[vala/switch-to-gir: 7/26] vapigen: Assume girparser handles SOURCE file types.



commit 93c8705f1cd21a378764890f98e9153202ec28f7
Author: Luca Bruno <lucabru src gnome org>
Date:   Tue Nov 16 09:39:11 2010 +0100

    vapigen: Assume girparser handles SOURCE file types.

 vala/valagirparser.vala  |    9 +++++++++
 vapigen/valavapigen.vala |   18 +++++++-----------
 2 files changed, 16 insertions(+), 11 deletions(-)
---
diff --git a/vala/valagirparser.vala b/vala/valagirparser.vala
index 3d257b6..a71b78d 100644
--- a/vala/valagirparser.vala
+++ b/vala/valagirparser.vala
@@ -1460,6 +1460,7 @@ public class Vala.GirParser : CodeVisitor {
 
 		var en = new Enum (element_get_name (), get_current_src ());
 		en.access = SymbolAccessibility.PUBLIC;
+		en.external = true;
 
 		string enum_cname = reader.get_attribute ("c:type");
 		if (enum_cname != null) {
@@ -1500,6 +1501,7 @@ public class Vala.GirParser : CodeVisitor {
 
 		var ed = new ErrorDomain (element_get_name (true), get_current_src ());
 		ed.access = SymbolAccessibility.PUBLIC;
+		ed.external = true;
 
 		string enum_cname = reader.get_attribute ("c:type");
 		if (enum_cname != null) {
@@ -1539,6 +1541,7 @@ public class Vala.GirParser : CodeVisitor {
 		start_element ("bitfield");
 		var en = new Enum (reader.get_attribute ("name"), get_current_src ());
 		en.access = SymbolAccessibility.PUBLIC;
+		en.external = true;
 		next ();
 		while (current_token == MarkupTokenType.START_ELEMENT) {
 			if (!push_metadata ()) {
@@ -1564,6 +1567,7 @@ public class Vala.GirParser : CodeVisitor {
 		start_element ("member");
 		var ev = new EnumValue (reader.get_attribute ("name").up ().replace ("-", "_"), null, get_current_src ());
 		ev.set_cname (reader.get_attribute ("c:identifier"));
+		ev.external = true;
 		next ();
 		end_element ("member");
 		return ev;
@@ -1580,6 +1584,7 @@ public class Vala.GirParser : CodeVisitor {
 		} else {
 			ec = new ErrorCode (name);
 		}
+		ec.external = true;
 
 		next ();
 		end_element ("member");
@@ -2105,6 +2110,7 @@ public class Vala.GirParser : CodeVisitor {
 		}
 		var field = new Field (name, type, null, get_current_src ());
 		field.access = SymbolAccessibility.PUBLIC;
+		field.external = true;
 		field.no_array_length = true;
 		if (allow_none == "1") {
 			type.nullable = true;
@@ -2126,6 +2132,7 @@ public class Vala.GirParser : CodeVisitor {
 		var type = parse_type (null, null, false, out no_array_length, out array_null_terminated);
 		var prop = new Property (name, type, null, null, get_current_src ());
 		prop.access = SymbolAccessibility.PUBLIC;
+		prop.external = true;
 		prop.no_accessor_method = true;
 		prop.no_array_length = no_array_length;
 		prop.array_null_terminated = array_null_terminated;
@@ -2150,6 +2157,7 @@ public class Vala.GirParser : CodeVisitor {
 		string cname = reader.get_attribute ("c:identifier");
 		var m = new CreationMethod (null, element_get_name (), get_current_src ());
 		m.access = SymbolAccessibility.PUBLIC;
+		m.external = true;
 		m.has_construct_function = false;
 
 		if (m.name == "new") {
@@ -2233,6 +2241,7 @@ public class Vala.GirParser : CodeVisitor {
 		}
 
 		s.access = SymbolAccessibility.PUBLIC;
+		s.external = true;
 		if (cname != null) {
 			if (s is Method) {
 				((Method) s).set_cname (cname);
diff --git a/vapigen/valavapigen.vala b/vapigen/valavapigen.vala
index cb44363..869ab0e 100644
--- a/vapigen/valavapigen.vala
+++ b/vapigen/valavapigen.vala
@@ -122,10 +122,14 @@ class Vala.VAPIGen : Object {
 		if (context.report.get_errors () > 0) {
 			return quit ();
 		}
-		
+
 		foreach (string source in sources) {
 			if (FileUtils.test (source, FileTest.EXISTS)) {
-				context.add_source_file (new SourceFile (context, SourceFileType.PACKAGE, source));
+				if (source.has_suffix (".gir")) {
+					context.add_source_file (new SourceFile (context, SourceFileType.SOURCE, source));
+				} else {
+					context.add_source_file (new SourceFile (context, SourceFileType.PACKAGE, source));
+				}
 			} else {
 				Report.error (null, "%s not found".printf (source));
 			}
@@ -164,16 +168,8 @@ class Vala.VAPIGen : Object {
 
 		// interface writer ignores external packages
 		foreach (SourceFile file in context.get_source_files ()) {
-			if (file.filename.has_suffix (".vapi")) {
-				continue;
-			}
-			if (file.filename in sources) {
+			if (!file.filename.has_suffix (".vapi") && !file.filename.has_suffix (".gir")) {
 				file.file_type = SourceFileType.SOURCE;
-			} else if (file.filename.has_suffix (".metadata")) {
-				string gir_filename = "%s.gir".printf (file.filename.ndup (file.filename.length - ".metadata".length));
-				if (gir_filename in sources) {
-					file.file_type = SourceFileType.SOURCE;
-				}
 			}
 		}
 



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