Fabric: Some helper classes and functions were moved to uimanager/primitives
Summary: Trivial. Reviewed By: mdvacca Differential Revision: D12876747 fbshipit-source-id: a2e72ecb69ffc3787f0d8b432f06b9c9715ac5b1
This commit is contained in:
parent
e88db99465
commit
ee5061886e
|
@ -7,7 +7,7 @@
|
|||
|
||||
#include <CoreFoundation/CoreFoundation.h>
|
||||
#include <CoreFoundation/CFRunLoop.h>
|
||||
#include <fabric/uimanager/FabricUIManager.h>
|
||||
#include <fabric/uimanager/primitives.h>
|
||||
#include <fabric/events/EventBeat.h>
|
||||
|
||||
namespace facebook {
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
#include <CoreFoundation/CoreFoundation.h>
|
||||
#include <CoreFoundation/CFRunLoop.h>
|
||||
#include <fabric/uimanager/FabricUIManager.h>
|
||||
#include <fabric/uimanager/primitives.h>
|
||||
#include <fabric/events/EventBeat.h>
|
||||
|
||||
namespace facebook {
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#include "ComponentDescriptorRegistry.h"
|
||||
|
||||
#include <fabric/core/ShadowNodeFragment.h>
|
||||
#include <fabric/uimanager/primitives.h>
|
||||
|
||||
namespace facebook {
|
||||
namespace react {
|
||||
|
@ -80,25 +81,6 @@ static const std::string componentNameByReactViewName(std::string viewName) {
|
|||
return viewName;
|
||||
}
|
||||
|
||||
static const RawProps rawPropsFromDynamic(const folly::dynamic object) {
|
||||
// TODO: Convert this to something smarter, probably returning
|
||||
// `std::iterator`.
|
||||
RawProps result;
|
||||
|
||||
if (object.isNull()) {
|
||||
return result;
|
||||
}
|
||||
|
||||
assert(object.isObject());
|
||||
|
||||
for (const auto &pair : object.items()) {
|
||||
assert(pair.first.isString());
|
||||
result[pair.first.asString()] = pair.second;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
SharedShadowNode ComponentDescriptorRegistry::createNode(
|
||||
Tag tag,
|
||||
const std::string &viewName,
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
#include "JSIFabricUIManager.h"
|
||||
|
||||
#include <fabric/uimanager/FabricUIManager.h>
|
||||
#include <fabric/uimanager/primitives.h>
|
||||
#include <fabric/core/ShadowNode.h>
|
||||
#include <fabric/uimanager/FabricUIManager.h>
|
||||
#include <jsi/JSIDynamic.h>
|
||||
|
@ -11,39 +13,7 @@ namespace react {
|
|||
|
||||
namespace {
|
||||
|
||||
struct EventTargetWrapper : public EventTarget {
|
||||
EventTargetWrapper(jsi::WeakObject instanceHandle)
|
||||
: instanceHandle(std::move(instanceHandle)) {}
|
||||
|
||||
mutable jsi::WeakObject instanceHandle;
|
||||
};
|
||||
|
||||
struct EventHandlerWrapper : public EventHandler {
|
||||
EventHandlerWrapper(jsi::Function eventHandler)
|
||||
: callback(std::move(eventHandler)) {}
|
||||
|
||||
jsi::Function callback;
|
||||
};
|
||||
|
||||
struct ShadowNodeWrapper : public jsi::HostObject {
|
||||
ShadowNodeWrapper(SharedShadowNode shadowNode)
|
||||
: shadowNode(std::move(shadowNode)) {}
|
||||
|
||||
SharedShadowNode shadowNode;
|
||||
};
|
||||
|
||||
struct ShadowNodeListWrapper : public jsi::HostObject {
|
||||
ShadowNodeListWrapper(SharedShadowNodeUnsharedList shadowNodeList)
|
||||
: shadowNodeList(shadowNodeList) {}
|
||||
|
||||
SharedShadowNodeUnsharedList shadowNodeList;
|
||||
};
|
||||
|
||||
jsi::Value createNode(
|
||||
const UIManager &uiManager,
|
||||
jsi::Runtime &runtime,
|
||||
const jsi::Value *arguments,
|
||||
size_t count) {
|
||||
jsi::Value createNode(const UIManager &uiManager, jsi::Runtime &runtime, const jsi::Value *arguments, size_t count) {
|
||||
auto reactTag = (Tag)arguments[0].getNumber();
|
||||
auto viewName = arguments[1].getString(runtime).utf8(runtime);
|
||||
auto rootTag = (Tag)arguments[2].getNumber();
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#include <fabric/uimanager/ShadowTree.h>
|
||||
#include <fabric/uimanager/ShadowTreeDelegate.h>
|
||||
#include <fabric/uimanager/UIManagerDelegate.h>
|
||||
#include <fabric/uimanager/primitives.h>
|
||||
|
||||
namespace facebook {
|
||||
namespace react {
|
||||
|
|
|
@ -0,0 +1,62 @@
|
|||
// Copyright 2004-present Facebook. All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <fabric/core/ShadowNode.h>
|
||||
#include <folly/dynamic.h>
|
||||
#include <jsi/JSIDynamic.h>
|
||||
#include <jsi/jsi.h>
|
||||
|
||||
namespace facebook {
|
||||
namespace react {
|
||||
|
||||
using RuntimeExecutor = std::function<void(
|
||||
std::function<void(facebook::jsi::Runtime &runtime)> &&callback)>;
|
||||
|
||||
inline RawProps rawPropsFromDynamic(const folly::dynamic object) noexcept {
|
||||
RawProps result;
|
||||
|
||||
if (object.isNull()) {
|
||||
return result;
|
||||
}
|
||||
|
||||
assert(object.isObject());
|
||||
|
||||
for (const auto &pair : object.items()) {
|
||||
assert(pair.first.isString());
|
||||
result[pair.first.asString()] = pair.second;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
struct EventTargetWrapper : public EventTarget {
|
||||
EventTargetWrapper(jsi::WeakObject instanceHandle)
|
||||
: instanceHandle(std::move(instanceHandle)) {}
|
||||
|
||||
mutable jsi::WeakObject instanceHandle;
|
||||
};
|
||||
|
||||
struct EventHandlerWrapper : public EventHandler {
|
||||
EventHandlerWrapper(jsi::Function eventHandler)
|
||||
: callback(std::move(eventHandler)) {}
|
||||
|
||||
jsi::Function callback;
|
||||
};
|
||||
|
||||
struct ShadowNodeWrapper : public jsi::HostObject {
|
||||
ShadowNodeWrapper(SharedShadowNode shadowNode)
|
||||
: shadowNode(std::move(shadowNode)) {}
|
||||
|
||||
SharedShadowNode shadowNode;
|
||||
};
|
||||
|
||||
struct ShadowNodeListWrapper : public jsi::HostObject {
|
||||
ShadowNodeListWrapper(SharedShadowNodeUnsharedList shadowNodeList)
|
||||
: shadowNodeList(shadowNodeList) {}
|
||||
|
||||
SharedShadowNodeUnsharedList shadowNodeList;
|
||||
};
|
||||
|
||||
} // namespace react
|
||||
} // namespace facebook
|
Loading…
Reference in New Issue