9 #ifndef __AFW_FUNCTION_H__
10 #define __AFW_FUNCTION_H__
44 #define AFW_FUNCTION_EXECUTE_STANDARD_POLYMORPHIC_FUNCTION_HANDLING NULL
159 #define AFW_FUNCTION_ARGV(A_N) \
160 ((A_N <= x->argc) ? x->argv[A_N] : NULL)
172 #define AFW_FUNCTION_ASSERT_PARAMETER_COUNT_IS(n) \
174 if ((x->argc) != (n)) {\
175 AFW_THROW_ERROR_Z(general, "Expecting " #n " parameters.", x->xctx);\
189 #define AFW_FUNCTION_ASSERT_PARAMETER_COUNT_MIN(n) \
191 if (x->argc < (n)) {\
192 AFW_THROW_ERROR_Z(general, "Expecting at least " #n " parameters.", x->xctx);\
206 #define AFW_FUNCTION_ASSERT_PARAMETER_COUNT_MAX(n) \
208 if (x->argc > (n)) {\
209 AFW_THROW_ERROR_Z(general, "Expecting no more than " #n " parameters.", x->xctx);\
223 #define AFW_FUNCTION_ASSERT_VALUE_IS_UTF8(A_VALUE) \
224 if (!(A_VALUE) || !afw_utf8_equal( \
225 &afw_value_get_data_type(((const afw_value_t *)A_VALUE), x->xctx)->cType, \
226 &afw_s_afw_utf8_t)) \
228 AFW_THROW_ERROR_Z(arg_error, \
229 "Value's data type not supported for this function", x->xctx); \
242 #define AFW_FUNCTION_PARAMETER_IS_PRESENT(A_N) \
243 (AFW_FUNCTION_ARGV(A_N) != NULL)
261 #define AFW_FUNCTION_EVALUATE_DATA_TYPE_PARAMETER(A_RESULT, A_N, A_TYPE) \
262 A_RESULT = (const afw_value_##A_TYPE##_t *) \
263 afw_function_evaluate_parameter(x, A_N, afw_data_type_##A_TYPE)
279 #define AFW_FUNCTION_EVALUATE_PARAMETER(A_RESULT, A_N) \
280 A_RESULT = afw_function_evaluate_parameter(x, A_N, NULL)
295 #define AFW_FUNCTION_EVALUATE_REQUIRED_PARAMETER(A_RESULT, A_N) \
296 A_RESULT = afw_function_evaluate_required_parameter(x, A_N, NULL);
309 #define AFW_FUNCTION_EVALUATE_REQUIRED_CONDITION_PARAMETER(A_RESULT, A_N) \
310 A_RESULT = (const afw_value_boolean_t *) \
311 afw_function_evaluate_required_parameter(x, A_N, NULL); \
312 if (!afw_value_is_boolean(A_RESULT)) \
313 AFW_THROW_ERROR_FZ(arg_error, xctx, \
314 "Condition must be boolean (parameter %d)", (A_N))
328 #define AFW_FUNCTION_EVALUATE_REQUIRED_DATA_TYPE_PARAMETER(A_RESULT, A_N, A_TYPE) \
329 A_RESULT = (const afw_value_##A_TYPE##_t *) \
330 afw_function_evaluate_required_parameter(x, A_N, afw_data_type_##A_TYPE)
341 #define AFW_FUNCTION_SOURCE_LOCATION \
342 afw_compile_source_location_of_value( \
343 (const afw_value_t *)x->self, x->p, x->xctx)
355 afw_function_evaluate_function_parameter(
373 afw_function_evaluate_whitespace_parameter(
AFW_DEFINE(const afw_object_t *)
#define AFW_BEGIN_DECLARES
#define AFW_DECLARE(type)
Declare a public afw function.
Interfaceafw_interface header.
apr_size_t afw_size_t
size_t.
afw_function_evaluate_required_parameter(afw_function_execute_t *x, afw_size_t parameter_number, const afw_data_type_t *data_type)
Evaluate an required parameter and convert if necessary.
const afw_value_t * afw_function_evaluate_parameter_with_type(const afw_value_t *value, afw_size_t parameter_number, const afw_value_type_t *type, const afw_pool_t *p, afw_xctx_t *xctx)
Evaluate a parameter with dataTypeParameter.
const afw_value_t * afw_function_evaluate_parameter(afw_function_execute_t *x, afw_size_t parameter_number, const afw_data_type_t *data_type)
Evaluate a parameter and convert if necessary.
Interface afw_data_type public struct.
const afw_value_function_definition_t * divide_operator_function
Divide operator function.
const afw_value_function_definition_t * or_operator_function
Or operator function.
const afw_value_function_definition_t * less_than_or_equal_to_function
Less than or equal to operator function.
const afw_value_function_definition_t * modulus_operator_function
Modulus operator function.
const afw_value_function_definition_t * multiply_operator_function
Multiply operator function.
const afw_value_function_definition_t * add_operator_function
Add operator function.
const afw_value_function_definition_t * unary_not_operator_function
Not operator function.
const afw_value_function_definition_t * exponentiation_operator_function
Exponentiation operator function.
const afw_value_function_definition_t * subtract_operator_function
Subtract operator function.
const afw_value_function_definition_t * less_than_operator_function
Less than operator function.
const afw_value_function_definition_t * negative_operator_function
Negative operator function.
const afw_value_function_definition_t * not_equal_to_operator_function
Not equal to operator function.
const afw_value_function_definition_t * and_operator_function
And operator function.
const afw_value_function_definition_t * greater_than_operator_function
Greater than operator function.
const afw_value_function_definition_t * greater_than_or_equal_to_function
Greater than or equal to operator function.
const afw_value_function_definition_t * equal_to_operator_function
Equal to operator function.
Function execute parameter.
const afw_value_t *const * argv
This is the function parameters.
afw_xctx_t * xctx
The execution context (xctx) of caller.
const afw_pool_t * p
Pool for result.
const afw_data_type_t * data_type
This is the <dataType> for data type functions or NULL.
afw_size_t argc
This is the argv count not counting argv[0].
const afw_value_t * first_arg
This is the evaluated first parameter if data type function.
Interface afw_pool public struct.
NFC normalized UTF-8 string.
Struct for function value.
Interface afw_value public struct.
Type meta (data type, data type parameters, and value meta object.
Interface afw_xctx public struct.