diff --git a/ChangeLog b/ChangeLog index 7feb54f5c..568dd0a84 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2003-10-13 Mike Kestner + + * gdk/Gdk.metadata : mark an array param on PixbufDestroyNotify + * gdk/gdk-api.xml : regenerated + * generator/CallbackGen.cs : Handle out params in callback sigs + and ditch the object[] args handling for typed args. + * generator/Parameters.cs : more proactive PassAs logic. We now + default all simple pointer types (uint*, int*, double*, etc...) + to out params unless they are marked otherwise in the XML with a + pass_as tag or an array tag. [Fixes #32104] + 2003-10-13 Mike Kestner * gnome/Gnome.metadata : new xpath metadata rules diff --git a/gdk/Gdk.metadata b/gdk/Gdk.metadata index 5309a4a64..b59917006 100644 --- a/gdk/Gdk.metadata +++ b/gdk/Gdk.metadata @@ -6,6 +6,7 @@ gboolean ref 1 + 1 EventHelper PangoHelper 1 diff --git a/gdk/gdk-api.xml b/gdk/gdk-api.xml index 033fe9e37..b95f989c4 100644 --- a/gdk/gdk-api.xml +++ b/gdk/gdk-api.xml @@ -3612,7 +3612,7 @@ - + diff --git a/generator/CallbackGen.cs b/generator/CallbackGen.cs index 4d7c0a533..1d4916ffe 100644 --- a/generator/CallbackGen.cs +++ b/generator/CallbackGen.cs @@ -104,12 +104,11 @@ 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); int idx = 0; bool need_sep = false; bool need_ref_owned = true; string call_str = ""; + string cleanup_str = ""; for (int i = 0; i < count; i++) { string parm_name = parms[i].Name; @@ -122,22 +121,27 @@ namespace GtkSharp.Generation { continue; string cstype = parms[i].CSType; - // FIXME: Too much code copy/pasted here. Refactor? ClassBase parm_wrapper = table.GetClassGen (ctype); if (need_ref_owned && parm_wrapper != null && ((parm_wrapper is ObjectGen) || (parm_wrapper is InterfaceGen))) { need_ref_owned = false; sw.WriteLine("\t\t\tbool ref_owned = false;"); } - sw.WriteLine("\t\t\t_args[" + idx + "] = " + table.FromNative (ctype, parm_name) + ";"); + sw.Write("\t\t\t" + cstype + " _arg" + idx); + if (parms[i].PassAs == "out") { + sw.WriteLine(";"); + cleanup_str += "\t\t\t" + parm_name + " = " + table.CallByName (ctype, "_arg" + idx) + ";\n"; + } else + sw.WriteLine(" = " + table.FromNative (ctype, parm_name) + ";"); + if ((parm_wrapper != null && ((parm_wrapper is OpaqueGen))) || table.IsManuallyWrapped (ctype)) { - sw.WriteLine("\t\t\tif (_args[" + idx + "] == null)"); - sw.WriteLine("\t\t\t\t_args[{0}] = new {1}({2});", idx, cstype, parm_name); + sw.WriteLine("\t\t\tif (_arg" + idx + " == null)"); + sw.WriteLine("\t\t\t\t_arg{0} = new {1}({2});", idx, cstype, parm_name); } if (need_sep) call_str += ", "; else need_sep = true; - call_str += String.Format ("({0}) _args[{1}]", cstype, idx); + call_str += String.Format ("{0} _arg{1}", parms[i].PassAs, idx); idx++; } @@ -154,9 +158,11 @@ namespace GtkSharp.Generation { sw.WriteLine ("return (int) {0};", invoke); else sw.WriteLine ("return ({0}) {1};", m_ret, table.ToNativeReturn (rettype, invoke)); - } - else + } else sw.WriteLine (invoke + ";"); + + if (cleanup_str != "") + sw.Write (cleanup_str); sw.WriteLine ("\t\t}"); sw.WriteLine (); diff --git a/generator/Parameters.cs b/generator/Parameters.cs index 52aad8600..18e995dd3 100644 --- a/generator/Parameters.cs +++ b/generator/Parameters.cs @@ -119,7 +119,16 @@ namespace GtkSharp.Generation { public string PassAs { get { - return elem.GetAttribute ("pass_as"); + if (elem.HasAttribute ("pass_as")) + return elem.GetAttribute ("pass_as"); + + if (IsArray) + return ""; + + if (Generatable is SimpleGen && !(Generatable is ConstStringGen) && CType.EndsWith ("*") && !CSType.EndsWith ("IntPtr")) + return "out"; + + return ""; } } @@ -283,7 +292,10 @@ namespace GtkSharp.Generation { need_sep = true; } - if (this [i].PassAs != "") { + if (type == "GError**") { + call_string += "out "; + import_sig += "out "; + } else if (this [i].PassAs != "" && !IsVarArgs) { signature += this [i].PassAs + " "; // We only need to do this for value types if (type != "GError**" && m_type != "IntPtr" && m_type != "System.IntPtr") @@ -298,12 +310,8 @@ namespace GtkSharp.Generation { call_parm = this [i].PassAs + " " + call_parm.Replace (".Handle", "_handle"); import_sig += this [i].PassAs + " "; } - - } else if (type == "GError**") { - call_string += "out "; - import_sig += "out "; } - + if (IsVarArgs && i == (Count - 2) && VAType == "length_param") { call_string += this [Count - 1].Name + ".Length"; } else {