[gjs/wip/ptomato/mozjs38: 10/23] js: Adapt to new JS_NewObject() API



commit fcaba2d76f718a4d0205cc5c4b08b5fc88de93fe
Author: Philip Chimento <philip chimento gmail com>
Date:   Wed Jan 11 22:45:20 2017 -0800

    js: Adapt to new JS_NewObject() API
    
    JS_NewObject() does not take a prototype parameter anymore, that has been
    split into a different function, JS_NewObjectWithGivenProto(). Passing
    JS::NullPtr() as prototype means "Look in the global object for a
    prototype that matches the given class" and that is now the only possible
    behaviour for JS_NewObject().
    
    Both JS_NewObject() and JS_NewObjectWithGivenProto() have had their
    global object parameter made optional, so in the cases where we were
    passing JS::NullPtr() there, then we simply leave it out.

 gi/arg.cpp                        |    3 +--
 gi/enumeration.cpp                |    3 +--
 gi/function.cpp                   |    2 +-
 gi/keep-alive.cpp                 |    2 +-
 gi/ns.cpp                         |    3 +--
 gi/object.cpp                     |    5 ++---
 gi/repo.cpp                       |    6 +++---
 gjs/byteArray.cpp                 |    6 +++---
 gjs/importer.cpp                  |   12 +++---------
 gjs/jsapi-dynamic-class.cpp       |    2 +-
 gjs/jsapi-util.cpp                |    2 +-
 modules/cairo-context.cpp         |    2 +-
 modules/cairo-image-surface.cpp   |    4 ++--
 modules/cairo-linear-gradient.cpp |    2 +-
 modules/cairo-path.cpp            |    2 +-
 modules/cairo-pdf-surface.cpp     |    2 +-
 modules/cairo-ps-surface.cpp      |    2 +-
 modules/cairo-radial-gradient.cpp |    2 +-
 modules/cairo-region.cpp          |    5 ++---
 modules/cairo-solid-pattern.cpp   |    2 +-
 modules/cairo-surface-pattern.cpp |    2 +-
 modules/cairo-surface.cpp         |    2 +-
 modules/cairo-svg-surface.cpp     |    2 +-
 modules/cairo.cpp                 |    2 +-
 modules/console.cpp               |    2 +-
 modules/system.cpp                |    2 +-
 26 files changed, 35 insertions(+), 46 deletions(-)
---
diff --git a/gi/arg.cpp b/gi/arg.cpp
index d623f56..d6f9c3c 100644
--- a/gi/arg.cpp
+++ b/gi/arg.cpp
@@ -2529,8 +2529,7 @@ gjs_object_from_g_hash (JSContext             *context,
         return true;
     }
 
-    JS::RootedObject obj(context,
-        JS_NewObject(context, NULL, JS::NullPtr(), JS::NullPtr()));
+    JS::RootedObject obj(context, JS_NewObject(context, NULL));
     if (obj == NULL)
         return false;
 
