summaryrefslogtreecommitdiff
path: root/vapigen
diff options
context:
space:
mode:
authorRaffaele Sandrini <raffaele@sandrini.ch>2008-07-09 09:17:43 +0000
committerRaffaele Sandrini <rasa@src.gnome.org>2008-07-09 09:17:43 +0000
commit70cd66a60bd778c5b2fbd2c0dc748e5a2fe53e2f (patch)
tree39d059de654ee2dd4f5fee7576707632bc43b21e /vapigen
parent141bea444669efd2cb9e7f2b9ad4e18ad552295c (diff)
downloadvala-70cd66a60bd778c5b2fbd2c0dc748e5a2fe53e2f.tar.gz
Add support for creation methods with a different (mostly super) type than
2008-07-09 Raffaele Sandrini <raffaele@sandrini.ch> * gobject/valaccodegenerator.vala: * gobject/valaccodemethodbinding.vala: * vala/valacreationmethod.vala: * vala/valainterfacewriter.vala: * vapigen/valagidlparser.vala: Add support for creation methods with a different (mostly super) type than the type of the object it creates. Add a `type' parameter to the CCode attribute which will be used to get the casts right for such creation methods. * vapi/gio-2.0.vapi: * vapi/gtk+-2.0.vapi: Regenerated, fixes bug 540661 svn path=/trunk/; revision=1688
Diffstat (limited to 'vapigen')
-rw-r--r--vapigen/valagidlparser.vala9
1 files changed, 9 insertions, 0 deletions
diff --git a/vapigen/valagidlparser.vala b/vapigen/valagidlparser.vala
index c97d87d90..2b39443f2 100644
--- a/vapigen/valagidlparser.vala
+++ b/vapigen/valagidlparser.vala
@@ -1257,6 +1257,15 @@ public class Vala.GIdlParser : CodeVisitor {
} else if (m.name.has_prefix ("new_")) {
m.name = m.name.offset ("new_".len ());
}
+ // For classes, check whether a creation method return type equals to the
+ // type of the class created. If the types do not match (e.g. in most
+ // gtk widgets) add an attribute to the creation method indicating the used
+ // return type.
+ if (current_data_type is Class && res != null) {
+ if ("%s*".printf (current_data_type.get_cname()) != res.type.unparsed) {
+ ((CreationMethod)m).custom_return_type_cname = res.type.unparsed;
+ }
+ }
} else {
m = new Method (name, return_type, current_source_reference);
}