[gjs/mozjs91: 3/18] Some functions have moved to js/String.h - JS_StringHasLatin1Chars is now JS::StringHasLatin1Chars -




commit 0253aba3b9daff542fbfd1094d6cc71723838a32
Author: Evan Welsh <contact evanwelsh com>
Date:   Sat Aug 7 14:45:11 2021 -0700

    Some functions have moved to js/String.h
    - JS_StringHasLatin1Chars is now JS::StringHasLatin1Chars
    - LinearString utilities in js:: have moved to JS::
    
    See https://bugzilla.mozilla.org/show_bug.cgi?id=1663365

 gjs/byteArray.cpp         |  6 ++++--
 gjs/gjs_pch.hh            |  1 +
 gjs/jsapi-util-string.cpp | 13 +++++++------
 3 files changed, 12 insertions(+), 8 deletions(-)
---
diff --git a/gjs/byteArray.cpp b/gjs/byteArray.cpp
index 05c25034..453e059a 100644
--- a/gjs/byteArray.cpp
+++ b/gjs/byteArray.cpp
@@ -13,11 +13,13 @@
 
 #include <js/ArrayBuffer.h>
 #include <js/CallArgs.h>
+#include <js/CharacterEncoding.h>
 #include <js/GCAPI.h>  // for AutoCheckCannotGC
 #include <js/PropertySpec.h>
 #include <js/RootingAPI.h>
+#include <js/String.h>
 #include <js/TypeDecls.h>
-#include <js/Utility.h>   // for UniqueChars
+#include <js/Utility.h>  // for UniqueChars
 #include <js/experimental/TypedData.h>
 #include <jsapi.h>        // for JS_DefineFunctionById, JS_DefineFun...
 #include <jsfriendapi.h>  // for JS_NewUint8ArrayWithBuffer, GetUint...
@@ -164,7 +166,7 @@ from_string_func(JSContext *context,
             JS::AutoCheckCannotGC nogc;
             size_t len;
 
-            if (JS_StringHasLatin1Chars(str)) {
+            if (JS::StringHasLatin1Chars(str)) {
                 const JS::Latin1Char *chars =
                     JS_GetLatin1StringCharsAndLength(context, nogc, str, &len);
                 if (chars == NULL)
diff --git a/gjs/gjs_pch.hh b/gjs/gjs_pch.hh
index 0e79f1c6..60519829 100644
--- a/gjs/gjs_pch.hh
+++ b/gjs/gjs_pch.hh
@@ -85,6 +85,7 @@
 #include <js/RootingAPI.h>
 #include <js/SavedFrameAPI.h>
 #include <js/SourceText.h>
+#include <js/String.h>
 #include <js/Symbol.h>
 #include <js/TracingAPI.h>
 #include <js/TypeDecls.h>
diff --git a/gjs/jsapi-util-string.cpp b/gjs/jsapi-util-string.cpp
index 3877b135..3119d05a 100644
--- a/gjs/jsapi-util-string.cpp
+++ b/gjs/jsapi-util-string.cpp
@@ -24,6 +24,7 @@
 #include <js/Id.h>     // for JSID_IS_STRING...
 #include <js/Promise.h>
 #include <js/RootingAPI.h>
+#include <js/String.h>
 #include <js/Symbol.h>
 #include <js/TypeDecls.h>
 #include <js/Utility.h>  // for UniqueChars
@@ -209,7 +210,7 @@ gjs_string_get_char16_data(JSContext       *context,
                            char16_t       **data_p,
                            size_t          *len_p)
 {
-    if (JS_StringHasLatin1Chars(str))
+    if (JS::StringHasLatin1Chars(str))
         return from_latin1(context, str, data_p, len_p);
 
     /* From this point on, crash if a GC is triggered while we are using
@@ -255,7 +256,7 @@ gjs_string_to_ucs4(JSContext       *cx,
     size_t len;
     GError *error = NULL;
 
-    if (JS_StringHasLatin1Chars(str))
+    if (JS::StringHasLatin1Chars(str))
         return from_latin1(cx, str, ucs4_string_p, len_p);
 
     /* From this point on, crash if a GC is triggered while we are using
@@ -402,22 +403,22 @@ enum Quotes {
 
 [[nodiscard]] static std::string gjs_debug_linear_string(JSLinearString* str,
                                                          Quotes quotes) {
-    size_t len = js::GetLinearStringLength(str);
+    size_t len = JS::GetLinearStringLength(str);
 
     std::ostringstream out;
     if (quotes == DoubleQuotes)
         out << '"';
 
     JS::AutoCheckCannotGC nogc;
-    if (js::LinearStringHasLatin1Chars(str)) {
-        const JS::Latin1Char *chars = js::GetLatin1LinearStringChars(nogc, str);
+    if (JS::LinearStringHasLatin1Chars(str)) {
+        const JS::Latin1Char* chars = JS::GetLatin1LinearStringChars(nogc, str);
         out << std::string(reinterpret_cast<const char*>(chars), len);
         if (quotes == DoubleQuotes)
             out << '"';
         return out.str();
     }
 
-    const char16_t *chars = js::GetTwoByteLinearStringChars(nogc, str);
+    const char16_t* chars = JS::GetTwoByteLinearStringChars(nogc, str);
     for (size_t ix = 0; ix < len; ix++) {
         char16_t c = chars[ix];
         if (c == '\n')


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]