Data Structures | |
| struct | PosExpr |
| Type and value of an expression in a parsed sequence. More... | |
| struct | _MetaDrawSpec |
| A computed expression in our simple vector drawing language. More... | |
Typedefs | |
| typedef struct _MetaDrawSpec | MetaDrawSpec |
Enumerations | |
| enum | PosExprType { POS_EXPR_INT, POS_EXPR_DOUBLE, POS_EXPR_OPERATOR } |
| The type of a PosExpr: either integer, double, or an operation. More... | |
Functions | |
| static gboolean | pos_eval_get_variable (PosToken *t, int *result, const MetaPositionExprEnv *env, GError **err) |
| There is a predefined set of variables which can appear in an expression. | |
| static gboolean | pos_eval_helper (PosToken *tokens, int n_tokens, const MetaPositionExprEnv *env, PosExpr *result, GError **err) |
| Evaluates a sequence of tokens within a particular environment context, and returns the current value. | |
| static gboolean | pos_eval (MetaDrawSpec *spec, const MetaPositionExprEnv *env, int *val_p, GError **err) |
| Evaluates an expression. | |
This is the parser used for that language.
| typedef struct _MetaDrawSpec MetaDrawSpec |
| enum PosExprType |
| static gboolean pos_eval | ( | MetaDrawSpec * | spec, | |
| const MetaPositionExprEnv * | env, | |||
| int * | val_p, | |||
| GError ** | err | |||
| ) | [static] |
Evaluates an expression.
| spec | The expression to evaluate. | |
| env | The environment context to evaluate the expression in. | |
| [out] | val_p | The integer value of the expression; if the expression is of type float, this will be rounded. If we return FALSE because the expression is invalid, this will be zero. |
| [out] | err | The error, if anything went wrong. |
Definition at line 2439 of file theme.c.
References PosExpr::d, PosExpr::double_val, FALSE, PosExpr::int_val, _MetaDrawSpec::n_tokens, pos_eval_helper(), POS_EXPR_DOUBLE, POS_EXPR_INT, POS_EXPR_OPERATOR, _MetaDrawSpec::tokens, TRUE, and PosExpr::type.
Referenced by meta_draw_spec_new(), meta_parse_position_expression(), and meta_parse_size_expression().
| static gboolean pos_eval_get_variable | ( | PosToken * | t, | |
| int * | result, | |||
| const MetaPositionExprEnv * | env, | |||
| GError ** | err | |||
| ) | [static] |
There is a predefined set of variables which can appear in an expression.
Here we take a token representing a variable, and return the current value of that variable in a particular environment. (The value is always an integer.)
There are supposedly some circumstances in which this function can be called from outside Metacity, in which case env->theme will be NULL, and therefore we can't use it to find out quark values, so we do the comparison using strcmp, which is slower.
| t | The token representing a variable | |
| [out] | result | The value of that variable; not set if the token did not represent a known variable |
| env | The environment within which t should be evaluated | |
| [out] | err | set to the problem if there was a problem |
Definition at line 2156 of file theme.c.
References _, _MetaPositionExprEnv::bottom_height, PosToken::d, FALSE, _MetaRectangle::height, _MetaPositionExprEnv::icon_height, _MetaPositionExprEnv::icon_width, _MetaPositionExprEnv::left_width, META_THEME_ERROR, META_THEME_ERROR_UNKNOWN_VARIABLE, _MetaPositionExprEnv::mini_icon_height, _MetaPositionExprEnv::mini_icon_width, _MetaPositionExprEnv::object_height, _MetaPositionExprEnv::object_width, _MetaTheme::quark_bottom_height, _MetaTheme::quark_height, _MetaTheme::quark_icon_height, _MetaTheme::quark_icon_width, _MetaTheme::quark_left_width, _MetaTheme::quark_mini_icon_height, _MetaTheme::quark_mini_icon_width, _MetaTheme::quark_object_height, _MetaTheme::quark_object_width, _MetaTheme::quark_right_width, _MetaTheme::quark_title_height, _MetaTheme::quark_title_width, _MetaTheme::quark_top_height, _MetaTheme::quark_width, _MetaPositionExprEnv::rect, _MetaPositionExprEnv::right_width, _MetaPositionExprEnv::theme, _MetaPositionExprEnv::title_height, _MetaPositionExprEnv::title_width, _MetaPositionExprEnv::top_height, TRUE, and _MetaRectangle::width.
Referenced by pos_eval_helper().
| static gboolean pos_eval_helper | ( | PosToken * | tokens, | |
| int | n_tokens, | |||
| const MetaPositionExprEnv * | env, | |||
| PosExpr * | result, | |||
| GError ** | err | |||
| ) | [static] |
Evaluates a sequence of tokens within a particular environment context, and returns the current value.
May recur if parantheses are found.
| tokens | A list of tokens to evaluate. | |
| n_tokens | How many tokens are in the list. | |
| env | The environment context in which to evaluate the expression. | |
| [out] | result | The current value of the expression |
Definition at line 2262 of file theme.c.
References _, PosToken::d, PosExpr::d, do_operations(), PosExpr::double_val, FALSE, PosExpr::int_val, MAX_EXPRS, META_THEME_ERROR, META_THEME_ERROR_BAD_PARENS, META_THEME_ERROR_FAILED, PosExpr::operator, pos_eval_get_variable(), POS_EXPR_DOUBLE, POS_EXPR_INT, POS_EXPR_OPERATOR, POS_TOKEN_CLOSE_PAREN, POS_TOKEN_DOUBLE, POS_TOKEN_INT, POS_TOKEN_OPEN_PAREN, POS_TOKEN_OPERATOR, POS_TOKEN_VARIABLE, TRUE, PosExpr::type, and PosToken::type.
Referenced by pos_eval().
1.5.5