GNOME Bugzilla – Bug 543073
Generated para type must be same as vala type
Last modified: 2008-07-17 09:40:49 UTC
Please describe the problem: Some cases GTK uses GtkWidget a bit too broad. One of these cases are: GtkMenuShell.append(GtkWidget child); Which we want to handle more strict in Vala: GtkMenuShell.append(GtkMenuItem child); If you throw anything other than GtkMenuItem or any subclass at it, it will cry, and the documentation also mentions GtkMenuItem. To come around this problem the .vapi-file now can use the following: public void append ([CCode(ctype="GtkWidget*")] Gtk.MenuItem child); Which will be interpreted the same way as when changing type for fields (see Gtk.ActionEntry.callback for example) Steps to reproduce: Call the append method on the MenuShell class. and the C-code will give warnings when passed through gcc. Actual results: The C-code will give warnings when compiled by gcc. Expected results: No warnings. Does this happen every time? Yes. Other information: Patch attached.
Created attachment 114589 [details] [review] adds support for changing C-type of parameters. The patch is based on how fields handle the same kind of functionality.
Note that this is related to bug 542953, but I won't mark dupe since they both have patches. The way you're handling the attribute looks a bit weird. Why not just something like.. if (a.has_argument ("ctype")) { ctype = a.get_string ("ctype"); } public string? ctype { get; private set; default = null } The idea is that after attribute processing has happened, you shouldn't need to look at the attribute again after that.
Actually, looking at the commit that Raffaele made for bug 540661, it makes a lot of sense to do CCode attribute handling just in the gobject code. Anyway, this implementation is a bit weird because it stores the value of one attribute into another attribute. I don't see why the second new attribute is necessary. :)
Yeah, like I said, I did it the same way as the field version of this functionality because I thought there was some idea behind it. But ok, great, and that other patch was merged so lets close this one. Maybe the field version of this bug should be changed too then.
ops.. didn't see that the resolved bug was kind of unreleated... same thing, but for return value. I could update the patch to be less retarded.
Created attachment 114644 [details] [review] change generated formal parameter type Patch updated based on comments.
*** Bug 542953 has been marked as a duplicate of this bug. ***
2008-07-17 Jürg Billeter <j@bitron.ch> * vala/valaformalparameter.vala: * vala/valainterfacewriter.vala: * gobject/valaccodeinvocationexpressionbinding.vala: Support [CCode (type = "Foo")] for parameters, based on patch by Daniel Svensson, fixes bug 543073 * vapigen/valagidlparser.vala: Add support for ctype metadata attribute for parameters * vapi/packages/gtk+-2.0/: Fix gtk_menu_shell_append binding * vapi/gtk+-2.0.vapi: regenerated Fixed in r1710.