Add and run clang format script

Summary: This code used to be auto generated. Let's let clang-format clean up some stuff for us.

Reviewed By: lucasr

Differential Revision: D3662225

fbshipit-source-id: ddd4064cbf9be21ca6a97001ace1b56b4314c86f
This commit is contained in:
Emil Sjolander
2016-08-04 08:20:11 -07:00
committed by Facebook Github Bot 9
parent 9278ff462e
commit efe1595f0e
9 changed files with 680 additions and 541 deletions

View File

@@ -26,9 +26,7 @@ typedef struct CSSCachedMeasurement {
// This value was chosen based on empiracle data. Even the most complicated // This value was chosen based on empiracle data. Even the most complicated
// layouts should not require more than 16 entries to fit within the cache. // layouts should not require more than 16 entries to fit within the cache.
enum { enum { CSS_MAX_CACHED_RESULT_COUNT = 16 };
CSS_MAX_CACHED_RESULT_COUNT = 16
};
typedef struct CSSLayout { typedef struct CSSLayout {
float position[4]; float position[4];
@@ -91,7 +89,11 @@ typedef struct CSSNode {
struct CSSNode *nextChild; struct CSSNode *nextChild;
CSSSize (*measure)(void *context, float width, CSSMeasureMode widthMode, float height, CSSMeasureMode heightMode); CSSSize (*measure)(void *context,
float width,
CSSMeasureMode widthMode,
float height,
CSSMeasureMode heightMode);
void (*print)(void *context); void (*print)(void *context);
void *context; void *context;
} CSSNode; } CSSNode;

File diff suppressed because it is too large Load Diff

View File

@@ -113,7 +113,8 @@ typedef struct CSSSize {
} CSSSize; } CSSSize;
typedef struct CSSNode *CSSNodeRef; typedef struct CSSNode *CSSNodeRef;
typedef CSSSize (*CSSMeasureFunc)(void *context, float width, CSSMeasureMode widthMode, float height, CSSMeasureMode heightMode); typedef CSSSize (*CSSMeasureFunc)(
void *context, float width, CSSMeasureMode widthMode, float height, CSSMeasureMode heightMode);
typedef void (*CSSPrintFunc)(void *context); typedef void (*CSSPrintFunc)(void *context);
// CSSNode // CSSNode
@@ -127,14 +128,14 @@ CSSNodeRef CSSNodeGetChild(CSSNodeRef node, uint32_t index);
uint32_t CSSNodeChildCount(CSSNodeRef node); uint32_t CSSNodeChildCount(CSSNodeRef node);
void CSSNodeCalculateLayout( void CSSNodeCalculateLayout(
CSSNodeRef node, CSSNodeRef node, float availableWidth, float availableHeight, CSSDirection parentDirection);
float availableWidth,
float availableHeight,
CSSDirection parentDirection);
// Mark a node as dirty. Only valid for nodes with a custom measure function set. // Mark a node as dirty. Only valid for nodes with a custom measure function
// CSSLayout knows when to mark all other nodes as dirty but because nodes with measure functions // set.
// depends on information not known to CSSLayout they must perform this dirty marking manually. // CSSLayout knows when to mark all other nodes as dirty but because nodes with
// measure functions
// depends on information not known to CSSLayout they must perform this dirty
// marking manually.
void CSSNodeMarkDirty(CSSNodeRef node); void CSSNodeMarkDirty(CSSNodeRef node);
bool CSSNodeIsDirty(CSSNodeRef node); bool CSSNodeIsDirty(CSSNodeRef node);
@@ -150,8 +151,7 @@ type CSSNodeGet##name(CSSNodeRef node);
void CSSNodeStyleSet##name(CSSNodeRef node, type paramName); \ void CSSNodeStyleSet##name(CSSNodeRef node, type paramName); \
type CSSNodeStyleGet##name(CSSNodeRef node); type CSSNodeStyleGet##name(CSSNodeRef node);
#define CSS_NODE_LAYOUT_PROPERTY(type, name) \ #define CSS_NODE_LAYOUT_PROPERTY(type, name) type CSSNodeLayoutGet##name(CSSNodeRef node);
type CSSNodeLayoutGet##name(CSSNodeRef node);
CSS_NODE_PROPERTY(void *, Context, context); CSS_NODE_PROPERTY(void *, Context, context);
CSS_NODE_PROPERTY(CSSMeasureFunc, MeasureFunc, measureFunc); CSS_NODE_PROPERTY(CSSMeasureFunc, MeasureFunc, measureFunc);

View File

@@ -27,13 +27,9 @@ CSSNodeListRef CSSNodeListNew(uint32_t initialCapacity) {
return list; return list;
} }
void CSSNodeListFree(CSSNodeListRef list) { void CSSNodeListFree(CSSNodeListRef list) { free(list); }
free(list);
}
uint32_t CSSNodeListCount(CSSNodeListRef list) { uint32_t CSSNodeListCount(CSSNodeListRef list) { return list->count; }
return list->count;
}
void CSSNodeListAdd(CSSNodeListRef list, CSSNodeRef node) { void CSSNodeListAdd(CSSNodeListRef list, CSSNodeRef node) {
CSSNodeListInsert(list, node, list->count); CSSNodeListInsert(list, node, list->count);
@@ -77,6 +73,4 @@ CSSNodeRef CSSNodeListDelete(CSSNodeListRef list, CSSNodeRef node) {
return NULL; return NULL;
} }
CSSNodeRef CSSNodeListGet(CSSNodeListRef list, uint32_t index) { CSSNodeRef CSSNodeListGet(CSSNodeListRef list, uint32_t index) { return list->items[index]; }
return list->items[index];
}

View File

@@ -20,15 +20,15 @@
int main(int argc, char const *argv[]) { \ int main(int argc, char const *argv[]) { \
clock_t __start; \ clock_t __start; \
clock_t __end; \ clock_t __end; \
{ \ { BLOCK } \
BLOCK \
} \
return 0; \ return 0; \
} }
#define CSS_BENCHMARK(NAME, BLOCK) \ #define CSS_BENCHMARK(NAME, BLOCK) \
__start = clock(); \ __start = clock(); \
for (uint32_t __i = 0; __i < NUM_REPETITIONS; __i++) { BLOCK } \ for (uint32_t __i = 0; __i < NUM_REPETITIONS; __i++) { \
BLOCK \
} \
__end = clock(); \ __end = clock(); \
__printBenchmarkResult(NAME, __start, __end); __printBenchmarkResult(NAME, __start, __end);

12
format.sh Executable file
View File

@@ -0,0 +1,12 @@
#!/usr/bin/env bash
clang-format \
-style="{ \
BasedOnStyle: WebKit, \
IndentWidth: 2, \
ColumnLimit: 100, \
BreakBeforeBraces: Attach, \
BinPackParameters: false, \
PointerAlignment: Right, \
}" "$@" \
-i ./**/*.{h,c,cpp}

View File

@@ -5315,7 +5315,8 @@ TEST(CSSLayoutTest, test_should_layout_absolute_node_top_with_right_width_and_no
ASSERT_TRUE(test(root_node, root_layout)); ASSERT_TRUE(test(root_node, root_layout));
} }
TEST(CSSLayoutTest, test_should_layout_absolute_node_left_with_right_width_and_no_parent_dimension) { TEST(
CSSLayoutTest, test_should_layout_absolute_node_left_with_right_width_and_no_parent_dimension) {
CSSNode *root_node = new_test_css_node(); CSSNode *root_node = new_test_css_node();
{ {
CSSNode *node_0 = root_node; CSSNode *node_0 = root_node;
@@ -5350,7 +5351,8 @@ TEST(CSSLayoutTest, test_should_layout_absolute_node_left_with_right_width_and_n
ASSERT_TRUE(test(root_node, root_layout)); ASSERT_TRUE(test(root_node, root_layout));
} }
TEST(CSSLayoutTest, test_should_layout_node_with_border_bottom__insidejustifyContent_space_between_container) { TEST(CSSLayoutTest,
test_should_layout_node_with_border_bottom__insidejustifyContent_space_between_container) {
CSSNode *root_node = new_test_css_node(); CSSNode *root_node = new_test_css_node();
{ {
CSSNode *node_0 = root_node; CSSNode *node_0 = root_node;
@@ -5384,7 +5386,8 @@ TEST(CSSLayoutTest, test_should_layout_node_with_border_bottom__insidejustifyCon
ASSERT_TRUE(test(root_node, root_layout)); ASSERT_TRUE(test(root_node, root_layout));
} }
TEST(CSSLayoutTest, test_should_layout_node_with_negative_margin_top_inside_justifyContent_center_container) { TEST(CSSLayoutTest,
test_should_layout_node_with_negative_margin_top_inside_justifyContent_center_container) {
CSSNode *root_node = new_test_css_node(); CSSNode *root_node = new_test_css_node();
{ {
CSSNode *node_0 = root_node; CSSNode *node_0 = root_node;
@@ -5418,7 +5421,8 @@ TEST(CSSLayoutTest, test_should_layout_node_with_negative_margin_top_inside_just
ASSERT_TRUE(test(root_node, root_layout)); ASSERT_TRUE(test(root_node, root_layout));
} }
TEST(CSSLayoutTest, test_should_layout_node_with_margin_top_inside_justifyContent_center_container) { TEST(
CSSLayoutTest, test_should_layout_node_with_margin_top_inside_justifyContent_center_container) {
CSSNode *root_node = new_test_css_node(); CSSNode *root_node = new_test_css_node();
{ {
CSSNode *node_0 = root_node; CSSNode *node_0 = root_node;
@@ -8166,7 +8170,8 @@ TEST(CSSLayoutTest, test_should_shrink_column_node_when_there_is_no_space_left_o
ASSERT_TRUE(test(root_node, root_layout)); ASSERT_TRUE(test(root_node, root_layout));
} }
TEST(CSSLayoutTest, test_should_not_shrink_column_node_with_siblings_when_there_is_space_left_over) { TEST(
CSSLayoutTest, test_should_not_shrink_column_node_with_siblings_when_there_is_space_left_over) {
CSSNode *root_node = new_test_css_node(); CSSNode *root_node = new_test_css_node();
{ {
CSSNode *node_0 = root_node; CSSNode *node_0 = root_node;
@@ -8302,7 +8307,8 @@ TEST(CSSLayoutTest, test_should_shrink_column_node_with_siblings_when_there_is_n
ASSERT_TRUE(test(root_node, root_layout)); ASSERT_TRUE(test(root_node, root_layout));
} }
TEST(CSSLayoutTest, test_should_shrink_column_nodes_proporional_to_their_main_size_when_there_is_no_space_left_over) { TEST(CSSLayoutTest,
test_should_shrink_column_nodes_proporional_to_their_main_size_when_there_is_no_space_left_over) {
CSSNode *root_node = new_test_css_node(); CSSNode *root_node = new_test_css_node();
{ {
CSSNode *node_0 = root_node; CSSNode *node_0 = root_node;
@@ -8462,7 +8468,8 @@ TEST(CSSLayoutTest, test_should_shrink_visible_row_node_when_there_is_no_space_l
ASSERT_TRUE(test(root_node, root_layout)); ASSERT_TRUE(test(root_node, root_layout));
} }
TEST(CSSLayoutTest, test_should_not_shrink_visible_row_node_with_siblings_when_there_is_space_left_over) { TEST(CSSLayoutTest,
test_should_not_shrink_visible_row_node_with_siblings_when_there_is_space_left_over) {
CSSNode *root_node = new_test_css_node(); CSSNode *root_node = new_test_css_node();
{ {
CSSNode *node_0 = root_node; CSSNode *node_0 = root_node;
@@ -8531,7 +8538,8 @@ TEST(CSSLayoutTest, test_should_not_shrink_visible_row_node_with_siblings_when_t
ASSERT_TRUE(test(root_node, root_layout)); ASSERT_TRUE(test(root_node, root_layout));
} }
TEST(CSSLayoutTest, test_should_shrink_visible_row_node_with_siblings_when_there_is_no_space_left_over) { TEST(CSSLayoutTest,
test_should_shrink_visible_row_node_with_siblings_when_there_is_no_space_left_over) {
CSSNode *root_node = new_test_css_node(); CSSNode *root_node = new_test_css_node();
{ {
CSSNode *node_0 = root_node; CSSNode *node_0 = root_node;
@@ -8763,7 +8771,8 @@ TEST(CSSLayoutTest, test_should_shrink_hidden_row_node_when_there_is_no_space_le
ASSERT_TRUE(test(root_node, root_layout)); ASSERT_TRUE(test(root_node, root_layout));
} }
TEST(CSSLayoutTest, test_should_not_shrink_hidden_row_node_with_siblings_when_there_is_space_left_over) { TEST(CSSLayoutTest,
test_should_not_shrink_hidden_row_node_with_siblings_when_there_is_space_left_over) {
CSSNode *root_node = new_test_css_node(); CSSNode *root_node = new_test_css_node();
{ {
CSSNode *node_0 = root_node; CSSNode *node_0 = root_node;
@@ -8833,7 +8842,8 @@ TEST(CSSLayoutTest, test_should_not_shrink_hidden_row_node_with_siblings_when_th
ASSERT_TRUE(test(root_node, root_layout)); ASSERT_TRUE(test(root_node, root_layout));
} }
TEST(CSSLayoutTest, test_should_shrink_hidden_row_node_with_siblings_when_there_is_no_space_left_over) { TEST(CSSLayoutTest,
test_should_shrink_hidden_row_node_with_siblings_when_there_is_no_space_left_over) {
CSSNode *root_node = new_test_css_node(); CSSNode *root_node = new_test_css_node();
{ {
CSSNode *node_0 = root_node; CSSNode *node_0 = root_node;
@@ -8903,7 +8913,8 @@ TEST(CSSLayoutTest, test_should_shrink_hidden_row_node_with_siblings_when_there_
ASSERT_TRUE(test(root_node, root_layout)); ASSERT_TRUE(test(root_node, root_layout));
} }
TEST(CSSLayoutTest, test_should_shrink_hidden_row_nodes_propertional_to_main_size_when_there_is_no_space_left_over) { TEST(CSSLayoutTest,
test_should_shrink_hidden_row_nodes_propertional_to_main_size_when_there_is_no_space_left_over) {
CSSNode *root_node = new_test_css_node(); CSSNode *root_node = new_test_css_node();
{ {
CSSNode *node_0 = root_node; CSSNode *node_0 = root_node;