[vala] Support external constants



commit 9cfacd54acfff052f475d86d28ff1dd8afe9f513
Author: Jürg Billeter <j bitron ch>
Date:   Tue Apr 14 18:54:29 2009 +0200

    Support external constants
---
 gobject/valaccodebasemodule.vala |   26 ++++++++++++++------------
 vala/valaconstant.vala           |    2 +-
 2 files changed, 15 insertions(+), 13 deletions(-)

diff --git a/gobject/valaccodebasemodule.vala b/gobject/valaccodebasemodule.vala
index d2d0afd..069be00 100644
--- a/gobject/valaccodebasemodule.vala
+++ b/gobject/valaccodebasemodule.vala
@@ -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);
+			}
 		}
 	}
 
diff --git a/vala/valaconstant.vala b/vala/valaconstant.vala
index dd5c4a8..81ed913 100644
--- a/vala/valaconstant.vala
+++ b/vala/valaconstant.vala
@@ -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");



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]