Change GLib.* to Gst.GLib.* and register managed GTypes with a different name prefix

This prevents all remaining conflicts between internal and external glib-sharp.
This commit is contained in:
Sebastian Dröge 2009-08-09 09:58:50 +02:00
parent 265cb43fa7
commit 1458658bec
35 changed files with 223 additions and 223 deletions

View file

@ -1,4 +1,4 @@
// GLib.Argv.cs : Argv marshaling class
// Gst.GLib.Argv.cs : Argv marshaling class
//
// Author: Mike Kestner <mkestner@novell.com>
//

View file

@ -56,8 +56,8 @@ namespace Gst.GLib {
// currently only GObjects store
// callbacks over the long-term
if (o is GLib.Object) {
AddDestroyNotify ((GLib.Object) o);
if (o is Gst.GLib.Object) {
AddDestroyNotify ((Gst.GLib.Object) o);
}
} else {
// If o is null, we cannot ask for a destroy
@ -75,7 +75,7 @@ namespace Gst.GLib {
[DllImport("libgobject-2.0-0.dll")]
private static extern void g_object_set_data_full (IntPtr obj, IntPtr name, IntPtr data, DestroyNotify destroy);
private void AddDestroyNotify (GLib.Object o) {
private void AddDestroyNotify (Gst.GLib.Object o) {
// This is a bit of an ugly hack. There is no
// way of getting a destroy notification
// explicitly, so we set some data and ask

View file

@ -1,4 +1,4 @@
// GLib.DestroyNotify.cs - internal DestroyNotify helper
// Gst.GLib.DestroyNotify.cs - internal DestroyNotify helper
//
// Author: Mike Kestner <mkestner@novell.com>
//

View file

@ -24,7 +24,7 @@ namespace Gst.GLib {
using System;
using System.Runtime.InteropServices;
[Obsolete ("Replaced by direct enum type casts to/from GLib.Value")]
[Obsolete ("Replaced by direct enum type casts to/from Gst.GLib.Value")]
public class EnumWrapper {
int val;
public bool flags;

View file

@ -1,4 +1,4 @@
// GLib.Application.cs - static Application class
// Gst.GLib.Application.cs - static Application class
//
// Authors: Mike Kestner <mkestner@novell.com>
//
@ -53,7 +53,7 @@ namespace Gst.GLib {
{
if (UnhandledException == null) {
Console.Error.WriteLine ("Exception in Gtk# callback delegate");
Console.Error.WriteLine (" Note: Applications can use GLib.ExceptionManager.UnhandledException to handle the exception.");
Console.Error.WriteLine (" Note: Applications can use Gst.GLib.ExceptionManager.UnhandledException to handle the exception.");
Console.Error.WriteLine (e);
Console.Error.WriteLine (new System.Diagnostics.StackTrace (true));
Environment.Exit (1);

View file

@ -1,4 +1,4 @@
// GLib.FileUtils.cs - GFileUtils class implementation
// Gst.GLib.FileUtils.cs - GFileUtils class implementation
//
// Author: Martin Baulig <martin@gnome.org>
//

View file

@ -1,4 +1,4 @@
// GLib.GString.cs : Marshaler for GStrings
// Gst.GLib.GString.cs : Marshaler for GStrings
//
// Author: Mike Kestner <mkestner@ximian.com>
//
@ -23,7 +23,7 @@ namespace Gst.GLib {
using System;
using System.Runtime.InteropServices;
public class GString : GLib.IWrapper {
public class GString : Gst.GLib.IWrapper {
IntPtr handle;

View file

@ -1,4 +1,4 @@
// GLib.Type.cs - GLib GType class implementation
// Gst.GLib.Type.cs - GLib GType class implementation
//
// Author: Mike Kestner <mkestner@speakeasy.net>
//
@ -29,7 +29,7 @@ namespace Gst.GLib {
using System.Runtime.InteropServices;
using System.Text;
public delegate System.Type TypeResolutionHandler (GLib.GType gtype, string gtype_name);
public delegate System.Type TypeResolutionHandler (Gst.GLib.GType gtype, string gtype_name);
[StructLayout(LayoutKind.Sequential)]
public struct GType {
@ -103,8 +103,8 @@ namespace Gst.GLib {
static GType ()
{
if (!GLib.Thread.Supported)
GLib.Thread.Init ();
if (!Gst.GLib.Thread.Supported)
Gst.GLib.Thread.Init ();
g_type_init ();
@ -119,7 +119,7 @@ namespace Gst.GLib {
Register (GType.Double, typeof (double));
Register (GType.String, typeof (string));
Register (GType.Pointer, typeof (IntPtr));
Register (GType.Object, typeof (GLib.Object));
Register (GType.Object, typeof (Gst.GLib.Object));
Register (GType.Pointer, typeof (IntPtr));
// One-way mapping
@ -135,8 +135,8 @@ namespace Gst.GLib {
return (GType)gtypes[type];
}
if (type.IsSubclassOf (typeof (GLib.Object))) {
gtype = GLib.Object.LookupGType (type);
if (type.IsSubclassOf (typeof (Gst.GLib.Object))) {
gtype = Gst.GLib.Object.LookupGType (type);
Register (gtype, type);
return gtype;
}
@ -148,7 +148,7 @@ namespace Gst.GLib {
GTypeAttribute gattr = (GTypeAttribute)Attribute.GetCustomAttribute (type, typeof (GTypeAttribute), false);
pi = gattr.WrapperType.GetProperty ("GType", BindingFlags.Public | BindingFlags.Static);
gtype = (GType) pi.GetValue (null, null);
} else if (type.IsSubclassOf (typeof (GLib.Opaque)))
} else if (type.IsSubclassOf (typeof (Gst.GLib.Opaque)))
gtype = GType.Pointer;
else
gtype = ManagedValue.GType;
@ -162,7 +162,7 @@ namespace Gst.GLib {
for (int i = 1; i < cname.Length; i++) {
if (System.Char.IsUpper (cname[i])) {
if (i == 1 && cname [0] == 'G')
return "GLib." + cname.Substring (1);
return "Gst.GLib." + cname.Substring (1);
else
return cname.Substring (0, i) + "." + cname.Substring (i);
}
@ -193,7 +193,7 @@ namespace Gst.GLib {
string native_name = Marshaller.Utf8PtrToString (g_type_name (typeid));
if (ResolveType != null) {
GLib.GType gt = new GLib.GType (typeid);
Gst.GLib.GType gt = new Gst.GLib.GType (typeid);
Delegate[] invocation_list = ResolveType.GetInvocationList ();
foreach (Delegate d in invocation_list) {
@ -306,7 +306,7 @@ namespace Gst.GLib {
public GType ThresholdType {
get {
GLib.GType curr_type = this;
Gst.GLib.GType curr_type = this;
while (curr_type.ToString ().StartsWith ("__gtksharp_")) {
curr_type = curr_type.BaseType;
}
@ -357,14 +357,14 @@ namespace Gst.GLib {
{
GType parent_gtype = LookupGObjectType (t.BaseType);
string name = BuildEscapedName (t);
IntPtr native_name = GLib.Marshaller.StringToPtrGStrdup (name);
IntPtr native_name = Gst.GLib.Marshaller.StringToPtrGStrdup (name);
GTypeQuery query;
g_type_query (parent_gtype.Val, out query);
GTypeInfo info = new GTypeInfo ();
info.class_size = (ushort) query.class_size;
info.instance_size = (ushort) query.instance_size;
GType gtype = new GType (g_type_register_static (parent_gtype.Val, native_name, ref info, 0));
GLib.Marshaller.Free (native_name);
Gst.GLib.Marshaller.Free (native_name);
Register (gtype, t);
return gtype;
}
@ -380,7 +380,7 @@ namespace Gst.GLib {
if (pi != null)
return (GType) pi.GetValue (null, null);
return GLib.Object.RegisterGType (t);
return Gst.GLib.Object.RegisterGType (t);
}
internal static IntPtr ValFromInstancePtr (IntPtr handle)

View file

@ -1,4 +1,4 @@
// GLib.Global.cs - Global glib properties and methods.
// Gst.GLib.Global.cs - Global glib properties and methods.
//
// Author: Andres G. Aragoneses <aaragoneses@novell.com>
//
@ -33,12 +33,12 @@ namespace Gst.GLib {
public static string ProgramName {
get {
return GLib.Marshaller.PtrToStringGFree(g_get_prgname());
return Gst.GLib.Marshaller.PtrToStringGFree(g_get_prgname());
}
set {
IntPtr native_name = GLib.Marshaller.StringToPtrGStrdup (value);
IntPtr native_name = Gst.GLib.Marshaller.StringToPtrGStrdup (value);
g_set_prgname (native_name);
GLib.Marshaller.Free (native_name);
Gst.GLib.Marshaller.Free (native_name);
}
}
@ -50,12 +50,12 @@ namespace Gst.GLib {
public static string ApplicationName {
get {
return GLib.Marshaller.PtrToStringGFree(g_get_application_name());
return Gst.GLib.Marshaller.PtrToStringGFree(g_get_application_name());
}
set {
IntPtr native_name = GLib.Marshaller.StringToPtrGStrdup (value);
IntPtr native_name = Gst.GLib.Marshaller.StringToPtrGStrdup (value);
g_set_application_name (native_name);
GLib.Marshaller.Free (native_name);
Gst.GLib.Marshaller.Free (native_name);
}
}

View file

@ -1,4 +1,4 @@
// GLib.Idle.cs - Idle class implementation
// Gst.GLib.Idle.cs - Idle class implementation
//
// Author(s):
// Mike Kestner <mkestner@speakeasy.net>

View file

@ -34,7 +34,7 @@ namespace Gst.GLib {
[Obsolete]
protected InitiallyUnowned (GType gtype) : base (gtype) {}
public new static GLib.GType GType {
public new static Gst.GLib.GType GType {
get {
return GType.Object;
}

View file

@ -26,7 +26,7 @@ namespace Gst.GLib {
using System.Collections;
using System.Runtime.InteropServices;
public abstract class ListBase : IDisposable, ICollection, GLib.IWrapper, ICloneable {
public abstract class ListBase : IDisposable, ICollection, Gst.GLib.IWrapper, ICloneable {
private IntPtr list_ptr = IntPtr.Zero;
private int length = -1;
@ -159,10 +159,10 @@ namespace Gst.GLib {
ret = Marshaller.FilenamePtrToString (data);
else if (element_type == typeof (IntPtr))
ret = data;
else if (element_type.IsSubclassOf (typeof (GLib.Object)))
ret = GLib.Object.GetObject (data, false);
else if (element_type.IsSubclassOf (typeof (GLib.Opaque)))
ret = GLib.Opaque.GetOpaque (data, element_type, elements_owned);
else if (element_type.IsSubclassOf (typeof (Gst.GLib.Object)))
ret = Gst.GLib.Object.GetObject (data, false);
else if (element_type.IsSubclassOf (typeof (Gst.GLib.Opaque)))
ret = Gst.GLib.Opaque.GetOpaque (data, element_type, elements_owned);
else if (element_type == typeof (int))
ret = (int) data;
else if (element_type.IsValueType)
@ -175,7 +175,7 @@ namespace Gst.GLib {
ret = Activator.CreateInstance (element_type, new object[] {data});
} else if (Object.IsObject (data))
ret = GLib.Object.GetObject (data, false);
ret = Gst.GLib.Object.GetObject (data, false);
return ret;
}
@ -190,10 +190,10 @@ namespace Gst.GLib {
{
if (elements_owned)
for (uint i = 0; i < Count; i++)
if (typeof (GLib.Object).IsAssignableFrom (element_type))
if (typeof (Gst.GLib.Object).IsAssignableFrom (element_type))
g_object_unref (NthData (i));
else if (typeof (GLib.Opaque).IsAssignableFrom (element_type))
GLib.Opaque.GetOpaque (NthData (i), element_type, true).Dispose ();
else if (typeof (Gst.GLib.Opaque).IsAssignableFrom (element_type))
Gst.GLib.Opaque.GetOpaque (NthData (i), element_type, true).Dispose ();
else
g_free (NthData (i));

View file

@ -1,4 +1,4 @@
// GLib.MainContext.cs - mainContext class implementation
// Gst.GLib.MainContext.cs - mainContext class implementation
//
// Author: Radek Doulik <rodo@matfyz.cz>
//

View file

@ -1,4 +1,4 @@
// GLib.MainLoop.cs - g_main_loop class implementation
// Gst.GLib.MainLoop.cs - g_main_loop class implementation
//
// Author: Jeroen Zwartepoorte <jeroen@xs4all.nl>
//

View file

@ -1,4 +1,4 @@
// GLib.ManagedValue.cs : Managed types boxer
// Gst.GLib.ManagedValue.cs : Managed types boxer
//
// Author: Rachel Hestilow <hestilow@ximian.com>
//
@ -77,7 +77,7 @@ namespace Gst.GLib {
free = new FreeFunc (Free);
IntPtr name = Marshaller.StringToPtrGStrdup ("GstGLibSharpValue");
boxed_type = new GLib.GType (g_boxed_type_register_static (name, copy, free));
boxed_type = new Gst.GLib.GType (g_boxed_type_register_static (name, copy, free));
Marshaller.Free (name);
}

View file

@ -56,7 +56,7 @@ namespace Gst.GLib {
IntPtr dummy, error;
IntPtr utf8 = g_filename_to_utf8 (ptr, -1, IntPtr.Zero, out dummy, out error);
if (error != IntPtr.Zero)
throw new GLib.GException (error);
throw new Gst.GLib.GException (error);
return Utf8PtrToString (utf8);
}
@ -200,9 +200,9 @@ namespace Gst.GLib {
string[] members = new string[count];
for (int i = 0; i < count; ++i) {
IntPtr s = Marshal.ReadIntPtr (string_array, i * IntPtr.Size);
members[i] = GLib.Marshaller.PtrToStringGFree (s);
members[i] = Gst.GLib.Marshaller.PtrToStringGFree (s);
}
GLib.Marshaller.Free (string_array);
Gst.GLib.Marshaller.Free (string_array);
return members;
}
@ -262,7 +262,7 @@ namespace Gst.GLib {
return buf;
}
[Obsolete ("Use GLib.Argv instead to avoid leaks.")]
[Obsolete ("Use Gst.GLib.Argv instead to avoid leaks.")]
public static IntPtr ArgvToArrayPtr (string[] args)
{
if (args.Length == 0)
@ -303,7 +303,7 @@ namespace Gst.GLib {
return args;
}
[Obsolete ("Use GLib.Argv instead to avoid leaks.")]
[Obsolete ("Use Gst.GLib.Argv instead to avoid leaks.")]
public static string[] ArrayPtrToArgv (IntPtr array, int argc)
{
if (argc == 0)
@ -379,10 +379,10 @@ namespace Gst.GLib {
{
Type array_type = elem_type == typeof (ListBase.FilenameString) ? typeof (string) : elem_type;
ListBase list;
if (list_type == typeof(GLib.List))
list = new GLib.List (list_ptr, elem_type, owned, elements_owned);
if (list_type == typeof(Gst.GLib.List))
list = new Gst.GLib.List (list_ptr, elem_type, owned, elements_owned);
else
list = new GLib.SList (list_ptr, elem_type, owned, elements_owned);
list = new Gst.GLib.SList (list_ptr, elem_type, owned, elements_owned);
using (list)
return ListToArray (list, array_type);
@ -390,7 +390,7 @@ namespace Gst.GLib {
public static Array PtrArrayToArray (IntPtr list_ptr, bool owned, bool elements_owned, Type elem_type)
{
GLib.PtrArray array = new GLib.PtrArray (list_ptr, elem_type, owned, elements_owned);
Gst.GLib.PtrArray array = new Gst.GLib.PtrArray (list_ptr, elem_type, owned, elements_owned);
Array ret = Array.CreateInstance (elem_type, array.Count);
array.CopyTo (ret, 0);
array.Dispose ();
@ -403,7 +403,7 @@ namespace Gst.GLib {
if (list.Count > 0)
list.CopyTo (result, 0);
if (type.IsSubclassOf (typeof (GLib.Opaque)))
if (type.IsSubclassOf (typeof (Gst.GLib.Opaque)))
list.elements_owned = false;
return result;

View file

@ -21,7 +21,7 @@ namespace Gst.GLib {
public delegate void NotifyHandler (object o, NotifyArgs args);
public class NotifyArgs : GLib.SignalArgs {
public class NotifyArgs : Gst.GLib.SignalArgs {
[DllImport("libgobject-2.0-0.dll")]
static extern IntPtr g_param_spec_get_name (IntPtr pspec);

View file

@ -118,7 +118,7 @@ namespace Gst.GLib {
if (!owned_ref)
g_object_ref (o);
obj = GLib.ObjectManager.CreateObject(o);
obj = Gst.GLib.ObjectManager.CreateObject(o);
if (obj == null) {
g_object_unref (o);
return null;
@ -163,7 +163,7 @@ namespace Gst.GLib {
m.Invoke (null, parms);
}
for (Type curr = t; curr != typeof(GLib.Object); curr = curr.BaseType) {
for (Type curr = t; curr != typeof(Gst.GLib.Object); curr = curr.BaseType) {
if (curr.Assembly.IsDefined (typeof (IgnoreClassInitializersAttribute), false))
continue;
@ -213,7 +213,7 @@ namespace Gst.GLib {
static Hashtable class_structs;
static GObjectClass GetClassStruct (GLib.GType gtype, bool use_cache)
static GObjectClass GetClassStruct (Gst.GLib.GType gtype, bool use_cache)
{
if (class_structs == null)
class_structs = new Hashtable ();
@ -229,7 +229,7 @@ namespace Gst.GLib {
}
}
static void OverrideClassStruct (GLib.GType gtype, GObjectClass class_struct)
static void OverrideClassStruct (Gst.GLib.GType gtype, GObjectClass class_struct)
{
IntPtr class_ptr = gtype.ClassPtr;
Marshal.StructureToPtr (class_struct, class_ptr, false);
@ -266,7 +266,7 @@ namespace Gst.GLib {
static IntPtr constructor_cb (IntPtr gtype, uint n_construct_properties, IntPtr construct_properties)
{
GType type = new GLib.GType (gtype);
GType type = new Gst.GLib.GType (gtype);
IntPtr instance = GetClassStruct (type.ThresholdType, 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)));
@ -274,11 +274,11 @@ namespace Gst.GLib {
GObjectConstructParam cparam = (GObjectConstructParam) Marshal.PtrToStructure (p, typeof (GObjectConstructParam));
ParamSpec pspec = new ParamSpec (cparam.pspec);
GLib.Value val = (Value) Marshal.PtrToStructure (cparam.value, typeof (Value));
Gst.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;
Object o = (Gst.GLib.Object) gch.Target;
o.Raw = instance;
}
}
@ -287,19 +287,19 @@ namespace Gst.GLib {
}
static ConstructedDelegate Constructed_cb = new ConstructedDelegate (constructed_cb);
[GLib.CDeclCallback]
[Gst.GLib.CDeclCallback]
delegate void ConstructedDelegate (IntPtr o);
static void constructed_cb (IntPtr o)
{
GLib.Object __obj = GLib.Object.GetObject (o, false) as GLib.Object;
Gst.GLib.Object __obj = Gst.GLib.Object.GetObject (o, false) as Gst.GLib.Object;
ConstructedDelegate unmanaged = GetClassStruct (__obj.LookupGType ().ThresholdType, 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 set_prop_dummy_cb (IntPtr GObject, uint property_id, ref Gst.GLib.Value value, IntPtr pspec) {}
static void AddProperties (GType gtype, System.Type t)
{
@ -322,7 +322,7 @@ namespace Gst.GLib {
foreach (PropertyInfo pinfo in t.GetProperties (BindingFlags.Instance | BindingFlags.Public | BindingFlags.DeclaredOnly)) {
foreach (object attr in pinfo.GetCustomAttributes (typeof (PropertyAttribute), false)) {
if(pinfo.GetIndexParameters().Length > 0)
throw(new InvalidOperationException(String.Format("GLib.RegisterPropertyAttribute cannot be applied to property {0} of type {1} because the property expects one or more indexed parameters", pinfo.Name, t.FullName)));
throw(new InvalidOperationException(String.Format("Gst.GLib.RegisterPropertyAttribute cannot be applied to property {0} of type {1} because the property expects one or more indexed parameters", pinfo.Name, t.FullName)));
PropertyAttribute property_attr = attr as PropertyAttribute;
if (!handlers_overridden) {
@ -335,21 +335,21 @@ namespace Gst.GLib {
Properties.Add (param_spec, pinfo);
idx++;
} catch (ArgumentException) {
throw new InvalidOperationException (String.Format ("GLib.PropertyAttribute cannot be applied to property {0} of type {1} because the return type of the property is not supported", pinfo.Name, t.FullName));
throw new InvalidOperationException (String.Format ("Gst.GLib.PropertyAttribute cannot be applied to property {0} of type {1} because the return type of the property is not supported", pinfo.Name, t.FullName));
}
}
}
}
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
delegate void GetPropertyDelegate (IntPtr GObject, uint property_id, ref GLib.Value value, IntPtr pspec);
delegate void GetPropertyDelegate (IntPtr GObject, uint property_id, ref Gst.GLib.Value value, IntPtr pspec);
static void GetPropertyCallback (IntPtr handle, uint property_id, ref GLib.Value value, IntPtr param_spec)
static void GetPropertyCallback (IntPtr handle, uint property_id, ref Gst.GLib.Value value, IntPtr param_spec)
{
if (!Properties.Contains (param_spec))
return;
GLib.Object obj = GLib.Object.GetObject (handle, false);
Gst.GLib.Object obj = Gst.GLib.Object.GetObject (handle, false);
value.Val = (Properties [param_spec] as PropertyInfo).GetValue (obj, new object [0]);
}
@ -363,14 +363,14 @@ namespace Gst.GLib {
}
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
delegate void SetPropertyDelegate (IntPtr GObject, uint property_id, ref GLib.Value value, IntPtr pspec);
delegate void SetPropertyDelegate (IntPtr GObject, uint property_id, ref Gst.GLib.Value value, IntPtr pspec);
static void SetPropertyCallback(IntPtr handle, uint property_id, ref GLib.Value value, IntPtr param_spec)
static void SetPropertyCallback(IntPtr handle, uint property_id, ref Gst.GLib.Value value, IntPtr param_spec)
{
if (!Properties.Contains (param_spec))
return;
GLib.Object obj = GLib.Object.GetObject (handle, false);
Gst.GLib.Object obj = Gst.GLib.Object.GetObject (handle, false);
(Properties [param_spec] as PropertyInfo).SetValue (obj, value.Val, new object [0]);
}
@ -416,7 +416,7 @@ namespace Gst.GLib {
if (Handle != IntPtr.Zero) {
GTypeInstance obj = (GTypeInstance) Marshal.PtrToStructure (Handle, typeof (GTypeInstance));
GTypeClass klass = (GTypeClass) Marshal.PtrToStructure (obj.g_class, typeof (GTypeClass));
return new GLib.GType (klass.gtype);
return new Gst.GLib.GType (klass.gtype);
} else {
return LookupGType (GetType ());
}
@ -434,7 +434,7 @@ namespace Gst.GLib {
protected Object ()
{
CreateNativeObject (new string [0], new GLib.Value [0]);
CreateNativeObject (new string [0], new Gst.GLib.Value [0]);
}
[DllImport("libgobject-2.0-0.dll")]
@ -448,28 +448,28 @@ namespace Gst.GLib {
struct GParameter {
public IntPtr name;
public GLib.Value val;
public Gst.GLib.Value val;
}
[DllImport("libgobject-2.0-0.dll")]
static extern IntPtr g_object_newv (IntPtr gtype, int n_params, GParameter[] parms);
protected virtual void CreateNativeObject (string[] names, GLib.Value[] vals)
protected virtual void CreateNativeObject (string[] names, Gst.GLib.Value[] vals)
{
GLib.GType gtype = LookupGType ();
Gst.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].name = Gst.GLib.Marshaller.StringToPtrGStrdup (names [i]);
parms [i].val = vals [i];
}
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);
parms[names.Length].name = Gst.GLib.Marshaller.StringToPtrGStrdup ("gtk-sharp-managed-instance");
parms[names.Length].val = new Gst.GLib.Value ((IntPtr) gch);
Raw = g_object_newv (gtype.Val, parms.Length, parms);
@ -479,7 +479,7 @@ namespace Gst.GLib {
}
foreach (GParameter p in parms)
GLib.Marshaller.Free (p.name);
Gst.GLib.Marshaller.Free (p.name);
}
protected virtual IntPtr Raw {
@ -505,7 +505,7 @@ namespace Gst.GLib {
}
}
public static GLib.GType GType {
public static Gst.GLib.GType GType {
get {
return GType.Object;
}
@ -517,7 +517,7 @@ namespace Gst.GLib {
}
}
internal GLib.GType NativeType {
internal Gst.GLib.GType NativeType {
get {
return LookupGType ();
}
@ -542,7 +542,7 @@ namespace Gst.GLib {
}
Hashtable before_signals;
[Obsolete ("Replaced by GLib.Signal marshaling mechanism.")]
[Obsolete ("Replaced by Gst.GLib.Signal marshaling mechanism.")]
protected internal Hashtable BeforeSignals {
get {
if (before_signals == null)
@ -552,7 +552,7 @@ namespace Gst.GLib {
}
Hashtable after_signals;
[Obsolete ("Replaced by GLib.Signal marshaling mechanism.")]
[Obsolete ("Replaced by Gst.GLib.Signal marshaling mechanism.")]
protected internal Hashtable AfterSignals {
get {
if (after_signals == null)
@ -562,7 +562,7 @@ namespace Gst.GLib {
}
EventHandlerList before_handlers;
[Obsolete ("Replaced by GLib.Signal marshaling mechanism.")]
[Obsolete ("Replaced by Gst.GLib.Signal marshaling mechanism.")]
protected EventHandlerList BeforeHandlers {
get {
if (before_handlers == null)
@ -572,7 +572,7 @@ namespace Gst.GLib {
}
EventHandlerList after_handlers;
[Obsolete ("Replaced by GLib.Signal marshaling mechanism.")]
[Obsolete ("Replaced by Gst.GLib.Signal marshaling mechanism.")]
protected EventHandlerList AfterHandlers {
get {
if (after_handlers == null)
@ -587,7 +587,7 @@ namespace Gst.GLib {
void NotifyCallback (IntPtr handle, IntPtr pspec, IntPtr gch)
{
try {
GLib.Signal sig = ((GCHandle) gch).Target as GLib.Signal;
Gst.GLib.Signal sig = ((GCHandle) gch).Target as Gst.GLib.Signal;
if (sig == null)
throw new Exception("Unknown signal GC handle received " + gch);
@ -595,7 +595,7 @@ namespace Gst.GLib {
args.Args = new object[1];
args.Args[0] = pspec;
NotifyHandler handler = (NotifyHandler) sig.Handler;
handler (GLib.Object.GetObject (handle), args);
handler (Gst.GLib.Object.GetObject (handle), args);
} catch (Exception e) {
ExceptionManager.RaiseUnhandledException (e, false);
}
@ -658,25 +658,25 @@ namespace Gst.GLib {
}
[DllImport("libgobject-2.0-0.dll")]
static extern void g_object_get_property (IntPtr obj, IntPtr name, ref GLib.Value val);
static extern void g_object_get_property (IntPtr obj, IntPtr name, ref Gst.GLib.Value val);
protected GLib.Value GetProperty (string name)
protected Gst.GLib.Value GetProperty (string name)
{
Value val = new Value (this, name);
IntPtr native_name = GLib.Marshaller.StringToPtrGStrdup (name);
IntPtr native_name = Gst.GLib.Marshaller.StringToPtrGStrdup (name);
g_object_get_property (Raw, native_name, ref val);
GLib.Marshaller.Free (native_name);
Gst.GLib.Marshaller.Free (native_name);
return val;
}
[DllImport("libgobject-2.0-0.dll")]
static extern void g_object_set_property (IntPtr obj, IntPtr name, ref GLib.Value val);
static extern void g_object_set_property (IntPtr obj, IntPtr name, ref Gst.GLib.Value val);
protected void SetProperty (string name, GLib.Value val)
protected void SetProperty (string name, Gst.GLib.Value val)
{
IntPtr native_name = GLib.Marshaller.StringToPtrGStrdup (name);
IntPtr native_name = Gst.GLib.Marshaller.StringToPtrGStrdup (name);
g_object_set_property (Raw, native_name, ref val);
GLib.Marshaller.Free (native_name);
Gst.GLib.Marshaller.Free (native_name);
}
[DllImport("libgobject-2.0-0.dll")]
@ -684,9 +684,9 @@ namespace Gst.GLib {
protected void Notify (string property_name)
{
IntPtr native_name = GLib.Marshaller.StringToPtrGStrdup (property_name);
IntPtr native_name = Gst.GLib.Marshaller.StringToPtrGStrdup (property_name);
g_object_notify (Handle, native_name);
GLib.Marshaller.Free (native_name);
Gst.GLib.Marshaller.Free (native_name);
}
protected static void OverrideVirtualMethod (GType gtype, string name, Delegate cb)
@ -695,7 +695,7 @@ namespace Gst.GLib {
}
[DllImport("libgobject-2.0-0.dll")]
protected static extern void g_signal_chain_from_overridden (IntPtr args, ref GLib.Value retval);
protected static extern void g_signal_chain_from_overridden (IntPtr args, ref Gst.GLib.Value retval);
[DllImport("libgobject-2.0-0.dll")]
static extern bool g_type_check_instance_is_a (IntPtr obj, IntPtr gtype);
@ -732,7 +732,7 @@ namespace Gst.GLib {
static Object ()
{
if (Environment.GetEnvironmentVariable ("GTK_SHARP_DEBUG") != null)
GLib.Log.SetLogHandler ("GLib-GObject", GLib.LogLevelFlags.All, new GLib.LogFunc (GLib.Log.PrintTraceLogFunction));
Gst.GLib.Log.SetLogHandler ("GLib-GObject", Gst.GLib.LogLevelFlags.All, new Gst.GLib.LogFunc (Gst.GLib.Log.PrintTraceLogFunction));
}
}
}

View file

@ -1,4 +1,4 @@
// GLib.ObjectManager.cs - GLib ObjectManager class implementation
// Gst.GLib.ObjectManager.cs - GLib ObjectManager class implementation
//
// Author: Mike Kestner <mkestner@speakeasy.net>
//
@ -30,7 +30,7 @@ namespace Gst.GLib {
static BindingFlags flags = BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance | BindingFlags.CreateInstance;
public static GLib.Object CreateObject (IntPtr raw)
public static Gst.GLib.Object CreateObject (IntPtr raw)
{
if (raw == IntPtr.Zero)
return null;
@ -40,11 +40,11 @@ namespace Gst.GLib {
if (type == null)
return null;
GLib.Object obj;
Gst.GLib.Object obj;
try {
obj = Activator.CreateInstance (type, flags, null, new object[] {raw}, null) as GLib.Object;
obj = Activator.CreateInstance (type, flags, null, new object[] {raw}, null) as Gst.GLib.Object;
} catch (MissingMethodException) {
throw new GLib.MissingIntPtrCtorException ("GLib.Object subclass " + type + " must provide a protected or public IntPtr ctor to support wrapping of native object handles.");
throw new Gst.GLib.MissingIntPtrCtorException ("Gst.GLib.Object subclass " + type + " must provide a protected or public IntPtr ctor to support wrapping of native object handles.");
}
return obj;
}

View file

@ -40,9 +40,9 @@ namespace Gst.GLib {
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);
IntPtr p_name = Gst.GLib.Marshaller.StringToPtrGStrdup (name);
IntPtr p_nick = Gst.GLib.Marshaller.StringToPtrGStrdup (nick);
IntPtr p_blurb = Gst.GLib.Marshaller.StringToPtrGStrdup (blurb);
if (type == GType.Char)
ret = g_param_spec_char (p_name, p_nick, p_blurb, SByte.MinValue, SByte.MaxValue, 0, flags);
@ -85,9 +85,9 @@ namespace Gst.GLib {
else
throw new ArgumentException ("type");
GLib.Marshaller.Free (p_name);
GLib.Marshaller.Free (p_nick);
GLib.Marshaller.Free (p_blurb);
Gst.GLib.Marshaller.Free (p_name);
Gst.GLib.Marshaller.Free (p_nick);
Gst.GLib.Marshaller.Free (p_blurb);
return ret;
}
@ -124,7 +124,7 @@ namespace Gst.GLib {
public string Name {
get {
GParamSpec spec = (GParamSpec) Marshal.PtrToStructure (Handle, typeof (GParamSpec));
return GLib.Marshaller.Utf8PtrToString (spec.name);
return Gst.GLib.Marshaller.Utf8PtrToString (spec.name);
}
}

View file

@ -1,4 +1,4 @@
// GLib.Priority.cs
// Gst.GLib.Priority.cs
//
// Author(s):
// Stephane Delcroix <stephane@delcroix.org>

View file

@ -94,10 +94,10 @@ namespace Gst.GLib {
if (elements_owned) {
int count = Count;
for (uint i = 0; i < count; i++)
if (typeof (GLib.Object).IsAssignableFrom (element_type))
if (typeof (Gst.GLib.Object).IsAssignableFrom (element_type))
g_object_unref (NthData (i));
else if (typeof (GLib.Opaque).IsAssignableFrom (element_type))
GLib.Opaque.GetOpaque (NthData (i), element_type, true).Dispose ();
else if (typeof (Gst.GLib.Opaque).IsAssignableFrom (element_type))
Gst.GLib.Opaque.GetOpaque (NthData (i), element_type, true).Dispose ();
else
g_free (NthData (i));
}
@ -174,10 +174,10 @@ namespace Gst.GLib {
ret = Marshaller.Utf8PtrToString (data);
else if (element_type == typeof (IntPtr))
ret = data;
else if (element_type.IsSubclassOf (typeof (GLib.Object)))
ret = GLib.Object.GetObject (data, false);
else if (element_type.IsSubclassOf (typeof (GLib.Opaque)))
ret = GLib.Opaque.GetOpaque (data, element_type, elements_owned);
else if (element_type.IsSubclassOf (typeof (Gst.GLib.Object)))
ret = Gst.GLib.Object.GetObject (data, false);
else if (element_type.IsSubclassOf (typeof (Gst.GLib.Opaque)))
ret = Gst.GLib.Opaque.GetOpaque (data, element_type, elements_owned);
else if (element_type == typeof (int))
ret = (int) data;
else if (element_type.IsValueType)
@ -186,7 +186,7 @@ namespace Gst.GLib {
ret = Activator.CreateInstance (element_type, new object[] {data});
} else if (Object.IsObject (data))
ret = GLib.Object.GetObject (data, false);
ret = Gst.GLib.Object.GetObject (data, false);
return ret;
}

View file

@ -1,4 +1,4 @@
// GLib.Signal.cs - signal marshaling class
// Gst.GLib.Signal.cs - signal marshaling class
//
// Authors: Mike Kestner <mkestner@novell.com>
// Andrés G. Aragoneses <aaragoneses@novell.com>
@ -140,7 +140,7 @@ namespace Gst.GLib {
SignalClosure after_closure;
Delegate marshaler;
private Signal (GLib.Object obj, string signal_name, Delegate marshaler)
private Signal (Gst.GLib.Object obj, string signal_name, Delegate marshaler)
{
tref = obj.ToggleRef;
name = signal_name;
@ -148,7 +148,7 @@ namespace Gst.GLib {
this.marshaler = marshaler;
}
private Signal (GLib.Object obj, string signal_name, Type args_type)
private Signal (Gst.GLib.Object obj, string signal_name, Type args_type)
{
tref = obj.ToggleRef;
name = signal_name;
@ -215,12 +215,12 @@ namespace Gst.GLib {
}
}
public static Signal Lookup (GLib.Object obj, string name)
public static Signal Lookup (Gst.GLib.Object obj, string name)
{
return Lookup (obj, name, typeof (EventArgs));
}
public static Signal Lookup (GLib.Object obj, string name, Delegate marshaler)
public static Signal Lookup (Gst.GLib.Object obj, string name, Delegate marshaler)
{
Signal result = obj.ToggleRef.Signals [name] as Signal;
if (result == null)
@ -228,7 +228,7 @@ namespace Gst.GLib {
return result;
}
public static Signal Lookup (GLib.Object obj, string name, Type args_type)
public static Signal Lookup (Gst.GLib.Object obj, string name, Type args_type)
{
Signal result = obj.ToggleRef.Signals [name] as Signal;
if (result == null)
@ -313,7 +313,7 @@ namespace Gst.GLib {
}
}
public static object Emit (GLib.Object instance, string detailed_signal, params object[] args)
public static object Emit (Gst.GLib.Object instance, string detailed_signal, params object[] args)
{
uint gquark, signal_id;
string signal_name;
@ -321,13 +321,13 @@ namespace Gst.GLib {
signal_id = GetSignalId (signal_name, instance);
if (signal_id <= 0)
throw new ArgumentException ("Invalid signal name: " + signal_name);
GLib.Value[] vals = new GLib.Value [args.Length + 1];
GLib.ValueArray inst_and_params = new GLib.ValueArray ((uint) args.Length + 1);
Gst.GLib.Value[] vals = new Gst.GLib.Value [args.Length + 1];
Gst.GLib.ValueArray inst_and_params = new Gst.GLib.ValueArray ((uint) args.Length + 1);
vals [0] = new GLib.Value (instance);
vals [0] = new Gst.GLib.Value (instance);
inst_and_params.Append (vals [0]);
for (int i = 1; i < vals.Length; i++) {
vals [i] = new GLib.Value (args [i - 1]);
vals [i] = new Gst.GLib.Value (args [i - 1]);
inst_and_params.Append (vals [i]);
}
@ -335,27 +335,27 @@ namespace Gst.GLib {
Query query;
g_signal_query (signal_id, out query);
if (query.return_type != GType.None.Val) {
GLib.Value ret = GLib.Value.Empty;
Gst.GLib.Value ret = Gst.GLib.Value.Empty;
g_signal_emitv (inst_and_params.ArrayPtr, signal_id, gquark, ref ret);
ret_obj = ret.Val;
ret.Dispose ();
} else
g_signal_emitv (inst_and_params.ArrayPtr, signal_id, gquark, IntPtr.Zero);
foreach (GLib.Value val in vals)
foreach (Gst.GLib.Value val in vals)
val.Dispose ();
return ret_obj;
}
private static uint GetGQuarkFromString (string str) {
IntPtr native_string = GLib.Marshaller.StringToPtrGStrdup (str);
IntPtr native_string = Gst.GLib.Marshaller.StringToPtrGStrdup (str);
uint ret = g_quark_from_string (native_string);
GLib.Marshaller.Free (native_string);
Gst.GLib.Marshaller.Free (native_string);
return ret;
}
private static uint GetSignalId (string signal_name, GLib.Object obj)
private static uint GetSignalId (string signal_name, Gst.GLib.Object obj)
{
IntPtr typeid = GType.ValFromInstancePtr (obj.Handle);
return GetSignalId (signal_name, typeid);
@ -363,13 +363,13 @@ namespace Gst.GLib {
private static uint GetSignalId (string signal_name, IntPtr typeid)
{
IntPtr native_name = GLib.Marshaller.StringToPtrGStrdup (signal_name);
IntPtr native_name = Gst.GLib.Marshaller.StringToPtrGStrdup (signal_name);
uint signal_id = g_signal_lookup (native_name, typeid);
GLib.Marshaller.Free (native_name);
Gst.GLib.Marshaller.Free (native_name);
return signal_id;
}
public static ulong AddEmissionHook (string detailed_signal, GLib.GType type, EmissionHook handler_func)
public static ulong AddEmissionHook (string detailed_signal, Gst.GLib.GType type, EmissionHook handler_func)
{
uint gquark;
string signal_name;
@ -395,7 +395,7 @@ namespace Gst.GLib {
static extern IntPtr g_signal_get_invocation_hint (IntPtr instance);
[DllImport("libgobject-2.0-0.dll")]
static extern void g_signal_emitv (IntPtr instance_and_params, uint signal_id, uint gquark_detail, ref GLib.Value return_value);
static extern void g_signal_emitv (IntPtr instance_and_params, uint signal_id, uint gquark_detail, ref Gst.GLib.Value return_value);
[DllImport("libgobject-2.0-0.dll")]
static extern void g_signal_emitv (IntPtr instance_and_params, uint signal_id, uint gquark_detail, IntPtr return_value);

View file

@ -1,4 +1,4 @@
// GLib.SignalArgs.cs - Signal argument class implementation
// Gst.GLib.SignalArgs.cs - Signal argument class implementation
//
// Author: Mike Kestner <mkestner@speakeasy.net>
//

View file

@ -1,4 +1,4 @@
// GLib.SignalCallback.cs - Signal callback base class implementation
// Gst.GLib.SignalCallback.cs - Signal callback base class implementation
//
// Authors: Mike Kestner <mkestner@ximian.com>
//
@ -25,7 +25,7 @@ namespace Gst.GLib {
using System.Collections;
using System.Runtime.InteropServices;
[Obsolete ("Replaced by GLib.Signal.")]
[Obsolete ("Replaced by Gst.GLib.Signal.")]
public abstract class SignalCallback : IDisposable {
// A counter used to produce unique keys for instances.
@ -35,13 +35,13 @@ namespace Gst.GLib {
protected static Hashtable _Instances = new Hashtable ();
// protected instance members
protected GLib.Object _obj;
protected Gst.GLib.Object _obj;
protected Delegate _handler;
protected int _key;
protected System.Type _argstype;
protected uint _HandlerID;
protected SignalCallback (GLib.Object obj, Delegate eh, System.Type argstype)
protected SignalCallback (Gst.GLib.Object obj, Delegate eh, System.Type argstype)
{
_key = _NextKey++;
_obj = obj;

View file

@ -28,10 +28,10 @@ namespace Gst.GLib {
internal class ClosureInvokedArgs : EventArgs {
EventArgs args;
GLib.Object obj;
Gst.GLib.Object obj;
object result;
public ClosureInvokedArgs (GLib.Object obj, EventArgs args)
public ClosureInvokedArgs (Gst.GLib.Object obj, EventArgs args)
{
this.obj = obj;
this.args = args;
@ -43,7 +43,7 @@ namespace Gst.GLib {
}
}
public GLib.Object Target {
public Gst.GLib.Object Target {
get {
return obj;
}
@ -97,9 +97,9 @@ namespace Gst.GLib {
public void Connect (bool is_after)
{
IntPtr native_name = GLib.Marshaller.StringToPtrGStrdup (name);
IntPtr native_name = Gst.GLib.Marshaller.StringToPtrGStrdup (name);
id = g_signal_connect_closure (handle, native_name, raw_closure, is_after);
GLib.Marshaller.Free (native_name);
Gst.GLib.Marshaller.Free (native_name);
}
public void Disconnect ()
@ -147,7 +147,7 @@ namespace Gst.GLib {
SignalClosure closure = closures [raw_closure] as SignalClosure;
message = "Marshaling " + closure.name + " signal";
Value objval = (Value) Marshal.PtrToStructure (param_values, typeof (Value));
GLib.Object __obj = objval.Val as GLib.Object;
Gst.GLib.Object __obj = objval.Val as Gst.GLib.Object;
if (__obj == null)
return;
@ -158,7 +158,7 @@ namespace Gst.GLib {
SignalArgs args = Activator.CreateInstance (closure.args_type, new object [0]) as SignalArgs;
args.Args = new object [n_param_vals - 1];
GLib.Value[] vals = new GLib.Value [n_param_vals - 1];
Gst.GLib.Value[] vals = new Gst.GLib.Value [n_param_vals - 1];
for (int i = 1; i < n_param_vals; i++) {
IntPtr ptr = new IntPtr (param_values.ToInt64 () + i * Marshal.SizeOf (typeof (Value)));
vals [i - 1] = (Value) Marshal.PtrToStructure (ptr, typeof (Value));

View file

@ -1,4 +1,4 @@
// GLib.Source.cs - Source class implementation
// Gst.GLib.Source.cs - Source class implementation
//
// Author: Duncan Mak <duncan@ximian.com>
//

View file

@ -126,7 +126,7 @@ namespace Gst.GLib {
Marshaller.Free (native_dir);
Marshaller.Free (native_argv);
Marshaller.Free (native_envp);
if (error != IntPtr.Zero) throw new GLib.GException (error);
if (error != IntPtr.Zero) throw new Gst.GLib.GException (error);
return result;
}
@ -161,7 +161,7 @@ namespace Gst.GLib {
Marshaller.Free (native_dir);
Marshaller.Free (native_argv);
Marshaller.Free (native_envp);
if (error != IntPtr.Zero) throw new GLib.GException (error);
if (error != IntPtr.Zero) throw new Gst.GLib.GException (error);
return result;
}
@ -181,7 +181,7 @@ namespace Gst.GLib {
Marshaller.Free (native_envp);
stdout = Marshaller.PtrToStringGFree (native_stdout);
stderr = Marshaller.PtrToStringGFree (native_stderr);
if (error != IntPtr.Zero) throw new GLib.GException (error);
if (error != IntPtr.Zero) throw new Gst.GLib.GException (error);
return result;
}
@ -194,7 +194,7 @@ namespace Gst.GLib {
IntPtr native_cmd = Marshaller.StringToPtrGStrdup (command_line);
bool result = g_spawn_command_line_async (native_cmd, out error);
Marshaller.Free (native_cmd);
if (error != IntPtr.Zero) throw new GLib.GException (error);
if (error != IntPtr.Zero) throw new Gst.GLib.GException (error);
return result;
}
@ -209,7 +209,7 @@ namespace Gst.GLib {
Marshaller.Free (native_cmd);
stdout = Marshaller.PtrToStringGFree (native_stdout);
stderr = Marshaller.PtrToStringGFree (native_stderr);
if (error != IntPtr.Zero) throw new GLib.GException (error);
if (error != IntPtr.Zero) throw new Gst.GLib.GException (error);
return result;
}
}

View file

@ -1,4 +1,4 @@
// GLib.Timeout.cs - Timeout class implementation
// Gst.GLib.Timeout.cs - Timeout class implementation
//
// Author(s):
// Mike Kestner <mkestner@speakeasy.net>

View file

@ -1,4 +1,4 @@
// GLib.ToggleRef.cs - GLib ToggleRef class implementation
// Gst.GLib.ToggleRef.cs - GLib ToggleRef class implementation
//
// Author: Mike Kestner <mkestner@novell.com>
//
@ -33,7 +33,7 @@ namespace Gst.GLib {
GCHandle gch;
Hashtable signals;
public ToggleRef (GLib.Object target)
public ToggleRef (Gst.GLib.Object target)
{
handle = target.Handle;
gch = GCHandle.Alloc (this);
@ -67,15 +67,15 @@ namespace Gst.GLib {
}
}
public GLib.Object Target {
public Gst.GLib.Object Target {
get {
if (reference == null)
return null;
else if (reference is GLib.Object)
return reference as GLib.Object;
else if (reference is Gst.GLib.Object)
return reference as Gst.GLib.Object;
WeakReference weak = reference as WeakReference;
return weak.Target as GLib.Object;
return weak.Target as Gst.GLib.Object;
}
}
@ -111,7 +111,7 @@ namespace Gst.GLib {
void Toggle (bool is_last_ref)
{
if (is_last_ref && reference is GLib.Object)
if (is_last_ref && reference is Gst.GLib.Object)
reference = new WeakReference (reference);
else if (!is_last_ref && reference is WeakReference) {
WeakReference weak = reference as WeakReference;

View file

@ -1,4 +1,4 @@
// GLib.TypeConverter.cs : Convert between fundamental and .NET types
// Gst.GLib.TypeConverter.cs : Convert between fundamental and .NET types
//
// Author: Rachel Hestilow <hestilow@ximian.com>
//

View file

@ -1,4 +1,4 @@
// GLib.TypeFundamentals.cs : Standard Types enumeration
// Gst.GLib.TypeFundamentals.cs : Standard Types enumeration
//
// Author: Mike Kestner <mkestner@speakeasy.net>
//

View file

@ -24,7 +24,7 @@ namespace Gst.GLib {
using System;
using System.Runtime.InteropServices;
[Obsolete ("Replaced by direct object-type casts to/from GLib.Value")]
[Obsolete ("Replaced by direct object-type casts to/from Gst.GLib.Value")]
public class UnwrappedObject {
IntPtr obj;

View file

@ -1,4 +1,4 @@
// GLib.Value.cs - GLib Value class implementation
// Gst.GLib.Value.cs - GLib Value class implementation
//
// Author: Mike Kestner <mkestner@speakeasy.net>
//
@ -49,7 +49,7 @@ namespace Gst.GLib {
public static Value Empty;
public Value (GLib.GType gtype)
public Value (Gst.GLib.GType gtype)
{
type = IntPtr.Zero;
pad1 = new Padding ();
@ -133,9 +133,9 @@ namespace Gst.GLib {
public Value (string val) : this (GType.String)
{
IntPtr native_val = GLib.Marshaller.StringToPtrGStrdup (val);
IntPtr native_val = Gst.GLib.Marshaller.StringToPtrGStrdup (val);
g_value_set_string (ref this, native_val);
GLib.Marshaller.Free (native_val);
Gst.GLib.Marshaller.Free (native_val);
}
public Value (ValueArray val) : this (ValueArray.GType)
@ -157,17 +157,17 @@ namespace Gst.GLib {
g_value_set_boxed (ref this, val.Handle);
}
public Value (GLib.Object val) : this (val == null ? GType.Object : val.NativeType)
public Value (Gst.GLib.Object val) : this (val == null ? GType.Object : val.NativeType)
{
g_value_set_object (ref this, val == null ? IntPtr.Zero : val.Handle);
}
public Value (GLib.GInterfaceAdapter val) : this (val == null ? GType.Object : val.GType)
public Value (Gst.GLib.GInterfaceAdapter val) : this (val == null ? GType.Object : val.GType)
{
g_value_set_object (ref this, val == null ? IntPtr.Zero : val.Handle);
}
public Value (GLib.Object obj, string prop_name)
public Value (Gst.GLib.Object obj, string prop_name)
{
type = IntPtr.Zero;
pad1 = new Padding ();
@ -176,7 +176,7 @@ namespace Gst.GLib {
}
[Obsolete]
public Value (GLib.Object obj, string prop_name, EnumWrapper wrap)
public Value (Gst.GLib.Object obj, string prop_name, EnumWrapper wrap)
{
type = IntPtr.Zero;
pad1 = new Padding ();
@ -194,11 +194,11 @@ namespace Gst.GLib {
type = IntPtr.Zero;
pad1 = new Padding ();
pad2 = new Padding ();
InitForProperty (GLib.Object.GetObject (obj), prop_name);
InitForProperty (Gst.GLib.Object.GetObject (obj), prop_name);
g_value_set_boxed (ref this, val.Handle);
}
public Value (string[] val) : this (new GLib.GType (g_strv_get_type ()))
public Value (string[] val) : this (new Gst.GLib.GType (g_strv_get_type ()))
{
if (val == null) {
g_value_set_boxed (ref this, IntPtr.Zero);
@ -207,13 +207,13 @@ namespace Gst.GLib {
IntPtr native_array = Marshal.AllocHGlobal ((val.Length + 1) * IntPtr.Size);
for (int i = 0; i < val.Length; i++)
Marshal.WriteIntPtr (native_array, i * IntPtr.Size, GLib.Marshaller.StringToPtrGStrdup (val[i]));
Marshal.WriteIntPtr (native_array, i * IntPtr.Size, Gst.GLib.Marshaller.StringToPtrGStrdup (val[i]));
Marshal.WriteIntPtr (native_array, val.Length * IntPtr.Size, IntPtr.Zero);
g_value_set_boxed (ref this, native_array);
for (int i = 0; i < val.Length; i++)
GLib.Marshaller.Free (Marshal.ReadIntPtr (native_array, i * IntPtr.Size));
Gst.GLib.Marshaller.Free (Marshal.ReadIntPtr (native_array, i * IntPtr.Size));
Marshal.FreeHGlobal (native_array);
}
@ -223,7 +223,7 @@ namespace Gst.GLib {
g_value_unset (ref this);
}
public void Init (GLib.GType gtype)
public void Init (Gst.GLib.GType gtype)
{
g_value_init (ref this, gtype.Val);
}
@ -299,7 +299,7 @@ namespace Gst.GLib {
public static explicit operator string (Value val)
{
IntPtr str = g_value_get_string (ref val);
return str == IntPtr.Zero ? null : GLib.Marshaller.Utf8PtrToString (str);
return str == IntPtr.Zero ? null : Gst.GLib.Marshaller.Utf8PtrToString (str);
}
public static explicit operator ValueArray (Value val)
@ -312,23 +312,23 @@ namespace Gst.GLib {
return g_value_get_pointer (ref val);
}
public static explicit operator GLib.Opaque (Value val)
public static explicit operator Gst.GLib.Opaque (Value val)
{
return GLib.Opaque.GetOpaque (g_value_get_boxed (ref val), (Type) new GType (val.type), false);
return Gst.GLib.Opaque.GetOpaque (g_value_get_boxed (ref val), (Type) new GType (val.type), false);
}
public static explicit operator GLib.Boxed (Value val)
public static explicit operator Gst.GLib.Boxed (Value val)
{
return new GLib.Boxed (g_value_get_boxed (ref val));
return new Gst.GLib.Boxed (g_value_get_boxed (ref val));
}
public static explicit operator GLib.Object (Value val)
public static explicit operator Gst.GLib.Object (Value val)
{
return GLib.Object.GetObject (g_value_get_object (ref val), false);
return Gst.GLib.Object.GetObject (g_value_get_object (ref val), false);
}
[Obsolete ("Replaced by GLib.Object cast")]
public static explicit operator GLib.UnwrappedObject (Value val)
[Obsolete ("Replaced by Gst.GLib.Object cast")]
public static explicit operator Gst.GLib.UnwrappedObject (Value val)
{
return new UnwrappedObject (g_value_get_object (ref val));
}
@ -344,18 +344,18 @@ namespace Gst.GLib {
count++;
string[] strings = new string[count];
for (int i = 0; i < count; i++)
strings[i] = GLib.Marshaller.Utf8PtrToString (Marshal.ReadIntPtr (native_array, i * IntPtr.Size));
strings[i] = Gst.GLib.Marshaller.Utf8PtrToString (Marshal.ReadIntPtr (native_array, i * IntPtr.Size));
return strings;
}
object ToRegisteredType () {
Type t = GLib.GType.LookupType (type);
Type t = Gst.GLib.GType.LookupType (type);
ConstructorInfo ci = null;
try {
while (ci == null && t != null) {
if (!t.IsAbstract)
ci = t.GetConstructor (new Type[] { typeof (GLib.Value) });
ci = t.GetConstructor (new Type[] { typeof (Gst.GLib.Value) });
if (ci == null)
t = t.BaseType;
}
@ -370,12 +370,12 @@ namespace Gst.GLib {
}
void FromRegisteredType (object val) {
Type t = GLib.GType.LookupType (type);
Type t = Gst.GLib.GType.LookupType (type);
MethodInfo mi = null;
try {
while (mi == null && t != null) {
mi = t.GetMethod ("SetGValue", new Type[] { Type.GetType ("GLib.Value&") });
mi = t.GetMethod ("SetGValue", new Type[] { Type.GetType ("Gst.GLib.Value&") });
if (mi != null && (mi.IsAbstract || mi.ReturnType != typeof (void)))
mi = null;
if (mi == null)
@ -390,7 +390,7 @@ namespace Gst.GLib {
object[] parameters = new object[] { this };
mi.Invoke (val, parameters);
this = (GLib.Value) parameters[0];
this = (Gst.GLib.Value) parameters[0];
}
object ToEnum ()
@ -413,8 +413,8 @@ namespace Gst.GLib {
Type t = GType.LookupType (type);
if (t == null)
throw new Exception ("Unknown type " + new GType (type).ToString ());
else if (t.IsSubclassOf (typeof (GLib.Opaque)))
return (GLib.Opaque) this;
else if (t.IsSubclassOf (typeof (Gst.GLib.Opaque)))
return (Gst.GLib.Opaque) this;
MethodInfo mi = t.GetMethod ("New", BindingFlags.Static | BindingFlags.Public | BindingFlags.FlattenHierarchy);
if (mi == null)
@ -458,7 +458,7 @@ namespace Gst.GLib {
else if (type == ManagedValue.GType.Val)
return ManagedValue.ObjectForWrapper (g_value_get_boxed (ref this));
else if (GType.Is (type, GType.Object))
return (GLib.Object) this;
return (Gst.GLib.Object) this;
else if (GType.Is (type, GType.Boxed))
return ToBoxed ();
else if (GType.LookupType (type) != null)
@ -492,9 +492,9 @@ namespace Gst.GLib {
else if (type == GType.Double.Val)
g_value_set_double (ref this, (double) value);
else if (type == GType.String.Val) {
IntPtr native = GLib.Marshaller.StringToPtrGStrdup ((string)value);
IntPtr native = Gst.GLib.Marshaller.StringToPtrGStrdup ((string)value);
g_value_set_string (ref this, native);
GLib.Marshaller.Free (native);
Gst.GLib.Marshaller.Free (native);
} else if (type == GType.Pointer.Val) {
if (value.GetType () == typeof (IntPtr)) {
g_value_set_pointer (ref this, (IntPtr) value);
@ -515,10 +515,10 @@ namespace Gst.GLib {
g_value_set_boxed (ref this, wrapper);
ManagedValue.ReleaseWrapper (wrapper);
} else if (GType.Is (type, GType.Object))
if(value is GLib.Object)
g_value_set_object (ref this, (value as GLib.Object).Handle);
if(value is Gst.GLib.Object)
g_value_set_object (ref this, (value as Gst.GLib.Object).Handle);
else
g_value_set_object (ref this, (value as GLib.GInterfaceAdapter).Handle);
g_value_set_object (ref this, (value as Gst.GLib.GInterfaceAdapter).Handle);
else if (GType.Is (type, GType.Boxed)) {
if (value is IWrapper) {
g_value_set_boxed (ref this, ((IWrapper)value).Handle);
@ -527,7 +527,7 @@ namespace Gst.GLib {
IntPtr buf = Marshaller.StructureToPtrAlloc (value);
g_value_set_boxed (ref this, buf);
Marshal.FreeHGlobal (buf);
} else if (GLib.GType.LookupType (type) != null) {
} else if (Gst.GLib.GType.LookupType (type) != null) {
FromRegisteredType (value);
} else
throw new Exception ("Unknown type " + new GType (type).ToString ());
@ -570,10 +570,10 @@ namespace Gst.GLib {
static extern bool g_type_check_value_holds (ref Value val, IntPtr gtype);
[DllImport("libgobject-2.0-0.dll")]
static extern void g_value_init (ref GLib.Value val, IntPtr gtype);
static extern void g_value_init (ref Gst.GLib.Value val, IntPtr gtype);
[DllImport("libgobject-2.0-0.dll")]
static extern void g_value_unset (ref GLib.Value val);
static extern void g_value_unset (ref Gst.GLib.Value val);
[DllImport("libgobject-2.0-0.dll")]
static extern void g_value_set_boolean (ref Value val, bool data);

View file

@ -116,25 +116,25 @@ namespace Gst.GLib {
}
[DllImport("libgobject-2.0-0.dll")]
static extern void g_value_array_append (IntPtr raw, ref GLib.Value val);
static extern void g_value_array_append (IntPtr raw, ref Gst.GLib.Value val);
public void Append (GLib.Value val)
public void Append (Gst.GLib.Value val)
{
g_value_array_append (Handle, ref val);
}
[DllImport("libgobject-2.0-0.dll")]
static extern void g_value_array_insert (IntPtr raw, uint idx, ref GLib.Value val);
static extern void g_value_array_insert (IntPtr raw, uint idx, ref Gst.GLib.Value val);
public void Insert (uint idx, GLib.Value val)
public void Insert (uint idx, Gst.GLib.Value val)
{
g_value_array_insert (Handle, idx, ref val);
}
[DllImport("libgobject-2.0-0.dll")]
static extern void g_value_array_prepend (IntPtr raw, ref GLib.Value val);
static extern void g_value_array_prepend (IntPtr raw, ref Gst.GLib.Value val);
public void Prepend (GLib.Value val)
public void Prepend (Gst.GLib.Value val)
{
g_value_array_prepend (Handle, ref val);
}
@ -158,7 +158,7 @@ namespace Gst.GLib {
public object this [int index] {
get {
IntPtr raw_val = g_value_array_get_nth (Handle, (uint) index);
return Marshal.PtrToStructure (raw_val, typeof (GLib.Value));
return Marshal.PtrToStructure (raw_val, typeof (Gst.GLib.Value));
}
}
@ -238,9 +238,9 @@ namespace Gst.GLib {
[DllImport ("libgobject-2.0-0.dll")]
static extern IntPtr g_value_array_get_type ();
public static GLib.GType GType {
public static Gst.GLib.GType GType {
get {
return new GLib.GType (g_value_array_get_type ());
return new Gst.GLib.GType (g_value_array_get_type ());
}
}
}