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.NSCoder;
|
|
8
|
|
9 import dstep.foundation.NSData;
|
|
10 import dstep.foundation.NSObject;
|
|
11 import dstep.foundation.NSString;
|
|
12 import dstep.objc.bridge.Bridge;
|
|
13 import dstep.objc.objc : id;
|
|
14
|
|
15 class NSCoder : NSObject
|
|
16 {
|
|
17 mixin ObjcWrap;
|
|
18 mixin TNSGeometryCoding;
|
|
19 mixin TNSExtendedCoder;
|
|
20 mixin TNSTypedstreamCompatibility;
|
|
21 mixin TNSGeometryKeyedCoding;
|
|
22
|
|
23 void encodeValueOfObjCType (char* type, void* addr)
|
|
24 {
|
|
25 return invokeObjcSelf!(void, "encodeValueOfObjCType:at:", char*, void*)(type, addr);
|
|
26 }
|
|
27
|
|
28 void encodeDataObject (NSData data)
|
|
29 {
|
|
30 return invokeObjcSelf!(void, "encodeDataObject:", NSData)(data);
|
|
31 }
|
|
32
|
|
33 void decodeValueOfObjCType (char* type, void* data)
|
|
34 {
|
|
35 return invokeObjcSelf!(void, "decodeValueOfObjCType:at:", char*, void*)(type, data);
|
|
36 }
|
|
37
|
|
38 NSData decodeDataObject ()
|
|
39 {
|
|
40 return invokeObjcSelf!(NSData, "decodeDataObject");
|
|
41 }
|
|
42
|
|
43 NSInteger versionForClassName (NSString className)
|
|
44 {
|
|
45 return invokeObjcSelf!(NSInteger, "versionForClassName:", NSString)(className);
|
|
46 }
|
|
47 }
|
|
48
|
|
49 template TNSExtendedCoder ()
|
|
50 {
|
|
51 void encodeObject (Object object)
|
|
52 {
|
|
53 return invokeObjcSelf!(void, "encodeObject:", Object)(object);
|
|
54 }
|
|
55
|
|
56 void encodePropertyList (Object aPropertyList)
|
|
57 {
|
|
58 return invokeObjcSelf!(void, "encodePropertyList:", Object)(aPropertyList);
|
|
59 }
|
|
60
|
|
61 void encodeRootObject (Object rootObject)
|
|
62 {
|
|
63 return invokeObjcSelf!(void, "encodeRootObject:", Object)(rootObject);
|
|
64 }
|
|
65
|
|
66 void encodeBycopyObject (Object anObject)
|
|
67 {
|
|
68 return invokeObjcSelf!(void, "encodeBycopyObject:", Object)(anObject);
|
|
69 }
|
|
70
|
|
71 void encodeByrefObject (Object anObject)
|
|
72 {
|
|
73 return invokeObjcSelf!(void, "encodeByrefObject:", Object)(anObject);
|
|
74 }
|
|
75
|
|
76 void encodeConditionalObject (Object object)
|
|
77 {
|
|
78 return invokeObjcSelf!(void, "encodeConditionalObject:", Object)(object);
|
|
79 }
|
|
80
|
|
81 void encodeValuesOfObjCTypes (char* encodeValuesOfObjCTypes, ...)
|
|
82 {
|
|
83 return invokeObjcSelf!(void, "encodeValuesOfObjCTypes:", char*)(encodeValuesOfObjCTypes);
|
|
84 }
|
|
85
|
|
86 void encodeArrayOfObjCType (char* type, NSUInteger count, void* array)
|
|
87 {
|
|
88 return invokeObjcSelf!(void, "encodeArrayOfObjCType:count:at:", char*, NSUInteger, void*)(type, count, array);
|
|
89 }
|
|
90
|
|
91 void encodeBytes (void* byteaddr, NSUInteger length)
|
|
92 {
|
|
93 return invokeObjcSelf!(void, "encodeBytes:length:", void*, NSUInteger)(byteaddr, length);
|
|
94 }
|
|
95
|
|
96 Object decodeObject ()
|
|
97 {
|
|
98 return invokeObjcSelf!(Object, "decodeObject");
|
|
99 }
|
|
100
|
|
101 Object decodePropertyList ()
|
|
102 {
|
|
103 return invokeObjcSelf!(Object, "decodePropertyList");
|
|
104 }
|
|
105
|
|
106 void decodeValuesOfObjCTypes (char* decodeValuesOfObjCTypes, ...)
|
|
107 {
|
|
108 return invokeObjcSelf!(void, "decodeValuesOfObjCTypes:", char*)(decodeValuesOfObjCTypes);
|
|
109 }
|
|
110
|
|
111 void decodeArrayOfObjCType (char* itemType, NSUInteger count, void* array)
|
|
112 {
|
|
113 return invokeObjcSelf!(void, "decodeArrayOfObjCType:count:at:", char*, NSUInteger, void*)(itemType, count, array);
|
|
114 }
|
|
115
|
|
116 void* decodeBytesWithReturnedLength (NSUInteger* lengthp)
|
|
117 {
|
|
118 return invokeObjcSelf!(void*, "decodeBytesWithReturnedLength:", NSUInteger*)(lengthp);
|
|
119 }
|
|
120
|
|
121 void setObjectZone (NSZone* zone)
|
|
122 {
|
|
123 return invokeObjcSelf!(void, "setObjectZone:", NSZone*)(zone);
|
|
124 }
|
|
125
|
|
126 NSZone* objectZone ()
|
|
127 {
|
|
128 return invokeObjcSelf!(NSZone*, "objectZone");
|
|
129 }
|
|
130
|
|
131 uint systemVersion ()
|
|
132 {
|
|
133 return invokeObjcSelf!(uint, "systemVersion");
|
|
134 }
|
|
135
|
|
136 bool allowsKeyedCoding ()
|
|
137 {
|
|
138 return invokeObjcSelf!(bool, "allowsKeyedCoding");
|
|
139 }
|
|
140
|
|
141 void encodeObject (Object objv, NSString key)
|
|
142 {
|
|
143 return invokeObjcSelf!(void, "encodeObject:forKey:", Object, NSString)(objv, key);
|
|
144 }
|
|
145
|
|
146 void encodeConditionalObject (Object objv, NSString key)
|
|
147 {
|
|
148 return invokeObjcSelf!(void, "encodeConditionalObject:forKey:", Object, NSString)(objv, key);
|
|
149 }
|
|
150
|
|
151 void encodeBool (bool boolv, NSString key)
|
|
152 {
|
|
153 return invokeObjcSelf!(void, "encodeBool:forKey:", bool, NSString)(boolv, key);
|
|
154 }
|
|
155
|
|
156 void encodeInt (int intv, NSString key)
|
|
157 {
|
|
158 return invokeObjcSelf!(void, "encodeInt:forKey:", int, NSString)(intv, key);
|
|
159 }
|
|
160
|
|
161 void encodeInt32 (int intv, NSString key)
|
|
162 {
|
|
163 return invokeObjcSelf!(void, "encodeInt32:forKey:", int, NSString)(intv, key);
|
|
164 }
|
|
165
|
|
166 void encodeInt64 (long intv, NSString key)
|
|
167 {
|
|
168 return invokeObjcSelf!(void, "encodeInt64:forKey:", long, NSString)(intv, key);
|
|
169 }
|
|
170
|
|
171 void encodeFloat (float realv, NSString key)
|
|
172 {
|
|
173 return invokeObjcSelf!(void, "encodeFloat:forKey:", float, NSString)(realv, key);
|
|
174 }
|
|
175
|
|
176 void encodeDouble (double realv, NSString key)
|
|
177 {
|
|
178 return invokeObjcSelf!(void, "encodeDouble:forKey:", double, NSString)(realv, key);
|
|
179 }
|
|
180
|
|
181 void encodeBytes (char* bytesp, NSUInteger lenv, NSString key)
|
|
182 {
|
|
183 return invokeObjcSelf!(void, "encodeBytes:length:forKey:", char*, NSUInteger, NSString)(bytesp, lenv, key);
|
|
184 }
|
|
185
|
|
186 bool containsValueForKey (NSString key)
|
|
187 {
|
|
188 return invokeObjcSelf!(bool, "containsValueForKey:", NSString)(key);
|
|
189 }
|
|
190
|
|
191 Object decodeObjectForKey (NSString key)
|
|
192 {
|
|
193 return invokeObjcSelf!(Object, "decodeObjectForKey:", NSString)(key);
|
|
194 }
|
|
195
|
|
196 bool decodeBoolForKey (NSString key)
|
|
197 {
|
|
198 return invokeObjcSelf!(bool, "decodeBoolForKey:", NSString)(key);
|
|
199 }
|
|
200
|
|
201 int decodeIntForKey (NSString key)
|
|
202 {
|
|
203 return invokeObjcSelf!(int, "decodeIntForKey:", NSString)(key);
|
|
204 }
|
|
205
|
|
206 int decodeInt32ForKey (NSString key)
|
|
207 {
|
|
208 return invokeObjcSelf!(int, "decodeInt32ForKey:", NSString)(key);
|
|
209 }
|
|
210
|
|
211 long decodeInt64ForKey (NSString key)
|
|
212 {
|
|
213 return invokeObjcSelf!(long, "decodeInt64ForKey:", NSString)(key);
|
|
214 }
|
|
215
|
|
216 float decodeFloatForKey (NSString key)
|
|
217 {
|
|
218 return invokeObjcSelf!(float, "decodeFloatForKey:", NSString)(key);
|
|
219 }
|
|
220
|
|
221 double decodeDoubleForKey (NSString key)
|
|
222 {
|
|
223 return invokeObjcSelf!(double, "decodeDoubleForKey:", NSString)(key);
|
|
224 }
|
|
225
|
|
226 char* decodeBytesForKey (NSString key, NSUInteger* lengthp)
|
|
227 {
|
|
228 return invokeObjcSelf!(char*, "decodeBytesForKey:returnedLength:", NSString, NSUInteger*)(key, lengthp);
|
|
229 }
|
|
230
|
|
231 void encodeInteger (NSInteger intv, NSString key)
|
|
232 {
|
|
233 return invokeObjcSelf!(void, "encodeInteger:forKey:", NSInteger, NSString)(intv, key);
|
|
234 }
|
|
235
|
|
236 NSInteger decodeIntegerForKey (NSString key)
|
|
237 {
|
|
238 return invokeObjcSelf!(NSInteger, "decodeIntegerForKey:", NSString)(key);
|
|
239 }
|
|
240 }
|
|
241
|
|
242 template TNSTypedstreamCompatibility ()
|
|
243 {
|
|
244 void encodeNXObject (Object object)
|
|
245 {
|
|
246 return invokeObjcSelf!(void, "encodeNXObject:", Object)(object);
|
|
247 }
|
|
248
|
|
249 Object decodeNXObject ()
|
|
250 {
|
|
251 return invokeObjcSelf!(Object, "decodeNXObject");
|
|
252 }
|
|
253 }
|
|
254
|
|
255 NSObject NXReadNSObjectFromCoder (NSCoder decoder)
|
|
256 {
|
|
257 return Bridge.invokeObjcFunction!(NSObject, bindings.NXReadNSObjectFromCoder, NSCoder)(decoder);
|
|
258 }
|
|
259
|