mirror of
https://github.com/status-im/react-native.git
synced 2025-02-23 22:58:19 +00:00
Summary: This is only the core C++ part of TurboModule - moving to github to make integration with existing NativeModules system slightly easier. Other bindings for iOS/Android are not yet ready to move. Notes: * TurboModules is not ready to use at the moment. * Build configuration is not yet provided (cocoapods/.xcodeproj/gradle), just like Fabric. * No effort was done to make this lib C++17 strictly compliant yet (there will be in the future). Reviewed By: RSNara Differential Revision: D13551211 fbshipit-source-id: cd3b458e6746ee9218451962ca65b1ad641a32db
45 lines
1.3 KiB
C++
45 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 <memory>
|
|
#include <vector>
|
|
|
|
#include <cxxreact/CxxModule.h>
|
|
|
|
#include "TurboModule.h"
|
|
|
|
namespace facebook {
|
|
namespace react {
|
|
|
|
/**
|
|
* A helper class to convert the legacy CxxModule instance to a TurboModule instance.
|
|
* This should be used only for migration purpose (to TurboModule), since it's not very performant
|
|
* due to a lot of back-and-forth value conversions between folly::dynamic and jsi::Value.
|
|
*/
|
|
class JSI_EXPORT TurboCxxModule : public TurboModule {
|
|
public:
|
|
TurboCxxModule(std::unique_ptr<facebook::xplat::module::CxxModule> cxxModule, std::shared_ptr<JSCallInvoker> jsInvoker);
|
|
|
|
virtual facebook::jsi::Value get(facebook::jsi::Runtime& runtime, const facebook::jsi::PropNameID& propName) override;
|
|
|
|
virtual jsi::Value invokeMethod(
|
|
jsi::Runtime &runtime,
|
|
TurboModuleMethodValueKind valueKind,
|
|
const std::string &methodName,
|
|
const jsi::Value *args,
|
|
size_t count) override;
|
|
|
|
private:
|
|
std::vector<facebook::xplat::module::CxxModule::Method> cxxMethods_;
|
|
std::unique_ptr<facebook::xplat::module::CxxModule> cxxModule_;
|
|
};
|
|
|
|
} // namespace react
|
|
} // namespace facebook
|