Expose the value type used by YGStyle
as ValueRepr
Summary: @public Adds `YGStyle::ValueRepr` to make code depending on the actual type easier to write. So far, we have treated `yoga::detail::CompactValue` as an implementation detail, and that’s what it’s supposed to stay. React Native Fabric has one value conversion overload that depends on that type, though, and used `decltype(YGStyle{}.margin()[0])` until now. That’s problematic for two reasons: - we want to constrain the parameter of `operator[](...)` to enum types, making the `0` unsuitable - we want to return the non-const overload of the operator to return a custom `Ref` type, which is not the type needed by Fabric. Making the storage type explicit allows to write more forward-compatible code. Reviewed By: SidharthGuglani Differential Revision: D15078960 fbshipit-source-id: 932c27ef2f2cdc6ce965b79894268170f0ccdce5
This commit is contained in:
committed by
Facebook Github Bot
parent
cc02a20c9e
commit
cea862a6bf
@@ -7,7 +7,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <initializer_list>
|
#include <type_traits>
|
||||||
#include "CompactValue.h"
|
#include "CompactValue.h"
|
||||||
#include "YGEnums.h"
|
#include "YGEnums.h"
|
||||||
#include "YGFloatOptional.h"
|
#include "YGFloatOptional.h"
|
||||||
@@ -171,6 +171,10 @@ private:
|
|||||||
BITFIELD_ACCESSORS(flexWrap);
|
BITFIELD_ACCESSORS(flexWrap);
|
||||||
BITFIELD_ACCESSORS(overflow);
|
BITFIELD_ACCESSORS(overflow);
|
||||||
BITFIELD_ACCESSORS(display);
|
BITFIELD_ACCESSORS(display);
|
||||||
|
|
||||||
|
public:
|
||||||
|
// for library users needing a type
|
||||||
|
using ValueRepr = std::remove_reference<decltype(margin_[0])>::type;
|
||||||
};
|
};
|
||||||
|
|
||||||
bool operator==(const YGStyle& lhs, const YGStyle& rhs);
|
bool operator==(const YGStyle& lhs, const YGStyle& rhs);
|
||||||
|
Reference in New Issue
Block a user