Commit 8f9092ce authored by Jürg Billeter's avatar Jürg Billeter Committed by Jürg Billeter

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
parent 4581254a
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> 2007-09-27 Jürg Billeter <j@bitron.ch>
* gobject/Makefile.am, gobject/valaccodeelementaccessbinding.vala, * gobject/Makefile.am, gobject/valaccodeelementaccessbinding.vala,
......
...@@ -148,16 +148,32 @@ public class Vala.GIdlParser : CodeVisitor { ...@@ -148,16 +148,32 @@ public class Vala.GIdlParser : CodeVisitor {
} }
private string! fix_type_name (string! type_name, Namespace! ns) { 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)) { if (type_name.has_prefix (ns.name)) {
return type_name.offset (ns.name.len ()); return type_name.offset (ns.name.len ());
} else if (ns.name == "GLib" && type_name.has_prefix ("G")) { } else if (ns.name == "GLib" && type_name.has_prefix ("G")) {
return type_name.offset (1); return type_name.offset (1);
} else { } else {
foreach (string name in ns.get_cprefixes ()) { string best_match = null;
if (type_name.has_prefix (name)) { foreach (string cprefix in ns.get_cprefixes ()) {
return type_name.offset (name.len ()); 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; return type_name;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment