summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/parse/properties/utils.c89
-rw-r--r--src/select/autogenerated_computed.h1
-rw-r--r--src/select/autogenerated_propset.h416
-rw-r--r--src/select/select_generator.py198
-rw-r--r--test/dump.h29
5 files changed, 228 insertions, 505 deletions
diff --git a/src/parse/properties/utils.c b/src/parse/properties/utils.c
index fe5ee6b..fa8ffbe 100644
--- a/src/parse/properties/utils.c
+++ b/src/parse/properties/utils.c
@@ -1362,16 +1362,17 @@ cleanup:
static css_error
css__parse_calc_sum(css_language *c,
const parserutils_vector *vector, int *ctx,
- css_style *result);
+ parserutils_buffer *result);
static css_error
css__parse_calc_number(
const parserutils_vector *vector, int *ctx,
- css_style *result)
+ parserutils_buffer *result)
{
const css_token *token;
css_fixed num;
size_t consumed;
+ css_code_t push = CALC_PUSH_NUMBER;
/* Consume the number token */
token = parserutils_vector_iterate(vector, ctx);
@@ -1386,13 +1387,18 @@ css__parse_calc_number(
return CSS_INVALID;
}
- return css__stylesheet_style_vappend(result, 2, (css_code_t) CALC_PUSH_NUMBER, (css_code_t)num);
+ return css_error_from_parserutils_error(
+ parserutils_buffer_appendv(result, 2,
+ &push, sizeof(push),
+ &num, sizeof(num)
+ )
+ );
}
static css_error
css__parse_calc_value(css_language *c,
const parserutils_vector *vector, int *ctx,
- css_style *result)
+ parserutils_buffer *result)
{
css_error error;
int orig_ctx = *ctx;
@@ -1426,6 +1432,7 @@ css__parse_calc_value(css_language *c,
{
css_fixed length = 0;
uint32_t unit = 0;
+ css_code_t push = CALC_PUSH_VALUE;
*ctx = orig_ctx;
error = css__parse_unit_specifier(c, vector, ctx, UNIT_CALC_NUMBER, &length, &unit);
@@ -1434,7 +1441,14 @@ css__parse_calc_value(css_language *c,
return error;
}
- error = css__stylesheet_style_vappend(result, 3, (css_code_t) CALC_PUSH_VALUE, length, unit);
+ error = css_error_from_parserutils_error(
+ parserutils_buffer_appendv(result, 3,
+ &push, sizeof(push),
+ &length, sizeof(length),
+ &unit, sizeof(unit)
+ )
+ );
+
}
break;
@@ -1455,12 +1469,11 @@ css__parse_calc_value(css_language *c,
static css_error
css__parse_calc_product(css_language *c,
const parserutils_vector *vector, int *ctx,
- css_style *result)
+ parserutils_buffer *result)
{
css_error error = CSS_OK;
const css_token *token;
- bool multiplication;
-
+ css_code_t operator;
/* First parse a value */
error = css__parse_calc_value(c, vector, ctx, result);
@@ -1480,9 +1493,9 @@ css__parse_calc_product(css_language *c,
tokenIsChar(token, '-'))
break;
else if (tokenIsChar(token, '*'))
- multiplication = true;
+ operator = CALC_MULTIPLY;
else if (tokenIsChar(token, '/'))
- multiplication = false;
+ operator = CALC_DIVIDE;
else {
error = CSS_INVALID;
break;
@@ -1492,7 +1505,7 @@ css__parse_calc_product(css_language *c,
consumeWhitespace(vector, ctx);
- if (multiplication) {
+ if (operator == CALC_MULTIPLY) {
/* parse another value */
error = css__parse_calc_value(c, vector, ctx, result);
} else {
@@ -1502,8 +1515,9 @@ css__parse_calc_product(css_language *c,
break;
/* emit the multiplication/division operator */
- error = css__stylesheet_style_append(result,
- (css_code_t) (multiplication ? CALC_MULTIPLY : CALC_DIVIDE));
+ error = css_error_from_parserutils_error(
+ parserutils_buffer_append(result, (const uint8_t *)&operator, sizeof(operator))
+ );
} while (1);
/* We've fallen off, either we had an error or we're left with ')' */
return error;
@@ -1513,12 +1527,11 @@ css__parse_calc_product(css_language *c,
css_error
css__parse_calc_sum(css_language *c,
const parserutils_vector *vector, int *ctx,
- css_style *result)
+ parserutils_buffer *result)
{
css_error error = CSS_OK;
const css_token *token;
- bool addition;
-
+ css_code_t operator;
/* First parse a product */
error = css__parse_calc_product(c, vector, ctx, result);
@@ -1535,9 +1548,9 @@ css__parse_calc_sum(css_language *c,
} else if (tokenIsChar(token, ')'))
break;
else if (tokenIsChar(token, '+'))
- addition = true;
+ operator = CALC_ADD;
else if (tokenIsChar(token, '-'))
- addition = false;
+ operator = CALC_SUBTRACT;
else {
error = CSS_INVALID;
break;
@@ -1552,7 +1565,9 @@ css__parse_calc_sum(css_language *c,
break;
/* emit the addition/subtraction operator */
- error = css__stylesheet_style_append(result, (css_code_t) (addition ? CALC_ADD : CALC_SUBTRACT));
+ error = css_error_from_parserutils_error(
+ parserutils_buffer_append(result, (const uint8_t *)&operator, sizeof(operator))
+ );
} while (1);
/* We've fallen off, either we had an error or we're left with ')' */
return error;
@@ -1569,6 +1584,10 @@ css_error css__parse_calc(css_language *c,
const css_token *token;
css_error error = CSS_OK;
css_style *calc_style = NULL;
+ parserutils_buffer *calc_buffer = NULL;
+ lwc_string *calc_expr = NULL;
+ uint32_t expr_index = 0;
+ css_code_t finish = CALC_FINISH;
consumeWhitespace(vector, ctx);
@@ -1578,6 +1597,12 @@ css_error css__parse_calc(css_language *c,
return CSS_INVALID;
}
+ if (parserutils_buffer_create(&calc_buffer) != PARSERUTILS_OK) {
+ /* Since &calc_buffer is valid, the only error case is NONMEM */
+ *ctx = orig_ctx;
+ return CSS_NOMEM;
+ }
+
error = css__stylesheet_style_create(c->sheet, &calc_style);
if (error != CSS_OK)
goto cleanup;
@@ -1585,12 +1610,12 @@ css_error css__parse_calc(css_language *c,
error = css__stylesheet_style_append(calc_style, property);
if (error != CSS_OK)
goto cleanup;
-
+
error = css__stylesheet_style_append(calc_style, (css_code_t) unit);
if (error != CSS_OK)
goto cleanup;
- error = css__parse_calc_sum(c, vector, ctx, calc_style);
+ error = css__parse_calc_sum(c, vector, ctx, calc_buffer);
if (error != CSS_OK)
goto cleanup;
@@ -1602,17 +1627,35 @@ css_error css__parse_calc(css_language *c,
goto cleanup;
}
+ /* Append the indicator that the calc is finished */
+ error = css_error_from_parserutils_error(
+ parserutils_buffer_append(calc_buffer, (const uint8_t *)&finish, sizeof(finish))
+ );
+ if (error != CSS_OK)
+ goto cleanup;
+
/* Swallow that close paren */
parserutils_vector_iterate(vector, ctx);
- /* Append the indicator that the calc is finished */
- error = css__stylesheet_style_append(calc_style, (css_code_t) CALC_FINISH);
+ /* Create the lwc string representing the calculation and store it in */
+ error = css_error_from_lwc_error(
+ lwc_intern_string((const char *)calc_buffer->data, calc_buffer->length, &calc_expr)
+ );
if (error != CSS_OK)
goto cleanup;
+ /* This always takes ownership of calc_expr, so we should not use after this */
+ error = css__stylesheet_string_add(calc_style->sheet, calc_expr, &expr_index);
+ if (error != CSS_OK)
+ goto cleanup;
+
+ css__stylesheet_style_append(calc_style, (css_code_t) expr_index);
+
error = css__stylesheet_merge_style(result, calc_style);
cleanup:
css__stylesheet_style_destroy(calc_style);
+ parserutils_buffer_destroy(calc_buffer);
+ /* We do not need to clean up calc_expr, it will never leak */
if (error != CSS_OK) {
*ctx = orig_ctx;
}
diff --git a/src/select/autogenerated_computed.h b/src/select/autogenerated_computed.h
index b26560d..c65cf98 100644
--- a/src/select/autogenerated_computed.h
+++ b/src/select/autogenerated_computed.h
@@ -263,7 +263,6 @@ struct css_computed_style_i {
css_fixed width;
css_fixed word_spacing;
int32_t z_index;
-
};
struct css_computed_style {
diff --git a/src/select/autogenerated_propset.h b/src/select/autogenerated_propset.h
index 036c2ba..71d1596 100644
--- a/src/select/autogenerated_propset.h
+++ b/src/select/autogenerated_propset.h
@@ -15,9 +15,7 @@
static inline css_error set_align_content(css_computed_style *style, uint8_t
type)
{
- uint32_t *bits;
-
- bits = &style->i.bits[ALIGN_CONTENT_INDEX];
+ uint32_t *bits = &style->i.bits[ALIGN_CONTENT_INDEX];
/* 3bits: ttt : type */
*bits = (*bits & ~ALIGN_CONTENT_MASK) | (((uint32_t)type & 0x7) <<
@@ -35,9 +33,7 @@ static inline css_error set_align_content(css_computed_style *style, uint8_t
static inline css_error set_align_items(css_computed_style *style, uint8_t type)
{
- uint32_t *bits;
-
- bits = &style->i.bits[ALIGN_ITEMS_INDEX];
+ uint32_t *bits = &style->i.bits[ALIGN_ITEMS_INDEX];
/* 3bits: ttt : type */
*bits = (*bits & ~ALIGN_ITEMS_MASK) | (((uint32_t)type & 0x7) <<
@@ -55,9 +51,7 @@ static inline css_error set_align_items(css_computed_style *style, uint8_t type)
static inline css_error set_align_self(css_computed_style *style, uint8_t type)
{
- uint32_t *bits;
-
- bits = &style->i.bits[ALIGN_SELF_INDEX];
+ uint32_t *bits = &style->i.bits[ALIGN_SELF_INDEX];
/* 3bits: ttt : type */
*bits = (*bits & ~ALIGN_SELF_MASK) | (((uint32_t)type & 0x7) <<
@@ -76,9 +70,7 @@ static inline css_error set_align_self(css_computed_style *style, uint8_t type)
static inline css_error set_background_attachment(css_computed_style *style,
uint8_t type)
{
- uint32_t *bits;
-
- bits = &style->i.bits[BACKGROUND_ATTACHMENT_INDEX];
+ uint32_t *bits = &style->i.bits[BACKGROUND_ATTACHMENT_INDEX];
/* 2bits: tt : type */
*bits = (*bits & ~BACKGROUND_ATTACHMENT_MASK) | (((uint32_t)type & 0x3)
@@ -97,9 +89,7 @@ static inline css_error set_background_attachment(css_computed_style *style,
static inline css_error set_background_color(css_computed_style *style, uint8_t
type, css_color color)
{
- uint32_t *bits;
-
- bits = &style->i.bits[BACKGROUND_COLOR_INDEX];
+ uint32_t *bits = &style->i.bits[BACKGROUND_COLOR_INDEX];
/* 2bits: tt : type */
*bits = (*bits & ~BACKGROUND_COLOR_MASK) | (((uint32_t)type & 0x3) <<
@@ -120,9 +110,7 @@ static inline css_error set_background_color(css_computed_style *style, uint8_t
static inline css_error set_background_image(css_computed_style *style, uint8_t
type, lwc_string *string)
{
- uint32_t *bits;
-
- bits = &style->i.bits[BACKGROUND_IMAGE_INDEX];
+ uint32_t *bits = &style->i.bits[BACKGROUND_IMAGE_INDEX];
/* 1bit: t : type */
*bits = (*bits & ~BACKGROUND_IMAGE_MASK) | (((uint32_t)type & 0x1) <<
@@ -153,9 +141,7 @@ static inline css_error set_background_position(css_computed_style *style,
uint8_t type, css_fixed length_a, css_unit unit_a, css_fixed
length_b, css_unit unit_b)
{
- uint32_t *bits;
-
- bits = &style->i.bits[BACKGROUND_POSITION_INDEX];
+ uint32_t *bits = &style->i.bits[BACKGROUND_POSITION_INDEX];
/* 11bits: aaaaabbbbbt : unit_a | unit_b | type */
*bits = (*bits & ~BACKGROUND_POSITION_MASK) | ((((uint32_t)type & 0x1)
@@ -179,9 +165,7 @@ static inline css_error set_background_position(css_computed_style *style,
static inline css_error set_background_repeat(css_computed_style *style,
uint8_t type)
{
- uint32_t *bits;
-
- bits = &style->i.bits[BACKGROUND_REPEAT_INDEX];
+ uint32_t *bits = &style->i.bits[BACKGROUND_REPEAT_INDEX];
/* 3bits: ttt : type */
*bits = (*bits & ~BACKGROUND_REPEAT_MASK) | (((uint32_t)type & 0x7) <<
@@ -200,9 +184,7 @@ static inline css_error set_background_repeat(css_computed_style *style,
static inline css_error set_border_bottom_color(css_computed_style *style,
uint8_t type, css_color color)
{
- uint32_t *bits;
-
- bits = &style->i.bits[BORDER_BOTTOM_COLOR_INDEX];
+ uint32_t *bits = &style->i.bits[BORDER_BOTTOM_COLOR_INDEX];
/* 2bits: tt : type */
*bits = (*bits & ~BORDER_BOTTOM_COLOR_MASK) | (((uint32_t)type & 0x3)
@@ -223,9 +205,7 @@ static inline css_error set_border_bottom_color(css_computed_style *style,
static inline css_error set_border_bottom_style(css_computed_style *style,
uint8_t type)
{
- uint32_t *bits;
-
- bits = &style->i.bits[BORDER_BOTTOM_STYLE_INDEX];
+ uint32_t *bits = &style->i.bits[BORDER_BOTTOM_STYLE_INDEX];
/* 4bits: tttt : type */
*bits = (*bits & ~BORDER_BOTTOM_STYLE_MASK) | (((uint32_t)type & 0xf)
@@ -244,9 +224,7 @@ static inline css_error set_border_bottom_style(css_computed_style *style,
static inline css_error set_border_bottom_width(css_computed_style *style,
uint8_t type, css_fixed length, css_unit unit)
{
- uint32_t *bits;
-
- bits = &style->i.bits[BORDER_BOTTOM_WIDTH_INDEX];
+ uint32_t *bits = &style->i.bits[BORDER_BOTTOM_WIDTH_INDEX];
/* 8bits: uuuuuttt : unit | type */
*bits = (*bits & ~BORDER_BOTTOM_WIDTH_MASK) | ((((uint32_t)type & 0x7)
@@ -267,9 +245,7 @@ static inline css_error set_border_bottom_width(css_computed_style *style,
static inline css_error set_border_collapse(css_computed_style *style, uint8_t
type)
{
- uint32_t *bits;
-
- bits = &style->i.bits[BORDER_COLLAPSE_INDEX];
+ uint32_t *bits = &style->i.bits[BORDER_COLLAPSE_INDEX];
/* 2bits: tt : type */
*bits = (*bits & ~BORDER_COLLAPSE_MASK) | (((uint32_t)type & 0x3) <<
@@ -288,9 +264,7 @@ static inline css_error set_border_collapse(css_computed_style *style, uint8_t
static inline css_error set_border_left_color(css_computed_style *style,
uint8_t type, css_color color)
{
- uint32_t *bits;
-
- bits = &style->i.bits[BORDER_LEFT_COLOR_INDEX];
+ uint32_t *bits = &style->i.bits[BORDER_LEFT_COLOR_INDEX];
/* 2bits: tt : type */
*bits = (*bits & ~BORDER_LEFT_COLOR_MASK) | (((uint32_t)type & 0x3) <<
@@ -311,9 +285,7 @@ static inline css_error set_border_left_color(css_computed_style *style,
static inline css_error set_border_left_style(css_computed_style *style,
uint8_t type)
{
- uint32_t *bits;
-
- bits = &style->i.bits[BORDER_LEFT_STYLE_INDEX];
+ uint32_t *bits = &style->i.bits[BORDER_LEFT_STYLE_INDEX];
/* 4bits: tttt : type */
*bits = (*bits & ~BORDER_LEFT_STYLE_MASK) | (((uint32_t)type & 0xf) <<
@@ -332,9 +304,7 @@ static inline css_error set_border_left_style(css_computed_style *style,
static inline css_error set_border_left_width(css_computed_style *style,
uint8_t type, css_fixed length, css_unit unit)
{
- uint32_t *bits;
-
- bits = &style->i.bits[BORDER_LEFT_WIDTH_INDEX];
+ uint32_t *bits = &style->i.bits[BORDER_LEFT_WIDTH_INDEX];
/* 8bits: uuuuuttt : unit | type */
*bits = (*bits & ~BORDER_LEFT_WIDTH_MASK) | ((((uint32_t)type & 0x7) | (
@@ -355,9 +325,7 @@ static inline css_error set_border_left_width(css_computed_style *style,
static inline css_error set_border_right_color(css_computed_style *style,
uint8_t type, css_color color)
{
- uint32_t *bits;
-
- bits = &style->i.bits[BORDER_RIGHT_COLOR_INDEX];
+ uint32_t *bits = &style->i.bits[BORDER_RIGHT_COLOR_INDEX];
/* 2bits: tt : type */
*bits = (*bits & ~BORDER_RIGHT_COLOR_MASK) | (((uint32_t)type & 0x3) <<
@@ -378,9 +346,7 @@ static inline css_error set_border_right_color(css_computed_style *style,
static inline css_error set_border_right_style(css_computed_style *style,
uint8_t type)
{
- uint32_t *bits;
-
- bits = &style->i.bits[BORDER_RIGHT_STYLE_INDEX];
+ uint32_t *bits = &style->i.bits[BORDER_RIGHT_STYLE_INDEX];
/* 4bits: tttt : type */
*bits = (*bits & ~BORDER_RIGHT_STYLE_MASK) | (((uint32_t)type & 0xf) <<
@@ -399,9 +365,7 @@ static inline css_error set_border_right_style(css_computed_style *style,
static inline css_error set_border_right_width(css_computed_style *style,
uint8_t type, css_fixed length, css_unit unit)
{
- uint32_t *bits;
-
- bits = &style->i.bits[BORDER_RIGHT_WIDTH_INDEX];
+ uint32_t *bits = &style->i.bits[BORDER_RIGHT_WIDTH_INDEX];
/* 8bits: uuuuuttt : unit | type */
*bits = (*bits & ~BORDER_RIGHT_WIDTH_MASK) | ((((uint32_t)type & 0x7) |
@@ -423,9 +387,7 @@ static inline css_error set_border_spacing(css_computed_style *style, uint8_t
type, css_fixed length_a, css_unit unit_a, css_fixed length_b,
css_unit unit_b)
{
- uint32_t *bits;
-
- bits = &style->i.bits[BORDER_SPACING_INDEX];
+ uint32_t *bits = &style->i.bits[BORDER_SPACING_INDEX];
/* 11bits: aaaaabbbbbt : unit_a | unit_b | type */
*bits = (*bits & ~BORDER_SPACING_MASK) | ((((uint32_t)type & 0x1) | (
@@ -448,9 +410,7 @@ static inline css_error set_border_spacing(css_computed_style *style, uint8_t
static inline css_error set_border_top_color(css_computed_style *style, uint8_t
type, css_color color)
{
- uint32_t *bits;
-
- bits = &style->i.bits[BORDER_TOP_COLOR_INDEX];
+ uint32_t *bits = &style->i.bits[BORDER_TOP_COLOR_INDEX];
/* 2bits: tt : type */
*bits = (*bits & ~BORDER_TOP_COLOR_MASK) | (((uint32_t)type & 0x3) <<
@@ -471,9 +431,7 @@ static inline css_error set_border_top_color(css_computed_style *style, uint8_t
static inline css_error set_border_top_style(css_computed_style *style, uint8_t
type)
{
- uint32_t *bits;
-
- bits = &style->i.bits[BORDER_TOP_STYLE_INDEX];
+ uint32_t *bits = &style->i.bits[BORDER_TOP_STYLE_INDEX];
/* 4bits: tttt : type */
*bits = (*bits & ~BORDER_TOP_STYLE_MASK) | (((uint32_t)type & 0xf) <<
@@ -492,9 +450,7 @@ static inline css_error set_border_top_style(css_computed_style *style, uint8_t
static inline css_error set_border_top_width(css_computed_style *style, uint8_t
type, css_fixed length, css_unit unit)
{
- uint32_t *bits;
-
- bits = &style->i.bits[BORDER_TOP_WIDTH_INDEX];
+ uint32_t *bits = &style->i.bits[BORDER_TOP_WIDTH_INDEX];
/* 8bits: uuuuuttt : unit | type */
*bits = (*bits & ~BORDER_TOP_WIDTH_MASK) | ((((uint32_t)type & 0x7) | (
@@ -515,9 +471,7 @@ static inline css_error set_border_top_width(css_computed_style *style, uint8_t
static inline css_error set_bottom(css_computed_style *style, uint8_t type,
css_fixed length, css_unit unit)
{
- uint32_t *bits;
-
- bits = &style->i.bits[BOTTOM_INDEX];
+ uint32_t *bits = &style->i.bits[BOTTOM_INDEX];
/* 7bits: uuuuutt : unit | type */
*bits = (*bits & ~BOTTOM_MASK) | ((((uint32_t)type & 0x3) | (unit <<
@@ -537,9 +491,7 @@ static inline css_error set_bottom(css_computed_style *style, uint8_t type,
static inline css_error set_box_sizing(css_computed_style *style, uint8_t type)
{
- uint32_t *bits;
-
- bits = &style->i.bits[BOX_SIZING_INDEX];
+ uint32_t *bits = &style->i.bits[BOX_SIZING_INDEX];
/* 2bits: tt : type */
*bits = (*bits & ~BOX_SIZING_MASK) | (((uint32_t)type & 0x3) <<
@@ -557,9 +509,7 @@ static inline css_error set_box_sizing(css_computed_style *style, uint8_t type)
static inline css_error set_break_after(css_computed_style *style, uint8_t type)
{
- uint32_t *bits;
-
- bits = &style->i.bits[BREAK_AFTER_INDEX];
+ uint32_t *bits = &style->i.bits[BREAK_AFTER_INDEX];
/* 4bits: tttt : type */
*bits = (*bits & ~BREAK_AFTER_MASK) | (((uint32_t)type & 0xf) <<
@@ -578,9 +528,7 @@ static inline css_error set_break_after(css_computed_style *style, uint8_t type)
static inline css_error set_break_before(css_computed_style *style, uint8_t
type)
{
- uint32_t *bits;
-
- bits = &style->i.bits[BREAK_BEFORE_INDEX];
+ uint32_t *bits = &style->i.bits[BREAK_BEFORE_INDEX];
/* 4bits: tttt : type */
*bits = (*bits & ~BREAK_BEFORE_MASK) | (((uint32_t)type & 0xf) <<
@@ -599,9 +547,7 @@ static inline css_error set_break_before(css_computed_style *style, uint8_t
static inline css_error set_break_inside(css_computed_style *style, uint8_t
type)
{
- uint32_t *bits;
-
- bits = &style->i.bits[BREAK_INSIDE_INDEX];
+ uint32_t *bits = &style->i.bits[BREAK_INSIDE_INDEX];
/* 4bits: tttt : type */
*bits = (*bits & ~BREAK_INSIDE_MASK) | (((uint32_t)type & 0xf) <<
@@ -620,9 +566,7 @@ static inline css_error set_break_inside(css_computed_style *style, uint8_t
static inline css_error set_caption_side(css_computed_style *style, uint8_t
type)
{
- uint32_t *bits;
-
- bits = &style->i.bits[CAPTION_SIDE_INDEX];
+ uint32_t *bits = &style->i.bits[CAPTION_SIDE_INDEX];
/* 2bits: tt : type */
*bits = (*bits & ~CAPTION_SIDE_MASK) | (((uint32_t)type & 0x3) <<
@@ -640,9 +584,7 @@ static inline css_error set_caption_side(css_computed_style *style, uint8_t
static inline css_error set_clear(css_computed_style *style, uint8_t type)
{
- uint32_t *bits;
-
- bits = &style->i.bits[CLEAR_INDEX];
+ uint32_t *bits = &style->i.bits[CLEAR_INDEX];
/* 3bits: ttt : type */
*bits = (*bits & ~CLEAR_MASK) | (((uint32_t)type & 0x7) << CLEAR_SHIFT);
@@ -703,9 +645,7 @@ static inline css_error set_clip(
static inline css_error set_color(css_computed_style *style, uint8_t type,
css_color color)
{
- uint32_t *bits;
-
- bits = &style->i.bits[COLOR_INDEX];
+ uint32_t *bits = &style->i.bits[COLOR_INDEX];
/* 1bit: t : type */
*bits = (*bits & ~COLOR_MASK) | (((uint32_t)type & 0x1) << COLOR_SHIFT);
@@ -725,9 +665,7 @@ static inline css_error set_color(css_computed_style *style, uint8_t type,
static inline css_error set_column_count(css_computed_style *style, uint8_t
type, int32_t integer)
{
- uint32_t *bits;
-
- bits = &style->i.bits[COLUMN_COUNT_INDEX];
+ uint32_t *bits = &style->i.bits[COLUMN_COUNT_INDEX];
/* 2bits: tt : type */
*bits = (*bits & ~COLUMN_COUNT_MASK) | (((uint32_t)type & 0x3) <<
@@ -747,9 +685,7 @@ static inline css_error set_column_count(css_computed_style *style, uint8_t
static inline css_error set_column_fill(css_computed_style *style, uint8_t type)
{
- uint32_t *bits;
-
- bits = &style->i.bits[COLUMN_FILL_INDEX];
+ uint32_t *bits = &style->i.bits[COLUMN_FILL_INDEX];
/* 2bits: tt : type */
*bits = (*bits & ~COLUMN_FILL_MASK) | (((uint32_t)type & 0x3) <<
@@ -768,9 +704,7 @@ static inline css_error set_column_fill(css_computed_style *style, uint8_t type)
static inline css_error set_column_gap(css_computed_style *style, uint8_t type,
css_fixed length, css_unit unit)
{
- uint32_t *bits;
-
- bits = &style->i.bits[COLUMN_GAP_INDEX];
+ uint32_t *bits = &style->i.bits[COLUMN_GAP_INDEX];
/* 7bits: uuuuutt : unit | type */
*bits = (*bits & ~COLUMN_GAP_MASK) | ((((uint32_t)type & 0x3) | (unit
@@ -791,9 +725,7 @@ static inline css_error set_column_gap(css_computed_style *style, uint8_t type,
static inline css_error set_column_rule_color(css_computed_style *style,
uint8_t type, css_color color)
{
- uint32_t *bits;
-
- bits = &style->i.bits[COLUMN_RULE_COLOR_INDEX];
+ uint32_t *bits = &style->i.bits[COLUMN_RULE_COLOR_INDEX];
/* 2bits: tt : type */
*bits = (*bits & ~COLUMN_RULE_COLOR_MASK) | (((uint32_t)type & 0x3) <<
@@ -814,9 +746,7 @@ static inline css_error set_column_rule_color(css_computed_style *style,
static inline css_error set_column_rule_style(css_computed_style *style,
uint8_t type)
{
- uint32_t *bits;
-
- bits = &style->i.bits[COLUMN_RULE_STYLE_INDEX];
+ uint32_t *bits = &style->i.bits[COLUMN_RULE_STYLE_INDEX];
/* 4bits: tttt : type */
*bits = (*bits & ~COLUMN_RULE_STYLE_MASK) | (((uint32_t)type & 0xf) <<
@@ -835,9 +765,7 @@ static inline css_error set_column_rule_style(css_computed_style *style,
static inline css_error set_column_rule_width(css_computed_style *style,
uint8_t type, css_fixed length, css_unit unit)
{
- uint32_t *bits;
-
- bits = &style->i.bits[COLUMN_RULE_WIDTH_INDEX];
+ uint32_t *bits = &style->i.bits[COLUMN_RULE_WIDTH_INDEX];
/* 8bits: uuuuuttt : unit | type */
*bits = (*bits & ~COLUMN_RULE_WIDTH_MASK) | ((((uint32_t)type & 0x7) | (
@@ -857,9 +785,7 @@ static inline css_error set_column_rule_width(css_computed_style *style,
static inline css_error set_column_span(css_computed_style *style, uint8_t type)
{
- uint32_t *bits;
-
- bits = &style->i.bits[COLUMN_SPAN_INDEX];
+ uint32_t *bits = &style->i.bits[COLUMN_SPAN_INDEX];
/* 2bits: tt : type */
*bits = (*bits & ~COLUMN_SPAN_MASK) | (((uint32_t)type & 0x3) <<
@@ -878,9 +804,7 @@ static inline css_error set_column_span(css_computed_style *style, uint8_t type)
static inline css_error set_column_width(css_computed_style *style, uint8_t
type, css_fixed length, css_unit unit)
{
- uint32_t *bits;
-
- bits = &style->i.bits[COLUMN_WIDTH_INDEX];
+ uint32_t *bits = &style->i.bits[COLUMN_WIDTH_INDEX];
/* 7bits: uuuuutt : unit | type */
*bits = (*bits & ~COLUMN_WIDTH_MASK) | ((((uint32_t)type & 0x3) | (unit
@@ -984,9 +908,7 @@ static inline css_error set_content(
static inline css_error set_counter_increment(css_computed_style *style,
uint8_t type, css_computed_counter *counter_arr)
{
- uint32_t *bits;
-
- bits = &style->i.bits[COUNTER_INCREMENT_INDEX];
+ uint32_t *bits = &style->i.bits[COUNTER_INCREMENT_INDEX];
/* 1bit: t : type */
*bits = (*bits & ~COUNTER_INCREMENT_MASK) | (((uint32_t)type & 0x1) <<
@@ -1022,9 +944,7 @@ static inline css_error set_counter_increment(css_computed_style *style,
static inline css_error set_counter_reset(css_computed_style *style, uint8_t
type, css_computed_counter *counter_arr)
{
- uint32_t *bits;
-
- bits = &style->i.bits[COUNTER_RESET_INDEX];
+ uint32_t *bits = &style->i.bits[COUNTER_RESET_INDEX];
/* 1bit: t : type */
*bits = (*bits & ~COUNTER_RESET_MASK) | (((uint32_t)type & 0x1) <<
@@ -1060,9 +980,7 @@ static inline css_error set_counter_reset(css_computed_style *style, uint8_t
static inline css_error set_cursor(css_computed_style *style, uint8_t type,
lwc_string **string_arr)
{
- uint32_t *bits;
-
- bits = &style->i.bits[CURSOR_INDEX];
+ uint32_t *bits = &style->i.bits[CURSOR_INDEX];
/* 5bits: ttttt : type */
*bits = (*bits & ~CURSOR_MASK) | (((uint32_t)type & 0x1f) <<
@@ -1097,9 +1015,7 @@ static inline css_error set_cursor(css_computed_style *style, uint8_t type,
static inline css_error set_direction(css_computed_style *style, uint8_t type)
{
- uint32_t *bits;
-
- bits = &style->i.bits[DIRECTION_INDEX];
+ uint32_t *bits = &style->i.bits[DIRECTION_INDEX];
/* 2bits: tt : type */
*bits = (*bits & ~DIRECTION_MASK) | (((uint32_t)type & 0x3) <<
@@ -1117,9 +1033,7 @@ static inline css_error set_direction(css_computed_style *style, uint8_t type)
static inline css_error set_display(css_computed_style *style, uint8_t type)
{
- uint32_t *bits;
-
- bits = &style->i.bits[DISPLAY_INDEX];
+ uint32_t *bits = &style->i.bits[DISPLAY_INDEX];
/* 5bits: ttttt : type */
*bits = (*bits & ~DISPLAY_MASK) | (((uint32_t)type & 0x1f) <<
@@ -1137,9 +1051,7 @@ static inline css_error set_display(css_computed_style *style, uint8_t type)
static inline css_error set_empty_cells(css_computed_style *style, uint8_t type)
{
- uint32_t *bits;
-
- bits = &style->i.bits[EMPTY_CELLS_INDEX];
+ uint32_t *bits = &style->i.bits[EMPTY_CELLS_INDEX];
/* 2bits: tt : type */
*bits = (*bits & ~EMPTY_CELLS_MASK) | (((uint32_t)type & 0x3) <<
@@ -1158,9 +1070,7 @@ static inline css_error set_empty_cells(css_computed_style *style, uint8_t type)
static inline css_error set_flex_basis(css_computed_style *style, uint8_t type,
css_fixed length, css_unit unit)
{
- uint32_t *bits;
-
- bits = &style->i.bits[FLEX_BASIS_INDEX];
+ uint32_t *bits = &style->i.bits[FLEX_BASIS_INDEX];
/* 7bits: uuuuutt : unit | type */
*bits = (*bits & ~FLEX_BASIS_MASK) | ((((uint32_t)type & 0x3) | (unit
@@ -1181,9 +1091,7 @@ static inline css_error set_flex_basis(css_computed_style *style, uint8_t type,
static inline css_error set_flex_direction(css_computed_style *style, uint8_t
type)
{
- uint32_t *bits;
-
- bits = &style->i.bits[FLEX_DIRECTION_INDEX];
+ uint32_t *bits = &style->i.bits[FLEX_DIRECTION_INDEX];
/* 3bits: ttt : type */
*bits = (*bits & ~FLEX_DIRECTION_MASK) | (((uint32_t)type & 0x7) <<
@@ -1202,9 +1110,7 @@ static inline css_error set_flex_direction(css_computed_style *style, uint8_t
static inline css_error set_flex_grow(css_computed_style *style, uint8_t type,
css_fixed fixed)
{
- uint32_t *bits;
-
- bits = &style->i.bits[FLEX_GROW_INDEX];
+ uint32_t *bits = &style->i.bits[FLEX_GROW_INDEX];
/* 1bit: t : type */
*bits = (*bits & ~FLEX_GROW_MASK) | (((uint32_t)type & 0x1) <<
@@ -1225,9 +1131,7 @@ static inline css_error set_flex_grow(css_computed_style *style, uint8_t type,
static inline css_error set_flex_shrink(css_computed_style *style, uint8_t
type, css_fixed fixed)
{
- uint32_t *bits;
-
- bits = &style->i.bits[FLEX_SHRINK_INDEX];
+ uint32_t *bits = &style->i.bits[FLEX_SHRINK_INDEX];
/* 1bit: t : type */
*bits = (*bits & ~FLEX_SHRINK_MASK) | (((uint32_t)type & 0x1) <<
@@ -1247,9 +1151,7 @@ static inline css_error set_flex_shrink(css_computed_style *style, uint8_t
static inline css_error set_flex_wrap(css_computed_style *style, uint8_t type)
{
- uint32_t *bits;
-
- bits = &style->i.bits[FLEX_WRAP_INDEX];
+ uint32_t *bits = &style->i.bits[FLEX_WRAP_INDEX];
/* 2bits: tt : type */
*bits = (*bits & ~FLEX_WRAP_MASK) | (((uint32_t)type & 0x3) <<
@@ -1267,9 +1169,7 @@ static inline css_error set_flex_wrap(css_computed_style *style, uint8_t type)
static inline css_error set_float(css_computed_style *style, uint8_t type)
{
- uint32_t *bits;
-
- bits = &style->i.bits[FLOAT_INDEX];
+ uint32_t *bits = &style->i.bits[FLOAT_INDEX];
/* 2bits: tt : type */
*bits = (*bits & ~FLOAT_MASK) | (((uint32_t)type & 0x3) << FLOAT_SHIFT);
@@ -1287,9 +1187,7 @@ static inline css_error set_float(css_computed_style *style, uint8_t type)
static inline css_error set_font_family(css_computed_style *style, uint8_t
type, lwc_string **string_arr)
{
- uint32_t *bits;
-
- bits = &style->i.bits[FONT_FAMILY_INDEX];
+ uint32_t *bits = &style->i.bits[FONT_FAMILY_INDEX];
/* 3bits: ttt : type */
*bits = (*bits & ~FONT_FAMILY_MASK) | (((uint32_t)type & 0x7) <<
@@ -1325,9 +1223,7 @@ static inline css_error set_font_family(css_computed_style *style, uint8_t
static inline css_error set_font_size(css_computed_style *style, uint8_t type,
css_fixed length, css_unit unit)
{
- uint32_t *bits;
-
- bits = &style->i.bits[FONT_SIZE_INDEX];
+ uint32_t *bits = &style->i.bits[FONT_SIZE_INDEX];
/* 9bits: uuuuutttt : unit | type */
*bits = (*bits & ~FONT_SIZE_MASK) | ((((uint32_t)type & 0xf) | (unit <<
@@ -1347,9 +1243,7 @@ static inline css_error set_font_size(css_computed_style *style, uint8_t type,
static inline css_error set_font_style(css_computed_style *style, uint8_t type)
{
- uint32_t *bits;
-
- bits = &style->i.bits[FONT_STYLE_INDEX];
+ uint32_t *bits = &style->i.bits[FONT_STYLE_INDEX];
/* 2bits: tt : type */
*bits = (*bits & ~FONT_STYLE_MASK) | (((uint32_t)type & 0x3) <<
@@ -1368,9 +1262,7 @@ static inline css_error set_font_style(css_computed_style *style, uint8_t type)
static inline css_error set_font_variant(css_computed_style *style, uint8_t
type)
{
- uint32_t *bits;
-
- bits = &style->i.bits[FONT_VARIANT_INDEX];
+ uint32_t *bits = &style->i.bits[FONT_VARIANT_INDEX];
/* 2bits: tt : type */
*bits = (*bits & ~FONT_VARIANT_MASK) | (((uint32_t)type & 0x3) <<
@@ -1388,9 +1280,7 @@ static inline css_error set_font_variant(css_computed_style *style, uint8_t
static inline css_error set_font_weight(css_computed_style *style, uint8_t type)
{
- uint32_t *bits;
-
- bits = &style->i.bits[FONT_WEIGHT_INDEX];
+ uint32_t *bits = &style->i.bits[FONT_WEIGHT_INDEX];
/* 4bits: tttt : type */
*bits = (*bits & ~FONT_WEIGHT_MASK) | (((uint32_t)type & 0xf) <<
@@ -1409,9 +1299,7 @@ static inline css_error set_font_weight(css_computed_style *style, uint8_t type)
static inline css_error set_height(css_computed_style *style, uint8_t type,
css_fixed length, css_unit unit)
{
- uint32_t *bits;
-
- bits = &style->i.bits[HEIGHT_INDEX];
+ uint32_t *bits = &style->i.bits[HEIGHT_INDEX];
/* 7bits: uuuuutt : unit | type */
*bits = (*bits & ~HEIGHT_MASK) | ((((uint32_t)type & 0x3) | (unit <<
@@ -1432,9 +1320,7 @@ static inline css_error set_height(css_computed_style *style, uint8_t type,
static inline css_error set_justify_content(css_computed_style *style, uint8_t
type)
{
- uint32_t *bits;
-
- bits = &style->i.bits[JUSTIFY_CONTENT_INDEX];
+ uint32_t *bits = &style->i.bits[JUSTIFY_CONTENT_INDEX];
/* 3bits: ttt : type */
*bits = (*bits & ~JUSTIFY_CONTENT_MASK) | (((uint32_t)type & 0x7) <<
@@ -1453,9 +1339,7 @@ static inline css_error set_justify_content(css_computed_style *style, uint8_t
static inline css_error set_left(css_computed_style *style, uint8_t type,
css_fixed length, css_unit unit)
{
- uint32_t *bits;
-
- bits = &style->i.bits[LEFT_INDEX];
+ uint32_t *bits = &style->i.bits[LEFT_INDEX];
/* 7bits: uuuuutt : unit | type */
*bits = (*bits & ~LEFT_MASK) | ((((uint32_t)type & 0x3) | (unit << 2))
@@ -1476,9 +1360,7 @@ static inline css_error set_left(css_computed_style *style, uint8_t type,
static inline css_error set_letter_spacing(css_computed_style *style, uint8_t
type, css_fixed length, css_unit unit)
{
- uint32_t *bits;
-
- bits = &style->i.bits[LETTER_SPACING_INDEX];
+ uint32_t *bits = &style->i.bits[LETTER_SPACING_INDEX];
/* 7bits: uuuuutt : unit | type */
*bits = (*bits & ~LETTER_SPACING_MASK) | ((((uint32_t)type & 0x3) | (
@@ -1499,9 +1381,7 @@ static inline css_error set_letter_spacing(css_computed_style *style, uint8_t
static inline css_error set_line_height(css_computed_style *style, uint8_t
type, css_fixed length, css_unit unit)
{
- uint32_t *bits;
-
- bits = &style->i.bits[LINE_HEIGHT_INDEX];
+ uint32_t *bits = &style->i.bits[LINE_HEIGHT_INDEX];
/* 7bits: uuuuutt : unit | type */
*bits = (*bits & ~LINE_HEIGHT_MASK) | ((((uint32_t)type & 0x3) | (unit
@@ -1522,9 +1402,7 @@ static inline css_error set_line_height(css_computed_style *style, uint8_t
static inline css_error set_list_style_image(css_computed_style *style, uint8_t
type, lwc_string *string)
{
- uint32_t *bits;
-
- bits = &style->i.bits[LIST_STYLE_IMAGE_INDEX];
+ uint32_t *bits = &style->i.bits[LIST_STYLE_IMAGE_INDEX];
/* 1bit: t : type */
*bits = (*bits & ~LIST_STYLE_IMAGE_MASK) | (((uint32_t)type & 0x1) <<
@@ -1554,9 +1432,7 @@ static inline css_error set_list_style_image(css_computed_style *style, uint8_t
static inline css_error set_list_style_position(css_computed_style *style,
uint8_t type)
{
- uint32_t *bits;
-
- bits = &style->i.bits[LIST_STYLE_POSITION_INDEX];
+ uint32_t *bits = &style->i.bits[LIST_STYLE_POSITION_INDEX];
/* 2bits: tt : type */
*bits = (*bits & ~LIST_STYLE_POSITION_MASK) | (((uint32_t)type & 0x3)
@@ -1575,9 +1451,7 @@ static inline css_error set_list_style_position(css_computed_style *style,
static inline css_error set_list_style_type(css_computed_style *style, uint8_t
type)
{
- uint32_t *bits;
-
- bits = &style->i.bits[LIST_STYLE_TYPE_INDEX];
+ uint32_t *bits = &style->i.bits[LIST_STYLE_TYPE_INDEX];
/* 6bits: tttttt : type */
*bits = (*bits & ~LIST_STYLE_TYPE_MASK) | (((uint32_t)type & 0x3f) <<
@@ -1596,9 +1470,7 @@ static inline css_error set_list_style_type(css_computed_style *style, uint8_t
static inline css_error set_margin_bottom(css_computed_style *style, uint8_t
type, css_fixed length, css_unit unit)
{
- uint32_t *bits;
-
- bits = &style->i.bits[MARGIN_BOTTOM_INDEX];
+ uint32_t *bits = &style->i.bits[MARGIN_BOTTOM_INDEX];
/* 7bits: uuuuutt : unit | type */
*bits = (*bits & ~MARGIN_BOTTOM_MASK) | ((((uint32_t)type & 0x3) | (
@@ -1619,9 +1491,7 @@ static inline css_error set_margin_bottom(css_computed_style *style, uint8_t
static inline css_error set_margin_left(css_computed_style *style, uint8_t
type, css_fixed length, css_unit unit)
{
- uint32_t *bits;
-
- bits = &style->i.bits[MARGIN_LEFT_INDEX];
+ uint32_t *bits = &style->i.bits[MARGIN_LEFT_INDEX];
/* 7bits: uuuuutt : unit | type */
*bits = (*bits & ~MARGIN_LEFT_MASK) | ((((uint32_t)type & 0x3) | (unit
@@ -1642,9 +1512,7 @@ static inline css_error set_margin_left(css_computed_style *style, uint8_t
static inline css_error set_margin_right(css_computed_style *style, uint8_t
type, css_fixed length, css_unit unit)
{
- uint32_t *bits;
-
- bits = &style->i.bits[MARGIN_RIGHT_INDEX];
+ uint32_t *bits = &style->i.bits[MARGIN_RIGHT_INDEX];
/* 7bits: uuuuutt : unit | type */
*bits = (*bits & ~MARGIN_RIGHT_MASK) | ((((uint32_t)type & 0x3) | (unit
@@ -1665,9 +1533,7 @@ static inline css_error set_margin_right(css_computed_style *style, uint8_t
static inline css_error set_margin_top(css_computed_style *style, uint8_t type,
css_fixed length, css_unit unit)
{
- uint32_t *bits;
-
- bits = &style->i.bits[MARGIN_TOP_INDEX];
+ uint32_t *bits = &style->i.bits[MARGIN_TOP_INDEX];
/* 7bits: uuuuutt : unit | type */
*bits = (*bits & ~MARGIN_TOP_MASK) | ((((uint32_t)type & 0x3) | (unit
@@ -1688,9 +1554,7 @@ static inline css_error set_margin_top(css_computed_style *style, uint8_t type,
static inline css_error set_max_height(css_computed_style *style, uint8_t type,
css_fixed length, css_unit unit)
{
- uint32_t *bits;
-
- bits = &style->i.bits[MAX_HEIGHT_INDEX];
+ uint32_t *bits = &style->i.bits[MAX_HEIGHT_INDEX];
/* 7bits: uuuuutt : unit | type */
*bits = (*bits & ~MAX_HEIGHT_MASK) | ((((uint32_t)type & 0x3) | (unit
@@ -1711,9 +1575,7 @@ static inline css_error set_max_height(css_computed_style *style, uint8_t type,
static inline css_error set_max_width(css_computed_style *style, uint8_t type,
css_fixed length, css_unit unit)
{
- uint32_t *bits;
-
- bits = &style->i.bits[MAX_WIDTH_INDEX];
+ uint32_t *bits = &style->i.bits[MAX_WIDTH_INDEX];
/* 7bits: uuuuutt : unit | type */
*bits = (*bits & ~MAX_WIDTH_MASK) | ((((uint32_t)type & 0x3) | (unit <<
@@ -1734,9 +1596,7 @@ static inline css_error set_max_width(css_computed_style *style, uint8_t type,
static inline css_error set_min_height(css_computed_style *style, uint8_t type,
css_fixed length, css_unit unit)
{
- uint32_t *bits;
-
- bits = &style->i.bits[MIN_HEIGHT_INDEX];
+ uint32_t *bits = &style->i.bits[MIN_HEIGHT_INDEX];
/* 7bits: uuuuutt : unit | type */
*bits = (*bits & ~MIN_HEIGHT_MASK) | ((((uint32_t)type & 0x3) | (unit
@@ -1757,9 +1617,7 @@ static inline css_error set_min_height(css_computed_style *style, uint8_t type,
static inline css_error set_min_width(css_computed_style *style, uint8_t type,
css_fixed length, css_unit unit)
{
- uint32_t *bits;
-
- bits = &style->i.bits[MIN_WIDTH_INDEX];
+ uint32_t *bits = &style->i.bits[MIN_WIDTH_INDEX];
/* 7bits: uuuuutt : unit | type */
*bits = (*bits & ~MIN_WIDTH_MASK) | ((((uint32_t)type & 0x3) | (unit <<
@@ -1780,9 +1638,7 @@ static inline css_error set_min_width(css_computed_style *style, uint8_t type,
static inline css_error set_opacity(css_computed_style *style, uint8_t type,
css_fixed fixed)
{
- uint32_t *bits;
-
- bits = &style->i.bits[OPACITY_INDEX];
+ uint32_t *bits = &style->i.bits[OPACITY_INDEX];
/* 1bit: t : type */
*bits = (*bits & ~OPACITY_MASK) | (((uint32_t)type & 0x1) <<
@@ -1803,9 +1659,7 @@ static inline css_error set_opacity(css_computed_style *style, uint8_t type,
static inline css_error set_order(css_computed_style *style, uint8_t type,
int32_t integer)
{
- uint32_t *bits;
-
- bits = &style->i.bits[ORDER_INDEX];
+ uint32_t *bits = &style->i.bits[ORDER_INDEX];
/* 1bit: t : type */
*bits = (*bits & ~ORDER_MASK) | (((uint32_t)type & 0x1) << ORDER_SHIFT);
@@ -1825,9 +1679,7 @@ static inline css_error set_order(css_computed_style *style, uint8_t type,
static inline css_error set_orphans(css_computed_style *style, uint8_t type,
int32_t integer)
{
- uint32_t *bits;
-
- bits = &style->i.bits[ORPHANS_INDEX];
+ uint32_t *bits = &style->i.bits[ORPHANS_INDEX];
/* 1bit: t : type */
*bits = (*bits & ~ORPHANS_MASK) | (((uint32_t)type & 0x1) <<
@@ -1848,9 +1700,7 @@ static inline css_error set_orphans(css_computed_style *style, uint8_t type,
static inline css_error set_outline_color(css_computed_style *style, uint8_t
type, css_color color)
{
- uint32_t *bits;
-
- bits = &style->i.bits[OUTLINE_COLOR_INDEX];
+ uint32_t *bits = &style->i.bits[OUTLINE_COLOR_INDEX];
/* 2bits: tt : type */
*bits = (*bits & ~OUTLINE_COLOR_MASK) | (((uint32_t)type & 0x3) <<
@@ -1871,9 +1721,7 @@ static inline css_error set_outline_color(css_computed_style *style, uint8_t
static inline css_error set_outline_style(css_computed_style *style, uint8_t
type)
{
- uint32_t *bits;
-
- bits = &style->i.bits[OUTLINE_STYLE_INDEX];
+ uint32_t *bits = &style->i.bits[OUTLINE_STYLE_INDEX];
/* 4bits: tttt : type */
*bits = (*bits & ~OUTLINE_STYLE_MASK) | (((uint32_t)type & 0xf) <<
@@ -1892,9 +1740,7 @@ static inline css_error set_outline_style(css_computed_style *style, uint8_t
static inline css_error set_outline_width(css_computed_style *style, uint8_t
type, css_fixed length, css_unit unit)
{
- uint32_t *bits;
-
- bits = &style->i.bits[OUTLINE_WIDTH_INDEX];
+ uint32_t *bits = &style->i.bits[OUTLINE_WIDTH_INDEX];
/* 8bits: uuuuuttt : unit | type */
*bits = (*bits & ~OUTLINE_WIDTH_MASK) | ((((uint32_t)type & 0x7) | (
@@ -1914,9 +1760,7 @@ static inline css_error set_outline_width(css_computed_style *style, uint8_t
static inline css_error set_overflow_x(css_computed_style *style, uint8_t type)
{
- uint32_t *bits;
-
- bits = &style->i.bits[OVERFLOW_X_INDEX];
+ uint32_t *bits = &style->i.bits[OVERFLOW_X_INDEX];
/* 3bits: ttt : type */
*bits = (*bits & ~OVERFLOW_X_MASK) | (((uint32_t)type & 0x7) <<
@@ -1934,9 +1778,7 @@ static inline css_error set_overflow_x(css_computed_style *style, uint8_t type)
static inline css_error set_overflow_y(css_computed_style *style, uint8_t type)
{
- uint32_t *bits;
-
- bits = &style->i.bits[OVERFLOW_Y_INDEX];
+ uint32_t *bits = &style->i.bits[OVERFLOW_Y_INDEX];
/* 3bits: ttt : type */
*bits = (*bits & ~OVERFLOW_Y_MASK) | (((uint32_t)type & 0x7) <<
@@ -1955,9 +1797,7 @@ static inline css_error set_overflow_y(css_computed_style *style, uint8_t type)
static inline css_error set_padding_bottom(css_computed_style *style, uint8_t
type, css_fixed length, css_unit unit)
{
- uint32_t *bits;
-
- bits = &style->i.bits[PADDING_BOTTOM_INDEX];
+ uint32_t *bits = &style->i.bits[PADDING_BOTTOM_INDEX];
/* 6bits: uuuuut : unit | type */
*bits = (*bits & ~PADDING_BOTTOM_MASK) | ((((uint32_t)type & 0x1) | (
@@ -1978,9 +1818,7 @@ static inline css_error set_padding_bottom(css_computed_style *style, uint8_t
static inline css_error set_padding_left(css_computed_style *style, uint8_t
type, css_fixed length, css_unit unit)
{
- uint32_t *bits;
-
- bits = &style->i.bits[PADDING_LEFT_INDEX];
+ uint32_t *bits = &style->i.bits[PADDING_LEFT_INDEX];
/* 6bits: uuuuut : unit | type */
*bits = (*bits & ~PADDING_LEFT_MASK) | ((((uint32_t)type & 0x1) | (unit
@@ -2001,9 +1839,7 @@ static inline css_error set_padding_left(css_computed_style *style, uint8_t
static inline css_error set_padding_right(css_computed_style *style, uint8_t
type, css_fixed length, css_unit unit)
{
- uint32_t *bits;
-
- bits = &style->i.bits[PADDING_RIGHT_INDEX];
+ uint32_t *bits = &style->i.bits[PADDING_RIGHT_INDEX];
/* 6bits: uuuuut : unit | type */
*bits = (*bits & ~PADDING_RIGHT_MASK) | ((((uint32_t)type & 0x1) | (
@@ -2024,9 +1860,7 @@ static inline css_error set_padding_right(css_computed_style *style, uint8_t
static inline css_error set_padding_top(css_computed_style *style, uint8_t
type, css_fixed length, css_unit unit)
{
- uint32_t *bits;
-
- bits = &style->i.bits[PADDING_TOP_INDEX];
+ uint32_t *bits = &style->i.bits[PADDING_TOP_INDEX];
/* 6bits: uuuuut : unit | type */
*bits = (*bits & ~PADDING_TOP_MASK) | ((((uint32_t)type & 0x1) | (unit
@@ -2047,9 +1881,7 @@ static inline css_error set_padding_top(css_computed_style *style, uint8_t
static inline css_error set_page_break_after(css_computed_style *style, uint8_t
type)
{
- uint32_t *bits;
-
- bits = &style->i.bits[PAGE_BREAK_AFTER_INDEX];
+ uint32_t *bits = &style->i.bits[PAGE_BREAK_AFTER_INDEX];
/* 3bits: ttt : type */
*bits = (*bits & ~PAGE_BREAK_AFTER_MASK) | (((uint32_t)type & 0x7) <<
@@ -2068,9 +1900,7 @@ static inline css_error set_page_break_after(css_computed_style *style, uint8_t
static inline css_error set_page_break_before(css_computed_style *style,
uint8_t type)
{
- uint32_t *bits;
-
- bits = &style->i.bits[PAGE_BREAK_BEFORE_INDEX];
+ uint32_t *bits = &style->i.bits[PAGE_BREAK_BEFORE_INDEX];
/* 3bits: ttt : type */
*bits = (*bits & ~PAGE_BREAK_BEFORE_MASK) | (((uint32_t)type & 0x7) <<
@@ -2089,9 +1919,7 @@ static inline css_error set_page_break_before(css_computed_style *style,
static inline css_error set_page_break_inside(css_computed_style *style,
uint8_t type)
{
- uint32_t *bits;
-
- bits = &style->i.bits[PAGE_BREAK_INSIDE_INDEX];
+ uint32_t *bits = &style->i.bits[PAGE_BREAK_INSIDE_INDEX];
/* 2bits: tt : type */
*bits = (*bits & ~PAGE_BREAK_INSIDE_MASK) | (((uint32_t)type & 0x3) <<
@@ -2109,9 +1937,7 @@ static inline css_error set_page_break_inside(css_computed_style *style,
static inline css_error set_position(css_computed_style *style, uint8_t type)
{
- uint32_t *bits;
-
- bits = &style->i.bits[POSITION_INDEX];
+ uint32_t *bits = &style->i.bits[POSITION_INDEX];
/* 3bits: ttt : type */
*bits = (*bits & ~POSITION_MASK) | (((uint32_t)type & 0x7) <<
@@ -2130,9 +1956,7 @@ static inline css_error set_position(css_computed_style *style, uint8_t type)
static inline css_error set_quotes(css_computed_style *style, uint8_t type,
lwc_string **string_arr)
{
- uint32_t *bits;
-
- bits = &style->i.bits[QUOTES_INDEX];
+ uint32_t *bits = &style->i.bits[QUOTES_INDEX];
/* 1bit: t : type */
*bits = (*bits & ~QUOTES_MASK) | (((uint32_t)type & 0x1) <<
@@ -2168,9 +1992,7 @@ static inline css_error set_quotes(css_computed_style *style, uint8_t type,
static inline css_error set_right(css_computed_style *style, uint8_t type,
css_fixed length, css_unit unit)
{
- uint32_t *bits;
-
- bits = &style->i.bits[RIGHT_INDEX];
+ uint32_t *bits = &style->i.bits[RIGHT_INDEX];
/* 7bits: uuuuutt : unit | type */
*bits = (*bits & ~RIGHT_MASK) | ((((uint32_t)type & 0x3) | (unit << 2))
@@ -2191,9 +2013,7 @@ static inline css_error set_right(css_computed_style *style, uint8_t type,
static inline css_error set_table_layout(css_computed_style *style, uint8_t
type)
{
- uint32_t *bits;
-
- bits = &style->i.bits[TABLE_LAYOUT_INDEX];
+ uint32_t *bits = &style->i.bits[TABLE_LAYOUT_INDEX];
/* 2bits: tt : type */
*bits = (*bits & ~TABLE_LAYOUT_MASK) | (((uint32_t)type & 0x3) <<
@@ -2211,9 +2031,7 @@ static inline css_error set_table_layout(css_computed_style *style, uint8_t
static inline css_error set_text_align(css_computed_style *style, uint8_t type)
{
- uint32_t *bits;
-
- bits = &style->i.bits[TEXT_ALIGN_INDEX];
+ uint32_t *bits = &style->i.bits[TEXT_ALIGN_INDEX];
/* 4bits: tttt : type */
*bits = (*bits & ~TEXT_ALIGN_MASK) | (((uint32_t)type & 0xf) <<
@@ -2232,9 +2050,7 @@ static inline css_error set_text_align(css_computed_style *style, uint8_t type)
static inline css_error set_text_decoration(css_computed_style *style, uint8_t
type)
{
- uint32_t *bits;
-
- bits = &style->i.bits[TEXT_DECORATION_INDEX];
+ uint32_t *bits = &style->i.bits[TEXT_DECORATION_INDEX];
/* 5bits: ttttt : type */
*bits = (*bits & ~TEXT_DECORATION_MASK) | (((uint32_t)type & 0x1f) <<
@@ -2253,9 +2069,7 @@ static inline css_error set_text_decoration(css_computed_style *style, uint8_t
static inline css_error set_text_indent(css_computed_style *style, uint8_t
type, css_fixed length, css_unit unit)
{
- uint32_t *bits;
-
- bits = &style->i.bits[TEXT_INDENT_INDEX];
+ uint32_t *bits = &style->i.bits[TEXT_INDENT_INDEX];
/* 6bits: uuuuut : unit | type */
*bits = (*bits & ~TEXT_INDENT_MASK) | ((((uint32_t)type & 0x1) | (unit
@@ -2276,9 +2090,7 @@ static inline css_error set_text_indent(css_computed_style *style, uint8_t
static inline css_error set_text_transform(css_computed_style *style, uint8_t
type)
{
- uint32_t *bits;
-
- bits = &style->i.bits[TEXT_TRANSFORM_INDEX];
+ uint32_t *bits = &style->i.bits[TEXT_TRANSFORM_INDEX];
/* 3bits: ttt : type */
*bits = (*bits & ~TEXT_TRANSFORM_MASK) | (((uint32_t)type & 0x7) <<
@@ -2297,9 +2109,7 @@ static inline css_error set_text_transform(css_computed_style *style, uint8_t
static inline css_error set_top(css_computed_style *style, uint8_t type,
css_fixed length, css_unit unit)
{
- uint32_t *bits;
-
- bits = &style->i.bits[TOP_INDEX];
+ uint32_t *bits = &style->i.bits[TOP_INDEX];
/* 7bits: uuuuutt : unit | type */
*bits = (*bits & ~TOP_MASK) | ((((uint32_t)type & 0x3) | (unit << 2))
@@ -2320,9 +2130,7 @@ static inline css_error set_top(css_computed_style *style, uint8_t type,
static inline css_error set_unicode_bidi(css_computed_style *style, uint8_t
type)
{
- uint32_t *bits;
-
- bits = &style->i.bits[UNICODE_BIDI_INDEX];
+ uint32_t *bits = &style->i.bits[UNICODE_BIDI_INDEX];
/* 2bits: tt : type */
*bits = (*bits & ~UNICODE_BIDI_MASK) | (((uint32_t)type & 0x3) <<
@@ -2341,9 +2149,7 @@ static inline css_error set_unicode_bidi(css_computed_style *style, uint8_t
static inline css_error set_vertical_align(css_computed_style *style, uint8_t
type, css_fixed length, css_unit unit)
{
- uint32_t *bits;
-
- bits = &style->i.bits[VERTICAL_ALIGN_INDEX];
+ uint32_t *bits = &style->i.bits[VERTICAL_ALIGN_INDEX];
/* 9bits: uuuuutttt : unit | type */
*bits = (*bits & ~VERTICAL_ALIGN_MASK) | ((((uint32_t)type & 0xf) | (
@@ -2363,9 +2169,7 @@ static inline css_error set_vertical_align(css_computed_style *style, uint8_t
static inline css_error set_visibility(css_computed_style *style, uint8_t type)
{
- uint32_t *bits;
-
- bits = &style->i.bits[VISIBILITY_INDEX];
+ uint32_t *bits = &style->i.bits[VISIBILITY_INDEX];
/* 2bits: tt : type */
*bits = (*bits & ~VISIBILITY_MASK) | (((uint32_t)type & 0x3) <<
@@ -2383,9 +2187,7 @@ static inline css_error set_visibility(css_computed_style *style, uint8_t type)
static inline css_error set_white_space(css_computed_style *style, uint8_t type)
{
- uint32_t *bits;
-
- bits = &style->i.bits[WHITE_SPACE_INDEX];
+ uint32_t *bits = &style->i.bits[WHITE_SPACE_INDEX];
/* 3bits: ttt : type */
*bits = (*bits & ~WHITE_SPACE_MASK) | (((uint32_t)type & 0x7) <<
@@ -2404,9 +2206,7 @@ static inline css_error set_white_space(css_computed_style *style, uint8_t type)
static inline css_error set_widows(css_computed_style *style, uint8_t type,
int32_t integer)
{
- uint32_t *bits;
-
- bits = &style->i.bits[WIDOWS_INDEX];
+ uint32_t *bits = &style->i.bits[WIDOWS_INDEX];
/* 1bit: t : type */
*bits = (*bits & ~WIDOWS_MASK) | (((uint32_t)type & 0x1) <<
@@ -2427,9 +2227,7 @@ static inline css_error set_widows(css_computed_style *style, uint8_t type,
static inline css_error set_width(css_computed_style *style, uint8_t type,
css_fixed length, css_unit unit)
{
- uint32_t *bits;
-
- bits = &style->i.bits[WIDTH_INDEX];
+ uint32_t *bits = &style->i.bits[WIDTH_INDEX];
/* 7bits: uuuuutt : unit | type */
*bits = (*bits & ~WIDTH_MASK) | ((((uint32_t)type & 0x3) | (unit << 2))
@@ -2450,9 +2248,7 @@ static inline css_error set_width(css_computed_style *style, uint8_t type,
static inline css_error set_word_spacing(css_computed_style *style, uint8_t
type, css_fixed length, css_unit unit)
{
- uint32_t *bits;
-
- bits = &style->i.bits[WORD_SPACING_INDEX];
+ uint32_t *bits = &style->i.bits[WORD_SPACING_INDEX];
/* 7bits: uuuuutt : unit | type */
*bits = (*bits & ~WORD_SPACING_MASK) | ((((uint32_t)type & 0x3) | (unit
@@ -2473,9 +2269,7 @@ static inline css_error set_word_spacing(css_computed_style *style, uint8_t
static inline css_error set_writing_mode(css_computed_style *style, uint8_t
type)
{
- uint32_t *bits;
-
- bits = &style->i.bits[WRITING_MODE_INDEX];
+ uint32_t *bits = &style->i.bits[WRITING_MODE_INDEX];
/* 2bits: tt : type */
*bits = (*bits & ~WRITING_MODE_MASK) | (((uint32_t)type & 0x3) <<
@@ -2494,9 +2288,7 @@ static inline css_error set_writing_mode(css_computed_style *style, uint8_t
static inline css_error set_z_index(css_computed_style *style, uint8_t type,
int32_t integer)
{
- uint32_t *bits;
-
- bits = &style->i.bits[Z_INDEX_INDEX];
+ uint32_t *bits = &style->i.bits[Z_INDEX_INDEX];
/* 2bits: tt : type */
*bits = (*bits & ~Z_INDEX_MASK) | (((uint32_t)type & 0x3) <<
diff --git a/src/select/select_generator.py b/src/select/select_generator.py
index 05a4511..9e92909 100644
--- a/src/select/select_generator.py
+++ b/src/select/select_generator.py
@@ -322,18 +322,16 @@ class CSSProperty:
"""
vals = []
for v in self.values:
+ star = '*' if pointer else ''
vt, vn = shift_star(v.type, v.name)
- vn += v.suffix
+ vn = star + vn + v.suffix
if pointer:
- vn = '*' + vn
if v.name == 'counter_arr' or v.name == 'content_item':
vt = 'const ' + vt
vals.append((vt, vn))
if v.bits is not None:
- bt, bn = shift_star(v.bits['type'], v.bits['name'])
- bn += v.suffix
- if pointer:
- bn = '*' + bn
+ bt = v.bits['type']
+ bn = star + v.bits['name'] + v.suffix
vals.append((bt, bn))
return vals
@@ -429,21 +427,12 @@ class CSSGroup:
return bits_array
- def get_idot_grp(self):
- """Make parameters for accessing bits and values in this group."""
- i_dot = '' if self.name == 'page' else 'i.'
- grp = '' if self.name == 'style' else '->{}{}'.format(
- '' if self.name == 'page' else i_dot, self.name)
- return (i_dot, grp)
-
def make_computed_h(self):
"""Output this group's text for the computed.h file."""
t = Text()
t.append()
- typedef = 'typedef ' if self.name == 'page' else ''
- t.append('{}struct css_computed_{}{} {{'.format(
- typedef, self.name, '' if self.name == 'page' else '_i'))
+ t.append('struct css_computed_style_i {')
t.comment()
commented = []
@@ -490,103 +479,28 @@ class CSSGroup:
t.append()
t.append(self.make_value_declaration(for_commented=False))
- if self.name == 'style':
- t.append()
- for g in css_groups:
- if g.name != 'style' and g.name != 'page':
- t.append('css_computed_{0} *{0};'.format(g.name))
-
t.indent(-1)
- t.append('}}{};'.format(
- ' css_computed_' + self.name if typedef else ''))
+ t.append('};')
- if self.name != 'page':
- typedef = 'typedef ' if self.name != 'style' else ''
- t.append()
- t.append('{}struct css_computed_{} {{'.format(
- typedef, self.name))
- t.indent(1)
- t.append('struct css_computed_' + self.name + '_i i;')
- t.append()
- t.append(self.make_value_declaration(for_commented=True))
- t.append()
+ t.append()
+ t.append('struct css_computed_style {')
+ t.indent(1)
+ t.append('struct css_computed_style_i i;')
+ t.append()
+ t.append(self.make_value_declaration(for_commented=True))
+ t.append()
- t.append('struct css_computed_' + self.name + ' *next;')
- t.append('uint32_t count;')
- t.append('uint32_t bin;')
- t.indent(-1)
- t.append('}}{};'.format(
- ' css_computed_' + self.name if typedef else ''))
+ t.append('struct css_computed_style *next;')
+ t.append('uint32_t count;')
+ t.append('uint32_t bin;')
+ t.indent(-1)
+ t.append('};')
return t.to_string()
def make_propset_h(self):
- """Output this group's property functions for the propset.h file.
-
- If group is not `style`, will also output the defaults
- and the ENSURE_{group} texts.
- """
+ """Output this group's property functions for the propset.h file."""
t = Text()
- i_dot, grp = self.get_idot_grp()
-
- if self.name != 'style':
- t.append('static const css_computed_{0} default_{0} = {{'.format(
- self.name))
- t.indent(1)
-
- if self.name != 'page':
- t.append('.i = {')
- t.indent(1)
-
- t.append('.bits = {')
- t.indent(1)
-
- bits_ops = []
- for b in self.bits_array:
- or_ops = []
- for p in b.contents:
- or_ops.append('({} << {})'.format(p.defaults, str(p.shift))
- if p.shift else p.defaults)
- bits_ops.append(' | '.join(or_ops))
-
- t.append(',\n'.join(bits_ops).split('\n'))
- t.indent(-1)
- t.append('},')
- t.append(',\n'.join(
- self.make_value_declaration(False, True)).split('\n'))
-
- if self.name != 'page':
- t.indent(-1)
- t.append('},')
- t.append(',\n'.join(
- self.make_value_declaration(True, True) +
- [ '.next = NULL', '.count = 0', '.bin = UINT32_MAX' ]
- ).split('\n'))
-
- t.indent(-1)
- t.append('};')
-
- t.append()
- t.escape_newline()
- t.append('#define ENSURE_{} do {{'.format(self.name.upper()))
- t.indent(1)
- t.append('if (style->{}{} == NULL) {{'.format(i_dot, self.name))
- t.indent(1)
- t.append('style->{}{n} = malloc(sizeof(css_computed_{n}));'.format(
- i_dot, n=self.name))
- t.append('if (style->{}{} == NULL)'.format(i_dot, self.name))
- t.indent(1)
- t.append('return CSS_NOMEM;')
- t.indent(-1)
- t.append()
- t.append('memcpy(style->{}{n}, &default_{n}, '
- 'sizeof(css_computed_{n}));'.format(i_dot, n=self.name))
- t.indent(-1)
- t.append('}')
- t.indent(-1)
- t.append('} while(0)')
- t.escape_newline()
- t.append()
for p in sorted(self.props, key=(lambda x: x.name)):
defines, undefs = p.def_undefs
@@ -608,15 +522,7 @@ class CSSGroup:
t.append('{')
t.indent(1)
- t.append('uint32_t *bits;')
- t.append()
-
- if self.name != 'style':
- t.append('ENSURE_{};'.format(self.name.upper()))
- t.append()
-
- t.append('bits = &style{}->{}bits[{}_INDEX];'.format(
- grp, i_dot, p.name.upper()))
+ t.append('uint32_t *bits = &style->i.bits[{}_INDEX];'.format(p.name.upper()))
t.append()
type_mask, shift_list, bits_comment = p.get_bits()
@@ -637,19 +543,17 @@ class CSSGroup:
old_t, old_n_shift = shift_star(v.type, old_n)
if v.name == 'string':
- t.append('{} {} = style{}->{}{};'.format(
- old_t, old_n_shift,
- grp, i_dot, p.name + v.suffix))
+ t.append('{} {} = style->i.{};'.format(
+ old_t, old_n_shift, p.name + v.suffix))
t.append()
t.append('if ({} != NULL) {{'.format(v.name + v.suffix))
t.indent(1)
- t.append('style{}->{}{} = lwc_string_ref({});'.format(
- grp, i_dot, p.name + v.suffix, v.name + v.suffix))
+ t.append('style->i.{} = lwc_string_ref({});'.format(
+ p.name + v.suffix, v.name + v.suffix))
t.indent(-1)
t.append('} else {')
t.indent(1)
- t.append('style{}->{}{} = NULL;'.format(
- grp, i_dot, p.name + v.suffix))
+ t.append('style->i.{} = NULL;'.format(p.name + v.suffix))
t.indent(-1)
t.append('}')
t.append()
@@ -661,9 +565,9 @@ class CSSGroup:
elif v.name == 'string_arr' or v.name == 'counter_arr':
iter_var = 's' if v.name == 'string_arr' else 'c'
iter_deref = '*s' if v.name == 'string_arr' else 'c->name'
- t.append('{} {} = style{}->{};'.format(
+ t.append('{} {} = style->{};'.format(
old_t, old_n_shift,
- grp, p.name + v.suffix))
+ p.name + v.suffix))
t.append('{} {};'.format(old_t,
shift_star(v.type, iter_var)[1]))
t.append()
@@ -674,8 +578,8 @@ class CSSGroup:
t.append('{0} = lwc_string_ref({0});'.format(iter_deref))
t.indent(-1)
t.append()
- t.append('style{}->{} = {};'.format(
- grp, p.name + v.suffix, v.name + v.suffix))
+ t.append('style->{} = {};'.format(
+ p.name + v.suffix, v.name + v.suffix))
t.append()
t.append('/* Free existing array */')
t.append('if ({} != NULL) {{'.format(old_n))
@@ -693,8 +597,8 @@ class CSSGroup:
t.append('}')
elif not v.is_ptr:
- t.append('style{}->{}{} = {};'.format(
- grp, i_dot, p.name + v.suffix, v.name + v.suffix))
+ t.append('style->i.{} = {};'.format(
+ p.name + v.suffix, v.name + v.suffix))
else:
raise ValueError('Cannot handle value ' + v.name +'!')
@@ -708,23 +612,18 @@ class CSSGroup:
return t.to_string()
def print_propget(self, t, p, only_bits=False):
- i_dot, grp = self.get_idot_grp()
-
vals = [] if only_bits else p.get_param_values(pointer=True)
params = ', '.join([ 'css_computed_style *style' ]
+ [ ' '.join(x) for x in vals ])
+
underscore_bits = '_bits' if only_bits else ''
t.append('static inline uint8_t get_{}{}(const {})'.format(
p.name, underscore_bits, params))
t.append('{')
t.indent(1)
- if self.name != 'style':
- t.append('if (style{} != NULL) {{'.format(grp))
- t.indent(1)
-
- t.append('uint32_t bits = style{}->{}bits[{}_INDEX];'.format(
- grp, i_dot, p.name.upper()))
+ t.append('uint32_t bits = style->i.bits[{}_INDEX];'.format(
+ p.name.upper()))
t.append('bits &= {}_MASK;'.format(p.name.upper()))
t.append('bits >>= {}_SHIFT;'.format(p.name.upper()))
t.append()
@@ -733,16 +632,15 @@ class CSSGroup:
t.append(bits_comment)
if only_bits == False:
-
if p.condition:
t.append('if ((bits & {}) == {}) {{'.format(
type_mask, p.condition))
t.indent(1)
for v in p.values:
- this_idot = '' if v.is_ptr and v.name != 'string' else i_dot
- t.append('*{} = style{}->{}{};'.format(
- v.name + v.suffix, grp, this_idot, p.name + v.suffix))
+ i_dot = '' if v.is_ptr and v.name != 'string' else 'i.'
+ t.append('*{} = style->{}{};'.format(
+ v.name + v.suffix, i_dot, p.name + v.suffix))
for i, v in enumerate(list(reversed(shift_list))):
if i == 0:
t.append('*{} = bits >> {};'.format(v[0], v[1]))
@@ -757,18 +655,6 @@ class CSSGroup:
t.append('return (bits & {});'.format(type_mask))
- if self.name != 'style':
- t.indent(-1)
- t.append('}')
- t.append()
- t.append('/* Initial value */')
- for v in p.values:
- t.append('*{} = {};'.format(v.name + v.suffix, v.defaults))
- if v.bits is not None:
- t.append('*{} = {};'.format(
- v.bits['name'] + v.suffix, v.bits['defaults']))
- t.append('return {};'.format(p.defaults))
-
t.indent(-1)
t.append('}')
@@ -793,7 +679,7 @@ class CSSGroup:
return t.to_string()
- def make_value_declaration(self, for_commented, defaults=False):
+ def make_value_declaration(self, for_commented):
"""Output declarations of values for this group's properties.
Args:
@@ -805,12 +691,8 @@ class CSSGroup:
for p in sorted(self.props, key=(lambda x: x.name)):
if bool(p.comments) == for_commented:
for v in p.values:
- if defaults:
- r.append('.{}{} = {}'.format(p.name, v.suffix,
- v.defaults))
- else:
- v_type, v_name = shift_star(v.type, p.name)
- r.append('{} {}{};'.format(v_type, v_name, v.suffix))
+ v_type, v_name = shift_star(v.type, p.name)
+ r.append('{} {}{};'.format(v_type, v_name, v.suffix))
return r
def make_text(self, filename):
diff --git a/test/dump.h b/test/dump.h
index a1fdd1f..eac0a9f 100644
--- a/test/dump.h
+++ b/test/dump.h
@@ -803,15 +803,23 @@ void dump_bytecode(css_style *style, char **ptr, uint32_t depth)
} else if (getFlagValue(opv) == FLAG_VALUE_UNSET) {
*ptr += sprintf(*ptr, "unset");
} else if (isCalc(opv)) {
+ lwc_string *calc_expr = NULL;
+ const uint8_t *codeptr = NULL;
+ css_code_t calc_opcode;
+ uint32_t unit, snum;
/* First entry is a unit */
- uint32_t unit = *((uint32_t *)bytecode);
+ unit = *((uint32_t *)bytecode);
ADVANCE(sizeof(unit));
+ /* Second entry is an lwc_string of the expression */
+ snum = *((uint32_t *)bytecode);
+ ADVANCE(sizeof(snum));
+ css__stylesheet_string_get(style->sheet, snum, &calc_expr);
+ codeptr = (const uint8_t *)lwc_string_data(calc_expr);
*ptr += sprintf(*ptr, "/* -> ");
dump_unit(0, unit, ptr);
*ptr += sprintf(*ptr, " */ calc(");
- css_code_t calc_opcode;
- while ((calc_opcode = *((css_code_t *)bytecode)) != CALC_FINISH) {
- ADVANCE(sizeof(calc_opcode));
+ while ((calc_opcode = *((css_code_t *)codeptr)) != CALC_FINISH) {
+ codeptr += sizeof(calc_opcode);
switch (calc_opcode) {
case CALC_ADD:
*ptr += sprintf(*ptr, "+ ");
@@ -826,17 +834,17 @@ void dump_bytecode(css_style *style, char **ptr, uint32_t depth)
*ptr += sprintf(*ptr, "/ ");
break;
case CALC_PUSH_VALUE: {
- css_fixed num = *((css_fixed *)bytecode);
- ADVANCE(sizeof(num));
- uint32_t unit = *((uint32_t *)bytecode);
- ADVANCE(sizeof(unit));
+ css_fixed num = *((css_fixed *)codeptr);
+ codeptr += sizeof(num);
+ uint32_t unit = *((uint32_t *)codeptr);
+ codeptr += sizeof(unit);
dump_unit(num, unit, ptr);
*ptr += sprintf(*ptr, " ");
break;
}
case CALC_PUSH_NUMBER: {
- css_fixed num = *((css_fixed *)bytecode);
- ADVANCE(sizeof(num));
+ css_fixed num = *((css_fixed *)codeptr);
+ codeptr += sizeof(num);
dump_number(num, ptr);
*ptr += sprintf(*ptr, " ");
break;
@@ -846,7 +854,6 @@ void dump_bytecode(css_style *style, char **ptr, uint32_t depth)
break;
}
}
- ADVANCE(sizeof(calc_opcode));
*ptr += sprintf(*ptr, "=)");
} else {
value = getValue(opv);