2002-06-24 Rachel Hestilow <hestilow@ximian.com>
* glib/UnwrappedObject.cs: New class which holds an IntPtr. This is used in Value so that we can retrieve the IntPtr itself for an object property. * glib/Value.cs: Add UnwrappedObject cast operator. * glib/Property.cs: If the retrieved value is an object, and there is no wrapper object, create a new one. svn path=/trunk/gtk-sharp/; revision=5440
This commit is contained in:
parent
594457e5ec
commit
414a14d93e
7 changed files with 73 additions and 6 deletions
11
ChangeLog
11
ChangeLog
|
@ -1,3 +1,14 @@
|
||||||
|
2002-06-24 Rachel Hestilow <hestilow@ximian.com>
|
||||||
|
|
||||||
|
* glib/UnwrappedObject.cs: New class which holds an IntPtr.
|
||||||
|
This is used in Value so that we can retrieve the IntPtr itself
|
||||||
|
for an object property.
|
||||||
|
|
||||||
|
* glib/Value.cs: Add UnwrappedObject cast operator.
|
||||||
|
|
||||||
|
* glib/Property.cs: If the retrieved value is an object,
|
||||||
|
and there is no wrapper object, create a new one.
|
||||||
|
|
||||||
2002-06-24 Rachel Hestilow <hestilow@ximian.com>
|
2002-06-24 Rachel Hestilow <hestilow@ximian.com>
|
||||||
|
|
||||||
* gtk/FileSelection.custom: Remove random cruft that was
|
* gtk/FileSelection.custom: Remove random cruft that was
|
||||||
|
|
|
@ -81,6 +81,7 @@ pango/Makefile
|
||||||
atk/Makefile
|
atk/Makefile
|
||||||
gdk/Makefile
|
gdk/Makefile
|
||||||
gtk/Makefile
|
gtk/Makefile
|
||||||
|
gnome/Makefile
|
||||||
sample/Makefile
|
sample/Makefile
|
||||||
])
|
])
|
||||||
|
|
||||||
|
|
|
@ -81,11 +81,22 @@ namespace GtkSharp.Generation {
|
||||||
sw.WriteLine("\t\t\tget {");
|
sw.WriteLine("\t\t\tget {");
|
||||||
sw.WriteLine("\t\t\t\tGLib.Value val = new GLib.Value (Handle, " + cname + ");");
|
sw.WriteLine("\t\t\t\tGLib.Value val = new GLib.Value (Handle, " + cname + ");");
|
||||||
sw.WriteLine("\t\t\t\tGetProperty(" + cname + ", val);");
|
sw.WriteLine("\t\t\t\tGetProperty(" + cname + ", val);");
|
||||||
sw.Write("\t\t\t\treturn (" + cs_type + ") ");
|
if (SymbolTable.IsObject (c_type))
|
||||||
if (v_type != "") {
|
{
|
||||||
sw.Write(v_type + " ");
|
sw.WriteLine("\t\t\t\tSystem.IntPtr raw_ret = (System.IntPtr) (GLib.UnwrappedObject) val;");
|
||||||
|
sw.WriteLine("\t\t\t\t" + cs_type + " ret = " + SymbolTable.FromNative(c_type, "raw_ret") + ";");
|
||||||
|
sw.WriteLine("\t\t\t\tif (ret == null) ret = new " + cs_type + "(raw_ret);");
|
||||||
}
|
}
|
||||||
sw.WriteLine("val;");
|
else {
|
||||||
|
sw.Write("\t\t\t\t" + cs_type + " ret = ");
|
||||||
|
sw.Write ("(" + cs_type + ") ");
|
||||||
|
if (v_type != "") {
|
||||||
|
sw.Write(v_type + " ");
|
||||||
|
}
|
||||||
|
sw.WriteLine("val;");
|
||||||
|
}
|
||||||
|
|
||||||
|
sw.WriteLine("\t\t\t\treturn ret;");
|
||||||
sw.WriteLine("\t\t\t}");
|
sw.WriteLine("\t\t\t}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
26
glib/UnwrappedObject.cs
Normal file
26
glib/UnwrappedObject.cs
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
// UnwrappedObject.cs - Class which holds an IntPtr without resolving it:
|
||||||
|
//
|
||||||
|
// Author: Rachel Hestilow <hestilow@ximian.com>
|
||||||
|
//
|
||||||
|
// (c) 2002 Rachel Hestilow
|
||||||
|
|
||||||
|
namespace GLib {
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
// <summary> Unwrapped object class </summary>
|
||||||
|
// <remarks> </remarks>
|
||||||
|
public class UnwrappedObject {
|
||||||
|
IntPtr obj;
|
||||||
|
|
||||||
|
public UnwrappedObject (IntPtr obj) {
|
||||||
|
this.obj = obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static explicit operator System.IntPtr (UnwrappedObject obj) {
|
||||||
|
return obj.obj;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -357,6 +357,24 @@ namespace GLib {
|
||||||
return GLib.Object.GetObject(g_value_get_object (val._val));
|
return GLib.Object.GetObject(g_value_get_object (val._val));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Value to Unresolved Object Conversion
|
||||||
|
/// </summary>
|
||||||
|
///
|
||||||
|
/// <remarks>
|
||||||
|
/// Extracts an object from a Value without looking up its wrapping
|
||||||
|
/// class.
|
||||||
|
/// Note, this method will produce an exception if the Value does
|
||||||
|
/// not hold a object value.
|
||||||
|
/// </remarks>
|
||||||
|
|
||||||
|
public static explicit operator GLib.UnwrappedObject (Value val)
|
||||||
|
{
|
||||||
|
// FIXME: Insert an appropriate exception here if
|
||||||
|
// _val.type indicates an error.
|
||||||
|
return new UnwrappedObject(g_value_get_object (val._val));
|
||||||
|
}
|
||||||
|
|
||||||
[DllImport("gobject-2.0")]
|
[DllImport("gobject-2.0")]
|
||||||
static extern IntPtr g_value_get_pointer (IntPtr val);
|
static extern IntPtr g_value_get_pointer (IntPtr val);
|
||||||
|
|
||||||
|
|
2
makefile
2
makefile
|
@ -1,4 +1,4 @@
|
||||||
DIRS=generator glib pango atk gdk gtk sample
|
DIRS=generator glib pango atk gdk gtk gnome sample
|
||||||
ROOT=/cygdrive/$(subst \,/,$(subst :\,/,$(SYSTEMROOT)))
|
ROOT=/cygdrive/$(subst \,/,$(subst :\,/,$(SYSTEMROOT)))
|
||||||
CSC=$(ROOT)/microsoft.net/framework/v1.0.3705/csc.exe
|
CSC=$(ROOT)/microsoft.net/framework/v1.0.3705/csc.exe
|
||||||
MCS=mcs
|
MCS=mcs
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
DIRS=generator glib pango atk gdk gtk sample
|
DIRS=generator glib pango atk gdk gtk gnome sample
|
||||||
ROOT=/cygdrive/$(subst \,/,$(subst :\,/,$(SYSTEMROOT)))
|
ROOT=/cygdrive/$(subst \,/,$(subst :\,/,$(SYSTEMROOT)))
|
||||||
CSC=$(ROOT)/microsoft.net/framework/v1.0.3705/csc.exe
|
CSC=$(ROOT)/microsoft.net/framework/v1.0.3705/csc.exe
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue