Use Marshal.GetFunctionPointerForDelegate<T> (#301)

This make code more trim friendly

Improve #300
This commit is contained in:
Andrii Kurdiumov 2022-01-26 00:46:06 +06:00 committed by GitHub
parent afc7ab450b
commit 723fef9d8d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 3 additions and 3 deletions

View File

@ -32,7 +32,7 @@ namespace Gtk
{
unsafe {
IntPtr* raw_ptr = (IntPtr*) (((long) gtype.GetClassPtr ()) + (long) class_abi.GetFieldOffset ("get_size"));
*raw_ptr = Marshal.GetFunctionPointerForDelegate ((Delegate) callback);
*raw_ptr = Marshal.GetFunctionPointerForDelegate (callback);
}
}

View File

@ -41,7 +41,7 @@ namespace Gtk
{
unsafe {
IntPtr* raw_ptr = (IntPtr*) (((long) gtype.GetClassPtr()) + (long) class_abi.GetFieldOffset("forall"));
*raw_ptr = Marshal.GetFunctionPointerForDelegate((Delegate) callback);
*raw_ptr = Marshal.GetFunctionPointerForDelegate(callback);
}
}

View File

@ -176,7 +176,7 @@ namespace GtkSharp.Generation {
// Override VM; class_offset var is generated by object generatable
sw.WriteLine("\t\t\tunsafe {");
sw.WriteLine("\t\t\t\tIntPtr* raw_ptr = (IntPtr*)(((long) gtype.GetClassPtr()) + (long) class_abi.GetFieldOffset(\"{0}\"));", CName);
sw.WriteLine("\t\t\t\t*raw_ptr = Marshal.GetFunctionPointerForDelegate((Delegate) callback);");
sw.WriteLine("\t\t\t\t*raw_ptr = Marshal.GetFunctionPointerForDelegate(callback);");
sw.WriteLine("\t\t\t}");
sw.WriteLine("\t\t}");
sw.WriteLine ();