fx: support for registering callable functions with types

This commit is contained in:
2026-05-05 21:16:31 +01:00
parent 703155affe
commit f3062222cb
16 changed files with 182 additions and 25 deletions
+19 -3
View File
@@ -22,6 +22,11 @@ struct fx_function_p {
/*** PRIVATE FUNCTIONS ********************************************************/
static const char *function_get_name(const struct fx_function_p *func)
{
return func->func_name;
}
static fx_status function_bind(
struct fx_function_p *func,
fx_value *args,
@@ -98,10 +103,9 @@ static fx_status function_invoke(
return FX_SUCCESS;
}
/*** PUBLIC FUNCTIONS
* *********************************************************/
/*** PUBLIC FUNCTIONS *********************************************************/
FX_API fx_function *fx_function_create(
fx_function *fx_function_create(
const char *name,
fx_function_flags flags,
fx_function_impl impl,
@@ -118,6 +122,10 @@ FX_API fx_function *fx_function_create(
func,
FX_REFLECTION_TYPE_FUNCTION);
if (nr_args == 1 && args[0] == FX_VALUE_TYPE_NONE) {
nr_args = 0;
}
p->func_name = fx_strdup(name);
p->func_flags = flags;
p->func_impl = impl;
@@ -131,6 +139,14 @@ FX_API fx_function *fx_function_create(
return func;
}
const char *fx_function_get_name(const fx_function *func)
{
FX_CLASS_DISPATCH_STATIC_0(
FX_REFLECTION_TYPE_FUNCTION,
function_get_name,
func);
}
fx_status fx_function_bind(fx_function *func, fx_value *args, size_t nr_args)
{
FX_CLASS_DISPATCH_STATIC(