From 3b1dd1079b390bc8cf88aade4cccd72a56216ec6 Mon Sep 17 00:00:00 2001 From: Mike Kestner Date: Fri, 11 Oct 2002 00:27:46 +0000 Subject: [PATCH] 2002-10-10 Mike Kestner * generator/CallbackGen.cs : some fixes * generator/Parameters.cs (CreateSignature): handle void params svn path=/trunk/gtk-sharp/; revision=8156 --- ChangeLog | 5 +++++ generator/CallbackGen.cs | 4 ++-- generator/Parameters.cs | 20 ++++++++++++++++---- 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index d7de7ff43..7b0126e7d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2002-10-10 Mike Kestner + + * generator/CallbackGen.cs : some fixes + * generator/Parameters.cs (CreateSignature): handle void params + 2002-10-10 Miguel de Icaza * gtk/ThreadNotify.cs: Avoid multiple notifications. diff --git a/generator/CallbackGen.cs b/generator/CallbackGen.cs index 939617959..6e23be5a9 100644 --- a/generator/CallbackGen.cs +++ b/generator/CallbackGen.cs @@ -94,7 +94,7 @@ namespace GtkSharp.Generation { sw.WriteLine ("\t\t{"); int count = (parms != null) ? parms.Count : 0; if (count > 0) - sw.WriteLine ("\t\t\tobject[] _args = new object[{0}];", count - 1); + sw.WriteLine ("\t\t\tobject[] _args = new object[{0}];", count); int idx = 0; bool need_sep = false; string call_str = ""; @@ -102,7 +102,7 @@ namespace GtkSharp.Generation { { string parm_name = parms[i].Name; string ctype = parms[i].CType; - if (ctype == "gpointer" && (parm_name.EndsWith ("data") || parm_name.EndsWith ("data_or_owner"))) + if ((i == count - 1) && ctype == "gpointer" && (parm_name.EndsWith ("data") || parm_name.EndsWith ("data_or_owner"))) continue; string cstype = parms[i].CSType; // FIXME: Too much code copy/pasted here. Refactor? diff --git a/generator/Parameters.cs b/generator/Parameters.cs index ec635d57e..23bedc8d1 100644 --- a/generator/Parameters.cs +++ b/generator/Parameters.cs @@ -21,13 +21,18 @@ namespace GtkSharp.Generation { public string CType { get { - return elem.GetAttribute("type"); + string type = elem.GetAttribute("type"); + if (type == "void*") + type = "gpointer"; + return type; } } public string CSType { get { string cstype = SymbolTable.GetCSType( elem.GetAttribute("type")); + if (cstype == "void") + cstype = "System.IntPtr"; if (elem.HasAttribute("array")) cstype += "[]"; return cstype; @@ -36,7 +41,10 @@ namespace GtkSharp.Generation { public string MarshalType { get { - return SymbolTable.GetMarshalType( elem.GetAttribute("type")); + string type = SymbolTable.GetMarshalType( elem.GetAttribute("type")); + if (type == "void") + type = "System.IntPtr"; + return type; } } @@ -188,7 +196,11 @@ namespace GtkSharp.Generation { XmlElement p_elem = (XmlElement) parm; string type = p_elem.GetAttribute("type"); string cs_type = SymbolTable.GetCSType(type); + if (cs_type == "void") + cs_type = "System.IntPtr"; string m_type = SymbolTable.GetMarshalType(type); + if (m_type == "void") + m_type = "System.IntPtr"; string name = MangleName(p_elem.GetAttribute("name")); string call_parm, call_parm_name; @@ -262,14 +274,14 @@ namespace GtkSharp.Generation { } else { - if (!(type == "GError**" || (has_callback && type == "gpointer" && (name.EndsWith ("data") || name.EndsWith ("data_or_owner"))))) { + if (!(type == "GError**" || (has_callback && (type == "gpointer" || type == "void*") && (i == Count - 1) && (name.EndsWith ("data") || name.EndsWith ("data_or_owner"))))) { signature += (cs_type + " " + name); signature_types += cs_type; last_was_user_data = false; } else if (type == "GError**") { call_parm = call_parm.Replace (name, "error"); last_was_user_data = false; - } else if (type == "gpointer" && (name.EndsWith ("data") || name.EndsWith ("data_or_owner"))) { + } else if ((type == "gpointer" || type == "void*") && (i == Count - 1) && (name.EndsWith ("data") || name.EndsWith ("data_or_owner"))) { call_parm = "IntPtr.Zero"; last_was_user_data = true; } else