some refactoring + methods are now supported in action mro...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2017-09-07 16:53:41 +03:00
parent e9a657045a
commit 93cd8760a0
2 changed files with 21 additions and 28 deletions

View File

@ -1127,9 +1127,18 @@ module.MetaActions = {
// get the overloading action... // get the overloading action...
// NOTE: this will get all the handlers including the root // NOTE: this will get all the handlers including the root
// and the current handlers... // and the current handlers...
// NOTE: this will ignore "shadows" that are not actions... // NOTE: if this encounters a matching mormal method/function
if(cur.hasOwnProperty(name) && cur[name] instanceof Action){ // this will not search beyond it.
handlers.push(cur[name].func) if(cur.hasOwnProperty(name)){
// action -> collect...
if(cur[name] instanceof Action){
handlers.push(cur[name].func)
// function -> terminate chain...
} else if(cur[name] instanceof Function){
handlers.push(cur[name])
break
}
} }
cur = cur.__proto__ cur = cur.__proto__
@ -1876,6 +1885,7 @@ object.makeConstructor('ActionSet', MetaActions)
// //
// XXX add doc, ldoc, tags and save them to each action... // XXX add doc, ldoc, tags and save them to each action...
// XXX is .config processing correct here??? // XXX is .config processing correct here???
// XXX do we need to handle methods in a special way???
var Actions = var Actions =
module.Actions = module.Actions =
function Actions(a, b){ function Actions(a, b){
@ -1901,34 +1911,17 @@ function Actions(a, b){
// be included as-is... // be included as-is...
var arg = Object.getOwnPropertyDescriptor(obj, k).value var arg = Object.getOwnPropertyDescriptor(obj, k).value
// skip non-arrays... // action/alias...
if(arg == null if(arg instanceof Array
// XXX node?: for some magical reason when running this && (arg[arg.length-1] instanceof Function
// from node console instanceof tests fail...
//|| !(arg instanceof Array)
|| arg.constructor.name != 'Array'
// skip arrays where the last element of which is not a function...
//|| !(arg[arg.length-1] instanceof Function)){
// XXX EXPERIMENTAL...
// XXX for this to work we need obj to be an
// instance of ActionSet...
// ...need a way to check this yet not require obj
// to strictly be anything special, the problem is
// that the string action syntax is defined in the
// action-set, thus we need to know about it here...
|| !(arg[arg.length-1] instanceof Function
|| (typeof(arg[arg.length-1]) == typeof('str') || (typeof(arg[arg.length-1]) == typeof('str')
&& (arg[arg.length-1] == '' && (arg[arg.length-1] == ''
// XXX should this be stricter??? // XXX should this be stricter???
|| (obj.isStringAction || isStringAction)(arg[arg.length-1])))) ){ || (obj.isStringAction || isStringAction)(arg[arg.length-1])))) ){
//*/ obj[k] = arg[arg.length-1] instanceof Function ?
return (new Action(k, arg))
: (new Alias(k, arg))
} }
// create a new action/alias...
var a = obj[k] = arg[arg.length-1] instanceof Function ?
(new Action(k, arg))
: (new Alias(k, arg))
}) })
return obj return obj

View File

@ -1,6 +1,6 @@
{ {
"name": "ig-actions", "name": "ig-actions",
"version": "3.6.1", "version": "3.7.0",
"description": "", "description": "",
"main": "actions.js", "main": "actions.js",
"scripts": { "scripts": {