Skip to content

Instantly share code, notes, and snippets.

@migueldeicaza
Created February 9, 2012 21:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save migueldeicaza/085aacca4c8d1092ab28 to your computer and use it in GitHub Desktop.
Save migueldeicaza/085aacca4c8d1092ab28 to your computer and use it in GitHub Desktop.
diff --git a/src/ObjCRuntime/Class.cs b/src/ObjCRuntime/Class.cs
index ace21db..99d4556 100644
--- a/src/ObjCRuntime/Class.cs
+++ b/src/ObjCRuntime/Class.cs
@@ -30,7 +30,7 @@ using System;
using System.Reflection;
using System.Collections.Generic;
using System.Runtime.InteropServices;
-
+using System.Drawing;
using MonoMac.Foundation;
namespace MonoMac.ObjCRuntime {
@@ -111,7 +111,7 @@ namespace MonoMac.ObjCRuntime {
} while (true);
}
- internal static IntPtr Register (Type type) {
+ internal static IntPtr Register (Type type) {
RegisterAttribute attr = (RegisterAttribute) Attribute.GetCustomAttribute (type, typeof (RegisterAttribute), false);
string name = attr == null ? type.FullName : attr.Name ?? type.FullName;
return Class.Register (type, name);
@@ -224,16 +224,33 @@ namespace MonoMac.ObjCRuntime {
RegisterMethod (minfo, ea, type, handle);
}
+ delegate void CB (IntPtr dest, IntPtr nso, IntPtr selector, IntPtr window, IntPtr sheet, RectangleF usingRect);
+
internal unsafe static void RegisterMethod (MethodInfo minfo, ExportAttribute ea, Type type, IntPtr handle) {
NativeMethodBuilder builder = new NativeMethodBuilder (minfo, type, ea);
-
- class_addMethod (minfo.IsStatic ? ((objc_class *) handle)->isa : handle, builder.Selector, builder.Delegate, builder.Signature);
- method_wrappers.Add (builder.Delegate);
+ CB cb = WillPosition;
+ Delegate d;
+ if (minfo.Name == "WillPositionSheet")
+ d = cb;
+ else
+ d = builder.Delegate;
+
+ class_addMethod (minfo.IsStatic ? ((objc_class *) handle)->isa : handle, builder.Selector, d, builder.Signature);
+ method_wrappers.Add (d);
#if DEBUG
Console.WriteLine ("[METHOD] Registering {0}[0x{1:x}|{2}] on {3} -> ({4})", ea.Selector, (int) builder.Selector, builder.Signature, type, minfo);
#endif
}
+ static void WillPosition (IntPtr dest, IntPtr nso, IntPtr selector, IntPtr window, IntPtr sheet, RectangleF usingRect)
+ {
+ var anso = Runtime.GetNSObject (nso);
+ var awin = Runtime.GetNSObject (window);
+ var asheet = Runtime.GetNSObject (sheet);
+
+ Console.WriteLine ("Got {0} {1} {2} and {3}", anso, awin, asheet, usingRect);
+ }
+
[DllImport ("/usr/lib/libobjc.dylib")]
extern static IntPtr objc_allocateClassPair (IntPtr superclass, string name, IntPtr extraBytes);
[DllImport ("/usr/lib/libobjc.dylib")]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment