Run lint on Yoga.cpp/Yoga.h

Summary:
@public

auto-fixes formatting for `Yoga.cpp`/`Yoga.h`.
Submitted separately to keep other diffs cleaner.

Reviewed By: astreet

Differential Revision: D8868179

fbshipit-source-id: d0667f8bb909bb5ada1263aac6e22b0a8f8875ad
This commit is contained in:
David Aurelio
2018-07-19 09:57:04 -07:00
committed by Facebook Github Bot
parent f95e3b49e9
commit 389f2fd85d
2 changed files with 789 additions and 570 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -1,10 +1,10 @@
/** /*
* Copyright (c) 2014-present, Facebook, Inc. * Copyright (c) 2014-present, Facebook, Inc.
* *
* This source code is licensed under the MIT license found in the * This source code is licensed under the MIT license found in the LICENSE
* LICENSE file in the root directory of this source tree. * file in the root directory of this source tree.
*
*/ */
#pragma once #pragma once
#include <assert.h> #include <assert.h>
@@ -45,22 +45,25 @@ typedef struct YGValue {
extern const YGValue YGValueUndefined; extern const YGValue YGValueUndefined;
extern const YGValue YGValueAuto; extern const YGValue YGValueAuto;
typedef struct YGConfig *YGConfigRef; typedef struct YGConfig* YGConfigRef;
typedef struct YGNode* YGNodeRef; typedef struct YGNode* YGNodeRef;
typedef YGSize (*YGMeasureFunc)(YGNodeRef node, typedef YGSize (*YGMeasureFunc)(
YGNodeRef node,
float width, float width,
YGMeasureMode widthMode, YGMeasureMode widthMode,
float height, float height,
YGMeasureMode heightMode); YGMeasureMode heightMode);
typedef float (*YGBaselineFunc)(YGNodeRef node, const float width, const float height); typedef float (
*YGBaselineFunc)(YGNodeRef node, const float width, const float height);
typedef void (*YGDirtiedFunc)(YGNodeRef node); typedef void (*YGDirtiedFunc)(YGNodeRef node);
typedef void (*YGPrintFunc)(YGNodeRef node); typedef void (*YGPrintFunc)(YGNodeRef node);
typedef int (*YGLogger)(const YGConfigRef config, typedef int (*YGLogger)(
const YGConfigRef config,
const YGNodeRef node, const YGNodeRef node,
YGLogLevel level, YGLogLevel level,
const char *format, const char* format,
va_list args); va_list args);
typedef YGNodeRef ( typedef YGNodeRef (
*YGCloneNodeFunc)(YGNodeRef oldNode, YGNodeRef owner, int childIndex); *YGCloneNodeFunc)(YGNodeRef oldNode, YGNodeRef owner, int childIndex);
@@ -74,7 +77,8 @@ WIN_EXPORT void YGNodeFreeRecursive(const YGNodeRef node);
WIN_EXPORT void YGNodeReset(const YGNodeRef node); WIN_EXPORT void YGNodeReset(const YGNodeRef node);
WIN_EXPORT int32_t YGNodeGetInstanceCount(void); WIN_EXPORT int32_t YGNodeGetInstanceCount(void);
WIN_EXPORT void YGNodeInsertChild(const YGNodeRef node, WIN_EXPORT void YGNodeInsertChild(
const YGNodeRef node,
const YGNodeRef child, const YGNodeRef child,
const uint32_t index); const uint32_t index);
@@ -99,7 +103,8 @@ WIN_EXPORT void YGNodeSetChildren(
const YGNodeRef children[], const YGNodeRef children[],
const uint32_t count); const uint32_t count);
WIN_EXPORT void YGNodeCalculateLayout(const YGNodeRef node, WIN_EXPORT void YGNodeCalculateLayout(
const YGNodeRef node,
const float availableWidth, const float availableWidth,
const float availableHeight, const float availableHeight,
const YGDirection ownerDirection); const YGDirection ownerDirection);
@@ -112,15 +117,18 @@ WIN_EXPORT void YGNodeCalculateLayout(const YGNodeRef node,
// marking manually. // marking manually.
WIN_EXPORT void YGNodeMarkDirty(const YGNodeRef node); WIN_EXPORT void YGNodeMarkDirty(const YGNodeRef node);
// This function marks the current node and all its descendants as dirty. This function is added to test yoga benchmarks. // This function marks the current node and all its descendants as dirty. This
// This function is not expected to be used in production as calling `YGCalculateLayout` will cause the recalculation of each and every node. // function is added to test yoga benchmarks. This function is not expected to
// be used in production as calling `YGCalculateLayout` will cause the
// recalculation of each and every node.
WIN_EXPORT void YGNodeMarkDirtyAndPropogateToDescendants(const YGNodeRef node); WIN_EXPORT void YGNodeMarkDirtyAndPropogateToDescendants(const YGNodeRef node);
WIN_EXPORT void YGNodePrint(const YGNodeRef node, const YGPrintOptions options); WIN_EXPORT void YGNodePrint(const YGNodeRef node, const YGPrintOptions options);
WIN_EXPORT bool YGFloatIsUndefined(const float value); WIN_EXPORT bool YGFloatIsUndefined(const float value);
WIN_EXPORT bool YGNodeCanUseCachedMeasurement(const YGMeasureMode widthMode, WIN_EXPORT bool YGNodeCanUseCachedMeasurement(
const YGMeasureMode widthMode,
const float width, const float width,
const YGMeasureMode heightMode, const YGMeasureMode heightMode,
const float height, const float height,
@@ -134,19 +142,24 @@ WIN_EXPORT bool YGNodeCanUseCachedMeasurement(const YGMeasureMode widthMode,
const float marginColumn, const float marginColumn,
const YGConfigRef config); const YGConfigRef config);
WIN_EXPORT void YGNodeCopyStyle(const YGNodeRef dstNode, const YGNodeRef srcNode); WIN_EXPORT void YGNodeCopyStyle(
const YGNodeRef dstNode,
const YGNodeRef srcNode);
#define YG_NODE_PROPERTY(type, name, paramName) \ #define YG_NODE_PROPERTY(type, name, paramName) \
WIN_EXPORT void YGNodeSet##name(const YGNodeRef node, type paramName); \ WIN_EXPORT void YGNodeSet##name(const YGNodeRef node, type paramName); \
WIN_EXPORT type YGNodeGet##name(const YGNodeRef node); WIN_EXPORT type YGNodeGet##name(const YGNodeRef node);
#define YG_NODE_STYLE_PROPERTY(type, name, paramName) \ #define YG_NODE_STYLE_PROPERTY(type, name, paramName) \
WIN_EXPORT void YGNodeStyleSet##name(const YGNodeRef node, const type paramName); \ WIN_EXPORT void YGNodeStyleSet##name( \
const YGNodeRef node, const type paramName); \
WIN_EXPORT type YGNodeStyleGet##name(const YGNodeRef node); WIN_EXPORT type YGNodeStyleGet##name(const YGNodeRef node);
#define YG_NODE_STYLE_PROPERTY_UNIT(type, name, paramName) \ #define YG_NODE_STYLE_PROPERTY_UNIT(type, name, paramName) \
WIN_EXPORT void YGNodeStyleSet##name(const YGNodeRef node, const float paramName); \ WIN_EXPORT void YGNodeStyleSet##name( \
WIN_EXPORT void YGNodeStyleSet##name##Percent(const YGNodeRef node, const float paramName); \ const YGNodeRef node, const float paramName); \
WIN_EXPORT void YGNodeStyleSet##name##Percent( \
const YGNodeRef node, const float paramName); \
WIN_EXPORT type YGNodeStyleGet##name(const YGNodeRef node); WIN_EXPORT type YGNodeStyleGet##name(const YGNodeRef node);
#define YG_NODE_STYLE_PROPERTY_UNIT_AUTO(type, name, paramName) \ #define YG_NODE_STYLE_PROPERTY_UNIT_AUTO(type, name, paramName) \
@@ -154,28 +167,28 @@ WIN_EXPORT void YGNodeCopyStyle(const YGNodeRef dstNode, const YGNodeRef srcNode
WIN_EXPORT void YGNodeStyleSet##name##Auto(const YGNodeRef node); WIN_EXPORT void YGNodeStyleSet##name##Auto(const YGNodeRef node);
#define YG_NODE_STYLE_EDGE_PROPERTY(type, name, paramName) \ #define YG_NODE_STYLE_EDGE_PROPERTY(type, name, paramName) \
WIN_EXPORT void YGNodeStyleSet##name(const YGNodeRef node, \ WIN_EXPORT void YGNodeStyleSet##name( \
const YGEdge edge, \ const YGNodeRef node, const YGEdge edge, const type paramName); \
const type paramName); \
WIN_EXPORT type YGNodeStyleGet##name(const YGNodeRef node, const YGEdge edge); WIN_EXPORT type YGNodeStyleGet##name(const YGNodeRef node, const YGEdge edge);
#define YG_NODE_STYLE_EDGE_PROPERTY_UNIT(type, name, paramName) \ #define YG_NODE_STYLE_EDGE_PROPERTY_UNIT(type, name, paramName) \
WIN_EXPORT void YGNodeStyleSet##name(const YGNodeRef node, \ WIN_EXPORT void YGNodeStyleSet##name( \
const YGEdge edge, \ const YGNodeRef node, const YGEdge edge, const float paramName); \
const float paramName); \ WIN_EXPORT void YGNodeStyleSet##name##Percent( \
WIN_EXPORT void YGNodeStyleSet##name##Percent(const YGNodeRef node, \ const YGNodeRef node, const YGEdge edge, const float paramName); \
const YGEdge edge, \ WIN_EXPORT WIN_STRUCT(type) \
const float paramName); \ YGNodeStyleGet##name(const YGNodeRef node, const YGEdge edge);
WIN_EXPORT WIN_STRUCT(type) YGNodeStyleGet##name(const YGNodeRef node, const YGEdge edge);
#define YG_NODE_STYLE_EDGE_PROPERTY_UNIT_AUTO(type, name) \ #define YG_NODE_STYLE_EDGE_PROPERTY_UNIT_AUTO(type, name) \
WIN_EXPORT void YGNodeStyleSet##name##Auto(const YGNodeRef node, const YGEdge edge); WIN_EXPORT void YGNodeStyleSet##name##Auto( \
const YGNodeRef node, const YGEdge edge);
#define YG_NODE_LAYOUT_PROPERTY(type, name) \ #define YG_NODE_LAYOUT_PROPERTY(type, name) \
WIN_EXPORT type YGNodeLayoutGet##name(const YGNodeRef node); WIN_EXPORT type YGNodeLayoutGet##name(const YGNodeRef node);
#define YG_NODE_LAYOUT_EDGE_PROPERTY(type, name) \ #define YG_NODE_LAYOUT_EDGE_PROPERTY(type, name) \
WIN_EXPORT type YGNodeLayoutGet##name(const YGNodeRef node, const YGEdge edge); WIN_EXPORT type YGNodeLayoutGet##name( \
const YGNodeRef node, const YGEdge edge);
void* YGNodeGetContext(YGNodeRef node); void* YGNodeGetContext(YGNodeRef node);
void YGNodeSetContext(YGNodeRef node, void* context); void YGNodeSetContext(YGNodeRef node, void* context);
@@ -224,16 +237,18 @@ YG_NODE_STYLE_PROPERTY_UNIT(YGValue, MaxHeight, maxHeight);
// Yoga specific properties, not compatible with flexbox specification // Yoga specific properties, not compatible with flexbox specification
// Aspect ratio control the size of the undefined dimension of a node. // Aspect ratio control the size of the undefined dimension of a node.
// Aspect ratio is encoded as a floating point value width/height. e.g. A value of 2 leads to a node // Aspect ratio is encoded as a floating point value width/height. e.g. A value
// with a width twice the size of its height while a value of 0.5 gives the opposite effect. // of 2 leads to a node with a width twice the size of its height while a value
// of 0.5 gives the opposite effect.
// //
// - On a node with a set width/height aspect ratio control the size of the unset dimension // - On a node with a set width/height aspect ratio control the size of the
// - On a node with a set flex basis aspect ratio controls the size of the node in the cross axis if // unset dimension
// unset // - On a node with a set flex basis aspect ratio controls the size of the node
// - On a node with a measure function aspect ratio works as though the measure function measures // in the cross axis if unset
// the flex basis // - On a node with a measure function aspect ratio works as though the measure
// - On a node with flex grow/shrink aspect ratio controls the size of the node in the cross axis if // function measures the flex basis
// unset // - On a node with flex grow/shrink aspect ratio controls the size of the node
// in the cross axis if unset
// - Aspect ratio takes min/max dimensions into account // - Aspect ratio takes min/max dimensions into account
YG_NODE_STYLE_PROPERTY(float, AspectRatio, aspectRatio); YG_NODE_STYLE_PROPERTY(float, AspectRatio, aspectRatio);
@@ -247,36 +262,47 @@ YG_NODE_LAYOUT_PROPERTY(YGDirection, Direction);
YG_NODE_LAYOUT_PROPERTY(bool, HadOverflow); YG_NODE_LAYOUT_PROPERTY(bool, HadOverflow);
bool YGNodeLayoutGetDidLegacyStretchFlagAffectLayout(const YGNodeRef node); bool YGNodeLayoutGetDidLegacyStretchFlagAffectLayout(const YGNodeRef node);
// Get the computed values for these nodes after performing layout. If they were set using // Get the computed values for these nodes after performing layout. If they were
// point values then the returned value will be the same as YGNodeStyleGetXXX. However if // set using point values then the returned value will be the same as
// they were set using a percentage value then the returned value is the computed value used // YGNodeStyleGetXXX. However if they were set using a percentage value then the
// during layout. // returned value is the computed value used during layout.
YG_NODE_LAYOUT_EDGE_PROPERTY(float, Margin); YG_NODE_LAYOUT_EDGE_PROPERTY(float, Margin);
YG_NODE_LAYOUT_EDGE_PROPERTY(float, Border); YG_NODE_LAYOUT_EDGE_PROPERTY(float, Border);
YG_NODE_LAYOUT_EDGE_PROPERTY(float, Padding); YG_NODE_LAYOUT_EDGE_PROPERTY(float, Padding);
WIN_EXPORT void YGConfigSetLogger(const YGConfigRef config, YGLogger logger); WIN_EXPORT void YGConfigSetLogger(const YGConfigRef config, YGLogger logger);
WIN_EXPORT void YGLog(const YGNodeRef node, YGLogLevel level, const char *message, ...); WIN_EXPORT void
WIN_EXPORT void YGLogWithConfig(const YGConfigRef config, YGLogLevel level, const char *format, ...); YGLog(const YGNodeRef node, YGLogLevel level, const char* message, ...);
WIN_EXPORT void YGAssert(const bool condition, const char *message); WIN_EXPORT void YGLogWithConfig(
WIN_EXPORT void YGAssertWithNode(const YGNodeRef node, const bool condition, const char *message); const YGConfigRef config,
WIN_EXPORT void YGAssertWithConfig(const YGConfigRef config, YGLogLevel level,
const char* format,
...);
WIN_EXPORT void YGAssert(const bool condition, const char* message);
WIN_EXPORT void YGAssertWithNode(
const YGNodeRef node,
const bool condition, const bool condition,
const char *message); const char* message);
WIN_EXPORT void YGAssertWithConfig(
const YGConfigRef config,
const bool condition,
const char* message);
// Set this to number of pixels in 1 point to round calculation results // Set this to number of pixels in 1 point to round calculation results
// If you want to avoid rounding - set PointScaleFactor to 0 // If you want to avoid rounding - set PointScaleFactor to 0
WIN_EXPORT void YGConfigSetPointScaleFactor(const YGConfigRef config, const float pixelsInPoint); WIN_EXPORT void YGConfigSetPointScaleFactor(
const YGConfigRef config,
const float pixelsInPoint);
void YGConfigSetShouldDiffLayoutWithoutLegacyStretchBehaviour( void YGConfigSetShouldDiffLayoutWithoutLegacyStretchBehaviour(
const YGConfigRef config, const YGConfigRef config,
const bool shouldDiffLayout); const bool shouldDiffLayout);
// Yoga previously had an error where containers would take the maximum space possible instead of // Yoga previously had an error where containers would take the maximum space
// the minimum // possible instead of the minimum like they are supposed to. In practice this
// like they are supposed to. In practice this resulted in implicit behaviour similar to align-self: // resulted in implicit behaviour similar to align-self: stretch; Because this
// stretch; // was such a long-standing bug we must allow legacy users to switch back to
// Because this was such a long-standing bug we must allow legacy users to switch back to this // this behaviour.
// behaviour. WIN_EXPORT void YGConfigSetUseLegacyStretchBehaviour(
WIN_EXPORT void YGConfigSetUseLegacyStretchBehaviour(const YGConfigRef config, const YGConfigRef config,
const bool useLegacyStretchBehaviour); const bool useLegacyStretchBehaviour);
// YGConfig // YGConfig
@@ -285,25 +311,30 @@ WIN_EXPORT void YGConfigFree(const YGConfigRef config);
WIN_EXPORT void YGConfigCopy(const YGConfigRef dest, const YGConfigRef src); WIN_EXPORT void YGConfigCopy(const YGConfigRef dest, const YGConfigRef src);
WIN_EXPORT int32_t YGConfigGetInstanceCount(void); WIN_EXPORT int32_t YGConfigGetInstanceCount(void);
WIN_EXPORT void YGConfigSetExperimentalFeatureEnabled(const YGConfigRef config, WIN_EXPORT void YGConfigSetExperimentalFeatureEnabled(
const YGConfigRef config,
const YGExperimentalFeature feature, const YGExperimentalFeature feature,
const bool enabled); const bool enabled);
WIN_EXPORT bool YGConfigIsExperimentalFeatureEnabled(const YGConfigRef config, WIN_EXPORT bool YGConfigIsExperimentalFeatureEnabled(
const YGConfigRef config,
const YGExperimentalFeature feature); const YGExperimentalFeature feature);
// Using the web defaults is the prefered configuration for new projects. // Using the web defaults is the prefered configuration for new projects.
// Usage of non web defaults should be considered as legacy. // Usage of non web defaults should be considered as legacy.
WIN_EXPORT void YGConfigSetUseWebDefaults(const YGConfigRef config, const bool enabled); WIN_EXPORT void YGConfigSetUseWebDefaults(
const YGConfigRef config,
const bool enabled);
WIN_EXPORT bool YGConfigGetUseWebDefaults(const YGConfigRef config); WIN_EXPORT bool YGConfigGetUseWebDefaults(const YGConfigRef config);
WIN_EXPORT void YGConfigSetCloneNodeFunc(const YGConfigRef config, WIN_EXPORT void YGConfigSetCloneNodeFunc(
const YGConfigRef config,
const YGCloneNodeFunc callback); const YGCloneNodeFunc callback);
// Export only for C# // Export only for C#
WIN_EXPORT YGConfigRef YGConfigGetDefault(void); WIN_EXPORT YGConfigRef YGConfigGetDefault(void);
WIN_EXPORT void YGConfigSetContext(const YGConfigRef config, void *context); WIN_EXPORT void YGConfigSetContext(const YGConfigRef config, void* context);
WIN_EXPORT void *YGConfigGetContext(const YGConfigRef config); WIN_EXPORT void* YGConfigGetContext(const YGConfigRef config);
WIN_EXPORT float YGRoundValueToPixelGrid( WIN_EXPORT float YGRoundValueToPixelGrid(
const float value, const float value,
@@ -319,7 +350,9 @@ YG_EXTERN_C_END
#include <vector> #include <vector>
// Calls f on each node in the tree including the given node argument. // Calls f on each node in the tree including the given node argument.
extern void YGTraversePreOrder(YGNodeRef const node, std::function<void(YGNodeRef node)>&& f); extern void YGTraversePreOrder(
YGNodeRef const node,
std::function<void(YGNodeRef node)>&& f);
extern void YGNodeSetChildren( extern void YGNodeSetChildren(
YGNodeRef const owner, YGNodeRef const owner,