| #define | XB_TYPE_MACHINE |
| struct | XbMachineClass |
| enum | XbMachineDebugFlags |
| enum | XbMachineParseFlags |
| XbMachine |
gboolean (*XbMachineOpcodeFixupFunc) (XbMachine *self,XbStack *opcodes,gpointer user_data,GError **error);
gboolean (*XbMachineTextHandlerFunc) (XbMachine *self,XbStack *opcodes,const gchar *text,gboolean *handled,gpointer user_data,GError **error);
gboolean (*XbMachineMethodFunc) (XbMachine *self,XbStack *stack,gboolean *result_unused,gpointer exec_data,gpointer user_data,GError **error);
void xb_machine_set_debug_flags (XbMachine *self,XbMachineDebugFlags flags);
Sets the debug level of the virtual machine.
Since: 0.1.1
XbStack * xb_machine_parse (XbMachine *self,const gchar *text,gssize text_len,GError **error);
xb_machine_parse is deprecated and should not be used in newly-written code.
Parses an XPath predicate. Not all of XPath 1.0 or XPath 1.0 is supported,
and new functions and mnemonics can be added using xb_machine_add_method()
and xb_machine_add_text_handler().
Since: 0.1.1
XbStack * xb_machine_parse_full (XbMachine *self,const gchar *text,gssize text_len,XbMachineParseFlags flags,GError **error);
Parses an XPath predicate. Not all of XPath 1.0 or XPath 1.0 is supported,
and new functions and mnemonics can be added using xb_machine_add_method()
and xb_machine_add_text_handler().
self |
||
text |
predicate to parse, e.g. |
|
text_len |
length of |
|
flags |
||
error |
Since: 0.1.4
gboolean xb_machine_run (XbMachine *self,XbStack *opcodes,gboolean *result,gpointer exec_data,GError **error);
xb_machine_run has been deprecated since version 0.3.0 and should not be used in newly-written code.
Use xb_machine_run_with_bindings() instead.
Runs a set of opcodes on the virtual machine.
It is safe to call this function from a different thread to the one that created the XbMachine.
self |
||
opcodes |
a XbStack of opcodes |
|
result |
return status after running |
[out] |
exec_data |
per-run user data that is passed to all the XbMachineMethodFunc functions |
|
error |
Since: 0.1.1
gboolean xb_machine_run_with_bindings (XbMachine *self,XbStack *opcodes,XbValueBindings *bindings,gboolean *result,gpointer exec_data,GError **error);
Runs a set of opcodes on the virtual machine, using the bound values given in
bindings
to substitute for bound opcodes.
It is safe to call this function from a different thread to the one that created the XbMachine.
self |
||
opcodes |
a XbStack of opcodes |
|
bindings |
values bound to opcodes of type
|
[nullable][transfer none] |
result |
return status after running |
[out] |
exec_data |
per-run user data that is passed to all the XbMachineMethodFunc functions |
|
error |
Since: 0.3.0
void xb_machine_add_opcode_fixup (XbMachine *self,const gchar *opcodes_sig,XbMachineOpcodeFixupFunc fixup_cb,gpointer user_data,GDestroyNotify user_data_free);
Adds an opcode fixup. Fixups can be used to optimize the stack of opcodes or to add support for a nonstandard feature, for instance supporting missing attributes to functions.
Since: 0.1.1
void xb_machine_add_text_handler (XbMachine *self,XbMachineTextHandlerFunc handler_cb,gpointer user_data,GDestroyNotify user_data_free);
Adds a text handler. This allows the virtual machine to support nonstandard encoding or shorthand mnemonics for standard functions.
Since: 0.1.1
void xb_machine_add_method (XbMachine *self,const gchar *name,guint n_opcodes,XbMachineMethodFunc method_cb,gpointer user_data,GDestroyNotify user_data_free);
Adds a new function to the virtual machine. Registered functions can then be used as methods.
The method_cb
must not modify the stack it’s passed unless it’s going to
succeed. In particular, if a method call is not optimisable, it must not
modify the stack it’s passed.
You need to add a custom function using xb_machine_add_method() before using
methods that may reference it, for example xb_machine_add_opcode_fixup().
Since: 0.1.1
void xb_machine_add_operator (XbMachine *self,const gchar *str,const gchar *name);
Adds a new operator to the virtual machine. Operators can then be used
instead of explicit methods like .eq()
You need to add a custom operator using xb_machine_add_operator() before
using xb_machine_parse(). Common operators like <= and = are built-in
and do not have to be added manually.
Since: 0.1.1
gboolean xb_machine_opcode_func_init (XbMachine *self,XbOpcode *opcode,const gchar *func_name);
Initialises a stack allocated XbOpcode for a registered function.
Some standard functions are registered by default, for instance eq or ge.
Other functions have to be added using xb_machine_add_method().
Since: 0.2.0
gboolean xb_machine_stack_pop (XbMachine *self,XbStack *stack,XbOpcode *opcode_out,GError **error);
Pops an opcode from the stack.
Since: 0.2.0
gboolean xb_machine_stack_push (XbMachine *self,XbStack *stack,XbOpcode **opcode_out,GError **error);
Pushes a new empty opcode onto the end of the stack. A pointer to the opcode
is returned in opcode_out
so that the caller can initialise it.
If the stack reaches its maximum size, G_IO_ERROR_NO_SPACE will be returned.
Since: 0.2.0
gboolean xb_machine_stack_push_text (XbMachine *self,XbStack *stack,const gchar *str,GError **error);
Adds a text literal to the stack, copying str
.
Errors are as for xb_machine_stack_push().
Since: 0.2.0
gboolean xb_machine_stack_push_text_static (XbMachine *self,XbStack *stack,const gchar *str,GError **error);
Adds static text literal to the stack.
Errors are as for xb_machine_stack_push().
Since: 0.2.0
gboolean xb_machine_stack_push_text_steal (XbMachine *self,XbStack *stack,gchar *str,GError **error);
Adds a stolen text literal to the stack.
Errors are as for xb_machine_stack_push().
Since: 0.2.0
gboolean xb_machine_stack_push_integer (XbMachine *self,XbStack *stack,guint32 val,GError **error);
Adds an integer literal to the stack.
Errors are as for xb_machine_stack_push().
Since: 0.2.0
void xb_machine_set_stack_size (XbMachine *self,guint stack_size);
Sets the maximum stack size used for the machine.
The stack size will be affective for new jobs started with xb_machine_run()
and xb_machine_parse().
Since: 0.1.3