Skip to content

Commit

Permalink
Merge branch 'revision-0.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
firelizzard18 committed Jan 22, 2014
2 parents 07608ae + 92770e6 commit 8d59626
Show file tree
Hide file tree
Showing 15 changed files with 71 additions and 97 deletions.
25 changes: 13 additions & 12 deletions CocoaSQLite.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
objects = {

/* Begin PBXBuildFile section */
42352D4E1877D05D0011CA48 /* ORDA.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 42352D4C1877D05D0011CA48 /* ORDA.framework */; };
42352D4F1877D05D0011CA48 /* TypeExtensions.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 42352D4D1877D05D0011CA48 /* TypeExtensions.framework */; };
4290EFC618498E2700C67769 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4290EFC518498E2700C67769 /* Cocoa.framework */; };
4290EFD018498E2700C67769 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 4290EFCE18498E2700C67769 /* InfoPlist.strings */; };
4290EFDB18498E2700C67769 /* XCTest.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4290EFDA18498E2700C67769 /* XCTest.framework */; };
Expand All @@ -35,6 +33,8 @@
4290F01318498E4700C67769 /* ORDASQLiteTableResultEntry.m in Sources */ = {isa = PBXBuildFile; fileRef = 4290F00018498E4700C67769 /* ORDASQLiteTableResultEntry.m */; };
4290F01418498E4700C67769 /* ORDASQLiteTableView.h in Headers */ = {isa = PBXBuildFile; fileRef = 4290F00118498E4700C67769 /* ORDASQLiteTableView.h */; };
4290F01518498E4700C67769 /* ORDASQLiteTableView.m in Sources */ = {isa = PBXBuildFile; fileRef = 4290F00218498E4700C67769 /* ORDASQLiteTableView.m */; };
429CE075188F8B4C00FF0113 /* ORDA.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 429CE073188F8B4C00FF0113 /* ORDA.framework */; };
429CE076188F8B4C00FF0113 /* TypeExtensions.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 429CE074188F8B4C00FF0113 /* TypeExtensions.framework */; };
42D1903F1849A464002EC23A /* .travis.yml in Resources */ = {isa = PBXBuildFile; fileRef = 42D1903E1849A464002EC23A /* .travis.yml */; };
42D190421849A471002EC23A /* LICENSE in Resources */ = {isa = PBXBuildFile; fileRef = 42D190401849A471002EC23A /* LICENSE */; };
42D190431849A471002EC23A /* README.md in Resources */ = {isa = PBXBuildFile; fileRef = 42D190411849A471002EC23A /* README.md */; };
Expand All @@ -51,8 +51,6 @@
/* End PBXContainerItemProxy section */

