Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- From 03cbb6cc7a5fb8dddd5fb41d3590855fd6a81355 Mon Sep 17 00:00:00 2001
- From: Tim Lunn <tim@feathertop.org>
- Date: Thu, 3 Jan 2013 12:59:54 +1100
- Subject: [PATCH 01/10] JS_BufferIsCompilableUnit API change
- ---
- modules/console.c | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
- diff --git a/modules/console.c b/modules/console.c
- index 71a95b4..a7e204e 100644
- --- a/modules/console.c
- +++ b/modules/console.c
- @@ -190,7 +190,7 @@ gjs_console_interact(JSContext *context,
- g_string_append(buffer, temp_buf);
- g_free(temp_buf);
- lineno++;
- - } while (!JS_BufferIsCompilableUnit(context, object, buffer->str, buffer->len));
- + } while (!JS_BufferIsCompilableUnit(context, JS_TRUE, object, buffer->str, buffer->len));
- JS_EvaluateScript(context, object, buffer->str, buffer->len, "typein",
- startline, &result);
- --
- 1.8.0
- From 9b1ffc1dd94f03097b2541c90f8d637163946540 Mon Sep 17 00:00:00 2001
- From: Tim Lunn <tim@feathertop.org>
- Date: Thu, 3 Jan 2013 14:13:45 +1100
- Subject: [PATCH 02/10] api change to JS_NumberValue
- JS_NewNumberValue is depreciated and removed in js188
- https://bugzilla.gnome.org/show_bug.cgi?id=690982
- ---
- gi/arg.c | 36 ++++++++++++++++++++++++------------
- gi/enumeration.c | 4 ++--
- gi/object.c | 4 ++--
- gi/value.c | 23 +++++++++++++++--------
- gjs/byteArray.c | 3 ++-
- gjs/jsapi-util.c | 3 ++-
- modules/cairo-context.c | 27 ++++++++++++++++++---------
- modules/mainloop.c | 18 ++++++++++--------
- 8 files changed, 75 insertions(+), 43 deletions(-)
- diff --git a/gi/arg.c b/gi/arg.c
- index 7c019d3..1602b59 100644
- --- a/gi/arg.c
- +++ b/gi/arg.c
- @@ -2377,34 +2377,44 @@ gjs_value_from_g_argument (JSContext *context,
- break;
- case GI_TYPE_TAG_INT32:
- - return JS_NewNumberValue(context, arg->v_int, value_p);
- + *value_p = JS_NumberValue(arg->v_int);
- + return JS_TRUE;
- case GI_TYPE_TAG_UINT32:
- - return JS_NewNumberValue(context, arg->v_uint, value_p);
- + *value_p = JS_NumberValue(arg->v_uint);
- + return JS_TRUE;
- case GI_TYPE_TAG_INT64:
- - return JS_NewNumberValue(context, arg->v_int64, value_p);
- + *value_p = JS_NumberValue(arg->v_int64);
- + return JS_TRUE;
- case GI_TYPE_TAG_UINT64:
- - return JS_NewNumberValue(context, arg->v_uint64, value_p);
- + *value_p = JS_NumberValue(arg->v_uint64);
- + return JS_TRUE;
- case GI_TYPE_TAG_UINT16:
- - return JS_NewNumberValue(context, arg->v_uint16, value_p);
- + *value_p = JS_NumberValue(arg->v_uint16);
- + return JS_TRUE;
- case GI_TYPE_TAG_INT16:
- - return JS_NewNumberValue(context, arg->v_int16, value_p);
- + *value_p = JS_NumberValue(arg->v_int16);
- + return JS_TRUE;
- case GI_TYPE_TAG_UINT8:
- - return JS_NewNumberValue(context, arg->v_uint8, value_p);
- + *value_p = JS_NumberValue(arg->v_uint8);
- + return JS_TRUE;
- case GI_TYPE_TAG_INT8:
- - return JS_NewNumberValue(context, arg->v_int8, value_p);
- + *value_p = JS_NumberValue(arg->v_int8);
- + return JS_TRUE;
- case GI_TYPE_TAG_FLOAT:
- - return JS_NewNumberValue(context, arg->v_float, value_p);
- + *value_p = JS_NumberValue(arg->v_float);
- + return JS_TRUE;
- case GI_TYPE_TAG_DOUBLE:
- - return JS_NewNumberValue(context, arg->v_double, value_p);
- + *value_p = JS_NumberValue(arg->v_double);
- + return JS_TRUE;
- case GI_TYPE_TAG_GTYPE:
- {
- @@ -2493,7 +2503,8 @@ gjs_value_from_g_argument (JSContext *context,
- if (_gjs_enum_value_is_valid(context, (GIEnumInfo *)interface_info, value_int64)) {
- jsval tmp;
- - if (JS_NewNumberValue(context, value_int64, &tmp))
- + tmp = JS_NumberValue(value_int64);
- + if (JSVAL_IS_NUMBER(tmp))
- value = tmp;
- }
- @@ -2504,7 +2515,8 @@ gjs_value_from_g_argument (JSContext *context,
- gtype = g_registered_type_info_get_g_type((GIRegisteredTypeInfo*)interface_info);
- if (_gjs_flags_value_is_valid(context, gtype, value_int64)) {
- jsval tmp;
- - if (JS_NewNumberValue(context, value_int64, &tmp))
- + tmp = JS_NumberValue(value_int64);
- + if (JSVAL_IS_NUMBER(tmp))
- value = tmp;
- }
- diff --git a/gi/enumeration.c b/gi/enumeration.c
- index 67c81db..6ff0d97 100644
- --- a/gi/enumeration.c
- +++ b/gi/enumeration.c
- @@ -84,8 +84,8 @@ gjs_define_enum_value(JSContext *context,
- gjs_debug(GJS_DEBUG_GENUM,
- "Defining enum value %s (fixed from %s) %" G_GINT64_MODIFIER "d",
- fixed_name, value_name, value_val);
- -
- - if (!JS_NewNumberValue(context, value_val, &value_js) ||
- + value_js = JS_NumberValue(value_val);
- + if (!JSVAL_IS_NUMBER(value_js) ||
- !JS_DefineProperty(context, in_object,
- fixed_name, value_js,
- NULL, NULL,
- diff --git a/gi/object.c b/gi/object.c
- index a5aac2e..f35161e 100644
- --- a/gi/object.c
- +++ b/gi/object.c
- @@ -1206,8 +1206,8 @@ real_connect_func(JSContext *context,
- signal_detail,
- closure,
- after);
- -
- - if (!JS_NewNumberValue(context, id, &retval)) {
- + retval = JS_NumberValue(id);
- + if (!JSVAL_IS_NUMBER(retval)) {
- g_signal_handler_disconnect(priv->gobj, id);
- goto out;
- }
- diff --git a/gi/value.c b/gi/value.c
- index 909742d..6cd076f 100644
- --- a/gi/value.c
- +++ b/gi/value.c
- @@ -610,9 +610,10 @@ convert_int_to_enum (JSContext *context,
- v_double = _gjs_enum_from_int ((GIEnumInfo *)info, v);
- g_base_info_unref(info);
- + return JS_FALSE;
- }
- -
- - return JS_NewNumberValue(context, v_double, value_p);
- + *value_p = JS_NumberValue(v_double);
- + return JS_TRUE;
- }
- static JSBool
- @@ -653,19 +654,23 @@ gjs_value_from_g_value_internal(JSContext *context,
- } else if (gtype == G_TYPE_INT) {
- int v;
- v = g_value_get_int(gvalue);
- - return JS_NewNumberValue(context, v, value_p);
- + *value_p = JS_NumberValue(v);
- + return JS_TRUE;
- } else if (gtype == G_TYPE_UINT) {
- uint v;
- v = g_value_get_uint(gvalue);
- - return JS_NewNumberValue(context, v, value_p);
- + *value_p = JS_NumberValue(v);
- + return JS_TRUE;
- } else if (gtype == G_TYPE_DOUBLE) {
- double d;
- d = g_value_get_double(gvalue);
- - return JS_NewNumberValue(context, d, value_p);
- + *value_p = JS_NumberValue(d);
- + return JS_TRUE;
- } else if (gtype == G_TYPE_FLOAT) {
- double d;
- d = g_value_get_float(gvalue);
- - return JS_NewNumberValue(context, d, value_p);
- + *value_p = JS_NumberValue(d);
- + return JS_TRUE;
- } else if (gtype == G_TYPE_BOOLEAN) {
- gboolean v;
- v = g_value_get_boolean(gvalue);
- @@ -816,14 +821,16 @@ gjs_value_from_g_value_internal(JSContext *context,
- g_value_init(&double_value, G_TYPE_DOUBLE);
- g_value_transform(gvalue, &double_value);
- v = g_value_get_double(&double_value);
- - return JS_NewNumberValue(context, v, value_p);
- + *value_p = JS_NumberValue(v);
- + return JS_TRUE;
- } else if (g_value_type_transformable(gtype, G_TYPE_INT)) {
- GValue int_value = { 0, };
- int v;
- g_value_init(&int_value, G_TYPE_INT);
- g_value_transform(gvalue, &int_value);
- v = g_value_get_int(&int_value);
- - return JS_NewNumberValue(context, v, value_p);
- + *value_p = JS_NumberValue(v);
- + return JS_TRUE;
- } else {
- gjs_throw(context,
- "Don't know how to convert GType %s to JavaScript object",
- diff --git a/gjs/byteArray.c b/gjs/byteArray.c
- index 825c296..02d0f9b 100644
- --- a/gjs/byteArray.c
- +++ b/gjs/byteArray.c
- @@ -94,7 +94,8 @@ gjs_value_from_gsize(JSContext *context,
- *value_p = INT_TO_JSVAL(v);
- return JS_TRUE;
- } else {
- - return JS_NewNumberValue(context, v, value_p);
- + *value_p = JS_NumberValue(v);
- + return JS_TRUE;
- }
- }
- diff --git a/gjs/jsapi-util.c b/gjs/jsapi-util.c
- index 6eab2ed..3a4c658 100644
- --- a/gjs/jsapi-util.c
- +++ b/gjs/jsapi-util.c
- @@ -823,7 +823,8 @@ gjs_date_from_time_t (JSContext *context, time_t time)
- date_class = JS_GET_CLASS(context, JSVAL_TO_OBJECT (date_prototype));
- - if (!JS_NewNumberValue(context, ((double) time) * 1000, &(args[0])))
- + args[0] = JS_NumberValue(((double) time) * 1000);
- + if (!JSVAL_IS_NUMBER(args[0]))
- gjs_fatal("Failed to convert time_t to number");
- date = JS_ConstructObjectWithArguments(context, date_class,
- diff --git a/modules/cairo-context.c b/modules/cairo-context.c
- index 7453494..ea23fdf 100644
- --- a/modules/cairo-context.c
- +++ b/modules/cairo-context.c
- @@ -88,9 +88,11 @@ _GJS_CAIRO_CONTEXT_DEFINE_FUNC_BEGIN(method) \
- if (!array) \
- return JS_FALSE; \
- jsval r; \
- - if (!JS_NewNumberValue(context, arg1, &r)) return JS_FALSE; \
- + r = JS_NumberValue(arg1); \
- + if (!JSVAL_IS_NUMBER(r)) return JS_FALSE; \
- if (!JS_SetElement(context, array, 0, &r)) return JS_FALSE; \
- - if (!JS_NewNumberValue(context, arg2, &r)) return JS_FALSE; \
- + r = JS_NumberValue(arg2); \
- + if (!JSVAL_IS_NUMBER(r)) return JS_FALSE; \
- if (!JS_SetElement(context, array, 1, &r)) return JS_FALSE; \
- JS_SET_RVAL(context, vp, OBJECT_TO_JSVAL(array)); \
- } \
- @@ -107,9 +109,11 @@ _GJS_CAIRO_CONTEXT_DEFINE_FUNC_BEGIN(method) \
- if (!array) \
- return JS_FALSE; \
- jsval r; \
- - if (!JS_NewNumberValue(context, arg1, &r)) return JS_FALSE; \
- + r = JS_NumberValue(arg1); \
- + if (!JSVAL_IS_NUMBER(r)) return JS_FALSE; \
- if (!JS_SetElement(context, array, 0, &r)) return JS_FALSE; \
- - if (!JS_NewNumberValue(context, arg2, &r)) return JS_FALSE; \
- + r = JS_NumberValue(arg2); \
- + if (!JSVAL_IS_NUMBER(r)) return JS_FALSE; \
- if (!JS_SetElement(context, array, 1, &r)) return JS_FALSE; \
- JS_SET_RVAL(context, vp, OBJECT_TO_JSVAL(array)); \
- } \
- @@ -126,13 +130,17 @@ _GJS_CAIRO_CONTEXT_DEFINE_FUNC_BEGIN(method) \
- if (!array) \
- return JS_FALSE; \
- jsval r; \
- - if (!JS_NewNumberValue(context, arg1, &r)) return JS_FALSE; \
- + r = JS_NumberValue(arg1); \
- + if (!JSVAL_IS_NUMBER(r)) return JS_FALSE; \
- if (!JS_SetElement(context, array, 0, &r)) return JS_FALSE; \
- - if (!JS_NewNumberValue(context, arg2, &r)) return JS_FALSE; \
- + r = JS_NumberValue(arg2); \
- + if (!JSVAL_IS_NUMBER(r)) return JS_FALSE; \
- if (!JS_SetElement(context, array, 1, &r)) return JS_FALSE; \
- - if (!JS_NewNumberValue(context, arg3, &r)) return JS_FALSE; \
- + r = JS_NumberValue(arg3); \
- + if (!JSVAL_IS_NUMBER(r)) return JS_FALSE; \
- if (!JS_SetElement(context, array, 2, &r)) return JS_FALSE; \
- - if (!JS_NewNumberValue(context, arg4, &r)) return JS_FALSE; \
- + r = JS_NumberValue(arg4); \
- + if (!JSVAL_IS_NUMBER(r)) return JS_FALSE; \
- if (!JS_SetElement(context, array, 3, &r)) return JS_FALSE; \
- JS_SET_RVAL(context, vp, OBJECT_TO_JSVAL(array)); \
- } \
- @@ -145,7 +153,8 @@ _GJS_CAIRO_CONTEXT_DEFINE_FUNC_BEGIN(method) \
- _GJS_CAIRO_CONTEXT_CHECK_NO_ARGS(method) \
- cr = gjs_cairo_context_get_context(context, obj); \
- ret = cfunc(cr); \
- - if (!JS_NewNumberValue(context, ret, &retval)) \
- + retval = JS_NumberValue(ret); \
- + if (!JSVAL_IS_NUMBER(retval)) \
- return JS_FALSE; \
- JS_SET_RVAL(context, vp, retval); \
- _GJS_CAIRO_CONTEXT_DEFINE_FUNC_END
- diff --git a/modules/mainloop.c b/modules/mainloop.c
- index cbf4069..c627736 100644
- --- a/modules/mainloop.c
- +++ b/modules/mainloop.c
- @@ -212,8 +212,8 @@ gjs_timeout_add(JSContext *context,
- */
- g_closure_add_invalidate_notifier(closure, GUINT_TO_POINTER(id),
- closure_invalidated);
- -
- - if (!JS_NewNumberValue(context, id, &retval))
- + retval = JS_NumberValue(id);
- + if (!JSVAL_IS_NUMBER(retval))
- return JS_FALSE;
- JS_SET_RVAL(context, vp, retval);
- @@ -255,12 +255,13 @@ gjs_timeout_add_seconds(JSContext *context,
- */
- g_closure_add_invalidate_notifier(closure, GUINT_TO_POINTER(id),
- closure_invalidated);
- + retval = JS_NumberValue(id);
- + if (JSVAL_IS_NUMBER(retval)){
- + JS_SET_RVAL(context, vp, retval);
- + return JS_TRUE;
- + }
- - if (!JS_NewNumberValue(context, id, &retval))
- - return JS_FALSE;
- - JS_SET_RVAL(context, vp, retval);
- -
- - return JS_TRUE;
- + return JS_FALSE;
- }
- static JSBool
- @@ -302,7 +303,8 @@ gjs_idle_add(JSContext *context,
- g_closure_add_invalidate_notifier(closure, GUINT_TO_POINTER(id),
- closure_invalidated);
- - if (!JS_NewNumberValue(context, id, &retval))
- + retval = JS_NumberValue(id);
- + if (!JSVAL_IS_NUMBER(retval))
- return JS_FALSE;
- JS_SET_RVAL(context, vp, retval);
- --
- 1.8.0
- From 6ec24216e5435764c30f344124137c61b676bfd1 Mon Sep 17 00:00:00 2001
- From: Tim Lunn <tim@feathertop.org>
- Date: Thu, 3 Jan 2013 12:59:54 +1100
- Subject: [PATCH 03/10] change build version to mozjs188
- ---
- configure.ac | 2 +-
- gjs-1.0.pc.in | 2 +-
- gjs-internals-1.0.pc.in | 2 +-
- 3 files changed, 3 insertions(+), 3 deletions(-)
- diff --git a/configure.ac b/configure.ac
- index 72e946a..f0a699e 100644
- --- a/configure.ac
- +++ b/configure.ac
- @@ -94,7 +94,7 @@ CFLAGS="$save_CFLAGS"
- GOBJECT_INTROSPECTION_REQUIRE([1.33.10])
- -common_packages="gmodule-2.0 gthread-2.0 gio-2.0 >= glib_required_version mozjs185"
- +common_packages="gmodule-2.0 gthread-2.0 gio-2.0 >= glib_required_version mozjs188"
- gjs_packages="gobject-introspection-1.0 libffi $common_packages"
- gjs_cairo_gobject_packages="cairo-gobject $common_packages"
- gjs_cairo_packages="cairo $common_packages"
- diff --git a/gjs-1.0.pc.in b/gjs-1.0.pc.in
- index e3ae371..ad85fa3 100644
- --- a/gjs-1.0.pc.in
- +++ b/gjs-1.0.pc.in
- @@ -10,7 +10,7 @@ gjs_console=${bindir}/gjs-console
- Cflags: -I${includedir}/gjs-1.0
- Requires: gobject-2.0
- -Requires.private: gobject-introspection-1.0 mozjs185
- +Requires.private: gobject-introspection-1.0 mozjs188
- Libs: -L${libdir} -lgjs
- Name: gjs-1.0
- diff --git a/gjs-internals-1.0.pc.in b/gjs-internals-1.0.pc.in
- index b898b2b..7a86f66 100644
- --- a/gjs-internals-1.0.pc.in
- +++ b/gjs-internals-1.0.pc.in
- @@ -10,7 +10,7 @@ jsdir=@gjsjsdir@
- jsnativedir=@gjsnativedir@
- Cflags: -I${includedir}/gjs-1.0
- -Requires: gjs-1.0 gobject-introspection-1.0 mozjs185
- +Requires: gjs-1.0 gobject-introspection-1.0 mozjs188
- Name: gjs-internals-1.0
- Description: Internal API for gjs (for modules and embedders); uses mozjs
- --
- 1.8.0
- From e0d772130437ae7b7c0399477eb48c8e14b2a5c5 Mon Sep 17 00:00:00 2001
- From: Tim Lunn <tim@feathertop.org>
- Date: Thu, 3 Jan 2013 13:51:26 +1100
- Subject: [PATCH 04/10] define JSVAL_IS_OBJECT
- JSVAL_IS_OBJECT has been removed, for now just redefine it in compat.h
- ---
- gjs/compat.h | 3 +++
- 1 file changed, 3 insertions(+)
- diff --git a/gjs/compat.h b/gjs/compat.h
- index f5e9634..b2a7e20 100644
- --- a/gjs/compat.h
- +++ b/gjs/compat.h
- @@ -49,6 +49,9 @@ G_BEGIN_DECLS
- * GJS_NATIVE_CONSTRUCTOR_DECLARE:
- * Prototype a constructor.
- */
- +
- +#define JSVAL_IS_OBJECT(obj) !JSVAL_IS_PRIMITIVE(obj)
- +
- #define GJS_NATIVE_CONSTRUCTOR_DECLARE(name) \
- static JSBool \
- gjs_##name##_constructor(JSContext *context, \
- --
- 1.8.0
- From d18d6feb0e918f8330f875e08082be3d64619637 Mon Sep 17 00:00:00 2001
- From: Tim Lunn <tim@feathertop.org>
- Date: Thu, 3 Jan 2013 14:36:15 +1100
- Subject: [PATCH 05/10] api change JS_GetClass
- JS_GetClass no longer takes *context as first argument,
- consequently the JS_GET_CLASS Macro is also removed.
- ---
- gi/boxed.c | 8 ++++----
- gi/gerror.c | 6 +++---
- gi/object.c | 4 ++--
- gi/param.c | 4 ++--
- gi/union.c | 6 +++---
- gjs/jsapi-dynamic-class.c | 2 +-
- gjs/jsapi-util.c | 16 ++++++----------
- gjs/stack.c | 2 +-
- 8 files changed, 22 insertions(+), 26 deletions(-)
- diff --git a/gi/boxed.c b/gi/boxed.c
- index f46cec5..bbea2c7 100644
- --- a/gi/boxed.c
- +++ b/gi/boxed.c
- @@ -598,7 +598,7 @@ get_nested_interface_object (JSContext *context,
- offset = g_field_info_get_offset (field_info);
- obj = JS_NewObjectWithGivenProto(context,
- - JS_GET_CLASS(context, proto), proto,
- + JS_GetClass(proto), proto,
- gjs_get_import_global (context));
- if (obj == NULL)
- @@ -1001,7 +1001,7 @@ gjs_lookup_boxed_class(JSContext *context,
- prototype = gjs_lookup_boxed_prototype(context, info);
- - return JS_GET_CLASS(context, prototype);
- + return JS_GetClass(prototype);
- }
- static gboolean
- @@ -1242,7 +1242,7 @@ gjs_define_boxed_class(JSContext *context,
- JS_SetPrivate(context, prototype, priv);
- gjs_debug(GJS_DEBUG_GBOXED, "Defined class %s prototype is %p class %p in object %p",
- - constructor_name, prototype, JS_GET_CLASS(context, prototype), in_object);
- + constructor_name, prototype, JS_GetClass(prototype), in_object);
- priv->can_allocate_directly = struct_is_simple (priv->info);
- @@ -1284,7 +1284,7 @@ gjs_boxed_from_c_struct(JSContext *context,
- proto_priv = priv_from_js(context, proto);
- obj = JS_NewObjectWithGivenProto(context,
- - JS_GET_CLASS(context, proto), proto,
- + JS_GetClass(proto), proto,
- gjs_get_import_global (context));
- GJS_INC_COUNTER(boxed);
- diff --git a/gi/gerror.c b/gi/gerror.c
- index ad75721..ea36b18 100644
- --- a/gi/gerror.c
- +++ b/gi/gerror.c
- @@ -380,7 +380,7 @@ gjs_lookup_error_class(JSContext *context,
- prototype = gjs_lookup_error_prototype(context, info);
- - return JS_GET_CLASS(context, prototype);
- + return JS_GetClass(prototype);
- }
- JSBool
- @@ -463,7 +463,7 @@ gjs_define_error_class(JSContext *context,
- JS_SetPrivate(context, prototype, priv);
- gjs_debug(GJS_DEBUG_GBOXED, "Defined class %s prototype is %p class %p in object %p",
- - constructor_name, prototype, JS_GET_CLASS(context, prototype), in_object);
- + constructor_name, prototype, JS_GetClass(prototype), in_object);
- gjs_define_enum_values(context, constructor, priv->info);
- @@ -590,7 +590,7 @@ gjs_error_from_gerror(JSContext *context,
- proto_priv = priv_from_js(context, proto);
- obj = JS_NewObjectWithGivenProto(context,
- - JS_GET_CLASS(context, proto), proto,
- + JS_GetClass(proto), proto,
- gjs_get_import_global (context));
- GJS_INC_COUNTER(gerror);
- diff --git a/gi/object.c b/gi/object.c
- index f35161e..04c7a1a 100644
- --- a/gi/object.c
- +++ b/gi/object.c
- @@ -1692,7 +1692,7 @@ gjs_define_object_class(JSContext *context,
- JS_SetPrivate(context, prototype, priv);
- gjs_debug(GJS_DEBUG_GOBJECT, "Defined class %s prototype %p class %p in object %p",
- - constructor_name, prototype, JS_GET_CLASS(context, prototype), in_object);
- + constructor_name, prototype, JS_GetClass(prototype), in_object);
- if (info)
- gjs_define_static_methods(context, constructor, gtype, info);
- @@ -1753,7 +1753,7 @@ gjs_object_from_g_object(JSContext *context,
- JS_BeginRequest(context);
- obj = JS_NewObjectWithGivenProto(context,
- - JS_GET_CLASS(context, proto), proto,
- + JS_GetClass(proto), proto,
- gjs_get_import_global (context));
- JS_EndRequest(context);
- diff --git a/gi/param.c b/gi/param.c
- index c8594d8..8e6d67d 100644
- --- a/gi/param.c
- +++ b/gi/param.c
- @@ -536,7 +536,7 @@ gjs_define_param_class(JSContext *context,
- *prototype_p = prototype;
- gjs_debug(GJS_DEBUG_GPARAM, "Defined class %s prototype is %p class %p in object %p",
- - constructor_name, prototype, JS_GET_CLASS(context, prototype), in_object);
- + constructor_name, prototype, JS_GetClass(prototype), in_object);
- return JS_TRUE;
- }
- @@ -561,7 +561,7 @@ gjs_param_from_g_param(JSContext *context,
- proto = gjs_lookup_param_prototype(context);
- obj = JS_NewObjectWithGivenProto(context,
- - JS_GET_CLASS(context, proto), proto,
- + JS_GetClass(proto), proto,
- gjs_get_import_global (context));
- GJS_INC_COUNTER(param);
- diff --git a/gi/union.c b/gi/union.c
- index b21c72a..bfd7501 100644
- --- a/gi/union.c
- +++ b/gi/union.c
- @@ -380,7 +380,7 @@ gjs_lookup_union_class(JSContext *context,
- prototype = gjs_lookup_union_prototype(context, info);
- - return JS_GET_CLASS(context, prototype);
- + return JS_GetClass(prototype);
- }
- JSBool
- @@ -463,7 +463,7 @@ gjs_define_union_class(JSContext *context,
- JS_SetPrivate(context, prototype, priv);
- gjs_debug(GJS_DEBUG_GBOXED, "Defined class %s prototype is %p class %p in object %p",
- - constructor_name, prototype, JS_GET_CLASS(context, prototype), in_object);
- + constructor_name, prototype, JS_GetClass(prototype), in_object);
- value = OBJECT_TO_JSVAL(gjs_gtype_create_gtype_wrapper(context, gtype));
- JS_DefineProperty(context, constructor, "$gtype", value,
- @@ -507,7 +507,7 @@ gjs_union_from_c_union(JSContext *context,
- proto = gjs_lookup_union_prototype(context, (GIUnionInfo*) info);
- obj = JS_NewObjectWithGivenProto(context,
- - JS_GET_CLASS(context, proto), proto,
- + JS_GetClass(proto), proto,
- gjs_get_import_global (context));
- GJS_INC_COUNTER(boxed);
- diff --git a/gjs/jsapi-dynamic-class.c b/gjs/jsapi-dynamic-class.c
- index d2648d8..e0df4dc 100644
- --- a/gjs/jsapi-dynamic-class.c
- +++ b/gjs/jsapi-dynamic-class.c
- @@ -184,7 +184,7 @@ gjs_typecheck_instance(JSContext *context,
- {
- if (!JS_InstanceOf(context, obj, static_clasp, NULL)) {
- if (throw) {
- - JSClass *obj_class = JS_GET_CLASS(context, obj);
- + JSClass *obj_class = JS_GetClass(obj);
- gjs_throw_custom(context, "TypeError",
- "Object %p is not a subclass of %s, it's a %s",
- diff --git a/gjs/jsapi-util.c b/gjs/jsapi-util.c
- index 3a4c658..7c9ca02 100644
- --- a/gjs/jsapi-util.c
- +++ b/gjs/jsapi-util.c
- @@ -220,7 +220,7 @@ gjs_throw_abstract_constructor_error(JSContext *context,
- if (JSVAL_IS_OBJECT(callee)) {
- if (gjs_object_get_property(context, JSVAL_TO_OBJECT(callee),
- "prototype", &prototype)) {
- - proto_class = JS_GetClass(context, JSVAL_TO_OBJECT(prototype));
- + proto_class = JS_GetClass(JSVAL_TO_OBJECT(prototype));
- name = proto_class->name;
- }
- }
- @@ -348,7 +348,7 @@ gjs_value_debug_string(JSContext *context,
- */
- JSClass *klass;
- - klass = JS_GET_CLASS(context, JSVAL_TO_OBJECT(value));
- + klass = JS_GetClass(JSVAL_TO_OBJECT(value));
- if (klass != NULL) {
- str = JS_NewStringCopyZ(context, klass->name);
- JS_ClearPendingException(context);
- @@ -814,26 +814,22 @@ gjs_date_from_time_t (JSContext *context, time_t time)
- if (!JS_EnterLocalRootScope(context))
- return JSVAL_VOID;
- - if (!JS_GetClassObject(context, JS_GetGlobalObject(context), JSProto_Date,
- + if (!JS_GetClassObject(contect, JS_GetGlobalObject(context), JSProto_Date,
- &date_constructor))
- gjs_fatal("Failed to lookup Date prototype");
- if (!JS_GetProperty(context, date_constructor, "prototype", &date_prototype))
- gjs_fatal("Failed to get prototype from Date constructor");
- - date_class = JS_GET_CLASS(context, JSVAL_TO_OBJECT (date_prototype));
- -
- args[0] = JS_NumberValue(((double) time) * 1000);
- if (!JSVAL_IS_NUMBER(args[0]))
- gjs_fatal("Failed to convert time_t to number");
- - date = JS_ConstructObjectWithArguments(context, date_class,
- - NULL, NULL, 1, args);
- -
- + date = JS_New(context, JSVAL_TO_OBJECT (date_prototype), 1, args);
- +
- result = OBJECT_TO_JSVAL(date);
- JS_LeaveLocalRootScope(context);
- - JS_EndRequest(context);
- -
- + JS_EndRequest(context);
- return result;
- }
- diff --git a/gjs/stack.c b/gjs/stack.c
- index 54317d6..aec76ed 100644
- --- a/gjs/stack.c
- +++ b/gjs/stack.c
- @@ -68,7 +68,7 @@ jsvalue_to_string(JSContext* cx, jsval val, gboolean* is_string)
- if (!value_str)
- value = g_strdup("[unknown function]");
- } else {
- - value = g_strdup_printf("[object %s]", JS_GetClass(cx, obj)->name);
- + value = g_strdup_printf("[object %s]", JS_GetClass(obj)->name);
- }
- }
- --
- 1.8.0
- From 6f035d6118002eaef64c0581d70e9e6773ca4038 Mon Sep 17 00:00:00 2001
- From: Tim Lunn <tim@feathertop.org>
- Date: Thu, 3 Jan 2013 15:08:19 +1100
- Subject: [PATCH 06/10] JS_SetPrivate/GetPrivate no longer require context
- argument
- ---
- gi/boxed.c | 43 +++++++++++++++++++++----------------------
- gi/function.c | 13 ++++++-------
- gi/gerror.c | 8 ++++----
- gi/gtype.c | 8 ++++----
- gi/interface.c | 14 +++++++-------
- gi/keep-alive.c | 4 ++--
- gi/ns.c | 16 ++++++++--------
- gi/object.c | 46 +++++++++++++++++++++++-----------------------
- gi/param.c | 10 +++++-----
- gi/repo.c | 14 +++++++-------
- gi/union.c | 20 ++++++++++----------
- gjs/byteArray.c | 24 ++++++++++++------------
- gjs/importer.c | 25 ++++++++++++-------------
- gjs/jsapi-dynamic-class.c | 2 +-
- gjs/jsapi-util.c | 10 +++++-----
- modules/cairo-context.c | 2 +-
- modules/cairo-path.c | 6 +++---
- modules/cairo-pattern.c | 6 +++---
- modules/cairo-surface.c | 6 +++---
- 19 files changed, 137 insertions(+), 140 deletions(-)
- diff --git a/gi/boxed.c b/gi/boxed.c
- index bbea2c7..2d26301 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) {
- @@ -443,13 +443,13 @@ GJS_NATIVE_CONSTRUCTOR_DECLARE(boxed)
- GJS_INC_COUNTER(boxed);
- g_assert(priv_from_js(context, object) == NULL);
- - JS_SetPrivate(context, object, priv);
- + JS_SetPrivate(object, priv);
- gjs_debug_lifecycle(GJS_DEBUG_GBOXED,
- "boxed constructor, obj %p priv %p",
- object, priv);
- - proto = JS_GetPrototype(context, object);
- + proto = JS_GetPrototype(object);
- gjs_debug_lifecycle(GJS_DEBUG_GBOXED, "boxed instance __proto__ is %p", proto);
- /* If we're the prototype, then post-construct we'll fill in priv->info.
- * If we are not the prototype, though, then we'll get ->info from the
- @@ -606,7 +606,7 @@ get_nested_interface_object (JSContext *context,
- GJS_INC_COUNTER(boxed);
- priv = g_slice_new0(Boxed);
- - JS_SetPrivate(context, obj, priv);
- + JS_SetPrivate(obj, priv);
- priv->info = (GIBoxedInfo*) interface_info;
- g_base_info_ref( (GIBaseInfo*) priv->info);
- priv->gtype = g_registered_type_info_get_g_type ((GIRegisteredTypeInfo*) interface_info);
- @@ -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;
- @@ -1239,7 +1238,7 @@ gjs_define_boxed_class(JSContext *context,
- g_base_info_ref( (GIBaseInfo*) priv->info);
- priv->gtype = g_registered_type_info_get_g_type ((GIRegisteredTypeInfo*) priv->info);
- - JS_SetPrivate(context, prototype, priv);
- + JS_SetPrivate(prototype, priv);
- gjs_debug(GJS_DEBUG_GBOXED, "Defined class %s prototype is %p class %p in object %p",
- constructor_name, prototype, JS_GetClass(prototype), in_object);
- @@ -1293,7 +1292,7 @@ gjs_boxed_from_c_struct(JSContext *context,
- *priv = *proto_priv;
- g_base_info_ref( (GIBaseInfo*) priv->info);
- - JS_SetPrivate(context, obj, priv);
- + JS_SetPrivate(obj, priv);
- if ((flags & GJS_BOXED_CREATION_NO_COPY) != 0) {
- /* we need to create a JS Boxed which references the
- diff --git a/gi/function.c b/gi/function.c
- index a37fb85..4b2f89c 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;
- @@ -1366,9 +1366,8 @@ static struct JSClass gjs_function_class = {
- JS_ConvertStub,
- function_finalize,
- NULL,
- - NULL,
- function_call,
- - NULL, NULL, NULL, NULL, NULL
- + NULL, NULL
- };
- static JSPropertySpec gjs_function_proto_props[] = {
- @@ -1549,7 +1548,7 @@ function_new(JSContext *context,
- JS_GetProperty(context, global, "Function", &native_function);
- /* We take advantage from that fact that Function.__proto__ is Function.prototype */
- - parent_proto = JS_GetPrototype(context, JSVAL_TO_OBJECT(native_function));
- + parent_proto = JS_GetPrototype(JSVAL_TO_OBJECT(native_function));
- prototype = JS_InitClass(context, global,
- /* parent prototype JSObject* for
- @@ -1594,7 +1593,7 @@ function_new(JSContext *context,
- GJS_INC_COUNTER(function);
- g_assert(priv_from_js(context, function) == NULL);
- - JS_SetPrivate(context, function, priv);
- + JS_SetPrivate(function, priv);
- gjs_debug_lifecycle(GJS_DEBUG_GFUNCTION,
- "function constructor, obj %p priv %p", function, priv);
- diff --git a/gi/gerror.c b/gi/gerror.c
- index ea36b18..5fd12b6 100644
- --- a/gi/gerror.c
- +++ b/gi/gerror.c
- @@ -77,13 +77,13 @@ GJS_NATIVE_CONSTRUCTOR_DECLARE(error)
- GJS_INC_COUNTER(gerror);
- g_assert(priv_from_js(context, object) == NULL);
- - JS_SetPrivate(context, object, priv);
- + JS_SetPrivate(object, priv);
- gjs_debug_lifecycle(GJS_DEBUG_GERROR,
- "GError constructor, obj %p priv %p",
- object, priv);
- - proto = JS_GetPrototype(context, object);
- + proto = JS_GetPrototype(object);
- gjs_debug_lifecycle(GJS_DEBUG_GERROR, "GError instance __proto__ is %p", proto);
- /* If we're the prototype, then post-construct we'll fill in priv->info.
- @@ -460,7 +460,7 @@ gjs_define_error_class(JSContext *context,
- g_base_info_ref( (GIBaseInfo*) priv->info);
- priv->domain = g_quark_from_string (g_enum_info_get_error_domain(priv->info));
- - JS_SetPrivate(context, prototype, priv);
- + JS_SetPrivate(prototype, priv);
- gjs_debug(GJS_DEBUG_GBOXED, "Defined class %s prototype is %p class %p in object %p",
- constructor_name, prototype, JS_GetClass(prototype), in_object);
- @@ -595,7 +595,7 @@ gjs_error_from_gerror(JSContext *context,
- GJS_INC_COUNTER(gerror);
- priv = g_slice_new0(Error);
- - JS_SetPrivate(context, obj, priv);
- + JS_SetPrivate(obj, priv);
- priv->info = info;
- priv->domain = proto_priv->domain;
- g_base_info_ref( (GIBaseInfo*) priv->info);
- diff --git a/gi/gtype.c b/gi/gtype.c
- index ba3954c..eb8a410 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)
- @@ -134,7 +134,7 @@ gjs_gtype_create_gtype_wrapper (JSContext *context,
- if (object == NULL)
- goto out;
- - JS_SetPrivate(context, object, GSIZE_TO_POINTER(gtype));
- + JS_SetPrivate(object, GSIZE_TO_POINTER(gtype));
- g_type_set_qdata(gtype, gjs_get_gtype_wrapper_quark(), object);
- out:
- diff --git a/gi/interface.c b/gi/interface.c
- index 43d7019..d223c3c 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);
- }
- @@ -231,7 +231,7 @@ gjs_define_interface_class(JSContext *context,
- priv->info = info;
- priv->gtype = g_registered_type_info_get_g_type(priv->info);
- g_base_info_ref((GIBaseInfo*)priv->info);
- - JS_SetPrivate(context, prototype, priv);
- + JS_SetPrivate(prototype, priv);
- gjs_define_static_methods(context, constructor, priv->gtype, priv->info);
- diff --git a/gi/keep-alive.c b/gi/keep-alive.c
- index 581c9ad..ce56e35 100644
- --- a/gi/keep-alive.c
- +++ b/gi/keep-alive.c
- @@ -133,7 +133,7 @@ keep_alive_trace(JSTracer *tracer,
- {
- KeepAlive *priv;
- - priv = JS_GetPrivate(tracer->context, obj);
- + priv = JS_GetPrivate(obj);
- if (priv == NULL) /* prototype */
- return;
- @@ -251,7 +251,7 @@ gjs_keep_alive_new(JSContext *context)
- priv->children = g_hash_table_new_full(child_hash, child_equal, NULL, child_free);
- g_assert(priv_from_js(context, keep_alive) == NULL);
- - JS_SetPrivate(context, keep_alive, priv);
- + JS_SetPrivate(keep_alive, priv);
- gjs_debug_lifecycle(GJS_DEBUG_KEEP_ALIVE,
- "keep_alive constructor, obj %p priv %p", keep_alive, priv);
- diff --git a/gi/ns.c b/gi/ns.c
- index 9bf7ef2..8a2d811 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,
- @@ -230,7 +230,7 @@ ns_new(JSContext *context,
- GJS_INC_COUNTER(ns);
- g_assert(priv_from_js(context, ns) == NULL);
- - JS_SetPrivate(context, ns, priv);
- + JS_SetPrivate(ns, priv);
- gjs_debug_lifecycle(GJS_DEBUG_GNAMESPACE, "ns constructor, obj %p priv %p", ns, priv);
- diff --git a/gi/object.c b/gi/object.c
- index 04c7a1a..7d24bae 100644
- --- a/gi/object.c
- +++ b/gi/object.c
- @@ -212,7 +212,7 @@ static inline ObjectInstance *
- proto_priv_from_js(JSContext *context,
- JSObject *obj)
- {
- - return priv_from_js(context, JS_GetPrototype(context, obj));
- + return priv_from_js(context, JS_GetPrototype(obj));
- }
- /* a hook on getting a property; set value_p to override property's value.
- @@ -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);
- @@ -397,7 +397,7 @@ find_vfunc_on_parent(GIObjectInfo *info,
- static JSBool
- object_instance_new_resolve_no_info(JSContext *context,
- - JSObject *obj,
- + JSObject *obj,
- JSObject **objp,
- ObjectInstance *priv,
- char *name)
- @@ -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;
- }
- @@ -543,7 +543,7 @@ object_instance_new_resolve(JSContext *context,
- }
- gjs_define_function(context, obj, priv->gtype, vfunc);
- - *objp = obj;
- + *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);
- }
- @@ -838,7 +838,7 @@ init_object_private (JSContext *context,
- GJS_INC_COUNTER(object);
- g_assert(priv_from_js(context, object) == NULL);
- - JS_SetPrivate(context, object, priv);
- + JS_SetPrivate(object, priv);
- gjs_debug_lifecycle(GJS_DEBUG_GOBJECT,
- "obj instance constructor, obj %p priv %p", object, priv);
- @@ -1026,7 +1026,7 @@ object_instance_trace(JSTracer *tracer,
- ObjectInstance *priv;
- GList *iter;
- - priv = JS_GetPrivate(tracer->context, obj);
- + priv = JS_GetPrivate(obj);
- for (iter = priv->signals; iter; iter = iter->next) {
- ConnectData *cd = iter->data;
- @@ -1689,7 +1689,7 @@ gjs_define_object_class(JSContext *context,
- g_base_info_ref( (GIBaseInfo*) priv->info);
- priv->gtype = gtype;
- priv->klass = g_type_class_ref (gtype);
- - JS_SetPrivate(context, prototype, priv);
- + JS_SetPrivate(prototype, priv);
- gjs_debug(GJS_DEBUG_GOBJECT, "Defined class %s prototype %p class %p in object %p",
- constructor_name, prototype, JS_GetClass(prototype), in_object);
- diff --git a/gi/param.c b/gi/param.c
- index 8e6d67d..e305351 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);
- @@ -566,7 +566,7 @@ gjs_param_from_g_param(JSContext *context,
- GJS_INC_COUNTER(param);
- priv = g_slice_new0(Param);
- - JS_SetPrivate(context, obj, priv);
- + JS_SetPrivate(obj, priv);
- priv->gparam = gparam;
- g_param_spec_ref (gparam);
- diff --git a/gi/repo.c b/gi/repo.c
- index 86dcd19..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);
- @@ -293,7 +293,7 @@ repo_new(JSContext *context)
- GJS_INC_COUNTER(repo);
- g_assert(priv_from_js(context, repo) == NULL);
- - JS_SetPrivate(context, repo, priv);
- + JS_SetPrivate(repo, priv);
- gjs_debug_lifecycle(GJS_DEBUG_GREPO,
- "repo constructor, obj %p priv %p", repo, priv);
- diff --git a/gi/union.c b/gi/union.c
- index bfd7501..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),
- @@ -202,13 +202,13 @@ GJS_NATIVE_CONSTRUCTOR_DECLARE(union)
- GJS_INC_COUNTER(boxed);
- g_assert(priv_from_js(context, object) == NULL);
- - JS_SetPrivate(context, object, priv);
- + JS_SetPrivate(object, priv);
- gjs_debug_lifecycle(GJS_DEBUG_GBOXED,
- "union constructor, obj %p priv %p",
- object, priv);
- - proto = JS_GetPrototype(context, object);
- + proto = JS_GetPrototype(object);
- gjs_debug_lifecycle(GJS_DEBUG_GBOXED, "union instance __proto__ is %p", proto);
- /* If we're the prototype, then post-construct we'll fill in priv->info.
- @@ -460,7 +460,7 @@ gjs_define_union_class(JSContext *context,
- priv->info = info;
- g_base_info_ref( (GIBaseInfo*) priv->info);
- priv->gtype = gtype;
- - JS_SetPrivate(context, prototype, priv);
- + JS_SetPrivate(prototype, priv);
- gjs_debug(GJS_DEBUG_GBOXED, "Defined class %s prototype is %p class %p in object %p",
- constructor_name, prototype, JS_GetClass(prototype), in_object);
- @@ -512,7 +512,7 @@ gjs_union_from_c_union(JSContext *context,
- GJS_INC_COUNTER(boxed);
- priv = g_slice_new0(Union);
- - JS_SetPrivate(context, obj, priv);
- + JS_SetPrivate(obj, priv);
- priv->info = info;
- g_base_info_ref( (GIBaseInfo *) priv->info);
- priv->gtype = gtype;
- diff --git a/gjs/byteArray.c b/gjs/byteArray.c
- index 02d0f9b..bf4b1b2 100644
- --- a/gjs/byteArray.c
- +++ b/gjs/byteArray.c
- @@ -50,8 +50,8 @@ static JSBool byte_array_set_prop (JSContext *context,
- 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);
- @@ -360,8 +360,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)
- {
- @@ -375,7 +375,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);
- @@ -395,15 +395,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;
- }
- }
- @@ -453,7 +453,7 @@ GJS_NATIVE_CONSTRUCTOR_DECLARE(byte_array)
- priv = g_slice_new0(ByteArrayInstance);
- priv->array = gjs_g_byte_array_new(preallocated_length);
- g_assert(priv_from_js(context, object) == NULL);
- - JS_SetPrivate(context, object, priv);
- + JS_SetPrivate(object, priv);
- GJS_NATIVE_CONSTRUCTOR_FINISH(byte_array);
- @@ -616,7 +616,7 @@ byte_array_new(JSContext *context)
- priv = g_slice_new0(ByteArrayInstance);
- g_assert(priv_from_js(context, array) == NULL);
- - JS_SetPrivate(context, array, priv);
- + JS_SetPrivate(array, priv);
- return array;
- }
- @@ -868,7 +868,7 @@ gjs_byte_array_from_byte_array (JSContext *context,
- priv = g_slice_new0(ByteArrayInstance);
- g_assert(priv_from_js(context, object) == NULL);
- - JS_SetPrivate(context, object, priv);
- + JS_SetPrivate(object, priv);
- priv->array = g_byte_array_new();
- priv->array->data = g_memdup(array->data, array->len);
- priv->array->len = array->len;
- @@ -897,7 +897,7 @@ gjs_byte_array_from_bytes (JSContext *context,
- priv = g_slice_new0(ByteArrayInstance);
- g_assert(priv_from_js(context, object) == NULL);
- - JS_SetPrivate(context, object, priv);
- + JS_SetPrivate(object, priv);
- priv->bytes = g_bytes_ref (bytes);
- return object;
- diff --git a/gjs/importer.c b/gjs/importer.c
- index 0a4b1c9..7cdf2c3 100644
- --- a/gjs/importer.c
- +++ b/gjs/importer.c
- @@ -751,7 +751,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)
- @@ -773,12 +773,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)) {
- @@ -941,8 +942,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)
- {
- @@ -952,7 +953,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 */
- @@ -960,16 +961,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;
- }
- @@ -1078,7 +1077,7 @@ importer_new(JSContext *context)
- GJS_INC_COUNTER(importer);
- g_assert(priv_from_js(context, importer) == NULL);
- - JS_SetPrivate(context, importer, priv);
- + JS_SetPrivate(importer, priv);
- gjs_debug_lifecycle(GJS_DEBUG_IMPORTER,
- "importer constructor, obj %p priv %p", importer, priv);
- diff --git a/gjs/jsapi-dynamic-class.c b/gjs/jsapi-dynamic-class.c
- index e0df4dc..ab8c530 100644
- --- a/gjs/jsapi-dynamic-class.c
- +++ b/gjs/jsapi-dynamic-class.c
- @@ -52,7 +52,7 @@ gjs_new_object_for_constructor(JSContext *context,
- jsval prototype;
- callee = JS_CALLEE(context, vp);
- - parent = JS_GetParent(context, JSVAL_TO_OBJECT (callee));
- + parent = JS_GetParent(JSVAL_TO_OBJECT (callee));
- if (!gjs_object_get_property(context, JSVAL_TO_OBJECT (callee), "prototype",
- &prototype))
- diff --git a/gjs/jsapi-util.c b/gjs/jsapi-util.c
- index 7c9ca02..eb91c6d 100644
- --- a/gjs/jsapi-util.c
- +++ b/gjs/jsapi-util.c
- @@ -85,7 +85,7 @@ gjs_runtime_get_context(JSRuntime *runtime)
- static JSClass global_class = {
- "GjsGlobal", JSCLASS_GLOBAL_FLAGS,
- JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_StrictPropertyStub,
- - JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, JS_FinalizeStub,
- + JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub,
- JSCLASS_NO_OPTIONAL_MEMBERS
- };
- @@ -481,7 +481,7 @@ gjs_explain_scope(JSContext *context,
- g_string_append_printf(chain, "%p %s",
- parent, debug);
- g_free(debug);
- - parent = JS_GetParent(context, parent);
- + parent = JS_GetParent(parent);
- }
- gjs_debug(GJS_DEBUG_SCOPE,
- " Chain: %s",
- @@ -814,7 +814,7 @@ gjs_date_from_time_t (JSContext *context, time_t time)
- if (!JS_EnterLocalRootScope(context))
- return JSVAL_VOID;
- - if (!JS_GetClassObject(contect, JS_GetGlobalObject(context), JSProto_Date,
- + if (!JS_GetClassObject(context, JS_GetGlobalObject(context), JSProto_Date,
- &date_constructor))
- gjs_fatal("Failed to lookup Date prototype");
- @@ -826,7 +826,7 @@ gjs_date_from_time_t (JSContext *context, time_t time)
- gjs_fatal("Failed to convert time_t to number");
- date = JS_New(context, JSVAL_TO_OBJECT (date_prototype), 1, args);
- -
- +
- result = OBJECT_TO_JSVAL(date);
- JS_LeaveLocalRootScope(context);
- JS_EndRequest(context);
- @@ -1186,7 +1186,7 @@ gjs_maybe_gc (JSContext *context)
- */
- if (rss_size > linux_rss_trigger) {
- linux_rss_trigger = (gulong) MIN(G_MAXULONG, rss_size * 1.25);
- - JS_GC(context);
- + JS_GC(JS_GetRuntime(context));
- } else if (rss_size < (0.75 * linux_rss_trigger)) {
- /* If we've shrunk by 75%, lower the trigger */
- linux_rss_trigger = (rss_size * 1.25);
- diff --git a/modules/cairo-context.c b/modules/cairo-context.c
- index ea23fdf..e22a5a4 100644
- --- a/modules/cairo-context.c
- +++ b/modules/cairo-context.c
- @@ -274,7 +274,7 @@ _gjs_cairo_context_construct_internal(JSContext *context,
- priv = g_slice_new0(GjsCairoContext);
- g_assert(priv_from_js(context, obj) == NULL);
- - JS_SetPrivate(context, obj, priv);
- + JS_SetPrivate(obj, priv);
- priv->context = context;
- priv->object = obj;
- diff --git a/modules/cairo-path.c b/modules/cairo-path.c
- index de59641..48435fd 100644
- --- a/modules/cairo-path.c
- +++ b/modules/cairo-path.c
- @@ -41,7 +41,7 @@ gjs_cairo_path_finalize(JSContext *context,
- JSObject *obj)
- {
- GjsCairoPath *priv;
- - priv = JS_GetPrivate(context, obj);
- + priv = JS_GetPrivate(obj);
- if (priv == NULL)
- return;
- cairo_path_destroy(priv->path);
- @@ -84,7 +84,7 @@ gjs_cairo_path_from_path(JSContext *context,
- priv = g_slice_new0(GjsCairoPath);
- g_assert(priv_from_js(context, object) == NULL);
- - JS_SetPrivate(context, object, priv);
- + JS_SetPrivate(object, priv);
- priv->context = context;
- priv->object = object;
- @@ -111,7 +111,7 @@ gjs_cairo_path_get_path(JSContext *context,
- g_return_val_if_fail(context != NULL, NULL);
- g_return_val_if_fail(object != NULL, NULL);
- - priv = JS_GetPrivate(context, object);
- + priv = JS_GetPrivate(object);
- if (priv == NULL)
- return NULL;
- return priv->path;
- diff --git a/modules/cairo-pattern.c b/modules/cairo-pattern.c
- index 98b64f2..cb52b24 100644
- --- a/modules/cairo-pattern.c
- +++ b/modules/cairo-pattern.c
- @@ -42,7 +42,7 @@ gjs_cairo_pattern_finalize(JSContext *context,
- JSObject *obj)
- {
- GjsCairoPattern *priv;
- - priv = JS_GetPrivate(context, obj);
- + priv = JS_GetPrivate(obj);
- if (priv == NULL)
- return;
- cairo_pattern_destroy(priv->pattern);
- @@ -114,7 +114,7 @@ gjs_cairo_pattern_construct(JSContext *context,
- priv = g_slice_new0(GjsCairoPattern);
- g_assert(priv_from_js(context, object) == NULL);
- - JS_SetPrivate(context, object, priv);
- + JS_SetPrivate(object, priv);
- priv->context = context;
- priv->object = object;
- @@ -196,7 +196,7 @@ gjs_cairo_pattern_get_pattern(JSContext *context,
- g_return_val_if_fail(context != NULL, NULL);
- g_return_val_if_fail(object != NULL, NULL);
- - priv = JS_GetPrivate(context, object);
- + priv = JS_GetPrivate(object);
- if (priv == NULL)
- return NULL;
- diff --git a/modules/cairo-surface.c b/modules/cairo-surface.c
- index 1d372df..5926930 100644
- --- a/modules/cairo-surface.c
- +++ b/modules/cairo-surface.c
- @@ -42,7 +42,7 @@ gjs_cairo_surface_finalize(JSContext *context,
- JSObject *obj)
- {
- GjsCairoSurface *priv;
- - priv = JS_GetPrivate(context, obj);
- + priv = JS_GetPrivate(obj);
- if (priv == NULL)
- return;
- cairo_surface_destroy(priv->surface);
- @@ -152,7 +152,7 @@ gjs_cairo_surface_construct(JSContext *context,
- priv = g_slice_new0(GjsCairoSurface);
- g_assert(priv_from_js(context, object) == NULL);
- - JS_SetPrivate(context, object, priv);
- + JS_SetPrivate(object, priv);
- priv->context = context;
- priv->object = object;
- @@ -237,7 +237,7 @@ gjs_cairo_surface_get_surface(JSContext *context,
- g_return_val_if_fail(context != NULL, NULL);
- g_return_val_if_fail(object != NULL, NULL);
- - priv = JS_GetPrivate(context, object);
- + priv = JS_GetPrivate(object);
- if (priv == NULL)
- return NULL;
- return priv->surface;
- --
- 1.8.0
- From bbf064c279c09c4fb1426f407cae3907e21edf72 Mon Sep 17 00:00:00 2001
- From: Tim Lunn <tim@feathertop.org>
- Date: Tue, 8 Jan 2013 07:51:05 +1100
- Subject: [PATCH 07/10] testBoxed: add test for getter
- ---
- test/js/test0030basicBoxed.js | 1 +
- 1 file changed, 1 insertion(+)
- diff --git a/test/js/test0030basicBoxed.js b/test/js/test0030basicBoxed.js
- index 57dbbe3..099d817 100644
- --- a/test/js/test0030basicBoxed.js
- +++ b/test/js/test0030basicBoxed.js
- @@ -4,6 +4,7 @@ var Regress = imports.gi.Regress;
- function testBasicBoxed() {
- var a = new Regress.TestSimpleBoxedA();
- a.some_int = 42;
- + assertEquals(a.some_int, 42);
- }
- gjstestRun();
- --
- 1.8.0
- From abf430bae0065fa4af0a5ceed6de72bc72e799c7 Mon Sep 17 00:00:00 2001
- From: Tim Lunn <tim@feathertop.org>
- Date: Wed, 9 Jan 2013 12:00:15 +1100
- Subject: [PATCH 08/10] update for JSClass prototype changes
- ---
- gi/boxed.c | 3 +--
- gi/function.c | 2 +-
- gi/gerror.c | 16 ++++++++--------
- gi/keep-alive.c | 6 +-----
- gi/object.c | 11 ++++-------
- gjs/byteArray.c | 47 +++++++++++++++++++++++------------------------
- gjs/importer.c | 2 +-
- gjs/jsapi-util.h | 3 +--
- 8 files changed, 40 insertions(+), 50 deletions(-)
- diff --git a/gi/boxed.c b/gi/boxed.c
- index 2d26301..7379edb 100644
- --- a/gi/boxed.c
- +++ b/gi/boxed.c
- @@ -940,8 +940,7 @@ static struct JSClass gjs_boxed_class = {
- boxed_finalize,
- NULL,
- NULL,
- - NULL,
- - NULL, NULL, NULL, NULL, NULL
- + NULL, NULL, NULL
- };
- static JSPropertySpec gjs_boxed_proto_props[] = {
- diff --git a/gi/function.c b/gi/function.c
- index 4b2f89c..6eaeb39 100644
- --- a/gi/function.c
- +++ b/gi/function.c
- @@ -1367,7 +1367,7 @@ static struct JSClass gjs_function_class = {
- function_finalize,
- NULL,
- function_call,
- - NULL, NULL
- + NULL, NULL, NULL
- };
- static JSPropertySpec gjs_function_proto_props[] = {
- 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/keep-alive.c b/gi/keep-alive.c
- index ce56e35..a8eea22 100644
- --- a/gi/keep-alive.c
- +++ b/gi/keep-alive.c
- @@ -150,7 +150,6 @@ keep_alive_trace(JSTracer *tracer,
- */
- static struct JSClass gjs_keep_alive_class = {
- "__private_GjsKeepAlive", /* means "new __private_GjsKeepAlive()" works */
- - JSCLASS_MARK_IS_TRACE | /* TraceOp not MarkOp */
- JSCLASS_HAS_PRIVATE,
- JS_PropertyStub,
- JS_PropertyStub,
- @@ -164,10 +163,7 @@ static struct JSClass gjs_keep_alive_class = {
- NULL,
- NULL,
- NULL,
- - NULL,
- - NULL,
- - JS_CLASS_TRACE(keep_alive_trace),
- - NULL
- + keep_alive_trace,
- };
- static JSPropertySpec gjs_keep_alive_proto_props[] = {
- diff --git a/gi/object.c b/gi/object.c
- index 7d24bae..0f66481 100644
- --- a/gi/object.c
- +++ b/gi/object.c
- @@ -542,7 +542,7 @@ object_instance_new_resolve(JSContext *context,
- goto out;
- }
- - gjs_define_function(context, obj, priv->gtype, vfunc);
- + gjs_define_function(context, *obj, priv->gtype, vfunc);
- *objp = *obj;
- g_base_info_unref((GIBaseInfo *)vfunc);
- ret = JS_TRUE;
- @@ -1436,8 +1436,7 @@ to_string_func(JSContext *context,
- static struct JSClass gjs_object_instance_class = {
- "GObject_Object",
- JSCLASS_HAS_PRIVATE |
- - JSCLASS_NEW_RESOLVE |
- - JSCLASS_MARK_IS_TRACE,
- + JSCLASS_NEW_RESOLVE,
- JS_PropertyStub,
- JS_PropertyStub,
- object_instance_get_prop,
- @@ -1450,10 +1449,8 @@ static struct JSClass gjs_object_instance_class = {
- NULL,
- NULL,
- NULL,
- - NULL,
- - NULL,
- - JS_CLASS_TRACE(object_instance_trace),
- - NULL,
- + object_instance_trace,
- +
- };
- static JSBool
- diff --git a/gjs/byteArray.c b/gjs/byteArray.c
- index bf4b1b2..416951c 100644
- --- a/gjs/byteArray.c
- +++ b/gjs/byteArray.c
- @@ -41,12 +41,12 @@ 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,
- @@ -65,16 +65,15 @@ static struct JSClass gjs_byte_array_class = {
- JSCLASS_NEW_RESOLVE,
- JS_PropertyStub,
- JS_PropertyStub,
- - byte_array_get_prop,
- - byte_array_set_prop,
- + (JSPropertyOp)byte_array_get_prop,
- + (JSStrictPropertyOp)byte_array_set_prop,
- NULL,
- (JSResolveOp) byte_array_new_resolve, /* cast due to new sig */
- JS_ConvertStub,
- byte_array_finalize,
- NULL,
- NULL,
- - NULL,
- - NULL, NULL, NULL, NULL, NULL
- + NULL, NULL, NULL
- };
- JSBool
- @@ -206,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 */
- @@ -226,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
- @@ -238,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;
- - priv = priv_from_js(context, obj);
- + priv = priv_from_js(context, *obj);
- if (priv == NULL)
- return JS_TRUE; /* prototype, not an instance. */
- @@ -259,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 */
- @@ -321,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);
- @@ -345,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 */
- diff --git a/gjs/importer.c b/gjs/importer.c
- index 7cdf2c3..0eb3c1e 100644
- --- a/gjs/importer.c
- +++ b/gjs/importer.c
- @@ -834,7 +834,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);
- diff --git a/gjs/jsapi-util.h b/gjs/jsapi-util.h
- index 19406a8..ce72963 100644
- --- a/gjs/jsapi-util.h
- +++ b/gjs/jsapi-util.h
- @@ -145,8 +145,7 @@ static struct JSClass gjs_##cname##_class = { \
- gjs_##cname##_finalize, \
- NULL, \
- NULL, \
- - NULL, \
- - NULL, NULL, NULL, NULL, NULL \
- + NULL, NULL, NULL \
- }; \
- jsval gjs_##cname##_create_proto(JSContext *context, JSObject *module, const char *proto_name, JSObject *parent) \
- { \
- --
- 1.8.0
- From 541363ac63596109a3b55d7e470ea0168c11ad5e Mon Sep 17 00:00:00 2001
- From: Tim Lunn <tim@feathertop.org>
- Date: Wed, 9 Jan 2013 18:54:15 +1100
- Subject: [PATCH 09/10] Misc api changes
- ---
- gjs/context.c | 6 +++---
- gjs/jsapi-private.cpp | 2 +-
- gjs/jsapi-util.c | 2 +-
- gjs/stack.c | 43 ++++++++++++++++++++++---------------------
- modules/jsUnit.js | 1 +
- modules/system.c | 2 +-
- test/gjs-tests.c | 2 +-
- 7 files changed, 30 insertions(+), 28 deletions(-)
- diff --git a/gjs/context.c b/gjs/context.c
- index 79a018a..186bf02 100644
- --- a/gjs/context.c
- +++ b/gjs/context.c
- @@ -571,7 +571,7 @@ gjs_context_constructor (GType type,
- *
- * JSOPTION_STRICT: Report warnings to error reporter function.
- */
- - options_flags = JSOPTION_DONT_REPORT_UNCAUGHT | JSOPTION_STRICT;
- + options_flags = JSOPTION_DONT_REPORT_UNCAUGHT | JSOPTION_STRICT | JSOPTION_ALLOW_XML;
- #ifdef JSOPTION_JIT
- if (!g_getenv("GJS_DISABLE_JIT")) {
- @@ -673,7 +673,7 @@ gjs_context_constructor (GType type,
- }
- if (js_context->gc_notifications_enabled)
- - JS_SetGCCallback(js_context->context, gjs_on_context_gc);
- + JS_SetGCCallback(JS_GetRuntime(js_context->context), gjs_on_context_gc);
- JS_EndRequest(js_context->context);
- @@ -878,7 +878,7 @@ gjs_context_maybe_gc (GjsContext *context)
- void
- gjs_context_gc (GjsContext *context)
- {
- - JS_GC(context->context);
- + JS_GC(JS_GetRuntime(context->context));
- }
- static gboolean
- diff --git a/gjs/jsapi-private.cpp b/gjs/jsapi-private.cpp
- index 463619f..5f39053 100644
- --- a/gjs/jsapi-private.cpp
- +++ b/gjs/jsapi-private.cpp
- @@ -35,7 +35,7 @@
- #pragma GCC diagnostic push
- #pragma GCC diagnostic ignored "-Wstrict-prototypes"
- #pragma GCC diagnostic ignored "-Winvalid-offsetof"
- -#include <jscntxt.h>
- +#include <jsfriendapi.h>
- #pragma GCC diagnostic pop
- void
- diff --git a/gjs/jsapi-util.c b/gjs/jsapi-util.c
- index eb91c6d..f3f2504 100644
- --- a/gjs/jsapi-util.c
- +++ b/gjs/jsapi-util.c
- @@ -102,7 +102,7 @@ gboolean
- gjs_init_context_standard (JSContext *context)
- {
- JSObject *global;
- - global = JS_NewCompartmentAndGlobalObject(context, &global_class, NULL);
- + global = JS_NewGlobalObject(context, &global_class, NULL);
- if (global == NULL)
- return FALSE;
- if (!JS_InitStandardClasses(context, global))
- diff --git a/gjs/stack.c b/gjs/stack.c
- index aec76ed..cd7c767 100644
- --- a/gjs/stack.c
- +++ b/gjs/stack.c
- @@ -100,16 +100,17 @@ format_frame(JSContext* cx, JSStackFrame* fp,
- (void)JS_EnterLocalRootScope(cx);
- - if (!JS_IsScriptFrame(cx, fp)) {
- - g_string_append_printf(buf, "%d [native frame]\n", num);
- - goto out;
- - }
- -
- /* get the info for this stack frame */
- script = JS_GetFrameScript(cx, fp);
- pc = JS_GetFramePC(cx, fp);
- + if (!script) {
- + g_string_append_printf(buf, "%d [native frame]\n", num);
- + goto out;
- + }
- +
- +
- if (script && pc) {
- filename = JS_GetScriptFilename(cx, script);
- lineno = (guint32) JS_PCToLineNumber(cx, script, pc);
- @@ -143,23 +144,23 @@ format_frame(JSContext* cx, JSStackFrame* fp,
- char *name = NULL;
- char *value = NULL;
- JSPropertyDesc* desc = &call_props.array[i];
- - if(desc->flags & JSPD_ARGUMENT) {
- - name = jsvalue_to_string(cx, desc->id, &is_string);
- - if(!is_string) {
- - g_free(name);
- - name = NULL;
- - }
- - value = jsvalue_to_string(cx, desc->value, &is_string);
- -
- - g_string_append_printf(buf, "%s%s%s%s%s%s",
- - named_arg_count ? ", " : "",
- - name ? name :"",
- - name ? " = " : "",
- - is_string ? "\"" : "",
- - value ? value : "?unknown?",
- - is_string ? "\"" : "");
- - named_arg_count++;
- +
- + name = jsvalue_to_string(cx, desc->id, &is_string);
- + if(!is_string) {
- + g_free(name);
- + name = NULL;
- }
- + value = jsvalue_to_string(cx, desc->value, &is_string);
- +
- + g_string_append_printf(buf, "%s%s%s%s%s%s",
- + named_arg_count ? ", " : "",
- + name ? name :"",
- + name ? " = " : "",
- + is_string ? "\"" : "",
- + value ? value : "?unknown?",
- + is_string ? "\"" : "");
- + named_arg_count++;
- +
- g_free(name);
- g_free(value);
- }
- diff --git a/modules/jsUnit.js b/modules/jsUnit.js
- index e260f22..08f7a19 100644
- --- a/modules/jsUnit.js
- +++ b/modules/jsUnit.js
- @@ -450,6 +450,7 @@ function jsUnitSetOnLoad(windowRef, onloadHandler)
- // GJS: entry point to run all functions named as test*, surrounded by
- // calls to setUp() and tearDown()
- function gjstestRun(window_, setUp, tearDown) {
- + var propName;
- var rv = 0;
- var failures = [];
- if (!window_) window_ = window;
- diff --git a/modules/system.c b/modules/system.c
- index 7ee9a2f..0752649 100644
- --- a/modules/system.c
- +++ b/modules/system.c
- @@ -100,7 +100,7 @@ gjs_gc(JSContext *context,
- jsval *argv = JS_ARGV(cx, vp);
- if (!gjs_parse_args(context, "gc", "", argc, argv))
- return JS_FALSE;
- - JS_GC(context);
- + JS_GC(JS_GetRuntime(context));
- return JS_TRUE;
- }
- diff --git a/test/gjs-tests.c b/test/gjs-tests.c
- index b92b33e..8fb67d3 100644
- --- a/test/gjs-tests.c
- +++ b/test/gjs-tests.c
- @@ -111,7 +111,7 @@ gjstest_test_func_gjs_jsapi_util_array(void)
- gjs_rooted_array_append(context, array, value);
- }
- - JS_GC(context);
- + JS_GC(JS_GetRuntime(context));
- for (i = 0; i < N_ELEMS; i++) {
- char *ascii;
- --
- 1.8.0
- From 036c5eae914eb57383383ac334b35bc8742563b7 Mon Sep 17 00:00:00 2001
- From: Tim Lunn <tim@feathertop.org>
- Date: Wed, 9 Jan 2013 19:21:24 +1100
- Subject: [PATCH 10/10] byteArray: update PropertySpec for new API
- For some reason the setter fails to get called when JSPROP_SHARED
- is set.
- ---
- gjs/byteArray.c | 6 +++---
- 1 file changed, 3 insertions(+), 3 deletions(-)
- diff --git a/gjs/byteArray.c b/gjs/byteArray.c
- index 416951c..37aad63 100644
- --- a/gjs/byteArray.c
- +++ b/gjs/byteArray.c
- @@ -957,9 +957,9 @@ enum ByteArrayTinyId {
- static JSPropertySpec gjs_byte_array_proto_props[] = {
- { "length", BYTE_ARRAY_TINY_ID_LENGTH,
- - JSPROP_PERMANENT | JSPROP_SHARED,
- - byte_array_length_getter,
- - byte_array_length_setter
- + JSPROP_PERMANENT,
- + (JSPropertyOp)byte_array_length_getter,
- + (JSStrictPropertyOp)byte_array_length_setter
- },
- { NULL }
- };
- --
- 1.8.0
Add Comment
Please, Sign In to add comment