Explorar o código

Removed ivars from public interfaces

- Moved into private class extensions.
- Removed ivars that will be synthesized for us
- Removed unnecessary synthesize statements
Robert M. Ryan %!s(int64=8) %!d(string=hai) anos
pai
achega
3c4cf5ad84

+ 1 - 1
src/extra/fts3/FMDatabase+FTS3.m

@@ -292,7 +292,7 @@ @implementation FMResultSet (FTS3)
 - (FMTextOffsets *)offsetsForColumnIndex:(int)columnIdx
 {
     // The offsets() value is a space separated groups of 4 integers
-    const char *rawOffsets = (const char *)sqlite3_column_text([_statement statement], columnIdx);
+    const char *rawOffsets = (const char *)sqlite3_column_text([self.statement statement], columnIdx);
     
     return [[FMTextOffsets alloc] initWithDBOffsets:rawOffsets];
 }

+ 1 - 20
src/fmdb/FMDatabase.h

@@ -71,26 +71,7 @@ typedef int(^FMDBExecuteStatementsCallbackBlock)(NSDictionary *resultsDictionary
 #pragma clang diagnostic ignored "-Wobjc-interface-ivars"
 
 
-@interface FMDatabase : NSObject  {
-    
-    void*               _db;
-    NSString*           _databasePath;
-    BOOL                _logsErrors;
-    BOOL                _crashOnErrors;
-    BOOL                _traceExecution;
-    BOOL                _checkedOut;
-    BOOL                _shouldCacheStatements;
-    BOOL                _isExecutingStatement;
-    BOOL                _inTransaction;
-    NSTimeInterval      _maxBusyRetryTimeInterval;
-    NSTimeInterval      _startBusyRetryTime;
-    
-    NSMutableDictionary *_cachedStatements;
-    NSMutableSet        *_openResultSets;
-    NSMutableSet        *_openFunctions;
-
-    NSDateFormatter     *_dateFormat;
-}
+@interface FMDatabase : NSObject
 
 ///-----------------
 /// @name Properties

+ 19 - 2
src/fmdb/FMDatabase.m

@@ -8,11 +8,28 @@
 #import <sqlite3.h>
 #endif
 
-@interface FMDatabase ()
+@interface FMDatabase () {
+    void*               _db;
+    NSString*           _databasePath;
+    BOOL                _shouldCacheStatements;
+    BOOL                _isExecutingStatement;
+    BOOL                _inTransaction;
+    NSTimeInterval      _maxBusyRetryTimeInterval;
+    NSTimeInterval      _startBusyRetryTime;
+    
+    NSMutableSet        *_openResultSets;
+    NSMutableSet        *_openFunctions;
+    
+    NSDateFormatter     *_dateFormat;
+}
+
+NS_ASSUME_NONNULL_BEGIN
 
 - (FMResultSet * _Nullable)executeQuery:(NSString *)sql withArgumentsInArray:(NSArray * _Nullable)arrayArgs orDictionary:(NSDictionary * _Nullable)dictionaryArgs orVAList:(va_list)args;
 - (BOOL)executeUpdate:(NSString *)sql error:(NSError * _Nullable *)outErr withArgumentsInArray:(NSArray * _Nullable)arrayArgs orDictionary:(NSDictionary * _Nullable)dictionaryArgs orVAList:(va_list)args;
 
+NS_ASSUME_NONNULL_END
+
 @end
 
 @implementation FMDatabase
@@ -1461,7 +1478,7 @@ - (void)makeFunctionNamed:(NSString *)name arguments:(int)arguments block:(void
     
     /* I tried adding custom functions to release the block when the connection is destroyed- but they seemed to never be called, so we use _openFunctions to store the values instead. */
 #if ! __has_feature(objc_arc)
-    sqlite3_create_function([self sqliteHandle], [name UTF8String], count, SQLITE_UTF8, (void*)b, &FMDBBlockSQLiteCallBackFunction, 0x00, 0x00);
+    sqlite3_create_function([self sqliteHandle], [name UTF8String], arguments, SQLITE_UTF8, (void*)b, &FMDBBlockSQLiteCallBackFunction, 0x00, 0x00);
 #else
     sqlite3_create_function([self sqliteHandle], [name UTF8String], arguments, SQLITE_UTF8, (__bridge void*)b, &FMDBBlockSQLiteCallBackFunction, 0x00, 0x00);
 #endif

+ 1 - 1
src/fmdb/FMDatabaseAdditions.m

@@ -226,7 +226,7 @@ - (BOOL)validateSQL:(NSString*)sql error:(NSError**)error {
     sqlite3_stmt *pStmt = NULL;
     BOOL validationSucceeded = YES;
     
-    int rc = sqlite3_prepare_v2(_db, [sql UTF8String], -1, &pStmt, 0);
+    int rc = sqlite3_prepare_v2([self sqliteHandle], [sql UTF8String], -1, &pStmt, 0);
     if (rc != SQLITE_OK) {
         validationSucceeded = NO;
         if (error) {

+ 4 - 17
src/fmdb/FMDatabasePool.h

@@ -30,28 +30,15 @@ NS_ASSUME_NONNULL_BEGIN
  in the main.m file.
  */
 
-@interface FMDatabasePool : NSObject {
-    NSString            *_path;
-    
-    dispatch_queue_t    _lockQueue;
-    
-    NSMutableArray      *_databaseInPool;
-    NSMutableArray      *_databaseOutPool;
-    
-    __unsafe_unretained id _delegate;
-    
-    NSUInteger          _maximumNumberOfDatabasesToCreate;
-    int                 _openFlags;
-    NSString            *_vfsName;
-}
+@interface FMDatabasePool : NSObject
 
 /** Database path */
 
-@property (atomic, retain) NSString *path;
+@property (atomic, copy, nullable) NSString *path;
 
 /** Delegate object */
 
-@property (atomic, assign) id delegate;
+@property (atomic, assign, nullable) id delegate;
 
 /** Maximum number of databases to create */
 
@@ -63,7 +50,7 @@ NS_ASSUME_NONNULL_BEGIN
 
 /**  Custom virtual file system name */
 
-@property (atomic, copy) NSString *vfsName;
+@property (atomic, copy, nullable) NSString *vfsName;
 
 
 ///---------------------

+ 6 - 1
src/fmdb/FMDatabasePool.m

@@ -15,7 +15,12 @@
 #import "FMDatabasePool.h"
 #import "FMDatabase.h"
 
-@interface FMDatabasePool()
+@interface FMDatabasePool () {
+    dispatch_queue_t    _lockQueue;
+    
+    NSMutableArray      *_databaseInPool;
+    NSMutableArray      *_databaseOutPool;
+}
 
 - (void)pushDatabaseBackInPool:(FMDatabase*)db;
 - (FMDatabase*)db;

+ 3 - 10
src/fmdb/FMDatabaseQueue.h

@@ -62,17 +62,10 @@ NS_ASSUME_NONNULL_BEGIN
 
  */
 
-@interface FMDatabaseQueue : NSObject {
-    NSString            *_path;
-    dispatch_queue_t    _queue;
-    FMDatabase          *_db;
-    int                 _openFlags;
-    NSString            *_vfsName;
-}
-
+@interface FMDatabaseQueue : NSObject
 /** Path of database */
 
-@property (atomic, retain) NSString *path;
+@property (atomic, retain, nullable) NSString *path;
 
 /** Open flags */
 
@@ -80,7 +73,7 @@ NS_ASSUME_NONNULL_BEGIN
 
 /**  Custom virtual file system name */
 
-@property (atomic, copy) NSString *vfsName;
+@property (atomic, copy, nullable) NSString *vfsName;
 
 ///----------------------------------------------------
 /// @name Initialization, opening, and closing of queue

+ 7 - 5
src/fmdb/FMDatabaseQueue.m

@@ -29,12 +29,14 @@
  * the queue's dispatch queue, which should not happen and causes a deadlock.
  */
 static const void * const kDispatchQueueSpecificKey = &kDispatchQueueSpecificKey;
- 
-@implementation FMDatabaseQueue
 
-@synthesize path = _path;
-@synthesize openFlags = _openFlags;
-@synthesize vfsName = _vfsName;
+@interface FMDatabaseQueue () {
+    dispatch_queue_t    _queue;
+    FMDatabase          *_db;
+}
+@end
+
+@implementation FMDatabaseQueue
 
 + (instancetype)databaseQueueWithPath:(NSString *)aPath {
     FMDatabaseQueue *q = [[self alloc] initWithPath:aPath];

+ 3 - 8
src/fmdb/FMResultSet.h

@@ -24,12 +24,7 @@ NS_ASSUME_NONNULL_BEGIN
  - `<FMDatabase>`
  */
 
-@interface FMResultSet : NSObject {
-    FMStatement         *_statement;
-    
-    NSString            *_query;
-    NSMutableDictionary *_columnNameToIndexMap;
-}
+@interface FMResultSet : NSObject
 
 @property (nonatomic, retain, nullable) FMDatabase *parentDB;
 
@@ -39,7 +34,7 @@ NS_ASSUME_NONNULL_BEGIN
 
 /** Executed query */
 
-@property (atomic, retain) NSString *query;
+@property (atomic, retain, nullable) NSString *query;
 
 /** `NSMutableDictionary` mapping column names to numeric index */
 
@@ -47,7 +42,7 @@ NS_ASSUME_NONNULL_BEGIN
 
 /** `FMStatement` used by result set. */
 
-@property (atomic, retain) FMStatement *statement;
+@property (atomic, retain, nullable) FMStatement *statement;
 
 ///------------------------------------
 /// @name Creating and closing database

+ 4 - 2
src/fmdb/FMResultSet.m

@@ -12,10 +12,12 @@ @interface FMDatabase ()
 - (void)resultSetDidClose:(FMResultSet *)resultSet;
 @end
 
+@interface FMResultSet () {
+    NSMutableDictionary *_columnNameToIndexMap;
+}
+@end
 
 @implementation FMResultSet
-@synthesize query=_query;
-@synthesize statement=_statement;
 
 + (instancetype)resultSetWithStatement:(FMStatement *)statement usingParentDatabase:(FMDatabase*)aDB {