[vala] Fix type declaration order for captured variables and parameters
- From: Jürg Billeter <juergbi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala] Fix type declaration order for captured variables and parameters
- Date: Thu, 8 Apr 2010 09:11:53 +0000 (UTC)
commit 681ca503df00e9dd9969a90dccc42dfc9f440d84
Author: Jürg Billeter <j bitron ch>
Date: Thu Apr 8 11:06:27 2010 +0200
Fix type declaration order for captured variables and parameters
codegen/valaccodebasemodule.vala | 12 ++++++++----
1 files changed, 8 insertions(+), 4 deletions(-)
---
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index 7e99f28..91b14e3 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -1701,6 +1701,8 @@ internal class Vala.CCodeBaseModule : CCodeModule {
}
void capture_parameter (FormalParameter param, CCodeStruct data, CCodeBlock cblock, int block_id, CCodeBlock free_block) {
+ generate_type_declaration (param.parameter_type, source_declarations);
+
var param_type = param.parameter_type.copy ();
param_type.value_owned = true;
data.add_field (param_type.get_cname (), get_variable_cname (param.name));
@@ -1795,6 +1797,8 @@ internal class Vala.CCodeBaseModule : CCodeModule {
}
foreach (var local in local_vars) {
if (local.captured) {
+ generate_type_declaration (local.variable_type, source_declarations);
+
data.add_field (local.variable_type.get_cname (), get_variable_cname (local.name) + local.variable_type.get_cdeclarator_suffix ());
if (local.variable_type is ArrayType) {
@@ -1829,10 +1833,6 @@ internal class Vala.CCodeBaseModule : CCodeModule {
}
}
- var typedef = new CCodeTypeDefinition ("struct _" + struct_name, new CCodeVariableDeclarator (struct_name));
- source_declarations.add_type_declaration (typedef);
- source_declarations.add_type_definition (data);
-
var data_alloc = new CCodeFunctionCall (new CCodeIdentifier ("g_slice_new0"));
data_alloc.add_argument (new CCodeIdentifier (struct_name));
@@ -1900,6 +1900,10 @@ internal class Vala.CCodeBaseModule : CCodeModule {
cblock.add_statement (cfrag);
}
+ var typedef = new CCodeTypeDefinition ("struct _" + struct_name, new CCodeVariableDeclarator (struct_name));
+ source_declarations.add_type_declaration (typedef);
+ source_declarations.add_type_definition (data);
+
var data_free = new CCodeFunctionCall (new CCodeIdentifier ("g_slice_free"));
data_free.add_argument (new CCodeIdentifier (struct_name));
data_free.add_argument (new CCodeIdentifier ("_data%d_".printf (block_id)));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]