]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
Support external constants
authorJürg Billeter <j@bitron.ch>
Tue, 14 Apr 2009 16:54:29 +0000 (18:54 +0200)
committerJürg Billeter <j@bitron.ch>
Tue, 14 Apr 2009 16:54:29 +0000 (18:54 +0200)
gobject/valaccodebasemodule.vala
vala/valaconstant.vala

index d2d0afd33f4f602a98f20b75342a387d60c4908c..069be00ce6d950dfebbdc03eff14cea4827a4ddb 100644 (file)
@@ -746,19 +746,21 @@ internal class Vala.CCodeBaseModule : CCodeModule {
 
                c.accept_children (codegen);
 
-               if (c.initializer is InitializerList) {
-                       var cdecl = new CCodeDeclaration (c.type_reference.get_const_cname ());
-                       var arr = "";
-                       if (c.type_reference is ArrayType) {
-                               arr = "[]";
-                       }
-                       cdecl.add_declarator (new CCodeVariableDeclarator ("%s%s".printf (c.get_cname (), arr), (CCodeExpression) c.initializer.ccodenode));
-                       cdecl.modifiers = CCodeModifiers.STATIC;
+               if (!c.external) {
+                       if (c.initializer is InitializerList) {
+                               var cdecl = new CCodeDeclaration (c.type_reference.get_const_cname ());
+                               var arr = "";
+                               if (c.type_reference is ArrayType) {
+                                       arr = "[]";
+                               }
+                               cdecl.add_declarator (new CCodeVariableDeclarator ("%s%s".printf (c.get_cname (), arr), (CCodeExpression) c.initializer.ccodenode));
+                               cdecl.modifiers = CCodeModifiers.STATIC;
                
-                       decl_space.add_constant_declaration (cdecl);
-               } else {
-                       var cdefine = new CCodeMacroReplacement.with_expression (c.get_cname (), (CCodeExpression) c.initializer.ccodenode);
-                       decl_space.add_type_member_declaration (cdefine);
+                               decl_space.add_constant_declaration (cdecl);
+                       } else {
+                               var cdefine = new CCodeMacroReplacement.with_expression (c.get_cname (), (CCodeExpression) c.initializer.ccodenode);
+                               decl_space.add_type_member_declaration (cdefine);
+                       }
                }
        }
 
index dd5c4a8dc2b5e0f0857ed606ad0b68a9e4319967..81ed913fa112c7fa8d930b56f90107d040d4360d 100644 (file)
@@ -170,7 +170,7 @@ public class Vala.Constant : Member, Lockable {
 
                type_reference.check (analyzer);
 
-               if (!external_package) {
+               if (!external) {
                        if (initializer == null) {
                                error = true;
                                Report.error (source_reference, "A const field requires a initializer to be provided");