vala r2397 - in trunk: . gobject
- From: juergbi svn gnome org
- To: svn-commits-list gnome org
- Subject: vala r2397 - in trunk: . gobject
- Date: Fri, 23 Jan 2009 14:20:15 +0000 (UTC)
Author: juergbi
Date: Fri Jan 23 14:20:15 2009
New Revision: 2397
URL: http://svn.gnome.org/viewvc/vala?rev=2397&view=rev
Log:
2009-01-23 JÃrg Billeter <j bitron ch>
* gobject/valaccodearraymodule.vala:
* gobject/valaccodedelegatemodule.vala:
* gobject/valaccodemethodmodule.vala:
Add virtual generate_parameter method. Move array and delegate type
specific parameter generation to corresponding modules.
Modified:
trunk/ChangeLog
trunk/gobject/valaccodearraymodule.vala
trunk/gobject/valaccodedelegatemodule.vala
trunk/gobject/valaccodemethodmodule.vala
Modified: trunk/gobject/valaccodearraymodule.vala
==============================================================================
--- trunk/gobject/valaccodearraymodule.vala (original)
+++ trunk/gobject/valaccodearraymodule.vala Fri Jan 23 14:20:15 2009
@@ -682,4 +682,33 @@
assignment.ccodenode = ccall;
}
+
+ public override void generate_parameter (FormalParameter param, Map<int,CCodeFormalParameter> cparam_map, Map<int,CCodeExpression>? carg_map) {
+ if (!(param.parameter_type is ArrayType)) {
+ base.generate_parameter (param, cparam_map, carg_map);
+ return;
+ }
+
+ var array_type = (ArrayType) param.parameter_type;
+
+ cparam_map.set (get_param_pos (param.cparameter_position), (CCodeFormalParameter) param.ccodenode);
+ if (carg_map != null) {
+ carg_map.set (get_param_pos (param.cparameter_position), new CCodeIdentifier (param.name));
+ }
+
+ if (!param.no_array_length) {
+ var length_ctype = "int";
+ if (param.direction != ParameterDirection.IN) {
+ length_ctype = "int*";
+ }
+
+ for (int dim = 1; dim <= array_type.rank; dim++) {
+ var cparam = new CCodeFormalParameter (head.get_array_length_cname (param.name, dim), length_ctype);
+ cparam_map.set (get_param_pos (param.carray_length_parameter_position + 0.01 * dim), cparam);
+ if (carg_map != null) {
+ carg_map.set (get_param_pos (param.carray_length_parameter_position + 0.01 * dim), new CCodeIdentifier (cparam.name));
+ }
+ }
+ }
+ }
}
Modified: trunk/gobject/valaccodedelegatemodule.vala
==============================================================================
--- trunk/gobject/valaccodedelegatemodule.vala (original)
+++ trunk/gobject/valaccodedelegatemodule.vala Fri Jan 23 14:20:15 2009
@@ -380,4 +380,41 @@
return wrapper_name;
}
+
+ public override void generate_parameter (FormalParameter param, Map<int,CCodeFormalParameter> cparam_map, Map<int,CCodeExpression>? carg_map) {
+ if (!(param.parameter_type is DelegateType || param.parameter_type is MethodType)) {
+ base.generate_parameter (param, cparam_map, carg_map);
+ return;
+ }
+
+ cparam_map.set (get_param_pos (param.cparameter_position), (CCodeFormalParameter) param.ccodenode);
+ if (carg_map != null) {
+ carg_map.set (get_param_pos (param.cparameter_position), new CCodeIdentifier (param.name));
+ }
+
+ if (param.parameter_type is DelegateType) {
+ var deleg_type = (DelegateType) param.parameter_type;
+ var d = deleg_type.delegate_symbol;
+ if (d.has_target) {
+ var cparam = new CCodeFormalParameter (get_delegate_target_cname (param.name), "void*");
+ cparam_map.set (get_param_pos (param.cdelegate_target_parameter_position), cparam);
+ if (carg_map != null) {
+ carg_map.set (get_param_pos (param.cdelegate_target_parameter_position), new CCodeIdentifier (cparam.name));
+ }
+ if (deleg_type.value_owned) {
+ cparam = new CCodeFormalParameter (get_delegate_target_destroy_notify_cname (param.name), "GDestroyNotify");
+ cparam_map.set (get_param_pos (param.cdelegate_target_parameter_position + 0.01), cparam);
+ if (carg_map != null) {
+ carg_map.set (get_param_pos (param.cdelegate_target_parameter_position + 0.01), new CCodeIdentifier (cparam.name));
+ }
+ }
+ }
+ } else if (param.parameter_type is MethodType) {
+ var cparam = new CCodeFormalParameter (get_delegate_target_cname (param.name), "void*");
+ cparam_map.set (get_param_pos (param.cdelegate_target_parameter_position), cparam);
+ if (carg_map != null) {
+ carg_map.set (get_param_pos (param.cdelegate_target_parameter_position), new CCodeIdentifier (cparam.name));
+ }
+ }
+ }
}
Modified: trunk/gobject/valaccodemethodmodule.vala
==============================================================================
--- trunk/gobject/valaccodemethodmodule.vala (original)
+++ trunk/gobject/valaccodemethodmodule.vala Fri Jan 23 14:20:15 2009
@@ -515,6 +515,13 @@
}
}
+ public virtual void generate_parameter (FormalParameter param, Map<int,CCodeFormalParameter> cparam_map, Map<int,CCodeExpression>? carg_map) {
+ cparam_map.set (get_param_pos (param.cparameter_position), (CCodeFormalParameter) param.ccodenode);
+ if (carg_map != null) {
+ carg_map.set (get_param_pos (param.cparameter_position), new CCodeIdentifier (param.name));
+ }
+ }
+
public override void generate_cparameters (Method m, DataType creturn_type, bool in_gtypeinstance_creation_method, Map<int,CCodeFormalParameter> cparam_map, CCodeFunction func, CCodeFunctionDeclarator? vdeclarator = null, Map<int,CCodeExpression>? carg_map = null, CCodeFunctionCall? vcall = null, int direction = 3) {
if (m.parent_symbol is Class && m is CreationMethod) {
var cl = (Class) m.parent_symbol;
@@ -588,52 +595,7 @@
}
}
- if (!param.no_array_length && param.parameter_type is ArrayType) {
- var array_type = (ArrayType) param.parameter_type;
-
- var length_ctype = "int";
- if (param.direction != ParameterDirection.IN) {
- length_ctype = "int*";
- }
-
- for (int dim = 1; dim <= array_type.rank; dim++) {
- var cparam = new CCodeFormalParameter (head.get_array_length_cname (param.name, dim), length_ctype);
- cparam_map.set (get_param_pos (param.carray_length_parameter_position + 0.01 * dim), cparam);
- if (carg_map != null) {
- carg_map.set (get_param_pos (param.carray_length_parameter_position + 0.01 * dim), new CCodeIdentifier (cparam.name));
- }
- }
- }
-
- cparam_map.set (get_param_pos (param.cparameter_position), (CCodeFormalParameter) param.ccodenode);
- if (carg_map != null) {
- carg_map.set (get_param_pos (param.cparameter_position), new CCodeIdentifier (param.name));
- }
-
- if (param.parameter_type is DelegateType) {
- var deleg_type = (DelegateType) param.parameter_type;
- var d = deleg_type.delegate_symbol;
- if (d.has_target) {
- var cparam = new CCodeFormalParameter (get_delegate_target_cname (param.name), "void*");
- cparam_map.set (get_param_pos (param.cdelegate_target_parameter_position), cparam);
- if (carg_map != null) {
- carg_map.set (get_param_pos (param.cdelegate_target_parameter_position), new CCodeIdentifier (cparam.name));
- }
- if (deleg_type.value_owned) {
- cparam = new CCodeFormalParameter (get_delegate_target_destroy_notify_cname (param.name), "GDestroyNotify");
- cparam_map.set (get_param_pos (param.cdelegate_target_parameter_position + 0.01), cparam);
- if (carg_map != null) {
- carg_map.set (get_param_pos (param.cdelegate_target_parameter_position + 0.01), new CCodeIdentifier (cparam.name));
- }
- }
- }
- } else if (param.parameter_type is MethodType) {
- var cparam = new CCodeFormalParameter (get_delegate_target_cname (param.name), "void*");
- cparam_map.set (get_param_pos (param.cdelegate_target_parameter_position), cparam);
- if (carg_map != null) {
- carg_map.set (get_param_pos (param.cdelegate_target_parameter_position), new CCodeIdentifier (cparam.name));
- }
- }
+ generate_parameter (param, cparam_map, carg_map);
}
if ((direction & 2) != 0) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]