Coverage Report

Created: 2026-12-01 07:09

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/yoga/yoga/YGMacros.h
Line
Count
Source
1
/*
2
 * Copyright (c) Meta Platforms, Inc. and 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
#ifdef __cplusplus
11
#include <type_traits>
12
#endif
13
14
#ifdef __cplusplus
15
#define YG_EXTERN_C_BEGIN extern "C" {
16
#define YG_EXTERN_C_END }
17
#else
18
#define YG_EXTERN_C_BEGIN
19
#define YG_EXTERN_C_END
20
#endif
21
22
#if defined(__cplusplus)
23
#define YG_DEPRECATED(message) [[deprecated(message)]]
24
#elif defined(_MSC_VER)
25
#define YG_DEPRECATED(message) __declspec(deprecated(message))
26
#else
27
#define YG_DEPRECATED(message) __attribute__((deprecated(message)))
28
#endif
29
30
#ifdef _WINDLL
31
#define YG_EXPORT __declspec(dllexport)
32
#elif defined(__EMSCRIPTEN__)
33
#define YG_EXPORT __attribute__((visibility("default"), used))
34
#elif !defined(_MSC_VER)
35
#define YG_EXPORT __attribute__((visibility("default")))
36
#else
37
#define YG_EXPORT
38
#endif
39
40
#ifdef __OBJC__
41
#if __has_include(<Foundation/Foundation.h>)
42
#import <Foundation/Foundation.h>
43
#endif
44
#endif
45
46
#ifdef NS_ENUM
47
// Cannot use NSInteger as NSInteger has a different size than int (which is the
48
// default type of an enum). Therefore when linking the Yoga C library into
49
// obj-c the header is a mismatch for the Yoga ABI.
50
#define YG_ENUM_BEGIN(name) NS_ENUM(int, name)
51
#define YG_ENUM_END(name)
52
#else
53
#define YG_ENUM_BEGIN(name) enum name
54
#define YG_ENUM_END(name) name
55
#endif
56
57
#ifdef __cplusplus
58
#define YG_DEFINE_ENUM_FLAG_OPERATORS(name)                       \
59
  extern "C++" {                                                  \
60
0
  constexpr name operator~(name a) {                              \
61
0
    return static_cast<name>(                                     \
62
0
        ~static_cast<std::underlying_type<name>::type>(a));       \
63
0
  }                                                               \
Unexecuted instantiation: operator~(YGErrata)
Unexecuted instantiation: facebook::yoga::operator~(facebook::yoga::Errata)
64
803
  constexpr name operator|(name a, name b) {                      \
65
803
    return static_cast<name>(                                     \
66
803
        static_cast<std::underlying_type<name>::type>(a) |        \
67
803
        static_cast<std::underlying_type<name>::type>(b));        \
68
803
  }                                                               \
Unexecuted instantiation: operator|(YGErrata, YGErrata)
facebook::yoga::operator|(facebook::yoga::Errata, facebook::yoga::Errata)
Line
Count
Source
64
803
  constexpr name operator|(name a, name b) {                      \
65
803
    return static_cast<name>(                                     \
66
803
        static_cast<std::underlying_type<name>::type>(a) |        \
67
803
        static_cast<std::underlying_type<name>::type>(b));        \
68
803
  }                                                               \
69
14.3M
  constexpr name operator&(name a, name b) {                      \
70
14.3M
    return static_cast<name>(                                     \
71
14.3M
        static_cast<std::underlying_type<name>::type>(a) &        \
72
14.3M
        static_cast<std::underlying_type<name>::type>(b));        \
73
14.3M
  }                                                               \
Unexecuted instantiation: operator&(YGErrata, YGErrata)
facebook::yoga::operator&(facebook::yoga::Errata, facebook::yoga::Errata)
Line
Count
Source
69
14.3M
  constexpr name operator&(name a, name b) {                      \
70
14.3M
    return static_cast<name>(                                     \
71
14.3M
        static_cast<std::underlying_type<name>::type>(a) &        \
72
14.3M
        static_cast<std::underlying_type<name>::type>(b));        \
73
14.3M
  }                                                               \
74
0
  constexpr name operator^(name a, name b) {                      \
75
0
    return static_cast<name>(                                     \
76
0
        static_cast<std::underlying_type<name>::type>(a) ^        \
77
0
        static_cast<std::underlying_type<name>::type>(b));        \
78
0
  }                                                               \
Unexecuted instantiation: operator^(YGErrata, YGErrata)
Unexecuted instantiation: facebook::yoga::operator^(facebook::yoga::Errata, facebook::yoga::Errata)
79
0
  inline name& operator|=(name& a, name b) {                      \
80
0
    return reinterpret_cast<name&>(                               \
81
0
        reinterpret_cast<std::underlying_type<name>::type&>(a) |= \
82
0
        static_cast<std::underlying_type<name>::type>(b));        \
83
0
  }                                                               \
Unexecuted instantiation: operator|=(YGErrata&, YGErrata)
Unexecuted instantiation: facebook::yoga::operator|=(facebook::yoga::Errata&, facebook::yoga::Errata)
84
0
  inline name& operator&=(name& a, name b) {                      \
85
0
    return reinterpret_cast<name&>(                               \
86
0
        reinterpret_cast<std::underlying_type<name>::type&>(a) &= \
87
0
        static_cast<std::underlying_type<name>::type>(b));        \
88
0
  }                                                               \
Unexecuted instantiation: operator&=(YGErrata&, YGErrata)
Unexecuted instantiation: facebook::yoga::operator&=(facebook::yoga::Errata&, facebook::yoga::Errata)
89
0
  inline name& operator^=(name& a, name b) {                      \
90
0
    return reinterpret_cast<name&>(                               \
91
0
        reinterpret_cast<std::underlying_type<name>::type&>(a) ^= \
92
0
        static_cast<std::underlying_type<name>::type>(b));        \
93
0
  }                                                               \
Unexecuted instantiation: operator^=(YGErrata&, YGErrata)
Unexecuted instantiation: facebook::yoga::operator^=(facebook::yoga::Errata&, facebook::yoga::Errata)
94
  }
95
#else
96
#define YG_DEFINE_ENUM_FLAG_OPERATORS(name)
97
#endif
98
99
#define YG_ENUM_DECL(NAME, ...)                               \
100
  typedef YG_ENUM_BEGIN(NAME){__VA_ARGS__} YG_ENUM_END(NAME); \
101
  YG_EXPORT const char* NAME##ToString(NAME);