From 6a50bef84ae6a0a67e03ac1356f8d85d15fe09d6 Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Wed, 19 Jan 2011 23:12:37 +0000 Subject: Merge parser autogeneration and string handling refactor branch r=jmb,kinnison,vince svn path=/trunk/libcss/; revision=11408 --- src/parse/properties/utils.h | 174 +++++++++++++++++++++++++++++++++++-------- 1 file changed, 142 insertions(+), 32 deletions(-) (limited to 'src/parse/properties/utils.h') diff --git a/src/parse/properties/utils.h b/src/parse/properties/utils.h index c5bef1c..66b706d 100644 --- a/src/parse/properties/utils.h +++ b/src/parse/properties/utils.h @@ -10,71 +10,181 @@ #include "parse/language.h" -css_error parse_pause_common(css_language *c, - const parserutils_vector *vector, int *ctx, - uint16_t op, css_style **result); - -css_error parse_list_style_type_value(css_language *c, - const css_token *token, uint16_t *value); -css_error parse_content_list(css_language *c, - const parserutils_vector *vector, int *ctx, - uint16_t *value, uint8_t *buffer, uint32_t *buflen); -css_error parse_counter_common(css_language *c, - const parserutils_vector *vector, int *ctx, - uint16_t op, css_style **result); +static inline bool is_css_inherit(css_language *c, const css_token *token) +{ + bool match; + return ((token->type == CSS_TOKEN_IDENT) && + (lwc_string_caseless_isequal( + token->idata, c->strings[INHERIT], + &match) == lwc_error_ok && match)); +} +enum border_side_e { BORDER_SIDE_TOP = 0, BORDER_SIDE_RIGHT = 1, BORDER_SIDE_BOTTOM = 2, BORDER_SIDE_LEFT = 3 }; -enum { BORDER_SIDE_TOP = 0, BORDER_SIDE_RIGHT = 1, BORDER_SIDE_BOTTOM = 2, BORDER_SIDE_LEFT = 3 }; - +/** + * Parse border-{top,right,bottom,left} shorthand + * + * \param c Parsing context. + * \param vector Vector of tokens to process. + * \param ctx Pointer to vector iteration context. + * \param result Result style. + * \param side The side we're parsing for. + * \return CSS_OK on success, + * CSS_NOMEM on memory exhaustion, + * CSS_INVALID if the input is not valid + * + * Post condition: \a *ctx is updated with the next token to process + * If the input is invalid, then \a *ctx remains unchanged. + */ css_error parse_border_side(css_language *c, const parserutils_vector *vector, int *ctx, - uint32_t side, css_style **result); + css_style *result, enum border_side_e side); + +/** + * Parse border-{top,right,bottom,left}-color + * + * \param c Parsing context + * \param vector Vector of tokens to process + * \param ctx Pointer to vector iteration context + * \param result Pointer to location to receive resulting style + * \param op Opcode to parse for (encodes side) + * \return CSS_OK on success, + * CSS_NOMEM on memory exhaustion, + * CSS_INVALID if the input is not valid + * + * Post condition: \a *ctx is updated with the next token to process + * If the input is invalid, then \a *ctx remains unchanged. + */ css_error parse_border_side_color(css_language *c, const parserutils_vector *vector, int *ctx, - uint16_t op, css_style **result); + css_style *result, enum css_properties_e op); + +/** + * Parse border-{top,right,bottom,left}-style + * + * \param c Parsing context + * \param vector Vector of tokens to process + * \param ctx Pointer to vector iteration context + * \param result Pointer to location to receive resulting style + * \param op Opcode to parse for (encodes side) + * \return CSS_OK on success, + * CSS_NOMEM on memory exhaustion, + * CSS_INVALID if the input is not valid + * + * Post condition: \a *ctx is updated with the next token to process + * If the input is invalid, then \a *ctx remains unchanged. + */ css_error parse_border_side_style(css_language *c, const parserutils_vector *vector, int *ctx, - uint16_t op, css_style **result); + css_style *result, enum css_properties_e op); + + +/** + * Parse border-{top,right,bottom,left}-width + * + * \param c Parsing context + * \param vector Vector of tokens to process + * \param ctx Pointer to vector iteration context + * \param result Pointer to location to receive resulting style + * \param op Opcode to parse for (encodes side) + * \return CSS_OK on success, + * CSS_NOMEM on memory exhaustion, + * CSS_INVALID if the input is not valid + * + * Post condition: \a *ctx is updated with the next token to process + * If the input is invalid, then \a *ctx remains unchanged. + */ css_error parse_border_side_width(css_language *c, const parserutils_vector *vector, int *ctx, - uint16_t op, css_style **result); + css_style *result, enum css_properties_e op); -css_error parse_margin_side(css_language *c, - const parserutils_vector *vector, int *ctx, - uint16_t op, css_style **result); +/** + * Parse {top,right,bottom,left} + * + * \param c Parsing context + * \param vector Vector of tokens to process + * \param ctx Pointer to vector iteration context + * \param op Opcode to parse for + * \param result Pointer to location to receive resulting style + * \return CSS_OK on success, + * CSS_NOMEM on memory exhaustion, + * CSS_INVALID if the input is not valid + * + * Post condition: \a *ctx is updated with the next token to process + * If the input is invalid, then \a *ctx remains unchanged. + */ css_error parse_side(css_language *c, const parserutils_vector *vector, int *ctx, - uint16_t op, css_style **result); + css_style *result, enum css_properties_e op); + +/** + * Parse margin-{top,right,bottom,left} + * + * \param c Parsing context + * \param vector Vector of tokens to process + * \param ctx Pointer to vector iteration context + * \param result Pointer to location to receive resulting style + * \return CSS_OK on success, + * CSS_NOMEM on memory exhaustion, + * CSS_INVALID if the input is not valid + * + * Post condition: \a *ctx is updated with the next token to process + * If the input is invalid, then \a *ctx remains unchanged. + */ +css_error parse_margin_side(css_language *c, + const parserutils_vector *vector, int *ctx, + css_style *result, enum css_properties_e op); + +/** + * Parse padding-{top,right,bottom,left} + * + * \param c Parsing context + * \param vector Vector of tokens to process + * \param ctx Pointer to vector iteration context + * \param result Pointer to location to receive resulting style + * \return CSS_OK on success, + * CSS_NOMEM on memory exhaustion, + * CSS_INVALID if the input is not valid + * + * Post condition: \a *ctx is updated with the next token to process + * If the input is invalid, then \a *ctx remains unchanged. + */ css_error parse_padding_side(css_language *c, const parserutils_vector *vector, int *ctx, - uint16_t op, css_style **result); + css_style *result, enum css_properties_e op); + + + + + + + +css_error parse_list_style_type_value(css_language *c, + const css_token *token, uint16_t *value); css_error parse_colour_specifier(css_language *c, const parserutils_vector *vector, int *ctx, uint32_t *result); + css_error parse_named_colour(css_language *c, lwc_string *data, uint32_t *result); + css_error parse_hash_colour(lwc_string *data, uint32_t *result); css_error parse_unit_specifier(css_language *c, const parserutils_vector *vector, int *ctx, uint32_t default_unit, css_fixed *length, uint32_t *unit); + css_error parse_unit_keyword(const char *ptr, size_t len, css_unit *unit); -css_error comma_list_length(css_language *c, - const parserutils_vector *vector, int *ctx, - const css_token *token, - bool (*reserved)(css_language *c, const css_token *ident), - uint32_t *size); -css_error comma_list_to_bytecode(css_language *c, +css_error comma_list_to_style(css_language *c, const parserutils_vector *vector, int *ctx, - const css_token *token, bool (*reserved)(css_language *c, const css_token *ident), - uint16_t (*get_value)(css_language *c, const css_token *token), - uint8_t **bytecode); + css_code_t (*get_value)(css_language *c, const css_token *token, bool first), + css_style *result); #endif -- cgit v1.2.3