vala r1465 - in trunk: . gobject vala
- From: juergbi svn gnome org
- To: svn-commits-list gnome org
- Subject: vala r1465 - in trunk: . gobject vala
- Date: Wed, 28 May 2008 17:41:50 +0000 (UTC)
Author: juergbi
Date: Wed May 28 17:41:50 2008
New Revision: 1465
URL: http://svn.gnome.org/viewvc/vala?rev=1465&view=rev
Log:
2008-05-28 Juerg Billeter <j bitron ch>
* vala/valasemanticanalyzer.vala:
* vala/valasignal.vala:
* gobject/valaccodeassignmentbinding.vala:
* gobject/valaccodedynamicsignalbinding.vala:
Improve handling of dynamic signal parameters
Modified:
trunk/ChangeLog
trunk/gobject/valaccodeassignmentbinding.vala
trunk/gobject/valaccodedynamicsignalbinding.vala
trunk/vala/valasemanticanalyzer.vala
trunk/vala/valasignal.vala
Modified: trunk/gobject/valaccodeassignmentbinding.vala
==============================================================================
--- trunk/gobject/valaccodeassignmentbinding.vala (original)
+++ trunk/gobject/valaccodeassignmentbinding.vala Wed May 28 17:41:50 2008
@@ -236,22 +236,13 @@
var cparam = new CCodeFormalParameter ("self", "gpointer");
cparam_map.set (codegen.get_param_pos (-1), cparam);
- if (sig is DynamicSignal) {
- foreach (FormalParameter param in m.get_parameters()) {
- // ensure that C code node has been generated
- param.accept (codegen);
+ cparam = new CCodeFormalParameter ("_sender", ((TypeSymbol) sig.parent_symbol).get_cname () + "*");
+ cparam_map.set (codegen.get_param_pos (0), cparam);
+ foreach (FormalParameter param in sig.get_parameters()) {
+ // ensure that C code node has been generated
+ param.accept (codegen);
- cparam_map.set (codegen.get_param_pos (param.cparameter_position), (CCodeFormalParameter) param.ccodenode);
- }
- } else {
- cparam = new CCodeFormalParameter ("sender", ((TypeSymbol) sig.parent_symbol).get_cname () + "*");
- cparam_map.set (codegen.get_param_pos (0), cparam);
- foreach (FormalParameter param in sig.get_parameters()) {
- // ensure that C code node has been generated
- param.accept (codegen);
-
- cparam_map.set (codegen.get_param_pos (param.cparameter_position), (CCodeFormalParameter) param.ccodenode);
- }
+ cparam_map.set (codegen.get_param_pos (param.cparameter_position), (CCodeFormalParameter) param.ccodenode);
}
// append C parameters in the right order
@@ -280,26 +271,18 @@
carg_map.set (codegen.get_param_pos (m.cinstance_parameter_position), new CCodeIdentifier ("self"));
}
- if (sig is DynamicSignal) {
- foreach (FormalParameter param in m.get_parameters ()) {
- CCodeExpression arg;
- arg = new CCodeIdentifier ((param.ccodenode as CCodeFormalParameter).name);
- carg_map.set (codegen.get_param_pos (param.cparameter_position), arg);
+ int i = -1;
+ var sig_params = sig.get_parameters ();
+ foreach (FormalParameter param in m.get_parameters ()) {
+ CCodeExpression arg;
+ if (i < 0) {
+ arg = new CCodeIdentifier ("_sender");
+ } else {
+ arg = new CCodeIdentifier ((sig_params.get (i).ccodenode as CCodeFormalParameter).name);
}
- } else {
- int i = -1;
- var sig_params = sig.get_parameters ();
- foreach (FormalParameter param in m.get_parameters ()) {
- CCodeExpression arg;
- if (i < 0) {
- arg = new CCodeIdentifier ("sender");
- } else {
- arg = new CCodeIdentifier ((sig_params.get (i).ccodenode as CCodeFormalParameter).name);
- }
- carg_map.set (codegen.get_param_pos (param.cparameter_position), arg);
- i++;
- }
- }
+ carg_map.set (codegen.get_param_pos (param.cparameter_position), arg);
+ i++;
+ }
var ccall = new CCodeFunctionCall (new CCodeIdentifier (m.get_cname ()));
// append C arguments in the right order
Modified: trunk/gobject/valaccodedynamicsignalbinding.vala
==============================================================================
--- trunk/gobject/valaccodedynamicsignalbinding.vala (original)
+++ trunk/gobject/valaccodedynamicsignalbinding.vala Wed May 28 17:41:50 2008
@@ -107,16 +107,6 @@
var m = (Method) dynamic_signal.handler.symbol_reference;
- bool first = true;
- foreach (FormalParameter param in m.get_parameters ()) {
- if (first) {
- // skip sender parameter
- first = false;
- continue;
- }
- node.add_parameter (param.copy ());
- }
-
node.accept (codegen);
// FIXME should only be done once per marshaller
@@ -128,7 +118,7 @@
add_call.add_argument (new CCodeIdentifier ("obj"));
add_call.add_argument (new CCodeConstant ("\"%s\"".printf (node.name)));
- first = true;
+ bool first = true;
foreach (FormalParameter param in m.get_parameters ()) {
if (first) {
// skip sender parameter
Modified: trunk/vala/valasemanticanalyzer.vala
==============================================================================
--- trunk/vala/valasemanticanalyzer.vala (original)
+++ trunk/vala/valasemanticanalyzer.vala Wed May 28 17:41:50 2008
@@ -3009,12 +3009,11 @@
return;
}
- if (ma.symbol_reference is Signal) {
+ if (ma.symbol_reference is DynamicSignal) {
+ // target_type not available for dynamic signals
+ } else if (ma.symbol_reference is Signal) {
var sig = (Signal) ma.symbol_reference;
- var deleg = sig.get_delegate ();
- if (deleg != null) {
- a.right.target_type = new DelegateType (deleg);
- }
+ a.right.target_type = new DelegateType (sig.get_delegate ());
} else {
a.right.target_type = ma.value_type;
}
@@ -3088,6 +3087,20 @@
Report.error (a.right.source_reference, "unsupported expression for signal handler");
return;
}
+
+ var dynamic_sig = sig as DynamicSignal;
+ if (dynamic_sig != null) {
+ bool first = true;
+ foreach (FormalParameter param in dynamic_sig.handler.value_type.get_parameters ()) {
+ if (first) {
+ // skip sender parameter
+ first = false;
+ } else {
+ dynamic_sig.add_parameter (param);
+ }
+ }
+ a.right.target_type = new DelegateType (sig.get_delegate ());
+ }
} else if (ma.symbol_reference is Property) {
var prop = (Property) ma.symbol_reference;
Modified: trunk/vala/valasignal.vala
==============================================================================
--- trunk/vala/valasignal.vala (original)
+++ trunk/vala/valasignal.vala Wed May 28 17:41:50 2008
@@ -102,7 +102,7 @@
} else {
sender_type = new ObjectType ((Interface) parent_symbol);
}
- var sender_param = new FormalParameter ("sender", sender_type);
+ var sender_param = new FormalParameter ("_sender", sender_type);
generated_delegate.add_parameter (sender_param);
foreach (FormalParameter param in parameters) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]