mirror of
https://github.com/flynx/actions.js.git
synced 2025-10-29 10:20:09 +00:00
experimenting...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
6a6fd990f3
commit
9080ecd29c
36
actions.js
36
actions.js
@ -363,7 +363,7 @@ function(func){
|
|||||||
// Special args:
|
// Special args:
|
||||||
// IDENTIFIER
|
// IDENTIFIER
|
||||||
// - expanded to context[IDENTIFIER]
|
// - expanded to context[IDENTIFIER]
|
||||||
// $N - expanded to and instance of parseStringAction.Argument
|
// $N - expanded to an instance of parseStringAction.Argument
|
||||||
// ... - expanded to parseStringAction.ALLARGS (singleton)
|
// ... - expanded to parseStringAction.ALLARGS (singleton)
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
@ -489,12 +489,17 @@ parseStringAction.resolveArgs = function(context, action_args, call_args){
|
|||||||
|
|
||||||
return args
|
return args
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// XXX should this break if action does not exist???
|
||||||
parseStringAction.callAction = function(context, action, ...args){
|
parseStringAction.callAction = function(context, action, ...args){
|
||||||
action = typeof(action) == typeof('str') ?
|
action = typeof(action) == typeof('str') ?
|
||||||
this(action)
|
this(action)
|
||||||
: action
|
: action
|
||||||
return context[action.action]
|
// XXX should this break if action does not exist???
|
||||||
.apply(context, this.resolveArgs(context, action.arguments, args))
|
return context[action.action] instanceof Function ?
|
||||||
|
context[action.action]
|
||||||
|
.apply(context, this.resolveArgs(context, action.arguments, args))
|
||||||
|
: undefined
|
||||||
}
|
}
|
||||||
parseStringAction.applyAction = function(context, action, args){
|
parseStringAction.applyAction = function(context, action, args){
|
||||||
return this.callAction(context, action, ...args) }
|
return this.callAction(context, action, ...args) }
|
||||||
@ -881,6 +886,7 @@ Action.prototype.chainCall = function(context, inner){
|
|||||||
// XXX alias parsing is dependant on the action set, move this functionality
|
// XXX alias parsing is dependant on the action set, move this functionality
|
||||||
// to the ActionSet.alias(..) method/action...
|
// to the ActionSet.alias(..) method/action...
|
||||||
// XXX handle alias args and pass them to the target...
|
// XXX handle alias args and pass them to the target...
|
||||||
|
// XXX should an alias return a value???
|
||||||
var Alias =
|
var Alias =
|
||||||
module.Alias =
|
module.Alias =
|
||||||
function Alias(alias, doc, ldoc, attrs, target){
|
function Alias(alias, doc, ldoc, attrs, target){
|
||||||
@ -919,24 +925,14 @@ 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)
|
||||||
|
|
||||||
// XXX handle errors...
|
var p = parsed || this.parseStringAction(target)
|
||||||
this.parseStringAction.callAction(this, parsed || target, in_args)
|
|
||||||
|
|
||||||
/*/ parse the target...
|
// XXX should an alias return a value???
|
||||||
// XXX should we cache here???
|
//return p.action in this ?
|
||||||
var action = parsed || this.parseStringAction(target)
|
p.action in this ?
|
||||||
|
this.parseStringAction.callAction(this, p, in_args)
|
||||||
if(this[action.action] instanceof Function){
|
// error...
|
||||||
// handle args...
|
: console.error(`${alias}: Unknown alias target action: ${p.action}`)
|
||||||
var args = that.parseStringAction.resolveArgs(that, action.arguments, in_args)
|
|
||||||
|
|
||||||
// call the alias...
|
|
||||||
return this[action.action].apply(this, args)
|
|
||||||
}
|
|
||||||
|
|
||||||
// error...
|
|
||||||
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 }
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "ig-actions",
|
"name": "ig-actions",
|
||||||
"version": "3.14.0",
|
"version": "3.15.0",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "actions.js",
|
"main": "actions.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user