/* Begin PBXFileReference section */
42352D4C1877D05D0011CA48 /* ORDA.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ORDA.framework; path = Resources/ORDA.framework; sourceTree = "<group>"; };
42352D4D1877D05D0011CA48 /* TypeExtensions.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = TypeExtensions.framework; path = Resources/TypeExtensions.framework; sourceTree = "<group>"; };
4290EFC218498E2700C67769 /* CocoaSQLite.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = CocoaSQLite.framework; sourceTree = BUILT_PRODUCTS_DIR; };
4290EFC518498E2700C67769 /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = System/Library/Frameworks/Cocoa.framework; sourceTree = SDKROOT; };
4290EFC818498E2700C67769 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
Expand Down Expand Up @@ -85,6 +83,8 @@
4290F00018498E4700C67769 /* ORDASQLiteTableResultEntry.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ORDASQLiteTableResultEntry.m; sourceTree = "<group>"; };
4290F00118498E4700C67769 /* ORDASQLiteTableView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ORDASQLiteTableView.h; sourceTree = "<group>"; };
4290F00218498E4700C67769 /* ORDASQLiteTableView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ORDASQLiteTableView.m; sourceTree = "<group>"; };
429CE073188F8B4C00FF0113 /* ORDA.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = ORDA.framework; sourceTree = "<group>"; };
429CE074188F8B4C00FF0113 /* TypeExtensions.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = TypeExtensions.framework; sourceTree = "<group>"; };
42D1903E1849A464002EC23A /* .travis.yml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = .travis.yml; sourceTree = "<group>"; };
42D190401849A471002EC23A /* LICENSE */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = LICENSE; sourceTree = "<group>"; };
42D190411849A471002EC23A /* README.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = README.md; sourceTree = "<group>"; };
Expand All @@ -95,9 +95,9 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
429CE075188F8B4C00FF0113 /* ORDA.framework in Frameworks */,
4290EFC618498E2700C67769 /* Cocoa.framework in Frameworks */,
42352D4F1877D05D0011CA48 /* TypeExtensions.framework in Frameworks */,
42352D4E1877D05D0011CA48 /* ORDA.framework in Frameworks */,
429CE076188F8B4C00FF0113 /* TypeExtensions.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -147,13 +147,14 @@
4290EFC418498E2700C67769 /* Frameworks */ = {
isa = PBXGroup;
children = (
42352D4C1877D05D0011CA48 /* ORDA.framework */,
42352D4D1877D05D0011CA48 /* TypeExtensions.framework */,
429CE073188F8B4C00FF0113 /* ORDA.framework */,
429CE074188F8B4C00FF0113 /* TypeExtensions.framework */,
4290EFC518498E2700C67769 /* Cocoa.framework */,
4290EFDA18498E2700C67769 /* XCTest.framework */,
4290EFC718498E2700C67769 /* Other Frameworks */,
);
name = Frameworks;
path = Resources;
sourceTree = "<group>";
};
4290EFC718498E2700C67769 /* Other Frameworks */ = {
Expand Down Expand Up @@ -414,7 +415,7 @@
ALWAYS_SEARCH_USER_PATHS = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_OBJC_ARC = NO;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
Expand Down Expand Up @@ -451,7 +452,7 @@
ALWAYS_SEARCH_USER_PATHS = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_OBJC_ARC = NO;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
Expand Down Expand Up @@ -484,7 +485,7 @@
DYLIB_CURRENT_VERSION = 1;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
/Users/firelizzard/Documents/Programming/CORM/Include/CocoaSQLite/Resources,
/Users/firelizzard/Documents/Programming/CocoaSQLite/Resources,
);
FRAMEWORK_VERSION = A;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
Expand All @@ -503,7 +504,7 @@
DYLIB_CURRENT_VERSION = 1;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
/Users/firelizzard/Documents/Programming/CORM/Include/CocoaSQLite/Resources,
/Users/firelizzard/Documents/Programming/CocoaSQLite/Resources,
);
FRAMEWORK_VERSION = A;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
Expand Down
4 changes: 2 additions & 2 deletions CocoaSQLite/CocoaSQLite-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.0-r0.1</string>
<string>1.0-r0.2</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>100</string>
<string>114</string>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2013 Firelizzard Inventions. All rights reserved.</string>
<key>NSPrincipalClass</key>
Expand Down
2 changes: 1 addition & 1 deletion CocoaSQLite/ORDASQLiteDriver.m
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ - (NSString *)scheme

- (id<ORDAGovernor>)governorForURL:(NSURL *)url
{
return [[[ORDASQLiteGovernor alloc] initWithURL:url] autorelease];
return [[ORDASQLiteGovernor alloc] initWithURL:url];
}

@end
2 changes: 1 addition & 1 deletion CocoaSQLite/ORDASQLiteErrorResult.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ + (ORDADriverResult *)errorWithCode:(ORDASQLiteResultCodeError)code

+ (ORDASQLiteErrorResult *)errorWithCode:(ORDASQLiteResultCodeError)code andSQLiteErrorCode:(int)status
{
return [[[self alloc] initWithCode:code andSQLiteErrorCode:status] autorelease];
return [[self alloc] initWithCode:code andSQLiteErrorCode:status];
}

+ (ORDASQLiteErrorResult *)errorWithSQLiteErrorCode:(int)status
Expand Down
18 changes: 8 additions & 10 deletions CocoaSQLite/ORDASQLiteGovernor.m
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ void update_hook(void * data, int type, char const * dbname, char const * tbname
break;
}

ORDASQLiteGovernor * gov = data;
ORDASQLiteGovernor * gov = (__bridge ORDASQLiteGovernor *)(data);

