Comment: | Merge trunk into 1.0 branch |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | 1.0 |
Files: | files | file ages | folders |
SHA3-256: |
438285cb1b4fbda5cba09f93e85b07ab |
User & Date: | js on 2023-08-23 16:10:47 |
Other Links: | branch diff | manifest | tags |
2023-08-28
| ||
15:44 | Merge trunk into 1.0 branch check-in: c20b5c87ef user: js tags: 1.0 | |
2023-08-23
| ||
16:10 | Merge trunk into 1.0 branch check-in: 438285cb1b user: js tags: 1.0 | |
16:01 | Remove incomplete NFD/NFKD support check-in: 149874777c user: js tags: trunk | |
2023-08-09
| ||
11:47 | Update version for 1.0 including shared lib check-in: 4d747f46f7 user: js tags: 1.0 | |
Modified PLATFORMS.md from [1aba75e60e] to [904253e6a5].
︙ | ︙ | |||
62 63 64 65 66 67 68 | GNU/Hurd -------- * OS Versions: 0.9 * Architectures: i686 * Compilers: Clang 14.0.6 * Runtimes: ObjFW | < < | 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | GNU/Hurd -------- * OS Versions: 0.9 * Architectures: i686 * Compilers: Clang 14.0.6 * Runtimes: ObjFW Haiku ----- * OS version: r1-alpha4 * Architectures: x86 |
︙ | ︙ |
Modified configure.ac from [8b58d54123] to [022d586a74].
︙ | ︙ | |||
1519 1520 1521 1522 1523 1524 1525 | #ifdef __morphos__ # error MorphOS has the struct but does not support it #endif #ifdef __MINT__ # error Gives invalid argument at runtime #endif | < < < < | 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 | #ifdef __morphos__ # error MorphOS has the struct but does not support it #endif #ifdef __MINT__ # error Gives invalid argument at runtime #endif ]) AC_CHECK_HEADER(netipx/ipx.h, [ AC_DEFINE(OF_HAVE_NETIPX_IPX_H, 1, [Whether we have netipx/ipx.h]) ]) AC_CHECK_MEMBER(struct sockaddr_ipx.sipx_network, [], [ |
︙ | ︙ |
Modified generators/unicode/TableGenerator.h from [68e11922ac] to [6c2ca9fc8b].
︙ | ︙ | |||
22 23 24 25 26 27 28 | OFHTTPClientDelegate> { OFHTTPClient *_HTTPClient; OFUnichar _uppercaseTable[0x110000]; OFUnichar _lowercaseTable[0x110000]; OFUnichar _titlecaseTable[0x110000]; OFUnichar _caseFoldingTable[0x110000]; | < < < < < < < | 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 | OFHTTPClientDelegate> { OFHTTPClient *_HTTPClient; OFUnichar _uppercaseTable[0x110000]; OFUnichar _lowercaseTable[0x110000]; OFUnichar _titlecaseTable[0x110000]; OFUnichar _caseFoldingTable[0x110000]; char _uppercaseTableUsed[0x1100]; char _lowercaseTableUsed[0x1100]; char _titlecaseTableUsed[0x1100]; char _caseFoldingTableUsed[0x1100]; size_t _uppercaseTableSize; size_t _lowercaseTableSize; size_t _titlecaseTableSize; size_t _caseFoldingTableSize; enum { stateUnicodeData, stateCaseFolding } _state; } - (void)parseUnicodeData: (OFHTTPResponse *)response; - (void)parseCaseFolding: (OFHTTPResponse *)response; - (void)writeFiles; - (void)writeTablesToFile: (OFString *)path; - (void)writeHeaderToFile: (OFString *)path; @end |
Modified generators/unicode/TableGenerator.m from [3403a36c8e] to [1fa7098a9b].
︙ | ︙ | |||
48 49 50 51 52 53 54 | _HTTPClient = [[OFHTTPClient alloc] init]; _HTTPClient.delegate = self; _uppercaseTableSize = SIZE_MAX; _lowercaseTableSize = SIZE_MAX; _titlecaseTableSize = SIZE_MAX; _caseFoldingTableSize = SIZE_MAX; | < < | 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | _HTTPClient = [[OFHTTPClient alloc] init]; _HTTPClient.delegate = self; _uppercaseTableSize = SIZE_MAX; _lowercaseTableSize = SIZE_MAX; _titlecaseTableSize = SIZE_MAX; _caseFoldingTableSize = SIZE_MAX; } @catch (id e) { [self release]; @throw e; } return self; } |
︙ | ︙ | |||
125 126 127 128 129 130 131 | _uppercaseTable[codePoint] = (OFUnichar)[[components objectAtIndex: 12] unsignedLongLongValueWithBase: 16]; _lowercaseTable[codePoint] = (OFUnichar)[[components objectAtIndex: 13] unsignedLongLongValueWithBase: 16]; _titlecaseTable[codePoint] = (OFUnichar)[[components objectAtIndex: 14] unsignedLongLongValueWithBase: 16]; | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 | _uppercaseTable[codePoint] = (OFUnichar)[[components objectAtIndex: 12] unsignedLongLongValueWithBase: 16]; _lowercaseTable[codePoint] = (OFUnichar)[[components objectAtIndex: 13] unsignedLongLongValueWithBase: 16]; _titlecaseTable[codePoint] = (OFUnichar)[[components objectAtIndex: 14] unsignedLongLongValueWithBase: 16]; objc_autoreleasePoolPop(pool2); } [OFStdOut writeLine: @" done"]; [OFStdOut writeString: @"Downloading CaseFolding.txt…"]; _state = stateCaseFolding; request = [OFHTTPRequest requestWithIRI: [OFIRI IRIWithString: caseFoldingIRI]]; [_HTTPClient asyncPerformRequest: request]; |
︙ | ︙ | |||
212 213 214 215 216 217 218 | } [OFStdOut writeLine: @" done"]; [self writeFiles]; } | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 178 179 180 181 182 183 184 185 186 187 188 189 190 191 | } [OFStdOut writeLine: @" done"]; [self writeFiles]; } - (void)writeFiles { OFIRI *IRI; [OFStdOut writeString: @"Writing files…"]; IRI = [OFIRI fileIRIWithPath: @"../../src/unicode.m"]; |
︙ | ︙ | |||
292 293 294 295 296 297 298 | mode: @"w"]; [file writeString: COPYRIGHT @"#include \"config.h\"\n" @"\n" @"#import \"OFString.h\"\n\n" @"static const OFUnichar emptyPage[0x100] = { 0 };\n" | < | 206 207 208 209 210 211 212 213 214 215 216 217 218 219 | mode: @"w"]; [file writeString: COPYRIGHT @"#include \"config.h\"\n" @"\n" @"#import \"OFString.h\"\n\n" @"static const OFUnichar emptyPage[0x100] = { 0 };\n" @"\n"]; /* Write uppercasePage%u */ for (OFUnichar i = 0; i < 0x110000; i += 0x100) { bool isEmpty = true; for (OFUnichar j = i; j < i + 0x100; j++) { |
︙ | ︙ | |||
453 454 455 456 457 458 459 | [file writeString: @"};\n\n"]; objc_autoreleasePoolPop(pool2); } } | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 | [file writeString: @"};\n\n"]; objc_autoreleasePoolPop(pool2); } } /* * Those are currently set to the last index. * But from now on, we need the size. */ _uppercaseTableSize++; _lowercaseTableSize++; _titlecaseTableSize++; _caseFoldingTableSize++; /* Write OFUnicodeUppercaseTable */ [file writeFormat: @"const OFUnichar *const " @"OFUnicodeUppercaseTable[0x%X] = {\n\t", _uppercaseTableSize]; for (OFUnichar i = 0; i < _uppercaseTableSize; i++) { |
︙ | ︙ | |||
671 672 673 674 675 676 677 | else [file writeString: @", "]; } } [file writeString: @"\n};\n\n"]; | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | < < | < < < < < < < | 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 | else [file writeString: @", "]; } } [file writeString: @"\n};\n\n"]; objc_autoreleasePoolPop(pool); } - (void)writeHeaderToFile: (OFString *)path { void *pool = objc_autoreleasePoolPush(); OFFile *file = [OFFile fileWithPath: path mode: @"w"]; [file writeString: COPYRIGHT @"#import \"OFString.h\"\n\n"]; [file writeFormat: @"#define OFUnicodeUppercaseTableSize 0x%X\n" @"#define OFUnicodeLowercaseTableSize 0x%X\n" @"#define OFUnicodeTitlecaseTableSize 0x%X\n" @"#define OFUnicodeCaseFoldingTableSize 0x%X\n\n", _uppercaseTableSize, _lowercaseTableSize, _titlecaseTableSize, _caseFoldingTableSize]; [file writeString: @"#ifdef __cplusplus\n" @"extern \"C\" {\n" @"#endif\n" @"extern const OFUnichar *const _Nonnull\n" @" OFUnicodeUppercaseTable[OFUnicodeUppercaseTableSize];\n" @"extern const OFUnichar *const _Nonnull\n" @" OFUnicodeLowercaseTable[OFUnicodeLowercaseTableSize];\n" @"extern const OFUnichar *const _Nonnull\n" @" OFUnicodeTitlecaseTable[OFUnicodeTitlecaseTableSize];\n" @"extern const OFUnichar *const _Nonnull\n" @" OFUnicodeCaseFoldingTable[OFUnicodeCaseFoldingTableSize];\n" @"#ifdef __cplusplus\n" @"}\n" @"#endif\n"]; objc_autoreleasePoolPop(pool); } @end |
Modified src/Makefile from [29dc8f24f3] to [3e54ffc274].
︙ | ︙ | |||
174 175 176 177 178 179 180 | platform.h \ ${USE_INCLUDES_ATOMIC} SRCS += OFASPrintF.m \ OFArchiveIRIHandler.m \ OFBase64.m \ OFBitSetCharacterSet.m \ | < > > > < < < < < | > > | 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 | platform.h \ ${USE_INCLUDES_ATOMIC} SRCS += OFASPrintF.m \ OFArchiveIRIHandler.m \ OFBase64.m \ OFBitSetCharacterSet.m \ OFCRC16.m \ OFCRC32.m \ OFConcreteArray.m \ OFConcreteColor.m \ OFConcreteCountedSet.m \ OFConcreteData.m \ OFConcreteDate.m \ OFConcreteDictionary.m \ OFConcreteMutableArray.m \ OFConcreteMutableData.m \ OFConcreteMutableDictionary.m \ OFConcreteMutableSet.m \ OFConcreteNumber.m \ OFConcreteSet.m \ OFConcreteSubarray.m \ OFConcreteValue.m \ OFEmbeddedIRIHandler.m \ OFHuffmanTree.m \ OFINIFileSettings.m \ OFInvertedCharacterSet.m \ OFLHADecompressingStream.m \ OFMutableUTF8String.m \ OFRangeCharacterSet.m \ OFSandbox.m \ OFStrFTime.m \ OFStrPTime.m \ OFSubarray.m \ OFSubdata.m \ OFTaggedPointerColor.m \ OFTaggedPointerDate.m \ OFTaggedPointerNumber.m \ OFUTF8String.m \ ${LIBBASES_M} \ ${RUNTIME_AUTORELEASE_M} \ ${RUNTIME_INSTANCE_M} \ ${UNICODE_M} SRCS_FILES += OFFileIRIHandler.m SRCS_SOCKETS += OFAsyncIPSocketConnector.m \ |
︙ | ︙ |
Modified src/OFASPrintF.m from [84a6c0408a] to [ebfc63953a].
︙ | ︙ | |||
32 33 34 35 36 37 38 39 40 41 42 43 44 45 | # include <xlocale.h> #endif #ifdef OF_HAVE_SYS_TYPES_H # include <sys/types.h> #endif #import "OFString.h" #import "OFLocale.h" #import "OFInitializationFailedException.h" #define maxSubformatLen 64 | > | 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | # include <xlocale.h> #endif #ifdef OF_HAVE_SYS_TYPES_H # include <sys/types.h> #endif #import "OFASPrintF.h" #import "OFString.h" #import "OFLocale.h" #import "OFInitializationFailedException.h" #define maxSubformatLen 64 |
︙ | ︙ |
Modified src/OFApplication.m from [594a3c0f6e] to [8c20d43cf6].
︙ | ︙ | |||
113 114 115 116 117 118 119 | OFSocketDeinit(); #endif } int OFApplicationMain(int *argc, char **argv[], id <OFApplicationDelegate> delegate) { | < < < < < > > > > | 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 | OFSocketDeinit(); #endif } int OFApplicationMain(int *argc, char **argv[], id <OFApplicationDelegate> delegate) { [[OFLocale alloc] init]; app = [[OFApplication alloc] of_init]; #ifdef OF_WINDOWS if ([OFSystemInfo isWindowsNT]) { wchar_t **wargv, **wenvp; int wargc, si = 0; __wgetmainargs(&wargc, &wargv, &wenvp, _CRT_glob, &si); [app of_setArgumentCount: argc andArgumentValues: argv andWideArgumentCount: wargc andWideArgumentValues: wargv]; } else #endif [app of_setArgumentCount: argc andArgumentValues: argv]; |
︙ | ︙ |
Modified src/OFArray.h from [3d63ad7d51] to [dde1d2db16].
︙ | ︙ | |||
180 181 182 183 184 185 186 187 188 189 190 191 192 193 | * @param objects A C array of objects * @param count The length of the C array * @return A new autoreleased OFArray */ + (instancetype)arrayWithObjects: (ObjectType const _Nonnull *_Nonnull)objects count: (size_t)count; /** * @brief Initializes an OFArray with the specified object. * * @param object An object * @return An initialized OFArray */ - (instancetype)initWithObject: (ObjectType)object; | > > > > > > > | 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 | * @param objects A C array of objects * @param count The length of the C array * @return A new autoreleased OFArray */ + (instancetype)arrayWithObjects: (ObjectType const _Nonnull *_Nonnull)objects count: (size_t)count; /** * @brief Initializes an OFArray with no objects. * * @return An initialized OFArray */ - (instancetype)init OF_DESIGNATED_INITIALIZER; /** * @brief Initializes an OFArray with the specified object. * * @param object An object * @return An initialized OFArray */ - (instancetype)initWithObject: (ObjectType)object; |
︙ | ︙ | |||
223 224 225 226 227 228 229 | * the specified length. * * @param objects A C array of objects * @param count The length of the C array * @return An initialized OFArray */ - (instancetype)initWithObjects: (ObjectType const _Nonnull *_Nonnull)objects | | | 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 | * the specified length. * * @param objects A C array of objects * @param count The length of the C array * @return An initialized OFArray */ - (instancetype)initWithObjects: (ObjectType const _Nonnull *_Nonnull)objects count: (size_t)count OF_DESIGNATED_INITIALIZER; /** * @brief Returns an OFEnumerator to enumerate through all objects of the array. * * @return An OFEnumerator to enumerate through all objects of the array */ - (OFEnumerator OF_GENERIC(ObjectType) *)objectEnumerator; |
︙ | ︙ |
Modified src/OFArray.m from [a991103c76] to [c1836ceb46].
︙ | ︙ | |||
40 41 42 43 44 45 46 47 48 49 50 51 52 53 | depth: (size_t)depth; @end @interface OFPlaceholderArray: OFArray @end @implementation OFPlaceholderArray - (instancetype)init { return (id)[[OFConcreteArray alloc] init]; } - (instancetype)initWithObject: (id)object { | > > > > > > | 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | depth: (size_t)depth; @end @interface OFPlaceholderArray: OFArray @end @implementation OFPlaceholderArray #ifdef __clang__ /* We intentionally don't call into super, so silence the warning. */ # pragma clang diagnostic push # pragma clang diagnostic ignored "-Wunknown-pragmas" # pragma clang diagnostic ignored "-Wobjc-designated-initializers" #endif - (instancetype)init { return (id)[[OFConcreteArray alloc] init]; } - (instancetype)initWithObject: (id)object { |
︙ | ︙ | |||
81 82 83 84 85 86 87 88 89 90 91 92 93 94 | - (instancetype)initWithObjects: (id const *)objects count: (size_t)count { return (id)[[OFConcreteArray alloc] initWithObjects: objects count: count]; } OF_SINGLETON_METHODS @end @implementation OFArray + (void)initialize { | > > > | 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 | - (instancetype)initWithObjects: (id const *)objects count: (size_t)count { return (id)[[OFConcreteArray alloc] initWithObjects: objects count: count]; } #ifdef __clang__ # pragma clang diagnostic pop #endif OF_SINGLETON_METHODS @end @implementation OFArray + (void)initialize { |
︙ | ︙ | |||
154 155 156 157 158 159 160 | } return [super init]; } - (instancetype)initWithObject: (id)object { | < < < < < | | > > | > | > > | > > > | > > > > > | > > > > > > > > > > > > > > > > > | > > > | > > > > > | > > > > > > > > > > > > > > > > > | 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 253 254 255 256 257 258 259 260 261 262 | } return [super init]; } - (instancetype)initWithObject: (id)object { return [self initWithObjects: &object count: 1]; } - (instancetype)initWithObjects: (id)firstObject, ... { id ret; va_list arguments; va_start(arguments, firstObject); ret = [self initWithObject: firstObject arguments: arguments]; va_end(arguments); return ret; } - (instancetype)initWithObject: (id)firstObject arguments: (va_list)arguments { size_t count = 1; va_list argumentsCopy; id *objects; if (firstObject == nil) return [self init]; va_copy(argumentsCopy, arguments); while (va_arg(argumentsCopy, id) != nil) count++; @try { objects = OFAllocMemory(count, sizeof(id)); } @catch (id e) { [self release]; @throw e; } @try { objects[0] = firstObject; for (size_t i = 1; i < count; i++) { objects[i] = va_arg(arguments, id); OFEnsure(objects[i] != nil); } return [self initWithObjects: objects count: count]; } @finally { OFFreeMemory(objects); } } - (instancetype)initWithArray: (OFArray *)array { id *objects; size_t count; @try { count = array.count; objects = OFAllocMemory(count, sizeof(id)); [array getObjects: objects inRange: OFMakeRange(0, count)]; } @catch (id e) { [self release]; @throw e; } @try { return [self initWithObjects: objects count: count]; } @finally { OFFreeMemory(objects); } } #ifdef __clang__ /* We intentionally don't call into super, so silence the warning. */ # pragma clang diagnostic push # pragma clang diagnostic ignored "-Wunknown-pragmas" # pragma clang diagnostic ignored "-Wobjc-designated-initializers" #endif - (instancetype)initWithObjects: (id const *)objects count: (size_t)count { OF_INVALID_INIT_METHOD } #ifdef __clang__ # pragma clang diagnostic pop #endif - (size_t)count { OF_UNRECOGNIZED_SELECTOR } - (void)getObjects: (id *)buffer inRange: (OFRange)range |
︙ | ︙ |
Modified src/OFColor.m from [a2a90d4c7a] to [8614080a4d].
︙ | ︙ | |||
19 20 21 22 23 24 25 | #import "OFColor.h" #import "OFConcreteColor.h" #import "OFOnce.h" #import "OFString.h" #import "OFTaggedPointerColor.h" | | | | 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | #import "OFColor.h" #import "OFConcreteColor.h" #import "OFOnce.h" #import "OFString.h" #import "OFTaggedPointerColor.h" @interface OFPlaceholderColor: OFColor @end @interface OFConcreteColorSingleton: OFConcreteColor @end static struct { Class isa; } placeholder; #ifdef OF_OBJFW_RUNTIME |
︙ | ︙ | |||
65 66 67 68 69 70 71 | blue: blue alpha: alpha]; } OF_SINGLETON_METHODS @end | | | 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 | blue: blue alpha: alpha]; } OF_SINGLETON_METHODS @end @implementation OFConcreteColorSingleton OF_SINGLETON_METHODS @end @implementation OFColor + (void)initialize { if (self == [OFColor class]) |
︙ | ︙ | |||
90 91 92 93 94 95 96 | #define PREDEFINED_COLOR(name, redValue, greenValue, blueValue) \ static OFColor *name##Color = nil; \ \ static void \ initPredefinedColor_##name(void) \ { \ | | | 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | #define PREDEFINED_COLOR(name, redValue, greenValue, blueValue) \ static OFColor *name##Color = nil; \ \ static void \ initPredefinedColor_##name(void) \ { \ name##Color = [[OFConcreteColorSingleton alloc] \ initWithRed: redValue \ green: greenValue \ blue: blueValue \ alpha: 1]; \ } \ \ + (OFColor *)name \ |
︙ | ︙ |
Modified src/OFConcreteArray.m from [5f63cf2e4a] to [1fd9667868].
︙ | ︙ | |||
121 122 123 124 125 126 127 | } return self; } - (instancetype)initWithObjects: (id const *)objects count: (size_t)count { | | > > | 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 | } return self; } - (instancetype)initWithObjects: (id const *)objects count: (size_t)count { self = [super init]; @try { bool ok = true; for (size_t i = 0; i < count; i++) { if (objects[i] == nil) ok = false; [objects[i] retain]; } if (!ok) @throw [OFInvalidArgumentException exception]; _array = [[OFMutableData alloc] initWithItemSize: sizeof(id) capacity: count]; [_array addItems: objects count: count]; } @catch (id e) { for (size_t i = 0; i < count; i++) [objects[i] release]; [self release]; @throw e; |
︙ | ︙ |
Added src/OFConcreteDate.h version [28a5352e63].
> > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | /* * Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in * the packaging of this file. * * 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 "OFDate.h" OF_ASSUME_NONNULL_BEGIN @interface OFConcreteDate: OFDate { OFTimeInterval _seconds; } @end OF_ASSUME_NONNULL_END |
Added src/OFConcreteDate.m version [536f6ea5d9].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | /* * Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in * the packaging of this file. * * 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 "OFConcreteDate.h" @implementation OFConcreteDate - (instancetype)initWithTimeIntervalSince1970: (OFTimeInterval)seconds { self = [super initWithTimeIntervalSince1970: seconds]; _seconds = seconds; return self; } - (OFTimeInterval)timeIntervalSince1970 { return _seconds; } @end |
Added src/OFConcreteNumber.h version [fe80ae4102].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | /* * Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in * the packaging of this file. * * 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 "OFNumber.h" OF_ASSUME_NONNULL_BEGIN @interface OFConcreteNumber: OFNumber { union { double float_; long long signed_; unsigned long long unsigned_; } _value; char _typeEncoding; } @end OF_ASSUME_NONNULL_END |
Added src/OFConcreteNumber.m version [f5ec3b05ca].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 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 | /* * Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in * the packaging of this file. * * 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. */ #include "config.h" #include <string.h> #import "OFConcreteNumber.h" #import "OFInvalidFormatException.h" static bool isUnsigned(OFNumber *number) { switch (*number.objCType) { case 'B': case 'C': case 'S': case 'I': case 'L': case 'Q': return true; default: return false; } } static bool isSigned(OFNumber *number) { switch (*number.objCType) { case 'c': case 's': case 'i': case 'l': case 'q': return true; default: return false; } } static bool isFloat(OFNumber *number) { switch (*number.objCType) { case 'f': case 'd': return true; default: return false; } } @implementation OFConcreteNumber - (instancetype)initWithBytes: (const void *)bytes objCType: (const char *)objCType { #define CASE(type, method) \ if (strcmp(objCType, @encode(type)) == 0) { \ type value; \ memcpy(&value, bytes, sizeof(type)); \ return [self method value]; \ } CASE(bool, initWithBool:) CASE(signed char, initWithChar:) CASE(short, initWithShort:) CASE(int, initWithInt:) CASE(long, initWithLong:) CASE(long long, initWithLongLong:) CASE(unsigned char, initWithUnsignedChar:) CASE(unsigned short, initWithUnsignedShort:) CASE(unsigned int, initWithUnsignedInt:) CASE(unsigned long, initWithUnsignedLong:) CASE(unsigned long long, initWithUnsignedLongLong:) CASE(float, initWithFloat:) CASE(double, initWithDouble:) [self release]; @throw [OFInvalidFormatException exception]; } - (instancetype)initWithBool: (bool)value { self = [super initWithBytes: &value objCType: @encode(bool)]; _value.unsigned_ = value; _typeEncoding = *@encode(bool); return self; } - (instancetype)initWithChar: (signed char)value { self = [super initWithBytes: &value objCType: @encode(signed char)]; _value.signed_ = value; _typeEncoding = *@encode(signed char); return self; } - (instancetype)initWithShort: (short)value { self = [super initWithBytes: &value objCType: @encode(short)]; _value.signed_ = value; _typeEncoding = *@encode(short); return self; } - (instancetype)initWithInt: (int)value { self = [super initWithBytes: &value objCType: @encode(int)]; _value.signed_ = value; _typeEncoding = *@encode(int); return self; } - (instancetype)initWithLong: (long)value { self = [super initWithBytes: &value objCType: @encode(long)]; _value.signed_ = value; _typeEncoding = *@encode(long); return self; } - (instancetype)initWithLongLong: (long long)value { self = [super initWithBytes: &value objCType: @encode(long long)]; _value.signed_ = value; _typeEncoding = *@encode(long long); return self; } - (instancetype)initWithUnsignedChar: (unsigned char)value { self = [super initWithBytes: &value objCType: @encode(unsigned char)]; _value.unsigned_ = value; _typeEncoding = *@encode(unsigned long); return self; } - (instancetype)initWithUnsignedShort: (unsigned short)value { self = [super initWithBytes: &value objCType: @encode(unsigned short)]; _value.unsigned_ = value; _typeEncoding = *@encode(unsigned short); return self; } - (instancetype)initWithUnsignedInt: (unsigned int)value { self = [super initWithBytes: &value objCType: @encode(unsigned int)]; _value.unsigned_ = value; _typeEncoding = *@encode(unsigned int); return self; } - (instancetype)initWithUnsignedLong: (unsigned long)value { self = [super initWithBytes: &value objCType: @encode(unsigned long)]; _value.unsigned_ = value; _typeEncoding = *@encode(unsigned long); return self; } - (instancetype)initWithUnsignedLongLong: (unsigned long long)value { self = [super initWithBytes: &value objCType: @encode(unsigned long long)]; _value.unsigned_ = value; _typeEncoding = *@encode(unsigned long long); return self; } - (instancetype)initWithFloat: (float)value { self = [super initWithBytes: &value objCType: @encode(float)]; _value.float_ = value; _typeEncoding = *@encode(float); return self; } - (instancetype)initWithDouble: (double)value { self = [super initWithBytes: &value objCType: @encode(double)]; _value.float_ = value; _typeEncoding = *@encode(double); return self; } - (const char *)objCType { return &_typeEncoding; } - (long long)longLongValue { if (isFloat(self)) return _value.float_; else if (isSigned(self)) return _value.signed_; else if (isUnsigned(self)) return _value.unsigned_; else @throw [OFInvalidFormatException exception]; } - (unsigned long long)unsignedLongLongValue { if (isFloat(self)) return _value.float_; else if (isSigned(self)) return _value.signed_; else if (isUnsigned(self)) return _value.unsigned_; else @throw [OFInvalidFormatException exception]; } - (double)doubleValue { if (isFloat(self)) return _value.float_; else if (isSigned(self)) return _value.signed_; else if (isUnsigned(self)) return _value.unsigned_; else @throw [OFInvalidFormatException exception]; } @end |
Renamed and modified src/OFBytesValue.h [fa7ec42d63] to src/OFConcreteValue.h [50c02d8332].
︙ | ︙ | |||
13 14 15 16 17 18 19 | * file. */ #import "OFValue.h" OF_ASSUME_NONNULL_BEGIN | | | | 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | * file. */ #import "OFValue.h" OF_ASSUME_NONNULL_BEGIN @interface OFConcreteValue: OFValue { size_t _size; void *_bytes; char *_objCType; } @end OF_ASSUME_NONNULL_END |
Renamed and modified src/OFBytesValue.m [b82083e896] to src/OFConcreteValue.m [27a3d1dc6b].
︙ | ︙ | |||
9 10 11 12 13 14 15 | * * 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. */ | | > | < < | | < > > > > > > | 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | * * 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 "OFConcreteValue.h" #import "OFMethodSignature.h" #import "OFString.h" #import "OFOutOfRangeException.h" @implementation OFConcreteValue - (instancetype)initWithBytes: (const void *)bytes objCType: (const char *)objCType { self = [super initWithBytes: bytes objCType: objCType]; @try { _size = OFSizeOfTypeEncoding(objCType); _objCType = OFStrDup(objCType); _bytes = OFAllocMemory(1, _size); memcpy(_bytes, bytes, _size); } @catch (id e) { [self release]; @throw e; } return self; } - (void)dealloc { OFFreeMemory(_bytes); OFFreeMemory(_objCType); [super dealloc]; } - (const char *)objCType { return _objCType; } - (void)getValue: (void *)value size: (size_t)size { if (size != _size) @throw [OFOutOfRangeException exception]; memcpy(value, _bytes, _size); } @end |
Modified src/OFConstantString.m from [58e75bd4ee] to [a848ea510b].
︙ | ︙ | |||
501 502 503 504 505 506 507 | - (OFData *)dataWithEncoding: (OFStringEncoding)encoding { [self finishInitialization]; return [self dataWithEncoding: encoding]; } | < < < < < < < < < < < < < < | 501 502 503 504 505 506 507 508 509 510 511 512 513 514 | - (OFData *)dataWithEncoding: (OFStringEncoding)encoding { [self finishInitialization]; return [self dataWithEncoding: encoding]; } #ifdef OF_WINDOWS - (OFString *)stringByExpandingWindowsEnvironmentStrings { [self finishInitialization]; return self.stringByExpandingWindowsEnvironmentStrings; } #endif |
︙ | ︙ |
Modified src/OFCountedSet.m from [3de39a28c5] to [e146ed9623].
︙ | ︙ | |||
26 27 28 29 30 31 32 33 34 35 36 37 38 39 | Class isa; } placeholder; @interface OFPlaceholderCountedSet: OFCountedSet @end @implementation OFPlaceholderCountedSet - (instancetype)init { return (id)[[OFConcreteCountedSet alloc] init]; } - (instancetype)initWithSet: (OFSet *)set { | > > > > > > | 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | Class isa; } placeholder; @interface OFPlaceholderCountedSet: OFCountedSet @end @implementation OFPlaceholderCountedSet #ifdef __clang__ /* We intentionally don't call into super, so silence the warning. */ # pragma clang diagnostic push # pragma clang diagnostic ignored "-Wunknown-pragmas" # pragma clang diagnostic ignored "-Wobjc-designated-initializers" #endif - (instancetype)init { return (id)[[OFConcreteCountedSet alloc] init]; } - (instancetype)initWithSet: (OFSet *)set { |
︙ | ︙ | |||
65 66 67 68 69 70 71 72 73 74 75 76 77 78 | } - (instancetype)initWithObject: (id)firstObject arguments: (va_list)arguments { return (id)[[OFConcreteCountedSet alloc] initWithObject: firstObject arguments: arguments]; } OF_SINGLETON_METHODS @end @implementation OFCountedSet + (void)initialize { | > > > | 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 | } - (instancetype)initWithObject: (id)firstObject arguments: (va_list)arguments { return (id)[[OFConcreteCountedSet alloc] initWithObject: firstObject arguments: arguments]; } #ifdef __clang__ # pragma clang diagnostic pop #endif OF_SINGLETON_METHODS @end @implementation OFCountedSet + (void)initialize { |
︙ | ︙ |
Modified src/OFData.m from [6b96716473] to [753e5c551b].
︙ | ︙ | |||
261 262 263 264 265 266 267 | { OF_INVALID_INIT_METHOD } #ifdef OF_HAVE_FILES - (instancetype)initWithContentsOfFile: (OFString *)path { | < < < < | < < | < < < | < < | < < < < | < < < < < | > | 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 | { OF_INVALID_INIT_METHOD } #ifdef OF_HAVE_FILES - (instancetype)initWithContentsOfFile: (OFString *)path { void *pool = objc_autoreleasePoolPush(); OFIRI *IRI; @try { IRI = [OFIRI fileIRIWithPath: path]; } @catch (id e) { [self release]; @throw e; } self = [self initWithContentsOfIRI: IRI]; objc_autoreleasePoolPop(pool); return self; } #endif - (instancetype)initWithContentsOfIRI: (OFIRI *)IRI { |
︙ | ︙ |
Modified src/OFDate.m from [468bf23684] to [d12ca09b85].
︙ | ︙ | |||
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 | #include <limits.h> #include <time.h> #include <math.h> #include <sys/time.h> #import "OFDate.h" #import "OFData.h" #import "OFDictionary.h" #import "OFMessagePackExtension.h" #ifdef OF_HAVE_THREADS # import "OFMutex.h" #endif #import "OFStrPTime.h" #import "OFString.h" #import "OFSystemInfo.h" #import "OFXMLAttribute.h" #import "OFInitializationFailedException.h" #import "OFInvalidArgumentException.h" #import "OFInvalidFormatException.h" #import "OFOutOfMemoryException.h" #import "OFOutOfRangeException.h" #if defined(OF_AMIGAOS_M68K) || defined(OF_MINT) /* amiga-gcc and freemint-gcc do not have trunc() */ # define trunc(x) ((int64_t)(x)) #endif @interface OFPlaceholderDate: OFDate @end | > > > | < < < < < < < < < < < | < < < > | | | | 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 | #include <limits.h> #include <time.h> #include <math.h> #include <sys/time.h> #import "OFDate.h" #import "OFConcreteDate.h" #import "OFData.h" #import "OFDictionary.h" #import "OFMessagePackExtension.h" #ifdef OF_HAVE_THREADS # import "OFMutex.h" #endif #import "OFStrFTime.h" #import "OFStrPTime.h" #import "OFString.h" #import "OFSystemInfo.h" #import "OFTaggedPointerDate.h" #import "OFXMLAttribute.h" #import "OFInitializationFailedException.h" #import "OFInvalidArgumentException.h" #import "OFInvalidFormatException.h" #import "OFOutOfMemoryException.h" #import "OFOutOfRangeException.h" #if defined(OF_AMIGAOS_M68K) || defined(OF_MINT) /* amiga-gcc and freemint-gcc do not have trunc() */ # define trunc(x) ((int64_t)(x)) #endif @interface OFPlaceholderDate: OFDate @end @interface OFConcreteDateSingleton: OFConcreteDate @end static struct { Class isa; } placeholder; static OFConcreteDateSingleton *zeroDate, *distantFuture, *distantPast; static void initZeroDate(void) { zeroDate = [[OFConcreteDateSingleton alloc] initWithTimeIntervalSince1970: 0]; } static void initDistantFuture(void) { distantFuture = [[OFConcreteDateSingleton alloc] initWithTimeIntervalSince1970: 64060588800.0]; } static void initDistantPast(void) { distantPast = [[OFConcreteDateSingleton alloc] initWithTimeIntervalSince1970: -62167219200.0]; } static OFTimeInterval now(void) { struct timeval tv; |
︙ | ︙ | |||
257 258 259 260 261 262 263 | seconds += tm->tm_sec; /* Time zone */ seconds += -(double)tz * 60; return seconds; } | | | 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 | seconds += tm->tm_sec; /* Time zone */ seconds += -(double)tz * 60; return seconds; } @implementation OFConcreteDateSingleton OF_SINGLETON_METHODS @end @implementation OFPlaceholderDate #ifdef __clang__ /* We intentionally don't call into super, so silence the warning. */ # pragma clang diagnostic push |
︙ | ︙ | |||
286 287 288 289 290 291 292 | #if defined(OF_OBJFW_RUNTIME) && UINTPTR_MAX == UINT64_MAX value = OFFromBigEndian64(OFDoubleToRawUInt64(OFToBigEndianDouble( seconds))); /* Almost all dates fall into this range. */ if (value & (UINT64_C(4) << 60)) { | | | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 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 | #if defined(OF_OBJFW_RUNTIME) && UINTPTR_MAX == UINT64_MAX value = OFFromBigEndian64(OFDoubleToRawUInt64(OFToBigEndianDouble( seconds))); /* Almost all dates fall into this range. */ if (value & (UINT64_C(4) << 60)) { id ret = [OFTaggedPointerDate dateWithUInt64TimeIntervalSince1970: value]; if (ret != nil) return ret; } #endif return (id)[[OFConcreteDate alloc] initWithTimeIntervalSince1970: seconds]; } #ifdef __clang__ # pragma clang diagnostic pop #endif OF_SINGLETON_METHODS @end @implementation OFDate + (void)initialize { #ifdef OF_WINDOWS HMODULE module; #endif |
︙ | ︙ | |||
357 358 359 360 361 362 363 | #endif #ifdef OF_WINDOWS if ((module = LoadLibrary("msvcrt.dll")) != NULL) _mktime64FuncPtr = (__time64_t (*)(struct tm *)) GetProcAddress(module, "_mktime64"); #endif | < < < < | 318 319 320 321 322 323 324 325 326 327 328 329 330 331 | #endif #ifdef OF_WINDOWS if ((module = LoadLibrary("msvcrt.dll")) != NULL) _mktime64FuncPtr = (__time64_t (*)(struct tm *)) GetProcAddress(module, "_mktime64"); #endif } + (instancetype)alloc { if (self == [OFDate class]) return (id)&placeholder; |
︙ | ︙ | |||
552 553 554 555 556 557 558 | return OFOrderedDescending; return OFOrderedSame; } - (OFString *)description { | | | 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 | return OFOrderedDescending; return OFOrderedSame; } - (OFString *)description { return [self dateStringWithFormat: @"%Y-%m-%dT%H:%M:%S%z"]; } - (OFData *)messagePackRepresentation { void *pool = objc_autoreleasePoolPush(); OFTimeInterval timeInterval = self.timeIntervalSince1970; int64_t seconds = (int64_t)timeInterval; |
︙ | ︙ | |||
732 733 734 735 736 737 738 | } # endif #endif pageSize = [OFSystemInfo pageSize]; buffer = OFAllocMemory(1, pageSize); @try { | < | > < < < < < < < | 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 | } # endif #endif pageSize = [OFSystemInfo pageSize]; buffer = OFAllocMemory(1, pageSize); @try { if (OFStrFTime(buffer, pageSize, format.UTF8String, &tm, 0) == 0) @throw [OFOutOfRangeException exception]; ret = [OFString stringWithUTF8String: buffer]; } @finally { OFFreeMemory(buffer); } return ret; } |
︙ | ︙ | |||
792 793 794 795 796 797 798 | } # endif #endif pageSize = [OFSystemInfo pageSize]; buffer = OFAllocMemory(1, pageSize); @try { | < | > < < < < < < < | 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 | } # endif #endif pageSize = [OFSystemInfo pageSize]; buffer = OFAllocMemory(1, pageSize); @try { if (OFStrFTime(buffer, pageSize, format.UTF8String, &tm, 0) == 0) @throw [OFOutOfRangeException exception]; ret = [OFString stringWithUTF8String: buffer]; } @finally { OFFreeMemory(buffer); } return ret; } |
︙ | ︙ |
Modified src/OFDictionary.h from [b2fad599b6] to [947ceaf9c2].
︙ | ︙ | |||
145 146 147 148 149 150 151 152 153 154 155 156 157 158 | * * @param firstKey The first key * @return A new autoreleased OFDictionary */ + (instancetype)dictionaryWithKeysAndObjects: (KeyType)firstKey, ... OF_SENTINEL; /** * @brief Initializes an already allocated OFDictionary with the specified * OFDictionary. * * @param dictionary An OFDictionary * @return An initialized OFDictionary */ | > > > > > > > | 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 | * * @param firstKey The first key * @return A new autoreleased OFDictionary */ + (instancetype)dictionaryWithKeysAndObjects: (KeyType)firstKey, ... OF_SENTINEL; /** * @brief Initializes an already allocated OFDictionary to be empty. * * @return An initialized OFDictionary */ - (instancetype)init OF_DESIGNATED_INITIALIZER; /** * @brief Initializes an already allocated OFDictionary with the specified * OFDictionary. * * @param dictionary An OFDictionary * @return An initialized OFDictionary */ |
︙ | ︙ | |||
187 188 189 190 191 192 193 | * @param keys An array of keys * @param objects An array of objects * @param count The number of objects in the arrays * @return An initialized OFDictionary */ - (instancetype)initWithObjects: (ObjectType const _Nonnull *_Nonnull)objects forKeys: (KeyType const _Nonnull *_Nonnull)keys | | | 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 | * @param keys An array of keys * @param objects An array of objects * @param count The number of objects in the arrays * @return An initialized OFDictionary */ - (instancetype)initWithObjects: (ObjectType const _Nonnull *_Nonnull)objects forKeys: (KeyType const _Nonnull *_Nonnull)keys count: (size_t)count OF_DESIGNATED_INITIALIZER; /** * @brief Initializes an already allocated OFDictionary with the specified keys * and objects. * * @param firstKey The first key * @return An initialized OFDictionary |
︙ | ︙ |
Modified src/OFDictionary.m from [8b606ffec2] to [e134f53095].
︙ | ︙ | |||
49 50 51 52 53 54 55 56 57 58 59 60 61 62 | OFEnumerator *_keyEnumerator; } - (instancetype)initWithDictionary: (OFDictionary *)dictionary; @end @implementation OFPlaceholderDictionary - (instancetype)init { return (id)[[OFConcreteDictionary alloc] init]; } - (instancetype)initWithDictionary: (OFDictionary *)dictionary { | > > > > > > | 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | OFEnumerator *_keyEnumerator; } - (instancetype)initWithDictionary: (OFDictionary *)dictionary; @end @implementation OFPlaceholderDictionary #ifdef __clang__ /* We intentionally don't call into super, so silence the warning. */ # pragma clang diagnostic push # pragma clang diagnostic ignored "-Wunknown-pragmas" # pragma clang diagnostic ignored "-Wobjc-designated-initializers" #endif - (instancetype)init { return (id)[[OFConcreteDictionary alloc] init]; } - (instancetype)initWithDictionary: (OFDictionary *)dictionary { |
︙ | ︙ | |||
100 101 102 103 104 105 106 107 108 109 110 111 112 113 | - (instancetype)initWithKey: (id <OFCopying>)firstKey arguments: (va_list)arguments { return (id)[[OFConcreteDictionary alloc] initWithKey: firstKey arguments: arguments]; } OF_SINGLETON_METHODS @end @implementation OFDictionary + (void)initialize { | > > > | 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 | - (instancetype)initWithKey: (id <OFCopying>)firstKey arguments: (va_list)arguments { return (id)[[OFConcreteDictionary alloc] initWithKey: firstKey arguments: arguments]; } #ifdef __clang__ # pragma clang diagnostic pop #endif OF_SINGLETON_METHODS @end @implementation OFDictionary + (void)initialize { |
︙ | ︙ | |||
184 185 186 187 188 189 190 | } return [super init]; } - (instancetype)initWithDictionary: (OFDictionary *)dictionary { | > > > | > > > | > > > > > > > > > > > > > > > > > > > > > | | > > > | > | > | | > > > > > > > > > > > > > > > > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 | } return [super init]; } - (instancetype)initWithDictionary: (OFDictionary *)dictionary { void *pool = objc_autoreleasePoolPush(); id const *objects, *keys; size_t count; @try { OFArray *objects_ = [dictionary.objectEnumerator allObjects]; OFArray *keys_ = [dictionary.keyEnumerator allObjects]; count = dictionary.count; if (count != keys_.count || count != objects_.count) @throw [OFInvalidArgumentException exception]; objects = objects_.objects; keys = keys_.objects; } @catch (id e) { [self release]; @throw e; } @try { return [self initWithObjects: objects forKeys: keys count: count]; } @finally { objc_autoreleasePoolPop(pool); } } - (instancetype)initWithObject: (id)object forKey: (id)key { @try { if (key == nil || object == nil) @throw [OFInvalidArgumentException exception]; } @catch (id e) { [self release]; @throw e; } return [self initWithObjects: &object forKeys: &key count: 1]; } - (instancetype)initWithObjects: (OFArray *)objects_ forKeys: (OFArray *)keys_ { void *pool = objc_autoreleasePoolPush(); id const *objects, *keys; size_t count; @try { count = objects_.count; if (count != keys_.count) @throw [OFInvalidArgumentException exception]; objects = objects_.objects; keys = keys_.objects; } @catch (id e) { [self release]; @throw e; } self = [self initWithObjects: objects forKeys: keys count: count]; objc_autoreleasePoolPop(pool); return self; } #ifdef __clang__ /* We intentionally don't call into super, so silence the warning. */ # pragma clang diagnostic push # pragma clang diagnostic ignored "-Wunknown-pragmas" # pragma clang diagnostic ignored "-Wobjc-designated-initializers" #endif - (instancetype)initWithObjects: (id const *)objects forKeys: (id const *)keys count: (size_t)count { OF_INVALID_INIT_METHOD } #ifdef __clang__ # pragma clang diagnostic pop #endif - (instancetype)initWithKeysAndObjects: (id)firstKey, ... { id ret; va_list arguments; va_start(arguments, firstKey); ret = [self initWithKey: firstKey arguments: arguments]; va_end(arguments); return ret; } - (instancetype)initWithKey: (id)firstKey arguments: (va_list)arguments { size_t count = 1; id *objects = NULL, *keys = NULL; va_list argumentsCopy; if (firstKey == nil) return [self init]; va_copy(argumentsCopy, arguments); while (va_arg(argumentsCopy, id) != nil) count++; @try { size_t i = 0; id key, object; if (count % 2 != 0) @throw [OFInvalidArgumentException exception]; count /= 2; objects = OFAllocMemory(count, sizeof(id)); keys = OFAllocMemory(count, sizeof(id)); while ((key = va_arg(arguments, id)) != nil && (object = va_arg(arguments, id)) != nil) { OFEnsure(i < count); objects[i] = object; keys[i] = key; i++; } } @catch (id e) { OFFreeMemory(objects); OFFreeMemory(keys); [self release]; @throw e; } @try { return [self initWithObjects: objects forKeys: keys count: count]; } @finally { OFFreeMemory(objects); OFFreeMemory(keys); } } - (id)objectForKey: (id)key { OF_UNRECOGNIZED_SELECTOR } |
︙ | ︙ |
Modified src/OFFileIRIHandler.m from [624183587b] to [b18e6efaea].
︙ | ︙ | |||
1021 1022 1023 1024 1025 1026 1027 | if (IRI == nil) @throw [OFInvalidArgumentException exception]; if (![IRI.scheme isEqual: _scheme]) @throw [OFInvalidArgumentException exception]; | | < < < < < | 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 | if (IRI == nil) @throw [OFInvalidArgumentException exception]; if (![IRI.scheme isEqual: _scheme]) @throw [OFInvalidArgumentException exception]; ret = (statWrapper(IRI.fileSystemRepresentation, &s) == 0); objc_autoreleasePoolPop(pool); return ret; } - (bool)directoryExistsAtIRI: (OFIRI *)IRI |
︙ | ︙ |
Modified src/OFHTTPClient.m from [feb32daab7] to [0a2253ded6].
︙ | ︙ | |||
636 637 638 639 640 641 642 | exception: (id)exception { if (exception != nil) { [self raiseException: exception]; return; } | < < | 636 637 638 639 640 641 642 643 644 645 646 647 648 649 | exception: (id)exception { if (exception != nil) { [self raiseException: exception]; return; } if ([_client->_delegate respondsToSelector: @selector(client:didCreateTCPSocket:request:)]) [_client->_delegate client: _client didCreateTCPSocket: sock request: _request]; if ([_request.IRI.scheme caseInsensitiveCompare: @"https"] == |
︙ | ︙ |
Modified src/OFHTTPRequest.h from [f431611fce] to [163a3d1bed].
︙ | ︙ | |||
49 50 51 52 53 54 55 | } OFHTTPRequestMethod; /** * @struct OFHTTPRequestProtocolVersion OFHTTPRequest.h ObjFW/OFHTTPRequest.h * * @brief The HTTP version of the HTTP request. */ | | | 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | } OFHTTPRequestMethod; /** * @struct OFHTTPRequestProtocolVersion OFHTTPRequest.h ObjFW/OFHTTPRequest.h * * @brief The HTTP version of the HTTP request. */ typedef struct OF_BOXABLE OFHTTPRequestProtocolVersion { /** The major of the HTTP version */ unsigned char major; /** The minor of the HTTP version */ unsigned char minor; } OFHTTPRequestProtocolVersion; /** |
︙ | ︙ |
Modified src/OFMatrix4x4.h from [c303f1010a] to [0e103db2bb].
︙ | ︙ | |||
46 47 48 49 50 51 52 53 54 55 56 57 58 | * @brief Creates a new 4x4 matrix with the specified values. * * @param values A 2D array of 4x4 floats in row-major format * @return A new, autoreleased OFMatrix4x4 */ + (instancetype)matrixWithValues: (const float [_Nonnull 4][4])values; /** * @brief Initializes an already allocated 4x4 matrix with the specified values. * * @param values A 2D array of 4x4 floats in row-major format * @return An initialized OFMatrix4x4 */ | > > | > | 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | * @brief Creates a new 4x4 matrix with the specified values. * * @param values A 2D array of 4x4 floats in row-major format * @return A new, autoreleased OFMatrix4x4 */ + (instancetype)matrixWithValues: (const float [_Nonnull 4][4])values; - (instancetype)init OF_UNAVAILABLE; /** * @brief Initializes an already allocated 4x4 matrix with the specified values. * * @param values A 2D array of 4x4 floats in row-major format * @return An initialized OFMatrix4x4 */ - (instancetype)initWithValues: (const float [_Nonnull 4][4])values OF_DESIGNATED_INITIALIZER; /** * @brief Mulitplies the receiver with the specified matrix on the left side * and the receiver on the right side. * * @param matrix The matrix to multiply the receiver with */ |
︙ | ︙ |
Modified src/OFMatrix4x4.m from [77a89afbe5] to [7871015766].
︙ | ︙ | |||
33 34 35 36 37 38 39 40 41 42 43 44 45 46 | initWithValues: identityValues] autorelease]; } + (instancetype)matrixWithValues: (const float [4][4])values { return [[[self alloc] initWithValues: values] autorelease]; } - (instancetype)initWithValues: (const float [4][4])values { self = [super init]; memcpy(_values, values, sizeof(_values)); | > > > > > | 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | initWithValues: identityValues] autorelease]; } + (instancetype)matrixWithValues: (const float [4][4])values { return [[[self alloc] initWithValues: values] autorelease]; } - (instancetype)init { OF_INVALID_INIT_METHOD } - (instancetype)initWithValues: (const float [4][4])values { self = [super init]; memcpy(_values, values, sizeof(_values)); |
︙ | ︙ |
Modified src/OFMethodSignature.h from [074e9c24c2] to [a9827bf762].
︙ | ︙ | |||
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | * * @param types The ObjC types of the method * @return A new, autoreleased OFMethodSignature * @throw OFInvalidFormatException The type encoding is invalid */ + (instancetype)signatureWithObjCTypes: (const char *)types; /** * @brief Initializes an already allocated OFMethodSignature with the specified * ObjC types. * * @param types The ObjC types of the method * @return An Initialized OFMethodSignature * @throw OFInvalidFormatException The type encoding is invalid */ | > > | > | 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 | * * @param types The ObjC types of the method * @return A new, autoreleased OFMethodSignature * @throw OFInvalidFormatException The type encoding is invalid */ + (instancetype)signatureWithObjCTypes: (const char *)types; - (instancetype)init OF_UNAVAILABLE; /** * @brief Initializes an already allocated OFMethodSignature with the specified * ObjC types. * * @param types The ObjC types of the method * @return An Initialized OFMethodSignature * @throw OFInvalidFormatException The type encoding is invalid */ - (instancetype)initWithObjCTypes: (const char *)types OF_DESIGNATED_INITIALIZER; /** * @brief Returns the ObjC type for the argument at the specified index. * * @param index The index of the argument for which to return the ObjC type * @return The ObjC type for the argument at the specified index */ |
︙ | ︙ |
Modified src/OFMethodSignature.m from [e8f9b47dc1] to [a2e3c59f99].
︙ | ︙ | |||
587 588 589 590 591 592 593 594 595 596 597 598 599 600 | } @implementation OFMethodSignature + (instancetype)signatureWithObjCTypes: (const char*)types { return [[[self alloc] initWithObjCTypes: types] autorelease]; } - (instancetype)initWithObjCTypes: (const char *)types { self = [super init]; @try { size_t length; | > > > > > | 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 | } @implementation OFMethodSignature + (instancetype)signatureWithObjCTypes: (const char*)types { return [[[self alloc] initWithObjCTypes: types] autorelease]; } - (instancetype)init { OF_INVALID_INIT_METHOD } - (instancetype)initWithObjCTypes: (const char *)types { self = [super init]; @try { size_t length; |
︙ | ︙ |
Modified src/OFMutableArray.h from [731451be69] to [bb37148bf6].
︙ | ︙ | |||
49 50 51 52 53 54 55 56 57 58 59 60 61 62 | * number of objects. * * @param capacity The initial capacity for the OFMutableArray * @return A new autoreleased OFMutableArray */ + (instancetype)arrayWithCapacity: (size_t)capacity; /** * @brief Initializes an already allocated OFMutableArray with enough memory to * hold the specified number of objects. * * @param capacity The initial capacity for the OFMutableArray * @return An initialized OFMutableArray */ | > > > > > > > | | 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 | * number of objects. * * @param capacity The initial capacity for the OFMutableArray * @return A new autoreleased OFMutableArray */ + (instancetype)arrayWithCapacity: (size_t)capacity; /** * @brief Initializes an OFMutableArray with no objects. * * @return An initialized OFMutableArray */ - (instancetype)init OF_DESIGNATED_INITIALIZER; /** * @brief Initializes an already allocated OFMutableArray with enough memory to * hold the specified number of objects. * * @param capacity The initial capacity for the OFMutableArray * @return An initialized OFMutableArray */ - (instancetype)initWithCapacity: (size_t)capacity OF_DESIGNATED_INITIALIZER; /** * @brief Adds an object to the end of the array. * * @param object An object to add */ - (void)addObject: (ObjectType)object; |
︙ | ︙ |
Modified src/OFMutableArray.m from [6a1691417f] to [e4c6e41ce6].
︙ | ︙ | |||
75 76 77 78 79 80 81 82 83 84 85 86 87 88 | options); left = i + 1; } } @implementation OFPlaceholderMutableArray - (instancetype)init { return (id)[[OFConcreteMutableArray alloc] init]; } - (instancetype)initWithCapacity: (size_t)capacity { | > > > > > > | 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 | options); left = i + 1; } } @implementation OFPlaceholderMutableArray #ifdef __clang__ /* We intentionally don't call into super, so silence the warning. */ # pragma clang diagnostic push # pragma clang diagnostic ignored "-Wunknown-pragmas" # pragma clang diagnostic ignored "-Wobjc-designated-initializers" #endif - (instancetype)init { return (id)[[OFConcreteMutableArray alloc] init]; } - (instancetype)initWithCapacity: (size_t)capacity { |
︙ | ︙ | |||
119 120 121 122 123 124 125 126 127 128 129 130 131 132 | } - (instancetype)initWithObjects: (id const *)objects count: (size_t)count { return (id)[[OFConcreteMutableArray alloc] initWithObjects: objects count: count]; } OF_SINGLETON_METHODS @end @implementation OFMutableArray + (void)initialize { | > > > | 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 | } - (instancetype)initWithObjects: (id const *)objects count: (size_t)count { return (id)[[OFConcreteMutableArray alloc] initWithObjects: objects count: count]; } #ifdef __clang__ # pragma clang diagnostic pop #endif OF_SINGLETON_METHODS @end @implementation OFMutableArray + (void)initialize { |
︙ | ︙ | |||
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 | return [super alloc]; } + (instancetype)arrayWithCapacity: (size_t)capacity { return [[[self alloc] initWithCapacity: capacity] autorelease]; } - (instancetype)initWithCapacity: (size_t)capacity { OF_INVALID_INIT_METHOD } - (id)copy { return [[OFArray alloc] initWithArray: self]; } - (void)addObject: (id)object | > > > > > > > > > > > > > > > > > > > > | 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 | return [super alloc]; } + (instancetype)arrayWithCapacity: (size_t)capacity { return [[[self alloc] initWithCapacity: capacity] autorelease]; } - (instancetype)init { return [super init]; } #ifdef __clang__ /* We intentionally don't call into super, so silence the warning. */ # pragma clang diagnostic push # pragma clang diagnostic ignored "-Wunknown-pragmas" # pragma clang diagnostic ignored "-Wobjc-designated-initializers" #endif - (instancetype)initWithObjects: (id const *)objects count: (size_t)count { OF_INVALID_INIT_METHOD } - (instancetype)initWithCapacity: (size_t)capacity { OF_INVALID_INIT_METHOD } #ifdef __clang__ # pragma clang diagnostic pop #endif - (id)copy { return [[OFArray alloc] initWithArray: self]; } - (void)addObject: (id)object |
︙ | ︙ |
Modified src/OFMutableDictionary.h from [368ae1527e] to [dd4009e02f].
︙ | ︙ | |||
50 51 52 53 54 55 56 57 58 59 60 61 62 63 | * specified number of objects. * * @param capacity The initial capacity for the OFMutableDictionary * @return A new autoreleased OFMutableDictionary */ + (instancetype)dictionaryWithCapacity: (size_t)capacity; /** * @brief Initializes an already allocated OFMutableDictionary with enough * memory to hold the specified number of objects. * * @param capacity The initial capacity for the OFMutableDictionary * @return An initialized OFMutableDictionary */ | > > > > > > > | | 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 | * specified number of objects. * * @param capacity The initial capacity for the OFMutableDictionary * @return A new autoreleased OFMutableDictionary */ + (instancetype)dictionaryWithCapacity: (size_t)capacity; /** * @brief Initializes an already allocated OFMutableDictionary to be empty. * * @return An initialized OFMutableDictionary */ - (instancetype)init OF_DESIGNATED_INITIALIZER; /** * @brief Initializes an already allocated OFMutableDictionary with enough * memory to hold the specified number of objects. * * @param capacity The initial capacity for the OFMutableDictionary * @return An initialized OFMutableDictionary */ - (instancetype)initWithCapacity: (size_t)capacity OF_DESIGNATED_INITIALIZER; /** * @brief Sets an object for a key. * * A key can be any object that conforms to the OFCopying protocol. * * @param key The key to set |
︙ | ︙ |
Modified src/OFMutableDictionary.m from [c24bbf1afd] to [8a88d7dabe].
︙ | ︙ | |||
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 | return [super alloc]; } + (instancetype)dictionaryWithCapacity: (size_t)capacity { return [[[self alloc] initWithCapacity: capacity] autorelease]; } - (instancetype)initWithCapacity: (size_t)capacity { OF_INVALID_INIT_METHOD } - (void)setObject: (id)object forKey: (id)key { OF_UNRECOGNIZED_SELECTOR } - (void)setObject: (id)object forKeyedSubscript: (id)key | > > > > > > > > > > > > > > > > > > > > > | 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 | return [super alloc]; } + (instancetype)dictionaryWithCapacity: (size_t)capacity { return [[[self alloc] initWithCapacity: capacity] autorelease]; } - (instancetype)init { return [super init]; } #ifdef __clang__ /* We intentionally don't call into super, so silence the warning. */ # pragma clang diagnostic push # pragma clang diagnostic ignored "-Wunknown-pragmas" # pragma clang diagnostic ignored "-Wobjc-designated-initializers" #endif - (instancetype)initWithObjects: (id const *)objects forKeys: (id const *)keys count: (size_t)count { OF_INVALID_INIT_METHOD } - (instancetype)initWithCapacity: (size_t)capacity { OF_INVALID_INIT_METHOD } #ifdef __clang__ # pragma clang diagnostic pop #endif - (void)setObject: (id)object forKey: (id)key { OF_UNRECOGNIZED_SELECTOR } - (void)setObject: (id)object forKeyedSubscript: (id)key |
︙ | ︙ |
Modified src/OFMutableSet.h from [3d35e08a82] to [6b1991592b].
︙ | ︙ | |||
34 35 36 37 38 39 40 41 42 43 44 45 46 47 | * number of objects. * * @param capacity The initial capacity for the OFMutableSet * @return A new autoreleased OFMutableSet */ + (instancetype)setWithCapacity: (size_t)capacity; /** * @brief Initializes an already allocated OFMutableSet with enough memory to * hold the specified number of objects. * * @param capacity The initial capacity for the OFMutableSet * @return An initialized OFMutableSet */ | > > > > > > > | | 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 | * number of objects. * * @param capacity The initial capacity for the OFMutableSet * @return A new autoreleased OFMutableSet */ + (instancetype)setWithCapacity: (size_t)capacity; /** * @brief Initializes an already allocated OFMutableSet to be empty. * * @return An initialized OFMutableSet */ - (instancetype)init OF_DESIGNATED_INITIALIZER; /** * @brief Initializes an already allocated OFMutableSet with enough memory to * hold the specified number of objects. * * @param capacity The initial capacity for the OFMutableSet * @return An initialized OFMutableSet */ - (instancetype)initWithCapacity: (size_t)capacity OF_DESIGNATED_INITIALIZER; /** * @brief Adds the specified object to the set. * * @param object The object to add to the set */ - (void)addObject: (ObjectType)object; |
︙ | ︙ |
Modified src/OFMutableSet.m from [c4dda1aa5f] to [ddcd040e35].
︙ | ︙ | |||
25 26 27 28 29 30 31 32 33 34 35 36 37 38 | Class isa; } placeholder; @interface OFPlaceholderMutableSet: OFMutableSet @end @implementation OFPlaceholderMutableSet - (instancetype)init { return (id)[[OFConcreteMutableSet alloc] init]; } - (instancetype)initWithSet: (OFSet *)set { | > > > > > > | 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | Class isa; } placeholder; @interface OFPlaceholderMutableSet: OFMutableSet @end @implementation OFPlaceholderMutableSet #ifdef __clang__ /* We intentionally don't call into super, so silence the warning. */ # pragma clang diagnostic push # pragma clang diagnostic ignored "-Wunknown-pragmas" # pragma clang diagnostic ignored "-Wobjc-designated-initializers" #endif - (instancetype)init { return (id)[[OFConcreteMutableSet alloc] init]; } - (instancetype)initWithSet: (OFSet *)set { |
︙ | ︙ | |||
69 70 71 72 73 74 75 76 77 78 79 80 81 82 | arguments: arguments]; } - (instancetype)initWithCapacity: (size_t)capacity { return (id)[[OFConcreteMutableSet alloc] initWithCapacity: capacity]; } OF_SINGLETON_METHODS @end @implementation OFMutableSet + (void)initialize { | > > > | 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 | arguments: arguments]; } - (instancetype)initWithCapacity: (size_t)capacity { return (id)[[OFConcreteMutableSet alloc] initWithCapacity: capacity]; } #ifdef __clang__ # pragma clang diagnostic pop #endif OF_SINGLETON_METHODS @end @implementation OFMutableSet + (void)initialize { |
︙ | ︙ | |||
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 | return [super alloc]; } + (instancetype)setWithCapacity: (size_t)capacity { return [[[self alloc] initWithCapacity: capacity] autorelease]; } - (instancetype)initWithCapacity: (size_t)capacity { OF_INVALID_INIT_METHOD } - (id)copy { return [[OFSet alloc] initWithSet: self]; } - (void)addObject: (id)object | > > > > > > > > > > > > > > > > > > > | 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 | return [super alloc]; } + (instancetype)setWithCapacity: (size_t)capacity { return [[[self alloc] initWithCapacity: capacity] autorelease]; } - (instancetype)init { return [super init]; } #ifdef __clang__ /* We intentionally don't call into super, so silence the warning. */ # pragma clang diagnostic push # pragma clang diagnostic ignored "-Wunknown-pragmas" # pragma clang diagnostic ignored "-Wobjc-designated-initializers" #endif - (instancetype)initWithObjects: (id const *)objects count: (size_t)count { OF_INVALID_INIT_METHOD } - (instancetype)initWithCapacity: (size_t)capacity { OF_INVALID_INIT_METHOD } #ifdef __clang__ # pragma clang diagnostic pop #endif - (id)copy { return [[OFSet alloc] initWithSet: self]; } - (void)addObject: (id)object |
︙ | ︙ |
Modified src/OFMutableString.m from [19236c79ee] to [4603982353].
︙ | ︙ | |||
33 34 35 36 37 38 39 40 41 42 43 44 45 46 | Class isa; } placeholder; @interface OFPlaceholderMutableString: OFMutableString @end @implementation OFPlaceholderMutableString - (instancetype)init { return (id)[[OFMutableUTF8String alloc] init]; } - (instancetype)initWithUTF8String: (const char *)UTF8String { | > > > > > > | 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | Class isa; } placeholder; @interface OFPlaceholderMutableString: OFMutableString @end @implementation OFPlaceholderMutableString #ifdef __clang__ /* We intentionally don't call into super, so silence the warning. */ # pragma clang diagnostic push # pragma clang diagnostic ignored "-Wunknown-pragmas" # pragma clang diagnostic ignored "-Wobjc-designated-initializers" #endif - (instancetype)init { return (id)[[OFMutableUTF8String alloc] init]; } - (instancetype)initWithUTF8String: (const char *)UTF8String { |
︙ | ︙ | |||
182 183 184 185 186 187 188 189 190 191 192 193 194 195 | - (instancetype)initWithContentsOfIRI: (OFIRI *)IRI encoding: (OFStringEncoding)encoding { return (id)[[OFMutableUTF8String alloc] initWithContentsOfIRI: IRI encoding: encoding]; } OF_SINGLETON_METHODS @end @implementation OFMutableString + (void)initialize { | > > > | 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 | - (instancetype)initWithContentsOfIRI: (OFIRI *)IRI encoding: (OFStringEncoding)encoding { return (id)[[OFMutableUTF8String alloc] initWithContentsOfIRI: IRI encoding: encoding]; } #ifdef __clang__ # pragma clang diagnostic pop #endif OF_SINGLETON_METHODS @end @implementation OFMutableString + (void)initialize { |
︙ | ︙ |
Deleted src/OFNonretainedObjectValue.h version [2d93396021].
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted src/OFNonretainedObjectValue.m version [76443b4198].
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Modified src/OFNumber.h from [bb1eda01eb] to [f19e1bade2].
︙ | ︙ | |||
35 36 37 38 39 40 41 | /** @file */ /** * @class OFNumber OFNumber.h ObjFW/OFNumber.h * * @brief Provides a way to store a number in an object. */ | < < < < < < < < < < < < | 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | /** @file */ /** * @class OFNumber OFNumber.h ObjFW/OFNumber.h * * @brief Provides a way to store a number in an object. */ @interface OFNumber: OFValue <OFComparing, OFJSONRepresentation, OFMessagePackRepresentation> /** * @brief The OFNumber as a `bool`. */ @property (readonly, nonatomic) bool boolValue; /** * @brief The OFNumber as a `signed char`. |
︙ | ︙ | |||
119 120 121 122 123 124 125 | @property (readonly, nonatomic) double doubleValue; /** * @brief The OFNumber as a string. */ @property (readonly, nonatomic) OFString *stringValue; | < < | 107 108 109 110 111 112 113 114 115 116 117 118 119 120 | @property (readonly, nonatomic) double doubleValue; /** * @brief The OFNumber as a string. */ @property (readonly, nonatomic) OFString *stringValue; + (instancetype)valueWithPointer: (const void *)pointer OF_UNAVAILABLE; + (instancetype)valueWithNonretainedObject: (id)object OF_UNAVAILABLE; + (instancetype)valueWithRange: (OFRange)range OF_UNAVAILABLE; + (instancetype)valueWithPoint: (OFPoint)point OF_UNAVAILABLE; + (instancetype)valueWithSize: (OFSize)size OF_UNAVAILABLE; + (instancetype)valueWithRect: (OFRect)rect OF_UNAVAILABLE; |
︙ | ︙ | |||
232 233 234 235 236 237 238 | * @brief Creates a new OFNumber with the specified `double`. * * @param value The `double` value which the OFNumber should contain * @return A new autoreleased OFNumber */ + (instancetype)numberWithDouble: (double)value; | < < < < | 218 219 220 221 222 223 224 225 226 227 228 229 230 231 | * @brief Creates a new OFNumber with the specified `double`. * * @param value The `double` value which the OFNumber should contain * @return A new autoreleased OFNumber */ + (instancetype)numberWithDouble: (double)value; /** * @brief Initializes an already allocated OFNumber with the specified `bool`. * * @param value The `bool` value which the OFNumber should contain * @return An initialized OFNumber */ - (instancetype)initWithBool: (bool)value; |
︙ | ︙ |
Modified src/OFNumber.m from [8fe1f42701] to [b5f05b79e3].
︙ | ︙ | |||
9 10 11 12 13 14 15 | * * 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. */ | < < > > < | < < < < < < < < < < < < < < < < < < < < | | | | | | | < < < < < < < < < < < < < < | 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 | * * 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. */ #include "config.h" #include <math.h> #import "OFNumber.h" #import "OFConcreteNumber.h" #import "OFData.h" #import "OFString.h" #import "OFTaggedPointerNumber.h" #import "OFInvalidArgumentException.h" #import "OFInvalidFormatException.h" #import "OFOutOfRangeException.h" @interface OFNumber () - (OFString *) of_JSONRepresentationWithOptions: (OFJSONRepresentationOptions)options depth: (size_t)depth; @end @interface OFPlaceholderNumber: OFNumber @end @interface OFConcreteNumberSingleton: OFConcreteNumber @end static struct { Class isa; } placeholder; #define SINGLETON(var, sel, val) \ static OFConcreteNumberSingleton *var; \ \ static void \ var##Init(void) \ { \ var = [[OFConcreteNumberSingleton alloc] sel val]; \ } SINGLETON(falseNumber, initWithBool:, false) SINGLETON(trueNumber, initWithBool:, true) SINGLETON(charZeroNumber, initWithChar:, 0) SINGLETON(shortZeroNumber, initWithShort:, 0) SINGLETON(intZeroNumber, initWithInt:, 0) SINGLETON(longZeroNumber, initWithLong:, 0) SINGLETON(longLongZeroNumber, initWithLongLong:, 0) SINGLETON(unsignedCharZeroNumber, initWithUnsignedChar:, 0) SINGLETON(unsignedShortZeroNumber, initWithUnsignedShort:, 0) SINGLETON(unsignedIntZeroNumber, initWithUnsignedInt:, 0) SINGLETON(unsignedLongZeroNumber, initWithUnsignedLong:, 0) SINGLETON(unsignedLongLongZeroNumber, initWithUnsignedLongLong:, 0) SINGLETON(floatZeroNumber, initWithFloat:, 0) SINGLETON(doubleZeroNumber, initWithDouble:, 0) #undef SINGLETON static bool isUnsigned(OFNumber *number) { switch (*number.objCType) { case 'B': case 'C': case 'S': case 'I': case 'L': case 'Q': return true; default: return false; } } static bool isSigned(OFNumber *number) { switch (*number.objCType) { case 'c': case 's': case 'i': case 'l': case 'q': return true; default: return false; } } static bool isFloat(OFNumber *number) { switch (*number.objCType) { case 'f': case 'd': return true; default: return false; } } |
︙ | ︙ | |||
166 167 168 169 170 171 172 | - (instancetype)initWithChar: (signed char)value { if (value == 0) { static OFOnceControl onceControl = OFOnceControlInitValue; OFOnce(&onceControl, charZeroNumberInit); return (id)charZeroNumber; #ifdef OF_OBJFW_RUNTIME | | | | | | | | | | | | | | | | | | | < | | | | < | | | < | | | < | | | < | | | | | | | | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | < < | < < < < < < < < < < < < < < < < | 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 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 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 | - (instancetype)initWithChar: (signed char)value { if (value == 0) { static OFOnceControl onceControl = OFOnceControlInitValue; OFOnce(&onceControl, charZeroNumberInit); return (id)charZeroNumber; #ifdef OF_OBJFW_RUNTIME } else if ((unsigned char)value <= (UINTPTR_MAX >> OFTaggedPointerNumberTagBits)) { id ret = [OFTaggedPointerNumber numberWithChar: value]; if (ret != nil) return ret; #endif } return (id)[[OFConcreteNumber alloc] initWithChar: value]; } - (instancetype)initWithShort: (short)value { if (value == 0) { static OFOnceControl onceControl = OFOnceControlInitValue; OFOnce(&onceControl, shortZeroNumberInit); return (id)shortZeroNumber; #ifdef OF_OBJFW_RUNTIME } else if ((unsigned short)value <= (UINTPTR_MAX >> OFTaggedPointerNumberTagBits)) { id ret = [OFTaggedPointerNumber numberWithShort: value]; if (ret != nil) return ret; #endif } return (id)[[OFConcreteNumber alloc] initWithShort: value]; } - (instancetype)initWithInt: (int)value { if (value == 0) { static OFOnceControl onceControl = OFOnceControlInitValue; OFOnce(&onceControl, intZeroNumberInit); return (id)intZeroNumber; #ifdef OF_OBJFW_RUNTIME } else if ((unsigned int)value <= (UINTPTR_MAX >> OFTaggedPointerNumberTagBits)) { id ret = [OFTaggedPointerNumber numberWithInt: value]; if (ret != nil) return ret; #endif } return (id)[[OFConcreteNumber alloc] initWithInt: value]; } - (instancetype)initWithLong: (long)value { if (value == 0) { static OFOnceControl onceControl = OFOnceControlInitValue; OFOnce(&onceControl, longZeroNumberInit); return (id)longZeroNumber; #ifdef OF_OBJFW_RUNTIME } else if ((unsigned long)value <= (UINTPTR_MAX >> OFTaggedPointerNumberTagBits)) { id ret = [OFTaggedPointerNumber numberWithLong: value]; if (ret != nil) return ret; #endif } return (id)[[OFConcreteNumber alloc] initWithLong: value]; } - (instancetype)initWithLongLong: (long long)value { if (value == 0) { static OFOnceControl onceControl = OFOnceControlInitValue; OFOnce(&onceControl, longLongZeroNumberInit); return (id)longLongZeroNumber; #ifdef OF_OBJFW_RUNTIME } else if ((unsigned long long)value <= (UINTPTR_MAX >> OFTaggedPointerNumberTagBits)) { id ret = [OFTaggedPointerNumber numberWithLongLong: value]; if (ret != nil) return ret; #endif } return (id)[[OFConcreteNumber alloc] initWithLongLong: value]; } - (instancetype)initWithUnsignedChar: (unsigned char)value { if (value == 0) { static OFOnceControl onceControl = OFOnceControlInitValue; OFOnce(&onceControl, unsignedCharZeroNumberInit); return (id)unsignedCharZeroNumber; #ifdef OF_OBJFW_RUNTIME } else if (value <= (UINTPTR_MAX >> OFTaggedPointerNumberTagBits)) { id ret = [OFTaggedPointerNumber numberWithUnsignedChar: value]; if (ret != nil) return ret; #endif } return (id)[[OFConcreteNumber alloc] initWithUnsignedChar: value]; } - (instancetype)initWithUnsignedShort: (unsigned short)value { if (value == 0) { static OFOnceControl onceControl = OFOnceControlInitValue; OFOnce(&onceControl, unsignedShortZeroNumberInit); return (id)unsignedShortZeroNumber; #ifdef OF_OBJFW_RUNTIME } else if (value <= (UINTPTR_MAX >> OFTaggedPointerNumberTagBits)) { id ret = [OFTaggedPointerNumber numberWithUnsignedShort: value]; if (ret != nil) return ret; #endif } return (id)[[OFConcreteNumber alloc] initWithUnsignedShort: value]; } - (instancetype)initWithUnsignedInt: (unsigned int)value { if (value == 0) { static OFOnceControl onceControl = OFOnceControlInitValue; OFOnce(&onceControl, unsignedIntZeroNumberInit); return (id)unsignedIntZeroNumber; #ifdef OF_OBJFW_RUNTIME } else if (value <= (UINTPTR_MAX >> OFTaggedPointerNumberTagBits)) { id ret = [OFTaggedPointerNumber numberWithUnsignedInt: value]; if (ret != nil) return ret; #endif } return (id)[[OFConcreteNumber alloc] initWithUnsignedInt: value]; } - (instancetype)initWithUnsignedLong: (unsigned long)value { if (value == 0) { static OFOnceControl onceControl = OFOnceControlInitValue; OFOnce(&onceControl, unsignedLongZeroNumberInit); return (id)unsignedLongZeroNumber; #ifdef OF_OBJFW_RUNTIME } else if (value <= (UINTPTR_MAX >> OFTaggedPointerNumberTagBits)) { id ret = [OFTaggedPointerNumber numberWithUnsignedLong: value]; if (ret != nil) return ret; #endif } return (id)[[OFConcreteNumber alloc] initWithUnsignedLong: value]; } - (instancetype)initWithUnsignedLongLong: (unsigned long long)value { if (value == 0) { static OFOnceControl onceControl = OFOnceControlInitValue; OFOnce(&onceControl, unsignedLongLongZeroNumberInit); return (id)unsignedLongLongZeroNumber; #ifdef OF_OBJFW_RUNTIME } else if (value <= (UINTPTR_MAX >> OFTaggedPointerNumberTagBits)) { id ret = [OFTaggedPointerNumber numberWithUnsignedLongLong: value]; if (ret != nil) return ret; #endif } return (id)[[OFConcreteNumber alloc] initWithUnsignedLongLong: value]; } - (instancetype)initWithFloat: (float)value { if (value == 0) { static OFOnceControl onceControl = OFOnceControlInitValue; OFOnce(&onceControl, floatZeroNumberInit); return (id)floatZeroNumber; } return (id)[[OFConcreteNumber alloc] initWithFloat: value]; } - (instancetype)initWithDouble: (double)value { if (value == 0) { static OFOnceControl onceControl = OFOnceControlInitValue; OFOnce(&onceControl, doubleZeroNumberInit); return (id)doubleZeroNumber; } return (id)[[OFConcreteNumber alloc] initWithDouble: value]; } #ifdef __clang__ # pragma clang diagnostic pop #endif OF_SINGLETON_METHODS @end @implementation OFConcreteNumberSingleton OF_SINGLETON_METHODS @end @implementation OFNumber + (void)initialize { if (self == [OFNumber class]) object_setClass((id)&placeholder, [OFPlaceholderNumber class]); } + (instancetype)alloc { if (self == [OFNumber class]) return (id)&placeholder; return [super alloc]; } + (instancetype)valueWithPointer: (const void *)pointer { OF_UNRECOGNIZED_SELECTOR } + (instancetype)valueWithNonretainedObject: (id)object { |
︙ | ︙ | |||
587 588 589 590 591 592 593 | } + (instancetype)numberWithDouble: (double)value { return [[[self alloc] initWithDouble: value] autorelease]; } | < < < < < < < < < < < < | < < < < < < < | < < < | < < < < < | < < < < < | < < < < < < < | < < < | < < < < < < < | < < < < < | < < < < < | | < | < < | < | | < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | < < < < < | < < | < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < > | < < < < < < < | < < < < < < < | 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 | } + (instancetype)numberWithDouble: (double)value { return [[[self alloc] initWithDouble: value] autorelease]; } - (instancetype)initWithBool: (bool)value { return [self initWithBytes: &value objCType: @encode(bool)]; } - (instancetype)initWithChar: (signed char)value { return [self initWithBytes: &value objCType: @encode(signed char)]; } - (instancetype)initWithShort: (short)value { return [self initWithBytes: &value objCType: @encode(short)]; } - (instancetype)initWithInt: (int)value { return [self initWithBytes: &value objCType: @encode(int)]; } - (instancetype)initWithLong: (long)value { return [self initWithBytes: &value objCType: @encode(long)]; } - (instancetype)initWithLongLong: (long long)value { return [self initWithBytes: &value objCType: @encode(long long)]; } - (instancetype)initWithUnsignedChar: (unsigned char)value { return [self initWithBytes: &value objCType: @encode(unsigned char)]; } - (instancetype)initWithUnsignedShort: (unsigned short)value { return [self initWithBytes: &value objCType: @encode(unsigned short)]; } - (instancetype)initWithUnsignedInt: (unsigned int)value { return [self initWithBytes: &value objCType: @encode(unsigned int)]; } - (instancetype)initWithUnsignedLong: (unsigned long)value { return [self initWithBytes: &value objCType: @encode(unsigned long)]; } - (instancetype)initWithUnsignedLongLong: (unsigned long long)value { return [self initWithBytes: &value objCType: @encode(unsigned long long)]; } - (instancetype)initWithFloat: (float)value { return [self initWithBytes: &value objCType: @encode(float)]; } - (instancetype)initWithDouble: (double)value { return [self initWithBytes: &value objCType: @encode(double)]; } - (long long)longLongValue { OF_UNRECOGNIZED_SELECTOR } - (unsigned long long)unsignedLongLongValue { OF_UNRECOGNIZED_SELECTOR } - (double)doubleValue { OF_UNRECOGNIZED_SELECTOR } - (bool)boolValue { return (bool)self.unsignedLongLongValue; } |
︙ | ︙ | |||
992 993 994 995 996 997 998 | - (OFString *)description { return [self stringValue]; } - (OFString *)stringValue { | | | 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 | - (OFString *)description { return [self stringValue]; } - (OFString *)stringValue { if (self.objCType[0] == 'B' && self.objCType[1] == '\0') return (self.boolValue ? @"true" : @"false"); if (isFloat(self)) return [OFString stringWithFormat: @"%g", self.doubleValue]; if (isSigned(self)) return [OFString stringWithFormat: @"%lld", self.longLongValue]; if (isUnsigned(self)) return [OFString stringWithFormat: @"%llu", |
︙ | ︙ | |||
1022 1023 1024 1025 1026 1027 1028 | - (OFString *) of_JSONRepresentationWithOptions: (OFJSONRepresentationOptions)options depth: (size_t)depth { double doubleValue; | | > > > | 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 | - (OFString *) of_JSONRepresentationWithOptions: (OFJSONRepresentationOptions)options depth: (size_t)depth { double doubleValue; if (self.objCType[0] == 'B' && self.objCType[1] == '\0') return (self.boolValue ? @"true" : @"false"); doubleValue = self.doubleValue; if (isinf(doubleValue)) { if (options & OFJSONRepresentationOptionJSON5) { if (doubleValue > 0) return @"Infinity"; else return @"-Infinity"; } else @throw [OFInvalidArgumentException exception]; } return self.description; } - (OFData *)messagePackRepresentation { OFMutableData *data; const char *typeEncoding = self.objCType; if (typeEncoding[0] == '\0' || typeEncoding[1] != '\0') @throw [OFInvalidFormatException exception]; if (*typeEncoding == 'B') { uint8_t type = (self.boolValue ? 0xC3 : 0xC2); data = [OFMutableData dataWithItems: &type count: 1]; } else if (*typeEncoding == 'f') { uint8_t type = 0xCA; float tmp = OFToBigEndianFloat(self.floatValue); |
︙ | ︙ |
Modified src/OFObject.h from [2c787e015d] to [6d396e3db6].
︙ | ︙ | |||
99 100 101 102 103 104 105 | } OFByteOrder; /** * @struct OFRange OFObject.h ObjFW/OFObject.h * * @brief A range. */ | | | 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 | } OFByteOrder; /** * @struct OFRange OFObject.h ObjFW/OFObject.h * * @brief A range. */ typedef struct OF_BOXABLE OFRange { /** The start of the range */ size_t location; /** The length of the range */ size_t length; } OFRange; /** |
︙ | ︙ | |||
150 151 152 153 154 155 156 | typedef double OFTimeInterval; /** * @struct OFPoint OFObject.h ObjFW/OFObject.h * * @brief A point in 2D space. */ | | | 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 | typedef double OFTimeInterval; /** * @struct OFPoint OFObject.h ObjFW/OFObject.h * * @brief A point in 2D space. */ typedef struct OF_BOXABLE OFPoint { /** The x coordinate of the point */ float x; /** The y coordinate of the point */ float y; } OFPoint; /** |
︙ | ︙ | |||
196 197 198 199 200 201 202 | } /** * @struct OFSize OFObject.h ObjFW/OFObject.h * * @brief A size. */ | | | 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 | } /** * @struct OFSize OFObject.h ObjFW/OFObject.h * * @brief A size. */ typedef struct OF_BOXABLE OFSize { /** The width of the size */ float width; /** The height of the size */ float height; } OFSize; /** |
︙ | ︙ | |||
242 243 244 245 246 247 248 | } /** * @struct OFRect OFObject.h ObjFW/OFObject.h * * @brief A rectangle. */ | | | 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 | } /** * @struct OFRect OFObject.h ObjFW/OFObject.h * * @brief A rectangle. */ typedef struct OF_BOXABLE OFRect { /** The point from where the rectangle originates */ OFPoint origin; /** The size of the rectangle */ OFSize size; } OFRect; /** |
︙ | ︙ | |||
293 294 295 296 297 298 299 | } /** * @struct OFVector3D OFObject.h ObjFW/OFObject.h * * @brief A vector in 3D space. */ | | | 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 | } /** * @struct OFVector3D OFObject.h ObjFW/OFObject.h * * @brief A vector in 3D space. */ typedef struct OF_BOXABLE OFVector3D { /** The x coordinate of the vector */ float x; /** The y coordinate of the vector */ float y; /** The z coordinate of the vector */ float z; } OFVector3D; |
︙ | ︙ | |||
345 346 347 348 349 350 351 | } /** * @struct OFVector4D OFObject.h ObjFW/OFObject.h * * @brief A vector in 4D space. */ | | | 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 | } /** * @struct OFVector4D OFObject.h ObjFW/OFObject.h * * @brief A vector in 4D space. */ typedef struct OF_BOXABLE OFVector4D { /** The x coordinate of the vector */ float x; /** The y coordinate of the vector */ float y; /** The z coordinate of the vector */ float z; /** The w coordinate of the vector */ |
︙ | ︙ |
Deleted src/OFPointValue.h version [fd8f67e118].
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted src/OFPointValue.m version [5526d367ab].
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted src/OFPointerValue.h version [343eb8ca5c].
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted src/OFPointerValue.m version [4e2634ad6c].
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted src/OFRangeValue.h version [846202afc6].
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted src/OFRangeValue.m version [801e11f4cf].
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted src/OFRectValue.h version [acbebbc020].
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted src/OFRectValue.m version [8879e2c8da].
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Modified src/OFSet.h from [b6b0fc8990] to [27d5fba5ea].
︙ | ︙ | |||
113 114 115 116 117 118 119 120 121 122 123 124 125 126 | * @param objects An array of objects for the set * @param count The number of objects in the specified array * @return A new, autoreleased set with the specified objects */ + (instancetype)setWithObjects: (ObjectType const _Nonnull *_Nonnull)objects count: (size_t)count; /** * @brief Initializes an already allocated set with the specified set. * * @param set The set to initialize the set with * @return An initialized set with the specified set */ - (instancetype)initWithSet: (OFSet OF_GENERIC(ObjectType) *)set; | > > > > > > > | 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 | * @param objects An array of objects for the set * @param count The number of objects in the specified array * @return A new, autoreleased set with the specified objects */ + (instancetype)setWithObjects: (ObjectType const _Nonnull *_Nonnull)objects count: (size_t)count; /** * @brief Initializes an already allocated set to be empty. * * @return An initialized set */ - (instancetype)init OF_DESIGNATED_INITIALIZER; /** * @brief Initializes an already allocated set with the specified set. * * @param set The set to initialize the set with * @return An initialized set with the specified set */ - (instancetype)initWithSet: (OFSet OF_GENERIC(ObjectType) *)set; |
︙ | ︙ | |||
156 157 158 159 160 161 162 | * @brief Initializes an already allocated set with the specified objects. * * @param objects An array of objects for the set * @param count The number of objects in the specified array * @return An initialized set with the specified objects */ - (instancetype)initWithObjects: (ObjectType const _Nonnull *_Nonnull)objects | | | 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 | * @brief Initializes an already allocated set with the specified objects. * * @param objects An array of objects for the set * @param count The number of objects in the specified array * @return An initialized set with the specified objects */ - (instancetype)initWithObjects: (ObjectType const _Nonnull *_Nonnull)objects count: (size_t)count OF_DESIGNATED_INITIALIZER; /** * @brief Returns an OFEnumerator to enumerate through all objects of the set. * * @return An OFEnumerator to enumerate through all objects of the set */ - (OFEnumerator OF_GENERIC(ObjectType) *)objectEnumerator; |
︙ | ︙ |
Modified src/OFSet.m from [cf7d351eda] to [8d2f3f00f2].
︙ | ︙ | |||
28 29 30 31 32 33 34 35 36 37 38 39 40 41 | Class isa; } placeholder; @interface OFPlaceholderSet: OFSet @end @implementation OFPlaceholderSet - (instancetype)init { return (id)[[OFConcreteSet alloc] init]; } - (instancetype)initWithSet: (OFSet *)set { | > > > > > > | 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | Class isa; } placeholder; @interface OFPlaceholderSet: OFSet @end @implementation OFPlaceholderSet #ifdef __clang__ /* We intentionally don't call into super, so silence the warning. */ # pragma clang diagnostic push # pragma clang diagnostic ignored "-Wunknown-pragmas" # pragma clang diagnostic ignored "-Wobjc-designated-initializers" #endif - (instancetype)init { return (id)[[OFConcreteSet alloc] init]; } - (instancetype)initWithSet: (OFSet *)set { |
︙ | ︙ | |||
67 68 69 70 71 72 73 74 75 76 77 78 79 80 | } - (instancetype)initWithObject: (id)firstObject arguments: (va_list)arguments { return (id)[[OFConcreteSet alloc] initWithObject: firstObject arguments: arguments]; } OF_SINGLETON_METHODS @end @implementation OFSet + (void)initialize { | > > > | 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | } - (instancetype)initWithObject: (id)firstObject arguments: (va_list)arguments { return (id)[[OFConcreteSet alloc] initWithObject: firstObject arguments: arguments]; } #ifdef __clang__ # pragma clang diagnostic pop #endif OF_SINGLETON_METHODS @end @implementation OFSet + (void)initialize { |
︙ | ︙ | |||
140 141 142 143 144 145 146 | } return [super init]; } - (instancetype)initWithSet: (OFSet *)set { | > > | > > > | > > > > > > > > > > > > > > > > > > > > > > > > > | > > > > > > | > > > > > > > > > > > > > > > > > > > | > > > > > > > > > > > > > > > > > > > > > > > > > > | 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 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 | } return [super init]; } - (instancetype)initWithSet: (OFSet *)set { id *objects = NULL; size_t count; @try { void *pool = objc_autoreleasePoolPush(); size_t i = 0; count = set.count; objects = OFAllocMemory(count, sizeof(id)); for (id object in set) { OFEnsure(i < count); objects[i++] = object; } objc_autoreleasePoolPop(pool); } @catch (id e) { OFFreeMemory(objects); [self release]; @throw e; } @try { return [self initWithObjects: objects count: count]; } @finally { OFFreeMemory(objects); } } - (instancetype)initWithArray: (OFArray *)array { void *pool = objc_autoreleasePoolPush(); size_t count; const id *objects; @try { count = array.count; objects = array.objects; } @catch (id e) { [self release]; @throw e; } self = [self initWithObjects: objects count: count]; objc_autoreleasePoolPop(pool); return self; } #ifdef __clang__ /* We intentionally don't call into super, so silence the warning. */ # pragma clang diagnostic push # pragma clang diagnostic ignored "-Wunknown-pragmas" # pragma clang diagnostic ignored "-Wobjc-designated-initializers" #endif - (instancetype)initWithObjects: (id const *)objects count: (size_t)count { OF_INVALID_INIT_METHOD } #ifdef __clang__ # pragma clang diagnostic pop #endif - (instancetype)initWithObjects: (id)firstObject, ... { id ret; va_list arguments; va_start(arguments, firstObject); ret = [self initWithObject: firstObject arguments: arguments]; va_end(arguments); return ret; } - (instancetype)initWithObject: (id)firstObject arguments: (va_list)arguments { size_t count = 1; va_list argumentsCopy; id *objects; if (firstObject == nil) return [self init]; va_copy(argumentsCopy, arguments); while (va_arg(argumentsCopy, id) != nil) count++; @try { objects = OFAllocMemory(count, sizeof(id)); } @catch (id e) { [self release]; @throw e; } @try { objects[0] = firstObject; for (size_t i = 1; i < count; i++) { objects[i] = va_arg(arguments, id); OFEnsure(objects[i] != nil); } return [self initWithObjects: objects count: count]; } @finally { OFFreeMemory(objects); } } - (size_t)count { OF_UNRECOGNIZED_SELECTOR } |
︙ | ︙ |
Deleted src/OFSizeValue.h version [2412c94f4a].
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted src/OFSizeValue.m version [664c2dc1a6].
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Modified src/OFSocket.h from [ef7090ccb7] to [39b53adb69].
︙ | ︙ | |||
175 176 177 178 179 180 181 | #endif /** * @struct OFSocketAddress OFSocket.h ObjFW/OFSocket.h * * @brief A struct which represents a host / port pair for a socket. */ | | | 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 | #endif /** * @struct OFSocketAddress OFSocket.h ObjFW/OFSocket.h * * @brief A struct which represents a host / port pair for a socket. */ typedef struct OF_BOXABLE OFSocketAddress { OFSocketAddressFamily family; /* * We can't use struct sockaddr as it can contain variable length * arrays. */ union { struct sockaddr_in in; |
︙ | ︙ |
Added src/OFStrFTime.h version [c0c458ef48].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | /* * Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in * the packaging of this file. * * 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. */ #ifndef __STDC_LIMIT_MACROS # define __STDC_LIMIT_MACROS #endif #ifndef __STDC_CONSTANT_MACROS # define __STDC_CONSTANT_MACROS #endif #include <time.h> #import "macros.h" OF_ASSUME_NONNULL_BEGIN #ifdef __cplusplus extern "C" { #endif extern size_t OFStrFTime(char *buffer, size_t bufferLen, const char *format, struct tm *tm, short tz); #ifdef __cplusplus } #endif OF_ASSUME_NONNULL_END |
Added src/OFStrFTime.m version [6b4b50f001].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 | /* * Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in * the packaging of this file. * * 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. */ #include "config.h" #include <string.h> #include <time.h> #import "OFStrFTime.h" #import "macros.h" static const char weekDays[7][4] = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" }; static const char monthNames[12][4] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }; size_t OFStrFTime(char *buffer, size_t bufferLen, const char *format, struct tm *tm, short tz) { enum { stateSearchConversionSpecifier, stateInConversionSpecifier } state = stateSearchConversionSpecifier; size_t j, formatLen; if (bufferLen == 0) return 0; formatLen = strlen(format); j = 0; for (size_t i = 0; i < formatLen; i++) { switch (state) { case stateSearchConversionSpecifier: if (format[i] == '%') state = stateInConversionSpecifier; else { if (j >= bufferLen) return 0; buffer[j++] = format[i]; } break; case stateInConversionSpecifier:; const char *appendFormat; unsigned int value = 0; char append[5]; int appendLen; switch (format[i]) { case '%': appendFormat = "%%"; break; case 'a': if (tm->tm_wday > 6) return 0; appendFormat = weekDays[tm->tm_wday]; break; case 'b': if (tm->tm_mon > 11) return 0; appendFormat = monthNames[tm->tm_mon]; break; case 'd': appendFormat = "%02u"; value = tm->tm_mday; break; case 'e': appendFormat = "%2u"; value = tm->tm_mday; break; case 'H': appendFormat = "%02u"; value = tm->tm_hour; break; case 'M': appendFormat = "%02u"; value = tm->tm_min; break; case 'm': appendFormat = "%02u"; value = tm->tm_mon + 1; break; case 'n': appendFormat = "\n"; break; case 'S': appendFormat = "%02u"; value = tm->tm_sec; break; case 't': appendFormat = "\t"; break; case 'Y': appendFormat = "%4u"; value = tm->tm_year + 1900; break; case 'y': appendFormat = "%02u"; value = tm->tm_year; while (value > 100) value -= 100; break; case 'z': if (tz == 0) appendFormat = "Z"; else if (tz >= 0) { appendFormat = "+%04u"; value = tz; } else { appendFormat = "-%04u"; value = -tz; } value = (value / 60) * 100 + (value % 60); break; default: return 0; } appendLen = snprintf(append, sizeof(append), appendFormat, value); if (appendLen < 0 || (size_t)appendLen >= sizeof(append)) return 0; if (bufferLen - j < (size_t)appendLen) return 0; memcpy(buffer + j, append, appendLen); j += appendLen; state = stateSearchConversionSpecifier; } } if (j >= bufferLen) return 0; buffer[j] = 0; return j; } |
Modified src/OFStrPTime.m from [998c03b4a3] to [92f937165d].
︙ | ︙ | |||
13 14 15 16 17 18 19 | * file. */ #include "config.h" #include <string.h> | < | | 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | * file. */ #include "config.h" #include <string.h> #import "OFStrPTime.h" #import "macros.h" const char * OFStrPTime(const char *buffer, const char *format, struct tm *tm, short *tz) { enum { stateSearchConversionSpecifier, |
︙ | ︙ |
Modified src/OFString.h from [9fa7a96c12] to [d0bd857da9].
︙ | ︙ | |||
262 263 264 265 266 267 268 | @property (readonly, nonatomic) OFString *stringByDeletingTrailingWhitespaces; /** * @brief The string with leading and trailing whitespaces deleted. */ @property (readonly, nonatomic) OFString *stringByDeletingEnclosingWhitespaces; | < < < < < < < < < < < < < | 262 263 264 265 266 267 268 269 270 271 272 273 274 275 | @property (readonly, nonatomic) OFString *stringByDeletingTrailingWhitespaces; /** * @brief The string with leading and trailing whitespaces deleted. */ @property (readonly, nonatomic) OFString *stringByDeletingEnclosingWhitespaces; #if defined(OF_WINDOWS) || defined(DOXYGEN) /** * @brief The string with the Windows Environment Strings expanded. */ @property (readonly, nonatomic) OFString *stringByExpandingWindowsEnvironmentStrings; #endif |
︙ | ︙ | |||
562 563 564 565 566 567 568 569 570 571 572 573 574 575 | * @param encoding The encoding to assume * @return A new autoreleased OFString * @throw OFInvalidEncodingException The string is not in the specified encoding */ + (instancetype)stringWithContentsOfIRI: (OFIRI *)IRI encoding: (OFStringEncoding)encoding; /** * @brief Initializes an already allocated OFString from a UTF-8 encoded C * string. * * @param UTF8String A UTF-8 encoded C string to initialize the OFString with * @return An initialized OFString * @throw OFInvalidEncodingException The string is not properly UTF-8-encoded | > > > > > > > | 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 | * @param encoding The encoding to assume * @return A new autoreleased OFString * @throw OFInvalidEncodingException The string is not in the specified encoding */ + (instancetype)stringWithContentsOfIRI: (OFIRI *)IRI encoding: (OFStringEncoding)encoding; /** * @brief Initializes an already allocated OFString to be empty. * * @return An initialized OFString */ - (instancetype)init OF_DESIGNATED_INITIALIZER; /** * @brief Initializes an already allocated OFString from a UTF-8 encoded C * string. * * @param UTF8String A UTF-8 encoded C string to initialize the OFString with * @return An initialized OFString * @throw OFInvalidEncodingException The string is not properly UTF-8-encoded |
︙ | ︙ |
Modified src/OFString.m from [e84d292643] to [70fe1f9064].
︙ | ︙ | |||
342 343 344 345 346 347 348 | size_t length = strlen(string); char *copy = (char *)OFAllocMemory(1, length + 1); memcpy(copy, string, length + 1); return copy; } | < | < < < < < < | < < < | < < < < | < < < < < < | < | < < < < | 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 | size_t length = strlen(string); char *copy = (char *)OFAllocMemory(1, length + 1); memcpy(copy, string, length + 1); return copy; } @implementation OFPlaceholderString #ifdef __clang__ /* We intentionally don't call into super, so silence the warning. */ # pragma clang diagnostic push # pragma clang diagnostic ignored "-Wunknown-pragmas" # pragma clang diagnostic ignored "-Wobjc-designated-initializers" #endif - (instancetype)init { return (id)[[OFUTF8String alloc] init]; } - (instancetype)initWithUTF8String: (const char *)UTF8String { |
︙ | ︙ | |||
587 588 589 590 591 592 593 594 595 596 597 598 599 600 | - (instancetype)initWithContentsOfIRI: (OFIRI *)IRI encoding: (OFStringEncoding)encoding { return (id)[[OFUTF8String alloc] initWithContentsOfIRI: IRI encoding: encoding]; } OF_SINGLETON_METHODS @end @implementation OFString + (void)initialize { | > > > | 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 | - (instancetype)initWithContentsOfIRI: (OFIRI *)IRI encoding: (OFStringEncoding)encoding { return (id)[[OFUTF8String alloc] initWithContentsOfIRI: IRI encoding: encoding]; } #ifdef __clang__ # pragma clang diagnostic pop #endif OF_SINGLETON_METHODS @end @implementation OFString + (void)initialize { |
︙ | ︙ | |||
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 | encoding: (OFStringEncoding)encoding { return [self initWithCString: cString encoding: encoding length: strlen(cString)]; } - (instancetype)initWithCString: (const char *)cString encoding: (OFStringEncoding)encoding length: (size_t)cStringLength { OF_INVALID_INIT_METHOD } - (instancetype)initWithData: (OFData *)data encoding: (OFStringEncoding)encoding { @try { if (data.itemSize != 1) @throw [OFInvalidArgumentException exception]; } @catch (id e) { [self release]; @throw e; } self = [self initWithCString: data.items encoding: encoding length: data.count]; return self; } - (instancetype)initWithString: (OFString *)string { OF_INVALID_INIT_METHOD } - (instancetype)initWithCharacters: (const OFUnichar *)string length: (size_t)length { OF_INVALID_INIT_METHOD } - (instancetype)initWithUTF16String: (const OFChar16 *)string { return [self initWithUTF16String: string length: OFUTF16StringLength(string) byteOrder: OFByteOrderNative]; } | > > > > > > > > > > > > > > > > > > | 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 | encoding: (OFStringEncoding)encoding { return [self initWithCString: cString encoding: encoding length: strlen(cString)]; } #ifdef __clang__ /* We intentionally don't call into super, so silence the warning. */ # pragma clang diagnostic push # pragma clang diagnostic ignored "-Wunknown-pragmas" # pragma clang diagnostic ignored "-Wobjc-designated-initializers" #endif - (instancetype)initWithCString: (const char *)cString encoding: (OFStringEncoding)encoding length: (size_t)cStringLength { OF_INVALID_INIT_METHOD } #ifdef __clang__ # pragma clang diagnostic pop #endif - (instancetype)initWithData: (OFData *)data encoding: (OFStringEncoding)encoding { @try { if (data.itemSize != 1) @throw [OFInvalidArgumentException exception]; } @catch (id e) { [self release]; @throw e; } self = [self initWithCString: data.items encoding: encoding length: data.count]; return self; } #ifdef __clang__ /* We intentionally don't call into super, so silence the warning. */ # pragma clang diagnostic push # pragma clang diagnostic ignored "-Wunknown-pragmas" # pragma clang diagnostic ignored "-Wobjc-designated-initializers" #endif - (instancetype)initWithString: (OFString *)string { OF_INVALID_INIT_METHOD } - (instancetype)initWithCharacters: (const OFUnichar *)string length: (size_t)length { OF_INVALID_INIT_METHOD } #ifdef __clang__ # pragma clang diagnostic pop #endif - (instancetype)initWithUTF16String: (const OFChar16 *)string { return [self initWithUTF16String: string length: OFUTF16StringLength(string) byteOrder: OFByteOrderNative]; } |
︙ | ︙ | |||
902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 | byteOrder: (OFByteOrder)byteOrder { return [self initWithUTF16String: string length: OFUTF16StringLength(string) byteOrder: byteOrder]; } - (instancetype)initWithUTF16String: (const OFChar16 *)string length: (size_t)length byteOrder: (OFByteOrder)byteOrder { OF_INVALID_INIT_METHOD } - (instancetype)initWithUTF32String: (const OFChar32 *)string { return [self initWithUTF32String: string length: OFUTF32StringLength(string) byteOrder: OFByteOrderNative]; } | > > > > > > > > > | 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 | byteOrder: (OFByteOrder)byteOrder { return [self initWithUTF16String: string length: OFUTF16StringLength(string) byteOrder: byteOrder]; } #ifdef __clang__ /* We intentionally don't call into super, so silence the warning. */ # pragma clang diagnostic push # pragma clang diagnostic ignored "-Wunknown-pragmas" # pragma clang diagnostic ignored "-Wobjc-designated-initializers" #endif - (instancetype)initWithUTF16String: (const OFChar16 *)string length: (size_t)length byteOrder: (OFByteOrder)byteOrder { OF_INVALID_INIT_METHOD } #ifdef __clang__ # pragma clang diagnostic pop #endif - (instancetype)initWithUTF32String: (const OFChar32 *)string { return [self initWithUTF32String: string length: OFUTF32StringLength(string) byteOrder: OFByteOrderNative]; } |
︙ | ︙ | |||
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 | byteOrder: (OFByteOrder)byteOrder { return [self initWithUTF32String: string length: OFUTF32StringLength(string) byteOrder: byteOrder]; } - (instancetype)initWithUTF32String: (const OFChar32 *)string length: (size_t)length byteOrder: (OFByteOrder)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: OFStringEncodingUTF8]; } - (instancetype)initWithContentsOfFile: (OFString *)path encoding: (OFStringEncoding)encoding { | > > > > > > > > > > > > > > > > > > < < < < | < < | < < < < < < < < | < | < < < < < < < < < < < < < < < < < < | < < < < | < > | 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 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 | byteOrder: (OFByteOrder)byteOrder { return [self initWithUTF32String: string length: OFUTF32StringLength(string) byteOrder: byteOrder]; } #ifdef __clang__ /* We intentionally don't call into super, so silence the warning. */ # pragma clang diagnostic push # pragma clang diagnostic ignored "-Wunknown-pragmas" # pragma clang diagnostic ignored "-Wobjc-designated-initializers" #endif - (instancetype)initWithUTF32String: (const OFChar32 *)string length: (size_t)length byteOrder: (OFByteOrder)byteOrder { OF_INVALID_INIT_METHOD } #ifdef __clang__ # pragma clang diagnostic pop #endif - (instancetype)initWithFormat: (OFConstantString *)format, ... { id ret; va_list arguments; va_start(arguments, format); ret = [self initWithFormat: format arguments: arguments]; va_end(arguments); return ret; } #ifdef __clang__ /* We intentionally don't call into super, so silence the warning. */ # pragma clang diagnostic push # pragma clang diagnostic ignored "-Wunknown-pragmas" # pragma clang diagnostic ignored "-Wobjc-designated-initializers" #endif - (instancetype)initWithFormat: (OFConstantString *)format arguments: (va_list)arguments { OF_INVALID_INIT_METHOD } #ifdef __clang__ # pragma clang diagnostic pop #endif #ifdef OF_HAVE_FILES - (instancetype)initWithContentsOfFile: (OFString *)path { return [self initWithContentsOfFile: path encoding: OFStringEncodingUTF8]; } - (instancetype)initWithContentsOfFile: (OFString *)path encoding: (OFStringEncoding)encoding { void *pool = objc_autoreleasePoolPush(); OFIRI *IRI; @try { IRI = [OFIRI fileIRIWithPath: path]; } @catch (id e) { [self release]; @throw e; } self = [self initWithContentsOfIRI: IRI encoding: encoding]; objc_autoreleasePoolPop(pool); return self; } #endif - (instancetype)initWithContentsOfIRI: (OFIRI *)IRI { |
︙ | ︙ | |||
2594 2595 2596 2597 2598 2599 2600 | [data retain]; objc_autoreleasePoolPop(pool); return [data autorelease]; } | < < < < < < < < < < < < < < | 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 | [data retain]; objc_autoreleasePoolPop(pool); return [data autorelease]; } #ifdef OF_WINDOWS - (OFString *)stringByExpandingWindowsEnvironmentStrings { if ([OFSystemInfo isWindowsNT]) { wchar_t buffer[512]; size_t length; |
︙ | ︙ |
Modified src/OFTaggedPointerColor.h from [ee19a5ec0d] to [10e58a16ea].
︙ | ︙ | |||
15 16 17 18 19 20 21 | #import "OFColor.h" OF_ASSUME_NONNULL_BEGIN #ifdef OF_OBJFW_RUNTIME @interface OFTaggedPointerColor: OFColor | | | | | 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | #import "OFColor.h" OF_ASSUME_NONNULL_BEGIN #ifdef OF_OBJFW_RUNTIME @interface OFTaggedPointerColor: OFColor + (OFTaggedPointerColor *)colorWithRed: (uint8_t)red green: (uint8_t)green blue: (uint8_t)blue; @end #endif OF_ASSUME_NONNULL_END |
Modified src/OFTaggedPointerColor.m from [c4dd78fccc] to [0651eb80cd].
︙ | ︙ | |||
23 24 25 26 27 28 29 | @implementation OFTaggedPointerColor + (void)initialize { if (self == [OFTaggedPointerColor class]) colorTag = objc_registerTaggedPointerClass(self); } | | | | | 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | @implementation OFTaggedPointerColor + (void)initialize { if (self == [OFTaggedPointerColor class]) colorTag = objc_registerTaggedPointerClass(self); } + (OFTaggedPointerColor *)colorWithRed: (uint8_t)red green: (uint8_t)green blue: (uint8_t)blue { return objc_createTaggedPointer(colorTag, (uintptr_t)red << 16 | (uintptr_t)green << 8 | (uintptr_t)blue); } - (void)getRed: (float *)red green: (float *)green |
︙ | ︙ |
Added src/OFTaggedPointerDate.h version [f3031387d9].
> > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | /* * Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in * the packaging of this file. * * 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 "OFDate.h" OF_ASSUME_NONNULL_BEGIN #if defined(OF_OBJFW_RUNTIME) && UINTPTR_MAX == UINT64_MAX @interface OFTaggedPointerDate: OFDate + (OFTaggedPointerDate *)dateWithUInt64TimeIntervalSince1970: (uint64_t)value; @end #endif OF_ASSUME_NONNULL_END |
Added src/OFTaggedPointerDate.m version [1b188d7d8a].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | /* * Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in * the packaging of this file. * * 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 "OFTaggedPointerDate.h" #if defined(OF_OBJFW_RUNTIME) && UINTPTR_MAX == UINT64_MAX static int dateTag; @implementation OFTaggedPointerDate + (void)initialize { if (self == [OFTaggedPointerDate class]) dateTag = objc_registerTaggedPointerClass(self); } + (OFTaggedPointerDate *)dateWithUInt64TimeIntervalSince1970: (uint64_t)value { return objc_createTaggedPointer(dateTag, value & ~(UINT64_C(4) << 60)); } - (OFTimeInterval)timeIntervalSince1970 { uint64_t value = (uint64_t)object_getTaggedPointerValue(self); value |= UINT64_C(4) << 60; return OFFromBigEndianDouble(OFRawUInt64ToDouble(OFToBigEndian64( value))); } OF_SINGLETON_METHODS @end #endif |
Added src/OFTaggedPointerNumber.h version [ab4cf3f56e].
> > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | /* * Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in * the packaging of this file. * * 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 "OFNumber.h" OF_ASSUME_NONNULL_BEGIN #ifdef OF_OBJFW_RUNTIME # define OFTaggedPointerNumberTagBits 4 @interface OFTaggedPointerNumber: OFNumber @end #endif OF_ASSUME_NONNULL_END |
Added src/OFTaggedPointerNumber.m version [afd66e3faa].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 | /* * Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in * the packaging of this file. * * 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. */ #include "config.h" #import "OFTaggedPointerNumber.h" #import "OFInvalidFormatException.h" #ifdef OF_OBJFW_RUNTIME enum Tag { tagChar, tagShort, tagInt, tagLong, tagLongLong, tagUnsignedChar, tagUnsignedShort, tagUnsignedInt, tagUnsignedLong, tagUnsignedLongLong, }; static const uintptr_t tagMask = (1 << OFTaggedPointerNumberTagBits) - 1; static int numberTag; @implementation OFTaggedPointerNumber + (void)initialize { if (self == [OFTaggedPointerNumber class]) numberTag = objc_registerTaggedPointerClass(self); } + (OFTaggedPointerNumber *)numberWithChar: (signed char)value { return objc_createTaggedPointer(numberTag, ((uintptr_t)(unsigned char)value << OFTaggedPointerNumberTagBits) | tagChar); } + (OFTaggedPointerNumber *)numberWithShort: (short)value { return objc_createTaggedPointer(numberTag, ((uintptr_t)(unsigned short)value << OFTaggedPointerNumberTagBits) | tagShort); } + (OFTaggedPointerNumber *)numberWithInt: (int)value { return objc_createTaggedPointer(numberTag, ((uintptr_t)(unsigned int)value << OFTaggedPointerNumberTagBits) | tagInt); } + (OFTaggedPointerNumber *)numberWithLong: (long)value { return objc_createTaggedPointer(numberTag, ((uintptr_t)(unsigned long)value << OFTaggedPointerNumberTagBits) | tagLong); } + (OFTaggedPointerNumber *)numberWithLongLong: (long long)value { return objc_createTaggedPointer(numberTag, ((uintptr_t)(unsigned long long)value << OFTaggedPointerNumberTagBits) | tagLongLong); } + (OFTaggedPointerNumber *)numberWithUnsignedChar: (unsigned char)value { return objc_createTaggedPointer(numberTag, ((uintptr_t)value << OFTaggedPointerNumberTagBits) | tagUnsignedChar); } + (OFTaggedPointerNumber *)numberWithUnsignedShort: (unsigned short)value { return objc_createTaggedPointer(numberTag, ((uintptr_t)value << OFTaggedPointerNumberTagBits) | tagUnsignedShort); } + (OFTaggedPointerNumber *)numberWithUnsignedInt: (unsigned int)value { return objc_createTaggedPointer(numberTag, ((uintptr_t)value << OFTaggedPointerNumberTagBits) | tagUnsignedInt); } + (OFTaggedPointerNumber *)numberWithUnsignedLong: (unsigned long)value { return objc_createTaggedPointer(numberTag, ((uintptr_t)value << OFTaggedPointerNumberTagBits) | tagUnsignedLong); } + (OFTaggedPointerNumber *)numberWithUnsignedLongLong: (unsigned long long)value { return objc_createTaggedPointer(numberTag, ((uintptr_t)value << OFTaggedPointerNumberTagBits) | tagUnsignedLongLong); } - (const char *)objCType { uintptr_t value = object_getTaggedPointerValue(self); switch (value & tagMask) { case tagChar: return @encode(signed char); case tagShort: return @encode(short); case tagInt: return @encode(int); case tagLong: return @encode(long); case tagLongLong: return @encode(long long); case tagUnsignedChar: return @encode(unsigned char); case tagUnsignedShort: return @encode(unsigned short); case tagUnsignedInt: return @encode(unsigned int); case tagUnsignedLong: return @encode(unsigned long); case tagUnsignedLongLong: return @encode(unsigned long long); default: @throw [OFInvalidFormatException exception]; } } # define RETURN_VALUE \ uintptr_t value = object_getTaggedPointerValue(self); \ \ switch (value & tagMask) { \ case tagChar: \ return (signed char)(unsigned char) \ (value >> OFTaggedPointerNumberTagBits); \ case tagShort: \ return (short)(unsigned short) \ (value >> OFTaggedPointerNumberTagBits); \ case tagInt: \ return (int)(unsigned int) \ (value >> OFTaggedPointerNumberTagBits); \ case tagLong: \ return (long)(unsigned long) \ (value >> OFTaggedPointerNumberTagBits); \ case tagLongLong: \ return (long long)(unsigned long long) \ (value >> OFTaggedPointerNumberTagBits); \ case tagUnsignedChar: \ return (unsigned char) \ (value >> OFTaggedPointerNumberTagBits); \ case tagUnsignedShort: \ return (unsigned short) \ (value >> OFTaggedPointerNumberTagBits); \ case tagUnsignedInt: \ return (unsigned int) \ (value >> OFTaggedPointerNumberTagBits); \ case tagUnsignedLong: \ return (unsigned long) \ (value >> OFTaggedPointerNumberTagBits); \ case tagUnsignedLongLong: \ return (unsigned long long) \ (value >> OFTaggedPointerNumberTagBits); \ default: \ @throw [OFInvalidFormatException exception]; \ } - (long long)longLongValue { RETURN_VALUE } - (unsigned long long)unsignedLongLongValue { RETURN_VALUE } - (double)doubleValue { RETURN_VALUE } # undef RETURN_VALUE OF_SINGLETON_METHODS @end #endif |
Modified src/OFValue.h from [4f26146aa4] to [fec80b138b].
︙ | ︙ | |||
19 20 21 22 23 24 25 | /** * @class OFValue OFValue.h ObjFW/OFValue.h * * @brief A class for storing arbitrary values in an object. */ @interface OFValue: OFObject <OFCopying> | < < < < | 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | /** * @class OFValue OFValue.h ObjFW/OFValue.h * * @brief A class for storing arbitrary values in an object. */ @interface OFValue: OFObject <OFCopying> /** * @brief The ObjC type encoding of the value. */ @property (readonly, nonatomic) const char *objCType; /** * @brief The value as a pointer to void. |
︙ | ︙ | |||
64 65 66 67 68 69 70 | * @brief The value as an OFSize. * * @throw OFOutOfRangeException The value is not OFSize-sized */ @property (readonly, nonatomic) OFSize sizeValue; /** | | > > > > > > > > > > > > > > | 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 | * @brief The value as an OFSize. * * @throw OFOutOfRangeException The value is not OFSize-sized */ @property (readonly, nonatomic) OFSize sizeValue; /** * @brief The value as an OFRect. * * @throw OFOutOfRangeException The value is not OFRect-sized */ @property (readonly, nonatomic) OFRect rectValue; /** * @brief The value as an OFVector3D. * * @throw OFOutOfRangeException The value is not OFVector3D-sized */ @property (readonly, nonatomic) OFVector3D vector3DValue; /** * @brief The value as an OFVector4D. * * @throw OFOutOfRangeException The value is not OFVector4D-sized */ @property (readonly, nonatomic) OFVector4D vector4DValue; /** * @brief Creates a new, autorelease OFValue with the specified bytes of the * specified type. * * @param bytes The bytes containing the value * @param objCType The ObjC type encoding for the value * @return A new, autoreleased OFValue |
︙ | ︙ | |||
136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 | * rectangle. * * @param rect The rectangle the OFValue should contain * @return A new, autoreleased OFValue */ + (instancetype)valueWithRect: (OFRect)rect; /** * @brief Initializes an already allocated OFValue with the specified bytes of * the specified type. * * @param bytes The bytes containing the value * @param objCType The ObjC type encoding for the value * @return An initialized OFValue */ - (instancetype)initWithBytes: (const void *)bytes | > > > > > > > > > > > > > > > > > > | > > | 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 | * rectangle. * * @param rect The rectangle the OFValue should contain * @return A new, autoreleased OFValue */ + (instancetype)valueWithRect: (OFRect)rect; /** * @brief Creates a new, autoreleased OFValue containing the specified * 3D vector. * * @param vector3D The 3D vector the OFValue should contain * @return A new, autoreleased OFValue */ + (instancetype)valueWithVector3D: (OFVector3D)vector3D; /** * @brief Creates a new, autoreleased OFValue containing the specified * 4D vector. * * @param vector4D The 4D vector the OFValue should contain * @return A new, autoreleased OFValue */ + (instancetype)valueWithVector4D: (OFVector4D)vector4D; /** * @brief Initializes an already allocated OFValue with the specified bytes of * the specified type. * * @param bytes The bytes containing the value * @param objCType The ObjC type encoding for the value * @return An initialized OFValue */ - (instancetype)initWithBytes: (const void *)bytes objCType: (const char *)objCType OF_DESIGNATED_INITIALIZER; - (instancetype)init OF_UNAVAILABLE; /** * @brief Gets the value. * * @param value The buffer to copy the value into * @param size The size of the value * @throw OFOutOfRangeException The specified size does not match the value |
︙ | ︙ |
Modified src/OFValue.m from [ed60df5d2c] to [d066bfb20d].
︙ | ︙ | |||
12 13 14 15 16 17 18 | * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #include "config.h" #import "OFValue.h" | | < | | | | > > > | > > | > > > > > > > > > | > > > > > > | > > > > > > > > | | | | > > | | | > | > | > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 | * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #include "config.h" #import "OFValue.h" #import "OFConcreteValue.h" #import "OFMethodSignature.h" #import "OFString.h" #import "OFOutOfMemoryException.h" static struct { Class isa; } placeholder; @interface OFPlaceholderValue: OFValue @end @implementation OFPlaceholderValue #ifdef __clang__ /* We intentionally don't call into super, so silence the warning. */ # pragma clang diagnostic push # pragma clang diagnostic ignored "-Wunknown-pragmas" # pragma clang diagnostic ignored "-Wobjc-designated-initializers" #endif - (instancetype)initWithBytes: (const void *)bytes objCType: (const char *)objCType { return (id)[[OFConcreteValue alloc] initWithBytes: bytes objCType: objCType]; } #ifdef __clang__ # pragma clang diagnostic pop #endif OF_SINGLETON_METHODS @end @implementation OFValue + (void)initialize { if (self == [OFValue class]) object_setClass((id)&placeholder, [OFPlaceholderValue class]); } + (instancetype)alloc { if (self == [OFValue class]) return (id)&placeholder; return [super alloc]; } + (instancetype)valueWithBytes: (const void *)bytes objCType: (const char *)objCType { return [[[OFValue alloc] initWithBytes: bytes objCType: objCType] autorelease]; } + (instancetype)valueWithPointer: (const void *)pointer { return [[[OFValue alloc] initWithBytes: &pointer objCType: @encode(const void *)] autorelease]; } + (instancetype)valueWithNonretainedObject: (id)object { return [[[OFValue alloc] initWithBytes: &object objCType: @encode(id)] autorelease]; } + (instancetype)valueWithRange: (OFRange)range { return [[[OFValue alloc] initWithBytes: &range objCType: @encode(OFRange)] autorelease]; } + (instancetype)valueWithPoint: (OFPoint)point { return [[[OFValue alloc] initWithBytes: &point objCType: @encode(OFPoint)] autorelease]; } + (instancetype)valueWithSize: (OFSize)size { return [[[OFValue alloc] initWithBytes: &size objCType: @encode(OFSize)] autorelease]; } + (instancetype)valueWithRect: (OFRect)rect { return [[[OFValue alloc] initWithBytes: &rect objCType: @encode(OFRect)] autorelease]; } + (instancetype)valueWithVector3D: (OFVector3D)vector3D { return [[[OFValue alloc] initWithBytes: &vector3D objCType: @encode(OFVector3D)] autorelease]; } + (instancetype)valueWithVector4D: (OFVector4D)vector4D { return [[[OFValue alloc] initWithBytes: &vector4D objCType: @encode(OFVector4D)] autorelease]; } - (instancetype)initWithBytes: (const void *)bytes objCType: (const char *)objCType { if ([self isMemberOfClass: [OFValue class]]) { @try { [self doesNotRecognizeSelector: _cmd]; } @catch (id e) { [self release]; @throw e; } abort(); } return [super init]; } - (instancetype)init { OF_INVALID_INIT_METHOD } - (bool)isEqual: (id)object { const char *objCType; |
︙ | ︙ | |||
196 197 198 199 200 201 202 203 204 205 | - (OFRect)rectValue { OFRect ret; [self getValue: &ret size: sizeof(ret)]; return ret; } - (OFString *)description { | > > > > > > > > > > > > > > > | < | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 | - (OFRect)rectValue { OFRect ret; [self getValue: &ret size: sizeof(ret)]; return ret; } - (OFVector3D)vector3DValue { OFVector3D ret; [self getValue: &ret size: sizeof(ret)]; return ret; } - (OFVector4D)vector4DValue { OFVector4D ret; [self getValue: &ret size: sizeof(ret)]; return ret; } - (OFString *)description { const char *objCType = self.objCType; OFMutableString *ret; size_t size; unsigned char *value; if (strcmp(objCType, @encode(OFRange)) == 0 || strcmp(objCType, @encode(const OFRange)) == 0) { OFRange rangeValue; [self getValue: &rangeValue size: sizeof(rangeValue)]; return [OFString stringWithFormat: @"<OFValue: OFRange { %zd, %zd }>", rangeValue.location, rangeValue.length]; } else if (strcmp(objCType, @encode(OFPoint)) == 0 || strcmp(objCType, @encode(const OFPoint)) == 0) { OFPoint pointValue; [self getValue: &pointValue size: sizeof(pointValue)]; return [OFString stringWithFormat: @"<OFValue: OFPoint { %g, %g }>", pointValue.x, pointValue.y]; } else if (strcmp(objCType, @encode(OFSize)) == 0 || strcmp(objCType, @encode(const OFSize)) == 0) { OFSize sizeValue; [self getValue: &sizeValue size: sizeof(sizeValue)]; return [OFString stringWithFormat: @"<OFValue: OFSize { %g, %g }>", sizeValue.width, sizeValue.height]; } else if (strcmp(objCType, @encode(OFRect)) == 0 || strcmp(objCType, @encode(const OFRect)) == 0) { OFRect rectValue; [self getValue: &rectValue size: sizeof(rectValue)]; return [OFString stringWithFormat: @"<OFValue: OFRect { %g, %g, %g, %g }>", rectValue.origin.x, rectValue.origin.y, rectValue.size.width, rectValue.size.height]; } else if (strcmp(objCType, @encode(OFVector3D)) == 0 || strcmp(objCType, @encode(const OFVector3D)) == 0) { OFVector3D vector3DValue; [self getValue: &vector3DValue size: sizeof(vector3DValue)]; return [OFString stringWithFormat: @"<OFValue: OFVector3D { %g, %g, %g }>", vector3DValue.x, vector3DValue.y, vector3DValue.z]; } else if (strcmp(objCType, @encode(OFVector4D)) == 0 || strcmp(objCType, @encode(const OFVector4D)) == 0) { OFVector4D vector4DValue; [self getValue: &vector4DValue size: sizeof(vector4DValue)]; return [OFString stringWithFormat: @"<OFValue: OFVector4D { %g, %g, %g, %g }>", vector4DValue.x, vector4DValue.y, vector4DValue.z, vector4DValue.w]; } ret = [OFMutableString stringWithString: @"<OFValue: "]; size = OFSizeOfTypeEncoding(objCType); value = OFAllocMemory(1, size); @try { [self getValue: value size: size]; for (size_t i = 0; i < size; i++) { if (i > 0) [ret appendString: @" "]; |
︙ | ︙ |
Modified src/unicode.h from [5afacb875e] to [272a9eb1c4].
︙ | ︙ | |||
15 16 17 18 19 20 21 | #import "OFString.h" #define OFUnicodeUppercaseTableSize 0x1EA #define OFUnicodeLowercaseTableSize 0x1EA #define OFUnicodeTitlecaseTableSize 0x1EA #define OFUnicodeCaseFoldingTableSize 0x1EA | < < < < < < | 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | #import "OFString.h" #define OFUnicodeUppercaseTableSize 0x1EA #define OFUnicodeLowercaseTableSize 0x1EA #define OFUnicodeTitlecaseTableSize 0x1EA #define OFUnicodeCaseFoldingTableSize 0x1EA #ifdef __cplusplus extern "C" { #endif extern const OFUnichar *const _Nonnull OFUnicodeUppercaseTable[OFUnicodeUppercaseTableSize]; extern const OFUnichar *const _Nonnull OFUnicodeLowercaseTable[OFUnicodeLowercaseTableSize]; extern const OFUnichar *const _Nonnull OFUnicodeTitlecaseTable[OFUnicodeTitlecaseTableSize]; extern const OFUnichar *const _Nonnull OFUnicodeCaseFoldingTable[OFUnicodeCaseFoldingTableSize]; #ifdef __cplusplus } #endif |
Modified src/unicode.m from [25e90b64b1] to [7322d3c69c].
more than 10,000 changes
Modified tests/OFStringTests.m from [4230f34f7e] to [87480291e6].
︙ | ︙ | |||
1403 1404 1405 1406 1407 1408 1409 | R([mutableString1 deleteEnclosingWhitespaces]) && [mutableString1 isEqual: @"asd"] && (mutableString1 = [mutableStringClass stringWithString: whitespace[1]]) && R([mutableString1 deleteEnclosingWhitespaces]) && [mutableString1 isEqual: @""]) | < < < < < < < < < < | 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 | R([mutableString1 deleteEnclosingWhitespaces]) && [mutableString1 isEqual: @"asd"] && (mutableString1 = [mutableStringClass stringWithString: whitespace[1]]) && R([mutableString1 deleteEnclosingWhitespaces]) && [mutableString1 isEqual: @""]) TEST(@"-[stringByXMLEscaping]", (string = C(@"<hello> &world'\"!&").stringByXMLEscaping) && [string isEqual: @"<hello> &world'"!&"]) TEST(@"-[stringByXMLUnescaping]", [string.stringByXMLUnescaping isEqual: @"<hello> &world'\"!&"] && [C(@"y").stringByXMLUnescaping isEqual: @"y"] && |
︙ | ︙ |