From 2aa75a05d450fd005a8439febee0d010762aab8a Mon Sep 17 00:00:00 2001 From: Itms Date: Fri, 2 Sep 2016 16:34:02 +0000 Subject: [PATCH] SpiderMonkey 38 upgrade: 18/35 Renamed JS_Compile{,UC}Function to JS::CompileFunction. Patch by leper. Addresses https://bugzilla.mozilla.org/show_bug.cgi?id=1089026 This was SVN commit r18672. --- source/gui/IGUIObject.cpp | 12 +++++++----- source/scriptinterface/ScriptInterface.cpp | 9 ++++----- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/source/gui/IGUIObject.cpp b/source/gui/IGUIObject.cpp index e9a48a24a1..b94c564b5d 100644 --- a/source/gui/IGUIObject.cpp +++ b/source/gui/IGUIObject.cpp @@ -414,11 +414,13 @@ void IGUIObject::RegisterScriptHandler(const CStr& Action, const CStr& Code, CGU options.setFileAndLine(CodeName.c_str(), 0); options.setCompileAndGo(true); - JS::RootedFunction func(cx, JS_CompileFunction(cx, globalObj, - buf, paramCount, paramNames, Code.c_str(), Code.length(), options)); - - if (!func) - return; // JS will report an error message + JS::RootedFunction func(cx); + JS::AutoObjectVector emptyScopeChain(cx); + if (!JS::CompileFunction(cx, emptyScopeChain, options, buf, paramCount, paramNames, Code.c_str(), Code.length(), &func)) + { + LOGERROR("RegisterScriptHandler: Failed to compile the script for %s", Action.c_str()); + return; + } JS::RootedObject funcObj(cx, JS_GetFunctionObject(func)); SetScriptHandler(Action, funcObj); diff --git a/source/scriptinterface/ScriptInterface.cpp b/source/scriptinterface/ScriptInterface.cpp index e610b31aa2..9063565d35 100644 --- a/source/scriptinterface/ScriptInterface.cpp +++ b/source/scriptinterface/ScriptInterface.cpp @@ -845,11 +845,10 @@ bool ScriptInterface::LoadScript(const VfsPath& filename, const std::string& cod options.setFileAndLine(filenameStr.c_str(), lineNo); options.setCompileAndGo(true); - JS::RootedFunction func(m->m_cx, - JS_CompileUCFunction(m->m_cx, global, NULL, 0, NULL, - reinterpret_cast(codeUtf16.c_str()), (uint)(codeUtf16.length()), options) - ); - if (!func) + JS::RootedFunction func(m->m_cx); + JS::AutoObjectVector emptyScopeChain(m->m_cx); + if (!JS::CompileFunction(m->m_cx, emptyScopeChain, options, NULL, 0, NULL, + reinterpret_cast(codeUtf16.c_str()), (uint)(codeUtf16.length()), &func)) return false; JS::RootedValue rval(m->m_cx);