[vala/switch-to-gir: 13/34] girparser: Add common parse_symbol_from_string method
- From: Luca Bruno <lucabru src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/switch-to-gir: 13/34] girparser: Add common parse_symbol_from_string method
- Date: Sun, 29 Aug 2010 16:20:49 +0000 (UTC)
commit 60a8c416601fe0cc0dfbbda08227c414d6bac77d
Author: Luca Bruno <lucabru src gnome org>
Date: Sun Aug 29 13:08:54 2010 +0200
girparser: Add common parse_symbol_from_string method
vala/valagirparser.vala | 22 +++++++++++++---------
1 files changed, 13 insertions(+), 9 deletions(-)
---
diff --git a/vala/valagirparser.vala b/vala/valagirparser.vala
index 40fb3cf..cea46da 100644
--- a/vala/valagirparser.vala
+++ b/vala/valagirparser.vala
@@ -565,6 +565,17 @@ public class Vala.GirParser : CodeVisitor {
return new SourceReference (this.current_source_file, begin.line, begin.column, end.line, end.column);
}
+ UnresolvedSymbol? parse_symbol_from_string (string symbol_string, SourceReference? source_reference = null) {
+ UnresolvedSymbol? sym = null;
+ foreach (unowned string s in symbol_string.split (".")) {
+ sym = new UnresolvedSymbol (sym, s, source_reference);
+ }
+ if (sym == null) {
+ Report.error (source_reference, "a symbol must be specified");
+ }
+ return sym;
+ }
+
void parse_repository () {
start_element ("repository");
next ();
@@ -1047,15 +1058,8 @@ public class Vala.GirParser : CodeVisitor {
} else if (type_name == "Atk.ImplementorIface") {
type_name = "Atk.Implementor";
}
- string[] type_components = type_name.split (".");
- if (type_components[1] != null) {
- // namespaced name
- string namespace_name = transform_namespace_name (type_components[0]);
- string transformed_type_name = type_components[1];
- type = new UnresolvedType.from_symbol (new UnresolvedSymbol (new UnresolvedSymbol (null, namespace_name), transformed_type_name));
- } else {
- type = new UnresolvedType.from_symbol (new UnresolvedSymbol (null, type_name));
- }
+ var sym = parse_symbol_from_string (type_name, get_current_src ());
+ type = new UnresolvedType.from_symbol (sym, get_current_src ());
}
return type;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]