Merge pull request #14527 from CocosRobot/update_lua_bindings_1448944051

[ci skip][AUTO]: updating luabinding & jsbinding automatically
This commit is contained in:
zilongshanren 2015-12-01 13:42:55 +08:00
commit 6db6e596bb
17 changed files with 3820 additions and 8013 deletions

View File

@ -13513,6 +13513,16 @@ isSelected : function (
return false; return false;
}, },
/**
* @method setCallback
* @param {function} arg0
*/
setCallback : function (
func
)
{
},
/** /**
* @method unselected * @method unselected
*/ */

View File

@ -778,6 +778,16 @@ getCallbackType : function (
return ; return ;
}, },
/**
* @method addTouchEventListener
* @param {function} arg0
*/
addTouchEventListener : function (
func
)
{
},
/** /**
* @method getTouchEndPosition * @method getTouchEndPosition
* @return {vec2_object} * @return {vec2_object}
@ -2007,6 +2017,16 @@ texturerestype
*/ */
ccui.CheckBox = { ccui.CheckBox = {
/**
* @method addEventListener
* @param {function} arg0
*/
addEventListener : function (
func
)
{
},
/** /**
* @method create * @method create
* @param {String|String} str * @param {String|String} str
@ -2055,6 +2075,16 @@ CheckBox : function (
*/ */
ccui.RadioButton = { ccui.RadioButton = {
/**
* @method addEventListener
* @param {function} arg0
*/
addEventListener : function (
func
)
{
},
/** /**
* @method create * @method create
* @param {String|String} str * @param {String|String} str
@ -2153,6 +2183,16 @@ int
{ {
}, },
/**
* @method addEventListener
* @param {function} arg0
*/
addEventListener : function (
func
)
{
},
/** /**
* @method removeAllRadioButtons * @method removeAllRadioButtons
*/ */
@ -3117,6 +3157,16 @@ float
{ {
}, },
/**
* @method addEventListener
* @param {function} arg0
*/
addEventListener : function (
func
)
{
},
/** /**
* @method setScrollBarAutoHideTime * @method setScrollBarAutoHideTime
* @param {float} arg0 * @param {float} arg0
@ -3561,6 +3611,16 @@ bool
{ {
}, },
/**
* @method addEventListener
* @param {function} arg0
*/
addEventListener : function (
func
)
{
},
/** /**
* @method doLayout * @method doLayout
*/ */
@ -3899,6 +3959,16 @@ texturerestype
{ {
}, },
/**
* @method addEventListener
* @param {function} arg0
*/
addEventListener : function (
func
)
{
},
/** /**
* @method setMaxPercent * @method setMaxPercent
* @param {int} arg0 * @param {int} arg0
@ -4521,6 +4591,16 @@ textvalignment
{ {
}, },
/**
* @method addEventListener
* @param {function} arg0
*/
addEventListener : function (
func
)
{
},
/** /**
* @method didNotSelectSelf * @method didNotSelectSelf
*/ */
@ -5001,6 +5081,16 @@ widget
{ {
}, },
/**
* @method addEventListener
* @param {function} arg0
*/
addEventListener : function (
func
)
{
},
/** /**
* @method setCurrentPageIndex * @method setCurrentPageIndex
* @param {long} arg0 * @param {long} arg0

View File

@ -21,8 +21,8 @@ static bool dummy_constructor(JSContext *cx, uint32_t argc, jsval *vp) {
typeClass = typeMapIter->second; typeClass = typeMapIter->second;
CCASSERT(typeClass, "The value is null."); CCASSERT(typeClass, "The value is null.");
JS::RootedObject proto(cx, typeClass->proto.get()); JS::RootedObject proto(cx, typeClass->proto.ref());
JS::RootedObject parent(cx, typeClass->parentProto.get()); JS::RootedObject parent(cx, typeClass->parentProto.ref());
JS::RootedObject _tmp(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); JS::RootedObject _tmp(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent));
args.rval().set(OBJECT_TO_JSVAL(_tmp)); 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!"); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!");
typeClass = typeMapIter->second; typeClass = typeMapIter->second;
CCASSERT(typeClass, "The value is null."); CCASSERT(typeClass, "The value is null.");
JS::RootedObject proto(cx, typeClass->proto.get()); JS::RootedObject proto(cx, typeClass->proto.ref());
JS::RootedObject parent(cx, typeClass->parentProto.get()); JS::RootedObject parent(cx, typeClass->parentProto.ref());
JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent));
args.rval().set(OBJECT_TO_JSVAL(obj)); args.rval().set(OBJECT_TO_JSVAL(obj));
// link the native object with the javascript object // 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( jsb_cocos2d_Animation3D_prototype = JS_InitClass(
cx, global, cx, global,
JS::NullPtr(), // parent proto JS::NullPtr(),
jsb_cocos2d_Animation3D_class, jsb_cocos2d_Animation3D_class,
js_cocos2dx_3d_Animation3D_constructor, 0, // constructor js_cocos2dx_3d_Animation3D_constructor, 0, // constructor
properties, properties,
funcs, funcs,
NULL, // no static properties NULL, // no static properties
st_funcs); 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 // add the proto and JSClass to the type->js info hash table
TypeTest<cocos2d::Animation3D> t; JS::RootedObject proto(cx, jsb_cocos2d_Animation3D_prototype);
js_type_class_t *p; jsb_register_class<cocos2d::Animation3D>(cx, jsb_cocos2d_Animation3D_class, proto, JS::NullPtr());
std::string typeName = t.s_name();
if (_js_global_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));
}
} }
JSClass *jsb_cocos2d_Animate3D_class; 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).isNull()) { arg0 = nullptr; break; }
if (!args.get(0).isObject()) { ok = false; break; } if (!args.get(0).isObject()) { ok = false; break; }
js_proxy_t *jsProxy; js_proxy_t *jsProxy;
JSObject *tmpObj = args.get(0).toObjectOrNull(); JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull());
jsProxy = jsb_get_js_proxy(tmpObj); jsProxy = jsb_get_js_proxy(tmpObj);
arg0 = (cocos2d::Animation3D*)(jsProxy ? jsProxy->ptr : NULL); arg0 = (cocos2d::Animation3D*)(jsProxy ? jsProxy->ptr : NULL);
JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); 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::CallArgs args = JS::CallArgsFromVp(argc, vp);
JS::RootedObject obj(cx); JS::RootedObject obj(cx);
obj = args.thisv().toObjectOrNull(); obj.set(args.thisv().toObjectOrNull());
js_proxy_t *proxy = jsb_get_js_proxy(obj); js_proxy_t *proxy = jsb_get_js_proxy(obj);
cobj = (cocos2d::Animate3D *)(proxy ? proxy->ptr : nullptr); cobj = (cocos2d::Animate3D *)(proxy ? proxy->ptr : nullptr);
JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_Animate3D_init : Invalid Native Object"); 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).isNull()) { arg0 = nullptr; break; }
if (!args.get(0).isObject()) { ok = false; break; } if (!args.get(0).isObject()) { ok = false; break; }
js_proxy_t *jsProxy; js_proxy_t *jsProxy;
JSObject *tmpObj = args.get(0).toObjectOrNull(); JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull());
jsProxy = jsb_get_js_proxy(tmpObj); jsProxy = jsb_get_js_proxy(tmpObj);
arg0 = (cocos2d::Animation3D*)(jsProxy ? jsProxy->ptr : NULL); arg0 = (cocos2d::Animation3D*)(jsProxy ? jsProxy->ptr : NULL);
JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); 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).isNull()) { arg0 = nullptr; break; }
if (!args.get(0).isObject()) { ok = false; break; } if (!args.get(0).isObject()) { ok = false; break; }
js_proxy_t *jsProxy; js_proxy_t *jsProxy;
JSObject *tmpObj = args.get(0).toObjectOrNull(); JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull());
jsProxy = jsb_get_js_proxy(tmpObj); jsProxy = jsb_get_js_proxy(tmpObj);
arg0 = (cocos2d::Animation3D*)(jsProxy ? jsProxy->ptr : NULL); arg0 = (cocos2d::Animation3D*)(jsProxy ? jsProxy->ptr : NULL);
JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); 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).isNull()) { arg0 = nullptr; break; }
if (!args.get(0).isObject()) { ok = false; break; } if (!args.get(0).isObject()) { ok = false; break; }
js_proxy_t *jsProxy; js_proxy_t *jsProxy;
JSObject *tmpObj = args.get(0).toObjectOrNull(); JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull());
jsProxy = jsb_get_js_proxy(tmpObj); jsProxy = jsb_get_js_proxy(tmpObj);
arg0 = (cocos2d::Animation3D*)(jsProxy ? jsProxy->ptr : NULL); arg0 = (cocos2d::Animation3D*)(jsProxy ? jsProxy->ptr : NULL);
JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); 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).isNull()) { arg0 = nullptr; break; }
if (!args.get(0).isObject()) { ok = false; break; } if (!args.get(0).isObject()) { ok = false; break; }
js_proxy_t *jsProxy; js_proxy_t *jsProxy;
JSObject *tmpObj = args.get(0).toObjectOrNull(); JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull());
jsProxy = jsb_get_js_proxy(tmpObj); jsProxy = jsb_get_js_proxy(tmpObj);
arg0 = (cocos2d::Animation3D*)(jsProxy ? jsProxy->ptr : NULL); arg0 = (cocos2d::Animation3D*)(jsProxy ? jsProxy->ptr : NULL);
JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); 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).isNull()) { arg0 = nullptr; break; }
if (!args.get(0).isObject()) { ok = false; break; } if (!args.get(0).isObject()) { ok = false; break; }
js_proxy_t *jsProxy; js_proxy_t *jsProxy;
JSObject *tmpObj = args.get(0).toObjectOrNull(); JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull());
jsProxy = jsb_get_js_proxy(tmpObj); jsProxy = jsb_get_js_proxy(tmpObj);
arg0 = (cocos2d::Animation3D*)(jsProxy ? jsProxy->ptr : NULL); arg0 = (cocos2d::Animation3D*)(jsProxy ? jsProxy->ptr : NULL);
JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); 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).isNull()) { arg0 = nullptr; break; }
if (!args.get(0).isObject()) { ok = false; break; } if (!args.get(0).isObject()) { ok = false; break; }
js_proxy_t *jsProxy; js_proxy_t *jsProxy;
JSObject *tmpObj = args.get(0).toObjectOrNull(); JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull());
jsProxy = jsb_get_js_proxy(tmpObj); jsProxy = jsb_get_js_proxy(tmpObj);
arg0 = (cocos2d::Animation3D*)(jsProxy ? jsProxy->ptr : NULL); arg0 = (cocos2d::Animation3D*)(jsProxy ? jsProxy->ptr : NULL);
JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); 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!"); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!");
typeClass = typeMapIter->second; typeClass = typeMapIter->second;
CCASSERT(typeClass, "The value is null."); CCASSERT(typeClass, "The value is null.");
JS::RootedObject proto(cx, typeClass->proto.get()); JS::RootedObject proto(cx, typeClass->proto.ref());
JS::RootedObject parent(cx, typeClass->parentProto.get()); JS::RootedObject parent(cx, typeClass->parentProto.ref());
JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent));
args.rval().set(OBJECT_TO_JSVAL(obj)); args.rval().set(OBJECT_TO_JSVAL(obj));
// link the native object with the javascript object // 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_FS_END
}; };
JS::RootedObject parent_proto(cx, jsb_cocos2d_ActionInterval_prototype);
jsb_cocos2d_Animate3D_prototype = JS_InitClass( jsb_cocos2d_Animate3D_prototype = JS_InitClass(
cx, global, cx, global,
JS::RootedObject(cx, jsb_cocos2d_ActionInterval_prototype), parent_proto,
jsb_cocos2d_Animate3D_class, jsb_cocos2d_Animate3D_class,
js_cocos2dx_3d_Animate3D_constructor, 0, // constructor js_cocos2dx_3d_Animate3D_constructor, 0, // constructor
properties, properties,
funcs, funcs,
NULL, // no static properties NULL, // no static properties
st_funcs); 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 // add the proto and JSClass to the type->js info hash table
TypeTest<cocos2d::Animate3D> t; JS::RootedObject proto(cx, jsb_cocos2d_Animate3D_prototype);
js_type_class_t *p; jsb_register_class<cocos2d::Animate3D>(cx, jsb_cocos2d_Animate3D_class, proto, parent_proto);
std::string typeName = t.s_name();
if (_js_global_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));
}
} }
JSClass *jsb_cocos2d_TextureCube_class; 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!"); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!");
typeClass = typeMapIter->second; typeClass = typeMapIter->second;
CCASSERT(typeClass, "The value is null."); CCASSERT(typeClass, "The value is null.");
JS::RootedObject proto(cx, typeClass->proto.get()); JS::RootedObject proto(cx, typeClass->proto.ref());
JS::RootedObject parent(cx, typeClass->parentProto.get()); JS::RootedObject parent(cx, typeClass->parentProto.ref());
JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent));
args.rval().set(OBJECT_TO_JSVAL(obj)); args.rval().set(OBJECT_TO_JSVAL(obj));
// link the native object with the javascript object // 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_FS_END
}; };
JS::RootedObject parent_proto(cx, jsb_cocos2d_Texture2D_prototype);
jsb_cocos2d_TextureCube_prototype = JS_InitClass( jsb_cocos2d_TextureCube_prototype = JS_InitClass(
cx, global, cx, global,
JS::RootedObject(cx, jsb_cocos2d_Texture2D_prototype), parent_proto,
jsb_cocos2d_TextureCube_class, jsb_cocos2d_TextureCube_class,
js_cocos2dx_3d_TextureCube_constructor, 0, // constructor js_cocos2dx_3d_TextureCube_constructor, 0, // constructor
properties, properties,
funcs, funcs,
NULL, // no static properties NULL, // no static properties
st_funcs); 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 // add the proto and JSClass to the type->js info hash table
TypeTest<cocos2d::TextureCube> t; JS::RootedObject proto(cx, jsb_cocos2d_TextureCube_prototype);
js_type_class_t *p; jsb_register_class<cocos2d::TextureCube>(cx, jsb_cocos2d_TextureCube_class, proto, parent_proto);
std::string typeName = t.s_name();
if (_js_global_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));
}
} }
JSClass *jsb_cocos2d_AttachNode_class; 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).isNull()) { arg0 = nullptr; break; }
if (!args.get(0).isObject()) { ok = false; break; } if (!args.get(0).isObject()) { ok = false; break; }
js_proxy_t *jsProxy; js_proxy_t *jsProxy;
JSObject *tmpObj = args.get(0).toObjectOrNull(); JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull());
jsProxy = jsb_get_js_proxy(tmpObj); jsProxy = jsb_get_js_proxy(tmpObj);
arg0 = (cocos2d::Bone3D*)(jsProxy ? jsProxy->ptr : NULL); arg0 = (cocos2d::Bone3D*)(jsProxy ? jsProxy->ptr : NULL);
JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); 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!"); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!");
typeClass = typeMapIter->second; typeClass = typeMapIter->second;
CCASSERT(typeClass, "The value is null."); CCASSERT(typeClass, "The value is null.");
JS::RootedObject proto(cx, typeClass->proto.get()); JS::RootedObject proto(cx, typeClass->proto.ref());
JS::RootedObject parent(cx, typeClass->parentProto.get()); JS::RootedObject parent(cx, typeClass->parentProto.ref());
JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent));
args.rval().set(OBJECT_TO_JSVAL(obj)); args.rval().set(OBJECT_TO_JSVAL(obj));
// link the native object with the javascript object // 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_FS_END
}; };
JS::RootedObject parent_proto(cx, jsb_cocos2d_Node_prototype);
jsb_cocos2d_AttachNode_prototype = JS_InitClass( jsb_cocos2d_AttachNode_prototype = JS_InitClass(
cx, global, cx, global,
JS::RootedObject(cx, jsb_cocos2d_Node_prototype), parent_proto,
jsb_cocos2d_AttachNode_class, jsb_cocos2d_AttachNode_class,
js_cocos2dx_3d_AttachNode_constructor, 0, // constructor js_cocos2dx_3d_AttachNode_constructor, 0, // constructor
properties, properties,
funcs, funcs,
NULL, // no static properties NULL, // no static properties
st_funcs); 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 // add the proto and JSClass to the type->js info hash table
TypeTest<cocos2d::AttachNode> t; JS::RootedObject proto(cx, jsb_cocos2d_AttachNode_prototype);
js_type_class_t *p; jsb_register_class<cocos2d::AttachNode>(cx, jsb_cocos2d_AttachNode_class, proto, parent_proto);
std::string typeName = t.s_name();
if (_js_global_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));
}
} }
JSClass *jsb_cocos2d_BillBoard_class; 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).isNull()) { arg0 = nullptr; break; }
if (!args.get(0).isObject()) { ok = false; break; } if (!args.get(0).isObject()) { ok = false; break; }
js_proxy_t *jsProxy; js_proxy_t *jsProxy;
JSObject *tmpObj = args.get(0).toObjectOrNull(); JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull());
jsProxy = jsb_get_js_proxy(tmpObj); jsProxy = jsb_get_js_proxy(tmpObj);
arg0 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); arg0 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL);
JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); 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).isNull()) { arg0 = nullptr; break; }
if (!args.get(0).isObject()) { ok = false; break; } if (!args.get(0).isObject()) { ok = false; break; }
js_proxy_t *jsProxy; js_proxy_t *jsProxy;
JSObject *tmpObj = args.get(0).toObjectOrNull(); JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull());
jsProxy = jsb_get_js_proxy(tmpObj); jsProxy = jsb_get_js_proxy(tmpObj);
arg0 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); arg0 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL);
JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); 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!"); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!");
typeClass = typeMapIter->second; typeClass = typeMapIter->second;
CCASSERT(typeClass, "The value is null."); CCASSERT(typeClass, "The value is null.");
JS::RootedObject proto(cx, typeClass->proto.get()); JS::RootedObject proto(cx, typeClass->proto.ref());
JS::RootedObject parent(cx, typeClass->parentProto.get()); JS::RootedObject parent(cx, typeClass->parentProto.ref());
JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent));
args.rval().set(OBJECT_TO_JSVAL(obj)); args.rval().set(OBJECT_TO_JSVAL(obj));
// link the native object with the javascript object // 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_FS_END
}; };
JS::RootedObject parent_proto(cx, jsb_cocos2d_Sprite_prototype);
jsb_cocos2d_BillBoard_prototype = JS_InitClass( jsb_cocos2d_BillBoard_prototype = JS_InitClass(
cx, global, cx, global,
JS::RootedObject(cx, jsb_cocos2d_Sprite_prototype), parent_proto,
jsb_cocos2d_BillBoard_class, jsb_cocos2d_BillBoard_class,
js_cocos2dx_3d_BillBoard_constructor, 0, // constructor js_cocos2dx_3d_BillBoard_constructor, 0, // constructor
properties, properties,
funcs, funcs,
NULL, // no static properties NULL, // no static properties
st_funcs); 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 // add the proto and JSClass to the type->js info hash table
TypeTest<cocos2d::BillBoard> t; JS::RootedObject proto(cx, jsb_cocos2d_BillBoard_prototype);
js_type_class_t *p; jsb_register_class<cocos2d::BillBoard>(cx, jsb_cocos2d_BillBoard_class, proto, parent_proto);
std::string typeName = t.s_name();
if (_js_global_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));
}
} }
JSClass *jsb_cocos2d_Mesh_class; 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::CallArgs args = JS::CallArgsFromVp(argc, vp);
JS::RootedObject obj(cx); JS::RootedObject obj(cx);
obj = args.thisv().toObjectOrNull(); obj.set(args.thisv().toObjectOrNull());
js_proxy_t *proxy = jsb_get_js_proxy(obj); js_proxy_t *proxy = jsb_get_js_proxy(obj);
cobj = (cocos2d::Mesh *)(proxy ? proxy->ptr : nullptr); cobj = (cocos2d::Mesh *)(proxy ? proxy->ptr : nullptr);
JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_Mesh_setTexture : Invalid Native Object"); 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).isNull()) { arg0 = nullptr; break; }
if (!args.get(0).isObject()) { ok = false; break; } if (!args.get(0).isObject()) { ok = false; break; }
js_proxy_t *jsProxy; js_proxy_t *jsProxy;
JSObject *tmpObj = args.get(0).toObjectOrNull(); JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull());
jsProxy = jsb_get_js_proxy(tmpObj); jsProxy = jsb_get_js_proxy(tmpObj);
arg0 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); arg0 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL);
JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); 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).isNull()) { arg0 = nullptr; break; }
if (!args.get(0).isObject()) { ok = false; break; } if (!args.get(0).isObject()) { ok = false; break; }
js_proxy_t *jsProxy; js_proxy_t *jsProxy;
JSObject *tmpObj = args.get(0).toObjectOrNull(); JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull());
jsProxy = jsb_get_js_proxy(tmpObj); jsProxy = jsb_get_js_proxy(tmpObj);
arg0 = (cocos2d::Material*)(jsProxy ? jsProxy->ptr : NULL); arg0 = (cocos2d::Material*)(jsProxy ? jsProxy->ptr : NULL);
JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); 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).isNull()) { arg0 = nullptr; break; }
if (!args.get(0).isObject()) { ok = false; break; } if (!args.get(0).isObject()) { ok = false; break; }
js_proxy_t *jsProxy; js_proxy_t *jsProxy;
JSObject *tmpObj = args.get(0).toObjectOrNull(); JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull());
jsProxy = jsb_get_js_proxy(tmpObj); jsProxy = jsb_get_js_proxy(tmpObj);
arg0 = (cocos2d::MeshIndexData*)(jsProxy ? jsProxy->ptr : NULL); arg0 = (cocos2d::MeshIndexData*)(jsProxy ? jsProxy->ptr : NULL);
JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); 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).isNull()) { arg0 = nullptr; break; }
if (!args.get(0).isObject()) { ok = false; break; } if (!args.get(0).isObject()) { ok = false; break; }
js_proxy_t *jsProxy; js_proxy_t *jsProxy;
JSObject *tmpObj = args.get(0).toObjectOrNull(); JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull());
jsProxy = jsb_get_js_proxy(tmpObj); jsProxy = jsb_get_js_proxy(tmpObj);
arg0 = (cocos2d::MeshSkin*)(jsProxy ? jsProxy->ptr : NULL); arg0 = (cocos2d::MeshSkin*)(jsProxy ? jsProxy->ptr : NULL);
JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); 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).isNull()) { arg0 = nullptr; break; }
if (!args.get(0).isObject()) { ok = false; break; } if (!args.get(0).isObject()) { ok = false; break; }
js_proxy_t *jsProxy; js_proxy_t *jsProxy;
JSObject *tmpObj = args.get(0).toObjectOrNull(); JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull());
jsProxy = jsb_get_js_proxy(tmpObj); jsProxy = jsb_get_js_proxy(tmpObj);
arg0 = (cocos2d::GLProgramState*)(jsProxy ? jsProxy->ptr : NULL); arg0 = (cocos2d::GLProgramState*)(jsProxy ? jsProxy->ptr : NULL);
JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); 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!"); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!");
typeClass = typeMapIter->second; typeClass = typeMapIter->second;
CCASSERT(typeClass, "The value is null."); CCASSERT(typeClass, "The value is null.");
JS::RootedObject proto(cx, typeClass->proto.get()); JS::RootedObject proto(cx, typeClass->proto.ref());
JS::RootedObject parent(cx, typeClass->parentProto.get()); JS::RootedObject parent(cx, typeClass->parentProto.ref());
JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent));
args.rval().set(OBJECT_TO_JSVAL(obj)); args.rval().set(OBJECT_TO_JSVAL(obj));
// link the native object with the javascript object // 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( jsb_cocos2d_Mesh_prototype = JS_InitClass(
cx, global, cx, global,
JS::NullPtr(), // parent proto JS::NullPtr(),
jsb_cocos2d_Mesh_class, jsb_cocos2d_Mesh_class,
js_cocos2dx_3d_Mesh_constructor, 0, // constructor js_cocos2dx_3d_Mesh_constructor, 0, // constructor
properties, properties,
funcs, funcs,
NULL, // no static properties NULL, // no static properties
st_funcs); 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 // add the proto and JSClass to the type->js info hash table
TypeTest<cocos2d::Mesh> t; JS::RootedObject proto(cx, jsb_cocos2d_Mesh_prototype);
js_type_class_t *p; jsb_register_class<cocos2d::Mesh>(cx, jsb_cocos2d_Mesh_class, proto, JS::NullPtr());
std::string typeName = t.s_name();
if (_js_global_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));
}
} }
JSClass *jsb_cocos2d_Skeleton3D_class; 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).isNull()) { arg0 = nullptr; break; }
if (!args.get(0).isObject()) { ok = false; break; } if (!args.get(0).isObject()) { ok = false; break; }
js_proxy_t *jsProxy; js_proxy_t *jsProxy;
JSObject *tmpObj = args.get(0).toObjectOrNull(); JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull());
jsProxy = jsb_get_js_proxy(tmpObj); jsProxy = jsb_get_js_proxy(tmpObj);
arg0 = (cocos2d::Bone3D*)(jsProxy ? jsProxy->ptr : NULL); arg0 = (cocos2d::Bone3D*)(jsProxy ? jsProxy->ptr : NULL);
JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); 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).isNull()) { arg0 = nullptr; break; }
if (!args.get(0).isObject()) { ok = false; break; } if (!args.get(0).isObject()) { ok = false; break; }
js_proxy_t *jsProxy; js_proxy_t *jsProxy;
JSObject *tmpObj = args.get(0).toObjectOrNull(); JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull());
jsProxy = jsb_get_js_proxy(tmpObj); jsProxy = jsb_get_js_proxy(tmpObj);
arg0 = (cocos2d::Bone3D*)(jsProxy ? jsProxy->ptr : NULL); arg0 = (cocos2d::Bone3D*)(jsProxy ? jsProxy->ptr : NULL);
JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); 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!"); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!");
typeClass = typeMapIter->second; typeClass = typeMapIter->second;
CCASSERT(typeClass, "The value is null."); CCASSERT(typeClass, "The value is null.");
JS::RootedObject proto(cx, typeClass->proto.get()); JS::RootedObject proto(cx, typeClass->proto.ref());
JS::RootedObject parent(cx, typeClass->parentProto.get()); JS::RootedObject parent(cx, typeClass->parentProto.ref());
JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent));
args.rval().set(OBJECT_TO_JSVAL(obj)); args.rval().set(OBJECT_TO_JSVAL(obj));
// link the native object with the javascript object // 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( jsb_cocos2d_Skeleton3D_prototype = JS_InitClass(
cx, global, cx, global,
JS::NullPtr(), // parent proto JS::NullPtr(),
jsb_cocos2d_Skeleton3D_class, jsb_cocos2d_Skeleton3D_class,
js_cocos2dx_3d_Skeleton3D_constructor, 0, // constructor js_cocos2dx_3d_Skeleton3D_constructor, 0, // constructor
properties, properties,
funcs, funcs,
NULL, // no static properties NULL, // no static properties
st_funcs); 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 // add the proto and JSClass to the type->js info hash table
TypeTest<cocos2d::Skeleton3D> t; JS::RootedObject proto(cx, jsb_cocos2d_Skeleton3D_prototype);
js_type_class_t *p; jsb_register_class<cocos2d::Skeleton3D>(cx, jsb_cocos2d_Skeleton3D_class, proto, JS::NullPtr());
std::string typeName = t.s_name();
if (_js_global_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));
}
} }
JSClass *jsb_cocos2d_Skybox_class; 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).isNull()) { arg0 = nullptr; break; }
if (!args.get(0).isObject()) { ok = false; break; } if (!args.get(0).isObject()) { ok = false; break; }
js_proxy_t *jsProxy; js_proxy_t *jsProxy;
JSObject *tmpObj = args.get(0).toObjectOrNull(); JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull());
jsProxy = jsb_get_js_proxy(tmpObj); jsProxy = jsb_get_js_proxy(tmpObj);
arg0 = (cocos2d::TextureCube*)(jsProxy ? jsProxy->ptr : NULL); arg0 = (cocos2d::TextureCube*)(jsProxy ? jsProxy->ptr : NULL);
JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); 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!"); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!");
typeClass = typeMapIter->second; typeClass = typeMapIter->second;
CCASSERT(typeClass, "The value is null."); CCASSERT(typeClass, "The value is null.");
JS::RootedObject proto(cx, typeClass->proto.get()); JS::RootedObject proto(cx, typeClass->proto.ref());
JS::RootedObject parent(cx, typeClass->parentProto.get()); JS::RootedObject parent(cx, typeClass->parentProto.ref());
JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent));
args.rval().set(OBJECT_TO_JSVAL(obj)); args.rval().set(OBJECT_TO_JSVAL(obj));
// link the native object with the javascript object // 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_FS_END
}; };
JS::RootedObject parent_proto(cx, jsb_cocos2d_Node_prototype);
jsb_cocos2d_Skybox_prototype = JS_InitClass( jsb_cocos2d_Skybox_prototype = JS_InitClass(
cx, global, cx, global,
JS::RootedObject(cx, jsb_cocos2d_Node_prototype), parent_proto,
jsb_cocos2d_Skybox_class, jsb_cocos2d_Skybox_class,
js_cocos2dx_3d_Skybox_constructor, 0, // constructor js_cocos2dx_3d_Skybox_constructor, 0, // constructor
properties, properties,
funcs, funcs,
NULL, // no static properties NULL, // no static properties
st_funcs); 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 // add the proto and JSClass to the type->js info hash table
TypeTest<cocos2d::Skybox> t; JS::RootedObject proto(cx, jsb_cocos2d_Skybox_prototype);
js_type_class_t *p; jsb_register_class<cocos2d::Skybox>(cx, jsb_cocos2d_Skybox_class, proto, parent_proto);
std::string typeName = t.s_name();
if (_js_global_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));
}
} }
JSClass *jsb_cocos2d_Sprite3D_class; 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::CallArgs args = JS::CallArgsFromVp(argc, vp);
JS::RootedObject obj(cx); JS::RootedObject obj(cx);
obj = args.thisv().toObjectOrNull(); obj.set(args.thisv().toObjectOrNull());
js_proxy_t *proxy = jsb_get_js_proxy(obj); js_proxy_t *proxy = jsb_get_js_proxy(obj);
cobj = (cocos2d::Sprite3D *)(proxy ? proxy->ptr : nullptr); cobj = (cocos2d::Sprite3D *)(proxy ? proxy->ptr : nullptr);
JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_Sprite3D_setTexture : Invalid Native Object"); 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).isNull()) { arg0 = nullptr; break; }
if (!args.get(0).isObject()) { ok = false; break; } if (!args.get(0).isObject()) { ok = false; break; }
js_proxy_t *jsProxy; js_proxy_t *jsProxy;
JSObject *tmpObj = args.get(0).toObjectOrNull(); JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull());
jsProxy = jsb_get_js_proxy(tmpObj); jsProxy = jsb_get_js_proxy(tmpObj);
arg0 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); arg0 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL);
JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); 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).isNull()) { arg0 = nullptr; break; }
if (!args.get(0).isObject()) { ok = false; break; } if (!args.get(0).isObject()) { ok = false; break; }
js_proxy_t *jsProxy; js_proxy_t *jsProxy;
JSObject *tmpObj = args.get(0).toObjectOrNull(); JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull());
jsProxy = jsb_get_js_proxy(tmpObj); jsProxy = jsb_get_js_proxy(tmpObj);
arg0 = (cocos2d::Mesh*)(jsProxy ? jsProxy->ptr : NULL); arg0 = (cocos2d::Mesh*)(jsProxy ? jsProxy->ptr : NULL);
JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); 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::CallArgs args = JS::CallArgsFromVp(argc, vp);
JS::RootedObject obj(cx); JS::RootedObject obj(cx);
obj = args.thisv().toObjectOrNull(); obj.set(args.thisv().toObjectOrNull());
js_proxy_t *proxy = jsb_get_js_proxy(obj); js_proxy_t *proxy = jsb_get_js_proxy(obj);
cobj = (cocos2d::Sprite3D *)(proxy ? proxy->ptr : nullptr); cobj = (cocos2d::Sprite3D *)(proxy ? proxy->ptr : nullptr);
JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_Sprite3D_setMaterial : Invalid Native Object"); 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).isNull()) { arg0 = nullptr; break; }
if (!args.get(0).isObject()) { ok = false; break; } if (!args.get(0).isObject()) { ok = false; break; }
js_proxy_t *jsProxy; js_proxy_t *jsProxy;
JSObject *tmpObj = args.get(0).toObjectOrNull(); JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull());
jsProxy = jsb_get_js_proxy(tmpObj); jsProxy = jsb_get_js_proxy(tmpObj);
arg0 = (cocos2d::Material*)(jsProxy ? jsProxy->ptr : NULL); arg0 = (cocos2d::Material*)(jsProxy ? jsProxy->ptr : NULL);
JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); 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).isNull()) { arg0 = nullptr; break; }
if (!args.get(0).isObject()) { ok = false; break; } if (!args.get(0).isObject()) { ok = false; break; }
js_proxy_t *jsProxy; js_proxy_t *jsProxy;
JSObject *tmpObj = args.get(0).toObjectOrNull(); JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull());
jsProxy = jsb_get_js_proxy(tmpObj); jsProxy = jsb_get_js_proxy(tmpObj);
arg0 = (cocos2d::Material*)(jsProxy ? jsProxy->ptr : NULL); arg0 = (cocos2d::Material*)(jsProxy ? jsProxy->ptr : NULL);
JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); 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).isNull()) { arg1 = nullptr; break; }
if (!args.get(1).isObject()) { ok = false; break; } if (!args.get(1).isObject()) { ok = false; break; }
js_proxy_t *jsProxy; js_proxy_t *jsProxy;
JSObject *tmpObj = args.get(1).toObjectOrNull(); JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull());
jsProxy = jsb_get_js_proxy(tmpObj); jsProxy = jsb_get_js_proxy(tmpObj);
arg1 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); arg1 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL);
JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); 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!"); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!");
typeClass = typeMapIter->second; typeClass = typeMapIter->second;
CCASSERT(typeClass, "The value is null."); CCASSERT(typeClass, "The value is null.");
JS::RootedObject proto(cx, typeClass->proto.get()); JS::RootedObject proto(cx, typeClass->proto.ref());
JS::RootedObject parent(cx, typeClass->parentProto.get()); JS::RootedObject parent(cx, typeClass->parentProto.ref());
JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent));
args.rval().set(OBJECT_TO_JSVAL(obj)); args.rval().set(OBJECT_TO_JSVAL(obj));
// link the native object with the javascript object // 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_FS_END
}; };
JS::RootedObject parent_proto(cx, jsb_cocos2d_Node_prototype);
jsb_cocos2d_Sprite3D_prototype = JS_InitClass( jsb_cocos2d_Sprite3D_prototype = JS_InitClass(
cx, global, cx, global,
JS::RootedObject(cx, jsb_cocos2d_Node_prototype), parent_proto,
jsb_cocos2d_Sprite3D_class, jsb_cocos2d_Sprite3D_class,
js_cocos2dx_3d_Sprite3D_constructor, 0, // constructor js_cocos2dx_3d_Sprite3D_constructor, 0, // constructor
properties, properties,
funcs, funcs,
NULL, // no static properties NULL, // no static properties
st_funcs); 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 // add the proto and JSClass to the type->js info hash table
TypeTest<cocos2d::Sprite3D> t; JS::RootedObject proto(cx, jsb_cocos2d_Sprite3D_prototype);
js_type_class_t *p; jsb_register_class<cocos2d::Sprite3D>(cx, jsb_cocos2d_Sprite3D_class, proto, parent_proto);
std::string typeName = t.s_name();
if (_js_global_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));
}
anonEvaluate(cx, global, "(function () { jsb.Sprite3D.extend = cc.Class.extend; })()"); 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( jsb_cocos2d_Sprite3DCache_prototype = JS_InitClass(
cx, global, cx, global,
JS::NullPtr(), // parent proto JS::NullPtr(),
jsb_cocos2d_Sprite3DCache_class, jsb_cocos2d_Sprite3DCache_class,
empty_constructor, 0, empty_constructor, 0,
properties, properties,
funcs, funcs,
NULL, // no static properties NULL, // no static properties
st_funcs); 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 // add the proto and JSClass to the type->js info hash table
TypeTest<cocos2d::Sprite3DCache> t; JS::RootedObject proto(cx, jsb_cocos2d_Sprite3DCache_prototype);
js_type_class_t *p; jsb_register_class<cocos2d::Sprite3DCache>(cx, jsb_cocos2d_Sprite3DCache_class, proto, JS::NullPtr());
std::string typeName = t.s_name();
if (_js_global_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));
}
} }
JSClass *jsb_cocos2d_Terrain_class; 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).isNull()) { arg0 = nullptr; break; }
if (!args.get(0).isObject()) { ok = false; break; } if (!args.get(0).isObject()) { ok = false; break; }
js_proxy_t *jsProxy; js_proxy_t *jsProxy;
JSObject *tmpObj = args.get(0).toObjectOrNull(); JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull());
jsProxy = jsb_get_js_proxy(tmpObj); jsProxy = jsb_get_js_proxy(tmpObj);
arg0 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); arg0 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL);
JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); 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::CallArgs args = JS::CallArgsFromVp(argc, vp);
JS::RootedObject obj(cx); JS::RootedObject obj(cx);
obj = args.thisv().toObjectOrNull(); obj.set(args.thisv().toObjectOrNull());
js_proxy_t *proxy = jsb_get_js_proxy(obj); js_proxy_t *proxy = jsb_get_js_proxy(obj);
cobj = (cocos2d::Terrain *)(proxy ? proxy->ptr : nullptr); cobj = (cocos2d::Terrain *)(proxy ? proxy->ptr : nullptr);
JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_Terrain_getHeight : Invalid Native Object"); 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).isNull()) { arg1 = nullptr; break; }
if (!args.get(1).isObject()) { ok = false; break; } if (!args.get(1).isObject()) { ok = false; break; }
js_proxy_t *jsProxy; js_proxy_t *jsProxy;
JSObject *tmpObj = args.get(1).toObjectOrNull(); JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull());
jsProxy = jsb_get_js_proxy(tmpObj); jsProxy = jsb_get_js_proxy(tmpObj);
arg1 = (cocos2d::Vec3*)(jsProxy ? jsProxy->ptr : NULL); arg1 = (cocos2d::Vec3*)(jsProxy ? jsProxy->ptr : NULL);
JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); 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).isNull()) { arg2 = nullptr; break; }
if (!args.get(2).isObject()) { ok = false; break; } if (!args.get(2).isObject()) { ok = false; break; }
js_proxy_t *jsProxy; js_proxy_t *jsProxy;
JSObject *tmpObj = args.get(2).toObjectOrNull(); JS::RootedObject tmpObj(cx, args.get(2).toObjectOrNull());
jsProxy = jsb_get_js_proxy(tmpObj); jsProxy = jsb_get_js_proxy(tmpObj);
arg2 = (cocos2d::Vec3*)(jsProxy ? jsProxy->ptr : NULL); arg2 = (cocos2d::Vec3*)(jsProxy ? jsProxy->ptr : NULL);
JSB_PRECONDITION2( arg2, cx, false, "Invalid Native Object"); 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::CallArgs args = JS::CallArgsFromVp(argc, vp);
JS::RootedObject obj(cx); JS::RootedObject obj(cx);
obj = args.thisv().toObjectOrNull(); obj.set(args.thisv().toObjectOrNull());
js_proxy_t *proxy = jsb_get_js_proxy(obj); js_proxy_t *proxy = jsb_get_js_proxy(obj);
cobj = (cocos2d::Terrain *)(proxy ? proxy->ptr : nullptr); cobj = (cocos2d::Terrain *)(proxy ? proxy->ptr : nullptr);
JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_Terrain_getIntersectionPoint : Invalid Native Object"); 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!"); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!");
typeClass = typeMapIter->second; typeClass = typeMapIter->second;
CCASSERT(typeClass, "The value is null."); CCASSERT(typeClass, "The value is null.");
JS::RootedObject proto(cx, typeClass->proto.get()); JS::RootedObject proto(cx, typeClass->proto.ref());
JS::RootedObject parent(cx, typeClass->parentProto.get()); JS::RootedObject parent(cx, typeClass->parentProto.ref());
JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent));
args.rval().set(OBJECT_TO_JSVAL(obj)); args.rval().set(OBJECT_TO_JSVAL(obj));
// link the native object with the javascript object // 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; JSFunctionSpec *st_funcs = NULL;
JS::RootedObject parent_proto(cx, jsb_cocos2d_Node_prototype);
jsb_cocos2d_Terrain_prototype = JS_InitClass( jsb_cocos2d_Terrain_prototype = JS_InitClass(
cx, global, cx, global,
JS::RootedObject(cx, jsb_cocos2d_Node_prototype), parent_proto,
jsb_cocos2d_Terrain_class, jsb_cocos2d_Terrain_class,
js_cocos2dx_3d_Terrain_constructor, 0, // constructor js_cocos2dx_3d_Terrain_constructor, 0, // constructor
properties, properties,
funcs, funcs,
NULL, // no static properties NULL, // no static properties
st_funcs); 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 // add the proto and JSClass to the type->js info hash table
TypeTest<cocos2d::Terrain> t; JS::RootedObject proto(cx, jsb_cocos2d_Terrain_prototype);
js_type_class_t *p; jsb_register_class<cocos2d::Terrain>(cx, jsb_cocos2d_Terrain_class, proto, parent_proto);
std::string typeName = t.s_name();
if (_js_global_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));
}
} }
JSClass *jsb_cocos2d_Bundle3D_class; 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).isNull()) { arg0 = nullptr; break; }
if (!args.get(0).isObject()) { ok = false; break; } if (!args.get(0).isObject()) { ok = false; break; }
js_proxy_t *jsProxy; js_proxy_t *jsProxy;
JSObject *tmpObj = args.get(0).toObjectOrNull(); JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull());
jsProxy = jsb_get_js_proxy(tmpObj); jsProxy = jsb_get_js_proxy(tmpObj);
arg0 = (cocos2d::Bundle3D*)(jsProxy ? jsProxy->ptr : NULL); arg0 = (cocos2d::Bundle3D*)(jsProxy ? jsProxy->ptr : NULL);
JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); 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!"); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!");
typeClass = typeMapIter->second; typeClass = typeMapIter->second;
CCASSERT(typeClass, "The value is null."); CCASSERT(typeClass, "The value is null.");
JS::RootedObject proto(cx, typeClass->proto.get()); JS::RootedObject proto(cx, typeClass->proto.ref());
JS::RootedObject parent(cx, typeClass->parentProto.get()); JS::RootedObject parent(cx, typeClass->parentProto.ref());
JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent));
args.rval().set(OBJECT_TO_JSVAL(obj)); args.rval().set(OBJECT_TO_JSVAL(obj));
// link the native object with the javascript object // 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); CCLOGINFO("jsbindings: finalizing JS object %p (Bundle3D)", obj);
js_proxy_t* nproxy; js_proxy_t* nproxy;
js_proxy_t* jsproxy; 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) { if (jsproxy) {
cocos2d::Bundle3D *nobj = static_cast<cocos2d::Bundle3D *>(jsproxy->ptr); cocos2d::Bundle3D *nobj = static_cast<cocos2d::Bundle3D *>(jsproxy->ptr);
nproxy = jsb_get_native_proxy(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( jsb_cocos2d_Bundle3D_prototype = JS_InitClass(
cx, global, cx, global,
JS::NullPtr(), // parent proto JS::NullPtr(),
jsb_cocos2d_Bundle3D_class, jsb_cocos2d_Bundle3D_class,
js_cocos2dx_3d_Bundle3D_constructor, 0, // constructor js_cocos2dx_3d_Bundle3D_constructor, 0, // constructor
properties, properties,
funcs, funcs,
NULL, // no static properties NULL, // no static properties
st_funcs); 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 // add the proto and JSClass to the type->js info hash table
TypeTest<cocos2d::Bundle3D> t; JS::RootedObject proto(cx, jsb_cocos2d_Bundle3D_prototype);
js_type_class_t *p; jsb_register_class<cocos2d::Bundle3D>(cx, jsb_cocos2d_Bundle3D_class, proto, JS::NullPtr());
std::string typeName = t.s_name();
if (_js_global_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));
}
} }
void register_all_cocos2dx_3d(JSContext* cx, JS::HandleObject obj) { void register_all_cocos2dx_3d(JSContext* cx, JS::HandleObject obj) {

View File

@ -19,8 +19,8 @@ static bool dummy_constructor(JSContext *cx, uint32_t argc, jsval *vp) {
typeClass = typeMapIter->second; typeClass = typeMapIter->second;
CCASSERT(typeClass, "The value is null."); CCASSERT(typeClass, "The value is null.");
JS::RootedObject proto(cx, typeClass->proto.get()); JS::RootedObject proto(cx, typeClass->proto.ref());
JS::RootedObject parent(cx, typeClass->parentProto.get()); JS::RootedObject parent(cx, typeClass->parentProto.ref());
JS::RootedObject _tmp(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); JS::RootedObject _tmp(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent));
args.rval().set(OBJECT_TO_JSVAL(_tmp)); 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!"); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!");
typeClass = typeMapIter->second; typeClass = typeMapIter->second;
CCASSERT(typeClass, "The value is null."); CCASSERT(typeClass, "The value is null.");
JS::RootedObject proto(cx, typeClass->proto.get()); JS::RootedObject proto(cx, typeClass->proto.ref());
JS::RootedObject parent(cx, typeClass->parentProto.get()); JS::RootedObject parent(cx, typeClass->parentProto.ref());
JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent));
args.rval().set(OBJECT_TO_JSVAL(obj)); args.rval().set(OBJECT_TO_JSVAL(obj));
// link the native object with the javascript object // 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; JSFunctionSpec *st_funcs = NULL;
JS::RootedObject parent_proto(cx, jsb_cocos2d_Node_prototype);
jsb_cocos2d_ParticleSystem3D_prototype = JS_InitClass( jsb_cocos2d_ParticleSystem3D_prototype = JS_InitClass(
cx, global, cx, global,
JS::RootedObject(cx, jsb_cocos2d_Node_prototype), parent_proto,
jsb_cocos2d_ParticleSystem3D_class, jsb_cocos2d_ParticleSystem3D_class,
js_cocos2dx_3d_extension_ParticleSystem3D_constructor, 0, // constructor js_cocos2dx_3d_extension_ParticleSystem3D_constructor, 0, // constructor
properties, properties,
funcs, funcs,
NULL, // no static properties NULL, // no static properties
st_funcs); 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 // add the proto and JSClass to the type->js info hash table
TypeTest<cocos2d::ParticleSystem3D> t; JS::RootedObject proto(cx, jsb_cocos2d_ParticleSystem3D_prototype);
js_type_class_t *p; jsb_register_class<cocos2d::ParticleSystem3D>(cx, jsb_cocos2d_ParticleSystem3D_class, proto, parent_proto);
std::string typeName = t.s_name();
if (_js_global_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));
}
} }
JSClass *jsb_cocos2d_PUParticleSystem3D_class; 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).isNull()) { arg0 = nullptr; break; }
if (!args.get(0).isObject()) { ok = false; break; } if (!args.get(0).isObject()) { ok = false; break; }
js_proxy_t *jsProxy; js_proxy_t *jsProxy;
JSObject *tmpObj = args.get(0).toObjectOrNull(); JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull());
jsProxy = jsb_get_js_proxy(tmpObj); jsProxy = jsb_get_js_proxy(tmpObj);
arg0 = (cocos2d::PUParticleSystem3D*)(jsProxy ? jsProxy->ptr : NULL); arg0 = (cocos2d::PUParticleSystem3D*)(jsProxy ? jsProxy->ptr : NULL);
JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); 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!"); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!");
typeClass = typeMapIter->second; typeClass = typeMapIter->second;
CCASSERT(typeClass, "The value is null."); CCASSERT(typeClass, "The value is null.");
JS::RootedObject proto(cx, typeClass->proto.get()); JS::RootedObject proto(cx, typeClass->proto.ref());
JS::RootedObject parent(cx, typeClass->parentProto.get()); JS::RootedObject parent(cx, typeClass->parentProto.ref());
JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent));
args.rval().set(OBJECT_TO_JSVAL(obj)); args.rval().set(OBJECT_TO_JSVAL(obj));
// link the native object with the javascript object // 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_FS_END
}; };
JS::RootedObject parent_proto(cx, jsb_cocos2d_ParticleSystem3D_prototype);
jsb_cocos2d_PUParticleSystem3D_prototype = JS_InitClass( jsb_cocos2d_PUParticleSystem3D_prototype = JS_InitClass(
cx, global, cx, global,
JS::RootedObject(cx, jsb_cocos2d_ParticleSystem3D_prototype), parent_proto,
jsb_cocos2d_PUParticleSystem3D_class, jsb_cocos2d_PUParticleSystem3D_class,
js_cocos2dx_3d_extension_PUParticleSystem3D_constructor, 0, // constructor js_cocos2dx_3d_extension_PUParticleSystem3D_constructor, 0, // constructor
properties, properties,
funcs, funcs,
NULL, // no static properties NULL, // no static properties
st_funcs); 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 // add the proto and JSClass to the type->js info hash table
TypeTest<cocos2d::PUParticleSystem3D> t; JS::RootedObject proto(cx, jsb_cocos2d_PUParticleSystem3D_prototype);
js_type_class_t *p; jsb_register_class<cocos2d::PUParticleSystem3D>(cx, jsb_cocos2d_PUParticleSystem3D_class, proto, parent_proto);
std::string typeName = t.s_name();
if (_js_global_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));
}
} }
void register_all_cocos2dx_3d_extension(JSContext* cx, JS::HandleObject obj) { void register_all_cocos2dx_3d_extension(JSContext* cx, JS::HandleObject obj) {

View File

@ -20,8 +20,8 @@ static bool dummy_constructor(JSContext *cx, uint32_t argc, jsval *vp) {
typeClass = typeMapIter->second; typeClass = typeMapIter->second;
CCASSERT(typeClass, "The value is null."); CCASSERT(typeClass, "The value is null.");
JS::RootedObject proto(cx, typeClass->proto.get()); JS::RootedObject proto(cx, typeClass->proto.ref());
JS::RootedObject parent(cx, typeClass->parentProto.get()); JS::RootedObject parent(cx, typeClass->parentProto.ref());
JS::RootedObject _tmp(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); JS::RootedObject _tmp(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent));
args.rval().set(OBJECT_TO_JSVAL(_tmp)); 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) bool js_cocos2dx_audioengine_AudioProfile_get_name(JSContext *cx, uint32_t argc, jsval *vp)
{ {
JS::CallArgs args = JS::CallArgsFromVp(argc, 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); 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"); 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) bool js_cocos2dx_audioengine_AudioProfile_set_name(JSContext *cx, uint32_t argc, jsval *vp)
{ {
JS::CallArgs args = JS::CallArgsFromVp(argc, 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); 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"); 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) bool js_cocos2dx_audioengine_AudioProfile_get_maxInstances(JSContext *cx, uint32_t argc, jsval *vp)
{ {
JS::CallArgs args = JS::CallArgsFromVp(argc, 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); 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"); 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) bool js_cocos2dx_audioengine_AudioProfile_set_maxInstances(JSContext *cx, uint32_t argc, jsval *vp)
{ {
JS::CallArgs args = JS::CallArgsFromVp(argc, 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); 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"); 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) bool js_cocos2dx_audioengine_AudioProfile_get_minDelay(JSContext *cx, uint32_t argc, jsval *vp)
{ {
JS::CallArgs args = JS::CallArgsFromVp(argc, 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); 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"); 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) bool js_cocos2dx_audioengine_AudioProfile_set_minDelay(JSContext *cx, uint32_t argc, jsval *vp)
{ {
JS::CallArgs args = JS::CallArgsFromVp(argc, 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); 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"); 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!"); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!");
typeClass = typeMapIter->second; typeClass = typeMapIter->second;
CCASSERT(typeClass, "The value is null."); CCASSERT(typeClass, "The value is null.");
JS::RootedObject proto(cx, typeClass->proto.get()); JS::RootedObject proto(cx, typeClass->proto.ref());
JS::RootedObject parent(cx, typeClass->parentProto.get()); JS::RootedObject parent(cx, typeClass->parentProto.ref());
JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent));
args.rval().set(OBJECT_TO_JSVAL(obj)); args.rval().set(OBJECT_TO_JSVAL(obj));
// link the native object with the javascript object // 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); CCLOGINFO("jsbindings: finalizing JS object %p (AudioProfile)", obj);
js_proxy_t* nproxy; js_proxy_t* nproxy;
js_proxy_t* jsproxy; 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) { if (jsproxy) {
cocos2d::experimental::AudioProfile *nobj = static_cast<cocos2d::experimental::AudioProfile *>(jsproxy->ptr); cocos2d::experimental::AudioProfile *nobj = static_cast<cocos2d::experimental::AudioProfile *>(jsproxy->ptr);
nproxy = jsb_get_native_proxy(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( jsb_cocos2d_experimental_AudioProfile_prototype = JS_InitClass(
cx, global, cx, global,
JS::NullPtr(), // parent proto JS::NullPtr(),
jsb_cocos2d_experimental_AudioProfile_class, jsb_cocos2d_experimental_AudioProfile_class,
js_cocos2dx_audioengine_AudioProfile_constructor, 0, // constructor js_cocos2dx_audioengine_AudioProfile_constructor, 0, // constructor
properties, properties,
funcs, funcs,
NULL, // no static properties NULL, // no static properties
st_funcs); 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 // add the proto and JSClass to the type->js info hash table
TypeTest<cocos2d::experimental::AudioProfile> t; JS::RootedObject proto(cx, jsb_cocos2d_experimental_AudioProfile_prototype);
js_type_class_t *p; jsb_register_class<cocos2d::experimental::AudioProfile>(cx, jsb_cocos2d_experimental_AudioProfile_class, proto, JS::NullPtr());
std::string typeName = t.s_name();
if (_js_global_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));
}
} }
JSClass *jsb_cocos2d_experimental_AudioEngine_class; JSClass *jsb_cocos2d_experimental_AudioEngine_class;
@ -462,7 +457,8 @@ bool js_cocos2dx_audioengine_AudioEngine_preload(JSContext *cx, uint32_t argc, j
do { do {
if(JS_TypeOfValue(cx, args.get(1)) == JSTYPE_FUNCTION) if(JS_TypeOfValue(cx, args.get(1)) == JSTYPE_FUNCTION)
{ {
std::shared_ptr<JSFunctionWrapper> func(new JSFunctionWrapper(cx, args.thisv().toObjectOrNull(), args.get(1))); JS::RootedObject jstarget(cx, args.thisv().toObjectOrNull());
std::shared_ptr<JSFunctionWrapper> func(new JSFunctionWrapper(cx, jstarget, args.get(1)));
auto lambda = [=](bool larg0) -> void { auto lambda = [=](bool larg0) -> void {
JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET
jsval largv[1]; 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).isNull()) { arg3 = nullptr; break; }
if (!args.get(3).isObject()) { ok = false; break; } if (!args.get(3).isObject()) { ok = false; break; }
js_proxy_t *jsProxy; js_proxy_t *jsProxy;
JSObject *tmpObj = args.get(3).toObjectOrNull(); JS::RootedObject tmpObj(cx, args.get(3).toObjectOrNull());
jsProxy = jsb_get_js_proxy(tmpObj); jsProxy = jsb_get_js_proxy(tmpObj);
arg3 = (const cocos2d::experimental::AudioProfile*)(jsProxy ? jsProxy->ptr : NULL); arg3 = (const cocos2d::experimental::AudioProfile*)(jsProxy ? jsProxy->ptr : NULL);
JSB_PRECONDITION2( arg3, cx, false, "Invalid Native Object"); JSB_PRECONDITION2( arg3, cx, false, "Invalid Native Object");
@ -685,7 +681,8 @@ bool js_cocos2dx_audioengine_AudioEngine_setFinishCallback(JSContext *cx, uint32
do { do {
if(JS_TypeOfValue(cx, args.get(1)) == JSTYPE_FUNCTION) if(JS_TypeOfValue(cx, args.get(1)) == JSTYPE_FUNCTION)
{ {
std::shared_ptr<JSFunctionWrapper> func(new JSFunctionWrapper(cx, args.thisv().toObjectOrNull(), args.get(1))); JS::RootedObject jstarget(cx, args.thisv().toObjectOrNull());
std::shared_ptr<JSFunctionWrapper> func(new JSFunctionWrapper(cx, jstarget, args.get(1)));
auto lambda = [=](int larg0, const std::basic_string<char> & larg1) -> void { auto lambda = [=](int larg0, const std::basic_string<char> & larg1) -> void {
JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET
jsval largv[2]; jsval largv[2];
@ -818,30 +815,17 @@ void js_register_cocos2dx_audioengine_AudioEngine(JSContext *cx, JS::HandleObjec
jsb_cocos2d_experimental_AudioEngine_prototype = JS_InitClass( jsb_cocos2d_experimental_AudioEngine_prototype = JS_InitClass(
cx, global, cx, global,
JS::NullPtr(), // parent proto JS::NullPtr(),
jsb_cocos2d_experimental_AudioEngine_class, jsb_cocos2d_experimental_AudioEngine_class,
empty_constructor, 0, empty_constructor, 0,
properties, properties,
funcs, funcs,
NULL, // no static properties NULL, // no static properties
st_funcs); 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 // add the proto and JSClass to the type->js info hash table
TypeTest<cocos2d::experimental::AudioEngine> t; JS::RootedObject proto(cx, jsb_cocos2d_experimental_AudioEngine_prototype);
js_type_class_t *p; jsb_register_class<cocos2d::experimental::AudioEngine>(cx, jsb_cocos2d_experimental_AudioEngine_class, proto, JS::NullPtr());
std::string typeName = t.s_name();
if (_js_global_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));
}
} }
void register_all_cocos2dx_audioengine(JSContext* cx, JS::HandleObject obj) { void register_all_cocos2dx_audioengine(JSContext* cx, JS::HandleObject obj) {

File diff suppressed because it is too large Load Diff

View File

@ -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_isEnabled(JSContext *cx, uint32_t argc, jsval *vp);
bool js_cocos2dx_MenuItem_selected(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_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_unselected(JSContext *cx, uint32_t argc, jsval *vp);
bool js_cocos2dx_MenuItem_rect(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); bool js_cocos2dx_MenuItem_MenuItem(JSContext *cx, uint32_t argc, jsval *vp);

View File

@ -19,8 +19,8 @@ static bool dummy_constructor(JSContext *cx, uint32_t argc, jsval *vp) {
typeClass = typeMapIter->second; typeClass = typeMapIter->second;
CCASSERT(typeClass, "The value is null."); CCASSERT(typeClass, "The value is null.");
JS::RootedObject proto(cx, typeClass->proto.get()); JS::RootedObject proto(cx, typeClass->proto.ref());
JS::RootedObject parent(cx, typeClass->parentProto.get()); JS::RootedObject parent(cx, typeClass->parentProto.ref());
JS::RootedObject _tmp(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); JS::RootedObject _tmp(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent));
args.rval().set(OBJECT_TO_JSVAL(_tmp)); 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).isNull()) { arg0 = nullptr; break; }
if (!args.get(0).isObject()) { ok = false; break; } if (!args.get(0).isObject()) { ok = false; break; }
js_proxy_t *jsProxy; js_proxy_t *jsProxy;
JSObject *tmpObj = args.get(0).toObjectOrNull(); JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull());
jsProxy = jsb_get_js_proxy(tmpObj); jsProxy = jsb_get_js_proxy(tmpObj);
arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL);
JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); 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).isNull()) { arg1 = nullptr; break; }
if (!args.get(1).isObject()) { ok = false; break; } if (!args.get(1).isObject()) { ok = false; break; }
js_proxy_t *jsProxy; js_proxy_t *jsProxy;
JSObject *tmpObj = args.get(1).toObjectOrNull(); JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull());
jsProxy = jsb_get_js_proxy(tmpObj); jsProxy = jsb_get_js_proxy(tmpObj);
arg1 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); arg1 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL);
JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); 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).isNull()) { arg0 = nullptr; break; }
if (!args.get(0).isObject()) { ok = false; break; } if (!args.get(0).isObject()) { ok = false; break; }
js_proxy_t *jsProxy; js_proxy_t *jsProxy;
JSObject *tmpObj = args.get(0).toObjectOrNull(); JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull());
jsProxy = jsb_get_js_proxy(tmpObj); jsProxy = jsb_get_js_proxy(tmpObj);
arg0 = (cocosbuilder::CCBSequenceProperty*)(jsProxy ? jsProxy->ptr : NULL); arg0 = (cocosbuilder::CCBSequenceProperty*)(jsProxy ? jsProxy->ptr : NULL);
JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); 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).isNull()) { arg1 = nullptr; break; }
if (!args.get(1).isObject()) { ok = false; break; } if (!args.get(1).isObject()) { ok = false; break; }
js_proxy_t *jsProxy; js_proxy_t *jsProxy;
JSObject *tmpObj = args.get(1).toObjectOrNull(); JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull());
jsProxy = jsb_get_js_proxy(tmpObj); jsProxy = jsb_get_js_proxy(tmpObj);
arg1 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); arg1 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL);
JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); 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).isNull()) { arg0 = nullptr; break; }
if (!args.get(0).isObject()) { ok = false; break; } if (!args.get(0).isObject()) { ok = false; break; }
js_proxy_t *jsProxy; js_proxy_t *jsProxy;
JSObject *tmpObj = args.get(0).toObjectOrNull(); JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull());
jsProxy = jsb_get_js_proxy(tmpObj); jsProxy = jsb_get_js_proxy(tmpObj);
arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL);
JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); 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).isNull()) { arg0 = nullptr; break; }
if (!args.get(0).isObject()) { ok = false; break; } if (!args.get(0).isObject()) { ok = false; break; }
js_proxy_t *jsProxy; js_proxy_t *jsProxy;
JSObject *tmpObj = args.get(0).toObjectOrNull(); JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull());
jsProxy = jsb_get_js_proxy(tmpObj); jsProxy = jsb_get_js_proxy(tmpObj);
arg0 = (cocos2d::Ref*)(jsProxy ? jsProxy->ptr : NULL); arg0 = (cocos2d::Ref*)(jsProxy ? jsProxy->ptr : NULL);
JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); 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).isNull()) { arg1 = nullptr; break; }
if (!args.get(1).isObject()) { ok = false; break; } if (!args.get(1).isObject()) { ok = false; break; }
js_proxy_t *jsProxy; js_proxy_t *jsProxy;
JSObject *tmpObj = args.get(1).toObjectOrNull(); JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull());
jsProxy = jsb_get_js_proxy(tmpObj); jsProxy = jsb_get_js_proxy(tmpObj);
arg1 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); arg1 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL);
JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); 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).isNull()) { arg0 = nullptr; break; }
if (!args.get(0).isObject()) { ok = false; break; } if (!args.get(0).isObject()) { ok = false; break; }
js_proxy_t *jsProxy; js_proxy_t *jsProxy;
JSObject *tmpObj = args.get(0).toObjectOrNull(); JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull());
jsProxy = jsb_get_js_proxy(tmpObj); jsProxy = jsb_get_js_proxy(tmpObj);
arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL);
JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); 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).isNull()) { arg0 = nullptr; break; }
if (!args.get(0).isObject()) { ok = false; break; } if (!args.get(0).isObject()) { ok = false; break; }
js_proxy_t *jsProxy; js_proxy_t *jsProxy;
JSObject *tmpObj = args.get(0).toObjectOrNull(); JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull());
jsProxy = jsb_get_js_proxy(tmpObj); jsProxy = jsb_get_js_proxy(tmpObj);
arg0 = (cocosbuilder::CCBSequenceProperty*)(jsProxy ? jsProxy->ptr : NULL); arg0 = (cocosbuilder::CCBSequenceProperty*)(jsProxy ? jsProxy->ptr : NULL);
JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); 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).isNull()) { arg0 = nullptr; break; }
if (!args.get(0).isObject()) { ok = false; break; } if (!args.get(0).isObject()) { ok = false; break; }
js_proxy_t *jsProxy; js_proxy_t *jsProxy;
JSObject *tmpObj = args.get(0).toObjectOrNull(); JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull());
jsProxy = jsb_get_js_proxy(tmpObj); jsProxy = jsb_get_js_proxy(tmpObj);
arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL);
JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); 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).isNull()) { arg0 = nullptr; break; }
if (!args.get(0).isObject()) { ok = false; break; } if (!args.get(0).isObject()) { ok = false; break; }
js_proxy_t *jsProxy; js_proxy_t *jsProxy;
JSObject *tmpObj = args.get(0).toObjectOrNull(); JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull());
jsProxy = jsb_get_js_proxy(tmpObj); jsProxy = jsb_get_js_proxy(tmpObj);
arg0 = (cocosbuilder::CCBAnimationManagerDelegate*)(jsProxy ? jsProxy->ptr : NULL); arg0 = (cocosbuilder::CCBAnimationManagerDelegate*)(jsProxy ? jsProxy->ptr : NULL);
JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); 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).isNull()) { arg0 = nullptr; break; }
if (!args.get(0).isObject()) { ok = false; break; } if (!args.get(0).isObject()) { ok = false; break; }
js_proxy_t *jsProxy; js_proxy_t *jsProxy;
JSObject *tmpObj = args.get(0).toObjectOrNull(); JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull());
jsProxy = jsb_get_js_proxy(tmpObj); jsProxy = jsb_get_js_proxy(tmpObj);
arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL);
JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); 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).isNull()) { arg0 = nullptr; break; }
if (!args.get(0).isObject()) { ok = false; break; } if (!args.get(0).isObject()) { ok = false; break; }
js_proxy_t *jsProxy; js_proxy_t *jsProxy;
JSObject *tmpObj = args.get(0).toObjectOrNull(); JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull());
jsProxy = jsb_get_js_proxy(tmpObj); jsProxy = jsb_get_js_proxy(tmpObj);
arg0 = (cocos2d::CallFunc*)(jsProxy ? jsProxy->ptr : NULL); arg0 = (cocos2d::CallFunc*)(jsProxy ? jsProxy->ptr : NULL);
JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); 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!"); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!");
typeClass = typeMapIter->second; typeClass = typeMapIter->second;
CCASSERT(typeClass, "The value is null."); CCASSERT(typeClass, "The value is null.");
JS::RootedObject proto(cx, typeClass->proto.get()); JS::RootedObject proto(cx, typeClass->proto.ref());
JS::RootedObject parent(cx, typeClass->parentProto.get()); JS::RootedObject parent(cx, typeClass->parentProto.ref());
JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent));
args.rval().set(OBJECT_TO_JSVAL(obj)); args.rval().set(OBJECT_TO_JSVAL(obj));
// link the native object with the javascript object // 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( jsb_cocosbuilder_CCBAnimationManager_prototype = JS_InitClass(
cx, global, cx, global,
JS::NullPtr(), // parent proto JS::NullPtr(),
jsb_cocosbuilder_CCBAnimationManager_class, jsb_cocosbuilder_CCBAnimationManager_class,
js_cocos2dx_builder_CCBAnimationManager_constructor, 0, // constructor js_cocos2dx_builder_CCBAnimationManager_constructor, 0, // constructor
properties, properties,
funcs, funcs,
NULL, // no static properties NULL, // no static properties
st_funcs); 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 // add the proto and JSClass to the type->js info hash table
TypeTest<cocosbuilder::CCBAnimationManager> t; JS::RootedObject proto(cx, jsb_cocosbuilder_CCBAnimationManager_prototype);
js_type_class_t *p; jsb_register_class<cocosbuilder::CCBAnimationManager>(cx, jsb_cocosbuilder_CCBAnimationManager_class, proto, JS::NullPtr());
std::string typeName = t.s_name();
if (_js_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));
}
} }
JSClass *jsb_cocosbuilder_CCBReader_class; 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).isNull()) { arg0 = nullptr; break; }
if (!args.get(0).isObject()) { ok = false; break; } if (!args.get(0).isObject()) { ok = false; break; }
js_proxy_t *jsProxy; js_proxy_t *jsProxy;
JSObject *tmpObj = args.get(0).toObjectOrNull(); JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull());
jsProxy = jsb_get_js_proxy(tmpObj); jsProxy = jsb_get_js_proxy(tmpObj);
arg0 = (cocosbuilder::CCBAnimationManager*)(jsProxy ? jsProxy->ptr : NULL); arg0 = (cocosbuilder::CCBAnimationManager*)(jsProxy ? jsProxy->ptr : NULL);
JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); 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).isNull()) { arg0 = nullptr; break; }
if (!args.get(0).isObject()) { ok = false; break; } if (!args.get(0).isObject()) { ok = false; break; }
js_proxy_t *jsProxy; js_proxy_t *jsProxy;
JSObject *tmpObj = args.get(0).toObjectOrNull(); JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull());
jsProxy = jsb_get_js_proxy(tmpObj); jsProxy = jsb_get_js_proxy(tmpObj);
arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL);
JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); 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).isNull()) { arg0 = nullptr; break; }
if (!args.get(0).isObject()) { ok = false; break; } if (!args.get(0).isObject()) { ok = false; break; }
js_proxy_t *jsProxy; js_proxy_t *jsProxy;
JSObject *tmpObj = args.get(0).toObjectOrNull(); JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull());
jsProxy = jsb_get_js_proxy(tmpObj); jsProxy = jsb_get_js_proxy(tmpObj);
arg0 = (cocosbuilder::CCBSequence*)(jsProxy ? jsProxy->ptr : NULL); arg0 = (cocosbuilder::CCBSequence*)(jsProxy ? jsProxy->ptr : NULL);
JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); 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).isNull()) { arg0 = nullptr; break; }
if (!args.get(0).isObject()) { ok = false; break; } if (!args.get(0).isObject()) { ok = false; break; }
js_proxy_t *jsProxy; js_proxy_t *jsProxy;
JSObject *tmpObj = args.get(0).toObjectOrNull(); JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull());
jsProxy = jsb_get_js_proxy(tmpObj); jsProxy = jsb_get_js_proxy(tmpObj);
arg0 = (cocosbuilder::CCBSequence*)(jsProxy ? jsProxy->ptr : NULL); arg0 = (cocosbuilder::CCBSequence*)(jsProxy ? jsProxy->ptr : NULL);
JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); 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).isNull()) { arg0 = nullptr; break; }
if (!args.get(0).isObject()) { ok = false; break; } if (!args.get(0).isObject()) { ok = false; break; }
js_proxy_t *jsProxy; js_proxy_t *jsProxy;
JSObject *tmpObj = args.get(0).toObjectOrNull(); JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull());
jsProxy = jsb_get_js_proxy(tmpObj); jsProxy = jsb_get_js_proxy(tmpObj);
arg0 = (cocosbuilder::CCBReader*)(jsProxy ? jsProxy->ptr : NULL); arg0 = (cocosbuilder::CCBReader*)(jsProxy ? jsProxy->ptr : NULL);
JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); 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; typeClass = typeMapIter->second;
CCASSERT(typeClass, "The value is null."); CCASSERT(typeClass, "The value is null.");
// obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); // obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto);
JS::RootedObject proto(cx, typeClass->proto.get()); JS::RootedObject proto(cx, typeClass->proto.ref());
JS::RootedObject parent(cx, typeClass->parentProto.get()); JS::RootedObject parent(cx, typeClass->parentProto.ref());
obj = JS_NewObject(cx, typeClass->jsclass, proto, parent); obj = JS_NewObject(cx, typeClass->jsclass, proto, parent);
js_proxy_t* p = jsb_new_proxy(cobj, obj); 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).isNull()) { arg0 = nullptr; break; }
if (!args.get(0).isObject()) { ok = false; break; } if (!args.get(0).isObject()) { ok = false; break; }
js_proxy_t *jsProxy; js_proxy_t *jsProxy;
JSObject *tmpObj = args.get(0).toObjectOrNull(); JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull());
jsProxy = jsb_get_js_proxy(tmpObj); jsProxy = jsb_get_js_proxy(tmpObj);
arg0 = (cocosbuilder::NodeLoaderLibrary*)(jsProxy ? jsProxy->ptr : NULL); arg0 = (cocosbuilder::NodeLoaderLibrary*)(jsProxy ? jsProxy->ptr : NULL);
JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); 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; typeClass = typeMapIter->second;
CCASSERT(typeClass, "The value is null."); CCASSERT(typeClass, "The value is null.");
// obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); // obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto);
JS::RootedObject proto(cx, typeClass->proto.get()); JS::RootedObject proto(cx, typeClass->proto.ref());
JS::RootedObject parent(cx, typeClass->parentProto.get()); JS::RootedObject parent(cx, typeClass->parentProto.ref());
obj = JS_NewObject(cx, typeClass->jsclass, proto, parent); obj = JS_NewObject(cx, typeClass->jsclass, proto, parent);
js_proxy_t* p = jsb_new_proxy(cobj, obj); 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).isNull()) { arg0 = nullptr; break; }
if (!args.get(0).isObject()) { ok = false; break; } if (!args.get(0).isObject()) { ok = false; break; }
js_proxy_t *jsProxy; js_proxy_t *jsProxy;
JSObject *tmpObj = args.get(0).toObjectOrNull(); JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull());
jsProxy = jsb_get_js_proxy(tmpObj); jsProxy = jsb_get_js_proxy(tmpObj);
arg0 = (cocosbuilder::NodeLoaderLibrary*)(jsProxy ? jsProxy->ptr : NULL); arg0 = (cocosbuilder::NodeLoaderLibrary*)(jsProxy ? jsProxy->ptr : NULL);
JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); 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).isNull()) { arg1 = nullptr; break; }
if (!args.get(1).isObject()) { ok = false; break; } if (!args.get(1).isObject()) { ok = false; break; }
js_proxy_t *jsProxy; js_proxy_t *jsProxy;
JSObject *tmpObj = args.get(1).toObjectOrNull(); JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull());
jsProxy = jsb_get_js_proxy(tmpObj); jsProxy = jsb_get_js_proxy(tmpObj);
arg1 = (cocosbuilder::CCBMemberVariableAssigner*)(jsProxy ? jsProxy->ptr : NULL); arg1 = (cocosbuilder::CCBMemberVariableAssigner*)(jsProxy ? jsProxy->ptr : NULL);
JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); 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; typeClass = typeMapIter->second;
CCASSERT(typeClass, "The value is null."); CCASSERT(typeClass, "The value is null.");
// obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); // obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto);
JS::RootedObject proto(cx, typeClass->proto.get()); JS::RootedObject proto(cx, typeClass->proto.ref());
JS::RootedObject parent(cx, typeClass->parentProto.get()); JS::RootedObject parent(cx, typeClass->parentProto.ref());
obj = JS_NewObject(cx, typeClass->jsclass, proto, parent); obj = JS_NewObject(cx, typeClass->jsclass, proto, parent);
js_proxy_t* p = jsb_new_proxy(cobj, obj); 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).isNull()) { arg0 = nullptr; break; }
if (!args.get(0).isObject()) { ok = false; break; } if (!args.get(0).isObject()) { ok = false; break; }
js_proxy_t *jsProxy; js_proxy_t *jsProxy;
JSObject *tmpObj = args.get(0).toObjectOrNull(); JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull());
jsProxy = jsb_get_js_proxy(tmpObj); jsProxy = jsb_get_js_proxy(tmpObj);
arg0 = (cocosbuilder::NodeLoaderLibrary*)(jsProxy ? jsProxy->ptr : NULL); arg0 = (cocosbuilder::NodeLoaderLibrary*)(jsProxy ? jsProxy->ptr : NULL);
JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); 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).isNull()) { arg1 = nullptr; break; }
if (!args.get(1).isObject()) { ok = false; break; } if (!args.get(1).isObject()) { ok = false; break; }
js_proxy_t *jsProxy; js_proxy_t *jsProxy;
JSObject *tmpObj = args.get(1).toObjectOrNull(); JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull());
jsProxy = jsb_get_js_proxy(tmpObj); jsProxy = jsb_get_js_proxy(tmpObj);
arg1 = (cocosbuilder::CCBMemberVariableAssigner*)(jsProxy ? jsProxy->ptr : NULL); arg1 = (cocosbuilder::CCBMemberVariableAssigner*)(jsProxy ? jsProxy->ptr : NULL);
JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); 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).isNull()) { arg2 = nullptr; break; }
if (!args.get(2).isObject()) { ok = false; break; } if (!args.get(2).isObject()) { ok = false; break; }
js_proxy_t *jsProxy; js_proxy_t *jsProxy;
JSObject *tmpObj = args.get(2).toObjectOrNull(); JS::RootedObject tmpObj(cx, args.get(2).toObjectOrNull());
jsProxy = jsb_get_js_proxy(tmpObj); jsProxy = jsb_get_js_proxy(tmpObj);
arg2 = (cocosbuilder::CCBSelectorResolver*)(jsProxy ? jsProxy->ptr : NULL); arg2 = (cocosbuilder::CCBSelectorResolver*)(jsProxy ? jsProxy->ptr : NULL);
JSB_PRECONDITION2( arg2, cx, false, "Invalid Native Object"); 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; typeClass = typeMapIter->second;
CCASSERT(typeClass, "The value is null."); CCASSERT(typeClass, "The value is null.");
// obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); // obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto);
JS::RootedObject proto(cx, typeClass->proto.get()); JS::RootedObject proto(cx, typeClass->proto.ref());
JS::RootedObject parent(cx, typeClass->parentProto.get()); JS::RootedObject parent(cx, typeClass->parentProto.ref());
obj = JS_NewObject(cx, typeClass->jsclass, proto, parent); obj = JS_NewObject(cx, typeClass->jsclass, proto, parent);
js_proxy_t* p = jsb_new_proxy(cobj, obj); 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).isNull()) { arg0 = nullptr; break; }
if (!args.get(0).isObject()) { ok = false; break; } if (!args.get(0).isObject()) { ok = false; break; }
js_proxy_t *jsProxy; js_proxy_t *jsProxy;
JSObject *tmpObj = args.get(0).toObjectOrNull(); JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull());
jsProxy = jsb_get_js_proxy(tmpObj); jsProxy = jsb_get_js_proxy(tmpObj);
arg0 = (cocosbuilder::NodeLoaderLibrary*)(jsProxy ? jsProxy->ptr : NULL); arg0 = (cocosbuilder::NodeLoaderLibrary*)(jsProxy ? jsProxy->ptr : NULL);
JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); 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).isNull()) { arg1 = nullptr; break; }
if (!args.get(1).isObject()) { ok = false; break; } if (!args.get(1).isObject()) { ok = false; break; }
js_proxy_t *jsProxy; js_proxy_t *jsProxy;
JSObject *tmpObj = args.get(1).toObjectOrNull(); JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull());
jsProxy = jsb_get_js_proxy(tmpObj); jsProxy = jsb_get_js_proxy(tmpObj);
arg1 = (cocosbuilder::CCBMemberVariableAssigner*)(jsProxy ? jsProxy->ptr : NULL); arg1 = (cocosbuilder::CCBMemberVariableAssigner*)(jsProxy ? jsProxy->ptr : NULL);
JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); 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).isNull()) { arg2 = nullptr; break; }
if (!args.get(2).isObject()) { ok = false; break; } if (!args.get(2).isObject()) { ok = false; break; }
js_proxy_t *jsProxy; js_proxy_t *jsProxy;
JSObject *tmpObj = args.get(2).toObjectOrNull(); JS::RootedObject tmpObj(cx, args.get(2).toObjectOrNull());
jsProxy = jsb_get_js_proxy(tmpObj); jsProxy = jsb_get_js_proxy(tmpObj);
arg2 = (cocosbuilder::CCBSelectorResolver*)(jsProxy ? jsProxy->ptr : NULL); arg2 = (cocosbuilder::CCBSelectorResolver*)(jsProxy ? jsProxy->ptr : NULL);
JSB_PRECONDITION2( arg2, cx, false, "Invalid Native Object"); 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).isNull()) { arg3 = nullptr; break; }
if (!args.get(3).isObject()) { ok = false; break; } if (!args.get(3).isObject()) { ok = false; break; }
js_proxy_t *jsProxy; js_proxy_t *jsProxy;
JSObject *tmpObj = args.get(3).toObjectOrNull(); JS::RootedObject tmpObj(cx, args.get(3).toObjectOrNull());
jsProxy = jsb_get_js_proxy(tmpObj); jsProxy = jsb_get_js_proxy(tmpObj);
arg3 = (cocosbuilder::NodeLoaderListener*)(jsProxy ? jsProxy->ptr : NULL); arg3 = (cocosbuilder::NodeLoaderListener*)(jsProxy ? jsProxy->ptr : NULL);
JSB_PRECONDITION2( arg3, cx, false, "Invalid Native Object"); 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; typeClass = typeMapIter->second;
CCASSERT(typeClass, "The value is null."); CCASSERT(typeClass, "The value is null.");
// obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); // obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto);
JS::RootedObject proto(cx, typeClass->proto.get()); JS::RootedObject proto(cx, typeClass->proto.ref());
JS::RootedObject parent(cx, typeClass->parentProto.get()); JS::RootedObject parent(cx, typeClass->parentProto.ref());
obj = JS_NewObject(cx, typeClass->jsclass, proto, parent); obj = JS_NewObject(cx, typeClass->jsclass, proto, parent);
js_proxy_t* p = jsb_new_proxy(cobj, obj); 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; typeClass = typeMapIter->second;
CCASSERT(typeClass, "The value is null."); CCASSERT(typeClass, "The value is null.");
// obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); // obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto);
JS::RootedObject proto(cx, typeClass->proto.get()); JS::RootedObject proto(cx, typeClass->proto.ref());
JS::RootedObject parent(cx, typeClass->parentProto.get()); JS::RootedObject parent(cx, typeClass->parentProto.ref());
obj = JS_NewObject(cx, typeClass->jsclass, proto, parent); obj = JS_NewObject(cx, typeClass->jsclass, proto, parent);
js_proxy_t* p = jsb_new_proxy(cobj, obj); 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( jsb_cocosbuilder_CCBReader_prototype = JS_InitClass(
cx, global, cx, global,
JS::NullPtr(), // parent proto JS::NullPtr(),
jsb_cocosbuilder_CCBReader_class, jsb_cocosbuilder_CCBReader_class,
js_cocos2dx_builder_CCBReader_constructor, 0, // constructor js_cocos2dx_builder_CCBReader_constructor, 0, // constructor
properties, properties,
funcs, funcs,
NULL, // no static properties NULL, // no static properties
st_funcs); 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 // add the proto and JSClass to the type->js info hash table
TypeTest<cocosbuilder::CCBReader> t; JS::RootedObject proto(cx, jsb_cocosbuilder_CCBReader_prototype);
js_type_class_t *p; jsb_register_class<cocosbuilder::CCBReader>(cx, jsb_cocosbuilder_CCBReader_class, proto, JS::NullPtr());
std::string typeName = t.s_name();
if (_js_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));
}
} }
void register_all_cocos2dx_builder(JSContext* cx, JS::HandleObject obj) { void register_all_cocos2dx_builder(JSContext* cx, JS::HandleObject obj) {

View File

@ -20,8 +20,8 @@ static bool dummy_constructor(JSContext *cx, uint32_t argc, jsval *vp) {
typeClass = typeMapIter->second; typeClass = typeMapIter->second;
CCASSERT(typeClass, "The value is null."); CCASSERT(typeClass, "The value is null.");
JS::RootedObject proto(cx, typeClass->proto.get()); JS::RootedObject proto(cx, typeClass->proto.ref());
JS::RootedObject parent(cx, typeClass->parentProto.get()); JS::RootedObject parent(cx, typeClass->parentProto.ref());
JS::RootedObject _tmp(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); JS::RootedObject _tmp(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent));
args.rval().set(OBJECT_TO_JSVAL(_tmp)); 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!"); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!");
typeClass = typeMapIter->second; typeClass = typeMapIter->second;
CCASSERT(typeClass, "The value is null."); CCASSERT(typeClass, "The value is null.");
JS::RootedObject proto(cx, typeClass->proto.get()); JS::RootedObject proto(cx, typeClass->proto.ref());
JS::RootedObject parent(cx, typeClass->parentProto.get()); JS::RootedObject parent(cx, typeClass->parentProto.ref());
JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent));
args.rval().set(OBJECT_TO_JSVAL(obj)); args.rval().set(OBJECT_TO_JSVAL(obj));
// link the native object with the javascript object // 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_FS_END
}; };
JS::RootedObject parent_proto(cx, jsb_cocos2d_ui_Widget_prototype);
jsb_cocos2d_experimental_ui_VideoPlayer_prototype = JS_InitClass( jsb_cocos2d_experimental_ui_VideoPlayer_prototype = JS_InitClass(
cx, global, cx, global,
JS::RootedObject(cx, jsb_cocos2d_ui_Widget_prototype), parent_proto,
jsb_cocos2d_experimental_ui_VideoPlayer_class, jsb_cocos2d_experimental_ui_VideoPlayer_class,
js_cocos2dx_experimental_video_VideoPlayer_constructor, 0, // constructor js_cocos2dx_experimental_video_VideoPlayer_constructor, 0, // constructor
properties, properties,
funcs, funcs,
NULL, // no static properties NULL, // no static properties
st_funcs); 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 // add the proto and JSClass to the type->js info hash table
TypeTest<cocos2d::experimental::ui::VideoPlayer> t; JS::RootedObject proto(cx, jsb_cocos2d_experimental_ui_VideoPlayer_prototype);
js_type_class_t *p; jsb_register_class<cocos2d::experimental::ui::VideoPlayer>(cx, jsb_cocos2d_experimental_ui_VideoPlayer_class, proto, parent_proto);
std::string typeName = t.s_name();
if (_js_global_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));
}
} }
void register_all_cocos2dx_experimental_video(JSContext* cx, JS::HandleObject obj) { void register_all_cocos2dx_experimental_video(JSContext* cx, JS::HandleObject obj) {

View File

@ -20,8 +20,8 @@ static bool dummy_constructor(JSContext *cx, uint32_t argc, jsval *vp) {
typeClass = typeMapIter->second; typeClass = typeMapIter->second;
CCASSERT(typeClass, "The value is null."); CCASSERT(typeClass, "The value is null.");
JS::RootedObject proto(cx, typeClass->proto.get()); JS::RootedObject proto(cx, typeClass->proto.ref());
JS::RootedObject parent(cx, typeClass->parentProto.get()); JS::RootedObject parent(cx, typeClass->parentProto.ref());
JS::RootedObject _tmp(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); JS::RootedObject _tmp(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent));
args.rval().set(OBJECT_TO_JSVAL(_tmp)); 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!"); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!");
typeClass = typeMapIter->second; typeClass = typeMapIter->second;
CCASSERT(typeClass, "The value is null."); CCASSERT(typeClass, "The value is null.");
JS::RootedObject proto(cx, typeClass->proto.get()); JS::RootedObject proto(cx, typeClass->proto.ref());
JS::RootedObject parent(cx, typeClass->parentProto.get()); JS::RootedObject parent(cx, typeClass->parentProto.ref());
JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent));
args.rval().set(OBJECT_TO_JSVAL(obj)); args.rval().set(OBJECT_TO_JSVAL(obj));
// link the native object with the javascript object // 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_FS_END
}; };
JS::RootedObject parent_proto(cx, jsb_cocos2d_ui_Widget_prototype);
jsb_cocos2d_experimental_ui_WebView_prototype = JS_InitClass( jsb_cocos2d_experimental_ui_WebView_prototype = JS_InitClass(
cx, global, cx, global,
JS::RootedObject(cx, jsb_cocos2d_ui_Widget_prototype), parent_proto,
jsb_cocos2d_experimental_ui_WebView_class, jsb_cocos2d_experimental_ui_WebView_class,
js_cocos2dx_experimental_webView_WebView_constructor, 0, // constructor js_cocos2dx_experimental_webView_WebView_constructor, 0, // constructor
properties, properties,
funcs, funcs,
NULL, // no static properties NULL, // no static properties
st_funcs); 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 // add the proto and JSClass to the type->js info hash table
TypeTest<cocos2d::experimental::ui::WebView> t; JS::RootedObject proto(cx, jsb_cocos2d_experimental_ui_WebView_prototype);
js_type_class_t *p; jsb_register_class<cocos2d::experimental::ui::WebView>(cx, jsb_cocos2d_experimental_ui_WebView_class, proto, parent_proto);
std::string typeName = t.s_name();
if (_js_global_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));
}
} }
void register_all_cocos2dx_experimental_webView(JSContext* cx, JS::HandleObject obj) { void register_all_cocos2dx_experimental_webView(JSContext* cx, JS::HandleObject obj) {

View File

@ -21,8 +21,8 @@ static bool dummy_constructor(JSContext *cx, uint32_t argc, jsval *vp) {
typeClass = typeMapIter->second; typeClass = typeMapIter->second;
CCASSERT(typeClass, "The value is null."); CCASSERT(typeClass, "The value is null.");
JS::RootedObject proto(cx, typeClass->proto.get()); JS::RootedObject proto(cx, typeClass->proto.ref());
JS::RootedObject parent(cx, typeClass->parentProto.get()); JS::RootedObject parent(cx, typeClass->parentProto.ref());
JS::RootedObject _tmp(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); JS::RootedObject _tmp(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent));
args.rval().set(OBJECT_TO_JSVAL(_tmp)); 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!"); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!");
typeClass = typeMapIter->second; typeClass = typeMapIter->second;
CCASSERT(typeClass, "The value is null."); CCASSERT(typeClass, "The value is null.");
JS::RootedObject proto(cx, typeClass->proto.get()); JS::RootedObject proto(cx, typeClass->proto.ref());
JS::RootedObject parent(cx, typeClass->parentProto.get()); JS::RootedObject parent(cx, typeClass->parentProto.ref());
JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent));
args.rval().set(OBJECT_TO_JSVAL(obj)); args.rval().set(OBJECT_TO_JSVAL(obj));
// link the native object with the javascript object // 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_FS_END
}; };
JS::RootedObject parent_proto(cx, jsb_cocos2d_Component_prototype);
jsb_cocos2d_NavMeshAgent_prototype = JS_InitClass( jsb_cocos2d_NavMeshAgent_prototype = JS_InitClass(
cx, global, cx, global,
JS::RootedObject(cx, jsb_cocos2d_Component_prototype), parent_proto,
jsb_cocos2d_NavMeshAgent_class, jsb_cocos2d_NavMeshAgent_class,
js_cocos2dx_navmesh_NavMeshAgent_constructor, 0, // constructor js_cocos2dx_navmesh_NavMeshAgent_constructor, 0, // constructor
properties, properties,
funcs, funcs,
NULL, // no static properties NULL, // no static properties
st_funcs); 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 // add the proto and JSClass to the type->js info hash table
TypeTest<cocos2d::NavMeshAgent> t; JS::RootedObject proto(cx, jsb_cocos2d_NavMeshAgent_prototype);
js_type_class_t *p; jsb_register_class<cocos2d::NavMeshAgent>(cx, jsb_cocos2d_NavMeshAgent_class, proto, parent_proto);
std::string typeName = t.s_name();
if (_js_global_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));
}
} }
JSClass *jsb_cocos2d_NavMeshObstacle_class; 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!"); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!");
typeClass = typeMapIter->second; typeClass = typeMapIter->second;
CCASSERT(typeClass, "The value is null."); CCASSERT(typeClass, "The value is null.");
JS::RootedObject proto(cx, typeClass->proto.get()); JS::RootedObject proto(cx, typeClass->proto.ref());
JS::RootedObject parent(cx, typeClass->parentProto.get()); JS::RootedObject parent(cx, typeClass->parentProto.ref());
JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent));
args.rval().set(OBJECT_TO_JSVAL(obj)); args.rval().set(OBJECT_TO_JSVAL(obj));
// link the native object with the javascript object // 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_FS_END
}; };
JS::RootedObject parent_proto(cx, jsb_cocos2d_Component_prototype);
jsb_cocos2d_NavMeshObstacle_prototype = JS_InitClass( jsb_cocos2d_NavMeshObstacle_prototype = JS_InitClass(
cx, global, cx, global,
JS::RootedObject(cx, jsb_cocos2d_Component_prototype), parent_proto,
jsb_cocos2d_NavMeshObstacle_class, jsb_cocos2d_NavMeshObstacle_class,
js_cocos2dx_navmesh_NavMeshObstacle_constructor, 0, // constructor js_cocos2dx_navmesh_NavMeshObstacle_constructor, 0, // constructor
properties, properties,
funcs, funcs,
NULL, // no static properties NULL, // no static properties
st_funcs); 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 // add the proto and JSClass to the type->js info hash table
TypeTest<cocos2d::NavMeshObstacle> t; JS::RootedObject proto(cx, jsb_cocos2d_NavMeshObstacle_prototype);
js_type_class_t *p; jsb_register_class<cocos2d::NavMeshObstacle>(cx, jsb_cocos2d_NavMeshObstacle_class, proto, parent_proto);
std::string typeName = t.s_name();
if (_js_global_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));
}
} }
JSClass *jsb_cocos2d_NavMesh_class; 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).isNull()) { arg0 = nullptr; break; }
if (!args.get(0).isObject()) { ok = false; break; } if (!args.get(0).isObject()) { ok = false; break; }
js_proxy_t *jsProxy; js_proxy_t *jsProxy;
JSObject *tmpObj = args.get(0).toObjectOrNull(); JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull());
jsProxy = jsb_get_js_proxy(tmpObj); jsProxy = jsb_get_js_proxy(tmpObj);
arg0 = (cocos2d::NavMeshObstacle*)(jsProxy ? jsProxy->ptr : NULL); arg0 = (cocos2d::NavMeshObstacle*)(jsProxy ? jsProxy->ptr : NULL);
JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); 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).isNull()) { arg0 = nullptr; break; }
if (!args.get(0).isObject()) { ok = false; break; } if (!args.get(0).isObject()) { ok = false; break; }
js_proxy_t *jsProxy; js_proxy_t *jsProxy;
JSObject *tmpObj = args.get(0).toObjectOrNull(); JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull());
jsProxy = jsb_get_js_proxy(tmpObj); jsProxy = jsb_get_js_proxy(tmpObj);
arg0 = (cocos2d::NavMeshAgent*)(jsProxy ? jsProxy->ptr : NULL); arg0 = (cocos2d::NavMeshAgent*)(jsProxy ? jsProxy->ptr : NULL);
JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); 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).isNull()) { arg0 = nullptr; break; }
if (!args.get(0).isObject()) { ok = false; break; } if (!args.get(0).isObject()) { ok = false; break; }
js_proxy_t *jsProxy; js_proxy_t *jsProxy;
JSObject *tmpObj = args.get(0).toObjectOrNull(); JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull());
jsProxy = jsb_get_js_proxy(tmpObj); jsProxy = jsb_get_js_proxy(tmpObj);
arg0 = (cocos2d::NavMeshAgent*)(jsProxy ? jsProxy->ptr : NULL); arg0 = (cocos2d::NavMeshAgent*)(jsProxy ? jsProxy->ptr : NULL);
JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); 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).isNull()) { arg0 = nullptr; break; }
if (!args.get(0).isObject()) { ok = false; break; } if (!args.get(0).isObject()) { ok = false; break; }
js_proxy_t *jsProxy; js_proxy_t *jsProxy;
JSObject *tmpObj = args.get(0).toObjectOrNull(); JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull());
jsProxy = jsb_get_js_proxy(tmpObj); jsProxy = jsb_get_js_proxy(tmpObj);
arg0 = (cocos2d::NavMeshObstacle*)(jsProxy ? jsProxy->ptr : NULL); arg0 = (cocos2d::NavMeshObstacle*)(jsProxy ? jsProxy->ptr : NULL);
JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); 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).isNull()) { arg0 = nullptr; break; }
if (!args.get(0).isObject()) { ok = false; break; } if (!args.get(0).isObject()) { ok = false; break; }
js_proxy_t *jsProxy; js_proxy_t *jsProxy;
JSObject *tmpObj = args.get(0).toObjectOrNull(); JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull());
jsProxy = jsb_get_js_proxy(tmpObj); jsProxy = jsb_get_js_proxy(tmpObj);
arg0 = (cocos2d::Renderer*)(jsProxy ? jsProxy->ptr : NULL); arg0 = (cocos2d::Renderer*)(jsProxy ? jsProxy->ptr : NULL);
JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); 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!"); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!");
typeClass = typeMapIter->second; typeClass = typeMapIter->second;
CCASSERT(typeClass, "The value is null."); CCASSERT(typeClass, "The value is null.");
JS::RootedObject proto(cx, typeClass->proto.get()); JS::RootedObject proto(cx, typeClass->proto.ref());
JS::RootedObject parent(cx, typeClass->parentProto.get()); JS::RootedObject parent(cx, typeClass->parentProto.ref());
JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent));
args.rval().set(OBJECT_TO_JSVAL(obj)); args.rval().set(OBJECT_TO_JSVAL(obj));
// link the native object with the javascript object // 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( jsb_cocos2d_NavMesh_prototype = JS_InitClass(
cx, global, cx, global,
JS::NullPtr(), // parent proto JS::NullPtr(),
jsb_cocos2d_NavMesh_class, jsb_cocos2d_NavMesh_class,
js_cocos2dx_navmesh_NavMesh_constructor, 0, // constructor js_cocos2dx_navmesh_NavMesh_constructor, 0, // constructor
properties, properties,
funcs, funcs,
NULL, // no static properties NULL, // no static properties
st_funcs); 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 // add the proto and JSClass to the type->js info hash table
TypeTest<cocos2d::NavMesh> t; JS::RootedObject proto(cx, jsb_cocos2d_NavMesh_prototype);
js_type_class_t *p; jsb_register_class<cocos2d::NavMesh>(cx, jsb_cocos2d_NavMesh_class, proto, JS::NullPtr());
std::string typeName = t.s_name();
if (_js_global_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));
}
} }
void register_all_cocos2dx_navmesh(JSContext* cx, JS::HandleObject obj) { void register_all_cocos2dx_navmesh(JSContext* cx, JS::HandleObject obj) {

View File

@ -21,8 +21,8 @@ static bool dummy_constructor(JSContext *cx, uint32_t argc, jsval *vp) {
typeClass = typeMapIter->second; typeClass = typeMapIter->second;
CCASSERT(typeClass, "The value is null."); CCASSERT(typeClass, "The value is null.");
JS::RootedObject proto(cx, typeClass->proto.get()); JS::RootedObject proto(cx, typeClass->proto.ref());
JS::RootedObject parent(cx, typeClass->parentProto.get()); JS::RootedObject parent(cx, typeClass->parentProto.ref());
JS::RootedObject _tmp(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); JS::RootedObject _tmp(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent));
args.rval().set(OBJECT_TO_JSVAL(_tmp)); 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).isNull()) { arg0 = nullptr; break; }
if (!args.get(0).isObject()) { ok = false; break; } if (!args.get(0).isObject()) { ok = false; break; }
js_proxy_t *jsProxy; js_proxy_t *jsProxy;
JSObject *tmpObj = args.get(0).toObjectOrNull(); JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull());
jsProxy = jsb_get_js_proxy(tmpObj); jsProxy = jsb_get_js_proxy(tmpObj);
arg0 = (const cocos2d::Vec3*)(jsProxy ? jsProxy->ptr : NULL); arg0 = (const cocos2d::Vec3*)(jsProxy ? jsProxy->ptr : NULL);
JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); 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).isNull()) { arg0 = nullptr; break; }
if (!args.get(0).isObject()) { ok = false; break; } if (!args.get(0).isObject()) { ok = false; break; }
js_proxy_t *jsProxy; js_proxy_t *jsProxy;
JSObject *tmpObj = args.get(0).toObjectOrNull(); JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull());
jsProxy = jsb_get_js_proxy(tmpObj); jsProxy = jsb_get_js_proxy(tmpObj);
arg0 = (const cocos2d::Vec3*)(jsProxy ? jsProxy->ptr : NULL); arg0 = (const cocos2d::Vec3*)(jsProxy ? jsProxy->ptr : NULL);
JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); 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!"); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!");
typeClass = typeMapIter->second; typeClass = typeMapIter->second;
CCASSERT(typeClass, "The value is null."); CCASSERT(typeClass, "The value is null.");
JS::RootedObject proto(cx, typeClass->proto.get()); JS::RootedObject proto(cx, typeClass->proto.ref());
JS::RootedObject parent(cx, typeClass->parentProto.get()); JS::RootedObject parent(cx, typeClass->parentProto.ref());
JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent));
args.rval().set(OBJECT_TO_JSVAL(obj)); args.rval().set(OBJECT_TO_JSVAL(obj));
// link the native object with the javascript object // 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( jsb_cocos2d_Physics3DShape_prototype = JS_InitClass(
cx, global, cx, global,
JS::NullPtr(), // parent proto JS::NullPtr(),
jsb_cocos2d_Physics3DShape_class, jsb_cocos2d_Physics3DShape_class,
js_cocos2dx_physics3d_Physics3DShape_constructor, 0, // constructor js_cocos2dx_physics3d_Physics3DShape_constructor, 0, // constructor
properties, properties,
funcs, funcs,
NULL, // no static properties NULL, // no static properties
st_funcs); 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 // add the proto and JSClass to the type->js info hash table
TypeTest<cocos2d::Physics3DShape> t; JS::RootedObject proto(cx, jsb_cocos2d_Physics3DShape_prototype);
js_type_class_t *p; jsb_register_class<cocos2d::Physics3DShape>(cx, jsb_cocos2d_Physics3DShape_class, proto, JS::NullPtr());
std::string typeName = t.s_name();
if (_js_global_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));
}
} }
JSClass *jsb_cocos2d_Physics3DObject_class; 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).isNull()) { arg0 = nullptr; break; }
if (!args.get(0).isObject()) { ok = false; break; } if (!args.get(0).isObject()) { ok = false; break; }
js_proxy_t *jsProxy; js_proxy_t *jsProxy;
JSObject *tmpObj = args.get(0).toObjectOrNull(); JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull());
jsProxy = jsb_get_js_proxy(tmpObj); jsProxy = jsb_get_js_proxy(tmpObj);
arg0 = (cocos2d::Physics3DWorld*)(jsProxy ? jsProxy->ptr : NULL); arg0 = (cocos2d::Physics3DWorld*)(jsProxy ? jsProxy->ptr : NULL);
JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); 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( jsb_cocos2d_Physics3DObject_prototype = JS_InitClass(
cx, global, cx, global,
JS::NullPtr(), // parent proto JS::NullPtr(),
jsb_cocos2d_Physics3DObject_class, jsb_cocos2d_Physics3DObject_class,
empty_constructor, 0, empty_constructor, 0,
properties, properties,
funcs, funcs,
NULL, // no static properties NULL, // no static properties
st_funcs); 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 // add the proto and JSClass to the type->js info hash table
TypeTest<cocos2d::Physics3DObject> t; JS::RootedObject proto(cx, jsb_cocos2d_Physics3DObject_prototype);
js_type_class_t *p; jsb_register_class<cocos2d::Physics3DObject>(cx, jsb_cocos2d_Physics3DObject_class, proto, JS::NullPtr());
std::string typeName = t.s_name();
if (_js_global_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));
}
} }
JSClass *jsb_cocos2d_Physics3DRigidBody_class; 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::CallArgs args = JS::CallArgsFromVp(argc, vp);
JS::RootedObject obj(cx); JS::RootedObject obj(cx);
obj = args.thisv().toObjectOrNull(); obj.set(args.thisv().toObjectOrNull());
js_proxy_t *proxy = jsb_get_js_proxy(obj); js_proxy_t *proxy = jsb_get_js_proxy(obj);
cobj = (cocos2d::Physics3DRigidBody *)(proxy ? proxy->ptr : nullptr); cobj = (cocos2d::Physics3DRigidBody *)(proxy ? proxy->ptr : nullptr);
JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_physics3d_Physics3DRigidBody_setAngularFactor : Invalid Native Object"); 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).isNull()) { arg0 = nullptr; break; }
if (!args.get(0).isObject()) { ok = false; break; } if (!args.get(0).isObject()) { ok = false; break; }
js_proxy_t *jsProxy; js_proxy_t *jsProxy;
JSObject *tmpObj = args.get(0).toObjectOrNull(); JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull());
jsProxy = jsb_get_js_proxy(tmpObj); jsProxy = jsb_get_js_proxy(tmpObj);
arg0 = (cocos2d::Physics3DConstraint*)(jsProxy ? jsProxy->ptr : NULL); arg0 = (cocos2d::Physics3DConstraint*)(jsProxy ? jsProxy->ptr : NULL);
JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); 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::CallArgs args = JS::CallArgsFromVp(argc, vp);
JS::RootedObject obj(cx); JS::RootedObject obj(cx);
obj = args.thisv().toObjectOrNull(); obj.set(args.thisv().toObjectOrNull());
js_proxy_t *proxy = jsb_get_js_proxy(obj); js_proxy_t *proxy = jsb_get_js_proxy(obj);
cobj = (cocos2d::Physics3DRigidBody *)(proxy ? proxy->ptr : nullptr); cobj = (cocos2d::Physics3DRigidBody *)(proxy ? proxy->ptr : nullptr);
JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_physics3d_Physics3DRigidBody_removeConstraint : Invalid Native Object"); 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).isNull()) { arg0 = nullptr; break; }
if (!args.get(0).isObject()) { ok = false; break; } if (!args.get(0).isObject()) { ok = false; break; }
js_proxy_t *jsProxy; js_proxy_t *jsProxy;
JSObject *tmpObj = args.get(0).toObjectOrNull(); JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull());
jsProxy = jsb_get_js_proxy(tmpObj); jsProxy = jsb_get_js_proxy(tmpObj);
arg0 = (cocos2d::Physics3DConstraint*)(jsProxy ? jsProxy->ptr : NULL); arg0 = (cocos2d::Physics3DConstraint*)(jsProxy ? jsProxy->ptr : NULL);
JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); 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!"); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!");
typeClass = typeMapIter->second; typeClass = typeMapIter->second;
CCASSERT(typeClass, "The value is null."); CCASSERT(typeClass, "The value is null.");
JS::RootedObject proto(cx, typeClass->proto.get()); JS::RootedObject proto(cx, typeClass->proto.ref());
JS::RootedObject parent(cx, typeClass->parentProto.get()); JS::RootedObject parent(cx, typeClass->parentProto.ref());
JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent));
args.rval().set(OBJECT_TO_JSVAL(obj)); args.rval().set(OBJECT_TO_JSVAL(obj));
// link the native object with the javascript object // 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; JSFunctionSpec *st_funcs = NULL;
JS::RootedObject parent_proto(cx, jsb_cocos2d_Physics3DObject_prototype);
jsb_cocos2d_Physics3DRigidBody_prototype = JS_InitClass( jsb_cocos2d_Physics3DRigidBody_prototype = JS_InitClass(
cx, global, cx, global,
JS::RootedObject(cx, jsb_cocos2d_Physics3DObject_prototype), parent_proto,
jsb_cocos2d_Physics3DRigidBody_class, jsb_cocos2d_Physics3DRigidBody_class,
js_cocos2dx_physics3d_Physics3DRigidBody_constructor, 0, // constructor js_cocos2dx_physics3d_Physics3DRigidBody_constructor, 0, // constructor
properties, properties,
funcs, funcs,
NULL, // no static properties NULL, // no static properties
st_funcs); 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 // add the proto and JSClass to the type->js info hash table
TypeTest<cocos2d::Physics3DRigidBody> t; JS::RootedObject proto(cx, jsb_cocos2d_Physics3DRigidBody_prototype);
js_type_class_t *p; jsb_register_class<cocos2d::Physics3DRigidBody>(cx, jsb_cocos2d_Physics3DRigidBody_class, proto, parent_proto);
std::string typeName = t.s_name();
if (_js_global_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));
}
} }
JSClass *jsb_cocos2d_Physics3DComponent_class; 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).isNull()) { arg0 = nullptr; break; }
if (!args.get(0).isObject()) { ok = false; break; } if (!args.get(0).isObject()) { ok = false; break; }
js_proxy_t *jsProxy; js_proxy_t *jsProxy;
JSObject *tmpObj = args.get(0).toObjectOrNull(); JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull());
jsProxy = jsb_get_js_proxy(tmpObj); jsProxy = jsb_get_js_proxy(tmpObj);
arg0 = (cocos2d::Physics3DWorld*)(jsProxy ? jsProxy->ptr : NULL); arg0 = (cocos2d::Physics3DWorld*)(jsProxy ? jsProxy->ptr : NULL);
JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); 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).isNull()) { arg0 = nullptr; break; }
if (!args.get(0).isObject()) { ok = false; break; } if (!args.get(0).isObject()) { ok = false; break; }
js_proxy_t *jsProxy; js_proxy_t *jsProxy;
JSObject *tmpObj = args.get(0).toObjectOrNull(); JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull());
jsProxy = jsb_get_js_proxy(tmpObj); jsProxy = jsb_get_js_proxy(tmpObj);
arg0 = (cocos2d::Physics3DObject*)(jsProxy ? jsProxy->ptr : NULL); arg0 = (cocos2d::Physics3DObject*)(jsProxy ? jsProxy->ptr : NULL);
JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); 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).isNull()) { arg0 = nullptr; break; }
if (!args.get(0).isObject()) { ok = false; break; } if (!args.get(0).isObject()) { ok = false; break; }
js_proxy_t *jsProxy; js_proxy_t *jsProxy;
JSObject *tmpObj = args.get(0).toObjectOrNull(); JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull());
jsProxy = jsb_get_js_proxy(tmpObj); jsProxy = jsb_get_js_proxy(tmpObj);
arg0 = (cocos2d::Physics3DObject*)(jsProxy ? jsProxy->ptr : NULL); arg0 = (cocos2d::Physics3DObject*)(jsProxy ? jsProxy->ptr : NULL);
JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); 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).isNull()) { arg0 = nullptr; break; }
if (!args.get(0).isObject()) { ok = false; break; } if (!args.get(0).isObject()) { ok = false; break; }
js_proxy_t *jsProxy; js_proxy_t *jsProxy;
JSObject *tmpObj = args.get(0).toObjectOrNull(); JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull());
jsProxy = jsb_get_js_proxy(tmpObj); jsProxy = jsb_get_js_proxy(tmpObj);
arg0 = (cocos2d::Physics3DObject*)(jsProxy ? jsProxy->ptr : NULL); arg0 = (cocos2d::Physics3DObject*)(jsProxy ? jsProxy->ptr : NULL);
JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); 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).isNull()) { arg0 = nullptr; break; }
if (!args.get(0).isObject()) { ok = false; break; } if (!args.get(0).isObject()) { ok = false; break; }
js_proxy_t *jsProxy; js_proxy_t *jsProxy;
JSObject *tmpObj = args.get(0).toObjectOrNull(); JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull());
jsProxy = jsb_get_js_proxy(tmpObj); jsProxy = jsb_get_js_proxy(tmpObj);
arg0 = (cocos2d::Physics3DObject*)(jsProxy ? jsProxy->ptr : NULL); arg0 = (cocos2d::Physics3DObject*)(jsProxy ? jsProxy->ptr : NULL);
JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); 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!"); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!");
typeClass = typeMapIter->second; typeClass = typeMapIter->second;
CCASSERT(typeClass, "The value is null."); CCASSERT(typeClass, "The value is null.");
JS::RootedObject proto(cx, typeClass->proto.get()); JS::RootedObject proto(cx, typeClass->proto.ref());
JS::RootedObject parent(cx, typeClass->parentProto.get()); JS::RootedObject parent(cx, typeClass->parentProto.ref());
JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent));
args.rval().set(OBJECT_TO_JSVAL(obj)); args.rval().set(OBJECT_TO_JSVAL(obj));
// link the native object with the javascript object // 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_FS_END
}; };
JS::RootedObject parent_proto(cx, jsb_cocos2d_Component_prototype);
jsb_cocos2d_Physics3DComponent_prototype = JS_InitClass( jsb_cocos2d_Physics3DComponent_prototype = JS_InitClass(
cx, global, cx, global,
JS::RootedObject(cx, jsb_cocos2d_Component_prototype), parent_proto,
jsb_cocos2d_Physics3DComponent_class, jsb_cocos2d_Physics3DComponent_class,
js_cocos2dx_physics3d_Physics3DComponent_constructor, 0, // constructor js_cocos2dx_physics3d_Physics3DComponent_constructor, 0, // constructor
properties, properties,
funcs, funcs,
NULL, // no static properties NULL, // no static properties
st_funcs); 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 // add the proto and JSClass to the type->js info hash table
TypeTest<cocos2d::Physics3DComponent> t; JS::RootedObject proto(cx, jsb_cocos2d_Physics3DComponent_prototype);
js_type_class_t *p; jsb_register_class<cocos2d::Physics3DComponent>(cx, jsb_cocos2d_Physics3DComponent_class, proto, parent_proto);
std::string typeName = t.s_name();
if (_js_global_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));
}
} }
JSClass *jsb_cocos2d_PhysicsSprite3D_class; 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!"); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!");
typeClass = typeMapIter->second; typeClass = typeMapIter->second;
CCASSERT(typeClass, "The value is null."); CCASSERT(typeClass, "The value is null.");
JS::RootedObject proto(cx, typeClass->proto.get()); JS::RootedObject proto(cx, typeClass->proto.ref());
JS::RootedObject parent(cx, typeClass->parentProto.get()); JS::RootedObject parent(cx, typeClass->parentProto.ref());
JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent));
args.rval().set(OBJECT_TO_JSVAL(obj)); args.rval().set(OBJECT_TO_JSVAL(obj));
// link the native object with the javascript object // 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; JSFunctionSpec *st_funcs = NULL;
JS::RootedObject parent_proto(cx, jsb_cocos2d_Sprite3D_prototype);
jsb_cocos2d_PhysicsSprite3D_prototype = JS_InitClass( jsb_cocos2d_PhysicsSprite3D_prototype = JS_InitClass(
cx, global, cx, global,
JS::RootedObject(cx, jsb_cocos2d_Sprite3D_prototype), parent_proto,
jsb_cocos2d_PhysicsSprite3D_class, jsb_cocos2d_PhysicsSprite3D_class,
js_cocos2dx_physics3d_PhysicsSprite3D_constructor, 0, // constructor js_cocos2dx_physics3d_PhysicsSprite3D_constructor, 0, // constructor
properties, properties,
funcs, funcs,
NULL, // no static properties NULL, // no static properties
st_funcs); 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 // add the proto and JSClass to the type->js info hash table
TypeTest<cocos2d::PhysicsSprite3D> t; JS::RootedObject proto(cx, jsb_cocos2d_PhysicsSprite3D_prototype);
js_type_class_t *p; jsb_register_class<cocos2d::PhysicsSprite3D>(cx, jsb_cocos2d_PhysicsSprite3D_class, proto, parent_proto);
std::string typeName = t.s_name();
if (_js_global_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));
}
} }
JSClass *jsb_cocos2d_Physics3DWorld_class; 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).isNull()) { arg0 = nullptr; break; }
if (!args.get(0).isObject()) { ok = false; break; } if (!args.get(0).isObject()) { ok = false; break; }
js_proxy_t *jsProxy; js_proxy_t *jsProxy;
JSObject *tmpObj = args.get(0).toObjectOrNull(); JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull());
jsProxy = jsb_get_js_proxy(tmpObj); jsProxy = jsb_get_js_proxy(tmpObj);
arg0 = (cocos2d::Physics3DConstraint*)(jsProxy ? jsProxy->ptr : NULL); arg0 = (cocos2d::Physics3DConstraint*)(jsProxy ? jsProxy->ptr : NULL);
JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); 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).isNull()) { arg0 = nullptr; break; }
if (!args.get(0).isObject()) { ok = false; break; } if (!args.get(0).isObject()) { ok = false; break; }
js_proxy_t *jsProxy; js_proxy_t *jsProxy;
JSObject *tmpObj = args.get(0).toObjectOrNull(); JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull());
jsProxy = jsb_get_js_proxy(tmpObj); jsProxy = jsb_get_js_proxy(tmpObj);
arg0 = (cocos2d::Physics3DObject*)(jsProxy ? jsProxy->ptr : NULL); arg0 = (cocos2d::Physics3DObject*)(jsProxy ? jsProxy->ptr : NULL);
JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); 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).isNull()) { arg0 = nullptr; break; }
if (!args.get(0).isObject()) { ok = false; break; } if (!args.get(0).isObject()) { ok = false; break; }
js_proxy_t *jsProxy; js_proxy_t *jsProxy;
JSObject *tmpObj = args.get(0).toObjectOrNull(); JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull());
jsProxy = jsb_get_js_proxy(tmpObj); jsProxy = jsb_get_js_proxy(tmpObj);
arg0 = (cocos2d::Physics3DObject*)(jsProxy ? jsProxy->ptr : NULL); arg0 = (cocos2d::Physics3DObject*)(jsProxy ? jsProxy->ptr : NULL);
JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); 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).isNull()) { arg0 = nullptr; break; }
if (!args.get(0).isObject()) { ok = false; break; } if (!args.get(0).isObject()) { ok = false; break; }
js_proxy_t *jsProxy; js_proxy_t *jsProxy;
JSObject *tmpObj = args.get(0).toObjectOrNull(); JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull());
jsProxy = jsb_get_js_proxy(tmpObj); jsProxy = jsb_get_js_proxy(tmpObj);
arg0 = (const btCollisionObject*)(jsProxy ? jsProxy->ptr : NULL); arg0 = (const btCollisionObject*)(jsProxy ? jsProxy->ptr : NULL);
JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); 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).isNull()) { arg0 = nullptr; break; }
if (!args.get(0).isObject()) { ok = false; break; } if (!args.get(0).isObject()) { ok = false; break; }
js_proxy_t *jsProxy; js_proxy_t *jsProxy;
JSObject *tmpObj = args.get(0).toObjectOrNull(); JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull());
jsProxy = jsb_get_js_proxy(tmpObj); jsProxy = jsb_get_js_proxy(tmpObj);
arg0 = (cocos2d::Physics3DConstraint*)(jsProxy ? jsProxy->ptr : NULL); arg0 = (cocos2d::Physics3DConstraint*)(jsProxy ? jsProxy->ptr : NULL);
JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); 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).isNull()) { arg0 = nullptr; break; }
if (!args.get(0).isObject()) { ok = false; break; } if (!args.get(0).isObject()) { ok = false; break; }
js_proxy_t *jsProxy; js_proxy_t *jsProxy;
JSObject *tmpObj = args.get(0).toObjectOrNull(); JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull());
jsProxy = jsb_get_js_proxy(tmpObj); jsProxy = jsb_get_js_proxy(tmpObj);
arg0 = (cocos2d::Physics3DConstraint*)(jsProxy ? jsProxy->ptr : NULL); arg0 = (cocos2d::Physics3DConstraint*)(jsProxy ? jsProxy->ptr : NULL);
JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); 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).isNull()) { arg0 = nullptr; break; }
if (!args.get(0).isObject()) { ok = false; break; } if (!args.get(0).isObject()) { ok = false; break; }
js_proxy_t *jsProxy; js_proxy_t *jsProxy;
JSObject *tmpObj = args.get(0).toObjectOrNull(); JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull());
jsProxy = jsb_get_js_proxy(tmpObj); jsProxy = jsb_get_js_proxy(tmpObj);
arg0 = (cocos2d::Renderer*)(jsProxy ? jsProxy->ptr : NULL); arg0 = (cocos2d::Renderer*)(jsProxy ? jsProxy->ptr : NULL);
JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); 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).isNull()) { arg0 = nullptr; break; }
if (!args.get(0).isObject()) { ok = false; break; } if (!args.get(0).isObject()) { ok = false; break; }
js_proxy_t *jsProxy; js_proxy_t *jsProxy;
JSObject *tmpObj = args.get(0).toObjectOrNull(); JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull());
jsProxy = jsb_get_js_proxy(tmpObj); jsProxy = jsb_get_js_proxy(tmpObj);
arg0 = (cocos2d::Physics3DShape*)(jsProxy ? jsProxy->ptr : NULL); arg0 = (cocos2d::Physics3DShape*)(jsProxy ? jsProxy->ptr : NULL);
JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); 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!"); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!");
typeClass = typeMapIter->second; typeClass = typeMapIter->second;
CCASSERT(typeClass, "The value is null."); CCASSERT(typeClass, "The value is null.");
JS::RootedObject proto(cx, typeClass->proto.get()); JS::RootedObject proto(cx, typeClass->proto.ref());
JS::RootedObject parent(cx, typeClass->parentProto.get()); JS::RootedObject parent(cx, typeClass->parentProto.ref());
JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent));
args.rval().set(OBJECT_TO_JSVAL(obj)); args.rval().set(OBJECT_TO_JSVAL(obj));
// link the native object with the javascript object // 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( jsb_cocos2d_Physics3DWorld_prototype = JS_InitClass(
cx, global, cx, global,
JS::NullPtr(), // parent proto JS::NullPtr(),
jsb_cocos2d_Physics3DWorld_class, jsb_cocos2d_Physics3DWorld_class,
js_cocos2dx_physics3d_Physics3DWorld_constructor, 0, // constructor js_cocos2dx_physics3d_Physics3DWorld_constructor, 0, // constructor
properties, properties,
funcs, funcs,
NULL, // no static properties NULL, // no static properties
st_funcs); 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 // add the proto and JSClass to the type->js info hash table
TypeTest<cocos2d::Physics3DWorld> t; JS::RootedObject proto(cx, jsb_cocos2d_Physics3DWorld_prototype);
js_type_class_t *p; jsb_register_class<cocos2d::Physics3DWorld>(cx, jsb_cocos2d_Physics3DWorld_class, proto, JS::NullPtr());
std::string typeName = t.s_name();
if (_js_global_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));
}
} }
JSClass *jsb_cocos2d_Physics3DConstraint_class; 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( jsb_cocos2d_Physics3DConstraint_prototype = JS_InitClass(
cx, global, cx, global,
JS::NullPtr(), // parent proto JS::NullPtr(),
jsb_cocos2d_Physics3DConstraint_class, jsb_cocos2d_Physics3DConstraint_class,
dummy_constructor<cocos2d::Physics3DConstraint>, 0, // no constructor dummy_constructor<cocos2d::Physics3DConstraint>, 0, // no constructor
properties, properties,
funcs, funcs,
NULL, // no static properties NULL, // no static properties
st_funcs); 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 // add the proto and JSClass to the type->js info hash table
TypeTest<cocos2d::Physics3DConstraint> t; JS::RootedObject proto(cx, jsb_cocos2d_Physics3DConstraint_prototype);
js_type_class_t *p; jsb_register_class<cocos2d::Physics3DConstraint>(cx, jsb_cocos2d_Physics3DConstraint_class, proto, JS::NullPtr());
std::string typeName = t.s_name();
if (_js_global_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));
}
} }
JSClass *jsb_cocos2d_Physics3DPointToPointConstraint_class; 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::CallArgs args = JS::CallArgsFromVp(argc, vp);
JS::RootedObject obj(cx); JS::RootedObject obj(cx);
obj = args.thisv().toObjectOrNull(); obj.set(args.thisv().toObjectOrNull());
js_proxy_t *proxy = jsb_get_js_proxy(obj); js_proxy_t *proxy = jsb_get_js_proxy(obj);
cobj = (cocos2d::Physics3DPointToPointConstraint *)(proxy ? proxy->ptr : nullptr); cobj = (cocos2d::Physics3DPointToPointConstraint *)(proxy ? proxy->ptr : nullptr);
JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_physics3d_Physics3DPointToPointConstraint_init : Invalid Native Object"); 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).isNull()) { arg0 = nullptr; break; }
if (!args.get(0).isObject()) { ok = false; break; } if (!args.get(0).isObject()) { ok = false; break; }
js_proxy_t *jsProxy; js_proxy_t *jsProxy;
JSObject *tmpObj = args.get(0).toObjectOrNull(); JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull());
jsProxy = jsb_get_js_proxy(tmpObj); jsProxy = jsb_get_js_proxy(tmpObj);
arg0 = (cocos2d::Physics3DRigidBody*)(jsProxy ? jsProxy->ptr : NULL); arg0 = (cocos2d::Physics3DRigidBody*)(jsProxy ? jsProxy->ptr : NULL);
JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); 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).isNull()) { arg1 = nullptr; break; }
if (!args.get(1).isObject()) { ok = false; break; } if (!args.get(1).isObject()) { ok = false; break; }
js_proxy_t *jsProxy; js_proxy_t *jsProxy;
JSObject *tmpObj = args.get(1).toObjectOrNull(); JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull());
jsProxy = jsb_get_js_proxy(tmpObj); jsProxy = jsb_get_js_proxy(tmpObj);
arg1 = (cocos2d::Physics3DRigidBody*)(jsProxy ? jsProxy->ptr : NULL); arg1 = (cocos2d::Physics3DRigidBody*)(jsProxy ? jsProxy->ptr : NULL);
JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); 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).isNull()) { arg0 = nullptr; break; }
if (!args.get(0).isObject()) { ok = false; break; } if (!args.get(0).isObject()) { ok = false; break; }
js_proxy_t *jsProxy; js_proxy_t *jsProxy;
JSObject *tmpObj = args.get(0).toObjectOrNull(); JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull());
jsProxy = jsb_get_js_proxy(tmpObj); jsProxy = jsb_get_js_proxy(tmpObj);
arg0 = (cocos2d::Physics3DRigidBody*)(jsProxy ? jsProxy->ptr : NULL); arg0 = (cocos2d::Physics3DRigidBody*)(jsProxy ? jsProxy->ptr : NULL);
JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); 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).isNull()) { arg0 = nullptr; break; }
if (!args.get(0).isObject()) { ok = false; break; } if (!args.get(0).isObject()) { ok = false; break; }
js_proxy_t *jsProxy; js_proxy_t *jsProxy;
JSObject *tmpObj = args.get(0).toObjectOrNull(); JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull());
jsProxy = jsb_get_js_proxy(tmpObj); jsProxy = jsb_get_js_proxy(tmpObj);
arg0 = (cocos2d::Physics3DRigidBody*)(jsProxy ? jsProxy->ptr : NULL); arg0 = (cocos2d::Physics3DRigidBody*)(jsProxy ? jsProxy->ptr : NULL);
JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); 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).isNull()) { arg1 = nullptr; break; }
if (!args.get(1).isObject()) { ok = false; break; } if (!args.get(1).isObject()) { ok = false; break; }
js_proxy_t *jsProxy; js_proxy_t *jsProxy;
JSObject *tmpObj = args.get(1).toObjectOrNull(); JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull());
jsProxy = jsb_get_js_proxy(tmpObj); jsProxy = jsb_get_js_proxy(tmpObj);
arg1 = (cocos2d::Physics3DRigidBody*)(jsProxy ? jsProxy->ptr : NULL); arg1 = (cocos2d::Physics3DRigidBody*)(jsProxy ? jsProxy->ptr : NULL);
JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); 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).isNull()) { arg0 = nullptr; break; }
if (!args.get(0).isObject()) { ok = false; break; } if (!args.get(0).isObject()) { ok = false; break; }
js_proxy_t *jsProxy; js_proxy_t *jsProxy;
JSObject *tmpObj = args.get(0).toObjectOrNull(); JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull());
jsProxy = jsb_get_js_proxy(tmpObj); jsProxy = jsb_get_js_proxy(tmpObj);
arg0 = (cocos2d::Physics3DRigidBody*)(jsProxy ? jsProxy->ptr : NULL); arg0 = (cocos2d::Physics3DRigidBody*)(jsProxy ? jsProxy->ptr : NULL);
JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); 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!"); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!");
typeClass = typeMapIter->second; typeClass = typeMapIter->second;
CCASSERT(typeClass, "The value is null."); CCASSERT(typeClass, "The value is null.");
JS::RootedObject proto(cx, typeClass->proto.get()); JS::RootedObject proto(cx, typeClass->proto.ref());
JS::RootedObject parent(cx, typeClass->parentProto.get()); JS::RootedObject parent(cx, typeClass->parentProto.ref());
JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent));
args.rval().set(OBJECT_TO_JSVAL(obj)); args.rval().set(OBJECT_TO_JSVAL(obj));
// link the native object with the javascript object // link the native object with the javascript object
@ -3607,32 +3519,20 @@ void js_register_cocos2dx_physics3d_Physics3DPointToPointConstraint(JSContext *c
JS_FS_END JS_FS_END
}; };
JS::RootedObject parent_proto(cx, jsb_cocos2d_Physics3DConstraint_prototype);
jsb_cocos2d_Physics3DPointToPointConstraint_prototype = JS_InitClass( jsb_cocos2d_Physics3DPointToPointConstraint_prototype = JS_InitClass(
cx, global, cx, global,
JS::RootedObject(cx, jsb_cocos2d_Physics3DConstraint_prototype), parent_proto,
jsb_cocos2d_Physics3DPointToPointConstraint_class, jsb_cocos2d_Physics3DPointToPointConstraint_class,
js_cocos2dx_physics3d_Physics3DPointToPointConstraint_constructor, 0, // constructor js_cocos2dx_physics3d_Physics3DPointToPointConstraint_constructor, 0, // constructor
properties, properties,
funcs, funcs,
NULL, // no static properties NULL, // no static properties
st_funcs); 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 // add the proto and JSClass to the type->js info hash table
TypeTest<cocos2d::Physics3DPointToPointConstraint> t; JS::RootedObject proto(cx, jsb_cocos2d_Physics3DPointToPointConstraint_prototype);
js_type_class_t *p; jsb_register_class<cocos2d::Physics3DPointToPointConstraint>(cx, jsb_cocos2d_Physics3DPointToPointConstraint_class, proto, parent_proto);
std::string typeName = t.s_name();
if (_js_global_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));
}
} }
JSClass *jsb_cocos2d_Physics3DHingeConstraint_class; 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::CallArgs args = JS::CallArgsFromVp(argc, vp);
JS::RootedObject obj(cx); JS::RootedObject obj(cx);
obj = args.thisv().toObjectOrNull(); obj.set(args.thisv().toObjectOrNull());
js_proxy_t *proxy = jsb_get_js_proxy(obj); js_proxy_t *proxy = jsb_get_js_proxy(obj);
cobj = (cocos2d::Physics3DHingeConstraint *)(proxy ? proxy->ptr : nullptr); cobj = (cocos2d::Physics3DHingeConstraint *)(proxy ? proxy->ptr : nullptr);
JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_physics3d_Physics3DHingeConstraint_getHingeAngle : Invalid Native Object"); 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::CallArgs args = JS::CallArgsFromVp(argc, vp);
JS::RootedObject obj(cx); JS::RootedObject obj(cx);
obj = args.thisv().toObjectOrNull(); obj.set(args.thisv().toObjectOrNull());
js_proxy_t *proxy = jsb_get_js_proxy(obj); js_proxy_t *proxy = jsb_get_js_proxy(obj);
cobj = (cocos2d::Physics3DHingeConstraint *)(proxy ? proxy->ptr : nullptr); cobj = (cocos2d::Physics3DHingeConstraint *)(proxy ? proxy->ptr : nullptr);
JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_physics3d_Physics3DHingeConstraint_setMotorTarget : Invalid Native Object"); 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).isNull()) { arg0 = nullptr; break; }
if (!args.get(0).isObject()) { ok = false; break; } if (!args.get(0).isObject()) { ok = false; break; }
js_proxy_t *jsProxy; js_proxy_t *jsProxy;
JSObject *tmpObj = args.get(0).toObjectOrNull(); JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull());
jsProxy = jsb_get_js_proxy(tmpObj); jsProxy = jsb_get_js_proxy(tmpObj);
arg0 = (cocos2d::Physics3DRigidBody*)(jsProxy ? jsProxy->ptr : NULL); arg0 = (cocos2d::Physics3DRigidBody*)(jsProxy ? jsProxy->ptr : NULL);
JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); 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).isNull()) { arg0 = nullptr; break; }
if (!args.get(0).isObject()) { ok = false; break; } if (!args.get(0).isObject()) { ok = false; break; }
js_proxy_t *jsProxy; js_proxy_t *jsProxy;
JSObject *tmpObj = args.get(0).toObjectOrNull(); JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull());
jsProxy = jsb_get_js_proxy(tmpObj); jsProxy = jsb_get_js_proxy(tmpObj);
arg0 = (cocos2d::Physics3DRigidBody*)(jsProxy ? jsProxy->ptr : NULL); arg0 = (cocos2d::Physics3DRigidBody*)(jsProxy ? jsProxy->ptr : NULL);
JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); 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).isNull()) { arg0 = nullptr; break; }
if (!args.get(0).isObject()) { ok = false; break; } if (!args.get(0).isObject()) { ok = false; break; }
js_proxy_t *jsProxy; js_proxy_t *jsProxy;
JSObject *tmpObj = args.get(0).toObjectOrNull(); JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull());
jsProxy = jsb_get_js_proxy(tmpObj); jsProxy = jsb_get_js_proxy(tmpObj);
arg0 = (cocos2d::Physics3DRigidBody*)(jsProxy ? jsProxy->ptr : NULL); arg0 = (cocos2d::Physics3DRigidBody*)(jsProxy ? jsProxy->ptr : NULL);
JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); 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).isNull()) { arg0 = nullptr; break; }
if (!args.get(0).isObject()) { ok = false; break; } if (!args.get(0).isObject()) { ok = false; break; }
js_proxy_t *jsProxy; js_proxy_t *jsProxy;
JSObject *tmpObj = args.get(0).toObjectOrNull(); JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull());
jsProxy = jsb_get_js_proxy(tmpObj); jsProxy = jsb_get_js_proxy(tmpObj);
arg0 = (cocos2d::Physics3DRigidBody*)(jsProxy ? jsProxy->ptr : NULL); arg0 = (cocos2d::Physics3DRigidBody*)(jsProxy ? jsProxy->ptr : NULL);
JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); 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).isNull()) { arg0 = nullptr; break; }
if (!args.get(0).isObject()) { ok = false; break; } if (!args.get(0).isObject()) { ok = false; break; }
js_proxy_t *jsProxy; js_proxy_t *jsProxy;
JSObject *tmpObj = args.get(0).toObjectOrNull(); JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull());
jsProxy = jsb_get_js_proxy(tmpObj); jsProxy = jsb_get_js_proxy(tmpObj);
arg0 = (cocos2d::Physics3DRigidBody*)(jsProxy ? jsProxy->ptr : NULL); arg0 = (cocos2d::Physics3DRigidBody*)(jsProxy ? jsProxy->ptr : NULL);
JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); 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).isNull()) { arg1 = nullptr; break; }
if (!args.get(1).isObject()) { ok = false; break; } if (!args.get(1).isObject()) { ok = false; break; }
js_proxy_t *jsProxy; js_proxy_t *jsProxy;
JSObject *tmpObj = args.get(1).toObjectOrNull(); JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull());
jsProxy = jsb_get_js_proxy(tmpObj); jsProxy = jsb_get_js_proxy(tmpObj);
arg1 = (cocos2d::Physics3DRigidBody*)(jsProxy ? jsProxy->ptr : NULL); arg1 = (cocos2d::Physics3DRigidBody*)(jsProxy ? jsProxy->ptr : NULL);
JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); 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).isNull()) { arg0 = nullptr; break; }
if (!args.get(0).isObject()) { ok = false; break; } if (!args.get(0).isObject()) { ok = false; break; }
js_proxy_t *jsProxy; js_proxy_t *jsProxy;
JSObject *tmpObj = args.get(0).toObjectOrNull(); JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull());
jsProxy = jsb_get_js_proxy(tmpObj); jsProxy = jsb_get_js_proxy(tmpObj);
arg0 = (cocos2d::Physics3DRigidBody*)(jsProxy ? jsProxy->ptr : NULL); arg0 = (cocos2d::Physics3DRigidBody*)(jsProxy ? jsProxy->ptr : NULL);
JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); 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).isNull()) { arg1 = nullptr; break; }
if (!args.get(1).isObject()) { ok = false; break; } if (!args.get(1).isObject()) { ok = false; break; }
js_proxy_t *jsProxy; js_proxy_t *jsProxy;
JSObject *tmpObj = args.get(1).toObjectOrNull(); JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull());
jsProxy = jsb_get_js_proxy(tmpObj); jsProxy = jsb_get_js_proxy(tmpObj);
arg1 = (cocos2d::Physics3DRigidBody*)(jsProxy ? jsProxy->ptr : NULL); arg1 = (cocos2d::Physics3DRigidBody*)(jsProxy ? jsProxy->ptr : NULL);
JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); 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).isNull()) { arg0 = nullptr; break; }
if (!args.get(0).isObject()) { ok = false; break; } if (!args.get(0).isObject()) { ok = false; break; }
js_proxy_t *jsProxy; js_proxy_t *jsProxy;
JSObject *tmpObj = args.get(0).toObjectOrNull(); JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull());
jsProxy = jsb_get_js_proxy(tmpObj); jsProxy = jsb_get_js_proxy(tmpObj);
arg0 = (cocos2d::Physics3DRigidBody*)(jsProxy ? jsProxy->ptr : NULL); arg0 = (cocos2d::Physics3DRigidBody*)(jsProxy ? jsProxy->ptr : NULL);
JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); 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).isNull()) { arg1 = nullptr; break; }
if (!args.get(1).isObject()) { ok = false; break; } if (!args.get(1).isObject()) { ok = false; break; }
js_proxy_t *jsProxy; js_proxy_t *jsProxy;
JSObject *tmpObj = args.get(1).toObjectOrNull(); JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull());
jsProxy = jsb_get_js_proxy(tmpObj); jsProxy = jsb_get_js_proxy(tmpObj);
arg1 = (cocos2d::Physics3DRigidBody*)(jsProxy ? jsProxy->ptr : NULL); arg1 = (cocos2d::Physics3DRigidBody*)(jsProxy ? jsProxy->ptr : NULL);
JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); 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).isNull()) { arg0 = nullptr; break; }
if (!args.get(0).isObject()) { ok = false; break; } if (!args.get(0).isObject()) { ok = false; break; }
js_proxy_t *jsProxy; js_proxy_t *jsProxy;
JSObject *tmpObj = args.get(0).toObjectOrNull(); JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull());
jsProxy = jsb_get_js_proxy(tmpObj); jsProxy = jsb_get_js_proxy(tmpObj);
arg0 = (cocos2d::Physics3DRigidBody*)(jsProxy ? jsProxy->ptr : NULL); arg0 = (cocos2d::Physics3DRigidBody*)(jsProxy ? jsProxy->ptr : NULL);
JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); 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).isNull()) { arg1 = nullptr; break; }
if (!args.get(1).isObject()) { ok = false; break; } if (!args.get(1).isObject()) { ok = false; break; }
js_proxy_t *jsProxy; js_proxy_t *jsProxy;
JSObject *tmpObj = args.get(1).toObjectOrNull(); JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull());
jsProxy = jsb_get_js_proxy(tmpObj); jsProxy = jsb_get_js_proxy(tmpObj);
arg1 = (cocos2d::Physics3DRigidBody*)(jsProxy ? jsProxy->ptr : NULL); arg1 = (cocos2d::Physics3DRigidBody*)(jsProxy ? jsProxy->ptr : NULL);
JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); 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!"); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!");
typeClass = typeMapIter->second; typeClass = typeMapIter->second;
CCASSERT(typeClass, "The value is null."); CCASSERT(typeClass, "The value is null.");
JS::RootedObject proto(cx, typeClass->proto.get()); JS::RootedObject proto(cx, typeClass->proto.ref());
JS::RootedObject parent(cx, typeClass->parentProto.get()); JS::RootedObject parent(cx, typeClass->parentProto.ref());
JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent));
args.rval().set(OBJECT_TO_JSVAL(obj)); args.rval().set(OBJECT_TO_JSVAL(obj));
// link the native object with the javascript object // 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_FS_END
}; };
JS::RootedObject parent_proto(cx, jsb_cocos2d_Physics3DConstraint_prototype);
jsb_cocos2d_Physics3DHingeConstraint_prototype = JS_InitClass( jsb_cocos2d_Physics3DHingeConstraint_prototype = JS_InitClass(
cx, global, cx, global,
JS::RootedObject(cx, jsb_cocos2d_Physics3DConstraint_prototype), parent_proto,
jsb_cocos2d_Physics3DHingeConstraint_class, jsb_cocos2d_Physics3DHingeConstraint_class,
js_cocos2dx_physics3d_Physics3DHingeConstraint_constructor, 0, // constructor js_cocos2dx_physics3d_Physics3DHingeConstraint_constructor, 0, // constructor
properties, properties,
funcs, funcs,
NULL, // no static properties NULL, // no static properties
st_funcs); 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 // add the proto and JSClass to the type->js info hash table
TypeTest<cocos2d::Physics3DHingeConstraint> t; JS::RootedObject proto(cx, jsb_cocos2d_Physics3DHingeConstraint_prototype);
js_type_class_t *p; jsb_register_class<cocos2d::Physics3DHingeConstraint>(cx, jsb_cocos2d_Physics3DHingeConstraint_class, proto, parent_proto);
std::string typeName = t.s_name();
if (_js_global_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));
}
} }
JSClass *jsb_cocos2d_Physics3DSliderConstraint_class; 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).isNull()) { arg0 = nullptr; break; }
if (!args.get(0).isObject()) { ok = false; break; } if (!args.get(0).isObject()) { ok = false; break; }
js_proxy_t *jsProxy; js_proxy_t *jsProxy;
JSObject *tmpObj = args.get(0).toObjectOrNull(); JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull());
jsProxy = jsb_get_js_proxy(tmpObj); jsProxy = jsb_get_js_proxy(tmpObj);
arg0 = (cocos2d::Physics3DRigidBody*)(jsProxy ? jsProxy->ptr : NULL); arg0 = (cocos2d::Physics3DRigidBody*)(jsProxy ? jsProxy->ptr : NULL);
JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); 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).isNull()) { arg1 = nullptr; break; }
if (!args.get(1).isObject()) { ok = false; break; } if (!args.get(1).isObject()) { ok = false; break; }
js_proxy_t *jsProxy; js_proxy_t *jsProxy;
JSObject *tmpObj = args.get(1).toObjectOrNull(); JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull());
jsProxy = jsb_get_js_proxy(tmpObj); jsProxy = jsb_get_js_proxy(tmpObj);
arg1 = (cocos2d::Physics3DRigidBody*)(jsProxy ? jsProxy->ptr : NULL); arg1 = (cocos2d::Physics3DRigidBody*)(jsProxy ? jsProxy->ptr : NULL);
JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); 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!"); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!");
typeClass = typeMapIter->second; typeClass = typeMapIter->second;
CCASSERT(typeClass, "The value is null."); CCASSERT(typeClass, "The value is null.");
JS::RootedObject proto(cx, typeClass->proto.get()); JS::RootedObject proto(cx, typeClass->proto.ref());
JS::RootedObject parent(cx, typeClass->parentProto.get()); JS::RootedObject parent(cx, typeClass->parentProto.ref());
JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent));
args.rval().set(OBJECT_TO_JSVAL(obj)); args.rval().set(OBJECT_TO_JSVAL(obj));
// link the native object with the javascript object // 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_FS_END
}; };
JS::RootedObject parent_proto(cx, jsb_cocos2d_Physics3DConstraint_prototype);
jsb_cocos2d_Physics3DSliderConstraint_prototype = JS_InitClass( jsb_cocos2d_Physics3DSliderConstraint_prototype = JS_InitClass(
cx, global, cx, global,
JS::RootedObject(cx, jsb_cocos2d_Physics3DConstraint_prototype), parent_proto,
jsb_cocos2d_Physics3DSliderConstraint_class, jsb_cocos2d_Physics3DSliderConstraint_class,
js_cocos2dx_physics3d_Physics3DSliderConstraint_constructor, 0, // constructor js_cocos2dx_physics3d_Physics3DSliderConstraint_constructor, 0, // constructor
properties, properties,
funcs, funcs,
NULL, // no static properties NULL, // no static properties
st_funcs); 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 // add the proto and JSClass to the type->js info hash table
TypeTest<cocos2d::Physics3DSliderConstraint> t; JS::RootedObject proto(cx, jsb_cocos2d_Physics3DSliderConstraint_prototype);
js_type_class_t *p; jsb_register_class<cocos2d::Physics3DSliderConstraint>(cx, jsb_cocos2d_Physics3DSliderConstraint_class, proto, parent_proto);
std::string typeName = t.s_name();
if (_js_global_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));
}
} }
JSClass *jsb_cocos2d_Physics3DConeTwistConstraint_class; 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).isNull()) { arg0 = nullptr; break; }
if (!args.get(0).isObject()) { ok = false; break; } if (!args.get(0).isObject()) { ok = false; break; }
js_proxy_t *jsProxy; js_proxy_t *jsProxy;
JSObject *tmpObj = args.get(0).toObjectOrNull(); JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull());
jsProxy = jsb_get_js_proxy(tmpObj); jsProxy = jsb_get_js_proxy(tmpObj);
arg0 = (cocos2d::Physics3DRigidBody*)(jsProxy ? jsProxy->ptr : NULL); arg0 = (cocos2d::Physics3DRigidBody*)(jsProxy ? jsProxy->ptr : NULL);
JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); 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).isNull()) { arg1 = nullptr; break; }
if (!args.get(1).isObject()) { ok = false; break; } if (!args.get(1).isObject()) { ok = false; break; }
js_proxy_t *jsProxy; js_proxy_t *jsProxy;
JSObject *tmpObj = args.get(1).toObjectOrNull(); JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull());
jsProxy = jsb_get_js_proxy(tmpObj); jsProxy = jsb_get_js_proxy(tmpObj);
arg1 = (cocos2d::Physics3DRigidBody*)(jsProxy ? jsProxy->ptr : NULL); arg1 = (cocos2d::Physics3DRigidBody*)(jsProxy ? jsProxy->ptr : NULL);
JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); 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).isNull()) { arg0 = nullptr; break; }
if (!args.get(0).isObject()) { ok = false; break; } if (!args.get(0).isObject()) { ok = false; break; }
js_proxy_t *jsProxy; js_proxy_t *jsProxy;
JSObject *tmpObj = args.get(0).toObjectOrNull(); JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull());
jsProxy = jsb_get_js_proxy(tmpObj); jsProxy = jsb_get_js_proxy(tmpObj);
arg0 = (cocos2d::Physics3DRigidBody*)(jsProxy ? jsProxy->ptr : NULL); arg0 = (cocos2d::Physics3DRigidBody*)(jsProxy ? jsProxy->ptr : NULL);
JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); 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!"); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!");
typeClass = typeMapIter->second; typeClass = typeMapIter->second;
CCASSERT(typeClass, "The value is null."); CCASSERT(typeClass, "The value is null.");
JS::RootedObject proto(cx, typeClass->proto.get()); JS::RootedObject proto(cx, typeClass->proto.ref());
JS::RootedObject parent(cx, typeClass->parentProto.get()); JS::RootedObject parent(cx, typeClass->parentProto.ref());
JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent));
args.rval().set(OBJECT_TO_JSVAL(obj)); args.rval().set(OBJECT_TO_JSVAL(obj));
// link the native object with the javascript object // link the native object with the javascript object
@ -6535,32 +6411,20 @@ void js_register_cocos2dx_physics3d_Physics3DConeTwistConstraint(JSContext *cx,
JS_FS_END JS_FS_END
}; };
JS::RootedObject parent_proto(cx, jsb_cocos2d_Physics3DConstraint_prototype);
jsb_cocos2d_Physics3DConeTwistConstraint_prototype = JS_InitClass( jsb_cocos2d_Physics3DConeTwistConstraint_prototype = JS_InitClass(
cx, global, cx, global,
JS::RootedObject(cx, jsb_cocos2d_Physics3DConstraint_prototype), parent_proto,
jsb_cocos2d_Physics3DConeTwistConstraint_class, jsb_cocos2d_Physics3DConeTwistConstraint_class,
js_cocos2dx_physics3d_Physics3DConeTwistConstraint_constructor, 0, // constructor js_cocos2dx_physics3d_Physics3DConeTwistConstraint_constructor, 0, // constructor
properties, properties,
funcs, funcs,
NULL, // no static properties NULL, // no static properties
st_funcs); 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 // add the proto and JSClass to the type->js info hash table
TypeTest<cocos2d::Physics3DConeTwistConstraint> t; JS::RootedObject proto(cx, jsb_cocos2d_Physics3DConeTwistConstraint_prototype);
js_type_class_t *p; jsb_register_class<cocos2d::Physics3DConeTwistConstraint>(cx, jsb_cocos2d_Physics3DConeTwistConstraint_class, proto, parent_proto);
std::string typeName = t.s_name();
if (_js_global_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));
}
} }
JSClass *jsb_cocos2d_Physics3D6DofConstraint_class; 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).isNull()) { arg0 = nullptr; break; }
if (!args.get(0).isObject()) { ok = false; break; } if (!args.get(0).isObject()) { ok = false; break; }
js_proxy_t *jsProxy; js_proxy_t *jsProxy;
JSObject *tmpObj = args.get(0).toObjectOrNull(); JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull());
jsProxy = jsb_get_js_proxy(tmpObj); jsProxy = jsb_get_js_proxy(tmpObj);
arg0 = (cocos2d::Physics3DRigidBody*)(jsProxy ? jsProxy->ptr : NULL); arg0 = (cocos2d::Physics3DRigidBody*)(jsProxy ? jsProxy->ptr : NULL);
JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); 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).isNull()) { arg0 = nullptr; break; }
if (!args.get(0).isObject()) { ok = false; break; } if (!args.get(0).isObject()) { ok = false; break; }
js_proxy_t *jsProxy; js_proxy_t *jsProxy;
JSObject *tmpObj = args.get(0).toObjectOrNull(); JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull());
jsProxy = jsb_get_js_proxy(tmpObj); jsProxy = jsb_get_js_proxy(tmpObj);
arg0 = (cocos2d::Physics3DRigidBody*)(jsProxy ? jsProxy->ptr : NULL); arg0 = (cocos2d::Physics3DRigidBody*)(jsProxy ? jsProxy->ptr : NULL);
JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); 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).isNull()) { arg1 = nullptr; break; }
if (!args.get(1).isObject()) { ok = false; break; } if (!args.get(1).isObject()) { ok = false; break; }
js_proxy_t *jsProxy; js_proxy_t *jsProxy;
JSObject *tmpObj = args.get(1).toObjectOrNull(); JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull());
jsProxy = jsb_get_js_proxy(tmpObj); jsProxy = jsb_get_js_proxy(tmpObj);
arg1 = (cocos2d::Physics3DRigidBody*)(jsProxy ? jsProxy->ptr : NULL); arg1 = (cocos2d::Physics3DRigidBody*)(jsProxy ? jsProxy->ptr : NULL);
JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); 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!"); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!");
typeClass = typeMapIter->second; typeClass = typeMapIter->second;
CCASSERT(typeClass, "The value is null."); CCASSERT(typeClass, "The value is null.");
JS::RootedObject proto(cx, typeClass->proto.get()); JS::RootedObject proto(cx, typeClass->proto.ref());
JS::RootedObject parent(cx, typeClass->parentProto.get()); JS::RootedObject parent(cx, typeClass->parentProto.ref());
JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent));
args.rval().set(OBJECT_TO_JSVAL(obj)); args.rval().set(OBJECT_TO_JSVAL(obj));
// link the native object with the javascript object // 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_FS_END
}; };
JS::RootedObject parent_proto(cx, jsb_cocos2d_Physics3DConstraint_prototype);
jsb_cocos2d_Physics3D6DofConstraint_prototype = JS_InitClass( jsb_cocos2d_Physics3D6DofConstraint_prototype = JS_InitClass(
cx, global, cx, global,
JS::RootedObject(cx, jsb_cocos2d_Physics3DConstraint_prototype), parent_proto,
jsb_cocos2d_Physics3D6DofConstraint_class, jsb_cocos2d_Physics3D6DofConstraint_class,
js_cocos2dx_physics3d_Physics3D6DofConstraint_constructor, 0, // constructor js_cocos2dx_physics3d_Physics3D6DofConstraint_constructor, 0, // constructor
properties, properties,
funcs, funcs,
NULL, // no static properties NULL, // no static properties
st_funcs); 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 // add the proto and JSClass to the type->js info hash table
TypeTest<cocos2d::Physics3D6DofConstraint> t; JS::RootedObject proto(cx, jsb_cocos2d_Physics3D6DofConstraint_prototype);
js_type_class_t *p; jsb_register_class<cocos2d::Physics3D6DofConstraint>(cx, jsb_cocos2d_Physics3D6DofConstraint_class, proto, parent_proto);
std::string typeName = t.s_name();
if (_js_global_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));
}
} }
void register_all_cocos2dx_physics3d(JSContext* cx, JS::HandleObject obj) { void register_all_cocos2dx_physics3d(JSContext* cx, JS::HandleObject obj) {

View File

@ -20,8 +20,8 @@ static bool dummy_constructor(JSContext *cx, uint32_t argc, jsval *vp) {
typeClass = typeMapIter->second; typeClass = typeMapIter->second;
CCASSERT(typeClass, "The value is null."); CCASSERT(typeClass, "The value is null.");
JS::RootedObject proto(cx, typeClass->proto.get()); JS::RootedObject proto(cx, typeClass->proto.ref());
JS::RootedObject parent(cx, typeClass->parentProto.get()); JS::RootedObject parent(cx, typeClass->parentProto.ref());
JS::RootedObject _tmp(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); JS::RootedObject _tmp(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent));
args.rval().set(OBJECT_TO_JSVAL(_tmp)); 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::CallArgs args = JS::CallArgsFromVp(argc, vp);
JS::RootedObject obj(cx); JS::RootedObject obj(cx);
obj = args.thisv().toObjectOrNull(); obj.set(args.thisv().toObjectOrNull());
js_proxy_t *proxy = jsb_get_js_proxy(obj); js_proxy_t *proxy = jsb_get_js_proxy(obj);
cobj = (spine::SkeletonRenderer *)(proxy ? proxy->ptr : nullptr); cobj = (spine::SkeletonRenderer *)(proxy ? proxy->ptr : nullptr);
JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_spine_SkeletonRenderer_setAttachment : Invalid Native Object"); 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::CallArgs args = JS::CallArgsFromVp(argc, vp);
JS::RootedObject obj(cx); JS::RootedObject obj(cx);
obj = args.thisv().toObjectOrNull(); obj.set(args.thisv().toObjectOrNull());
js_proxy_t *proxy = jsb_get_js_proxy(obj); js_proxy_t *proxy = jsb_get_js_proxy(obj);
cobj = (spine::SkeletonRenderer *)(proxy ? proxy->ptr : nullptr); cobj = (spine::SkeletonRenderer *)(proxy ? proxy->ptr : nullptr);
JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_spine_SkeletonRenderer_initWithFile : Invalid Native Object"); 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::CallArgs args = JS::CallArgsFromVp(argc, vp);
JS::RootedObject obj(cx); JS::RootedObject obj(cx);
obj = args.thisv().toObjectOrNull(); obj.set(args.thisv().toObjectOrNull());
js_proxy_t *proxy = jsb_get_js_proxy(obj); js_proxy_t *proxy = jsb_get_js_proxy(obj);
cobj = (spine::SkeletonRenderer *)(proxy ? proxy->ptr : nullptr); cobj = (spine::SkeletonRenderer *)(proxy ? proxy->ptr : nullptr);
JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_spine_SkeletonRenderer_setSkin : Invalid Native Object"); 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; typeClass = typeMapIter->second;
CCASSERT(typeClass, "The value is null."); CCASSERT(typeClass, "The value is null.");
// obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); // obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto);
JS::RootedObject proto(cx, typeClass->proto.get()); JS::RootedObject proto(cx, typeClass->proto.ref());
JS::RootedObject parent(cx, typeClass->parentProto.get()); JS::RootedObject parent(cx, typeClass->parentProto.ref());
obj = JS_NewObject(cx, typeClass->jsclass, proto, parent); obj = JS_NewObject(cx, typeClass->jsclass, proto, parent);
js_proxy_t* p = jsb_new_proxy(cobj, obj); 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; typeClass = typeMapIter->second;
CCASSERT(typeClass, "The value is null."); CCASSERT(typeClass, "The value is null.");
// obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); // obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto);
JS::RootedObject proto(cx, typeClass->proto.get()); JS::RootedObject proto(cx, typeClass->proto.ref());
JS::RootedObject parent(cx, typeClass->parentProto.get()); JS::RootedObject parent(cx, typeClass->parentProto.ref());
obj = JS_NewObject(cx, typeClass->jsclass, proto, parent); obj = JS_NewObject(cx, typeClass->jsclass, proto, parent);
js_proxy_t* p = jsb_new_proxy(cobj, obj); 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; typeClass = typeMapIter->second;
CCASSERT(typeClass, "The value is null."); CCASSERT(typeClass, "The value is null.");
// obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); // obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto);
JS::RootedObject proto(cx, typeClass->proto.get()); JS::RootedObject proto(cx, typeClass->proto.ref());
JS::RootedObject parent(cx, typeClass->parentProto.get()); JS::RootedObject parent(cx, typeClass->parentProto.ref());
obj = JS_NewObject(cx, typeClass->jsclass, proto, parent); obj = JS_NewObject(cx, typeClass->jsclass, proto, parent);
js_proxy_t* p = jsb_new_proxy(cobj, obj); 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; typeClass = typeMapIter->second;
CCASSERT(typeClass, "The value is null."); CCASSERT(typeClass, "The value is null.");
// obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); // obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto);
JS::RootedObject proto(cx, typeClass->proto.get()); JS::RootedObject proto(cx, typeClass->proto.ref());
JS::RootedObject parent(cx, typeClass->parentProto.get()); JS::RootedObject parent(cx, typeClass->parentProto.ref());
obj = JS_NewObject(cx, typeClass->jsclass, proto, parent); obj = JS_NewObject(cx, typeClass->jsclass, proto, parent);
js_proxy_t* p = jsb_new_proxy(cobj, obj); 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; typeClass = typeMapIter->second;
CCASSERT(typeClass, "The value is null."); CCASSERT(typeClass, "The value is null.");
// obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); // obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto);
JS::RootedObject proto(cx, typeClass->proto.get()); JS::RootedObject proto(cx, typeClass->proto.ref());
JS::RootedObject parent(cx, typeClass->parentProto.get()); JS::RootedObject parent(cx, typeClass->parentProto.ref());
obj = JS_NewObject(cx, typeClass->jsclass, proto, parent); obj = JS_NewObject(cx, typeClass->jsclass, proto, parent);
js_proxy_t* p = jsb_new_proxy(cobj, obj); 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; typeClass = typeMapIter->second;
CCASSERT(typeClass, "The value is null."); CCASSERT(typeClass, "The value is null.");
// obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); // obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto);
JS::RootedObject proto(cx, typeClass->proto.get()); JS::RootedObject proto(cx, typeClass->proto.ref());
JS::RootedObject parent(cx, typeClass->parentProto.get()); JS::RootedObject parent(cx, typeClass->parentProto.ref());
obj = JS_NewObject(cx, typeClass->jsclass, proto, parent); obj = JS_NewObject(cx, typeClass->jsclass, proto, parent);
js_proxy_t* p = jsb_new_proxy(cobj, obj); 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; typeClass = typeMapIter->second;
CCASSERT(typeClass, "The value is null."); CCASSERT(typeClass, "The value is null.");
// obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); // obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto);
JS::RootedObject proto(cx, typeClass->proto.get()); JS::RootedObject proto(cx, typeClass->proto.ref());
JS::RootedObject parent(cx, typeClass->parentProto.get()); JS::RootedObject parent(cx, typeClass->parentProto.ref());
obj = JS_NewObject(cx, typeClass->jsclass, proto, parent); obj = JS_NewObject(cx, typeClass->jsclass, proto, parent);
js_proxy_t* p = jsb_new_proxy(cobj, obj); 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_FS_END
}; };
JS::RootedObject parent_proto(cx, jsb_cocos2d_Node_prototype);
jsb_spine_SkeletonRenderer_prototype = JS_InitClass( jsb_spine_SkeletonRenderer_prototype = JS_InitClass(
cx, global, cx, global,
JS::RootedObject(cx, jsb_cocos2d_Node_prototype), parent_proto,
jsb_spine_SkeletonRenderer_class, jsb_spine_SkeletonRenderer_class,
js_cocos2dx_spine_SkeletonRenderer_constructor, 0, // constructor js_cocos2dx_spine_SkeletonRenderer_constructor, 0, // constructor
properties, properties,
funcs, funcs,
NULL, // no static properties NULL, // no static properties
st_funcs); 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 // add the proto and JSClass to the type->js info hash table
TypeTest<spine::SkeletonRenderer> t; JS::RootedObject proto(cx, jsb_spine_SkeletonRenderer_prototype);
js_type_class_t *p; jsb_register_class<spine::SkeletonRenderer>(cx, jsb_spine_SkeletonRenderer_class, proto, parent_proto);
std::string typeName = t.s_name();
if (_js_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));
}
} }
JSClass *jsb_spine_SkeletonAnimation_class; JSClass *jsb_spine_SkeletonAnimation_class;
@ -949,7 +937,8 @@ bool js_cocos2dx_spine_SkeletonAnimation_setStartListener(JSContext *cx, uint32_
do { do {
if(JS_TypeOfValue(cx, args.get(0)) == JSTYPE_FUNCTION) if(JS_TypeOfValue(cx, args.get(0)) == JSTYPE_FUNCTION)
{ {
std::shared_ptr<JSFunctionWrapper> func(new JSFunctionWrapper(cx, args.thisv().toObjectOrNull(), args.get(0))); JS::RootedObject jstarget(cx, args.thisv().toObjectOrNull());
std::shared_ptr<JSFunctionWrapper> func(new JSFunctionWrapper(cx, jstarget, args.get(0)));
auto lambda = [=](int larg0) -> void { auto lambda = [=](int larg0) -> void {
JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET
jsval largv[1]; jsval largv[1];
@ -993,7 +982,8 @@ bool js_cocos2dx_spine_SkeletonAnimation_setTrackEventListener(JSContext *cx, ui
do { do {
if(JS_TypeOfValue(cx, args.get(1)) == JSTYPE_FUNCTION) if(JS_TypeOfValue(cx, args.get(1)) == JSTYPE_FUNCTION)
{ {
std::shared_ptr<JSFunctionWrapper> func(new JSFunctionWrapper(cx, args.thisv().toObjectOrNull(), args.get(1))); JS::RootedObject jstarget(cx, args.thisv().toObjectOrNull());
std::shared_ptr<JSFunctionWrapper> func(new JSFunctionWrapper(cx, jstarget, args.get(1)));
auto lambda = [=](int larg0, spEvent* larg1) -> void { auto lambda = [=](int larg0, spEvent* larg1) -> void {
JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET
jsval largv[2]; jsval largv[2];
@ -1056,7 +1046,8 @@ bool js_cocos2dx_spine_SkeletonAnimation_setTrackCompleteListener(JSContext *cx,
do { do {
if(JS_TypeOfValue(cx, args.get(1)) == JSTYPE_FUNCTION) if(JS_TypeOfValue(cx, args.get(1)) == JSTYPE_FUNCTION)
{ {
std::shared_ptr<JSFunctionWrapper> func(new JSFunctionWrapper(cx, args.thisv().toObjectOrNull(), args.get(1))); JS::RootedObject jstarget(cx, args.thisv().toObjectOrNull());
std::shared_ptr<JSFunctionWrapper> func(new JSFunctionWrapper(cx, jstarget, args.get(1)));
auto lambda = [=](int larg0, int larg1) -> void { auto lambda = [=](int larg0, int larg1) -> void {
JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET
jsval largv[2]; jsval largv[2];
@ -1128,7 +1119,8 @@ bool js_cocos2dx_spine_SkeletonAnimation_setTrackStartListener(JSContext *cx, ui
do { do {
if(JS_TypeOfValue(cx, args.get(1)) == JSTYPE_FUNCTION) if(JS_TypeOfValue(cx, args.get(1)) == JSTYPE_FUNCTION)
{ {
std::shared_ptr<JSFunctionWrapper> func(new JSFunctionWrapper(cx, args.thisv().toObjectOrNull(), args.get(1))); JS::RootedObject jstarget(cx, args.thisv().toObjectOrNull());
std::shared_ptr<JSFunctionWrapper> func(new JSFunctionWrapper(cx, jstarget, args.get(1)));
auto lambda = [=](int larg0) -> void { auto lambda = [=](int larg0) -> void {
JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET
jsval largv[1]; jsval largv[1];
@ -1189,7 +1181,8 @@ bool js_cocos2dx_spine_SkeletonAnimation_setCompleteListener(JSContext *cx, uint
do { do {
if(JS_TypeOfValue(cx, args.get(0)) == JSTYPE_FUNCTION) if(JS_TypeOfValue(cx, args.get(0)) == JSTYPE_FUNCTION)
{ {
std::shared_ptr<JSFunctionWrapper> func(new JSFunctionWrapper(cx, args.thisv().toObjectOrNull(), args.get(0))); JS::RootedObject jstarget(cx, args.thisv().toObjectOrNull());
std::shared_ptr<JSFunctionWrapper> func(new JSFunctionWrapper(cx, jstarget, args.get(0)));
auto lambda = [=](int larg0, int larg1) -> void { auto lambda = [=](int larg0, int larg1) -> void {
JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET
jsval largv[2]; jsval largv[2];
@ -1234,7 +1227,8 @@ bool js_cocos2dx_spine_SkeletonAnimation_setTrackEndListener(JSContext *cx, uint
do { do {
if(JS_TypeOfValue(cx, args.get(1)) == JSTYPE_FUNCTION) if(JS_TypeOfValue(cx, args.get(1)) == JSTYPE_FUNCTION)
{ {
std::shared_ptr<JSFunctionWrapper> func(new JSFunctionWrapper(cx, args.thisv().toObjectOrNull(), args.get(1))); JS::RootedObject jstarget(cx, args.thisv().toObjectOrNull());
std::shared_ptr<JSFunctionWrapper> func(new JSFunctionWrapper(cx, jstarget, args.get(1)));
auto lambda = [=](int larg0) -> void { auto lambda = [=](int larg0) -> void {
JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET
jsval largv[1]; jsval largv[1];
@ -1275,7 +1269,8 @@ bool js_cocos2dx_spine_SkeletonAnimation_setEventListener(JSContext *cx, uint32_
do { do {
if(JS_TypeOfValue(cx, args.get(0)) == JSTYPE_FUNCTION) if(JS_TypeOfValue(cx, args.get(0)) == JSTYPE_FUNCTION)
{ {
std::shared_ptr<JSFunctionWrapper> func(new JSFunctionWrapper(cx, args.thisv().toObjectOrNull(), args.get(0))); JS::RootedObject jstarget(cx, args.thisv().toObjectOrNull());
std::shared_ptr<JSFunctionWrapper> func(new JSFunctionWrapper(cx, jstarget, args.get(0)));
auto lambda = [=](int larg0, spEvent* larg1) -> void { auto lambda = [=](int larg0, spEvent* larg1) -> void {
JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET
jsval largv[2]; jsval largv[2];
@ -1341,7 +1336,8 @@ bool js_cocos2dx_spine_SkeletonAnimation_setEndListener(JSContext *cx, uint32_t
do { do {
if(JS_TypeOfValue(cx, args.get(0)) == JSTYPE_FUNCTION) if(JS_TypeOfValue(cx, args.get(0)) == JSTYPE_FUNCTION)
{ {
std::shared_ptr<JSFunctionWrapper> func(new JSFunctionWrapper(cx, args.thisv().toObjectOrNull(), args.get(0))); JS::RootedObject jstarget(cx, args.thisv().toObjectOrNull());
std::shared_ptr<JSFunctionWrapper> func(new JSFunctionWrapper(cx, jstarget, args.get(0)));
auto lambda = [=](int larg0) -> void { auto lambda = [=](int larg0) -> void {
JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET
jsval largv[1]; jsval largv[1];
@ -1585,8 +1581,8 @@ bool js_cocos2dx_spine_SkeletonAnimation_constructor(JSContext *cx, uint32_t arg
typeClass = typeMapIter->second; typeClass = typeMapIter->second;
CCASSERT(typeClass, "The value is null."); CCASSERT(typeClass, "The value is null.");
// obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); // obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto);
JS::RootedObject proto(cx, typeClass->proto.get()); JS::RootedObject proto(cx, typeClass->proto.ref());
JS::RootedObject parent(cx, typeClass->parentProto.get()); JS::RootedObject parent(cx, typeClass->parentProto.ref());
obj = JS_NewObject(cx, typeClass->jsclass, proto, parent); obj = JS_NewObject(cx, typeClass->jsclass, proto, parent);
js_proxy_t* p = jsb_new_proxy(cobj, obj); 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; typeClass = typeMapIter->second;
CCASSERT(typeClass, "The value is null."); CCASSERT(typeClass, "The value is null.");
// obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); // obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto);
JS::RootedObject proto(cx, typeClass->proto.get()); JS::RootedObject proto(cx, typeClass->proto.ref());
JS::RootedObject parent(cx, typeClass->parentProto.get()); JS::RootedObject parent(cx, typeClass->parentProto.ref());
obj = JS_NewObject(cx, typeClass->jsclass, proto, parent); obj = JS_NewObject(cx, typeClass->jsclass, proto, parent);
js_proxy_t* p = jsb_new_proxy(cobj, obj); 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; typeClass = typeMapIter->second;
CCASSERT(typeClass, "The value is null."); CCASSERT(typeClass, "The value is null.");
// obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); // obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto);
JS::RootedObject proto(cx, typeClass->proto.get()); JS::RootedObject proto(cx, typeClass->proto.ref());
JS::RootedObject parent(cx, typeClass->parentProto.get()); JS::RootedObject parent(cx, typeClass->parentProto.ref());
obj = JS_NewObject(cx, typeClass->jsclass, proto, parent); obj = JS_NewObject(cx, typeClass->jsclass, proto, parent);
js_proxy_t* p = jsb_new_proxy(cobj, obj); 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; typeClass = typeMapIter->second;
CCASSERT(typeClass, "The value is null."); CCASSERT(typeClass, "The value is null.");
// obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); // obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto);
JS::RootedObject proto(cx, typeClass->proto.get()); JS::RootedObject proto(cx, typeClass->proto.ref());
JS::RootedObject parent(cx, typeClass->parentProto.get()); JS::RootedObject parent(cx, typeClass->parentProto.ref());
obj = JS_NewObject(cx, typeClass->jsclass, proto, parent); obj = JS_NewObject(cx, typeClass->jsclass, proto, parent);
js_proxy_t* p = jsb_new_proxy(cobj, obj); 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; typeClass = typeMapIter->second;
CCASSERT(typeClass, "The value is null."); CCASSERT(typeClass, "The value is null.");
// obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); // obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto);
JS::RootedObject proto(cx, typeClass->proto.get()); JS::RootedObject proto(cx, typeClass->proto.ref());
JS::RootedObject parent(cx, typeClass->parentProto.get()); JS::RootedObject parent(cx, typeClass->parentProto.ref());
obj = JS_NewObject(cx, typeClass->jsclass, proto, parent); obj = JS_NewObject(cx, typeClass->jsclass, proto, parent);
js_proxy_t* p = jsb_new_proxy(cobj, obj); 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; typeClass = typeMapIter->second;
CCASSERT(typeClass, "The value is null."); CCASSERT(typeClass, "The value is null.");
// obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); // obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto);
JS::RootedObject proto(cx, typeClass->proto.get()); JS::RootedObject proto(cx, typeClass->proto.ref());
JS::RootedObject parent(cx, typeClass->parentProto.get()); JS::RootedObject parent(cx, typeClass->parentProto.ref());
obj = JS_NewObject(cx, typeClass->jsclass, proto, parent); obj = JS_NewObject(cx, typeClass->jsclass, proto, parent);
js_proxy_t* p = jsb_new_proxy(cobj, obj); 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; typeClass = typeMapIter->second;
CCASSERT(typeClass, "The value is null."); CCASSERT(typeClass, "The value is null.");
// obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); // obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto);
JS::RootedObject proto(cx, typeClass->proto.get()); JS::RootedObject proto(cx, typeClass->proto.ref());
JS::RootedObject parent(cx, typeClass->parentProto.get()); JS::RootedObject parent(cx, typeClass->parentProto.ref());
obj = JS_NewObject(cx, typeClass->jsclass, proto, parent); obj = JS_NewObject(cx, typeClass->jsclass, proto, parent);
js_proxy_t* p = jsb_new_proxy(cobj, obj); 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_FS_END
}; };
JS::RootedObject parent_proto(cx, jsb_spine_SkeletonRenderer_prototype);
jsb_spine_SkeletonAnimation_prototype = JS_InitClass( jsb_spine_SkeletonAnimation_prototype = JS_InitClass(
cx, global, cx, global,
JS::RootedObject(cx, jsb_spine_SkeletonRenderer_prototype), parent_proto,
jsb_spine_SkeletonAnimation_class, jsb_spine_SkeletonAnimation_class,
js_cocos2dx_spine_SkeletonAnimation_constructor, 0, // constructor js_cocos2dx_spine_SkeletonAnimation_constructor, 0, // constructor
properties, properties,
funcs, funcs,
NULL, // no static properties NULL, // no static properties
st_funcs); 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 // add the proto and JSClass to the type->js info hash table
TypeTest<spine::SkeletonAnimation> t; JS::RootedObject proto(cx, jsb_spine_SkeletonAnimation_prototype);
js_type_class_t *p; jsb_register_class<spine::SkeletonAnimation>(cx, jsb_spine_SkeletonAnimation_class, proto, parent_proto);
std::string typeName = t.s_name();
if (_js_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));
}
anonEvaluate(cx, global, "(function () { sp.SkeletonAnimation.extend = cc.Class.extend; })()"); anonEvaluate(cx, global, "(function () { sp.SkeletonAnimation.extend = cc.Class.extend; })()");
} }

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -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_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_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_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_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_getPositionPercent(JSContext *cx, uint32_t argc, jsval *vp);
bool js_cocos2dx_ui_Widget_propagateTouchEvent(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_cocos2dx_ui_CheckBox_finalize(JSContext *cx, JSObject *obj);
void js_register_cocos2dx_ui_CheckBox(JSContext *cx, JS::HandleObject global); void js_register_cocos2dx_ui_CheckBox(JSContext *cx, JS::HandleObject global);
void register_all_cocos2dx_ui(JSContext* cx, JS::HandleObject obj); 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_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_createInstance(JSContext *cx, uint32_t argc, jsval *vp);
bool js_cocos2dx_ui_CheckBox_CheckBox(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_cocos2dx_ui_RadioButton_finalize(JSContext *cx, JSObject *obj);
void js_register_cocos2dx_ui_RadioButton(JSContext *cx, JS::HandleObject global); void js_register_cocos2dx_ui_RadioButton(JSContext *cx, JS::HandleObject global);
void register_all_cocos2dx_ui(JSContext* cx, JS::HandleObject obj); 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_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_createInstance(JSContext *cx, uint32_t argc, jsval *vp);
bool js_cocos2dx_ui_RadioButton_RadioButton(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_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_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_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_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_getRadioButtonByIndex(JSContext *cx, uint32_t argc, jsval *vp);
bool js_cocos2dx_ui_RadioButtonGroup_getNumberOfRadioButtons(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_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_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_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_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_setScrollBarPositionFromCornerForHorizontal(JSContext *cx, uint32_t argc, jsval *vp);
bool js_cocos2dx_ui_ScrollView_setInertiaScrollEnabled(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_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_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_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_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_getTopmostItemInCurrentView(JSContext *cx, uint32_t argc, jsval *vp);
bool js_cocos2dx_ui_ListView_removeAllItems(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_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_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_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_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_loadBarTexture(JSContext *cx, uint32_t argc, jsval *vp);
bool js_cocos2dx_ui_Slider_getProgressBarFile(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_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_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_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_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_getFontName(JSContext *cx, uint32_t argc, jsval *vp);
bool js_cocos2dx_ui_TextField_setTextAreaSize(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_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_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_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_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_getIndicatorEnabled(JSContext *cx, uint32_t argc, jsval *vp);
bool js_cocos2dx_ui_PageView_scrollToPage(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_PageView_scrollToPage(JSContext *cx, uint32_t argc, jsval *vp);