我把1.3的ScriptingCore.cpp文件中的evalString方法替换到1.2.2了:
bool ScriptingCore::evalString(const char string, JS::MutableHandleValue outVal, const char *filename, JSContext cx, JS::HandleObject global)
{
JSAutoCompartment ac(cx, global);
JS::PersistentRootedScript script(cx);
JS::CompileOptions op(cx);
op.setUTF8(true);
std::string content = string;
bool ok = false;
bool evaluatedOK = false;
if (!content.empty())
{
ok = JS::Compile(cx, global, op, content.c_str(), content.size(), &(script) );
}
if (ok) {
evaluatedOK = JS_ExecuteScript(cx, global, script, outVal);
if (false == evaluatedOK) {
cocos2d::log("Evaluating %s failed (evaluatedOK == JS_FALSE)", content.c_str());
JS_ReportPendingException(cx);
}
}
else {
cocos2d::log("ScriptingCore:: evaluateScript fail: %s", content.c_str());
}
return evaluatedOK;
}
bool ScriptingCore::evalString(const char *string, JS::MutableHandleValue outVal)
{
JS::RootedObject global(_cx, _global->get());
return evalString(string, outVal, nullptr, _cx, global);
}
bool ScriptingCore::evalString(const char *string)
{
JS::RootedValue retVal(_cx);
return evalString(string, &retVal);
}
这三个方法直接替换过去吧?头文件里的相应声明也替换了。
哪几个SpiderMonkey的接口不同呢?
这些改变的接口如果被覆盖,是否会影响别的功能的使用呢?
我调用js就是为了解决游戏内手动暂停,然后切出,再切入时,安卓端的表现是画面暂停,但是有声音的bug,我想切入后是全暂停的状态。