Parse _Nonnull and _Nullable attributes in RCTParseMethodSignature

Differential Revision: D3171305

fb-gh-sync-id: 687b030e13e762110f9ea9b750b0bc09457229a5
fbshipit-source-id: 687b030e13e762110f9ea9b750b0bc09457229a5
This commit is contained in:
Justin Zeus 2016-04-12 17:44:31 -07:00 committed by Facebook Github Bot 3
parent c596f8d0ef
commit b2eecdc90d
1 changed files with 14 additions and 0 deletions

View File

@ -93,6 +93,16 @@ static RCTNullability RCTParseNullability(const char **input)
return RCTNullabilityUnspecified;
}
static RCTNullability RCTParseNullabilityPostfix(const char **input)
{
if (RCTReadString(input, "_Nullable")) {
return RCTNullable;
} else if (RCTReadString(input, "_Nonnull")) {
return RCTNonnullable;
}
return RCTNullabilityUnspecified;
}
SEL RCTParseMethodSignature(NSString *, NSArray<RCTMethodArgument *> **);
SEL RCTParseMethodSignature(NSString *methodSignature, NSArray<RCTMethodArgument *> **arguments)
{
@ -117,6 +127,10 @@ SEL RCTParseMethodSignature(NSString *methodSignature, NSArray<RCTMethodArgument
RCTSkipWhitespace(&input);
NSString *type = RCTParseType(&input);
RCTSkipWhitespace(&input);
if (nullability == RCTNullabilityUnspecified) {
nullability = RCTParseNullabilityPostfix(&input);
}
[args addObject:[[RCTMethodArgument alloc] initWithType:type
nullability:nullability
unused:unused]];