diff --git a/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputComponentView.mm b/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputComponentView.mm index 1c3b916163c..3631fb45cbc 100644 --- a/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputComponentView.mm +++ b/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputComponentView.mm @@ -566,8 +566,8 @@ using namespace facebook::react; - (void)_restoreTextSelection { - const auto selection = std::dynamic_pointer_cast(_props)->selection.get_pointer(); - if (selection == nullptr) { + auto const selection = std::dynamic_pointer_cast(_props)->selection; + if (!selection.has_value()) { return; } auto start = [_backedTextInputView positionFromPosition:_backedTextInputView.beginningOfDocument diff --git a/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputUtils.h b/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputUtils.h index 08bdb6bffcf..ffaac133609 100644 --- a/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputUtils.h +++ b/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputUtils.h @@ -7,8 +7,9 @@ #import +#import + #import -#import #import NS_ASSUME_NONNULL_BEGIN @@ -17,7 +18,7 @@ void RCTCopyBackedTextInput( UIView *fromTextInput, UIView *toTextInput); -UITextAutocorrectionType RCTUITextAutocorrectionTypeFromOptionalBool(facebook::butter::optional autoCorrect); +UITextAutocorrectionType RCTUITextAutocorrectionTypeFromOptionalBool(std::optional autoCorrect); UITextAutocapitalizationType RCTUITextAutocapitalizationTypeFromAutocapitalizationType( facebook::react::AutocapitalizationType autocapitalizationType); @@ -25,7 +26,7 @@ UITextAutocapitalizationType RCTUITextAutocapitalizationTypeFromAutocapitalizati UIKeyboardAppearance RCTUIKeyboardAppearanceFromKeyboardAppearance( facebook::react::KeyboardAppearance keyboardAppearance); -UITextSpellCheckingType RCTUITextSpellCheckingTypeFromOptionalBool(facebook::butter::optional spellCheck); +UITextSpellCheckingType RCTUITextSpellCheckingTypeFromOptionalBool(std::optional spellCheck); UITextFieldViewMode RCTUITextFieldViewModeFromTextInputAccessoryVisibilityMode( facebook::react::TextInputAccessoryVisibilityMode mode); diff --git a/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputUtils.mm b/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputUtils.mm index a0880581c4d..99f46819af9 100644 --- a/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputUtils.mm +++ b/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputUtils.mm @@ -51,7 +51,7 @@ void RCTCopyBackedTextInput( [toTextInput setSelectedTextRange:fromTextInput.selectedTextRange notifyDelegate:NO]; } -UITextAutocorrectionType RCTUITextAutocorrectionTypeFromOptionalBool(facebook::butter::optional autoCorrect) +UITextAutocorrectionType RCTUITextAutocorrectionTypeFromOptionalBool(std::optional autoCorrect) { return autoCorrect.has_value() ? (*autoCorrect ? UITextAutocorrectionTypeYes : UITextAutocorrectionTypeNo) : UITextAutocorrectionTypeDefault; @@ -84,7 +84,7 @@ UIKeyboardAppearance RCTUIKeyboardAppearanceFromKeyboardAppearance(KeyboardAppea } } -UITextSpellCheckingType RCTUITextSpellCheckingTypeFromOptionalBool(facebook::butter::optional spellCheck) +UITextSpellCheckingType RCTUITextSpellCheckingTypeFromOptionalBool(std::optional spellCheck) { return spellCheck.has_value() ? (*spellCheck ? UITextSpellCheckingTypeYes : UITextSpellCheckingTypeNo) : UITextSpellCheckingTypeDefault; diff --git a/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm b/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm index 5c25be60215..7f7e54d7995 100644 --- a/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm +++ b/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm @@ -335,12 +335,12 @@ using namespace facebook::react; // `accessibilityValue` if (oldViewProps.accessibilityValue != newViewProps.accessibilityValue) { - if (newViewProps.accessibilityValue.text.hasValue()) { + if (newViewProps.accessibilityValue.text.has_value()) { self.accessibilityElement.accessibilityValue = RCTNSStringFromStringNilIfEmpty(newViewProps.accessibilityValue.text.value()); } else if ( - newViewProps.accessibilityValue.now.hasValue() && newViewProps.accessibilityValue.min.hasValue() && - newViewProps.accessibilityValue.max.hasValue()) { + newViewProps.accessibilityValue.now.has_value() && newViewProps.accessibilityValue.min.has_value() && + newViewProps.accessibilityValue.max.has_value()) { CGFloat val = (CGFloat)(newViewProps.accessibilityValue.now.value()) / (newViewProps.accessibilityValue.max.value() - newViewProps.accessibilityValue.min.value()); self.accessibilityElement.accessibilityValue = diff --git a/React/Fabric/RCTSurfacePresenter.mm b/React/Fabric/RCTSurfacePresenter.mm index b5bc02a02f9..b72a5c2629d 100644 --- a/React/Fabric/RCTSurfacePresenter.mm +++ b/React/Fabric/RCTSurfacePresenter.mm @@ -281,7 +281,7 @@ static BackgroundExecutor RCTGetBackgroundExecutor() toolbox.componentRegistryFactory = componentRegistryFactory; auto weakRuntimeScheduler = _contextContainer->find>("RuntimeScheduler"); - auto runtimeScheduler = weakRuntimeScheduler.hasValue() ? weakRuntimeScheduler.value().lock() : nullptr; + auto runtimeScheduler = weakRuntimeScheduler.has_value() ? weakRuntimeScheduler.value().lock() : nullptr; if (runtimeScheduler) { runtimeScheduler->setEnableYielding(true); runtimeExecutor = [runtimeScheduler](std::function &&callback) { diff --git a/React/Fabric/Surface/RCTFabricSurface.mm b/React/Fabric/Surface/RCTFabricSurface.mm index 13683a25aa6..074a610ef75 100644 --- a/React/Fabric/Surface/RCTFabricSurface.mm +++ b/React/Fabric/Surface/RCTFabricSurface.mm @@ -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. - butter::optional _surfaceHandler; + std::optional _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. diff --git a/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/viewPropConversions.h b/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/viewPropConversions.h index f3572406d10..6fd7eb18130 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/viewPropConversions.h +++ b/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/viewPropConversions.h @@ -13,6 +13,8 @@ #include #include +#include + namespace facebook { namespace react { @@ -122,7 +124,7 @@ MapBuffer convertAccessibilityState(AccessibilityState const &state) { inline void putOptionalColor( MapBufferBuilder &builder, MapBuffer::Key key, - butter::optional const &color) { + std::optional const &color) { builder.putInt(key, color.has_value() ? toAndroidRepr(color.value()) : -1); } @@ -159,7 +161,7 @@ constexpr MapBuffer::Key CORNER_ALL = 8; inline void putOptionalFloat( MapBufferBuilder &builder, MapBuffer::Key key, - butter::optional const &value) { + std::optional const &value) { builder.putDouble(key, value.value_or(NAN)); } @@ -213,8 +215,7 @@ constexpr MapBuffer::Key NATIVE_DRAWABLE_COLOR = 2; constexpr MapBuffer::Key NATIVE_DRAWABLE_BORDERLESS = 3; constexpr MapBuffer::Key NATIVE_DRAWABLE_RIPPLE_RADIUS = 4; -MapBuffer convertNativeBackground( - butter::optional const &value) { +MapBuffer convertNativeBackground(std::optional const &value) { if (!value.has_value()) { return MapBufferBuilder::EMPTY(); } diff --git a/ReactCommon/butter/optional.h b/ReactCommon/butter/optional.h deleted file mode 100644 index e887918f19d..00000000000 --- a/ReactCommon/butter/optional.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -#pragma once - -#include - -#if defined(BUTTER_USE_FOLLY_CONTAINERS) || __cplusplus < 202000L - -#include - -#else - -#include - -#endif - -namespace facebook { -namespace butter { - -#if defined(BUTTER_USE_FOLLY_CONTAINERS) || __cplusplus < 202000L - -template -using optional = folly::Optional; - -#else - -template -using optional = std::optional; - -#endif - -} // namespace butter -} // namespace facebook diff --git a/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.cpp b/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.cpp index dc815408e8c..e1198fd368d 100644 --- a/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.cpp +++ b/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.cpp @@ -173,7 +173,7 @@ bool LayoutAnimationKeyFrameManager::shouldOverridePullTransaction() const { return shouldAnimateFrame(); } -butter::optional +std::optional LayoutAnimationKeyFrameManager::pullTransaction( SurfaceId surfaceId, MountingTransaction::Number transactionNumber, @@ -251,7 +251,7 @@ LayoutAnimationKeyFrameManager::pullTransaction( surfaceId, mutations, conflictingAnimations); // Are we animating this list of mutations? - butter::optional currentAnimation{}; + std::optional currentAnimation{}; { std::lock_guard lock(currentAnimationMutex_); if (currentAnimation_) { @@ -260,7 +260,7 @@ LayoutAnimationKeyFrameManager::pullTransaction( } } - if (currentAnimation.hasValue()) { + if (currentAnimation.has_value()) { LayoutAnimation animation = std::move(currentAnimation).value(); animation.surfaceId = surfaceId; animation.startTime = now; @@ -321,7 +321,7 @@ LayoutAnimationKeyFrameManager::pullTransaction( continue; } - butter::optional executeMutationImmediately{}; + std::optional executeMutationImmediately{}; bool isRemoveReinserted = mutation.type == ShadowViewMutation::Type::Remove && @@ -703,7 +703,7 @@ LayoutAnimationKeyFrameManager::pullTransaction( keyFramesToAnimate.push_back(keyFrame); } - if (executeMutationImmediately.hasValue()) { + if (executeMutationImmediately.has_value()) { PrintMutationInstruction( "Queue Up For Immediate Execution", *executeMutationImmediately); immediateMutations.push_back(*executeMutationImmediately); @@ -1064,7 +1064,7 @@ LayoutAnimationKeyFrameManager::pullTransaction( void LayoutAnimationKeyFrameManager::uiManagerDidConfigureNextLayoutAnimation( LayoutAnimation layoutAnimation) const { - currentAnimation_ = butter::optional{layoutAnimation}; + currentAnimation_ = std::optional{layoutAnimation}; } void LayoutAnimationKeyFrameManager::setLayoutAnimationStatusDelegate( diff --git a/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.h b/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.h index 9998b3cc147..56d283a3f22 100644 --- a/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.h +++ b/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.h @@ -8,7 +8,6 @@ #pragma once #include -#include #include #include #include @@ -20,6 +19,8 @@ #include #include +#include + namespace facebook { namespace react { @@ -67,7 +68,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. - butter::optional pullTransaction( + std::optional pullTransaction( SurfaceId surfaceId, MountingTransaction::Number number, TransactionTelemetry const &telemetry, @@ -95,7 +96,7 @@ class LayoutAnimationKeyFrameManager : public UIManagerAnimationDelegate, protected: SharedComponentDescriptorRegistry componentDescriptorRegistry_; - mutable butter::optional currentAnimation_{}; + mutable std::optional currentAnimation_{}; mutable std::mutex currentAnimationMutex_; /** diff --git a/ReactCommon/react/renderer/animations/conversions.h b/ReactCommon/react/renderer/animations/conversions.h index e9c3275e3d8..021399b9f7f 100644 --- a/ReactCommon/react/renderer/animations/conversions.h +++ b/ReactCommon/react/renderer/animations/conversions.h @@ -5,15 +5,15 @@ * LICENSE file in the root directory of this source tree. */ -#include +#include #include -#include +#include namespace facebook { namespace react { -static inline butter::optional parseAnimationType( +static inline std::optional parseAnimationType( std::string param) { if (param == "spring") { return AnimationType::Spring; @@ -38,7 +38,7 @@ static inline butter::optional parseAnimationType( return {}; } -static inline butter::optional parseAnimationProperty( +static inline std::optional parseAnimationProperty( std::string param) { if (param == "opacity") { return AnimationProperty::Opacity; @@ -57,7 +57,7 @@ static inline butter::optional parseAnimationProperty( return {}; } -static inline butter::optional parseAnimationConfig( +static inline std::optional parseAnimationConfig( folly::dynamic const &config, double defaultDuration, bool parsePropertyType) { @@ -163,7 +163,7 @@ static inline butter::optional parseAnimationConfig( } } - return butter::optional(AnimationConfig{ + return std::optional(AnimationConfig{ *animationType, animationProperty, duration, @@ -173,8 +173,8 @@ static inline butter::optional parseAnimationConfig( } // Parse animation config from JS -static inline butter::optional -parseLayoutAnimationConfig(folly::dynamic const &config) { +static inline std::optional 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() - ? butter::optional(AnimationConfig{}) + ? std::optional(AnimationConfig{}) : parseAnimationConfig(createConfigIt->second, duration, true); const auto updateConfigIt = config.find("update"); const auto updateConfig = updateConfigIt == config.items().end() - ? butter::optional(AnimationConfig{}) + ? std::optional(AnimationConfig{}) : parseAnimationConfig(updateConfigIt->second, duration, false); const auto deleteConfigIt = config.find("delete"); const auto deleteConfig = deleteConfigIt == config.items().end() - ? butter::optional(AnimationConfig{}) + ? std::optional(AnimationConfig{}) : parseAnimationConfig(deleteConfigIt->second, duration, true); if (!createConfig || !updateConfig || !deleteConfig) { diff --git a/ReactCommon/react/renderer/animations/tests/LayoutAnimationTest.cpp b/ReactCommon/react/renderer/animations/tests/LayoutAnimationTest.cpp index e5eef16ba07..09f78e23364 100644 --- a/ReactCommon/react/renderer/animations/tests/LayoutAnimationTest.cpp +++ b/ReactCommon/react/renderer/animations/tests/LayoutAnimationTest.cpp @@ -273,7 +273,7 @@ static void testShadowNodeTreeLifeCycleLayoutAnimations( auto transaction = animationDriver->pullTransaction(surfaceId, 0, telemetry, {}); // We have something to validate. - if (transaction.hasValue()) { + if (transaction.has_value()) { auto mutations = transaction->getMutations(); // Mutating the view tree. diff --git a/ReactCommon/react/renderer/attributedstring/TextAttributes.cpp b/ReactCommon/react/renderer/attributedstring/TextAttributes.cpp index b947137be63..3728f0c3612 100644 --- a/ReactCommon/react/renderer/attributedstring/TextAttributes.cpp +++ b/ReactCommon/react/renderer/attributedstring/TextAttributes.cpp @@ -37,20 +37,20 @@ void TextAttributes::apply(TextAttributes textAttributes) { fontSizeMultiplier = !std::isnan(textAttributes.fontSizeMultiplier) ? textAttributes.fontSizeMultiplier : fontSizeMultiplier; - fontWeight = textAttributes.fontWeight.hasValue() ? textAttributes.fontWeight - : fontWeight; - fontStyle = textAttributes.fontStyle.hasValue() ? textAttributes.fontStyle - : fontStyle; - fontVariant = textAttributes.fontVariant.hasValue() + fontWeight = textAttributes.fontWeight.has_value() ? textAttributes.fontWeight + : fontWeight; + fontStyle = textAttributes.fontStyle.has_value() ? textAttributes.fontStyle + : fontStyle; + fontVariant = textAttributes.fontVariant.has_value() ? textAttributes.fontVariant : fontVariant; - allowFontScaling = textAttributes.allowFontScaling.hasValue() + allowFontScaling = textAttributes.allowFontScaling.has_value() ? textAttributes.allowFontScaling : allowFontScaling; letterSpacing = !std::isnan(textAttributes.letterSpacing) ? textAttributes.letterSpacing : letterSpacing; - textTransform = textAttributes.textTransform.hasValue() + textTransform = textAttributes.textTransform.has_value() ? textAttributes.textTransform : textTransform; @@ -58,9 +58,9 @@ void TextAttributes::apply(TextAttributes textAttributes) { lineHeight = !std::isnan(textAttributes.lineHeight) ? textAttributes.lineHeight : lineHeight; - alignment = textAttributes.alignment.hasValue() ? textAttributes.alignment - : alignment; - baseWritingDirection = textAttributes.baseWritingDirection.hasValue() + alignment = textAttributes.alignment.has_value() ? textAttributes.alignment + : alignment; + baseWritingDirection = textAttributes.baseWritingDirection.has_value() ? textAttributes.baseWritingDirection : baseWritingDirection; @@ -68,15 +68,15 @@ void TextAttributes::apply(TextAttributes textAttributes) { textDecorationColor = textAttributes.textDecorationColor ? textAttributes.textDecorationColor : textDecorationColor; - textDecorationLineType = textAttributes.textDecorationLineType.hasValue() + textDecorationLineType = textAttributes.textDecorationLineType.has_value() ? textAttributes.textDecorationLineType : textDecorationLineType; - textDecorationStyle = textAttributes.textDecorationStyle.hasValue() + textDecorationStyle = textAttributes.textDecorationStyle.has_value() ? textAttributes.textDecorationStyle : textDecorationStyle; // Shadow - textShadowOffset = textAttributes.textShadowOffset.hasValue() + textShadowOffset = textAttributes.textShadowOffset.has_value() ? textAttributes.textShadowOffset.value() : textShadowOffset; textShadowRadius = !std::isnan(textAttributes.textShadowRadius) @@ -87,13 +87,13 @@ void TextAttributes::apply(TextAttributes textAttributes) { : textShadowColor; // Special - isHighlighted = textAttributes.isHighlighted.hasValue() + isHighlighted = textAttributes.isHighlighted.has_value() ? textAttributes.isHighlighted : isHighlighted; - layoutDirection = textAttributes.layoutDirection.hasValue() + layoutDirection = textAttributes.layoutDirection.has_value() ? textAttributes.layoutDirection : layoutDirection; - accessibilityRole = textAttributes.accessibilityRole.hasValue() + accessibilityRole = textAttributes.accessibilityRole.has_value() ? textAttributes.accessibilityRole : accessibilityRole; } diff --git a/ReactCommon/react/renderer/attributedstring/TextAttributes.h b/ReactCommon/react/renderer/attributedstring/TextAttributes.h index 8a86d01f3b6..82b8547507e 100644 --- a/ReactCommon/react/renderer/attributedstring/TextAttributes.h +++ b/ReactCommon/react/renderer/attributedstring/TextAttributes.h @@ -9,8 +9,8 @@ #include #include +#include -#include #include #include #include @@ -46,38 +46,38 @@ class TextAttributes : public DebugStringConvertible { std::string fontFamily{""}; Float fontSize{std::numeric_limits::quiet_NaN()}; Float fontSizeMultiplier{std::numeric_limits::quiet_NaN()}; - butter::optional fontWeight{}; - butter::optional fontStyle{}; - butter::optional fontVariant{}; - butter::optional allowFontScaling{}; + std::optional fontWeight{}; + std::optional fontStyle{}; + std::optional fontVariant{}; + std::optional allowFontScaling{}; Float letterSpacing{std::numeric_limits::quiet_NaN()}; - butter::optional textTransform{}; + std::optional textTransform{}; // Paragraph Styles Float lineHeight{std::numeric_limits::quiet_NaN()}; - butter::optional alignment{}; - butter::optional baseWritingDirection{}; + std::optional alignment{}; + std::optional baseWritingDirection{}; // Decoration SharedColor textDecorationColor{}; - butter::optional textDecorationLineType{}; - butter::optional textDecorationStyle{}; + std::optional textDecorationLineType{}; + std::optional textDecorationStyle{}; // Shadow // TODO: Use `Point` type instead of `Size` for `textShadowOffset` attribute. - butter::optional textShadowOffset{}; + std::optional textShadowOffset{}; Float textShadowRadius{std::numeric_limits::quiet_NaN()}; SharedColor textShadowColor{}; // Special - butter::optional isHighlighted{}; + std::optional 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. - butter::optional layoutDirection{}; - butter::optional accessibilityRole{}; + std::optional layoutDirection{}; + std::optional accessibilityRole{}; #pragma mark - Operations diff --git a/ReactCommon/react/renderer/attributedstring/conversions.h b/ReactCommon/react/renderer/attributedstring/conversions.h index c8b5a9ab2dd..96cbc0c5d7e 100644 --- a/ReactCommon/react/renderer/attributedstring/conversions.h +++ b/ReactCommon/react/renderer/attributedstring/conversions.h @@ -860,7 +860,7 @@ inline folly::dynamic toDynamic(const TextAttributes &textAttributes) { if (!std::isnan(textAttributes.letterSpacing)) { _textAttributes("letterSpacing", textAttributes.letterSpacing); } - if (textAttributes.textTransform.hasValue()) { + if (textAttributes.textTransform.has_value()) { _textAttributes("textTransform", toString(*textAttributes.textTransform)); } if (!std::isnan(textAttributes.lineHeight)) { diff --git a/ReactCommon/react/renderer/components/text/ParagraphShadowNode.h b/ReactCommon/react/renderer/components/text/ParagraphShadowNode.h index e4db0f76b34..42ef650a3cf 100644 --- a/ReactCommon/react/renderer/components/text/ParagraphShadowNode.h +++ b/ReactCommon/react/renderer/components/text/ParagraphShadowNode.h @@ -102,7 +102,7 @@ class ParagraphShadowNode final : public ConcreteViewShadowNode< /* * Cached content of the subtree started from the node. */ - mutable butter::optional content_{}; + mutable std::optional content_{}; }; } // namespace react diff --git a/ReactCommon/react/renderer/components/textinput/androidtextinput/react/renderer/components/androidtextinput/AndroidTextInputShadowNode.h b/ReactCommon/react/renderer/components/textinput/androidtextinput/react/renderer/components/androidtextinput/AndroidTextInputShadowNode.h index 90ae122f5ed..d79d8e51059 100644 --- a/ReactCommon/react/renderer/components/textinput/androidtextinput/react/renderer/components/androidtextinput/AndroidTextInputShadowNode.h +++ b/ReactCommon/react/renderer/components/textinput/androidtextinput/react/renderer/components/androidtextinput/AndroidTextInputShadowNode.h @@ -81,7 +81,7 @@ class AndroidTextInputShadowNode final : public ConcreteViewShadowNode< * Cached attributed string that represents the content of the subtree started * from the node. */ - mutable butter::optional cachedAttributedString_{}; + mutable std::optional cachedAttributedString_{}; }; } // namespace react diff --git a/ReactCommon/react/renderer/components/textinput/iostextinput/TextInputProps.cpp b/ReactCommon/react/renderer/components/textinput/iostextinput/TextInputProps.cpp index 65355be1d64..a8716286aee 100644 --- a/ReactCommon/react/renderer/components/textinput/iostextinput/TextInputProps.cpp +++ b/ReactCommon/react/renderer/components/textinput/iostextinput/TextInputProps.cpp @@ -87,7 +87,7 @@ TextInputProps::TextInputProps( rawProps, "selection", sourceProps.selection, - butter::optional())), + std::optional())), inputAccessoryViewID(convertRawProp( context, rawProps, diff --git a/ReactCommon/react/renderer/components/textinput/iostextinput/TextInputProps.h b/ReactCommon/react/renderer/components/textinput/iostextinput/TextInputProps.h index 1169277c647..a72b63063b9 100644 --- a/ReactCommon/react/renderer/components/textinput/iostextinput/TextInputProps.h +++ b/ReactCommon/react/renderer/components/textinput/iostextinput/TextInputProps.h @@ -58,7 +58,7 @@ class TextInputProps final : public ViewProps, public BaseTextProps { int const mostRecentEventCount{0}; bool autoFocus{false}; - butter::optional selection{}; + std::optional selection{}; std::string const inputAccessoryViewID{}; diff --git a/ReactCommon/react/renderer/components/textinput/iostextinput/primitives.h b/ReactCommon/react/renderer/components/textinput/iostextinput/primitives.h index 54e241a2112..1747a98bf4c 100644 --- a/ReactCommon/react/renderer/components/textinput/iostextinput/primitives.h +++ b/ReactCommon/react/renderer/components/textinput/iostextinput/primitives.h @@ -7,10 +7,9 @@ #pragma once +#include #include -#include - namespace facebook { namespace react { @@ -106,7 +105,7 @@ class TextInputTraits final { * iOS & Android * Default value: `empty` (`null`). */ - butter::optional autoCorrect{}; + std::optional autoCorrect{}; /* * iOS & Android @@ -141,7 +140,7 @@ class TextInputTraits final { * Can be empty (`null` in JavaScript) which means `default`. * Default value: `empty` (`null`). */ - butter::optional spellCheck{}; + std::optional spellCheck{}; /* * iOS & Android diff --git a/ReactCommon/react/renderer/components/view/AccessibilityPrimitives.h b/ReactCommon/react/renderer/components/view/AccessibilityPrimitives.h index 2a692bdbeae..abc5df00883 100644 --- a/ReactCommon/react/renderer/components/view/AccessibilityPrimitives.h +++ b/ReactCommon/react/renderer/components/view/AccessibilityPrimitives.h @@ -7,8 +7,8 @@ #pragma once -#include #include +#include #include #include @@ -51,7 +51,7 @@ constexpr enum AccessibilityTraits operator&( struct AccessibilityAction { std::string name{""}; - butter::optional label{}; + std::optional label{}; }; inline static bool operator==( @@ -105,10 +105,10 @@ inline static bool operator!=( } struct AccessibilityValue { - butter::optional min; - butter::optional max; - butter::optional now; - butter::optional text{}; + std::optional min; + std::optional max; + std::optional now; + std::optional text{}; }; constexpr bool operator==( diff --git a/ReactCommon/react/renderer/components/view/ViewProps.h b/ReactCommon/react/renderer/components/view/ViewProps.h index 7e131604bdf..be31a70f787 100644 --- a/ReactCommon/react/renderer/components/view/ViewProps.h +++ b/ReactCommon/react/renderer/components/view/ViewProps.h @@ -17,6 +17,8 @@ #include #include +#include + namespace facebook { namespace react { @@ -55,7 +57,7 @@ class ViewProps : public YogaStylableProps, public AccessibilityProps { Transform transform{}; BackfaceVisibility backfaceVisibility{}; bool shouldRasterize{}; - butter::optional zIndex{}; + std::optional zIndex{}; // Events PointerEventsMode pointerEvents{}; @@ -72,8 +74,8 @@ class ViewProps : public YogaStylableProps, public AccessibilityProps { #ifdef ANDROID - butter::optional nativeBackground{}; - butter::optional nativeForeground{}; + std::optional nativeBackground{}; + std::optional nativeForeground{}; bool focusable{false}; bool hasTVPreferredFocus{false}; diff --git a/ReactCommon/react/renderer/components/view/YogaLayoutableShadowNode.cpp b/ReactCommon/react/renderer/components/view/YogaLayoutableShadowNode.cpp index 90d6a808ea5..29ef3edf2e8 100644 --- a/ReactCommon/react/renderer/components/view/YogaLayoutableShadowNode.cpp +++ b/ReactCommon/react/renderer/components/view/YogaLayoutableShadowNode.cpp @@ -701,44 +701,44 @@ void YogaLayoutableShadowNode::swapLeftAndRightInViewProps( auto &props = const_cast(typedCasting); // Swap border node values, borderRadii, borderColors and borderStyles. - if (props.borderRadii.topLeft.hasValue()) { + if (props.borderRadii.topLeft.has_value()) { props.borderRadii.topStart = props.borderRadii.topLeft; - props.borderRadii.topLeft.clear(); + props.borderRadii.topLeft.reset(); } - if (props.borderRadii.bottomLeft.hasValue()) { + if (props.borderRadii.bottomLeft.has_value()) { props.borderRadii.bottomStart = props.borderRadii.bottomLeft; - props.borderRadii.bottomLeft.clear(); + props.borderRadii.bottomLeft.reset(); } - if (props.borderRadii.topRight.hasValue()) { + if (props.borderRadii.topRight.has_value()) { props.borderRadii.topEnd = props.borderRadii.topRight; - props.borderRadii.topRight.clear(); + props.borderRadii.topRight.reset(); } - if (props.borderRadii.bottomRight.hasValue()) { + if (props.borderRadii.bottomRight.has_value()) { props.borderRadii.bottomEnd = props.borderRadii.bottomRight; - props.borderRadii.bottomRight.clear(); + props.borderRadii.bottomRight.reset(); } - if (props.borderColors.left.hasValue()) { + if (props.borderColors.left.has_value()) { props.borderColors.start = props.borderColors.left; - props.borderColors.left.clear(); + props.borderColors.left.reset(); } - if (props.borderColors.right.hasValue()) { + if (props.borderColors.right.has_value()) { props.borderColors.end = props.borderColors.right; - props.borderColors.right.clear(); + props.borderColors.right.reset(); } - if (props.borderStyles.left.hasValue()) { + if (props.borderStyles.left.has_value()) { props.borderStyles.start = props.borderStyles.left; - props.borderStyles.left.clear(); + props.borderStyles.left.reset(); } - if (props.borderStyles.right.hasValue()) { + if (props.borderStyles.right.has_value()) { props.borderStyles.end = props.borderStyles.right; - props.borderStyles.right.clear(); + props.borderStyles.right.reset(); } YGStyle::Edges const &border = props.yogaStyle.border(); diff --git a/ReactCommon/react/renderer/components/view/conversions.h b/ReactCommon/react/renderer/components/view/conversions.h index 3820a872dc9..2da720e2e59 100644 --- a/ReactCommon/react/renderer/components/view/conversions.h +++ b/ReactCommon/react/renderer/components/view/conversions.h @@ -8,7 +8,6 @@ #pragma once #include -#include #include #include #include @@ -23,6 +22,7 @@ #include #include #include +#include namespace facebook { namespace react { @@ -98,9 +98,9 @@ inline YGValue yogaStyleValueFromFloat( return {(float)value, unit}; } -inline butter::optional optionalFloatFromYogaValue( +inline std::optional optionalFloatFromYogaValue( const YGValue value, - butter::optional base = {}) { + std::optional base = {}) { switch (value.unit) { case YGUnitUndefined: return {}; @@ -108,9 +108,8 @@ inline butter::optional optionalFloatFromYogaValue( return floatFromYogaFloat(value.value); case YGUnitPercent: return base.has_value() - ? butter::optional( - base.value() * floatFromYogaFloat(value.value)) - : butter::optional(); + ? std::optional(base.value() * floatFromYogaFloat(value.value)) + : std::optional(); case YGUnitAuto: return {}; } diff --git a/ReactCommon/react/renderer/components/view/primitives.h b/ReactCommon/react/renderer/components/view/primitives.h index 37ba307a0e2..86be3728f40 100644 --- a/ReactCommon/react/renderer/components/view/primitives.h +++ b/ReactCommon/react/renderer/components/view/primitives.h @@ -7,12 +7,13 @@ #pragma once -#include #include #include + #include #include #include +#include namespace facebook { namespace react { @@ -74,7 +75,7 @@ enum class BorderStyle { Solid, Dotted, Dashed }; template struct CascadedRectangleEdges { using Counterpart = RectangleEdges; - using OptionalT = butter::optional; + using OptionalT = std::optional; OptionalT left{}; OptionalT top{}; @@ -135,7 +136,7 @@ struct CascadedRectangleEdges { template struct CascadedRectangleCorners { using Counterpart = RectangleCorners; - using OptionalT = butter::optional; + using OptionalT = std::optional; OptionalT topLeft{}; OptionalT topRight{}; @@ -236,9 +237,9 @@ struct NativeDrawable { }; struct Ripple { - butter::optional color{}; + std::optional color{}; bool borderless{false}; - butter::optional rippleRadius{}; + std::optional rippleRadius{}; bool operator==(const Ripple &rhs) const { return std::tie(this->color, this->borderless, this->rippleRadius) == diff --git a/ReactCommon/react/renderer/components/view/propsConversions.h b/ReactCommon/react/renderer/components/view/propsConversions.h index 36d6966a4f1..4bcc461a73c 100644 --- a/ReactCommon/react/renderer/components/view/propsConversions.h +++ b/ReactCommon/react/renderer/components/view/propsConversions.h @@ -11,6 +11,8 @@ #include #include +#include + namespace facebook { namespace react { @@ -633,7 +635,7 @@ static inline void fromRawValue( NativeDrawable::Ripple{ .color = color != map.end() && color->second.hasType() ? (int32_t)color->second - : butter::optional{}, + : std::optional{}, .borderless = borderless != map.end() && borderless->second.hasType() ? (bool)borderless->second @@ -641,7 +643,7 @@ static inline void fromRawValue( .rippleRadius = rippleRadius != map.end() && rippleRadius->second.hasType() ? (Float)rippleRadius->second - : butter::optional{}, + : std::optional{}, }, }; } else { diff --git a/ReactCommon/react/renderer/core/RawProps.h b/ReactCommon/react/renderer/core/RawProps.h index 99b4a7e1eb9..3b28256f4d4 100644 --- a/ReactCommon/react/renderer/core/RawProps.h +++ b/ReactCommon/react/renderer/core/RawProps.h @@ -8,9 +8,9 @@ #pragma once #include +#include #include -#include #include #include diff --git a/ReactCommon/react/renderer/core/propsConversions.h b/ReactCommon/react/renderer/core/propsConversions.h index 34881004c8e..0095a3989f4 100644 --- a/ReactCommon/react/renderer/core/propsConversions.h +++ b/ReactCommon/react/renderer/core/propsConversions.h @@ -7,7 +7,8 @@ #pragma once -#include +#include + #include #include #include @@ -106,12 +107,12 @@ T convertRawProp( } template -static butter::optional convertRawProp( +static std::optional convertRawProp( const PropsParserContext &context, RawProps const &rawProps, char const *name, - butter::optional const &sourceValue, - butter::optional const &defaultValue, + std::optional const &sourceValue, + std::optional const &defaultValue, char const *namePrefix = nullptr, char const *nameSuffix = nullptr) { const auto *rawValue = rawProps.at(name, namePrefix, nameSuffix); @@ -128,7 +129,7 @@ static butter::optional convertRawProp( T result; fromRawValue(context, *rawValue, result); - return butter::optional{result}; + return std::optional{result}; } } // namespace react diff --git a/ReactCommon/react/renderer/debug/debugStringConvertibleUtils.h b/ReactCommon/react/renderer/debug/debugStringConvertibleUtils.h index fa8a5f8b19a..6fde6333157 100644 --- a/ReactCommon/react/renderer/debug/debugStringConvertibleUtils.h +++ b/ReactCommon/react/renderer/debug/debugStringConvertibleUtils.h @@ -7,9 +7,9 @@ #pragma once -#include #include #include +#include #include #include @@ -34,9 +34,9 @@ debugStringConvertibleItem(std::string name, T value, T defaultValue = {}) { template inline SharedDebugStringConvertible debugStringConvertibleItem( std::string name, - butter::optional value, + std::optional value, T defaultValue = {}) { - if (!value.hasValue()) { + if (!value.has_value()) { return nullptr; } diff --git a/ReactCommon/react/renderer/graphics/platform/ios/Color.h b/ReactCommon/react/renderer/graphics/platform/ios/Color.h index 2e62adb8fc2..0a50fa455ad 100644 --- a/ReactCommon/react/renderer/graphics/platform/ios/Color.h +++ b/ReactCommon/react/renderer/graphics/platform/ios/Color.h @@ -8,6 +8,7 @@ #pragma once #include +#include #include #include diff --git a/ReactCommon/react/renderer/mounting/MountingCoordinator.cpp b/ReactCommon/react/renderer/mounting/MountingCoordinator.cpp index 6546e0c11ad..8dc8f97ca60 100644 --- a/ReactCommon/react/renderer/mounting/MountingCoordinator.cpp +++ b/ReactCommon/react/renderer/mounting/MountingCoordinator.cpp @@ -75,11 +75,11 @@ void MountingCoordinator::resetLatestRevision() const { lastRevision_.reset(); } -butter::optional MountingCoordinator::pullTransaction() +std::optional MountingCoordinator::pullTransaction() const { std::lock_guard lock(mutex_); - auto transaction = butter::optional{}; + auto transaction = std::optional{}; // Base case if (lastRevision_.has_value()) { diff --git a/ReactCommon/react/renderer/mounting/MountingCoordinator.h b/ReactCommon/react/renderer/mounting/MountingCoordinator.h index 6d6e1e4623d..ba66f6a11dc 100644 --- a/ReactCommon/react/renderer/mounting/MountingCoordinator.h +++ b/ReactCommon/react/renderer/mounting/MountingCoordinator.h @@ -7,8 +7,8 @@ #pragma once -#include #include +#include #include #include @@ -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. */ - butter::optional pullTransaction() const; + std::optional 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 butter::optional lastRevision_{}; + mutable std::optional lastRevision_{}; mutable MountingTransaction::Number number_{0}; mutable std::condition_variable signal_; mutable std::weak_ptr diff --git a/ReactCommon/react/renderer/mounting/MountingOverrideDelegate.h b/ReactCommon/react/renderer/mounting/MountingOverrideDelegate.h index 67c2b876cb0..807cd9f0130 100644 --- a/ReactCommon/react/renderer/mounting/MountingOverrideDelegate.h +++ b/ReactCommon/react/renderer/mounting/MountingOverrideDelegate.h @@ -36,7 +36,7 @@ class MountingOverrideDelegate { * @param mountingCoordinator * @return */ - virtual butter::optional pullTransaction( + virtual std::optional pullTransaction( SurfaceId surfaceId, MountingTransaction::Number number, TransactionTelemetry const &telemetry, diff --git a/ReactCommon/react/renderer/mounting/ShadowTreeRevision.h b/ReactCommon/react/renderer/mounting/ShadowTreeRevision.h index 73234689489..4c7075ec7a5 100644 --- a/ReactCommon/react/renderer/mounting/ShadowTreeRevision.h +++ b/ReactCommon/react/renderer/mounting/ShadowTreeRevision.h @@ -7,8 +7,6 @@ #pragma once -#include - #include #include #include diff --git a/ReactCommon/react/renderer/runtimescheduler/Task.h b/ReactCommon/react/renderer/runtimescheduler/Task.h index c1c006042f6..76c52a9ff5e 100644 --- a/ReactCommon/react/renderer/runtimescheduler/Task.h +++ b/ReactCommon/react/renderer/runtimescheduler/Task.h @@ -7,11 +7,12 @@ #pragma once -#include #include #include #include +#include + namespace facebook { namespace react { @@ -29,7 +30,7 @@ struct Task final { friend TaskPriorityComparer; SchedulerPriority priority; - butter::optional callback; + std::optional callback; RuntimeSchedulerClock::time_point expirationTime; jsi::Value execute(jsi::Runtime &runtime); diff --git a/ReactCommon/react/renderer/scheduler/Scheduler.cpp b/ReactCommon/react/renderer/scheduler/Scheduler.cpp index f56b10a9753..f33cf522d4a 100644 --- a/ReactCommon/react/renderer/scheduler/Scheduler.cpp +++ b/ReactCommon/react/renderer/scheduler/Scheduler.cpp @@ -42,8 +42,7 @@ Scheduler::Scheduler( "ReactNativeConfig"); // Creating a container for future `EventDispatcher` instance. - eventDispatcher_ = - std::make_shared>(); + eventDispatcher_ = std::make_shared>(); auto uiManager = std::make_shared( runtimeExecutor_, schedulerToolbox.backgroundExecutor, contextContainer_); @@ -62,7 +61,7 @@ Scheduler::Scheduler( contextContainer_->find>( "RuntimeScheduler"); auto runtimeScheduler = - (enableCallImmediates && weakRuntimeScheduler.hasValue()) + (enableCallImmediates && weakRuntimeScheduler.has_value()) ? weakRuntimeScheduler.value().lock() : nullptr; diff --git a/ReactCommon/react/renderer/scheduler/Scheduler.h b/ReactCommon/react/renderer/scheduler/Scheduler.h index 488a656619f..30dad1f75ad 100644 --- a/ReactCommon/react/renderer/scheduler/Scheduler.h +++ b/ReactCommon/react/renderer/scheduler/Scheduler.h @@ -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> eventDispatcher_; + std::shared_ptr> eventDispatcher_; /** * Hold onto ContextContainer. See SchedulerToolbox. diff --git a/ReactCommon/react/renderer/textlayoutmanager/platform/ios/RCTAttributedTextUtils.mm b/ReactCommon/react/renderer/textlayoutmanager/platform/ios/RCTAttributedTextUtils.mm index 1c6aa270ea5..b3b7064f9cc 100644 --- a/ReactCommon/react/renderer/textlayoutmanager/platform/ios/RCTAttributedTextUtils.mm +++ b/ReactCommon/react/renderer/textlayoutmanager/platform/ios/RCTAttributedTextUtils.mm @@ -62,13 +62,13 @@ inline static UIFont *RCTEffectiveFontFromTextAttributes(const TextAttributes &t RCTFontProperties fontProperties; fontProperties.family = fontFamily; fontProperties.size = textAttributes.fontSize; - fontProperties.style = textAttributes.fontStyle.hasValue() + fontProperties.style = textAttributes.fontStyle.has_value() ? RCTFontStyleFromFontStyle(textAttributes.fontStyle.value()) : RCTFontStyleUndefined; - fontProperties.variant = textAttributes.fontVariant.hasValue() + fontProperties.variant = textAttributes.fontVariant.has_value() ? RCTFontVariantFromFontVariant(textAttributes.fontVariant.value()) : RCTFontVariantUndefined; - fontProperties.weight = textAttributes.fontWeight.hasValue() + fontProperties.weight = textAttributes.fontWeight.has_value() ? RCTUIFontWeightFromInteger((NSInteger)textAttributes.fontWeight.value()) : NAN; fontProperties.sizeMultiplier = textAttributes.fontSizeMultiplier; @@ -136,7 +136,7 @@ NSDictionary *RCTNSTextAttributesFromTextAttributes(T // Paragraph Style NSMutableParagraphStyle *paragraphStyle = [NSMutableParagraphStyle new]; BOOL isParagraphStyleUsed = NO; - if (textAttributes.alignment.hasValue()) { + if (textAttributes.alignment.has_value()) { TextAlignment textAlignment = textAttributes.alignment.value_or(TextAlignment::Natural); if (textAttributes.layoutDirection.value_or(LayoutDirection::LeftToRight) == LayoutDirection::RightToLeft) { if (textAlignment == TextAlignment::Right) { @@ -150,7 +150,7 @@ NSDictionary *RCTNSTextAttributesFromTextAttributes(T isParagraphStyleUsed = YES; } - if (textAttributes.baseWritingDirection.hasValue()) { + if (textAttributes.baseWritingDirection.has_value()) { paragraphStyle.baseWritingDirection = RCTNSWritingDirectionFromWritingDirection(textAttributes.baseWritingDirection.value()); isParagraphStyleUsed = YES; @@ -198,7 +198,7 @@ NSDictionary *RCTNSTextAttributesFromTextAttributes(T } // Shadow - if (textAttributes.textShadowOffset.hasValue()) { + if (textAttributes.textShadowOffset.has_value()) { auto textShadowOffset = textAttributes.textShadowOffset.value(); NSShadow *shadow = [NSShadow new]; shadow.shadowOffset = CGSize{textShadowOffset.width, textShadowOffset.height}; @@ -212,7 +212,7 @@ NSDictionary *RCTNSTextAttributesFromTextAttributes(T attributes[RCTAttributedStringIsHighlightedAttributeName] = @YES; } - if (textAttributes.accessibilityRole.hasValue()) { + if (textAttributes.accessibilityRole.has_value()) { auto accessibilityRole = textAttributes.accessibilityRole.value(); switch (accessibilityRole) { case AccessibilityRole::None: @@ -334,7 +334,7 @@ NSAttributedString *RCTNSAttributedStringFromAttributedString(const AttributedSt } else { NSString *string = [NSString stringWithCString:fragment.string.c_str() encoding:NSUTF8StringEncoding]; - if (fragment.textAttributes.textTransform.hasValue()) { + if (fragment.textAttributes.textTransform.has_value()) { auto textTransform = fragment.textAttributes.textTransform.value(); string = RCTNSStringFromStringApplyingTextTransform(string, textTransform); } diff --git a/ReactCommon/react/utils/ContextContainer.h b/ReactCommon/react/utils/ContextContainer.h index bbf99a24891..636736afec7 100644 --- a/ReactCommon/react/utils/ContextContainer.h +++ b/ReactCommon/react/utils/ContextContainer.h @@ -9,11 +9,11 @@ #include #include +#include #include #include #include -#include #include #include @@ -92,7 +92,7 @@ class ContextContainer final { * Returns an empty optional if the instance could not be found. */ template - butter::optional find(std::string const &key) const { + std::optional find(std::string const &key) const { std::shared_lock lock(mutex_); auto iterator = instances_.find(key); diff --git a/ReactCommon/react/utils/SimpleThreadSafeCache.h b/ReactCommon/react/utils/SimpleThreadSafeCache.h index f5b71fec499..3954d951f0f 100644 --- a/ReactCommon/react/utils/SimpleThreadSafeCache.h +++ b/ReactCommon/react/utils/SimpleThreadSafeCache.h @@ -8,8 +8,8 @@ #include #include #include +#include -#include #include namespace facebook { @@ -48,7 +48,7 @@ class SimpleThreadSafeCache { * If the value wasn't found in the cache, returns empty optional. * Can be called from any thread. */ - butter::optional get(const KeyT &key) const { + std::optional get(const KeyT &key) const { std::lock_guard lock(mutex_); auto iterator = map_.find(key); if (iterator == map_.end()) {