From bd723745c14a507931753e8602a2b02cdd272280 Mon Sep 17 00:00:00 2001 From: Alex Dvornikov Date: Thu, 7 Sep 2017 09:11:27 -0700 Subject: [PATCH] Allow Cxx references to be used in native module's method signature Reviewed By: javache Differential Revision: D5772182 fbshipit-source-id: 21e2f7b8d14ffdcfc0ba969c9a35315863a19b71 --- RNTester/RNTesterUnitTests/RCTMethodArgumentTests.m | 7 ++++--- React/Base/RCTParserUtils.m | 4 +++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/RNTester/RNTesterUnitTests/RCTMethodArgumentTests.m b/RNTester/RNTesterUnitTests/RCTMethodArgumentTests.m index 79c8db686..8c266cdce 100644 --- a/RNTester/RNTesterUnitTests/RCTMethodArgumentTests.m +++ b/RNTester/RNTesterUnitTests/RCTMethodArgumentTests.m @@ -90,11 +90,12 @@ extern SEL RCTParseMethodSignature(const char *methodSignature, NSArray **argTyp - (void)testNamespacedCxxStruct { NSArray *arguments; - const char *methodSignature = "foo:(foo::type &)foo"; + const char *methodSignature = "foo:(foo::type &)foo bar:(bar::type &)bar"; SEL selector = RCTParseMethodSignature(methodSignature, &arguments); - XCTAssertEqualObjects(NSStringFromSelector(selector), @"foo:"); - XCTAssertEqual(arguments.count, (NSUInteger)1); + XCTAssertEqualObjects(NSStringFromSelector(selector), @"foo:bar:"); + XCTAssertEqual(arguments.count, (NSUInteger)2); XCTAssertEqualObjects(((RCTMethodArgument *)arguments[0]).type, @"foo::type"); + XCTAssertEqualObjects(((RCTMethodArgument *)arguments[1]).type, @"bar::type"); } - (void)testAttributes diff --git a/React/Base/RCTParserUtils.m b/React/Base/RCTParserUtils.m index 138fdf744..d70c4181b 100644 --- a/React/Base/RCTParserUtils.m +++ b/React/Base/RCTParserUtils.m @@ -136,7 +136,9 @@ NSString *RCTParseType(const char **input) RCTReadChar(input, '>'); } RCTSkipWhitespace(input); - RCTReadChar(input, '*'); + if (!RCTReadChar(input, '*')) { + RCTReadChar(input, '&'); + } return type; }