diff --git a/React/Base/RCTConvert.h b/React/Base/RCTConvert.h index 520c216b54c..18c2a157b59 100644 --- a/React/Base/RCTConvert.h +++ b/React/Base/RCTConvert.h @@ -235,10 +235,18 @@ RCT_CUSTOM_CONVERTER(type, type, [RCT_DEBUG ? [self NSNumber:json] : json getter } /** - * This macro is used for creating converter functions for typed arrays. + * This macro is used for creating explicitly-named converter functions + * for typed arrays. */ -#define RCT_ARRAY_CONVERTER(type) \ -+ (NSArray *)type##Array:(id)json \ +#define RCT_ARRAY_CONVERTER_NAMED(type, name) \ ++ (NSArray *)name##Array:(id)json \ { \ - return RCTConvertArrayValue(@selector(type:), json); \ + return RCTConvertArrayValue(@selector(name:), json); \ } + +/** + * This macro is used for creating converter functions for typed arrays. + * RCT_ARRAY_CONVERTER_NAMED may be used when type contains characters + * which are disallowed in selector names. + */ +#define RCT_ARRAY_CONVERTER(type) RCT_ARRAY_CONVERTER_NAMED(type, type) diff --git a/React/Base/RCTConvert.m b/React/Base/RCTConvert.m index 1a33d84b676..e26026440e5 100644 --- a/React/Base/RCTConvert.m +++ b/React/Base/RCTConvert.m @@ -558,14 +558,15 @@ RCT_ARRAY_CONVERTER(UIColor) * representable json array values that require no conversion. */ #if RCT_DEBUG -#define RCT_JSON_ARRAY_CONVERTER(type) RCT_ARRAY_CONVERTER(type) +#define RCT_JSON_ARRAY_CONVERTER_NAMED(type, name) RCT_ARRAY_CONVERTER_NAMED(type, name) #else -#define RCT_JSON_ARRAY_CONVERTER(type) + (NSArray *)type##Array:(id)json { return json; } +#define RCT_JSON_ARRAY_CONVERTER_NAMED(type, name) + (NSArray *)name##Array:(id)json { return json; } #endif +#define RCT_JSON_ARRAY_CONVERTER(type) RCT_JSON_ARRAY_CONVERTER_NAMED(type, type) RCT_JSON_ARRAY_CONVERTER(NSArray) RCT_JSON_ARRAY_CONVERTER(NSString) -RCT_JSON_ARRAY_CONVERTER(NSStringArray) +RCT_JSON_ARRAY_CONVERTER_NAMED(NSArray, NSStringArray) RCT_JSON_ARRAY_CONVERTER(NSDictionary) RCT_JSON_ARRAY_CONVERTER(NSNumber)