mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
ce50c43986
Summary: changelog: [internal] Add more clang tidy rules to prevent common class of bugs. Reviewed By: javache Differential Revision: D39245194 fbshipit-source-id: 5521c5c4653d7005b96ebba494e810ba5075afbc
67 lines
1.9 KiB
C++
67 lines
1.9 KiB
C++
/*
|
|
* Copyright (c) Meta Platforms, Inc. and 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 <folly/dynamic.h>
|
|
|
|
#include <react/config/ReactNativeConfig.h>
|
|
#include <react/renderer/componentregistry/ComponentDescriptorRegistry.h>
|
|
#include <react/renderer/core/ShadowNode.h>
|
|
#include <react/renderer/uimanager/UIManagerDelegate.h>
|
|
|
|
namespace facebook {
|
|
namespace react {
|
|
|
|
// Temporary NativeModuleRegistry definition
|
|
using NativeModuleCallFn =
|
|
std::function<folly::dynamic(const std::string &, const folly::dynamic &)>;
|
|
|
|
class NativeModuleRegistry {
|
|
public:
|
|
void registerModule(
|
|
const std::string &moduleName,
|
|
NativeModuleCallFn callFn) {
|
|
modules_.emplace(moduleName, callFn);
|
|
}
|
|
|
|
folly::dynamic call(
|
|
const std::string &moduleName,
|
|
const std::string &methodName,
|
|
const folly::dynamic &args) const {
|
|
return modules_.at(moduleName)(methodName, args);
|
|
}
|
|
|
|
private:
|
|
std::unordered_map<std::string, NativeModuleCallFn> modules_;
|
|
};
|
|
|
|
class UITemplateProcessor {
|
|
public:
|
|
static ShadowNode::Shared buildShadowTree(
|
|
const std::string &jsonStr,
|
|
int surfaceId,
|
|
const folly::dynamic ¶ms,
|
|
const ComponentDescriptorRegistry &componentDescriptorRegistry,
|
|
const NativeModuleRegistry &nativeModuleRegistry,
|
|
std::shared_ptr<const ReactNativeConfig> const &reactNativeConfig);
|
|
|
|
private:
|
|
static ShadowNode::Shared runCommand(
|
|
const folly::dynamic &command,
|
|
Tag surfaceId,
|
|
std::vector<ShadowNode::Shared> &nodes,
|
|
std::vector<folly::dynamic> ®isters,
|
|
const ComponentDescriptorRegistry &componentDescriptorRegistry,
|
|
const NativeModuleRegistry &nativeModuleRegistry,
|
|
std::shared_ptr<const ReactNativeConfig> const &reactNativeConfig);
|
|
};
|
|
} // namespace react
|
|
} // namespace facebook
|