diff options
author | Colin Walters <walters@verbum.org> | 2010-10-20 16:50:41 -0400 |
---|---|---|
committer | Colin Walters <walters@verbum.org> | 2010-10-29 12:56:43 -0400 |
commit | 50dd303f1299c4972bb3f2aece7d38135784c752 (patch) | |
tree | de84c85118b0d41219e36bfa399ff6dd3a3dd892 /gi/param.c | |
parent | 1a74cfc76b5a8b5ef00a255d8ae813153337e8ab (diff) | |
download | gjs-50dd303f1299c4972bb3f2aece7d38135784c752.tar.gz |
Use fast constructors if available
"slow" natives were removed in the mozjs commit:
http://hg.mozilla.org/mozilla-central/rev/66c8ad02543b
In order to work with both, add compatibility macros to compat.h,
and also update the ones in jsapi-util.h to use these.
Port all constructors to use these macros.
Diffstat (limited to 'gi/param.c')
-rw-r--r-- | gi/param.c | 25 |
1 files changed, 11 insertions, 14 deletions
@@ -142,13 +142,9 @@ param_new_resolve(JSContext *context, * identify the prototype as an object of our class with NULL private * data. */ -static JSBool -param_constructor(JSContext *context, - JSObject *obj, - uintN argc, - jsval *argv, - jsval *retval) +GJS_NATIVE_CONSTRUCTOR_DECLARE(param) { + GJS_NATIVE_CONSTRUCTOR_VARIABLES(param) Param *priv; Param *proto_priv; JSClass *obj_class; @@ -156,27 +152,26 @@ param_constructor(JSContext *context, JSObject *proto; gboolean is_proto; - if (!gjs_check_constructing(context)) - return JS_FALSE; + GJS_NATIVE_CONSTRUCTOR_PRELUDE(param); priv = g_slice_new0(Param); GJS_INC_COUNTER(param); - g_assert(priv_from_js(context, obj) == NULL); - JS_SetPrivate(context, obj, priv); + g_assert(priv_from_js(context, object) == NULL); + JS_SetPrivate(context, object, priv); gjs_debug_lifecycle(GJS_DEBUG_GPARAM, - "param constructor, obj %p priv %p", obj, priv); + "param constructor, obj %p priv %p", object, priv); - proto = JS_GetPrototype(context, obj); + proto = JS_GetPrototype(context, object); gjs_debug_lifecycle(GJS_DEBUG_GPARAM, "param instance __proto__ is %p", proto); /* If we're constructing the prototype, its __proto__ is not the same * class as us, but if we're constructing an instance, the prototype * has the same class. */ - obj_class = JS_GET_CLASS(context, obj); + obj_class = JS_GET_CLASS(context, object); proto_class = JS_GET_CLASS(context, proto); is_proto = (obj_class != proto_class); @@ -214,6 +209,8 @@ param_constructor(JSContext *context, priv->gparam, g_type_name(G_TYPE_FROM_INSTANCE((GTypeInstance*) priv->gparam))); } + GJS_NATIVE_CONSTRUCTOR_FINISH(param); + return JS_TRUE; } @@ -345,7 +342,7 @@ gjs_define_param_class(JSContext *context, * none - just name the prototype like * Math - rarely correct) */ - param_constructor, + gjs_param_constructor, /* number of constructor args */ 0, /* props of prototype */ |