[vala/wip/attributes: 6/121] Move cheader_filename out of the code tree



commit 6c1f7804b7c737487c7e63f530ccd9958db62142
Author: Luca Bruno <lucabru src gnome org>
Date:   Sat Jun 25 17:35:05 2011 +0200

    Move cheader_filename out of the code tree

 codegen/valaccodebasemodule.vala |   56 ++++++++++++++++++++++++++++++------
 codegen/valadovabasemodule.vala  |    2 +-
 codegen/valagirwriter.vala       |    4 +-
 vala/valaclass.vala              |    6 ----
 vala/valacodenode.vala           |   18 ++++++++++++
 vala/valacodewriter.vala         |   24 +++++++--------
 vala/valaconstant.vala           |    6 ----
 vala/valadelegate.vala           |    6 ----
 vala/valadynamicmethod.vala      |    4 --
 vala/valadynamicproperty.vala    |    4 --
 vala/valaenum.vala               |    6 ----
 vala/valaerrordomain.vala        |    6 ----
 vala/valafield.vala              |    6 ----
 vala/valagirparser.vala          |   15 ++--------
 vala/valainterface.vala          |    6 ----
 vala/valamethod.vala             |    6 ----
 vala/valanamespace.vala          |    6 ----
 vala/valapropertyaccessor.vala   |    4 --
 vala/valastruct.vala             |    6 ----
 vala/valasymbol.vala             |   58 --------------------------------------
 vapigen/valagidlparser.vala      |   36 ++++++++++++------------
 21 files changed, 100 insertions(+), 185 deletions(-)
