Commit 150fc53d authored by Jürg Billeter's avatar Jürg Billeter Committed by Jürg Billeter
Browse files

fix initialization of external variables

2007-08-20  Juerg Billeter  <j@bitron.ch>

	* ccode/valaccodedeclaration.vala, ccode/valaccodemodifiers.vala,
	  gobject/valacodegenerator.vala: fix initialization of external
	  variables

svn path=/trunk/; revision=487
parent be9e1c92
2007-08-20 Jürg Billeter <j@bitron.ch>
* ccode/valaccodedeclaration.vala, ccode/valaccodemodifiers.vala,
gobject/valacodegenerator.vala: fix initialization of external
variables
2007-08-20 Jürg Billeter <j@bitron.ch>
* vala/valafield.vala, gobject/valacodegenerator.vala,
......
......@@ -52,10 +52,12 @@ public class Vala.CCodeDeclaration : CCodeStatement {
}
public override void write (CCodeWriter! writer) {
if ((modifiers & CCodeModifiers.STATIC) == CCodeModifiers.STATIC) {
// combined declaration and initialization for static variables
if ((modifiers & (CCodeModifiers.STATIC | CCodeModifiers.EXTERN)) != 0) {
// combined declaration and initialization for static and extern variables
writer.write_indent ();
writer.write_string ("static ");
if ((modifiers & CCodeModifiers.STATIC) != 0) {
writer.write_string ("static ");
}
writer.write_string (type_name);
writer.write_string (" ");
......@@ -79,7 +81,7 @@ public class Vala.CCodeDeclaration : CCodeStatement {
}
public override void write_declaration (CCodeWriter! writer) {
if ((modifiers & CCodeModifiers.STATIC) == CCodeModifiers.STATIC) {
if ((modifiers & (CCodeModifiers.STATIC | CCodeModifiers.EXTERN)) != 0) {
// no separate declaration for static variables
return;
}
......
/* valaccodemodifiers.vala
*
* Copyright (C) 2006 Jürg Billeter, Raffaele Sandrini
* Copyright (C) 2006-2007 Jürg Billeter, Raffaele Sandrini
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
......@@ -23,8 +23,10 @@
using GLib;
public enum /* flags */ Vala.CCodeModifiers {
[Flags]
public enum Vala.CCodeModifiers {
NONE,
STATIC,
REGISTER
REGISTER,
EXTERN
}
......@@ -419,6 +419,7 @@ public class Vala.CodeGenerator : CodeVisitor {
}
}
cdecl.add_declarator (var_decl);
cdecl.modifiers = CCodeModifiers.EXTERN;
source_type_member_declaration.append (cdecl);
lhs = new CCodeIdentifier (f.get_cname ());
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment