spidermonkey using JS_CallFunction for static function
Posted
by
supersuraccoon
on Stack Overflow
See other posts from Stack Overflow
or by supersuraccoon
Published on 2014-06-07T09:20:13Z
Indexed on
2014/06/07
9:24 UTC
Read the original article
Hit count: 249
JavaScript
|spidermonkey
JS_CallFunctionName can call a method of an object by name:
JSObject* obj;
JS_CallFunctionName(cx, obj, "doSomething", argc, vp, retVal);
The code above works fine if the "doSomething" is a function declared in the prototype of the "obj".
What I want to know is if there is a way to call a function that is a "class function".
I tried:
if(JS_HasProperty(getGlobalContext(), getGlobalObject(), "ClassToGet", &b)) {
print("OK");
}
and the output is "OK".
But when tried:
JS_GetProperty(getGlobalContext(), getGlobalObject(), "ClassToGet", &jsOwner);
if (jsOwner != JSVAL_VOID) {
}
the jsOwner is a JSVAL_VOID.
Maybe there is a function in SpiderMonkey can execute function in a JSClass ?
Any suggestion will be appreciated, thanks :)
© Stack Overflow or respective owner