JSRawObject
was a typedef for JSObject*
, so your usage is right. We did this, because in future version all APIs are going to take handles, so like JS::HandleObject. You might read about that upcoming change here: https://developer.mozilla.org/en-US/docs/SpiderMonkey/31#Migrating_to_SpiderMonkey_31
I think you have to use the return value of JS_BindCallable
and overwrite "finish" with it. Actually you might do something like this:
//define a function on an object which is bound to the object it is defined on
JSBool JS_DefineBoundFunction(JSContext *cx, JSObject *obj, const char *name,
JSNative call, unsigned int nargs, unsigned int attrs) {
JSFunction *func = JS_NewFunction(cx, call, nargs, 0, NULL, name);
if (!func) {
return JS_FALSE;
}
JSObject *funcObj = JS_GetFunctionObject(func);
if (!funcObj) {
return JS_FALSE;
}
JSObject *boundFuncObj = JS_BindCallable(cx, funcObj, obj);
if (!boundFuncObj) {
return JS_FALSE;
}
return JS_DefineProperty(cx, obj, name,
OBJECT_TO_JSVAL(boundFuncObj),
NULL, NULL, attrs);
}