Fix some issue of js_type_class usage

This commit is contained in:
pandamicro 2015-11-27 10:16:11 +08:00
parent 73c3a5dcf5
commit d23ffe4fc7
4 changed files with 9 additions and 11 deletions

View File

@ -5807,7 +5807,7 @@ bool js_cocos2dx_ComponentJS_getScriptObject(JSContext *cx, uint32_t argc, jsval
cocos2d::ComponentJS* cobj = (cocos2d::ComponentJS *)(proxy ? proxy->ptr : NULL);
JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ComponentJS_getScriptObject : Invalid Native Object");
if (argc == 0) {
JSObject* ret = static_cast<JSObject*>(cobj->getScriptObject());
JS::RootedObject ret(cx, static_cast<JSObject*>(cobj->getScriptObject()));
jsval jsret = OBJECT_TO_JSVAL(ret);
args.rval().set(jsret);
return true;

View File

@ -76,7 +76,7 @@ ComponentJS::ComponentJS(const std::string& scriptFileName)
mozilla::Maybe<JS::PersistentRootedObject> *jsObj = new mozilla::Maybe<JS::PersistentRootedObject>();
JS::RootedObject proto(cx, protoValue.toObjectOrNull());
JS::RootedObject parent(cx, typeClass->proto.get());
JS::RootedObject parent(cx, typeClass->proto.ref());
jsObj->construct(cx);
jsObj->ref() = JS_NewObject(cx, theClass, proto, parent);
@ -85,7 +85,7 @@ ComponentJS::ComponentJS(const std::string& scriptFileName)
JS::RemoveObjectRoot(cx, &jsproxy->obj);
jsb_remove_proxy(jsb_get_native_proxy(this), jsproxy);
// link the native object with the javascript object
jsb_new_proxy(this, jsObj->ref().get());
jsb_new_proxy(this, jsObj->ref());
_jsObj = jsObj;
}

View File

@ -499,8 +499,8 @@ bool js_cocos2dx_DrawNode3D_constructor(JSContext *cx, uint32_t argc, jsval *vp)
typeClass = typeMapIter->second;
CCASSERT(typeClass, "The value is null.");
// JSObject *obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto);
JS::RootedObject proto(cx, typeClass->proto.get());
JS::RootedObject parent(cx, typeClass->parentProto.get());
JS::RootedObject proto(cx, typeClass->proto.ref());
JS::RootedObject parent(cx, typeClass->parentProto.ref());
JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent));
args.rval().set(OBJECT_TO_JSVAL(obj));
// link the native object with the javascript object

View File

@ -483,9 +483,8 @@ bool jsb_Effect3DOutline_constructor(JSContext *cx, uint32_t argc, jsval *vp)
CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!");
typeClass = typeMapIter->second;
CCASSERT(typeClass, "The value is null.");
// JSObject *obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto);
JS::RootedObject proto(cx, typeClass->proto.get());
JS::RootedObject parent(cx, typeClass->parentProto.get());
JS::RootedObject proto(cx, typeClass->proto.ref());
JS::RootedObject parent(cx, typeClass->parentProto.ref());
JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent));
args.rval().set(OBJECT_TO_JSVAL(obj));
// link the native object with the javascript object
@ -685,9 +684,8 @@ bool jsb_EffectSprite3D_constructor(JSContext *cx, uint32_t argc, jsval *vp)
CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!");
typeClass = typeMapIter->second;
CCASSERT(typeClass, "The value is null.");
// JSObject *obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto);
JS::RootedObject proto(cx, typeClass->proto.get());
JS::RootedObject parent(cx, typeClass->parentProto.get());
JS::RootedObject proto(cx, typeClass->proto.ref());
JS::RootedObject parent(cx, typeClass->parentProto.ref());
JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent));
args.rval().set(OBJECT_TO_JSVAL(obj));
// link the native object with the javascript object