Fixed broken struct arguments

This commit is contained in:
Nick Lockwood 2015-04-22 13:23:48 -07:00
parent b4c82a4089
commit fc6e209223
3 changed files with 14 additions and 8 deletions

View File

@ -163,12 +163,12 @@ RCT_EXPORT_MODULE()
#pragma mark - Public API #pragma mark - Public API
RCT_EXPORT_METHOD(startObserving:(RCTLocationOptions)options) RCT_EXPORT_METHOD(startObserving:(NSDictionary *)optionsJSON)
{ {
[self checkLocationConfig]; [self checkLocationConfig];
// Select best options // Select best options
_observerOptions = options; _observerOptions = [RCTConvert RCTLocationOptions:optionsJSON];
for (RCTLocationRequest *request in _pendingRequests) { for (RCTLocationRequest *request in _pendingRequests) {
_observerOptions.accuracy = MIN(_observerOptions.accuracy, request.options.accuracy); _observerOptions.accuracy = MIN(_observerOptions.accuracy, request.options.accuracy);
} }
@ -189,7 +189,7 @@ RCT_EXPORT_METHOD(stopObserving)
} }
} }
RCT_EXPORT_METHOD(getCurrentPosition:(RCTLocationOptions)options RCT_EXPORT_METHOD(getCurrentPosition:(NSDictionary *)optionsJSON
withSuccessCallback:(RCTResponseSenderBlock)successBlock withSuccessCallback:(RCTResponseSenderBlock)successBlock
errorCallback:(RCTResponseSenderBlock)errorBlock) errorCallback:(RCTResponseSenderBlock)errorBlock)
{ {
@ -219,6 +219,7 @@ RCT_EXPORT_METHOD(getCurrentPosition:(RCTLocationOptions)options
} }
// Check if previous recorded location exists and is good enough // Check if previous recorded location exists and is good enough
RCTLocationOptions options = [RCTConvert RCTLocationOptions:optionsJSON];
if (_lastLocationEvent && if (_lastLocationEvent &&
CFAbsoluteTimeGetCurrent() - [RCTConvert NSTimeInterval:_lastLocationEvent[@"timestamp"]] < options.maximumAge && CFAbsoluteTimeGetCurrent() - [RCTConvert NSTimeInterval:_lastLocationEvent[@"timestamp"]] < options.maximumAge &&
[_lastLocationEvent[@"coords"][@"accuracy"] doubleValue] >= options.accuracy) { [_lastLocationEvent[@"coords"][@"accuracy"] doubleValue] >= options.accuracy) {

View File

@ -375,10 +375,14 @@ static NSString *RCTStringUpToFirstArgument(NSString *methodName)
RCT_CONVERT_CASE('B', BOOL) RCT_CONVERT_CASE('B', BOOL)
RCT_CONVERT_CASE('@', id) RCT_CONVERT_CASE('@', id)
RCT_CONVERT_CASE('^', void *) RCT_CONVERT_CASE('^', void *)
case '{':
RCTAssert(NO, @"Argument %zd of %C[%@ %@] is defined as %@, however RCT_EXPORT_METHOD() "
"does not currently support struct-type arguments.", i - 2,
[reactMethodName characterAtIndex:0], _moduleClassName,
objCMethodName, argumentName);
break;
default: default:
defaultCase(argumentType); defaultCase(argumentType);
break;
} }
} else if ([argumentName isEqualToString:@"RCTResponseSenderBlock"]) { } else if ([argumentName isEqualToString:@"RCTResponseSenderBlock"]) {
addBlockArgument(); addBlockArgument();
@ -434,7 +438,6 @@ static NSString *RCTStringUpToFirstArgument(NSString *methodName)
default: default:
defaultCase(argumentType); defaultCase(argumentType);
break;
} }
} }
} }

View File

@ -1001,11 +1001,12 @@ RCT_EXPORT_METHOD(measureLayoutRelativeToParent:(NSNumber *)reactTag
* Only layouts for views that are within the rect passed in are returned. Invokes the error callback if the * Only layouts for views that are within the rect passed in are returned. Invokes the error callback if the
* passed in parent view does not exist. Invokes the supplied callback with the array of computed layouts. * passed in parent view does not exist. Invokes the supplied callback with the array of computed layouts.
*/ */
RCT_EXPORT_METHOD(measureViewsInRect:(CGRect)rect RCT_EXPORT_METHOD(measureViewsInRect:(id)rectJSON
parentView:(NSNumber *)reactTag parentView:(NSNumber *)reactTag
errorCallback:(RCTResponseSenderBlock)errorCallback errorCallback:(RCTResponseSenderBlock)errorCallback
callback:(RCTResponseSenderBlock)callback) callback:(RCTResponseSenderBlock)callback)
{ {
CGRect rect = [RCTConvert CGRect:rectJSON];
RCTShadowView *shadowView = _shadowViewRegistry[reactTag]; RCTShadowView *shadowView = _shadowViewRegistry[reactTag];
if (!shadowView) { if (!shadowView) {
RCTLogError(@"Attempting to measure view that does not exist (tag #%@)", reactTag); RCTLogError(@"Attempting to measure view that does not exist (tag #%@)", reactTag);
@ -1101,8 +1102,9 @@ RCT_EXPORT_METHOD(scrollWithoutAnimationTo:(NSNumber *)reactTag
} }
RCT_EXPORT_METHOD(zoomToRect:(NSNumber *)reactTag RCT_EXPORT_METHOD(zoomToRect:(NSNumber *)reactTag
withRect:(CGRect)rect) withRect:(id)rectJSON)
{ {
CGRect rect = [RCTConvert CGRect:rectJSON];
[self addUIBlock:^(RCTUIManager *uiManager, RCTSparseArray *viewRegistry){ [self addUIBlock:^(RCTUIManager *uiManager, RCTSparseArray *viewRegistry){
UIView *view = viewRegistry[reactTag]; UIView *view = viewRegistry[reactTag];
if ([view conformsToProtocol:@protocol(RCTScrollableProtocol)]) { if ([view conformsToProtocol:@protocol(RCTScrollableProtocol)]) {