update binding-generator sub module & code

This commit is contained in:
XiaoFeng 2015-12-01 18:37:03 +08:00 committed by 肖峰
parent ea077c5141
commit e5d57b4fa2
4 changed files with 18 additions and 12 deletions

View File

@ -119,7 +119,8 @@ int js_module_register()
return 1; return 1;
} }
JSObject* get_jsb_cocos2d_FileUtils_prototype() JS::HandleObject get_jsb_cocos2d_FileUtils_prototype()
{ {
return jsb_cocos2d_FileUtils_prototype; JS::RootedObject fileUtilsProto(ScriptingCore::getInstance()->getGlobalContext(), jsb_cocos2d_FileUtils_prototype);
return fileUtilsProto;
} }

View File

@ -6,7 +6,7 @@
CC_JS_DLL int js_module_register(); CC_JS_DLL int js_module_register();
CC_JS_DLL JSObject* get_jsb_cocos2d_FileUtils_prototype(); CC_JS_DLL JS::HandleObject get_jsb_cocos2d_FileUtils_prototype();
#endif // __JS_TEMPLATE_RUNTIME_FRAMEWORKS_RUNTIME_SRC_CLASSES_JS_MODULE_REGISTER_H__ #endif // __JS_TEMPLATE_RUNTIME_FRAMEWORKS_RUNTIME_SRC_CLASSES_JS_MODULE_REGISTER_H__

@ -1 +1 @@
Subproject commit a0fe326ea3d685d342ba2a61c0be6f9dee83f800 Subproject commit 2f9a05f30839f9733da97ca0fffdc9dd20a71575

View File

@ -50,7 +50,7 @@ bool runtime_FileUtils_addSearchPath(JSContext *cx, uint32_t argc, jsval *vp)
{ {
JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
bool ok = true; bool ok = true;
JSObject *obj = JS_THIS_OBJECT(cx, vp); JS::RootedObject obj(cx, args.thisv().toObjectOrNull());
js_proxy_t *proxy = jsb_get_js_proxy(obj); js_proxy_t *proxy = jsb_get_js_proxy(obj);
cocos2d::FileUtils* cobj = (cocos2d::FileUtils *)(proxy ? proxy->ptr : NULL); cocos2d::FileUtils* cobj = (cocos2d::FileUtils *)(proxy ? proxy->ptr : NULL);
JSB_PRECONDITION2( cobj, cx, false, "cocos2dx_FileUtils_addSearchPath : Invalid Native Object"); JSB_PRECONDITION2( cobj, cx, false, "cocos2dx_FileUtils_addSearchPath : Invalid Native Object");
@ -95,7 +95,7 @@ bool runtime_FileUtils_setSearchPaths(JSContext *cx, uint32_t argc, jsval *vp)
{ {
JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
bool ok = true; bool ok = true;
JSObject *obj = JS_THIS_OBJECT(cx, vp); JS::RootedObject obj(cx, args.thisv().toObjectOrNull());
js_proxy_t *proxy = jsb_get_js_proxy(obj); js_proxy_t *proxy = jsb_get_js_proxy(obj);
cocos2d::FileUtils* cobj = (cocos2d::FileUtils *)(proxy ? proxy->ptr : NULL); cocos2d::FileUtils* cobj = (cocos2d::FileUtils *)(proxy ? proxy->ptr : NULL);
JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_FileUtils_setSearchPaths : Invalid Native Object"); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_FileUtils_setSearchPaths : Invalid Native Object");
@ -144,11 +144,11 @@ void register_FileUtils(JSContext *cx, JS::HandleObject global)
JS_GetProperty(cx, global, "cc", &nsval); JS_GetProperty(cx, global, "cc", &nsval);
if (nsval == JSVAL_VOID) { if (nsval == JSVAL_VOID) {
return; return;
} else { }
else {
ns.set(nsval.toObjectOrNull()); ns.set(nsval.toObjectOrNull());
} }
JSObject* fileUtils = get_jsb_cocos2d_FileUtils_prototype(); JS::RootedObject proto(cx, get_jsb_cocos2d_FileUtils_prototype());
JS::RootedObject proto(cx, fileUtils);
JS_DefineFunction(cx, proto, "addSearchPath", runtime_FileUtils_addSearchPath, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE); JS_DefineFunction(cx, proto, "addSearchPath", runtime_FileUtils_addSearchPath, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE);
JS_DefineFunction(cx, proto, "setSearchPaths", runtime_FileUtils_setSearchPaths, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE); JS_DefineFunction(cx, proto, "setSearchPaths", runtime_FileUtils_setSearchPaths, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE);
} }
@ -231,7 +231,12 @@ void RuntimeJsImpl::onPrecompile(const rapidjson::Document& dArgParse, rapidjson
const rapidjson::Value& objectfiles = dArgParse["modulefiles"]; const rapidjson::Value& objectfiles = dArgParse["modulefiles"];
for (rapidjson::SizeType i = 0; i < objectfiles.Size(); i++) for (rapidjson::SizeType i = 0; i < objectfiles.Size(); i++)
{ {
ScriptingCore::getInstance()->compileScript(objectfiles[i].GetString()); ScriptingCore* sc = ScriptingCore::getInstance();
JSContext* gc = sc->getGlobalContext();
sc->compileScript(objectfiles[i].GetString(),
JS::RootedObject(gc, sc->getGlobalObject()),
gc);
} }
dReplyParse.AddMember("code",0,dReplyParse.GetAllocator()); dReplyParse.AddMember("code",0,dReplyParse.GetAllocator());