2026-05-04 16:37:06 +01:00
|
|
|
#include <fx/reflection/function.h>
|
|
|
|
|
#include <fx/value.h>
|
2026-05-03 13:11:22 +01:00
|
|
|
#include <stdio.h>
|
|
|
|
|
|
2026-05-04 16:37:06 +01:00
|
|
|
static double test_function(int a, double b, int c, ...)
|
|
|
|
|
{
|
|
|
|
|
#if 1
|
|
|
|
|
va_list args;
|
|
|
|
|
va_start(args, c);
|
|
|
|
|
int d = va_arg(args, int);
|
|
|
|
|
double e = va_arg(args, double);
|
|
|
|
|
int f = va_arg(args, int);
|
|
|
|
|
printf("a=%d, b=%lf, c=%d, d=%d, e=%lf, f=%d\n", a, b, c, d, e, f);
|
|
|
|
|
return (a + b + c + d + e + f) + 0.5;
|
|
|
|
|
#else
|
|
|
|
|
printf("a=%d, b=%lf, c=%d\n", a, b, c);
|
|
|
|
|
return 32;
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-03 13:11:22 +01:00
|
|
|
int main(int argc, const char **argv)
|
|
|
|
|
{
|
2026-05-04 16:37:06 +01:00
|
|
|
fx_value_type arg_types[] = {
|
|
|
|
|
FX_VALUE_TYPE_INT,
|
|
|
|
|
FX_VALUE_TYPE_DOUBLE,
|
|
|
|
|
FX_VALUE_TYPE_INT,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
fx_function *func = fx_function_create(
|
|
|
|
|
"test_function",
|
|
|
|
|
FX_FUNCTION_F_VARARG,
|
|
|
|
|
(fx_function_impl)test_function,
|
|
|
|
|
arg_types,
|
|
|
|
|
3,
|
|
|
|
|
FX_VALUE_TYPE_DOUBLE);
|
2026-05-03 13:11:22 +01:00
|
|
|
|
2026-05-04 16:37:06 +01:00
|
|
|
fx_value args[] = {
|
|
|
|
|
FX_VALUE_INT(1),
|
|
|
|
|
FX_VALUE_DOUBLE(2.5),
|
|
|
|
|
FX_VALUE_INT(3),
|
|
|
|
|
FX_VALUE_INT(4),
|
|
|
|
|
FX_VALUE_DOUBLE(5.5),
|
|
|
|
|
FX_VALUE_INT(6),
|
|
|
|
|
};
|
2026-05-03 13:11:22 +01:00
|
|
|
|
2026-05-04 16:37:06 +01:00
|
|
|
fx_value result = FX_VALUE_EMPTY;
|
|
|
|
|
int r = fx_function_invoke(func, args, 6, &result);
|
|
|
|
|
printf("%lf\n", result.v_double);
|
2026-05-03 13:11:22 +01:00
|
|
|
return 0;
|
|
|
|
|
}
|