Modularize and document public API (#1449)

Summary:
X-link: https://github.com/facebook/react-native/pull/41317

Pull Request resolved: https://github.com/facebook/yoga/pull/1449

This aims to clean up the public Yoga C API, by:
1. Documenting public YGNode, YGValue, YGConfig APIs
2. Splitting APIs for specific objects into different header files (because Yoga.h was big enough without documentation)
3. Reordering headers and definitions for consistent grouping

Changelog: [Internal]

Reviewed By: joevilches

Differential Revision: D50963424

fbshipit-source-id: 45124b7370256fc63aefd6d5b7641466e9a79d3b
This commit is contained in:
Nick Gerleman
2023-11-10 16:31:46 -08:00
committed by Facebook GitHub Bot
parent 12a8d16b62
commit c46ea9c6f5
15 changed files with 1717 additions and 1287 deletions

View File

@@ -7,22 +7,14 @@
#pragma once
#include <stdbool.h>
#include <yoga/YGEnums.h>
#include <yoga/YGMacros.h>
YG_EXTERN_C_BEGIN
typedef struct YGValue {
float value;
YGUnit unit;
} YGValue;
YG_EXPORT extern const YGValue YGValueAuto;
YG_EXPORT extern const YGValue YGValueUndefined;
YG_EXPORT extern const YGValue YGValueZero;
YG_EXTERN_C_END
/**
* Float value to represent "undefined" in style values.
*/
#ifdef __cplusplus
#include <limits>
constexpr float YGUndefined = std::numeric_limits<float>::quiet_NaN();
@@ -31,6 +23,39 @@ constexpr float YGUndefined = std::numeric_limits<float>::quiet_NaN();
#define YGUndefined NAN
#endif
YG_EXTERN_C_BEGIN
/**
* Structure used to represent a dimension in a style.
*/
typedef struct YGValue {
float value;
YGUnit unit;
} YGValue;
/**
* Constant for a dimension of "auto".
*/
YG_EXPORT extern const YGValue YGValueAuto;
/**
* Constant for a dimension which is not defined.
*/
YG_EXPORT extern const YGValue YGValueUndefined;
/**
* Constant for a dimension that is zero-length.
*/
YG_EXPORT extern const YGValue YGValueZero;
/**
* Whether a dimension represented as a float is defined.
*/
YG_EXPORT bool YGFloatIsUndefined(float value);
YG_EXTERN_C_END
// Equality operators for comparison of YGValue in C++
#ifdef __cplusplus
inline bool operator==(const YGValue& lhs, const YGValue& rhs) {
if (lhs.unit != rhs.unit) {