Coverage Report

Created: 2025-10-10 06:42

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(_MSC_VER)
33
#define YG_EXPORT __attribute__((visibility("default")))
34
#else
35
#define YG_EXPORT
36
#endif
37
38
#ifdef __OBJC__
39
#if __has_include(<Foundation/Foundation.h>)
40
#import <Foundation/Foundation.h>
41
#endif
42
#endif
43
44
#ifdef NS_ENUM
45
// Cannot use NSInteger as NSInteger has a different size than int (which is the
46
// default type of a enum). Therefor when linking the Yoga C library into obj-c
47
// the header is a mismatch for the Yoga ABI.
48
#define YG_ENUM_BEGIN(name) NS_ENUM(int, name)
49
#define YG_ENUM_END(name)
50
#else
51
#define YG_ENUM_BEGIN(name) enum name
52
#define YG_ENUM_END(name) name
53
#endif
54
55
#ifdef __cplusplus
56
#define YG_DEFINE_ENUM_FLAG_OPERATORS(name)                       \
57
  extern "C++" {                                                  \
58
0
  constexpr name operator~(name a) {                              \
59
0
    return static_cast<name>(                                     \
60
0
        ~static_cast<std::underlying_type<name>::type>(a));       \
61
0
  }                                                               \
Unexecuted instantiation: operator~(YGErrata)
Unexecuted instantiation: facebook::yoga::operator~(facebook::yoga::Errata)
62
0
  constexpr name operator|(name a, name b) {                      \
63
0
    return static_cast<name>(                                     \
64
0
        static_cast<std::underlying_type<name>::type>(a) |        \
65
0
        static_cast<std::underlying_type<name>::type>(b));        \
66
0
  }                                                               \
Unexecuted instantiation: operator|(YGErrata, YGErrata)
Unexecuted instantiation: facebook::yoga::operator|(facebook::yoga::Errata, facebook::yoga::Errata)
67
932k
  constexpr name operator&(name a, name b) {                      \
68
932k
    return static_cast<name>(                                     \
69
932k
        static_cast<std::underlying_type<name>::type>(a) &        \
70
932k
        static_cast<std::underlying_type<name>::type>(b));        \
71
932k
  }                                                               \
Unexecuted instantiation: operator&(YGErrata, YGErrata)
facebook::yoga::operator&(facebook::yoga::Errata, facebook::yoga::Errata)
Line
Count
Source
67
932k
  constexpr name operator&(name a, name b) {                      \
68
932k
    return static_cast<name>(                                     \
69
932k
        static_cast<std::underlying_type<name>::type>(a) &        \
70
932k
        static_cast<std::underlying_type<name>::type>(b));        \
71
932k
  }                                                               \
72
0
  constexpr name operator^(name a, name b) {                      \
73
0
    return static_cast<name>(                                     \
74
0
        static_cast<std::underlying_type<name>::type>(a) ^        \
75
0
        static_cast<std::underlying_type<name>::type>(b));        \
76
0
  }                                                               \
Unexecuted instantiation: operator^(YGErrata, YGErrata)
Unexecuted instantiation: facebook::yoga::operator^(facebook::yoga::Errata, facebook::yoga::Errata)
77
0
  inline name& operator|=(name& a, name b) {                      \
78
0
    return reinterpret_cast<name&>(                               \
79
0
        reinterpret_cast<std::underlying_type<name>::type&>(a) |= \
80
0
        static_cast<std::underlying_type<name>::type>(b));        \
81
0
  }                                                               \
Unexecuted instantiation: operator|=(YGErrata&, YGErrata)
Unexecuted instantiation: facebook::yoga::operator|=(facebook::yoga::Errata&, facebook::yoga::Errata)
82
0
  inline name& operator&=(name& a, name b) {                      \
83
0
    return reinterpret_cast<name&>(                               \
84
0
        reinterpret_cast<std::underlying_type<name>::type&>(a) &= \
85
0
        static_cast<std::underlying_type<name>::type>(b));        \
86
0
  }                                                               \
Unexecuted instantiation: operator&=(YGErrata&, YGErrata)
Unexecuted instantiation: facebook::yoga::operator&=(facebook::yoga::Errata&, facebook::yoga::Errata)
87
0
  inline name& operator^=(name& a, name b) {                      \
88
0
    return reinterpret_cast<name&>(                               \
89
0
        reinterpret_cast<std::underlying_type<name>::type&>(a) ^= \
90
0
        static_cast<std::underlying_type<name>::type>(b));        \
91
0
  }                                                               \
Unexecuted instantiation: operator^=(YGErrata&, YGErrata)
Unexecuted instantiation: facebook::yoga::operator^=(facebook::yoga::Errata&, facebook::yoga::Errata)
92
  }
93
#else
94
#define YG_DEFINE_ENUM_FLAG_OPERATORS(name)
95
#endif
96
97
#define YG_ENUM_DECL(NAME, ...)                               \
98
  typedef YG_ENUM_BEGIN(NAME){__VA_ARGS__} YG_ENUM_END(NAME); \
99
  YG_EXPORT const char* NAME##ToString(NAME);