[gov.tables[@(tbname)] tableUpdateDidOccur:ordaType toRowWithKey:@(rowid)];
}
Expand All @@ -55,22 +55,22 @@ - (id)initWithURL:(NSURL *)URL
return self;

if (!URL)
return (ORDASQLiteGovernor *)[ORDASQLiteErrorResult errorWithCode:kORDANilURLErrorResultCode].retain;
return (ORDASQLiteGovernor *)[ORDASQLiteErrorResult errorWithCode:(ORDASQLiteResultCodeError)kORDANilURLErrorResultCode];

NSString * path = URL.relativePath;
if (!path)
return (ORDASQLiteGovernor *)[ORDASQLiteErrorResult errorWithCode:kORDABadURLErrorResultCode].retain;
return (ORDASQLiteGovernor *)[ORDASQLiteErrorResult errorWithCode:(ORDASQLiteResultCodeError)kORDABadURLErrorResultCode];

if (![[NSFileManager defaultManager] fileExistsAtPath:path])
return (ORDASQLiteGovernor *)[ORDASQLiteErrorResult errorWithCode:kORDASQLiteFileDoesNotExistErrorResultCode].retain;
return (ORDASQLiteGovernor *)[ORDASQLiteErrorResult errorWithCode:kORDASQLiteFileDoesNotExistErrorResultCode];

int status = sqlite3_open([path cStringUsingEncoding:NSUTF8StringEncoding], &_connection);
if (status != SQLITE_OK)
return (ORDASQLiteGovernor *)[ORDASQLiteErrorResult errorWithCode:(ORDACode)kORDAConnectionErrorResultCode andSQLiteErrorCode:status].retain;
return (ORDASQLiteGovernor *)[ORDASQLiteErrorResult errorWithCode:(ORDACode)kORDAConnectionErrorResultCode andSQLiteErrorCode:status];

sqlite3_update_hook(self.connection, &update_hook, self);
sqlite3_update_hook(self.connection, &update_hook, (__bridge void *)self);

_tables = [[NSMutableDictionary dictionary] retain];
_tables = [NSMutableDictionary dictionary];

return self;
}
Expand All @@ -79,15 +79,13 @@ - (void)dealloc
{
if (_connection)
sqlite3_close(_connection);

[super dealloc];
}

