YGStyle: mutable accessors return Ref instances

Summary:
@public

Change style property accessors to return `Ref` instances instead of references to `CompactValue`.

This will allow to track assignments to properties later on, e.g. for instrumentation or dynamic property storage.

Reviewed By: SidharthGuglani

Differential Revision: D15078961

fbshipit-source-id: 259f05f7d30f093c04bf333c5bd4fb3601b8e933
This commit is contained in:
David Aurelio
2019-05-01 06:47:30 -07:00
committed by Facebook Github Bot
parent cea862a6bf
commit 0a4f7bd558
3 changed files with 174 additions and 105 deletions

View File

@@ -8,7 +8,7 @@
#include <yoga/YGStyle.h>
#include <yoga/YGValue.h>
#include <initializer_list>
#include <utility>
#define ACCESSOR_TESTS_1(NAME, X) \
style.NAME() = X; \
@@ -29,9 +29,14 @@
#define ACCESSOR_TESTS_N(a, b, c, d, e, COUNT, ...) ACCESSOR_TESTS_##COUNT
#define ACCESSOR_TESTS(...) ACCESSOR_TESTS_N(__VA_ARGS__, 5, 4, 3, 2, 1)
#define INDEX_ACCESSOR_TESTS_1(NAME, IDX, X) \
style.NAME()[IDX] = X; \
ASSERT_EQ(style.NAME()[IDX], X);
#define INDEX_ACCESSOR_TESTS_1(NAME, IDX, X) \
{ \
style.NAME()[IDX] = X; \
ASSERT_EQ(style.NAME()[IDX], X); \
auto asArray = decltype(std::declval<const YGStyle&>().NAME()){X}; \
style.NAME() = asArray; \
ASSERT_EQ(static_cast<decltype(asArray)>(style.NAME()), asArray); \
}
#define INDEX_ACCESSOR_TESTS_2(NAME, IDX, X, Y) \
INDEX_ACCESSOR_TESTS_1(NAME, IDX, X) \