Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- version (D_LP64)
- alias double CGFloat;
- else
- alias float CGFloat;
- struct NSRect
- {
- NSPoint origin;
- NSSize size;
- }
- public struct NSPoint {
- public CGFloat x;// = 0.0;
- public CGFloat y;// = 0.0;
- }
- struct NSSize {
- public CGFloat width;// = 0.0;
- public CGFloat height;// = 0.0;
- }
- alias char* SEL;
- alias objc_class* Class;
- alias objc_object* id;
- struct objc_object
- {
- Class isa;
- }
- struct objc_class;
- extern (C)
- {
- Class objc_getClass (in char* name);
- id objc_msgSend (id theReceiver, SEL theSelector, ...);
- void objc_msgSend_stret(void* stretAddr, id theReceiver, SEL theSelector, ...);
- SEL sel_registerName (in char* str);
- }
- extern (C) int printf(in char*, ...);
- NSRect foo (id screen)
- {
- alias extern (C) NSRect function (id, SEL) frameFp;
- auto fp = cast(frameFp) &objc_msgSend_stret;
- return fp(screen, sel_registerName("visibleFrame".ptr));
- }
- int main ()
- {
- auto cls = objc_getClass("NSScreen".ptr);
- alias extern (C) id function (id, SEL) screenFp;
- auto screen = (cast(screenFp)&objc_msgSend)(cast(id) cls, sel_registerName("mainScreen".ptr));
- auto frame = foo(screen);
- printf("x=%f y=%f width=%f height=%f\n".ptr, frame.origin.x, frame.origin.y, frame.size.width, frame.size.height);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement