[gjs] GI: handle G_SIGNAL_TYPE_STATIC_SCOPE in signal emission from JS
- From: Johan Bilien <jobi src gnome org>
- To: svn-commits-list gnome org
- Subject: [gjs] GI: handle G_SIGNAL_TYPE_STATIC_SCOPE in signal emission from JS
- Date: Tue, 24 Mar 2009 13:01:20 -0400 (EDT)
commit 379c97bc10d5f873d3aee784e3b6733fd774dbf1
Author: Johan Bilien <jobi litl com>
Date: Tue Mar 24 15:40:34 2009 +0000
GI: handle G_SIGNAL_TYPE_STATIC_SCOPE in signal emission from JS
value.[ch]:
. add a gjs_value_to_g_value_no_copy for building GValue without
copying the content
gi/object.c:
. use this for G_SIGNAL_TYPE_STATIC_SCOPE signal parameters
---
gi/object.c | 10 ++++++----
gi/value.c | 30 +++++++++++++++++++++++++-----
gi/value.h | 29 ++++++++++++++++-------------
3 files changed, 47 insertions(+), 22 deletions(-)
diff --git a/gi/object.c b/gi/object.c
index b4ee367..b4d5f1c 100644
--- a/gi/object.c
+++ b/gi/object.c
@@ -1088,11 +1088,13 @@ emit_func(JSContext *context,
value = &instance_and_args[i + 1];
g_value_init(value, signal_query.param_types[i] & ~G_SIGNAL_TYPE_STATIC_SCOPE);
- if (!gjs_value_to_g_value(context, argv[i+1],
- value)) {
- failed = TRUE;
+ if (signal_query.param_types[i] & G_SIGNAL_TYPE_STATIC_SCOPE)
+ failed = !gjs_value_to_g_value_no_copy(context, argv[i+1], value);
+ else
+ failed = !gjs_value_to_g_value(context, argv[i+1], value);
+
+ if (failed)
break;
- }
}
if (!failed) {
diff --git a/gi/value.c b/gi/value.c
index 590da8a..aed44c7 100644
--- a/gi/value.c
+++ b/gi/value.c
@@ -189,10 +189,11 @@ gjs_value_guess_g_type(jsval value)
return G_TYPE_INVALID;
}
-JSBool
-gjs_value_to_g_value(JSContext *context,
- jsval value,
- GValue *gvalue)
+static JSBool
+gjs_value_to_g_value_internal(JSContext *context,
+ jsval value,
+ GValue *gvalue,
+ gboolean no_copy)
{
GType gtype;
@@ -383,7 +384,10 @@ gjs_value_to_g_value(JSContext *context,
return JS_FALSE;
}
- g_value_set_boxed(gvalue, gboxed);
+ if (no_copy)
+ g_value_set_static_boxed(gvalue, gboxed);
+ else
+ g_value_set_boxed(gvalue, gboxed);
} else if (g_type_is_a(gtype, G_TYPE_ENUM)) {
if (JSVAL_IS_INT(value)) {
GEnumValue *v;
@@ -479,6 +483,22 @@ gjs_value_to_g_value(JSContext *context,
return JS_TRUE;
}
+JSBool
+gjs_value_to_g_value(JSContext *context,
+ jsval value,
+ GValue *gvalue)
+{
+ return gjs_value_to_g_value_internal(context, value, gvalue, FALSE);
+}
+
+JSBool
+gjs_value_to_g_value_no_copy(JSContext *context,
+ jsval value,
+ GValue *gvalue)
+{
+ return gjs_value_to_g_value_internal(context, value, gvalue, TRUE);
+}
+
static JSBool
gjs_value_from_g_value_internal(JSContext *context,
jsval *value_p,
diff --git a/gi/value.h b/gi/value.h
index 460c5ed..8340fcf 100644
--- a/gi/value.h
+++ b/gi/value.h
@@ -30,19 +30,22 @@
G_BEGIN_DECLS
-JSBool gjs_value_to_g_value (JSContext *context,
- jsval value,
- GValue *gvalue);
-JSBool gjs_value_from_g_value (JSContext *context,
- jsval *value_p,
- const GValue *gvalue);
-GClosure* gjs_closure_new_marshaled (JSContext *context,
- JSObject *callable,
- const char *description);
-GClosure* gjs_closure_new_for_signal(JSContext *context,
- JSObject *callable,
- const char *description,
- guint signal_id);
+JSBool gjs_value_to_g_value (JSContext *context,
+ jsval value,
+ GValue *gvalue);
+JSBool gjs_value_to_g_value_no_copy (JSContext *context,
+ jsval value,
+ GValue *gvalue);
+JSBool gjs_value_from_g_value (JSContext *context,
+ jsval *value_p,
+ const GValue *gvalue);
+GClosure* gjs_closure_new_marshaled (JSContext *context,
+ JSObject *callable,
+ const char *description);
+GClosure* gjs_closure_new_for_signal (JSContext *context,
+ JSObject *callable,
+ const char *description,
+ guint signal_id);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]