When I use JS_DefineFunctions my functions work. But when I use
JS_DefineFunction to add a method to a class, I need to call
JS_DefineProperty afterwards, otherwise I get 'x is not a function'. Is
it normal that I need to call JS_DefineProperty?
This is how I use JS_DefineFunction:
JSFunction* fun;
fun = JS_DefineFunction(cx, obj, methodName, MethodCallback, args,
JSPROP_READONLY | JSPROP_PERMANENT);
m_objectMethods.push_back(&method);
jsval v = INT_TO_JSVAL(m_objectMethods.size() - 1);
JS_SetReservedSlot(cx, JS_GetFunctionObject(fun), 0, v); \
JS_DefineProperty(cx, obj, methodName,
OBJECT_TO_JSVAL(JS_GetFunctionObject(fun)), JS_PropertyStub,
JS_PropertyStub, JSPROP_READONLY | JSPROP_PERMANENT);
I can't use JS_DefineFunctions because I need to set a slot.
Franky.
_______________________________________________
dev-tech-js-engine mailing list
dev-tech-js-engine@...
https://lists.mozilla.org/listinfo/dev-tech-js-engine