Summary: https://github.com/facebook/yoga/pull/1116 adds a new enum. The enum generator is out of date with copyright header, and some codemods, but it also looks like there were manual changes, types added, etc since generation. I fixed up the script to incorporate generating the changes folks made manually, and also added an enum that was previously only added manually to the C ABI. Changelog: [General][Fixed] - Fixup Yoga Enum Generator Reviewed By: yungsters Differential Revision: D39922252 fbshipit-source-id: b678fa9a43a896873d8c434745bdaf3f16fd991f
97 lines
2.3 KiB
C++
97 lines
2.3 KiB
C++
/*
|
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#ifdef __cplusplus
|
|
#define YG_EXTERN_C_BEGIN extern "C" {
|
|
#define YG_EXTERN_C_END }
|
|
#else
|
|
#define YG_EXTERN_C_BEGIN
|
|
#define YG_EXTERN_C_END
|
|
#endif
|
|
|
|
#ifdef _WINDLL
|
|
#define WIN_EXPORT __declspec(dllexport)
|
|
#else
|
|
#define WIN_EXPORT
|
|
#endif
|
|
|
|
#ifndef YOGA_EXPORT
|
|
#ifdef _MSC_VER
|
|
#define YOGA_EXPORT
|
|
#else
|
|
#define YOGA_EXPORT __attribute__((visibility("default")))
|
|
#endif
|
|
#endif
|
|
|
|
#ifdef NS_ENUM
|
|
// Cannot use NSInteger as NSInteger has a different size than int (which is the
|
|
// default type of a enum). Therefor when linking the Yoga C library into obj-c
|
|
// the header is a missmatch for the Yoga ABI.
|
|
#define YG_ENUM_BEGIN(name) NS_ENUM(int, name)
|
|
#define YG_ENUM_END(name)
|
|
#else
|
|
#define YG_ENUM_BEGIN(name) enum name
|
|
#define YG_ENUM_END(name) name
|
|
#endif
|
|
|
|
#ifdef __cplusplus
|
|
namespace facebook {
|
|
namespace yoga {
|
|
namespace enums {
|
|
|
|
template <typename T>
|
|
constexpr int count(); // can't use `= delete` due to a defect in clang < 3.9
|
|
|
|
namespace detail {
|
|
template <int... xs>
|
|
constexpr int n() {
|
|
return sizeof...(xs);
|
|
}
|
|
} // namespace detail
|
|
|
|
} // namespace enums
|
|
} // namespace yoga
|
|
} // namespace facebook
|
|
#endif
|
|
|
|
#define YG_ENUM_DECL(NAME, ...) \
|
|
typedef YG_ENUM_BEGIN(NAME){__VA_ARGS__} YG_ENUM_END(NAME); \
|
|
WIN_EXPORT const char* NAME##ToString(NAME);
|
|
|
|
#ifdef __cplusplus
|
|
#define YG_ENUM_SEQ_DECL(NAME, ...) \
|
|
YG_ENUM_DECL(NAME, __VA_ARGS__) \
|
|
YG_EXTERN_C_END \
|
|
namespace facebook { \
|
|
namespace yoga { \
|
|
namespace enums { \
|
|
template <> \
|
|
constexpr int count<NAME>() { \
|
|
return detail::n<__VA_ARGS__>(); \
|
|
} \
|
|
} \
|
|
} \
|
|
} \
|
|
YG_EXTERN_C_BEGIN
|
|
#else
|
|
#define YG_ENUM_SEQ_DECL YG_ENUM_DECL
|
|
#endif
|
|
|
|
#ifdef __GNUC__
|
|
#define YG_DEPRECATED __attribute__((deprecated))
|
|
#elif defined(_MSC_VER)
|
|
#define YG_DEPRECATED __declspec(deprecated)
|
|
#elif __cplusplus >= 201402L
|
|
#if defined(__has_cpp_attribute)
|
|
#if __has_cpp_attribute(deprecated)
|
|
#define YG_DEPRECATED [[deprecated]]
|
|
#endif
|
|
#endif
|
|
#endif
|