Next: , Previous: , Up: Functions   [Index]

3.4.2 Defining Function Sets

The expression evaluator is introduced the functions set via a look up function and a look up context. Every time a function identifier is picked up while parsing the expression the evaluator calls the look up function supplying it the retrieved name, its length and the look up context. If the look up function is successful in identifying the function, the reference to the function definition is expected.

The look up function and the look up context are specified via the struct x1f4_e4_type, as function_set.get and function_set.context, respectively.

See struct x1f4_e4_type.

The C type of the look up function is:

int (*)(const char *, unsigned, const void *,
        const struct x1f4_function_type **)

When called it is passed the retrieved identifier as the first argument and its length as the second. Note the identifier is not a null terminated string and no more the specified number of character should be interpreted.

The look up function is passed the look up context as the third argument.

If the look up function fails to identify the function it is expected to return a non null value. Otherwise, the reference to the function definition for which address has been passed as the fourth argument is expected to be set.

The C type of the otherwise uninterpreted look up context is const void *.

Function definitions may be used up to parsed expression destruction, thus the function definition references must be valid for as long as the result of expression parsing is used.