vala r1589 - in trunk: . gobject tests
- From: juergbi svn gnome org
- To: svn-commits-list gnome org
- Subject: vala r1589 - in trunk: . gobject tests
- Date: Sun, 15 Jun 2008 21:29:51 +0000 (UTC)
Author: juergbi
Date: Sun Jun 15 21:29:51 2008
New Revision: 1589
URL: http://svn.gnome.org/viewvc/vala?rev=1589&view=rev
Log:
2008-06-15 JÃrg Billeter <j bitron ch>
* gobject/valaccodeinvocationexpressionbinding.vala:
Support emitting signals with return values,
patch by Samuel Cormier-Iijima, fixes bug 537323
* tests/classes-signals.exp:
* tests/classes-signals.vala:
Test signals with return values
Modified:
trunk/ChangeLog
trunk/THANKS
trunk/gobject/valaccodeinvocationexpressionbinding.vala
trunk/tests/classes-signals.exp
trunk/tests/classes-signals.vala
Modified: trunk/THANKS
==============================================================================
--- trunk/THANKS (original)
+++ trunk/THANKS Sun Jun 15 21:29:51 2008
@@ -43,6 +43,7 @@
Roberto Majadas
Roland Hostettler
Ross Burton
+Samuel Cormier-Iijima
StÃphan Kochen
Thijs Vermeir
Travis Watkins
Modified: trunk/gobject/valaccodeinvocationexpressionbinding.vala
==============================================================================
--- trunk/gobject/valaccodeinvocationexpressionbinding.vala (original)
+++ trunk/gobject/valaccodeinvocationexpressionbinding.vala Sun Jun 15 21:29:51 2008
@@ -386,6 +386,26 @@
}
}
+ // pass address for the return value of non-void signals without emitter functions
+ if (itype is SignalType && !(itype.get_return_type () is VoidType)) {
+ var sig = ((SignalType) itype).signal_symbol;
+
+ if (!sig.has_emitter) {
+ var temp_var = codegen.get_temp_variable (itype.get_return_type ());
+ var temp_ref = new CCodeIdentifier (temp_var.name);
+
+ codegen.temp_vars.insert (0, temp_var);
+
+ carg_map.set (codegen.get_param_pos (-1, true), new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, temp_ref));
+
+ var ccomma = new CCodeCommaExpression ();
+ ccomma.append_expression ((CCodeExpression) ccall_expr);
+ ccomma.append_expression ((CCodeExpression) temp_ref);
+
+ ccall_expr = ccomma;
+ }
+ }
+
// append C arguments in the right order
int last_pos = -1;
int min_pos;
Modified: trunk/tests/classes-signals.exp
==============================================================================
--- trunk/tests/classes-signals.exp (original)
+++ trunk/tests/classes-signals.exp Sun Jun 15 21:29:51 2008
@@ -1,2 +1,3 @@
Signal Test: 1 2 3 4 5 6 7 8 9 10
User Signal Test: 1 2 3 4 5 6
+Signal Return Test: 1 2 3 4 5 6 7 8
Modified: trunk/tests/classes-signals.vala
==============================================================================
--- trunk/tests/classes-signals.vala (original)
+++ trunk/tests/classes-signals.vala Sun Jun 15 21:29:51 2008
@@ -62,6 +62,13 @@
stdout.printf (" 6\n");
+ stdout.printf ("Signal Return Test: 1");
+
+ var return_bar = new ReturnBar ();
+ return_bar.run ();
+
+ stdout.printf (" 8\n");
+
return 0;
}
}
@@ -92,3 +99,31 @@
}
}
+class Maman.ReturnFoo : Object {
+ public signal int int_activated (int arg);
+ public signal string string_activated (string arg);
+}
+
+class Maman.ReturnBar : Object {
+ public void run () {
+ stdout.printf (" 2");
+
+ var foo = new ReturnFoo ();
+
+ foo.int_activated += (foo, arg) => {
+ stdout.printf (" %d", arg);
+ return arg + 1;
+ };
+
+ foo.string_activated += (foo, arg) => {
+ stdout.printf (arg);
+ return " 6";
+ };
+
+ stdout.printf (" %d", foo.int_activated (3));
+
+ stdout.printf (foo.string_activated (" 5"));
+
+ stdout.printf (" 7");
+ }
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]