2008-03-21 Mike Kestner <mkestner@novell.com>

* 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.

svn path=/trunk/gtk-sharp/; revision=98782
This commit is contained in:
Mike Kestner 2008-03-22 01:30:42 +00:00
parent c030d70107
commit de56504f8b
8 changed files with 54 additions and 12 deletions

View File

@ -1,3 +1,18 @@
2008-03-21 Mike Kestner <mkestner@novell.com>
* 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 <mkestner@novell.com>
* gtk/Gtk.metadata: s/GtkDestroyNotify/GDestroyNotify in vms too.

View File

@ -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

View File

@ -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 {");

View File

@ -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")

View File

@ -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;

View File

@ -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) ||

View File

@ -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**")

View File

@ -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") + ");");