From 0ee03178a023a6238510d4a80db7829edf575fca Mon Sep 17 00:00:00 2001 From: Kevin Gozali Date: Fri, 23 Feb 2018 19:32:36 -0800 Subject: [PATCH] added C++ setup for FabricUIManager Reviewed By: shergin Differential Revision: D7077312 fbshipit-source-id: e284c151438eb4d1f67a8386580ab54e3dce7c17 --- ReactCommon/fabric/BUCK | 46 ++++++++++++++++++++++++++ ReactCommon/fabric/FabricUIManager.cpp | 46 ++++++++++++++++++++++++++ ReactCommon/fabric/FabricUIManager.h | 34 +++++++++++++++++++ ReactCommon/fabric/ShadowNode.cpp | 15 +++++++++ ReactCommon/fabric/ShadowNode.h | 22 ++++++++++++ 5 files changed, 163 insertions(+) create mode 100644 ReactCommon/fabric/BUCK create mode 100644 ReactCommon/fabric/FabricUIManager.cpp create mode 100644 ReactCommon/fabric/FabricUIManager.h create mode 100644 ReactCommon/fabric/ShadowNode.cpp create mode 100644 ReactCommon/fabric/ShadowNode.h diff --git a/ReactCommon/fabric/BUCK b/ReactCommon/fabric/BUCK new file mode 100644 index 00000000000000..4fcbe82b5b40a9 --- /dev/null +++ b/ReactCommon/fabric/BUCK @@ -0,0 +1,46 @@ +load("@xplat//configurations/buck/apple:flag_defs.bzl", "DEBUG_PREPROCESSOR_FLAGS") +load("//ReactNative:DEFS.bzl", "IS_OSS_BUILD", "rn_xplat_cxx_library", "APPLE_INSPECTOR_FLAGS") + +CXX_LIBRARY_COMPILER_FLAGS = [ + "-std=c++14", + "-Wall", +] + +APPLE_COMPILER_FLAGS = [] + +if not IS_OSS_BUILD: + load("@xplat//configurations/buck/apple:flag_defs.bzl", "STATIC_LIBRARY_IOS_FLAGS", "flags") + APPLE_COMPILER_FLAGS = flags.get_flag_value(STATIC_LIBRARY_IOS_FLAGS, 'compiler_flags') + +rn_xplat_cxx_library( + name = "fabric", + srcs = glob(["**/*.cpp"]), + header_namespace = "", + exported_headers = subdir_glob( + [ + ("", "**/*.h"), + ], + prefix = "fabric", + ), + compiler_flags = CXX_LIBRARY_COMPILER_FLAGS + [ + "-fexceptions", + "-frtti", + ], + fbobjc_compiler_flags = APPLE_COMPILER_FLAGS, + fbobjc_preprocessor_flags = DEBUG_PREPROCESSOR_FLAGS + APPLE_INSPECTOR_FLAGS, + force_static = True, + preprocessor_flags = [ + "-DLOG_TAG=\"ReactNative\"", + "-DWITH_FBSYSTRACE=1", + ], + visibility = [ + "PUBLIC", + ], + deps = [ + "xplat//fbsystrace:fbsystrace", + "xplat//folly:headers_only", + "xplat//folly:memory", + "xplat//folly:molly", + "xplat//third-party/glog:glog", + ], +) diff --git a/ReactCommon/fabric/FabricUIManager.cpp b/ReactCommon/fabric/FabricUIManager.cpp new file mode 100644 index 00000000000000..c58fd859f141af --- /dev/null +++ b/ReactCommon/fabric/FabricUIManager.cpp @@ -0,0 +1,46 @@ +// Copyright 2004-present Facebook. All Rights Reserved. + +#include "FabricUIManager.h" +#include "ShadowNode.h" + +namespace facebook { +namespace react { + +FabricUIManager::FabricUIManager() {} + +ShadowNodeRef FabricUIManager::createNode(int reactTag, std::string viewName, int rootTag, folly::dynamic props, void *instanceHandle) { + return std::make_shared(reactTag, viewName, rootTag, props, instanceHandle); +} + +ShadowNodeRef FabricUIManager::cloneNode(const ShadowNodeRef &node) { + return nullptr; +} + +ShadowNodeRef FabricUIManager::cloneNodeWithNewChildren(const ShadowNodeRef &node) { + return nullptr; +} + +ShadowNodeRef FabricUIManager::cloneNodeWithNewProps(const ShadowNodeRef &node, folly::dynamic props) { + return nullptr; +} + +ShadowNodeRef FabricUIManager::cloneNodeWithNewChildrenAndProps(const ShadowNodeRef &node, folly::dynamic newProps) { + return nullptr; +} + +void FabricUIManager::appendChild(const ShadowNodeRef &parentNode, const ShadowNodeRef &childNode) { +} + +ShadowNodeSetRef FabricUIManager::createChildSet(int rootTag) { + return nullptr; +} + +void FabricUIManager::appendChildToSet(const ShadowNodeSetRef &childSet, const ShadowNodeRef &childNode) { +} + +void FabricUIManager::completeRoot(int rootTag) { +} + +}} + + diff --git a/ReactCommon/fabric/FabricUIManager.h b/ReactCommon/fabric/FabricUIManager.h new file mode 100644 index 00000000000000..118a713962a37a --- /dev/null +++ b/ReactCommon/fabric/FabricUIManager.h @@ -0,0 +1,34 @@ +// Copyright 2004-present Facebook. All Rights Reserved. + +#pragma once + +#include +#include +#include + +namespace facebook { +namespace react { + +class ShadowNode; + +typedef std::shared_ptr ShadowNodeRef; +typedef folly::fbvector ShadowNodeSet; +typedef std::shared_ptr ShadowNodeSetRef; + +class FabricUIManager { +public: + FabricUIManager(); + + ShadowNodeRef createNode(int reactTag, std::string viewName, int rootTag, folly::dynamic props, void *instanceHandle); + ShadowNodeRef cloneNode(const ShadowNodeRef &node); + ShadowNodeRef cloneNodeWithNewChildren(const ShadowNodeRef &node); + ShadowNodeRef cloneNodeWithNewProps(const ShadowNodeRef &node, folly::dynamic props); + ShadowNodeRef cloneNodeWithNewChildrenAndProps(const ShadowNodeRef &node, folly::dynamic newProps); + void appendChild(const ShadowNodeRef &parentNode, const ShadowNodeRef &childNode); + ShadowNodeSetRef createChildSet(int rootTag); + void appendChildToSet(const ShadowNodeSetRef &childSet, const ShadowNodeRef &childNode); + void completeRoot(int rootTag); +}; + +}} + diff --git a/ReactCommon/fabric/ShadowNode.cpp b/ReactCommon/fabric/ShadowNode.cpp new file mode 100644 index 00000000000000..39b4d145a798c6 --- /dev/null +++ b/ReactCommon/fabric/ShadowNode.cpp @@ -0,0 +1,15 @@ +// Copyright 2004-present Facebook. All Rights Reserved. + +#include "ShadowNode.h" + +namespace facebook { +namespace react { + +ShadowNode::ShadowNode(int reactTag, std::string viewName, int rootTag, folly::dynamic props, void *instanceHandle) : + reactTag_(reactTag), + viewName_(viewName), + rootTag_(rootTag), + props_(props), + instanceHandle_(instanceHandle) {} + +}} diff --git a/ReactCommon/fabric/ShadowNode.h b/ReactCommon/fabric/ShadowNode.h new file mode 100644 index 00000000000000..a707f7160970a9 --- /dev/null +++ b/ReactCommon/fabric/ShadowNode.h @@ -0,0 +1,22 @@ +// Copyright 2004-present Facebook. All Rights Reserved. + +#pragma once + +#include +#include + +namespace facebook { +namespace react { + +class ShadowNode { +public: + int reactTag_; + std::string viewName_; + int rootTag_; + folly::dynamic props_; + void *instanceHandle_; + + ShadowNode(int reactTag, std::string viewName, int rootTag, folly::dynamic props, void *instanceHandle); +}; + +}}