From 7fb558bea0f0bf0402ea04577137e417e009bcd4 Mon Sep 17 00:00:00 2001 From: Rachel Hestilow Date: Sun, 23 Jun 2002 03:38:02 +0000 Subject: [PATCH] 2002-06-23 Rachel Hestilow * generator/ClassBase.cs: Add accessors for methods and signals. Change GenSignals and GenMethods to public, as csc has a different idea of protected than mcs. Handle interface collisions in GenMethods. * generator/Method.cs: Add accessor Protection - "public" by default. * generator/ObjectGen.cs: Make sure wrapper's Signals hashtable only gets generated once. Generate a list of collisions for GenMethods. Remove dead foreach loop from Validate. * generator/Paramaters.cs (CreateSignature): Initialize last_param. * parser/Gtk.metadata: Add property & event collision renames for TextBuffer and OldEditable. * sample/makefile.win32: Reference atk-sharp.dll. * makefile.win32: Do not build gdk.imaging. svn path=/trunk/gtk-sharp/; revision=5420 --- ChangeLog | 22 ++++++++++++++++++++ generator/ClassBase.cs | 33 ++++++++++++++++++++++++++---- generator/Method.cs | 16 +++++++++++++-- generator/ObjectGen.cs | 46 +++++++++++++++++++++++++++++++++--------- generator/gtkapi.xml | 2 +- makefile.win32 | 2 +- parser/Gtk.metadata | 23 +++++++++++++++++++++ parser/build.pl | 10 ++++----- sample/makefile.win32 | 6 +++--- sources/Gtk.metadata | 23 +++++++++++++++++++++ 10 files changed, 157 insertions(+), 26 deletions(-) diff --git a/ChangeLog b/ChangeLog index d7a378f29..80f1c407a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,25 @@ +2002-06-23 Rachel Hestilow + + * generator/ClassBase.cs: Add accessors for methods and signals. + Change GenSignals and GenMethods to public, as csc has a different + idea of protected than mcs. Handle interface collisions in + GenMethods. + + * generator/Method.cs: Add accessor Protection - "public" by default. + + * generator/ObjectGen.cs: Make sure wrapper's Signals hashtable only + gets generated once. Generate a list of collisions for GenMethods. + Remove dead foreach loop from Validate. + + * generator/Paramaters.cs (CreateSignature): Initialize last_param. + + * parser/Gtk.metadata: Add property & event collision renames + for TextBuffer and OldEditable. + + * sample/makefile.win32: Reference atk-sharp.dll. + + * makefile.win32: Do not build gdk.imaging. + 2002-06-22 Mike Kestner * */makefile.win32 : add docs target diff --git a/generator/ClassBase.cs b/generator/ClassBase.cs index bfe2dfdf4..74a869be6 100644 --- a/generator/ClassBase.cs +++ b/generator/ClassBase.cs @@ -18,6 +18,18 @@ namespace GtkSharp.Generation { protected Hashtable methods = new Hashtable(); protected ArrayList interfaces = null; + public Hashtable Methods { + get { + return methods; + } + } + + public Hashtable Signals { + get { + return sigs; + } + } + protected ClassBase (XmlElement ns, XmlElement elem) : base (ns, elem) { foreach (XmlNode node in elem.ChildNodes) { XmlElement member = (XmlElement) node; @@ -89,13 +101,11 @@ namespace GtkSharp.Generation { } } - protected void GenSignals (StreamWriter sw) + public void GenSignals (StreamWriter sw) { if (sigs == null) return; - sw.WriteLine("\t\tprivate Hashtable Signals = new Hashtable();"); - foreach (Signal sig in sigs.Values) { if (sig.Validate ()) sig.Generate (sw); @@ -125,7 +135,7 @@ namespace GtkSharp.Generation { (props != null) && props.ContainsKey(mname.Substring(3))); } - public void GenMethods (StreamWriter sw) + public void GenMethods (StreamWriter sw, Hashtable collisions) { if (methods == null) return; @@ -135,7 +145,22 @@ namespace GtkSharp.Generation { continue; if (method.Validate ()) + { + String oname = null, oprotection = null; + if (collisions != null && collisions.Contains (method.Name)) + { + oname = method.Name; + oprotection = method.Protection; + method.Name = Name + "." + method.Name; + method.Protection = ""; + } method.Generate (sw); + if (oname != null) + { + method.Name = oname; + method.Protection = oprotection; + } + } else Console.WriteLine(" in Object " + Name); } diff --git a/generator/Method.cs b/generator/Method.cs index cdf2a40a1..ef74bad80 100644 --- a/generator/Method.cs +++ b/generator/Method.cs @@ -22,6 +22,7 @@ namespace GtkSharp.Generation { private string sig, isig, call; private string rettype, m_ret, s_ret; private string name, cname, safety; + private string protection = "public"; private bool is_get, is_set; public Method (string libname, XmlElement elem, ClassBase container_type) @@ -49,6 +50,15 @@ namespace GtkSharp.Generation { } } + public string Protection { + get { + return protection; + } + set { + protection = value; + } + } + public override bool Equals (object o) { if (!(o is Method)) @@ -249,8 +259,10 @@ namespace GtkSharp.Generation { GenerateImport (sw); if (comp != null && s_ret == comp.parms.AccessorReturnType) comp.GenerateImport (sw); - - sw.Write("\t\tpublic "); + + sw.Write("\t\t"); + if (protection != "") + sw.Write("{0} ", protection); GenerateDeclCommon (sw); if (is_get || is_set) diff --git a/generator/ObjectGen.cs b/generator/ObjectGen.cs index 103be0ccb..f72d839fa 100644 --- a/generator/ObjectGen.cs +++ b/generator/ObjectGen.cs @@ -69,13 +69,43 @@ namespace GtkSharp.Generation { GenCtors (sw); GenProperties (sw); - GenSignals (sw); - GenMethods (sw); - if (interfaces != null) { + bool has_sigs = (sigs != null); + if (!has_sigs) { foreach (string iface in interfaces) { ClassBase igen = SymbolTable.GetClassGen (iface); - igen.GenMethods (sw); + if (igen.Signals != null) { + has_sigs = true; + break; + } + } + } + + if (has_sigs) + { + sw.WriteLine("\t\tprivate Hashtable Signals = new Hashtable();"); + GenSignals (sw); + } + + GenMethods (sw, null); + + if (interfaces != null) { + Hashtable all_methods = new Hashtable (); + Hashtable collisions = new Hashtable (); + foreach (string iface in interfaces) { + ClassBase igen = SymbolTable.GetClassGen (iface); + foreach (Method m in igen.Methods.Values) { + if (all_methods.Contains (m.Name)) + collisions[m.Name] = true; + else + all_methods[m.Name] = true; + } + } + + foreach (string iface in interfaces) { + ClassBase igen = SymbolTable.GetClassGen (iface); + igen.GenMethods (sw, collisions); + igen.GenSignals (sw); } } @@ -116,12 +146,8 @@ namespace GtkSharp.Generation { if (!method.Validate()) return false; - if (interfaces != null) { - foreach (string iface in interfaces) { - if (SymbolTable.GetCSType(parent) == null) - return false; - } - } + if (SymbolTable.GetCSType(parent) == null) + return false; return true; } diff --git a/generator/gtkapi.xml b/generator/gtkapi.xml index f655f92ee..33c0af17c 100644 --- a/generator/gtkapi.xml +++ b/generator/gtkapi.xml @@ -1,2 +1,2 @@ - + diff --git a/makefile.win32 b/makefile.win32 index ef668ffad..555d84790 100755 --- a/makefile.win32 +++ b/makefile.win32 @@ -1,4 +1,4 @@ -DIRS=generator glib pango atk gdk gdk.imaging gtk sample +DIRS=generator glib pango atk gdk gtk sample ROOT=/cygdrive/$(subst \,/,$(subst :\,/,$(SYSTEMROOT))) CSC=$(ROOT)/microsoft.net/framework/v1.0.3705/csc.exe diff --git a/parser/Gtk.metadata b/parser/Gtk.metadata index 1ef7b2467..3f6e0ad0f 100644 --- a/parser/Gtk.metadata +++ b/parser/Gtk.metadata @@ -300,6 +300,17 @@ + + + GetInsert + + + + name + GetInsertMark + + + Select @@ -741,6 +752,18 @@ + + + Changed + + + + name + Change + + + + ValueChanged diff --git a/parser/build.pl b/parser/build.pl index 8d465879d..03733b8cd 100755 --- a/parser/build.pl +++ b/parser/build.pl @@ -4,11 +4,11 @@ $file = "../generator/gtkapi.xml"; unlink ($file); -%srcs = ( "atk-1.0.0/atk" => "Atk:atk-1.0", - "pango-1.0.0/pango" => "Pango:pango-1.0", - "gtk+-2.0.0/gdk" => "Gdk:gdk-x11-2.0", - "gtk+-2.0.0/gdk-pixbuf" => "Gdk:gdk_pixbuf-2.0", - "gtk+-2.0.0/gtk" => "Gtk:gtk-x11-2.0"); +%srcs = ( "atk-1.0.2/atk" => "Atk:atk-1.0", + "pango-1.0.2/pango" => "Pango:pango-1.0", + "gtk+-2.0.3/gdk" => "Gdk:gdk-x11-2.0", + "gtk+-2.0.3/gdk-pixbuf" => "Gdk:gdk_pixbuf-2.0", + "gtk+-2.0.3/gtk" => "Gtk:gtk-x11-2.0"); foreach $dir (keys %srcs) { ($ns, $lib) = split (/:/, $srcs{$dir}); diff --git a/sample/makefile.win32 b/sample/makefile.win32 index 7c3c943d2..255528650 100644 --- a/sample/makefile.win32 +++ b/sample/makefile.win32 @@ -1,9 +1,9 @@ all: windows windows: - $(CSC) /unsafe /out:gtk-hello-world.exe /r:../glib/glib-sharp.dll /r:../gtk/gtk-sharp.dll /r:../gdk/gdk-sharp.dll HelloWorld.cs - $(CSC) /unsafe /out:button.exe /r:../glib/glib-sharp.dll /r:../gtk/gtk-sharp.dll ButtonApp.cs - $(CSC) /unsafe /out:menu.exe /r:../glib/glib-sharp.dll /r:../gtk/gtk-sharp.dll Menu.cs + $(CSC) /unsafe /out:gtk-hello-world.exe /r:../glib/glib-sharp.dll /r:../atk/atk-sharp.dll /r:../gtk/gtk-sharp.dll /r:../gdk/gdk-sharp.dll HelloWorld.cs + $(CSC) /unsafe /out:button.exe /r:../glib/glib-sharp.dll /r:../atk/atk-sharp.dll /r:../gtk/gtk-sharp.dll ButtonApp.cs + $(CSC) /unsafe /out:menu.exe /r:../glib/glib-sharp.dll /r:../atk/atk-sharp.dll /r:../gtk/gtk-sharp.dll Menu.cs docs: @echo "No docs to make." diff --git a/sources/Gtk.metadata b/sources/Gtk.metadata index 1ef7b2467..3f6e0ad0f 100644 --- a/sources/Gtk.metadata +++ b/sources/Gtk.metadata @@ -300,6 +300,17 @@ + + + GetInsert + + + + name + GetInsertMark + + + Select @@ -741,6 +752,18 @@ + + + Changed + + + + name + Change + + + + ValueChanged