[gjs/wip/ptomato/mozjs31prep: 5/8] cairo: Root gjs_cairo_image_surface_init()



commit f1eb421fcde5ab3284d06bb993f93eee7e2b15e5
Author: Philip Chimento <philip endlessm com>
Date:   Thu Nov 3 16:44:16 2016 -0700

    cairo: Root gjs_cairo_image_surface_init()
    
    Using exact rooting in gjs_cairo_image_surface_init() has a small cascade
    effect into cairo.cpp.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=742249

 modules/cairo-image-surface.cpp |    7 +++----
 modules/cairo-private.h         |    3 ++-
 modules/cairo.cpp               |    4 +++-
 3 files changed, 8 insertions(+), 6 deletions(-)
---
diff --git a/modules/cairo-image-surface.cpp b/modules/cairo-image-surface.cpp
index c346944..ee0e4d2 100644
--- a/modules/cairo-image-surface.cpp
+++ b/modules/cairo-image-surface.cpp
@@ -227,12 +227,11 @@ gjs_cairo_image_surface_from_surface(JSContext       *context,
 }
 
 void
-gjs_cairo_image_surface_init(JSContext *context, JSObject *module_obj)
+gjs_cairo_image_surface_init(JSContext       *cx,
+                             JS::HandleObject proto)
 {
 
-    if (!JS_DefineFunction(context, module_obj,
-                           "createFromPNG",
-                           (JSNative)createFromPNG_func,
+    if (!JS_DefineFunction(cx, proto, "createFromPNG", createFromPNG_func,
                            1, GJS_MODULE_PROP_FLAGS))
         return;
 }
diff --git a/modules/cairo-private.h b/modules/cairo-private.h
index f5b2409..c80b87f 100644
--- a/modules/cairo-private.h
+++ b/modules/cairo-private.h
@@ -84,7 +84,8 @@ JS::Value gjs_cairo_image_surface_create_proto(JSContext       *context,
                                                JS::HandleObject parent);
 
 void             gjs_cairo_image_surface_init           (JSContext       *context,
-                                                         JSObject        *object);
+                                                         JS::HandleObject proto);
+
 JSObject *       gjs_cairo_image_surface_from_surface   (JSContext       *context,
                                                          cairo_surface_t *surface);
 
diff --git a/modules/cairo.cpp b/modules/cairo.cpp
index 4701e0a..2114a17 100644
--- a/modules/cairo.cpp
+++ b/modules/cairo.cpp
@@ -88,7 +88,9 @@ gjs_js_define_cairo_stuff(JSContext              *context,
                                                "ImageSurface", surface_proto);
     if (obj.isNull())
         return false;
-    gjs_cairo_image_surface_init(context, &obj.toObject());
+
+    JS::RootedObject image_surface_proto(context, &obj.toObject());
+    gjs_cairo_image_surface_init(context, image_surface_proto);
 
 #if CAIRO_HAS_PS_SURFACE
     obj = gjs_cairo_ps_surface_create_proto(context, module,


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