Skip to content

Commit ee50618

Browse files
sherginfacebook-github-bot
authored andcommitted
Fabric: Some helper classes and functions were moved to uimanager/primitives
Summary: Trivial. Reviewed By: mdvacca Differential Revision: D12876747 fbshipit-source-id: a2e72ecb69ffc3787f0d8b432f06b9c9715ac5b1
1 parent e88db99 commit ee50618

File tree

6 files changed

+69
-54
lines changed

6 files changed

+69
-54
lines changed

React/Fabric/Utils/MainRunLoopEventBeat.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
#include <CoreFoundation/CoreFoundation.h>
99
#include <CoreFoundation/CFRunLoop.h>
10-
#include <fabric/uimanager/FabricUIManager.h>
10+
#include <fabric/uimanager/primitives.h>
1111
#include <fabric/events/EventBeat.h>
1212

1313
namespace facebook {

React/Fabric/Utils/RuntimeEventBeat.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
#include <CoreFoundation/CoreFoundation.h>
99
#include <CoreFoundation/CFRunLoop.h>
10-
#include <fabric/uimanager/FabricUIManager.h>
10+
#include <fabric/uimanager/primitives.h>
1111
#include <fabric/events/EventBeat.h>
1212

1313
namespace facebook {

ReactCommon/fabric/uimanager/ComponentDescriptorRegistry.cpp

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include "ComponentDescriptorRegistry.h"
77

88
#include <fabric/core/ShadowNodeFragment.h>
9+
#include <fabric/uimanager/primitives.h>
910

1011
namespace facebook {
1112
namespace react {
@@ -80,25 +81,6 @@ static const std::string componentNameByReactViewName(std::string viewName) {
8081
return viewName;
8182
}
8283

83-
static const RawProps rawPropsFromDynamic(const folly::dynamic object) {
84-
// TODO: Convert this to something smarter, probably returning
85-
// `std::iterator`.
86-
RawProps result;
87-
88-
if (object.isNull()) {
89-
return result;
90-
}
91-
92-
assert(object.isObject());
93-
94-
for (const auto &pair : object.items()) {
95-
assert(pair.first.isString());
96-
result[pair.first.asString()] = pair.second;
97-
}
98-
99-
return result;
100-
}
101-
10284
SharedShadowNode ComponentDescriptorRegistry::createNode(
10385
Tag tag,
10486
const std::string &viewName,

ReactCommon/fabric/uimanager/JSIFabricUIManager.cpp

Lines changed: 3 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
#include "JSIFabricUIManager.h"
44

5+
#include <fabric/uimanager/FabricUIManager.h>
6+
#include <fabric/uimanager/primitives.h>
57
#include <fabric/core/ShadowNode.h>
68
#include <fabric/uimanager/FabricUIManager.h>
79
#include <jsi/JSIDynamic.h>
@@ -11,39 +13,7 @@ namespace react {
1113

1214
namespace {
1315

14-
struct EventTargetWrapper : public EventTarget {
15-
EventTargetWrapper(jsi::WeakObject instanceHandle)
16-
: instanceHandle(std::move(instanceHandle)) {}
17-
18-
mutable jsi::WeakObject instanceHandle;
19-
};
20-
21-
struct EventHandlerWrapper : public EventHandler {
22-
EventHandlerWrapper(jsi::Function eventHandler)
23-
: callback(std::move(eventHandler)) {}
24-
25-
jsi::Function callback;
26-
};
27-
28-
struct ShadowNodeWrapper : public jsi::HostObject {
29-
ShadowNodeWrapper(SharedShadowNode shadowNode)
30-
: shadowNode(std::move(shadowNode)) {}
31-
32-
SharedShadowNode shadowNode;
33-
};
34-
35-
struct ShadowNodeListWrapper : public jsi::HostObject {
36-
ShadowNodeListWrapper(SharedShadowNodeUnsharedList shadowNodeList)
37-
: shadowNodeList(shadowNodeList) {}
38-
39-
SharedShadowNodeUnsharedList shadowNodeList;
40-
};
41-
42-
jsi::Value createNode(
43-
const UIManager &uiManager,
44-
jsi::Runtime &runtime,
45-
const jsi::Value *arguments,
46-
size_t count) {
16+
jsi::Value createNode(const UIManager &uiManager, jsi::Runtime &runtime, const jsi::Value *arguments, size_t count) {
4717
auto reactTag = (Tag)arguments[0].getNumber();
4818
auto viewName = arguments[1].getString(runtime).utf8(runtime);
4919
auto rootTag = (Tag)arguments[2].getNumber();

ReactCommon/fabric/uimanager/Scheduler.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include <fabric/uimanager/ShadowTree.h>
1717
#include <fabric/uimanager/ShadowTreeDelegate.h>
1818
#include <fabric/uimanager/UIManagerDelegate.h>
19+
#include <fabric/uimanager/primitives.h>
1920

2021
namespace facebook {
2122
namespace react {
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
// Copyright 2004-present Facebook. All Rights Reserved.
2+
3+
#pragma once
4+
5+
#include <fabric/core/ShadowNode.h>
6+
#include <folly/dynamic.h>
7+
#include <jsi/JSIDynamic.h>
8+
#include <jsi/jsi.h>
9+
10+
namespace facebook {
11+
namespace react {
12+
13+
using RuntimeExecutor = std::function<void(
14+
std::function<void(facebook::jsi::Runtime &runtime)> &&callback)>;
15+
16+
inline RawProps rawPropsFromDynamic(const folly::dynamic object) noexcept {
17+
RawProps result;
18+
19+
if (object.isNull()) {
20+
return result;
21+
}
22+
23+
assert(object.isObject());
24+
25+
for (const auto &pair : object.items()) {
26+
assert(pair.first.isString());
27+
result[pair.first.asString()] = pair.second;
28+
}
29+
30+
return result;
31+
}
32+
33+
struct EventTargetWrapper : public EventTarget {
34+
EventTargetWrapper(jsi::WeakObject instanceHandle)
35+
: instanceHandle(std::move(instanceHandle)) {}
36+
37+
mutable jsi::WeakObject instanceHandle;
38+
};
39+
40+
struct EventHandlerWrapper : public EventHandler {
41+
EventHandlerWrapper(jsi::Function eventHandler)
42+
: callback(std::move(eventHandler)) {}
43+
44+
jsi::Function callback;
45+
};
46+
47+
struct ShadowNodeWrapper : public jsi::HostObject {
48+
ShadowNodeWrapper(SharedShadowNode shadowNode)
49+
: shadowNode(std::move(shadowNode)) {}
50+
51+
SharedShadowNode shadowNode;
52+
};
53+
54+
struct ShadowNodeListWrapper : public jsi::HostObject {
55+
ShadowNodeListWrapper(SharedShadowNodeUnsharedList shadowNodeList)
56+
: shadowNodeList(shadowNodeList) {}
57+
58+
SharedShadowNodeUnsharedList shadowNodeList;
59+
};
60+
61+
} // namespace react
62+
} // namespace facebook

0 commit comments

Comments
 (0)