UNPKG

1.28 kBtext/x-cView Raw
1/**
2 * Copyright (c) Facebook, Inc. and its affiliates.
3 *
4 * This source code is licensed under the MIT license found in the
5 * LICENSE file in the root directory of this source tree.
6 */
7
8#pragma once
9
10#include <react/core/LayoutPrimitives.h>
11
12namespace facebook {
13namespace react {
14
15inline 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
26inline 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
37inline 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} // namespace react
52} // namespace facebook