Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Make nqp::isinvokable respect nqp::setinvokespec.
  • Loading branch information
pmurias committed Feb 14, 2015
1 parent dd4e123 commit d2e9220
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/vm/js/nqp-runtime/core.js
Expand Up @@ -29,7 +29,7 @@ op.getcomp = function(lang) {
};

op.isinvokable = function(obj) {
return (obj instanceof CodeRef ? 1 : 0);
return (obj instanceof CodeRef || (obj._STable && obj._STable.invocationSpec) ? 1 : 0);
};

op.escape = function(str) {
Expand Down
1 change: 1 addition & 0 deletions src/vm/js/nqp-runtime/sixmodel.js
Expand Up @@ -46,6 +46,7 @@ STable.prototype.setinvokespec = function(classHandle, attrName, invocationHandl
this.obj_constructor.prototype.$apply = function _(args) {
return this[attrName].$apply(args);
};
this.invocationSpec = {classHandle: classHandle, attrName: attrName, invocationHandler: invocationHandler};
};

function injectMethod(proto, name, method) {
Expand Down
5 changes: 5 additions & 0 deletions t/nqp/70-invokespec.t
Expand Up @@ -25,3 +25,8 @@ $bar.set_code_ref(sub () {1001});
$bar.set_code_ref_differently(sub () {1002});
ok($bar() == 1002,"setinvokespec with a attribute in a subclass");

class Baz {
}

ok(nqp::isinvokable(Foo) == 1, "nqp::isinvokable works on objects that have a set invokespec");
ok(nqp::isinvokable(Baz) == 0, "nqp::isinvokable works on objects that don't have a set invokespec");

0 comments on commit d2e9220

Please sign in to comment.