1
|
1 /**
|
|
2 * Copyright: Copyright (c) 2009 Jacob Carlborg.
|
|
3 * Authors: Jacob Carlborg
|
|
4 * Version: Initial created: Feb 1, 2009
|
|
5 * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0)
|
|
6 */
|
|
7 module dstep.objc.bridge.Wrapper;
|
|
8
|
|
9 import dstep.internal.String;
|
|
10 import dstep.objc.bridge.Bridge;
|
|
11 import dstep.objc.bridge.Capsule;
|
|
12 import dstep.objc.message;
|
|
13 import dstep.objc.objc;
|
|
14 import dstep.objc.runtime;
|
|
15
|
|
16 class ObjcWrapper
|
|
17 {
|
|
18 package objc_super* objcSuper;
|
|
19
|
|
20 static private Class objcClass_;
|
|
21 static private Class objcSuperClass_;
|
|
22
|
|
23 private id objcObject_;
|
|
24
|
|
25 /// Initialize object from an Objective-C object instance to wrap.
|
|
26 this (id object)
|
|
27 {
|
|
28 objcObject_ = object;
|
|
29 dObject = this;
|
|
30 }
|
|
31
|
|
32 static Class objcClass ()
|
|
33 {
|
|
34 return capsuleClass;
|
|
35 }
|
|
36
|
|
37 static Class objcSuperClass ()
|
|
38 {
|
|
39 if (!objcSuperClass_)
|
|
40 return objcSuperClass_ = objcClass.getSuperclass;
|
|
41
|
|
42 return objcSuperClass_;
|
|
43 }
|
|
44
|
|
45 id objcObject ()
|
|
46 {
|
|
47 return objcObject_;
|
|
48 }
|
|
49
|
|
50 protected id objcObject (id object)
|
|
51 {
|
|
52 return objcObject_ = object;
|
|
53 }
|
|
54
|
|
55 protected void dObject (Object dObject)
|
|
56 {
|
|
57 Bridge.setDObject(dObject, objcObject);
|
|
58 }
|
|
59
|
|
60 /*this (bool init = true, bool alloc = true)
|
|
61 {
|
|
62 if (init && alloc)
|
|
63 {
|
|
64 id result = objc_msgSend!(id)(objc_getClass(this.classinfo.name), sel.registerName!("alloc"));
|
|
65 id result2;
|
|
66
|
|
67 if (result)
|
|
68 result2 = objc_msgSend(result, sel.registerName!("init"));
|
|
69
|
|
70 if (result2)
|
|
71 objc.object = result2;
|
|
72
|
|
73 else
|
|
74 objc.object = result;
|
|
75 }
|
|
76
|
|
77 else if (alloc)
|
|
78 objc.object = objc_msgSend(objc_getClass(this.classinfo.name), sel.registerName!("alloc"));
|
|
79 }*/
|
|
80 } |