Skip to content

Commit

Permalink
added C++ setup for FabricUIManager
Browse files Browse the repository at this point in the history
Reviewed By: shergin

Differential Revision: D7077312

fbshipit-source-id: e284c151438eb4d1f67a8386580ab54e3dce7c17
  • Loading branch information
fkgozali authored and facebook-github-bot committed Feb 24, 2018
1 parent d8bb990 commit 0ee0317
Show file tree
Hide file tree
Showing 5 changed files with 163 additions and 0 deletions.
46 changes: 46 additions & 0 deletions ReactCommon/fabric/BUCK
Original file line number Diff line number Diff line change
@@ -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",
],
)
46 changes: 46 additions & 0 deletions ReactCommon/fabric/FabricUIManager.cpp
Original file line number Diff line number Diff line change
@@ -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<ShadowNode>(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) {
}

}}


34 changes: 34 additions & 0 deletions ReactCommon/fabric/FabricUIManager.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Copyright 2004-present Facebook. All Rights Reserved.

#pragma once

#include <folly/dynamic.h>
#include <folly/FBVector.h>
#include <memory>

namespace facebook {
namespace react {

class ShadowNode;

typedef std::shared_ptr<const ShadowNode> ShadowNodeRef;
typedef folly::fbvector<const ShadowNodeRef> ShadowNodeSet;
typedef std::shared_ptr<const ShadowNodeSet> 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);
};

}}

15 changes: 15 additions & 0 deletions ReactCommon/fabric/ShadowNode.cpp
Original file line number Diff line number Diff line change
@@ -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) {}

}}
22 changes: 22 additions & 0 deletions ReactCommon/fabric/ShadowNode.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Copyright 2004-present Facebook. All Rights Reserved.

#pragma once

#include <folly/dynamic.h>
#include <memory>

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);
};

}}

0 comments on commit 0ee0317

Please sign in to comment.