I use the sample test but JSBinding is CCNode instead of CCObject.
JSBool js_constructor(JSContext* cx, uint32_t argc, jsval* vp){
cocos2d::CCLog("JS Constructor...");
if (argc == 0) {
JSB::JSBinding* cobj = new JSB::JSBinding();
if(!cobj) {
CCLog("ERROR, ERROR, ERROR");
}
cocos2d::CCNode* ccobj = dynamic_cast<cocos2d::CCNode*>(cobj);
if (ccobj) {
ccobj->autorelease();
}
TypeTest<JSB::JSBinding> t;
js_type_class_t* typeClass;
uint32_t typeId = t.s_id();
HASH_FIND_INT(_js_global_type_ht, &typeId, typeClass);
assert(typeClass); // crashes here sometimes. but not all the time. I don't know how to solve it.
JSObject* obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto);
JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(obj));
js_proxy_t* p = jsb_new_proxy(cobj, obj);
JS_AddNamedObjectRoot(cx, &p->obj, "JSB::JSBinding");
return JS_TRUE;
}
JS_ReportError(cx, "Wrong number of arguments: %d, was expecting: %d", argc, 0);
return JS_FALSE;
}
The app got rejected because of the crash.