2017-02-01 22:10:41 +00:00
|
|
|
/**
|
|
|
|
* Copyright (c) 2015-present, Facebook, Inc.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* This source code is licensed under the BSD-style license found in the
|
|
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
|
|
*/
|
|
|
|
|
2017-03-17 13:55:44 +00:00
|
|
|
#include <memory>
|
|
|
|
|
2017-02-01 22:10:41 +00:00
|
|
|
#import <React/RCTConvert.h>
|
2017-02-16 21:56:26 +00:00
|
|
|
#include <JavaScriptCore/JavaScriptCore.h>
|
|
|
|
#include <cxxreact/JSCExecutor.h>
|
2017-02-01 22:10:41 +00:00
|
|
|
#include <folly/dynamic.h>
|
2017-02-16 21:56:26 +00:00
|
|
|
#include <jschelpers/JavaScriptCore.h>
|
2017-02-01 22:10:41 +00:00
|
|
|
|
2017-03-17 13:55:44 +00:00
|
|
|
@class RCTBridge;
|
|
|
|
@class RCTModuleData;
|
|
|
|
|
2017-02-01 22:10:41 +00:00
|
|
|
@interface RCTConvert (folly)
|
|
|
|
|
|
|
|
+ (folly::dynamic)folly_dynamic:(id)json;
|
|
|
|
|
|
|
|
@end
|
2017-02-15 14:12:46 +00:00
|
|
|
|
|
|
|
namespace facebook {
|
|
|
|
namespace react {
|
|
|
|
|
2017-03-17 13:55:44 +00:00
|
|
|
class Instance;
|
|
|
|
|
2017-04-07 16:27:05 +00:00
|
|
|
std::vector<std::unique_ptr<NativeModule>> createNativeModules(NSArray<RCTModuleData *> *modules, RCTBridge *bridge, const std::shared_ptr<Instance> &instance);
|
2017-03-17 13:55:44 +00:00
|
|
|
|
2017-02-16 21:56:26 +00:00
|
|
|
JSContext *contextForGlobalContextRef(JSGlobalContextRef contextRef);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The ValueEncoder<NSArray *>::toValue is used by JSCExecutor callFunctionSync.
|
|
|
|
* Note: Because the NSArray * is really a NSArray * __strong the toValue is
|
|
|
|
* accepting NSArray *const __strong instead of NSArray *&&.
|
|
|
|
*/
|
|
|
|
template <>
|
|
|
|
struct ValueEncoder<NSArray *> {
|
|
|
|
static Value toValue(JSGlobalContextRef ctx, NSArray *const __strong array)
|
|
|
|
{
|
2017-03-16 01:25:35 +00:00
|
|
|
JSValue *value = [JSC_JSValue(ctx) valueWithObject:array inContext:contextForGlobalContextRef(ctx)];
|
2017-02-16 21:56:26 +00:00
|
|
|
return {ctx, [value JSValueRef]};
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-02-15 14:12:46 +00:00
|
|
|
NSError *tryAndReturnError(const std::function<void()>& func);
|
|
|
|
|
|
|
|
} }
|