review improvements
This commit is contained in:
@@ -9,7 +9,6 @@
|
|||||||
|
|
||||||
#import <UIKit/UIKit.h>
|
#import <UIKit/UIKit.h>
|
||||||
#import <yoga/YGEnums.h>
|
#import <yoga/YGEnums.h>
|
||||||
#import <yoga/YGValue.h>
|
|
||||||
|
|
||||||
@interface YGLayout : NSObject
|
@interface YGLayout : NSObject
|
||||||
|
|
||||||
|
@@ -10,11 +10,6 @@
|
|||||||
#import "YGLayout+Private.h"
|
#import "YGLayout+Private.h"
|
||||||
#import "UIView+Yoga.h"
|
#import "UIView+Yoga.h"
|
||||||
#import <yoga/Yoga.h>
|
#import <yoga/Yoga.h>
|
||||||
#import <UIKit/UIKit.h>
|
|
||||||
|
|
||||||
extern YGValue YGValueMake(CGFloat value, YGUnit unit) {
|
|
||||||
return (YGValue) { .value = value, .unit = unit };
|
|
||||||
}
|
|
||||||
|
|
||||||
#define YG_STYLE_PROPERTY_IMPL(type, lowercased_name, capitalized_name) \
|
#define YG_STYLE_PROPERTY_IMPL(type, lowercased_name, capitalized_name) \
|
||||||
- (type)lowercased_name \
|
- (type)lowercased_name \
|
||||||
|
14
enums.py
14
enums.py
@@ -126,23 +126,13 @@ with open(root + '/yoga/YGEnums.h', 'w') as f:
|
|||||||
f.write('YG_EXTERN_C_BEGIN\n\n')
|
f.write('YG_EXTERN_C_BEGIN\n\n')
|
||||||
for name, values in ENUMS.items():
|
for name, values in ENUMS.items():
|
||||||
f.write('#define YG%sCount %s\n' % (name, len(values)))
|
f.write('#define YG%sCount %s\n' % (name, len(values)))
|
||||||
f.write('#ifndef NS_ENUM\n')
|
f.write('typedef YG_ENUM_BEGIN(YG%s) {\n' % name)
|
||||||
f.write('typedef enum YG%s {\n' % name)
|
|
||||||
for value in values:
|
for value in values:
|
||||||
if isinstance(value, tuple):
|
if isinstance(value, tuple):
|
||||||
f.write(' YG%s%s = %d,\n' % (name, value[0], value[1]))
|
f.write(' YG%s%s = %d,\n' % (name, value[0], value[1]))
|
||||||
else:
|
else:
|
||||||
f.write(' YG%s%s,\n' % (name, value))
|
f.write(' YG%s%s,\n' % (name, value))
|
||||||
f.write('} YG%s;\n' % name)
|
f.write('} YG_ENUM_END(YG%s);\n' % name)
|
||||||
f.write('#else\n')
|
|
||||||
f.write('typedef NS_ENUM(NSInteger, YG%s) {\n' % name)
|
|
||||||
for value in values:
|
|
||||||
if isinstance(value, tuple):
|
|
||||||
f.write(' YG%s%s = %d,\n' % (name, value[0], value[1]))
|
|
||||||
else:
|
|
||||||
f.write(' YG%s%s,\n' % (name, value))
|
|
||||||
f.write('};\n')
|
|
||||||
f.write('#endif\n')
|
|
||||||
f.write('\n')
|
f.write('\n')
|
||||||
f.write('YG_EXTERN_C_END\n')
|
f.write('YG_EXTERN_C_END\n')
|
||||||
|
|
||||||
|
177
yoga/YGEnums.h
177
yoga/YGEnums.h
@@ -14,55 +14,29 @@
|
|||||||
YG_EXTERN_C_BEGIN
|
YG_EXTERN_C_BEGIN
|
||||||
|
|
||||||
#define YGFlexDirectionCount 4
|
#define YGFlexDirectionCount 4
|
||||||
#ifndef NS_ENUM
|
typedef YG_ENUM_BEGIN(YGFlexDirection) {
|
||||||
typedef enum YGFlexDirection {
|
|
||||||
YGFlexDirectionColumn,
|
YGFlexDirectionColumn,
|
||||||
YGFlexDirectionColumnReverse,
|
YGFlexDirectionColumnReverse,
|
||||||
YGFlexDirectionRow,
|
YGFlexDirectionRow,
|
||||||
YGFlexDirectionRowReverse,
|
YGFlexDirectionRowReverse,
|
||||||
} YGFlexDirection;
|
} YG_ENUM_END(YGFlexDirection);
|
||||||
#else
|
|
||||||
typedef NS_ENUM(NSInteger, YGFlexDirection) {
|
|
||||||
YGFlexDirectionColumn,
|
|
||||||
YGFlexDirectionColumnReverse,
|
|
||||||
YGFlexDirectionRow,
|
|
||||||
YGFlexDirectionRowReverse,
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define YGMeasureModeCount 3
|
#define YGMeasureModeCount 3
|
||||||
#ifndef NS_ENUM
|
typedef YG_ENUM_BEGIN(YGMeasureMode) {
|
||||||
typedef enum YGMeasureMode {
|
|
||||||
YGMeasureModeUndefined,
|
YGMeasureModeUndefined,
|
||||||
YGMeasureModeExactly,
|
YGMeasureModeExactly,
|
||||||
YGMeasureModeAtMost,
|
YGMeasureModeAtMost,
|
||||||
} YGMeasureMode;
|
} YG_ENUM_END(YGMeasureMode);
|
||||||
#else
|
|
||||||
typedef NS_ENUM(NSInteger, YGMeasureMode) {
|
|
||||||
YGMeasureModeUndefined,
|
|
||||||
YGMeasureModeExactly,
|
|
||||||
YGMeasureModeAtMost,
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define YGPrintOptionsCount 3
|
#define YGPrintOptionsCount 3
|
||||||
#ifndef NS_ENUM
|
typedef YG_ENUM_BEGIN(YGPrintOptions) {
|
||||||
typedef enum YGPrintOptions {
|
|
||||||
YGPrintOptionsLayout = 1,
|
YGPrintOptionsLayout = 1,
|
||||||
YGPrintOptionsStyle = 2,
|
YGPrintOptionsStyle = 2,
|
||||||
YGPrintOptionsChildren = 4,
|
YGPrintOptionsChildren = 4,
|
||||||
} YGPrintOptions;
|
} YG_ENUM_END(YGPrintOptions);
|
||||||
#else
|
|
||||||
typedef NS_ENUM(NSInteger, YGPrintOptions) {
|
|
||||||
YGPrintOptionsLayout = 1,
|
|
||||||
YGPrintOptionsStyle = 2,
|
|
||||||
YGPrintOptionsChildren = 4,
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define YGEdgeCount 9
|
#define YGEdgeCount 9
|
||||||
#ifndef NS_ENUM
|
typedef YG_ENUM_BEGIN(YGEdge) {
|
||||||
typedef enum YGEdge {
|
|
||||||
YGEdgeLeft,
|
YGEdgeLeft,
|
||||||
YGEdgeTop,
|
YGEdgeTop,
|
||||||
YGEdgeRight,
|
YGEdgeRight,
|
||||||
@@ -72,173 +46,78 @@ typedef enum YGEdge {
|
|||||||
YGEdgeHorizontal,
|
YGEdgeHorizontal,
|
||||||
YGEdgeVertical,
|
YGEdgeVertical,
|
||||||
YGEdgeAll,
|
YGEdgeAll,
|
||||||
} YGEdge;
|
} YG_ENUM_END(YGEdge);
|
||||||
#else
|
|
||||||
typedef NS_ENUM(NSInteger, YGEdge) {
|
|
||||||
YGEdgeLeft,
|
|
||||||
YGEdgeTop,
|
|
||||||
YGEdgeRight,
|
|
||||||
YGEdgeBottom,
|
|
||||||
YGEdgeStart,
|
|
||||||
YGEdgeEnd,
|
|
||||||
YGEdgeHorizontal,
|
|
||||||
YGEdgeVertical,
|
|
||||||
YGEdgeAll,
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define YGPositionTypeCount 2
|
#define YGPositionTypeCount 2
|
||||||
#ifndef NS_ENUM
|
typedef YG_ENUM_BEGIN(YGPositionType) {
|
||||||
typedef enum YGPositionType {
|
|
||||||
YGPositionTypeRelative,
|
YGPositionTypeRelative,
|
||||||
YGPositionTypeAbsolute,
|
YGPositionTypeAbsolute,
|
||||||
} YGPositionType;
|
} YG_ENUM_END(YGPositionType);
|
||||||
#else
|
|
||||||
typedef NS_ENUM(NSInteger, YGPositionType) {
|
|
||||||
YGPositionTypeRelative,
|
|
||||||
YGPositionTypeAbsolute,
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define YGDimensionCount 2
|
#define YGDimensionCount 2
|
||||||
#ifndef NS_ENUM
|
typedef YG_ENUM_BEGIN(YGDimension) {
|
||||||
typedef enum YGDimension {
|
|
||||||
YGDimensionWidth,
|
YGDimensionWidth,
|
||||||
YGDimensionHeight,
|
YGDimensionHeight,
|
||||||
} YGDimension;
|
} YG_ENUM_END(YGDimension);
|
||||||
#else
|
|
||||||
typedef NS_ENUM(NSInteger, YGDimension) {
|
|
||||||
YGDimensionWidth,
|
|
||||||
YGDimensionHeight,
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define YGJustifyCount 5
|
#define YGJustifyCount 5
|
||||||
#ifndef NS_ENUM
|
typedef YG_ENUM_BEGIN(YGJustify) {
|
||||||
typedef enum YGJustify {
|
|
||||||
YGJustifyFlexStart,
|
YGJustifyFlexStart,
|
||||||
YGJustifyCenter,
|
YGJustifyCenter,
|
||||||
YGJustifyFlexEnd,
|
YGJustifyFlexEnd,
|
||||||
YGJustifySpaceBetween,
|
YGJustifySpaceBetween,
|
||||||
YGJustifySpaceAround,
|
YGJustifySpaceAround,
|
||||||
} YGJustify;
|
} YG_ENUM_END(YGJustify);
|
||||||
#else
|
|
||||||
typedef NS_ENUM(NSInteger, YGJustify) {
|
|
||||||
YGJustifyFlexStart,
|
|
||||||
YGJustifyCenter,
|
|
||||||
YGJustifyFlexEnd,
|
|
||||||
YGJustifySpaceBetween,
|
|
||||||
YGJustifySpaceAround,
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define YGDirectionCount 3
|
#define YGDirectionCount 3
|
||||||
#ifndef NS_ENUM
|
typedef YG_ENUM_BEGIN(YGDirection) {
|
||||||
typedef enum YGDirection {
|
|
||||||
YGDirectionInherit,
|
YGDirectionInherit,
|
||||||
YGDirectionLTR,
|
YGDirectionLTR,
|
||||||
YGDirectionRTL,
|
YGDirectionRTL,
|
||||||
} YGDirection;
|
} YG_ENUM_END(YGDirection);
|
||||||
#else
|
|
||||||
typedef NS_ENUM(NSInteger, YGDirection) {
|
|
||||||
YGDirectionInherit,
|
|
||||||
YGDirectionLTR,
|
|
||||||
YGDirectionRTL,
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define YGLogLevelCount 5
|
#define YGLogLevelCount 5
|
||||||
#ifndef NS_ENUM
|
typedef YG_ENUM_BEGIN(YGLogLevel) {
|
||||||
typedef enum YGLogLevel {
|
|
||||||
YGLogLevelError,
|
YGLogLevelError,
|
||||||
YGLogLevelWarn,
|
YGLogLevelWarn,
|
||||||
YGLogLevelInfo,
|
YGLogLevelInfo,
|
||||||
YGLogLevelDebug,
|
YGLogLevelDebug,
|
||||||
YGLogLevelVerbose,
|
YGLogLevelVerbose,
|
||||||
} YGLogLevel;
|
} YG_ENUM_END(YGLogLevel);
|
||||||
#else
|
|
||||||
typedef NS_ENUM(NSInteger, YGLogLevel) {
|
|
||||||
YGLogLevelError,
|
|
||||||
YGLogLevelWarn,
|
|
||||||
YGLogLevelInfo,
|
|
||||||
YGLogLevelDebug,
|
|
||||||
YGLogLevelVerbose,
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define YGWrapCount 2
|
#define YGWrapCount 2
|
||||||
#ifndef NS_ENUM
|
typedef YG_ENUM_BEGIN(YGWrap) {
|
||||||
typedef enum YGWrap {
|
|
||||||
YGWrapNoWrap,
|
YGWrapNoWrap,
|
||||||
YGWrapWrap,
|
YGWrapWrap,
|
||||||
} YGWrap;
|
} YG_ENUM_END(YGWrap);
|
||||||
#else
|
|
||||||
typedef NS_ENUM(NSInteger, YGWrap) {
|
|
||||||
YGWrapNoWrap,
|
|
||||||
YGWrapWrap,
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define YGOverflowCount 3
|
#define YGOverflowCount 3
|
||||||
#ifndef NS_ENUM
|
typedef YG_ENUM_BEGIN(YGOverflow) {
|
||||||
typedef enum YGOverflow {
|
|
||||||
YGOverflowVisible,
|
YGOverflowVisible,
|
||||||
YGOverflowHidden,
|
YGOverflowHidden,
|
||||||
YGOverflowScroll,
|
YGOverflowScroll,
|
||||||
} YGOverflow;
|
} YG_ENUM_END(YGOverflow);
|
||||||
#else
|
|
||||||
typedef NS_ENUM(NSInteger, YGOverflow) {
|
|
||||||
YGOverflowVisible,
|
|
||||||
YGOverflowHidden,
|
|
||||||
YGOverflowScroll,
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define YGExperimentalFeatureCount 2
|
#define YGExperimentalFeatureCount 2
|
||||||
#ifndef NS_ENUM
|
typedef YG_ENUM_BEGIN(YGExperimentalFeature) {
|
||||||
typedef enum YGExperimentalFeature {
|
|
||||||
YGExperimentalFeatureRounding,
|
YGExperimentalFeatureRounding,
|
||||||
YGExperimentalFeatureWebFlexBasis,
|
YGExperimentalFeatureWebFlexBasis,
|
||||||
} YGExperimentalFeature;
|
} YG_ENUM_END(YGExperimentalFeature);
|
||||||
#else
|
|
||||||
typedef NS_ENUM(NSInteger, YGExperimentalFeature) {
|
|
||||||
YGExperimentalFeatureRounding,
|
|
||||||
YGExperimentalFeatureWebFlexBasis,
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define YGAlignCount 5
|
#define YGAlignCount 5
|
||||||
#ifndef NS_ENUM
|
typedef YG_ENUM_BEGIN(YGAlign) {
|
||||||
typedef enum YGAlign {
|
|
||||||
YGAlignAuto,
|
YGAlignAuto,
|
||||||
YGAlignFlexStart,
|
YGAlignFlexStart,
|
||||||
YGAlignCenter,
|
YGAlignCenter,
|
||||||
YGAlignFlexEnd,
|
YGAlignFlexEnd,
|
||||||
YGAlignStretch,
|
YGAlignStretch,
|
||||||
} YGAlign;
|
} YG_ENUM_END(YGAlign);
|
||||||
#else
|
|
||||||
typedef NS_ENUM(NSInteger, YGAlign) {
|
|
||||||
YGAlignAuto,
|
|
||||||
YGAlignFlexStart,
|
|
||||||
YGAlignCenter,
|
|
||||||
YGAlignFlexEnd,
|
|
||||||
YGAlignStretch,
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define YGUnitCount 3
|
#define YGUnitCount 3
|
||||||
#ifndef NS_ENUM
|
typedef YG_ENUM_BEGIN(YGUnit) {
|
||||||
typedef enum YGUnit {
|
|
||||||
YGUnitUndefined,
|
YGUnitUndefined,
|
||||||
YGUnitPixel,
|
YGUnitPixel,
|
||||||
YGUnitPercent,
|
YGUnitPercent,
|
||||||
} YGUnit;
|
} YG_ENUM_END(YGUnit);
|
||||||
#else
|
|
||||||
typedef NS_ENUM(NSInteger, YGUnit) {
|
|
||||||
YGUnitUndefined,
|
|
||||||
YGUnitPixel,
|
|
||||||
YGUnitPercent,
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
YG_EXTERN_C_END
|
YG_EXTERN_C_END
|
||||||
|
@@ -40,3 +40,19 @@
|
|||||||
YG_ABORT(); \
|
YG_ABORT(); \
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef YG_ENUM_BEGIN
|
||||||
|
#ifndef NS_ENUM
|
||||||
|
#define YG_ENUM_BEGIN(name) enum name
|
||||||
|
#else
|
||||||
|
#define YG_ENUM_BEGIN(name) NS_ENUM(NSInteger, name)
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef YG_ENUM_END
|
||||||
|
#ifndef NS_ENUM
|
||||||
|
#define YG_ENUM_END(name) name
|
||||||
|
#else
|
||||||
|
#define YG_ENUM_END(name)
|
||||||
|
#endif
|
||||||
|
#endif
|
@@ -1,19 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) 2014-present, Facebook, Inc.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* This source code is licensed under the BSD-style license found in the
|
|
||||||
* LICENSE file in the root directory of this source tree. An additional grant
|
|
||||||
* of patent rights can be found in the PATENTS file in the same directory.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
YG_EXTERN_C_BEGIN
|
|
||||||
|
|
||||||
typedef struct YGValue {
|
|
||||||
float value;
|
|
||||||
YGUnit unit;
|
|
||||||
} YGValue;
|
|
||||||
|
|
||||||
YG_EXTERN_C_END
|
|
@@ -30,7 +30,6 @@ static const unsigned long __nan[2] = {0xffffffff, 0x7fffffff};
|
|||||||
|
|
||||||
#include "YGEnums.h"
|
#include "YGEnums.h"
|
||||||
#include "YGMacros.h"
|
#include "YGMacros.h"
|
||||||
#include "YGValue.h"
|
|
||||||
|
|
||||||
YG_EXTERN_C_BEGIN
|
YG_EXTERN_C_BEGIN
|
||||||
|
|
||||||
@@ -39,6 +38,11 @@ typedef struct YGSize {
|
|||||||
float height;
|
float height;
|
||||||
} YGSize;
|
} YGSize;
|
||||||
|
|
||||||
|
typedef struct YGValue {
|
||||||
|
float value;
|
||||||
|
YGUnit unit;
|
||||||
|
} YGValue;
|
||||||
|
|
||||||
typedef struct YGNode *YGNodeRef;
|
typedef struct YGNode *YGNodeRef;
|
||||||
typedef YGSize (*YGMeasureFunc)(YGNodeRef node,
|
typedef YGSize (*YGMeasureFunc)(YGNodeRef node,
|
||||||
float width,
|
float width,
|
||||||
|
Reference in New Issue
Block a user