︙ | | |
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
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
|
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
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
|
-
-
-
+
+
+
+
-
+
-
+
-
+
-
+
-
+
-
+
-
-
+
+
-
-
+
+
-
+
-
+
-
+
-
+
-
-
+
+
-
-
+
+
-
+
-
+
-
-
+
+
-
-
+
+
|
#import "OFCollection.h"
#import "OFEnumerator.h"
@class OFDataArray;
@class OFString;
#ifdef OF_HAVE_BLOCKS
typedef void (^of_array_enumeration_block_t)(id obj, size_t idx, BOOL *stop);
typedef BOOL (^of_array_filter_block_t)(id odj, size_t idx);
typedef id (^of_array_map_block_t)(id obj, size_t idx);
typedef void (^of_array_enumeration_block_t)(id object, size_t index,
BOOL *stop);
typedef BOOL (^of_array_filter_block_t)(id odject, size_t index);
typedef id (^of_array_map_block_t)(id object, size_t index);
#endif
/**
* \brief A class for storing objects in an array.
*/
@interface OFArray: OFObject <OFCopying, OFMutableCopying, OFCollection,
OFFastEnumeration>
{
OFDataArray *array;
}
/**
* \return A new autoreleased OFArray
*/
+ array;
/**
* Creates a new OFArray with the specified object.
*
* \param obj An object
* \param object An object
* \return A new autoreleased OFArray
*/
+ arrayWithObject: (id)obj;
+ arrayWithObject: (id)object;
/**
* Creates a new OFArray with the specified objects, terminated by nil.
*
* \param first The first object in the array
* \param firstObject The first object in the array
* \return A new autoreleased OFArray
*/
+ arrayWithObjects: (id)first, ...;
+ arrayWithObjects: (id)firstObject, ...;
/**
* Creates a new OFArray with the objects from the specified C array.
*
* \param objs A C array of objects, terminated with nil
* \param objects A C array of objects, terminated with nil
* \return A new autoreleased OFArray
*/
+ arrayWithCArray: (id*)objs;
+ arrayWithCArray: (id*)objects;
/**
* Creates a new OFArray with the objects from the specified C array of the
* specified length.
*
* \param objs A C array of objects
* \param len The length of the C array
* \param objects A C array of objects
* \param length The length of the C array
* \return A new autoreleased OFArray
*/
+ arrayWithCArray: (id*)objs
length: (size_t)len;
+ arrayWithCArray: (id*)objects
length: (size_t)length;
/**
* Initializes an OFArray with the specified object.
*
* \param obj An object
* \param object An object
* \return An initialized OFArray
*/
- initWithObject: (id)obj;
- initWithObject: (id)object;
/**
* Initializes an OFArray with the specified objects.
*
* \param first The first object
* \param firstObject The first object
* \return An initialized OFArray
*/
- initWithObjects: (id)first, ...;
- initWithObjects: (id)firstObject, ...;
/**
* Initializes an OFArray with the specified object and a va_list.
*
* \param first The first object
* \param args A va_list
* \param firstObject The first object
* \param arguments A va_list
* \return An initialized OFArray
*/
- initWithObject: (id)first
argList: (va_list)args;
- initWithObject: (id)firstObject
argumentList: (va_list)arguments;
/**
* Initializes an OFArray with the objects from the specified C array.
*
* \param objs A C array of objects, terminated with nil
* \param objects A C array of objects, terminated with nil
* \return An initialized OFArray
*/
- initWithCArray: (id*)objs;
- initWithCArray: (id*)objects;
/**
* Initializes an OFArray with the objects from the specified C array of the
* specified length.
*
* \param objs A C array of objects
* \param len The length of the C array
* \param objects A C array of objects
* \param length The length of the C array
* \return An initialized OFArray
*/
- initWithCArray: (id*)objs
length: (size_t)len;
- initWithCArray: (id*)objects
length: (size_t)length;
/**
* \return The objects of the array as a C array
*/
- (id*)cArray;
/**
|
︙ | | |
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
|
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
|
-
+
-
+
-
+
-
+
|
*/
- (id)objectAtIndex: (size_t)index;
/**
* Returns the index of the first object that is equivalent to the specified
* object or OF_INVALID_INDEX if it was not found.
*
* \param obj The object whose index is returned
* \param object The object whose index is returned
* \return The index of the first object equivalent to the specified object
* or OF_INVALID_INDEX if it was not found
*/
- (size_t)indexOfObject: (id)obj;
- (size_t)indexOfObject: (id)object;
/**
* Returns the index of the first object that has the same address as the
* specified object or OF_INVALID_INDEX if it was not found.
*
* \param obj The object whose index is returned
* \param object The object whose index is returned
* \return The index of the first object that has the same aaddress as
* the specified object or OF_INVALID_INDEX if it was not found
*/
- (size_t)indexOfObjectIdenticalTo: (id)obj;
- (size_t)indexOfObjectIdenticalTo: (id)object;
/**
* Returns the first object of the array or nil.
*
* The returned object is <i>not</i> retained and autoreleased for performance
* reasons!
*
|
︙ | | |
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
|
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
|
-
+
-
+
|
- (void)makeObjectsPerformSelector: (SEL)selector;
/**
* Performs the specified selector on all objects in the array with the
* specified object.
*
* \param selector The selector to perform on all objects in the array
* \param obj The object to perform the selector with on all objects in the
* \param object The object to perform the selector with on all objects in the
* array
*/
- (void)makeObjectsPerformSelector: (SEL)selector
withObject: (id)obj;
withObject: (id)object;
#ifdef OF_HAVE_BLOCKS
/**
* Executes a block for each object.
*
* \param block The block to execute for each object
*/
|
︙ | | |
︙ | | |
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
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
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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
|
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
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
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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
|
-
+
-
+
-
+
-
+
-
-
-
-
+
+
+
+
-
+
-
+
-
-
+
+
-
-
+
+
-
+
-
-
+
+
-
+
-
+
-
-
-
-
+
+
+
+
-
-
+
+
-
+
-
-
-
-
+
+
+
+
-
+
-
+
-
-
+
+
-
+
-
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
|
@implementation OFArray
+ array
{
return [[[self alloc] init] autorelease];
}
+ arrayWithObject: (id)obj
+ arrayWithObject: (id)object
{
return [[[self alloc] initWithObject: obj] autorelease];
return [[[self alloc] initWithObject: object] autorelease];
}
+ arrayWithObjects: (id)first, ...
+ arrayWithObjects: (id)firstObject, ...
{
id ret;
va_list args;
va_list arguments;
va_start(args, first);
ret = [[[self alloc] initWithObject: first
argList: args] autorelease];
va_end(args);
va_start(arguments, firstObject);
ret = [[[self alloc] initWithObject: firstObject
argumentList: arguments] autorelease];
va_end(arguments);
return ret;
}
+ arrayWithCArray: (id*)objs
+ arrayWithCArray: (id*)objects
{
return [[[self alloc] initWithCArray: objs] autorelease];
return [[[self alloc] initWithCArray: objects] autorelease];
}
+ arrayWithCArray: (id*)objs
length: (size_t)len
+ arrayWithCArray: (id*)objects
length: (size_t)length
{
return [[[self alloc] initWithCArray: objs
length: len] autorelease];
return [[[self alloc] initWithCArray: objects
length: length] autorelease];
}
- init
{
self = [super init];
@try {
array = [[OFDataArray alloc] initWithItemSize: sizeof(id)];
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
- initWithObject: (id)obj
- initWithObject: (id)object
{
self = [self init];
@try {
[array addItem: &obj];
[obj retain];
[array addItem: &object];
[object retain];
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
- initWithObjects: (id)first, ...
- initWithObjects: (id)firstObject, ...
{
id ret;
va_list args;
va_list arguments;
va_start(args, first);
ret = [self initWithObject: first
argList: args];
va_end(args);
va_start(arguments, firstObject);
ret = [self initWithObject: firstObject
argumentList: arguments];
va_end(arguments);
return ret;
}
- initWithObject: (id)first
argList: (va_list)args
- initWithObject: (id)firstObject
argumentList: (va_list)arguments
{
self = [self init];
@try {
id obj;
id object;
[array addItem: &first];
while ((obj = va_arg(args, id)) != nil) {
[array addItem: &obj];
[obj retain];
[array addItem: &firstObject];
while ((object = va_arg(arguments, id)) != nil) {
[array addItem: &object];
[object retain];
}
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
- initWithCArray: (id*)objs
- initWithCArray: (id*)objects
{
self = [self init];
@try {
id *obj;
id *object;
size_t count = 0;
for (obj = objs; *obj != nil; obj++) {
[*obj retain];
for (object = objects; *object != nil; object++) {
[*object retain];
count++;
}
[array addNItems: count
fromCArray: objs];
fromCArray: objects];
} @catch (id e) {
id *obj;
id *object;
for (obj = objs; *obj != nil; obj++)
[*obj release];
for (object = objects; *object != nil; object++)
[*object release];
[self release];
@throw e;
}
return self;
}
- initWithCArray: (id*)objs
length: (size_t)len
- initWithCArray: (id*)objects
length: (size_t)length
{
self = [self init];
@try {
size_t i;
for (i = 0; i < len; i++)
[objs[i] retain];
for (i = 0; i < length; i++)
[objects[i] retain];
[array addNItems: len
fromCArray: objs];
[array addNItems: length
fromCArray: objects];
} @catch (id e) {
size_t i;
for (i = 0; i < len; i++)
[objs[i] release];
for (i = 0; i < length; i++)
[objects[i] release];
[self release];
@throw e;
}
return self;
}
|
︙ | | |
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
|
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
|
-
-
+
+
-
+
-
-
+
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
|
- copy
{
return [self retain];
}
- mutableCopy
{
OFArray *new = [[OFMutableArray alloc] init];
id *objs;
OFArray *mutableCopy = [[OFMutableArray alloc] init];
id *cArray;
size_t count, i;
objs = [array cArray];
cArray = [array cArray];
count = [array count];
[new->array addNItems: count
fromCArray: objs];
[mutableCopy->array addNItems: count
fromCArray: cArray];
for (i = 0; i < count; i++)
[objs[i] retain];
[cArray[i] retain];
return new;
return mutableCopy;
}
- (id)objectAtIndex: (size_t)index
{
return *((id*)[array itemAtIndex: index]);
}
- (size_t)indexOfObject: (id)obj
- (size_t)indexOfObject: (id)object
{
id *objs = [array cArray];
id *cArray = [array cArray];
size_t i, count = [array count];
if (objs == NULL)
if (cArray == NULL)
return OF_INVALID_INDEX;
for (i = 0; i < count; i++)
if ([objs[i] isEqual: obj])
if ([cArray[i] isEqual: object])
return i;
return OF_INVALID_INDEX;
}
- (size_t)indexOfObjectIdenticalTo: (id)obj
- (size_t)indexOfObjectIdenticalTo: (id)object
{
id *objs = [array cArray];
id *cArray = [array cArray];
size_t i, count = [array count];
if (objs == NULL)
if (cArray == NULL)
return OF_INVALID_INDEX;
for (i = 0; i < count; i++)
if (objs[i] == obj)
if (cArray[i] == object)
return i;
return OF_INVALID_INDEX;
}
- (BOOL)containsObject: (id)obj
- (BOOL)containsObject: (id)object
{
id *objs = [array cArray];
id *cArray = [array cArray];
size_t i, count = [array count];
if (objs == NULL)
if (cArray == NULL)
return NO;
for (i = 0; i < count; i++)
if ([objs[i] isEqual: obj])
if ([cArray[i] isEqual: object])
return YES;
return NO;
}
- (BOOL)containsObjectIdenticalTo: (id)obj
- (BOOL)containsObjectIdenticalTo: (id)object
{
id *objs = [array cArray];
id *cArray = [array cArray];
size_t i, count = [array count];
if (objs == NULL)
if (cArray == NULL)
return NO;
for (i = 0; i < count; i++)
if (objs[i] == obj)
if (cArray[i] == object)
return YES;
return NO;
}
- (id)firstObject
{
id *first = [array firstItem];
id *firstObject = [array firstItem];
return (first != NULL ? *first : nil);
return (firstObject != NULL ? *firstObject : nil);
}
- (id)lastObject
{
id *last = [array lastItem];
id *lastObject = [array lastItem];
return (last != NULL ? *last : nil);
return (lastObject != NULL ? *lastObject : nil);
}
- (OFArray*)objectsFromIndex: (size_t)start
toIndex: (size_t)end
{
size_t count = [array count];
|
︙ | | |
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
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
|
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
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
|
-
-
+
+
-
+
-
-
+
+
-
-
+
+
-
+
-
-
+
+
-
+
+
-
-
+
+
-
+
+
+
-
-
+
-
-
+
+
-
+
-
+
-
+
|
return [self objectsFromIndex: range.start
toIndex: range.start + range.length];
}
- (OFString*)componentsJoinedByString: (OFString*)separator
{
OFAutoreleasePool *pool;
OFString *str;
OFObject **objs = [array cArray];
OFString *ret;
OFObject **cArray = [array cArray];
size_t i, count = [array count];
IMP append;
if (count == 0)
return @"";
if (count == 1)
return [objs[0] description];
return [cArray[0] description];
str = [OFMutableString string];
append = [str methodForSelector: @selector(appendString:)];
ret = [OFMutableString string];
append = [ret methodForSelector: @selector(appendString:)];
pool = [[OFAutoreleasePool alloc] init];
for (i = 0; i < count - 1; i++) {
append(str, @selector(appendString:), [objs[i] description]);
append(str, @selector(appendString:), separator);
append(ret, @selector(appendString:), [cArray[i] description]);
append(ret, @selector(appendString:), separator);
[pool releaseObjects];
}
append(str, @selector(appendString:), [objs[i] description]);
append(ret, @selector(appendString:), [cArray[i] description]);
[pool release];
/*
* Class swizzle the string to be immutable. We declared the return type
* to be OFString*, so it can't be modified anyway. But not swizzling it
* would create a real copy each time -[copy] is called.
*/
str->isa = [OFString class];
return str;
ret->isa = [OFString class];
return ret;
}
- (BOOL)isEqual: (id)obj
- (BOOL)isEqual: (id)object
{
OFArray *otherArray;
id *objs, *objs2;
size_t i, count, count2;
id *cArray, *otherCArray;
size_t i, count;
if (![obj isKindOfClass: [OFArray class]])
if (![object isKindOfClass: [OFArray class]])
return NO;
otherArray = (OFArray*)object;
count = [array count];
count2 = [(OFArray*)obj count];
if (count != count2)
if (count != [otherArray count])
return NO;
objs = [array cArray];
objs2 = [(OFArray*)obj cArray];
cArray = [array cArray];
otherCArray = [otherArray cArray];
for (i = 0; i < count; i++)
if (![objs[i] isEqual: objs2[i]])
if (![cArray[i] isEqual: otherCArray[i]])
return NO;
return YES;
}
- (uint32_t)hash
{
id *objs = [array cArray];
id *cArray = [array cArray];
size_t i, count = [array count];
uint32_t hash;
OF_HASH_INIT(hash);
for (i = 0; i < count; i++) {
uint32_t h = [objs[i] hash];
uint32_t h = [cArray[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);
}
|
︙ | | |
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
|
424
425
426
427
428
429
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
|
-
+
-
-
+
+
-
+
-
+
-
-
+
+
|
*/
ret->isa = [OFString class];
return ret;
}
- (void)makeObjectsPerformSelector: (SEL)selector
{
id *objs = [array cArray];
id *cArray = [array cArray];
size_t i, count = [array count];
for (i = 0; i < count; i++)
((void(*)(id, SEL))[objs[i]
methodForSelector: selector])(objs[i], selector);
((void(*)(id, SEL))[cArray[i]
methodForSelector: selector])(cArray[i], selector);
}
- (void)makeObjectsPerformSelector: (SEL)selector
withObject: (id)obj
withObject: (id)object
{
id *objs = [array cArray];
id *cArray = [array cArray];
size_t i, count = [array count];
for (i = 0; i < count; i++)
((void(*)(id, SEL, id))[objs[i]
methodForSelector: selector])(objs[i], selector, obj);
((void(*)(id, SEL, id))[cArray[i]
methodForSelector: selector])(cArray[i], selector, object);
}
- (int)countByEnumeratingWithState: (of_fast_enumeration_state_t*)state
objects: (id*)objects
count: (int)count_
{
size_t count = [array count];
|
︙ | | |
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
|
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
|
-
+
-
+
-
+
-
+
|
mutationsPointer: NULL] autorelease];
}
#ifdef OF_HAVE_BLOCKS
- (void)enumerateObjectsUsingBlock: (of_array_enumeration_block_t)block
{
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
id *objs = [array cArray];
id *cArray = [array cArray];
size_t i, count = [array count];
BOOL stop = NO;
for (i = 0; i < count && !stop; i++) {
block(objs[i], i, &stop);
block(cArray[i], i, &stop);
[pool releaseObjects];
}
[pool release];
}
- (OFArray*)mappedArrayUsingBlock: (of_array_map_block_t)block
{
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
OFArray *ret;
size_t count = [array count];
id *tmp = [self allocMemoryForNItems: count
withSize: sizeof(id)];
@try {
id *objs = [array cArray];
id *cArray = [array cArray];
size_t i;
for (i = 0; i < count; i++)
tmp[i] = block(objs[i], i);
tmp[i] = block(cArray[i], i);
ret = [[OFArray alloc] initWithCArray: tmp
length: count];
@try {
[pool release];
} @finally {
|
︙ | | |
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
|
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
|
-
+
-
-
+
+
-
+
-
+
|
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
OFArray *ret;
size_t count = [array count];
id *tmp = [self allocMemoryForNItems: count
withSize: sizeof(id)];
@try {
id *objs = [array cArray];
id *cArray = [array cArray];
size_t i, j = 0;
for (i = 0; i < count; i++) {
if (block(objs[i], i))
tmp[j++] = objs[i];
if (block(cArray[i], i))
tmp[j++] = cArray[i];
[pool releaseObjects];
}
[pool release];
ret = [OFArray arrayWithCArray: tmp
length: j];
} @finally {
[self freeMemory: tmp];
}
return ret;
}
#endif
- (void)dealloc
{
id *objs = [array cArray];
id *cArray = [array cArray];
size_t i, count = [array count];
for (i = 0; i < count; i++)
[objs[i] release];
[cArray[i] release];
[array release];
[super dealloc];
}
@end
|
︙ | | |
︙ | | |
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
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
|
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
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
|
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
|
@property (readonly) size_t count;
@property (readonly) size_t itemSize;
#endif
/**
* Creates a new OFDataArray whose items all have the same size.
*
* \param is The size of each element in the OFDataArray
* \param itemSize The size of each element in the OFDataArray
* \return A new autoreleased OFDataArray
*/
+ dataArrayWithItemSize: (size_t)is;
+ dataArrayWithItemSize: (size_t)itemSize;
/**
* Creates a new OFDataArary with an item size of 1, containing the data of the
* specified file.
*
* \param path The path of the file
* \return A new autoreleased OFDataArray
*/
+ dataArrayWithContentsOfFile: (OFString*)path;
/**
* Creates a new OFDataArray with an item size of 1, containing the data of the
* Base64-encoded string.
*
* \param str The string with the Base64-encoded data
* \param string The string with the Base64-encoded data
* \return A new autoreleased OFDataArray
*/
+ dataArrayWithBase64EncodedString: (OFString*)str;
+ dataArrayWithBase64EncodedString: (OFString*)string;
/**
* Initializes an already allocated OFDataArray whose items all have the same
* size.
*
* \param is The size of each element in the OFDataArray
* \param itemSize The size of each element in the OFDataArray
* \return An initialized OFDataArray
*/
- initWithItemSize: (size_t)is;
- initWithItemSize: (size_t)itemSize;
/**
* Initializes an already allocated OFDataArray with an item size of 1,
* containing the data of the specified file.
*
* \param path The path of the file
* \return An initialized OFDataArray
*/
- initWithContentsOfFile: (OFString*)path;
/**
* Initializes an already allocated OFDataArray with an item size of 1,
* containing the data of the Base64-encoded string.
*
* \param str The string with the Base64-encoded data
* \param string The string with the Base64-encoded data
* \return A initialized OFDataArray
*/
- initWithBase64EncodedString: (OFString*)str;
- initWithBase64EncodedString: (OFString*)string;
/**
* \return The number of items in the OFDataArray
*/
- (size_t)count;
/**
|
︙ | | |
137
138
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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
|
137
138
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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
|
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
+
-
+
-
+
-
+
|
*/
- (void)addItem: (const void*)item
atIndex: (size_t)index;
/**
* Adds items from a C array to the OFDataArray.
*
* \param nitems The number of items to add
* \param carray A C array containing the items to add
* \param nItems The number of items to add
* \param cArray A C array containing the items to add
*/
- (void)addNItems: (size_t)nitems
fromCArray: (const void*)carray;
- (void)addNItems: (size_t)nItems
fromCArray: (const void*)cArray;
/**
* Adds items from a C array to the OFDataArray at the specified index.
*
* \param nitems The number of items to add
* \param carray A C array containing the items to add
* \param nItems The number of items to add
* \param cArray A C array containing the items to add
* \param index The index where the items should be added
*/
- (void)addNItems: (size_t)nitems
fromCArray: (const void*)carray
- (void)addNItems: (size_t)nItems
fromCArray: (const void*)cArray
atIndex: (size_t)index;
/**
* Removes the item at the specified index.
*
* \param index The index of the item to remove
*/
- (void)removeItemAtIndex: (size_t)index;
/**
* Removes the specified amount of items from the end of the OFDataArray.
*
* \param nitems The number of items to remove
* \param nItems The number of items to remove
*/
- (void)removeNItems: (size_t)nitems;
- (void)removeNItems: (size_t)nItems;
/**
* Removes the specified amount of items at the specified index.
*
* \param nitems The number of items to remove
* \param nItems The number of items to remove
* \param index The index at which the items are removed
*/
- (void)removeNItems: (size_t)nitems
- (void)removeNItems: (size_t)nItems
atIndex: (size_t)index;
/**
* \return A string containing the data in Base64 encoding
*/
- (OFString*)stringByBase64Encoding;
@end
|
︙ | | |
︙ | | |
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
-
+
-
+
-
+
-
+
-
+
-
+
-
+
|
/* References for static linking */
void _references_to_categories_of_OFDataArray(void)
{
_OFDataArray_Hashing_reference = 1;
};
@implementation OFDataArray
+ dataArrayWithItemSize: (size_t)is
+ dataArrayWithItemSize: (size_t)itemSize
{
return [[[self alloc] initWithItemSize: is] autorelease];
return [[[self alloc] initWithItemSize: itemSize] autorelease];
}
+ dataArrayWithContentsOfFile: (OFString*)path
{
return [[[self alloc] initWithContentsOfFile: path] autorelease];
}
+ dataArrayWithBase64EncodedString: (OFString*)str
+ dataArrayWithBase64EncodedString: (OFString*)string
{
return [[[self alloc] initWithBase64EncodedString: str] autorelease];
return [[[self alloc] initWithBase64EncodedString: string] autorelease];
}
- init
{
Class c = isa;
[self release];
@throw [OFNotImplementedException newWithClass: c
selector: _cmd];
}
- initWithItemSize: (size_t)is
- initWithItemSize: (size_t)itemSize_
{
self = [super init];
@try {
if (is == 0)
if (itemSize_ == 0)
@throw [OFInvalidArgumentException newWithClass: isa
selector: _cmd];
itemSize = is;
itemSize = itemSize_;
data = NULL;
} @catch (id e) {
[self release];
@throw e;
}
return self;
|
︙ | | |
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
|
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
|
-
+
-
+
-
-
-
-
+
+
+
+
-
+
-
+
-
+
|
OFFile *file = [[OFFile alloc] initWithPath: path
mode: @"rb"];
itemSize = 1;
data = NULL;
@try {
char *buf = [self allocMemoryWithSize: of_pagesize];
char *buffer = [self allocMemoryWithSize: of_pagesize];
while (![file isAtEndOfStream]) {
size_t size;
size_t length;
size = [file readNBytes: of_pagesize
intoBuffer: buf];
[self addNItems: size
fromCArray: buf];
length = [file readNBytes: of_pagesize
intoBuffer: buffer];
[self addNItems: length
fromCArray: buffer];
}
[self freeMemory: buf];
[self freeMemory: buffer];
} @finally {
[file release];
}
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
- initWithBase64EncodedString: (OFString*)str
- initWithBase64EncodedString: (OFString*)string
{
self = [super init];
itemSize = 1;
data = NULL;
if (!of_base64_decode(self, [str cString], [str cStringLength])) {
if (!of_base64_decode(self, [string cString], [string cStringLength])) {
Class c = isa;
[self release];
@throw [OFInvalidEncodingException newWithClass: c];
}
return self;
}
|
︙ | | |
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
|
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
334
|
-
-
+
+
-
+
-
+
-
-
+
+
-
-
+
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
-
+
+
-
+
-
-
-
+
+
+
+
-
+
-
+
+
+
-
+
+
+
+
-
-
+
+
-
+
-
+
+
-
-
+
+
-
+
+
+
-
+
-
-
+
+
-
-
-
+
+
+
-
+
-
+
|
atIndex: (size_t)index
{
[self addNItems: 1
fromCArray: item
atIndex: index];
}
- (void)addNItems: (size_t)nitems
fromCArray: (const void*)carray
- (void)addNItems: (size_t)nItems
fromCArray: (const void*)cArray
{
if (nitems > SIZE_MAX - count)
if (nItems > SIZE_MAX - count)
@throw [OFOutOfRangeException newWithClass: isa];
data = [self resizeMemory: data
toNItems: count + nitems
toNItems: count + nItems
withSize: itemSize];
memcpy(data + count * itemSize, carray, nitems * itemSize);
count += nitems;
memcpy(data + count * itemSize, cArray, nItems * itemSize);
count += nItems;
}
- (void)addNItems: (size_t)nitems
fromCArray: (const void*)carray
- (void)addNItems: (size_t)nItems
fromCArray: (const void*)cArray
atIndex: (size_t)index
{
if (nitems > SIZE_MAX - count)
if (nItems > SIZE_MAX - count)
@throw [OFOutOfRangeException newWithClass: isa];
data = [self resizeMemory: data
toNItems: count + nitems
toNItems: count + nItems
withSize: itemSize];
memmove(data + (index + nitems) * itemSize, data + index * itemSize,
memmove(data + (index + nItems) * itemSize, data + index * itemSize,
(count - index) * itemSize);
memcpy(data + index * itemSize, carray, nitems * itemSize);
memcpy(data + index * itemSize, cArray, nItems * itemSize);
count += nitems;
count += nItems;
}
- (void)removeItemAtIndex: (size_t)index
{
[self removeNItems: 1
atIndex: index];
}
- (void)removeNItems: (size_t)nitems
- (void)removeNItems: (size_t)nItems
{
if (nitems > count)
if (nItems > count)
@throw [OFOutOfRangeException newWithClass: isa];
count -= nitems;
count -= nItems;
@try {
data = [self resizeMemory: data
toNItems: count
withSize: itemSize];
} @catch (OFOutOfMemoryException *e) {
/* We don't really care, as we only made it smaller */
[e release];
}
}
- (void)removeNItems: (size_t)nitems
- (void)removeNItems: (size_t)nItems
atIndex: (size_t)index
{
if (nitems > count)
if (nItems > count)
@throw [OFOutOfRangeException newWithClass: isa];
memmove(data + index * itemSize, data + (index + nitems) * itemSize,
(count - index - nitems) * itemSize);
memmove(data + index * itemSize, data + (index + nItems) * itemSize,
(count - index - nItems) * itemSize);
count -= nitems;
count -= nItems;
@try {
data = [self resizeMemory: data
toNItems: count
withSize: itemSize];
} @catch (OFOutOfMemoryException *e) {
/* We don't really care, as we only made it smaller */
[e release];
}
}
- copy
{
OFDataArray *new = [[OFDataArray alloc] initWithItemSize: itemSize];
[new addNItems: count
fromCArray: data];
OFDataArray *copy = [[OFDataArray alloc] initWithItemSize: itemSize];
[copy addNItems: count
fromCArray: data];
return new;
return copy;
}
- (BOOL)isEqual: (id)obj
- (BOOL)isEqual: (id)object
{
OFDataArray *otherDataArray;
if (![obj isKindOfClass: [OFDataArray class]])
if (![object isKindOfClass: [OFDataArray class]])
return NO;
otherDataArray = (OFDataArray*)object;
if ([(OFDataArray*)obj count] != count ||
[(OFDataArray*)obj itemSize] != itemSize)
if ([otherDataArray count] != count ||
[otherDataArray itemSize] != itemSize)
return NO;
if (memcmp([(OFDataArray*)obj cArray], data, count * itemSize))
if (memcmp([otherDataArray cArray], data, count * itemSize))
return NO;
return YES;
}
- (of_comparison_result_t)compare: (id)obj
- (of_comparison_result_t)compare: (id)object
{
OFDataArray *otherDataArray;
int cmp;
size_t ary_count, min_count;
int comparison;
size_t otherCount, minimumCount;
if (![obj isKindOfClass: [OFDataArray class]])
if (![object isKindOfClass: [OFDataArray class]])
@throw [OFInvalidArgumentException newWithClass: isa
selector: _cmd];
otherDataArray = (OFDataArray*)object;
if ([(OFDataArray*)obj itemSize] != itemSize)
if ([otherDataArray itemSize] != itemSize)
@throw [OFInvalidArgumentException newWithClass: isa
selector: _cmd];
ary_count = [(OFDataArray*)obj count];
min_count = (count > ary_count ? ary_count : count);
otherCount = [otherDataArray count];
minimumCount = (count > otherCount ? otherCount : count);
if ((cmp = memcmp(data, [(OFDataArray*)obj cArray],
min_count * itemSize)) == 0) {
if (count > ary_count)
if ((comparison = memcmp(data, [otherDataArray cArray],
minimumCount * itemSize)) == 0) {
if (count > otherCount)
return OF_ORDERED_DESCENDING;
if (count < ary_count)
if (count < otherCount)
return OF_ORDERED_ASCENDING;
return OF_ORDERED_SAME;
}
if (cmp > 0)
if (comparison > 0)
return OF_ORDERED_DESCENDING;
else
return OF_ORDERED_ASCENDING;
}
- (uint32_t)hash
{
|
︙ | | |
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
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
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
|
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
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
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
|
-
+
-
-
+
+
-
+
-
+
-
+
-
-
+
+
-
+
-
+
-
-
+
+
-
+
-
+
-
+
-
-
+
+
-
-
+
+
-
+
-
+
-
-
+
+
-
+
-
+
-
+
-
+
-
-
+
+
-
+
-
+
-
+
-
-
-
+
+
+
-
+
-
-
+
+
-
+
-
+
-
+
-
-
+
+
-
-
-
+
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
|
return of_base64_encode(data, count * itemSize);
}
@end
@implementation OFBigDataArray
- (void)addItem: (const void*)item
{
size_t nsize, lastpagebyte;
size_t newSize, lastPageByte;
if (SIZE_MAX - count < 1 || count + 1 > SIZE_MAX / itemSize)
@throw [OFOutOfRangeException newWithClass: isa];
lastpagebyte = of_pagesize - 1;
nsize = ((count + 1) * itemSize + lastpagebyte) & ~lastpagebyte;
lastPageByte = of_pagesize - 1;
newSize = ((count + 1) * itemSize + lastPageByte) & ~lastPageByte;
if (size != nsize)
if (size != newSize)
data = [self resizeMemory: data
toSize: nsize];
toSize: newSize];
memcpy(data + count * itemSize, item, itemSize);
count++;
size = nsize;
size = newSize;
}
- (void)addNItems: (size_t)nitems
fromCArray: (const void*)carray
- (void)addNItems: (size_t)nItems
fromCArray: (const void*)cArray
{
size_t nsize, lastpagebyte;
size_t newSize, lastPageByte;
if (nitems > SIZE_MAX - count || count + nitems > SIZE_MAX / itemSize)
if (nItems > SIZE_MAX - count || count + nItems > SIZE_MAX / itemSize)
@throw [OFOutOfRangeException newWithClass: isa];
lastpagebyte = of_pagesize - 1;
nsize = ((count + nitems) * itemSize + lastpagebyte) & ~lastpagebyte;
lastPageByte = of_pagesize - 1;
newSize = ((count + nItems) * itemSize + lastPageByte) & ~lastPageByte;
if (size != nsize)
if (size != newSize)
data = [self resizeMemory: data
toSize: nsize];
toSize: newSize];
memcpy(data + count * itemSize, carray, nitems * itemSize);
memcpy(data + count * itemSize, cArray, nItems * itemSize);
count += nitems;
size = nsize;
count += nItems;
size = newSize;
}
- (void)addNItems: (size_t)nitems
fromCArray: (const void*)carray
- (void)addNItems: (size_t)nItems
fromCArray: (const void*)cArray
atIndex: (size_t)index
{
size_t nsize, lastpagebyte;
size_t newSize, lastPageByte;
if (nitems > SIZE_MAX - count || count + nitems > SIZE_MAX / itemSize)
if (nItems > SIZE_MAX - count || count + nItems > SIZE_MAX / itemSize)
@throw [OFOutOfRangeException newWithClass: isa];
lastpagebyte = of_pagesize - 1;
nsize = ((count + nitems) * itemSize + lastpagebyte) & ~lastpagebyte;
lastPageByte = of_pagesize - 1;
newSize = ((count + nItems) * itemSize + lastPageByte) & ~lastPageByte;
if (size != nsize)
if (size != newSize)
data = [self resizeMemory: data
toNItems: nsize
toNItems: newSize
withSize: itemSize];
memmove(data + (index + nitems) * itemSize, data + index * itemSize,
memmove(data + (index + nItems) * itemSize, data + index * itemSize,
(count - index) * itemSize);
memcpy(data + index * itemSize, carray, nitems * itemSize);
memcpy(data + index * itemSize, cArray, nItems * itemSize);
count += nitems;
size = nsize;
count += nItems;
size = newSize;
}
- (void)removeNItems: (size_t)nitems
- (void)removeNItems: (size_t)nItems
{
size_t nsize, lastpagebyte;
size_t newSize, lastPageByte;
if (nitems > count)
if (nItems > count)
@throw [OFOutOfRangeException newWithClass: isa];
count -= nitems;
lastpagebyte = of_pagesize - 1;
nsize = (count * itemSize + lastpagebyte) & ~lastpagebyte;
count -= nItems;
lastPageByte = of_pagesize - 1;
newSize = (count * itemSize + lastPageByte) & ~lastPageByte;
if (size != nsize)
if (size != newSize)
data = [self resizeMemory: data
toSize: nsize];
size = nsize;
toSize: newSize];
size = newSize;
}
- (void)removeNItems: (size_t)nitems
- (void)removeNItems: (size_t)nItems
atIndex: (size_t)index
{
size_t nsize, lastpagebyte;
size_t newSize, lastPageByte;
if (nitems > count)
if (nItems > count)
@throw [OFOutOfRangeException newWithClass: isa];
memmove(data + index * itemSize, data + (index + nitems) * itemSize,
(count - index - nitems) * itemSize);
memmove(data + index * itemSize, data + (index + nItems) * itemSize,
(count - index - nItems) * itemSize);
count -= nitems;
lastpagebyte = of_pagesize - 1;
nsize = (count * itemSize + lastpagebyte) & ~lastpagebyte;
count -= nItems;
lastPageByte = of_pagesize - 1;
newSize = (count * itemSize + lastPageByte) & ~lastPageByte;
if (size != nsize)
if (size != newSize)
data = [self resizeMemory: data
toSize: nsize];
size = nsize;
toSize: newSize];
size = newSize;
}
- copy
{
OFDataArray *new = [[OFBigDataArray alloc] initWithItemSize: itemSize];
OFDataArray *copy = [[OFBigDataArray alloc] initWithItemSize: itemSize];
[new addNItems: count
fromCArray: data];
[copy addNItems: count
fromCArray: data];
return new;
return copy;
}
@end
|
︙ | | |
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
|
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
|
-
+
+
-
+
-
-
-
-
+
+
+
+
-
-
+
+
-
+
-
+
|
*/
- (id)performSelector: (SEL)selector;
/**
* Performs the specified selector with the specified object.
*
* \param selector The selector to perform
* \param obj The object that is passed to the method specified by the selector
* \param object The object that is passed to the method specified by the
* selector
* \return The object returned by the method specified by the selector
*/
- (id)performSelector: (SEL)selector
withObject: (id)obj;
withObject: (id)object;
/**
* Performs the specified selector with the specified objects.
*
* \param selector The selector to perform
* \param obj1 The first object that is passed to the method specified by the
* selector
* \param obj2 The second object that is passed to the method specified by the
* selector
* \param object The first object that is passed to the method specified by the
* selector
* \param otherObject The second object that is passed to the method specified
* by the selector
* \return The object returned by the method specified by the selector
*/
- (id)performSelector: (SEL)selector
withObject: (id)obj1
withObject: (id)obj2;
withObject: (id)object
withObject: (id)otherObject;
/**
* Checks two objects for equality.
*
* Classes containing data (like strings, arrays, lists etc.) should reimplement
* this!
*
* \param obj The object which should be tested for equality
* \param object The object which should be tested for equality
* \return A boolean whether the object is equal to the specified object
*/
- (BOOL)isEqual: (id)obj;
- (BOOL)isEqual: (id)object;
/**
* Calculates a hash for the object.
*
* Classes containing data (like strings, arrays, lists etc.) should reimplement
* this!
*
|
︙ | | |
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
|
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
|
-
+
-
+
|
*
* This protocol is implemented by objects that can be compared.
*/
@protocol OFComparing
/**
* Compares the object with another object.
*
* \param obj An object to compare the object to
* \param object An object to compare the object to
* \return The result of the comparison
*/
- (of_comparison_result_t)compare: (id)obj;
- (of_comparison_result_t)compare: (id)object;
@end
#ifdef __cplusplus
extern "C" {
#endif
extern id objc_getProperty(id, SEL, ptrdiff_t, BOOL);
extern void objc_setProperty(id, SEL, ptrdiff_t, id, BOOL, BOOL);
extern size_t of_pagesize;
#ifdef __cplusplus
}
#endif
|
︙ | | |
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
|
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
|
-
+
-
+
-
-
+
+
-
+
|
{
id (*imp)(id, SEL) = (id(*)(id, SEL))[self methodForSelector: selector];
return imp(self, selector);
}
- (id)performSelector: (SEL)selector
withObject: (id)obj
withObject: (id)object
{
id (*imp)(id, SEL, id) =
(id(*)(id, SEL, id))[self methodForSelector: selector];
return imp(self, selector, obj);
return imp(self, selector, object);
}
- (id)performSelector: (SEL)selector
withObject: (id)obj1
withObject: (id)obj2
withObject: (id)object
withObject: (id)otherObject
{
id (*imp)(id, SEL, id, id) =
(id(*)(id, SEL, id, id))[self methodForSelector: selector];
return imp(self, selector, obj1, obj2);
return imp(self, selector, object, otherObject);
}
- (const char*)typeEncodingForSelector: (SEL)selector
{
#if defined(OF_OBJFW_RUNTIME)
const char *ret;
|
︙ | | |
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
|
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
|
-
+
-
+
|
@throw [OFNotImplementedException newWithClass: isa
selector: selector];
return ret;
#endif
}
- (BOOL)isEqual: (id)obj
- (BOOL)isEqual: (id)object
{
/* Classes containing data should reimplement this! */
return (self == obj);
return (self == object);
}
- (uint32_t)hash
{
/* Classes containing data should reimplement this! */
return (uint32_t)(uintptr_t)self;
}
|
︙ | | |