Mercurial > projects > dstep
annotate dstep/foundation/NSPointerFunctions.d @ 25:b9de51448c6b
Added an id constructor. Changed the string mixin to a template mixin. Added support for building as a dynamic library
author | Jacob Carlborg <doob@me.com> |
---|---|
date | Tue, 06 Apr 2010 11:37:27 +0200 |
parents | 19885b43130e |
children |
rev | line source |
---|---|
14 | 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.NSPointerFunctions; | |
8 | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
9 import dstep.foundation.NSObjCRuntime; |
14 | 10 import dstep.foundation.NSObject; |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
11 import dstep.foundation.NSZone; |
14 | 12 import dstep.objc.bridge.Bridge; |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
13 import dstep.objc.objc; |
14 | 14 |
15 alias NSUInteger NSPointerFunctionsOptions; | |
16 | |
17 enum | |
18 { | |
19 NSPointerFunctionsStrongMemory = (0 << 0), | |
20 NSPointerFunctionsZeroingWeakMemory = (1 << 0), | |
21 NSPointerFunctionsOpaqueMemory = (2 << 0), | |
22 NSPointerFunctionsMallocMemory = (3 << 0), | |
23 NSPointerFunctionsMachVirtualMemory = (4 << 0), | |
24 NSPointerFunctionsObjectPersonality = (0 << 8), | |
25 NSPointerFunctionsOpaquePersonality = (1 << 8), | |
26 NSPointerFunctionsObjectPointerPersonality = (2 << 8), | |
27 NSPointerFunctionsCStringPersonality = (3 << 8), | |
28 NSPointerFunctionsStructPersonality = (4 << 8), | |
29 NSPointerFunctionsIntegerPersonality = (5 << 8), | |
30 NSPointerFunctionsCopyIn = (1 << 16) | |
31 } | |
32 | |
33 class NSPointerFunctions : NSObject, INSCopying | |
34 { | |
25
b9de51448c6b
Added an id constructor. Changed the string mixin to a template mixin. Added support for building as a dynamic library
Jacob Carlborg <doob@me.com>
parents:
16
diff
changeset
|
35 mixin ObjcWrap; |
b9de51448c6b
Added an id constructor. Changed the string mixin to a template mixin. Added support for building as a dynamic library
Jacob Carlborg <doob@me.com>
parents:
16
diff
changeset
|
36 |
b9de51448c6b
Added an id constructor. Changed the string mixin to a template mixin. Added support for building as a dynamic library
Jacob Carlborg <doob@me.com>
parents:
16
diff
changeset
|
37 this (id object) |
b9de51448c6b
Added an id constructor. Changed the string mixin to a template mixin. Added support for building as a dynamic library
Jacob Carlborg <doob@me.com>
parents:
16
diff
changeset
|
38 { |
b9de51448c6b
Added an id constructor. Changed the string mixin to a template mixin. Added support for building as a dynamic library
Jacob Carlborg <doob@me.com>
parents:
16
diff
changeset
|
39 super(object); |
b9de51448c6b
Added an id constructor. Changed the string mixin to a template mixin. Added support for building as a dynamic library
Jacob Carlborg <doob@me.com>
parents:
16
diff
changeset
|
40 } |
14 | 41 |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
42 this () |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
43 { |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
44 super(typeof(this).alloc.init.objcObject); |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
45 } |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
46 |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
47 typeof(this) init () |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
48 { |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
49 return invokeObjcSelf!(typeof(this), "init"); |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
50 } |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
51 |
14 | 52 Object initWithOptions (uint options) |
53 { | |
54 return invokeObjcSelf!(Object, "initWithOptions:", uint)(options); | |
55 } | |
56 | |
57 this (uint options) | |
58 { | |
59 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); | |
60 id result = Bridge.invokeObjcMethod!(id, "initWithOptions:", uint)(objcObject, options); | |
61 | |
62 if (result) | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
63 objcObject = result; |
14 | 64 |
65 dObject = this; | |
66 } | |
67 | |
68 static Object pointerFunctionsWithOptions (uint options) | |
69 { | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
70 return invokeObjcSuperClass!(Object, "pointerFunctionsWithOptions:", uint)(options); |
14 | 71 } |
72 | |
73 bool usesStrongWriteBarrier () | |
74 { | |
75 return invokeObjcSelf!(bool, "usesStrongWriteBarrier"); | |
76 } | |
77 | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
78 void setUsesStrongWriteBarrier (bool arg) |
14 | 79 { |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
80 return invokeObjcSelf!(void, "setUsesStrongWriteBarrier:", bool)(arg); |
14 | 81 } |
82 | |
83 bool usesWeakReadAndWriteBarriers () | |
84 { | |
85 return invokeObjcSelf!(bool, "usesWeakReadAndWriteBarriers"); | |
86 } | |
87 | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
88 void setUsesWeakReadAndWriteBarriers (bool arg) |
14 | 89 { |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
90 return invokeObjcSelf!(void, "setUsesWeakReadAndWriteBarriers:", bool)(arg); |
14 | 91 } |
92 | |
93 Object copyWithZone (NSZone* zone) | |
94 { | |
95 return invokeObjcSelf!(Object, "copyWithZone:", NSZone*)(zone); | |
96 } | |
97 } | |
98 |