2008-12-22 Andrés G. Aragoneses <aaragoneses@novell.com>

* glib/GType.cs: simplify, avoiding a static method.  
        * generator/InterfaceGen.cs: track API.
        * glib/Value.cs: reuse g_type_is_a.
        [Improves fix for #448009 in r121990]


svn path=/trunk/gtk-sharp/; revision=121991
This commit is contained in:
Andrés G. Aragoneses 2008-12-22 17:16:03 +00:00
parent 8191911b26
commit a8b28619be
4 changed files with 19 additions and 15 deletions

View File

@ -1,3 +1,10 @@
2008-12-22 Andrés G. Aragoneses <aaragoneses@novell.com>
* generator/InterfaceGen.cs: track API.
* glib/GType.cs: simplify, avoiding a static method.
* glib/Value.cs: reuse g_type_is_a.
[Improves fix for #448009 in r121990]
2008-12-22 Andrés G. Aragoneses <aaragoneses@novell.com>
* generator/InterfaceGen.cs: use the new GLib API to detect

View File

@ -177,7 +177,7 @@ namespace GtkSharp.Generation {
sw.WriteLine ();
sw.WriteLine ("\t\tpublic " + Name + "Adapter (IntPtr handle)");
sw.WriteLine ("\t\t{");
sw.WriteLine ("\t\t\tif (!GLib.GType.IsInstance (handle, _gtype))");
sw.WriteLine ("\t\t\tif (!_gtype.IsInstance (handle))");
sw.WriteLine ("\t\t\t\tthrow new ArgumentException (\"The gobject doesn't implement the GInterface of this adapter\", \"handle\");");
sw.WriteLine ("\t\t\tthis.handle = handle;");
sw.WriteLine ("\t\t}");

View File

@ -339,9 +339,9 @@ namespace GLib {
return g_type_is_a (type, is_a_type.Val);
}
public static bool IsInstance (IntPtr raw, GType type)
public bool IsInstance (IntPtr raw)
{
return GType.Is (ValFromInstancePtr (raw), type);
return GType.Is (ValFromInstancePtr (raw), this);
}
[DllImport("libgobject-2.0-0.dll")]

View File

@ -351,8 +351,8 @@ namespace GLib {
return (long) this;
else if (type == GType.UInt64.Val)
return (ulong) this;
else if (g_type_is_a (type, GType.Enum.Val) ||
g_type_is_a (type, GType.Flags.Val))
else if (GType.Is (type, GType.Enum) ||
GType.Is (type, GType.Flags))
return (Enum) this;
else if (type == GType.Float.Val)
return (float) this;
@ -366,9 +366,9 @@ namespace GLib {
return g_value_get_param (ref this);
else if (type == ManagedValue.GType.Val)
return ManagedValue.ObjectForWrapper (g_value_get_boxed (ref this));
else if (g_type_is_a (type, GType.Object.Val))
else if (GType.Is (type, GType.Object))
return (GLib.Object) this;
else if (g_type_is_a (type, GType.Boxed.Val))
else if (GType.Is (type, GType.Boxed))
return ToBoxed ();
else if (type == IntPtr.Zero)
return null;
@ -390,9 +390,9 @@ namespace GLib {
g_value_set_int64 (ref this, (long) value);
else if (type == GType.UInt64.Val)
g_value_set_uint64 (ref this, (ulong) value);
else if (g_type_is_a (type, GType.Enum.Val))
else if (GType.Is (type, GType.Enum))
g_value_set_enum (ref this, (int)value);
else if (g_type_is_a (type, GType.Flags.Val))
else if (GType.Is (type, GType.Flags))
g_value_set_flags (ref this, (uint)(int)value);
else if (type == GType.Float.Val)
g_value_set_float (ref this, (float) value);
@ -419,12 +419,12 @@ namespace GLib {
IntPtr wrapper = ManagedValue.WrapObject (value);
g_value_set_boxed (ref this, wrapper);
ManagedValue.ReleaseWrapper (wrapper);
} else if (g_type_is_a (type, GType.Object.Val))
} else if (GType.Is (type, GType.Object))
if(value is GLib.Object)
g_value_set_object (ref this, (value as GLib.Object).Handle);
else
g_value_set_object (ref this, (value as GLib.GInterfaceAdapter).Handle);
else if (g_type_is_a (type, GType.Boxed.Val)) {
else if (GType.Is (type, GType.Boxed)) {
if (value is IWrapper) {
g_value_set_boxed (ref this, ((IWrapper)value).Handle);
return;
@ -439,7 +439,7 @@ namespace GLib {
internal void Update (object val)
{
if (g_type_is_a (type, GType.Boxed.Val) && !(val is IWrapper))
if (GType.Is (type, GType.Boxed) && !(val is IWrapper))
Marshal.StructureToPtr (val, g_value_get_boxed (ref this), false);
}
@ -567,9 +567,6 @@ namespace GLib {
[DllImport("libgobject-2.0-0.dll")]
static extern uint g_value_get_flags (ref Value val);
[DllImport("libgobject-2.0-0.dll")]
static extern bool g_type_is_a (IntPtr type, IntPtr is_a_type);
[DllImport("libgobject-2.0-0.dll")]
static extern IntPtr g_strv_get_type ();
}