9 #ifndef __AFW_VALUE_H__
10 #define __AFW_VALUE_H__
330 #define afw_value_undefined NULL
363 #define afw_value_for_boolean(variable) (variable) \
375 #define AFW_VALUE_UNDECORATE(a_value) \
377 if ((a_value)->inf == &afw_value_compiled_value_inf) { \
378 a_value = ((const afw_value_compiled_value_t *)a_value)->root_value; \
380 if ((a_value)->inf == &afw_value_annotated_inf) { \
381 a_value = ((const afw_value_annotated_t *)a_value)->value; \
422 #define afw_value_is_nullish(A_VALUE) \
425 (A_VALUE)->inf->fully_evaluated_data_type == afw_data_type_null \
438 #define afw_value_is_undefined(A_VALUE) (!A_VALUE)
458 #define AFW_VALUE_TYPE_ID(A_VALUE) \
459 &(A_VALUE)->inf->rti.implementation_id
468 #define afw_value_is_annotated(A_VALUE) \
471 (A_VALUE)->inf == &afw_value_annotated_inf \
481 #define afw_value_is_defined_and_evaluated(A_VALUE) \
484 (A_VALUE)->inf->fully_evaluated_data_type \
494 #define afw_value_is_undefined_or_evaluated(A_VALUE) \
497 (A_VALUE)->inf->fully_evaluated_data_type \
520 #define afw_value_is_assignment_target(A_VALUE) \
523 (A_VALUE)->inf == &afw_value_assignment_target_inf \
533 #define afw_value_is_block(A_VALUE) \
536 (A_VALUE)->inf == &afw_value_block_inf \
546 #define afw_value_is_call(A_VALUE) \
549 (A_VALUE)->inf == &afw_value_call_inf \
559 #define afw_value_is_call_built_in_function(A_VALUE) \
562 (A_VALUE)->inf == &afw_value_call_built_in_function_inf \
572 #define afw_value_is_any_call(A_VALUE) \
576 (A_VALUE)->inf == &afw_value_call_inf || \
577 (A_VALUE)->inf == &afw_value_call_built_in_function_inf \
588 #define afw_value_is_compiled_value(A_VALUE) \
591 (A_VALUE)->inf == &afw_value_compiled_value_inf \
601 #define afw_value_is_expression_definition(A_VALUE) \
604 (A_VALUE)->inf == &afw_value_expression_definition_inf \
614 #define afw_value_is_function_definition(A_VALUE) \
617 (A_VALUE)->inf == &afw_value_function_definition_inf \
627 #define afw_value_is_function_thunk(A_VALUE) \
630 (A_VALUE)->inf == &afw_value_function_thunk_inf \
640 #define afw_value_is_list_expression(A_VALUE) \
643 (A_VALUE)->inf == &afw_value_list_expression_inf \
653 #define afw_value_is_object_expression(A_VALUE) \
656 (A_VALUE)->inf == &afw_value_object_expression_inf \
666 #define afw_value_is_script_function(A_VALUE) \
669 (A_VALUE)->inf == &afw_value_script_function_definition_inf \
679 #define afw_value_is_qualified_variable_reference(A_VALUE) \
682 (A_VALUE)->inf == &afw_value_qualified_variable_reference_inf \
692 #define afw_value_is_reference_by_key(A_VALUE) \
695 (A_VALUE)->inf == &afw_value_reference_by_key_inf \
705 #define afw_value_is_template_definition(A_VALUE) \
708 (A_VALUE)->inf == &afw_value_template_definition_inf \
718 #define afw_value_is_variable_reference(A_VALUE) \
721 (A_VALUE)->inf == &afw_value_variable_reference_inf \
726 #define AFW_VALUE_ASSERT_IS(A_VALUE, A_TYPE_ID, A_SCOPE) \
727 if (!A_VALUE || (A_VALUE)->inf != &afw_value_ ## A_TYPE_ID ## _inf) \
728 AFW_THROW_ERROR_Z(cast_error, "Expecting " #A_TYPE_ID, A_SCOPE)
739 #define afw_value_quick_data_type(A_VALUE) \
740 ((A_VALUE)->inf->data_type)
751 #define afw_value_get_quick_data_type_id(A_VALUE) \
752 (((A_VALUE) && (A_VALUE)->inf->data_type) \
753 ? &((A_VALUE)->inf->data_type->data_type_id) \
759 #define AFW_VALUE_IS_DATA_TYPE(A_VALUE,A_DATA_TYPE) \
761 (A_VALUE) && (A_VALUE)->inf->fully_evaluated_data_type && \
762 (A_VALUE)->inf->fully_evaluated_data_type == afw_data_type_ ## A_DATA_TYPE \
768 #define AFW_VALUE_ASSERT_IS_DATA_TYPE(A_VALUE, A_DATA_TYPE, A_SCOPE) \
770 if (!AFW_VALUE_IS_DATA_TYPE(A_VALUE, A_DATA_TYPE)) \
771 AFW_THROW_ERROR_Z(cast_error, "Type safe exception.", A_SCOPE); \
777 #define AFW_VALUE_ASSERT_IS_ANYURI_OR_STRING(A_VALUE, A_SCOPE) \
779 if (!AFW_VALUE_IS_DATA_TYPE(A_VALUE, anyURI) && \
780 !AFW_VALUE_IS_DATA_TYPE(A_VALUE, string) ) \
781 AFW_THROW_ERROR_Z(cast_error, "Type safe exception.", A_SCOPE); \
841 #define afw_value_evaluate(value, p, xctx) \
842 (((value) && (value)->inf->optional_evaluate) \
843 ? (value)->inf->optional_evaluate(value, p, xctx) \
856 #define AFW_VALUE_INTERNAL(_VALUE_) \
857 ((void *)(&((afw_value_evaluated_t *)(_VALUE_))->internal))
867 #define AFW_VALUE_DATA_TYPES_EQUAL(value1, value2, xctx) \
868 (afw_value_get_data_type(value1, xctx) != \
869 afw_value_get_data_type(value2, xctx))
879 #define AFW_VALUE_ASSERT_DATA_TYPES_EQUAL(value1, value2, xctx) \
880 if (!AFW_VALUE_DATA_TYPES_EQUAL(value1, value2, xctx)) \
882 AFW_THROW_ERROR_Z(cast_error, "Type safe exception.", xctx); \
893 #define afw_value_is_true(A_VALUE) \
895 AFW_VALUE_IS_DATA_TYPE(A_VALUE, boolean) && \
896 ((const afw_value_boolean_t *)(A_VALUE))->internal \
1338 #define afw_value_function_thunk_create( \
1339 name, like_function_value, execute, ctx, p, xctx) \
1340 afw_value_function_thunk_create_impl( \
1341 name, like_function_value, execute, ctx, AFW__FILE_LINE__, p, xctx)
1645 afw_value_register_core_value_infs(
afw_xctx_t *xctx);
AFW_DEFINE(const afw_object_t *)
#define AFW_BEGIN_DECLARES
#define AFW_DECLARE(type)
Declare a public afw function.
Interfaceafw_interface header.
AFW_DECLARE_CONST_DATA(afw_utf8_t) afw_s_200
afw_utf8_t for string 200
const afw_utf8_t *(* afw_function_arg_check_t)(afw_function_execute_t *x, afw_size_t argc, const afw_value_t *argv[], const afw_pool_t *p, afw_xctx_t *xctx)
Typedef for function arg check functions.
const afw_value_t *(* afw_function_execute_cb_t)(afw_function_execute_t *x)
Typedef for function execute functions.
afw_utf8_octet_t afw_utf8_z_t
NFC normalized UTF-8 null terminated string.
enum afw_compile_type_e afw_compile_type_t
Compile type enum.
char afw_utf8_octet_t
8 bits of utf-8 codepoint.
apr_size_t afw_size_t
size_t.
const afw_value_t *(* afw_function_thunk_execute_t)(const afw_value_function_thunk_t *function, afw_size_t argc, const afw_value_t *const *argv, const afw_pool_t *p, afw_xctx_t *xctx)
Typedef for function thunk execute functions.
unsigned char afw_octet_t
8 bits (unsigned).
apr_int64_t afw_integer_t
typedef for big signed int.
const afw_utf8_t *const * afw_value_as_array_of_utf8(const afw_value_t *value, const afw_pool_t *p, afw_xctx_t *xctx)
Return a NULL terminated list of utf8 in a specified pool.
const afw_value_t * afw_value_expression_definition_create(const afw_compile_value_contextual_t *contextual, const afw_value_assignment_t *const *assignments, const afw_value_t *value, const afw_pool_t *p, afw_xctx_t *xctx)
Create function for expression definition value.
const afw_value_t * afw_value_convert_to_string(const afw_value_t *value, afw_boolean_t allow_undefined, const afw_pool_t *p, afw_xctx_t *xctx)
Convert a value to a string value.
afw_value_compiler_listing_to_string(const afw_value_t *value, const afw_utf8_t *tab, const afw_pool_t *p, afw_xctx_t *xctx)
Decompile a value to a compiler listing string.
const afw_value_t * afw_value_one_and_only(const afw_value_t *value, const afw_pool_t *p, afw_xctx_t *xctx)
Return value from one entry list or single value.
afw_value_assignment_target_inf
Value annotated inf.
afw_value_function_thunk_inf
Value function thunk inf.
const afw_value_t * afw_value_undecorate(const afw_value_t *value)
Return undecorated value.
const afw_value_t * afw_value_compile_and_evaluate_as(const afw_value_t *value, const afw_utf8_t *source_location, afw_compile_type_t compile_type, const afw_pool_t *p, afw_xctx_t *xctx)
Compile and evaluate a value using specified compile type.
afw_boolean_t afw_value_equal(const afw_value_t *value1, const afw_value_t *value2, afw_xctx_t *xctx)
Test whether two values are equal.
const afw_value_t * afw_value_compile_as(const afw_value_t *value, const afw_utf8_t *source_location, afw_compile_type_t compile_type, const afw_pool_t *p, afw_xctx_t *xctx)
Compile a value using specified compile type.
const afw_utf8_t * afw_value_decompile_to_string(const afw_value_t *value, const afw_utf8_t *tab, const afw_pool_t *p, afw_xctx_t *xctx)
Decompile a value to a string.
const afw_value_t * afw_value_annotated_create(const afw_compile_value_contextual_t *contextual, const afw_value_t *value, const afw_object_t *annotation, const afw_pool_t *p, afw_xctx_t *xctx)
Create function for annotated value.
const afw_value_t * afw_value_script_function_definition_create(const afw_compile_value_contextual_t *contextual, const afw_value_type_t *returns, afw_size_t count, const afw_value_script_function_parameter_t **parameters, const afw_value_t *body, const afw_pool_t *p, afw_xctx_t *xctx)
Create function for lambda definition value.
afw_value_create_list_expression(const afw_compile_value_contextual_t *contextual, const afw_value_t *internal, const afw_pool_t *p, afw_xctx_t *xctx)
Create function for list expression value.
afw_value_decompile_call_args(const afw_writer_t *writer, afw_size_t first_arg, const afw_value_call_args_t *args, afw_xctx_t *xctx)
Decompile call args.
afw_value_undefined_as_string
Adaptive value containing <undefined> string.
afw_value_reference_by_key_inf
Value evaluation_reference_by_key inf.
const afw_value_t * afw_value_clone(const afw_value_t *value, const afw_pool_t *p, afw_xctx_t *xctx)
Clone a value to specified pool.
afw_value_annotated_inf
Value annotated inf.
const afw_value_t * afw_value_compile_and_evaluate(const afw_value_t *value, const afw_utf8_t *source_location, const afw_pool_t *p, afw_xctx_t *xctx)
Compile and evaluate a value.
const afw_value_t * afw_value_template_definition_create(const afw_compile_value_contextual_t *contextual, afw_size_t count, const afw_value_t *const *values, const afw_pool_t *p, afw_xctx_t *xctx)
Create function for template definition value.
const afw_utf8_t * afw_value_as_utf8(const afw_value_t *value, const afw_pool_t *p, afw_xctx_t *xctx)
afw_value_evaluated_t * afw_value_evaluated_allocate(const afw_data_type_t *data_type, const afw_pool_t *p, afw_xctx_t *xctx)
Allocate function for an evaluated data type value.
const afw_value_t * afw_value_compile(const afw_value_t *value, const afw_utf8_t *source_location, const afw_pool_t *p, afw_xctx_t *xctx)
Compile a value.
afw_value_block_inf
Value block inf.
afw_value_call_built_in_function_inf
Value call inf.
afw_value_expression_definition_inf
Value expression inf.
afw_value_false
Adaptive value false.
afw_value_object_expression_inf
Value object expression inf.
const afw_utf8_z_t * afw_value_as_utf8_z(const afw_value_t *value, const afw_pool_t *p, afw_xctx_t *xctx)
afw_value_call_inf
Value call inf.
const afw_utf8_t * afw_value_one_and_only_as_utf8(const afw_value_t *value, const afw_pool_t *p, afw_xctx_t *xctx)
Return result of afw_value_one_and_only() as utf8.
const afw_value_t * afw_value_evaluated_create(const void *value, const afw_data_type_t *data_type, const afw_pool_t *p, afw_xctx_t *xctx)
Create function for an evaluated data type value.
const afw_value_t * afw_value_assignment_target_create(const afw_compile_value_contextual_t *contextual, const afw_compile_assignment_target_t *assignment_target, const afw_pool_t *p, afw_xctx_t *xctx)
Create assignment target value.
afw_value_function_definition_inf
Value function inf.
const afw_value_t * afw_value_create_dateTime_now_local(const afw_pool_t *p, afw_xctx_t *xctx)
Create a dateTime value with current local time.
afw_value_empty_string
Adaptive value empty string.
const afw_value_t * afw_value_create_dateTime_now_utc(const afw_pool_t *p, afw_xctx_t *xctx)
Create a dateTime value with current time.
const afw_value_t * afw_value_convert(const afw_value_t *value, const afw_data_type_t *to_data_type, afw_boolean_t required, const afw_pool_t *p, afw_xctx_t *xctx)
Convert a value to a value/data type.
afw_boolean_t afw_value_undecorated_inf_is(const afw_value_t *value, const afw_value_inf_t *inf)
Determine if value's undecorated inf is the supplied one.
const afw_value_t * afw_value_block_finalize(const afw_value_block_t *block, afw_size_t argc, const afw_value_t *const *argv, afw_xctx_t *xctx)
Create and link a new block.
afw_value_decompile_value(const afw_value_t *instance, const afw_writer_t *writer, afw_xctx_t *xctx)
Decompile Value::.
afw_boolean_t afw_value_contains(const afw_value_t *value, const afw_value_t *substring, afw_xctx_t *xctx)
Check to see if a value contains a substring.
const afw_value_t * afw_value_function_thunk_create_impl(const afw_utf8_t *name, const afw_value_t *like_function_value, afw_function_thunk_execute_t execute, void *ctx, const afw_utf8_z_t *source_z, const afw_pool_t *p, afw_xctx_t *xctx)
Create a function thunk value.
const afw_value_t * afw_value_make_string_copy(const afw_utf8_octet_t *s, afw_size_t len, const afw_pool_t *p, afw_xctx_t *xctx)
afw_value_variable_reference_inf
Value variable_reference inf.
afw_value_script_function_definition_inf
Value lambda inf.
const afw_value_t * afw_value_variable_reference_create(const afw_compile_value_contextual_t *contextual, const afw_value_block_symbol_t *symbol, const afw_pool_t *p, afw_xctx_t *xctx)
Create function for variable reference value.
int afw_value_compare(const afw_value_t *value1, const afw_value_t *value2, afw_xctx_t *xctx)
Compare two evaluated values.
const afw_value_t * afw_value_call_create(const afw_compile_value_contextual_t *contextual, afw_size_t argc, const afw_value_t *const *argv, const afw_pool_t *p, afw_xctx_t *xctx)
Create function for call value.
const afw_utf8_t * afw_value_as_casted_utf8(const afw_value_t *value, const afw_pool_t *p, afw_xctx_t *xctx)
Convert value to casted utf8 in specified pool.
const afw_value_t * afw_value_evaluate_with_additional_untrusted_qualified_variables(const afw_value_t *value, const afw_value_t *untrusted_qualified_variables, const afw_pool_t *p, afw_xctx_t *xctx)
Evaluate a value with additional insecure context.
afw_value_list_expression_inf
Value list expression inf.
afw_boolean_t afw_value_is_scalar(const afw_value_t *value, afw_xctx_t *xctx)
Determine if value is scalar.
const afw_value_t * afw_value_call_built_in_function_create(const afw_compile_value_contextual_t *contextual, afw_size_t argc, const afw_value_t *const *argv, const afw_pool_t *p, afw_xctx_t *xctx)
Create function for call_built_in_function value.
afw_value_qualified_variable_reference_inf
Value qualified_variable_reference inf.
const afw_value_block_t * afw_value_block_allocated_and_link(const afw_compile_value_contextual_t *contextual, afw_value_compiled_value_t *compiled_value, afw_size_t *block_count, const afw_pool_t *p, afw_xctx_t *xctx)
Create and link a new block.
afw_value_null
Adaptive value null.
afw_value_template_definition_inf
Value template inf.
const afw_value_t * afw_value_make_single_string(const afw_utf8_octet_t *s, afw_size_t len, const afw_pool_t *p, afw_xctx_t *xctx)
const afw_value_t * afw_value_string_from_internal(const afw_value_t *value, const afw_pool_t *p, afw_xctx_t *xctx)
afw_value_compiled_value_inf
Value call inf.
afw_boolean_t afw_value_is_fully_evaluated(const afw_value_t *value, afw_xctx_t *xctx)
Determine if value and all of it contained values are evaluated.
afw_value_annotated_t * afw_value_annotation_allocate(const afw_pool_t *p, afw_xctx_t *xctx)
Allocate function for annotation value.
afw_value_create_object_expression(const afw_compile_value_contextual_t *contextual, const afw_object_t *internal, const afw_pool_t *p, afw_xctx_t *xctx)
Create function for object expression value.
afw_value_true
Adaptive value true.
const afw_value_t * afw_value_create_string_from_u8z(const afw_utf8_z_t *string_z, const afw_pool_t *p, afw_xctx_t *xctx)
const afw_value_t * afw_value_reference_by_key_create(const afw_compile_value_contextual_t *contextual, const afw_value_t *aggregate_value, const afw_value_t *key, const afw_pool_t *p, afw_xctx_t *xctx)
Create function for reference_by_key value.
const afw_value_t * afw_value_qualified_variable_reference_create(const afw_compile_value_contextual_t *contextual, const afw_utf8_t *qualifier, const afw_utf8_t *name, const afw_pool_t *p, afw_xctx_t *xctx)
Create function for variable reference value.
const afw_value_t *const * afw_value_as_array_of_values(const afw_value_t *value, const afw_pool_t *p, afw_xctx_t *xctx)
Return a NULL terminated list of values in a specified pool.
Contextual information provided in some values.
Interface afw_data_type public struct.
Interface afw_object public struct.
Interface afw_pool public struct.
NFC normalized UTF-8 string.
Struct for annotated value.
Struct for value assignment.
struct for afw_value_block_t
struct for afw_value_block_symbol_t
Struct for contextual and args for call values.
Struct to access internal of all evaluated values.
Struct for function value.
const afw_value_function_parameter_t *const * parameters
Function parameters.
afw_utf8_t functionSignature
Function signature.
afw_utf8_t description
Description of function.
afw_boolean_t polymorphicExecuteFunctionEvaluatesFirstParameter
True if polymorphic execute evaluates first parameter.
afw_integer_t numberOfRequiredParameters
The number of required parameters.
afw_utf8_t untypedFunctionId
Function id without <dataType>.
afw_boolean_t deprecated
This function is deprecated.
const afw_utf8_t * sideEffects
Side effects or NULL.
const afw_object_t * object
Object representing function.
afw_function_execute_cb_t execute
Function called to execute this Adaptive function.
afw_utf8_t afwCamelCaseFunctionLabel
functionLabel prefixed with "afw" and converted to camel case.
afw_utf8_t category
Category of function.
afw_boolean_t polymorphic
True if this is a polymorphic function.
afw_boolean_t signatureOnly
This is only a signature with an unimplemented execute function.
afw_function_arg_check_t arg_check
Optional function called to check args.
const afw_data_type_t * data_type
If this is a data type method, this is the data type.
afw_utf8_t functionLabel
Label used internally for function.
afw_integer_t dataTypeMethodNumber
Data type member number.
afw_boolean_t pure
Given the same exact parameter values, this function will always return the same result an not cause ...
afw_utf8_t op
Optional operator for function.
const afw_utf8_t * polymorphicDataTypes
If this is polymorphic function, these are supported data types.
const afw_value_function_parameter_t * returns
Function returns.
afw_utf8_t functionId
Function id of function.
afw_octet_t scriptSupportNumber
See AFW_VALUE_SCRIPT_SUPPORT_NUMBER_* #defines.
afw_utf8_t dataType
If this is a data type method, this is the data type id.
afw_utf8_t camelCaseFunctionLabel
functionLabel converted to camel case.
afw_utf8_t brief
Brief description.
const afw_size_t parameters_count
Parameters count.
afw_utf8_t functionDeclaration
Function declaration.
const afw_utf8_z_t *const * errorsThrown
Errors thrown or NULL.
afw_integer_t maximumNumberOfParameters
The maximum number of required parameters or -1 is no max.
Struct for adaptive function parameter.
Interface afw_value_inf_s struct.
Filled in by afw_value get_info method.
Struct for compiled value value.
Interface afw_value public struct.
Struct for script function parameter.
Type meta (data type, data type parameters, and value meta object.
Interface afw_writer public struct.
Interface afw_xctx public struct.