[gjs/wip/xulrunner-2-rebase3] [REBASE] Use NewObjectForConstructor
- From: Colin Walters <walters src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs/wip/xulrunner-2-rebase3] [REBASE] Use NewObjectForConstructor
- Date: Fri, 29 Oct 2010 15:22:06 +0000 (UTC)
commit f5956583ebd0cead1fee863fd42a95b9b8ab38d6
Author: Colin Walters <walters verbum org>
Date: Fri Oct 29 11:18:35 2010 -0400
[REBASE] Use NewObjectForConstructor
This gets us the right class.
gi/function.c | 8 ++++++--
gjs/compat.h | 2 +-
2 files changed, 7 insertions(+), 3 deletions(-)
---
diff --git a/gi/function.c b/gi/function.c
index d6b199a..0404bdf 100644
--- a/gi/function.c
+++ b/gi/function.c
@@ -791,7 +791,8 @@ function_call(JSContext *context,
{
jsval retval;
success = gjs_invoke_c_function(context, priv, object, js_argc, js_argv, &retval);
- JS_SET_RVAL(context, vp, retval);
+ if (success)
+ JS_SET_RVAL(context, vp, retval);
}
#else
success = gjs_invoke_c_function(context, priv, object, js_argc, js_argv, retval);
@@ -819,7 +820,7 @@ function_constructor(JSContext *context,
return JS_FALSE;
}
if (object == NULL)
- object = JS_NewObject(context, &gjs_function_class, NULL, NULL);
+ object = JS_NewObjectForConstructor(context, vp);
#else
static JSBool
function_constructor(JSContext *context,
@@ -840,6 +841,9 @@ function_constructor(JSContext *context,
gjs_debug_lifecycle(GJS_DEBUG_GFUNCTION,
"function constructor, obj %p priv %p", object, priv);
+#ifdef JSFUN_CONSTRUCTOR
+ JS_SET_RVAL(context, vp, OBJECT_TO_JSVAL(object));
+#endif
return JS_TRUE;
}
diff --git a/gjs/compat.h b/gjs/compat.h
index 508bf79..d418a22 100644
--- a/gjs/compat.h
+++ b/gjs/compat.h
@@ -100,7 +100,7 @@ gjs_##name##_constructor(JSContext *context, \
return JS_FALSE; \
} \
if (object == NULL) \
- object = JS_NewObject(context, &gjs_##name##_class, NULL, NULL); \
+ object = JS_NewObjectForConstructor(context, vp); \
if (object == NULL) \
return JS_FALSE; \
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]