diff --git a/ChangeLog b/ChangeLog index cfcb31dbe..c8c478ed1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2004-12-20 Mike Kestner + + * gdk/Gdk.metadata : mark a couple array params. + * generator/Field.cs : remove the MarshalAs hack. We have to + do something much more evil since MarshalAs can't hang. + * generator/ImportSignature.cs : deal with out LP(U)Gen params. + * generator/LPGen.cs : moved from SSizeTGen and generalized. + * generator/LPUGen.cs : moved from SizeTGen and generalized. + * generator/Makefile.am : update sources. + * generator/MethodBody.cs : deal with out LP(U)Gen params. + * generator/Parameters.cs : deal with out LP(U)Gen params. + * generator/SymbolTable.cs : make all longs and size_t types LP(U)Gens. + 2004-12-20 Dan Winship * generator/GUnicharGen.cs: generatable for gunichar, using diff --git a/doc/en/Gdk/Colors.xml b/doc/en/Gdk/Colors.xml index 84c1bf99c..325ca4189 100644 --- a/doc/en/Gdk/Colors.xml +++ b/doc/en/Gdk/Colors.xml @@ -18,32 +18,6 @@ - - - Method - - System.Int32 - - - - - - - - - - - To be added - a - a - a - a - a - a - a - To be added - - Method @@ -63,26 +37,6 @@ To be added - - - Method - - System.UInt64 - - - - - - - - To be added - a - a - a - a - To be added - - Constructor @@ -94,5 +48,52 @@ To be added + + + Method + + System.Int32 + + + + + + + + + + + To be added + a + a + a + a + a + a + a + To be added + + + + + Method + + System.Void + + + + + + + + + To be added + a + a + a + a + To be added + + - \ No newline at end of file + diff --git a/doc/en/Vte/Terminal.xml b/doc/en/Vte/Terminal.xml index 821b1e1d4..bf6ebec65 100644 --- a/doc/en/Vte/Terminal.xml +++ b/doc/en/Vte/Terminal.xml @@ -1758,4 +1758,4 @@ class T - \ No newline at end of file + diff --git a/gdk/Gdk.metadata b/gdk/Gdk.metadata index 4556a9666..272ecaf51 100644 --- a/gdk/Gdk.metadata +++ b/gdk/Gdk.metadata @@ -9,6 +9,8 @@ out out 1 + 1 + 1 1 out out diff --git a/generator/Field.cs b/generator/Field.cs index a67818706..3663ed113 100644 --- a/generator/Field.cs +++ b/generator/Field.cs @@ -201,12 +201,6 @@ namespace GtkSharp.Generation { } else if (IsPointer && CSType != "string") { // FIXME: probably some fields here which should be visible. sw.WriteLine ("\t\tprivate {0} {1};", CSType, Name); - } else if (CSType == "long") { - sw.WriteLine ("\t\t[MarshalAs (UnmanagedType.SysInt)]"); - sw.WriteLine ("\t\t{0} {1} {2};", Access, CSType, StudlyName); - } else if (CSType == "ulong") { - sw.WriteLine ("\t\t[MarshalAs (UnmanagedType.SysUInt)]"); - sw.WriteLine ("\t\t{0} {1} {2};", Access, CSType, StudlyName); } else if (Access != "public") { sw.WriteLine ("\t\t{0} {1} {2};", Access, CSType, Name); } else { diff --git a/generator/ImportSignature.cs b/generator/ImportSignature.cs index 2019c35b0..8dda9c395 100644 --- a/generator/ImportSignature.cs +++ b/generator/ImportSignature.cs @@ -56,7 +56,7 @@ namespace GtkSharp.Generation { parms [i] = ""; if (p.CType == "GError**") parms [i] += "out "; - else if (p.PassAs != "" && (!m_type.EndsWith ("IntPtr") || UsesHandle (p.Generatable))) + else if (p.PassAs != "" && (!m_type.EndsWith ("IntPtr") || p.Generatable is LPGen || p.Generatable is LPUGen || UsesHandle (p.Generatable))) parms [i] += p.PassAs + " "; parms [i] += m_type + " " + p.Name; } diff --git a/generator/SSizeTGen.cs b/generator/LPGen.cs similarity index 84% rename from generator/SSizeTGen.cs rename to generator/LPGen.cs index c4fec6e3d..e34923012 100644 --- a/generator/SSizeTGen.cs +++ b/generator/LPGen.cs @@ -1,4 +1,4 @@ -// GtkSharp.Generation.SizeTGen.cs - The size_t Generatable. +// GtkSharp.Generation.LPGen.cs - long/pointer Generatable. // // Author: Mike Kestner // @@ -23,14 +23,18 @@ namespace GtkSharp.Generation { using System; - public class SSizeTGen : IGeneratable { + public class LPGen : IGeneratable { string ctype; - string type; + + public LPGen (string ctype) + { + this.ctype = ctype; + } public string CName { get { - return "ssize_t"; + return ctype; } } @@ -53,15 +57,13 @@ namespace GtkSharp.Generation { } public string MarshalReturnType { - get - { + get { return MarshalType; } } public string ToNativeReturnType { - get - { + get { return MarshalType; } } diff --git a/generator/SizeTGen.cs b/generator/LPUGen.cs similarity index 85% rename from generator/SizeTGen.cs rename to generator/LPUGen.cs index 77a39a2de..3e5b8ce3c 100644 --- a/generator/SizeTGen.cs +++ b/generator/LPUGen.cs @@ -1,4 +1,4 @@ -// GtkSharp.Generation.SizeTGen.cs - The size_t Generatable. +// GtkSharp.Generation.LPUGen.cs - unsugned long/pointer generatable. // // Author: Mike Kestner // @@ -23,15 +23,18 @@ namespace GtkSharp.Generation { using System; - public class SizeTGen : IGeneratable { + public class LPUGen : IGeneratable { string ctype; - string type; - string ns = ""; + + public LPUGen (string ctype) + { + this.ctype = ctype; + } public string CName { get { - return "size_t"; + return ctype; } } diff --git a/generator/Makefile.am b/generator/Makefile.am index 91b8878c2..e4efe48f4 100644 --- a/generator/Makefile.am +++ b/generator/Makefile.am @@ -28,6 +28,8 @@ sources = \ IGeneratable.cs \ ImportSignature.cs \ InterfaceGen.cs \ + LPGen.cs \ + LPUGen.cs \ ManagedCallString.cs \ ManualGen.cs \ MethodBody.cs \ @@ -42,8 +44,6 @@ sources = \ SignalHandler.cs \ Signature.cs \ SimpleGen.cs \ - SizeTGen.cs \ - SSizeTGen.cs \ Statistics.cs \ StringGen.cs \ StructBase.cs \ diff --git a/generator/MethodBody.cs b/generator/MethodBody.cs index 072104ad5..ab019694d 100644 --- a/generator/MethodBody.cs +++ b/generator/MethodBody.cs @@ -86,11 +86,13 @@ namespace GtkSharp.Generation { if (p.CType == "GError**") { result [i] += "out "; } else if (p.PassAs != "") { - if (!p.MarshalType.EndsWith ("IntPtr")) + if (p.Generatable is LPGen || !p.MarshalType.EndsWith ("IntPtr")) result [i] += p.PassAs + " "; if (igen is EnumGen) call_parm = p.Name + "_as_int"; + else if (igen is LPUGen || igen is LPGen) + call_parm = p.Name + "_as_ptr"; else if (UsesHandle (igen)) { call_parm = p.PassAs + " " + call_parm.Replace (".Handle", "_handle"); } @@ -132,6 +134,9 @@ namespace GtkSharp.Generation { if (p.PassAs == "out" && gen is EnumGen) sw.WriteLine(indent + "\t\t\tint " + name + "_as_int;"); + if (p.PassAs == "out" && (gen is LPGen || gen is LPUGen)) + sw.WriteLine(indent + "\t\t\t" + gen.MarshalType + " " + name + "_as_ptr;"); + if (p.IsArray && p.MarshalType != p.CSType) { sw.WriteLine(indent + "\t\t\t{0}[] native_{1} = new {0} [{1}.Length];", p.MarshalType.TrimEnd('[', ']'), name); sw.WriteLine(indent + "\t\t\tfor (int i = 0; i < {0}.Length; i++)", name); @@ -166,12 +171,14 @@ namespace GtkSharp.Generation { for (int i = 0; i < parameters.Count; i++) { Parameter p = parameters [i]; - if (p.PassAs == "out" && p.Generatable is EnumGen) { - sw.WriteLine(indent + "\t\t\t" + p.Name + " = (" + p.CSType + ") " + p.Name + "_as_int;"); - } - IGeneratable gen = p.Generatable; + if (p.PassAs == "out" && gen is EnumGen) + sw.WriteLine(indent + "\t\t\t" + p.Name + " = (" + p.CSType + ") " + p.Name + "_as_int;"); + + if (p.PassAs == "out" && (gen is LPGen || gen is LPUGen)) + sw.WriteLine(indent + "\t\t\t" + p.Name + " = (" + p.CSType + ") " + p.Name + "_as_ptr;"); + if (p.PassAs == "out" && UsesHandle (gen)) sw.WriteLine(indent + "\t\t\t" + p.Name + " = " + gen.FromNativeReturn (p.Name + "_handle") + ";"); } diff --git a/generator/Parameters.cs b/generator/Parameters.cs index 639a4e020..e444b4235 100644 --- a/generator/Parameters.cs +++ b/generator/Parameters.cs @@ -178,6 +178,9 @@ namespace GtkSharp.Generation { if (Generatable is SimpleGen && !(Generatable is ConstStringGen) && CType.EndsWith ("*") && !CSType.EndsWith ("IntPtr")) return "out"; + if ((Generatable is LPGen || Generatable is LPUGen) && CType.EndsWith ("*")) + return "out"; + if (Generatable is EnumGen && CType.EndsWith ("*")) return "out"; diff --git a/generator/SymbolTable.cs b/generator/SymbolTable.cs index 786803b9b..3a28bb100 100644 --- a/generator/SymbolTable.cs +++ b/generator/SymbolTable.cs @@ -47,7 +47,6 @@ namespace GtkSharp.Generation { AddType (new SimpleGen ("gint", "int")); AddType (new SimpleGen ("guint", "uint")); AddType (new SimpleGen ("unsigned int", "uint")); - AddType (new SimpleGen ("glong", "long")); AddType (new SimpleGen ("gshort", "short")); AddType (new SimpleGen ("gushort", "ushort")); AddType (new SimpleGen ("guint32", "uint")); @@ -71,9 +70,6 @@ namespace GtkSharp.Generation { AddType (new SimpleGen ("guchar", "byte")); AddType (new SimpleGen ("unsigned char", "byte")); AddType (new SimpleGen ("short", "short")); - AddType (new SimpleGen ("long", "long")); - AddType (new SimpleGen ("ulong", "ulong")); - AddType (new SimpleGen ("gulong", "ulong")); AddType (new SimpleGen ("GQuark", "int")); AddType (new SimpleGen ("int", "int")); AddType (new StringGen ("char")); @@ -84,13 +80,21 @@ namespace GtkSharp.Generation { AddType (new SimpleGen ("GPtrArray", "IntPtr[]")); AddType (new ManualGen ("GType", "GLib.GType", "Val")); AddType (new SimpleGen ("GError", "IntPtr")); + // gsize is a system-specific typedef in glibconfig.h, // but this should work for now AddType (new SimpleGen ("gsize", "uint")); AddType (new SimpleGen ("gssize", "int")); AddType (new AliasGen ("off_t", "size_t")); - AddType (new SizeTGen ()); - AddType (new SSizeTGen ()); + + // system specific integer types. these will break on any + // platform where sizeof (long) != sizeof (pointer) + AddType (new LPGen ("ssize_t")); + AddType (new LPGen ("long")); + AddType (new LPGen ("glong")); + AddType (new LPUGen ("size_t")); + AddType (new LPUGen ("ulong")); + AddType (new LPUGen ("gulong")); AddType (new GUnicharGen ()); // FIXME: These ought to be handled properly.