2009-09-23 Mike Kestner <mkestner@novell.com>
* glib/Value.cs: support long and ulong gtypes. still can't construct generically, but can cast to long/ulong and access via Val prop. [Fixes #539812] svn path=/trunk/gtk-sharp/; revision=142588
This commit is contained in:
parent
c5c48dfd1c
commit
5de50e936f
2 changed files with 102 additions and 2 deletions
|
@ -1,3 +1,9 @@
|
||||||
|
2009-09-23 Mike Kestner <mkestner@novell.com>
|
||||||
|
|
||||||
|
* glib/Value.cs: support long and ulong gtypes. still can't construct
|
||||||
|
generically, but can cast to long/ulong and access via Val prop.
|
||||||
|
[Fixes #539812]
|
||||||
|
|
||||||
2009-09-23 Mike Kestner <mkestner@novell.com>
|
2009-09-23 Mike Kestner <mkestner@novell.com>
|
||||||
|
|
||||||
* generator/ReturnValue.cs: support metadata override of default return
|
* generator/ReturnValue.cs: support metadata override of default return
|
||||||
|
|
|
@ -261,11 +261,17 @@ namespace GLib {
|
||||||
|
|
||||||
public static explicit operator long (Value val)
|
public static explicit operator long (Value val)
|
||||||
{
|
{
|
||||||
|
if (val.type == GType.Long.Val)
|
||||||
|
return val.GetLongForPlatform ();
|
||||||
|
else
|
||||||
return g_value_get_int64 (ref val);
|
return g_value_get_int64 (ref val);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static explicit operator ulong (Value val)
|
public static explicit operator ulong (Value val)
|
||||||
{
|
{
|
||||||
|
if (val.type == GType.ULong.Val)
|
||||||
|
return val.GetULongForPlatform ();
|
||||||
|
else
|
||||||
return g_value_get_uint64 (ref val);
|
return g_value_get_uint64 (ref val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -393,6 +399,62 @@ namespace GLib {
|
||||||
this = (GLib.Value) parameters[0];
|
this = (GLib.Value) parameters[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
long GetLongForPlatform ()
|
||||||
|
{
|
||||||
|
switch (Environment.OSVersion.Platform) {
|
||||||
|
case PlatformID.Win32NT:
|
||||||
|
case PlatformID.Win32S:
|
||||||
|
case PlatformID.Win32Windows:
|
||||||
|
case PlatformID.WinCE:
|
||||||
|
return (long) g_value_get_long_as_int (ref this);
|
||||||
|
default:
|
||||||
|
return g_value_get_long (ref this).ToInt64 ();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ulong GetULongForPlatform ()
|
||||||
|
{
|
||||||
|
switch (Environment.OSVersion.Platform) {
|
||||||
|
case PlatformID.Win32NT:
|
||||||
|
case PlatformID.Win32S:
|
||||||
|
case PlatformID.Win32Windows:
|
||||||
|
case PlatformID.WinCE:
|
||||||
|
return (ulong) g_value_get_ulong_as_uint (ref this);
|
||||||
|
default:
|
||||||
|
return g_value_get_ulong (ref this).ToUInt64 ();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetLongForPlatform (long val)
|
||||||
|
{
|
||||||
|
switch (Environment.OSVersion.Platform) {
|
||||||
|
case PlatformID.Win32NT:
|
||||||
|
case PlatformID.Win32S:
|
||||||
|
case PlatformID.Win32Windows:
|
||||||
|
case PlatformID.WinCE:
|
||||||
|
g_value_set_long (ref this, (int) val);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
g_value_set_long (ref this, new IntPtr (val));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetULongForPlatform (ulong val)
|
||||||
|
{
|
||||||
|
switch (Environment.OSVersion.Platform) {
|
||||||
|
case PlatformID.Win32NT:
|
||||||
|
case PlatformID.Win32S:
|
||||||
|
case PlatformID.Win32Windows:
|
||||||
|
case PlatformID.WinCE:
|
||||||
|
g_value_set_ulong (ref this, (uint) val);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
g_value_set_ulong (ref this, new UIntPtr (val));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
object ToEnum ()
|
object ToEnum ()
|
||||||
{
|
{
|
||||||
Type t = GType.LookupType (type);
|
Type t = GType.LookupType (type);
|
||||||
|
@ -438,8 +500,12 @@ namespace GLib {
|
||||||
return (uint) this;
|
return (uint) this;
|
||||||
else if (type == GType.Int64.Val)
|
else if (type == GType.Int64.Val)
|
||||||
return (long) this;
|
return (long) this;
|
||||||
|
else if (type == GType.Long.Val)
|
||||||
|
return GetLongForPlatform ();
|
||||||
else if (type == GType.UInt64.Val)
|
else if (type == GType.UInt64.Val)
|
||||||
return (ulong) this;
|
return (ulong) this;
|
||||||
|
else if (type == GType.ULong.Val)
|
||||||
|
return GetULongForPlatform ();
|
||||||
else if (GType.Is (type, GType.Enum) ||
|
else if (GType.Is (type, GType.Enum) ||
|
||||||
GType.Is (type, GType.Flags))
|
GType.Is (type, GType.Flags))
|
||||||
return ToEnum ();
|
return ToEnum ();
|
||||||
|
@ -481,8 +547,12 @@ namespace GLib {
|
||||||
g_value_set_uint (ref this, (uint) value);
|
g_value_set_uint (ref this, (uint) value);
|
||||||
else if (type == GType.Int64.Val)
|
else if (type == GType.Int64.Val)
|
||||||
g_value_set_int64 (ref this, (long) value);
|
g_value_set_int64 (ref this, (long) value);
|
||||||
|
else if (type == GType.Long.Val)
|
||||||
|
SetLongForPlatform ((long) value);
|
||||||
else if (type == GType.UInt64.Val)
|
else if (type == GType.UInt64.Val)
|
||||||
g_value_set_uint64 (ref this, (ulong) value);
|
g_value_set_uint64 (ref this, (ulong) value);
|
||||||
|
else if (type == GType.ULong.Val)
|
||||||
|
SetULongForPlatform ((ulong) value);
|
||||||
else if (GType.Is (type, GType.Enum))
|
else if (GType.Is (type, GType.Enum))
|
||||||
g_value_set_enum (ref this, (int)value);
|
g_value_set_enum (ref this, (int)value);
|
||||||
else if (GType.Is (type, GType.Flags))
|
else if (GType.Is (type, GType.Flags))
|
||||||
|
@ -599,6 +669,12 @@ namespace GLib {
|
||||||
[DllImport ("libgobject-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
[DllImport ("libgobject-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||||
static extern void g_value_set_int64 (ref Value val, long data);
|
static extern void g_value_set_int64 (ref Value val, long data);
|
||||||
|
|
||||||
|
[DllImport ("libgobject-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||||
|
static extern void g_value_set_long (ref Value val, IntPtr data);
|
||||||
|
|
||||||
|
[DllImport ("libgobject-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||||
|
static extern void g_value_set_long (ref Value val, int data);
|
||||||
|
|
||||||
[DllImport ("libgobject-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
[DllImport ("libgobject-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||||
static extern void g_value_set_uint64 (ref Value val, ulong data);
|
static extern void g_value_set_uint64 (ref Value val, ulong data);
|
||||||
|
|
||||||
|
@ -617,6 +693,12 @@ namespace GLib {
|
||||||
[DllImport ("libgobject-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
[DllImport ("libgobject-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||||
static extern void g_value_set_uint (ref Value val, uint data);
|
static extern void g_value_set_uint (ref Value val, uint data);
|
||||||
|
|
||||||
|
[DllImport ("libgobject-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||||
|
static extern void g_value_set_ulong (ref Value val, UIntPtr data);
|
||||||
|
|
||||||
|
[DllImport ("libgobject-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||||
|
static extern void g_value_set_ulong (ref Value val, uint data);
|
||||||
|
|
||||||
[DllImport ("libgobject-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
[DllImport ("libgobject-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||||
static extern void g_value_set_enum (ref Value val, int data);
|
static extern void g_value_set_enum (ref Value val, int data);
|
||||||
[DllImport ("libgobject-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
[DllImport ("libgobject-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||||
|
@ -646,9 +728,21 @@ namespace GLib {
|
||||||
[DllImport ("libgobject-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
[DllImport ("libgobject-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||||
static extern long g_value_get_int64 (ref Value val);
|
static extern long g_value_get_int64 (ref Value val);
|
||||||
|
|
||||||
|
[DllImport ("libgobject-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||||
|
static extern IntPtr g_value_get_long (ref Value val);
|
||||||
|
|
||||||
|
[DllImport ("libgobject-2.0-0.dll", EntryPoint = "g_value_get_long", CallingConvention = CallingConvention.Cdecl)]
|
||||||
|
static extern int g_value_get_long_as_int (ref Value val);
|
||||||
|
|
||||||
[DllImport ("libgobject-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
[DllImport ("libgobject-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||||
static extern ulong g_value_get_uint64 (ref Value val);
|
static extern ulong g_value_get_uint64 (ref Value val);
|
||||||
|
|
||||||
|
[DllImport ("libgobject-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||||
|
static extern UIntPtr g_value_get_ulong (ref Value val);
|
||||||
|
|
||||||
|
[DllImport ("libgobject-2.0-0.dll", EntryPoint = "g_value_get_ulong", CallingConvention = CallingConvention.Cdecl)]
|
||||||
|
static extern int g_value_get_ulong_as_uint (ref Value val);
|
||||||
|
|
||||||
[DllImport ("libgobject-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
[DllImport ("libgobject-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||||
static extern IntPtr g_value_get_object (ref Value val);
|
static extern IntPtr g_value_get_object (ref Value val);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue