blob: a409653bb58dd35b59845b8119fea11fd8d54dc8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
/*
* Copyright (C) 2016 The Qt Company Ltd.
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* SPDX-License-Identifier: MIT
*/
#pragma once
#include <yoga/YGEnums.h>
#include <yoga/YGMacros.h>
YG_EXTERN_C_BEGIN
typedef struct YGValue {
float value;
YGUnit unit;
} YGValue;
YOGA_EXPORT extern const YGValue YGValueAuto;
YOGA_EXPORT extern const YGValue YGValueUndefined;
YOGA_EXPORT extern const YGValue YGValueZero;
YG_EXTERN_C_END
#ifdef __cplusplus
#include <limits>
constexpr float YGUndefined = std::numeric_limits<float>::quiet_NaN();
#else
#include <math.h>
#define YGUndefined NAN
#endif
#ifdef __cplusplus
inline bool operator==(const YGValue& lhs, const YGValue& rhs) {
if (lhs.unit != rhs.unit) {
return false;
}
switch (lhs.unit) {
case YGUnitUndefined:
case YGUnitAuto:
return true;
case YGUnitPoint:
case YGUnitPercent:
return lhs.value == rhs.value;
}
return false;
}
inline bool operator!=(const YGValue& lhs, const YGValue& rhs) {
return !(lhs == rhs);
}
inline YGValue operator-(const YGValue& value) {
return {-value.value, value.unit};
}
#endif
|