From 9fcf82d28e54c61786c47226c7ca4ed6cd0f4dfc Mon Sep 17 00:00:00 2001 From: Mike Kestner Date: Sat, 12 Jan 2002 02:08:16 +0000 Subject: [PATCH] 2002-01-11 Mike Kestner * generator/ObjectGen.cs : Add property generation. * generator/SymbolTable.cs : More fixage to simple_types. Add GetMarshalType and IsObject methods. * glib/Object.cs : Rename Events prop to EventList to avoid name collision. Add float, double, uint, and IntPtr GetProp and SetProp methods. * parser/TODO : Add a couple prop related bugs to come back for. * parser/gapi2xml.pl (addPropElems): Restructure. It was thoroughly broken. It's better now. svn path=/trunk/gtk-sharp/; revision=1960 --- ChangeLog | 14 +- generator/ObjectGen.cs | 61 ++++- generator/SymbolTable.cs | 30 ++- generator/api.xml | 2 +- glib/Object.cs | 157 ++++++++++++- gtk/Button.cs | 464 --------------------------------------- gtk/Container.cs | 100 --------- gtk/Label.cs | 240 -------------------- gtk/Object.cs | 16 -- parser/TODO | 2 + parser/gapi2xml.pl | 86 ++++---- 11 files changed, 299 insertions(+), 873 deletions(-) delete mode 100644 gtk/Button.cs delete mode 100644 gtk/Container.cs delete mode 100644 gtk/Label.cs delete mode 100755 gtk/Object.cs diff --git a/ChangeLog b/ChangeLog index a15c2cc77..472517c14 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,16 @@ -2002-01-08 Mike Kestner +2002-01-11 Mike Kestner + + * generator/ObjectGen.cs : Add property generation. + * generator/SymbolTable.cs : More fixage to simple_types. Add + GetMarshalType and IsObject methods. + * glib/Object.cs : Rename Events prop to EventList to avoid name + collision. Add float, double, uint, and IntPtr GetProp and SetProp + methods. + * parser/TODO : Add a couple prop related bugs to come back for. + * parser/gapi2xml.pl (addPropElems): Restructure. It was thoroughly + broken. It's better now. + +2002-01-10 Mike Kestner * generator/StructBase.cs (GenField): Return a bool success indicator. * generator/ObjectGen.cs : Check the return of GenField. diff --git a/generator/ObjectGen.cs b/generator/ObjectGen.cs index 3f6418899..e7f4a13e5 100644 --- a/generator/ObjectGen.cs +++ b/generator/ObjectGen.cs @@ -101,6 +101,9 @@ namespace GtkSharp.Generation { break; case "property": + if (!GenProperty(member, table, sw)) { + Console.WriteLine("in object " + CName); + } break; case "signal": @@ -119,7 +122,63 @@ namespace GtkSharp.Generation { sw.Flush(); sw.Close(); - } + } + + public bool GenProperty (XmlElement prop, SymbolTable table, StreamWriter sw) + { + String c_type = prop.GetAttribute("type"); + + char[] ast = {'*'}; + c_type = c_type.TrimEnd(ast); + String cs_type = table.GetCSType(c_type); + String m_type; + + if (table.IsObject(c_type)) { + m_type = "GLib.Object"; + } else { + m_type = table.GetMarshalType(c_type); + } + + if ((cs_type == "") || (m_type == "")) { + Console.Write("Property has unknown Type {0} ", c_type); + return false; + } + + if (prop.HasAttribute("construct-only") && !prop.HasAttribute("readable")) { + return true; + } + + XmlElement parent = (XmlElement) prop.ParentNode; + String name = prop.GetAttribute("name"); + if (name == parent.GetAttribute("name")) { + name += "Prop"; + } + + sw.WriteLine("\t\tpublic " + cs_type + " " + name + " {"); + if (prop.HasAttribute("readable")) { + sw.WriteLine("\t\t\tget {"); + sw.WriteLine("\t\t\t\t" + m_type + " val;"); + sw.WriteLine("\t\t\t\tGetProperty(\"" + prop.GetAttribute("cname") + "\", out val);"); + sw.Write("\t\t\t\treturn "); + if (cs_type != m_type) { + sw.Write("(" + cs_type + ") "); + } + sw.WriteLine("val;"); + sw.WriteLine("\t\t\t}"); + } + + if (prop.HasAttribute("writeable") && !prop.HasAttribute("construct-only")) { + sw.WriteLine("\t\t\tset {"); + sw.WriteLine("\t\t\t\tSetProperty(\"" + prop.GetAttribute("cname") + "\", (" + m_type + ") value);"); + sw.WriteLine("\t\t\t}"); + } + + sw.WriteLine("\t\t}"); + sw.WriteLine(); + + return true; + } + } } diff --git a/generator/SymbolTable.cs b/generator/SymbolTable.cs index dc1050e8c..92a2cdea6 100644 --- a/generator/SymbolTable.cs +++ b/generator/SymbolTable.cs @@ -44,6 +44,7 @@ namespace GtkSharp.Generation { simple_types.Add ("int", "int"); simple_types.Add ("char", "char"); simple_types.Add ("double", "double"); + simple_types.Add ("float", "float"); simple_types.Add ("gunichar", "String"); simple_types.Add ("uint1", "bool"); simple_types.Add ("GPtrArray", "IntPtr[]"); @@ -75,15 +76,15 @@ namespace GtkSharp.Generation { } } - public IDictionaryEnumerator GetEnumerator () + public IDictionaryEnumerator GetEnumerator() { return complex_types.GetEnumerator(); } - public String GetCSType (String c_type) + public String GetCSType(String c_type) { if (simple_types.ContainsKey(c_type)) { - return (String) simple_types [c_type]; + return (String) simple_types[c_type]; } else if (complex_types.ContainsKey(c_type)) { IGeneratable gen = (IGeneratable) complex_types[c_type]; return gen.QualifiedName; @@ -92,6 +93,29 @@ namespace GtkSharp.Generation { } } + public String GetMarshalType(String c_type) + { + if (simple_types.ContainsKey(c_type)) { + return (String) simple_types[c_type]; + } else if (complex_types.ContainsKey(c_type)) { + IGeneratable gen = (IGeneratable) complex_types[c_type]; + return gen.MarshalType; + } else { + return ""; + } + } + + public bool IsObject(String c_type) + { + if (complex_types.ContainsKey(c_type)) { + IGeneratable gen = (IGeneratable) complex_types[c_type]; + if (gen is ObjectGen) { + return true; + } + } + return false; + } + } } diff --git a/generator/api.xml b/generator/api.xml index d10bb9bb5..4e8a686cc 100644 --- a/generator/api.xml +++ b/generator/api.xml @@ -1,2 +1,2 @@ - + diff --git a/glib/Object.cs b/glib/Object.cs index 9786f9a48..b52b0b59c 100644 --- a/glib/Object.cs +++ b/glib/Object.cs @@ -90,7 +90,7 @@ namespace GLib { } /// - /// Events Property + /// EventList Property /// /// /// @@ -98,7 +98,7 @@ namespace GLib { /// object indexed by the Gtk+ signal name. /// - protected EventHandlerList Events { + protected EventHandlerList EventList { get { if (_events == null) _events = new EventHandlerList (); @@ -209,6 +209,46 @@ namespace GLib { out val, new IntPtr (0)); } + /// + /// GetProperty Method + /// + /// + /// + /// Accesses a double Property. + /// + + [DllImport("gobject-1.3.dll", CharSet=CharSet.Ansi, + CallingConvention=CallingConvention.Cdecl)] + static extern void g_object_get (IntPtr obj, IntPtr name, + out double val, IntPtr term); + + public void GetProperty (String name, out double val) + { + g_object_get (RawObject, + Marshal.StringToHGlobalAnsi (name), + out val, new IntPtr (0)); + } + + /// + /// GetProperty Method + /// + /// + /// + /// Accesses a float Property. + /// + + [DllImport("gobject-1.3.dll", CharSet=CharSet.Ansi, + CallingConvention=CallingConvention.Cdecl)] + static extern void g_object_get (IntPtr obj, IntPtr name, + out float val, IntPtr term); + + public void GetProperty (String name, out float val) + { + g_object_get (RawObject, + Marshal.StringToHGlobalAnsi (name), + out val, new IntPtr (0)); + } + /// /// GetProperty Method /// @@ -229,6 +269,26 @@ namespace GLib { out val, new IntPtr (0)); } + /// + /// GetProperty Method + /// + /// + /// + /// Accesses an unsigned integer Property. + /// + + [DllImport("gobject-1.3.dll", CharSet=CharSet.Ansi, + CallingConvention=CallingConvention.Cdecl)] + static extern void g_object_get (IntPtr obj, IntPtr name, + out uint val, IntPtr term); + + public void GetProperty (String name, out uint val) + { + g_object_get (RawObject, + Marshal.StringToHGlobalAnsi (name), + out val, new IntPtr (0)); + } + /// /// GetProperty Method /// @@ -246,6 +306,24 @@ namespace GLib { val = GLib.Object.GetObject (obj); } + /// + /// GetProperty Method + /// + /// + /// + /// Accesses an IntPtr Property. + /// + + public void GetProperty (String name, out IntPtr val) + { + g_object_get (RawObject, + Marshal.StringToHGlobalAnsi (name), + out val, new IntPtr (0)); + } + + /// + /// SetProperty Method + /// /// /// SetProperty Method /// @@ -287,6 +365,26 @@ namespace GLib { val, new IntPtr (0)); } + /// + /// SetProperty Method + /// + /// + /// + /// Changes the value of an unsigned integer Property. + /// + + [DllImport("gobject-1.3.dll", CharSet=CharSet.Ansi, + CallingConvention=CallingConvention.Cdecl)] + static extern void g_object_set (IntPtr obj, IntPtr name, + uint val, IntPtr term); + + public void SetProperty (String name, uint val) + { + g_object_set (RawObject, + Marshal.StringToHGlobalAnsi (name), + val, new IntPtr (0)); + } + /// /// SetProperty Method /// @@ -307,6 +405,61 @@ namespace GLib { val, new IntPtr (0)); } + /// + /// SetProperty Method + /// + /// + /// + /// Changes the value of a double Property. + /// + + [DllImport("gobject-1.3.dll", CharSet=CharSet.Ansi, + CallingConvention=CallingConvention.Cdecl)] + static extern void g_object_set (IntPtr obj, IntPtr name, + double val, IntPtr term); + + public void SetProperty (String name, double val) + { + g_object_set (RawObject, + Marshal.StringToHGlobalAnsi (name), + val, new IntPtr (0)); + } + + /// + /// SetProperty Method + /// + /// + /// + /// Changes the value of a float Property. + /// + + [DllImport("gobject-1.3.dll", CharSet=CharSet.Ansi, + CallingConvention=CallingConvention.Cdecl)] + static extern void g_object_set (IntPtr obj, IntPtr name, + float val, IntPtr term); + + public void SetProperty (String name, float val) + { + g_object_set (RawObject, + Marshal.StringToHGlobalAnsi (name), + val, new IntPtr (0)); + } + + /// + /// SetProperty Method + /// + /// + /// + /// Changes the value of an IntPtr Property. + /// + + public void SetProperty (String name, IntPtr val) + { + g_object_set (RawObject, + Marshal.StringToHGlobalAnsi (name), + val, new IntPtr (0)); + } + /// /// SetProperty Method /// diff --git a/gtk/Button.cs b/gtk/Button.cs deleted file mode 100644 index 34d1f477e..000000000 --- a/gtk/Button.cs +++ /dev/null @@ -1,464 +0,0 @@ -// GTK.Button.cs - GTK Button class implementation -// -// Authors: Bob Smith -// Mike Kestner -// -// (c) 2001 Bob Smith and Mike Kestner - -namespace Gtk { - - using System; - using System.Collections; - using System.Runtime.InteropServices; - using GLib; - - /// - /// Button Class - /// - /// - /// - /// A Button user interface element. - /// - - public class Button : Widget { - - private Hashtable Signals = new Hashtable (); - - /// - /// Button Constructor - /// - /// - /// - /// Constructs a Button with no label. - /// - - [DllImport("gtk-1.3.dll", CharSet=CharSet.Ansi, - CallingConvention=CallingConvention.Cdecl)] - static extern IntPtr gtk_button_new (); - - public Button () - { - RawObject = gtk_button_new (); - } - - /// - /// Button Object Constructor - /// - /// - /// - /// Constructs a Button Wrapper from a raw object. This - /// constructor is primarily used internally by gtk-sharp, - /// but could conceivably be called by an application if - /// the need to wrap a raw button object presents itself. - /// - /// - /// - /// Raw object reference from the native library. - /// - - public Button (IntPtr obj) - { - RawObject = obj; - } - - /// - /// Button Constructor - /// - /// - /// - /// Constructs a new Button with the specified label. - /// Note, that underlines in the label provided will - /// be converted into mnemonics and the label will be - /// interpreted as a stock system identifier if possible. - /// If this behavior is not desired, more control can be - /// obtained with an overloaded constructor. - /// - /// - /// - /// Text label or stock system id to display on the button. - /// - - [DllImport("gtk-1.3.dll", CharSet=CharSet.Ansi, - CallingConvention=CallingConvention.Cdecl)] - static extern IntPtr gtk_button_new_from_stock (IntPtr str); - - public Button (String label) - { - RawObject = gtk_button_new_from_stock ( - Marshal.StringToHGlobalAnsi (label)); - } - - /// - /// Button Constructor - /// - /// - /// - /// Constructs a new Button with the specified label. - /// Underlines in the label can be converted to mnemonics - /// based on the specified flag. The label can identify - /// a stock button if desired as well. - /// - /// - /// - /// Text label to display on the button face. - /// - /// - /// - /// Indicates if the stock system should be used. If the - /// label does not represent a known stock button, it will - /// instead be used verbatim with mnemonic if an underline - /// is included. - /// - /// - /// - /// Convert underscore to a mnemonic which can be used - /// to activate the button with the keyboard. - /// - - [DllImport("gtk-1.3.dll", CharSet=CharSet.Ansi, - CallingConvention=CallingConvention.Cdecl)] - static extern IntPtr gtk_button_new_with_mnemonic (IntPtr str); - - [DllImport("gtk-1.3.dll", CharSet=CharSet.Ansi, - CallingConvention=CallingConvention.Cdecl)] - static extern IntPtr gtk_button_new_with_label (IntPtr str); - - public Button (String label, bool stock, bool mnemonic) - { - if (stock) - RawObject = gtk_button_new_from_stock ( - Marshal.StringToHGlobalAnsi (label)); - else if (mnemonic) - RawObject = gtk_button_new_with_mnemonic ( - Marshal.StringToHGlobalAnsi (label)); - else - RawObject = gtk_button_new_with_label ( - Marshal.StringToHGlobalAnsi (label)); - } - - /// - /// Label Property - /// - /// - /// - /// Text label to display on the button face. - /// - - public String Label { - get { - String val; - GetProperty ("label", out val); - return val; - } - set { - SetProperty ("label", value); - } - } - - /// - /// Relief Property - /// - /// - /// - /// Relief style used to draw the button. - /// - - public ReliefStyle Relief { - get { - int val; - GetProperty ("relief", out val); - return (ReliefStyle) val; - } - set { - SetProperty ("relief", (int) value); - } - } - - /// - /// UseStock Property - /// - /// - /// - /// Indicates if stock button images should be used. - /// - - public bool UseStock { - get { - bool val; - GetProperty ("use-stock", out val); - return val; - } - set { - SetProperty ("use-stock", value); - } - } - - /// - /// UseUnderline Property - /// - /// - /// - /// Indicates if underlines in the label text should be - /// treated as a mnemonic. - /// - - public bool UseUnderline { - get { - bool val; - GetProperty ("use-underline", out val); - return val; - } - set { - SetProperty ("use-underline", value); - } - } - - /// - /// Activated Event - /// - /// - /// - /// Signal indicating that the button has been activated. - /// - - private static readonly string ActName = "activate"; - - public event EventHandler Activated - { - add { - if (Events [ActName] == null) - Signals [ActName] = new SimpleSignal ( - this, RawObject, - ActName, value); - - Events.AddHandler (ActName, value); - } - remove { - Events.RemoveHandler (ActName, value); - if (Events [ActName] == null) - Signals.Remove (ActName); - } - } - - /// - /// Clicked Event - /// - /// - /// - /// Signal indicating that the button has been clicked. - /// - - private static readonly string ClkName = "clicked"; - - public event EventHandler Clicked - { - add { - if (Events [ClkName] == null) - Signals [ClkName] = new SimpleSignal ( - this, RawObject, - ClkName, value); - - Events.AddHandler (ClkName, value); - } - remove { - Events.RemoveHandler (ClkName, value); - if (Events [ClkName] == null) - Signals.Remove (ClkName); - } - } - - /// - /// Entered Event - /// - /// - /// - /// Signal indicating that the focus has entered the button. - /// - - private static readonly string EnterName = "enter"; - - public event EventHandler Entered - { - add { - if (Events [EnterName] == null) - Signals [EnterName] = new SimpleSignal ( - this, RawObject, - EnterName, value); - - Events.AddHandler (EnterName, value); - } - remove { - Events.RemoveHandler (EnterName, value); - if (Events [EnterName] == null) - Signals.Remove (EnterName); - } - } - - /// - /// Left Event - /// - /// - /// - /// Signal indicating that the focus has left the button. - /// - - private static readonly string LeaveName = "leave"; - - public event EventHandler Left - { - add { - if (Events [LeaveName] == null) - Signals [LeaveName] = new SimpleSignal ( - this, RawObject, - LeaveName, value); - - Events.AddHandler (LeaveName, value); - } - remove { - Events.RemoveHandler (LeaveName, value); - if (Events [LeaveName] == null) - Signals.Remove (LeaveName); - } - } - - /// - /// Pressed Event - /// - /// - /// - /// Signal indicating that the button has been pressed. - /// - - private static readonly string PressName = "pressed"; - - public event EventHandler Pressed - { - add { - if (Events [PressName] == null) - Signals [PressName] = new SimpleSignal ( - this, RawObject, - PressName, value); - - Events.AddHandler (PressName, value); - } - remove { - Events.RemoveHandler (PressName, value); - if (Events [PressName] == null) - Signals.Remove (PressName); - } - } - - /// - /// Released Event - /// - /// - /// - /// Signal indicating that the button has been released. - /// - - private static readonly string RelName = "released"; - - public event EventHandler Released - { - add { - if (Events [RelName] == null) - Signals [RelName] = new SimpleSignal ( - this, RawObject, - RelName, value); - - Events.AddHandler (RelName, value); - } - remove { - Events.RemoveHandler (RelName, value); - if (Events [RelName] == null) - Signals.Remove (RelName); - } - } - - /// - /// Click Method - /// - /// - /// - /// Emit a Signal indicating that the button has been - /// clicked. - /// - - [DllImport("gtk-1.3.dll")] - static extern void gtk_button_clicked (IntPtr obj); - - public void Click () - { - gtk_button_clicked (RawObject); - } - - /// - /// Enter Method - /// - /// - /// - /// Emit a Signal indicating that the focus has entered - /// the button. - /// - - [DllImport("gtk-1.3.dll")] - static extern void gtk_button_enter (IntPtr obj); - - public void Enter () - { - gtk_button_enter (RawObject); - } - - /// - /// Leave Method - /// - /// - /// - /// Emit a Signal indicating that the focus has left the - /// button. - /// - - [DllImport("gtk-1.3.dll")] - static extern void gtk_button_leave (IntPtr obj); - - public void Leave () - { - gtk_button_leave (RawObject); - } - - /// - /// Pressed Method - /// - /// - /// - /// Emit a Signal indicating that the button has been - /// pressed. - /// - - [DllImport("gtk-1.3.dll")] - static extern void gtk_button_pressed (IntPtr obj); - - public void Press () - { - gtk_button_pressed (RawObject); - } - - /// - /// Release Method - /// - /// - /// - /// Emit a Signal indicating that the button has been - /// released. - /// - - [DllImport("gtk-1.3.dll")] - static extern void gtk_button_released (IntPtr obj); - - public void Release () - { - gtk_button_released (RawObject); - } - - } -} diff --git a/gtk/Container.cs b/gtk/Container.cs deleted file mode 100644 index 6282a9c69..000000000 --- a/gtk/Container.cs +++ /dev/null @@ -1,100 +0,0 @@ -// Gtk.Container.cs - GtkContainer class wrapper implementation -// -// Author: Mike Kestner -// -// (c) 2001 Mike Kestner - -namespace Gtk { - - using System; - using System.Runtime.InteropServices; - - /// - /// Container Class - /// - /// - /// - /// Abstract class which provides the capability to embed a - /// widget within its boundaries. - /// - - public abstract class Container : Widget { - - /// - /// BorderWidth Property - /// - /// - /// - /// The Width, in pixels, of the border around the - /// Container. - /// - - public int BorderWidth { - get { - int val; - GetProperty ("border-width", out val); - return val; - } - set { - SetProperty ("border-width", value); - } - } - - // FIXME: Implement Child property. - - /// - /// ResizeMode Property - /// - /// - /// - /// Indicates the resizing policy for the Container. - /// - - public ResizeMode ResizeMode { - get { - int val; - GetProperty ("border-width", out val); - return (ResizeMode) val; - } - set { - SetProperty ("border-width", (int) value); - } - } - - /// - /// Add Method - /// - /// - /// - /// Adds a child Widget to the Container. - /// - - [DllImport("gtk-1.3.dll", CharSet=CharSet.Ansi, - CallingConvention=CallingConvention.Cdecl)] - static extern void gtk_container_add (IntPtr obj, IntPtr child); - - public void Add (Widget child) - { - gtk_container_add (Handle, child.Handle); - } - - /// - /// Remove Method - /// - /// - /// - /// Remove a child Widget from the Container. - /// - - [DllImport("gtk-1.3.dll", CharSet=CharSet.Ansi, - CallingConvention=CallingConvention.Cdecl)] - static extern void gtk_container_remove (IntPtr obj, - IntPtr child); - - public void Remove (Widget child) - { - gtk_container_remove (Handle, child.Handle); - } - - } -} diff --git a/gtk/Label.cs b/gtk/Label.cs deleted file mode 100644 index db5df56d6..000000000 --- a/gtk/Label.cs +++ /dev/null @@ -1,240 +0,0 @@ -// GTK.Label.cs - GTK Label class implementation -// -// Author: Bob Smith -// -// (c) 2001 Bob Smith - -namespace Gtk { - - using System; - using System.Runtime.InteropServices; - - public class Label : Widget { - - /// - /// Label Object Constructor - /// - /// - /// - /// Constructs a Label Wrapper. - /// - - public Label (IntPtr o) - { - RawObject = o; - } - - /// - /// Label Constructor - /// - /// - /// - /// Constructs a new Label with the specified content. - /// - - [DllImport("gtk-1.3")] - static extern IntPtr gtk_label_new (String str); - - public Label (String str) - { - RawObject = gtk_label_new (str); - } - - /// - /// Text Property - /// - /// - /// - /// The raw text of the label. - /// - - [DllImport("gtk-1.3")] - static extern void gtk_label_set_text (IntPtr hnd, String str); - [DllImport("gtk-1.3")] - static extern String gtk_label_get_text (IntPtr hnd); - - public String Text { - get - { - return gtk_label_get_text (RawObject); - } - set - { - gtk_label_set_text (RawObject, value); - } - } - - /// - /// Markup Property - /// - /// - /// - /// Text to parse. - /// - - [DllImport("gtk-1.3")] - static extern void gtk_label_set_markup (IntPtr hnd, String str); - - public String Markup { - set - { - gtk_label_set_markup (RawObject, value); - } - } - - /// - /// Label Property - /// - /// - /// - /// Parsed content. - /// -/* - [DllImport("gtk-1.3")] - static extern void gtk_label_set_label (IntPtr hnd, String str); - [DllImport("gtk-1.3")] - static extern String gtk_label_get_label (IntPtr hnd); - - public String Label { - get - { - return gtk_label_get_label (RawObject); - } - set - { - gtk_label_set_label (RawObject, value); - } - } -*/ - /// - /// Selectable Property - /// - /// - /// - /// Is the user able to select text from the label. - /// - - [DllImport("gtk-1.3")] - static extern void gtk_label_set_selectable (IntPtr hnd, bool setting); - [DllImport("gtk-1.3")] - static extern bool gtk_label_get_selectable (IntPtr hnd); - - public bool Selectable { - get - { - return gtk_label_get_selectable (RawObject); - } - set - { - gtk_label_set_selectable (RawObject, value); - } - } - - /// - /// UseUnderline Property - /// - /// - /// - /// Indicates that the next character after an underline should be the accelerator key. - /// - - [DllImport("gtk-1.3")] - static extern void gtk_label_set_use_underline (IntPtr hnd, bool setting); - [DllImport("gtk-1.3")] - static extern bool gtk_label_get_use_underline (IntPtr hnd); - - public bool UseUnderline { - get - { - return gtk_label_get_use_underline (RawObject); - } - set - { - gtk_label_set_use_underline (RawObject, value); - } - } - - /// - /// UseMarkup Property - /// - /// - /// - /// Indicates that the text contains markup. - /// - - [DllImport("gtk-1.3")] - static extern void gtk_label_set_use_markup (IntPtr hnd, bool setting); - [DllImport("gtk-1.3")] - static extern bool gtk_label_get_use_markup (IntPtr hnd); - - public bool UseMarkup { - get - { - return gtk_label_get_use_markup (RawObject); - } - set - { - gtk_label_set_use_markup (RawObject, value); - } - } - - /// - /// LineWrap Property - /// - /// - /// - /// Indicates that the text is automatically wrapped if to long. - /// - - [DllImport("gtk-1.3")] - static extern void gtk_label_set_line_wrap (IntPtr hnd, bool setting); - [DllImport("gtk-1.3")] - static extern bool gtk_label_get_line_wrap (IntPtr hnd); - - public bool LineWrap { - get - { - return gtk_label_get_line_wrap (RawObject); - } - set - { - gtk_label_set_line_wrap (RawObject, value); - } - } - - -/* -TODO: - -void gtk_label_set_attributes(GtkLabel *label, PangoAttrList *attrs); -void gtk_label_set_markup_with_mnemonic(GtkLabel *label, const gchar *str); -void gtk_label_set_pattern(GtkLabel *label, const gchar *pattern); -void gtk_label_set_justify(GtkLabel *label, GtkJustification jtype); -guint gtk_label_parse_uline(GtkLabel *label, const gchar *string); -void gtk_label_get_layout_offsets (GtkLabel *label, - gint *x, - gint *y); -guint gtk_label_get_mnemonic_keyval (GtkLabel *label); -GtkWidget* gtk_label_new_with_mnemonic (const char *str); -void gtk_label_select_region (GtkLabel *label, - gint start_offset, - gint end_offset); -void gtk_label_set_mnemonic_widget (GtkLabel *label, - GtkWidget *widget); -void gtk_label_set_text_with_mnemonic -(GtkLabel *label, - const gchar *str); -PangoAttrList* gtk_label_get_attributes (GtkLabel *label); -GtkJustification gtk_label_get_justify (GtkLabel *label); -PangoLayout* gtk_label_get_layout (GtkLabel *label); - -GtkWidget* gtk_label_get_mnemonic_widget (GtkLabel *label); -gboolean gtk_label_get_selection_bounds (GtkLabel *label, - gint *start, - gint *end); - -*/ - - - } -} diff --git a/gtk/Object.cs b/gtk/Object.cs deleted file mode 100755 index 83fb6bb63..000000000 --- a/gtk/Object.cs +++ /dev/null @@ -1,16 +0,0 @@ -// Object.cs - GtkObject class wrapper implementation -// -// Author: Mike Kestner -// -// (c) 2001 Mike Kestner - -namespace Gtk { - - using System; - using System.ComponentModel; - using System.Runtime.InteropServices; - - public abstract class Object : GLib.Object { - - } -} diff --git a/parser/TODO b/parser/TODO index 5f299c7f4..af3c1582c 100644 --- a/parser/TODO +++ b/parser/TODO @@ -1 +1,3 @@ Fix enum bug where symbolic values are used (eg Gdk.ModifierType.ModifierMask). +Fix property names where a variable is used instead of a string literal. +Fix the bool property macro definitions in GtkTextTag and CellRendererText. diff --git a/parser/gapi2xml.pl b/parser/gapi2xml.pl index a65449065..741e21dee 100755 --- a/parser/gapi2xml.pl +++ b/parser/gapi2xml.pl @@ -425,46 +425,45 @@ sub addPropElem { my ($spec, $node) = @_; my ($name, $mode, $docs); - $spec =~ /g_param_spec_(\w+)\s*\((.*)/; + $spec =~ /g_param_spec_(\w+)\s*\((.*)\s*\)\s*\)/; my $type = $1; - my $params = $2; + my @params = split(/,/, $2); - if ($type =~ /boolean|^u*int|pointer/) { - $params =~ /\"(.+)\",.+\".+\".+\"(.+)\".*(,\s*G_PARAM_\w+.*)\)\s*\)/; - $name = $1; $docs = $2; $mode = $3; + # FIXME: Handle non-literals. Needs work in the pp too. + $name = $params[0]; + $name =~ s/\"//g; + + while ($params[2] !~ /\"\s*\)?$/) { + die "Unable to reconstruct doc string.\n" if (!$params[3]); + $params[2] .= ",$params[3]"; + @params = (@params[0..2],@params[4..$#params]); + } + $docs = $params[2]; + $docs =~ s/\"//g; + $docs =~ s/\s+/ /g; + $mode = $params[$#params]; + + if ($type =~ /boolean|float|double|^u?int|pointer/) { $type = "g$type"; } elsif ($type =~ /string/) { - $params =~ /\"(.+)\",.+\".+\".+\"(.+)\".*(,\s*G_PARAM_\w+.*)\)\s*\)/; - $name = $1; $docs = $2; $mode = $3; $type = "gchar*"; - } elsif ($type =~ /enum|flags/) { - $params =~ /\"(.+)\",.+,.+\"(.+)\".*,\s+(\w+),.*,(\s*G_PARAM_\w+.*)\)\s*\)/; - $name = $1; $docs = $2; $type = $3; $mode = $4; - $type =~ s/TYPE_//; - $type = StudlyCaps(lc($type)); - } elsif ($type =~ /object/) { - $params =~ /\"(.+)\",.+,.+\"(.+)\".*,\s+(\w+),(\s*G_PARAM_\w+.*)\)\s*\)/; - $name = $1; $docs = $2; $type = $3; $mode = $4; + } elsif ($type =~ /enum|flags|object/) { + $type = $params[3]; $type =~ s/TYPE_//; + $type =~ s/\s+//g; $type = StudlyCaps(lc($type)); } - $prop_elem = $doc->createElement('property'); $node->appendChild($prop_elem); - $prop_elem->setAttribute('name', $name); + $prop_elem->setAttribute('name', StudlyCaps($name)); + $prop_elem->setAttribute('cname', $name); $prop_elem->setAttribute('type', $type); $prop_elem->setAttribute('doc-string', $docs); - if ($mode =~ /READ/) { - $prop_elem->setAttribute('readable', "true"); - } - if ($mode =~ /WRIT/) { - $prop_elem->setAttribute('writeable', "true"); - } - if ($mode =~ /CONS/) { - $prop_elem->setAttribute('construct-only', "true"); - } + $prop_elem->setAttribute('readable', "true") if ($mode =~ /READ/); + $prop_elem->setAttribute('writeable', "true") if ($mode =~ /WRIT/); + $prop_elem->setAttribute('construct-only', "true") if ($mode =~ /CONS/); } sub addSignalElem @@ -526,26 +525,23 @@ sub parseInitFunc my $line = $init_lines[$linenum]; - while ($linenum < @init_lines) { - $line = $init_lines[$linenum]; - if ($line =~ /g_object_class_install_prop/) { - my $prop = $line; - do { - $prop .= $init_lines[++$linenum]; - } until ($init_lines[$linenum] =~ /;/); - addPropElem ($prop, $obj_el); - $propcnt++; - } elsif ($line =~ /g(tk)?_signal_new/) { - my $sig = $line; - do { - $sig .= $init_lines[++$linenum]; - } until ($init_lines[$linenum] =~ /;/); - addSignalElem ($sig, $classdef, $obj_el); - $sigcnt++; - } - $linenum++; + if ($line =~ /#define/) { + # FIXME: This ignores the bool helper macro thingie. + } elsif ($line =~ /g_object_class_install_prop/) { + my $prop = $line; + do { + $prop .= $init_lines[++$linenum]; + } until ($init_lines[$linenum] =~ /;/); + addPropElem ($prop, $obj_el); + $propcnt++; + } elsif ($line =~ /g(tk)?_signal_new/) { + my $sig = $line; + do { + $sig .= $init_lines[++$linenum]; + } until ($init_lines[$linenum] =~ /;/); + addSignalElem ($sig, $classdef, $obj_el); + $sigcnt++; } - $linenum++; } }