XenevaOS
Loading...
Searching...
No Matches
Macros | Functions
utils.c File Reference
#include <assert.h>
#include <string.h>
#include <strings.h>
#include "stylesheet.h"
#include "bytecode/bytecode.h"
#include "bytecode/opcodes.h"
#include "parse/properties/properties.h"
#include "parse/properties/utils.h"
#include "utils/parserutilserror.h"
Include dependency graph for utils.c:

Macros

#define MAP_ENTRIES   52
 
#define ORGB(R, G, B)
 

Functions

css_error css__parse_list_style_type_value (css_language *c, const css_token *ident, uint16_t *value)
 
css_error css__parse_border_side (css_language *c, const parserutils_vector *vector, int32_t *ctx, css_style *result, enum border_side_e side)
 
css_error css__parse_colour_specifier (css_language *c, const parserutils_vector *vector, int32_t *ctx, uint16_t *value, uint32_t *result)
 
css_error css__parse_named_colour (css_language *c, lwc_string *data, uint32_t *result)
 
css_error css__parse_hash_colour (lwc_string *data, uint32_t *result)
 
css_error css__parse_unit_specifier (css_language *c, const parserutils_vector *vector, int32_t *ctx, uint32_t default_unit, css_fixed *length, uint32_t *unit)
 
css_error css__parse_unit_keyword (const char *ptr, size_t len, uint32_t *unit)
 
css_error css__ident_list_or_string_to_string (css_language *c, const parserutils_vector *vector, int32_t *ctx, bool(*reserved)(css_language *c, const css_token *ident), lwc_string **result)
 
css_error css__ident_list_to_string (css_language *c, const parserutils_vector *vector, int32_t *ctx, bool(*reserved)(css_language *c, const css_token *ident), lwc_string **result)
 
css_error css__comma_list_to_style (css_language *c, const parserutils_vector *vector, int32_t *ctx, bool(*reserved)(css_language *c, const css_token *ident), css_code_t(*get_value)(css_language *c, const css_token *token, bool first), css_style *result)
 

Macro Definition Documentation

◆ MAP_ENTRIES

#define MAP_ENTRIES   52

◆ ORGB

#define ORGB (   R,
  G,
  B 
)
Value:
*r = FIXTOINT(FDIV(FMUL((R), F_255), F_100)); \
*g = FIXTOINT(FDIV(FMUL((G), F_255), F_100)); \
size_t b
Definition main.cpp:156
#define R
Definition am_map.c:143
@ B
Definition element-type.h:28
#define FDIV(a, b)
Definition fpmath.h:119
#define FMUL(a, b)
Definition fpmath.h:117
#define F_100
Definition fpmath.h:152
#define FIXTOINT(a)
Definition fpmath.h:129
#define F_255
Definition fpmath.h:154

Function Documentation

◆ css__comma_list_to_style()

css_error css__comma_list_to_style ( css_language *  c,
const parserutils_vector *  vector,
int32_t *  ctx,
bool(*)(css_language *c, const css_token *ident)  reserved,
css_code_t(*)(css_language *c, const css_token *token, bool first)  get_value,
css_style *  result 
)

Parse a comma separated list, converting to bytecode

Parameters
cParsing context
vectorVector of tokens to process
ctxPointer to vector iteration context
reservedCallback to determine if an identifier is reserved
get_valueCallback to retrieve bytecode value for a token
stylePointer to output style
Returns
CSS_OK on success, CSS_INVALID if the input is invalid

Post condition: *ctx is updated with the next token to process If the input is invalid, then *ctx remains unchanged.

◆ css__ident_list_or_string_to_string()

css_error css__ident_list_or_string_to_string ( css_language *  c,
const parserutils_vector *  vector,
int32_t *  ctx,
bool(*)(css_language *c, const css_token *ident)  reserved,
lwc_string **  result 
)

Create a string from a list of IDENT/S tokens if the next token is IDENT or references the next token's string if it is a STRING

Parameters
cParsing context
vectorVector containing tokens
ctxVector iteration context
reservedCallback to determine if an identifier is reserved
resultPointer to location to receive resulting string
Returns
CSS_OK on success, appropriate error otherwise.

