Update css-layout sync scripts

Reviewed By: emilsjolander

Differential Revision: D3424265

fbshipit-source-id: b1a765bbe11f776e418ae8b01c5c2a292f590a6b
This commit is contained in:
Pieter De Baets 2016-06-15 09:44:30 -07:00 коммит произвёл Facebook Github Bot 1
Родитель b7352b4667
Коммит 0a9cc99a4f
5 изменённых файлов: 2004 добавлений и 2026 удалений

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -1,212 +1,203 @@
/**
*
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
* !! This file is a check-in from github! !!
* !! !!
* !! You should not modify this file directly. Instead: !!
* !! 1) Go to https://github.com/facebook/css-layout !!
* !! 2) Make a pull request and get it merged !!
* !! 3) Copy the file from github to here !!
* !! (don't forget to keep this header) !!
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
* @generated
*
* Copyright (c) 2014, Facebook, Inc.
* 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.
*/
#ifndef __LAYOUT_H
#define __LAYOUT_H
// NOTE: this file is auto-copied from https://github.com/facebook/css-layout
// @generated SignedSource<<c504fae9470271c5617f345667bef8ad>>
#include <math.h>
#ifndef __cplusplus
#include <stdbool.h>
#endif
// Not defined in MSVC++
#ifndef NAN
static const unsigned long __nan[2] = {0xffffffff, 0x7fffffff};
#define NAN (*(const float *)__nan)
#endif
#ifndef __LAYOUT_H
#define __LAYOUT_H
#define CSS_UNDEFINED NAN
#include <math.h>
#ifndef __cplusplus
#include <stdbool.h>
#endif
typedef enum {
CSS_DIRECTION_INHERIT = 0,
CSS_DIRECTION_LTR,
CSS_DIRECTION_RTL
} css_direction_t;
// Not defined in MSVC++
#ifndef NAN
static const unsigned long __nan[2] = {0xffffffff, 0x7fffffff};
#define NAN (*(const float *)__nan)
#endif
typedef enum {
CSS_FLEX_DIRECTION_COLUMN = 0,
CSS_FLEX_DIRECTION_COLUMN_REVERSE,
CSS_FLEX_DIRECTION_ROW,
CSS_FLEX_DIRECTION_ROW_REVERSE
} css_flex_direction_t;
#define CSS_UNDEFINED NAN
typedef enum {
CSS_JUSTIFY_FLEX_START = 0,
CSS_JUSTIFY_CENTER,
CSS_JUSTIFY_FLEX_END,
CSS_JUSTIFY_SPACE_BETWEEN,
CSS_JUSTIFY_SPACE_AROUND
} css_justify_t;
typedef enum {
CSS_DIRECTION_INHERIT = 0,
CSS_DIRECTION_LTR,
CSS_DIRECTION_RTL
} css_direction_t;
typedef enum {
CSS_OVERFLOW_VISIBLE = 0,
CSS_OVERFLOW_HIDDEN
} css_overflow_t;
typedef enum {
CSS_FLEX_DIRECTION_COLUMN = 0,
CSS_FLEX_DIRECTION_COLUMN_REVERSE,
CSS_FLEX_DIRECTION_ROW,
CSS_FLEX_DIRECTION_ROW_REVERSE
} css_flex_direction_t;
// Note: auto is only a valid value for alignSelf. It is NOT a valid value for
// alignItems.
typedef enum {
CSS_ALIGN_AUTO = 0,
CSS_ALIGN_FLEX_START,
CSS_ALIGN_CENTER,
CSS_ALIGN_FLEX_END,
CSS_ALIGN_STRETCH
} css_align_t;
typedef enum {
CSS_JUSTIFY_FLEX_START = 0,
CSS_JUSTIFY_CENTER,
CSS_JUSTIFY_FLEX_END,
CSS_JUSTIFY_SPACE_BETWEEN,
CSS_JUSTIFY_SPACE_AROUND
} css_justify_t;
typedef enum {
CSS_POSITION_RELATIVE = 0,
CSS_POSITION_ABSOLUTE
} css_position_type_t;
typedef enum {
CSS_OVERFLOW_VISIBLE = 0,
CSS_OVERFLOW_HIDDEN
} css_overflow_t;
typedef enum {
CSS_NOWRAP = 0,
CSS_WRAP
} css_wrap_type_t;
// Note: auto is only a valid value for alignSelf. It is NOT a valid value for
// alignItems.
typedef enum {
CSS_ALIGN_AUTO = 0,
CSS_ALIGN_FLEX_START,
CSS_ALIGN_CENTER,
CSS_ALIGN_FLEX_END,
CSS_ALIGN_STRETCH
} css_align_t;
// Note: left and top are shared between position[2] and position[4], so
// they have to be before right and bottom.
typedef enum {
CSS_LEFT = 0,
CSS_TOP,
CSS_RIGHT,
CSS_BOTTOM,
CSS_START,
CSS_END,
CSS_POSITION_COUNT
} css_position_t;
typedef enum {
CSS_POSITION_RELATIVE = 0,
CSS_POSITION_ABSOLUTE
} css_position_type_t;
typedef enum {
CSS_MEASURE_MODE_UNDEFINED = 0,
CSS_MEASURE_MODE_EXACTLY,
CSS_MEASURE_MODE_AT_MOST,
CSS_MEASURE_MODE_COUNT
} css_measure_mode_t;
typedef enum {
CSS_NOWRAP = 0,
CSS_WRAP
} css_wrap_type_t;
typedef enum {
CSS_WIDTH = 0,
CSS_HEIGHT
} css_dimension_t;
// Note: left and top are shared between position[2] and position[4], so
// they have to be before right and bottom.
typedef enum {
CSS_LEFT = 0,
CSS_TOP,
CSS_RIGHT,
CSS_BOTTOM,
CSS_START,
CSS_END,
CSS_POSITION_COUNT
} css_position_t;
typedef struct {
float available_width;
float available_height;
css_measure_mode_t width_measure_mode;
css_measure_mode_t height_measure_mode;
typedef enum {
CSS_MEASURE_MODE_UNDEFINED = 0,
CSS_MEASURE_MODE_EXACTLY,
CSS_MEASURE_MODE_AT_MOST,
CSS_MEASURE_MODE_COUNT
} css_measure_mode_t;
float computed_width;
float computed_height;
} css_cached_measurement_t;
typedef enum {
CSS_WIDTH = 0,
CSS_HEIGHT
} css_dimension_t;
enum {
// 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.
CSS_MAX_CACHED_RESULT_COUNT = 16
};
typedef struct {
float available_width;
float available_height;
css_measure_mode_t width_measure_mode;
css_measure_mode_t height_measure_mode;
typedef struct {
float position[4];
float dimensions[2];
css_direction_t direction;
float computed_width;
float computed_height;
} css_cached_measurement_t;
float flex_basis;
enum {
// 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.
CSS_MAX_CACHED_RESULT_COUNT = 16
};
// Instead of recomputing the entire layout every single time, we
// cache some information to break early when nothing changed
bool should_update;
int generation_count;
css_direction_t last_parent_direction;
typedef struct {
float position[4];
float dimensions[2];
css_direction_t direction;
int next_cached_measurements_index;
css_cached_measurement_t cached_measurements[CSS_MAX_CACHED_RESULT_COUNT];
float measured_dimensions[2];
float flex_basis;
css_cached_measurement_t cached_layout;
} css_layout_t;
// Instead of recomputing the entire layout every single time, we
// cache some information to break early when nothing changed
bool should_update;
int generation_count;
css_direction_t last_parent_direction;
typedef struct {
float dimensions[2];
} css_dim_t;
int next_cached_measurements_index;
css_cached_measurement_t cached_measurements[CSS_MAX_CACHED_RESULT_COUNT];
float measured_dimensions[2];
typedef struct {
css_direction_t direction;
css_flex_direction_t flex_direction;
css_justify_t justify_content;
css_align_t align_content;
css_align_t align_items;
css_align_t align_self;
css_position_type_t position_type;
css_wrap_type_t flex_wrap;
css_overflow_t overflow;
float flex;
float margin[6];
float position[4];
/**
* You should skip all the rules that contain negative values for the
* following attributes. For example:
* {padding: 10, paddingLeft: -5}
* should output:
* {left: 10 ...}
* the following two are incorrect:
* {left: -5 ...}
* {left: 0 ...}
*/
float padding[6];
float border[6];
float dimensions[2];
float minDimensions[2];
float maxDimensions[2];
} css_style_t;
css_cached_measurement_t cached_layout;
} css_layout_t;
typedef struct css_node css_node_t;
struct css_node {
css_style_t style;
css_layout_t layout;
int children_count;
int line_index;
typedef struct {
float dimensions[2];
} css_dim_t;
css_node_t* next_child;
typedef struct {
css_direction_t direction;
css_flex_direction_t flex_direction;
css_justify_t justify_content;
css_align_t align_content;
css_align_t align_items;
css_align_t align_self;
css_position_type_t position_type;
css_wrap_type_t flex_wrap;
css_overflow_t overflow;
float flex;
float margin[6];
float position[4];
/**
* You should skip all the rules that contain negative values for the
* following attributes. For example:
* {padding: 10, paddingLeft: -5}
* should output:
* {left: 10 ...}
* the following two are incorrect:
* {left: -5 ...}
* {left: 0 ...}
*/
float padding[6];
float border[6];
float dimensions[2];
float minDimensions[2];
float maxDimensions[2];
} css_style_t;
css_dim_t (*measure)(void *context, float width, css_measure_mode_t widthMode, float height, css_measure_mode_t heightMode);
void (*print)(void *context);
struct css_node* (*get_child)(void *context, int i);
bool (*is_dirty)(void *context);
bool (*is_text_node)(void *context);
void *context;
};
typedef struct css_node css_node_t;
struct css_node {
css_style_t style;
css_layout_t layout;
int children_count;
int line_index;
// Lifecycle of nodes and children
css_node_t *new_css_node(void);
void init_css_node(css_node_t *node);
void free_css_node(css_node_t *node);
css_node_t* next_child;
// Print utilities
typedef enum {
CSS_PRINT_LAYOUT = 1,
CSS_PRINT_STYLE = 2,
CSS_PRINT_CHILDREN = 4,
} css_print_options_t;
void print_css_node(css_node_t *node, css_print_options_t options);
css_dim_t (*measure)(void *context, float width, css_measure_mode_t widthMode, float height, css_measure_mode_t heightMode);
void (*print)(void *context);
struct css_node* (*get_child)(void *context, int i);
bool (*is_dirty)(void *context);
bool (*is_text_node)(void *context);
void *context;
};
// Function that computes the layout!
void layoutNode(css_node_t *node, float availableWidth, float availableHeight, css_direction_t parentDirection);
bool isUndefined(float value);
// Lifecycle of nodes and children
css_node_t *new_css_node(void);
void init_css_node(css_node_t *node);
void free_css_node(css_node_t *node);
#endif
// Print utilities
typedef enum {
CSS_PRINT_LAYOUT = 1,
CSS_PRINT_STYLE = 2,
CSS_PRINT_CHILDREN = 4,
} css_print_options_t;
void print_css_node(css_node_t *node, css_print_options_t options);
// Function that computes the layout!
void layoutNode(css_node_t *node, float availableWidth, float availableHeight, css_direction_t parentDirection);
bool isUndefined(float value);
#endif

