From: Jürg Billeter Date: Thu, 12 Aug 2010 14:35:36 +0000 (+0200) Subject: gtk+-2.0, gtk+-3.0: Fix gtk_widget_new binding X-Git-Tag: 0.9.6~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e56818c7f62ad413dc5d6b59bccf288b2f94ef43;p=thirdparty%2Fvala.git gtk+-2.0, gtk+-3.0: Fix gtk_widget_new binding --- diff --git a/vala/valacodewriter.vala b/vala/valacodewriter.vala index e3ca81b14..5b8ada0bb 100644 --- a/vala/valacodewriter.vala +++ b/vala/valacodewriter.vala @@ -1011,13 +1011,23 @@ public class Vala.CodeWriter : CodeVisitor { ccode_params.append_printf ("%ssentinel = \"%s\"", separator, m.sentinel); separator = ", "; } - if (m is CreationMethod && ((CreationMethod)m).custom_return_type_cname != null) { - ccode_params.append_printf ("%stype = \"%s\"", separator, ((CreationMethod)m).custom_return_type_cname); - separator = ", "; - } - if (m is CreationMethod && !m.has_construct_function) { - ccode_params.append_printf ("%shas_construct_function = false", separator); - separator = ", "; + var cm = m as CreationMethod; + if (cm != null) { + if (cm.custom_return_type_cname != null) { + ccode_params.append_printf ("%stype = \"%s\"", separator, cm.custom_return_type_cname); + separator = ", "; + } + if (!m.has_new_function) { + ccode_params.append_printf ("%shas_new_function = false", separator); + separator = ", "; + } + if (!m.has_construct_function) { + ccode_params.append_printf ("%shas_construct_function = false", separator); + separator = ", "; + } else if (m.name == ".new" && m.get_real_cname () != cm.get_default_construct_function ()) { + ccode_params.append_printf ("%sconstruct_function = \"%s\"", separator, cm.get_default_construct_function ()); + separator = ", "; + } } if (ccode_params.len > 0) { diff --git a/vala/valacreationmethod.vala b/vala/valacreationmethod.vala index 10891d3bd..5dbd6f0e5 100644 --- a/vala/valacreationmethod.vala +++ b/vala/valacreationmethod.vala @@ -115,17 +115,21 @@ public class Vala.CreationMethod : Method { } public override string get_real_cname () { + var ccode_attribute = get_attribute ("CCode"); + if (ccode_attribute != null && ccode_attribute.has_argument ("construct_function")) { + return ccode_attribute.get_string ("construct_function"); + } + + return get_default_construct_function (); + } + + public string get_default_construct_function () { var parent = parent_symbol as Class; if (parent == null || parent.is_compact) { return get_cname (); } - var ccode_attribute = get_attribute ("CCode"); - if (ccode_attribute != null && ccode_attribute.has_argument ("construct_function")) { - return ccode_attribute.get_string ("construct_function"); - } - string infix = "construct"; if (CodeContext.get ().profile == Profile.DOVA) { diff --git a/vapi/gtk+-2.0.vapi b/vapi/gtk+-2.0.vapi index aafd6e530..d8e430776 100644 --- a/vapi/gtk+-2.0.vapi +++ b/vapi/gtk+-2.0.vapi @@ -5188,7 +5188,8 @@ namespace Gtk { public uchar saved_state; public uchar state; public Gdk.Window window; - public Widget (GLib.Type type, ...); + [CCode (has_new_function = false, construct_function = "gtk_widget_new")] + public Widget (...); public bool activate (); public void add_accelerator (string accel_signal, Gtk.AccelGroup accel_group, uint accel_key, Gdk.ModifierType accel_mods, Gtk.AccelFlags accel_flags); public void add_events (int events); diff --git a/vapi/gtk+-3.0.vapi b/vapi/gtk+-3.0.vapi index 3165e4e14..0846d8c4d 100644 --- a/vapi/gtk+-3.0.vapi +++ b/vapi/gtk+-3.0.vapi @@ -4689,7 +4689,8 @@ namespace Gtk { } [CCode (cheader_filename = "gtk/gtk.h")] public class Widget : Gtk.Object, Atk.Implementor, Gtk.Buildable, Gtk.SizeRequest { - public Widget (GLib.Type type, ...); + [CCode (has_new_function = false, construct_function = "gtk_widget_new")] + public Widget (...); public bool activate (); public void add_accelerator (string accel_signal, Gtk.AccelGroup accel_group, uint accel_key, Gdk.ModifierType accel_mods, Gtk.AccelFlags accel_flags); public void add_device_events (Gdk.Device device, Gdk.EventMask events); diff --git a/vapi/packages/gtk+-2.0/gtk+-2.0-custom.vala b/vapi/packages/gtk+-2.0/gtk+-2.0-custom.vala index fc803003e..591a660fa 100644 --- a/vapi/packages/gtk+-2.0/gtk+-2.0-custom.vala +++ b/vapi/packages/gtk+-2.0/gtk+-2.0-custom.vala @@ -51,7 +51,8 @@ namespace Gtk { } public class Widget { - public extern Widget (GLib.Type type, ...); + [CCode (has_new_function = false, construct_function = "gtk_widget_new")] + public extern Widget (...); [CCode (cname = "GTK_WIDGET_FLAGS")] public extern WidgetFlags get_flags (); diff --git a/vapi/packages/gtk+-3.0/gtk+-3.0-custom.vala b/vapi/packages/gtk+-3.0/gtk+-3.0-custom.vala index feabb3491..89f141945 100644 --- a/vapi/packages/gtk+-3.0/gtk+-3.0-custom.vala +++ b/vapi/packages/gtk+-3.0/gtk+-3.0-custom.vala @@ -51,7 +51,8 @@ namespace Gtk { } public class Widget { - public extern Widget (GLib.Type type, ...); + [CCode (has_new_function = false, construct_function = "gtk_widget_new")] + public extern Widget (...); } public interface Editable {