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
This commit is contained in:
Mike Kestner 2003-12-15 16:59:25 +00:00
parent 027410def9
commit ff263164e3
20 changed files with 212 additions and 183 deletions

View file

@ -1,3 +1,22 @@
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.
2003-12-12 Mike Kestner <mkestner@ximian.com> 2003-12-12 Mike Kestner <mkestner@ximian.com>
* generator/CallbackGen.cs : kill some redundant generation * generator/CallbackGen.cs : kill some redundant generation

View file

@ -25,7 +25,7 @@ namespace GtkSharp.Generation {
StreamWriter sw = gen_info.Writer = gen_info.OpenStream (Name); StreamWriter sw = gen_info.Writer = gen_info.OpenStream (Name);
base.Generate (gen_info); base.Generate (gen_info);
sw.WriteLine ("\t\t[DllImport(\"gtksharpglue\")]"); sw.WriteLine ("\t\t[DllImport(\"gtksharpglue\")]");
sw.WriteLine ("\t\tstatic extern IntPtr gtksharp_value_create (uint gtype);"); sw.WriteLine ("\t\tstatic extern IntPtr gtksharp_value_create (GLib.GType gtype);");
sw.WriteLine (); sw.WriteLine ();
sw.WriteLine ("\t\t[DllImport(\"libgobject-2.0-0.dll\")]"); sw.WriteLine ("\t\t[DllImport(\"libgobject-2.0-0.dll\")]");
sw.WriteLine ("\t\tstatic extern void g_value_set_boxed (IntPtr handle, ref " + QualifiedName + " boxed);"); sw.WriteLine ("\t\tstatic extern void g_value_set_boxed (IntPtr handle, ref " + QualifiedName + " boxed);");

View file

@ -10,13 +10,17 @@ namespace GtkSharp.Generation {
public class ManualGen : IGeneratable { public class ManualGen : IGeneratable {
string handle;
string ctype; string ctype;
string type; string type;
string ns = ""; string ns = "";
public ManualGen (string ctype, string type) public ManualGen (string ctype, string type) : this (ctype, type, "Handle") {}
public ManualGen (string ctype, string type, string handle)
{ {
string[] toks = type.Split('.'); string[] toks = type.Split('.');
this.handle = handle;
this.ctype = ctype; this.ctype = ctype;
this.type = toks[toks.Length - 1]; this.type = toks[toks.Length - 1];
if (toks.Length > 2) if (toks.Length > 2)
@ -25,13 +29,6 @@ namespace GtkSharp.Generation {
this.ns = toks[0]; this.ns = toks[0];
} }
public ManualGen (string ctype, string ns, string type)
{
this.ns = ns;
this.ctype = ctype;
this.type = type;
}
public string CName { public string CName {
get get
{ {
@ -68,7 +65,7 @@ namespace GtkSharp.Generation {
public string CallByName (string var_name) public string CallByName (string var_name)
{ {
return var_name + ".Handle"; return var_name + "." + handle;
} }
public string FromNative(string var) public string FromNative(string var)

View file

@ -179,7 +179,7 @@ namespace GtkSharp.Generation {
gen_info.Writer.WriteLine("\t\t\tDispose();"); gen_info.Writer.WriteLine("\t\t\tDispose();");
gen_info.Writer.WriteLine("\t\t}"); gen_info.Writer.WriteLine("\t\t}");
gen_info.Writer.WriteLine(); gen_info.Writer.WriteLine();
gen_info.Writer.WriteLine("\t\tprotected " + Name + "(GLib.Type gtype) : base(gtype) {}"); gen_info.Writer.WriteLine("\t\tprotected " + Name + "(GLib.GType gtype) : base(gtype) {}");
gen_info.Writer.WriteLine("\t\tpublic " + Name + "(IntPtr raw) : base(raw) {}"); gen_info.Writer.WriteLine("\t\tpublic " + Name + "(IntPtr raw) : base(raw) {}");
gen_info.Writer.WriteLine(); gen_info.Writer.WriteLine();

View file

@ -195,11 +195,11 @@ namespace GtkSharp.Generation {
sw.WriteLine ("obj.{0} ({1});", "On" + Name, call.ToString ()); sw.WriteLine ("obj.{0} ({1});", "On" + Name, call.ToString ());
sw.WriteLine ("\t\t}\n"); sw.WriteLine ("\t\t}\n");
string cname = "\"" + elem.GetAttribute("cname") + "\""; string cname = "\"" + elem.GetAttribute("cname") + "\"";
sw.WriteLine ("\t\tprotected static void Override" + Name + " (uint gtype)"); sw.WriteLine ("\t\tprotected static void Override" + Name + " (GLib.GType gtype)");
sw.WriteLine ("\t\t{"); sw.WriteLine ("\t\t{");
sw.WriteLine ("\t\t\tif (" + Name + "Callback == null)"); sw.WriteLine ("\t\t\tif (" + Name + "Callback == null)");
sw.WriteLine ("\t\t\t\t" + Name + "Callback = new " + Name + "Delegate (" + Name.ToLower() + "_cb);"); sw.WriteLine ("\t\t\t\t" + Name + "Callback = new " + Name + "Delegate (" + Name.ToLower() + "_cb);");
sw.WriteLine ("\t\t\tgtksharp_override_virtual_method (gtype, " + cname + ", " + Name + "Callback);"); sw.WriteLine ("\t\t\tOverrideVirtualMethod (gtype, " + cname + ", " + Name + "Callback);");
sw.WriteLine ("\t\t}\n"); sw.WriteLine ("\t\t}\n");
} }

View file

@ -69,7 +69,7 @@ namespace GtkSharp.Generation {
AddType (new SimpleGen ("uint1", "bool")); AddType (new SimpleGen ("uint1", "bool"));
AddType (new SimpleGen ("GC", "IntPtr")); AddType (new SimpleGen ("GC", "IntPtr"));
AddType (new SimpleGen ("GPtrArray", "IntPtr[]")); AddType (new SimpleGen ("GPtrArray", "IntPtr[]"));
AddType (new SimpleGen ("GType", "uint")); AddType (new ManualGen ("GType", "GLib.GType", "Val"));
AddType (new SimpleGen ("GError", "IntPtr")); AddType (new SimpleGen ("GError", "IntPtr"));
// gsize is a system-specific typedef in glibconfig.h, // gsize is a system-specific typedef in glibconfig.h,
// but this should work for now // but this should work for now
@ -89,10 +89,10 @@ namespace GtkSharp.Generation {
AddType (new SimpleGen ("GParamSpec", "IntPtr")); AddType (new SimpleGen ("GParamSpec", "IntPtr"));
AddType (new SimpleGen ("gconstpointer", "IntPtr")); AddType (new SimpleGen ("gconstpointer", "IntPtr"));
AddType (new ManualGen ("GSList", "GLib", "SList")); AddType (new ManualGen ("GSList", "GLib.SList"));
AddType (new ManualGen ("GList", "GLib", "List")); AddType (new ManualGen ("GList", "GLib.List"));
AddType (new ManualGen ("GValue", "GLib", "Value")); AddType (new ManualGen ("GValue", "GLib.Value"));
AddType (new ManualGen ("GObject", "GLib", "Object")); AddType (new ManualGen ("GObject", "GLib.Object"));
} }
public void AddType (IGeneratable gen) public void AddType (IGeneratable gen)

View file

@ -13,7 +13,7 @@ namespace GLib {
public sealed class DefaultSignalHandlerAttribute : Attribute public sealed class DefaultSignalHandlerAttribute : Attribute
{ {
private string method; private string method;
private Type type; private System.Type type;
public DefaultSignalHandlerAttribute () {} public DefaultSignalHandlerAttribute () {}
@ -27,7 +27,7 @@ namespace GLib {
} }
} }
public Type Type public System.Type Type
{ {
get { get {
return type; return type;

View file

@ -8,6 +8,7 @@ namespace GLibSharp {
using System; using System;
using System.Collections; using System.Collections;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using GLib;
/// <summary> /// <summary>
/// Managed types boxer /// Managed types boxer
@ -37,18 +38,18 @@ namespace GLibSharp {
private static IntPtr cur_ptr = IntPtr.Zero; private static IntPtr cur_ptr = IntPtr.Zero;
private static CopyFunc copy; private static CopyFunc copy;
private static FreeFunc free; private static FreeFunc free;
private static uint boxed_type = 0; private static GType boxed_type = GType.Invalid;
[DllImport("libgobject-2.0-0.dll")] [DllImport("libgobject-2.0-0.dll")]
private static extern uint g_boxed_type_register_static (string typename, CopyFunc copy_func, FreeFunc free_func); private static extern IntPtr g_boxed_type_register_static (string typename, CopyFunc copy_func, FreeFunc free_func);
public static uint GType { public static GType GType {
get { get {
if (boxed_type == 0) { if (boxed_type == GType.Invalid) {
copy = new CopyFunc (Copy); copy = new CopyFunc (Copy);
free = new FreeFunc (Free); free = new FreeFunc (Free);
boxed_type = g_boxed_type_register_static ("GtkSharpValue", copy, free); boxed_type = new GLib.GType (g_boxed_type_register_static ("GtkSharpValue", copy, free));
} }
return boxed_type; return boxed_type;

View file

@ -142,7 +142,7 @@ namespace GLib {
} }
[DllImport("gtksharpglue")] [DllImport("gtksharpglue")]
static extern uint gtksharp_register_type (string name, uint parent_type); static extern IntPtr gtksharp_register_type (string name, IntPtr parent_type);
/// <summary> /// <summary>
/// RegisterGType Shared Method /// RegisterGType Shared Method
@ -154,18 +154,18 @@ namespace GLib {
/// of subclasses. /// of subclasses.
/// </remarks> /// </remarks>
public static GLib.Type RegisterGType (System.Type t) public static GType RegisterGType (System.Type t)
{ {
System.Type parent = t.BaseType; System.Type parent = t.BaseType;
PropertyInfo pi = parent.GetProperty ("GType", BindingFlags.DeclaredOnly | BindingFlags.Static | BindingFlags.Public); PropertyInfo pi = parent.GetProperty ("GType", BindingFlags.DeclaredOnly | BindingFlags.Static | BindingFlags.Public);
if (pi == null) { if (pi == null) {
Console.WriteLine ("null PropertyInfo"); Console.WriteLine ("null PropertyInfo");
return null; return GType.Invalid;
} }
uint parent_gtype = (uint) pi.GetValue (null, null); GType parent_gtype = (GType) pi.GetValue (null, null);
string name = t.Namespace.Replace(".", "_") + t.Name; string name = t.Namespace.Replace(".", "_") + t.Name;
GtkSharp.ObjectManager.RegisterType (name, t.Namespace + t.Name, t.Assembly.GetName().Name); GtkSharp.ObjectManager.RegisterType (name, t.Namespace + t.Name, t.Assembly.GetName().Name);
return new GLib.Type (gtksharp_register_type (name, parent_gtype)); return new GLib.GType (gtksharp_register_type (name, parent_gtype.Val));
} }
/// <summary> /// <summary>
@ -192,7 +192,7 @@ namespace GLib {
} }
[DllImport("libgobject-2.0-0.dll")] [DllImport("libgobject-2.0-0.dll")]
static extern IntPtr g_object_new (uint gtype, IntPtr dummy); static extern IntPtr g_object_new (IntPtr gtype, IntPtr dummy);
/// <summary> /// <summary>
/// Object Constructor /// Object Constructor
@ -202,9 +202,9 @@ namespace GLib {
/// Creates an object from a specified GType. /// Creates an object from a specified GType.
/// </remarks> /// </remarks>
protected Object (GLib.Type gtype) protected Object (GType gtype)
{ {
Raw = g_object_new (gtype.Value, IntPtr.Zero); Raw = g_object_new (gtype.Val, IntPtr.Zero);
} }
/// <summary> /// <summary>
@ -237,11 +237,11 @@ namespace GLib {
/// </remarks> /// </remarks>
[DllImport("gtksharpglue")] [DllImport("gtksharpglue")]
private static extern uint gtksharp_get_type_id (IntPtr obj); private static extern IntPtr gtksharp_get_type_id (IntPtr obj);
public static uint GType { public static GLib.GType GType {
get { get {
return 0; return GType.Invalid;
} }
} }
@ -262,11 +262,11 @@ namespace GLib {
/// Returns the GType of this object. /// Returns the GType of this object.
/// </remarks> /// </remarks>
public uint GetGType () { public GLib.GType GetGType () {
if (_obj == IntPtr.Zero) if (_obj == IntPtr.Zero)
return (uint) TypeFundamentals.TypeInvalid; return GType.Invalid;
else
return gtksharp_get_type_id (_obj); return new GLib.GType (gtksharp_get_type_id (_obj));
} }
/// <summary> /// <summary>
@ -367,7 +367,12 @@ namespace GLib {
} }
[DllImport("gtksharpglue")] [DllImport("gtksharpglue")]
protected static extern void gtksharp_override_virtual_method (uint gtype, string name, Delegate cb); static extern void gtksharp_override_virtual_method (IntPtr gtype, string name, Delegate cb);
protected static void OverrideVirtualMethod (GType gtype, string name, Delegate cb)
{
gtksharp_override_virtual_method (gtype.Val, name, cb);
}
[DllImport("libgobject-2.0-0.dll")] [DllImport("libgobject-2.0-0.dll")]
protected static extern void g_signal_chain_from_overridden (IntPtr[] args, IntPtr retval); protected static extern void g_signal_chain_from_overridden (IntPtr[] args, IntPtr retval);

View file

@ -1,15 +1,16 @@
// GLib.Type.cs - GLib Type class implementation // GLib.Type.cs - GLib GType class implementation
// //
// Author: Mike Kestner <mkestner@speakeasy.net> // Author: Mike Kestner <mkestner@speakeasy.net>
// //
// (c) 2003 Mike Kestner // (c) 2003 Mike Kestner, Novell, Inc.
namespace GLib { namespace GLib {
using System; using System;
using System.Runtime.InteropServices;
/// <summary> /// <summary>
/// Type Class /// GType Class
/// </summary> /// </summary>
/// ///
/// <remarks> /// <remarks>
@ -17,37 +18,66 @@ namespace GLib {
/// to get and set properties on Objects. /// to get and set properties on Objects.
/// </remarks> /// </remarks>
public class Type { [StructLayout(LayoutKind.Sequential)]
public struct GType {
uint val; IntPtr val;
/// <summary> /// <summary>
/// Type Constructor /// GType Constructor
/// </summary> /// </summary>
/// ///
/// <remarks> /// <remarks>
/// Constructs a new Type from a native GType value. /// Constructs a new GType from a native GType value.
/// </remarks> /// </remarks>
public Type (uint val) { public GType (IntPtr val) {
this.val = val; this.val = val;
} }
/// <summary> public static readonly GType Invalid = new GType ((IntPtr) TypeFundamentals.TypeInvalid);
/// Value Property public static readonly GType None = new GType ((IntPtr) TypeFundamentals.TypeNone);
/// </summary> public static readonly GType String = new GType ((IntPtr) TypeFundamentals.TypeString);
/// public static readonly GType Boolean = new GType ((IntPtr) TypeFundamentals.TypeBoolean);
/// <remarks> public static readonly GType Int = new GType ((IntPtr) TypeFundamentals.TypeInt);
/// Gets the native value of a Type object. public static readonly GType Double = new GType ((IntPtr) TypeFundamentals.TypeDouble);
/// </remarks> public static readonly GType Float = new GType ((IntPtr) TypeFundamentals.TypeFloat);
public static readonly GType Char = new GType ((IntPtr) TypeFundamentals.TypeChar);
public static readonly GType UInt = new GType ((IntPtr) TypeFundamentals.TypeUInt);
public static readonly GType Object = new GType ((IntPtr) TypeFundamentals.TypeObject);
public static readonly GType Pointer = new GType ((IntPtr) TypeFundamentals.TypePointer);
public static readonly GType Boxed = new GType ((IntPtr) TypeFundamentals.TypeBoxed);
public uint Value { public IntPtr Val {
get { get {
return val; return val;
} }
} }
public override string ToString() public override bool Equals (object o)
{
if (!(o is GType))
return false;
return ((GType) o) == this;
}
public static bool operator == (GType a, GType b)
{
return a.Val == b.Val;
}
public static bool operator != (GType a, GType b)
{
return a.Val != b.Val;
}
public override int GetHashCode ()
{
return val.GetHashCode ();
}
public override string ToString ()
{ {
return val.ToString(); return val.ToString();
} }

View file

@ -20,34 +20,34 @@ namespace GLibSharp {
private TypeConverter () {} private TypeConverter () {}
public static TypeFundamentals LookupType (System.Type type) public static GType LookupType (System.Type type)
{ {
if (type.Equals (typeof (string))) if (type.Equals (typeof (string)))
return TypeFundamentals.TypeString; return GType.String;
if (!type.IsValueType) { if (!type.IsValueType) {
if (type.IsSubclassOf (typeof (GLib.Object))) if (type.IsSubclassOf (typeof (GLib.Object)))
return TypeFundamentals.TypeObject; return GType.Object;
else if (type.IsSubclassOf (typeof (GLib.Boxed))) else if (type.IsSubclassOf (typeof (GLib.Boxed)))
return TypeFundamentals.TypeBoxed; return GType.Boxed;
else else
return TypeFundamentals.TypeNone; return GType.None;
} }
if (type.Equals (typeof (bool))) if (type.Equals (typeof (bool)))
return TypeFundamentals.TypeBoolean; return GType.Boolean;
if (type.Equals (typeof (int))) if (type.Equals (typeof (int)))
return TypeFundamentals.TypeInt; return GType.Int;
if (type.Equals (typeof (double))) if (type.Equals (typeof (double)))
return TypeFundamentals.TypeDouble; return GType.Double;
if (type.Equals (typeof (float))) if (type.Equals (typeof (float)))
return TypeFundamentals.TypeFloat; return GType.Float;
if (type.Equals (typeof (char))) if (type.Equals (typeof (char)))
return TypeFundamentals.TypeChar; return GType.Char;
if (type.Equals (typeof (uint))) if (type.Equals (typeof (uint)))
return TypeFundamentals.TypeUInt; return GType.UInt;
return TypeFundamentals.TypeInvalid; return GType.Invalid;
} }
} }
} }

View file

@ -2,7 +2,7 @@
// //
// Author: Mike Kestner <mkestner@speakeasy.net> // Author: Mike Kestner <mkestner@speakeasy.net>
// //
// (c) 2001 Mike Kestner // (c) 2001 Mike Kestner, (c) 2003 Novell, Inc.
namespace GLib { namespace GLib {
@ -37,8 +37,8 @@ namespace GLib {
public void Dispose () { public void Dispose () {
if (_val != IntPtr.Zero) { if (_val != IntPtr.Zero) {
uint type = gtksharp_value_get_value_type (_val); IntPtr rawtype = gtksharp_value_get_value_type (_val);
if (type == ManagedValue.GType) { if (rawtype == ManagedValue.GType.Val) {
ManagedValue.Free (g_value_get_boxed (_val)); ManagedValue.Free (g_value_get_boxed (_val));
} }
@ -51,7 +51,7 @@ namespace GLib {
// import the glue function to allocate values on heap // import the glue function to allocate values on heap
[DllImport("gtksharpglue")] [DllImport("gtksharpglue")]
static extern IntPtr gtksharp_value_create(uint type); static extern IntPtr gtksharp_value_create(IntPtr type);
[DllImport("gtksharpglue")] [DllImport("gtksharpglue")]
static extern IntPtr gtksharp_value_create_from_property(IntPtr obj, string name); static extern IntPtr gtksharp_value_create_from_property(IntPtr obj, string name);
@ -74,7 +74,7 @@ namespace GLib {
/// </remarks> /// </remarks>
public Value () { public Value () {
_val = gtksharp_value_create ((uint) TypeFundamentals.TypeInvalid); _val = gtksharp_value_create (GType.Invalid.Val);
} }
/// <summary> /// <summary>
@ -92,8 +92,7 @@ namespace GLib {
} }
[DllImport("libgobject-2.0-0.dll")] [DllImport("libgobject-2.0-0.dll")]
static extern void g_value_set_boolean (IntPtr val, static extern void g_value_set_boolean (IntPtr val, bool data);
bool data);
/// <summary> /// <summary>
/// Value Constructor /// Value Constructor
@ -105,13 +104,14 @@ namespace GLib {
public Value (bool val) public Value (bool val)
{ {
_val = gtksharp_value_create((uint) TypeFundamentals.TypeBoolean); _val = gtksharp_value_create(GType.Boolean.Val);
g_value_set_boolean (_val, val); g_value_set_boolean (_val, val);
} }
[DllImport("libgobject-2.0-0.dll")] [DllImport("libgobject-2.0-0.dll")]
static extern void g_value_set_boxed (IntPtr val, IntPtr data); static extern void g_value_set_boxed (IntPtr val, IntPtr data);
/*
/// <summary> /// <summary>
/// Value Constructor /// Value Constructor
/// </summary> /// </summary>
@ -122,7 +122,7 @@ namespace GLib {
public Value (GLib.Boxed val) public Value (GLib.Boxed val)
{ {
_val = gtksharp_value_create((uint) TypeFundamentals.TypeBoxed); _val = gtksharp_value_create(GType.Boxed);
//g_value_set_boxed (_val, val.Handle); //g_value_set_boxed (_val, val.Handle);
} }
@ -131,6 +131,7 @@ namespace GLib {
_val = gtksharp_value_create_from_property (obj, prop_name); _val = gtksharp_value_create_from_property (obj, prop_name);
//g_value_set_boxed (_val, val.Handle); //g_value_set_boxed (_val, val.Handle);
} }
*/
public Value (IntPtr obj, string prop_name, Opaque val) public Value (IntPtr obj, string prop_name, Opaque val)
{ {
@ -151,7 +152,7 @@ namespace GLib {
public Value (double val) public Value (double val)
{ {
_val = gtksharp_value_create ((uint) TypeFundamentals.TypeDouble); _val = gtksharp_value_create (GType.Double.Val);
g_value_set_double (_val, val); g_value_set_double (_val, val);
} }
@ -168,7 +169,7 @@ namespace GLib {
public Value (float val) public Value (float val)
{ {
_val = gtksharp_value_create ((uint) TypeFundamentals.TypeFloat); _val = gtksharp_value_create (GType.Float.Val);
g_value_set_float (_val, val); g_value_set_float (_val, val);
} }
@ -185,7 +186,7 @@ namespace GLib {
public Value (int val) public Value (int val)
{ {
_val = gtksharp_value_create ((uint) TypeFundamentals.TypeInt); _val = gtksharp_value_create (GType.Int.Val);
g_value_set_int (_val, val); g_value_set_int (_val, val);
} }
@ -202,7 +203,7 @@ namespace GLib {
public Value (GLib.Object val) public Value (GLib.Object val)
{ {
_val = gtksharp_value_create (val.GetGType ()); _val = gtksharp_value_create (val.GetGType ().Val);
g_value_set_object (_val, val.Handle); g_value_set_object (_val, val.Handle);
} }
@ -219,7 +220,7 @@ namespace GLib {
public Value (IntPtr val) public Value (IntPtr val)
{ {
_val = gtksharp_value_create ((uint) TypeFundamentals.TypePointer); _val = gtksharp_value_create (GType.Pointer.Val);
g_value_set_pointer (_val, val); g_value_set_pointer (_val, val);
} }
@ -236,7 +237,7 @@ namespace GLib {
public Value (string val) public Value (string val)
{ {
_val = gtksharp_value_create ((uint) TypeFundamentals.TypeString); _val = gtksharp_value_create (GType.String.Val);
g_value_set_string (_val, val); g_value_set_string (_val, val);
} }
@ -253,7 +254,7 @@ namespace GLib {
public Value (uint val) public Value (uint val)
{ {
_val = gtksharp_value_create ((uint) TypeFundamentals.TypeUInt); _val = gtksharp_value_create (GType.UInt.Val);
g_value_set_uint (_val, val); g_value_set_uint (_val, val);
} }
@ -267,7 +268,7 @@ namespace GLib {
public Value (ushort val) public Value (ushort val)
{ {
_val = gtksharp_value_create ((uint) TypeFundamentals.TypeUInt); _val = gtksharp_value_create (GType.UInt.Val);
g_value_set_uint (_val, val); g_value_set_uint (_val, val);
} }
@ -309,48 +310,37 @@ namespace GLib {
public Value (object obj) public Value (object obj)
{ {
TypeFundamentals type = TypeConverter.LookupType (obj.GetType ()); GType type = TypeConverter.LookupType (obj.GetType ());
if (type == TypeFundamentals.TypeNone) { if (type == GType.None) {
_val = gtksharp_value_create (ManagedValue.GType); _val = gtksharp_value_create (ManagedValue.GType.Val);
} else if (type == TypeFundamentals.TypeObject) { } else if (type == GType.Object) {
_val = gtksharp_value_create (((GLib.Object) obj).GetGType ()); _val = gtksharp_value_create (((GLib.Object) obj).GetGType ().Val);
} else if (type == TypeFundamentals.TypeInvalid) { } else if (type == GType.Invalid) {
throw new Exception ("Unknown type"); throw new Exception ("Unknown type");
} else { } else {
_val = gtksharp_value_create ((uint) type); _val = gtksharp_value_create (type.Val);
} }
switch (type) { if (type == GType.None)
case TypeFundamentals.TypeNone:
g_value_set_boxed_take_ownership (_val, ManagedValue.WrapObject (obj)); g_value_set_boxed_take_ownership (_val, ManagedValue.WrapObject (obj));
break; else if (type == GType.String)
case TypeFundamentals.TypeString:
g_value_set_string (_val, (string) obj); g_value_set_string (_val, (string) obj);
break; else if (type == GType.Boolean)
case TypeFundamentals.TypeBoolean:
g_value_set_boolean (_val, (bool) obj); g_value_set_boolean (_val, (bool) obj);
break; else if (type == GType.Int)
case TypeFundamentals.TypeInt:
g_value_set_int (_val, (int) obj); g_value_set_int (_val, (int) obj);
break; else if (type == GType.Double)
case TypeFundamentals.TypeDouble:
g_value_set_double (_val, (double) obj); g_value_set_double (_val, (double) obj);
break; else if (type == GType.Float)
case TypeFundamentals.TypeFloat:
g_value_set_float (_val, (float) obj); g_value_set_float (_val, (float) obj);
break; else if (type == GType.Char)
case TypeFundamentals.TypeChar:
g_value_set_char (_val, (char) obj); g_value_set_char (_val, (char) obj);
break; else if (type == GType.UInt)
case TypeFundamentals.TypeUInt:
g_value_set_uint (_val, (uint) obj); g_value_set_uint (_val, (uint) obj);
break; else if (type == GType.Object)
case TypeFundamentals.TypeObject:
g_value_set_object (_val, ((GLib.Object) obj).Handle); g_value_set_object (_val, ((GLib.Object) obj).Handle);
break; else
default:
throw new Exception ("Unknown type"); throw new Exception ("Unknown type");
}
} }
@ -597,70 +587,57 @@ namespace GLib {
} }
[DllImport("gtksharpglue")] [DllImport("gtksharpglue")]
static extern uint gtksharp_value_get_value_type (IntPtr val); static extern IntPtr gtksharp_value_get_value_type (IntPtr val);
public object Val public object Val
{ {
get { get {
uint type = gtksharp_value_get_value_type (_val); GLib.GType type = new GLib.GType (gtksharp_value_get_value_type (_val));
if (type == ManagedValue.GType) { if (type == ManagedValue.GType) {
return ManagedValue.ObjectForWrapper (g_value_get_boxed (_val)); return ManagedValue.ObjectForWrapper (g_value_get_boxed (_val));
} }
switch ((TypeFundamentals) type) { if (type == GType.String)
case TypeFundamentals.TypeString:
return (string) this; return (string) this;
case TypeFundamentals.TypeBoolean: else if (type == GType.Boolean)
return (bool) this; return (bool) this;
case TypeFundamentals.TypeInt: else if (type == GType.Int)
return (int) this; return (int) this;
case TypeFundamentals.TypeDouble: else if (type == GType.Double)
return (double) this; return (double) this;
case TypeFundamentals.TypeFloat: else if (type == GType.Float)
return (float) this; return (float) this;
case TypeFundamentals.TypeChar: else if (type == GType.Char)
return (char) this; return (char) this;
case TypeFundamentals.TypeUInt: else if (type == GType.UInt)
return (uint) this; return (uint) this;
case TypeFundamentals.TypeObject: else if (type == GType.Object)
return (GLib.Object) this; return (GLib.Object) this;
default: else
throw new Exception ("Unknown type"); throw new Exception ("Unknown type");
}
} }
set { set {
GLib.TypeFundamentals type = GLibSharp.TypeConverter.LookupType (value.GetType()); GType type = GLibSharp.TypeConverter.LookupType (value.GetType());
switch (type) { if (type == GType.None)
case TypeFundamentals.TypeNone:
g_value_set_boxed_take_ownership (_val, ManagedValue.WrapObject (value)); g_value_set_boxed_take_ownership (_val, ManagedValue.WrapObject (value));
break; else if (type == GType.String)
case TypeFundamentals.TypeString:
g_value_set_string (_val, (string) value); g_value_set_string (_val, (string) value);
break; else if (type == GType.Boolean)
case TypeFundamentals.TypeBoolean:
g_value_set_boolean (_val, (bool) value); g_value_set_boolean (_val, (bool) value);
break; else if (type == GType.Int)
case TypeFundamentals.TypeInt:
g_value_set_int (_val, (int) value); g_value_set_int (_val, (int) value);
break; else if (type == GType.Double)
case TypeFundamentals.TypeDouble:
g_value_set_double (_val, (double) value); g_value_set_double (_val, (double) value);
break; else if (type == GType.Float)
case TypeFundamentals.TypeFloat:
g_value_set_float (_val, (float) value); g_value_set_float (_val, (float) value);
break; else if (type == GType.Char)
case TypeFundamentals.TypeChar:
g_value_set_char (_val, (char) value); g_value_set_char (_val, (char) value);
break; else if (type == GType.UInt)
case TypeFundamentals.TypeUInt:
g_value_set_uint (_val, (uint) value); g_value_set_uint (_val, (uint) value);
break; else if (type == GType.Object)
case TypeFundamentals.TypeObject:
g_value_set_object (_val, ((GLib.Object) value).Handle); g_value_set_object (_val, ((GLib.Object) value).Handle);
break; else
default:
throw new Exception ("Unknown type"); throw new Exception ("Unknown type");
}
} }
} }

View file

@ -8,7 +8,7 @@
// This code is inserted after the automatically generated code. // This code is inserted after the automatically generated code.
// //
protected CanvasGroup (Gnome.CanvasGroup group, uint type) : base (group, type) protected CanvasGroup (Gnome.CanvasGroup group, GLib.GType type) : base (group, type)
{ {
} }

View file

@ -8,12 +8,12 @@
// This code is inserted after the automatically generated code. // This code is inserted after the automatically generated code.
// //
[DllImport("gnomecanvas-2")] [DllImport("gnomecanvas-2")]
static extern System.IntPtr gnome_canvas_item_new (IntPtr group, uint type, IntPtr null_terminator); static extern System.IntPtr gnome_canvas_item_new (IntPtr group, GLib.GType type, IntPtr null_terminator);
[DllImport("libgobject-2.0-0.dll")] [DllImport("libgobject-2.0-0.dll")]
static extern void g_object_ref (IntPtr raw); static extern void g_object_ref (IntPtr raw);
public CanvasItem (Gnome.CanvasGroup group, uint type) public CanvasItem (Gnome.CanvasGroup group, GLib.GType type)
: base (gnome_canvas_item_new (group.Handle, type, IntPtr.Zero)) : base (gnome_canvas_item_new (group.Handle, type, IntPtr.Zero))
{ {
g_object_ref (Handle); g_object_ref (Handle);

View file

@ -8,7 +8,7 @@
// This code is inserted after the automatically generated code. // This code is inserted after the automatically generated code.
// //
protected CanvasRE (Gnome.CanvasGroup group, uint type) : base (group, type) protected CanvasRE (Gnome.CanvasGroup group, GLib.GType type) : base (group, type)
{ {
} }

View file

@ -8,7 +8,7 @@
// This code is inserted after the automatically generated code. // This code is inserted after the automatically generated code.
// //
protected CanvasShape (Gnome.CanvasGroup group, uint type) : base (group, type) protected CanvasShape (Gnome.CanvasGroup group, GLib.GType type) : base (group, type)
{ {
} }

View file

@ -83,16 +83,16 @@
public ListStore (params Type[] types) public ListStore (params Type[] types)
{ {
uint[] ctypes = new uint[types.Length]; IntPtr[] ctypes = new IntPtr[types.Length];
int i = 0; int i = 0;
foreach (Type type in types) { foreach (Type type in types) {
GLib.TypeFundamentals ctype = GLibSharp.TypeConverter.LookupType (type); GLib.GType ctype = GLibSharp.TypeConverter.LookupType (type);
if (ctype == GLib.TypeFundamentals.TypeNone) { if (ctype == GLib.GType.None) {
ctypes[i] = GLibSharp.ManagedValue.GType; ctypes[i] = GLibSharp.ManagedValue.GType.Val;
} else if (ctype == GLib.TypeFundamentals.TypeInvalid) { } else if (ctype == GLib.GType.Invalid) {
throw new Exception ("Unknown type"); throw new Exception ("Unknown type");
} else { } else {
ctypes[i] = (uint) ctype; ctypes[i] = ctype.Val;
} }
i++; i++;
} }

View file

@ -36,7 +36,7 @@ namespace Gtk {
delegate int GetFlagsDelegate (); delegate int GetFlagsDelegate ();
delegate int GetNColumnsDelegate (); delegate int GetNColumnsDelegate ();
delegate uint GetColumnTypeDelegate (int col); delegate IntPtr GetColumnTypeDelegate (int col);
delegate bool GetNodeDelegate (out int node_idx, IntPtr path); delegate bool GetNodeDelegate (out int node_idx, IntPtr path);
delegate IntPtr GetPathDelegate (int node_idx); delegate IntPtr GetPathDelegate (int node_idx);
delegate void GetValueDelegate (int node_idx, int col, IntPtr val); delegate void GetValueDelegate (int node_idx, int col, IntPtr val);
@ -65,7 +65,7 @@ namespace Gtk {
int stamp; int stamp;
Hashtable node_hash = new IDHashtable (); Hashtable node_hash = new IDHashtable ();
uint[] ctypes; GLib.GType[] ctypes;
PropertyInfo[] getters; PropertyInfo[] getters;
int n_cols = 1; int n_cols = 1;
ArrayList nodes = new ArrayList (); ArrayList nodes = new ArrayList ();
@ -81,9 +81,9 @@ namespace Gtk {
return n_cols; return n_cols;
} }
uint get_column_type_cb (int col) IntPtr get_column_type_cb (int col)
{ {
return ctypes [col]; return ctypes [col].Val;
} }
bool get_node_cb (out int node_idx, IntPtr path) bool get_node_cb (out int node_idx, IntPtr path)
@ -124,7 +124,7 @@ namespace Gtk {
} }
[DllImport("libgobject-2.0-0.dll")] [DllImport("libgobject-2.0-0.dll")]
static extern void g_value_init (IntPtr handle, uint type); static extern void g_value_init (IntPtr handle, IntPtr type);
void get_value_cb (int node_idx, int col, IntPtr val) void get_value_cb (int node_idx, int col, IntPtr val)
{ {
@ -132,7 +132,7 @@ namespace Gtk {
ITreeNode node = node_hash [node_idx] as ITreeNode; ITreeNode node = node_hash [node_idx] as ITreeNode;
if (node == null) if (node == null)
return; return;
g_value_init (gval.Handle, ctypes [col]); g_value_init (gval.Handle, ctypes [col].Val);
object col_val = getters[col].GetValue (node, null); object col_val = getters[col].GetValue (node, null);
gval.Val = col_val; gval.Val = col_val;
} }
@ -292,7 +292,7 @@ namespace Gtk {
} }
} }
ctypes = new uint [n_cols]; ctypes = new GLib.GType [n_cols];
getters = new PropertyInfo [n_cols]; getters = new PropertyInfo [n_cols];
MemberInfo[] info = type.GetMembers (); MemberInfo[] info = type.GetMembers ();
@ -306,13 +306,13 @@ namespace Gtk {
int col = tnva.Column; int col = tnva.Column;
pi = mi as PropertyInfo; pi = mi as PropertyInfo;
getters [col] = pi; getters [col] = pi;
GLib.TypeFundamentals ctype = GLibSharp.TypeConverter.LookupType (pi.PropertyType); GLib.GType ctype = GLibSharp.TypeConverter.LookupType (pi.PropertyType);
if (ctype == GLib.TypeFundamentals.TypeNone) { if (ctype == GLib.GType.None) {
ctypes[col] = GLibSharp.ManagedValue.GType; ctypes[col] = GLibSharp.ManagedValue.GType;
} else if (ctype == GLib.TypeFundamentals.TypeInvalid) { } else if (ctype == GLib.GType.Invalid) {
throw new Exception ("Unknown type"); throw new Exception ("Unknown type");
} else { } else {
ctypes[col] = (uint) ctype; ctypes[col] = ctype;
} }
break; break;
default: default:

View file

@ -171,16 +171,16 @@
public TreeStore (params Type[] types) public TreeStore (params Type[] types)
{ {
uint[] ctypes = new uint[types.Length]; IntPtr[] ctypes = new IntPtr[types.Length];
int i = 0; int i = 0;
foreach (Type type in types) { foreach (Type type in types) {
GLib.TypeFundamentals ctype = GLibSharp.TypeConverter.LookupType (type); GLib.GType ctype = GLibSharp.TypeConverter.LookupType (type);
if (ctype == GLib.TypeFundamentals.TypeNone) { if (ctype == GLib.GType.None) {
ctypes[i] = GLibSharp.ManagedValue.GType; ctypes[i] = GLibSharp.ManagedValue.GType.Val;
} else if (ctype == GLib.TypeFundamentals.TypeInvalid) { } else if (ctype == GLib.GType.Invalid) {
throw new Exception ("Unknown type"); throw new Exception ("Unknown type");
} else { } else {
ctypes[i] = (uint) ctype; ctypes[i] = ctype.Val;
} }
i++; i++;
} }

View file

@ -43,14 +43,14 @@ namespace GtkSamples {
public class MyButton : Gtk.Button { public class MyButton : Gtk.Button {
static uint gtype = 0; static GLib.GType gtype = GLib.GType.Invalid;
public MyButton () : base (new GLib.Type (GType)) {} public MyButton () : base (GType) {}
public static new uint GType { public static new GLib.GType GType {
get { get {
if (gtype == 0) if (gtype == GLib.GType.Invalid)
gtype = RegisterGType (typeof (MyButton)).Value; gtype = RegisterGType (typeof (MyButton));
return gtype; return gtype;
} }
} }