[gjs/wip/ptomato/mozjs31prep: 11/11] js: Root create_proto functions



commit c78a70638e1525082aa0bc6794c88b401a6df56c
Author: Philip Chimento <philip endlessm com>
Date:   Fri Oct 21 18:30:38 2016 -0700

    js: Root create_proto functions
    
    This changes the gjs_whatever_create_proto() functions generated by the
    GJS_DEFINE_PROTO macros in jsapi-util.h to be correctly rooted, letting
    changes to those function prototypes cascade everywhere else.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=742249

 gi/arg.cpp                  |    4 +-
 gi/boxed.cpp                |    4 +-
 gi/fundamental.cpp          |    2 +-
 gi/gerror.cpp               |    4 +-
 gi/gtype.cpp                |   13 ++---
 gi/object.cpp               |    4 +-
 gi/repo.cpp                 |   11 +---
 gi/value.cpp                |    2 +-
 gjs/importer.cpp            |    4 +-
 gjs/jsapi-dynamic-class.cpp |    2 +-
 gjs/jsapi-util.cpp          |   14 ++----
 gjs/jsapi-util.h            |   44 ++++++++--------
 modules/cairo-private.h     |  121 +++++++++++++++++++++++--------------------
 modules/cairo.cpp           |   11 ++--
 14 files changed, 120 insertions(+), 120 deletions(-)
