2002-08-06 Rachel Hestilow <hestilow@ximian.com>

* generator/SignalHandler.cs: Handle null arguments and return values.

	* sample/Makefile.in: Add fifteen game.

svn path=/trunk/gtk-sharp/; revision=6483
This commit is contained in:
Rachel Hestilow 2002-08-06 21:56:57 +00:00
parent 4750a00588
commit 0bf76f0d61
3 changed files with 35 additions and 12 deletions

View file

@ -1,3 +1,9 @@
2002-08-06 Rachel Hestilow <hestilow@ximian.com>
* generator/SignalHandler.cs: Handle null arguments and return values.
* sample/Makefile.in: Add fifteen game.
2002-08-06 Gonzalo Paniagua Javier <gonzalo@ximian.com>
* sample/GnomeHelloWorld.cs: use DeleteEventHandler.

View file

@ -145,20 +145,28 @@ namespace GtkSharp.Generation {
sw.WriteLine("\t\t\targs.Args = new object[" + (parms.Count-1) + "];");
}
for (int idx=1; idx < parms.Count; idx++) {
if (SymbolTable.IsObject((String)parms[idx])) {
sw.Write("\t\t\targs.Args[" + (idx-1) + "] ");
sw.WriteLine("= GLib.Object.GetObject(arg" + idx + ");");
string ctype = (string) parms[idx];
/* ok, this should do the "create a new wrapper" thing for
* objects as well, but because the signature only
* specifies GObject, we can't. So wait for introspection */
ClassBase wrapper = SymbolTable.GetClassGen (ctype);
if ((wrapper != null && !(wrapper is StructBase)) || SymbolTable.IsManuallyWrapped (ctype)) {
sw.WriteLine("\t\t\tif (arg{0} == IntPtr.Zero)", idx);
sw.WriteLine("\t\t\t\targs.Args[{0}] = null;", idx - 1);
sw.WriteLine("\t\t\telse {");
if (wrapper != null && wrapper is ObjectGen)
sw.WriteLine("\t\t\t\targs.Args[" + (idx-1) + "] = GLib.Object.GetObject(arg" + idx + ");");
else
sw.WriteLine("\t\t\t\targs.Args[" + (idx-1) + "] = " + SymbolTable.FromNative (ctype, "arg" + idx) + ";");
if ((wrapper != null && (wrapper is OpaqueGen)) || SymbolTable.IsManuallyWrapped (ctype)) {
sw.WriteLine("\t\t\t\tif (args.Args[" + (idx-1) + "] == null)");
sw.WriteLine("\t\t\t\t\targs.Args[{0}] = new {1}(arg{2});", idx-1, SymbolTable.GetCSType (ctype), idx);
}
sw.WriteLine("\t\t\t}");
} else {
string ctype = (string) parms[idx];
ClassBase wrapper = SymbolTable.GetClassGen (ctype);
if (wrapper != null && (wrapper is StructBase)) {
if (wrapper != null && (wrapper is StructBase))
sw.WriteLine("\t\t\targ{0}._Initialize ();", idx);
}
sw.WriteLine("\t\t\targs.Args[" + (idx-1) + "] = " + SymbolTable.FromNative (ctype, "arg" + idx) + ";");
if ((wrapper != null && ((wrapper is ObjectGen) || (wrapper is OpaqueGen))) || SymbolTable.IsManuallyWrapped (ctype)) {
sw.WriteLine("\t\t\tif (args.Args[" + (idx-1) + "] == null)");
sw.WriteLine("\t\t\t\targs.Args[{0}] = new {1}(arg{2});", idx-1, SymbolTable.GetCSType (ctype), idx);
}
}
}
sw.WriteLine("\t\t\tobject[] argv = new object[2];");
@ -166,6 +174,12 @@ namespace GtkSharp.Generation {
sw.WriteLine("\t\t\targv[1] = args;");
sw.WriteLine("\t\t\tinst._handler.DynamicInvoke(argv);");
if (retval != "void") {
sw.WriteLine ("\t\t\tif (args.RetVal == null)");
if (s_ret == "bool")
sw.WriteLine ("\t\t\t\treturn false;");
else
sw.WriteLine ("\t\t\t\tthrow new Exception(\"args.RetVal unset in callback\");");
sw.WriteLine("\t\t\treturn (" + s_ret + ") args.RetVal;");
}
sw.WriteLine("\t\t}");

View file

@ -2,7 +2,7 @@ MCS=mcs
@ENABLE_GNOME_TRUE@ GNOME_PATH=-L ../gnome
@ENABLE_GNOME_TRUE@ GNOME_ASSEMBLY=-r gnome-sharp.dll
@ENABLE_GNOME_TRUE@ GNOME_TARGETS=gnome-hello-world.exe canvas-example.exe
@ENABLE_GNOME_TRUE@ GNOME_TARGETS=gnome-hello-world.exe canvas-example.exe fifteen.exe
local_paths=-L ../glib -L ../pango -L ../atk -L ../gdk -L ../gtk $(GNOME_PATH)
all_assemblies=-r glib-sharp.dll -r pango-sharp.dll -r atk-sharp.dll -r gdk-sharp.dll -r gtk-sharp.dll $(GNOME_ASSEMBLY) -r System.Drawing
@ -25,6 +25,9 @@ gnome-hello-world.exe: GnomeHelloWorld.cs
canvas-example.exe: CanvasExample.cs
$(MCS) --unsafe -o canvas-example.exe $(local_paths) $(all_assemblies) CanvasExample.cs
fifteen.exe: Fifteen.cs
$(MCS) --unsafe -o fifteen.exe $(local_paths) $(all_assemblies) Fifteen.cs
button.exe: ButtonApp.cs
$(MCS) --unsafe -o button.exe $(local_paths) $(all_assemblies) ButtonApp.cs