Index: Doxyfile
==================================================================
--- Doxyfile
+++ Doxyfile
@@ -4,10 +4,11 @@
FILE_PATTERNS = *.h *.m
HTML_OUTPUT = .
GENERATE_LATEX = NO
HIDE_UNDOC_CLASSES = YES
HIDE_UNDOC_MEMBERS = YES
+TYPEDEF_HIDES_STRUCT = YES
PREDEFINED = __OBJC__ \
DOXYGEN \
OF_BOXABLE \
OF_CONSUMED \
OF_DESIGNATED_INITIALIZER \
Index: README.md
==================================================================
--- README.md
+++ README.md
@@ -159,19 +159,19 @@
$ clang="clang -isysroot $(xcrun --sdk iphoneos --show-sdk-path)"
$ export OBJC="$clang -arch armv7 -arch arm64"
$ export OBJCPP="$clang -arch armv7 -E"
$ export IPHONEOS_DEPLOYMENT_TARGET="9.0"
- $ ./configure --prefix=/usr/local/ios --host=arm-apple-darwin
+ $ ./configure --prefix=/usr/local/ios --host=arm64-apple-darwin
To build for the iOS simulator, use something like this:
$ clang="clang -isysroot $(xcrun --sdk iphonesimulator --show-sdk-path)"
$ export OBJC="$clang -arch i386 -arch x86_64"
$ export OBJCPP="$clang -arch i386 -E"
$ export IPHONEOS_DEPLOYMENT_TARGET="9.0"
- $ ./configure --prefix=/usr/local/iossim --host=i386-apple-darwin
+ $ ./configure --prefix=/usr/local/iossim --host=x86_64-apple-darwin
Using the macOS or iOS framework in Xcode
To use the macOS framework in Xcode, you need to add the `.framework`s to
your project and add the following flags to `Other C Flags`:
Index: src/Makefile
==================================================================
--- src/Makefile
+++ src/Makefile
@@ -108,11 +108,10 @@
OFXMLNode.m \
OFXMLParser.m \
OFXMLProcessingInstruction.m \
OFZIPArchive.m \
OFZIPArchiveEntry.m \
- ${UNICODE_M} \
${USE_SRCS_FILES} \
${USE_SRCS_PLUGINS} \
${USE_SRCS_SOCKETS} \
${USE_SRCS_THREADS} \
${USE_SRCS_WINDOWS}
@@ -198,11 +197,12 @@
OFSizeValue.m \
OFSubarray.m \
OFUTF8String.m \
${LIBBASES_M} \
${RUNTIME_AUTORELEASE_M} \
- ${RUNTIME_INSTANCE_M}
+ ${RUNTIME_INSTANCE_M} \
+ ${UNICODE_M}
SRCS_FILES += OFFileURLHandler.m \
OFINIFileSettings.m
SRCS_SOCKETS += OFDNSResolverSettings.m \
OFHTTPURLHandler.m \
OFHostAddressResolver.m \
Index: src/OFArray.h
==================================================================
--- src/OFArray.h
+++ src/OFArray.h
@@ -38,16 +38,22 @@
/**
* @brief Options for joining the objects of an array.
*
* This is a bit mask.
*/
-typedef enum OFArrayJoinOptions {
+typedef enum {
/** Skip empty components */
OFArraySkipEmptyComponents = 1
} OFArrayJoinOptions;
-typedef enum OFArraySortOptions {
+/**
+ * @brief Options for sorting an array.
+ *
+ * This is a bit mask.
+ */
+typedef enum {
+ /** Sort the array descending */
OFArraySortDescending = 1
} OFArraySortOptions;
#ifdef OF_HAVE_BLOCKS
/**
Index: src/OFDNSResolver.h
==================================================================
--- src/OFDNSResolver.h
+++ src/OFDNSResolver.h
@@ -38,11 +38,11 @@
/**
* @enum OFDNSResolverErrorCode OFDNSResolver.h ObjFW/OFDNSResolver.h
*
* @brief An enum describing why resolving a host failed.
*/
-typedef enum OFDNSResolverErrorCode {
+typedef enum {
/** An unknown error */
OFDNSResolverErrorCodeUnknown,
/** The query timed out */
OFDNSResolverErrorCodeTimeout,
/** The query was canceled */
Index: src/OFDNSResourceRecord.h
==================================================================
--- src/OFDNSResourceRecord.h
+++ src/OFDNSResourceRecord.h
@@ -25,21 +25,21 @@
@class OFData;
/**
* @brief The DNS class.
*/
-typedef enum OFDNSClass {
+typedef enum {
/** IN */
OFDNSClassIN = 1,
/** Any class. Only for queries. */
OFDNSClassAny = 255,
} OFDNSClass;
/**
* @brief The type of a DNS resource record.
*/
-typedef enum OFDNSRecordType {
+typedef enum {
/** A */
OFDNSRecordTypeA = 1,
/** NS */
OFDNSRecordTypeNS = 2,
/** CNAME */
Index: src/OFData.h
==================================================================
--- src/OFData.h
+++ src/OFData.h
@@ -27,11 +27,11 @@
/**
* @brief Options for searching in data.
*
* This is a bit mask.
*/
-typedef enum OFDataSearchOptions {
+typedef enum {
/** Search backwards in the data */
OFDataSearchBackwards = 1
} OFDataSearchOptions;
/**
Index: src/OFFile.h
==================================================================
--- src/OFFile.h
+++ src/OFFile.h
@@ -19,11 +19,11 @@
#ifndef OF_AMIGAOS
# define OF_FILE_HANDLE_IS_FD
typedef int OFFileHandle;
static const OFFileHandle OFInvalidFileHandle = -1;
#else
-typedef struct OFFileHandle *OFFileHandle;
+typedef struct _OFFileHandle *OFFileHandle;
static const OFFileHandle OFInvalidFileHandle = NULL;
#endif
OF_ASSUME_NONNULL_BEGIN
Index: src/OFFile.m
==================================================================
--- src/OFFile.m
+++ src/OFFile.m
@@ -77,12 +77,12 @@
#endif
#ifndef OF_AMIGAOS
# define closeHandle(h) close(h)
#else
-static struct OFFileHandle
- struct OFFileHandle *previous, *next;
+static struct _OFFileHandle
+ struct _OFFileHandle *previous, *next;
BPTR handle;
bool append;
} *firstHandle = NULL;
static void
Index: src/OFFileManager.h
==================================================================
--- src/OFFileManager.h
+++ src/OFFileManager.h
@@ -227,10 +227,19 @@
/**
* @brief A socket.
*/
extern const OFFileAttributeType OFFileTypeSocket;
+
+/**
+ * @brief An unknown file type.
+ *
+ * This is different from not having an @ref OFFileType at all in that it means
+ * that retrieving file types is supported, but the particular file type is
+ * unknown.
+ */
+extern const OFFileAttributeType OFFileTypeUnknown;
#ifdef __cplusplus
}
#endif
/**
Index: src/OFFileManager.m
==================================================================
--- src/OFFileManager.m
+++ src/OFFileManager.m
@@ -93,10 +93,11 @@
const OFFileAttributeType OFFileTypeFIFO = @"OFFileTypeFIFO";
const OFFileAttributeType OFFileTypeCharacterSpecial =
@"OFFileTypeCharacterSpecial";
const OFFileAttributeType OFFileTypeBlockSpecial = @"OFFileTypeBlockSpecial";
const OFFileAttributeType OFFileTypeSocket = @"OFFileTypeSocket";
+const OFFileAttributeType OFFileTypeUnknown = @"OFFileTypeUnknown";
#ifdef OF_AMIGAOS4
# define CurrentDir(lock) SetCurrentDir(lock)
#endif
Index: src/OFFileURLHandler.m
==================================================================
--- src/OFFileURLHandler.m
+++ src/OFFileURLHandler.m
@@ -386,10 +386,12 @@
#endif
#ifdef S_ISSOCK
else if (S_ISSOCK(s->st_mode))
[attributes setObject: OFFileTypeSocket forKey: OFFileType];
#endif
+ else
+ [attributes setObject: OFFileTypeUnknown forKey: OFFileType];
}
static void
setDateAttributes(OFMutableFileAttributes attributes, Stat *s)
{
Index: src/OFGZIPStream.h
==================================================================
--- src/OFGZIPStream.h
+++ src/OFGZIPStream.h
@@ -21,11 +21,11 @@
OF_ASSUME_NONNULL_BEGIN
/**
* @brief The operating system on which compressed the data.
*/
-typedef enum OFGZIPStreamOperatingSystem {
+typedef enum {
OFGZIPStreamOperatingSystemFAT = 0,
OFGZIPStreamOperatingSystemAmiga = 1,
OFGZIPStreamOperatingSystemVMS = 2,
OFGZIPStreamOperatingSystemUNIX = 3,
OFGZIPStreamOperatingSystemVM_CMS = 4,
Index: src/OFHTTPRequest.h
==================================================================
--- src/OFHTTPRequest.h
+++ src/OFHTTPRequest.h
@@ -27,11 +27,11 @@
/** @file */
/**
* @brief The type of an HTTP request.
*/
-typedef enum OFHTTPRequestMethod {
+typedef enum {
/** OPTIONS */
OFHTTPRequestMethodOptions,
/** GET */
OFHTTPRequestMethodGet,
/** HEAD */
@@ -51,17 +51,16 @@
/**
* @struct OFHTTPRequestProtocolVersion OFHTTPRequest.h ObjFW/OFHTTPRequest.h
*
* @brief The HTTP version of the HTTP request.
*/
-struct OF_BOXABLE OFHTTPRequestProtocolVersion {
+typedef struct OF_BOXABLE {
/** The major of the HTTP version */
unsigned char major;
/** The minor of the HTTP version */
unsigned char minor;
-};
-typedef struct OFHTTPRequestProtocolVersion OFHTTPRequestProtocolVersion;
+} OFHTTPRequestProtocolVersion;
/**
* @class OFHTTPRequest OFHTTPRequest.h ObjFW/OFHTTPRequest.h
*
* @brief A class for storing HTTP requests.
Index: src/OFHuffmanTree.h
==================================================================
--- src/OFHuffmanTree.h
+++ src/OFHuffmanTree.h
@@ -20,22 +20,22 @@
#import "OFInvalidFormatException.h"
OF_ASSUME_NONNULL_BEGIN
-typedef struct OFHuffmanTree {
- struct OFHuffmanTree *_Nullable leaves[2];
+typedef struct _OFHuffmanTree {
+ struct _OFHuffmanTree *_Nullable leaves[2];
uint16_t value;
-} OFHuffmanTree;
+} *OFHuffmanTree;
/* Inlined for performance. */
static OF_INLINE bool
OFHuffmanTreeWalk(id _Nullable stream,
bool (*bitReader)(id _Nullable, uint16_t *_Nonnull, uint8_t),
- OFHuffmanTree *_Nonnull *_Nonnull tree, uint16_t *_Nonnull value)
+ OFHuffmanTree _Nonnull *_Nonnull tree, uint16_t *_Nonnull value)
{
- struct OFHuffmanTree *iter = *tree;
+ OFHuffmanTree iter = *tree;
uint16_t bits;
while (iter->value == 0xFFFF) {
if OF_UNLIKELY (!bitReader(stream, &bits, 1)) {
*tree = iter;
@@ -53,14 +53,14 @@
}
#ifdef __cplusplus
extern "C" {
#endif
-extern OFHuffmanTree *_Nonnull OFHuffmanTreeNew(uint8_t lengths[_Nonnull],
+extern OFHuffmanTree _Nonnull OFHuffmanTreeNew(uint8_t lengths[_Nonnull],
uint16_t count);
-extern OFHuffmanTree *_Nonnull OFHuffmanTreeNewSingle(uint16_t value);
-extern void OFHuffmanTreeFree(OFHuffmanTree *_Nonnull tree);
+extern OFHuffmanTree _Nonnull OFHuffmanTreeNewSingle(uint16_t value);
+extern void OFHuffmanTreeFree(OFHuffmanTree _Nonnull tree);
#ifdef __cplusplus
}
#endif
OF_ASSUME_NONNULL_END
Index: src/OFHuffmanTree.m
==================================================================
--- src/OFHuffmanTree.m
+++ src/OFHuffmanTree.m
@@ -21,24 +21,24 @@
#import "OFHuffmanTree.h"
#import "OFInvalidFormatException.h"
#import "OFOutOfMemoryException.h"
-static OFHuffmanTree *
+static OFHuffmanTree
newTree(void)
{
- OFHuffmanTree *tree;
+ OFHuffmanTree tree;
tree = OFAllocMemory(1, sizeof(*tree));
tree->leaves[0] = tree->leaves[1] = NULL;
tree->value = 0xFFFF;
return tree;
}
static void
-treeInsert(OFHuffmanTree *tree, uint16_t code, uint8_t length, uint16_t value)
+treeInsert(OFHuffmanTree tree, uint16_t code, uint8_t length, uint16_t value)
{
while (length > 0) {
uint8_t bit;
length--;
@@ -51,14 +51,14 @@
}
tree->value = value;
}
-OFHuffmanTree *
+OFHuffmanTree
OFHuffmanTreeNew(uint8_t lengths[], uint16_t count)
{
- OFHuffmanTree *tree;
+ OFHuffmanTree tree;
uint16_t *lengthCount = NULL;
uint16_t code, maxCode = 0, *nextCode = NULL;
uint_fast8_t maxBit = 0;
@try {
@@ -106,24 +106,24 @@
}
return tree;
}
-OFHuffmanTree *
+OFHuffmanTree
OFHuffmanTreeNewSingle(uint16_t value)
{
- OFHuffmanTree *tree = newTree();
+ OFHuffmanTree tree = newTree();
tree->value = value;
return tree;
}
void
-OFHuffmanTreeFree(OFHuffmanTree *tree)
+OFHuffmanTreeFree(OFHuffmanTree tree)
{
for (uint_fast8_t i = 0; i < 2; i++)
if OF_LIKELY (tree->leaves[i] != NULL)
OFHuffmanTreeFree(tree->leaves[i]);
OFFreeMemory(tree);
}
Index: src/OFINICategory.h
==================================================================
--- src/OFINICategory.h
+++ src/OFINICategory.h
@@ -138,22 +138,22 @@
- (OFArray OF_GENERIC(OFString *) *)stringArrayForKey: (OFString *)key;
/**
* @brief Sets the value of the specified key to the specified string.
*
- * If the specified key is a multi-key (see @ref stringValuesForKey:), the
- * value of the first key/value pair found is changed.
+ * If the specified key is a multi-key (see @ref stringArrayForKey:), the value
+ * of the first key/value pair found is changed.
*
* @param string The string to which the key should be set
* @param key The key for which the new value should be set
*/
- (void)setString: (OFString *)string forKey: (OFString *)key;
/**
* @brief Sets the value of the specified key to the specified long long.
*
- * If the specified key is a multi-key (see @ref stringValuesForKey:), the value
+ * If the specified key is a multi-key (see @ref stringArrayForKey:), the value
* of the first key/value pair found is changed.
*
* @param longLong The long long to which the key should be set
* @param key The key for which the new value should be set
*/
@@ -160,33 +160,33 @@
- (void)setLongLong: (long long)longLong forKey: (OFString *)key;
/**
* @brief Sets the value of the specified key to the specified bool.
*
- * If the specified key is a multi-key (see @ref stringValuesForKey:), the
- * value of the first key/value pair found is changed.
+ * If the specified key is a multi-key (see @ref stringArrayForKey:), the value
+ * of the first key/value pair found is changed.
*
* @param bool_ The bool to which the key should be set
* @param key The key for which the new value should be set
*/
- (void)setBool: (bool)bool_ forKey: (OFString *)key;
/**
* @brief Sets the value of the specified key to the specified float.
*
- * If the specified key is a multi-key (see @ref stringValuesForKey:), the
- * value of the first key/value pair found is changed.
+ * If the specified key is a multi-key (see @ref stringArrayForKey:), the value
+ * of the first key/value pair found is changed.
*
* @param float_ The float to which the key should be set
* @param key The key for which the new value should be set
*/
- (void)setFloat: (float)float_ forKey: (OFString *)key;
/**
* @brief Sets the value of the specified key to the specified double.
*
- * If the specified key is a multi-key (see @ref stringValuesForKey:), the value
+ * If the specified key is a multi-key (see @ref stringArrayForKey:), the value
* of the first key/value pair found is changed.
*
* @param double_ The double to which the key should be set
* @param key The key for which the new value should be set
*/
@@ -208,14 +208,14 @@
forKey: (OFString *)key;
/**
* @brief Removes the value for the specified key
*
- * If the specified key is a multi-key (see @ref stringValuesForKey:), all
+ * If the specified key is a multi-key (see @ref stringArrayForKey:), all
* key/value pairs matching the specified key are removed.
*
* @param key The key of the value to remove
*/
- (void)removeValueForKey: (OFString *)key;
@end
OF_ASSUME_NONNULL_END
Index: src/OFIPXSocket.h
==================================================================
--- src/OFIPXSocket.h
+++ src/OFIPXSocket.h
@@ -33,11 +33,11 @@
* @brief A class which provides methods to create and use IPX sockets.
*
* Addresses are of type @ref OFSocketAddress. You can use
* @ref OFSocketAddressMakeIPX to create an address or
* @ref OFSocketAddressIPXNetwork to get the IPX network,
- * @ref OFSocketAddressIpxNode to get the IPX node and
+ * @ref OFSocketAddressIPXNode to get the IPX node and
* @ref OFSocketAddressPort to get the port (sometimes also called
* socket number).
*
* @warning Even though the OFCopying protocol is implemented, it does *not*
* return an independent copy of the socket, but instead retains it.
Index: src/OFInflate64Stream.h
==================================================================
--- src/OFInflate64Stream.h
+++ src/OFInflate64Stream.h
@@ -49,23 +49,23 @@
} uncompressedHeader;
struct {
uint16_t position, length;
} uncompressed;
struct {
- OFHuffmanTree *_Nullable litLenTree;
- OFHuffmanTree *_Nullable distTree;
- OFHuffmanTree *_Nullable codeLenTree;
- OFHuffmanTree *_Nullable treeIter;
+ OFHuffmanTree _Nullable litLenTree;
+ OFHuffmanTree _Nullable distTree;
+ OFHuffmanTree _Nullable codeLenTree;
+ OFHuffmanTree _Nullable treeIter;
uint8_t *_Nullable lengths;
uint16_t receivedCount;
uint8_t value, litLenCodesCount, distCodesCount;
uint8_t codeLenCodesCount;
} huffmanTree;
struct {
- OFHuffmanTree *_Nullable litLenTree;
- OFHuffmanTree *_Nullable distTree;
- OFHuffmanTree *_Nullable treeIter;
+ OFHuffmanTree _Nullable litLenTree;
+ OFHuffmanTree _Nullable distTree;
+ OFHuffmanTree _Nullable treeIter;
int state;
uint16_t value, length, distance, extraBits;
} huffman;
} _context;
bool _inLastBlock, _atEndOfStream;
Index: src/OFInflateStream.h
==================================================================
--- src/OFInflateStream.h
+++ src/OFInflateStream.h
@@ -49,23 +49,23 @@
} uncompressedHeader;
struct {
uint16_t position, length;
} uncompressed;
struct {
- OFHuffmanTree *_Nullable litLenTree;
- OFHuffmanTree *_Nullable distTree;
- OFHuffmanTree *_Nullable codeLenTree;
- OFHuffmanTree *_Nullable treeIter;
+ OFHuffmanTree _Nullable litLenTree;
+ OFHuffmanTree _Nullable distTree;
+ OFHuffmanTree _Nullable codeLenTree;
+ OFHuffmanTree _Nullable treeIter;
uint8_t *_Nullable lengths;
uint16_t receivedCount;
uint8_t value, litLenCodesCount, distCodesCount;
uint8_t codeLenCodesCount;
} huffmanTree;
struct {
- OFHuffmanTree *_Nullable litLenTree;
- OFHuffmanTree *_Nullable distTree;
- OFHuffmanTree *_Nullable treeIter;
+ OFHuffmanTree _Nullable litLenTree;
+ OFHuffmanTree _Nullable distTree;
+ OFHuffmanTree _Nullable treeIter;
int state;
uint16_t value, length, distance, extraBits;
} huffman;
} _context;
bool _inLastBlock, _atEndOfStream;
Index: src/OFInflateStream.m
==================================================================
--- src/OFInflateStream.m
+++ src/OFInflateStream.m
@@ -97,11 +97,11 @@
};
#endif
static const uint8_t codeLengthsOrder[19] = {
16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15
};
-static OFHuffmanTree *fixedLitLenTree, *fixedDistTree;
+static OFHuffmanTree fixedLitLenTree, fixedDistTree;
@implementation OFInflateStream
static OF_INLINE bool
tryReadBits(OFInflateStream *stream, uint16_t *bits, uint8_t count)
{
Index: src/OFJSONRepresentation.h
==================================================================
--- src/OFJSONRepresentation.h
+++ src/OFJSONRepresentation.h
@@ -20,11 +20,11 @@
OF_ASSUME_NONNULL_BEGIN
/**
* @brief Options to change the behavior when creating a JSON representation.
*/
-typedef enum OFJSONRepresentationOptions {
+typedef enum {
/** Optimize for readability */
OFJSONRepresentationOptionPretty = 0x01,
/** Generate JSON5 */
OFJSONRepresentationOptionJSON5 = 0x02,
OFJSONRepresentationOptionIsIdentifier = 0x10
Index: src/OFLHAArchive.h
==================================================================
--- src/OFLHAArchive.h
+++ src/OFLHAArchive.h
@@ -29,15 +29,11 @@
*/
OF_SUBCLASSING_RESTRICTED
@interface OFLHAArchive: OFObject
{
OFStream *_stream;
- enum {
- OFLHAArchiveModeRead,
- OFLHAArchiveModeWrite,
- OFLHAArchiveModeAppend
- } _mode;
+ uint_least8_t _mode;
OFStringEncoding _encoding;
OFStream *_Nullable _lastReturnedStream;
}
/**
Index: src/OFLHAArchive.m
==================================================================
--- src/OFLHAArchive.m
+++ src/OFLHAArchive.m
@@ -32,10 +32,16 @@
#import "OFNotImplementedException.h"
#import "OFNotOpenException.h"
#import "OFOutOfRangeException.h"
#import "OFTruncatedDataException.h"
#import "OFWriteFailedException.h"
+
+enum {
+ modeRead,
+ modeWrite,
+ modeAppend
+};
OF_DIRECT_MEMBERS
@interface OFLHAArchiveFileReadStream: OFStream
{
OFStream *_stream, *_decompressedStream;
@@ -92,24 +98,23 @@
@try {
_stream = [stream retain];
if ([mode isEqual: @"r"])
- _mode = OFLHAArchiveModeRead;
+ _mode = modeRead;
else if ([mode isEqual: @"w"])
- _mode = OFLHAArchiveModeWrite;
+ _mode = modeWrite;
else if ([mode isEqual: @"a"])
- _mode = OFLHAArchiveModeAppend;
+ _mode = modeAppend;
else
@throw [OFInvalidArgumentException exception];
- if ((_mode == OFLHAArchiveModeWrite ||
- _mode == OFLHAArchiveModeAppend) &&
+ if ((_mode == modeWrite || _mode == modeAppend) &&
![_stream isKindOfClass: [OFSeekableStream class]])
@throw [OFInvalidArgumentException exception];
- if (_mode == OFLHAArchiveModeAppend)
+ if (_mode == modeAppend)
[(OFSeekableStream *)_stream seekToOffset: 0
whence: SEEK_END];
_encoding = OFStringEncodingISO8859_1;
} @catch (id e) {
@@ -152,11 +157,11 @@
{
OFLHAArchiveEntry *entry;
char header[21];
size_t headerLen;
- if (_mode != OFLHAArchiveModeRead)
+ if (_mode != modeRead)
@throw [OFInvalidArgumentException exception];
[(OFLHAArchiveFileReadStream *)_lastReturnedStream of_skip];
@try {
[_lastReturnedStream close];
@@ -193,11 +198,11 @@
return entry;
}
- (OFStream *)streamForReadingCurrentEntry
{
- if (_mode != OFLHAArchiveModeRead)
+ if (_mode != modeRead)
@throw [OFInvalidArgumentException exception];
if (_lastReturnedStream == nil)
@throw [OFInvalidArgumentException exception];
@@ -207,11 +212,11 @@
- (OFStream *)streamForWritingEntry: (OFLHAArchiveEntry *)entry
{
OFString *compressionMethod;
- if (_mode != OFLHAArchiveModeWrite && _mode != OFLHAArchiveModeAppend)
+ if (_mode != modeWrite && _mode != modeAppend)
@throw [OFInvalidArgumentException exception];
compressionMethod = entry.compressionMethod;
if (![compressionMethod isEqual: @"-lh0-"] &&
Index: src/OFLHADecompressingStream.h
==================================================================
--- src/OFLHADecompressingStream.h
+++ src/OFLHADecompressingStream.h
@@ -33,12 +33,14 @@
uint16_t _savedBits;
unsigned char *_slidingWindow;
uint32_t _slidingWindowIndex, _slidingWindowMask;
int _state;
uint16_t _symbolsLeft;
- OFHuffmanTree *_Nullable _codeLenTree, *_Nullable _litLenTree;
- OFHuffmanTree *_Nullable _distTree, *_Nullable _treeIter;
+ OFHuffmanTree _Nullable _codeLenTree;
+ OFHuffmanTree _Nullable _litLenTree;
+ OFHuffmanTree _Nullable _distTree;
+ OFHuffmanTree _Nullable _treeIter;
uint16_t _codesCount, _codesReceived;
bool _currentIsExtendedLength, _skip;
uint8_t *_Nullable _codesLengths;
uint16_t _length;
uint32_t _distance;
Index: src/OFList.h
==================================================================
--- src/OFList.h
+++ src/OFList.h
@@ -18,18 +18,31 @@
#import "OFEnumerator.h"
#import "OFSerialization.h"
OF_ASSUME_NONNULL_BEGIN
+/** @file */
+
+/*
+ * Make clang's -Wdocumentation shut about about using @struct on someting it
+ * thinks is not a struct. Doxygen requires it this way.
+ */
+#ifdef __clang__
+# pragma clang diagnostic push
+# pragma clang diagnostic ignored "-Wdocumentation"
+#endif
/**
- * @typedef OFListItem OFList.h ObjFW/OFList.h
+ * @struct OFListItem OFList.h ObjFW/OFList.h
*
* @brief A list item.
*
* See @ref OFListItemNext, @ref OFListItemPrevious and @ref OFListItemObject.
*/
-typedef struct OFListItem *OFListItem;
+typedef struct _OFListItem *OFListItem;
+#ifdef __clang__
+# pragma clang diagnostic pop
+#endif
#ifdef __cplusplus
extern "C" {
#endif
/*!
Index: src/OFList.m
==================================================================
--- src/OFList.m
+++ src/OFList.m
@@ -24,12 +24,12 @@
#import "OFArray.h"
#import "OFEnumerationMutationException.h"
#import "OFInvalidArgumentException.h"
-struct OFListItem {
- OFListItem previous, next;
+struct _OFListItem {
+ struct _OFListItem *previous, *next;
id object;
};
OF_DIRECT_MEMBERS
@interface OFListEnumerator: OFEnumerator
Index: src/OFMapTable.h
==================================================================
--- src/OFMapTable.h
+++ src/OFMapTable.h
@@ -23,22 +23,21 @@
/**
* @struct OFMapTableFunctions OFMapTable.h ObjFW/OFMapTable.h
*
* @brief A struct describing the functions to be used by the map table.
*/
-struct OFMapTableFunctions {
+typedef struct {
/** The function to retain keys / objects */
void *_Nullable (*_Nullable retain)(void *_Nullable object);
/** The function to release keys / objects */
void (*_Nullable release)(void *_Nullable object);
/** The function to hash keys */
unsigned long (*_Nullable hash)(void *_Nullable object);
/** The function to compare keys / objects */
bool (*_Nullable equal)(void *_Nullable object1,
void *_Nullable object2);
-};
-typedef struct OFMapTableFunctions OFMapTableFunctions;
+} OFMapTableFunctions;
#ifdef OF_HAVE_BLOCKS
/**
* @brief A block for enumerating an OFMapTable.
*
Index: src/OFMapTable.m
==================================================================
--- src/OFMapTable.m
+++ src/OFMapTable.m
@@ -25,10 +25,12 @@
#import "OFEnumerator.h"
#import "OFEnumerationMutationException.h"
#import "OFInvalidArgumentException.h"
#import "OFOutOfRangeException.h"
+
+extern unsigned long OFHashSeed;
static const unsigned long minCapacity = 16;
struct OFMapTableBucket {
void *key, *object;
Index: src/OFObject.h
==================================================================
--- src/OFObject.h
+++ src/OFObject.h
@@ -52,11 +52,11 @@
/** @file */
/**
* @brief A result of a comparison.
*/
-typedef enum OFComparisonResult {
+typedef enum {
/** The left object is smaller than the right */
OFOrderedAscending = -1,
/** Both objects are equal */
OFOrderedSame = 0,
/** The left object is bigger than the right */
@@ -73,13 +73,13 @@
*/
typedef OFComparisonResult (^OFComparator)(id _Nonnull left, id _Nonnull right);
#endif
/**
- * @brief An enum for storing endianess.
+ * @brief An enum for representing endianess.
*/
-typedef enum OFByteOrder {
+typedef enum {
/** Most significant byte first (big endian) */
OFByteOrderBigEndian,
/** Least significant byte first (little endian) */
OFByteOrderLittleEndian,
/** Native byte order of the system */
@@ -93,17 +93,16 @@
/**
* @struct OFRange OFObject.h ObjFW/OFObject.h
*
* @brief A range.
*/
-struct OF_BOXABLE OFRange {
+typedef struct OF_BOXABLE {
/** The start of the range */
size_t location;
/** The length of the range */
size_t length;
-};
-typedef struct OFRange OFRange;
+} OFRange;
/**
* @brief Creates a new OFRange.
*
* @param start The starting index of the range
@@ -145,17 +144,16 @@
/**
* @struct OFPoint OFObject.h ObjFW/OFObject.h
*
* @brief A point.
*/
-struct OF_BOXABLE OFPoint {
+typedef struct OF_BOXABLE {
/** The x coordinate of the point */
float x;
/** The y coordinate of the point */
float y;
-};
-typedef struct OFPoint OFPoint;
+} OFPoint;
/**
* @brief Creates a new OFPoint.
*
* @param x The x coordinate of the point
@@ -192,17 +190,16 @@
/**
* @struct OFSize OFObject.h ObjFW/OFObject.h
*
* @brief A size.
*/
-struct OF_BOXABLE OFSize {
+typedef struct OF_BOXABLE {
/** The width of the size */
float width;
/** The height of the size */
float height;
-};
-typedef struct OFSize OFSize;
+} OFSize;
/**
* @brief Creates a new OFSize.
*
* @param width The width of the size
@@ -239,17 +236,16 @@
/**
* @struct OFRect OFObject.h ObjFW/OFObject.h
*
* @brief A rectangle.
*/
-struct OF_BOXABLE OFRect {
+typedef struct OF_BOXABLE {
/** The point from where the rectangle originates */
OFPoint origin;
/** The size of the rectangle */
OFSize size;
-};
-typedef struct OFRect OFRect;
+} OFRect;
/**
* @brief Creates a new OFRect.
*
* @param x The x coordinate of the top left corner of the rectangle
@@ -285,10 +281,60 @@
if (!OFSizeEqual(rect1.size, rect2.size))
return false;
return true;
}
+
+/**
+ * @brief Adds the specified byte to the hash.
+ *
+ * @param hash A pointer to a hash to add the byte to
+ * @param byte The byte to add to the hash
+ */
+static OF_INLINE void
+OFHashAdd(unsigned long *_Nonnull hash, unsigned char byte)
+{
+ uint32_t tmp = (uint32_t)*hash;
+
+ tmp += byte;
+ tmp += tmp << 10;
+ tmp ^= tmp >> 6;
+
+ *hash = tmp;
+}
+
+/**
+ * @brief Adds the specified hash to the hash.
+ *
+ * @param hash A pointer to a hash to add the hash to
+ * @param otherHash The hash to add to the hash
+ */
+static OF_INLINE void
+OFHashAddHash(unsigned long *_Nonnull hash, unsigned long otherHash)
+{
+ OFHashAdd(hash, (otherHash >> 24) & 0xFF);
+ OFHashAdd(hash, (otherHash >> 16) & 0xFF);
+ OFHashAdd(hash, (otherHash >> 8) & 0xFF);
+ OFHashAdd(hash, otherHash & 0xFF);
+}
+
+/**
+ * @brief Finalizes the specified hash.
+ *
+ * @param hash A pointer to the hash to finalize
+ */
+static OF_INLINE void
+OFHashFinalize(unsigned long *_Nonnull hash)
+{
+ uint32_t tmp = (uint32_t)*hash;
+
+ tmp += tmp << 3;
+ tmp ^= tmp >> 11;
+ tmp += tmp << 15;
+
+ *hash = tmp;
+}
static const size_t OFNotFound = SIZE_MAX;
#ifdef __OBJC__
@class OFMethodSignature;
@@ -1334,10 +1380,17 @@
* @brief Returns 64 bit or non-cryptographical randomness.
*
* @return 64 bit or non-cryptographical randomness
*/
extern uint64_t OFRandom64(void);
+
+/**
+ * @brief Initializes the specified hash.
+ *
+ * @param hash A pointer to the hash to initialize
+ */
+extern void OFHashInit(unsigned long *_Nonnull hash);
#ifdef __cplusplus
}
#endif
OF_ASSUME_NONNULL_END
Index: src/OFObject.m
==================================================================
--- src/OFObject.m
+++ src/OFObject.m
@@ -225,10 +225,16 @@
return buffer;
#else
return ((uint64_t)OFRandom32() << 32) | OFRandom32();
#endif
}
+
+void
+OFHashInit(unsigned long *hash)
+{
+ *hash = OFHashSeed;
+}
static const char *
typeEncodingForSelector(Class class, SEL selector)
{
Method method;
Index: src/OFOptionsParser.h
==================================================================
--- src/OFOptionsParser.h
+++ src/OFOptionsParser.h
@@ -23,11 +23,11 @@
/**
* @struct OFOptionsParserOption OFOptionsParser.h ObjFW/OFOptionsParser.h
*
* @brief An option which can be parsed by an @ref OFOptionsParser.
*/
-struct OFOptionsParserOption {
+typedef struct {
/** The short version (e.g. `-v`) of the option or `\0` for none. */
OFUnichar shortOption;
/**
* The long version (e.g. `--verbose`) of the option or `nil` for none.
@@ -55,12 +55,11 @@
/**
* An optional pointer to an `OFString *` that is set to the
* argument specified for the option or `nil` for no argument.
*/
OFString *__autoreleasing _Nullable *_Nullable argumentPtr;
-};
-typedef struct OFOptionsParserOption OFOptionsParserOption;
+} OFOptionsParserOption;
/**
* @class OFOptionsParser OFOptionsParser.h ObjFW/OFOptionsParser.h
*
* @brief A class for parsing the program options specified on the command line.
Index: src/OFPBKDF2.h
==================================================================
--- src/OFPBKDF2.h
+++ src/OFPBKDF2.h
@@ -29,11 +29,11 @@
@class OFHMAC;
/**
* @brief The parameters for @ref OFPBKDF2.
*/
-typedef struct OFPBKDF2Parameters {
+typedef struct {
/** @brief The HMAC to use to derive a key. */
__unsafe_unretained OFHMAC *HMAC;
/** @brief The number of iterations to perform. */
size_t iterations;
/** @brief The salt to derive a key with. */
Index: src/OFPlainThread.h
==================================================================
--- src/OFPlainThread.h
+++ src/OFPlainThread.h
@@ -42,11 +42,11 @@
unsigned char joinSigBit;
bool detached, done;
} *OFPlainThread;
#endif
-typedef struct OFPlainThreadAttributes {
+typedef struct {
float priority;
size_t stackSize;
} OFPlainThreadAttributes;
#if defined(OF_HAVE_PTHREADS)
Index: src/OFPlugin.h
==================================================================
--- src/OFPlugin.h
+++ src/OFPlugin.h
@@ -19,19 +19,19 @@
#ifndef OF_WINDOWS
# include
typedef void *OFPluginHandle;
-typedef enum OFDLOpenFlags {
+typedef enum {
OFDLOpenFlagLazy = RTLD_LAZY,
OFDLOpenFlagNow = RTLD_NOW
} OFDLOpenFlags;
#else
# include
typedef HMODULE OFPluginHandle;
-typedef enum OFDLOpenFlags {
+typedef enum {
OFDLOpenFlagLazy = 0,
OFDLOpenFlagNow = 0
} OFDLOpenFlags;
#endif
@@ -39,10 +39,14 @@
/**
* @class OFPlugin OFPlugin.h ObjFW/OFPlugin.h
*
* @brief Provides a system for loading plugins at runtime.
+ *
+ * A plugin must subclass @ref OFPlugin and have a global function called
+ * `OFPluginInit`, which returns an instance of the @ref OFPlugin subclass and
+ * takes no parameters.
*/
@interface OFPlugin: OFObject
{
OFPluginHandle _pluginHandle;
OF_RESERVE_IVARS(OFPlugin, 4)
Index: src/OFScrypt.h
==================================================================
--- src/OFScrypt.h
+++ src/OFScrypt.h
@@ -29,11 +29,11 @@
@class OFHMAC;
/**
* @brief The parameters for @ref OFScrypt.
*/
-typedef struct OFScryptParameters {
+typedef struct {
/** @brief The block size to use. */
size_t blockSize;
/** @brief The CPU/memory cost factor to use. */
size_t costFactor;
/** @brief The parallelization to use. */
Index: src/OFSocket.h
==================================================================
--- src/OFSocket.h
+++ src/OFSocket.h
@@ -128,11 +128,11 @@
/**
* @struct OFSocketAddress OFSocket.h ObjFW/OFSocket.h
*
* @brief A struct which represents a host / port pair for a socket.
*/
-struct OF_BOXABLE OFSocketAddress {
+typedef struct OF_BOXABLE {
/*
* Even though struct sockaddr contains the family, we need to use our
* own family, as we need to support storing an IPv6 address on systems
* that don't support IPv6. These may not have AF_INET6 defined and we
* can't just define it, as the value is system-dependent and might
@@ -144,12 +144,11 @@
struct sockaddr_in in;
struct sockaddr_in6 in6;
struct sockaddr_ipx ipx;
} sockaddr;
socklen_t length;
-};
-typedef struct OFSocketAddress OFSocketAddress;
+} OFSocketAddress;
#ifdef __cplusplus
extern "C" {
#endif
/**
Index: src/OFString.h
==================================================================
--- src/OFString.h
+++ src/OFString.h
@@ -63,11 +63,11 @@
typedef OFChar32 OFUnichar;
/**
* @brief The encoding of a string.
*/
-typedef enum OFStringEncoding {
+typedef enum {
/*
* UTF-8 *has* to be 0, so that if the current @ref OFLocale is
* `nil`, `[OFLocale encoding]` returns UTF-8.
*/
/** UTF-8 */
@@ -105,21 +105,21 @@
/**
* @brief Options for searching in strings.
*
* This is a bit mask.
*/
-typedef enum OFStringSearchOptions {
+typedef enum {
/** Search backwards in the string */
OFStringSearchBackwards = 1
} OFStringSearchOptions;
/**
* @brief Options for separating strings.
*
* This is a bit mask.
*/
-typedef enum OFStringSeparationOptions {
+typedef enum {
/** Skip empty components */
OFStringSkipEmptyComponents = 1
} OFStringSeparationOptions;
#ifdef OF_HAVE_BLOCKS
Index: src/OFTCPSocketSOCKS5Connector.h
==================================================================
--- src/OFTCPSocketSOCKS5Connector.h
+++ src/OFTCPSocketSOCKS5Connector.h
@@ -27,18 +27,11 @@
id _Nullable _delegate;
#ifdef OF_HAVE_BLOCKS
OFTCPSocketAsyncConnectBlock _Nullable _block;
#endif
id _Nullable _exception;
- enum {
- OFSOCKS5StateSendAuthentication = 1,
- OFSOCKS5StateReadVersion,
- OFSOCKS5StateSendRequest,
- OFSOCKS5StateReadResponse,
- OFSOCKS5StateReadAddress,
- OFSOCKS5StateReadAddressLength,
- } _SOCKS5State;
+ uint_least8_t _SOCKS5State;
/* Longest read is domain name (max 255 bytes) + port */
unsigned char _buffer[257];
OFMutableData *_Nullable _request;
}
Index: src/OFTCPSocketSOCKS5Connector.m
==================================================================
--- src/OFTCPSocketSOCKS5Connector.m
+++ src/OFTCPSocketSOCKS5Connector.m
@@ -22,10 +22,19 @@
#import "OFData.h"
#import "OFRunLoop.h"
#import "OFString.h"
#import "OFConnectionFailedException.h"
+
+enum {
+ stateSendAuthentication = 1,
+ stateReadVersion,
+ stateSendRequest,
+ stateReadResponse,
+ stateReadAddress,
+ stateReadAddressLength,
+};
@implementation OFTCPSocketSOCKS5Connector
- (instancetype)initWithSocket: (OFTCPSocket *)sock
host: (OFString *)host
port: (uint16_t)port
@@ -104,11 +113,11 @@
return;
}
data = [OFData dataWithItems: "\x05\x01\x00" count: 3];
- _SOCKS5State = OFSOCKS5StateSendAuthentication;
+ _SOCKS5State = stateSendAuthentication;
[_socket asyncWriteData: data
runLoopMode: [OFRunLoop currentRunLoop].currentMode];
}
- (bool)stream: (OFStream *)sock
@@ -129,11 +138,11 @@
}
runLoopMode = [OFRunLoop currentRunLoop].currentMode;
switch (_SOCKS5State) {
- case OFSOCKS5StateReadVersion:
+ case stateReadVersion:
SOCKSVersion = buffer;
if (SOCKSVersion[0] != 5 || SOCKSVersion[1] != 0) {
_exception = [[OFConnectionFailedException alloc]
initWithHost: _host
@@ -155,14 +164,14 @@
port[0] = _port >> 8;
port[1] = _port & 0xFF;
[_request addItems: port count: 2];
- _SOCKS5State = OFSOCKS5StateSendRequest;
+ _SOCKS5State = stateSendRequest;
[_socket asyncWriteData: _request runLoopMode: runLoopMode];
return false;
- case OFSOCKS5StateReadResponse:
+ case stateReadResponse:
response = buffer;
if (response[0] != 5 || response[2] != 0) {
_exception = [[OFConnectionFailedException alloc]
initWithHost: _host
@@ -217,23 +226,23 @@
}
/* Skip the rest of the response */
switch (response[3]) {
case 1: /* IPv4 */
- _SOCKS5State = OFSOCKS5StateReadAddress;
+ _SOCKS5State = stateReadAddress;
[_socket asyncReadIntoBuffer: _buffer
exactLength: 4 + 2
runLoopMode: runLoopMode];
return false;
case 3: /* Domain name */
- _SOCKS5State = OFSOCKS5StateReadAddressLength;
+ _SOCKS5State = stateReadAddressLength;
[_socket asyncReadIntoBuffer: _buffer
exactLength: 1
runLoopMode: runLoopMode];
return false;
case 4: /* IPv6 */
- _SOCKS5State = OFSOCKS5StateReadAddress;
+ _SOCKS5State = stateReadAddress;
[_socket asyncReadIntoBuffer: _buffer
exactLength: 16 + 2
runLoopMode: runLoopMode];
return false;
default:
@@ -245,17 +254,17 @@
[self didConnect];
return false;
}
return false;
- case OFSOCKS5StateReadAddress:
+ case stateReadAddress:
[self didConnect];
return false;
- case OFSOCKS5StateReadAddressLength:
+ case stateReadAddressLength:
addressLength = buffer;
- _SOCKS5State = OFSOCKS5StateReadAddress;
+ _SOCKS5State = stateReadAddress;
[_socket asyncReadIntoBuffer: _buffer
exactLength: addressLength[0] + 2
runLoopMode: runLoopMode];
return false;
default:
@@ -278,21 +287,21 @@
}
runLoopMode = [OFRunLoop currentRunLoop].currentMode;
switch (_SOCKS5State) {
- case OFSOCKS5StateSendAuthentication:
- _SOCKS5State = OFSOCKS5StateReadVersion;
+ case stateSendAuthentication:
+ _SOCKS5State = stateReadVersion;
[_socket asyncReadIntoBuffer: _buffer
exactLength: 2
runLoopMode: runLoopMode];
return nil;
- case OFSOCKS5StateSendRequest:
+ case stateSendRequest:
[_request release];
_request = nil;
- _SOCKS5State = OFSOCKS5StateReadResponse;
+ _SOCKS5State = stateReadResponse;
[_socket asyncReadIntoBuffer: _buffer
exactLength: 4
runLoopMode: runLoopMode];
return nil;
default:
Index: src/OFTLSKey.h
==================================================================
--- src/OFTLSKey.h
+++ src/OFTLSKey.h
@@ -34,13 +34,13 @@
typedef DWORD OFTLSKey;
#elif defined(OF_MORPHOS)
# include
typedef ULONG OFTLSKey;
#elif defined(OF_AMIGAOS)
-typedef struct OFTLSKey {
+typedef struct _OFTLSKey {
struct objc_hashtable *table;
- struct OFTLSKey *next, *previous;
+ struct _OFTLSKey *next, *previous;
} *OFTLSKey;
#endif
#ifdef __cplusplus
extern "C" {
Index: src/OFTarArchiveEntry.h
==================================================================
--- src/OFTarArchiveEntry.h
+++ src/OFTarArchiveEntry.h
@@ -22,11 +22,11 @@
@class OFDate;
/**
* @brief The type of the archive entry.
*/
-typedef enum OFTarArchiveEntryType {
+typedef enum {
/** Normal file */
OFTarArchiveEntryTypeFile = '0',
/** Hard link */
OFTarArchiveEntryTypeLink = '1',
/** Symbolic link */
Index: src/OFXMLParser.h
==================================================================
--- src/OFXMLParser.h
+++ src/OFXMLParser.h
@@ -128,32 +128,11 @@
*/
OF_SUBCLASSING_RESTRICTED
@interface OFXMLParser: OFObject
{
id _Nullable _delegate;
- enum {
- OFXMLParserStateInByteOrderMark,
- OFXMLParserStateOutsideTag,
- OFXMLParserStateTagOpened,
- OFXMLParserStateInProcessingInstruction,
- OFXMLParserStateInTagName,
- OFXMLParserStateInCloseTagName,
- OFXMLParserStateInTag,
- OFXMLParserStateInAttributeName,
- OFXMLParserStateExpectAttributeEqualSign,
- OFXMLParserStateExpectAttributeDelimiter,
- OFXMLParserStateInAttributeValue,
- OFXMLParserStateExpectTagClose,
- OFXMLParserStateExpectSpaceOrTagClose,
- OFXMLParserStateInExclamationMark,
- OFXMLParserStateInCDATAOpening,
- OFXMLParserStateInCDATA,
- OFXMLParserStateInCommentOpening,
- OFXMLParserStateInComment1,
- OFXMLParserStateInComment2,
- OFXMLParserStateInDOCTYPE
- } _state;
+ uint_least8_t _state;
size_t _i, _last;
const char *_Nullable _data;
OFMutableData *_buffer;
OFString *_Nullable _name, *_Nullable _prefix;
OFMutableArray
Index: src/OFXMLParser.m
==================================================================
--- src/OFXMLParser.m
+++ src/OFXMLParser.m
@@ -37,10 +37,33 @@
#import "OFInvalidEncodingException.h"
#import "OFInvalidFormatException.h"
#import "OFMalformedXMLException.h"
#import "OFOutOfRangeException.h"
#import "OFUnboundPrefixException.h"
+
+enum {
+ stateInByteOrderMark,
+ stateOutsideTag,
+ stateTagOpened,
+ stateInProcessingInstruction,
+ stateInTagName,
+ stateInCloseTagName,
+ stateInTag,
+ stateInAttributeName,
+ stateExpectAttributeEqualSign,
+ stateExpectAttributeDelimiter,
+ stateInAttributeValue,
+ stateExpectTagClose,
+ stateExpectSpaceOrTagClose,
+ stateInExclamationMark,
+ stateInCDATAOpening,
+ stateInCDATA,
+ stateInCommentOpening,
+ stateInComment1,
+ stateInComment2,
+ stateInDOCTYPE
+};
@interface OFXMLParser ()
@end
static void inByteOrderMarkState(OFXMLParser *);
@@ -63,33 +86,30 @@
static void inCommentState1(OFXMLParser *);
static void inCommentState2(OFXMLParser *);
static void inDOCTYPEState(OFXMLParser *);
typedef void (*StateFunction)(OFXMLParser *);
static StateFunction lookupTable[] = {
- [OFXMLParserStateInByteOrderMark] = inByteOrderMarkState,
- [OFXMLParserStateOutsideTag] = outsideTagState,
- [OFXMLParserStateTagOpened] = tagOpenedState,
- [OFXMLParserStateInProcessingInstruction] =
- inProcessingInstructionState,
- [OFXMLParserStateInTagName] = inTagNameState,
- [OFXMLParserStateInCloseTagName] = inCloseTagNameState,
- [OFXMLParserStateInTag] = inTagState,
- [OFXMLParserStateInAttributeName] = inAttributeNameState,
- [OFXMLParserStateExpectAttributeEqualSign] =
- expectAttributeEqualSignState,
- [OFXMLParserStateExpectAttributeDelimiter] =
- expectAttributeDelimiterState,
- [OFXMLParserStateInAttributeValue] = inAttributeValueState,
- [OFXMLParserStateExpectTagClose] = expectTagCloseState,
- [OFXMLParserStateExpectSpaceOrTagClose] = expectSpaceOrTagCloseState,
- [OFXMLParserStateInExclamationMark] = inExclamationMarkState,
- [OFXMLParserStateInCDATAOpening] = inCDATAOpeningState,
- [OFXMLParserStateInCDATA] = inCDATAState,
- [OFXMLParserStateInCommentOpening] = inCommentOpeningState,
- [OFXMLParserStateInComment1] = inCommentState1,
- [OFXMLParserStateInComment2] = inCommentState2,
- [OFXMLParserStateInDOCTYPE] = inDOCTYPEState
+ [stateInByteOrderMark] = inByteOrderMarkState,
+ [stateOutsideTag] = outsideTagState,
+ [stateTagOpened] = tagOpenedState,
+ [stateInProcessingInstruction] = inProcessingInstructionState,
+ [stateInTagName] = inTagNameState,
+ [stateInCloseTagName] = inCloseTagNameState,
+ [stateInTag] = inTagState,
+ [stateInAttributeName] = inAttributeNameState,
+ [stateExpectAttributeEqualSign] = expectAttributeEqualSignState,
+ [stateExpectAttributeDelimiter] = expectAttributeDelimiterState,
+ [stateInAttributeValue] = inAttributeValueState,
+ [stateExpectTagClose] = expectTagCloseState,
+ [stateExpectSpaceOrTagClose] = expectSpaceOrTagCloseState,
+ [stateInExclamationMark] = inExclamationMarkState,
+ [stateInCDATAOpening] = inCDATAOpeningState,
+ [stateInCDATA] = inCDATAState,
+ [stateInCommentOpening] = inCommentOpeningState,
+ [stateInComment1] = inCommentState1,
+ [stateInComment2] = inCommentState2,
+ [stateInDOCTYPE] = inDOCTYPEState
};
static OF_INLINE void
appendToBuffer(OFMutableData *buffer, const char *string,
OFStringEncoding encoding, size_t length)
@@ -256,12 +276,12 @@
_lineNumber++;
_lastCarriageReturn = (_data[_i] == '\r');
}
- /* In OFXMLParserStateInTag, there can be only spaces */
- if (length - _last > 0 && _state != OFXMLParserStateInTag)
+ /* In stateInTag, there can be only spaces */
+ if (length - _last > 0 && _state != stateInTag)
appendToBuffer(_buffer, _data + _last, _encoding,
length - _last);
}
- (void)parseString: (OFString *)string
@@ -288,20 +308,20 @@
static void
inByteOrderMarkState(OFXMLParser *self)
{
if (self->_data[self->_i] != "\xEF\xBB\xBF"[self->_level]) {
if (self->_level == 0) {
- self->_state = OFXMLParserStateOutsideTag;
+ self->_state = stateOutsideTag;
self->_i--;
return;
}
@throw [OFMalformedXMLException exceptionWithParser: self];
}
if (self->_level++ == 2)
- self->_state = OFXMLParserStateOutsideTag;
+ self->_state = stateOutsideTag;
self->_last = self->_i + 1;
}
/* Not in a tag */
@@ -337,11 +357,11 @@
}
[self->_buffer removeAllItems];
self->_last = self->_i + 1;
- self->_state = OFXMLParserStateTagOpened;
+ self->_state = stateTagOpened;
}
/* Tag was just opened */
static void
tagOpenedState(OFXMLParser *self)
@@ -351,29 +371,29 @@
@throw [OFMalformedXMLException exceptionWithParser: self];
switch (self->_data[self->_i]) {
case '?':
self->_last = self->_i + 1;
- self->_state = OFXMLParserStateInProcessingInstruction;
+ self->_state = stateInProcessingInstruction;
self->_level = 0;
break;
case '/':
self->_last = self->_i + 1;
- self->_state = OFXMLParserStateInCloseTagName;
+ self->_state = stateInCloseTagName;
self->_acceptProlog = false;
break;
case '!':
self->_last = self->_i + 1;
- self->_state = OFXMLParserStateInExclamationMark;
+ self->_state = stateInExclamationMark;
self->_acceptProlog = false;
break;
default:
if (self->_depthLimit > 0 &&
self->_previous.count >= self->_depthLimit)
@throw [OFOutOfRangeException exception];
- self->_state = OFXMLParserStateInTagName;
+ self->_state = stateInTagName;
self->_acceptProlog = false;
self->_i--;
break;
}
}
@@ -514,11 +534,11 @@
objc_autoreleasePoolPop(pool);
[self->_buffer removeAllItems];
self->_last = self->_i + 1;
- self->_state = OFXMLParserStateOutsideTag;
+ self->_state = stateOutsideTag;
} else
self->_level = 0;
}
/* Inside a tag, no name yet */
@@ -592,14 +612,13 @@
[self->_name release];
[self->_prefix release];
self->_name = self->_prefix = nil;
self->_state = (self->_data[self->_i] == '/'
- ? OFXMLParserStateExpectTagClose
- : OFXMLParserStateOutsideTag);
+ ? stateExpectTagClose : stateOutsideTag);
} else
- self->_state = OFXMLParserStateInTag;
+ self->_state = stateInTag;
if (self->_data[self->_i] != '/')
[self->_namespaces addObject: [OFMutableDictionary dictionary]];
objc_autoreleasePoolPop(pool);
@@ -673,12 +692,11 @@
[self->_prefix release];
self->_name = self->_prefix = nil;
self->_last = self->_i + 1;
self->_state = (self->_data[self->_i] == '>'
- ? OFXMLParserStateOutsideTag
- : OFXMLParserStateExpectSpaceOrTagClose);
+ ? stateOutsideTag : stateExpectSpaceOrTagClose);
if (self->_previous.count == 0)
self->_finishedParsing = true;
}
@@ -695,11 +713,11 @@
if (self->_data[self->_i] != ' ' &&
self->_data[self->_i] != '\t' &&
self->_data[self->_i] != '\n' &&
self->_data[self->_i] != '\r') {
self->_last = self->_i;
- self->_state = OFXMLParserStateInAttributeName;
+ self->_state = stateInAttributeName;
self->_i--;
}
return;
}
@@ -754,11 +772,11 @@
[self->_attributes removeAllObjects];
self->_name = self->_prefix = nil;
self->_last = self->_i + 1;
self->_state = (self->_data[self->_i] == '/'
- ? OFXMLParserStateExpectTagClose : OFXMLParserStateOutsideTag);
+ ? stateExpectTagClose : stateOutsideTag);
}
/* Looking for attribute name */
static void
inAttributeNameState(OFXMLParser *self)
@@ -802,21 +820,20 @@
[self->_buffer removeAllItems];
self->_last = self->_i + 1;
self->_state = (self->_data[self->_i] == '='
- ? OFXMLParserStateExpectAttributeDelimiter
- : OFXMLParserStateExpectAttributeEqualSign);
+ ? stateExpectAttributeDelimiter : stateExpectAttributeEqualSign);
}
/* Expecting equal sign of an attribute */
static void
expectAttributeEqualSignState(OFXMLParser *self)
{
if (self->_data[self->_i] == '=') {
self->_last = self->_i + 1;
- self->_state = OFXMLParserStateExpectAttributeDelimiter;
+ self->_state = stateExpectAttributeDelimiter;
return;
}
if (self->_data[self->_i] != ' ' && self->_data[self->_i] != '\t' &&
self->_data[self->_i] != '\n' && self->_data[self->_i] != '\r')
@@ -835,11 +852,11 @@
if (self->_data[self->_i] != '\'' && self->_data[self->_i] != '"')
@throw [OFMalformedXMLException exceptionWithParser: self];
self->_delimiter = self->_data[self->_i];
- self->_state = OFXMLParserStateInAttributeValue;
+ self->_state = stateInAttributeValue;
}
/* Looking for attribute value */
static void
inAttributeValueState(OFXMLParser *self)
@@ -879,20 +896,20 @@
[self->_attributeName release];
[self->_attributePrefix release];
self->_attributeName = self->_attributePrefix = nil;
self->_last = self->_i + 1;
- self->_state = OFXMLParserStateInTag;
+ self->_state = stateInTag;
}
/* Expecting closing '>' */
static void
expectTagCloseState(OFXMLParser *self)
{
if (self->_data[self->_i] == '>') {
self->_last = self->_i + 1;
- self->_state = OFXMLParserStateOutsideTag;
+ self->_state = stateOutsideTag;
} else
@throw [OFMalformedXMLException exceptionWithParser: self];
}
/* Expecting closing '>' or space */
@@ -899,11 +916,11 @@
static void
expectSpaceOrTagCloseState(OFXMLParser *self)
{
if (self->_data[self->_i] == '>') {
self->_last = self->_i + 1;
- self->_state = OFXMLParserStateOutsideTag;
+ self->_state = stateOutsideTag;
} else if (self->_data[self->_i] != ' ' &&
self->_data[self->_i] != '\t' && self->_data[self->_i] != '\n' &&
self->_data[self->_i] != '\r')
@throw [OFMalformedXMLException exceptionWithParser: self];
}
@@ -914,16 +931,16 @@
{
if (self->_finishedParsing && self->_data[self->_i] != '-')
@throw [OFMalformedXMLException exceptionWithParser: self];
if (self->_data[self->_i] == '-')
- self->_state = OFXMLParserStateInCommentOpening;
+ self->_state = stateInCommentOpening;
else if (self->_data[self->_i] == '[') {
- self->_state = OFXMLParserStateInCDATAOpening;
+ self->_state = stateInCDATAOpening;
self->_level = 0;
} else if (self->_data[self->_i] == 'D') {
- self->_state = OFXMLParserStateInDOCTYPE;
+ self->_state = stateInDOCTYPE;
self->_level = 0;
} else
@throw [OFMalformedXMLException exceptionWithParser: self];
self->_last = self->_i + 1;
@@ -935,11 +952,11 @@
{
if (self->_data[self->_i] != "CDATA["[self->_level])
@throw [OFMalformedXMLException exceptionWithParser: self];
if (++self->_level == 6) {
- self->_state = OFXMLParserStateInCDATA;
+ self->_state = stateInCDATA;
self->_level = 0;
}
self->_last = self->_i + 1;
}
@@ -964,11 +981,11 @@
objc_autoreleasePoolPop(pool);
[self->_buffer removeAllItems];
self->_last = self->_i + 1;
- self->_state = OFXMLParserStateOutsideTag;
+ self->_state = stateOutsideTag;
} else
self->_level = 0;
}
/* Comment */
@@ -977,11 +994,11 @@
{
if (self->_data[self->_i] != '-')
@throw [OFMalformedXMLException exceptionWithParser: self];
self->_last = self->_i + 1;
- self->_state = OFXMLParserStateInComment1;
+ self->_state = stateInComment1;
self->_level = 0;
}
static void
inCommentState1(OFXMLParser *self)
@@ -990,11 +1007,11 @@
self->_level++;
else
self->_level = 0;
if (self->_level == 2)
- self->_state = OFXMLParserStateInComment2;
+ self->_state = stateInComment2;
}
static void
inCommentState2(OFXMLParser *self)
{
@@ -1017,11 +1034,11 @@
objc_autoreleasePoolPop(pool);
[self->_buffer removeAllItems];
self->_last = self->_i + 1;
- self->_state = OFXMLParserStateOutsideTag;
+ self->_state = stateOutsideTag;
}
/* In */
static void
inDOCTYPEState(OFXMLParser *self)
@@ -1034,11 +1051,11 @@
@throw [OFMalformedXMLException exceptionWithParser: self];
self->_level++;
if (self->_level > 6 && self->_data[self->_i] == '>')
- self->_state = OFXMLParserStateOutsideTag;
+ self->_state = stateOutsideTag;
self->_last = self->_i + 1;
}
- (size_t)lineNumber
Index: src/OFZIPArchive.h
==================================================================
--- src/OFZIPArchive.h
+++ src/OFZIPArchive.h
@@ -32,15 +32,11 @@
OF_SUBCLASSING_RESTRICTED
@interface OFZIPArchive: OFObject
{
OFStream *_stream;
int64_t _offset;
- enum {
- OFZIPArchiveModeRead,
- OFZIPArchiveModeWrite,
- OFZIPArchiveModeAppend
- } _mode;
+ uint_least8_t _mode;
uint32_t _diskNumber, _centralDirectoryDisk;
uint64_t _centralDirectoryEntriesInDisk, _centralDirectoryEntries;
uint64_t _centralDirectorySize;
int64_t _centralDirectoryOffset;
OFString *_Nullable _archiveComment;
Index: src/OFZIPArchive.m
==================================================================
--- src/OFZIPArchive.m
+++ src/OFZIPArchive.m
@@ -46,10 +46,16 @@
/*
* FIXME: Current limitations:
* - Split archives are not supported.
* - Encrypted files cannot be read.
*/
+
+enum {
+ modeRead,
+ modeWrite,
+ modeAppend
+};
OF_DIRECT_MEMBERS
@interface OFZIPArchive ()
- (void)of_readZIPInfo;
- (void)of_readEntries;
@@ -173,32 +179,31 @@
{
self = [super init];
@try {
if ([mode isEqual: @"r"])
- _mode = OFZIPArchiveModeRead;
+ _mode = modeRead;
else if ([mode isEqual: @"w"])
- _mode = OFZIPArchiveModeWrite;
+ _mode = modeWrite;
else if ([mode isEqual: @"a"])
- _mode = OFZIPArchiveModeAppend;
+ _mode = modeAppend;
else
@throw [OFInvalidArgumentException exception];
_stream = [stream retain];
_entries = [[OFMutableArray alloc] init];
_pathToEntryMap = [[OFMutableDictionary alloc] init];
- if (_mode == OFZIPArchiveModeRead ||
- _mode == OFZIPArchiveModeAppend) {
+ if (_mode == modeRead || _mode == modeAppend) {
if (![stream isKindOfClass: [OFSeekableStream class]])
@throw [OFInvalidArgumentException exception];
[self of_readZIPInfo];
[self of_readEntries];
}
- if (_mode == OFZIPArchiveModeAppend) {
+ if (_mode == modeAppend) {
_offset = _centralDirectoryOffset;
seekOrThrowInvalidFormat((OFSeekableStream *)_stream,
(OFFileOffset)_offset, SEEK_SET);
}
} @catch (id e) {
@@ -398,12 +403,11 @@
[_lastReturnedStream close];
} @catch (OFNotOpenException *e) {
/* Might have already been closed by the user - that's fine. */
}
- if ((_mode == OFZIPArchiveModeWrite ||
- _mode == OFZIPArchiveModeAppend) &&
+ if ((_mode == modeWrite || _mode == modeAppend) &&
[_lastReturnedStream isKindOfClass:
[OFZIPArchiveFileWriteStream class]]) {
OFZIPArchiveFileWriteStream *stream =
(OFZIPArchiveFileWriteStream *)_lastReturnedStream;
@@ -428,11 +432,11 @@
void *pool = objc_autoreleasePoolPush();
OFZIPArchiveEntry *entry;
OFZIPArchiveLocalFileHeader *localFileHeader;
int64_t offset64;
- if (_mode != OFZIPArchiveModeRead)
+ if (_mode != modeRead)
@throw [OFInvalidArgumentException exception];
if ((entry = [_pathToEntryMap objectForKey: path]) == nil)
@throw [OFOpenItemFailedException exceptionWithPath: path
mode: @"r"
@@ -478,11 +482,11 @@
OFMutableZIPArchiveEntry *entry;
OFString *fileName;
OFData *extraField;
uint16_t fileNameLength, extraFieldLength;
- if (_mode != OFZIPArchiveModeWrite && _mode != OFZIPArchiveModeAppend)
+ if (_mode != modeWrite && _mode != modeAppend)
@throw [OFInvalidArgumentException exception];
pool = objc_autoreleasePoolPush();
entry = [[entry_ mutableCopy] autorelease];
@@ -611,11 +615,11 @@
if (_stream == nil)
@throw [OFNotOpenException exceptionWithObject: self];
[self of_closeLastReturnedStream];
- if (_mode == OFZIPArchiveModeWrite || _mode == OFZIPArchiveModeAppend)
+ if (_mode == modeWrite || _mode == modeAppend)
[self of_writeCentralDirectory];
[_stream release];
_stream = nil;
}
Index: src/OFZIPArchiveEntry.h
==================================================================
--- src/OFZIPArchiveEntry.h
+++ src/OFZIPArchiveEntry.h
@@ -17,11 +17,11 @@
OF_ASSUME_NONNULL_BEGIN
/** @file */
-typedef enum OFZIPArchiveEntryCompressionMethod {
+typedef enum {
OFZIPArchiveEntryCompressionMethodNone = 0,
OFZIPArchiveEntryCompressionMethodShrink = 1,
OFZIPArchiveEntryCompressionMethodReduceFactor1 = 2,
OFZIPArchiveEntryCompressionMethodReduceFactor2 = 3,
OFZIPArchiveEntryCompressionMethodReduceFactor3 = 4,
@@ -36,11 +36,11 @@
} OFZIPArchiveEntryCompressionMethod;
/**
* @brief Attribute compatibility part of ZIP versions.
*/
-typedef enum OFZIPArchiveEntryAttributeCompatibility {
+typedef enum {
/** MS-DOS and OS/2 */
OFZIPArchiveEntryAttributeCompatibilityMSDOS = 0,
/** Amiga */
OFZIPArchiveEntryAttributeCompatibilityAmiga = 1,
/** OpenVMS */
@@ -82,11 +82,11 @@
} OFZIPArchiveEntryAttributeCompatibility;
/**
* @brief Tags for the extra field.
*/
-typedef enum OFZIPArchiveEntryExtraFieldTag {
+typedef enum {
/** ZIP64 extra field tag */
OFZIPArchiveEntryExtraFieldTagZIP64 = 0x0001
} OFZIPArchiveEntryExtraFieldTag;
@class OFString;
Index: src/exceptions/OFException.m
==================================================================
--- src/exceptions/OFException.m
+++ src/exceptions/OFException.m
@@ -47,11 +47,11 @@
struct _Unwind_Context;
typedef enum {
_URC_OK = 0,
_URC_END_OF_STACK = 5
-}_Unwind_Reason_Code;
+} _Unwind_Reason_Code;
struct BacktraceCtx {
void **backtrace;
uint8_t i;
};
Index: src/macros.h
==================================================================
--- src/macros.h
+++ src/macros.h
@@ -637,51 +637,10 @@
: (value))
#define OFRoundUpToPowerOf2(pow2, value) \
(((value) + (pow2) - 1) & ~((pow2) - 1))
-extern unsigned long OFHashSeed;
-
-static OF_INLINE void
-OFHashInit(unsigned long *_Nonnull hash)
-{
- *hash = OFHashSeed;
-}
-
-static OF_INLINE void
-OFHashAdd(unsigned long *_Nonnull hash, unsigned char byte)
-{
- uint32_t tmp = (uint32_t)*hash;
-
- tmp += byte;
- tmp += tmp << 10;
- tmp ^= tmp >> 6;
-
- *hash = tmp;
-}
-
-static OF_INLINE void
-OFHashAddHash(unsigned long *_Nonnull hash, unsigned long otherHash)
-{
- OFHashAdd(hash, (otherHash >> 24) & 0xFF);
- OFHashAdd(hash, (otherHash >> 16) & 0xFF);
- OFHashAdd(hash, (otherHash >> 8) & 0xFF);
- OFHashAdd(hash, otherHash & 0xFF);
-}
-
-static OF_INLINE void
-OFHashFinalize(unsigned long *_Nonnull hash)
-{
- uint32_t tmp = (uint32_t)*hash;
-
- tmp += tmp << 3;
- tmp ^= tmp >> 11;
- tmp += tmp << 15;
-
- *hash = tmp;
-}
-
static OF_INLINE bool
OFBitsetIsSet(unsigned char *_Nonnull storage, size_t idx)
{
return storage[idx / CHAR_BIT] & (1u << (idx % CHAR_BIT));
}
Index: src/runtime/misc.m
==================================================================
--- src/runtime/misc.m
+++ src/runtime/misc.m
@@ -130,11 +130,11 @@
#endif
OF_UNREACHABLE
}
-static char *
+char *
objc_strdup(const char *string)
{
char *copy;
size_t length = strlen(string);
Index: tests/TestsAppDelegate.m
==================================================================
--- tests/TestsAppDelegate.m
+++ tests/TestsAppDelegate.m
@@ -48,10 +48,12 @@
/* Newer versions of libctru started using id as a parameter name. */
# define id id_3ds
# include <3ds.h>
# undef id
#endif
+
+extern unsigned long OFHashSeed;
#ifdef OF_PSP
static int
exit_cb(int arg1, int arg2, void *arg)
{
Index: utils/ofhttp/ProgressBar.m
==================================================================
--- utils/ofhttp/ProgressBar.m
+++ utils/ofhttp/ProgressBar.m
@@ -23,12 +23,12 @@
#import "OFLocale.h"
#import "ProgressBar.h"
static const float oneKibibyte = 1024;
-static const float oneMebibyte = 1024 * oneKibibyte;
-static const float oneGibibyte = 1024 * oneMebibyte;
+static const float oneMebibyte = 1024 * 1024;
+static const float oneGibibyte = 1024 * 1024 * 1024;
static const OFTimeInterval updateInterval = 0.1;
#ifndef HAVE_TRUNCF
# define truncf(x) trunc(x)