Update based on PR feedback
This commit is contained in:
parent
238b98b631
commit
2c54a7824c
29 changed files with 109 additions and 89 deletions
|
@ -53,7 +53,7 @@ namespace Cairo {
|
||||||
|
|
||||||
static int native_glyph_size, c_compiler_long_size;
|
static int native_glyph_size, c_compiler_long_size;
|
||||||
|
|
||||||
static Context ()
|
static unsafe Context ()
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
// This is used to determine what kind of structure
|
// This is used to determine what kind of structure
|
||||||
|
@ -65,7 +65,7 @@ namespace Cairo {
|
||||||
// except in the case of Win64 where sizeof(long)
|
// except in the case of Win64 where sizeof(long)
|
||||||
// is 32 bits
|
// is 32 bits
|
||||||
//
|
//
|
||||||
int ptr_size = Marshal.SizeOf<IntPtr>();
|
int ptr_size = sizeof(IntPtr);
|
||||||
|
|
||||||
PlatformID platform = Environment.OSVersion.Platform;
|
PlatformID platform = Environment.OSVersion.Platform;
|
||||||
if (platform == PlatformID.Win32NT ||
|
if (platform == PlatformID.Win32NT ||
|
||||||
|
@ -74,10 +74,10 @@ namespace Cairo {
|
||||||
platform == PlatformID.WinCE ||
|
platform == PlatformID.WinCE ||
|
||||||
ptr_size == 4){
|
ptr_size == 4){
|
||||||
c_compiler_long_size = 4;
|
c_compiler_long_size = 4;
|
||||||
native_glyph_size = Marshal.SizeOf (typeof (NativeGlyph_4byte_longs));
|
native_glyph_size = Marshal.SizeOf<NativeGlyph_4byte_longs> ();
|
||||||
} else {
|
} else {
|
||||||
c_compiler_long_size = 8;
|
c_compiler_long_size = 8;
|
||||||
native_glyph_size = Marshal.SizeOf (typeof (Glyph));
|
native_glyph_size = Marshal.SizeOf<Glyph> ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -75,7 +75,7 @@ namespace Cairo
|
||||||
|
|
||||||
internal static IntPtr GlyphsToIntPtr (Glyph[] glyphs)
|
internal static IntPtr GlyphsToIntPtr (Glyph[] glyphs)
|
||||||
{
|
{
|
||||||
int size = Marshal.SizeOf (glyphs[0]);
|
int size = Marshal.SizeOf<Glyph> ();
|
||||||
IntPtr dest = Marshal.AllocHGlobal (size * glyphs.Length);
|
IntPtr dest = Marshal.AllocHGlobal (size * glyphs.Length);
|
||||||
long pos = dest.ToInt64 ();
|
long pos = dest.ToInt64 ();
|
||||||
for (int i = 0; i < glyphs.Length; i++, pos += size)
|
for (int i = 0; i < glyphs.Length; i++, pos += size)
|
||||||
|
|
|
@ -12,10 +12,10 @@ namespace GLib {
|
||||||
public partial class HookList : GLib.Opaque {
|
public partial class HookList : GLib.Opaque {
|
||||||
|
|
||||||
// Internal representation of the wrapped ABI structure.
|
// Internal representation of the wrapped ABI structure.
|
||||||
static public AbiStruct abi_info = new AbiStruct(new List<AbiField> {
|
static public unsafe AbiStruct abi_info = new AbiStruct(new List<AbiField> {
|
||||||
new GLib.AbiField("seq_id"
|
new GLib.AbiField("seq_id"
|
||||||
, 0
|
, 0
|
||||||
, (uint) Marshal.SizeOf<ulong>() // seq_id
|
, (uint) sizeof (ulong) // seq_id
|
||||||
, null
|
, null
|
||||||
, "hook_size"
|
, "hook_size"
|
||||||
, (long) Marshal.OffsetOf(typeof(GHookList_seq_idAlign), "seq_id")
|
, (long) Marshal.OffsetOf(typeof(GHookList_seq_idAlign), "seq_id")
|
||||||
|
@ -23,7 +23,7 @@ namespace GLib {
|
||||||
),
|
),
|
||||||
new GLib.AbiField("hook_size"
|
new GLib.AbiField("hook_size"
|
||||||
, -1
|
, -1
|
||||||
, (uint) Marshal.SizeOf<uint>() // hook_size
|
, (uint) sizeof (uint) // hook_size
|
||||||
, "seq_id"
|
, "seq_id"
|
||||||
, "is_setup"
|
, "is_setup"
|
||||||
, 1
|
, 1
|
||||||
|
@ -31,7 +31,7 @@ namespace GLib {
|
||||||
),
|
),
|
||||||
new GLib.AbiField("is_setup"
|
new GLib.AbiField("is_setup"
|
||||||
, -1
|
, -1
|
||||||
, (uint) Marshal.SizeOf<bool>() // is_setup
|
, (uint) sizeof (bool) // is_setup
|
||||||
, "hook_size"
|
, "hook_size"
|
||||||
, "hooks"
|
, "hooks"
|
||||||
, 1
|
, 1
|
||||||
|
@ -39,7 +39,7 @@ namespace GLib {
|
||||||
),
|
),
|
||||||
new GLib.AbiField("hooks"
|
new GLib.AbiField("hooks"
|
||||||
, -1
|
, -1
|
||||||
, (uint) Marshal.SizeOf<IntPtr>() // hooks
|
, (uint) sizeof (IntPtr) // hooks
|
||||||
, "is_setup"
|
, "is_setup"
|
||||||
, "dummy3"
|
, "dummy3"
|
||||||
, (long) Marshal.OffsetOf(typeof(GHookList_hooksAlign), "hooks")
|
, (long) Marshal.OffsetOf(typeof(GHookList_hooksAlign), "hooks")
|
||||||
|
@ -47,7 +47,7 @@ namespace GLib {
|
||||||
),
|
),
|
||||||
new GLib.AbiField("dummy3"
|
new GLib.AbiField("dummy3"
|
||||||
, -1
|
, -1
|
||||||
, (uint) Marshal.SizeOf<IntPtr>() // dummy3
|
, (uint) sizeof (IntPtr) // dummy3
|
||||||
, "hooks"
|
, "hooks"
|
||||||
, "finalize_hook"
|
, "finalize_hook"
|
||||||
, (long) Marshal.OffsetOf(typeof(GHookList_dummy3Align), "dummy3")
|
, (long) Marshal.OffsetOf(typeof(GHookList_dummy3Align), "dummy3")
|
||||||
|
@ -55,7 +55,7 @@ namespace GLib {
|
||||||
),
|
),
|
||||||
new GLib.AbiField("finalize_hook"
|
new GLib.AbiField("finalize_hook"
|
||||||
, -1
|
, -1
|
||||||
, (uint) Marshal.SizeOf<IntPtr>() // finalize_hook
|
, (uint) sizeof (IntPtr) // finalize_hook
|
||||||
, "dummy3"
|
, "dummy3"
|
||||||
, "dummy"
|
, "dummy"
|
||||||
, (long) Marshal.OffsetOf(typeof(GHookList_finalize_hookAlign), "finalize_hook")
|
, (long) Marshal.OffsetOf(typeof(GHookList_finalize_hookAlign), "finalize_hook")
|
||||||
|
@ -63,7 +63,7 @@ namespace GLib {
|
||||||
),
|
),
|
||||||
new GLib.AbiField("dummy"
|
new GLib.AbiField("dummy"
|
||||||
, -1
|
, -1
|
||||||
, (uint) Marshal.SizeOf<IntPtr>() * 2 // dummy
|
, (uint) sizeof (IntPtr) * 2 // dummy
|
||||||
, "finalize_hook"
|
, "finalize_hook"
|
||||||
, null
|
, null
|
||||||
, (long) Marshal.OffsetOf(typeof(GHookList_dummyAlign), "dummy")
|
, (long) Marshal.OffsetOf(typeof(GHookList_dummyAlign), "dummy")
|
||||||
|
|
|
@ -356,19 +356,19 @@ namespace GLib {
|
||||||
while (current != IntPtr.Zero) {
|
while (current != IntPtr.Zero) {
|
||||||
Marshal.PtrToStructure (current, currentStruct);
|
Marshal.PtrToStructure (current, currentStruct);
|
||||||
res.Add (currentStruct);
|
res.Add (currentStruct);
|
||||||
current = (IntPtr) ((long)current + Marshal.SizeOf (typeof (T)));
|
current = (IntPtr) ((long)current + Marshal.SizeOf<T> ());
|
||||||
}
|
}
|
||||||
|
|
||||||
return res.ToArray ();
|
return res.ToArray ();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IntPtr StructArrayToNullTerminatedStructArrayIntPtr<T> (T[] InputArray)
|
public static unsafe IntPtr StructArrayToNullTerminatedStructArrayIntPtr<T> (T[] InputArray)
|
||||||
{
|
{
|
||||||
int intPtrSize = Marshal.SizeOf<IntPtr>();
|
int intPtrSize = sizeof (IntPtr);
|
||||||
IntPtr mem = Marshal.AllocHGlobal ((InputArray.Length + 1) * intPtrSize);
|
IntPtr mem = Marshal.AllocHGlobal ((InputArray.Length + 1) * intPtrSize);
|
||||||
|
|
||||||
for (int i = 0; i < InputArray.Length; i++) {
|
for (int i = 0; i < InputArray.Length; i++) {
|
||||||
IntPtr structPtr = Marshal.AllocHGlobal (Marshal.SizeOf (typeof (T)));
|
IntPtr structPtr = Marshal.AllocHGlobal (Marshal.SizeOf<T> ());
|
||||||
Marshal.StructureToPtr (InputArray[i], structPtr, false);
|
Marshal.StructureToPtr (InputArray[i], structPtr, false);
|
||||||
// jump to next pointer
|
// jump to next pointer
|
||||||
Marshal.WriteIntPtr (mem, structPtr);
|
Marshal.WriteIntPtr (mem, structPtr);
|
||||||
|
|
|
@ -936,10 +936,10 @@ namespace GLib {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Internal representation of the wrapped ABI structure.
|
// Internal representation of the wrapped ABI structure.
|
||||||
static public AbiStruct abi_info = new AbiStruct(new List<AbiField> {
|
static public unsafe AbiStruct abi_info = new AbiStruct(new List<AbiField> {
|
||||||
new GLib.AbiField("g_type_instance"
|
new GLib.AbiField("g_type_instance"
|
||||||
, 0
|
, 0
|
||||||
, (uint) Marshal.SizeOf<IntPtr>() // g_type_instance
|
, (uint) sizeof (IntPtr) // g_type_instance
|
||||||
, null
|
, null
|
||||||
, "ref_count"
|
, "ref_count"
|
||||||
, (long) Marshal.OffsetOf(typeof(GObject_g_type_instanceAlign), "g_type_instance")
|
, (long) Marshal.OffsetOf(typeof(GObject_g_type_instanceAlign), "g_type_instance")
|
||||||
|
@ -947,7 +947,7 @@ namespace GLib {
|
||||||
),
|
),
|
||||||
new GLib.AbiField("ref_count"
|
new GLib.AbiField("ref_count"
|
||||||
, -1
|
, -1
|
||||||
, (uint) Marshal.SizeOf<uint>() // ref_count
|
, (uint) sizeof (uint) // ref_count
|
||||||
, "g_type_instance"
|
, "g_type_instance"
|
||||||
, "qdata"
|
, "qdata"
|
||||||
, (long) Marshal.OffsetOf(typeof(GObject_ref_countAlign), "ref_count")
|
, (long) Marshal.OffsetOf(typeof(GObject_ref_countAlign), "ref_count")
|
||||||
|
@ -955,7 +955,7 @@ namespace GLib {
|
||||||
),
|
),
|
||||||
new GLib.AbiField("qdata"
|
new GLib.AbiField("qdata"
|
||||||
, -1
|
, -1
|
||||||
, (uint) Marshal.SizeOf<IntPtr>() // qdata
|
, (uint) sizeof (IntPtr) // qdata
|
||||||
, "ref_count"
|
, "ref_count"
|
||||||
, null
|
, null
|
||||||
, (long) Marshal.OffsetOf(typeof(GObject_qdataAlign), "qdata")
|
, (long) Marshal.OffsetOf(typeof(GObject_qdataAlign), "qdata")
|
||||||
|
@ -965,149 +965,149 @@ namespace GLib {
|
||||||
);
|
);
|
||||||
//
|
//
|
||||||
// Internal representation of the wrapped ABI structure.
|
// Internal representation of the wrapped ABI structure.
|
||||||
static public AbiStruct class_abi = new AbiStruct(new List<AbiField> {
|
static public unsafe AbiStruct class_abi = new AbiStruct(new List<AbiField> {
|
||||||
new GLib.AbiField("type_class"
|
new GLib.AbiField("type_class"
|
||||||
, 0
|
, 0
|
||||||
, (uint) Marshal.SizeOf<IntPtr>() // g_type_instance
|
, (uint) sizeof (IntPtr) // g_type_instance
|
||||||
, null
|
, null
|
||||||
, "construct_props"
|
, "construct_props"
|
||||||
, (uint) Marshal.SizeOf<IntPtr>() // g_type_instance
|
, (uint) sizeof (IntPtr) // g_type_instance
|
||||||
, 0
|
, 0
|
||||||
),
|
),
|
||||||
new GLib.AbiField("construct_props"
|
new GLib.AbiField("construct_props"
|
||||||
, 0
|
, 0
|
||||||
, (uint) Marshal.SizeOf<IntPtr>() // g_type_instance
|
, (uint) sizeof (IntPtr) // g_type_instance
|
||||||
, "type_class"
|
, "type_class"
|
||||||
, "constructor_cb"
|
, "constructor_cb"
|
||||||
, (uint) Marshal.SizeOf<IntPtr>() // g_type_instance
|
, (uint) sizeof (IntPtr) // g_type_instance
|
||||||
, 0
|
, 0
|
||||||
),
|
),
|
||||||
new GLib.AbiField("constructor_cb"
|
new GLib.AbiField("constructor_cb"
|
||||||
, 0
|
, 0
|
||||||
, (uint) Marshal.SizeOf<IntPtr>() // g_type_instance
|
, (uint) sizeof (IntPtr) // g_type_instance
|
||||||
, "construct_props"
|
, "construct_props"
|
||||||
, "set_prop_cb"
|
, "set_prop_cb"
|
||||||
, (uint) Marshal.SizeOf<IntPtr>() // g_type_instance
|
, (uint) sizeof (IntPtr) // g_type_instance
|
||||||
, 0
|
, 0
|
||||||
),
|
),
|
||||||
new GLib.AbiField("set_prop_cb"
|
new GLib.AbiField("set_prop_cb"
|
||||||
, 0
|
, 0
|
||||||
, (uint) Marshal.SizeOf<IntPtr>() // g_type_instance
|
, (uint) sizeof (IntPtr) // g_type_instance
|
||||||
, "constructor_cb"
|
, "constructor_cb"
|
||||||
, "get_prop_cb"
|
, "get_prop_cb"
|
||||||
, (uint) Marshal.SizeOf<IntPtr>() // g_type_instance
|
, (uint) sizeof (IntPtr) // g_type_instance
|
||||||
, 0
|
, 0
|
||||||
),
|
),
|
||||||
new GLib.AbiField("get_prop_cb"
|
new GLib.AbiField("get_prop_cb"
|
||||||
, 0
|
, 0
|
||||||
, (uint) Marshal.SizeOf<IntPtr>() // g_type_instance
|
, (uint) sizeof (IntPtr) // g_type_instance
|
||||||
, "set_prop_cb"
|
, "set_prop_cb"
|
||||||
, "dispose"
|
, "dispose"
|
||||||
, (uint) Marshal.SizeOf<IntPtr>() // g_type_instance
|
, (uint) sizeof (IntPtr) // g_type_instance
|
||||||
, 0
|
, 0
|
||||||
),
|
),
|
||||||
new GLib.AbiField("dispose"
|
new GLib.AbiField("dispose"
|
||||||
, 0
|
, 0
|
||||||
, (uint) Marshal.SizeOf<IntPtr>() // g_type_instance
|
, (uint) sizeof (IntPtr) // g_type_instance
|
||||||
, "get_prop_cb"
|
, "get_prop_cb"
|
||||||
, "finalize"
|
, "finalize"
|
||||||
, (uint) Marshal.SizeOf<IntPtr>() // g_type_instance
|
, (uint) sizeof (IntPtr) // g_type_instance
|
||||||
, 0
|
, 0
|
||||||
),
|
),
|
||||||
new GLib.AbiField("finalize"
|
new GLib.AbiField("finalize"
|
||||||
, 0
|
, 0
|
||||||
, (uint) Marshal.SizeOf<IntPtr>() // g_type_instance
|
, (uint) sizeof (IntPtr) // g_type_instance
|
||||||
, "dispose"
|
, "dispose"
|
||||||
, "dispatch_properties_changed"
|
, "dispatch_properties_changed"
|
||||||
, (uint) Marshal.SizeOf<IntPtr>() // g_type_instance
|
, (uint) sizeof (IntPtr) // g_type_instance
|
||||||
, 0
|
, 0
|
||||||
),
|
),
|
||||||
new GLib.AbiField("dispatch_properties_changed"
|
new GLib.AbiField("dispatch_properties_changed"
|
||||||
, 0
|
, 0
|
||||||
, (uint) Marshal.SizeOf<IntPtr>() // g_type_instance
|
, (uint) sizeof (IntPtr) // g_type_instance
|
||||||
, "finalize"
|
, "finalize"
|
||||||
, "notify"
|
, "notify"
|
||||||
, (uint) Marshal.SizeOf<IntPtr>() // g_type_instance
|
, (uint) sizeof (IntPtr) // g_type_instance
|
||||||
, 0
|
, 0
|
||||||
),
|
),
|
||||||
new GLib.AbiField("notify"
|
new GLib.AbiField("notify"
|
||||||
, 0
|
, 0
|
||||||
, (uint) Marshal.SizeOf<IntPtr>() // g_type_instance
|
, (uint) sizeof (IntPtr) // g_type_instance
|
||||||
, "dispatch_properties_changed"
|
, "dispatch_properties_changed"
|
||||||
, "constructed"
|
, "constructed"
|
||||||
, (uint) Marshal.SizeOf<IntPtr>() // g_type_instance
|
, (uint) sizeof (IntPtr) // g_type_instance
|
||||||
, 0
|
, 0
|
||||||
),
|
),
|
||||||
new GLib.AbiField("constructed"
|
new GLib.AbiField("constructed"
|
||||||
, 0
|
, 0
|
||||||
, (uint) Marshal.SizeOf<IntPtr>() // g_type_instance
|
, (uint) sizeof (IntPtr) // g_type_instance
|
||||||
, "notify"
|
, "notify"
|
||||||
, "dummy1"
|
, "dummy1"
|
||||||
, (uint) Marshal.SizeOf<IntPtr>() // g_type_instance
|
, (uint) sizeof (IntPtr) // g_type_instance
|
||||||
, 0
|
, 0
|
||||||
),
|
),
|
||||||
new GLib.AbiField("dummy1"
|
new GLib.AbiField("dummy1"
|
||||||
, 0
|
, 0
|
||||||
, (uint) Marshal.SizeOf<IntPtr>() // g_type_instance
|
, (uint) sizeof (IntPtr) // g_type_instance
|
||||||
, "constructed"
|
, "constructed"
|
||||||
, "dummy2"
|
, "dummy2"
|
||||||
, (uint) Marshal.SizeOf<IntPtr>() // g_type_instance
|
, (uint) sizeof (IntPtr) // g_type_instance
|
||||||
, 0
|
, 0
|
||||||
),
|
),
|
||||||
new GLib.AbiField("dummy2"
|
new GLib.AbiField("dummy2"
|
||||||
, 0
|
, 0
|
||||||
, (uint) Marshal.SizeOf<IntPtr>() // g_type_instance
|
, (uint) sizeof (IntPtr) // g_type_instance
|
||||||
, "dummy1"
|
, "dummy1"
|
||||||
, "dummy3"
|
, "dummy3"
|
||||||
, (uint) Marshal.SizeOf<IntPtr>() // g_type_instance
|
, (uint) sizeof (IntPtr) // g_type_instance
|
||||||
, 0
|
, 0
|
||||||
),
|
),
|
||||||
new GLib.AbiField("dummy3"
|
new GLib.AbiField("dummy3"
|
||||||
, 0
|
, 0
|
||||||
, (uint) Marshal.SizeOf<IntPtr>() // g_type_instance
|
, (uint) sizeof (IntPtr) // g_type_instance
|
||||||
, "dummy2"
|
, "dummy2"
|
||||||
, "dummy4"
|
, "dummy4"
|
||||||
, (uint) Marshal.SizeOf<IntPtr>() // g_type_instance
|
, (uint) sizeof (IntPtr) // g_type_instance
|
||||||
, 0
|
, 0
|
||||||
),
|
),
|
||||||
new GLib.AbiField("dummy3"
|
new GLib.AbiField("dummy3"
|
||||||
, 0
|
, 0
|
||||||
, (uint) Marshal.SizeOf<IntPtr>() // g_type_instance
|
, (uint) sizeof (IntPtr) // g_type_instance
|
||||||
, "dummy2"
|
, "dummy2"
|
||||||
, "dummy4"
|
, "dummy4"
|
||||||
, (uint) Marshal.SizeOf<IntPtr>() // g_type_instance
|
, (uint) sizeof (IntPtr) // g_type_instance
|
||||||
, 0
|
, 0
|
||||||
),
|
),
|
||||||
new GLib.AbiField("dummy4"
|
new GLib.AbiField("dummy4"
|
||||||
, 0
|
, 0
|
||||||
, (uint) Marshal.SizeOf<IntPtr>() // g_type_instance
|
, (uint) sizeof (IntPtr) // g_type_instance
|
||||||
, "dummy3"
|
, "dummy3"
|
||||||
, "dummy5"
|
, "dummy5"
|
||||||
, (uint) Marshal.SizeOf<IntPtr>() // g_type_instance
|
, (uint) sizeof (IntPtr) // g_type_instance
|
||||||
, 0
|
, 0
|
||||||
),
|
),
|
||||||
new GLib.AbiField("dummy5"
|
new GLib.AbiField("dummy5"
|
||||||
, 0
|
, 0
|
||||||
, (uint) Marshal.SizeOf<IntPtr>() // g_type_instance
|
, (uint) sizeof (IntPtr) // g_type_instance
|
||||||
, "dummy4"
|
, "dummy4"
|
||||||
, "dummy6"
|
, "dummy6"
|
||||||
, (uint) Marshal.SizeOf<IntPtr>() // g_type_instance
|
, (uint) sizeof (IntPtr) // g_type_instance
|
||||||
, 0
|
, 0
|
||||||
),
|
),
|
||||||
new GLib.AbiField("dummy6"
|
new GLib.AbiField("dummy6"
|
||||||
, 0
|
, 0
|
||||||
, (uint) Marshal.SizeOf<IntPtr>() // g_type_instance
|
, (uint) sizeof (IntPtr) // g_type_instance
|
||||||
, "dummy5"
|
, "dummy5"
|
||||||
, "dummy7"
|
, "dummy7"
|
||||||
, (uint) Marshal.SizeOf<IntPtr>() // g_type_instance
|
, (uint) sizeof (IntPtr) // g_type_instance
|
||||||
, 0
|
, 0
|
||||||
),
|
),
|
||||||
new GLib.AbiField("dummy7"
|
new GLib.AbiField("dummy7"
|
||||||
, 0
|
, 0
|
||||||
, (uint) Marshal.SizeOf<IntPtr>() // g_type_instance
|
, (uint) sizeof (IntPtr) // g_type_instance
|
||||||
, "dummy6"
|
, "dummy6"
|
||||||
, null
|
, null
|
||||||
, (uint) Marshal.SizeOf<IntPtr>() // g_type_instance
|
, (uint) sizeof (IntPtr) // g_type_instance
|
||||||
, 0
|
, 0
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
|
|
@ -92,7 +92,7 @@ namespace GLib {
|
||||||
{
|
{
|
||||||
object[] pvals = new object [n_pvals];
|
object[] pvals = new object [n_pvals];
|
||||||
for (int i = 0; i < n_pvals; i++) {
|
for (int i = 0; i < n_pvals; i++) {
|
||||||
IntPtr p = new IntPtr ((long) pvals_ptr + i * Marshal.SizeOf (typeof (Value)));
|
IntPtr p = new IntPtr ((long) pvals_ptr + i * Marshal.SizeOf<Value> ());
|
||||||
Value v = (Value) Marshal.PtrToStructure (p, typeof (Value));
|
Value v = (Value) Marshal.PtrToStructure (p, typeof (Value));
|
||||||
pvals [i] = v.Val;
|
pvals [i] = v.Val;
|
||||||
}
|
}
|
||||||
|
@ -110,7 +110,7 @@ namespace GLib {
|
||||||
|
|
||||||
bool NativeInvoker (InvocationHint ihint, object[] pvals)
|
bool NativeInvoker (InvocationHint ihint, object[] pvals)
|
||||||
{
|
{
|
||||||
int val_sz = Marshal.SizeOf (typeof (Value));
|
int val_sz = Marshal.SizeOf<Value> ();
|
||||||
IntPtr buf = Marshal.AllocHGlobal (pvals.Length * val_sz);
|
IntPtr buf = Marshal.AllocHGlobal (pvals.Length * val_sz);
|
||||||
Value[] vals = new Value [pvals.Length];
|
Value[] vals = new Value [pvals.Length];
|
||||||
for (int i = 0; i < pvals.Length; i++) {
|
for (int i = 0; i < pvals.Length; i++) {
|
||||||
|
|
|
@ -72,7 +72,7 @@ namespace GLib {
|
||||||
|
|
||||||
public SignalClosure (IntPtr obj, string signal_name, System.Type args_type)
|
public SignalClosure (IntPtr obj, string signal_name, System.Type args_type)
|
||||||
{
|
{
|
||||||
raw_closure = g_closure_new_simple (Marshal.SizeOf (typeof (GClosure)), IntPtr.Zero);
|
raw_closure = g_closure_new_simple (Marshal.SizeOf<GClosure> (), IntPtr.Zero);
|
||||||
g_closure_set_marshal (raw_closure, Marshaler);
|
g_closure_set_marshal (raw_closure, Marshaler);
|
||||||
g_closure_add_finalize_notifier (raw_closure, IntPtr.Zero, Notify);
|
g_closure_add_finalize_notifier (raw_closure, IntPtr.Zero, Notify);
|
||||||
closures [raw_closure] = this;
|
closures [raw_closure] = this;
|
||||||
|
@ -159,7 +159,7 @@ namespace GLib {
|
||||||
args.Args = new object [n_param_vals - 1];
|
args.Args = new object [n_param_vals - 1];
|
||||||
GLib.Value[] vals = new GLib.Value [n_param_vals - 1];
|
GLib.Value[] vals = new GLib.Value [n_param_vals - 1];
|
||||||
for (int i = 1; i < n_param_vals; i++) {
|
for (int i = 1; i < n_param_vals; i++) {
|
||||||
IntPtr ptr = new IntPtr (param_values.ToInt64 () + i * Marshal.SizeOf (typeof (Value)));
|
IntPtr ptr = new IntPtr (param_values.ToInt64 () + i * Marshal.SizeOf<Value> ());
|
||||||
vals [i - 1] = (Value) Marshal.PtrToStructure (ptr, typeof (Value));
|
vals [i - 1] = (Value) Marshal.PtrToStructure (ptr, typeof (Value));
|
||||||
args.Args [i - 1] = vals [i - 1].Val;
|
args.Args [i - 1] = vals [i - 1].Val;
|
||||||
}
|
}
|
||||||
|
@ -167,7 +167,7 @@ namespace GLib {
|
||||||
closure.Invoke (ci_args);
|
closure.Invoke (ci_args);
|
||||||
for (int i = 1; i < n_param_vals; i++) {
|
for (int i = 1; i < n_param_vals; i++) {
|
||||||
vals [i - 1].Update (args.Args [i - 1]);
|
vals [i - 1].Update (args.Args [i - 1]);
|
||||||
IntPtr ptr = new IntPtr (param_values.ToInt64 () + i * Marshal.SizeOf (typeof (Value)));
|
IntPtr ptr = new IntPtr (param_values.ToInt64 () + i * Marshal.SizeOf<Value> ());
|
||||||
Marshal.StructureToPtr (vals [i - 1], ptr, false);
|
Marshal.StructureToPtr (vals [i - 1], ptr, false);
|
||||||
}
|
}
|
||||||
if (return_val == IntPtr.Zero || args.RetVal == null)
|
if (return_val == IntPtr.Zero || args.RetVal == null)
|
||||||
|
|
|
@ -43,7 +43,7 @@ namespace GLib {
|
||||||
static d_g_time_val_add g_time_val_add = FuncLoader.LoadFunction<d_g_time_val_add>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_time_val_add"));
|
static d_g_time_val_add g_time_val_add = FuncLoader.LoadFunction<d_g_time_val_add>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_time_val_add"));
|
||||||
|
|
||||||
public void Add(long microseconds) {
|
public void Add(long microseconds) {
|
||||||
IntPtr this_as_native = System.Runtime.InteropServices.Marshal.AllocHGlobal (System.Runtime.InteropServices.Marshal.SizeOf (this));
|
IntPtr this_as_native = System.Runtime.InteropServices.Marshal.AllocHGlobal (System.Runtime.InteropServices.Marshal.SizeOf<TimeVal> ());
|
||||||
System.Runtime.InteropServices.Marshal.StructureToPtr (this, this_as_native, false);
|
System.Runtime.InteropServices.Marshal.StructureToPtr (this, this_as_native, false);
|
||||||
g_time_val_add(this_as_native, new IntPtr (microseconds));
|
g_time_val_add(this_as_native, new IntPtr (microseconds));
|
||||||
ReadNative (this_as_native, ref this);
|
ReadNative (this_as_native, ref this);
|
||||||
|
@ -54,7 +54,7 @@ namespace GLib {
|
||||||
static d_g_time_val_to_iso8601 g_time_val_to_iso8601 = FuncLoader.LoadFunction<d_g_time_val_to_iso8601>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_time_val_to_iso8601"));
|
static d_g_time_val_to_iso8601 g_time_val_to_iso8601 = FuncLoader.LoadFunction<d_g_time_val_to_iso8601>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_time_val_to_iso8601"));
|
||||||
|
|
||||||
public string ToIso8601() {
|
public string ToIso8601() {
|
||||||
IntPtr this_as_native = System.Runtime.InteropServices.Marshal.AllocHGlobal (System.Runtime.InteropServices.Marshal.SizeOf (this));
|
IntPtr this_as_native = System.Runtime.InteropServices.Marshal.AllocHGlobal (System.Runtime.InteropServices.Marshal.SizeOf<TimeVal> ());
|
||||||
System.Runtime.InteropServices.Marshal.StructureToPtr (this, this_as_native, false);
|
System.Runtime.InteropServices.Marshal.StructureToPtr (this, this_as_native, false);
|
||||||
IntPtr raw_ret = g_time_val_to_iso8601(this_as_native);
|
IntPtr raw_ret = g_time_val_to_iso8601(this_as_native);
|
||||||
string ret = GLib.Marshaller.PtrToStringGFree(raw_ret);
|
string ret = GLib.Marshaller.PtrToStringGFree(raw_ret);
|
||||||
|
@ -68,7 +68,7 @@ namespace GLib {
|
||||||
|
|
||||||
public static bool FromIso8601(string iso_date, out GLib.TimeVal time_) {
|
public static bool FromIso8601(string iso_date, out GLib.TimeVal time_) {
|
||||||
IntPtr native_iso_date = GLib.Marshaller.StringToPtrGStrdup (iso_date);
|
IntPtr native_iso_date = GLib.Marshaller.StringToPtrGStrdup (iso_date);
|
||||||
IntPtr native_time_ = Marshal.AllocHGlobal (Marshal.SizeOf (typeof (GLib.TimeVal)));
|
IntPtr native_time_ = Marshal.AllocHGlobal (Marshal.SizeOf<GLib.TimeVal> ());
|
||||||
bool raw_ret = g_time_val_from_iso8601(native_iso_date, native_time_);
|
bool raw_ret = g_time_val_from_iso8601(native_iso_date, native_time_);
|
||||||
bool ret = raw_ret;
|
bool ret = raw_ret;
|
||||||
GLib.Marshaller.Free (native_iso_date);
|
GLib.Marshaller.Free (native_iso_date);
|
||||||
|
|
|
@ -39,7 +39,7 @@ namespace Gdk {
|
||||||
int[] tmp = new int [count];
|
int[] tmp = new int [count];
|
||||||
Marshal.Copy (keyval_ptr, tmp, 0, count);
|
Marshal.Copy (keyval_ptr, tmp, 0, count);
|
||||||
for (int i = 0; i < count; i++) {
|
for (int i = 0; i < count; i++) {
|
||||||
IntPtr ptr = new IntPtr ((long) key_ptr + i * Marshal.SizeOf (typeof (KeymapKey)));
|
IntPtr ptr = new IntPtr ((long) key_ptr + i * Marshal.SizeOf<KeymapKey> ());
|
||||||
keyvals [i] = (uint) tmp [i];
|
keyvals [i] = (uint) tmp [i];
|
||||||
keys [i] = KeymapKey.New (ptr);
|
keys [i] = KeymapKey.New (ptr);
|
||||||
}
|
}
|
||||||
|
@ -61,7 +61,7 @@ namespace Gdk {
|
||||||
if (gdk_keymap_get_entries_for_keyval(Handle, keyval, out key_ptr, out count)) {
|
if (gdk_keymap_get_entries_for_keyval(Handle, keyval, out key_ptr, out count)) {
|
||||||
KeymapKey[] result = new KeymapKey [count];
|
KeymapKey[] result = new KeymapKey [count];
|
||||||
for (int i = 0; i < count; i++) {
|
for (int i = 0; i < count; i++) {
|
||||||
IntPtr ptr = new IntPtr ((long) key_ptr + i * Marshal.SizeOf (typeof (KeymapKey)));
|
IntPtr ptr = new IntPtr ((long) key_ptr + i * Marshal.SizeOf<KeymapKey> ());
|
||||||
result [i] = KeymapKey.New (ptr);
|
result [i] = KeymapKey.New (ptr);
|
||||||
}
|
}
|
||||||
GLib.Marshaller.Free (key_ptr);
|
GLib.Marshaller.Free (key_ptr);
|
||||||
|
|
|
@ -55,7 +55,7 @@ namespace Gtk {
|
||||||
for (int i=0; i < n_colors; i++)
|
for (int i=0; i < n_colors; i++)
|
||||||
{
|
{
|
||||||
colors[i] = Gdk.Color.New(parsedColors);
|
colors[i] = Gdk.Color.New(parsedColors);
|
||||||
parsedColors = (IntPtr) ((int)parsedColors + Marshal.SizeOf(colors[i]));
|
parsedColors = (IntPtr) ((int)parsedColors + Marshal.SizeOf<Gdk.Color> ());
|
||||||
}
|
}
|
||||||
return colors;
|
return colors;
|
||||||
}
|
}
|
||||||
|
|
|
@ -271,7 +271,7 @@ namespace Gtk {
|
||||||
vals [2] = new GLib.Value (iter);
|
vals [2] = new GLib.Value (iter);
|
||||||
inst_and_params.Append (vals [2]);
|
inst_and_params.Append (vals [2]);
|
||||||
int cnt = IterNChildren ();
|
int cnt = IterNChildren ();
|
||||||
IntPtr new_order_ptr = Marshal.AllocHGlobal (Marshal.SizeOf (typeof (int)) * cnt);
|
IntPtr new_order_ptr = Marshal.AllocHGlobal (sizeof(int) * cnt);
|
||||||
Marshal.Copy (new_order, 0, new_order_ptr, cnt);
|
Marshal.Copy (new_order, 0, new_order_ptr, cnt);
|
||||||
vals [3] = new GLib.Value (new_order_ptr);
|
vals [3] = new GLib.Value (new_order_ptr);
|
||||||
inst_and_params.Append (vals [3]);
|
inst_and_params.Append (vals [3]);
|
||||||
|
|
|
@ -90,7 +90,7 @@ namespace Gtk {
|
||||||
public bool GetGeometry(out Gdk.Screen screen, out Gdk.Rectangle area, out Gtk.Orientation orientation)
|
public bool GetGeometry(out Gdk.Screen screen, out Gdk.Rectangle area, out Gtk.Orientation orientation)
|
||||||
{
|
{
|
||||||
IntPtr native_screen;
|
IntPtr native_screen;
|
||||||
IntPtr native_area = Marshal.AllocHGlobal (Marshal.SizeOf (typeof (Gdk.Rectangle)));
|
IntPtr native_area = Marshal.AllocHGlobal (Marshal.SizeOf<Gdk.Rectangle> ());
|
||||||
int native_orientation;
|
int native_orientation;
|
||||||
bool ret = gtk_status_icon_get_geometry(Handle, out native_screen, native_area, out native_orientation);
|
bool ret = gtk_status_icon_get_geometry(Handle, out native_screen, native_area, out native_orientation);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
|
|
|
@ -33,7 +33,7 @@ namespace Gtk {
|
||||||
IntPtr array_ptr = gtk_target_table_new_from_list (list.Handle, out n_targets);
|
IntPtr array_ptr = gtk_target_table_new_from_list (list.Handle, out n_targets);
|
||||||
|
|
||||||
Gtk.TargetEntry[] ret = new Gtk.TargetEntry [n_targets];
|
Gtk.TargetEntry[] ret = new Gtk.TargetEntry [n_targets];
|
||||||
int unmanaged_struct_size = Marshal.SizeOf (typeof (Gtk.TargetEntry));
|
int unmanaged_struct_size = Marshal.SizeOf<Gtk.TargetEntry> ();
|
||||||
for (int i = 0; i < n_targets; i++) {
|
for (int i = 0; i < n_targets; i++) {
|
||||||
ret [i] = Gtk.TargetEntry.New (new IntPtr (array_ptr.ToInt64 () + i * unmanaged_struct_size));
|
ret [i] = Gtk.TargetEntry.New (new IntPtr (array_ptr.ToInt64 () + i * unmanaged_struct_size));
|
||||||
}
|
}
|
||||||
|
|
|
@ -161,7 +161,7 @@ namespace Gtk {
|
||||||
vals [2] = new GLib.Value (iter);
|
vals [2] = new GLib.Value (iter);
|
||||||
inst_and_params.Append (vals [2]);
|
inst_and_params.Append (vals [2]);
|
||||||
int cnt = IterNChildren (iter);
|
int cnt = IterNChildren (iter);
|
||||||
IntPtr new_order_ptr = Marshal.AllocHGlobal (Marshal.SizeOf (typeof (int)) * cnt);
|
IntPtr new_order_ptr = Marshal.AllocHGlobal (sizeof(int) * cnt);
|
||||||
Marshal.Copy (new_order, 0, new_order_ptr, cnt);
|
Marshal.Copy (new_order, 0, new_order_ptr, cnt);
|
||||||
vals [3] = new GLib.Value (new_order_ptr);
|
vals [3] = new GLib.Value (new_order_ptr);
|
||||||
inst_and_params.Append (vals [3]);
|
inst_and_params.Append (vals [3]);
|
||||||
|
|
|
@ -185,7 +185,7 @@ namespace Gtk {
|
||||||
vals [2] = new GLib.Value (iter);
|
vals [2] = new GLib.Value (iter);
|
||||||
inst_and_params.Append (vals [2]);
|
inst_and_params.Append (vals [2]);
|
||||||
int cnt = IterNChildren (iter);
|
int cnt = IterNChildren (iter);
|
||||||
IntPtr new_order_ptr = Marshal.AllocHGlobal (Marshal.SizeOf (typeof (int)) * cnt);
|
IntPtr new_order_ptr = Marshal.AllocHGlobal (sizeof(int) * cnt);
|
||||||
Marshal.Copy (new_order, 0, new_order_ptr, cnt);
|
Marshal.Copy (new_order, 0, new_order_ptr, cnt);
|
||||||
vals [3] = new GLib.Value (new_order_ptr);
|
vals [3] = new GLib.Value (new_order_ptr);
|
||||||
inst_and_params.Append (vals [3]);
|
inst_and_params.Append (vals [3]);
|
||||||
|
|
|
@ -165,7 +165,7 @@ namespace Gtk {
|
||||||
vals [2] = new GLib.Value (iter);
|
vals [2] = new GLib.Value (iter);
|
||||||
inst_and_params.Append (vals [2]);
|
inst_and_params.Append (vals [2]);
|
||||||
int cnt = IterNChildren (iter);
|
int cnt = IterNChildren (iter);
|
||||||
IntPtr new_order_ptr = Marshal.AllocHGlobal (Marshal.SizeOf (typeof (int)) * cnt);
|
IntPtr new_order_ptr = Marshal.AllocHGlobal (sizeof(int) * cnt);
|
||||||
Marshal.Copy (new_order, 0, new_order_ptr, cnt);
|
Marshal.Copy (new_order, 0, new_order_ptr, cnt);
|
||||||
vals [3] = new GLib.Value (new_order_ptr);
|
vals [3] = new GLib.Value (new_order_ptr);
|
||||||
inst_and_params.Append (vals [3]);
|
inst_and_params.Append (vals [3]);
|
||||||
|
|
|
@ -382,7 +382,7 @@ namespace Gtk {
|
||||||
vals [2] = new GLib.Value (iter);
|
vals [2] = new GLib.Value (iter);
|
||||||
inst_and_params.Append (vals [2]);
|
inst_and_params.Append (vals [2]);
|
||||||
int cnt = IterNChildren (iter);
|
int cnt = IterNChildren (iter);
|
||||||
IntPtr new_order_ptr = Marshal.AllocHGlobal (Marshal.SizeOf (typeof (int)) * cnt);
|
IntPtr new_order_ptr = Marshal.AllocHGlobal (sizeof(int) * cnt);
|
||||||
Marshal.Copy (new_order, 0, new_order_ptr, cnt);
|
Marshal.Copy (new_order, 0, new_order_ptr, cnt);
|
||||||
vals [3] = new GLib.Value (new_order_ptr);
|
vals [3] = new GLib.Value (new_order_ptr);
|
||||||
inst_and_params.Append (vals [3]);
|
inst_and_params.Append (vals [3]);
|
||||||
|
|
|
@ -65,7 +65,7 @@ namespace Gtk {
|
||||||
static d_g_closure_set_marshal g_closure_set_marshal = FuncLoader.LoadFunction<d_g_closure_set_marshal>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GObject), "g_closure_set_marshal"));
|
static d_g_closure_set_marshal g_closure_set_marshal = FuncLoader.LoadFunction<d_g_closure_set_marshal>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GObject), "g_closure_set_marshal"));
|
||||||
|
|
||||||
static IntPtr CreateClosure (ClosureMarshal marshaler) {
|
static IntPtr CreateClosure (ClosureMarshal marshaler) {
|
||||||
IntPtr raw_closure = g_closure_new_simple (Marshal.SizeOf (typeof (GClosure)), IntPtr.Zero);
|
IntPtr raw_closure = g_closure_new_simple (Marshal.SizeOf<GClosure> (), IntPtr.Zero);
|
||||||
g_closure_set_marshal (raw_closure, marshaler);
|
g_closure_set_marshal (raw_closure, marshaler);
|
||||||
return raw_closure;
|
return raw_closure;
|
||||||
}
|
}
|
||||||
|
@ -149,7 +149,7 @@ namespace Gtk {
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
GLib.Value[] inst_and_params = new GLib.Value [n_param_vals];
|
GLib.Value[] inst_and_params = new GLib.Value [n_param_vals];
|
||||||
int gvalue_size = Marshal.SizeOf (typeof (GLib.Value));
|
int gvalue_size = Marshal.SizeOf<GLib.Value> ();
|
||||||
for (int idx = 0; idx < n_param_vals; idx++)
|
for (int idx = 0; idx < n_param_vals; idx++)
|
||||||
inst_and_params [idx] = (GLib.Value) Marshal.PtrToStructure (new IntPtr (param_values.ToInt64 () + idx * gvalue_size), typeof (GLib.Value));
|
inst_and_params [idx] = (GLib.Value) Marshal.PtrToStructure (new IntPtr (param_values.ToInt64 () + idx * gvalue_size), typeof (GLib.Value));
|
||||||
|
|
||||||
|
|
|
@ -508,7 +508,7 @@
|
||||||
</Docs>
|
</Docs>
|
||||||
</Member>
|
</Member>
|
||||||
<Member MemberName="StructArrayToNullTerminatedStructArrayIntPtr<T>">
|
<Member MemberName="StructArrayToNullTerminatedStructArrayIntPtr<T>">
|
||||||
<MemberSignature Language="C#" Value="public static IntPtr StructArrayToNullTerminatedStructArrayIntPtr<T> (T[] InputArray);" />
|
<MemberSignature Language="C#" Value="public static IntPtr unsafe StructArrayToNullTerminatedStructArrayIntPtr<T> (T[] InputArray);" />
|
||||||
<MemberSignature Language="ILAsm" Value=".method public static hidebysig native int StructArrayToNullTerminatedStructArrayIntPtr<T>(!!T[] InputArray) cil managed" />
|
<MemberSignature Language="ILAsm" Value=".method public static hidebysig native int StructArrayToNullTerminatedStructArrayIntPtr<T>(!!T[] InputArray) cil managed" />
|
||||||
<MemberType>Method</MemberType>
|
<MemberType>Method</MemberType>
|
||||||
<ReturnValue>
|
<ReturnValue>
|
||||||
|
|
|
@ -41,7 +41,7 @@ namespace GtkSharp.Generation {
|
||||||
|
|
||||||
public string AllocNative ()
|
public string AllocNative ()
|
||||||
{
|
{
|
||||||
return "Marshal.AllocHGlobal (Marshal.SizeOf (typeof (" + QualifiedName + ")))";
|
return "Marshal.AllocHGlobal (" + GenerationInfo.GetSizeOfExpression(QualifiedName) + ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
public string AllocNative (string var_name)
|
public string AllocNative (string var_name)
|
||||||
|
|
|
@ -227,7 +227,7 @@ namespace GtkSharp.Generation {
|
||||||
sw.WriteLine ();
|
sw.WriteLine ();
|
||||||
sw.WriteLine ("\t\t// Internal representation of the wrapped structure ABI.");
|
sw.WriteLine ("\t\t// Internal representation of the wrapped structure ABI.");
|
||||||
sw.WriteLine ("\t\tstatic GLib.AbiStruct _" + info_name + " = null;");
|
sw.WriteLine ("\t\tstatic GLib.AbiStruct _" + info_name + " = null;");
|
||||||
sw.WriteLine ("\t\tstatic public " + _new + "GLib.AbiStruct " + info_name + " {");
|
sw.WriteLine ("\t\tstatic public unsafe " + _new + "GLib.AbiStruct " + info_name + " {");
|
||||||
sw.WriteLine ("\t\t\tget {");
|
sw.WriteLine ("\t\t\tget {");
|
||||||
sw.WriteLine ("\t\t\t\tif (_" + info_name + " == null)");
|
sw.WriteLine ("\t\t\t\tif (_" + info_name + " == null)");
|
||||||
|
|
||||||
|
|
|
@ -90,7 +90,7 @@ namespace GtkSharp.Generation {
|
||||||
if (p.PassAs == "ref")
|
if (p.PassAs == "ref")
|
||||||
sw.WriteLine ("\t\t\tIntPtr " + p.Name + "_ptr = GLib.Marshaller.StructureToPtrAlloc (" + p.Generatable.CallByName (p.Name) + ");");
|
sw.WriteLine ("\t\t\tIntPtr " + p.Name + "_ptr = GLib.Marshaller.StructureToPtrAlloc (" + p.Generatable.CallByName (p.Name) + ");");
|
||||||
else
|
else
|
||||||
sw.WriteLine ("\t\t\tIntPtr " + p.Name + "_ptr = Marshal.AllocHGlobal (Marshal.SizeOf (typeof (" + p.MarshalType + ")));");
|
sw.WriteLine ("\t\t\tIntPtr " + p.Name + "_ptr = Marshal.AllocHGlobal (" + GenerationInfo.GetSizeOfExpression(p.MarshalType) + ");");
|
||||||
|
|
||||||
sw.WriteLine ("\t\t\tvals [" + (i + 1) + "] = new GLib.Value (" + p.Name + "_ptr);");
|
sw.WriteLine ("\t\t\tvals [" + (i + 1) + "] = new GLib.Value (" + p.Name + "_ptr);");
|
||||||
cleanup += "\t\t\t" + p.Name + " = " + p.FromNative ("(" + p.MarshalType + ") Marshal.PtrToStructure (" + p.Name + "_ptr, typeof (" + p.MarshalType + "))") + ";\n";
|
cleanup += "\t\t\t" + p.Name + " = " + p.FromNative ("(" + p.MarshalType + ") Marshal.PtrToStructure (" + p.Name + "_ptr, typeof (" + p.MarshalType + "))") + ";\n";
|
||||||
|
|
|
@ -234,6 +234,26 @@ namespace GtkSharp.Generation {
|
||||||
|
|
||||||
return sw;
|
return sw;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal static string GetSizeOfExpression(string cstype)
|
||||||
|
{
|
||||||
|
bool isBlittable = cstype == "IntPtr"
|
||||||
|
|| cstype == "UIntPtr"
|
||||||
|
|| cstype == "ulong"
|
||||||
|
|| cstype == "long"
|
||||||
|
|| cstype == "uint"
|
||||||
|
|| cstype == "int"
|
||||||
|
|| cstype == "ushort"
|
||||||
|
|| cstype == "short"
|
||||||
|
|| cstype == "byte"
|
||||||
|
|| cstype == "sbyte"
|
||||||
|
|| cstype == "char"
|
||||||
|
|| cstype == "byte";
|
||||||
|
if (isBlittable)
|
||||||
|
return "sizeof( " + cstype + " )";
|
||||||
|
|
||||||
|
return "Marshal.SizeOf<" + cstype + ">()";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -68,7 +68,7 @@ namespace GtkSharp.Generation {
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string GenerateGetSizeOf () {
|
public override string GenerateGetSizeOf () {
|
||||||
return "(uint) Marshal.SizeOf<" + abi_type + ">()";
|
return "(uint) " + GenerationInfo.GetSizeOfExpression(abi_type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -394,7 +394,7 @@ namespace GtkSharp.Generation {
|
||||||
public override string[] Prepare {
|
public override string[] Prepare {
|
||||||
get {
|
get {
|
||||||
if (PassAs == "out")
|
if (PassAs == "out")
|
||||||
return new string [] { "IntPtr native_" + CallName + " = Marshal.AllocHGlobal (Marshal.SizeOf (typeof (" + Generatable.QualifiedName + ")));"};
|
return new string [] { "IntPtr native_" + CallName + " = Marshal.AllocHGlobal (" + GenerationInfo.GetSizeOfExpression(Generatable.QualifiedName) + ");"};
|
||||||
else
|
else
|
||||||
return new string [] { "IntPtr native_" + CallName + " = " + (Generatable as IManualMarshaler).AllocNative (CallName) + ";"};
|
return new string [] { "IntPtr native_" + CallName + " = " + (Generatable as IManualMarshaler).AllocNative (CallName) + ";"};
|
||||||
}
|
}
|
||||||
|
|
|
@ -104,7 +104,7 @@ namespace GtkSharp.Generation {
|
||||||
|
|
||||||
// Do not generate structs if the type is a simple pointer.
|
// Do not generate structs if the type is a simple pointer.
|
||||||
if (IsCPointer())
|
if (IsCPointer())
|
||||||
min_align = "(uint) Marshal.SizeOf<IntPtr>()";
|
min_align = "(uint) sizeof(IntPtr)";
|
||||||
|
|
||||||
if (IsBitfield)
|
if (IsBitfield)
|
||||||
min_align = "1";
|
min_align = "1";
|
||||||
|
|
|
@ -298,7 +298,7 @@ namespace GtkSharp.Generation {
|
||||||
|
|
||||||
public override void Prepare (StreamWriter sw, string indent)
|
public override void Prepare (StreamWriter sw, string indent)
|
||||||
{
|
{
|
||||||
sw.WriteLine (indent + "IntPtr this_as_native = System.Runtime.InteropServices.Marshal.AllocHGlobal (System.Runtime.InteropServices.Marshal.SizeOf (this));");
|
sw.WriteLine (indent + "IntPtr this_as_native = System.Runtime.InteropServices.Marshal.AllocHGlobal (System.Runtime.InteropServices.Marshal.SizeOf<" + QualifiedName + ">());");
|
||||||
sw.WriteLine (indent + "System.Runtime.InteropServices.Marshal.StructureToPtr (this, this_as_native, false);");
|
sw.WriteLine (indent + "System.Runtime.InteropServices.Marshal.StructureToPtr (this, this_as_native, false);");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -142,9 +142,9 @@ namespace GtkSharp.Generation {
|
||||||
|
|
||||||
var _enum = gen as EnumGen;
|
var _enum = gen as EnumGen;
|
||||||
if (_enum != null && !is_pointer)
|
if (_enum != null && !is_pointer)
|
||||||
res = "(uint) Marshal.SizeOf(System.Enum.GetUnderlyingType(typeof(" + cstype + ")))";
|
res = "(uint) sizeof(" + cstype + ")";
|
||||||
else
|
else
|
||||||
res = "(uint) Marshal.SizeOf<" + cstype + ">()";
|
res = "(uint) " + GenerationInfo.GetSizeOfExpression(cstype);
|
||||||
|
|
||||||
if (IsFixedSizeArray())
|
if (IsFixedSizeArray())
|
||||||
res += " * " + ArrayLength;
|
res += " * " + ArrayLength;
|
||||||
|
|
|
@ -150,7 +150,7 @@ namespace GtkSharp.Generation {
|
||||||
AddType (new MarshalGen ("GType", "GLib.GType", "IntPtr", "{0}.Val", "new GLib.GType({0})", "GLib.GType.None"));
|
AddType (new MarshalGen ("GType", "GLib.GType", "IntPtr", "{0}.Val", "new GLib.GType({0})", "GLib.GType.None"));
|
||||||
AddType (new ByRefGen ("GValue", "GLib.Value"));
|
AddType (new ByRefGen ("GValue", "GLib.Value"));
|
||||||
AddType (new SimpleGen ("GDestroyNotify", "GLib.DestroyNotify", "null",
|
AddType (new SimpleGen ("GDestroyNotify", "GLib.DestroyNotify", "null",
|
||||||
"(uint) Marshal.SizeOf<IntPtr>()"));
|
"(uint) sizeof(IntPtr)"));
|
||||||
AddType (new SimpleGen ("GThread", "GLib.Thread", "null"));
|
AddType (new SimpleGen ("GThread", "GLib.Thread", "null"));
|
||||||
AddType (new ManualGen ("GBytes", "GLib.Bytes"));
|
AddType (new ManualGen ("GBytes", "GLib.Bytes"));
|
||||||
AddType (new SimpleGen ("GHookList", "GLib.HookList", "null",
|
AddType (new SimpleGen ("GHookList", "GLib.HookList", "null",
|
||||||
|
|
Loading…
Reference in a new issue