C++ - better => butter

Summary:
Renaming the `better` utilities to `butter`:
- to prevent claims that this library is superior to others - it really depends on use cases
- to indicate ease of use throughout the codebase, easily spread like butter

Changelog: [C++][Changed] Renaming C++ better util to butter, used by Fabric internals

Reviewed By: JoshuaGross

Differential Revision: D33242764

fbshipit-source-id: 26dc95d9597c61ce8e66708e44ed545e0fc5cff5
This commit is contained in:
Kevin Gozali
2021-12-20 22:23:18 -08:00
committed by Facebook GitHub Bot
parent b4dab1a537
commit fb39d45ed5
107 changed files with 370 additions and 370 deletions
@@ -8,7 +8,7 @@
#import <UIKit/UIKit.h>
#import <React/RCTBackedTextInputViewProtocol.h>
#import <better/optional.h>
#import <butter/optional.h>
#import <react/renderer/components/iostextinput/primitives.h>
NS_ASSUME_NONNULL_BEGIN
@@ -17,7 +17,7 @@ void RCTCopyBackedTextInput(
UIView<RCTBackedTextInputViewProtocol> *fromTextInput,
UIView<RCTBackedTextInputViewProtocol> *toTextInput);
UITextAutocorrectionType RCTUITextAutocorrectionTypeFromOptionalBool(facebook::better::optional<bool> autoCorrect);
UITextAutocorrectionType RCTUITextAutocorrectionTypeFromOptionalBool(facebook::butter::optional<bool> autoCorrect);
UITextAutocapitalizationType RCTUITextAutocapitalizationTypeFromAutocapitalizationType(
facebook::react::AutocapitalizationType autocapitalizationType);
@@ -25,7 +25,7 @@ UITextAutocapitalizationType RCTUITextAutocapitalizationTypeFromAutocapitalizati
UIKeyboardAppearance RCTUIKeyboardAppearanceFromKeyboardAppearance(
facebook::react::KeyboardAppearance keyboardAppearance);
UITextSpellCheckingType RCTUITextSpellCheckingTypeFromOptionalBool(facebook::better::optional<bool> spellCheck);
UITextSpellCheckingType RCTUITextSpellCheckingTypeFromOptionalBool(facebook::butter::optional<bool> spellCheck);
UITextFieldViewMode RCTUITextFieldViewModeFromTextInputAccessoryVisibilityMode(
facebook::react::TextInputAccessoryVisibilityMode mode);
@@ -51,7 +51,7 @@ void RCTCopyBackedTextInput(
[toTextInput setSelectedTextRange:fromTextInput.selectedTextRange notifyDelegate:NO];
}
UITextAutocorrectionType RCTUITextAutocorrectionTypeFromOptionalBool(facebook::better::optional<bool> autoCorrect)
UITextAutocorrectionType RCTUITextAutocorrectionTypeFromOptionalBool(facebook::butter::optional<bool> autoCorrect)
{
return autoCorrect.has_value() ? (*autoCorrect ? UITextAutocorrectionTypeYes : UITextAutocorrectionTypeNo)
: UITextAutocorrectionTypeDefault;
@@ -84,7 +84,7 @@ UIKeyboardAppearance RCTUIKeyboardAppearanceFromKeyboardAppearance(KeyboardAppea
}
}
UITextSpellCheckingType RCTUITextSpellCheckingTypeFromOptionalBool(facebook::better::optional<bool> spellCheck)
UITextSpellCheckingType RCTUITextSpellCheckingTypeFromOptionalBool(facebook::butter::optional<bool> spellCheck)
{
return spellCheck.has_value() ? (*spellCheck ? UITextSpellCheckingTypeYes : UITextSpellCheckingTypeNo)
: UITextSpellCheckingTypeDefault;
@@ -10,9 +10,9 @@
#import <React/RCTAssert.h>
#import <React/RCTConversions.h>
#import <better/map.h>
#import <better/mutex.h>
#import <better/set.h>
#import <butter/map.h>
#import <butter/mutex.h>
#import <butter/set.h>
#import <react/renderer/componentregistry/ComponentDescriptorProviderRegistry.h>
#import <react/renderer/componentregistry/componentNameByReactViewName.h>
@@ -56,10 +56,10 @@ static Class<RCTComponentViewProtocol> RCTComponentViewClassWithName(const char
}
@implementation RCTComponentViewFactory {
better::map<ComponentHandle, RCTComponentViewClassDescriptor> _componentViewClasses;
better::set<std::string> _registeredComponentsNames;
butter::map<ComponentHandle, RCTComponentViewClassDescriptor> _componentViewClasses;
butter::set<std::string> _registeredComponentsNames;
ComponentDescriptorProviderRegistry _providerRegistry;
better::shared_mutex _mutex;
butter::shared_mutex _mutex;
}
+ (RCTComponentViewFactory *)currentComponentViewFactory
@@ -149,7 +149,7 @@ static Class<RCTComponentViewProtocol> RCTComponentViewClassWithName(const char
- (void)registerComponentViewClass:(Class<RCTComponentViewProtocol>)componentViewClass
{
RCTAssert(componentViewClass, @"RCTComponentViewFactory: Provided `componentViewClass` is `nil`.");
std::unique_lock<better::shared_mutex> lock(_mutex);
std::unique_lock<butter::shared_mutex> lock(_mutex);
auto componentDescriptorProvider = [componentViewClass componentDescriptorProvider];
_componentViewClasses[componentDescriptorProvider.handle] =
@@ -171,7 +171,7 @@ static Class<RCTComponentViewProtocol> RCTComponentViewClassWithName(const char
- (RCTComponentViewDescriptor)createComponentViewWithComponentHandle:(facebook::react::ComponentHandle)componentHandle
{
RCTAssertMainQueue();
std::shared_lock<better::shared_mutex> lock(_mutex);
std::shared_lock<butter::shared_mutex> lock(_mutex);
auto iterator = _componentViewClasses.find(componentHandle);
RCTAssert(
@@ -192,7 +192,7 @@ static Class<RCTComponentViewProtocol> RCTComponentViewClassWithName(const char
- (facebook::react::ComponentDescriptorRegistry::Shared)createComponentDescriptorRegistryWithParameters:
(facebook::react::ComponentDescriptorParameters)parameters
{
std::shared_lock<better::shared_mutex> lock(_mutex);
std::shared_lock<butter::shared_mutex> lock(_mutex);
return _providerRegistry.createComponentDescriptorRegistry(parameters);
}
@@ -15,15 +15,15 @@
#import "RCTParagraphComponentView.h"
#import "RCTViewComponentView.h"
#import <better/map.h>
#import <butter/map.h>
using namespace facebook::react;
const NSInteger RCTComponentViewRegistryRecyclePoolMaxSize = 1024;
@implementation RCTComponentViewRegistry {
better::map<Tag, RCTComponentViewDescriptor> _registry;
better::map<ComponentHandle, std::vector<RCTComponentViewDescriptor>> _recyclePool;
butter::map<Tag, RCTComponentViewDescriptor> _registry;
butter::map<ComponentHandle, std::vector<RCTComponentViewDescriptor>> _recyclePool;
}
- (instancetype)init
+1 -1
View File
@@ -7,7 +7,7 @@
#import "RCTMountingManager.h"
#import <better/map.h>
#import <butter/map.h>
#import <React/RCTAssert.h>
#import <React/RCTComponent.h>
@@ -8,8 +8,8 @@
#import <React/RCTComponentViewDescriptor.h>
#import "RCTMountingTransactionObserverCoordinator.h"
#import <better/map.h>
#import <better/set.h>
#import <butter/map.h>
#import <butter/set.h>
#import <react/renderer/mounting/MountingTransactionMetadata.h>
@@ -36,8 +36,8 @@ class RCTMountingTransactionObserverCoordinator final {
facebook::react::MountingTransactionMetadata const &metadata) const;
private:
facebook::better::map<
facebook::butter::map<
facebook::react::SurfaceId,
facebook::better::set<RCTComponentViewDescriptor>>
facebook::butter::set<RCTComponentViewDescriptor>>
registry_;
};
+5 -5
View File
@@ -79,7 +79,7 @@ static BackgroundExecutor RCTGetBackgroundExecutor()
ContextContainer::Shared _contextContainer; // Protected by `_schedulerLifeCycleMutex`.
RuntimeExecutor _runtimeExecutor; // Protected by `_schedulerLifeCycleMutex`.
better::shared_mutex _observerListMutex;
butter::shared_mutex _observerListMutex;
NSMutableArray<id<RCTSurfacePresenterObserver>> *_observers;
}
@@ -365,13 +365,13 @@ static BackgroundExecutor RCTGetBackgroundExecutor()
- (void)addObserver:(id<RCTSurfacePresenterObserver>)observer
{
std::unique_lock<better::shared_mutex> lock(_observerListMutex);
std::unique_lock<butter::shared_mutex> lock(_observerListMutex);
[self->_observers addObject:observer];
}
- (void)removeObserver:(id<RCTSurfacePresenterObserver>)observer
{
std::unique_lock<better::shared_mutex> lock(_observerListMutex);
std::unique_lock<butter::shared_mutex> lock(_observerListMutex);
[self->_observers removeObject:observer];
}
@@ -381,7 +381,7 @@ static BackgroundExecutor RCTGetBackgroundExecutor()
{
RCTAssertMainQueue();
std::shared_lock<better::shared_mutex> lock(_observerListMutex);
std::shared_lock<butter::shared_mutex> lock(_observerListMutex);
for (id<RCTSurfacePresenterObserver> observer in _observers) {
if ([observer respondsToSelector:@selector(willMountComponentsWithRootTag:)]) {
[observer willMountComponentsWithRootTag:rootTag];
@@ -393,7 +393,7 @@ static BackgroundExecutor RCTGetBackgroundExecutor()
{
RCTAssertMainQueue();
std::shared_lock<better::shared_mutex> lock(_observerListMutex);
std::shared_lock<butter::shared_mutex> lock(_observerListMutex);
for (id<RCTSurfacePresenterObserver> observer in _observers) {
if ([observer respondsToSelector:@selector(didMountComponentsWithRootTag:)]) {
[observer didMountComponentsWithRootTag:rootTag];
+6 -6
View File
@@ -7,7 +7,7 @@
#import "RCTSurfaceRegistry.h"
#import <better/mutex.h>
#import <butter/mutex.h>
#import <mutex>
#import <shared_mutex>
@@ -16,7 +16,7 @@
using namespace facebook;
@implementation RCTSurfaceRegistry {
better::shared_mutex _mutex;
butter::shared_mutex _mutex;
NSMapTable<id, RCTFabricSurface *> *_registry;
}
@@ -32,13 +32,13 @@ using namespace facebook;
- (void)enumerateWithBlock:(RCTSurfaceEnumeratorBlock)block
{
std::shared_lock<better::shared_mutex> lock(_mutex);
std::shared_lock<butter::shared_mutex> lock(_mutex);
block([_registry objectEnumerator]);
}
- (void)registerSurface:(RCTFabricSurface *)surface
{
std::unique_lock<better::shared_mutex> lock(_mutex);
std::unique_lock<butter::shared_mutex> lock(_mutex);
ReactTag rootTag = surface.rootViewTag.integerValue;
[_registry setObject:surface forKey:(__bridge id)(void *)rootTag];
@@ -46,7 +46,7 @@ using namespace facebook;
- (void)unregisterSurface:(RCTFabricSurface *)surface
{
std::unique_lock<better::shared_mutex> lock(_mutex);
std::unique_lock<butter::shared_mutex> lock(_mutex);
ReactTag rootTag = surface.rootViewTag.integerValue;
[_registry removeObjectForKey:(__bridge id)(void *)rootTag];
@@ -54,7 +54,7 @@ using namespace facebook;
- (RCTFabricSurface *)surfaceForRootTag:(ReactTag)rootTag
{
std::shared_lock<better::shared_mutex> lock(_mutex);
std::shared_lock<butter::shared_mutex> lock(_mutex);
return [_registry objectForKey:(__bridge id)(void *)rootTag];
}
+1 -1
View File
@@ -34,7 +34,7 @@ using namespace facebook::react;
// `SurfaceHandler` is a thread-safe object, so we don't need additional synchronization.
// Objective-C++ classes cannot have instance variables without default constructors,
// hence we wrap a value into `optional` to workaround it.
better::optional<SurfaceHandler> _surfaceHandler;
butter::optional<SurfaceHandler> _surfaceHandler;
// Protects Surface's start and stop processes.
// Even though SurfaceHandler is tread-safe, it will crash if we try to stop a surface that is not running.
@@ -12,7 +12,7 @@ LOCAL_MODULE := fabricjni
LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp)
LOCAL_SHARED_LIBRARIES := \
libbetter \
libbutter \
libfb \
libfbjni \
libfolly_futures \
@@ -46,7 +46,7 @@ jni::local_ref<Binding::jhybriddata> Binding::initHybrid(
// Thread-safe getter
std::shared_ptr<Scheduler> Binding::getScheduler() {
std::shared_lock<better::shared_mutex> lock(installMutex_);
std::shared_lock<butter::shared_mutex> lock(installMutex_);
return scheduler_;
}
@@ -128,7 +128,7 @@ void Binding::startSurface(
{
SystraceSection s2("FabricUIManagerBinding::startSurface::surfaceId::lock");
std::unique_lock<better::shared_mutex> lock(surfaceHandlerRegistryMutex_);
std::unique_lock<butter::shared_mutex> lock(surfaceHandlerRegistryMutex_);
SystraceSection s3("FabricUIManagerBinding::startSurface::surfaceId");
surfaceHandlerRegistry_.emplace(surfaceId, std::move(surfaceHandler));
}
@@ -191,7 +191,7 @@ void Binding::startSurfaceWithConstraints(
{
SystraceSection s2(
"FabricUIManagerBinding::startSurfaceWithConstraints::surfaceId::lock");
std::unique_lock<better::shared_mutex> lock(surfaceHandlerRegistryMutex_);
std::unique_lock<butter::shared_mutex> lock(surfaceHandlerRegistryMutex_);
SystraceSection s3(
"FabricUIManagerBinding::startSurfaceWithConstraints::surfaceId");
surfaceHandlerRegistry_.emplace(surfaceId, std::move(surfaceHandler));
@@ -228,7 +228,7 @@ void Binding::stopSurface(jint surfaceId) {
}
{
std::unique_lock<better::shared_mutex> lock(surfaceHandlerRegistryMutex_);
std::unique_lock<butter::shared_mutex> lock(surfaceHandlerRegistryMutex_);
auto iterator = surfaceHandlerRegistry_.find(surfaceId);
@@ -289,7 +289,7 @@ void Binding::setConstraints(
isRTL ? LayoutDirection::RightToLeft : LayoutDirection::LeftToRight;
{
std::shared_lock<better::shared_mutex> lock(surfaceHandlerRegistryMutex_);
std::shared_lock<butter::shared_mutex> lock(surfaceHandlerRegistryMutex_);
auto iterator = surfaceHandlerRegistry_.find(surfaceId);
@@ -334,7 +334,7 @@ void Binding::installFabricUIManager(
// Use std::lock and std::adopt_lock to prevent deadlocks by locking mutexes
// at the same time
std::unique_lock<better::shared_mutex> lock(installMutex_);
std::unique_lock<butter::shared_mutex> lock(installMutex_);
auto globalJavaUiManager = make_global(javaUIManager);
mountingManager_ =
@@ -434,7 +434,7 @@ void Binding::uninstallFabricUIManager() {
<< this << ").";
}
std::unique_lock<better::shared_mutex> lock(installMutex_);
std::unique_lock<butter::shared_mutex> lock(installMutex_);
animationDriver_ = nullptr;
scheduler_ = nullptr;
mountingManager_ = nullptr;
@@ -443,7 +443,7 @@ void Binding::uninstallFabricUIManager() {
std::shared_ptr<FabricMountingManager> Binding::verifyMountingManager(
std::string const &hint) {
std::shared_lock<better::shared_mutex> lock(installMutex_);
std::shared_lock<butter::shared_mutex> lock(installMutex_);
if (!mountingManager_) {
LOG(ERROR) << hint << " mounting manager disappeared.";
}
@@ -129,7 +129,7 @@ class Binding : public jni::HybridClass<Binding>,
void uninstallFabricUIManager();
// Private member variables
better::shared_mutex installMutex_;
butter::shared_mutex installMutex_;
std::shared_ptr<FabricMountingManager> mountingManager_;
std::shared_ptr<Scheduler> scheduler_;
@@ -145,8 +145,8 @@ class Binding : public jni::HybridClass<Binding>,
std::unique_ptr<JBackgroundExecutor> backgroundExecutor_;
better::map<SurfaceId, SurfaceHandler> surfaceHandlerRegistry_{};
better::shared_mutex
butter::map<SurfaceId, SurfaceHandler> surfaceHandlerRegistry_{};
butter::shared_mutex
surfaceHandlerRegistryMutex_; // Protects `surfaceHandlerRegistry_`.
float pointScaleFactor_ = 1;
@@ -21,7 +21,7 @@ void SurfaceHandlerBinding::setDisplayMode(jint mode) {
}
void SurfaceHandlerBinding::start() {
std::unique_lock<better::shared_mutex> lock(lifecycleMutex_);
std::unique_lock<butter::shared_mutex> lock(lifecycleMutex_);
if (surfaceHandler_.getStatus() != SurfaceHandler::Status::Running) {
surfaceHandler_.start();
@@ -29,7 +29,7 @@ void SurfaceHandlerBinding::start() {
}
void SurfaceHandlerBinding::stop() {
std::unique_lock<better::shared_mutex> lock(lifecycleMutex_);
std::unique_lock<butter::shared_mutex> lock(lifecycleMutex_);
if (surfaceHandler_.getStatus() == SurfaceHandler::Status::Running) {
surfaceHandler_.stop();
@@ -50,7 +50,7 @@ class SurfaceHandlerBinding : public jni::HybridClass<SurfaceHandlerBinding> {
SurfaceHandler const &getSurfaceHandler();
private:
mutable better::shared_mutex lifecycleMutex_;
mutable butter::shared_mutex lifecycleMutex_;
const SurfaceHandler surfaceHandler_;
jni::alias_ref<SurfaceHandlerBinding::jhybriddata> jhybridobject_;
@@ -130,7 +130,7 @@ include $(BUILD_SHARED_LIBRARY)
# Whenever you encounter an include <dir>/<module-dir>/Android.mk, you
# tell andorid-ndk to compile the module in <dir>/<module-dir> according
# to the specification inside <dir>/<module-dir>/Android.mk.
$(call import-module,better)
$(call import-module,butter)
$(call import-module,folly)
$(call import-module,fb)
$(call import-module,fbjni)
+4 -4
View File
@@ -61,12 +61,12 @@ Pod::Spec.new do |s|
ss.pod_target_xcconfig = { "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)/ReactCommon\" \"$(PODS_ROOT)/RCT-Folly\"" }
end
s.subspec "better" do |ss|
s.subspec "butter" do |ss|
ss.dependency folly_dep_name, folly_version
ss.compiler_flags = folly_compiler_flags
ss.source_files = "better/**/*.{m,mm,cpp,h}"
ss.exclude_files = "better/tests"
ss.header_dir = "better"
ss.source_files = "butter/**/*.{m,mm,cpp,h}"
ss.exclude_files = "butter/tests"
ss.header_dir = "butter"
ss.pod_target_xcconfig = { "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)/ReactCommon\" \"$(PODS_ROOT)/RCT-Folly\"" }
end
@@ -7,7 +7,7 @@ LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := better
LOCAL_MODULE := butter
LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp)
@@ -15,7 +15,7 @@ LOCAL_C_INCLUDES := $(LOCAL_PATH)/
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/
LOCAL_CFLAGS := \
-DLOG_TAG=\"Better\"
-DLOG_TAG=\"Butter\"
LOCAL_CFLAGS += -fexceptions -frtti -std=c++17 -Wall
@@ -13,7 +13,7 @@ load(
APPLE_COMPILER_FLAGS = get_apple_compiler_flags()
rn_xplat_cxx_library(
name = "better",
name = "butter",
srcs = glob(
["**/*.cpp"],
exclude = glob(["tests/**/*.cpp"]),
@@ -27,7 +27,7 @@ rn_xplat_cxx_library(
[
("", "*.h"),
],
prefix = "better",
prefix = "butter",
),
fbobjc_compiler_flags = APPLE_COMPILER_FLAGS,
fbobjc_preprocessor_flags = get_preprocessor_flags_for_build_mode() + get_apple_inspector_flags(),
@@ -8,20 +8,20 @@
#pragma once
namespace facebook {
namespace better {
namespace butter {
/*
* `Better` is a trivial collection of basic tools borrowed from other low-level
* `Butter` is a trivial collection of basic tools borrowed from other low-level
* general purpose libraries (like Folly, Abseil or Boost). The main goals of
* Better:
* Butter:
* - Make the codebase more portable;
* - Make the dependency list explicit (by decoupling it as a dependency list of
* Better);
* Butter);
* - Make relying on modern C++ patterns and tools in code simple and easy.
* - Make executing experiments with different dependencies easier.
*
* What should be part of Better and what should not? Should I add some piece of
* functionality in the Better? Here is a quick checklist.
* What should be part of Butter and what should not? Should I add some piece of
* functionality in the Butter? Here is a quick checklist.
*
* If one of the following is true, yes, go for it:
* - If some feature is already in some future C++ standard (possibly in draft
@@ -55,8 +55,8 @@ namespace better {
* introspections mechanisms.
*/
#ifndef DEBUG
#define BETTER_USE_FOLLY_CONTAINERS
#define BUTTER_USE_FOLLY_CONTAINERS
#endif
} // namespace better
} // namespace butter
} // namespace facebook
@@ -7,9 +7,9 @@
#pragma once
#include <better/better.h>
#include <butter/butter.h>
#ifdef BETTER_USE_FOLLY_CONTAINERS
#ifdef BUTTER_USE_FOLLY_CONTAINERS
#include <folly/container/F14Map.h>
@@ -20,16 +20,16 @@
#endif
namespace facebook {
namespace better {
namespace butter {
/*
* Note: In Better, `map` aliases to `unorderd_map` because everyone agrees that
* Note: In Butter, `map` aliases to `unorderd_map` because everyone agrees that
* an *ordered* map is nonsense and was a huge mistake for standardization. If
* you need an *ordered* map, feel free to introduce that as
* `better::ordered_map`.
* `butter::ordered_map`.
*/
#ifdef BETTER_USE_FOLLY_CONTAINERS
#ifdef BUTTER_USE_FOLLY_CONTAINERS
template <typename... Ts>
using map = folly::F14FastMap<Ts...>;
@@ -41,5 +41,5 @@ using map = std::unordered_map<Ts...>;
#endif
} // namespace better
} // namespace butter
} // namespace facebook
@@ -12,9 +12,9 @@
#include <shared_mutex>
namespace facebook {
namespace better {
namespace butter {
using shared_mutex = folly::SharedMutex;
} // namespace better
} // namespace butter
} // namespace facebook
@@ -7,9 +7,9 @@
#pragma once
#include <better/better.h>
#include <butter/butter.h>
#if defined(BETTER_USE_FOLLY_CONTAINERS) || __cplusplus < 202000L
#if defined(BUTTER_USE_FOLLY_CONTAINERS) || __cplusplus < 202000L
#include <folly/Optional.h>
@@ -20,9 +20,9 @@
#endif
namespace facebook {
namespace better {
namespace butter {
#if defined(BETTER_USE_FOLLY_CONTAINERS) || __cplusplus < 202000L
#if defined(BUTTER_USE_FOLLY_CONTAINERS) || __cplusplus < 202000L
template <typename Value>
using optional = folly::Optional<Value>;
@@ -34,5 +34,5 @@ using optional = std::optional<Value>;
#endif
} // namespace better
} // namespace butter
} // namespace facebook
@@ -7,9 +7,9 @@
#pragma once
#include <better/better.h>
#include <butter/butter.h>
#ifdef BETTER_USE_FOLLY_CONTAINERS
#ifdef BUTTER_USE_FOLLY_CONTAINERS
#include <folly/container/F14Set.h>
@@ -20,9 +20,9 @@
#endif
namespace facebook {
namespace better {
namespace butter {
#ifdef BETTER_USE_FOLLY_CONTAINERS
#ifdef BUTTER_USE_FOLLY_CONTAINERS
template <typename... Ts>
using set = folly::F14FastSet<Ts...>;
@@ -34,5 +34,5 @@ using set = std::unordered_set<Ts...>;
#endif
} // namespace better
} // namespace butter
} // namespace facebook
@@ -7,10 +7,10 @@
#pragma once
#include <better/better.h>
#include <butter/butter.h>
// `folly::small_vector` is broken on some versions of Android.
#if defined(BETTER_USE_FOLLY_CONTAINERS) && !defined(ANDROID)
#if defined(BUTTER_USE_FOLLY_CONTAINERS) && !defined(ANDROID)
#include <folly/small_vector.h>
@@ -21,9 +21,9 @@
#endif
namespace facebook {
namespace better {
namespace butter {
#if defined(BETTER_USE_FOLLY_CONTAINERS) && !defined(ANDROID)
#if defined(BUTTER_USE_FOLLY_CONTAINERS) && !defined(ANDROID)
template <typename T, std::size_t Size, typename... Ts>
using small_vector = folly::small_vector<T, Size, Ts...>;
@@ -35,5 +35,5 @@ using small_vector = std::vector<T, Ts...>;
#endif
} // namespace better
} // namespace butter
} // namespace facebook
@@ -172,7 +172,7 @@ bool LayoutAnimationKeyFrameManager::shouldOverridePullTransaction() const {
return shouldAnimateFrame();
}
better::optional<MountingTransaction>
butter::optional<MountingTransaction>
LayoutAnimationKeyFrameManager::pullTransaction(
SurfaceId surfaceId,
MountingTransaction::Number transactionNumber,
@@ -250,7 +250,7 @@ LayoutAnimationKeyFrameManager::pullTransaction(
surfaceId, mutations, conflictingAnimations);
// Are we animating this list of mutations?
better::optional<LayoutAnimation> currentAnimation{};
butter::optional<LayoutAnimation> currentAnimation{};
{
std::lock_guard<std::mutex> lock(currentAnimationMutex_);
if (currentAnimation_) {
@@ -271,9 +271,9 @@ LayoutAnimationKeyFrameManager::pullTransaction(
// TODO: to prevent this step we could tag Remove/Insert mutations as
// being moves on the Differ level, since we know that there? We could use
// TinyMap here, but it's not exposed by Differentiator (yet).
better::set<Tag> insertedTags;
better::set<Tag> deletedTags;
better::set<Tag> reparentedTags; // tags that are deleted and recreated
butter::set<Tag> insertedTags;
butter::set<Tag> deletedTags;
butter::set<Tag> reparentedTags; // tags that are deleted and recreated
std::unordered_map<Tag, ShadowViewMutation> movedTags;
for (const auto &mutation : mutations) {
if (mutation.type == ShadowViewMutation::Type::Insert) {
@@ -320,7 +320,7 @@ LayoutAnimationKeyFrameManager::pullTransaction(
continue;
}
better::optional<ShadowViewMutation> executeMutationImmediately{};
butter::optional<ShadowViewMutation> executeMutationImmediately{};
bool isRemoveReinserted =
mutation.type == ShadowViewMutation::Type::Remove &&
@@ -1063,7 +1063,7 @@ LayoutAnimationKeyFrameManager::pullTransaction(
void LayoutAnimationKeyFrameManager::uiManagerDidConfigureNextLayoutAnimation(
LayoutAnimation layoutAnimation) const {
currentAnimation_ = better::optional<LayoutAnimation>{layoutAnimation};
currentAnimation_ = butter::optional<LayoutAnimation>{layoutAnimation};
}
void LayoutAnimationKeyFrameManager::setLayoutAnimationStatusDelegate(
@@ -1616,7 +1616,7 @@ void LayoutAnimationKeyFrameManager::deleteAnimationsForStoppedSurfaces()
// Execute stopSurface on any ongoing animations
if (inflightAnimationsExistInitially) {
better::set<SurfaceId> surfaceIdsToStop{};
butter::set<SurfaceId> surfaceIdsToStop{};
{
std::lock_guard<std::mutex> lock(surfaceIdsToStopMutex_);
surfaceIdsToStop = surfaceIdsToStop_;
@@ -8,8 +8,8 @@
#pragma once
#include <ReactCommon/RuntimeExecutor.h>
#include <better/optional.h>
#include <better/set.h>
#include <butter/optional.h>
#include <butter/set.h>
#include <react/renderer/animations/LayoutAnimationCallbackWrapper.h>
#include <react/renderer/animations/primitives.h>
#include <react/renderer/core/RawValue.h>
@@ -67,7 +67,7 @@ class LayoutAnimationKeyFrameManager : public UIManagerAnimationDelegate,
// This is used to "hijack" the diffing process to figure out which mutations
// should be animated. The mutations returned by this function will be
// executed immediately.
better::optional<MountingTransaction> pullTransaction(
butter::optional<MountingTransaction> pullTransaction(
SurfaceId surfaceId,
MountingTransaction::Number number,
TransactionTelemetry const &telemetry,
@@ -95,7 +95,7 @@ class LayoutAnimationKeyFrameManager : public UIManagerAnimationDelegate,
protected:
SharedComponentDescriptorRegistry componentDescriptorRegistry_;
mutable better::optional<LayoutAnimation> currentAnimation_{};
mutable butter::optional<LayoutAnimation> currentAnimation_{};
mutable std::mutex currentAnimationMutex_;
/**
@@ -148,7 +148,7 @@ class LayoutAnimationKeyFrameManager : public UIManagerAnimationDelegate,
mutable std::mutex layoutAnimationStatusDelegateMutex_;
mutable LayoutAnimationStatusDelegate *layoutAnimationStatusDelegate_{};
mutable std::mutex surfaceIdsToStopMutex_;
mutable better::set<SurfaceId> surfaceIdsToStop_{};
mutable butter::set<SurfaceId> surfaceIdsToStop_{};
bool skipInvalidatedKeyFrames_{false};
/*
@@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/
#include <better/optional.h>
#include <butter/optional.h>
#include <react/renderer/animations/primitives.h>
#include <glog/logging.h>
@@ -13,7 +13,7 @@
namespace facebook {
namespace react {
static inline better::optional<AnimationType> parseAnimationType(
static inline butter::optional<AnimationType> parseAnimationType(
std::string param) {
if (param == "spring") {
return AnimationType::Spring;
@@ -38,7 +38,7 @@ static inline better::optional<AnimationType> parseAnimationType(
return {};
}
static inline better::optional<AnimationProperty> parseAnimationProperty(
static inline butter::optional<AnimationProperty> parseAnimationProperty(
std::string param) {
if (param == "opacity") {
return AnimationProperty::Opacity;
@@ -57,7 +57,7 @@ static inline better::optional<AnimationProperty> parseAnimationProperty(
return {};
}
static inline better::optional<AnimationConfig> parseAnimationConfig(
static inline butter::optional<AnimationConfig> parseAnimationConfig(
folly::dynamic const &config,
double defaultDuration,
bool parsePropertyType) {
@@ -163,7 +163,7 @@ static inline better::optional<AnimationConfig> parseAnimationConfig(
}
}
return better::optional<AnimationConfig>(AnimationConfig{
return butter::optional<AnimationConfig>(AnimationConfig{
*animationType,
animationProperty,
duration,
@@ -173,7 +173,7 @@ static inline better::optional<AnimationConfig> parseAnimationConfig(
}
// Parse animation config from JS
static inline better::optional<LayoutAnimationConfig>
static inline butter::optional<LayoutAnimationConfig>
parseLayoutAnimationConfig(folly::dynamic const &config) {
if (config.empty() || !config.isObject()) {
return {};
@@ -187,17 +187,17 @@ parseLayoutAnimationConfig(folly::dynamic const &config) {
const auto createConfigIt = config.find("create");
const auto createConfig = createConfigIt == config.items().end()
? better::optional<AnimationConfig>(AnimationConfig{})
? butter::optional<AnimationConfig>(AnimationConfig{})
: parseAnimationConfig(createConfigIt->second, duration, true);
const auto updateConfigIt = config.find("update");
const auto updateConfig = updateConfigIt == config.items().end()
? better::optional<AnimationConfig>(AnimationConfig{})
? butter::optional<AnimationConfig>(AnimationConfig{})
: parseAnimationConfig(updateConfigIt->second, duration, false);
const auto deleteConfigIt = config.find("delete");
const auto deleteConfig = deleteConfigIt == config.items().end()
? better::optional<AnimationConfig>(AnimationConfig{})
? butter::optional<AnimationConfig>(AnimationConfig{})
: parseAnimationConfig(deleteConfigIt->second, duration, true);
if (!createConfig || !updateConfig || !deleteConfig) {
@@ -23,7 +23,7 @@ LOCAL_STATIC_LIBRARIES :=
LOCAL_SHARED_LIBRARIES := \
glog \
libbetter \
libbutter \
libfolly_futures \
libfolly_json \
libglog_init \
@@ -38,7 +38,7 @@ LOCAL_SHARED_LIBRARIES := \
include $(BUILD_SHARED_LIBRARY)
$(call import-module,better)
$(call import-module,butter)
$(call import-module,glog)
$(call import-module,folly)
$(call import-module,fbgloginit)
@@ -56,7 +56,7 @@ class AttributedString : public Sealable, public DebugStringConvertible {
int length{0};
};
using Fragments = better::small_vector<Fragment, 1>;
using Fragments = butter::small_vector<Fragment, 1>;
/*
* Appends and prepends a `fragment` to the string.
@@ -10,7 +10,7 @@
#include <functional>
#include <limits>
#include <better/optional.h>
#include <butter/optional.h>
#include <folly/Hash.h>
#include <react/renderer/attributedstring/primitives.h>
#include <react/renderer/core/LayoutPrimitives.h>
@@ -46,38 +46,38 @@ class TextAttributes : public DebugStringConvertible {
std::string fontFamily{""};
Float fontSize{std::numeric_limits<Float>::quiet_NaN()};
Float fontSizeMultiplier{std::numeric_limits<Float>::quiet_NaN()};
better::optional<FontWeight> fontWeight{};
better::optional<FontStyle> fontStyle{};
better::optional<FontVariant> fontVariant{};
better::optional<bool> allowFontScaling{};
butter::optional<FontWeight> fontWeight{};
butter::optional<FontStyle> fontStyle{};
butter::optional<FontVariant> fontVariant{};
butter::optional<bool> allowFontScaling{};
Float letterSpacing{std::numeric_limits<Float>::quiet_NaN()};
better::optional<TextTransform> textTransform{};
butter::optional<TextTransform> textTransform{};
// Paragraph Styles
Float lineHeight{std::numeric_limits<Float>::quiet_NaN()};
better::optional<TextAlignment> alignment{};
better::optional<WritingDirection> baseWritingDirection{};
butter::optional<TextAlignment> alignment{};
butter::optional<WritingDirection> baseWritingDirection{};
// Decoration
SharedColor textDecorationColor{};
better::optional<TextDecorationLineType> textDecorationLineType{};
better::optional<TextDecorationStyle> textDecorationStyle{};
butter::optional<TextDecorationLineType> textDecorationLineType{};
butter::optional<TextDecorationStyle> textDecorationStyle{};
// Shadow
// TODO: Use `Point` type instead of `Size` for `textShadowOffset` attribute.
better::optional<Size> textShadowOffset{};
butter::optional<Size> textShadowOffset{};
Float textShadowRadius{std::numeric_limits<Float>::quiet_NaN()};
SharedColor textShadowColor{};
// Special
better::optional<bool> isHighlighted{};
butter::optional<bool> isHighlighted{};
// TODO T59221129: document where this value comes from and how it is set.
// It's not clear if this is being used properly, or if it's being set at all.
// Currently, it is intentionally *not* being set as part of BaseTextProps
// construction.
better::optional<LayoutDirection> layoutDirection{};
better::optional<AccessibilityRole> accessibilityRole{};
butter::optional<LayoutDirection> layoutDirection{};
butter::optional<AccessibilityRole> accessibilityRole{};
#pragma mark - Operations
@@ -768,7 +768,7 @@ inline void fromRawValue(
const PropsParserContext &context,
RawValue const &value,
AttributedString::Range &result) {
auto map = (better::map<std::string, int>)value;
auto map = (butter::map<std::string, int>)value;
auto start = map.find("start");
if (start != map.end()) {
@@ -12,7 +12,7 @@ namespace react {
void ComponentDescriptorProviderRegistry::add(
ComponentDescriptorProvider provider) const {
std::unique_lock<better::shared_mutex> lock(mutex_);
std::unique_lock<butter::shared_mutex> lock(mutex_);
/*
// TODO: T57583139
@@ -45,7 +45,7 @@ void ComponentDescriptorProviderRegistry::add(
void ComponentDescriptorProviderRegistry::setComponentDescriptorProviderRequest(
ComponentDescriptorProviderRequest componentDescriptorProviderRequest)
const {
std::shared_lock<better::shared_mutex> lock(mutex_);
std::shared_lock<butter::shared_mutex> lock(mutex_);
componentDescriptorProviderRequest_ = componentDescriptorProviderRequest;
}
@@ -54,7 +54,7 @@ void ComponentDescriptorProviderRegistry::request(
ComponentDescriptorProviderRequest componentDescriptorProviderRequest;
{
std::shared_lock<better::shared_mutex> lock(mutex_);
std::shared_lock<butter::shared_mutex> lock(mutex_);
componentDescriptorProviderRequest = componentDescriptorProviderRequest_;
}
@@ -66,7 +66,7 @@ void ComponentDescriptorProviderRegistry::request(
ComponentDescriptorRegistry::Shared
ComponentDescriptorProviderRegistry::createComponentDescriptorRegistry(
ComponentDescriptorParameters const &parameters) const {
std::shared_lock<better::shared_mutex> lock(mutex_);
std::shared_lock<butter::shared_mutex> lock(mutex_);
auto registry = std::make_shared<ComponentDescriptorRegistry const>(
parameters, *this, parameters.contextContainer);
@@ -7,7 +7,7 @@
#pragma once
#include <better/mutex.h>
#include <butter/mutex.h>
#include <react/renderer/componentregistry/ComponentDescriptorProvider.h>
#include <react/renderer/componentregistry/ComponentDescriptorRegistry.h>
@@ -59,10 +59,10 @@ class ComponentDescriptorProviderRegistry final {
void request(ComponentName componentName) const;
mutable better::shared_mutex mutex_;
mutable butter::shared_mutex mutex_;
mutable std::vector<std::weak_ptr<ComponentDescriptorRegistry const>>
componentDescriptorRegistries_;
mutable better::map<ComponentHandle, ComponentDescriptorProvider const>
mutable butter::map<ComponentHandle, ComponentDescriptorProvider const>
componentDescriptorProviders_;
mutable ComponentDescriptorProviderRequest
componentDescriptorProviderRequest_;
@@ -27,7 +27,7 @@ ComponentDescriptorRegistry::ComponentDescriptorRegistry(
void ComponentDescriptorRegistry::add(
ComponentDescriptorProvider componentDescriptorProvider) const {
std::unique_lock<better::shared_mutex> lock(mutex_);
std::unique_lock<butter::shared_mutex> lock(mutex_);
auto componentDescriptor = componentDescriptorProvider.constructor(
{parameters_.eventDispatcher,
@@ -58,7 +58,7 @@ void ComponentDescriptorRegistry::registerComponentDescriptor(
ComponentDescriptor const &ComponentDescriptorRegistry::at(
std::string const &componentName) const {
std::shared_lock<better::shared_mutex> lock(mutex_);
std::shared_lock<butter::shared_mutex> lock(mutex_);
auto unifiedComponentName = componentNameByReactViewName(componentName);
@@ -95,7 +95,7 @@ ComponentDescriptor const &ComponentDescriptorRegistry::at(
ComponentDescriptor const *ComponentDescriptorRegistry::
findComponentDescriptorByHandle_DO_NOT_USE_THIS_IS_BROKEN(
ComponentHandle componentHandle) const {
std::shared_lock<better::shared_mutex> lock(mutex_);
std::shared_lock<butter::shared_mutex> lock(mutex_);
auto iterator = _registryByHandle.find(componentHandle);
if (iterator == _registryByHandle.end()) {
@@ -107,14 +107,14 @@ ComponentDescriptor const *ComponentDescriptorRegistry::
ComponentDescriptor const &ComponentDescriptorRegistry::at(
ComponentHandle componentHandle) const {
std::shared_lock<better::shared_mutex> lock(mutex_);
std::shared_lock<butter::shared_mutex> lock(mutex_);
return *_registryByHandle.at(componentHandle);
}
bool ComponentDescriptorRegistry::hasComponentDescriptorAt(
ComponentHandle componentHandle) const {
std::shared_lock<better::shared_mutex> lock(mutex_);
std::shared_lock<butter::shared_mutex> lock(mutex_);
auto iterator = _registryByHandle.find(componentHandle);
if (iterator == _registryByHandle.end()) {
@@ -9,8 +9,8 @@
#include <memory>
#include <better/map.h>
#include <better/mutex.h>
#include <butter/map.h>
#include <butter/mutex.h>
#include <react/renderer/componentregistry/ComponentDescriptorProvider.h>
#include <react/renderer/core/ComponentDescriptor.h>
@@ -80,10 +80,10 @@ class ComponentDescriptorRegistry {
*/
void add(ComponentDescriptorProvider componentDescriptorProvider) const;
mutable better::shared_mutex mutex_;
mutable better::map<ComponentHandle, SharedComponentDescriptor>
mutable butter::shared_mutex mutex_;
mutable butter::map<ComponentHandle, SharedComponentDescriptor>
_registryByHandle;
mutable better::map<std::string, SharedComponentDescriptor> _registryByName;
mutable butter::map<std::string, SharedComponentDescriptor> _registryByName;
ComponentDescriptor::Shared _fallbackComponentDescriptor;
ComponentDescriptorParameters parameters_{};
ComponentDescriptorProviderRegistry const &providerRegistry_;
@@ -7,7 +7,7 @@
#pragma once
#include <better/map.h>
#include <butter/map.h>
#include <folly/dynamic.h>
#include <glog/logging.h>
#include <react/debug/react_native_assert.h>
@@ -30,8 +30,8 @@ inline void fromRawValue(
return;
}
if (value.hasType<better::map<std::string, RawValue>>()) {
auto items = (better::map<std::string, RawValue>)value;
if (value.hasType<butter::map<std::string, RawValue>>()) {
auto items = (butter::map<std::string, RawValue>)value;
result = {};
result.type = ImageSource::Type::Remote;
@@ -101,7 +101,7 @@ class ParagraphShadowNode final : public ConcreteViewShadowNode<
/*
* Cached content of the subtree started from the node.
*/
mutable better::optional<Content> content_{};
mutable butter::optional<Content> content_{};
};
} // namespace react
@@ -180,7 +180,7 @@ class AndroidTextInputComponentDescriptor final
"com/facebook/react/fabric/FabricUIManager";
SharedTextLayoutManager textLayoutManager_;
mutable better::map<int, YGStyle::Edges> surfaceIdToThemePaddingMap_;
mutable butter::map<int, YGStyle::Edges> surfaceIdToThemePaddingMap_;
};
} // namespace react
@@ -37,7 +37,7 @@ static inline void fromRawValue(
const PropsParserContext &context,
const RawValue &value,
AndroidTextInputSelectionStruct &result) {
auto map = (better::map<std::string, RawValue>)value;
auto map = (butter::map<std::string, RawValue>)value;
auto start = map.find("start");
if (start != map.end()) {
@@ -63,7 +63,7 @@ static inline void fromRawValue(
const PropsParserContext &context,
const RawValue &value,
AndroidTextInputTextShadowOffsetStruct &result) {
auto map = (better::map<std::string, RawValue>)value;
auto map = (butter::map<std::string, RawValue>)value;
auto width = map.find("width");
if (width != map.end()) {
@@ -81,7 +81,7 @@ class AndroidTextInputShadowNode final : public ConcreteViewShadowNode<
* Cached attributed string that represents the content of the subtree started
* from the node.
*/
mutable better::optional<AttributedString> cachedAttributedString_{};
mutable butter::optional<AttributedString> cachedAttributedString_{};
};
} // namespace react
@@ -87,7 +87,7 @@ TextInputProps::TextInputProps(
rawProps,
"selection",
sourceProps.selection,
better::optional<Selection>())),
butter::optional<Selection>())),
inputAccessoryViewID(convertRawProp(
context,
rawProps,
@@ -58,7 +58,7 @@ class TextInputProps final : public ViewProps, public BaseTextProps {
int const mostRecentEventCount{0};
bool autoFocus{false};
better::optional<Selection> selection{};
butter::optional<Selection> selection{};
std::string const inputAccessoryViewID{};
@@ -9,7 +9,7 @@
#include <string>
#include <better/optional.h>
#include <butter/optional.h>
namespace facebook {
namespace react {
@@ -106,7 +106,7 @@ class TextInputTraits final {
* iOS & Android
* Default value: `empty` (`null`).
*/
better::optional<bool> autoCorrect{};
butter::optional<bool> autoCorrect{};
/*
* iOS & Android
@@ -141,7 +141,7 @@ class TextInputTraits final {
* Can be empty (`null` in JavaScript) which means `default`.
* Default value: `empty` (`null`).
*/
better::optional<bool> spellCheck{};
butter::optional<bool> spellCheck{};
/*
* iOS & Android
@@ -149,8 +149,8 @@ inline void fromRawValue(
const PropsParserContext &context,
const RawValue &value,
Selection &result) {
if (value.hasType<better::map<std::string, int>>()) {
auto map = (better::map<std::string, int>)value;
if (value.hasType<butter::map<std::string, int>>()) {
auto map = (butter::map<std::string, int>)value;
for (const auto &pair : map) {
if (pair.first == "start") {
result.start = pair.second;
@@ -7,7 +7,7 @@
#pragma once
#include <better/optional.h>
#include <butter/optional.h>
#include <cinttypes>
#include <string>
@@ -50,7 +50,7 @@ constexpr enum AccessibilityTraits operator&(
struct AccessibilityAction {
std::string name{""};
better::optional<std::string> label{};
butter::optional<std::string> label{};
};
struct AccessibilityState {
@@ -76,10 +76,10 @@ constexpr bool operator!=(
}
struct AccessibilityValue {
better::optional<int> min;
better::optional<int> max;
better::optional<int> now;
better::optional<std::string> text{};
butter::optional<int> min;
butter::optional<int> max;
butter::optional<int> now;
butter::optional<std::string> text{};
};
constexpr bool operator==(
@@ -54,7 +54,7 @@ class ViewProps : public YogaStylableProps, public AccessibilityProps {
Transform transform{};
BackfaceVisibility backfaceVisibility{};
bool shouldRasterize{};
better::optional<int> zIndex{};
butter::optional<int> zIndex{};
// Events
PointerEventsMode pointerEvents{};
@@ -25,7 +25,7 @@ namespace react {
class YogaLayoutableShadowNode : public LayoutableShadowNode {
public:
using UnsharedList = better::small_vector<
using UnsharedList = butter::small_vector<
YogaLayoutableShadowNode *,
kShadowNodeChildrenSmallVectorSize>;
@@ -133,7 +133,7 @@ inline void fromRawValue(
const PropsParserContext &context,
const RawValue &value,
AccessibilityState &result) {
auto map = (better::map<std::string, RawValue>)value;
auto map = (butter::map<std::string, RawValue>)value;
auto selected = map.find("selected");
if (selected != map.end()) {
fromRawValue(context, selected->second, result.selected);
@@ -212,7 +212,7 @@ inline void fromRawValue(
const PropsParserContext &context,
const RawValue &value,
AccessibilityAction &result) {
auto map = (better::map<std::string, RawValue>)value;
auto map = (butter::map<std::string, RawValue>)value;
auto name = map.find("name");
react_native_assert(name != map.end() && name->second.hasType<std::string>());
@@ -232,7 +232,7 @@ inline void fromRawValue(
const PropsParserContext &,
const RawValue &value,
AccessibilityValue &result) {
auto map = (better::map<std::string, RawValue>)value;
auto map = (butter::map<std::string, RawValue>)value;
auto min = map.find("min");
if (min != map.end()) {
@@ -7,8 +7,8 @@
#pragma once
#include <better/map.h>
#include <better/optional.h>
#include <butter/map.h>
#include <butter/optional.h>
#include <folly/Conv.h>
#include <folly/dynamic.h>
#include <glog/logging.h>
@@ -98,9 +98,9 @@ inline YGValue yogaStyleValueFromFloat(
return {(float)value, unit};
}
inline better::optional<Float> optionalFloatFromYogaValue(
inline butter::optional<Float> optionalFloatFromYogaValue(
const YGValue value,
better::optional<Float> base = {}) {
butter::optional<Float> base = {}) {
switch (value.unit) {
case YGUnitUndefined:
return {};
@@ -108,9 +108,9 @@ inline better::optional<Float> optionalFloatFromYogaValue(
return floatFromYogaFloat(value.value);
case YGUnitPercent:
return base.has_value()
? better::optional<Float>(
? butter::optional<Float>(
base.value() * floatFromYogaFloat(value.value))
: better::optional<Float>();
: butter::optional<Float>();
case YGUnitAuto:
return {};
}
@@ -444,14 +444,14 @@ inline void fromRawValue(
auto configurations = static_cast<std::vector<RawValue>>(value);
for (const auto &configuration : configurations) {
if (!configuration.hasType<better::map<std::string, RawValue>>()) {
if (!configuration.hasType<butter::map<std::string, RawValue>>()) {
// TODO: The following checks have to be removed after codegen is shipped.
// See T45151459.
continue;
}
auto configurationPair =
static_cast<better::map<std::string, RawValue>>(configuration);
static_cast<butter::map<std::string, RawValue>>(configuration);
auto pair = configurationPair.begin();
auto operation = pair->first;
auto &parameters = pair->second;
@@ -7,7 +7,7 @@
#pragma once
#include <better/optional.h>
#include <butter/optional.h>
#include <react/renderer/graphics/Color.h>
#include <react/renderer/graphics/Geometry.h>
#include <array>
@@ -25,7 +25,7 @@ enum class BorderStyle { Solid, Dotted, Dashed };
template <typename T>
struct CascadedRectangleEdges {
using Counterpart = RectangleEdges<T>;
using OptionalT = better::optional<T>;
using OptionalT = butter::optional<T>;
OptionalT left{};
OptionalT top{};
@@ -86,7 +86,7 @@ struct CascadedRectangleEdges {
template <typename T>
struct CascadedRectangleCorners {
using Counterpart = RectangleCorners<T>;
using OptionalT = better::optional<T>;
using OptionalT = butter::optional<T>;
OptionalT topLeft{};
OptionalT topRight{};
@@ -56,7 +56,7 @@ LayoutMetrics LayoutableShadowNode::computeRelativeLayoutMetrics(
// Step 1.
// Creating a list of nodes that form a chain from the descender node to
// ancestor node inclusively.
auto shadowNodeList = better::small_vector<ShadowNode const *, 16>{};
auto shadowNodeList = butter::small_vector<ShadowNode const *, 16>{};
// Finding the measured node.
// The last element in the `AncestorList` is a pair of a parent of the node
@@ -12,7 +12,7 @@
#include <memory>
#include <vector>
#include <better/small_vector.h>
#include <butter/small_vector.h>
#include <react/debug/react_native_assert.h>
#include <react/renderer/core/LayoutMetrics.h>
#include <react/renderer/core/ShadowNode.h>
@@ -49,7 +49,7 @@ class LayoutableShadowNode : public ShadowNode {
bool includeViewportOffset{false};
};
using UnsharedList = better::
using UnsharedList = butter::
small_vector<LayoutableShadowNode *, kShadowNodeChildrenSmallVectorSize>;
/*
+5 -5
View File
@@ -9,9 +9,9 @@
#include <limits>
#include <better/map.h>
#include <better/optional.h>
#include <better/small_vector.h>
#include <butter/map.h>
#include <butter/optional.h>
#include <butter/small_vector.h>
#include <folly/dynamic.h>
#include <jsi/JSIDynamic.h>
@@ -125,10 +125,10 @@ class RawProps final {
* Parsed artefacts:
* To be used by `RawPropParser`.
*/
mutable better::
mutable butter::
small_vector<RawPropsValueIndex, kNumberOfPropsPerComponentSoftCap>
keyIndexToValueIndex_;
mutable better::
mutable butter::
small_vector<RawValue, kNumberOfExplicitlySpecifedPropsSoftCap>
values_;
};
@@ -7,7 +7,7 @@
#pragma once
#include <better/small_vector.h>
#include <butter/small_vector.h>
#include <react/renderer/core/RawPropsKey.h>
#include <react/renderer/core/RawPropsPrimitives.h>
@@ -55,8 +55,8 @@ class RawPropsKeyMap final {
Item const &rhs) noexcept;
static bool hasSameName(Item const &lhs, Item const &rhs) noexcept;
better::small_vector<Item, kNumberOfExplicitlySpecifedPropsSoftCap> items_{};
better::small_vector<RawPropsPropNameLength, kPropNameLengthHardCap>
butter::small_vector<Item, kNumberOfExplicitlySpecifedPropsSoftCap> items_{};
butter::small_vector<RawPropsPropNameLength, kPropNameLengthHardCap>
buckets_{};
};
@@ -7,8 +7,8 @@
#pragma once
#include <better/map.h>
#include <better/small_vector.h>
#include <butter/map.h>
#include <butter/small_vector.h>
#include <react/renderer/core/Props.h>
#include <react/renderer/core/PropsParserContext.h>
#include <react/renderer/core/RawProps.h>
@@ -76,7 +76,7 @@ class RawPropsParser final {
RawValue const *at(RawProps const &rawProps, RawPropsKey const &key)
const noexcept;
mutable better::small_vector<RawPropsKey, kNumberOfPropsPerComponentSoftCap>
mutable butter::small_vector<RawPropsKey, kNumberOfPropsPerComponentSoftCap>
keys_{};
mutable RawPropsKeyMap nameToIndex_{};
mutable int size_{0};
+6 -6
View File
@@ -7,7 +7,7 @@
#pragma once
#include <better/map.h>
#include <butter/map.h>
#include <folly/dynamic.h>
#include <jsi/JSIDynamic.h>
#include <jsi/jsi.h>
@@ -78,7 +78,7 @@ class RawValue {
/*
* Copy constructor and copy assignment operator would be private and only for
* internal use, but it's needed for user-code that does `auto val =
* (better::map<std::string, RawValue>)rawVal;`
* (butter::map<std::string, RawValue>)rawVal;`
*/
RawValue(RawValue const &other) noexcept : dynamic_(other.dynamic_) {}
@@ -185,7 +185,7 @@ class RawValue {
template <typename T>
static bool checkValueType(
const folly::dynamic &dynamic,
better::map<std::string, T> *type) noexcept {
butter::map<std::string, T> *type) noexcept {
if (!dynamic.isObject()) {
return false;
}
@@ -267,11 +267,11 @@ class RawValue {
}
template <typename T>
static better::map<std::string, T> castValue(
static butter::map<std::string, T> castValue(
const folly::dynamic &dynamic,
better::map<std::string, T> *type) noexcept {
butter::map<std::string, T> *type) noexcept {
react_native_assert(dynamic.isObject());
auto result = better::map<std::string, T>{};
auto result = butter::map<std::string, T>{};
for (const auto &item : dynamic.items()) {
react_native_assert(item.first.isString());
result[item.first.getString()] = castValue(item.second, (T *)nullptr);
@@ -9,7 +9,7 @@
#include "DynamicPropsUtilities.h"
#include "ShadowNodeFragment.h"
#include <better/small_vector.h>
#include <butter/small_vector.h>
#include <react/debug/react_native_assert.h>
#include <react/renderer/core/ComponentDescriptor.h>
+5 -5
View File
@@ -11,7 +11,7 @@
#include <string>
#include <vector>
#include <better/small_vector.h>
#include <butter/small_vector.h>
#include <react/renderer/core/EventEmitter.h>
#include <react/renderer/core/Props.h>
#include <react/renderer/core/ReactPrimitives.h>
@@ -34,7 +34,7 @@ class ShadowNode;
using SharedShadowNode = std::shared_ptr<const ShadowNode>;
using WeakShadowNode = std::weak_ptr<const ShadowNode>;
using SharedShadowNodeList =
better::small_vector<SharedShadowNode, kShadowNodeChildrenSmallVectorSize>;
butter::small_vector<SharedShadowNode, kShadowNodeChildrenSmallVectorSize>;
using SharedShadowNodeSharedList = std::shared_ptr<const SharedShadowNodeList>;
using SharedShadowNodeUnsharedList = std::shared_ptr<SharedShadowNodeList>;
@@ -44,14 +44,14 @@ class ShadowNode : public Sealable, public DebugStringConvertible {
using Weak = std::weak_ptr<ShadowNode const>;
using Unshared = std::shared_ptr<ShadowNode>;
using ListOfShared =
better::small_vector<Shared, kShadowNodeChildrenSmallVectorSize>;
butter::small_vector<Shared, kShadowNodeChildrenSmallVectorSize>;
using ListOfWeak =
better::small_vector<Weak, kShadowNodeChildrenSmallVectorSize>;
butter::small_vector<Weak, kShadowNodeChildrenSmallVectorSize>;
using SharedListOfShared = std::shared_ptr<ListOfShared const>;
using UnsharedListOfShared = std::shared_ptr<ListOfShared>;
using UnsharedListOfWeak = std::shared_ptr<ListOfWeak>;
using AncestorList = better::small_vector<
using AncestorList = butter::small_vector<
std::pair<
std::reference_wrapper<ShadowNode const> /* parentNode */,
int /* childIndex */>,
@@ -57,7 +57,7 @@ const ComponentDescriptor &ShadowNodeFamily::getComponentDescriptor() const {
AncestorList ShadowNodeFamily::getAncestors(
ShadowNode const &ancestorShadowNode) const {
auto families = better::small_vector<ShadowNodeFamily const *, 64>{};
auto families = butter::small_vector<ShadowNodeFamily const *, 64>{};
auto ancestorFamily = ancestorShadowNode.family_.get();
auto family = this;
@@ -96,12 +96,12 @@ AncestorList ShadowNodeFamily::getAncestors(
}
State::Shared ShadowNodeFamily::getMostRecentState() const {
std::unique_lock<better::shared_mutex> lock(mutex_);
std::unique_lock<butter::shared_mutex> lock(mutex_);
return mostRecentState_;
}
void ShadowNodeFamily::setMostRecentState(State::Shared const &state) const {
std::unique_lock<better::shared_mutex> lock(mutex_);
std::unique_lock<butter::shared_mutex> lock(mutex_);
/*
* Checking and setting `isObsolete_` prevents old states to be recommitted
@@ -122,7 +122,7 @@ void ShadowNodeFamily::setMostRecentState(State::Shared const &state) const {
std::shared_ptr<State const> ShadowNodeFamily::getMostRecentStateIfObsolete(
State const &state) const {
std::unique_lock<better::shared_mutex> lock(mutex_);
std::unique_lock<butter::shared_mutex> lock(mutex_);
if (!state.isObsolete_) {
return {};
}
@@ -9,8 +9,8 @@
#include <memory>
#include <better/mutex.h>
#include <better/small_vector.h>
#include <butter/mutex.h>
#include <butter/small_vector.h>
#include <react/renderer/core/EventEmitter.h>
#include <react/renderer/core/ReactPrimitives.h>
@@ -32,7 +32,7 @@ class ShadowNodeFamily final {
using Shared = std::shared_ptr<ShadowNodeFamily const>;
using Weak = std::weak_ptr<ShadowNodeFamily const>;
using AncestorList = better::small_vector<
using AncestorList = butter::small_vector<
std::pair<
std::reference_wrapper<ShadowNode const> /* parentNode */,
int /* childIndex */>,
@@ -101,7 +101,7 @@ class ShadowNodeFamily final {
EventDispatcher::Weak eventDispatcher_;
mutable std::shared_ptr<State const> mostRecentState_;
mutable better::shared_mutex mutex_;
mutable butter::shared_mutex mutex_;
/*
* Deprecated.
@@ -7,7 +7,7 @@
#pragma once
#include <better/optional.h>
#include <butter/optional.h>
#include <folly/Likely.h>
#include <folly/dynamic.h>
#include <react/renderer/core/PropsParserContext.h>
@@ -106,12 +106,12 @@ T convertRawProp(
}
template <typename T>
static better::optional<T> convertRawProp(
static butter::optional<T> convertRawProp(
const PropsParserContext &context,
RawProps const &rawProps,
char const *name,
better::optional<T> const &sourceValue,
better::optional<T> const &defaultValue,
butter::optional<T> const &sourceValue,
butter::optional<T> const &defaultValue,
char const *namePrefix = nullptr,
char const *nameSuffix = nullptr) {
const auto *rawValue = rawProps.at(name, namePrefix, nameSuffix);
@@ -128,7 +128,7 @@ static better::optional<T> convertRawProp(
T result;
fromRawValue(context, *rawValue, result);
return better::optional<T>{result};
return butter::optional<T>{result};
}
} // namespace react
+1 -1
View File
@@ -50,7 +50,7 @@ rn_xplat_cxx_library(
"//xplat/folly:headers_only",
"//xplat/folly:memory",
"//xplat/folly:molly",
react_native_xplat_target("better:better"),
react_native_xplat_target("butter:butter"),
react_native_xplat_target("react/debug:debug"),
],
)
@@ -7,7 +7,7 @@
#pragma once
#include <better/optional.h>
#include <butter/optional.h>
#include <limits>
#include <memory>
#include <string>
@@ -34,7 +34,7 @@ debugStringConvertibleItem(std::string name, T value, T defaultValue = {}) {
template <typename T>
inline SharedDebugStringConvertible debugStringConvertibleItem(
std::string name,
better::optional<T> value,
butter::optional<T> value,
T defaultValue = {}) {
if (!value.hasValue()) {
return nullptr;
+1 -1
View File
@@ -102,7 +102,7 @@ rn_xplat_cxx_library(
visibility = ["PUBLIC"],
deps = [
react_native_xplat_target("react/debug:debug"),
react_native_xplat_target("better:better"),
react_native_xplat_target("butter:butter"),
"//third-party/glog:glog",
"//xplat/fbsystrace:fbsystrace",
"//xplat/folly:headers_only",
@@ -7,7 +7,7 @@
#pragma once
#include <better/map.h>
#include <butter/map.h>
#include <glog/logging.h>
#include <react/debug/react_native_assert.h>
#include <react/renderer/core/PropsParserContext.h>
@@ -88,8 +88,8 @@ inline void fromRawValue(
const PropsParserContext &context,
const RawValue &value,
Point &result) {
if (value.hasType<better::map<std::string, Float>>()) {
auto map = (better::map<std::string, Float>)value;
if (value.hasType<butter::map<std::string, Float>>()) {
auto map = (butter::map<std::string, Float>)value;
for (const auto &pair : map) {
if (pair.first == "x") {
result.x = pair.second;
@@ -119,8 +119,8 @@ inline void fromRawValue(
const PropsParserContext &context,
const RawValue &value,
Size &result) {
if (value.hasType<better::map<std::string, Float>>()) {
auto map = (better::map<std::string, Float>)value;
if (value.hasType<butter::map<std::string, Float>>()) {
auto map = (butter::map<std::string, Float>)value;
for (const auto &pair : map) {
if (pair.first == "width") {
result.width = pair.second;
@@ -159,8 +159,8 @@ inline void fromRawValue(
return;
}
if (value.hasType<better::map<std::string, Float>>()) {
auto map = (better::map<std::string, Float>)value;
if (value.hasType<butter::map<std::string, Float>>()) {
auto map = (butter::map<std::string, Float>)value;
for (const auto &pair : map) {
if (pair.first == "top") {
result.top = pair.second;
@@ -203,8 +203,8 @@ inline void fromRawValue(
return;
}
if (value.hasType<better::map<std::string, Float>>()) {
auto map = (better::map<std::string, Float>)value;
if (value.hasType<butter::map<std::string, Float>>()) {
auto map = (butter::map<std::string, Float>)value;
for (const auto &pair : map) {
if (pair.first == "topLeft") {
result.topLeft = pair.second;
@@ -21,8 +21,8 @@ inline ColorComponents parsePlatformColor(
const RawValue &value) {
ColorComponents colorComponents = {0, 0, 0, 0};
if (value.hasType<better::map<std::string, std::vector<std::string>>>()) {
auto map = (better::map<std::string, std::vector<std::string>>)value;
if (value.hasType<butter::map<std::string, std::vector<std::string>>>()) {
auto map = (butter::map<std::string, std::vector<std::string>>)value;
auto resourcePaths = map["resource_paths"];
auto dynamicResourcePaths = folly::dynamic::array();
for (const auto &resourcePath : resourcePaths) {
@@ -7,7 +7,7 @@
#pragma once
#include <better/optional.h>
#include <butter/optional.h>
#include <cmath>
#include <folly/Hash.h>
@@ -18,8 +18,8 @@ namespace react {
inline ColorComponents parsePlatformColor(
const PropsParserContext &context,
const RawValue &value) {
if (value.hasType<better::map<std::string, RawValue>>()) {
auto items = (better::map<std::string, RawValue>)value;
if (value.hasType<butter::map<std::string, RawValue>>()) {
auto items = (butter::map<std::string, RawValue>)value;
if (items.find("semantic") != items.end() &&
items.at("semantic").hasType<std::vector<std::string>>()) {
auto semanticItems = (std::vector<std::string>)items.at("semantic");
@@ -10,7 +10,7 @@
#include <react/renderer/imagemanager/ImageResponse.h>
#include <react/renderer/imagemanager/ImageResponseObserver.h>
#include <better/small_vector.h>
#include <butter/small_vector.h>
#include <mutex>
#include <vector>
@@ -59,7 +59,7 @@ class ImageResponseObserverCoordinator {
* List of observers.
* Mutable: protected by mutex_.
*/
mutable better::small_vector<ImageResponseObserver const *, 1> observers_;
mutable butter::small_vector<ImageResponseObserver const *, 1> observers_;
/*
* Current status of image loading.
@@ -23,7 +23,7 @@ LOCAL_STATIC_LIBRARIES :=
LOCAL_SHARED_LIBRARIES := \
glog \
libbetter \
libbutter \
libfolly_futures \
libfolly_json \
libglog_init \
@@ -40,7 +40,7 @@ LOCAL_SHARED_LIBRARIES := \
include $(BUILD_SHARED_LIBRARY)
$(call import-module,better)
$(call import-module,butter)
$(call import-module,glog)
$(call import-module,folly)
$(call import-module,fbgloginit)
+1 -1
View File
@@ -50,7 +50,7 @@ rn_xplat_cxx_library(
"//xplat/folly:headers_only",
"//xplat/folly:memory",
"//xplat/folly:molly",
react_native_xplat_target("better:better"),
react_native_xplat_target("butter:butter"),
react_native_xplat_target("react/debug:debug"),
react_native_xplat_target("react/renderer/components/root:root"),
react_native_xplat_target("react/renderer/components/view:view"),
@@ -7,8 +7,8 @@
#include "Differentiator.h"
#include <better/map.h>
#include <better/small_vector.h>
#include <butter/map.h>
#include <butter/small_vector.h>
#include <react/debug/react_native_assert.h>
#include <react/renderer/core/LayoutableShadowNode.h>
#include <react/renderer/debug/SystraceSection.h>
@@ -168,7 +168,7 @@ class TinyMap final {
erasedAtFront_ = 0;
}
better::small_vector<Pair, DefaultSize> vector_;
butter::small_vector<Pair, DefaultSize> vector_;
size_t numErased_{0};
size_t erasedAtFront_{0};
};
@@ -75,11 +75,11 @@ void MountingCoordinator::resetLatestRevision() const {
lastRevision_.reset();
}
better::optional<MountingTransaction> MountingCoordinator::pullTransaction()
butter::optional<MountingTransaction> MountingCoordinator::pullTransaction()
const {
std::lock_guard<std::mutex> lock(mutex_);
auto transaction = better::optional<MountingTransaction>{};
auto transaction = butter::optional<MountingTransaction>{};
// Base case
if (lastRevision_.has_value()) {
@@ -7,7 +7,7 @@
#pragma once
#include <better/optional.h>
#include <butter/optional.h>
#include <chrono>
#include <react/renderer/debug/flags.h>
@@ -56,7 +56,7 @@ class MountingCoordinator final {
* However, a consumer should always call it on the same thread (e.g. on the
* main thread) or ensure sequentiality of mount transactions separately.
*/
better::optional<MountingTransaction> pullTransaction() const;
butter::optional<MountingTransaction> pullTransaction() const;
/*
* Blocks the current thread until a new mounting transaction is available or
@@ -104,7 +104,7 @@ class MountingCoordinator final {
mutable std::mutex mutex_;
mutable ShadowTreeRevision baseRevision_;
mutable better::optional<ShadowTreeRevision> lastRevision_{};
mutable butter::optional<ShadowTreeRevision> lastRevision_{};
mutable MountingTransaction::Number number_{0};
mutable std::condition_variable signal_;
mutable std::weak_ptr<MountingOverrideDelegate const>
@@ -36,7 +36,7 @@ class MountingOverrideDelegate {
* @param mountingCoordinator
* @return
*/
virtual better::optional<MountingTransaction> pullTransaction(
virtual butter::optional<MountingTransaction> pullTransaction(
SurfaceId surfaceId,
MountingTransaction::Number number,
TransactionTelemetry const &telemetry,
@@ -270,7 +270,7 @@ void ShadowTree::setCommitMode(CommitMode commitMode) const {
auto revision = ShadowTreeRevision{};
{
std::unique_lock<better::shared_mutex> lock(commitMutex_);
std::unique_lock<butter::shared_mutex> lock(commitMutex_);
if (commitMode_ == commitMode) {
return;
}
@@ -287,7 +287,7 @@ void ShadowTree::setCommitMode(CommitMode commitMode) const {
}
CommitMode ShadowTree::getCommitMode() const {
std::shared_lock<better::shared_mutex> lock(commitMutex_);
std::shared_lock<butter::shared_mutex> lock(commitMutex_);
return commitMode_;
}
@@ -330,7 +330,7 @@ CommitStatus ShadowTree::tryCommit(
{
// Reading `currentRevision_` in shared manner.
std::shared_lock<better::shared_mutex> lock(commitMutex_);
std::shared_lock<butter::shared_mutex> lock(commitMutex_);
commitMode = commitMode_;
oldRevision = currentRevision_;
}
@@ -367,7 +367,7 @@ CommitStatus ShadowTree::tryCommit(
{
// Updating `currentRevision_` in unique manner if it hasn't changed.
std::unique_lock<better::shared_mutex> lock(commitMutex_);
std::unique_lock<butter::shared_mutex> lock(commitMutex_);
if (currentRevision_.number != oldRevision.number) {
return CommitStatus::Failed;
@@ -410,7 +410,7 @@ CommitStatus ShadowTree::tryCommit(
}
ShadowTreeRevision ShadowTree::getCurrentRevision() const {
std::shared_lock<better::shared_mutex> lock(commitMutex_);
std::shared_lock<butter::shared_mutex> lock(commitMutex_);
return currentRevision_;
}
@@ -7,7 +7,7 @@
#pragma once
#include <better/mutex.h>
#include <butter/mutex.h>
#include <memory>
#include <react/renderer/components/root/RootComponentDescriptor.h>
@@ -135,7 +135,7 @@ class ShadowTree final {
SurfaceId const surfaceId_;
ShadowTreeDelegate const &delegate_;
mutable better::shared_mutex commitMutex_;
mutable butter::shared_mutex commitMutex_;
mutable CommitMode commitMode_{
CommitMode::Normal}; // Protected by `commitMutex_`.
mutable ShadowTreeRevision currentRevision_; // Protected by `commitMutex_`.
@@ -18,14 +18,14 @@ ShadowTreeRegistry::~ShadowTreeRegistry() {
}
void ShadowTreeRegistry::add(std::unique_ptr<ShadowTree> &&shadowTree) const {
std::unique_lock<better::shared_mutex> lock(mutex_);
std::unique_lock<butter::shared_mutex> lock(mutex_);
registry_.emplace(shadowTree->getSurfaceId(), std::move(shadowTree));
}
std::unique_ptr<ShadowTree> ShadowTreeRegistry::remove(
SurfaceId surfaceId) const {
std::unique_lock<better::shared_mutex> lock(mutex_);
std::unique_lock<butter::shared_mutex> lock(mutex_);
auto iterator = registry_.find(surfaceId);
if (iterator == registry_.end()) {
@@ -40,7 +40,7 @@ std::unique_ptr<ShadowTree> ShadowTreeRegistry::remove(
bool ShadowTreeRegistry::visit(
SurfaceId surfaceId,
std::function<void(const ShadowTree &shadowTree)> callback) const {
std::shared_lock<better::shared_mutex> lock(mutex_);
std::shared_lock<butter::shared_mutex> lock(mutex_);
auto iterator = registry_.find(surfaceId);
@@ -54,7 +54,7 @@ bool ShadowTreeRegistry::visit(
void ShadowTreeRegistry::enumerate(
std::function<void(const ShadowTree &shadowTree)> callback) const {
std::shared_lock<better::shared_mutex> lock(mutex_);
std::shared_lock<butter::shared_mutex> lock(mutex_);
for (auto const &pair : registry_) {
callback(*pair.second);
}
@@ -7,8 +7,8 @@
#pragma once
#include <better/map.h>
#include <better/mutex.h>
#include <butter/map.h>
#include <butter/mutex.h>
#include <react/renderer/core/ReactPrimitives.h>
#include <react/renderer/mounting/ShadowTree.h>
@@ -60,8 +60,8 @@ class ShadowTreeRegistry final {
std::function<void(const ShadowTree &shadowTree)> callback) const;
private:
mutable better::shared_mutex mutex_;
mutable better::map<SurfaceId, std::unique_ptr<ShadowTree>>
mutable butter::shared_mutex mutex_;
mutable butter::map<SurfaceId, std::unique_ptr<ShadowTree>>
registry_; // Protected by `mutex_`.
};
@@ -7,7 +7,7 @@
#pragma once
#include <better/optional.h>
#include <butter/optional.h>
#include <react/renderer/components/root/RootShadowNode.h>
#include <react/renderer/mounting/MountingOverrideDelegate.h>
@@ -7,7 +7,7 @@
#pragma once
#include <better/small_vector.h>
#include <butter/small_vector.h>
#include <folly/Hash.h>
#include <react/renderer/core/EventEmitter.h>
#include <react/renderer/core/LayoutMetrics.h>
@@ -65,9 +65,9 @@ std::vector<DebugStringConvertibleObject> getDebugProps(
*
*/
struct ShadowViewNodePair final {
using NonOwningList = better::
using NonOwningList = butter::
small_vector<ShadowViewNodePair *, kShadowNodeChildrenSmallVectorSize>;
using OwningList = better::
using OwningList = butter::
small_vector<ShadowViewNodePair, kShadowNodeChildrenSmallVectorSize>;
ShadowView shadowView;
@@ -103,7 +103,7 @@ struct ShadowViewNodePair final {
*
*/
struct ShadowViewNodePairLegacy final {
using OwningList = better::small_vector<
using OwningList = butter::small_vector<
ShadowViewNodePairLegacy,
kShadowNodeChildrenSmallVectorSize>;
@@ -46,7 +46,7 @@ rn_xplat_cxx_library(
deps = [
react_native_xplat_target("runtimeexecutor:runtimeexecutor"),
react_native_xplat_target("react/renderer/debug:debug"),
react_native_xplat_target("better:better"),
react_native_xplat_target("butter:butter"),
react_native_xplat_target("callinvoker:callinvoker"),
],
)
@@ -7,7 +7,7 @@
#pragma once
#include <better/optional.h>
#include <butter/optional.h>
#include <jsi/jsi.h>
#include <react/renderer/runtimescheduler/RuntimeSchedulerClock.h>
#include <react/renderer/runtimescheduler/SchedulerPriority.h>
@@ -29,7 +29,7 @@ struct Task final {
friend TaskPriorityComparer;
SchedulerPriority priority;
better::optional<jsi::Function> callback;
butter::optional<jsi::Function> callback;
RuntimeSchedulerClock::time_point expirationTime;
jsi::Value execute(jsi::Runtime &runtime);
@@ -43,7 +43,7 @@ Scheduler::Scheduler(
// Creating a container for future `EventDispatcher` instance.
eventDispatcher_ =
std::make_shared<better::optional<EventDispatcher const>>();
std::make_shared<butter::optional<EventDispatcher const>>();
auto uiManager = std::make_shared<UIManager>(
runtimeExecutor_, schedulerToolbox.backgroundExecutor, contextContainer_);
@@ -125,7 +125,7 @@ class Scheduler final : public UIManagerDelegate {
* parts that need to have ownership (and only ownership) of that, and then
* fill the optional.
*/
std::shared_ptr<better::optional<EventDispatcher const>> eventDispatcher_;
std::shared_ptr<butter::optional<EventDispatcher const>> eventDispatcher_;
/**
* Hold onto ContextContainer. See SchedulerToolbox.
@@ -29,12 +29,12 @@ SurfaceHandler::SurfaceHandler(SurfaceHandler &&other) noexcept {
}
SurfaceHandler &SurfaceHandler::operator=(SurfaceHandler &&other) noexcept {
std::unique_lock<better::shared_mutex> lock1(linkMutex_, std::defer_lock);
std::unique_lock<better::shared_mutex> lock2(
std::unique_lock<butter::shared_mutex> lock1(linkMutex_, std::defer_lock);
std::unique_lock<butter::shared_mutex> lock2(
parametersMutex_, std::defer_lock);
std::unique_lock<better::shared_mutex> lock3(
std::unique_lock<butter::shared_mutex> lock3(
other.linkMutex_, std::defer_lock);
std::unique_lock<better::shared_mutex> lock4(
std::unique_lock<butter::shared_mutex> lock4(
other.parametersMutex_, std::defer_lock);
std::lock(lock1, lock2, lock3, lock4);
@@ -55,13 +55,13 @@ void SurfaceHandler::setContextContainer(
}
Status SurfaceHandler::getStatus() const noexcept {
std::shared_lock<better::shared_mutex> lock(linkMutex_);
std::shared_lock<butter::shared_mutex> lock(linkMutex_);
return link_.status;
}
void SurfaceHandler::start() const noexcept {
SystraceSection s("SurfaceHandler::start");
std::unique_lock<better::shared_mutex> lock(linkMutex_);
std::unique_lock<butter::shared_mutex> lock(linkMutex_);
react_native_assert(
link_.status == Status::Registered && "Surface must be registered.");
react_native_assert(
@@ -73,7 +73,7 @@ void SurfaceHandler::start() const noexcept {
auto parameters = Parameters{};
{
SystraceSection s2("SurfaceHandler::start::paramsLock");
std::shared_lock<better::shared_mutex> parametersLock(parametersMutex_);
std::shared_lock<butter::shared_mutex> parametersLock(parametersMutex_);
parameters = parameters_;
}
@@ -100,7 +100,7 @@ void SurfaceHandler::start() const noexcept {
void SurfaceHandler::stop() const noexcept {
auto shadowTree = ShadowTree::Unique{};
{
std::unique_lock<better::shared_mutex> lock(linkMutex_);
std::unique_lock<butter::shared_mutex> lock(linkMutex_);
react_native_assert(
link_.status == Status::Running && "Surface must be running.");
@@ -118,7 +118,7 @@ void SurfaceHandler::stop() const noexcept {
void SurfaceHandler::setDisplayMode(DisplayMode displayMode) const noexcept {
{
std::unique_lock<better::shared_mutex> lock(parametersMutex_);
std::unique_lock<butter::shared_mutex> lock(parametersMutex_);
if (parameters_.displayMode == displayMode) {
return;
}
@@ -127,7 +127,7 @@ void SurfaceHandler::setDisplayMode(DisplayMode displayMode) const noexcept {
}
{
std::shared_lock<better::shared_mutex> lock(linkMutex_);
std::shared_lock<butter::shared_mutex> lock(linkMutex_);
if (link_.status != Status::Running) {
return;
@@ -144,41 +144,41 @@ void SurfaceHandler::setDisplayMode(DisplayMode displayMode) const noexcept {
}
DisplayMode SurfaceHandler::getDisplayMode() const noexcept {
std::shared_lock<better::shared_mutex> lock(parametersMutex_);
std::shared_lock<butter::shared_mutex> lock(parametersMutex_);
return parameters_.displayMode;
}
#pragma mark - Accessors
SurfaceId SurfaceHandler::getSurfaceId() const noexcept {
std::shared_lock<better::shared_mutex> lock(parametersMutex_);
std::shared_lock<butter::shared_mutex> lock(parametersMutex_);
return parameters_.surfaceId;
}
void SurfaceHandler::setSurfaceId(SurfaceId surfaceId) const noexcept {
std::unique_lock<better::shared_mutex> lock(parametersMutex_);
std::unique_lock<butter::shared_mutex> lock(parametersMutex_);
parameters_.surfaceId = surfaceId;
}
std::string SurfaceHandler::getModuleName() const noexcept {
std::shared_lock<better::shared_mutex> lock(parametersMutex_);
std::shared_lock<butter::shared_mutex> lock(parametersMutex_);
return parameters_.moduleName;
}
void SurfaceHandler::setProps(folly::dynamic const &props) const noexcept {
SystraceSection s("SurfaceHandler::setProps");
std::unique_lock<better::shared_mutex> lock(parametersMutex_);
std::unique_lock<butter::shared_mutex> lock(parametersMutex_);
parameters_.props = props;
}
folly::dynamic SurfaceHandler::getProps() const noexcept {
std::shared_lock<better::shared_mutex> lock(parametersMutex_);
std::shared_lock<butter::shared_mutex> lock(parametersMutex_);
return parameters_.props;
}
std::shared_ptr<MountingCoordinator const>
SurfaceHandler::getMountingCoordinator() const noexcept {
std::shared_lock<better::shared_mutex> lock(linkMutex_);
std::shared_lock<butter::shared_mutex> lock(linkMutex_);
react_native_assert(
link_.status != Status::Unregistered && "Surface must be registered.");
react_native_assert(
@@ -191,7 +191,7 @@ SurfaceHandler::getMountingCoordinator() const noexcept {
Size SurfaceHandler::measure(
LayoutConstraints const &layoutConstraints,
LayoutContext const &layoutContext) const noexcept {
std::shared_lock<better::shared_mutex> lock(linkMutex_);
std::shared_lock<butter::shared_mutex> lock(linkMutex_);
if (link_.status != Status::Running) {
return layoutConstraints.clamp({0, 0});
@@ -217,7 +217,7 @@ void SurfaceHandler::constraintLayout(
LayoutContext const &layoutContext) const noexcept {
SystraceSection s("SurfaceHandler::constraintLayout");
{
std::unique_lock<better::shared_mutex> lock(parametersMutex_);
std::unique_lock<butter::shared_mutex> lock(parametersMutex_);
if (parameters_.layoutConstraints == layoutConstraints &&
parameters_.layoutContext == layoutContext) {
@@ -229,7 +229,7 @@ void SurfaceHandler::constraintLayout(
}
{
std::shared_lock<better::shared_mutex> lock(linkMutex_);
std::shared_lock<butter::shared_mutex> lock(linkMutex_);
if (link_.status != Status::Running) {
return;
@@ -248,12 +248,12 @@ void SurfaceHandler::constraintLayout(
}
LayoutConstraints SurfaceHandler::getLayoutConstraints() const noexcept {
std::shared_lock<better::shared_mutex> lock(parametersMutex_);
std::shared_lock<butter::shared_mutex> lock(parametersMutex_);
return parameters_.layoutConstraints;
}
LayoutContext SurfaceHandler::getLayoutContext() const noexcept {
std::shared_lock<better::shared_mutex> lock(parametersMutex_);
std::shared_lock<butter::shared_mutex> lock(parametersMutex_);
return parameters_.layoutContext;
}
@@ -292,7 +292,7 @@ void SurfaceHandler::applyDisplayMode(DisplayMode displayMode) const noexcept {
}
void SurfaceHandler::setUIManager(UIManager const *uiManager) const noexcept {
std::unique_lock<better::shared_mutex> lock(linkMutex_);
std::unique_lock<butter::shared_mutex> lock(linkMutex_);
react_native_assert(
link_.status != Status::Running && "Surface must not be running.");
@@ -195,13 +195,13 @@ class SurfaceHandler {
/*
* `link_` and `linkMutex_` pair.
*/
mutable better::shared_mutex linkMutex_;
mutable butter::shared_mutex linkMutex_;
mutable Link link_;
/*
* `parameters_` and `parametersMutex_` pair.
*/
mutable better::shared_mutex parametersMutex_;
mutable butter::shared_mutex parametersMutex_;
mutable Parameters parameters_;
};
@@ -22,7 +22,7 @@ void SurfaceManager::startSurface(
LayoutConstraints const &layoutConstraints,
LayoutContext const &layoutContext) const noexcept {
{
std::unique_lock<better::shared_mutex> lock(mutex_);
std::unique_lock<butter::shared_mutex> lock(mutex_);
auto surfaceHandler = SurfaceHandler{moduleName, surfaceId};
surfaceHandler.setContextContainer(scheduler_.getContextContainer());
registry_.emplace(surfaceId, std::move(surfaceHandler));
@@ -45,7 +45,7 @@ void SurfaceManager::stopSurface(SurfaceId surfaceId) const noexcept {
});
{
std::unique_lock<better::shared_mutex> lock(mutex_);
std::unique_lock<butter::shared_mutex> lock(mutex_);
auto iterator = registry_.find(surfaceId);
registry_.erase(iterator);
@@ -89,7 +89,7 @@ void SurfaceManager::visit(
SurfaceId surfaceId,
std::function<void(SurfaceHandler const &surfaceHandler)> const &callback)
const noexcept {
std::shared_lock<better::shared_mutex> lock(mutex_);
std::shared_lock<butter::shared_mutex> lock(mutex_);
auto iterator = registry_.find(surfaceId);
@@ -7,7 +7,7 @@
#pragma once
#include <better/map.h>
#include <butter/map.h>
#include <mutex>
#include <react/renderer/core/LayoutConstraints.h>
@@ -59,8 +59,8 @@ class SurfaceManager final {
const noexcept;
Scheduler const &scheduler_;
mutable better::shared_mutex mutex_; // Protects `registry_`.
mutable better::map<SurfaceId, SurfaceHandler> registry_{};
mutable butter::shared_mutex mutex_; // Protects `registry_`.
mutable butter::map<SurfaceId, SurfaceHandler> registry_{};
};
} // namespace react
@@ -23,7 +23,7 @@ LOCAL_STATIC_LIBRARIES :=
LOCAL_SHARED_LIBRARIES := \
glog \
libbetter \
libbutter \
libfolly_futures \
libfolly_json \
libglog_init \
@@ -37,7 +37,7 @@ LOCAL_SHARED_LIBRARIES := \
include $(BUILD_SHARED_LIBRARY)
$(call import-module,better)
$(call import-module,butter)
$(call import-module,glog)
$(call import-module,folly)
$(call import-module,react/utils)
+1 -1
View File
@@ -50,7 +50,7 @@ rn_xplat_cxx_library(
"//xplat/folly:headers_only",
"//xplat/folly:memory",
"//xplat/folly:molly",
react_native_xplat_target("better:better"),
react_native_xplat_target("butter:butter"),
react_native_xplat_target("react/debug:debug"),
react_native_xplat_target("react/utils:utils"),
],
@@ -7,7 +7,7 @@
#pragma once
#include <better/small_vector.h>
#include <butter/small_vector.h>
#include <vector>
#include <react/renderer/telemetry/TransactionTelemetry.h>
@@ -60,7 +60,7 @@ class SurfaceTelemetry final {
int numberOfTextMeasurements_{};
int lastRevisionNumber_{};
better::
butter::
small_vector<TransactionTelemetry, kMaxNumberOfRecordedCommitTelemetries>
recentTransactionTelemetries_{};
};
@@ -10,7 +10,7 @@
#include <memory>
#include <vector>
#include <better/mutex.h>
#include <butter/mutex.h>
#include <react/renderer/core/ReactPrimitives.h>
#include <react/renderer/timeline/TimelineSnapshot.h>
@@ -25,7 +25,7 @@ TimelineHandler TimelineController::enable(SurfaceId surfaceId) const {
assert(shadowTreePtr);
{
std::unique_lock<better::shared_mutex> lock(timelinesMutex_);
std::unique_lock<butter::shared_mutex> lock(timelinesMutex_);
auto timeline = std::make_unique<Timeline>(*shadowTreePtr);
auto handler = TimelineHandler{*timeline};
@@ -35,7 +35,7 @@ TimelineHandler TimelineController::enable(SurfaceId surfaceId) const {
}
void TimelineController::disable(TimelineHandler &&handler) const {
std::unique_lock<better::shared_mutex> lock(timelinesMutex_);
std::unique_lock<butter::shared_mutex> lock(timelinesMutex_);
auto iterator = timelines_.find(handler.getSurfaceId());
assert(iterator != timelines_.end());
@@ -57,7 +57,7 @@ RootShadowNode::Unshared TimelineController::shadowTreeWillCommit(
ShadowTree const &shadowTree,
RootShadowNode::Shared const &oldRootShadowNode,
RootShadowNode::Unshared const &newRootShadowNode) const noexcept {
std::shared_lock<better::shared_mutex> lock(timelinesMutex_);
std::shared_lock<butter::shared_mutex> lock(timelinesMutex_);
assert(uiManager_ && "`uiManager_` must not be `nullptr`.");
@@ -9,7 +9,7 @@
#include <memory>
#include <better/map.h>
#include <butter/map.h>
#include <react/renderer/core/ReactPrimitives.h>
#include <react/renderer/timeline/Timeline.h>
@@ -65,12 +65,12 @@ class TimelineController final : public UIManagerCommitHook {
/*
* Protects all the data members.
*/
mutable better::shared_mutex timelinesMutex_;
mutable butter::shared_mutex timelinesMutex_;
/*
* Owning collection of all running `Timeline` instances.
*/
mutable better::map<SurfaceId, std::unique_ptr<Timeline>> timelines_;
mutable butter::map<SurfaceId, std::unique_ptr<Timeline>> timelines_;
mutable UIManager const *uiManager_;
mutable SurfaceId lastUpdatedSurface_;
@@ -376,7 +376,7 @@ ShadowTreeRegistry const &UIManager::getShadowTreeRegistry() const {
void UIManager::registerCommitHook(
UIManagerCommitHook const &commitHook) const {
std::unique_lock<better::shared_mutex> lock(commitHookMutex_);
std::unique_lock<butter::shared_mutex> lock(commitHookMutex_);
react_native_assert(
std::find(commitHooks_.begin(), commitHooks_.end(), &commitHook) ==
commitHooks_.end());
@@ -386,7 +386,7 @@ void UIManager::registerCommitHook(
void UIManager::unregisterCommitHook(
UIManagerCommitHook const &commitHook) const {
std::unique_lock<better::shared_mutex> lock(commitHookMutex_);
std::unique_lock<butter::shared_mutex> lock(commitHookMutex_);
auto iterator =
std::find(commitHooks_.begin(), commitHooks_.end(), &commitHook);
react_native_assert(iterator != commitHooks_.end());
@@ -400,7 +400,7 @@ RootShadowNode::Unshared UIManager::shadowTreeWillCommit(
ShadowTree const &shadowTree,
RootShadowNode::Shared const &oldRootShadowNode,
RootShadowNode::Unshared const &newRootShadowNode) const {
std::shared_lock<better::shared_mutex> lock(commitHookMutex_);
std::shared_lock<butter::shared_mutex> lock(commitHookMutex_);
auto resultRootShadowNode = newRootShadowNode;
for (auto const *commitHook : commitHooks_) {
@@ -194,7 +194,7 @@ class UIManager final : public ShadowTreeDelegate {
BackgroundExecutor const backgroundExecutor_{};
ContextContainer::Shared contextContainer_;
mutable better::shared_mutex commitHookMutex_;
mutable butter::shared_mutex commitHookMutex_;
mutable std::vector<UIManagerCommitHook const *> commitHooks_;
std::unique_ptr<LeakChecker> leakChecker_;
+1 -1
View File
@@ -42,7 +42,7 @@ rn_xplat_cxx_library(
visibility = ["PUBLIC"],
deps = [
"//xplat/jsi:jsi",
react_native_xplat_target("better:better"),
react_native_xplat_target("butter:butter"),
react_native_xplat_target("react/debug:debug"),
],
exported_deps = [
+1 -1
View File
@@ -58,7 +58,7 @@ rn_xplat_cxx_library(
"//xplat/folly:memory",
"//xplat/folly:molly",
"//xplat/jsi:jsi",
react_native_xplat_target("better:better"),
react_native_xplat_target("butter:butter"),
react_native_xplat_target("react/debug:debug"),
],
)

Some files were not shown because too many files have changed in this diff Show More