diff --git a/ChangeLog b/ChangeLog index f0fd4d925..02db63f16 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +2008-03-21 Mike Kestner + + * bootstrap-2.12: bump svn version + * generator/CallbackGen.cs: add dnotify support to invoker. + Store and respond with incoming UserData params. Start using + __prefixed private vars to avoid collisions with parameters, + like the 'result' params in gio. + * generator/ManagedCallString.cs: use new data/dnotify invoker + ctors. + * generator/MethodBody.cs: + * generator/Parameters.cs: don't link "out" length params to + preceding strings. + * generator/VMSignature.cs: don't require UserData to be last + param, since it can have things like error after it. + 2008-03-21 Mike Kestner * gtk/Gtk.metadata: s/GtkDestroyNotify/GDestroyNotify in vms too. diff --git a/bootstrap-2.12 b/bootstrap-2.12 index 2e3599cdc..7b35f4471 100755 --- a/bootstrap-2.12 +++ b/bootstrap-2.12 @@ -1,7 +1,7 @@ #!/bin/sh # Run this to set configure.in up for an API version. -GTK_SHARP_VERSION=2.12.0 +GTK_SHARP_VERSION=2.12.1 ASSEMBLY_VERSION=2.12.0.0 POLICY_VERSIONS="2.4 2.6 2.8 2.10" GTK_REQUIRED_VERSION=2.12.0 diff --git a/generator/CallbackGen.cs b/generator/CallbackGen.cs index f7fde7216..17b492e23 100644 --- a/generator/CallbackGen.cs +++ b/generator/CallbackGen.cs @@ -122,7 +122,7 @@ namespace GtkSharp.Generation { p.CallName = p.Name; result [i] = p.CallString; if (p.IsUserData) - result [i] = "IntPtr.Zero"; + result [i] = "__data"; } return String.Join (", ", result); @@ -139,10 +139,25 @@ namespace GtkSharp.Generation { sw.WriteLine ("\tinternal class " + Name + "Invoker {"); sw.WriteLine (); sw.WriteLine ("\t\t" + Name + "Native native_cb;"); + sw.WriteLine ("\t\tIntPtr __data;"); + sw.WriteLine ("\t\tGLib.DestroyNotify __notify;"); sw.WriteLine (); - sw.WriteLine ("\t\tinternal " + Name + "Invoker (" + Name + "Native native_cb)"); + sw.WriteLine ("\t\t~" + Name + "Invoker ()"); + sw.WriteLine ("\t\t{"); + sw.WriteLine ("\t\t\tif (__notify == null)"); + sw.WriteLine ("\t\t\t\treturn;"); + sw.WriteLine ("\t\t\t__notify (__data);"); + sw.WriteLine ("\t\t}"); + sw.WriteLine (); + sw.WriteLine ("\t\tinternal " + Name + "Invoker (" + Name + "Native native_cb) : this (native_cb, IntPtr.Zero, null) {}"); + sw.WriteLine (); + sw.WriteLine ("\t\tinternal " + Name + "Invoker (" + Name + "Native native_cb, IntPtr data) : this (native_cb, data, null) {}"); + sw.WriteLine (); + sw.WriteLine ("\t\tinternal " + Name + "Invoker (" + Name + "Native native_cb, IntPtr data, GLib.DestroyNotify notify)"); sw.WriteLine ("\t\t{"); sw.WriteLine ("\t\t\tthis.native_cb = native_cb;"); + sw.WriteLine ("\t\t\t__data = data;"); + sw.WriteLine ("\t\t\t__notify = notify;"); sw.WriteLine ("\t\t}"); sw.WriteLine (); sw.WriteLine ("\t\tinternal " + QualifiedName + " Handler {"); diff --git a/generator/ManagedCallString.cs b/generator/ManagedCallString.cs index fdd07a063..57bccdebf 100644 --- a/generator/ManagedCallString.cs +++ b/generator/ManagedCallString.cs @@ -30,6 +30,8 @@ namespace GtkSharp.Generation { ArrayList parms = new ArrayList (); ArrayList special = new ArrayList (); string error_param = null; + string user_data_param = null; + string destroy_param = null; public ManagedCallString (Parameters parms) { @@ -37,10 +39,14 @@ namespace GtkSharp.Generation { Parameter p = parms [i]; if (p.IsLength && parms [i-1].IsString) continue; - else if (p.Scope == "notified") + else if (p.Scope == "notified") { + user_data_param = parms[i+1].Name; + destroy_param = parms[i+2].Name; i += 2; - - else if (p is ErrorParameter) { + } else if (p.IsUserData && parms [i-1].Generatable is CallbackGen) { + user_data_param = p.Name; + continue; + } else if (p is ErrorParameter) { error_param = p.Name; continue; } @@ -70,7 +76,12 @@ namespace GtkSharp.Generation { IGeneratable igen = p.Generatable; if (igen is CallbackGen) { - ret += indent + String.Format ("{0} {1}_invoker = new {0} ({1});\n", (igen as CallbackGen).InvokerName, p.Name); + if (user_data_param == null) + ret += indent + String.Format ("{0} {1}_invoker = new {0} ({1});\n", (igen as CallbackGen).InvokerName, p.Name); + else if (destroy_param == null) + ret += indent + String.Format ("{0} {1}_invoker = new {0} ({1}, {2});\n", (igen as CallbackGen).InvokerName, p.Name, user_data_param); + else + ret += indent + String.Format ("{0} {1}_invoker = new {0} ({1}, {2}, {3});\n", (igen as CallbackGen).InvokerName, p.Name, user_data_param, destroy_param); } else { ret += indent + igen.QualifiedName + " my" + p.Name; if (p.PassAs == "ref") diff --git a/generator/MethodBody.cs b/generator/MethodBody.cs index 68d969162..d4dbde087 100644 --- a/generator/MethodBody.cs +++ b/generator/MethodBody.cs @@ -52,7 +52,7 @@ namespace GtkSharp.Generation { bool is_prop = is_set && i == 0; - if (i > 0 && parameters [i - 1].IsString && p.IsLength) { + if (i > 0 && parameters [i - 1].IsString && p.IsLength && p.PassAs == String.Empty) { string string_name = (i == 1 && is_set) ? "value" : parameters [i - 1].Name; result[i] = igen.CallByName (CastFromInt (p.CSType) + "System.Text.Encoding.UTF8.GetByteCount (" + string_name + ")"); continue; diff --git a/generator/Parameters.cs b/generator/Parameters.cs index 9186b8f72..e9f894d26 100644 --- a/generator/Parameters.cs +++ b/generator/Parameters.cs @@ -541,7 +541,7 @@ namespace GtkSharp.Generation { { int idx = param_list.IndexOf (p); - if (idx > 0 && p.IsLength && this [idx - 1].IsString) + if (idx > 0 && p.IsLength && p.PassAs == String.Empty && this [idx - 1].IsString) return true; if (p.IsCount && ((idx > 0 && this [idx - 1].IsArray) || diff --git a/generator/VMSignature.cs b/generator/VMSignature.cs index 3f2b70145..fe0ebf165 100644 --- a/generator/VMSignature.cs +++ b/generator/VMSignature.cs @@ -42,7 +42,7 @@ namespace GtkSharp.Generation { continue; has_cb = has_cb || p.Generatable is CallbackGen; - if (p.IsUserData && has_cb && (i == parms.Count - 1)) + if (p.IsUserData && has_cb) continue; if (p.CType == "GError**") diff --git a/generator/VirtualMethod.cs b/generator/VirtualMethod.cs index 217f80100..23aa27937 100644 --- a/generator/VirtualMethod.cs +++ b/generator/VirtualMethod.cs @@ -38,6 +38,7 @@ namespace GtkSharp.Generation { this.elem = elem; retval = new ReturnValue (elem ["return-type"]); parms = new Parameters (elem["parameters"]); + parms.HideData = true; } public bool IsGetter { @@ -96,11 +97,11 @@ namespace GtkSharp.Generation { } else sw.WriteLine ("\t\t\t\t" + call_string + ";"); } else - sw.WriteLine ("\t\t\t\t" + retval.ToNativeType + " result = " + retval.ToNative (call_string) + ";"); + sw.WriteLine ("\t\t\t\t" + retval.ToNativeType + " __result = " + retval.ToNative (call_string) + ";"); bool fatal = parms.HasOutParam || !retval.IsVoid; sw.Write (call.Finish ("\t\t\t\t")); if (!retval.IsVoid) - sw.WriteLine ("\t\t\t\treturn result;"); + sw.WriteLine ("\t\t\t\treturn __result;"); sw.WriteLine ("\t\t\t} catch (Exception e) {"); sw.WriteLine ("\t\t\t\tGLib.ExceptionManager.RaiseUnhandledException (e, " + (fatal ? "true" : "false") + ");");