internal object DataMarshal(IntPtr data) { object ret = null; if (element_type != null) { if (element_type == typeof(string)) { ret = Marshaller.Utf8PtrToString(data); } else if (element_type == typeof(FilenameString)) { 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 == typeof(int)) { ret = (int)data; } else if (element_type.IsValueType) { ret = Marshal.PtrToStructure(data, element_type); } else if (element_type.IsInterface) { Type adapter_type = element_type.Assembly.GetType(InterfaceToAdapterTypeName(element_type)); System.Reflection.MethodInfo method = adapter_type.GetMethod("GetObject", new Type[] { typeof(IntPtr), typeof(bool) }); ret = method.Invoke(null, new object[] { data, false }); } else { ret = Activator.CreateInstance(element_type, new object[] { data }); } } else if (Object.IsObject(data)) { ret = GLib.Object.GetObject(data, false); } return(ret); }
internal object DataMarshal(IntPtr data) { object ret = null; if (element_type != null) { if (element_type == typeof(string)) { 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 == typeof(int)) { ret = (int)data; } else if (element_type.IsValueType) { ret = Marshal.PtrToStructure(data, element_type); } else { ret = Activator.CreateInstance(element_type, new object[] { data }); } } else if (Object.IsObject(data)) { ret = GLib.Object.GetObject(data, false); } return(ret); }