Overview
Comment: | Use ARC functions for RR |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | trunk |
Files: | files | file ages | folders |
SHA3-256: |
d80ebb2ce13b075e0e67dfb391cd120f |
User & Date: | js 2025-04-18 21:29:58 |
Context
2025-04-18
| ||
21:29 | Use ARC functions for RR Leaf check-in: d80ebb2ce1 user: js tags: trunk | |
2024-08-17
| ||
00:32 | Include includedir in .oc file check-in: 86f27a3ae3 user: js tags: trunk | |
Changes
Changes to src/SL3Connection.m.
︙ | ︙ | |||
22 23 24 25 26 27 28 | #import "SL3ExecuteStatementFailedException.h" #import "SL3OpenFailedException.h" @implementation SL3Connection + (instancetype)connectionWithIRI: (OFIRI *)IRI { | | | > | 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | #import "SL3ExecuteStatementFailedException.h" #import "SL3OpenFailedException.h" @implementation SL3Connection + (instancetype)connectionWithIRI: (OFIRI *)IRI { return objc_autoreleaseReturnValue([[self alloc] initWithIRI: IRI]); } + (instancetype)connectionWithIRI: (OFIRI *)IRI flags: (int)flags { return objc_autoreleaseReturnValue([[self alloc] initWithIRI: IRI flags: flags]); } - (instancetype)initWithIRI: (OFIRI *)IRI { return [self initWithIRI: IRI flags: SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE]; } |
︙ | ︙ | |||
50 51 52 53 54 55 56 | NULL); if (code != SQLITE_OK) @throw [SL3OpenFailedException exceptionWithIRI: IRI flags: flags errorCode: code]; } @catch (id e) { | | | | | 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 | NULL); if (code != SQLITE_OK) @throw [SL3OpenFailedException exceptionWithIRI: IRI flags: flags errorCode: code]; } @catch (id e) { objc_release(self); @throw e; } return self; } - (void)dealloc { sqlite3_close(_conn); [super dealloc]; } - (SL3PreparedStatement *)prepareStatement: (OFConstantString *)SQLStatement { return objc_autoreleaseReturnValue([[SL3PreparedStatement alloc] sl3_initWithConnection: self SQLStatement: SQLStatement]); } - (void)executeStatement: (OFConstantString *)SQLStatement { int code = sqlite3_exec(_conn, SQLStatement.UTF8String, NULL, NULL, NULL); |
︙ | ︙ |
Changes to src/SL3PreparedStatement.m.
︙ | ︙ | |||
21 22 23 24 25 26 27 | #import "SL3BindObjectFailedException.h" #import "SL3ClearBindingsFailedException.h" #import "SL3ExecuteStatementFailedException.h" #import "SL3PrepareStatementFailedException.h" #import "SL3ResetStatementFailedException.h" | < < < < < < | | | | 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 64 | #import "SL3BindObjectFailedException.h" #import "SL3ClearBindingsFailedException.h" #import "SL3ExecuteStatementFailedException.h" #import "SL3PrepareStatementFailedException.h" #import "SL3ResetStatementFailedException.h" @implementation SL3PreparedStatement - (instancetype)sl3_initWithConnection: (SL3Connection *)connection SQLStatement: (OFConstantString *)SQLStatement { self = [super init]; @try { int code = sqlite3_prepare_v2(connection->_conn, SQLStatement.UTF8String, SQLStatement.UTF8StringLength, &_stmt, NULL); if (code != SQLITE_OK) @throw [SL3PrepareStatementFailedException exceptionWithConnection: connection SQLStatement: SQLStatement errorCode: code]; _connection = objc_retain(connection); } @catch (id e) { objc_release(self); @throw e; } return self; } - (void)dealloc { sqlite3_finalize(_stmt); objc_release(_connection); [super dealloc]; } static void bindObject(SL3PreparedStatement *statement, int column, id object) { |
︙ | ︙ | |||
83 84 85 86 87 88 89 | [object longLongValue]); break; } } else if ([object isKindOfClass: [OFString class]]) { OFString *copy = [object copy]; code = sqlite3_bind_text64(statement->_stmt, column, | | > | > | 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 | [object longLongValue]); break; } } else if ([object isKindOfClass: [OFString class]]) { OFString *copy = [object copy]; code = sqlite3_bind_text64(statement->_stmt, column, copy.UTF8String, copy.UTF8StringLength, (void (*)(void *))(void (*)(void))objc_release, SQLITE_UTF8); } else if ([object isKindOfClass: [OFData class]]) { OFData *copy = [object copy]; code = sqlite3_bind_blob64(statement->_stmt, column, copy.items, copy.count * copy.itemSize, (void (*)(void *))(void (*)(void))objc_release); } else if ([object isEqual: [OFNull null]]) code = sqlite3_bind_null(statement->_stmt, column); else @throw [OFInvalidArgumentException exception]; if (code != SQLITE_OK) @throw [SL3BindObjectFailedException |
︙ | ︙ |
Changes to src/exceptions/SL3BindObjectFailedException.m.
︙ | ︙ | |||
28 29 30 31 32 33 34 | } + (instancetype)exceptionWithObject: (id)object column: (int)column statement: (SL3PreparedStatement *)statement errorCode: (int)errorCode { | > | | | | | | | | | | 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 64 65 66 67 68 69 70 71 72 73 74 | } + (instancetype)exceptionWithObject: (id)object column: (int)column statement: (SL3PreparedStatement *)statement errorCode: (int)errorCode { return objc_autoreleaseReturnValue( [[self alloc] initWithObject: object column: column statement: statement errorCode: errorCode]); } - (instancetype)initWithConnection: (SL3Connection *)connection errorCode: (int)errorCode { OF_INVALID_INIT_METHOD } - (instancetype)initWithObject: (id)object column: (int)column statement: (SL3PreparedStatement *)statement errorCode: (int)errorCode { self = [super initWithConnection: statement->_connection errorCode: errorCode]; @try { _object = objc_retain(object); _statement = objc_retain(statement); } @catch (id e) { objc_release(self); @throw e; } return self; } - (void)dealloc { objc_release(_object); objc_release(_statement); [super dealloc]; } @end |
Changes to src/exceptions/SL3ClearBindingsFailedException.m.
︙ | ︙ | |||
26 27 28 29 30 31 32 | { OF_UNRECOGNIZED_SELECTOR } + (instancetype)exceptionWithStatement: (SL3PreparedStatement *)statement errorCode: (int)errorCode { | > | | | | | | 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 64 65 66 | { OF_UNRECOGNIZED_SELECTOR } + (instancetype)exceptionWithStatement: (SL3PreparedStatement *)statement errorCode: (int)errorCode { return objc_autoreleaseReturnValue( [[self alloc] initWithStatement: statement errorCode: errorCode]); } - (instancetype)initWithConnection: (SL3Connection *)connection errorCode: (int)errorCode { OF_INVALID_INIT_METHOD } - (instancetype)initWithStatement: (SL3PreparedStatement *)statement errorCode: (int)errorCode { self = [super initWithConnection: statement->_connection errorCode: errorCode]; @try { _statement = objc_retain(statement); } @catch (id e) { objc_release(self); @throw e; } return self; } - (void)dealloc { objc_release(_statement); [super dealloc]; } @end |
Changes to src/exceptions/SL3Exception.m.
︙ | ︙ | |||
25 26 27 28 29 30 31 | { OF_UNRECOGNIZED_SELECTOR } + (instancetype)exceptionWithConnection: (SL3Connection *)connection errorCode: (int)errorCode { | > | | | | | 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 | { OF_UNRECOGNIZED_SELECTOR } + (instancetype)exceptionWithConnection: (SL3Connection *)connection errorCode: (int)errorCode { return objc_autoreleaseReturnValue( [[self alloc] initWithConnection: connection errorCode: errorCode]); } - (instancetype)init { OF_INVALID_INIT_METHOD } - (instancetype)initWithConnection: (SL3Connection *)connection errorCode: (int)errorCode { self = [super init]; _connection = objc_retain(connection); _errorCode = errorCode; return self; } - (void)dealloc { objc_release(_connection); [super dealloc]; } - (OFString *)description { return [OFString stringWithUTF8String: sqlite3_errstr(_errorCode)]; |
︙ | ︙ |
Changes to src/exceptions/SL3ExecuteStatementFailedException.m.
︙ | ︙ | |||
20 21 22 23 24 25 26 | @implementation SL3ExecuteStatementFailedException @synthesize statement = _statement; + (instancetype)exceptionWithStatement: (SL3PreparedStatement *)statement errorCode: (int)errorCode { | > | | | | | | 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 | @implementation SL3ExecuteStatementFailedException @synthesize statement = _statement; + (instancetype)exceptionWithStatement: (SL3PreparedStatement *)statement errorCode: (int)errorCode { return objc_autoreleaseReturnValue( [[self alloc] initWithStatement: statement errorCode: errorCode]); } - (instancetype)initWithStatement: (SL3PreparedStatement *)statement errorCode: (int)errorCode { self = [super initWithConnection: statement->_connection errorCode: errorCode]; @try { _statement = objc_retain(statement); } @catch (id e) { objc_release(self); @throw e; } return self; } - (void)dealloc { objc_release(_statement); [super dealloc]; } @end |
Changes to src/exceptions/SL3OpenFailedException.m.
︙ | ︙ | |||
27 28 29 30 31 32 33 | OF_UNRECOGNIZED_SELECTOR } + (instancetype)exceptionWithIRI: (OFIRI *)IRI flags: (int)flags errorCode: (int)errorCode { | > | | | | | | 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 64 65 66 67 68 69 70 | OF_UNRECOGNIZED_SELECTOR } + (instancetype)exceptionWithIRI: (OFIRI *)IRI flags: (int)flags errorCode: (int)errorCode { return objc_autoreleaseReturnValue( [[self alloc] initWithIRI: IRI flags: flags errorCode: errorCode]); } - (instancetype)initWithConnection: (SL3Connection *)connection errorCode: (int)errorCode { OF_INVALID_INIT_METHOD } - (instancetype)initWithIRI: (OFIRI *)IRI flags: (int)flags errorCode: (int)errorCode { self = [super initWithConnection: nil errorCode: errorCode]; @try { _IRI = [IRI copy]; _flags = flags; } @catch (id e) { objc_release(self); @throw e; } return self; } - (void)dealloc { objc_release(_IRI); [super dealloc]; } @end |
Changes to src/exceptions/SL3PrepareStatementFailedException.m.
︙ | ︙ | |||
27 28 29 30 31 32 33 | OF_UNRECOGNIZED_SELECTOR } + (instancetype)exceptionWithConnection: (SL3Connection *)connection SQLStatement: (OFConstantString *)SQLStatement errorCode: (int)errorCode { | > | | | | | | | 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 64 65 66 67 68 69 | OF_UNRECOGNIZED_SELECTOR } + (instancetype)exceptionWithConnection: (SL3Connection *)connection SQLStatement: (OFConstantString *)SQLStatement errorCode: (int)errorCode { return objc_autoreleaseReturnValue( [[self alloc] initWithConnection: connection SQLStatement: SQLStatement errorCode: errorCode]); } - (instancetype)initWithConnection: (SL3Connection *)connection errorCode: (int)errorCode { OF_INVALID_INIT_METHOD } - (instancetype)initWithConnection: (SL3Connection *)connection SQLStatement: (OFConstantString *)SQLStatement errorCode: (int)errorCode { self = [super initWithConnection: connection errorCode: errorCode]; @try { _SQLStatement = objc_retain(SQLStatement); } @catch (id e) { objc_release(self); @throw e; } return self; } - (void)dealloc { objc_release(_SQLStatement); [super dealloc]; } @end |
Changes to src/exceptions/SL3ResetStatementFailedException.m.
︙ | ︙ | |||
26 27 28 29 30 31 32 | { OF_UNRECOGNIZED_SELECTOR } + (instancetype)exceptionWithStatement: (SL3PreparedStatement *)statement errorCode: (int)errorCode { | > | | | | | | 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 64 65 66 | { OF_UNRECOGNIZED_SELECTOR } + (instancetype)exceptionWithStatement: (SL3PreparedStatement *)statement errorCode: (int)errorCode { return objc_autoreleaseReturnValue( [[self alloc] initWithStatement: statement errorCode: errorCode]); } - (instancetype)initWithConnection: (SL3Connection *)connection errorCode: (int)errorCode { OF_INVALID_INIT_METHOD } - (instancetype)initWithStatement: (SL3PreparedStatement *)statement errorCode: (int)errorCode { self = [super initWithConnection: statement->_connection errorCode: errorCode]; @try { _statement = objc_retain(statement); } @catch (id e) { objc_release(self); @throw e; } return self; } - (void)dealloc { objc_release(_statement); [super dealloc]; } @end |