Просмотреть файл

@ -4,11 +4,12 @@ The code here should be kept in sync with GitHub.
HEAD at the time this code was synced: https://github.com/facebook/css-layout/commit/383d8a6b3dcbdb978e012e29040e1a43157765c6
There is generated code in:
- README.facebook (this file)
- java/com/facebook/csslayout (this folder)
- javatests/com/facebook/csslayout
- README (this file)
- fbandroid/java/com/facebook/csslayout
- fbandroid/javatests/com/facebook/csslayout
- fbobjc/Libraries/FBReactKit/js/react-native-github/React/Layout
The code was generated by running 'make' in the css-layout folder and running:
./syncFromGithub.sh <pathToGithubRepo> <pathToFbAndroid>
scripts/sync-css-layout.sh <pathToGithubRepo> <pathToFbSourceRepo>

Просмотреть файл

@ -5,8 +5,11 @@ HEAD at the time this code was synced: https://github.com/facebook/css-layout/co
There is generated code in:
- README (this file)
- java/com/facebook/csslayout (this folder)
- javatests/com/facebook/csslayout
- fbandroid/java/com/facebook/csslayout
- fbandroid/javatests/com/facebook/csslayout
- fbobjc/Libraries/FBReactKit/js/react-native-github/React/Layout
The code was generated by running 'make' in the css-layout folder and copied to React Native.
The code was generated by running 'make' in the css-layout folder and running:
scripts/sync-css-layout.sh <pathToGithubRepo> <pathToFbSourceRepo>

