From e891b03eeead17b805ca9d4ec12e7c1fe171a2f3 Mon Sep 17 00:00:00 2001 From: CocosRobot Date: Tue, 1 Dec 2015 04:32:19 +0000 Subject: [PATCH] [ci skip][AUTO]: updating luabinding & jsbinding automatically --- .../auto/api/jsb_cocos2dx_auto_api.js | 10 + .../auto/api/jsb_cocos2dx_ui_auto_api.js | 90 + .../js-bindings/auto/jsb_cocos2dx_3d_auto.cpp | 353 +- .../auto/jsb_cocos2dx_3d_extension_auto.cpp | 54 +- .../auto/jsb_cocos2dx_audioengine_auto.cpp | 76 +- .../js-bindings/auto/jsb_cocos2dx_auto.cpp | 7182 +++++------------ .../js-bindings/auto/jsb_cocos2dx_auto.hpp | 1 + .../auto/jsb_cocos2dx_builder_auto.cpp | 126 +- .../jsb_cocos2dx_experimental_video_auto.cpp | 28 +- ...jsb_cocos2dx_experimental_webView_auto.cpp | 28 +- .../auto/jsb_cocos2dx_extension_auto.cpp | 576 +- .../auto/jsb_cocos2dx_navmesh_auto.cpp | 85 +- .../auto/jsb_cocos2dx_physics3d_auto.cpp | 378 +- .../auto/jsb_cocos2dx_spine_auto.cpp | 130 +- .../auto/jsb_cocos2dx_studio_auto.cpp | 1242 +-- .../js-bindings/auto/jsb_cocos2dx_ui_auto.cpp | 1465 ++-- .../js-bindings/auto/jsb_cocos2dx_ui_auto.hpp | 9 + 17 files changed, 3820 insertions(+), 8013 deletions(-) diff --git a/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_auto_api.js b/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_auto_api.js index 6d0eca5575..7f5fbcb0f2 100644 --- a/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_auto_api.js +++ b/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_auto_api.js @@ -13513,6 +13513,16 @@ isSelected : function ( return false; }, +/** + * @method setCallback + * @param {function} arg0 + */ +setCallback : function ( +func +) +{ +}, + /** * @method unselected */ diff --git a/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_ui_auto_api.js b/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_ui_auto_api.js index a1ac1bd1b4..900ebe9f42 100644 --- a/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_ui_auto_api.js +++ b/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_ui_auto_api.js @@ -778,6 +778,16 @@ getCallbackType : function ( return ; }, +/** + * @method addTouchEventListener + * @param {function} arg0 + */ +addTouchEventListener : function ( +func +) +{ +}, + /** * @method getTouchEndPosition * @return {vec2_object} @@ -2007,6 +2017,16 @@ texturerestype */ ccui.CheckBox = { +/** + * @method addEventListener + * @param {function} arg0 + */ +addEventListener : function ( +func +) +{ +}, + /** * @method create * @param {String|String} str @@ -2055,6 +2075,16 @@ CheckBox : function ( */ ccui.RadioButton = { +/** + * @method addEventListener + * @param {function} arg0 + */ +addEventListener : function ( +func +) +{ +}, + /** * @method create * @param {String|String} str @@ -2153,6 +2183,16 @@ int { }, +/** + * @method addEventListener + * @param {function} arg0 + */ +addEventListener : function ( +func +) +{ +}, + /** * @method removeAllRadioButtons */ @@ -3117,6 +3157,16 @@ float { }, +/** + * @method addEventListener + * @param {function} arg0 + */ +addEventListener : function ( +func +) +{ +}, + /** * @method setScrollBarAutoHideTime * @param {float} arg0 @@ -3561,6 +3611,16 @@ bool { }, +/** + * @method addEventListener + * @param {function} arg0 + */ +addEventListener : function ( +func +) +{ +}, + /** * @method doLayout */ @@ -3899,6 +3959,16 @@ texturerestype { }, +/** + * @method addEventListener + * @param {function} arg0 + */ +addEventListener : function ( +func +) +{ +}, + /** * @method setMaxPercent * @param {int} arg0 @@ -4521,6 +4591,16 @@ textvalignment { }, +/** + * @method addEventListener + * @param {function} arg0 + */ +addEventListener : function ( +func +) +{ +}, + /** * @method didNotSelectSelf */ @@ -5001,6 +5081,16 @@ widget { }, +/** + * @method addEventListener + * @param {function} arg0 + */ +addEventListener : function ( +func +) +{ +}, + /** * @method setCurrentPageIndex * @param {long} arg0 diff --git a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_3d_auto.cpp b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_3d_auto.cpp index f5e50cb934..cb5b5f16bb 100644 --- a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_3d_auto.cpp +++ b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_3d_auto.cpp @@ -21,8 +21,8 @@ static bool dummy_constructor(JSContext *cx, uint32_t argc, jsval *vp) { typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject _tmp(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(_tmp)); @@ -200,8 +200,8 @@ bool js_cocos2dx_3d_Animation3D_constructor(JSContext *cx, uint32_t argc, jsval CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -248,30 +248,17 @@ void js_register_cocos2dx_3d_Animation3D(JSContext *cx, JS::HandleObject global) jsb_cocos2d_Animation3D_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocos2d_Animation3D_class, js_cocos2dx_3d_Animation3D_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "Animation3D", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_Animation3D_class; - p->proto = jsb_cocos2d_Animation3D_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_Animation3D_prototype); + jsb_register_class(cx, jsb_cocos2d_Animation3D_class, proto, JS::NullPtr()); } JSClass *jsb_cocos2d_Animate3D_class; @@ -390,7 +377,7 @@ bool js_cocos2dx_3d_Animate3D_initWithFrames(JSContext *cx, uint32_t argc, jsval if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Animation3D*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -454,7 +441,7 @@ bool js_cocos2dx_3d_Animate3D_init(JSContext *cx, uint32_t argc, jsval *vp) JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::Animate3D *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_Animate3D_init : Invalid Native Object"); @@ -465,7 +452,7 @@ bool js_cocos2dx_3d_Animate3D_init(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Animation3D*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -492,7 +479,7 @@ bool js_cocos2dx_3d_Animate3D_init(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Animation3D*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -577,7 +564,7 @@ bool js_cocos2dx_3d_Animate3D_create(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Animation3D*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -611,7 +598,7 @@ bool js_cocos2dx_3d_Animate3D_create(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Animation3D*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -660,7 +647,7 @@ bool js_cocos2dx_3d_Animate3D_createWithFrames(JSContext *cx, uint32_t argc, jsv if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Animation3D*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -690,7 +677,7 @@ bool js_cocos2dx_3d_Animate3D_createWithFrames(JSContext *cx, uint32_t argc, jsv if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Animation3D*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -748,8 +735,8 @@ bool js_cocos2dx_3d_Animate3D_constructor(JSContext *cx, uint32_t argc, jsval *v CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -807,32 +794,20 @@ void js_register_cocos2dx_3d_Animate3D(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ActionInterval_prototype); jsb_cocos2d_Animate3D_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ActionInterval_prototype), + parent_proto, jsb_cocos2d_Animate3D_class, js_cocos2dx_3d_Animate3D_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "Animate3D", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_Animate3D_class; - p->proto = jsb_cocos2d_Animate3D_prototype; - p->parentProto = jsb_cocos2d_ActionInterval_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_Animate3D_prototype); + jsb_register_class(cx, jsb_cocos2d_Animate3D_class, proto, parent_proto); } JSClass *jsb_cocos2d_TextureCube_class; @@ -907,8 +882,8 @@ bool js_cocos2dx_3d_TextureCube_constructor(JSContext *cx, uint32_t argc, jsval CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -952,32 +927,20 @@ void js_register_cocos2dx_3d_TextureCube(JSContext *cx, JS::HandleObject global) JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Texture2D_prototype); jsb_cocos2d_TextureCube_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Texture2D_prototype), + parent_proto, jsb_cocos2d_TextureCube_class, js_cocos2dx_3d_TextureCube_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "TextureCube", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_TextureCube_class; - p->proto = jsb_cocos2d_TextureCube_prototype; - p->parentProto = jsb_cocos2d_Texture2D_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_TextureCube_prototype); + jsb_register_class(cx, jsb_cocos2d_TextureCube_class, proto, parent_proto); } JSClass *jsb_cocos2d_AttachNode_class; @@ -993,7 +956,7 @@ bool js_cocos2dx_3d_AttachNode_create(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Bone3D*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -1032,8 +995,8 @@ bool js_cocos2dx_3d_AttachNode_constructor(JSContext *cx, uint32_t argc, jsval * CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -1076,32 +1039,20 @@ void js_register_cocos2dx_3d_AttachNode(JSContext *cx, JS::HandleObject global) JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Node_prototype); jsb_cocos2d_AttachNode_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Node_prototype), + parent_proto, jsb_cocos2d_AttachNode_class, js_cocos2dx_3d_AttachNode_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "AttachNode", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_AttachNode_class; - p->proto = jsb_cocos2d_AttachNode_prototype; - p->parentProto = jsb_cocos2d_Node_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_AttachNode_prototype); + jsb_register_class(cx, jsb_cocos2d_AttachNode_class, proto, parent_proto); } JSClass *jsb_cocos2d_BillBoard_class; @@ -1288,7 +1239,7 @@ bool js_cocos2dx_3d_BillBoard_createWithTexture(JSContext *cx, uint32_t argc, js if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -1314,7 +1265,7 @@ bool js_cocos2dx_3d_BillBoard_createWithTexture(JSContext *cx, uint32_t argc, js if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -1354,8 +1305,8 @@ bool js_cocos2dx_3d_BillBoard_constructor(JSContext *cx, uint32_t argc, jsval *v CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -1401,32 +1352,20 @@ void js_register_cocos2dx_3d_BillBoard(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Sprite_prototype); jsb_cocos2d_BillBoard_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Sprite_prototype), + parent_proto, jsb_cocos2d_BillBoard_class, js_cocos2dx_3d_BillBoard_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "BillBoard", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_BillBoard_class; - p->proto = jsb_cocos2d_BillBoard_prototype; - p->parentProto = jsb_cocos2d_Sprite_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_BillBoard_prototype); + jsb_register_class(cx, jsb_cocos2d_BillBoard_class, proto, parent_proto); } JSClass *jsb_cocos2d_Mesh_class; @@ -1439,7 +1378,7 @@ bool js_cocos2dx_3d_Mesh_setTexture(JSContext *cx, uint32_t argc, jsval *vp) JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::Mesh *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_Mesh_setTexture : Invalid Native Object"); @@ -1450,7 +1389,7 @@ bool js_cocos2dx_3d_Mesh_setTexture(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -1583,7 +1522,7 @@ bool js_cocos2dx_3d_Mesh_setMaterial(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Material*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -1809,7 +1748,7 @@ bool js_cocos2dx_3d_Mesh_setMeshIndexData(JSContext *cx, uint32_t argc, jsval *v if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::MeshIndexData*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -1913,7 +1852,7 @@ bool js_cocos2dx_3d_Mesh_setSkin(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::MeshSkin*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -1977,7 +1916,7 @@ bool js_cocos2dx_3d_Mesh_setGLProgramState(JSContext *cx, uint32_t argc, jsval * if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::GLProgramState*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -2027,8 +1966,8 @@ bool js_cocos2dx_3d_Mesh_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -2094,30 +2033,17 @@ void js_register_cocos2dx_3d_Mesh(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_Mesh_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocos2d_Mesh_class, js_cocos2dx_3d_Mesh_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "Mesh", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_Mesh_class; - p->proto = jsb_cocos2d_Mesh_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_Mesh_prototype); + jsb_register_class(cx, jsb_cocos2d_Mesh_class, proto, JS::NullPtr()); } JSClass *jsb_cocos2d_Skeleton3D_class; @@ -2153,7 +2079,7 @@ bool js_cocos2dx_3d_Skeleton3D_addBone(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Bone3D*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -2302,7 +2228,7 @@ bool js_cocos2dx_3d_Skeleton3D_getBoneIndex(JSContext *cx, uint32_t argc, jsval if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Bone3D*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -2352,8 +2278,8 @@ bool js_cocos2dx_3d_Skeleton3D_constructor(JSContext *cx, uint32_t argc, jsval * CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -2402,30 +2328,17 @@ void js_register_cocos2dx_3d_Skeleton3D(JSContext *cx, JS::HandleObject global) jsb_cocos2d_Skeleton3D_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocos2d_Skeleton3D_class, js_cocos2dx_3d_Skeleton3D_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "Skeleton3D", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_Skeleton3D_class; - p->proto = jsb_cocos2d_Skeleton3D_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_Skeleton3D_prototype); + jsb_register_class(cx, jsb_cocos2d_Skeleton3D_class, proto, JS::NullPtr()); } JSClass *jsb_cocos2d_Skybox_class; @@ -2493,7 +2406,7 @@ bool js_cocos2dx_3d_Skybox_setTexture(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::TextureCube*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -2582,8 +2495,8 @@ bool js_cocos2dx_3d_Skybox_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -2629,32 +2542,20 @@ void js_register_cocos2dx_3d_Skybox(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Node_prototype); jsb_cocos2d_Skybox_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Node_prototype), + parent_proto, jsb_cocos2d_Skybox_class, js_cocos2dx_3d_Skybox_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "Skybox", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_Skybox_class; - p->proto = jsb_cocos2d_Skybox_prototype; - p->parentProto = jsb_cocos2d_Node_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_Skybox_prototype); + jsb_register_class(cx, jsb_cocos2d_Skybox_class, proto, parent_proto); } JSClass *jsb_cocos2d_Sprite3D_class; @@ -2687,7 +2588,7 @@ bool js_cocos2dx_3d_Sprite3D_setTexture(JSContext *cx, uint32_t argc, jsval *vp) JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::Sprite3D *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_Sprite3D_setTexture : Invalid Native Object"); @@ -2698,7 +2599,7 @@ bool js_cocos2dx_3d_Sprite3D_setTexture(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -2860,7 +2761,7 @@ bool js_cocos2dx_3d_Sprite3D_addMesh(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Mesh*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -2897,7 +2798,7 @@ bool js_cocos2dx_3d_Sprite3D_setMaterial(JSContext *cx, uint32_t argc, jsval *vp JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::Sprite3D *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_Sprite3D_setMaterial : Invalid Native Object"); @@ -2908,7 +2809,7 @@ bool js_cocos2dx_3d_Sprite3D_setMaterial(JSContext *cx, uint32_t argc, jsval *vp if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Material*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -2930,7 +2831,7 @@ bool js_cocos2dx_3d_Sprite3D_setMaterial(JSContext *cx, uint32_t argc, jsval *vp if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Material*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -3088,7 +2989,7 @@ bool js_cocos2dx_3d_Sprite3D_createNode(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -3555,8 +3456,8 @@ bool js_cocos2dx_3d_Sprite3D_constructor(JSContext *cx, uint32_t argc, jsval *vp CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -3648,32 +3549,20 @@ void js_register_cocos2dx_3d_Sprite3D(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Node_prototype); jsb_cocos2d_Sprite3D_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Node_prototype), + parent_proto, jsb_cocos2d_Sprite3D_class, js_cocos2dx_3d_Sprite3D_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "Sprite3D", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_Sprite3D_class; - p->proto = jsb_cocos2d_Sprite3D_prototype; - p->parentProto = jsb_cocos2d_Node_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_Sprite3D_prototype); + jsb_register_class(cx, jsb_cocos2d_Sprite3D_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { jsb.Sprite3D.extend = cc.Class.extend; })()"); } @@ -3785,30 +3674,17 @@ void js_register_cocos2dx_3d_Sprite3DCache(JSContext *cx, JS::HandleObject globa jsb_cocos2d_Sprite3DCache_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocos2d_Sprite3DCache_class, empty_constructor, 0, properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "Sprite3DCache", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_Sprite3DCache_class; - p->proto = jsb_cocos2d_Sprite3DCache_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_Sprite3DCache_prototype); + jsb_register_class(cx, jsb_cocos2d_Sprite3DCache_class, proto, JS::NullPtr()); } JSClass *jsb_cocos2d_Terrain_class; @@ -3953,7 +3829,7 @@ bool js_cocos2dx_3d_Terrain_setAlphaMap(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -4052,7 +3928,7 @@ bool js_cocos2dx_3d_Terrain_getHeight(JSContext *cx, uint32_t argc, jsval *vp) JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::Terrain *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_Terrain_getHeight : Invalid Native Object"); @@ -4079,7 +3955,7 @@ bool js_cocos2dx_3d_Terrain_getHeight(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Vec3*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -4122,7 +3998,7 @@ bool js_cocos2dx_3d_Terrain_getHeight(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(2).isNull()) { arg2 = nullptr; break; } if (!args.get(2).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(2).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(2).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg2 = (cocos2d::Vec3*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg2, cx, false, "Invalid Native Object"); @@ -4212,7 +4088,7 @@ bool js_cocos2dx_3d_Terrain_getIntersectionPoint(JSContext *cx, uint32_t argc, j JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::Terrain *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_Terrain_getIntersectionPoint : Invalid Native Object"); @@ -4404,8 +4280,8 @@ bool js_cocos2dx_3d_Terrain_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -4468,32 +4344,20 @@ void js_register_cocos2dx_3d_Terrain(JSContext *cx, JS::HandleObject global) { JSFunctionSpec *st_funcs = NULL; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Node_prototype); jsb_cocos2d_Terrain_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Node_prototype), + parent_proto, jsb_cocos2d_Terrain_class, js_cocos2dx_3d_Terrain_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "Terrain", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_Terrain_class; - p->proto = jsb_cocos2d_Terrain_prototype; - p->parentProto = jsb_cocos2d_Node_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_Terrain_prototype); + jsb_register_class(cx, jsb_cocos2d_Terrain_class, proto, parent_proto); } JSClass *jsb_cocos2d_Bundle3D_class; @@ -4687,7 +4551,7 @@ bool js_cocos2dx_3d_Bundle3D_destroyBundle(JSContext *cx, uint32_t argc, jsval * if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Bundle3D*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -4761,8 +4625,8 @@ bool js_cocos2dx_3d_Bundle3D_constructor(JSContext *cx, uint32_t argc, jsval *vp CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -4777,7 +4641,9 @@ void js_cocos2d_Bundle3D_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (Bundle3D)", obj); js_proxy_t* nproxy; js_proxy_t* jsproxy; - jsproxy = jsb_get_js_proxy(obj); + JSContext *cx = ScriptingCore::getInstance()->getGlobalContext(); + JS::RootedObject jsobj(cx, obj); + jsproxy = jsb_get_js_proxy(jsobj); if (jsproxy) { cocos2d::Bundle3D *nobj = static_cast(jsproxy->ptr); nproxy = jsb_get_native_proxy(jsproxy->ptr); @@ -4827,30 +4693,17 @@ void js_register_cocos2dx_3d_Bundle3D(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_Bundle3D_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocos2d_Bundle3D_class, js_cocos2dx_3d_Bundle3D_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "Bundle3D", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_Bundle3D_class; - p->proto = jsb_cocos2d_Bundle3D_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_Bundle3D_prototype); + jsb_register_class(cx, jsb_cocos2d_Bundle3D_class, proto, JS::NullPtr()); } void register_all_cocos2dx_3d(JSContext* cx, JS::HandleObject obj) { diff --git a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_3d_extension_auto.cpp b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_3d_extension_auto.cpp index d87d9dc80b..447025172b 100644 --- a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_3d_extension_auto.cpp +++ b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_3d_extension_auto.cpp @@ -19,8 +19,8 @@ static bool dummy_constructor(JSContext *cx, uint32_t argc, jsval *vp) { typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject _tmp(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(_tmp)); @@ -312,8 +312,8 @@ bool js_cocos2dx_3d_extension_ParticleSystem3D_constructor(JSContext *cx, uint32 CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -367,32 +367,20 @@ void js_register_cocos2dx_3d_extension_ParticleSystem3D(JSContext *cx, JS::Handl JSFunctionSpec *st_funcs = NULL; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Node_prototype); jsb_cocos2d_ParticleSystem3D_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Node_prototype), + parent_proto, jsb_cocos2d_ParticleSystem3D_class, js_cocos2dx_3d_extension_ParticleSystem3D_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "ParticleSystem3D", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_ParticleSystem3D_class; - p->proto = jsb_cocos2d_ParticleSystem3D_prototype; - p->parentProto = jsb_cocos2d_Node_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ParticleSystem3D_prototype); + jsb_register_class(cx, jsb_cocos2d_ParticleSystem3D_class, proto, parent_proto); } JSClass *jsb_cocos2d_PUParticleSystem3D_class; @@ -777,7 +765,7 @@ bool js_cocos2dx_3d_extension_PUParticleSystem3D_copyAttributesTo(JSContext *cx, if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::PUParticleSystem3D*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -1145,8 +1133,8 @@ bool js_cocos2dx_3d_extension_PUParticleSystem3D_constructor(JSContext *cx, uint CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -1223,32 +1211,20 @@ void js_register_cocos2dx_3d_extension_PUParticleSystem3D(JSContext *cx, JS::Han JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ParticleSystem3D_prototype); jsb_cocos2d_PUParticleSystem3D_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ParticleSystem3D_prototype), + parent_proto, jsb_cocos2d_PUParticleSystem3D_class, js_cocos2dx_3d_extension_PUParticleSystem3D_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "PUParticleSystem3D", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_PUParticleSystem3D_class; - p->proto = jsb_cocos2d_PUParticleSystem3D_prototype; - p->parentProto = jsb_cocos2d_ParticleSystem3D_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_PUParticleSystem3D_prototype); + jsb_register_class(cx, jsb_cocos2d_PUParticleSystem3D_class, proto, parent_proto); } void register_all_cocos2dx_3d_extension(JSContext* cx, JS::HandleObject obj) { diff --git a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_audioengine_auto.cpp b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_audioengine_auto.cpp index 9cf3a8b792..3c20615156 100644 --- a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_audioengine_auto.cpp +++ b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_audioengine_auto.cpp @@ -20,8 +20,8 @@ static bool dummy_constructor(JSContext *cx, uint32_t argc, jsval *vp) { typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject _tmp(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(_tmp)); @@ -48,7 +48,8 @@ JSObject *jsb_cocos2d_experimental_AudioProfile_prototype; bool js_cocos2dx_audioengine_AudioProfile_get_name(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - js_proxy_t *proxy = jsb_get_js_proxy(args.thisv().toObjectOrNull()); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(jsthis); cocos2d::experimental::AudioProfile* cobj = (cocos2d::experimental::AudioProfile *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_audioengine_AudioProfile_get_name : Invalid Native Object"); @@ -59,7 +60,8 @@ bool js_cocos2dx_audioengine_AudioProfile_get_name(JSContext *cx, uint32_t argc, bool js_cocos2dx_audioengine_AudioProfile_set_name(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - js_proxy_t *proxy = jsb_get_js_proxy(args.thisv().toObjectOrNull()); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(jsthis); cocos2d::experimental::AudioProfile* cobj = (cocos2d::experimental::AudioProfile *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_audioengine_AudioProfile_set_name : Invalid Native Object"); @@ -73,7 +75,8 @@ bool js_cocos2dx_audioengine_AudioProfile_set_name(JSContext *cx, uint32_t argc, bool js_cocos2dx_audioengine_AudioProfile_get_maxInstances(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - js_proxy_t *proxy = jsb_get_js_proxy(args.thisv().toObjectOrNull()); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(jsthis); cocos2d::experimental::AudioProfile* cobj = (cocos2d::experimental::AudioProfile *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_audioengine_AudioProfile_get_maxInstances : Invalid Native Object"); @@ -84,7 +87,8 @@ bool js_cocos2dx_audioengine_AudioProfile_get_maxInstances(JSContext *cx, uint32 bool js_cocos2dx_audioengine_AudioProfile_set_maxInstances(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - js_proxy_t *proxy = jsb_get_js_proxy(args.thisv().toObjectOrNull()); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(jsthis); cocos2d::experimental::AudioProfile* cobj = (cocos2d::experimental::AudioProfile *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_audioengine_AudioProfile_set_maxInstances : Invalid Native Object"); @@ -98,7 +102,8 @@ bool js_cocos2dx_audioengine_AudioProfile_set_maxInstances(JSContext *cx, uint32 bool js_cocos2dx_audioengine_AudioProfile_get_minDelay(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - js_proxy_t *proxy = jsb_get_js_proxy(args.thisv().toObjectOrNull()); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(jsthis); cocos2d::experimental::AudioProfile* cobj = (cocos2d::experimental::AudioProfile *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_audioengine_AudioProfile_get_minDelay : Invalid Native Object"); @@ -109,7 +114,8 @@ bool js_cocos2dx_audioengine_AudioProfile_get_minDelay(JSContext *cx, uint32_t a bool js_cocos2dx_audioengine_AudioProfile_set_minDelay(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - js_proxy_t *proxy = jsb_get_js_proxy(args.thisv().toObjectOrNull()); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(jsthis); cocos2d::experimental::AudioProfile* cobj = (cocos2d::experimental::AudioProfile *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_audioengine_AudioProfile_set_minDelay : Invalid Native Object"); @@ -132,8 +138,8 @@ bool js_cocos2dx_audioengine_AudioProfile_constructor(JSContext *cx, uint32_t ar CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -148,7 +154,9 @@ void js_cocos2d_experimental_AudioProfile_finalize(JSFreeOp *fop, JSObject *obj) CCLOGINFO("jsbindings: finalizing JS object %p (AudioProfile)", obj); js_proxy_t* nproxy; js_proxy_t* jsproxy; - jsproxy = jsb_get_js_proxy(obj); + JSContext *cx = ScriptingCore::getInstance()->getGlobalContext(); + JS::RootedObject jsobj(cx, obj); + jsproxy = jsb_get_js_proxy(jsobj); if (jsproxy) { cocos2d::experimental::AudioProfile *nobj = static_cast(jsproxy->ptr); nproxy = jsb_get_native_proxy(jsproxy->ptr); @@ -189,30 +197,17 @@ void js_register_cocos2dx_audioengine_AudioProfile(JSContext *cx, JS::HandleObje jsb_cocos2d_experimental_AudioProfile_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocos2d_experimental_AudioProfile_class, js_cocos2dx_audioengine_AudioProfile_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "AudioProfile", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_experimental_AudioProfile_class; - p->proto = jsb_cocos2d_experimental_AudioProfile_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_experimental_AudioProfile_prototype); + jsb_register_class(cx, jsb_cocos2d_experimental_AudioProfile_class, proto, JS::NullPtr()); } JSClass *jsb_cocos2d_experimental_AudioEngine_class; @@ -462,7 +457,8 @@ bool js_cocos2dx_audioengine_AudioEngine_preload(JSContext *cx, uint32_t argc, j do { if(JS_TypeOfValue(cx, args.get(1)) == JSTYPE_FUNCTION) { - std::shared_ptr func(new JSFunctionWrapper(cx, args.thisv().toObjectOrNull(), args.get(1))); + JS::RootedObject jstarget(cx, args.thisv().toObjectOrNull()); + std::shared_ptr func(new JSFunctionWrapper(cx, jstarget, args.get(1))); auto lambda = [=](bool larg0) -> void { JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET jsval largv[1]; @@ -551,7 +547,7 @@ bool js_cocos2dx_audioengine_AudioEngine_play2d(JSContext *cx, uint32_t argc, js if (args.get(3).isNull()) { arg3 = nullptr; break; } if (!args.get(3).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(3).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(3).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg3 = (const cocos2d::experimental::AudioProfile*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg3, cx, false, "Invalid Native Object"); @@ -685,7 +681,8 @@ bool js_cocos2dx_audioengine_AudioEngine_setFinishCallback(JSContext *cx, uint32 do { if(JS_TypeOfValue(cx, args.get(1)) == JSTYPE_FUNCTION) { - std::shared_ptr func(new JSFunctionWrapper(cx, args.thisv().toObjectOrNull(), args.get(1))); + JS::RootedObject jstarget(cx, args.thisv().toObjectOrNull()); + std::shared_ptr func(new JSFunctionWrapper(cx, jstarget, args.get(1))); auto lambda = [=](int larg0, const std::basic_string & larg1) -> void { JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET jsval largv[2]; @@ -818,30 +815,17 @@ void js_register_cocos2dx_audioengine_AudioEngine(JSContext *cx, JS::HandleObjec jsb_cocos2d_experimental_AudioEngine_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocos2d_experimental_AudioEngine_class, empty_constructor, 0, properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "AudioEngine", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_experimental_AudioEngine_class; - p->proto = jsb_cocos2d_experimental_AudioEngine_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_experimental_AudioEngine_prototype); + jsb_register_class(cx, jsb_cocos2d_experimental_AudioEngine_class, proto, JS::NullPtr()); } void register_all_cocos2dx_audioengine(JSContext* cx, JS::HandleObject obj) { diff --git a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_auto.cpp b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_auto.cpp index 226143358d..4cf53c35bc 100644 --- a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_auto.cpp +++ b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_auto.cpp @@ -23,8 +23,8 @@ static bool dummy_constructor(JSContext *cx, uint32_t argc, jsval *vp) { typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject _tmp(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(_tmp)); @@ -116,7 +116,7 @@ bool js_cocos2dx_Texture2D_initWithImage(JSContext *cx, uint32_t argc, jsval *vp JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::Texture2D *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Texture2D_initWithImage : Invalid Native Object"); @@ -127,7 +127,7 @@ bool js_cocos2dx_Texture2D_initWithImage(JSContext *cx, uint32_t argc, jsval *vp if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Image*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -151,7 +151,7 @@ bool js_cocos2dx_Texture2D_initWithImage(JSContext *cx, uint32_t argc, jsval *vp if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Image*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -182,7 +182,7 @@ bool js_cocos2dx_Texture2D_setGLProgram(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::GLProgram*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -304,7 +304,7 @@ bool js_cocos2dx_Texture2D_getBitsPerPixelForFormat(JSContext *cx, uint32_t argc JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::Texture2D *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Texture2D_getBitsPerPixelForFormat : Invalid Native Object"); @@ -359,7 +359,7 @@ bool js_cocos2dx_Texture2D_initWithString(JSContext *cx, uint32_t argc, jsval *v JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::Texture2D *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Texture2D_initWithString : Invalid Native Object"); @@ -758,8 +758,8 @@ bool js_cocos2dx_Texture2D_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -829,30 +829,17 @@ void js_register_cocos2dx_Texture2D(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_Texture2D_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocos2d_Texture2D_class, js_cocos2dx_Texture2D_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "Texture2D", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_Texture2D_class; - p->proto = jsb_cocos2d_Texture2D_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_Texture2D_prototype); + jsb_register_class(cx, jsb_cocos2d_Texture2D_class, proto, JS::NullPtr()); } JSClass *jsb_cocos2d_Touch_class; @@ -1042,8 +1029,8 @@ bool js_cocos2dx_Touch_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -1092,30 +1079,17 @@ void js_register_cocos2dx_Touch(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_Touch_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocos2d_Touch_class, js_cocos2dx_Touch_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "Touch", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_Touch_class; - p->proto = jsb_cocos2d_Touch_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_Touch_prototype); + jsb_register_class(cx, jsb_cocos2d_Touch_class, proto, JS::NullPtr()); } JSClass *jsb_cocos2d_Event_class; @@ -1217,8 +1191,8 @@ bool js_cocos2dx_Event_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -1262,30 +1236,17 @@ void js_register_cocos2dx_Event(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_Event_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocos2d_Event_class, js_cocos2dx_Event_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "Event", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_Event_class; - p->proto = jsb_cocos2d_Event_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_Event_prototype); + jsb_register_class(cx, jsb_cocos2d_Event_class, proto, JS::NullPtr()); } JSClass *jsb_cocos2d_EventTouch_class; @@ -1345,8 +1306,8 @@ bool js_cocos2dx_EventTouch_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -1388,32 +1349,20 @@ void js_register_cocos2dx_EventTouch(JSContext *cx, JS::HandleObject global) { JSFunctionSpec *st_funcs = NULL; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Event_prototype); jsb_cocos2d_EventTouch_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Event_prototype), + parent_proto, jsb_cocos2d_EventTouch_class, js_cocos2dx_EventTouch_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "EventTouch", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_EventTouch_class; - p->proto = jsb_cocos2d_EventTouch_prototype; - p->parentProto = jsb_cocos2d_Event_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_EventTouch_prototype); + jsb_register_class(cx, jsb_cocos2d_EventTouch_class, proto, parent_proto); } JSClass *jsb_cocos2d_ComponentContainer_class; @@ -1446,7 +1395,7 @@ bool js_cocos2dx_ComponentContainer_remove(JSContext *cx, uint32_t argc, jsval * JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::ComponentContainer *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ComponentContainer_remove : Invalid Native Object"); @@ -1457,7 +1406,7 @@ bool js_cocos2dx_ComponentContainer_remove(JSContext *cx, uint32_t argc, jsval * if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Component*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -1517,7 +1466,7 @@ bool js_cocos2dx_ComponentContainer_add(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Component*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -1616,30 +1565,17 @@ void js_register_cocos2dx_ComponentContainer(JSContext *cx, JS::HandleObject glo jsb_cocos2d_ComponentContainer_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocos2d_ComponentContainer_class, empty_constructor, 0, properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "ComponentContainer", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_ComponentContainer_class; - p->proto = jsb_cocos2d_ComponentContainer_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ComponentContainer_prototype); + jsb_register_class(cx, jsb_cocos2d_ComponentContainer_class, proto, JS::NullPtr()); } JSClass *jsb_cocos2d_Component_class; @@ -1760,7 +1696,7 @@ bool js_cocos2dx_Component_setOwner(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -1829,8 +1765,8 @@ bool js_cocos2dx_Component_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -1897,30 +1833,17 @@ void js_register_cocos2dx_Component(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_Component_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocos2d_Component_class, js_cocos2dx_Component_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "Component", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_Component_class; - p->proto = jsb_cocos2d_Component_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_Component_prototype); + jsb_register_class(cx, jsb_cocos2d_Component_class, proto, JS::NullPtr()); anonEvaluate(cx, global, "(function () { cc.Component.extend = cc.Class.extend; })()"); } @@ -1934,7 +1857,7 @@ bool js_cocos2dx_Node_addChild(JSContext *cx, uint32_t argc, jsval *vp) JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::Node *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Node_addChild : Invalid Native Object"); @@ -1945,7 +1868,7 @@ bool js_cocos2dx_Node_addChild(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -1967,7 +1890,7 @@ bool js_cocos2dx_Node_addChild(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -1986,7 +1909,7 @@ bool js_cocos2dx_Node_addChild(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -2011,7 +1934,7 @@ bool js_cocos2dx_Node_addChild(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -2039,7 +1962,7 @@ bool js_cocos2dx_Node_removeComponent(JSContext *cx, uint32_t argc, jsval *vp) JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::Node *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Node_removeComponent : Invalid Native Object"); @@ -2050,7 +1973,7 @@ bool js_cocos2dx_Node_removeComponent(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Component*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -2094,7 +2017,7 @@ bool js_cocos2dx_Node_setPhysicsBody(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Component*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -2198,7 +2121,7 @@ bool js_cocos2dx_Node_getChildren(JSContext *cx, uint32_t argc, jsval *vp) JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::Node *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Node_getChildren : Invalid Native Object"); @@ -2238,7 +2161,8 @@ bool js_cocos2dx_Node_setOnExitCallback(JSContext *cx, uint32_t argc, jsval *vp) do { if(JS_TypeOfValue(cx, args.get(0)) == JSTYPE_FUNCTION) { - std::shared_ptr func(new JSFunctionWrapper(cx, args.thisv().toObjectOrNull(), args.get(0))); + JS::RootedObject jstarget(cx, args.thisv().toObjectOrNull()); + std::shared_ptr func(new JSFunctionWrapper(cx, jstarget, args.get(0))); auto lambda = [=]() -> void { JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET JS::RootedValue rval(cx); @@ -2478,7 +2402,8 @@ bool js_cocos2dx_Node_setonEnterTransitionDidFinishCallback(JSContext *cx, uint3 do { if(JS_TypeOfValue(cx, args.get(0)) == JSTYPE_FUNCTION) { - std::shared_ptr func(new JSFunctionWrapper(cx, args.thisv().toObjectOrNull(), args.get(0))); + JS::RootedObject jstarget(cx, args.thisv().toObjectOrNull()); + std::shared_ptr func(new JSFunctionWrapper(cx, jstarget, args.get(0))); auto lambda = [=]() -> void { JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET JS::RootedValue rval(cx); @@ -2654,7 +2579,7 @@ bool js_cocos2dx_Node_removeChild(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -2671,7 +2596,7 @@ bool js_cocos2dx_Node_removeChild(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -2770,7 +2695,7 @@ bool js_cocos2dx_Node_setGLProgramState(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::GLProgramState*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -2797,7 +2722,8 @@ bool js_cocos2dx_Node_setOnEnterCallback(JSContext *cx, uint32_t argc, jsval *vp do { if(JS_TypeOfValue(cx, args.get(0)) == JSTYPE_FUNCTION) { - std::shared_ptr func(new JSFunctionWrapper(cx, args.thisv().toObjectOrNull(), args.get(0))); + JS::RootedObject jstarget(cx, args.thisv().toObjectOrNull()); + std::shared_ptr func(new JSFunctionWrapper(cx, jstarget, args.get(0))); auto lambda = [=]() -> void { JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET JS::RootedValue rval(cx); @@ -2876,7 +2802,8 @@ bool js_cocos2dx_Node_setonExitTransitionDidStartCallback(JSContext *cx, uint32_ do { if(JS_TypeOfValue(cx, args.get(0)) == JSTYPE_FUNCTION) { - std::shared_ptr func(new JSFunctionWrapper(cx, args.thisv().toObjectOrNull(), args.get(0))); + JS::RootedObject jstarget(cx, args.thisv().toObjectOrNull()); + std::shared_ptr func(new JSFunctionWrapper(cx, jstarget, args.get(0))); auto lambda = [=]() -> void { JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET JS::RootedValue rval(cx); @@ -2916,7 +2843,7 @@ bool js_cocos2dx_Node_convertTouchToNodeSpace(JSContext *cx, uint32_t argc, jsva if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Touch*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -2939,7 +2866,7 @@ bool js_cocos2dx_Node_removeAllChildrenWithCleanup(JSContext *cx, uint32_t argc, JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::Node *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Node_removeAllChildrenWithCleanup : Invalid Native Object"); @@ -3050,7 +2977,7 @@ bool js_cocos2dx_Node_setParent(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -3107,7 +3034,7 @@ bool js_cocos2dx_Node_getNodeToParentAffineTransform(JSContext *cx, uint32_t arg JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::Node *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Node_getNodeToParentAffineTransform : Invalid Native Object"); @@ -3118,7 +3045,7 @@ bool js_cocos2dx_Node_getNodeToParentAffineTransform(JSContext *cx, uint32_t arg if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -3159,7 +3086,7 @@ bool js_cocos2dx_Node_convertTouchToNodeSpaceAR(JSContext *cx, uint32_t argc, js if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Touch*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -3246,7 +3173,7 @@ bool js_cocos2dx_Node_reorderChild(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -3456,7 +3383,7 @@ bool js_cocos2dx_Node_getNodeToParentTransform(JSContext *cx, uint32_t argc, jsv JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::Node *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Node_getNodeToParentTransform : Invalid Native Object"); @@ -3467,7 +3394,7 @@ bool js_cocos2dx_Node_getNodeToParentTransform(JSContext *cx, uint32_t argc, jsv if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -3530,7 +3457,7 @@ bool js_cocos2dx_Node_addComponent(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Component*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -3560,7 +3487,7 @@ bool js_cocos2dx_Node_runAction(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Action*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -3590,7 +3517,7 @@ bool js_cocos2dx_Node_visit(JSContext *cx, uint32_t argc, jsval *vp) JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::Node *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Node_visit : Invalid Native Object"); @@ -3609,7 +3536,7 @@ bool js_cocos2dx_Node_visit(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Renderer*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -3644,7 +3571,7 @@ bool js_cocos2dx_Node_setGLProgram(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::GLProgram*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -3826,7 +3753,7 @@ bool js_cocos2dx_Node_setScheduler(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Scheduler*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -4064,7 +3991,7 @@ bool js_cocos2dx_Node_getScheduler(JSContext *cx, uint32_t argc, jsval *vp) JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::Node *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Node_getScheduler : Invalid Native Object"); @@ -4137,7 +4064,7 @@ bool js_cocos2dx_Node_setActionManager(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionManager*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -4158,7 +4085,7 @@ bool js_cocos2dx_Node_getPosition(JSContext *cx, uint32_t argc, jsval *vp) JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::Node *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Node_getPosition : Invalid Native Object"); @@ -4216,7 +4143,7 @@ bool js_cocos2dx_Node_getParent(JSContext *cx, uint32_t argc, jsval *vp) JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::Node *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Node_getParent : Invalid Native Object"); @@ -4464,7 +4391,7 @@ bool js_cocos2dx_Node_setScale(JSContext *cx, uint32_t argc, jsval *vp) JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::Node *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Node_setScale : Invalid Native Object"); @@ -4776,7 +4703,7 @@ bool js_cocos2dx_Node_setEventDispatcher(JSContext *cx, uint32_t argc, jsval *vp if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::EventDispatcher*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -4815,7 +4742,7 @@ bool js_cocos2dx_Node_draw(JSContext *cx, uint32_t argc, jsval *vp) JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::Node *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Node_draw : Invalid Native Object"); @@ -4834,7 +4761,7 @@ bool js_cocos2dx_Node_draw(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Renderer*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -4869,7 +4796,7 @@ bool js_cocos2dx_Node_setUserObject(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Ref*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -4898,7 +4825,8 @@ bool js_cocos2dx_Node_enumerateChildren(JSContext *cx, uint32_t argc, jsval *vp) do { if(JS_TypeOfValue(cx, args.get(1)) == JSTYPE_FUNCTION) { - std::shared_ptr func(new JSFunctionWrapper(cx, args.thisv().toObjectOrNull(), args.get(1))); + JS::RootedObject jstarget(cx, args.thisv().toObjectOrNull()); + std::shared_ptr func(new JSFunctionWrapper(cx, jstarget, args.get(1))); auto lambda = [=](cocos2d::Node* larg0) -> bool { JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET jsval largv[1]; @@ -4961,7 +4889,7 @@ bool js_cocos2dx_Node_removeFromParentAndCleanup(JSContext *cx, uint32_t argc, j JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::Node *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Node_removeFromParentAndCleanup : Invalid Native Object"); @@ -5208,7 +5136,7 @@ bool js_cocos2dx_Node_stopAction(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Action*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -5229,7 +5157,7 @@ bool js_cocos2dx_Node_getActionManager(JSContext *cx, uint32_t argc, jsval *vp) JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::Node *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Node_getActionManager : Invalid Native Object"); @@ -5307,8 +5235,8 @@ bool js_cocos2dx_Node_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -5504,30 +5432,17 @@ void js_register_cocos2dx_Node(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_Node_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocos2d_Node_class, js_cocos2dx_Node_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "Node", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_Node_class; - p->proto = jsb_cocos2d_Node_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_Node_prototype); + jsb_register_class(cx, jsb_cocos2d_Node_class, proto, JS::NullPtr()); anonEvaluate(cx, global, "(function () { cc.Node.extend = cc.Class.extend; })()"); } @@ -5550,8 +5465,8 @@ bool js_cocos2dx___NodeRGBA_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -5608,32 +5523,20 @@ void js_register_cocos2dx___NodeRGBA(JSContext *cx, JS::HandleObject global) { JSFunctionSpec *st_funcs = NULL; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Node_prototype); jsb_cocos2d___NodeRGBA_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Node_prototype), + parent_proto, jsb_cocos2d___NodeRGBA_class, js_cocos2dx___NodeRGBA_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "NodeRGBA", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d___NodeRGBA_class; - p->proto = jsb_cocos2d___NodeRGBA_prototype; - p->parentProto = jsb_cocos2d_Node_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d___NodeRGBA_prototype); + jsb_register_class(cx, jsb_cocos2d___NodeRGBA_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.NodeRGBA.extend = cc.Class.extend; })()"); } @@ -5670,7 +5573,7 @@ bool js_cocos2dx_Scene_render(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Renderer*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -5718,7 +5621,7 @@ bool js_cocos2dx_Scene_onProjectionChanged(JSContext *cx, uint32_t argc, jsval * if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::EventCustom*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -5841,8 +5744,8 @@ bool js_cocos2dx_Scene_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -5909,32 +5812,20 @@ void js_register_cocos2dx_Scene(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Node_prototype); jsb_cocos2d_Scene_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Node_prototype), + parent_proto, jsb_cocos2d_Scene_class, js_cocos2dx_Scene_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "Scene", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_Scene_class; - p->proto = jsb_cocos2d_Scene_prototype; - p->parentProto = jsb_cocos2d_Node_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_Scene_prototype); + jsb_register_class(cx, jsb_cocos2d_Scene_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.Scene.extend = cc.Class.extend; })()"); } @@ -6574,30 +6465,17 @@ void js_register_cocos2dx_GLView(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_GLView_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocos2d_GLView_class, empty_constructor, 0, properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "GLView", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_GLView_class; - p->proto = jsb_cocos2d_GLView_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_GLView_prototype); + jsb_register_class(cx, jsb_cocos2d_GLView_class, proto, JS::NullPtr()); } JSClass *jsb_cocos2d_Director_class; @@ -6633,7 +6511,7 @@ bool js_cocos2dx_Director_setEventDispatcher(JSContext *cx, uint32_t argc, jsval if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::EventDispatcher*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -6751,7 +6629,7 @@ bool js_cocos2dx_Director_setActionManager(JSContext *cx, uint32_t argc, jsval * if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionManager*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -7121,7 +6999,7 @@ bool js_cocos2dx_Director_setScheduler(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Scheduler*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -7343,7 +7221,7 @@ bool js_cocos2dx_Director_setOpenGLView(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::GLView*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -7427,7 +7305,7 @@ bool js_cocos2dx_Director_runWithScene(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -7455,7 +7333,7 @@ bool js_cocos2dx_Director_setNotificationNode(JSContext *cx, uint32_t argc, jsva if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -7712,7 +7590,7 @@ bool js_cocos2dx_Director_pushScene(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -7821,7 +7699,7 @@ bool js_cocos2dx_Director_replaceScene(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -7997,30 +7875,17 @@ void js_register_cocos2dx_Director(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_Director_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocos2d_Director_class, empty_constructor, 0, properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "Director", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_Director_class; - p->proto = jsb_cocos2d_Director_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_Director_prototype); + jsb_register_class(cx, jsb_cocos2d_Director_class, proto, JS::NullPtr()); } JSClass *jsb_cocos2d_Scheduler_class; @@ -8119,7 +7984,8 @@ bool js_cocos2dx_Scheduler_performFunctionInCocosThread(JSContext *cx, uint32_t do { if(JS_TypeOfValue(cx, args.get(0)) == JSTYPE_FUNCTION) { - std::shared_ptr func(new JSFunctionWrapper(cx, args.thisv().toObjectOrNull(), args.get(0))); + JS::RootedObject jstarget(cx, args.thisv().toObjectOrNull()); + std::shared_ptr func(new JSFunctionWrapper(cx, jstarget, args.get(0))); auto lambda = [=]() -> void { JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET JS::RootedValue rval(cx); @@ -8195,8 +8061,8 @@ bool js_cocos2dx_Scheduler_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -8243,30 +8109,17 @@ void js_register_cocos2dx_Scheduler(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_Scheduler_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocos2d_Scheduler_class, js_cocos2dx_Scheduler_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "Scheduler", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_Scheduler_class; - p->proto = jsb_cocos2d_Scheduler_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_Scheduler_prototype); + jsb_register_class(cx, jsb_cocos2d_Scheduler_class, proto, JS::NullPtr()); } JSClass *jsb_cocos2d_AsyncTaskPool_class; @@ -8360,30 +8213,17 @@ void js_register_cocos2dx_AsyncTaskPool(JSContext *cx, JS::HandleObject global) jsb_cocos2d_AsyncTaskPool_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocos2d_AsyncTaskPool_class, empty_constructor, 0, properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "AsyncTaskPool", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_AsyncTaskPool_class; - p->proto = jsb_cocos2d_AsyncTaskPool_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_AsyncTaskPool_prototype); + jsb_register_class(cx, jsb_cocos2d_AsyncTaskPool_class, proto, JS::NullPtr()); } JSClass *jsb_cocos2d_Action_class; @@ -8403,7 +8243,7 @@ bool js_cocos2dx_Action_startWithTarget(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -8431,7 +8271,7 @@ bool js_cocos2dx_Action_setOriginalTarget(JSContext *cx, uint32_t argc, jsval *v if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -8666,7 +8506,7 @@ bool js_cocos2dx_Action_setTarget(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -8768,30 +8608,17 @@ void js_register_cocos2dx_Action(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_Action_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocos2d_Action_class, empty_constructor, 0, properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "Action", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_Action_class; - p->proto = jsb_cocos2d_Action_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_Action_prototype); + jsb_register_class(cx, jsb_cocos2d_Action_class, proto, JS::NullPtr()); } JSClass *jsb_cocos2d_FiniteTimeAction_class; @@ -8867,32 +8694,20 @@ void js_register_cocos2dx_FiniteTimeAction(JSContext *cx, JS::HandleObject globa JSFunctionSpec *st_funcs = NULL; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Action_prototype); jsb_cocos2d_FiniteTimeAction_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Action_prototype), + parent_proto, jsb_cocos2d_FiniteTimeAction_class, empty_constructor, 0, properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "FiniteTimeAction", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_FiniteTimeAction_class; - p->proto = jsb_cocos2d_FiniteTimeAction_prototype; - p->parentProto = jsb_cocos2d_Action_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_FiniteTimeAction_prototype); + jsb_register_class(cx, jsb_cocos2d_FiniteTimeAction_class, proto, parent_proto); } JSClass *jsb_cocos2d_Speed_class; @@ -8912,7 +8727,7 @@ bool js_cocos2dx_Speed_setInnerAction(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -8979,7 +8794,7 @@ bool js_cocos2dx_Speed_initWithAction(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -9032,7 +8847,7 @@ bool js_cocos2dx_Speed_create(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -9072,8 +8887,8 @@ bool js_cocos2dx_Speed_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -9121,32 +8936,20 @@ void js_register_cocos2dx_Speed(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Action_prototype); jsb_cocos2d_Speed_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Action_prototype), + parent_proto, jsb_cocos2d_Speed_class, js_cocos2dx_Speed_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "Speed", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_Speed_class; - p->proto = jsb_cocos2d_Speed_prototype; - p->parentProto = jsb_cocos2d_Action_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_Speed_prototype); + jsb_register_class(cx, jsb_cocos2d_Speed_class, proto, parent_proto); } JSClass *jsb_cocos2d_Follow_class; @@ -9186,7 +8989,7 @@ bool js_cocos2dx_Follow_initWithTarget(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -9205,7 +9008,7 @@ bool js_cocos2dx_Follow_initWithTarget(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -9250,7 +9053,7 @@ bool js_cocos2dx_Follow_create(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -9276,7 +9079,7 @@ bool js_cocos2dx_Follow_create(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -9316,8 +9119,8 @@ bool js_cocos2dx_Follow_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -9380,32 +9183,20 @@ void js_register_cocos2dx_Follow(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Action_prototype); jsb_cocos2d_Follow_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Action_prototype), + parent_proto, jsb_cocos2d_Follow_class, js_cocos2dx_Follow_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "Follow", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_Follow_class; - p->proto = jsb_cocos2d_Follow_prototype; - p->parentProto = jsb_cocos2d_Action_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_Follow_prototype); + jsb_register_class(cx, jsb_cocos2d_Follow_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.Follow.extend = cc.Class.extend; })()"); } @@ -9768,8 +9559,8 @@ bool js_cocos2dx_Image_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -9827,30 +9618,17 @@ void js_register_cocos2dx_Image(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_Image_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocos2d_Image_class, js_cocos2dx_Image_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "Image", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_Image_class; - p->proto = jsb_cocos2d_Image_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_Image_prototype); + jsb_register_class(cx, jsb_cocos2d_Image_class, proto, JS::NullPtr()); } JSClass *jsb_cocos2d_GLProgramState_class; @@ -9863,7 +9641,7 @@ bool js_cocos2dx_GLProgramState_setUniformCallback(JSContext *cx, uint32_t argc, JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::GLProgramState *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_GLProgramState_setUniformCallback : Invalid Native Object"); @@ -9876,7 +9654,8 @@ bool js_cocos2dx_GLProgramState_setUniformCallback(JSContext *cx, uint32_t argc, do { if(JS_TypeOfValue(cx, args.get(1)) == JSTYPE_FUNCTION) { - std::shared_ptr func(new JSFunctionWrapper(cx, args.thisv().toObjectOrNull(), args.get(1))); + JS::RootedObject jstarget(cx, args.thisv().toObjectOrNull()); + std::shared_ptr func(new JSFunctionWrapper(cx, jstarget, args.get(1))); auto lambda = [=](cocos2d::GLProgram* larg0, cocos2d::Uniform* larg1) -> void { JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET jsval largv[2]; @@ -9919,7 +9698,8 @@ bool js_cocos2dx_GLProgramState_setUniformCallback(JSContext *cx, uint32_t argc, do { if(JS_TypeOfValue(cx, args.get(1)) == JSTYPE_FUNCTION) { - std::shared_ptr func(new JSFunctionWrapper(cx, args.thisv().toObjectOrNull(), args.get(1))); + JS::RootedObject jstarget(cx, args.thisv().toObjectOrNull()); + std::shared_ptr func(new JSFunctionWrapper(cx, jstarget, args.get(1))); auto lambda = [=](cocos2d::GLProgram* larg0, cocos2d::Uniform* larg1) -> void { JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET jsval largv[2]; @@ -10003,7 +9783,7 @@ bool js_cocos2dx_GLProgramState_setUniformVec2(JSContext *cx, uint32_t argc, jsv JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::GLProgramState *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_GLProgramState_setUniformVec2 : Invalid Native Object"); @@ -10045,7 +9825,7 @@ bool js_cocos2dx_GLProgramState_setUniformVec3(JSContext *cx, uint32_t argc, jsv JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::GLProgramState *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_GLProgramState_setUniformVec3 : Invalid Native Object"); @@ -10095,7 +9875,8 @@ bool js_cocos2dx_GLProgramState_setVertexAttribCallback(JSContext *cx, uint32_t do { if(JS_TypeOfValue(cx, args.get(1)) == JSTYPE_FUNCTION) { - std::shared_ptr func(new JSFunctionWrapper(cx, args.thisv().toObjectOrNull(), args.get(1))); + JS::RootedObject jstarget(cx, args.thisv().toObjectOrNull()); + std::shared_ptr func(new JSFunctionWrapper(cx, jstarget, args.get(1))); auto lambda = [=](cocos2d::VertexAttrib* larg0) -> void { JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET jsval largv[1]; @@ -10209,7 +9990,7 @@ bool js_cocos2dx_GLProgramState_setNodeBinding(JSContext *cx, uint32_t argc, jsv if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -10230,7 +10011,7 @@ bool js_cocos2dx_GLProgramState_setUniformInt(JSContext *cx, uint32_t argc, jsva JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::GLProgramState *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_GLProgramState_setUniformInt : Invalid Native Object"); @@ -10294,7 +10075,7 @@ bool js_cocos2dx_GLProgramState_setUniformVec2v(JSContext *cx, uint32_t argc, js JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::GLProgramState *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_GLProgramState_setUniformVec2v : Invalid Native Object"); @@ -10417,7 +10198,7 @@ bool js_cocos2dx_GLProgramState_setGLProgram(JSContext *cx, uint32_t argc, jsval if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::GLProgram*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -10438,7 +10219,7 @@ bool js_cocos2dx_GLProgramState_setUniformFloatv(JSContext *cx, uint32_t argc, j JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::GLProgramState *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_GLProgramState_setUniformFloatv : Invalid Native Object"); @@ -10513,7 +10294,7 @@ bool js_cocos2dx_GLProgramState_setUniformTexture(JSContext *cx, uint32_t argc, JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::GLProgramState *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_GLProgramState_setUniformTexture : Invalid Native Object"); @@ -10541,7 +10322,7 @@ bool js_cocos2dx_GLProgramState_setUniformTexture(JSContext *cx, uint32_t argc, if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -10563,7 +10344,7 @@ bool js_cocos2dx_GLProgramState_setUniformTexture(JSContext *cx, uint32_t argc, if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -10615,7 +10396,7 @@ bool js_cocos2dx_GLProgramState_setUniformFloat(JSContext *cx, uint32_t argc, js JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::GLProgramState *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_GLProgramState_setUniformFloat : Invalid Native Object"); @@ -10657,7 +10438,7 @@ bool js_cocos2dx_GLProgramState_setUniformMat4(JSContext *cx, uint32_t argc, jsv JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::GLProgramState *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_GLProgramState_setUniformMat4 : Invalid Native Object"); @@ -10699,7 +10480,7 @@ bool js_cocos2dx_GLProgramState_setUniformVec3v(JSContext *cx, uint32_t argc, js JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::GLProgramState *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_GLProgramState_setUniformVec3v : Invalid Native Object"); @@ -10716,7 +10497,7 @@ bool js_cocos2dx_GLProgramState_setUniformVec3v(JSContext *cx, uint32_t argc, js if (args.get(2).isNull()) { arg2 = nullptr; break; } if (!args.get(2).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(2).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(2).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg2 = (const cocos2d::Vec3*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg2, cx, false, "Invalid Native Object"); @@ -10741,7 +10522,7 @@ bool js_cocos2dx_GLProgramState_setUniformVec3v(JSContext *cx, uint32_t argc, js if (args.get(2).isNull()) { arg2 = nullptr; break; } if (!args.get(2).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(2).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(2).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg2 = (const cocos2d::Vec3*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg2, cx, false, "Invalid Native Object"); @@ -10784,7 +10565,7 @@ bool js_cocos2dx_GLProgramState_create(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::GLProgram*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -10842,7 +10623,7 @@ bool js_cocos2dx_GLProgramState_getOrCreateWithGLProgram(JSContext *cx, uint32_t if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::GLProgram*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -10955,30 +10736,17 @@ void js_register_cocos2dx_GLProgramState(JSContext *cx, JS::HandleObject global) jsb_cocos2d_GLProgramState_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocos2d_GLProgramState_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "GLProgramState", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_GLProgramState_class; - p->proto = jsb_cocos2d_GLProgramState_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_GLProgramState_prototype); + jsb_register_class(cx, jsb_cocos2d_GLProgramState_class, proto, JS::NullPtr()); } JSClass *jsb_cocos2d_SpriteFrame_class; @@ -10998,7 +10766,7 @@ bool js_cocos2dx_SpriteFrame_setTexture(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -11160,7 +10928,7 @@ bool js_cocos2dx_SpriteFrame_initWithTextureFilename(JSContext *cx, uint32_t arg JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::SpriteFrame *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_SpriteFrame_initWithTextureFilename : Invalid Native Object"); @@ -11234,7 +11002,7 @@ bool js_cocos2dx_SpriteFrame_initWithTexture(JSContext *cx, uint32_t argc, jsval JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::SpriteFrame *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_SpriteFrame_initWithTexture : Invalid Native Object"); @@ -11245,7 +11013,7 @@ bool js_cocos2dx_SpriteFrame_initWithTexture(JSContext *cx, uint32_t argc, jsval if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -11277,7 +11045,7 @@ bool js_cocos2dx_SpriteFrame_initWithTexture(JSContext *cx, uint32_t argc, jsval if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -11526,7 +11294,7 @@ bool js_cocos2dx_SpriteFrame_createWithTexture(JSContext *cx, uint32_t argc, jsv if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -11566,7 +11334,7 @@ bool js_cocos2dx_SpriteFrame_createWithTexture(JSContext *cx, uint32_t argc, jsv if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -11608,8 +11376,8 @@ bool js_cocos2dx_SpriteFrame_constructor(JSContext *cx, uint32_t argc, jsval *vp CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -11689,30 +11457,17 @@ void js_register_cocos2dx_SpriteFrame(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_SpriteFrame_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocos2d_SpriteFrame_class, js_cocos2dx_SpriteFrame_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "SpriteFrame", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_SpriteFrame_class; - p->proto = jsb_cocos2d_SpriteFrame_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_SpriteFrame_prototype); + jsb_register_class(cx, jsb_cocos2d_SpriteFrame_class, proto, JS::NullPtr()); anonEvaluate(cx, global, "(function () { cc.SpriteFrame.extend = cc.Class.extend; })()"); } @@ -11733,7 +11488,7 @@ bool js_cocos2dx_AnimationFrame_setSpriteFrame(JSContext *cx, uint32_t argc, jsv if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::SpriteFrame*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -11754,7 +11509,7 @@ bool js_cocos2dx_AnimationFrame_getUserInfo(JSContext *cx, uint32_t argc, jsval JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::AnimationFrame *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_AnimationFrame_getUserInfo : Invalid Native Object"); @@ -11905,7 +11660,7 @@ bool js_cocos2dx_AnimationFrame_initWithSpriteFrame(JSContext *cx, uint32_t argc if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::SpriteFrame*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -11935,7 +11690,7 @@ bool js_cocos2dx_AnimationFrame_create(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::SpriteFrame*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -11976,8 +11731,8 @@ bool js_cocos2dx_AnimationFrame_constructor(JSContext *cx, uint32_t argc, jsval CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -12045,30 +11800,17 @@ void js_register_cocos2dx_AnimationFrame(JSContext *cx, JS::HandleObject global) jsb_cocos2d_AnimationFrame_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocos2d_AnimationFrame_class, js_cocos2dx_AnimationFrame_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "AnimationFrame", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_AnimationFrame_class; - p->proto = jsb_cocos2d_AnimationFrame_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_AnimationFrame_prototype); + jsb_register_class(cx, jsb_cocos2d_AnimationFrame_class, proto, JS::NullPtr()); anonEvaluate(cx, global, "(function () { cc.AnimationFrame.extend = cc.Class.extend; })()"); } @@ -12107,7 +11849,7 @@ bool js_cocos2dx_Animation_addSpriteFrame(JSContext *cx, uint32_t argc, jsval *v if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::SpriteFrame*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -12443,7 +12185,7 @@ bool js_cocos2dx_Animation_addSpriteFrameWithTexture(JSContext *cx, uint32_t arg if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -12611,8 +12353,8 @@ bool js_cocos2dx_Animation_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -12690,30 +12432,17 @@ void js_register_cocos2dx_Animation(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_Animation_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocos2d_Animation_class, js_cocos2dx_Animation_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "Animation", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_Animation_class; - p->proto = jsb_cocos2d_Animation_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_Animation_prototype); + jsb_register_class(cx, jsb_cocos2d_Animation_class, proto, JS::NullPtr()); anonEvaluate(cx, global, "(function () { cc.Animation.extend = cc.Class.extend; })()"); } @@ -12832,32 +12561,20 @@ void js_register_cocos2dx_ActionInterval(JSContext *cx, JS::HandleObject global) JSFunctionSpec *st_funcs = NULL; + JS::RootedObject parent_proto(cx, jsb_cocos2d_FiniteTimeAction_prototype); jsb_cocos2d_ActionInterval_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_FiniteTimeAction_prototype), + parent_proto, jsb_cocos2d_ActionInterval_class, empty_constructor, 0, properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "ActionInterval", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_ActionInterval_class; - p->proto = jsb_cocos2d_ActionInterval_prototype; - p->parentProto = jsb_cocos2d_FiniteTimeAction_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ActionInterval_prototype); + jsb_register_class(cx, jsb_cocos2d_ActionInterval_class, proto, parent_proto); } JSClass *jsb_cocos2d_Sequence_class; @@ -12878,7 +12595,7 @@ bool js_cocos2dx_Sequence_initWithTwoActions(JSContext *cx, uint32_t argc, jsval if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::FiniteTimeAction*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -12887,7 +12604,7 @@ bool js_cocos2dx_Sequence_initWithTwoActions(JSContext *cx, uint32_t argc, jsval if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::FiniteTimeAction*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -12919,8 +12636,8 @@ bool js_cocos2dx_Sequence_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -12978,32 +12695,20 @@ void js_register_cocos2dx_Sequence(JSContext *cx, JS::HandleObject global) { JSFunctionSpec *st_funcs = NULL; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ActionInterval_prototype); jsb_cocos2d_Sequence_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ActionInterval_prototype), + parent_proto, jsb_cocos2d_Sequence_class, js_cocos2dx_Sequence_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "Sequence", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_Sequence_class; - p->proto = jsb_cocos2d_Sequence_prototype; - p->parentProto = jsb_cocos2d_ActionInterval_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_Sequence_prototype); + jsb_register_class(cx, jsb_cocos2d_Sequence_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.Sequence.extend = cc.Class.extend; })()"); } @@ -13024,7 +12729,7 @@ bool js_cocos2dx_Repeat_setInnerAction(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::FiniteTimeAction*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -13053,7 +12758,7 @@ bool js_cocos2dx_Repeat_initWithAction(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::FiniteTimeAction*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -13106,7 +12811,7 @@ bool js_cocos2dx_Repeat_create(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::FiniteTimeAction*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -13146,8 +12851,8 @@ bool js_cocos2dx_Repeat_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -13210,32 +12915,20 @@ void js_register_cocos2dx_Repeat(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ActionInterval_prototype); jsb_cocos2d_Repeat_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ActionInterval_prototype), + parent_proto, jsb_cocos2d_Repeat_class, js_cocos2dx_Repeat_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "Repeat", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_Repeat_class; - p->proto = jsb_cocos2d_Repeat_prototype; - p->parentProto = jsb_cocos2d_ActionInterval_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_Repeat_prototype); + jsb_register_class(cx, jsb_cocos2d_Repeat_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.Repeat.extend = cc.Class.extend; })()"); } @@ -13256,7 +12949,7 @@ bool js_cocos2dx_RepeatForever_setInnerAction(JSContext *cx, uint32_t argc, jsva if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -13284,7 +12977,7 @@ bool js_cocos2dx_RepeatForever_initWithAction(JSContext *cx, uint32_t argc, jsva if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -13335,7 +13028,7 @@ bool js_cocos2dx_RepeatForever_create(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -13374,8 +13067,8 @@ bool js_cocos2dx_RepeatForever_constructor(JSContext *cx, uint32_t argc, jsval * CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -13438,32 +13131,20 @@ void js_register_cocos2dx_RepeatForever(JSContext *cx, JS::HandleObject global) JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ActionInterval_prototype); jsb_cocos2d_RepeatForever_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ActionInterval_prototype), + parent_proto, jsb_cocos2d_RepeatForever_class, js_cocos2dx_RepeatForever_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "RepeatForever", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_RepeatForever_class; - p->proto = jsb_cocos2d_RepeatForever_prototype; - p->parentProto = jsb_cocos2d_ActionInterval_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_RepeatForever_prototype); + jsb_register_class(cx, jsb_cocos2d_RepeatForever_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.RepeatForever.extend = cc.Class.extend; })()"); } @@ -13485,7 +13166,7 @@ bool js_cocos2dx_Spawn_initWithTwoActions(JSContext *cx, uint32_t argc, jsval *v if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::FiniteTimeAction*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -13494,7 +13175,7 @@ bool js_cocos2dx_Spawn_initWithTwoActions(JSContext *cx, uint32_t argc, jsval *v if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::FiniteTimeAction*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -13526,8 +13207,8 @@ bool js_cocos2dx_Spawn_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -13585,32 +13266,20 @@ void js_register_cocos2dx_Spawn(JSContext *cx, JS::HandleObject global) { JSFunctionSpec *st_funcs = NULL; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ActionInterval_prototype); jsb_cocos2d_Spawn_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ActionInterval_prototype), + parent_proto, jsb_cocos2d_Spawn_class, js_cocos2dx_Spawn_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "Spawn", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_Spawn_class; - p->proto = jsb_cocos2d_Spawn_prototype; - p->parentProto = jsb_cocos2d_ActionInterval_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_Spawn_prototype); + jsb_register_class(cx, jsb_cocos2d_Spawn_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.Spawn.extend = cc.Class.extend; })()"); } @@ -13624,7 +13293,7 @@ bool js_cocos2dx_RotateTo_initWithDuration(JSContext *cx, uint32_t argc, jsval * JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::RotateTo *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_RotateTo_initWithDuration : Invalid Native Object"); @@ -13761,8 +13430,8 @@ bool js_cocos2dx_RotateTo_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -13823,32 +13492,20 @@ void js_register_cocos2dx_RotateTo(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ActionInterval_prototype); jsb_cocos2d_RotateTo_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ActionInterval_prototype), + parent_proto, jsb_cocos2d_RotateTo_class, js_cocos2dx_RotateTo_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "RotateTo", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_RotateTo_class; - p->proto = jsb_cocos2d_RotateTo_prototype; - p->parentProto = jsb_cocos2d_ActionInterval_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_RotateTo_prototype); + jsb_register_class(cx, jsb_cocos2d_RotateTo_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.RotateTo.extend = cc.Class.extend; })()"); } @@ -13862,7 +13519,7 @@ bool js_cocos2dx_RotateBy_initWithDuration(JSContext *cx, uint32_t argc, jsval * JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::RotateBy *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_RotateBy_initWithDuration : Invalid Native Object"); @@ -14015,8 +13672,8 @@ bool js_cocos2dx_RotateBy_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -14077,32 +13734,20 @@ void js_register_cocos2dx_RotateBy(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ActionInterval_prototype); jsb_cocos2d_RotateBy_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ActionInterval_prototype), + parent_proto, jsb_cocos2d_RotateBy_class, js_cocos2dx_RotateBy_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "RotateBy", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_RotateBy_class; - p->proto = jsb_cocos2d_RotateBy_prototype; - p->parentProto = jsb_cocos2d_ActionInterval_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_RotateBy_prototype); + jsb_register_class(cx, jsb_cocos2d_RotateBy_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.RotateBy.extend = cc.Class.extend; })()"); } @@ -14116,7 +13761,7 @@ bool js_cocos2dx_MoveBy_initWithDuration(JSContext *cx, uint32_t argc, jsval *vp JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::MoveBy *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_MoveBy_initWithDuration : Invalid Native Object"); @@ -14224,8 +13869,8 @@ bool js_cocos2dx_MoveBy_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -14286,32 +13931,20 @@ void js_register_cocos2dx_MoveBy(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ActionInterval_prototype); jsb_cocos2d_MoveBy_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ActionInterval_prototype), + parent_proto, jsb_cocos2d_MoveBy_class, js_cocos2dx_MoveBy_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "MoveBy", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_MoveBy_class; - p->proto = jsb_cocos2d_MoveBy_prototype; - p->parentProto = jsb_cocos2d_ActionInterval_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_MoveBy_prototype); + jsb_register_class(cx, jsb_cocos2d_MoveBy_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.MoveBy.extend = cc.Class.extend; })()"); } @@ -14325,7 +13958,7 @@ bool js_cocos2dx_MoveTo_initWithDuration(JSContext *cx, uint32_t argc, jsval *vp JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::MoveTo *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_MoveTo_initWithDuration : Invalid Native Object"); @@ -14433,8 +14066,8 @@ bool js_cocos2dx_MoveTo_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -14495,32 +14128,20 @@ void js_register_cocos2dx_MoveTo(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_MoveBy_prototype); jsb_cocos2d_MoveTo_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_MoveBy_prototype), + parent_proto, jsb_cocos2d_MoveTo_class, js_cocos2dx_MoveTo_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "MoveTo", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_MoveTo_class; - p->proto = jsb_cocos2d_MoveTo_prototype; - p->parentProto = jsb_cocos2d_MoveBy_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_MoveTo_prototype); + jsb_register_class(cx, jsb_cocos2d_MoveTo_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.MoveTo.extend = cc.Class.extend; })()"); } @@ -14598,8 +14219,8 @@ bool js_cocos2dx_SkewTo_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -14660,32 +14281,20 @@ void js_register_cocos2dx_SkewTo(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ActionInterval_prototype); jsb_cocos2d_SkewTo_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ActionInterval_prototype), + parent_proto, jsb_cocos2d_SkewTo_class, js_cocos2dx_SkewTo_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "SkewTo", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_SkewTo_class; - p->proto = jsb_cocos2d_SkewTo_prototype; - p->parentProto = jsb_cocos2d_ActionInterval_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_SkewTo_prototype); + jsb_register_class(cx, jsb_cocos2d_SkewTo_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.SkewTo.extend = cc.Class.extend; })()"); } @@ -14763,8 +14372,8 @@ bool js_cocos2dx_SkewBy_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -14825,32 +14434,20 @@ void js_register_cocos2dx_SkewBy(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_SkewTo_prototype); jsb_cocos2d_SkewBy_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_SkewTo_prototype), + parent_proto, jsb_cocos2d_SkewBy_class, js_cocos2dx_SkewBy_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "SkewBy", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_SkewBy_class; - p->proto = jsb_cocos2d_SkewBy_prototype; - p->parentProto = jsb_cocos2d_SkewTo_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_SkewBy_prototype); + jsb_register_class(cx, jsb_cocos2d_SkewBy_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.SkewBy.extend = cc.Class.extend; })()"); } @@ -14932,8 +14529,8 @@ bool js_cocos2dx_JumpBy_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -14994,32 +14591,20 @@ void js_register_cocos2dx_JumpBy(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ActionInterval_prototype); jsb_cocos2d_JumpBy_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ActionInterval_prototype), + parent_proto, jsb_cocos2d_JumpBy_class, js_cocos2dx_JumpBy_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "JumpBy", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_JumpBy_class; - p->proto = jsb_cocos2d_JumpBy_prototype; - p->parentProto = jsb_cocos2d_ActionInterval_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_JumpBy_prototype); + jsb_register_class(cx, jsb_cocos2d_JumpBy_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.JumpBy.extend = cc.Class.extend; })()"); } @@ -15101,8 +14686,8 @@ bool js_cocos2dx_JumpTo_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -15163,32 +14748,20 @@ void js_register_cocos2dx_JumpTo(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_JumpBy_prototype); jsb_cocos2d_JumpTo_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_JumpBy_prototype), + parent_proto, jsb_cocos2d_JumpTo_class, js_cocos2dx_JumpTo_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "JumpTo", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_JumpTo_class; - p->proto = jsb_cocos2d_JumpTo_prototype; - p->parentProto = jsb_cocos2d_JumpBy_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_JumpTo_prototype); + jsb_register_class(cx, jsb_cocos2d_JumpTo_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.JumpTo.extend = cc.Class.extend; })()"); } @@ -15211,8 +14784,8 @@ bool js_cocos2dx_BezierBy_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -15269,32 +14842,20 @@ void js_register_cocos2dx_BezierBy(JSContext *cx, JS::HandleObject global) { JSFunctionSpec *st_funcs = NULL; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ActionInterval_prototype); jsb_cocos2d_BezierBy_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ActionInterval_prototype), + parent_proto, jsb_cocos2d_BezierBy_class, js_cocos2dx_BezierBy_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "BezierBy", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_BezierBy_class; - p->proto = jsb_cocos2d_BezierBy_prototype; - p->parentProto = jsb_cocos2d_ActionInterval_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_BezierBy_prototype); + jsb_register_class(cx, jsb_cocos2d_BezierBy_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.BezierBy.extend = cc.Class.extend; })()"); } @@ -15317,8 +14878,8 @@ bool js_cocos2dx_BezierTo_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -15375,32 +14936,20 @@ void js_register_cocos2dx_BezierTo(JSContext *cx, JS::HandleObject global) { JSFunctionSpec *st_funcs = NULL; + JS::RootedObject parent_proto(cx, jsb_cocos2d_BezierBy_prototype); jsb_cocos2d_BezierTo_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_BezierBy_prototype), + parent_proto, jsb_cocos2d_BezierTo_class, js_cocos2dx_BezierTo_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "BezierTo", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_BezierTo_class; - p->proto = jsb_cocos2d_BezierTo_prototype; - p->parentProto = jsb_cocos2d_BezierBy_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_BezierTo_prototype); + jsb_register_class(cx, jsb_cocos2d_BezierTo_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.BezierTo.extend = cc.Class.extend; })()"); } @@ -15414,7 +14963,7 @@ bool js_cocos2dx_ScaleTo_initWithDuration(JSContext *cx, uint32_t argc, jsval *v JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::ScaleTo *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ScaleTo_initWithDuration : Invalid Native Object"); @@ -15579,8 +15128,8 @@ bool js_cocos2dx_ScaleTo_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -15641,32 +15190,20 @@ void js_register_cocos2dx_ScaleTo(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ActionInterval_prototype); jsb_cocos2d_ScaleTo_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ActionInterval_prototype), + parent_proto, jsb_cocos2d_ScaleTo_class, js_cocos2dx_ScaleTo_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "ScaleTo", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_ScaleTo_class; - p->proto = jsb_cocos2d_ScaleTo_prototype; - p->parentProto = jsb_cocos2d_ActionInterval_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ScaleTo_prototype); + jsb_register_class(cx, jsb_cocos2d_ScaleTo_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.ScaleTo.extend = cc.Class.extend; })()"); } @@ -15774,8 +15311,8 @@ bool js_cocos2dx_ScaleBy_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -15835,32 +15372,20 @@ void js_register_cocos2dx_ScaleBy(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ScaleTo_prototype); jsb_cocos2d_ScaleBy_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ScaleTo_prototype), + parent_proto, jsb_cocos2d_ScaleBy_class, js_cocos2dx_ScaleBy_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "ScaleBy", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_ScaleBy_class; - p->proto = jsb_cocos2d_ScaleBy_prototype; - p->parentProto = jsb_cocos2d_ScaleTo_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ScaleBy_prototype); + jsb_register_class(cx, jsb_cocos2d_ScaleBy_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.ScaleBy.extend = cc.Class.extend; })()"); } @@ -15934,8 +15459,8 @@ bool js_cocos2dx_Blink_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -15996,32 +15521,20 @@ void js_register_cocos2dx_Blink(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ActionInterval_prototype); jsb_cocos2d_Blink_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ActionInterval_prototype), + parent_proto, jsb_cocos2d_Blink_class, js_cocos2dx_Blink_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "Blink", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_Blink_class; - p->proto = jsb_cocos2d_Blink_prototype; - p->parentProto = jsb_cocos2d_ActionInterval_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_Blink_prototype); + jsb_register_class(cx, jsb_cocos2d_Blink_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.Blink.extend = cc.Class.extend; })()"); } @@ -16095,8 +15608,8 @@ bool js_cocos2dx_FadeTo_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -16157,32 +15670,20 @@ void js_register_cocos2dx_FadeTo(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ActionInterval_prototype); jsb_cocos2d_FadeTo_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ActionInterval_prototype), + parent_proto, jsb_cocos2d_FadeTo_class, js_cocos2dx_FadeTo_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "FadeTo", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_FadeTo_class; - p->proto = jsb_cocos2d_FadeTo_prototype; - p->parentProto = jsb_cocos2d_ActionInterval_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_FadeTo_prototype); + jsb_register_class(cx, jsb_cocos2d_FadeTo_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.FadeTo.extend = cc.Class.extend; })()"); } @@ -16203,7 +15704,7 @@ bool js_cocos2dx_FadeIn_setReverseAction(JSContext *cx, uint32_t argc, jsval *vp if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::FadeTo*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -16258,8 +15759,8 @@ bool js_cocos2dx_FadeIn_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -16320,32 +15821,20 @@ void js_register_cocos2dx_FadeIn(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_FadeTo_prototype); jsb_cocos2d_FadeIn_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_FadeTo_prototype), + parent_proto, jsb_cocos2d_FadeIn_class, js_cocos2dx_FadeIn_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "FadeIn", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_FadeIn_class; - p->proto = jsb_cocos2d_FadeIn_prototype; - p->parentProto = jsb_cocos2d_FadeTo_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_FadeIn_prototype); + jsb_register_class(cx, jsb_cocos2d_FadeIn_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.FadeIn.extend = cc.Class.extend; })()"); } @@ -16366,7 +15855,7 @@ bool js_cocos2dx_FadeOut_setReverseAction(JSContext *cx, uint32_t argc, jsval *v if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::FadeTo*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -16421,8 +15910,8 @@ bool js_cocos2dx_FadeOut_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -16483,32 +15972,20 @@ void js_register_cocos2dx_FadeOut(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_FadeTo_prototype); jsb_cocos2d_FadeOut_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_FadeTo_prototype), + parent_proto, jsb_cocos2d_FadeOut_class, js_cocos2dx_FadeOut_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "FadeOut", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_FadeOut_class; - p->proto = jsb_cocos2d_FadeOut_prototype; - p->parentProto = jsb_cocos2d_FadeTo_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_FadeOut_prototype); + jsb_register_class(cx, jsb_cocos2d_FadeOut_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.FadeOut.extend = cc.Class.extend; })()"); } @@ -16618,8 +16095,8 @@ bool js_cocos2dx_TintTo_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -16680,32 +16157,20 @@ void js_register_cocos2dx_TintTo(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ActionInterval_prototype); jsb_cocos2d_TintTo_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ActionInterval_prototype), + parent_proto, jsb_cocos2d_TintTo_class, js_cocos2dx_TintTo_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "TintTo", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_TintTo_class; - p->proto = jsb_cocos2d_TintTo_prototype; - p->parentProto = jsb_cocos2d_ActionInterval_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_TintTo_prototype); + jsb_register_class(cx, jsb_cocos2d_TintTo_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.TintTo.extend = cc.Class.extend; })()"); } @@ -16787,8 +16252,8 @@ bool js_cocos2dx_TintBy_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -16849,32 +16314,20 @@ void js_register_cocos2dx_TintBy(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ActionInterval_prototype); jsb_cocos2d_TintBy_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ActionInterval_prototype), + parent_proto, jsb_cocos2d_TintBy_class, js_cocos2dx_TintBy_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "TintBy", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_TintBy_class; - p->proto = jsb_cocos2d_TintBy_prototype; - p->parentProto = jsb_cocos2d_ActionInterval_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_TintBy_prototype); + jsb_register_class(cx, jsb_cocos2d_TintBy_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.TintBy.extend = cc.Class.extend; })()"); } @@ -16922,8 +16375,8 @@ bool js_cocos2dx_DelayTime_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -16983,32 +16436,20 @@ void js_register_cocos2dx_DelayTime(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ActionInterval_prototype); jsb_cocos2d_DelayTime_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ActionInterval_prototype), + parent_proto, jsb_cocos2d_DelayTime_class, js_cocos2dx_DelayTime_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "DelayTime", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_DelayTime_class; - p->proto = jsb_cocos2d_DelayTime_prototype; - p->parentProto = jsb_cocos2d_ActionInterval_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_DelayTime_prototype); + jsb_register_class(cx, jsb_cocos2d_DelayTime_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.DelayTime.extend = cc.Class.extend; })()"); } @@ -17029,7 +16470,7 @@ bool js_cocos2dx_ReverseTime_initWithAction(JSContext *cx, uint32_t argc, jsval if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::FiniteTimeAction*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -17055,7 +16496,7 @@ bool js_cocos2dx_ReverseTime_create(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::FiniteTimeAction*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -17094,8 +16535,8 @@ bool js_cocos2dx_ReverseTime_constructor(JSContext *cx, uint32_t argc, jsval *vp CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -17156,32 +16597,20 @@ void js_register_cocos2dx_ReverseTime(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ActionInterval_prototype); jsb_cocos2d_ReverseTime_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ActionInterval_prototype), + parent_proto, jsb_cocos2d_ReverseTime_class, js_cocos2dx_ReverseTime_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "ReverseTime", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_ReverseTime_class; - p->proto = jsb_cocos2d_ReverseTime_prototype; - p->parentProto = jsb_cocos2d_ActionInterval_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ReverseTime_prototype); + jsb_register_class(cx, jsb_cocos2d_ReverseTime_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.ReverseTime.extend = cc.Class.extend; })()"); } @@ -17202,7 +16631,7 @@ bool js_cocos2dx_Animate_initWithAnimation(JSContext *cx, uint32_t argc, jsval * if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Animation*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -17225,7 +16654,7 @@ bool js_cocos2dx_Animate_getAnimation(JSContext *cx, uint32_t argc, jsval *vp) JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::Animate *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Animate_getAnimation : Invalid Native Object"); @@ -17298,7 +16727,7 @@ bool js_cocos2dx_Animate_setAnimation(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Animation*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -17322,7 +16751,7 @@ bool js_cocos2dx_Animate_create(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Animation*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -17361,8 +16790,8 @@ bool js_cocos2dx_Animate_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -17426,32 +16855,20 @@ void js_register_cocos2dx_Animate(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ActionInterval_prototype); jsb_cocos2d_Animate_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ActionInterval_prototype), + parent_proto, jsb_cocos2d_Animate_class, js_cocos2dx_Animate_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "Animate", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_Animate_class; - p->proto = jsb_cocos2d_Animate_prototype; - p->parentProto = jsb_cocos2d_ActionInterval_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_Animate_prototype); + jsb_register_class(cx, jsb_cocos2d_Animate_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.Animate.extend = cc.Class.extend; })()"); } @@ -17465,7 +16882,7 @@ bool js_cocos2dx_TargetedAction_getForcedTarget(JSContext *cx, uint32_t argc, js JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::TargetedAction *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TargetedAction_getForcedTarget : Invalid Native Object"); @@ -17521,7 +16938,7 @@ bool js_cocos2dx_TargetedAction_initWithTarget(JSContext *cx, uint32_t argc, jsv if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -17530,7 +16947,7 @@ bool js_cocos2dx_TargetedAction_initWithTarget(JSContext *cx, uint32_t argc, jsv if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::FiniteTimeAction*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -17560,7 +16977,7 @@ bool js_cocos2dx_TargetedAction_setForcedTarget(JSContext *cx, uint32_t argc, js if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -17585,7 +17002,7 @@ bool js_cocos2dx_TargetedAction_create(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -17594,7 +17011,7 @@ bool js_cocos2dx_TargetedAction_create(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::FiniteTimeAction*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -17633,8 +17050,8 @@ bool js_cocos2dx_TargetedAction_constructor(JSContext *cx, uint32_t argc, jsval CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -17697,32 +17114,20 @@ void js_register_cocos2dx_TargetedAction(JSContext *cx, JS::HandleObject global) JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ActionInterval_prototype); jsb_cocos2d_TargetedAction_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ActionInterval_prototype), + parent_proto, jsb_cocos2d_TargetedAction_class, js_cocos2dx_TargetedAction_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "TargetedAction", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_TargetedAction_class; - p->proto = jsb_cocos2d_TargetedAction_prototype; - p->parentProto = jsb_cocos2d_ActionInterval_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_TargetedAction_prototype); + jsb_register_class(cx, jsb_cocos2d_TargetedAction_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.TargetedAction.extend = cc.Class.extend; })()"); } @@ -17748,7 +17153,8 @@ bool js_cocos2dx_ActionFloat_initWithDuration(JSContext *cx, uint32_t argc, jsva do { if(JS_TypeOfValue(cx, args.get(3)) == JSTYPE_FUNCTION) { - std::shared_ptr func(new JSFunctionWrapper(cx, args.thisv().toObjectOrNull(), args.get(3))); + JS::RootedObject jstarget(cx, args.thisv().toObjectOrNull()); + std::shared_ptr func(new JSFunctionWrapper(cx, jstarget, args.get(3))); auto lambda = [=](float larg0) -> void { JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET jsval largv[1]; @@ -17793,7 +17199,8 @@ bool js_cocos2dx_ActionFloat_create(JSContext *cx, uint32_t argc, jsval *vp) do { if(JS_TypeOfValue(cx, args.get(3)) == JSTYPE_FUNCTION) { - std::shared_ptr func(new JSFunctionWrapper(cx, args.thisv().toObjectOrNull(), args.get(3))); + JS::RootedObject jstarget(cx, args.thisv().toObjectOrNull()); + std::shared_ptr func(new JSFunctionWrapper(cx, jstarget, args.get(3))); auto lambda = [=](float larg0) -> void { JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET jsval largv[1]; @@ -17846,8 +17253,8 @@ bool js_cocos2dx_ActionFloat_constructor(JSContext *cx, uint32_t argc, jsval *vp CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -17908,32 +17315,20 @@ void js_register_cocos2dx_ActionFloat(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ActionInterval_prototype); jsb_cocos2d_ActionFloat_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ActionInterval_prototype), + parent_proto, jsb_cocos2d_ActionFloat_class, js_cocos2dx_ActionFloat_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "ActionFloat", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_ActionFloat_class; - p->proto = jsb_cocos2d_ActionFloat_prototype; - p->parentProto = jsb_cocos2d_ActionInterval_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ActionFloat_prototype); + jsb_register_class(cx, jsb_cocos2d_ActionFloat_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.ActionFloat.extend = cc.Class.extend; })()"); } @@ -18449,30 +17844,17 @@ void js_register_cocos2dx_Configuration(JSContext *cx, JS::HandleObject global) jsb_cocos2d_Configuration_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocos2d_Configuration_class, empty_constructor, 0, properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "Configuration", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_Configuration_class; - p->proto = jsb_cocos2d_Configuration_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_Configuration_prototype); + jsb_register_class(cx, jsb_cocos2d_Configuration_class, proto, JS::NullPtr()); } JSClass *jsb_cocos2d_Properties_class; @@ -18589,7 +17971,7 @@ bool js_cocos2dx_Properties_getNamespace(JSContext *cx, uint32_t argc, jsval *vp JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::Properties *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Properties_getNamespace : Invalid Native Object"); @@ -18713,7 +18095,7 @@ bool js_cocos2dx_Properties_getMat4(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Mat4*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -18879,7 +18261,7 @@ bool js_cocos2dx_Properties_getColor(JSContext *cx, uint32_t argc, jsval *vp) JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::Properties *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Properties_getColor : Invalid Native Object"); @@ -18893,7 +18275,7 @@ bool js_cocos2dx_Properties_getColor(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Vec4*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -18917,7 +18299,7 @@ bool js_cocos2dx_Properties_getColor(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Vec3*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -19033,7 +18415,7 @@ bool js_cocos2dx_Properties_getVec3(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Vec3*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -19089,7 +18471,7 @@ bool js_cocos2dx_Properties_getVec4(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Vec4*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -19168,7 +18550,7 @@ bool js_cocos2dx_Properties_getQuaternionFromAxisAngle(JSContext *cx, uint32_t a if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Quaternion*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -19199,7 +18581,7 @@ bool js_cocos2dx_Properties_parseColor(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Vec4*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -19223,7 +18605,7 @@ bool js_cocos2dx_Properties_parseColor(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Vec3*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -19251,7 +18633,7 @@ bool js_cocos2dx_Properties_parseVec3(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Vec3*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -19279,7 +18661,7 @@ bool js_cocos2dx_Properties_parseAxisAngle(JSContext *cx, uint32_t argc, jsval * if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Quaternion*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -19352,7 +18734,7 @@ bool js_cocos2dx_Properties_parseVec4(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Vec4*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -19428,30 +18810,17 @@ void js_register_cocos2dx_Properties(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_Properties_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocos2d_Properties_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "Properties", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_Properties_class; - p->proto = jsb_cocos2d_Properties_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_Properties_prototype); + jsb_register_class(cx, jsb_cocos2d_Properties_class, proto, JS::NullPtr()); } JSClass *jsb_cocos2d_FileUtils_class; @@ -19552,7 +18921,7 @@ bool js_cocos2dx_FileUtils_renameFile(JSContext *cx, uint32_t argc, jsval *vp) JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::FileUtils *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_FileUtils_renameFile : Invalid Native Object"); @@ -20214,7 +19583,7 @@ bool js_cocos2dx_FileUtils_setDelegate(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::FileUtils*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -20316,30 +19685,17 @@ void js_register_cocos2dx_FileUtils(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_FileUtils_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocos2d_FileUtils_class, empty_constructor, 0, properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "FileUtils", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_FileUtils_class; - p->proto = jsb_cocos2d_FileUtils_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_FileUtils_prototype); + jsb_register_class(cx, jsb_cocos2d_FileUtils_class, proto, JS::NullPtr()); } JSClass *jsb_cocos2d_EventAcceleration_class; @@ -20364,8 +19720,8 @@ bool js_cocos2dx_EventAcceleration_constructor(JSContext *cx, uint32_t argc, jsv CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -20405,32 +19761,20 @@ void js_register_cocos2dx_EventAcceleration(JSContext *cx, JS::HandleObject glob JSFunctionSpec *st_funcs = NULL; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Event_prototype); jsb_cocos2d_EventAcceleration_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Event_prototype), + parent_proto, jsb_cocos2d_EventAcceleration_class, js_cocos2dx_EventAcceleration_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "EventAcceleration", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_EventAcceleration_class; - p->proto = jsb_cocos2d_EventAcceleration_prototype; - p->parentProto = jsb_cocos2d_Event_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_EventAcceleration_prototype); + jsb_register_class(cx, jsb_cocos2d_EventAcceleration_class, proto, parent_proto); } JSClass *jsb_cocos2d_EventCustom_class; @@ -20473,8 +19817,8 @@ bool js_cocos2dx_EventCustom_constructor(JSContext *cx, uint32_t argc, jsval *vp CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -20515,32 +19859,20 @@ void js_register_cocos2dx_EventCustom(JSContext *cx, JS::HandleObject global) { JSFunctionSpec *st_funcs = NULL; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Event_prototype); jsb_cocos2d_EventCustom_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Event_prototype), + parent_proto, jsb_cocos2d_EventCustom_class, js_cocos2dx_EventCustom_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "EventCustom", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_EventCustom_class; - p->proto = jsb_cocos2d_EventCustom_prototype; - p->parentProto = jsb_cocos2d_Event_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_EventCustom_prototype); + jsb_register_class(cx, jsb_cocos2d_EventCustom_class, proto, parent_proto); } JSClass *jsb_cocos2d_EventListener_class; @@ -20661,30 +19993,17 @@ void js_register_cocos2dx_EventListener(JSContext *cx, JS::HandleObject global) jsb_cocos2d_EventListener_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocos2d_EventListener_class, empty_constructor, 0, properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "EventListener", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_EventListener_class; - p->proto = jsb_cocos2d_EventListener_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_EventListener_prototype); + jsb_register_class(cx, jsb_cocos2d_EventListener_class, proto, JS::NullPtr()); } JSClass *jsb_cocos2d_EventDispatcher_class; @@ -20741,7 +20060,7 @@ bool js_cocos2dx_EventDispatcher_addEventListenerWithSceneGraphPriority(JSContex if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::EventListener*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -20750,7 +20069,7 @@ bool js_cocos2dx_EventDispatcher_addEventListenerWithSceneGraphPriority(JSContex if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -20779,7 +20098,8 @@ bool js_cocos2dx_EventDispatcher_addCustomEventListener(JSContext *cx, uint32_t do { if(JS_TypeOfValue(cx, args.get(1)) == JSTYPE_FUNCTION) { - std::shared_ptr func(new JSFunctionWrapper(cx, args.thisv().toObjectOrNull(), args.get(1))); + JS::RootedObject jstarget(cx, args.thisv().toObjectOrNull()); + std::shared_ptr func(new JSFunctionWrapper(cx, jstarget, args.get(1))); auto lambda = [=](cocos2d::EventCustom* larg0) -> void { JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET jsval largv[1]; @@ -20838,7 +20158,7 @@ bool js_cocos2dx_EventDispatcher_addEventListenerWithFixedPriority(JSContext *cx if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::EventListener*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -20860,7 +20180,7 @@ bool js_cocos2dx_EventDispatcher_removeEventListenersForTarget(JSContext *cx, ui JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::EventDispatcher *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_EventDispatcher_removeEventListenersForTarget : Invalid Native Object"); @@ -20871,7 +20191,7 @@ bool js_cocos2dx_EventDispatcher_removeEventListenersForTarget(JSContext *cx, ui if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -20890,7 +20210,7 @@ bool js_cocos2dx_EventDispatcher_removeEventListenersForTarget(JSContext *cx, ui if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -20932,7 +20252,7 @@ bool js_cocos2dx_EventDispatcher_resumeEventListenersForTarget(JSContext *cx, ui if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -20949,7 +20269,7 @@ bool js_cocos2dx_EventDispatcher_resumeEventListenersForTarget(JSContext *cx, ui if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -20979,7 +20299,7 @@ bool js_cocos2dx_EventDispatcher_setPriority(JSContext *cx, uint32_t argc, jsval if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::EventListener*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -21008,7 +20328,7 @@ bool js_cocos2dx_EventDispatcher_dispatchEvent(JSContext *cx, uint32_t argc, jsv if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Event*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -21036,7 +20356,7 @@ bool js_cocos2dx_EventDispatcher_pauseEventListenersForTarget(JSContext *cx, uin if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -21053,7 +20373,7 @@ bool js_cocos2dx_EventDispatcher_pauseEventListenersForTarget(JSContext *cx, uin if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -21102,7 +20422,7 @@ bool js_cocos2dx_EventDispatcher_removeEventListener(JSContext *cx, uint32_t arg if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::EventListener*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -21150,8 +20470,8 @@ bool js_cocos2dx_EventDispatcher_constructor(JSContext *cx, uint32_t argc, jsval CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -21204,30 +20524,17 @@ void js_register_cocos2dx_EventDispatcher(JSContext *cx, JS::HandleObject global jsb_cocos2d_EventDispatcher_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocos2d_EventDispatcher_class, js_cocos2dx_EventDispatcher_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "EventDispatcher", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_EventDispatcher_class; - p->proto = jsb_cocos2d_EventDispatcher_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_EventDispatcher_prototype); + jsb_register_class(cx, jsb_cocos2d_EventDispatcher_class, proto, JS::NullPtr()); } JSClass *jsb_cocos2d_EventFocus_class; @@ -21243,7 +20550,7 @@ bool js_cocos2dx_EventFocus_constructor(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ui::Widget*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -21252,7 +20559,7 @@ bool js_cocos2dx_EventFocus_constructor(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::ui::Widget*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -21270,8 +20577,8 @@ bool js_cocos2dx_EventFocus_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -21311,32 +20618,20 @@ void js_register_cocos2dx_EventFocus(JSContext *cx, JS::HandleObject global) { JSFunctionSpec *st_funcs = NULL; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Event_prototype); jsb_cocos2d_EventFocus_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Event_prototype), + parent_proto, jsb_cocos2d_EventFocus_class, js_cocos2dx_EventFocus_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "EventFocus", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_EventFocus_class; - p->proto = jsb_cocos2d_EventFocus_prototype; - p->parentProto = jsb_cocos2d_Event_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_EventFocus_prototype); + jsb_register_class(cx, jsb_cocos2d_EventFocus_class, proto, parent_proto); } JSClass *jsb_cocos2d_EventListenerAcceleration_class; @@ -21355,7 +20650,8 @@ bool js_cocos2dx_EventListenerAcceleration_init(JSContext *cx, uint32_t argc, js do { if(JS_TypeOfValue(cx, args.get(0)) == JSTYPE_FUNCTION) { - std::shared_ptr func(new JSFunctionWrapper(cx, args.thisv().toObjectOrNull(), args.get(0))); + JS::RootedObject jstarget(cx, args.thisv().toObjectOrNull()); + std::shared_ptr func(new JSFunctionWrapper(cx, jstarget, args.get(0))); auto lambda = [=](cocos2d::Acceleration* larg0, cocos2d::Event* larg1) -> void { JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET jsval largv[2]; @@ -21402,7 +20698,8 @@ bool js_cocos2dx_EventListenerAcceleration_create(JSContext *cx, uint32_t argc, do { if(JS_TypeOfValue(cx, args.get(0)) == JSTYPE_FUNCTION) { - std::shared_ptr func(new JSFunctionWrapper(cx, args.thisv().toObjectOrNull(), args.get(0))); + JS::RootedObject jstarget(cx, args.thisv().toObjectOrNull()); + std::shared_ptr func(new JSFunctionWrapper(cx, jstarget, args.get(0))); auto lambda = [=](cocos2d::Acceleration* larg0, cocos2d::Event* larg1) -> void { JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET jsval largv[2]; @@ -21463,8 +20760,8 @@ bool js_cocos2dx_EventListenerAcceleration_constructor(JSContext *cx, uint32_t a CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -21508,32 +20805,20 @@ void js_register_cocos2dx_EventListenerAcceleration(JSContext *cx, JS::HandleObj JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_EventListener_prototype); jsb_cocos2d_EventListenerAcceleration_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_EventListener_prototype), + parent_proto, jsb_cocos2d_EventListenerAcceleration_class, js_cocos2dx_EventListenerAcceleration_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "EventListenerAcceleration", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_EventListenerAcceleration_class; - p->proto = jsb_cocos2d_EventListenerAcceleration_prototype; - p->parentProto = jsb_cocos2d_EventListener_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_EventListenerAcceleration_prototype); + jsb_register_class(cx, jsb_cocos2d_EventListenerAcceleration_class, proto, parent_proto); } JSClass *jsb_cocos2d_EventListenerCustom_class; @@ -21550,7 +20835,8 @@ bool js_cocos2dx_EventListenerCustom_create(JSContext *cx, uint32_t argc, jsval do { if(JS_TypeOfValue(cx, args.get(1)) == JSTYPE_FUNCTION) { - std::shared_ptr func(new JSFunctionWrapper(cx, args.thisv().toObjectOrNull(), args.get(1))); + JS::RootedObject jstarget(cx, args.thisv().toObjectOrNull()); + std::shared_ptr func(new JSFunctionWrapper(cx, jstarget, args.get(1))); auto lambda = [=](cocos2d::EventCustom* larg0) -> void { JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET jsval largv[1]; @@ -21610,8 +20896,8 @@ bool js_cocos2dx_EventListenerCustom_constructor(JSContext *cx, uint32_t argc, j CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -21654,32 +20940,20 @@ void js_register_cocos2dx_EventListenerCustom(JSContext *cx, JS::HandleObject gl JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_EventListener_prototype); jsb_cocos2d_EventListenerCustom_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_EventListener_prototype), + parent_proto, jsb_cocos2d_EventListenerCustom_class, js_cocos2dx_EventListenerCustom_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "EventListenerCustom", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_EventListenerCustom_class; - p->proto = jsb_cocos2d_EventListenerCustom_prototype; - p->parentProto = jsb_cocos2d_EventListener_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_EventListenerCustom_prototype); + jsb_register_class(cx, jsb_cocos2d_EventListenerCustom_class, proto, parent_proto); } JSClass *jsb_cocos2d_EventListenerFocus_class; @@ -21719,8 +20993,8 @@ bool js_cocos2dx_EventListenerFocus_constructor(JSContext *cx, uint32_t argc, js CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -21761,32 +21035,20 @@ void js_register_cocos2dx_EventListenerFocus(JSContext *cx, JS::HandleObject glo JSFunctionSpec *st_funcs = NULL; + JS::RootedObject parent_proto(cx, jsb_cocos2d_EventListener_prototype); jsb_cocos2d_EventListenerFocus_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_EventListener_prototype), + parent_proto, jsb_cocos2d_EventListenerFocus_class, js_cocos2dx_EventListenerFocus_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "EventListenerFocus", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_EventListenerFocus_class; - p->proto = jsb_cocos2d_EventListenerFocus_prototype; - p->parentProto = jsb_cocos2d_EventListener_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_EventListenerFocus_prototype); + jsb_register_class(cx, jsb_cocos2d_EventListenerFocus_class, proto, parent_proto); } JSClass *jsb_cocos2d_EventListenerKeyboard_class; @@ -21826,8 +21088,8 @@ bool js_cocos2dx_EventListenerKeyboard_constructor(JSContext *cx, uint32_t argc, CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -21868,32 +21130,20 @@ void js_register_cocos2dx_EventListenerKeyboard(JSContext *cx, JS::HandleObject JSFunctionSpec *st_funcs = NULL; + JS::RootedObject parent_proto(cx, jsb_cocos2d_EventListener_prototype); jsb_cocos2d_EventListenerKeyboard_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_EventListener_prototype), + parent_proto, jsb_cocos2d_EventListenerKeyboard_class, js_cocos2dx_EventListenerKeyboard_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "EventListenerKeyboard", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_EventListenerKeyboard_class; - p->proto = jsb_cocos2d_EventListenerKeyboard_prototype; - p->parentProto = jsb_cocos2d_EventListener_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_EventListenerKeyboard_prototype); + jsb_register_class(cx, jsb_cocos2d_EventListenerKeyboard_class, proto, parent_proto); } JSClass *jsb_cocos2d_EventMouse_class; @@ -22198,8 +21448,8 @@ bool js_cocos2dx_EventMouse_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -22254,32 +21504,20 @@ void js_register_cocos2dx_EventMouse(JSContext *cx, JS::HandleObject global) { JSFunctionSpec *st_funcs = NULL; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Event_prototype); jsb_cocos2d_EventMouse_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Event_prototype), + parent_proto, jsb_cocos2d_EventMouse_class, js_cocos2dx_EventMouse_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "EventMouse", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_EventMouse_class; - p->proto = jsb_cocos2d_EventMouse_prototype; - p->parentProto = jsb_cocos2d_Event_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_EventMouse_prototype); + jsb_register_class(cx, jsb_cocos2d_EventMouse_class, proto, parent_proto); } JSClass *jsb_cocos2d_EventListenerMouse_class; @@ -22319,8 +21557,8 @@ bool js_cocos2dx_EventListenerMouse_constructor(JSContext *cx, uint32_t argc, js CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -22361,32 +21599,20 @@ void js_register_cocos2dx_EventListenerMouse(JSContext *cx, JS::HandleObject glo JSFunctionSpec *st_funcs = NULL; + JS::RootedObject parent_proto(cx, jsb_cocos2d_EventListener_prototype); jsb_cocos2d_EventListenerMouse_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_EventListener_prototype), + parent_proto, jsb_cocos2d_EventListenerMouse_class, js_cocos2dx_EventListenerMouse_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "EventListenerMouse", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_EventListenerMouse_class; - p->proto = jsb_cocos2d_EventListenerMouse_prototype; - p->parentProto = jsb_cocos2d_EventListener_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_EventListenerMouse_prototype); + jsb_register_class(cx, jsb_cocos2d_EventListenerMouse_class, proto, parent_proto); } JSClass *jsb_cocos2d_EventListenerTouchOneByOne_class; @@ -22464,8 +21690,8 @@ bool js_cocos2dx_EventListenerTouchOneByOne_constructor(JSContext *cx, uint32_t CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -22508,32 +21734,20 @@ void js_register_cocos2dx_EventListenerTouchOneByOne(JSContext *cx, JS::HandleOb JSFunctionSpec *st_funcs = NULL; + JS::RootedObject parent_proto(cx, jsb_cocos2d_EventListener_prototype); jsb_cocos2d_EventListenerTouchOneByOne_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_EventListener_prototype), + parent_proto, jsb_cocos2d_EventListenerTouchOneByOne_class, js_cocos2dx_EventListenerTouchOneByOne_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "EventListenerTouchOneByOne", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_EventListenerTouchOneByOne_class; - p->proto = jsb_cocos2d_EventListenerTouchOneByOne_prototype; - p->parentProto = jsb_cocos2d_EventListener_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_EventListenerTouchOneByOne_prototype); + jsb_register_class(cx, jsb_cocos2d_EventListenerTouchOneByOne_class, proto, parent_proto); } JSClass *jsb_cocos2d_EventListenerTouchAllAtOnce_class; @@ -22573,8 +21787,8 @@ bool js_cocos2dx_EventListenerTouchAllAtOnce_constructor(JSContext *cx, uint32_t CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -22615,32 +21829,20 @@ void js_register_cocos2dx_EventListenerTouchAllAtOnce(JSContext *cx, JS::HandleO JSFunctionSpec *st_funcs = NULL; + JS::RootedObject parent_proto(cx, jsb_cocos2d_EventListener_prototype); jsb_cocos2d_EventListenerTouchAllAtOnce_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_EventListener_prototype), + parent_proto, jsb_cocos2d_EventListenerTouchAllAtOnce_class, js_cocos2dx_EventListenerTouchAllAtOnce_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "EventListenerTouchAllAtOnce", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_EventListenerTouchAllAtOnce_class; - p->proto = jsb_cocos2d_EventListenerTouchAllAtOnce_prototype; - p->parentProto = jsb_cocos2d_EventListener_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_EventListenerTouchAllAtOnce_prototype); + jsb_register_class(cx, jsb_cocos2d_EventListenerTouchAllAtOnce_class, proto, parent_proto); } JSClass *jsb_cocos2d_ActionCamera_class; @@ -22653,7 +21855,7 @@ bool js_cocos2dx_ActionCamera_setEye(JSContext *cx, uint32_t argc, jsval *vp) JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::ActionCamera *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ActionCamera_setEye : Invalid Native Object"); @@ -22798,8 +22000,8 @@ bool js_cocos2dx_ActionCamera_constructor(JSContext *cx, uint32_t argc, jsval *v CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -22862,32 +22064,20 @@ void js_register_cocos2dx_ActionCamera(JSContext *cx, JS::HandleObject global) { JSFunctionSpec *st_funcs = NULL; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ActionInterval_prototype); jsb_cocos2d_ActionCamera_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ActionInterval_prototype), + parent_proto, jsb_cocos2d_ActionCamera_class, js_cocos2dx_ActionCamera_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "ActionCamera", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_ActionCamera_class; - p->proto = jsb_cocos2d_ActionCamera_prototype; - p->parentProto = jsb_cocos2d_ActionInterval_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ActionCamera_prototype); + jsb_register_class(cx, jsb_cocos2d_ActionCamera_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.ActionCamera.extend = cc.Class.extend; })()"); } @@ -23008,8 +22198,8 @@ bool js_cocos2dx_OrbitCamera_constructor(JSContext *cx, uint32_t argc, jsval *vp CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -23071,32 +22261,20 @@ void js_register_cocos2dx_OrbitCamera(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ActionCamera_prototype); jsb_cocos2d_OrbitCamera_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ActionCamera_prototype), + parent_proto, jsb_cocos2d_OrbitCamera_class, js_cocos2dx_OrbitCamera_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "OrbitCamera", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_OrbitCamera_class; - p->proto = jsb_cocos2d_OrbitCamera_prototype; - p->parentProto = jsb_cocos2d_ActionCamera_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_OrbitCamera_prototype); + jsb_register_class(cx, jsb_cocos2d_OrbitCamera_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.OrbitCamera.extend = cc.Class.extend; })()"); } @@ -23164,8 +22342,8 @@ bool js_cocos2dx_CardinalSplineTo_constructor(JSContext *cx, uint32_t argc, jsva CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -23207,32 +22385,20 @@ void js_register_cocos2dx_CardinalSplineTo(JSContext *cx, JS::HandleObject globa JSFunctionSpec *st_funcs = NULL; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ActionInterval_prototype); jsb_cocos2d_CardinalSplineTo_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ActionInterval_prototype), + parent_proto, jsb_cocos2d_CardinalSplineTo_class, js_cocos2dx_CardinalSplineTo_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "CardinalSplineTo", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_CardinalSplineTo_class; - p->proto = jsb_cocos2d_CardinalSplineTo_prototype; - p->parentProto = jsb_cocos2d_ActionInterval_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_CardinalSplineTo_prototype); + jsb_register_class(cx, jsb_cocos2d_CardinalSplineTo_class, proto, parent_proto); } JSClass *jsb_cocos2d_CardinalSplineBy_class; @@ -23254,8 +22420,8 @@ bool js_cocos2dx_CardinalSplineBy_constructor(JSContext *cx, uint32_t argc, jsva CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -23295,32 +22461,20 @@ void js_register_cocos2dx_CardinalSplineBy(JSContext *cx, JS::HandleObject globa JSFunctionSpec *st_funcs = NULL; + JS::RootedObject parent_proto(cx, jsb_cocos2d_CardinalSplineTo_prototype); jsb_cocos2d_CardinalSplineBy_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_CardinalSplineTo_prototype), + parent_proto, jsb_cocos2d_CardinalSplineBy_class, js_cocos2dx_CardinalSplineBy_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "CardinalSplineBy", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_CardinalSplineBy_class; - p->proto = jsb_cocos2d_CardinalSplineBy_prototype; - p->parentProto = jsb_cocos2d_CardinalSplineTo_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_CardinalSplineBy_prototype); + jsb_register_class(cx, jsb_cocos2d_CardinalSplineBy_class, proto, parent_proto); } JSClass *jsb_cocos2d_CatmullRomTo_class; @@ -23356,32 +22510,20 @@ void js_register_cocos2dx_CatmullRomTo(JSContext *cx, JS::HandleObject global) { JSFunctionSpec *st_funcs = NULL; + JS::RootedObject parent_proto(cx, jsb_cocos2d_CardinalSplineTo_prototype); jsb_cocos2d_CatmullRomTo_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_CardinalSplineTo_prototype), + parent_proto, jsb_cocos2d_CatmullRomTo_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "CatmullRomTo", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_CatmullRomTo_class; - p->proto = jsb_cocos2d_CatmullRomTo_prototype; - p->parentProto = jsb_cocos2d_CardinalSplineTo_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_CatmullRomTo_prototype); + jsb_register_class(cx, jsb_cocos2d_CatmullRomTo_class, proto, parent_proto); } JSClass *jsb_cocos2d_CatmullRomBy_class; @@ -23417,32 +22559,20 @@ void js_register_cocos2dx_CatmullRomBy(JSContext *cx, JS::HandleObject global) { JSFunctionSpec *st_funcs = NULL; + JS::RootedObject parent_proto(cx, jsb_cocos2d_CardinalSplineBy_prototype); jsb_cocos2d_CatmullRomBy_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_CardinalSplineBy_prototype), + parent_proto, jsb_cocos2d_CatmullRomBy_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "CatmullRomBy", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_CatmullRomBy_class; - p->proto = jsb_cocos2d_CatmullRomBy_prototype; - p->parentProto = jsb_cocos2d_CardinalSplineBy_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_CatmullRomBy_prototype); + jsb_register_class(cx, jsb_cocos2d_CatmullRomBy_class, proto, parent_proto); } JSClass *jsb_cocos2d_ActionEase_class; @@ -23462,7 +22592,7 @@ bool js_cocos2dx_ActionEase_initWithAction(JSContext *cx, uint32_t argc, jsval * if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -23535,32 +22665,20 @@ void js_register_cocos2dx_ActionEase(JSContext *cx, JS::HandleObject global) { JSFunctionSpec *st_funcs = NULL; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ActionInterval_prototype); jsb_cocos2d_ActionEase_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ActionInterval_prototype), + parent_proto, jsb_cocos2d_ActionEase_class, empty_constructor, 0, properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "ActionEase", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_ActionEase_class; - p->proto = jsb_cocos2d_ActionEase_prototype; - p->parentProto = jsb_cocos2d_ActionInterval_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ActionEase_prototype); + jsb_register_class(cx, jsb_cocos2d_ActionEase_class, proto, parent_proto); } JSClass *jsb_cocos2d_EaseRateAction_class; @@ -23601,7 +22719,7 @@ bool js_cocos2dx_EaseRateAction_initWithAction(JSContext *cx, uint32_t argc, jsv if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -23647,7 +22765,7 @@ bool js_cocos2dx_EaseRateAction_create(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -23707,32 +22825,20 @@ void js_register_cocos2dx_EaseRateAction(JSContext *cx, JS::HandleObject global) JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ActionEase_prototype); jsb_cocos2d_EaseRateAction_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ActionEase_prototype), + parent_proto, jsb_cocos2d_EaseRateAction_class, empty_constructor, 0, properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "EaseRateAction", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_EaseRateAction_class; - p->proto = jsb_cocos2d_EaseRateAction_prototype; - p->parentProto = jsb_cocos2d_ActionEase_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_EaseRateAction_prototype); + jsb_register_class(cx, jsb_cocos2d_EaseRateAction_class, proto, parent_proto); } JSClass *jsb_cocos2d_EaseIn_class; @@ -23749,7 +22855,7 @@ bool js_cocos2dx_EaseIn_create(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -23789,8 +22895,8 @@ bool js_cocos2dx_EaseIn_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -23850,32 +22956,20 @@ void js_register_cocos2dx_EaseIn(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_EaseRateAction_prototype); jsb_cocos2d_EaseIn_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_EaseRateAction_prototype), + parent_proto, jsb_cocos2d_EaseIn_class, js_cocos2dx_EaseIn_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "EaseIn", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_EaseIn_class; - p->proto = jsb_cocos2d_EaseIn_prototype; - p->parentProto = jsb_cocos2d_EaseRateAction_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_EaseIn_prototype); + jsb_register_class(cx, jsb_cocos2d_EaseIn_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.EaseIn.extend = cc.Class.extend; })()"); } @@ -23893,7 +22987,7 @@ bool js_cocos2dx_EaseOut_create(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -23933,8 +23027,8 @@ bool js_cocos2dx_EaseOut_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -23994,32 +23088,20 @@ void js_register_cocos2dx_EaseOut(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_EaseRateAction_prototype); jsb_cocos2d_EaseOut_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_EaseRateAction_prototype), + parent_proto, jsb_cocos2d_EaseOut_class, js_cocos2dx_EaseOut_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "EaseOut", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_EaseOut_class; - p->proto = jsb_cocos2d_EaseOut_prototype; - p->parentProto = jsb_cocos2d_EaseRateAction_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_EaseOut_prototype); + jsb_register_class(cx, jsb_cocos2d_EaseOut_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.EaseOut.extend = cc.Class.extend; })()"); } @@ -24037,7 +23119,7 @@ bool js_cocos2dx_EaseInOut_create(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -24077,8 +23159,8 @@ bool js_cocos2dx_EaseInOut_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -24138,32 +23220,20 @@ void js_register_cocos2dx_EaseInOut(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_EaseRateAction_prototype); jsb_cocos2d_EaseInOut_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_EaseRateAction_prototype), + parent_proto, jsb_cocos2d_EaseInOut_class, js_cocos2dx_EaseInOut_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "EaseInOut", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_EaseInOut_class; - p->proto = jsb_cocos2d_EaseInOut_prototype; - p->parentProto = jsb_cocos2d_EaseRateAction_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_EaseInOut_prototype); + jsb_register_class(cx, jsb_cocos2d_EaseInOut_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.EaseInOut.extend = cc.Class.extend; })()"); } @@ -24180,7 +23250,7 @@ bool js_cocos2dx_EaseExponentialIn_create(JSContext *cx, uint32_t argc, jsval *v if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -24219,8 +23289,8 @@ bool js_cocos2dx_EaseExponentialIn_constructor(JSContext *cx, uint32_t argc, jsv CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -24280,32 +23350,20 @@ void js_register_cocos2dx_EaseExponentialIn(JSContext *cx, JS::HandleObject glob JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ActionEase_prototype); jsb_cocos2d_EaseExponentialIn_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ActionEase_prototype), + parent_proto, jsb_cocos2d_EaseExponentialIn_class, js_cocos2dx_EaseExponentialIn_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "EaseExponentialIn", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_EaseExponentialIn_class; - p->proto = jsb_cocos2d_EaseExponentialIn_prototype; - p->parentProto = jsb_cocos2d_ActionEase_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_EaseExponentialIn_prototype); + jsb_register_class(cx, jsb_cocos2d_EaseExponentialIn_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.EaseExponentialIn.extend = cc.Class.extend; })()"); } @@ -24322,7 +23380,7 @@ bool js_cocos2dx_EaseExponentialOut_create(JSContext *cx, uint32_t argc, jsval * if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -24361,8 +23419,8 @@ bool js_cocos2dx_EaseExponentialOut_constructor(JSContext *cx, uint32_t argc, js CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -24422,32 +23480,20 @@ void js_register_cocos2dx_EaseExponentialOut(JSContext *cx, JS::HandleObject glo JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ActionEase_prototype); jsb_cocos2d_EaseExponentialOut_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ActionEase_prototype), + parent_proto, jsb_cocos2d_EaseExponentialOut_class, js_cocos2dx_EaseExponentialOut_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "EaseExponentialOut", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_EaseExponentialOut_class; - p->proto = jsb_cocos2d_EaseExponentialOut_prototype; - p->parentProto = jsb_cocos2d_ActionEase_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_EaseExponentialOut_prototype); + jsb_register_class(cx, jsb_cocos2d_EaseExponentialOut_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.EaseExponentialOut.extend = cc.Class.extend; })()"); } @@ -24464,7 +23510,7 @@ bool js_cocos2dx_EaseExponentialInOut_create(JSContext *cx, uint32_t argc, jsval if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -24503,8 +23549,8 @@ bool js_cocos2dx_EaseExponentialInOut_constructor(JSContext *cx, uint32_t argc, CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -24564,32 +23610,20 @@ void js_register_cocos2dx_EaseExponentialInOut(JSContext *cx, JS::HandleObject g JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ActionEase_prototype); jsb_cocos2d_EaseExponentialInOut_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ActionEase_prototype), + parent_proto, jsb_cocos2d_EaseExponentialInOut_class, js_cocos2dx_EaseExponentialInOut_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "EaseExponentialInOut", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_EaseExponentialInOut_class; - p->proto = jsb_cocos2d_EaseExponentialInOut_prototype; - p->parentProto = jsb_cocos2d_ActionEase_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_EaseExponentialInOut_prototype); + jsb_register_class(cx, jsb_cocos2d_EaseExponentialInOut_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.EaseExponentialInOut.extend = cc.Class.extend; })()"); } @@ -24606,7 +23640,7 @@ bool js_cocos2dx_EaseSineIn_create(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -24645,8 +23679,8 @@ bool js_cocos2dx_EaseSineIn_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -24706,32 +23740,20 @@ void js_register_cocos2dx_EaseSineIn(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ActionEase_prototype); jsb_cocos2d_EaseSineIn_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ActionEase_prototype), + parent_proto, jsb_cocos2d_EaseSineIn_class, js_cocos2dx_EaseSineIn_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "EaseSineIn", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_EaseSineIn_class; - p->proto = jsb_cocos2d_EaseSineIn_prototype; - p->parentProto = jsb_cocos2d_ActionEase_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_EaseSineIn_prototype); + jsb_register_class(cx, jsb_cocos2d_EaseSineIn_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.EaseSineIn.extend = cc.Class.extend; })()"); } @@ -24748,7 +23770,7 @@ bool js_cocos2dx_EaseSineOut_create(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -24787,8 +23809,8 @@ bool js_cocos2dx_EaseSineOut_constructor(JSContext *cx, uint32_t argc, jsval *vp CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -24848,32 +23870,20 @@ void js_register_cocos2dx_EaseSineOut(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ActionEase_prototype); jsb_cocos2d_EaseSineOut_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ActionEase_prototype), + parent_proto, jsb_cocos2d_EaseSineOut_class, js_cocos2dx_EaseSineOut_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "EaseSineOut", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_EaseSineOut_class; - p->proto = jsb_cocos2d_EaseSineOut_prototype; - p->parentProto = jsb_cocos2d_ActionEase_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_EaseSineOut_prototype); + jsb_register_class(cx, jsb_cocos2d_EaseSineOut_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.EaseSineOut.extend = cc.Class.extend; })()"); } @@ -24890,7 +23900,7 @@ bool js_cocos2dx_EaseSineInOut_create(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -24929,8 +23939,8 @@ bool js_cocos2dx_EaseSineInOut_constructor(JSContext *cx, uint32_t argc, jsval * CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -24990,32 +24000,20 @@ void js_register_cocos2dx_EaseSineInOut(JSContext *cx, JS::HandleObject global) JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ActionEase_prototype); jsb_cocos2d_EaseSineInOut_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ActionEase_prototype), + parent_proto, jsb_cocos2d_EaseSineInOut_class, js_cocos2dx_EaseSineInOut_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "EaseSineInOut", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_EaseSineInOut_class; - p->proto = jsb_cocos2d_EaseSineInOut_prototype; - p->parentProto = jsb_cocos2d_ActionEase_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_EaseSineInOut_prototype); + jsb_register_class(cx, jsb_cocos2d_EaseSineInOut_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.EaseSineInOut.extend = cc.Class.extend; })()"); } @@ -25056,7 +24054,7 @@ bool js_cocos2dx_EaseElastic_initWithAction(JSContext *cx, uint32_t argc, jsval if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -25075,7 +24073,7 @@ bool js_cocos2dx_EaseElastic_initWithAction(JSContext *cx, uint32_t argc, jsval if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -25143,32 +24141,20 @@ void js_register_cocos2dx_EaseElastic(JSContext *cx, JS::HandleObject global) { JSFunctionSpec *st_funcs = NULL; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ActionEase_prototype); jsb_cocos2d_EaseElastic_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ActionEase_prototype), + parent_proto, jsb_cocos2d_EaseElastic_class, empty_constructor, 0, properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "EaseElastic", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_EaseElastic_class; - p->proto = jsb_cocos2d_EaseElastic_prototype; - p->parentProto = jsb_cocos2d_ActionEase_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_EaseElastic_prototype); + jsb_register_class(cx, jsb_cocos2d_EaseElastic_class, proto, parent_proto); } JSClass *jsb_cocos2d_EaseElasticIn_class; @@ -25186,7 +24172,7 @@ bool js_cocos2dx_EaseElasticIn_create(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -25214,7 +24200,7 @@ bool js_cocos2dx_EaseElasticIn_create(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -25256,8 +24242,8 @@ bool js_cocos2dx_EaseElasticIn_constructor(JSContext *cx, uint32_t argc, jsval * CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -25317,32 +24303,20 @@ void js_register_cocos2dx_EaseElasticIn(JSContext *cx, JS::HandleObject global) JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_EaseElastic_prototype); jsb_cocos2d_EaseElasticIn_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_EaseElastic_prototype), + parent_proto, jsb_cocos2d_EaseElasticIn_class, js_cocos2dx_EaseElasticIn_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "EaseElasticIn", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_EaseElasticIn_class; - p->proto = jsb_cocos2d_EaseElasticIn_prototype; - p->parentProto = jsb_cocos2d_EaseElastic_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_EaseElasticIn_prototype); + jsb_register_class(cx, jsb_cocos2d_EaseElasticIn_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.EaseElasticIn.extend = cc.Class.extend; })()"); } @@ -25361,7 +24335,7 @@ bool js_cocos2dx_EaseElasticOut_create(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -25389,7 +24363,7 @@ bool js_cocos2dx_EaseElasticOut_create(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -25431,8 +24405,8 @@ bool js_cocos2dx_EaseElasticOut_constructor(JSContext *cx, uint32_t argc, jsval CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -25492,32 +24466,20 @@ void js_register_cocos2dx_EaseElasticOut(JSContext *cx, JS::HandleObject global) JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_EaseElastic_prototype); jsb_cocos2d_EaseElasticOut_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_EaseElastic_prototype), + parent_proto, jsb_cocos2d_EaseElasticOut_class, js_cocos2dx_EaseElasticOut_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "EaseElasticOut", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_EaseElasticOut_class; - p->proto = jsb_cocos2d_EaseElasticOut_prototype; - p->parentProto = jsb_cocos2d_EaseElastic_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_EaseElasticOut_prototype); + jsb_register_class(cx, jsb_cocos2d_EaseElasticOut_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.EaseElasticOut.extend = cc.Class.extend; })()"); } @@ -25536,7 +24498,7 @@ bool js_cocos2dx_EaseElasticInOut_create(JSContext *cx, uint32_t argc, jsval *vp if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -25564,7 +24526,7 @@ bool js_cocos2dx_EaseElasticInOut_create(JSContext *cx, uint32_t argc, jsval *vp if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -25606,8 +24568,8 @@ bool js_cocos2dx_EaseElasticInOut_constructor(JSContext *cx, uint32_t argc, jsva CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -25667,32 +24629,20 @@ void js_register_cocos2dx_EaseElasticInOut(JSContext *cx, JS::HandleObject globa JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_EaseElastic_prototype); jsb_cocos2d_EaseElasticInOut_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_EaseElastic_prototype), + parent_proto, jsb_cocos2d_EaseElasticInOut_class, js_cocos2dx_EaseElasticInOut_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "EaseElasticInOut", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_EaseElasticInOut_class; - p->proto = jsb_cocos2d_EaseElasticInOut_prototype; - p->parentProto = jsb_cocos2d_EaseElastic_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_EaseElasticInOut_prototype); + jsb_register_class(cx, jsb_cocos2d_EaseElasticInOut_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.EaseElasticInOut.extend = cc.Class.extend; })()"); } @@ -25729,32 +24679,20 @@ void js_register_cocos2dx_EaseBounce(JSContext *cx, JS::HandleObject global) { JSFunctionSpec *st_funcs = NULL; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ActionEase_prototype); jsb_cocos2d_EaseBounce_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ActionEase_prototype), + parent_proto, jsb_cocos2d_EaseBounce_class, empty_constructor, 0, properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "EaseBounce", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_EaseBounce_class; - p->proto = jsb_cocos2d_EaseBounce_prototype; - p->parentProto = jsb_cocos2d_ActionEase_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_EaseBounce_prototype); + jsb_register_class(cx, jsb_cocos2d_EaseBounce_class, proto, parent_proto); } JSClass *jsb_cocos2d_EaseBounceIn_class; @@ -25770,7 +24708,7 @@ bool js_cocos2dx_EaseBounceIn_create(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -25809,8 +24747,8 @@ bool js_cocos2dx_EaseBounceIn_constructor(JSContext *cx, uint32_t argc, jsval *v CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -25870,32 +24808,20 @@ void js_register_cocos2dx_EaseBounceIn(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_EaseBounce_prototype); jsb_cocos2d_EaseBounceIn_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_EaseBounce_prototype), + parent_proto, jsb_cocos2d_EaseBounceIn_class, js_cocos2dx_EaseBounceIn_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "EaseBounceIn", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_EaseBounceIn_class; - p->proto = jsb_cocos2d_EaseBounceIn_prototype; - p->parentProto = jsb_cocos2d_EaseBounce_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_EaseBounceIn_prototype); + jsb_register_class(cx, jsb_cocos2d_EaseBounceIn_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.EaseBounceIn.extend = cc.Class.extend; })()"); } @@ -25912,7 +24838,7 @@ bool js_cocos2dx_EaseBounceOut_create(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -25951,8 +24877,8 @@ bool js_cocos2dx_EaseBounceOut_constructor(JSContext *cx, uint32_t argc, jsval * CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -26012,32 +24938,20 @@ void js_register_cocos2dx_EaseBounceOut(JSContext *cx, JS::HandleObject global) JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_EaseBounce_prototype); jsb_cocos2d_EaseBounceOut_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_EaseBounce_prototype), + parent_proto, jsb_cocos2d_EaseBounceOut_class, js_cocos2dx_EaseBounceOut_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "EaseBounceOut", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_EaseBounceOut_class; - p->proto = jsb_cocos2d_EaseBounceOut_prototype; - p->parentProto = jsb_cocos2d_EaseBounce_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_EaseBounceOut_prototype); + jsb_register_class(cx, jsb_cocos2d_EaseBounceOut_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.EaseBounceOut.extend = cc.Class.extend; })()"); } @@ -26054,7 +24968,7 @@ bool js_cocos2dx_EaseBounceInOut_create(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -26093,8 +25007,8 @@ bool js_cocos2dx_EaseBounceInOut_constructor(JSContext *cx, uint32_t argc, jsval CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -26154,32 +25068,20 @@ void js_register_cocos2dx_EaseBounceInOut(JSContext *cx, JS::HandleObject global JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_EaseBounce_prototype); jsb_cocos2d_EaseBounceInOut_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_EaseBounce_prototype), + parent_proto, jsb_cocos2d_EaseBounceInOut_class, js_cocos2dx_EaseBounceInOut_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "EaseBounceInOut", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_EaseBounceInOut_class; - p->proto = jsb_cocos2d_EaseBounceInOut_prototype; - p->parentProto = jsb_cocos2d_EaseBounce_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_EaseBounceInOut_prototype); + jsb_register_class(cx, jsb_cocos2d_EaseBounceInOut_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.EaseBounceInOut.extend = cc.Class.extend; })()"); } @@ -26196,7 +25098,7 @@ bool js_cocos2dx_EaseBackIn_create(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -26235,8 +25137,8 @@ bool js_cocos2dx_EaseBackIn_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -26296,32 +25198,20 @@ void js_register_cocos2dx_EaseBackIn(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ActionEase_prototype); jsb_cocos2d_EaseBackIn_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ActionEase_prototype), + parent_proto, jsb_cocos2d_EaseBackIn_class, js_cocos2dx_EaseBackIn_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "EaseBackIn", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_EaseBackIn_class; - p->proto = jsb_cocos2d_EaseBackIn_prototype; - p->parentProto = jsb_cocos2d_ActionEase_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_EaseBackIn_prototype); + jsb_register_class(cx, jsb_cocos2d_EaseBackIn_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.EaseBackIn.extend = cc.Class.extend; })()"); } @@ -26338,7 +25228,7 @@ bool js_cocos2dx_EaseBackOut_create(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -26377,8 +25267,8 @@ bool js_cocos2dx_EaseBackOut_constructor(JSContext *cx, uint32_t argc, jsval *vp CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -26438,32 +25328,20 @@ void js_register_cocos2dx_EaseBackOut(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ActionEase_prototype); jsb_cocos2d_EaseBackOut_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ActionEase_prototype), + parent_proto, jsb_cocos2d_EaseBackOut_class, js_cocos2dx_EaseBackOut_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "EaseBackOut", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_EaseBackOut_class; - p->proto = jsb_cocos2d_EaseBackOut_prototype; - p->parentProto = jsb_cocos2d_ActionEase_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_EaseBackOut_prototype); + jsb_register_class(cx, jsb_cocos2d_EaseBackOut_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.EaseBackOut.extend = cc.Class.extend; })()"); } @@ -26480,7 +25358,7 @@ bool js_cocos2dx_EaseBackInOut_create(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -26519,8 +25397,8 @@ bool js_cocos2dx_EaseBackInOut_constructor(JSContext *cx, uint32_t argc, jsval * CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -26580,32 +25458,20 @@ void js_register_cocos2dx_EaseBackInOut(JSContext *cx, JS::HandleObject global) JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ActionEase_prototype); jsb_cocos2d_EaseBackInOut_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ActionEase_prototype), + parent_proto, jsb_cocos2d_EaseBackInOut_class, js_cocos2dx_EaseBackInOut_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "EaseBackInOut", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_EaseBackInOut_class; - p->proto = jsb_cocos2d_EaseBackInOut_prototype; - p->parentProto = jsb_cocos2d_ActionEase_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_EaseBackInOut_prototype); + jsb_register_class(cx, jsb_cocos2d_EaseBackInOut_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.EaseBackInOut.extend = cc.Class.extend; })()"); } @@ -26648,7 +25514,7 @@ bool js_cocos2dx_EaseBezierAction_create(JSContext *cx, uint32_t argc, jsval *vp if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -26687,8 +25553,8 @@ bool js_cocos2dx_EaseBezierAction_constructor(JSContext *cx, uint32_t argc, jsva CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -26749,32 +25615,20 @@ void js_register_cocos2dx_EaseBezierAction(JSContext *cx, JS::HandleObject globa JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ActionEase_prototype); jsb_cocos2d_EaseBezierAction_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ActionEase_prototype), + parent_proto, jsb_cocos2d_EaseBezierAction_class, js_cocos2dx_EaseBezierAction_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "EaseBezierAction", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_EaseBezierAction_class; - p->proto = jsb_cocos2d_EaseBezierAction_prototype; - p->parentProto = jsb_cocos2d_ActionEase_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_EaseBezierAction_prototype); + jsb_register_class(cx, jsb_cocos2d_EaseBezierAction_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.EaseBezierAction.extend = cc.Class.extend; })()"); } @@ -26791,7 +25645,7 @@ bool js_cocos2dx_EaseQuadraticActionIn_create(JSContext *cx, uint32_t argc, jsva if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -26830,8 +25684,8 @@ bool js_cocos2dx_EaseQuadraticActionIn_constructor(JSContext *cx, uint32_t argc, CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -26891,32 +25745,20 @@ void js_register_cocos2dx_EaseQuadraticActionIn(JSContext *cx, JS::HandleObject JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ActionEase_prototype); jsb_cocos2d_EaseQuadraticActionIn_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ActionEase_prototype), + parent_proto, jsb_cocos2d_EaseQuadraticActionIn_class, js_cocos2dx_EaseQuadraticActionIn_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "EaseQuadraticActionIn", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_EaseQuadraticActionIn_class; - p->proto = jsb_cocos2d_EaseQuadraticActionIn_prototype; - p->parentProto = jsb_cocos2d_ActionEase_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_EaseQuadraticActionIn_prototype); + jsb_register_class(cx, jsb_cocos2d_EaseQuadraticActionIn_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.EaseQuadraticActionIn.extend = cc.Class.extend; })()"); } @@ -26933,7 +25775,7 @@ bool js_cocos2dx_EaseQuadraticActionOut_create(JSContext *cx, uint32_t argc, jsv if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -26972,8 +25814,8 @@ bool js_cocos2dx_EaseQuadraticActionOut_constructor(JSContext *cx, uint32_t argc CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -27033,32 +25875,20 @@ void js_register_cocos2dx_EaseQuadraticActionOut(JSContext *cx, JS::HandleObject JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ActionEase_prototype); jsb_cocos2d_EaseQuadraticActionOut_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ActionEase_prototype), + parent_proto, jsb_cocos2d_EaseQuadraticActionOut_class, js_cocos2dx_EaseQuadraticActionOut_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "EaseQuadraticActionOut", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_EaseQuadraticActionOut_class; - p->proto = jsb_cocos2d_EaseQuadraticActionOut_prototype; - p->parentProto = jsb_cocos2d_ActionEase_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_EaseQuadraticActionOut_prototype); + jsb_register_class(cx, jsb_cocos2d_EaseQuadraticActionOut_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.EaseQuadraticActionOut.extend = cc.Class.extend; })()"); } @@ -27075,7 +25905,7 @@ bool js_cocos2dx_EaseQuadraticActionInOut_create(JSContext *cx, uint32_t argc, j if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -27114,8 +25944,8 @@ bool js_cocos2dx_EaseQuadraticActionInOut_constructor(JSContext *cx, uint32_t ar CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -27175,32 +26005,20 @@ void js_register_cocos2dx_EaseQuadraticActionInOut(JSContext *cx, JS::HandleObje JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ActionEase_prototype); jsb_cocos2d_EaseQuadraticActionInOut_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ActionEase_prototype), + parent_proto, jsb_cocos2d_EaseQuadraticActionInOut_class, js_cocos2dx_EaseQuadraticActionInOut_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "EaseQuadraticActionInOut", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_EaseQuadraticActionInOut_class; - p->proto = jsb_cocos2d_EaseQuadraticActionInOut_prototype; - p->parentProto = jsb_cocos2d_ActionEase_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_EaseQuadraticActionInOut_prototype); + jsb_register_class(cx, jsb_cocos2d_EaseQuadraticActionInOut_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.EaseQuadraticActionInOut.extend = cc.Class.extend; })()"); } @@ -27217,7 +26035,7 @@ bool js_cocos2dx_EaseQuarticActionIn_create(JSContext *cx, uint32_t argc, jsval if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -27256,8 +26074,8 @@ bool js_cocos2dx_EaseQuarticActionIn_constructor(JSContext *cx, uint32_t argc, j CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -27317,32 +26135,20 @@ void js_register_cocos2dx_EaseQuarticActionIn(JSContext *cx, JS::HandleObject gl JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ActionEase_prototype); jsb_cocos2d_EaseQuarticActionIn_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ActionEase_prototype), + parent_proto, jsb_cocos2d_EaseQuarticActionIn_class, js_cocos2dx_EaseQuarticActionIn_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "EaseQuarticActionIn", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_EaseQuarticActionIn_class; - p->proto = jsb_cocos2d_EaseQuarticActionIn_prototype; - p->parentProto = jsb_cocos2d_ActionEase_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_EaseQuarticActionIn_prototype); + jsb_register_class(cx, jsb_cocos2d_EaseQuarticActionIn_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.EaseQuarticActionIn.extend = cc.Class.extend; })()"); } @@ -27359,7 +26165,7 @@ bool js_cocos2dx_EaseQuarticActionOut_create(JSContext *cx, uint32_t argc, jsval if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -27398,8 +26204,8 @@ bool js_cocos2dx_EaseQuarticActionOut_constructor(JSContext *cx, uint32_t argc, CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -27459,32 +26265,20 @@ void js_register_cocos2dx_EaseQuarticActionOut(JSContext *cx, JS::HandleObject g JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ActionEase_prototype); jsb_cocos2d_EaseQuarticActionOut_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ActionEase_prototype), + parent_proto, jsb_cocos2d_EaseQuarticActionOut_class, js_cocos2dx_EaseQuarticActionOut_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "EaseQuarticActionOut", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_EaseQuarticActionOut_class; - p->proto = jsb_cocos2d_EaseQuarticActionOut_prototype; - p->parentProto = jsb_cocos2d_ActionEase_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_EaseQuarticActionOut_prototype); + jsb_register_class(cx, jsb_cocos2d_EaseQuarticActionOut_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.EaseQuarticActionOut.extend = cc.Class.extend; })()"); } @@ -27501,7 +26295,7 @@ bool js_cocos2dx_EaseQuarticActionInOut_create(JSContext *cx, uint32_t argc, jsv if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -27540,8 +26334,8 @@ bool js_cocos2dx_EaseQuarticActionInOut_constructor(JSContext *cx, uint32_t argc CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -27601,32 +26395,20 @@ void js_register_cocos2dx_EaseQuarticActionInOut(JSContext *cx, JS::HandleObject JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ActionEase_prototype); jsb_cocos2d_EaseQuarticActionInOut_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ActionEase_prototype), + parent_proto, jsb_cocos2d_EaseQuarticActionInOut_class, js_cocos2dx_EaseQuarticActionInOut_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "EaseQuarticActionInOut", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_EaseQuarticActionInOut_class; - p->proto = jsb_cocos2d_EaseQuarticActionInOut_prototype; - p->parentProto = jsb_cocos2d_ActionEase_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_EaseQuarticActionInOut_prototype); + jsb_register_class(cx, jsb_cocos2d_EaseQuarticActionInOut_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.EaseQuarticActionInOut.extend = cc.Class.extend; })()"); } @@ -27643,7 +26425,7 @@ bool js_cocos2dx_EaseQuinticActionIn_create(JSContext *cx, uint32_t argc, jsval if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -27682,8 +26464,8 @@ bool js_cocos2dx_EaseQuinticActionIn_constructor(JSContext *cx, uint32_t argc, j CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -27743,32 +26525,20 @@ void js_register_cocos2dx_EaseQuinticActionIn(JSContext *cx, JS::HandleObject gl JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ActionEase_prototype); jsb_cocos2d_EaseQuinticActionIn_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ActionEase_prototype), + parent_proto, jsb_cocos2d_EaseQuinticActionIn_class, js_cocos2dx_EaseQuinticActionIn_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "EaseQuinticActionIn", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_EaseQuinticActionIn_class; - p->proto = jsb_cocos2d_EaseQuinticActionIn_prototype; - p->parentProto = jsb_cocos2d_ActionEase_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_EaseQuinticActionIn_prototype); + jsb_register_class(cx, jsb_cocos2d_EaseQuinticActionIn_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.EaseQuinticActionIn.extend = cc.Class.extend; })()"); } @@ -27785,7 +26555,7 @@ bool js_cocos2dx_EaseQuinticActionOut_create(JSContext *cx, uint32_t argc, jsval if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -27824,8 +26594,8 @@ bool js_cocos2dx_EaseQuinticActionOut_constructor(JSContext *cx, uint32_t argc, CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -27885,32 +26655,20 @@ void js_register_cocos2dx_EaseQuinticActionOut(JSContext *cx, JS::HandleObject g JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ActionEase_prototype); jsb_cocos2d_EaseQuinticActionOut_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ActionEase_prototype), + parent_proto, jsb_cocos2d_EaseQuinticActionOut_class, js_cocos2dx_EaseQuinticActionOut_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "EaseQuinticActionOut", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_EaseQuinticActionOut_class; - p->proto = jsb_cocos2d_EaseQuinticActionOut_prototype; - p->parentProto = jsb_cocos2d_ActionEase_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_EaseQuinticActionOut_prototype); + jsb_register_class(cx, jsb_cocos2d_EaseQuinticActionOut_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.EaseQuinticActionOut.extend = cc.Class.extend; })()"); } @@ -27927,7 +26685,7 @@ bool js_cocos2dx_EaseQuinticActionInOut_create(JSContext *cx, uint32_t argc, jsv if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -27966,8 +26724,8 @@ bool js_cocos2dx_EaseQuinticActionInOut_constructor(JSContext *cx, uint32_t argc CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -28027,32 +26785,20 @@ void js_register_cocos2dx_EaseQuinticActionInOut(JSContext *cx, JS::HandleObject JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ActionEase_prototype); jsb_cocos2d_EaseQuinticActionInOut_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ActionEase_prototype), + parent_proto, jsb_cocos2d_EaseQuinticActionInOut_class, js_cocos2dx_EaseQuinticActionInOut_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "EaseQuinticActionInOut", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_EaseQuinticActionInOut_class; - p->proto = jsb_cocos2d_EaseQuinticActionInOut_prototype; - p->parentProto = jsb_cocos2d_ActionEase_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_EaseQuinticActionInOut_prototype); + jsb_register_class(cx, jsb_cocos2d_EaseQuinticActionInOut_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.EaseQuinticActionInOut.extend = cc.Class.extend; })()"); } @@ -28069,7 +26815,7 @@ bool js_cocos2dx_EaseCircleActionIn_create(JSContext *cx, uint32_t argc, jsval * if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -28108,8 +26854,8 @@ bool js_cocos2dx_EaseCircleActionIn_constructor(JSContext *cx, uint32_t argc, js CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -28169,32 +26915,20 @@ void js_register_cocos2dx_EaseCircleActionIn(JSContext *cx, JS::HandleObject glo JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ActionEase_prototype); jsb_cocos2d_EaseCircleActionIn_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ActionEase_prototype), + parent_proto, jsb_cocos2d_EaseCircleActionIn_class, js_cocos2dx_EaseCircleActionIn_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "EaseCircleActionIn", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_EaseCircleActionIn_class; - p->proto = jsb_cocos2d_EaseCircleActionIn_prototype; - p->parentProto = jsb_cocos2d_ActionEase_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_EaseCircleActionIn_prototype); + jsb_register_class(cx, jsb_cocos2d_EaseCircleActionIn_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.EaseCircleActionIn.extend = cc.Class.extend; })()"); } @@ -28211,7 +26945,7 @@ bool js_cocos2dx_EaseCircleActionOut_create(JSContext *cx, uint32_t argc, jsval if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -28250,8 +26984,8 @@ bool js_cocos2dx_EaseCircleActionOut_constructor(JSContext *cx, uint32_t argc, j CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -28311,32 +27045,20 @@ void js_register_cocos2dx_EaseCircleActionOut(JSContext *cx, JS::HandleObject gl JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ActionEase_prototype); jsb_cocos2d_EaseCircleActionOut_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ActionEase_prototype), + parent_proto, jsb_cocos2d_EaseCircleActionOut_class, js_cocos2dx_EaseCircleActionOut_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "EaseCircleActionOut", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_EaseCircleActionOut_class; - p->proto = jsb_cocos2d_EaseCircleActionOut_prototype; - p->parentProto = jsb_cocos2d_ActionEase_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_EaseCircleActionOut_prototype); + jsb_register_class(cx, jsb_cocos2d_EaseCircleActionOut_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.EaseCircleActionOut.extend = cc.Class.extend; })()"); } @@ -28353,7 +27075,7 @@ bool js_cocos2dx_EaseCircleActionInOut_create(JSContext *cx, uint32_t argc, jsva if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -28392,8 +27114,8 @@ bool js_cocos2dx_EaseCircleActionInOut_constructor(JSContext *cx, uint32_t argc, CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -28453,32 +27175,20 @@ void js_register_cocos2dx_EaseCircleActionInOut(JSContext *cx, JS::HandleObject JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ActionEase_prototype); jsb_cocos2d_EaseCircleActionInOut_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ActionEase_prototype), + parent_proto, jsb_cocos2d_EaseCircleActionInOut_class, js_cocos2dx_EaseCircleActionInOut_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "EaseCircleActionInOut", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_EaseCircleActionInOut_class; - p->proto = jsb_cocos2d_EaseCircleActionInOut_prototype; - p->parentProto = jsb_cocos2d_ActionEase_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_EaseCircleActionInOut_prototype); + jsb_register_class(cx, jsb_cocos2d_EaseCircleActionInOut_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.EaseCircleActionInOut.extend = cc.Class.extend; })()"); } @@ -28495,7 +27205,7 @@ bool js_cocos2dx_EaseCubicActionIn_create(JSContext *cx, uint32_t argc, jsval *v if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -28534,8 +27244,8 @@ bool js_cocos2dx_EaseCubicActionIn_constructor(JSContext *cx, uint32_t argc, jsv CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -28595,32 +27305,20 @@ void js_register_cocos2dx_EaseCubicActionIn(JSContext *cx, JS::HandleObject glob JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ActionEase_prototype); jsb_cocos2d_EaseCubicActionIn_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ActionEase_prototype), + parent_proto, jsb_cocos2d_EaseCubicActionIn_class, js_cocos2dx_EaseCubicActionIn_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "EaseCubicActionIn", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_EaseCubicActionIn_class; - p->proto = jsb_cocos2d_EaseCubicActionIn_prototype; - p->parentProto = jsb_cocos2d_ActionEase_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_EaseCubicActionIn_prototype); + jsb_register_class(cx, jsb_cocos2d_EaseCubicActionIn_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.EaseCubicActionIn.extend = cc.Class.extend; })()"); } @@ -28637,7 +27335,7 @@ bool js_cocos2dx_EaseCubicActionOut_create(JSContext *cx, uint32_t argc, jsval * if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -28676,8 +27374,8 @@ bool js_cocos2dx_EaseCubicActionOut_constructor(JSContext *cx, uint32_t argc, js CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -28737,32 +27435,20 @@ void js_register_cocos2dx_EaseCubicActionOut(JSContext *cx, JS::HandleObject glo JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ActionEase_prototype); jsb_cocos2d_EaseCubicActionOut_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ActionEase_prototype), + parent_proto, jsb_cocos2d_EaseCubicActionOut_class, js_cocos2dx_EaseCubicActionOut_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "EaseCubicActionOut", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_EaseCubicActionOut_class; - p->proto = jsb_cocos2d_EaseCubicActionOut_prototype; - p->parentProto = jsb_cocos2d_ActionEase_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_EaseCubicActionOut_prototype); + jsb_register_class(cx, jsb_cocos2d_EaseCubicActionOut_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.EaseCubicActionOut.extend = cc.Class.extend; })()"); } @@ -28779,7 +27465,7 @@ bool js_cocos2dx_EaseCubicActionInOut_create(JSContext *cx, uint32_t argc, jsval if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -28818,8 +27504,8 @@ bool js_cocos2dx_EaseCubicActionInOut_constructor(JSContext *cx, uint32_t argc, CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -28879,32 +27565,20 @@ void js_register_cocos2dx_EaseCubicActionInOut(JSContext *cx, JS::HandleObject g JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ActionEase_prototype); jsb_cocos2d_EaseCubicActionInOut_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ActionEase_prototype), + parent_proto, jsb_cocos2d_EaseCubicActionInOut_class, js_cocos2dx_EaseCubicActionInOut_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "EaseCubicActionInOut", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_EaseCubicActionInOut_class; - p->proto = jsb_cocos2d_EaseCubicActionInOut_prototype; - p->parentProto = jsb_cocos2d_ActionEase_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_EaseCubicActionInOut_prototype); + jsb_register_class(cx, jsb_cocos2d_EaseCubicActionInOut_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.EaseCubicActionInOut.extend = cc.Class.extend; })()"); } @@ -28941,32 +27615,20 @@ void js_register_cocos2dx_ActionInstant(JSContext *cx, JS::HandleObject global) JSFunctionSpec *st_funcs = NULL; + JS::RootedObject parent_proto(cx, jsb_cocos2d_FiniteTimeAction_prototype); jsb_cocos2d_ActionInstant_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_FiniteTimeAction_prototype), + parent_proto, jsb_cocos2d_ActionInstant_class, empty_constructor, 0, properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "ActionInstant", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_ActionInstant_class; - p->proto = jsb_cocos2d_ActionInstant_prototype; - p->parentProto = jsb_cocos2d_FiniteTimeAction_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ActionInstant_prototype); + jsb_register_class(cx, jsb_cocos2d_ActionInstant_class, proto, parent_proto); } JSClass *jsb_cocos2d_Show_class; @@ -29009,8 +27671,8 @@ bool js_cocos2dx_Show_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -29070,32 +27732,20 @@ void js_register_cocos2dx_Show(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ActionInstant_prototype); jsb_cocos2d_Show_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ActionInstant_prototype), + parent_proto, jsb_cocos2d_Show_class, js_cocos2dx_Show_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "Show", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_Show_class; - p->proto = jsb_cocos2d_Show_prototype; - p->parentProto = jsb_cocos2d_ActionInstant_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_Show_prototype); + jsb_register_class(cx, jsb_cocos2d_Show_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.Show.extend = cc.Class.extend; })()"); } @@ -29139,8 +27789,8 @@ bool js_cocos2dx_Hide_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -29200,32 +27850,20 @@ void js_register_cocos2dx_Hide(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ActionInstant_prototype); jsb_cocos2d_Hide_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ActionInstant_prototype), + parent_proto, jsb_cocos2d_Hide_class, js_cocos2dx_Hide_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "Hide", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_Hide_class; - p->proto = jsb_cocos2d_Hide_prototype; - p->parentProto = jsb_cocos2d_ActionInstant_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_Hide_prototype); + jsb_register_class(cx, jsb_cocos2d_Hide_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.Hide.extend = cc.Class.extend; })()"); } @@ -29269,8 +27907,8 @@ bool js_cocos2dx_ToggleVisibility_constructor(JSContext *cx, uint32_t argc, jsva CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -29313,32 +27951,20 @@ void js_register_cocos2dx_ToggleVisibility(JSContext *cx, JS::HandleObject globa JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ActionInstant_prototype); jsb_cocos2d_ToggleVisibility_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ActionInstant_prototype), + parent_proto, jsb_cocos2d_ToggleVisibility_class, js_cocos2dx_ToggleVisibility_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "ToggleVisibility", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_ToggleVisibility_class; - p->proto = jsb_cocos2d_ToggleVisibility_prototype; - p->parentProto = jsb_cocos2d_ActionInstant_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ToggleVisibility_prototype); + jsb_register_class(cx, jsb_cocos2d_ToggleVisibility_class, proto, parent_proto); } JSClass *jsb_cocos2d_RemoveSelf_class; @@ -29421,8 +28047,8 @@ bool js_cocos2dx_RemoveSelf_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -29466,32 +28092,20 @@ void js_register_cocos2dx_RemoveSelf(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ActionInstant_prototype); jsb_cocos2d_RemoveSelf_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ActionInstant_prototype), + parent_proto, jsb_cocos2d_RemoveSelf_class, js_cocos2dx_RemoveSelf_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "RemoveSelf", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_RemoveSelf_class; - p->proto = jsb_cocos2d_RemoveSelf_prototype; - p->parentProto = jsb_cocos2d_ActionInstant_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_RemoveSelf_prototype); + jsb_register_class(cx, jsb_cocos2d_RemoveSelf_class, proto, parent_proto); } JSClass *jsb_cocos2d_FlipX_class; @@ -29560,8 +28174,8 @@ bool js_cocos2dx_FlipX_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -29622,32 +28236,20 @@ void js_register_cocos2dx_FlipX(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ActionInstant_prototype); jsb_cocos2d_FlipX_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ActionInstant_prototype), + parent_proto, jsb_cocos2d_FlipX_class, js_cocos2dx_FlipX_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "FlipX", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_FlipX_class; - p->proto = jsb_cocos2d_FlipX_prototype; - p->parentProto = jsb_cocos2d_ActionInstant_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_FlipX_prototype); + jsb_register_class(cx, jsb_cocos2d_FlipX_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.FlipX.extend = cc.Class.extend; })()"); } @@ -29717,8 +28319,8 @@ bool js_cocos2dx_FlipY_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -29779,32 +28381,20 @@ void js_register_cocos2dx_FlipY(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ActionInstant_prototype); jsb_cocos2d_FlipY_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ActionInstant_prototype), + parent_proto, jsb_cocos2d_FlipY_class, js_cocos2dx_FlipY_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "FlipY", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_FlipY_class; - p->proto = jsb_cocos2d_FlipY_prototype; - p->parentProto = jsb_cocos2d_ActionInstant_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_FlipY_prototype); + jsb_register_class(cx, jsb_cocos2d_FlipY_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.FlipY.extend = cc.Class.extend; })()"); } @@ -29874,8 +28464,8 @@ bool js_cocos2dx_Place_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -29936,32 +28526,20 @@ void js_register_cocos2dx_Place(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ActionInstant_prototype); jsb_cocos2d_Place_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ActionInstant_prototype), + parent_proto, jsb_cocos2d_Place_class, js_cocos2dx_Place_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "Place", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_Place_class; - p->proto = jsb_cocos2d_Place_prototype; - p->parentProto = jsb_cocos2d_ActionInstant_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_Place_prototype); + jsb_register_class(cx, jsb_cocos2d_Place_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.Place.extend = cc.Class.extend; })()"); } @@ -30000,8 +28578,8 @@ bool js_cocos2dx_CallFunc_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -30059,32 +28637,20 @@ void js_register_cocos2dx_CallFunc(JSContext *cx, JS::HandleObject global) { JSFunctionSpec *st_funcs = NULL; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ActionInstant_prototype); jsb_cocos2d_CallFunc_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ActionInstant_prototype), + parent_proto, jsb_cocos2d_CallFunc_class, js_cocos2dx_CallFunc_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "_CallFunc", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_CallFunc_class; - p->proto = jsb_cocos2d_CallFunc_prototype; - p->parentProto = jsb_cocos2d_ActionInstant_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_CallFunc_prototype); + jsb_register_class(cx, jsb_cocos2d_CallFunc_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc._CallFunc.extend = cc.Class.extend; })()"); } @@ -30107,8 +28673,8 @@ bool js_cocos2dx_CallFuncN_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -30165,32 +28731,20 @@ void js_register_cocos2dx_CallFuncN(JSContext *cx, JS::HandleObject global) { JSFunctionSpec *st_funcs = NULL; + JS::RootedObject parent_proto(cx, jsb_cocos2d_CallFunc_prototype); jsb_cocos2d_CallFuncN_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_CallFunc_prototype), + parent_proto, jsb_cocos2d_CallFuncN_class, js_cocos2dx_CallFuncN_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "CallFunc", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_CallFuncN_class; - p->proto = jsb_cocos2d_CallFuncN_prototype; - p->parentProto = jsb_cocos2d_CallFunc_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_CallFuncN_prototype); + jsb_register_class(cx, jsb_cocos2d_CallFuncN_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.CallFunc.extend = cc.Class.extend; })()"); } @@ -30278,32 +28832,20 @@ void js_register_cocos2dx_GridAction(JSContext *cx, JS::HandleObject global) { JSFunctionSpec *st_funcs = NULL; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ActionInterval_prototype); jsb_cocos2d_GridAction_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ActionInterval_prototype), + parent_proto, jsb_cocos2d_GridAction_class, empty_constructor, 0, properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "GridAction", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_GridAction_class; - p->proto = jsb_cocos2d_GridAction_prototype; - p->parentProto = jsb_cocos2d_ActionInterval_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_GridAction_prototype); + jsb_register_class(cx, jsb_cocos2d_GridAction_class, proto, parent_proto); } JSClass *jsb_cocos2d_Grid3DAction_class; @@ -30358,32 +28900,20 @@ void js_register_cocos2dx_Grid3DAction(JSContext *cx, JS::HandleObject global) { JSFunctionSpec *st_funcs = NULL; + JS::RootedObject parent_proto(cx, jsb_cocos2d_GridAction_prototype); jsb_cocos2d_Grid3DAction_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_GridAction_prototype), + parent_proto, jsb_cocos2d_Grid3DAction_class, empty_constructor, 0, properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "Grid3DAction", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_Grid3DAction_class; - p->proto = jsb_cocos2d_Grid3DAction_prototype; - p->parentProto = jsb_cocos2d_GridAction_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_Grid3DAction_prototype); + jsb_register_class(cx, jsb_cocos2d_Grid3DAction_class, proto, parent_proto); } JSClass *jsb_cocos2d_TiledGrid3DAction_class; @@ -30419,32 +28949,20 @@ void js_register_cocos2dx_TiledGrid3DAction(JSContext *cx, JS::HandleObject glob JSFunctionSpec *st_funcs = NULL; + JS::RootedObject parent_proto(cx, jsb_cocos2d_GridAction_prototype); jsb_cocos2d_TiledGrid3DAction_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_GridAction_prototype), + parent_proto, jsb_cocos2d_TiledGrid3DAction_class, empty_constructor, 0, properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "TiledGrid3DAction", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_TiledGrid3DAction_class; - p->proto = jsb_cocos2d_TiledGrid3DAction_prototype; - p->parentProto = jsb_cocos2d_GridAction_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_TiledGrid3DAction_prototype); + jsb_register_class(cx, jsb_cocos2d_TiledGrid3DAction_class, proto, parent_proto); } JSClass *jsb_cocos2d_StopGrid_class; @@ -30487,8 +29005,8 @@ bool js_cocos2dx_StopGrid_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -30531,32 +29049,20 @@ void js_register_cocos2dx_StopGrid(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ActionInstant_prototype); jsb_cocos2d_StopGrid_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ActionInstant_prototype), + parent_proto, jsb_cocos2d_StopGrid_class, js_cocos2dx_StopGrid_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "StopGrid", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_StopGrid_class; - p->proto = jsb_cocos2d_StopGrid_prototype; - p->parentProto = jsb_cocos2d_ActionInstant_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_StopGrid_prototype); + jsb_register_class(cx, jsb_cocos2d_StopGrid_class, proto, parent_proto); } JSClass *jsb_cocos2d_ReuseGrid_class; @@ -30625,8 +29131,8 @@ bool js_cocos2dx_ReuseGrid_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -30670,32 +29176,20 @@ void js_register_cocos2dx_ReuseGrid(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ActionInstant_prototype); jsb_cocos2d_ReuseGrid_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ActionInstant_prototype), + parent_proto, jsb_cocos2d_ReuseGrid_class, js_cocos2dx_ReuseGrid_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "ReuseGrid", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_ReuseGrid_class; - p->proto = jsb_cocos2d_ReuseGrid_prototype; - p->parentProto = jsb_cocos2d_ActionInstant_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ReuseGrid_prototype); + jsb_register_class(cx, jsb_cocos2d_ReuseGrid_class, proto, parent_proto); } JSClass *jsb_cocos2d_Waves3D_class; @@ -30852,8 +29346,8 @@ bool js_cocos2dx_Waves3D_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -30901,32 +29395,20 @@ void js_register_cocos2dx_Waves3D(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Grid3DAction_prototype); jsb_cocos2d_Waves3D_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Grid3DAction_prototype), + parent_proto, jsb_cocos2d_Waves3D_class, js_cocos2dx_Waves3D_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "Waves3D", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_Waves3D_class; - p->proto = jsb_cocos2d_Waves3D_prototype; - p->parentProto = jsb_cocos2d_Grid3DAction_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_Waves3D_prototype); + jsb_register_class(cx, jsb_cocos2d_Waves3D_class, proto, parent_proto); } JSClass *jsb_cocos2d_FlipX3D_class; @@ -31019,8 +29501,8 @@ bool js_cocos2dx_FlipX3D_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -31082,32 +29564,20 @@ void js_register_cocos2dx_FlipX3D(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Grid3DAction_prototype); jsb_cocos2d_FlipX3D_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Grid3DAction_prototype), + parent_proto, jsb_cocos2d_FlipX3D_class, js_cocos2dx_FlipX3D_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "FlipX3D", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_FlipX3D_class; - p->proto = jsb_cocos2d_FlipX3D_prototype; - p->parentProto = jsb_cocos2d_Grid3DAction_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_FlipX3D_prototype); + jsb_register_class(cx, jsb_cocos2d_FlipX3D_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.FlipX3D.extend = cc.Class.extend; })()"); } @@ -31155,8 +29625,8 @@ bool js_cocos2dx_FlipY3D_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -31216,32 +29686,20 @@ void js_register_cocos2dx_FlipY3D(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_FlipX3D_prototype); jsb_cocos2d_FlipY3D_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_FlipX3D_prototype), + parent_proto, jsb_cocos2d_FlipY3D_class, js_cocos2dx_FlipY3D_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "FlipY3D", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_FlipY3D_class; - p->proto = jsb_cocos2d_FlipY3D_prototype; - p->parentProto = jsb_cocos2d_FlipX3D_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_FlipY3D_prototype); + jsb_register_class(cx, jsb_cocos2d_FlipY3D_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.FlipY3D.extend = cc.Class.extend; })()"); } @@ -31419,8 +29877,8 @@ bool js_cocos2dx_Lens3D_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -31469,32 +29927,20 @@ void js_register_cocos2dx_Lens3D(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Grid3DAction_prototype); jsb_cocos2d_Lens3D_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Grid3DAction_prototype), + parent_proto, jsb_cocos2d_Lens3D_class, js_cocos2dx_Lens3D_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "Lens3D", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_Lens3D_class; - p->proto = jsb_cocos2d_Lens3D_prototype; - p->parentProto = jsb_cocos2d_Grid3DAction_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_Lens3D_prototype); + jsb_register_class(cx, jsb_cocos2d_Lens3D_class, proto, parent_proto); } JSClass *jsb_cocos2d_Ripple3D_class; @@ -31697,8 +30143,8 @@ bool js_cocos2dx_Ripple3D_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -31748,32 +30194,20 @@ void js_register_cocos2dx_Ripple3D(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Grid3DAction_prototype); jsb_cocos2d_Ripple3D_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Grid3DAction_prototype), + parent_proto, jsb_cocos2d_Ripple3D_class, js_cocos2dx_Ripple3D_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "Ripple3D", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_Ripple3D_class; - p->proto = jsb_cocos2d_Ripple3D_prototype; - p->parentProto = jsb_cocos2d_Grid3DAction_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_Ripple3D_prototype); + jsb_register_class(cx, jsb_cocos2d_Ripple3D_class, proto, parent_proto); } JSClass *jsb_cocos2d_Shaky3D_class; @@ -31854,8 +30288,8 @@ bool js_cocos2dx_Shaky3D_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -31899,32 +30333,20 @@ void js_register_cocos2dx_Shaky3D(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Grid3DAction_prototype); jsb_cocos2d_Shaky3D_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Grid3DAction_prototype), + parent_proto, jsb_cocos2d_Shaky3D_class, js_cocos2dx_Shaky3D_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "Shaky3D", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_Shaky3D_class; - p->proto = jsb_cocos2d_Shaky3D_prototype; - p->parentProto = jsb_cocos2d_Grid3DAction_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_Shaky3D_prototype); + jsb_register_class(cx, jsb_cocos2d_Shaky3D_class, proto, parent_proto); } JSClass *jsb_cocos2d_Liquid_class; @@ -32081,8 +30503,8 @@ bool js_cocos2dx_Liquid_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -32130,32 +30552,20 @@ void js_register_cocos2dx_Liquid(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Grid3DAction_prototype); jsb_cocos2d_Liquid_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Grid3DAction_prototype), + parent_proto, jsb_cocos2d_Liquid_class, js_cocos2dx_Liquid_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "Liquid", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_Liquid_class; - p->proto = jsb_cocos2d_Liquid_prototype; - p->parentProto = jsb_cocos2d_Grid3DAction_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_Liquid_prototype); + jsb_register_class(cx, jsb_cocos2d_Liquid_class, proto, parent_proto); } JSClass *jsb_cocos2d_Waves_class; @@ -32320,8 +30730,8 @@ bool js_cocos2dx_Waves_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -32369,32 +30779,20 @@ void js_register_cocos2dx_Waves(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Grid3DAction_prototype); jsb_cocos2d_Waves_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Grid3DAction_prototype), + parent_proto, jsb_cocos2d_Waves_class, js_cocos2dx_Waves_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "Waves", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_Waves_class; - p->proto = jsb_cocos2d_Waves_prototype; - p->parentProto = jsb_cocos2d_Grid3DAction_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_Waves_prototype); + jsb_register_class(cx, jsb_cocos2d_Waves_class, proto, parent_proto); } JSClass *jsb_cocos2d_Twirl_class; @@ -32593,8 +30991,8 @@ bool js_cocos2dx_Twirl_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -32644,32 +31042,20 @@ void js_register_cocos2dx_Twirl(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Grid3DAction_prototype); jsb_cocos2d_Twirl_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Grid3DAction_prototype), + parent_proto, jsb_cocos2d_Twirl_class, js_cocos2dx_Twirl_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "Twirl", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_Twirl_class; - p->proto = jsb_cocos2d_Twirl_prototype; - p->parentProto = jsb_cocos2d_Grid3DAction_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_Twirl_prototype); + jsb_register_class(cx, jsb_cocos2d_Twirl_class, proto, parent_proto); } JSClass *jsb_cocos2d_ActionManager_class; @@ -32691,7 +31077,7 @@ bool js_cocos2dx_ActionManager_getActionByTag(JSContext *cx, uint32_t argc, jsva if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (const cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -32730,7 +31116,7 @@ bool js_cocos2dx_ActionManager_removeActionByTag(JSContext *cx, uint32_t argc, j if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -32760,7 +31146,7 @@ bool js_cocos2dx_ActionManager_removeActionsByFlags(JSContext *cx, uint32_t argc if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -32806,7 +31192,7 @@ bool js_cocos2dx_ActionManager_addAction(JSContext *cx, uint32_t argc, jsval *vp if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Action*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -32815,7 +31201,7 @@ bool js_cocos2dx_ActionManager_addAction(JSContext *cx, uint32_t argc, jsval *vp if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -32844,7 +31230,7 @@ bool js_cocos2dx_ActionManager_resumeTarget(JSContext *cx, uint32_t argc, jsval if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -32892,7 +31278,7 @@ bool js_cocos2dx_ActionManager_pauseTarget(JSContext *cx, uint32_t argc, jsval * if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -32920,7 +31306,7 @@ bool js_cocos2dx_ActionManager_getNumberOfRunningActionsInTarget(JSContext *cx, if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (const cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -32950,7 +31336,7 @@ bool js_cocos2dx_ActionManager_removeAllActionsFromTarget(JSContext *cx, uint32_ if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -32998,7 +31384,7 @@ bool js_cocos2dx_ActionManager_removeAction(JSContext *cx, uint32_t argc, jsval if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Action*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -33028,7 +31414,7 @@ bool js_cocos2dx_ActionManager_removeAllActionsByTag(JSContext *cx, uint32_t arg if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -33076,8 +31462,8 @@ bool js_cocos2dx_ActionManager_constructor(JSContext *cx, uint32_t argc, jsval * CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -33148,30 +31534,17 @@ void js_register_cocos2dx_ActionManager(JSContext *cx, JS::HandleObject global) jsb_cocos2d_ActionManager_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocos2d_ActionManager_class, js_cocos2dx_ActionManager_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "ActionManager", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_ActionManager_class; - p->proto = jsb_cocos2d_ActionManager_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ActionManager_prototype); + jsb_register_class(cx, jsb_cocos2d_ActionManager_class, proto, JS::NullPtr()); anonEvaluate(cx, global, "(function () { cc.ActionManager.extend = cc.Class.extend; })()"); } @@ -33238,32 +31611,20 @@ void js_register_cocos2dx_PageTurn3D(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Grid3DAction_prototype); jsb_cocos2d_PageTurn3D_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Grid3DAction_prototype), + parent_proto, jsb_cocos2d_PageTurn3D_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "PageTurn3D", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_PageTurn3D_class; - p->proto = jsb_cocos2d_PageTurn3D_prototype; - p->parentProto = jsb_cocos2d_Grid3DAction_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_PageTurn3D_prototype); + jsb_register_class(cx, jsb_cocos2d_PageTurn3D_class, proto, parent_proto); } JSClass *jsb_cocos2d_ProgressTo_class; @@ -33336,8 +31697,8 @@ bool js_cocos2dx_ProgressTo_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -33398,32 +31759,20 @@ void js_register_cocos2dx_ProgressTo(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ActionInterval_prototype); jsb_cocos2d_ProgressTo_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ActionInterval_prototype), + parent_proto, jsb_cocos2d_ProgressTo_class, js_cocos2dx_ProgressTo_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "ProgressTo", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_ProgressTo_class; - p->proto = jsb_cocos2d_ProgressTo_prototype; - p->parentProto = jsb_cocos2d_ActionInterval_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ProgressTo_prototype); + jsb_register_class(cx, jsb_cocos2d_ProgressTo_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.ProgressTo.extend = cc.Class.extend; })()"); } @@ -33501,8 +31850,8 @@ bool js_cocos2dx_ProgressFromTo_constructor(JSContext *cx, uint32_t argc, jsval CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -33563,32 +31912,20 @@ void js_register_cocos2dx_ProgressFromTo(JSContext *cx, JS::HandleObject global) JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ActionInterval_prototype); jsb_cocos2d_ProgressFromTo_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ActionInterval_prototype), + parent_proto, jsb_cocos2d_ProgressFromTo_class, js_cocos2dx_ProgressFromTo_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "ProgressFromTo", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_ProgressFromTo_class; - p->proto = jsb_cocos2d_ProgressFromTo_prototype; - p->parentProto = jsb_cocos2d_ActionInterval_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ProgressFromTo_prototype); + jsb_register_class(cx, jsb_cocos2d_ProgressFromTo_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.ProgressFromTo.extend = cc.Class.extend; })()"); } @@ -33670,8 +32007,8 @@ bool js_cocos2dx_ShakyTiles3D_constructor(JSContext *cx, uint32_t argc, jsval *v CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -33715,32 +32052,20 @@ void js_register_cocos2dx_ShakyTiles3D(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_TiledGrid3DAction_prototype); jsb_cocos2d_ShakyTiles3D_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_TiledGrid3DAction_prototype), + parent_proto, jsb_cocos2d_ShakyTiles3D_class, js_cocos2dx_ShakyTiles3D_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "ShakyTiles3D", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_ShakyTiles3D_class; - p->proto = jsb_cocos2d_ShakyTiles3D_prototype; - p->parentProto = jsb_cocos2d_TiledGrid3DAction_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ShakyTiles3D_prototype); + jsb_register_class(cx, jsb_cocos2d_ShakyTiles3D_class, proto, parent_proto); } JSClass *jsb_cocos2d_ShatteredTiles3D_class; @@ -33821,8 +32146,8 @@ bool js_cocos2dx_ShatteredTiles3D_constructor(JSContext *cx, uint32_t argc, jsva CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -33866,32 +32191,20 @@ void js_register_cocos2dx_ShatteredTiles3D(JSContext *cx, JS::HandleObject globa JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_TiledGrid3DAction_prototype); jsb_cocos2d_ShatteredTiles3D_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_TiledGrid3DAction_prototype), + parent_proto, jsb_cocos2d_ShatteredTiles3D_class, js_cocos2dx_ShatteredTiles3D_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "ShatteredTiles3D", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_ShatteredTiles3D_class; - p->proto = jsb_cocos2d_ShatteredTiles3D_prototype; - p->parentProto = jsb_cocos2d_TiledGrid3DAction_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ShatteredTiles3D_prototype); + jsb_register_class(cx, jsb_cocos2d_ShatteredTiles3D_class, proto, parent_proto); } JSClass *jsb_cocos2d_ShuffleTiles_class; @@ -34036,8 +32349,8 @@ bool js_cocos2dx_ShuffleTiles_constructor(JSContext *cx, uint32_t argc, jsval *v CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -34084,32 +32397,20 @@ void js_register_cocos2dx_ShuffleTiles(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_TiledGrid3DAction_prototype); jsb_cocos2d_ShuffleTiles_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_TiledGrid3DAction_prototype), + parent_proto, jsb_cocos2d_ShuffleTiles_class, js_cocos2dx_ShuffleTiles_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "ShuffleTiles", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_ShuffleTiles_class; - p->proto = jsb_cocos2d_ShuffleTiles_prototype; - p->parentProto = jsb_cocos2d_TiledGrid3DAction_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ShuffleTiles_prototype); + jsb_register_class(cx, jsb_cocos2d_ShuffleTiles_class, proto, parent_proto); } JSClass *jsb_cocos2d_FadeOutTRTiles_class; @@ -34244,8 +32545,8 @@ bool js_cocos2dx_FadeOutTRTiles_constructor(JSContext *cx, uint32_t argc, jsval CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -34309,32 +32610,20 @@ void js_register_cocos2dx_FadeOutTRTiles(JSContext *cx, JS::HandleObject global) JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_TiledGrid3DAction_prototype); jsb_cocos2d_FadeOutTRTiles_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_TiledGrid3DAction_prototype), + parent_proto, jsb_cocos2d_FadeOutTRTiles_class, js_cocos2dx_FadeOutTRTiles_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "FadeOutTRTiles", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_FadeOutTRTiles_class; - p->proto = jsb_cocos2d_FadeOutTRTiles_prototype; - p->parentProto = jsb_cocos2d_TiledGrid3DAction_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_FadeOutTRTiles_prototype); + jsb_register_class(cx, jsb_cocos2d_FadeOutTRTiles_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.FadeOutTRTiles.extend = cc.Class.extend; })()"); } @@ -34384,8 +32673,8 @@ bool js_cocos2dx_FadeOutBLTiles_constructor(JSContext *cx, uint32_t argc, jsval CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -34445,32 +32734,20 @@ void js_register_cocos2dx_FadeOutBLTiles(JSContext *cx, JS::HandleObject global) JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_FadeOutTRTiles_prototype); jsb_cocos2d_FadeOutBLTiles_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_FadeOutTRTiles_prototype), + parent_proto, jsb_cocos2d_FadeOutBLTiles_class, js_cocos2dx_FadeOutBLTiles_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "FadeOutBLTiles", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_FadeOutBLTiles_class; - p->proto = jsb_cocos2d_FadeOutBLTiles_prototype; - p->parentProto = jsb_cocos2d_FadeOutTRTiles_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_FadeOutBLTiles_prototype); + jsb_register_class(cx, jsb_cocos2d_FadeOutBLTiles_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.FadeOutBLTiles.extend = cc.Class.extend; })()"); } @@ -34520,8 +32797,8 @@ bool js_cocos2dx_FadeOutUpTiles_constructor(JSContext *cx, uint32_t argc, jsval CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -34581,32 +32858,20 @@ void js_register_cocos2dx_FadeOutUpTiles(JSContext *cx, JS::HandleObject global) JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_FadeOutTRTiles_prototype); jsb_cocos2d_FadeOutUpTiles_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_FadeOutTRTiles_prototype), + parent_proto, jsb_cocos2d_FadeOutUpTiles_class, js_cocos2dx_FadeOutUpTiles_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "FadeOutUpTiles", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_FadeOutUpTiles_class; - p->proto = jsb_cocos2d_FadeOutUpTiles_prototype; - p->parentProto = jsb_cocos2d_FadeOutTRTiles_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_FadeOutUpTiles_prototype); + jsb_register_class(cx, jsb_cocos2d_FadeOutUpTiles_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.FadeOutUpTiles.extend = cc.Class.extend; })()"); } @@ -34656,8 +32921,8 @@ bool js_cocos2dx_FadeOutDownTiles_constructor(JSContext *cx, uint32_t argc, jsva CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -34717,32 +32982,20 @@ void js_register_cocos2dx_FadeOutDownTiles(JSContext *cx, JS::HandleObject globa JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_FadeOutUpTiles_prototype); jsb_cocos2d_FadeOutDownTiles_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_FadeOutUpTiles_prototype), + parent_proto, jsb_cocos2d_FadeOutDownTiles_class, js_cocos2dx_FadeOutDownTiles_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "FadeOutDownTiles", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_FadeOutDownTiles_class; - p->proto = jsb_cocos2d_FadeOutDownTiles_prototype; - p->parentProto = jsb_cocos2d_FadeOutUpTiles_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_FadeOutDownTiles_prototype); + jsb_register_class(cx, jsb_cocos2d_FadeOutDownTiles_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.FadeOutDownTiles.extend = cc.Class.extend; })()"); } @@ -34910,8 +33163,8 @@ bool js_cocos2dx_TurnOffTiles_constructor(JSContext *cx, uint32_t argc, jsval *v CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -34958,32 +33211,20 @@ void js_register_cocos2dx_TurnOffTiles(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_TiledGrid3DAction_prototype); jsb_cocos2d_TurnOffTiles_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_TiledGrid3DAction_prototype), + parent_proto, jsb_cocos2d_TurnOffTiles_class, js_cocos2dx_TurnOffTiles_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "TurnOffTiles", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_TurnOffTiles_class; - p->proto = jsb_cocos2d_TurnOffTiles_prototype; - p->parentProto = jsb_cocos2d_TiledGrid3DAction_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_TurnOffTiles_prototype); + jsb_register_class(cx, jsb_cocos2d_TurnOffTiles_class, proto, parent_proto); } JSClass *jsb_cocos2d_WavesTiles3D_class; @@ -35140,8 +33381,8 @@ bool js_cocos2dx_WavesTiles3D_constructor(JSContext *cx, uint32_t argc, jsval *v CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -35189,32 +33430,20 @@ void js_register_cocos2dx_WavesTiles3D(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_TiledGrid3DAction_prototype); jsb_cocos2d_WavesTiles3D_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_TiledGrid3DAction_prototype), + parent_proto, jsb_cocos2d_WavesTiles3D_class, js_cocos2dx_WavesTiles3D_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "WavesTiles3D", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_WavesTiles3D_class; - p->proto = jsb_cocos2d_WavesTiles3D_prototype; - p->parentProto = jsb_cocos2d_TiledGrid3DAction_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_WavesTiles3D_prototype); + jsb_register_class(cx, jsb_cocos2d_WavesTiles3D_class, proto, parent_proto); } JSClass *jsb_cocos2d_JumpTiles3D_class; @@ -35371,8 +33600,8 @@ bool js_cocos2dx_JumpTiles3D_constructor(JSContext *cx, uint32_t argc, jsval *vp CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -35437,32 +33666,20 @@ void js_register_cocos2dx_JumpTiles3D(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_TiledGrid3DAction_prototype); jsb_cocos2d_JumpTiles3D_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_TiledGrid3DAction_prototype), + parent_proto, jsb_cocos2d_JumpTiles3D_class, js_cocos2dx_JumpTiles3D_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "JumpTiles3D", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_JumpTiles3D_class; - p->proto = jsb_cocos2d_JumpTiles3D_prototype; - p->parentProto = jsb_cocos2d_TiledGrid3DAction_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_JumpTiles3D_prototype); + jsb_register_class(cx, jsb_cocos2d_JumpTiles3D_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.JumpTiles3D.extend = cc.Class.extend; })()"); } @@ -35536,8 +33753,8 @@ bool js_cocos2dx_SplitRows_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -35581,32 +33798,20 @@ void js_register_cocos2dx_SplitRows(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_TiledGrid3DAction_prototype); jsb_cocos2d_SplitRows_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_TiledGrid3DAction_prototype), + parent_proto, jsb_cocos2d_SplitRows_class, js_cocos2dx_SplitRows_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "SplitRows", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_SplitRows_class; - p->proto = jsb_cocos2d_SplitRows_prototype; - p->parentProto = jsb_cocos2d_TiledGrid3DAction_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_SplitRows_prototype); + jsb_register_class(cx, jsb_cocos2d_SplitRows_class, proto, parent_proto); } JSClass *jsb_cocos2d_SplitCols_class; @@ -35679,8 +33884,8 @@ bool js_cocos2dx_SplitCols_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -35724,32 +33929,20 @@ void js_register_cocos2dx_SplitCols(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_TiledGrid3DAction_prototype); jsb_cocos2d_SplitCols_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_TiledGrid3DAction_prototype), + parent_proto, jsb_cocos2d_SplitCols_class, js_cocos2dx_SplitCols_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "SplitCols", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_SplitCols_class; - p->proto = jsb_cocos2d_SplitCols_prototype; - p->parentProto = jsb_cocos2d_TiledGrid3DAction_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_SplitCols_prototype); + jsb_register_class(cx, jsb_cocos2d_SplitCols_class, proto, parent_proto); } JSClass *jsb_cocos2d_ActionTween_class; @@ -35848,32 +34041,20 @@ void js_register_cocos2dx_ActionTween(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ActionInterval_prototype); jsb_cocos2d_ActionTween_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ActionInterval_prototype), + parent_proto, jsb_cocos2d_ActionTween_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "ActionTween", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_ActionTween_class; - p->proto = jsb_cocos2d_ActionTween_prototype; - p->parentProto = jsb_cocos2d_ActionInterval_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ActionTween_prototype); + jsb_register_class(cx, jsb_cocos2d_ActionTween_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.ActionTween.extend = cc.Class.extend; })()"); } @@ -35963,7 +34144,7 @@ bool js_cocos2dx_AtlasNode_setTextureAtlas(JSContext *cx, uint32_t argc, jsval * if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::TextureAtlas*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -36072,7 +34253,7 @@ bool js_cocos2dx_AtlasNode_setTexture(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -36103,7 +34284,7 @@ bool js_cocos2dx_AtlasNode_initWithTexture(JSContext *cx, uint32_t argc, jsval * if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -36189,8 +34370,8 @@ bool js_cocos2dx_AtlasNode_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -36244,32 +34425,20 @@ void js_register_cocos2dx_AtlasNode(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Node_prototype); jsb_cocos2d_AtlasNode_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Node_prototype), + parent_proto, jsb_cocos2d_AtlasNode_class, js_cocos2dx_AtlasNode_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "AtlasNode", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_AtlasNode_class; - p->proto = jsb_cocos2d_AtlasNode_prototype; - p->parentProto = jsb_cocos2d_Node_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_AtlasNode_prototype); + jsb_register_class(cx, jsb_cocos2d_AtlasNode_class, proto, parent_proto); } JSClass *jsb_cocos2d_ClippingNode_class; @@ -36327,7 +34496,7 @@ bool js_cocos2dx_ClippingNode_setStencil(JSContext *cx, uint32_t argc, jsval *vp if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -36434,7 +34603,7 @@ bool js_cocos2dx_ClippingNode_create(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -36490,8 +34659,8 @@ bool js_cocos2dx_ClippingNode_constructor(JSContext *cx, uint32_t argc, jsval *v CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -36541,32 +34710,20 @@ void js_register_cocos2dx_ClippingNode(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Node_prototype); jsb_cocos2d_ClippingNode_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Node_prototype), + parent_proto, jsb_cocos2d_ClippingNode_class, js_cocos2dx_ClippingNode_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "ClippingNode", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_ClippingNode_class; - p->proto = jsb_cocos2d_ClippingNode_prototype; - p->parentProto = jsb_cocos2d_Node_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ClippingNode_prototype); + jsb_register_class(cx, jsb_cocos2d_ClippingNode_class, proto, parent_proto); } JSClass *jsb_cocos2d_DrawNode_class; @@ -36603,7 +34760,7 @@ bool js_cocos2dx_DrawNode_drawPoints(JSContext *cx, uint32_t argc, jsval *vp) JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::DrawNode *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_DrawNode_drawPoints : Invalid Native Object"); @@ -36654,7 +34811,7 @@ bool js_cocos2dx_DrawNode_drawRect(JSContext *cx, uint32_t argc, jsval *vp) JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::DrawNode *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_DrawNode_drawRect : Invalid Native Object"); @@ -36708,7 +34865,7 @@ bool js_cocos2dx_DrawNode_drawSolidCircle(JSContext *cx, uint32_t argc, jsval *v JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::DrawNode *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_DrawNode_drawSolidCircle : Invalid Native Object"); @@ -36877,7 +35034,7 @@ bool js_cocos2dx_DrawNode_drawCatmullRom(JSContext *cx, uint32_t argc, jsval *vp if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::PointArray*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -36966,7 +35123,7 @@ bool js_cocos2dx_DrawNode_drawCircle(JSContext *cx, uint32_t argc, jsval *vp) JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::DrawNode *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_DrawNode_drawCircle : Invalid Native Object"); @@ -37182,7 +35339,7 @@ bool js_cocos2dx_DrawNode_drawCardinalSpline(JSContext *cx, uint32_t argc, jsval if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::PointArray*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -37314,8 +35471,8 @@ bool js_cocos2dx_DrawNode_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -37398,32 +35555,20 @@ void js_register_cocos2dx_DrawNode(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Node_prototype); jsb_cocos2d_DrawNode_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Node_prototype), + parent_proto, jsb_cocos2d_DrawNode_class, js_cocos2dx_DrawNode_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "DrawNode", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_DrawNode_class; - p->proto = jsb_cocos2d_DrawNode_prototype; - p->parentProto = jsb_cocos2d_Node_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_DrawNode_prototype); + jsb_register_class(cx, jsb_cocos2d_DrawNode_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.DrawNode.extend = cc.Class.extend; })()"); } @@ -37560,7 +35705,7 @@ bool js_cocos2dx_Label_disableEffect(JSContext *cx, uint32_t argc, jsval *vp) JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::Label *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Label_disableEffect : Invalid Native Object"); @@ -38049,7 +36194,7 @@ bool js_cocos2dx_Label_setCharMap(JSContext *cx, uint32_t argc, jsval *vp) JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::Label *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Label_setCharMap : Invalid Native Object"); @@ -38060,7 +36205,7 @@ bool js_cocos2dx_Label_setCharMap(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -38535,7 +36680,7 @@ bool js_cocos2dx_Label_setAlignment(JSContext *cx, uint32_t argc, jsval *vp) JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::Label *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Label_setAlignment : Invalid Native Object"); @@ -38732,7 +36877,7 @@ bool js_cocos2dx_Label_createWithCharMap(JSContext *cx, uint32_t argc, jsval *vp if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -38933,8 +37078,8 @@ bool js_cocos2dx_Label_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -39050,32 +37195,20 @@ void js_register_cocos2dx_Label(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Node_prototype); jsb_cocos2d_Label_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Node_prototype), + parent_proto, jsb_cocos2d_Label_class, js_cocos2dx_Label_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "Label", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_Label_class; - p->proto = jsb_cocos2d_Label_prototype; - p->parentProto = jsb_cocos2d_Node_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_Label_prototype); + jsb_register_class(cx, jsb_cocos2d_Label_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.Label.extend = cc.Class.extend; })()"); } @@ -39109,7 +37242,7 @@ bool js_cocos2dx_LabelAtlas_initWithString(JSContext *cx, uint32_t argc, jsval * JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::LabelAtlas *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_LabelAtlas_initWithString : Invalid Native Object"); @@ -39164,7 +37297,7 @@ bool js_cocos2dx_LabelAtlas_initWithString(JSContext *cx, uint32_t argc, jsval * if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -39303,8 +37436,8 @@ bool js_cocos2dx_LabelAtlas_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -39367,32 +37500,20 @@ void js_register_cocos2dx_LabelAtlas(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_AtlasNode_prototype); jsb_cocos2d_LabelAtlas_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_AtlasNode_prototype), + parent_proto, jsb_cocos2d_LabelAtlas_class, js_cocos2dx_LabelAtlas_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "LabelAtlas", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_LabelAtlas_class; - p->proto = jsb_cocos2d_LabelAtlas_prototype; - p->parentProto = jsb_cocos2d_AtlasNode_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_LabelAtlas_prototype); + jsb_register_class(cx, jsb_cocos2d_LabelAtlas_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.LabelAtlas.extend = cc.Class.extend; })()"); } @@ -39831,8 +37952,8 @@ bool js_cocos2dx_LabelBMFont_constructor(JSContext *cx, uint32_t argc, jsval *vp CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -39903,32 +38024,20 @@ void js_register_cocos2dx_LabelBMFont(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Node_prototype); jsb_cocos2d_LabelBMFont_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Node_prototype), + parent_proto, jsb_cocos2d_LabelBMFont_class, js_cocos2dx_LabelBMFont_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "LabelBMFont", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_LabelBMFont_class; - p->proto = jsb_cocos2d_LabelBMFont_prototype; - p->parentProto = jsb_cocos2d_Node_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_LabelBMFont_prototype); + jsb_register_class(cx, jsb_cocos2d_LabelBMFont_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.LabelBMFont.extend = cc.Class.extend; })()"); } @@ -40721,8 +38830,8 @@ bool js_cocos2dx_LabelTTF_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -40808,32 +38917,20 @@ void js_register_cocos2dx_LabelTTF(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Node_prototype); jsb_cocos2d_LabelTTF_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Node_prototype), + parent_proto, jsb_cocos2d_LabelTTF_class, js_cocos2dx_LabelTTF_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "LabelTTF", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_LabelTTF_class; - p->proto = jsb_cocos2d_LabelTTF_prototype; - p->parentProto = jsb_cocos2d_Node_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_LabelTTF_prototype); + jsb_register_class(cx, jsb_cocos2d_LabelTTF_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.LabelTTF.extend = cc.Class.extend; })()"); } @@ -40877,8 +38974,8 @@ bool js_cocos2dx_Layer_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -40938,32 +39035,20 @@ void js_register_cocos2dx_Layer(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Node_prototype); jsb_cocos2d_Layer_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Node_prototype), + parent_proto, jsb_cocos2d_Layer_class, js_cocos2dx_Layer_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "Layer", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_Layer_class; - p->proto = jsb_cocos2d_Layer_prototype; - p->parentProto = jsb_cocos2d_Node_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_Layer_prototype); + jsb_register_class(cx, jsb_cocos2d_Layer_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.Layer.extend = cc.Class.extend; })()"); } @@ -41007,8 +39092,8 @@ bool js_cocos2dx___LayerRGBA_constructor(JSContext *cx, uint32_t argc, jsval *vp CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -41051,32 +39136,20 @@ void js_register_cocos2dx___LayerRGBA(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Layer_prototype); jsb_cocos2d___LayerRGBA_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Layer_prototype), + parent_proto, jsb_cocos2d___LayerRGBA_class, js_cocos2dx___LayerRGBA_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "LayerRGBA", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d___LayerRGBA_class; - p->proto = jsb_cocos2d___LayerRGBA_prototype; - p->parentProto = jsb_cocos2d_Layer_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d___LayerRGBA_prototype); + jsb_register_class(cx, jsb_cocos2d___LayerRGBA_class, proto, parent_proto); } JSClass *jsb_cocos2d_LayerColor_class; @@ -41169,7 +39242,7 @@ bool js_cocos2dx_LayerColor_initWithColor(JSContext *cx, uint32_t argc, jsval *v JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::LayerColor *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_LayerColor_initWithColor : Invalid Native Object"); @@ -41314,8 +39387,8 @@ bool js_cocos2dx_LayerColor_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -41381,32 +39454,20 @@ void js_register_cocos2dx_LayerColor(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Layer_prototype); jsb_cocos2d_LayerColor_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Layer_prototype), + parent_proto, jsb_cocos2d_LayerColor_class, js_cocos2dx_LayerColor_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "LayerColor", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_LayerColor_class; - p->proto = jsb_cocos2d_LayerColor_prototype; - p->parentProto = jsb_cocos2d_Layer_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_LayerColor_prototype); + jsb_register_class(cx, jsb_cocos2d_LayerColor_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.LayerColor.extend = cc.Class.extend; })()"); } @@ -41592,7 +39653,7 @@ bool js_cocos2dx_LayerGradient_initWithColor(JSContext *cx, uint32_t argc, jsval JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::LayerGradient *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_LayerGradient_initWithColor : Invalid Native Object"); @@ -41779,8 +39840,8 @@ bool js_cocos2dx_LayerGradient_constructor(JSContext *cx, uint32_t argc, jsval * CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -41853,32 +39914,20 @@ void js_register_cocos2dx_LayerGradient(JSContext *cx, JS::HandleObject global) JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_LayerColor_prototype); jsb_cocos2d_LayerGradient_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_LayerColor_prototype), + parent_proto, jsb_cocos2d_LayerGradient_class, js_cocos2dx_LayerGradient_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "LayerGradient", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_LayerGradient_class; - p->proto = jsb_cocos2d_LayerGradient_prototype; - p->parentProto = jsb_cocos2d_LayerColor_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_LayerGradient_prototype); + jsb_register_class(cx, jsb_cocos2d_LayerGradient_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.LayerGradient.extend = cc.Class.extend; })()"); } @@ -41941,7 +39990,7 @@ bool js_cocos2dx_LayerMultiplex_addLayer(JSContext *cx, uint32_t argc, jsval *vp if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Layer*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -41991,8 +40040,8 @@ bool js_cocos2dx_LayerMultiplex_constructor(JSContext *cx, uint32_t argc, jsval CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -42053,32 +40102,20 @@ void js_register_cocos2dx_LayerMultiplex(JSContext *cx, JS::HandleObject global) JSFunctionSpec *st_funcs = NULL; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Layer_prototype); jsb_cocos2d_LayerMultiplex_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Layer_prototype), + parent_proto, jsb_cocos2d_LayerMultiplex_class, js_cocos2dx_LayerMultiplex_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "LayerMultiplex", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_LayerMultiplex_class; - p->proto = jsb_cocos2d_LayerMultiplex_prototype; - p->parentProto = jsb_cocos2d_Layer_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_LayerMultiplex_prototype); + jsb_register_class(cx, jsb_cocos2d_LayerMultiplex_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.LayerMultiplex.extend = cc.Class.extend; })()"); } @@ -42134,7 +40171,8 @@ bool js_cocos2dx_MenuItem_initWithCallback(JSContext *cx, uint32_t argc, jsval * do { if(JS_TypeOfValue(cx, args.get(0)) == JSTYPE_FUNCTION) { - std::shared_ptr func(new JSFunctionWrapper(cx, args.thisv().toObjectOrNull(), args.get(0))); + JS::RootedObject jstarget(cx, args.thisv().toObjectOrNull()); + std::shared_ptr func(new JSFunctionWrapper(cx, jstarget, args.get(0))); auto lambda = [=](cocos2d::Ref* larg0) -> void { JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET jsval largv[1]; @@ -42223,6 +40261,55 @@ bool js_cocos2dx_MenuItem_isSelected(JSContext *cx, uint32_t argc, jsval *vp) JS_ReportError(cx, "js_cocos2dx_MenuItem_isSelected : wrong number of arguments: %d, was expecting %d", argc, 0); return false; } +bool js_cocos2dx_MenuItem_setCallback(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::MenuItem* cobj = (cocos2d::MenuItem *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_MenuItem_setCallback : Invalid Native Object"); + if (argc == 1) { + std::function arg0; + do { + if(JS_TypeOfValue(cx, args.get(0)) == JSTYPE_FUNCTION) + { + JS::RootedObject jstarget(cx, args.thisv().toObjectOrNull()); + std::shared_ptr func(new JSFunctionWrapper(cx, jstarget, args.get(0))); + auto lambda = [=](cocos2d::Ref* larg0) -> void { + JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET + jsval largv[1]; + do { + if (larg0) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Ref*)larg0); + largv[0] = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + largv[0] = JSVAL_NULL; + } + } while (0); + JS::RootedValue rval(cx); + bool succeed = func->invoke(1, &largv[0], &rval); + if (!succeed && JS_IsExceptionPending(cx)) { + JS_ReportPendingException(cx); + } + }; + arg0 = lambda; + } + else + { + arg0 = nullptr; + } + } while(0) + ; + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_MenuItem_setCallback : Error processing arguments"); + cobj->setCallback(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_MenuItem_setCallback : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} bool js_cocos2dx_MenuItem_unselected(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); @@ -42273,8 +40360,8 @@ bool js_cocos2dx_MenuItem_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -42331,6 +40418,7 @@ void js_register_cocos2dx_MenuItem(JSContext *cx, JS::HandleObject global) { JS_FN("isEnabled", js_cocos2dx_MenuItem_isEnabled, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("selected", js_cocos2dx_MenuItem_selected, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("isSelected", js_cocos2dx_MenuItem_isSelected, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setCallback", js_cocos2dx_MenuItem_setCallback, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("unselected", js_cocos2dx_MenuItem_unselected, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("rect", js_cocos2dx_MenuItem_rect, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("ctor", js_cocos2dx_MenuItem_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), @@ -42339,32 +40427,20 @@ void js_register_cocos2dx_MenuItem(JSContext *cx, JS::HandleObject global) { JSFunctionSpec *st_funcs = NULL; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Node_prototype); jsb_cocos2d_MenuItem_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Node_prototype), + parent_proto, jsb_cocos2d_MenuItem_class, js_cocos2dx_MenuItem_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "MenuItem", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_MenuItem_class; - p->proto = jsb_cocos2d_MenuItem_prototype; - p->parentProto = jsb_cocos2d_Node_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_MenuItem_prototype); + jsb_register_class(cx, jsb_cocos2d_MenuItem_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.MenuItem.extend = cc.Class.extend; })()"); } @@ -42385,7 +40461,7 @@ bool js_cocos2dx_MenuItemLabel_setLabel(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -42452,7 +40528,7 @@ bool js_cocos2dx_MenuItemLabel_initWithLabel(JSContext *cx, uint32_t argc, jsval if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -42460,7 +40536,8 @@ bool js_cocos2dx_MenuItemLabel_initWithLabel(JSContext *cx, uint32_t argc, jsval do { if(JS_TypeOfValue(cx, args.get(1)) == JSTYPE_FUNCTION) { - std::shared_ptr func(new JSFunctionWrapper(cx, args.thisv().toObjectOrNull(), args.get(1))); + JS::RootedObject jstarget(cx, args.thisv().toObjectOrNull()); + std::shared_ptr func(new JSFunctionWrapper(cx, jstarget, args.get(1))); auto lambda = [=](cocos2d::Ref* larg0) -> void { JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET jsval largv[1]; @@ -42558,8 +40635,8 @@ bool js_cocos2dx_MenuItemLabel_constructor(JSContext *cx, uint32_t argc, jsval * CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -42622,32 +40699,20 @@ void js_register_cocos2dx_MenuItemLabel(JSContext *cx, JS::HandleObject global) JSFunctionSpec *st_funcs = NULL; + JS::RootedObject parent_proto(cx, jsb_cocos2d_MenuItem_prototype); jsb_cocos2d_MenuItemLabel_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_MenuItem_prototype), + parent_proto, jsb_cocos2d_MenuItemLabel_class, js_cocos2dx_MenuItemLabel_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "MenuItemLabel", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_MenuItemLabel_class; - p->proto = jsb_cocos2d_MenuItemLabel_prototype; - p->parentProto = jsb_cocos2d_MenuItem_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_MenuItemLabel_prototype); + jsb_register_class(cx, jsb_cocos2d_MenuItemLabel_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.MenuItemLabel.extend = cc.Class.extend; })()"); } @@ -42677,7 +40742,8 @@ bool js_cocos2dx_MenuItemAtlasFont_initWithString(JSContext *cx, uint32_t argc, do { if(JS_TypeOfValue(cx, args.get(5)) == JSTYPE_FUNCTION) { - std::shared_ptr func(new JSFunctionWrapper(cx, args.thisv().toObjectOrNull(), args.get(5))); + JS::RootedObject jstarget(cx, args.thisv().toObjectOrNull()); + std::shared_ptr func(new JSFunctionWrapper(cx, jstarget, args.get(5))); auto lambda = [=](cocos2d::Ref* larg0) -> void { JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET jsval largv[1]; @@ -42730,8 +40796,8 @@ bool js_cocos2dx_MenuItemAtlasFont_constructor(JSContext *cx, uint32_t argc, jsv CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -42789,32 +40855,20 @@ void js_register_cocos2dx_MenuItemAtlasFont(JSContext *cx, JS::HandleObject glob JSFunctionSpec *st_funcs = NULL; + JS::RootedObject parent_proto(cx, jsb_cocos2d_MenuItemLabel_prototype); jsb_cocos2d_MenuItemAtlasFont_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_MenuItemLabel_prototype), + parent_proto, jsb_cocos2d_MenuItemAtlasFont_class, js_cocos2dx_MenuItemAtlasFont_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "MenuItemAtlasFont", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_MenuItemAtlasFont_class; - p->proto = jsb_cocos2d_MenuItemAtlasFont_prototype; - p->parentProto = jsb_cocos2d_MenuItemLabel_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_MenuItemAtlasFont_prototype); + jsb_register_class(cx, jsb_cocos2d_MenuItemAtlasFont_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.MenuItemAtlasFont.extend = cc.Class.extend; })()"); } @@ -42894,7 +40948,8 @@ bool js_cocos2dx_MenuItemFont_initWithString(JSContext *cx, uint32_t argc, jsval do { if(JS_TypeOfValue(cx, args.get(1)) == JSTYPE_FUNCTION) { - std::shared_ptr func(new JSFunctionWrapper(cx, args.thisv().toObjectOrNull(), args.get(1))); + JS::RootedObject jstarget(cx, args.thisv().toObjectOrNull()); + std::shared_ptr func(new JSFunctionWrapper(cx, jstarget, args.get(1))); auto lambda = [=](cocos2d::Ref* larg0) -> void { JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET jsval largv[1]; @@ -43025,8 +41080,8 @@ bool js_cocos2dx_MenuItemFont_constructor(JSContext *cx, uint32_t argc, jsval *v CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -43094,32 +41149,20 @@ void js_register_cocos2dx_MenuItemFont(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_MenuItemLabel_prototype); jsb_cocos2d_MenuItemFont_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_MenuItemLabel_prototype), + parent_proto, jsb_cocos2d_MenuItemFont_class, js_cocos2dx_MenuItemFont_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "MenuItemFont", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_MenuItemFont_class; - p->proto = jsb_cocos2d_MenuItemFont_prototype; - p->parentProto = jsb_cocos2d_MenuItemLabel_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_MenuItemFont_prototype); + jsb_register_class(cx, jsb_cocos2d_MenuItemFont_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.MenuItemFont.extend = cc.Class.extend; })()"); } @@ -43176,7 +41219,7 @@ bool js_cocos2dx_MenuItemSprite_setNormalImage(JSContext *cx, uint32_t argc, jsv if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -43204,7 +41247,7 @@ bool js_cocos2dx_MenuItemSprite_setDisabledImage(JSContext *cx, uint32_t argc, j if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -43235,7 +41278,7 @@ bool js_cocos2dx_MenuItemSprite_initWithNormalSprite(JSContext *cx, uint32_t arg if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -43244,7 +41287,7 @@ bool js_cocos2dx_MenuItemSprite_initWithNormalSprite(JSContext *cx, uint32_t arg if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -43253,7 +41296,7 @@ bool js_cocos2dx_MenuItemSprite_initWithNormalSprite(JSContext *cx, uint32_t arg if (args.get(2).isNull()) { arg2 = nullptr; break; } if (!args.get(2).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(2).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(2).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg2 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg2, cx, false, "Invalid Native Object"); @@ -43261,7 +41304,8 @@ bool js_cocos2dx_MenuItemSprite_initWithNormalSprite(JSContext *cx, uint32_t arg do { if(JS_TypeOfValue(cx, args.get(3)) == JSTYPE_FUNCTION) { - std::shared_ptr func(new JSFunctionWrapper(cx, args.thisv().toObjectOrNull(), args.get(3))); + JS::RootedObject jstarget(cx, args.thisv().toObjectOrNull()); + std::shared_ptr func(new JSFunctionWrapper(cx, jstarget, args.get(3))); auto lambda = [=](cocos2d::Ref* larg0) -> void { JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET jsval largv[1]; @@ -43312,7 +41356,7 @@ bool js_cocos2dx_MenuItemSprite_setSelectedImage(JSContext *cx, uint32_t argc, j if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -43433,8 +41477,8 @@ bool js_cocos2dx_MenuItemSprite_constructor(JSContext *cx, uint32_t argc, jsval CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -43501,32 +41545,20 @@ void js_register_cocos2dx_MenuItemSprite(JSContext *cx, JS::HandleObject global) JSFunctionSpec *st_funcs = NULL; + JS::RootedObject parent_proto(cx, jsb_cocos2d_MenuItem_prototype); jsb_cocos2d_MenuItemSprite_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_MenuItem_prototype), + parent_proto, jsb_cocos2d_MenuItemSprite_class, js_cocos2dx_MenuItemSprite_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "MenuItemSprite", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_MenuItemSprite_class; - p->proto = jsb_cocos2d_MenuItemSprite_prototype; - p->parentProto = jsb_cocos2d_MenuItem_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_MenuItemSprite_prototype); + jsb_register_class(cx, jsb_cocos2d_MenuItemSprite_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.MenuItemSprite.extend = cc.Class.extend; })()"); } @@ -43547,7 +41579,7 @@ bool js_cocos2dx_MenuItemImage_setDisabledSpriteFrame(JSContext *cx, uint32_t ar if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::SpriteFrame*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -43575,7 +41607,7 @@ bool js_cocos2dx_MenuItemImage_setSelectedSpriteFrame(JSContext *cx, uint32_t ar if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::SpriteFrame*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -43603,7 +41635,7 @@ bool js_cocos2dx_MenuItemImage_setNormalSpriteFrame(JSContext *cx, uint32_t argc if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::SpriteFrame*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -43654,7 +41686,8 @@ bool js_cocos2dx_MenuItemImage_initWithNormalImage(JSContext *cx, uint32_t argc, do { if(JS_TypeOfValue(cx, args.get(3)) == JSTYPE_FUNCTION) { - std::shared_ptr func(new JSFunctionWrapper(cx, args.thisv().toObjectOrNull(), args.get(3))); + JS::RootedObject jstarget(cx, args.thisv().toObjectOrNull()); + std::shared_ptr func(new JSFunctionWrapper(cx, jstarget, args.get(3))); auto lambda = [=](cocos2d::Ref* larg0) -> void { JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET jsval largv[1]; @@ -43707,8 +41740,8 @@ bool js_cocos2dx_MenuItemImage_constructor(JSContext *cx, uint32_t argc, jsval * CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -43770,32 +41803,20 @@ void js_register_cocos2dx_MenuItemImage(JSContext *cx, JS::HandleObject global) JSFunctionSpec *st_funcs = NULL; + JS::RootedObject parent_proto(cx, jsb_cocos2d_MenuItemSprite_prototype); jsb_cocos2d_MenuItemImage_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_MenuItemSprite_prototype), + parent_proto, jsb_cocos2d_MenuItemImage_class, js_cocos2dx_MenuItemImage_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "MenuItemImage", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_MenuItemImage_class; - p->proto = jsb_cocos2d_MenuItemImage_prototype; - p->parentProto = jsb_cocos2d_MenuItemSprite_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_MenuItemImage_prototype); + jsb_register_class(cx, jsb_cocos2d_MenuItemImage_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.MenuItemImage.extend = cc.Class.extend; })()"); } @@ -43836,7 +41857,7 @@ bool js_cocos2dx_MenuItemToggle_initWithItem(JSContext *cx, uint32_t argc, jsval if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::MenuItem*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -43884,7 +41905,7 @@ bool js_cocos2dx_MenuItemToggle_addSubItem(JSContext *cx, uint32_t argc, jsval * if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::MenuItem*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -43959,8 +41980,8 @@ bool js_cocos2dx_MenuItemToggle_constructor(JSContext *cx, uint32_t argc, jsval CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -44023,32 +42044,20 @@ void js_register_cocos2dx_MenuItemToggle(JSContext *cx, JS::HandleObject global) JSFunctionSpec *st_funcs = NULL; + JS::RootedObject parent_proto(cx, jsb_cocos2d_MenuItem_prototype); jsb_cocos2d_MenuItemToggle_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_MenuItem_prototype), + parent_proto, jsb_cocos2d_MenuItemToggle_class, js_cocos2dx_MenuItemToggle_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "MenuItemToggle", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_MenuItemToggle_class; - p->proto = jsb_cocos2d_MenuItemToggle_prototype; - p->parentProto = jsb_cocos2d_MenuItem_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_MenuItemToggle_prototype); + jsb_register_class(cx, jsb_cocos2d_MenuItemToggle_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.MenuItemToggle.extend = cc.Class.extend; })()"); } @@ -44203,8 +42212,8 @@ bool js_cocos2dx_Menu_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -44268,32 +42277,20 @@ void js_register_cocos2dx_Menu(JSContext *cx, JS::HandleObject global) { JSFunctionSpec *st_funcs = NULL; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Layer_prototype); jsb_cocos2d_Menu_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Layer_prototype), + parent_proto, jsb_cocos2d_Menu_class, js_cocos2dx_Menu_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "Menu", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_Menu_class; - p->proto = jsb_cocos2d_Menu_prototype; - p->parentProto = jsb_cocos2d_Layer_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_Menu_prototype); + jsb_register_class(cx, jsb_cocos2d_Menu_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.Menu.extend = cc.Class.extend; })()"); } @@ -44330,7 +42327,7 @@ bool js_cocos2dx_MotionStreak_setTexture(JSContext *cx, uint32_t argc, jsval *vp if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -44508,7 +42505,7 @@ bool js_cocos2dx_MotionStreak_initWithFade(JSContext *cx, uint32_t argc, jsval * JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::MotionStreak *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_MotionStreak_initWithFade : Invalid Native Object"); @@ -44531,7 +42528,7 @@ bool js_cocos2dx_MotionStreak_initWithFade(JSContext *cx, uint32_t argc, jsval * if (args.get(4).isNull()) { arg4 = nullptr; break; } if (!args.get(4).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(4).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(4).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg4 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg4, cx, false, "Invalid Native Object"); @@ -44637,7 +42634,7 @@ bool js_cocos2dx_MotionStreak_create(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(4).isNull()) { arg4 = nullptr; break; } if (!args.get(4).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(4).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(4).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg4 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg4, cx, false, "Invalid Native Object"); @@ -44708,8 +42705,8 @@ bool js_cocos2dx_MotionStreak_constructor(JSContext *cx, uint32_t argc, jsval *v CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -44782,32 +42779,20 @@ void js_register_cocos2dx_MotionStreak(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Node_prototype); jsb_cocos2d_MotionStreak_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Node_prototype), + parent_proto, jsb_cocos2d_MotionStreak_class, js_cocos2dx_MotionStreak_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "MotionStreak", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_MotionStreak_class; - p->proto = jsb_cocos2d_MotionStreak_prototype; - p->parentProto = jsb_cocos2d_Node_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_MotionStreak_prototype); + jsb_register_class(cx, jsb_cocos2d_MotionStreak_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.MotionStreak.extend = cc.Class.extend; })()"); } @@ -44828,7 +42813,7 @@ bool js_cocos2dx_NodeGrid_setTarget(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -44849,7 +42834,7 @@ bool js_cocos2dx_NodeGrid_getGrid(JSContext *cx, uint32_t argc, jsval *vp) JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::NodeGrid *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_NodeGrid_getGrid : Invalid Native Object"); @@ -44968,8 +42953,8 @@ bool js_cocos2dx_NodeGrid_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -45015,32 +43000,20 @@ void js_register_cocos2dx_NodeGrid(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Node_prototype); jsb_cocos2d_NodeGrid_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Node_prototype), + parent_proto, jsb_cocos2d_NodeGrid_class, js_cocos2dx_NodeGrid_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "NodeGrid", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_NodeGrid_class; - p->proto = jsb_cocos2d_NodeGrid_prototype; - p->parentProto = jsb_cocos2d_Node_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_NodeGrid_prototype); + jsb_register_class(cx, jsb_cocos2d_NodeGrid_class, proto, parent_proto); } JSClass *jsb_cocos2d_ParticleBatchNode_class; @@ -45060,7 +43033,7 @@ bool js_cocos2dx_ParticleBatchNode_setTexture(JSContext *cx, uint32_t argc, jsva if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -45089,7 +43062,7 @@ bool js_cocos2dx_ParticleBatchNode_initWithTexture(JSContext *cx, uint32_t argc, if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -45165,7 +43138,7 @@ bool js_cocos2dx_ParticleBatchNode_setTextureAtlas(JSContext *cx, uint32_t argc, if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::TextureAtlas*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -45301,7 +43274,7 @@ bool js_cocos2dx_ParticleBatchNode_insertChild(JSContext *cx, uint32_t argc, jsv if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ParticleSystem*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -45392,7 +43365,7 @@ bool js_cocos2dx_ParticleBatchNode_createWithTexture(JSContext *cx, uint32_t arg if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -45418,7 +43391,7 @@ bool js_cocos2dx_ParticleBatchNode_createWithTexture(JSContext *cx, uint32_t arg if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -45458,8 +43431,8 @@ bool js_cocos2dx_ParticleBatchNode_constructor(JSContext *cx, uint32_t argc, jsv CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -45532,32 +43505,20 @@ void js_register_cocos2dx_ParticleBatchNode(JSContext *cx, JS::HandleObject glob JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Node_prototype); jsb_cocos2d_ParticleBatchNode_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Node_prototype), + parent_proto, jsb_cocos2d_ParticleBatchNode_class, js_cocos2dx_ParticleBatchNode_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "ParticleBatchNode", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_ParticleBatchNode_class; - p->proto = jsb_cocos2d_ParticleBatchNode_prototype; - p->parentProto = jsb_cocos2d_Node_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ParticleBatchNode_prototype); + jsb_register_class(cx, jsb_cocos2d_ParticleBatchNode_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.ParticleBatchNode.extend = cc.Class.extend; })()"); } @@ -45654,8 +43615,8 @@ bool js_cocos2dx_ParticleData_constructor(JSContext *cx, uint32_t argc, jsval *v CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -45670,7 +43631,9 @@ void js_cocos2d_ParticleData_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (ParticleData)", obj); js_proxy_t* nproxy; js_proxy_t* jsproxy; - jsproxy = jsb_get_js_proxy(obj); + JSContext *cx = ScriptingCore::getInstance()->getGlobalContext(); + JS::RootedObject jsobj(cx, obj); + jsproxy = jsb_get_js_proxy(jsobj); if (jsproxy) { cocos2d::ParticleData *nobj = static_cast(jsproxy->ptr); nproxy = jsb_get_native_proxy(jsproxy->ptr); @@ -45712,30 +43675,17 @@ void js_register_cocos2dx_ParticleData(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_ParticleData_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocos2d_ParticleData_class, js_cocos2dx_ParticleData_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "ParticleData", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_ParticleData_class; - p->proto = jsb_cocos2d_ParticleData_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ParticleData_prototype); + jsb_register_class(cx, jsb_cocos2d_ParticleData_class, proto, JS::NullPtr()); } JSClass *jsb_cocos2d_ParticleSystem_class; @@ -46281,7 +44231,7 @@ bool js_cocos2dx_ParticleSystem_setTexture(JSContext *cx, uint32_t argc, jsval * if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -46969,7 +44919,7 @@ bool js_cocos2dx_ParticleSystem_setBatchNode(JSContext *cx, uint32_t argc, jsval if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ParticleBatchNode*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -47498,7 +45448,7 @@ bool js_cocos2dx_ParticleSystem_initWithDictionary(JSContext *cx, uint32_t argc, JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParticleSystem_initWithDictionary : Invalid Native Object"); @@ -47712,8 +45662,8 @@ bool js_cocos2dx_ParticleSystem_constructor(JSContext *cx, uint32_t argc, jsval CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -47872,32 +45822,20 @@ void js_register_cocos2dx_ParticleSystem(JSContext *cx, JS::HandleObject global) JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Node_prototype); jsb_cocos2d_ParticleSystem_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Node_prototype), + parent_proto, jsb_cocos2d_ParticleSystem_class, js_cocos2dx_ParticleSystem_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "ParticleSystem", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_ParticleSystem_class; - p->proto = jsb_cocos2d_ParticleSystem_prototype; - p->parentProto = jsb_cocos2d_Node_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ParticleSystem_prototype); + jsb_register_class(cx, jsb_cocos2d_ParticleSystem_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.ParticleSystem.extend = cc.Class.extend; })()"); } @@ -47918,7 +45856,7 @@ bool js_cocos2dx_ParticleSystemQuad_setDisplayFrame(JSContext *cx, uint32_t argc if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::SpriteFrame*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -47947,7 +45885,7 @@ bool js_cocos2dx_ParticleSystemQuad_setTextureWithRect(JSContext *cx, uint32_t a if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -47976,7 +45914,7 @@ bool js_cocos2dx_ParticleSystemQuad_listenRendererRecreated(JSContext *cx, uint3 if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::EventCustom*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -48095,8 +46033,8 @@ bool js_cocos2dx_ParticleSystemQuad_constructor(JSContext *cx, uint32_t argc, js CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -48143,32 +46081,20 @@ void js_register_cocos2dx_ParticleSystemQuad(JSContext *cx, JS::HandleObject glo JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ParticleSystem_prototype); jsb_cocos2d_ParticleSystemQuad_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ParticleSystem_prototype), + parent_proto, jsb_cocos2d_ParticleSystemQuad_class, js_cocos2dx_ParticleSystemQuad_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "ParticleSystem", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_ParticleSystemQuad_class; - p->proto = jsb_cocos2d_ParticleSystemQuad_prototype; - p->parentProto = jsb_cocos2d_ParticleSystem_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ParticleSystemQuad_prototype); + jsb_register_class(cx, jsb_cocos2d_ParticleSystemQuad_class, proto, parent_proto); } JSClass *jsb_cocos2d_ParticleFire_class; @@ -48236,8 +46162,8 @@ bool js_cocos2dx_ParticleFire_constructor(JSContext *cx, uint32_t argc, jsval *v CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -48281,32 +46207,20 @@ void js_register_cocos2dx_ParticleFire(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ParticleSystemQuad_prototype); jsb_cocos2d_ParticleFire_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ParticleSystemQuad_prototype), + parent_proto, jsb_cocos2d_ParticleFire_class, js_cocos2dx_ParticleFire_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "ParticleFire", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_ParticleFire_class; - p->proto = jsb_cocos2d_ParticleFire_prototype; - p->parentProto = jsb_cocos2d_ParticleSystemQuad_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ParticleFire_prototype); + jsb_register_class(cx, jsb_cocos2d_ParticleFire_class, proto, parent_proto); } JSClass *jsb_cocos2d_ParticleFireworks_class; @@ -48414,8 +46328,8 @@ bool js_cocos2dx_ParticleFireworks_constructor(JSContext *cx, uint32_t argc, jsv CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -48461,32 +46375,20 @@ void js_register_cocos2dx_ParticleFireworks(JSContext *cx, JS::HandleObject glob JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ParticleSystemQuad_prototype); jsb_cocos2d_ParticleFireworks_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ParticleSystemQuad_prototype), + parent_proto, jsb_cocos2d_ParticleFireworks_class, js_cocos2dx_ParticleFireworks_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "ParticleFireworks", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_ParticleFireworks_class; - p->proto = jsb_cocos2d_ParticleFireworks_prototype; - p->parentProto = jsb_cocos2d_ParticleSystemQuad_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ParticleFireworks_prototype); + jsb_register_class(cx, jsb_cocos2d_ParticleFireworks_class, proto, parent_proto); } JSClass *jsb_cocos2d_ParticleSun_class; @@ -48594,8 +46496,8 @@ bool js_cocos2dx_ParticleSun_constructor(JSContext *cx, uint32_t argc, jsval *vp CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -48641,32 +46543,20 @@ void js_register_cocos2dx_ParticleSun(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ParticleSystemQuad_prototype); jsb_cocos2d_ParticleSun_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ParticleSystemQuad_prototype), + parent_proto, jsb_cocos2d_ParticleSun_class, js_cocos2dx_ParticleSun_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "ParticleSun", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_ParticleSun_class; - p->proto = jsb_cocos2d_ParticleSun_prototype; - p->parentProto = jsb_cocos2d_ParticleSystemQuad_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ParticleSun_prototype); + jsb_register_class(cx, jsb_cocos2d_ParticleSun_class, proto, parent_proto); } JSClass *jsb_cocos2d_ParticleGalaxy_class; @@ -48774,8 +46664,8 @@ bool js_cocos2dx_ParticleGalaxy_constructor(JSContext *cx, uint32_t argc, jsval CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -48821,32 +46711,20 @@ void js_register_cocos2dx_ParticleGalaxy(JSContext *cx, JS::HandleObject global) JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ParticleSystemQuad_prototype); jsb_cocos2d_ParticleGalaxy_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ParticleSystemQuad_prototype), + parent_proto, jsb_cocos2d_ParticleGalaxy_class, js_cocos2dx_ParticleGalaxy_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "ParticleGalaxy", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_ParticleGalaxy_class; - p->proto = jsb_cocos2d_ParticleGalaxy_prototype; - p->parentProto = jsb_cocos2d_ParticleSystemQuad_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ParticleGalaxy_prototype); + jsb_register_class(cx, jsb_cocos2d_ParticleGalaxy_class, proto, parent_proto); } JSClass *jsb_cocos2d_ParticleFlower_class; @@ -48954,8 +46832,8 @@ bool js_cocos2dx_ParticleFlower_constructor(JSContext *cx, uint32_t argc, jsval CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -49001,32 +46879,20 @@ void js_register_cocos2dx_ParticleFlower(JSContext *cx, JS::HandleObject global) JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ParticleSystemQuad_prototype); jsb_cocos2d_ParticleFlower_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ParticleSystemQuad_prototype), + parent_proto, jsb_cocos2d_ParticleFlower_class, js_cocos2dx_ParticleFlower_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "ParticleFlower", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_ParticleFlower_class; - p->proto = jsb_cocos2d_ParticleFlower_prototype; - p->parentProto = jsb_cocos2d_ParticleSystemQuad_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ParticleFlower_prototype); + jsb_register_class(cx, jsb_cocos2d_ParticleFlower_class, proto, parent_proto); } JSClass *jsb_cocos2d_ParticleMeteor_class; @@ -49134,8 +47000,8 @@ bool js_cocos2dx_ParticleMeteor_constructor(JSContext *cx, uint32_t argc, jsval CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -49181,32 +47047,20 @@ void js_register_cocos2dx_ParticleMeteor(JSContext *cx, JS::HandleObject global) JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ParticleSystemQuad_prototype); jsb_cocos2d_ParticleMeteor_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ParticleSystemQuad_prototype), + parent_proto, jsb_cocos2d_ParticleMeteor_class, js_cocos2dx_ParticleMeteor_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "ParticleMeteor", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_ParticleMeteor_class; - p->proto = jsb_cocos2d_ParticleMeteor_prototype; - p->parentProto = jsb_cocos2d_ParticleSystemQuad_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ParticleMeteor_prototype); + jsb_register_class(cx, jsb_cocos2d_ParticleMeteor_class, proto, parent_proto); } JSClass *jsb_cocos2d_ParticleSpiral_class; @@ -49314,8 +47168,8 @@ bool js_cocos2dx_ParticleSpiral_constructor(JSContext *cx, uint32_t argc, jsval CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -49361,32 +47215,20 @@ void js_register_cocos2dx_ParticleSpiral(JSContext *cx, JS::HandleObject global) JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ParticleSystemQuad_prototype); jsb_cocos2d_ParticleSpiral_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ParticleSystemQuad_prototype), + parent_proto, jsb_cocos2d_ParticleSpiral_class, js_cocos2dx_ParticleSpiral_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "ParticleSpiral", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_ParticleSpiral_class; - p->proto = jsb_cocos2d_ParticleSpiral_prototype; - p->parentProto = jsb_cocos2d_ParticleSystemQuad_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ParticleSpiral_prototype); + jsb_register_class(cx, jsb_cocos2d_ParticleSpiral_class, proto, parent_proto); } JSClass *jsb_cocos2d_ParticleExplosion_class; @@ -49494,8 +47336,8 @@ bool js_cocos2dx_ParticleExplosion_constructor(JSContext *cx, uint32_t argc, jsv CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -49541,32 +47383,20 @@ void js_register_cocos2dx_ParticleExplosion(JSContext *cx, JS::HandleObject glob JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ParticleSystemQuad_prototype); jsb_cocos2d_ParticleExplosion_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ParticleSystemQuad_prototype), + parent_proto, jsb_cocos2d_ParticleExplosion_class, js_cocos2dx_ParticleExplosion_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "ParticleExplosion", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_ParticleExplosion_class; - p->proto = jsb_cocos2d_ParticleExplosion_prototype; - p->parentProto = jsb_cocos2d_ParticleSystemQuad_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ParticleExplosion_prototype); + jsb_register_class(cx, jsb_cocos2d_ParticleExplosion_class, proto, parent_proto); } JSClass *jsb_cocos2d_ParticleSmoke_class; @@ -49674,8 +47504,8 @@ bool js_cocos2dx_ParticleSmoke_constructor(JSContext *cx, uint32_t argc, jsval * CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -49721,32 +47551,20 @@ void js_register_cocos2dx_ParticleSmoke(JSContext *cx, JS::HandleObject global) JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ParticleSystemQuad_prototype); jsb_cocos2d_ParticleSmoke_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ParticleSystemQuad_prototype), + parent_proto, jsb_cocos2d_ParticleSmoke_class, js_cocos2dx_ParticleSmoke_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "ParticleSmoke", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_ParticleSmoke_class; - p->proto = jsb_cocos2d_ParticleSmoke_prototype; - p->parentProto = jsb_cocos2d_ParticleSystemQuad_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ParticleSmoke_prototype); + jsb_register_class(cx, jsb_cocos2d_ParticleSmoke_class, proto, parent_proto); } JSClass *jsb_cocos2d_ParticleSnow_class; @@ -49854,8 +47672,8 @@ bool js_cocos2dx_ParticleSnow_constructor(JSContext *cx, uint32_t argc, jsval *v CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -49901,32 +47719,20 @@ void js_register_cocos2dx_ParticleSnow(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ParticleSystemQuad_prototype); jsb_cocos2d_ParticleSnow_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ParticleSystemQuad_prototype), + parent_proto, jsb_cocos2d_ParticleSnow_class, js_cocos2dx_ParticleSnow_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "ParticleSnow", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_ParticleSnow_class; - p->proto = jsb_cocos2d_ParticleSnow_prototype; - p->parentProto = jsb_cocos2d_ParticleSystemQuad_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ParticleSnow_prototype); + jsb_register_class(cx, jsb_cocos2d_ParticleSnow_class, proto, parent_proto); } JSClass *jsb_cocos2d_ParticleRain_class; @@ -50034,8 +47840,8 @@ bool js_cocos2dx_ParticleRain_constructor(JSContext *cx, uint32_t argc, jsval *v CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -50081,32 +47887,20 @@ void js_register_cocos2dx_ParticleRain(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ParticleSystemQuad_prototype); jsb_cocos2d_ParticleRain_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ParticleSystemQuad_prototype), + parent_proto, jsb_cocos2d_ParticleRain_class, js_cocos2dx_ParticleRain_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "ParticleRain", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_ParticleRain_class; - p->proto = jsb_cocos2d_ParticleRain_prototype; - p->parentProto = jsb_cocos2d_ParticleSystemQuad_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ParticleRain_prototype); + jsb_register_class(cx, jsb_cocos2d_ParticleRain_class, proto, parent_proto); } JSClass *jsb_cocos2d_ProgressTimer_class; @@ -50126,7 +47920,7 @@ bool js_cocos2dx_ProgressTimer_initWithSprite(JSContext *cx, uint32_t argc, jsva if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -50212,7 +48006,7 @@ bool js_cocos2dx_ProgressTimer_setSprite(JSContext *cx, uint32_t argc, jsval *vp if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -50314,7 +48108,7 @@ bool js_cocos2dx_ProgressTimer_setReverseDirection(JSContext *cx, uint32_t argc, JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::ProgressTimer *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ProgressTimer_setReverseDirection : Invalid Native Object"); @@ -50409,7 +48203,7 @@ bool js_cocos2dx_ProgressTimer_create(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -50448,8 +48242,8 @@ bool js_cocos2dx_ProgressTimer_constructor(JSContext *cx, uint32_t argc, jsval * CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -50522,32 +48316,20 @@ void js_register_cocos2dx_ProgressTimer(JSContext *cx, JS::HandleObject global) JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Node_prototype); jsb_cocos2d_ProgressTimer_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Node_prototype), + parent_proto, jsb_cocos2d_ProgressTimer_class, js_cocos2dx_ProgressTimer_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "ProgressTimer", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_ProgressTimer_class; - p->proto = jsb_cocos2d_ProgressTimer_prototype; - p->parentProto = jsb_cocos2d_Node_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ProgressTimer_prototype); + jsb_register_class(cx, jsb_cocos2d_ProgressTimer_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.ProgressTimer.extend = cc.Class.extend; })()"); } @@ -50561,7 +48343,7 @@ bool js_cocos2dx_ProtectedNode_addProtectedChild(JSContext *cx, uint32_t argc, j JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::ProtectedNode *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ProtectedNode_addProtectedChild : Invalid Native Object"); @@ -50572,7 +48354,7 @@ bool js_cocos2dx_ProtectedNode_addProtectedChild(JSContext *cx, uint32_t argc, j if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -50594,7 +48376,7 @@ bool js_cocos2dx_ProtectedNode_addProtectedChild(JSContext *cx, uint32_t argc, j if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -50613,7 +48395,7 @@ bool js_cocos2dx_ProtectedNode_addProtectedChild(JSContext *cx, uint32_t argc, j if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -50695,7 +48477,7 @@ bool js_cocos2dx_ProtectedNode_reorderProtectedChild(JSContext *cx, uint32_t arg if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -50805,7 +48587,7 @@ bool js_cocos2dx_ProtectedNode_removeProtectedChild(JSContext *cx, uint32_t argc if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -50822,7 +48604,7 @@ bool js_cocos2dx_ProtectedNode_removeProtectedChild(JSContext *cx, uint32_t argc if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -50890,8 +48672,8 @@ bool js_cocos2dx_ProtectedNode_constructor(JSContext *cx, uint32_t argc, jsval * CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -50944,32 +48726,20 @@ void js_register_cocos2dx_ProtectedNode(JSContext *cx, JS::HandleObject global) JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Node_prototype); jsb_cocos2d_ProtectedNode_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Node_prototype), + parent_proto, jsb_cocos2d_ProtectedNode_class, js_cocos2dx_ProtectedNode_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "ProtectedNode", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_ProtectedNode_class; - p->proto = jsb_cocos2d_ProtectedNode_prototype; - p->parentProto = jsb_cocos2d_Node_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ProtectedNode_prototype); + jsb_register_class(cx, jsb_cocos2d_ProtectedNode_class, proto, parent_proto); } JSClass *jsb_cocos2d_Sprite_class; @@ -50982,7 +48752,7 @@ bool js_cocos2dx_Sprite_setSpriteFrame(JSContext *cx, uint32_t argc, jsval *vp) JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::Sprite *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Sprite_setSpriteFrame : Invalid Native Object"); @@ -50993,7 +48763,7 @@ bool js_cocos2dx_Sprite_setSpriteFrame(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::SpriteFrame*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -51026,7 +48796,7 @@ bool js_cocos2dx_Sprite_setTexture(JSContext *cx, uint32_t argc, jsval *vp) JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::Sprite *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Sprite_setTexture : Invalid Native Object"); @@ -51037,7 +48807,7 @@ bool js_cocos2dx_Sprite_setTexture(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -51175,7 +48945,7 @@ bool js_cocos2dx_Sprite_initWithTexture(JSContext *cx, uint32_t argc, jsval *vp) JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::Sprite *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Sprite_initWithTexture : Invalid Native Object"); @@ -51186,7 +48956,7 @@ bool js_cocos2dx_Sprite_initWithTexture(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -51210,7 +48980,7 @@ bool js_cocos2dx_Sprite_initWithTexture(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -51231,7 +49001,7 @@ bool js_cocos2dx_Sprite_initWithTexture(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -51323,7 +49093,7 @@ bool js_cocos2dx_Sprite_setTextureRect(JSContext *cx, uint32_t argc, jsval *vp) JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::Sprite *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Sprite_setTextureRect : Invalid Native Object"); @@ -51393,7 +49163,7 @@ bool js_cocos2dx_Sprite_isFrameDisplayed(JSContext *cx, uint32_t argc, jsval *vp if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::SpriteFrame*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -51441,7 +49211,7 @@ bool js_cocos2dx_Sprite_setBatchNode(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::SpriteBatchNode*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -51509,7 +49279,7 @@ bool js_cocos2dx_Sprite_setTextureAtlas(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::TextureAtlas*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -51649,7 +49419,7 @@ bool js_cocos2dx_Sprite_initWithFile(JSContext *cx, uint32_t argc, jsval *vp) JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::Sprite *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Sprite_initWithFile : Invalid Native Object"); @@ -51744,7 +49514,7 @@ bool js_cocos2dx_Sprite_initWithSpriteFrame(JSContext *cx, uint32_t argc, jsval if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::SpriteFrame*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -51832,8 +49602,8 @@ bool js_cocos2dx_Sprite_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -51922,32 +49692,20 @@ void js_register_cocos2dx_Sprite(JSContext *cx, JS::HandleObject global) { JSFunctionSpec *st_funcs = NULL; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Node_prototype); jsb_cocos2d_Sprite_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Node_prototype), + parent_proto, jsb_cocos2d_Sprite_class, js_cocos2dx_Sprite_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "Sprite", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_Sprite_class; - p->proto = jsb_cocos2d_Sprite_prototype; - p->parentProto = jsb_cocos2d_Node_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_Sprite_prototype); + jsb_register_class(cx, jsb_cocos2d_Sprite_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.Sprite.extend = cc.Class.extend; })()"); } @@ -52084,7 +49842,7 @@ bool js_cocos2dx_RenderTexture_setSprite(JSContext *cx, uint32_t argc, jsval *vp if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -52260,7 +50018,7 @@ bool js_cocos2dx_RenderTexture_beginWithClear(JSContext *cx, uint32_t argc, jsva JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::RenderTexture *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_RenderTexture_beginWithClear : Invalid Native Object"); @@ -52488,7 +50246,7 @@ bool js_cocos2dx_RenderTexture_initWithWidthAndHeight(JSContext *cx, uint32_t ar JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::RenderTexture *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_RenderTexture_initWithWidthAndHeight : Invalid Native Object"); @@ -52637,8 +50395,8 @@ bool js_cocos2dx_RenderTexture_constructor(JSContext *cx, uint32_t argc, jsval * CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -52721,32 +50479,20 @@ void js_register_cocos2dx_RenderTexture(JSContext *cx, JS::HandleObject global) JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Node_prototype); jsb_cocos2d_RenderTexture_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Node_prototype), + parent_proto, jsb_cocos2d_RenderTexture_class, js_cocos2dx_RenderTexture_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "RenderTexture", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_RenderTexture_class; - p->proto = jsb_cocos2d_RenderTexture_prototype; - p->parentProto = jsb_cocos2d_Node_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_RenderTexture_prototype); + jsb_register_class(cx, jsb_cocos2d_RenderTexture_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.RenderTexture.extend = cc.Class.extend; })()"); } @@ -52767,7 +50513,7 @@ bool js_cocos2dx_TransitionEaseScene_easeActionWithAction(JSContext *cx, uint32_ if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -52821,30 +50567,17 @@ void js_register_cocos2dx_TransitionEaseScene(JSContext *cx, JS::HandleObject gl jsb_cocos2d_TransitionEaseScene_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocos2d_TransitionEaseScene_class, empty_constructor, 0, properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "TransitionEaseScene", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_TransitionEaseScene_class; - p->proto = jsb_cocos2d_TransitionEaseScene_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_TransitionEaseScene_prototype); + jsb_register_class(cx, jsb_cocos2d_TransitionEaseScene_class, proto, JS::NullPtr()); } JSClass *jsb_cocos2d_TransitionScene_class; @@ -52907,7 +50640,7 @@ bool js_cocos2dx_TransitionScene_initWithDuration(JSContext *cx, uint32_t argc, if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -52969,7 +50702,7 @@ bool js_cocos2dx_TransitionScene_create(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -53008,8 +50741,8 @@ bool js_cocos2dx_TransitionScene_constructor(JSContext *cx, uint32_t argc, jsval CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -53074,32 +50807,20 @@ void js_register_cocos2dx_TransitionScene(JSContext *cx, JS::HandleObject global JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Scene_prototype); jsb_cocos2d_TransitionScene_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Scene_prototype), + parent_proto, jsb_cocos2d_TransitionScene_class, js_cocos2dx_TransitionScene_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "TransitionScene", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_TransitionScene_class; - p->proto = jsb_cocos2d_TransitionScene_prototype; - p->parentProto = jsb_cocos2d_Scene_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_TransitionScene_prototype); + jsb_register_class(cx, jsb_cocos2d_TransitionScene_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.TransitionScene.extend = cc.Class.extend; })()"); } @@ -53123,7 +50844,7 @@ bool js_cocos2dx_TransitionSceneOriented_initWithDuration(JSContext *cx, uint32_ if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -53153,7 +50874,7 @@ bool js_cocos2dx_TransitionSceneOriented_create(JSContext *cx, uint32_t argc, js if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -53193,8 +50914,8 @@ bool js_cocos2dx_TransitionSceneOriented_constructor(JSContext *cx, uint32_t arg CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -53255,32 +50976,20 @@ void js_register_cocos2dx_TransitionSceneOriented(JSContext *cx, JS::HandleObjec JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_TransitionScene_prototype); jsb_cocos2d_TransitionSceneOriented_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_TransitionScene_prototype), + parent_proto, jsb_cocos2d_TransitionSceneOriented_class, js_cocos2dx_TransitionSceneOriented_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "TransitionSceneOriented", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_TransitionSceneOriented_class; - p->proto = jsb_cocos2d_TransitionSceneOriented_prototype; - p->parentProto = jsb_cocos2d_TransitionScene_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_TransitionSceneOriented_prototype); + jsb_register_class(cx, jsb_cocos2d_TransitionSceneOriented_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.TransitionSceneOriented.extend = cc.Class.extend; })()"); } @@ -53299,7 +51008,7 @@ bool js_cocos2dx_TransitionRotoZoom_create(JSContext *cx, uint32_t argc, jsval * if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -53338,8 +51047,8 @@ bool js_cocos2dx_TransitionRotoZoom_constructor(JSContext *cx, uint32_t argc, js CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -53399,32 +51108,20 @@ void js_register_cocos2dx_TransitionRotoZoom(JSContext *cx, JS::HandleObject glo JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_TransitionScene_prototype); jsb_cocos2d_TransitionRotoZoom_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_TransitionScene_prototype), + parent_proto, jsb_cocos2d_TransitionRotoZoom_class, js_cocos2dx_TransitionRotoZoom_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "TransitionRotoZoom", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_TransitionRotoZoom_class; - p->proto = jsb_cocos2d_TransitionRotoZoom_prototype; - p->parentProto = jsb_cocos2d_TransitionScene_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_TransitionRotoZoom_prototype); + jsb_register_class(cx, jsb_cocos2d_TransitionRotoZoom_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.TransitionRotoZoom.extend = cc.Class.extend; })()"); } @@ -53443,7 +51140,7 @@ bool js_cocos2dx_TransitionJumpZoom_create(JSContext *cx, uint32_t argc, jsval * if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -53482,8 +51179,8 @@ bool js_cocos2dx_TransitionJumpZoom_constructor(JSContext *cx, uint32_t argc, js CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -53543,32 +51240,20 @@ void js_register_cocos2dx_TransitionJumpZoom(JSContext *cx, JS::HandleObject glo JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_TransitionScene_prototype); jsb_cocos2d_TransitionJumpZoom_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_TransitionScene_prototype), + parent_proto, jsb_cocos2d_TransitionJumpZoom_class, js_cocos2dx_TransitionJumpZoom_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "TransitionJumpZoom", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_TransitionJumpZoom_class; - p->proto = jsb_cocos2d_TransitionJumpZoom_prototype; - p->parentProto = jsb_cocos2d_TransitionScene_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_TransitionJumpZoom_prototype); + jsb_register_class(cx, jsb_cocos2d_TransitionJumpZoom_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.TransitionJumpZoom.extend = cc.Class.extend; })()"); } @@ -53614,7 +51299,7 @@ bool js_cocos2dx_TransitionMoveInL_easeActionWithAction(JSContext *cx, uint32_t if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -53649,7 +51334,7 @@ bool js_cocos2dx_TransitionMoveInL_create(JSContext *cx, uint32_t argc, jsval *v if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -53688,8 +51373,8 @@ bool js_cocos2dx_TransitionMoveInL_constructor(JSContext *cx, uint32_t argc, jsv CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -53751,32 +51436,20 @@ void js_register_cocos2dx_TransitionMoveInL(JSContext *cx, JS::HandleObject glob JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_TransitionScene_prototype); jsb_cocos2d_TransitionMoveInL_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_TransitionScene_prototype), + parent_proto, jsb_cocos2d_TransitionMoveInL_class, js_cocos2dx_TransitionMoveInL_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "TransitionMoveInL", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_TransitionMoveInL_class; - p->proto = jsb_cocos2d_TransitionMoveInL_prototype; - p->parentProto = jsb_cocos2d_TransitionScene_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_TransitionMoveInL_prototype); + jsb_register_class(cx, jsb_cocos2d_TransitionMoveInL_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.TransitionMoveInL.extend = cc.Class.extend; })()"); } @@ -53795,7 +51468,7 @@ bool js_cocos2dx_TransitionMoveInR_create(JSContext *cx, uint32_t argc, jsval *v if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -53834,8 +51507,8 @@ bool js_cocos2dx_TransitionMoveInR_constructor(JSContext *cx, uint32_t argc, jsv CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -53895,32 +51568,20 @@ void js_register_cocos2dx_TransitionMoveInR(JSContext *cx, JS::HandleObject glob JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_TransitionMoveInL_prototype); jsb_cocos2d_TransitionMoveInR_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_TransitionMoveInL_prototype), + parent_proto, jsb_cocos2d_TransitionMoveInR_class, js_cocos2dx_TransitionMoveInR_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "TransitionMoveInR", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_TransitionMoveInR_class; - p->proto = jsb_cocos2d_TransitionMoveInR_prototype; - p->parentProto = jsb_cocos2d_TransitionMoveInL_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_TransitionMoveInR_prototype); + jsb_register_class(cx, jsb_cocos2d_TransitionMoveInR_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.TransitionMoveInR.extend = cc.Class.extend; })()"); } @@ -53939,7 +51600,7 @@ bool js_cocos2dx_TransitionMoveInT_create(JSContext *cx, uint32_t argc, jsval *v if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -53978,8 +51639,8 @@ bool js_cocos2dx_TransitionMoveInT_constructor(JSContext *cx, uint32_t argc, jsv CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -54039,32 +51700,20 @@ void js_register_cocos2dx_TransitionMoveInT(JSContext *cx, JS::HandleObject glob JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_TransitionMoveInL_prototype); jsb_cocos2d_TransitionMoveInT_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_TransitionMoveInL_prototype), + parent_proto, jsb_cocos2d_TransitionMoveInT_class, js_cocos2dx_TransitionMoveInT_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "TransitionMoveInT", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_TransitionMoveInT_class; - p->proto = jsb_cocos2d_TransitionMoveInT_prototype; - p->parentProto = jsb_cocos2d_TransitionMoveInL_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_TransitionMoveInT_prototype); + jsb_register_class(cx, jsb_cocos2d_TransitionMoveInT_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.TransitionMoveInT.extend = cc.Class.extend; })()"); } @@ -54083,7 +51732,7 @@ bool js_cocos2dx_TransitionMoveInB_create(JSContext *cx, uint32_t argc, jsval *v if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -54122,8 +51771,8 @@ bool js_cocos2dx_TransitionMoveInB_constructor(JSContext *cx, uint32_t argc, jsv CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -54183,32 +51832,20 @@ void js_register_cocos2dx_TransitionMoveInB(JSContext *cx, JS::HandleObject glob JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_TransitionMoveInL_prototype); jsb_cocos2d_TransitionMoveInB_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_TransitionMoveInL_prototype), + parent_proto, jsb_cocos2d_TransitionMoveInB_class, js_cocos2dx_TransitionMoveInB_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "TransitionMoveInB", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_TransitionMoveInB_class; - p->proto = jsb_cocos2d_TransitionMoveInB_prototype; - p->parentProto = jsb_cocos2d_TransitionMoveInL_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_TransitionMoveInB_prototype); + jsb_register_class(cx, jsb_cocos2d_TransitionMoveInB_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.TransitionMoveInB.extend = cc.Class.extend; })()"); } @@ -54254,7 +51891,7 @@ bool js_cocos2dx_TransitionSlideInL_easeActionWithAction(JSContext *cx, uint32_t if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -54289,7 +51926,7 @@ bool js_cocos2dx_TransitionSlideInL_create(JSContext *cx, uint32_t argc, jsval * if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -54328,8 +51965,8 @@ bool js_cocos2dx_TransitionSlideInL_constructor(JSContext *cx, uint32_t argc, js CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -54391,32 +52028,20 @@ void js_register_cocos2dx_TransitionSlideInL(JSContext *cx, JS::HandleObject glo JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_TransitionScene_prototype); jsb_cocos2d_TransitionSlideInL_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_TransitionScene_prototype), + parent_proto, jsb_cocos2d_TransitionSlideInL_class, js_cocos2dx_TransitionSlideInL_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "TransitionSlideInL", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_TransitionSlideInL_class; - p->proto = jsb_cocos2d_TransitionSlideInL_prototype; - p->parentProto = jsb_cocos2d_TransitionScene_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_TransitionSlideInL_prototype); + jsb_register_class(cx, jsb_cocos2d_TransitionSlideInL_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.TransitionSlideInL.extend = cc.Class.extend; })()"); } @@ -54435,7 +52060,7 @@ bool js_cocos2dx_TransitionSlideInR_create(JSContext *cx, uint32_t argc, jsval * if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -54474,8 +52099,8 @@ bool js_cocos2dx_TransitionSlideInR_constructor(JSContext *cx, uint32_t argc, js CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -54535,32 +52160,20 @@ void js_register_cocos2dx_TransitionSlideInR(JSContext *cx, JS::HandleObject glo JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_TransitionSlideInL_prototype); jsb_cocos2d_TransitionSlideInR_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_TransitionSlideInL_prototype), + parent_proto, jsb_cocos2d_TransitionSlideInR_class, js_cocos2dx_TransitionSlideInR_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "TransitionSlideInR", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_TransitionSlideInR_class; - p->proto = jsb_cocos2d_TransitionSlideInR_prototype; - p->parentProto = jsb_cocos2d_TransitionSlideInL_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_TransitionSlideInR_prototype); + jsb_register_class(cx, jsb_cocos2d_TransitionSlideInR_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.TransitionSlideInR.extend = cc.Class.extend; })()"); } @@ -54579,7 +52192,7 @@ bool js_cocos2dx_TransitionSlideInB_create(JSContext *cx, uint32_t argc, jsval * if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -54618,8 +52231,8 @@ bool js_cocos2dx_TransitionSlideInB_constructor(JSContext *cx, uint32_t argc, js CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -54679,32 +52292,20 @@ void js_register_cocos2dx_TransitionSlideInB(JSContext *cx, JS::HandleObject glo JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_TransitionSlideInL_prototype); jsb_cocos2d_TransitionSlideInB_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_TransitionSlideInL_prototype), + parent_proto, jsb_cocos2d_TransitionSlideInB_class, js_cocos2dx_TransitionSlideInB_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "TransitionSlideInB", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_TransitionSlideInB_class; - p->proto = jsb_cocos2d_TransitionSlideInB_prototype; - p->parentProto = jsb_cocos2d_TransitionSlideInL_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_TransitionSlideInB_prototype); + jsb_register_class(cx, jsb_cocos2d_TransitionSlideInB_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.TransitionSlideInB.extend = cc.Class.extend; })()"); } @@ -54723,7 +52324,7 @@ bool js_cocos2dx_TransitionSlideInT_create(JSContext *cx, uint32_t argc, jsval * if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -54762,8 +52363,8 @@ bool js_cocos2dx_TransitionSlideInT_constructor(JSContext *cx, uint32_t argc, js CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -54823,32 +52424,20 @@ void js_register_cocos2dx_TransitionSlideInT(JSContext *cx, JS::HandleObject glo JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_TransitionSlideInL_prototype); jsb_cocos2d_TransitionSlideInT_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_TransitionSlideInL_prototype), + parent_proto, jsb_cocos2d_TransitionSlideInT_class, js_cocos2dx_TransitionSlideInT_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "TransitionSlideInT", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_TransitionSlideInT_class; - p->proto = jsb_cocos2d_TransitionSlideInT_prototype; - p->parentProto = jsb_cocos2d_TransitionSlideInL_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_TransitionSlideInT_prototype); + jsb_register_class(cx, jsb_cocos2d_TransitionSlideInT_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.TransitionSlideInT.extend = cc.Class.extend; })()"); } @@ -54869,7 +52458,7 @@ bool js_cocos2dx_TransitionShrinkGrow_easeActionWithAction(JSContext *cx, uint32 if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -54904,7 +52493,7 @@ bool js_cocos2dx_TransitionShrinkGrow_create(JSContext *cx, uint32_t argc, jsval if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -54943,8 +52532,8 @@ bool js_cocos2dx_TransitionShrinkGrow_constructor(JSContext *cx, uint32_t argc, CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -55005,32 +52594,20 @@ void js_register_cocos2dx_TransitionShrinkGrow(JSContext *cx, JS::HandleObject g JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_TransitionScene_prototype); jsb_cocos2d_TransitionShrinkGrow_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_TransitionScene_prototype), + parent_proto, jsb_cocos2d_TransitionShrinkGrow_class, js_cocos2dx_TransitionShrinkGrow_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "TransitionShrinkGrow", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_TransitionShrinkGrow_class; - p->proto = jsb_cocos2d_TransitionShrinkGrow_prototype; - p->parentProto = jsb_cocos2d_TransitionScene_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_TransitionShrinkGrow_prototype); + jsb_register_class(cx, jsb_cocos2d_TransitionShrinkGrow_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.TransitionShrinkGrow.extend = cc.Class.extend; })()"); } @@ -55052,7 +52629,7 @@ bool js_cocos2dx_TransitionFlipX_create(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -55083,7 +52660,7 @@ bool js_cocos2dx_TransitionFlipX_create(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -55125,8 +52702,8 @@ bool js_cocos2dx_TransitionFlipX_constructor(JSContext *cx, uint32_t argc, jsval CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -55186,32 +52763,20 @@ void js_register_cocos2dx_TransitionFlipX(JSContext *cx, JS::HandleObject global JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_TransitionSceneOriented_prototype); jsb_cocos2d_TransitionFlipX_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_TransitionSceneOriented_prototype), + parent_proto, jsb_cocos2d_TransitionFlipX_class, js_cocos2dx_TransitionFlipX_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "TransitionFlipX", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_TransitionFlipX_class; - p->proto = jsb_cocos2d_TransitionFlipX_prototype; - p->parentProto = jsb_cocos2d_TransitionSceneOriented_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_TransitionFlipX_prototype); + jsb_register_class(cx, jsb_cocos2d_TransitionFlipX_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.TransitionFlipX.extend = cc.Class.extend; })()"); } @@ -55233,7 +52798,7 @@ bool js_cocos2dx_TransitionFlipY_create(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -55264,7 +52829,7 @@ bool js_cocos2dx_TransitionFlipY_create(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -55306,8 +52871,8 @@ bool js_cocos2dx_TransitionFlipY_constructor(JSContext *cx, uint32_t argc, jsval CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -55367,32 +52932,20 @@ void js_register_cocos2dx_TransitionFlipY(JSContext *cx, JS::HandleObject global JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_TransitionSceneOriented_prototype); jsb_cocos2d_TransitionFlipY_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_TransitionSceneOriented_prototype), + parent_proto, jsb_cocos2d_TransitionFlipY_class, js_cocos2dx_TransitionFlipY_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "TransitionFlipY", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_TransitionFlipY_class; - p->proto = jsb_cocos2d_TransitionFlipY_prototype; - p->parentProto = jsb_cocos2d_TransitionSceneOriented_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_TransitionFlipY_prototype); + jsb_register_class(cx, jsb_cocos2d_TransitionFlipY_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.TransitionFlipY.extend = cc.Class.extend; })()"); } @@ -55414,7 +52967,7 @@ bool js_cocos2dx_TransitionFlipAngular_create(JSContext *cx, uint32_t argc, jsva if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -55445,7 +52998,7 @@ bool js_cocos2dx_TransitionFlipAngular_create(JSContext *cx, uint32_t argc, jsva if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -55487,8 +53040,8 @@ bool js_cocos2dx_TransitionFlipAngular_constructor(JSContext *cx, uint32_t argc, CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -55548,32 +53101,20 @@ void js_register_cocos2dx_TransitionFlipAngular(JSContext *cx, JS::HandleObject JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_TransitionSceneOriented_prototype); jsb_cocos2d_TransitionFlipAngular_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_TransitionSceneOriented_prototype), + parent_proto, jsb_cocos2d_TransitionFlipAngular_class, js_cocos2dx_TransitionFlipAngular_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "TransitionFlipAngular", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_TransitionFlipAngular_class; - p->proto = jsb_cocos2d_TransitionFlipAngular_prototype; - p->parentProto = jsb_cocos2d_TransitionSceneOriented_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_TransitionFlipAngular_prototype); + jsb_register_class(cx, jsb_cocos2d_TransitionFlipAngular_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.TransitionFlipAngular.extend = cc.Class.extend; })()"); } @@ -55595,7 +53136,7 @@ bool js_cocos2dx_TransitionZoomFlipX_create(JSContext *cx, uint32_t argc, jsval if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -55626,7 +53167,7 @@ bool js_cocos2dx_TransitionZoomFlipX_create(JSContext *cx, uint32_t argc, jsval if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -55668,8 +53209,8 @@ bool js_cocos2dx_TransitionZoomFlipX_constructor(JSContext *cx, uint32_t argc, j CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -55729,32 +53270,20 @@ void js_register_cocos2dx_TransitionZoomFlipX(JSContext *cx, JS::HandleObject gl JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_TransitionSceneOriented_prototype); jsb_cocos2d_TransitionZoomFlipX_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_TransitionSceneOriented_prototype), + parent_proto, jsb_cocos2d_TransitionZoomFlipX_class, js_cocos2dx_TransitionZoomFlipX_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "TransitionZoomFlipX", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_TransitionZoomFlipX_class; - p->proto = jsb_cocos2d_TransitionZoomFlipX_prototype; - p->parentProto = jsb_cocos2d_TransitionSceneOriented_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_TransitionZoomFlipX_prototype); + jsb_register_class(cx, jsb_cocos2d_TransitionZoomFlipX_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.TransitionZoomFlipX.extend = cc.Class.extend; })()"); } @@ -55776,7 +53305,7 @@ bool js_cocos2dx_TransitionZoomFlipY_create(JSContext *cx, uint32_t argc, jsval if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -55807,7 +53336,7 @@ bool js_cocos2dx_TransitionZoomFlipY_create(JSContext *cx, uint32_t argc, jsval if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -55849,8 +53378,8 @@ bool js_cocos2dx_TransitionZoomFlipY_constructor(JSContext *cx, uint32_t argc, j CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -55910,32 +53439,20 @@ void js_register_cocos2dx_TransitionZoomFlipY(JSContext *cx, JS::HandleObject gl JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_TransitionSceneOriented_prototype); jsb_cocos2d_TransitionZoomFlipY_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_TransitionSceneOriented_prototype), + parent_proto, jsb_cocos2d_TransitionZoomFlipY_class, js_cocos2dx_TransitionZoomFlipY_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "TransitionZoomFlipY", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_TransitionZoomFlipY_class; - p->proto = jsb_cocos2d_TransitionZoomFlipY_prototype; - p->parentProto = jsb_cocos2d_TransitionSceneOriented_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_TransitionZoomFlipY_prototype); + jsb_register_class(cx, jsb_cocos2d_TransitionZoomFlipY_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.TransitionZoomFlipY.extend = cc.Class.extend; })()"); } @@ -55957,7 +53474,7 @@ bool js_cocos2dx_TransitionZoomFlipAngular_create(JSContext *cx, uint32_t argc, if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -55988,7 +53505,7 @@ bool js_cocos2dx_TransitionZoomFlipAngular_create(JSContext *cx, uint32_t argc, if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -56030,8 +53547,8 @@ bool js_cocos2dx_TransitionZoomFlipAngular_constructor(JSContext *cx, uint32_t a CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -56091,32 +53608,20 @@ void js_register_cocos2dx_TransitionZoomFlipAngular(JSContext *cx, JS::HandleObj JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_TransitionSceneOriented_prototype); jsb_cocos2d_TransitionZoomFlipAngular_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_TransitionSceneOriented_prototype), + parent_proto, jsb_cocos2d_TransitionZoomFlipAngular_class, js_cocos2dx_TransitionZoomFlipAngular_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "TransitionZoomFlipAngular", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_TransitionZoomFlipAngular_class; - p->proto = jsb_cocos2d_TransitionZoomFlipAngular_prototype; - p->parentProto = jsb_cocos2d_TransitionSceneOriented_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_TransitionZoomFlipAngular_prototype); + jsb_register_class(cx, jsb_cocos2d_TransitionZoomFlipAngular_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.TransitionZoomFlipAngular.extend = cc.Class.extend; })()"); } @@ -56130,7 +53635,7 @@ bool js_cocos2dx_TransitionFade_initWithDuration(JSContext *cx, uint32_t argc, j JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::TransitionFade *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TransitionFade_initWithDuration : Invalid Native Object"); @@ -56144,7 +53649,7 @@ bool js_cocos2dx_TransitionFade_initWithDuration(JSContext *cx, uint32_t argc, j if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -56168,7 +53673,7 @@ bool js_cocos2dx_TransitionFade_initWithDuration(JSContext *cx, uint32_t argc, j if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -56203,7 +53708,7 @@ bool js_cocos2dx_TransitionFade_create(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -56234,7 +53739,7 @@ bool js_cocos2dx_TransitionFade_create(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -56276,8 +53781,8 @@ bool js_cocos2dx_TransitionFade_constructor(JSContext *cx, uint32_t argc, jsval CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -56338,32 +53843,20 @@ void js_register_cocos2dx_TransitionFade(JSContext *cx, JS::HandleObject global) JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_TransitionScene_prototype); jsb_cocos2d_TransitionFade_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_TransitionScene_prototype), + parent_proto, jsb_cocos2d_TransitionFade_class, js_cocos2dx_TransitionFade_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "TransitionFade", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_TransitionFade_class; - p->proto = jsb_cocos2d_TransitionFade_prototype; - p->parentProto = jsb_cocos2d_TransitionScene_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_TransitionFade_prototype); + jsb_register_class(cx, jsb_cocos2d_TransitionFade_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.TransitionFade.extend = cc.Class.extend; })()"); } @@ -56382,7 +53875,7 @@ bool js_cocos2dx_TransitionCrossFade_create(JSContext *cx, uint32_t argc, jsval if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -56421,8 +53914,8 @@ bool js_cocos2dx_TransitionCrossFade_constructor(JSContext *cx, uint32_t argc, j CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -56482,32 +53975,20 @@ void js_register_cocos2dx_TransitionCrossFade(JSContext *cx, JS::HandleObject gl JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_TransitionScene_prototype); jsb_cocos2d_TransitionCrossFade_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_TransitionScene_prototype), + parent_proto, jsb_cocos2d_TransitionCrossFade_class, js_cocos2dx_TransitionCrossFade_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "TransitionCrossFade", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_TransitionCrossFade_class; - p->proto = jsb_cocos2d_TransitionCrossFade_prototype; - p->parentProto = jsb_cocos2d_TransitionScene_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_TransitionCrossFade_prototype); + jsb_register_class(cx, jsb_cocos2d_TransitionCrossFade_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.TransitionCrossFade.extend = cc.Class.extend; })()"); } @@ -56528,7 +54009,7 @@ bool js_cocos2dx_TransitionTurnOffTiles_easeActionWithAction(JSContext *cx, uint if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -56563,7 +54044,7 @@ bool js_cocos2dx_TransitionTurnOffTiles_create(JSContext *cx, uint32_t argc, jsv if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -56602,8 +54083,8 @@ bool js_cocos2dx_TransitionTurnOffTiles_constructor(JSContext *cx, uint32_t argc CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -56664,32 +54145,20 @@ void js_register_cocos2dx_TransitionTurnOffTiles(JSContext *cx, JS::HandleObject JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_TransitionScene_prototype); jsb_cocos2d_TransitionTurnOffTiles_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_TransitionScene_prototype), + parent_proto, jsb_cocos2d_TransitionTurnOffTiles_class, js_cocos2dx_TransitionTurnOffTiles_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "TransitionTurnOffTiles", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_TransitionTurnOffTiles_class; - p->proto = jsb_cocos2d_TransitionTurnOffTiles_prototype; - p->parentProto = jsb_cocos2d_TransitionScene_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_TransitionTurnOffTiles_prototype); + jsb_register_class(cx, jsb_cocos2d_TransitionTurnOffTiles_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.TransitionTurnOffTiles.extend = cc.Class.extend; })()"); } @@ -56735,7 +54204,7 @@ bool js_cocos2dx_TransitionSplitCols_easeActionWithAction(JSContext *cx, uint32_ if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -56770,7 +54239,7 @@ bool js_cocos2dx_TransitionSplitCols_create(JSContext *cx, uint32_t argc, jsval if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -56809,8 +54278,8 @@ bool js_cocos2dx_TransitionSplitCols_constructor(JSContext *cx, uint32_t argc, j CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -56872,32 +54341,20 @@ void js_register_cocos2dx_TransitionSplitCols(JSContext *cx, JS::HandleObject gl JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_TransitionScene_prototype); jsb_cocos2d_TransitionSplitCols_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_TransitionScene_prototype), + parent_proto, jsb_cocos2d_TransitionSplitCols_class, js_cocos2dx_TransitionSplitCols_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "TransitionSplitCols", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_TransitionSplitCols_class; - p->proto = jsb_cocos2d_TransitionSplitCols_prototype; - p->parentProto = jsb_cocos2d_TransitionScene_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_TransitionSplitCols_prototype); + jsb_register_class(cx, jsb_cocos2d_TransitionSplitCols_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.TransitionSplitCols.extend = cc.Class.extend; })()"); } @@ -56916,7 +54373,7 @@ bool js_cocos2dx_TransitionSplitRows_create(JSContext *cx, uint32_t argc, jsval if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -56955,8 +54412,8 @@ bool js_cocos2dx_TransitionSplitRows_constructor(JSContext *cx, uint32_t argc, j CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -57016,32 +54473,20 @@ void js_register_cocos2dx_TransitionSplitRows(JSContext *cx, JS::HandleObject gl JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_TransitionSplitCols_prototype); jsb_cocos2d_TransitionSplitRows_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_TransitionSplitCols_prototype), + parent_proto, jsb_cocos2d_TransitionSplitRows_class, js_cocos2dx_TransitionSplitRows_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "TransitionSplitRows", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_TransitionSplitRows_class; - p->proto = jsb_cocos2d_TransitionSplitRows_prototype; - p->parentProto = jsb_cocos2d_TransitionSplitCols_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_TransitionSplitRows_prototype); + jsb_register_class(cx, jsb_cocos2d_TransitionSplitRows_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.TransitionSplitRows.extend = cc.Class.extend; })()"); } @@ -57062,7 +54507,7 @@ bool js_cocos2dx_TransitionFadeTR_easeActionWithAction(JSContext *cx, uint32_t a if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -57126,7 +54571,7 @@ bool js_cocos2dx_TransitionFadeTR_create(JSContext *cx, uint32_t argc, jsval *vp if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -57165,8 +54610,8 @@ bool js_cocos2dx_TransitionFadeTR_constructor(JSContext *cx, uint32_t argc, jsva CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -57228,32 +54673,20 @@ void js_register_cocos2dx_TransitionFadeTR(JSContext *cx, JS::HandleObject globa JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_TransitionScene_prototype); jsb_cocos2d_TransitionFadeTR_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_TransitionScene_prototype), + parent_proto, jsb_cocos2d_TransitionFadeTR_class, js_cocos2dx_TransitionFadeTR_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "TransitionFadeTR", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_TransitionFadeTR_class; - p->proto = jsb_cocos2d_TransitionFadeTR_prototype; - p->parentProto = jsb_cocos2d_TransitionScene_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_TransitionFadeTR_prototype); + jsb_register_class(cx, jsb_cocos2d_TransitionFadeTR_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.TransitionFadeTR.extend = cc.Class.extend; })()"); } @@ -57272,7 +54705,7 @@ bool js_cocos2dx_TransitionFadeBL_create(JSContext *cx, uint32_t argc, jsval *vp if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -57311,8 +54744,8 @@ bool js_cocos2dx_TransitionFadeBL_constructor(JSContext *cx, uint32_t argc, jsva CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -57372,32 +54805,20 @@ void js_register_cocos2dx_TransitionFadeBL(JSContext *cx, JS::HandleObject globa JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_TransitionFadeTR_prototype); jsb_cocos2d_TransitionFadeBL_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_TransitionFadeTR_prototype), + parent_proto, jsb_cocos2d_TransitionFadeBL_class, js_cocos2dx_TransitionFadeBL_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "TransitionFadeBL", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_TransitionFadeBL_class; - p->proto = jsb_cocos2d_TransitionFadeBL_prototype; - p->parentProto = jsb_cocos2d_TransitionFadeTR_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_TransitionFadeBL_prototype); + jsb_register_class(cx, jsb_cocos2d_TransitionFadeBL_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.TransitionFadeBL.extend = cc.Class.extend; })()"); } @@ -57416,7 +54837,7 @@ bool js_cocos2dx_TransitionFadeUp_create(JSContext *cx, uint32_t argc, jsval *vp if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -57455,8 +54876,8 @@ bool js_cocos2dx_TransitionFadeUp_constructor(JSContext *cx, uint32_t argc, jsva CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -57516,32 +54937,20 @@ void js_register_cocos2dx_TransitionFadeUp(JSContext *cx, JS::HandleObject globa JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_TransitionFadeTR_prototype); jsb_cocos2d_TransitionFadeUp_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_TransitionFadeTR_prototype), + parent_proto, jsb_cocos2d_TransitionFadeUp_class, js_cocos2dx_TransitionFadeUp_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "TransitionFadeUp", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_TransitionFadeUp_class; - p->proto = jsb_cocos2d_TransitionFadeUp_prototype; - p->parentProto = jsb_cocos2d_TransitionFadeTR_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_TransitionFadeUp_prototype); + jsb_register_class(cx, jsb_cocos2d_TransitionFadeUp_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.TransitionFadeUp.extend = cc.Class.extend; })()"); } @@ -57560,7 +54969,7 @@ bool js_cocos2dx_TransitionFadeDown_create(JSContext *cx, uint32_t argc, jsval * if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -57599,8 +55008,8 @@ bool js_cocos2dx_TransitionFadeDown_constructor(JSContext *cx, uint32_t argc, js CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -57660,32 +55069,20 @@ void js_register_cocos2dx_TransitionFadeDown(JSContext *cx, JS::HandleObject glo JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_TransitionFadeTR_prototype); jsb_cocos2d_TransitionFadeDown_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_TransitionFadeTR_prototype), + parent_proto, jsb_cocos2d_TransitionFadeDown_class, js_cocos2dx_TransitionFadeDown_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "TransitionFadeDown", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_TransitionFadeDown_class; - p->proto = jsb_cocos2d_TransitionFadeDown_prototype; - p->parentProto = jsb_cocos2d_TransitionFadeTR_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_TransitionFadeDown_prototype); + jsb_register_class(cx, jsb_cocos2d_TransitionFadeDown_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.TransitionFadeDown.extend = cc.Class.extend; })()"); } @@ -57738,7 +55135,7 @@ bool js_cocos2dx_TransitionPageTurn_initWithDuration(JSContext *cx, uint32_t arg if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -57768,7 +55165,7 @@ bool js_cocos2dx_TransitionPageTurn_create(JSContext *cx, uint32_t argc, jsval * if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -57808,8 +55205,8 @@ bool js_cocos2dx_TransitionPageTurn_constructor(JSContext *cx, uint32_t argc, js CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -57871,32 +55268,20 @@ void js_register_cocos2dx_TransitionPageTurn(JSContext *cx, JS::HandleObject glo JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_TransitionScene_prototype); jsb_cocos2d_TransitionPageTurn_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_TransitionScene_prototype), + parent_proto, jsb_cocos2d_TransitionPageTurn_class, js_cocos2dx_TransitionPageTurn_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "TransitionPageTurn", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_TransitionPageTurn_class; - p->proto = jsb_cocos2d_TransitionPageTurn_prototype; - p->parentProto = jsb_cocos2d_TransitionScene_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_TransitionPageTurn_prototype); + jsb_register_class(cx, jsb_cocos2d_TransitionPageTurn_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.TransitionPageTurn.extend = cc.Class.extend; })()"); } @@ -57915,7 +55300,7 @@ bool js_cocos2dx_TransitionProgress_create(JSContext *cx, uint32_t argc, jsval * if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -57954,8 +55339,8 @@ bool js_cocos2dx_TransitionProgress_constructor(JSContext *cx, uint32_t argc, js CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -58015,32 +55400,20 @@ void js_register_cocos2dx_TransitionProgress(JSContext *cx, JS::HandleObject glo JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_TransitionScene_prototype); jsb_cocos2d_TransitionProgress_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_TransitionScene_prototype), + parent_proto, jsb_cocos2d_TransitionProgress_class, js_cocos2dx_TransitionProgress_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "TransitionProgress", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_TransitionProgress_class; - p->proto = jsb_cocos2d_TransitionProgress_prototype; - p->parentProto = jsb_cocos2d_TransitionScene_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_TransitionProgress_prototype); + jsb_register_class(cx, jsb_cocos2d_TransitionProgress_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.TransitionProgress.extend = cc.Class.extend; })()"); } @@ -58059,7 +55432,7 @@ bool js_cocos2dx_TransitionProgressRadialCCW_create(JSContext *cx, uint32_t argc if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -58098,8 +55471,8 @@ bool js_cocos2dx_TransitionProgressRadialCCW_constructor(JSContext *cx, uint32_t CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -58159,32 +55532,20 @@ void js_register_cocos2dx_TransitionProgressRadialCCW(JSContext *cx, JS::HandleO JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_TransitionProgress_prototype); jsb_cocos2d_TransitionProgressRadialCCW_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_TransitionProgress_prototype), + parent_proto, jsb_cocos2d_TransitionProgressRadialCCW_class, js_cocos2dx_TransitionProgressRadialCCW_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "TransitionProgressRadialCCW", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_TransitionProgressRadialCCW_class; - p->proto = jsb_cocos2d_TransitionProgressRadialCCW_prototype; - p->parentProto = jsb_cocos2d_TransitionProgress_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_TransitionProgressRadialCCW_prototype); + jsb_register_class(cx, jsb_cocos2d_TransitionProgressRadialCCW_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.TransitionProgressRadialCCW.extend = cc.Class.extend; })()"); } @@ -58203,7 +55564,7 @@ bool js_cocos2dx_TransitionProgressRadialCW_create(JSContext *cx, uint32_t argc, if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -58242,8 +55603,8 @@ bool js_cocos2dx_TransitionProgressRadialCW_constructor(JSContext *cx, uint32_t CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -58303,32 +55664,20 @@ void js_register_cocos2dx_TransitionProgressRadialCW(JSContext *cx, JS::HandleOb JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_TransitionProgress_prototype); jsb_cocos2d_TransitionProgressRadialCW_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_TransitionProgress_prototype), + parent_proto, jsb_cocos2d_TransitionProgressRadialCW_class, js_cocos2dx_TransitionProgressRadialCW_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "TransitionProgressRadialCW", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_TransitionProgressRadialCW_class; - p->proto = jsb_cocos2d_TransitionProgressRadialCW_prototype; - p->parentProto = jsb_cocos2d_TransitionProgress_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_TransitionProgressRadialCW_prototype); + jsb_register_class(cx, jsb_cocos2d_TransitionProgressRadialCW_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.TransitionProgressRadialCW.extend = cc.Class.extend; })()"); } @@ -58347,7 +55696,7 @@ bool js_cocos2dx_TransitionProgressHorizontal_create(JSContext *cx, uint32_t arg if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -58386,8 +55735,8 @@ bool js_cocos2dx_TransitionProgressHorizontal_constructor(JSContext *cx, uint32_ CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -58447,32 +55796,20 @@ void js_register_cocos2dx_TransitionProgressHorizontal(JSContext *cx, JS::Handle JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_TransitionProgress_prototype); jsb_cocos2d_TransitionProgressHorizontal_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_TransitionProgress_prototype), + parent_proto, jsb_cocos2d_TransitionProgressHorizontal_class, js_cocos2dx_TransitionProgressHorizontal_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "TransitionProgressHorizontal", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_TransitionProgressHorizontal_class; - p->proto = jsb_cocos2d_TransitionProgressHorizontal_prototype; - p->parentProto = jsb_cocos2d_TransitionProgress_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_TransitionProgressHorizontal_prototype); + jsb_register_class(cx, jsb_cocos2d_TransitionProgressHorizontal_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.TransitionProgressHorizontal.extend = cc.Class.extend; })()"); } @@ -58491,7 +55828,7 @@ bool js_cocos2dx_TransitionProgressVertical_create(JSContext *cx, uint32_t argc, if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -58530,8 +55867,8 @@ bool js_cocos2dx_TransitionProgressVertical_constructor(JSContext *cx, uint32_t CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -58591,32 +55928,20 @@ void js_register_cocos2dx_TransitionProgressVertical(JSContext *cx, JS::HandleOb JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_TransitionProgress_prototype); jsb_cocos2d_TransitionProgressVertical_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_TransitionProgress_prototype), + parent_proto, jsb_cocos2d_TransitionProgressVertical_class, js_cocos2dx_TransitionProgressVertical_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "TransitionProgressVertical", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_TransitionProgressVertical_class; - p->proto = jsb_cocos2d_TransitionProgressVertical_prototype; - p->parentProto = jsb_cocos2d_TransitionProgress_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_TransitionProgressVertical_prototype); + jsb_register_class(cx, jsb_cocos2d_TransitionProgressVertical_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.TransitionProgressVertical.extend = cc.Class.extend; })()"); } @@ -58635,7 +55960,7 @@ bool js_cocos2dx_TransitionProgressInOut_create(JSContext *cx, uint32_t argc, js if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -58674,8 +55999,8 @@ bool js_cocos2dx_TransitionProgressInOut_constructor(JSContext *cx, uint32_t arg CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -58735,32 +56060,20 @@ void js_register_cocos2dx_TransitionProgressInOut(JSContext *cx, JS::HandleObjec JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_TransitionProgress_prototype); jsb_cocos2d_TransitionProgressInOut_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_TransitionProgress_prototype), + parent_proto, jsb_cocos2d_TransitionProgressInOut_class, js_cocos2dx_TransitionProgressInOut_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "TransitionProgressInOut", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_TransitionProgressInOut_class; - p->proto = jsb_cocos2d_TransitionProgressInOut_prototype; - p->parentProto = jsb_cocos2d_TransitionProgress_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_TransitionProgressInOut_prototype); + jsb_register_class(cx, jsb_cocos2d_TransitionProgressInOut_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.TransitionProgressInOut.extend = cc.Class.extend; })()"); } @@ -58779,7 +56092,7 @@ bool js_cocos2dx_TransitionProgressOutIn_create(JSContext *cx, uint32_t argc, js if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -58818,8 +56131,8 @@ bool js_cocos2dx_TransitionProgressOutIn_constructor(JSContext *cx, uint32_t arg CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -58879,32 +56192,20 @@ void js_register_cocos2dx_TransitionProgressOutIn(JSContext *cx, JS::HandleObjec JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_TransitionProgress_prototype); jsb_cocos2d_TransitionProgressOutIn_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_TransitionProgress_prototype), + parent_proto, jsb_cocos2d_TransitionProgressOutIn_class, js_cocos2dx_TransitionProgressOutIn_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "TransitionProgressOutIn", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_TransitionProgressOutIn_class; - p->proto = jsb_cocos2d_TransitionProgressOutIn_prototype; - p->parentProto = jsb_cocos2d_TransitionProgress_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_TransitionProgressOutIn_prototype); + jsb_register_class(cx, jsb_cocos2d_TransitionProgressOutIn_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.TransitionProgressOutIn.extend = cc.Class.extend; })()"); } @@ -58977,7 +56278,7 @@ bool js_cocos2dx_Camera_setBackgroundBrush(JSContext *cx, uint32_t argc, jsval * if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::CameraBackgroundBrush*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -59293,7 +56594,7 @@ bool js_cocos2dx_Camera_setScene(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -59455,7 +56756,7 @@ bool js_cocos2dx_Camera_setFrameBufferObject(JSContext *cx, uint32_t argc, jsval if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::experimental::FrameBuffer*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -59687,8 +56988,8 @@ bool js_cocos2dx_Camera_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -59766,32 +57067,20 @@ void js_register_cocos2dx_Camera(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Node_prototype); jsb_cocos2d_Camera_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Node_prototype), + parent_proto, jsb_cocos2d_Camera_class, js_cocos2dx_Camera_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "Camera", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_Camera_class; - p->proto = jsb_cocos2d_Camera_prototype; - p->parentProto = jsb_cocos2d_Node_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_Camera_prototype); + jsb_register_class(cx, jsb_cocos2d_Camera_class, proto, parent_proto); } JSClass *jsb_cocos2d_CameraBackgroundBrush_class; @@ -59829,7 +57118,7 @@ bool js_cocos2dx_CameraBackgroundBrush_drawBackground(JSContext *cx, uint32_t ar if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Camera*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -59999,8 +57288,8 @@ bool js_cocos2dx_CameraBackgroundBrush_constructor(JSContext *cx, uint32_t argc, CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -60049,30 +57338,17 @@ void js_register_cocos2dx_CameraBackgroundBrush(JSContext *cx, JS::HandleObject jsb_cocos2d_CameraBackgroundBrush_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocos2d_CameraBackgroundBrush_class, js_cocos2dx_CameraBackgroundBrush_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "CameraBackgroundBrush", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_CameraBackgroundBrush_class; - p->proto = jsb_cocos2d_CameraBackgroundBrush_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_CameraBackgroundBrush_prototype); + jsb_register_class(cx, jsb_cocos2d_CameraBackgroundBrush_class, proto, JS::NullPtr()); } JSClass *jsb_cocos2d_CameraBackgroundDepthBrush_class; @@ -60139,8 +57415,8 @@ bool js_cocos2dx_CameraBackgroundDepthBrush_constructor(JSContext *cx, uint32_t CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -60184,32 +57460,20 @@ void js_register_cocos2dx_CameraBackgroundDepthBrush(JSContext *cx, JS::HandleOb JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_CameraBackgroundBrush_prototype); jsb_cocos2d_CameraBackgroundDepthBrush_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_CameraBackgroundBrush_prototype), + parent_proto, jsb_cocos2d_CameraBackgroundDepthBrush_class, js_cocos2dx_CameraBackgroundDepthBrush_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "CameraBackgroundDepthBrush", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_CameraBackgroundDepthBrush_class; - p->proto = jsb_cocos2d_CameraBackgroundDepthBrush_prototype; - p->parentProto = jsb_cocos2d_CameraBackgroundBrush_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_CameraBackgroundDepthBrush_prototype); + jsb_register_class(cx, jsb_cocos2d_CameraBackgroundDepthBrush_class, proto, parent_proto); } JSClass *jsb_cocos2d_CameraBackgroundColorBrush_class; @@ -60278,8 +57542,8 @@ bool js_cocos2dx_CameraBackgroundColorBrush_constructor(JSContext *cx, uint32_t CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -60323,32 +57587,20 @@ void js_register_cocos2dx_CameraBackgroundColorBrush(JSContext *cx, JS::HandleOb JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_CameraBackgroundDepthBrush_prototype); jsb_cocos2d_CameraBackgroundColorBrush_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_CameraBackgroundDepthBrush_prototype), + parent_proto, jsb_cocos2d_CameraBackgroundColorBrush_class, js_cocos2dx_CameraBackgroundColorBrush_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "CameraBackgroundColorBrush", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_CameraBackgroundColorBrush_class; - p->proto = jsb_cocos2d_CameraBackgroundColorBrush_prototype; - p->parentProto = jsb_cocos2d_CameraBackgroundDepthBrush_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_CameraBackgroundColorBrush_prototype); + jsb_register_class(cx, jsb_cocos2d_CameraBackgroundColorBrush_class, proto, parent_proto); } JSClass *jsb_cocos2d_CameraBackgroundSkyBoxBrush_class; @@ -60368,7 +57620,7 @@ bool js_cocos2dx_CameraBackgroundSkyBoxBrush_setTexture(JSContext *cx, uint32_t if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::TextureCube*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -60457,8 +57709,8 @@ bool js_cocos2dx_CameraBackgroundSkyBoxBrush_constructor(JSContext *cx, uint32_t CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -60502,32 +57754,20 @@ void js_register_cocos2dx_CameraBackgroundSkyBoxBrush(JSContext *cx, JS::HandleO JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_CameraBackgroundBrush_prototype); jsb_cocos2d_CameraBackgroundSkyBoxBrush_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_CameraBackgroundBrush_prototype), + parent_proto, jsb_cocos2d_CameraBackgroundSkyBoxBrush_class, js_cocos2dx_CameraBackgroundSkyBoxBrush_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "CameraBackgroundSkyBoxBrush", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_CameraBackgroundSkyBoxBrush_class; - p->proto = jsb_cocos2d_CameraBackgroundSkyBoxBrush_prototype; - p->parentProto = jsb_cocos2d_CameraBackgroundBrush_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_CameraBackgroundSkyBoxBrush_prototype); + jsb_register_class(cx, jsb_cocos2d_CameraBackgroundSkyBoxBrush_class, proto, parent_proto); } JSClass *jsb_cocos2d_GridBase_class; @@ -60621,7 +57861,7 @@ bool js_cocos2dx_GridBase_afterDraw(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -60838,7 +58078,7 @@ bool js_cocos2dx_GridBase_initWithSize(JSContext *cx, uint32_t argc, jsval *vp) JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::GridBase *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_GridBase_initWithSize : Invalid Native Object"); @@ -60881,7 +58121,7 @@ bool js_cocos2dx_GridBase_initWithSize(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -60907,7 +58147,7 @@ bool js_cocos2dx_GridBase_initWithSize(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -61034,7 +58274,7 @@ bool js_cocos2dx_GridBase_create(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -61114,30 +58354,17 @@ void js_register_cocos2dx_GridBase(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_GridBase_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocos2d_GridBase_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "GridBase", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_GridBase_class; - p->proto = jsb_cocos2d_GridBase_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_GridBase_prototype); + jsb_register_class(cx, jsb_cocos2d_GridBase_class, proto, JS::NullPtr()); anonEvaluate(cx, global, "(function () { cc.GridBase.extend = cc.Class.extend; })()"); } @@ -61240,7 +58467,7 @@ bool js_cocos2dx_Grid3D_create(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -61274,7 +58501,7 @@ bool js_cocos2dx_Grid3D_create(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -61319,8 +58546,8 @@ bool js_cocos2dx_Grid3D_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -61382,32 +58609,20 @@ void js_register_cocos2dx_Grid3D(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_GridBase_prototype); jsb_cocos2d_Grid3D_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_GridBase_prototype), + parent_proto, jsb_cocos2d_Grid3D_class, js_cocos2dx_Grid3D_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "Grid3D", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_Grid3D_class; - p->proto = jsb_cocos2d_Grid3D_prototype; - p->parentProto = jsb_cocos2d_GridBase_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_Grid3D_prototype); + jsb_register_class(cx, jsb_cocos2d_Grid3D_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.Grid3D.extend = cc.Class.extend; })()"); } @@ -61472,7 +58687,7 @@ bool js_cocos2dx_TiledGrid3D_create(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -61506,7 +58721,7 @@ bool js_cocos2dx_TiledGrid3D_create(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -61551,8 +58766,8 @@ bool js_cocos2dx_TiledGrid3D_constructor(JSContext *cx, uint32_t argc, jsval *vp CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -61612,32 +58827,20 @@ void js_register_cocos2dx_TiledGrid3D(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_GridBase_prototype); jsb_cocos2d_TiledGrid3D_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_GridBase_prototype), + parent_proto, jsb_cocos2d_TiledGrid3D_class, js_cocos2dx_TiledGrid3D_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "TiledGrid3D", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_TiledGrid3D_class; - p->proto = jsb_cocos2d_TiledGrid3D_prototype; - p->parentProto = jsb_cocos2d_GridBase_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_TiledGrid3D_prototype); + jsb_register_class(cx, jsb_cocos2d_TiledGrid3D_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.TiledGrid3D.extend = cc.Class.extend; })()"); } @@ -61813,32 +59016,20 @@ void js_register_cocos2dx_BaseLight(JSContext *cx, JS::HandleObject global) { JSFunctionSpec *st_funcs = NULL; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Node_prototype); jsb_cocos2d_BaseLight_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Node_prototype), + parent_proto, jsb_cocos2d_BaseLight_class, empty_constructor, 0, properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "BaseLight", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_BaseLight_class; - p->proto = jsb_cocos2d_BaseLight_prototype; - p->parentProto = jsb_cocos2d_Node_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_BaseLight_prototype); + jsb_register_class(cx, jsb_cocos2d_BaseLight_class, proto, parent_proto); } JSClass *jsb_cocos2d_DirectionLight_class; @@ -61943,8 +59134,8 @@ bool js_cocos2dx_DirectionLight_constructor(JSContext *cx, uint32_t argc, jsval CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -61990,32 +59181,20 @@ void js_register_cocos2dx_DirectionLight(JSContext *cx, JS::HandleObject global) JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_BaseLight_prototype); jsb_cocos2d_DirectionLight_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_BaseLight_prototype), + parent_proto, jsb_cocos2d_DirectionLight_class, js_cocos2dx_DirectionLight_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "DirectionLight", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_DirectionLight_class; - p->proto = jsb_cocos2d_DirectionLight_prototype; - p->parentProto = jsb_cocos2d_BaseLight_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_DirectionLight_prototype); + jsb_register_class(cx, jsb_cocos2d_DirectionLight_class, proto, parent_proto); } JSClass *jsb_cocos2d_PointLight_class; @@ -62104,8 +59283,8 @@ bool js_cocos2dx_PointLight_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -62150,32 +59329,20 @@ void js_register_cocos2dx_PointLight(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_BaseLight_prototype); jsb_cocos2d_PointLight_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_BaseLight_prototype), + parent_proto, jsb_cocos2d_PointLight_class, js_cocos2dx_PointLight_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "PointLight", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_PointLight_class; - p->proto = jsb_cocos2d_PointLight_prototype; - p->parentProto = jsb_cocos2d_BaseLight_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_PointLight_prototype); + jsb_register_class(cx, jsb_cocos2d_PointLight_class, proto, parent_proto); } JSClass *jsb_cocos2d_SpotLight_class; @@ -62438,8 +59605,8 @@ bool js_cocos2dx_SpotLight_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -62493,32 +59660,20 @@ void js_register_cocos2dx_SpotLight(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_BaseLight_prototype); jsb_cocos2d_SpotLight_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_BaseLight_prototype), + parent_proto, jsb_cocos2d_SpotLight_class, js_cocos2dx_SpotLight_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "SpotLight", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_SpotLight_class; - p->proto = jsb_cocos2d_SpotLight_prototype; - p->parentProto = jsb_cocos2d_BaseLight_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_SpotLight_prototype); + jsb_register_class(cx, jsb_cocos2d_SpotLight_class, proto, parent_proto); } JSClass *jsb_cocos2d_AmbientLight_class; @@ -62565,8 +59720,8 @@ bool js_cocos2dx_AmbientLight_constructor(JSContext *cx, uint32_t argc, jsval *v CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -62609,32 +59764,20 @@ void js_register_cocos2dx_AmbientLight(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_BaseLight_prototype); jsb_cocos2d_AmbientLight_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_BaseLight_prototype), + parent_proto, jsb_cocos2d_AmbientLight_class, js_cocos2dx_AmbientLight_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "AmbientLight", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_AmbientLight_class; - p->proto = jsb_cocos2d_AmbientLight_prototype; - p->parentProto = jsb_cocos2d_BaseLight_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_AmbientLight_prototype); + jsb_register_class(cx, jsb_cocos2d_AmbientLight_class, proto, parent_proto); } JSClass *jsb_cocos2d_GLProgram_class; @@ -62765,7 +59908,7 @@ bool js_cocos2dx_GLProgram_initWithByteArrays(JSContext *cx, uint32_t argc, jsva JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::GLProgram *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_GLProgram_initWithByteArrays : Invalid Native Object"); @@ -62836,7 +59979,7 @@ bool js_cocos2dx_GLProgram_initWithFilenames(JSContext *cx, uint32_t argc, jsval JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::GLProgram *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_GLProgram_initWithFilenames : Invalid Native Object"); @@ -62911,7 +60054,7 @@ bool js_cocos2dx_GLProgram_setUniformsForBuiltins(JSContext *cx, uint32_t argc, JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::GLProgram *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_GLProgram_setUniformsForBuiltins : Invalid Native Object"); @@ -63333,8 +60476,8 @@ bool js_cocos2dx_GLProgram_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -63418,30 +60561,17 @@ void js_register_cocos2dx_GLProgram(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_GLProgram_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocos2d_GLProgram_class, js_cocos2dx_GLProgram_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "GLProgram", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_GLProgram_class; - p->proto = jsb_cocos2d_GLProgram_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_GLProgram_prototype); + jsb_register_class(cx, jsb_cocos2d_GLProgram_class, proto, JS::NullPtr()); anonEvaluate(cx, global, "(function () { cc.GLProgram.extend = cc.Class.extend; })()"); } @@ -63495,7 +60625,7 @@ bool js_cocos2dx_GLProgramCache_addGLProgram(JSContext *cx, uint32_t argc, jsval if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::GLProgram*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -63604,8 +60734,8 @@ bool js_cocos2dx_GLProgramCache_constructor(JSContext *cx, uint32_t argc, jsval CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -63654,30 +60784,17 @@ void js_register_cocos2dx_GLProgramCache(JSContext *cx, JS::HandleObject global) jsb_cocos2d_GLProgramCache_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocos2d_GLProgramCache_class, js_cocos2dx_GLProgramCache_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "ShaderCache", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_GLProgramCache_class; - p->proto = jsb_cocos2d_GLProgramCache_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_GLProgramCache_prototype); + jsb_register_class(cx, jsb_cocos2d_GLProgramCache_class, proto, JS::NullPtr()); } JSClass *jsb_cocos2d_RenderState_class; @@ -63697,7 +60814,7 @@ bool js_cocos2dx_RenderState_setTexture(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -63725,7 +60842,7 @@ bool js_cocos2dx_RenderState_getTopmost(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::RenderState*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -63787,7 +60904,7 @@ bool js_cocos2dx_RenderState_bind(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Pass*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -63858,7 +60975,7 @@ bool js_cocos2dx_RenderState_setParent(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::RenderState*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -63937,30 +61054,17 @@ void js_register_cocos2dx_RenderState(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_RenderState_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocos2d_RenderState_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "RenderState", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_RenderState_class; - p->proto = jsb_cocos2d_RenderState_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_RenderState_prototype); + jsb_register_class(cx, jsb_cocos2d_RenderState_class, proto, JS::NullPtr()); } JSClass *jsb_cocos2d_Pass_class; @@ -63989,7 +61093,7 @@ bool js_cocos2dx_Pass_bind(JSContext *cx, uint32_t argc, jsval *vp) JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::Pass *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Pass_bind : Invalid Native Object"); @@ -64127,7 +61231,7 @@ bool js_cocos2dx_Pass_setVertexAttribBinding(JSContext *cx, uint32_t argc, jsval if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::VertexAttribBinding*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -64151,7 +61255,7 @@ bool js_cocos2dx_Pass_create(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Technique*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -64185,7 +61289,7 @@ bool js_cocos2dx_Pass_createWithGLProgramState(JSContext *cx, uint32_t argc, jsv if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Technique*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -64194,7 +61298,7 @@ bool js_cocos2dx_Pass_createWithGLProgramState(JSContext *cx, uint32_t argc, jsv if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::GLProgramState*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -64258,32 +61362,20 @@ void js_register_cocos2dx_Pass(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_RenderState_prototype); jsb_cocos2d_Pass_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_RenderState_prototype), + parent_proto, jsb_cocos2d_Pass_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "Pass", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_Pass_class; - p->proto = jsb_cocos2d_Pass_prototype; - p->parentProto = jsb_cocos2d_RenderState_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_Pass_prototype); + jsb_register_class(cx, jsb_cocos2d_Pass_class, proto, parent_proto); } JSClass *jsb_cocos2d_Technique_class; @@ -64346,7 +61438,7 @@ bool js_cocos2dx_Technique_addPass(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Pass*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -64435,7 +61527,7 @@ bool js_cocos2dx_Technique_create(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Material*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -64469,7 +61561,7 @@ bool js_cocos2dx_Technique_createWithGLProgramState(JSContext *cx, uint32_t argc if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Material*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -64478,7 +61570,7 @@ bool js_cocos2dx_Technique_createWithGLProgramState(JSContext *cx, uint32_t argc if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::GLProgramState*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -64541,32 +61633,20 @@ void js_register_cocos2dx_Technique(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_RenderState_prototype); jsb_cocos2d_Technique_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_RenderState_prototype), + parent_proto, jsb_cocos2d_Technique_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "Technique", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_Technique_class; - p->proto = jsb_cocos2d_Technique_prototype; - p->parentProto = jsb_cocos2d_RenderState_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_Technique_prototype); + jsb_register_class(cx, jsb_cocos2d_Technique_class, proto, parent_proto); } JSClass *jsb_cocos2d_Material_class; @@ -64763,7 +61843,7 @@ bool js_cocos2dx_Material_addTechnique(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Technique*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -64837,7 +61917,7 @@ bool js_cocos2dx_Material_createWithGLStateProgram(JSContext *cx, uint32_t argc, if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::GLProgramState*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -64870,7 +61950,7 @@ bool js_cocos2dx_Material_createWithProperties(JSContext *cx, uint32_t argc, jsv if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Properties*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -64938,32 +62018,20 @@ void js_register_cocos2dx_Material(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_RenderState_prototype); jsb_cocos2d_Material_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_RenderState_prototype), + parent_proto, jsb_cocos2d_Material_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "Material", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_Material_class; - p->proto = jsb_cocos2d_Material_prototype; - p->parentProto = jsb_cocos2d_RenderState_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_Material_prototype); + jsb_register_class(cx, jsb_cocos2d_Material_class, proto, parent_proto); } JSClass *jsb_cocos2d_TextureCache_class; @@ -65058,7 +62126,8 @@ bool js_cocos2dx_TextureCache_addImageAsync(JSContext *cx, uint32_t argc, jsval do { if(JS_TypeOfValue(cx, args.get(1)) == JSTYPE_FUNCTION) { - std::shared_ptr func(new JSFunctionWrapper(cx, args.thisv().toObjectOrNull(), args.get(1))); + JS::RootedObject jstarget(cx, args.thisv().toObjectOrNull()); + std::shared_ptr func(new JSFunctionWrapper(cx, jstarget, args.get(1))); auto lambda = [=](cocos2d::Texture2D* larg0) -> void { JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET jsval largv[1]; @@ -65136,7 +62205,7 @@ bool js_cocos2dx_TextureCache_addImage(JSContext *cx, uint32_t argc, jsval *vp) JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::TextureCache *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TextureCache_addImage : Invalid Native Object"); @@ -65147,7 +62216,7 @@ bool js_cocos2dx_TextureCache_addImage(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Image*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -65257,7 +62326,7 @@ bool js_cocos2dx_TextureCache_getTextureFilePath(JSContext *cx, uint32_t argc, j if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -65303,7 +62372,7 @@ bool js_cocos2dx_TextureCache_removeTexture(JSContext *cx, uint32_t argc, jsval if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -65349,8 +62418,8 @@ bool js_cocos2dx_TextureCache_constructor(JSContext *cx, uint32_t argc, jsval *v CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -65404,30 +62473,17 @@ void js_register_cocos2dx_TextureCache(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_TextureCache_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocos2d_TextureCache_class, js_cocos2dx_TextureCache_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "TextureCache", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_TextureCache_class; - p->proto = jsb_cocos2d_TextureCache_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_TextureCache_prototype); + jsb_register_class(cx, jsb_cocos2d_TextureCache_class, proto, JS::NullPtr()); } JSClass *jsb_cocos2d_Device_class; @@ -65548,30 +62604,17 @@ void js_register_cocos2dx_Device(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_Device_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocos2d_Device_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "Device", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_Device_class; - p->proto = jsb_cocos2d_Device_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_Device_prototype); + jsb_register_class(cx, jsb_cocos2d_Device_class, proto, JS::NullPtr()); } JSClass *jsb_cocos2d_SAXParser_class; @@ -65630,30 +62673,17 @@ void js_register_cocos2dx_SAXParser(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_SAXParser_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocos2d_SAXParser_class, empty_constructor, 0, properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "PlistParser", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_SAXParser_class; - p->proto = jsb_cocos2d_SAXParser_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_SAXParser_prototype); + jsb_register_class(cx, jsb_cocos2d_SAXParser_class, proto, JS::NullPtr()); } JSClass *jsb_cocos2d_Application_class; @@ -65793,30 +62823,17 @@ void js_register_cocos2dx_Application(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_Application_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocos2d_Application_class, empty_constructor, 0, properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "Application", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_Application_class; - p->proto = jsb_cocos2d_Application_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_Application_prototype); + jsb_register_class(cx, jsb_cocos2d_Application_class, proto, JS::NullPtr()); } JSClass *jsb_cocos2d_AnimationCache_class; @@ -65866,7 +62883,7 @@ bool js_cocos2dx_AnimationCache_addAnimation(JSContext *cx, uint32_t argc, jsval if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Animation*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -66010,8 +63027,8 @@ bool js_cocos2dx_AnimationCache_constructor(JSContext *cx, uint32_t argc, jsval CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -66078,30 +63095,17 @@ void js_register_cocos2dx_AnimationCache(JSContext *cx, JS::HandleObject global) jsb_cocos2d_AnimationCache_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocos2d_AnimationCache_class, js_cocos2dx_AnimationCache_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "AnimationCache", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_AnimationCache_class; - p->proto = jsb_cocos2d_AnimationCache_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_AnimationCache_prototype); + jsb_register_class(cx, jsb_cocos2d_AnimationCache_class, proto, JS::NullPtr()); anonEvaluate(cx, global, "(function () { cc.AnimationCache.extend = cc.Class.extend; })()"); } @@ -66122,7 +63126,7 @@ bool js_cocos2dx_SpriteBatchNode_appendChild(JSContext *cx, uint32_t argc, jsval if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -66152,7 +63156,7 @@ bool js_cocos2dx_SpriteBatchNode_addSpriteWithoutQuad(JSContext *cx, uint32_t ar if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -66211,7 +63215,7 @@ bool js_cocos2dx_SpriteBatchNode_initWithTexture(JSContext *cx, uint32_t argc, j if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -66230,7 +63234,7 @@ bool js_cocos2dx_SpriteBatchNode_initWithTexture(JSContext *cx, uint32_t argc, j if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -66279,7 +63283,7 @@ bool js_cocos2dx_SpriteBatchNode_lowestAtlasIndexInChild(JSContext *cx, uint32_t if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -66310,7 +63314,7 @@ bool js_cocos2dx_SpriteBatchNode_atlasIndexForChild(JSContext *cx, uint32_t argc if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -66341,7 +63345,7 @@ bool js_cocos2dx_SpriteBatchNode_setTextureAtlas(JSContext *cx, uint32_t argc, j if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::TextureAtlas*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -66470,7 +63474,7 @@ bool js_cocos2dx_SpriteBatchNode_insertQuadFromSprite(JSContext *cx, uint32_t ar if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -66499,7 +63503,7 @@ bool js_cocos2dx_SpriteBatchNode_setTexture(JSContext *cx, uint32_t argc, jsval if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -66528,7 +63532,7 @@ bool js_cocos2dx_SpriteBatchNode_rebuildIndexInOrder(JSContext *cx, uint32_t arg if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -66559,7 +63563,7 @@ bool js_cocos2dx_SpriteBatchNode_highestAtlasIndexInChild(JSContext *cx, uint32_ if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -66611,7 +63615,7 @@ bool js_cocos2dx_SpriteBatchNode_removeSpriteFromAtlas(JSContext *cx, uint32_t a if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -66699,7 +63703,7 @@ bool js_cocos2dx_SpriteBatchNode_createWithTexture(JSContext *cx, uint32_t argc, if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -66725,7 +63729,7 @@ bool js_cocos2dx_SpriteBatchNode_createWithTexture(JSContext *cx, uint32_t argc, if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -66765,8 +63769,8 @@ bool js_cocos2dx_SpriteBatchNode_constructor(JSContext *cx, uint32_t argc, jsval CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -66846,32 +63850,20 @@ void js_register_cocos2dx_SpriteBatchNode(JSContext *cx, JS::HandleObject global JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Node_prototype); jsb_cocos2d_SpriteBatchNode_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Node_prototype), + parent_proto, jsb_cocos2d_SpriteBatchNode_class, js_cocos2dx_SpriteBatchNode_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "SpriteBatchNode", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_SpriteBatchNode_class; - p->proto = jsb_cocos2d_SpriteBatchNode_prototype; - p->parentProto = jsb_cocos2d_Node_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_SpriteBatchNode_prototype); + jsb_register_class(cx, jsb_cocos2d_SpriteBatchNode_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.SpriteBatchNode.extend = cc.Class.extend; })()"); } @@ -66894,7 +63886,7 @@ bool js_cocos2dx_SpriteFrameCache_addSpriteFramesWithFileContent(JSContext *cx, if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -66923,7 +63915,7 @@ bool js_cocos2dx_SpriteFrameCache_addSpriteFrame(JSContext *cx, uint32_t argc, j if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::SpriteFrame*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -66945,7 +63937,7 @@ bool js_cocos2dx_SpriteFrameCache_addSpriteFramesWithFile(JSContext *cx, uint32_ JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::SpriteFrameCache *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_SpriteFrameCache_addSpriteFramesWithFile : Invalid Native Object"); @@ -66984,7 +63976,7 @@ bool js_cocos2dx_SpriteFrameCache_addSpriteFramesWithFile(JSContext *cx, uint32_ if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -67174,7 +64166,7 @@ bool js_cocos2dx_SpriteFrameCache_removeSpriteFramesFromTexture(JSContext *cx, u if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -67267,30 +64259,17 @@ void js_register_cocos2dx_SpriteFrameCache(JSContext *cx, JS::HandleObject globa jsb_cocos2d_SpriteFrameCache_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocos2d_SpriteFrameCache_class, empty_constructor, 0, properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "SpriteFrameCache", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_SpriteFrameCache_class; - p->proto = jsb_cocos2d_SpriteFrameCache_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_SpriteFrameCache_prototype); + jsb_register_class(cx, jsb_cocos2d_SpriteFrameCache_class, proto, JS::NullPtr()); } JSClass *jsb_cocos2d_TextFieldTTF_class; @@ -67359,7 +64338,7 @@ bool js_cocos2dx_TextFieldTTF_initWithPlaceHolder(JSContext *cx, uint32_t argc, JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::TextFieldTTF *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TextFieldTTF_initWithPlaceHolder : Invalid Native Object"); @@ -67417,7 +64396,7 @@ bool js_cocos2dx_TextFieldTTF_setColorSpaceHolder(JSContext *cx, uint32_t argc, JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::TextFieldTTF *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TextFieldTTF_setColorSpaceHolder : Invalid Native Object"); @@ -67619,8 +64598,8 @@ bool js_cocos2dx_TextFieldTTF_constructor(JSContext *cx, uint32_t argc, jsval *v CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -67690,32 +64669,20 @@ void js_register_cocos2dx_TextFieldTTF(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Label_prototype); jsb_cocos2d_TextFieldTTF_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Label_prototype), + parent_proto, jsb_cocos2d_TextFieldTTF_class, js_cocos2dx_TextFieldTTF_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "TextFieldTTF", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_TextFieldTTF_class; - p->proto = jsb_cocos2d_TextFieldTTF_prototype; - p->parentProto = jsb_cocos2d_Label_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_TextFieldTTF_prototype); + jsb_register_class(cx, jsb_cocos2d_TextFieldTTF_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.TextFieldTTF.extend = cc.Class.extend; })()"); } @@ -67729,7 +64696,7 @@ bool js_cocos2dx_ParallaxNode_getParallaxArray(JSContext *cx, uint32_t argc, jsv JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::ParallaxNode *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParallaxNode_getParallaxArray : Invalid Native Object"); @@ -67773,7 +64740,7 @@ bool js_cocos2dx_ParallaxNode_addChild(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -67868,8 +64835,8 @@ bool js_cocos2dx_ParallaxNode_constructor(JSContext *cx, uint32_t argc, jsval *v CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -67933,32 +64900,20 @@ void js_register_cocos2dx_ParallaxNode(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Node_prototype); jsb_cocos2d_ParallaxNode_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Node_prototype), + parent_proto, jsb_cocos2d_ParallaxNode_class, js_cocos2dx_ParallaxNode_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "ParallaxNode", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_ParallaxNode_class; - p->proto = jsb_cocos2d_ParallaxNode_prototype; - p->parentProto = jsb_cocos2d_Node_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ParallaxNode_prototype); + jsb_register_class(cx, jsb_cocos2d_ParallaxNode_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.ParallaxNode.extend = cc.Class.extend; })()"); } @@ -68054,7 +65009,7 @@ bool js_cocos2dx_TMXObjectGroup_getObjects(JSContext *cx, uint32_t argc, jsval * JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::TMXObjectGroup *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TMXObjectGroup_getObjects : Invalid Native Object"); @@ -68108,7 +65063,7 @@ bool js_cocos2dx_TMXObjectGroup_getProperties(JSContext *cx, uint32_t argc, jsva JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::TMXObjectGroup *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TMXObjectGroup_getProperties : Invalid Native Object"); @@ -68209,8 +65164,8 @@ bool js_cocos2dx_TMXObjectGroup_constructor(JSContext *cx, uint32_t argc, jsval CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -68260,30 +65215,17 @@ void js_register_cocos2dx_TMXObjectGroup(JSContext *cx, JS::HandleObject global) jsb_cocos2d_TMXObjectGroup_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocos2d_TMXObjectGroup_class, js_cocos2dx_TMXObjectGroup_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "TMXObjectGroup", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_TMXObjectGroup_class; - p->proto = jsb_cocos2d_TMXObjectGroup_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_TMXObjectGroup_prototype); + jsb_register_class(cx, jsb_cocos2d_TMXObjectGroup_class, proto, JS::NullPtr()); } JSClass *jsb_cocos2d_TMXLayerInfo_class; @@ -68343,8 +65285,8 @@ bool js_cocos2dx_TMXLayerInfo_constructor(JSContext *cx, uint32_t argc, jsval *v CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -68386,30 +65328,17 @@ void js_register_cocos2dx_TMXLayerInfo(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_TMXLayerInfo_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocos2d_TMXLayerInfo_class, js_cocos2dx_TMXLayerInfo_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "TMXLayerInfo", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_TMXLayerInfo_class; - p->proto = jsb_cocos2d_TMXLayerInfo_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_TMXLayerInfo_prototype); + jsb_register_class(cx, jsb_cocos2d_TMXLayerInfo_class, proto, JS::NullPtr()); } JSClass *jsb_cocos2d_TMXTilesetInfo_class; @@ -68453,8 +65382,8 @@ bool js_cocos2dx_TMXTilesetInfo_constructor(JSContext *cx, uint32_t argc, jsval CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -68495,30 +65424,17 @@ void js_register_cocos2dx_TMXTilesetInfo(JSContext *cx, JS::HandleObject global) jsb_cocos2d_TMXTilesetInfo_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocos2d_TMXTilesetInfo_class, js_cocos2dx_TMXTilesetInfo_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "TMXTilesetInfo", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_TMXTilesetInfo_class; - p->proto = jsb_cocos2d_TMXTilesetInfo_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_TMXTilesetInfo_prototype); + jsb_register_class(cx, jsb_cocos2d_TMXTilesetInfo_class, proto, JS::NullPtr()); } JSClass *jsb_cocos2d_TMXMapInfo_class; @@ -68731,7 +65647,7 @@ bool js_cocos2dx_TMXMapInfo_getLayers(JSContext *cx, uint32_t argc, jsval *vp) JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::TMXMapInfo *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TMXMapInfo_getLayers : Invalid Native Object"); @@ -68765,7 +65681,7 @@ bool js_cocos2dx_TMXMapInfo_getTilesets(JSContext *cx, uint32_t argc, jsval *vp) JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::TMXMapInfo *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TMXMapInfo_getTilesets : Invalid Native Object"); @@ -68935,7 +65851,7 @@ bool js_cocos2dx_TMXMapInfo_getObjectGroups(JSContext *cx, uint32_t argc, jsval JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::TMXMapInfo *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TMXMapInfo_getObjectGroups : Invalid Native Object"); @@ -69145,7 +66061,7 @@ bool js_cocos2dx_TMXMapInfo_getProperties(JSContext *cx, uint32_t argc, jsval *v JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::TMXMapInfo *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TMXMapInfo_getProperties : Invalid Native Object"); @@ -69278,8 +66194,8 @@ bool js_cocos2dx_TMXMapInfo_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -69372,30 +66288,17 @@ void js_register_cocos2dx_TMXMapInfo(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_TMXMapInfo_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocos2d_TMXMapInfo_class, js_cocos2dx_TMXMapInfo_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "TMXMapInfo", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_TMXMapInfo_class; - p->proto = jsb_cocos2d_TMXMapInfo_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_TMXMapInfo_prototype); + jsb_register_class(cx, jsb_cocos2d_TMXMapInfo_class, proto, JS::NullPtr()); anonEvaluate(cx, global, "(function () { cc.TMXMapInfo.extend = cc.Class.extend; })()"); } @@ -69647,7 +66550,7 @@ bool js_cocos2dx_TMXLayer_initWithTilesetInfo(JSContext *cx, uint32_t argc, jsva if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::TMXTilesetInfo*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -69656,7 +66559,7 @@ bool js_cocos2dx_TMXLayer_initWithTilesetInfo(JSContext *cx, uint32_t argc, jsva if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::TMXLayerInfo*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -69665,7 +66568,7 @@ bool js_cocos2dx_TMXLayer_initWithTilesetInfo(JSContext *cx, uint32_t argc, jsva if (args.get(2).isNull()) { arg2 = nullptr; break; } if (!args.get(2).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(2).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(2).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg2 = (cocos2d::TMXMapInfo*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg2, cx, false, "Invalid Native Object"); @@ -69704,7 +66607,7 @@ bool js_cocos2dx_TMXLayer_setTileGID(JSContext *cx, uint32_t argc, jsval *vp) JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::TMXLayer *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TMXLayer_setTileGID : Invalid Native Object"); @@ -69834,7 +66737,7 @@ bool js_cocos2dx_TMXLayer_setTileSet(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::TMXTilesetInfo*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -69880,7 +66783,7 @@ bool js_cocos2dx_TMXLayer_getProperties(JSContext *cx, uint32_t argc, jsval *vp) JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::TMXLayer *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TMXLayer_getProperties : Invalid Native Object"); @@ -69948,7 +66851,7 @@ bool js_cocos2dx_TMXLayer_create(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::TMXTilesetInfo*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -69957,7 +66860,7 @@ bool js_cocos2dx_TMXLayer_create(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::TMXLayerInfo*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -69966,7 +66869,7 @@ bool js_cocos2dx_TMXLayer_create(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(2).isNull()) { arg2 = nullptr; break; } if (!args.get(2).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(2).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(2).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg2 = (cocos2d::TMXMapInfo*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg2, cx, false, "Invalid Native Object"); @@ -70005,8 +66908,8 @@ bool js_cocos2dx_TMXLayer_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -70088,32 +66991,20 @@ void js_register_cocos2dx_TMXLayer(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_SpriteBatchNode_prototype); jsb_cocos2d_TMXLayer_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_SpriteBatchNode_prototype), + parent_proto, jsb_cocos2d_TMXLayer_class, js_cocos2dx_TMXLayer_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "TMXLayer", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_TMXLayer_class; - p->proto = jsb_cocos2d_TMXLayer_prototype; - p->parentProto = jsb_cocos2d_SpriteBatchNode_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_TMXLayer_prototype); + jsb_register_class(cx, jsb_cocos2d_TMXLayer_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.TMXLayer.extend = cc.Class.extend; })()"); } @@ -70218,7 +67109,7 @@ bool js_cocos2dx_TMXTiledMap_getObjectGroups(JSContext *cx, uint32_t argc, jsval JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::TMXTiledMap *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TMXTiledMap_getObjectGroups : Invalid Native Object"); @@ -70352,7 +67243,7 @@ bool js_cocos2dx_TMXTiledMap_getPropertiesForGID(JSContext *cx, uint32_t argc, j JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::TMXTiledMap *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TMXTiledMap_getPropertiesForGID : Invalid Native Object"); @@ -70366,7 +67257,7 @@ bool js_cocos2dx_TMXTiledMap_getPropertiesForGID(JSContext *cx, uint32_t argc, j if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Value**)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -70571,8 +67462,8 @@ bool js_cocos2dx_TMXTiledMap_constructor(JSContext *cx, uint32_t argc, jsval *vp CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -70649,32 +67540,20 @@ void js_register_cocos2dx_TMXTiledMap(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Node_prototype); jsb_cocos2d_TMXTiledMap_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Node_prototype), + parent_proto, jsb_cocos2d_TMXTiledMap_class, js_cocos2dx_TMXTiledMap_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "TMXTiledMap", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_TMXTiledMap_class; - p->proto = jsb_cocos2d_TMXTiledMap_prototype; - p->parentProto = jsb_cocos2d_Node_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_TMXTiledMap_prototype); + jsb_register_class(cx, jsb_cocos2d_TMXTiledMap_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.TMXTiledMap.extend = cc.Class.extend; })()"); } @@ -70855,8 +67734,8 @@ bool js_cocos2dx_TileMapAtlas_constructor(JSContext *cx, uint32_t argc, jsval *v CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -70922,32 +67801,20 @@ void js_register_cocos2dx_TileMapAtlas(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_AtlasNode_prototype); jsb_cocos2d_TileMapAtlas_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_AtlasNode_prototype), + parent_proto, jsb_cocos2d_TileMapAtlas_class, js_cocos2dx_TileMapAtlas_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "TileMapAtlas", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_TileMapAtlas_class; - p->proto = jsb_cocos2d_TileMapAtlas_prototype; - p->parentProto = jsb_cocos2d_AtlasNode_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_TileMapAtlas_prototype); + jsb_register_class(cx, jsb_cocos2d_TileMapAtlas_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.TileMapAtlas.extend = cc.Class.extend; })()"); } @@ -71507,30 +68374,17 @@ void js_register_cocos2dx_SimpleAudioEngine(JSContext *cx, JS::HandleObject glob jsb_CocosDenshion_SimpleAudioEngine_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_CocosDenshion_SimpleAudioEngine_class, empty_constructor, 0, properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "AudioEngine", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_CocosDenshion_SimpleAudioEngine_class; - p->proto = jsb_CocosDenshion_SimpleAudioEngine_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_CocosDenshion_SimpleAudioEngine_prototype); + jsb_register_class(cx, jsb_CocosDenshion_SimpleAudioEngine_class, proto, JS::NullPtr()); } JSClass *jsb_cocos2d_ComponentJS_class; @@ -71580,8 +68434,8 @@ bool js_cocos2dx_ComponentJS_constructor(JSContext *cx, uint32_t argc, jsval *vp CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -71645,32 +68499,20 @@ void js_register_cocos2dx_ComponentJS(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Component_prototype); jsb_cocos2d_ComponentJS_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Component_prototype), + parent_proto, jsb_cocos2d_ComponentJS_class, js_cocos2dx_ComponentJS_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "ComponentJS", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_ComponentJS_class; - p->proto = jsb_cocos2d_ComponentJS_prototype; - p->parentProto = jsb_cocos2d_Component_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ComponentJS_prototype); + jsb_register_class(cx, jsb_cocos2d_ComponentJS_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.ComponentJS.extend = cc.Class.extend; })()"); } diff --git a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_auto.hpp b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_auto.hpp index fc47a4ce20..1cc6ffe101 100644 --- a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_auto.hpp +++ b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_auto.hpp @@ -2427,6 +2427,7 @@ bool js_cocos2dx_MenuItem_initWithCallback(JSContext *cx, uint32_t argc, jsval * bool js_cocos2dx_MenuItem_isEnabled(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_MenuItem_selected(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_MenuItem_isSelected(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_MenuItem_setCallback(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_MenuItem_unselected(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_MenuItem_rect(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_MenuItem_MenuItem(JSContext *cx, uint32_t argc, jsval *vp); diff --git a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_builder_auto.cpp b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_builder_auto.cpp index d3440967a9..1b83ed43ec 100644 --- a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_builder_auto.cpp +++ b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_builder_auto.cpp @@ -19,8 +19,8 @@ static bool dummy_constructor(JSContext *cx, uint32_t argc, jsval *vp) { typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject _tmp(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(_tmp)); @@ -59,7 +59,7 @@ bool js_cocos2dx_builder_CCBAnimationManager_moveAnimationsFromNode(JSContext *c if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -68,7 +68,7 @@ bool js_cocos2dx_builder_CCBAnimationManager_moveAnimationsFromNode(JSContext *c if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -134,7 +134,7 @@ bool js_cocos2dx_builder_CCBAnimationManager_actionForSoundChannel(JSContext *cx if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocosbuilder::CCBSequenceProperty*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -174,7 +174,7 @@ bool js_cocos2dx_builder_CCBAnimationManager_setBaseValue(JSContext *cx, uint32_ if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -239,7 +239,7 @@ bool js_cocos2dx_builder_CCBAnimationManager_setRootNode(JSContext *cx, uint32_t if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -349,7 +349,7 @@ bool js_cocos2dx_builder_CCBAnimationManager_setObject(JSContext *cx, uint32_t a if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Ref*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -358,7 +358,7 @@ bool js_cocos2dx_builder_CCBAnimationManager_setObject(JSContext *cx, uint32_t a if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -387,7 +387,7 @@ bool js_cocos2dx_builder_CCBAnimationManager_getContainerSize(JSContext *cx, uin if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -417,7 +417,7 @@ bool js_cocos2dx_builder_CCBAnimationManager_actionForCallbackChannel(JSContext if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocosbuilder::CCBSequenceProperty*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -669,7 +669,7 @@ bool js_cocos2dx_builder_CCBAnimationManager_addDocumentOutletNode(JSContext *cx if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -697,7 +697,7 @@ bool js_cocos2dx_builder_CCBAnimationManager_setDelegate(JSContext *cx, uint32_t if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocosbuilder::CCBAnimationManagerDelegate*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -747,7 +747,7 @@ bool js_cocos2dx_builder_CCBAnimationManager_addDocumentCallbackNode(JSContext * if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -818,7 +818,7 @@ bool js_cocos2dx_builder_CCBAnimationManager_setCallFunc(JSContext *cx, uint32_t if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::CallFunc*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -921,8 +921,8 @@ bool js_cocos2dx_builder_CCBAnimationManager_constructor(JSContext *cx, uint32_t CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -999,30 +999,17 @@ void js_register_cocos2dx_builder_CCBAnimationManager(JSContext *cx, JS::HandleO jsb_cocosbuilder_CCBAnimationManager_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocosbuilder_CCBAnimationManager_class, js_cocos2dx_builder_CCBAnimationManager_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "BuilderAnimationManager", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocosbuilder_CCBAnimationManager_class; - p->proto = jsb_cocosbuilder_CCBAnimationManager_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocosbuilder_CCBAnimationManager_prototype); + jsb_register_class(cx, jsb_cocosbuilder_CCBAnimationManager_class, proto, JS::NullPtr()); } JSClass *jsb_cocosbuilder_CCBReader_class; @@ -1067,7 +1054,7 @@ bool js_cocos2dx_builder_CCBReader_setAnimationManager(JSContext *cx, uint32_t a if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocosbuilder::CCBAnimationManager*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -1173,7 +1160,7 @@ bool js_cocos2dx_builder_CCBReader_addOwnerOutletNode(JSContext *cx, uint32_t ar if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -1219,7 +1206,7 @@ bool js_cocos2dx_builder_CCBReader_readSoundKeyframesForSeq(JSContext *cx, uint3 if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocosbuilder::CCBSequence*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -1359,7 +1346,7 @@ bool js_cocos2dx_builder_CCBReader_readCallbackKeyframesForSeq(JSContext *cx, ui if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocosbuilder::CCBSequence*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -1441,7 +1428,7 @@ bool js_cocos2dx_builder_CCBReader_constructor(JSContext *cx, uint32_t argc, jsv if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocosbuilder::CCBReader*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -1461,8 +1448,8 @@ bool js_cocos2dx_builder_CCBReader_constructor(JSContext *cx, uint32_t argc, jsv typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); // obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); obj = JS_NewObject(cx, typeClass->jsclass, proto, parent); js_proxy_t* p = jsb_new_proxy(cobj, obj); @@ -1477,7 +1464,7 @@ bool js_cocos2dx_builder_CCBReader_constructor(JSContext *cx, uint32_t argc, jsv if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocosbuilder::NodeLoaderLibrary*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -1497,8 +1484,8 @@ bool js_cocos2dx_builder_CCBReader_constructor(JSContext *cx, uint32_t argc, jsv typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); // obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); obj = JS_NewObject(cx, typeClass->jsclass, proto, parent); js_proxy_t* p = jsb_new_proxy(cobj, obj); @@ -1513,7 +1500,7 @@ bool js_cocos2dx_builder_CCBReader_constructor(JSContext *cx, uint32_t argc, jsv if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocosbuilder::NodeLoaderLibrary*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -1524,7 +1511,7 @@ bool js_cocos2dx_builder_CCBReader_constructor(JSContext *cx, uint32_t argc, jsv if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocosbuilder::CCBMemberVariableAssigner*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -1544,8 +1531,8 @@ bool js_cocos2dx_builder_CCBReader_constructor(JSContext *cx, uint32_t argc, jsv typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); // obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); obj = JS_NewObject(cx, typeClass->jsclass, proto, parent); js_proxy_t* p = jsb_new_proxy(cobj, obj); @@ -1560,7 +1547,7 @@ bool js_cocos2dx_builder_CCBReader_constructor(JSContext *cx, uint32_t argc, jsv if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocosbuilder::NodeLoaderLibrary*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -1571,7 +1558,7 @@ bool js_cocos2dx_builder_CCBReader_constructor(JSContext *cx, uint32_t argc, jsv if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocosbuilder::CCBMemberVariableAssigner*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -1582,7 +1569,7 @@ bool js_cocos2dx_builder_CCBReader_constructor(JSContext *cx, uint32_t argc, jsv if (args.get(2).isNull()) { arg2 = nullptr; break; } if (!args.get(2).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(2).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(2).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg2 = (cocosbuilder::CCBSelectorResolver*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg2, cx, false, "Invalid Native Object"); @@ -1602,8 +1589,8 @@ bool js_cocos2dx_builder_CCBReader_constructor(JSContext *cx, uint32_t argc, jsv typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); // obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); obj = JS_NewObject(cx, typeClass->jsclass, proto, parent); js_proxy_t* p = jsb_new_proxy(cobj, obj); @@ -1618,7 +1605,7 @@ bool js_cocos2dx_builder_CCBReader_constructor(JSContext *cx, uint32_t argc, jsv if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocosbuilder::NodeLoaderLibrary*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -1629,7 +1616,7 @@ bool js_cocos2dx_builder_CCBReader_constructor(JSContext *cx, uint32_t argc, jsv if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocosbuilder::CCBMemberVariableAssigner*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -1640,7 +1627,7 @@ bool js_cocos2dx_builder_CCBReader_constructor(JSContext *cx, uint32_t argc, jsv if (args.get(2).isNull()) { arg2 = nullptr; break; } if (!args.get(2).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(2).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(2).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg2 = (cocosbuilder::CCBSelectorResolver*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg2, cx, false, "Invalid Native Object"); @@ -1651,7 +1638,7 @@ bool js_cocos2dx_builder_CCBReader_constructor(JSContext *cx, uint32_t argc, jsv if (args.get(3).isNull()) { arg3 = nullptr; break; } if (!args.get(3).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(3).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(3).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg3 = (cocosbuilder::NodeLoaderListener*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg3, cx, false, "Invalid Native Object"); @@ -1671,8 +1658,8 @@ bool js_cocos2dx_builder_CCBReader_constructor(JSContext *cx, uint32_t argc, jsv typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); // obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); obj = JS_NewObject(cx, typeClass->jsclass, proto, parent); js_proxy_t* p = jsb_new_proxy(cobj, obj); @@ -1696,8 +1683,8 @@ bool js_cocos2dx_builder_CCBReader_constructor(JSContext *cx, uint32_t argc, jsv typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); // obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); obj = JS_NewObject(cx, typeClass->jsclass, proto, parent); js_proxy_t* p = jsb_new_proxy(cobj, obj); @@ -1767,30 +1754,17 @@ void js_register_cocos2dx_builder_CCBReader(JSContext *cx, JS::HandleObject glob jsb_cocosbuilder_CCBReader_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocosbuilder_CCBReader_class, js_cocos2dx_builder_CCBReader_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "_Reader", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocosbuilder_CCBReader_class; - p->proto = jsb_cocosbuilder_CCBReader_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocosbuilder_CCBReader_prototype); + jsb_register_class(cx, jsb_cocosbuilder_CCBReader_class, proto, JS::NullPtr()); } void register_all_cocos2dx_builder(JSContext* cx, JS::HandleObject obj) { diff --git a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_experimental_video_auto.cpp b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_experimental_video_auto.cpp index 7ba5c234e2..d3ef2d7f9f 100644 --- a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_experimental_video_auto.cpp +++ b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_experimental_video_auto.cpp @@ -20,8 +20,8 @@ static bool dummy_constructor(JSContext *cx, uint32_t argc, jsval *vp) { typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject _tmp(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(_tmp)); @@ -324,8 +324,8 @@ bool js_cocos2dx_experimental_video_VideoPlayer_constructor(JSContext *cx, uint3 CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -381,32 +381,20 @@ void js_register_cocos2dx_experimental_video_VideoPlayer(JSContext *cx, JS::Hand JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ui_Widget_prototype); jsb_cocos2d_experimental_ui_VideoPlayer_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ui_Widget_prototype), + parent_proto, jsb_cocos2d_experimental_ui_VideoPlayer_class, js_cocos2dx_experimental_video_VideoPlayer_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "VideoPlayer", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_experimental_ui_VideoPlayer_class; - p->proto = jsb_cocos2d_experimental_ui_VideoPlayer_prototype; - p->parentProto = jsb_cocos2d_ui_Widget_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_experimental_ui_VideoPlayer_prototype); + jsb_register_class(cx, jsb_cocos2d_experimental_ui_VideoPlayer_class, proto, parent_proto); } void register_all_cocos2dx_experimental_video(JSContext* cx, JS::HandleObject obj) { diff --git a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_experimental_webView_auto.cpp b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_experimental_webView_auto.cpp index 81776d11e5..1b0d37bddd 100644 --- a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_experimental_webView_auto.cpp +++ b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_experimental_webView_auto.cpp @@ -20,8 +20,8 @@ static bool dummy_constructor(JSContext *cx, uint32_t argc, jsval *vp) { typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject _tmp(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(_tmp)); @@ -384,8 +384,8 @@ bool js_cocos2dx_experimental_webView_WebView_constructor(JSContext *cx, uint32_ CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -444,32 +444,20 @@ void js_register_cocos2dx_experimental_webView_WebView(JSContext *cx, JS::Handle JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ui_Widget_prototype); jsb_cocos2d_experimental_ui_WebView_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ui_Widget_prototype), + parent_proto, jsb_cocos2d_experimental_ui_WebView_class, js_cocos2dx_experimental_webView_WebView_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "WebView", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_experimental_ui_WebView_class; - p->proto = jsb_cocos2d_experimental_ui_WebView_prototype; - p->parentProto = jsb_cocos2d_ui_Widget_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_experimental_ui_WebView_prototype); + jsb_register_class(cx, jsb_cocos2d_experimental_ui_WebView_class, proto, parent_proto); } void register_all_cocos2dx_experimental_webView(JSContext* cx, JS::HandleObject obj) { diff --git a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_extension_auto.cpp b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_extension_auto.cpp index 266d9d67bf..aef3313aa0 100644 --- a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_extension_auto.cpp +++ b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_extension_auto.cpp @@ -19,8 +19,8 @@ static bool dummy_constructor(JSContext *cx, uint32_t argc, jsval *vp) { typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject _tmp(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(_tmp)); @@ -206,7 +206,7 @@ bool js_cocos2dx_extension_Control_isTouchInside(JSContext *cx, uint32_t argc, j if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Touch*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -256,7 +256,7 @@ bool js_cocos2dx_extension_Control_getTouchLocation(JSContext *cx, uint32_t argc if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Touch*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -327,8 +327,8 @@ bool js_cocos2dx_extension_Control_constructor(JSContext *cx, uint32_t argc, jsv CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -383,32 +383,20 @@ void js_register_cocos2dx_extension_Control(JSContext *cx, JS::HandleObject glob JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Layer_prototype); jsb_cocos2d_extension_Control_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Layer_prototype), + parent_proto, jsb_cocos2d_extension_Control_class, js_cocos2dx_extension_Control_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "Control", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_extension_Control_class; - p->proto = jsb_cocos2d_extension_Control_prototype; - p->parentProto = jsb_cocos2d_Layer_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_extension_Control_prototype); + jsb_register_class(cx, jsb_cocos2d_extension_Control_class, proto, parent_proto); } JSClass *jsb_cocos2d_extension_ControlButton_class; @@ -447,7 +435,7 @@ bool js_cocos2dx_extension_ControlButton_setTitleLabelForState(JSContext *cx, ui if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -556,7 +544,7 @@ bool js_cocos2dx_extension_ControlButton_initWithBackgroundSprite(JSContext *cx, if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ui::Scale9Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -652,7 +640,7 @@ bool js_cocos2dx_extension_ControlButton_setTitleLabel(JSContext *cx, uint32_t a if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -738,7 +726,7 @@ bool js_cocos2dx_extension_ControlButton_setBackgroundSprite(JSContext *cx, uint if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ui::Scale9Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -989,7 +977,7 @@ bool js_cocos2dx_extension_ControlButton_setBackgroundSpriteFrameForState(JSCont if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::SpriteFrame*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -1019,7 +1007,7 @@ bool js_cocos2dx_extension_ControlButton_setBackgroundSpriteForState(JSContext * if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ui::Scale9Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -1195,7 +1183,7 @@ bool js_cocos2dx_extension_ControlButton_getCurrentTitle(JSContext *cx, uint32_t JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::extension::ControlButton *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ControlButton_getCurrentTitle : Invalid Native Object"); @@ -1237,7 +1225,7 @@ bool js_cocos2dx_extension_ControlButton_initWithLabelAndBackgroundSprite(JSCont if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -1246,7 +1234,7 @@ bool js_cocos2dx_extension_ControlButton_initWithLabelAndBackgroundSprite(JSCont if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::ui::Scale9Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -1314,7 +1302,7 @@ bool js_cocos2dx_extension_ControlButton_create(JSContext *cx, uint32_t argc, js if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ui::Scale9Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -1359,7 +1347,7 @@ bool js_cocos2dx_extension_ControlButton_create(JSContext *cx, uint32_t argc, js if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -1370,7 +1358,7 @@ bool js_cocos2dx_extension_ControlButton_create(JSContext *cx, uint32_t argc, js if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::ui::Scale9Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -1435,8 +1423,8 @@ bool js_cocos2dx_extension_ControlButton_constructor(JSContext *cx, uint32_t arg CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -1534,32 +1522,20 @@ void js_register_cocos2dx_extension_ControlButton(JSContext *cx, JS::HandleObjec JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_extension_Control_prototype); jsb_cocos2d_extension_ControlButton_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_extension_Control_prototype), + parent_proto, jsb_cocos2d_extension_ControlButton_class, js_cocos2dx_extension_ControlButton_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "ControlButton", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_extension_ControlButton_class; - p->proto = jsb_cocos2d_extension_ControlButton_prototype; - p->parentProto = jsb_cocos2d_extension_Control_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_extension_ControlButton_prototype); + jsb_register_class(cx, jsb_cocos2d_extension_ControlButton_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.ControlButton.extend = cc.Class.extend; })()"); } @@ -1581,7 +1557,7 @@ bool js_cocos2dx_extension_ControlHuePicker_initWithTargetAndPos(JSContext *cx, if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -1693,7 +1669,7 @@ bool js_cocos2dx_extension_ControlHuePicker_setBackground(JSContext *cx, uint32_ if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -1784,7 +1760,7 @@ bool js_cocos2dx_extension_ControlHuePicker_setSlider(JSContext *cx, uint32_t ar if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -1809,7 +1785,7 @@ bool js_cocos2dx_extension_ControlHuePicker_create(JSContext *cx, uint32_t argc, if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -1849,8 +1825,8 @@ bool js_cocos2dx_extension_ControlHuePicker_constructor(JSContext *cx, uint32_t CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -1903,32 +1879,20 @@ void js_register_cocos2dx_extension_ControlHuePicker(JSContext *cx, JS::HandleOb JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_extension_Control_prototype); jsb_cocos2d_extension_ControlHuePicker_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_extension_Control_prototype), + parent_proto, jsb_cocos2d_extension_ControlHuePicker_class, js_cocos2dx_extension_ControlHuePicker_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "ControlHuePicker", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_extension_ControlHuePicker_class; - p->proto = jsb_cocos2d_extension_ControlHuePicker_prototype; - p->parentProto = jsb_cocos2d_extension_Control_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_extension_ControlHuePicker_prototype); + jsb_register_class(cx, jsb_cocos2d_extension_ControlHuePicker_class, proto, parent_proto); } JSClass *jsb_cocos2d_extension_ControlSaturationBrightnessPicker_class; @@ -1974,7 +1938,7 @@ bool js_cocos2dx_extension_ControlSaturationBrightnessPicker_initWithTargetAndPo if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -2131,7 +2095,7 @@ bool js_cocos2dx_extension_ControlSaturationBrightnessPicker_create(JSContext *c if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -2171,8 +2135,8 @@ bool js_cocos2dx_extension_ControlSaturationBrightnessPicker_constructor(JSConte CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -2223,32 +2187,20 @@ void js_register_cocos2dx_extension_ControlSaturationBrightnessPicker(JSContext JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_extension_Control_prototype); jsb_cocos2d_extension_ControlSaturationBrightnessPicker_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_extension_Control_prototype), + parent_proto, jsb_cocos2d_extension_ControlSaturationBrightnessPicker_class, js_cocos2dx_extension_ControlSaturationBrightnessPicker_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "ControlSaturationBrightnessPicker", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_extension_ControlSaturationBrightnessPicker_class; - p->proto = jsb_cocos2d_extension_ControlSaturationBrightnessPicker_prototype; - p->parentProto = jsb_cocos2d_extension_Control_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_extension_ControlSaturationBrightnessPicker_prototype); + jsb_register_class(cx, jsb_cocos2d_extension_ControlSaturationBrightnessPicker_class, proto, parent_proto); } JSClass *jsb_cocos2d_extension_ControlColourPicker_class; @@ -2269,7 +2221,7 @@ bool js_cocos2dx_extension_ControlColourPicker_hueSliderValueChanged(JSContext * if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Ref*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -2348,7 +2300,7 @@ bool js_cocos2dx_extension_ControlColourPicker_setBackground(JSContext *cx, uint if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -2376,7 +2328,7 @@ bool js_cocos2dx_extension_ControlColourPicker_setcolourPicker(JSContext *cx, ui if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::extension::ControlSaturationBrightnessPicker*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -2405,7 +2357,7 @@ bool js_cocos2dx_extension_ControlColourPicker_colourSliderValueChanged(JSContex if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Ref*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -2434,7 +2386,7 @@ bool js_cocos2dx_extension_ControlColourPicker_setHuePicker(JSContext *cx, uint3 if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::extension::ControlHuePicker*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -2510,8 +2462,8 @@ bool js_cocos2dx_extension_ControlColourPicker_constructor(JSContext *cx, uint32 CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -2579,32 +2531,20 @@ void js_register_cocos2dx_extension_ControlColourPicker(JSContext *cx, JS::Handl JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_extension_Control_prototype); jsb_cocos2d_extension_ControlColourPicker_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_extension_Control_prototype), + parent_proto, jsb_cocos2d_extension_ControlColourPicker_class, js_cocos2dx_extension_ControlColourPicker_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "ControlColourPicker", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_extension_ControlColourPicker_class; - p->proto = jsb_cocos2d_extension_ControlColourPicker_prototype; - p->parentProto = jsb_cocos2d_extension_Control_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_extension_ControlColourPicker_prototype); + jsb_register_class(cx, jsb_cocos2d_extension_ControlColourPicker_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.ControlColourPicker.extend = cc.Class.extend; })()"); } @@ -2794,7 +2734,7 @@ bool js_cocos2dx_extension_ControlPotentiometer_setThumbSprite(JSContext *cx, ui if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -2902,7 +2842,7 @@ bool js_cocos2dx_extension_ControlPotentiometer_setProgressTimer(JSContext *cx, if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ProgressTimer*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -2977,7 +2917,7 @@ bool js_cocos2dx_extension_ControlPotentiometer_initWithTrackSprite_ProgressTime if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -2986,7 +2926,7 @@ bool js_cocos2dx_extension_ControlPotentiometer_initWithTrackSprite_ProgressTime if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::ProgressTimer*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -2995,7 +2935,7 @@ bool js_cocos2dx_extension_ControlPotentiometer_initWithTrackSprite_ProgressTime if (args.get(2).isNull()) { arg2 = nullptr; break; } if (!args.get(2).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(2).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(2).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg2 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg2, cx, false, "Invalid Native Object"); @@ -3076,8 +3016,8 @@ bool js_cocos2dx_extension_ControlPotentiometer_constructor(JSContext *cx, uint3 CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -3155,32 +3095,20 @@ void js_register_cocos2dx_extension_ControlPotentiometer(JSContext *cx, JS::Hand JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_extension_Control_prototype); jsb_cocos2d_extension_ControlPotentiometer_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_extension_Control_prototype), + parent_proto, jsb_cocos2d_extension_ControlPotentiometer_class, js_cocos2dx_extension_ControlPotentiometer_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "ControlPotentiometer", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_extension_ControlPotentiometer_class; - p->proto = jsb_cocos2d_extension_ControlPotentiometer_prototype; - p->parentProto = jsb_cocos2d_extension_Control_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_extension_ControlPotentiometer_prototype); + jsb_register_class(cx, jsb_cocos2d_extension_ControlPotentiometer_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.ControlPotentiometer.extend = cc.Class.extend; })()"); } @@ -3201,7 +3129,7 @@ bool js_cocos2dx_extension_ControlSlider_setBackgroundSprite(JSContext *cx, uint if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -3240,7 +3168,7 @@ bool js_cocos2dx_extension_ControlSlider_initWithSprites(JSContext *cx, uint32_t JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::extension::ControlSlider *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ControlSlider_initWithSprites : Invalid Native Object"); @@ -3251,7 +3179,7 @@ bool js_cocos2dx_extension_ControlSlider_initWithSprites(JSContext *cx, uint32_t if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -3262,7 +3190,7 @@ bool js_cocos2dx_extension_ControlSlider_initWithSprites(JSContext *cx, uint32_t if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -3273,7 +3201,7 @@ bool js_cocos2dx_extension_ControlSlider_initWithSprites(JSContext *cx, uint32_t if (args.get(2).isNull()) { arg2 = nullptr; break; } if (!args.get(2).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(2).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(2).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg2 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg2, cx, false, "Invalid Native Object"); @@ -3284,7 +3212,7 @@ bool js_cocos2dx_extension_ControlSlider_initWithSprites(JSContext *cx, uint32_t if (args.get(3).isNull()) { arg3 = nullptr; break; } if (!args.get(3).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(3).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(3).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg3 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg3, cx, false, "Invalid Native Object"); @@ -3305,7 +3233,7 @@ bool js_cocos2dx_extension_ControlSlider_initWithSprites(JSContext *cx, uint32_t if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -3316,7 +3244,7 @@ bool js_cocos2dx_extension_ControlSlider_initWithSprites(JSContext *cx, uint32_t if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -3327,7 +3255,7 @@ bool js_cocos2dx_extension_ControlSlider_initWithSprites(JSContext *cx, uint32_t if (args.get(2).isNull()) { arg2 = nullptr; break; } if (!args.get(2).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(2).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(2).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg2 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg2, cx, false, "Invalid Native Object"); @@ -3419,7 +3347,7 @@ bool js_cocos2dx_extension_ControlSlider_setProgressSprite(JSContext *cx, uint32 if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -3485,7 +3413,7 @@ bool js_cocos2dx_extension_ControlSlider_setThumbSprite(JSContext *cx, uint32_t if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -3601,7 +3529,7 @@ bool js_cocos2dx_extension_ControlSlider_locationFromTouch(JSContext *cx, uint32 if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Touch*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -3696,7 +3624,7 @@ bool js_cocos2dx_extension_ControlSlider_setSelectedThumbSprite(JSContext *cx, u if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -3742,7 +3670,7 @@ bool js_cocos2dx_extension_ControlSlider_create(JSContext *cx, uint32_t argc, js if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -3753,7 +3681,7 @@ bool js_cocos2dx_extension_ControlSlider_create(JSContext *cx, uint32_t argc, js if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -3764,7 +3692,7 @@ bool js_cocos2dx_extension_ControlSlider_create(JSContext *cx, uint32_t argc, js if (args.get(2).isNull()) { arg2 = nullptr; break; } if (!args.get(2).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(2).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(2).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg2 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg2, cx, false, "Invalid Native Object"); @@ -3847,7 +3775,7 @@ bool js_cocos2dx_extension_ControlSlider_create(JSContext *cx, uint32_t argc, js if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -3858,7 +3786,7 @@ bool js_cocos2dx_extension_ControlSlider_create(JSContext *cx, uint32_t argc, js if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -3869,7 +3797,7 @@ bool js_cocos2dx_extension_ControlSlider_create(JSContext *cx, uint32_t argc, js if (args.get(2).isNull()) { arg2 = nullptr; break; } if (!args.get(2).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(2).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(2).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg2 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg2, cx, false, "Invalid Native Object"); @@ -3880,7 +3808,7 @@ bool js_cocos2dx_extension_ControlSlider_create(JSContext *cx, uint32_t argc, js if (args.get(3).isNull()) { arg3 = nullptr; break; } if (!args.get(3).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(3).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(3).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg3 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg3, cx, false, "Invalid Native Object"); @@ -3919,8 +3847,8 @@ bool js_cocos2dx_extension_ControlSlider_constructor(JSContext *cx, uint32_t arg CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -4000,32 +3928,20 @@ void js_register_cocos2dx_extension_ControlSlider(JSContext *cx, JS::HandleObjec JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_extension_Control_prototype); jsb_cocos2d_extension_ControlSlider_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_extension_Control_prototype), + parent_proto, jsb_cocos2d_extension_ControlSlider_class, js_cocos2dx_extension_ControlSlider_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "ControlSlider", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_extension_ControlSlider_class; - p->proto = jsb_cocos2d_extension_ControlSlider_prototype; - p->parentProto = jsb_cocos2d_extension_Control_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_extension_ControlSlider_prototype); + jsb_register_class(cx, jsb_cocos2d_extension_ControlSlider_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.ControlSlider.extend = cc.Class.extend; })()"); } @@ -4112,7 +4028,7 @@ bool js_cocos2dx_extension_ControlStepper_initWithMinusSpriteAndPlusSprite(JSCon if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -4121,7 +4037,7 @@ bool js_cocos2dx_extension_ControlStepper_initWithMinusSpriteAndPlusSprite(JSCon if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -4263,7 +4179,7 @@ bool js_cocos2dx_extension_ControlStepper_setMinusLabel(JSContext *cx, uint32_t if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Label*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -4381,7 +4297,7 @@ bool js_cocos2dx_extension_ControlStepper_setPlusLabel(JSContext *cx, uint32_t a if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Label*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -4452,7 +4368,7 @@ bool js_cocos2dx_extension_ControlStepper_setPlusSprite(JSContext *cx, uint32_t if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -4480,7 +4396,7 @@ bool js_cocos2dx_extension_ControlStepper_setMinusSprite(JSContext *cx, uint32_t if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -4505,7 +4421,7 @@ bool js_cocos2dx_extension_ControlStepper_create(JSContext *cx, uint32_t argc, j if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -4514,7 +4430,7 @@ bool js_cocos2dx_extension_ControlStepper_create(JSContext *cx, uint32_t argc, j if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -4553,8 +4469,8 @@ bool js_cocos2dx_extension_ControlStepper_constructor(JSContext *cx, uint32_t ar CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -4634,32 +4550,20 @@ void js_register_cocos2dx_extension_ControlStepper(JSContext *cx, JS::HandleObje JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_extension_Control_prototype); jsb_cocos2d_extension_ControlStepper_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_extension_Control_prototype), + parent_proto, jsb_cocos2d_extension_ControlStepper_class, js_cocos2dx_extension_ControlStepper_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "ControlStepper", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_extension_ControlStepper_class; - p->proto = jsb_cocos2d_extension_ControlStepper_prototype; - p->parentProto = jsb_cocos2d_extension_Control_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_extension_ControlStepper_prototype); + jsb_register_class(cx, jsb_cocos2d_extension_ControlStepper_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.ControlStepper.extend = cc.Class.extend; })()"); } @@ -4673,7 +4577,7 @@ bool js_cocos2dx_extension_ControlSwitch_setOn(JSContext *cx, uint32_t argc, jsv JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::extension::ControlSwitch *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ControlSwitch_setOn : Invalid Native Object"); @@ -4716,7 +4620,7 @@ bool js_cocos2dx_extension_ControlSwitch_locationFromTouch(JSContext *cx, uint32 if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Touch*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -4757,7 +4661,7 @@ bool js_cocos2dx_extension_ControlSwitch_initWithMaskSprite(JSContext *cx, uint3 JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::extension::ControlSwitch *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ControlSwitch_initWithMaskSprite : Invalid Native Object"); @@ -4768,7 +4672,7 @@ bool js_cocos2dx_extension_ControlSwitch_initWithMaskSprite(JSContext *cx, uint3 if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -4779,7 +4683,7 @@ bool js_cocos2dx_extension_ControlSwitch_initWithMaskSprite(JSContext *cx, uint3 if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -4790,7 +4694,7 @@ bool js_cocos2dx_extension_ControlSwitch_initWithMaskSprite(JSContext *cx, uint3 if (args.get(2).isNull()) { arg2 = nullptr; break; } if (!args.get(2).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(2).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(2).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg2 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg2, cx, false, "Invalid Native Object"); @@ -4801,7 +4705,7 @@ bool js_cocos2dx_extension_ControlSwitch_initWithMaskSprite(JSContext *cx, uint3 if (args.get(3).isNull()) { arg3 = nullptr; break; } if (!args.get(3).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(3).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(3).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg3 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg3, cx, false, "Invalid Native Object"); @@ -4812,7 +4716,7 @@ bool js_cocos2dx_extension_ControlSwitch_initWithMaskSprite(JSContext *cx, uint3 if (args.get(4).isNull()) { arg4 = nullptr; break; } if (!args.get(4).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(4).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(4).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg4 = (cocos2d::Label*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg4, cx, false, "Invalid Native Object"); @@ -4823,7 +4727,7 @@ bool js_cocos2dx_extension_ControlSwitch_initWithMaskSprite(JSContext *cx, uint3 if (args.get(5).isNull()) { arg5 = nullptr; break; } if (!args.get(5).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(5).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(5).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg5 = (cocos2d::Label*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg5, cx, false, "Invalid Native Object"); @@ -4844,7 +4748,7 @@ bool js_cocos2dx_extension_ControlSwitch_initWithMaskSprite(JSContext *cx, uint3 if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -4855,7 +4759,7 @@ bool js_cocos2dx_extension_ControlSwitch_initWithMaskSprite(JSContext *cx, uint3 if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -4866,7 +4770,7 @@ bool js_cocos2dx_extension_ControlSwitch_initWithMaskSprite(JSContext *cx, uint3 if (args.get(2).isNull()) { arg2 = nullptr; break; } if (!args.get(2).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(2).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(2).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg2 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg2, cx, false, "Invalid Native Object"); @@ -4877,7 +4781,7 @@ bool js_cocos2dx_extension_ControlSwitch_initWithMaskSprite(JSContext *cx, uint3 if (args.get(3).isNull()) { arg3 = nullptr; break; } if (!args.get(3).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(3).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(3).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg3 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg3, cx, false, "Invalid Native Object"); @@ -4924,7 +4828,7 @@ bool js_cocos2dx_extension_ControlSwitch_create(JSContext *cx, uint32_t argc, js if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -4935,7 +4839,7 @@ bool js_cocos2dx_extension_ControlSwitch_create(JSContext *cx, uint32_t argc, js if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -4946,7 +4850,7 @@ bool js_cocos2dx_extension_ControlSwitch_create(JSContext *cx, uint32_t argc, js if (args.get(2).isNull()) { arg2 = nullptr; break; } if (!args.get(2).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(2).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(2).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg2 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg2, cx, false, "Invalid Native Object"); @@ -4957,7 +4861,7 @@ bool js_cocos2dx_extension_ControlSwitch_create(JSContext *cx, uint32_t argc, js if (args.get(3).isNull()) { arg3 = nullptr; break; } if (!args.get(3).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(3).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(3).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg3 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg3, cx, false, "Invalid Native Object"); @@ -4985,7 +4889,7 @@ bool js_cocos2dx_extension_ControlSwitch_create(JSContext *cx, uint32_t argc, js if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -4996,7 +4900,7 @@ bool js_cocos2dx_extension_ControlSwitch_create(JSContext *cx, uint32_t argc, js if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -5007,7 +4911,7 @@ bool js_cocos2dx_extension_ControlSwitch_create(JSContext *cx, uint32_t argc, js if (args.get(2).isNull()) { arg2 = nullptr; break; } if (!args.get(2).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(2).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(2).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg2 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg2, cx, false, "Invalid Native Object"); @@ -5018,7 +4922,7 @@ bool js_cocos2dx_extension_ControlSwitch_create(JSContext *cx, uint32_t argc, js if (args.get(3).isNull()) { arg3 = nullptr; break; } if (!args.get(3).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(3).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(3).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg3 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg3, cx, false, "Invalid Native Object"); @@ -5029,7 +4933,7 @@ bool js_cocos2dx_extension_ControlSwitch_create(JSContext *cx, uint32_t argc, js if (args.get(4).isNull()) { arg4 = nullptr; break; } if (!args.get(4).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(4).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(4).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg4 = (cocos2d::Label*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg4, cx, false, "Invalid Native Object"); @@ -5040,7 +4944,7 @@ bool js_cocos2dx_extension_ControlSwitch_create(JSContext *cx, uint32_t argc, js if (args.get(5).isNull()) { arg5 = nullptr; break; } if (!args.get(5).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(5).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(5).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg5 = (cocos2d::Label*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg5, cx, false, "Invalid Native Object"); @@ -5079,8 +4983,8 @@ bool js_cocos2dx_extension_ControlSwitch_constructor(JSContext *cx, uint32_t arg CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -5145,32 +5049,20 @@ void js_register_cocos2dx_extension_ControlSwitch(JSContext *cx, JS::HandleObjec JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_extension_Control_prototype); jsb_cocos2d_extension_ControlSwitch_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_extension_Control_prototype), + parent_proto, jsb_cocos2d_extension_ControlSwitch_class, js_cocos2dx_extension_ControlSwitch_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "ControlSwitch", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_extension_ControlSwitch_class; - p->proto = jsb_cocos2d_extension_ControlSwitch_prototype; - p->parentProto = jsb_cocos2d_extension_Control_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_extension_ControlSwitch_prototype); + jsb_register_class(cx, jsb_cocos2d_extension_ControlSwitch_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.ControlSwitch.extend = cc.Class.extend; })()"); } @@ -5209,7 +5101,7 @@ bool js_cocos2dx_extension_ScrollView_setContainer(JSContext *cx, uint32_t argc, if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -5450,7 +5342,7 @@ bool js_cocos2dx_extension_ScrollView_initWithViewSize(JSContext *cx, uint32_t a if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -5480,7 +5372,7 @@ bool js_cocos2dx_extension_ScrollView_pause(JSContext *cx, uint32_t argc, jsval if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Ref*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -5670,7 +5562,7 @@ bool js_cocos2dx_extension_ScrollView_resume(JSContext *cx, uint32_t argc, jsval if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Ref*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -5792,7 +5684,7 @@ bool js_cocos2dx_extension_ScrollView_isNodeVisible(JSContext *cx, uint32_t argc if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -5833,7 +5725,7 @@ bool js_cocos2dx_extension_ScrollView_setZoomScale(JSContext *cx, uint32_t argc, JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::extension::ScrollView *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ScrollView_setZoomScale : Invalid Native Object"); @@ -5915,7 +5807,7 @@ bool js_cocos2dx_extension_ScrollView_create(JSContext *cx, uint32_t argc, jsval if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -5954,8 +5846,8 @@ bool js_cocos2dx_extension_ScrollView_constructor(JSContext *cx, uint32_t argc, CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -6046,32 +5938,20 @@ void js_register_cocos2dx_extension_ScrollView(JSContext *cx, JS::HandleObject g JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Layer_prototype); jsb_cocos2d_extension_ScrollView_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Layer_prototype), + parent_proto, jsb_cocos2d_extension_ScrollView_class, js_cocos2dx_extension_ScrollView_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "ScrollView", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_extension_ScrollView_class; - p->proto = jsb_cocos2d_extension_ScrollView_prototype; - p->parentProto = jsb_cocos2d_Layer_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_extension_ScrollView_prototype); + jsb_register_class(cx, jsb_cocos2d_extension_ScrollView_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.ScrollView.extend = cc.Class.extend; })()"); } @@ -6169,8 +6049,8 @@ bool js_cocos2dx_extension_TableViewCell_constructor(JSContext *cx, uint32_t arg CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -6233,32 +6113,20 @@ void js_register_cocos2dx_extension_TableViewCell(JSContext *cx, JS::HandleObjec JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Node_prototype); jsb_cocos2d_extension_TableViewCell_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Node_prototype), + parent_proto, jsb_cocos2d_extension_TableViewCell_class, js_cocos2dx_extension_TableViewCell_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "TableViewCell", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_extension_TableViewCell_class; - p->proto = jsb_cocos2d_extension_TableViewCell_prototype; - p->parentProto = jsb_cocos2d_Node_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_extension_TableViewCell_prototype); + jsb_register_class(cx, jsb_cocos2d_extension_TableViewCell_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.TableViewCell.extend = cc.Class.extend; })()"); } @@ -6319,7 +6187,7 @@ bool js_cocos2dx_extension_TableView_scrollViewDidZoom(JSContext *cx, uint32_t a if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::extension::ScrollView*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -6413,7 +6281,7 @@ bool js_cocos2dx_extension_TableView_initWithViewSize(JSContext *cx, uint32_t ar if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -6443,7 +6311,7 @@ bool js_cocos2dx_extension_TableView_scrollViewDidScroll(JSContext *cx, uint32_t if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::extension::ScrollView*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -6563,8 +6431,8 @@ bool js_cocos2dx_extension_TableView_constructor(JSContext *cx, uint32_t argc, j CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -6633,32 +6501,20 @@ void js_register_cocos2dx_extension_TableView(JSContext *cx, JS::HandleObject gl JSFunctionSpec *st_funcs = NULL; + JS::RootedObject parent_proto(cx, jsb_cocos2d_extension_ScrollView_prototype); jsb_cocos2d_extension_TableView_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_extension_ScrollView_prototype), + parent_proto, jsb_cocos2d_extension_TableView_class, js_cocos2dx_extension_TableView_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "TableView", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_extension_TableView_class; - p->proto = jsb_cocos2d_extension_TableView_prototype; - p->parentProto = jsb_cocos2d_extension_ScrollView_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_extension_TableView_prototype); + jsb_register_class(cx, jsb_cocos2d_extension_TableView_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { cc.TableView.extend = cc.Class.extend; })()"); } @@ -6828,7 +6684,7 @@ bool js_cocos2dx_extension_EventAssetsManagerEx_constructor(JSContext *cx, uint3 if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::extension::AssetsManagerEx*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -6847,8 +6703,8 @@ bool js_cocos2dx_extension_EventAssetsManagerEx_constructor(JSContext *cx, uint3 CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -6896,32 +6752,20 @@ void js_register_cocos2dx_extension_EventAssetsManagerEx(JSContext *cx, JS::Hand JSFunctionSpec *st_funcs = NULL; + JS::RootedObject parent_proto(cx, jsb_cocos2d_EventCustom_prototype); jsb_cocos2d_extension_EventAssetsManagerEx_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_EventCustom_prototype), + parent_proto, jsb_cocos2d_extension_EventAssetsManagerEx_class, js_cocos2dx_extension_EventAssetsManagerEx_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "EventAssetsManager", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_extension_EventAssetsManagerEx_class; - p->proto = jsb_cocos2d_extension_EventAssetsManagerEx_prototype; - p->parentProto = jsb_cocos2d_EventCustom_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_extension_EventAssetsManagerEx_prototype); + jsb_register_class(cx, jsb_cocos2d_extension_EventAssetsManagerEx_class, proto, parent_proto); } JSClass *jsb_cocos2d_extension_Manifest_class; @@ -7090,30 +6934,17 @@ void js_register_cocos2dx_extension_Manifest(JSContext *cx, JS::HandleObject glo jsb_cocos2d_extension_Manifest_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocos2d_extension_Manifest_class, empty_constructor, 0, properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "Manifest", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_extension_Manifest_class; - p->proto = jsb_cocos2d_extension_Manifest_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_extension_Manifest_prototype); + jsb_register_class(cx, jsb_cocos2d_extension_Manifest_class, proto, JS::NullPtr()); } JSClass *jsb_cocos2d_extension_AssetsManagerEx_class; @@ -7301,8 +7132,8 @@ bool js_cocos2dx_extension_AssetsManagerEx_constructor(JSContext *cx, uint32_t a CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -7352,30 +7183,17 @@ void js_register_cocos2dx_extension_AssetsManagerEx(JSContext *cx, JS::HandleObj jsb_cocos2d_extension_AssetsManagerEx_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocos2d_extension_AssetsManagerEx_class, js_cocos2dx_extension_AssetsManagerEx_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "AssetsManager", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_extension_AssetsManagerEx_class; - p->proto = jsb_cocos2d_extension_AssetsManagerEx_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_extension_AssetsManagerEx_prototype); + jsb_register_class(cx, jsb_cocos2d_extension_AssetsManagerEx_class, proto, JS::NullPtr()); } JSClass *jsb_cocos2d_extension_EventListenerAssetsManagerEx_class; @@ -7396,7 +7214,7 @@ bool js_cocos2dx_extension_EventListenerAssetsManagerEx_init(JSContext *cx, uint if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (const cocos2d::extension::AssetsManagerEx*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -7404,7 +7222,8 @@ bool js_cocos2dx_extension_EventListenerAssetsManagerEx_init(JSContext *cx, uint do { if(JS_TypeOfValue(cx, args.get(1)) == JSTYPE_FUNCTION) { - std::shared_ptr func(new JSFunctionWrapper(cx, args.thisv().toObjectOrNull(), args.get(1))); + JS::RootedObject jstarget(cx, args.thisv().toObjectOrNull()); + std::shared_ptr func(new JSFunctionWrapper(cx, jstarget, args.get(1))); auto lambda = [=](cocos2d::extension::EventAssetsManagerEx* larg0) -> void { JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET jsval largv[1]; @@ -7452,7 +7271,7 @@ bool js_cocos2dx_extension_EventListenerAssetsManagerEx_create(JSContext *cx, ui if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::extension::AssetsManagerEx*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -7460,7 +7279,8 @@ bool js_cocos2dx_extension_EventListenerAssetsManagerEx_create(JSContext *cx, ui do { if(JS_TypeOfValue(cx, args.get(1)) == JSTYPE_FUNCTION) { - std::shared_ptr func(new JSFunctionWrapper(cx, args.thisv().toObjectOrNull(), args.get(1))); + JS::RootedObject jstarget(cx, args.thisv().toObjectOrNull()); + std::shared_ptr func(new JSFunctionWrapper(cx, jstarget, args.get(1))); auto lambda = [=](cocos2d::extension::EventAssetsManagerEx* larg0) -> void { JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET jsval largv[1]; @@ -7520,8 +7340,8 @@ bool js_cocos2dx_extension_EventListenerAssetsManagerEx_constructor(JSContext *c CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -7565,32 +7385,20 @@ void js_register_cocos2dx_extension_EventListenerAssetsManagerEx(JSContext *cx, JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_EventListenerCustom_prototype); jsb_cocos2d_extension_EventListenerAssetsManagerEx_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_EventListenerCustom_prototype), + parent_proto, jsb_cocos2d_extension_EventListenerAssetsManagerEx_class, js_cocos2dx_extension_EventListenerAssetsManagerEx_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "EventListenerAssetsManager", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_extension_EventListenerAssetsManagerEx_class; - p->proto = jsb_cocos2d_extension_EventListenerAssetsManagerEx_prototype; - p->parentProto = jsb_cocos2d_EventListenerCustom_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_extension_EventListenerAssetsManagerEx_prototype); + jsb_register_class(cx, jsb_cocos2d_extension_EventListenerAssetsManagerEx_class, proto, parent_proto); } void register_all_cocos2dx_extension(JSContext* cx, JS::HandleObject obj) { diff --git a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_navmesh_auto.cpp b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_navmesh_auto.cpp index a178091a1a..4041cb029a 100644 --- a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_navmesh_auto.cpp +++ b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_navmesh_auto.cpp @@ -21,8 +21,8 @@ static bool dummy_constructor(JSContext *cx, uint32_t argc, jsval *vp) { typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject _tmp(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(_tmp)); @@ -595,8 +595,8 @@ bool js_cocos2dx_navmesh_NavMeshAgent_constructor(JSContext *cx, uint32_t argc, CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -667,32 +667,20 @@ void js_register_cocos2dx_navmesh_NavMeshAgent(JSContext *cx, JS::HandleObject g JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Component_prototype); jsb_cocos2d_NavMeshAgent_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Component_prototype), + parent_proto, jsb_cocos2d_NavMeshAgent_class, js_cocos2dx_navmesh_NavMeshAgent_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "NavMeshAgent", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_NavMeshAgent_class; - p->proto = jsb_cocos2d_NavMeshAgent_prototype; - p->parentProto = jsb_cocos2d_Component_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_NavMeshAgent_prototype); + jsb_register_class(cx, jsb_cocos2d_NavMeshAgent_class, proto, parent_proto); } JSClass *jsb_cocos2d_NavMeshObstacle_class; @@ -885,8 +873,8 @@ bool js_cocos2dx_navmesh_NavMeshObstacle_constructor(JSContext *cx, uint32_t arg CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -937,32 +925,20 @@ void js_register_cocos2dx_navmesh_NavMeshObstacle(JSContext *cx, JS::HandleObjec JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Component_prototype); jsb_cocos2d_NavMeshObstacle_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Component_prototype), + parent_proto, jsb_cocos2d_NavMeshObstacle_class, js_cocos2dx_navmesh_NavMeshObstacle_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "NavMeshObstacle", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_NavMeshObstacle_class; - p->proto = jsb_cocos2d_NavMeshObstacle_prototype; - p->parentProto = jsb_cocos2d_Component_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_NavMeshObstacle_prototype); + jsb_register_class(cx, jsb_cocos2d_NavMeshObstacle_class, proto, parent_proto); } JSClass *jsb_cocos2d_NavMesh_class; @@ -982,7 +958,7 @@ bool js_cocos2dx_navmesh_NavMesh_removeNavMeshObstacle(JSContext *cx, uint32_t a if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::NavMeshObstacle*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -1010,7 +986,7 @@ bool js_cocos2dx_navmesh_NavMesh_removeNavMeshAgent(JSContext *cx, uint32_t argc if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::NavMeshAgent*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -1076,7 +1052,7 @@ bool js_cocos2dx_navmesh_NavMesh_addNavMeshAgent(JSContext *cx, uint32_t argc, j if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::NavMeshAgent*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -1104,7 +1080,7 @@ bool js_cocos2dx_navmesh_NavMesh_addNavMeshObstacle(JSContext *cx, uint32_t argc if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::NavMeshObstacle*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -1152,7 +1128,7 @@ bool js_cocos2dx_navmesh_NavMesh_debugDraw(JSContext *cx, uint32_t argc, jsval * if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Renderer*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -1209,8 +1185,8 @@ bool js_cocos2dx_navmesh_NavMesh_constructor(JSContext *cx, uint32_t argc, jsval CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -1261,30 +1237,17 @@ void js_register_cocos2dx_navmesh_NavMesh(JSContext *cx, JS::HandleObject global jsb_cocos2d_NavMesh_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocos2d_NavMesh_class, js_cocos2dx_navmesh_NavMesh_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "NavMesh", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_NavMesh_class; - p->proto = jsb_cocos2d_NavMesh_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_NavMesh_prototype); + jsb_register_class(cx, jsb_cocos2d_NavMesh_class, proto, JS::NullPtr()); } void register_all_cocos2dx_navmesh(JSContext* cx, JS::HandleObject obj) { diff --git a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_physics3d_auto.cpp b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_physics3d_auto.cpp index a1e0ac3275..d94b26ac15 100644 --- a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_physics3d_auto.cpp +++ b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_physics3d_auto.cpp @@ -21,8 +21,8 @@ static bool dummy_constructor(JSContext *cx, uint32_t argc, jsval *vp) { typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject _tmp(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(_tmp)); @@ -61,7 +61,7 @@ bool js_cocos2dx_physics3d_Physics3DShape_initConvexHull(JSContext *cx, uint32_t if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (const cocos2d::Vec3*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -276,7 +276,7 @@ bool js_cocos2dx_physics3d_Physics3DShape_createConvexHull(JSContext *cx, uint32 if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (const cocos2d::Vec3*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -368,8 +368,8 @@ bool js_cocos2dx_physics3d_Physics3DShape_constructor(JSContext *cx, uint32_t ar CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -423,30 +423,17 @@ void js_register_cocos2dx_physics3d_Physics3DShape(JSContext *cx, JS::HandleObje jsb_cocos2d_Physics3DShape_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocos2d_Physics3DShape_class, js_cocos2dx_physics3d_Physics3DShape_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "Physics3DShape", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_Physics3DShape_class; - p->proto = jsb_cocos2d_Physics3DShape_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_Physics3DShape_prototype); + jsb_register_class(cx, jsb_cocos2d_Physics3DShape_class, proto, JS::NullPtr()); } JSClass *jsb_cocos2d_Physics3DObject_class; @@ -523,7 +510,7 @@ bool js_cocos2dx_physics3d_Physics3DObject_setPhysicsWorld(JSContext *cx, uint32 if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Physics3DWorld*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -694,30 +681,17 @@ void js_register_cocos2dx_physics3d_Physics3DObject(JSContext *cx, JS::HandleObj jsb_cocos2d_Physics3DObject_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocos2d_Physics3DObject_class, empty_constructor, 0, properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "Physics3DObject", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_Physics3DObject_class; - p->proto = jsb_cocos2d_Physics3DObject_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_Physics3DObject_prototype); + jsb_register_class(cx, jsb_cocos2d_Physics3DObject_class, proto, JS::NullPtr()); } JSClass *jsb_cocos2d_Physics3DRigidBody_class; @@ -768,7 +742,7 @@ bool js_cocos2dx_physics3d_Physics3DRigidBody_setAngularFactor(JSContext *cx, ui JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::Physics3DRigidBody *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_physics3d_Physics3DRigidBody_setAngularFactor : Invalid Native Object"); @@ -811,7 +785,7 @@ bool js_cocos2dx_physics3d_Physics3DRigidBody_addConstraint(JSContext *cx, uint3 if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Physics3DConstraint*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -1449,7 +1423,7 @@ bool js_cocos2dx_physics3d_Physics3DRigidBody_removeConstraint(JSContext *cx, ui JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::Physics3DRigidBody *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_physics3d_Physics3DRigidBody_removeConstraint : Invalid Native Object"); @@ -1471,7 +1445,7 @@ bool js_cocos2dx_physics3d_Physics3DRigidBody_removeConstraint(JSContext *cx, ui if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Physics3DConstraint*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -1751,8 +1725,8 @@ bool js_cocos2dx_physics3d_Physics3DRigidBody_constructor(JSContext *cx, uint32_ CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -1841,32 +1815,20 @@ void js_register_cocos2dx_physics3d_Physics3DRigidBody(JSContext *cx, JS::Handle JSFunctionSpec *st_funcs = NULL; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Physics3DObject_prototype); jsb_cocos2d_Physics3DRigidBody_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Physics3DObject_prototype), + parent_proto, jsb_cocos2d_Physics3DRigidBody_class, js_cocos2dx_physics3d_Physics3DRigidBody_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "Physics3DRigidBody", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_Physics3DRigidBody_class; - p->proto = jsb_cocos2d_Physics3DRigidBody_prototype; - p->parentProto = jsb_cocos2d_Physics3DObject_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_Physics3DRigidBody_prototype); + jsb_register_class(cx, jsb_cocos2d_Physics3DRigidBody_class, proto, parent_proto); } JSClass *jsb_cocos2d_Physics3DComponent_class; @@ -1902,7 +1864,7 @@ bool js_cocos2dx_physics3d_Physics3DComponent_addToPhysicsWorld(JSContext *cx, u if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Physics3DWorld*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -1971,7 +1933,7 @@ bool js_cocos2dx_physics3d_Physics3DComponent_setPhysics3DObject(JSContext *cx, if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Physics3DObject*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -2039,7 +2001,7 @@ bool js_cocos2dx_physics3d_Physics3DComponent_create(JSContext *cx, uint32_t arg if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Physics3DObject*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -2066,7 +2028,7 @@ bool js_cocos2dx_physics3d_Physics3DComponent_create(JSContext *cx, uint32_t arg if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Physics3DObject*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -2096,7 +2058,7 @@ bool js_cocos2dx_physics3d_Physics3DComponent_create(JSContext *cx, uint32_t arg if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Physics3DObject*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -2172,8 +2134,8 @@ bool js_cocos2dx_physics3d_Physics3DComponent_constructor(JSContext *cx, uint32_ CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -2224,32 +2186,20 @@ void js_register_cocos2dx_physics3d_Physics3DComponent(JSContext *cx, JS::Handle JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Component_prototype); jsb_cocos2d_Physics3DComponent_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Component_prototype), + parent_proto, jsb_cocos2d_Physics3DComponent_class, js_cocos2dx_physics3d_Physics3DComponent_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "Physics3DComponent", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_Physics3DComponent_class; - p->proto = jsb_cocos2d_Physics3DComponent_prototype; - p->parentProto = jsb_cocos2d_Component_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_Physics3DComponent_prototype); + jsb_register_class(cx, jsb_cocos2d_Physics3DComponent_class, proto, parent_proto); } JSClass *jsb_cocos2d_PhysicsSprite3D_class; @@ -2348,8 +2298,8 @@ bool js_cocos2dx_physics3d_PhysicsSprite3D_constructor(JSContext *cx, uint32_t a CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -2393,32 +2343,20 @@ void js_register_cocos2dx_physics3d_PhysicsSprite3D(JSContext *cx, JS::HandleObj JSFunctionSpec *st_funcs = NULL; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Sprite3D_prototype); jsb_cocos2d_PhysicsSprite3D_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Sprite3D_prototype), + parent_proto, jsb_cocos2d_PhysicsSprite3D_class, js_cocos2dx_physics3d_PhysicsSprite3D_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "PhysicsSprite3D", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_PhysicsSprite3D_class; - p->proto = jsb_cocos2d_PhysicsSprite3D_prototype; - p->parentProto = jsb_cocos2d_Sprite3D_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_PhysicsSprite3D_prototype); + jsb_register_class(cx, jsb_cocos2d_PhysicsSprite3D_class, proto, parent_proto); } JSClass *jsb_cocos2d_Physics3DWorld_class; @@ -2619,7 +2557,7 @@ bool js_cocos2dx_physics3d_Physics3DWorld_removePhysics3DConstraint(JSContext *c if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Physics3DConstraint*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -2647,7 +2585,7 @@ bool js_cocos2dx_physics3d_Physics3DWorld_addPhysics3DObject(JSContext *cx, uint if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Physics3DObject*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -2695,7 +2633,7 @@ bool js_cocos2dx_physics3d_Physics3DWorld_removePhysics3DObject(JSContext *cx, u if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Physics3DObject*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -2723,7 +2661,7 @@ bool js_cocos2dx_physics3d_Physics3DWorld_getPhysicsObject(JSContext *cx, uint32 if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (const btCollisionObject*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -2760,7 +2698,7 @@ bool js_cocos2dx_physics3d_Physics3DWorld_addPhysics3DConstraint(JSContext *cx, if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Physics3DConstraint*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -2777,7 +2715,7 @@ bool js_cocos2dx_physics3d_Physics3DWorld_addPhysics3DConstraint(JSContext *cx, if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Physics3DConstraint*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -2806,7 +2744,7 @@ bool js_cocos2dx_physics3d_Physics3DWorld_debugDraw(JSContext *cx, uint32_t argc if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Renderer*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -2837,7 +2775,7 @@ bool js_cocos2dx_physics3d_Physics3DWorld_sweepShape(JSContext *cx, uint32_t arg if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Physics3DShape*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -2899,8 +2837,8 @@ bool js_cocos2dx_physics3d_Physics3DWorld_constructor(JSContext *cx, uint32_t ar CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -2961,30 +2899,17 @@ void js_register_cocos2dx_physics3d_Physics3DWorld(JSContext *cx, JS::HandleObje jsb_cocos2d_Physics3DWorld_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocos2d_Physics3DWorld_class, js_cocos2dx_physics3d_Physics3DWorld_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "Physics3DWorld", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_Physics3DWorld_class; - p->proto = jsb_cocos2d_Physics3DWorld_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_Physics3DWorld_prototype); + jsb_register_class(cx, jsb_cocos2d_Physics3DWorld_class, proto, JS::NullPtr()); } JSClass *jsb_cocos2d_Physics3DConstraint_class; @@ -3278,30 +3203,17 @@ void js_register_cocos2dx_physics3d_Physics3DConstraint(JSContext *cx, JS::Handl jsb_cocos2d_Physics3DConstraint_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocos2d_Physics3DConstraint_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "Physics3DConstraint", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_Physics3DConstraint_class; - p->proto = jsb_cocos2d_Physics3DConstraint_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_Physics3DConstraint_prototype); + jsb_register_class(cx, jsb_cocos2d_Physics3DConstraint_class, proto, JS::NullPtr()); } JSClass *jsb_cocos2d_Physics3DPointToPointConstraint_class; @@ -3350,7 +3262,7 @@ bool js_cocos2dx_physics3d_Physics3DPointToPointConstraint_init(JSContext *cx, u JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::Physics3DPointToPointConstraint *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_physics3d_Physics3DPointToPointConstraint_init : Invalid Native Object"); @@ -3361,7 +3273,7 @@ bool js_cocos2dx_physics3d_Physics3DPointToPointConstraint_init(JSContext *cx, u if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Physics3DRigidBody*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -3372,7 +3284,7 @@ bool js_cocos2dx_physics3d_Physics3DPointToPointConstraint_init(JSContext *cx, u if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Physics3DRigidBody*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -3399,7 +3311,7 @@ bool js_cocos2dx_physics3d_Physics3DPointToPointConstraint_init(JSContext *cx, u if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Physics3DRigidBody*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -3471,7 +3383,7 @@ bool js_cocos2dx_physics3d_Physics3DPointToPointConstraint_create(JSContext *cx, if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Physics3DRigidBody*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -3482,7 +3394,7 @@ bool js_cocos2dx_physics3d_Physics3DPointToPointConstraint_create(JSContext *cx, if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Physics3DRigidBody*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -3516,7 +3428,7 @@ bool js_cocos2dx_physics3d_Physics3DPointToPointConstraint_create(JSContext *cx, if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Physics3DRigidBody*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -3558,8 +3470,8 @@ bool js_cocos2dx_physics3d_Physics3DPointToPointConstraint_constructor(JSContext CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -3607,32 +3519,20 @@ void js_register_cocos2dx_physics3d_Physics3DPointToPointConstraint(JSContext *c JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Physics3DConstraint_prototype); jsb_cocos2d_Physics3DPointToPointConstraint_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Physics3DConstraint_prototype), + parent_proto, jsb_cocos2d_Physics3DPointToPointConstraint_class, js_cocos2dx_physics3d_Physics3DPointToPointConstraint_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "Physics3DPointToPointConstraint", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_Physics3DPointToPointConstraint_class; - p->proto = jsb_cocos2d_Physics3DPointToPointConstraint_prototype; - p->parentProto = jsb_cocos2d_Physics3DConstraint_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_Physics3DPointToPointConstraint_prototype); + jsb_register_class(cx, jsb_cocos2d_Physics3DPointToPointConstraint_class, proto, parent_proto); } JSClass *jsb_cocos2d_Physics3DHingeConstraint_class; @@ -3645,7 +3545,7 @@ bool js_cocos2dx_physics3d_Physics3DHingeConstraint_getHingeAngle(JSContext *cx, JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::Physics3DHingeConstraint *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_physics3d_Physics3DHingeConstraint_getHingeAngle : Invalid Native Object"); @@ -4037,7 +3937,7 @@ bool js_cocos2dx_physics3d_Physics3DHingeConstraint_setMotorTarget(JSContext *cx JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::Physics3DHingeConstraint *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_physics3d_Physics3DHingeConstraint_setMotorTarget : Invalid Native Object"); @@ -4140,7 +4040,7 @@ bool js_cocos2dx_physics3d_Physics3DHingeConstraint_create(JSContext *cx, uint32 if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Physics3DRigidBody*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -4173,7 +4073,7 @@ bool js_cocos2dx_physics3d_Physics3DHingeConstraint_create(JSContext *cx, uint32 if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Physics3DRigidBody*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -4210,7 +4110,7 @@ bool js_cocos2dx_physics3d_Physics3DHingeConstraint_create(JSContext *cx, uint32 if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Physics3DRigidBody*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -4240,7 +4140,7 @@ bool js_cocos2dx_physics3d_Physics3DHingeConstraint_create(JSContext *cx, uint32 if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Physics3DRigidBody*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -4274,7 +4174,7 @@ bool js_cocos2dx_physics3d_Physics3DHingeConstraint_create(JSContext *cx, uint32 if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Physics3DRigidBody*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -4285,7 +4185,7 @@ bool js_cocos2dx_physics3d_Physics3DHingeConstraint_create(JSContext *cx, uint32 if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Physics3DRigidBody*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -4324,7 +4224,7 @@ bool js_cocos2dx_physics3d_Physics3DHingeConstraint_create(JSContext *cx, uint32 if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Physics3DRigidBody*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -4335,7 +4235,7 @@ bool js_cocos2dx_physics3d_Physics3DHingeConstraint_create(JSContext *cx, uint32 if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Physics3DRigidBody*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -4378,7 +4278,7 @@ bool js_cocos2dx_physics3d_Physics3DHingeConstraint_create(JSContext *cx, uint32 if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Physics3DRigidBody*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -4389,7 +4289,7 @@ bool js_cocos2dx_physics3d_Physics3DHingeConstraint_create(JSContext *cx, uint32 if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Physics3DRigidBody*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -4422,7 +4322,7 @@ bool js_cocos2dx_physics3d_Physics3DHingeConstraint_create(JSContext *cx, uint32 if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Physics3DRigidBody*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -4433,7 +4333,7 @@ bool js_cocos2dx_physics3d_Physics3DHingeConstraint_create(JSContext *cx, uint32 if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Physics3DRigidBody*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -4481,8 +4381,8 @@ bool js_cocos2dx_physics3d_Physics3DHingeConstraint_constructor(JSContext *cx, u CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -4546,32 +4446,20 @@ void js_register_cocos2dx_physics3d_Physics3DHingeConstraint(JSContext *cx, JS:: JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Physics3DConstraint_prototype); jsb_cocos2d_Physics3DHingeConstraint_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Physics3DConstraint_prototype), + parent_proto, jsb_cocos2d_Physics3DHingeConstraint_class, js_cocos2dx_physics3d_Physics3DHingeConstraint_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "Physics3DHingeConstraint", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_Physics3DHingeConstraint_class; - p->proto = jsb_cocos2d_Physics3DHingeConstraint_prototype; - p->parentProto = jsb_cocos2d_Physics3DConstraint_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_Physics3DHingeConstraint_prototype); + jsb_register_class(cx, jsb_cocos2d_Physics3DHingeConstraint_class, proto, parent_proto); } JSClass *jsb_cocos2d_Physics3DSliderConstraint_class; @@ -5805,7 +5693,7 @@ bool js_cocos2dx_physics3d_Physics3DSliderConstraint_create(JSContext *cx, uint3 if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Physics3DRigidBody*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -5814,7 +5702,7 @@ bool js_cocos2dx_physics3d_Physics3DSliderConstraint_create(JSContext *cx, uint3 if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Physics3DRigidBody*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -5856,8 +5744,8 @@ bool js_cocos2dx_physics3d_Physics3DSliderConstraint_constructor(JSContext *cx, CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -5964,32 +5852,20 @@ void js_register_cocos2dx_physics3d_Physics3DSliderConstraint(JSContext *cx, JS: JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Physics3DConstraint_prototype); jsb_cocos2d_Physics3DSliderConstraint_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Physics3DConstraint_prototype), + parent_proto, jsb_cocos2d_Physics3DSliderConstraint_class, js_cocos2dx_physics3d_Physics3DSliderConstraint_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "Physics3DSliderConstraint", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_Physics3DSliderConstraint_class; - p->proto = jsb_cocos2d_Physics3DSliderConstraint_prototype; - p->parentProto = jsb_cocos2d_Physics3DConstraint_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_Physics3DSliderConstraint_prototype); + jsb_register_class(cx, jsb_cocos2d_Physics3DSliderConstraint_class, proto, parent_proto); } JSClass *jsb_cocos2d_Physics3DConeTwistConstraint_class; @@ -6387,7 +6263,7 @@ bool js_cocos2dx_physics3d_Physics3DConeTwistConstraint_create(JSContext *cx, ui if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Physics3DRigidBody*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -6398,7 +6274,7 @@ bool js_cocos2dx_physics3d_Physics3DConeTwistConstraint_create(JSContext *cx, ui if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Physics3DRigidBody*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -6432,7 +6308,7 @@ bool js_cocos2dx_physics3d_Physics3DConeTwistConstraint_create(JSContext *cx, ui if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Physics3DRigidBody*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -6474,8 +6350,8 @@ bool js_cocos2dx_physics3d_Physics3DConeTwistConstraint_constructor(JSContext *c CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -6535,32 +6411,20 @@ void js_register_cocos2dx_physics3d_Physics3DConeTwistConstraint(JSContext *cx, JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Physics3DConstraint_prototype); jsb_cocos2d_Physics3DConeTwistConstraint_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Physics3DConstraint_prototype), + parent_proto, jsb_cocos2d_Physics3DConeTwistConstraint_class, js_cocos2dx_physics3d_Physics3DConeTwistConstraint_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "Physics3DConeTwistConstraint", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_Physics3DConeTwistConstraint_class; - p->proto = jsb_cocos2d_Physics3DConeTwistConstraint_prototype; - p->parentProto = jsb_cocos2d_Physics3DConstraint_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_Physics3DConeTwistConstraint_prototype); + jsb_register_class(cx, jsb_cocos2d_Physics3DConeTwistConstraint_class, proto, parent_proto); } JSClass *jsb_cocos2d_Physics3D6DofConstraint_class; @@ -6790,7 +6654,7 @@ bool js_cocos2dx_physics3d_Physics3D6DofConstraint_create(JSContext *cx, uint32_ if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Physics3DRigidBody*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -6824,7 +6688,7 @@ bool js_cocos2dx_physics3d_Physics3D6DofConstraint_create(JSContext *cx, uint32_ if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Physics3DRigidBody*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -6835,7 +6699,7 @@ bool js_cocos2dx_physics3d_Physics3D6DofConstraint_create(JSContext *cx, uint32_ if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Physics3DRigidBody*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -6883,8 +6747,8 @@ bool js_cocos2dx_physics3d_Physics3D6DofConstraint_constructor(JSContext *cx, ui CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -6938,32 +6802,20 @@ void js_register_cocos2dx_physics3d_Physics3D6DofConstraint(JSContext *cx, JS::H JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Physics3DConstraint_prototype); jsb_cocos2d_Physics3D6DofConstraint_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Physics3DConstraint_prototype), + parent_proto, jsb_cocos2d_Physics3D6DofConstraint_class, js_cocos2dx_physics3d_Physics3D6DofConstraint_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "Physics3D6DofConstraint", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_Physics3D6DofConstraint_class; - p->proto = jsb_cocos2d_Physics3D6DofConstraint_prototype; - p->parentProto = jsb_cocos2d_Physics3DConstraint_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_Physics3D6DofConstraint_prototype); + jsb_register_class(cx, jsb_cocos2d_Physics3D6DofConstraint_class, proto, parent_proto); } void register_all_cocos2dx_physics3d(JSContext* cx, JS::HandleObject obj) { diff --git a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_spine_auto.cpp b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_spine_auto.cpp index 838d77a01c..a1fb9cc721 100644 --- a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_spine_auto.cpp +++ b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_spine_auto.cpp @@ -20,8 +20,8 @@ static bool dummy_constructor(JSContext *cx, uint32_t argc, jsval *vp) { typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject _tmp(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(_tmp)); @@ -90,7 +90,7 @@ bool js_cocos2dx_spine_SkeletonRenderer_setAttachment(JSContext *cx, uint32_t ar JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (spine::SkeletonRenderer *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_spine_SkeletonRenderer_setAttachment : Invalid Native Object"); @@ -364,7 +364,7 @@ bool js_cocos2dx_spine_SkeletonRenderer_initWithFile(JSContext *cx, uint32_t arg JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (spine::SkeletonRenderer *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_spine_SkeletonRenderer_initWithFile : Invalid Native Object"); @@ -462,7 +462,7 @@ bool js_cocos2dx_spine_SkeletonRenderer_setSkin(JSContext *cx, uint32_t argc, js JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (spine::SkeletonRenderer *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_spine_SkeletonRenderer_setSkin : Invalid Native Object"); @@ -645,8 +645,8 @@ bool js_cocos2dx_spine_SkeletonRenderer_constructor(JSContext *cx, uint32_t argc typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); // obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); obj = JS_NewObject(cx, typeClass->jsclass, proto, parent); js_proxy_t* p = jsb_new_proxy(cobj, obj); @@ -676,8 +676,8 @@ bool js_cocos2dx_spine_SkeletonRenderer_constructor(JSContext *cx, uint32_t argc typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); // obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); obj = JS_NewObject(cx, typeClass->jsclass, proto, parent); js_proxy_t* p = jsb_new_proxy(cobj, obj); @@ -701,8 +701,8 @@ bool js_cocos2dx_spine_SkeletonRenderer_constructor(JSContext *cx, uint32_t argc typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); // obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); obj = JS_NewObject(cx, typeClass->jsclass, proto, parent); js_proxy_t* p = jsb_new_proxy(cobj, obj); @@ -733,8 +733,8 @@ bool js_cocos2dx_spine_SkeletonRenderer_constructor(JSContext *cx, uint32_t argc typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); // obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); obj = JS_NewObject(cx, typeClass->jsclass, proto, parent); js_proxy_t* p = jsb_new_proxy(cobj, obj); @@ -768,8 +768,8 @@ bool js_cocos2dx_spine_SkeletonRenderer_constructor(JSContext *cx, uint32_t argc typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); // obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); obj = JS_NewObject(cx, typeClass->jsclass, proto, parent); js_proxy_t* p = jsb_new_proxy(cobj, obj); @@ -799,8 +799,8 @@ bool js_cocos2dx_spine_SkeletonRenderer_constructor(JSContext *cx, uint32_t argc typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); // obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); obj = JS_NewObject(cx, typeClass->jsclass, proto, parent); js_proxy_t* p = jsb_new_proxy(cobj, obj); @@ -833,8 +833,8 @@ bool js_cocos2dx_spine_SkeletonRenderer_constructor(JSContext *cx, uint32_t argc typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); // obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); obj = JS_NewObject(cx, typeClass->jsclass, proto, parent); js_proxy_t* p = jsb_new_proxy(cobj, obj); @@ -905,32 +905,20 @@ void js_register_cocos2dx_spine_SkeletonRenderer(JSContext *cx, JS::HandleObject JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Node_prototype); jsb_spine_SkeletonRenderer_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Node_prototype), + parent_proto, jsb_spine_SkeletonRenderer_class, js_cocos2dx_spine_SkeletonRenderer_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "Skeleton", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_spine_SkeletonRenderer_class; - p->proto = jsb_spine_SkeletonRenderer_prototype; - p->parentProto = jsb_cocos2d_Node_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_spine_SkeletonRenderer_prototype); + jsb_register_class(cx, jsb_spine_SkeletonRenderer_class, proto, parent_proto); } JSClass *jsb_spine_SkeletonAnimation_class; @@ -949,7 +937,8 @@ bool js_cocos2dx_spine_SkeletonAnimation_setStartListener(JSContext *cx, uint32_ do { if(JS_TypeOfValue(cx, args.get(0)) == JSTYPE_FUNCTION) { - std::shared_ptr func(new JSFunctionWrapper(cx, args.thisv().toObjectOrNull(), args.get(0))); + JS::RootedObject jstarget(cx, args.thisv().toObjectOrNull()); + std::shared_ptr func(new JSFunctionWrapper(cx, jstarget, args.get(0))); auto lambda = [=](int larg0) -> void { JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET jsval largv[1]; @@ -993,7 +982,8 @@ bool js_cocos2dx_spine_SkeletonAnimation_setTrackEventListener(JSContext *cx, ui do { if(JS_TypeOfValue(cx, args.get(1)) == JSTYPE_FUNCTION) { - std::shared_ptr func(new JSFunctionWrapper(cx, args.thisv().toObjectOrNull(), args.get(1))); + JS::RootedObject jstarget(cx, args.thisv().toObjectOrNull()); + std::shared_ptr func(new JSFunctionWrapper(cx, jstarget, args.get(1))); auto lambda = [=](int larg0, spEvent* larg1) -> void { JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET jsval largv[2]; @@ -1056,7 +1046,8 @@ bool js_cocos2dx_spine_SkeletonAnimation_setTrackCompleteListener(JSContext *cx, do { if(JS_TypeOfValue(cx, args.get(1)) == JSTYPE_FUNCTION) { - std::shared_ptr func(new JSFunctionWrapper(cx, args.thisv().toObjectOrNull(), args.get(1))); + JS::RootedObject jstarget(cx, args.thisv().toObjectOrNull()); + std::shared_ptr func(new JSFunctionWrapper(cx, jstarget, args.get(1))); auto lambda = [=](int larg0, int larg1) -> void { JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET jsval largv[2]; @@ -1128,7 +1119,8 @@ bool js_cocos2dx_spine_SkeletonAnimation_setTrackStartListener(JSContext *cx, ui do { if(JS_TypeOfValue(cx, args.get(1)) == JSTYPE_FUNCTION) { - std::shared_ptr func(new JSFunctionWrapper(cx, args.thisv().toObjectOrNull(), args.get(1))); + JS::RootedObject jstarget(cx, args.thisv().toObjectOrNull()); + std::shared_ptr func(new JSFunctionWrapper(cx, jstarget, args.get(1))); auto lambda = [=](int larg0) -> void { JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET jsval largv[1]; @@ -1189,7 +1181,8 @@ bool js_cocos2dx_spine_SkeletonAnimation_setCompleteListener(JSContext *cx, uint do { if(JS_TypeOfValue(cx, args.get(0)) == JSTYPE_FUNCTION) { - std::shared_ptr func(new JSFunctionWrapper(cx, args.thisv().toObjectOrNull(), args.get(0))); + JS::RootedObject jstarget(cx, args.thisv().toObjectOrNull()); + std::shared_ptr func(new JSFunctionWrapper(cx, jstarget, args.get(0))); auto lambda = [=](int larg0, int larg1) -> void { JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET jsval largv[2]; @@ -1234,7 +1227,8 @@ bool js_cocos2dx_spine_SkeletonAnimation_setTrackEndListener(JSContext *cx, uint do { if(JS_TypeOfValue(cx, args.get(1)) == JSTYPE_FUNCTION) { - std::shared_ptr func(new JSFunctionWrapper(cx, args.thisv().toObjectOrNull(), args.get(1))); + JS::RootedObject jstarget(cx, args.thisv().toObjectOrNull()); + std::shared_ptr func(new JSFunctionWrapper(cx, jstarget, args.get(1))); auto lambda = [=](int larg0) -> void { JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET jsval largv[1]; @@ -1275,7 +1269,8 @@ bool js_cocos2dx_spine_SkeletonAnimation_setEventListener(JSContext *cx, uint32_ do { if(JS_TypeOfValue(cx, args.get(0)) == JSTYPE_FUNCTION) { - std::shared_ptr func(new JSFunctionWrapper(cx, args.thisv().toObjectOrNull(), args.get(0))); + JS::RootedObject jstarget(cx, args.thisv().toObjectOrNull()); + std::shared_ptr func(new JSFunctionWrapper(cx, jstarget, args.get(0))); auto lambda = [=](int larg0, spEvent* larg1) -> void { JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET jsval largv[2]; @@ -1341,7 +1336,8 @@ bool js_cocos2dx_spine_SkeletonAnimation_setEndListener(JSContext *cx, uint32_t do { if(JS_TypeOfValue(cx, args.get(0)) == JSTYPE_FUNCTION) { - std::shared_ptr func(new JSFunctionWrapper(cx, args.thisv().toObjectOrNull(), args.get(0))); + JS::RootedObject jstarget(cx, args.thisv().toObjectOrNull()); + std::shared_ptr func(new JSFunctionWrapper(cx, jstarget, args.get(0))); auto lambda = [=](int larg0) -> void { JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET jsval largv[1]; @@ -1585,8 +1581,8 @@ bool js_cocos2dx_spine_SkeletonAnimation_constructor(JSContext *cx, uint32_t arg typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); // obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); obj = JS_NewObject(cx, typeClass->jsclass, proto, parent); js_proxy_t* p = jsb_new_proxy(cobj, obj); @@ -1616,8 +1612,8 @@ bool js_cocos2dx_spine_SkeletonAnimation_constructor(JSContext *cx, uint32_t arg typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); // obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); obj = JS_NewObject(cx, typeClass->jsclass, proto, parent); js_proxy_t* p = jsb_new_proxy(cobj, obj); @@ -1641,8 +1637,8 @@ bool js_cocos2dx_spine_SkeletonAnimation_constructor(JSContext *cx, uint32_t arg typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); // obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); obj = JS_NewObject(cx, typeClass->jsclass, proto, parent); js_proxy_t* p = jsb_new_proxy(cobj, obj); @@ -1673,8 +1669,8 @@ bool js_cocos2dx_spine_SkeletonAnimation_constructor(JSContext *cx, uint32_t arg typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); // obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); obj = JS_NewObject(cx, typeClass->jsclass, proto, parent); js_proxy_t* p = jsb_new_proxy(cobj, obj); @@ -1708,8 +1704,8 @@ bool js_cocos2dx_spine_SkeletonAnimation_constructor(JSContext *cx, uint32_t arg typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); // obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); obj = JS_NewObject(cx, typeClass->jsclass, proto, parent); js_proxy_t* p = jsb_new_proxy(cobj, obj); @@ -1739,8 +1735,8 @@ bool js_cocos2dx_spine_SkeletonAnimation_constructor(JSContext *cx, uint32_t arg typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); // obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); obj = JS_NewObject(cx, typeClass->jsclass, proto, parent); js_proxy_t* p = jsb_new_proxy(cobj, obj); @@ -1773,8 +1769,8 @@ bool js_cocos2dx_spine_SkeletonAnimation_constructor(JSContext *cx, uint32_t arg typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); // obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); obj = JS_NewObject(cx, typeClass->jsclass, proto, parent); js_proxy_t* p = jsb_new_proxy(cobj, obj); @@ -2001,32 +1997,20 @@ void js_register_cocos2dx_spine_SkeletonAnimation(JSContext *cx, JS::HandleObjec JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_spine_SkeletonRenderer_prototype); jsb_spine_SkeletonAnimation_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_spine_SkeletonRenderer_prototype), + parent_proto, jsb_spine_SkeletonAnimation_class, js_cocos2dx_spine_SkeletonAnimation_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "SkeletonAnimation", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_spine_SkeletonAnimation_class; - p->proto = jsb_spine_SkeletonAnimation_prototype; - p->parentProto = jsb_spine_SkeletonRenderer_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_spine_SkeletonAnimation_prototype); + jsb_register_class(cx, jsb_spine_SkeletonAnimation_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { sp.SkeletonAnimation.extend = cc.Class.extend; })()"); } diff --git a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_studio_auto.cpp b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_studio_auto.cpp index 36ba34352a..4819d2922a 100644 --- a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_studio_auto.cpp +++ b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_studio_auto.cpp @@ -21,8 +21,8 @@ static bool dummy_constructor(JSContext *cx, uint32_t argc, jsval *vp) { typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject _tmp(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(_tmp)); @@ -181,7 +181,7 @@ bool js_cocos2dx_studio_ActionObject_play(JSContext *cx, uint32_t argc, jsval *v JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocostudio::ActionObject *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ActionObject_play : Invalid Native Object"); @@ -192,7 +192,7 @@ bool js_cocos2dx_studio_ActionObject_play(JSContext *cx, uint32_t argc, jsval *v if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::CallFunc*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -247,7 +247,7 @@ bool js_cocos2dx_studio_ActionObject_removeActionNode(JSContext *cx, uint32_t ar if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocostudio::ActionNode*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -295,7 +295,7 @@ bool js_cocos2dx_studio_ActionObject_initWithBinary(JSContext *cx, uint32_t argc if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocostudio::CocoLoader*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -306,7 +306,7 @@ bool js_cocos2dx_studio_ActionObject_initWithBinary(JSContext *cx, uint32_t argc if (args.get(2).isNull()) { arg2 = nullptr; break; } if (!args.get(2).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(2).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(2).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg2 = (cocos2d::Ref*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg2, cx, false, "Invalid Native Object"); @@ -334,7 +334,7 @@ bool js_cocos2dx_studio_ActionObject_addActionNode(JSContext *cx, uint32_t argc, if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocostudio::ActionNode*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -460,8 +460,8 @@ bool js_cocos2dx_studio_ActionObject_constructor(JSContext *cx, uint32_t argc, j CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -519,30 +519,17 @@ void js_register_cocos2dx_studio_ActionObject(JSContext *cx, JS::HandleObject gl jsb_cocostudio_ActionObject_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocostudio_ActionObject_class, js_cocos2dx_studio_ActionObject_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "ActionObject", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocostudio_ActionObject_class; - p->proto = jsb_cocostudio_ActionObject_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocostudio_ActionObject_prototype); + jsb_register_class(cx, jsb_cocostudio_ActionObject_class, proto, JS::NullPtr()); } JSClass *jsb_cocostudio_ActionManagerEx_class; @@ -628,7 +615,7 @@ bool js_cocos2dx_studio_ActionManagerEx_initWithBinary(JSContext *cx, uint32_t a if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Ref*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -637,7 +624,7 @@ bool js_cocos2dx_studio_ActionManagerEx_initWithBinary(JSContext *cx, uint32_t a if (args.get(2).isNull()) { arg2 = nullptr; break; } if (!args.get(2).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(2).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(2).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg2 = (cocostudio::CocoLoader*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg2, cx, false, "Invalid Native Object"); @@ -660,7 +647,7 @@ bool js_cocos2dx_studio_ActionManagerEx_playActionByName(JSContext *cx, uint32_t JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocostudio::ActionManagerEx *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ActionManagerEx_playActionByName : Invalid Native Object"); @@ -677,7 +664,7 @@ bool js_cocos2dx_studio_ActionManagerEx_playActionByName(JSContext *cx, uint32_t if (args.get(2).isNull()) { arg2 = nullptr; break; } if (!args.get(2).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(2).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(2).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg2 = (cocos2d::CallFunc*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg2, cx, false, "Invalid Native Object"); @@ -812,30 +799,17 @@ void js_register_cocos2dx_studio_ActionManagerEx(JSContext *cx, JS::HandleObject jsb_cocostudio_ActionManagerEx_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocostudio_ActionManagerEx_class, empty_constructor, 0, properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "ActionManager", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocostudio_ActionManagerEx_class; - p->proto = jsb_cocostudio_ActionManagerEx_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocostudio_ActionManagerEx_prototype); + jsb_register_class(cx, jsb_cocostudio_ActionManagerEx_class, proto, JS::NullPtr()); } JSClass *jsb_cocostudio_BaseData_class; @@ -916,8 +890,8 @@ bool js_cocos2dx_studio_BaseData_constructor(JSContext *cx, uint32_t argc, jsval CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -962,30 +936,17 @@ void js_register_cocos2dx_studio_BaseData(JSContext *cx, JS::HandleObject global jsb_cocostudio_BaseData_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocostudio_BaseData_class, js_cocos2dx_studio_BaseData_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "BaseData", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocostudio_BaseData_class; - p->proto = jsb_cocostudio_BaseData_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocostudio_BaseData_prototype); + jsb_register_class(cx, jsb_cocostudio_BaseData_class, proto, JS::NullPtr()); } JSClass *jsb_cocostudio_MovementData_class; @@ -1034,7 +995,7 @@ bool js_cocos2dx_studio_MovementData_addMovementBoneData(JSContext *cx, uint32_t if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocostudio::MovementBoneData*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -1085,8 +1046,8 @@ bool js_cocos2dx_studio_MovementData_constructor(JSContext *cx, uint32_t argc, j CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -1131,30 +1092,17 @@ void js_register_cocos2dx_studio_MovementData(JSContext *cx, JS::HandleObject gl jsb_cocostudio_MovementData_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocostudio_MovementData_class, js_cocos2dx_studio_MovementData_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "MovementData", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocostudio_MovementData_class; - p->proto = jsb_cocostudio_MovementData_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocostudio_MovementData_prototype); + jsb_register_class(cx, jsb_cocostudio_MovementData_class, proto, JS::NullPtr()); } JSClass *jsb_cocostudio_AnimationData_class; @@ -1221,7 +1169,7 @@ bool js_cocos2dx_studio_AnimationData_addMovement(JSContext *cx, uint32_t argc, if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocostudio::MovementData*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -1272,8 +1220,8 @@ bool js_cocos2dx_studio_AnimationData_constructor(JSContext *cx, uint32_t argc, CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -1319,30 +1267,17 @@ void js_register_cocos2dx_studio_AnimationData(JSContext *cx, JS::HandleObject g jsb_cocostudio_AnimationData_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocostudio_AnimationData_class, js_cocos2dx_studio_AnimationData_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "AnimationData", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocostudio_AnimationData_class; - p->proto = jsb_cocostudio_AnimationData_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocostudio_AnimationData_prototype); + jsb_register_class(cx, jsb_cocostudio_AnimationData_class, proto, JS::NullPtr()); } JSClass *jsb_cocostudio_ContourData_class; @@ -1423,8 +1358,8 @@ bool js_cocos2dx_studio_ContourData_constructor(JSContext *cx, uint32_t argc, js CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -1469,30 +1404,17 @@ void js_register_cocos2dx_studio_ContourData(JSContext *cx, JS::HandleObject glo jsb_cocostudio_ContourData_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocostudio_ContourData_class, js_cocos2dx_studio_ContourData_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "ContourData", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocostudio_ContourData_class; - p->proto = jsb_cocostudio_ContourData_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocostudio_ContourData_prototype); + jsb_register_class(cx, jsb_cocostudio_ContourData_class, proto, JS::NullPtr()); } JSClass *jsb_cocostudio_TextureData_class; @@ -1559,7 +1481,7 @@ bool js_cocos2dx_studio_TextureData_addContourData(JSContext *cx, uint32_t argc, if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocostudio::ContourData*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -1610,8 +1532,8 @@ bool js_cocos2dx_studio_TextureData_constructor(JSContext *cx, uint32_t argc, js CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -1657,30 +1579,17 @@ void js_register_cocos2dx_studio_TextureData(JSContext *cx, JS::HandleObject glo jsb_cocostudio_TextureData_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocostudio_TextureData_class, js_cocos2dx_studio_TextureData_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "TextureData", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocostudio_TextureData_class; - p->proto = jsb_cocostudio_TextureData_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocostudio_TextureData_prototype); + jsb_register_class(cx, jsb_cocostudio_TextureData_class, proto, JS::NullPtr()); } JSClass *jsb_cocostudio_ProcessBase_class; @@ -2002,8 +1911,8 @@ bool js_cocos2dx_studio_ProcessBase_constructor(JSContext *cx, uint32_t argc, js CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -2059,30 +1968,17 @@ void js_register_cocos2dx_studio_ProcessBase(JSContext *cx, JS::HandleObject glo jsb_cocostudio_ProcessBase_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocostudio_ProcessBase_class, js_cocos2dx_studio_ProcessBase_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "ProcessBase", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocostudio_ProcessBase_class; - p->proto = jsb_cocostudio_ProcessBase_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocostudio_ProcessBase_prototype); + jsb_register_class(cx, jsb_cocostudio_ProcessBase_class, proto, JS::NullPtr()); } JSClass *jsb_cocostudio_Tween_class; @@ -2151,7 +2047,7 @@ bool js_cocos2dx_studio_Tween_play(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocostudio::MovementBoneData*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -2203,7 +2099,7 @@ bool js_cocos2dx_studio_Tween_init(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocostudio::Bone*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -2233,7 +2129,7 @@ bool js_cocos2dx_studio_Tween_setAnimation(JSContext *cx, uint32_t argc, jsval * if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocostudio::ArmatureAnimation*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -2257,7 +2153,7 @@ bool js_cocos2dx_studio_Tween_create(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocostudio::Bone*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -2296,8 +2192,8 @@ bool js_cocos2dx_studio_Tween_constructor(JSContext *cx, uint32_t argc, jsval *v CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -2346,32 +2242,20 @@ void js_register_cocos2dx_studio_Tween(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocostudio_ProcessBase_prototype); jsb_cocostudio_Tween_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocostudio_ProcessBase_prototype), + parent_proto, jsb_cocostudio_Tween_class, js_cocos2dx_studio_Tween_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "Tween", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocostudio_Tween_class; - p->proto = jsb_cocostudio_Tween_prototype; - p->parentProto = jsb_cocostudio_ProcessBase_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocostudio_Tween_prototype); + jsb_register_class(cx, jsb_cocostudio_Tween_class, proto, parent_proto); } JSClass *jsb_cocostudio_ColliderFilter_class; @@ -2407,30 +2291,17 @@ void js_register_cocos2dx_studio_ColliderFilter(JSContext *cx, JS::HandleObject jsb_cocostudio_ColliderFilter_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocostudio_ColliderFilter_class, empty_constructor, 0, properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "ColliderFilter", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocostudio_ColliderFilter_class; - p->proto = jsb_cocostudio_ColliderFilter_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocostudio_ColliderFilter_prototype); + jsb_register_class(cx, jsb_cocostudio_ColliderFilter_class, proto, JS::NullPtr()); } JSClass *jsb_cocostudio_ColliderBody_class; @@ -2466,30 +2337,17 @@ void js_register_cocos2dx_studio_ColliderBody(JSContext *cx, JS::HandleObject gl jsb_cocostudio_ColliderBody_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocostudio_ColliderBody_class, empty_constructor, 0, properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "ColliderBody", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocostudio_ColliderBody_class; - p->proto = jsb_cocostudio_ColliderBody_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocostudio_ColliderBody_prototype); + jsb_register_class(cx, jsb_cocostudio_ColliderBody_class, proto, JS::NullPtr()); } JSClass *jsb_cocostudio_ColliderDetector_class; @@ -2599,7 +2457,7 @@ bool js_cocos2dx_studio_ColliderDetector_init(JSContext *cx, uint32_t argc, jsva JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocostudio::ColliderDetector *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ColliderDetector_init : Invalid Native Object"); @@ -2610,7 +2468,7 @@ bool js_cocos2dx_studio_ColliderDetector_init(JSContext *cx, uint32_t argc, jsva if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocostudio::Bone*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -2671,7 +2529,7 @@ bool js_cocos2dx_studio_ColliderDetector_setBone(JSContext *cx, uint32_t argc, j if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocostudio::Bone*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -2697,7 +2555,7 @@ bool js_cocos2dx_studio_ColliderDetector_create(JSContext *cx, uint32_t argc, js if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocostudio::Bone*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -2778,30 +2636,17 @@ void js_register_cocos2dx_studio_ColliderDetector(JSContext *cx, JS::HandleObjec jsb_cocostudio_ColliderDetector_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocostudio_ColliderDetector_class, empty_constructor, 0, properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "ColliderDetector", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocostudio_ColliderDetector_class; - p->proto = jsb_cocostudio_ColliderDetector_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocostudio_ColliderDetector_prototype); + jsb_register_class(cx, jsb_cocostudio_ColliderDetector_class, proto, JS::NullPtr()); } JSClass *jsb_cocostudio_DecorativeDisplay_class; @@ -2871,7 +2716,7 @@ bool js_cocos2dx_studio_DecorativeDisplay_setDisplay(JSContext *cx, uint32_t arg if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -2917,7 +2762,7 @@ bool js_cocos2dx_studio_DecorativeDisplay_setDisplayData(JSContext *cx, uint32_t if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocostudio::DisplayData*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -2970,7 +2815,7 @@ bool js_cocos2dx_studio_DecorativeDisplay_setColliderDetector(JSContext *cx, uin if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocostudio::ColliderDetector*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -3045,30 +2890,17 @@ void js_register_cocos2dx_studio_DecorativeDisplay(JSContext *cx, JS::HandleObje jsb_cocostudio_DecorativeDisplay_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocostudio_DecorativeDisplay_class, empty_constructor, 0, properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "DecorativeDisplay", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocostudio_DecorativeDisplay_class; - p->proto = jsb_cocostudio_DecorativeDisplay_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocostudio_DecorativeDisplay_prototype); + jsb_register_class(cx, jsb_cocostudio_DecorativeDisplay_class, proto, JS::NullPtr()); } JSClass *jsb_cocostudio_DisplayManager_class; @@ -3156,7 +2988,7 @@ bool js_cocos2dx_studio_DisplayManager_setCurrentDecorativeDisplay(JSContext *cx if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocostudio::DecorativeDisplay*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -3242,7 +3074,7 @@ bool js_cocos2dx_studio_DisplayManager_init(JSContext *cx, uint32_t argc, jsval if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocostudio::Bone*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -3301,7 +3133,7 @@ bool js_cocos2dx_studio_DisplayManager_addDisplay(JSContext *cx, uint32_t argc, JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocostudio::DisplayManager *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_DisplayManager_addDisplay : Invalid Native Object"); @@ -3312,7 +3144,7 @@ bool js_cocos2dx_studio_DisplayManager_addDisplay(JSContext *cx, uint32_t argc, if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -3334,7 +3166,7 @@ bool js_cocos2dx_studio_DisplayManager_addDisplay(JSContext *cx, uint32_t argc, if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocostudio::DisplayData*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -3359,7 +3191,7 @@ bool js_cocos2dx_studio_DisplayManager_containPoint(JSContext *cx, uint32_t argc JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocostudio::DisplayManager *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_DisplayManager_containPoint : Invalid Native Object"); @@ -3409,7 +3241,7 @@ bool js_cocos2dx_studio_DisplayManager_initDisplayList(JSContext *cx, uint32_t a if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocostudio::BoneData*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -3616,7 +3448,7 @@ bool js_cocos2dx_studio_DisplayManager_create(JSContext *cx, uint32_t argc, jsva if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocostudio::Bone*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -3655,8 +3487,8 @@ bool js_cocos2dx_studio_DisplayManager_constructor(JSContext *cx, uint32_t argc, CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -3721,30 +3553,17 @@ void js_register_cocos2dx_studio_DisplayManager(JSContext *cx, JS::HandleObject jsb_cocostudio_DisplayManager_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocostudio_DisplayManager_class, js_cocos2dx_studio_DisplayManager_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "DisplayManager", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocostudio_DisplayManager_class; - p->proto = jsb_cocostudio_DisplayManager_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocostudio_DisplayManager_prototype); + jsb_register_class(cx, jsb_cocostudio_DisplayManager_class, proto, JS::NullPtr()); } JSClass *jsb_cocostudio_Bone_class; @@ -3879,7 +3698,7 @@ bool js_cocos2dx_studio_Bone_addChildBone(JSContext *cx, uint32_t argc, jsval *v if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocostudio::Bone*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -4056,7 +3875,7 @@ bool js_cocos2dx_studio_Bone_setBoneData(JSContext *cx, uint32_t argc, jsval *vp if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocostudio::BoneData*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -4106,7 +3925,7 @@ bool js_cocos2dx_studio_Bone_setParentBone(JSContext *cx, uint32_t argc, jsval * if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocostudio::Bone*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -4127,7 +3946,7 @@ bool js_cocos2dx_studio_Bone_addDisplay(JSContext *cx, uint32_t argc, jsval *vp) JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocostudio::Bone *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_Bone_addDisplay : Invalid Native Object"); @@ -4138,7 +3957,7 @@ bool js_cocos2dx_studio_Bone_addDisplay(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -4160,7 +3979,7 @@ bool js_cocos2dx_studio_Bone_addDisplay(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocostudio::DisplayData*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -4344,7 +4163,7 @@ bool js_cocos2dx_studio_Bone_setArmature(JSContext *cx, uint32_t argc, jsval *vp if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocostudio::Armature*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -4393,7 +4212,7 @@ bool js_cocos2dx_studio_Bone_removeChildBone(JSContext *cx, uint32_t argc, jsval if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocostudio::Bone*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -4422,7 +4241,7 @@ bool js_cocos2dx_studio_Bone_setChildArmature(JSContext *cx, uint32_t argc, jsva if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocostudio::Armature*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -4564,8 +4383,8 @@ bool js_cocos2dx_studio_Bone_constructor(JSContext *cx, uint32_t argc, jsval *vp CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -4640,32 +4459,20 @@ void js_register_cocos2dx_studio_Bone(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Node_prototype); jsb_cocostudio_Bone_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Node_prototype), + parent_proto, jsb_cocostudio_Bone_class, js_cocos2dx_studio_Bone_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "Bone", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocostudio_Bone_class; - p->proto = jsb_cocostudio_Bone_prototype; - p->parentProto = jsb_cocos2d_Node_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocostudio_Bone_prototype); + jsb_register_class(cx, jsb_cocostudio_Bone_class, proto, parent_proto); } JSClass *jsb_cocostudio_BatchNode_class; @@ -4725,32 +4532,20 @@ void js_register_cocos2dx_studio_BatchNode(JSContext *cx, JS::HandleObject globa JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Node_prototype); jsb_cocostudio_BatchNode_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Node_prototype), + parent_proto, jsb_cocostudio_BatchNode_class, empty_constructor, 0, properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "BatchNode", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocostudio_BatchNode_class; - p->proto = jsb_cocostudio_BatchNode_prototype; - p->parentProto = jsb_cocos2d_Node_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocostudio_BatchNode_prototype); + jsb_register_class(cx, jsb_cocostudio_BatchNode_class, proto, parent_proto); } JSClass *jsb_cocostudio_ArmatureAnimation_class; @@ -4892,7 +4687,7 @@ bool js_cocos2dx_studio_ArmatureAnimation_setAnimationData(JSContext *cx, uint32 if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocostudio::AnimationData*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -4985,7 +4780,7 @@ bool js_cocos2dx_studio_ArmatureAnimation_init(JSContext *cx, uint32_t argc, jsv if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocostudio::Armature*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -5131,7 +4926,7 @@ bool js_cocos2dx_studio_ArmatureAnimation_create(JSContext *cx, uint32_t argc, j if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocostudio::Armature*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -5170,8 +4965,8 @@ bool js_cocos2dx_studio_ArmatureAnimation_constructor(JSContext *cx, uint32_t ar CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -5227,32 +5022,20 @@ void js_register_cocos2dx_studio_ArmatureAnimation(JSContext *cx, JS::HandleObje JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocostudio_ProcessBase_prototype); jsb_cocostudio_ArmatureAnimation_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocostudio_ProcessBase_prototype), + parent_proto, jsb_cocostudio_ArmatureAnimation_class, js_cocos2dx_studio_ArmatureAnimation_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "ArmatureAnimation", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocostudio_ArmatureAnimation_class; - p->proto = jsb_cocostudio_ArmatureAnimation_prototype; - p->parentProto = jsb_cocostudio_ProcessBase_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocostudio_ArmatureAnimation_prototype); + jsb_register_class(cx, jsb_cocostudio_ArmatureAnimation_class, proto, parent_proto); } JSClass *jsb_cocostudio_ArmatureDataManager_class; @@ -5312,7 +5095,7 @@ bool js_cocos2dx_studio_ArmatureDataManager_addArmatureData(JSContext *cx, uint3 if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocostudio::ArmatureData*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -5331,7 +5114,7 @@ bool js_cocos2dx_studio_ArmatureDataManager_addArmatureData(JSContext *cx, uint3 if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocostudio::ArmatureData*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -5353,7 +5136,7 @@ bool js_cocos2dx_studio_ArmatureDataManager_addArmatureFileInfo(JSContext *cx, u JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocostudio::ArmatureDataManager *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ArmatureDataManager_addArmatureFileInfo : Invalid Native Object"); @@ -5511,7 +5294,7 @@ bool js_cocos2dx_studio_ArmatureDataManager_addAnimationData(JSContext *cx, uint if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocostudio::AnimationData*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -5530,7 +5313,7 @@ bool js_cocos2dx_studio_ArmatureDataManager_addAnimationData(JSContext *cx, uint if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocostudio::AnimationData*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -5637,7 +5420,7 @@ bool js_cocos2dx_studio_ArmatureDataManager_addTextureData(JSContext *cx, uint32 if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocostudio::TextureData*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -5656,7 +5439,7 @@ bool js_cocos2dx_studio_ArmatureDataManager_addTextureData(JSContext *cx, uint32 if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocostudio::TextureData*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -5806,30 +5589,17 @@ void js_register_cocos2dx_studio_ArmatureDataManager(JSContext *cx, JS::HandleOb jsb_cocostudio_ArmatureDataManager_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocostudio_ArmatureDataManager_class, empty_constructor, 0, properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "ArmatureDataManager", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocostudio_ArmatureDataManager_class; - p->proto = jsb_cocostudio_ArmatureDataManager_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocostudio_ArmatureDataManager_prototype); + jsb_register_class(cx, jsb_cocostudio_ArmatureDataManager_class, proto, JS::NullPtr()); } JSClass *jsb_cocostudio_Armature_class; @@ -5879,7 +5649,7 @@ bool js_cocos2dx_studio_Armature_changeBoneParent(JSContext *cx, uint32_t argc, if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocostudio::Bone*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -5908,7 +5678,7 @@ bool js_cocos2dx_studio_Armature_setAnimation(JSContext *cx, uint32_t argc, jsva if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocostudio::ArmatureAnimation*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -6047,7 +5817,7 @@ bool js_cocos2dx_studio_Armature_removeBone(JSContext *cx, uint32_t argc, jsval if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocostudio::Bone*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -6094,7 +5864,7 @@ bool js_cocos2dx_studio_Armature_init(JSContext *cx, uint32_t argc, jsval *vp) JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocostudio::Armature *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_Armature_init : Invalid Native Object"); @@ -6108,7 +5878,7 @@ bool js_cocos2dx_studio_Armature_init(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocostudio::Bone*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -6152,7 +5922,7 @@ bool js_cocos2dx_studio_Armature_setParentBone(JSContext *cx, uint32_t argc, jsv if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocostudio::Bone*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -6180,7 +5950,7 @@ bool js_cocos2dx_studio_Armature_setBatchNode(JSContext *cx, uint32_t argc, jsva if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocostudio::BatchNode*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -6226,7 +5996,7 @@ bool js_cocos2dx_studio_Armature_setArmatureData(JSContext *cx, uint32_t argc, j if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocostudio::ArmatureData*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -6255,7 +6025,7 @@ bool js_cocos2dx_studio_Armature_addBone(JSContext *cx, uint32_t argc, jsval *vp if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocostudio::Bone*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -6464,7 +6234,7 @@ bool js_cocos2dx_studio_Armature_create(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocostudio::Bone*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -6503,8 +6273,8 @@ bool js_cocos2dx_studio_Armature_constructor(JSContext *cx, uint32_t argc, jsval CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -6587,32 +6357,20 @@ void js_register_cocos2dx_studio_Armature(JSContext *cx, JS::HandleObject global JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Node_prototype); jsb_cocostudio_Armature_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Node_prototype), + parent_proto, jsb_cocostudio_Armature_class, js_cocos2dx_studio_Armature_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "Armature", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocostudio_Armature_class; - p->proto = jsb_cocostudio_Armature_prototype; - p->parentProto = jsb_cocos2d_Node_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocostudio_Armature_prototype); + jsb_register_class(cx, jsb_cocostudio_Armature_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { ccs.Armature.extend = cc.Class.extend; })()"); } @@ -6710,7 +6468,7 @@ bool js_cocos2dx_studio_Skin_setBone(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocostudio::Bone*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -6809,8 +6567,8 @@ bool js_cocos2dx_studio_Skin_constructor(JSContext *cx, uint32_t argc, jsval *vp CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -6859,32 +6617,20 @@ void js_register_cocos2dx_studio_Skin(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Sprite_prototype); jsb_cocostudio_Skin_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Sprite_prototype), + parent_proto, jsb_cocostudio_Skin_class, js_cocos2dx_studio_Skin_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "Skin", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocostudio_Skin_class; - p->proto = jsb_cocostudio_Skin_prototype; - p->parentProto = jsb_cocos2d_Sprite_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocostudio_Skin_prototype); + jsb_register_class(cx, jsb_cocostudio_Skin_class, proto, parent_proto); } JSClass *jsb_cocostudio_ComAttribute_class; @@ -7173,8 +6919,8 @@ bool js_cocos2dx_studio_ComAttribute_constructor(JSContext *cx, uint32_t argc, j CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -7226,32 +6972,20 @@ void js_register_cocos2dx_studio_ComAttribute(JSContext *cx, JS::HandleObject gl JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Component_prototype); jsb_cocostudio_ComAttribute_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Component_prototype), + parent_proto, jsb_cocostudio_ComAttribute_class, js_cocos2dx_studio_ComAttribute_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "ComAttribute", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocostudio_ComAttribute_class; - p->proto = jsb_cocostudio_ComAttribute_prototype; - p->parentProto = jsb_cocos2d_Component_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocostudio_ComAttribute_prototype); + jsb_register_class(cx, jsb_cocostudio_ComAttribute_class, proto, parent_proto); } JSClass *jsb_cocostudio_ComAudio_class; @@ -7390,7 +7124,7 @@ bool js_cocos2dx_studio_ComAudio_stopBackgroundMusic(JSContext *cx, uint32_t arg JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocostudio::ComAudio *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ComAudio_stopBackgroundMusic : Invalid Native Object"); @@ -7526,7 +7260,7 @@ bool js_cocos2dx_studio_ComAudio_playBackgroundMusic(JSContext *cx, uint32_t arg JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocostudio::ComAudio *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ComAudio_playBackgroundMusic : Invalid Native Object"); @@ -7572,7 +7306,7 @@ bool js_cocos2dx_studio_ComAudio_playEffect(JSContext *cx, uint32_t argc, jsval JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocostudio::ComAudio *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ComAudio_playEffect : Invalid Native Object"); @@ -7844,8 +7578,8 @@ bool js_cocos2dx_studio_ComAudio_constructor(JSContext *cx, uint32_t argc, jsval CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -7914,32 +7648,20 @@ void js_register_cocos2dx_studio_ComAudio(JSContext *cx, JS::HandleObject global JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Component_prototype); jsb_cocostudio_ComAudio_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Component_prototype), + parent_proto, jsb_cocostudio_ComAudio_class, js_cocos2dx_studio_ComAudio_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "ComAudio", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocostudio_ComAudio_class; - p->proto = jsb_cocostudio_ComAudio_prototype; - p->parentProto = jsb_cocos2d_Component_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocostudio_ComAudio_prototype); + jsb_register_class(cx, jsb_cocostudio_ComAudio_class, proto, parent_proto); } JSClass *jsb_cocostudio_InputDelegate_class; @@ -8175,30 +7897,17 @@ void js_register_cocos2dx_studio_InputDelegate(JSContext *cx, JS::HandleObject g jsb_cocostudio_InputDelegate_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocostudio_InputDelegate_class, empty_constructor, 0, properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "InputDelegate", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocostudio_InputDelegate_class; - p->proto = jsb_cocostudio_InputDelegate_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocostudio_InputDelegate_prototype); + jsb_register_class(cx, jsb_cocostudio_InputDelegate_class, proto, JS::NullPtr()); } JSClass *jsb_cocostudio_ComController_class; @@ -8241,8 +7950,8 @@ bool js_cocos2dx_studio_ComController_constructor(JSContext *cx, uint32_t argc, CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -8302,32 +8011,20 @@ void js_register_cocos2dx_studio_ComController(JSContext *cx, JS::HandleObject g JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Component_prototype); jsb_cocostudio_ComController_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Component_prototype), + parent_proto, jsb_cocostudio_ComController_class, js_cocos2dx_studio_ComController_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "ComController", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocostudio_ComController_class; - p->proto = jsb_cocostudio_ComController_prototype; - p->parentProto = jsb_cocos2d_Component_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocostudio_ComController_prototype); + jsb_register_class(cx, jsb_cocostudio_ComController_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { ccs.ComController.extend = cc.Class.extend; })()"); } @@ -8348,7 +8045,7 @@ bool js_cocos2dx_studio_ComRender_setNode(JSContext *cx, uint32_t argc, jsval *v if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -8399,7 +8096,7 @@ bool js_cocos2dx_studio_ComRender_create(JSContext *cx, uint32_t argc, jsval *vp if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -8456,7 +8153,7 @@ bool js_cocos2dx_studio_ComRender_constructor(JSContext *cx, uint32_t argc, jsva if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -8479,8 +8176,8 @@ bool js_cocos2dx_studio_ComRender_constructor(JSContext *cx, uint32_t argc, jsva typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); // obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); obj = JS_NewObject(cx, typeClass->jsclass, proto, parent); js_proxy_t* p = jsb_new_proxy(cobj, obj); @@ -8504,8 +8201,8 @@ bool js_cocos2dx_studio_ComRender_constructor(JSContext *cx, uint32_t argc, jsva typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); // obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); obj = JS_NewObject(cx, typeClass->jsclass, proto, parent); js_proxy_t* p = jsb_new_proxy(cobj, obj); @@ -8559,32 +8256,20 @@ void js_register_cocos2dx_studio_ComRender(JSContext *cx, JS::HandleObject globa JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Component_prototype); jsb_cocostudio_ComRender_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Component_prototype), + parent_proto, jsb_cocostudio_ComRender_class, js_cocos2dx_studio_ComRender_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "ComRender", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocostudio_ComRender_class; - p->proto = jsb_cocostudio_ComRender_prototype; - p->parentProto = jsb_cocos2d_Component_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocostudio_ComRender_prototype); + jsb_register_class(cx, jsb_cocostudio_ComRender_class, proto, parent_proto); } JSClass *jsb_cocostudio_timeline_Frame_class; @@ -8649,7 +8334,7 @@ bool js_cocos2dx_studio_Frame_setNode(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -8677,7 +8362,7 @@ bool js_cocos2dx_studio_Frame_setTimeline(JSContext *cx, uint32_t argc, jsval *v if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocostudio::timeline::Timeline*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -8916,30 +8601,17 @@ void js_register_cocos2dx_studio_Frame(JSContext *cx, JS::HandleObject global) { jsb_cocostudio_timeline_Frame_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocostudio_timeline_Frame_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "Frame", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocostudio_timeline_Frame_class; - p->proto = jsb_cocostudio_timeline_Frame_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocostudio_timeline_Frame_prototype); + jsb_register_class(cx, jsb_cocostudio_timeline_Frame_class, proto, JS::NullPtr()); } JSClass *jsb_cocostudio_timeline_VisibleFrame_class; @@ -9020,8 +8692,8 @@ bool js_cocos2dx_studio_VisibleFrame_constructor(JSContext *cx, uint32_t argc, j CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -9066,32 +8738,20 @@ void js_register_cocos2dx_studio_VisibleFrame(JSContext *cx, JS::HandleObject gl JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocostudio_timeline_Frame_prototype); jsb_cocostudio_timeline_VisibleFrame_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocostudio_timeline_Frame_prototype), + parent_proto, jsb_cocostudio_timeline_VisibleFrame_class, js_cocos2dx_studio_VisibleFrame_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "VisibleFrame", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocostudio_timeline_VisibleFrame_class; - p->proto = jsb_cocostudio_timeline_VisibleFrame_prototype; - p->parentProto = jsb_cocostudio_timeline_Frame_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocostudio_timeline_VisibleFrame_prototype); + jsb_register_class(cx, jsb_cocostudio_timeline_VisibleFrame_class, proto, parent_proto); } JSClass *jsb_cocostudio_timeline_TextureFrame_class; @@ -9172,8 +8832,8 @@ bool js_cocos2dx_studio_TextureFrame_constructor(JSContext *cx, uint32_t argc, j CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -9218,32 +8878,20 @@ void js_register_cocos2dx_studio_TextureFrame(JSContext *cx, JS::HandleObject gl JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocostudio_timeline_Frame_prototype); jsb_cocostudio_timeline_TextureFrame_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocostudio_timeline_Frame_prototype), + parent_proto, jsb_cocostudio_timeline_TextureFrame_class, js_cocos2dx_studio_TextureFrame_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "TextureFrame", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocostudio_timeline_TextureFrame_class; - p->proto = jsb_cocostudio_timeline_TextureFrame_prototype; - p->parentProto = jsb_cocostudio_timeline_Frame_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocostudio_timeline_TextureFrame_prototype); + jsb_register_class(cx, jsb_cocostudio_timeline_TextureFrame_class, proto, parent_proto); } JSClass *jsb_cocostudio_timeline_RotationFrame_class; @@ -9324,8 +8972,8 @@ bool js_cocos2dx_studio_RotationFrame_constructor(JSContext *cx, uint32_t argc, CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -9370,32 +9018,20 @@ void js_register_cocos2dx_studio_RotationFrame(JSContext *cx, JS::HandleObject g JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocostudio_timeline_Frame_prototype); jsb_cocostudio_timeline_RotationFrame_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocostudio_timeline_Frame_prototype), + parent_proto, jsb_cocostudio_timeline_RotationFrame_class, js_cocos2dx_studio_RotationFrame_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "RotationFrame", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocostudio_timeline_RotationFrame_class; - p->proto = jsb_cocostudio_timeline_RotationFrame_prototype; - p->parentProto = jsb_cocostudio_timeline_Frame_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocostudio_timeline_RotationFrame_prototype); + jsb_register_class(cx, jsb_cocostudio_timeline_RotationFrame_class, proto, parent_proto); } JSClass *jsb_cocostudio_timeline_SkewFrame_class; @@ -9514,8 +9150,8 @@ bool js_cocos2dx_studio_SkewFrame_constructor(JSContext *cx, uint32_t argc, jsva CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -9562,32 +9198,20 @@ void js_register_cocos2dx_studio_SkewFrame(JSContext *cx, JS::HandleObject globa JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocostudio_timeline_Frame_prototype); jsb_cocostudio_timeline_SkewFrame_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocostudio_timeline_Frame_prototype), + parent_proto, jsb_cocostudio_timeline_SkewFrame_class, js_cocos2dx_studio_SkewFrame_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "SkewFrame", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocostudio_timeline_SkewFrame_class; - p->proto = jsb_cocostudio_timeline_SkewFrame_prototype; - p->parentProto = jsb_cocostudio_timeline_Frame_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocostudio_timeline_SkewFrame_prototype); + jsb_register_class(cx, jsb_cocostudio_timeline_SkewFrame_class, proto, parent_proto); } JSClass *jsb_cocostudio_timeline_RotationSkewFrame_class; @@ -9630,8 +9254,8 @@ bool js_cocos2dx_studio_RotationSkewFrame_constructor(JSContext *cx, uint32_t ar CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -9674,32 +9298,20 @@ void js_register_cocos2dx_studio_RotationSkewFrame(JSContext *cx, JS::HandleObje JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocostudio_timeline_SkewFrame_prototype); jsb_cocostudio_timeline_RotationSkewFrame_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocostudio_timeline_SkewFrame_prototype), + parent_proto, jsb_cocostudio_timeline_RotationSkewFrame_class, js_cocos2dx_studio_RotationSkewFrame_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "RotationSkewFrame", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocostudio_timeline_RotationSkewFrame_class; - p->proto = jsb_cocostudio_timeline_RotationSkewFrame_prototype; - p->parentProto = jsb_cocostudio_timeline_SkewFrame_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocostudio_timeline_RotationSkewFrame_prototype); + jsb_register_class(cx, jsb_cocostudio_timeline_RotationSkewFrame_class, proto, parent_proto); } JSClass *jsb_cocostudio_timeline_PositionFrame_class; @@ -9856,8 +9468,8 @@ bool js_cocos2dx_studio_PositionFrame_constructor(JSContext *cx, uint32_t argc, CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -9906,32 +9518,20 @@ void js_register_cocos2dx_studio_PositionFrame(JSContext *cx, JS::HandleObject g JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocostudio_timeline_Frame_prototype); jsb_cocostudio_timeline_PositionFrame_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocostudio_timeline_Frame_prototype), + parent_proto, jsb_cocostudio_timeline_PositionFrame_class, js_cocos2dx_studio_PositionFrame_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "PositionFrame", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocostudio_timeline_PositionFrame_class; - p->proto = jsb_cocostudio_timeline_PositionFrame_prototype; - p->parentProto = jsb_cocostudio_timeline_Frame_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocostudio_timeline_PositionFrame_prototype); + jsb_register_class(cx, jsb_cocostudio_timeline_PositionFrame_class, proto, parent_proto); } JSClass *jsb_cocostudio_timeline_ScaleFrame_class; @@ -10070,8 +9670,8 @@ bool js_cocos2dx_studio_ScaleFrame_constructor(JSContext *cx, uint32_t argc, jsv CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -10119,32 +9719,20 @@ void js_register_cocos2dx_studio_ScaleFrame(JSContext *cx, JS::HandleObject glob JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocostudio_timeline_Frame_prototype); jsb_cocostudio_timeline_ScaleFrame_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocostudio_timeline_Frame_prototype), + parent_proto, jsb_cocostudio_timeline_ScaleFrame_class, js_cocos2dx_studio_ScaleFrame_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "ScaleFrame", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocostudio_timeline_ScaleFrame_class; - p->proto = jsb_cocostudio_timeline_ScaleFrame_prototype; - p->parentProto = jsb_cocostudio_timeline_Frame_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocostudio_timeline_ScaleFrame_prototype); + jsb_register_class(cx, jsb_cocostudio_timeline_ScaleFrame_class, proto, parent_proto); } JSClass *jsb_cocostudio_timeline_AnchorPointFrame_class; @@ -10225,8 +9813,8 @@ bool js_cocos2dx_studio_AnchorPointFrame_constructor(JSContext *cx, uint32_t arg CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -10271,32 +9859,20 @@ void js_register_cocos2dx_studio_AnchorPointFrame(JSContext *cx, JS::HandleObjec JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocostudio_timeline_Frame_prototype); jsb_cocostudio_timeline_AnchorPointFrame_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocostudio_timeline_Frame_prototype), + parent_proto, jsb_cocostudio_timeline_AnchorPointFrame_class, js_cocos2dx_studio_AnchorPointFrame_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "AnchorPointFrame", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocostudio_timeline_AnchorPointFrame_class; - p->proto = jsb_cocostudio_timeline_AnchorPointFrame_prototype; - p->parentProto = jsb_cocostudio_timeline_Frame_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocostudio_timeline_AnchorPointFrame_prototype); + jsb_register_class(cx, jsb_cocostudio_timeline_AnchorPointFrame_class, proto, parent_proto); } JSClass *jsb_cocostudio_timeline_InnerActionFrame_class; @@ -10531,8 +10107,8 @@ bool js_cocos2dx_studio_InnerActionFrame_constructor(JSContext *cx, uint32_t arg CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -10585,32 +10161,20 @@ void js_register_cocos2dx_studio_InnerActionFrame(JSContext *cx, JS::HandleObjec JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocostudio_timeline_Frame_prototype); jsb_cocostudio_timeline_InnerActionFrame_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocostudio_timeline_Frame_prototype), + parent_proto, jsb_cocostudio_timeline_InnerActionFrame_class, js_cocos2dx_studio_InnerActionFrame_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "InnerActionFrame", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocostudio_timeline_InnerActionFrame_class; - p->proto = jsb_cocostudio_timeline_InnerActionFrame_prototype; - p->parentProto = jsb_cocostudio_timeline_Frame_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocostudio_timeline_InnerActionFrame_prototype); + jsb_register_class(cx, jsb_cocostudio_timeline_InnerActionFrame_class, proto, parent_proto); } JSClass *jsb_cocostudio_timeline_ColorFrame_class; @@ -10691,8 +10255,8 @@ bool js_cocos2dx_studio_ColorFrame_constructor(JSContext *cx, uint32_t argc, jsv CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -10737,32 +10301,20 @@ void js_register_cocos2dx_studio_ColorFrame(JSContext *cx, JS::HandleObject glob JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocostudio_timeline_Frame_prototype); jsb_cocostudio_timeline_ColorFrame_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocostudio_timeline_Frame_prototype), + parent_proto, jsb_cocostudio_timeline_ColorFrame_class, js_cocos2dx_studio_ColorFrame_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "ColorFrame", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocostudio_timeline_ColorFrame_class; - p->proto = jsb_cocostudio_timeline_ColorFrame_prototype; - p->parentProto = jsb_cocostudio_timeline_Frame_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocostudio_timeline_ColorFrame_prototype); + jsb_register_class(cx, jsb_cocostudio_timeline_ColorFrame_class, proto, parent_proto); } JSClass *jsb_cocostudio_timeline_AlphaFrame_class; @@ -10843,8 +10395,8 @@ bool js_cocos2dx_studio_AlphaFrame_constructor(JSContext *cx, uint32_t argc, jsv CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -10889,32 +10441,20 @@ void js_register_cocos2dx_studio_AlphaFrame(JSContext *cx, JS::HandleObject glob JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocostudio_timeline_Frame_prototype); jsb_cocostudio_timeline_AlphaFrame_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocostudio_timeline_Frame_prototype), + parent_proto, jsb_cocostudio_timeline_AlphaFrame_class, js_cocos2dx_studio_AlphaFrame_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "AlphaFrame", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocostudio_timeline_AlphaFrame_class; - p->proto = jsb_cocostudio_timeline_AlphaFrame_prototype; - p->parentProto = jsb_cocostudio_timeline_Frame_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocostudio_timeline_AlphaFrame_prototype); + jsb_register_class(cx, jsb_cocostudio_timeline_AlphaFrame_class, proto, parent_proto); } JSClass *jsb_cocostudio_timeline_EventFrame_class; @@ -11011,8 +10551,8 @@ bool js_cocos2dx_studio_EventFrame_constructor(JSContext *cx, uint32_t argc, jsv CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -11058,32 +10598,20 @@ void js_register_cocos2dx_studio_EventFrame(JSContext *cx, JS::HandleObject glob JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocostudio_timeline_Frame_prototype); jsb_cocostudio_timeline_EventFrame_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocostudio_timeline_Frame_prototype), + parent_proto, jsb_cocostudio_timeline_EventFrame_class, js_cocos2dx_studio_EventFrame_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "EventFrame", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocostudio_timeline_EventFrame_class; - p->proto = jsb_cocostudio_timeline_EventFrame_prototype; - p->parentProto = jsb_cocostudio_timeline_Frame_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocostudio_timeline_EventFrame_prototype); + jsb_register_class(cx, jsb_cocostudio_timeline_EventFrame_class, proto, parent_proto); } JSClass *jsb_cocostudio_timeline_ZOrderFrame_class; @@ -11164,8 +10692,8 @@ bool js_cocos2dx_studio_ZOrderFrame_constructor(JSContext *cx, uint32_t argc, js CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -11210,32 +10738,20 @@ void js_register_cocos2dx_studio_ZOrderFrame(JSContext *cx, JS::HandleObject glo JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocostudio_timeline_Frame_prototype); jsb_cocostudio_timeline_ZOrderFrame_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocostudio_timeline_Frame_prototype), + parent_proto, jsb_cocostudio_timeline_ZOrderFrame_class, js_cocos2dx_studio_ZOrderFrame_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "ZOrderFrame", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocostudio_timeline_ZOrderFrame_class; - p->proto = jsb_cocostudio_timeline_ZOrderFrame_prototype; - p->parentProto = jsb_cocostudio_timeline_Frame_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocostudio_timeline_ZOrderFrame_prototype); + jsb_register_class(cx, jsb_cocostudio_timeline_ZOrderFrame_class, proto, parent_proto); } JSClass *jsb_cocostudio_timeline_BlendFuncFrame_class; @@ -11316,8 +10832,8 @@ bool js_cocos2dx_studio_BlendFuncFrame_constructor(JSContext *cx, uint32_t argc, CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -11362,32 +10878,20 @@ void js_register_cocos2dx_studio_BlendFuncFrame(JSContext *cx, JS::HandleObject JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocostudio_timeline_Frame_prototype); jsb_cocostudio_timeline_BlendFuncFrame_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocostudio_timeline_Frame_prototype), + parent_proto, jsb_cocostudio_timeline_BlendFuncFrame_class, js_cocos2dx_studio_BlendFuncFrame_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "BlendFuncFrame", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocostudio_timeline_BlendFuncFrame_class; - p->proto = jsb_cocostudio_timeline_BlendFuncFrame_prototype; - p->parentProto = jsb_cocostudio_timeline_Frame_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocostudio_timeline_BlendFuncFrame_prototype); + jsb_register_class(cx, jsb_cocostudio_timeline_BlendFuncFrame_class, proto, parent_proto); } JSClass *jsb_cocostudio_timeline_Timeline_class; @@ -11452,7 +10956,7 @@ bool js_cocos2dx_studio_Timeline_setNode(JSContext *cx, uint32_t argc, jsval *vp if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -11506,7 +11010,7 @@ bool js_cocos2dx_studio_Timeline_insertFrame(JSContext *cx, uint32_t argc, jsval if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocostudio::timeline::Frame*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -11555,7 +11059,7 @@ bool js_cocos2dx_studio_Timeline_addFrame(JSContext *cx, uint32_t argc, jsval *v if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocostudio::timeline::Frame*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -11644,7 +11148,7 @@ bool js_cocos2dx_studio_Timeline_removeFrame(JSContext *cx, uint32_t argc, jsval if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocostudio::timeline::Frame*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -11672,7 +11176,7 @@ bool js_cocos2dx_studio_Timeline_setActionTimeline(JSContext *cx, uint32_t argc, if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocostudio::timeline::ActionTimeline*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -11743,8 +11247,8 @@ bool js_cocos2dx_studio_Timeline_constructor(JSContext *cx, uint32_t argc, jsval CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -11800,30 +11304,17 @@ void js_register_cocos2dx_studio_Timeline(JSContext *cx, JS::HandleObject global jsb_cocostudio_timeline_Timeline_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocostudio_timeline_Timeline_class, js_cocos2dx_studio_Timeline_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "Timeline", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocostudio_timeline_Timeline_class; - p->proto = jsb_cocostudio_timeline_Timeline_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocostudio_timeline_Timeline_prototype); + jsb_register_class(cx, jsb_cocostudio_timeline_Timeline_class, proto, JS::NullPtr()); } JSClass *jsb_cocostudio_timeline_ActionTimelineData_class; @@ -11930,8 +11421,8 @@ bool js_cocos2dx_studio_ActionTimelineData_constructor(JSContext *cx, uint32_t a CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -11977,30 +11468,17 @@ void js_register_cocos2dx_studio_ActionTimelineData(JSContext *cx, JS::HandleObj jsb_cocostudio_timeline_ActionTimelineData_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocostudio_timeline_ActionTimelineData_class, js_cocos2dx_studio_ActionTimelineData_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "ActionTimelineData", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocostudio_timeline_ActionTimelineData_class; - p->proto = jsb_cocostudio_timeline_ActionTimelineData_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocostudio_timeline_ActionTimelineData_prototype); + jsb_register_class(cx, jsb_cocostudio_timeline_ActionTimelineData_class, proto, JS::NullPtr()); } JSClass *jsb_cocostudio_timeline_ActionTimeline_class; @@ -12019,7 +11497,8 @@ bool js_cocos2dx_studio_ActionTimeline_setFrameEventCallFunc(JSContext *cx, uint do { if(JS_TypeOfValue(cx, args.get(0)) == JSTYPE_FUNCTION) { - std::shared_ptr func(new JSFunctionWrapper(cx, args.thisv().toObjectOrNull(), args.get(0))); + JS::RootedObject jstarget(cx, args.thisv().toObjectOrNull()); + std::shared_ptr func(new JSFunctionWrapper(cx, jstarget, args.get(0))); auto lambda = [=](cocostudio::timeline::Frame* larg0) -> void { JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET jsval largv[1]; @@ -12085,7 +11564,8 @@ bool js_cocos2dx_studio_ActionTimeline_setAnimationEndCallFunc(JSContext *cx, ui do { if(JS_TypeOfValue(cx, args.get(1)) == JSTYPE_FUNCTION) { - std::shared_ptr func(new JSFunctionWrapper(cx, args.thisv().toObjectOrNull(), args.get(1))); + JS::RootedObject jstarget(cx, args.thisv().toObjectOrNull()); + std::shared_ptr func(new JSFunctionWrapper(cx, jstarget, args.get(1))); auto lambda = [=]() -> void { JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET JS::RootedValue rval(cx); @@ -12125,7 +11605,7 @@ bool js_cocos2dx_studio_ActionTimeline_addTimeline(JSContext *cx, uint32_t argc, if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocostudio::timeline::Timeline*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -12223,7 +11703,7 @@ bool js_cocos2dx_studio_ActionTimeline_removeTimeline(JSContext *cx, uint32_t ar if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocostudio::timeline::Timeline*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -12250,7 +11730,8 @@ bool js_cocos2dx_studio_ActionTimeline_setLastFrameCallFunc(JSContext *cx, uint3 do { if(JS_TypeOfValue(cx, args.get(0)) == JSTYPE_FUNCTION) { - std::shared_ptr func(new JSFunctionWrapper(cx, args.thisv().toObjectOrNull(), args.get(0))); + JS::RootedObject jstarget(cx, args.thisv().toObjectOrNull()); + std::shared_ptr func(new JSFunctionWrapper(cx, jstarget, args.get(0))); auto lambda = [=]() -> void { JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET JS::RootedValue rval(cx); @@ -12393,7 +11874,8 @@ bool js_cocos2dx_studio_ActionTimeline_addFrameEndCallFunc(JSContext *cx, uint32 do { if(JS_TypeOfValue(cx, args.get(2)) == JSTYPE_FUNCTION) { - std::shared_ptr func(new JSFunctionWrapper(cx, args.thisv().toObjectOrNull(), args.get(2))); + JS::RootedObject jstarget(cx, args.thisv().toObjectOrNull()); + std::shared_ptr func(new JSFunctionWrapper(cx, jstarget, args.get(2))); auto lambda = [=]() -> void { JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET JS::RootedValue rval(cx); @@ -12560,7 +12042,7 @@ bool js_cocos2dx_studio_ActionTimeline_gotoFrameAndPlay(JSContext *cx, uint32_t JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocostudio::timeline::ActionTimeline *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ActionTimeline_gotoFrameAndPlay : Invalid Native Object"); @@ -12795,8 +12277,8 @@ bool js_cocos2dx_studio_ActionTimeline_constructor(JSContext *cx, uint32_t argc, CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -12870,32 +12352,20 @@ void js_register_cocos2dx_studio_ActionTimeline(JSContext *cx, JS::HandleObject JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Action_prototype); jsb_cocostudio_timeline_ActionTimeline_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Action_prototype), + parent_proto, jsb_cocostudio_timeline_ActionTimeline_class, js_cocos2dx_studio_ActionTimeline_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "ActionTimeline", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocostudio_timeline_ActionTimeline_class; - p->proto = jsb_cocostudio_timeline_ActionTimeline_prototype; - p->parentProto = jsb_cocos2d_Action_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocostudio_timeline_ActionTimeline_prototype); + jsb_register_class(cx, jsb_cocostudio_timeline_ActionTimeline_class, proto, parent_proto); } JSClass *jsb_cocostudio_timeline_BoneNode_class; @@ -12926,7 +12396,7 @@ bool js_cocos2dx_studio_BoneNode_getChildBones(JSContext *cx, uint32_t argc, jsv JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocostudio::timeline::BoneNode *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_BoneNode_getChildBones : Invalid Native Object"); @@ -13072,7 +12542,7 @@ bool js_cocos2dx_studio_BoneNode_displaySkin(JSContext *cx, uint32_t argc, jsval JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocostudio::timeline::BoneNode *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_BoneNode_displaySkin : Invalid Native Object"); @@ -13096,7 +12566,7 @@ bool js_cocos2dx_studio_BoneNode_displaySkin(JSContext *cx, uint32_t argc, jsval if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocostudio::timeline::SkinNode*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -13138,7 +12608,7 @@ bool js_cocos2dx_studio_BoneNode_addSkin(JSContext *cx, uint32_t argc, jsval *vp JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocostudio::timeline::BoneNode *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_BoneNode_addSkin : Invalid Native Object"); @@ -13149,7 +12619,7 @@ bool js_cocos2dx_studio_BoneNode_addSkin(JSContext *cx, uint32_t argc, jsval *vp if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocostudio::timeline::SkinNode*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -13172,7 +12642,7 @@ bool js_cocos2dx_studio_BoneNode_addSkin(JSContext *cx, uint32_t argc, jsval *vp if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocostudio::timeline::SkinNode*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -13241,7 +12711,7 @@ bool js_cocos2dx_studio_BoneNode_getSkins(JSContext *cx, uint32_t argc, jsval *v JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocostudio::timeline::BoneNode *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_BoneNode_getSkins : Invalid Native Object"); @@ -13422,8 +12892,8 @@ bool js_cocos2dx_studio_BoneNode_constructor(JSContext *cx, uint32_t argc, jsval CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -13502,32 +12972,20 @@ void js_register_cocos2dx_studio_BoneNode(JSContext *cx, JS::HandleObject global JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Node_prototype); jsb_cocostudio_timeline_BoneNode_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Node_prototype), + parent_proto, jsb_cocostudio_timeline_BoneNode_class, js_cocos2dx_studio_BoneNode_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "BoneNode", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocostudio_timeline_BoneNode_class; - p->proto = jsb_cocostudio_timeline_BoneNode_prototype; - p->parentProto = jsb_cocos2d_Node_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocostudio_timeline_BoneNode_prototype); + jsb_register_class(cx, jsb_cocostudio_timeline_BoneNode_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { ccs.BoneNode.extend = cc.Class.extend; })()"); } @@ -13570,7 +13028,7 @@ bool js_cocos2dx_studio_SkeletonNode_changeSkins(JSContext *cx, uint32_t argc, j JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocostudio::timeline::SkeletonNode *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_SkeletonNode_changeSkins : Invalid Native Object"); @@ -13676,8 +13134,8 @@ bool js_cocos2dx_studio_SkeletonNode_constructor(JSContext *cx, uint32_t argc, j CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -13741,32 +13199,20 @@ void js_register_cocos2dx_studio_SkeletonNode(JSContext *cx, JS::HandleObject gl JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocostudio_timeline_BoneNode_prototype); jsb_cocostudio_timeline_SkeletonNode_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocostudio_timeline_BoneNode_prototype), + parent_proto, jsb_cocostudio_timeline_SkeletonNode_class, js_cocos2dx_studio_SkeletonNode_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "SkeletonNode", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocostudio_timeline_SkeletonNode_class; - p->proto = jsb_cocostudio_timeline_SkeletonNode_prototype; - p->parentProto = jsb_cocostudio_timeline_BoneNode_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocostudio_timeline_SkeletonNode_prototype); + jsb_register_class(cx, jsb_cocostudio_timeline_SkeletonNode_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { ccs.SkeletonNode.extend = cc.Class.extend; })()"); } @@ -13886,8 +13332,8 @@ bool js_cocos2dx_studio_ComExtensionData_constructor(JSContext *cx, uint32_t arg CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -13934,32 +13380,20 @@ void js_register_cocos2dx_studio_ComExtensionData(JSContext *cx, JS::HandleObjec JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Component_prototype); jsb_cocostudio_ComExtensionData_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Component_prototype), + parent_proto, jsb_cocostudio_ComExtensionData_class, js_cocos2dx_studio_ComExtensionData_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "ComExtensionData", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocostudio_ComExtensionData_class; - p->proto = jsb_cocostudio_ComExtensionData_prototype; - p->parentProto = jsb_cocos2d_Component_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocostudio_ComExtensionData_prototype); + jsb_register_class(cx, jsb_cocostudio_ComExtensionData_class, proto, parent_proto); } void register_all_cocos2dx_studio(JSContext* cx, JS::HandleObject obj) { diff --git a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_ui_auto.cpp b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_ui_auto.cpp index be7803f52b..54bf6dfde8 100644 --- a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_ui_auto.cpp +++ b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_ui_auto.cpp @@ -20,8 +20,8 @@ static bool dummy_constructor(JSContext *cx, uint32_t argc, jsval *vp) { typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject _tmp(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(_tmp)); @@ -127,7 +127,7 @@ bool js_cocos2dx_ui_LayoutParameter_copyProperties(JSContext *cx, uint32_t argc, if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ui::LayoutParameter*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -178,8 +178,8 @@ bool js_cocos2dx_ui_LayoutParameter_constructor(JSContext *cx, uint32_t argc, js CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -226,30 +226,17 @@ void js_register_cocos2dx_ui_LayoutParameter(JSContext *cx, JS::HandleObject glo jsb_cocos2d_ui_LayoutParameter_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocos2d_ui_LayoutParameter_class, js_cocos2dx_ui_LayoutParameter_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "LayoutParameter", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_ui_LayoutParameter_class; - p->proto = jsb_cocos2d_ui_LayoutParameter_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ui_LayoutParameter_prototype); + jsb_register_class(cx, jsb_cocos2d_ui_LayoutParameter_class, proto, JS::NullPtr()); } JSClass *jsb_cocos2d_ui_LinearLayoutParameter_class; @@ -330,8 +317,8 @@ bool js_cocos2dx_ui_LinearLayoutParameter_constructor(JSContext *cx, uint32_t ar CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -376,32 +363,20 @@ void js_register_cocos2dx_ui_LinearLayoutParameter(JSContext *cx, JS::HandleObje JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ui_LayoutParameter_prototype); jsb_cocos2d_ui_LinearLayoutParameter_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ui_LayoutParameter_prototype), + parent_proto, jsb_cocos2d_ui_LinearLayoutParameter_class, js_cocos2dx_ui_LinearLayoutParameter_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "LinearLayoutParameter", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_ui_LinearLayoutParameter_class; - p->proto = jsb_cocos2d_ui_LinearLayoutParameter_prototype; - p->parentProto = jsb_cocos2d_ui_LayoutParameter_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ui_LinearLayoutParameter_prototype); + jsb_register_class(cx, jsb_cocos2d_ui_LinearLayoutParameter_class, proto, parent_proto); } JSClass *jsb_cocos2d_ui_RelativeLayoutParameter_class; @@ -558,8 +533,8 @@ bool js_cocos2dx_ui_RelativeLayoutParameter_constructor(JSContext *cx, uint32_t CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -608,32 +583,20 @@ void js_register_cocos2dx_ui_RelativeLayoutParameter(JSContext *cx, JS::HandleOb JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ui_LayoutParameter_prototype); jsb_cocos2d_ui_RelativeLayoutParameter_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ui_LayoutParameter_prototype), + parent_proto, jsb_cocos2d_ui_RelativeLayoutParameter_class, js_cocos2dx_ui_RelativeLayoutParameter_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "RelativeLayoutParameter", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_ui_RelativeLayoutParameter_class; - p->proto = jsb_cocos2d_ui_RelativeLayoutParameter_prototype; - p->parentProto = jsb_cocos2d_ui_LayoutParameter_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ui_RelativeLayoutParameter_prototype); + jsb_register_class(cx, jsb_cocos2d_ui_RelativeLayoutParameter_class, proto, parent_proto); } JSClass *jsb_cocos2d_ui_Widget_class; @@ -1026,7 +989,8 @@ bool js_cocos2dx_ui_Widget_addCCSEventListener(JSContext *cx, uint32_t argc, jsv do { if(JS_TypeOfValue(cx, args.get(0)) == JSTYPE_FUNCTION) { - std::shared_ptr func(new JSFunctionWrapper(cx, args.thisv().toObjectOrNull(), args.get(0))); + JS::RootedObject jstarget(cx, args.thisv().toObjectOrNull()); + std::shared_ptr func(new JSFunctionWrapper(cx, jstarget, args.get(0))); auto lambda = [=](cocos2d::Ref* larg0, int larg1) -> void { JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET jsval largv[2]; @@ -1134,7 +1098,7 @@ bool js_cocos2dx_ui_Widget_findNextFocusedWidget(JSContext *cx, uint32_t argc, j if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::ui::Widget*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -1471,7 +1435,7 @@ bool js_cocos2dx_ui_Widget_setLayoutParameter(JSContext *cx, uint32_t argc, jsva if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ui::LayoutParameter*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -1581,7 +1545,7 @@ bool js_cocos2dx_ui_Widget_dispatchFocusEvent(JSContext *cx, uint32_t argc, jsva if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ui::Widget*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -1590,7 +1554,7 @@ bool js_cocos2dx_ui_Widget_dispatchFocusEvent(JSContext *cx, uint32_t argc, jsva if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::ui::Widget*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -1659,7 +1623,7 @@ bool js_cocos2dx_ui_Widget_hitTest(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (const cocos2d::Camera*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -1668,7 +1632,7 @@ bool js_cocos2dx_ui_Widget_hitTest(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(2).isNull()) { arg2 = nullptr; break; } if (!args.get(2).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(2).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(2).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg2 = (cocos2d::Vec3*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg2, cx, false, "Invalid Native Object"); @@ -1725,7 +1689,7 @@ bool js_cocos2dx_ui_Widget_updateSizeAndPosition(JSContext *cx, uint32_t argc, j JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::ui::Widget *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Widget_updateSizeAndPosition : Invalid Native Object"); @@ -1766,7 +1730,7 @@ bool js_cocos2dx_ui_Widget_onFocusChange(JSContext *cx, uint32_t argc, jsval *vp if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ui::Widget*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -1775,7 +1739,7 @@ bool js_cocos2dx_ui_Widget_onFocusChange(JSContext *cx, uint32_t argc, jsval *vp if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::ui::Widget*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -1843,6 +1807,56 @@ bool js_cocos2dx_ui_Widget_getCallbackType(JSContext *cx, uint32_t argc, jsval * JS_ReportError(cx, "js_cocos2dx_ui_Widget_getCallbackType : wrong number of arguments: %d, was expecting %d", argc, 0); return false; } +bool js_cocos2dx_ui_Widget_addTouchEventListener(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::Widget* cobj = (cocos2d::ui::Widget *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Widget_addTouchEventListener : Invalid Native Object"); + if (argc == 1) { + std::function arg0; + do { + if(JS_TypeOfValue(cx, args.get(0)) == JSTYPE_FUNCTION) + { + JS::RootedObject jstarget(cx, args.thisv().toObjectOrNull()); + std::shared_ptr func(new JSFunctionWrapper(cx, jstarget, args.get(0))); + auto lambda = [=](cocos2d::Ref* larg0, cocos2d::ui::Widget::TouchEventType larg1) -> void { + JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET + jsval largv[2]; + do { + if (larg0) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Ref*)larg0); + largv[0] = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + largv[0] = JSVAL_NULL; + } + } while (0); + largv[1] = int32_to_jsval(cx, (int)larg1); + JS::RootedValue rval(cx); + bool succeed = func->invoke(2, &largv[0], &rval); + if (!succeed && JS_IsExceptionPending(cx)) { + JS_ReportPendingException(cx); + } + }; + arg0 = lambda; + } + else + { + arg0 = nullptr; + } + } while(0) + ; + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Widget_addTouchEventListener : Error processing arguments"); + cobj->addTouchEventListener(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Widget_addTouchEventListener : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} bool js_cocos2dx_ui_Widget_getTouchEndPosition(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); @@ -1896,7 +1910,7 @@ bool js_cocos2dx_ui_Widget_propagateTouchEvent(JSContext *cx, uint32_t argc, jsv if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::ui::Widget*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -1905,7 +1919,7 @@ bool js_cocos2dx_ui_Widget_propagateTouchEvent(JSContext *cx, uint32_t argc, jsv if (args.get(2).isNull()) { arg2 = nullptr; break; } if (!args.get(2).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(2).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(2).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg2 = (cocos2d::Touch*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg2, cx, false, "Invalid Native Object"); @@ -1932,7 +1946,8 @@ bool js_cocos2dx_ui_Widget_addClickEventListener(JSContext *cx, uint32_t argc, j do { if(JS_TypeOfValue(cx, args.get(0)) == JSTYPE_FUNCTION) { - std::shared_ptr func(new JSFunctionWrapper(cx, args.thisv().toObjectOrNull(), args.get(0))); + JS::RootedObject jstarget(cx, args.thisv().toObjectOrNull()); + std::shared_ptr func(new JSFunctionWrapper(cx, jstarget, args.get(0))); auto lambda = [=](cocos2d::Ref* larg0) -> void { JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET jsval largv[1]; @@ -2062,7 +2077,7 @@ bool js_cocos2dx_ui_Widget_interceptTouchEvent(JSContext *cx, uint32_t argc, jsv if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::ui::Widget*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -2071,7 +2086,7 @@ bool js_cocos2dx_ui_Widget_interceptTouchEvent(JSContext *cx, uint32_t argc, jsv if (args.get(2).isNull()) { arg2 = nullptr; break; } if (!args.get(2).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(2).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(2).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg2 = (cocos2d::Touch*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg2, cx, false, "Invalid Native Object"); @@ -2217,8 +2232,8 @@ bool js_cocos2dx_ui_Widget_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -2325,6 +2340,7 @@ void js_register_cocos2dx_ui_Widget(JSContext *cx, JS::HandleObject global) { JS_FN("getTouchMovePosition", js_cocos2dx_ui_Widget_getTouchMovePosition, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getSizeType", js_cocos2dx_ui_Widget_getSizeType, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getCallbackType", js_cocos2dx_ui_Widget_getCallbackType, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("addTouchEventListener", js_cocos2dx_ui_Widget_addTouchEventListener, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getTouchEndPosition", js_cocos2dx_ui_Widget_getTouchEndPosition, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getPositionPercent", js_cocos2dx_ui_Widget_getPositionPercent, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("propagateTouchEvent", js_cocos2dx_ui_Widget_propagateTouchEvent, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), @@ -2348,32 +2364,20 @@ void js_register_cocos2dx_ui_Widget(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ProtectedNode_prototype); jsb_cocos2d_ui_Widget_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ProtectedNode_prototype), + parent_proto, jsb_cocos2d_ui_Widget_class, js_cocos2dx_ui_Widget_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "Widget", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_ui_Widget_class; - p->proto = jsb_cocos2d_ui_Widget_prototype; - p->parentProto = jsb_cocos2d_ProtectedNode_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ui_Widget_prototype); + jsb_register_class(cx, jsb_cocos2d_ui_Widget_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { ccui.Widget.extend = cc.Class.extend; })()"); } @@ -2526,7 +2530,7 @@ bool js_cocos2dx_ui_Layout_getRenderFile(JSContext *cx, uint32_t argc, jsval *vp if (argc == 0) { cocos2d::ResouceData ret = cobj->getRenderFile(); jsval jsret = JSVAL_NULL; - #pragma warning NO CONVERSION FROM NATIVE FOR ResouceData; + jsret = resoucedata_to_jsval(cx, ret); args.rval().set(jsret); return true; } @@ -2661,7 +2665,7 @@ bool js_cocos2dx_ui_Layout_setBackGroundColor(JSContext *cx, uint32_t argc, jsva JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::ui::Layout *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Layout_setBackGroundColor : Invalid Native Object"); @@ -3101,8 +3105,8 @@ bool js_cocos2dx_ui_Layout_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -3197,32 +3201,20 @@ void js_register_cocos2dx_ui_Layout(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ui_Widget_prototype); jsb_cocos2d_ui_Layout_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ui_Widget_prototype), + parent_proto, jsb_cocos2d_ui_Layout_class, js_cocos2dx_ui_Layout_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "Layout", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_ui_Layout_class; - p->proto = jsb_cocos2d_ui_Layout_prototype; - p->parentProto = jsb_cocos2d_ui_Widget_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ui_Layout_prototype); + jsb_register_class(cx, jsb_cocos2d_ui_Layout_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { ccui.Layout.extend = cc.Class.extend; })()"); } @@ -3397,7 +3389,7 @@ bool js_cocos2dx_ui_Button_getDisabledFile(JSContext *cx, uint32_t argc, jsval * if (argc == 0) { cocos2d::ResouceData ret = cobj->getDisabledFile(); jsval jsret = JSVAL_NULL; - #pragma warning NO CONVERSION FROM NATIVE FOR ResouceData; + jsret = resoucedata_to_jsval(cx, ret); args.rval().set(jsret); return true; } @@ -3471,7 +3463,7 @@ bool js_cocos2dx_ui_Button_getNormalFile(JSContext *cx, uint32_t argc, jsval *vp if (argc == 0) { cocos2d::ResouceData ret = cobj->getNormalFile(); jsval jsret = JSVAL_NULL; - #pragma warning NO CONVERSION FROM NATIVE FOR ResouceData; + jsret = resoucedata_to_jsval(cx, ret); args.rval().set(jsret); return true; } @@ -3769,7 +3761,7 @@ bool js_cocos2dx_ui_Button_setTitleAlignment(JSContext *cx, uint32_t argc, jsval JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::ui::Button *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Button_setTitleAlignment : Invalid Native Object"); @@ -3945,7 +3937,7 @@ bool js_cocos2dx_ui_Button_getPressedFile(JSContext *cx, uint32_t argc, jsval *v if (argc == 0) { cocos2d::ResouceData ret = cobj->getPressedFile(); jsval jsret = JSVAL_NULL; - #pragma warning NO CONVERSION FROM NATIVE FOR ResouceData; + jsret = resoucedata_to_jsval(cx, ret); args.rval().set(jsret); return true; } @@ -4228,8 +4220,8 @@ bool js_cocos2dx_ui_Button_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -4327,32 +4319,20 @@ void js_register_cocos2dx_ui_Button(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ui_Widget_prototype); jsb_cocos2d_ui_Button_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ui_Widget_prototype), + parent_proto, jsb_cocos2d_ui_Button_class, js_cocos2dx_ui_Button_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "Button", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_ui_Button_class; - p->proto = jsb_cocos2d_ui_Button_prototype; - p->parentProto = jsb_cocos2d_ui_Widget_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ui_Button_prototype); + jsb_register_class(cx, jsb_cocos2d_ui_Button_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { ccui.Button.extend = cc.Class.extend; })()"); } @@ -4369,7 +4349,7 @@ bool js_cocos2dx_ui_AbstractCheckButton_getBackDisabledFile(JSContext *cx, uint3 if (argc == 0) { cocos2d::ResouceData ret = cobj->getBackDisabledFile(); jsval jsret = JSVAL_NULL; - #pragma warning NO CONVERSION FROM NATIVE FOR ResouceData; + jsret = resoucedata_to_jsval(cx, ret); args.rval().set(jsret); return true; } @@ -4387,7 +4367,7 @@ bool js_cocos2dx_ui_AbstractCheckButton_getCrossDisabeldFile(JSContext *cx, uint if (argc == 0) { cocos2d::ResouceData ret = cobj->getCrossDisabeldFile(); jsval jsret = JSVAL_NULL; - #pragma warning NO CONVERSION FROM NATIVE FOR ResouceData; + jsret = resoucedata_to_jsval(cx, ret); args.rval().set(jsret); return true; } @@ -4465,7 +4445,7 @@ bool js_cocos2dx_ui_AbstractCheckButton_getCrossNormalFile(JSContext *cx, uint32 if (argc == 0) { cocos2d::ResouceData ret = cobj->getCrossNormalFile(); jsval jsret = JSVAL_NULL; - #pragma warning NO CONVERSION FROM NATIVE FOR ResouceData; + jsret = resoucedata_to_jsval(cx, ret); args.rval().set(jsret); return true; } @@ -4503,7 +4483,7 @@ bool js_cocos2dx_ui_AbstractCheckButton_getBackPressedFile(JSContext *cx, uint32 if (argc == 0) { cocos2d::ResouceData ret = cobj->getBackPressedFile(); jsval jsret = JSVAL_NULL; - #pragma warning NO CONVERSION FROM NATIVE FOR ResouceData; + jsret = resoucedata_to_jsval(cx, ret); args.rval().set(jsret); return true; } @@ -4694,7 +4674,7 @@ bool js_cocos2dx_ui_AbstractCheckButton_getBackNormalFile(JSContext *cx, uint32_ if (argc == 0) { cocos2d::ResouceData ret = cobj->getBackNormalFile(); jsval jsret = JSVAL_NULL; - #pragma warning NO CONVERSION FROM NATIVE FOR ResouceData; + jsret = resoucedata_to_jsval(cx, ret); args.rval().set(jsret); return true; } @@ -4947,37 +4927,75 @@ void js_register_cocos2dx_ui_AbstractCheckButton(JSContext *cx, JS::HandleObject JSFunctionSpec *st_funcs = NULL; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ui_Widget_prototype); jsb_cocos2d_ui_AbstractCheckButton_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ui_Widget_prototype), + parent_proto, jsb_cocos2d_ui_AbstractCheckButton_class, empty_constructor, 0, properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "AbstractCheckButton", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_ui_AbstractCheckButton_class; - p->proto = jsb_cocos2d_ui_AbstractCheckButton_prototype; - p->parentProto = jsb_cocos2d_ui_Widget_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ui_AbstractCheckButton_prototype); + jsb_register_class(cx, jsb_cocos2d_ui_AbstractCheckButton_class, proto, parent_proto); } JSClass *jsb_cocos2d_ui_CheckBox_class; JSObject *jsb_cocos2d_ui_CheckBox_prototype; +bool js_cocos2dx_ui_CheckBox_addEventListener(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::CheckBox* cobj = (cocos2d::ui::CheckBox *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_CheckBox_addEventListener : Invalid Native Object"); + if (argc == 1) { + std::function arg0; + do { + if(JS_TypeOfValue(cx, args.get(0)) == JSTYPE_FUNCTION) + { + JS::RootedObject jstarget(cx, args.thisv().toObjectOrNull()); + std::shared_ptr func(new JSFunctionWrapper(cx, jstarget, args.get(0))); + auto lambda = [=](cocos2d::Ref* larg0, cocos2d::ui::CheckBox::EventType larg1) -> void { + JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET + jsval largv[2]; + do { + if (larg0) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Ref*)larg0); + largv[0] = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + largv[0] = JSVAL_NULL; + } + } while (0); + largv[1] = int32_to_jsval(cx, (int)larg1); + JS::RootedValue rval(cx); + bool succeed = func->invoke(2, &largv[0], &rval); + if (!succeed && JS_IsExceptionPending(cx)) { + JS_ReportPendingException(cx); + } + }; + arg0 = lambda; + } + else + { + arg0 = nullptr; + } + } while(0) + ; + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_CheckBox_addEventListener : Error processing arguments"); + cobj->addEventListener(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_CheckBox_addEventListener : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} bool js_cocos2dx_ui_CheckBox_create(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); @@ -5153,8 +5171,8 @@ bool js_cocos2dx_ui_CheckBox_constructor(JSContext *cx, uint32_t argc, jsval *vp CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -5205,6 +5223,7 @@ void js_register_cocos2dx_ui_CheckBox(JSContext *cx, JS::HandleObject global) { }; static JSFunctionSpec funcs[] = { + JS_FN("addEventListener", js_cocos2dx_ui_CheckBox_addEventListener, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("ctor", js_cocos2dx_ui_CheckBox_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; @@ -5215,38 +5234,76 @@ void js_register_cocos2dx_ui_CheckBox(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ui_AbstractCheckButton_prototype); jsb_cocos2d_ui_CheckBox_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ui_AbstractCheckButton_prototype), + parent_proto, jsb_cocos2d_ui_CheckBox_class, js_cocos2dx_ui_CheckBox_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "CheckBox", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_ui_CheckBox_class; - p->proto = jsb_cocos2d_ui_CheckBox_prototype; - p->parentProto = jsb_cocos2d_ui_AbstractCheckButton_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ui_CheckBox_prototype); + jsb_register_class(cx, jsb_cocos2d_ui_CheckBox_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { ccui.CheckBox.extend = cc.Class.extend; })()"); } JSClass *jsb_cocos2d_ui_RadioButton_class; JSObject *jsb_cocos2d_ui_RadioButton_prototype; +bool js_cocos2dx_ui_RadioButton_addEventListener(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::RadioButton* cobj = (cocos2d::ui::RadioButton *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_RadioButton_addEventListener : Invalid Native Object"); + if (argc == 1) { + std::function arg0; + do { + if(JS_TypeOfValue(cx, args.get(0)) == JSTYPE_FUNCTION) + { + JS::RootedObject jstarget(cx, args.thisv().toObjectOrNull()); + std::shared_ptr func(new JSFunctionWrapper(cx, jstarget, args.get(0))); + auto lambda = [=](cocos2d::ui::RadioButton* larg0, cocos2d::ui::RadioButton::EventType larg1) -> void { + JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET + jsval largv[2]; + do { + if (larg0) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ui::RadioButton*)larg0); + largv[0] = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + largv[0] = JSVAL_NULL; + } + } while (0); + largv[1] = int32_to_jsval(cx, (int)larg1); + JS::RootedValue rval(cx); + bool succeed = func->invoke(2, &largv[0], &rval); + if (!succeed && JS_IsExceptionPending(cx)) { + JS_ReportPendingException(cx); + } + }; + arg0 = lambda; + } + else + { + arg0 = nullptr; + } + } while(0) + ; + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_RadioButton_addEventListener : Error processing arguments"); + cobj->addEventListener(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_RadioButton_addEventListener : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} bool js_cocos2dx_ui_RadioButton_create(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); @@ -5422,8 +5479,8 @@ bool js_cocos2dx_ui_RadioButton_constructor(JSContext *cx, uint32_t argc, jsval CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -5474,6 +5531,7 @@ void js_register_cocos2dx_ui_RadioButton(JSContext *cx, JS::HandleObject global) }; static JSFunctionSpec funcs[] = { + JS_FN("addEventListener", js_cocos2dx_ui_RadioButton_addEventListener, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("ctor", js_cocos2dx_ui_RadioButton_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; @@ -5484,32 +5542,20 @@ void js_register_cocos2dx_ui_RadioButton(JSContext *cx, JS::HandleObject global) JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ui_AbstractCheckButton_prototype); jsb_cocos2d_ui_RadioButton_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ui_AbstractCheckButton_prototype), + parent_proto, jsb_cocos2d_ui_RadioButton_class, js_cocos2dx_ui_RadioButton_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "RadioButton", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_ui_RadioButton_class; - p->proto = jsb_cocos2d_ui_RadioButton_prototype; - p->parentProto = jsb_cocos2d_ui_AbstractCheckButton_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ui_RadioButton_prototype); + jsb_register_class(cx, jsb_cocos2d_ui_RadioButton_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { ccui.RadioButton.extend = cc.Class.extend; })()"); } @@ -5530,7 +5576,7 @@ bool js_cocos2dx_ui_RadioButtonGroup_removeRadioButton(JSContext *cx, uint32_t a if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ui::RadioButton*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -5607,7 +5653,7 @@ bool js_cocos2dx_ui_RadioButtonGroup_setSelectedButtonWithoutEvent(JSContext *cx JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::ui::RadioButtonGroup *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_RadioButtonGroup_setSelectedButtonWithoutEvent : Invalid Native Object"); @@ -5618,7 +5664,7 @@ bool js_cocos2dx_ui_RadioButtonGroup_setSelectedButtonWithoutEvent(JSContext *cx if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ui::RadioButton*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -5644,6 +5690,57 @@ bool js_cocos2dx_ui_RadioButtonGroup_setSelectedButtonWithoutEvent(JSContext *cx JS_ReportError(cx, "js_cocos2dx_ui_RadioButtonGroup_setSelectedButtonWithoutEvent : wrong number of arguments"); return false; } +bool js_cocos2dx_ui_RadioButtonGroup_addEventListener(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::RadioButtonGroup* cobj = (cocos2d::ui::RadioButtonGroup *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_RadioButtonGroup_addEventListener : Invalid Native Object"); + if (argc == 1) { + std::function arg0; + do { + if(JS_TypeOfValue(cx, args.get(0)) == JSTYPE_FUNCTION) + { + JS::RootedObject jstarget(cx, args.thisv().toObjectOrNull()); + std::shared_ptr func(new JSFunctionWrapper(cx, jstarget, args.get(0))); + auto lambda = [=](cocos2d::ui::RadioButton* larg0, int larg1, cocos2d::ui::RadioButtonGroup::EventType larg2) -> void { + JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET + jsval largv[3]; + do { + if (larg0) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ui::RadioButton*)larg0); + largv[0] = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + largv[0] = JSVAL_NULL; + } + } while (0); + largv[1] = int32_to_jsval(cx, larg1); + largv[2] = int32_to_jsval(cx, (int)larg2); + JS::RootedValue rval(cx); + bool succeed = func->invoke(3, &largv[0], &rval); + if (!succeed && JS_IsExceptionPending(cx)) { + JS_ReportPendingException(cx); + } + }; + arg0 = lambda; + } + else + { + arg0 = nullptr; + } + } while(0) + ; + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_RadioButtonGroup_addEventListener : Error processing arguments"); + cobj->addEventListener(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_RadioButtonGroup_addEventListener : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} bool js_cocos2dx_ui_RadioButtonGroup_removeAllRadioButtons(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); @@ -5721,7 +5818,7 @@ bool js_cocos2dx_ui_RadioButtonGroup_addRadioButton(JSContext *cx, uint32_t argc if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ui::RadioButton*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -5742,7 +5839,7 @@ bool js_cocos2dx_ui_RadioButtonGroup_setSelectedButton(JSContext *cx, uint32_t a JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::ui::RadioButtonGroup *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_RadioButtonGroup_setSelectedButton : Invalid Native Object"); @@ -5753,7 +5850,7 @@ bool js_cocos2dx_ui_RadioButtonGroup_setSelectedButton(JSContext *cx, uint32_t a if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ui::RadioButton*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -5816,8 +5913,8 @@ bool js_cocos2dx_ui_RadioButtonGroup_constructor(JSContext *cx, uint32_t argc, j CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -5873,6 +5970,7 @@ void js_register_cocos2dx_ui_RadioButtonGroup(JSContext *cx, JS::HandleObject gl JS_FN("getSelectedButtonIndex", js_cocos2dx_ui_RadioButtonGroup_getSelectedButtonIndex, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setAllowedNoSelection", js_cocos2dx_ui_RadioButtonGroup_setAllowedNoSelection, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setSelectedButtonWithoutEvent", js_cocos2dx_ui_RadioButtonGroup_setSelectedButtonWithoutEvent, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("addEventListener", js_cocos2dx_ui_RadioButtonGroup_addEventListener, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("removeAllRadioButtons", js_cocos2dx_ui_RadioButtonGroup_removeAllRadioButtons, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getRadioButtonByIndex", js_cocos2dx_ui_RadioButtonGroup_getRadioButtonByIndex, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getNumberOfRadioButtons", js_cocos2dx_ui_RadioButtonGroup_getNumberOfRadioButtons, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), @@ -5887,32 +5985,20 @@ void js_register_cocos2dx_ui_RadioButtonGroup(JSContext *cx, JS::HandleObject gl JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ui_Widget_prototype); jsb_cocos2d_ui_RadioButtonGroup_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ui_Widget_prototype), + parent_proto, jsb_cocos2d_ui_RadioButtonGroup_class, js_cocos2dx_ui_RadioButtonGroup_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "RadioButtonGroup", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_ui_RadioButtonGroup_class; - p->proto = jsb_cocos2d_ui_RadioButtonGroup_prototype; - p->parentProto = jsb_cocos2d_ui_Widget_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ui_RadioButtonGroup_prototype); + jsb_register_class(cx, jsb_cocos2d_ui_RadioButtonGroup_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { ccui.RadioButtonGroup.extend = cc.Class.extend; })()"); } @@ -6053,7 +6139,7 @@ bool js_cocos2dx_ui_ImageView_getRenderFile(JSContext *cx, uint32_t argc, jsval if (argc == 0) { cocos2d::ResouceData ret = cobj->getRenderFile(); jsval jsret = JSVAL_NULL; - #pragma warning NO CONVERSION FROM NATIVE FOR ResouceData; + jsret = resoucedata_to_jsval(cx, ret); args.rval().set(jsret); return true; } @@ -6200,8 +6286,8 @@ bool js_cocos2dx_ui_ImageView_constructor(JSContext *cx, uint32_t argc, jsval *v CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -6270,32 +6356,20 @@ void js_register_cocos2dx_ui_ImageView(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ui_Widget_prototype); jsb_cocos2d_ui_ImageView_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ui_Widget_prototype), + parent_proto, jsb_cocos2d_ui_ImageView_class, js_cocos2dx_ui_ImageView_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "ImageView", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_ui_ImageView_class; - p->proto = jsb_cocos2d_ui_ImageView_prototype; - p->parentProto = jsb_cocos2d_ui_Widget_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ui_ImageView_prototype); + jsb_register_class(cx, jsb_cocos2d_ui_ImageView_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { ccui.ImageView.extend = cc.Class.extend; })()"); } @@ -6392,7 +6466,7 @@ bool js_cocos2dx_ui_Text_disableEffect(JSContext *cx, uint32_t argc, jsval *vp) JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::ui::Text *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Text_disableEffect : Invalid Native Object"); @@ -6903,8 +6977,8 @@ bool js_cocos2dx_ui_Text_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -6989,32 +7063,20 @@ void js_register_cocos2dx_ui_Text(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ui_Widget_prototype); jsb_cocos2d_ui_Text_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ui_Widget_prototype), + parent_proto, jsb_cocos2d_ui_Text_class, js_cocos2dx_ui_Text_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "Text", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_ui_Text_class; - p->proto = jsb_cocos2d_ui_Text_prototype; - p->parentProto = jsb_cocos2d_ui_Widget_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ui_Text_prototype); + jsb_register_class(cx, jsb_cocos2d_ui_Text_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { ccui.Text.extend = cc.Class.extend; })()"); } @@ -7087,7 +7149,7 @@ bool js_cocos2dx_ui_TextAtlas_getRenderFile(JSContext *cx, uint32_t argc, jsval if (argc == 0) { cocos2d::ResouceData ret = cobj->getRenderFile(); jsval jsret = JSVAL_NULL; - #pragma warning NO CONVERSION FROM NATIVE FOR ResouceData; + jsret = resoucedata_to_jsval(cx, ret); args.rval().set(jsret); return true; } @@ -7232,8 +7294,8 @@ bool js_cocos2dx_ui_TextAtlas_constructor(JSContext *cx, uint32_t argc, jsval *v CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -7300,32 +7362,20 @@ void js_register_cocos2dx_ui_TextAtlas(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ui_Widget_prototype); jsb_cocos2d_ui_TextAtlas_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ui_Widget_prototype), + parent_proto, jsb_cocos2d_ui_TextAtlas_class, js_cocos2dx_ui_TextAtlas_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "TextAtlas", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_ui_TextAtlas_class; - p->proto = jsb_cocos2d_ui_TextAtlas_prototype; - p->parentProto = jsb_cocos2d_ui_Widget_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ui_TextAtlas_prototype); + jsb_register_class(cx, jsb_cocos2d_ui_TextAtlas_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { ccui.TextAtlas.extend = cc.Class.extend; })()"); } @@ -7412,7 +7462,7 @@ bool js_cocos2dx_ui_LoadingBar_getRenderFile(JSContext *cx, uint32_t argc, jsval if (argc == 0) { cocos2d::ResouceData ret = cobj->getRenderFile(); jsval jsret = JSVAL_NULL; - #pragma warning NO CONVERSION FROM NATIVE FOR ResouceData; + jsret = resoucedata_to_jsval(cx, ret); args.rval().set(jsret); return true; } @@ -7683,8 +7733,8 @@ bool js_cocos2dx_ui_LoadingBar_constructor(JSContext *cx, uint32_t argc, jsval * CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -7755,32 +7805,20 @@ void js_register_cocos2dx_ui_LoadingBar(JSContext *cx, JS::HandleObject global) JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ui_Widget_prototype); jsb_cocos2d_ui_LoadingBar_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ui_Widget_prototype), + parent_proto, jsb_cocos2d_ui_LoadingBar_class, js_cocos2dx_ui_LoadingBar_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "LoadingBar", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_ui_LoadingBar_class; - p->proto = jsb_cocos2d_ui_LoadingBar_prototype; - p->parentProto = jsb_cocos2d_ui_Widget_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ui_LoadingBar_prototype); + jsb_register_class(cx, jsb_cocos2d_ui_LoadingBar_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { ccui.LoadingBar.extend = cc.Class.extend; })()"); } @@ -8204,6 +8242,56 @@ bool js_cocos2dx_ui_ScrollView_jumpToPercentVertical(JSContext *cx, uint32_t arg JS_ReportError(cx, "js_cocos2dx_ui_ScrollView_jumpToPercentVertical : wrong number of arguments: %d, was expecting %d", argc, 1); return false; } +bool js_cocos2dx_ui_ScrollView_addEventListener(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::ScrollView* cobj = (cocos2d::ui::ScrollView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_ScrollView_addEventListener : Invalid Native Object"); + if (argc == 1) { + std::function arg0; + do { + if(JS_TypeOfValue(cx, args.get(0)) == JSTYPE_FUNCTION) + { + JS::RootedObject jstarget(cx, args.thisv().toObjectOrNull()); + std::shared_ptr func(new JSFunctionWrapper(cx, jstarget, args.get(0))); + auto lambda = [=](cocos2d::Ref* larg0, cocos2d::ui::ScrollView::EventType larg1) -> void { + JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET + jsval largv[2]; + do { + if (larg0) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Ref*)larg0); + largv[0] = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + largv[0] = JSVAL_NULL; + } + } while (0); + largv[1] = int32_to_jsval(cx, (int)larg1); + JS::RootedValue rval(cx); + bool succeed = func->invoke(2, &largv[0], &rval); + if (!succeed && JS_IsExceptionPending(cx)) { + JS_ReportPendingException(cx); + } + }; + arg0 = lambda; + } + else + { + arg0 = nullptr; + } + } while(0) + ; + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_ScrollView_addEventListener : Error processing arguments"); + cobj->addEventListener(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_ScrollView_addEventListener : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} bool js_cocos2dx_ui_ScrollView_setScrollBarAutoHideTime(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); @@ -8820,8 +8908,8 @@ bool js_cocos2dx_ui_ScrollView_constructor(JSContext *cx, uint32_t argc, jsval * CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -8893,6 +8981,7 @@ void js_register_cocos2dx_ui_ScrollView(JSContext *cx, JS::HandleObject global) JS_FN("getInnerContainerSize", js_cocos2dx_ui_ScrollView_getInnerContainerSize, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("isBounceEnabled", js_cocos2dx_ui_ScrollView_isBounceEnabled, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("jumpToPercentVertical", js_cocos2dx_ui_ScrollView_jumpToPercentVertical, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("addEventListener", js_cocos2dx_ui_ScrollView_addEventListener, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setScrollBarAutoHideTime", js_cocos2dx_ui_ScrollView_setScrollBarAutoHideTime, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setScrollBarPositionFromCornerForHorizontal", js_cocos2dx_ui_ScrollView_setScrollBarPositionFromCornerForHorizontal, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setInertiaScrollEnabled", js_cocos2dx_ui_ScrollView_setInertiaScrollEnabled, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), @@ -8932,32 +9021,20 @@ void js_register_cocos2dx_ui_ScrollView(JSContext *cx, JS::HandleObject global) JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ui_Layout_prototype); jsb_cocos2d_ui_ScrollView_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ui_Layout_prototype), + parent_proto, jsb_cocos2d_ui_ScrollView_class, js_cocos2dx_ui_ScrollView_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "ScrollView", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_ui_ScrollView_class; - p->proto = jsb_cocos2d_ui_ScrollView_prototype; - p->parentProto = jsb_cocos2d_ui_Layout_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ui_ScrollView_prototype); + jsb_register_class(cx, jsb_cocos2d_ui_ScrollView_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { ccui.ScrollView.extend = cc.Class.extend; })()"); } @@ -9119,7 +9196,7 @@ bool js_cocos2dx_ui_ListView_getIndex(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ui::Widget*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -9149,7 +9226,7 @@ bool js_cocos2dx_ui_ListView_pushBackCustomItem(JSContext *cx, uint32_t argc, js if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ui::Widget*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -9203,6 +9280,56 @@ bool js_cocos2dx_ui_ListView_setMagneticAllowedOutOfBoundary(JSContext *cx, uint JS_ReportError(cx, "js_cocos2dx_ui_ListView_setMagneticAllowedOutOfBoundary : wrong number of arguments: %d, was expecting %d", argc, 1); return false; } +bool js_cocos2dx_ui_ListView_addEventListener(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::ListView* cobj = (cocos2d::ui::ListView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_ListView_addEventListener : Invalid Native Object"); + if (argc == 1) { + std::function arg0; + do { + if(JS_TypeOfValue(cx, args.get(0)) == JSTYPE_FUNCTION) + { + JS::RootedObject jstarget(cx, args.thisv().toObjectOrNull()); + std::shared_ptr func(new JSFunctionWrapper(cx, jstarget, args.get(0))); + auto lambda = [=](cocos2d::Ref* larg0, cocos2d::ui::ListView::EventType larg1) -> void { + JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET + jsval largv[2]; + do { + if (larg0) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Ref*)larg0); + largv[0] = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + largv[0] = JSVAL_NULL; + } + } while (0); + largv[1] = int32_to_jsval(cx, (int)larg1); + JS::RootedValue rval(cx); + bool succeed = func->invoke(2, &largv[0], &rval); + if (!succeed && JS_IsExceptionPending(cx)) { + JS_ReportPendingException(cx); + } + }; + arg0 = lambda; + } + else + { + arg0 = nullptr; + } + } while(0) + ; + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_ListView_addEventListener : Error processing arguments"); + cobj->addEventListener(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_ListView_addEventListener : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} bool js_cocos2dx_ui_ListView_doLayout(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); @@ -9422,7 +9549,7 @@ bool js_cocos2dx_ui_ListView_scrollToItem(JSContext *cx, uint32_t argc, jsval *v JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::ui::ListView *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_ListView_scrollToItem : Invalid Native Object"); @@ -9601,7 +9728,7 @@ bool js_cocos2dx_ui_ListView_setItemModel(JSContext *cx, uint32_t argc, jsval *v if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ui::Widget*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -9630,7 +9757,7 @@ bool js_cocos2dx_ui_ListView_insertCustomItem(JSContext *cx, uint32_t argc, jsva if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ui::Widget*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -9703,8 +9830,8 @@ bool js_cocos2dx_ui_ListView_constructor(JSContext *cx, uint32_t argc, jsval *vp CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -9766,6 +9893,7 @@ void js_register_cocos2dx_ui_ListView(JSContext *cx, JS::HandleObject global) { JS_FN("pushBackCustomItem", js_cocos2dx_ui_ListView_pushBackCustomItem, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("insertDefaultItem", js_cocos2dx_ui_ListView_insertDefaultItem, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setMagneticAllowedOutOfBoundary", js_cocos2dx_ui_ListView_setMagneticAllowedOutOfBoundary, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("addEventListener", js_cocos2dx_ui_ListView_addEventListener, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("doLayout", js_cocos2dx_ui_ListView_doLayout, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getTopmostItemInCurrentView", js_cocos2dx_ui_ListView_getTopmostItemInCurrentView, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("removeAllItems", js_cocos2dx_ui_ListView_removeAllItems, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), @@ -9794,32 +9922,20 @@ void js_register_cocos2dx_ui_ListView(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ui_ScrollView_prototype); jsb_cocos2d_ui_ListView_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ui_ScrollView_prototype), + parent_proto, jsb_cocos2d_ui_ListView_class, js_cocos2dx_ui_ListView_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "ListView", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_ui_ListView_class; - p->proto = jsb_cocos2d_ui_ListView_prototype; - p->parentProto = jsb_cocos2d_ui_ScrollView_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ui_ListView_prototype); + jsb_register_class(cx, jsb_cocos2d_ui_ListView_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { ccui.ListView.extend = cc.Class.extend; })()"); } @@ -9934,7 +10050,7 @@ bool js_cocos2dx_ui_Slider_getBallNormalFile(JSContext *cx, uint32_t argc, jsval if (argc == 0) { cocos2d::ResouceData ret = cobj->getBallNormalFile(); jsval jsret = JSVAL_NULL; - #pragma warning NO CONVERSION FROM NATIVE FOR ResouceData; + jsret = resoucedata_to_jsval(cx, ret); args.rval().set(jsret); return true; } @@ -9990,7 +10106,7 @@ bool js_cocos2dx_ui_Slider_getBallPressedFile(JSContext *cx, uint32_t argc, jsva if (argc == 0) { cocos2d::ResouceData ret = cobj->getBallPressedFile(); jsval jsret = JSVAL_NULL; - #pragma warning NO CONVERSION FROM NATIVE FOR ResouceData; + jsret = resoucedata_to_jsval(cx, ret); args.rval().set(jsret); return true; } @@ -10072,6 +10188,56 @@ bool js_cocos2dx_ui_Slider_loadSlidBallTextures(JSContext *cx, uint32_t argc, js JS_ReportError(cx, "js_cocos2dx_ui_Slider_loadSlidBallTextures : wrong number of arguments: %d, was expecting %d", argc, 1); return false; } +bool js_cocos2dx_ui_Slider_addEventListener(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::Slider* cobj = (cocos2d::ui::Slider *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Slider_addEventListener : Invalid Native Object"); + if (argc == 1) { + std::function arg0; + do { + if(JS_TypeOfValue(cx, args.get(0)) == JSTYPE_FUNCTION) + { + JS::RootedObject jstarget(cx, args.thisv().toObjectOrNull()); + std::shared_ptr func(new JSFunctionWrapper(cx, jstarget, args.get(0))); + auto lambda = [=](cocos2d::Ref* larg0, cocos2d::ui::Slider::EventType larg1) -> void { + JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET + jsval largv[2]; + do { + if (larg0) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Ref*)larg0); + largv[0] = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + largv[0] = JSVAL_NULL; + } + } while (0); + largv[1] = int32_to_jsval(cx, (int)larg1); + JS::RootedValue rval(cx); + bool succeed = func->invoke(2, &largv[0], &rval); + if (!succeed && JS_IsExceptionPending(cx)) { + JS_ReportPendingException(cx); + } + }; + arg0 = lambda; + } + else + { + arg0 = nullptr; + } + } while(0) + ; + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Slider_addEventListener : Error processing arguments"); + cobj->addEventListener(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Slider_addEventListener : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} bool js_cocos2dx_ui_Slider_setMaxPercent(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); @@ -10132,7 +10298,7 @@ bool js_cocos2dx_ui_Slider_getProgressBarFile(JSContext *cx, uint32_t argc, jsva if (argc == 0) { cocos2d::ResouceData ret = cobj->getProgressBarFile(); jsval jsret = JSVAL_NULL; - #pragma warning NO CONVERSION FROM NATIVE FOR ResouceData; + jsret = resoucedata_to_jsval(cx, ret); args.rval().set(jsret); return true; } @@ -10198,7 +10364,7 @@ bool js_cocos2dx_ui_Slider_getBackFile(JSContext *cx, uint32_t argc, jsval *vp) if (argc == 0) { cocos2d::ResouceData ret = cobj->getBackFile(); jsval jsret = JSVAL_NULL; - #pragma warning NO CONVERSION FROM NATIVE FOR ResouceData; + jsret = resoucedata_to_jsval(cx, ret); args.rval().set(jsret); return true; } @@ -10274,7 +10440,7 @@ bool js_cocos2dx_ui_Slider_getBallDisabeldFile(JSContext *cx, uint32_t argc, jsv if (argc == 0) { cocos2d::ResouceData ret = cobj->getBallDisabeldFile(); jsval jsret = JSVAL_NULL; - #pragma warning NO CONVERSION FROM NATIVE FOR ResouceData; + jsret = resoucedata_to_jsval(cx, ret); args.rval().set(jsret); return true; } @@ -10479,8 +10645,8 @@ bool js_cocos2dx_ui_Slider_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -10541,6 +10707,7 @@ void js_register_cocos2dx_ui_Slider(JSContext *cx, JS::HandleObject global) { JS_FN("getBallPressedFile", js_cocos2dx_ui_Slider_getBallPressedFile, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getZoomScale", js_cocos2dx_ui_Slider_getZoomScale, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("loadSlidBallTextures", js_cocos2dx_ui_Slider_loadSlidBallTextures, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("addEventListener", js_cocos2dx_ui_Slider_addEventListener, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setMaxPercent", js_cocos2dx_ui_Slider_setMaxPercent, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("loadBarTexture", js_cocos2dx_ui_Slider_loadBarTexture, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getProgressBarFile", js_cocos2dx_ui_Slider_getProgressBarFile, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), @@ -10565,32 +10732,20 @@ void js_register_cocos2dx_ui_Slider(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ui_Widget_prototype); jsb_cocos2d_ui_Slider_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ui_Widget_prototype), + parent_proto, jsb_cocos2d_ui_Slider_class, js_cocos2dx_ui_Slider_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "Slider", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_ui_Slider_class; - p->proto = jsb_cocos2d_ui_Slider_prototype; - p->parentProto = jsb_cocos2d_ui_Widget_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ui_Slider_prototype); + jsb_register_class(cx, jsb_cocos2d_ui_Slider_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { ccui.Slider.extend = cc.Class.extend; })()"); } @@ -10611,7 +10766,7 @@ bool js_cocos2dx_ui_UICCTextField_onTextFieldAttachWithIME(JSContext *cx, uint32 if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::TextFieldTTF*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -10719,7 +10874,7 @@ bool js_cocos2dx_ui_UICCTextField_onTextFieldDeleteBackward(JSContext *cx, uint3 if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::TextFieldTTF*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -10959,7 +11114,7 @@ bool js_cocos2dx_ui_UICCTextField_onTextFieldInsertText(JSContext *cx, uint32_t if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::TextFieldTTF*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -10991,7 +11146,7 @@ bool js_cocos2dx_ui_UICCTextField_onTextFieldDetachWithIME(JSContext *cx, uint32 if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::TextFieldTTF*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -11164,8 +11319,8 @@ bool js_cocos2dx_ui_UICCTextField_constructor(JSContext *cx, uint32_t argc, jsva CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -11233,32 +11388,20 @@ void js_register_cocos2dx_ui_UICCTextField(JSContext *cx, JS::HandleObject globa JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_TextFieldTTF_prototype); jsb_cocos2d_ui_UICCTextField_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_TextFieldTTF_prototype), + parent_proto, jsb_cocos2d_ui_UICCTextField_class, js_cocos2dx_ui_UICCTextField_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "UICCTextField", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_ui_UICCTextField_class; - p->proto = jsb_cocos2d_ui_UICCTextField_prototype; - p->parentProto = jsb_cocos2d_TextFieldTTF_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ui_UICCTextField_prototype); + jsb_register_class(cx, jsb_cocos2d_ui_UICCTextField_class, proto, parent_proto); } JSClass *jsb_cocos2d_ui_TextField_class; @@ -11528,6 +11671,56 @@ bool js_cocos2dx_ui_TextField_setTextVerticalAlignment(JSContext *cx, uint32_t a JS_ReportError(cx, "js_cocos2dx_ui_TextField_setTextVerticalAlignment : wrong number of arguments: %d, was expecting %d", argc, 1); return false; } +bool js_cocos2dx_ui_TextField_addEventListener(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::TextField* cobj = (cocos2d::ui::TextField *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_TextField_addEventListener : Invalid Native Object"); + if (argc == 1) { + std::function arg0; + do { + if(JS_TypeOfValue(cx, args.get(0)) == JSTYPE_FUNCTION) + { + JS::RootedObject jstarget(cx, args.thisv().toObjectOrNull()); + std::shared_ptr func(new JSFunctionWrapper(cx, jstarget, args.get(0))); + auto lambda = [=](cocos2d::Ref* larg0, cocos2d::ui::TextField::EventType larg1) -> void { + JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET + jsval largv[2]; + do { + if (larg0) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Ref*)larg0); + largv[0] = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + largv[0] = JSVAL_NULL; + } + } while (0); + largv[1] = int32_to_jsval(cx, (int)larg1); + JS::RootedValue rval(cx); + bool succeed = func->invoke(2, &largv[0], &rval); + if (!succeed && JS_IsExceptionPending(cx)) { + JS_ReportPendingException(cx); + } + }; + arg0 = lambda; + } + else + { + arg0 = nullptr; + } + } while(0) + ; + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_TextField_addEventListener : Error processing arguments"); + cobj->addEventListener(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_TextField_addEventListener : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} bool js_cocos2dx_ui_TextField_didNotSelectSelf(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); @@ -11813,7 +12006,7 @@ bool js_cocos2dx_ui_TextField_setPlaceHolderColor(JSContext *cx, uint32_t argc, JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::ui::TextField *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_TextField_setPlaceHolderColor : Invalid Native Object"); @@ -12121,8 +12314,8 @@ bool js_cocos2dx_ui_TextField_constructor(JSContext *cx, uint32_t argc, jsval *v CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -12187,6 +12380,7 @@ void js_register_cocos2dx_ui_TextField(JSContext *cx, JS::HandleObject global) { JS_FN("setString", js_cocos2dx_ui_TextField_setString, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getDetachWithIME", js_cocos2dx_ui_TextField_getDetachWithIME, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setTextVerticalAlignment", js_cocos2dx_ui_TextField_setTextVerticalAlignment, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("addEventListener", js_cocos2dx_ui_TextField_addEventListener, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("didNotSelectSelf", js_cocos2dx_ui_TextField_didNotSelectSelf, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getFontName", js_cocos2dx_ui_TextField_getFontName, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setTextAreaSize", js_cocos2dx_ui_TextField_setTextAreaSize, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), @@ -12223,32 +12417,20 @@ void js_register_cocos2dx_ui_TextField(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ui_Widget_prototype); jsb_cocos2d_ui_TextField_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ui_Widget_prototype), + parent_proto, jsb_cocos2d_ui_TextField_class, js_cocos2dx_ui_TextField_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "TextField", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_ui_TextField_class; - p->proto = jsb_cocos2d_ui_TextField_prototype; - p->parentProto = jsb_cocos2d_ui_Widget_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ui_TextField_prototype); + jsb_register_class(cx, jsb_cocos2d_ui_TextField_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { ccui.TextField.extend = cc.Class.extend; })()"); } @@ -12321,7 +12503,7 @@ bool js_cocos2dx_ui_TextBMFont_getRenderFile(JSContext *cx, uint32_t argc, jsval if (argc == 0) { cocos2d::ResouceData ret = cobj->getRenderFile(); jsval jsret = JSVAL_NULL; - #pragma warning NO CONVERSION FROM NATIVE FOR ResouceData; + jsret = resoucedata_to_jsval(cx, ret); args.rval().set(jsret); return true; } @@ -12433,8 +12615,8 @@ bool js_cocos2dx_ui_TextBMFont_constructor(JSContext *cx, uint32_t argc, jsval * CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -12500,32 +12682,20 @@ void js_register_cocos2dx_ui_TextBMFont(JSContext *cx, JS::HandleObject global) JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ui_Widget_prototype); jsb_cocos2d_ui_TextBMFont_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ui_Widget_prototype), + parent_proto, jsb_cocos2d_ui_TextBMFont_class, js_cocos2dx_ui_TextBMFont_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "TextBMFont", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_ui_TextBMFont_class; - p->proto = jsb_cocos2d_ui_TextBMFont_prototype; - p->parentProto = jsb_cocos2d_ui_Widget_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ui_TextBMFont_prototype); + jsb_register_class(cx, jsb_cocos2d_ui_TextBMFont_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { ccui.TextBMFont.extend = cc.Class.extend; })()"); } @@ -12661,7 +12831,7 @@ bool js_cocos2dx_ui_PageView_insertPage(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ui::Widget*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -12708,7 +12878,7 @@ bool js_cocos2dx_ui_PageView_removePage(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ui::Widget*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -12722,6 +12892,56 @@ bool js_cocos2dx_ui_PageView_removePage(JSContext *cx, uint32_t argc, jsval *vp) JS_ReportError(cx, "js_cocos2dx_ui_PageView_removePage : wrong number of arguments: %d, was expecting %d", argc, 1); return false; } +bool js_cocos2dx_ui_PageView_addEventListener(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::PageView* cobj = (cocos2d::ui::PageView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_PageView_addEventListener : Invalid Native Object"); + if (argc == 1) { + std::function arg0; + do { + if(JS_TypeOfValue(cx, args.get(0)) == JSTYPE_FUNCTION) + { + JS::RootedObject jstarget(cx, args.thisv().toObjectOrNull()); + std::shared_ptr func(new JSFunctionWrapper(cx, jstarget, args.get(0))); + auto lambda = [=](cocos2d::Ref* larg0, cocos2d::ui::PageView::EventType larg1) -> void { + JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET + jsval largv[2]; + do { + if (larg0) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Ref*)larg0); + largv[0] = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + largv[0] = JSVAL_NULL; + } + } while (0); + largv[1] = int32_to_jsval(cx, (int)larg1); + JS::RootedValue rval(cx); + bool succeed = func->invoke(2, &largv[0], &rval); + if (!succeed && JS_IsExceptionPending(cx)) { + JS_ReportPendingException(cx); + } + }; + arg0 = lambda; + } + else + { + arg0 = nullptr; + } + } while(0) + ; + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_PageView_addEventListener : Error processing arguments"); + cobj->addEventListener(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_PageView_addEventListener : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} bool js_cocos2dx_ui_PageView_setCurrentPageIndex(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); @@ -12854,7 +13074,7 @@ bool js_cocos2dx_ui_PageView_addPage(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ui::Widget*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -12980,8 +13200,8 @@ bool js_cocos2dx_ui_PageView_constructor(JSContext *cx, uint32_t argc, jsval *vp CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -13041,6 +13261,7 @@ void js_register_cocos2dx_ui_PageView(JSContext *cx, JS::HandleObject global) { JS_FN("insertPage", js_cocos2dx_ui_PageView_insertPage, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getCurrentPageIndex", js_cocos2dx_ui_PageView_getCurrentPageIndex, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("removePage", js_cocos2dx_ui_PageView_removePage, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("addEventListener", js_cocos2dx_ui_PageView_addEventListener, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setCurrentPageIndex", js_cocos2dx_ui_PageView_setCurrentPageIndex, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getIndicatorEnabled", js_cocos2dx_ui_PageView_getIndicatorEnabled, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("scrollToPage", js_cocos2dx_ui_PageView_scrollToPage, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), @@ -13061,32 +13282,20 @@ void js_register_cocos2dx_ui_PageView(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ui_ListView_prototype); jsb_cocos2d_ui_PageView_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ui_ListView_prototype), + parent_proto, jsb_cocos2d_ui_PageView_class, js_cocos2dx_ui_PageView_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "PageView", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_ui_PageView_class; - p->proto = jsb_cocos2d_ui_PageView_prototype; - p->parentProto = jsb_cocos2d_ui_ListView_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ui_PageView_prototype); + jsb_register_class(cx, jsb_cocos2d_ui_PageView_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { ccui.PageView.extend = cc.Class.extend; })()"); } @@ -13125,7 +13334,7 @@ bool js_cocos2dx_ui_Helper_convertBoundingBoxToScreen(JSContext *cx, uint32_t ar if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -13168,7 +13377,7 @@ bool js_cocos2dx_ui_Helper_seekActionWidgetByActionTag(JSContext *cx, uint32_t a if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ui::Widget*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -13203,7 +13412,7 @@ bool js_cocos2dx_ui_Helper_seekWidgetByName(JSContext *cx, uint32_t argc, jsval if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ui::Widget*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -13238,7 +13447,7 @@ bool js_cocos2dx_ui_Helper_seekWidgetByTag(JSContext *cx, uint32_t argc, jsval * if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ui::Widget*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -13292,7 +13501,7 @@ bool js_cocos2dx_ui_Helper_doLayout(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -13346,30 +13555,17 @@ void js_register_cocos2dx_ui_Helper(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_ui_Helper_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocos2d_ui_Helper_class, empty_constructor, 0, properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "Helper", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_ui_Helper_class; - p->proto = jsb_cocos2d_ui_Helper_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ui_Helper_prototype); + jsb_register_class(cx, jsb_cocos2d_ui_Helper_class, proto, JS::NullPtr()); } JSClass *jsb_cocos2d_ui_RichElement_class; @@ -13417,8 +13613,8 @@ bool js_cocos2dx_ui_RichElement_constructor(JSContext *cx, uint32_t argc, jsval CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -13476,30 +13672,17 @@ void js_register_cocos2dx_ui_RichElement(JSContext *cx, JS::HandleObject global) jsb_cocos2d_ui_RichElement_prototype = JS_InitClass( cx, global, - JS::NullPtr(), // parent proto + JS::NullPtr(), jsb_cocos2d_ui_RichElement_class, js_cocos2dx_ui_RichElement_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "RichElement", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_ui_RichElement_class; - p->proto = jsb_cocos2d_ui_RichElement_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ui_RichElement_prototype); + jsb_register_class(cx, jsb_cocos2d_ui_RichElement_class, proto, JS::NullPtr()); anonEvaluate(cx, global, "(function () { ccui.RichElement.extend = cc.Class.extend; })()"); } @@ -13589,8 +13772,8 @@ bool js_cocos2dx_ui_RichElementText_constructor(JSContext *cx, uint32_t argc, js CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -13651,32 +13834,20 @@ void js_register_cocos2dx_ui_RichElementText(JSContext *cx, JS::HandleObject glo JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ui_RichElement_prototype); jsb_cocos2d_ui_RichElementText_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ui_RichElement_prototype), + parent_proto, jsb_cocos2d_ui_RichElementText_class, js_cocos2dx_ui_RichElementText_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "RichElementText", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_ui_RichElementText_class; - p->proto = jsb_cocos2d_ui_RichElementText_prototype; - p->parentProto = jsb_cocos2d_ui_RichElement_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ui_RichElementText_prototype); + jsb_register_class(cx, jsb_cocos2d_ui_RichElementText_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { ccui.RichElementText.extend = cc.Class.extend; })()"); } @@ -13758,8 +13929,8 @@ bool js_cocos2dx_ui_RichElementImage_constructor(JSContext *cx, uint32_t argc, j CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -13820,32 +13991,20 @@ void js_register_cocos2dx_ui_RichElementImage(JSContext *cx, JS::HandleObject gl JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ui_RichElement_prototype); jsb_cocos2d_ui_RichElementImage_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ui_RichElement_prototype), + parent_proto, jsb_cocos2d_ui_RichElementImage_class, js_cocos2dx_ui_RichElementImage_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "RichElementImage", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_ui_RichElementImage_class; - p->proto = jsb_cocos2d_ui_RichElementImage_prototype; - p->parentProto = jsb_cocos2d_ui_RichElement_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ui_RichElementImage_prototype); + jsb_register_class(cx, jsb_cocos2d_ui_RichElementImage_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { ccui.RichElementImage.extend = cc.Class.extend; })()"); } @@ -13872,7 +14031,7 @@ bool js_cocos2dx_ui_RichElementCustomNode_init(JSContext *cx, uint32_t argc, jsv if (args.get(3).isNull()) { arg3 = nullptr; break; } if (!args.get(3).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(3).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(3).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg3 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg3, cx, false, "Invalid Native Object"); @@ -13904,7 +14063,7 @@ bool js_cocos2dx_ui_RichElementCustomNode_create(JSContext *cx, uint32_t argc, j if (args.get(3).isNull()) { arg3 = nullptr; break; } if (!args.get(3).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(3).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(3).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg3 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg3, cx, false, "Invalid Native Object"); @@ -13943,8 +14102,8 @@ bool js_cocos2dx_ui_RichElementCustomNode_constructor(JSContext *cx, uint32_t ar CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -14005,32 +14164,20 @@ void js_register_cocos2dx_ui_RichElementCustomNode(JSContext *cx, JS::HandleObje JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ui_RichElement_prototype); jsb_cocos2d_ui_RichElementCustomNode_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ui_RichElement_prototype), + parent_proto, jsb_cocos2d_ui_RichElementCustomNode_class, js_cocos2dx_ui_RichElementCustomNode_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "RichElementCustomNode", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_ui_RichElementCustomNode_class; - p->proto = jsb_cocos2d_ui_RichElementCustomNode_prototype; - p->parentProto = jsb_cocos2d_ui_RichElement_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ui_RichElementCustomNode_prototype); + jsb_register_class(cx, jsb_cocos2d_ui_RichElementCustomNode_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { ccui.RichElementCustomNode.extend = cc.Class.extend; })()"); } @@ -14052,7 +14199,7 @@ bool js_cocos2dx_ui_RichText_insertElement(JSContext *cx, uint32_t argc, jsval * if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ui::RichElement*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -14081,7 +14228,7 @@ bool js_cocos2dx_ui_RichText_pushBackElement(JSContext *cx, uint32_t argc, jsval if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ui::RichElement*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -14138,7 +14285,7 @@ bool js_cocos2dx_ui_RichText_removeElement(JSContext *cx, uint32_t argc, jsval * JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::ui::RichText *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_RichText_removeElement : Invalid Native Object"); @@ -14149,7 +14296,7 @@ bool js_cocos2dx_ui_RichText_removeElement(JSContext *cx, uint32_t argc, jsval * if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ui::RichElement*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -14212,8 +14359,8 @@ bool js_cocos2dx_ui_RichText_constructor(JSContext *cx, uint32_t argc, jsval *vp CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -14278,32 +14425,20 @@ void js_register_cocos2dx_ui_RichText(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ui_Widget_prototype); jsb_cocos2d_ui_RichText_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ui_Widget_prototype), + parent_proto, jsb_cocos2d_ui_RichText_class, js_cocos2dx_ui_RichText_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "RichText", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_ui_RichText_class; - p->proto = jsb_cocos2d_ui_RichText_prototype; - p->parentProto = jsb_cocos2d_ui_Widget_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ui_RichText_prototype); + jsb_register_class(cx, jsb_cocos2d_ui_RichText_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { ccui.RichText.extend = cc.Class.extend; })()"); } @@ -14392,8 +14527,8 @@ bool js_cocos2dx_ui_HBox_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -14454,32 +14589,20 @@ void js_register_cocos2dx_ui_HBox(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ui_Layout_prototype); jsb_cocos2d_ui_HBox_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ui_Layout_prototype), + parent_proto, jsb_cocos2d_ui_HBox_class, js_cocos2dx_ui_HBox_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "HBox", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_ui_HBox_class; - p->proto = jsb_cocos2d_ui_HBox_prototype; - p->parentProto = jsb_cocos2d_ui_Layout_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ui_HBox_prototype); + jsb_register_class(cx, jsb_cocos2d_ui_HBox_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { ccui.HBox.extend = cc.Class.extend; })()"); } @@ -14568,8 +14691,8 @@ bool js_cocos2dx_ui_VBox_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -14630,32 +14753,20 @@ void js_register_cocos2dx_ui_VBox(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ui_Layout_prototype); jsb_cocos2d_ui_VBox_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ui_Layout_prototype), + parent_proto, jsb_cocos2d_ui_VBox_class, js_cocos2dx_ui_VBox_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "VBox", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_ui_VBox_class; - p->proto = jsb_cocos2d_ui_VBox_prototype; - p->parentProto = jsb_cocos2d_ui_Layout_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ui_VBox_prototype); + jsb_register_class(cx, jsb_cocos2d_ui_VBox_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { ccui.VBox.extend = cc.Class.extend; })()"); } @@ -14744,8 +14855,8 @@ bool js_cocos2dx_ui_RelativeBox_constructor(JSContext *cx, uint32_t argc, jsval CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -14806,32 +14917,20 @@ void js_register_cocos2dx_ui_RelativeBox(JSContext *cx, JS::HandleObject global) JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ui_Layout_prototype); jsb_cocos2d_ui_RelativeBox_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ui_Layout_prototype), + parent_proto, jsb_cocos2d_ui_RelativeBox_class, js_cocos2dx_ui_RelativeBox_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "RelativeBox", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_ui_RelativeBox_class; - p->proto = jsb_cocos2d_ui_RelativeBox_prototype; - p->parentProto = jsb_cocos2d_ui_Layout_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ui_RelativeBox_prototype); + jsb_register_class(cx, jsb_cocos2d_ui_RelativeBox_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { ccui.RelativeBox.extend = cc.Class.extend; })()"); } @@ -14861,7 +14960,7 @@ bool js_cocos2dx_ui_Scale9Sprite_updateWithSprite(JSContext *cx, uint32_t argc, JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::ui::Scale9Sprite *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Scale9Sprite_updateWithSprite : Invalid Native Object"); @@ -14872,7 +14971,7 @@ bool js_cocos2dx_ui_Scale9Sprite_updateWithSprite(JSContext *cx, uint32_t argc, if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -14907,7 +15006,7 @@ bool js_cocos2dx_ui_Scale9Sprite_updateWithSprite(JSContext *cx, uint32_t argc, if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -15120,7 +15219,7 @@ bool js_cocos2dx_ui_Scale9Sprite_initWithSpriteFrameName(JSContext *cx, uint32_t JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::ui::Scale9Sprite *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Scale9Sprite_initWithSpriteFrameName : Invalid Native Object"); @@ -15228,7 +15327,7 @@ bool js_cocos2dx_ui_Scale9Sprite_init(JSContext *cx, uint32_t argc, jsval *vp) JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::ui::Scale9Sprite *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Scale9Sprite_init : Invalid Native Object"); @@ -15239,7 +15338,7 @@ bool js_cocos2dx_ui_Scale9Sprite_init(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -15266,7 +15365,7 @@ bool js_cocos2dx_ui_Scale9Sprite_init(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -15295,7 +15394,7 @@ bool js_cocos2dx_ui_Scale9Sprite_init(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -15360,7 +15459,7 @@ bool js_cocos2dx_ui_Scale9Sprite_setSpriteFrame(JSContext *cx, uint32_t argc, js if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::SpriteFrame*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -15377,7 +15476,7 @@ bool js_cocos2dx_ui_Scale9Sprite_setSpriteFrame(JSContext *cx, uint32_t argc, js if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::SpriteFrame*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -15541,7 +15640,7 @@ bool js_cocos2dx_ui_Scale9Sprite_initWithFile(JSContext *cx, uint32_t argc, jsva JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::ui::Scale9Sprite *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Scale9Sprite_initWithFile : Invalid Native Object"); @@ -15677,7 +15776,7 @@ bool js_cocos2dx_ui_Scale9Sprite_initWithSpriteFrame(JSContext *cx, uint32_t arg JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::ui::Scale9Sprite *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Scale9Sprite_initWithSpriteFrame : Invalid Native Object"); @@ -15688,7 +15787,7 @@ bool js_cocos2dx_ui_Scale9Sprite_initWithSpriteFrame(JSContext *cx, uint32_t arg if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::SpriteFrame*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -15709,7 +15808,7 @@ bool js_cocos2dx_ui_Scale9Sprite_initWithSpriteFrame(JSContext *cx, uint32_t arg if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::SpriteFrame*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -16001,7 +16100,7 @@ bool js_cocos2dx_ui_Scale9Sprite_createWithSpriteFrame(JSContext *cx, uint32_t a if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::SpriteFrame*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -16032,7 +16131,7 @@ bool js_cocos2dx_ui_Scale9Sprite_createWithSpriteFrame(JSContext *cx, uint32_t a if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::SpriteFrame*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -16071,8 +16170,8 @@ bool js_cocos2dx_ui_Scale9Sprite_constructor(JSContext *cx, uint32_t argc, jsval CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -16170,32 +16269,20 @@ void js_register_cocos2dx_ui_Scale9Sprite(JSContext *cx, JS::HandleObject global JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Node_prototype); jsb_cocos2d_ui_Scale9Sprite_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Node_prototype), + parent_proto, jsb_cocos2d_ui_Scale9Sprite_class, js_cocos2dx_ui_Scale9Sprite_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "Scale9Sprite", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_ui_Scale9Sprite_class; - p->proto = jsb_cocos2d_ui_Scale9Sprite_prototype; - p->parentProto = jsb_cocos2d_Node_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ui_Scale9Sprite_prototype); + jsb_register_class(cx, jsb_cocos2d_ui_Scale9Sprite_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { ccui.Scale9Sprite.extend = cc.Class.extend; })()"); } @@ -16365,7 +16452,7 @@ bool js_cocos2dx_ui_EditBox_setPlaceholderFontColor(JSContext *cx, uint32_t argc JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::ui::EditBox *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_EditBox_setPlaceholderFontColor : Invalid Native Object"); @@ -16401,7 +16488,7 @@ bool js_cocos2dx_ui_EditBox_setFontColor(JSContext *cx, uint32_t argc, jsval *vp JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::ui::EditBox *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_EditBox_setFontColor : Invalid Native Object"); @@ -16459,7 +16546,7 @@ bool js_cocos2dx_ui_EditBox_initWithSizeAndBackgroundSprite(JSContext *cx, uint3 JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx); - obj = args.thisv().toObjectOrNull(); + obj.set(args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::ui::EditBox *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_EditBox_initWithSizeAndBackgroundSprite : Invalid Native Object"); @@ -16473,7 +16560,7 @@ bool js_cocos2dx_ui_EditBox_initWithSizeAndBackgroundSprite(JSContext *cx, uint3 if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::ui::Scale9Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -16708,7 +16795,7 @@ bool js_cocos2dx_ui_EditBox_create(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::ui::Scale9Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -16738,7 +16825,7 @@ bool js_cocos2dx_ui_EditBox_create(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::ui::Scale9Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -16749,7 +16836,7 @@ bool js_cocos2dx_ui_EditBox_create(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(2).isNull()) { arg2 = nullptr; break; } if (!args.get(2).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(2).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(2).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg2 = (cocos2d::ui::Scale9Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg2, cx, false, "Invalid Native Object"); @@ -16779,7 +16866,7 @@ bool js_cocos2dx_ui_EditBox_create(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(1).isNull()) { arg1 = nullptr; break; } if (!args.get(1).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::ui::Scale9Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); @@ -16790,7 +16877,7 @@ bool js_cocos2dx_ui_EditBox_create(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(2).isNull()) { arg2 = nullptr; break; } if (!args.get(2).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(2).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(2).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg2 = (cocos2d::ui::Scale9Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg2, cx, false, "Invalid Native Object"); @@ -16801,7 +16888,7 @@ bool js_cocos2dx_ui_EditBox_create(JSContext *cx, uint32_t argc, jsval *vp) if (args.get(3).isNull()) { arg3 = nullptr; break; } if (!args.get(3).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(3).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(3).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg3 = (cocos2d::ui::Scale9Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg3, cx, false, "Invalid Native Object"); @@ -16840,8 +16927,8 @@ bool js_cocos2dx_ui_EditBox_constructor(JSContext *cx, uint32_t argc, jsval *vp) CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -16919,32 +17006,20 @@ void js_register_cocos2dx_ui_EditBox(JSContext *cx, JS::HandleObject global) { JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ui_Widget_prototype); jsb_cocos2d_ui_EditBox_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ui_Widget_prototype), + parent_proto, jsb_cocos2d_ui_EditBox_class, js_cocos2dx_ui_EditBox_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "EditBox", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_ui_EditBox_class; - p->proto = jsb_cocos2d_ui_EditBox_prototype; - p->parentProto = jsb_cocos2d_ui_Widget_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ui_EditBox_prototype); + jsb_register_class(cx, jsb_cocos2d_ui_EditBox_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { ccui.EditBox.extend = cc.Class.extend; })()"); } @@ -17912,7 +17987,7 @@ bool js_cocos2dx_ui_LayoutComponent_bindLayoutComponent(JSContext *cx, uint32_t if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -17951,8 +18026,8 @@ bool js_cocos2dx_ui_LayoutComponent_constructor(JSContext *cx, uint32_t argc, js CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -18062,32 +18137,20 @@ void js_register_cocos2dx_ui_LayoutComponent(JSContext *cx, JS::HandleObject glo JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_Component_prototype); jsb_cocos2d_ui_LayoutComponent_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_Component_prototype), + parent_proto, jsb_cocos2d_ui_LayoutComponent_class, js_cocos2dx_ui_LayoutComponent_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "LayoutComponent", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_ui_LayoutComponent_class; - p->proto = jsb_cocos2d_ui_LayoutComponent_prototype; - p->parentProto = jsb_cocos2d_Component_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ui_LayoutComponent_prototype); + jsb_register_class(cx, jsb_cocos2d_ui_LayoutComponent_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { ccui.LayoutComponent.extend = cc.Class.extend; })()"); } @@ -18277,7 +18340,7 @@ bool js_cocos2dx_ui_ScrollViewBar_create(JSContext *cx, uint32_t argc, jsval *vp if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ui::ScrollView*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -18311,7 +18374,7 @@ bool js_cocos2dx_ui_ScrollViewBar_constructor(JSContext *cx, uint32_t argc, jsva if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ui::ScrollView*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -18330,8 +18393,8 @@ bool js_cocos2dx_ui_ScrollViewBar_constructor(JSContext *cx, uint32_t argc, jsva CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object @@ -18351,7 +18414,7 @@ bool js_cocos2dx_ui_ScrollViewBar_constructor(JSContext *cx, uint32_t argc, jsva if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); jsProxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ui::ScrollView*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); @@ -18414,32 +18477,20 @@ void js_register_cocos2dx_ui_ScrollViewBar(JSContext *cx, JS::HandleObject globa JS_FS_END }; + JS::RootedObject parent_proto(cx, jsb_cocos2d_ProtectedNode_prototype); jsb_cocos2d_ui_ScrollViewBar_prototype = JS_InitClass( cx, global, - JS::RootedObject(cx, jsb_cocos2d_ProtectedNode_prototype), + parent_proto, jsb_cocos2d_ui_ScrollViewBar_class, js_cocos2dx_ui_ScrollViewBar_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "ScrollViewBar", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_ui_ScrollViewBar_class; - p->proto = jsb_cocos2d_ui_ScrollViewBar_prototype; - p->parentProto = jsb_cocos2d_ProtectedNode_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } + JS::RootedObject proto(cx, jsb_cocos2d_ui_ScrollViewBar_prototype); + jsb_register_class(cx, jsb_cocos2d_ui_ScrollViewBar_class, proto, parent_proto); anonEvaluate(cx, global, "(function () { ccui.ScrollViewBar.extend = cc.Class.extend; })()"); } diff --git a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_ui_auto.hpp b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_ui_auto.hpp index 5ff1f071f9..4d6f753354 100644 --- a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_ui_auto.hpp +++ b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_ui_auto.hpp @@ -110,6 +110,7 @@ bool js_cocos2dx_ui_Widget_onFocusChange(JSContext *cx, uint32_t argc, jsval *vp bool js_cocos2dx_ui_Widget_getTouchMovePosition(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Widget_getSizeType(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Widget_getCallbackType(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Widget_addTouchEventListener(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Widget_getTouchEndPosition(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Widget_getPositionPercent(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Widget_propagateTouchEvent(JSContext *cx, uint32_t argc, jsval *vp); @@ -256,6 +257,7 @@ bool js_cocos2dx_ui_CheckBox_constructor(JSContext *cx, uint32_t argc, jsval *vp void js_cocos2dx_ui_CheckBox_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_ui_CheckBox(JSContext *cx, JS::HandleObject global); void register_all_cocos2dx_ui(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_ui_CheckBox_addEventListener(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_CheckBox_create(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_CheckBox_createInstance(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_CheckBox_CheckBox(JSContext *cx, uint32_t argc, jsval *vp); @@ -267,6 +269,7 @@ bool js_cocos2dx_ui_RadioButton_constructor(JSContext *cx, uint32_t argc, jsval void js_cocos2dx_ui_RadioButton_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_ui_RadioButton(JSContext *cx, JS::HandleObject global); void register_all_cocos2dx_ui(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_ui_RadioButton_addEventListener(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_RadioButton_create(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_RadioButton_createInstance(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_RadioButton_RadioButton(JSContext *cx, uint32_t argc, jsval *vp); @@ -283,6 +286,7 @@ bool js_cocos2dx_ui_RadioButtonGroup_isAllowedNoSelection(JSContext *cx, uint32_ bool js_cocos2dx_ui_RadioButtonGroup_getSelectedButtonIndex(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_RadioButtonGroup_setAllowedNoSelection(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_RadioButtonGroup_setSelectedButtonWithoutEvent(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_RadioButtonGroup_addEventListener(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_RadioButtonGroup_removeAllRadioButtons(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_RadioButtonGroup_getRadioButtonByIndex(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_RadioButtonGroup_getNumberOfRadioButtons(JSContext *cx, uint32_t argc, jsval *vp); @@ -411,6 +415,7 @@ bool js_cocos2dx_ui_ScrollView_getInnerContainerPosition(JSContext *cx, uint32_t bool js_cocos2dx_ui_ScrollView_getInnerContainerSize(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_ScrollView_isBounceEnabled(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_ScrollView_jumpToPercentVertical(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_ScrollView_addEventListener(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_ScrollView_setScrollBarAutoHideTime(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_ScrollView_setScrollBarPositionFromCornerForHorizontal(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_ScrollView_setInertiaScrollEnabled(JSContext *cx, uint32_t argc, jsval *vp); @@ -462,6 +467,7 @@ bool js_cocos2dx_ui_ListView_getIndex(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_ListView_pushBackCustomItem(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_ListView_insertDefaultItem(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_ListView_setMagneticAllowedOutOfBoundary(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_ListView_addEventListener(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_ListView_doLayout(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_ListView_getTopmostItemInCurrentView(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_ListView_removeAllItems(JSContext *cx, uint32_t argc, jsval *vp); @@ -501,6 +507,7 @@ bool js_cocos2dx_ui_Slider_setScale9Enabled(JSContext *cx, uint32_t argc, jsval bool js_cocos2dx_ui_Slider_getBallPressedFile(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Slider_getZoomScale(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Slider_loadSlidBallTextures(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Slider_addEventListener(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Slider_setMaxPercent(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Slider_loadBarTexture(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Slider_getProgressBarFile(JSContext *cx, uint32_t argc, jsval *vp); @@ -575,6 +582,7 @@ bool js_cocos2dx_ui_TextField_setInsertText(JSContext *cx, uint32_t argc, jsval bool js_cocos2dx_ui_TextField_setString(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_TextField_getDetachWithIME(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_TextField_setTextVerticalAlignment(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_TextField_addEventListener(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_TextField_didNotSelectSelf(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_TextField_getFontName(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_TextField_setTextAreaSize(JSContext *cx, uint32_t argc, jsval *vp); @@ -637,6 +645,7 @@ bool js_cocos2dx_ui_PageView_getIndicatorPosition(JSContext *cx, uint32_t argc, bool js_cocos2dx_ui_PageView_insertPage(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_PageView_getCurrentPageIndex(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_PageView_removePage(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_PageView_addEventListener(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_PageView_setCurrentPageIndex(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_PageView_getIndicatorEnabled(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_PageView_scrollToPage(JSContext *cx, uint32_t argc, jsval *vp);