[gjs] Fix JS types in callback signatures
- From: Jasper St. Pierre <jstpierre src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs] Fix JS types in callback signatures
- Date: Sat, 23 Aug 2014 02:35:54 +0000 (UTC)
commit 117f200e97b85424f21ca837b5094370f0120192
Author: Michel Dänzer <michel daenzer net>
Date: Mon May 5 11:46:44 2014 +0900
Fix JS types in callback signatures
Fixes crashes in the testsuite and in gnome-shell on at least PPC, due
to treating things like pointers which really aren't.
Signed-off-by: Michel Dänzer <michel daenzer net>
gi/boxed.cpp | 18 +++++------
gi/function.cpp | 10 +++---
gi/fundamental.cpp | 26 ++++++++---------
gi/gerror.cpp | 21 ++++++++------
gi/gtype.cpp | 12 ++++----
gi/interface.cpp | 18 +++++------
gi/ns.cpp | 18 +++++------
gi/object.cpp | 36 +++++++++++------------
gi/repo.cpp | 20 ++++++-------
gi/union.cpp | 18 +++++------
gjs/byteArray.cpp | 80 +++++++++++++++++++++++++--------------------------
gjs/importer.cpp | 20 ++++++-------
12 files changed, 141 insertions(+), 156 deletions(-)
---
diff --git a/gi/boxed.cpp b/gi/boxed.cpp
index 497352f..0c8e6bd 100644
--- a/gi/boxed.cpp
+++ b/gi/boxed.cpp
@@ -118,21 +118,19 @@ gjs_define_static_methods(JSContext *context,
*/
static JSBool
boxed_new_resolve(JSContext *context,
- JSObject **obj,
- jsid *id,
- unsigned flags,
- JSObject **objp)
+ JS::HandleObject obj,
+ JS::HandleId id,
+ unsigned flags,
+ JS::MutableHandleObject objp)
{
Boxed *priv;
char *name;
JSBool ret = JS_FALSE;
- *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_GBOXED, "Resolve prop '%s' hook obj %p priv %p", name, *obj, priv);
if (priv == NULL)
@@ -161,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) {
@@ -169,7 +167,7 @@ boxed_new_resolve(JSContext *context,
goto out;
}
- *objp = boxed_proto; /* we defined the prop in object_proto */
+ objp.set(boxed_proto); /* we defined the prop in object_proto */
}
g_base_info_unref( (GIBaseInfo*) method_info);
diff --git a/gi/function.cpp b/gi/function.cpp
index 792778c..6b55273 100644
--- a/gi/function.cpp
+++ b/gi/function.cpp
@@ -1334,15 +1334,15 @@ function_finalize(JSFreeOp *fop,
static JSBool
get_num_arguments (JSContext *context,
- JSObject **obj,
- jsid *id,
- jsval *vp)
+ JS::HandleObject obj,
+ JS::HandleId id,
+ JS::MutableHandleValue 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;
@@ -1362,7 +1362,7 @@ get_num_arguments (JSContext *context,
}
retval = INT_TO_JSVAL(n_jsargs);
- JS_SET_RVAL(context, vp, retval);
+ JS_SET_RVAL(context, vp.address(), retval);
return JS_TRUE;
}
diff --git a/gi/fundamental.cpp b/gi/fundamental.cpp
index bdb2742..9ca8003 100644
--- a/gi/fundamental.cpp
+++ b/gi/fundamental.cpp
@@ -233,8 +233,8 @@ find_fundamental_constructor(JSContext *context,
static JSBool
fundamental_instance_new_resolve_interface(JSContext *context,
- JSObject *obj,
- JSObject **objp,
+ JS::HandleObject obj,
+ JS::MutableHandleObject objp,
Fundamental *proto_priv,
char *name)
{
@@ -271,7 +271,7 @@ fundamental_instance_new_resolve_interface(JSContext *context,
if (gjs_define_function(context, obj,
proto_priv->gtype,
(GICallableInfo *) method_info)) {
- *objp = obj;
+ objp.set(obj);
} else {
ret = JS_FALSE;
}
@@ -300,21 +300,19 @@ fundamental_instance_new_resolve_interface(JSContext *context,
*/
static JSBool
fundamental_instance_new_resolve(JSContext *context,
- JSObject **obj,
- jsid *id,
- unsigned flags,
- JSObject **objp)
+ JS::HandleObject obj,
+ JS::HandleId id,
+ unsigned flags,
+ JS::MutableHandleObject objp)
{
FundamentalInstance *priv;
char *name;
JSBool ret = JS_FALSE;
- *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_GFUNDAMENTAL, "Resolve prop '%s' hook obj %p priv %p", name, *obj, priv);
if (priv == NULL)
@@ -355,19 +353,19 @@ fundamental_instance_new_resolve(JSContext *context,
g_base_info_get_namespace((GIBaseInfo *) proto_priv->info),
g_base_info_get_name((GIBaseInfo *) proto_priv->info));
- if (gjs_define_function(context, *obj, proto_priv->gtype,
+ if (gjs_define_function(context, obj, proto_priv->gtype,
method_info) == NULL) {
g_base_info_unref((GIBaseInfo *) method_info);
goto out;
}
- *objp = *obj;
+ objp.set(obj);
}
g_base_info_unref((GIBaseInfo *) method_info);
}
- ret = fundamental_instance_new_resolve_interface(context, *obj, objp,
+ ret = fundamental_instance_new_resolve_interface(context, obj, objp,
proto_priv, name);
} else {
/* We are an instance, not a prototype, so look for
diff --git a/gi/gerror.cpp b/gi/gerror.cpp
index 891f99c..2384cd5 100644
--- a/gi/gerror.cpp
+++ b/gi/gerror.cpp
@@ -150,25 +150,27 @@ error_finalize(JSFreeOp *fop,
}
static JSBool
-error_get_domain(JSContext *context, JSObject **obj, jsid *id, jsval *vp)
+error_get_domain(JSContext *context, JS::HandleObject obj,
+ JS::HandleId id, JS::MutableHandleValue vp)
{
Error *priv;
- priv = priv_from_js(context, *obj);
+ priv = priv_from_js(context, obj);
if (priv == NULL)
return JS_FALSE;
- *vp = INT_TO_JSVAL(priv->domain);
+ vp.set(INT_TO_JSVAL(priv->domain));
return JS_TRUE;
}
static JSBool
-error_get_message(JSContext *context, JSObject **obj, jsid *id, jsval *vp)
+error_get_message(JSContext *context, JS::HandleObject obj,
+ JS::HandleId id, JS::MutableHandleValue vp)
{
Error *priv;
- priv = priv_from_js(context, *obj);
+ priv = priv_from_js(context, obj);
if (priv == NULL)
return JS_FALSE;
@@ -179,15 +181,16 @@ error_get_message(JSContext *context, JSObject **obj, jsid *id, jsval *vp)
return JS_FALSE;
}
- return gjs_string_from_utf8(context, priv->gerror->message, -1, vp);
+ return gjs_string_from_utf8(context, priv->gerror->message, -1, vp.address());
}
static JSBool
-error_get_code(JSContext *context, JSObject **obj, jsid *id, jsval *vp)
+error_get_code(JSContext *context, JS::HandleObject obj,
+ JS::HandleId id, JS::MutableHandleValue vp)
{
Error *priv;
- priv = priv_from_js(context, *obj);
+ priv = priv_from_js(context, obj);
if (priv == NULL)
return JS_FALSE;
@@ -198,7 +201,7 @@ error_get_code(JSContext *context, JSObject **obj, jsid *id, jsval *vp)
return JS_FALSE;
}
- *vp = INT_TO_JSVAL(priv->gerror->code);
+ vp.set(INT_TO_JSVAL(priv->gerror->code));
return JS_TRUE;
}
diff --git a/gi/gtype.cpp b/gi/gtype.cpp
index c45698f..7ac2a38 100644
--- a/gi/gtype.cpp
+++ b/gi/gtype.cpp
@@ -88,23 +88,23 @@ to_string_func(JSContext *context,
static JSBool
get_name_func (JSContext *context,
- JSObject **obj,
- jsid *id,
- jsval *vp)
+ JS::HandleObject obj,
+ JS::HandleId id,
+ JS::MutableHandleValue 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));
if (gtype == 0) {
- JS_SET_RVAL(context, vp, JSVAL_NULL);
+ JS_SET_RVAL(context, vp.address(), JSVAL_NULL);
return TRUE;
} else {
ret = gjs_string_from_utf8(context, g_type_name(gtype), -1, &retval);
if (ret)
- JS_SET_RVAL(context, vp, retval);
+ JS_SET_RVAL(context, vp.address(), retval);
return ret;
}
}
diff --git a/gi/interface.cpp b/gi/interface.cpp
index 8fb1253..e13cf3a 100644
--- a/gi/interface.cpp
+++ b/gi/interface.cpp
@@ -100,22 +100,20 @@ gjs_define_static_methods(JSContext *context,
static JSBool
interface_new_resolve(JSContext *context,
- JSObject **obj,
- jsid *id,
- unsigned flags,
- JSObject **objp)
+ JS::HandleObject obj,
+ JS::HandleId id,
+ unsigned flags,
+ JS::MutableHandleObject objp)
{
Interface *priv;
char *name;
JSBool ret = JS_FALSE;
GIFunctionInfo *method_info;
- *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;
@@ -124,14 +122,14 @@ interface_new_resolve(JSContext *context,
if (method_info != NULL) {
if (g_function_info_get_flags (method_info) & GI_FUNCTION_IS_METHOD) {
- 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.set(obj);
}
g_base_info_unref((GIBaseInfo*)method_info);
diff --git a/gi/ns.cpp b/gi/ns.cpp
index f3d116b..5c84281 100644
--- a/gi/ns.cpp
+++ b/gi/ns.cpp
@@ -57,10 +57,10 @@ GJS_DEFINE_PRIV_FROM_JS(Ns, gjs_ns_class)
*/
static JSBool
ns_new_resolve(JSContext *context,
- JSObject **obj,
- jsid *id,
- unsigned flags,
- JSObject **objp)
+ JS::HandleObject obj,
+ JS::HandleId id,
+ unsigned flags,
+ JS::MutableHandleObject objp)
{
Ns *priv;
char *name;
@@ -68,9 +68,7 @@ ns_new_resolve(JSContext *context,
GIBaseInfo *info;
JSBool ret = JS_FALSE;
- *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 */
@@ -80,7 +78,7 @@ ns_new_resolve(JSContext *context,
goto out;
}
- priv = priv_from_js(context, *obj);
+ 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) {
@@ -106,9 +104,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.set(obj); /* we defined the property in this object */
ret = JS_TRUE;
} else {
gjs_debug(GJS_DEBUG_GNAMESPACE,
diff --git a/gi/object.cpp b/gi/object.cpp
index 5e74f63..1fb4de5 100644
--- a/gi/object.cpp
+++ b/gi/object.cpp
@@ -267,7 +267,7 @@ object_instance_get_prop(JSContext *context,
priv = priv_from_js(context, obj);
gjs_debug_jsprop(GJS_DEBUG_GOBJECT,
- "Get prop '%s' hook obj %p priv %p", name, obj, priv);
+ "Get prop '%s' hook obj %p priv %p", name, *obj, priv);
if (priv == NULL) {
/* If we reach this point, either object_instance_new_resolve
@@ -335,7 +335,7 @@ object_instance_set_prop(JSContext *context,
priv = priv_from_js(context, obj);
gjs_debug_jsprop(GJS_DEBUG_GOBJECT,
- "Set prop '%s' hook obj %p priv %p", name, obj, priv);
+ "Set prop '%s' hook obj %p priv %p", name, *obj, priv);
if (priv == NULL) {
/* see the comment in object_instance_get_prop() on this */
@@ -435,8 +435,8 @@ find_vfunc_on_parents(GIObjectInfo *info,
static JSBool
object_instance_new_resolve_no_info(JSContext *context,
- JSObject *obj,
- JSObject **objp,
+ JS::HandleObject obj,
+ JS::MutableHandleObject objp,
ObjectInstance *priv,
char *name)
{
@@ -472,7 +472,7 @@ object_instance_new_resolve_no_info(JSContext *context,
if (g_function_info_get_flags (method_info) & GI_FUNCTION_IS_METHOD) {
if (gjs_define_function(context, obj, priv->gtype,
(GICallableInfo *)method_info)) {
- *objp = obj;
+ objp.set(obj);
} else {
ret = JS_FALSE;
}
@@ -501,22 +501,20 @@ object_instance_new_resolve_no_info(JSContext *context,
*/
static JSBool
object_instance_new_resolve(JSContext *context,
- JSObject **obj,
- jsid *id,
- unsigned flags,
- JSObject **objp)
+ JS::HandleObject obj,
+ JS::HandleId id,
+ unsigned flags,
+ JS::MutableHandleObject objp)
{
GIFunctionInfo *method_info;
ObjectInstance *priv;
char *name;
JSBool ret = JS_FALSE;
- *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",
@@ -550,7 +548,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;
}
@@ -583,8 +581,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.set(obj);
g_base_info_unref((GIBaseInfo *)vfunc);
ret = JS_TRUE;
goto out;
@@ -615,7 +613,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 {
@@ -631,12 +629,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.set(obj); /* we defined the prop in obj */
}
g_base_info_unref( (GIBaseInfo*) method_info);
diff --git a/gi/repo.cpp b/gi/repo.cpp
index 8037d5f..54a84d6 100644
--- a/gi/repo.cpp
+++ b/gi/repo.cpp
@@ -173,18 +173,16 @@ resolve_namespace_object(JSContext *context,
*/
static JSBool
repo_new_resolve(JSContext *context,
- JSObject **obj,
- jsid *id,
- unsigned flags,
- JSObject **objp)
+ JS::HandleObject obj,
+ JS::HandleId id,
+ unsigned flags,
+ JS::MutableHandleObject objp)
{
Repo *priv;
char *name;
JSBool ret = JS_TRUE;
- *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 */
@@ -192,16 +190,16 @@ repo_new_resolve(JSContext *context,
strcmp(name, "toString") == 0)
goto out;
- priv = priv_from_js(context, *obj);
- gjs_debug_jsprop(GJS_DEBUG_GREPO, "Resolve prop '%s' hook obj %p priv %p", name, obj, priv);
+ 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;
- if (!resolve_namespace_object(context, *obj, *id, name)) {
+ if (!resolve_namespace_object(context, obj, id, name)) {
ret = JS_FALSE;
} else {
- *objp = *obj; /* store the object we defined the prop in */
+ objp.set(obj); /* store the object we defined the prop in */
}
out:
diff --git a/gi/union.cpp b/gi/union.cpp
index 7ac58e3..718b991 100644
--- a/gi/union.cpp
+++ b/gi/union.cpp
@@ -64,21 +64,19 @@ GJS_DEFINE_PRIV_FROM_JS(Union, gjs_union_class)
*/
static JSBool
union_new_resolve(JSContext *context,
- JSObject **obj,
- jsid *id,
- unsigned flags,
- JSObject **objp)
+ JS::HandleObject obj,
+ JS::HandleId id,
+ unsigned flags,
+ JS::MutableHandleObject objp)
{
Union *priv;
char *name;
JSBool ret = JS_TRUE;
- *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_GBOXED, "Resolve prop '%s' hook obj %p priv %p", name, *obj, priv);
if (priv == NULL) {
@@ -109,7 +107,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),
@@ -119,7 +117,7 @@ union_new_resolve(JSContext *context,
goto out;
}
- *objp = union_proto; /* we defined the prop in object_proto */
+ objp.set(union_proto); /* we defined the prop in object_proto */
}
g_base_info_unref( (GIBaseInfo*) method_info);
diff --git a/gjs/byteArray.cpp b/gjs/byteArray.cpp
index b5ff7a9..8f99f42 100644
--- a/gjs/byteArray.cpp
+++ b/gjs/byteArray.cpp
@@ -40,14 +40,14 @@ extern struct JSClass gjs_byte_array_class;
GJS_DEFINE_PRIV_FROM_JS(ByteArrayInstance, gjs_byte_array_class)
static JSBool byte_array_get_prop (JSContext *context,
- JSObject **obj,
- jsid *id,
- jsval *value_p);
+ JS::HandleObject obj,
+ JS::HandleId id,
+ JS::MutableHandleValue value_p);
static JSBool byte_array_set_prop (JSContext *context,
- JSObject **obj,
- jsid *id,
+ JS::HandleObject obj,
+ JS::HandleId id,
JSBool strict,
- jsval *value_p);
+ JS::MutableHandleValue value_p);
GJS_NATIVE_CONSTRUCTOR_DECLARE(byte_array);
static void byte_array_finalize (JSFreeOp *fop,
JSObject *obj);
@@ -81,13 +81,13 @@ gjs_typecheck_bytearray(JSContext *context,
static JSBool
gjs_value_from_gsize(JSContext *context,
gsize v,
- jsval *value_p)
+ JS::MutableHandleValue value_p)
{
if (v > (gsize) JSVAL_INT_MAX) {
- *value_p = INT_TO_JSVAL(v);
+ value_p.set(INT_TO_JSVAL(v));
return JS_TRUE;
} else {
- return JS_NewNumberValue(context, v, value_p);
+ return JS_NewNumberValue(context, v, value_p.address());
}
}
@@ -170,10 +170,10 @@ gjs_value_to_byte(JSContext *context,
static JSBool
byte_array_get_index(JSContext *context,
- JSObject *obj,
+ JS::HandleObject obj,
ByteArrayInstance *priv,
gsize idx,
- jsval *value_p)
+ JS::MutableHandleValue value_p)
{
gsize len;
guint8 *data;
@@ -188,7 +188,7 @@ byte_array_get_index(JSContext *context,
return JS_FALSE;
}
- *value_p = INT_TO_JSVAL(data[idx]);
+ value_p.set(INT_TO_JSVAL(data[idx]));
return JS_TRUE;
}
@@ -198,19 +198,19 @@ byte_array_get_index(JSContext *context,
*/
static JSBool
byte_array_get_prop(JSContext *context,
- JSObject **obj,
- jsid *id,
- jsval *value_p)
+ JS::HandleObject obj,
+ JS::HandleId id,
+ JS::MutableHandleValue 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 */
@@ -218,7 +218,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
@@ -230,14 +230,14 @@ byte_array_get_prop(JSContext *context,
static JSBool
byte_array_length_getter(JSContext *context,
- JSObject **obj,
- jsid *id,
- jsval *value_p)
+ JS::HandleObject obj,
+ JS::HandleId id,
+ JS::MutableHandleValue 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. */
@@ -251,23 +251,22 @@ byte_array_length_getter(JSContext *context,
static JSBool
byte_array_length_setter(JSContext *context,
- JSObject **obj,
- jsid *id,
- JSBool strict,
- jsval *value_p)
+ JS::HandleObject obj,
+ JS::HandleId id,
+ JSBool strict,
+ JS::MutableHandleValue 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 */
byte_array_ensure_array(priv);
- if (!gjs_value_to_gsize(context, *value_p,
- &len)) {
+ if (!gjs_value_to_gsize(context, value_p, &len)) {
gjs_throw(context,
"Can't set ByteArray length to non-integer");
return JS_FALSE;
@@ -278,15 +277,14 @@ byte_array_length_setter(JSContext *context,
static JSBool
byte_array_set_index(JSContext *context,
- JSObject *obj,
+ JS::HandleObject obj,
ByteArrayInstance *priv,
gsize idx,
- jsval *value_p)
+ JS::MutableHandleValue value_p)
{
guint8 v;
- if (!gjs_value_to_byte(context, *value_p,
- &v)) {
+ if (!gjs_value_to_byte(context, value_p, &v)) {
return JS_FALSE;
}
@@ -301,7 +299,7 @@ byte_array_set_index(JSContext *context,
g_array_index(priv->array, guint8, idx) = v;
/* Stop JS from storing a copy of the value */
- *value_p = JSVAL_VOID;
+ value_p.set(JSVAL_VOID);
return JS_TRUE;
}
@@ -311,20 +309,20 @@ byte_array_set_index(JSContext *context,
*/
static JSBool
byte_array_set_prop(JSContext *context,
- JSObject **obj,
- jsid *id,
- JSBool strict,
- jsval *value_p)
+ JS::HandleObject obj,
+ JS::HandleId id,
+ JSBool strict,
+ JS::MutableHandleValue 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 */
@@ -333,7 +331,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 */
diff --git a/gjs/importer.cpp b/gjs/importer.cpp
index cccd6a9..5bf922f 100644
--- a/gjs/importer.cpp
+++ b/gjs/importer.cpp
@@ -855,23 +855,21 @@ importer_new_enumerate(JSContext *context,
*/
static JSBool
importer_new_resolve(JSContext *context,
- JSObject **obj,
- jsid *id,
- unsigned flags,
- JSObject **objp)
+ JS::HandleObject obj,
+ JS::HandleId id,
+ unsigned flags,
+ JS::MutableHandleObject objp)
{
Importer *priv;
char *name;
JSBool ret = JS_TRUE;
jsid module_init_name;
- *objp = NULL;
-
module_init_name = gjs_context_get_const_string(context, GJS_STRING_MODULE_INIT);
- if (*id == module_init_name)
+ if (id == module_init_name)
return JS_TRUE;
- if (!gjs_get_string_id(context, *id, &name))
+ if (!gjs_get_string_id(context, id, &name))
return JS_FALSE;
/* let Object.prototype resolve these */
@@ -879,14 +877,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);
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.set(obj);
} else {
ret = JS_FALSE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]