---
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index b0d0e7c..f15d2a4 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -544,7 +544,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
 		}
 		if (sym.external_package || (!decl_space.is_header && CodeContext.get ().use_header && !sym.is_internal_symbol ())) {
 			// add appropriate include file
-			foreach (string header_filename in sym.get_cheader_filenames ()) {
+			foreach (string header_filename in get_ccode_header_filenames (sym)) {
 				decl_space.add_include (header_filename, !sym.external_package);
 			}
 			// declaration complete
@@ -5574,6 +5574,10 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
 		return get_ccode_attribute(iface).type_name;
 	}
 
+	public static List<string> get_ccode_header_filenames (Symbol sym) {
+		return get_ccode_attribute(sym).header_filenames;
+	}
+
 	public override void visit_class (Class cl) {
 	}
 
@@ -5904,6 +5908,7 @@ public class Vala.GLibValue : TargetValue {
 
 public class Vala.CCodeAttribute : AttributeCache {
 	public weak CodeNode node;
+	public weak Symbol sym;
 
 	public string name {
 		get {
@@ -5954,9 +5959,38 @@ public class Vala.CCodeAttribute : AttributeCache {
 		}
 	}
 
+	public List<string> header_filenames {
+		get {
+			if (_header_filenames == null) {
+				_header_filenames = get_default_header_filenames ();
+			}
+			return _header_filenames;
+		}
+	}
+
 	private string _name;
 	private string _const_name;
 	private string _type_name;
+	private List<string> _header_filenames;
+
+	public CCodeAttribute (CodeNode node) {
+		this.node = node;
+		this.sym = node as Symbol;
+
+		var attr = node.get_attribute ("CCode");
+		if (attr != null) {
+			_name = attr.get_string ("cname");
+			_const_name = attr.get_string ("const_cname");
+			_type_name = attr.get_string ("type_cname");
+			var headers = attr.get_string ("cheader_filename");
+			if (headers != null) {
+				_header_filenames = new ArrayList<string> ();
+				foreach (var header in headers.split (",")) {
+					_header_filenames.add (header);
+				}
+			}
+		}
+	}
 
 	private string get_default_name () {
 		var sym = node as Symbol;
@@ -6089,14 +6123,18 @@ public class Vala.CCodeAttribute : AttributeCache {
 		}
 	}
 
-	public CCodeAttribute (CodeNode node) {
-		this.node = node;
-
-		var attr = node.get_attribute ("CCode");
-		if (attr != null) {
-			_name = attr.get_string ("cname");
-			_const_name = attr.get_string ("const_cname");
-			_type_name = attr.get_string ("type_cname");
+	private List<string> get_default_header_filenames () {
+		if (sym is DynamicProperty || sym is DynamicMethod) {
+			return new ArrayList<string> ();
+		} else if (sym.parent_symbol != null) {
+			return CCodeBaseModule.get_ccode_header_filenames (sym.parent_symbol);
+		} else {
+			var headers = new ArrayList<string> ();
+			if (sym.source_reference != null && !sym.external_package) {
+				// don't add default include directives for VAPI files
+				headers.add (sym.source_reference.file.get_cinclude_filename ());
+			}
+			return headers;
 		}
 	}
 }
diff --git a/codegen/valadovabasemodule.vala b/codegen/valadovabasemodule.vala
index 5ee0675..ec45d9d 100644
--- a/codegen/valadovabasemodule.vala
+++ b/codegen/valadovabasemodule.vala
@@ -333,7 +333,7 @@ public abstract class Vala.DovaBaseModule : CodeGenerator {
 		}
 		if (sym.external_package || (!decl_space.is_header && CodeContext.get ().use_header && !sym.is_internal_symbol ())) {
 			// add appropriate include file
-			foreach (string header_filename in sym.get_cheader_filenames ()) {
+			foreach (string header_filename in CCodeBaseModule.get_ccode_header_filenames (sym)) {
 				decl_space.add_include (header_filename, !sym.external_package);
 			}
 			// declaration complete
diff --git a/codegen/valagirwriter.vala b/codegen/valagirwriter.vala
index a29b654..56c746d 100644
--- a/codegen/valagirwriter.vala
+++ b/codegen/valagirwriter.vala
@@ -128,11 +128,11 @@ public class Vala.GIRWriter : CodeVisitor {
 	private void write_c_includes (Namespace ns) {
 		// Collect C header filenames
 		Set<string> header_filenames = new HashSet<string> (str_hash, str_equal);
-		foreach (string c_header_filename in ns.get_cheader_filenames ()) {
+		foreach (string c_header_filename in CCodeBaseModule.get_ccode_header_filenames (ns)) {
 			header_filenames.add (c_header_filename);
 		}
 		foreach (Symbol symbol in ns.scope.get_symbol_table ().get_values ()) {
-			foreach (string c_header_filename in symbol.get_cheader_filenames ()) {
+			foreach (string c_header_filename in CCodeBaseModule.get_ccode_header_filenames (symbol)) {
 				header_filenames.add (c_header_filename);
 			}
 		}
diff --git a/vala/valaclass.vala b/vala/valaclass.vala
index c88b5d3..2b30864 100644
--- a/vala/valaclass.vala
+++ b/vala/valaclass.vala
@@ -712,12 +712,6 @@ public class Vala.Class : ObjectTypeSymbol {
 		if (a.has_argument ("lower_case_csuffix")) {
 			lower_case_csuffix = a.get_string ("lower_case_csuffix");
 		}
-		if (a.has_argument ("cheader_filename")) {
-			var val = a.get_string ("cheader_filename");
-			foreach (string filename in val.split (",")) {
-				add_cheader_filename (filename);
-			}
-		}
 		if (a.has_argument ("type_check_function")) {
 			type_check_function = a.get_string ("type_check_function");
 		}
diff --git a/vala/valacodenode.vala b/vala/valacodenode.vala
index fbde238..40728a1 100644
--- a/vala/valacodenode.vala
+++ b/vala/valacodenode.vala
@@ -154,6 +154,24 @@ public abstract class Vala.CodeNode {
 	}
 
 	/**
+	 * Sets the string value of the specified attribute argument.
+	 *
+	 * @param attribute attribute name
+	 * @param argument  argument name
+	 * @param value     string value
+	 */
+	public void set_attribute_string (string attribute, string argument, string value, SourceReference? source_reference = null) {
+		var attr = get_attribute (attribute);
+
+		if (attr == null) {
+			attr = new Attribute (attribute, source_reference);
+			attributes.append (attr);
+		}
+
+		attr.add_argument (argument, "\"%s\"".printf (value));
+	}
+
+	/**
 	 * Returns the specified attribute cache.
 	 *
 	 * @param hash hash number
diff --git a/vala/valacodewriter.vala b/vala/valacodewriter.vala
index a8a62c9..ff02a7e 100644
--- a/vala/valacodewriter.vala
+++ b/vala/valacodewriter.vala
@@ -182,21 +182,19 @@ public class Vala.CodeWriter : CodeVisitor {
 		write_newline ();
 	}
 
-	private string get_cheaders (Symbol cl) {
-		bool first = true;
+	private string get_cheaders (Symbol sym) {
 		string cheaders = "";
 		if (type != CodeWriterType.FAST) {
-			foreach (string cheader in cl.get_cheader_filenames ()) {
-				if (header_to_override != null &&
-				    cheader == header_to_override) {
-					cheader = override_header;
-				}
-				if (first) {
-					cheaders = cheader;
-					first = false;
-				} else {
-					cheaders = "%s,%s".printf (cheaders, cheader);
-				}
+			var a = sym.get_attribute ("CCode");
+			if (a != null && a.has_argument ("cheader_filename")) {
+				cheaders = a.get_string ("cheader_filename");
+			} else if (sym.parent_symbol != null) {
+				cheaders = get_cheaders (sym.parent_symbol);
+			} else if (sym.source_reference != null) {
+				cheaders = sym.source_reference.file.get_cinclude_filename ();
+			}
+			if (header_to_override != null) {
+				cheaders = cheaders.replace (header_to_override, override_header).replace (",,", ",");
 			}
 		}
 		return cheaders;
diff --git a/vala/valaconstant.vala b/vala/valaconstant.vala
index 0c77d07..b6bb8e1 100644
--- a/vala/valaconstant.vala
+++ b/vala/valaconstant.vala
@@ -142,12 +142,6 @@ public class Vala.Constant : Symbol, Lockable {
 		if (a.has_argument ("cname")) {
 			cname = a.get_string ("cname");
 		}
-		if (a.has_argument ("cheader_filename")) {
-			var val = a.get_string ("cheader_filename");
-			foreach (string filename in val.split (",")) {
-				add_cheader_filename (filename);
-			}
-		}
 	}
 
 	/**
diff --git a/vala/valadelegate.vala b/vala/valadelegate.vala
index ddaba92..dd021f2 100644
--- a/vala/valadelegate.vala
+++ b/vala/valadelegate.vala
@@ -304,12 +304,6 @@ public class Vala.Delegate : TypeSymbol {
 		if (a.has_argument ("delegate_target_pos")) {
 			cdelegate_target_parameter_position = a.get_double ("delegate_target_pos");
 		}
-		if (a.has_argument ("cheader_filename")) {
-			var val = a.get_string ("cheader_filename");
-			foreach (string filename in val.split (",")) {
-				add_cheader_filename (filename);
-			}
-		}
 	}
 	
 	/**
diff --git a/vala/valadynamicmethod.vala b/vala/valadynamicmethod.vala
index 3fc98f6..ff5f4e2 100644
--- a/vala/valadynamicmethod.vala
+++ b/vala/valadynamicmethod.vala
@@ -38,10 +38,6 @@ public class Vala.DynamicMethod : Method {
 		this.dynamic_type = dynamic_type;
 	}
 
-	public override List<string> get_cheader_filenames () {
-		return new ArrayList<string> ();
-	}
-
 	public override string get_default_cname () {
 		// return cname of wrapper method
 		if (cname == null) {
diff --git a/vala/valadynamicproperty.vala b/vala/valadynamicproperty.vala
index dc9acb5..a15ff2f 100644
--- a/vala/valadynamicproperty.vala
+++ b/vala/valadynamicproperty.vala
@@ -33,10 +33,6 @@ public class Vala.DynamicProperty : Property {
 		this.dynamic_type = dynamic_type;
 	}
 
-	public override List<string> get_cheader_filenames () {
-		return new ArrayList<string> ();
-	}
-
 	public override bool check (CodeContext context) {
 		return true;
 	}
diff --git a/vala/valaenum.vala b/vala/valaenum.vala
index fed3286..0acf6f9 100644
--- a/vala/valaenum.vala
+++ b/vala/valaenum.vala
@@ -232,12 +232,6 @@ public class Vala.Enum : TypeSymbol {
 		if (a.has_argument ("lower_case_csuffix")) {
 			lower_case_csuffix = a.get_string ("lower_case_csuffix");
 		}
-		if (a.has_argument ("cheader_filename")) {
-			var val = a.get_string ("cheader_filename");
-			foreach (string filename in val.split (",")) {
-				add_cheader_filename (filename);
-			}
-		}
 		if (a.has_argument ("has_type_id")) {
 			has_type_id = a.get_bool ("has_type_id");
 		}
diff --git a/vala/valaerrordomain.vala b/vala/valaerrordomain.vala
index 40dd9b1..12f9f37 100644
--- a/vala/valaerrordomain.vala
+++ b/vala/valaerrordomain.vala
@@ -180,12 +180,6 @@ public class Vala.ErrorDomain : TypeSymbol {
 		if (a.has_argument ("lower_case_csuffix")) {
 			lower_case_csuffix = a.get_string ("lower_case_csuffix");
 		}
-		if (a.has_argument ("cheader_filename")) {
-			var val = a.get_string ("cheader_filename");
-			foreach (string filename in val.split (",")) {
-				add_cheader_filename (filename);
-			}
-		}
 	}
 	
 	/**
diff --git a/vala/valafield.vala b/vala/valafield.vala
index 4d260d1..27eb95a 100644
--- a/vala/valafield.vala
+++ b/vala/valafield.vala
@@ -105,12 +105,6 @@ public class Vala.Field : Variable, Lockable {
 		if (a.has_argument ("cname")) {
 			set_cname (a.get_string ("cname"));
 		}
-		if (a.has_argument ("cheader_filename")) {
-			var val = a.get_string ("cheader_filename");
-			foreach (string filename in val.split (",")) {
-				add_cheader_filename (filename);
-			}
-		}
 	}
 	
 	/**
diff --git a/vala/valagirparser.vala b/vala/valagirparser.vala
index b64f2dd..a64f41c 100644
--- a/vala/valagirparser.vala
+++ b/vala/valagirparser.vala
@@ -852,9 +852,7 @@ public class Vala.GirParser : CodeVisitor {
 				// cheader filename
 				var cheader_filename = metadata.get_string (ArgumentType.CHEADER_FILENAME);
 				if (cheader_filename != null) {
-					foreach (string filename in cheader_filename.split (",")) {
-						symbol.add_cheader_filename (filename);
-					}
+					symbol.set_attribute_string ("CCode", "cheader_filename", cheader_filename);
 				}
 			}
 
@@ -1643,15 +1641,8 @@ public class Vala.GirParser : CodeVisitor {
 			ns.set_lower_case_cprefix (Symbol.camel_case_to_lower_case (cprefix) + "_");
 		}
 
-		if (ns_metadata.has_argument (ArgumentType.CHEADER_FILENAME)) {
-			var val = ns_metadata.get_string (ArgumentType.CHEADER_FILENAME);
-			foreach (string filename in val.split (",")) {
-				ns.add_cheader_filename (filename);
-			}
-		} else {
-			foreach (string c_header in cheader_filenames) {
-				ns.add_cheader_filename (c_header);
-			}
+		if (cheader_filenames != null) {
+			ns.set_attribute_string ("CCode", "cheader_filename", string.joinv (",", cheader_filenames));
 		}
 
 		next ();
diff --git a/vala/valainterface.vala b/vala/valainterface.vala
index d189323..b56755b 100644
--- a/vala/valainterface.vala
+++ b/vala/valainterface.vala
@@ -473,12 +473,6 @@ public class Vala.Interface : ObjectTypeSymbol {
 		if (a.has_argument ("type_cname")) {
 			set_type_cname (a.get_string ("type_cname"));
 		}
-		if (a.has_argument ("cheader_filename")) {
-			var val = a.get_string ("cheader_filename");
-			foreach (string filename in val.split (",")) {
-				add_cheader_filename (filename);
-			}
-		}
 		if (a.has_argument ("lower_case_csuffix")) {
 			lower_case_csuffix = a.get_string ("lower_case_csuffix");
 		}
diff --git a/vala/valamethod.vala b/vala/valamethod.vala
index 9664072..b5e12f6 100644
--- a/vala/valamethod.vala
+++ b/vala/valamethod.vala
@@ -427,12 +427,6 @@ public class Vala.Method : Subroutine {
 		if (a.has_argument ("cname")) {
 			set_cname (a.get_string ("cname"));
 		}
-		if (a.has_argument ("cheader_filename")) {
-			var val = a.get_string ("cheader_filename");
-			foreach (string filename in val.split (",")) {
-				add_cheader_filename (filename);
-			}
-		}
 		if (a.has_argument ("vfunc_name")) {
 			this.vfunc_name = a.get_string ("vfunc_name");
 		}
diff --git a/vala/valanamespace.vala b/vala/valanamespace.vala
index 45abd68..dc8614b 100644
--- a/vala/valanamespace.vala
+++ b/vala/valanamespace.vala
@@ -581,12 +581,6 @@ public class Vala.Namespace : Symbol {
 		if (a.has_argument ("lower_case_cprefix")) {
 			set_lower_case_cprefix (a.get_string ("lower_case_cprefix"));
 		}
-		if (a.has_argument ("cheader_filename")) {
-			var val = a.get_string ("cheader_filename");
-			foreach (string filename in val.split (",")) {
-				add_cheader_filename (filename);
-			}
-		}
 		if (a.has_argument ("gir_namespace")) {
 			source_reference.file.gir_namespace = a.get_string ("gir_namespace");
 		}
diff --git a/vala/valapropertyaccessor.vala b/vala/valapropertyaccessor.vala
index dc4a8b3..119ce51 100644
--- a/vala/valapropertyaccessor.vala
+++ b/vala/valapropertyaccessor.vala
@@ -229,8 +229,4 @@ public class Vala.PropertyAccessor : Subroutine {
 			value_type = new_type;
 		}
 	}
-
-	public override List<string> get_cheader_filenames () {
-		return parent_symbol.get_cheader_filenames ();
-	}
 }
diff --git a/vala/valastruct.vala b/vala/valastruct.vala
index a492233..ecff5ce 100644
--- a/vala/valastruct.vala
+++ b/vala/valastruct.vala
@@ -421,12 +421,6 @@ public class Vala.Struct : TypeSymbol {
 		if (a.has_argument ("cprefix")) {
 			lower_case_cprefix = a.get_string ("cprefix");
 		}
-		if (a.has_argument ("cheader_filename")) {
-			var val = a.get_string ("cheader_filename");
-			foreach (string filename in val.split (",")) {
-				add_cheader_filename (filename);
-			}
-		}
 		if (a.has_argument ("has_type_id")) {
 			has_type_id = a.get_bool ("has_type_id");
 		}
diff --git a/vala/valasymbol.vala b/vala/valasymbol.vala
index 5b1ef12..39a65c8 100644
--- a/vala/valasymbol.vala
+++ b/vala/valasymbol.vala
@@ -114,8 +114,6 @@ public abstract class Vala.Symbol : CodeNode {
 
 	public Comment? comment { get; set; }
 
-	private List<string> cheader_filenames;
-
 	/**
 	 * Specifies whether this method explicitly hides a member of a base
 	 * type.
@@ -292,38 +290,6 @@ public abstract class Vala.Symbol : CodeNode {
 		return "";
 	}
 
-	static List<string> _empty_string_list;
-
-	/**
-	 * Returns a list of C header filenames users of this symbol must
-	 * include.
-	 *
-	 * @return list of C header filenames for this symbol
-	 */
-	public virtual List<string> get_cheader_filenames () {
-		if (cheader_filenames == null || cheader_filenames.size == 0) {
-			// parent_symbol can be null on incremental parsing
-			if (parent_symbol != null) {
-				/* default to header filenames of the namespace */
-				var parent_header_filenames = parent_symbol.get_cheader_filenames ();
-				if (parent_header_filenames.size > 0) {
-					return parent_header_filenames;
-				}
-			}
-
-			if (source_reference != null && !external_package) {
-				// don't add default include directives for VAPI files
-				add_cheader_filename (source_reference.file.get_cinclude_filename ());
-			} else {
-				if (_empty_string_list == null) {
-					_empty_string_list = new ArrayList<string> ();
-				}
-				return _empty_string_list;
-			}
-		}
-		return cheader_filenames;
-	}
-
 	/**
 	 * Converts a string from CamelCase to lower_case.
 	 *
@@ -532,30 +498,6 @@ public abstract class Vala.Symbol : CodeNode {
 		}
 	}
 
-	/**
-	 * Sets the C header filename of this namespace to the specified
-	 * filename.
-	 *
-	 * @param cheader_filename header filename
-	 */
-	public void set_cheader_filename (string cheader_filename) {
-		cheader_filenames = new ArrayList<string> ();
-		cheader_filenames.add (cheader_filename);
-	}
-
-	/**
-	 * Adds a filename to the list of C header filenames users of this data
-	 * type must include.
-	 *
-	 * @param filename a C header filename
-	 */
-	public void add_cheader_filename (string filename) {
-		if (cheader_filenames == null) {
-			cheader_filenames = new ArrayList<string> ();
-		}
-		cheader_filenames.add (filename);
-	}
-
 	public Symbol? get_hidden_member () {
 		Symbol sym = null;
 
diff --git a/vapigen/valagidlparser.vala b/vapigen/valagidlparser.vala
index f89441f..a25f478 100644
--- a/vapigen/valagidlparser.vala
+++ b/vapigen/valagidlparser.vala
@@ -384,7 +384,7 @@ public class Vala.GIdlParser : CodeVisitor {
 			foreach (string attr in attributes) {
 				var nv = attr.split ("=", 2);
 				if (nv[0] == "cheader_filename") {
-					ns.set_cheader_filename (eval (nv[1]));
+					ns.set_attribute_string ("CCode", "cheader_filename", eval (nv[1]));
 				} else if (nv[0] == "cprefix") {
 					var cprefixes = eval (nv[1]).split (",");
 					foreach(string name in cprefixes) {
@@ -464,7 +464,7 @@ public class Vala.GIdlParser : CodeVisitor {
 						return null;
 					}
 				} else if (nv[0] == "cheader_filename") {
-					cb.add_cheader_filename (eval (nv[1]));
+					cb.set_attribute_string ("CCode", "cheader_filename", eval (nv[1]));
 				} else if (nv[0] == "has_target") {
 					if (eval (nv[1]) == "0") {
 						check_has_target = false;
@@ -664,7 +664,7 @@ public class Vala.GIdlParser : CodeVisitor {
 					foreach (string attr in st_attributes) {
 						var nv = attr.split ("=", 2);
 						if (nv[0] == "cheader_filename") {
-							st.add_cheader_filename (eval (nv[1]));
+							st.set_attribute_string ("CCode", "cheader_filename", eval (nv[1]));
 						} else if (nv[0] == "hidden") {
 							if (eval (nv[1]) == "1") {
 								return;
@@ -752,7 +752,7 @@ public class Vala.GIdlParser : CodeVisitor {
 					foreach (string attr in cl_attributes) {
 						var nv = attr.split ("=", 2);
 						if (nv[0] == "cheader_filename") {
-							cl.add_cheader_filename (eval (nv[1]));
+							cl.set_attribute_string ("CCode", "cheader_filename", eval (nv[1]));
 						} else if (nv[0] == "base_class") {
 							base_class = eval (nv[1]);
 						} else if (nv[0] == "hidden") {
@@ -879,7 +879,7 @@ public class Vala.GIdlParser : CodeVisitor {
 					foreach (string attr in st_attributes) {
 						var nv = attr.split ("=", 2);
 						if (nv[0] == "cheader_filename") {
-							st.add_cheader_filename (eval (nv[1]));
+							st.set_attribute_string ("CCode", "cheader_filename", eval (nv[1]));
 						} else if (nv[0] == "deprecated") {
 							if (eval (nv[1]) == "1") {
 								st.deprecated = true;
@@ -933,7 +933,7 @@ public class Vala.GIdlParser : CodeVisitor {
 					foreach (string attr in cl_attributes) {
 						var nv = attr.split ("=", 2);
 						if (nv[0] == "cheader_filename") {
-							cl.add_cheader_filename (eval (nv[1]));
+							cl.set_attribute_string ("CCode", "cheader_filename", eval (nv[1]));
 						} else if (nv[0] == "hidden") {
 							if (eval (nv[1]) == "1") {
 								return;
@@ -1023,7 +1023,7 @@ public class Vala.GIdlParser : CodeVisitor {
 					foreach (string attr in st_attributes) {
 						var nv = attr.split ("=", 2);
 						if (nv[0] == "cheader_filename") {
-							st.add_cheader_filename (eval (nv[1]));
+							st.set_attribute_string ("CCode", "cheader_filename", eval (nv[1]));
 						} else if (nv[0] == "deprecated") {
 							if (eval (nv[1]) == "1") {
 								st.deprecated = true;
@@ -1094,7 +1094,7 @@ public class Vala.GIdlParser : CodeVisitor {
 					foreach (string attr in cl_attributes) {
 						var nv = attr.split ("=", 2);
 						if (nv[0] == "cheader_filename") {
-							cl.add_cheader_filename (eval (nv[1]));
+							cl.set_attribute_string ("CCode", "cheader_filename", eval (nv[1]));
 						} else if (nv[0] == "base_class") {
 							base_class = eval (nv[1]);
 						} else if (nv[0] == "is_immutable") {
@@ -1246,7 +1246,7 @@ public class Vala.GIdlParser : CodeVisitor {
 
 		bool is_errordomain = false;
 
-		var cheader_filenames = new ArrayList<string> ();
+		string cheader_filename = null;
 
 		var en_attributes = get_attributes (node.name);
 		if (en_attributes != null) {
@@ -1255,8 +1255,8 @@ public class Vala.GIdlParser : CodeVisitor {
 				if (nv[0] == "common_prefix") {
 					common_prefix = eval (nv[1]);
 				} else if (nv[0] == "cheader_filename") {
-					cheader_filenames.add (eval (nv[1]));
-					en.add_cheader_filename (eval (nv[1]));
+					cheader_filename = eval (nv[1]);
+					en.set_attribute_string ("CCode", "cheader_filename", cheader_filename);
 				} else if (nv[0] == "hidden") {
 					if (eval (nv[1]) == "1") {
 						return;
@@ -1316,8 +1316,8 @@ public class Vala.GIdlParser : CodeVisitor {
 			ed.access = SymbolAccessibility.PUBLIC;
 			ed.set_cprefix (common_prefix);
 
-			foreach (string filename in cheader_filenames) {
-				ed.add_cheader_filename (filename);
+			if (cheader_filename != null) {
+				ed.set_attribute_string ("CCode", "cheader_filename", cheader_filename);
 			}
 
 			foreach (EnumValue ev in en.get_values ()) {
@@ -1352,7 +1352,7 @@ public class Vala.GIdlParser : CodeVisitor {
 				foreach (string attr in attributes) {
 					var nv = attr.split ("=", 2);
 					if (nv[0] == "cheader_filename") {
-						cl.add_cheader_filename (eval (nv[1]));
+						cl.set_attribute_string ("CCode", "cheader_filename", eval (nv[1]));
 					} else if (nv[0] == "base_class") {
 						base_class = eval (nv[1]);
 					} else if (nv[0] == "hidden") {
@@ -1521,7 +1521,7 @@ public class Vala.GIdlParser : CodeVisitor {
 				foreach (string attr in attributes) {
 					var nv = attr.split ("=", 2);
 					if (nv[0] == "cheader_filename") {
-						iface.add_cheader_filename (eval (nv[1]));
+						iface.set_attribute_string ("CCode", "cheader_filename", eval (nv[1]));
 					} else if (nv[0] == "hidden") {
 						if (eval (nv[1]) == "1") {
 							return;
@@ -2114,7 +2114,7 @@ public class Vala.GIdlParser : CodeVisitor {
 				} else if (nv[0] == "deprecated_since") {
 					m.deprecated_since = eval (nv[1]);
 				} else if (nv[0] == "cheader_filename") {
-					m.add_cheader_filename (eval (nv[1]));
+					m.set_attribute_string ("CCode", "cheader_filename", eval (nv[1]));
 				} else if (nv[0] == "abstract") {
 					if (eval (nv[1]) == "1") {
 						m.is_abstract = true;
@@ -2557,7 +2557,7 @@ public class Vala.GIdlParser : CodeVisitor {
 			foreach (string attr in attributes) {
 				var nv = attr.split ("=", 2);
 				if (nv[0] == "cheader_filename") {
-					c.add_cheader_filename (eval (nv[1]));
+					c.set_attribute_string ("CCode", "cheader_filename", eval (nv[1]));
 				} else if (nv[0] == "deprecated") {
 					if (eval (nv[1]) == "1") {
 						c.deprecated = true;
@@ -2705,7 +2705,7 @@ public class Vala.GIdlParser : CodeVisitor {
 		}
 
 		if (cheader_filename != null) {
-			field.add_cheader_filename (cheader_filename);
+			field.set_attribute_string ("CCode", "cheader_filename", cheader_filename);
 		}
 
 		if (array_null_terminated) {



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