Differences From Artifact [661e4352a9]:
- File
src/OFString.m
— part of check-in
[56a18442e2]
at
2017-09-24 00:59:12
on branch trunk
— Make OFHTTPClient asynchronous
This does not make OFHTTPClientResponse completely asynchronous yet.
Since -[initWithURL:] does not work well with an asynchronous API, it no
longer supports HTTP URLs. However, a new, asynchronous API will be
added as a replacement later on. (user: js, size: 65583) [annotate] [blame] [check-ins using]
To Artifact [0cbd68fca6]:
- File
src/OFString.m
— part of check-in
[2f4e0df8be]
at
2017-10-17 00:33:37
on branch trunk
— Do not use implicit method return types
Instead, explicitly declare them, as OF_ASSUME_NONNULL_{BEGIN,END} does
not apply to implicit return types. This means that after this commit,
all init methods have a nonnull return type, as they should have. (user: js, size: 66347) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
374 375 376 377 378 379 380 | Class isa; } placeholder; @interface OFString_placeholder: OFString @end @implementation OFString_placeholder | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 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 | Class isa; } placeholder; @interface OFString_placeholder: OFString @end @implementation OFString_placeholder - (instancetype)init { return (id)[[OFString_UTF8 alloc] init]; } - (instancetype)initWithUTF8String: (const char *)UTF8String { id string; size_t length; void *storage; length = strlen(UTF8String); string = of_alloc_object([OFString_UTF8 class], length + 1, 1, &storage); return (id)[string of_initWithUTF8String: UTF8String length: length storage: storage]; } - (instancetype)initWithUTF8String: (const char *)UTF8String length: (size_t)UTF8StringLength { id string; void *storage; string = of_alloc_object([OFString_UTF8 class], UTF8StringLength + 1, 1, &storage); return (id)[string of_initWithUTF8String: UTF8String length: UTF8StringLength storage: storage]; } - (instancetype)initWithUTF8StringNoCopy: (char *)UTF8String freeWhenDone: (bool)freeWhenDone { return (id)[[OFString_UTF8 alloc] initWithUTF8StringNoCopy: UTF8String freeWhenDone: freeWhenDone]; } - (instancetype)initWithCString: (const char *)cString encoding: (of_string_encoding_t)encoding { if (encoding == OF_STRING_ENCODING_UTF_8) { id string; size_t length; void *storage; length = strlen(cString); string = of_alloc_object([OFString_UTF8 class], length + 1, 1, &storage); return (id)[string of_initWithUTF8String: cString length: length storage: storage]; } return (id)[[OFString_UTF8 alloc] initWithCString: cString encoding: encoding]; } - (instancetype)initWithCString: (const char *)cString encoding: (of_string_encoding_t)encoding length: (size_t)cStringLength { if (encoding == OF_STRING_ENCODING_UTF_8) { id string; void *storage; string = of_alloc_object([OFString_UTF8 class], cStringLength + 1, 1, &storage); return (id)[string of_initWithUTF8String: cString length: cStringLength storage: storage]; } return (id)[[OFString_UTF8 alloc] initWithCString: cString encoding: encoding length: cStringLength]; } - (instancetype)initWithData: (OFData *)data encoding: (of_string_encoding_t)encoding { return (id)[[OFString_UTF8 alloc] initWithData: data encoding: encoding]; } - (instancetype)initWithString: (OFString *)string { return (id)[[OFString_UTF8 alloc] initWithString: string]; } - (instancetype)initWithCharacters: (const of_unichar_t *)string length: (size_t)length { return (id)[[OFString_UTF8 alloc] initWithCharacters: string length: length]; } - (instancetype)initWithUTF16String: (const char16_t *)string { return (id)[[OFString_UTF8 alloc] initWithUTF16String: string]; } - (instancetype)initWithUTF16String: (const char16_t *)string length: (size_t)length { return (id)[[OFString_UTF8 alloc] initWithUTF16String: string length: length]; } - (instancetype)initWithUTF16String: (const char16_t *)string byteOrder: (of_byte_order_t)byteOrder { return (id)[[OFString_UTF8 alloc] initWithUTF16String: string byteOrder: byteOrder]; } - (instancetype)initWithUTF16String: (const char16_t *)string length: (size_t)length byteOrder: (of_byte_order_t)byteOrder { return (id)[[OFString_UTF8 alloc] initWithUTF16String: string length: length byteOrder: byteOrder]; } - (instancetype)initWithUTF32String: (const char32_t *)string { return (id)[[OFString_UTF8 alloc] initWithUTF32String: string]; } - (instancetype)initWithUTF32String: (const char32_t *)string length: (size_t)length { return (id)[[OFString_UTF8 alloc] initWithUTF32String: string length: length]; } - (instancetype)initWithUTF32String: (const char32_t *)string byteOrder: (of_byte_order_t)byteOrder { return (id)[[OFString_UTF8 alloc] initWithUTF32String: string byteOrder: byteOrder]; } - (instancetype)initWithUTF32String: (const char32_t *)string length: (size_t)length byteOrder: (of_byte_order_t)byteOrder { return (id)[[OFString_UTF8 alloc] initWithUTF32String: string length: length byteOrder: byteOrder]; } - (instancetype)initWithFormat: (OFConstantString *)format, ... { id ret; va_list arguments; va_start(arguments, format); ret = [[OFString_UTF8 alloc] initWithFormat: format arguments: arguments]; va_end(arguments); return ret; } - (instancetype)initWithFormat: (OFConstantString *)format arguments: (va_list)arguments { return (id)[[OFString_UTF8 alloc] initWithFormat: format arguments: arguments]; } #ifdef OF_HAVE_FILES - (instancetype)initWithContentsOfFile: (OFString *)path { return (id)[[OFString_UTF8 alloc] initWithContentsOfFile: path]; } - (instancetype)initWithContentsOfFile: (OFString *)path encoding: (of_string_encoding_t)encoding { return (id)[[OFString_UTF8 alloc] initWithContentsOfFile: path encoding: encoding]; } #endif #if defined(OF_HAVE_FILES) || defined(OF_HAVE_SOCKETS) - (instancetype)initWithContentsOfURL: (OFURL *)URL { return (id)[[OFString_UTF8 alloc] initWithContentsOfURL: URL]; } - (instancetype)initWithContentsOfURL: (OFURL *)URL encoding: (of_string_encoding_t)encoding { return (id)[[OFString_UTF8 alloc] initWithContentsOfURL: URL encoding: encoding]; } #endif - (instancetype)initWithSerialization: (OFXMLElement *)element { return (id)[[OFString_UTF8 alloc] initWithSerialization: element]; } - (instancetype)retain { return self; } - (instancetype)autorelease { return self; } - (void)release { } |
︙ | ︙ | |||
621 622 623 624 625 626 627 | #if defined(HAVE_STRTOF_L) || defined(HAVE_STRTOD_L) if ((cLocale = newlocale(LC_ALL_MASK, "C", NULL)) == NULL) @throw [OFInitializationFailedException exceptionWithClass: self]; #endif } | | | 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 | #if defined(HAVE_STRTOF_L) || defined(HAVE_STRTOD_L) if ((cLocale = newlocale(LC_ALL_MASK, "C", NULL)) == NULL) @throw [OFInitializationFailedException exceptionWithClass: self]; #endif } + (instancetype)alloc { if (self == [OFString class]) return (id)&placeholder; return [super alloc]; } |
︙ | ︙ | |||
804 805 806 807 808 809 810 | first = false; } return ret; } | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 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 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 | first = false; } return ret; } - (instancetype)init { if (object_getClass(self) == [OFString class]) { @try { [self doesNotRecognizeSelector: _cmd]; } @catch (id e) { [self release]; @throw e; } abort(); } return [super init]; } - (instancetype)initWithUTF8String: (const char *)UTF8String { return [self initWithCString: UTF8String encoding: OF_STRING_ENCODING_UTF_8 length: strlen(UTF8String)]; } - (instancetype)initWithUTF8String: (const char *)UTF8String length: (size_t)UTF8StringLength { return [self initWithCString: UTF8String encoding: OF_STRING_ENCODING_UTF_8 length: UTF8StringLength]; } - (instancetype)initWithUTF8StringNoCopy: (char *)UTF8String freeWhenDone: (bool)freeWhenDone { return [self initWithUTF8String: UTF8String]; } - (instancetype)initWithCString: (const char *)cString encoding: (of_string_encoding_t)encoding { return [self initWithCString: cString encoding: encoding length: strlen(cString)]; } - (instancetype)initWithCString: (const char *)cString encoding: (of_string_encoding_t)encoding length: (size_t)cStringLength { OF_INVALID_INIT_METHOD } - (instancetype)initWithData: (OFData *)data encoding: (of_string_encoding_t)encoding { @try { if ([data itemSize] != 1) @throw [OFInvalidArgumentException exception]; self = [self initWithCString: [data items] encoding: encoding length: [data count]]; } @catch (id e) { [self release]; @throw e; } return self; } - (instancetype)initWithString: (OFString *)string { OF_INVALID_INIT_METHOD } - (instancetype)initWithCharacters: (const of_unichar_t *)string length: (size_t)length { OF_INVALID_INIT_METHOD } - (instancetype)initWithUTF16String: (const char16_t *)string { return [self initWithUTF16String: string length: of_string_utf16_length(string) byteOrder: OF_BYTE_ORDER_NATIVE]; } - (instancetype)initWithUTF16String: (const char16_t *)string length: (size_t)length { return [self initWithUTF16String: string length: length byteOrder: OF_BYTE_ORDER_NATIVE]; } - (instancetype)initWithUTF16String: (const char16_t *)string byteOrder: (of_byte_order_t)byteOrder { return [self initWithUTF16String: string length: of_string_utf16_length(string) byteOrder: byteOrder]; } - (instancetype)initWithUTF16String: (const char16_t *)string length: (size_t)length byteOrder: (of_byte_order_t)byteOrder { OF_INVALID_INIT_METHOD } - (instancetype)initWithUTF32String: (const char32_t *)string { return [self initWithUTF32String: string length: of_string_utf32_length(string) byteOrder: OF_BYTE_ORDER_NATIVE]; } - (instancetype)initWithUTF32String: (const char32_t *)string length: (size_t)length { return [self initWithUTF32String: string length: length byteOrder: OF_BYTE_ORDER_NATIVE]; } - (instancetype)initWithUTF32String: (const char32_t *)string byteOrder: (of_byte_order_t)byteOrder { return [self initWithUTF32String: string length: of_string_utf32_length(string) byteOrder: byteOrder]; } - (instancetype)initWithUTF32String: (const char32_t *)string length: (size_t)length byteOrder: (of_byte_order_t)byteOrder { OF_INVALID_INIT_METHOD } - (instancetype)initWithFormat: (OFConstantString *)format, ... { id ret; va_list arguments; va_start(arguments, format); ret = [self initWithFormat: format arguments: arguments]; va_end(arguments); return ret; } - (instancetype)initWithFormat: (OFConstantString *)format arguments: (va_list)arguments { OF_INVALID_INIT_METHOD } #ifdef OF_HAVE_FILES - (instancetype)initWithContentsOfFile: (OFString *)path { return [self initWithContentsOfFile: path encoding: OF_STRING_ENCODING_UTF_8]; } - (instancetype)initWithContentsOfFile: (OFString *)path encoding: (of_string_encoding_t)encoding { char *tmp; of_offset_t fileSize; @try { OFFile *file; |
︙ | ︙ | |||
1020 1021 1022 1023 1024 1025 1026 | [self freeMemory: tmp]; return self; } #endif #if defined(OF_HAVE_FILES) || defined(OF_HAVE_SOCKETS) | | | | | 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 | [self freeMemory: tmp]; return self; } #endif #if defined(OF_HAVE_FILES) || defined(OF_HAVE_SOCKETS) - (instancetype)initWithContentsOfURL: (OFURL *)URL { return [self initWithContentsOfURL: URL encoding: OF_STRING_ENCODING_AUTODETECT]; } - (instancetype)initWithContentsOfURL: (OFURL *)URL encoding: (of_string_encoding_t)encoding { void *pool = objc_autoreleasePoolPush(); OFString *scheme = [URL scheme]; # ifdef OF_HAVE_FILES if ([scheme isEqual: @"file"]) { if (encoding == OF_STRING_ENCODING_AUTODETECT) |
︙ | ︙ | |||
1049 1050 1051 1052 1053 1054 1055 | objc_autoreleasePoolPop(pool); return self; } #endif | | | 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 | objc_autoreleasePoolPop(pool); return self; } #endif - (instancetype)initWithSerialization: (OFXMLElement *)element { @try { void *pool = objc_autoreleasePoolPush(); if (![[element namespace] isEqual: OF_SERIALIZATION_NS]) @throw [OFInvalidArgumentException exception]; |
︙ | ︙ | |||
1496 1497 1498 1499 1500 1501 1502 | } objc_autoreleasePoolPop(pool); return true; } | | | | 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 | } objc_autoreleasePoolPop(pool); return true; } - (id)copy { return [self retain]; } - (id)mutableCopy { return [[OFMutableString alloc] initWithString: self]; } - (of_comparison_result_t)compare: (id <OFComparing>)object { void *pool; |
︙ | ︙ |