[gjs/gnome-3-8-js17: 5/14] JSClass callbacks now use JSHandleObject/Id types



commit 7ec6642a2b48457baaa7c14e636afba23b5dcf01
Author: Tim Lunn <tim feathertop org>
Date:   Sat Jan 5 16:13:30 2013 +1100

    JSClass callbacks now use JSHandleObject/Id types
    
    All functions which are callbacks for JSClass, now have new types
    which wraps the Objects in an extra pointer. We need to cast and
    then derefence these objects.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=690982

 gi/boxed.c      |   33 +++++++++++++++----------------
 gi/function.c   |    6 ++--
 gi/gerror.c     |   16 +++++++-------
 gi/gtype.c      |    6 ++--
 gi/interface.c  |   12 +++++-----
 gi/ns.c         |   14 ++++++------
 gi/object.c     |   38 ++++++++++++++++++------------------
 gi/param.c      |    8 +++---
 gi/repo.c       |   12 +++++-----
 gi/union.c      |   12 +++++-----
 gjs/byteArray.c |   56 +++++++++++++++++++++++++++---------------------------
 gjs/importer.c  |   25 +++++++++++------------
 12 files changed, 118 insertions(+), 120 deletions(-)
---
diff --git a/gi/boxed.c b/gi/boxed.c
index 464834e..265cb2e 100644
--- a/gi/boxed.c
+++ b/gi/boxed.c
@@ -116,8 +116,8 @@ gjs_define_static_methods(JSContext    *context,
  */
 static JSBool
 boxed_new_resolve(JSContext *context,
-                  JSObject  *obj,
-                  jsid       id,
+                  JSObject **obj,
+                  jsid      *id,
                   unsigned   flags,
                   JSObject **objp)
 {
@@ -127,11 +127,11 @@ boxed_new_resolve(JSContext *context,
 
     *objp = NULL;
 
-    if (!gjs_get_string_id(context, id, &name))
+    if (!gjs_get_string_id(context, *id, &name))
         return JS_TRUE; /* not resolved, but no error */
 
-    priv = priv_from_js(context, obj);
-    gjs_debug_jsprop(GJS_DEBUG_GBOXED, "Resolve prop '%s' hook obj %p priv %p", name, obj, priv);
+    priv = priv_from_js(context, *obj);
+    gjs_debug_jsprop(GJS_DEBUG_GBOXED, "Resolve prop '%s' hook obj %p priv %p", name, *obj, priv);
 
     if (priv == NULL)
         goto out; /* wrong class */
@@ -159,7 +159,7 @@ boxed_new_resolve(JSContext *context,
                       g_base_info_get_namespace( (GIBaseInfo*) priv->info),
                       g_base_info_get_name( (GIBaseInfo*) priv->info));
 
-            boxed_proto = obj;
+            boxed_proto = *obj;
 
             if (gjs_define_function(context, boxed_proto, priv->gtype,
                                     (GICallableInfo *)method_info) == NULL) {
@@ -619,7 +619,7 @@ get_nested_interface_object (JSContext   *context,
     /* We never actually read the reserved slot, but we put the parent object
      * into it to hold onto the parent object.
      */
-    JS_SetReservedSlot(context, obj, 0,
+    JS_SetReservedSlot(obj, 0,
                        OBJECT_TO_JSVAL (parent_obj));
 
     *value = OBJECT_TO_JSVAL(obj);
@@ -628,8 +628,8 @@ get_nested_interface_object (JSContext   *context,
 
 static JSBool
 boxed_field_getter (JSContext *context,
-                    JSObject  *obj,
-                    jsid       id,
+                    JSObject **obj,
+                    jsid      *id,
                     jsval     *value)
 {
     Boxed *priv;
@@ -638,11 +638,11 @@ boxed_field_getter (JSContext *context,
     GArgument arg;
     gboolean success = FALSE;
 
-    priv = priv_from_js(context, obj);
+    priv = priv_from_js(context, *obj);
     if (!priv)
         return JS_FALSE;
 
-    field_info = get_field_info(context, priv, id);
+    field_info = get_field_info(context, priv, *id);
     if (!field_info)
         return JS_FALSE;
 
@@ -663,7 +663,7 @@ boxed_field_getter (JSContext *context,
         if (g_base_info_get_type (interface_info) == GI_INFO_TYPE_STRUCT ||
             g_base_info_get_type (interface_info) == GI_INFO_TYPE_BOXED) {
 
-            success = get_nested_interface_object (context, obj, priv,
+            success = get_nested_interface_object (context, *obj, priv,
                                                    field_info, type_info, interface_info,
                                                    value);
 
@@ -808,8 +808,8 @@ out:
 
 static JSBool
 boxed_field_setter (JSContext *context,
-                    JSObject  *obj,
-                    jsid       id,
+                    JSObject **obj,
+                    jsid      *id,
                     JSBool     strict,
                     jsval     *value)
 {
@@ -817,11 +817,10 @@ boxed_field_setter (JSContext *context,
     GIFieldInfo *field_info;
     gboolean success = FALSE;
 
-    priv = priv_from_js(context, obj);
+    priv = priv_from_js(context, *obj);
     if (!priv)
         return JS_FALSE;
-
-    field_info = get_field_info(context, priv, id);
+    field_info = get_field_info(context, priv, *id);
     if (!field_info)
         return JS_FALSE;
 
diff --git a/gi/function.c b/gi/function.c
index 1d9f2ad..8cc6076 100644
--- a/gi/function.c
+++ b/gi/function.c
@@ -1242,15 +1242,15 @@ function_finalize(JSContext *context,
 
 static JSBool
 get_num_arguments (JSContext *context,
-                   JSObject  *obj,
-                   jsid       id,
+                   JSObject **obj,
+                   jsid      *id,
                    jsval     *vp)
 {
     int n_args, n_jsargs, i;
     jsval retval;
     Function *priv;
 
-    priv = priv_from_js(context, obj);
+    priv = priv_from_js(context, *obj);
 
     if (priv == NULL)
         return JS_FALSE;
diff --git a/gi/gerror.c b/gi/gerror.c
index 5fd12b6..f682a28 100644
--- a/gi/gerror.c
+++ b/gi/gerror.c
@@ -147,11 +147,11 @@ error_finalize(JSContext *context,
 }
 
 static JSBool
-error_get_domain(JSContext *context, JSObject *obj, jsid id, jsval *vp)
+error_get_domain(JSContext *context, JSObject **obj, jsid *id, jsval *vp)
 {
     Error *priv;
 
-    priv = priv_from_js(context, obj);
+    priv = priv_from_js(context, *obj);
 
     if (priv == NULL)
         return JS_FALSE;
@@ -161,11 +161,11 @@ error_get_domain(JSContext *context, JSObject *obj, jsid id, jsval *vp)
 }
 
 static JSBool
-error_get_message(JSContext *context, JSObject *obj, jsid id, jsval *vp)
+error_get_message(JSContext *context, JSObject **obj, jsid *id, jsval **vp)
 {
     Error *priv;
 
-    priv = priv_from_js(context, obj);
+    priv = priv_from_js(context, *obj);
 
     if (priv == NULL)
         return JS_FALSE;
@@ -180,11 +180,11 @@ error_get_message(JSContext *context, JSObject *obj, jsid id, jsval *vp)
 }
 
 static JSBool
-error_get_code(JSContext *context, JSObject *obj, jsid id, jsval *vp)
+error_get_code(JSContext *context, JSObject **obj, jsid *id, jsval *vp)
 {
     Error *priv;
 
-    priv = priv_from_js(context, obj);
+    priv = priv_from_js(context, *obj);
 
     if (priv == NULL)
         return JS_FALSE;
@@ -520,7 +520,8 @@ define_error_properties(JSContext *context,
     /* find the JS frame that triggered the error */
     frame = NULL;
     while (JS_FrameIterator(context, &frame)) {
-        if (JS_IsScriptFrame(context, frame))
+        script = JS_GetFrameScript(context, frame);
+        if (script)
             break;
     }
 
@@ -530,7 +531,6 @@ define_error_properties(JSContext *context,
     if (!frame)
         return;
 
-    script = JS_GetFrameScript(context, frame);
     pc = JS_GetFramePC(context, frame);
 
     stack = g_string_new(NULL);
diff --git a/gi/gtype.c b/gi/gtype.c
index 5bcdd6f..a5638d3 100644
--- a/gi/gtype.c
+++ b/gi/gtype.c
@@ -85,15 +85,15 @@ to_string_func(JSContext *context,
 
 static JSBool
 get_name_func (JSContext *context,
-               JSObject  *obj,
-               jsid       id,
+               JSObject **obj,
+               jsid      *id,
                jsval     *vp)
 {
     GType gtype;
     JSBool ret;
     jsval retval;
 
-    gtype = GPOINTER_TO_SIZE(priv_from_js(context, obj));
+    gtype = GPOINTER_TO_SIZE(priv_from_js(context, *obj));
 
     ret = gjs_string_from_utf8(context, g_type_name(gtype), -1, &retval);
     if (ret)
diff --git a/gi/interface.c b/gi/interface.c
index e447ba4..c8ebd34 100644
--- a/gi/interface.c
+++ b/gi/interface.c
@@ -100,8 +100,8 @@ gjs_define_static_methods(JSContext       *context,
 
 static JSBool
 interface_new_resolve(JSContext *context,
-                      JSObject  *obj,
-                      jsid       id,
+                      JSObject **obj,
+                      jsid      *id,
                       unsigned   flags,
                       JSObject **objp)
 {
@@ -112,10 +112,10 @@ interface_new_resolve(JSContext *context,
 
     *objp = NULL;
 
-    if (!gjs_get_string_id(context, id, &name))
+    if (!gjs_get_string_id(context, *id, &name))
         return JS_TRUE;
 
-    priv = priv_from_js(context, obj);
+    priv = priv_from_js(context, *obj);
 
     if (priv == NULL)
         goto out;
@@ -123,14 +123,14 @@ interface_new_resolve(JSContext *context,
     method_info = g_interface_info_find_method((GIInterfaceInfo*) priv->info, name);
 
     if (method_info != NULL) {
-        if (gjs_define_function(context, obj,
+        if (gjs_define_function(context, *obj,
                                 priv->gtype,
                                 (GICallableInfo*)method_info) == NULL) {
             g_base_info_unref((GIBaseInfo*)method_info);
             goto out;
         }
 
-        *objp = obj;
+        *objp = *obj;
         g_base_info_unref((GIBaseInfo*)method_info);
     }
 
diff --git a/gi/ns.c b/gi/ns.c
index 8d8930b..cfa9413 100644
--- a/gi/ns.c
+++ b/gi/ns.c
@@ -59,8 +59,8 @@ GJS_DEFINE_PRIV_FROM_JS(Ns, gjs_ns_class)
  */
 static JSBool
 ns_new_resolve(JSContext *context,
-               JSObject  *obj,
-               jsid       id,
+               JSObject **obj,
+               jsid      *id,
                unsigned   flags,
                JSObject **objp)
 {
@@ -72,7 +72,7 @@ ns_new_resolve(JSContext *context,
 
     *objp = NULL;
 
-    if (!gjs_get_string_id(context, id, &name))
+    if (!gjs_get_string_id(context, *id, &name))
         return JS_TRUE; /* not resolved, but no error */
 
     /* let Object.prototype resolve these */
@@ -82,8 +82,8 @@ ns_new_resolve(JSContext *context,
         goto out;
     }
 
-    priv = priv_from_js(context, obj);
-    gjs_debug_jsprop(GJS_DEBUG_GNAMESPACE, "Resolve prop '%s' hook obj %p priv %p", name, obj, priv);
+    priv = priv_from_js(context, *obj);
+    gjs_debug_jsprop(GJS_DEBUG_GNAMESPACE, "Resolve prop '%s' hook obj %p priv %p", name, *obj, priv);
 
     if (priv == NULL) {
         ret = JS_TRUE; /* we are the prototype, or have the wrong class */
@@ -108,9 +108,9 @@ ns_new_resolve(JSContext *context,
               g_base_info_get_name(info),
               g_base_info_get_namespace(info));
 
-    if (gjs_define_info(context, obj, info)) {
+    if (gjs_define_info(context, *obj, info)) {
         g_base_info_unref(info);
-        *objp = obj; /* we defined the property in this object */
+        *objp = *obj; /* we defined the property in this object */
         ret = JS_TRUE;
     } else {
         gjs_debug(GJS_DEBUG_GNAMESPACE,
diff --git a/gi/object.c b/gi/object.c
index 13dfbf9..bcbab0a 100644
--- a/gi/object.c
+++ b/gi/object.c
@@ -220,8 +220,8 @@ proto_priv_from_js(JSContext *context,
  */
 static JSBool
 object_instance_get_prop(JSContext *context,
-                         JSObject  *obj,
-                         jsid       id,
+                         JSObject **obj,
+                         jsid      *id,
                          jsval     *value_p)
 {
     ObjectInstance *priv;
@@ -231,10 +231,10 @@ object_instance_get_prop(JSContext *context,
     GValue gvalue = { 0, };
     JSBool ret = JS_TRUE;
 
-    if (!gjs_get_string_id(context, id, &name))
+    if (!gjs_get_string_id(context, *id, &name))
         return JS_TRUE; /* not resolved, but no error */
 
-    priv = priv_from_js(context, obj);
+    priv = priv_from_js(context, *obj);
     gjs_debug_jsprop(GJS_DEBUG_GOBJECT,
                      "Get prop '%s' hook obj %p priv %p", name, obj, priv);
 
@@ -289,8 +289,8 @@ object_instance_get_prop(JSContext *context,
  */
 static JSBool
 object_instance_set_prop(JSContext *context,
-                         JSObject  *obj,
-                         jsid       id,
+                         JSObject **obj,
+                         jsid      *id,
                          JSBool     strict,
                          jsval     *value_p)
 {
@@ -299,10 +299,10 @@ object_instance_set_prop(JSContext *context,
     GParameter param = { NULL, { 0, }};
     JSBool ret = JS_TRUE;
 
-    if (!gjs_get_string_id(context, id, &name))
+    if (!gjs_get_string_id(context, *id, &name))
         return JS_TRUE; /* not resolved, but no error */
 
-    priv = priv_from_js(context, obj);
+    priv = priv_from_js(context, *obj);
     gjs_debug_jsprop(GJS_DEBUG_GOBJECT,
                      "Set prop '%s' hook obj %p priv %p", name, obj, priv);
 
@@ -461,8 +461,8 @@ object_instance_new_resolve_no_info(JSContext       *context,
  */
 static JSBool
 object_instance_new_resolve(JSContext *context,
-                            JSObject  *obj,
-                            jsid       id,
+                            JSObject **obj,
+                            jsid      *id,
                             unsigned   flags,
                             JSObject **objp)
 {
@@ -473,15 +473,15 @@ object_instance_new_resolve(JSContext *context,
 
     *objp = NULL;
 
-    if (!gjs_get_string_id(context, id, &name))
+    if (!gjs_get_string_id(context, *id, &name))
         return JS_TRUE; /* not resolved, but no error */
 
-    priv = priv_from_js(context, obj);
+    priv = priv_from_js(context, *obj);
 
     gjs_debug_jsprop(GJS_DEBUG_GOBJECT,
                      "Resolve prop '%s' hook obj %p priv %p (%s.%s) gobj %p %s",
                      name,
-                     obj,
+                     *obj,
                      priv,
                      priv && priv->info ? g_base_info_get_namespace (priv->info) : "",
                      priv && priv->info ? g_base_info_get_name (priv->info) : "",
@@ -510,7 +510,7 @@ object_instance_new_resolve(JSContext *context,
      * we need to look at exposing interfaces. Look up our interfaces through
      * GType data, and then hope that *those* are introspectable. */
     if (priv->info == NULL) {
-        ret = object_instance_new_resolve_no_info(context, obj, objp, priv, name);
+        ret = object_instance_new_resolve_no_info(context, *obj, objp, priv, name);
         goto out;
     }
 
@@ -542,8 +542,8 @@ object_instance_new_resolve(JSContext *context,
                 goto out;
             }
 
-            gjs_define_function(context, obj, priv->gtype, vfunc);
-            *objp = obj;
+            gjs_define_function(context, *obj, priv->gtype, vfunc);
+            *objp = *obj;
             g_base_info_unref((GIBaseInfo *)vfunc);
             ret = JS_TRUE;
             goto out;
@@ -574,7 +574,7 @@ object_instance_new_resolve(JSContext *context,
      * https://bugzilla.gnome.org/show_bug.cgi?id=632922
      */
     if (method_info == NULL) {
-        ret = object_instance_new_resolve_no_info(context, obj, objp,
+        ret = object_instance_new_resolve_no_info(context, *obj, objp,
                                                   priv, name);
         goto out;
     } else {
@@ -589,12 +589,12 @@ object_instance_new_resolve(JSContext *context,
                   g_base_info_get_namespace( (GIBaseInfo*) priv->info),
                   g_base_info_get_name( (GIBaseInfo*) priv->info));
 
-        if (gjs_define_function(context, obj, priv->gtype, method_info) == NULL) {
+        if (gjs_define_function(context, *obj, priv->gtype, method_info) == NULL) {
             g_base_info_unref( (GIBaseInfo*) method_info);
             goto out;
         }
 
-        *objp = obj; /* we defined the prop in obj */
+        *objp = *obj; /* we defined the prop in obj */
 
         g_base_info_unref( (GIBaseInfo*) method_info);
     }
diff --git a/gi/param.c b/gi/param.c
index aaddc5b..c82cf42 100644
--- a/gi/param.c
+++ b/gi/param.c
@@ -68,8 +68,8 @@ find_field_info(GIObjectInfo *info,
  */
 static JSBool
 param_get_prop(JSContext *context,
-               JSObject  *obj,
-               jsid       id,
+               JSObject **obj,
+               jsid      *id,
                jsval     *value_p)
 {
     JSBool success;
@@ -82,10 +82,10 @@ param_get_prop(JSContext *context,
     GITypeInfo *type_info = NULL;
     GIArgument arg;
 
-    if (!gjs_get_string_id(context, id, &name))
+    if (!gjs_get_string_id(context, *id, &name))
         return JS_TRUE; /* not something we affect, but no error */
 
-    priv = priv_from_js(context, obj);
+    priv = priv_from_js(context, *obj);
 
     if (priv == NULL) {
         g_free(name);
diff --git a/gi/repo.c b/gi/repo.c
index c14ff7a..ec7d713 100644
--- a/gi/repo.c
+++ b/gi/repo.c
@@ -156,8 +156,8 @@ resolve_namespace_object(JSContext  *context,
  */
 static JSBool
 repo_new_resolve(JSContext *context,
-                 JSObject  *obj,
-                 jsid       id,
+                 JSObject **obj,
+                 jsid      *id,
                  unsigned   flags,
                  JSObject **objp)
 {
@@ -167,7 +167,7 @@ repo_new_resolve(JSContext *context,
 
     *objp = NULL;
 
-    if (!gjs_get_string_id(context, id, &name))
+    if (!gjs_get_string_id(context, *id, &name))
         return JS_TRUE; /* not resolved, but no error */
 
     /* let Object.prototype resolve these */
@@ -175,17 +175,17 @@ repo_new_resolve(JSContext *context,
         strcmp(name, "toString") == 0)
         goto out;
 
-    priv = priv_from_js(context, obj);
+    priv = priv_from_js(context, *obj);
     gjs_debug_jsprop(GJS_DEBUG_GREPO, "Resolve prop '%s' hook obj %p priv %p", name, obj, priv);
 
     if (priv == NULL) /* we are the prototype, or have the wrong class */
         goto out;
 
     JS_BeginRequest(context);
-    if (resolve_namespace_object(context, obj, name) == NULL) {
+    if (resolve_namespace_object(context, *obj, name) == NULL) {
         ret = JS_FALSE;
     } else {
-        *objp = obj; /* store the object we defined the prop in */
+        *objp = *obj; /* store the object we defined the prop in */
     }
     JS_EndRequest(context);
 
diff --git a/gi/union.c b/gi/union.c
index 19e3491..e6ad2ff 100644
--- a/gi/union.c
+++ b/gi/union.c
@@ -64,8 +64,8 @@ GJS_DEFINE_PRIV_FROM_JS(Union, gjs_union_class)
  */
 static JSBool
 union_new_resolve(JSContext *context,
-                  JSObject  *obj,
-                  jsid       id,
+                  JSObject **obj,
+                  jsid      *id,
                   unsigned   flags,
                   JSObject **objp)
 {
@@ -75,11 +75,11 @@ union_new_resolve(JSContext *context,
 
     *objp = NULL;
 
-    if (!gjs_get_string_id(context, id, &name))
+    if (!gjs_get_string_id(context, *id, &name))
         return JS_TRUE; /* not resolved, but no error */
 
-    priv = priv_from_js(context, obj);
-    gjs_debug_jsprop(GJS_DEBUG_GBOXED, "Resolve prop '%s' hook obj %p priv %p", name, obj, priv);
+    priv = priv_from_js(context, *obj);
+    gjs_debug_jsprop(GJS_DEBUG_GBOXED, "Resolve prop '%s' hook obj %p priv %p", name, *obj, priv);
 
     if (priv == NULL) {
         ret = JS_FALSE; /* wrong class */
@@ -109,7 +109,7 @@ union_new_resolve(JSContext *context,
                       g_base_info_get_namespace( (GIBaseInfo*) priv->info),
                       g_base_info_get_name( (GIBaseInfo*) priv->info));
 
-            union_proto = obj;
+            union_proto = *obj;
 
             if (gjs_define_function(context, union_proto,
                                     g_registered_type_info_get_g_type(priv->info),
diff --git a/gjs/byteArray.c b/gjs/byteArray.c
index 33852b1..11d03a2 100644
--- a/gjs/byteArray.c
+++ b/gjs/byteArray.c
@@ -41,17 +41,17 @@ static struct JSObject* gjs_byte_array_prototype;
 GJS_DEFINE_PRIV_FROM_JS(ByteArrayInstance, gjs_byte_array_class)
 
 static JSBool byte_array_get_prop      (JSContext    *context,
-                                        JSObject     *obj,
-                                        jsid          id,
+                                        JSObject    **obj,
+                                        jsid         *id,
                                         jsval        *value_p);
 static JSBool byte_array_set_prop      (JSContext    *context,
-                                        JSObject     *obj,
-                                        jsid          id,
+                                        JSObject    **obj,
+                                        jsid         *id,
                                         JSBool        strict,
                                         jsval        *value_p);
 static JSBool byte_array_new_resolve   (JSContext    *context,
-                                        JSObject     *obj,
-                                        jsid          id,
+                                        JSObject    **obj,
+                                        jsid         *id,
                                         unsigned      flags,
                                         JSObject    **objp);
 GJS_NATIVE_CONSTRUCTOR_DECLARE(byte_array);
@@ -205,19 +205,19 @@ byte_array_get_index(JSContext         *context,
  */
 static JSBool
 byte_array_get_prop(JSContext *context,
-                    JSObject  *obj,
-                    jsid       id,
+                    JSObject **obj,
+                    jsid      *id,
                     jsval     *value_p)
 {
     ByteArrayInstance *priv;
     jsval id_value;
 
-    priv = priv_from_js(context, obj);
+    priv = priv_from_js(context, *obj);
 
     if (priv == NULL)
         return JS_TRUE; /* prototype, not an instance. */
 
-    if (!JS_IdToValue(context, id, &id_value))
+    if (!JS_IdToValue(context, *id, &id_value))
         return JS_FALSE;
 
     /* First handle array indexing */
@@ -225,7 +225,7 @@ byte_array_get_prop(JSContext *context,
         gsize idx;
         if (!gjs_value_to_gsize(context, id_value, &idx))
             return JS_FALSE;
-        return byte_array_get_index(context, obj, priv, idx, value_p);
+        return byte_array_get_index(context, *obj, priv, idx, value_p);
     }
 
     /* We don't special-case anything else for now. Regular JS arrays
@@ -237,14 +237,14 @@ byte_array_get_prop(JSContext *context,
 
 static JSBool
 byte_array_length_getter(JSContext *context,
-                         JSObject  *obj,
-                         jsid       id,
+                         JSObject **obj,
+                         jsid      *id,
                          jsval     *value_p)
 {
     ByteArrayInstance *priv;
     gsize len = 0;
 
-    priv = priv_from_js(context, obj);
+    priv = priv_from_js(context, *obj);
 
     if (priv == NULL)
         return JS_TRUE; /* prototype, not an instance. */
@@ -258,15 +258,15 @@ byte_array_length_getter(JSContext *context,
 
 static JSBool
 byte_array_length_setter(JSContext *context,
-                         JSObject  *obj,
-                         jsid       id,
+                         JSObject **obj,
+                         jsid      *id,
                          JSBool     strict,
                          jsval     *value_p)
 {
     ByteArrayInstance *priv;
     gsize len = 0;
 
-    priv = priv_from_js(context, obj);
+    priv = priv_from_js(context, *obj);
 
     if (priv == NULL)
         return JS_TRUE; /* prototype, not instance */
@@ -320,20 +320,20 @@ byte_array_set_index(JSContext         *context,
  */
 static JSBool
 byte_array_set_prop(JSContext *context,
-                    JSObject  *obj,
-                    jsid       id,
+                    JSObject **obj,
+                    jsid      *id,
                     JSBool     strict,
                     jsval     *value_p)
 {
     ByteArrayInstance *priv;
     jsval id_value;
 
-    priv = priv_from_js(context, obj);
+    priv = priv_from_js(context, *obj);
 
     if (priv == NULL)
         return JS_TRUE; /* prototype, not an instance. */
 
-    if (!JS_IdToValue(context, id, &id_value))
+    if (!JS_IdToValue(context, *id, &id_value))
         return JS_FALSE;
 
     byte_array_ensure_array(priv);
@@ -344,7 +344,7 @@ byte_array_set_prop(JSContext *context,
         if (!gjs_value_to_gsize(context, id_value, &idx))
             return JS_FALSE;
 
-        return byte_array_set_index(context, obj, priv, idx, value_p);
+        return byte_array_set_index(context, *obj, priv, idx, value_p);
     }
 
     /* We don't special-case anything else for now */
@@ -359,8 +359,8 @@ byte_array_set_prop(JSContext *context,
 
 static JSBool
 byte_array_new_resolve(JSContext *context,
-                       JSObject  *obj,
-                       jsid       id,
+                       JSObject **obj,
+                       jsid      *id,
                        unsigned   flags,
                        JSObject **objp)
 {
@@ -374,7 +374,7 @@ byte_array_new_resolve(JSContext *context,
     if (priv == NULL)
         return JS_TRUE; /* prototype, not an instance. */
 
-    if (!JS_IdToValue(context, id, &id_val))
+    if (!JS_IdToValue(context, *id, &id_val))
         return JS_FALSE;
 
     byte_array_ensure_array(priv);
@@ -394,15 +394,15 @@ byte_array_new_resolve(JSContext *context,
              * a property but must define it.
              */
             if (!JS_DefinePropertyById(context,
-                                       obj,
-                                       id,
+                                       *obj,
+                                       *id,
                                        JSVAL_VOID,
                                        byte_array_get_prop,
                                        byte_array_set_prop,
                                        JSPROP_ENUMERATE))
                 return JS_FALSE;
 
-            *objp = obj;
+            *objp = *obj;
         }
     }
 
diff --git a/gjs/importer.c b/gjs/importer.c
index 7bfc6fd..52b8719 100644
--- a/gjs/importer.c
+++ b/gjs/importer.c
@@ -726,7 +726,7 @@ importer_iterator_free(ImporterIterator *iter)
  */
 static JSBool
 importer_new_enumerate(JSContext  *context,
-                       JSObject   *object,
+                       JSObject  **object,
                        JSIterateOp enum_op,
                        jsval      *state_p,
                        jsid       *id_p)
@@ -748,12 +748,13 @@ importer_new_enumerate(JSContext  *context,
         if (id_p)
             *id_p = INT_TO_JSID(0);
 
-        priv = priv_from_js(context, object);
+        priv = priv_from_js(context, *object);
+
         if (!priv)
             /* we are enumerating the prototype properties */
             return JS_TRUE;
 
-        if (!gjs_object_require_property(context, object, "importer", "searchPath", &search_path_val))
+        if (!gjs_object_require_property(context, *object, "importer", "searchPath", &search_path_val))
             return JS_FALSE;
 
         if (!JSVAL_IS_OBJECT(search_path_val)) {
@@ -808,7 +809,7 @@ importer_new_enumerate(JSContext  *context,
             init_path = g_build_filename(dirname, MODULE_INIT_FILENAME,
                                          NULL);
 
-            load_module_elements(context, object, iter, init_path);
+            load_module_elements(context, *object, iter, init_path);
 
             g_free(init_path);
 
@@ -916,8 +917,8 @@ importer_new_enumerate(JSContext  *context,
  */
 static JSBool
 importer_new_resolve(JSContext *context,
-                     JSObject  *obj,
-                     jsid       id,
+                     JSObject **obj,
+                     jsid      *id,
                      unsigned   flags,
                      JSObject **objp)
 {
@@ -927,7 +928,7 @@ importer_new_resolve(JSContext *context,
 
     *objp = NULL;
 
-    if (!gjs_get_string_id(context, id, &name))
+    if (!gjs_get_string_id(context, *id, &name))
         return JS_FALSE;
 
     /* let Object.prototype resolve these */
@@ -935,16 +936,14 @@ importer_new_resolve(JSContext *context,
         strcmp(name, "toString") == 0 ||
         strcmp(name, "__iterator__") == 0)
         goto out;
+    priv = priv_from_js(context, *obj);
 
-    priv = priv_from_js(context, obj);
-    gjs_debug_jsprop(GJS_DEBUG_IMPORTER, "Resolve prop '%s' hook obj %p priv %p", name, obj, priv);
-
+    gjs_debug_jsprop(GJS_DEBUG_IMPORTER, "Resolve prop '%s' hook obj %p priv %p", name, *obj, priv);
     if (priv == NULL) /* we are the prototype, or have the wrong class */
         goto out;
-
     JS_BeginRequest(context);
-    if (do_import(context, obj, priv, name)) {
-        *objp = obj;
+    if (do_import(context, *obj, priv, name)) {
+        *objp = *obj;
     } else {
         ret = JS_FALSE;
     }


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