[vala] gtk+-2.0, gtk+-3.0: Fix gtk_widget_new binding
- From: Jürg Billeter <juergbi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala] gtk+-2.0, gtk+-3.0: Fix gtk_widget_new binding
- Date: Thu, 12 Aug 2010 14:36:32 +0000 (UTC)
commit e56818c7f62ad413dc5d6b59bccf288b2f94ef43
Author: Jürg Billeter <j bitron ch>
Date: Thu Aug 12 16:35:36 2010 +0200
gtk+-2.0, gtk+-3.0: Fix gtk_widget_new binding
vala/valacodewriter.vala | 24 +++++++++++++++++-------
vala/valacreationmethod.vala | 14 +++++++++-----
vapi/gtk+-2.0.vapi | 3 ++-
vapi/gtk+-3.0.vapi | 3 ++-
vapi/packages/gtk+-2.0/gtk+-2.0-custom.vala | 3 ++-
vapi/packages/gtk+-3.0/gtk+-3.0-custom.vala | 3 ++-
6 files changed, 34 insertions(+), 16 deletions(-)
---
diff --git a/vala/valacodewriter.vala b/vala/valacodewriter.vala
index e3ca81b..5b8ada0 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 10891d3..5dbd6f0 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 aafd6e5..d8e4307 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 3165e4e..0846d8c 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 fc80300..591a660 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 feabb34..89f1419 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 {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]