more string action refactroing...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2018-02-10 14:12:21 +03:00
parent b30681fad8
commit 6a6fd990f3

View File

@ -490,7 +490,9 @@ parseStringAction.resolveArgs = function(context, action_args, call_args){
return args return args
} }
parseStringAction.callAction = function(context, action, ...args){ parseStringAction.callAction = function(context, action, ...args){
var action = this(action) action = typeof(action) == typeof('str') ?
this(action)
: action
return context[action.action] return context[action.action]
.apply(context, this.resolveArgs(context, action.arguments, args)) .apply(context, this.resolveArgs(context, action.arguments, args))
} }
@ -917,11 +919,13 @@ function Alias(alias, doc, ldoc, attrs, target){
var that = this var that = this
var in_args = [].slice.call(arguments) var in_args = [].slice.call(arguments)
// parse the target... // XXX handle errors...
this.parseStringAction.callAction(this, parsed || target, in_args)
/*/ parse the target...
// XXX should we cache here??? // XXX should we cache here???
var action = parsed || this.parseStringAction(target) var action = parsed || this.parseStringAction(target)
// XXX use that.parseStringAction.call(this, target, in_args)
if(this[action.action] instanceof Function){ if(this[action.action] instanceof Function){
// handle args... // handle args...
var args = that.parseStringAction.resolveArgs(that, action.arguments, in_args) var args = that.parseStringAction.resolveArgs(that, action.arguments, in_args)
@ -932,6 +936,7 @@ function Alias(alias, doc, ldoc, attrs, target){
// error... // error...
console.error(`${alias}: alias to unknown action: ${action.action}`) console.error(`${alias}: alias to unknown action: ${action.action}`)
//*/
} }
func.toString = function(){ func.toString = function(){
return meth.alias.code || meth.alias } return meth.alias.code || meth.alias }