Comment: | Introduce some consistency when to use OFObject* and when to use id. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
c7ab3a46d15ffeeae41cc9a41541a6a5 |
User & Date: | js on 2009-12-02 20:02:26 |
Other Links: | manifest | tags |
2009-12-03
| ||
10:14 | Add documentation for OFXMLParser. check-in: a0b676019d user: js tags: trunk | |
2009-12-02
| ||
20:02 | Introduce some consistency when to use OFObject* and when to use id. check-in: c7ab3a46d1 user: js tags: trunk | |
09:45 | Fix one more missing LD = ${OBJC}. check-in: 25d8c4c030 user: js tags: trunk | |
Modified src/OFArray.h from [03634b7b64] to [6a0650261e].
︙ | ︙ | |||
100 101 102 103 104 105 106 | /** * Returns the index of the first object that is equivalent to the specified * object. * * \param obj The object whose index is returned * \return The index of the first object equivalent to the specified object */ | | | | | | 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 | /** * Returns the index of the first object that is equivalent to the specified * object. * * \param obj The object whose index is returned * \return The index of the first object equivalent to the specified object */ - (size_t)indexOfObject: (OFObject*)obj; /** * Returns the index of the first object that has the same address as the * specified object. * * \param obj The object whose index is returned * \return The index of the first object that has the same aaddress as * the specified object */ - (size_t)indexOfObjectIdenticalTo: (OFObject*)obj; /** * \return The first object of the OFArray or nil */ - (id)firstObject; /** * \return The last object of the OFArray or nil */ - (id)lastObject; - addObject: (OFObject*)obj; - addObject: (OFObject*)obj atIndex: (size_t)index; - removeObject: (OFObject*)obj; - removeObjectIdenticalTo: (OFObject*)obj; - removeObjectAtIndex: (size_t)index; - removeNObjects: (size_t)nobjects; - removeNObjects: (size_t)nobjects atIndex: (size_t)index; @end #import "OFMutableArray.h" |
Modified src/OFArray.m from [bf2f167ef1] to [3d6ca823bb].
︙ | ︙ | |||
168 169 170 171 172 173 174 | } - (id)objectAtIndex: (size_t)index { return *((OFObject**)[array itemAtIndex: index]); } | | | | 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 | } - (id)objectAtIndex: (size_t)index { return *((OFObject**)[array itemAtIndex: index]); } - (size_t)indexOfObject: (OFObject*)obj { id *objs = [array cArray]; size_t i, count = [array count]; if (objs == NULL) return SIZE_MAX; for (i = 0; i < count; i++) if ([objs[i] isEqual: obj]) return i; return SIZE_MAX; } - (size_t)indexOfObjectIdenticalTo: (OFObject*)obj { id *objs = [array cArray]; size_t i, count = [array count]; if (objs == NULL) return SIZE_MAX; |
︙ | ︙ | |||
212 213 214 215 216 217 218 | - (id)lastObject { id *last = [array lastItem]; return (last != NULL ? *last : nil); } | | | | | 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 | - (id)lastObject { id *last = [array lastItem]; return (last != NULL ? *last : nil); } - (BOOL)isEqual: (OFObject*)obj { OFObject **objs, **objs2; size_t i, count, count2; if (![obj isKindOfClass: [OFArray class]]) return NO; count = [array count]; count2 = [(OFArray*)obj count]; if (count != count2) return NO; objs = [array cArray]; objs2 = [(OFArray*)obj cArray]; for (i = 0; i < count; i++) if (![objs[i] isEqual: objs2[i]]) return NO; return YES; } |
︙ | ︙ | |||
284 285 286 287 288 289 290 | - addObject: (OFObject*)obj atIndex: (size_t)index { @throw [OFNotImplementedException newWithClass: isa selector: _cmd]; } | | | | 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 | - addObject: (OFObject*)obj atIndex: (size_t)index { @throw [OFNotImplementedException newWithClass: isa selector: _cmd]; } - removeObject: (OFObject*)obj { @throw [OFNotImplementedException newWithClass: isa selector: _cmd]; } - removeObjectIdenticalTo: (OFObject*)obj { @throw [OFNotImplementedException newWithClass: isa selector: _cmd]; } - removeObjectAtIndex: (size_t)index { |
︙ | ︙ |
Modified src/OFDataArray.m from [f8e71178db] to [b89c31d500].
︙ | ︙ | |||
208 209 210 211 212 213 214 | OFDataArray *new = [[OFDataArray alloc] initWithItemSize: itemsize]; [new addNItems: count fromCArray: data]; return new; } | | > | | | 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 | OFDataArray *new = [[OFDataArray alloc] initWithItemSize: itemsize]; [new addNItems: count fromCArray: data]; return new; } - (BOOL)isEqual: (OFObject*)obj { if (![obj isKindOfClass: [OFDataArray class]]) return NO; if ([(OFDataArray*)obj count] != count || [(OFDataArray*)obj itemsize] != itemsize) return NO; if (memcmp([(OFDataArray*)obj cArray], data, count * itemsize)) return NO; return YES; } - (of_comparison_result_t)compare: (OFDataArray*)ary { |
︙ | ︙ |
Modified src/OFList.h from [4d2ba9daa2] to [d1b99d4de4].
︙ | ︙ | |||
54 55 56 57 58 59 60 | * Appends an object to the list. * * \param obj The object to append * \return An of_list_object_t, needed to identify the object inside the list. * For example, if you want to remove an object from the list, you need * its of_list_object_t. */ | | | | | | 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 | * Appends an object to the list. * * \param obj The object to append * \return An of_list_object_t, needed to identify the object inside the list. * For example, if you want to remove an object from the list, you need * its of_list_object_t. */ - (of_list_object_t*)append: (OFObject*)obj; /** * Prepends an object to the list. * * \param obj The object to prepend * \return An of_list_object_t, needed to identify the object inside the list. * For example, if you want to remove an object from the list, you need * its of_list_object_t. */ - (of_list_object_t*)prepend: (OFObject*)obj; /** * Inserts an object before another object. * \param obj The object to insert * \param listobj The of_list_object_t of the object before which it should be * inserted * \return An of_list_object_t, needed to identify the object inside the list. * For example, if you want to remove an object from the list, you need * its of_list_object_t. */ - (of_list_object_t*)insert: (OFObject*)obj before: (of_list_object_t*)listobj; /** * Inserts an object after another object. * \param obj The object to insert * \param listobj The of_list_object_t of the object after which it should be * inserted * \return An of_list_object_t, needed to identify the object inside the list. * For example, if you want to remove an object from the list, you need * its of_list_object_t. */ - (of_list_object_t*)insert: (OFObject*)obj after: (of_list_object_t*)listobj; /** * Removes the object with the specified list object from the list. * * \param listobj The list object returned by append / prepend */ |
︙ | ︙ |
Modified src/OFList.m from [7db0d8023f] to [157ed5cd6f].
︙ | ︙ | |||
49 50 51 52 53 54 55 | } - (of_list_object_t*)last { return last; } | | | 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | } - (of_list_object_t*)last { return last; } - (of_list_object_t*)append: (OFObject*)obj { of_list_object_t *o; o = [self allocMemoryWithSize: sizeof(of_list_object_t)]; o->object = [obj retain]; o->next = NULL; o->prev = last; |
︙ | ︙ | |||
72 73 74 75 76 77 78 | count++; [obj retain]; return o; } | | | 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 | count++; [obj retain]; return o; } - (of_list_object_t*)prepend: (OFObject*)obj { of_list_object_t *o; o = [self allocMemoryWithSize: sizeof(of_list_object_t)]; o->object = [obj retain]; o->next = first; o->prev = NULL; |
︙ | ︙ | |||
95 96 97 98 99 100 101 | count++; [obj retain]; return o; } | | | 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 | count++; [obj retain]; return o; } - (of_list_object_t*)insert: (OFObject*)obj before: (of_list_object_t*)listobj { of_list_object_t *o; o = [self allocMemoryWithSize: sizeof(of_list_object_t)]; o->object = [obj retain]; o->next = listobj; |
︙ | ︙ | |||
120 121 122 123 124 125 126 | count++; [obj retain]; return o; } | | | 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 | count++; [obj retain]; return o; } - (of_list_object_t*)insert: (OFObject*)obj after: (of_list_object_t*)listobj { of_list_object_t *o; o = [self allocMemoryWithSize: sizeof(of_list_object_t)]; o->object = [obj retain]; o->next = listobj->next; |
︙ | ︙ | |||
171 172 173 174 175 176 177 | } - (size_t)count { return count; } | | | | | | 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 | } - (size_t)count { return count; } - (BOOL)isEqual: (OFObject*)obj { of_list_object_t *iter, *iter2; if (![obj isKindOfClass: [OFList class]]) return NO; if ([(OFList*)obj count] != count) return NO; for (iter = first, iter2 = [(OFList*)obj first]; iter != NULL && iter2 != NULL; iter = iter->next, iter2 = iter2->next) if (![iter->object isEqual: iter2->object]) return NO; /* One is bigger than the other although we checked the count */ assert(iter == NULL && iter2 == NULL); return YES; |
︙ | ︙ |
Modified src/OFMutableArray.h from [ab1b1cb945] to [5a4d04ab53].
︙ | ︙ | |||
33 34 35 36 37 38 39 | atIndex: (size_t)index; /** * Removes the first object equivalent to the specified object. * * \param obj The object to remove */ | | | | 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | atIndex: (size_t)index; /** * Removes the first object equivalent to the specified object. * * \param obj The object to remove */ - removeObject: (OFObject*)obj; /** * Removes the first object that has the same address as the specified object. * * \param obj The object to remove */ - removeObjectIdenticalTo: (OFObject*)obj; /** * Removes the object at the specified index. * * \param index The index of the object to remove */ - removeObjectAtIndex: (size_t)index; |
︙ | ︙ |
Modified src/OFMutableArray.m from [44d3bbcada] to [b93f8c643f].
︙ | ︙ | |||
47 48 49 50 51 52 53 | [array addItem: &obj atIndex: index]; [obj retain]; return self; } | | | | 47 48 49 50 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 | [array addItem: &obj atIndex: index]; [obj retain]; return self; } - removeObject: (OFObject*)obj { OFObject **objs = [array cArray]; size_t i, count = [array count]; for (i = 0; i < count; i++) { if ([objs[i] isEqual: obj]) { [objs[i] release]; [array removeItemAtIndex: i]; return self; } } return self; } - removeObjectIdenticalTo: (OFObject*)obj { OFObject **objs = [array cArray]; size_t i, count = [array count]; for (i = 0; i < count; i++) { if (objs[i] == obj) { [obj release]; |
︙ | ︙ |
Modified src/OFNumber.m from [d440c31735] to [3600c71552].
︙ | ︙ | |||
715 716 717 718 719 720 721 | } - (long double)asLongDouble { RETURN_AS(long double) } | | | > | > | > | 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 | } - (long double)asLongDouble { RETURN_AS(long double) } - (BOOL)isEqual: (OFObject*)obj { if (![obj isKindOfClass: [OFNumber class]]) return NO; switch (type) { case OF_NUMBER_CHAR: case OF_NUMBER_SHORT: case OF_NUMBER_INT: case OF_NUMBER_LONG: case OF_NUMBER_INT8: case OF_NUMBER_INT16: case OF_NUMBER_INT32: case OF_NUMBER_INT64: case OF_NUMBER_INTMAX: case OF_NUMBER_PTRDIFF: return ([(OFNumber*)obj asIntMax] == [self asIntMax] ? YES : NO); case OF_NUMBER_SSIZE: case OF_NUMBER_UCHAR: case OF_NUMBER_USHORT: case OF_NUMBER_UINT: case OF_NUMBER_ULONG: case OF_NUMBER_UINT8: case OF_NUMBER_UINT16: case OF_NUMBER_UINT32: case OF_NUMBER_UINT64: case OF_NUMBER_SIZE: case OF_NUMBER_UINTMAX: case OF_NUMBER_INTPTR: return ([(OFNumber*)obj asUIntMax] == [self asUIntMax] ? YES : NO); case OF_NUMBER_FLOAT: case OF_NUMBER_DOUBLE: return ([(OFNumber*)obj asDouble] == [self asDouble] ? YES : NO); default: @throw [OFInvalidArgumentException newWithClass: isa selector: _cmd]; } } - (uint32_t)hash |
︙ | ︙ |
Modified src/OFObject.h from [5c9737ae0e] to [d628e82c53].
︙ | ︙ | |||
173 174 175 176 177 178 179 | * * Classes containing data (like strings, arrays, lists etc.) should reimplement * this! * * \param obj The object which should be tested for equality * \return A boolean whether the object is equal to the specified object */ | | | 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 | * * Classes containing data (like strings, arrays, lists etc.) should reimplement * this! * * \param obj The object which should be tested for equality * \return A boolean whether the object is equal to the specified object */ - (BOOL)isEqual: (OFObject*)obj; /** * Calculates a hash for the object. * * Classes containing data (like strings, arrays, lists etc.) should reimplement * this! * |
︙ | ︙ |
Modified src/OFObject.m from [e42ffed2f9] to [6b6a2eea9a].
︙ | ︙ | |||
254 255 256 257 258 259 260 | if (object_is_instance(self)) return method_get_imp(class_get_instance_method(isa, selector)); else return method_get_imp(class_get_class_method(isa, selector)); #endif } | | | 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 | if (object_is_instance(self)) return method_get_imp(class_get_instance_method(isa, selector)); else return method_get_imp(class_get_class_method(isa, selector)); #endif } - (BOOL)isEqual: (OFObject*)obj { /* Classes containing data should reimplement this! */ return (self == obj ? YES : NO); } - (uint32_t)hash { |
︙ | ︙ |
Modified src/OFString.m from [fa163f325d] to [21b0d1d0a2].
︙ | ︙ | |||
544 545 546 547 548 549 550 | } - (size_t)cStringLength { return length; } | | | | 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 | } - (size_t)cStringLength { return length; } - (BOOL)isEqual: (OFObject*)obj { if (![obj isKindOfClass: [OFString class]]) return NO; if (strcmp(string, [(OFString*)obj cString])) return NO; return YES; } - (id)copy { |
︙ | ︙ |
Modified src/OFThread.h from [03b7369e6c] to [d9ac27e5a8].
︙ | ︙ | |||
55 56 57 58 59 60 61 | * The OFThread class provides portable threads. * * To use it, you should create a new class derived from it and reimplement * main. */ @interface OFThread: OFObject { | | | | | | 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 | * The OFThread class provides portable threads. * * To use it, you should create a new class derived from it and reimplement * main. */ @interface OFThread: OFObject { OFObject <OFCopying> *object; of_thread_t thread; BOOL running; @public id retval; } /** * \param obj An object that is passed to the main method as a copy or nil * \return A new autoreleased thread */ + threadWithObject: (OFObject <OFCopying>*)obj; /** * Sets the Thread Local Storage for the specified key. * * The specified object is first retained and then the object stored before is * released. You can specify nil as object if you want the old object to be * released and don't want any new object for the TLS key. * * \param key The Thread Local Storage key * \param obj The object the Thread Local Storage key will be set to */ + setObject: (OFObject*)obj forTLSKey: (OFTLSKey*)key; /** * Returns the object for the specified Thread Local Storage key. * * \param key The Thread Local Storage key */ + (id)objectForTLSKey: (OFTLSKey*)key; /** * \param obj An object that is passed to the main method as a copy or nil * \return An initialized OFThread. */ - initWithObject: (OFObject <OFCopying>*)obj; /** * The main routine of the thread. You need to reimplement this! * * It can access the object passed to the threadWithObject or initWithObject * method using the instance variable named object. * |
︙ | ︙ |
Modified src/OFThread.m from [5453c14532] to [0701aeb932].
︙ | ︙ | |||
32 33 34 35 36 37 38 | [OFTLSKey callAllDestructors]; [OFAutoreleasePool releaseAll]; return 0; } @implementation OFThread | | | | 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | [OFTLSKey callAllDestructors]; [OFAutoreleasePool releaseAll]; return 0; } @implementation OFThread + threadWithObject: (OFObject <OFCopying>*)obj { return [[[self alloc] initWithObject: obj] autorelease]; } + setObject: (OFObject*)obj forTLSKey: (OFTLSKey*)key { id old = of_tlskey_get(key->key); if (!of_tlskey_set(key->key, [obj retain])) @throw [OFInvalidArgumentException newWithClass: self selector: _cmd]; |
︙ | ︙ | |||
62 63 64 65 66 67 68 | - init { @throw [OFNotImplementedException newWithClass: isa selector: _cmd]; } | | | 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 | - init { @throw [OFNotImplementedException newWithClass: isa selector: _cmd]; } - initWithObject: (OFObject <OFCopying>*)obj { self = [super init]; object = [obj copy]; if (!of_thread_new(&thread, call_main, self)) { Class c = isa; [object release]; |
︙ | ︙ |