[gjs] importer: Clean up extra roots



commit 397251edefdc37d2dc8126d0abd663d76e2bc365
Author: Philip Chimento <philip chimento gmail com>
Date:   Tue Jan 24 00:18:33 2017 -0800

    importer: Clean up extra roots
    
    This function added extra roots where they weren't needed; we can clean
    it up by taking a JS::HandleObject.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=777205

 gjs/context.cpp  |    3 +--
 gjs/importer.cpp |   16 +++++-----------
 gjs/importer.h   |    6 ++++--
 3 files changed, 10 insertions(+), 15 deletions(-)
---
diff --git a/gjs/context.cpp b/gjs/context.cpp
index 9ea53f2..085f76c 100644
--- a/gjs/context.cpp
+++ b/gjs/context.cpp
@@ -528,8 +528,7 @@ gjs_context_constructed(GObject *object)
     /* Now copy the global root importer (which we just created,
      * if it didn't exist) to our global object
      */
-    if (!gjs_define_root_importer(js_context->context,
-                                  js_context->global))
+    if (!gjs_define_root_importer(js_context->context, global))
         g_error("Failed to point 'imports' property at root importer");
 
     /* FIXME: We should define the Promise object before any imports, in case
diff --git a/gjs/importer.cpp b/gjs/importer.cpp
index 1ba4a85..643b529 100644
--- a/gjs/importer.cpp
+++ b/gjs/importer.cpp
@@ -1194,16 +1194,10 @@ gjs_define_root_importer_object(JSContext        *context,
 }
 
 bool
-gjs_define_root_importer(JSContext   *context,
-                         JSObject    *in_object)
+gjs_define_root_importer(JSContext       *cx,
+                         JS::HandleObject in_object)
 {
-    JS::RootedValue importer(JS_GetRuntime(context),
-                             gjs_get_global_slot(context, GJS_GLOBAL_SLOT_IMPORTS));
-    JS::RootedObject rooted_in_object(JS_GetRuntime(context),
-                                      in_object);
-    JS::RootedObject rooted_importer(JS_GetRuntime(context),
-                                     &importer.toObject());
-    return gjs_define_root_importer_object(context,
-                                           rooted_in_object,
-                                           rooted_importer);
+    JS::Value importer = gjs_get_global_slot(cx, GJS_GLOBAL_SLOT_IMPORTS);
+    JS::RootedObject rooted_importer(cx, &importer.toObject());
+    return gjs_define_root_importer_object(cx, in_object, rooted_importer);
 }
diff --git a/gjs/importer.h b/gjs/importer.h
index fd0475d..55babb2 100644
--- a/gjs/importer.h
+++ b/gjs/importer.h
@@ -33,8 +33,10 @@ G_BEGIN_DECLS
 bool      gjs_create_root_importer (JSContext   *context,
                                     const char **initial_search_path,
                                     bool         add_standard_search_path);
-bool      gjs_define_root_importer (JSContext   *context,
-                                    JSObject    *in_object);
+
+bool gjs_define_root_importer(JSContext       *cx,
+                              JS::HandleObject in_object);
+
 bool      gjs_define_root_importer_object(JSContext        *context,
                                           JS::HandleObject  in_object,
                                           JS::HandleObject  root_importer);


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