Apply clang-format rules

Summary:
@public

Formats Yoga's source according to our clang-format configuration

Reviewed By: SidharthGuglani

Differential Revision: D13596650

fbshipit-source-id: c3722d4eafd63b7596a8b1e85c0197e9d2d6cb7d
This commit is contained in:
David Aurelio
2019-01-08 12:47:53 -08:00
committed by Facebook Github Bot
parent 5ee32fbefc
commit ab9d06abf5
16 changed files with 188 additions and 176 deletions

View File

@@ -15,7 +15,7 @@
#define NUM_REPETITIONS 1000 #define NUM_REPETITIONS 1000
#define YGBENCHMARKS(BLOCK) \ #define YGBENCHMARKS(BLOCK) \
int main(int argc, char const *argv[]) { \ int main(int argc, char const* argv[]) { \
clock_t __start; \ clock_t __start; \
clock_t __endTimes[NUM_REPETITIONS]; \ clock_t __endTimes[NUM_REPETITIONS]; \
{ BLOCK } \ { BLOCK } \
@@ -25,14 +25,13 @@
#define YGBENCHMARK(NAME, BLOCK) \ #define YGBENCHMARK(NAME, BLOCK) \
__start = clock(); \ __start = clock(); \
for (uint32_t __i = 0; __i < NUM_REPETITIONS; __i++) { \ for (uint32_t __i = 0; __i < NUM_REPETITIONS; __i++) { \
{ BLOCK } \ {BLOCK} __endTimes[__i] = clock(); \
__endTimes[__i] = clock(); \
} \ } \
__printBenchmarkResult(NAME, __start, __endTimes); __printBenchmarkResult(NAME, __start, __endTimes);
static int __compareDoubles(const void *a, const void *b) { static int __compareDoubles(const void* a, const void* b) {
double arg1 = *(const double *) a; double arg1 = *(const double*) a;
double arg2 = *(const double *) b; double arg2 = *(const double*) b;
if (arg1 < arg2) { if (arg1 < arg2) {
return -1; return -1;
@@ -45,7 +44,10 @@ static int __compareDoubles(const void *a, const void *b) {
return 0; return 0;
} }
static void __printBenchmarkResult(char *name, clock_t start, clock_t *endTimes) { static void __printBenchmarkResult(
char* name,
clock_t start,
clock_t* endTimes) {
double timesInMs[NUM_REPETITIONS]; double timesInMs[NUM_REPETITIONS];
double mean = 0; double mean = 0;
clock_t lastEnd = start; clock_t lastEnd = start;
@@ -69,12 +71,12 @@ static void __printBenchmarkResult(char *name, clock_t start, clock_t *endTimes)
printf("%s: median: %lf ms, stddev: %lf ms\n", name, median, stddev); printf("%s: median: %lf ms, stddev: %lf ms\n", name, median, stddev);
} }
static YGSize _measure(
static YGSize _measure(YGNodeRef node, YGNodeRef node,
float width, float width,
YGMeasureMode widthMode, YGMeasureMode widthMode,
float height, float height,
YGMeasureMode heightMode) { YGMeasureMode heightMode) {
return (YGSize){ return (YGSize){
.width = widthMode == YGMeasureModeUndefined ? 10 : width, .width = widthMode == YGMeasureModeUndefined ? 10 : width,
.height = heightMode == YGMeasureModeUndefined ? 10 : width, .height = heightMode == YGMeasureModeUndefined ? 10 : width,
@@ -82,7 +84,6 @@ static YGSize _measure(YGNodeRef node,
} }
YGBENCHMARKS({ YGBENCHMARKS({
YGBENCHMARK("Stack with flex", { YGBENCHMARK("Stack with flex", {
const YGNodeRef root = YGNodeNew(); const YGNodeRef root = YGNodeNew();
YGNodeStyleSetWidth(root, 100); YGNodeStyleSetWidth(root, 100);
@@ -160,7 +161,8 @@ YGBENCHMARKS({
for (uint32_t iiii = 0; iiii < 10; iiii++) { for (uint32_t iiii = 0; iiii < 10; iiii++) {
const YGNodeRef grandGrandGrandChild = YGNodeNew(); const YGNodeRef grandGrandGrandChild = YGNodeNew();
YGNodeStyleSetFlexDirection(grandGrandGrandChild, YGFlexDirectionRow); YGNodeStyleSetFlexDirection(
grandGrandGrandChild, YGFlexDirectionRow);
YGNodeStyleSetFlexGrow(grandGrandGrandChild, 1); YGNodeStyleSetFlexGrow(grandGrandGrandChild, 1);
YGNodeStyleSetWidth(grandGrandGrandChild, 10); YGNodeStyleSetWidth(grandGrandGrandChild, 10);
YGNodeStyleSetHeight(grandGrandGrandChild, 10); YGNodeStyleSetHeight(grandGrandGrandChild, 10);
@@ -173,5 +175,4 @@ YGBENCHMARKS({
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
YGNodeFreeRecursive(root); YGNodeFreeRecursive(root);
}); });
}); });

View File

@@ -100,7 +100,7 @@ static void YGTransferLayoutOutputsRecursive(YGNodeRef root) {
const int PADDING = 2; const int PADDING = 2;
const int BORDER = 4; const int BORDER = 4;
int hasEdgeSetFlag = (int)obj->getFieldValue(edgeSetFlagField); int hasEdgeSetFlag = (int) obj->getFieldValue(edgeSetFlagField);
obj->setFieldValue(widthField, YGNodeLayoutGetWidth(root)); obj->setFieldValue(widthField, YGNodeLayoutGetWidth(root));
obj->setFieldValue(heightField, YGNodeLayoutGetHeight(root)); obj->setFieldValue(heightField, YGNodeLayoutGetHeight(root));
@@ -180,8 +180,10 @@ static inline YGConfigRef _jlong2YGConfigRef(jlong addr) {
return reinterpret_cast<YGConfigRef>(static_cast<intptr_t>(addr)); return reinterpret_cast<YGConfigRef>(static_cast<intptr_t>(addr));
} }
static YGNodeRef static YGNodeRef YGJNIOnNodeClonedFunc(
YGJNIOnNodeClonedFunc(YGNodeRef oldNode, YGNodeRef owner, int childIndex) { YGNodeRef oldNode,
YGNodeRef owner,
int childIndex) {
auto config = oldNode->getConfig(); auto config = oldNode->getConfig();
if (!config) { if (!config) {
return nullptr; return nullptr;
@@ -404,7 +406,7 @@ void jni_YGNodeMarkDirtyAndPropogateToDescendants(jlong nativePointer) {
} }
jboolean jni_YGNodeIsDirty(jlong nativePointer) { jboolean jni_YGNodeIsDirty(jlong nativePointer) {
return (jboolean)_jlong2YGNodeRef(nativePointer)->isDirty(); return (jboolean) _jlong2YGNodeRef(nativePointer)->isDirty();
} }
void jni_YGNodeSetHasMeasureFunc(jlong nativePointer, jboolean hasMeasureFunc) { void jni_YGNodeSetHasMeasureFunc(jlong nativePointer, jboolean hasMeasureFunc) {
@@ -432,14 +434,14 @@ struct JYogaValue : public JavaClass<JYogaValue> {
} }
}; };
#define YG_NODE_JNI_STYLE_PROP(javatype, type, name) \ #define YG_NODE_JNI_STYLE_PROP(javatype, type, name) \
javatype jni_YGNodeStyleGet##name(jlong nativePointer) { \ javatype jni_YGNodeStyleGet##name(jlong nativePointer) { \
return (javatype)YGNodeStyleGet##name(_jlong2YGNodeRef(nativePointer)); \ return (javatype) YGNodeStyleGet##name(_jlong2YGNodeRef(nativePointer)); \
} \ } \
\ \
void jni_YGNodeStyleSet##name(jlong nativePointer, javatype value) { \ void jni_YGNodeStyleSet##name(jlong nativePointer, javatype value) { \
YGNodeStyleSet##name( \ YGNodeStyleSet##name( \
_jlong2YGNodeRef(nativePointer), static_cast<type>(value)); \ _jlong2YGNodeRef(nativePointer), static_cast<type>(value)); \
} }
#define YG_NODE_JNI_STYLE_UNIT_PROP(name) \ #define YG_NODE_JNI_STYLE_UNIT_PROP(name) \
@@ -467,7 +469,7 @@ struct JYogaValue : public JavaClass<JYogaValue> {
#define YG_NODE_JNI_STYLE_EDGE_PROP(javatype, type, name) \ #define YG_NODE_JNI_STYLE_EDGE_PROP(javatype, type, name) \
javatype jni_YGNodeStyleGet##name(jlong nativePointer, jint edge) { \ javatype jni_YGNodeStyleGet##name(jlong nativePointer, jint edge) { \
return (javatype)YGNodeStyleGet##name( \ return (javatype) YGNodeStyleGet##name( \
_jlong2YGNodeRef(nativePointer), static_cast<YGEdge>(edge)); \ _jlong2YGNodeRef(nativePointer), static_cast<YGEdge>(edge)); \
} \ } \
\ \

View File

@@ -42,7 +42,7 @@ namespace detail {
class CompactValue { class CompactValue {
friend constexpr bool operator==(CompactValue, CompactValue) noexcept; friend constexpr bool operator==(CompactValue, CompactValue) noexcept;
public: public:
static constexpr auto LOWER_BOUND = 1.08420217e-19f; static constexpr auto LOWER_BOUND = 1.08420217e-19f;
static constexpr auto UPPER_BOUND_POINT = 36893485948395847680.0f; static constexpr auto UPPER_BOUND_POINT = 36893485948395847680.0f;
static constexpr auto UPPER_BOUND_PERCENT = 18446742974197923840.0f; static constexpr auto UPPER_BOUND_PERCENT = 18446742974197923840.0f;
@@ -137,7 +137,7 @@ class CompactValue {
return payload_.repr == AUTO_BITS; return payload_.repr == AUTO_BITS;
} }
private: private:
union Payload { union Payload {
float value; float value;
uint32_t repr; uint32_t repr;

View File

@@ -6,8 +6,8 @@
*/ */
#include "YGEnums.h" #include "YGEnums.h"
const char *YGAlignToString(const YGAlign value){ const char* YGAlignToString(const YGAlign value) {
switch(value){ switch (value) {
case YGAlignAuto: case YGAlignAuto:
return "auto"; return "auto";
case YGAlignFlexStart: case YGAlignFlexStart:
@@ -28,8 +28,8 @@ const char *YGAlignToString(const YGAlign value){
return "unknown"; return "unknown";
} }
const char *YGDimensionToString(const YGDimension value){ const char* YGDimensionToString(const YGDimension value) {
switch(value){ switch (value) {
case YGDimensionWidth: case YGDimensionWidth:
return "width"; return "width";
case YGDimensionHeight: case YGDimensionHeight:
@@ -38,8 +38,8 @@ const char *YGDimensionToString(const YGDimension value){
return "unknown"; return "unknown";
} }
const char *YGDirectionToString(const YGDirection value){ const char* YGDirectionToString(const YGDirection value) {
switch(value){ switch (value) {
case YGDirectionInherit: case YGDirectionInherit:
return "inherit"; return "inherit";
case YGDirectionLTR: case YGDirectionLTR:
@@ -50,8 +50,8 @@ const char *YGDirectionToString(const YGDirection value){
return "unknown"; return "unknown";
} }
const char *YGDisplayToString(const YGDisplay value){ const char* YGDisplayToString(const YGDisplay value) {
switch(value){ switch (value) {
case YGDisplayFlex: case YGDisplayFlex:
return "flex"; return "flex";
case YGDisplayNone: case YGDisplayNone:
@@ -60,8 +60,8 @@ const char *YGDisplayToString(const YGDisplay value){
return "unknown"; return "unknown";
} }
const char *YGEdgeToString(const YGEdge value){ const char* YGEdgeToString(const YGEdge value) {
switch(value){ switch (value) {
case YGEdgeLeft: case YGEdgeLeft:
return "left"; return "left";
case YGEdgeTop: case YGEdgeTop:
@@ -84,16 +84,16 @@ const char *YGEdgeToString(const YGEdge value){
return "unknown"; return "unknown";
} }
const char *YGExperimentalFeatureToString(const YGExperimentalFeature value){ const char* YGExperimentalFeatureToString(const YGExperimentalFeature value) {
switch(value){ switch (value) {
case YGExperimentalFeatureWebFlexBasis: case YGExperimentalFeatureWebFlexBasis:
return "web-flex-basis"; return "web-flex-basis";
} }
return "unknown"; return "unknown";
} }
const char *YGFlexDirectionToString(const YGFlexDirection value){ const char* YGFlexDirectionToString(const YGFlexDirection value) {
switch(value){ switch (value) {
case YGFlexDirectionColumn: case YGFlexDirectionColumn:
return "column"; return "column";
case YGFlexDirectionColumnReverse: case YGFlexDirectionColumnReverse:
@@ -106,8 +106,8 @@ const char *YGFlexDirectionToString(const YGFlexDirection value){
return "unknown"; return "unknown";
} }
const char *YGJustifyToString(const YGJustify value){ const char* YGJustifyToString(const YGJustify value) {
switch(value){ switch (value) {
case YGJustifyFlexStart: case YGJustifyFlexStart:
return "flex-start"; return "flex-start";
case YGJustifyCenter: case YGJustifyCenter:
@@ -124,8 +124,8 @@ const char *YGJustifyToString(const YGJustify value){
return "unknown"; return "unknown";
} }
const char *YGLogLevelToString(const YGLogLevel value){ const char* YGLogLevelToString(const YGLogLevel value) {
switch(value){ switch (value) {
case YGLogLevelError: case YGLogLevelError:
return "error"; return "error";
case YGLogLevelWarn: case YGLogLevelWarn:
@@ -142,8 +142,8 @@ const char *YGLogLevelToString(const YGLogLevel value){
return "unknown"; return "unknown";
} }
const char *YGMeasureModeToString(const YGMeasureMode value){ const char* YGMeasureModeToString(const YGMeasureMode value) {
switch(value){ switch (value) {
case YGMeasureModeUndefined: case YGMeasureModeUndefined:
return "undefined"; return "undefined";
case YGMeasureModeExactly: case YGMeasureModeExactly:
@@ -154,8 +154,8 @@ const char *YGMeasureModeToString(const YGMeasureMode value){
return "unknown"; return "unknown";
} }
const char *YGNodeTypeToString(const YGNodeType value){ const char* YGNodeTypeToString(const YGNodeType value) {
switch(value){ switch (value) {
case YGNodeTypeDefault: case YGNodeTypeDefault:
return "default"; return "default";
case YGNodeTypeText: case YGNodeTypeText:
@@ -164,8 +164,8 @@ const char *YGNodeTypeToString(const YGNodeType value){
return "unknown"; return "unknown";
} }
const char *YGOverflowToString(const YGOverflow value){ const char* YGOverflowToString(const YGOverflow value) {
switch(value){ switch (value) {
case YGOverflowVisible: case YGOverflowVisible:
return "visible"; return "visible";
case YGOverflowHidden: case YGOverflowHidden:
@@ -176,8 +176,8 @@ const char *YGOverflowToString(const YGOverflow value){
return "unknown"; return "unknown";
} }
const char *YGPositionTypeToString(const YGPositionType value){ const char* YGPositionTypeToString(const YGPositionType value) {
switch(value){ switch (value) {
case YGPositionTypeRelative: case YGPositionTypeRelative:
return "relative"; return "relative";
case YGPositionTypeAbsolute: case YGPositionTypeAbsolute:
@@ -186,8 +186,8 @@ const char *YGPositionTypeToString(const YGPositionType value){
return "unknown"; return "unknown";
} }
const char *YGPrintOptionsToString(const YGPrintOptions value){ const char* YGPrintOptionsToString(const YGPrintOptions value) {
switch(value){ switch (value) {
case YGPrintOptionsLayout: case YGPrintOptionsLayout:
return "layout"; return "layout";
case YGPrintOptionsStyle: case YGPrintOptionsStyle:
@@ -198,8 +198,8 @@ const char *YGPrintOptionsToString(const YGPrintOptions value){
return "unknown"; return "unknown";
} }
const char *YGUnitToString(const YGUnit value){ const char* YGUnitToString(const YGUnit value) {
switch(value){ switch (value) {
case YGUnitUndefined: case YGUnitUndefined:
return "undefined"; return "undefined";
case YGUnitPoint: case YGUnitPoint:
@@ -212,8 +212,8 @@ const char *YGUnitToString(const YGUnit value){
return "unknown"; return "unknown";
} }
const char *YGWrapToString(const YGWrap value){ const char* YGWrapToString(const YGWrap value) {
switch(value){ switch (value) {
case YGWrapNoWrap: case YGWrapNoWrap:
return "no-wrap"; return "no-wrap";
case YGWrapWrap: case YGWrapWrap:

View File

@@ -11,68 +11,69 @@
YG_EXTERN_C_BEGIN YG_EXTERN_C_BEGIN
#define YGAlignCount 8 #define YGAlignCount 8
typedef YG_ENUM_BEGIN(YGAlign) { typedef YG_ENUM_BEGIN(YGAlign){
YGAlignAuto, YGAlignAuto,
YGAlignFlexStart, YGAlignFlexStart,
YGAlignCenter, YGAlignCenter,
YGAlignFlexEnd, YGAlignFlexEnd,
YGAlignStretch, YGAlignStretch,
YGAlignBaseline, YGAlignBaseline,
YGAlignSpaceBetween, YGAlignSpaceBetween,
YGAlignSpaceAround, YGAlignSpaceAround,
} YG_ENUM_END(YGAlign); } YG_ENUM_END(YGAlign);
WIN_EXPORT const char *YGAlignToString(const YGAlign value); WIN_EXPORT const char* YGAlignToString(const YGAlign value);
#define YGDimensionCount 2 #define YGDimensionCount 2
typedef YG_ENUM_BEGIN(YGDimension) { typedef YG_ENUM_BEGIN(YGDimension){
YGDimensionWidth, YGDimensionWidth,
YGDimensionHeight, YGDimensionHeight,
} YG_ENUM_END(YGDimension); } YG_ENUM_END(YGDimension);
WIN_EXPORT const char *YGDimensionToString(const YGDimension value); WIN_EXPORT const char* YGDimensionToString(const YGDimension value);
#define YGDirectionCount 3 #define YGDirectionCount 3
typedef YG_ENUM_BEGIN(YGDirection) { typedef YG_ENUM_BEGIN(YGDirection){
YGDirectionInherit, YGDirectionInherit,
YGDirectionLTR, YGDirectionLTR,
YGDirectionRTL, YGDirectionRTL,
} YG_ENUM_END(YGDirection); } YG_ENUM_END(YGDirection);
WIN_EXPORT const char *YGDirectionToString(const YGDirection value); WIN_EXPORT const char* YGDirectionToString(const YGDirection value);
#define YGDisplayCount 2 #define YGDisplayCount 2
typedef YG_ENUM_BEGIN(YGDisplay) { typedef YG_ENUM_BEGIN(YGDisplay){
YGDisplayFlex, YGDisplayFlex,
YGDisplayNone, YGDisplayNone,
} YG_ENUM_END(YGDisplay); } YG_ENUM_END(YGDisplay);
WIN_EXPORT const char *YGDisplayToString(const YGDisplay value); WIN_EXPORT const char* YGDisplayToString(const YGDisplay value);
#define YGEdgeCount 9 #define YGEdgeCount 9
typedef YG_ENUM_BEGIN(YGEdge) { typedef YG_ENUM_BEGIN(YGEdge){
YGEdgeLeft, YGEdgeLeft,
YGEdgeTop, YGEdgeTop,
YGEdgeRight, YGEdgeRight,
YGEdgeBottom, YGEdgeBottom,
YGEdgeStart, YGEdgeStart,
YGEdgeEnd, YGEdgeEnd,
YGEdgeHorizontal, YGEdgeHorizontal,
YGEdgeVertical, YGEdgeVertical,
YGEdgeAll, YGEdgeAll,
} YG_ENUM_END(YGEdge); } YG_ENUM_END(YGEdge);
WIN_EXPORT const char *YGEdgeToString(const YGEdge value); WIN_EXPORT const char* YGEdgeToString(const YGEdge value);
#define YGExperimentalFeatureCount 1 #define YGExperimentalFeatureCount 1
typedef YG_ENUM_BEGIN(YGExperimentalFeature) { typedef YG_ENUM_BEGIN(YGExperimentalFeature){
YGExperimentalFeatureWebFlexBasis, YGExperimentalFeatureWebFlexBasis,
} YG_ENUM_END(YGExperimentalFeature); } YG_ENUM_END(YGExperimentalFeature);
WIN_EXPORT const char *YGExperimentalFeatureToString(const YGExperimentalFeature value); WIN_EXPORT const char* YGExperimentalFeatureToString(
const YGExperimentalFeature value);
#define YGFlexDirectionCount 4 #define YGFlexDirectionCount 4
typedef YG_ENUM_BEGIN(YGFlexDirection) { typedef YG_ENUM_BEGIN(YGFlexDirection){
YGFlexDirectionColumn, YGFlexDirectionColumn,
YGFlexDirectionColumnReverse, YGFlexDirectionColumnReverse,
YGFlexDirectionRow, YGFlexDirectionRow,
YGFlexDirectionRowReverse, YGFlexDirectionRowReverse,
} YG_ENUM_END(YGFlexDirection); } YG_ENUM_END(YGFlexDirection);
WIN_EXPORT const char *YGFlexDirectionToString(const YGFlexDirection value); WIN_EXPORT const char* YGFlexDirectionToString(const YGFlexDirection value);
#define YGJustifyCount 6 #define YGJustifyCount 6
typedef YG_ENUM_BEGIN(YGJustify){ typedef YG_ENUM_BEGIN(YGJustify){
@@ -83,72 +84,72 @@ typedef YG_ENUM_BEGIN(YGJustify){
YGJustifySpaceAround, YGJustifySpaceAround,
YGJustifySpaceEvenly, YGJustifySpaceEvenly,
} YG_ENUM_END(YGJustify); } YG_ENUM_END(YGJustify);
WIN_EXPORT const char *YGJustifyToString(const YGJustify value); WIN_EXPORT const char* YGJustifyToString(const YGJustify value);
#define YGLogLevelCount 6 #define YGLogLevelCount 6
typedef YG_ENUM_BEGIN(YGLogLevel) { typedef YG_ENUM_BEGIN(YGLogLevel){
YGLogLevelError, YGLogLevelError,
YGLogLevelWarn, YGLogLevelWarn,
YGLogLevelInfo, YGLogLevelInfo,
YGLogLevelDebug, YGLogLevelDebug,
YGLogLevelVerbose, YGLogLevelVerbose,
YGLogLevelFatal, YGLogLevelFatal,
} YG_ENUM_END(YGLogLevel); } YG_ENUM_END(YGLogLevel);
WIN_EXPORT const char *YGLogLevelToString(const YGLogLevel value); WIN_EXPORT const char* YGLogLevelToString(const YGLogLevel value);
#define YGMeasureModeCount 3 #define YGMeasureModeCount 3
typedef YG_ENUM_BEGIN(YGMeasureMode) { typedef YG_ENUM_BEGIN(YGMeasureMode){
YGMeasureModeUndefined, YGMeasureModeUndefined,
YGMeasureModeExactly, YGMeasureModeExactly,
YGMeasureModeAtMost, YGMeasureModeAtMost,
} YG_ENUM_END(YGMeasureMode); } YG_ENUM_END(YGMeasureMode);
WIN_EXPORT const char *YGMeasureModeToString(const YGMeasureMode value); WIN_EXPORT const char* YGMeasureModeToString(const YGMeasureMode value);
#define YGNodeTypeCount 2 #define YGNodeTypeCount 2
typedef YG_ENUM_BEGIN(YGNodeType) { typedef YG_ENUM_BEGIN(YGNodeType){
YGNodeTypeDefault, YGNodeTypeDefault,
YGNodeTypeText, YGNodeTypeText,
} YG_ENUM_END(YGNodeType); } YG_ENUM_END(YGNodeType);
WIN_EXPORT const char *YGNodeTypeToString(const YGNodeType value); WIN_EXPORT const char* YGNodeTypeToString(const YGNodeType value);
#define YGOverflowCount 3 #define YGOverflowCount 3
typedef YG_ENUM_BEGIN(YGOverflow) { typedef YG_ENUM_BEGIN(YGOverflow){
YGOverflowVisible, YGOverflowVisible,
YGOverflowHidden, YGOverflowHidden,
YGOverflowScroll, YGOverflowScroll,
} YG_ENUM_END(YGOverflow); } YG_ENUM_END(YGOverflow);
WIN_EXPORT const char *YGOverflowToString(const YGOverflow value); WIN_EXPORT const char* YGOverflowToString(const YGOverflow value);
#define YGPositionTypeCount 2 #define YGPositionTypeCount 2
typedef YG_ENUM_BEGIN(YGPositionType) { typedef YG_ENUM_BEGIN(YGPositionType){
YGPositionTypeRelative, YGPositionTypeRelative,
YGPositionTypeAbsolute, YGPositionTypeAbsolute,
} YG_ENUM_END(YGPositionType); } YG_ENUM_END(YGPositionType);
WIN_EXPORT const char *YGPositionTypeToString(const YGPositionType value); WIN_EXPORT const char* YGPositionTypeToString(const YGPositionType value);
#define YGPrintOptionsCount 3 #define YGPrintOptionsCount 3
typedef YG_ENUM_BEGIN(YGPrintOptions) { typedef YG_ENUM_BEGIN(YGPrintOptions){
YGPrintOptionsLayout = 1, YGPrintOptionsLayout = 1,
YGPrintOptionsStyle = 2, YGPrintOptionsStyle = 2,
YGPrintOptionsChildren = 4, YGPrintOptionsChildren = 4,
} YG_ENUM_END(YGPrintOptions); } YG_ENUM_END(YGPrintOptions);
WIN_EXPORT const char *YGPrintOptionsToString(const YGPrintOptions value); WIN_EXPORT const char* YGPrintOptionsToString(const YGPrintOptions value);
#define YGUnitCount 4 #define YGUnitCount 4
typedef YG_ENUM_BEGIN(YGUnit) { typedef YG_ENUM_BEGIN(YGUnit){
YGUnitUndefined, YGUnitUndefined,
YGUnitPoint, YGUnitPoint,
YGUnitPercent, YGUnitPercent,
YGUnitAuto, YGUnitAuto,
} YG_ENUM_END(YGUnit); } YG_ENUM_END(YGUnit);
WIN_EXPORT const char *YGUnitToString(const YGUnit value); WIN_EXPORT const char* YGUnitToString(const YGUnit value);
#define YGWrapCount 3 #define YGWrapCount 3
typedef YG_ENUM_BEGIN(YGWrap) { typedef YG_ENUM_BEGIN(YGWrap){
YGWrapNoWrap, YGWrapNoWrap,
YGWrapWrap, YGWrapWrap,
YGWrapWrapReverse, YGWrapWrapReverse,
} YG_ENUM_END(YGWrap); } YG_ENUM_END(YGWrap);
WIN_EXPORT const char *YGWrapToString(const YGWrap value); WIN_EXPORT const char* YGWrapToString(const YGWrap value);
YG_EXTERN_C_END YG_EXTERN_C_END

View File

@@ -11,10 +11,10 @@
#include "Yoga-internal.h" #include "Yoga-internal.h"
struct YGFloatOptional { struct YGFloatOptional {
private: private:
float value_ = std::numeric_limits<float>::quiet_NaN(); float value_ = std::numeric_limits<float>::quiet_NaN();
public: public:
explicit constexpr YGFloatOptional(float value) : value_(value) {} explicit constexpr YGFloatOptional(float value) : value_(value) {}
constexpr YGFloatOptional() = default; constexpr YGFloatOptional() = default;

View File

@@ -28,7 +28,7 @@ struct YGLayout {
// Instead of recomputing the entire layout every single time, we // Instead of recomputing the entire layout every single time, we
// cache some information to break early when nothing changed // cache some information to break early when nothing changed
uint32_t generationCount = 0; uint32_t generationCount = 0;
YGDirection lastOwnerDirection = (YGDirection)-1; YGDirection lastOwnerDirection = (YGDirection) -1;
uint32_t nextCachedMeasurementsIndex = 0; uint32_t nextCachedMeasurementsIndex = 0;
std::array<YGCachedMeasurement, YG_MAX_CACHED_RESULT_COUNT> std::array<YGCachedMeasurement, YG_MAX_CACHED_RESULT_COUNT>

View File

@@ -21,7 +21,7 @@
#endif #endif
#ifdef WINARMDLL #ifdef WINARMDLL
#define WIN_STRUCT(type) type * #define WIN_STRUCT(type) type*
#define WIN_STRUCT_REF(value) &value #define WIN_STRUCT_REF(value) &value
#else #else
#define WIN_STRUCT(type) type #define WIN_STRUCT(type) type
@@ -29,9 +29,9 @@
#endif #endif
#ifdef NS_ENUM #ifdef NS_ENUM
// Cannot use NSInteger as NSInteger has a different size than int (which is the default type of a // Cannot use NSInteger as NSInteger has a different size than int (which is the
// enum). // default type of a enum). Therefor when linking the Yoga C library into obj-c
// Therefor when linking the Yoga C library into obj-c the header is a missmatch for the Yoga ABI. // the header is a missmatch for the Yoga ABI.
#define YG_ENUM_BEGIN(name) NS_ENUM(int, name) #define YG_ENUM_BEGIN(name) NS_ENUM(int, name)
#define YG_ENUM_END(name) #define YG_ENUM_END(name)
#else #else

View File

@@ -113,7 +113,8 @@ void YGNode::setMeasureFunc(YGMeasureFunc measureFunc) {
YGAssertWithNode( YGAssertWithNode(
this, this,
children_.size() == 0, children_.size() == 0,
"Cannot set measure function: Nodes with measure functions cannot have children."); "Cannot set measure function: Nodes with measure functions cannot have "
"children.");
measure_ = measureFunc; measure_ = measureFunc;
// TODO: t18095186 Move nodeType to opt-in function and mark appropriate // TODO: t18095186 Move nodeType to opt-in function and mark appropriate
// places in Litho // places in Litho

View File

@@ -12,7 +12,7 @@
#include "Yoga-internal.h" #include "Yoga-internal.h"
struct YGNode { struct YGNode {
private: private:
void* context_ = nullptr; void* context_ = nullptr;
YGPrintFunc print_ = nullptr; YGPrintFunc print_ = nullptr;
bool hasNewLayout_ : 1; bool hasNewLayout_ : 1;
@@ -35,7 +35,7 @@ struct YGNode {
const YGFlexDirection axis, const YGFlexDirection axis,
const float axisSize) const; const float axisSize) const;
public: public:
YGNode() YGNode()
: hasNewLayout_(true), : hasNewLayout_(true),
isReferenceBaseline_(false), isReferenceBaseline_(false),

View File

@@ -63,15 +63,19 @@ static void appendNumberIfNotUndefined(
} }
} }
static void static void appendNumberIfNotAuto(
appendNumberIfNotAuto(string& base, const string& key, const YGValue number) { string& base,
const string& key,
const YGValue number) {
if (number.unit != YGUnitAuto) { if (number.unit != YGUnitAuto) {
appendNumberIfNotUndefined(base, key, number); appendNumberIfNotUndefined(base, key, number);
} }
} }
static void static void appendNumberIfNotZero(
appendNumberIfNotZero(string& base, const string& str, const YGValue number) { string& base,
const string& str,
const YGValue number) {
if (number.unit == YGUnitAuto) { if (number.unit == YGUnitAuto) {
base.append(str + ": auto; "); base.append(str + ": auto; ");
} else if (!YGFloatsEqual(number.value, 0)) { } else if (!YGFloatsEqual(number.value, 0)) {

View File

@@ -18,10 +18,10 @@ constexpr YGValue kYGValueUndefined = {0, YGUnitUndefined};
constexpr YGValue kYGValueAuto = {0, YGUnitAuto}; constexpr YGValue kYGValueAuto = {0, YGUnitAuto};
struct YGStyle { struct YGStyle {
private: private:
using CompactValue = facebook::yoga::detail::CompactValue; using CompactValue = facebook::yoga::detail::CompactValue;
public: public:
using Dimensions = facebook::yoga::detail::Values<2>; using Dimensions = facebook::yoga::detail::Values<2>;
using Edges = facebook::yoga::detail::Values<YGEdgeCount>; using Edges = facebook::yoga::detail::Values<YGEdgeCount>;

View File

@@ -15,7 +15,7 @@ YG_EXTERN_C_BEGIN
// Not defined in MSVC++ // Not defined in MSVC++
#ifndef NAN #ifndef NAN
static const uint32_t __nan = 0x7fc00000; static const uint32_t __nan = 0x7fc00000;
#define NAN (*(const float*)__nan) #define NAN (*(const float*) __nan)
#endif #endif
#define YGUndefined NAN #define YGUndefined NAN

View File

@@ -55,8 +55,8 @@ struct YGCachedMeasurement {
YGCachedMeasurement() YGCachedMeasurement()
: availableWidth(0), : availableWidth(0),
availableHeight(0), availableHeight(0),
widthMeasureMode((YGMeasureMode)-1), widthMeasureMode((YGMeasureMode) -1),
heightMeasureMode((YGMeasureMode)-1), heightMeasureMode((YGMeasureMode) -1),
computedWidth(-1), computedWidth(-1),
computedHeight(-1) {} computedHeight(-1) {}
@@ -95,10 +95,10 @@ namespace detail {
template <size_t Size> template <size_t Size>
class Values { class Values {
private: private:
std::array<CompactValue, Size> values_; std::array<CompactValue, Size> values_;
public: public:
Values() = default; Values() = default;
explicit Values(const YGValue& defaultValue) noexcept { explicit Values(const YGValue& defaultValue) noexcept {
values_.fill(defaultValue); values_.fill(defaultValue);

View File

@@ -74,7 +74,7 @@ static int YGAndroidLog(
return result; return result;
} }
#else #else
#define YG_UNUSED(x) (void)(x); #define YG_UNUSED(x) (void) (x);
static int YGDefaultLog( static int YGDefaultLog(
const YGConfigRef config, const YGConfigRef config,
@@ -921,7 +921,7 @@ float YGNodeStyleGetBorder(const YGNodeRef node, const YGEdge edge) {
return YGUndefined; return YGUndefined;
} }
auto border = (YGValue)node->getStyle().border[edge]; auto border = (YGValue) node->getStyle().border[edge];
return border.value; return border.value;
} }
@@ -3745,8 +3745,8 @@ bool YGLayoutNodeInternal(
if (needToVisitNode) { if (needToVisitNode) {
// Invalidate the cached results. // Invalidate the cached results.
layout->nextCachedMeasurementsIndex = 0; layout->nextCachedMeasurementsIndex = 0;
layout->cachedLayout.widthMeasureMode = (YGMeasureMode)-1; layout->cachedLayout.widthMeasureMode = (YGMeasureMode) -1;
layout->cachedLayout.heightMeasureMode = (YGMeasureMode)-1; layout->cachedLayout.heightMeasureMode = (YGMeasureMode) -1;
layout->cachedLayout.computedWidth = -1; layout->cachedLayout.computedWidth = -1;
layout->cachedLayout.computedHeight = -1; layout->cachedLayout.computedHeight = -1;
} }

View File

@@ -358,8 +358,11 @@ WIN_EXPORT float YGNodeLayoutGetPadding(
const YGEdge edge); const YGEdge edge);
WIN_EXPORT void YGConfigSetLogger(const YGConfigRef config, YGLogger logger); WIN_EXPORT void YGConfigSetLogger(const YGConfigRef config, YGLogger logger);
WIN_EXPORT void WIN_EXPORT void YGLog(
YGLog(const YGNodeRef node, YGLogLevel level, const char* message, ...); const YGNodeRef node,
YGLogLevel level,
const char* message,
...);
WIN_EXPORT void YGLogWithConfig( WIN_EXPORT void YGLogWithConfig(
const YGConfigRef config, const YGConfigRef config,
YGLogLevel level, YGLogLevel level,