Add and run clang format script

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 2
parent e0fc8c0ea0
commit 4983a58d6c
6 changed files with 609 additions and 493 deletions

View File

@ -26,9 +26,7 @@ typedef struct CSSCachedMeasurement {
// 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.
enum {
CSS_MAX_CACHED_RESULT_COUNT = 16
};
enum { CSS_MAX_CACHED_RESULT_COUNT = 16 };
typedef struct CSSLayout {
float position[4];
@ -89,9 +87,13 @@ typedef struct CSSNode {
CSSNodeListRef children;
bool isDirty;
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 *context;
} CSSNode;

File diff suppressed because it is too large Load Diff

View File

@ -21,7 +21,7 @@
// Not defined in MSVC++
#ifndef NAN
static const unsigned long __nan[2] = {0xffffffff, 0x7fffffff};
static const unsigned long __nan[2] = { 0xffffffff, 0x7fffffff };
#define NAN (*(const float *)__nan)
#endif
@ -112,8 +112,9 @@ typedef struct CSSSize {
float height;
} CSSSize;
typedef struct CSSNode * CSSNodeRef;
typedef CSSSize (*CSSMeasureFunc)(void *context, float width, CSSMeasureMode widthMode, float height, CSSMeasureMode heightMode);
typedef struct CSSNode *CSSNodeRef;
typedef CSSSize (*CSSMeasureFunc)(
void *context, float width, CSSMeasureMode widthMode, float height, CSSMeasureMode heightMode);
typedef void (*CSSPrintFunc)(void *context);
// CSSNode
@ -127,14 +128,14 @@ CSSNodeRef CSSNodeGetChild(CSSNodeRef node, uint32_t index);
uint32_t CSSNodeChildCount(CSSNodeRef node);
void CSSNodeCalculateLayout(
CSSNodeRef node,
float availableWidth,
float availableHeight,
CSSDirection parentDirection);
CSSNodeRef node, float availableWidth, float availableHeight, CSSDirection parentDirection);
// Mark a node as dirty. Only valid for nodes with a custom measure function set.
// 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.
// Mark a node as dirty. Only valid for nodes with a custom measure function
// set.
// 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);
bool CSSNodeIsDirty(CSSNodeRef node);
@ -142,18 +143,17 @@ void CSSNodePrint(CSSNodeRef node, CSSPrintOptions options);
bool isUndefined(float value);
#define CSS_NODE_PROPERTY(type, name, paramName) \
void CSSNodeSet##name(CSSNodeRef node, type paramName); \
type CSSNodeGet##name(CSSNodeRef node);
#define CSS_NODE_PROPERTY(type, name, paramName) \
void CSSNodeSet##name(CSSNodeRef node, type paramName); \
type CSSNodeGet##name(CSSNodeRef node);
#define CSS_NODE_STYLE_PROPERTY(type, name, paramName) \
void CSSNodeStyleSet##name(CSSNodeRef node, type paramName); \
type CSSNodeStyleGet##name(CSSNodeRef node);
#define CSS_NODE_STYLE_PROPERTY(type, name, paramName) \
void CSSNodeStyleSet##name(CSSNodeRef node, type paramName); \
type CSSNodeStyleGet##name(CSSNodeRef node);
#define CSS_NODE_LAYOUT_PROPERTY(type, name) \
type CSSNodeLayoutGet##name(CSSNodeRef node);
#define CSS_NODE_LAYOUT_PROPERTY(type, name) 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(CSSPrintFunc, PrintFunc, printFunc);
CSS_NODE_PROPERTY(bool, IsTextnode, isTextNode);

View File

@ -10,11 +10,11 @@
#pragma once
#ifdef __cplusplus
# define CSS_EXTERN_C_BEGIN extern "C" {
# define CSS_EXTERN_C_END }
#define CSS_EXTERN_C_BEGIN extern "C" {
#define CSS_EXTERN_C_END }
#else
# define CSS_EXTERN_C_BEGIN
# define CSS_EXTERN_C_END
#define CSS_EXTERN_C_BEGIN
#define CSS_EXTERN_C_END
#endif
#ifndef FB_ASSERTIONS_ENABLED
@ -27,8 +27,8 @@
#define CSS_ABORT()
#endif
#define CSS_ASSERT(X, message) \
if (!(X)) { \
fprintf(stderr, "%s\n", message); \
CSS_ABORT(); \
}
#define CSS_ASSERT(X, message) \
if (!(X)) { \
fprintf(stderr, "%s\n", message); \
CSS_ABORT(); \
}

View File

@ -21,19 +21,15 @@ CSSNodeListRef CSSNodeListNew(uint32_t initialCapacity) {
list->capacity = initialCapacity;
list->count = 0;
list->items = malloc(sizeof(void*) * list->capacity);
list->items = malloc(sizeof(void *) * list->capacity);
CSS_ASSERT(list->items != NULL, "Could not allocate memory for items");
return list;
}
void CSSNodeListFree(CSSNodeListRef list) {
free(list);
}
void CSSNodeListFree(CSSNodeListRef list) { free(list); }
uint32_t CSSNodeListCount(CSSNodeListRef list) {
return list->count;
}
uint32_t CSSNodeListCount(CSSNodeListRef list) { return list->count; }
void CSSNodeListAdd(CSSNodeListRef list, CSSNodeRef node) {
CSSNodeListInsert(list, node, list->count);
@ -42,7 +38,7 @@ void CSSNodeListAdd(CSSNodeListRef list, CSSNodeRef node) {
void CSSNodeListInsert(CSSNodeListRef list, CSSNodeRef node, uint32_t index) {
if (list->count == list->capacity) {
list->capacity *= 2;
list->items = realloc(list->items, sizeof(void*) * list->capacity);
list->items = realloc(list->items, sizeof(void *) * list->capacity);
CSS_ASSERT(list->items != NULL, "Could not extend allocation for items");
}
@ -77,6 +73,4 @@ CSSNodeRef CSSNodeListDelete(CSSNodeListRef list, CSSNodeRef node) {
return NULL;
}
CSSNodeRef CSSNodeListGet(CSSNodeListRef list, uint32_t index) {
return list->items[index];
}
CSSNodeRef CSSNodeListGet(CSSNodeListRef list, uint32_t index) { return list->items[index]; }

View File

@ -19,7 +19,7 @@
CSS_EXTERN_C_BEGIN
typedef struct CSSNodeList * CSSNodeListRef;
typedef struct CSSNodeList *CSSNodeListRef;
CSSNodeListRef CSSNodeListNew(uint32_t initialCapacity);
void CSSNodeListFree(CSSNodeListRef list);