From 6a194ae2b4479fefb803fc38a2ccad3ebc766440 Mon Sep 17 00:00:00 2001 From: Kalev Lember Date: Tue, 15 May 2018 21:14:16 +0200 Subject: [PATCH] Revert "js: Convert scripts to UTF-16 before evaluating" RHEL 7 libstdc++ 4.8 doesn't have header that gjs needs. In order to work this around, this commit reverts the patch that introduced the requirement. This reverts commit bc36f39ff09629e1b4c5c54f334028d2b2f8c545. --- gjs/jsapi-util.cpp | 15 ++++++--------- gjs/module.cpp | 15 ++++++--------- 2 files changed, 12 insertions(+), 18 deletions(-) diff --git a/gjs/jsapi-util.cpp b/gjs/jsapi-util.cpp index 322a41b..6033dff 100644 --- a/gjs/jsapi-util.cpp +++ b/gjs/jsapi-util.cpp @@ -24,9 +24,6 @@ #include -#include -#include - #include #include #include @@ -851,19 +848,19 @@ gjs_eval_with_scope(JSContext *context, eval_obj = JS_NewPlainObject(context); JS::CompileOptions options(context); - options.setFileAndLine(filename, start_line_number) + options.setUTF8(true) + .setFileAndLine(filename, start_line_number) .setSourceIsLazy(true); - std::wstring_convert, char16_t> convert; - std::u16string utf16_string = convert.from_bytes(script); - JS::SourceBufferHolder buf(utf16_string.c_str(), utf16_string.size(), - JS::SourceBufferHolder::NoOwnership); + JS::RootedScript compiled_script(context); + if (!JS::Compile(context, options, script, real_len, &compiled_script)) + return false; JS::AutoObjectVector scope_chain(context); if (!scope_chain.append(eval_obj)) g_error("Unable to append to vector"); - if (!JS::Evaluate(context, scope_chain, options, buf, retval)) + if (!JS_ExecuteScript(context, scope_chain, compiled_script, retval)) return false; gjs_schedule_gc_if_needed(context); diff --git a/gjs/module.cpp b/gjs/module.cpp index cc6657a..4b8bd40 100644 --- a/gjs/module.cpp +++ b/gjs/module.cpp @@ -21,9 +21,6 @@ * IN THE SOFTWARE. */ -#include -#include - #include #include "jsapi-util.h" @@ -89,20 +86,20 @@ class GjsModule { int line_number) { JS::CompileOptions options(cx); - options.setFileAndLine(filename, line_number) + options.setUTF8(true) + .setFileAndLine(filename, line_number) .setSourceIsLazy(true); - std::wstring_convert, char16_t> convert; - std::u16string utf16_string = convert.from_bytes(script); - JS::SourceBufferHolder buf(utf16_string.c_str(), utf16_string.size(), - JS::SourceBufferHolder::NoOwnership); + JS::RootedScript compiled_script(cx); + if (!JS::Compile(cx, options, script, script_len, &compiled_script)) + return false; JS::AutoObjectVector scope_chain(cx); if (!scope_chain.append(module)) g_error("Unable to append to vector"); JS::RootedValue ignored_retval(cx); - if (!JS::Evaluate(cx, scope_chain, options, buf, &ignored_retval)) + if (!JS_ExecuteScript(cx, scope_chain, compiled_script, &ignored_retval)) return false; gjs_schedule_gc_if_needed(cx); -- 1.8.3.1