1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 | #pragma once
|
9 |
|
10 | #include <react/core/LayoutPrimitives.h>
|
11 |
|
12 | namespace facebook {
|
13 | namespace react {
|
14 |
|
15 | inline std::string toString(const LayoutDirection &layoutDirection) {
|
16 | switch (layoutDirection) {
|
17 | case LayoutDirection::Undefined:
|
18 | return "undefined";
|
19 | case LayoutDirection::LeftToRight:
|
20 | return "ltr";
|
21 | case LayoutDirection::RightToLeft:
|
22 | return "rtl";
|
23 | }
|
24 | }
|
25 |
|
26 | inline std::string toString(const DisplayType &displayType) {
|
27 | switch (displayType) {
|
28 | case DisplayType::None:
|
29 | return "none";
|
30 | case DisplayType::Flex:
|
31 | return "flex";
|
32 | case DisplayType::Inline:
|
33 | return "inline";
|
34 | }
|
35 | }
|
36 |
|
37 | inline Size yogaMeassureToSize(int64_t value) {
|
38 | static_assert(
|
39 | sizeof(value) == 8,
|
40 | "Expected measureResult to be 8 bytes, or two 32 bit ints");
|
41 |
|
42 | int32_t wBits = 0xFFFFFFFF & (value >> 32);
|
43 | int32_t hBits = 0xFFFFFFFF & value;
|
44 |
|
45 | float *measuredWidth = reinterpret_cast<float *>(&wBits);
|
46 | float *measuredHeight = reinterpret_cast<float *>(&hBits);
|
47 |
|
48 | return {*measuredWidth, *measuredHeight};
|
49 | }
|
50 |
|
51 | }
|
52 | }
|