[gjs] value: Handle foreign types correctly when converting from a GValue
- From: Jasper St. Pierre <jstpierre src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs] value: Handle foreign types correctly when converting from a GValue
- Date: Fri, 25 May 2012 20:38:11 +0000 (UTC)
commit 085fb4d3262e7d427867b0ac3d46f465785d7f88
Author: Jasper St. Pierre <jstpierre mecheye net>
Date: Thu Mar 8 18:24:01 2012 -0500
value: Handle foreign types correctly when converting from a GValue
https://bugzilla.gnome.org/show_bug.cgi?id=671687
gi/value.c | 11 +++++++++++
test/js/testCairo.js | 12 ++++++++++++
2 files changed, 23 insertions(+), 0 deletions(-)
---
diff --git a/gi/value.c b/gi/value.c
index fe19aac..71fd39b 100644
--- a/gi/value.c
+++ b/gi/value.c
@@ -25,6 +25,7 @@
#include <util/log.h>
+#include "foreign.h"
#include "value.h"
#include "closure.h"
#include "arg.h"
@@ -676,6 +677,16 @@ gjs_value_from_g_value_internal(JSContext *context,
return JS_FALSE;
}
+ if (g_base_info_get_type(info) == GI_INFO_TYPE_STRUCT &&
+ g_struct_info_is_foreign((GIStructInfo*)info)) {
+ JSBool ret;
+ GIArgument arg;
+ arg.v_pointer = gboxed;
+ ret = gjs_struct_foreign_convert_from_g_argument(context, value_p, info, &arg);
+ g_base_info_unref(info);
+ return ret;
+ }
+
switch (g_base_info_get_type(info)) {
case GI_INFO_TYPE_BOXED:
case GI_INFO_TYPE_STRUCT:
diff --git a/test/js/testCairo.js b/test/js/testCairo.js
index 7dd66cc..22d63f0 100644
--- a/test/js/testCairo.js
+++ b/test/js/testCairo.js
@@ -1,5 +1,6 @@
// application/javascript;version=1.8
const Cairo = imports.cairo;
+const Everything = imports.gi.Regress;
function _ts(obj) {
return obj.toString().slice(8, -1);
@@ -165,4 +166,15 @@ function testRadialGradient() {
assertEquals(_ts(cr.getSource()), "CairoRadialGradient");
}
+function testCairoSignal() {
+ let o = new Everything.TestObj();
+ let called = false;
+ o.connect('sig-with-foreign-struct', function(o, cr) {
+ called = true;
+ assertTrue(_ts(cr), "CairoContext");
+ });
+ o.emit_sig_with_foreign_struct();
+ assertTrue(called);
+}
+
gjstestRun();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]