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:
parent
027410def9
commit
ff263164e3
20 changed files with 212 additions and 183 deletions
19
ChangeLog
19
ChangeLog
|
@ -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>
|
||||
|
||||
* generator/CallbackGen.cs : kill some redundant generation
|
||||
|
|
|
@ -25,7 +25,7 @@ namespace GtkSharp.Generation {
|
|||
StreamWriter sw = gen_info.Writer = gen_info.OpenStream (Name);
|
||||
base.Generate (gen_info);
|
||||
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 ("\t\t[DllImport(\"libgobject-2.0-0.dll\")]");
|
||||
sw.WriteLine ("\t\tstatic extern void g_value_set_boxed (IntPtr handle, ref " + QualifiedName + " boxed);");
|
||||
|
|
|
@ -10,13 +10,17 @@ namespace GtkSharp.Generation {
|
|||
|
||||
public class ManualGen : IGeneratable {
|
||||
|
||||
string handle;
|
||||
string ctype;
|
||||
string type;
|
||||
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('.');
|
||||
this.handle = handle;
|
||||
this.ctype = ctype;
|
||||
this.type = toks[toks.Length - 1];
|
||||
if (toks.Length > 2)
|
||||
|
@ -25,13 +29,6 @@ namespace GtkSharp.Generation {
|
|||
this.ns = toks[0];
|
||||
}
|
||||
|
||||
public ManualGen (string ctype, string ns, string type)
|
||||
{
|
||||
this.ns = ns;
|
||||
this.ctype = ctype;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public string CName {
|
||||
get
|
||||
{
|
||||
|
@ -68,7 +65,7 @@ namespace GtkSharp.Generation {
|
|||
|
||||
public string CallByName (string var_name)
|
||||
{
|
||||
return var_name + ".Handle";
|
||||
return var_name + "." + handle;
|
||||
}
|
||||
|
||||
public string FromNative(string var)
|
||||
|
|
|
@ -179,7 +179,7 @@ namespace GtkSharp.Generation {
|
|||
gen_info.Writer.WriteLine("\t\t\tDispose();");
|
||||
gen_info.Writer.WriteLine("\t\t}");
|
||||
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();
|
||||
|
||||
|
|
|
@ -195,11 +195,11 @@ namespace GtkSharp.Generation {
|
|||
sw.WriteLine ("obj.{0} ({1});", "On" + Name, call.ToString ());
|
||||
sw.WriteLine ("\t\t}\n");
|
||||
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\tif (" + Name + "Callback == null)");
|
||||
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");
|
||||
}
|
||||
|
||||
|
|
|
@ -69,7 +69,7 @@ namespace GtkSharp.Generation {
|
|||
AddType (new SimpleGen ("uint1", "bool"));
|
||||
AddType (new SimpleGen ("GC", "IntPtr"));
|
||||
AddType (new SimpleGen ("GPtrArray", "IntPtr[]"));
|
||||
AddType (new SimpleGen ("GType", "uint"));
|
||||
AddType (new ManualGen ("GType", "GLib.GType", "Val"));
|
||||
AddType (new SimpleGen ("GError", "IntPtr"));
|
||||
// gsize is a system-specific typedef in glibconfig.h,
|
||||
// but this should work for now
|
||||
|
@ -89,10 +89,10 @@ namespace GtkSharp.Generation {
|
|||
AddType (new SimpleGen ("GParamSpec", "IntPtr"));
|
||||
AddType (new SimpleGen ("gconstpointer", "IntPtr"));
|
||||
|
||||
AddType (new ManualGen ("GSList", "GLib", "SList"));
|
||||
AddType (new ManualGen ("GList", "GLib", "List"));
|
||||
AddType (new ManualGen ("GValue", "GLib", "Value"));
|
||||
AddType (new ManualGen ("GObject", "GLib", "Object"));
|
||||
AddType (new ManualGen ("GSList", "GLib.SList"));
|
||||
AddType (new ManualGen ("GList", "GLib.List"));
|
||||
AddType (new ManualGen ("GValue", "GLib.Value"));
|
||||
AddType (new ManualGen ("GObject", "GLib.Object"));
|
||||
}
|
||||
|
||||
public void AddType (IGeneratable gen)
|
||||
|
|
|
@ -13,7 +13,7 @@ namespace GLib {
|
|||
public sealed class DefaultSignalHandlerAttribute : Attribute
|
||||
{
|
||||
private string method;
|
||||
private Type type;
|
||||
private System.Type type;
|
||||
|
||||
public DefaultSignalHandlerAttribute () {}
|
||||
|
||||
|
@ -27,7 +27,7 @@ namespace GLib {
|
|||
}
|
||||
}
|
||||
|
||||
public Type Type
|
||||
public System.Type Type
|
||||
{
|
||||
get {
|
||||
return type;
|
||||
|
|
|
@ -8,6 +8,7 @@ namespace GLibSharp {
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Runtime.InteropServices;
|
||||
using GLib;
|
||||
|
||||
/// <summary>
|
||||
/// Managed types boxer
|
||||
|
@ -37,18 +38,18 @@ namespace GLibSharp {
|
|||
private static IntPtr cur_ptr = IntPtr.Zero;
|
||||
private static CopyFunc copy;
|
||||
private static FreeFunc free;
|
||||
private static uint boxed_type = 0;
|
||||
private static GType boxed_type = GType.Invalid;
|
||||
|
||||
[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 {
|
||||
if (boxed_type == 0) {
|
||||
if (boxed_type == GType.Invalid) {
|
||||
copy = new CopyFunc (Copy);
|
||||
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;
|
||||
|
|
|
@ -142,7 +142,7 @@ namespace GLib {
|
|||
}
|
||||
|
||||
[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>
|
||||
/// RegisterGType Shared Method
|
||||
|
@ -154,18 +154,18 @@ namespace GLib {
|
|||
/// of subclasses.
|
||||
/// </remarks>
|
||||
|
||||
public static GLib.Type RegisterGType (System.Type t)
|
||||
public static GType RegisterGType (System.Type t)
|
||||
{
|
||||
System.Type parent = t.BaseType;
|
||||
PropertyInfo pi = parent.GetProperty ("GType", BindingFlags.DeclaredOnly | BindingFlags.Static | BindingFlags.Public);
|
||||
if (pi == null) {
|
||||
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;
|
||||
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>
|
||||
|
@ -192,7 +192,7 @@ namespace GLib {
|
|||
}
|
||||
|
||||
[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>
|
||||
/// Object Constructor
|
||||
|
@ -202,9 +202,9 @@ namespace GLib {
|
|||
/// Creates an object from a specified GType.
|
||||
/// </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>
|
||||
|
@ -237,11 +237,11 @@ namespace GLib {
|
|||
/// </remarks>
|
||||
|
||||
[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 {
|
||||
return 0;
|
||||
return GType.Invalid;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -262,11 +262,11 @@ namespace GLib {
|
|||
/// Returns the GType of this object.
|
||||
/// </remarks>
|
||||
|
||||
public uint GetGType () {
|
||||
public GLib.GType GetGType () {
|
||||
if (_obj == IntPtr.Zero)
|
||||
return (uint) TypeFundamentals.TypeInvalid;
|
||||
else
|
||||
return gtksharp_get_type_id (_obj);
|
||||
return GType.Invalid;
|
||||
|
||||
return new GLib.GType (gtksharp_get_type_id (_obj));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -367,7 +367,12 @@ namespace GLib {
|
|||
}
|
||||
|
||||
[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")]
|
||||
protected static extern void g_signal_chain_from_overridden (IntPtr[] args, IntPtr retval);
|
||||
|
|
64
glib/Type.cs
64
glib/Type.cs
|
@ -1,15 +1,16 @@
|
|||
// GLib.Type.cs - GLib Type class implementation
|
||||
// GLib.Type.cs - GLib GType class implementation
|
||||
//
|
||||
// Author: Mike Kestner <mkestner@speakeasy.net>
|
||||
//
|
||||
// (c) 2003 Mike Kestner
|
||||
// (c) 2003 Mike Kestner, Novell, Inc.
|
||||
|
||||
namespace GLib {
|
||||
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
/// <summary>
|
||||
/// Type Class
|
||||
/// GType Class
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
|
@ -17,37 +18,66 @@ namespace GLib {
|
|||
/// to get and set properties on Objects.
|
||||
/// </remarks>
|
||||
|
||||
public class Type {
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct GType {
|
||||
|
||||
uint val;
|
||||
IntPtr val;
|
||||
|
||||
/// <summary>
|
||||
/// Type Constructor
|
||||
/// GType Constructor
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// Constructs a new Type from a native GType value.
|
||||
/// Constructs a new GType from a native GType value.
|
||||
/// </remarks>
|
||||
|
||||
public Type (uint val) {
|
||||
public GType (IntPtr val) {
|
||||
this.val = val;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Value Property
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// Gets the native value of a Type object.
|
||||
/// </remarks>
|
||||
public static readonly GType Invalid = new GType ((IntPtr) TypeFundamentals.TypeInvalid);
|
||||
public static readonly GType None = new GType ((IntPtr) TypeFundamentals.TypeNone);
|
||||
public static readonly GType String = new GType ((IntPtr) TypeFundamentals.TypeString);
|
||||
public static readonly GType Boolean = new GType ((IntPtr) TypeFundamentals.TypeBoolean);
|
||||
public static readonly GType Int = new GType ((IntPtr) TypeFundamentals.TypeInt);
|
||||
public static readonly GType Double = new GType ((IntPtr) TypeFundamentals.TypeDouble);
|
||||
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 {
|
||||
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();
|
||||
}
|
||||
|
|
|
@ -20,34 +20,34 @@ namespace GLibSharp {
|
|||
|
||||
private TypeConverter () {}
|
||||
|
||||
public static TypeFundamentals LookupType (System.Type type)
|
||||
public static GType LookupType (System.Type type)
|
||||
{
|
||||
if (type.Equals (typeof (string)))
|
||||
return TypeFundamentals.TypeString;
|
||||
return GType.String;
|
||||
|
||||
if (!type.IsValueType) {
|
||||
if (type.IsSubclassOf (typeof (GLib.Object)))
|
||||
return TypeFundamentals.TypeObject;
|
||||
return GType.Object;
|
||||
else if (type.IsSubclassOf (typeof (GLib.Boxed)))
|
||||
return TypeFundamentals.TypeBoxed;
|
||||
return GType.Boxed;
|
||||
else
|
||||
return TypeFundamentals.TypeNone;
|
||||
return GType.None;
|
||||
}
|
||||
|
||||
if (type.Equals (typeof (bool)))
|
||||
return TypeFundamentals.TypeBoolean;
|
||||
return GType.Boolean;
|
||||
if (type.Equals (typeof (int)))
|
||||
return TypeFundamentals.TypeInt;
|
||||
return GType.Int;
|
||||
if (type.Equals (typeof (double)))
|
||||
return TypeFundamentals.TypeDouble;
|
||||
return GType.Double;
|
||||
if (type.Equals (typeof (float)))
|
||||
return TypeFundamentals.TypeFloat;
|
||||
return GType.Float;
|
||||
if (type.Equals (typeof (char)))
|
||||
return TypeFundamentals.TypeChar;
|
||||
return GType.Char;
|
||||
if (type.Equals (typeof (uint)))
|
||||
return TypeFundamentals.TypeUInt;
|
||||
return GType.UInt;
|
||||
|
||||
return TypeFundamentals.TypeInvalid;
|
||||
return GType.Invalid;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
137
glib/Value.cs
137
glib/Value.cs
|
@ -2,7 +2,7 @@
|
|||
//
|
||||
// Author: Mike Kestner <mkestner@speakeasy.net>
|
||||
//
|
||||
// (c) 2001 Mike Kestner
|
||||
// (c) 2001 Mike Kestner, (c) 2003 Novell, Inc.
|
||||
|
||||
namespace GLib {
|
||||
|
||||
|
@ -37,8 +37,8 @@ namespace GLib {
|
|||
|
||||
public void Dispose () {
|
||||
if (_val != IntPtr.Zero) {
|
||||
uint type = gtksharp_value_get_value_type (_val);
|
||||
if (type == ManagedValue.GType) {
|
||||
IntPtr rawtype = gtksharp_value_get_value_type (_val);
|
||||
if (rawtype == ManagedValue.GType.Val) {
|
||||
ManagedValue.Free (g_value_get_boxed (_val));
|
||||
}
|
||||
|
||||
|
@ -51,7 +51,7 @@ namespace GLib {
|
|||
// import the glue function to allocate values on heap
|
||||
|
||||
[DllImport("gtksharpglue")]
|
||||
static extern IntPtr gtksharp_value_create(uint type);
|
||||
static extern IntPtr gtksharp_value_create(IntPtr type);
|
||||
|
||||
[DllImport("gtksharpglue")]
|
||||
static extern IntPtr gtksharp_value_create_from_property(IntPtr obj, string name);
|
||||
|
@ -74,7 +74,7 @@ namespace GLib {
|
|||
/// </remarks>
|
||||
|
||||
public Value () {
|
||||
_val = gtksharp_value_create ((uint) TypeFundamentals.TypeInvalid);
|
||||
_val = gtksharp_value_create (GType.Invalid.Val);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -92,8 +92,7 @@ namespace GLib {
|
|||
}
|
||||
|
||||
[DllImport("libgobject-2.0-0.dll")]
|
||||
static extern void g_value_set_boolean (IntPtr val,
|
||||
bool data);
|
||||
static extern void g_value_set_boolean (IntPtr val, bool data);
|
||||
|
||||
/// <summary>
|
||||
/// Value Constructor
|
||||
|
@ -105,13 +104,14 @@ namespace GLib {
|
|||
|
||||
public Value (bool val)
|
||||
{
|
||||
_val = gtksharp_value_create((uint) TypeFundamentals.TypeBoolean);
|
||||
_val = gtksharp_value_create(GType.Boolean.Val);
|
||||
g_value_set_boolean (_val, val);
|
||||
}
|
||||
|
||||
[DllImport("libgobject-2.0-0.dll")]
|
||||
static extern void g_value_set_boxed (IntPtr val, IntPtr data);
|
||||
|
||||
/*
|
||||
/// <summary>
|
||||
/// Value Constructor
|
||||
/// </summary>
|
||||
|
@ -122,7 +122,7 @@ namespace GLib {
|
|||
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -131,6 +131,7 @@ namespace GLib {
|
|||
_val = gtksharp_value_create_from_property (obj, prop_name);
|
||||
//g_value_set_boxed (_val, val.Handle);
|
||||
}
|
||||
*/
|
||||
|
||||
public Value (IntPtr obj, string prop_name, Opaque val)
|
||||
{
|
||||
|
@ -151,7 +152,7 @@ namespace GLib {
|
|||
|
||||
public Value (double val)
|
||||
{
|
||||
_val = gtksharp_value_create ((uint) TypeFundamentals.TypeDouble);
|
||||
_val = gtksharp_value_create (GType.Double.Val);
|
||||
g_value_set_double (_val, val);
|
||||
}
|
||||
|
||||
|
@ -168,7 +169,7 @@ namespace GLib {
|
|||
|
||||
public Value (float val)
|
||||
{
|
||||
_val = gtksharp_value_create ((uint) TypeFundamentals.TypeFloat);
|
||||
_val = gtksharp_value_create (GType.Float.Val);
|
||||
g_value_set_float (_val, val);
|
||||
}
|
||||
|
||||
|
@ -185,7 +186,7 @@ namespace GLib {
|
|||
|
||||
public Value (int val)
|
||||
{
|
||||
_val = gtksharp_value_create ((uint) TypeFundamentals.TypeInt);
|
||||
_val = gtksharp_value_create (GType.Int.Val);
|
||||
g_value_set_int (_val, val);
|
||||
}
|
||||
|
||||
|
@ -202,7 +203,7 @@ namespace GLib {
|
|||
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -219,7 +220,7 @@ namespace GLib {
|
|||
|
||||
public Value (IntPtr val)
|
||||
{
|
||||
_val = gtksharp_value_create ((uint) TypeFundamentals.TypePointer);
|
||||
_val = gtksharp_value_create (GType.Pointer.Val);
|
||||
g_value_set_pointer (_val, val);
|
||||
}
|
||||
|
||||
|
@ -236,7 +237,7 @@ namespace GLib {
|
|||
|
||||
public Value (string val)
|
||||
{
|
||||
_val = gtksharp_value_create ((uint) TypeFundamentals.TypeString);
|
||||
_val = gtksharp_value_create (GType.String.Val);
|
||||
g_value_set_string (_val, val);
|
||||
}
|
||||
|
||||
|
@ -253,7 +254,7 @@ namespace GLib {
|
|||
|
||||
public Value (uint val)
|
||||
{
|
||||
_val = gtksharp_value_create ((uint) TypeFundamentals.TypeUInt);
|
||||
_val = gtksharp_value_create (GType.UInt.Val);
|
||||
g_value_set_uint (_val, val);
|
||||
}
|
||||
|
||||
|
@ -267,7 +268,7 @@ namespace GLib {
|
|||
|
||||
public Value (ushort val)
|
||||
{
|
||||
_val = gtksharp_value_create ((uint) TypeFundamentals.TypeUInt);
|
||||
_val = gtksharp_value_create (GType.UInt.Val);
|
||||
g_value_set_uint (_val, val);
|
||||
}
|
||||
|
||||
|
@ -309,49 +310,38 @@ namespace GLib {
|
|||
|
||||
public Value (object obj)
|
||||
{
|
||||
TypeFundamentals type = TypeConverter.LookupType (obj.GetType ());
|
||||
if (type == TypeFundamentals.TypeNone) {
|
||||
_val = gtksharp_value_create (ManagedValue.GType);
|
||||
} else if (type == TypeFundamentals.TypeObject) {
|
||||
_val = gtksharp_value_create (((GLib.Object) obj).GetGType ());
|
||||
} else if (type == TypeFundamentals.TypeInvalid) {
|
||||
GType type = TypeConverter.LookupType (obj.GetType ());
|
||||
if (type == GType.None) {
|
||||
_val = gtksharp_value_create (ManagedValue.GType.Val);
|
||||
} else if (type == GType.Object) {
|
||||
_val = gtksharp_value_create (((GLib.Object) obj).GetGType ().Val);
|
||||
} else if (type == GType.Invalid) {
|
||||
throw new Exception ("Unknown type");
|
||||
} else {
|
||||
_val = gtksharp_value_create ((uint) type);
|
||||
_val = gtksharp_value_create (type.Val);
|
||||
}
|
||||
|
||||
switch (type) {
|
||||
case TypeFundamentals.TypeNone:
|
||||
if (type == GType.None)
|
||||
g_value_set_boxed_take_ownership (_val, ManagedValue.WrapObject (obj));
|
||||
break;
|
||||
case TypeFundamentals.TypeString:
|
||||
else if (type == GType.String)
|
||||
g_value_set_string (_val, (string) obj);
|
||||
break;
|
||||
case TypeFundamentals.TypeBoolean:
|
||||
else if (type == GType.Boolean)
|
||||
g_value_set_boolean (_val, (bool) obj);
|
||||
break;
|
||||
case TypeFundamentals.TypeInt:
|
||||
else if (type == GType.Int)
|
||||
g_value_set_int (_val, (int) obj);
|
||||
break;
|
||||
case TypeFundamentals.TypeDouble:
|
||||
else if (type == GType.Double)
|
||||
g_value_set_double (_val, (double) obj);
|
||||
break;
|
||||
case TypeFundamentals.TypeFloat:
|
||||
else if (type == GType.Float)
|
||||
g_value_set_float (_val, (float) obj);
|
||||
break;
|
||||
case TypeFundamentals.TypeChar:
|
||||
else if (type == GType.Char)
|
||||
g_value_set_char (_val, (char) obj);
|
||||
break;
|
||||
case TypeFundamentals.TypeUInt:
|
||||
else if (type == GType.UInt)
|
||||
g_value_set_uint (_val, (uint) obj);
|
||||
break;
|
||||
case TypeFundamentals.TypeObject:
|
||||
else if (type == GType.Object)
|
||||
g_value_set_object (_val, ((GLib.Object) obj).Handle);
|
||||
break;
|
||||
default:
|
||||
else
|
||||
throw new Exception ("Unknown type");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -597,72 +587,59 @@ namespace GLib {
|
|||
}
|
||||
|
||||
[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
|
||||
{
|
||||
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) {
|
||||
return ManagedValue.ObjectForWrapper (g_value_get_boxed (_val));
|
||||
}
|
||||
|
||||
switch ((TypeFundamentals) type) {
|
||||
case TypeFundamentals.TypeString:
|
||||
if (type == GType.String)
|
||||
return (string) this;
|
||||
case TypeFundamentals.TypeBoolean:
|
||||
else if (type == GType.Boolean)
|
||||
return (bool) this;
|
||||
case TypeFundamentals.TypeInt:
|
||||
else if (type == GType.Int)
|
||||
return (int) this;
|
||||
case TypeFundamentals.TypeDouble:
|
||||
else if (type == GType.Double)
|
||||
return (double) this;
|
||||
case TypeFundamentals.TypeFloat:
|
||||
else if (type == GType.Float)
|
||||
return (float) this;
|
||||
case TypeFundamentals.TypeChar:
|
||||
else if (type == GType.Char)
|
||||
return (char) this;
|
||||
case TypeFundamentals.TypeUInt:
|
||||
else if (type == GType.UInt)
|
||||
return (uint) this;
|
||||
case TypeFundamentals.TypeObject:
|
||||
else if (type == GType.Object)
|
||||
return (GLib.Object) this;
|
||||
default:
|
||||
else
|
||||
throw new Exception ("Unknown type");
|
||||
}
|
||||
}
|
||||
set {
|
||||
GLib.TypeFundamentals type = GLibSharp.TypeConverter.LookupType (value.GetType());
|
||||
switch (type) {
|
||||
case TypeFundamentals.TypeNone:
|
||||
GType type = GLibSharp.TypeConverter.LookupType (value.GetType());
|
||||
if (type == GType.None)
|
||||
g_value_set_boxed_take_ownership (_val, ManagedValue.WrapObject (value));
|
||||
break;
|
||||
case TypeFundamentals.TypeString:
|
||||
else if (type == GType.String)
|
||||
g_value_set_string (_val, (string) value);
|
||||
break;
|
||||
case TypeFundamentals.TypeBoolean:
|
||||
else if (type == GType.Boolean)
|
||||
g_value_set_boolean (_val, (bool) value);
|
||||
break;
|
||||
case TypeFundamentals.TypeInt:
|
||||
else if (type == GType.Int)
|
||||
g_value_set_int (_val, (int) value);
|
||||
break;
|
||||
case TypeFundamentals.TypeDouble:
|
||||
else if (type == GType.Double)
|
||||
g_value_set_double (_val, (double) value);
|
||||
break;
|
||||
case TypeFundamentals.TypeFloat:
|
||||
else if (type == GType.Float)
|
||||
g_value_set_float (_val, (float) value);
|
||||
break;
|
||||
case TypeFundamentals.TypeChar:
|
||||
else if (type == GType.Char)
|
||||
g_value_set_char (_val, (char) value);
|
||||
break;
|
||||
case TypeFundamentals.TypeUInt:
|
||||
else if (type == GType.UInt)
|
||||
g_value_set_uint (_val, (uint) value);
|
||||
break;
|
||||
case TypeFundamentals.TypeObject:
|
||||
else if (type == GType.Object)
|
||||
g_value_set_object (_val, ((GLib.Object) value).Handle);
|
||||
break;
|
||||
default:
|
||||
else
|
||||
throw new Exception ("Unknown type");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handle Property
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
// 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)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -8,12 +8,12 @@
|
|||
// This code is inserted after the automatically generated code.
|
||||
//
|
||||
[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")]
|
||||
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))
|
||||
{
|
||||
g_object_ref (Handle);
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
// 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)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
// 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)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -83,16 +83,16 @@
|
|||
|
||||
public ListStore (params Type[] types)
|
||||
{
|
||||
uint[] ctypes = new uint[types.Length];
|
||||
IntPtr[] ctypes = new IntPtr[types.Length];
|
||||
int i = 0;
|
||||
foreach (Type type in types) {
|
||||
GLib.TypeFundamentals ctype = GLibSharp.TypeConverter.LookupType (type);
|
||||
if (ctype == GLib.TypeFundamentals.TypeNone) {
|
||||
ctypes[i] = GLibSharp.ManagedValue.GType;
|
||||
} else if (ctype == GLib.TypeFundamentals.TypeInvalid) {
|
||||
GLib.GType ctype = GLibSharp.TypeConverter.LookupType (type);
|
||||
if (ctype == GLib.GType.None) {
|
||||
ctypes[i] = GLibSharp.ManagedValue.GType.Val;
|
||||
} else if (ctype == GLib.GType.Invalid) {
|
||||
throw new Exception ("Unknown type");
|
||||
} else {
|
||||
ctypes[i] = (uint) ctype;
|
||||
ctypes[i] = ctype.Val;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ namespace Gtk {
|
|||
|
||||
delegate int GetFlagsDelegate ();
|
||||
delegate int GetNColumnsDelegate ();
|
||||
delegate uint GetColumnTypeDelegate (int col);
|
||||
delegate IntPtr GetColumnTypeDelegate (int col);
|
||||
delegate bool GetNodeDelegate (out int node_idx, IntPtr path);
|
||||
delegate IntPtr GetPathDelegate (int node_idx);
|
||||
delegate void GetValueDelegate (int node_idx, int col, IntPtr val);
|
||||
|
@ -65,7 +65,7 @@ namespace Gtk {
|
|||
|
||||
int stamp;
|
||||
Hashtable node_hash = new IDHashtable ();
|
||||
uint[] ctypes;
|
||||
GLib.GType[] ctypes;
|
||||
PropertyInfo[] getters;
|
||||
int n_cols = 1;
|
||||
ArrayList nodes = new ArrayList ();
|
||||
|
@ -81,9 +81,9 @@ namespace Gtk {
|
|||
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)
|
||||
|
@ -124,7 +124,7 @@ namespace Gtk {
|
|||
}
|
||||
|
||||
[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)
|
||||
{
|
||||
|
@ -132,7 +132,7 @@ namespace Gtk {
|
|||
ITreeNode node = node_hash [node_idx] as ITreeNode;
|
||||
if (node == null)
|
||||
return;
|
||||
g_value_init (gval.Handle, ctypes [col]);
|
||||
g_value_init (gval.Handle, ctypes [col].Val);
|
||||
object col_val = getters[col].GetValue (node, null);
|
||||
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];
|
||||
|
||||
MemberInfo[] info = type.GetMembers ();
|
||||
|
@ -306,13 +306,13 @@ namespace Gtk {
|
|||
int col = tnva.Column;
|
||||
pi = mi as PropertyInfo;
|
||||
getters [col] = pi;
|
||||
GLib.TypeFundamentals ctype = GLibSharp.TypeConverter.LookupType (pi.PropertyType);
|
||||
if (ctype == GLib.TypeFundamentals.TypeNone) {
|
||||
GLib.GType ctype = GLibSharp.TypeConverter.LookupType (pi.PropertyType);
|
||||
if (ctype == GLib.GType.None) {
|
||||
ctypes[col] = GLibSharp.ManagedValue.GType;
|
||||
} else if (ctype == GLib.TypeFundamentals.TypeInvalid) {
|
||||
} else if (ctype == GLib.GType.Invalid) {
|
||||
throw new Exception ("Unknown type");
|
||||
} else {
|
||||
ctypes[col] = (uint) ctype;
|
||||
ctypes[col] = ctype;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
|
|
@ -171,16 +171,16 @@
|
|||
|
||||
public TreeStore (params Type[] types)
|
||||
{
|
||||
uint[] ctypes = new uint[types.Length];
|
||||
IntPtr[] ctypes = new IntPtr[types.Length];
|
||||
int i = 0;
|
||||
foreach (Type type in types) {
|
||||
GLib.TypeFundamentals ctype = GLibSharp.TypeConverter.LookupType (type);
|
||||
if (ctype == GLib.TypeFundamentals.TypeNone) {
|
||||
ctypes[i] = GLibSharp.ManagedValue.GType;
|
||||
} else if (ctype == GLib.TypeFundamentals.TypeInvalid) {
|
||||
GLib.GType ctype = GLibSharp.TypeConverter.LookupType (type);
|
||||
if (ctype == GLib.GType.None) {
|
||||
ctypes[i] = GLibSharp.ManagedValue.GType.Val;
|
||||
} else if (ctype == GLib.GType.Invalid) {
|
||||
throw new Exception ("Unknown type");
|
||||
} else {
|
||||
ctypes[i] = (uint) ctype;
|
||||
ctypes[i] = ctype.Val;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
|
|
@ -43,14 +43,14 @@ namespace GtkSamples {
|
|||
|
||||
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 {
|
||||
if (gtype == 0)
|
||||
gtype = RegisterGType (typeof (MyButton)).Value;
|
||||
if (gtype == GLib.GType.Invalid)
|
||||
gtype = RegisterGType (typeof (MyButton));
|
||||
return gtype;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue