Differences From Artifact [156d215610]:
- File
src/OFList.m
— part of check-in
[e2b06423e0]
at
2010-09-05 23:19:08
on branch trunk
— Replace OFObject* with id in many places.
We assume now that every object understands retain, release, etc. so
that we can weaken the type from OFObject* to id. This makes it
possible to use different root object classes. (user: js, size: 4362) [annotate] [blame] [check-ins using]
To Artifact [79d7008d03]:
- File src/OFList.m — part of check-in [2cb79baae4] at 2010-09-06 13:47:45 on branch trunk — Make OFList conform to OFCollection and OFFastEnumeration protocol. (user: js, size: 5732) [annotate] [blame] [check-ins using]
︙ | |||
66 67 68 69 70 71 72 73 74 75 76 77 78 79 | 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | + | lastListObject->next = o; lastListObject = o; if (firstListObject == NULL) firstListObject = o; count++; mutations++; [obj retain]; return o; } - (of_list_object_t*)prependObject: (id)obj |
︙ | |||
89 90 91 92 93 94 95 96 97 98 99 100 101 102 | 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | + | firstListObject->prev = o; firstListObject = o; if (lastListObject == NULL) lastListObject = o; count++; mutations++; [obj retain]; return o; } - (of_list_object_t*)insertObject: (id)obj |
︙ | |||
114 115 116 117 118 119 120 121 122 123 124 125 126 127 | 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 | + | listobj->prev = o; if (listobj == firstListObject) firstListObject = o; count++; mutations++; [obj retain]; return o; } - (of_list_object_t*)insertObject: (id)obj |
︙ | |||
139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 | 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 | + + | listobj->next = o; if (listobj == lastListObject) lastListObject = o; count++; mutations++; [obj retain]; return o; } - (void)removeListObject: (of_list_object_t*)listobj { if (listobj->prev != NULL) listobj->prev->next = listobj->next; if (listobj->next != NULL) listobj->next->prev = listobj->prev; if (firstListObject == listobj) firstListObject = listobj->next; if (lastListObject == listobj) lastListObject = listobj->prev; count--; mutations++; [listobj->object release]; [self freeMemory: listobj]; } - (size_t)count |
︙ | |||
247 248 249 250 251 252 253 254 | 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | OF_HASH_ADD(hash, h & 0xFF); } OF_HASH_FINALIZE(hash); return hash; } - (int)countByEnumeratingWithState: (of_fast_enumeration_state_t*)state objects: (id*)objects count: (int)count_ { of_list_object_t **list_obj = (of_list_object_t**)state->extra; state->itemsPtr = objects; state->mutationsPtr = &mutations; if (state->state == 0) { *list_obj = firstListObject; state->state = 1; } if (*list_obj == NULL) return 0; objects[0] = (*list_obj)->object; *list_obj = (*list_obj)->next; return 1; } - (OFEnumerator*)objectEnumerator { return [[[OFListEnumerator alloc] initWithFirstListObject: firstListObject mutationsPointer: &mutations] autorelease]; } @end /// \cond internal @implementation OFListEnumerator - initWithFirstListObject: (of_list_object_t*)first_ mutationsPointer: (unsigned long*)mutationsPtr_; { self = [super init]; first = first_; current = first_; mutations = *mutationsPtr_; mutationsPtr = mutationsPtr_; return self; } - (id)nextObject { id ret; if (*mutationsPtr != mutations) @throw [OFEnumerationMutationException newWithClass: isa]; if (current == NULL) return nil; ret = current->object; current = current->next; return ret; } - (void)reset { if (*mutationsPtr != mutations) @throw [OFEnumerationMutationException newWithClass: isa]; current = first; } @end /// \endcond |