37 lines
737 B
C
37 lines
737 B
C
#include <fx/cstr.h>
|
|
#include <fx/reflection/function.h>
|
|
#include <fx/string.h>
|
|
#include <fx/value.h>
|
|
#include <inttypes.h>
|
|
#include <stdio.h>
|
|
|
|
int main(int argc, const char **argv)
|
|
{
|
|
fx_type_id arg_types[] = {
|
|
FX_TYPE_CSTR,
|
|
};
|
|
|
|
fx_function *func = fx_function_create(
|
|
"printf",
|
|
FX_FUNCTION_F_VARARG,
|
|
(fx_function_impl)printf,
|
|
arg_types,
|
|
1,
|
|
FX_TYPE_INT);
|
|
|
|
fx_string *fmt = fx_string_create_from_cstr(
|
|
"Hello %s! You are number %lf\n");
|
|
fx_value args[] = {
|
|
FX_VALUE_OBJECT(fmt),
|
|
FX_CSTR("Jonh"),
|
|
FX_DOUBLE(2.5),
|
|
};
|
|
|
|
fx_function_bind(func, args, sizeof args / sizeof args[0]);
|
|
|
|
fx_value result = FX_VALUE_EMPTY;
|
|
int r = fx_function_invoke(func, NULL, 0, &result);
|
|
printf("%d\n", result.v_int);
|
|
return 0;
|
|
}
|