Permalink
Browse files

add more primitive types support (#569)

* add more primitive types support

* fix char convert to BOOL bugs

* add Unit Test for primitive support

* remove commented codes
  • Loading branch information...
ahui2823 authored and billinghamj committed Mar 28, 2017
1 parent cd940e7 commit 9db401306b35e836e497c81ab0bf2d0256c007ab
@@ -5,7 +5,15 @@
"floatNumber": 12.12,
"doubleNumber": 121231312.124,
"boolYES": true,
"boolNO": false
"boolNO": false,
"unsignedIntNumber": 6666,
"unsignedLongNumber": 666666,
"longLongNumber": 121231312,
"unsignedLongLongNumber": 4121231312,
"unsignedShortNumber": 5555,
"charNumber": 30,
"unsignedCharNumber": 255
}
@@ -6,5 +6,13 @@
"doubleNumber": 121231312.124,
"boolYES": true,
"boolNO": false
"boolNO": false,
"unsignedIntNumber": 6666,
"unsignedLongNumber": 666666,
"longLongNumber": 121231312,
"unsignedLongLongNumber": 4121231312,
"unsignedShortNumber": 5555,
"charNumber": 30,
"unsignedCharNumber": 255
}
@@ -18,4 +18,12 @@
@property (assign, nonatomic) BOOL boolYES;
@property (assign, nonatomic) BOOL boolNO;
@property (assign, nonatomic) unsigned int unsignedIntNumber;
@property (assign, nonatomic) unsigned long unsignedLongNumber;
@property (assign, nonatomic) long long longLongNumber;
@property (assign, nonatomic) unsigned long long unsignedLongLongNumber;
@property (assign, nonatomic) unsigned short unsignedShortNumber;
@property (assign, nonatomic) char charNumber;
@property (assign, nonatomic) unsigned char unsignedCharNumber;
@end
@@ -50,6 +50,14 @@ -(void)testPrimitiveTypes
XCTAssertTrue(p.boolNO==NO, @"boolNO read fail");
XCTAssertTrue(p.boolYES==YES, @"boolYES read fail");
XCTAssertTrue(p.unsignedIntNumber==6666, @"unsignedIntNumber read fail");
XCTAssertTrue(p.unsignedLongNumber==666666, @"unsignedLongNumber read fail");
XCTAssertTrue(p.longLongNumber==121231312, @"longLongNumber read fail");
XCTAssertTrue(p.unsignedLongLongNumber==4121231312, @"unsignedLongLongNumber read fail");
XCTAssertTrue(p.unsignedShortNumber==5555, @"unsignedShortNumber read fail");
XCTAssertTrue(p.charNumber==30, @"charNumber read fail");
XCTAssertTrue(p.unsignedCharNumber==255, @"unsignedCharNumber read fail");
}
-(void)testBoolExport
@@ -53,6 +53,7 @@ +(void)load
allowedPrimitiveTypes = @[
@"BOOL", @"float", @"int", @"long", @"double", @"short",
@"unsigned int", @"usigned long", @"long long", @"unsigned long long", @"unsigned short", @"char", @"unsigned char",
//and some famous aliases
@"NSInteger", @"NSUInteger",
@"Block"
@@ -566,12 +567,6 @@ -(void)__inspectProperties
continue; //to next property
}
//check for 64b BOOLs
if ([propertyAttributes hasPrefix:@"Tc,"]) {
//mask BOOLs as structs so they can have custom converters
p.structName = @"BOOL";
}
scanner = [NSScanner scannerWithString: propertyAttributes];
//JMLog(@"attr: %@", [NSString stringWithCString:attrs encoding:NSUTF8StringEncoding]);
@@ -20,7 +20,8 @@ -(id)init
{
self = [super init];
if (self) {
_primitivesNames = @{@"f":@"float", @"i":@"int", @"d":@"double", @"l":@"long", @"c":@"BOOL", @"s":@"short", @"q":@"long",
_primitivesNames = @{@"f":@"float", @"i":@"int", @"d":@"double", @"l":@"long", @"B":@"BOOL", @"s":@"short",
@"I":@"unsigned int", @"L":@"usigned long", @"q":@"long long", @"Q":@"unsigned long long", @"S":@"unsigned short", @"c":@"char", @"C":@"unsigned char",
//and some famous aliases of primitive types
// BOOL is now "B" on iOS __LP64 builds
@"I":@"NSInteger", @"Q":@"NSUInteger", @"B":@"BOOL",

0 comments on commit 9db4013

Please sign in to comment.