gstreamer-sharp/DynamicSignal.cs: Added support for objects derived from GLib.Opaque

git-svn-id: svn://anonsvn.mono-project.com/source/branches/abock/gstreamer-sharp@65082 e3ebcda4-bce8-0310-ba0a-eca2169e7518
This commit is contained in:
Khaled Mohammed 2006-09-07 22:22:09 +00:00
parent 60312ccf83
commit a6ca2de622
3 changed files with 17 additions and 6 deletions

View file

@ -1,6 +1,6 @@
//
//
// (C) 2006
// (C) 2006 Novell Inc.
//
// This class implements the functionalities to bind a callback
// function to a signal dynamically.
@ -116,6 +116,9 @@ namespace GLib {
}
}
[DllImport("libgobject-2.0-0.dll")]
static extern IntPtr g_value_peek_pointer(IntPtr ptr);
static void OnMarshal(IntPtr closure, ref GLib.Value retval, uint argc, IntPtr argsPtr,
IntPtr ihint, IntPtr data)
{
@ -124,8 +127,14 @@ namespace GLib {
for(int i=1; i < argc; i++) {
IntPtr struct_ptr = (IntPtr)((long) argsPtr + (i * gvalue_struct_size));
GLib.Value argument = (GLib.Value) Marshal.PtrToStructure(struct_ptr, typeof(GLib.Value));
args[i - 1] = argument.Val;
Type detectedType = GLib.GType.LookupType(Marshal.ReadIntPtr(struct_ptr));
if(detectedType.IsSubclassOf(typeof(Opaque))) {
args[i - 1] = (Opaque) Opaque.GetOpaque(g_value_peek_pointer(struct_ptr), detectedType, false);
}
else {
GLib.Value argument = (GLib.Value) Marshal.PtrToStructure(struct_ptr, typeof(GLib.Value));
args[i - 1] = argument.Val;
}
}
if(data == IntPtr.Zero) {

View file

@ -20,11 +20,13 @@ namespace Gst
}
public uint Probability {
get { return (uint)Args[1]; }
get { return (uint)Args[0]; }
}
public Gst.Caps Caps {
get { return (Gst.Caps)Args[2]; }
get {
return (Gst.Caps)Args[1];
}
}
}

View file

@ -35,7 +35,7 @@ public static class GstTypefindTest
{
Caps caps = args.Args[1] as Caps;
caps.Refcount++;
Console.WriteLine("MimeType: {0}, {1}", caps , typefind.Caps);
Console.WriteLine("MimeType: {0}", caps);
}
}