Modified configure.ac
from [9036437ef5]
to [b1e49e08ab].
︙ | | | ︙ | |
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
|
AX_CHECK_COMPILER_FLAGS(-fno-objc-nonfragile-abi, [
flag="-fno-objc-nonfragile-abi"
OBJCFLAGS="$OBJCFLAGS $flag"
RUNTIME_FLAGS="$RUNTIME_FLAGS $flag"
])
])
AX_CHECK_COMPILER_FLAGS(-Wno-deprecated-objc-isa-usage,
[OBJCFLAGS="$OBJCFLAGS -Wno-deprecated-objc-isa-usage"])
AC_SUBST(RUNTIME_FLAGS)
AC_SUBST(RUNTIME, "runtime")
if test x"$enable_shared" != x"no"; then
AC_SUBST(RUNTIME_LIB_A, "runtime.lib.a")
AC_SUBST(RUNTIME_RUNTIME_LIB_A, "runtime/runtime.lib.a")
fi
if test x"$enable_static" = x"yes" \
-o x"$enable_shared" = x"no"; then
AC_SUBST(RUNTIME_A, "runtime.a")
|
<
<
|
<
|
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
|
AX_CHECK_COMPILER_FLAGS(-fno-objc-nonfragile-abi, [
flag="-fno-objc-nonfragile-abi"
OBJCFLAGS="$OBJCFLAGS $flag"
RUNTIME_FLAGS="$RUNTIME_FLAGS $flag"
])
])
AC_SUBST(RUNTIME, "runtime")
AC_SUBST(RUNTIME_FLAGS)
if test x"$enable_shared" != x"no"; then
AC_SUBST(RUNTIME_LIB_A, "runtime.lib.a")
AC_SUBST(RUNTIME_RUNTIME_LIB_A, "runtime/runtime.lib.a")
fi
if test x"$enable_static" = x"yes" \
-o x"$enable_shared" = x"no"; then
AC_SUBST(RUNTIME_A, "runtime.a")
|
︙ | | | ︙ | |
Modified src/OFApplication.m
from [68b2ca804c]
to [26c169306d].
︙ | | | ︙ | |
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
|
[super dealloc];
}
@end
@implementation OFObject (OFApplicationDelegate)
- (void)applicationDidFinishLaunching
{
@throw [OFNotImplementedException exceptionWithClass: isa
selector: _cmd];
}
- (void)applicationWillTerminate
{
}
|
|
|
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
|
[super dealloc];
}
@end
@implementation OFObject (OFApplicationDelegate)
- (void)applicationDidFinishLaunching
{
@throw [OFNotImplementedException exceptionWithClass: [self class]
selector: _cmd];
}
- (void)applicationWillTerminate
{
}
|
︙ | | | ︙ | |
Modified src/OFArray.m
from [7b45e24981]
to [e58f6deb57].
︙ | | | ︙ | |
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
|
- (void)release
{
}
- (void)dealloc
{
@throw [OFNotImplementedException exceptionWithClass: isa
selector: _cmd];
[super dealloc]; /* Get rid of a stupid warning */
}
@end
@implementation OFArray
+ (void)initialize
{
if (self == [OFArray class])
placeholder.isa = [OFArray_placeholder class];
}
+ alloc
{
if (self == [OFArray class])
return (id)&placeholder;
|
|
|
|
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
|
- (void)release
{
}
- (void)dealloc
{
@throw [OFNotImplementedException exceptionWithClass: [self class]
selector: _cmd];
[super dealloc]; /* Get rid of a stupid warning */
}
@end
@implementation OFArray
+ (void)initialize
{
if (self == [OFArray class])
object_setClass((id)&placeholder, [OFArray_placeholder class]);
}
+ alloc
{
if (self == [OFArray class])
return (id)&placeholder;
|
︙ | | | ︙ | |
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
|
{
return [[[self alloc] initWithObjects: objects
count: count] autorelease];
}
- init
{
if (isa == [OFArray class]) {
Class c = isa;
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
return [super init];
}
|
|
|
|
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
|
{
return [[[self alloc] initWithObjects: objects
count: count] autorelease];
}
- init
{
if (object_getClass(self) == [OFArray class]) {
Class c = [self class];
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
return [super init];
}
|
︙ | | | ︙ | |
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
|
return ret;
}
- initWithObject: (id)firstObject
arguments: (va_list)arguments
{
Class c = isa;
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
- initWithArray: (OFArray*)array
{
Class c = isa;
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
- initWithObjects: (id const*)objects
count: (size_t)count
{
Class c = isa;
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
- initWithSerialization: (OFXMLElement*)element
{
Class c = isa;
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
- (size_t)count
{
@throw [OFNotImplementedException exceptionWithClass: isa
selector: _cmd];
}
- (void)getObjects: (id*)buffer
inRange: (of_range_t)range
{
size_t i;
|
|
|
|
|
|
|
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
|
return ret;
}
- initWithObject: (id)firstObject
arguments: (va_list)arguments
{
Class c = [self class];
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
- initWithArray: (OFArray*)array
{
Class c = [self class];
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
- initWithObjects: (id const*)objects
count: (size_t)count
{
Class c = [self class];
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
- initWithSerialization: (OFXMLElement*)element
{
Class c = [self class];
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
- (size_t)count
{
@throw [OFNotImplementedException exceptionWithClass: [self class]
selector: _cmd];
}
- (void)getObjects: (id*)buffer
inRange: (of_range_t)range
{
size_t i;
|
︙ | | | ︙ | |
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
|
- mutableCopy
{
return [[OFMutableArray alloc] initWithArray: self];
}
- (id)objectAtIndex: (size_t)index
{
@throw [OFNotImplementedException exceptionWithClass: isa
selector: _cmd];
}
- (id)objectAtIndexedSubscript: (size_t)index
{
return [self objectAtIndex: index];
}
|
|
|
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
|
- mutableCopy
{
return [[OFMutableArray alloc] initWithArray: self];
}
- (id)objectAtIndex: (size_t)index
{
@throw [OFNotImplementedException exceptionWithClass: [self class]
selector: _cmd];
}
- (id)objectAtIndexedSubscript: (size_t)index
{
return [self objectAtIndex: index];
}
|
︙ | | | ︙ | |
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
|
objects: (id*)objects
count: (int)count_
{
/* FIXME: Use -[getObjects:inRange:] on the passed objects */
size_t count = [self count];
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;
|
|
|
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
|
objects: (id*)objects
count: (int)count_
{
/* FIXME: Use -[getObjects:inRange:] on the passed objects */
size_t count = [self count];
if (count > INT_MAX)
@throw [OFOutOfRangeException exceptionWithClass: [self class]];
if (state->state >= count)
return 0;
state->state = count;
state->itemsPtr = [self objects];
state->mutationsPtr = (unsigned long*)self;
|
︙ | | | ︙ | |
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
|
[super dealloc];
}
- (id)nextObject
{
if (mutationsPtr != NULL && *mutationsPtr != mutations)
@throw [OFEnumerationMutationException
exceptionWithClass: isa
object: array];
if (position < count)
return [array objectAtIndex: position++];
return nil;
}
- (void)reset
{
if (mutationsPtr != NULL && *mutationsPtr != mutations)
@throw [OFEnumerationMutationException
exceptionWithClass: isa
object: array];
position = 0;
}
@end
|
|
|
|
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
|
[super dealloc];
}
- (id)nextObject
{
if (mutationsPtr != NULL && *mutationsPtr != mutations)
@throw [OFEnumerationMutationException
exceptionWithClass: [self class]
object: array];
if (position < count)
return [array objectAtIndex: position++];
return nil;
}
- (void)reset
{
if (mutationsPtr != NULL && *mutationsPtr != mutations)
@throw [OFEnumerationMutationException
exceptionWithClass: [self class]
object: array];
position = 0;
}
@end
|
Modified src/OFArray_adjacent.m
from [7c4a615aae]
to [a6c8e71afe].
︙ | | | ︙ | |
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
|
pool = [[OFAutoreleasePool alloc] init];
if ((![[element name] isEqual: @"OFArray"] &&
![[element name] isEqual: @"OFMutableArray"]) ||
![[element namespace] isEqual: OF_SERIALIZATION_NS])
@throw [OFInvalidArgumentException
exceptionWithClass: isa
selector: _cmd];
enumerator = [[element elementsForNamespace:
OF_SERIALIZATION_NS] objectEnumerator];
pool2 = [[OFAutoreleasePool alloc] init];
while ((child = [enumerator nextObject]) != nil) {
|
|
|
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
|
pool = [[OFAutoreleasePool alloc] init];
if ((![[element name] isEqual: @"OFArray"] &&
![[element name] isEqual: @"OFMutableArray"]) ||
![[element namespace] isEqual: OF_SERIALIZATION_NS])
@throw [OFInvalidArgumentException
exceptionWithClass: [self class]
selector: _cmd];
enumerator = [[element elementsForNamespace:
OF_SERIALIZATION_NS] objectEnumerator];
pool2 = [[OFAutoreleasePool alloc] init];
while ((child = [enumerator nextObject]) != nil) {
|
︙ | | | ︙ | |
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
|
- (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
{
|
|
|
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
|
- (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: [self class]];
for (i = 0; i < range.length; i++)
buffer[i] = objects[range.start + i];
}
- (size_t)indexOfObject: (id)object
{
|
︙ | | | ︙ | |
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
|
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
{
|
|
|
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
|
if (![self isKindOfClass: [OFMutableArray class]])
return [OFArray_adjacentSubarray arrayWithArray: self
range: range];
count = [array count];
if (range.start + range.length > count)
@throw [OFOutOfRangeException exceptionWithClass: [self class]];
return [OFArray arrayWithObjects: (id*)[array cArray] + range.start
count: range.length];
}
- (BOOL)isEqual: (id)object
{
|
︙ | | | ︙ | |
Modified src/OFArray_subarray.m
from [535e1320bc]
to [1f6f789ff3].
︙ | | | ︙ | |
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
{
return range.length;
}
- (id)objectAtIndex: (size_t)index
{
if (index >= range.length)
@throw [OFOutOfRangeException exceptionWithClass: isa];
return [array objectAtIndex: index + range.start];
}
- (void)getObjects: (id*)buffer
inRange: (of_range_t)range_
{
if (range_.start + range_.length > range.length)
@throw [OFOutOfRangeException exceptionWithClass: isa];
range_.start += range.start;
return [array getObjects: buffer
inRange: range_];
}
|
|
|
|
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
{
return range.length;
}
- (id)objectAtIndex: (size_t)index
{
if (index >= range.length)
@throw [OFOutOfRangeException exceptionWithClass: [self class]];
return [array objectAtIndex: index + range.start];
}
- (void)getObjects: (id*)buffer
inRange: (of_range_t)range_
{
if (range_.start + range_.length > range.length)
@throw [OFOutOfRangeException exceptionWithClass: [self class]];
range_.start += range.start;
return [array getObjects: buffer
inRange: range_];
}
|
︙ | | | ︙ | |
106
107
108
109
110
111
112
113
114
115
116
117
118
119
|
return index;
}
- (OFArray*)objectsInRange: (of_range_t)range_
{
if (range_.start + range_.length > range.length)
@throw [OFOutOfRangeException exceptionWithClass: isa];
range_.start += range.start;
return [array objectsInRange: range_];
}
@end
|
|
|
106
107
108
109
110
111
112
113
114
115
116
117
118
119
|
return index;
}
- (OFArray*)objectsInRange: (of_range_t)range_
{
if (range_.start + range_.length > range.length)
@throw [OFOutOfRangeException exceptionWithClass: [self class]];
range_.start += range.start;
return [array objectsInRange: range_];
}
@end
|
Modified src/OFAutoreleasePool.m
from [42c4c969f4]
to [6d60b227fa].
︙ | | | ︙ | |
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
|
@try {
#ifdef OF_THREADS
id firstPool = of_tlskey_get(firstKey);
previousPool = of_tlskey_get(lastKey);
if (!of_tlskey_set(lastKey, self))
@throw [OFInitializationFailedException
exceptionWithClass: isa];
#else
previousPool = lastPool;
lastPool = self;
#endif
if (firstPool == nil) {
#ifdef OF_THREADS
if (!of_tlskey_set(firstKey, self)) {
of_tlskey_set(lastKey, previousPool);
@throw [OFInitializationFailedException
exceptionWithClass: isa];
}
#else
firstPool = self;
#endif
}
if (previousPool != nil)
|
|
|
|
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
|
@try {
#ifdef OF_THREADS
id firstPool = of_tlskey_get(firstKey);
previousPool = of_tlskey_get(lastKey);
if (!of_tlskey_set(lastKey, self))
@throw [OFInitializationFailedException
exceptionWithClass: [self class]];
#else
previousPool = lastPool;
lastPool = self;
#endif
if (firstPool == nil) {
#ifdef OF_THREADS
if (!of_tlskey_set(firstKey, self)) {
of_tlskey_set(lastKey, previousPool);
@throw [OFInitializationFailedException
exceptionWithClass: [self class]];
}
#else
firstPool = self;
#endif
}
if (previousPool != nil)
|
︙ | | | ︙ | |
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
|
#endif
[super dealloc];
}
- retain
{
@throw [OFNotImplementedException exceptionWithClass: isa
selector: _cmd];
}
- autorelease
{
@throw [OFNotImplementedException exceptionWithClass: isa
selector: _cmd];
}
@end
|
|
|
|
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
|
#endif
[super dealloc];
}
- retain
{
@throw [OFNotImplementedException exceptionWithClass: [self class]
selector: _cmd];
}
- autorelease
{
@throw [OFNotImplementedException exceptionWithClass: [self class]
selector: _cmd];
}
@end
|
Modified src/OFBlock.m
from [d9ed74f314]
to [badbea4cd4].
︙ | | | ︙ | |
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
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
|
#endif
void*
_Block_copy(const void *block_)
{
of_block_literal_t *block = (of_block_literal_t*)block_;
if (block->isa == (Class)&_NSConcreteStackBlock) {
of_block_literal_t *copy;
if ((copy = malloc(block->descriptor->size)) == NULL) {
alloc_failed_exception.isa =
[OFAllocFailedException class];
@throw (OFAllocFailedException*)&alloc_failed_exception;
}
memcpy(copy, block, block->descriptor->size);
copy->isa = (Class)&_NSConcreteMallocBlock;
copy->flags++;
if (block->flags & OF_BLOCK_HAS_COPY_DISPOSE)
block->descriptor->copy_helper(copy, block);
return copy;
}
if (block->isa == (Class)&_NSConcreteMallocBlock) {
#if defined(OF_ATOMIC_OPS)
of_atomic_inc_int(&block->flags);
#else
unsigned hash = SPINLOCK_HASH(block);
assert(of_spinlock_lock(&spinlocks[hash]));
block->flags++;
assert(of_spinlock_unlock(&spinlocks[hash]));
#endif
}
return block;
}
void
_Block_release(const void *block_)
{
of_block_literal_t *block = (of_block_literal_t*)block_;
if (block->isa != (Class)&_NSConcreteMallocBlock)
return;
#ifdef OF_ATOMIC_OPS
if ((of_atomic_dec_int(&block->flags) & OF_BLOCK_REFCOUNT_MASK) == 0) {
if (block->flags & OF_BLOCK_HAS_COPY_DISPOSE)
block->descriptor->dispose_helper(block);
|
|
|
|
|
|
|
|
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
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
|
#endif
void*
_Block_copy(const void *block_)
{
of_block_literal_t *block = (of_block_literal_t*)block_;
if (object_getClass((id)block) == (Class)&_NSConcreteStackBlock) {
of_block_literal_t *copy;
if ((copy = malloc(block->descriptor->size)) == NULL) {
object_setClass((id)&alloc_failed_exception,
[OFAllocFailedException class]);
@throw (OFAllocFailedException*)&alloc_failed_exception;
}
memcpy(copy, block, block->descriptor->size);
object_setClass((id)copy, (Class)&_NSConcreteMallocBlock);
copy->flags++;
if (block->flags & OF_BLOCK_HAS_COPY_DISPOSE)
block->descriptor->copy_helper(copy, block);
return copy;
}
if (object_getClass((id)block) == (Class)&_NSConcreteMallocBlock) {
#if defined(OF_ATOMIC_OPS)
of_atomic_inc_int(&block->flags);
#else
unsigned hash = SPINLOCK_HASH(block);
assert(of_spinlock_lock(&spinlocks[hash]));
block->flags++;
assert(of_spinlock_unlock(&spinlocks[hash]));
#endif
}
return block;
}
void
_Block_release(const void *block_)
{
of_block_literal_t *block = (of_block_literal_t*)block_;
if (object_getClass((id)block) != (Class)&_NSConcreteMallocBlock)
return;
#ifdef OF_ATOMIC_OPS
if ((of_atomic_dec_int(&block->flags) & OF_BLOCK_REFCOUNT_MASK) == 0) {
if (block->flags & OF_BLOCK_HAS_COPY_DISPOSE)
block->descriptor->dispose_helper(block);
|
︙ | | | ︙ | |
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
|
break;
case OF_BLOCK_FIELD_IS_BYREF:;
of_block_byref_t *src = (of_block_byref_t*)src_;
of_block_byref_t **dst = (of_block_byref_t**)dst_;
if ((src->flags & OF_BLOCK_REFCOUNT_MASK) == 0) {
if ((*dst = malloc(src->size)) == NULL) {
alloc_failed_exception.isa =
[OFAllocFailedException class];
@throw (OFAllocFailedException*)
&alloc_failed_exception;
}
if (src->forwarding == src)
(*dst)->forwarding = *dst;
|
|
|
|
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
|
break;
case OF_BLOCK_FIELD_IS_BYREF:;
of_block_byref_t *src = (of_block_byref_t*)src_;
of_block_byref_t **dst = (of_block_byref_t**)dst_;
if ((src->flags & OF_BLOCK_REFCOUNT_MASK) == 0) {
if ((*dst = malloc(src->size)) == NULL) {
object_setClass((id)&alloc_failed_exception,
[OFAllocFailedException class]);
@throw (OFAllocFailedException*)
&alloc_failed_exception;
}
if (src->forwarding == src)
(*dst)->forwarding = *dst;
|
︙ | | | ︙ | |
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
|
{
@throw [OFNotImplementedException exceptionWithClass: self
selector: _cmd];
}
- init
{
@throw [OFNotImplementedException exceptionWithClass: isa
selector: _cmd];
}
- (void*)allocMemoryWithSize: (size_t)size
{
@throw [OFNotImplementedException exceptionWithClass: isa
selector: _cmd];
}
- (void*)allocMemoryWithSize: (size_t)size
count: (size_t)count
{
@throw [OFNotImplementedException exceptionWithClass: isa
selector: _cmd];
}
- (void*)resizeMemory: (void*)ptr
size: (size_t)size
{
@throw [OFNotImplementedException exceptionWithClass: isa
selector: _cmd];
}
- (void*)resizeMemory: (void*)ptr
size: (size_t)size
count: (size_t)count
{
@throw [OFNotImplementedException exceptionWithClass: isa
selector: _cmd];
}
- (void)freeMemory: (void*)ptr
{
@throw [OFNotImplementedException exceptionWithClass: isa
selector: _cmd];
}
- retain
{
if (isa == (Class)&_NSConcreteMallocBlock)
return Block_copy(self);
return self;
}
- copy
{
return Block_copy(self);
}
- autorelease
{
if (isa == (Class)&_NSConcreteMallocBlock)
return [super autorelease];
return self;
}
- (unsigned int)retainCount
{
if (isa == (Class)&_NSConcreteMallocBlock)
return ((of_block_literal_t*)self)->flags &
OF_BLOCK_REFCOUNT_MASK;
return OF_RETAIN_COUNT_MAX;
}
- (void)release
{
if (isa == (Class)&_NSConcreteMallocBlock)
Block_release(self);
}
- (void)dealloc
{
@throw [OFNotImplementedException exceptionWithClass: isa
selector: _cmd];
[super dealloc]; /* Get rid of a stupid warning */
}
@end
#if defined(OF_APPLE_RUNTIME) && defined(__OBJC2__)
@implementation OFStackBlock
|
|
|
|
|
|
|
|
|
|
|
|
|
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
|
{
@throw [OFNotImplementedException exceptionWithClass: self
selector: _cmd];
}
- init
{
@throw [OFNotImplementedException exceptionWithClass: [self class]
selector: _cmd];
}
- (void*)allocMemoryWithSize: (size_t)size
{
@throw [OFNotImplementedException exceptionWithClass: [self class]
selector: _cmd];
}
- (void*)allocMemoryWithSize: (size_t)size
count: (size_t)count
{
@throw [OFNotImplementedException exceptionWithClass: [self class]
selector: _cmd];
}
- (void*)resizeMemory: (void*)ptr
size: (size_t)size
{
@throw [OFNotImplementedException exceptionWithClass: [self class]
selector: _cmd];
}
- (void*)resizeMemory: (void*)ptr
size: (size_t)size
count: (size_t)count
{
@throw [OFNotImplementedException exceptionWithClass: [self class]
selector: _cmd];
}
- (void)freeMemory: (void*)ptr
{
@throw [OFNotImplementedException exceptionWithClass: [self class]
selector: _cmd];
}
- retain
{
if (object_getClass(self) == (Class)&_NSConcreteMallocBlock)
return Block_copy(self);
return self;
}
- copy
{
return Block_copy(self);
}
- autorelease
{
if (object_getClass(self) == (Class)&_NSConcreteMallocBlock)
return [super autorelease];
return self;
}
- (unsigned int)retainCount
{
if (object_getClass(self) == (Class)&_NSConcreteMallocBlock)
return ((of_block_literal_t*)self)->flags &
OF_BLOCK_REFCOUNT_MASK;
return OF_RETAIN_COUNT_MAX;
}
- (void)release
{
if (object_getClass(self) == (Class)&_NSConcreteMallocBlock)
Block_release(self);
}
- (void)dealloc
{
@throw [OFNotImplementedException exceptionWithClass: [self class]
selector: _cmd];
[super dealloc]; /* Get rid of a stupid warning */
}
@end
#if defined(OF_APPLE_RUNTIME) && defined(__OBJC2__)
@implementation OFStackBlock
|
︙ | | | ︙ | |
Modified src/OFConstantString.m
from [63e98f3fd3]
to [634c81749f].
︙ | | | ︙ | |
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
|
@throw [OFNotImplementedException exceptionWithClass: self
selector: _cmd];
}
- (void*)allocMemoryWithSize: (size_t)size
{
@throw [OFNotImplementedException exceptionWithClass: isa
selector: _cmd];
}
- (void*)allocMemoryWithSize: (size_t)itemSize
count: (size_t)count
{
@throw [OFNotImplementedException exceptionWithClass: isa
selector: _cmd];
}
- (void*)resizeMemory: (void*)ptr
size: (size_t)size
{
@throw [OFNotImplementedException exceptionWithClass: isa
selector: _cmd];
}
- (void*)resizeMemory: (void*)ptr
toNItems: (size_t)nitems
withSize: (size_t)size
{
@throw [OFNotImplementedException exceptionWithClass: isa
selector: _cmd];
}
- (void)freeMemory: (void*)ptr
{
@throw [OFNotImplementedException exceptionWithClass: isa
selector: _cmd];
}
- retain
{
return self;
}
|
|
|
|
|
|
|
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
|
@throw [OFNotImplementedException exceptionWithClass: self
selector: _cmd];
}
- (void*)allocMemoryWithSize: (size_t)size
{
@throw [OFNotImplementedException exceptionWithClass: [self class]
selector: _cmd];
}
- (void*)allocMemoryWithSize: (size_t)itemSize
count: (size_t)count
{
@throw [OFNotImplementedException exceptionWithClass: [self class]
selector: _cmd];
}
- (void*)resizeMemory: (void*)ptr
size: (size_t)size
{
@throw [OFNotImplementedException exceptionWithClass: [self class]
selector: _cmd];
}
- (void*)resizeMemory: (void*)ptr
toNItems: (size_t)nitems
withSize: (size_t)size
{
@throw [OFNotImplementedException exceptionWithClass: [self class]
selector: _cmd];
}
- (void)freeMemory: (void*)ptr
{
@throw [OFNotImplementedException exceptionWithClass: [self class]
selector: _cmd];
}
- retain
{
return self;
}
|
︙ | | | ︙ | |
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
|
- (void)release
{
}
- (void)dealloc
{
@throw [OFNotImplementedException exceptionWithClass: isa
selector: _cmd];
[super dealloc]; /* Get rid of a stupid warning */
}
@end
@implementation OFConstantString
+ (void)load
|
|
|
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
|
- (void)release
{
}
- (void)dealloc
{
@throw [OFNotImplementedException exceptionWithClass: [self class]
selector: _cmd];
[super dealloc]; /* Get rid of a stupid warning */
}
@end
@implementation OFConstantString
+ (void)load
|
︙ | | | ︙ | |
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
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
|
- (void)finishInitialization
{
struct of_string_utf8_ivars *ivars;
if ((ivars = malloc(sizeof(*ivars))) == NULL)
@throw [OFOutOfMemoryException
exceptionWithClass: isa
requestedSize: sizeof(*ivars)];
memset(ivars, 0, sizeof(*ivars));
ivars->cString = cString;
ivars->cStringLength = cStringLength;
switch (of_string_check_utf8(ivars->cString, ivars->cStringLength,
&ivars->length)) {
case 1:
ivars->UTF8 = YES;
break;
case -1:
free(ivars);
@throw [OFInvalidEncodingException exceptionWithClass: isa];
}
cString = (char*)ivars;
isa = [OFString_const class];
}
+ alloc
{
@throw [OFNotImplementedException exceptionWithClass: self
selector: _cmd];
}
- (void*)allocMemoryWithSize: (size_t)size
{
@throw [OFNotImplementedException exceptionWithClass: isa
selector: _cmd];
}
- (void*)allocMemoryWithSize: (size_t)size
count: (size_t)count
{
@throw [OFNotImplementedException exceptionWithClass: isa
selector: _cmd];
}
- (void*)resizeMemory: (void*)ptr
size: (size_t)size
{
@throw [OFNotImplementedException exceptionWithClass: isa
selector: _cmd];
}
- (void*)resizeMemory: (void*)ptr
size: (size_t)size
count: (size_t)count
{
@throw [OFNotImplementedException exceptionWithClass: isa
selector: _cmd];
}
- (void)freeMemory: (void*)ptr
{
@throw [OFNotImplementedException exceptionWithClass: isa
selector: _cmd];
}
- retain
{
return self;
}
|
|
|
>
|
|
|
|
|
|
|
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
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
|
- (void)finishInitialization
{
struct of_string_utf8_ivars *ivars;
if ((ivars = malloc(sizeof(*ivars))) == NULL)
@throw [OFOutOfMemoryException
exceptionWithClass: [self class]
requestedSize: sizeof(*ivars)];
memset(ivars, 0, sizeof(*ivars));
ivars->cString = cString;
ivars->cStringLength = cStringLength;
switch (of_string_check_utf8(ivars->cString, ivars->cStringLength,
&ivars->length)) {
case 1:
ivars->UTF8 = YES;
break;
case -1:
free(ivars);
@throw [OFInvalidEncodingException
exceptionWithClass: [self class]];
}
cString = (char*)ivars;
object_setClass(self, [OFString_const class]);
}
+ alloc
{
@throw [OFNotImplementedException exceptionWithClass: self
selector: _cmd];
}
- (void*)allocMemoryWithSize: (size_t)size
{
@throw [OFNotImplementedException exceptionWithClass: [self class]
selector: _cmd];
}
- (void*)allocMemoryWithSize: (size_t)size
count: (size_t)count
{
@throw [OFNotImplementedException exceptionWithClass: [self class]
selector: _cmd];
}
- (void*)resizeMemory: (void*)ptr
size: (size_t)size
{
@throw [OFNotImplementedException exceptionWithClass: [self class]
selector: _cmd];
}
- (void*)resizeMemory: (void*)ptr
size: (size_t)size
count: (size_t)count
{
@throw [OFNotImplementedException exceptionWithClass: [self class]
selector: _cmd];
}
- (void)freeMemory: (void*)ptr
{
@throw [OFNotImplementedException exceptionWithClass: [self class]
selector: _cmd];
}
- retain
{
return self;
}
|
︙ | | | ︙ | |
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
|
- (void)release
{
}
- (void)dealloc
{
@throw [OFNotImplementedException exceptionWithClass: isa
selector: _cmd];
[super dealloc]; /* Get rid of a stupid warning */
}
/*
* In all following methods, the constant string is converted to an
* OFString_UTF8 and the message sent again.
|
|
|
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
|
- (void)release
{
}
- (void)dealloc
{
@throw [OFNotImplementedException exceptionWithClass: [self class]
selector: _cmd];
[super dealloc]; /* Get rid of a stupid warning */
}
/*
* In all following methods, the constant string is converted to an
* OFString_UTF8 and the message sent again.
|
︙ | | | ︙ | |
Modified src/OFCountedSet.m
from [1ffb5da144]
to [e5a46a4669].
︙ | | | ︙ | |
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
|
- (void)release
{
}
- (void)dealloc
{
@throw [OFNotImplementedException exceptionWithClass: isa
selector: _cmd];
[super dealloc]; /* Get rid of a stupid warning */
}
@end
@implementation OFCountedSet
+ (void)initialize
{
if (self == [OFCountedSet class])
placeholder.isa = [OFCountedSet_placeholder class];
}
+ alloc
{
if (self == [OFCountedSet class])
return (id)&placeholder;
return [super alloc];
}
- init
{
if (isa == [OFCountedSet class]) {
Class c = isa;
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
return [super init];
}
- (size_t)countForObject: (id)object
{
@throw [OFNotImplementedException exceptionWithClass: isa
selector: _cmd];
}
- (OFString*)description
{
OFMutableString *ret;
OFAutoreleasePool *pool, *pool2;
|
|
>
|
|
|
|
|
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
|
- (void)release
{
}
- (void)dealloc
{
@throw [OFNotImplementedException exceptionWithClass: [self class]
selector: _cmd];
[super dealloc]; /* Get rid of a stupid warning */
}
@end
@implementation OFCountedSet
+ (void)initialize
{
if (self == [OFCountedSet class])
object_setClass((id)&placeholder,
[OFCountedSet_placeholder class]);
}
+ alloc
{
if (self == [OFCountedSet class])
return (id)&placeholder;
return [super alloc];
}
- init
{
if (object_getClass(self) == [OFCountedSet class]) {
Class c = [self class];
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
return [super init];
}
- (size_t)countForObject: (id)object
{
@throw [OFNotImplementedException exceptionWithClass: [self class]
selector: _cmd];
}
- (OFString*)description
{
OFMutableString *ret;
OFAutoreleasePool *pool, *pool2;
|
︙ | | | ︙ | |
Modified src/OFCountedSet_hashtable.m
from [18146f1db1]
to [b90b5a288c].
︙ | | | ︙ | |
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
|
OFArray *objects;
OFEnumerator *enumerator;
OFXMLElement *objectElement;
if (![[element name] isEqual: @"OFCountedSet"] ||
![[element namespace] isEqual: OF_SERIALIZATION_NS])
@throw [OFInvalidArgumentException
exceptionWithClass: isa
selector: _cmd];
objects = [element elementsForName: @"object"
namespace: OF_SERIALIZATION_NS];
enumerator = [objects objectEnumerator];
pool2 = [[OFAutoreleasePool alloc] init];
while ((objectElement = [enumerator nextObject]) != nil) {
OFXMLElement *object;
OFXMLAttribute *count;
OFNumber *number;
object = [[objectElement elementsForNamespace:
OF_SERIALIZATION_NS] firstObject];
count = [objectElement attributeForName: @"count"];
if (object == nil || count == nil)
@throw [OFInvalidFormatException
exceptionWithClass: isa];
number = [OFNumber numberWithSize:
(size_t)[[count stringValue] decimalValue]];
[dictionary _setObject: number
forKey: [object objectByDeserializing]
copyKey: NO];
|
|
|
|
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
|
OFArray *objects;
OFEnumerator *enumerator;
OFXMLElement *objectElement;
if (![[element name] isEqual: @"OFCountedSet"] ||
![[element namespace] isEqual: OF_SERIALIZATION_NS])
@throw [OFInvalidArgumentException
exceptionWithClass: [self class]
selector: _cmd];
objects = [element elementsForName: @"object"
namespace: OF_SERIALIZATION_NS];
enumerator = [objects objectEnumerator];
pool2 = [[OFAutoreleasePool alloc] init];
while ((objectElement = [enumerator nextObject]) != nil) {
OFXMLElement *object;
OFXMLAttribute *count;
OFNumber *number;
object = [[objectElement elementsForNamespace:
OF_SERIALIZATION_NS] firstObject];
count = [objectElement attributeForName: @"count"];
if (object == nil || count == nil)
@throw [OFInvalidFormatException
exceptionWithClass: [self class]];
number = [OFNumber numberWithSize:
(size_t)[[count stringValue] decimalValue]];
[dictionary _setObject: number
forKey: [object objectByDeserializing]
copyKey: NO];
|
︙ | | | ︙ | |
Modified src/OFDataArray.m
from [a3f3ece2b2]
to [3687781c21].
︙ | | | ︙ | |
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
}
- initWithItemSize: (size_t)itemSize_
{
self = [super init];
if (itemSize_ == 0) {
Class c = isa;
[self release];
@throw [OFInvalidArgumentException exceptionWithClass: c
selector: _cmd];
}
itemSize = itemSize_;
|
|
|
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
}
- initWithItemSize: (size_t)itemSize_
{
self = [super init];
if (itemSize_ == 0) {
Class c = [self class];
[self release];
@throw [OFInvalidArgumentException exceptionWithClass: c
selector: _cmd];
}
itemSize = itemSize_;
|
︙ | | | ︙ | |
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
|
- initWithContentsOfURL: (OFURL*)URL
{
OFAutoreleasePool *pool;
OFHTTPRequest *request;
OFHTTPRequestResult *result;
Class c;
c = isa;
[self release];
pool = [[OFAutoreleasePool alloc] init];
if ([[URL scheme] isEqual: @"file"]) {
self = [[c alloc] initWithContentsOfFile: [URL path]];
[pool release];
|
|
|
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
|
- initWithContentsOfURL: (OFURL*)URL
{
OFAutoreleasePool *pool;
OFHTTPRequest *request;
OFHTTPRequestResult *result;
Class c;
c = [self class];
[self release];
pool = [[OFAutoreleasePool alloc] init];
if ([[URL scheme] isEqual: @"file"]) {
self = [[c alloc] initWithContentsOfFile: [URL path]];
[pool release];
|
︙ | | | ︙ | |
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
200
201
202
203
204
205
206
207
208
209
210
211
|
self = [super init];
itemSize = 1;
if (!of_base64_decode(self,
[string cStringWithEncoding: OF_STRING_ENCODING_ASCII],
[string cStringLengthWithEncoding: OF_STRING_ENCODING_ASCII])) {
Class c = isa;
[self release];
@throw [OFInvalidEncodingException exceptionWithClass: c];
}
return self;
}
- initWithSerialization: (OFXMLElement*)element
{
self = [super init];
itemSize = 1;
@try {
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
OFString *stringValue;
if (![[element name] isEqual: [self className]] ||
![[element namespace] isEqual: OF_SERIALIZATION_NS])
@throw [OFInvalidArgumentException
exceptionWithClass: isa
selector: _cmd];
stringValue = [element stringValue];
if (!of_base64_decode(self,
[stringValue cStringWithEncoding: OF_STRING_ENCODING_ASCII],
[stringValue cStringLengthWithEncoding:
OF_STRING_ENCODING_ASCII]))
@throw [OFInvalidEncodingException
exceptionWithClass: isa];
[pool release];
} @catch (id e) {
[self release];
@throw e;
}
|
|
|
|
|
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
200
201
202
203
204
205
206
207
208
209
210
211
|
self = [super init];
itemSize = 1;
if (!of_base64_decode(self,
[string cStringWithEncoding: OF_STRING_ENCODING_ASCII],
[string cStringLengthWithEncoding: OF_STRING_ENCODING_ASCII])) {
Class c = [self class];
[self release];
@throw [OFInvalidEncodingException exceptionWithClass: c];
}
return self;
}
- initWithSerialization: (OFXMLElement*)element
{
self = [super init];
itemSize = 1;
@try {
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
OFString *stringValue;
if (![[element name] isEqual: [self className]] ||
![[element namespace] isEqual: OF_SERIALIZATION_NS])
@throw [OFInvalidArgumentException
exceptionWithClass: [self class]
selector: _cmd];
stringValue = [element stringValue];
if (!of_base64_decode(self,
[stringValue cStringWithEncoding: OF_STRING_ENCODING_ASCII],
[stringValue cStringLengthWithEncoding:
OF_STRING_ENCODING_ASCII]))
@throw [OFInvalidEncodingException
exceptionWithClass: [self class]];
[pool release];
} @catch (id e) {
[self release];
@throw e;
}
|
︙ | | | ︙ | |
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
|
{
return data;
}
- (void*)itemAtIndex: (size_t)index
{
if (index >= count)
@throw [OFOutOfRangeException exceptionWithClass: isa];
return data + index * itemSize;
}
- (void*)firstItem
{
if (data == NULL || count == 0)
|
|
|
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
|
{
return data;
}
- (void*)itemAtIndex: (size_t)index
{
if (index >= count)
@throw [OFOutOfRangeException exceptionWithClass: [self class]];
return data + index * itemSize;
}
- (void*)firstItem
{
if (data == NULL || count == 0)
|
︙ | | | ︙ | |
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
|
return data + (count - 1) * itemSize;
}
- (void)addItem: (const void*)item
{
if (SIZE_MAX - count < 1)
@throw [OFOutOfRangeException exceptionWithClass: isa];
data = [self resizeMemory: data
size: itemSize
count: count + 1];
memcpy(data + count * itemSize, item, itemSize);
|
|
|
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
|
return data + (count - 1) * itemSize;
}
- (void)addItem: (const void*)item
{
if (SIZE_MAX - count < 1)
@throw [OFOutOfRangeException exceptionWithClass: [self class]];
data = [self resizeMemory: data
size: itemSize
count: count + 1];
memcpy(data + count * itemSize, item, itemSize);
|
︙ | | | ︙ | |
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
335
336
337
338
339
340
341
342
|
count: 1];
}
- (void)addItemsFromCArray: (const void*)cArray
count: (size_t)nItems
{
if (nItems > SIZE_MAX - count)
@throw [OFOutOfRangeException exceptionWithClass: isa];
data = [self resizeMemory: data
size: itemSize
count: count + nItems];
memcpy(data + count * itemSize, cArray, nItems * itemSize);
count += nItems;
}
- (void)insertItemsFromCArray: (const void*)cArray
atIndex: (size_t)index
count: (size_t)nItems
{
if (nItems > SIZE_MAX - count || index > count)
@throw [OFOutOfRangeException exceptionWithClass: isa];
data = [self resizeMemory: data
size: itemSize
count: count + nItems];
memmove(data + (index + nItems) * itemSize, data + index * itemSize,
(count - index) * itemSize);
memcpy(data + index * itemSize, cArray, nItems * itemSize);
count += nItems;
}
- (void)removeItemAtIndex: (size_t)index
{
[self removeItemsInRange: of_range(index, 1)];
}
- (void)removeItemsInRange: (of_range_t)range
{
if (range.start + range.length > count)
@throw [OFOutOfRangeException exceptionWithClass: isa];
memmove(data + range.start * itemSize,
data + (range.start + range.length) * itemSize,
(count - range.start - range.length) * itemSize);
count -= range.length;
@try {
data = [self resizeMemory: data
size: itemSize
count: count];
} @catch (OFOutOfMemoryException *e) {
/* We don't really care, as we only made it smaller */
}
}
- (void)removeLastItem
{
if (count < 1)
@throw [OFOutOfRangeException exceptionWithClass: isa];
count--;
@try {
data = [self resizeMemory: data
size: itemSize
count: count];
} @catch (OFOutOfMemoryException *e) {
|
|
|
|
|
|
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
335
336
337
338
339
340
341
342
|
count: 1];
}
- (void)addItemsFromCArray: (const void*)cArray
count: (size_t)nItems
{
if (nItems > SIZE_MAX - count)
@throw [OFOutOfRangeException exceptionWithClass: [self class]];
data = [self resizeMemory: data
size: itemSize
count: count + nItems];
memcpy(data + count * itemSize, cArray, nItems * itemSize);
count += nItems;
}
- (void)insertItemsFromCArray: (const void*)cArray
atIndex: (size_t)index
count: (size_t)nItems
{
if (nItems > SIZE_MAX - count || index > count)
@throw [OFOutOfRangeException exceptionWithClass: [self class]];
data = [self resizeMemory: data
size: itemSize
count: count + nItems];
memmove(data + (index + nItems) * itemSize, data + index * itemSize,
(count - index) * itemSize);
memcpy(data + index * itemSize, cArray, nItems * itemSize);
count += nItems;
}
- (void)removeItemAtIndex: (size_t)index
{
[self removeItemsInRange: of_range(index, 1)];
}
- (void)removeItemsInRange: (of_range_t)range
{
if (range.start + range.length > count)
@throw [OFOutOfRangeException exceptionWithClass: [self class]];
memmove(data + range.start * itemSize,
data + (range.start + range.length) * itemSize,
(count - range.start - range.length) * itemSize);
count -= range.length;
@try {
data = [self resizeMemory: data
size: itemSize
count: count];
} @catch (OFOutOfMemoryException *e) {
/* We don't really care, as we only made it smaller */
}
}
- (void)removeLastItem
{
if (count < 1)
@throw [OFOutOfRangeException exceptionWithClass: [self class]];
count--;
@try {
data = [self resizeMemory: data
size: itemSize
count: count];
} @catch (OFOutOfMemoryException *e) {
|
︙ | | | ︙ | |
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
|
data = NULL;
count = 0;
}
- copy
{
OFDataArray *copy = [[isa alloc] initWithItemSize: itemSize];
[copy addItemsFromCArray: data
count: count];
return copy;
}
|
|
|
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
|
data = NULL;
count = 0;
}
- copy
{
OFDataArray *copy = [[[self class] alloc] initWithItemSize: itemSize];
[copy addItemsFromCArray: data
count: count];
return copy;
}
|
︙ | | | ︙ | |
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
|
- (of_comparison_result_t)compare: (id)object
{
OFDataArray *otherDataArray;
int comparison;
size_t otherCount, minimumCount;
if (![object isKindOfClass: [OFDataArray class]])
@throw [OFInvalidArgumentException exceptionWithClass: isa
selector: _cmd];
otherDataArray = object;
if ([otherDataArray itemSize] != itemSize)
@throw [OFInvalidArgumentException exceptionWithClass: isa
selector: _cmd];
otherCount = [otherDataArray count];
minimumCount = (count > otherCount ? otherCount : count);
if ((comparison = memcmp(data, [otherDataArray cArray],
minimumCount * itemSize)) == 0) {
|
|
>
|
>
|
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
|
- (of_comparison_result_t)compare: (id)object
{
OFDataArray *otherDataArray;
int comparison;
size_t otherCount, minimumCount;
if (![object isKindOfClass: [OFDataArray class]])
@throw [OFInvalidArgumentException
exceptionWithClass: [self class]
selector: _cmd];
otherDataArray = object;
if ([otherDataArray itemSize] != itemSize)
@throw [OFInvalidArgumentException
exceptionWithClass: [self class]
selector: _cmd];
otherCount = [otherDataArray count];
minimumCount = (count > otherCount ? otherCount : count);
if ((comparison = memcmp(data, [otherDataArray cArray],
minimumCount * itemSize)) == 0) {
|
︙ | | | ︙ | |
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
|
- (OFXMLElement*)XMLElementBySerializing
{
OFAutoreleasePool *pool;
OFXMLElement *element;
if (itemSize != 1)
@throw [OFNotImplementedException exceptionWithClass: isa
selector: _cmd];
pool = [[OFAutoreleasePool alloc] init];
element = [OFXMLElement
elementWithName: [self className]
namespace: OF_SERIALIZATION_NS
stringValue: of_base64_encode(data, count * itemSize)];
|
|
>
|
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
|
- (OFXMLElement*)XMLElementBySerializing
{
OFAutoreleasePool *pool;
OFXMLElement *element;
if (itemSize != 1)
@throw [OFNotImplementedException
exceptionWithClass: [self class]
selector: _cmd];
pool = [[OFAutoreleasePool alloc] init];
element = [OFXMLElement
elementWithName: [self className]
namespace: OF_SERIALIZATION_NS
stringValue: of_base64_encode(data, count * itemSize)];
|
︙ | | | ︙ | |
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
495
496
497
498
499
500
501
502
503
504
|
@implementation OFBigDataArray
- (void)addItem: (const void*)item
{
size_t newSize, lastPageByte;
if (SIZE_MAX - count < 1 || count + 1 > SIZE_MAX / itemSize)
@throw [OFOutOfRangeException exceptionWithClass: isa];
lastPageByte = of_pagesize - 1;
newSize = ((count + 1) * itemSize + lastPageByte) & ~lastPageByte;
if (size != newSize)
data = [self resizeMemory: data
size: newSize];
memcpy(data + count * itemSize, item, itemSize);
count++;
size = newSize;
}
- (void)addItemsFromCArray: (const void*)cArray
count: (size_t)nItems
{
size_t newSize, lastPageByte;
if (nItems > SIZE_MAX - count || count + nItems > SIZE_MAX / itemSize)
@throw [OFOutOfRangeException exceptionWithClass: isa];
lastPageByte = of_pagesize - 1;
newSize = ((count + nItems) * itemSize + lastPageByte) & ~lastPageByte;
if (size != newSize)
data = [self resizeMemory: data
size: newSize];
|
|
|
|
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
|
@implementation OFBigDataArray
- (void)addItem: (const void*)item
{
size_t newSize, lastPageByte;
if (SIZE_MAX - count < 1 || count + 1 > SIZE_MAX / itemSize)
@throw [OFOutOfRangeException exceptionWithClass: [self class]];
lastPageByte = of_pagesize - 1;
newSize = ((count + 1) * itemSize + lastPageByte) & ~lastPageByte;
if (size != newSize)
data = [self resizeMemory: data
size: newSize];
memcpy(data + count * itemSize, item, itemSize);
count++;
size = newSize;
}
- (void)addItemsFromCArray: (const void*)cArray
count: (size_t)nItems
{
size_t newSize, lastPageByte;
if (nItems > SIZE_MAX - count || count + nItems > SIZE_MAX / itemSize)
@throw [OFOutOfRangeException exceptionWithClass: [self class]];
lastPageByte = of_pagesize - 1;
newSize = ((count + nItems) * itemSize + lastPageByte) & ~lastPageByte;
if (size != newSize)
data = [self resizeMemory: data
size: newSize];
|
︙ | | | ︙ | |
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
|
atIndex: (size_t)index
count: (size_t)nItems
{
size_t newSize, lastPageByte;
if (nItems > SIZE_MAX - count || index > count ||
count + nItems > SIZE_MAX / itemSize)
@throw [OFOutOfRangeException exceptionWithClass: isa];
lastPageByte = of_pagesize - 1;
newSize = ((count + nItems) * itemSize + lastPageByte) & ~lastPageByte;
if (size != newSize)
data = [self resizeMemory: data
size: newSize];
|
|
|
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
|
atIndex: (size_t)index
count: (size_t)nItems
{
size_t newSize, lastPageByte;
if (nItems > SIZE_MAX - count || index > count ||
count + nItems > SIZE_MAX / itemSize)
@throw [OFOutOfRangeException exceptionWithClass: [self class]];
lastPageByte = of_pagesize - 1;
newSize = ((count + nItems) * itemSize + lastPageByte) & ~lastPageByte;
if (size != newSize)
data = [self resizeMemory: data
size: newSize];
|
︙ | | | ︙ | |
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
567
568
569
570
|
}
- (void)removeItemsInRange: (of_range_t)range
{
size_t newSize, lastPageByte;
if (range.start + range.length > count)
@throw [OFOutOfRangeException exceptionWithClass: isa];
memmove(data + range.start * itemSize,
data + (range.start + range.length) * itemSize,
(count - range.start - range.length) * itemSize);
count -= range.length;
lastPageByte = of_pagesize - 1;
newSize = (count * itemSize + lastPageByte) & ~lastPageByte;
if (size != newSize)
data = [self resizeMemory: data
size: newSize];
size = newSize;
}
- (void)removeLastItem
{
size_t newSize, lastPageByte;
if (count < 1)
@throw [OFOutOfRangeException exceptionWithClass: isa];
count--;
lastPageByte = of_pagesize - 1;
newSize = (count * itemSize + lastPageByte) & ~lastPageByte;
if (size != newSize) {
@try {
|
|
|
|
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
567
568
569
570
571
572
573
|
}
- (void)removeItemsInRange: (of_range_t)range
{
size_t newSize, lastPageByte;
if (range.start + range.length > count)
@throw [OFOutOfRangeException exceptionWithClass: [self class]];
memmove(data + range.start * itemSize,
data + (range.start + range.length) * itemSize,
(count - range.start - range.length) * itemSize);
count -= range.length;
lastPageByte = of_pagesize - 1;
newSize = (count * itemSize + lastPageByte) & ~lastPageByte;
if (size != newSize)
data = [self resizeMemory: data
size: newSize];
size = newSize;
}
- (void)removeLastItem
{
size_t newSize, lastPageByte;
if (count < 1)
@throw [OFOutOfRangeException exceptionWithClass: [self class]];
count--;
lastPageByte = of_pagesize - 1;
newSize = (count * itemSize + lastPageByte) & ~lastPageByte;
if (size != newSize) {
@try {
|
︙ | | | ︙ | |
Modified src/OFDate.m
from [eecbbd56be]
to [2b9c35d972].
︙ | | | ︙ | |
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
|
#ifdef HAVE_GMTIME_R
# define GMTIME_RET(field) \
time_t seconds_ = (time_t)seconds; \
struct tm tm; \
\
if (seconds_ != floor(seconds)) \
@throw [OFOutOfRangeException exceptionWithClass: isa]; \
\
if (gmtime_r(&seconds_, &tm) == NULL) \
@throw [OFOutOfRangeException exceptionWithClass: isa]; \
\
return tm.field;
# define LOCALTIME_RET(field) \
time_t seconds_ = (time_t)seconds; \
struct tm tm; \
\
if (seconds_ != floor(seconds)) \
@throw [OFOutOfRangeException exceptionWithClass: isa]; \
\
if (localtime_r(&seconds_, &tm) == NULL) \
@throw [OFOutOfRangeException exceptionWithClass: isa]; \
\
return tm.field;
#else
# ifdef OF_THREADS
# define GMTIME_RET(field) \
time_t seconds_ = (time_t)seconds; \
struct tm *tm; \
\
if (seconds_ != floor(seconds)) \
@throw [OFOutOfRangeException exceptionWithClass: isa]; \
\
[mutex lock]; \
\
@try { \
if ((tm = gmtime(&seconds_)) == NULL) \
@throw [OFOutOfRangeException \
exceptionWithClass: isa]; \
\
return tm->field; \
} @finally { \
[mutex unlock]; \
}
# define LOCALTIME_RET(field) \
time_t seconds_ = (time_t)seconds; \
struct tm *tm; \
\
if (seconds_ != floor(seconds)) \
@throw [OFOutOfRangeException exceptionWithClass: isa]; \
\
[mutex lock]; \
\
@try { \
if ((tm = localtime(&seconds_)) == NULL) \
@throw [OFOutOfRangeException \
exceptionWithClass: isa]; \
\
return tm->field; \
} @finally { \
[mutex unlock]; \
}
# else
# define GMTIME_RET(field) \
time_t seconds_ = (time_t)seconds; \
struct tm *tm; \
\
if (seconds_ != floor(seconds)) \
@throw [OFOutOfRangeException exceptionWithClass: isa]; \
\
if ((tm = gmtime(&seconds_)) == NULL) \
@throw [OFOutOfRangeException exceptionWithClass: isa]; \
\
return tm->field;
# define LOCALTIME_RET(field) \
time_t seconds_ = (time_t)seconds; \
struct tm *tm; \
\
if (seconds_ != floor(seconds)) \
@throw [OFOutOfRangeException exceptionWithClass: isa]; \
\
if ((tm = localtime(&seconds_)) == NULL) \
@throw [OFOutOfRangeException exceptionWithClass: isa]; \
\
return tm->field;
# endif
#endif
static int month_to_day_of_year[12] = {
0,
|
|
>
|
>
|
>
|
>
|
>
|
|
>
|
|
>
|
>
|
>
|
>
|
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
|
#ifdef HAVE_GMTIME_R
# define GMTIME_RET(field) \
time_t seconds_ = (time_t)seconds; \
struct tm tm; \
\
if (seconds_ != floor(seconds)) \
@throw [OFOutOfRangeException \
exceptionWithClass: [self class]]; \
\
if (gmtime_r(&seconds_, &tm) == NULL) \
@throw [OFOutOfRangeException \
exceptionWithClass: [self class]]; \
\
return tm.field;
# define LOCALTIME_RET(field) \
time_t seconds_ = (time_t)seconds; \
struct tm tm; \
\
if (seconds_ != floor(seconds)) \
@throw [OFOutOfRangeException \
exceptionWithClass: [self class]]; \
\
if (localtime_r(&seconds_, &tm) == NULL) \
@throw [OFOutOfRangeException \
exceptionWithClass: [self class]]; \
\
return tm.field;
#else
# ifdef OF_THREADS
# define GMTIME_RET(field) \
time_t seconds_ = (time_t)seconds; \
struct tm *tm; \
\
if (seconds_ != floor(seconds)) \
@throw [OFOutOfRangeException \
exceptionWithClass: [self class]]; \
\
[mutex lock]; \
\
@try { \
if ((tm = gmtime(&seconds_)) == NULL) \
@throw [OFOutOfRangeException \
exceptionWithClass: [self class]]; \
\
return tm->field; \
} @finally { \
[mutex unlock]; \
}
# define LOCALTIME_RET(field) \
time_t seconds_ = (time_t)seconds; \
struct tm *tm; \
\
if (seconds_ != floor(seconds)) \
@throw [OFOutOfRangeException \
exceptionWithClass: [self class]]; \
\
[mutex lock]; \
\
@try { \
if ((tm = localtime(&seconds_)) == NULL) \
@throw [OFOutOfRangeException \
exceptionWithClass: [self class]]; \
\
return tm->field; \
} @finally { \
[mutex unlock]; \
}
# else
# define GMTIME_RET(field) \
time_t seconds_ = (time_t)seconds; \
struct tm *tm; \
\
if (seconds_ != floor(seconds)) \
@throw [OFOutOfRangeException \
exceptionWithClass: [self class]]; \
\
if ((tm = gmtime(&seconds_)) == NULL) \
@throw [OFOutOfRangeException \
exceptionWithClass: [self class]]; \
\
return tm->field;
# define LOCALTIME_RET(field) \
time_t seconds_ = (time_t)seconds; \
struct tm *tm; \
\
if (seconds_ != floor(seconds)) \
@throw [OFOutOfRangeException \
exceptionWithClass: [self class]]; \
\
if ((tm = localtime(&seconds_)) == NULL) \
@throw [OFOutOfRangeException \
exceptionWithClass: [self class]]; \
\
return tm->field;
# endif
#endif
static int month_to_day_of_year[12] = {
0,
|
︙ | | | ︙ | |
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
|
struct tm tm = {};
tm.tm_isdst = -1;
if (of_strptime([string UTF8String], [format UTF8String],
&tm) == NULL)
@throw [OFInvalidFormatException
exceptionWithClass: isa];
/* Years */
seconds = (int64_t)(tm.tm_year - 70) * 31536000;
/* Days of leap years, excluding the year to look at */
seconds += (((tm.tm_year + 1899) / 4) - 492) * 86400;
seconds -= (((tm.tm_year + 1899) / 100) - 19) * 86400;
seconds += (((tm.tm_year + 1899) / 400) - 4) * 86400;
/* Leap day */
if (tm.tm_mon >= 2 && (((tm.tm_year + 1900) % 4 == 0 &&
(tm.tm_year + 1900) % 100 != 0) ||
(tm.tm_year + 1900) % 400 == 0))
seconds += 86400;
/* Months */
if (tm.tm_mon < 0 || tm.tm_mon > 12)
@throw [OFInvalidFormatException
exceptionWithClass: isa];
seconds += month_to_day_of_year[tm.tm_mon] * 86400;
/* Days */
seconds += (tm.tm_mday - 1) * 86400;
/* Hours */
seconds += tm.tm_hour * 3600;
/* Minutes */
seconds += tm.tm_min * 60;
|
|
|
|
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
|
struct tm tm = {};
tm.tm_isdst = -1;
if (of_strptime([string UTF8String], [format UTF8String],
&tm) == NULL)
@throw [OFInvalidFormatException
exceptionWithClass: [self class]];
/* Years */
seconds = (int64_t)(tm.tm_year - 70) * 31536000;
/* Days of leap years, excluding the year to look at */
seconds += (((tm.tm_year + 1899) / 4) - 492) * 86400;
seconds -= (((tm.tm_year + 1899) / 100) - 19) * 86400;
seconds += (((tm.tm_year + 1899) / 400) - 4) * 86400;
/* Leap day */
if (tm.tm_mon >= 2 && (((tm.tm_year + 1900) % 4 == 0 &&
(tm.tm_year + 1900) % 100 != 0) ||
(tm.tm_year + 1900) % 400 == 0))
seconds += 86400;
/* Months */
if (tm.tm_mon < 0 || tm.tm_mon > 12)
@throw [OFInvalidFormatException
exceptionWithClass: [self class]];
seconds += month_to_day_of_year[tm.tm_mon] * 86400;
/* Days */
seconds += (tm.tm_mday - 1) * 86400;
/* Hours */
seconds += tm.tm_hour * 3600;
/* Minutes */
seconds += tm.tm_min * 60;
|
︙ | | | ︙ | |
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
|
struct tm tm = {};
tm.tm_isdst = -1;
if (of_strptime([string UTF8String], [format UTF8String],
&tm) == NULL)
@throw [OFInvalidFormatException
exceptionWithClass: isa];
if ((seconds = mktime(&tm)) == -1)
@throw [OFInvalidFormatException
exceptionWithClass: isa];
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
- initWithSerialization: (OFXMLElement*)element
{
self = [super init];
@try {
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
if (![[element name] isEqual: [self className]] ||
![[element namespace] isEqual: OF_SERIALIZATION_NS])
@throw [OFInvalidArgumentException
exceptionWithClass: isa
selector: _cmd];
seconds = [element doubleValue];
[pool release];
} @catch (id e) {
[self release];
|
|
|
|
|
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
335
336
337
338
|
struct tm tm = {};
tm.tm_isdst = -1;
if (of_strptime([string UTF8String], [format UTF8String],
&tm) == NULL)
@throw [OFInvalidFormatException
exceptionWithClass: [self class]];
if ((seconds = mktime(&tm)) == -1)
@throw [OFInvalidFormatException
exceptionWithClass: [self class]];
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
- initWithSerialization: (OFXMLElement*)element
{
self = [super init];
@try {
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
if (![[element name] isEqual: [self className]] ||
![[element namespace] isEqual: OF_SERIALIZATION_NS])
@throw [OFInvalidArgumentException
exceptionWithClass: [self class]
selector: _cmd];
seconds = [element doubleValue];
[pool release];
} @catch (id e) {
[self release];
|
︙ | | | ︙ | |
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
|
}
- (of_comparison_result_t)compare: (id)object
{
OFDate *otherDate;
if (![object isKindOfClass: [OFDate class]])
@throw [OFInvalidArgumentException exceptionWithClass: isa
selector: _cmd];
otherDate = object;
if (seconds < otherDate->seconds)
return OF_ORDERED_ASCENDING;
if (seconds > otherDate->seconds)
|
|
>
|
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
|
}
- (of_comparison_result_t)compare: (id)object
{
OFDate *otherDate;
if (![object isKindOfClass: [OFDate class]])
@throw [OFInvalidArgumentException
exceptionWithClass: [self class]
selector: _cmd];
otherDate = object;
if (seconds < otherDate->seconds)
return OF_ORDERED_ASCENDING;
if (seconds > otherDate->seconds)
|
︙ | | | ︙ | |
491
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
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
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
|
{
OFString *ret;
time_t seconds_ = (time_t)seconds;
struct tm tm;
char *buffer;
if (seconds_ != floor(seconds))
@throw [OFOutOfRangeException exceptionWithClass: isa];
#ifdef HAVE_GMTIME_R
if (gmtime_r(&seconds_, &tm) == NULL)
@throw [OFOutOfRangeException exceptionWithClass: isa];
#else
# ifdef OF_THREADS
[mutex lock];
@try {
# endif
struct tm *tmp;
if ((tmp = gmtime(&seconds_)) == NULL)
@throw [OFOutOfRangeException exceptionWithClass: isa];
tm = *tmp;
# ifdef OF_THREADS
} @finally {
[mutex unlock];
}
# endif
#endif
buffer = [self allocMemoryWithSize: of_pagesize];
@try {
if (!strftime(buffer, of_pagesize, [format UTF8String], &tm))
@throw [OFOutOfRangeException exceptionWithClass: isa];
ret = [OFString stringWithUTF8String: buffer];
} @finally {
[self freeMemory: buffer];
}
return ret;
}
- (OFString*)localDateStringWithFormat: (OFConstantString*)format
{
OFString *ret;
time_t seconds_ = (time_t)seconds;
struct tm tm;
char *buffer;
if (seconds_ != floor(seconds))
@throw [OFOutOfRangeException exceptionWithClass: isa];
#ifdef HAVE_LOCALTIME_R
if (localtime_r(&seconds_, &tm) == NULL)
@throw [OFOutOfRangeException exceptionWithClass: isa];
#else
# ifdef OF_THREADS
[mutex lock];
@try {
# endif
struct tm *tmp;
if ((tmp = localtime(&seconds_)) == NULL)
@throw [OFOutOfRangeException exceptionWithClass: isa];
tm = *tmp;
# ifdef OF_THREADS
} @finally {
[mutex unlock];
}
# endif
#endif
buffer = [self allocMemoryWithSize: of_pagesize];
@try {
if (!strftime(buffer, of_pagesize, [format UTF8String], &tm))
@throw [OFOutOfRangeException exceptionWithClass: isa];
ret = [OFString stringWithUTF8String: buffer];
} @finally {
[self freeMemory: buffer];
}
return ret;
|
|
|
|
>
|
>
|
|
|
>
|
>
|
502
503
504
505
506
507
508
509
510
511
512
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
544
545
546
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
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
|
{
OFString *ret;
time_t seconds_ = (time_t)seconds;
struct tm tm;
char *buffer;
if (seconds_ != floor(seconds))
@throw [OFOutOfRangeException exceptionWithClass: [self class]];
#ifdef HAVE_GMTIME_R
if (gmtime_r(&seconds_, &tm) == NULL)
@throw [OFOutOfRangeException exceptionWithClass: [self class]];
#else
# ifdef OF_THREADS
[mutex lock];
@try {
# endif
struct tm *tmp;
if ((tmp = gmtime(&seconds_)) == NULL)
@throw [OFOutOfRangeException
exceptionWithClass: [self class]];
tm = *tmp;
# ifdef OF_THREADS
} @finally {
[mutex unlock];
}
# endif
#endif
buffer = [self allocMemoryWithSize: of_pagesize];
@try {
if (!strftime(buffer, of_pagesize, [format UTF8String], &tm))
@throw [OFOutOfRangeException
exceptionWithClass: [self class]];
ret = [OFString stringWithUTF8String: buffer];
} @finally {
[self freeMemory: buffer];
}
return ret;
}
- (OFString*)localDateStringWithFormat: (OFConstantString*)format
{
OFString *ret;
time_t seconds_ = (time_t)seconds;
struct tm tm;
char *buffer;
if (seconds_ != floor(seconds))
@throw [OFOutOfRangeException exceptionWithClass: [self class]];
#ifdef HAVE_LOCALTIME_R
if (localtime_r(&seconds_, &tm) == NULL)
@throw [OFOutOfRangeException exceptionWithClass: [self class]];
#else
# ifdef OF_THREADS
[mutex lock];
@try {
# endif
struct tm *tmp;
if ((tmp = localtime(&seconds_)) == NULL)
@throw [OFOutOfRangeException
exceptionWithClass: [self class]];
tm = *tmp;
# ifdef OF_THREADS
} @finally {
[mutex unlock];
}
# endif
#endif
buffer = [self allocMemoryWithSize: of_pagesize];
@try {
if (!strftime(buffer, of_pagesize, [format UTF8String], &tm))
@throw [OFOutOfRangeException
exceptionWithClass: [self class]];
ret = [OFString stringWithUTF8String: buffer];
} @finally {
[self freeMemory: buffer];
}
return ret;
|
︙ | | | ︙ | |
Modified src/OFDictionary.m
from [d6efe13c19]
to [4a522c344b].
︙ | | | ︙ | |
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
|
- (void)release
{
}
- (void)dealloc
{
@throw [OFNotImplementedException exceptionWithClass: isa
selector: _cmd];
[super dealloc]; /* Get rid of a stupid warning */
}
@end
@implementation OFDictionary
+ (void)initialize
{
if (self == [OFDictionary class])
placeholder.isa = [OFDictionary_placeholder class];
}
+ alloc
{
if (self == [OFDictionary class])
return (id)&placeholder;
|
|
>
|
|
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
|
- (void)release
{
}
- (void)dealloc
{
@throw [OFNotImplementedException exceptionWithClass: [self class]
selector: _cmd];
[super dealloc]; /* Get rid of a stupid warning */
}
@end
@implementation OFDictionary
+ (void)initialize
{
if (self == [OFDictionary class])
object_setClass((id)&placeholder,
[OFDictionary_placeholder class]);
}
+ alloc
{
if (self == [OFDictionary class])
return (id)&placeholder;
|
︙ | | | ︙ | |
176
177
178
179
180
181
182
183
184
185
186
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
|
va_end(arguments);
return ret;
}
- init
{
if (isa == [OFDictionary class]) {
Class c = isa;
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
return [super init];
}
- initWithDictionary: (OFDictionary*)dictionary
{
Class c = isa;
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
- initWithObject: (id)object
forKey: (id)key
{
return [self initWithKeysAndObjects: key, object, nil];
}
- initWithObjects: (OFArray*)objects
forKeys: (OFArray*)keys
{
Class c = isa;
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
- initWithObjects: (id const*)objects
forKeys: (id const*)keys
count: (size_t)count
{
Class c = isa;
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
- initWithKeysAndObjects: (id)firstKey, ...
{
|
|
|
|
|
|
|
177
178
179
180
181
182
183
184
185
186
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
|
va_end(arguments);
return ret;
}
- init
{
if (object_getClass(self) == [OFDictionary class]) {
Class c = [self class];
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
return [super init];
}
- initWithDictionary: (OFDictionary*)dictionary
{
Class c = [self class];
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
- initWithObject: (id)object
forKey: (id)key
{
return [self initWithKeysAndObjects: key, object, nil];
}
- initWithObjects: (OFArray*)objects
forKeys: (OFArray*)keys
{
Class c = [self class];
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
- initWithObjects: (id const*)objects
forKeys: (id const*)keys
count: (size_t)count
{
Class c = [self class];
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
- initWithKeysAndObjects: (id)firstKey, ...
{
|
︙ | | | ︙ | |
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
|
return ret;
}
- initWithKey: (id)firstKey
arguments: (va_list)arguments
{
Class c = isa;
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
- initWithSerialization: (OFXMLElement*)element
{
Class c = isa;
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
- (id)objectForKey: (id)key
{
@throw [OFNotImplementedException exceptionWithClass: isa
selector: _cmd];
}
- (id)objectForKeyedSubscript: (id)key
{
return [self objectForKey: key];
}
- (size_t)count
{
@throw [OFNotImplementedException exceptionWithClass: isa
selector: _cmd];
}
- copy
{
return [self retain];
}
|
|
|
|
|
|
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
|
return ret;
}
- initWithKey: (id)firstKey
arguments: (va_list)arguments
{
Class c = [self class];
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
- initWithSerialization: (OFXMLElement*)element
{
Class c = [self class];
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
- (id)objectForKey: (id)key
{
@throw [OFNotImplementedException exceptionWithClass: [self class]
selector: _cmd];
}
- (id)objectForKeyedSubscript: (id)key
{
return [self objectForKey: key];
}
- (size_t)count
{
@throw [OFNotImplementedException exceptionWithClass: [self class]
selector: _cmd];
}
- copy
{
return [self retain];
}
|
︙ | | | ︙ | |
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
|
}
return ret;
}
- (OFEnumerator*)objectEnumerator
{
@throw [OFNotImplementedException exceptionWithClass: isa
selector: _cmd];
}
- (OFEnumerator*)keyEnumerator
{
@throw [OFNotImplementedException exceptionWithClass: isa
selector: _cmd];
}
- (int)countByEnumeratingWithState: (of_fast_enumeration_state_t*)state
objects: (id*)objects
count: (int)count_
{
@throw [OFNotImplementedException exceptionWithClass: isa
selector: _cmd];
}
#if defined(OF_HAVE_BLOCKS) && defined(OF_HAVE_FAST_ENUMERATION)
- (void)enumerateKeysAndObjectsUsingBlock:
(of_dictionary_enumeration_block_t)block
{
|
|
|
|
|
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
|
}
return ret;
}
- (OFEnumerator*)objectEnumerator
{
@throw [OFNotImplementedException exceptionWithClass: [self class]
selector: _cmd];
}
- (OFEnumerator*)keyEnumerator
{
@throw [OFNotImplementedException exceptionWithClass: [self class]
selector: _cmd];
}
- (int)countByEnumeratingWithState: (of_fast_enumeration_state_t*)state
objects: (id*)objects
count: (int)count_
{
@throw [OFNotImplementedException exceptionWithClass: [self class]
selector: _cmd];
}
#if defined(OF_HAVE_BLOCKS) && defined(OF_HAVE_FAST_ENUMERATION)
- (void)enumerateKeysAndObjectsUsingBlock:
(of_dictionary_enumeration_block_t)block
{
|
︙ | | | ︙ | |
Modified src/OFDictionary_hashtable.m
from [81e5d7fd45]
to [64cc71dd61].
︙ | | | ︙ | |
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
@try {
uint32_t i;
OFDictionary_hashtable *hashtable;
if (dictionary == nil)
@throw [OFInvalidArgumentException
exceptionWithClass: isa
selector: _cmd];
if (![dictionary isKindOfClass:
[OFDictionary_hashtable class]] &&
![dictionary isKindOfClass:
[OFMutableDictionary_hashtable class]])
@throw [OFInvalidArgumentException
exceptionWithClass: isa
selector: _cmd];
hashtable = (OFDictionary_hashtable*)dictionary;
data = [self allocMemoryWithSize: sizeof(*data)
count: hashtable->size];
|
|
|
|
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
@try {
uint32_t i;
OFDictionary_hashtable *hashtable;
if (dictionary == nil)
@throw [OFInvalidArgumentException
exceptionWithClass: [self class]
selector: _cmd];
if (![dictionary isKindOfClass:
[OFDictionary_hashtable class]] &&
![dictionary isKindOfClass:
[OFMutableDictionary_hashtable class]])
@throw [OFInvalidArgumentException
exceptionWithClass: [self class]
selector: _cmd];
hashtable = (OFDictionary_hashtable*)dictionary;
data = [self allocMemoryWithSize: sizeof(*data)
count: hashtable->size];
|
︙ | | | ︙ | |
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
|
OFEnumerator *enumerator;
id key;
uint32_t i, newSize;
count = [dictionary count];
if (count > UINT32_MAX)
@throw [OFOutOfRangeException exceptionWithClass: isa];
for (newSize = 1; newSize < count; newSize <<= 1);
if (count * 4 / newSize >= 3)
newSize <<= 1;
if (newSize == 0)
@throw [OFOutOfRangeException exceptionWithClass: isa];
data = [self allocMemoryWithSize: sizeof(*data)
count: newSize];
for (i = 0; i < newSize; i++)
data[i] = NULL;
|
|
>
|
>
|
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
|
OFEnumerator *enumerator;
id key;
uint32_t i, newSize;
count = [dictionary count];
if (count > UINT32_MAX)
@throw [OFOutOfRangeException
exceptionWithClass: [self class]];
for (newSize = 1; newSize < count; newSize <<= 1);
if (count * 4 / newSize >= 3)
newSize <<= 1;
if (newSize == 0)
@throw [OFOutOfRangeException
exceptionWithClass: [self class]];
data = [self allocMemoryWithSize: sizeof(*data)
count: newSize];
for (i = 0; i < newSize; i++)
data[i] = NULL;
|
︙ | | | ︙ | |
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
|
last = hash & (size - 1);
for (i = 0; i < last && data[i] != NULL; i++);
}
if (data[i] != NULL)
@throw [OFOutOfRangeException
exceptionWithClass: isa];
bucket = [self allocMemoryWithSize: sizeof(*bucket)];
object = [dictionary objectForKey: key];
bucket->key = [key copy];
bucket->object = [object retain];
|
|
|
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
|
last = hash & (size - 1);
for (i = 0; i < last && data[i] != NULL; i++);
}
if (data[i] != NULL)
@throw [OFOutOfRangeException
exceptionWithClass: [self class]];
bucket = [self allocMemoryWithSize: sizeof(*bucket)];
object = [dictionary objectForKey: key];
bucket->key = [key copy];
bucket->object = [object retain];
|
︙ | | | ︙ | |
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
|
@try {
uint32_t i;
struct of_dictionary_hashtable_bucket *bucket;
if (key == nil || object == nil)
@throw [OFInvalidArgumentException
exceptionWithClass: isa
selector: _cmd];
data = [self allocMemoryWithSize: sizeof(*data)
count: 2];
size = 2;
for (i = 0; i < size; i++)
|
|
|
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
|
@try {
uint32_t i;
struct of_dictionary_hashtable_bucket *bucket;
if (key == nil || object == nil)
@throw [OFInvalidArgumentException
exceptionWithClass: [self class]
selector: _cmd];
data = [self allocMemoryWithSize: sizeof(*data)
count: 2];
size = 2;
for (i = 0; i < size; i++)
|
︙ | | | ︙ | |
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
|
forKeys: (OFArray*)keys
{
id ret;
@try {
if ([objects count] != [keys count])
@throw [OFInvalidArgumentException
exceptionWithClass: isa];
ret = [self initWithObjects: [objects objects]
forKeys: [keys objects]
count: [objects count]];
} @catch (id e) {
[self release];
@throw e;
|
|
|
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
|
forKeys: (OFArray*)keys
{
id ret;
@try {
if ([objects count] != [keys count])
@throw [OFInvalidArgumentException
exceptionWithClass: [self class]];
ret = [self initWithObjects: [objects objects]
forKeys: [keys objects]
count: [objects count]];
} @catch (id e) {
[self release];
@throw e;
|
︙ | | | ︙ | |
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
|
@try {
uint32_t i, j, newSize;
count = count_;
if (count > UINT32_MAX)
@throw [OFOutOfRangeException exceptionWithClass: isa];
for (newSize = 1; newSize < count; newSize <<= 1);
if (count * 4 / newSize >= 3)
newSize <<= 1;
if (newSize == 0)
@throw [OFOutOfRangeException exceptionWithClass: isa];
data = [self allocMemoryWithSize: sizeof(*data)
count: newSize];
for (j = 0; j < newSize; j++)
data[j] = NULL;
|
|
>
|
>
|
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
|
@try {
uint32_t i, j, newSize;
count = count_;
if (count > UINT32_MAX)
@throw [OFOutOfRangeException
exceptionWithClass: [self class]];
for (newSize = 1; newSize < count; newSize <<= 1);
if (count * 4 / newSize >= 3)
newSize <<= 1;
if (newSize == 0)
@throw [OFOutOfRangeException
exceptionWithClass: [self class]];
data = [self allocMemoryWithSize: sizeof(*data)
count: newSize];
for (j = 0; j < newSize; j++)
data[j] = NULL;
|
︙ | | | ︙ | |
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
|
for (j = 0; j < last && data[j] != NULL;
j++);
}
if (j >= last)
@throw [OFOutOfRangeException
exceptionWithClass: isa];
bucket =
[self allocMemoryWithSize: sizeof(*bucket)];
key = [keys[i] copy];
bucket->key = key;
bucket->object = [objects[i] retain];
|
|
|
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
|
for (j = 0; j < last && data[j] != NULL;
j++);
}
if (j >= last)
@throw [OFOutOfRangeException
exceptionWithClass: [self class]];
bucket =
[self allocMemoryWithSize: sizeof(*bucket)];
key = [keys[i] copy];
bucket->key = key;
bucket->object = [objects[i] retain];
|
︙ | | | ︙ | |
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
|
va_list argumentsCopy;
struct of_dictionary_hashtable_bucket *bucket;
va_copy(argumentsCopy, arguments);
if (firstKey == nil)
@throw [OFInvalidArgumentException
exceptionWithClass: isa
selector: _cmd];
key = firstKey;
if ((object = va_arg(arguments, id)) == nil)
@throw [OFInvalidArgumentException
exceptionWithClass: isa
selector: _cmd];
count = 1;
for (; va_arg(argumentsCopy, id) != nil; count++);
count >>= 1;
if (count > UINT32_MAX)
@throw [OFOutOfRangeException exceptionWithClass: isa];
for (newSize = 1; newSize < count; newSize <<= 1);
if (count * 4 / newSize >= 3)
newSize <<= 1;
if (newSize == 0)
@throw [OFOutOfRangeException exceptionWithClass: isa];
data = [self allocMemoryWithSize: sizeof(*data)
count: newSize];
for (j = 0; j < newSize; j++)
data[j] = NULL;
|
|
|
|
>
|
>
|
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
|
va_list argumentsCopy;
struct of_dictionary_hashtable_bucket *bucket;
va_copy(argumentsCopy, arguments);
if (firstKey == nil)
@throw [OFInvalidArgumentException
exceptionWithClass: [self class]
selector: _cmd];
key = firstKey;
if ((object = va_arg(arguments, id)) == nil)
@throw [OFInvalidArgumentException
exceptionWithClass: [self class]
selector: _cmd];
count = 1;
for (; va_arg(argumentsCopy, id) != nil; count++);
count >>= 1;
if (count > UINT32_MAX)
@throw [OFOutOfRangeException
exceptionWithClass: [self class]];
for (newSize = 1; newSize < count; newSize <<= 1);
if (count * 4 / newSize >= 3)
newSize <<= 1;
if (newSize == 0)
@throw [OFOutOfRangeException
exceptionWithClass: [self class]];
data = [self allocMemoryWithSize: sizeof(*data)
count: newSize];
for (j = 0; j < newSize; j++)
data[j] = NULL;
|
︙ | | | ︙ | |
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
|
uint32_t last;
key = va_arg(arguments, id);
object = va_arg(arguments, id);
if (key == nil || object == nil)
@throw [OFInvalidArgumentException
exceptionWithClass: isa
selector: _cmd];
hash = [key hash];
last = size;
for (j = hash & (size - 1); j < last && data[j] != NULL;
j++)
|
|
|
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
|
uint32_t last;
key = va_arg(arguments, id);
object = va_arg(arguments, id);
if (key == nil || object == nil)
@throw [OFInvalidArgumentException
exceptionWithClass: [self class]
selector: _cmd];
hash = [key hash];
last = size;
for (j = hash & (size - 1); j < last && data[j] != NULL;
j++)
|
︙ | | | ︙ | |
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
|
for (j = 0; j < last && data[j] != NULL;
j++);
}
if (j >= last)
@throw [OFOutOfRangeException
exceptionWithClass: isa];
bucket =
[self allocMemoryWithSize: sizeof(*bucket)];
bucket->key = [key copy];
bucket->object = [object retain];
bucket->hash = hash;
|
|
|
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
|
for (j = 0; j < last && data[j] != NULL;
j++);
}
if (j >= last)
@throw [OFOutOfRangeException
exceptionWithClass: [self class]];
bucket =
[self allocMemoryWithSize: sizeof(*bucket)];
bucket->key = [key copy];
bucket->object = [object retain];
bucket->hash = hash;
|
︙ | | | ︙ | |
502
503
504
505
506
507
508
509
510
511
512
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
544
545
|
OFEnumerator *keyEnumerator, *objectEnumerator;
OFXMLElement *keyElement, *objectElement;
if ((![[element name] isEqual: @"OFDictionary"] &&
![[element name] isEqual: @"OFMutableDictionary"]) ||
![[element namespace] isEqual: OF_SERIALIZATION_NS])
@throw [OFInvalidArgumentException
exceptionWithClass: isa
selector: _cmd];
dictionary = [OFMutableDictionary dictionary];
keys = [element elementsForName: @"key"
namespace: OF_SERIALIZATION_NS];
objects = [element elementsForName: @"object"
namespace: OF_SERIALIZATION_NS];
if ([keys count] != [objects count])
@throw [OFInvalidFormatException
exceptionWithClass: isa];
keyEnumerator = [keys objectEnumerator];
objectEnumerator = [objects objectEnumerator];
pool2 = [[OFAutoreleasePool alloc] init];
while ((keyElement = [keyEnumerator nextObject]) != nil &&
(objectElement = [objectEnumerator nextObject]) != nil) {
OFXMLElement *key, *object;
key = [[keyElement elementsForNamespace:
OF_SERIALIZATION_NS] firstObject];
object = [[objectElement elementsForNamespace:
OF_SERIALIZATION_NS] firstObject];
if (key == nil || object == nil)
@throw [OFInvalidFormatException
exceptionWithClass: isa];
[dictionary setObject: [object objectByDeserializing]
forKey: [key objectByDeserializing]];
[pool2 releaseObjects];
}
|
|
|
|
|
508
509
510
511
512
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
544
545
546
547
548
549
550
551
|
OFEnumerator *keyEnumerator, *objectEnumerator;
OFXMLElement *keyElement, *objectElement;
if ((![[element name] isEqual: @"OFDictionary"] &&
![[element name] isEqual: @"OFMutableDictionary"]) ||
![[element namespace] isEqual: OF_SERIALIZATION_NS])
@throw [OFInvalidArgumentException
exceptionWithClass: [self class]
selector: _cmd];
dictionary = [OFMutableDictionary dictionary];
keys = [element elementsForName: @"key"
namespace: OF_SERIALIZATION_NS];
objects = [element elementsForName: @"object"
namespace: OF_SERIALIZATION_NS];
if ([keys count] != [objects count])
@throw [OFInvalidFormatException
exceptionWithClass: [self class]];
keyEnumerator = [keys objectEnumerator];
objectEnumerator = [objects objectEnumerator];
pool2 = [[OFAutoreleasePool alloc] init];
while ((keyElement = [keyEnumerator nextObject]) != nil &&
(objectElement = [objectEnumerator nextObject]) != nil) {
OFXMLElement *key, *object;
key = [[keyElement elementsForNamespace:
OF_SERIALIZATION_NS] firstObject];
object = [[objectElement elementsForNamespace:
OF_SERIALIZATION_NS] firstObject];
if (key == nil || object == nil)
@throw [OFInvalidFormatException
exceptionWithClass: [self class]];
[dictionary setObject: [object objectByDeserializing]
forKey: [key objectByDeserializing]];
[pool2 releaseObjects];
}
|
︙ | | | ︙ | |
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
|
}
- (id)objectForKey: (id)key
{
uint32_t i, hash, last;
if (key == nil)
@throw [OFInvalidArgumentException exceptionWithClass: isa
selector: _cmd];
hash = [key hash];
last = size;
for (i = hash & (size - 1); i < last && data[i] != NULL; i++) {
if (data[i] == DELETED)
|
|
>
|
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
|
}
- (id)objectForKey: (id)key
{
uint32_t i, hash, last;
if (key == nil)
@throw [OFInvalidArgumentException
exceptionWithClass: [self class]
selector: _cmd];
hash = [key hash];
last = size;
for (i = hash & (size - 1); i < last && data[i] != NULL; i++) {
if (data[i] == DELETED)
|
︙ | | | ︙ | |
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
|
[super dealloc];
}
- (void)reset
{
if (mutationsPtr != NULL && *mutationsPtr != mutations)
@throw [OFEnumerationMutationException
exceptionWithClass: isa
object: dictionary];
pos = 0;
}
@end
@implementation OFDictionaryObjectEnumerator_hashtable
- (id)nextObject
{
if (mutationsPtr != NULL && *mutationsPtr != mutations)
@throw [OFEnumerationMutationException
exceptionWithClass: isa
object: dictionary];
for (; pos < size && (data[pos] == NULL ||
data[pos] == DELETED); pos++);
if (pos < size)
return data[pos++]->object;
else
return nil;
}
@end
@implementation OFDictionaryKeyEnumerator_hashtable
- (id)nextObject
{
if (mutationsPtr != NULL && *mutationsPtr != mutations)
@throw [OFEnumerationMutationException
exceptionWithClass: isa
object: dictionary];
for (; pos < size && (data[pos] == NULL ||
data[pos] == DELETED); pos++);
if (pos < size)
return data[pos++]->key;
else
return nil;
}
@end
|
|
|
|
|
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
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
|
[super dealloc];
}
- (void)reset
{
if (mutationsPtr != NULL && *mutationsPtr != mutations)
@throw [OFEnumerationMutationException
exceptionWithClass: [self class]
object: dictionary];
pos = 0;
}
@end
@implementation OFDictionaryObjectEnumerator_hashtable
- (id)nextObject
{
if (mutationsPtr != NULL && *mutationsPtr != mutations)
@throw [OFEnumerationMutationException
exceptionWithClass: [self class]
object: dictionary];
for (; pos < size && (data[pos] == NULL ||
data[pos] == DELETED); pos++);
if (pos < size)
return data[pos++]->object;
else
return nil;
}
@end
@implementation OFDictionaryKeyEnumerator_hashtable
- (id)nextObject
{
if (mutationsPtr != NULL && *mutationsPtr != mutations)
@throw [OFEnumerationMutationException
exceptionWithClass: [self class]
object: dictionary];
for (; pos < size && (data[pos] == NULL ||
data[pos] == DELETED); pos++);
if (pos < size)
return data[pos++]->key;
else
return nil;
}
@end
|
Modified src/OFEnumerator.m
from [cbc41131f3]
to [a52bed56fc].
︙ | | | ︙ | |
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
|
#import "OFEnumerator.h"
#import "OFNotImplementedException.h"
@implementation OFEnumerator
- init
{
if (isa == [OFEnumerator class]) {
Class c = isa;
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
return [super init];
}
- (id)nextObject
{
@throw [OFNotImplementedException exceptionWithClass: isa
selector: _cmd];
}
- (void)reset
{
@throw [OFNotImplementedException exceptionWithClass: isa
selector: _cmd];
}
@end
|
|
|
|
|
|
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
|
#import "OFEnumerator.h"
#import "OFNotImplementedException.h"
@implementation OFEnumerator
- init
{
if (object_getClass(self) == [OFEnumerator class]) {
Class c = [self class];
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
return [super init];
}
- (id)nextObject
{
@throw [OFNotImplementedException exceptionWithClass: [self class]
selector: _cmd];
}
- (void)reset
{
@throw [OFNotImplementedException exceptionWithClass: [self class]
selector: _cmd];
}
@end
|
Modified src/OFFile.m
from [be7cb0fa5d]
to [5fa5942d93].
︙ | | | ︙ | |
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
678
|
[pool release];
}
#endif
- init
{
Class c = isa;
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
- initWithPath: (OFString*)path
mode: (OFString*)mode
{
self = [super init];
@try {
int flags;
if ((flags = parse_mode([mode cStringWithEncoding:
OF_STRING_ENCODING_NATIVE])) == -1)
@throw [OFInvalidArgumentException
exceptionWithClass: isa
selector: _cmd];
if ((fileDescriptor = open([path cStringWithEncoding:
OF_STRING_ENCODING_NATIVE], flags, DEFAULT_MODE)) == -1)
@throw [OFOpenFileFailedException
exceptionWithClass: isa
path: path
mode: mode];
closable = YES;
} @catch (id e) {
[self release];
@throw e;
|
|
|
|
|
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
678
|
[pool release];
}
#endif
- init
{
Class c = [self class];
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
- initWithPath: (OFString*)path
mode: (OFString*)mode
{
self = [super init];
@try {
int flags;
if ((flags = parse_mode([mode cStringWithEncoding:
OF_STRING_ENCODING_NATIVE])) == -1)
@throw [OFInvalidArgumentException
exceptionWithClass: [self class]
selector: _cmd];
if ((fileDescriptor = open([path cStringWithEncoding:
OF_STRING_ENCODING_NATIVE], flags, DEFAULT_MODE)) == -1)
@throw [OFOpenFileFailedException
exceptionWithClass: [self class]
path: path
mode: mode];
closable = YES;
} @catch (id e) {
[self release];
@throw e;
|
︙ | | | ︙ | |
701
702
703
704
705
706
707
708
709
710
711
712
713
714
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
|
- (size_t)_readIntoBuffer: (void*)buffer
length: (size_t)length
{
ssize_t ret;
if (fileDescriptor == -1 || atEndOfStream ||
(ret = read(fileDescriptor, buffer, length)) < 0)
@throw [OFReadFailedException exceptionWithClass: isa
stream: self
requestedLength: length];
if (ret == 0)
atEndOfStream = YES;
return ret;
}
- (void)_writeBuffer: (const void*)buffer
length: (size_t)length
{
if (fileDescriptor == -1 || atEndOfStream ||
write(fileDescriptor, buffer, length) < length)
@throw [OFWriteFailedException exceptionWithClass: isa
stream: self
requestedLength: length];
}
- (void)_seekToOffset: (off_t)offset
{
if (lseek(fileDescriptor, offset, SEEK_SET) == -1)
@throw [OFSeekFailedException exceptionWithClass: isa
stream: self
offset: offset
whence: SEEK_SET];
}
- (off_t)_seekForwardWithOffset: (off_t)offset
{
off_t ret;
if ((ret = lseek(fileDescriptor, offset, SEEK_CUR)) == -1)
@throw [OFSeekFailedException exceptionWithClass: isa
stream: self
offset: offset
whence: SEEK_CUR];
return ret;
}
- (off_t)_seekToOffsetRelativeToEnd: (off_t)offset
{
off_t ret;
if ((ret = lseek(fileDescriptor, offset, SEEK_END)) == -1)
@throw [OFSeekFailedException exceptionWithClass: isa
stream: self
offset: offset
whence: SEEK_END];
return ret;
}
|
|
|
|
|
|
|
701
702
703
704
705
706
707
708
709
710
711
712
713
714
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
|
- (size_t)_readIntoBuffer: (void*)buffer
length: (size_t)length
{
ssize_t ret;
if (fileDescriptor == -1 || atEndOfStream ||
(ret = read(fileDescriptor, buffer, length)) < 0)
@throw [OFReadFailedException exceptionWithClass: [self class]
stream: self
requestedLength: length];
if (ret == 0)
atEndOfStream = YES;
return ret;
}
- (void)_writeBuffer: (const void*)buffer
length: (size_t)length
{
if (fileDescriptor == -1 || atEndOfStream ||
write(fileDescriptor, buffer, length) < length)
@throw [OFWriteFailedException exceptionWithClass: [self class]
stream: self
requestedLength: length];
}
- (void)_seekToOffset: (off_t)offset
{
if (lseek(fileDescriptor, offset, SEEK_SET) == -1)
@throw [OFSeekFailedException exceptionWithClass: [self class]
stream: self
offset: offset
whence: SEEK_SET];
}
- (off_t)_seekForwardWithOffset: (off_t)offset
{
off_t ret;
if ((ret = lseek(fileDescriptor, offset, SEEK_CUR)) == -1)
@throw [OFSeekFailedException exceptionWithClass: [self class]
stream: self
offset: offset
whence: SEEK_CUR];
return ret;
}
- (off_t)_seekToOffsetRelativeToEnd: (off_t)offset
{
off_t ret;
if ((ret = lseek(fileDescriptor, offset, SEEK_END)) == -1)
@throw [OFSeekFailedException exceptionWithClass: [self class]
stream: self
offset: offset
whence: SEEK_END];
return ret;
}
|
︙ | | | ︙ | |
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
|
of_stdout = [[OFFileSingleton alloc] initWithFileDescriptor: 1];
of_stderr = [[OFFileSingleton alloc] initWithFileDescriptor: 2];
}
- initWithPath: (OFString*)path
mode: (OFString*)mode
{
Class c = isa;
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
- autorelease
{
|
|
|
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
|
of_stdout = [[OFFileSingleton alloc] initWithFileDescriptor: 1];
of_stderr = [[OFFileSingleton alloc] initWithFileDescriptor: 2];
}
- initWithPath: (OFString*)path
mode: (OFString*)mode
{
Class c = [self class];
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
- autorelease
{
|
︙ | | | ︙ | |
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
|
- (unsigned int)retainCount
{
return OF_RETAIN_COUNT_MAX;
}
- (void)dealloc
{
@throw [OFNotImplementedException exceptionWithClass: isa
selector: _cmd];
[super dealloc]; /* Get rid of stupid warning */
}
- (void)_seekToOffset: (off_t)offset
{
@throw [OFNotImplementedException exceptionWithClass: isa
selector: _cmd];
}
- (off_t)_seekForwardWithOffset: (off_t)offset
{
@throw [OFNotImplementedException exceptionWithClass: isa
selector: _cmd];
}
- (off_t)_seekToOffsetRelativeToEnd: (off_t)offset
{
@throw [OFNotImplementedException exceptionWithClass: isa
selector: _cmd];
}
@end
|
|
|
|
|
|
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
|
- (unsigned int)retainCount
{
return OF_RETAIN_COUNT_MAX;
}
- (void)dealloc
{
@throw [OFNotImplementedException exceptionWithClass: [self class]
selector: _cmd];
[super dealloc]; /* Get rid of stupid warning */
}
- (void)_seekToOffset: (off_t)offset
{
@throw [OFNotImplementedException exceptionWithClass: [self class]
selector: _cmd];
}
- (off_t)_seekForwardWithOffset: (off_t)offset
{
@throw [OFNotImplementedException exceptionWithClass: [self class]
selector: _cmd];
}
- (off_t)_seekToOffsetRelativeToEnd: (off_t)offset
{
@throw [OFNotImplementedException exceptionWithClass: [self class]
selector: _cmd];
}
@end
|
Modified src/OFHTTPRequest.m
from [bba59f52c5]
to [222aca0da5].
︙ | | | ︙ | |
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
|
const char *type = NULL;
size_t contentLength = 0;
BOOL chunked;
char *buffer;
size_t bytesReceived;
if (![scheme isEqual: @"http"] && ![scheme isEqual: @"https"])
@throw [OFUnsupportedProtocolException exceptionWithClass: isa
URL: URL];
if ([scheme isEqual: @"http"])
sock = [OFTCPSocket socket];
else {
if (of_http_request_tls_socket_class == Nil)
@throw [OFUnsupportedProtocolException
exceptionWithClass: isa
URL: URL];
sock = [[[of_http_request_tls_socket_class alloc] init]
autorelease];
}
[delegate request: self
|
|
>
|
|
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
|
const char *type = NULL;
size_t contentLength = 0;
BOOL chunked;
char *buffer;
size_t bytesReceived;
if (![scheme isEqual: @"http"] && ![scheme isEqual: @"https"])
@throw [OFUnsupportedProtocolException
exceptionWithClass: [self class]
URL: URL];
if ([scheme isEqual: @"http"])
sock = [OFTCPSocket socket];
else {
if (of_http_request_tls_socket_class == Nil)
@throw [OFUnsupportedProtocolException
exceptionWithClass: [self class]
URL: URL];
sock = [[[of_http_request_tls_socket_class alloc] init]
autorelease];
}
[delegate request: self
|
︙ | | | ︙ | |
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
|
if (requestType == OF_HTTP_REQUEST_TYPE_POST)
[sock writeString: queryString];
@try {
line = [sock readLine];
} @catch (OFInvalidEncodingException *e) {
@throw [OFInvalidServerReplyException exceptionWithClass: isa];
}
if (![line hasPrefix: @"HTTP/1.0 "] && ![line hasPrefix: @"HTTP/1.1 "])
@throw [OFInvalidServerReplyException exceptionWithClass: isa];
status = (int)[[line substringWithRange: of_range(9, 3)] decimalValue];
serverHeaders = [OFMutableDictionary dictionary];
for (;;) {
OFString *key, *value;
const char *line_c, *tmp;
@try {
line = [sock readLine];
} @catch (OFInvalidEncodingException *e) {
@throw [OFInvalidServerReplyException
exceptionWithClass: isa];
}
if (line == nil)
@throw [OFInvalidServerReplyException
exceptionWithClass: isa];
if ([line isEqual: @""])
break;
line_c = [line UTF8String];
if ((tmp = strchr(line_c, ':')) == NULL)
@throw [OFInvalidServerReplyException
exceptionWithClass: isa];
key = [OFString stringWithUTF8String: line_c
length: tmp - line_c];
normalizeKey(key);
do {
tmp++;
|
|
>
|
>
|
|
|
|
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
|
if (requestType == OF_HTTP_REQUEST_TYPE_POST)
[sock writeString: queryString];
@try {
line = [sock readLine];
} @catch (OFInvalidEncodingException *e) {
@throw [OFInvalidServerReplyException
exceptionWithClass: [self class]];
}
if (![line hasPrefix: @"HTTP/1.0 "] && ![line hasPrefix: @"HTTP/1.1 "])
@throw [OFInvalidServerReplyException
exceptionWithClass: [self class]];
status = (int)[[line substringWithRange: of_range(9, 3)] decimalValue];
serverHeaders = [OFMutableDictionary dictionary];
for (;;) {
OFString *key, *value;
const char *line_c, *tmp;
@try {
line = [sock readLine];
} @catch (OFInvalidEncodingException *e) {
@throw [OFInvalidServerReplyException
exceptionWithClass: [self class]];
}
if (line == nil)
@throw [OFInvalidServerReplyException
exceptionWithClass: [self class]];
if ([line isEqual: @""])
break;
line_c = [line UTF8String];
if ((tmp = strchr(line_c, ':')) == NULL)
@throw [OFInvalidServerReplyException
exceptionWithClass: [self class]];
key = [OFString stringWithUTF8String: line_c
length: tmp - line_c];
normalizeKey(key);
do {
tmp++;
|
︙ | | | ︙ | |
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
|
contentLengthHeader = [serverHeaders objectForKey: @"Content-Length"];
if (contentLengthHeader != nil) {
contentLength = (size_t)[contentLengthHeader decimalValue];
if (contentLength > SIZE_MAX)
@throw [OFOutOfRangeException exceptionWithClass: isa];
}
buffer = [self allocMemoryWithSize: of_pagesize];
bytesReceived = 0;
@try {
OFAutoreleasePool *pool2 = [[OFAutoreleasePool alloc] init];
if (chunked) {
for (;;) {
size_t pos, toRead;
@try {
line = [sock readLine];
} @catch (OFInvalidEncodingException *e) {
@throw [OFInvalidServerReplyException
exceptionWithClass: isa];
}
pos = [line
indexOfFirstOccurrenceOfString: @";"];
if (pos != OF_INVALID_INDEX)
line = [line substringWithRange:
of_range(0, pos)];
@try {
toRead =
(size_t)[line hexadecimalValue];
} @catch (OFInvalidFormatException *e) {
@throw [OFInvalidServerReplyException
exceptionWithClass: isa];
}
if (toRead == 0 ||
(contentLengthHeader != nil &&
contentLength >= bytesReceived))
break;
|
|
>
|
|
|
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
|
contentLengthHeader = [serverHeaders objectForKey: @"Content-Length"];
if (contentLengthHeader != nil) {
contentLength = (size_t)[contentLengthHeader decimalValue];
if (contentLength > SIZE_MAX)
@throw [OFOutOfRangeException
exceptionWithClass: [self class]];
}
buffer = [self allocMemoryWithSize: of_pagesize];
bytesReceived = 0;
@try {
OFAutoreleasePool *pool2 = [[OFAutoreleasePool alloc] init];
if (chunked) {
for (;;) {
size_t pos, toRead;
@try {
line = [sock readLine];
} @catch (OFInvalidEncodingException *e) {
@throw [OFInvalidServerReplyException
exceptionWithClass: [self class]];
}
pos = [line
indexOfFirstOccurrenceOfString: @";"];
if (pos != OF_INVALID_INDEX)
line = [line substringWithRange:
of_range(0, pos)];
@try {
toRead =
(size_t)[line hexadecimalValue];
} @catch (OFInvalidFormatException *e) {
@throw [OFInvalidServerReplyException
exceptionWithClass: [self class]];
}
if (toRead == 0 ||
(contentLengthHeader != nil &&
contentLength >= bytesReceived))
break;
|
︙ | | | ︙ | |
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
|
toRead -= length;
}
@try {
line = [sock readLine];
} @catch (OFInvalidEncodingException *e) {
@throw [OFInvalidServerReplyException
exceptionWithClass: isa];
}
if (![line isEqual: @""])
@throw [OFInvalidServerReplyException
exceptionWithClass: isa];
[pool2 releaseObjects];
}
} else {
size_t length;
while ((length = [sock
|
|
|
|
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
|
toRead -= length;
}
@try {
line = [sock readLine];
} @catch (OFInvalidEncodingException *e) {
@throw [OFInvalidServerReplyException
exceptionWithClass: [self class]];
}
if (![line isEqual: @""])
@throw [OFInvalidServerReplyException
exceptionWithClass: [self class]];
[pool2 releaseObjects];
}
} else {
size_t length;
while ((length = [sock
|
︙ | | | ︙ | |
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
513
|
/*
* We only want to throw on these status codes as we will throw an
* OFHTTPRequestFailedException for all other status codes later.
*/
if (contentLengthHeader != nil && contentLength != bytesReceived &&
(status == 200 || status == 301 || status == 302 || status == 303 ||
status == 307))
@throw [OFTruncatedDataException exceptionWithClass: isa];
[serverHeaders makeImmutable];
result = [[OFHTTPRequestResult alloc] initWithStatusCode: status
headers: serverHeaders
data: data];
switch (status) {
case 200:
case 301:
case 302:
case 303:
case 307:
break;
default:
[result release];
@throw [OFHTTPRequestFailedException
exceptionWithClass: isa
HTTPRequest: self
result: result];
}
[pool release];
return [result autorelease];
|
|
>
|
|
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
513
514
515
516
517
518
|
/*
* We only want to throw on these status codes as we will throw an
* OFHTTPRequestFailedException for all other status codes later.
*/
if (contentLengthHeader != nil && contentLength != bytesReceived &&
(status == 200 || status == 301 || status == 302 || status == 303 ||
status == 307))
@throw [OFTruncatedDataException
exceptionWithClass: [self class]];
[serverHeaders makeImmutable];
result = [[OFHTTPRequestResult alloc] initWithStatusCode: status
headers: serverHeaders
data: data];
switch (status) {
case 200:
case 301:
case 302:
case 303:
case 307:
break;
default:
[result release];
@throw [OFHTTPRequestFailedException
exceptionWithClass: [self class]
HTTPRequest: self
result: result];
}
[pool release];
return [result autorelease];
|
︙ | | | ︙ | |
Modified src/OFHash.m
from [7dbf281922]
to [5f584d8a06].
︙ | | | ︙ | |
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
@throw [OFNotImplementedException exceptionWithClass: self
selector: _cmd];
}
- (void)updateWithBuffer: (const void*)buffer
length: (size_t)length
{
@throw [OFNotImplementedException exceptionWithClass: isa
selector: _cmd];
}
- (uint8_t*)digest
{
@throw [OFNotImplementedException exceptionWithClass: isa
selector: _cmd];
}
- (BOOL)isCalculated
{
return calculated;
}
@end
|
|
|
|
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
@throw [OFNotImplementedException exceptionWithClass: self
selector: _cmd];
}
- (void)updateWithBuffer: (const void*)buffer
length: (size_t)length
{
@throw [OFNotImplementedException exceptionWithClass: [self class]
selector: _cmd];
}
- (uint8_t*)digest
{
@throw [OFNotImplementedException exceptionWithClass: [self class]
selector: _cmd];
}
- (BOOL)isCalculated
{
return calculated;
}
@end
|
Modified src/OFIntrospection.m
from [e4635330ec]
to [1b37797849].
︙ | | | ︙ | |
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
|
instanceMethods = [[OFMutableArray alloc] init];
instanceVariables = [[OFMutableArray alloc] init];
#ifdef OF_HAVE_PROPERTIES
properties = [[OFMutableArray alloc] init];
#endif
#if defined(OF_APPLE_RUNTIME)
methodList = class_copyMethodList(((OFObject*)class)->isa,
&count);
@try {
for (i = 0; i < count; i++) {
[classMethods addObject: [[[OFMethod alloc]
_initWithMethod: methodList[i]]
autorelease]];
[pool releaseObjects];
|
|
|
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
|
instanceMethods = [[OFMutableArray alloc] init];
instanceVariables = [[OFMutableArray alloc] init];
#ifdef OF_HAVE_PROPERTIES
properties = [[OFMutableArray alloc] init];
#endif
#if defined(OF_APPLE_RUNTIME)
methodList = class_copyMethodList(object_getClass(class),
&count);
@try {
for (i = 0; i < count; i++) {
[classMethods addObject: [[[OFMethod alloc]
_initWithMethod: methodList[i]]
autorelease]];
[pool releaseObjects];
|
︙ | | | ︙ | |
Modified src/OFList.m
from [161c3c4eaf]
to [22c9c07182].
︙ | | | ︙ | |
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
OFAutoreleasePool *pool2;
OFEnumerator *enumerator;
OFXMLElement *child;
if (![[element name] isEqual: [self className]] ||
![[element namespace] isEqual: OF_SERIALIZATION_NS])
@throw [OFInvalidArgumentException
exceptionWithClass: isa
selector: _cmd];
enumerator = [[element elementsForNamespace:
OF_SERIALIZATION_NS] objectEnumerator];
pool2 = [[OFAutoreleasePool alloc] init];
while ((child = [enumerator nextObject]) != nil) {
|
|
|
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
OFAutoreleasePool *pool2;
OFEnumerator *enumerator;
OFXMLElement *child;
if (![[element name] isEqual: [self className]] ||
![[element namespace] isEqual: OF_SERIALIZATION_NS])
@throw [OFInvalidArgumentException
exceptionWithClass: [self class]
selector: _cmd];
enumerator = [[element elementsForNamespace:
OF_SERIALIZATION_NS] objectEnumerator];
pool2 = [[OFAutoreleasePool alloc] init];
while ((child = [enumerator nextObject]) != nil) {
|
︙ | | | ︙ | |
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
|
return YES;
return NO;
}
- copy
{
OFList *copy = [[isa alloc] init];
of_list_object_t *iter, *listObject, *previous;
listObject = NULL;
previous = NULL;
@try {
for (iter = firstListObject; iter != NULL; iter = iter->next) {
|
|
|
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
|
return YES;
return NO;
}
- copy
{
OFList *copy = [[[self class] alloc] init];
of_list_object_t *iter, *listObject, *previous;
listObject = NULL;
previous = NULL;
@try {
for (iter = firstListObject; iter != NULL; iter = iter->next) {
|
︙ | | | ︙ | |
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
|
- (id)nextObject
{
id ret;
if (*mutationsPtr != mutations)
@throw [OFEnumerationMutationException
exceptionWithClass: isa
object: list];
if (current == NULL)
return nil;
ret = current->object;
current = current->next;
return ret;
}
- (void)reset
{
if (*mutationsPtr != mutations)
@throw [OFEnumerationMutationException
exceptionWithClass: isa
object: list];
current = [list firstListObject];
}
@end
|
|
|
|
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
|
- (id)nextObject
{
id ret;
if (*mutationsPtr != mutations)
@throw [OFEnumerationMutationException
exceptionWithClass: [self class]
object: list];
if (current == NULL)
return nil;
ret = current->object;
current = current->next;
return ret;
}
- (void)reset
{
if (*mutationsPtr != mutations)
@throw [OFEnumerationMutationException
exceptionWithClass: [self class]
object: list];
current = [list firstListObject];
}
@end
|
Modified src/OFMD5Hash.m
from [a97a93ff1c]
to [2ed1eeca9f].
︙ | | | ︙ | |
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
|
const char *buffer_ = buffer__;
if (length == 0)
return;
if (calculated)
@throw [OFHashAlreadyCalculatedException
exceptionWithClass: isa
hash: self];
/* Update bitcount */
t = bits[0];
if ((bits[0] = t + ((uint32_t)length << 3)) < t)
/* Carry from low to high */
bits[1]++;
|
|
|
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
|
const char *buffer_ = buffer__;
if (length == 0)
return;
if (calculated)
@throw [OFHashAlreadyCalculatedException
exceptionWithClass: [self class]
hash: self];
/* Update bitcount */
t = bits[0];
if ((bits[0] = t + ((uint32_t)length << 3)) < t)
/* Carry from low to high */
bits[1]++;
|
︙ | | | ︙ | |
Modified src/OFMutableArray.m
from [0bfaa52216]
to [a85051edf1].
︙ | | | ︙ | |
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
|
- (void)release
{
}
- (void)dealloc
{
@throw [OFNotImplementedException exceptionWithClass: isa
selector: _cmd];
[super dealloc]; /* Get rid of a stupid warning */
}
@end
@implementation OFMutableArray
+ (void)initialize
{
if (self == [OFMutableArray class])
placeholder.isa = [OFMutableArray_placeholder class];
}
+ alloc
{
if (self == [OFMutableArray class])
return (id)&placeholder;
return [super alloc];
}
- init
{
if (isa == [OFMutableArray class]) {
Class c = isa;
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
return [super init];
}
|
|
>
|
|
|
|
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
|
- (void)release
{
}
- (void)dealloc
{
@throw [OFNotImplementedException exceptionWithClass: [self class]
selector: _cmd];
[super dealloc]; /* Get rid of a stupid warning */
}
@end
@implementation OFMutableArray
+ (void)initialize
{
if (self == [OFMutableArray class])
object_setClass((id)&placeholder,
[OFMutableArray_placeholder class]);
}
+ alloc
{
if (self == [OFMutableArray class])
return (id)&placeholder;
return [super alloc];
}
- init
{
if (object_getClass(self) == [OFMutableArray class]) {
Class c = [self class];
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
return [super init];
}
|
︙ | | | ︙ | |
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
|
[self insertObjectsFromArray: array
atIndex: [self count]];
}
- (void)insertObject: (id)object
atIndex: (size_t)index
{
@throw [OFNotImplementedException exceptionWithClass: isa
selector: _cmd];
}
- (void)insertObjectsFromArray: (OFArray*)array
atIndex: (size_t)index
{
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
|
|
|
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
|
[self insertObjectsFromArray: array
atIndex: [self count]];
}
- (void)insertObject: (id)object
atIndex: (size_t)index
{
@throw [OFNotImplementedException exceptionWithClass: [self class]
selector: _cmd];
}
- (void)insertObjectsFromArray: (OFArray*)array
atIndex: (size_t)index
{
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
|
︙ | | | ︙ | |
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
|
[pool release];
}
- (void)replaceObjectAtIndex: (size_t)index
withObject: (id)object
{
@throw [OFNotImplementedException exceptionWithClass: isa
selector: _cmd];
}
- (void)setObject: (id)object
atIndexedSubscript: (size_t)index
{
[self replaceObjectAtIndex: index
|
|
|
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
|
[pool release];
}
- (void)replaceObjectAtIndex: (size_t)index
withObject: (id)object
{
@throw [OFNotImplementedException exceptionWithClass: [self class]
selector: _cmd];
}
- (void)setObject: (id)object
atIndexedSubscript: (size_t)index
{
[self replaceObjectAtIndex: index
|
︙ | | | ︙ | |
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
|
return;
}
}
}
- (void)removeObjectAtIndex: (size_t)index
{
@throw [OFNotImplementedException exceptionWithClass: isa
selector: _cmd];
}
- (void)removeObject: (id)object
{
size_t i, count = [self count];
|
|
|
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
|
return;
}
}
}
- (void)removeObjectAtIndex: (size_t)index
{
@throw [OFNotImplementedException exceptionWithClass: [self class]
selector: _cmd];
}
- (void)removeObject: (id)object
{
size_t i, count = [self count];
|
︙ | | | ︙ | |
Modified src/OFMutableArray_adjacent.m
from [e388818b36]
to [6feaf02274].
︙ | | | ︙ | |
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
- (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
|
|
|
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
- (void)replaceObjectAtIndex: (size_t)index
withObject: (id)object
{
id *objects = [array cArray];
id oldObject;
if (index >= [array count])
@throw [OFOutOfRangeException exceptionWithClass: [self class]];
oldObject = objects[index];
objects[index] = [object retain];
[oldObject release];
}
- (void)replaceObjectIdenticalTo: (id)oldObject
|
︙ | | | ︙ | |
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
|
- (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 allocMemoryWithSize: sizeof(*copy)
count: range.length];
memcpy(copy, objects + range.start, range.length * sizeof(id));
@try {
[array removeItemsInRange: range];
|
|
|
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
|
- (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: [self class]];
copy = [self allocMemoryWithSize: sizeof(*copy)
count: range.length];
memcpy(copy, objects + range.start, range.length * sizeof(id));
@try {
[array removeItemsInRange: range];
|
︙ | | | ︙ | |
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
|
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
|
|
|
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
|
withObjectAtIndex: (size_t)index2
{
id *objects = [array cArray];
size_t count = [array count];
id tmp;
if (index1 >= count || index2 >= count)
@throw [OFOutOfRangeException exceptionWithClass: [self class]];
tmp = objects[index1];
objects[index1] = objects[index2];
objects[index2] = tmp;
}
- (void)reverse
|
︙ | | | ︙ | |
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
|
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
|
|
|
|
|
|
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
|
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: [self class]
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: [self class]
object: self];
newObject = block(objects[i], i, &stop);
if (newObject == nil)
@throw [OFInvalidArgumentException
exceptionWithClass: [self class]
selector: _cmd];
[newObject retain];
[objects[i] release];
objects[i] = newObject;
}
}
#endif
- (void)makeImmutable
{
object_setClass(self, [OFArray_adjacent class]);
}
@end
|
Modified src/OFMutableDictionary.m
from [3637b5fc69]
to [d28ad27aa9].
︙ | | | ︙ | |
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
|
- (void)release
{
}
- (void)dealloc
{
@throw [OFNotImplementedException exceptionWithClass: isa
selector: _cmd];
[super dealloc]; /* Get rid of a stupid warning */
}
@end
@implementation OFMutableDictionary
+ (void)initialize
{
if (self == [OFMutableDictionary class])
placeholder.isa = [OFMutableDictionary_placeholder class];
}
+ alloc
{
if (self == [OFMutableDictionary class])
return (id)&placeholder;
return [super alloc];
}
- init
{
if (isa == [OFMutableDictionary class]) {
Class c = isa;
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
return [super init];
}
- (void)setObject: (id)object
forKey: (id)key
{
@throw [OFNotImplementedException exceptionWithClass: isa
selector: _cmd];
}
- (void)setObject: (id)object
forKeyedSubscript: (id)key
{
[self setObject: object
forKey: key];
}
- (void)removeObjectForKey: (id)key
{
@throw [OFNotImplementedException exceptionWithClass: isa
selector: _cmd];
}
- copy
{
return [[OFDictionary alloc] initWithDictionary: self];
}
|
|
>
|
|
|
|
|
|
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
|
- (void)release
{
}
- (void)dealloc
{
@throw [OFNotImplementedException exceptionWithClass: [self class]
selector: _cmd];
[super dealloc]; /* Get rid of a stupid warning */
}
@end
@implementation OFMutableDictionary
+ (void)initialize
{
if (self == [OFMutableDictionary class])
object_setClass((id)&placeholder,
[OFMutableDictionary_placeholder class]);
}
+ alloc
{
if (self == [OFMutableDictionary class])
return (id)&placeholder;
return [super alloc];
}
- init
{
if (object_getClass(self) == [OFMutableDictionary class]) {
Class c = [self class];
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
return [super init];
}
- (void)setObject: (id)object
forKey: (id)key
{
@throw [OFNotImplementedException exceptionWithClass: [self class]
selector: _cmd];
}
- (void)setObject: (id)object
forKeyedSubscript: (id)key
{
[self setObject: object
forKey: key];
}
- (void)removeObjectForKey: (id)key
{
@throw [OFNotImplementedException exceptionWithClass: [self class]
selector: _cmd];
}
- copy
{
return [[OFDictionary alloc] initWithDictionary: self];
}
|
︙ | | | ︙ | |
Modified src/OFMutableDictionary_hashtable.m
from [aeb921a44b]
to [131e6a2740].
︙ | | | ︙ | |
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
|
- (void)_resizeForCount: (size_t)newCount
{
size_t fullness = newCount * 4 / size;
struct of_dictionary_hashtable_bucket **newData;
uint32_t i, newSize;
if (newCount > UINT32_MAX)
@throw [OFOutOfRangeException exceptionWithClass: isa];
if (fullness >= 3)
newSize = size << 1;
else if (fullness <= 1)
newSize = size >> 1;
else
return;
if (newSize == 0)
@throw [OFOutOfRangeException exceptionWithClass: isa];
newData = [self allocMemoryWithSize: sizeof(*newData)
count: newSize];
for (i = 0; i < newSize; i++)
newData[i] = NULL;
|
|
|
|
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
|
- (void)_resizeForCount: (size_t)newCount
{
size_t fullness = newCount * 4 / size;
struct of_dictionary_hashtable_bucket **newData;
uint32_t i, newSize;
if (newCount > UINT32_MAX)
@throw [OFOutOfRangeException exceptionWithClass: [self class]];
if (fullness >= 3)
newSize = size << 1;
else if (fullness <= 1)
newSize = size >> 1;
else
return;
if (newSize == 0)
@throw [OFOutOfRangeException exceptionWithClass: [self class]];
newData = [self allocMemoryWithSize: sizeof(*newData)
count: newSize];
for (i = 0; i < newSize; i++)
newData[i] = NULL;
|
︙ | | | ︙ | |
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
|
for (j = 0; j < last &&
newData[j] != NULL; j++);
}
if (j >= last) {
[self freeMemory: newData];
@throw [OFOutOfRangeException
exceptionWithClass: isa];
}
newData[j] = data[i];
}
}
[self freeMemory: data];
data = newData;
size = newSize;
}
- (void)_setObject: (id)object
forKey: (id)key
copyKey: (BOOL)copyKey
{
uint32_t i, hash, last;
id old;
if (key == nil || object == nil)
@throw [OFInvalidArgumentException exceptionWithClass: isa
selector: _cmd];
hash = [key hash];
last = size;
for (i = hash & (size - 1); i < last && data[i] != NULL; i++) {
if (data[i] == DELETED)
|
|
|
>
|
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
|
for (j = 0; j < last &&
newData[j] != NULL; j++);
}
if (j >= last) {
[self freeMemory: newData];
@throw [OFOutOfRangeException
exceptionWithClass: [self class]];
}
newData[j] = data[i];
}
}
[self freeMemory: data];
data = newData;
size = newSize;
}
- (void)_setObject: (id)object
forKey: (id)key
copyKey: (BOOL)copyKey
{
uint32_t i, hash, last;
id old;
if (key == nil || object == nil)
@throw [OFInvalidArgumentException
exceptionWithClass: [self class]
selector: _cmd];
hash = [key hash];
last = size;
for (i = hash & (size - 1); i < last && data[i] != NULL; i++) {
if (data[i] == DELETED)
|
︙ | | | ︙ | |
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
|
last = hash & (size - 1);
for (i = 0; i < last && data[i] != NULL &&
data[i] != DELETED; i++);
}
if (i >= last)
@throw [OFOutOfRangeException exceptionWithClass: isa];
bucket = [self allocMemoryWithSize: sizeof(*bucket)];
if (copyKey) {
@try {
bucket->key = [key copy];
} @catch (id e) {
|
|
>
|
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
|
last = hash & (size - 1);
for (i = 0; i < last && data[i] != NULL &&
data[i] != DELETED; i++);
}
if (i >= last)
@throw [OFOutOfRangeException
exceptionWithClass: [self class]];
bucket = [self allocMemoryWithSize: sizeof(*bucket)];
if (copyKey) {
@try {
bucket->key = [key copy];
} @catch (id e) {
|
︙ | | | ︙ | |
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
|
}
- (void)removeObjectForKey: (id)key
{
uint32_t i, hash, last;
if (key == nil)
@throw [OFInvalidArgumentException exceptionWithClass: isa
selector: _cmd];
hash = [key hash];
last = size;
for (i = hash & (size - 1); i < last && data[i] != NULL; i++) {
if (data[i] == DELETED)
|
|
>
|
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
|
}
- (void)removeObjectForKey: (id)key
{
uint32_t i, hash, last;
if (key == nil)
@throw [OFInvalidArgumentException
exceptionWithClass: [self class]
selector: _cmd];
hash = [key hash];
last = size;
for (i = hash & (size - 1); i < last && data[i] != NULL; i++) {
if (data[i] == DELETED)
|
︙ | | | ︙ | |
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
|
size_t i;
BOOL stop = NO;
unsigned long mutations2 = mutations;
for (i = 0; i < size && !stop; i++) {
if (mutations != mutations2)
@throw [OFEnumerationMutationException
exceptionWithClass: isa
object: self];
if (data[i] != NULL && data[i] != DELETED)
block(data[i]->key, data[i]->object, &stop);
}
}
- (void)replaceObjectsUsingBlock: (of_dictionary_replace_block_t)block
{
size_t i;
BOOL stop = NO;
unsigned long mutations2 = mutations;
for (i = 0; i < size && !stop; i++) {
if (mutations != mutations2)
@throw [OFEnumerationMutationException
exceptionWithClass: isa
object: self];
if (data[i] != NULL && data[i] != DELETED) {
id new = block(data[i]->key, data[i]->object, &stop);
if (new == nil)
@throw [OFInvalidArgumentException
exceptionWithClass: isa
selector: _cmd];
[new retain];
[data[i]->object release];
data[i]->object = new;
}
}
}
#endif
- (void)makeImmutable
{
isa = [OFDictionary_hashtable class];
}
@end
|
|
|
|
|
|
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
335
336
337
|
size_t i;
BOOL stop = NO;
unsigned long mutations2 = mutations;
for (i = 0; i < size && !stop; i++) {
if (mutations != mutations2)
@throw [OFEnumerationMutationException
exceptionWithClass: [self class]
object: self];
if (data[i] != NULL && data[i] != DELETED)
block(data[i]->key, data[i]->object, &stop);
}
}
- (void)replaceObjectsUsingBlock: (of_dictionary_replace_block_t)block
{
size_t i;
BOOL stop = NO;
unsigned long mutations2 = mutations;
for (i = 0; i < size && !stop; i++) {
if (mutations != mutations2)
@throw [OFEnumerationMutationException
exceptionWithClass: [self class]
object: self];
if (data[i] != NULL && data[i] != DELETED) {
id new = block(data[i]->key, data[i]->object, &stop);
if (new == nil)
@throw [OFInvalidArgumentException
exceptionWithClass: [self class]
selector: _cmd];
[new retain];
[data[i]->object release];
data[i]->object = new;
}
}
}
#endif
- (void)makeImmutable
{
object_setClass(self, [OFDictionary_hashtable class]);
}
@end
|
Modified src/OFMutableSet.m
from [ae4b0f4644]
to [cfc47921d9].
︙ | | | ︙ | |
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
|
- (void)release
{
}
- (void)dealloc
{
@throw [OFNotImplementedException exceptionWithClass: isa
selector: _cmd];
[super dealloc]; /* Get rid of a stupid warning */
}
@end
@implementation OFMutableSet
+ (void)initialize
{
if (self == [OFMutableSet class])
placeholder.isa = [OFMutableSet_placeholder class];
}
+ alloc
{
if (self == [OFMutableSet class])
return (id)&placeholder;
return [super alloc];
}
- init
{
if (isa == [OFMutableSet class]) {
Class c = isa;
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
return [super init];
}
- (void)addObject: (id)object
{
@throw [OFNotImplementedException exceptionWithClass: isa
selector: _cmd];
}
- (void)removeObject: (id)object
{
@throw [OFNotImplementedException exceptionWithClass: isa
selector: _cmd];
}
- (void)minusSet: (OFSet*)set
{
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
OFEnumerator *enumerator = [set objectEnumerator];
|
|
>
|
|
|
|
|
|
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
|
- (void)release
{
}
- (void)dealloc
{
@throw [OFNotImplementedException exceptionWithClass: [self class]
selector: _cmd];
[super dealloc]; /* Get rid of a stupid warning */
}
@end
@implementation OFMutableSet
+ (void)initialize
{
if (self == [OFMutableSet class])
object_setClass((id)&placeholder,
[OFMutableSet_placeholder class]);
}
+ alloc
{
if (self == [OFMutableSet class])
return (id)&placeholder;
return [super alloc];
}
- init
{
if (object_getClass(self) == [OFMutableSet class]) {
Class c = [self class];
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
return [super init];
}
- (void)addObject: (id)object
{
@throw [OFNotImplementedException exceptionWithClass: [self class]
selector: _cmd];
}
- (void)removeObject: (id)object
{
@throw [OFNotImplementedException exceptionWithClass: [self class]
selector: _cmd];
}
- (void)minusSet: (OFSet*)set
{
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
OFEnumerator *enumerator = [set objectEnumerator];
|
︙ | | | ︙ | |
Modified src/OFMutableSet_hashtable.m
from [d5483ec005]
to [a0924df2b2].
︙ | | | ︙ | |
45
46
47
48
49
50
51
52
53
54
|
[dictionary removeObjectForKey: object];
mutations++;
}
- (void)makeImmutable
{
isa = [OFSet_hashtable class];
}
@end
|
|
|
45
46
47
48
49
50
51
52
53
54
|
[dictionary removeObjectForKey: object];
mutations++;
}
- (void)makeImmutable
{
object_setClass(self, [OFSet_hashtable class]);
}
@end
|
Modified src/OFMutableString.m
from [a950dfa678]
to [dd89e81e6e].
︙ | | | ︙ | |
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
|
- (void)release
{
}
- (void)dealloc
{
@throw [OFNotImplementedException exceptionWithClass: isa
selector: _cmd];
[super dealloc]; /* Get rid of a stupid warning */
}
@end
@implementation OFMutableString
+ (void)initialize
{
if (self == [OFMutableString class])
placeholder.isa = [OFMutableString_placeholder class];
}
+ alloc
{
if (self == [OFMutableString class])
return (id)&placeholder;
|
|
>
|
|
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
|
- (void)release
{
}
- (void)dealloc
{
@throw [OFNotImplementedException exceptionWithClass: [self class]
selector: _cmd];
[super dealloc]; /* Get rid of a stupid warning */
}
@end
@implementation OFMutableString
+ (void)initialize
{
if (self == [OFMutableString class])
object_setClass((id)&placeholder,
[OFMutableString_placeholder class]);
}
+ alloc
{
if (self == [OFMutableString class])
return (id)&placeholder;
|
︙ | | | ︙ | |
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
|
[pool release];
}
- (void)setCharacter: (of_unichar_t)character
atIndex: (size_t)index
{
@throw [OFNotImplementedException exceptionWithClass: isa
selector: _cmd];
}
- (void)appendUTF8String: (const char*)UTF8String
{
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
|
|
|
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
|
[pool release];
}
- (void)setCharacter: (of_unichar_t)character
atIndex: (size_t)index
{
@throw [OFNotImplementedException exceptionWithClass: [self class]
selector: _cmd];
}
- (void)appendUTF8String: (const char*)UTF8String
{
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
|
︙ | | | ︙ | |
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
|
- (void)appendFormat: (OFConstantString*)format
withArguments: (va_list)arguments
{
char *UTF8String;
int UTF8StringLength;
if (format == nil)
@throw [OFInvalidArgumentException exceptionWithClass: isa
selector: _cmd];
if ((UTF8StringLength = of_vasprintf(&UTF8String, [format UTF8String],
arguments)) == -1)
@throw [OFInvalidFormatException exceptionWithClass: isa];
@try {
[self appendUTF8String: UTF8String
withLength: UTF8StringLength];
} @finally {
free(UTF8String);
}
|
|
>
|
>
|
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
|
- (void)appendFormat: (OFConstantString*)format
withArguments: (va_list)arguments
{
char *UTF8String;
int UTF8StringLength;
if (format == nil)
@throw [OFInvalidArgumentException
exceptionWithClass: [self class]
selector: _cmd];
if ((UTF8StringLength = of_vasprintf(&UTF8String, [format UTF8String],
arguments)) == -1)
@throw [OFInvalidFormatException
exceptionWithClass: [self class]];
@try {
[self appendUTF8String: UTF8String
withLength: UTF8StringLength];
} @finally {
free(UTF8String);
}
|
︙ | | | ︙ | |
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
|
wordStartTableSize: OF_UNICODE_TITLECASE_TABLE_SIZE
wordMiddleTableSize: OF_UNICODE_LOWERCASE_TABLE_SIZE];
}
- (void)insertString: (OFString*)string
atIndex: (size_t)index
{
@throw [OFNotImplementedException exceptionWithClass: isa
selector: _cmd];
}
- (void)deleteCharactersInRange: (of_range_t)range
{
@throw [OFNotImplementedException exceptionWithClass: isa
selector: _cmd];
}
- (void)replaceCharactersInRange: (of_range_t)range
withString: (OFString*)replacement
{
[self deleteCharactersInRange: range];
|
|
|
|
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
|
wordStartTableSize: OF_UNICODE_TITLECASE_TABLE_SIZE
wordMiddleTableSize: OF_UNICODE_LOWERCASE_TABLE_SIZE];
}
- (void)insertString: (OFString*)string
atIndex: (size_t)index
{
@throw [OFNotImplementedException exceptionWithClass: [self class]
selector: _cmd];
}
- (void)deleteCharactersInRange: (of_range_t)range
{
@throw [OFNotImplementedException exceptionWithClass: [self class]
selector: _cmd];
}
- (void)replaceCharactersInRange: (of_range_t)range
withString: (OFString*)replacement
{
[self deleteCharactersInRange: range];
|
︙ | | | ︙ | |
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
|
const of_unichar_t *unicodeString;
const of_unichar_t *searchString = [string unicodeString];
size_t searchLength = [string length];
size_t replacementLength = [replacement length];
size_t i;
if (range.start + range.length > [self length])
@throw [OFOutOfRangeException exceptionWithClass: isa];
if (searchLength > range.length) {
[pool release];
return;
}
pool2 = [[OFAutoreleasePool alloc] init];
|
|
|
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
|
const of_unichar_t *unicodeString;
const of_unichar_t *searchString = [string unicodeString];
size_t searchLength = [string length];
size_t replacementLength = [replacement length];
size_t i;
if (range.start + range.length > [self length])
@throw [OFOutOfRangeException exceptionWithClass: [self class]];
if (searchLength > range.length) {
[pool release];
return;
}
pool2 = [[OFAutoreleasePool alloc] init];
|
︙ | | | ︙ | |
Modified src/OFMutableString_UTF8.m
from [665667dba6]
to [79591b5b1e].
︙ | | | ︙ | |
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
|
cLen = of_string_utf8_to_unicode(s->cString + i,
s->cStringLength - i, &c);
if (cLen == 0 || c > 0x10FFFF) {
[self freeMemory: unicodeString];
@throw [OFInvalidEncodingException
exceptionWithClass: isa];
}
switch (c) {
case ' ':
case '\t':
case '\n':
case '\r':
|
|
|
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
|
cLen = of_string_utf8_to_unicode(s->cString + i,
s->cStringLength - i, &c);
if (cLen == 0 || c > 0x10FFFF) {
[self freeMemory: unicodeString];
@throw [OFInvalidEncodingException
exceptionWithClass: [self class]];
}
switch (c) {
case ' ':
case '\t':
case '\n':
case '\r':
|
︙ | | | ︙ | |
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
|
else if (c < 0x10000)
newCStringLength += 3;
else if (c < 0x110000)
newCStringLength += 4;
else {
[self freeMemory: unicodeString];
@throw [OFInvalidEncodingException
exceptionWithClass: isa];
}
i += cLen;
}
@try {
newCString = [self allocMemoryWithSize: newCStringLength + 1];
|
|
|
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
|
else if (c < 0x10000)
newCStringLength += 3;
else if (c < 0x110000)
newCStringLength += 4;
else {
[self freeMemory: unicodeString];
@throw [OFInvalidEncodingException
exceptionWithClass: [self class]];
}
i += cLen;
}
@try {
newCString = [self allocMemoryWithSize: newCStringLength + 1];
|
︙ | | | ︙ | |
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
|
size_t d;
if ((d = of_string_unicode_to_utf8(unicodeString[i],
newCString + j)) == 0) {
[self freeMemory: unicodeString];
[self freeMemory: newCString];
@throw [OFInvalidEncodingException
exceptionWithClass: isa];
}
j += d;
}
assert(j == newCStringLength);
newCString[j] = 0;
[self freeMemory: unicodeString];
|
|
|
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
|
size_t d;
if ((d = of_string_unicode_to_utf8(unicodeString[i],
newCString + j)) == 0) {
[self freeMemory: unicodeString];
[self freeMemory: newCString];
@throw [OFInvalidEncodingException
exceptionWithClass: [self class]];
}
j += d;
}
assert(j == newCStringLength);
newCString[j] = 0;
[self freeMemory: unicodeString];
|
︙ | | | ︙ | |
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
|
if (!(character & 0x80) && !(s->cString[index] & 0x80)) {
s->hashed = NO;
s->cString[index] = character;
return;
}
if ((length = of_string_unicode_to_utf8(character, buffer)) == 0)
@throw [OFInvalidEncodingException exceptionWithClass: isa];
if ((oldLength = of_string_utf8_to_unicode(s->cString + index,
s->cStringLength - index, &c)) == 0)
@throw [OFInvalidEncodingException exceptionWithClass: isa];
s->hashed = NO;
if (length == oldLength) {
memcpy(s->cString + index, buffer, length);
return;
}
|
|
>
|
>
|
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
|
if (!(character & 0x80) && !(s->cString[index] & 0x80)) {
s->hashed = NO;
s->cString[index] = character;
return;
}
if ((length = of_string_unicode_to_utf8(character, buffer)) == 0)
@throw [OFInvalidEncodingException
exceptionWithClass: [self class]];
if ((oldLength = of_string_utf8_to_unicode(s->cString + index,
s->cStringLength - index, &c)) == 0)
@throw [OFInvalidEncodingException
exceptionWithClass: [self class]];
s->hashed = NO;
if (length == oldLength) {
memcpy(s->cString + index, buffer, length);
return;
}
|
︙ | | | ︙ | |
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
|
}
switch (of_string_check_utf8(UTF8String, UTF8StringLength, &length)) {
case 1:
s->UTF8 = YES;
break;
case -1:
@throw [OFInvalidEncodingException exceptionWithClass: isa];
}
s->hashed = NO;
s->cString = [self resizeMemory: s->cString
size: s->cStringLength +
UTF8StringLength + 1];
memcpy(s->cString + s->cStringLength, UTF8String, UTF8StringLength + 1);
|
|
>
|
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
|
}
switch (of_string_check_utf8(UTF8String, UTF8StringLength, &length)) {
case 1:
s->UTF8 = YES;
break;
case -1:
@throw [OFInvalidEncodingException
exceptionWithClass: [self class]];
}
s->hashed = NO;
s->cString = [self resizeMemory: s->cString
size: s->cStringLength +
UTF8StringLength + 1];
memcpy(s->cString + s->cStringLength, UTF8String, UTF8StringLength + 1);
|
︙ | | | ︙ | |
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
|
}
switch (of_string_check_utf8(UTF8String, UTF8StringLength, &length)) {
case 1:
s->UTF8 = YES;
break;
case -1:
@throw [OFInvalidEncodingException exceptionWithClass: isa];
}
s->hashed = NO;
s->cString = [self resizeMemory: s->cString
size: s->cStringLength +
UTF8StringLength + 1];
memcpy(s->cString + s->cStringLength, UTF8String, UTF8StringLength);
|
|
>
|
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
|
}
switch (of_string_check_utf8(UTF8String, UTF8StringLength, &length)) {
case 1:
s->UTF8 = YES;
break;
case -1:
@throw [OFInvalidEncodingException
exceptionWithClass: [self class]];
}
s->hashed = NO;
s->cString = [self resizeMemory: s->cString
size: s->cStringLength +
UTF8StringLength + 1];
memcpy(s->cString + s->cStringLength, UTF8String, UTF8StringLength);
|
︙ | | | ︙ | |
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
|
}
- (void)appendString: (OFString*)string
{
size_t UTF8StringLength;
if (string == nil)
@throw [OFInvalidArgumentException exceptionWithClass: isa
selector: _cmd];
UTF8StringLength = [string UTF8StringLength];
s->hashed = NO;
s->cString = [self resizeMemory: s->cString
size: s->cStringLength +
|
|
>
|
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
|
}
- (void)appendString: (OFString*)string
{
size_t UTF8StringLength;
if (string == nil)
@throw [OFInvalidArgumentException
exceptionWithClass: [self class]
selector: _cmd];
UTF8StringLength = [string UTF8StringLength];
s->hashed = NO;
s->cString = [self resizeMemory: s->cString
size: s->cStringLength +
|
︙ | | | ︙ | |
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
|
- (void)appendFormat: (OFConstantString*)format
withArguments: (va_list)arguments
{
char *UTF8String;
int UTF8StringLength;
if (format == nil)
@throw [OFInvalidArgumentException exceptionWithClass: isa
selector: _cmd];
if ((UTF8StringLength = of_vasprintf(&UTF8String, [format UTF8String],
arguments)) == -1)
@throw [OFInvalidFormatException exceptionWithClass: isa];
@try {
[self appendUTF8String: UTF8String
withLength: UTF8StringLength];
} @finally {
free(UTF8String);
}
|
|
>
|
>
|
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
|
- (void)appendFormat: (OFConstantString*)format
withArguments: (va_list)arguments
{
char *UTF8String;
int UTF8StringLength;
if (format == nil)
@throw [OFInvalidArgumentException
exceptionWithClass: [self class]
selector: _cmd];
if ((UTF8StringLength = of_vasprintf(&UTF8String, [format UTF8String],
arguments)) == -1)
@throw [OFInvalidFormatException
exceptionWithClass: [self class]];
@try {
[self appendUTF8String: UTF8String
withLength: UTF8StringLength];
} @finally {
free(UTF8String);
}
|
︙ | | | ︙ | |
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
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
495
496
497
498
499
500
501
|
/* ASCII */
if (OF_LIKELY(!(s->cString[i] & 0x80)))
continue;
/* A start byte can't happen first as we reversed everything */
if (OF_UNLIKELY(s->cString[i] & 0x40))
@throw [OFInvalidEncodingException
exceptionWithClass: isa];
/* Next byte must not be ASCII */
if (OF_UNLIKELY(s->cStringLength < i + 1 ||
!(s->cString[i + 1] & 0x80)))
@throw [OFInvalidEncodingException
exceptionWithClass: isa];
/* Next byte is the start byte */
if (OF_LIKELY(s->cString[i + 1] & 0x40)) {
s->cString[i] ^= s->cString[i + 1];
s->cString[i + 1] ^= s->cString[i];
s->cString[i] ^= s->cString[i + 1];
i++;
continue;
}
/* Second next byte must not be ASCII */
if (OF_UNLIKELY(s->cStringLength < i + 2 ||
!(s->cString[i + 2] & 0x80)))
@throw [OFInvalidEncodingException
exceptionWithClass: isa];
/* Second next byte is the start byte */
if (OF_LIKELY(s->cString[i + 2] & 0x40)) {
s->cString[i] ^= s->cString[i + 2];
s->cString[i + 2] ^= s->cString[i];
s->cString[i] ^= s->cString[i + 2];
i += 2;
continue;
}
/* Third next byte must not be ASCII */
if (OF_UNLIKELY(s->cStringLength < i + 3 ||
!(s->cString[i + 3] & 0x80)))
@throw [OFInvalidEncodingException
exceptionWithClass: isa];
/* Third next byte is the start byte */
if (OF_LIKELY(s->cString[i + 3] & 0x40)) {
s->cString[i] ^= s->cString[i + 3];
s->cString[i + 3] ^= s->cString[i];
s->cString[i] ^= s->cString[i + 3];
s->cString[i + 1] ^= s->cString[i + 2];
s->cString[i + 2] ^= s->cString[i + 1];
s->cString[i + 1] ^= s->cString[i + 2];
i += 3;
continue;
}
/* UTF-8 does not allow more than 4 bytes per character */
@throw [OFInvalidEncodingException exceptionWithClass: isa];
}
}
- (void)insertString: (OFString*)string
atIndex: (size_t)index
{
size_t newCStringLength;
if (index > s->length)
@throw [OFOutOfRangeException exceptionWithClass: isa];
if (s->UTF8)
index = of_string_index_to_position(s->cString, index,
s->cStringLength);
newCStringLength = s->cStringLength + [string UTF8StringLength];
s->hashed = NO;
|
|
|
|
|
|
>
|
>
|
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
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
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
|
/* ASCII */
if (OF_LIKELY(!(s->cString[i] & 0x80)))
continue;
/* A start byte can't happen first as we reversed everything */
if (OF_UNLIKELY(s->cString[i] & 0x40))
@throw [OFInvalidEncodingException
exceptionWithClass: [self class]];
/* Next byte must not be ASCII */
if (OF_UNLIKELY(s->cStringLength < i + 1 ||
!(s->cString[i + 1] & 0x80)))
@throw [OFInvalidEncodingException
exceptionWithClass: [self class]];
/* Next byte is the start byte */
if (OF_LIKELY(s->cString[i + 1] & 0x40)) {
s->cString[i] ^= s->cString[i + 1];
s->cString[i + 1] ^= s->cString[i];
s->cString[i] ^= s->cString[i + 1];
i++;
continue;
}
/* Second next byte must not be ASCII */
if (OF_UNLIKELY(s->cStringLength < i + 2 ||
!(s->cString[i + 2] & 0x80)))
@throw [OFInvalidEncodingException
exceptionWithClass: [self class]];
/* Second next byte is the start byte */
if (OF_LIKELY(s->cString[i + 2] & 0x40)) {
s->cString[i] ^= s->cString[i + 2];
s->cString[i + 2] ^= s->cString[i];
s->cString[i] ^= s->cString[i + 2];
i += 2;
continue;
}
/* Third next byte must not be ASCII */
if (OF_UNLIKELY(s->cStringLength < i + 3 ||
!(s->cString[i + 3] & 0x80)))
@throw [OFInvalidEncodingException
exceptionWithClass: [self class]];
/* Third next byte is the start byte */
if (OF_LIKELY(s->cString[i + 3] & 0x40)) {
s->cString[i] ^= s->cString[i + 3];
s->cString[i + 3] ^= s->cString[i];
s->cString[i] ^= s->cString[i + 3];
s->cString[i + 1] ^= s->cString[i + 2];
s->cString[i + 2] ^= s->cString[i + 1];
s->cString[i + 1] ^= s->cString[i + 2];
i += 3;
continue;
}
/* UTF-8 does not allow more than 4 bytes per character */
@throw [OFInvalidEncodingException
exceptionWithClass: [self class]];
}
}
- (void)insertString: (OFString*)string
atIndex: (size_t)index
{
size_t newCStringLength;
if (index > s->length)
@throw [OFOutOfRangeException
exceptionWithClass: [self class]];
if (s->UTF8)
index = of_string_index_to_position(s->cString, index,
s->cStringLength);
newCStringLength = s->cStringLength + [string UTF8StringLength];
s->hashed = NO;
|
︙ | | | ︙ | |
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
|
- (void)deleteCharactersInRange: (of_range_t)range
{
size_t start = range.start;
size_t end = range.start + range.length;
if (end > s->length)
@throw [OFOutOfRangeException exceptionWithClass: isa];
s->hashed = NO;
s->length -= end - start;
if (s->UTF8) {
start = of_string_index_to_position(s->cString, start,
s->cStringLength);
|
|
|
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
|
- (void)deleteCharactersInRange: (of_range_t)range
{
size_t start = range.start;
size_t end = range.start + range.length;
if (end > s->length)
@throw [OFOutOfRangeException exceptionWithClass: [self class]];
s->hashed = NO;
s->length -= end - start;
if (s->UTF8) {
start = of_string_index_to_position(s->cString, start,
s->cStringLength);
|
︙ | | | ︙ | |
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
|
withString: (OFString*)replacement
{
size_t start = range.start;
size_t end = range.start + range.length;
size_t newCStringLength, newLength;
if (end > s->length)
@throw [OFOutOfRangeException exceptionWithClass: isa];
newLength = s->length - (end - start) + [replacement length];
if (s->UTF8) {
start = of_string_index_to_position(s->cString, start,
s->cStringLength);
end = of_string_index_to_position(s->cString, end,
|
|
|
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
|
withString: (OFString*)replacement
{
size_t start = range.start;
size_t end = range.start + range.length;
size_t newCStringLength, newLength;
if (end > s->length)
@throw [OFOutOfRangeException exceptionWithClass: [self class]];
newLength = s->length - (end - start) + [replacement length];
if (s->UTF8) {
start = of_string_index_to_position(s->cString, start,
s->cStringLength);
end = of_string_index_to_position(s->cString, end,
|
︙ | | | ︙ | |
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
|
range.start = of_string_index_to_position(s->cString,
range.start, s->cStringLength);
range.length = of_string_index_to_position(s->cString,
range.start + range.length, s->cStringLength) - range.start;
}
if (range.start + range.length > [self UTF8StringLength])
@throw [OFOutOfRangeException exceptionWithClass: isa];
if ([string UTF8StringLength] > range.length)
return;
newCString = NULL;
newCStringLength = 0;
newLength = s->length;
|
|
|
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
|
range.start = of_string_index_to_position(s->cString,
range.start, s->cStringLength);
range.length = of_string_index_to_position(s->cString,
range.start + range.length, s->cStringLength) - range.start;
}
if (range.start + range.length > [self UTF8StringLength])
@throw [OFOutOfRangeException exceptionWithClass: [self class]];
if ([string UTF8StringLength] > range.length)
return;
newCString = NULL;
newCStringLength = 0;
newLength = s->length;
|
︙ | | | ︙ | |
748
749
750
751
752
753
754
755
756
757
|
} @catch (OFOutOfMemoryException *e) {
/* We don't really care, as we only made it smaller */
}
}
- (void)makeImmutable
{
isa = [OFString_UTF8 class];
}
@end
|
|
|
757
758
759
760
761
762
763
764
765
766
|
} @catch (OFOutOfMemoryException *e) {
/* We don't really care, as we only made it smaller */
}
}
- (void)makeImmutable
{
object_setClass(self, [OFString_UTF8 class]);
}
@end
|
Modified src/OFNull.m
from [3617640ff6]
to [2dd9bd511c].
︙ | | | ︙ | |
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
[self release];
pool = [[OFAutoreleasePool alloc] init];
if (![[element name] isEqual: [self className]] ||
![[element namespace] isEqual: OF_SERIALIZATION_NS])
@throw [OFInvalidArgumentException exceptionWithClass: isa
selector: _cmd];
[pool release];
return [OFNull null];
}
|
|
>
|
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
[self release];
pool = [[OFAutoreleasePool alloc] init];
if (![[element name] isEqual: [self className]] ||
![[element namespace] isEqual: OF_SERIALIZATION_NS])
@throw [OFInvalidArgumentException
exceptionWithClass: [self class]
selector: _cmd];
[pool release];
return [OFNull null];
}
|
︙ | | | ︙ | |
102
103
104
105
106
107
108
109
110
111
112
113
|
- (unsigned int)retainCount
{
return OF_RETAIN_COUNT_MAX;
}
- (void)dealloc
{
@throw [OFNotImplementedException exceptionWithClass: isa
selector: _cmd];
[super dealloc]; /* Get rid of a stupid warning */
}
@end
|
|
|
103
104
105
106
107
108
109
110
111
112
113
114
|
- (unsigned int)retainCount
{
return OF_RETAIN_COUNT_MAX;
}
- (void)dealloc
{
@throw [OFNotImplementedException exceptionWithClass: [self class]
selector: _cmd];
[super dealloc]; /* Get rid of a stupid warning */
}
@end
|
Modified src/OFNumber.m
from [3bd254e0cf]
to [b82d9f97c4].
︙ | | | ︙ | |
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
return (t)value.uintptr; \
case OF_NUMBER_FLOAT: \
return (t)value.float_; \
case OF_NUMBER_DOUBLE: \
return (t)value.double_; \
default: \
@throw [OFInvalidFormatException \
exceptionWithClass: isa]; \
}
#define CALCULATE(o, n) \
switch (type) { \
case OF_NUMBER_BOOL: \
return [OFNumber numberWithBool: \
value.bool_ o [n boolValue]]; \
case OF_NUMBER_CHAR: \
|
|
|
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
return (t)value.uintptr; \
case OF_NUMBER_FLOAT: \
return (t)value.float_; \
case OF_NUMBER_DOUBLE: \
return (t)value.double_; \
default: \
@throw [OFInvalidFormatException \
exceptionWithClass: [self class]]; \
}
#define CALCULATE(o, n) \
switch (type) { \
case OF_NUMBER_BOOL: \
return [OFNumber numberWithBool: \
value.bool_ o [n boolValue]]; \
case OF_NUMBER_CHAR: \
|
︙ | | | ︙ | |
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
|
return [OFNumber numberWithFloat: \
value.float_ o [n floatValue]]; \
case OF_NUMBER_DOUBLE: \
return [OFNumber numberWithDouble: \
value.double_ o [n doubleValue]]; \
default: \
@throw [OFInvalidFormatException \
exceptionWithClass: isa]; \
}
#define CALCULATE2(o, n) \
switch (type) { \
case OF_NUMBER_BOOL: \
return [OFNumber numberWithBool: \
value.bool_ o [n boolValue]]; \
case OF_NUMBER_CHAR: \
|
|
|
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
|
return [OFNumber numberWithFloat: \
value.float_ o [n floatValue]]; \
case OF_NUMBER_DOUBLE: \
return [OFNumber numberWithDouble: \
value.double_ o [n doubleValue]]; \
default: \
@throw [OFInvalidFormatException \
exceptionWithClass: [self class]]; \
}
#define CALCULATE2(o, n) \
switch (type) { \
case OF_NUMBER_BOOL: \
return [OFNumber numberWithBool: \
value.bool_ o [n boolValue]]; \
case OF_NUMBER_CHAR: \
|
︙ | | | ︙ | |
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
|
value.intptr o [n intPtrValue]]; \
case OF_NUMBER_UINTPTR: \
return [OFNumber numberWithUIntPtr: \
value.uintptr o [n uIntPtrValue]]; \
case OF_NUMBER_FLOAT: \
case OF_NUMBER_DOUBLE: \
@throw [OFNotImplementedException \
exceptionWithClass: isa \
selector: _cmd]; \
default: \
@throw [OFInvalidFormatException \
exceptionWithClass: isa]; \
}
#define CALCULATE3(o) \
switch (type) { \
case OF_NUMBER_BOOL: \
return [OFNumber numberWithBool: value.bool_ o]; \
case OF_NUMBER_CHAR: \
return [OFNumber numberWithChar: value.char_ o]; \
|
|
|
|
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
|
value.intptr o [n intPtrValue]]; \
case OF_NUMBER_UINTPTR: \
return [OFNumber numberWithUIntPtr: \
value.uintptr o [n uIntPtrValue]]; \
case OF_NUMBER_FLOAT: \
case OF_NUMBER_DOUBLE: \
@throw [OFNotImplementedException \
exceptionWithClass: [self class] \
selector: _cmd]; \
default: \
@throw [OFInvalidFormatException \
exceptionWithClass: [self class]]; \
}
#define CALCULATE3(o) \
switch (type) { \
case OF_NUMBER_BOOL: \
return [OFNumber numberWithBool: value.bool_ o]; \
case OF_NUMBER_CHAR: \
return [OFNumber numberWithChar: value.char_ o]; \
|
︙ | | | ︙ | |
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
|
return [OFNumber numberWithUIntPtr: value.uintptr o]; \
case OF_NUMBER_FLOAT: \
return [OFNumber numberWithFloat: value.float_ o]; \
case OF_NUMBER_DOUBLE: \
return [OFNumber numberWithDouble: value.double_ o]; \
default: \
@throw [OFInvalidFormatException \
exceptionWithClass: isa]; \
}
@implementation OFNumber
+ numberWithBool: (BOOL)bool_
{
return [[[self alloc] initWithBool: bool_] autorelease];
}
|
|
|
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
|
return [OFNumber numberWithUIntPtr: value.uintptr o]; \
case OF_NUMBER_FLOAT: \
return [OFNumber numberWithFloat: value.float_ o]; \
case OF_NUMBER_DOUBLE: \
return [OFNumber numberWithDouble: value.double_ o]; \
default: \
@throw [OFInvalidFormatException \
exceptionWithClass: [self class]]; \
}
@implementation OFNumber
+ numberWithBool: (BOOL)bool_
{
return [[[self alloc] initWithBool: bool_] autorelease];
}
|
︙ | | | ︙ | |
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
|
+ numberWithDouble: (double)double_
{
return [[[self alloc] initWithDouble: double_] autorelease];
}
- init
{
@throw [OFNotImplementedException exceptionWithClass: isa
selector: _cmd];
}
- initWithBool: (BOOL)bool_
{
self = [super init];
|
|
|
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
|
+ numberWithDouble: (double)double_
{
return [[[self alloc] initWithDouble: double_] autorelease];
}
- init
{
@throw [OFNotImplementedException exceptionWithClass: [self class]
selector: _cmd];
}
- initWithBool: (BOOL)bool_
{
self = [super init];
|
︙ | | | ︙ | |
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
765
766
767
768
769
|
@try {
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
OFString *typeString;
if (![[element name] isEqual: [self className]] ||
![[element namespace] isEqual: OF_SERIALIZATION_NS])
@throw [OFInvalidArgumentException
exceptionWithClass: isa
selector: _cmd];
typeString = [[element attributeForName: @"type"] stringValue];
if ([typeString isEqual: @"boolean"]) {
type = OF_NUMBER_BOOL;
if ([[element stringValue] isEqual: @"YES"])
value.bool_ = YES;
else if ([[element stringValue] isEqual: @"NO"])
value.bool_ = NO;
else
@throw [OFInvalidArgumentException
exceptionWithClass: isa
selector: _cmd];
} else if ([typeString isEqual: @"unsigned"]) {
/*
* FIXME: This will fail if the value is bigger than
* INTMAX_MAX!
*/
type = OF_NUMBER_UINTMAX;
value.uintmax = [element decimalValue];
} else if ([typeString isEqual: @"signed"]) {
type = OF_NUMBER_INTMAX;
value.intmax = [element decimalValue];
} else if ([typeString isEqual: @"float"]) {
type = OF_NUMBER_FLOAT;
value.float_ = [element floatValue];
} else if ([typeString isEqual: @"double"]) {
type = OF_NUMBER_DOUBLE;
value.double_ = [element doubleValue];
} else
@throw [OFInvalidArgumentException
exceptionWithClass: isa
selector: _cmd];
[pool release];
} @catch (id e) {
[self release];
@throw e;
}
|
|
|
|
|
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
765
766
767
768
769
|
@try {
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
OFString *typeString;
if (![[element name] isEqual: [self className]] ||
![[element namespace] isEqual: OF_SERIALIZATION_NS])
@throw [OFInvalidArgumentException
exceptionWithClass: [self class]
selector: _cmd];
typeString = [[element attributeForName: @"type"] stringValue];
if ([typeString isEqual: @"boolean"]) {
type = OF_NUMBER_BOOL;
if ([[element stringValue] isEqual: @"YES"])
value.bool_ = YES;
else if ([[element stringValue] isEqual: @"NO"])
value.bool_ = NO;
else
@throw [OFInvalidArgumentException
exceptionWithClass: [self class]
selector: _cmd];
} else if ([typeString isEqual: @"unsigned"]) {
/*
* FIXME: This will fail if the value is bigger than
* INTMAX_MAX!
*/
type = OF_NUMBER_UINTMAX;
value.uintmax = [element decimalValue];
} else if ([typeString isEqual: @"signed"]) {
type = OF_NUMBER_INTMAX;
value.intmax = [element decimalValue];
} else if ([typeString isEqual: @"float"]) {
type = OF_NUMBER_FLOAT;
value.float_ = [element floatValue];
} else if ([typeString isEqual: @"double"]) {
type = OF_NUMBER_DOUBLE;
value.double_ = [element doubleValue];
} else
@throw [OFInvalidArgumentException
exceptionWithClass: [self class]
selector: _cmd];
[pool release];
} @catch (id e) {
[self release];
@throw e;
}
|
︙ | | | ︙ | |
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
|
case OF_NUMBER_FLOAT:
return [OFNumber
numberWithFloat: fmodf(value.float_, [number floatValue])];
case OF_NUMBER_DOUBLE:
return [OFNumber numberWithDouble:
fmod(value.double_, [number doubleValue])];
default:
@throw [OFInvalidFormatException exceptionWithClass: isa];
}
}
- copy
{
return [self retain];
}
|
|
>
|
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
|
case OF_NUMBER_FLOAT:
return [OFNumber
numberWithFloat: fmodf(value.float_, [number floatValue])];
case OF_NUMBER_DOUBLE:
return [OFNumber numberWithDouble:
fmod(value.double_, [number doubleValue])];
default:
@throw [OFInvalidFormatException
exceptionWithClass: [self class]];
}
}
- copy
{
return [self retain];
}
|
︙ | | | ︙ | |
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
|
if (![ret containsString: @"."])
[ret appendString: @".0"];
[ret makeImmutable];
return ret;
default:
@throw [OFInvalidFormatException exceptionWithClass: isa];
}
}
- (OFXMLElement*)XMLElementBySerializing
{
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
OFXMLElement *element;
|
|
>
|
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
|
if (![ret containsString: @"."])
[ret appendString: @".0"];
[ret makeImmutable];
return ret;
default:
@throw [OFInvalidFormatException
exceptionWithClass: [self class]];
}
}
- (OFXMLElement*)XMLElementBySerializing
{
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
OFXMLElement *element;
|
︙ | | | ︙ | |
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
|
[element addAttributeWithName: @"type"
stringValue: @"double"];
[element setStringValue:
[OFString stringWithFormat: @"%la", value.double_]];
break;
default:
@throw [OFInvalidFormatException exceptionWithClass: isa];
}
[element retain];
[pool release];
[element autorelease];
return element;
|
|
>
|
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
|
[element addAttributeWithName: @"type"
stringValue: @"double"];
[element setStringValue:
[OFString stringWithFormat: @"%la", value.double_]];
break;
default:
@throw [OFInvalidFormatException
exceptionWithClass: [self class]];
}
[element retain];
[pool release];
[element autorelease];
return element;
|
︙ | | | ︙ | |
Modified src/OFObject+Serialization.m
from [d3f96b9582]
to [012cfeffa7].
︙ | | | ︙ | |
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
OFAutoreleasePool *pool;
OFXMLElement *element;
OFXMLElement *root;
OFString *ret;
if (![self conformsToProtocol: @protocol(OFSerialization)])
@throw [OFNotImplementedException
exceptionWithClass: isa
selector: @selector(stringBySerializing)];
pool = [[OFAutoreleasePool alloc] init];
element = [(id)self XMLElementBySerializing];
root = [OFXMLElement elementWithName: @"serialization"
namespace: OF_SERIALIZATION_NS];
|
|
|
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
OFAutoreleasePool *pool;
OFXMLElement *element;
OFXMLElement *root;
OFString *ret;
if (![self conformsToProtocol: @protocol(OFSerialization)])
@throw [OFNotImplementedException
exceptionWithClass: [self class]
selector: @selector(stringBySerializing)];
pool = [[OFAutoreleasePool alloc] init];
element = [(id)self XMLElementBySerializing];
root = [OFXMLElement elementWithName: @"serialization"
namespace: OF_SERIALIZATION_NS];
|
︙ | | | ︙ | |
Modified src/OFObject.h
from [f1d13468c6]
to [98f274a22b].
︙ | | | ︙ | |
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
#include <limits.h>
#ifdef OF_OBJFW_RUNTIME
# import "runtime.h"
#else
# import <objc/objc.h>
#endif
#ifdef __has_feature
# if __has_feature(objc_bool)
# undef YES
# define YES __objc_yes
# undef NO
# define NO __objc_no
|
>
>
>
>
|
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
#include <limits.h>
#ifdef OF_OBJFW_RUNTIME
# import "runtime.h"
#else
# import <objc/objc.h>
#endif
#ifdef OF_APPLE_RUNTIME
# import <objc/runtime.h>
#endif
#ifdef __has_feature
# if __has_feature(objc_bool)
# undef YES
# define YES __objc_yes
# undef NO
# define NO __objc_no
|
︙ | | | ︙ | |
Modified src/OFObject.m
from [64a1864a0a]
to [470fa11181].
︙ | | | ︙ | |
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
|
extraAlignment = ((instanceSize + extraAlignment - 1) &
~(extraAlignment - 1)) - extraAlignment;
instance = malloc(PRE_IVAR_ALIGN + instanceSize +
extraAlignment + extraSize);
if (OF_UNLIKELY(instance == nil)) {
alloc_failed_exception.isa = [OFAllocFailedException class];
@throw (OFAllocFailedException*)&alloc_failed_exception;
}
((struct pre_ivar*)instance)->retainCount = 1;
((struct pre_ivar*)instance)->firstMem = NULL;
((struct pre_ivar*)instance)->lastMem = NULL;
#if !defined(OF_ATOMIC_OPS) && defined(OF_THREADS)
if (OF_UNLIKELY(!of_spinlock_new(
&((struct pre_ivar*)instance)->retainCountSpinlock))) {
free(instance);
@throw [OFInitializationFailedException
exceptionWithClass: class];
}
#endif
instance = (OFObject*)((char*)instance + PRE_IVAR_ALIGN);
instance->isa = class;
memset((char*)instance + sizeof(instance->isa), 0,
instanceSize - sizeof(instance->isa));
if (OF_UNLIKELY(extra != NULL))
*extra = (char*)instance + instanceSize + extraAlignment;
return instance;
}
|
>
|
|
|
<
|
|
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
|
extraAlignment = ((instanceSize + extraAlignment - 1) &
~(extraAlignment - 1)) - extraAlignment;
instance = malloc(PRE_IVAR_ALIGN + instanceSize +
extraAlignment + extraSize);
if (OF_UNLIKELY(instance == nil)) {
object_setClass((id)&alloc_failed_exception,
[OFAllocFailedException class]);
@throw (id)&alloc_failed_exception;
}
((struct pre_ivar*)instance)->retainCount = 1;
((struct pre_ivar*)instance)->firstMem = NULL;
((struct pre_ivar*)instance)->lastMem = NULL;
#if !defined(OF_ATOMIC_OPS) && defined(OF_THREADS)
if (OF_UNLIKELY(!of_spinlock_new(
&((struct pre_ivar*)instance)->retainCountSpinlock))) {
free(instance);
@throw [OFInitializationFailedException
exceptionWithClass: class];
}
#endif
instance = (OFObject*)((char*)instance + PRE_IVAR_ALIGN);
memset(instance, 0, instanceSize);
object_setClass(instance, class);
if (OF_UNLIKELY(extra != NULL))
*extra = (char*)instance + instanceSize + extraAlignment;
return instance;
}
|
︙ | | | ︙ | |
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
|
typeEncoding);
}
+ (IMP)replaceClassMethod: (SEL)selector
withImplementation: (IMP)implementation
typeEncoding: (const char*)typeEncoding
{
return class_replaceMethod(((OFObject*)self)->isa, selector,
implementation, typeEncoding);
}
+ (void)inheritMethodsFromClass: (Class)class
{
Class superclass = [self superclass];
if ([self isSubclassOfClass: class])
return;
#if defined(OF_APPLE_RUNTIME)
Method *methodList;
unsigned i, count;
methodList = class_copyMethodList(((OFObject*)class)->isa, &count);
@try {
for (i = 0; i < count; i++) {
SEL selector = method_getName(methodList[i]);
/*
* Don't replace methods implemented in receiving class.
*/
|
|
|
|
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
|
typeEncoding);
}
+ (IMP)replaceClassMethod: (SEL)selector
withImplementation: (IMP)implementation
typeEncoding: (const char*)typeEncoding
{
return class_replaceMethod(object_getClass(self), selector,
implementation, typeEncoding);
}
+ (void)inheritMethodsFromClass: (Class)class
{
Class superclass = [self superclass];
if ([self isSubclassOfClass: class])
return;
#if defined(OF_APPLE_RUNTIME)
Method *methodList;
unsigned i, count;
methodList = class_copyMethodList(object_getClass(class), &count);
@try {
for (i = 0; i < count; i++) {
SEL selector = method_getName(methodList[i]);
/*
* Don't replace methods implemented in receiving class.
*/
|
︙ | | | ︙ | |
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
|
}
} @finally {
free(methodList);
}
#elif defined(OF_OBJFW_RUNTIME)
struct objc_method_list *methodlist;
for (methodlist = class->isa->methodlist;
methodlist != NULL; methodlist = methodlist->next) {
int i;
for (i = 0; i < methodlist->count; i++) {
SEL selector = (SEL)&methodlist->methods[i].sel;
/*
|
|
|
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
|
}
} @finally {
free(methodList);
}
#elif defined(OF_OBJFW_RUNTIME)
struct objc_method_list *methodlist;
for (methodlist = object_getClass(class)->methodlist;
methodlist != NULL; methodlist = methodlist->next) {
int i;
for (i = 0; i < methodlist->count; i++) {
SEL selector = (SEL)&methodlist->methods[i].sel;
/*
|
︙ | | | ︙ | |
465
466
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
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
522
523
524
525
526
527
528
529
530
531
532
533
534
|
}
- init
{
Class class;
void (*last)(id, SEL) = NULL;
for (class = isa; class != Nil; class = class_getSuperclass(class)) {
void (*construct)(id, SEL);
if ([class instancesRespondToSelector: cxx_construct]) {
if ((construct = (void(*)(id, SEL))[class
instanceMethodForSelector: cxx_construct]) != last)
construct(self, cxx_construct);
last = construct;
} else
break;
}
return self;
}
- (Class)class
{
return isa;
}
- (OFString*)className
{
return [OFString stringWithCString: class_getName(isa)
encoding: OF_STRING_ENCODING_ASCII];
}
- (BOOL)isKindOfClass: (Class)class
{
Class iter;
for (iter = isa; iter != Nil; iter = class_getSuperclass(iter))
if (iter == class)
return YES;
return NO;
}
- (BOOL)isMemberOfClass: (Class)class
{
return (isa == class);
}
- (BOOL)respondsToSelector: (SEL)selector
{
return class_respondsToSelector(isa, selector);
}
- (BOOL)conformsToProtocol: (Protocol*)protocol
{
return [isa conformsToProtocol: protocol];
}
- (IMP)methodForSelector: (SEL)selector
{
return class_getMethodImplementation(isa, selector);
}
- (id)performSelector: (SEL)selector
{
id (*imp)(id, SEL) = (id(*)(id, SEL))[self methodForSelector: selector];
return imp(self, selector);
|
>
|
|
|
>
|
|
|
|
|
|
465
466
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
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
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
|
}
- init
{
Class class;
void (*last)(id, SEL) = NULL;
for (class = object_getClass(self); class != Nil;
class = class_getSuperclass(class)) {
void (*construct)(id, SEL);
if ([class instancesRespondToSelector: cxx_construct]) {
if ((construct = (void(*)(id, SEL))[class
instanceMethodForSelector: cxx_construct]) != last)
construct(self, cxx_construct);
last = construct;
} else
break;
}
return self;
}
- (Class)class
{
return object_getClass(self);
}
- (OFString*)className
{
return [OFString stringWithCString: object_getClassName(self)
encoding: OF_STRING_ENCODING_ASCII];
}
- (BOOL)isKindOfClass: (Class)class
{
Class iter;
for (iter = object_getClass(self); iter != Nil;
iter = class_getSuperclass(iter))
if (iter == class)
return YES;
return NO;
}
- (BOOL)isMemberOfClass: (Class)class
{
return (object_getClass(self) == class);
}
- (BOOL)respondsToSelector: (SEL)selector
{
return class_respondsToSelector(object_getClass(self), selector);
}
- (BOOL)conformsToProtocol: (Protocol*)protocol
{
return [object_getClass(self) conformsToProtocol: protocol];
}
- (IMP)methodForSelector: (SEL)selector
{
return class_getMethodImplementation(object_getClass(self), selector);
}
- (id)performSelector: (SEL)selector
{
id (*imp)(id, SEL) = (id(*)(id, SEL))[self methodForSelector: selector];
return imp(self, selector);
|
︙ | | | ︙ | |
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
|
}
- (const char*)typeEncodingForSelector: (SEL)selector
{
#if defined(OF_OBJFW_RUNTIME)
const char *ret;
if ((ret = objc_get_type_encoding(isa, selector)) == NULL)
@throw [OFNotImplementedException exceptionWithClass: isa
selector: selector];
return ret;
#else
Method m;
const char *ret;
if ((m = class_getInstanceMethod(isa, selector)) == NULL ||
(ret = method_getTypeEncoding(m)) == NULL)
@throw [OFNotImplementedException exceptionWithClass: isa
selector: selector];
return ret;
#endif
}
- (BOOL)isEqual: (id)object
|
|
>
|
>
|
|
|
>
|
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
|
}
- (const char*)typeEncodingForSelector: (SEL)selector
{
#if defined(OF_OBJFW_RUNTIME)
const char *ret;
if ((ret = objc_get_type_encoding(object_getClass(self),
selector)) == NULL)
@throw [OFNotImplementedException
exceptionWithClass: [self class]
selector: selector];
return ret;
#else
Method m;
const char *ret;
if ((m = class_getInstanceMethod(object_getClass(self),
selector)) == NULL || (ret = method_getTypeEncoding(m)) == NULL)
@throw [OFNotImplementedException
exceptionWithClass: [self class]
selector: selector];
return ret;
#endif
}
- (BOOL)isEqual: (id)object
|
︙ | | | ︙ | |
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
|
- (void*)allocMemoryWithSize: (size_t)size
{
void *pointer;
struct pre_mem *preMem;
if (size > SIZE_MAX - PRE_IVAR_ALIGN)
@throw [OFOutOfRangeException exceptionWithClass: isa];
if ((pointer = malloc(PRE_MEM_ALIGN + size)) == NULL)
@throw [OFOutOfMemoryException exceptionWithClass: isa
requestedSize: size];
preMem = pointer;
preMem->owner = self;
preMem->prev = PRE_IVAR->lastMem;
preMem->next = NULL;
|
|
|
|
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
|
- (void*)allocMemoryWithSize: (size_t)size
{
void *pointer;
struct pre_mem *preMem;
if (size > SIZE_MAX - PRE_IVAR_ALIGN)
@throw [OFOutOfRangeException exceptionWithClass: [self class]];
if ((pointer = malloc(PRE_MEM_ALIGN + size)) == NULL)
@throw [OFOutOfMemoryException exceptionWithClass: [self class]
requestedSize: size];
preMem = pointer;
preMem->owner = self;
preMem->prev = PRE_IVAR->lastMem;
preMem->next = NULL;
|
︙ | | | ︙ | |
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
648
649
650
651
652
653
654
655
656
657
658
659
660
661
|
- (void*)allocMemoryWithSize: (size_t)size
count: (size_t)count
{
if (size == 0 || count == 0)
return NULL;
if (count > SIZE_MAX / size)
@throw [OFOutOfRangeException exceptionWithClass: isa];
return [self allocMemoryWithSize: size * count];
}
- (void*)resizeMemory: (void*)pointer
size: (size_t)size
{
void *new;
struct pre_mem *preMem;
if (pointer == NULL)
return [self allocMemoryWithSize: size];
if (size == 0) {
[self freeMemory: pointer];
return NULL;
}
if (PRE_MEM(pointer)->owner != self)
@throw [OFMemoryNotPartOfObjectException
exceptionWithClass: isa
pointer: pointer];
if ((new = realloc(PRE_MEM(pointer), PRE_MEM_ALIGN + size)) == NULL)
@throw [OFOutOfMemoryException exceptionWithClass: isa
requestedSize: size];
preMem = new;
if (preMem != PRE_MEM(pointer)) {
if (preMem->prev != NULL)
preMem->prev->next = preMem;
if (preMem->next != NULL)
|
|
|
|
|
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
|
- (void*)allocMemoryWithSize: (size_t)size
count: (size_t)count
{
if (size == 0 || count == 0)
return NULL;
if (count > SIZE_MAX / size)
@throw [OFOutOfRangeException exceptionWithClass: [self class]];
return [self allocMemoryWithSize: size * count];
}
- (void*)resizeMemory: (void*)pointer
size: (size_t)size
{
void *new;
struct pre_mem *preMem;
if (pointer == NULL)
return [self allocMemoryWithSize: size];
if (size == 0) {
[self freeMemory: pointer];
return NULL;
}
if (PRE_MEM(pointer)->owner != self)
@throw [OFMemoryNotPartOfObjectException
exceptionWithClass: [self class]
pointer: pointer];
if ((new = realloc(PRE_MEM(pointer), PRE_MEM_ALIGN + size)) == NULL)
@throw [OFOutOfMemoryException exceptionWithClass: [self class]
requestedSize: size];
preMem = new;
if (preMem != PRE_MEM(pointer)) {
if (preMem->prev != NULL)
preMem->prev->next = preMem;
if (preMem->next != NULL)
|
︙ | | | ︙ | |
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
705
706
707
|
if (size == 0 || count == 0) {
[self freeMemory: pointer];
return NULL;
}
if (count > SIZE_MAX / size)
@throw [OFOutOfRangeException exceptionWithClass: isa];
return [self resizeMemory: pointer
size: size * count];
}
- (void)freeMemory: (void*)pointer
{
if (pointer == NULL)
return;
if (PRE_MEM(pointer)->owner != self)
@throw [OFMemoryNotPartOfObjectException
exceptionWithClass: isa
pointer: pointer];
if (PRE_MEM(pointer)->prev != NULL)
PRE_MEM(pointer)->prev->next = PRE_MEM(pointer)->next;
if (PRE_MEM(pointer)->next != NULL)
PRE_MEM(pointer)->next->prev = PRE_MEM(pointer)->prev;
|
|
|
|
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
|
if (size == 0 || count == 0) {
[self freeMemory: pointer];
return NULL;
}
if (count > SIZE_MAX / size)
@throw [OFOutOfRangeException exceptionWithClass: [self class]];
return [self resizeMemory: pointer
size: size * count];
}
- (void)freeMemory: (void*)pointer
{
if (pointer == NULL)
return;
if (PRE_MEM(pointer)->owner != self)
@throw [OFMemoryNotPartOfObjectException
exceptionWithClass: [self class]
pointer: pointer];
if (PRE_MEM(pointer)->prev != NULL)
PRE_MEM(pointer)->prev->next = PRE_MEM(pointer)->next;
if (PRE_MEM(pointer)->next != NULL)
PRE_MEM(pointer)->next->prev = PRE_MEM(pointer)->prev;
|
︙ | | | ︙ | |
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
|
- (void)dealloc
{
Class class;
void (*last)(id, SEL) = NULL;
struct pre_mem *iter;
for (class = isa; class != Nil; class = class_getSuperclass(class)) {
void (*destruct)(id, SEL);
if ([class instancesRespondToSelector: cxx_destruct]) {
if ((destruct = (void(*)(id, SEL))[class
instanceMethodForSelector: cxx_destruct]) != last)
destruct(self, cxx_destruct);
|
>
|
|
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
|
- (void)dealloc
{
Class class;
void (*last)(id, SEL) = NULL;
struct pre_mem *iter;
for (class = object_getClass(self); class != Nil;
class = class_getSuperclass(class)) {
void (*destruct)(id, SEL);
if ([class instancesRespondToSelector: cxx_destruct]) {
if ((destruct = (void(*)(id, SEL))[class
instanceMethodForSelector: cxx_destruct]) != last)
destruct(self, cxx_destruct);
|
︙ | | | ︙ | |
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
|
free((char*)self - PRE_IVAR_ALIGN);
}
/* Required to use properties with the Apple runtime */
- copyWithZone: (void*)zone
{
if (zone != NULL)
@throw [OFNotImplementedException exceptionWithClass: isa
selector: _cmd];
return [(id)self copy];
}
- mutableCopyWithZone: (void*)zone
{
if (zone != NULL)
@throw [OFNotImplementedException exceptionWithClass: isa
selector: _cmd];
return [(id)self mutableCopy];
}
/*
* Those are needed as the root class is the superclass of the root class's
|
|
>
|
>
|
825
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
|
free((char*)self - PRE_IVAR_ALIGN);
}
/* Required to use properties with the Apple runtime */
- copyWithZone: (void*)zone
{
if (zone != NULL)
@throw [OFNotImplementedException
exceptionWithClass: [self class]
selector: _cmd];
return [(id)self copy];
}
- mutableCopyWithZone: (void*)zone
{
if (zone != NULL)
@throw [OFNotImplementedException
exceptionWithClass: [self class]
selector: _cmd];
return [(id)self mutableCopy];
}
/*
* Those are needed as the root class is the superclass of the root class's
|
︙ | | | ︙ | |
Modified src/OFPlugin.m
from [c2bd5da7b9]
to [9ce801be06].
︙ | | | ︙ | |
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
plugin->handle = handle;
return plugin;
}
- init
{
if (isa == [OFPlugin class]) {
Class c = isa;
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
return [super init];
}
|
|
|
|
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
plugin->handle = handle;
return plugin;
}
- init
{
if (object_getClass(self) == [OFPlugin class]) {
Class c = [self class];
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
return [super init];
}
|
︙ | | | ︙ | |
Modified src/OFProcess.m
from [8d0f0fd4b4]
to [a1bb959d69].
︙ | | | ︙ | |
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
|
{
self = [super init];
@try {
#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;
|
|
|
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
|
{
self = [super init];
@try {
#ifndef _WIN32
if (pipe(readPipe) != 0 || pipe(writePipe) != 0)
@throw [OFInitializationFailedException
exceptionWithClass: [self class]];
switch ((pid = fork())) {
case 0:;
OFString **objects = [arguments objects];
size_t i, count = [arguments count];
char **argv;
|
︙ | | | ︙ | |
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
|
close(writePipe[1]);
dup2(writePipe[0], 0);
dup2(readPipe[1], 1);
execvp([program cStringWithEncoding:
OF_STRING_ENCODING_NATIVE], argv);
@throw [OFInitializationFailedException
exceptionWithClass: isa];
case -1:
@throw [OFInitializationFailedException
exceptionWithClass: isa];
default:
close(readPipe[1]);
close(writePipe[0]);
break;
}
#else
SECURITY_ATTRIBUTES sa;
|
|
|
|
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
|
close(writePipe[1]);
dup2(writePipe[0], 0);
dup2(readPipe[1], 1);
execvp([program cStringWithEncoding:
OF_STRING_ENCODING_NATIVE], argv);
@throw [OFInitializationFailedException
exceptionWithClass: [self class]];
case -1:
@throw [OFInitializationFailedException
exceptionWithClass: [self class]];
default:
close(readPipe[1]);
close(writePipe[0]);
break;
}
#else
SECURITY_ATTRIBUTES sa;
|
︙ | | | ︙ | |
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
|
sa.nLength = sizeof(sa);
sa.bInheritHandle = TRUE;
sa.lpSecurityDescriptor = NULL;
if (!CreatePipe(&readPipe[0], &readPipe[1], &sa, 0))
@throw [OFInitializationFailedException
exceptionWithClass: isa];
if (!SetHandleInformation(readPipe[0], HANDLE_FLAG_INHERIT, 0))
@throw [OFInitializationFailedException
exceptionWithClass: isa];
if (!CreatePipe(&writePipe[0], &writePipe[1], &sa, 0))
@throw [OFInitializationFailedException
exceptionWithClass: isa];
if (!SetHandleInformation(writePipe[1], HANDLE_FLAG_INHERIT, 0))
@throw [OFInitializationFailedException
exceptionWithClass: isa];
memset(&pi, 0, sizeof(pi));
memset(&si, 0, sizeof(si));
si.cb = sizeof(si);
si.hStdInput = writePipe[0];
si.hStdOutput = readPipe[1];
|
|
|
|
|
|
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
|
sa.nLength = sizeof(sa);
sa.bInheritHandle = TRUE;
sa.lpSecurityDescriptor = NULL;
if (!CreatePipe(&readPipe[0], &readPipe[1], &sa, 0))
@throw [OFInitializationFailedException
exceptionWithClass: [self class]];
if (!SetHandleInformation(readPipe[0], HANDLE_FLAG_INHERIT, 0))
@throw [OFInitializationFailedException
exceptionWithClass: [self class]];
if (!CreatePipe(&writePipe[0], &writePipe[1], &sa, 0))
@throw [OFInitializationFailedException
exceptionWithClass: [self class]];
if (!SetHandleInformation(writePipe[1], HANDLE_FLAG_INHERIT, 0))
@throw [OFInitializationFailedException
exceptionWithClass: [self class]];
memset(&pi, 0, sizeof(pi));
memset(&si, 0, sizeof(si));
si.cb = sizeof(si);
si.hStdInput = writePipe[0];
si.hStdOutput = readPipe[1];
|
︙ | | | ︙ | |
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
|
argumentsCString = strdup([argumentsString
cStringWithEncoding: OF_STRING_ENCODING_NATIVE]);
@try {
if (!CreateProcess([program cStringWithEncoding:
OF_STRING_ENCODING_NATIVE], argumentsCString, NULL,
NULL, TRUE, 0, NULL, NULL, &si, &pi))
@throw [OFInitializationFailedException
exceptionWithClass: isa];
} @finally {
free(argumentsString);
}
[pool release];
CloseHandle(pi.hProcess);
|
|
|
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
|
argumentsCString = strdup([argumentsString
cStringWithEncoding: OF_STRING_ENCODING_NATIVE]);
@try {
if (!CreateProcess([program cStringWithEncoding:
OF_STRING_ENCODING_NATIVE], argumentsCString, NULL,
NULL, TRUE, 0, NULL, NULL, &si, &pi))
@throw [OFInitializationFailedException
exceptionWithClass: [self class]];
} @finally {
free(argumentsString);
}
[pool release];
CloseHandle(pi.hProcess);
|
︙ | | | ︙ | |
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
|
!ReadFile(readPipe[0], buffer, length, &ret, NULL)) {
if (GetLastError() == ERROR_BROKEN_PIPE) {
atEndOfStream = YES;
return 0;
}
#endif
@throw [OFReadFailedException exceptionWithClass: isa
stream: self
requestedLength: length];
}
if (ret == 0)
atEndOfStream = YES;
|
|
|
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
|
!ReadFile(readPipe[0], buffer, length, &ret, NULL)) {
if (GetLastError() == ERROR_BROKEN_PIPE) {
atEndOfStream = YES;
return 0;
}
#endif
@throw [OFReadFailedException exceptionWithClass: [self class]
stream: self
requestedLength: length];
}
if (ret == 0)
atEndOfStream = YES;
|
︙ | | | ︙ | |
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
|
#else
DWORD ret;
if (writePipe[1] == NULL || atEndOfStream ||
!WriteFile(writePipe[1], buffer, length, &ret, NULL) ||
ret < length)
#endif
@throw [OFWriteFailedException exceptionWithClass: isa
stream: self
requestedLength: length];
}
- (void)dealloc
{
[self close];
|
|
|
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
|
#else
DWORD ret;
if (writePipe[1] == NULL || atEndOfStream ||
!WriteFile(writePipe[1], buffer, length, &ret, NULL) ||
ret < length)
#endif
@throw [OFWriteFailedException exceptionWithClass: [self class]
stream: self
requestedLength: length];
}
- (void)dealloc
{
[self close];
|
︙ | | | ︙ | |
Modified src/OFSHA1Hash.m
from [6e4ec96cf9]
to [88920d7f76].
︙ | | | ︙ | |
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
|
length: (size_t)length
{
if (length == 0)
return;
if (calculated)
@throw [OFHashAlreadyCalculatedException
exceptionWithClass: isa
hash: self];
sha1_update(state, &count, buffer, buffer_, length);
}
- (uint8_t*)digest
{
|
|
|
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
|
length: (size_t)length
{
if (length == 0)
return;
if (calculated)
@throw [OFHashAlreadyCalculatedException
exceptionWithClass: [self class]
hash: self];
sha1_update(state, &count, buffer, buffer_, length);
}
- (uint8_t*)digest
{
|
︙ | | | ︙ | |
Modified src/OFSeekableStream.m
from [0d216f9606]
to [e3dd88a6e5].
︙ | | | ︙ | |
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
|
#import "OFSeekableStream.h"
#import "OFNotImplementedException.h"
@implementation OFSeekableStream
- (void)_seekToOffset: (off_t)offset
{
@throw [OFNotImplementedException exceptionWithClass: isa
selector: _cmd];
}
- (off_t)_seekForwardWithOffset: (off_t)offset
{
@throw [OFNotImplementedException exceptionWithClass: isa
selector: _cmd];
}
- (off_t)_seekToOffsetRelativeToEnd: (off_t)offset
{
@throw [OFNotImplementedException exceptionWithClass: isa
selector: _cmd];
}
- (void)seekToOffset: (off_t)offset
{
[self _seekToOffset: offset];
|
|
|
|
|
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
|
#import "OFSeekableStream.h"
#import "OFNotImplementedException.h"
@implementation OFSeekableStream
- (void)_seekToOffset: (off_t)offset
{
@throw [OFNotImplementedException exceptionWithClass: [self class]
selector: _cmd];
}
- (off_t)_seekForwardWithOffset: (off_t)offset
{
@throw [OFNotImplementedException exceptionWithClass: [self class]
selector: _cmd];
}
- (off_t)_seekToOffsetRelativeToEnd: (off_t)offset
{
@throw [OFNotImplementedException exceptionWithClass: [self class]
selector: _cmd];
}
- (void)seekToOffset: (off_t)offset
{
[self _seekToOffset: offset];
|
︙ | | | ︙ | |
Modified src/OFSet.m
from [fdc2275c3d]
to [7c97ea2061].
︙ | | | ︙ | |
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
|
- (void)release
{
}
- (void)dealloc
{
@throw [OFNotImplementedException exceptionWithClass: isa
selector: _cmd];
[super dealloc]; /* Get rid of a stupid warning */
}
@end
@implementation OFSet
+ (void)initialize
{
if (self == [OFSet class])
placeholder.isa = [OFSet_placeholder class];
}
+ alloc
{
if (self == [OFSet class])
return (id)&placeholder;
|
|
|
|
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
|
- (void)release
{
}
- (void)dealloc
{
@throw [OFNotImplementedException exceptionWithClass: [self class]
selector: _cmd];
[super dealloc]; /* Get rid of a stupid warning */
}
@end
@implementation OFSet
+ (void)initialize
{
if (self == [OFSet class])
object_setClass((id)&placeholder, [OFSet_placeholder class]);
}
+ alloc
{
if (self == [OFSet class])
return (id)&placeholder;
|
︙ | | | ︙ | |
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
|
{
return [[[self alloc] initWithObjects: objects
count: count] autorelease];
}
- init
{
if (isa == [OFSet class]) {
Class c = isa;
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
return [super init];
}
- initWithSet: (OFSet*)set
{
Class c = isa;
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
- initWithArray: (OFArray*)array
{
Class c = isa;
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
- (id)initWithObjects: (id)firstObject, ...
{
|
|
|
|
|
|
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
|
{
return [[[self alloc] initWithObjects: objects
count: count] autorelease];
}
- init
{
if (object_getClass(self) == [OFSet class]) {
Class c = [self class];
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
return [super init];
}
- initWithSet: (OFSet*)set
{
Class c = [self class];
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
- initWithArray: (OFArray*)array
{
Class c = [self class];
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
- (id)initWithObjects: (id)firstObject, ...
{
|
︙ | | | ︙ | |
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
|
return ret;
}
- initWithObjects: (id const*)objects
count: (size_t)count
{
Class c = isa;
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
- initWithObject: (id)firstObject
arguments: (va_list)arguments
{
Class c = isa;
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
- initWithSerialization: (OFXMLElement*)element
{
Class c = isa;
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
- (size_t)count
{
@throw [OFNotImplementedException exceptionWithClass: isa
selector: _cmd];
}
- (BOOL)containsObject: (id)object
{
@throw [OFNotImplementedException exceptionWithClass: isa
selector: _cmd];
}
- (OFEnumerator*)objectEnumerator
{
@throw [OFNotImplementedException exceptionWithClass: isa
selector: _cmd];
}
- (int)countByEnumeratingWithState: (of_fast_enumeration_state_t*)state
objects: (id*)objects
count: (int)count
{
@throw [OFNotImplementedException exceptionWithClass: isa
selector: _cmd];
}
- (BOOL)isEqual: (id)object
{
OFSet *otherSet;
|
|
|
|
|
|
|
|
|
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
|
return ret;
}
- initWithObjects: (id const*)objects
count: (size_t)count
{
Class c = [self class];
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
- initWithObject: (id)firstObject
arguments: (va_list)arguments
{
Class c = [self class];
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
- initWithSerialization: (OFXMLElement*)element
{
Class c = [self class];
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
- (size_t)count
{
@throw [OFNotImplementedException exceptionWithClass: [self class]
selector: _cmd];
}
- (BOOL)containsObject: (id)object
{
@throw [OFNotImplementedException exceptionWithClass: [self class]
selector: _cmd];
}
- (OFEnumerator*)objectEnumerator
{
@throw [OFNotImplementedException exceptionWithClass: [self class]
selector: _cmd];
}
- (int)countByEnumeratingWithState: (of_fast_enumeration_state_t*)state
objects: (id*)objects
count: (int)count
{
@throw [OFNotImplementedException exceptionWithClass: [self class]
selector: _cmd];
}
- (BOOL)isEqual: (id)object
{
OFSet *otherSet;
|
︙ | | | ︙ | |
Modified src/OFSet_hashtable.m
from [bf071b8c76]
to [38338532b1].
︙ | | | ︙ | |
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
|
pool = [[OFAutoreleasePool alloc] init];
if ((![[element name] isEqual: @"OFSet"] &&
![[element name] isEqual: @"OFMutableSet"]) ||
![[element namespace] isEqual: OF_SERIALIZATION_NS])
@throw [OFInvalidArgumentException
exceptionWithClass: isa
selector: _cmd];
one = [OFNumber numberWithSize: 1];
enumerator = [[element elementsForNamespace:
OF_SERIALIZATION_NS] objectEnumerator];
pool2 = [[OFAutoreleasePool alloc] init];
|
|
|
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
|
pool = [[OFAutoreleasePool alloc] init];
if ((![[element name] isEqual: @"OFSet"] &&
![[element name] isEqual: @"OFMutableSet"]) ||
![[element namespace] isEqual: OF_SERIALIZATION_NS])
@throw [OFInvalidArgumentException
exceptionWithClass: [self class]
selector: _cmd];
one = [OFNumber numberWithSize: 1];
enumerator = [[element elementsForNamespace:
OF_SERIALIZATION_NS] objectEnumerator];
pool2 = [[OFAutoreleasePool alloc] init];
|
︙ | | | ︙ | |
Modified src/OFStream.m
from [6e083ee3de]
to [a84b6238c0].
︙ | | | ︙ | |
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
|
if (self == [OFStream class])
signal(SIGPIPE, SIG_IGN);
}
#endif
- init
{
if (isa == [OFStream class]) {
Class c = isa;
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
self = [super init];
cache = NULL;
writeBuffer = NULL;
blocking = YES;
return self;
}
- (BOOL)_isAtEndOfStream
{
@throw [OFNotImplementedException exceptionWithClass: isa
selector: _cmd];
}
- (size_t)_readIntoBuffer: (void*)buffer
length: (size_t)length
{
@throw [OFNotImplementedException exceptionWithClass: isa
selector: _cmd];
}
- (void)_writeBuffer: (const void*)buffer
length: (size_t)length
{
@throw [OFNotImplementedException exceptionWithClass: isa
selector: _cmd];
}
- copy
{
return [self retain];
}
|
|
|
|
|
|
|
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
|
if (self == [OFStream class])
signal(SIGPIPE, SIG_IGN);
}
#endif
- init
{
if (object_getClass(self) == [OFStream class]) {
Class c = [self class];
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
self = [super init];
cache = NULL;
writeBuffer = NULL;
blocking = YES;
return self;
}
- (BOOL)_isAtEndOfStream
{
@throw [OFNotImplementedException exceptionWithClass: [self class]
selector: _cmd];
}
- (size_t)_readIntoBuffer: (void*)buffer
length: (size_t)length
{
@throw [OFNotImplementedException exceptionWithClass: [self class]
selector: _cmd];
}
- (void)_writeBuffer: (const void*)buffer
length: (size_t)length
{
@throw [OFNotImplementedException exceptionWithClass: [self class]
selector: _cmd];
}
- copy
{
return [self retain];
}
|
︙ | | | ︙ | |
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
|
/* FIXME: Convert delimiter to specified charset */
delimiterUTF8String = [delimiter UTF8String];
delimiterLength = [delimiter UTF8StringLength];
j = 0;
if (delimiterLength == 0)
@throw [OFInvalidArgumentException exceptionWithClass: isa
selector: _cmd];
/* Look if there's something in our cache */
if (!waitingForDelimiter && cache != NULL) {
for (i = 0; i < cacheLength; i++) {
if (cache[i] != delimiterUTF8String[j++])
j = 0;
|
|
>
|
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
|
/* FIXME: Convert delimiter to specified charset */
delimiterUTF8String = [delimiter UTF8String];
delimiterLength = [delimiter UTF8StringLength];
j = 0;
if (delimiterLength == 0)
@throw [OFInvalidArgumentException
exceptionWithClass: [self class]
selector: _cmd];
/* Look if there's something in our cache */
if (!waitingForDelimiter && cache != NULL) {
for (i = 0; i < cacheLength; i++) {
if (cache[i] != delimiterUTF8String[j++])
j = 0;
|
︙ | | | ︙ | |
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
|
- (size_t)writeFormat: (OFConstantString*)format
arguments: (va_list)arguments
{
char *UTF8String;
int length;
if (format == nil)
@throw [OFInvalidArgumentException exceptionWithClass: isa
selector: _cmd];
if ((length = of_vasprintf(&UTF8String, [format UTF8String],
arguments)) == -1)
@throw [OFInvalidFormatException exceptionWithClass: isa];
@try {
[self writeBuffer: UTF8String
length: length];
} @finally {
free(UTF8String);
}
|
|
>
|
>
|
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
|
- (size_t)writeFormat: (OFConstantString*)format
arguments: (va_list)arguments
{
char *UTF8String;
int length;
if (format == nil)
@throw [OFInvalidArgumentException
exceptionWithClass: [self class]
selector: _cmd];
if ((length = of_vasprintf(&UTF8String, [format UTF8String],
arguments)) == -1)
@throw [OFInvalidFormatException
exceptionWithClass: [self class]];
@try {
[self writeBuffer: UTF8String
length: length];
} @finally {
free(UTF8String);
}
|
︙ | | | ︙ | |
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
|
{
#ifndef _WIN32
int flags;
blocking = enable;
if ((flags = fcntl([self fileDescriptor], F_GETFL)) == -1)
@throw [OFSetOptionFailedException exceptionWithClass: isa
stream: self];
if (enable)
flags &= ~O_NONBLOCK;
else
flags |= O_NONBLOCK;
if (fcntl([self fileDescriptor], F_SETFL, flags) == -1)
@throw [OFSetOptionFailedException exceptionWithClass: isa
stream: self];
#else
@throw [OFNotImplementedException exceptionWithClass: isa
selector: _cmd];
#endif
}
- (int)fileDescriptor
{
@throw [OFNotImplementedException exceptionWithClass: isa
selector: _cmd];
}
- (void)close
{
@throw [OFNotImplementedException exceptionWithClass: isa
selector: _cmd];
}
- (BOOL)_isWaitingForDelimiter
{
return waitingForDelimiter;
}
@end
|
|
>
|
>
|
|
|
|
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
|
{
#ifndef _WIN32
int flags;
blocking = enable;
if ((flags = fcntl([self fileDescriptor], F_GETFL)) == -1)
@throw [OFSetOptionFailedException
exceptionWithClass: [self class]
stream: self];
if (enable)
flags &= ~O_NONBLOCK;
else
flags |= O_NONBLOCK;
if (fcntl([self fileDescriptor], F_SETFL, flags) == -1)
@throw [OFSetOptionFailedException
exceptionWithClass: [self class]
stream: self];
#else
@throw [OFNotImplementedException exceptionWithClass: [self class]
selector: _cmd];
#endif
}
- (int)fileDescriptor
{
@throw [OFNotImplementedException exceptionWithClass: [self class]
selector: _cmd];
}
- (void)close
{
@throw [OFNotImplementedException exceptionWithClass: [self class]
selector: _cmd];
}
- (BOOL)_isWaitingForDelimiter
{
return waitingForDelimiter;
}
@end
|
Modified src/OFStreamObserver.m
from [aaaee883eb]
to [6213636312].
︙ | | | ︙ | |
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
|
queue = [[OFMutableArray alloc] init];
queueInfo = [[OFDataArray alloc] initWithItemSize: sizeof(int)];
queueFDs = [[OFDataArray alloc] initWithItemSize: sizeof(int)];
#ifndef _WIN32
if (pipe(cancelFD))
@throw [OFInitializationFailedException
exceptionWithClass: isa];
#else
/* Make sure WSAStartup has been called */
[OFTCPSocket class];
cancelFD[0] = socket(AF_INET, SOCK_DGRAM, 0);
cancelFD[1] = socket(AF_INET, SOCK_DGRAM, 0);
if (cancelFD[0] == INVALID_SOCKET ||
cancelFD[1] == INVALID_SOCKET)
@throw [OFInitializationFailedException
exceptionWithClass: isa];
cancelAddr.sin_family = AF_INET;
cancelAddr.sin_port = 0;
cancelAddr.sin_addr.s_addr = inet_addr("127.0.0.1");
cancelAddr2 = cancelAddr;
if (bind(cancelFD[0], (struct sockaddr*)&cancelAddr,
sizeof(cancelAddr)) || bind(cancelFD[1],
(struct sockaddr*)&cancelAddr2, sizeof(cancelAddr2)))
@throw [OFInitializationFailedException
exceptionWithClass: isa];
cancelAddrLen = sizeof(cancelAddr);
if (getsockname(cancelFD[0], (struct sockaddr*)&cancelAddr,
&cancelAddrLen))
@throw [OFInitializationFailedException
exceptionWithClass: isa];
#endif
maxFD = cancelFD[0];
FDToStream = [self allocMemoryWithSize: sizeof(OFStream*)
count: maxFD + 1];
FDToStream[cancelFD[0]] = nil;
|
|
|
|
|
|
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
|
queue = [[OFMutableArray alloc] init];
queueInfo = [[OFDataArray alloc] initWithItemSize: sizeof(int)];
queueFDs = [[OFDataArray alloc] initWithItemSize: sizeof(int)];
#ifndef _WIN32
if (pipe(cancelFD))
@throw [OFInitializationFailedException
exceptionWithClass: [self class]];
#else
/* Make sure WSAStartup has been called */
[OFTCPSocket class];
cancelFD[0] = socket(AF_INET, SOCK_DGRAM, 0);
cancelFD[1] = socket(AF_INET, SOCK_DGRAM, 0);
if (cancelFD[0] == INVALID_SOCKET ||
cancelFD[1] == INVALID_SOCKET)
@throw [OFInitializationFailedException
exceptionWithClass: [self class]];
cancelAddr.sin_family = AF_INET;
cancelAddr.sin_port = 0;
cancelAddr.sin_addr.s_addr = inet_addr("127.0.0.1");
cancelAddr2 = cancelAddr;
if (bind(cancelFD[0], (struct sockaddr*)&cancelAddr,
sizeof(cancelAddr)) || bind(cancelFD[1],
(struct sockaddr*)&cancelAddr2, sizeof(cancelAddr2)))
@throw [OFInitializationFailedException
exceptionWithClass: [self class]];
cancelAddrLen = sizeof(cancelAddr);
if (getsockname(cancelFD[0], (struct sockaddr*)&cancelAddr,
&cancelAddrLen))
@throw [OFInitializationFailedException
exceptionWithClass: [self class]];
#endif
maxFD = cancelFD[0];
FDToStream = [self allocMemoryWithSize: sizeof(OFStream*)
count: maxFD + 1];
FDToStream[cancelFD[0]] = nil;
|
︙ | | | ︙ | |
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
|
assert(sendto(cancelFD[1], "", 1, 0, (struct sockaddr*)&cancelAddr,
sizeof(cancelAddr)) > 0);
#endif
}
- (void)_addFileDescriptorForReading: (int)fd
{
@throw [OFNotImplementedException exceptionWithClass: isa
selector: _cmd];
}
- (void)_addFileDescriptorForWriting: (int)fd
{
@throw [OFNotImplementedException exceptionWithClass: isa
selector: _cmd];
}
- (void)_removeFileDescriptorForReading: (int)fd
{
@throw [OFNotImplementedException exceptionWithClass: isa
selector: _cmd];
}
- (void)_removeFileDescriptorForWriting: (int)fd
{
@throw [OFNotImplementedException exceptionWithClass: isa
selector: _cmd];
}
- (void)_processQueue
{
[mutex lock];
@try {
|
|
|
|
|
|
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
|
assert(sendto(cancelFD[1], "", 1, 0, (struct sockaddr*)&cancelAddr,
sizeof(cancelAddr)) > 0);
#endif
}
- (void)_addFileDescriptorForReading: (int)fd
{
@throw [OFNotImplementedException exceptionWithClass: [self class]
selector: _cmd];
}
- (void)_addFileDescriptorForWriting: (int)fd
{
@throw [OFNotImplementedException exceptionWithClass: [self class]
selector: _cmd];
}
- (void)_removeFileDescriptorForReading: (int)fd
{
@throw [OFNotImplementedException exceptionWithClass: [self class]
selector: _cmd];
}
- (void)_removeFileDescriptorForWriting: (int)fd
{
@throw [OFNotImplementedException exceptionWithClass: [self class]
selector: _cmd];
}
- (void)_processQueue
{
[mutex lock];
@try {
|
︙ | | | ︙ | |
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
|
- (void)observe
{
[self observeWithTimeout: -1];
}
- (BOOL)observeWithTimeout: (int)timeout
{
@throw [OFNotImplementedException exceptionWithClass: isa
selector: _cmd];
}
- (BOOL)_processCache
{
OFAutoreleasePool *pool;
OFStream **objects = [readStreams objects];
|
|
|
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
|
- (void)observe
{
[self observeWithTimeout: -1];
}
- (BOOL)observeWithTimeout: (int)timeout
{
@throw [OFNotImplementedException exceptionWithClass: [self class]
selector: _cmd];
}
- (BOOL)_processCache
{
OFAutoreleasePool *pool;
OFStream **objects = [readStreams objects];
|
︙ | | | ︙ | |
Modified src/OFStreamObserver_kqueue.m
from [c2387049cc]
to [5e762c9efc].
︙ | | | ︙ | |
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
- init
{
self = [super init];
@try {
if ((kernelQueue = kqueue()) == -1)
@throw [OFInitializationFailedException
exceptionWithClass: isa];
changeList = [[OFDataArray alloc] initWithItemSize:
sizeof(struct kevent)];
[self _addFileDescriptorForReading: cancelFD[0]];
} @catch (id e) {
[self release];
|
|
|
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
- init
{
self = [super init];
@try {
if ((kernelQueue = kqueue()) == -1)
@throw [OFInitializationFailedException
exceptionWithClass: [self class]];
changeList = [[OFDataArray alloc] initWithItemSize:
sizeof(struct kevent)];
[self _addFileDescriptorForReading: cancelFD[0]];
} @catch (id e) {
[self release];
|
︙ | | | ︙ | |
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
|
if (events == -1) {
switch (errno) {
case EINTR:
[pool release];
return NO;
case ENOMEM:
[pool release];
@throw [OFOutOfMemoryException exceptionWithClass: isa];
default:
assert(0);
}
}
[changeList removeAllItems];
|
|
>
|
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
|
if (events == -1) {
switch (errno) {
case EINTR:
[pool release];
return NO;
case ENOMEM:
[pool release];
@throw [OFOutOfMemoryException
exceptionWithClass: [self class]];
default:
assert(0);
}
}
[changeList removeAllItems];
|
︙ | | | ︙ | |
Modified src/OFStreamObserver_poll.m
from [e0025aa14e]
to [106a17bb8d].
︙ | | | ︙ | |
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
|
}
FDsCArray = [FDs cArray];
nFDs = [FDs count];
#ifdef OPEN_MAX
if (nFDs > OPEN_MAX)
@throw [OFOutOfRangeException exceptionWithClass: isa];
#endif
if (poll(FDsCArray, (nfds_t)nFDs, timeout) < 1) {
[pool release];
return NO;
}
|
|
|
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
|
}
FDsCArray = [FDs cArray];
nFDs = [FDs count];
#ifdef OPEN_MAX
if (nFDs > OPEN_MAX)
@throw [OFOutOfRangeException exceptionWithClass: [self class]];
#endif
if (poll(FDsCArray, (nfds_t)nFDs, timeout) < 1) {
[pool release];
return NO;
}
|
︙ | | | ︙ | |
Modified src/OFStreamSocket.m
from [57d59bfcb8]
to [987460de9d].
︙ | | | ︙ | |
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
|
- (size_t)_readIntoBuffer: (void*)buffer
length: (size_t)length
{
ssize_t ret;
if (sock == INVALID_SOCKET)
@throw [OFNotConnectedException exceptionWithClass: isa
socket: self];
if (atEndOfStream) {
OFReadFailedException *e;
e = [OFReadFailedException exceptionWithClass: isa
stream: self
requestedLength: length];
#ifndef _WIN32
e->errNo = ENOTCONN;
#else
e->errNo = WSAENOTCONN;
#endif
@throw e;
}
if ((ret = recv(sock, buffer, length, 0)) < 0)
@throw [OFReadFailedException exceptionWithClass: isa
stream: self
requestedLength: length];
if (ret == 0)
atEndOfStream = YES;
return ret;
}
- (void)_writeBuffer: (const void*)buffer
length: (size_t)length
{
if (sock == INVALID_SOCKET)
@throw [OFNotConnectedException exceptionWithClass: isa
socket: self];
if (atEndOfStream) {
OFWriteFailedException *e;
e = [OFWriteFailedException exceptionWithClass: isa
stream: self
requestedLength: length];
#ifndef _WIN32
e->errNo = ENOTCONN;
#else
e->errNo = WSAENOTCONN;
#endif
@throw e;
}
if (send(sock, buffer, length, 0) < length)
@throw [OFWriteFailedException exceptionWithClass: isa
stream: self
requestedLength: length];
}
#ifdef _WIN32
- (void)setBlocking: (BOOL)enable
{
u_long v = enable;
blocking = enable;
if (ioctlsocket(sock, FIONBIO, &v) == SOCKET_ERROR)
@throw [OFSetOptionFailedException exceptionWithClass: isa
stream: self];
}
#endif
- (int)fileDescriptor
{
return sock;
}
- (void)close
{
if (sock == INVALID_SOCKET)
@throw [OFNotConnectedException exceptionWithClass: isa
socket: self];
close(sock);
sock = INVALID_SOCKET;
atEndOfStream = NO;
}
|
|
|
|
|
|
|
|
>
|
|
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
|
- (size_t)_readIntoBuffer: (void*)buffer
length: (size_t)length
{
ssize_t ret;
if (sock == INVALID_SOCKET)
@throw [OFNotConnectedException exceptionWithClass: [self class]
socket: self];
if (atEndOfStream) {
OFReadFailedException *e;
e = [OFReadFailedException exceptionWithClass: [self class]
stream: self
requestedLength: length];
#ifndef _WIN32
e->errNo = ENOTCONN;
#else
e->errNo = WSAENOTCONN;
#endif
@throw e;
}
if ((ret = recv(sock, buffer, length, 0)) < 0)
@throw [OFReadFailedException exceptionWithClass: [self class]
stream: self
requestedLength: length];
if (ret == 0)
atEndOfStream = YES;
return ret;
}
- (void)_writeBuffer: (const void*)buffer
length: (size_t)length
{
if (sock == INVALID_SOCKET)
@throw [OFNotConnectedException exceptionWithClass: [self class]
socket: self];
if (atEndOfStream) {
OFWriteFailedException *e;
e = [OFWriteFailedException exceptionWithClass: [self class]
stream: self
requestedLength: length];
#ifndef _WIN32
e->errNo = ENOTCONN;
#else
e->errNo = WSAENOTCONN;
#endif
@throw e;
}
if (send(sock, buffer, length, 0) < length)
@throw [OFWriteFailedException exceptionWithClass: [self class]
stream: self
requestedLength: length];
}
#ifdef _WIN32
- (void)setBlocking: (BOOL)enable
{
u_long v = enable;
blocking = enable;
if (ioctlsocket(sock, FIONBIO, &v) == SOCKET_ERROR)
@throw [OFSetOptionFailedException
exceptionWithClass: [self class]
stream: self];
}
#endif
- (int)fileDescriptor
{
return sock;
}
- (void)close
{
if (sock == INVALID_SOCKET)
@throw [OFNotConnectedException exceptionWithClass: [self class]
socket: self];
close(sock);
sock = INVALID_SOCKET;
atEndOfStream = NO;
}
|
︙ | | | ︙ | |
Modified src/OFString+JSONValue.m
from [291a080964]
to [a76e28c035].
︙ | | | ︙ | |
636
637
638
639
640
641
642
643
644
645
646
647
648
|
id object;
size_t line = 1;
object = nextObject(&pointer, stop, &line);
skipWhitespacesAndComments(&pointer, stop, &line);
if (pointer < stop || object == nil)
@throw [OFInvalidJSONException exceptionWithClass: isa
line: line];
return object;
}
@end
|
|
|
636
637
638
639
640
641
642
643
644
645
646
647
648
|
id object;
size_t line = 1;
object = nextObject(&pointer, stop, &line);
skipWhitespacesAndComments(&pointer, stop, &line);
if (pointer < stop || object == nil)
@throw [OFInvalidJSONException exceptionWithClass: [self class]
line: line];
return object;
}
@end
|
Modified src/OFString+Serialization.m
from [5f80765a24]
to [120cf860de].
︙ | | | ︙ | |
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
|
OFXMLElement *root;
OFArray *elements;
id object;
@try {
root = [OFXMLElement elementWithXMLString: self];
} @catch (OFMalformedXMLException *e) {
@throw [OFInvalidArgumentException exceptionWithClass: isa
selector: _cmd];
} @catch (OFUnboundNamespaceException *e) {
@throw [OFInvalidArgumentException exceptionWithClass: isa
selector: _cmd];
}
elements = [root elementsForNamespace: OF_SERIALIZATION_NS];
if ([elements count] != 1)
@throw [OFInvalidArgumentException exceptionWithClass: isa
selector: _cmd];
object = [[elements firstObject] objectByDeserializing];
[object retain];
[pool release];
[object autorelease];
return object;
}
@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
|
OFXMLElement *root;
OFArray *elements;
id object;
@try {
root = [OFXMLElement elementWithXMLString: self];
} @catch (OFMalformedXMLException *e) {
@throw [OFInvalidArgumentException
exceptionWithClass: [self class]
selector: _cmd];
} @catch (OFUnboundNamespaceException *e) {
@throw [OFInvalidArgumentException
exceptionWithClass: [self class]
selector: _cmd];
}
elements = [root elementsForNamespace: OF_SERIALIZATION_NS];
if ([elements count] != 1)
@throw [OFInvalidArgumentException
exceptionWithClass: [self class]
selector: _cmd];
object = [[elements firstObject] objectByDeserializing];
[object retain];
[pool release];
[object autorelease];
return object;
}
@end
|
Modified src/OFString+URLEncoding.m
from [0d263c76b7]
to [4bb769e47e].
︙ | | | ︙ | |
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
/*
* Worst case: 3 times longer than before.
* Oh, and we can't use [self allocWithSize:] here as self might be a
* @"" literal.
*/
if ((retCString = malloc(([self UTF8StringLength] * 3) + 1)) == NULL)
@throw [OFOutOfMemoryException
exceptionWithClass: isa
requestedSize: ([self UTF8StringLength] * 3) + 1];
for (i = 0; *string != '\0'; string++) {
if (isalnum((int)*string) || *string == '-' || *string == '_' ||
*string == '.' || *string == '~')
retCString[i++] = *string;
else {
|
|
|
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
/*
* Worst case: 3 times longer than before.
* Oh, and we can't use [self allocWithSize:] here as self might be a
* @"" literal.
*/
if ((retCString = malloc(([self UTF8StringLength] * 3) + 1)) == NULL)
@throw [OFOutOfMemoryException
exceptionWithClass: [self class]
requestedSize: ([self UTF8StringLength] * 3) + 1];
for (i = 0; *string != '\0'; string++) {
if (isalnum((int)*string) || *string == '-' || *string == '_' ||
*string == '.' || *string == '~')
retCString[i++] = *string;
else {
|
︙ | | | ︙ | |
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
char *retCString;
char byte = 0;
int state = 0;
size_t i;
if ((retCString = malloc([self UTF8StringLength] + 1)) == NULL)
@throw [OFOutOfMemoryException
exceptionWithClass: isa
requestedSize: [self UTF8StringLength] + 1];
for (i = 0; *string; string++) {
switch (state) {
case 0:
if (*string == '%')
state = 1;
|
|
|
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
char *retCString;
char byte = 0;
int state = 0;
size_t i;
if ((retCString = malloc([self UTF8StringLength] + 1)) == NULL)
@throw [OFOutOfMemoryException
exceptionWithClass: [self class]
requestedSize: [self UTF8StringLength] + 1];
for (i = 0; *string; string++) {
switch (state) {
case 0:
if (*string == '%')
state = 1;
|
︙ | | | ︙ | |
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
|
else if (*string >= 'A' && *string <= 'F')
byte += (*string - 'A' + 10) << shift;
else if (*string >= 'a' && *string <= 'f')
byte += (*string - 'a' + 10) << shift;
else {
free(retCString);
@throw [OFInvalidEncodingException
exceptionWithClass: isa];
}
if (++state == 3) {
retCString[i++] = byte;
state = 0;
byte = 0;
}
break;
}
}
retCString[i] = '\0';
if (state != 0) {
free(retCString);
@throw [OFInvalidEncodingException exceptionWithClass: isa];
}
@try {
ret = [OFString stringWithUTF8String: retCString
length: i];
} @finally {
free(retCString);
}
return ret;
}
@end
|
|
|
>
|
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
|
else if (*string >= 'A' && *string <= 'F')
byte += (*string - 'A' + 10) << shift;
else if (*string >= 'a' && *string <= 'f')
byte += (*string - 'a' + 10) << shift;
else {
free(retCString);
@throw [OFInvalidEncodingException
exceptionWithClass: [self class]];
}
if (++state == 3) {
retCString[i++] = byte;
state = 0;
byte = 0;
}
break;
}
}
retCString[i] = '\0';
if (state != 0) {
free(retCString);
@throw [OFInvalidEncodingException
exceptionWithClass: [self class]];
}
@try {
ret = [OFString stringWithUTF8String: retCString
length: i];
} @finally {
free(retCString);
}
return ret;
}
@end
|
Modified src/OFString+XMLEscaping.m
from [6681cd6914]
to [c0bd527074].
︙ | | | ︙ | |
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
j = 0;
retLength = length;
/*
* We can't use allocMemoryWithSize: here as it might be a @"" literal
*/
if ((retCString = malloc(retLength)) == NULL)
@throw [OFOutOfMemoryException exceptionWithClass: isa
requestedSize: retLength];
for (i = 0; i < length; i++) {
switch (string[i]) {
case '<':
append = "<";
appendLen = 4;
|
|
|
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
j = 0;
retLength = length;
/*
* We can't use allocMemoryWithSize: here as it might be a @"" literal
*/
if ((retCString = malloc(retLength)) == NULL)
@throw [OFOutOfMemoryException exceptionWithClass: [self class]
requestedSize: retLength];
for (i = 0; i < length; i++) {
switch (string[i]) {
case '<':
append = "<";
appendLen = 4;
|
︙ | | | ︙ | |
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
if (append != NULL) {
char *newRetCString;
if ((newRetCString = realloc(retCString,
retLength + appendLen)) == NULL) {
free(retCString);
@throw [OFOutOfMemoryException
exceptionWithClass: isa
requestedSize: retLength + appendLen];
}
retCString = newRetCString;
retLength += appendLen - 1;
memcpy(retCString + j, append, appendLen);
j += appendLen;
|
|
|
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
if (append != NULL) {
char *newRetCString;
if ((newRetCString = realloc(retCString,
retLength + appendLen)) == NULL) {
free(retCString);
@throw [OFOutOfMemoryException
exceptionWithClass: [self class]
requestedSize: retLength + appendLen];
}
retCString = newRetCString;
retLength += appendLen - 1;
memcpy(retCString + j, append, appendLen);
j += appendLen;
|
︙ | | | ︙ | |
Modified src/OFString+XMLUnescaping.m
from [0a4c71c87a]
to [9d6ca887c3].
︙ | | | ︙ | |
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
|
pool = [[OFAutoreleasePool alloc] init];
tmp = parse_numeric_entity(entity,
entityLength);
if (tmp == nil)
@throw [OFInvalidEncodingException
exceptionWithClass: isa];
[ret appendString: tmp];
[pool release];
} else if (delegate != nil) {
OFAutoreleasePool *pool;
OFString *n, *tmp;
pool = [[OFAutoreleasePool alloc] init];
n = [OFString
stringWithUTF8String: entity
length: entityLength];
tmp = [delegate string: self
containsUnknownEntityNamed: n];
if (tmp == nil)
@throw [OFInvalidEncodingException
exceptionWithClass: isa];
[ret appendString: tmp];
[pool release];
} else
@throw [OFInvalidEncodingException
exceptionWithClass: isa];
last = i + 1;
inEntity = NO;
}
}
if (inEntity)
@throw [OFInvalidEncodingException exceptionWithClass: isa];
[ret appendUTF8String: string + last
withLength: i - last];
[ret makeImmutable];
return ret;
|
|
|
|
|
>
|
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
183
|
pool = [[OFAutoreleasePool alloc] init];
tmp = parse_numeric_entity(entity,
entityLength);
if (tmp == nil)
@throw [OFInvalidEncodingException
exceptionWithClass: [self class]];
[ret appendString: tmp];
[pool release];
} else if (delegate != nil) {
OFAutoreleasePool *pool;
OFString *n, *tmp;
pool = [[OFAutoreleasePool alloc] init];
n = [OFString
stringWithUTF8String: entity
length: entityLength];
tmp = [delegate string: self
containsUnknownEntityNamed: n];
if (tmp == nil)
@throw [OFInvalidEncodingException
exceptionWithClass: [self class]];
[ret appendString: tmp];
[pool release];
} else
@throw [OFInvalidEncodingException
exceptionWithClass: [self class]];
last = i + 1;
inEntity = NO;
}
}
if (inEntity)
@throw [OFInvalidEncodingException
exceptionWithClass: [self class]];
[ret appendUTF8String: string + last
withLength: i - last];
[ret makeImmutable];
return ret;
|
︙ | | | ︙ | |
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
|
pool = [[OFAutoreleasePool alloc] init];
tmp = parse_numeric_entity(entity,
entityLength);
if (tmp == nil)
@throw [OFInvalidEncodingException
exceptionWithClass: isa];
[ret appendString: tmp];
[pool release];
} else {
OFAutoreleasePool *pool;
OFString *entityString, *tmp;
pool = [[OFAutoreleasePool alloc] init];
entityString = [OFString
stringWithUTF8String: entity
length: entityLength];
tmp = block(self, entityString);
if (tmp == nil)
@throw [OFInvalidEncodingException
exceptionWithClass: isa];
[ret appendString: tmp];
[pool release];
}
last = i + 1;
inEntity = NO;
}
}
if (inEntity)
@throw [OFInvalidEncodingException exceptionWithClass: isa];
[ret appendUTF8String: string + last
withLength: i - last];
[ret makeImmutable];
return ret;
}
#endif
@end
|
|
|
|
>
|
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
|
pool = [[OFAutoreleasePool alloc] init];
tmp = parse_numeric_entity(entity,
entityLength);
if (tmp == nil)
@throw [OFInvalidEncodingException
exceptionWithClass: [self class]];
[ret appendString: tmp];
[pool release];
} else {
OFAutoreleasePool *pool;
OFString *entityString, *tmp;
pool = [[OFAutoreleasePool alloc] init];
entityString = [OFString
stringWithUTF8String: entity
length: entityLength];
tmp = block(self, entityString);
if (tmp == nil)
@throw [OFInvalidEncodingException
exceptionWithClass: [self class]];
[ret appendString: tmp];
[pool release];
}
last = i + 1;
inEntity = NO;
}
}
if (inEntity)
@throw [OFInvalidEncodingException
exceptionWithClass: [self class]];
[ret appendUTF8String: string + last
withLength: i - last];
[ret makeImmutable];
return ret;
}
#endif
@end
|
Modified src/OFString.m
from [b81efdf820]
to [2da268688d].
︙ | | | ︙ | |
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
|
- (void)release
{
}
- (void)dealloc
{
@throw [OFNotImplementedException exceptionWithClass: isa
selector: _cmd];
[super dealloc]; /* Get rid of a stupid warning */
}
@end
@implementation OFString
+ (void)initialize
{
if (self == [OFString class])
placeholder.isa = [OFString_placeholder class];
}
+ alloc
{
if (self == [OFString class])
return (id)&placeholder;
|
|
|
|
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
|
- (void)release
{
}
- (void)dealloc
{
@throw [OFNotImplementedException exceptionWithClass: [self class]
selector: _cmd];
[super dealloc]; /* Get rid of a stupid warning */
}
@end
@implementation OFString
+ (void)initialize
{
if (self == [OFString class])
object_setClass((id)&placeholder, [OFString_placeholder class]);
}
+ alloc
{
if (self == [OFString class])
return (id)&placeholder;
|
︙ | | | ︙ | |
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
|
{
return [[[self alloc] initWithContentsOfURL: URL
encoding: encoding] autorelease];
}
- init
{
if (isa == [OFString class]) {
Class c = isa;
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
return [super init];
}
|
|
|
|
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
|
{
return [[[self alloc] initWithContentsOfURL: URL
encoding: encoding] autorelease];
}
- init
{
if (object_getClass(self) == [OFString class]) {
Class c = [self class];
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
return [super init];
}
|
︙ | | | ︙ | |
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
|
length: strlen(cString)];
}
- initWithCString: (const char*)cString
encoding: (of_string_encoding_t)encoding
length: (size_t)cStringLength
{
Class c = isa;
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
- initWithString: (OFString*)string
{
Class c = isa;
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
- initWithUnicodeString: (const of_unichar_t*)string
{
|
|
|
|
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
|
length: strlen(cString)];
}
- initWithCString: (const char*)cString
encoding: (of_string_encoding_t)encoding
length: (size_t)cStringLength
{
Class c = [self class];
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
- initWithString: (OFString*)string
{
Class c = [self class];
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
- initWithUnicodeString: (const of_unichar_t*)string
{
|
︙ | | | ︙ | |
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
|
length: length];
}
- initWithUnicodeString: (const of_unichar_t*)string
byteOrder: (of_endianess_t)byteOrder
length: (size_t)length
{
Class c = isa;
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
- initWithUTF16String: (const uint16_t*)string
{
|
|
|
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
|
length: length];
}
- initWithUnicodeString: (const of_unichar_t*)string
byteOrder: (of_endianess_t)byteOrder
length: (size_t)length
{
Class c = [self class];
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
- initWithUTF16String: (const uint16_t*)string
{
|
︙ | | | ︙ | |
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
|
length: length];
}
- initWithUTF16String: (const uint16_t*)string
byteOrder: (of_endianess_t)byteOrder
length: (size_t)length
{
Class c = isa;
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
- initWithFormat: (OFConstantString*)format, ...
{
|
|
|
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
|
length: length];
}
- initWithUTF16String: (const uint16_t*)string
byteOrder: (of_endianess_t)byteOrder
length: (size_t)length
{
Class c = [self class];
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
- initWithFormat: (OFConstantString*)format, ...
{
|
︙ | | | ︙ | |
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
|
return ret;
}
- initWithFormat: (OFConstantString*)format
arguments: (va_list)arguments
{
Class c = isa;
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
- initWithPath: (OFString*)firstComponent, ...
{
|
|
|
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
|
return ret;
}
- initWithFormat: (OFConstantString*)format
arguments: (va_list)arguments
{
Class c = [self class];
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
- initWithPath: (OFString*)firstComponent, ...
{
|
︙ | | | ︙ | |
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
|
return ret;
}
- initWithPath: (OFString*)firstComponent
arguments: (va_list)arguments
{
Class c = isa;
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
- initWithContentsOfFile: (OFString*)path
{
|
|
|
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
|
return ret;
}
- initWithPath: (OFString*)firstComponent
arguments: (va_list)arguments
{
Class c = [self class];
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
- initWithContentsOfFile: (OFString*)path
{
|
︙ | | | ︙ | |
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
|
@try {
OFFile *file;
if (stat([path cStringWithEncoding: OF_STRING_ENCODING_NATIVE],
&st) == -1)
@throw [OFOpenFileFailedException
exceptionWithClass: isa
path: path
mode: @"rb"];
if (st.st_size > SIZE_MAX)
@throw [OFOutOfRangeException exceptionWithClass: isa];
file = [[OFFile alloc] initWithPath: path
mode: @"rb"];
@try {
tmp = [self allocMemoryWithSize: (size_t)st.st_size];
|
|
|
>
|
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
|
@try {
OFFile *file;
if (stat([path cStringWithEncoding: OF_STRING_ENCODING_NATIVE],
&st) == -1)
@throw [OFOpenFileFailedException
exceptionWithClass: [self class]
path: path
mode: @"rb"];
if (st.st_size > SIZE_MAX)
@throw [OFOutOfRangeException
exceptionWithClass: [self class]];
file = [[OFFile alloc] initWithPath: path
mode: @"rb"];
@try {
tmp = [self allocMemoryWithSize: (size_t)st.st_size];
|
︙ | | | ︙ | |
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
|
{
OFAutoreleasePool *pool;
OFHTTPRequest *request;
OFHTTPRequestResult *result;
OFString *contentType;
Class c;
c = isa;
[self release];
pool = [[OFAutoreleasePool alloc] init];
if ([[URL scheme] isEqual: @"file"]) {
if (encoding == OF_STRING_ENCODING_AUTODETECT)
encoding = OF_STRING_ENCODING_UTF_8;
|
|
|
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
|
{
OFAutoreleasePool *pool;
OFHTTPRequest *request;
OFHTTPRequestResult *result;
OFString *contentType;
Class c;
c = [self class];
[self release];
pool = [[OFAutoreleasePool alloc] init];
if ([[URL scheme] isEqual: @"file"]) {
if (encoding == OF_STRING_ENCODING_AUTODETECT)
encoding = OF_STRING_ENCODING_UTF_8;
|
︙ | | | ︙ | |
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
|
- initWithSerialization: (OFXMLElement*)element
{
@try {
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
if (![[element namespace] isEqual: OF_SERIALIZATION_NS])
@throw [OFInvalidArgumentException
exceptionWithClass: isa
selector: _cmd];
if ([self isKindOfClass: [OFMutableString class]]) {
if (![[element name] isEqual: @"OFMutableString"])
@throw [OFInvalidArgumentException
exceptionWithClass: isa
selector: _cmd];
} else {
if (![[element name] isEqual: @"OFString"])
@throw [OFInvalidArgumentException
exceptionWithClass: isa
selector: _cmd];
}
self = [self initWithString: [element stringValue]];
[pool release];
} @catch (id e) {
|
|
|
|
|
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
|
- initWithSerialization: (OFXMLElement*)element
{
@try {
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
if (![[element namespace] isEqual: OF_SERIALIZATION_NS])
@throw [OFInvalidArgumentException
exceptionWithClass: [self class]
selector: _cmd];
if ([self isKindOfClass: [OFMutableString class]]) {
if (![[element name] isEqual: @"OFMutableString"])
@throw [OFInvalidArgumentException
exceptionWithClass: [self class]
selector: _cmd];
} else {
if (![[element name] isEqual: @"OFString"])
@throw [OFInvalidArgumentException
exceptionWithClass: [self class]
selector: _cmd];
}
self = [self initWithString: [element stringValue]];
[pool release];
} @catch (id e) {
|
︙ | | | ︙ | |
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
|
memcpy(UTF8String + j, buffer, 4);
j += 4;
break;
default:
@throw [OFInvalidEncodingException
exceptionWithClass: isa];
}
}
UTF8String[j] = '\0';
@try {
UTF8String = [object resizeMemory: UTF8String
|
|
|
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
|
memcpy(UTF8String + j, buffer, 4);
j += 4;
break;
default:
@throw [OFInvalidEncodingException
exceptionWithClass: [self class]];
}
}
UTF8String[j] = '\0';
@try {
UTF8String = [object resizeMemory: UTF8String
|
︙ | | | ︙ | |
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
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
|
- (const char*)cStringWithEncoding: (of_string_encoding_t)encoding
{
if (encoding == OF_STRING_ENCODING_UTF_8)
return [self UTF8String];
/* TODO: Implement! */
@throw [OFNotImplementedException exceptionWithClass: isa
selector: _cmd];
}
- (size_t)length
{
@throw [OFNotImplementedException exceptionWithClass: isa
selector: _cmd];
}
- (size_t)UTF8StringLength
{
const of_unichar_t *unicodeString = [self unicodeString];
size_t length = [self length];
size_t i, UTF8StringLength = 0;
for (i = 0; i < length; i++) {
char buffer[4];
size_t characterLen = of_string_unicode_to_utf8(
unicodeString[i], buffer);
if (characterLen == 0)
@throw [OFInvalidEncodingException
exceptionWithClass: isa];
UTF8StringLength += characterLen;
}
return UTF8StringLength;
}
- (size_t)cStringLengthWithEncoding: (of_string_encoding_t)encoding
{
if (encoding == OF_STRING_ENCODING_UTF_8)
return [self UTF8StringLength];
/* TODO: Implement! */
@throw [OFNotImplementedException exceptionWithClass: isa
selector: _cmd];
}
- (of_unichar_t)characterAtIndex: (size_t)index
{
@throw [OFNotImplementedException exceptionWithClass: isa
selector: _cmd];
}
- (void)getCharacters: (of_unichar_t*)buffer
inRange: (of_range_t)range
{
size_t i;
|
|
|
|
|
|
|
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
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
|
- (const char*)cStringWithEncoding: (of_string_encoding_t)encoding
{
if (encoding == OF_STRING_ENCODING_UTF_8)
return [self UTF8String];
/* TODO: Implement! */
@throw [OFNotImplementedException exceptionWithClass: [self class]
selector: _cmd];
}
- (size_t)length
{
@throw [OFNotImplementedException exceptionWithClass: [self class]
selector: _cmd];
}
- (size_t)UTF8StringLength
{
const of_unichar_t *unicodeString = [self unicodeString];
size_t length = [self length];
size_t i, UTF8StringLength = 0;
for (i = 0; i < length; i++) {
char buffer[4];
size_t characterLen = of_string_unicode_to_utf8(
unicodeString[i], buffer);
if (characterLen == 0)
@throw [OFInvalidEncodingException
exceptionWithClass: [self class]];
UTF8StringLength += characterLen;
}
return UTF8StringLength;
}
- (size_t)cStringLengthWithEncoding: (of_string_encoding_t)encoding
{
if (encoding == OF_STRING_ENCODING_UTF_8)
return [self UTF8StringLength];
/* TODO: Implement! */
@throw [OFNotImplementedException exceptionWithClass: [self class]
selector: _cmd];
}
- (of_unichar_t)characterAtIndex: (size_t)index
{
@throw [OFNotImplementedException exceptionWithClass: [self class]
selector: _cmd];
}
- (void)getCharacters: (of_unichar_t*)buffer
inRange: (of_range_t)range
{
size_t i;
|
︙ | | | ︙ | |
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
|
const of_unichar_t *unicodeString, *otherUnicodeString;
size_t i, minimumLength;
if (object == self)
return OF_ORDERED_SAME;
if (![object isKindOfClass: [OFString class]])
@throw [OFInvalidArgumentException exceptionWithClass: isa
selector: _cmd];
otherString = object;
minimumLength = ([self length] > [otherString length]
? [otherString length] : [self length]);
pool = [[OFAutoreleasePool alloc] init];
|
|
>
|
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
|
const of_unichar_t *unicodeString, *otherUnicodeString;
size_t i, minimumLength;
if (object == self)
return OF_ORDERED_SAME;
if (![object isKindOfClass: [OFString class]])
@throw [OFInvalidArgumentException
exceptionWithClass: [self class]
selector: _cmd];
otherString = object;
minimumLength = ([self length] > [otherString length]
? [otherString length] : [self length]);
pool = [[OFAutoreleasePool alloc] init];
|
︙ | | | ︙ | |
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
|
- (OFString*)substringWithRange: (of_range_t)range
{
OFAutoreleasePool *pool;
OFString *ret;
if (range.start + range.length > [self length])
@throw [OFOutOfRangeException exceptionWithClass: isa];
pool = [[OFAutoreleasePool alloc] init];
ret = [[OFString alloc]
initWithUnicodeString: [self unicodeString] + range.start
length: range.length];
[pool release];
|
|
>
|
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
|
- (OFString*)substringWithRange: (of_range_t)range
{
OFAutoreleasePool *pool;
OFString *ret;
if (range.start + range.length > [self length])
@throw [OFOutOfRangeException
exceptionWithClass: [self class]];
pool = [[OFAutoreleasePool alloc] init];
ret = [[OFString alloc]
initWithUnicodeString: [self unicodeString] + range.start
length: range.length];
[pool release];
|
︙ | | | ︙ | |
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
|
for (; i < length; i++) {
if (expectWhitespace) {
if (string[i] != ' ' && string[i] != '\t' &&
string[i] != '\n' && string[i] != '\r' &&
string[i] != '\f')
@throw [OFInvalidFormatException
exceptionWithClass: isa];
continue;
}
if (string[i] >= '0' && string[i] <= '9') {
if (INTMAX_MAX / 10 < value ||
INTMAX_MAX - value * 10 < string[i] - '0')
@throw [OFOutOfRangeException
exceptionWithClass: isa];
value = (value * 10) + (string[i] - '0');
} else if (string[i] == ' ' || string[i] == '\t' ||
string[i] == '\n' || string[i] == '\r' ||
string[i] == '\f')
expectWhitespace = YES;
else
@throw [OFInvalidFormatException
exceptionWithClass: isa];
}
if (string[0] == '-')
value *= -1;
[pool release];
|
|
|
|
|
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
|
for (; i < length; i++) {
if (expectWhitespace) {
if (string[i] != ' ' && string[i] != '\t' &&
string[i] != '\n' && string[i] != '\r' &&
string[i] != '\f')
@throw [OFInvalidFormatException
exceptionWithClass: [self class]];
continue;
}
if (string[i] >= '0' && string[i] <= '9') {
if (INTMAX_MAX / 10 < value ||
INTMAX_MAX - value * 10 < string[i] - '0')
@throw [OFOutOfRangeException
exceptionWithClass: [self class]];
value = (value * 10) + (string[i] - '0');
} else if (string[i] == ' ' || string[i] == '\t' ||
string[i] == '\n' || string[i] == '\r' ||
string[i] == '\f')
expectWhitespace = YES;
else
@throw [OFInvalidFormatException
exceptionWithClass: [self class]];
}
if (string[0] == '-')
value *= -1;
[pool release];
|
︙ | | | ︙ | |
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
|
uintmax_t newValue;
if (expectWhitespace) {
if (string[i] != ' ' && string[i] != '\t' &&
string[i] != '\n' && string[i] != '\r' &&
string[i] != '\f')
@throw [OFInvalidFormatException
exceptionWithClass: isa];
continue;
}
if (string[i] >= '0' && string[i] <= '9') {
newValue = (value << 4) | (string[i] - '0');
foundValue = YES;
} else if (string[i] >= 'A' && string[i] <= 'F') {
newValue = (value << 4) | (string[i] - 'A' + 10);
foundValue = YES;
} else if (string[i] >= 'a' && string[i] <= 'f') {
newValue = (value << 4) | (string[i] - 'a' + 10);
foundValue = YES;
} else if (string[i] == 'h' || string[i] == ' ' ||
string[i] == '\t' || string[i] == '\n' ||
string[i] == '\r' || string[i] == '\f') {
expectWhitespace = YES;
continue;
} else
@throw [OFInvalidFormatException
exceptionWithClass: isa];
if (newValue < value)
@throw [OFOutOfRangeException exceptionWithClass: isa];
value = newValue;
}
if (!foundValue)
@throw [OFInvalidFormatException exceptionWithClass: isa];
[pool release];
return value;
}
- (float)floatValue
|
|
|
|
>
|
>
|
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
|
uintmax_t newValue;
if (expectWhitespace) {
if (string[i] != ' ' && string[i] != '\t' &&
string[i] != '\n' && string[i] != '\r' &&
string[i] != '\f')
@throw [OFInvalidFormatException
exceptionWithClass: [self class]];
continue;
}
if (string[i] >= '0' && string[i] <= '9') {
newValue = (value << 4) | (string[i] - '0');
foundValue = YES;
} else if (string[i] >= 'A' && string[i] <= 'F') {
newValue = (value << 4) | (string[i] - 'A' + 10);
foundValue = YES;
} else if (string[i] >= 'a' && string[i] <= 'f') {
newValue = (value << 4) | (string[i] - 'a' + 10);
foundValue = YES;
} else if (string[i] == 'h' || string[i] == ' ' ||
string[i] == '\t' || string[i] == '\n' ||
string[i] == '\r' || string[i] == '\f') {
expectWhitespace = YES;
continue;
} else
@throw [OFInvalidFormatException
exceptionWithClass: [self class]];
if (newValue < value)
@throw [OFOutOfRangeException
exceptionWithClass: [self class]];
value = newValue;
}
if (!foundValue)
@throw [OFInvalidFormatException
exceptionWithClass: [self class]];
[pool release];
return value;
}
- (float)floatValue
|
︙ | | | ︙ | |
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
|
/* Check if there are any invalid chars left */
if (endPointer != NULL)
for (; *endPointer != '\0'; endPointer++)
if (*endPointer != ' ' && *endPointer != '\t' &&
*endPointer != '\n' && *endPointer != '\r' &&
*endPointer != '\f')
@throw [OFInvalidFormatException
exceptionWithClass: isa];
[pool release];
return value;
}
- (double)doubleValue
|
|
|
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
|
/* Check if there are any invalid chars left */
if (endPointer != NULL)
for (; *endPointer != '\0'; endPointer++)
if (*endPointer != ' ' && *endPointer != '\t' &&
*endPointer != '\n' && *endPointer != '\r' &&
*endPointer != '\f')
@throw [OFInvalidFormatException
exceptionWithClass: [self class]];
[pool release];
return value;
}
- (double)doubleValue
|
︙ | | | ︙ | |
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
|
/* Check if there are any invalid chars left */
if (endPointer != NULL)
for (; *endPointer != '\0'; endPointer++)
if (*endPointer != ' ' && *endPointer != '\t' &&
*endPointer != '\n' && *endPointer != '\r' &&
*endPointer != '\f')
@throw [OFInvalidFormatException
exceptionWithClass: isa];
[pool release];
return value;
}
- (const of_unichar_t*)unicodeString
|
|
|
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
|
/* Check if there are any invalid chars left */
if (endPointer != NULL)
for (; *endPointer != '\0'; endPointer++)
if (*endPointer != ' ' && *endPointer != '\t' &&
*endPointer != '\n' && *endPointer != '\r' &&
*endPointer != '\f')
@throw [OFInvalidFormatException
exceptionWithClass: [self class]];
[pool release];
return value;
}
- (const of_unichar_t*)unicodeString
|
︙ | | | ︙ | |
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
|
j = 0;
for (i = 0; i < length; i++) {
of_unichar_t c = unicodeString[i];
if (c > 0x10FFFF)
@throw [OFInvalidEncodingException
exceptionWithClass: isa];
if (c > 0xFFFF) {
c -= 0x10000;
ret[j++] = of_bswap16_if_le(0xD800 | (c >> 10));
ret[j++] = of_bswap16_if_le(0xDC00 | (c & 0x3FF));
} else
ret[j++] = of_bswap16_if_le(c);
|
|
|
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
|
j = 0;
for (i = 0; i < length; i++) {
of_unichar_t c = unicodeString[i];
if (c > 0x10FFFF)
@throw [OFInvalidEncodingException
exceptionWithClass: [self class]];
if (c > 0xFFFF) {
c -= 0x10000;
ret[j++] = of_bswap16_if_le(0xD800 | (c >> 10));
ret[j++] = of_bswap16_if_le(0xDC00 | (c & 0x3FF));
} else
ret[j++] = of_bswap16_if_le(c);
|
︙ | | | ︙ | |
Modified src/OFString_UTF8.m
from [65dd22d751]
to [090bb87767].
︙ | | | ︙ | |
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
switch (of_string_check_utf8(UTF8String, UTF8StringLength,
&s->length)) {
case 1:
s->UTF8 = YES;
break;
case -1:
@throw [OFInvalidEncodingException
exceptionWithClass: isa];
}
memcpy(s->cString, UTF8String, UTF8StringLength);
s->cString[UTF8StringLength] = 0;
} @catch (id e) {
[self release];
@throw e;
|
|
|
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
switch (of_string_check_utf8(UTF8String, UTF8StringLength,
&s->length)) {
case 1:
s->UTF8 = YES;
break;
case -1:
@throw [OFInvalidEncodingException
exceptionWithClass: [self class]];
}
memcpy(s->cString, UTF8String, UTF8StringLength);
s->cString[UTF8StringLength] = 0;
} @catch (id e) {
[self release];
@throw e;
|
︙ | | | ︙ | |
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
|
if (encoding == OF_STRING_ENCODING_UTF_8 ||
encoding == OF_STRING_ENCODING_ASCII) {
switch (of_string_check_utf8(cString, cStringLength,
&s->length)) {
case 1:
if (encoding == OF_STRING_ENCODING_ASCII)
@throw [OFInvalidEncodingException
exceptionWithClass: isa];
s->UTF8 = YES;
break;
case -1:
@throw [OFInvalidEncodingException
exceptionWithClass: isa];
}
memcpy(s->cString, cString, cStringLength);
s->cString[cStringLength] = 0;
return self;
}
|
|
|
|
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
|
if (encoding == OF_STRING_ENCODING_UTF_8 ||
encoding == OF_STRING_ENCODING_ASCII) {
switch (of_string_check_utf8(cString, cStringLength,
&s->length)) {
case 1:
if (encoding == OF_STRING_ENCODING_ASCII)
@throw [OFInvalidEncodingException
exceptionWithClass: [self class]];
s->UTF8 = YES;
break;
case -1:
@throw [OFInvalidEncodingException
exceptionWithClass: [self class]];
}
memcpy(s->cString, cString, cStringLength);
s->cString[cStringLength] = 0;
return self;
}
|
︙ | | | ︙ | |
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
|
s->UTF8 = YES;
bytes = of_string_unicode_to_utf8(
(uint8_t)cString[i], buffer);
if (bytes == 0)
@throw [OFInvalidEncodingException
exceptionWithClass: isa];
s->cStringLength += bytes - 1;
s->cString = [self
resizeMemory: s->cString
size: s->cStringLength + 1];
memcpy(s->cString + j, buffer, bytes);
|
|
|
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
|
s->UTF8 = YES;
bytes = of_string_unicode_to_utf8(
(uint8_t)cString[i], buffer);
if (bytes == 0)
@throw [OFInvalidEncodingException
exceptionWithClass: [self class]];
s->cStringLength += bytes - 1;
s->cString = [self
resizeMemory: s->cString
size: s->cStringLength + 1];
memcpy(s->cString + j, buffer, bytes);
|
︙ | | | ︙ | |
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
|
table = of_iso_8859_15;
break;
case OF_STRING_ENCODING_WINDOWS_1252:
table = of_windows_1252;
break;
default:
@throw [OFInvalidEncodingException
exceptionWithClass: isa];
}
for (i = j = 0; i < cStringLength; i++) {
char buffer[4];
of_unichar_t character;
size_t characterBytes;
if (!(cString[i] & 0x80)) {
s->cString[j++] = cString[i];
continue;
}
character = table[(uint8_t)cString[i]];
if (character == 0xFFFD)
@throw [OFInvalidEncodingException
exceptionWithClass: isa];
s->UTF8 = YES;
characterBytes = of_string_unicode_to_utf8(character,
buffer);
if (characterBytes == 0)
@throw [OFInvalidEncodingException
exceptionWithClass: isa];
s->cStringLength += characterBytes - 1;
s->cString = [self resizeMemory: s->cString
size: s->cStringLength + 1];
memcpy(s->cString + j, buffer, characterBytes);
j += characterBytes;
|
|
|
|
|
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
|
table = of_iso_8859_15;
break;
case OF_STRING_ENCODING_WINDOWS_1252:
table = of_windows_1252;
break;
default:
@throw [OFInvalidEncodingException
exceptionWithClass: [self class]];
}
for (i = j = 0; i < cStringLength; i++) {
char buffer[4];
of_unichar_t character;
size_t characterBytes;
if (!(cString[i] & 0x80)) {
s->cString[j++] = cString[i];
continue;
}
character = table[(uint8_t)cString[i]];
if (character == 0xFFFD)
@throw [OFInvalidEncodingException
exceptionWithClass: [self class]];
s->UTF8 = YES;
characterBytes = of_string_unicode_to_utf8(character,
buffer);
if (characterBytes == 0)
@throw [OFInvalidEncodingException
exceptionWithClass: [self class]];
s->cStringLength += characterBytes - 1;
s->cString = [self resizeMemory: s->cString
size: s->cStringLength + 1];
memcpy(s->cString + j, buffer, characterBytes);
j += characterBytes;
|
︙ | | | ︙ | |
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
|
memcpy(s->cString + j, buffer, 4);
j += 4;
break;
default:
@throw [OFInvalidEncodingException
exceptionWithClass: isa];
}
}
s->cString[j] = '\0';
@try {
s->cString = [self resizeMemory: s->cString
|
|
|
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
|
memcpy(s->cString + j, buffer, 4);
j += 4;
break;
default:
@throw [OFInvalidEncodingException
exceptionWithClass: [self class]];
}
}
s->cString[j] = '\0';
@try {
s->cString = [self resizeMemory: s->cString
|
︙ | | | ︙ | |
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
|
of_unichar_t character =
(swap ? of_bswap16(string[i]) : string[i]);
size_t characterLen;
/* Missing high surrogate */
if ((character & 0xFC00) == 0xDC00)
@throw [OFInvalidEncodingException
exceptionWithClass: isa];
if ((character & 0xFC00) == 0xD800) {
uint16_t nextCharacter;
if (length <= i + 1)
@throw [OFInvalidEncodingException
exceptionWithClass: isa];
nextCharacter = (swap
? of_bswap16(string[i + 1])
: string[i + 1]);
character = (((character & 0x3FF) << 10) |
(nextCharacter & 0x3FF)) + 0x10000;
|
|
|
|
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
|
of_unichar_t character =
(swap ? of_bswap16(string[i]) : string[i]);
size_t characterLen;
/* Missing high surrogate */
if ((character & 0xFC00) == 0xDC00)
@throw [OFInvalidEncodingException
exceptionWithClass: [self class]];
if ((character & 0xFC00) == 0xD800) {
uint16_t nextCharacter;
if (length <= i + 1)
@throw [OFInvalidEncodingException
exceptionWithClass: [self class]];
nextCharacter = (swap
? of_bswap16(string[i + 1])
: string[i + 1]);
character = (((character & 0x3FF) << 10) |
(nextCharacter & 0x3FF)) + 0x10000;
|
︙ | | | ︙ | |
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
|
memcpy(s->cString + j, buffer, 4);
j += 4;
break;
default:
@throw [OFInvalidEncodingException
exceptionWithClass: isa];
}
}
s->cString[j] = '\0';
@try {
s->cString = [self resizeMemory: s->cString
|
|
|
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
|
memcpy(s->cString + j, buffer, 4);
j += 4;
break;
default:
@throw [OFInvalidEncodingException
exceptionWithClass: [self class]];
}
}
s->cString[j] = '\0';
@try {
s->cString = [self resizeMemory: s->cString
|
︙ | | | ︙ | |
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
495
496
497
498
499
500
501
502
503
|
@try {
char *tmp;
int cStringLength;
if (format == nil)
@throw [OFInvalidArgumentException
exceptionWithClass: isa
selector: _cmd];
s = &s_store;
if ((cStringLength = of_vasprintf(&tmp, [format UTF8String],
arguments)) == -1)
@throw [OFInvalidFormatException
exceptionWithClass: isa];
s->cStringLength = cStringLength;
@try {
switch (of_string_check_utf8(tmp, cStringLength,
&s->length)) {
case 1:
s->UTF8 = YES;
break;
case -1:
@throw [OFInvalidEncodingException
exceptionWithClass: isa];
}
s->cString = [self
allocMemoryWithSize: cStringLength + 1];
memcpy(s->cString, tmp, cStringLength + 1);
} @finally {
free(tmp);
|
|
|
|
|
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
495
496
497
498
499
500
501
502
503
|
@try {
char *tmp;
int cStringLength;
if (format == nil)
@throw [OFInvalidArgumentException
exceptionWithClass: [self class]
selector: _cmd];
s = &s_store;
if ((cStringLength = of_vasprintf(&tmp, [format UTF8String],
arguments)) == -1)
@throw [OFInvalidFormatException
exceptionWithClass: [self class]];
s->cStringLength = cStringLength;
@try {
switch (of_string_check_utf8(tmp, cStringLength,
&s->length)) {
case 1:
s->UTF8 = YES;
break;
case -1:
@throw [OFInvalidEncodingException
exceptionWithClass: [self class]];
}
s->cString = [self
allocMemoryWithSize: cStringLength + 1];
memcpy(s->cString, tmp, cStringLength + 1);
} @finally {
free(tmp);
|
︙ | | | ︙ | |
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
|
{
switch (encoding) {
case OF_STRING_ENCODING_UTF_8:
return s->cString;
case OF_STRING_ENCODING_ASCII:
if (s->UTF8)
@throw [OFInvalidEncodingException
exceptionWithClass: isa];
return s->cString;
default:
@throw [OFNotImplementedException exceptionWithClass: isa
selector: _cmd];
}
}
- (size_t)length
{
return s->length;
|
|
|
>
|
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
|
{
switch (encoding) {
case OF_STRING_ENCODING_UTF_8:
return s->cString;
case OF_STRING_ENCODING_ASCII:
if (s->UTF8)
@throw [OFInvalidEncodingException
exceptionWithClass: [self class]];
return s->cString;
default:
@throw [OFNotImplementedException
exceptionWithClass: [self class]
selector: _cmd];
}
}
- (size_t)length
{
return s->length;
|
︙ | | | ︙ | |
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
|
{
switch (encoding) {
case OF_STRING_ENCODING_UTF_8:
return s->cStringLength;
case OF_STRING_ENCODING_ASCII:
if (s->UTF8)
@throw [OFInvalidEncodingException
exceptionWithClass: isa];
return s->cStringLength;
default:
@throw [OFNotImplementedException exceptionWithClass: isa
selector: _cmd];
}
}
- (BOOL)isEqual: (id)object
{
OFString_UTF8 *otherString;
|
|
|
>
|
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
|
{
switch (encoding) {
case OF_STRING_ENCODING_UTF_8:
return s->cStringLength;
case OF_STRING_ENCODING_ASCII:
if (s->UTF8)
@throw [OFInvalidEncodingException
exceptionWithClass: [self class]];
return s->cStringLength;
default:
@throw [OFNotImplementedException
exceptionWithClass: [self class]
selector: _cmd];
}
}
- (BOOL)isEqual: (id)object
{
OFString_UTF8 *otherString;
|
︙ | | | ︙ | |
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
|
size_t otherCStringLength, minimumCStringLength;
int compare;
if (object == self)
return OF_ORDERED_SAME;
if (![object isKindOfClass: [OFString class]])
@throw [OFInvalidArgumentException exceptionWithClass: isa
selector: _cmd];
otherString = object;
otherCStringLength = [otherString UTF8StringLength];
minimumCStringLength = (s->cStringLength > otherCStringLength
? otherCStringLength : s->cStringLength);
|
|
>
|
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
|
size_t otherCStringLength, minimumCStringLength;
int compare;
if (object == self)
return OF_ORDERED_SAME;
if (![object isKindOfClass: [OFString class]])
@throw [OFInvalidArgumentException
exceptionWithClass: [self class]
selector: _cmd];
otherString = object;
otherCStringLength = [otherString UTF8StringLength];
minimumCStringLength = (s->cStringLength > otherCStringLength
? otherCStringLength : s->cStringLength);
|
︙ | | | ︙ | |
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
|
size_t i, j, otherCStringLength, minimumCStringLength;
int compare;
if (otherString == self)
return OF_ORDERED_SAME;
if (![otherString isKindOfClass: [OFString class]])
@throw [OFInvalidArgumentException exceptionWithClass: isa
selector: _cmd];
otherCString = [otherString UTF8String];
otherCStringLength = [otherString UTF8StringLength];
if (!s->UTF8) {
minimumCStringLength = (s->cStringLength > otherCStringLength
|
|
>
|
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
|
size_t i, j, otherCStringLength, minimumCStringLength;
int compare;
if (otherString == self)
return OF_ORDERED_SAME;
if (![otherString isKindOfClass: [OFString class]])
@throw [OFInvalidArgumentException
exceptionWithClass: [self class]
selector: _cmd];
otherCString = [otherString UTF8String];
otherCStringLength = [otherString UTF8StringLength];
if (!s->UTF8) {
minimumCStringLength = (s->cStringLength > otherCStringLength
|
︙ | | | ︙ | |
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
|
l1 = of_string_utf8_to_unicode(s->cString + i,
s->cStringLength - i, &c1);
l2 = of_string_utf8_to_unicode(otherCString + j,
otherCStringLength - j, &c2);
if (l1 == 0 || l2 == 0 || c1 > 0x10FFFF || c2 > 0x10FFFF)
@throw [OFInvalidEncodingException
exceptionWithClass: isa];
if (c1 >> 8 < OF_UNICODE_CASEFOLDING_TABLE_SIZE) {
of_unichar_t tc =
of_unicode_casefolding_table[c1 >> 8][c1 & 0xFF];
if (tc)
c1 = tc;
|
|
|
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
|
l1 = of_string_utf8_to_unicode(s->cString + i,
s->cStringLength - i, &c1);
l2 = of_string_utf8_to_unicode(otherCString + j,
otherCStringLength - j, &c2);
if (l1 == 0 || l2 == 0 || c1 > 0x10FFFF || c2 > 0x10FFFF)
@throw [OFInvalidEncodingException
exceptionWithClass: [self class]];
if (c1 >> 8 < OF_UNICODE_CASEFOLDING_TABLE_SIZE) {
of_unichar_t tc =
of_unicode_casefolding_table[c1 >> 8][c1 & 0xFF];
if (tc)
c1 = tc;
|
︙ | | | ︙ | |
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
|
for (i = 0; i < s->cStringLength; i++) {
of_unichar_t c;
size_t length;
if ((length = of_string_utf8_to_unicode(s->cString + i,
s->cStringLength - i, &c)) == 0)
@throw [OFInvalidEncodingException
exceptionWithClass: isa];
OF_HASH_ADD(hash, (c & 0xFF0000) >> 16);
OF_HASH_ADD(hash, (c & 0x00FF00) >> 8);
OF_HASH_ADD(hash, c & 0x0000FF);
i += length - 1;
}
|
|
|
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
|
for (i = 0; i < s->cStringLength; i++) {
of_unichar_t c;
size_t length;
if ((length = of_string_utf8_to_unicode(s->cString + i,
s->cStringLength - i, &c)) == 0)
@throw [OFInvalidEncodingException
exceptionWithClass: [self class]];
OF_HASH_ADD(hash, (c & 0xFF0000) >> 16);
OF_HASH_ADD(hash, (c & 0x00FF00) >> 8);
OF_HASH_ADD(hash, c & 0x0000FF);
i += length - 1;
}
|
︙ | | | ︙ | |
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
|
}
- (of_unichar_t)characterAtIndex: (size_t)index
{
of_unichar_t character;
if (index >= s->length)
@throw [OFOutOfRangeException exceptionWithClass: isa];
if (!s->UTF8)
return s->cString[index];
index = of_string_index_to_position(s->cString, index,
s->cStringLength);
if (!of_string_utf8_to_unicode(s->cString + index,
s->cStringLength - index, &character))
@throw [OFInvalidEncodingException exceptionWithClass: isa];
return character;
}
- (void)getCharacters: (of_unichar_t*)buffer
inRange: (of_range_t)range
{
|
|
|
>
|
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
|
}
- (of_unichar_t)characterAtIndex: (size_t)index
{
of_unichar_t character;
if (index >= s->length)
@throw [OFOutOfRangeException exceptionWithClass: [self class]];
if (!s->UTF8)
return s->cString[index];
index = of_string_index_to_position(s->cString, index,
s->cStringLength);
if (!of_string_utf8_to_unicode(s->cString + index,
s->cStringLength - index, &character))
@throw [OFInvalidEncodingException
exceptionWithClass: [self class]];
return character;
}
- (void)getCharacters: (of_unichar_t*)buffer
inRange: (of_range_t)range
{
|
︙ | | | ︙ | |
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
|
- (OFString*)substringWithRange: (of_range_t)range
{
size_t start = range.start;
size_t end = range.start + range.length;
if (end > s->length)
@throw [OFOutOfRangeException exceptionWithClass: isa];
if (s->UTF8) {
start = of_string_index_to_position(s->cString, start,
s->cStringLength);
end = of_string_index_to_position(s->cString, end,
s->cStringLength);
}
|
|
|
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
|
- (OFString*)substringWithRange: (of_range_t)range
{
size_t start = range.start;
size_t end = range.start + range.length;
if (end > s->length)
@throw [OFOutOfRangeException exceptionWithClass: [self class]];
if (s->UTF8) {
start = of_string_index_to_position(s->cString, start,
s->cStringLength);
end = of_string_index_to_position(s->cString, end,
s->cStringLength);
}
|
︙ | | | ︙ | |
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
|
size_t cLen;
cLen = of_string_utf8_to_unicode(s->cString + i,
s->cStringLength - i, &c);
if (cLen == 0 || c > 0x10FFFF)
@throw [OFInvalidEncodingException
exceptionWithClass: isa];
ret[j++] = c;
i += cLen;
}
ret[j] = 0;
|
|
|
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
|
size_t cLen;
cLen = of_string_utf8_to_unicode(s->cString + i,
s->cStringLength - i, &c);
if (cLen == 0 || c > 0x10FFFF)
@throw [OFInvalidEncodingException
exceptionWithClass: [self class]];
ret[j++] = c;
i += cLen;
}
ret[j] = 0;
|
︙ | | | ︙ | |
Modified src/OFTCPSocket+SOCKS5.m
from [a16701d00f]
to [69a9d94787].
︙ | | | ︙ | |
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
[self readIntoBuffer: reply
exactLength: 2];
if (reply[0] != 5 || reply[1] != 0) {
[self close];
@throw [OFConnectionFailedException
exceptionWithClass: isa
socket: self
host: host
port: port];
}
oldWriteBufferEnabled = [self writeBufferEnabled];
[self setWriteBufferEnabled: YES];
|
|
|
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
[self readIntoBuffer: reply
exactLength: 2];
if (reply[0] != 5 || reply[1] != 0) {
[self close];
@throw [OFConnectionFailedException
exceptionWithClass: [self class]
socket: self
host: host
port: port];
}
oldWriteBufferEnabled = [self writeBufferEnabled];
[self setWriteBufferEnabled: YES];
|
︙ | | | ︙ | |
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
[self setWriteBufferEnabled: oldWriteBufferEnabled];
[self readIntoBuffer: reply
exactLength: 4];
if (reply[0] != 5 || reply[1] != 0 || reply[2] != 0) {
[self close];
@throw [OFConnectionFailedException exceptionWithClass: isa
socket: self
host: host
port: port];
}
/* Skip the rest of the reply */
switch (reply[3]) {
|
|
>
|
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
[self setWriteBufferEnabled: oldWriteBufferEnabled];
[self readIntoBuffer: reply
exactLength: 4];
if (reply[0] != 5 || reply[1] != 0 || reply[2] != 0) {
[self close];
@throw [OFConnectionFailedException
exceptionWithClass: [self class]
socket: self
host: host
port: port];
}
/* Skip the rest of the reply */
switch (reply[3]) {
|
︙ | | | ︙ | |
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
break;
case 4: /* IPv6 */
[self readIntoBuffer: reply
exactLength: 16];
break;
default:
[self close];
@throw [OFConnectionFailedException exceptionWithClass: isa
socket: self
host: host
port: port];
}
[self readBigEndianInt16];
}
@end
|
|
>
|
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
|
break;
case 4: /* IPv6 */
[self readIntoBuffer: reply
exactLength: 16];
break;
default:
[self close];
@throw [OFConnectionFailedException
exceptionWithClass: [self class]
socket: self
host: host
port: port];
}
[self readBigEndianInt16];
}
@end
|
Modified src/OFTCPSocket.m
from [43ccdbbf0d]
to [f2b49c30d2].
︙ | | | ︙ | |
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
|
- (void)connectToHost: (OFString*)host
port: (uint16_t)port
{
OFString *destinationHost = host;
uint16_t destinationPort = port;
if (sock != INVALID_SOCKET)
@throw [OFAlreadyConnectedException exceptionWithClass: isa
socket: self];
if (SOCKS5Host != nil) {
/* Connect to the SOCKS5 proxy instead */
host = SOCKS5Host;
port = SOCKS5Port;
}
#ifdef HAVE_THREADSAFE_GETADDRINFO
struct addrinfo hints, *res, *res0;
char portCString[7];
memset(&hints, 0, sizeof(struct addrinfo));
hints.ai_family = AF_UNSPEC;
hints.ai_socktype = SOCK_STREAM;
snprintf(portCString, 7, "%" PRIu16, port);
if (getaddrinfo([host cStringWithEncoding: OF_STRING_ENCODING_NATIVE],
portCString, &hints, &res0))
@throw [OFAddressTranslationFailedException
exceptionWithClass: isa
socket: self
host: host];
for (res = res0; res != NULL; res = res->ai_next) {
if ((sock = socket(res->ai_family, res->ai_socktype,
res->ai_protocol)) == INVALID_SOCKET)
continue;
|
|
>
|
|
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
|
- (void)connectToHost: (OFString*)host
port: (uint16_t)port
{
OFString *destinationHost = host;
uint16_t destinationPort = port;
if (sock != INVALID_SOCKET)
@throw [OFAlreadyConnectedException
exceptionWithClass: [self class]
socket: self];
if (SOCKS5Host != nil) {
/* Connect to the SOCKS5 proxy instead */
host = SOCKS5Host;
port = SOCKS5Port;
}
#ifdef HAVE_THREADSAFE_GETADDRINFO
struct addrinfo hints, *res, *res0;
char portCString[7];
memset(&hints, 0, sizeof(struct addrinfo));
hints.ai_family = AF_UNSPEC;
hints.ai_socktype = SOCK_STREAM;
snprintf(portCString, 7, "%" PRIu16, port);
if (getaddrinfo([host cStringWithEncoding: OF_STRING_ENCODING_NATIVE],
portCString, &hints, &res0))
@throw [OFAddressTranslationFailedException
exceptionWithClass: [self class]
socket: self
host: host];
for (res = res0; res != NULL; res = res->ai_next) {
if ((sock = socket(res->ai_family, res->ai_socktype,
res->ai_protocol)) == INVALID_SOCKET)
continue;
|
︙ | | | ︙ | |
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
|
if ((he = gethostbyname([host cStringWithEncoding:
OF_STRING_ENCODING_NATIVE])) == NULL) {
# ifdef OF_THREADS
[addrlist release];
[mutex unlock];
# endif
@throw [OFAddressTranslationFailedException
exceptionWithClass: isa
socket: self
host: host];
}
memset(&addr, 0, sizeof(addr));
addr.sin_family = AF_INET;
addr.sin_port = of_bswap16_if_le(port);
if (he->h_addrtype != AF_INET ||
(sock = socket(AF_INET, SOCK_STREAM, 0)) == INVALID_SOCKET) {
# ifdef OF_THREADS
[addrlist release];
[mutex unlock];
# endif
@throw [OFConnectionFailedException exceptionWithClass: isa
socket: self
host: host
port: port];
}
# ifdef OF_THREADS
@try {
|
|
|
>
|
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
|
if ((he = gethostbyname([host cStringWithEncoding:
OF_STRING_ENCODING_NATIVE])) == NULL) {
# ifdef OF_THREADS
[addrlist release];
[mutex unlock];
# endif
@throw [OFAddressTranslationFailedException
exceptionWithClass: [self class]
socket: self
host: host];
}
memset(&addr, 0, sizeof(addr));
addr.sin_family = AF_INET;
addr.sin_port = of_bswap16_if_le(port);
if (he->h_addrtype != AF_INET ||
(sock = socket(AF_INET, SOCK_STREAM, 0)) == INVALID_SOCKET) {
# ifdef OF_THREADS
[addrlist release];
[mutex unlock];
# endif
@throw [OFConnectionFailedException
exceptionWithClass: [self class]
socket: self
host: host
port: port];
}
# ifdef OF_THREADS
@try {
|
︙ | | | ︙ | |
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
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
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
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
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
522
523
|
if (!connected) {
close(sock);
sock = INVALID_SOCKET;
}
#endif
if (sock == INVALID_SOCKET)
@throw [OFConnectionFailedException exceptionWithClass: isa
socket: self
host: host
port: port];
if (SOCKS5Host != nil)
[self _SOCKS5ConnectToHost: destinationHost
port: destinationPort];
}
- (uint16_t)bindToHost: (OFString*)host
port: (uint16_t)port
{
union {
struct sockaddr_storage storage;
struct sockaddr_in in;
struct sockaddr_in6 in6;
} addr;
socklen_t addrLen;
if (sock != INVALID_SOCKET)
@throw [OFAlreadyConnectedException exceptionWithClass: isa
socket: self];
if (SOCKS5Host != nil)
@throw [OFNotImplementedException exceptionWithClass: isa
selector: _cmd];
#ifdef HAVE_THREADSAFE_GETADDRINFO
struct addrinfo hints, *res;
char portCString[7];
memset(&hints, 0, sizeof(struct addrinfo));
hints.ai_family = AF_UNSPEC;
hints.ai_socktype = SOCK_STREAM;
snprintf(portCString, 7, "%" PRIu16, port);
if (getaddrinfo([host cStringWithEncoding: OF_STRING_ENCODING_NATIVE],
portCString, &hints, &res))
@throw [OFAddressTranslationFailedException
exceptionWithClass: isa
socket: self
host: host];
if ((sock = socket(res->ai_family, SOCK_STREAM, 0)) == INVALID_SOCKET)
@throw [OFBindFailedException exceptionWithClass: isa
socket: self
host: host
port: port];
if (bind(sock, res->ai_addr, res->ai_addrlen) == -1) {
freeaddrinfo(res);
close(sock);
sock = INVALID_SOCKET;
@throw [OFBindFailedException exceptionWithClass: isa
socket: self
host: host
port: port];
}
freeaddrinfo(res);
#else
struct hostent *he;
# ifdef OF_THREADS
[mutex lock];
# endif
if ((he = gethostbyname([host cStringWithEncoding:
OF_STRING_ENCODING_NATIVE])) == NULL) {
# ifdef OF_THREADS
[mutex unlock];
# endif
@throw [OFAddressTranslationFailedException
exceptionWithClass: isa
socket: self
host: host];
}
memset(&addr, 0, sizeof(addr));
addr.in.sin_family = AF_INET;
addr.in.sin_port = of_bswap16_if_le(port);
if (he->h_addrtype != AF_INET || he->h_addr_list[0] == NULL) {
# ifdef OF_THREADS
[mutex unlock];
# endif
@throw [OFAddressTranslationFailedException
exceptionWithClass: isa
socket: self
host: host];
}
memcpy(&addr.in.sin_addr.s_addr, he->h_addr_list[0], he->h_length);
# ifdef OF_THREADS
[mutex unlock];
# endif
if ((sock = socket(AF_INET, SOCK_STREAM, 0)) == INVALID_SOCKET)
@throw [OFBindFailedException exceptionWithClass: isa
socket: self
host: host
port: port];
if (bind(sock, (struct sockaddr*)&addr.in, sizeof(addr.in)) == -1) {
close(sock);
sock = INVALID_SOCKET;
@throw [OFBindFailedException exceptionWithClass: isa
socket: self
host: host
port: port];
}
#endif
if (port > 0)
return port;
addrLen = sizeof(addr.storage);
if (getsockname(sock, (struct sockaddr*)&addr, &addrLen)) {
close(sock);
sock = INVALID_SOCKET;
@throw [OFBindFailedException exceptionWithClass: isa
socket: self
host: host
port: port];
}
if (addr.storage.ss_family == AF_INET)
return of_bswap16_if_le(addr.in.sin_port);
if (addr.storage.ss_family == AF_INET6)
return of_bswap16_if_le(addr.in6.sin6_port);
close(sock);
sock = INVALID_SOCKET;
@throw [OFBindFailedException exceptionWithClass: isa
socket: self
host: host
port: port];
}
- (void)listenWithBackLog: (int)backLog
{
if (sock == INVALID_SOCKET)
@throw [OFNotConnectedException exceptionWithClass: isa
socket: self];
if (listen(sock, backLog) == -1)
@throw [OFListenFailedException exceptionWithClass: isa
socket: self
backLog: backLog];
listening = YES;
}
- (void)listen
{
if (sock == INVALID_SOCKET)
@throw [OFNotConnectedException exceptionWithClass: isa
socket: self];
if (listen(sock, 5) == -1)
@throw [OFListenFailedException exceptionWithClass: isa
socket: self
backLog: 5];
listening = YES;
}
- (OFTCPSocket*)accept
{
OFTCPSocket *newSocket;
struct sockaddr_storage *addr;
socklen_t addrLen;
int newSock;
newSocket = [[[isa alloc] init] autorelease];
addrLen = sizeof(struct sockaddr);
@try {
addr = [newSocket allocMemoryWithSize: sizeof(struct sockaddr)];
} @catch (id e) {
[newSocket release];
@throw e;
}
if ((newSock = accept(sock, (struct sockaddr*)addr,
&addrLen)) == INVALID_SOCKET) {
[newSocket release];
@throw [OFAcceptFailedException exceptionWithClass: isa
socket: self];
}
newSocket->sock = newSock;
newSocket->sockAddr = addr;
newSocket->sockAddrLen = addrLen;
return newSocket;
}
- (void)setKeepAlivesEnabled: (BOOL)enable
{
int v = enable;
if (setsockopt(sock, SOL_SOCKET, SO_KEEPALIVE, (char*)&v, sizeof(v)))
@throw [OFSetOptionFailedException exceptionWithClass: isa
stream: self];
}
- (OFString*)remoteAddress
{
char *host;
if (sockAddr == NULL || sockAddrLen == 0)
@throw [OFInvalidArgumentException exceptionWithClass: isa
selector: _cmd];
#ifdef HAVE_THREADSAFE_GETADDRINFO
host = [self allocMemoryWithSize: NI_MAXHOST];
@try {
if (getnameinfo((struct sockaddr*)sockAddr, sockAddrLen, host,
NI_MAXHOST, NULL, 0, NI_NUMERICHOST))
@throw [OFAddressTranslationFailedException
exceptionWithClass: isa];
return [OFString stringWithCString: host
encoding: OF_STRING_ENCODING_NATIVE];
} @finally {
[self freeMemory: host];
}
#else
# ifdef OF_THREADS
[mutex lock];
@try {
# endif
host = inet_ntoa(((struct sockaddr_in*)sockAddr)->sin_addr);
if (host == NULL)
@throw [OFAddressTranslationFailedException
exceptionWithClass: isa];
return [OFString stringWithCString: host
encoding: OF_STRING_ENCODING_NATIVE];
# ifdef OF_THREADS
} @finally {
[mutex unlock];
}
|
|
>
|
>
|
>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
>
|
>
|
|
|
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
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
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
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
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
522
523
524
525
526
527
528
529
530
|
if (!connected) {
close(sock);
sock = INVALID_SOCKET;
}
#endif
if (sock == INVALID_SOCKET)
@throw [OFConnectionFailedException
exceptionWithClass: [self class]
socket: self
host: host
port: port];
if (SOCKS5Host != nil)
[self _SOCKS5ConnectToHost: destinationHost
port: destinationPort];
}
- (uint16_t)bindToHost: (OFString*)host
port: (uint16_t)port
{
union {
struct sockaddr_storage storage;
struct sockaddr_in in;
struct sockaddr_in6 in6;
} addr;
socklen_t addrLen;
if (sock != INVALID_SOCKET)
@throw [OFAlreadyConnectedException
exceptionWithClass: [self class]
socket: self];
if (SOCKS5Host != nil)
@throw [OFNotImplementedException
exceptionWithClass: [self class]
selector: _cmd];
#ifdef HAVE_THREADSAFE_GETADDRINFO
struct addrinfo hints, *res;
char portCString[7];
memset(&hints, 0, sizeof(struct addrinfo));
hints.ai_family = AF_UNSPEC;
hints.ai_socktype = SOCK_STREAM;
snprintf(portCString, 7, "%" PRIu16, port);
if (getaddrinfo([host cStringWithEncoding: OF_STRING_ENCODING_NATIVE],
portCString, &hints, &res))
@throw [OFAddressTranslationFailedException
exceptionWithClass: [self class]
socket: self
host: host];
if ((sock = socket(res->ai_family, SOCK_STREAM, 0)) == INVALID_SOCKET)
@throw [OFBindFailedException exceptionWithClass: [self class]
socket: self
host: host
port: port];
if (bind(sock, res->ai_addr, res->ai_addrlen) == -1) {
freeaddrinfo(res);
close(sock);
sock = INVALID_SOCKET;
@throw [OFBindFailedException exceptionWithClass: [self class]
socket: self
host: host
port: port];
}
freeaddrinfo(res);
#else
struct hostent *he;
# ifdef OF_THREADS
[mutex lock];
# endif
if ((he = gethostbyname([host cStringWithEncoding:
OF_STRING_ENCODING_NATIVE])) == NULL) {
# ifdef OF_THREADS
[mutex unlock];
# endif
@throw [OFAddressTranslationFailedException
exceptionWithClass: [self class]
socket: self
host: host];
}
memset(&addr, 0, sizeof(addr));
addr.in.sin_family = AF_INET;
addr.in.sin_port = of_bswap16_if_le(port);
if (he->h_addrtype != AF_INET || he->h_addr_list[0] == NULL) {
# ifdef OF_THREADS
[mutex unlock];
# endif
@throw [OFAddressTranslationFailedException
exceptionWithClass: [self class]
socket: self
host: host];
}
memcpy(&addr.in.sin_addr.s_addr, he->h_addr_list[0], he->h_length);
# ifdef OF_THREADS
[mutex unlock];
# endif
if ((sock = socket(AF_INET, SOCK_STREAM, 0)) == INVALID_SOCKET)
@throw [OFBindFailedException exceptionWithClass: [self class]
socket: self
host: host
port: port];
if (bind(sock, (struct sockaddr*)&addr.in, sizeof(addr.in)) == -1) {
close(sock);
sock = INVALID_SOCKET;
@throw [OFBindFailedException exceptionWithClass: [self class]
socket: self
host: host
port: port];
}
#endif
if (port > 0)
return port;
addrLen = sizeof(addr.storage);
if (getsockname(sock, (struct sockaddr*)&addr, &addrLen)) {
close(sock);
sock = INVALID_SOCKET;
@throw [OFBindFailedException exceptionWithClass: [self class]
socket: self
host: host
port: port];
}
if (addr.storage.ss_family == AF_INET)
return of_bswap16_if_le(addr.in.sin_port);
if (addr.storage.ss_family == AF_INET6)
return of_bswap16_if_le(addr.in6.sin6_port);
close(sock);
sock = INVALID_SOCKET;
@throw [OFBindFailedException exceptionWithClass: [self class]
socket: self
host: host
port: port];
}
- (void)listenWithBackLog: (int)backLog
{
if (sock == INVALID_SOCKET)
@throw [OFNotConnectedException exceptionWithClass: [self class]
socket: self];
if (listen(sock, backLog) == -1)
@throw [OFListenFailedException exceptionWithClass: [self class]
socket: self
backLog: backLog];
listening = YES;
}
- (void)listen
{
if (sock == INVALID_SOCKET)
@throw [OFNotConnectedException exceptionWithClass: [self class]
socket: self];
if (listen(sock, 5) == -1)
@throw [OFListenFailedException exceptionWithClass: [self class]
socket: self
backLog: 5];
listening = YES;
}
- (OFTCPSocket*)accept
{
OFTCPSocket *newSocket;
struct sockaddr_storage *addr;
socklen_t addrLen;
int newSock;
newSocket = [[[[self class] alloc] init] autorelease];
addrLen = sizeof(struct sockaddr);
@try {
addr = [newSocket allocMemoryWithSize: sizeof(struct sockaddr)];
} @catch (id e) {
[newSocket release];
@throw e;
}
if ((newSock = accept(sock, (struct sockaddr*)addr,
&addrLen)) == INVALID_SOCKET) {
[newSocket release];
@throw [OFAcceptFailedException exceptionWithClass: [self class]
socket: self];
}
newSocket->sock = newSock;
newSocket->sockAddr = addr;
newSocket->sockAddrLen = addrLen;
return newSocket;
}
- (void)setKeepAlivesEnabled: (BOOL)enable
{
int v = enable;
if (setsockopt(sock, SOL_SOCKET, SO_KEEPALIVE, (char*)&v, sizeof(v)))
@throw [OFSetOptionFailedException
exceptionWithClass: [self class]
stream: self];
}
- (OFString*)remoteAddress
{
char *host;
if (sockAddr == NULL || sockAddrLen == 0)
@throw [OFInvalidArgumentException
exceptionWithClass: [self class]
selector: _cmd];
#ifdef HAVE_THREADSAFE_GETADDRINFO
host = [self allocMemoryWithSize: NI_MAXHOST];
@try {
if (getnameinfo((struct sockaddr*)sockAddr, sockAddrLen, host,
NI_MAXHOST, NULL, 0, NI_NUMERICHOST))
@throw [OFAddressTranslationFailedException
exceptionWithClass: [self class]];
return [OFString stringWithCString: host
encoding: OF_STRING_ENCODING_NATIVE];
} @finally {
[self freeMemory: host];
}
#else
# ifdef OF_THREADS
[mutex lock];
@try {
# endif
host = inet_ntoa(((struct sockaddr_in*)sockAddr)->sin_addr);
if (host == NULL)
@throw [OFAddressTranslationFailedException
exceptionWithClass: [self class]];
return [OFString stringWithCString: host
encoding: OF_STRING_ENCODING_NATIVE];
# ifdef OF_THREADS
} @finally {
[mutex unlock];
}
|
︙ | | | ︙ | |
Modified src/OFThread.m
from [15c3b7304d]
to [01ca359fa0].
︙ | | | ︙ | |
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
|
return self;
}
#endif
- (id)main
{
@throw [OFNotImplementedException exceptionWithClass: isa
selector: _cmd];
return nil;
}
- (void)handleTermination
{
}
- (void)start
{
if (running == OF_THREAD_RUNNING)
@throw [OFThreadStillRunningException exceptionWithClass: isa
thread: self];
if (running == OF_THREAD_WAITING_FOR_JOIN) {
of_thread_detach(thread);
[returnValue release];
}
[self retain];
if (!of_thread_new(&thread, call_main, self)) {
[self release];
@throw [OFThreadStartFailedException exceptionWithClass: isa
thread: self];
}
running = OF_THREAD_RUNNING;
}
- (id)join
{
if (running == OF_THREAD_NOT_RUNNING || !of_thread_join(thread))
@throw [OFThreadJoinFailedException exceptionWithClass: isa
thread: self];
running = OF_THREAD_NOT_RUNNING;
return returnValue;
}
- (void)dealloc
{
if (running == OF_THREAD_RUNNING)
@throw [OFThreadStillRunningException exceptionWithClass: isa
thread: self];
/*
* We should not be running anymore, but call detach in order to free
* the resources.
*/
if (running == OF_THREAD_WAITING_FOR_JOIN)
|
|
|
>
|
>
|
>
|
>
|
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
|
return self;
}
#endif
- (id)main
{
@throw [OFNotImplementedException exceptionWithClass: [self class]
selector: _cmd];
return nil;
}
- (void)handleTermination
{
}
- (void)start
{
if (running == OF_THREAD_RUNNING)
@throw [OFThreadStillRunningException
exceptionWithClass: [self class]
thread: self];
if (running == OF_THREAD_WAITING_FOR_JOIN) {
of_thread_detach(thread);
[returnValue release];
}
[self retain];
if (!of_thread_new(&thread, call_main, self)) {
[self release];
@throw [OFThreadStartFailedException
exceptionWithClass: [self class]
thread: self];
}
running = OF_THREAD_RUNNING;
}
- (id)join
{
if (running == OF_THREAD_NOT_RUNNING || !of_thread_join(thread))
@throw [OFThreadJoinFailedException
exceptionWithClass: [self class]
thread: self];
running = OF_THREAD_NOT_RUNNING;
return returnValue;
}
- (void)dealloc
{
if (running == OF_THREAD_RUNNING)
@throw [OFThreadStillRunningException
exceptionWithClass: [self class]
thread: self];
/*
* We should not be running anymore, but call detach in order to free
* the resources.
*/
if (running == OF_THREAD_WAITING_FOR_JOIN)
|
︙ | | | ︙ | |
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
|
- init
{
self = [super init];
@try {
if (!of_tlskey_new(&key))
@throw [OFInitializationFailedException
exceptionWithClass: isa];
initialized = YES;
@synchronized (TLSKeys) {
listObject = [TLSKeys appendObject: self];
}
} @catch (id e) {
|
|
|
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
|
- init
{
self = [super init];
@try {
if (!of_tlskey_new(&key))
@throw [OFInitializationFailedException
exceptionWithClass: [self class]];
initialized = YES;
@synchronized (TLSKeys) {
listObject = [TLSKeys appendObject: self];
}
} @catch (id e) {
|
︙ | | | ︙ | |
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
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
495
496
497
498
499
500
501
502
503
|
}
- init
{
self = [super init];
if (!of_mutex_new(&mutex)) {
Class c = isa;
[self release];
@throw [OFInitializationFailedException exceptionWithClass: c];
}
initialized = YES;
return self;
}
- (void)lock
{
if (!of_mutex_lock(&mutex))
@throw [OFMutexLockFailedException exceptionWithClass: isa
mutex: self];
}
- (BOOL)tryLock
{
return of_mutex_trylock(&mutex);
}
- (void)unlock
{
if (!of_mutex_unlock(&mutex))
@throw [OFMutexUnlockFailedException exceptionWithClass: isa
mutex: self];
}
- (void)dealloc
{
if (initialized)
if (!of_mutex_free(&mutex))
@throw [OFMutexStillLockedException
exceptionWithClass: isa
mutex: self];
[super dealloc];
}
@end
@implementation OFCondition
+ condition
{
return [[[self alloc] init] autorelease];
}
- init
{
self = [super init];
if (!of_condition_new(&condition)) {
Class c = isa;
[self release];
@throw [OFInitializationFailedException exceptionWithClass: c];
}
conditionInitialized = YES;
return self;
}
- (void)wait
{
if (!of_condition_wait(&condition, &mutex))
@throw [OFConditionWaitFailedException
exceptionWithClass: isa
condition: self];
}
- (void)signal
{
if (!of_condition_signal(&condition))
@throw [OFConditionSignalFailedException
exceptionWithClass: isa
condition: self];
}
- (void)broadcast
{
if (!of_condition_broadcast(&condition))
@throw [OFConditionBroadcastFailedException
exceptionWithClass: isa
condition: self];
}
- (void)dealloc
{
if (conditionInitialized)
if (!of_condition_free(&condition))
@throw [OFConditionStillWaitingException
exceptionWithClass: isa
condition: self];
[super dealloc];
}
@end
|
|
|
>
|
>
|
|
|
|
|
|
|
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
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
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
|
}
- init
{
self = [super init];
if (!of_mutex_new(&mutex)) {
Class c = [self class];
[self release];
@throw [OFInitializationFailedException exceptionWithClass: c];
}
initialized = YES;
return self;
}
- (void)lock
{
if (!of_mutex_lock(&mutex))
@throw [OFMutexLockFailedException
exceptionWithClass: [self class]
mutex: self];
}
- (BOOL)tryLock
{
return of_mutex_trylock(&mutex);
}
- (void)unlock
{
if (!of_mutex_unlock(&mutex))
@throw [OFMutexUnlockFailedException
exceptionWithClass: [self class]
mutex: self];
}
- (void)dealloc
{
if (initialized)
if (!of_mutex_free(&mutex))
@throw [OFMutexStillLockedException
exceptionWithClass: [self class]
mutex: self];
[super dealloc];
}
@end
@implementation OFCondition
+ condition
{
return [[[self alloc] init] autorelease];
}
- init
{
self = [super init];
if (!of_condition_new(&condition)) {
Class c = [self class];
[self release];
@throw [OFInitializationFailedException exceptionWithClass: c];
}
conditionInitialized = YES;
return self;
}
- (void)wait
{
if (!of_condition_wait(&condition, &mutex))
@throw [OFConditionWaitFailedException
exceptionWithClass: [self class]
condition: self];
}
- (void)signal
{
if (!of_condition_signal(&condition))
@throw [OFConditionSignalFailedException
exceptionWithClass: [self class]
condition: self];
}
- (void)broadcast
{
if (!of_condition_broadcast(&condition))
@throw [OFConditionBroadcastFailedException
exceptionWithClass: [self class]
condition: self];
}
- (void)dealloc
{
if (conditionInitialized)
if (!of_condition_free(&condition))
@throw [OFConditionStillWaitingException
exceptionWithClass: [self class]
condition: self];
[super dealloc];
}
@end
|
Modified src/OFURL.m
from [6ecf671f02]
to [9e27844090].
︙ | | | ︙ | |
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
|
self = [super init];
@try {
char *tmp, *tmp2;
if ((UTF8String2 = strdup([string UTF8String])) == NULL)
@throw [OFOutOfMemoryException
exceptionWithClass: isa
requestedSize: [string UTF8StringLength]];
UTF8String = UTF8String2;
if (!strncmp(UTF8String, "file://", 7)) {
scheme = @"file";
path = [[OFString alloc]
initWithUTF8String: UTF8String + 7];
return self;
} else if (!strncmp(UTF8String, "http://", 7)) {
scheme = @"http";
UTF8String += 7;
} else if (!strncmp(UTF8String, "https://", 8)) {
scheme = @"https";
UTF8String += 8;
} else
@throw [OFInvalidFormatException
exceptionWithClass: isa];
if ((tmp = strchr(UTF8String, '/')) != NULL) {
*tmp = '\0';
tmp++;
}
if ((tmp2 = strchr(UTF8String, '@')) != NULL) {
|
|
|
|
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
|
self = [super init];
@try {
char *tmp, *tmp2;
if ((UTF8String2 = strdup([string UTF8String])) == NULL)
@throw [OFOutOfMemoryException
exceptionWithClass: [self class]
requestedSize: [string UTF8StringLength]];
UTF8String = UTF8String2;
if (!strncmp(UTF8String, "file://", 7)) {
scheme = @"file";
path = [[OFString alloc]
initWithUTF8String: UTF8String + 7];
return self;
} else if (!strncmp(UTF8String, "http://", 7)) {
scheme = @"http";
UTF8String += 7;
} else if (!strncmp(UTF8String, "https://", 8)) {
scheme = @"https";
UTF8String += 8;
} else
@throw [OFInvalidFormatException
exceptionWithClass: [self class]];
if ((tmp = strchr(UTF8String, '/')) != NULL) {
*tmp = '\0';
tmp++;
}
if ((tmp2 = strchr(UTF8String, '@')) != NULL) {
|
︙ | | | ︙ | |
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
|
initWithUTF8String: UTF8String];
pool = [[OFAutoreleasePool alloc] init];
portString = [OFString stringWithUTF8String: tmp2];
if ([portString decimalValue] > 65535)
@throw [OFInvalidFormatException
exceptionWithClass: isa];
port = [portString decimalValue];
[pool release];
} else {
host = [[OFString alloc]
initWithUTF8String: UTF8String];
|
|
|
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
|
initWithUTF8String: UTF8String];
pool = [[OFAutoreleasePool alloc] init];
portString = [OFString stringWithUTF8String: tmp2];
if ([portString decimalValue] > 65535)
@throw [OFInvalidFormatException
exceptionWithClass: [self class]];
port = [portString decimalValue];
[pool release];
} else {
host = [[OFString alloc]
initWithUTF8String: UTF8String];
|
︙ | | | ︙ | |
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
|
host = [URL->host copy];
port = URL->port;
user = [URL->user copy];
password = [URL->password copy];
if ((UTF8String2 = strdup([string UTF8String])) == NULL)
@throw [OFOutOfMemoryException
exceptionWithClass: isa
requestedSize: [string UTF8StringLength]];
UTF8String = UTF8String2;
if ((tmp = strchr(UTF8String, '#')) != NULL) {
*tmp = '\0';
fragment = [[OFString alloc]
|
|
|
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
|
host = [URL->host copy];
port = URL->port;
user = [URL->user copy];
password = [URL->password copy];
if ((UTF8String2 = strdup([string UTF8String])) == NULL)
@throw [OFOutOfMemoryException
exceptionWithClass: [self class]
requestedSize: [string UTF8StringLength]];
UTF8String = UTF8String2;
if ((tmp = strchr(UTF8String, '#')) != NULL) {
*tmp = '\0';
fragment = [[OFString alloc]
|
︙ | | | ︙ | |
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
|
{
@try {
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
if (![[element name] isEqual: [self className]] ||
![[element namespace] isEqual: OF_SERIALIZATION_NS])
@throw [OFInvalidArgumentException
exceptionWithClass: isa
selector: _cmd];
self = [self initWithString: [element stringValue]];
[pool release];
} @catch (id e) {
[self release];
|
|
|
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
|
{
@try {
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
if (![[element name] isEqual: [self className]] ||
![[element namespace] isEqual: OF_SERIALIZATION_NS])
@throw [OFInvalidArgumentException
exceptionWithClass: [self class]
selector: _cmd];
self = [self initWithString: [element stringValue]];
[pool release];
} @catch (id e) {
[self release];
|
︙ | | | ︙ | |
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
|
OF_HASH_FINALIZE(hash);
return hash;
}
- copy
{
OFURL *copy = [[isa alloc] init];
@try {
copy->scheme = [scheme copy];
copy->host = [host copy];
copy->port = port;
copy->user = [user copy];
copy->password = [password copy];
|
|
|
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
|
OF_HASH_FINALIZE(hash);
return hash;
}
- copy
{
OFURL *copy = [[[self class] alloc] init];
@try {
copy->scheme = [scheme copy];
copy->host = [host copy];
copy->port = port;
copy->user = [user copy];
copy->password = [password copy];
|
︙ | | | ︙ | |
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
|
{
OF_GETTER(scheme, YES)
}
- (void)setScheme: (OFString*)scheme_
{
if (![scheme_ isEqual: @"http"] && ![scheme_ isEqual: @"https"])
@throw [OFInvalidArgumentException exceptionWithClass: isa
selector: _cmd];
OF_SETTER(scheme, scheme_, YES, 1)
}
- (OFString*)host
{
|
|
>
|
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
|
{
OF_GETTER(scheme, YES)
}
- (void)setScheme: (OFString*)scheme_
{
if (![scheme_ isEqual: @"http"] && ![scheme_ isEqual: @"https"])
@throw [OFInvalidArgumentException
exceptionWithClass: [self class]
selector: _cmd];
OF_SETTER(scheme, scheme_, YES, 1)
}
- (OFString*)host
{
|
︙ | | | ︙ | |
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
|
OF_GETTER(path, YES)
}
- (void)setPath: (OFString*)path_
{
if (([scheme isEqual: @"http"] || [scheme isEqual: @"https"]) &&
![path_ hasPrefix: @"/"])
@throw [OFInvalidArgumentException exceptionWithClass: isa
selector: _cmd];
OF_SETTER(path, path_, YES, 1)
}
- (OFString*)parameters
{
|
|
>
|
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
|
OF_GETTER(path, YES)
}
- (void)setPath: (OFString*)path_
{
if (([scheme isEqual: @"http"] || [scheme isEqual: @"https"]) &&
![path_ hasPrefix: @"/"])
@throw [OFInvalidArgumentException
exceptionWithClass: [self class]
selector: _cmd];
OF_SETTER(path, path_, YES, 1)
}
- (OFString*)parameters
{
|
︙ | | | ︙ | |
Modified src/OFXMLAttribute.m
from [506cef53d5]
to [9f7e711096].
︙ | | | ︙ | |
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
@try {
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
if (![[element name] isEqual: [self className]] ||
![[element namespace] isEqual: OF_SERIALIZATION_NS])
@throw [OFInvalidArgumentException
exceptionWithClass: isa
selector: _cmd];
name = [[[element attributeForName: @"name"] stringValue]
copy];
ns = [[[element attributeForName: @"namespace"] stringValue]
copy];
stringValue = [[[element attributeForName: @"stringValue"]
|
|
|
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
@try {
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
if (![[element name] isEqual: [self className]] ||
![[element namespace] isEqual: OF_SERIALIZATION_NS])
@throw [OFInvalidArgumentException
exceptionWithClass: [self class]
selector: _cmd];
name = [[[element attributeForName: @"name"] stringValue]
copy];
ns = [[[element attributeForName: @"namespace"] stringValue]
copy];
stringValue = [[[element attributeForName: @"stringValue"]
|
︙ | | | ︙ | |
Modified src/OFXMLCDATA.m
from [5d39af6dd0]
to [de756c000b].
︙ | | | ︙ | |
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
@try {
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
if (![[element name] isEqual: [self className]] ||
![[element namespace] isEqual: OF_SERIALIZATION_NS])
@throw [OFInvalidArgumentException
exceptionWithClass: isa
selector: _cmd];
CDATA = [[element stringValue] copy];
[pool release];
} @catch (id e) {
[self release];
|
|
|
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
@try {
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
if (![[element name] isEqual: [self className]] ||
![[element namespace] isEqual: OF_SERIALIZATION_NS])
@throw [OFInvalidArgumentException
exceptionWithClass: [self class]
selector: _cmd];
CDATA = [[element stringValue] copy];
[pool release];
} @catch (id e) {
[self release];
|
︙ | | | ︙ | |
Modified src/OFXMLCharacters.m
from [be73869b51]
to [992b1e5e2e].
︙ | | | ︙ | |
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
@try {
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
if (![[element name] isEqual: [self className]] ||
![[element namespace] isEqual: OF_SERIALIZATION_NS])
@throw [OFInvalidArgumentException
exceptionWithClass: isa
selector: _cmd];
characters = [[element stringValue] copy];
[pool release];
} @catch (id e) {
[self release];
|
|
|
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
@try {
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
if (![[element name] isEqual: [self className]] ||
![[element namespace] isEqual: OF_SERIALIZATION_NS])
@throw [OFInvalidArgumentException
exceptionWithClass: [self class]
selector: _cmd];
characters = [[element stringValue] copy];
[pool release];
} @catch (id e) {
[self release];
|
︙ | | | ︙ | |
Modified src/OFXMLComment.m
from [f495904fb6]
to [b127c0c456].
︙ | | | ︙ | |
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
@try {
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
if (![[element name] isEqual: [self className]] ||
![[element namespace] isEqual: OF_SERIALIZATION_NS])
@throw [OFInvalidArgumentException
exceptionWithClass: isa
selector: _cmd];
comment = [[element stringValue] copy];
[pool release];
} @catch (id e) {
[self release];
|
|
|
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
@try {
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
if (![[element name] isEqual: [self className]] ||
![[element namespace] isEqual: OF_SERIALIZATION_NS])
@throw [OFInvalidArgumentException
exceptionWithClass: [self class]
selector: _cmd];
comment = [[element stringValue] copy];
[pool release];
} @catch (id e) {
[self release];
|
︙ | | | ︙ | |
Modified src/OFXMLElement.m
from [dff10de86f]
to [103672a799].
︙ | | | ︙ | |
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
|
+ elementWithFile: (OFString*)path
{
return [[[self alloc] initWithFile: path] autorelease];
}
- init
{
Class c = isa;
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
- initWithName: (OFString*)name_
{
|
|
|
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
|
+ elementWithFile: (OFString*)path
{
return [[[self alloc] initWithFile: path] autorelease];
}
- init
{
Class c = [self class];
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
- initWithName: (OFString*)name_
{
|
︙ | | | ︙ | |
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
|
stringValue: (OFString*)stringValue
{
self = [super init];
@try {
if (name_ == nil)
@throw [OFInvalidArgumentException
exceptionWithClass: isa
selector: _cmd];
name = [name_ copy];
ns = [ns_ copy];
namespaces = [[OFMutableDictionary alloc]
initWithKeysAndObjects:
|
|
|
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
|
stringValue: (OFString*)stringValue
{
self = [super init];
@try {
if (name_ == nil)
@throw [OFInvalidArgumentException
exceptionWithClass: [self class]
selector: _cmd];
name = [name_ copy];
ns = [ns_ copy];
namespaces = [[OFMutableDictionary alloc]
initWithKeysAndObjects:
|
︙ | | | ︙ | |
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
|
- initWithElement: (OFXMLElement*)element
{
self = [super init];
@try {
if (element == nil)
@throw [OFInvalidArgumentException
exceptionWithClass: isa
selector: _cmd];
name = [element->name copy];
ns = [element->ns copy];
defaultNamespace = [element->defaultNamespace copy];
attributes = [element->attributes mutableCopy];
namespaces = [element->namespaces mutableCopy];
|
|
|
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
|
- initWithElement: (OFXMLElement*)element
{
self = [super init];
@try {
if (element == nil)
@throw [OFInvalidArgumentException
exceptionWithClass: [self class]
selector: _cmd];
name = [element->name copy];
ns = [element->ns copy];
defaultNamespace = [element->defaultNamespace copy];
attributes = [element->attributes mutableCopy];
namespaces = [element->namespaces mutableCopy];
|
︙ | | | ︙ | |
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
|
{
OFAutoreleasePool *pool;
OFXMLParser *parser;
OFXMLElementBuilder *builder;
OFXMLElement_OFXMLElementBuilderDelegate *delegate;
Class c;
c = isa;
[self release];
if (string == nil)
@throw [OFInvalidArgumentException exceptionWithClass: isa
selector: _cmd];
pool = [[OFAutoreleasePool alloc] init];
parser = [OFXMLParser parser];
builder = [OFXMLElementBuilder elementBuilder];
delegate = [[[OFXMLElement_OFXMLElementBuilderDelegate alloc] init]
|
|
|
|
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
|
{
OFAutoreleasePool *pool;
OFXMLParser *parser;
OFXMLElementBuilder *builder;
OFXMLElement_OFXMLElementBuilderDelegate *delegate;
Class c;
c = [self class];
[self release];
if (string == nil)
@throw [OFInvalidArgumentException exceptionWithClass: c
selector: _cmd];
pool = [[OFAutoreleasePool alloc] init];
parser = [OFXMLParser parser];
builder = [OFXMLElementBuilder elementBuilder];
delegate = [[[OFXMLElement_OFXMLElementBuilderDelegate alloc] init]
|
︙ | | | ︙ | |
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
|
{
OFAutoreleasePool *pool;
OFXMLParser *parser;
OFXMLElementBuilder *builder;
OFXMLElement_OFXMLElementBuilderDelegate *delegate;
Class c;
c = isa;
[self release];
pool = [[OFAutoreleasePool alloc] init];
parser = [OFXMLParser parser];
builder = [OFXMLElementBuilder elementBuilder];
delegate = [[[OFXMLElement_OFXMLElementBuilderDelegate alloc] init]
|
|
|
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
|
{
OFAutoreleasePool *pool;
OFXMLParser *parser;
OFXMLElementBuilder *builder;
OFXMLElement_OFXMLElementBuilderDelegate *delegate;
Class c;
c = [self class];
[self release];
pool = [[OFAutoreleasePool alloc] init];
parser = [OFXMLParser parser];
builder = [OFXMLElementBuilder elementBuilder];
delegate = [[[OFXMLElement_OFXMLElementBuilderDelegate alloc] init]
|
︙ | | | ︙ | |
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
|
OFXMLElement *childrenElement;
OFEnumerator *keyEnumerator, *objectEnumerator;
id key, object;
if (![[element name] isEqual: [self className]] ||
![[element namespace] isEqual: OF_SERIALIZATION_NS])
@throw [OFInvalidArgumentException
exceptionWithClass: isa
selector: _cmd];
name = [[[element attributeForName: @"name"] stringValue] copy];
ns = [[[element attributeForName: @"namespace"] stringValue]
copy];
defaultNamespace = [[[element attributeForName:
@"defaultNamespace"] stringValue] copy];
|
|
|
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
|
OFXMLElement *childrenElement;
OFEnumerator *keyEnumerator, *objectEnumerator;
id key, object;
if (![[element name] isEqual: [self className]] ||
![[element namespace] isEqual: OF_SERIALIZATION_NS])
@throw [OFInvalidArgumentException
exceptionWithClass: [self class]
selector: _cmd];
name = [[[element attributeForName: @"name"] stringValue] copy];
ns = [[[element attributeForName: @"namespace"] stringValue]
copy];
defaultNamespace = [[[element attributeForName:
@"defaultNamespace"] stringValue] copy];
|
︙ | | | ︙ | |
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
|
if ((attributes != nil &&
![attributes isKindOfClass: [OFMutableArray class]]) ||
(namespaces != nil &&
![namespaces isKindOfClass: [OFMutableDictionary class]]) ||
(children != nil &&
![children isKindOfClass: [OFMutableArray class]]))
@throw [OFInvalidArgumentException
exceptionWithClass: isa
selector: _cmd];
objectEnumerator = [attributes objectEnumerator];
while ((object = [objectEnumerator nextObject]) != nil)
if (![object isKindOfClass: [OFXMLAttribute class]])
@throw [OFInvalidArgumentException
exceptionWithClass: isa
selector: _cmd];
keyEnumerator = [namespaces keyEnumerator];
objectEnumerator = [namespaces objectEnumerator];
while ((key = [keyEnumerator nextObject]) != nil &&
(object = [objectEnumerator nextObject]) != nil)
if (![key isKindOfClass: [OFString class]] ||
![object isKindOfClass: [OFString class]])
@throw [OFInvalidArgumentException
exceptionWithClass: isa
selector: _cmd];
objectEnumerator = [children objectEnumerator];
while ((object = [objectEnumerator nextObject]) != nil)
if (![object isKindOfClass: [OFXMLNode class]])
@throw [OFInvalidArgumentException
exceptionWithClass: isa
selector: _cmd];
if (namespaces == nil)
namespaces = [[OFMutableDictionary alloc] init];
[namespaces setObject: @"xml"
forKey: @"http://www.w3.org/XML/1998/namespace"];
[namespaces setObject: @"xmlns"
forKey: @"http://www.w3.org/2000/xmlns/"];
if (name == nil)
@throw [OFInvalidArgumentException
exceptionWithClass: isa
selector: _cmd];
[pool release];
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
- (void)setName: (OFString*)name_
{
if (name_ == nil)
@throw [OFInvalidArgumentException exceptionWithClass: isa
selector: _cmd];
OF_SETTER(name, name_, YES, 1)
}
- (OFString*)name
{
|
|
|
|
|
|
|
>
|
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
394
|
if ((attributes != nil &&
![attributes isKindOfClass: [OFMutableArray class]]) ||
(namespaces != nil &&
![namespaces isKindOfClass: [OFMutableDictionary class]]) ||
(children != nil &&
![children isKindOfClass: [OFMutableArray class]]))
@throw [OFInvalidArgumentException
exceptionWithClass: [self class]
selector: _cmd];
objectEnumerator = [attributes objectEnumerator];
while ((object = [objectEnumerator nextObject]) != nil)
if (![object isKindOfClass: [OFXMLAttribute class]])
@throw [OFInvalidArgumentException
exceptionWithClass: [self class]
selector: _cmd];
keyEnumerator = [namespaces keyEnumerator];
objectEnumerator = [namespaces objectEnumerator];
while ((key = [keyEnumerator nextObject]) != nil &&
(object = [objectEnumerator nextObject]) != nil)
if (![key isKindOfClass: [OFString class]] ||
![object isKindOfClass: [OFString class]])
@throw [OFInvalidArgumentException
exceptionWithClass: [self class]
selector: _cmd];
objectEnumerator = [children objectEnumerator];
while ((object = [objectEnumerator nextObject]) != nil)
if (![object isKindOfClass: [OFXMLNode class]])
@throw [OFInvalidArgumentException
exceptionWithClass: [self class]
selector: _cmd];
if (namespaces == nil)
namespaces = [[OFMutableDictionary alloc] init];
[namespaces setObject: @"xml"
forKey: @"http://www.w3.org/XML/1998/namespace"];
[namespaces setObject: @"xmlns"
forKey: @"http://www.w3.org/2000/xmlns/"];
if (name == nil)
@throw [OFInvalidArgumentException
exceptionWithClass: [self class]
selector: _cmd];
[pool release];
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
- (void)setName: (OFString*)name_
{
if (name_ == nil)
@throw [OFInvalidArgumentException
exceptionWithClass: [self class]
selector: _cmd];
OF_SETTER(name, name_, YES, 1)
}
- (OFString*)name
{
|
︙ | | | ︙ | |
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
|
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;
|
|
|
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
|
OFString *tmp =
[[attributesObjects[j] stringValue] stringByXMLEscaping];
if ([attributesObjects[j] namespace] != nil &&
(attributePrefix = [allNamespaces objectForKey:
[attributesObjects[j] namespace]]) == nil)
@throw [OFUnboundNamespaceException
exceptionWithClass: [self class]
namespace: [attributesObjects[j]
namespace]];
length += [attributeName UTF8StringLength] +
(attributePrefix != nil ?
[attributePrefix UTF8StringLength] + 1 : 0) +
[tmp UTF8StringLength] + 4;
|
︙ | | | ︙ | |
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
|
}
}
- (void)setPrefix: (OFString*)prefix
forNamespace: (OFString*)ns_
{
if (prefix == nil || [prefix isEqual: @""])
@throw [OFInvalidArgumentException exceptionWithClass: isa
selector: _cmd];
if (ns_ == nil)
ns_ = @"";
[namespaces setObject: prefix
forKey: ns_];
}
|
|
>
|
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
|
}
}
- (void)setPrefix: (OFString*)prefix
forNamespace: (OFString*)ns_
{
if (prefix == nil || [prefix isEqual: @""])
@throw [OFInvalidArgumentException
exceptionWithClass: [self class]
selector: _cmd];
if (ns_ == nil)
ns_ = @"";
[namespaces setObject: prefix
forKey: ns_];
}
|
︙ | | | ︙ | |
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
|
{
OF_SETTER(defaultNamespace, ns_, YES, 1)
}
- (void)addChild: (OFXMLNode*)child
{
if ([child isKindOfClass: [OFXMLAttribute class]])
@throw [OFInvalidArgumentException exceptionWithClass: isa
selector: _cmd];
if (children == nil)
children = [[OFMutableArray alloc] init];
[children addObject: child];
}
- (void)removeChild: (OFXMLNode*)child
{
if ([child isKindOfClass: [OFXMLAttribute class]])
@throw [OFInvalidArgumentException exceptionWithClass: isa
selector: _cmd];
[children removeObject: child];
}
- (OFXMLElement*)elementForName: (OFString*)elementName
{
|
|
>
|
>
|
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
|
{
OF_SETTER(defaultNamespace, ns_, YES, 1)
}
- (void)addChild: (OFXMLNode*)child
{
if ([child isKindOfClass: [OFXMLAttribute class]])
@throw [OFInvalidArgumentException
exceptionWithClass: [self class]
selector: _cmd];
if (children == nil)
children = [[OFMutableArray alloc] init];
[children addObject: child];
}
- (void)removeChild: (OFXMLNode*)child
{
if ([child isKindOfClass: [OFXMLAttribute class]])
@throw [OFInvalidArgumentException
exceptionWithClass: [self class]
selector: _cmd];
[children removeObject: child];
}
- (OFXMLElement*)elementForName: (OFString*)elementName
{
|
︙ | | | ︙ | |
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
|
OF_HASH_FINALIZE(hash);
return hash;
}
- copy
{
return [[isa alloc] initWithElement: self];
}
- (void)dealloc
{
[name release];
[ns release];
[defaultNamespace release];
|
|
|
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
|
OF_HASH_FINALIZE(hash);
return hash;
}
- copy
{
return [[[self class] alloc] initWithElement: self];
}
- (void)dealloc
{
[name release];
[ns release];
[defaultNamespace release];
|
︙ | | | ︙ | |
Modified src/OFXMLNode.m
from [350476157f]
to [cb63feb9eb].
︙ | | | ︙ | |
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
#import "OFString.h"
#import "OFNotImplementedException.h"
@implementation OFXMLNode
- initWithSerialization: (OFXMLElement*)element
{
Class c = isa;
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
- (OFString*)stringValue
{
@throw [OFNotImplementedException exceptionWithClass: isa
selector: _cmd];
}
- (intmax_t)decimalValue
{
return [[self stringValue] decimalValue];
}
|
|
|
|
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
#import "OFString.h"
#import "OFNotImplementedException.h"
@implementation OFXMLNode
- initWithSerialization: (OFXMLElement*)element
{
Class c = [self class];
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
- (OFString*)stringValue
{
@throw [OFNotImplementedException exceptionWithClass: [self class]
selector: _cmd];
}
- (intmax_t)decimalValue
{
return [[self stringValue] decimalValue];
}
|
︙ | | | ︙ | |
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
|
return [self XMLStringWithIndentation: 0
level: 0];
}
- (OFString*)XMLStringWithIndentation: (unsigned int)indentation
level: (unsigned int)level
{
@throw [OFNotImplementedException exceptionWithClass: isa
selector: _cmd];
}
- (OFString*)description
{
return [self XMLStringWithIndentation: 2];
}
- (OFXMLElement*)XMLElementBySerializing
{
@throw [OFNotImplementedException exceptionWithClass: isa
selector: _cmd];
}
- copy
{
return [self retain];
}
@end
|
|
|
|
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
|
return [self XMLStringWithIndentation: 0
level: 0];
}
- (OFString*)XMLStringWithIndentation: (unsigned int)indentation
level: (unsigned int)level
{
@throw [OFNotImplementedException exceptionWithClass: [self class]
selector: _cmd];
}
- (OFString*)description
{
return [self XMLStringWithIndentation: 2];
}
- (OFXMLElement*)XMLElementBySerializing
{
@throw [OFNotImplementedException exceptionWithClass: [self class]
selector: _cmd];
}
- copy
{
return [self retain];
}
@end
|
Modified src/OFXMLParser.m
from [4119684e10]
to [c329ebfb71].
︙ | | | ︙ | |
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
|
}
return nil;
}
static OF_INLINE void
resolve_attribute_namespace(OFXMLAttribute *attribute, OFArray *namespaces,
Class isa)
{
OFString *attributeNS;
OFString *attributePrefix = attribute->ns;
if (attributePrefix == nil)
return;
attributeNS = namespace_for_prefix(attributePrefix, namespaces);
if ((attributePrefix != nil && attributeNS == nil))
@throw [OFUnboundNamespaceException
exceptionWithClass: isa
prefix: attributePrefix];
[attribute->ns release];
attribute->ns = [attributeNS retain];
}
@implementation OFXMLParser
|
|
|
|
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
|
}
return nil;
}
static OF_INLINE void
resolve_attribute_namespace(OFXMLAttribute *attribute, OFArray *namespaces,
OFXMLParser *self)
{
OFString *attributeNS;
OFString *attributePrefix = attribute->ns;
if (attributePrefix == nil)
return;
attributeNS = namespace_for_prefix(attributePrefix, namespaces);
if ((attributePrefix != nil && attributeNS == nil))
@throw [OFUnboundNamespaceException
exceptionWithClass: [self class]
prefix: attributePrefix];
[attribute->ns release];
attribute->ns = [attributeNS retain];
}
@implementation OFXMLParser
|
︙ | | | ︙ | |
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
|
last: (size_t*)last
{
size_t length;
if ((finishedParsing || [previous count] < 1) && buffer[*i] != ' ' &&
buffer[*i] != '\t' && buffer[*i] != '\n' && buffer[*i] != '\r' &&
buffer[*i] != '<')
@throw [OFMalformedXMLException exceptionWithClass: isa
parser: self];
if (buffer[*i] != '<')
return;
if ((length = *i - *last) > 0)
cache_append(cache, buffer + *last, encoding, length);
|
|
|
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
|
last: (size_t*)last
{
size_t length;
if ((finishedParsing || [previous count] < 1) && buffer[*i] != ' ' &&
buffer[*i] != '\t' && buffer[*i] != '\n' && buffer[*i] != '\r' &&
buffer[*i] != '<')
@throw [OFMalformedXMLException exceptionWithClass: [self class]
parser: self];
if (buffer[*i] != '<')
return;
if ((length = *i - *last) > 0)
cache_append(cache, buffer + *last, encoding, length);
|
︙ | | | ︙ | |
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
|
/* Tag was just opened */
- (void)_parseTagOpenedWithBuffer: (const char*)buffer
i: (size_t*)i
last: (size_t*)last
{
if (finishedParsing && buffer[*i] != '!' && buffer[*i] != '?')
@throw [OFMalformedXMLException exceptionWithClass: isa
parser: self];
switch (buffer[*i]) {
case '?':
*last = *i + 1;
state = OF_XMLPARSER_IN_PROCESSING_INSTRUCTIONS;
level = 0;
|
|
|
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
|
/* Tag was just opened */
- (void)_parseTagOpenedWithBuffer: (const char*)buffer
i: (size_t*)i
last: (size_t*)last
{
if (finishedParsing && buffer[*i] != '!' && buffer[*i] != '?')
@throw [OFMalformedXMLException exceptionWithClass: [self class]
parser: self];
switch (buffer[*i]) {
case '?':
*last = *i + 1;
state = OF_XMLPARSER_IN_PROCESSING_INSTRUCTIONS;
level = 0;
|
︙ | | | ︙ | |
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
|
pi = transform_string(cache, 1, NO, nil);
if ([pi isEqual: @"xml"] || [pi hasPrefix: @"xml "] ||
[pi hasPrefix: @"xml\t"] || [pi hasPrefix: @"xml\r"] ||
[pi hasPrefix: @"xml\n"])
if (![self _parseXMLProcessingInstructions: pi])
@throw [OFMalformedXMLException
exceptionWithClass: isa
parser: self];
[delegate parser: self
foundProcessingInstructions: pi];
[pool release];
|
|
|
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
|
pi = transform_string(cache, 1, NO, nil);
if ([pi isEqual: @"xml"] || [pi hasPrefix: @"xml "] ||
[pi hasPrefix: @"xml\t"] || [pi hasPrefix: @"xml\r"] ||
[pi hasPrefix: @"xml\n"])
if (![self _parseXMLProcessingInstructions: pi])
@throw [OFMalformedXMLException
exceptionWithClass: [self class]
parser: self];
[delegate parser: self
foundProcessingInstructions: pi];
[pool release];
|
︙ | | | ︙ | |
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
|
OFAutoreleasePool *pool2;
OFString *ns;
ns = namespace_for_prefix(prefix, namespaces);
if (prefix != nil && ns == nil)
@throw [OFUnboundNamespaceException
exceptionWithClass: isa
prefix: prefix];
pool2 = [[OFAutoreleasePool alloc] init];
[delegate parser: self
didStartElement: name
withPrefix: prefix
|
|
|
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
|
OFAutoreleasePool *pool2;
OFString *ns;
ns = namespace_for_prefix(prefix, namespaces);
if (prefix != nil && ns == nil)
@throw [OFUnboundNamespaceException
exceptionWithClass: [self class]
prefix: prefix];
pool2 = [[OFAutoreleasePool alloc] init];
[delegate parser: self
didStartElement: name
withPrefix: prefix
|
︙ | | | ︙ | |
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
|
length: tmp - cacheCString];
} else {
name = [cacheString copy];
prefix = nil;
}
if (![[previous lastObject] isEqual: cacheString])
@throw [OFMalformedXMLException exceptionWithClass: isa
parser: self];
[previous removeLastObject];
[cache removeAllItems];
ns = namespace_for_prefix(prefix, namespaces);
if (prefix != nil && ns == nil)
@throw [OFUnboundNamespaceException exceptionWithClass: isa
prefix: prefix];
[delegate parser: self
didEndElement: name
withPrefix: prefix
namespace: ns];
|
|
|
>
|
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
|
length: tmp - cacheCString];
} else {
name = [cacheString copy];
prefix = nil;
}
if (![[previous lastObject] isEqual: cacheString])
@throw [OFMalformedXMLException exceptionWithClass: [self class]
parser: self];
[previous removeLastObject];
[cache removeAllItems];
ns = namespace_for_prefix(prefix, namespaces);
if (prefix != nil && ns == nil)
@throw [OFUnboundNamespaceException
exceptionWithClass: [self class]
prefix: prefix];
[delegate parser: self
didEndElement: name
withPrefix: prefix
namespace: ns];
|
︙ | | | ︙ | |
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
|
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
namespace: ns
|
|
>
|
|
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
|
attributesObjects = [attributes objects];
attributesCount = [attributes count];
ns = namespace_for_prefix(prefix, namespaces);
if (prefix != nil && ns == nil)
@throw [OFUnboundNamespaceException
exceptionWithClass: [self class]
prefix: prefix];
for (j = 0; j < attributesCount; j++)
resolve_attribute_namespace(attributesObjects[j], namespaces,
self);
pool = [[OFAutoreleasePool alloc] init];
[delegate parser: self
didStartElement: name
withPrefix: prefix
namespace: ns
|
︙ | | | ︙ | |
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
|
*last = *i + 1;
if (buffer[*i] == ' ' || buffer[*i] == '\t' || buffer[*i] == '\n' ||
buffer[*i] == '\r')
return;
if (buffer[*i] != '\'' && buffer[*i] != '"')
@throw [OFMalformedXMLException exceptionWithClass: isa
parser: self];
delimiter = buffer[*i];
state = OF_XMLPARSER_IN_ATTR_VALUE;
}
/* Looking for attribute value */
|
|
|
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
|
*last = *i + 1;
if (buffer[*i] == ' ' || buffer[*i] == '\t' || buffer[*i] == '\n' ||
buffer[*i] == '\r')
return;
if (buffer[*i] != '\'' && buffer[*i] != '"')
@throw [OFMalformedXMLException exceptionWithClass: [self class]
parser: self];
delimiter = buffer[*i];
state = OF_XMLPARSER_IN_ATTR_VALUE;
}
/* Looking for attribute value */
|
︙ | | | ︙ | |
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
901
902
903
904
905
906
907
908
909
910
|
i: (size_t*)i
last: (size_t*)last
{
if (buffer[*i] == '>') {
*last = *i + 1;
state = OF_XMLPARSER_OUTSIDE_TAG;
} else
@throw [OFMalformedXMLException exceptionWithClass: isa
parser: self];
}
/* Expecting closing '>' or space */
- (void)_parseExpectSpaceOrCloseWithBuffer: (const char*)buffer
i: (size_t*)i
last: (size_t*)last
{
if (buffer[*i] == '>') {
*last = *i + 1;
state = OF_XMLPARSER_OUTSIDE_TAG;
} else if (buffer[*i] != ' ' && buffer[*i] != '\t' &&
buffer[*i] != '\n' && buffer[*i] != '\r')
@throw [OFMalformedXMLException exceptionWithClass: isa
parser: self];
}
/* In <! */
- (void)_parseInExclamationMarkWithBuffer: (const char*)buffer
i: (size_t*)i
last: (size_t*)last
{
if (finishedParsing && buffer[*i] != '-')
@throw [OFMalformedXMLException exceptionWithClass: isa
parser: self];
if (buffer[*i] == '-')
state = OF_XMLPARSER_IN_COMMENT_OPENING;
else if (buffer[*i] == '[') {
state = OF_XMLPARSER_IN_CDATA_OPENING;
level = 0;
} else if (buffer[*i] == 'D') {
state = OF_XMLPARSER_IN_DOCTYPE;
level = 0;
} else
@throw [OFMalformedXMLException exceptionWithClass: isa
parser: self];
*last = *i + 1;
}
/* CDATA */
- (void)_parseInCDATAOpeningWithBuffer: (const char*)buffer
i: (size_t*)i
last: (size_t*)last
{
if (buffer[*i] != "CDATA["[level])
@throw [OFMalformedXMLException exceptionWithClass: isa
parser: self];
if (++level == 6) {
state = OF_XMLPARSER_IN_CDATA_1;
level = 0;
}
|
|
|
|
|
|
|
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
901
902
903
904
905
906
907
908
909
910
911
912
|
i: (size_t*)i
last: (size_t*)last
{
if (buffer[*i] == '>') {
*last = *i + 1;
state = OF_XMLPARSER_OUTSIDE_TAG;
} else
@throw [OFMalformedXMLException exceptionWithClass: [self class]
parser: self];
}
/* Expecting closing '>' or space */
- (void)_parseExpectSpaceOrCloseWithBuffer: (const char*)buffer
i: (size_t*)i
last: (size_t*)last
{
if (buffer[*i] == '>') {
*last = *i + 1;
state = OF_XMLPARSER_OUTSIDE_TAG;
} else if (buffer[*i] != ' ' && buffer[*i] != '\t' &&
buffer[*i] != '\n' && buffer[*i] != '\r')
@throw [OFMalformedXMLException exceptionWithClass: [self class]
parser: self];
}
/* In <! */
- (void)_parseInExclamationMarkWithBuffer: (const char*)buffer
i: (size_t*)i
last: (size_t*)last
{
if (finishedParsing && buffer[*i] != '-')
@throw [OFMalformedXMLException exceptionWithClass: [self class]
parser: self];
if (buffer[*i] == '-')
state = OF_XMLPARSER_IN_COMMENT_OPENING;
else if (buffer[*i] == '[') {
state = OF_XMLPARSER_IN_CDATA_OPENING;
level = 0;
} else if (buffer[*i] == 'D') {
state = OF_XMLPARSER_IN_DOCTYPE;
level = 0;
} else
@throw [OFMalformedXMLException exceptionWithClass: [self class]
parser: self];
*last = *i + 1;
}
/* CDATA */
- (void)_parseInCDATAOpeningWithBuffer: (const char*)buffer
i: (size_t*)i
last: (size_t*)last
{
if (buffer[*i] != "CDATA["[level])
@throw [OFMalformedXMLException exceptionWithClass: [self class]
parser: self];
if (++level == 6) {
state = OF_XMLPARSER_IN_CDATA_1;
level = 0;
}
|
︙ | | | ︙ | |
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
|
/* Comment */
- (void)_parseInCommentOpeningWithBuffer: (const char*)buffer
i: (size_t*)i
last: (size_t*)last
{
if (buffer[*i] != '-')
@throw [OFMalformedXMLException exceptionWithClass: isa
parser: self];
*last = *i + 1;
state = OF_XMLPARSER_IN_COMMENT_1;
level = 0;
}
|
|
|
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
|
/* Comment */
- (void)_parseInCommentOpeningWithBuffer: (const char*)buffer
i: (size_t*)i
last: (size_t*)last
{
if (buffer[*i] != '-')
@throw [OFMalformedXMLException exceptionWithClass: [self class]
parser: self];
*last = *i + 1;
state = OF_XMLPARSER_IN_COMMENT_1;
level = 0;
}
|
︙ | | | ︙ | |
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
|
i: (size_t*)i
last: (size_t*)last
{
OFAutoreleasePool *pool;
OFString *comment;
if (buffer[*i] != '>')
@throw [OFMalformedXMLException exceptionWithClass: isa
parser: self];
pool = [[OFAutoreleasePool alloc] init];
cache_append(cache, buffer + *last, encoding, *i - *last);
comment = transform_string(cache, 2, NO, nil);
|
|
|
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
|
i: (size_t*)i
last: (size_t*)last
{
OFAutoreleasePool *pool;
OFString *comment;
if (buffer[*i] != '>')
@throw [OFMalformedXMLException exceptionWithClass: [self class]
parser: self];
pool = [[OFAutoreleasePool alloc] init];
cache_append(cache, buffer + *last, encoding, *i - *last);
comment = transform_string(cache, 2, NO, nil);
|
︙ | | | ︙ | |
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
|
- (void)_parseInDoctypeWithBuffer: (const char*)buffer
i: (size_t*)i
last: (size_t*)last
{
if ((level < 6 && buffer[*i] != "OCTYPE"[level]) ||
(level == 6 && buffer[*i] != ' ' && buffer[*i] != '\t' &&
buffer[*i] != '\n' && buffer[*i] != '\r'))
@throw [OFMalformedXMLException exceptionWithClass: isa
parser: self];
if (level < 7 || buffer[*i] == '<')
level++;
if (buffer[*i] == '>') {
if (level == 7)
|
|
|
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
|
- (void)_parseInDoctypeWithBuffer: (const char*)buffer
i: (size_t*)i
last: (size_t*)last
{
if ((level < 6 && buffer[*i] != "OCTYPE"[level]) ||
(level == 6 && buffer[*i] != ' ' && buffer[*i] != '\t' &&
buffer[*i] != '\n' && buffer[*i] != '\r'))
@throw [OFMalformedXMLException exceptionWithClass: [self class]
parser: self];
if (level < 7 || buffer[*i] == '<')
level++;
if (buffer[*i] == '>') {
if (level == 7)
|
︙ | | | ︙ | |
Modified src/OFXMLProcessingInstructions.m
from [8cbcee10cf]
to [a0218b0933].
︙ | | | ︙ | |
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
@try {
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
if (![[element name] isEqual: [self className]] ||
![[element namespace] isEqual: OF_SERIALIZATION_NS])
@throw [OFInvalidArgumentException
exceptionWithClass: isa
selector: _cmd];
processingInstructions = [[element stringValue] copy];
[pool release];
} @catch (id e) {
[self release];
|
|
|
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
@try {
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
if (![[element name] isEqual: [self className]] ||
![[element namespace] isEqual: OF_SERIALIZATION_NS])
@throw [OFInvalidArgumentException
exceptionWithClass: [self class]
selector: _cmd];
processingInstructions = [[element stringValue] copy];
[pool release];
} @catch (id e) {
[self release];
|
︙ | | | ︙ | |
Modified src/exceptions/OFAcceptFailedException.m
from [bb2f874396]
to [c0bc1a68c7].
︙ | | | ︙ | |
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
{
return [[[self alloc] initWithClass: class_
socket: socket] autorelease];
}
- initWithClass: (Class)class_
{
Class c = isa;
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
- initWithClass: (Class)class_
socket: (OFTCPSocket*)socket_
|
|
|
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
{
return [[[self alloc] initWithClass: class_
socket: socket] autorelease];
}
- initWithClass: (Class)class_
{
Class c = [self class];
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
- initWithClass: (Class)class_
socket: (OFTCPSocket*)socket_
|
︙ | | | ︙ | |
Modified src/exceptions/OFAllocFailedException.m
from [c7cd0a3c1f]
to [13d067f85c].
︙ | | | ︙ | |
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
|
{
@throw [OFNotImplementedException exceptionWithClass: self
selector: _cmd];
}
- init
{
@throw [OFNotImplementedException exceptionWithClass: isa
selector: _cmd];
}
- (void)addMemoryToPool: (void*)ptr
{
@throw [OFNotImplementedException exceptionWithClass: isa
selector: _cmd];
}
- (void*)allocMemoryWithSize: (size_t)size
{
@throw [OFNotImplementedException exceptionWithClass: isa
selector: _cmd];
}
- (void*)allocMemoryForNItems: (size_t)nitems
withSize: (size_t)size
{
@throw [OFNotImplementedException exceptionWithClass: isa
selector: _cmd];
}
- (void*)resizeMemory: (void*)ptr
toSize: (size_t)size
{
@throw [OFNotImplementedException exceptionWithClass: isa
selector: _cmd];
}
- (void*)resizeMemory: (void*)ptr
toNItems: (size_t)nitems
withSize: (size_t)size
{
@throw [OFNotImplementedException exceptionWithClass: isa
selector: _cmd];
}
- (void)freeMemory: (void*)ptr
{
@throw [OFNotImplementedException exceptionWithClass: isa
selector: _cmd];
}
- retain
{
return self;
}
|
|
|
|
|
|
|
|
|
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
|
{
@throw [OFNotImplementedException exceptionWithClass: self
selector: _cmd];
}
- init
{
@throw [OFNotImplementedException exceptionWithClass: [self class]
selector: _cmd];
}
- (void)addMemoryToPool: (void*)ptr
{
@throw [OFNotImplementedException exceptionWithClass: [self class]
selector: _cmd];
}
- (void*)allocMemoryWithSize: (size_t)size
{
@throw [OFNotImplementedException exceptionWithClass: [self class]
selector: _cmd];
}
- (void*)allocMemoryForNItems: (size_t)nitems
withSize: (size_t)size
{
@throw [OFNotImplementedException exceptionWithClass: [self class]
selector: _cmd];
}
- (void*)resizeMemory: (void*)ptr
toSize: (size_t)size
{
@throw [OFNotImplementedException exceptionWithClass: [self class]
selector: _cmd];
}
- (void*)resizeMemory: (void*)ptr
toNItems: (size_t)nitems
withSize: (size_t)size
{
@throw [OFNotImplementedException exceptionWithClass: [self class]
selector: _cmd];
}
- (void)freeMemory: (void*)ptr
{
@throw [OFNotImplementedException exceptionWithClass: [self class]
selector: _cmd];
}
- retain
{
return self;
}
|
︙ | | | ︙ | |
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
|
- (void)release
{
}
- (void)dealloc
{
@throw [OFNotImplementedException exceptionWithClass: isa
selector: _cmd];
[super dealloc]; /* Get rid of a stupid warning */
}
- (OFString*)description
{
return @"Allocating an object failed!";
}
@end
|
|
|
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
|
- (void)release
{
}
- (void)dealloc
{
@throw [OFNotImplementedException exceptionWithClass: [self class]
selector: _cmd];
[super dealloc]; /* Get rid of a stupid warning */
}
- (OFString*)description
{
return @"Allocating an object failed!";
}
@end
|
Modified src/exceptions/OFAlreadyConnectedException.m
from [0e242f765d]
to [7c9868ccaa].
︙ | | | ︙ | |
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
{
return [[[self alloc] initWithClass: class_
socket: socket] autorelease];
}
- initWithClass: (Class)class_
{
Class c = isa;
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
- initWithClass: (Class)class_
socket: (OFTCPSocket*)socket_
|
|
|
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
{
return [[[self alloc] initWithClass: class_
socket: socket] autorelease];
}
- initWithClass: (Class)class_
{
Class c = [self class];
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
- initWithClass: (Class)class_
socket: (OFTCPSocket*)socket_
|
︙ | | | ︙ | |
Modified src/exceptions/OFBindFailedException.m
from [df615de3a6]
to [d796c063e2].
︙ | | | ︙ | |
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
socket: socket
host: host
port: port] autorelease];
}
- initWithClass: (Class)class_
{
Class c = isa;
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
- initWithClass: (Class)class_
socket: (OFTCPSocket*)socket_
|
|
|
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
socket: socket
host: host
port: port] autorelease];
}
- initWithClass: (Class)class_
{
Class c = [self class];
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
- initWithClass: (Class)class_
socket: (OFTCPSocket*)socket_
|
︙ | | | ︙ | |
Modified src/exceptions/OFChangeDirectoryFailedException.m
from [b4df339463]
to [59a8888365].
︙ | | | ︙ | |
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
{
return [[[self alloc] initWithClass: class_
path: path_] autorelease];
}
- initWithClass: (Class)class_
{
Class c = isa;
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
- initWithClass: (Class)class_
path: (OFString*)path_
|
|
|
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
{
return [[[self alloc] initWithClass: class_
path: path_] autorelease];
}
- initWithClass: (Class)class_
{
Class c = [self class];
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
- initWithClass: (Class)class_
path: (OFString*)path_
|
︙ | | | ︙ | |
Modified src/exceptions/OFChangeFileModeFailedException.m
from [bd99ce9451]
to [2bb80dce5e].
︙ | | | ︙ | |
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
return [[[self alloc] initWithClass: class_
path: path
mode: mode] autorelease];
}
- initWithClass: (Class)class_
{
Class c = isa;
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
- initWithClass: (Class)class_
path: (OFString*)path_
|
|
|
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
return [[[self alloc] initWithClass: class_
path: path
mode: mode] autorelease];
}
- initWithClass: (Class)class_
{
Class c = [self class];
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
- initWithClass: (Class)class_
path: (OFString*)path_
|
︙ | | | ︙ | |
Modified src/exceptions/OFChangeFileOwnerFailedException.m
from [b902baaaa0]
to [69fce37d1b].
︙ | | | ︙ | |
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
path: path
owner: owner
group: group] autorelease];
}
- initWithClass: (Class)class_
{
Class c = isa;
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
- initWithClass: (Class)class_
path: (OFString*)path_
|
|
|
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
path: path
owner: owner
group: group] autorelease];
}
- initWithClass: (Class)class_
{
Class c = [self class];
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
- initWithClass: (Class)class_
path: (OFString*)path_
|
︙ | | | ︙ | |
Modified src/exceptions/OFConditionBroadcastFailedException.m
from [797f26e087]
to [9a6700f23c].
︙ | | | ︙ | |
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
{
return [[[self alloc] initWithClass: class_
condition: condition] autorelease];
}
- initWithClass: (Class)class_
{
Class c = isa;
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
- initWithClass: (Class)class_
condition: (OFCondition*)condition_
|
|
|
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
{
return [[[self alloc] initWithClass: class_
condition: condition] autorelease];
}
- initWithClass: (Class)class_
{
Class c = [self class];
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
- initWithClass: (Class)class_
condition: (OFCondition*)condition_
|
︙ | | | ︙ | |
Modified src/exceptions/OFConditionSignalFailedException.m
from [54e9a1d911]
to [81e4b38137].
︙ | | | ︙ | |
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
{
return [[[self alloc] initWithClass: class_
condition: condition] autorelease];
}
- initWithClass: (Class)class_
{
Class c = isa;
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
- initWithClass: (Class)class_
condition: (OFCondition*)condition_
|
|
|
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
{
return [[[self alloc] initWithClass: class_
condition: condition] autorelease];
}
- initWithClass: (Class)class_
{
Class c = [self class];
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
- initWithClass: (Class)class_
condition: (OFCondition*)condition_
|
︙ | | | ︙ | |
Modified src/exceptions/OFConditionStillWaitingException.m
from [a8603b4d6b]
to [05defc03ca].
︙ | | | ︙ | |
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
{
return [[[self alloc] initWithClass: class_
condition: condition] autorelease];
}
- initWithClass: (Class)class_
{
Class c = isa;
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
- initWithClass: (Class)class_
condition: (OFCondition*)condition_
|
|
|
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
{
return [[[self alloc] initWithClass: class_
condition: condition] autorelease];
}
- initWithClass: (Class)class_
{
Class c = [self class];
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
- initWithClass: (Class)class_
condition: (OFCondition*)condition_
|
︙ | | | ︙ | |
Modified src/exceptions/OFConditionWaitFailedException.m
from [0cd74eb5d3]
to [28d819a605].
︙ | | | ︙ | |
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
{
return [[[self alloc] initWithClass: class_
condition: condition] autorelease];
}
- initWithClass: (Class)class_
{
Class c = isa;
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
- initWithClass: (Class)class_
condition: (OFCondition*)condition_
|
|
|
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
{
return [[[self alloc] initWithClass: class_
condition: condition] autorelease];
}
- initWithClass: (Class)class_
{
Class c = [self class];
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
- initWithClass: (Class)class_
condition: (OFCondition*)condition_
|
︙ | | | ︙ | |
Modified src/exceptions/OFConnectionFailedException.m
from [134f8efbd2]
to [c9f175e2a4].
︙ | | | ︙ | |
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
socket: socket
host: host
port: port] autorelease];
}
- initWithClass: (Class)class_
{
Class c = isa;
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
- initWithClass: (Class)class_
socket: (OFTCPSocket*)socket_
|
|
|
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
socket: socket
host: host
port: port] autorelease];
}
- initWithClass: (Class)class_
{
Class c = [self class];
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
- initWithClass: (Class)class_
socket: (OFTCPSocket*)socket_
|
︙ | | | ︙ | |
Modified src/exceptions/OFCopyFileFailedException.m
from [ea25f448eb]
to [af3294e8fa].
︙ | | | ︙ | |
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
return [[[self alloc] initWithClass: class_
sourcePath: source
destinationPath: destination] autorelease];
}
- initWithClass: (Class)class_
{
Class c = isa;
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
- initWithClass: (Class)class_
sourcePath: (OFString*)source
|
|
|
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
return [[[self alloc] initWithClass: class_
sourcePath: source
destinationPath: destination] autorelease];
}
- initWithClass: (Class)class_
{
Class c = [self class];
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
- initWithClass: (Class)class_
sourcePath: (OFString*)source
|
︙ | | | ︙ | |
Modified src/exceptions/OFCreateDirectoryFailedException.m
from [0e2e2ecfc2]
to [c1a3e21ad9].
︙ | | | ︙ | |
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
{
return [[[self alloc] initWithClass: class_
path: path_] autorelease];
}
- initWithClass: (Class)class_
{
Class c = isa;
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
- initWithClass: (Class)class_
path: (OFString*)path_
|
|
|
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
{
return [[[self alloc] initWithClass: class_
path: path_] autorelease];
}
- initWithClass: (Class)class_
{
Class c = [self class];
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
- initWithClass: (Class)class_
path: (OFString*)path_
|
︙ | | | ︙ | |
Modified src/exceptions/OFDeleteDirectoryFailedException.m
from [5b30c82146]
to [51c696b033].
︙ | | | ︙ | |
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
{
return [[[self alloc] initWithClass: class_
path: path_] autorelease];
}
- initWithClass: (Class)class_
{
Class c = isa;
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
- initWithClass: (Class)class_
path: (OFString*)path_
|
|
|
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
{
return [[[self alloc] initWithClass: class_
path: path_] autorelease];
}
- initWithClass: (Class)class_
{
Class c = [self class];
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
- initWithClass: (Class)class_
path: (OFString*)path_
|
︙ | | | ︙ | |
Modified src/exceptions/OFDeleteFileFailedException.m
from [9e7f086966]
to [98159ee061].
︙ | | | ︙ | |
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
{
return [[[self alloc] initWithClass: class_
path: path_] autorelease];
}
- initWithClass: (Class)class_
{
Class c = isa;
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
- initWithClass: (Class)class_
path: (OFString*)path_
|
|
|
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
{
return [[[self alloc] initWithClass: class_
path: path_] autorelease];
}
- initWithClass: (Class)class_
{
Class c = [self class];
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
- initWithClass: (Class)class_
path: (OFString*)path_
|
︙ | | | ︙ | |
Modified src/exceptions/OFEnumerationMutationException.m
from [7cb1fb2cc9]
to [092080e143].
︙ | | | ︙ | |
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
{
return [[[self alloc] initWithClass: class_
object: object] autorelease];
}
- initWithClass: (Class)class_
{
Class c = isa;
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
- initWithClass: (Class)class_
object: (id)object_
|
|
|
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
{
return [[[self alloc] initWithClass: class_
object: object] autorelease];
}
- initWithClass: (Class)class_
{
Class c = [self class];
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
- initWithClass: (Class)class_
object: (id)object_
|
︙ | | | ︙ | |
Modified src/exceptions/OFException.m
from [13ae2563a0]
to [e04692d9ff].
︙ | | | ︙ | |
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
+ exceptionWithClass: (Class)class_
{
return [[[self alloc] initWithClass: class_] autorelease];
}
- init
{
Class c = isa;
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
- initWithClass: (Class)class_
{
|
|
|
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
+ exceptionWithClass: (Class)class_
{
return [[[self alloc] initWithClass: class_] autorelease];
}
- init
{
Class c = [self class];
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
- initWithClass: (Class)class_
{
|
︙ | | | ︙ | |
58
59
60
61
62
63
64
65
66
67
68
69
|
- (OFString*)description
{
if (description != nil)
return description;
description = [[OFString alloc] initWithFormat:
@"An exception of class %@ occurred in class %@", isa, inClass];
return description;
}
@end
|
|
>
|
58
59
60
61
62
63
64
65
66
67
68
69
70
|
- (OFString*)description
{
if (description != nil)
return description;
description = [[OFString alloc] initWithFormat:
@"An exception of class %@ occurred in class %@",
object_getClass(self), inClass];
return description;
}
@end
|
Modified src/exceptions/OFHTTPRequestFailedException.m
from [8558823ee2]
to [b853bc24af].
︙ | | | ︙ | |
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
return [[[self alloc] initWithClass: class_
HTTPRequest: request
result: result] autorelease];
}
- initWithClass: (Class)class_
{
Class c = isa;
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
- initWithClass: (Class)class_
HTTPRequest: (OFHTTPRequest*)request
|
|
|
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
return [[[self alloc] initWithClass: class_
HTTPRequest: request
result: result] autorelease];
}
- initWithClass: (Class)class_
{
Class c = [self class];
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
- initWithClass: (Class)class_
HTTPRequest: (OFHTTPRequest*)request
|
︙ | | | ︙ | |
Modified src/exceptions/OFHashAlreadyCalculatedException.m
from [a398dd3824]
to [ab8625fe9b].
︙ | | | ︙ | |
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
{
return [[[self alloc] initWithClass: class_
hash: hash] autorelease];
}
- initWithClass: (Class)class_
{
Class c = isa;
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
- initWithClass: (Class)class_
hash: (OFHash*)hash
|
|
|
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
{
return [[[self alloc] initWithClass: class_
hash: hash] autorelease];
}
- initWithClass: (Class)class_
{
Class c = [self class];
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
- initWithClass: (Class)class_
hash: (OFHash*)hash
|
︙ | | | ︙ | |
Modified src/exceptions/OFInvalidArgumentException.m
from [438e5eaf23]
to [a6a662ba80].
︙ | | | ︙ | |
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
{
return [[[self alloc] initWithClass: class_
selector: selector_] autorelease];
}
- initWithClass: (Class)class_
{
Class c = isa;
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
- initWithClass: (Class)class_
selector: (SEL)selector_
|
|
|
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
{
return [[[self alloc] initWithClass: class_
selector: selector_] autorelease];
}
- initWithClass: (Class)class_
{
Class c = [self class];
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
- initWithClass: (Class)class_
selector: (SEL)selector_
|
︙ | | | ︙ | |
Modified src/exceptions/OFInvalidJSONException.m
from [ca1d0c629a]
to [7120552858].
︙ | | | ︙ | |
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
{
return [[[self alloc] initWithClass: class_
line: line] autorelease];
}
- init
{
Class c = isa;
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
- initWithClass: (Class)class_
line: (size_t)line_
|
|
|
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
{
return [[[self alloc] initWithClass: class_
line: line] autorelease];
}
- init
{
Class c = [self class];
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
- initWithClass: (Class)class_
line: (size_t)line_
|
︙ | | | ︙ | |
Modified src/exceptions/OFLinkFailedException.m
from [9d20d8d748]
to [e4101540ee].
︙ | | | ︙ | |
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
return [[[self alloc] initWithClass: class_
sourcePath: source
destinationPath: destination] autorelease];
}
- initWithClass: (Class)class_
{
Class c = isa;
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
- initWithClass: (Class)class_
sourcePath: (OFString*)source
|
|
|
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
return [[[self alloc] initWithClass: class_
sourcePath: source
destinationPath: destination] autorelease];
}
- initWithClass: (Class)class_
{
Class c = [self class];
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
- initWithClass: (Class)class_
sourcePath: (OFString*)source
|
︙ | | | ︙ | |
Modified src/exceptions/OFListenFailedException.m
from [83cf442429]
to [eb6c563353].
︙ | | | ︙ | |
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
return [[[self alloc] initWithClass: class_
socket: socket
backLog: backlog] autorelease];
}
- initWithClass: (Class)class_
{
Class c = isa;
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
- initWithClass: (Class)class_
socket: (OFTCPSocket*)socket_
|
|
|
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
return [[[self alloc] initWithClass: class_
socket: socket
backLog: backlog] autorelease];
}
- initWithClass: (Class)class_
{
Class c = [self class];
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
- initWithClass: (Class)class_
socket: (OFTCPSocket*)socket_
|
︙ | | | ︙ | |
Modified src/exceptions/OFMemoryNotPartOfObjectException.m
from [98297d177e]
to [795b07ac4b].
︙ | | | ︙ | |
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
{
return [[[self alloc] initWithClass: class_
pointer: ptr] autorelease];
}
- initWithClass: (Class)class_
{
Class c = isa;
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
- initWithClass: (Class)class_
pointer: (void*)ptr
|
|
|
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
{
return [[[self alloc] initWithClass: class_
pointer: ptr] autorelease];
}
- initWithClass: (Class)class_
{
Class c = [self class];
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
- initWithClass: (Class)class_
pointer: (void*)ptr
|
︙ | | | ︙ | |
Modified src/exceptions/OFMutexLockFailedException.m
from [96099c5585]
to [0f471f5960].
︙ | | | ︙ | |
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
{
return [[[self alloc] initWithClass: class_
mutex: mutex] autorelease];
}
- initWithClass: (Class)class_
{
Class c = isa;
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
- initWithClass: (Class)class_
mutex: (OFMutex*)mutex_
|
|
|
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
{
return [[[self alloc] initWithClass: class_
mutex: mutex] autorelease];
}
- initWithClass: (Class)class_
{
Class c = [self class];
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
- initWithClass: (Class)class_
mutex: (OFMutex*)mutex_
|
︙ | | | ︙ | |
Modified src/exceptions/OFMutexStillLockedException.m
from [b9e292235b]
to [ff0c5d43a6].
︙ | | | ︙ | |
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
{
return [[[self alloc] initWithClass: class_
mutex: mutex] autorelease];
}
- initWithClass: (Class)class_
{
Class c = isa;
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
- initWithClass: (Class)class_
mutex: (OFMutex*)mutex_
|
|
|
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
{
return [[[self alloc] initWithClass: class_
mutex: mutex] autorelease];
}
- initWithClass: (Class)class_
{
Class c = [self class];
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
- initWithClass: (Class)class_
mutex: (OFMutex*)mutex_
|
︙ | | | ︙ | |
Modified src/exceptions/OFMutexUnlockFailedException.m
from [08a37d6d7a]
to [c4a9463880].
︙ | | | ︙ | |
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
{
return [[[self alloc] initWithClass: class_
mutex: mutex] autorelease];
}
- initWithClass: (Class)class_
{
Class c = isa;
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
- initWithClass: (Class)class_
mutex: (OFMutex*)mutex_
|
|
|
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
{
return [[[self alloc] initWithClass: class_
mutex: mutex] autorelease];
}
- initWithClass: (Class)class_
{
Class c = [self class];
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
- initWithClass: (Class)class_
mutex: (OFMutex*)mutex_
|
︙ | | | ︙ | |
Modified src/exceptions/OFNotConnectedException.m
from [ed27efcb61]
to [0c7a0604fc].
︙ | | | ︙ | |
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
{
return [[[self alloc] initWithClass: class_
socket: socket] autorelease];
}
- initWithClass: (Class)class_
{
Class c = isa;
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
- initWithClass: (Class)class_
socket: (OFStreamSocket*)socket_
|
|
|
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
{
return [[[self alloc] initWithClass: class_
socket: socket] autorelease];
}
- initWithClass: (Class)class_
{
Class c = [self class];
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
- initWithClass: (Class)class_
socket: (OFStreamSocket*)socket_
|
︙ | | | ︙ | |
Modified src/exceptions/OFNotImplementedException.m
from [9d000fd2c5]
to [9940be49c7].
︙ | | | ︙ | |
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
{
return [[[self alloc] initWithClass: class_
selector: selector] autorelease];
}
- initWithClass: (Class)class_
{
Class c = isa;
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
- initWithClass: (Class)class_
selector: (SEL)selector_
|
|
|
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
{
return [[[self alloc] initWithClass: class_
selector: selector] autorelease];
}
- initWithClass: (Class)class_
{
Class c = [self class];
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
- initWithClass: (Class)class_
selector: (SEL)selector_
|
︙ | | | ︙ | |
Modified src/exceptions/OFOpenFileFailedException.m
from [aa6dd716b2]
to [496127f6be].
︙ | | | ︙ | |
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
return [[[self alloc] initWithClass: class_
path: path
mode: mode] autorelease];
}
- initWithClass: (Class)class_
{
Class c = isa;
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
- initWithClass: (Class)class_
path: (OFString*)path_
|
|
|
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
return [[[self alloc] initWithClass: class_
path: path
mode: mode] autorelease];
}
- initWithClass: (Class)class_
{
Class c = [self class];
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
- initWithClass: (Class)class_
path: (OFString*)path_
|
︙ | | | ︙ | |
Modified src/exceptions/OFReadOrWriteFailedException.m
from [68006d8668]
to [a9588f5d20].
︙ | | | ︙ | |
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
return [[[self alloc] initWithClass: class_
stream: stream
requestedLength: length] autorelease];
}
- initWithClass: (Class)class_
{
Class c = isa;
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
- initWithClass: (Class)class_
stream: (OFStream*)stream_
|
|
|
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
return [[[self alloc] initWithClass: class_
stream: stream
requestedLength: length] autorelease];
}
- initWithClass: (Class)class_
{
Class c = [self class];
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
- initWithClass: (Class)class_
stream: (OFStream*)stream_
|
︙ | | | ︙ | |
Modified src/exceptions/OFRenameFileFailedException.m
from [a9d15bac5e]
to [af0a07bcb2].
︙ | | | ︙ | |
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
return [[[self alloc] initWithClass: class_
sourcePath: source
destinationPath: destination] autorelease];
}
- initWithClass: (Class)class_
{
Class c = isa;
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
- initWithClass: (Class)class_
sourcePath: (OFString*)source
|
|
|
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
return [[[self alloc] initWithClass: class_
sourcePath: source
destinationPath: destination] autorelease];
}
- initWithClass: (Class)class_
{
Class c = [self class];
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
- initWithClass: (Class)class_
sourcePath: (OFString*)source
|
︙ | | | ︙ | |
Modified src/exceptions/OFSeekFailedException.m
from [c61a9a15f4]
to [9676a55c0c].
︙ | | | ︙ | |
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
stream: stream
offset: offset
whence: whence] autorelease];
}
- initWithClass: (Class)class_
{
Class c = isa;
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
- initWithClass: (Class)class_
stream: (OFSeekableStream*)stream_
|
|
|
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
stream: stream
offset: offset
whence: whence] autorelease];
}
- initWithClass: (Class)class_
{
Class c = [self class];
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
- initWithClass: (Class)class_
stream: (OFSeekableStream*)stream_
|
︙ | | | ︙ | |
Modified src/exceptions/OFSetOptionFailedException.m
from [7a4edc2cf1]
to [aa24331688].
︙ | | | ︙ | |
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
{
return [[[self alloc] initWithClass: class_
stream: stream] autorelease];
}
- initWithClass: (Class)class_
{
Class c = isa;
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
- initWithClass: (Class)class_
stream: (OFStream*)stream_
|
|
|
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
{
return [[[self alloc] initWithClass: class_
stream: stream] autorelease];
}
- initWithClass: (Class)class_
{
Class c = [self class];
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
- initWithClass: (Class)class_
stream: (OFStream*)stream_
|
︙ | | | ︙ | |
Modified src/exceptions/OFSymlinkFailedException.m
from [b700addde1]
to [214ce42612].
︙ | | | ︙ | |
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
return [[[self alloc] initWithClass: class_
sourcePath: source
destinationPath: destination] autorelease];
}
- initWithClass: (Class)class_
{
Class c = isa;
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
- initWithClass: (Class)class_
sourcePath: (OFString*)source
|
|
|
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
return [[[self alloc] initWithClass: class_
sourcePath: source
destinationPath: destination] autorelease];
}
- initWithClass: (Class)class_
{
Class c = [self class];
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
- initWithClass: (Class)class_
sourcePath: (OFString*)source
|
︙ | | | ︙ | |
Modified src/exceptions/OFThreadJoinFailedException.m
from [d09d962f98]
to [b07b6bac14].
︙ | | | ︙ | |
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
{
return [[[self alloc] initWithClass: class_
thread: thread] autorelease];
}
- initWithClass: (Class)class_
{
Class c = isa;
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
- initWithClass: (Class)class_
thread: (OFThread*)thread_
|
|
|
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
{
return [[[self alloc] initWithClass: class_
thread: thread] autorelease];
}
- initWithClass: (Class)class_
{
Class c = [self class];
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
- initWithClass: (Class)class_
thread: (OFThread*)thread_
|
︙ | | | ︙ | |
Modified src/exceptions/OFThreadStartFailedException.m
from [3f8951507b]
to [be16f87910].
︙ | | | ︙ | |
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
{
return [[[self alloc] initWithClass: class_
thread: thread] autorelease];
}
- initWithClass: (Class)class_
{
Class c = isa;
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
- initWithClass: (Class)class_
thread: (OFThread*)thread_
|
|
|
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
{
return [[[self alloc] initWithClass: class_
thread: thread] autorelease];
}
- initWithClass: (Class)class_
{
Class c = [self class];
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
- initWithClass: (Class)class_
thread: (OFThread*)thread_
|
︙ | | | ︙ | |
Modified src/exceptions/OFThreadStillRunningException.m
from [282b5fe672]
to [71badbba8d].
︙ | | | ︙ | |
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
{
return [[[self alloc] initWithClass: class_
thread: thread] autorelease];
}
- initWithClass: (Class)class_
{
Class c = isa;
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
- initWithClass: (Class)class_
thread: (OFThread*)thread_
|
|
|
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
{
return [[[self alloc] initWithClass: class_
thread: thread] autorelease];
}
- initWithClass: (Class)class_
{
Class c = [self class];
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
- initWithClass: (Class)class_
thread: (OFThread*)thread_
|
︙ | | | ︙ | |
Modified src/exceptions/OFUnboundNamespaceException.m
from [0bd9f0134d]
to [dec99405b9].
︙ | | | ︙ | |
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
{
return [[[self alloc] initWithClass: class_
prefix: prefix] autorelease];
}
- initWithClass: (Class)class_
{
Class c = isa;
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
- initWithClass: (Class)class_
namespace: (OFString*)ns_
|
|
|
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
{
return [[[self alloc] initWithClass: class_
prefix: prefix] autorelease];
}
- initWithClass: (Class)class_
{
Class c = [self class];
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
- initWithClass: (Class)class_
namespace: (OFString*)ns_
|
︙ | | | ︙ | |
Modified src/exceptions/OFUnsupportedProtocolException.m
from [64fddef22b]
to [84b4e15386].
︙ | | | ︙ | |
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
{
return [[[self alloc] initWithClass: class_
URL: url] autorelease];
}
- initWithClass: (Class)class_
{
Class c = isa;
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
- initWithClass: (Class)class_
URL: (OFURL*)url
|
|
|
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
{
return [[[self alloc] initWithClass: class_
URL: url] autorelease];
}
- initWithClass: (Class)class_
{
Class c = [self class];
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
- initWithClass: (Class)class_
URL: (OFURL*)url
|
︙ | | | ︙ | |
Modified src/foundation-compat.m
from [6bb0937ec0]
to [5ec64d7fc7].
︙ | | | ︙ | |
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
autoreleaseMethod = class_getInstanceMethod(NSObject,
@selector(autorelease));
if (allocMethod == NULL || addObjectMethod == NULL ||
autoreleaseMethod == NULL)
return;
class_replaceMethod(NSAutoreleasePool->isa, @selector(alloc),
(IMP)alloc, method_getTypeEncoding(allocMethod));
class_replaceMethod(NSAutoreleasePool->isa, @selector(addObject:),
(IMP)addObject, method_getTypeEncoding(addObjectMethod));
class_replaceMethod(NSObject, @selector(autorelease),
(IMP)autorelease, method_getTypeEncoding(autoreleaseMethod));
}
|
|
|
>
|
|
|
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
autoreleaseMethod = class_getInstanceMethod(NSObject,
@selector(autorelease));
if (allocMethod == NULL || addObjectMethod == NULL ||
autoreleaseMethod == NULL)
return;
class_replaceMethod(object_getClass(NSAutoreleasePool),
@selector(alloc), (IMP)alloc, method_getTypeEncoding(allocMethod));
class_replaceMethod(object_getClass(NSAutoreleasePool),
@selector(addObject:), (IMP)addObject,
method_getTypeEncoding(addObjectMethod));
class_replaceMethod(NSObject, @selector(autorelease),
(IMP)autorelease, method_getTypeEncoding(autoreleaseMethod));
}
|
Modified src/runtime/exception.m
from [9f84282618]
to [93064c290f].
︙ | | | ︙ | |
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
|
if (class == Nil)
return YES;
if (object == nil)
return NO;
for (iter = object->isa; iter != Nil; iter = class_getSuperclass(iter))
if (iter == class)
return YES;
return NO;
}
static uint8_t
|
>
|
|
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
|
if (class == Nil)
return YES;
if (object == nil)
return NO;
for (iter = object_getClass(object); iter != Nil;
iter = class_getSuperclass(iter))
if (iter == class)
return YES;
return NO;
}
static uint8_t
|
︙ | | | ︙ | |
Modified src/runtime/lookup.m
from [584f60ba59]
to [34d39a737b].
︙ | | | ︙ | |
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
#import "macros.h"
IMP (*objc_forward_handler)(id, SEL) = NULL;
IMP
objc_not_found_handler(id obj, SEL sel)
{
if (!(obj->isa->info & OBJC_CLASS_INFO_INITIALIZED)) {
BOOL is_class = obj->isa->info & OBJC_CLASS_INFO_METACLASS;
Class cls = (is_class ? (Class)obj : obj->isa);
objc_initialize_class(cls);
if (!(cls->info & OBJC_CLASS_INFO_SETUP)) {
if (is_class)
return objc_msg_lookup(nil, sel);
else
|
|
>
|
|
|
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
#import "macros.h"
IMP (*objc_forward_handler)(id, SEL) = NULL;
IMP
objc_not_found_handler(id obj, SEL sel)
{
if (!(object_getClass(obj)->info & OBJC_CLASS_INFO_INITIALIZED)) {
BOOL is_class =
object_getClass(obj)->info & OBJC_CLASS_INFO_METACLASS;
Class cls = (is_class ? (Class)obj : object_getClass(obj));
objc_initialize_class(cls);
if (!(cls->info & OBJC_CLASS_INFO_SETUP)) {
if (is_class)
return objc_msg_lookup(nil, sel);
else
|
︙ | | | ︙ | |
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
return objc_msg_lookup(obj, sel);
}
if (objc_forward_handler != NULL)
return objc_forward_handler(obj, sel);
ERROR("Selector %s is not implemented for class %s!",
sel_getName(sel), obj->isa->name);
}
BOOL
class_respondsToSelector(Class cls, SEL sel)
{
if (cls == Nil)
return NO;
|
|
|
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
return objc_msg_lookup(obj, sel);
}
if (objc_forward_handler != NULL)
return objc_forward_handler(obj, sel);
ERROR("Selector %s is not implemented for class %s!",
sel_getName(sel), object_getClassName(obj));
}
BOOL
class_respondsToSelector(Class cls, SEL sel)
{
if (cls == Nil)
return NO;
|
︙ | | | ︙ | |
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
|
objc_msg_lookup(id obj, SEL sel)
{
IMP imp;
if (obj == nil)
return (IMP)nil_method;
imp = objc_sparsearray_get(obj->isa->dtable, (uint32_t)sel->uid);
if (imp == NULL)
return objc_not_found_handler(obj, sel);
return imp;
}
|
|
>
|
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
objc_msg_lookup(id obj, SEL sel)
{
IMP imp;
if (obj == nil)
return (IMP)nil_method;
imp = objc_sparsearray_get(object_getClass(obj)->dtable,
(uint32_t)sel->uid);
if (imp == NULL)
return objc_not_found_handler(obj, sel);
return imp;
}
|
︙ | | | ︙ | |
Modified src/runtime/static-instances.m
from [af522385e4]
to [3523e88639].
︙ | | | ︙ | |
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
Class cls = objc_lookup_class(static_instances[i]->class_name);
if (cls != Nil) {
id *instances;
for (instances = static_instances[i]->instances;
*instances != nil; instances++)
(*instances)->isa = cls;
static_instances_cnt--;
if (static_instances_cnt == 0) {
free(static_instances);
static_instances = NULL;
continue;
|
|
|
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
Class cls = objc_lookup_class(static_instances[i]->class_name);
if (cls != Nil) {
id *instances;
for (instances = static_instances[i]->instances;
*instances != nil; instances++)
object_setClass(*instances, cls);
static_instances_cnt--;
if (static_instances_cnt == 0) {
free(static_instances);
static_instances = NULL;
continue;
|
︙ | | | ︙ | |
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
Class cls = objc_lookup_class((*si)->class_name);
if (cls != Nil) {
id *instances;
for (instances = (*si)->instances; *instances != nil;
instances++)
(*instances)->isa = cls;
} else {
if (static_instances == NULL)
static_instances = malloc(sizeof(
struct objc_abi_static_instances*));
else
static_instances = realloc(static_instances,
sizeof(struct objc_abi_static_instances*) *
|
|
|
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
Class cls = objc_lookup_class((*si)->class_name);
if (cls != Nil) {
id *instances;
for (instances = (*si)->instances; *instances != nil;
instances++)
object_setClass(*instances, cls);
} else {
if (static_instances == NULL)
static_instances = malloc(sizeof(
struct objc_abi_static_instances*));
else
static_instances = realloc(static_instances,
sizeof(struct objc_abi_static_instances*) *
|
︙ | | | ︙ | |