diff -Naur glib/Argv.cs glib-sharp/Argv.cs --- glib/Argv.cs 2009-09-02 22:17:37.000000000 +0200 +++ glib-sharp/Argv.cs 2009-09-03 10:41:01.000000000 +0200 @@ -19,7 +19,7 @@ // Boston, MA 02111-1307, USA. -namespace GLib { +namespace Gst.GLib { using System; using System.Runtime.InteropServices; diff -Naur glib/Boxed.cs glib-sharp/Boxed.cs --- glib/Boxed.cs 2004-10-21 03:08:10.000000000 +0200 +++ glib-sharp/Boxed.cs 2009-09-03 10:41:01.000000000 +0200 @@ -18,7 +18,7 @@ // Free Software Foundation, Inc., 59 Temple Place - Suite 330, // Boston, MA 02111-1307, USA. -namespace GLib { +namespace Gst.GLib { using System; diff -Naur glib/CDeclCallbackAttribute.cs glib-sharp/CDeclCallbackAttribute.cs --- glib/CDeclCallbackAttribute.cs 2009-07-02 22:18:10.000000000 +0200 +++ glib-sharp/CDeclCallbackAttribute.cs 2009-09-03 10:41:01.000000000 +0200 @@ -19,7 +19,7 @@ // Boston, MA 02111-1307, USA. -namespace GLib { +namespace Gst.GLib { using System; diff -Naur glib/ClassInitializerAttribute.cs glib-sharp/ClassInitializerAttribute.cs --- glib/ClassInitializerAttribute.cs 2007-09-07 16:40:46.000000000 +0200 +++ glib-sharp/ClassInitializerAttribute.cs 2009-09-03 10:41:01.000000000 +0200 @@ -19,7 +19,7 @@ // Boston, MA 02111-1307, USA. -namespace GLib { +namespace Gst.GLib { using System; diff -Naur glib/ConnectBeforeAttribute.cs glib-sharp/ConnectBeforeAttribute.cs --- glib/ConnectBeforeAttribute.cs 2004-06-25 20:42:19.000000000 +0200 +++ glib-sharp/ConnectBeforeAttribute.cs 2009-09-03 10:41:01.000000000 +0200 @@ -19,7 +19,7 @@ // Boston, MA 02111-1307, USA. -namespace GLib { +namespace Gst.GLib { using System; diff -Naur glib/DefaultSignalHandlerAttribute.cs glib-sharp/DefaultSignalHandlerAttribute.cs --- glib/DefaultSignalHandlerAttribute.cs 2004-06-25 20:42:19.000000000 +0200 +++ glib-sharp/DefaultSignalHandlerAttribute.cs 2009-09-03 10:41:01.000000000 +0200 @@ -19,7 +19,7 @@ // Boston, MA 02111-1307, USA. -namespace GLib { +namespace Gst.GLib { using System; diff -Naur glib/DelegateWrapper.cs glib-sharp/DelegateWrapper.cs --- glib/DelegateWrapper.cs 2009-09-02 22:17:37.000000000 +0200 +++ glib-sharp/DelegateWrapper.cs 2009-09-03 10:41:01.000000000 +0200 @@ -22,7 +22,7 @@ // Boston, MA 02111-1307, USA. -namespace GLib { +namespace Gst.GLib { using System; using System.Collections; diff -Naur glib/DestroyNotify.cs glib-sharp/DestroyNotify.cs --- glib/DestroyNotify.cs 2009-09-02 22:17:37.000000000 +0200 +++ glib-sharp/DestroyNotify.cs 2009-09-03 10:41:01.000000000 +0200 @@ -18,7 +18,7 @@ // Free Software Foundation, Inc., 59 Temple Place - Suite 330, // Boston, MA 02111-1307, USA. -namespace GLib { +namespace Gst.GLib { using System; using System.Runtime.InteropServices; diff -Naur glib/EnumWrapper.cs glib-sharp/EnumWrapper.cs --- glib/EnumWrapper.cs 2005-07-22 20:36:50.000000000 +0200 +++ glib-sharp/EnumWrapper.cs 2009-09-03 10:41:01.000000000 +0200 @@ -19,7 +19,7 @@ // Boston, MA 02111-1307, USA. -namespace GLib { +namespace Gst.GLib { using System; using System.Runtime.InteropServices; diff -Naur glib/ExceptionManager.cs glib-sharp/ExceptionManager.cs --- glib/ExceptionManager.cs 2007-03-08 21:28:24.000000000 +0100 +++ glib-sharp/ExceptionManager.cs 2009-09-03 10:41:01.000000000 +0200 @@ -19,7 +19,7 @@ // Boston, MA 02111-1307, USA. -namespace GLib { +namespace Gst.GLib { using System; diff -Naur glib/FileUtils.cs glib-sharp/FileUtils.cs --- glib/FileUtils.cs 2009-09-02 22:17:37.000000000 +0200 +++ glib-sharp/FileUtils.cs 2009-09-03 10:41:01.000000000 +0200 @@ -19,7 +19,7 @@ // Boston, MA 02111-1307, USA. -namespace GLib { +namespace Gst.GLib { using System; using System.Text; diff -Naur glib/Format.cs glib-sharp/Format.cs --- glib/Format.cs 2009-09-02 22:17:37.000000000 +0200 +++ glib-sharp/Format.cs 2009-09-03 10:41:01.000000000 +0200 @@ -23,7 +23,7 @@ using System; using System.Runtime.InteropServices; -namespace GLib { +namespace Gst.GLib { #if GTK_SHARP_2_14 public class Format { [DllImport ("libglib-2.0-0.dll", CallingConvention = Global.CallingConvention)] diff -Naur glib/GException.cs glib-sharp/GException.cs --- glib/GException.cs 2009-09-02 22:17:37.000000000 +0200 +++ glib-sharp/GException.cs 2009-09-03 10:41:01.000000000 +0200 @@ -19,7 +19,7 @@ // Boston, MA 02111-1307, USA. -namespace GLib { +namespace Gst.GLib { using System; using System.Runtime.InteropServices; diff -Naur glib/GInterfaceAdapter.cs glib-sharp/GInterfaceAdapter.cs --- glib/GInterfaceAdapter.cs 2009-07-21 08:51:10.000000000 +0200 +++ glib-sharp/GInterfaceAdapter.cs 2009-09-03 10:41:01.000000000 +0200 @@ -19,7 +19,7 @@ // Boston, MA 02111-1307, USA. -namespace GLib { +namespace Gst.GLib { using System; using System.Runtime.InteropServices; diff -Naur glib/GInterfaceAttribute.cs glib-sharp/GInterfaceAttribute.cs --- glib/GInterfaceAttribute.cs 2007-09-11 22:34:24.000000000 +0200 +++ glib-sharp/GInterfaceAttribute.cs 2009-09-03 10:41:01.000000000 +0200 @@ -17,7 +17,7 @@ // Boston, MA 02111-1307, USA. -namespace GLib { +namespace Gst.GLib { using System; diff -Naur glib/Global.cs glib-sharp/Global.cs --- glib/Global.cs 2009-09-02 22:17:37.000000000 +0200 +++ glib-sharp/Global.cs 2009-09-03 10:41:01.000000000 +0200 @@ -19,7 +19,7 @@ // Boston, MA 02111-1307, USA. -namespace GLib { +namespace Gst.GLib { using System; using System.Text; diff -Naur glib/glue/Makefile.am glib-sharp/glue/Makefile.am diff -Naur glib/glue/thread.c glib-sharp/glue/thread.c diff -Naur glib/glue/win32dll.c glib-sharp/glue/win32dll.c diff -Naur glib/GString.cs glib-sharp/GString.cs --- glib/GString.cs 2009-09-02 22:17:37.000000000 +0200 +++ glib-sharp/GString.cs 2009-09-03 10:41:01.000000000 +0200 @@ -19,7 +19,7 @@ // Boston, MA 02111-1307, USA. -namespace GLib { +namespace Gst.GLib { using System; using System.Runtime.InteropServices; diff -Naur glib/GTypeAttribute.cs glib-sharp/GTypeAttribute.cs --- glib/GTypeAttribute.cs 2005-05-04 18:54:24.000000000 +0200 +++ glib-sharp/GTypeAttribute.cs 2009-09-03 10:41:01.000000000 +0200 @@ -17,7 +17,7 @@ // Boston, MA 02111-1307, USA. -namespace GLib { +namespace Gst.GLib { using System; diff -Naur glib/GType.cs glib-sharp/GType.cs --- glib/GType.cs 2009-09-02 22:17:37.000000000 +0200 +++ glib-sharp/GType.cs 2009-09-03 10:41:01.000000000 +0200 @@ -20,7 +20,7 @@ // Boston, MA 02111-1307, USA. -namespace GLib { +namespace Gst.GLib { using System; using System.Collections; diff -Naur glib/Idle.cs glib-sharp/Idle.cs --- glib/Idle.cs 2009-09-02 22:17:37.000000000 +0200 +++ glib-sharp/Idle.cs 2009-09-03 10:41:01.000000000 +0200 @@ -24,7 +24,7 @@ // Boston, MA 02111-1307, USA. -namespace GLib { +namespace Gst.GLib { using System; using System.Collections; diff -Naur glib/IgnoreClassInitializersAttribute.cs glib-sharp/IgnoreClassInitializersAttribute.cs --- glib/IgnoreClassInitializersAttribute.cs 2007-09-07 16:40:46.000000000 +0200 +++ glib-sharp/IgnoreClassInitializersAttribute.cs 2009-09-03 10:41:01.000000000 +0200 @@ -19,7 +19,7 @@ // Boston, MA 02111-1307, USA. -namespace GLib { +namespace Gst.GLib { using System; diff -Naur glib/InitiallyUnowned.cs glib-sharp/InitiallyUnowned.cs --- glib/InitiallyUnowned.cs 2009-08-08 05:06:53.000000000 +0200 +++ glib-sharp/InitiallyUnowned.cs 2009-09-03 10:41:01.000000000 +0200 @@ -20,7 +20,7 @@ #if GTK_SHARP_2_10 -namespace GLib { +namespace Gst.GLib { using System; using System.Collections; diff -Naur glib/IOChannel.cs glib-sharp/IOChannel.cs --- glib/IOChannel.cs 2009-09-02 22:17:37.000000000 +0200 +++ glib-sharp/IOChannel.cs 2009-09-03 10:41:01.000000000 +0200 @@ -19,7 +19,7 @@ // Boston, MA 02111-1307, USA. -namespace GLibSharp { +namespace Gst.GLibSharp { using System; using System.Runtime.InteropServices; @@ -51,7 +51,7 @@ } } -namespace GLib { +namespace Gst.GLib { using System; using System.Runtime.InteropServices; diff -Naur glib/IWrapper.cs glib-sharp/IWrapper.cs --- glib/IWrapper.cs 2004-06-25 20:42:19.000000000 +0200 +++ glib-sharp/IWrapper.cs 2009-09-03 10:41:01.000000000 +0200 @@ -19,7 +19,7 @@ // Boston, MA 02111-1307, USA. -namespace GLib +namespace Gst.GLib { using System; diff -Naur glib/ListBase.cs glib-sharp/ListBase.cs --- glib/ListBase.cs 2009-09-02 22:17:37.000000000 +0200 +++ glib-sharp/ListBase.cs 2009-09-03 10:41:01.000000000 +0200 @@ -20,7 +20,7 @@ // Boston, MA 02111-1307, USA. -namespace GLib { +namespace Gst.GLib { using System; using System.Collections; diff -Naur glib/List.cs glib-sharp/List.cs --- glib/List.cs 2009-09-02 22:17:37.000000000 +0200 +++ glib-sharp/List.cs 2009-09-03 10:41:01.000000000 +0200 @@ -19,7 +19,7 @@ // Boston, MA 02111-1307, USA. -namespace GLib { +namespace Gst.GLib { using System; using System.Runtime.InteropServices; diff -Naur glib/Log.cs glib-sharp/Log.cs --- glib/Log.cs 2009-09-02 22:17:37.000000000 +0200 +++ glib-sharp/Log.cs 2009-09-03 10:41:01.000000000 +0200 @@ -22,7 +22,7 @@ // -namespace GLib { +namespace Gst.GLib { using System; using System.Collections; diff -Naur glib/MainContext.cs glib-sharp/MainContext.cs --- glib/MainContext.cs 2009-09-02 22:17:37.000000000 +0200 +++ glib-sharp/MainContext.cs 2009-09-03 10:41:01.000000000 +0200 @@ -19,7 +19,7 @@ // Boston, MA 02111-1307, USA. -namespace GLib { +namespace Gst.GLib { using System; using System.Runtime.InteropServices; diff -Naur glib/MainLoop.cs glib-sharp/MainLoop.cs --- glib/MainLoop.cs 2009-09-02 22:17:37.000000000 +0200 +++ glib-sharp/MainLoop.cs 2009-09-03 10:41:01.000000000 +0200 @@ -21,7 +21,7 @@ using System; using System.Runtime.InteropServices; -namespace GLib { +namespace Gst.GLib { public class MainLoop { private IntPtr handle; diff -Naur glib/Makefile.am glib-sharp/Makefile.am diff -Naur glib/ManagedValue.cs glib-sharp/ManagedValue.cs --- glib/ManagedValue.cs 2009-09-02 22:17:37.000000000 +0200 +++ glib-sharp/ManagedValue.cs 2009-09-03 10:41:01.000000000 +0200 @@ -19,7 +19,7 @@ // Boston, MA 02111-1307, USA. -namespace GLib { +namespace Gst.GLib { using System; using System.Collections; using System.Runtime.InteropServices; @@ -76,7 +76,7 @@ copy = new CopyFunc (Copy); free = new FreeFunc (Free); - IntPtr name = Marshaller.StringToPtrGStrdup ("GtkSharpValue"); + IntPtr name = Marshaller.StringToPtrGStrdup ("GstGLibSharpValue"); boxed_type = new GLib.GType (g_boxed_type_register_static (name, copy, free)); Marshaller.Free (name); } diff -Naur glib/Markup.cs glib-sharp/Markup.cs --- glib/Markup.cs 2009-09-02 22:17:37.000000000 +0200 +++ glib-sharp/Markup.cs 2009-09-03 10:41:01.000000000 +0200 @@ -23,7 +23,7 @@ using System; using System.Runtime.InteropServices; -namespace GLib { +namespace Gst.GLib { public class Markup { diff -Naur glib/Marshaller.cs glib-sharp/Marshaller.cs --- glib/Marshaller.cs 2009-09-02 22:17:37.000000000 +0200 +++ glib-sharp/Marshaller.cs 2009-09-03 10:41:01.000000000 +0200 @@ -21,7 +21,7 @@ // Boston, MA 02111-1307, USA. -namespace GLib { +namespace Gst.GLib { using System; using System.Runtime.InteropServices; diff -Naur glib/MissingIntPtrCtorException.cs glib-sharp/MissingIntPtrCtorException.cs --- glib/MissingIntPtrCtorException.cs 2004-06-25 20:42:19.000000000 +0200 +++ glib-sharp/MissingIntPtrCtorException.cs 2009-09-03 10:41:01.000000000 +0200 @@ -19,7 +19,7 @@ // Boston, MA 02111-1307, USA. -namespace GLib { +namespace Gst.GLib { using System; using System.Runtime.InteropServices; diff -Naur glib/NotifyHandler.cs glib-sharp/NotifyHandler.cs --- glib/NotifyHandler.cs 2009-09-02 22:17:37.000000000 +0200 +++ glib-sharp/NotifyHandler.cs 2009-09-03 10:41:01.000000000 +0200 @@ -14,7 +14,7 @@ // Free Software Foundation, Inc., 59 Temple Place - Suite 330, // Boston, MA 02111-1307, USA. -namespace GLib { +namespace Gst.GLib { using System; using System.Runtime.InteropServices; diff -Naur glib/Object.cs glib-sharp/Object.cs --- glib/Object.cs 2009-09-02 22:17:37.000000000 +0200 +++ glib-sharp/Object.cs 2009-09-03 10:45:33.000000000 +0200 @@ -20,7 +20,7 @@ // Boston, MA 02111-1307, USA. -namespace GLib { +namespace Gst.GLib { using System; using System.Collections; @@ -185,21 +185,23 @@ } } + [StructLayout(LayoutKind.Sequential)] struct GTypeClass { public IntPtr gtype; } + [StructLayout(LayoutKind.Sequential)] struct GObjectClass { GTypeClass type_class; IntPtr construct_props; - IntPtr constructor_cb; + public ConstructorDelegate constructor_cb; public SetPropertyDelegate set_prop_cb; public GetPropertyDelegate get_prop_cb; IntPtr dispose; IntPtr finalize; IntPtr dispatch_properties_changed; IntPtr notify; - IntPtr constructed; + public ConstructedDelegate constructed_cb; IntPtr dummy1; IntPtr dummy2; IntPtr dummy3; @@ -209,13 +211,37 @@ IntPtr dummy7; } + static Hashtable class_structs; + + static GObjectClass GetClassStruct (GLib.GType gtype, bool use_cache) + { + if (class_structs == null) + class_structs = new Hashtable (); + + if (use_cache && class_structs.Contains (gtype)) + return (GObjectClass) class_structs [gtype]; + else { + IntPtr class_ptr = gtype.GetClassPtr (); + GObjectClass class_struct = (GObjectClass) Marshal.PtrToStructure (class_ptr, typeof (GObjectClass)); + if (use_cache) + class_structs.Add (gtype, class_struct); + return class_struct; + } + } + + static void OverrideClassStruct (GLib.GType gtype, GObjectClass class_struct) + { + IntPtr class_ptr = gtype.GetClassPtr (); + Marshal.StructureToPtr (class_struct, class_ptr, false); + } + + static void OverridePropertyHandlers (GType gtype, GetPropertyDelegate get_cb, SetPropertyDelegate set_cb) { - IntPtr class_ptr = gtype.GetClassPtr (); - GObjectClass klass = (GObjectClass) Marshal.PtrToStructure (class_ptr, typeof (GObjectClass)); + GObjectClass klass = GetClassStruct (gtype, false); klass.get_prop_cb = get_cb; klass.set_prop_cb = set_cb; - Marshal.StructureToPtr (klass, class_ptr, false); + OverrideClassStruct (gtype, klass); } [DllImport ("libgobject-2.0-0.dll", CallingConvention = Global.CallingConvention)] @@ -230,9 +256,68 @@ return pspec.Handle; } + static ConstructorDelegate Constructor_cb = new ConstructorDelegate (constructor_cb); + delegate IntPtr ConstructorDelegate (IntPtr gtype, uint n_construct_properties, IntPtr construct_properties); + + [StructLayout(LayoutKind.Sequential)] + struct GObjectConstructParam { + public IntPtr pspec; + public IntPtr value; + } + + static IntPtr constructor_cb (IntPtr gtype, uint n_construct_properties, IntPtr construct_properties) + { + GType type = new GLib.GType (gtype); + IntPtr instance = GetClassStruct (type.GetThresholdType (), false).constructor_cb (gtype, n_construct_properties, construct_properties); + for (int i = 0; i < n_construct_properties; i++) { + IntPtr p = new IntPtr ((long) construct_properties + i * Marshal.SizeOf (typeof (GObjectConstructParam))); + + GObjectConstructParam cparam = (GObjectConstructParam) Marshal.PtrToStructure (p, typeof (GObjectConstructParam)); + + ParamSpec pspec = new ParamSpec (cparam.pspec); + GLib.Value val = (Value) Marshal.PtrToStructure (cparam.value, typeof (Value)); + + if (pspec.Name == "gtk-sharp-managed-instance" && (IntPtr) val.Val != IntPtr.Zero) { + GCHandle gch = (GCHandle) (IntPtr) val.Val; + Object o = (GLib.Object) gch.Target; + o.Raw = instance; + } + } + + return instance; + } + + static ConstructedDelegate Constructed_cb = new ConstructedDelegate (constructed_cb); + [GLib.CDeclCallback] + delegate void ConstructedDelegate (IntPtr o); + + static void constructed_cb (IntPtr o) + { + GLib.Object __obj = GLib.Object.GetObject (o, false) as GLib.Object; + ConstructedDelegate unmanaged = GetClassStruct (__obj.LookupGType ().GetThresholdType (), true).constructed_cb; + if (unmanaged != null) + unmanaged (__obj.Handle); + } + + static SetPropertyDelegate Set_prop_dummy_cb = new SetPropertyDelegate (set_prop_dummy_cb); + static void set_prop_dummy_cb (IntPtr GObject, uint property_id, ref GLib.Value value, IntPtr pspec) {} + static void AddProperties (GType gtype, System.Type t) { uint idx = 1; + + if (gtype.GetBaseType () == gtype.GetThresholdType ()) { + GObjectClass gobject_class = GetClassStruct (gtype, false); + gobject_class.constructor_cb = Constructor_cb; + gobject_class.constructed_cb = Constructed_cb; + gobject_class.set_prop_cb = Set_prop_dummy_cb; + OverrideClassStruct (gtype, gobject_class); + + IntPtr declaring_class = gtype.GetClassPtr (); + ParamSpec pspec = new ParamSpec ("gtk-sharp-managed-instance", "", "", GType.Pointer, ParamFlags.Writable | ParamFlags.ConstructOnly); + g_object_class_install_property (declaring_class, idx, pspec.Handle); + idx++; + } bool handlers_overridden = false; foreach (PropertyInfo pinfo in t.GetProperties (BindingFlags.Instance | BindingFlags.Public | BindingFlags.DeclaredOnly)) { @@ -262,6 +347,9 @@ static void GetPropertyCallback (IntPtr handle, uint property_id, ref GLib.Value value, IntPtr param_spec) { + if (!Properties.Contains (param_spec)) + return; + GLib.Object obj = GLib.Object.GetObject (handle, false); value.Val = (Properties [param_spec] as PropertyInfo).GetValue (obj, new object [0]); } @@ -280,6 +368,9 @@ static void SetPropertyCallback(IntPtr handle, uint property_id, ref GLib.Value value, IntPtr param_spec) { + if (!Properties.Contains (param_spec)) + return; + GLib.Object obj = GLib.Object.GetObject (handle, false); (Properties [param_spec] as PropertyInfo).SetValue (obj, value.Val, new object [0]); } @@ -360,12 +451,28 @@ protected virtual void CreateNativeObject (string[] names, GLib.Value[] vals) { - GParameter[] parms = new GParameter [names.Length]; + GLib.GType gtype = LookupGType (); + bool managed_type = gtype.ToString().StartsWith ("__gtksharp_"); + + GParameter[] parms = new GParameter [names.Length + ((managed_type) ? 1 : 0)]; + for (int i = 0; i < names.Length; i++) { parms [i].name = GLib.Marshaller.StringToPtrGStrdup (names [i]); parms [i].val = vals [i]; } - Raw = g_object_newv (LookupGType ().Val, parms.Length, parms); + + if (managed_type) { + GCHandle gch = GCHandle.Alloc (this); + parms[names.Length].name = GLib.Marshaller.StringToPtrGStrdup ("gtk-sharp-managed-instance"); + parms[names.Length].val = new GLib.Value ((IntPtr) gch); + + Raw = g_object_newv (gtype.Val, parms.Length, parms); + + gch.Free (); + } else { + Raw = g_object_newv (gtype.Val, parms.Length, parms); + } + foreach (GParameter p in parms) GLib.Marshaller.Free (p.name); } @@ -593,10 +700,12 @@ return g_type_check_instance_is_a (obj, GType.Object.Val); } + [StructLayout(LayoutKind.Sequential)] struct GTypeInstance { public IntPtr g_class; } + [StructLayout(LayoutKind.Sequential)] struct GObject { public GTypeInstance type_instance; public uint ref_count; diff -Naur glib/ObjectManager.cs glib-sharp/ObjectManager.cs --- glib/ObjectManager.cs 2009-09-02 22:17:37.000000000 +0200 +++ glib-sharp/ObjectManager.cs 2009-09-03 10:41:01.000000000 +0200 @@ -20,7 +20,7 @@ // Boston, MA 02111-1307, USA. -namespace GLib { +namespace Gst.GLib { using System; using System.Runtime.InteropServices; diff -Naur glib/Opaque.cs glib-sharp/Opaque.cs --- glib/Opaque.cs 2009-01-29 17:26:09.000000000 +0100 +++ glib-sharp/Opaque.cs 2009-09-03 10:41:01.000000000 +0200 @@ -24,7 +24,7 @@ // Boston, MA 02111-1307, USA. -namespace GLib { +namespace Gst.GLib { using System; using System.Collections; diff -Naur glib/ParamSpec.cs glib-sharp/ParamSpec.cs --- glib/ParamSpec.cs 2009-09-02 22:17:37.000000000 +0200 +++ glib-sharp/ParamSpec.cs 2009-09-03 10:41:01.000000000 +0200 @@ -19,50 +19,49 @@ // Boston, MA 02111-1307, USA. -namespace GLib { +namespace Gst.GLib { using System; using System.Runtime.InteropServices; internal enum ParamFlags { - None = 0, - Readable = 1 << 0, - Writable = 1 << 1, + None = 0, + Readable = 1 << 0, + Writable = 1 << 1, + Construct = 1 << 2, + ConstructOnly = 1 << 3, } public class ParamSpec { IntPtr handle; - public ParamSpec (string name, string nick, string blurb, GType type, bool readable, bool writable) - { - ParamFlags pflags = ParamFlags.None; - if (readable) pflags |= ParamFlags.Readable; - if (writable) pflags |= ParamFlags.Writable; + private static IntPtr CreateParamSpec (string name, string nick, string blurb, GType type, ParamFlags pflags) { int flags = (int) pflags; + IntPtr ret; IntPtr p_name = GLib.Marshaller.StringToPtrGStrdup (name); IntPtr p_nick = GLib.Marshaller.StringToPtrGStrdup (nick); IntPtr p_blurb = GLib.Marshaller.StringToPtrGStrdup (blurb); if (type == GType.Char) - handle = g_param_spec_char (p_name, p_nick, p_blurb, SByte.MinValue, SByte.MaxValue, 0, flags); + ret = g_param_spec_char (p_name, p_nick, p_blurb, SByte.MinValue, SByte.MaxValue, 0, flags); else if (type == GType.UChar) - handle = g_param_spec_uchar (p_name, p_nick, p_blurb, Byte.MinValue, Byte.MaxValue, 0, flags); + ret = g_param_spec_uchar (p_name, p_nick, p_blurb, Byte.MinValue, Byte.MaxValue, 0, flags); else if (type == GType.Boolean) - handle = g_param_spec_boolean (p_name, p_nick, p_blurb, false, flags); + ret = g_param_spec_boolean (p_name, p_nick, p_blurb, false, flags); else if (type == GType.Int) - handle = g_param_spec_int (p_name, p_nick, p_blurb, Int32.MinValue, Int32.MaxValue, 0, flags); + ret = g_param_spec_int (p_name, p_nick, p_blurb, Int32.MinValue, Int32.MaxValue, 0, flags); else if (type == GType.UInt) - handle = g_param_spec_uint (p_name, p_nick, p_blurb, 0, UInt32.MaxValue, 0, flags); + ret = g_param_spec_uint (p_name, p_nick, p_blurb, 0, UInt32.MaxValue, 0, flags); else if (type == GType.Long) - handle = g_param_spec_long (p_name, p_nick, p_blurb, IntPtr.Zero, IntPtr.Size == 4 ? new IntPtr (Int32.MaxValue) : new IntPtr (Int64.MaxValue), IntPtr.Zero, flags); + ret = g_param_spec_long (p_name, p_nick, p_blurb, IntPtr.Zero, IntPtr.Size == 4 ? new IntPtr (Int32.MaxValue) : new IntPtr (Int64.MaxValue), IntPtr.Zero, flags); else if (type == GType.ULong) - handle = g_param_spec_ulong (p_name, p_nick, p_blurb, UIntPtr.Zero, UIntPtr.Size == 4 ? new UIntPtr (UInt32.MaxValue) : new UIntPtr (UInt64.MaxValue), UIntPtr.Zero, flags); + ret = g_param_spec_ulong (p_name, p_nick, p_blurb, UIntPtr.Zero, UIntPtr.Size == 4 ? new UIntPtr (UInt32.MaxValue) : new UIntPtr (UInt64.MaxValue), UIntPtr.Zero, flags); else if (type == GType.Int64) - handle = g_param_spec_int64 (p_name, p_nick, p_blurb, Int64.MinValue, Int64.MaxValue, 0, flags); + ret = g_param_spec_int64 (p_name, p_nick, p_blurb, Int64.MinValue, Int64.MaxValue, 0, flags); else if (type == GType.UInt64) - handle = g_param_spec_uint64 (p_name, p_nick, p_blurb, 0, UInt64.MaxValue, 0, flags); + ret = g_param_spec_uint64 (p_name, p_nick, p_blurb, 0, UInt64.MaxValue, 0, flags); /* else if (type == GType.Enum) else if (type == GType.Flags) @@ -70,25 +69,40 @@ * Both g_param_spec_enum and g_param_spec_flags expect default property values and the members of the enum seemingly cannot be enumerated */ else if (type == GType.Float) - handle = g_param_spec_float (p_name, p_nick, p_blurb, Single.MinValue, Single.MaxValue, 0.0f, flags); + ret = g_param_spec_float (p_name, p_nick, p_blurb, Single.MinValue, Single.MaxValue, 0.0f, flags); else if (type == GType.Double) - handle = g_param_spec_double (p_name, p_nick, p_blurb, Double.MinValue, Double.MaxValue, 0.0, flags); + ret = g_param_spec_double (p_name, p_nick, p_blurb, Double.MinValue, Double.MaxValue, 0.0, flags); else if (type == GType.String) - handle = g_param_spec_string (p_name, p_nick, p_blurb, IntPtr.Zero, flags); + ret = g_param_spec_string (p_name, p_nick, p_blurb, IntPtr.Zero, flags); else if (type == GType.Pointer) - handle = g_param_spec_pointer (p_name, p_nick, p_blurb, flags); + ret = g_param_spec_pointer (p_name, p_nick, p_blurb, flags); else if (type.Val == g_gtype_get_type ()) - handle = g_param_spec_gtype (p_name, p_nick, p_blurb, GType.None.Val, flags); + ret = g_param_spec_gtype (p_name, p_nick, p_blurb, GType.None.Val, flags); else if (g_type_is_a (type.Val, GType.Boxed.Val)) - handle = g_param_spec_boxed (p_name, p_nick, p_blurb, type.Val, flags); + ret = g_param_spec_boxed (p_name, p_nick, p_blurb, type.Val, flags); else if (g_type_is_a (type.Val, GType.Object.Val)) - handle = g_param_spec_object (p_name, p_nick, p_blurb, type.Val, flags); + ret = g_param_spec_object (p_name, p_nick, p_blurb, type.Val, flags); else throw new ArgumentException ("type"); GLib.Marshaller.Free (p_name); GLib.Marshaller.Free (p_nick); GLib.Marshaller.Free (p_blurb); + + return ret; + } + + internal ParamSpec (string name, string nick, string blurb, GType type, ParamFlags pflags) { + handle = CreateParamSpec (name, nick, blurb, type, pflags); + } + + public ParamSpec (string name, string nick, string blurb, GType type, bool readable, bool writable) + { + ParamFlags pflags = ParamFlags.None; + if (readable) pflags |= ParamFlags.Readable; + if (writable) pflags |= ParamFlags.Writable; + + handle = CreateParamSpec (name, nick, blurb, type, pflags); } public ParamSpec (IntPtr native) @@ -107,6 +121,13 @@ } } + public string Name { + get { + GParamSpec spec = (GParamSpec) Marshal.PtrToStructure (Handle, typeof (GParamSpec)); + return GLib.Marshaller.Utf8PtrToString (spec.name); + } + } + struct GTypeInstance { IntPtr g_class; } @@ -114,7 +135,7 @@ struct GParamSpec { GTypeInstance g_type_instance; - IntPtr name; + public IntPtr name; ParamFlags flags; public IntPtr value_type; IntPtr owner_type; diff -Naur glib/Priority.cs glib-sharp/Priority.cs --- glib/Priority.cs 2009-05-03 21:34:22.000000000 +0200 +++ glib-sharp/Priority.cs 2009-09-03 10:41:01.000000000 +0200 @@ -19,7 +19,7 @@ // Free Software Foundation, Inc., 59 Temple Place - Suite 330, // Boston, MA 02111-1307, USA. -namespace GLib { +namespace Gst.GLib { public enum Priority { High = -100, diff -Naur glib/PropertyAttribute.cs glib-sharp/PropertyAttribute.cs --- glib/PropertyAttribute.cs 2008-06-06 18:55:00.000000000 +0200 +++ glib-sharp/PropertyAttribute.cs 2009-09-03 10:41:01.000000000 +0200 @@ -17,7 +17,7 @@ // Boston, MA 02111-1307, USA. -namespace GLib { +namespace Gst.GLib { using System; diff -Naur glib/PtrArray.cs glib-sharp/PtrArray.cs --- glib/PtrArray.cs 2009-09-02 22:17:37.000000000 +0200 +++ glib-sharp/PtrArray.cs 2009-09-03 10:41:01.000000000 +0200 @@ -19,7 +19,7 @@ // Boston, MA 02111-1307, USA. -namespace GLib { +namespace Gst.GLib { using System; using System.Collections; diff -Naur glib/SignalArgs.cs glib-sharp/SignalArgs.cs --- glib/SignalArgs.cs 2004-06-25 20:42:19.000000000 +0200 +++ glib-sharp/SignalArgs.cs 2009-09-03 10:41:01.000000000 +0200 @@ -20,7 +20,7 @@ // Boston, MA 02111-1307, USA. -namespace GLib { +namespace Gst.GLib { using System; using System.Collections; diff -Naur glib/SignalAttribute.cs glib-sharp/SignalAttribute.cs --- glib/SignalAttribute.cs 2005-10-08 23:08:04.000000000 +0200 +++ glib-sharp/SignalAttribute.cs 2009-09-03 10:41:01.000000000 +0200 @@ -20,7 +20,7 @@ // Boston, MA 02111-1307, USA. -namespace GLib { +namespace Gst.GLib { using System; diff -Naur glib/SignalCallback.cs glib-sharp/SignalCallback.cs --- glib/SignalCallback.cs 2009-09-02 22:17:37.000000000 +0200 +++ glib-sharp/SignalCallback.cs 2009-09-03 10:41:01.000000000 +0200 @@ -20,7 +20,7 @@ // Boston, MA 02111-1307, USA. -namespace GLib { +namespace Gst.GLib { using System; using System.Collections; using System.Runtime.InteropServices; diff -Naur glib/SignalClosure.cs glib-sharp/SignalClosure.cs --- glib/SignalClosure.cs 2009-09-02 22:17:37.000000000 +0200 +++ glib-sharp/SignalClosure.cs 2009-09-03 10:41:01.000000000 +0200 @@ -19,7 +19,7 @@ // Boston, MA 02111-1307, USA. -namespace GLib { +namespace Gst.GLib { using System; using System.Collections; diff -Naur glib/Signal.cs glib-sharp/Signal.cs --- glib/Signal.cs 2009-09-02 22:17:37.000000000 +0200 +++ glib-sharp/Signal.cs 2009-09-03 10:41:01.000000000 +0200 @@ -20,7 +20,7 @@ // Boston, MA 02111-1307, USA. -namespace GLib { +namespace Gst.GLib { using System; using System.Collections; diff -Naur glib/SList.cs glib-sharp/SList.cs --- glib/SList.cs 2009-09-02 22:17:37.000000000 +0200 +++ glib-sharp/SList.cs 2009-09-03 10:41:01.000000000 +0200 @@ -19,7 +19,7 @@ // Boston, MA 02111-1307, USA. -namespace GLib { +namespace Gst.GLib { using System; using System.Runtime.InteropServices; diff -Naur glib/Source.cs glib-sharp/Source.cs --- glib/Source.cs 2009-09-02 22:17:37.000000000 +0200 +++ glib-sharp/Source.cs 2009-09-03 10:41:01.000000000 +0200 @@ -19,7 +19,7 @@ // Boston, MA 02111-1307, USA. -namespace GLib { +namespace Gst.GLib { using System; using System.Collections; diff -Naur glib/Spawn.cs glib-sharp/Spawn.cs --- glib/Spawn.cs 2009-09-02 22:17:37.000000000 +0200 +++ glib-sharp/Spawn.cs 2009-09-03 10:41:01.000000000 +0200 @@ -19,7 +19,7 @@ // Boston, MA 02111-1307, USA. -namespace GLib { +namespace Gst.GLib { using System; using System.Runtime.InteropServices; diff -Naur glib/Thread.cs glib-sharp/Thread.cs --- glib/Thread.cs 2009-09-02 22:17:37.000000000 +0200 +++ glib-sharp/Thread.cs 2009-09-03 10:59:53.000000000 +0200 @@ -19,7 +19,7 @@ // Boston, MA 02111-1307, USA. -namespace GLib +namespace Gst.GLib { using System; using System.Runtime.InteropServices; @@ -36,13 +36,13 @@ g_thread_init (IntPtr.Zero); } - [DllImport("glibsharpglue-3")] - static extern bool glibsharp_g_thread_supported (); + [DllImport("gstreamersharpglue-0.10")] + static extern bool gstglibsharp_g_thread_supported (); public static bool Supported { get { - return glibsharp_g_thread_supported (); + return gstglibsharp_g_thread_supported (); } } } diff -Naur glib/Timeout.cs glib-sharp/Timeout.cs --- glib/Timeout.cs 2009-09-02 22:17:37.000000000 +0200 +++ glib-sharp/Timeout.cs 2009-09-03 10:41:01.000000000 +0200 @@ -22,7 +22,7 @@ // Boston, MA 02111-1307, USA. -namespace GLib { +namespace Gst.GLib { using System; using System.Collections; diff -Naur glib/ToggleRef.cs glib-sharp/ToggleRef.cs --- glib/ToggleRef.cs 2009-09-02 22:17:37.000000000 +0200 +++ glib-sharp/ToggleRef.cs 2009-09-03 10:41:01.000000000 +0200 @@ -19,7 +19,7 @@ // Boston, MA 02111-1307, USA. -namespace GLib { +namespace Gst.GLib { using System; using System.Collections; diff -Naur glib/TypeConverter.cs glib-sharp/TypeConverter.cs --- glib/TypeConverter.cs 2005-05-04 18:54:24.000000000 +0200 +++ glib-sharp/TypeConverter.cs 2009-09-03 10:41:01.000000000 +0200 @@ -19,7 +19,7 @@ // Boston, MA 02111-1307, USA. -namespace GLib { +namespace Gst.GLib { using System; public class TypeConverter { diff -Naur glib/TypeFundamentals.cs glib-sharp/TypeFundamentals.cs --- glib/TypeFundamentals.cs 2004-07-09 17:25:39.000000000 +0200 +++ glib-sharp/TypeFundamentals.cs 2009-09-03 10:41:01.000000000 +0200 @@ -19,7 +19,7 @@ // Boston, MA 02111-1307, USA. -namespace GLib { +namespace Gst.GLib { public enum TypeFundamentals { TypeInvalid = 0 << 2, diff -Naur glib/TypeInitializerAttribute.cs glib-sharp/TypeInitializerAttribute.cs --- glib/TypeInitializerAttribute.cs 2007-09-07 16:40:46.000000000 +0200 +++ glib-sharp/TypeInitializerAttribute.cs 2009-09-03 10:41:01.000000000 +0200 @@ -19,7 +19,7 @@ // Boston, MA 02111-1307, USA. -namespace GLib { +namespace Gst.GLib { using System; diff -Naur glib/UnwrappedObject.cs glib-sharp/UnwrappedObject.cs --- glib/UnwrappedObject.cs 2005-07-22 20:36:50.000000000 +0200 +++ glib-sharp/UnwrappedObject.cs 2009-09-03 10:41:01.000000000 +0200 @@ -19,7 +19,7 @@ // Boston, MA 02111-1307, USA. -namespace GLib { +namespace Gst.GLib { using System; using System.Runtime.InteropServices; diff -Naur glib/ValueArray.cs glib-sharp/ValueArray.cs --- glib/ValueArray.cs 2009-09-02 22:17:37.000000000 +0200 +++ glib-sharp/ValueArray.cs 2009-09-03 10:41:01.000000000 +0200 @@ -19,7 +19,7 @@ // Boston, MA 02111-1307, USA. -namespace GLib { +namespace Gst.GLib { using System; using System.Collections; diff -Naur glib/Value.cs glib-sharp/Value.cs --- glib/Value.cs 2009-09-02 22:17:37.000000000 +0200 +++ glib-sharp/Value.cs 2009-09-03 10:41:01.000000000 +0200 @@ -20,7 +20,7 @@ // Boston, MA 02111-1307, USA. -namespace GLib { +namespace Gst.GLib { using System; using System.Collections;