diff --git a/ChangeLog b/ChangeLog index 0ed0491c6..92c24e40f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2002-02-06 Mike Kestner + + * generator/BoxedGen.cs : Marshal as IntPtr using Raw prop. + * generator/ObjectGen.cs : Use Handle for marshaling. + * generator/StructBase.cs (CallByName): Fill out the stub. + (GetImportSig): Fill out the stub. + * generator/StructGen.cs (MarshalType): Use QualifiedName. + * generator/SymbolTable.cs (GetMarshalType): Trim type. + (CallByName): New. Provides calling syntax. + * sample/HelloWorld.cs : Make it compile. + 2002-02-02 Mike Kestner * generator/ObjectGen.cs : Add IntPtr constructor generation. Pass a diff --git a/generator/BoxedGen.cs b/generator/BoxedGen.cs index a94f06bb5..7193912e7 100644 --- a/generator/BoxedGen.cs +++ b/generator/BoxedGen.cs @@ -17,7 +17,7 @@ namespace GtkSharp.Generation { public String MarshalType { get { - return QualifiedName; + return "IntPtr"; } } diff --git a/generator/ObjectGen.cs b/generator/ObjectGen.cs index 3690b0bf8..1c71ed630 100644 --- a/generator/ObjectGen.cs +++ b/generator/ObjectGen.cs @@ -24,7 +24,7 @@ namespace GtkSharp.Generation { public String CallByName (String var_name) { - return var_name + ".RawObject"; + return var_name + ".Handle"; } public void Generate (SymbolTable table) diff --git a/generator/StructBase.cs b/generator/StructBase.cs index 581b61cfe..36539fbe5 100644 --- a/generator/StructBase.cs +++ b/generator/StructBase.cs @@ -131,6 +131,22 @@ namespace GtkSharp.Generation { } XmlElement elem = (XmlElement) parm; + String type = elem.GetAttribute("type"); + String name = elem.GetAttribute("name"); + name = MangleName(name); + String call_parm = table.CallByName(type, name); + + if (call_parm == "") { + Console.Write("Name: " + name + " Type: " + type + " "); + return false; + } + + if (need_comma) { + call += ", "; + } else { + need_comma = true; + } + call += call_parm; } call += ")"; @@ -141,12 +157,34 @@ namespace GtkSharp.Generation { { isig = "("; + bool need_comma = false; + foreach (XmlNode parm in parms.ChildNodes) { - if (parm.Name != "namespace") { + if (parm.Name != "parameter") { continue; } XmlElement elem = (XmlElement) parm; + String type = elem.GetAttribute("type"); + String m_type = table.GetMarshalType(type); + String name = elem.GetAttribute("name"); + name = MangleName(name); + + if ((m_type == "") || (name == "")) { + Console.Write("Name: " + name + " Type: " + type + " "); + return false; + } + + if (elem.HasAttribute("array")) { + m_type += "[]"; + } + + if (need_comma) { + isig += ", "; + } else { + need_comma = true; + } + isig += (m_type + " " + name); } isig += ");"; diff --git a/generator/StructGen.cs b/generator/StructGen.cs index 83bce520e..888917d9f 100644 --- a/generator/StructGen.cs +++ b/generator/StructGen.cs @@ -17,7 +17,7 @@ namespace GtkSharp.Generation { public String MarshalType { get { - return "IntPtr"; + return QualifiedName; } } diff --git a/generator/SymbolTable.cs b/generator/SymbolTable.cs index fe6109ddf..28e52423a 100644 --- a/generator/SymbolTable.cs +++ b/generator/SymbolTable.cs @@ -115,6 +115,7 @@ namespace GtkSharp.Generation { public String GetMarshalType(String c_type) { + c_type = Trim(c_type); if (simple_types.ContainsKey(c_type)) { return (String) simple_types[c_type]; } else if (complex_types.ContainsKey(c_type)) { @@ -125,6 +126,19 @@ namespace GtkSharp.Generation { } } + public String CallByName(String c_type, String var_name) + { + c_type = Trim(c_type); + if (simple_types.ContainsKey(c_type)) { + return var_name; + } else if (complex_types.ContainsKey(c_type)) { + IGeneratable gen = (IGeneratable) complex_types[c_type]; + return gen.CallByName(var_name); + } else { + return ""; + } + } + public bool IsBoxed(String c_type) { if (complex_types.ContainsKey(c_type)) { diff --git a/sample/HelloWorld.cs b/sample/HelloWorld.cs index 0eb9164f0..5bc04973e 100755 --- a/sample/HelloWorld.cs +++ b/sample/HelloWorld.cs @@ -17,9 +17,13 @@ namespace GtkSamples { public static int Main (string[] args) { Application.Init (ref args); - Gtk.Window win = new Gtk.Window ("Gtk# Hello World"); - win.Deleted += new EventHandler (Window_Delete); - win.Show (); + Console.WriteLine("Creating Window"); + Gtk.Window win = new Gtk.Window (Gtk.WindowType.Toplevel); + Console.WriteLine("Setting Title"); + win.Title = "Gtk# Hello World"; + // win.Deleted += new EventHandler (Window_Delete); + // win.Show (); + Console.WriteLine("Entering event loop"); Application.Run (); return 0; }