---
diff --git a/gi/arg.cpp b/gi/arg.cpp
index 77a25d2..b336454 100644
--- a/gi/arg.cpp
+++ b/gi/arg.cpp
@@ -1118,7 +1118,7 @@ gjs_array_to_explicit_array_internal(JSContext       *context,
             goto out;
     } else if (JS_HasPropertyById(context, &value.toObject(), length_name, &found_length) &&
                found_length) {
-        JS::Value length_value;
+        JS::RootedValue length_value(context);
         guint32 length;
 
         if (!gjs_object_require_property(context,
@@ -1648,7 +1648,7 @@ gjs_value_to_g_argument(JSContext      *context,
         if (value.isObject() &&
             JS_HasPropertyById(context, &value.toObject(), length_name, &found_length) &&
             found_length) {
-            JS::Value length_value;
+            JS::RootedValue length_value(context);
             guint32 length;
 
             if (!gjs_object_require_property(context,
diff --git a/gi/boxed.cpp b/gi/boxed.cpp
index 16aee62..227b88d 100644
--- a/gi/boxed.cpp
+++ b/gi/boxed.cpp
@@ -290,7 +290,7 @@ boxed_init_from_props(JSContext   *context,
     while (!JSID_IS_VOID(prop_id)) {
         GIFieldInfo *field_info;
         char *name;
-        JS::Value value;
+        JS::RootedValue value(context);
 
         if (!gjs_get_string_id(context, prop_id, &name))
             goto out;
@@ -330,7 +330,7 @@ boxed_invoke_constructor(JSContext             *context,
                          jsid                   constructor_name,
                          JS::CallArgs&          args)
 {
-    JS::Value js_constructor, js_constructor_func;
+    JS::RootedValue js_constructor(context), js_constructor_func(context);
     jsid constructor_const;
 
     constructor_const = gjs_context_get_const_string(context, GJS_STRING_CONSTRUCTOR);
diff --git a/gi/fundamental.cpp b/gi/fundamental.cpp
index 35fbd18..d87b939 100644
--- a/gi/fundamental.cpp
+++ b/gi/fundamental.cpp
@@ -388,7 +388,7 @@ fundamental_invoke_constructor(FundamentalInstance *priv,
                                JS::Value           *argv,
                                GArgument           *rvalue)
 {
-    JS::Value js_constructor, js_constructor_func;
+    JS::RootedValue js_constructor(context), js_constructor_func(context);
     jsid constructor_const;
 
     constructor_const = gjs_context_get_const_string(context, GJS_STRING_CONSTRUCTOR);
diff --git a/gi/gerror.cpp b/gi/gerror.cpp
index d989318..57274d0 100644
--- a/gi/gerror.cpp
+++ b/gi/gerror.cpp
@@ -54,7 +54,6 @@ GJS_NATIVE_CONSTRUCTOR_DECLARE(error)
     Error *priv;
     Error *proto_priv;
     jsid message_name, code_name;
-    JS::Value v_message, v_code;
     gchar *message;
 
     /* Check early to avoid allocating memory for nothing */
@@ -96,6 +95,7 @@ GJS_NATIVE_CONSTRUCTOR_DECLARE(error)
     g_base_info_ref( (GIBaseInfo*) priv->info);
     priv->domain = proto_priv->domain;
 
+    JS::RootedValue v_message(context), v_code(context);
     message_name = gjs_context_get_const_string(context, GJS_STRING_MESSAGE);
     code_name = gjs_context_get_const_string(context, GJS_STRING_CODE);
     if (!gjs_object_require_property(context, &argv[0].toObject(),
@@ -244,7 +244,7 @@ error_constructor_value_of(JSContext *context,
                            JS::Value *vp)
 {
     GJS_GET_THIS(context, argc, vp, rec, self);
-    JS::Value v_prototype;
+    JS::RootedValue v_prototype(context);
     Error *priv;
     jsid prototype_name;
 
diff --git a/gi/gtype.cpp b/gi/gtype.cpp
index 5d76e7f..d7900e6 100644
--- a/gi/gtype.cpp
+++ b/gi/gtype.cpp
@@ -30,10 +30,10 @@
 #include <girepository.h>
 
 static JS::Value
-gjs_gtype_create_proto(JSContext  *context,
-                       JSObject   *module,
-                       const char *proto_name,
-                       JSObject   *parent);
+gjs_gtype_create_proto(JSContext       *context,
+                       JS::HandleObject module,
+                       const char      *proto_name,
+                       JS::HandleObject parent);
 
 GJS_DEFINE_PROTO_ABSTRACT("GIRepositoryGType", gtype, 0);
 
@@ -121,13 +121,12 @@ gjs_gtype_create_gtype_wrapper (JSContext *context,
                                 GType      gtype)
 {
     JSObject *object;
-    JSObject *global;
 
     JS_BeginRequest(context);
 
     /* put constructor for GIRepositoryGType() in the global namespace */
-    global = gjs_get_import_global(context);
-    gjs_gtype_create_proto(context, global, "GIRepositoryGType", NULL);
+    JS::RootedObject global(context, gjs_get_import_global(context));
+    gjs_gtype_create_proto(context, global, "GIRepositoryGType", JS::NullPtr());
 
     object = (JSObject*) g_type_get_qdata(gtype, gjs_get_gtype_wrapper_quark());
     if (object != NULL)
diff --git a/gi/object.cpp b/gi/object.cpp
index f2bfe50..bdb8b0c 100644
--- a/gi/object.cpp
+++ b/gi/object.cpp
@@ -700,7 +700,7 @@ object_instance_props_to_g_parameters(JSContext               *context,
 
     while (!JSID_IS_VOID(prop_id)) {
         char *name = NULL;
-        JS::Value value;
+        JS::RootedValue value(context);
         GParameter gparam = { NULL, { 0, }};
 
         if (!gjs_object_require_property(context, props, "property list", prop_id, &value)) {
@@ -1318,7 +1318,7 @@ GJS_NATIVE_CONSTRUCTOR_DECLARE(object_instance)
 {
     GJS_NATIVE_CONSTRUCTOR_VARIABLES(object_instance)
     bool ret;
-    JS::Value initer;
+    JS::RootedValue initer(context);
     jsid object_init_name;
 
     GJS_NATIVE_CONSTRUCTOR_PRELUDE(object_instance);
diff --git a/gi/repo.cpp b/gi/repo.cpp
index 6051a9d..cd52d10 100644
--- a/gi/repo.cpp
+++ b/gi/repo.cpp
@@ -63,7 +63,7 @@ get_version_for_ns (JSContext *context,
                     char     **version)
 {
     jsid versions_name;
-    JS::Value versions_val;
+    JS::RootedValue versions_val(context);
     JSObject *versions;
     JS::Value version_val;
 
@@ -586,9 +586,7 @@ lookup_override_function(JSContext  *context,
                          jsid        ns_name)
 {
     JS::Value importer;
-    JS::Value overridespkg;
-    JS::Value module;
-    JS::Value function;
+    JS::RootedValue overridespkg(context), module(context), function(context);
     jsid overrides_name, object_init_name;
 
     JS_BeginRequest(context);
@@ -596,7 +594,6 @@ lookup_override_function(JSContext  *context,
     importer = gjs_get_global_slot(context, GJS_GLOBAL_SLOT_IMPORTS);
     g_assert(importer.isObject());
 
-    overridespkg = JS::UndefinedValue();
     overrides_name = gjs_context_get_const_string(context, GJS_STRING_GI_OVERRIDES);
     if (!gjs_object_require_property(context, &importer.toObject(), "importer",
                                      overrides_name, &overridespkg) ||
@@ -629,8 +626,7 @@ gjs_lookup_namespace_object_by_name(JSContext      *context,
 {
     JSObject *repo_obj;
     JS::Value importer;
-    JS::Value girepository;
-    JS::Value ns_obj;
+    JS::RootedValue girepository(context), ns_obj(context);
     jsid gi_name;
 
     JS_BeginRequest(context);
@@ -638,7 +634,6 @@ gjs_lookup_namespace_object_by_name(JSContext      *context,
     importer = gjs_get_global_slot(context, GJS_GLOBAL_SLOT_IMPORTS);
     g_assert(importer.isObject());
 
-    girepository = JS::UndefinedValue();
     gi_name = gjs_context_get_const_string(context, GJS_STRING_GI_MODULE);
     if (!gjs_object_require_property(context, &importer.toObject(), "importer",
                                      gi_name, &girepository) ||
diff --git a/gi/value.cpp b/gi/value.cpp
index edff321..1efd267 100644
--- a/gi/value.cpp
+++ b/gi/value.cpp
@@ -493,7 +493,7 @@ gjs_value_to_g_value_internal(JSContext    *context,
             /* do nothing */
         } else if (JS_HasPropertyById(context, &value.toObject(), length_name, &found_length) &&
                    found_length) {
-            JS::Value length_value;
+            JS::RootedValue length_value(context);
             guint32 length;
 
             if (!gjs_object_require_property(context,
diff --git a/gjs/importer.cpp b/gjs/importer.cpp
index 4ea961e..5682a61 100644
--- a/gjs/importer.cpp
+++ b/gjs/importer.cpp
@@ -411,7 +411,7 @@ do_import(JSContext       *context,
     char *filename;
     char *full_path;
     char *dirname = NULL;
-    JS::Value search_path_val;
+    JS::RootedValue search_path_val(context);
     guint32 search_path_len;
     guint32 i;
     bool result;
@@ -662,7 +662,7 @@ importer_new_enumerate(JSContext  *context,
     case JSENUMERATE_INIT_ALL:
     case JSENUMERATE_INIT: {
         Importer *priv;
-        JS::Value search_path_val;
+        JS::RootedValue search_path_val(context);
         guint32 search_path_len;
         guint32 i;
         jsid search_path_name;
diff --git a/gjs/jsapi-dynamic-class.cpp b/gjs/jsapi-dynamic-class.cpp
index a47aba8..e6e5204 100644
--- a/gjs/jsapi-dynamic-class.cpp
+++ b/gjs/jsapi-dynamic-class.cpp
@@ -174,7 +174,7 @@ gjs_construct_object_dynamic(JSContext      *context,
 {
     JSObject *constructor;
     JSObject *result = NULL;
-    JS::Value value;
+    JS::RootedValue value(context);
     jsid constructor_name;
 
     JS_BeginRequest(context);
diff --git a/gjs/jsapi-util.cpp b/gjs/jsapi-util.cpp
index 9b20c9b..3d1539d 100644
--- a/gjs/jsapi-util.cpp
+++ b/gjs/jsapi-util.cpp
@@ -141,23 +141,17 @@ gjs_object_require_property(JSContext       *context,
                             JSObject        *obj,
                             const char      *obj_description,
                             jsid             property_name,
-                            JS::Value       *value_p)
+                            JS::MutableHandleValue value)
 {
-    JS::Value value;
     char *name;
 
-    value = JS::UndefinedValue();
-    if (value_p)
-        *value_p = value;
+    value.setUndefined();
 
-    if (G_UNLIKELY (!JS_GetPropertyById(context, obj, property_name, &value)))
+    if (G_UNLIKELY(!JS_GetPropertyById(context, obj, property_name, value.address())))
         return false;
 
-    if (G_LIKELY (!value.isUndefined())) {
-        if (value_p)
-            *value_p = value;
+    if (G_LIKELY(!value.isUndefined()))
         return true;
-    }
 
     /* remember gjs_throw() is a no-op if JS_GetProperty()
      * already set an exception
diff --git a/gjs/jsapi-util.h b/gjs/jsapi-util.h
index d0862db..28e25d9 100644
--- a/gjs/jsapi-util.h
+++ b/gjs/jsapi-util.h
@@ -197,24 +197,24 @@ static struct JSClass gjs_##cname##_class = { \
     gjs_##cname##_finalize, \
     JSCLASS_NO_OPTIONAL_MEMBERS \
 }; \
-JS::Value gjs_##cname##_create_proto(JSContext *context, JSObject *module, const char *proto_name, JSObject 
*parent) \
+JS::Value                                                                      \
+gjs_##cname##_create_proto(JSContext *context,                                 \
+                           JS::HandleObject module,                            \
+                           const char      *proto_name,                        \
+                           JS::HandleObject parent)                            \
 { \
-    JS::Value rval; \
-    JSObject *global = gjs_get_import_global(context); \
-    jsid class_name = gjs_intern_string_to_id(context, gjs_##cname##_class.name); \
-    if (!JS_GetPropertyById(context, global, class_name, &rval))                       \
+    JS::RootedValue rval(context);                                             \
+    JS::RootedObject global(context, gjs_get_import_global(context));          \
+    JS::RootedId class_name(context,                                           \
+        gjs_intern_string_to_id(context, gjs_##cname##_class.name));           \
+    if (!JS_GetPropertyById(context, global, class_name, rval.address()))      \
         return JS::NullValue(); \
     if (rval.isUndefined()) { \
-        JS::Value value; \
-        JSObject *prototype = JS_InitClass(context, global,     \
-                                 parent, \
-                                 &gjs_##cname##_class, \
-                                 ctor, \
-                                 0, \
-                                 &gjs_##cname##_proto_props[0], \
-                                 &gjs_##cname##_proto_funcs[0], \
-                                 NULL, \
-                                 NULL); \
+        JS::RootedObject prototype(context,                                    \
+            JS_InitClass(context, global, parent, &gjs_##cname##_class, ctor,  \
+                         0, &gjs_##cname##_proto_props[0],                     \
+                         &gjs_##cname##_proto_funcs[0],                        \
+                         NULL, NULL));                                         \
         if (prototype == NULL) { \
             return JS::NullValue(); \
         } \
@@ -227,7 +227,9 @@ JS::Value gjs_##cname##_create_proto(JSContext *context, JSObject *module, const
                                rval, NULL, NULL, GJS_MODULE_PROP_FLAGS)) \
             return JS::NullValue(); \
         if (gtype != G_TYPE_NONE) { \
-            value = JS::ObjectOrNullValue(gjs_gtype_create_gtype_wrapper(context, gtype)); \
+            JS::RootedValue value(context,                                     \
+                JS::ObjectOrNullValue(gjs_gtype_create_gtype_wrapper(context,  \
+                                                                     gtype))); \
             JS_DefineProperty(context, &rval.toObject(), "$gtype", value, \
                               NULL, NULL, JSPROP_PERMANENT);            \
         } \
@@ -301,11 +303,11 @@ void        gjs_set_global_slot              (JSContext       *context,
                                               GjsGlobalSlot    slot,
                                               JS::Value        value);
 
-bool        gjs_object_require_property      (JSContext       *context,
-                                              JSObject        *obj,
-                                              const char      *obj_description,
-                                              jsid             property_name,
-                                              JS::Value       *value_p);
+bool gjs_object_require_property(JSContext             *context,
+                                 JSObject              *obj,
+                                 const char            *obj_description,
+                                 jsid                   property_name,
+                                 JS::MutableHandleValue value);
 
 bool gjs_init_class_dynamic(JSContext              *context,
                             JSObject               *in_object,
diff --git a/modules/cairo-private.h b/modules/cairo-private.h
index 97e3380..f5b2409 100644
--- a/modules/cairo-private.h
+++ b/modules/cairo-private.h
@@ -30,17 +30,18 @@ bool             gjs_cairo_check_status                 (JSContext       *contex
                                                          cairo_status_t   status,
                                                          const char      *name);
 
-JS::Value        gjs_cairo_region_create_proto          (JSContext       *context,
-                                                         JSObject        *module,
-                                                         const char      *proto_name,
-                                                         JSObject        *parent);
+JS::Value gjs_cairo_region_create_proto(JSContext       *context,
+                                        JS::HandleObject module,
+                                        const char      *proto_name,
+                                        JS::HandleObject parent);
+
 void             gjs_cairo_region_init                  (JSContext       *context);
 
+JS::Value gjs_cairo_context_create_proto(JSContext       *context,
+                                         JS::HandleObject module,
+                                         const char      *proto_name,
+                                         JS::HandleObject parent);
 
-JS::Value        gjs_cairo_context_create_proto         (JSContext       *context,
-                                                         JSObject        *module,
-                                                         const char      *proto_name,
-                                                         JSObject        *parent);
 cairo_t *        gjs_cairo_context_get_context          (JSContext       *context,
                                                          JS::HandleObject object);
 JSObject *       gjs_cairo_context_from_context         (JSContext       *context,
@@ -50,20 +51,22 @@ void             gjs_cairo_surface_init                 (JSContext       *contex
 
 
 /* cairo_path_t */
-JS::Value        gjs_cairo_path_create_proto            (JSContext       *context,
-                                                         JSObject        *module,
-                                                         const char      *proto_name,
-                                                         JSObject        *parent);
+JS::Value gjs_cairo_path_create_proto(JSContext       *context,
+                                      JS::HandleObject module,
+                                      const char      *proto_name,
+                                      JS::HandleObject parent);
+
 JSObject *       gjs_cairo_path_from_path               (JSContext       *context,
                                                          cairo_path_t    *path);
 cairo_path_t *   gjs_cairo_path_get_path                (JSContext       *context,
                                                          JSObject        *path_wrapper);
 
 /* surface */
-JS::Value        gjs_cairo_surface_create_proto         (JSContext       *context,
-                                                         JSObject        *module,
-                                                         const char      *proto_name,
-                                                         JSObject        *parent);
+JS::Value gjs_cairo_surface_create_proto(JSContext       *context,
+                                         JS::HandleObject module,
+                                         const char      *proto_name,
+                                         JS::HandleObject parent);
+
 void             gjs_cairo_surface_construct            (JSContext       *context,
                                                          JS::HandleObject object,
                                                          cairo_surface_t *surface);
@@ -75,10 +78,11 @@ cairo_surface_t* gjs_cairo_surface_get_surface          (JSContext       *contex
                                                          JSObject        *object);
 
 /* image surface */
-JS::Value        gjs_cairo_image_surface_create_proto   (JSContext       *context,
-                                                         JSObject        *module,
-                                                         const char      *proto_name,
-                                                         JSObject        *parent);
+JS::Value gjs_cairo_image_surface_create_proto(JSContext       *context,
+                                               JS::HandleObject module,
+                                               const char      *proto_name,
+                                               JS::HandleObject parent);
+
 void             gjs_cairo_image_surface_init           (JSContext       *context,
                                                          JSObject        *object);
 JSObject *       gjs_cairo_image_surface_from_surface   (JSContext       *context,
@@ -86,39 +90,40 @@ JSObject *       gjs_cairo_image_surface_from_surface   (JSContext       *contex
 
 /* postscript surface */
 #ifdef CAIRO_HAS_PS_SURFACE
-JS::Value        gjs_cairo_ps_surface_create_proto      (JSContext       *context,
-                                                         JSObject        *module,
-                                                         const char      *proto_name,
-                                                         JSObject        *parent);
+JS::Value gjs_cairo_ps_surface_create_proto(JSContext       *context,
+                                            JS::HandleObject module,
+                                            const char      *proto_name,
+                                            JS::HandleObject parent);
 #endif
 JSObject *       gjs_cairo_ps_surface_from_surface       (JSContext       *context,
                                                           cairo_surface_t *surface);
 
 /* pdf surface */
 #ifdef CAIRO_HAS_PDF_SURFACE
-JS::Value        gjs_cairo_pdf_surface_create_proto     (JSContext       *context,
-                                                         JSObject        *module,
-                                                         const char      *proto_name,
-                                                         JSObject        *parent);
+JS::Value gjs_cairo_pdf_surface_create_proto(JSContext       *context,
+                                             JS::HandleObject module,
+                                             const char      *proto_name,
+                                             JS::HandleObject parent);
 #endif
 JSObject *       gjs_cairo_pdf_surface_from_surface     (JSContext       *context,
                                                          cairo_surface_t *surface);
 
 /* svg surface */
 #ifdef CAIRO_HAS_SVG_SURFACE
-JS::Value        gjs_cairo_svg_surface_create_proto     (JSContext       *context,
-                                                         JSObject        *module,
-                                                         const char      *proto_name,
-                                                         JSObject        *parent);
+JS::Value gjs_cairo_svg_surface_create_proto(JSContext       *context,
+                                             JS::HandleObject module,
+                                             const char      *proto_name,
+                                             JS::HandleObject parent);
 #endif
 JSObject *       gjs_cairo_svg_surface_from_surface     (JSContext       *context,
                                                          cairo_surface_t *surface);
 
 /* pattern */
-JS::Value        gjs_cairo_pattern_create_proto         (JSContext       *context,
-                                                         JSObject        *module,
-                                                         const char      *proto_name,
-                                                         JSObject        *parent);
+JS::Value gjs_cairo_pattern_create_proto(JSContext       *context,
+                                         JS::HandleObject module,
+                                         const char      *proto_name,
+                                         JS::HandleObject parent);
+
 void             gjs_cairo_pattern_construct            (JSContext       *context,
                                                          JS::HandleObject object,
                                                          cairo_pattern_t *pattern);
@@ -130,40 +135,44 @@ cairo_pattern_t* gjs_cairo_pattern_get_pattern          (JSContext       *contex
                                                          JSObject        *object);
 
 /* gradient */
-JS::Value        gjs_cairo_gradient_create_proto        (JSContext       *context,
-                                                         JSObject        *module,
-                                                         const char      *proto_name,
-                                                         JSObject        *parent);
+JS::Value gjs_cairo_gradient_create_proto(JSContext       *context,
+                                          JS::HandleObject module,
+                                          const char      *proto_name,
+                                          JS::HandleObject parent);
 
 /* linear gradient */
-JS::Value        gjs_cairo_linear_gradient_create_proto (JSContext       *context,
-                                                         JSObject        *module,
-                                                         const char      *proto_name,
-                                                         JSObject        *parent);
+JS::Value gjs_cairo_linear_gradient_create_proto(JSContext       *context,
+                                                 JS::HandleObject module,
+                                                 const char      *proto_name,
+                                                 JS::HandleObject parent);
+
 JSObject *       gjs_cairo_linear_gradient_from_pattern (JSContext       *context,
                                                          cairo_pattern_t *pattern);
 
 /* radial gradient */
-JS::Value        gjs_cairo_radial_gradient_create_proto (JSContext       *context,
-                                                         JSObject        *module,
-                                                         const char      *proto_name,
-                                                         JSObject        *parent);
+JS::Value gjs_cairo_radial_gradient_create_proto(JSContext       *context,
+                                                 JS::HandleObject module,
+                                                 const char      *proto_name,
+                                                 JS::HandleObject parent);
+
 JSObject *       gjs_cairo_radial_gradient_from_pattern (JSContext       *context,
                                                          cairo_pattern_t *pattern);
 
 /* surface pattern */
-JS::Value        gjs_cairo_surface_pattern_create_proto (JSContext       *context,
-                                                         JSObject        *module,
-                                                         const char      *proto_name,
-                                                         JSObject        *parent);
+JS::Value gjs_cairo_surface_pattern_create_proto(JSContext       *context,
+                                                 JS::HandleObject module,
+                                                 const char      *proto_name,
+                                                 JS::HandleObject parent);
+
 JSObject *       gjs_cairo_surface_pattern_from_pattern (JSContext       *context,
                                                          cairo_pattern_t *pattern);
 
 /* solid pattern */
-JS::Value        gjs_cairo_solid_pattern_create_proto   (JSContext       *context,
-                                                         JSObject        *module,
-                                                         const char      *proto_name,
-                                                         JSObject        *parent);
+JS::Value gjs_cairo_solid_pattern_create_proto(JSContext       *context,
+                                               JS::HandleObject module,
+                                               const char      *proto_name,
+                                               JS::HandleObject parent);
+
 JSObject *       gjs_cairo_solid_pattern_from_pattern   (JSContext       *context,
                                                          cairo_pattern_t *pattern);
 
diff --git a/modules/cairo.cpp b/modules/cairo.cpp
index 0b2f2c8..4701e0a 100644
--- a/modules/cairo.cpp
+++ b/modules/cairo.cpp
@@ -60,25 +60,26 @@ gjs_js_define_cairo_stuff(JSContext              *context,
                           JS::MutableHandleObject module)
 {
     JS::Value obj;
-    JSObject *surface_proto, *pattern_proto, *gradient_proto;
+    JS::RootedObject surface_proto(context), pattern_proto(context),
+        gradient_proto(context);
 
     module.set(JS_NewObject(context, NULL, NULL, NULL));
 
     obj = gjs_cairo_region_create_proto(context, module,
-                                        "Region", NULL);
+                                        "Region", JS::NullPtr());
     if (obj.isNull())
         return false;
     gjs_cairo_region_init(context);
 
     obj = gjs_cairo_context_create_proto(context, module,
-                                         "Context", NULL);
+                                         "Context", JS::NullPtr());
     if (obj.isNull())
         return false;
     gjs_cairo_context_init(context);
     gjs_cairo_surface_init(context);
 
     obj = gjs_cairo_surface_create_proto(context, module,
-                                         "Surface", NULL);
+                                         "Surface", JS::NullPtr());
     if (obj.isNull())
         return false;
     surface_proto = &obj.toObject();
@@ -111,7 +112,7 @@ gjs_js_define_cairo_stuff(JSContext              *context,
 #endif
 
     obj = gjs_cairo_pattern_create_proto(context, module,
-                                         "Pattern", NULL);
+                                         "Pattern", JS::NullPtr());
     if (obj.isNull())
         return false;
     pattern_proto = &obj.toObject();


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