Permalink
Browse files

Add support for bound arrays.

  • Loading branch information...
1 parent 43e1f53 commit a35ed92eebfd1beca0c1a4dd3d55a5629d78c140 @sethk committed Apr 10, 2012
@@ -162,6 +162,9 @@
FD5A13D015311CD800223FED /* FLXPostgresTypeNSDate.m in Sources */ = {isa = PBXBuildFile; fileRef = FD5A13CE152FBC7700223FED /* FLXPostgresTypeNSDate.m */; };
FD77B7DC152ED9130080F258 /* FLXPostgresTypeNSData.h in Headers */ = {isa = PBXBuildFile; fileRef = FD77B7DA152ED9120080F258 /* FLXPostgresTypeNSData.h */; };
FD77B7DD152ED9130080F258 /* FLXPostgresTypeNSData.m in Sources */ = {isa = PBXBuildFile; fileRef = FD77B7DB152ED9120080F258 /* FLXPostgresTypeNSData.m */; };
+ FDC2E6761533E16000FD5AF1 /* FLXPostgresTypeNSArray.h in Headers */ = {isa = PBXBuildFile; fileRef = FDC2E6741533E16000FD5AF1 /* FLXPostgresTypeNSArray.h */; };
+ FDC2E6771533E16000FD5AF1 /* FLXPostgresTypeNSArray.m in Sources */ = {isa = PBXBuildFile; fileRef = FDC2E6751533E16000FD5AF1 /* FLXPostgresTypeNSArray.m */; };
+ FDC2E6791533EF0A00FD5AF1 /* FLXPostgresArray.m in Sources */ = {isa = PBXBuildFile; fileRef = 6E4FFCA80F7E9F5300A11AAD /* FLXPostgresArray.m */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
@@ -551,6 +554,8 @@
FD5A13CE152FBC7700223FED /* FLXPostgresTypeNSDate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FLXPostgresTypeNSDate.m; sourceTree = "<group>"; };
FD77B7DA152ED9120080F258 /* FLXPostgresTypeNSData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FLXPostgresTypeNSData.h; sourceTree = "<group>"; };
FD77B7DB152ED9120080F258 /* FLXPostgresTypeNSData.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FLXPostgresTypeNSData.m; sourceTree = "<group>"; };
+ FDC2E6741533E16000FD5AF1 /* FLXPostgresTypeNSArray.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FLXPostgresTypeNSArray.h; sourceTree = "<group>"; };
+ FDC2E6751533E16000FD5AF1 /* FLXPostgresTypeNSArray.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FLXPostgresTypeNSArray.m; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@@ -720,6 +725,8 @@
FD77B7DB152ED9120080F258 /* FLXPostgresTypeNSData.m */,
FD5A13CD152FBC7700223FED /* FLXPostgresTypeNSDate.h */,
FD5A13CE152FBC7700223FED /* FLXPostgresTypeNSDate.m */,
+ FDC2E6741533E16000FD5AF1 /* FLXPostgresTypeNSArray.h */,
+ FDC2E6751533E16000FD5AF1 /* FLXPostgresTypeNSArray.m */,
);
name = Types;
sourceTree = "<group>";
@@ -1120,6 +1127,7 @@
6E1EA3680FD13DB10039B9FF /* FLXPostgresTypeNSString.h in Headers */,
6ECF97A010B9CB5C0029AB09 /* FLXPostgresTypeNSNumber.h in Headers */,
FD77B7DC152ED9130080F258 /* FLXPostgresTypeNSData.h in Headers */,
+ FDC2E6761533E16000FD5AF1 /* FLXPostgresTypeNSArray.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -1575,6 +1583,8 @@
6ECF97A110B9CB5C0029AB09 /* FLXPostgresTypeNSNumber.m in Sources */,
FD77B7DD152ED9130080F258 /* FLXPostgresTypeNSData.m in Sources */,
FD5A13D015311CD800223FED /* FLXPostgresTypeNSDate.m in Sources */,
+ FDC2E6771533E16000FD5AF1 /* FLXPostgresTypeNSArray.m in Sources */,
+ FDC2E6791533EF0A00FD5AF1 /* FLXPostgresArray.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -4,7 +4,7 @@
// helper function for constructing arrays
@interface FLXPostgresArray : NSObject {
- FLXPostgresType type;
+ FLXPostgresOid type;
NSUInteger dimensions;
NSUInteger* size;
NSUInteger* lowerBound;
@@ -13,13 +13,13 @@
}
@property (retain) NSMutableArray* tuples;
-@property (assign) FLXPostgresType type;
+@property (assign) FLXPostgresOid type;
@property (assign) NSUInteger dimensions;
@property (assign) NSUInteger numberOfTuples;
@property (assign) NSUInteger* size;
@property (assign) NSUInteger* lowerBound;
-+(FLXPostgresArray* )arrayWithDimensions:(NSUInteger)theDimensions type:(FLXPostgresType)theType;
++(FLXPostgresArray* )arrayWithDimensions:(NSUInteger)theDimensions type:(FLXPostgresOid)theType;
// methods
-(void)setDimension:(NSUInteger)theDimension size:(NSUInteger)theSize lowerBound:(NSUInteger)theLowerBound;
@@ -1,6 +1,7 @@
#import "PostgresClientKit.h"
#import "PostgresClientKitPrivate.h"
+#import "FLXPostgresArray.h"
@implementation FLXPostgresArray
@@ -15,7 +16,7 @@ @implementation FLXPostgresArray
////////////////////////////////////////////////////////////////////////////////
--(id)initWithDimensions:(NSUInteger)theDimensions type:(FLXPostgresType)theType {
+-(id)initWithDimensions:(NSUInteger)theDimensions type:(FLXPostgresOid)theType {
self = [super init];
if (self != nil) {
[self setType:theType];
@@ -38,7 +39,7 @@ -(void)dealloc {
[super dealloc];
}
-+(FLXPostgresArray* )arrayWithDimensions:(NSUInteger)theDimensions type:(FLXPostgresType)theType {
++(FLXPostgresArray* )arrayWithDimensions:(NSUInteger)theDimensions type:(FLXPostgresOid)theType {
return [[[FLXPostgresArray alloc] initWithDimensions:theDimensions type:theType] autorelease];
}
@@ -2,6 +2,7 @@
#import "FLXPostgresConnection.h"
#import "PostgresClientKitPrivate.h"
#import "FLXPostgresTypeNSDate.h"
+#import "FLXPostgresTypeNSArray.h"
#import "FLXPostgresException.h"
////////////////////////////////////////////////////////////////////////////////
@@ -300,14 +301,7 @@ -(FLXPostgresResult* )_execute:(NSObject* )theQuery values:(NSArray* )theValues
}
// obtain correct handler for this class
- Class theClass = [theNativeObject class];
- id<FLXPostgresTypeProtocol> theTypeHandler = nil;
- while (theClass) {
- theTypeHandler = [self _typeHandlerForClass:theClass];
- if (theTypeHandler)
- break;
- theClass = [theClass superclass];
- }
+ id<FLXPostgresTypeProtocol> theTypeHandler = [self _typeHandlerForClass:[theNativeObject class]];
if(theTypeHandler==nil) {
free(paramValues);
free(paramTypes);
@@ -473,7 +467,13 @@ -(void)_registerTypeHandler:(Class)theTypeHandlerClass {
}
-(id<FLXPostgresTypeProtocol>)_typeHandlerForClass:(Class)theClass {
- return [m_theTypeMap objectForKey:NSStringFromClass(theClass)];
+ while (theClass) {
+ id<FLXPostgresTypeProtocol> theTypeHandler = [m_theTypeMap objectForKey:NSStringFromClass(theClass)];
+ if (theTypeHandler)
+ return theTypeHandler;
+ theClass = [theClass superclass];
+ }
+ return nil;
}
-(id<FLXPostgresTypeProtocol>)_typeHandlerForRemoteType:(FLXPostgresOid)theType {
@@ -485,6 +485,7 @@ -(void)_registerStandardTypeHandlers {
[self _registerTypeHandler:[FLXPostgresTypeNSNumber class]];
[self _registerTypeHandler:[FLXPostgresTypeNSData class]];
[self _registerTypeHandler:[FLXPostgresTypeNSDate class]];
+ [self _registerTypeHandler:[FLXPostgresTypeNSArray class]];
}
@end
@@ -0,0 +1,6 @@
+
+@interface FLXPostgresTypeNSArray : NSObject <FLXPostgresTypeProtocol> {
+ FLXPostgresConnection* m_theConnection;
+}
+
+@end
Oops, something went wrong.

0 comments on commit a35ed92

Please sign in to comment.