[gjs/wip/ptomato/mozjs31: 3/22] js: Leftover rooting changes



commit fd77a221ce2117e3b323e74394e0abc62ce72546
Author: Philip Chimento <philip endlessm com>
Date:   Mon Nov 7 12:08:33 2016 -0800

    js: Leftover rooting changes
    
    Fixing some stragglers that were rooted only on my post-mozjs31-switch
    branch.

 gjs/context.cpp     |   12 +++++-------
 gjs/coverage.cpp    |    5 ++---
 gjs/importer.cpp    |    6 +++---
 gjs/jsapi-util.cpp  |    5 ++---
 modules/console.cpp |    2 +-
 5 files changed, 13 insertions(+), 17 deletions(-)
---
diff --git a/gjs/context.cpp b/gjs/context.cpp
index 87d9960..6bf1536 100644
--- a/gjs/context.cpp
+++ b/gjs/context.cpp
@@ -110,7 +110,6 @@ gjs_log(JSContext *context,
     JS::CallArgs argv = JS::CallArgsFromVp (argc, vp);
     char *s;
     JSExceptionState *exc_state;
-    JSString *jstr;
 
     if (argc != 1) {
         gjs_throw(context, "Must pass a single argument to log()");
@@ -122,9 +121,9 @@ gjs_log(JSContext *context,
     /* JS_ValueToString might throw, in which we will only
      *log that the value could be converted to string */
     exc_state = JS_SaveExceptionState(context);
-    jstr = JS_ValueToString(context, argv[0]);
+    JS::RootedString jstr(context, JS_ValueToString(context, argv[0]));
     if (jstr != NULL)
-        argv[0] = JS::StringValue(jstr);    // GC root
+        argv[0].setString(jstr);  // GC root
     JS_RestoreExceptionState(context, exc_state);
 
     if (jstr == NULL) {
@@ -169,7 +168,7 @@ gjs_log_error(JSContext *context,
         exc_state = JS_SaveExceptionState(context);
         jstr = JS_ValueToString(context, argv[1]);
         if (jstr != NULL)
-            argv[1] = JS::StringValue(jstr);    // GC root
+            argv[1].setString(jstr);  // GC root
         JS_RestoreExceptionState(context, exc_state);
     }
 
@@ -195,15 +194,14 @@ gjs_print_parse_args(JSContext *context,
     str = g_string_new("");
     for (n = 0; n < argv.length(); ++n) {
         JSExceptionState *exc_state;
-        JSString *jstr;
 
         /* JS_ValueToString might throw, in which we will only
          * log that the value could be converted to string */
         exc_state = JS_SaveExceptionState(context);
 
-        jstr = JS_ValueToString(context, argv[n]);
+        JS::RootedString jstr(context, JS_ValueToString(context, argv[n]));
         if (jstr != NULL)
-            argv[n] = JS::StringValue(jstr); // GC root
+            argv[n].setString(jstr); // GC root
 
         JS_RestoreExceptionState(context, exc_state);
 
diff --git a/gjs/coverage.cpp b/gjs/coverage.cpp
index f016137..19dd1a5 100644
--- a/gjs/coverage.cpp
+++ b/gjs/coverage.cpp
@@ -1314,7 +1314,6 @@ coverage_log(JSContext *context,
     JS::CallArgs argv = JS::CallArgsFromVp (argc, vp);
     char *s;
     JSExceptionState *exc_state;
-    JSString *jstr;
 
     if (argc != 1) {
         gjs_throw(context, "Must pass a single argument to log()");
@@ -1332,9 +1331,9 @@ coverage_log(JSContext *context,
     /* JS_ValueToString might throw, in which we will only
      *log that the value could be converted to string */
     exc_state = JS_SaveExceptionState(context);
-    jstr = JS_ValueToString(context, argv[0]);
+    JS::RootedString jstr(context, JS_ValueToString(context, argv[0]));
     if (jstr != NULL)
-        argv[0] = JS::StringValue(jstr);    // GC root
+        argv[0].setString(jstr);  // GC root
     JS_RestoreExceptionState(context, exc_state);
 
     if (jstr == NULL) {
diff --git a/gjs/importer.cpp b/gjs/importer.cpp
index 1b7f9cc..12323e3 100644
--- a/gjs/importer.cpp
+++ b/gjs/importer.cpp
@@ -153,9 +153,9 @@ define_import(JSContext       *context,
  * we do this after the import succesfully completes.
  */
 static bool
-seal_import(JSContext  *context,
-            JSObject   *obj,
-            const char *name)
+seal_import(JSContext       *context,
+            JS::HandleObject obj,
+            const char      *name)
 {
     JSBool found;
     unsigned attrs;
diff --git a/gjs/jsapi-util.cpp b/gjs/jsapi-util.cpp
index c0a5794..81f97b9 100644
--- a/gjs/jsapi-util.cpp
+++ b/gjs/jsapi-util.cpp
@@ -437,7 +437,6 @@ char*
 gjs_value_debug_string(JSContext      *context,
                        JS::HandleValue value)
 {
-    JSString *str;
     char *bytes;
     char *debugstr;
 
@@ -448,7 +447,7 @@ gjs_value_debug_string(JSContext      *context,
 
     JS_BeginRequest(context);
 
-    str = JS_ValueToString(context, value);
+    JS::RootedString str(context, JS_ValueToString(context, value));
 
     if (str == NULL) {
         if (value.isObject()) {
@@ -497,7 +496,7 @@ utf8_exception_from_non_gerror_value(JSContext      *cx,
                                      JS::HandleValue exc)
 {
     char *utf8_exception = NULL;
-    JSString *exc_str = JS_ValueToString(cx, exc);
+    JS::RootedString exc_str(cx, JS_ValueToString(cx, exc));
     if (exc_str != NULL)
         gjs_string_to_utf8(cx, JS::StringValue(exc_str), &utf8_exception);
     return utf8_exception;
diff --git a/modules/console.cpp b/modules/console.cpp
index f183269..0375eda 100644
--- a/modules/console.cpp
+++ b/modules/console.cpp
@@ -161,7 +161,7 @@ gjs_console_interact(JSContext *context,
     GJS_GET_THIS(context, argc, vp, argv, object);
     bool eof = false;
     JS::RootedValue result(context);
-    JSString *str;
+    JS::RootedString str(context);
     GString *buffer = NULL;
     char *temp_buf = NULL;
     int lineno;


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