Просмотреть файл

@ -1,12 +1,12 @@
#!/usr/bin/env bash
function usage {
echo "usage: syncFromGithub.sh <pathToGithubRepo> <pathToFbAndroidRepo>";
echo "usage: sync-css-layout.sh <pathToGithubRepo> <pathToFbSourceRepo>";
}
function patchfile {
# Add React Native copyright
printf "/**\n" >> /tmp/csslayoutsync.tmp
printf "/**\n" > /tmp/csslayoutsync.tmp
printf " * Copyright (c) 2014-present, Facebook, Inc.\n" >> /tmp/csslayoutsync.tmp
printf " * All rights reserved.\n" >> /tmp/csslayoutsync.tmp
printf " * This source code is licensed under the BSD-style license found in the\n" >> /tmp/csslayoutsync.tmp
@ -21,7 +21,7 @@ function patchfile {
printf "!plEphiEmie@IsG>>\n\n" >> /tmp/csslayoutsync.tmp
tail -n +9 $1 >> /tmp/csslayoutsync.tmp
mv /tmp/csslayoutsync.tmp $1
$ROOT/scripts/signedsource.py sign $1
$ROOT/fbandroid/scripts/signedsource.py sign $1
}
if [ -z $1 ]; then
@ -44,15 +44,19 @@ pushd $GITHUB
COMMIT_ID=$(git rev-parse HEAD)
popd
SRC=$GITHUB/src/java/src/com/facebook/csslayout
C_SRC=$GITHUB/src/
JAVA_SRC=$GITHUB/src/java/src/com/facebook/csslayout
TESTS=$GITHUB/src/java/tests/com/facebook/csslayout
FBA_SRC=$ROOT/java/com/facebook/catalyst/js/react-native-github/ReactAndroid/src/main/java/com/facebook/csslayout/
FBA_TESTS=$ROOT/javatests/com/facebook/csslayout
FBA_SRC=$ROOT/fbandroid/java/com/facebook/catalyst/js/react-native-github/ReactAndroid/src/main/java/com/facebook/csslayout/
FBA_TESTS=$ROOT/fbandroid/javatests/com/facebook/csslayout/
FBO_SRC=$ROOT/fbobjc/Libraries/FBReactKit/js/react-native-github/React/Layout/
echo "Copying src files over..."
cp $SRC/*.java $FBA_SRC
echo "Copying test files over..."
echo "Copying fbandroid src files over..."
cp $JAVA_SRC/*.java $FBA_SRC
echo "Copying fbandroid test files over..."
cp $TESTS/*.java $FBA_TESTS
echo "Copying fbobjc src files over..."
cp $C_SRC/Layout.{c,h} $FBO_SRC
echo "Patching files..."
for sourcefile in $FBA_SRC/*.java; do
@ -61,23 +65,9 @@ done
for testfile in $FBA_TESTS/*.java; do
patchfile $testfile
done
echo "Writing README.facebook"
echo "The source of truth for css-layout is: https://github.com/facebook/css-layout
The code here should be kept in sync with GitHub.
HEAD at the time this code was synced: https://github.com/facebook/css-layout/commit/$COMMIT_ID
There is generated code in:
- README.facebook (this file)
- java/com/facebook/csslayout (this folder)
- javatests/com/facebook/csslayout
The code was generated by running 'make' in the css-layout folder and running:
./syncFromGithub.sh <pathToGithubRepo> <pathToFbAndroid>
" > $FBA_SRC/README.facebook
for sourcefile in $FBO_SRC/Layout.{c,h}; do
patchfile $sourcefile
done
echo "Writing README"
@ -88,12 +78,14 @@ HEAD at the time this code was synced: https://github.com/facebook/css-layout/co
There is generated code in:
- README (this file)
- java/com/facebook/csslayout (this folder)
- javatests/com/facebook/csslayout
- fbandroid/java/com/facebook/csslayout
- fbandroid/javatests/com/facebook/csslayout
- fbobjc/Libraries/FBReactKit/js/react-native-github/React/Layout
The code was generated by running 'make' in the css-layout folder and copied to React Native.
" > $FBA_SRC/README
The code was generated by running 'make' in the css-layout folder and running:
echo "fbandroid was updated. Please also update the fbobjc version under" \
"fbobjc/Libraries/FBReactKit/js/react-native-github/React/Layout/Layout.c."
echo "Please run buck test //javatests/com/facebook/csslayout"
scripts/sync-css-layout.sh <pathToGithubRepo> <pathToFbSourceRepo>
" > /tmp/csslayoutsync.tmp
cp /tmp/csslayoutsync.tmp "$FBA_SRC/README"
cp /tmp/csslayoutsync.tmp "$FBO_SRC/README"