summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJuerg Billeter <j@bitron.ch>2007-09-27 18:25:25 +0000
committerJürg Billeter <juergbi@src.gnome.org>2007-09-27 18:25:25 +0000
commit8f9092cef206d88341775a871a13bfc8bf6f5192 (patch)
treef1fe3227035fe300f6fc60678560f089800ac433
parent4581254a297ea4668086041db1d996bf5a758672 (diff)
downloadvala-8f9092cef206d88341775a871a13bfc8bf6f5192.tar.gz
improve fix_type_name, based on patch by Andrea Del Signore
2007-09-27 Juerg Billeter <j@bitron.ch> * vapigen/valagidlparser.vala: improve fix_type_name, based on patch by Andrea Del Signore svn path=/trunk/; revision=635
-rw-r--r--ChangeLog5
-rw-r--r--vapigen/valagidlparser.vala22
2 files changed, 24 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index 370e3e4a3..f36e0b788 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
2007-09-27 Jürg Billeter <j@bitron.ch>
+ * vapigen/valagidlparser.vala: improve fix_type_name,
+ based on patch by Andrea Del Signore
+
+2007-09-27 Jürg Billeter <j@bitron.ch>
+
* gobject/Makefile.am, gobject/valaccodeelementaccessbinding.vala,
gobject/valaccodegenerator.vala: add CCodeElementAccessBinding class
and move relevant code from CCodeGenerator to
diff --git a/vapigen/valagidlparser.vala b/vapigen/valagidlparser.vala
index 547b0bde7..82ee26c19 100644
--- a/vapigen/valagidlparser.vala
+++ b/vapigen/valagidlparser.vala
@@ -148,16 +148,32 @@ public class Vala.GIdlParser : CodeVisitor {
}
private string! fix_type_name (string! type_name, Namespace! ns) {
+ var attributes = get_attributes (type_name);
+ if (attributes != null) {
+ foreach (string attr in attributes) {
+ var nv = attr.split ("=", 2);
+ if (nv[0] == "name") {
+ return eval (nv[1]);
+ }
+ }
+ }
+
if (type_name.has_prefix (ns.name)) {
return type_name.offset (ns.name.len ());
} else if (ns.name == "GLib" && type_name.has_prefix ("G")) {
return type_name.offset (1);
} else {
- foreach (string name in ns.get_cprefixes ()) {
- if (type_name.has_prefix (name)) {
- return type_name.offset (name.len ());
+ string best_match = null;
+ foreach (string cprefix in ns.get_cprefixes ()) {
+ if (type_name.has_prefix (cprefix)) {
+ if (best_match == null || cprefix.len () > best_match.len ())
+ best_match = cprefix;
}
}
+
+ if (best_match != null) {
+ return type_name.offset (best_match.len ());;
+ }
}
return type_name;