From 0263046930b420e07c312c6fbe0156a4a1ebcdf0 Mon Sep 17 00:00:00 2001 From: Max Date: Sun, 4 Oct 2015 06:13:38 +0200 Subject: Remove a duplicate @interface and prepare some functions for unit testing --- .../SPMySQLFramework/Source/SPMySQL Private APIs.h | 7 +------ .../SPMySQLResult Categories/Data Conversion.h | 7 +------ .../SPMySQLResult Categories/Data Conversion.m | 21 ++++++++++++++++----- .../SPMySQLResult Categories/Field Definitions.m | 9 +-------- 4 files changed, 19 insertions(+), 25 deletions(-) (limited to 'Frameworks/SPMySQLFramework/Source') diff --git a/Frameworks/SPMySQLFramework/Source/SPMySQL Private APIs.h b/Frameworks/SPMySQLFramework/Source/SPMySQL Private APIs.h index 2419d7a9..ec85f92b 100644 --- a/Frameworks/SPMySQLFramework/Source/SPMySQL Private APIs.h +++ b/Frameworks/SPMySQLFramework/Source/SPMySQL Private APIs.h @@ -99,12 +99,7 @@ @end // SPMySQLResult Data Conversion Private API -@interface SPMySQLResult (Data_Conversion_Private_API) - -+ (void)_initializeDataConversion; -- (id)_getObjectFromBytes:(char *)bytes ofLength:(NSUInteger)length fieldDefinitionIndex:(NSUInteger)fieldIndex previewLength:(NSUInteger)previewLength; - -@end +#import "Data Conversion.h" /** * Set up a static function to allow fast calling of SPMySQLResult data conversion with cached selectors diff --git a/Frameworks/SPMySQLFramework/Source/SPMySQLResult Categories/Data Conversion.h b/Frameworks/SPMySQLFramework/Source/SPMySQLResult Categories/Data Conversion.h index 817d2cb7..7d865226 100644 --- a/Frameworks/SPMySQLFramework/Source/SPMySQLResult Categories/Data Conversion.h +++ b/Frameworks/SPMySQLFramework/Source/SPMySQLResult Categories/Data Conversion.h @@ -30,12 +30,7 @@ @interface SPMySQLResult (Data_Conversion_Private_API) ++ (void)_initializeDataConversion; - (id)_getObjectFromBytes:(char *)bytes ofLength:(NSUInteger)length fieldDefinitionIndex:(NSUInteger)fieldIndex previewLength:(NSUInteger)previewLength; -static inline SPMySQLResultFieldProcessor _processorForField(MYSQL_FIELD aField); - -static inline NSString * _stringWithBytes(const void *dataBytes, NSUInteger dataLength, NSStringEncoding aStringEncoding, NSUInteger previewLength); -static inline NSString * _bitStringWithBytes(const char *bytes, NSUInteger length, NSUInteger padLength); -static inline NSString * _convertStringData(const void *dataBytes, NSUInteger dataLength, NSStringEncoding aStringEncoding, NSUInteger previewLength); - @end diff --git a/Frameworks/SPMySQLFramework/Source/SPMySQLResult Categories/Data Conversion.m b/Frameworks/SPMySQLFramework/Source/SPMySQLResult Categories/Data Conversion.m index 8c5b9181..b2336aaa 100644 --- a/Frameworks/SPMySQLFramework/Source/SPMySQLResult Categories/Data Conversion.m +++ b/Frameworks/SPMySQLFramework/Source/SPMySQLResult Categories/Data Conversion.m @@ -31,6 +31,16 @@ #import "Data Conversion.h" +#ifdef SPMYSQL_FOR_UNIT_TESTING +#define PRIVATE /* public */ +#else +#define PRIVATE static inline +#endif + +PRIVATE SPMySQLResultFieldProcessor _processorForField(MYSQL_FIELD aField); +PRIVATE NSString * _bitStringWithBytes(const char *bytes, NSUInteger length, NSUInteger padLength); +PRIVATE NSString * _convertStringData(const void *dataBytes, NSUInteger dataLength, NSStringEncoding aStringEncoding, NSUInteger previewLength); + static SPMySQLResultFieldProcessor fieldProcessingMap[256]; static id NSNullPointer; static NSStringEncoding NSFromCFStringEncodingBig5; @@ -161,10 +171,12 @@ static NSStringEncoding NSFromCFStringEncodingGBK_95; return nil; } +@end + /** * Returns the field processor to use for a specified field. */ -static inline SPMySQLResultFieldProcessor _processorForField(MYSQL_FIELD aField) +PRIVATE SPMySQLResultFieldProcessor _processorForField(MYSQL_FIELD aField) { // Determine the default field processor to use SPMySQLResultFieldProcessor dataProcessor = fieldProcessingMap[aField.type]; @@ -200,7 +212,7 @@ static inline SPMySQLResultFieldProcessor _processorForField(MYSQL_FIELD aField) * field length. * MySQL stores bit data as string data stored in an 8-bit wide character set. */ -static inline NSString * _bitStringWithBytes(const char *bytes, NSUInteger length, NSUInteger padLength) +PRIVATE NSString * _bitStringWithBytes(const char *bytes, NSUInteger length, NSUInteger padLength) { NSUInteger i = 0; NSUInteger bitLength = length << 3; @@ -242,7 +254,7 @@ static inline NSString * _bitStringWithBytes(const char *bytes, NSUInteger lengt * Converts stored string data - which may contain nul bytes - to a native * Objective-C string, using the current class encoding. */ -static inline NSString * _convertStringData(const void *dataBytes, NSUInteger dataLength, NSStringEncoding aStringEncoding, NSUInteger previewLength) +PRIVATE NSString * _convertStringData(const void *dataBytes, NSUInteger dataLength, NSStringEncoding aStringEncoding, NSUInteger previewLength) { // Fast case - if not using a preview length, or if the data length is shorter, return the requested data. @@ -413,5 +425,4 @@ static inline NSString * _convertStringData(const void *dataBytes, NSUInteger da return previewString; } - -@end +#undef PRIVATE diff --git a/Frameworks/SPMySQLFramework/Source/SPMySQLResult Categories/Field Definitions.m b/Frameworks/SPMySQLFramework/Source/SPMySQLResult Categories/Field Definitions.m index c61b9140..09bd9580 100644 --- a/Frameworks/SPMySQLFramework/Source/SPMySQLResult Categories/Field Definitions.m +++ b/Frameworks/SPMySQLFramework/Source/SPMySQLResult Categories/Field Definitions.m @@ -29,6 +29,7 @@ // More info at #import "Field Definitions.h" +#import "SPMySQL Private APIs.h" @interface SPMySQLResult (Field_Definitions_Private_API) @@ -40,14 +41,6 @@ @end -// Import a private declaration from the SPMySQLResult file for use -@interface SPMySQLResult (Private_API) - -- (NSString *)_stringWithBytes:(const void *)bytes length:(NSUInteger)length; -- (NSString *)_lossyStringWithBytes:(const void *)bytes length:(NSUInteger)length wasLossy:(BOOL *)outLossy; - -@end - #define MAGIC_BINARY_CHARSET_NR 63 const SPMySQLResultCharset SPMySQLCharsetMap[] = -- cgit v1.2.3