Ryujinx-GtkSharp/glib/TypeConverter.cs
Mike Kestner ff263164e3 2003-12-15 Mike Kestner <mkestner@ximian.com>
* generator/BoxedGen.cs : s/uint/GLib.GType
	* generator/ManualGen.cs : add a ctor to pass ToNative handle name
	* generator/ObjectGen.cs : s/uint/GLib.GType
	* generator/Signal.cs : use GLib.GType and call OverrideVirtualMethod
	* generator/SymbolTable.cs : make GType a ManualGen and update a few
	ManualGens to the new signatures.
	* glib/DefaultSignalHandler.cs : s/Type/System.Type
	* glib/ManagedValue.cs : s/uint/GLib.GType
	* glib/Object.cs : s/uint/GLib.GType, add OverrideVirtualMethod.
	* glib/Type.cs : s/uint/IntPtr, add static fields for fundamentals.
	make it a value type and add ==, !=, Equals, and GetHashCode.
	* glib/TypeConverter.cs : use new GType statics, not fundamentals.
	* glib/Value.cs : use new GType statics, not fundamentals.
	* gnome/*.custom : s/uint/GLib.GType
	* gtk/*Store.custom : use GType statics, not fundamentals.
	* sample/Subclass.cs : s/uint/GLib.GType.

svn path=/trunk/gtk-sharp/; revision=21181
2003-12-15 16:59:25 +00:00

55 lines
1.2 KiB
C#

// GLib.TypeConverter.cs : Convert between fundamental and .NET types
//
// Author: Rachel Hestilow <hestilow@ximian.com>
//
// (c) 2002 Rachel Hestilow
namespace GLibSharp {
using System;
using System.Collections;
using GLib;
/// <summary>
/// Fundamental type converter
/// </summary>
///
/// <remarks>
/// Utilities for converting between TypeFundamentals and System.Type
/// </remarks>
public class TypeConverter {
private TypeConverter () {}
public static GType LookupType (System.Type type)
{
if (type.Equals (typeof (string)))
return GType.String;
if (!type.IsValueType) {
if (type.IsSubclassOf (typeof (GLib.Object)))
return GType.Object;
else if (type.IsSubclassOf (typeof (GLib.Boxed)))
return GType.Boxed;
else
return GType.None;
}
if (type.Equals (typeof (bool)))
return GType.Boolean;
if (type.Equals (typeof (int)))
return GType.Int;
if (type.Equals (typeof (double)))
return GType.Double;
if (type.Equals (typeof (float)))
return GType.Float;
if (type.Equals (typeof (char)))
return GType.Char;
if (type.Equals (typeof (uint)))
return GType.UInt;
return GType.Invalid;
}
}
}