mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
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:
committed by
Facebook GitHub Bot
parent
b4dab1a537
commit
fb39d45ed5
@@ -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
|
||||
|
||||
@@ -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_;
|
||||
};
|
||||
|
||||
@@ -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];
|
||||
|
||||
@@ -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];
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user