[vala/switch-to-gir: 4/36] girparser: Stop parsing if the context already has the provided package
- From: Luca Bruno <lucabru src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/switch-to-gir: 4/36] girparser: Stop parsing if the context already has the provided package
- Date: Sat, 6 Nov 2010 11:48:43 +0000 (UTC)
commit a53ac761c958d93b0fa2b6fa2ca5667253826fe8
Author: Luca Bruno <lethalman88 gmail com>
Date: Sat Oct 16 22:36:36 2010 -0700
girparser: Stop parsing if the context already has the provided package
compiler/valacompiler.vala | 6 ------
vala/valagirparser.vala | 32 ++++++++++----------------------
2 files changed, 10 insertions(+), 28 deletions(-)
---
diff --git a/compiler/valacompiler.vala b/compiler/valacompiler.vala
index 772ed94..ae88a6b 100644
--- a/compiler/valacompiler.vala
+++ b/compiler/valacompiler.vala
@@ -328,12 +328,6 @@ class Vala.Compiler {
var gir_parser = new GirParser ();
gir_parser.parse (context);
- if (gir_parser.get_package_names != null) {
- foreach (var pkg in gir_parser.get_package_names ()) {
- context.add_package (pkg);
- }
- }
-
if (context.report.get_errors () > 0 || (fatal_warnings && context.report.get_warnings () > 0)) {
return quit ();
}
diff --git a/vala/valagirparser.vala b/vala/valagirparser.vala
index a77b047..a09611e 100644
--- a/vala/valagirparser.vala
+++ b/vala/valagirparser.vala
@@ -37,7 +37,6 @@ public class Vala.GirParser : CodeVisitor {
MarkupTokenType current_token;
string[] cheader_filenames;
- string[] package_names;
HashMap<string,string> attributes_map = new HashMap<string,string> (str_hash, str_equal);
@@ -149,7 +148,13 @@ public class Vala.GirParser : CodeVisitor {
} else if (reader.name == "include") {
parse_include ();
} else if (reader.name == "package") {
- parse_package ();
+ var pkg = parse_package ();
+ if (context.has_package (pkg)) {
+ // package already provided elsewhere, stop parsing this GIR
+ return;
+ } else {
+ context.add_package (pkg);
+ }
} else if (reader.name == "c:include") {
parse_c_include ();
} else {
@@ -167,11 +172,12 @@ public class Vala.GirParser : CodeVisitor {
end_element ("include");
}
- void parse_package () {
+ string parse_package () {
start_element ("package");
- add_package_name (reader.get_attribute ("name"));
+ var pkg = reader.get_attribute ("name");
next ();
end_element ("package");
+ return pkg;
}
void parse_c_include () {
@@ -1428,23 +1434,5 @@ public class Vala.GirParser : CodeVisitor {
Report.error (null, "Metadata file `%s' not found".printf (metadata_filename));
}
}
-
- void add_package_name (string name) {
- if (package_names == null) {
- package_names = new string[0];
- }
-
- foreach (var existing in package_names) {
- if (name == existing) {
- return;
- }
- }
-
- package_names += name;
- }
-
- public string[]? get_package_names () {
- return package_names;
- }
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]