GNOME Bugzilla – Bug 673117
Wrong definition of TargetList.add_table ()
Last modified: 2012-04-05 10:33:28 UTC
According to the docs and to the Vapi files, this function is defined as : public void add_table (TargetEntry[] targets, uint ntargets) This doesn't compile currently, Vala appends one more size parameter and it fails to compile. This patch fixes the definition as : public class TargetList { public void add_table (Gtk.TargetEntry[] targets); } Thanks for you work on the Vala compiler, great language, great project. ;) Regards.
Created attachment 210903 [details] [review] fixes Gtk+-2.0 and Gtk+-3.0 Vapi files...
Review of attachment 210903 [details] [review]: Thanks for the patch. Please note that the gtk+-2.0.vapi and gtk+-3.0.vapi are autogenerated using vapi/packages/gtk+-2.0 and vapi/packages/gtk+-3.0 metadata respectively. To regenerate both vapi, go into the vapi/ directory and type make gtk+-2.0 && make gtk+-3.0 .
Created attachment 211359 [details] [review] new patch against "gi" files Thanks for the information, Luca, this is a new patch against ".gi" files, I'm not sure if it's the correct way to do it though, that's my first attempt to fix vapi files. :)
Review of attachment 211359 [details] [review]: Sorry for not providing enough information :-( .gi files must not be manually modified, they are autogenerated too :-) The files to modify are .metadata. This is the flow: C headers -> autogenerate .gi -> vapigen + .metadata -> autogenerate .vapi In the .metadata an hidden="1" should be added relatively to that parameter.
I reverted my patched vapi files to do a test case, in a real life program, this line doesn't build : targets.add_table (dnd_targets, dnd_targets.length); I've this error : error: too many arguments to function ‘gtk_target_list_add_table’ This is the generated code : gtk_target_list_add_table (targets, DESKTOP_dnd_targets, G_N_ELEMENTS (DESKTOP_dnd_targets), (guint) G_N_ELEMENTS (DESKTOP_dnd_targets)); It takes only 3 parameters not 4. I've done this case : //-------------------------------------------------------------------- // valac --pkg gtk+-2.0 -C target_list_add_table.vala private const Gtk.TargetEntry dnd_targets[] = {}; int main (string[] args) { Gtk.init (ref args); Gtk.TargetList targets = new Gtk.TargetList (dnd_targets); targets.add_table (dnd_targets, dnd_targets.length); Gtk.main (); return 0; } //-------------------------------------------------------------------- It's strange because, this compiles and generates a binary but the generated C code is still wrong :) I still have the additional parameter : gtk_target_list_add_table (targets, dnd_targets, G_N_ELEMENTS (dnd_targets), (guint) G_N_ELEMENTS (dnd_targets)); Here is the definition in the metadata : gtk_target_list_add_table.targets is_array="1" gtk_target_list_new.targets is_array="1" gtk_target_list_new.ntargets hidden="1" Is it "gtk_target_list_add_table.ntargets hidden="1"" that is missing ? :)
Created attachment 211363 [details] [review] third take :) This one should be better :-P (About the test case, it doesn't generate a binary, only the .c file) :)
Created attachment 211364 [details] [review] gtk+-2.0, gtk+-3.0: Fix TargetList.add_table binding Based on patch by Axel FILMORE. Fixes bug 673117. Thanks for taking time to provide the patches. This is how the patch should look like in the end.
commit a5d52a8343a1387006d4ed08a4bf5f185970affc Author: Luca Bruno <lucabru@src.gnome.org> Date: Thu Apr 5 12:28:35 2012 +0200 gtk+-2.0, gtk+-3.0: Fix TargetList.add_table binding Based on patch by Axel FILMORE. Fixes bug 673117. This problem has been fixed in the development version. The fix will be available in the next major software release. Thank you for your bug report.