[gjs/wip/ptomato/mozjs52: 4/12] js: Report warnings and errors with encoding



commit c76d23d8db9297d2ef2cc500a807846a28879830
Author: Philip Chimento <philip chimento gmail com>
Date:   Tue May 2 22:02:51 2017 -0700

    js: Report warnings and errors with encoding
    
    JS_ReportWarning() and JS_ReportError() are changed in SpiderMonkey 52 to
    specify their character encodings. Therefore, we use JS_ReportWarningUTF8()
    and JS_ReportErrorUTF8(), except in a few cases where we use the ASCII
    version because the argument is a string literal with only ASCII characters
    and no format codes.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=784196

 gi/function.cpp          |    6 +++---
 gi/repo.cpp              |    2 +-
 gjs/jsapi-util-error.cpp |    8 +++-----
 3 files changed, 7 insertions(+), 9 deletions(-)
---
diff --git a/gi/function.cpp b/gi/function.cpp
index 70306cd..1a89821 100644
--- a/gi/function.cpp
+++ b/gi/function.cpp
@@ -769,9 +769,9 @@ gjs_invoke_c_function(JSContext                             *context,
      */
     if (args.length() > function->expected_js_argc) {
         GjsAutoChar name = format_function_name(function, is_method);
-        JS_ReportWarning(context, "Too many arguments to %s: expected %d, "
-                         "got %" G_GSIZE_FORMAT, name.get(),
-                         function->expected_js_argc, args.length());
+        JS_ReportWarningUTF8(context, "Too many arguments to %s: expected %d, "
+                             "got %" G_GSIZE_FORMAT, name.get(),
+                             function->expected_js_argc, args.length());
     } else if (args.length() < function->expected_js_argc) {
         GjsAutoChar name = format_function_name(function, is_method);
         gjs_throw(context, "Too few arguments to %s: "
diff --git a/gi/repo.cpp b/gi/repo.cpp
index abe4ce9..b5fd45d 100644
--- a/gi/repo.cpp
+++ b/gi/repo.cpp
@@ -105,7 +105,7 @@ resolve_namespace_object(JSContext       *context,
                                                 "versions available; use "
                                                 "imports.gi.versions to pick one",
                                                 ns_name, nversions);
-        JS_ReportWarning(context, warn_text);
+        JS_ReportWarningUTF8(context, "%s", warn_text.get());
     }
     g_list_free_full(versions, g_free);
 
diff --git a/gjs/jsapi-util-error.cpp b/gjs/jsapi-util-error.cpp
index 56d3ec7..88ab949 100644
--- a/gjs/jsapi-util-error.cpp
+++ b/gjs/jsapi-util-error.cpp
@@ -83,13 +83,13 @@ gjs_throw_valist(JSContext       *context,
     result = false;
 
     if (!gjs_string_from_utf8(context, s, -1, error_args[0])) {
-        JS_ReportError(context, "Failed to copy exception string");
+        JS_ReportErrorASCII(context, "Failed to copy exception string");
         goto out;
     }
 
     if (!JS_GetProperty(context, global, error_class, &v_constructor) ||
         !v_constructor.isObject()) {
-        JS_ReportError(context, "??? Missing Error constructor in global object?");
+        JS_ReportErrorASCII(context, "??? Missing Error constructor in global object?");
         goto out;
     }
 
@@ -119,9 +119,7 @@ gjs_throw_valist(JSContext       *context,
         /* try just reporting it to error handler? should not
          * happen though pretty much
          */
-        JS_ReportError(context,
-                       "Failed to throw exception '%s'",
-                       s);
+        JS_ReportErrorUTF8(context, "Failed to throw exception '%s'", s);
     }
     g_free(s);
 


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