- (id<ORDAStatement>)createStatement:(NSString *)format, ... NS_FORMAT_FUNCTION(1,2)
{
va_list args;
va_start(args, format);
NSString * statementSQL = [[[NSString alloc] initWithFormat:format arguments:args] autorelease];
NSString * statementSQL = [[NSString alloc] initWithFormat:format arguments:args];
va_end(args);

return [ORDASQLiteStatement statementWithGovernor:self withSQL:statementSQL];
Expand Down
41 changes: 20 additions & 21 deletions CocoaSQLite/ORDASQLiteStatement.m
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ - (id)initWithGovernor:(id<ORDAGovernor>)governor withSQL:(NSString *)SQL
return self;

if (![governor isKindOfClass:[ORDASQLiteGovernor class]])
return (ORDASQLiteStatement *)[ORDASQLiteErrorResult errorWithCode:kORDAInternalAPIMismatchErrorResultCode].retain;
return (ORDASQLiteStatement *)[ORDASQLiteErrorResult errorWithCode:(ORDASQLiteResultCodeError)kORDAInternalAPIMismatchErrorResultCode];

_result = nil;

char * rest;
int status = sqlite3_prepare_v2(((ORDASQLiteGovernor *)self.governor).connection, [SQL cStringUsingEncoding:NSASCIIStringEncoding], (int)SQL.length, &_statement, (const char **) &rest);
if (status != SQLITE_OK)
return (ORDASQLiteStatement *)[ORDASQLiteErrorResult errorWithCode:(ORDACode)kORDABadStatementSQLErrorResultCode andSQLiteErrorCode:status].retain;
return (ORDASQLiteStatement *)[ORDASQLiteErrorResult errorWithCode:(ORDACode)kORDABadStatementSQLErrorResultCode andSQLiteErrorCode:status];

if (!rest[0]) {
_nextStatement = nil;
Expand All @@ -43,7 +43,7 @@ - (id)initWithGovernor:(id<ORDAGovernor>)governor withSQL:(NSString *)SQL

_nextStatement = [[ORDASQLiteStatement alloc] initWithGovernor:governor withSQL:@(rest)];
if (!_nextStatement)
return (ORDASQLiteStatement *)[ORDASQLiteErrorResult errorWithCode:(ORDACode)kORDAInternalErrorResultCode].retain;
return (ORDASQLiteStatement *)[ORDASQLiteErrorResult errorWithCode:(ORDACode)kORDAInternalErrorResultCode];
if (_nextStatement.isError)
return _nextStatement;

Expand All @@ -53,28 +53,30 @@ - (id)initWithGovernor:(id<ORDAGovernor>)governor withSQL:(NSString *)SQL

- (void)dealloc
{
if (_statement) sqlite3_finalize(_statement);
[_result release];
[_nextStatement release];

[super dealloc];
if (_statement)
sqlite3_finalize(_statement);
}

- (id<ORDAStatementResult>)result
{
if (!_result) {
int status = sqlite3_step(self.statement);
int status, rows, columns, changed;
long long lastID;
NSMutableArray * colarr, * dictArray;
NSMutableDictionary * arrayDict;

status = sqlite3_step(self.statement);
if (!(status == SQLITE_DONE || status == SQLITE_ROW))
goto done;

int rows = -1;
int columns = sqlite3_column_count(self.statement);
int changed = sqlite3_changes(((ORDASQLiteGovernor *)self.governor).connection);
long long lastID = sqlite3_last_insert_rowid(((ORDASQLiteGovernor *)self.governor).connection);
rows = -1;
columns = sqlite3_column_count(self.statement);
changed = sqlite3_changes(((ORDASQLiteGovernor *)self.governor).connection);
lastID = sqlite3_last_insert_rowid(((ORDASQLiteGovernor *)self.governor).connection);

NSMutableArray * colarr = [NSMutableArray arrayWithCapacity:columns];
NSMutableDictionary * arrayDict = [NSMutableDictionary dictionaryWithCapacity:columns];
NSMutableArray * dictArray = [NSMutableArray array];
colarr = [NSMutableArray arrayWithCapacity:columns];
arrayDict = [NSMutableDictionary dictionaryWithCapacity:columns];
dictArray = [NSMutableArray array];

if (columns > 0) {
for (int i = 0; i < columns; i++)
Expand All @@ -97,15 +99,13 @@ - (void)dealloc
}
} while ((status = sqlite3_step(self.statement)) == SQLITE_ROW);
rows = (int)dictArray.count;
} else {

}

done:
if (status == SQLITE_DONE)
return _result = [ORDAStatementResultImpl statementResultWithChanged:changed andLastID:lastID andRows:rows andColumns:colarr andDictionaryOfArrays:arrayDict andArrayOfDictionaries:dictArray].retain;
return _result = [ORDAStatementResultImpl statementResultWithChanged:changed andLastID:lastID andRows:rows andColumns:colarr andDictionaryOfArrays:arrayDict andArrayOfDictionaries:dictArray];
else
return _result = (id<ORDAStatementResult>)[ORDASQLiteErrorResult errorWithSQLiteErrorCode:status].retain;
return _result = (id<ORDAStatementResult>)[ORDASQLiteErrorResult errorWithSQLiteErrorCode:status];
}

return _result;
Expand All @@ -116,7 +116,6 @@ - (void)dealloc
if (!_result)
return nil;

[_result release];
_result = nil;

return [ORDASQLiteErrorResult errorWithSQLiteErrorCode:sqlite3_reset(self.statement)];
Expand Down
22 changes: 7 additions & 15 deletions CocoaSQLite/ORDASQLiteTable.m
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,14 @@ - (id)initWithGovernor:(id<ORDAGovernor>)governor withName:(NSString *)tableName
return self;

if (![governor isKindOfClass:[ORDASQLiteGovernor class]])
return (ORDASQLiteTable *)[ORDASQLiteErrorResult errorWithCode:kORDAInternalAPIMismatchErrorResultCode].retain;
return (ORDASQLiteTable *)[ORDASQLiteErrorResult errorWithCode:(ORDASQLiteResultCodeError)kORDAInternalAPIMismatchErrorResultCode];

_tableInfoStatement = [self.governor createStatement:@"PRAGMA table_info(%@)", self.name].retain;
_foreignKeyListStatement = [self.governor createStatement:@"PRAGMA foreign_key_list(%@)", self.name].retain;
_tableInfoStatement = [self.governor createStatement:@"PRAGMA table_info(%@)", self.name];
_foreignKeyListStatement = [self.governor createStatement:@"PRAGMA foreign_key_list(%@)", self.name];

return self;
}