Post condition: *ctx is updated with the next token to process If the input is invalid, then *ctx remains unchanged.

The resulting string's reference is passed to the caller

◆ css__ident_list_to_string()

css_error css__ident_list_to_string ( css_language *  c,
const parserutils_vector *  vector,
int32_t *  ctx,
bool(*)(css_language *c, const css_token *ident)  reserved,
lwc_string **  result 
)

Create a string from a list of IDENT/S tokens

Parameters
cParsing context
vectorVector containing tokens
ctxVector iteration context
reservedCallback to determine if an identifier is reserved
resultPointer to location to receive resulting string
Returns
CSS_OK on success, appropriate error otherwise.

Post condition: *ctx is updated with the next token to process If the input is invalid, then *ctx remains unchanged.

The resulting string's reference is passed to the caller

◆ css__parse_border_side()

css_error css__parse_border_side ( css_language *  c,
const parserutils_vector *  vector,
int32_t *  ctx,
css_style *  result,
enum border_side_e  side 
)

Parse border-{top,right,bottom,left} shorthand

Parameters
cParsing context
vectorVector of tokens to process
ctxPointer to vector iteration context
sideThe side we're parsing for
resultPointer to location to receive resulting style
Returns
CSS_OK on success, CSS_NOMEM on memory exhaustion, CSS_INVALID if the input is not valid

Post condition: *ctx is updated with the next token to process If the input is invalid, then *ctx remains unchanged.

◆ css__parse_colour_specifier()

css_error css__parse_colour_specifier ( css_language *  c,
const parserutils_vector *  vector,
int32_t *  ctx,
uint16_t *  value,
uint32_t *  result 
)

Parse a colour specifier

Parameters
cParsing context
vectorVector of tokens to process
ctxPointer to vector iteration context
valuePointer to location to receive value
resultPointer to location to receive result (AARRGGBB)
Returns
CSS_OK on success, CSS_INVALID if the input is invalid

Post condition: *ctx is updated with the next token to process If the input is invalid, then *ctx remains unchanged.

◆ css__parse_hash_colour()

css_error css__parse_hash_colour ( lwc_string *  data,
uint32_t *  result 
)

Parse a hash colour (#rgb or rrggbb)

Parameters
dataPointer to colour string
resultPointer to location to receive result (AARRGGBB)
Returns
CSS_OK on success, CSS_INVALID if the input is invalid

◆ css__parse_list_style_type_value()

css_error css__parse_list_style_type_value ( css_language *  c,
const css_token *  ident,
uint16_t *  value 
)

Parse list-style-type value

Parameters
cParsing context
identIdentifier to consider
valuePointer to location to receive value
Returns
CSS_OK on success, CSS_INVALID if the input is not valid

◆ css__parse_named_colour()

css_error css__parse_named_colour ( css_language *  c,
lwc_string *  data,
uint32_t *  result 
)

Parse a named colour

Parameters
cParsing context
dataColour name string
resultPointer to location to receive result
Returns
CSS_OK on success, CSS_INVALID if the colour name is unknown

◆ css__parse_unit_keyword()

css_error css__parse_unit_keyword ( const char *  ptr,
size_t  len,
uint32_t *  unit 
)

Parse a unit keyword

Parameters
ptrPointer to keyword string
lenLength, in bytes, of string
unitPointer to location to receive computed unit
Returns
CSS_OK on success, CSS_INVALID on encountering an unknown keyword

◆ css__parse_unit_specifier()

css_error css__parse_unit_specifier ( css_language *  c,
const parserutils_vector *  vector,
int32_t *  ctx,
uint32_t  default_unit,
css_fixed *  length,
uint32_t *  unit 
)

Parse a unit specifier

Parameters
cParsing context
vectorVector of tokens to process
ctxPointer to current vector iteration context
default_unitThe default unit to use if none specified
lengthPointer to location to receive length
unitPointer to location to receive unit
Returns
CSS_OK on success, CSS_INVALID if the tokens do not form a valid unit

Post condition: *ctx is updated with the next token to process If the input is invalid, then *ctx remains unchanged.