[vala] GObject: Only declare boxed variable when used
- From: Jürg Billeter <juergbi src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [vala] GObject: Only declare boxed variable when used
- Date: Wed, 16 Sep 2009 12:23:07 +0000 (UTC)
commit 2abd2b63ff9ebb87053fe9e1152e2be511efe257
Author: Jürg Billeter <j bitron ch>
Date: Wed Sep 16 14:20:23 2009 +0200
GObject: Only declare boxed variable when used
codegen/valagobjectmodule.vala | 11 ++++++++---
1 files changed, 8 insertions(+), 3 deletions(-)
---
diff --git a/codegen/valagobjectmodule.vala b/codegen/valagobjectmodule.vala
index 7b3b515..504474c 100644
--- a/codegen/valagobjectmodule.vala
+++ b/codegen/valagobjectmodule.vala
@@ -189,9 +189,7 @@ internal class Vala.GObjectModule : GTypeModule {
cdecl.add_declarator (new CCodeVariableDeclarator ("self", ccall));
block.add_statement (cdecl);
- cdecl = new CCodeDeclaration ("gpointer");
- cdecl.add_declarator (new CCodeVariableDeclarator ("boxed"));
- block.add_statement (cdecl);
+ bool boxed_declared = false;
var cswitch = new CCodeSwitchStatement (new CCodeIdentifier ("property_id"));
var props = cl.get_properties ();
@@ -222,6 +220,13 @@ internal class Vala.GObjectModule : GTypeModule {
cswitch.add_statement (new CCodeCaseStatement (new CCodeIdentifier (prop.get_upper_case_cname ())));
if (prop.property_type.is_real_struct_type ()) {
+ if (!boxed_declared) {
+ cdecl = new CCodeDeclaration ("gpointer");
+ cdecl.add_declarator (new CCodeVariableDeclarator ("boxed"));
+ block.add_statement (cdecl);
+ boxed_declared = true;
+ }
+
var st = prop.property_type.data_type as Struct;
var struct_creation = new CCodeFunctionCall (new CCodeIdentifier ("g_new0"));
struct_creation.add_argument (new CCodeIdentifier (st.get_cname ()));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]