[gjs: 2/12] internal: Switch to compiling UTF-8 script directly
- From: Philip Chimento <pchimento src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs: 2/12] internal: Switch to compiling UTF-8 script directly
- Date: Tue, 10 Aug 2021 04:08:01 +0000 (UTC)
commit f1b04e060d7e879c1f994c19081b9093cfa0c6fb
Author: Philip Chimento <philip chimento gmail com>
Date: Sun Jul 4 16:32:57 2021 -0700
internal: Switch to compiling UTF-8 script directly
There is a Mozilla bug which prevents us from doing this elsewhere
(https://bugzilla.mozilla.org/show_bug.cgi?id=1404784), but it doesn't
apply here because we don't do the evaluation with an extra object on the
environment chain.
gjs/internal.cpp | 19 +++++--------------
1 file changed, 5 insertions(+), 14 deletions(-)
---
diff --git a/gjs/internal.cpp b/gjs/internal.cpp
index fea6e71e..845f2641 100644
--- a/gjs/internal.cpp
+++ b/gjs/internal.cpp
@@ -26,8 +26,6 @@
#include <stddef.h> // for size_t
#include <sys/types.h> // for ssize_t
-#include <codecvt> // for codecvt_utf8_utf16
-#include <locale> // for wstring_convert
#include <memory> // for unique_ptr
#include <string> // for u16string
#include <vector>
@@ -72,21 +70,14 @@ bool gjs_load_internal_module(JSContext* cx, const char* identifier) {
gjs_debug(GJS_DEBUG_IMPORTER, "Loading internal module '%s' (%s)",
identifier, full_path.get());
- char* script;
+ char* script_unowned;
size_t script_len;
-
- if (!gjs_load_internal_source(cx, full_path, &script, &script_len))
+ if (!gjs_load_internal_source(cx, full_path, &script_unowned, &script_len))
return false;
- std::u16string utf16_string = gjs_utf8_script_to_utf16(script, script_len);
- g_free(script);
-
- // COMPAT: This could use JS::SourceText<mozilla::Utf8Unit> directly,
- // but that messes up code coverage. See bug
- // https://bugzilla.mozilla.org/show_bug.cgi?id=1404784
- JS::SourceText<char16_t> buf;
- if (!buf.init(cx, utf16_string.c_str(), utf16_string.size(),
- JS::SourceOwnership::Borrowed))
+ GjsAutoChar script = script_unowned;
+ JS::SourceText<mozilla::Utf8Unit> buf;
+ if (!buf.init(cx, script.get(), script_len, JS::SourceOwnership::Borrowed))
return false;
JS::CompileOptions options(cx);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]