Modified src/OFApplication.m
from [c080ac0fe6]
to [9f8423320a].
︙ | | |
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
|
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
|
-
+
-
+
-
-
+
+
|
if ([delegate respondsToSelector: @selector(applicationWillTerminate)])
[delegate applicationWillTerminate];
[delegate release];
}
#define SIGNAL_HANDLER(sig) \
#define SIGNAL_HANDLER(signal) \
static void \
handle##sig(int signal) \
handle##signal(int sig) \
{ \
app->_##sig##Handler(app->_delegate, \
@selector(applicationDidReceive##sig)); \
app->_##signal##Handler(app->_delegate, \
@selector(applicationDidReceive##signal)); \
}
SIGNAL_HANDLER(SIGINT)
#ifdef SIGHUP
SIGNAL_HANDLER(SIGHUP)
#endif
#ifdef SIGUSR1
SIGNAL_HANDLER(SIGUSR1)
|
︙ | | |
Modified src/OFArray.m
from [5414c26349]
to [1bed7cc771].
︙ | | |
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
|
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
|
-
+
-
+
-
+
|
}
- (id)mutableCopy
{
return [[OFMutableArray alloc] initWithArray: self];
}
- (id)objectAtIndex: (size_t)index
- (id)objectAtIndex: (size_t)idx
{
OF_UNRECOGNIZED_SELECTOR
}
- (id)objectAtIndexedSubscript: (size_t)index
- (id)objectAtIndexedSubscript: (size_t)idx
{
return [self objectAtIndex: index];
return [self objectAtIndex: idx];
}
- (id)valueForKey: (OFString *)key
{
id ret;
if ([key hasPrefix: @"@"]) {
|
︙ | | |
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
|
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
|
-
+
-
+
|
{
OFArray *ret;
size_t count = [self count];
id *tmp = [self allocMemoryWithSize: sizeof(id)
count: count];
@try {
[self enumerateObjectsUsingBlock: ^ (id object, size_t index,
[self enumerateObjectsUsingBlock: ^ (id object, size_t idx,
bool *stop) {
tmp[index] = block(object, index);
tmp[idx] = block(object, idx);
}];
ret = [OFArray arrayWithObjects: tmp
count: count];
} @finally {
[self freeMemory: tmp];
}
|
︙ | | |
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
|
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
|
-
+
-
+
|
size_t count = [self count];
id *tmp = [self allocMemoryWithSize: sizeof(id)
count: count];
@try {
__block size_t i = 0;
[self enumerateObjectsUsingBlock: ^ (id object, size_t index,
[self enumerateObjectsUsingBlock: ^ (id object, size_t idx,
bool *stop) {
if (block(object, index))
if (block(object, idx))
tmp[i++] = object;
}];
ret = [OFArray arrayWithObjects: tmp
count: i];
} @finally {
[self freeMemory: tmp];
|
︙ | | |
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
|
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
|
-
+
-
+
|
__block id current;
if (count == 0)
return nil;
if (count == 1)
return [[[self firstObject] retain] autorelease];
[self enumerateObjectsUsingBlock: ^ (id object, size_t index,
[self enumerateObjectsUsingBlock: ^ (id object, size_t idx,
bool *stop) {
id new;
if (index == 0) {
if (idx == 0) {
current = [object retain];
return;
}
@try {
new = [block(current, object) retain];
} @finally {
|
︙ | | |
Modified src/OFArray_adjacent.m
from [c6a82f0db4]
to [2b59628bd4].
︙ | | |
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
|
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
|
-
+
-
+
-
+
-
+
|
}
- (id const *)objects
{
return [_array items];
}
- (id)objectAtIndex: (size_t)index
- (id)objectAtIndex: (size_t)idx
{
return *((id *)[_array itemAtIndex: index]);
return *((id *)[_array itemAtIndex: idx]);
}
- (id)objectAtIndexedSubscript: (size_t)index
- (id)objectAtIndexedSubscript: (size_t)idx
{
return *((id *)[_array itemAtIndex: index]);
return *((id *)[_array itemAtIndex: idx]);
}
- (void)getObjects: (id *)buffer
inRange: (of_range_t)range
{
id *objects = [_array items];
size_t count = [_array count];
|
︙ | | |
Modified src/OFArray_subarray.m
from [25410c7619]
to [28b00df2ee].
︙ | | |
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
|
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
|
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
|
}
- (size_t)count
{
return _range.length;
}
- (id)objectAtIndex: (size_t)index
- (id)objectAtIndex: (size_t)idx
{
if (index >= _range.length)
if (idx >= _range.length)
@throw [OFOutOfRangeException exception];
return [_array objectAtIndex: index + _range.location];
return [_array objectAtIndex: idx + _range.location];
}
- (void)getObjects: (id *)buffer
inRange: (of_range_t)range
{
if (range.length > SIZE_MAX - range.location ||
range.location + range.length > _range.length)
@throw [OFOutOfRangeException exception];
range.location += _range.location;
[_array getObjects: buffer
inRange: range];
}
- (size_t)indexOfObject: (id)object
{
size_t index = [_array indexOfObject: object];
size_t idx = [_array indexOfObject: object];
if (index < _range.location)
if (idx < _range.location)
return OF_NOT_FOUND;
index -= _range.location;
idx -= _range.location;
if (index >= _range.length)
if (idx >= _range.length)
return OF_NOT_FOUND;
return index;
return idx;
}
- (size_t)indexOfObjectIdenticalTo: (id)object
{
size_t index = [_array indexOfObjectIdenticalTo: object];
size_t idx = [_array indexOfObjectIdenticalTo: object];
if (index < _range.location)
if (idx < _range.location)
return OF_NOT_FOUND;
index -= _range.location;
idx -= _range.location;
if (index >= _range.length)
if (idx >= _range.length)
return OF_NOT_FOUND;
return index;
return idx;
}
- (OFArray *)objectsInRange: (of_range_t)range
{
if (range.length > SIZE_MAX - range.location ||
range.location + range.length > _range.length)
@throw [OFOutOfRangeException exception];
range.location += _range.location;
return [_array objectsInRange: range];
}
@end
|
Modified src/OFConstantString.m
from [aaf59fe08c]
to [8314c8c128].
︙ | | |
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
|
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
|
-
+
-
+
|
- (of_comparison_result_t)caseInsensitiveCompare: (OFString *)otherString
{
[self finishInitialization];
return [self caseInsensitiveCompare: otherString];
}
- (of_unichar_t)characterAtIndex: (size_t)index
- (of_unichar_t)characterAtIndex: (size_t)idx
{
[self finishInitialization];
return [self characterAtIndex: index];
return [self characterAtIndex: idx];
}
- (void)getCharacters: (of_unichar_t *)buffer
inRange: (of_range_t)range
{
[self finishInitialization];
|
︙ | | |
Modified src/OFData.m
from [15a4b9e206]
to [118e27647e].
︙ | | |
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
|
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
|
-
+
-
+
-
+
|
}
- (const void *)items
{
return _items;
}
- (const void *)itemAtIndex: (size_t)index
- (const void *)itemAtIndex: (size_t)idx
{
if (index >= _count)
if (idx >= _count)
@throw [OFOutOfRangeException exception];
return _items + index * _itemSize;
return _items + idx * _itemSize;
}
- (const void *)firstItem
{
if (_items == NULL || _count == 0)
return NULL;
|
︙ | | |
Modified src/OFHTTPClient.m
from [901849c7c7]
to [3d2d594ca8].
︙ | | |
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
-
+
|
OFTCPSocket *_socket;
bool _hasContentLength, _chunked, _keepAlive, _atEndOfStream;
size_t _toRead;
}
@property (nonatomic, setter=of_setKeepAlive:) bool of_keepAlive;
- (instancetype)initWithSocket: (OFTCPSocket *)socket;
- (instancetype)initWithSocket: (OFTCPSocket *)sock;
@end
static OFString *
constructRequestString(OFHTTPRequest *request)
{
void *pool = objc_autoreleasePoolPush();
of_http_request_method_t method = [request method];
|
︙ | | |
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
|
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
|
-
+
-
+
|
[_context release];
[_version release];
[_serverHeaders release];
[super dealloc];
}
- (void)createResponseWithSocket: (OFTCPSocket *)socket
- (void)createResponseWithSocket: (OFTCPSocket *)sock
{
OFURL *URL = [_request URL];
OFHTTPClientResponse *response;
OFString *connectionHeader;
bool keepAlive;
OFString *location;
response = [[[OFHTTPClientResponse alloc] initWithSocket: socket]
response = [[[OFHTTPClientResponse alloc] initWithSocket: sock]
autorelease];
[response setProtocolVersionFromString: _version];
[response setStatusCode: _status];
[response setHeaders: _serverHeaders];
connectionHeader = [_serverHeaders objectForKey: @"Connection"];
if ([_version isEqual: @"1.1"]) {
|
︙ | | |
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
|
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
|
-
+
|
else
keepAlive = false;
}
if (keepAlive) {
[response of_setKeepAlive: true];
_client->_socket = [socket retain];
_client->_socket = [sock retain];
_client->_lastURL = [URL copy];
_client->_lastWasHEAD =
([_request method] == OF_HTTP_REQUEST_METHOD_HEAD);
_client->_lastResponse = [response retain];
}
/* FIXME: Case-insensitive check of redirect's scheme */
|
︙ | | |
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
|
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
|
-
+
-
+
|
_status = (int)[[line substringWithRange: of_range(9, 3)] decimalValue];
return true;
}
- (bool)handleServerHeader: (OFString *)line
socket: (OFTCPSocket *)socket
socket: (OFTCPSocket *)sock
{
OFString *key, *value, *old;
const char *lineC, *tmp;
char *keyC;
if (line == nil)
@throw [OFInvalidServerReplyException exception];
if ([line length] == 0) {
[_serverHeaders makeImmutable];
if ([_client->_delegate respondsToSelector: @selector(client:
didReceiveHeaders:statusCode:request:context:)])
[_client->_delegate client: _client
didReceiveHeaders: _serverHeaders
statusCode: _status
request: _request
context: _context];
[self performSelector: @selector(createResponseWithSocket:)
withObject: socket
withObject: sock
afterDelay: 0];
return false;
}
lineC = [line UTF8String];
|
︙ | | |
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
537
538
|
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
537
538
539
540
541
542
|
-
+
+
+
-
+
-
-
+
+
-
+
-
-
-
+
+
+
+
+
-
-
-
-
+
+
+
+
-
+
|
[_serverHeaders setObject: value
forKey: key];
return true;
}
- (bool)socket: (OFTCPSocket *)socket
- (bool)socket: (OFTCPSocket *)sock
didReadLine: (OFString *)line
context: (id)context
exception: (id)exception
{
bool ret;
if (exception != nil) {
if ([exception isKindOfClass:
[OFInvalidEncodingException class]])
exception = [OFInvalidServerReplyException exception];
[_client->_delegate client: _client
didEncounterException: exception
forRequest: _request
context: _context];
return false;
}
@try {
if (_firstLine) {
_firstLine = false;
return [self handleFirstLine: line];
ret = [self handleFirstLine: line];
} else
return [self handleServerHeader: line
socket: socket];
ret = [self handleServerHeader: line
socket: sock];
} @catch (id e) {
[_client->_delegate client: _client
didEncounterException: e
forRequest: _request
context: _context];
return false;
ret = false;
}
}
- (size_t)socket: (OFTCPSocket *)socket
return ret;
}
- (size_t)socket: (OFTCPSocket *)sock
didWriteBody: (const void **)body
length: (size_t)length
context: (id)context
exception: (id)exception
{
if (exception != nil) {
[_client->_delegate client: _client
didEncounterException: exception
forRequest: _request
context: _context];
return 0;
}
[socket asyncReadLineWithTarget: self
selector: @selector(socket:didReadLine:context:
exception:)
context: nil];
[sock asyncReadLineWithTarget: self
selector: @selector(socket:didReadLine:context:
exception:)
context: nil];
return 0;
}
- (size_t)socket: (OFTCPSocket *)socket
- (size_t)socket: (OFTCPSocket *)sock
didWriteRequest: (const void **)request
length: (size_t)length
context: (id)context
exception: (id)exception
{
OFData *body;
|
︙ | | |
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
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
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
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
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
|
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
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
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
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
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
|
-
-
-
-
-
-
+
+
+
+
+
+
-
+
-
+
-
-
-
-
-
-
+
+
+
+
+
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
-
+
-
-
-
-
-
-
+
+
+
+
+
+
-
+
-
+
|
didEncounterException: exception
forRequest: _request
context: _context];
return 0;
}
if ((body = [_request body]) != nil) {
[socket asyncWriteBuffer: [body items]
length: [body count] * [body itemSize]
target: self
selector: @selector(socket:didWriteBody:length:
context:exception:)
context: nil];
[sock asyncWriteBuffer: [body items]
length: [body count] * [body itemSize]
target: self
selector: @selector(socket:didWriteBody:length:
context:exception:)
context: nil];
return 0;
} else
return [self socket: socket
return [self socket: sock
didWriteBody: NULL
length: 0
context: nil
exception: nil];
}
- (void)handleSocket: (OFTCPSocket *)socket
- (void)handleSocket: (OFTCPSocket *)sock
{
/*
* As a work around for a bug with split packets in lighttpd when using
* HTTPS, we construct the complete request in a buffer string and then
* send it all at once.
*
* We do not use the socket's write buffer in case we need to resend
* the entire request (e.g. in case a keep-alive connection timed out).
*/
@try {
OFString *requestString = constructRequestString(_request);
const char *UTF8String = [requestString UTF8String];
size_t UTF8StringLength = [requestString UTF8StringLength];
/*
* Pass requestString as context to retain it so that the
* underlying buffer lives long enough.
*/
[socket asyncWriteBuffer: UTF8String
length: UTF8StringLength
target: self
selector: @selector(socket:didWriteRequest:
length:context:exception:)
context: requestString];
[sock asyncWriteBuffer: UTF8String
length: UTF8StringLength
target: self
selector: @selector(socket:didWriteRequest:
length:context:exception:)
context: requestString];
} @catch (id e) {
[_client->_delegate client: _client
didEncounterException: e
forRequest: _request
context: _context];
return;
}
}
- (void)socketDidConnect: (OFTCPSocket *)socket
- (void)socketDidConnect: (OFTCPSocket *)sock
context: (id)context
exception: (id)exception
{
if (exception != nil) {
[_client->_delegate client: _client
didEncounterException: exception
forRequest: _request
context: _context];
return;
}
if ([_client->_delegate respondsToSelector:
@selector(client:didCreateSocket:forRequest:context:)])
[_client->_delegate client: _client
didCreateSocket: socket
didCreateSocket: sock
forRequest: _request
context: _context];
[self performSelector: @selector(handleSocket:)
withObject: socket
withObject: sock
afterDelay: 0];
}
- (bool)throwAwayContent: (OFHTTPClientResponse *)response
buffer: (char *)buffer
length: (size_t)length
context: (OFTCPSocket *)socket
context: (OFTCPSocket *)sock
exception: (id)exception
{
if (exception != nil) {
[_client->_delegate client: _client
didEncounterException: exception
forRequest: _request
context: _context];
return false;
}
if ([response isAtEndOfStream]) {
[self freeMemory: buffer];
[_client->_lastResponse release];
_client->_lastResponse = nil;
[self performSelector: @selector(handleSocket:)
withObject: socket
withObject: sock
afterDelay: 0];
return false;
}
return true;
}
- (void)start
{
OFURL *URL = [_request URL];
OFTCPSocket *socket;
OFTCPSocket *sock;
/* Can we reuse the last socket? */
if (_client->_socket != nil &&
[[_client->_lastURL scheme] isEqual: [URL scheme]] &&
[[_client->_lastURL host] isEqual: [URL host]] &&
[_client->_lastURL port] == [URL port]) {
/*
* Set _socket to nil, so that in case of an error it won't be
* reused. If everything is successful, we set _socket again
* at the end.
*/
socket = [_client->_socket autorelease];
sock = [_client->_socket autorelease];
_client->_socket = nil;
[_client->_lastURL release];
_client->_lastURL = nil;
if (!_client->_lastWasHEAD) {
/* Throw away content that has not been read yet */
char *buffer = [self allocMemoryWithSize: 512];
[_client->_lastResponse
asyncReadIntoBuffer: buffer
length: 512
target: self
selector: @selector(throwAwayContent:
buffer:length:context:
exception:)
context: socket];
context: sock];
} else {
[_client->_lastResponse release];
_client->_lastResponse = nil;
[self performSelector: @selector(handleSocket:)
withObject: socket
withObject: sock
afterDelay: 0];
}
} else
[self closeAndReconnect];
}
- (void)closeAndReconnect
{
OFURL *URL = [_request URL];
OFTCPSocket *socket;
OFTCPSocket *sock;
[_client close];
if ([[URL scheme] isEqual: @"https"]) {
if (of_tls_socket_class == Nil)
@throw [OFUnsupportedProtocolException
exceptionWithURL: URL];
socket = [[[of_tls_socket_class alloc] init]
sock = [[[of_tls_socket_class alloc] init] autorelease];
autorelease];
} else
socket = [OFTCPSocket socket];
sock = [OFTCPSocket socket];
[socket asyncConnectToHost: [URL host]
port: [URL port]
target: self
selector: @selector(socketDidConnect:context:
exception:)
context: nil];
[sock asyncConnectToHost: [URL host]
port: [URL port]
target: self
selector: @selector(socketDidConnect:context:
exception:)
context: nil];
}
@end
@implementation OFHTTPClientResponse
@synthesize of_keepAlive = _keepAlive;
- (instancetype)initWithSocket: (OFTCPSocket *)socket
- (instancetype)initWithSocket: (OFTCPSocket *)sock
{
self = [super init];
_socket = [socket retain];
_socket = [sock retain];
return self;
}
- (void)dealloc
{
[_socket release];
|
︙ | | |
Modified src/OFHTTPServer.m
from [339d905a8d]
to [a75e2ea261].
︙ | | |
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
-
+
|
/*
* FIXME: Key normalization replaces headers like "DNT" with "Dnt".
* FIXME: Errors are not reported to the user.
*/
@interface OFHTTPServer ()
- (bool)of_socket: (OFTCPSocket *)socket
- (bool)of_socket: (OFTCPSocket *)sock
didAcceptSocket: (OFTCPSocket *)clientSocket
context: (id)context
exception: (id)exception;
@end
static const char *
statusCodeToString(short code)
|
︙ | | |
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
|
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
|
-
+
-
+
-
+
|
{
OFTCPSocket *_socket;
OFHTTPServer *_server;
OFHTTPRequest *_request;
bool _chunked, _headersSent;
}
- (instancetype)initWithSocket: (OFTCPSocket *)socket
- (instancetype)initWithSocket: (OFTCPSocket *)sock
server: (OFHTTPServer *)server
request: (OFHTTPRequest *)request;
@end
@implementation OFHTTPServerResponse
- (instancetype)initWithSocket: (OFTCPSocket *)socket
- (instancetype)initWithSocket: (OFTCPSocket *)sock
server: (OFHTTPServer *)server
request: (OFHTTPRequest *)request
{
self = [super init];
_statusCode = 500;
_socket = [socket retain];
_socket = [sock retain];
_server = [server retain];
_request = [request retain];
return self;
}
- (void)dealloc
|
︙ | | |
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
|
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
|
-
+
-
+
-
+
-
+
-
+
-
+
|
OFString *_host, *_path;
uint16_t _port;
OFMutableDictionary *_headers;
size_t _contentLength;
OFMutableData *_body;
}
- (instancetype)initWithSocket: (OFTCPSocket *)socket
- (instancetype)initWithSocket: (OFTCPSocket *)sock
server: (OFHTTPServer *)server;
- (bool)socket: (OFTCPSocket *)socket
- (bool)socket: (OFTCPSocket *)sock
didReadLine: (OFString *)line
context: (id)context
exception: (id)exception;
- (bool)parseProlog: (OFString *)line;
- (bool)parseHeaders: (OFString *)line;
- (bool)socket: (OFTCPSocket *)socket
- (bool)socket: (OFTCPSocket *)sock
didReadIntoBuffer: (char *)buffer
length: (size_t)length
context: (id)context
exception: (id)exception;
- (bool)sendErrorAndClose: (short)statusCode;
- (void)createResponse;
@end
@implementation OFHTTPServer_Connection
- (instancetype)initWithSocket: (OFTCPSocket *)socket
- (instancetype)initWithSocket: (OFTCPSocket *)sock
server: (OFHTTPServer *)server
{
self = [super init];
@try {
_socket = [socket retain];
_socket = [sock retain];
_server = [server retain];
_timer = [[OFTimer
scheduledTimerWithTimeInterval: 10
target: socket
target: _socket
selector: @selector(
cancelAsyncRequests)
repeats: false] retain];
_state = AWAITING_PROLOG;
} @catch (id e) {
[self release];
@throw e;
|
︙ | | |
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
|
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
|
-
+
|
[_path release];
[_headers release];
[_body release];
[super dealloc];
}
- (bool)socket: (OFTCPSocket *)socket
- (bool)socket: (OFTCPSocket *)sock
didReadLine: (OFString *)line
context: (id)context
exception: (id)exception
{
if (line == nil || exception != nil)
return false;
|
︙ | | |
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
|
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
|
-
+
-
+
|
_port = 80;
}
}
return true;
}
- (bool)socket: (OFTCPSocket *)socket
- (bool)socket: (OFTCPSocket *)sock
didReadIntoBuffer: (char *)buffer
length: (size_t)length
context: (id)context
exception: (id)exception
{
if ([socket isAtEndOfStream] || exception != nil)
if ([sock isAtEndOfStream] || exception != nil)
return false;
[_body addItems: buffer
count: length];
if ([_body count] >= _contentLength) {
/*
|
︙ | | |
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
|
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
|
-
+
|
- (void)stop
{
[_listeningSocket cancelAsyncRequests];
[_listeningSocket release];
_listeningSocket = nil;
}
- (bool)of_socket: (OFTCPSocket *)socket
- (bool)of_socket: (OFTCPSocket *)sock
didAcceptSocket: (OFTCPSocket *)clientSocket
context: (id)context
exception: (id)exception
{
OFHTTPServer_Connection *connection;
if (exception != nil) {
|
︙ | | |
Modified src/OFInflateStream.m
from [360414f679]
to [4049e67acd].
︙ | | |
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
|
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
|
-
+
-
+
-
+
|
uint16_t j;
if OF_UNLIKELY (_slidingWindow == NULL)
@throw [OFInvalidFormatException
exception];
for (j = 0; j < CTX.length; j++) {
uint16_t index;
uint16_t idx;
if OF_UNLIKELY (length == 0) {
CTX.length -= j;
return bytesWritten;
}
index = (_slidingWindowIndex -
idx = (_slidingWindowIndex -
CTX.distance) & _slidingWindowMask;
value = _slidingWindow[index];
value = _slidingWindow[idx];
buffer[bytesWritten++] = value;
length--;
_slidingWindow[_slidingWindowIndex] =
value;
_slidingWindowIndex =
|
︙ | | |
Modified src/OFInvocation.m
from [de7b955371]
to [2bd671288a].
︙ | | |
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
|
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
|
-
+
-
+
-
+
-
+
|
[_arguments release];
[_returnValue release];
[super dealloc];
}
- (void)setArgument: (const void *)buffer
atIndex: (size_t)index
atIndex: (size_t)idx
{
OFMutableData *data = [_arguments objectAtIndex: index];
OFMutableData *data = [_arguments objectAtIndex: idx];
memcpy([data items], buffer, [data itemSize]);
}
- (void)getArgument: (void *)buffer
atIndex: (size_t)index
atIndex: (size_t)idx
{
OFData *data = [_arguments objectAtIndex: index];
OFData *data = [_arguments objectAtIndex: idx];
memcpy(buffer, [data items], [data itemSize]);
}
- (void)setReturnValue: (const void *)buffer
{
memcpy([_returnValue items], buffer, [_returnValue itemSize]);
|
︙ | | |
Modified src/OFMethodSignature.m
from [8c5f408f1b]
to [42dcab5ffc].
︙ | | |
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
|
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
|
-
+
-
+
-
+
-
+
|
}
- (size_t)frameLength
{
return *(size_t *)[_offsets firstItem];
}
- (const char *)argumentTypeAtIndex: (size_t)index
- (const char *)argumentTypeAtIndex: (size_t)idx
{
return *(const char **)[_typesPointers itemAtIndex: index + 1];
return *(const char **)[_typesPointers itemAtIndex: idx + 1];
}
- (size_t)argumentOffsetAtIndex: (size_t)index
- (size_t)argumentOffsetAtIndex: (size_t)idx
{
return *(size_t *)[_offsets itemAtIndex: index + 1];
return *(size_t *)[_offsets itemAtIndex: idx + 1];
}
@end
|
Modified src/OFMutableArray.m
from [d9547cea8c]
to [a7a21a8f36].
︙ | | |
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
|
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
|
-
+
-
+
-
+
-
+
-
+
-
+
|
- (void)addObjectsFromArray: (OFArray *)array
{
[self insertObjectsFromArray: array
atIndex: [self count]];
}
- (void)insertObject: (id)object
atIndex: (size_t)index
atIndex: (size_t)idx
{
OF_UNRECOGNIZED_SELECTOR
}
- (void)insertObjectsFromArray: (OFArray *)array
atIndex: (size_t)index
atIndex: (size_t)idx
{
size_t i = 0;
for (id object in array)
[self insertObject: object
atIndex: index + i++];
atIndex: idx + i++];
}
- (void)replaceObjectAtIndex: (size_t)index
- (void)replaceObjectAtIndex: (size_t)idx
withObject: (id)object
{
OF_UNRECOGNIZED_SELECTOR
}
- (void)setObject: (id)object
atIndexedSubscript: (size_t)index
atIndexedSubscript: (size_t)idx
{
[self replaceObjectAtIndex: index
[self replaceObjectAtIndex: idx
withObject: object];
}
- (void)replaceObject: (id)oldObject
withObject: (id)newObject
{
size_t count;
|
︙ | | |
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
|
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
|
-
+
|
withObject: newObject];
return;
}
}
}
- (void)removeObjectAtIndex: (size_t)index
- (void)removeObjectAtIndex: (size_t)idx
{
OF_UNRECOGNIZED_SELECTOR
}
- (void)removeObject: (id)object
{
size_t count;
|
︙ | | |
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
|
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
|
-
+
-
+
-
+
-
-
+
+
-
-
+
+
-
+
-
+
|
{
[self removeObjectsInRange: of_range(0, [self count])];
}
#ifdef OF_HAVE_BLOCKS
- (void)replaceObjectsUsingBlock: (of_array_replace_block_t)block
{
[self enumerateObjectsUsingBlock: ^ (id object, size_t index,
[self enumerateObjectsUsingBlock: ^ (id object, size_t idx,
bool *stop) {
id new = block(object, index);
id new = block(object, idx);
if (new != object)
[self replaceObjectAtIndex: index
[self replaceObjectAtIndex: idx
withObject: new];
}];
}
#endif
- (void)exchangeObjectAtIndex: (size_t)index1
withObjectAtIndex: (size_t)index2
- (void)exchangeObjectAtIndex: (size_t)idx1
withObjectAtIndex: (size_t)idx2
{
id object1 = [self objectAtIndex: index1];
id object2 = [self objectAtIndex: index2];
id object1 = [self objectAtIndex: idx1];
id object2 = [self objectAtIndex: idx2];
[object1 retain];
@try {
[self replaceObjectAtIndex: index1
[self replaceObjectAtIndex: idx1
withObject: object2];
[self replaceObjectAtIndex: index2
[self replaceObjectAtIndex: idx2
withObject: object1];
} @finally {
[object1 release];
}
}
- (void)sort
|
︙ | | |
Modified src/OFMutableArray_adjacent.m
from [5cf73c1314]
to [271b9597ba].
︙ | | |
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
|
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
|
-
+
-
+
-
+
-
+
|
[_array addItem: &object];
[object retain];
_mutations++;
}
- (void)insertObject: (id)object
atIndex: (size_t)index
atIndex: (size_t)idx
{
if (object == nil)
@throw [OFInvalidArgumentException exception];
@try {
[_array insertItem: &object
atIndex: index];
atIndex: idx];
} @catch (OFOutOfRangeException *e) {
@throw [OFOutOfRangeException exception];
}
[object retain];
_mutations++;
}
- (void)insertObjectsFromArray: (OFArray *)array
atIndex: (size_t)index
atIndex: (size_t)idx
{
id const *objects = [array objects];
size_t count = [array count];
@try {
[_array insertItems: objects
atIndex: index
atIndex: idx
count: count];
} @catch (OFOutOfRangeException *e) {
@throw [OFOutOfRangeException exception];
}
for (size_t i = 0; i < count; i++)
[objects[i] retain];
|
︙ | | |
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
|
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
|
-
+
-
+
-
-
+
+
|
objects[i] = newObject;
return;
}
}
}
- (void)replaceObjectAtIndex: (size_t)index
- (void)replaceObjectAtIndex: (size_t)idx
withObject: (id)object
{
id *objects;
id oldObject;
if (object == nil)
@throw [OFInvalidArgumentException exception];
objects = [_array items];
if (index >= [_array count])
if (idx >= [_array count])
@throw [OFOutOfRangeException exception];
oldObject = objects[index];
objects[index] = [object retain];
oldObject = objects[idx];
objects[idx] = [object retain];
[oldObject release];
}
- (void)replaceObjectIdenticalTo: (id)oldObject
withObject: (id)newObject
{
id *objects;
|
︙ | | |
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
|
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
|
-
+
-
-
+
+
|
[object release];
return;
}
}
}
- (void)removeObjectAtIndex: (size_t)index
- (void)removeObjectAtIndex: (size_t)idx
{
#ifndef __clang_analyzer__
id object = [self objectAtIndex: index];
[_array removeItemAtIndex: index];
id object = [self objectAtIndex: idx];
[_array removeItemAtIndex: idx];
[object release];
_mutations++;
#endif
}
- (void)removeAllObjects
|
︙ | | |
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
|
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
|
-
-
+
+
-
+
-
-
-
+
+
+
|
[_array removeLastItem];
[object release];
_mutations++;
#endif
}
- (void)exchangeObjectAtIndex: (size_t)index1
withObjectAtIndex: (size_t)index2
- (void)exchangeObjectAtIndex: (size_t)idx1
withObjectAtIndex: (size_t)idx2
{
id *objects = [_array items];
size_t count = [_array count];
id tmp;
if (index1 >= count || index2 >= count)
if (idx1 >= count || idx2 >= count)
@throw [OFOutOfRangeException exception];
tmp = objects[index1];
objects[index1] = objects[index2];
objects[index2] = tmp;
tmp = objects[idx1];
objects[idx1] = objects[idx2];
objects[idx2] = tmp;
}
- (void)reverse
{
id *objects = [_array items];
size_t i, j, count = [_array count];
|
︙ | | |
Modified src/OFMutableData.m
from [1ec47eeb35]
to [c971350bab].
︙ | | |
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
|
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
|
-
+
-
+
|
memcpy(_items + _count * _itemSize, item, _itemSize);
_count++;
}
- (void)insertItem: (const void *)item
atIndex: (size_t)index
atIndex: (size_t)idx
{
[self insertItems: item
atIndex: index
atIndex: idx
count: 1];
}
- (void)addItems: (const void *)items
count: (size_t)count
{
if (count > SIZE_MAX - _count)
|
︙ | | |
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
|
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
|
-
+
-
+
-
-
-
+
+
+
-
+
-
+
|
}
memcpy(_items + _count * _itemSize, items, count * _itemSize);
_count += count;
}
- (void)insertItems: (const void *)items
atIndex: (size_t)index
atIndex: (size_t)idx
count: (size_t)count
{
if (count > SIZE_MAX - _count || index > _count)
if (count > SIZE_MAX - _count || idx > _count)
@throw [OFOutOfRangeException exception];
if (_count + count > _capacity) {
_items = [self resizeMemory: _items
size: _itemSize
count: _count + count];
_capacity = _count + count;
}
memmove(_items + (index + count) * _itemSize,
_items + index * _itemSize, (_count - index) * _itemSize);
memcpy(_items + index * _itemSize, items, count * _itemSize);
memmove(_items + (idx + count) * _itemSize, _items + idx * _itemSize,
(_count - idx) * _itemSize);
memcpy(_items + idx * _itemSize, items, count * _itemSize);
_count += count;
}
- (void)increaseCountBy: (size_t)count
{
if (count > SIZE_MAX - _count)
@throw [OFOutOfRangeException exception];
if (_count + count > _capacity) {
_items = [self resizeMemory: _items
size: _itemSize
count: _count + count];
_capacity = _count + count;
}
memset(_items + _count * _itemSize, '\0', count * _itemSize);
_count += count;
}
- (void)removeItemAtIndex: (size_t)index
- (void)removeItemAtIndex: (size_t)idx
{
[self removeItemsInRange: of_range(index, 1)];
[self removeItemsInRange: of_range(idx, 1)];
}
- (void)removeItemsInRange: (of_range_t)range
{
if (range.length > SIZE_MAX - range.location ||
range.location + range.length > _count)
@throw [OFOutOfRangeException exception];
|
︙ | | |
Modified src/OFMutableString.m
from [8288a048e9]
to [9c395a3fd8].
︙ | | |
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
|
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
|
-
+
-
+
|
}
objc_autoreleasePoolPop(pool);
}
#endif
- (void)setCharacter: (of_unichar_t)character
atIndex: (size_t)index
atIndex: (size_t)idx
{
void *pool = objc_autoreleasePoolPush();
OFString *string;
string = [OFString stringWithCharacters: &character
length: 1];
[self replaceCharactersInRange: of_range(index, 1)
[self replaceCharactersInRange: of_range(idx, 1)
withString: string];
objc_autoreleasePoolPop(pool);
}
- (void)appendString: (OFString *)string
{
|
︙ | | |
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
|
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
|
-
+
-
+
|
{
[self of_convertWithWordStartFunction: of_ascii_toupper
wordMiddleFunction: of_ascii_tolower];
}
#endif
- (void)insertString: (OFString *)string
atIndex: (size_t)index
atIndex: (size_t)idx
{
[self replaceCharactersInRange: of_range(index, 0)
[self replaceCharactersInRange: of_range(idx, 0)
withString: string];
}
- (void)deleteCharactersInRange: (of_range_t)range
{
[self replaceCharactersInRange: range
withString: @""];
|
︙ | | |
Modified src/OFMutableString_UTF8.m
from [4eb8ccee47]
to [7d0da4b4a5].
︙ | | |
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
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
|
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
228
229
230
231
232
233
234
235
236
237
238
239
240
|
-
+
-
+
-
+
-
+
-
+
-
-
+
+
-
+
-
+
-
-
-
+
+
-
+
-
-
-
+
+
|
/*
* Even though cStringLength can change, length cannot, therefore no
* need to change it.
*/
}
- (void)setCharacter: (of_unichar_t)character
atIndex: (size_t)index
atIndex: (size_t)idx
{
char buffer[4];
of_unichar_t c;
size_t lenNew;
ssize_t lenOld;
if (_s->isUTF8)
index = of_string_utf8_get_position(_s->cString, index,
idx = of_string_utf8_get_position(_s->cString, idx,
_s->cStringLength);
if (index > _s->cStringLength)
if (idx > _s->cStringLength)
@throw [OFOutOfRangeException exception];
/* Shortcut if old and new character both are ASCII */
if (character < 0x80 && !(_s->cString[index] & 0x80)) {
if (character < 0x80 && !(_s->cString[idx] & 0x80)) {
_s->hashed = false;
_s->cString[index] = character;
_s->cString[idx] = character;
return;
}
if ((lenNew = of_string_utf8_encode(character, buffer)) == 0)
@throw [OFInvalidEncodingException exception];
if ((lenOld = of_string_utf8_decode(_s->cString + index,
_s->cStringLength - index, &c)) <= 0)
if ((lenOld = of_string_utf8_decode(_s->cString + idx,
_s->cStringLength - idx, &c)) <= 0)
@throw [OFInvalidEncodingException exception];
_s->hashed = false;
if (lenNew == (size_t)lenOld)
memcpy(_s->cString + index, buffer, lenNew);
memcpy(_s->cString + idx, buffer, lenNew);
else if (lenNew > (size_t)lenOld) {
_s->cString = [self resizeMemory: _s->cString
size: _s->cStringLength -
lenOld + lenNew + 1];
memmove(_s->cString + index + lenNew,
memmove(_s->cString + idx + lenNew, _s->cString + idx + lenOld,
_s->cString + index + lenOld,
_s->cStringLength - index - lenOld);
memcpy(_s->cString + index, buffer, lenNew);
_s->cStringLength - idx - lenOld);
memcpy(_s->cString + idx, buffer, lenNew);
_s->cStringLength -= lenOld;
_s->cStringLength += lenNew;
_s->cString[_s->cStringLength] = '\0';
if (character >= 0x80)
_s->isUTF8 = true;
} else if (lenNew < (size_t)lenOld) {
memmove(_s->cString + index + lenNew,
memmove(_s->cString + idx + lenNew, _s->cString + idx + lenOld,
_s->cString + index + lenOld,
_s->cStringLength - index - lenOld);
memcpy(_s->cString + index, buffer, lenNew);
_s->cStringLength - idx - lenOld);
memcpy(_s->cString + idx, buffer, lenNew);
_s->cStringLength -= lenOld;
_s->cStringLength += lenNew;
_s->cString[_s->cStringLength] = '\0';
if (character >= 0x80)
_s->isUTF8 = true;
|
︙ | | |
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
|
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
|
-
+
-
+
-
+
-
-
-
+
+
+
|
/* UTF-8 does not allow more than 4 bytes per character */
@throw [OFInvalidEncodingException exception];
}
}
- (void)insertString: (OFString *)string
atIndex: (size_t)index
atIndex: (size_t)idx
{
size_t newCStringLength;
if (index > _s->length)
if (idx > _s->length)
@throw [OFOutOfRangeException exception];
if (_s->isUTF8)
index = of_string_utf8_get_position(_s->cString, index,
idx = of_string_utf8_get_position(_s->cString, idx,
_s->cStringLength);
newCStringLength = _s->cStringLength + [string UTF8StringLength];
_s->hashed = false;
_s->cString = [self resizeMemory: _s->cString
size: newCStringLength + 1];
memmove(_s->cString + index + [string UTF8StringLength],
_s->cString + index, _s->cStringLength - index);
memcpy(_s->cString + index, [string UTF8String],
memmove(_s->cString + idx + [string UTF8StringLength],
_s->cString + idx, _s->cStringLength - idx);
memcpy(_s->cString + idx, [string UTF8String],
[string UTF8StringLength]);
_s->cString[newCStringLength] = '\0';
_s->cStringLength = newCStringLength;
_s->length += [string length];
if ([string isKindOfClass: [OFString_UTF8 class]] ||
|
︙ | | |
Modified src/OFNumber.h
from [92dadecb01]
to [8625e9c54a].
︙ | | |
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
|
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
|
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
-
-
-
-
+
+
+
+
-
-
-
-
-
-
+
+
+
+
+
+
|
* @brief Provides a way to store a number in an object.
*/
@interface OFNumber: OFObject <OFCopying, OFComparing, OFSerialization,
OFJSONRepresentation, OFMessagePackRepresentation>
{
union of_number_value {
bool bool_;
signed char schar;
signed short sshort;
signed int sint;
signed long slong;
signed long long slonglong;
unsigned char uchar;
unsigned short ushort;
unsigned int uint;
unsigned long ulong;
unsigned long long ulonglong;
signed char sChar;
signed short sShort;
signed int sInt;
signed long sLong;
signed long long sLongLong;
unsigned char uChar;
unsigned short uShort;
unsigned int uInt;
unsigned long uLong;
unsigned long long uLongLong;
int8_t int8;
int16_t int16;
int32_t int32;
int64_t int64;
uint8_t uint8;
uint16_t uint16;
uint32_t uint32;
uint64_t uint64;
uint8_t uInt8;
uint16_t uInt16;
uint32_t uInt32;
uint64_t uInt64;
size_t size;
ssize_t ssize;
intmax_t intmax;
uintmax_t uintmax;
ptrdiff_t ptrdiff;
intptr_t intptr;
uintptr_t uintptr;
ssize_t sSize;
intmax_t intMax;
uintmax_t uIntMax;
ptrdiff_t ptrDiff;
intptr_t intPtr;
uintptr_t uIntPtr;
float float_;
double double_;
} _value;
of_number_type_t _type;
}
/*!
|
︙ | | |
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
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
|
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
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
|
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
|
* @return A new autoreleased OFNumber
*/
+ (instancetype)numberWithBool: (bool)bool_;
/*!
* @brief Creates a new OFNumber with the specified signed char.
*
* @param schar A signed char which the OFNumber should contain
* @param sChar A signed char which the OFNumber should contain
* @return A new autoreleased OFNumber
*/
+ (instancetype)numberWithChar: (signed char)schar;
+ (instancetype)numberWithChar: (signed char)sChar;
/*!
* @brief Creates a new OFNumber with the specified signed short.
*
* @param sshort A signed short which the OFNumber should contain
* @param sShort A signed short which the OFNumber should contain
* @return A new autoreleased OFNumber
*/
+ (instancetype)numberWithShort: (signed short)sshort;
+ (instancetype)numberWithShort: (signed short)sShort;
/*!
* @brief Creates a new OFNumber with the specified signed int.
*
* @param sint A signed int which the OFNumber should contain
* @param sInt A signed int which the OFNumber should contain
* @return A new autoreleased OFNumber
*/
+ (instancetype)numberWithInt: (signed int)sint;
+ (instancetype)numberWithInt: (signed int)sInt;
/*!
* @brief Creates a new OFNumber with the specified signed long.
*
* @param slong A signed long which the OFNumber should contain
* @param sLong A signed long which the OFNumber should contain
* @return A new autoreleased OFNumber
*/
+ (instancetype)numberWithLong: (signed long)slong;
+ (instancetype)numberWithLong: (signed long)sLong;
/*!
* @brief Creates a new OFNumber with the specified signed long long.
*
* @param slonglong A signed long long which the OFNumber should contain
* @param sLongLong A signed long long which the OFNumber should contain
* @return A new autoreleased OFNumber
*/
+ (instancetype)numberWithLongLong: (signed long long)slonglong;
+ (instancetype)numberWithLongLong: (signed long long)sLongLong;
/*!
* @brief Creates a new OFNumber with the specified unsigned char.
*
* @param uchar An unsigned char which the OFNumber should contain
* @param uChar An unsigned char which the OFNumber should contain
* @return A new autoreleased OFNumber
*/
+ (instancetype)numberWithUnsignedChar: (unsigned char)uchar;
+ (instancetype)numberWithUnsignedChar: (unsigned char)uChar;
/*!
* @brief Creates a new OFNumber with the specified unsigned short.
*
* @param ushort An unsigned short which the OFNumber should contain
* @param uShort An unsigned short which the OFNumber should contain
* @return A new autoreleased OFNumber
*/
+ (instancetype)numberWithUnsignedShort: (unsigned short)ushort;
+ (instancetype)numberWithUnsignedShort: (unsigned short)uShort;
/*!
* @brief Creates a new OFNumber with the specified unsigned int.
*
* @param uint An unsigned int which the OFNumber should contain
* @param uInt An unsigned int which the OFNumber should contain
* @return A new autoreleased OFNumber
*/
+ (instancetype)numberWithUnsignedInt: (unsigned int)uint;
+ (instancetype)numberWithUnsignedInt: (unsigned int)uInt;
/*!
* @brief Creates a new OFNumber with the specified unsigned long.
*
* @param ulong An unsigned long which the OFNumber should contain
* @param uLong An unsigned long which the OFNumber should contain
* @return A new autoreleased OFNumber
*/
+ (instancetype)numberWithUnsignedLong: (unsigned long)ulong;
+ (instancetype)numberWithUnsignedLong: (unsigned long)uLong;
/*!
* @brief Creates a new OFNumber with the specified unsigned long long.
*
* @param ulonglong An unsigned long long which the OFNumber should contain
* @param uLongLong An unsigned long long which the OFNumber should contain
* @return A new autoreleased OFNumber
*/
+ (instancetype)numberWithUnsignedLongLong: (unsigned long long)ulonglong;
+ (instancetype)numberWithUnsignedLongLong: (unsigned long long)uLongLong;
/*!
* @brief Creates a new OFNumber with the specified int8_t.
*
* @param int8 An int8_t which the OFNumber should contain
* @return A new autoreleased OFNumber
*/
|
︙ | | |
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
|
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
|
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
|
* @return A new autoreleased OFNumber
*/
+ (instancetype)numberWithInt64: (int64_t)int64;
/*!
* @brief Creates a new OFNumber with the specified uint8_t.
*
* @param uint8 A uint8_t which the OFNumber should contain
* @param uInt8 A uint8_t which the OFNumber should contain
* @return A new autoreleased OFNumber
*/
+ (instancetype)numberWithUInt8: (uint8_t)uint8;
+ (instancetype)numberWithUInt8: (uint8_t)uInt8;
/*!
* @brief Creates a new OFNumber with the specified uint16_t.
*
* @param uint16 A uint16_t which the OFNumber should contain
* @param uInt16 A uint16_t which the OFNumber should contain
* @return A new autoreleased OFNumber
*/
+ (instancetype)numberWithUInt16: (uint16_t)uint16;
+ (instancetype)numberWithUInt16: (uint16_t)uInt16;
/*!
* @brief Creates a new OFNumber with the specified uint32_t.
*
* @param uint32 A uint32_t which the OFNumber should contain
* @param uInt32 A uint32_t which the OFNumber should contain
* @return A new autoreleased OFNumber
*/
+ (instancetype)numberWithUInt32: (uint32_t)uint32;
+ (instancetype)numberWithUInt32: (uint32_t)uInt32;
/*!
* @brief Creates a new OFNumber with the specified uint64_t.
*
* @param uint64 A uint64_t which the OFNumber should contain
* @param uInt64 A uint64_t which the OFNumber should contain
* @return A new autoreleased OFNumber
*/
+ (instancetype)numberWithUInt64: (uint64_t)uint64;
+ (instancetype)numberWithUInt64: (uint64_t)uInt64;
/*!
* @brief Creates a new OFNumber with the specified size_t.
*
* @param size A size_t which the OFNumber should contain
* @return A new autoreleased OFNumber
*/
+ (instancetype)numberWithSize: (size_t)size;
/*!
* @brief Creates a new OFNumber with the specified ssize_t.
*
* @param ssize An ssize_t which the OFNumber should contain
* @param sSize An ssize_t which the OFNumber should contain
* @return A new autoreleased OFNumber
*/
+ (instancetype)numberWithSSize: (ssize_t)ssize;
+ (instancetype)numberWithSSize: (ssize_t)sSize;
/*!
* @brief Creates a new OFNumber with the specified intmax_t.
*
* @param intmax An intmax_t which the OFNumber should contain
* @param intMax An intmax_t which the OFNumber should contain
* @return A new autoreleased OFNumber
*/
+ (instancetype)numberWithIntMax: (intmax_t)intmax;
+ (instancetype)numberWithIntMax: (intmax_t)intMax;
/*!
* @brief Creates a new OFNumber with the specified uintmax_t.
*
* @param uintmax A uintmax_t which the OFNumber should contain
* @param uIntMax A uintmax_t which the OFNumber should contain
* @return A new autoreleased OFNumber
*/
+ (instancetype)numberWithUIntMax: (uintmax_t)uintmax;
+ (instancetype)numberWithUIntMax: (uintmax_t)uIntMax;
/*!
* @brief Creates a new OFNumber with the specified ptrdiff_t.
*
* @param ptrdiff A ptrdiff_t which the OFNumber should contain
* @param ptrDiff A ptrdiff_t which the OFNumber should contain
* @return A new autoreleased OFNumber
*/
+ (instancetype)numberWithPtrDiff: (ptrdiff_t)ptrdiff;
+ (instancetype)numberWithPtrDiff: (ptrdiff_t)ptrDiff;
/*!
* @brief Creates a new OFNumber with the specified intptr_t.
*
* @param intptr An intptr_t which the OFNumber should contain
* @param intPtr An intptr_t which the OFNumber should contain
* @return A new autoreleased OFNumber
*/
+ (instancetype)numberWithIntPtr: (intptr_t)intptr;
+ (instancetype)numberWithIntPtr: (intptr_t)intPtr;
/*!
* @brief Creates a new OFNumber with the specified uintptr_t.
*
* @param uintptr A uintptr_t which the OFNumber should contain
* @param uIntPtr A uintptr_t which the OFNumber should contain
* @return A new autoreleased OFNumber
*/
+ (instancetype)numberWithUIntPtr: (uintptr_t)uintptr;
+ (instancetype)numberWithUIntPtr: (uintptr_t)uIntPtr;
/*!
* @brief Creates a new OFNumber with the specified float.
*
* @param float_ A float which the OFNumber should contain
* @return A new autoreleased OFNumber
*/
|
︙ | | |
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
|
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
|
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
|
*/
- (instancetype)initWithBool: (bool)bool_;
/*!
* @brief Initializes an already allocated OFNumber with the specified signed
* char.
*
* @param schar A signed char which the OFNumber should contain
* @param sChar A signed char which the OFNumber should contain
* @return An initialized OFNumber
*/
- (instancetype)initWithChar: (signed char)schar;
- (instancetype)initWithChar: (signed char)sChar;
/*!
* @brief Initializes an already allocated OFNumber with the specified signed
* short.
*
* @param sshort A signed short which the OFNumber should contain
* @param sShort A signed short which the OFNumber should contain
* @return An initialized OFNumber
*/
- (instancetype)initWithShort: (signed short)sshort;
- (instancetype)initWithShort: (signed short)sShort;
/*!
* @brief Initializes an already allocated OFNumber with the specified signed
* int.
*
* @param sint A signed int which the OFNumber should contain
* @param sInt A signed int which the OFNumber should contain
* @return An initialized OFNumber
*/
- (instancetype)initWithInt: (signed int)sint;
- (instancetype)initWithInt: (signed int)sInt;
/*!
* @brief Initializes an already allocated OFNumber with the specified signed
* long.
*
* @param slong A signed long which the OFNumber should contain
* @param sLong A signed long which the OFNumber should contain
* @return An initialized OFNumber
*/
- (instancetype)initWithLong: (signed long)slong;
- (instancetype)initWithLong: (signed long)sLong;
/*!
* @brief Initializes an already allocated OFNumber with the specified signed
* long long.
*
* @param slonglong A signed long long which the OFNumber should contain
* @param sLongLong A signed long long which the OFNumber should contain
* @return An initialized OFNumber
*/
- (instancetype)initWithLongLong: (signed long long)slonglong;
- (instancetype)initWithLongLong: (signed long long)sLongLong;
/*!
* @brief Initializes an already allocated OFNumber with the specified unsigned
* char.
*
* @param uchar An unsigned char which the OFNumber should contain
* @param uChar An unsigned char which the OFNumber should contain
* @return An initialized OFNumber
*/
- (instancetype)initWithUnsignedChar: (unsigned char)uchar;
- (instancetype)initWithUnsignedChar: (unsigned char)uChar;
/*!
* @brief Initializes an already allocated OFNumber with the specified unsigned
* short.
*
* @param ushort An unsigned short which the OFNumber should contain
* @param uShort An unsigned short which the OFNumber should contain
* @return An initialized OFNumber
*/
- (instancetype)initWithUnsignedShort: (unsigned short)ushort;
- (instancetype)initWithUnsignedShort: (unsigned short)uShort;
/*!
* @brief Initializes an already allocated OFNumber with the specified unsigned
* int.
*
* @param uint An unsigned int which the OFNumber should contain
* @param uInt An unsigned int which the OFNumber should contain
* @return An initialized OFNumber
*/
- (instancetype)initWithUnsignedInt: (unsigned int)uint;
- (instancetype)initWithUnsignedInt: (unsigned int)uInt;
/*!
* @brief Initializes an already allocated OFNumber with the specified unsigned
* long.
*
* @param ulong An unsigned long which the OFNumber should contain
* @param uLong An unsigned long which the OFNumber should contain
* @return An initialized OFNumber
*/
- (instancetype)initWithUnsignedLong: (unsigned long)ulong;
- (instancetype)initWithUnsignedLong: (unsigned long)uLong;
/*!
* @brief Initializes an already allocated OFNumber with the specified unsigned
* long long.
*
* @param ulonglong An unsigned long long which the OFNumber should contain
* @param uLongLong An unsigned long long which the OFNumber should contain
* @return An initialized OFNumber
*/
- (instancetype)initWithUnsignedLongLong: (unsigned long long)ulonglong;
- (instancetype)initWithUnsignedLongLong: (unsigned long long)uLongLong;
/*!
* @brief Initializes an already allocated OFNumber with the specified int8_t.
*
* @param int8 An int8_t which the OFNumber should contain
* @return An initialized OFNumber
*/
|
︙ | | |
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
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
|
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
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
|
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
|
* @return An initialized OFNumber
*/
- (instancetype)initWithInt64: (int64_t)int64;
/*!
* @brief Initializes an already allocated OFNumber with the specified uint8_t.
*
* @param uint8 A uint8_t which the OFNumber should contain
* @param uInt8 A uint8_t which the OFNumber should contain
* @return An initialized OFNumber
*/
- (instancetype)initWithUInt8: (uint8_t)uint8;
- (instancetype)initWithUInt8: (uint8_t)uInt8;
/*!
* @brief Initializes an already allocated OFNumber with the specified uint16_t.
*
* @param uint16 A uint16_t which the OFNumber should contain
* @param uInt16 A uint16_t which the OFNumber should contain
* @return An initialized OFNumber
*/
- (instancetype)initWithUInt16: (uint16_t)uint16;
- (instancetype)initWithUInt16: (uint16_t)uInt16;
/*!
* @brief Initializes an already allocated OFNumber with the specified uint32_t.
*
* @param uint32 A uint32_t which the OFNumber should contain
* @param uInt32 A uint32_t which the OFNumber should contain
* @return An initialized OFNumber
*/
- (instancetype)initWithUInt32: (uint32_t)uint32;
- (instancetype)initWithUInt32: (uint32_t)uInt32;
/*!
* @brief Initializes an already allocated OFNumber with the specified uint64_t.
*
* @param uint64 A uint64_t which the OFNumber should contain
* @param uInt64 A uint64_t which the OFNumber should contain
* @return An initialized OFNumber
*/
- (instancetype)initWithUInt64: (uint64_t)uint64;
- (instancetype)initWithUInt64: (uint64_t)uInt64;
/*!
* @brief Initializes an already allocated OFNumber with the specified size_t.
*
* @param size A size_t which the OFNumber should contain
* @return An initialized OFNumber
*/
- (instancetype)initWithSize: (size_t)size;
/*!
* @brief Initializes an already allocated OFNumber with the specified ssize_t.
*
* @param ssize An ssize_t which the OFNumber should contain
* @param sSize An ssize_t which the OFNumber should contain
* @return An initialized OFNumber
*/
- (instancetype)initWithSSize: (ssize_t)ssize;
- (instancetype)initWithSSize: (ssize_t)sSize;
/*!
* @brief Initializes an already allocated OFNumber with the specified intmax_t.
*
* @param intmax An intmax_t which the OFNumber should contain
* @param intMax An intmax_t which the OFNumber should contain
* @return An initialized OFNumber
*/
- (instancetype)initWithIntMax: (intmax_t)intmax;
- (instancetype)initWithIntMax: (intmax_t)intMax;
/*!
* @brief Initializes an already allocated OFNumber with the specified
* uintmax_t.
*
* @param uintmax A uintmax_t which the OFNumber should contain
* @param uIntMax A uintmax_t which the OFNumber should contain
* @return An initialized OFNumber
*/
- (instancetype)initWithUIntMax: (uintmax_t)uintmax;
- (instancetype)initWithUIntMax: (uintmax_t)uIntMax;
/*!
* @brief Initializes an already allocated OFNumber with the specified
* ptrdiff_t.
*
* @param ptrdiff A ptrdiff_t which the OFNumber should contain
* @param ptrDiff A ptrdiff_t which the OFNumber should contain
* @return An initialized OFNumber
*/
- (instancetype)initWithPtrDiff: (ptrdiff_t)ptrdiff;
- (instancetype)initWithPtrDiff: (ptrdiff_t)ptrDiff;
/*!
* @brief Initializes an already allocated OFNumber with the specified intptr_t.
*
* @param intptr An intptr_t which the OFNumber should contain
* @param intPtr An intptr_t which the OFNumber should contain
* @return An initialized OFNumber
*/
- (instancetype)initWithIntPtr: (intptr_t)intptr;
- (instancetype)initWithIntPtr: (intptr_t)intPtr;
/*!
* @brief Initializes an already allocated OFNumber with the specified
* uintptr_t.
*
* @param uintptr A uintptr_t which the OFNumber should contain
* @param uIntPtr A uintptr_t which the OFNumber should contain
* @return An initialized OFNumber
*/
- (instancetype)initWithUIntPtr: (uintptr_t)uintptr;
- (instancetype)initWithUIntPtr: (uintptr_t)uIntPtr;
/*!
* @brief Initializes an already allocated OFNumber with the specified float.
*
* @param float_ A float which the OFNumber should contain
* @return An initialized OFNumber
*/
|
︙ | | |
Modified src/OFNumber.m
from [2a910136b7]
to [c650f7deea].
︙ | | |
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
|
#import "OFOutOfRangeException.h"
#define RETURN_AS(t) \
switch (_type) { \
case OF_NUMBER_TYPE_BOOL: \
return (t)_value.bool_; \
case OF_NUMBER_TYPE_CHAR: \
return (t)_value.schar; \
return (t)_value.sChar; \
case OF_NUMBER_TYPE_SHORT: \
return (t)_value.sshort; \
return (t)_value.sShort; \
case OF_NUMBER_TYPE_INT: \
return (t)_value.sint; \
return (t)_value.sInt; \
case OF_NUMBER_TYPE_LONG: \
return (t)_value.slong; \
return (t)_value.sLong; \
case OF_NUMBER_TYPE_LONGLONG: \
return (t)_value.slonglong; \
return (t)_value.sLongLong; \
case OF_NUMBER_TYPE_UCHAR: \
return (t)_value.uchar; \
return (t)_value.uChar; \
case OF_NUMBER_TYPE_USHORT: \
return (t)_value.ushort; \
return (t)_value.uShort; \
case OF_NUMBER_TYPE_UINT: \
return (t)_value.uint; \
return (t)_value.uInt; \
case OF_NUMBER_TYPE_ULONG: \
return (t)_value.ulong; \
return (t)_value.uLong; \
case OF_NUMBER_TYPE_ULONGLONG: \
return (t)_value.ulonglong; \
return (t)_value.uLongLong; \
case OF_NUMBER_TYPE_INT8: \
return (t)_value.int8; \
case OF_NUMBER_TYPE_INT16: \
return (t)_value.int16; \
case OF_NUMBER_TYPE_INT32: \
return (t)_value.int32; \
case OF_NUMBER_TYPE_INT64: \
return (t)_value.int64; \
case OF_NUMBER_TYPE_UINT8: \
return (t)_value.uint8; \
return (t)_value.uInt8; \
case OF_NUMBER_TYPE_UINT16: \
return (t)_value.uint16; \
return (t)_value.uInt16; \
case OF_NUMBER_TYPE_UINT32: \
return (t)_value.uint32; \
return (t)_value.uInt32; \
case OF_NUMBER_TYPE_UINT64: \
return (t)_value.uint64; \
return (t)_value.uInt64; \
case OF_NUMBER_TYPE_SIZE: \
return (t)_value.size; \
case OF_NUMBER_TYPE_SSIZE: \
return (t)_value.ssize; \
return (t)_value.sSize; \
case OF_NUMBER_TYPE_INTMAX: \
return (t)_value.intmax; \
return (t)_value.intMax; \
case OF_NUMBER_TYPE_UINTMAX: \
return (t)_value.uintmax; \
return (t)_value.uIntMax; \
case OF_NUMBER_TYPE_PTRDIFF: \
return (t)_value.ptrdiff; \
return (t)_value.ptrDiff; \
case OF_NUMBER_TYPE_INTPTR: \
return (t)_value.intptr; \
return (t)_value.intPtr; \
case OF_NUMBER_TYPE_UINTPTR: \
return (t)_value.uintptr; \
return (t)_value.uIntPtr; \
case OF_NUMBER_TYPE_FLOAT: \
return (t)_value.float_; \
case OF_NUMBER_TYPE_DOUBLE: \
return (t)_value.double_; \
default: \
@throw [OFInvalidFormatException exception]; \
}
|
︙ | | |
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
|
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
|
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
|
@synthesize type = _type;
+ (instancetype)numberWithBool: (bool)bool_
{
return [[[self alloc] initWithBool: bool_] autorelease];
}
+ (instancetype)numberWithChar: (signed char)schar
+ (instancetype)numberWithChar: (signed char)sChar
{
return [[[self alloc] initWithChar: schar] autorelease];
return [[[self alloc] initWithChar: sChar] autorelease];
}
+ (instancetype)numberWithShort: (signed short)sshort
+ (instancetype)numberWithShort: (signed short)sShort
{
return [[[self alloc] initWithShort: sshort] autorelease];
return [[[self alloc] initWithShort: sShort] autorelease];
}
+ (instancetype)numberWithInt: (signed int)sint
+ (instancetype)numberWithInt: (signed int)sInt
{
return [[[self alloc] initWithInt: sint] autorelease];
return [[[self alloc] initWithInt: sInt] autorelease];
}
+ (instancetype)numberWithLong: (signed long)slong
+ (instancetype)numberWithLong: (signed long)sLong
{
return [[[self alloc] initWithLong: slong] autorelease];
return [[[self alloc] initWithLong: sLong] autorelease];
}
+ (instancetype)numberWithLongLong: (signed long long)slonglong
+ (instancetype)numberWithLongLong: (signed long long)sLongLong
{
return [[[self alloc] initWithLongLong: slonglong] autorelease];
return [[[self alloc] initWithLongLong: sLongLong] autorelease];
}
+ (instancetype)numberWithUnsignedChar: (unsigned char)uchar
+ (instancetype)numberWithUnsignedChar: (unsigned char)uChar
{
return [[[self alloc] initWithUnsignedChar: uchar] autorelease];
return [[[self alloc] initWithUnsignedChar: uChar] autorelease];
}
+ (instancetype)numberWithUnsignedShort: (unsigned short)ushort
+ (instancetype)numberWithUnsignedShort: (unsigned short)uShort
{
return [[[self alloc] initWithUnsignedShort: ushort] autorelease];
return [[[self alloc] initWithUnsignedShort: uShort] autorelease];
}
+ (instancetype)numberWithUnsignedInt: (unsigned int)uint
+ (instancetype)numberWithUnsignedInt: (unsigned int)uInt
{
return [[[self alloc] initWithUnsignedInt: uint] autorelease];
return [[[self alloc] initWithUnsignedInt: uInt] autorelease];
}
+ (instancetype)numberWithUnsignedLong: (unsigned long)ulong
+ (instancetype)numberWithUnsignedLong: (unsigned long)uLong
{
return [[[self alloc] initWithUnsignedLong: ulong] autorelease];
return [[[self alloc] initWithUnsignedLong: uLong] autorelease];
}
+ (instancetype)numberWithUnsignedLongLong: (unsigned long long)ulonglong
+ (instancetype)numberWithUnsignedLongLong: (unsigned long long)uLongLong
{
return [[[self alloc] initWithUnsignedLongLong: ulonglong] autorelease];
return [[[self alloc] initWithUnsignedLongLong: uLongLong] autorelease];
}
+ (instancetype)numberWithInt8: (int8_t)int8
{
return [[[self alloc] initWithInt8: int8] autorelease];
}
|
︙ | | |
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
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
|
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
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
|
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
|
}
+ (instancetype)numberWithInt64: (int64_t)int64
{
return [[[self alloc] initWithInt64: int64] autorelease];
}
+ (instancetype)numberWithUInt8: (uint8_t)uint8
+ (instancetype)numberWithUInt8: (uint8_t)uInt8
{
return [[[self alloc] initWithUInt8: uint8] autorelease];
return [[[self alloc] initWithUInt8: uInt8] autorelease];
}
+ (instancetype)numberWithUInt16: (uint16_t)uint16
+ (instancetype)numberWithUInt16: (uint16_t)uInt16
{
return [[[self alloc] initWithUInt16: uint16] autorelease];
return [[[self alloc] initWithUInt16: uInt16] autorelease];
}
+ (instancetype)numberWithUInt32: (uint32_t)uint32
+ (instancetype)numberWithUInt32: (uint32_t)uInt32
{
return [[[self alloc] initWithUInt32: uint32] autorelease];
return [[[self alloc] initWithUInt32: uInt32] autorelease];
}
+ (instancetype)numberWithUInt64: (uint64_t)uint64
+ (instancetype)numberWithUInt64: (uint64_t)uInt64
{
return [[[self alloc] initWithUInt64: uint64] autorelease];
return [[[self alloc] initWithUInt64: uInt64] autorelease];
}
+ (instancetype)numberWithSize: (size_t)size
{
return [[[self alloc] initWithSize: size] autorelease];
}
+ (instancetype)numberWithSSize: (ssize_t)ssize
+ (instancetype)numberWithSSize: (ssize_t)sSize
{
return [[[self alloc] initWithSSize: ssize] autorelease];
return [[[self alloc] initWithSSize: sSize] autorelease];
}
+ (instancetype)numberWithIntMax: (intmax_t)intmax
+ (instancetype)numberWithIntMax: (intmax_t)intMax
{
return [[[self alloc] initWithIntMax: intmax] autorelease];
return [[[self alloc] initWithIntMax: intMax] autorelease];
}
+ (instancetype)numberWithUIntMax: (uintmax_t)uintmax
+ (instancetype)numberWithUIntMax: (uintmax_t)uIntMax
{
return [[[self alloc] initWithUIntMax: uintmax] autorelease];
return [[[self alloc] initWithUIntMax: uIntMax] autorelease];
}
+ (instancetype)numberWithPtrDiff: (ptrdiff_t)ptrdiff
+ (instancetype)numberWithPtrDiff: (ptrdiff_t)ptrDiff
{
return [[[self alloc] initWithPtrDiff: ptrdiff] autorelease];
return [[[self alloc] initWithPtrDiff: ptrDiff] autorelease];
}
+ (instancetype)numberWithIntPtr: (intptr_t)intptr
+ (instancetype)numberWithIntPtr: (intptr_t)intPtr
{
return [[[self alloc] initWithIntPtr: intptr] autorelease];
return [[[self alloc] initWithIntPtr: intPtr] autorelease];
}
+ (instancetype)numberWithUIntPtr: (uintptr_t)uintptr
+ (instancetype)numberWithUIntPtr: (uintptr_t)uIntPtr
{
return [[[self alloc] initWithUIntPtr: uintptr] autorelease];
return [[[self alloc] initWithUIntPtr: uIntPtr] autorelease];
}
+ (instancetype)numberWithFloat: (float)float_
{
return [[[self alloc] initWithFloat: float_] autorelease];
}
|
︙ | | |
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
|
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
|
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
|
_value.bool_ = bool_;
_type = OF_NUMBER_TYPE_BOOL;
return self;
}
- (instancetype)initWithChar: (signed char)schar
- (instancetype)initWithChar: (signed char)sChar
{
self = [super init];
_value.schar = schar;
_value.sChar = sChar;
_type = OF_NUMBER_TYPE_CHAR;
return self;
}
- (instancetype)initWithShort: (signed short)sshort
- (instancetype)initWithShort: (signed short)sShort
{
self = [super init];
_value.sshort = sshort;
_value.sShort = sShort;
_type = OF_NUMBER_TYPE_SHORT;
return self;
}
- (instancetype)initWithInt: (signed int)sint
- (instancetype)initWithInt: (signed int)sInt
{
self = [super init];
_value.sint = sint;
_value.sInt = sInt;
_type = OF_NUMBER_TYPE_INT;
return self;
}
- (instancetype)initWithLong: (signed long)slong
- (instancetype)initWithLong: (signed long)sLong
{
self = [super init];
_value.slong = slong;
_value.sLong = sLong;
_type = OF_NUMBER_TYPE_LONG;
return self;
}
- (instancetype)initWithLongLong: (signed long long)slonglong
- (instancetype)initWithLongLong: (signed long long)sLongLong
{
self = [super init];
_value.slonglong = slonglong;
_value.sLongLong = sLongLong;
_type = OF_NUMBER_TYPE_LONGLONG;
return self;
}
- (instancetype)initWithUnsignedChar: (unsigned char)uchar
- (instancetype)initWithUnsignedChar: (unsigned char)uChar
{
self = [super init];
_value.uchar = uchar;
_value.uChar = uChar;
_type = OF_NUMBER_TYPE_UCHAR;
return self;
}
- (instancetype)initWithUnsignedShort: (unsigned short)ushort
- (instancetype)initWithUnsignedShort: (unsigned short)uShort
{
self = [super init];
_value.ushort = ushort;
_value.uShort = uShort;
_type = OF_NUMBER_TYPE_USHORT;
return self;
}
- (instancetype)initWithUnsignedInt: (unsigned int)uint
- (instancetype)initWithUnsignedInt: (unsigned int)uInt
{
self = [super init];
_value.uint = uint;
_value.uInt = uInt;
_type = OF_NUMBER_TYPE_UINT;
return self;
}
- (instancetype)initWithUnsignedLong: (unsigned long)ulong
- (instancetype)initWithUnsignedLong: (unsigned long)uLong
{
self = [super init];
_value.ulong = ulong;
_value.uLong = uLong;
_type = OF_NUMBER_TYPE_ULONG;
return self;
}
- (instancetype)initWithUnsignedLongLong: (unsigned long long)ulonglong
- (instancetype)initWithUnsignedLongLong: (unsigned long long)uLongLong
{
self = [super init];
_value.ulonglong = ulonglong;
_value.uLongLong = uLongLong;
_type = OF_NUMBER_TYPE_ULONGLONG;
return self;
}
- (instancetype)initWithInt8: (int8_t)int8
{
|
︙ | | |
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
|
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
|
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
|
_value.int64 = int64;
_type = OF_NUMBER_TYPE_INT64;
return self;
}
- (instancetype)initWithUInt8: (uint8_t)uint8
- (instancetype)initWithUInt8: (uint8_t)uInt8
{
self = [super init];
_value.uint8 = uint8;
_value.uInt8 = uInt8;
_type = OF_NUMBER_TYPE_UINT8;
return self;
}
- (instancetype)initWithUInt16: (uint16_t)uint16
- (instancetype)initWithUInt16: (uint16_t)uInt16
{
self = [super init];
_value.uint16 = uint16;
_value.uInt16 = uInt16;
_type = OF_NUMBER_TYPE_UINT16;
return self;
}
- (instancetype)initWithUInt32: (uint32_t)uint32
- (instancetype)initWithUInt32: (uint32_t)uInt32
{
self = [super init];
_value.uint32 = uint32;
_value.uInt32 = uInt32;
_type = OF_NUMBER_TYPE_UINT32;
return self;
}
- (instancetype)initWithUInt64: (uint64_t)uint64
- (instancetype)initWithUInt64: (uint64_t)uInt64
{
self = [super init];
_value.uint64 = uint64;
_value.uInt64 = uInt64;
_type = OF_NUMBER_TYPE_UINT64;
return self;
}
- (instancetype)initWithSize: (size_t)size
{
self = [super init];
_value.size = size;
_type = OF_NUMBER_TYPE_SIZE;
return self;
}
- (instancetype)initWithSSize: (ssize_t)ssize
- (instancetype)initWithSSize: (ssize_t)sSize
{
self = [super init];
_value.ssize = ssize;
_value.sSize = sSize;
_type = OF_NUMBER_TYPE_SSIZE;
return self;
}
- (instancetype)initWithIntMax: (intmax_t)intmax
- (instancetype)initWithIntMax: (intmax_t)intMax
{
self = [super init];
_value.intmax = intmax;
_value.intMax = intMax;
_type = OF_NUMBER_TYPE_INTMAX;
return self;
}
- (instancetype)initWithUIntMax: (uintmax_t)uintmax
- (instancetype)initWithUIntMax: (uintmax_t)uIntMax
{
self = [super init];
_value.uintmax = uintmax;
_value.uIntMax = uIntMax;
_type = OF_NUMBER_TYPE_UINTMAX;
return self;
}
- (instancetype)initWithPtrDiff: (ptrdiff_t)ptrdiff
- (instancetype)initWithPtrDiff: (ptrdiff_t)ptrDiff
{
self = [super init];
_value.ptrdiff = ptrdiff;
_value.ptrDiff = ptrDiff;
_type = OF_NUMBER_TYPE_PTRDIFF;
return self;
}
- (instancetype)initWithIntPtr: (intptr_t)intptr
- (instancetype)initWithIntPtr: (intptr_t)intPtr
{
self = [super init];
_value.intptr = intptr;
_value.intPtr = intPtr;
_type = OF_NUMBER_TYPE_INTPTR;
return self;
}
- (instancetype)initWithUIntPtr: (uintptr_t)uintptr
- (instancetype)initWithUIntPtr: (uintptr_t)uIntPtr
{
self = [super init];
_value.uintptr = uintptr;
_value.uIntPtr = uIntPtr;
_type = OF_NUMBER_TYPE_UINTPTR;
return self;
}
- (instancetype)initWithFloat: (float)float_
{
|
︙ | | |
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
|
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
|
-
+
-
+
|
@throw [OFInvalidArgumentException exception];
} else if ([typeString isEqual: @"unsigned"]) {
/*
* FIXME: This will fail if the value is bigger than
* INTMAX_MAX!
*/
_type = OF_NUMBER_TYPE_UINTMAX;
_value.uintmax = [element decimalValue];
_value.uIntMax = [element decimalValue];
} else if ([typeString isEqual: @"signed"]) {
_type = OF_NUMBER_TYPE_INTMAX;
_value.intmax = [element decimalValue];
_value.intMax = [element decimalValue];
} else if ([typeString isEqual: @"float"]) {
union {
float f;
uint32_t u;
} f;
f.u = OF_BSWAP32_IF_LE(
|
︙ | | |
Modified src/OFRunLoop.m
from [03e94e120d]
to [2a10d90f42].
︙ | | |
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
|
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
|
-
+
-
+
-
+
-
+
|
ADD_READ(OFRunLoop_AcceptQueueItem, stream, {
queueItem->_target = [target retain];
queueItem->_selector = selector;
queueItem->_context = [context retain];
})
}
+ (void)of_addAsyncReceiveForUDPSocket: (OFUDPSocket *)socket
+ (void)of_addAsyncReceiveForUDPSocket: (OFUDPSocket *)sock
buffer: (void *)buffer
length: (size_t)length
target: (id)target
selector: (SEL)selector
context: (id)context
{
ADD_READ(OFRunLoop_UDPReceiveQueueItem, socket, {
ADD_READ(OFRunLoop_UDPReceiveQueueItem, sock, {
queueItem->_target = [target retain];
queueItem->_selector = selector;
queueItem->_context = [context retain];
queueItem->_buffer = buffer;
queueItem->_length = length;
})
}
+ (void)of_addAsyncSendForUDPSocket: (OFUDPSocket *)socket
+ (void)of_addAsyncSendForUDPSocket: (OFUDPSocket *)sock
buffer: (const void *)buffer
length: (size_t)length
receiver: (of_udp_socket_address_t)receiver
target: (id)target
selector: (SEL)selector
context: (id)context
{
ADD_WRITE(OFRunLoop_UDPSendQueueItem, socket, {
ADD_WRITE(OFRunLoop_UDPSendQueueItem, sock, {
queueItem->_target = [target retain];
queueItem->_selector = selector;
queueItem->_context = [context retain];
queueItem->_buffer = buffer;
queueItem->_length = length;
queueItem->_receiver = receiver;
})
|
︙ | | |
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
713
714
715
716
717
718
719
720
721
|
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
713
714
715
716
717
718
719
720
721
|
-
+
-
+
-
+
-
+
|
block: (of_tcp_socket_async_accept_block_t)block
{
ADD_READ(OFRunLoop_AcceptQueueItem, stream, {
queueItem->_block = [block copy];
})
}
+ (void)of_addAsyncReceiveForUDPSocket: (OFUDPSocket *)socket
+ (void)of_addAsyncReceiveForUDPSocket: (OFUDPSocket *)sock
buffer: (void *)buffer
length: (size_t)length
block: (of_udp_socket_async_receive_block_t)
block
{
ADD_READ(OFRunLoop_UDPReceiveQueueItem, socket, {
ADD_READ(OFRunLoop_UDPReceiveQueueItem, sock, {
queueItem->_block = [block copy];
queueItem->_buffer = buffer;
queueItem->_length = length;
})
}
+ (void)of_addAsyncSendForUDPSocket: (OFUDPSocket *)socket
+ (void)of_addAsyncSendForUDPSocket: (OFUDPSocket *)sock
buffer: (const void *)buffer
length: (size_t)length
receiver: (of_udp_socket_address_t)receiver
block: (of_udp_socket_async_send_block_t)block
{
ADD_WRITE(OFRunLoop_UDPSendQueueItem, socket, {
ADD_WRITE(OFRunLoop_UDPSendQueueItem, sock, {
queueItem->_block = [block copy];
queueItem->_buffer = buffer;
queueItem->_length = length;
queueItem->_receiver = receiver;
})
}
# endif
|
︙ | | |
Modified src/OFString.m
from [0cbd68fca6]
to [66df8d1952].
︙ | | |
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
|
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
|
-
+
|
}
- (size_t)UTF8StringLength
{
return [self cStringLengthWithEncoding: OF_STRING_ENCODING_UTF_8];
}
- (of_unichar_t)characterAtIndex: (size_t)index
- (of_unichar_t)characterAtIndex: (size_t)idx
{
OF_UNRECOGNIZED_SELECTOR
}
- (void)getCharacters: (of_unichar_t *)buffer
inRange: (of_range_t)range
{
|
︙ | | |
Modified src/OFString_UTF8.m
from [3425587555]
to [9568261c3b].
︙ | | |
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
|
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
|
-
+
-
+
-
+
-
+
-
+
-
+
-
+
|
return isUTF8;
}
size_t
of_string_utf8_get_index(const char *string, size_t position)
{
size_t index = position;
size_t idx = position;
for (size_t i = 0; i < position; i++)
if OF_UNLIKELY ((string[i] & 0xC0) == 0x80)
index--;
idx--;
return index;
return idx;
}
size_t
of_string_utf8_get_position(const char *string, size_t index, size_t length)
of_string_utf8_get_position(const char *string, size_t idx, size_t length)
{
for (size_t i = 0; i <= index; i++)
for (size_t i = 0; i <= idx; i++)
if OF_UNLIKELY ((string[i] & 0xC0) == 0x80)
if (++index > length)
if (++idx > length)
return OF_NOT_FOUND;
return index;
return idx;
}
@implementation OFString_UTF8
- (instancetype)init
{
self = [super init];
|
︙ | | |
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
|
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
|
-
+
-
+
-
+
-
+
-
-
-
+
+
|
_s->hash = hash;
_s->hashed = true;
return hash;
}
- (of_unichar_t)characterAtIndex: (size_t)index
- (of_unichar_t)characterAtIndex: (size_t)idx
{
of_unichar_t character;
if (index >= _s->length)
if (idx >= _s->length)
@throw [OFOutOfRangeException exception];
if (!_s->isUTF8)
return _s->cString[index];
return _s->cString[idx];
index = of_string_utf8_get_position(_s->cString, index,
idx = of_string_utf8_get_position(_s->cString, idx, _s->cStringLength);
_s->cStringLength);
if (of_string_utf8_decode(_s->cString + index,
_s->cStringLength - index, &character) <= 0)
if (of_string_utf8_decode(_s->cString + idx,
_s->cStringLength - idx, &character) <= 0)
@throw [OFInvalidEncodingException exception];
return character;
}
- (void)getCharacters: (of_unichar_t *)buffer
inRange: (of_range_t)range
|
︙ | | |
Modified src/OFTCPSocket+SOCKS5.m
from [08455d53f4]
to [7ec0dff4e0].
︙ | | |
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
|
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
|
-
+
-
+
-
+
-
+
|
#import "socket_helpers.h"
/* Reference for static linking */
int _OFTCPSocket_SOCKS5_reference;
static void
send_or_exception(OFTCPSocket *self, of_socket_t socket, char *buffer,
send_or_exception(OFTCPSocket *self, of_socket_t sock, char *buffer,
int length)
{
#ifndef OF_WINDOWS
ssize_t bytesWritten;
#else
int bytesWritten;
#endif
if ((bytesWritten = send(socket, (const void *)buffer, length, 0)) < 0)
if ((bytesWritten = send(sock, (const void *)buffer, length, 0)) < 0)
@throw [OFWriteFailedException
exceptionWithObject: self
requestedLength: length
bytesWritten: 0
errNo: of_socket_errno()];
if ((int)bytesWritten != length)
@throw [OFWriteFailedException exceptionWithObject: self
requestedLength: length
bytesWritten: bytesWritten
errNo: 0];
}
static void
recv_exact(OFTCPSocket *self, of_socket_t socket, char *buffer, int length)
recv_exact(OFTCPSocket *self, of_socket_t sock, char *buffer, int length)
{
while (length > 0) {
ssize_t ret = recv(socket, (void *)buffer, length, 0);
ssize_t ret = recv(sock, (void *)buffer, length, 0);
if (ret < 0)
@throw [OFReadFailedException
exceptionWithObject: self
requestedLength: length
errNo: of_socket_errno()];
|
︙ | | |
Modified src/OFTCPSocket.m
from [f8b1b83a89]
to [88cbad652d].
︙ | | |
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
|
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
|
-
+
-
+
-
+
-
+
-
+
-
+
|
# ifdef OF_HAVE_BLOCKS
of_tcp_socket_async_connect_block_t _block;
# endif
id _exception;
}
- (instancetype)initWithSourceThread: (OFThread *)sourceThread
socket: (OFTCPSocket *)socket
socket: (OFTCPSocket *)sock
host: (OFString *)host
port: (uint16_t)port
target: (id)target
selector: (SEL)selector
context: (id)context;
# ifdef OF_HAVE_BLOCKS
- (instancetype)initWithSourceThread: (OFThread *)sourceThread
socket: (OFTCPSocket *)socket
socket: (OFTCPSocket *)sock
host: (OFString *)host
port: (uint16_t)port
block: (of_tcp_socket_async_connect_block_t)
block;
# endif
@end
@implementation OFTCPSocket_ConnectThread
- (instancetype)initWithSourceThread: (OFThread *)sourceThread
socket: (OFTCPSocket *)socket
socket: (OFTCPSocket *)sock
host: (OFString *)host
port: (uint16_t)port
target: (id)target
selector: (SEL)selector
context: (id)context
{
self = [super init];
@try {
_sourceThread = [sourceThread retain];
_socket = [socket retain];
_socket = [sock retain];
_host = [host copy];
_port = port;
_target = [target retain];
_selector = selector;
_context = [context retain];
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
# ifdef OF_HAVE_BLOCKS
- (instancetype)initWithSourceThread: (OFThread *)sourceThread
socket: (OFTCPSocket *)socket
socket: (OFTCPSocket *)sock
host: (OFString *)host
port: (uint16_t)port
block: (of_tcp_socket_async_connect_block_t)block
{
self = [super init];
@try {
_sourceThread = [sourceThread retain];
_socket = [socket retain];
_socket = [sock retain];
_host = [host copy];
_port = port;
_block = [block copy];
} @catch (id e) {
[self release];
@throw e;
}
|
︙ | | |
Modified src/OFTarArchive.m
from [deb3b00a60]
to [72c8a07e42].
︙ | | |
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
|
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
|
+
-
+
+
|
if (_stream == nil)
@throw [OFNotOpenException exceptionWithObject: self];
if (_atEndOfStream)
return 0;
#if SIZE_MAX >= UINT64_MAX
if (sizeof(length) >= sizeof(uint64_t) && length > UINT64_MAX)
if (length > UINT64_MAX)
@throw [OFOutOfRangeException exception];
#endif
if ((uint64_t)length > _toRead)
length = (size_t)_toRead;
ret = [_stream readIntoBuffer: buffer
length: length];
|
︙ | | |
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
|
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
|
-
+
|
_toRead = 0;
}
size = [_entry size];
if (size % 512 != 0)
[_stream readIntoBuffer: buffer
exactLength: 512 - (size % 512)];
exactLength: (size_t)(512 - (size % 512))];
}
}
@end
@implementation OFTarArchive_FileWriteStream
- (instancetype)initWithStream: (OFStream *)stream
entry: (OFTarArchiveEntry *)entry
|
︙ | | |
Modified src/OFTimer.m
from [a3b64a1457]
to [d55afecf6c].
︙ | | |
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
|
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
|
-
+
|
id object2 = [[_object2 retain] autorelease];
id object3 = [[_object3 retain] autorelease];
id object4 = [[_object4 retain] autorelease];
OF_ENSURE(_arguments <= 4);
if (_repeats && _valid) {
int missedIntervals =
int64_t missedIntervals =
-[_fireDate timeIntervalSinceNow] / _interval;
of_time_interval_t newFireDate;
/* In case the clock was changed backwards */
if (missedIntervals < 0)
missedIntervals = 0;
|
︙ | | |
Modified src/OFUDPSocket.m
from [8a3b636da1]
to [488e7d77d9].
︙ | | |
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
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
|
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
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
|
-
+
-
+
-
-
+
+
-
+
-
+
-
-
+
+
-
+
-
-
-
+
+
+
-
+
-
+
-
+
-
-
+
+
-
+
-
+
-
-
+
+
|
@end
#endif
bool
of_udp_socket_address_equal(of_udp_socket_address_t *address1,
of_udp_socket_address_t *address2)
{
struct sockaddr_in *sin_1, *sin_2;
struct sockaddr_in *addrIn1, *addrIn2;
#ifdef HAVE_IPV6
struct sockaddr_in6 *sin6_1, *sin6_2;
struct sockaddr_in6 *addrIn6_1, *addrIn6_2;
#endif
if (address1->address.ss_family != address2->address.ss_family)
return false;
switch (address1->address.ss_family) {
case AF_INET:
#if !defined(OF_WII) && !defined(OF_NINTENDO_3DS)
if (address1->length < (socklen_t)sizeof(struct sockaddr_in) ||
address2->length < (socklen_t)sizeof(struct sockaddr_in))
@throw [OFInvalidArgumentException exception];
#else
if (address1->length < 8 || address2->length < 8)
@throw [OFInvalidArgumentException exception];
#endif
sin_1 = (struct sockaddr_in *)&address1->address;
sin_2 = (struct sockaddr_in *)&address2->address;
addrIn1 = (struct sockaddr_in *)&address1->address;
addrIn2 = (struct sockaddr_in *)&address2->address;
if (sin_1->sin_port != sin_2->sin_port)
if (addrIn1->sin_port != addrIn2->sin_port)
return false;
if (sin_1->sin_addr.s_addr != sin_2->sin_addr.s_addr)
if (addrIn1->sin_addr.s_addr != addrIn2->sin_addr.s_addr)
return false;
break;
#ifdef HAVE_IPV6
case AF_INET6:
if (address1->length < sizeof(struct sockaddr_in6) ||
address2->length < sizeof(struct sockaddr_in6))
@throw [OFInvalidArgumentException exception];
sin6_1 = (struct sockaddr_in6 *)&address1->address;
sin6_2 = (struct sockaddr_in6 *)&address2->address;
addrIn6_1 = (struct sockaddr_in6 *)&address1->address;
addrIn6_2 = (struct sockaddr_in6 *)&address2->address;
if (sin6_1->sin6_port != sin6_2->sin6_port)
if (addrIn6_1->sin6_port != addrIn6_2->sin6_port)
return false;
if (memcmp(sin6_1->sin6_addr.s6_addr,
sin6_2->sin6_addr.s6_addr,
sizeof(sin6_1->sin6_addr.s6_addr)) != 0)
if (memcmp(addrIn6_1->sin6_addr.s6_addr,
addrIn6_2->sin6_addr.s6_addr,
sizeof(addrIn6_1->sin6_addr.s6_addr)) != 0)
return false;
break;
#endif
default:
@throw [OFInvalidArgumentException exception];
}
return true;
}
uint32_t
of_udp_socket_address_hash(of_udp_socket_address_t *address)
{
uint32_t hash = of_hash_seed;
struct sockaddr_in *sin;
struct sockaddr_in *addrIn;
#ifdef HAVE_IPV6
struct sockaddr_in6 *sin6;
struct sockaddr_in6 *addrIn6;
uint32_t subhash;
#endif
hash += address->address.ss_family;
switch (address->address.ss_family) {
case AF_INET:
#if !defined(OF_WII) && !defined(OF_NINTENDO_3DS)
if (address->length < (socklen_t)sizeof(struct sockaddr_in))
@throw [OFInvalidArgumentException exception];
#else
if (address->length < 8)
@throw [OFInvalidArgumentException exception];
#endif
sin = (struct sockaddr_in *)&address->address;
addrIn = (struct sockaddr_in *)&address->address;
hash += (sin->sin_port << 1);
hash ^= sin->sin_addr.s_addr;
hash += (addrIn->sin_port << 1);
hash ^= addrIn->sin_addr.s_addr;
break;
#ifdef HAVE_IPV6
case AF_INET6:
if (address->length < sizeof(struct sockaddr_in6))
@throw [OFInvalidArgumentException exception];
sin6 = (struct sockaddr_in6 *)&address->address;
addrIn6 = (struct sockaddr_in6 *)&address->address;
hash += (sin6->sin6_port << 1);
hash += (addrIn6->sin6_port << 1);
OF_HASH_INIT(subhash);
for (size_t i = 0; i < sizeof(sin6->sin6_addr.s6_addr); i++)
OF_HASH_ADD(subhash, sin6->sin6_addr.s6_addr[i]);
for (size_t i = 0; i < sizeof(addrIn6->sin6_addr.s6_addr); i++)
OF_HASH_ADD(subhash, adrIn6->sin6_addr.s6_addr[i]);
OF_HASH_FINALIZE(subhash);
hash ^= subhash;
break;
#endif
|
︙ | | |
Modified src/OFXMLElement.m
from [ac132aa128]
to [e09b35486d].
︙ | | |
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
913
914
915
916
917
918
919
920
921
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
|
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
913
914
915
916
917
918
919
920
921
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
|
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
|
if (_children == nil)
_children = [[OFMutableArray alloc] init];
[_children addObject: child];
}
- (void)insertChild: (OFXMLNode *)child
atIndex: (size_t)index
atIndex: (size_t)idx
{
if ([child isKindOfClass: [OFXMLAttribute class]])
@throw [OFInvalidArgumentException exception];
if (_children == nil)
_children = [[OFMutableArray alloc] init];
[_children insertObject: child
atIndex: index];
atIndex: idx];
}
- (void)insertChildren: (OFArray *)children
atIndex: (size_t)index
atIndex: (size_t)idx
{
for (OFXMLNode *node in children)
if ([node isKindOfClass: [OFXMLAttribute class]])
@throw [OFInvalidArgumentException exception];
[_children insertObjectsFromArray: children
atIndex: index];
atIndex: idx];
}
- (void)removeChild: (OFXMLNode *)child
{
if ([child isKindOfClass: [OFXMLAttribute class]])
@throw [OFInvalidArgumentException exception];
[_children removeObject: child];
}
- (void)removeChildAtIndex: (size_t)index
- (void)removeChildAtIndex: (size_t)idx
{
[_children removeObjectAtIndex: index];
[_children removeObjectAtIndex: idx];
}
- (void)replaceChild: (OFXMLNode *)child
withNode: (OFXMLNode *)node
{
if ([node isKindOfClass: [OFXMLAttribute class]] ||
[child isKindOfClass: [OFXMLAttribute class]])
@throw [OFInvalidArgumentException exception];
[_children replaceObject: child
withObject: node];
}
- (void)replaceChildAtIndex: (size_t)index
- (void)replaceChildAtIndex: (size_t)idx
withNode: (OFXMLNode *)node
{
if ([node isKindOfClass: [OFXMLAttribute class]])
@throw [OFInvalidArgumentException exception];
[_children replaceObjectAtIndex: index
[_children replaceObjectAtIndex: idx
withObject: node];
}
- (OFXMLElement *)elementForName: (OFString *)elementName
{
return [[self elementsForName: elementName] firstObject];
}
|
︙ | | |
Modified src/OFZIPArchive.m
from [f82daa6eae]
to [f074dafa32].
︙ | | |
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
|
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
|
+
-
+
+
|
if (_stream == nil)
@throw [OFNotOpenException exceptionWithObject: self];
if (_atEndOfStream)
return 0;
#if SIZE_MAX >= UINT64_MAX
if (sizeof(length) >= sizeof(uint64_t) && length > UINT64_MAX)
if (length > UINT64_MAX)
@throw [OFOutOfRangeException exception];
#endif
if ((uint64_t)length > _toRead)
length = (size_t)_toRead;
ret = [_decompressedStream readIntoBuffer: buffer
length: length];
|
︙ | | |
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
|
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
|
+
-
-
+
+
+
+
+
|
}
- (size_t)lowlevelWriteBuffer: (const void *)buffer
length: (size_t)length
{
size_t bytesWritten;
#if SIZE_MAX >= INT64_MAX
if ((sizeof(length) >= sizeof(int64_t) && length > INT64_MAX) ||
INT64_MAX - _bytesWritten < (int64_t)length)
if (length > INT64_MAX)
@throw [OFOutOfRangeException exception];
#endif
if (INT64_MAX - _bytesWritten < (int64_t)length)
@throw [OFOutOfRangeException exception];
bytesWritten = [_stream writeBuffer: buffer
length: length];
_bytesWritten += (int64_t)bytesWritten;
_CRC32 = of_crc32(_CRC32, buffer, length);
|
︙ | | |
Modified src/bridge/NSArray+OFObject.h
from [3236718bb9]
to [af97e776cc].
︙ | | |
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
-
+
-
+
|
* file.
*/
#import <Foundation/NSArray.h>
#import "NSBridging.h"
NS_ASSUME_NONNULL_BEGIN
OF_ASSUME_NONNULL_BEGIN
#ifdef __cplusplus
extern "C" {
#endif
extern int _NSArray_OFObject_reference;
#ifdef __cplusplus
}
#endif
/*!
* @category NSArray (OFObject) \
* NSArray+OFObject.h ObjFW-Bridge/NSArray+OFObject.h
*
* @brief Support for bridging NSArrays to OFArrays.
*/
@interface NSArray (OFObject) <NSBridging>
@end
NS_ASSUME_NONNULL_END
OF_ASSUME_NONNULL_END
|
Modified src/bridge/NSArray_OFArray.h
from [fc39953ec6]
to [2544af2f50].
︙ | | |
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
+
+
-
+
-
+
|
* Public License, either version 2 or 3, which can be found in the file
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
#import <Foundation/NSArray.h>
#import "macros.h"
@class OFArray;
NS_ASSUME_NONNULL_BEGIN
OF_ASSUME_NONNULL_BEGIN
@interface NSArray_OFArray: NSArray
{
OFArray *_array;
}
- (instancetype)initWithOFArray: (OFArray *)array;
@end
NS_ASSUME_NONNULL_END
OF_ASSUME_NONNULL_END
|
Modified src/bridge/NSArray_OFArray.m
from [92d6803c52]
to [24e48bd9b8].
︙ | | |
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
-
+
-
+
|
return nil;
}
}
return self;
}
- (id)objectAtIndex: (NSUInteger)index
- (id)objectAtIndex: (NSUInteger)idx
{
id object = [_array objectAtIndex: index];
id object = [_array objectAtIndex: idx];
if ([(OFObject *)object conformsToProtocol: @protocol(OFBridging)])
return [object NSObject];
return object;
}
|
︙ | | |
Modified src/bridge/NSDictionary+OFObject.h
from [e7ea1a71e3]
to [14c5a862d2].
︙ | | |
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
-
+
-
+
|
* file.
*/
#import <Foundation/NSDictionary.h>
#import "NSBridging.h"
NS_ASSUME_NONNULL_BEGIN
OF_ASSUME_NONNULL_BEGIN
#ifdef __cplusplus
extern "C" {
#endif
extern int _NSDictionary_OFObject_reference;
#ifdef __cplusplus
}
#endif
/*!
* @category NSDictionary (OFObject) \
* NSDictionary+OFObject.h ObjFW-Bridge/NSDictionary+OFObject.h
*
* @brief Support for bridging NSDictionaries to OFDictionaries.
*/
@interface NSDictionary (OFObject) <NSBridging>
@end
NS_ASSUME_NONNULL_END
OF_ASSUME_NONNULL_END
|
Modified src/bridge/NSDictionary_OFDictionary.h
from [bf71dfed62]
to [63518320f8].
︙ | | |
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
+
+
-
+
-
+
|
* Alternatively, it may be distributed under the terms of the GNU General
* Public License, either version 2 or 3, which can be found in the file
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
#import <Foundation/NSDictionary.h>
#import "macros.h"
@class OFDictionary;
NS_ASSUME_NONNULL_BEGIN
OF_ASSUME_NONNULL_BEGIN
@interface NSDictionary_OFDictionary: NSDictionary
{
OFDictionary *_dictionary;
}
- (instancetype)initWithOFDictionary: (OFDictionary *)dictionary;
@end
NS_ASSUME_NONNULL_END
OF_ASSUME_NONNULL_END
|
Modified src/bridge/NSString+OFObject.h
from [8cc6d5774c]
to [fdff56af4e].
︙ | | |
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
-
+
|
* file.
*/
#import <Foundation/NSString.h>
#import "NSBridging.h"
NS_ASSUME_NONNULL_BEGIN
OF_ASSUME_NONNULL_BEGIN
#ifdef __cplusplus
extern "C" {
#endif
extern int _NSString_OFObject_reference;
#ifdef __cplusplus
}
|
︙ | | |
37
38
39
40
41
42
43
44
|
37
38
39
40
41
42
43
44
|
-
+
|
* Unfortunately, they need to be copied, as NSString is not capable of
* handling UCS-4 properly (a character of NSString is only 2 bytes, while a
* character of OFString is 4).
*/
@interface NSString (OFObject) <NSBridging>
@end
NS_ASSUME_NONNULL_END
OF_ASSUME_NONNULL_END
|
Modified src/bridge/OFArray_NSArray.m
from [f4bf332284]
to [fa2dd5e88f].
︙ | | |
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
|
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
|
-
+
-
+
-
+
|
[self release];
@throw e;
}
return self;
}
- (id)objectAtIndex: (size_t)index
- (id)objectAtIndex: (size_t)idx
{
id object;
if (index > NSUIntegerMax)
if (idx > NSUIntegerMax)
@throw [OFOutOfRangeException exception];
object = [_array objectAtIndex: index];
object = [_array objectAtIndex: idx];
if ([(NSObject *)object conformsToProtocol: @protocol(NSBridging)])
return [object OFObject];
return object;
}
- (size_t)count
{
return [_array count];
}
@end
|
Modified src/encodings/codepage_437.m
from [c1aa2005c6]
to [8cf0d5a40f].
︙ | | |
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
|
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
|
-
+
|
of_unicode_to_codepage_437(const of_unichar_t *input, unsigned char *output,
size_t length, bool lossy)
{
for (size_t i = 0; i < length; i++) {
of_unichar_t c = input[i];
if OF_UNLIKELY (c > 0x7F) {
uint8_t index;
uint8_t idx;
if OF_UNLIKELY (c > 0xFFFF) {
if (lossy) {
output[i] = '?';
continue;
} else
return false;
|
︙ | | |
Modified src/encodings/codepage_850.m
from [59298ea7e4]
to [42a9f55d3e].
︙ | | |
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
|
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
|
-
+
|
of_unicode_to_codepage_850(const of_unichar_t *input, unsigned char *output,
size_t length, bool lossy)
{
for (size_t i = 0; i < length; i++) {
of_unichar_t c = input[i];
if OF_UNLIKELY (c > 0x7F) {
uint8_t index;
uint8_t idx;
if OF_UNLIKELY (c > 0xFFFF) {
if (lossy) {
output[i] = '?';
continue;
} else
return false;
|
︙ | | |
Modified src/encodings/codepage_858.m
from [d4ab6dcec9]
to [a1c541d3cd].
︙ | | |
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
|
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
|
-
+
|
of_unicode_to_codepage_858(const of_unichar_t *input, unsigned char *output,
size_t length, bool lossy)
{
for (size_t i = 0; i < length; i++) {
of_unichar_t c = input[i];
if OF_UNLIKELY (c > 0x7F) {
uint8_t index;
uint8_t idx;
if OF_UNLIKELY (c > 0xFFFF) {
if (lossy) {
output[i] = '?';
continue;
} else
return false;
|
︙ | | |
Modified src/encodings/common.h
from [8b3b315d4d]
to [321ef98b23].
︙ | | |
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
-
+
-
+
-
+
-
+
-
+
-
+
-
+
|
#define CASE_MISSING_IS_KEEP(nr) \
case nr: \
if OF_UNLIKELY ((c & 0xFF) < page##nr##Start) { \
output[i] = (unsigned char)c; \
continue; \
} \
\
index = (c & 0xFF) - page##nr##Start; \
idx = (c & 0xFF) - page##nr##Start; \
\
if (index >= sizeof(page##nr)) { \
if (idx >= sizeof(page##nr)) { \
output[i] = (unsigned char)c; \
continue; \
} \
\
if (page##nr[index] == 0x00) { \
if (page##nr[idx] == 0x00) { \
if (lossy) { \
output[i] = '?'; \
continue; \
} else \
return false; \
} \
\
output[i] = page##nr[index]; \
output[i] = page##nr[idx]; \
break;
#define CASE_MISSING_IS_ERROR(nr) \
case 0x##nr: \
if OF_UNLIKELY ((c & 0xFF) < page##nr##Start) { \
if (lossy) { \
output[i] = '?'; \
continue; \
} else \
return false; \
} \
\
index = (c & 0xFF) - page##nr##Start; \
idx = (c & 0xFF) - page##nr##Start; \
\
if (index >= sizeof(page##nr) || page##nr[index] == 0) { \
if (idx >= sizeof(page##nr) || page##nr[idx] == 0) { \
if (lossy) { \
output[i] = '?'; \
continue; \
} else \
return false; \
} \
\
output[i] = page##nr[index]; \
output[i] = page##nr[idx]; \
break;
|
Modified src/encodings/iso_8859-15.m
from [16863c4f02]
to [8f6da128e4].
︙ | | |
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
-
+
|
of_unicode_to_iso_8859_15(const of_unichar_t *input, unsigned char *output,
size_t length, bool lossy)
{
for (size_t i = 0; i < length; i++) {
of_unichar_t c = input[i];
if OF_UNLIKELY (c > 0x7F) {
uint8_t index;
uint8_t idx;
if OF_UNLIKELY (c > 0xFFFF) {
if (lossy) {
output[i] = '?';
continue;
} else
return false;
|
︙ | | |
Modified src/encodings/iso_8859-2.m
from [744cbf950c]
to [de487566d1].
︙ | | |
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
|
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
|
-
+
|
of_unicode_to_iso_8859_2(const of_unichar_t *input, unsigned char *output,
size_t length, bool lossy)
{
for (size_t i = 0; i < length; i++) {
of_unichar_t c = input[i];
if OF_UNLIKELY (c > 0x7F) {
uint8_t index;
uint8_t idx;
if OF_UNLIKELY (c > 0xFFFF) {
if (lossy) {
output[i] = '?';
continue;
} else
return false;
|
︙ | | |
Modified src/encodings/iso_8859-3.m
from [3670e938ce]
to [ca6d9c039c].
︙ | | |
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
-
+
|
of_unicode_to_iso_8859_3(const of_unichar_t *input, unsigned char *output,
size_t length, bool lossy)
{
for (size_t i = 0; i < length; i++) {
of_unichar_t c = input[i];
if OF_UNLIKELY (c > 0x7F) {
uint8_t index;
uint8_t idx;
if OF_UNLIKELY (c > 0xFFFF) {
if (lossy) {
output[i] = '?';
continue;
} else
return false;
|
︙ | | |
Modified src/encodings/koi8-r.m
from [512f05d1ec]
to [e77fc0ad5b].
︙ | | |
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
|
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
|
-
+
|
of_unicode_to_koi8_r(const of_unichar_t *input, unsigned char *output,
size_t length, bool lossy)
{
for (size_t i = 0; i < length; i++) {
of_unichar_t c = input[i];
if OF_UNLIKELY (c > 0x7F) {
uint8_t index;
uint8_t idx;
if OF_UNLIKELY (c > 0xFFFF) {
if (lossy) {
output[i] = '?';
continue;
} else
return false;
|
︙ | | |
Modified src/encodings/koi8-u.m
from [b72abc7c7a]
to [a1d99e8a1a].
︙ | | |
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
|
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
|
-
+
|
of_unicode_to_koi8_u(const of_unichar_t *input, unsigned char *output,
size_t length, bool lossy)
{
for (size_t i = 0; i < length; i++) {
of_unichar_t c = input[i];
if OF_UNLIKELY (c > 0x7F) {
uint8_t index;
uint8_t idx;
if OF_UNLIKELY (c > 0xFFFF) {
if (lossy) {
output[i] = '?';
continue;
} else
return false;
|
︙ | | |
Modified src/encodings/mac_roman.m
from [621b6250aa]
to [c8c7b33ca3].
︙ | | |
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
|
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
|
-
+
|
of_unicode_to_mac_roman(const of_unichar_t *input, unsigned char *output,
size_t length, bool lossy)
{
for (size_t i = 0; i < length; i++) {
of_unichar_t c = input[i];
if OF_UNLIKELY (c > 0x7F) {
uint8_t index;
uint8_t idx;
if OF_UNLIKELY (c > 0xFFFF) {
if (lossy) {
output[i] = '?';
continue;
} else
return false;
|
︙ | | |
Modified src/encodings/windows-1251.m
from [752c057c67]
to [c78eb7b263].
︙ | | |
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
|
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
|
-
+
|
of_unicode_to_windows_1251(const of_unichar_t *input, unsigned char *output,
size_t length, bool lossy)
{
for (size_t i = 0; i < length; i++) {
of_unichar_t c = input[i];
if OF_UNLIKELY (c > 0x7F) {
uint8_t index;
uint8_t idx;
if OF_UNLIKELY (c > 0xFFFF) {
if (lossy) {
output[i] = '?';
continue;
} else
return false;
|
︙ | | |
Modified src/encodings/windows-1252.m
from [8416ceeb47]
to [a7686520cf].
︙ | | |
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
|
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
|
-
+
|
of_unicode_to_windows_1252(const of_unichar_t *input, unsigned char *output,
size_t length, bool lossy)
{
for (size_t i = 0; i < length; i++) {
of_unichar_t c = input[i];
if OF_UNLIKELY (c > 0x7F) {
uint8_t index;
uint8_t idx;
if OF_UNLIKELY (c > 0xFFFF) {
if (lossy) {
output[i] = '?';
continue;
} else
return false;
|
︙ | | |
Modified src/macros.h
from [15e6f8eafc]
to [298ad747ab].
︙ | | |
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
|
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
|
-
+
-
+
-
+
-
+
-
+
-
+
|
OF_HASH_ADD(hash, (otherCopy >> 24) & 0xFF); \
OF_HASH_ADD(hash, (otherCopy >> 16) & 0xFF); \
OF_HASH_ADD(hash, (otherCopy >> 8) & 0xFF); \
OF_HASH_ADD(hash, otherCopy & 0xFF); \
}
static OF_INLINE bool
of_bitset_isset(uint8_t *_Nonnull storage, size_t index)
of_bitset_isset(uint8_t *_Nonnull storage, size_t idx)
{
return storage[index / 8] & (1 << (index % 8));
return storage[idx / 8] & (1 << (idx % 8));
}
static OF_INLINE void
of_bitset_set(uint8_t *_Nonnull storage, size_t index)
of_bitset_set(uint8_t *_Nonnull storage, size_t idx)
{
storage[index / 8] |= (1 << (index % 8));
storage[idx / 8] |= (1 << (idx % 8));
}
static OF_INLINE void
of_bitset_clear(uint8_t *_Nonnull storage, size_t index)
of_bitset_clear(uint8_t *_Nonnull storage, size_t idx)
{
storage[index / 8] &= ~(1 << (index % 8));
storage[idx / 8] &= ~(1 << (idx % 8));
}
static OF_INLINE char *_Nullable
of_strdup(const char *_Nonnull string)
{
char *copy;
size_t length = strlen(string);
|
︙ | | |
Modified src/socket.h
from [1d3c37e76e]
to [ea1fed378b].
︙ | | |
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
|
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
|
-
-
+
+
|
#ifdef __cplusplus
extern "C" {
#endif
extern bool of_socket_init(void);
extern int of_socket_errno(void);
# ifndef OF_WII
extern int of_getsockname(of_socket_t socket, struct sockaddr *restrict address,
socklen_t *restrict address_len);
extern int of_getsockname(of_socket_t sock, struct sockaddr *restrict addr,
socklen_t *restrict addrLen);
# endif
#ifdef __cplusplus
}
#endif
OF_ASSUME_NONNULL_END
|
Modified src/socket.m
from [c5f416940a]
to [ac7909760b].
︙ | | |
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
|
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
|
-
-
+
+
-
+
|
return 0;
#endif
}
#ifndef OF_WII
int
of_getsockname(of_socket_t socket, struct sockaddr *restrict address,
socklen_t *restrict address_len)
of_getsockname(of_socket_t sock, struct sockaddr *restrict addr,
socklen_t *restrict addrLen)
{
int ret;
# ifdef OF_HAVE_THREADS
if (!of_mutex_lock(&mutex))
@throw [OFLockFailedException exception];
# endif
ret = getsockname(socket, address, address_len);
ret = getsockname(sock, addr, addrLen);
# ifdef OF_HAVE_THREADS
if (!of_mutex_unlock(&mutex))
@throw [OFUnlockFailedException exception];
# endif
return ret;
}
#endif
|
Modified tests/OFArrayTests.m
from [4fabdad1e7]
to [3b9dbd2a79].
︙ | | |
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
|
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
|
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
|
- (void)dealloc
{
[_array release];
[super dealloc];
}
- (id)objectAtIndex: (size_t)index
- (id)objectAtIndex: (size_t)idx
{
return [_array objectAtIndex: index];
return [_array objectAtIndex: idx];
}
- (size_t)count
{
return [_array count];
}
@end
@implementation SimpleMutableArray
+ (void)initialize
{
if (self == [SimpleMutableArray class])
[self inheritMethodsFromClass: [SimpleArray class]];
}
- (void)insertObject: (id)object
atIndex: (size_t)index
atIndex: (size_t)idx
{
[_array insertObject: object
atIndex: index];
atIndex: idx];
}
- (void)replaceObjectAtIndex: (size_t)index
- (void)replaceObjectAtIndex: (size_t)idx
withObject: (id)object
{
[_array replaceObjectAtIndex: index
[_array replaceObjectAtIndex: idx
withObject: object];
}
- (void)removeObjectAtIndex: (size_t)index
- (void)removeObjectAtIndex: (size_t)idx
{
[_array removeObjectAtIndex: index];
[_array removeObjectAtIndex: idx];
}
@end
@implementation TestsAppDelegate (OFArrayTests)
- (void)arrayTestsWithClass: (Class)arrayClass
mutableClass: (Class)mutableArrayClass
{
|
︙ | | |
Modified tests/OFInvocationTests.m
from [5d557debb9]
to [ed7a567435].
︙ | | |
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
|
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
|
-
-
+
+
|
: (float)f11
: (float)f12
: (float)f13
: (float)f14
: (float)f15
: (float)f16
{
return (d1 + f2 + f3 + f4 + f5 + f6 + f7 + f8 + f9 + d10 + f11 +
f12 + f13 + f14 + f15 + f16) / 16;
return (float)((d1 + f2 + f3 + f4 + f5 + f6 + f7 + f8 + f9 + d10 + f11 +
f12 + f13 + f14 + f15 + f16) / 16);
}
- (long double)invocationTestMethod5: (long double)d1
: (long double)d2
: (long double)d3
: (long double)d4
: (long double)d5
|
︙ | | |
Modified tests/OFStringTests.m
from [71dce1ac50]
to [33bc7fca89].
︙ | | |
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
|
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
|
-
+
-
+
|
- (void)dealloc
{
[_string release];
[super dealloc];
}
- (of_unichar_t)characterAtIndex: (size_t)index
- (of_unichar_t)characterAtIndex: (size_t)idx
{
return [_string characterAtIndex: index];
return [_string characterAtIndex: idx];
}
- (size_t)length
{
return [_string length];
}
@end
|
︙ | | |
Modified utils/ofhttp/OFHTTP.m
from [7674e4cd26]
to [46acc91009].
︙ | | |
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
|
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
|
-
+
-
+
-
+
|
}
[self performSelector: @selector(downloadNextURL)
afterDelay: 0];
}
- (void)client: (OFHTTPClient *)client
didCreateSocket: (OF_KINDOF(OFTCPSocket *))socket
didCreateSocket: (OF_KINDOF(OFTCPSocket *))sock
request: (OFHTTPRequest *)request
context: (id)context
{
if (_insecure && [socket respondsToSelector:
if (_insecure && [sock respondsToSelector:
@selector(setCertificateVerificationEnabled:)])
[socket setCertificateVerificationEnabled: false];
[sock setCertificateVerificationEnabled: false];
}
- (bool)client: (OFHTTPClient *)client
shouldFollowRedirect: (OFURL *)URL
statusCode: (int)statusCode
request: (OFHTTPRequest *)request
response: (OFHTTPResponse *)response
|
︙ | | |
Modified utils/ofhttp/ProgressBar.m
from [f1b2b790af]
to [665b1281f2].
︙ | | |
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
|
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
|
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
|
(float)(_resumedFrom + _length) * 100;
[of_stdout writeString: @"\r ▕"];
for (size_t i = 0; i < (size_t)bars; i++)
[of_stdout writeString: @"█"];
if (bars < barWidth) {
float remainder = bars - floorf(bars);
float rem = bars - floorf(bars);
if (remainder >= 0.875)
if (rem >= 0.875)
[of_stdout writeString: @"▉"];
else if (remainder >= 0.75)
else if (rem >= 0.75)
[of_stdout writeString: @"▊"];
else if (remainder >= 0.625)
else if (rem >= 0.625)
[of_stdout writeString: @"▋"];
else if (remainder >= 0.5)
else if (rem >= 0.5)
[of_stdout writeString: @"▌"];
else if (remainder >= 0.375)
else if (rem >= 0.375)
[of_stdout writeString: @"▍"];
else if (remainder >= 0.25)
else if (rem >= 0.25)
[of_stdout writeString: @"▎"];
else if (remainder >= 0.125)
else if (rem >= 0.125)
[of_stdout writeString: @"▏"];
else
[of_stdout writeString: @" "];
for (size_t i = 0; i < barWidth - (size_t)bars - 1; i++)
[of_stdout writeString: @" "];
}
|
︙ | | |