Improve JS bindings (#16751)

* Fix tests for v3.12 web

* Improve scheduler wrapper

* Update web engine ref

* Fix leak: js_remove_object_reference can not remove non binding objects

* Fix ScriptingCore::evalString

* Add missed `__cppCreated` for JS create objects

* Fix manifest path issue
This commit is contained in:
pandamicro 2016-10-28 09:29:56 +08:00 committed by minggo
parent cfcbbaa6e5
commit e4170a7b02
3 changed files with 5 additions and 10 deletions

View File

@ -521,9 +521,6 @@ bool ScriptingCore::evalString(const char *string, JS::MutableHandleValue outVal
{
JSAutoCompartment ac(cx, global);
JS::PersistentRootedScript script(cx);
if (script == nullptr) {
return false;
}
JS::CompileOptions op(cx);
op.setUTF8(true);
@ -2374,6 +2371,10 @@ JSObject* jsb_get_or_create_weak_jsobject(JSContext *cx, void *native, js_type_c
JS::RootedObject jsObj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent));
proxy = jsb_new_proxy(native, jsObj);
JS::RootedObject flag(cx, JS_NewObject(cx, nullptr, JS::NullPtr(), JS::NullPtr()));
JS::RootedValue flagVal(cx, OBJECT_TO_JSVAL(flag));
JS_SetProperty(cx, jsObj, "__cppCreated", flagVal);
#if ! CC_ENABLE_GC_FOR_NATIVE_OBJECTS
JS::AddNamedObjectRoot(cx, &proxy->obj, debug);
#else

View File

@ -625,12 +625,6 @@ void js_remove_object_reference(JS::HandleValue owner, JS::HandleValue target)
JSContext *cx = engine->getGlobalContext();
JS::RootedObject ownerObj(cx, owner.toObjectOrNull());
JS::RootedObject targetObj(cx, target.toObjectOrNull());
js_proxy_t *pOwner = jsb_get_js_proxy(ownerObj);
js_proxy_t *pTarget = jsb_get_js_proxy(targetObj);
if (!pOwner || !pTarget)
{
return;
}
JS::RootedObject global(cx, engine->getGlobalObject());
JS::RootedObject jsbObj(cx);

View File

@ -5,7 +5,7 @@
USING_NS_CC;
USING_NS_CC_EXT;
const char* sceneManifests[] = {"AMTestScene1/project.manifest", "AMTestScene2/project.manifest", "AMTestScene3/project.manifest"};
const char* sceneManifests[] = {"Manifests/AMTestScene1/project.manifest", "Manifests/AMTestScene2/project.manifest", "Manifests/AMTestScene3/project.manifest"};
const char* storagePaths[] = {"CppTests/AssetsManagerExTest/scene1/", "CppTests/AssetsManagerExTest/scene2/", "CppTests/AssetsManagerExTest/scene3"};
const char* backgroundPaths[] = {"Images/assetMgrBackground1.jpg", "Images/assetMgrBackground2.png", "Images/assetMgrBackground3.png"};