2002-06-20 Mike Kestner <mkestner@speakeasy.net>
* generator/Parameters.cs : GError handling overhaul * generator/SymbolTable.cs : map GError to IntPtr * glib/GException.cs : Refactor to use glue. * glue/Makefile.am : add the error.c file. * glue/error.c : glue for error message string access * gtk/makefile.win32 : ref the gdk-imaging-sharp assembly svn path=/trunk/gtk-sharp/; revision=5351
This commit is contained in:
parent
2854aa2e16
commit
dbfe6207a7
7 changed files with 49 additions and 36 deletions
|
@ -1,3 +1,12 @@
|
|||
2002-06-20 Mike Kestner <mkestner@speakeasy.net>
|
||||
|
||||
* generator/Parameters.cs : GError handling overhaul
|
||||
* generator/SymbolTable.cs : map GError to IntPtr
|
||||
* glib/GException.cs : Refactor to use glue.
|
||||
* glue/Makefile.am : add the error.c file.
|
||||
* glue/error.c : glue for error message string access
|
||||
* gtk/makefile.win32 : ref the gdk-imaging-sharp assembly
|
||||
|
||||
2002-06-19 Mike Kestner <mkestner@speakeasy.net>
|
||||
|
||||
* generator/Parameters.cs : csc build error fixes
|
||||
|
|
|
@ -91,10 +91,10 @@ namespace GtkSharp.Generation {
|
|||
signature += p_elem.GetAttribute("pass_as") + " ";
|
||||
}
|
||||
|
||||
if (type == "GError**")
|
||||
call_string += "&";
|
||||
else
|
||||
{
|
||||
if (type == "GError**") {
|
||||
call_string += "out ";
|
||||
import_sig += "out ";
|
||||
} else {
|
||||
signature += (cs_type + " " + name);
|
||||
signature_types += cs_type;
|
||||
}
|
||||
|
@ -127,14 +127,14 @@ namespace GtkSharp.Generation {
|
|||
}
|
||||
|
||||
if (ThrowsException)
|
||||
sw.WriteLine ("\t\t\tGLib.GError* {0} = null;", name);
|
||||
sw.WriteLine ("\t\t\tIntPtr error;");
|
||||
}
|
||||
|
||||
public void HandleException (StreamWriter sw)
|
||||
{
|
||||
if (!ThrowsException)
|
||||
return;
|
||||
sw.WriteLine ("\t\t\tif (error != null) throw new GLib.GException (error);");
|
||||
sw.WriteLine ("\t\t\tif (error != IntPtr.Zero) throw new GLib.GException (error);");
|
||||
}
|
||||
|
||||
public bool IsAccessor {
|
||||
|
@ -160,19 +160,10 @@ namespace GtkSharp.Generation {
|
|||
|
||||
public bool ThrowsException {
|
||||
get {
|
||||
XmlNode last_parm = null;
|
||||
foreach (XmlNode parm in elem.ChildNodes) {
|
||||
if (parm.Name != "parameter") {
|
||||
continue;
|
||||
}
|
||||
|
||||
last_parm = parm;
|
||||
}
|
||||
|
||||
if (last_parm == null)
|
||||
if ((elem.ChildNodes == null) || (elem.ChildNodes.Count < 1))
|
||||
return false;
|
||||
|
||||
XmlElement p_elem = (XmlElement) last_parm;
|
||||
|
||||
XmlElement p_elem = (XmlElement) elem.ChildNodes[elem.ChildNodes.Count - 1];
|
||||
string type = p_elem.GetAttribute("type");
|
||||
return (type == "GError**");
|
||||
}
|
||||
|
|
|
@ -52,7 +52,7 @@ namespace GtkSharp.Generation {
|
|||
simple_types.Add ("uint1", "bool");
|
||||
simple_types.Add ("GPtrArray", "System.IntPtr[]");
|
||||
simple_types.Add ("GType", "int");
|
||||
simple_types.Add ("GError", "GLib.GError**");
|
||||
simple_types.Add ("GError", "IntPtr");
|
||||
|
||||
// FIXME: These ought to be handled properly.
|
||||
simple_types.Add ("GList", "System.IntPtr");
|
||||
|
|
|
@ -9,31 +9,28 @@ namespace GLib {
|
|||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public unsafe struct GError
|
||||
public class GException : Exception
|
||||
{
|
||||
[MarshalAs (UnmanagedType.U4)]
|
||||
public uint domain;
|
||||
[MarshalAs (UnmanagedType.I4)]
|
||||
public int code;
|
||||
[MarshalAs (UnmanagedType.LPStr)]
|
||||
public string message;
|
||||
}
|
||||
|
||||
public unsafe class GException : Exception
|
||||
{
|
||||
GError *errptr;
|
||||
IntPtr errptr;
|
||||
|
||||
unsafe public GException (GError *errptr) : base (errptr->message)
|
||||
public GException (IntPtr errptr) : base ()
|
||||
{
|
||||
this.errptr = errptr;
|
||||
}
|
||||
|
||||
[DllImport("gtksharpglue")]
|
||||
static extern string gtksharp_error_get_message (IntPtr errptr);
|
||||
public override string Message {
|
||||
get {
|
||||
return gtksharp_error_get_message (errptr);
|
||||
}
|
||||
}
|
||||
|
||||
[DllImport("glib-2.0")]
|
||||
unsafe static extern void g_clear_error (GError **errptr);
|
||||
static extern void g_clear_error (IntPtr errptr);
|
||||
~GException ()
|
||||
{
|
||||
unsafe { g_clear_error (&errptr); }
|
||||
g_clear_error (errptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ INCLUDES = $(GTK_CFLAGS) -I$(top_srcdir)
|
|||
libgtksharpglue_la_SOURCES = \
|
||||
value.c \
|
||||
textiter.c \
|
||||
error.c \
|
||||
#
|
||||
|
||||
libgtksharpglue.dll: $(libgtksharpglue_la_OBJECTS) libgtksharpglue.rc libgtksharpglue.def
|
||||
|
|
15
glue/error.c
Executable file
15
glue/error.c
Executable file
|
@ -0,0 +1,15 @@
|
|||
/* error.c : Glue to access GError values.
|
||||
*
|
||||
* Author: Mike Kestner <mkestner@speakeasy.net>
|
||||
*
|
||||
* <c> 2002 Mike Kestner
|
||||
*/
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
gchar *
|
||||
gtksharp_error_get_message (GError *err)
|
||||
{
|
||||
return err->message;
|
||||
}
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
all: windows
|
||||
|
||||
windows:
|
||||
$(CSC) /unsafe /target:library /r:../glib/glib-sharp.dll /r:../pango/pango-sharp.dll /r:../atk/atk-sharp.dll /r:../gdk/gdk-sharp.dll /out:gtk-sharp.dll /recurse:*.cs
|
||||
$(CSC) /unsafe /target:library /r:../glib/glib-sharp.dll /r:../pango/pango-sharp.dll /r:../atk/atk-sharp.dll /r:../gdk/gdk-sharp.dll /r:../gdk.imaging/gdk-imaging-sharp.dll /out:gtk-sharp.dll /recurse:*.cs
|
||||
|
||||
|
|
Loading…
Reference in a new issue