[vala] codegen: Do not use C statement nodes in property accessors
- From: Jürg Billeter <juergbi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala] codegen: Do not use C statement nodes in property accessors
- Date: Sun, 10 Oct 2010 16:38:52 +0000 (UTC)
commit 1df48495e26cd21a0c7b3018dc15f1f65bc8543f
Author: Jürg Billeter <j bitron ch>
Date: Sun Oct 10 11:33:25 2010 +0200
codegen: Do not use C statement nodes in property accessors
codegen/valaccodebasemodule.vala | 11 ++++++-----
codegen/valadovaobjectmodule.vala | 16 ++++++++++------
2 files changed, 16 insertions(+), 11 deletions(-)
---
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index 9c07a9d..e8d6764 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -1397,8 +1397,7 @@ public class Vala.CCodeBaseModule : CodeGenerator {
function.modifiers |= CCodeModifiers.STATIC;
}
- var block = new CCodeBlock ();
- function.block = block;
+ push_function (function);
CCodeFunctionCall vcast = null;
if (prop.parent_symbol is Interface) {
@@ -1417,7 +1416,7 @@ public class Vala.CCodeBaseModule : CodeGenerator {
vcall.add_argument (new CCodeIdentifier ("self"));
if (returns_real_struct) {
vcall.add_argument (new CCodeIdentifier ("result"));
- block.add_statement (new CCodeExpressionStatement (vcall));
+ ccode.add_expression (vcall);
} else {
if (acc.value_type is ArrayType) {
var array_type = (ArrayType) acc.value_type;
@@ -1430,7 +1429,7 @@ public class Vala.CCodeBaseModule : CodeGenerator {
vcall.add_argument (new CCodeIdentifier (get_delegate_target_cname ("result")));
}
- block.add_statement (new CCodeReturnStatement (vcall));
+ ccode.add_return (vcall);
}
} else {
var vcall = new CCodeFunctionCall (new CCodeMemberAccess.pointer (vcast, "set_%s".printf (prop.name)));
@@ -1448,9 +1447,11 @@ public class Vala.CCodeBaseModule : CodeGenerator {
vcall.add_argument (new CCodeIdentifier (get_delegate_target_cname ("value")));
}
- block.add_statement (new CCodeExpressionStatement (vcall));
+ ccode.add_expression (vcall);
}
+ pop_function ();
+
cfile.add_function (function);
}
diff --git a/codegen/valadovaobjectmodule.vala b/codegen/valadovaobjectmodule.vala
index 7a0e7ba..6112c72 100644
--- a/codegen/valadovaobjectmodule.vala
+++ b/codegen/valadovaobjectmodule.vala
@@ -1210,22 +1210,23 @@ public class Vala.DovaObjectModule : DovaArrayModule {
function.modifiers |= CCodeModifiers.STATIC;
}
- var block = new CCodeBlock ();
- function.block = block;
+ push_function (function);
var vcast = get_type_private_from_type ((ObjectTypeSymbol) prop.parent_symbol, get_type_from_instance (new CCodeIdentifier ("this")));
if (acc.readable) {
var vcall = new CCodeFunctionCall (new CCodeMemberAccess.pointer (vcast, "get_%s".printf (prop.name)));
vcall.add_argument (new CCodeIdentifier ("this"));
- block.add_statement (new CCodeReturnStatement (vcall));
+ ccode.add_return (vcall);
} else {
var vcall = new CCodeFunctionCall (new CCodeMemberAccess.pointer (vcast, "set_%s".printf (prop.name)));
vcall.add_argument (new CCodeIdentifier ("this"));
vcall.add_argument (new CCodeIdentifier ("value"));
- block.add_statement (new CCodeExpressionStatement (vcall));
+ ccode.add_expression (vcall);
}
+ pop_function ();
+
cfile.add_function (function);
@@ -1239,11 +1240,14 @@ public class Vala.DovaObjectModule : DovaArrayModule {
var override_func = new CCodeFunction ("%soverride_%s_%s".printf (prop.parent_symbol.get_lower_case_cprefix (), acc.readable ? "get" : "set", prop.name));
override_func.add_parameter (new CCodeFormalParameter ("type", "DovaType *"));
override_func.add_parameter (new CCodeFormalParameter ("(*function) %s".printf (param_list), acc.readable ? acc.value_type.get_cname () : "void"));
- override_func.block = new CCodeBlock ();
+
+ push_function (override_func);
vcast = get_type_private_from_type ((ObjectTypeSymbol) prop.parent_symbol, new CCodeIdentifier ("type"));
- override_func.block.add_statement (new CCodeExpressionStatement (new CCodeAssignment (new CCodeMemberAccess.pointer (vcast, "%s_%s".printf (acc.readable ? "get" : "set", prop.name)), new CCodeIdentifier ("function"))));
+ ccode.add_expression (new CCodeAssignment (new CCodeMemberAccess.pointer (vcast, "%s_%s".printf (acc.readable ? "get" : "set", prop.name)), new CCodeIdentifier ("function")));
+
+ pop_function ();
cfile.add_function (override_func);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]