Use std::optional instead of butter::optional
Summary: changelog: Use std::optional instead of butter::optional Reviewed By: fkgozali Differential Revision: D33352680 fbshipit-source-id: 45a53fec181a6ffb6218909bc23348f7c9f21ec4
This commit is contained in:
Родитель
c2e4ae39b8
Коммит
a159416333
|
@ -566,8 +566,8 @@ using namespace facebook::react;
|
|||
|
||||
- (void)_restoreTextSelection
|
||||
{
|
||||
const auto selection = std::dynamic_pointer_cast<TextInputProps const>(_props)->selection.get_pointer();
|
||||
if (selection == nullptr) {
|
||||
auto const selection = std::dynamic_pointer_cast<TextInputProps const>(_props)->selection;
|
||||
if (!selection.has_value()) {
|
||||
return;
|
||||
}
|
||||
auto start = [_backedTextInputView positionFromPosition:_backedTextInputView.beginningOfDocument
|
||||
|
|
|
@ -7,8 +7,9 @@
|
|||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
#import <optional>
|
||||
|
||||
#import <React/RCTBackedTextInputViewProtocol.h>
|
||||
#import <butter/optional.h>
|
||||
#import <react/renderer/components/iostextinput/primitives.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
@ -17,7 +18,7 @@ void RCTCopyBackedTextInput(
|
|||
UIView<RCTBackedTextInputViewProtocol> *fromTextInput,
|
||||
UIView<RCTBackedTextInputViewProtocol> *toTextInput);
|
||||
|
||||
UITextAutocorrectionType RCTUITextAutocorrectionTypeFromOptionalBool(facebook::butter::optional<bool> autoCorrect);
|
||||
UITextAutocorrectionType RCTUITextAutocorrectionTypeFromOptionalBool(std::optional<bool> autoCorrect);
|
||||
|
||||
UITextAutocapitalizationType RCTUITextAutocapitalizationTypeFromAutocapitalizationType(
|
||||
facebook::react::AutocapitalizationType autocapitalizationType);
|
||||
|
@ -25,7 +26,7 @@ UITextAutocapitalizationType RCTUITextAutocapitalizationTypeFromAutocapitalizati
|
|||
UIKeyboardAppearance RCTUIKeyboardAppearanceFromKeyboardAppearance(
|
||||
facebook::react::KeyboardAppearance keyboardAppearance);
|
||||
|
||||
UITextSpellCheckingType RCTUITextSpellCheckingTypeFromOptionalBool(facebook::butter::optional<bool> spellCheck);
|
||||
UITextSpellCheckingType RCTUITextSpellCheckingTypeFromOptionalBool(std::optional<bool> spellCheck);
|
||||
|
||||
UITextFieldViewMode RCTUITextFieldViewModeFromTextInputAccessoryVisibilityMode(
|
||||
facebook::react::TextInputAccessoryVisibilityMode mode);
|
||||
|
|
|
@ -51,7 +51,7 @@ void RCTCopyBackedTextInput(
|
|||
[toTextInput setSelectedTextRange:fromTextInput.selectedTextRange notifyDelegate:NO];
|
||||
}
|
||||
|
||||
UITextAutocorrectionType RCTUITextAutocorrectionTypeFromOptionalBool(facebook::butter::optional<bool> autoCorrect)
|
||||
UITextAutocorrectionType RCTUITextAutocorrectionTypeFromOptionalBool(std::optional<bool> autoCorrect)
|
||||
{
|
||||
return autoCorrect.has_value() ? (*autoCorrect ? UITextAutocorrectionTypeYes : UITextAutocorrectionTypeNo)
|
||||
: UITextAutocorrectionTypeDefault;
|
||||
|
@ -84,7 +84,7 @@ UIKeyboardAppearance RCTUIKeyboardAppearanceFromKeyboardAppearance(KeyboardAppea
|
|||
}
|
||||
}
|
||||
|
||||
UITextSpellCheckingType RCTUITextSpellCheckingTypeFromOptionalBool(facebook::butter::optional<bool> spellCheck)
|
||||
UITextSpellCheckingType RCTUITextSpellCheckingTypeFromOptionalBool(std::optional<bool> spellCheck)
|
||||
{
|
||||
return spellCheck.has_value() ? (*spellCheck ? UITextSpellCheckingTypeYes : UITextSpellCheckingTypeNo)
|
||||
: UITextSpellCheckingTypeDefault;
|
||||
|
|
|
@ -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 =
|
||||
|
|
|
@ -281,7 +281,7 @@ static BackgroundExecutor RCTGetBackgroundExecutor()
|
|||
toolbox.componentRegistryFactory = componentRegistryFactory;
|
||||
|
||||
auto weakRuntimeScheduler = _contextContainer->find<std::weak_ptr<RuntimeScheduler>>("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<void(jsi::Runtime & runtime)> &&callback) {
|
||||
|
|
|
@ -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> _surfaceHandler;
|
||||
std::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.
|
||||
|
|
|
@ -13,6 +13,8 @@
|
|||
#include <react/renderer/mapbuffer/MapBuffer.h>
|
||||
#include <react/renderer/mapbuffer/MapBufferBuilder.h>
|
||||
|
||||
#include <optional>
|
||||
|
||||
namespace facebook {
|
||||
namespace react {
|
||||
|
||||
|
@ -122,7 +124,7 @@ MapBuffer convertAccessibilityState(AccessibilityState const &state) {
|
|||
inline void putOptionalColor(
|
||||
MapBufferBuilder &builder,
|
||||
MapBuffer::Key key,
|
||||
butter::optional<SharedColor> const &color) {
|
||||
std::optional<SharedColor> 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<Float> const &value) {
|
||||
std::optional<Float> 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<NativeDrawable> const &value) {
|
||||
MapBuffer convertNativeBackground(std::optional<NativeDrawable> const &value) {
|
||||
if (!value.has_value()) {
|
||||
return MapBufferBuilder::EMPTY();
|
||||
}
|
||||
|
|
|
@ -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 <butter/butter.h>
|
||||
|
||||
#if defined(BUTTER_USE_FOLLY_CONTAINERS) || __cplusplus < 202000L
|
||||
|
||||
#include <folly/Optional.h>
|
||||
|
||||
#else
|
||||
|
||||
#include <optional>
|
||||
|
||||
#endif
|
||||
|
||||
namespace facebook {
|
||||
namespace butter {
|
||||
|
||||
#if defined(BUTTER_USE_FOLLY_CONTAINERS) || __cplusplus < 202000L
|
||||
|
||||
template <typename Value>
|
||||
using optional = folly::Optional<Value>;
|
||||
|
||||
#else
|
||||
|
||||
template <typename Value>
|
||||
using optional = std::optional<Value>;
|
||||
|
||||
#endif
|
||||
|
||||
} // namespace butter
|
||||
} // namespace facebook
|
|
@ -173,7 +173,7 @@ bool LayoutAnimationKeyFrameManager::shouldOverridePullTransaction() const {
|
|||
return shouldAnimateFrame();
|
||||
}
|
||||
|
||||
butter::optional<MountingTransaction>
|
||||
std::optional<MountingTransaction>
|
||||
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<LayoutAnimation> currentAnimation{};
|
||||
std::optional<LayoutAnimation> currentAnimation{};
|
||||
{
|
||||
std::lock_guard<std::mutex> 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<ShadowViewMutation> executeMutationImmediately{};
|
||||
std::optional<ShadowViewMutation> 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>{layoutAnimation};
|
||||
currentAnimation_ = std::optional<LayoutAnimation>{layoutAnimation};
|
||||
}
|
||||
|
||||
void LayoutAnimationKeyFrameManager::setLayoutAnimationStatusDelegate(
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
#pragma once
|
||||
|
||||
#include <ReactCommon/RuntimeExecutor.h>
|
||||
#include <butter/optional.h>
|
||||
#include <butter/set.h>
|
||||
#include <react/renderer/animations/LayoutAnimationCallbackWrapper.h>
|
||||
#include <react/renderer/animations/primitives.h>
|
||||
|
@ -20,6 +19,8 @@
|
|||
#include <react/renderer/uimanager/LayoutAnimationStatusDelegate.h>
|
||||
#include <react/renderer/uimanager/UIManagerAnimationDelegate.h>
|
||||
|
||||
#include <optional>
|
||||
|
||||
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<MountingTransaction> pullTransaction(
|
||||
std::optional<MountingTransaction> pullTransaction(
|
||||
SurfaceId surfaceId,
|
||||
MountingTransaction::Number number,
|
||||
TransactionTelemetry const &telemetry,
|
||||
|
@ -95,7 +96,7 @@ class LayoutAnimationKeyFrameManager : public UIManagerAnimationDelegate,
|
|||
|
||||
protected:
|
||||
SharedComponentDescriptorRegistry componentDescriptorRegistry_;
|
||||
mutable butter::optional<LayoutAnimation> currentAnimation_{};
|
||||
mutable std::optional<LayoutAnimation> currentAnimation_{};
|
||||
mutable std::mutex currentAnimationMutex_;
|
||||
|
||||
/**
|
||||
|
|
|
@ -5,15 +5,15 @@
|
|||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#include <butter/optional.h>
|
||||
#include <glog/logging.h>
|
||||
#include <react/renderer/animations/primitives.h>
|
||||
|
||||
#include <glog/logging.h>
|
||||
#include <optional>
|
||||
|
||||
namespace facebook {
|
||||
namespace react {
|
||||
|
||||
static inline butter::optional<AnimationType> parseAnimationType(
|
||||
static inline std::optional<AnimationType> parseAnimationType(
|
||||
std::string param) {
|
||||
if (param == "spring") {
|
||||
return AnimationType::Spring;
|
||||
|
@ -38,7 +38,7 @@ static inline butter::optional<AnimationType> parseAnimationType(
|
|||
return {};
|
||||
}
|
||||
|
||||
static inline butter::optional<AnimationProperty> parseAnimationProperty(
|
||||
static inline std::optional<AnimationProperty> parseAnimationProperty(
|
||||
std::string param) {
|
||||
if (param == "opacity") {
|
||||
return AnimationProperty::Opacity;
|
||||
|
@ -57,7 +57,7 @@ static inline butter::optional<AnimationProperty> parseAnimationProperty(
|
|||
return {};
|
||||
}
|
||||
|
||||
static inline butter::optional<AnimationConfig> parseAnimationConfig(
|
||||
static inline std::optional<AnimationConfig> parseAnimationConfig(
|
||||
folly::dynamic const &config,
|
||||
double defaultDuration,
|
||||
bool parsePropertyType) {
|
||||
|
@ -163,7 +163,7 @@ static inline butter::optional<AnimationConfig> parseAnimationConfig(
|
|||
}
|
||||
}
|
||||
|
||||
return butter::optional<AnimationConfig>(AnimationConfig{
|
||||
return std::optional<AnimationConfig>(AnimationConfig{
|
||||
*animationType,
|
||||
animationProperty,
|
||||
duration,
|
||||
|
@ -173,8 +173,8 @@ static inline butter::optional<AnimationConfig> parseAnimationConfig(
|
|||
}
|
||||
|
||||
// Parse animation config from JS
|
||||
static inline butter::optional<LayoutAnimationConfig>
|
||||
parseLayoutAnimationConfig(folly::dynamic const &config) {
|
||||
static inline std::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()
|
||||
? butter::optional<AnimationConfig>(AnimationConfig{})
|
||||
? std::optional<AnimationConfig>(AnimationConfig{})
|
||||
: parseAnimationConfig(createConfigIt->second, duration, true);
|
||||
|
||||
const auto updateConfigIt = config.find("update");
|
||||
const auto updateConfig = updateConfigIt == config.items().end()
|
||||
? butter::optional<AnimationConfig>(AnimationConfig{})
|
||||
? std::optional<AnimationConfig>(AnimationConfig{})
|
||||
: parseAnimationConfig(updateConfigIt->second, duration, false);
|
||||
|
||||
const auto deleteConfigIt = config.find("delete");
|
||||
const auto deleteConfig = deleteConfigIt == config.items().end()
|
||||
? butter::optional<AnimationConfig>(AnimationConfig{})
|
||||
? std::optional<AnimationConfig>(AnimationConfig{})
|
||||
: parseAnimationConfig(deleteConfigIt->second, duration, true);
|
||||
|
||||
if (!createConfig || !updateConfig || !deleteConfig) {
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -9,8 +9,8 @@
|
|||
|
||||
#include <functional>
|
||||
#include <limits>
|
||||
#include <optional>
|
||||
|
||||
#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()};
|
||||
butter::optional<FontWeight> fontWeight{};
|
||||
butter::optional<FontStyle> fontStyle{};
|
||||
butter::optional<FontVariant> fontVariant{};
|
||||
butter::optional<bool> allowFontScaling{};
|
||||
std::optional<FontWeight> fontWeight{};
|
||||
std::optional<FontStyle> fontStyle{};
|
||||
std::optional<FontVariant> fontVariant{};
|
||||
std::optional<bool> allowFontScaling{};
|
||||
Float letterSpacing{std::numeric_limits<Float>::quiet_NaN()};
|
||||
butter::optional<TextTransform> textTransform{};
|
||||
std::optional<TextTransform> textTransform{};
|
||||
|
||||
// Paragraph Styles
|
||||
Float lineHeight{std::numeric_limits<Float>::quiet_NaN()};
|
||||
butter::optional<TextAlignment> alignment{};
|
||||
butter::optional<WritingDirection> baseWritingDirection{};
|
||||
std::optional<TextAlignment> alignment{};
|
||||
std::optional<WritingDirection> baseWritingDirection{};
|
||||
|
||||
// Decoration
|
||||
SharedColor textDecorationColor{};
|
||||
butter::optional<TextDecorationLineType> textDecorationLineType{};
|
||||
butter::optional<TextDecorationStyle> textDecorationStyle{};
|
||||
std::optional<TextDecorationLineType> textDecorationLineType{};
|
||||
std::optional<TextDecorationStyle> textDecorationStyle{};
|
||||
|
||||
// Shadow
|
||||
// TODO: Use `Point` type instead of `Size` for `textShadowOffset` attribute.
|
||||
butter::optional<Size> textShadowOffset{};
|
||||
std::optional<Size> textShadowOffset{};
|
||||
Float textShadowRadius{std::numeric_limits<Float>::quiet_NaN()};
|
||||
SharedColor textShadowColor{};
|
||||
|
||||
// Special
|
||||
butter::optional<bool> isHighlighted{};
|
||||
std::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.
|
||||
butter::optional<LayoutDirection> layoutDirection{};
|
||||
butter::optional<AccessibilityRole> accessibilityRole{};
|
||||
std::optional<LayoutDirection> layoutDirection{};
|
||||
std::optional<AccessibilityRole> accessibilityRole{};
|
||||
|
||||
#pragma mark - Operations
|
||||
|
||||
|
|
|
@ -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)) {
|
||||
|
|
|
@ -102,7 +102,7 @@ class ParagraphShadowNode final : public ConcreteViewShadowNode<
|
|||
/*
|
||||
* Cached content of the subtree started from the node.
|
||||
*/
|
||||
mutable butter::optional<Content> content_{};
|
||||
mutable std::optional<Content> content_{};
|
||||
};
|
||||
|
||||
} // namespace react
|
||||
|
|
|
@ -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<AttributedString> cachedAttributedString_{};
|
||||
mutable std::optional<AttributedString> cachedAttributedString_{};
|
||||
};
|
||||
|
||||
} // namespace react
|
||||
|
|
|
@ -87,7 +87,7 @@ TextInputProps::TextInputProps(
|
|||
rawProps,
|
||||
"selection",
|
||||
sourceProps.selection,
|
||||
butter::optional<Selection>())),
|
||||
std::optional<Selection>())),
|
||||
inputAccessoryViewID(convertRawProp(
|
||||
context,
|
||||
rawProps,
|
||||
|
|
|
@ -58,7 +58,7 @@ class TextInputProps final : public ViewProps, public BaseTextProps {
|
|||
int const mostRecentEventCount{0};
|
||||
|
||||
bool autoFocus{false};
|
||||
butter::optional<Selection> selection{};
|
||||
std::optional<Selection> selection{};
|
||||
|
||||
std::string const inputAccessoryViewID{};
|
||||
|
||||
|
|
|
@ -7,10 +7,9 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <optional>
|
||||
#include <string>
|
||||
|
||||
#include <butter/optional.h>
|
||||
|
||||
namespace facebook {
|
||||
namespace react {
|
||||
|
||||
|
@ -106,7 +105,7 @@ class TextInputTraits final {
|
|||
* iOS & Android
|
||||
* Default value: `empty` (`null`).
|
||||
*/
|
||||
butter::optional<bool> autoCorrect{};
|
||||
std::optional<bool> 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<bool> spellCheck{};
|
||||
std::optional<bool> spellCheck{};
|
||||
|
||||
/*
|
||||
* iOS & Android
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <butter/optional.h>
|
||||
#include <cinttypes>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
|
@ -51,7 +51,7 @@ constexpr enum AccessibilityTraits operator&(
|
|||
|
||||
struct AccessibilityAction {
|
||||
std::string name{""};
|
||||
butter::optional<std::string> label{};
|
||||
std::optional<std::string> label{};
|
||||
};
|
||||
|
||||
inline static bool operator==(
|
||||
|
@ -105,10 +105,10 @@ inline static bool operator!=(
|
|||
}
|
||||
|
||||
struct AccessibilityValue {
|
||||
butter::optional<int> min;
|
||||
butter::optional<int> max;
|
||||
butter::optional<int> now;
|
||||
butter::optional<std::string> text{};
|
||||
std::optional<int> min;
|
||||
std::optional<int> max;
|
||||
std::optional<int> now;
|
||||
std::optional<std::string> text{};
|
||||
};
|
||||
|
||||
constexpr bool operator==(
|
||||
|
|
|
@ -17,6 +17,8 @@
|
|||
#include <react/renderer/graphics/Geometry.h>
|
||||
#include <react/renderer/graphics/Transform.h>
|
||||
|
||||
#include <optional>
|
||||
|
||||
namespace facebook {
|
||||
namespace react {
|
||||
|
||||
|
@ -55,7 +57,7 @@ class ViewProps : public YogaStylableProps, public AccessibilityProps {
|
|||
Transform transform{};
|
||||
BackfaceVisibility backfaceVisibility{};
|
||||
bool shouldRasterize{};
|
||||
butter::optional<int> zIndex{};
|
||||
std::optional<int> zIndex{};
|
||||
|
||||
// Events
|
||||
PointerEventsMode pointerEvents{};
|
||||
|
@ -72,8 +74,8 @@ class ViewProps : public YogaStylableProps, public AccessibilityProps {
|
|||
|
||||
#ifdef ANDROID
|
||||
|
||||
butter::optional<NativeDrawable> nativeBackground{};
|
||||
butter::optional<NativeDrawable> nativeForeground{};
|
||||
std::optional<NativeDrawable> nativeBackground{};
|
||||
std::optional<NativeDrawable> nativeForeground{};
|
||||
|
||||
bool focusable{false};
|
||||
bool hasTVPreferredFocus{false};
|
||||
|
|
|
@ -701,44 +701,44 @@ void YogaLayoutableShadowNode::swapLeftAndRightInViewProps(
|
|||
auto &props = const_cast<ViewProps &>(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();
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
#pragma once
|
||||
|
||||
#include <butter/map.h>
|
||||
#include <butter/optional.h>
|
||||
#include <folly/Conv.h>
|
||||
#include <folly/dynamic.h>
|
||||
#include <glog/logging.h>
|
||||
|
@ -23,6 +22,7 @@
|
|||
#include <yoga/YGNode.h>
|
||||
#include <yoga/Yoga.h>
|
||||
#include <cmath>
|
||||
#include <optional>
|
||||
|
||||
namespace facebook {
|
||||
namespace react {
|
||||
|
@ -98,9 +98,9 @@ inline YGValue yogaStyleValueFromFloat(
|
|||
return {(float)value, unit};
|
||||
}
|
||||
|
||||
inline butter::optional<Float> optionalFloatFromYogaValue(
|
||||
inline std::optional<Float> optionalFloatFromYogaValue(
|
||||
const YGValue value,
|
||||
butter::optional<Float> base = {}) {
|
||||
std::optional<Float> base = {}) {
|
||||
switch (value.unit) {
|
||||
case YGUnitUndefined:
|
||||
return {};
|
||||
|
@ -108,9 +108,8 @@ inline butter::optional<Float> optionalFloatFromYogaValue(
|
|||
return floatFromYogaFloat(value.value);
|
||||
case YGUnitPercent:
|
||||
return base.has_value()
|
||||
? butter::optional<Float>(
|
||||
base.value() * floatFromYogaFloat(value.value))
|
||||
: butter::optional<Float>();
|
||||
? std::optional<Float>(base.value() * floatFromYogaFloat(value.value))
|
||||
: std::optional<Float>();
|
||||
case YGUnitAuto:
|
||||
return {};
|
||||
}
|
||||
|
|
|
@ -7,12 +7,13 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <butter/optional.h>
|
||||
#include <react/renderer/graphics/Color.h>
|
||||
#include <react/renderer/graphics/Geometry.h>
|
||||
|
||||
#include <array>
|
||||
#include <bitset>
|
||||
#include <cmath>
|
||||
#include <optional>
|
||||
|
||||
namespace facebook {
|
||||
namespace react {
|
||||
|
@ -74,7 +75,7 @@ enum class BorderStyle { Solid, Dotted, Dashed };
|
|||
template <typename T>
|
||||
struct CascadedRectangleEdges {
|
||||
using Counterpart = RectangleEdges<T>;
|
||||
using OptionalT = butter::optional<T>;
|
||||
using OptionalT = std::optional<T>;
|
||||
|
||||
OptionalT left{};
|
||||
OptionalT top{};
|
||||
|
@ -135,7 +136,7 @@ struct CascadedRectangleEdges {
|
|||
template <typename T>
|
||||
struct CascadedRectangleCorners {
|
||||
using Counterpart = RectangleCorners<T>;
|
||||
using OptionalT = butter::optional<T>;
|
||||
using OptionalT = std::optional<T>;
|
||||
|
||||
OptionalT topLeft{};
|
||||
OptionalT topRight{};
|
||||
|
@ -236,9 +237,9 @@ struct NativeDrawable {
|
|||
};
|
||||
|
||||
struct Ripple {
|
||||
butter::optional<int32_t> color{};
|
||||
std::optional<int32_t> color{};
|
||||
bool borderless{false};
|
||||
butter::optional<Float> rippleRadius{};
|
||||
std::optional<Float> rippleRadius{};
|
||||
|
||||
bool operator==(const Ripple &rhs) const {
|
||||
return std::tie(this->color, this->borderless, this->rippleRadius) ==
|
||||
|
|
|
@ -11,6 +11,8 @@
|
|||
#include <react/renderer/core/PropsParserContext.h>
|
||||
#include <react/renderer/core/propsConversions.h>
|
||||
|
||||
#include <optional>
|
||||
|
||||
namespace facebook {
|
||||
namespace react {
|
||||
|
||||
|
@ -633,7 +635,7 @@ static inline void fromRawValue(
|
|||
NativeDrawable::Ripple{
|
||||
.color = color != map.end() && color->second.hasType<int32_t>()
|
||||
? (int32_t)color->second
|
||||
: butter::optional<int32_t>{},
|
||||
: std::optional<int32_t>{},
|
||||
.borderless = borderless != map.end() &&
|
||||
borderless->second.hasType<bool>()
|
||||
? (bool)borderless->second
|
||||
|
@ -641,7 +643,7 @@ static inline void fromRawValue(
|
|||
.rippleRadius = rippleRadius != map.end() &&
|
||||
rippleRadius->second.hasType<Float>()
|
||||
? (Float)rippleRadius->second
|
||||
: butter::optional<Float>{},
|
||||
: std::optional<Float>{},
|
||||
},
|
||||
};
|
||||
} else {
|
||||
|
|
|
@ -8,9 +8,9 @@
|
|||
#pragma once
|
||||
|
||||
#include <limits>
|
||||
#include <optional>
|
||||
|
||||
#include <butter/map.h>
|
||||
#include <butter/optional.h>
|
||||
#include <butter/small_vector.h>
|
||||
|
||||
#include <folly/dynamic.h>
|
||||
|
|
|
@ -7,7 +7,8 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <butter/optional.h>
|
||||
#include <optional>
|
||||
|
||||
#include <folly/Likely.h>
|
||||
#include <folly/dynamic.h>
|
||||
#include <react/renderer/core/PropsParserContext.h>
|
||||
|
@ -106,12 +107,12 @@ T convertRawProp(
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
static butter::optional<T> convertRawProp(
|
||||
static std::optional<T> convertRawProp(
|
||||
const PropsParserContext &context,
|
||||
RawProps const &rawProps,
|
||||
char const *name,
|
||||
butter::optional<T> const &sourceValue,
|
||||
butter::optional<T> const &defaultValue,
|
||||
std::optional<T> const &sourceValue,
|
||||
std::optional<T> 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<T> convertRawProp(
|
|||
|
||||
T result;
|
||||
fromRawValue(context, *rawValue, result);
|
||||
return butter::optional<T>{result};
|
||||
return std::optional<T>{result};
|
||||
}
|
||||
|
||||
} // namespace react
|
||||
|
|
|
@ -7,9 +7,9 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <butter/optional.h>
|
||||
#include <limits>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
|
@ -34,9 +34,9 @@ debugStringConvertibleItem(std::string name, T value, T defaultValue = {}) {
|
|||
template <typename T>
|
||||
inline SharedDebugStringConvertible debugStringConvertibleItem(
|
||||
std::string name,
|
||||
butter::optional<T> value,
|
||||
std::optional<T> value,
|
||||
T defaultValue = {}) {
|
||||
if (!value.hasValue()) {
|
||||
if (!value.has_value()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <cmath>
|
||||
#include <optional>
|
||||
|
||||
#include <folly/Hash.h>
|
||||
#include <react/renderer/graphics/ColorComponents.h>
|
||||
|
|
|
@ -75,11 +75,11 @@ void MountingCoordinator::resetLatestRevision() const {
|
|||
lastRevision_.reset();
|
||||
}
|
||||
|
||||
butter::optional<MountingTransaction> MountingCoordinator::pullTransaction()
|
||||
std::optional<MountingTransaction> MountingCoordinator::pullTransaction()
|
||||
const {
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
|
||||
auto transaction = butter::optional<MountingTransaction>{};
|
||||
auto transaction = std::optional<MountingTransaction>{};
|
||||
|
||||
// Base case
|
||||
if (lastRevision_.has_value()) {
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <butter/optional.h>
|
||||
#include <chrono>
|
||||
#include <optional>
|
||||
|
||||
#include <react/renderer/debug/flags.h>
|
||||
#include <react/renderer/mounting/Differentiator.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.
|
||||
*/
|
||||
butter::optional<MountingTransaction> pullTransaction() const;
|
||||
std::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 butter::optional<ShadowTreeRevision> lastRevision_{};
|
||||
mutable std::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 butter::optional<MountingTransaction> pullTransaction(
|
||||
virtual std::optional<MountingTransaction> pullTransaction(
|
||||
SurfaceId surfaceId,
|
||||
MountingTransaction::Number number,
|
||||
TransactionTelemetry const &telemetry,
|
||||
|
|
|
@ -7,8 +7,6 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <butter/optional.h>
|
||||
|
||||
#include <react/renderer/components/root/RootShadowNode.h>
|
||||
#include <react/renderer/mounting/MountingOverrideDelegate.h>
|
||||
#include <react/renderer/mounting/MountingTransaction.h>
|
||||
|
|
|
@ -7,11 +7,12 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <butter/optional.h>
|
||||
#include <jsi/jsi.h>
|
||||
#include <react/renderer/runtimescheduler/RuntimeSchedulerClock.h>
|
||||
#include <react/renderer/runtimescheduler/SchedulerPriority.h>
|
||||
|
||||
#include <optional>
|
||||
|
||||
namespace facebook {
|
||||
namespace react {
|
||||
|
||||
|
@ -29,7 +30,7 @@ struct Task final {
|
|||
friend TaskPriorityComparer;
|
||||
|
||||
SchedulerPriority priority;
|
||||
butter::optional<jsi::Function> callback;
|
||||
std::optional<jsi::Function> callback;
|
||||
RuntimeSchedulerClock::time_point expirationTime;
|
||||
|
||||
jsi::Value execute(jsi::Runtime &runtime);
|
||||
|
|
|
@ -42,8 +42,7 @@ Scheduler::Scheduler(
|
|||
"ReactNativeConfig");
|
||||
|
||||
// Creating a container for future `EventDispatcher` instance.
|
||||
eventDispatcher_ =
|
||||
std::make_shared<butter::optional<EventDispatcher const>>();
|
||||
eventDispatcher_ = std::make_shared<std::optional<EventDispatcher const>>();
|
||||
|
||||
auto uiManager = std::make_shared<UIManager>(
|
||||
runtimeExecutor_, schedulerToolbox.backgroundExecutor, contextContainer_);
|
||||
|
@ -62,7 +61,7 @@ Scheduler::Scheduler(
|
|||
contextContainer_->find<std::weak_ptr<RuntimeScheduler>>(
|
||||
"RuntimeScheduler");
|
||||
auto runtimeScheduler =
|
||||
(enableCallImmediates && weakRuntimeScheduler.hasValue())
|
||||
(enableCallImmediates && weakRuntimeScheduler.has_value())
|
||||
? weakRuntimeScheduler.value().lock()
|
||||
: nullptr;
|
||||
|
||||
|
|
|
@ -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<butter::optional<EventDispatcher const>> eventDispatcher_;
|
||||
std::shared_ptr<std::optional<EventDispatcher const>> eventDispatcher_;
|
||||
|
||||
/**
|
||||
* Hold onto ContextContainer. See SchedulerToolbox.
|
||||
|
|
|
@ -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<NSAttributedStringKey, id> *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<NSAttributedStringKey, id> *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<NSAttributedStringKey, id> *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<NSAttributedStringKey, id> *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);
|
||||
}
|
||||
|
|
|
@ -9,11 +9,11 @@
|
|||
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
|
||||
#include <butter/map.h>
|
||||
#include <butter/mutex.h>
|
||||
#include <butter/optional.h>
|
||||
|
||||
#include <react/debug/flags.h>
|
||||
#include <react/debug/react_native_assert.h>
|
||||
|
@ -92,7 +92,7 @@ class ContextContainer final {
|
|||
* Returns an empty optional if the instance could not be found.
|
||||
*/
|
||||
template <typename T>
|
||||
butter::optional<T> find(std::string const &key) const {
|
||||
std::optional<T> find(std::string const &key) const {
|
||||
std::shared_lock<butter::shared_mutex> lock(mutex_);
|
||||
|
||||
auto iterator = instances_.find(key);
|
||||
|
|
|
@ -8,8 +8,8 @@
|
|||
#include <functional>
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <optional>
|
||||
|
||||
#include <butter/optional.h>
|
||||
#include <folly/container/EvictingCacheMap.h>
|
||||
|
||||
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<ValueT> get(const KeyT &key) const {
|
||||
std::optional<ValueT> get(const KeyT &key) const {
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
auto iterator = map_.find(key);
|
||||
if (iterator == map_.end()) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче