Skip to content

Commit

Permalink
Fabric: ContextContainer was moved to utils module
Browse files Browse the repository at this point in the history
Summary: That allows avoiding circular deps and unnecessary deps on uimanager module.

Reviewed By: PeteTheHeat

Differential Revision: D14917227

fbshipit-source-id: fe7962ee528aa659d8bd23e3e46627722551d995
  • Loading branch information
shergin authored and facebook-github-bot committed Apr 12, 2019
1 parent 108c419 commit 792585f
Show file tree
Hide file tree
Showing 17 changed files with 22 additions and 23 deletions.
2 changes: 1 addition & 1 deletion RNTester/ComponentRegistry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#include <react/config/ReactNativeConfig.h>
#include <react/uimanager/ComponentDescriptorFactory.h>
#include <react/uimanager/ComponentDescriptorRegistry.h>
#include <react/uimanager/ContextContainer.h>
#include <react/utils/ContextContainer.h>

namespace facebook {
namespace react {
Expand Down
2 changes: 1 addition & 1 deletion React/Fabric/RCTScheduler.mm
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@

#import <react/debug/SystraceSection.h>
#import <react/uimanager/ComponentDescriptorFactory.h>
#import <react/uimanager/ContextContainer.h>
#import <react/uimanager/Scheduler.h>
#import <react/uimanager/SchedulerDelegate.h>
#import <react/utils/ContextContainer.h>

#import <React/RCTFollyConvert.h>

Expand Down
2 changes: 1 addition & 1 deletion React/Fabric/RCTSurfacePresenter.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#import <React/RCTComponentViewFactory.h>
#import <React/RCTPrimitives.h>
#import <react/config/ReactNativeConfig.h>
#import <react/uimanager/ContextContainer.h>
#import <react/utils/ContextContainer.h>

NS_ASSUME_NONNULL_BEGIN

Expand Down
2 changes: 1 addition & 1 deletion React/Fabric/RCTSurfacePresenter.mm
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#import <react/core/LayoutConstraints.h>
#import <react/core/LayoutContext.h>
#import <react/imagemanager/ImageManager.h>
#import <react/uimanager/ContextContainer.h>
#import <react/utils/ContextContainer.h>

#import "MainRunLoopEventBeat.h"
#import "RuntimeEventBeat.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#include <react/core/EventBeat.h>
#include <react/core/EventEmitter.h>
#include <react/uimanager/ComponentDescriptorFactory.h>
#include <react/uimanager/ContextContainer.h>
#include <react/utils/ContextContainer.h>
#include <react/uimanager/Scheduler.h>
#include <react/uimanager/SchedulerDelegate.h>
#include <react/uimanager/primitives.h>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include <fb/fbjni.h>
#include <jsi/jsi.h>
#include <react/uimanager/ComponentDescriptorRegistry.h>
#include <react/uimanager/ContextContainer.h>
#include <react/utils/ContextContainer.h>
#include <react/uimanager/Scheduler.h>
#include <mutex>
#include <unordered_set>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include <react/components/image/ImageShadowNode.h>
#include <react/core/ConcreteComponentDescriptor.h>
#include <react/imagemanager/ImageManager.h>
#include <react/uimanager/ContextContainer.h>
#include <react/utils/ContextContainer.h>

namespace facebook {
namespace react {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

#include <react/core/ConcreteComponentDescriptor.h>
#include <react/core/LayoutConstraints.h>
#include <react/uimanager/ContextContainer.h>
#include <react/utils/ContextContainer.h>

namespace facebook {
namespace react {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

#include <react/core/ConcreteComponentDescriptor.h>
#include <react/core/LayoutConstraints.h>
#include <react/uimanager/ContextContainer.h>
#include <react/utils/ContextContainer.h>

namespace facebook {
namespace react {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
#include "ParagraphShadowNode.h"

#include <folly/container/EvictingCacheMap.h>
#include <react/config/ReactNativeConfig.h>
#include <react/core/ConcreteComponentDescriptor.h>
#include <react/textlayoutmanager/TextLayoutManager.h>
#include <react/uimanager/ContextContainer.h>
#include <react/config/ReactNativeConfig.h>
#include <react/utils/ContextContainer.h>

namespace facebook {
namespace react {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

#include <react/uimanager/ComponentDescriptorFactory.h>
#include <react/uimanager/ComponentDescriptorRegistry.h>
#include <react/uimanager/ContextContainer.h>
#include <react/utils/ContextContainer.h>

namespace facebook {
namespace react {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include <react/attributedstring/AttributedString.h>
#include <react/attributedstring/ParagraphAttributes.h>
#include <react/core/LayoutConstraints.h>
#include <react/uimanager/ContextContainer.h>
#include <react/utils/ContextContainer.h>

namespace facebook {
namespace react {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include <react/attributedstring/AttributedString.h>
#include <react/attributedstring/ParagraphAttributes.h>
#include <react/core/LayoutConstraints.h>
#include <react/uimanager/ContextContainer.h>
#include <react/utils/ContextContainer.h>

namespace facebook {
namespace react {
Expand Down
2 changes: 1 addition & 1 deletion ReactCommon/fabric/uimanager/ComponentDescriptorFactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

#include <react/core/ComponentDescriptor.h>
#include <react/core/EventDispatcher.h>
#include <react/uimanager/ContextContainer.h>
#include <react/utils/ContextContainer.h>

#include "ComponentDescriptorRegistry.h"

Expand Down
2 changes: 1 addition & 1 deletion ReactCommon/fabric/uimanager/Scheduler.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
#include <react/mounting/ShadowTreeRegistry.h>
#include <react/uimanager/ComponentDescriptorFactory.h>
#include <react/uimanager/ComponentDescriptorRegistry.h>
#include <react/uimanager/ContextContainer.h>
#include <react/uimanager/SchedulerDelegate.h>
#include <react/uimanager/UIManagerBinding.h>
#include <react/uimanager/UIManagerDelegate.h>
#include <react/uimanager/primitives.h>
#include <react/utils/ContextContainer.h>

namespace facebook {
namespace react {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ using namespace facebook::react;
#include <react/config/ReactNativeConfig.h>
#include <react/uimanager/ComponentDescriptorFactory.h>
#include <react/uimanager/ComponentDescriptorRegistry.h>
#include <react/uimanager/ContextContainer.h>
#include <react/utils/ContextContainer.h>

namespace facebook {
namespace react {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@
#include <memory>
#include <mutex>
#include <string>
#include <typeindex>
#include <typeinfo>
#include <unordered_map>
#include <utility>

#include <glog/logging.h>

Expand All @@ -28,6 +25,8 @@ using SharedContextContainer = std::shared_ptr<ContextContainer>;
*/
class ContextContainer final {
public:
using Shared = std::shared_ptr<ContextContainer>;

/*
* Registers an instance of the particular type `T` in the container
* using the provided `key`. Only one instance can be registered per key.
Expand All @@ -39,10 +38,10 @@ class ContextContainer final {
*`EmptyReactNativeConfig`.
*/
template <typename T>
void registerInstance(const T &instance, const std::string &key) {
void registerInstance(T const &instance, std::string const &key) {
std::lock_guard<std::mutex> lock(mutex_);

const auto res = instances_.insert({key, std::make_shared<T>(instance)});
auto res = instances_.insert({key, std::make_shared<T>(instance)});
if (res.second == false) {
LOG(FATAL) << "ContextContainer already had instance for key '" << key
<< "'";
Expand All @@ -54,7 +53,7 @@ class ContextContainer final {
* for `key`.
*/
template <typename T>
T getInstance(const std::string &key) const {
T getInstance(std::string const &key) const {
std::lock_guard<std::mutex> lock(mutex_);

return *std::static_pointer_cast<T>(instances_.at(key));
Expand Down

0 comments on commit 792585f

Please sign in to comment.