comparison dstep/foundation/NSProtocolChecker.d @ 14:89f3c3ef1fd2

Added the Foundation framework
author Jacob Carlborg <doob@me.com>
date Mon, 03 Aug 2009 15:23:15 +0200
parents
children 19885b43130e
comparison
equal deleted inserted replaced
13:4f583f7e242e 14:89f3c3ef1fd2
1 /**
2 * Copyright: Copyright (c) 2009 Jacob Carlborg.
3 * Authors: Jacob Carlborg
4 * Version: Initial created: Aug 3, 2009
5 * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0)
6 */
7 module dstep.foundation.NSProtocolChecker;
8
9 import dstep.foundation.NSObject;
10 import dstep.foundation.NSProxy;
11 import dstep.objc.bridge.Bridge;
12 import dstep.objc.objc : id;
13
14 class NSProtocolChecker : NSProxy
15 {
16 mixin ObjcWrap;
17 mixin TNSProtocolCheckerCreation;
18
19 Protocol protocol ()
20 {
21 return invokeObjcSelf!(Protocol, "protocol");
22 }
23
24 NSObject target ()
25 {
26 return invokeObjcSelf!(NSObject, "target");
27 }
28 }
29
30 template TNSProtocolCheckerCreation ()
31 {
32 static Object protocolCheckerWithTarget (NSObject anObject, Protocol aProtocol)
33 {
34 return invokeObjcSelfClass!(Object, "protocolCheckerWithTarget:protocol:", NSObject, Protocol)(anObject, aProtocol);
35 }
36
37 Object initWithTarget (NSObject anObject, Protocol aProtocol)
38 {
39 return invokeObjcSelf!(Object, "initWithTarget:protocol:", NSObject, Protocol)(anObject, aProtocol);
40 }
41
42 this (NSObject anObject, Protocol aProtocol)
43 {
44 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass);
45 id result = Bridge.invokeObjcMethod!(id, "initWithTarget:protocol:", NSObject, Protocol)(objcObject, anObject, aProtocol);
46
47 if (result)
48 objcObject = ret;
49
50 dObject = this;
51 }
52 }
53