1 #ifndef __XEXPER_TYPES_H__
2 #define __XEXPER_TYPES_H__
5 #include <libxml/tree.h>
11 * @ns: the namespace to which @function belongs, or %NULL
12 * @function: the function to be invoked
13 * @bindings: (element-type XexprBinding): the pre-bound arguments
14 * @constants: (element-type XexprConstant): the other arguments
16 * A structure describing the invocation of a function.
18 typedef struct xexpr_invocation {
27 * @args: (element-type utf8): the parameter names
28 * @constants: (element-type XexprConstant): the constants
29 * which will be evaluated when the function is invoked
31 * A structure describing the definition of a function.
33 typedef struct xexpr_function {
38 typedef struct xexpr_constant XexprConstant;
43 * @value: the expresion bound to @id
45 * A structure describing the binding of a value to a name.
47 typedef struct xexpr_binding {
54 * @XEXPR_TYPE_INVOCATION: a function invocation
55 * @XEXPR_TYPE_FUNCTION: a function definition
56 * @XEXPR_TYPE_STRING: a string
57 * @XEXPR_TYPE_INTEGER: an integer
58 * @XEXPR_TYPE_NUMBER: a floating-point number
60 * Enum values for the type, to specify the type of expression.
63 XEXPR_TYPE_INVOCATION=1,
72 * @type: the type of expression
73 * @u: type-specific parameters
75 * A structure describing an XEXPR expression
77 struct xexpr_constant {
80 XexprInvocation *invocation;
81 XexprFunction *function;
83 long long int integer;
90 * @function: the name of the function to which the environment belongs,
91 * or %NULL if this is the outermost environment
92 * @outer: the next environment in the chain from innermost to outermost,
93 * or %NULL if this is the outermost environment
94 * @bindings: (element-type XexprBinding): the variables set in this environment
96 * A structure describing an XEXPR environment
98 typedef struct xexpr_environment {
103 struct xexpr_environment *outer;
109 * @constants: (element-type XexprConstant): the constants that make up this
111 * @environment: the innermost environment
113 * A structure describing an XEXPR expression
115 typedef struct xexpr {
120 XexprEnvironment *environment;
125 * @ns: the namespace of the extension
126 * @function_evaluate: evaluates functions defined in the extension
128 * A structure describing an XEXPR extension
130 typedef struct xexpr_extension {
132 XexprConstant *(*function_evaluate)(Xexpr *xexpr,const char *ns,
133 const char *id,GSList *bindings,GSList *args,GError **err);
136 XexprConstant *xexpr_new_string(const char *s,gssize len);
137 XexprConstant *xexpr_new_string_take_ownership(char *s);
138 XexprConstant *xexpr_new_integer(long long int integer);
139 XexprConstant *xexpr_new_number(double number);
140 XexprConstant *xexpr_new_invocation(const char *ns,const char *function,
141 GSList *bindings,GSList *constants);
142 XexprConstant *xexpr_new_invocation_take_ownership(char *ns,char *function,
143 GSList *bindings,GSList *constants);
144 XexprConstant *xexpr_new_function_take_ownership(GSList *args,
146 XexprConstant *xexpr_new_function(GSList *args,GSList *constants);
147 XexprConstant *xexpr_constant_dup(XexprConstant *constant);
148 void xexpr_constant_free(XexprConstant *constant);
150 void xexpr_binding_free(XexprBinding *binding);
152 XexprConstant *xexpr_bindings_get(GSList *bindings,const char *id);
153 gboolean xexpr_bindings_set(GSList *bindings,const char *id,
154 XexprConstant *value);
155 GSList *xexpr_bindings_new(GSList *bindings,const char *id,
156 XexprConstant *value);
157 GSList *xexpr_bindings_dup(GSList *bindings);
159 Xexpr *xexpr_new(void);
160 Xexpr *xexpr_sub(Xexpr *xexpr);
161 void xexpr_var_new(Xexpr *xexpr,const char *id,XexprConstant *value);
162 void xexpr_var_set(Xexpr *xexpr,const char *id,XexprConstant *value);
163 XexprConstant *xexpr_var_get(Xexpr *xexpr,const char *id);
164 void xexpr_start_tracing(Xexpr *xexpr,const char *id);
165 gboolean xexpr_is_tracing(Xexpr *xexpr,const char *id);
166 void xexpr_free(Xexpr *xexpr);
167 XexprEnvironment *xexpr_get_environment(Xexpr *xexpr);
168 void xexpr_set_constants(Xexpr *xexpr,GSList *constants);
169 void xexpr_set_constants_take_ownership(Xexpr *xexpr,GSList *constants);
171 void xexpr_environment_foreach(XexprEnvironment *environment,GTraverseFunc func,
176 #endif /* __XEXPER_TYPES_H__ */