spidermonkey using JS_CallFunction for static function
- by supersuraccoon
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 :)