[gjs] js: Use JS_NewObjectWithGivenProto



commit a2fdf358207d075e9cbc6d78895f87b4e5a72bea
Author: Philip Chimento <philip endlessm com>
Date:   Fri Jan 6 17:44:44 2017 -0800

    js: Use JS_NewObjectWithGivenProto
    
    In mozjs38, JS_NewObject() doesn't take a prototype JSObject anymore;
    instead, JS_NewObjectWithGivenProto() is used for that purpose. The
    behaviour of JS_NewObject() is changed so that it looks for a default
    prototype, which is the same as passing JS::NullPtr() as the proto
    parameter in mozjs31.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=776966

 gjs/byteArray.cpp           |    4 ++--
 gjs/jsapi-dynamic-class.cpp |    2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
---
diff --git a/gjs/byteArray.cpp b/gjs/byteArray.cpp
index 453f951..78e6a18 100644
--- a/gjs/byteArray.cpp
+++ b/gjs/byteArray.cpp
@@ -531,7 +531,7 @@ byte_array_new(JSContext *context)
 
     JS::RootedObject proto(context, byte_array_get_prototype(context));
     JS::RootedObject array(context,
-        JS_NewObject(context, &gjs_byte_array_class, proto, JS::NullPtr()));
+        JS_NewObjectWithGivenProto(context, &gjs_byte_array_class, proto, JS::NullPtr()));
 
     priv = g_slice_new0(ByteArrayInstance);
 
@@ -741,7 +741,7 @@ gjs_byte_array_from_byte_array (JSContext *context,
 
     JS::RootedObject proto(context, byte_array_get_prototype(context));
     JS::RootedObject object(context,
-        JS_NewObject(context, &gjs_byte_array_class, proto, JS::NullPtr()));
+        JS_NewObjectWithGivenProto(context, &gjs_byte_array_class, proto, JS::NullPtr()));
 
     if (!object) {
         gjs_throw(context, "failed to create byte array");
diff --git a/gjs/jsapi-dynamic-class.cpp b/gjs/jsapi-dynamic-class.cpp
index e229215..e53efcf 100644
--- a/gjs/jsapi-dynamic-class.cpp
+++ b/gjs/jsapi-dynamic-class.cpp
@@ -84,7 +84,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, parent_proto, global));
+    prototype.set(JS_NewObjectWithGivenProto(context, clasp, parent_proto, global));
     if (!prototype)
         goto out;
 


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