Mercurial > projects > dstep
comparison dstep/coredata/NSManagedObject.d @ 16:19885b43130e
Huge update, the bridge actually works now
author | Jacob Carlborg <doob@me.com> |
---|---|
date | Sun, 03 Jan 2010 22:06:11 +0100 |
parents | |
children | b9de51448c6b |
comparison
equal
deleted
inserted
replaced
15:7ff919f595d5 | 16:19885b43130e |
---|---|
1 /** | |
2 * Copyright: Copyright (c) 2009 Jacob Carlborg. | |
3 * Authors: Jacob Carlborg | |
4 * Version: Initial created: Sep 25, 2009 | |
5 * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0) | |
6 */ | |
7 module dstep.coredata.NSManagedObject; | |
8 | |
9 import dstep.coredata.NSEntityDescription; | |
10 | |
11 import dstep.coredata.NSManagedObjectContext; | |
12 import dstep.coredata.NSManagedObjectID; | |
13 import dstep.foundation.NSArray; | |
14 import dstep.foundation.NSDictionary; | |
15 import dstep.foundation.NSError; | |
16 import dstep.foundation.NSKeyValueObserving; | |
17 import dstep.foundation.NSObject; | |
18 import dstep.foundation.NSSet; | |
19 import dstep.foundation.NSString; | |
20 import dstep.objc.bridge.Bridge; | |
21 import dstep.objc.objc; | |
22 | |
23 class NSManagedObject : NSObject | |
24 { | |
25 mixin (ObjcWrap); | |
26 | |
27 NSManagedObject initWithEntity (NSEntityDescription entity, NSManagedObjectContext context) | |
28 { | |
29 id result = invokeObjcSelf!(id, "initWithEntity:insertIntoManagedObjectContext:", NSEntityDescription, NSManagedObjectContext)(entity, context); | |
30 return result is this.objcObject ? this : (result !is null ? new NSManagedObject(result) : null); | |
31 } | |
32 | |
33 this (NSEntityDescription entity, NSManagedObjectContext context) | |
34 { | |
35 super(NSManagedObject.alloc.initWithEntity(entity, context).objcObject); | |
36 } | |
37 | |
38 NSManagedObjectContext managedObjectContext () | |
39 { | |
40 return invokeObjcSelf!(NSManagedObjectContext, "managedObjectContext"); | |
41 } | |
42 | |
43 NSEntityDescription entity () | |
44 { | |
45 return invokeObjcSelf!(NSEntityDescription, "entity"); | |
46 } | |
47 | |
48 NSManagedObjectID objectID () | |
49 { | |
50 return invokeObjcSelf!(NSManagedObjectID, "objectID"); | |
51 } | |
52 | |
53 bool isInserted () | |
54 { | |
55 return invokeObjcSelf!(bool, "isInserted"); | |
56 } | |
57 | |
58 bool isUpdated () | |
59 { | |
60 return invokeObjcSelf!(bool, "isUpdated"); | |
61 } | |
62 | |
63 bool isDeleted () | |
64 { | |
65 return invokeObjcSelf!(bool, "isDeleted"); | |
66 } | |
67 | |
68 bool isFault () | |
69 { | |
70 return invokeObjcSelf!(bool, "isFault"); | |
71 } | |
72 | |
73 bool hasFaultForRelationshipNamed (NSString key) | |
74 { | |
75 return invokeObjcSelf!(bool, "hasFaultForRelationshipNamed:", NSString)(key); | |
76 } | |
77 | |
78 void willAccessValueForKey (NSString key) | |
79 { | |
80 return invokeObjcSelf!(void, "willAccessValueForKey:", NSString)(key); | |
81 } | |
82 | |
83 void didAccessValueForKey (NSString key) | |
84 { | |
85 return invokeObjcSelf!(void, "didAccessValueForKey:", NSString)(key); | |
86 } | |
87 | |
88 void willChangeValueForKey (NSString key) | |
89 { | |
90 return invokeObjcSelf!(void, "willChangeValueForKey:", NSString)(key); | |
91 } | |
92 | |
93 void didChangeValueForKey (NSString key) | |
94 { | |
95 return invokeObjcSelf!(void, "didChangeValueForKey:", NSString)(key); | |
96 } | |
97 | |
98 void willChangeValueForKey (NSString inKey, uint inMutationKind, NSSet inObjects) | |
99 { | |
100 return invokeObjcSelf!(void, "willChangeValueForKey:withSetMutation:usingObjects:", NSString, uint, NSSet)(inKey, inMutationKind, inObjects); | |
101 } | |
102 | |
103 void didChangeValueForKey (NSString inKey, uint inMutationKind, NSSet inObjects) | |
104 { | |
105 return invokeObjcSelf!(void, "didChangeValueForKey:withSetMutation:usingObjects:", NSString, uint, NSSet)(inKey, inMutationKind, inObjects); | |
106 } | |
107 | |
108 void setObservationInfo (void* inObservationInfo) | |
109 { | |
110 return invokeObjcSelf!(void, "setObservationInfo:", void*)(inObservationInfo); | |
111 } | |
112 | |
113 void* observationInfo () | |
114 { | |
115 return invokeObjcSelf!(void*, "observationInfo"); | |
116 } | |
117 | |
118 void awakeFromFetch () | |
119 { | |
120 return invokeObjcSelf!(void, "awakeFromFetch"); | |
121 } | |
122 | |
123 void awakeFromInsert () | |
124 { | |
125 return invokeObjcSelf!(void, "awakeFromInsert"); | |
126 } | |
127 | |
128 void willSave () | |
129 { | |
130 return invokeObjcSelf!(void, "willSave"); | |
131 } | |
132 | |
133 void didSave () | |
134 { | |
135 return invokeObjcSelf!(void, "didSave"); | |
136 } | |
137 | |
138 void willTurnIntoFault () | |
139 { | |
140 return invokeObjcSelf!(void, "willTurnIntoFault"); | |
141 } | |
142 | |
143 void didTurnIntoFault () | |
144 { | |
145 return invokeObjcSelf!(void, "didTurnIntoFault"); | |
146 } | |
147 | |
148 Object valueForKey (NSString key) | |
149 { | |
150 return invokeObjcSelf!(Object, "valueForKey:", NSString)(key); | |
151 } | |
152 | |
153 void setValue (Object value, NSString key) | |
154 { | |
155 return invokeObjcSelf!(void, "setValue:forKey:", Object, NSString)(value, key); | |
156 } | |
157 | |
158 Object primitiveValueForKey (NSString key) | |
159 { | |
160 return invokeObjcSelf!(Object, "primitiveValueForKey:", NSString)(key); | |
161 } | |
162 | |
163 void setPrimitiveValue (Object value, NSString key) | |
164 { | |
165 return invokeObjcSelf!(void, "setPrimitiveValue:forKey:", Object, NSString)(value, key); | |
166 } | |
167 | |
168 NSDictionary committedValuesForKeys (NSArray keys) | |
169 { | |
170 return invokeObjcSelf!(NSDictionary, "committedValuesForKeys:", NSArray)(keys); | |
171 } | |
172 | |
173 NSDictionary changedValues () | |
174 { | |
175 return invokeObjcSelf!(NSDictionary, "changedValues"); | |
176 } | |
177 | |
178 bool validateValue (id* value, NSString key, ref NSError error) | |
179 { | |
180 id __arg2; | |
181 | |
182 if (error) | |
183 __arg2 = error.objcObject; | |
184 | |
185 bool result = invokeObjcSelf!(bool, "validateValue:forKey:error:", id*, NSString, id*)(value, key, &__arg2); | |
186 | |
187 if (__arg2) | |
188 error = new NSError(__arg2); | |
189 | |
190 return result; | |
191 } | |
192 | |
193 bool validateForDelete (ref NSError error) | |
194 { | |
195 id __arg0; | |
196 | |
197 if (error) | |
198 __arg0 = error.objcObject; | |
199 | |
200 bool result = invokeObjcSelf!(bool, "validateForDelete:", id*)(&__arg0); | |
201 | |
202 if (__arg0) | |
203 error = new NSError(__arg0); | |
204 | |
205 return result; | |
206 } | |
207 | |
208 bool validateForInsert (ref NSError error) | |
209 { | |
210 id __arg0; | |
211 | |
212 if (error) | |
213 __arg0 = error.objcObject; | |
214 | |
215 bool result = invokeObjcSelf!(bool, "validateForInsert:", id*)(&__arg0); | |
216 | |
217 if (__arg0) | |
218 error = new NSError(__arg0); | |
219 | |
220 return result; | |
221 } | |
222 | |
223 bool validateForUpdate (ref NSError error) | |
224 { | |
225 id __arg0; | |
226 | |
227 if (error) | |
228 __arg0 = error.objcObject; | |
229 | |
230 bool result = invokeObjcSelf!(bool, "validateForUpdate:", id*)(&__arg0); | |
231 | |
232 if (__arg0) | |
233 error = new NSError(__arg0); | |
234 | |
235 return result; | |
236 } | |
237 } | |
238 |