Files
react-native/ReactCommon/react/nativemodule/core/ReactCommon/TurboModuleBinding.h
T
Kevin Gozali 5be44456f2 TurboModule Android: compile TurboModule C++ Core into ReactAndroid
Summary:
This is to prepare for enabling TurboModule on Android. This commit compiles in all the core files (C++) into the ReactAndroid NDK build step. This doesn't yet enable TurboModule by default, just compiling in the infra, just like for iOS.

New shared libs:
* libreact_nativemodule_core.so: The TurboModule Android core
* libreact_nativemodule_manager.so: The TurboModule manager/delegate

To be compatible with `<ReactCommon/` .h include prefix, the files had to move to local `ReactCommon` subdirs.

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D23805717

fbshipit-source-id: b41c392a592dd095ae003f7b2a689f4add2c37a9
2020-09-20 14:23:43 -07:00

59 lines
1.3 KiB
C++

/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
#pragma once
#include <string>
#include <ReactCommon/TurboModule.h>
#include <jsi/jsi.h>
namespace facebook {
namespace react {
class JSCallInvoker;
/**
* Represents the JavaScript binding for the TurboModule system.
*/
class TurboModuleBinding {
public:
/*
* Installs TurboModuleBinding into JavaScript runtime.
* Thread synchronization must be enforced externally.
*/
static void install(
jsi::Runtime &runtime,
const TurboModuleProviderFunctionType &&moduleProvider);
TurboModuleBinding(const TurboModuleProviderFunctionType &&moduleProvider);
virtual ~TurboModuleBinding();
/**
* Get an TurboModule instance for the given module name.
*/
std::shared_ptr<TurboModule> getModule(
const std::string &name,
const jsi::Value *schema);
private:
/**
* A lookup function exposed to JS to get an instance of a TurboModule
* for the given name.
*/
jsi::Value jsProxy(
jsi::Runtime &runtime,
const jsi::Value &thisVal,
const jsi::Value *args,
size_t count);
TurboModuleProviderFunctionType moduleProvider_;
};
} // namespace react
} // namespace facebook