[gjs/wip/ptomato/mozjs31: 1/23] gtype: Specify GType object prototype explicitly



commit b7efc891504fd58034e71391c2ce62e93586b3d0
Author: Philip Chimento <philip endlessm com>
Date:   Tue Nov 8 16:35:48 2016 -0800

    gtype: Specify GType object prototype explicitly
    
    Previously, JS_NewObject() was able to infer the prototype of the GType
    object because the prototype was there in the global namespace.
    JS_NewObject() has stopped doing this in mozjs31, so we need to
    explicitly specify the prototype using JS_NewObjectWithGivenProto().
    
    (I'm not sure if this needs to be fixed up anywhere else. The tests all
    pass without it, and in the importer case, the tests were relying on the
    importer object _not_ having the prototype of Object.)
    
    https://bugzilla.gnome.org/show_bug.cgi?id=742249

 gi/gtype.cpp |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
---
diff --git a/gi/gtype.cpp b/gi/gtype.cpp
index bc2eadb..872da37 100644
--- a/gi/gtype.cpp
+++ b/gi/gtype.cpp
@@ -126,13 +126,14 @@ gjs_gtype_create_gtype_wrapper (JSContext *context,
 
     /* put constructor for GIRepositoryGType() in the global namespace */
     JS::RootedObject global(context, gjs_get_import_global(context));
-    gjs_gtype_create_proto(context, global, "GIRepositoryGType", JS::NullPtr());
+    JS::RootedObject proto(context,
+        gjs_gtype_create_proto(context, global, "GIRepositoryGType", JS::NullPtr()).toObjectOrNull());
 
     object = (JSObject*) g_type_get_qdata(gtype, gjs_get_gtype_wrapper_quark());
     if (object != NULL)
         goto out;
 
-    object = JS_NewObject(context, &gjs_gtype_class, NULL, NULL);
+    object = JS_NewObjectWithGivenProto(context, &gjs_gtype_class, proto, NULL);
     if (object == NULL)
         goto out;
 


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