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 ();