[gjs/wip/ptomato/mozjs45prep: 13/32] js: Don't pass global object to JS_NewObject functions



commit 626db194cc0ebe8b7109bfc16ea241f6e66ceaee
Author: Philip Chimento <philip chimento gmail com>
Date:   Sat Apr 15 23:50:14 2017 -0700

    js: Don't pass global object to JS_NewObject functions
    
    This is optional, and will become disallowed in SpiderMonkey 45. No
    change in functionality, because leaving it out already causes JS to get
    the global object internally.

 gi/boxed.cpp                |    6 ++----
 gi/fundamental.cpp          |    4 +---
 gi/gerror.cpp               |    3 +--
 gi/object.cpp               |    5 +----
 gi/param.cpp                |    3 +--
 gi/union.cpp                |    3 +--
 gjs/jsapi-dynamic-class.cpp |    5 ++---
 7 files changed, 9 insertions(+), 20 deletions(-)
---
diff --git a/gi/boxed.cpp b/gi/boxed.cpp
index 466127f..e6500d3 100644
--- a/gi/boxed.cpp
+++ b/gi/boxed.cpp
@@ -564,7 +564,6 @@ get_nested_interface_object(JSContext             *context,
         return false;
     }
 
-    JS::RootedObject global(context, gjs_get_import_global(context));
     JS::RootedObject proto(context,
                            gjs_lookup_generic_prototype(context,
                                                         (GIBoxedInfo*) interface_info));
@@ -572,7 +571,7 @@ get_nested_interface_object(JSContext             *context,
 
     offset = g_field_info_get_offset (field_info);
 
-    obj = JS_NewObjectWithGivenProto(context, JS_GetClass(proto), proto, global);
+    obj = JS_NewObjectWithGivenProto(context, JS_GetClass(proto), proto);
 
     if (obj == NULL)
         return false;
@@ -1222,11 +1221,10 @@ gjs_boxed_from_c_struct(JSContext             *context,
                       "Wrapping struct %s %p with JSObject",
                       g_base_info_get_name((GIBaseInfo *)info), gboxed);
 
-    JS::RootedObject global(context, gjs_get_import_global(context));
     JS::RootedObject proto(context, gjs_lookup_generic_prototype(context, info));
     proto_priv = priv_from_js(context, proto);
 
-    obj = JS_NewObjectWithGivenProto(context, JS_GetClass(proto), proto, global);
+    obj = JS_NewObjectWithGivenProto(context, JS_GetClass(proto), proto);
 
     GJS_INC_COUNTER(boxed);
     priv = g_slice_new0(Boxed);
diff --git a/gi/fundamental.cpp b/gi/fundamental.cpp
index df3837f..2242bc8 100644
--- a/gi/fundamental.cpp
+++ b/gi/fundamental.cpp
@@ -778,9 +778,7 @@ gjs_object_from_g_fundamental(JSContext    *context,
     if (!proto)
         return NULL;
 
-    JS::RootedObject global(context, gjs_get_import_global(context));
-    object = JS_NewObjectWithGivenProto(context, JS_GetClass(proto), proto,
-                                        global);
+    object = JS_NewObjectWithGivenProto(context, JS_GetClass(proto), proto);
 
     if (object == NULL)
         goto out;
diff --git a/gi/gerror.cpp b/gi/gerror.cpp
index b8035c0..9d4977f 100644
--- a/gi/gerror.cpp
+++ b/gi/gerror.cpp
@@ -445,11 +445,10 @@ gjs_error_from_gerror(JSContext             *context,
                       g_base_info_get_name((GIBaseInfo *)info));
 
     JS::RootedObject proto(context, gjs_lookup_generic_prototype(context, info));
-    JS::RootedObject global(context, gjs_get_import_global(context));
     proto_priv = priv_from_js(context, proto);
 
     JS::RootedObject obj(context,
-        JS_NewObjectWithGivenProto(context, JS_GetClass(proto), proto, global));
+        JS_NewObjectWithGivenProto(context, JS_GetClass(proto), proto));
 
     GJS_INC_COUNTER(gerror);
     priv = g_slice_new0(Error);
diff --git a/gi/object.cpp b/gi/object.cpp
index 4b5ddcf..2f353a0 100644
--- a/gi/object.cpp
+++ b/gi/object.cpp
@@ -2035,11 +2035,8 @@ gjs_object_from_g_object(JSContext    *context,
         if (!proto)
             return nullptr;
 
-        JS::RootedObject global(context, gjs_get_import_global(context));
-
         JS::RootedObject obj(context,
-            JS_NewObjectWithGivenProto(context, JS_GetClass(proto), proto,
-                                       global));
+            JS_NewObjectWithGivenProto(context, JS_GetClass(proto), proto));
         if (obj == NULL)
             return nullptr;
 
diff --git a/gi/param.cpp b/gi/param.cpp
index 2dec2c8..c38eebb 100644
--- a/gi/param.cpp
+++ b/gi/param.cpp
@@ -260,9 +260,8 @@ gjs_param_from_g_param(JSContext    *context,
               g_type_name(gparam->owner_type));
 
     JS::RootedObject proto(context, gjs_lookup_param_prototype(context));
-    JS::RootedObject global(context, gjs_get_import_global(context));
 
-    obj = JS_NewObjectWithGivenProto(context, JS_GetClass(proto), proto, global);
+    obj = JS_NewObjectWithGivenProto(context, JS_GetClass(proto), proto);
 
     GJS_INC_COUNTER(param);
     priv = g_slice_new0(Param);
diff --git a/gi/union.cpp b/gi/union.cpp
index 35c4d8f..c4ef103 100644
--- a/gi/union.cpp
+++ b/gi/union.cpp
@@ -405,9 +405,8 @@ gjs_union_from_c_union(JSContext    *context,
 
     JS::RootedObject proto(context,
         gjs_lookup_generic_prototype(context, (GIUnionInfo*) info));
-    JS::RootedObject global(context, gjs_get_import_global(context));
 
-    obj = JS_NewObjectWithGivenProto(context, JS_GetClass(proto), proto, global);
+    obj = JS_NewObjectWithGivenProto(context, JS_GetClass(proto), proto);
 
     GJS_INC_COUNTER(boxed);
     priv = g_slice_new0(Union);
diff --git a/gjs/jsapi-dynamic-class.cpp b/gjs/jsapi-dynamic-class.cpp
index 7203fb2..3d70222 100644
--- a/gjs/jsapi-dynamic-class.cpp
+++ b/gjs/jsapi-dynamic-class.cpp
@@ -79,8 +79,7 @@ gjs_init_class_dynamic(JSContext              *context,
     */
 
     if (parent_proto) {
-        prototype.set(JS_NewObjectWithGivenProto(context, clasp,
-                                                 parent_proto, global));
+        prototype.set(JS_NewObjectWithGivenProto(context, clasp, parent_proto));
     } else {
         /* JS_NewObject will try to search for clasp prototype in the
          * global object, which is wrong, but it's not a problem because
@@ -88,7 +87,7 @@ gjs_init_class_dynamic(JSContext              *context,
          * constructor is not found (and it won't be found, because we
          * never call JS_InitClass).
          */
-        prototype.set(JS_NewObject(context, clasp, global));
+        prototype.set(JS_NewObject(context, clasp));
     }
     if (!prototype)
         goto out;


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