Overview
Comment: | Split OFArray into OFArray and OFMutableArray. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
163409967e47800c141d126d49b4269a |
User & Date: | js on 2009-05-18 17:50:35 |
Other Links: | manifest | tags |
Context
2009-05-18
| ||
18:09 | More separation for OFString and OFMutableString. check-in: e7e8efd297 user: js tags: trunk | |
17:50 | Split OFArray into OFArray and OFMutableArray. check-in: 163409967e user: js tags: trunk | |
16:49 | Make - copy a protocol. check-in: 8dc49f1861 user: js tags: trunk | |
Changes
Modified src/Makefile from [82ad65dd42] to [74096cf5ac].
︙ | ︙ | |||
10 11 12 13 14 15 16 17 18 19 20 21 22 23 | OFDataArray.m \ OFDictionary.m \ OFExceptions.m \ OFFile.m \ OFHashes.m \ OFIterator.m \ OFList.m \ OFMutableString.m \ OFNumber.m \ OFObject.m \ ${OFPLUGIN_M} \ OFSocket.m \ OFStream.m \ OFString.m \ | > | 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | OFDataArray.m \ OFDictionary.m \ OFExceptions.m \ OFFile.m \ OFHashes.m \ OFIterator.m \ OFList.m \ OFMutableArray.m \ OFMutableString.m \ OFNumber.m \ OFObject.m \ ${OFPLUGIN_M} \ OFSocket.m \ OFStream.m \ OFString.m \ |
︙ | ︙ |
Modified src/OFArray.h from [ec8ee2c449] to [46dcbcf5e6].
︙ | ︙ | |||
58 59 60 61 62 63 64 | /** * Removes the specified amount of object from the end of the OFDataArray. * * \param nobjects The number of objects to remove */ - removeNObjects: (size_t)nobjects; @end | > > | 58 59 60 61 62 63 64 65 66 | /** * Removes the specified amount of object from the end of the OFDataArray. * * \param nobjects The number of objects to remove */ - removeNObjects: (size_t)nobjects; @end #import "OFMutableArray.h" |
Modified src/OFArray.m from [14d672c6d1] to [f1d02c7bd0].
︙ | ︙ | |||
13 14 15 16 17 18 19 | #import "OFArray.h" #import "OFExceptions.h" @implementation OFArray + array { | | | 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | #import "OFArray.h" #import "OFExceptions.h" @implementation OFArray + array { return [[[self alloc] init] autorelease]; } - init { self = [super init]; @try { |
︙ | ︙ | |||
75 76 77 78 79 80 81 | - (id)last { return *((OFObject**)[array last]); } - add: (OFObject*)obj { | < < | | < < < < < < < | | < < < < < < | 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 | - (id)last { return *((OFObject**)[array last]); } - add: (OFObject*)obj { @throw [OFNotImplementedException newWithClass: isa andSelector: _cmd]; } - removeNObjects: (size_t)nobjects { @throw [OFNotImplementedException newWithClass: isa andSelector: _cmd]; } - (void)dealloc { OFObject **objs; size_t len, i; |
︙ | ︙ |
Modified src/OFAutoreleasePool.m from [c665c234c4] to [81f708f0c4].
︙ | ︙ | |||
91 92 93 94 95 96 97 | [super dealloc]; } - addToPool: (OFObject*)obj { if (objects == nil) | | | 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 | [super dealloc]; } - addToPool: (OFObject*)obj { if (objects == nil) objects = [[OFMutableArray alloc] init]; [objects add: obj]; [obj release]; return self; } |
︙ | ︙ |
Modified src/OFDataArray.h from [de40862157] to [1afd404279].
︙ | ︙ | |||
29 30 31 32 33 34 35 | * Creates a new OFDataArray whose items all have the same size. * * \param is The size of each element in the OFDataArray * \return A new autoreleased OFDataArray */ + dataArrayWithItemSize: (size_t)is; | < < < < < < < < < | 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | * Creates a new OFDataArray whose items all have the same size. * * \param is The size of each element in the OFDataArray * \return A new autoreleased OFDataArray */ + dataArrayWithItemSize: (size_t)is; /** * Initializes an already allocated OFDataArray whose items all have the same * size. * * \param is The size of each element in the OFDataArray * \return An initialized OFDataArray */ |
︙ | ︙ |
Modified src/OFDataArray.m from [a8904a350c] to [c1f4692477].
︙ | ︙ | |||
22 23 24 25 26 27 28 | static size_t lastpagebyte = 0; extern int getpagesize(void); @implementation OFDataArray + dataArrayWithItemSize: (size_t)is { | | < < < < < | 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | static size_t lastpagebyte = 0; extern int getpagesize(void); @implementation OFDataArray + dataArrayWithItemSize: (size_t)is { return [[[self alloc] initWithItemSize: is] autorelease]; } - initWithItemSize: (size_t)is { Class c; self = [super init]; |
︙ | ︙ | |||
255 256 257 258 259 260 261 | size = nsize; return self; } - (id)copy { | | | 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 | size = nsize; return self; } - (id)copy { OFDataArray *new = [OFBigDataArray dataArrayWithItemSize: itemsize]; [new addNItems: count fromCArray: data]; return new; } @end |
Added src/OFMutableArray.h version [521f11b9ef].
> > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | /* * Copyright (c) 2008 - 2009 * Jonathan Schleifer <js@webkeks.org> * * All rights reserved. * * This file is part of libobjfw. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE included in * the packaging of this file. */ #import "OFArray.h" /** * The OFMutableArray class provides a class for storing, adding and removing * objects in an array. */ @interface OFMutableArray: OFArray @end |
Added src/OFMutableArray.m version [b08a16685b].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 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 | /* * Copyright (c) 2008 - 2009 * Jonathan Schleifer <js@webkeks.org> * * All rights reserved. * * This file is part of libobjfw. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE included in * the packaging of this file. */ #import "config.h" #import "OFMutableArray.h" #import "OFExceptions.h" @implementation OFMutableArray - add: (OFObject*)obj { [array add: &obj]; [obj retain]; return self; } - removeNObjects: (size_t)nobjects { OFObject **objs; size_t len, i; objs = [array data]; len = [array count]; if (nobjects > len) @throw [OFOutOfRangeException newWithClass: isa]; for (i = len - nobjects; i < len; i++) [objs[i] release]; [array removeNItems: nobjects]; return self; } @end |
Modified src/OFString.m from [0327728187] to [1c15b5afa3].
︙ | ︙ | |||
167 168 169 170 171 172 173 | { OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; OFArray *array = nil; const char *delim = [delimiter cString]; size_t delim_len = [delimiter length]; size_t i, last; | | | 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 | { OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; OFArray *array = nil; const char *delim = [delimiter cString]; size_t delim_len = [delimiter length]; size_t i, last; array = [OFMutableArray array]; for (i = 0, last = 0; i <= length; i++) { if (OF_UNLIKELY(i == length || !memcmp(string + i, delim, delim_len))) { OFString *str; char *tmp; |
︙ | ︙ |
Modified tests/OFDataArray/OFDataArray.m from [ebf9c80b5a] to [156e55b3b9].
︙ | ︙ | |||
125 126 127 128 129 130 131 | TEST(OFDataArray) puts("== TESTING OFBigArray =="); TEST(OFBigDataArray) pool = [[OFAutoreleasePool alloc] init]; x = [OFDataArray dataArrayWithItemSize: 1]; | | | | 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 | TEST(OFDataArray) puts("== TESTING OFBigArray =="); TEST(OFBigDataArray) pool = [[OFAutoreleasePool alloc] init]; x = [OFDataArray dataArrayWithItemSize: 1]; y = [OFBigDataArray dataArrayWithItemSize: 1]; if (![x isEqual: y]) { puts("FAIL 1!"); return 1; } if ([x hash] != [y hash]) { puts("FAIL 2!"); return 1; } [x add: "x"]; if ([x isEqual: y]) { puts("FAIL 3!"); return 1; } [pool releaseObjects]; x = [OFDataArray dataArrayWithItemSize: 2]; y = [OFBigDataArray dataArrayWithItemSize: 4]; if ([x isEqual: y]) { puts("FAIL 4!"); return 1; } [pool releaseObjects]; |
︙ | ︙ |