vala r1150 - in trunk: . ccode gobject
- From: juergbi svn gnome org
- To: svn-commits-list gnome org
- Subject: vala r1150 - in trunk: . ccode gobject
- Date: Sat, 22 Mar 2008 22:03:20 +0000 (GMT)
Author: juergbi
Date: Sat Mar 22 22:03:19 2008
New Revision: 1150
URL: http://svn.gnome.org/viewvc/vala?rev=1150&view=rev
Log:
2008-03-22 Juerg Billeter <j bitron ch>
* ccode/valaccodedeclaration.vala, gobject/valaccodegenerator.vala:
use extern appropriately for static fields,
based on patch by Daniel Silverstone, fixes bug 523768
Modified:
trunk/ChangeLog
trunk/ccode/valaccodedeclaration.vala
trunk/gobject/valaccodegenerator.vala
Modified: trunk/ccode/valaccodedeclaration.vala
==============================================================================
--- trunk/ccode/valaccodedeclaration.vala (original)
+++ trunk/ccode/valaccodedeclaration.vala Sat Mar 22 22:03:19 2008
@@ -1,6 +1,6 @@
/* valaccodedeclaration.vala
*
- * Copyright (C) 2006-2007 JÃrg Billeter
+ * Copyright (C) 2006-2008 JÃrg Billeter
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -58,6 +58,9 @@
if ((modifiers & CCodeModifiers.STATIC) != 0) {
writer.write_string ("static ");
}
+ if ((modifiers & CCodeModifiers.EXTERN) != 0 && !has_initializer ()) {
+ writer.write_string ("extern ");
+ }
writer.write_string (type_name);
writer.write_string (" ");
@@ -80,6 +83,16 @@
}
}
+ private bool has_initializer () {
+ foreach (CCodeDeclarator decl in declarators) {
+ var var_decl = decl as CCodeVariableDeclarator;
+ if (var_decl != null && var_decl.initializer == null) {
+ return false;
+ }
+ }
+ return true;
+ }
+
public override void write_declaration (CCodeWriter! writer) {
if ((modifiers & (CCodeModifiers.STATIC | CCodeModifiers.EXTERN)) != 0) {
// no separate declaration for static variables
Modified: trunk/gobject/valaccodegenerator.vala
==============================================================================
--- trunk/gobject/valaccodegenerator.vala (original)
+++ trunk/gobject/valaccodegenerator.vala Sat Mar 22 22:03:19 2008
@@ -517,18 +517,21 @@
cdecl.modifiers = CCodeModifiers.EXTERN;
header_type_member_declaration.append (cdecl);
+ var var_decl = new CCodeVariableDeclarator (f.get_cname ());
+ var_decl.initializer = default_value_for_type (f.type_reference);
+
if (f.initializer != null) {
var init = (CCodeExpression) f.initializer.ccodenode;
if (is_constant_ccode_expression (init)) {
- var cinit_decl = new CCodeDeclaration (field_ctype);
- var var_decl = new CCodeVariableDeclarator (f.get_cname ());
var_decl.initializer = init;
- cinit_decl.add_declarator (var_decl);
- cinit_decl.modifiers = CCodeModifiers.EXTERN;
- source_type_member_declaration.append (cinit_decl);
}
}
+ var var_def = new CCodeDeclaration (field_ctype);
+ var_def.add_declarator (var_decl);
+ var_def.modifiers = CCodeModifiers.EXTERN;
+ source_type_member_declaration.append (var_def);
+
lhs = new CCodeIdentifier (f.get_cname ());
}
} else if (f.access == SymbolAccessibility.PRIVATE) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]