- (void)dealloc
{
[_tableInfoStatement release];
[_foreignKeyListStatement release];

[super dealloc];
}

- (NSArray *)columnNames
{
return _tableInfoStatement.result[@"name"];
Expand Down Expand Up @@ -101,7 +93,7 @@ - (id)selectWhereRowidEquals:(NSNumber *)rowid
else {
va_list args;
va_start(args, format);
clause = [[[NSString alloc] initWithFormat:format arguments:args] autorelease];
clause = [[NSString alloc] initWithFormat:format arguments:args];
va_end(args);
}

Expand Down Expand Up @@ -170,7 +162,7 @@ - (id)selectWhereRowidEquals:(NSNumber *)rowid
else {
va_list args;
va_start(args, format);
clause = [[[NSString alloc] initWithFormat:format arguments:args] autorelease];
clause = [[NSString alloc] initWithFormat:format arguments:args];
va_end(args);
}

Expand All @@ -193,7 +185,7 @@ - (id)selectWhereRowidEquals:(NSNumber *)rowid
else {
va_list args;
va_start(args, format);
clause = [[[NSString alloc] initWithFormat:format arguments:args] autorelease];
clause = [[NSString alloc] initWithFormat:format arguments:args];
va_end(args);
}

Expand Down Expand Up @@ -226,7 +218,7 @@ - (id)selectWhereRowidEquals:(NSNumber *)rowid
else {
va_list args;
va_start(args, format);
clause = [[[NSString alloc] initWithFormat:format arguments:args] autorelease];
clause = [[NSString alloc] initWithFormat:format arguments:args];
va_end(args);
}

Expand Down
15 changes: 4 additions & 11 deletions CocoaSQLite/ORDASQLiteTableResultEntry.m
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ @implementation ORDASQLiteTableResultEntry {

+ (ORDASQLiteTableResultEntry *)tableResultEntryWithRowID:(NSNumber *)rowid andData:(NSDictionary *)data forTable:(id<ORDATable>)table
{
return [[[self alloc] initWithRowID:rowid andData:data forTable:table] autorelease];
return [[self alloc] initWithRowID:rowid andData:data forTable:table];
}

- (id)initWithObjects:(const id [])objects forKeys:(const id<NSCopying> [])keys count:(NSUInteger)cnt
Expand All @@ -35,7 +35,7 @@ - (id)initWithObjects:(const id [])objects forKeys:(const id<NSCopying> [])keys

id locks[cnt];
for (int i = 0; i < cnt; i++)
locks[i] = [[[NSLock alloc] init] autorelease];
locks[i] = [[NSLock alloc] init];
_locks = [[NSDictionary alloc] initWithObjects:locks forKeys:keys count:cnt];

for (id key in _backing)
Expand All @@ -52,8 +52,8 @@ - (id)initWithRowID:(NSNumber *)rowid andData:(NSDictionary *)data forTable:(id<
if (![table isKindOfClass:ORDASQLiteTable.class])
return nil;

_rowid = rowid.retain;
_table = table.retain;
_rowid = rowid;
_table = table;

[self addObserver:self forKeyPath:@"rowid" options:NSKeyValueObservingOptionNew context:nil];

Expand All @@ -67,13 +67,6 @@ - (void)dealloc

for (id key in _backing)
[self removeObserver:self forKeyPath:[key description] context:nil];

[_table release];
[_rowid release];
[_locks release];
[_backing release];

[super dealloc];
}

- (NSUInteger)count
Expand Down
Loading

0 comments on commit 8d59626

Please sign in to comment.