1 /* Fo 2 * fo-expr-eval.h: XSL expression language evaluation module 3 * 4 * Copyright (C) 1998-2002 Daniel Veillard. 5 * Copyright (C) 2001-2002 Sun Microsystems. 6 * All Rights Reserved. 7 * 8 * Based on an XSL expression language evaluator that was based on the 9 * 'XML Path Language implementation' in 'xpath.c' from libxml2 by 10 * Daniel Veillard. 11 * Copyright (C) 2007 Menteith Consulting Ltd 12 * 13 * !See COPYING for the status of this software. 14 */ 15 16 #ifndef __FO_EXPR_EVAL_H__ 17 #define __FO_EXPR_EVAL_H__ 18 19 #include <libfo/fo-utils.h> 20 #include <libfo/property/fo-property.h> 21 #include <libfo/fo-context.h> 22 #include <libfo/datatype/fo-datatype.h> 23 24 G_BEGIN_DECLS 25 26 typedef struct _FoExprEnv FoExprEnv; 27 typedef GSList FoExprEnvList; 28 typedef struct _FoExprContext FoExprContext; 29 typedef FoDatatype* (* FoExprFunc) (FoExprContext *context, 30 gint nargs); 31 32 #define FO_EXPR_ERROR fo_expr_error_quark () 33 GQuark fo_expr_error_quark (void); 34 35 typedef enum 36 { 37 FO_EXPR_ERROR_FAILED, 38 FO_EXPR_ERROR_NULL_RESULT, 39 FO_EXPR_ERROR_ERROR_RESULT, 40 FO_EXPR_ERROR_EXTRA_STACK, 41 FO_EXPR_ERROR_EXTRA_EXPR 42 } FoExprError; 43 44 #define FO_EXPR_EVAL_ERROR fo_expr_eval_error_quark () 45 GQuark fo_expr_eval_error_quark (void); 46 47 typedef enum 48 { 49 FO_EXPR_EVAL_ERROR_FAILED, /* Expression evaluation failed */ 50 FO_EXPR_EVAL_ERROR_UNFINISHED_LITERAL, 51 FO_EXPR_EVAL_ERROR_START_LITERAL, 52 FO_EXPR_EVAL_ERROR_EXPR_ERROR, 53 FO_EXPR_EVAL_ERROR_UNKNOWN_FUNC, 54 FO_EXPR_EVAL_ERROR_INVALID_ARITY, 55 FO_EXPR_EVAL_ERROR_INVALID_TYPE, 56 FO_EXPR_EVAL_ERROR_NOT_INHERITED, 57 FO_EXPR_EVAL_ERROR_INVALID_PROPERTY, 58 FO_EXPR_EVAL_ERROR_FUNCTION_INVALID_PROPERTY, 59 FO_EXPR_EVAL_ERROR_NOT_TABLE_CELL_OR_DESCENDANT, 60 FO_EXPR_EVAL_ERROR_NO_TABLE_CELL_COLUMN, 61 FO_EXPR_EVAL_ERROR_NOT_LIST_BLOCK_OR_DESCENDANT, 62 FO_EXPR_EVAL_ERROR_NOT_TABLE_COLUMN, 63 FO_EXPR_EVAL_ERROR_NOT_COLUMN_WIDTH, 64 FO_EXPR_EVAL_ERROR_NOT_FIXED_METHOD, 65 FO_EXPR_EVAL_ERROR_COLOR_DECL, 66 FO_EXPR_EVAL_ERROR_UNKNOWN_OPERATOR, 67 FO_EXPR_EVAL_ERROR_FUNC_RETURN_NULL, 68 FO_EXPR_EVAL_ERROR_CANNOT_INHERIT, 69 FO_EXPR_EVAL_ERROR_NO_RESOLVE_PERCENT_FUNC, 70 FO_EXPR_EVAL_ERROR_UNFINISHED_URL, 71 FO_EXPR_EVAL_ERROR_LAST 72 } FoExprEvalError; 73 74 extern const gchar *fo_expr_eval_error_messages[FO_EXPR_EVAL_ERROR_LAST]; 75 76 FoDatatype* fo_expr_eval (const gchar *string, 77 const gchar *property_name, 78 FoResolveEnumFunc resolve_enum_func, 79 FoResolvePercentFunc resolve_percent_func, 80 const FoProperty *font_size_prop, 81 const FoFo *current_fo, 82 const FoContext *fo_context, 83 const FoExprEnvList *env_list, 84 GError **error); 85 86 FoDatatype* fo_expr_padding_eval (const gchar *string, 87 const gchar *property_name, 88 FoResolveEnumFunc resolve_enum_func, 89 FoResolvePercentFunc resolve_percent_func, 90 const FoProperty *font_size_prop, 91 const FoFo *current_fo, 92 const FoContext *fo_context, 93 const FoExprEnvList *env_list, 94 GError **error); 95 96 FoDatatype* fo_expr_border_color_eval (const gchar *string, 97 const gchar *property_name, 98 FoResolveEnumFunc resolve_enum_func, 99 FoResolvePercentFunc resolve_percent_func, 100 const FoProperty *font_size_prop, 101 const FoFo *current_fo, 102 const FoContext *fo_context, 103 const FoExprEnvList *env_list, 104 GError **error); 105 106 FoDatatype * fo_expr_border_style_eval (const gchar *string, 107 const gchar *property_name, 108 FoResolveEnumFunc resolve_enum_func, 109 FoResolvePercentFunc resolve_percent_func, 110 const FoProperty *font_size_prop, 111 const FoFo *current_fo, 112 const FoContext *fo_context, 113 const FoExprEnvList *env_list, 114 GError **error); 115 116 FoDatatype * fo_expr_wsc_eval (const gchar *string, 117 const gchar *property_name, 118 FoResolveEnumFunc resolve_enum_func, 119 FoResolvePercentFunc resolve_percent_func, 120 const FoProperty *font_size_prop, 121 const FoFo *current_fo, 122 const FoContext *fo_context, 123 const FoExprEnvList *env_list, 124 GError **error); 125 126 FoDatatype * fo_expr_eval_new_error (FoExprContext *context, 127 FoExprEvalError error_type); 128 FoDatatype * fo_expr_eval_propagate_error (FoExprContext *context, 129 GError *error); 130 131 void fo_expr_context_push_stack (FoExprContext *context, 132 FoDatatype *datatype); 133 FoDatatype * fo_expr_context_pop_stack (FoExprContext *context); 134 FoDatatype * fo_expr_context_peek_stack (FoExprContext *context); 135 gboolean fo_expr_context_stack_is_empty (FoExprContext *context); 136 FoExprFunc fo_expr_context_get_func (FoExprContext *context, 137 const gchar *name); 138 void fo_expr_context_debug_dump_stack (FoExprContext *context); 139 140 FoExprEnv * fo_expr_env_new (void); 141 FoExprEnv * fo_expr_env_register_func (FoExprEnv *env, 142 const gchar *name, 143 FoExprFunc func); 144 FoExprFunc fo_expr_env_get_func (FoExprEnv *env, 145 const gchar *name); 146 147 FoExprEnvList * fo_expr_env_list_new (void); 148 void fo_expr_env_list_free (FoExprEnvList *env_list); 149 FoExprEnvList * fo_expr_env_list_prepend (FoExprEnvList *env_list, 150 FoExprEnv *env); 151 FoExprFunc fo_expr_env_list_get_func (const FoExprEnvList *env_list, 152 const gchar *name); 153 154 G_END_DECLS 155 156 #endif /* !__FO_EXPR_EVAL_H__ */ 157