diff --git a/gi/enumeration.cpp b/gi/enumeration.cpp
index d73622e..9d0eeb4 100644
--- a/gi/enumeration.cpp
+++ b/gi/enumeration.cpp
@@ -165,8 +165,7 @@ gjs_define_enumeration(JSContext       *context,
 
     enum_name = g_base_info_get_name( (GIBaseInfo*) info);
 
-    JS::RootedObject enum_obj(context, JS_NewObject(context, NULL, JS::NullPtr(),
-                                                    global));
+    JS::RootedObject enum_obj(context, JS_NewObject(context, NULL, global));
     if (enum_obj == NULL) {
         g_error("Could not create enumeration %s.%s",
                        g_base_info_get_namespace( (GIBaseInfo*) info),
diff --git a/gi/function.cpp b/gi/function.cpp
index be62252..c01dd29 100644
--- a/gi/function.cpp
+++ b/gi/function.cpp
@@ -1689,7 +1689,7 @@ function_new(JSContext      *context,
     }
 
     JS::RootedObject function(context,
-        JS_NewObject(context, &gjs_function_class, JS::NullPtr(), global));
+        JS_NewObject(context, &gjs_function_class, global));
     if (function == NULL) {
         gjs_debug(GJS_DEBUG_GFUNCTION, "Failed to construct function");
         return NULL;
diff --git a/gi/keep-alive.cpp b/gi/keep-alive.cpp
index 8adbabc..d9e7fa5 100644
--- a/gi/keep-alive.cpp
+++ b/gi/keep-alive.cpp
@@ -236,7 +236,7 @@ gjs_keep_alive_new(JSContext *context)
               context, global.get());
 
     JS::RootedObject keep_alive(context,
-        JS_NewObject(context, &gjs_keep_alive_class, JS::NullPtr(), global));
+        JS_NewObject(context, &gjs_keep_alive_class, global));
     if (keep_alive == NULL) {
         gjs_log_exception(context);
         g_error("Failed to create keep_alive object");
diff --git a/gi/ns.cpp b/gi/ns.cpp
index 933e818..6af1138 100644
--- a/gi/ns.cpp
+++ b/gi/ns.cpp
@@ -222,8 +222,7 @@ ns_new(JSContext    *context,
                   gjs_ns_class.name, prototype);
     }
 
-    JS::RootedObject ns(context, JS_NewObject(context, &gjs_ns_class,
-                                              JS::NullPtr(), global));
+    JS::RootedObject ns(context, JS_NewObject(context, &gjs_ns_class, global));
     if (ns == NULL)
         g_error("No memory to create ns object");
 
diff --git a/gi/object.cpp b/gi/object.cpp
index 3806ce4..ea14101 100644
--- a/gi/object.cpp
+++ b/gi/object.cpp
@@ -2566,8 +2566,7 @@ gjs_object_constructor (GType                  type,
     if (n_construct_properties) {
         guint i;
 
-        JS::RootedObject props_hash(context,
-            JS_NewObject(context, NULL, JS::NullPtr(), JS::NullPtr()));
+        JS::RootedObject props_hash(context, JS_NewObject(context, NULL));
 
         for (i = 0; i < n_construct_properties; i++)
             jsobj_set_gproperty(context, props_hash,
@@ -3148,7 +3147,7 @@ bool
 gjs_define_private_gi_stuff(JSContext              *cx,
                             JS::MutableHandleObject module)
 {
-    module.set(JS_NewObject(cx, NULL, JS::NullPtr(), JS::NullPtr()));
+    module.set(JS_NewObject(cx, NULL));
     return JS_DefineFunctions(cx, module, &module_funcs[0]);
 }
 
diff --git a/gi/repo.cpp b/gi/repo.cpp
index 7b8a1ed..97cd44f 100644
--- a/gi/repo.cpp
+++ b/gi/repo.cpp
@@ -274,7 +274,7 @@ repo_new(JSContext *context)
     }
 
     JS::RootedObject repo(context,
-        JS_NewObject(context, &gjs_repo_class, JS::NullPtr(), global));
+        JS_NewObject(context, &gjs_repo_class, global));
     if (repo == NULL) {
         gjs_throw(context, "No memory to create repo object");
         return NULL;
@@ -290,7 +290,7 @@ repo_new(JSContext *context)
     gjs_debug_lifecycle(GJS_DEBUG_GREPO,
                         "repo constructor, obj %p priv %p", repo.get(), priv);
 
-    versions = JS_NewObject(context, NULL, JS::NullPtr(), global);
+    versions = JS_NewObject(context, NULL, global);
     JS::RootedId versions_name(context,
         gjs_context_get_const_string(context, GJS_STRING_GI_VERSIONS));
     JS_DefinePropertyById(context, repo,
@@ -299,7 +299,7 @@ repo_new(JSContext *context)
                           NULL, NULL,
                           JSPROP_PERMANENT);
 
-    private_ns = JS_NewObject(context, NULL, JS::NullPtr(), global);
+    private_ns = JS_NewObject(context, NULL, global);
     JS::RootedId private_ns_name(context,
         gjs_context_get_const_string(context, GJS_STRING_PRIVATE_NS_MARKER));
     JS_DefinePropertyById(context, repo,
diff --git a/gjs/byteArray.cpp b/gjs/byteArray.cpp
index 675202e..f416ffc 100644
--- a/gjs/byteArray.cpp
+++ b/gjs/byteArray.cpp
@@ -532,7 +532,7 @@ byte_array_new(JSContext *context)
 
     JS::RootedObject proto(context, byte_array_get_prototype(context));
     JS::RootedObject array(context,
-        JS_NewObjectWithGivenProto(context, &gjs_byte_array_class, proto, JS::NullPtr()));
+        JS_NewObjectWithGivenProto(context, &gjs_byte_array_class, proto));
 
     priv = g_slice_new0(ByteArrayInstance);
 
@@ -742,7 +742,7 @@ gjs_byte_array_from_byte_array (JSContext *context,
 
     JS::RootedObject proto(context, byte_array_get_prototype(context));
     JS::RootedObject object(context,
-        JS_NewObjectWithGivenProto(context, &gjs_byte_array_class, proto, JS::NullPtr()));
+        JS_NewObjectWithGivenProto(context, &gjs_byte_array_class, proto));
 
     if (!object) {
         gjs_throw(context, "failed to create byte array");
@@ -830,7 +830,7 @@ gjs_define_byte_array_stuff(JSContext              *context,
 {
     JSObject *prototype;
 
-    module.set(JS_NewObject(context, NULL, JS::NullPtr(), JS::NullPtr()));
+    module.set(JS_NewObject(context, NULL));
 
     prototype = JS_InitClass(context, module, JS::NullPtr(),
                              &gjs_byte_array_class,
diff --git a/gjs/importer.cpp b/gjs/importer.cpp
index f997267..670185e 100644
--- a/gjs/importer.cpp
+++ b/gjs/importer.cpp
@@ -313,12 +313,6 @@ import_native_file(JSContext       *context,
                              GJS_MODULE_PROP_FLAGS);
 }
 
-static JSObject *
-create_module_object(JSContext *context)
-{
-    return JS_NewObject(context, NULL, JS::NullPtr(), JS::NullPtr());
-}
-
 static bool
 import_file(JSContext       *context,
             const char      *name,
@@ -380,7 +374,7 @@ load_module_init(JSContext       *context,
         }
     }
 
-    JS::RootedObject module_obj(context, create_module_object(context));
+    JS::RootedObject module_obj(context, JS_NewObject(context, NULL));
     file = g_file_new_for_commandline_arg(full_path);
     if (!import_file (context, "__init__", file, module_obj))
         goto out;
@@ -431,7 +425,7 @@ import_file_on_module(JSContext       *context,
     bool retval = false;
     char *full_path = NULL;
 
-    JS::RootedObject module_obj(context, create_module_object(context));
+    JS::RootedObject module_obj(context, JS_NewObject(context, NULL));
 
     if (!define_import(context, obj, module_obj, name))
         goto out;
@@ -1003,7 +997,7 @@ importer_new(JSContext *context,
     }
 
     JS::RootedObject importer(context,
-        JS_NewObject(context, &gjs_importer_class, JS::NullPtr(), global));
+        JS_NewObject(context, &gjs_importer_class, global));
     if (importer == NULL)
         g_error("No memory to create importer importer");
 
diff --git a/gjs/jsapi-dynamic-class.cpp b/gjs/jsapi-dynamic-class.cpp
index 57fdfc3..f83e437 100644
--- a/gjs/jsapi-dynamic-class.cpp
+++ b/gjs/jsapi-dynamic-class.cpp
@@ -87,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, JS::NullPtr(), global));
+        prototype.set(JS_NewObject(context, clasp, global));
     }
     if (!prototype)
         goto out;
diff --git a/gjs/jsapi-util.cpp b/gjs/jsapi-util.cpp
index cacf7dc..799a625 100644
--- a/gjs/jsapi-util.cpp
+++ b/gjs/jsapi-util.cpp
@@ -872,7 +872,7 @@ gjs_eval_with_scope(JSContext             *context,
 
     JS::RootedObject eval_obj(context, object);
     if (!eval_obj)
-        eval_obj = JS_NewObject(context, NULL, JS::NullPtr(), JS::NullPtr());
+        eval_obj = JS_NewObject(context, NULL);
 
     JS::CompileOptions options(context);
     options.setUTF8(true)
diff --git a/modules/cairo-context.cpp b/modules/cairo-context.cpp
index cf5efa5..5f1164b 100644
--- a/modules/cairo-context.cpp
+++ b/modules/cairo-context.cpp
@@ -923,7 +923,7 @@ gjs_cairo_context_from_context(JSContext *context,
                                cairo_t *cr)
 {
     JS::RootedObject object(context,
-        JS_NewObject(context, &gjs_cairo_context_class, JS::NullPtr(), JS::NullPtr()));
+        JS_NewObject(context, &gjs_cairo_context_class));
     if (!object)
         return NULL;
 
diff --git a/modules/cairo-image-surface.cpp b/modules/cairo-image-surface.cpp
index 2af2d79..408bc10 100644
--- a/modules/cairo-image-surface.cpp
+++ b/modules/cairo-image-surface.cpp
@@ -88,7 +88,7 @@ createFromPNG_func(JSContext *context,
         return false;
 
     JS::RootedObject surface_wrapper(context,
-        JS_NewObject(context, &gjs_cairo_image_surface_class, JS::NullPtr(), JS::NullPtr()));
+        JS_NewObject(context, &gjs_cairo_image_surface_class));
     if (!surface_wrapper) {
         gjs_throw(context, "failed to create surface");
         return false;
@@ -215,7 +215,7 @@ gjs_cairo_image_surface_from_surface(JSContext       *context,
     g_return_val_if_fail(cairo_surface_get_type(surface) == CAIRO_SURFACE_TYPE_IMAGE, NULL);
 
     JS::RootedObject object(context,
-        JS_NewObject(context, &gjs_cairo_image_surface_class, JS::NullPtr(), JS::NullPtr()));
+        JS_NewObject(context, &gjs_cairo_image_surface_class));
     if (!object) {
         gjs_throw(context, "failed to create image surface");
         return NULL;
diff --git a/modules/cairo-linear-gradient.cpp b/modules/cairo-linear-gradient.cpp
index 3c0b866..89fb087 100644
--- a/modules/cairo-linear-gradient.cpp
+++ b/modules/cairo-linear-gradient.cpp
@@ -82,7 +82,7 @@ gjs_cairo_linear_gradient_from_pattern(JSContext       *context,
     g_return_val_if_fail(cairo_pattern_get_type(pattern) == CAIRO_PATTERN_TYPE_LINEAR, NULL);
 
     JS::RootedObject object(context,
-        JS_NewObject(context, &gjs_cairo_linear_gradient_class, JS::NullPtr(), JS::NullPtr()));
+        JS_NewObject(context, &gjs_cairo_linear_gradient_class));
     if (!object) {
         gjs_throw(context, "failed to create linear gradient pattern");
         return NULL;
diff --git a/modules/cairo-path.cpp b/modules/cairo-path.cpp
index c4c0aed..5ffa05a 100644
--- a/modules/cairo-path.cpp
+++ b/modules/cairo-path.cpp
@@ -75,7 +75,7 @@ gjs_cairo_path_from_path(JSContext    *context,
     g_return_val_if_fail(path != NULL, NULL);
 
     JS::RootedObject object(context,
-        JS_NewObject(context, &gjs_cairo_path_class, JS::NullPtr(), JS::NullPtr()));
+        JS_NewObject(context, &gjs_cairo_path_class));
     if (!object) {
         gjs_throw(context, "failed to create path");
         return NULL;
diff --git a/modules/cairo-pdf-surface.cpp b/modules/cairo-pdf-surface.cpp
index 2e68a64..5ae5ff1 100644
--- a/modules/cairo-pdf-surface.cpp
+++ b/modules/cairo-pdf-surface.cpp
@@ -88,7 +88,7 @@ gjs_cairo_pdf_surface_from_surface(JSContext       *context,
     g_return_val_if_fail(cairo_surface_get_type(surface) == CAIRO_SURFACE_TYPE_PDF, NULL);
 
     JS::RootedObject object(context,
-        JS_NewObject(context, &gjs_cairo_pdf_surface_class, JS::NullPtr(), JS::NullPtr()));
+        JS_NewObject(context, &gjs_cairo_pdf_surface_class));
     if (!object) {
         gjs_throw(context, "failed to create pdf surface");
         return NULL;
diff --git a/modules/cairo-ps-surface.cpp b/modules/cairo-ps-surface.cpp
index 270c73d..0110708 100644
--- a/modules/cairo-ps-surface.cpp
+++ b/modules/cairo-ps-surface.cpp
@@ -97,7 +97,7 @@ gjs_cairo_ps_surface_from_surface(JSContext       *context,
     g_return_val_if_fail(cairo_surface_get_type(surface) == CAIRO_SURFACE_TYPE_PS, NULL);
 
     JS::RootedObject object(context,
-        JS_NewObject(context, &gjs_cairo_ps_surface_class, JS::NullPtr(), JS::NullPtr()));
+        JS_NewObject(context, &gjs_cairo_ps_surface_class));
     if (!object) {
         gjs_throw(context, "failed to create ps surface");
         return NULL;
diff --git a/modules/cairo-radial-gradient.cpp b/modules/cairo-radial-gradient.cpp
index f93ff29..308e69d 100644
--- a/modules/cairo-radial-gradient.cpp
+++ b/modules/cairo-radial-gradient.cpp
@@ -84,7 +84,7 @@ gjs_cairo_radial_gradient_from_pattern(JSContext       *context,
     g_return_val_if_fail(cairo_pattern_get_type(pattern) == CAIRO_PATTERN_TYPE_RADIAL, NULL);
 
     JS::RootedObject object(context,
-        JS_NewObject(context, &gjs_cairo_radial_gradient_class, JS::NullPtr(), JS::NullPtr()));
+        JS_NewObject(context, &gjs_cairo_radial_gradient_class));
     if (!object) {
         gjs_throw(context, "failed to create radial gradient pattern");
         return NULL;
diff --git a/modules/cairo-region.cpp b/modules/cairo-region.cpp
index 39ff07e..c22e7b0 100644
--- a/modules/cairo-region.cpp
+++ b/modules/cairo-region.cpp
@@ -147,8 +147,7 @@ static JSObject *
 make_rectangle(JSContext *context,
                cairo_rectangle_int_t *rect)
 {
-    JS::RootedObject rect_obj(context,
-        JS_NewObject(context, NULL, JS::NullPtr(), JS::NullPtr()));
+    JS::RootedObject rect_obj(context, JS_NewObject(context, NULL));
     JS::RootedValue val(context);
 
     val = JS::Int32Value(rect->x);
@@ -278,7 +277,7 @@ gjs_cairo_region_from_region(JSContext *context,
                              cairo_region_t *region)
 {
     JS::RootedObject object(context,
-        JS_NewObject(context, &gjs_cairo_region_class, JS::NullPtr(), JS::NullPtr()));
+        JS_NewObject(context, &gjs_cairo_region_class));
     if (!object)
         return NULL;
 
diff --git a/modules/cairo-solid-pattern.cpp b/modules/cairo-solid-pattern.cpp
index 9d994b8..d7fd747 100644
--- a/modules/cairo-solid-pattern.cpp
+++ b/modules/cairo-solid-pattern.cpp
@@ -112,7 +112,7 @@ gjs_cairo_solid_pattern_from_pattern(JSContext       *context,
     g_return_val_if_fail(cairo_pattern_get_type(pattern) == CAIRO_PATTERN_TYPE_SOLID, NULL);
 
     JS::RootedObject object(context,
-        JS_NewObject(context, &gjs_cairo_solid_pattern_class, JS::NullPtr(), JS::NullPtr()));
+        JS_NewObject(context, &gjs_cairo_solid_pattern_class));
     if (!object) {
         gjs_throw(context, "failed to create solid pattern");
         return NULL;
diff --git a/modules/cairo-surface-pattern.cpp b/modules/cairo-surface-pattern.cpp
index 43ba99e..c38ac56 100644
--- a/modules/cairo-surface-pattern.cpp
+++ b/modules/cairo-surface-pattern.cpp
@@ -187,7 +187,7 @@ gjs_cairo_surface_pattern_from_pattern(JSContext       *context,
     g_return_val_if_fail(cairo_pattern_get_type(pattern) == CAIRO_PATTERN_TYPE_SURFACE, NULL);
 
     JS::RootedObject object(context,
-        JS_NewObject(context, &gjs_cairo_surface_pattern_class, JS::NullPtr(), JS::NullPtr()));
+        JS_NewObject(context, &gjs_cairo_surface_pattern_class));
     if (!object) {
         gjs_throw(context, "failed to create surface pattern");
         return NULL;
diff --git a/modules/cairo-surface.cpp b/modules/cairo-surface.cpp
index 1bfdb73..abfb313 100644
--- a/modules/cairo-surface.cpp
+++ b/modules/cairo-surface.cpp
@@ -206,7 +206,7 @@ gjs_cairo_surface_from_surface(JSContext       *context,
         return gjs_cairo_svg_surface_from_surface(context, surface);
 
     JS::RootedObject object(context,
-        JS_NewObject(context, &gjs_cairo_surface_class, JS::NullPtr(), JS::NullPtr()));
+        JS_NewObject(context, &gjs_cairo_surface_class));
     if (!object) {
         gjs_throw(context, "failed to create surface");
         return NULL;
diff --git a/modules/cairo-svg-surface.cpp b/modules/cairo-svg-surface.cpp
index f18ee0f..b6807a7 100644
--- a/modules/cairo-svg-surface.cpp
+++ b/modules/cairo-svg-surface.cpp
@@ -88,7 +88,7 @@ gjs_cairo_svg_surface_from_surface(JSContext       *context,
     g_return_val_if_fail(cairo_surface_get_type(surface) == CAIRO_SURFACE_TYPE_SVG, NULL);
 
     JS::RootedObject object(context,
-        JS_NewObject(context, &gjs_cairo_svg_surface_class, JS::NullPtr(), JS::NullPtr()));
+        JS_NewObject(context, &gjs_cairo_svg_surface_class));
     if (!object) {
         gjs_throw(context, "failed to create svg surface");
         return NULL;
diff --git a/modules/cairo.cpp b/modules/cairo.cpp
index 15fadae..f3e4647 100644
--- a/modules/cairo.cpp
+++ b/modules/cairo.cpp
@@ -63,7 +63,7 @@ gjs_js_define_cairo_stuff(JSContext              *context,
     JS::RootedObject surface_proto(context), pattern_proto(context),
         gradient_proto(context);
 
-    module.set(JS_NewObject(context, NULL, JS::NullPtr(), JS::NullPtr()));
+    module.set(JS_NewObject(context, NULL));
 
     obj = gjs_cairo_region_create_proto(context, module,
                                         "Region", JS::NullPtr());
diff --git a/modules/console.cpp b/modules/console.cpp
index abcb175..b746136 100644
--- a/modules/console.cpp
+++ b/modules/console.cpp
@@ -245,7 +245,7 @@ bool
 gjs_define_console_stuff(JSContext              *context,
                          JS::MutableHandleObject module)
 {
-    module.set(JS_NewObject(context, NULL, JS::NullPtr(), JS::NullPtr()));
+    module.set(JS_NewObject(context, NULL));
     return JS_DefineFunction(context, module, "interact", gjs_console_interact,
                              1, GJS_MODULE_PROP_FLAGS);
 }
diff --git a/modules/system.cpp b/modules/system.cpp
index c2c1551..7ab2e35 100644
--- a/modules/system.cpp
+++ b/modules/system.cpp
@@ -160,7 +160,7 @@ gjs_js_define_system_stuff(JSContext              *context,
     char *program_name;
     bool retval;
 
-    module.set(JS_NewObject(context, NULL, JS::NullPtr(), JS::NullPtr()));
+    module.set(JS_NewObject(context, NULL));
 
     if (!JS_DefineFunctions(context, module, &module_funcs[0]))
         return false;


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