// jsb.create_prototype(superProto);
bool jsb_create_prototype(JSContext *cx, uint32_t argc, jsval *vp)
{
jsval *argv = JS_ARGV(cx, vp);
JSObject *super_prototype;
super_prototype = JSVAL_TO_OBJECT(argv[0]);
const JSClass *super_class = JS_GetClass(super_prototype);
JSObject *global = ScriptingCore::getInstance()->getGlobalObject();
JSClass *js_class;
js_class = (JSClass *)calloc(1, sizeof(JSClass));
js_class->name = "";
js_class->addProperty = JS_PropertyStub;
js_class->delProperty = JS_DeletePropertyStub;
js_class->getProperty = JS_PropertyStub;
js_class->setProperty = JS_StrictPropertyStub;
js_class->enumerate = JS_EnumerateStub;
js_class->resolve = JS_ResolveStub;
js_class->convert = JS_ConvertStub;
// Important!
js_class->finalize = super_class->finalize;
js_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2);
JSObject *jsb_prototype = JS_InitClass(
cx, global,
super_prototype,
js_class,
NULL, 0, // constructor
NULL, NULL, NULL, NULL);
jsval jsret = JSVAL_NULL;
if (jsb_prototype) {
jsret = OBJECT_TO_JSVAL(jsb_prototype);
}
JS_SET_RVAL(cx, vp, jsret);
return true;
}
--
You received this message because you are subscribed to the Google Groups "cocos2d JS development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cocos2d-js-dev...@googlegroups.com.
To post to this group, send email to cocos2d-...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.