mirror of
https://github.com/status-im/react-native.git
synced 2025-02-24 15:18:10 +00:00
Summary: React bytecode is kind of a different thing that sebmarkbage already has in mind so lets keep the namespace separate. Reviewed By: mdvacca Differential Revision: D12896293 fbshipit-source-id: e0f266da6e7a051bcf5defea49b958452342754d
64 lines
1.7 KiB
C++
64 lines
1.7 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 <fabric/core/ShadowNode.h>
|
|
#include <fabric/uimanager/ComponentDescriptorRegistry.h>
|
|
#include <fabric/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 SharedShadowNode buildShadowTree(
|
|
const std::string &jsonStr,
|
|
int rootTag,
|
|
const folly::dynamic ¶ms,
|
|
const ComponentDescriptorRegistry &componentDescriptorRegistry,
|
|
const NativeModuleRegistry &nativeModuleRegistry);
|
|
|
|
private:
|
|
static SharedShadowNode runCommand(
|
|
const folly::dynamic &command,
|
|
Tag rootTag,
|
|
std::vector<SharedShadowNode> &nodes,
|
|
std::vector<folly::dynamic> ®isters,
|
|
const ComponentDescriptorRegistry &componentDescriptorRegistry,
|
|
const NativeModuleRegistry &nativeModuleRegistry);
|
|
};
|
|
} // namespace react
|
|
} // namespace facebook
|