diff options
author | Juerg Billeter <j@bitron.ch> | 2007-09-27 18:25:25 +0000 |
---|---|---|
committer | Jürg Billeter <juergbi@src.gnome.org> | 2007-09-27 18:25:25 +0000 |
commit | 8f9092cef206d88341775a871a13bfc8bf6f5192 (patch) | |
tree | f1fe3227035fe300f6fc60678560f089800ac433 | |
parent | 4581254a297ea4668086041db1d996bf5a758672 (diff) | |
download | vala-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-- | ChangeLog | 5 | ||||
-rw-r--r-- | vapigen/valagidlparser.vala | 22 |
2 files changed, 24 insertions, 3 deletions
@@ -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; |