23 const void *entry_internal;
36 impl_call_over_list_cb_t callback,
53 functor_argc = x->
argc - 1;
56 functor_argv[0] = afw_function_evaluate_function_parameter(
57 x->
argv[1], e.p, e.xctx);
65 for (e.n = 1; e.n <= functor_argc; e.n++) {
68 e.entry_arg_ptr = &functor_argv[e.n];
70 *e.entry_arg_ptr = NULL;
80 if (!e.entry_arg_ptr) {
86 for (iterator = NULL;;) {
88 &e.entry_internal, e.xctx);
89 if (!e.entry_internal) {
93 e.data_type->c_type_size);
105 for (iterator = NULL;;) {
107 e.list, &iterator, NULL, e.xctx);
108 if (!*e.entry_arg_ptr) {
140 data->result = data->stop_on;
154 data.stop_on = stop_on;
155 data.result = !stop_on;
156 impl_over_list(x, impl_of_cb, (
void *)&data);
170 const void *internal1, *internal2;
178 f_argv[0] = afw_function_evaluate_function_parameter(
190 if (!all_1 && all_2) {
201 if (!data_type_1 || !data_type_2) {
203 "list1 and list2 must both be typed",
209 data_type_1, x->
p, x->
xctx);
214 data_type_2, x->
p, x->
xctx);
220 for (iterator1 = NULL;;) {
222 &iterator1, NULL, &internal1, x->
xctx);
227 for (iterator2 = NULL;;) {
229 &iterator2, NULL, &internal2, x->
xctx);
233 memcpy(e1, internal1, data_type_1->c_type_size);
234 memcpy(e2, internal2, data_type_2->c_type_size);
238 "First argument must be a boolean function", x->
xctx);
255 if (any_1 && is_true)
break;
258 if (!any_1 && !is_true)
break;
307 return impl_of(x,
false);
353 return impl_bag_of_bag(x,
true,
true);
399 return impl_bag_of_bag(x,
true,
false);
444 return impl_of(x,
true);
490 return impl_bag_of_bag(x,
false,
true);
536 return impl_bag_of_bag(x,
false,
false);
554 e->data_type, e->entry_internal, e->xctx);
604 impl_over_list(x, impl_filter_cb, (
void *)&data);
624 e->entry_internal, e->data_type, e->p, e->xctx);
674 impl_over_list(x, impl_find_cb, (
void *)&data);
692 if (!data->mapped_list) {
693 data->data_type = e->data_type;
694 data->functor = e->functor;
745 impl_over_list(x, impl_map_cb, (
void *)&data);
747 if (!data.mapped_list) {
751 data.functor)->data_type->empty_list_value;
818 f_argv[0] = afw_function_evaluate_function_parameter(
824 for (iterator = NULL;;) {
830 f_argv[1] = accumulator;
861 pivot = ctx->values[high];
864 memcpy(&(ctx->args[2]->internal), pivot, ctx->c_type_size);
865 for (i = low, j = low; j <= high - 1; j++)
868 memcpy(&(ctx->args[1]->internal), ctx->values[j], ctx->c_type_size);
879 value = ctx->values[i];
880 ctx->values[i] = ctx->values[j];
881 ctx->values[j] = value;
887 value = ctx->values[i];
888 ctx->values[i] = ctx->values[high];
889 ctx->values[high] = value;
905 pivot_i = impl_partition(ctx, low, high);
907 impl_quick_sort(ctx, low, pivot_i - 1);
909 impl_quick_sort(ctx, pivot_i + 1, high);
967 afw_function_evaluate_function_parameter(x->
argv[1], ctx.p, ctx.xctx);
969 2, (
const afw_value_t *
const *)&ctx.args[0], ctx.p, ctx.xctx);
976 "sort() requires list to be typed", ctx.xctx);
978 ctx.c_type_size = data_type->c_type_size;
980 if (ctx.count == 0) {
981 return data_type->empty_list_value;
989 ctx.values =
afw_pool_malloc(ctx.p,
sizeof(
void *) * ctx.count, ctx.xctx);
990 for (iterator = NULL, value = ctx.values;
992 NULL, value, ctx.xctx);
997 impl_quick_sort(&ctx, 0, ctx.count - 1);
1002 ctx.values,
true, data_type, ctx.count, ctx.p, ctx.xctx);
Adaptive Framework Core Internal.
#define afw_value_is_boolean(A_VALUE)
Macro to determine if value is evaluated boolean.
afw_value_create_list(const afw_list_t *internal, const afw_pool_t *p, afw_xctx_t *xctx)
Create function for unmanaged data type list value.
#define afw_value_is_list(A_VALUE)
Macro to determine if value is evaluated list.
afw_data_type_null
Data type struct for null.
struct afw_iterator_s afw_iterator_t
apr_size_t afw_size_t
size_t.
#define AFW_THROW_ERROR_Z(code, message_z, xctx)
Macro used to set error and 0 rv in xctx and throw it.
#define AFW_FUNCTION_EVALUATE_REQUIRED_DATA_TYPE_PARAMETER(A_RESULT, A_N, A_TYPE)
Evaluate an arg for a particular data type.
#define AFW_FUNCTION_EVALUATE_REQUIRED_PARAMETER(A_RESULT, A_N)
Evaluate an required parameter.
const afw_value_t * afw_function_execute_sort(afw_function_execute_t *x)
Adaptive Function sort
const afw_value_t * afw_function_execute_reduce(afw_function_execute_t *x)
Adaptive Function reduce
const afw_value_t * afw_function_execute_find(afw_function_execute_t *x)
Adaptive Function find
const afw_value_t * afw_function_execute_all_of_all(afw_function_execute_t *x)
Adaptive Function all_of_all
const afw_value_t * afw_function_execute_any_of(afw_function_execute_t *x)
Adaptive Function any_of
const afw_value_t * afw_function_execute_any_of_all(afw_function_execute_t *x)
Adaptive Function any_of_all
const afw_value_t * afw_function_execute_map(afw_function_execute_t *x)
Adaptive Function map
const afw_value_t * afw_function_execute_filter(afw_function_execute_t *x)
Adaptive Function filter
const afw_value_t * afw_function_execute_all_of(afw_function_execute_t *x)
Adaptive Function all_of
const afw_value_t * afw_function_execute_all_of_any(afw_function_execute_t *x)
Adaptive Function all_of_any
const afw_value_t * afw_function_execute_any_of_any(afw_function_execute_t *x)
Adaptive Function any_of_any
#define afw_list_get_next_internal(instance, iterator, data_type, internal, xctx)
Call method get_next_internal of interface afw_list.
#define afw_list_get_next_value(instance, iterator, p, xctx)
Call method get_next_value of interface afw_list.
#define afw_list_get_data_type(instance, xctx)
Call method get_data_type of interface afw_list.
#define afw_list_get_count(instance, xctx)
Call method get_count of interface afw_list.
afw_list_determine_data_type_and_set_immutable(const afw_list_t *instance, afw_xctx_t *xctx)
Set list to immutable and determine data type of entries.
afw_list_create_wrapper_for_array(const void *array, afw_boolean_t indirect, const afw_data_type_t *data_type, afw_size_t count, const afw_pool_t *p, afw_xctx_t *xctx)
Create a immutable list wrapper for an array.
afw_list_add_internal(const afw_list_t *instance, const afw_data_type_t *data_type, const void *internal, afw_xctx_t *xctx)
Call method add of interface afw_list_setter.
#define afw_list_create_generic(p, xctx)
Create an value list in memory.
afw_list_add_value(const afw_list_t *instance, const afw_value_t *value, afw_xctx_t *xctx)
Call method add_value of interface afw_list_setter.
const afw_list_t * afw_list_create_with_options(int options, const afw_data_type_t *data_type, const afw_pool_t *p, afw_xctx_t *xctx)
Create an list in memory with options.
#define afw_memory_clear(to)
Clear preallocated memory for sizeof(*(to)).
#define afw_pool_malloc(instance, size, xctx)
Call method malloc of interface afw_pool.
#define afw_pool_calloc(instance, size, xctx)
Call method calloc of interface afw_pool.
#define afw_value_evaluate(value, p, xctx)
Evaluate value if needed using specific pool.
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.
afw_value_false
Adaptive value false.
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.
#define AFW_VALUE_INTERNAL(_VALUE_)
Macro to get const void * of the internal of a value.
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.
#define AFW_VALUE_ASSERT_IS_DATA_TYPE(A_VALUE, A_DATA_TYPE, A_SCOPE)
Throw and error if A_VALUE is not evaluated data type A_DATA_TYPE.
afw_value_null
Adaptive value null.
afw_value_true
Adaptive value true.
Interface afw_data_type public struct.
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_value_function_definition_t * function
The evaluated function definition.
const afw_pool_t * p
Pool for result.
afw_size_t argc
This is the argv count not counting argv[0].
Interface afw_list public struct.
Interface afw_pool public struct.
struct for data type boolean values.
Struct to access internal of all evaluated values.
Struct for function value.
struct for data type list values.
Interface afw_value public struct.
Interface afw_xctx public struct.