/*
 *  Copyright (c) 2018-present, Facebook, Inc.
 *
 *  This source code is licensed under the MIT license found in the LICENSE
 *  file in the root directory of this source tree.
 *
 */
#import "SonarCppBridgingResponder.h"

#import <FBCxxUtils/FBCxxFollyDynamicConvert.h>

@implementation SonarCppBridgingResponder {
  std::unique_ptr<facebook::sonar::SonarResponder> responder_;
}

- (instancetype)initWithCppResponder:(std::unique_ptr<facebook::sonar::SonarResponder>)responder
{
  if (!responder) {
    return nil;
  }

  if (self = [super init]) {
    responder_ = std::move(responder);
  }

  return self;
}

#pragma mark - SonarResponder

- (void)success:(NSDictionary *)response { responder_->success(facebook::cxxutils::convertIdToFollyDynamic(response)); }

- (void)error:(NSDictionary *)response { responder_->error(facebook::cxxutils::convertIdToFollyDynamic(response)); }

@end

/*
 *  Copyright (c) 2018-present, Facebook, Inc.
 *
 *  This source code is licensed under the MIT license found in the LICENSE
 *  file in the root directory of this source tree.
 *
 */
#import "SonarCppBridgingResponder.h"

#import <FBCxxUtils/FBCxxFollyDynamicConvert.h>

@implementation SonarCppBridgingResponder {
  std::unique_ptr<facebook::sonar::SonarResponder> responder_;
}

- (instancetype)initWithCppResponder:(std::unique_ptr<facebook::sonar::SonarResponder>)responder
{
  if (!responder) {
    return nil;
  }

  if (self = [super init]) {
    responder_ = std::move(responder);
  }

  return self;
}

#pragma mark - SonarResponder

- (void)success:(NSDictionary *)response { responder_->success(facebook::cxxutils::convertIdToFollyDynamic(response, true)); }

- (void)error:(NSDictionary *)response { responder_->error(facebook::cxxutils::convertIdToFollyDynamic(response, true)); }

@end

Fix Nan / Inf serialization issue
Fix Nan / Inf serialization issue

Summary:
Sonar was trying to convert folly dynamics containing NaN and Inf to json.
Folly doesn't allow this so we have to get rid of them before converting.

See https://fb.facebook.com/groups/230455004101832/permalink/483173632163300/ for more context.

`grep -r convertFollyDynamicToId fbsource/xplat/sonar` now returns results which all have `true` in the second parameter slot.

Reviewed By: danielbuechele

Differential Revision: D9570364

fbshipit-source-id: bf28b03e54b4987399e028a491d82451a8267d97
