Files
react-native/ReactCommon/react/renderer/templateprocessor/UITemplateProcessor.h
T
David Vacca 3093010ea5 move fabric to ReactCommon/react/renderer
Summary:
This diff moves fabric C++ code from ReactCommon/fabric to ReactCommon/react/renderer
As part of this diff I also refactored components, codegen and callsites on CatalystApp, FB4A and venice

Script: P137350694

changelog: [internal] internal refactor

Reviewed By: fkgozali

Differential Revision: D22852139

fbshipit-source-id: f85310ba858b6afd81abfd9cbe6d70b28eca7415
2020-07-31 13:34:29 -07:00

67 lines
1.9 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 <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 rootTag,
const folly::dynamic &params,
const ComponentDescriptorRegistry &componentDescriptorRegistry,
const NativeModuleRegistry &nativeModuleRegistry,
const std::shared_ptr<const ReactNativeConfig> reactNativeConfig);
private:
static ShadowNode::Shared runCommand(
const folly::dynamic &command,
Tag rootTag,
std::vector<SharedShadowNode> &nodes,
std::vector<folly::dynamic> &registers,
const ComponentDescriptorRegistry &componentDescriptorRegistry,
const NativeModuleRegistry &nativeModuleRegistry,
const std::shared_ptr<const ReactNativeConfig> reactNativeConfig);
};
} // namespace react
} // namespace facebook