GapiCodegen: added support for deprecated constructors

Also added deprecation to manual constructors
This commit is contained in:
dmg 2022-07-22 22:29:01 +03:00
parent 3c56c6c992
commit f857cd7edf
12 changed files with 30 additions and 4 deletions

View file

@ -19,6 +19,7 @@ namespace Gtk {
public partial class HBox { public partial class HBox {
[Obsolete]
public HBox () : this (false, 0) {} public HBox () : this (false, 0) {}
} }

View file

@ -28,6 +28,7 @@ namespace Gtk {
delegate IntPtr d_gtk_hscale_new_with_range(double min, double max, double step); delegate IntPtr d_gtk_hscale_new_with_range(double min, double max, double step);
static d_gtk_hscale_new_with_range gtk_hscale_new_with_range = FuncLoader.LoadFunction<d_gtk_hscale_new_with_range>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gtk), "gtk_hscale_new_with_range")); static d_gtk_hscale_new_with_range gtk_hscale_new_with_range = FuncLoader.LoadFunction<d_gtk_hscale_new_with_range>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gtk), "gtk_hscale_new_with_range"));
[Obsolete]
public HScale (double min, double max, double step) : base (IntPtr.Zero) public HScale (double min, double max, double step) : base (IntPtr.Zero)
{ {
if (GetType() != typeof (HScale)) { if (GetType() != typeof (HScale)) {

View file

@ -24,7 +24,7 @@ namespace Gtk {
static d_gtk_icon_size_lookup gtk_icon_size_lookup = FuncLoader.LoadFunction<d_gtk_icon_size_lookup>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gtk), "gtk_icon_size_lookup")); static d_gtk_icon_size_lookup gtk_icon_size_lookup = FuncLoader.LoadFunction<d_gtk_icon_size_lookup>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gtk), "gtk_icon_size_lookup"));
/// <summary> Query icon dimensions </summary> /// <summary> Query icon dimensions </summary>
/// <remarks> Queries dimensions for icons of the specified size. </remarks> /// <remarks> Queries dimensions for icons of the specified size. </remarks>
public void LookupIconSize (IconSize size, out int width, out int height) public void LookupIconSize (IconSize size, out int width, out int height)
{ {
gtk_icon_size_lookup (size, out width, out height); gtk_icon_size_lookup (size, out width, out height);

View file

@ -25,6 +25,7 @@ namespace Gtk {
/// <summary> Sizes Property </summary> /// <summary> Sizes Property </summary>
/// <remarks> To be completed </remarks> /// <remarks> To be completed </remarks>
[Obsolete]
public Gtk.IconSize [] Sizes { public Gtk.IconSize [] Sizes {
get { get {

View file

@ -28,6 +28,7 @@ namespace Gtk {
delegate IntPtr d_gtk_image_menu_item_new_with_mnemonic(IntPtr label); delegate IntPtr d_gtk_image_menu_item_new_with_mnemonic(IntPtr label);
static d_gtk_image_menu_item_new_with_mnemonic gtk_image_menu_item_new_with_mnemonic = FuncLoader.LoadFunction<d_gtk_image_menu_item_new_with_mnemonic>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gtk), "gtk_image_menu_item_new_with_mnemonic")); static d_gtk_image_menu_item_new_with_mnemonic gtk_image_menu_item_new_with_mnemonic = FuncLoader.LoadFunction<d_gtk_image_menu_item_new_with_mnemonic>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gtk), "gtk_image_menu_item_new_with_mnemonic"));
[Obsolete]
public ImageMenuItem (string label) : base (IntPtr.Zero) public ImageMenuItem (string label) : base (IntPtr.Zero)
{ {
if (GetType() != typeof (ImageMenuItem)) { if (GetType() != typeof (ImageMenuItem)) {

View file

@ -32,6 +32,7 @@ namespace Gtk
delegate void d_gtk_radio_action_set_group(IntPtr raw, IntPtr list); delegate void d_gtk_radio_action_set_group(IntPtr raw, IntPtr list);
static d_gtk_radio_action_set_group gtk_radio_action_set_group = FuncLoader.LoadFunction<d_gtk_radio_action_set_group>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gtk), "gtk_radio_action_set_group")); static d_gtk_radio_action_set_group gtk_radio_action_set_group = FuncLoader.LoadFunction<d_gtk_radio_action_set_group>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gtk), "gtk_radio_action_set_group"));
[Obsolete]
[GLib.Property ("group")] [GLib.Property ("group")]
public RadioAction[] Group { public RadioAction[] Group {
get { get {

View file

@ -49,6 +49,7 @@ namespace Gtk {
delegate IntPtr d_gtk_radio_tool_button_new_from_stock(IntPtr group, IntPtr stock_id); delegate IntPtr d_gtk_radio_tool_button_new_from_stock(IntPtr group, IntPtr stock_id);
static d_gtk_radio_tool_button_new_from_stock gtk_radio_tool_button_new_from_stock = FuncLoader.LoadFunction<d_gtk_radio_tool_button_new_from_stock>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gtk), "gtk_radio_tool_button_new_from_stock")); static d_gtk_radio_tool_button_new_from_stock gtk_radio_tool_button_new_from_stock = FuncLoader.LoadFunction<d_gtk_radio_tool_button_new_from_stock>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gtk), "gtk_radio_tool_button_new_from_stock"));
[Obsolete]
public RadioToolButton (RadioToolButton[] group, string stock_id) : base (IntPtr.Zero) public RadioToolButton (RadioToolButton[] group, string stock_id) : base (IntPtr.Zero)
{ {
if (GetType () != typeof (RadioToolButton)) { if (GetType () != typeof (RadioToolButton)) {

View file

@ -87,6 +87,7 @@ namespace Gtk {
delegate bool d_gtk_status_icon_get_geometry(IntPtr raw, out IntPtr screen, IntPtr area, out int orientation); delegate bool d_gtk_status_icon_get_geometry(IntPtr raw, out IntPtr screen, IntPtr area, out int orientation);
static d_gtk_status_icon_get_geometry gtk_status_icon_get_geometry = FuncLoader.LoadFunction<d_gtk_status_icon_get_geometry>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gtk), "gtk_status_icon_get_geometry")); static d_gtk_status_icon_get_geometry gtk_status_icon_get_geometry = FuncLoader.LoadFunction<d_gtk_status_icon_get_geometry>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gtk), "gtk_status_icon_get_geometry"));
[Obsolete]
public bool GetGeometry(out Gdk.Screen screen, out Gdk.Rectangle area, out Gtk.Orientation orientation) public bool GetGeometry(out Gdk.Screen screen, out Gdk.Rectangle area, out Gtk.Orientation orientation)
{ {
IntPtr native_screen; IntPtr native_screen;

View file

@ -26,6 +26,7 @@ namespace Gtk {
public partial class UIManager { public partial class UIManager {
[Obsolete]
[MethodImpl(MethodImplOptions.NoInlining)] [MethodImpl(MethodImplOptions.NoInlining)]
public uint AddUiFromResource (string resource) public uint AddUiFromResource (string resource)
{ {
@ -42,6 +43,7 @@ namespace Gtk {
delegate uint d_gtk_ui_manager_new_merge_id(IntPtr raw); delegate uint d_gtk_ui_manager_new_merge_id(IntPtr raw);
static d_gtk_ui_manager_new_merge_id gtk_ui_manager_new_merge_id = FuncLoader.LoadFunction<d_gtk_ui_manager_new_merge_id>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gtk), "gtk_ui_manager_new_merge_id")); static d_gtk_ui_manager_new_merge_id gtk_ui_manager_new_merge_id = FuncLoader.LoadFunction<d_gtk_ui_manager_new_merge_id>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gtk), "gtk_ui_manager_new_merge_id"));
[Obsolete]
public uint NewMergeId () public uint NewMergeId ()
{ {
return gtk_ui_manager_new_merge_id (Handle); return gtk_ui_manager_new_merge_id (Handle);
@ -50,10 +52,11 @@ namespace Gtk {
delegate IntPtr d_gtk_ui_manager_get_toplevels(IntPtr raw, int types); delegate IntPtr d_gtk_ui_manager_get_toplevels(IntPtr raw, int types);
static d_gtk_ui_manager_get_toplevels gtk_ui_manager_get_toplevels = FuncLoader.LoadFunction<d_gtk_ui_manager_get_toplevels>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gtk), "gtk_ui_manager_get_toplevels")); static d_gtk_ui_manager_get_toplevels gtk_ui_manager_get_toplevels = FuncLoader.LoadFunction<d_gtk_ui_manager_get_toplevels>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gtk), "gtk_ui_manager_get_toplevels"));
[Obsolete]
public Widget[] GetToplevels (Gtk.UIManagerItemType types) { public Widget[] GetToplevels (Gtk.UIManagerItemType types) {
IntPtr raw_ret = gtk_ui_manager_get_toplevels (Handle, (int) types); IntPtr raw_ret = gtk_ui_manager_get_toplevels (Handle, (int) types);
GLib.SList list = new GLib.SList (raw_ret); GLib.SList list = new GLib.SList (raw_ret);
Widget[] result = new Widget [list.Count]; Widget[] result = new Widget [list.Count];
for (int i = 0; i < list.Count; i++) for (int i = 0; i < list.Count; i++)
result [i] = list [i] as Widget; result [i] = list [i] as Widget;
@ -63,11 +66,12 @@ namespace Gtk {
delegate IntPtr d_gtk_ui_manager_get_action_groups(IntPtr raw); delegate IntPtr d_gtk_ui_manager_get_action_groups(IntPtr raw);
static d_gtk_ui_manager_get_action_groups gtk_ui_manager_get_action_groups = FuncLoader.LoadFunction<d_gtk_ui_manager_get_action_groups>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gtk), "gtk_ui_manager_get_action_groups")); static d_gtk_ui_manager_get_action_groups gtk_ui_manager_get_action_groups = FuncLoader.LoadFunction<d_gtk_ui_manager_get_action_groups>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gtk), "gtk_ui_manager_get_action_groups"));
[Obsolete]
public ActionGroup[] ActionGroups { public ActionGroup[] ActionGroups {
get { get {
IntPtr raw_ret = gtk_ui_manager_get_action_groups (Handle); IntPtr raw_ret = gtk_ui_manager_get_action_groups (Handle);
GLib.List list = new GLib.List(raw_ret); GLib.List list = new GLib.List(raw_ret);
ActionGroup[] result = new ActionGroup [list.Count]; ActionGroup[] result = new ActionGroup [list.Count];
for (int i = 0; i < list.Count; i++) for (int i = 0; i < list.Count; i++)
result [i] = list [i] as ActionGroup; result [i] = list [i] as ActionGroup;

View file

@ -19,6 +19,7 @@ namespace Gtk {
public partial class VBox { public partial class VBox {
[Obsolete]
public VBox () : this (false, 0) {} public VBox () : this (false, 0) {}
} }

View file

@ -28,6 +28,7 @@ namespace Gtk {
delegate IntPtr d_gtk_vscale_new_with_range(double min, double max, double step); delegate IntPtr d_gtk_vscale_new_with_range(double min, double max, double step);
static d_gtk_vscale_new_with_range gtk_vscale_new_with_range = FuncLoader.LoadFunction<d_gtk_vscale_new_with_range>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gtk), "gtk_vscale_new_with_range")); static d_gtk_vscale_new_with_range gtk_vscale_new_with_range = FuncLoader.LoadFunction<d_gtk_vscale_new_with_range>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gtk), "gtk_vscale_new_with_range"));
[Obsolete]
public VScale (double min, double max, double step) : base (IntPtr.Zero) public VScale (double min, double max, double step) : base (IntPtr.Zero)
{ {
if (GetType() != typeof (VScale)) { if (GetType() != typeof (VScale)) {

View file

@ -30,12 +30,15 @@ namespace GtkSharp.Generation {
public class Ctor : MethodBase { public class Ctor : MethodBase {
private bool preferred; private bool preferred;
private bool deprecated;
private string name; private string name;
private bool needs_chaining = false; private bool needs_chaining;
public Ctor (XmlElement elem, ClassBase implementor) : base (elem, implementor) public Ctor (XmlElement elem, ClassBase implementor) : base (elem, implementor)
{ {
preferred = elem.GetAttributeAsBoolean ("preferred"); preferred = elem.GetAttributeAsBoolean ("preferred");
deprecated = elem.GetAttributeAsBoolean("deprecated");
if (implementor is ObjectGen) if (implementor is ObjectGen)
needs_chaining = true; needs_chaining = true;
@ -47,6 +50,12 @@ namespace GtkSharp.Generation {
set { preferred = value; } set { preferred = value; }
} }
public bool IsDeprecated {
get {
return deprecated;
}
}
public string StaticName { public string StaticName {
get { get {
if (!IsStatic) if (!IsStatic)
@ -101,6 +110,10 @@ namespace GtkSharp.Generation {
if (IsStatic) if (IsStatic)
GenerateStatic (gen_info); GenerateStatic (gen_info);
else { else {
if (IsDeprecated)
sw.WriteLine("\t\t[Obsolete]");
sw.WriteLine("\t\t{0} {1}{2} ({3}) {4}", Protection, Safety, name, Signature.ToString(), needs_chaining ? ": base (IntPtr.Zero)" : ""); sw.WriteLine("\t\t{0} {1}{2} ({3}) {4}", Protection, Safety, name, Signature.ToString(), needs_chaining ? ": base (IntPtr.Zero)" : "");
sw.WriteLine("\t\t{"); sw.WriteLine("\t\t{");