Overview
Comment: | Make OFObject.h and OFString.h C-safe |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
6e7e19252b730dabcd46691b7d55a306 |
User & Date: | js on 2020-04-11 19:31:11 |
Other Links: | manifest | tags |
Context
2020-04-11
| ||
23:10 | OFLocale: Support for translated plurals check-in: 7fa757534a user: js tags: trunk | |
19:31 | Make OFObject.h and OFString.h C-safe check-in: 6e7e19252b user: js tags: trunk | |
16:31 | OFHTTP*: Use -[asyncReadLine:] for chunk size check-in: ba4a65d397 user: js tags: trunk | |
Changes
Modified src/OFConstantString.h from [a28a2410f5] to [b16809eb56].
︙ | ︙ | |||
11 12 13 14 15 16 17 | * * 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. */ | > > > | > > > > | 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 | * * 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 OBJFW_OF_CONSTANT_STRING_H #define OBJFW_OF_CONSTANT_STRING_H #include "OFString.h" OF_ASSUME_NONNULL_BEGIN #if !defined(OF_CONSTANT_STRING_M) && \ defined(OF_APPLE_RUNTIME) && !defined(__OBJC2__) # ifdef __cplusplus extern "C" { # endif extern void *_OFConstantStringClassReference; # ifdef __cplusplus } # endif #endif #ifdef __OBJC__ /*! * @class OFConstantString OFConstantString.h ObjFW/OFConstantString.h * * @brief A class for storing constant strings using the `@""` literal. */ OF_SUBCLASSING_RESTRICTED @interface OFConstantString: OFString { char *_cString; unsigned int _cStringLength; } @end #endif OF_ASSUME_NONNULL_END #endif |
Modified src/OFMutableString.h from [dd3e9e1fa2] to [7d782f5154].
︙ | ︙ | |||
11 12 13 14 15 16 17 | * * 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. */ | > > > | > | 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | * * 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 OBJFW_OF_MUTABLE_STRING_H #define OBJFW_OF_MUTABLE_STRING_H #include "OFString.h" OF_ASSUME_NONNULL_BEGIN #ifdef __OBJC__ /*! * @class OFMutableString OFString.h ObjFW/OFString.h * * @brief A class for storing and modifying strings. */ @interface OFMutableString: OFString /*! |
︙ | ︙ | |||
208 209 210 211 212 213 214 215 216 | - (void)deleteEnclosingWhitespaces; /*! * @brief Converts the mutable string to an immutable string. */ - (void)makeImmutable; @end OF_ASSUME_NONNULL_END | > > > | 212 213 214 215 216 217 218 219 220 221 222 223 | - (void)deleteEnclosingWhitespaces; /*! * @brief Converts the mutable string to an immutable string. */ - (void)makeImmutable; @end #endif OF_ASSUME_NONNULL_END #endif |
Modified src/OFObject.h from [67744f52d1] to [27f5bcdbd5].
︙ | ︙ | |||
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | * * 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 "objfw-defs.h" #ifndef __STDC_LIMIT_MACROS # define __STDC_LIMIT_MACROS #endif #ifndef __STDC_CONSTANT_MACROS # define __STDC_CONSTANT_MACROS #endif #include <stddef.h> #include <stdint.h> #include <stdbool.h> #include <limits.h> | > > > | | | 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 | * * 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 OBJFW_OF_OBJECT_H #define OBJFW_OF_OBJECT_H #include "objfw-defs.h" #ifndef __STDC_LIMIT_MACROS # define __STDC_LIMIT_MACROS #endif #ifndef __STDC_CONSTANT_MACROS # define __STDC_CONSTANT_MACROS #endif #include <stddef.h> #include <stdint.h> #include <stdbool.h> #include <limits.h> #include "macros.h" #include "block.h" /* * Some versions of MinGW require <winsock2.h> to be included before * <windows.h>. Do this here to make sure this is always done in the correct * order, even if another header includes just <windows.h>. */ #ifdef __MINGW32__ |
︙ | ︙ | |||
273 274 275 276 277 278 279 280 281 282 283 284 285 286 | if (!of_dimension_equal(rectangle1.size, rectangle2.size)) return false; return true; } @class OFMethodSignature; @class OFString; @class OFThread; /*! * @protocol OFObject OFObject.h ObjFW/OFObject.h * | > | 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 | if (!of_dimension_equal(rectangle1.size, rectangle2.size)) return false; return true; } #ifdef __OBJC__ @class OFMethodSignature; @class OFString; @class OFThread; /*! * @protocol OFObject OFObject.h ObjFW/OFObject.h * |
︙ | ︙ | |||
488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 | /*! * @brief Retain a weak reference to this object. * * @return Whether a weak reference to this object has been retained */ - (bool)retainWeakReference; @end /*! * @class OFObject OFObject.h ObjFW/OFObject.h * * @brief The root class for all other classes inside ObjFW. */ OF_ROOT_CLASS @interface OFObject <OFObject> { @private #ifndef __clang_analyzer__ Class _isa; #else | > > | 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 | /*! * @brief Retain a weak reference to this object. * * @return Whether a weak reference to this object has been retained */ - (bool)retainWeakReference; @end #endif /*! * @class OFObject OFObject.h ObjFW/OFObject.h * * @brief The root class for all other classes inside ObjFW. */ #ifdef __OBJC__ OF_ROOT_CLASS @interface OFObject <OFObject> { @private #ifndef __clang_analyzer__ Class _isa; #else |
︙ | ︙ | |||
1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 | * @warning If you override this method, you must make sure that it never * returns! * * @param selector The selector not understood by the receiver */ - (void)doesNotRecognizeSelector: (SEL)selector OF_NO_RETURN; @end /*! * @protocol OFCopying OFObject.h ObjFW/OFObject.h * * @brief A protocol for the creation of copies. */ @protocol OFCopying /*! | > > > > | 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 | * @warning If you override this method, you must make sure that it never * returns! * * @param selector The selector not understood by the receiver */ - (void)doesNotRecognizeSelector: (SEL)selector OF_NO_RETURN; @end #else typedef void OFObject; #endif #ifdef __OBJC__ /*! * @protocol OFCopying OFObject.h ObjFW/OFObject.h * * @brief A protocol for the creation of copies. */ @protocol OFCopying /*! |
︙ | ︙ | |||
1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 | * @brief Compares the object with another object. * * @param object An object to compare the object to * @return The result of the comparison */ - (of_comparison_result_t)compare: (id <OFComparing>)object; @end #ifdef __cplusplus extern "C" { #endif #ifdef OF_APPLE_RUNTIME extern void *_Null_unspecified objc_autoreleasePoolPush(void); extern void objc_autoreleasePoolPop(void *_Null_unspecified pool); #endif extern id of_alloc_object(Class class_, size_t extraSize, size_t extraAlignment, void *_Nullable *_Nullable extra); extern void OF_NO_RETURN_FUNC of_method_not_found(id self, SEL _cmd); extern uint32_t of_hash_seed; #ifdef __cplusplus } #endif OF_ASSUME_NONNULL_END #import "OFObject+KeyValueCoding.h" #import "OFObject+Serialization.h" | > > > > > | 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 | * @brief Compares the object with another object. * * @param object An object to compare the object to * @return The result of the comparison */ - (of_comparison_result_t)compare: (id <OFComparing>)object; @end #endif #ifdef __cplusplus extern "C" { #endif #ifdef OF_APPLE_RUNTIME extern void *_Null_unspecified objc_autoreleasePoolPush(void); extern void objc_autoreleasePoolPop(void *_Null_unspecified pool); #endif extern id of_alloc_object(Class class_, size_t extraSize, size_t extraAlignment, void *_Nullable *_Nullable extra); extern void OF_NO_RETURN_FUNC of_method_not_found(id self, SEL _cmd); extern uint32_t of_hash_seed; #ifdef __cplusplus } #endif OF_ASSUME_NONNULL_END #ifdef __OBJC__ #import "OFObject+KeyValueCoding.h" #import "OFObject+Serialization.h" #endif #endif |
Modified src/OFString.h from [dae29d5404] to [bdb6b2db5a].
︙ | ︙ | |||
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | * 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 | > > > | | > > > > > > > | 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 | * 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 OBJFW_OF_STRING_H #define OBJFW_OF_STRING_H #ifndef __STDC_LIMIT_MACROS # define __STDC_LIMIT_MACROS #endif #ifndef __STDC_CONSTANT_MACROS # define __STDC_CONSTANT_MACROS #endif #include "objfw-defs.h" #ifdef OF_HAVE_SYS_TYPES_H # include <sys/types.h> #endif #include <stdarg.h> #include <stdint.h> #ifdef OF_HAVE_INTTYPES_H # include <inttypes.h> #endif #include "OFObject.h" #ifdef __OBJC__ #import "OFSerialization.h" #import "OFJSONRepresentation.h" #import "OFMessagePackRepresentation.h" #endif OF_ASSUME_NONNULL_BEGIN /*! @file */ #ifdef __OBJC__ @class OFConstantString; @class OFString; #else typedef void OFString; #endif #if defined(__cplusplus) && __cplusplus >= 201103L typedef char16_t of_char16_t; typedef char32_t of_char32_t; #else typedef uint_least16_t of_char16_t; typedef uint_least32_t of_char32_t; |
︙ | ︙ | |||
106 107 108 109 110 111 112 113 114 115 116 117 118 119 | * @param line The current line * @param stop A pointer to a variable that can be set to true to stop the * enumeration */ typedef void (^of_string_line_enumeration_block_t)(OFString *line, bool *stop); #endif @class OFArray OF_GENERIC(ObjectType); @class OFCharacterSet; @class OFURL; /*! * @class OFString OFString.h ObjFW/OFString.h * | > | 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 | * @param line The current line * @param stop A pointer to a variable that can be set to true to stop the * enumeration */ typedef void (^of_string_line_enumeration_block_t)(OFString *line, bool *stop); #endif #ifdef __OBJC__ @class OFArray OF_GENERIC(ObjectType); @class OFCharacterSet; @class OFURL; /*! * @class OFString OFString.h ObjFW/OFString.h * |
︙ | ︙ | |||
1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 | * Enumerates all lines in the receiver using the specified block. * * @brief block The block to call for each line */ - (void)enumerateLinesUsingBlock: (of_string_line_enumeration_block_t)block; #endif @end #ifdef __cplusplus extern "C" { #endif extern of_string_encoding_t of_string_parse_encoding(OFString *); extern OFString *_Nullable of_string_name_of_encoding(of_string_encoding_t); extern size_t of_string_utf8_encode(of_unichar_t, char *); extern ssize_t of_string_utf8_decode(const char *, size_t, of_unichar_t *); extern size_t of_string_utf16_length(const of_char16_t *); extern size_t of_string_utf32_length(const of_char32_t *); #ifdef __cplusplus } #endif OF_ASSUME_NONNULL_END | > | | > > | > > | 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 | * Enumerates all lines in the receiver using the specified block. * * @brief block The block to call for each line */ - (void)enumerateLinesUsingBlock: (of_string_line_enumeration_block_t)block; #endif @end #endif #ifdef __cplusplus extern "C" { #endif extern of_string_encoding_t of_string_parse_encoding(OFString *); extern OFString *_Nullable of_string_name_of_encoding(of_string_encoding_t); extern size_t of_string_utf8_encode(of_unichar_t, char *); extern ssize_t of_string_utf8_decode(const char *, size_t, of_unichar_t *); extern size_t of_string_utf16_length(const of_char16_t *); extern size_t of_string_utf32_length(const of_char32_t *); #ifdef __cplusplus } #endif OF_ASSUME_NONNULL_END #include "OFConstantString.h" #include "OFMutableString.h" #ifdef __OBJC__ #import "OFString+CryptoHashing.h" #import "OFString+JSONValue.h" #ifdef OF_HAVE_FILES # import "OFString+PathAdditions.h" #endif #import "OFString+PropertyListValue.h" #import "OFString+Serialization.h" #import "OFString+URLEncoding.h" #import "OFString+XMLEscaping.h" #import "OFString+XMLUnescaping.h" #endif #if defined(__OBJC__) && !defined(NSINTEGER_DEFINED) && !__has_feature(modules) /* * Very *ugly* hack required for string boxing literals to work. * * This hack is needed in order to work with `@class NSString` from Apple's * objc/NSString.h - which is included when using modules - as * @compatibility_alias does not work if @class has been used before. * For some reason, this makes Clang refer to OFString for string box literals * and not to NSString (which would result in a linker error, but would be the * correct behavior). * * TODO: Submit a patch for Clang that makes the boxing classes configurable! */ @interface NSString: OFString @end #endif #endif |
Modified src/block.h from [bf1e73c83e] to [6724cf2142].
︙ | ︙ | |||
11 12 13 14 15 16 17 | * * 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. */ | > > > | | 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | * * 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 OBJFW_BLOCK_H #define OBJFW_BLOCK_H #include "macros.h" OF_ASSUME_NONNULL_BEGIN typedef struct of_block_literal_t { #ifdef __OBJC__ Class isa; #else |
︙ | ︙ | |||
66 67 68 69 70 71 72 | ((__typeof__(__VA_ARGS__))_Block_copy((const void *)(__VA_ARGS__))) #endif #ifndef Block_release # define Block_release(...) _Block_release((const void *)(__VA_ARGS__)) #endif OF_ASSUME_NONNULL_END | > > | 69 70 71 72 73 74 75 76 77 | ((__typeof__(__VA_ARGS__))_Block_copy((const void *)(__VA_ARGS__))) #endif #ifndef Block_release # define Block_release(...) _Block_release((const void *)(__VA_ARGS__)) #endif OF_ASSUME_NONNULL_END #endif |
Modified src/macros.h from [9bed6604d9] to [798f22e9e5].
︙ | ︙ | |||
10 11 12 13 14 15 16 17 18 19 20 21 22 23 | * 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 "objfw-defs.h" #ifndef __STDC_LIMIT_MACROS # define __STDC_LIMIT_MACROS #endif #ifndef __STDC_CONSTANT_MACROS | > > > | 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | * 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 OBJFW_MACROS_H #define OBJFW_MACROS_H #include "objfw-defs.h" #ifndef __STDC_LIMIT_MACROS # define __STDC_LIMIT_MACROS #endif #ifndef __STDC_CONSTANT_MACROS |
︙ | ︙ | |||
33 34 35 36 37 38 39 | #include <sys/time.h> #include "platform.h" #ifdef OF_OBJFW_RUNTIME # ifdef OF_COMPILING_OBJFW | | | | | | | 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | #include <sys/time.h> #include "platform.h" #ifdef OF_OBJFW_RUNTIME # ifdef OF_COMPILING_OBJFW # include "ObjFWRT.h" # else # include <ObjFWRT/ObjFWRT.h> # endif #endif #ifdef OF_APPLE_RUNTIME # include <objc/objc.h> # include <objc/runtime.h> # include <objc/message.h> #endif #if defined(__GNUC__) # define restrict __restrict__ #elif __STDC_VERSION__ < 199901L # define restrict #endif |
︙ | ︙ | |||
884 885 886 887 888 889 890 | struct timeval tv; gettimeofday(&tv, NULL); srand((unsigned)(tv.tv_sec ^ tv.tv_usec)); return (((uint32_t)(rand()) << 16) | ((uint32_t)(rand()) & 0xFFFF)); #endif } | > > | 887 888 889 890 891 892 893 894 895 | struct timeval tv; gettimeofday(&tv, NULL); srand((unsigned)(tv.tv_sec ^ tv.tv_usec)); return (((uint32_t)(rand()) << 16) | ((uint32_t)(rand()) & 0xFFFF)); #endif } #endif |