Comment: | OFArray: +[arrayWithCArray:length:] -> +[arrayWithObjects:count:].
This is required for the new array literals. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
008be86a167d80a2925e8c05dfbc4c05 |
User & Date: | js on 2012-03-12 11:54:22 |
Other Links: | manifest | tags |
2012-03-12
| ||
12:05 | Make array literals work. check-in: a18e732a06 user: js tags: trunk | |
11:54 | OFArray: +[arrayWithCArray:length:] -> +[arrayWithObjects:count:]. check-in: 008be86a16 user: js tags: trunk | |
11:01 | Remove +[OFArray arrayWithCArray:] as it is pretty useless. check-in: 32f7b1390a user: js tags: trunk | |
Modified src/OFArray.h from [d765ca91e7] to [bf9a1af9b3].
︙ | ︙ | |||
83 84 85 86 87 88 89 | * \brief Creates a new OFArray with the objects from the specified C array of * the specified length. * * \param objects A C array of objects * \param length The length of the C array * \return A new autoreleased OFArray */ | | | | 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 | * \brief Creates a new OFArray with the objects from the specified C array of * the specified length. * * \param objects A C array of objects * \param length The length of the C array * \return A new autoreleased OFArray */ + arrayWithObjects: (id*)objects count: (size_t)count; /** * \brief Initializes an OFArray with the specified object. * * \param object An object * \return An initialized OFArray */ |
︙ | ︙ | |||
128 129 130 131 132 133 134 | * \brief Initializes an OFArray with the objects from the specified C array of * the specified length. * * \param objects A C array of objects * \param length The length of the C array * \return An initialized OFArray */ | | | | 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 | * \brief Initializes an OFArray with the objects from the specified C array of * the specified length. * * \param objects A C array of objects * \param length The length of the C array * \return An initialized OFArray */ - initWithObjects: (id*)objects count: (size_t)count; /** * \brief Returns a specified object of the array. * * The returned object is <i>not</i> retained and autoreleased for performance * reasons! * |
︙ | ︙ | |||
156 157 158 159 160 161 162 | inRange: (of_range_t)range; /** * \brief Returns the objects of the array as a C array. * * \return The objects of the array as a C array */ | | | 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 | inRange: (of_range_t)range; /** * \brief Returns the objects of the array as a C array. * * \return The objects of the array as a C array */ - (id*)objects; /** * \brief Returns the index of the first object that is equivalent to the * specified object or OF_INVALID_INDEX if it was not found. * * \param object The object whose index is returned * \return The index of the first object equivalent to the specified object |
︙ | ︙ |
Modified src/OFArray.m from [8fffeb8088] to [f4dee3f63a].
︙ | ︙ | |||
71 72 73 74 75 76 77 | } - initWithArray: (OFArray*)array { return (id)[[OFArray_adjacent alloc] initWithArray: array]; } | | | | | | 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | } - initWithArray: (OFArray*)array { return (id)[[OFArray_adjacent alloc] initWithArray: array]; } - initWithObjects: (id*)objects count: (size_t)count { return (id)[[OFArray_adjacent alloc] initWithObjects: objects count: count]; } - initWithSerialization: (OFXMLElement*)element { return (id)[[OFArray_adjacent alloc] initWithSerialization: element]; } |
︙ | ︙ | |||
148 149 150 151 152 153 154 | } + arrayWithArray: (OFArray*)array { return [[[self alloc] initWithArray: array] autorelease]; } | | | | | | 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 | } + arrayWithArray: (OFArray*)array { return [[[self alloc] initWithArray: array] autorelease]; } + arrayWithObjects: (id*)objects count: (size_t)count { return [[[self alloc] initWithObjects: objects count: count] autorelease]; } - init { if (isa == [OFArray class]) { Class c = isa; [self release]; |
︙ | ︙ | |||
202 203 204 205 206 207 208 | { Class c = isa; [self release]; @throw [OFNotImplementedException exceptionWithClass: c selector: _cmd]; } | | | | 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 | { Class c = isa; [self release]; @throw [OFNotImplementedException exceptionWithClass: c selector: _cmd]; } - initWithObjects: (id*)objects count: (size_t)count { Class c = isa; [self release]; @throw [OFNotImplementedException exceptionWithClass: c selector: _cmd]; } |
︙ | ︙ | |||
234 235 236 237 238 239 240 | { size_t i; for (i = 0; i < range.length; i++) buffer[i] = [self objectAtIndex: range.start + i]; } | | | 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 | { size_t i; for (i = 0; i < range.length; i++) buffer[i] = [self objectAtIndex: range.start + i]; } - (id*)objects { OFObject *container; size_t count; id *buffer; container = [[[OFObject alloc] init] autorelease]; count = [self count]; |
︙ | ︙ | |||
333 334 335 336 337 338 339 | buffer = [self allocMemoryForNItems: range.length ofSize: sizeof(*buffer)]; @try { [self getObjects: buffer inRange: range]; | | | | | | | | 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 | buffer = [self allocMemoryForNItems: range.length ofSize: sizeof(*buffer)]; @try { [self getObjects: buffer inRange: range]; ret = [OFArray arrayWithObjects: buffer count: range.length]; } @finally { [self freeMemory: buffer]; } return ret; } - (OFString*)componentsJoinedByString: (OFString*)separator { return [self componentsJoinedByString: separator usingSelector: @selector(description)]; } - (OFString*)componentsJoinedByString: (OFString*)separator usingSelector: (SEL)selector { OFAutoreleasePool *pool, *pool2; OFMutableString *ret; id *objects; size_t i, count = [self count]; IMP append; if (count == 0) return @""; if (count == 1) return [[self firstObject] performSelector: selector]; ret = [OFMutableString string]; append = [ret methodForSelector: @selector(appendString:)]; pool = [[OFAutoreleasePool alloc] init]; objects = [self objects]; pool2 = [[OFAutoreleasePool alloc] init]; for (i = 0; i < count - 1; i++) { append(ret, @selector(appendString:), [objects[i] performSelector: selector]); append(ret, @selector(appendString:), separator); [pool2 releaseObjects]; } append(ret, @selector(appendString:), [objects[i] performSelector: selector]); [ret makeImmutable]; [pool release]; return ret; } |
︙ | ︙ | |||
413 414 415 416 417 418 419 | return NO; return YES; } - (uint32_t)hash { | | | | 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 | return NO; return YES; } - (uint32_t)hash { id *objects = [self objects]; size_t i, count = [self count]; uint32_t hash; OF_HASH_INIT(hash); for (i = 0; i < count; i++) { uint32_t h = [objects[i] hash]; OF_HASH_ADD(hash, h >> 24); OF_HASH_ADD(hash, (h >> 16) & 0xFF); OF_HASH_ADD(hash, (h >> 8) & 0xFF); OF_HASH_ADD(hash, h & 0xFF); } |
︙ | ︙ | |||
467 468 469 470 471 472 473 | } - (OFXMLElement*)XMLElementBySerializing { OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; OFAutoreleasePool *pool2; OFXMLElement *element; | | | | 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 | } - (OFXMLElement*)XMLElementBySerializing { OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; OFAutoreleasePool *pool2; OFXMLElement *element; id <OFSerialization> *objects = [self objects]; size_t i, count = [self count]; if ([self isKindOfClass: [OFMutableArray class]]) element = [OFXMLElement elementWithName: @"OFMutableArray" namespace: OF_SERIALIZATION_NS]; else element = [OFXMLElement elementWithName: @"OFArray" namespace: OF_SERIALIZATION_NS]; pool2 = [[OFAutoreleasePool alloc] init]; for (i = 0; i < count; i++) { [element addChild: [objects[i] XMLElementBySerializing]]; [pool2 releaseObjects]; } [element retain]; [pool release]; [element autorelease]; |
︙ | ︙ | |||
513 514 515 516 517 518 519 | [JSON makeImmutable]; return JSON; } - (void)makeObjectsPerformSelector: (SEL)selector { | | | | | | | | 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 | [JSON makeImmutable]; return JSON; } - (void)makeObjectsPerformSelector: (SEL)selector { id *objects = [self objects]; size_t i, count = [self count]; for (i = 0; i < count; i++) ((void(*)(id, SEL))[objects[i] methodForSelector: selector])(objects[i], selector); } - (void)makeObjectsPerformSelector: (SEL)selector withObject: (id)object { id *objects = [self objects]; size_t i, count = [self count]; for (i = 0; i < count; i++) ((void(*)(id, SEL, id))[objects[i] methodForSelector: selector])(objects[i], selector, object); } - (OFArray*)sortedArray { OFMutableArray *new = [[self mutableCopy] autorelease]; [new sort]; |
︙ | ︙ | |||
568 569 570 571 572 573 574 | if (count > INT_MAX) @throw [OFOutOfRangeException exceptionWithClass: isa]; if (state->state >= count) return 0; state->state = count; | | | 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 | if (count > INT_MAX) @throw [OFOutOfRangeException exceptionWithClass: isa]; if (state->state >= count) return 0; state->state = count; state->itemsPtr = [self objects]; state->mutationsPtr = (unsigned long*)self; return (int)count; } - (OFEnumerator*)objectEnumerator { |
︙ | ︙ | |||
609 610 611 612 613 614 615 | @try { [self enumerateObjectsUsingBlock: ^ (id object, size_t index, BOOL *stop) { tmp[index] = block(object, index); }]; | | | | 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 | @try { [self enumerateObjectsUsingBlock: ^ (id object, size_t index, BOOL *stop) { tmp[index] = block(object, index); }]; ret = [OFArray arrayWithObjects: tmp count: count]; } @finally { [self freeMemory: tmp]; } return ret; } |
︙ | ︙ | |||
634 635 636 637 638 639 640 | [self enumerateObjectsUsingBlock: ^ (id object, size_t index, BOOL *stop) { if (block(object, index)) tmp[i++] = object; }]; | | | | 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 | [self enumerateObjectsUsingBlock: ^ (id object, size_t index, BOOL *stop) { if (block(object, index)) tmp[i++] = object; }]; ret = [OFArray arrayWithObjects: tmp count: i]; } @finally { [self freeMemory: tmp]; } return ret; } |
︙ | ︙ |
Modified src/OFArray_adjacent.m from [650b5ba321] to [cb33472061].
︙ | ︙ | |||
83 84 85 86 87 88 89 | } return self; } - initWithArray: (OFArray*)array_ { | | | | | | | | | | | | 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 | } return self; } - initWithArray: (OFArray*)array_ { id *objects; size_t i, count; self = [self init]; @try { objects = [array_ objects]; count = [array_ count]; } @catch (id e) { [self release]; @throw e; } @try { for (i = 0; i < count; i++) [objects[i] retain]; [array addNItems: count fromCArray: objects]; } @catch (id e) { for (i = 0; i < count; i++) [objects[i] release]; /* Prevent double-release of objects */ [array release]; array = nil; [self release]; @throw e; } return self; } - initWithObjects: (id*)objects count: (size_t)count { self = [self init]; @try { size_t i; for (i = 0; i < count; i++) [objects[i] retain]; [array addNItems: count fromCArray: objects]; } @catch (id e) { size_t i; for (i = 0; i < count; i++) [objects[i] release]; [self release]; @throw e; } return self; |
︙ | ︙ | |||
187 188 189 190 191 192 193 | } - (size_t)count { return [array count]; } | | | | | | | | | | | | | | | | | | | | | 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 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 330 331 332 333 | } - (size_t)count { return [array count]; } - (id*)objects { return [array cArray]; } - (id)objectAtIndex: (size_t)index { return *((id*)[array itemAtIndex: index]); } - (void)getObjects: (id*)buffer inRange: (of_range_t)range { id *objects = [array cArray]; size_t i, count = [array count]; if (range.start + range.length > count) @throw [OFOutOfRangeException exceptionWithClass: isa]; for (i = 0; i < range.length; i++) buffer[i] = objects[range.start + i]; } - (size_t)indexOfObject: (id)object { id *objects = [array cArray]; size_t i, count = [array count]; for (i = 0; i < count; i++) if ([objects[i] isEqual: object]) return i; return OF_INVALID_INDEX; } - (size_t)indexOfObjectIdenticalTo: (id)object { id *objects = [array cArray]; size_t i, count = [array count]; for (i = 0; i < count; i++) if (objects[i] == object) return i; return OF_INVALID_INDEX; } - (OFArray*)objectsInRange: (of_range_t)range { size_t count; if (![self isKindOfClass: [OFMutableArray class]]) return [OFArray_adjacentSubarray arrayWithArray: self range: range]; count = [array count]; if (range.start + range.length > count) @throw [OFOutOfRangeException exceptionWithClass: isa]; return [OFArray arrayWithObjects: (id*)[array cArray] + range.start count: range.length]; } - (BOOL)isEqual: (id)object { OFArray *otherArray; id *objects, *otherObjects; size_t i, count; if ([object class] != [OFArray_adjacent class] && [object class] != [OFMutableArray_adjacent class] && [object class] != [OFArray_adjacentSubarray class]) return [super isEqual: object]; otherArray = object; count = [array count]; if (count != [otherArray count]) return NO; objects = [array cArray]; otherObjects = [otherArray objects]; for (i = 0; i < count; i++) if (![objects[i] isEqual: otherObjects[i]]) return NO; return YES; } - (uint32_t)hash { id *objects = [array cArray]; size_t i, count = [array count]; uint32_t hash; OF_HASH_INIT(hash); for (i = 0; i < count; i++) { uint32_t h = [objects[i] hash]; OF_HASH_ADD(hash, h >> 24); OF_HASH_ADD(hash, (h >> 16) & 0xFF); OF_HASH_ADD(hash, (h >> 8) & 0xFF); OF_HASH_ADD(hash, h & 0xFF); } OF_HASH_FINALIZE(hash); return hash; } #ifdef OF_HAVE_BLOCKS - (void)enumerateObjectsUsingBlock: (of_array_enumeration_block_t)block { id *objects = [array cArray]; size_t i, count = [array count]; BOOL stop = NO; for (i = 0; i < count && !stop; i++) block(objects[i], i, &stop); } #endif - (void)dealloc { id *objects = [array cArray]; size_t i, count = [array count]; for (i = 0; i < count; i++) [objects[i] release]; [array release]; [super dealloc]; } @end |
Modified src/OFArray_adjacentSubarray.m from [93b321ec4d] to [eb001a037a].
︙ | ︙ | |||
17 18 19 20 21 22 23 | #include "config.h" #import "OFArray_adjacentSubarray.h" #import "OFArray_adjacent.h" #import "OFMutableArray_adjacent.h" @implementation OFArray_adjacentSubarray | | | | | | | | | | 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | #include "config.h" #import "OFArray_adjacentSubarray.h" #import "OFArray_adjacent.h" #import "OFMutableArray_adjacent.h" @implementation OFArray_adjacentSubarray - (id*)objects { return [array objects] + range.start; } - (BOOL)isEqual: (id)object { OFArray *otherArray; id *objects, *otherObjects; size_t i; if ([object class] != [OFArray_adjacent class] && [object class] != [OFMutableArray_adjacent class] && [object class] != [OFArray_adjacentSubarray class]) return [super isEqual: object]; otherArray = object; if (range.length != [otherArray count]) return NO; objects = [self objects]; otherObjects = [otherArray objects]; for (i = 0; i < range.length; i++) if (![objects[i] isEqual: otherObjects[i]]) return NO; return YES; } #ifdef OF_HAVE_BLOCKS - (void)enumerateObjectsUsingBlock: (of_array_enumeration_block_t)block { id *objects = [self objects]; size_t i; BOOL stop = NO; for (i = 0; i < range.length && !stop; i++) block(objects[i], i, &stop); } #endif @end |
Modified src/OFCountedSet_hashtable.m from [d9c4c3dca1] to [fed71ad63c].
︙ | ︙ | |||
77 78 79 80 81 82 83 | } - initWithArray: (OFArray*)array { self = [self init]; @try { | | | | 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 | } - initWithArray: (OFArray*)array { self = [self init]; @try { id *objects = [array objects]; size_t i, count = [array count]; for (i = 0; i < count; i++) [self addObject: objects[i]]; } @catch (id e) { [self release]; @throw e; } return self; } |
︙ | ︙ |
Modified src/OFDictionary.m from [940c27c632] to [29eff2abae].
︙ | ︙ | |||
309 310 311 312 313 314 315 | return NO; } - (OFArray*)allKeys { OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; | | | | | | | | | | | | | | 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 | return NO; } - (OFArray*)allKeys { OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; id *keys = [self allocMemoryForNItems: [self count] ofSize: sizeof(id)]; OFArray *ret; OFEnumerator *enumerator; id key; size_t i = 0; pool = [[OFAutoreleasePool alloc] init]; enumerator = [self keyEnumerator]; while ((key = [enumerator nextObject]) != nil) keys[i++] = key; assert(i == [self count]); [pool release]; @try { ret = [OFArray arrayWithObjects: keys count: [self count]]; } @finally { [self freeMemory: keys]; } return ret; } - (OFArray*)allObjects { OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; id *objects = [self allocMemoryForNItems: [self count] ofSize: sizeof(id)]; OFArray *ret; OFEnumerator *enumerator; id object; size_t i = 0; pool = [[OFAutoreleasePool alloc] init]; enumerator = [self objectEnumerator]; while ((object = [enumerator nextObject]) != nil) objects[i++] = object; assert(i == [self count]); [pool release]; @try { ret = [OFArray arrayWithObjects: objects count: [self count]]; } @finally { [self freeMemory: objects]; } return ret; } - (OFEnumerator*)objectEnumerator { |
︙ | ︙ |
Modified src/OFDictionary_hashtable.m from [a4ce122b88] to [dc60bfa33c].
︙ | ︙ | |||
237 238 239 240 241 242 243 | { self = [super init]; @try { id *objectsCArray, *keysCArray; uint32_t i, j, newSize; | | | | 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 | { self = [super init]; @try { id *objectsCArray, *keysCArray; uint32_t i, j, newSize; keysCArray = [keys objects]; objectsCArray = [objects objects]; count = [keys count]; if (count > UINT32_MAX) @throw [OFOutOfRangeException exceptionWithClass: isa]; for (newSize = 1; newSize < count; newSize <<= 1); if (count * 4 / newSize >= 3) |
︙ | ︙ | |||
626 627 628 629 630 631 632 | return NO; } - (OFArray*)allKeys { OFArray *ret; | | | | | | | | | | | | | | 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 | return NO; } - (OFArray*)allKeys { OFArray *ret; id *keys = [self allocMemoryForNItems: count ofSize: sizeof(id)]; size_t i, j; for (i = j = 0; i < size; i++) if (data[i] != NULL && data[i] != DELETED) keys[j++] = data[i]->key; assert(j == count); @try { ret = [OFArray arrayWithObjects: keys count: count]; } @finally { [self freeMemory: keys]; } return ret; } - (OFArray*)allObjects { OFArray *ret; id *objects = [self allocMemoryForNItems: count ofSize: sizeof(id)]; size_t i, j; for (i = j = 0; i < size; i++) if (data[i] != NULL && data[i] != DELETED) objects[j++] = data[i]->object; assert(j == count); @try { ret = [OFArray arrayWithObjects: objects count: count]; } @finally { [self freeMemory: objects]; } return ret; } - (OFEnumerator*)keyEnumerator { |
︙ | ︙ |
Modified src/OFMutableArray.m from [5ab0a3a71f] to [f7e8e6c2e5].
︙ | ︙ | |||
104 105 106 107 108 109 110 | } - initWithArray: (OFArray*)array { return (id)[[OFMutableArray_adjacent alloc] initWithArray: array]; } | | | | | | 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 | } - initWithArray: (OFArray*)array { return (id)[[OFMutableArray_adjacent alloc] initWithArray: array]; } - initWithObjects: (id*)objects count: (size_t)count { return (id)[[OFMutableArray_adjacent alloc] initWithObjects: objects count: count]; } - initWithSerialization: (OFXMLElement*)element { return (id)[[OFMutableArray_adjacent alloc] initWithSerialization: element]; } |
︙ | ︙ |
Modified src/OFMutableArray_adjacent.m from [e02a8ee9e6] to [a923c5af53].
︙ | ︙ | |||
51 52 53 54 55 56 57 | mutations++; } - (void)replaceObject: (id)oldObject withObject: (id)newObject { | | | | | | | | | | | | | | | | | | 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 | mutations++; } - (void)replaceObject: (id)oldObject withObject: (id)newObject { id *objects = [array cArray]; size_t i, count = [array count]; for (i = 0; i < count; i++) { if ([objects[i] isEqual: oldObject]) { [newObject retain]; [objects[i] release]; objects[i] = newObject; return; } } } - (void)replaceObjectAtIndex: (size_t)index withObject: (id)object { id *objects = [array cArray]; id oldObject; if (index >= [array count]) @throw [OFOutOfRangeException exceptionWithClass: isa]; oldObject = objects[index]; objects[index] = [object retain]; [oldObject release]; } - (void)replaceObjectIdenticalTo: (id)oldObject withObject: (id)newObject { id *objects = [array cArray]; size_t i, count = [array count]; for (i = 0; i < count; i++) { if (objects[i] == oldObject) { [newObject retain]; [objects[i] release]; objects[i] = newObject; return; } } } - (void)removeObject: (id)object { id *objects = [array cArray]; size_t i, count = [array count]; for (i = 0; i < count; i++) { if ([objects[i] isEqual: object]) { object = objects[i]; [array removeItemAtIndex: i]; mutations++; [object release]; return; } } } - (void)removeObjectIdenticalTo: (id)object { id *objects = [array cArray]; size_t i, count = [array count]; for (i = 0; i < count; i++) { if (objects[i] == object) { [array removeItemAtIndex: i]; mutations++; [object release]; return; } |
︙ | ︙ | |||
143 144 145 146 147 148 149 | [object release]; mutations++; } - (void)removeNObjects: (size_t)nObjects { | | | | | | | | 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 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 | [object release]; mutations++; } - (void)removeNObjects: (size_t)nObjects { id *objects = [array cArray], *copy; size_t i, count = [array count]; if (nObjects > count) @throw [OFOutOfRangeException exceptionWithClass: isa]; copy = [self allocMemoryForNItems: nObjects ofSize: sizeof(id)]; memcpy(copy, objects + (count - nObjects), nObjects * sizeof(id)); @try { [array removeNItems: nObjects]; mutations++; for (i = 0; i < nObjects; i++) [copy[i] release]; } @finally { [self freeMemory: copy]; } } - (void)removeAllObjects { id *objects = [array cArray]; size_t i, count = [array count]; for (i = 0; i < count; i++) [objects[i] release]; [array removeAllItems]; } - (void)removeObjectsInRange: (of_range_t)range { id *objects = [array cArray], *copy; size_t i, count = [array count]; if (range.length > count - range.start) @throw [OFOutOfRangeException exceptionWithClass: isa]; copy = [self allocMemoryForNItems: range.length ofSize: sizeof(id)]; memcpy(copy, objects + range.start, range.length * sizeof(id)); @try { [array removeNItems: range.length atIndex: range.start]; mutations++; for (i = 0; i < range.length; i++) |
︙ | ︙ | |||
211 212 213 214 215 216 217 | mutations++; } - (void)swapObjectAtIndex: (size_t)index1 withObjectAtIndex: (size_t)index2 { | | | | | | | | | | 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 | mutations++; } - (void)swapObjectAtIndex: (size_t)index1 withObjectAtIndex: (size_t)index2 { id *objects = [array cArray]; size_t count = [array count]; id tmp; if (index1 >= count || index2 >= count) @throw [OFOutOfRangeException exceptionWithClass: isa]; tmp = objects[index1]; objects[index1] = objects[index2]; objects[index2] = tmp; } - (void)reverse { id *objects = [array cArray]; size_t i, j, count = [array count]; if (count == 0 || count == 1) return; for (i = 0, j = count - 1; i < j; i++, j--) { id tmp = objects[i]; objects[i] = objects[j]; objects[j] = tmp; } } - (int)countByEnumeratingWithState: (of_fast_enumeration_state_t*)state objects: (id*)objects count: (int)count { |
︙ | ︙ | |||
266 267 268 269 270 271 272 | initWithArray: self mutationsPtr: &mutations] autorelease]; } #ifdef OF_HAVE_BLOCKS - (void)enumerateObjectsUsingBlock: (of_array_enumeration_block_t)block { | | | | | | | | 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 | initWithArray: self mutationsPtr: &mutations] autorelease]; } #ifdef OF_HAVE_BLOCKS - (void)enumerateObjectsUsingBlock: (of_array_enumeration_block_t)block { id *objects = [array cArray]; size_t i, count = [array count]; BOOL stop = NO; unsigned long mutations2 = mutations; for (i = 0; i < count && !stop; i++) { if (mutations != mutations2) @throw [OFEnumerationMutationException exceptionWithClass: isa object: self]; block(objects[i], i, &stop); } } - (void)replaceObjectsUsingBlock: (of_array_replace_block_t)block { id *objects = [array cArray]; size_t i, count = [array count]; BOOL stop = NO; unsigned long mutations2 = mutations; for (i = 0; i < count && !stop; i++) { id newObject; if (mutations != mutations2) @throw [OFEnumerationMutationException exceptionWithClass: isa object: self]; newObject = block(objects[i], i, &stop); if (newObject == nil) @throw [OFInvalidArgumentException exceptionWithClass: isa selector: _cmd]; [newObject retain]; [objects[i] release]; objects[i] = newObject; } } #endif - (void)makeImmutable { isa = [OFArray_adjacent class]; } @end |
Modified src/OFProcess.m from [39656659f7] to [53a70ada66].
︙ | ︙ | |||
83 84 85 86 87 88 89 | #ifndef _WIN32 if (pipe(readPipe) != 0 || pipe(writePipe) != 0) @throw [OFInitializationFailedException exceptionWithClass: isa]; switch ((pid = fork())) { case 0:; | | | | 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 | #ifndef _WIN32 if (pipe(readPipe) != 0 || pipe(writePipe) != 0) @throw [OFInitializationFailedException exceptionWithClass: isa]; switch ((pid = fork())) { case 0:; OFString **objects = [arguments objects]; size_t i, count = [arguments count]; char **argv; argv = [self allocMemoryForNItems: count + 2 ofSize: sizeof(char*)]; argv[0] = (char*)[programName cStringWithEncoding: OF_STRING_ENCODING_NATIVE]; for (i = 0; i < count; i++) argv[i + 1] = (char*)[objects[i] cStringWithEncoding: OF_STRING_ENCODING_NATIVE]; argv[i + 1] = NULL; close(readPipe[0]); close(writePipe[1]); |
︙ | ︙ |
Modified src/OFSet_hashtable.m from [44df8e110b] to [2beeed38e8].
︙ | ︙ | |||
76 77 78 79 80 81 82 | - initWithArray: (OFArray*)array { self = [self init]; @try { OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; OFNumber *one = [OFNumber numberWithSize: 1]; | | | | 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 | - initWithArray: (OFArray*)array { self = [self init]; @try { OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; OFNumber *one = [OFNumber numberWithSize: 1]; id *objects = [array objects]; size_t i, count = [array count]; for (i = 0; i < count; i++) [dictionary _setObject: one forKey: objects[i] copyKey: NO]; [pool release]; } @catch (id e) { [self release]; @throw e; } |
︙ | ︙ |
Modified src/OFStreamObserver.m from [ff67a9acd7] to [89d321be6d].
︙ | ︙ | |||
293 294 295 296 297 298 299 | selector: _cmd]; } - (void)_processQueue { [mutex lock]; @try { | | | | 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 | selector: _cmd]; } - (void)_processQueue { [mutex lock]; @try { OFStream **queueObjects = [queue objects]; int *queueInfoCArray = [queueInfo cArray]; int *queueFDsCArray = [queueFDs cArray]; size_t i, count = [queue count]; for (i = 0; i < count; i++) { OFStream *stream = queueObjects[i]; int action = queueInfoCArray[i]; int fd = queueFDsCArray[i]; if ((action & QUEUE_ACTION) == QUEUE_ADD) { if (fd > maxFD) { maxFD = fd; FDToStream = [self |
︙ | ︙ | |||
372 373 374 375 376 377 378 | @throw [OFNotImplementedException exceptionWithClass: isa selector: _cmd]; } - (BOOL)_processCache { OFAutoreleasePool *pool; | | | | | | 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 | @throw [OFNotImplementedException exceptionWithClass: isa selector: _cmd]; } - (BOOL)_processCache { OFAutoreleasePool *pool; OFStream **objects = [readStreams objects]; size_t i, count = [readStreams count]; BOOL foundInCache = NO; pool = [[OFAutoreleasePool alloc] init]; for (i = 0; i < count; i++) { if ([objects[i] pendingBytes] > 0 && ![objects[i] _isWaitingForDelimiter]) { [delegate streamIsReadyForReading: objects[i]]; foundInCache = YES; [pool releaseObjects]; } } [pool release]; |
︙ | ︙ |
Modified src/OFStreamObserver_select.m from [a5aa0c34fc] to [17f835ff3b].
︙ | ︙ | |||
67 68 69 70 71 72 73 | if (!FD_ISSET(fd, &readFDs)) FD_CLR(fd, &exceptFDs); } - (BOOL)observeWithTimeout: (int)timeout { OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; | | | 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 | if (!FD_ISSET(fd, &readFDs)) FD_CLR(fd, &exceptFDs); } - (BOOL)observeWithTimeout: (int)timeout { OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; OFStream **objects; fd_set readFDs_; fd_set writeFDs_; fd_set exceptFDs_; struct timeval time; size_t i, count; [self _processQueue]; |
︙ | ︙ | |||
109 110 111 112 113 114 115 | #ifndef _WIN32 assert(read(cancelFD[0], &buffer, 1) > 0); #else assert(recvfrom(cancelFD[0], &buffer, 1, 0, NULL, NULL) > 0); #endif } | | | | | | | | | | 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 | #ifndef _WIN32 assert(read(cancelFD[0], &buffer, 1) > 0); #else assert(recvfrom(cancelFD[0], &buffer, 1, 0, NULL, NULL) > 0); #endif } objects = [readStreams objects]; count = [readStreams count]; for (i = 0; i < count; i++) { int fileDescriptor = [objects[i] fileDescriptor]; if (FD_ISSET(fileDescriptor, &readFDs_)) { [delegate streamIsReadyForReading: objects[i]]; [pool releaseObjects]; } if (FD_ISSET(fileDescriptor, &exceptFDs_)) { [delegate streamDidReceiveException: objects[i]]; [pool releaseObjects]; /* * Prevent calling it twice in case the FD is in both * sets. */ FD_CLR(fileDescriptor, &exceptFDs_); } } objects = [writeStreams objects]; count = [writeStreams count]; for (i = 0; i < count; i++) { int fileDescriptor = [objects[i] fileDescriptor]; if (FD_ISSET(fileDescriptor, &writeFDs_)) { [delegate streamIsReadyForWriting: objects[i]]; [pool releaseObjects]; } if (FD_ISSET(fileDescriptor, &exceptFDs_)) { [delegate streamDidReceiveException: objects[i]]; [pool releaseObjects]; } } [pool release]; return YES; } @end |
Modified src/OFURL.m from [61882f6a6e] to [c16b58c0b2].
︙ | ︙ | |||
40 41 42 43 44 45 46 | OFString *ret; BOOL done = NO; array = [[[path componentsSeparatedByString: @"/"] mutableCopy] autorelease]; while (!done) { | | | | | 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | OFString *ret; BOOL done = NO; array = [[[path componentsSeparatedByString: @"/"] mutableCopy] autorelease]; while (!done) { id *objects = [array objects]; size_t i, length = [array count]; done = YES; for (i = 0; i < length; i++) { if ([objects[i] isEqual: @"."]) { [array removeObjectAtIndex: i]; done = NO; break; } if ([objects[i] isEqual: @".."]) { [array removeObjectAtIndex: i]; if (i > 0) [array removeObjectAtIndex: i - 1]; done = NO; |
︙ | ︙ |
Modified src/OFXMLElement.m from [2c9333bc62] to [5e22d1f74a].
︙ | ︙ | |||
430 431 432 433 434 435 436 | [pool release]; } - (OFString*)stringValue { OFAutoreleasePool *pool; OFMutableString *ret; | | | | | | 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 | [pool release]; } - (OFString*)stringValue { OFAutoreleasePool *pool; OFMutableString *ret; OFXMLElement **objects; size_t i, count = [children count]; if (count == 0) return @""; ret = [OFMutableString string]; objects = [children objects]; pool = [[OFAutoreleasePool alloc] init]; for (i = 0; i < count; i++) { [ret appendString: [objects[i] stringValue]]; [pool releaseObjects]; } [ret makeImmutable]; [pool release]; return ret; } - (OFString*)_XMLStringWithParent: (OFXMLElement*)parent namespaces: (OFDictionary*)allNamespaces indentation: (unsigned int)indentation level: (unsigned int)level { OFAutoreleasePool *pool, *pool2; char *cString; size_t length, i, j, attributesCount; OFString *prefix, *parentPrefix; OFXMLAttribute **attributesObjects; OFString *ret; OFString *defaultNS; pool = [[OFAutoreleasePool alloc] init]; parentPrefix = [allNamespaces objectForKey: (parent != nil && parent->ns != nil ? parent->ns : (OFString*)@"")]; |
︙ | ︙ | |||
547 548 549 550 551 552 553 | i += 8; memcpy(cString + i, [ns UTF8String], [ns UTF8StringLength]); i += [ns UTF8StringLength]; cString[i++] = '\''; } /* Attributes */ | | | | | | | | 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 | i += 8; memcpy(cString + i, [ns UTF8String], [ns UTF8StringLength]); i += [ns UTF8StringLength]; cString[i++] = '\''; } /* Attributes */ attributesObjects = [attributes objects]; attributesCount = [attributes count]; pool2 = [[OFAutoreleasePool alloc] init]; for (j = 0; j < attributesCount; j++) { OFString *attributeName = [attributesObjects[j] name]; OFString *attributePrefix = nil; OFString *tmp = [[attributesObjects[j] stringValue] stringByXMLEscaping]; if ([attributesObjects[j] namespace] != nil && (attributePrefix = [allNamespaces objectForKey: [attributesObjects[j] namespace]]) == nil) @throw [OFUnboundNamespaceException exceptionWithClass: isa namespace: [attributesObjects[j] namespace]]; length += [attributeName UTF8StringLength] + (attributePrefix != nil ? [attributePrefix UTF8StringLength] + 1 : 0) + [tmp UTF8StringLength] + 4; |
︙ | ︙ | |||
599 600 601 602 603 604 605 | cString[i++] = '\''; [pool2 releaseObjects]; } /* Childen */ if (children != nil) { | | > | | | | | | 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 | cString[i++] = '\''; [pool2 releaseObjects]; } /* Childen */ if (children != nil) { OFXMLElement **childrenObjects = [children objects]; size_t childrenCount = [children count]; OFDataArray *tmp = [OFDataArray dataArray]; BOOL indent; if (indentation > 0) { indent = YES; for (j = 0; j < childrenCount; j++) { if ([childrenObjects[j] isKindOfClass: charactersClass] || [childrenObjects[j] isKindOfClass: CDATAClass]) { indent = NO; break; } } } else indent = NO; for (j = 0; j < childrenCount; j++) { OFString *child; unsigned int ind = (indent ? indentation : 0); if (ind) [tmp addItem: "\n"]; if ([childrenObjects[j] isKindOfClass: [OFXMLElement class]]) child = [childrenObjects[j] _XMLStringWithParent: self namespaces: allNamespaces indentation: ind level: level + 1]; else child = [childrenObjects[j] XMLStringWithIndentation: ind level: level + 1]; [tmp addNItems: [child UTF8StringLength] fromCArray: [child UTF8String]]; } |
︙ | ︙ | |||
825 826 827 828 829 830 831 | stringValue: stringValue]]; [pool release]; } - (OFXMLAttribute*)attributeForName: (OFString*)attributeName { | | | | | | | | | | | | | | | | | | 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 | stringValue: stringValue]]; [pool release]; } - (OFXMLAttribute*)attributeForName: (OFString*)attributeName { OFXMLAttribute **objects = [attributes objects]; size_t i, count = [attributes count]; for (i = 0; i < count; i++) if (objects[i]->ns == nil && [objects[i]->name isEqual: attributeName]) return objects[i]; return nil; } - (OFXMLAttribute*)attributeForName: (OFString*)attributeName namespace: (OFString*)attributeNS { OFXMLAttribute **objects; size_t i, count; if (attributeNS == nil) return [self attributeForName: attributeName]; objects = [attributes objects]; count = [attributes count]; for (i = 0; i < count; i++) if ([objects[i]->ns isEqual: attributeNS] && [objects[i]->name isEqual: attributeName]) return objects[i]; return nil; } - (void)removeAttributeForName: (OFString*)attributeName { OFXMLAttribute **objects = [attributes objects]; size_t i, count = [attributes count]; for (i = 0; i < count; i++) { if (objects[i]->ns == nil && [objects[i]->name isEqual: attributeName]) { [attributes removeObjectAtIndex: i]; return; } } } - (void)removeAttributeForName: (OFString*)attributeName namespace: (OFString*)attributeNS { OFXMLAttribute **objects; size_t i, count; if (attributeNS == nil) return [self removeAttributeForName: attributeName]; objects = [attributes objects]; count = [attributes count]; for (i = 0; i < count; i++) { if ([objects[i]->ns isEqual: attributeNS] && [objects[i]->name isEqual: attributeName]) { [attributes removeObjectAtIndex: i]; return; } } } - (void)setPrefix: (OFString*)prefix |
︙ | ︙ | |||
961 962 963 964 965 966 967 | return [[self elementsForName: elementName namespace: elementNS] firstObject]; } - (OFArray*)elements { OFMutableArray *ret = [OFMutableArray array]; | | | | | | | | | | | | | | | | | | | | | 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 | return [[self elementsForName: elementName namespace: elementNS] firstObject]; } - (OFArray*)elements { OFMutableArray *ret = [OFMutableArray array]; OFXMLElement **objects = [children objects]; size_t i, count = [children count]; for (i = 0; i < count; i++) if ([objects[i] isKindOfClass: [OFXMLElement class]]) [ret addObject: objects[i]]; [ret makeImmutable]; return ret; } - (OFArray*)elementsForName: (OFString*)elementName { OFMutableArray *ret = [OFMutableArray array]; OFXMLElement **objects = [children objects]; size_t i, count = [children count]; for (i = 0; i < count; i++) if ([objects[i] isKindOfClass: [OFXMLElement class]] && objects[i]->ns == nil && [objects[i]->name isEqual: elementName]) [ret addObject: objects[i]]; [ret makeImmutable]; return ret; } - (OFArray*)elementsForNamespace: (OFString*)elementNS { OFMutableArray *ret = [OFMutableArray array]; OFXMLElement **objects = [children objects]; size_t i, count = [children count]; for (i = 0; i < count; i++) if ([objects[i] isKindOfClass: [OFXMLElement class]] && objects[i]->name != nil && [objects[i]->ns isEqual: elementNS]) [ret addObject: objects[i]]; [ret makeImmutable]; return ret; } - (OFArray*)elementsForName: (OFString*)elementName namespace: (OFString*)elementNS { OFMutableArray *ret; OFXMLElement **objects; size_t i, count; if (elementNS == nil) return [self elementsForName: elementName]; ret = [OFMutableArray array]; objects = [children objects]; count = [children count]; for (i = 0; i < count; i++) if ([objects[i] isKindOfClass: [OFXMLElement class]] && [objects[i]->ns isEqual: elementNS] && [objects[i]->name isEqual: elementName]) [ret addObject: objects[i]]; [ret makeImmutable]; return ret; } - (BOOL)isEqual: (id)object |
︙ | ︙ |
Modified src/OFXMLElementBuilder.m from [21ba954ddd] to [13948b0a6c].
︙ | ︙ | |||
86 87 88 89 90 91 92 | - (void)parser: (OFXMLParser*)parser didStartElement: (OFString*)name withPrefix: (OFString*)prefix namespace: (OFString*)ns attributes: (OFArray*)attributes { OFXMLElement *element; | | | | | | | | | | 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 | - (void)parser: (OFXMLParser*)parser didStartElement: (OFString*)name withPrefix: (OFString*)prefix namespace: (OFString*)ns attributes: (OFArray*)attributes { OFXMLElement *element; OFXMLAttribute **objects; size_t i, count; element = [OFXMLElement elementWithName: name namespace: ns]; objects = [attributes objects]; count = [attributes count]; for (i = 0; i < count; i++) { if ([objects[i] namespace] == nil && [[objects[i] name] isEqual: @"xmlns"]) continue; if ([[objects[i] namespace] isEqual: @"http://www.w3.org/2000/xmlns/"]) [element setPrefix: [objects[i] name] forNamespace: [objects[i] stringValue]]; [element addAttribute: objects[i]]; } [[stack lastObject] addChild: element]; [stack addObject: element]; } - (void)parser: (OFXMLParser*)parser |
︙ | ︙ |
Modified src/OFXMLParser.m from [768dfa63ad] to [a8f0eceb0e].
︙ | ︙ | |||
94 95 96 97 98 99 100 | return ret; } static OFString* namespace_for_prefix(OFString *prefix, OFArray *namespaces) { | | | | 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 | return ret; } static OFString* namespace_for_prefix(OFString *prefix, OFArray *namespaces) { OFDictionary **objects = [namespaces objects]; ssize_t i; if (prefix == nil) prefix = @""; for (i = [namespaces count] - 1; i >= 0; i--) { OFString *tmp; if ((tmp = [objects[i] objectForKey: prefix]) != nil) return tmp; } return nil; } static OF_INLINE void |
︙ | ︙ | |||
666 667 668 669 670 671 672 | /* Inside a tag, name found */ - (void)_parseInTagWithBuffer: (const char*)buffer i: (size_t*)i last: (size_t*)last { OFAutoreleasePool *pool; OFString *ns; | | | | | 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 | /* Inside a tag, name found */ - (void)_parseInTagWithBuffer: (const char*)buffer i: (size_t*)i last: (size_t*)last { OFAutoreleasePool *pool; OFString *ns; OFXMLAttribute **attributesObjects; size_t j, attributesCount; if (buffer[*i] != '>' && buffer[*i] != '/') { if (buffer[*i] != ' ' && buffer[*i] != '\t' && buffer[*i] != '\n' && buffer[*i] != '\r') { *last = *i; state = OF_XMLPARSER_IN_ATTR_NAME; (*i)--; } return; } attributesObjects = [attributes objects]; attributesCount = [attributes count]; ns = namespace_for_prefix(prefix, namespaces); if (prefix != nil && ns == nil) @throw [OFUnboundNamespaceException exceptionWithClass: isa prefix: prefix]; for (j = 0; j < attributesCount; j++) resolve_attribute_namespace(attributesObjects[j], namespaces, isa); pool = [[OFAutoreleasePool alloc] init]; [delegate parser: self didStartElement: name withPrefix: prefix |
︙ | ︙ |
Modified tests/OFArrayTests.m from [65511c9fb4] to [19f0fe9122].
︙ | ︙ | |||
25 26 27 28 29 30 31 | #import "TestsAppDelegate.h" static OFString *module = @"OFArray"; static OFString *c_ary[] = { @"Foo", @"Bar", | | < < < | | | | | 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | #import "TestsAppDelegate.h" static OFString *module = @"OFArray"; static OFString *c_ary[] = { @"Foo", @"Bar", @"Baz" }; @implementation TestsAppDelegate (OFArrayTests) - (void)arrayTests { OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; OFArray *a[3]; OFMutableArray *m[2]; OFEnumerator *enumerator; id obj; BOOL ok; size_t i; TEST(@"+[array]", (m[0] = [OFMutableArray array])) TEST(@"+[arrayWithObjects:]", (a[0] = [OFArray arrayWithObjects: @"Foo", @"Bar", @"Baz", nil])) TEST(@"+[arrayWithObjects:count:]", (a[1] = [OFArray arrayWithObjects: c_ary count: 3]) && [a[1] isEqual: a[0]]) TEST(@"-[description]", [[a[0] description ]isEqual: @"(\n\tFoo,\n\tBar,\n\tBaz\n)"]) TEST(@"-[addObject:]", R([m[0] addObject: c_ary[0]]) && R([m[0] addObject: c_ary[2]])) |
︙ | ︙ |