fx.reflection: implement dynamic function calling
This commit is contained in:
@@ -0,0 +1,86 @@
|
||||
#include <fx/macros.h>
|
||||
#include <fx/reflection/function.h>
|
||||
#include <fx/string.h>
|
||||
#include <fx/value.h>
|
||||
#include <platform/callvm.h>
|
||||
|
||||
struct fx_function_context_p {
|
||||
struct callvm ctx_vm;
|
||||
};
|
||||
|
||||
/*** PRIVATE FUNCTIONS ********************************************************/
|
||||
|
||||
static fx_status function_context_reset(
|
||||
const struct fx_function_context_p *func)
|
||||
{
|
||||
return FX_SUCCESS;
|
||||
}
|
||||
|
||||
static fx_status function_context_push_arg(
|
||||
const struct fx_function_context_p *func,
|
||||
const fx_value *arg)
|
||||
{
|
||||
return FX_SUCCESS;
|
||||
}
|
||||
|
||||
/*** PUBLIC FUNCTIONS *********************************************************/
|
||||
|
||||
FX_API fx_function *fx_function_context_create(void)
|
||||
{
|
||||
fx_function_context *ctx
|
||||
= fx_object_create(FX_REFLECTION_TYPE_FUNCTION_CONTEXT);
|
||||
if (!ctx) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct fx_function_context_p *p = fx_object_get_private(
|
||||
ctx,
|
||||
FX_REFLECTION_TYPE_FUNCTION_CONTEXT);
|
||||
|
||||
return ctx;
|
||||
}
|
||||
|
||||
FX_API void fx_function_context_reset(fx_function_context *ctx)
|
||||
{
|
||||
FX_CLASS_DISPATCH_STATIC_V0(
|
||||
FX_REFLECTION_TYPE_FUNCTION_CONTEXT,
|
||||
function_context_reset,
|
||||
ctx);
|
||||
}
|
||||
|
||||
FX_API void fx_function_context_push_arg(
|
||||
fx_function_context *ctx,
|
||||
const fx_value *value)
|
||||
{
|
||||
FX_CLASS_DISPATCH_STATIC_V(
|
||||
FX_REFLECTION_TYPE_FUNCTION_CONTEXT,
|
||||
function_context_push_arg,
|
||||
ctx,
|
||||
value);
|
||||
}
|
||||
|
||||
/*** VIRTUAL FUNCTIONS ********************************************************/
|
||||
|
||||
static void function_context_init(fx_object *obj, void *priv)
|
||||
{
|
||||
}
|
||||
|
||||
static void function_context_fini(fx_object *obj, void *priv)
|
||||
{
|
||||
}
|
||||
|
||||
/*** CLASS DEFINITION *********************************************************/
|
||||
|
||||
FX_TYPE_CLASS_DEFINITION_BEGIN(fx_function_context)
|
||||
FX_TYPE_CLASS_INTERFACE_BEGIN(fx_object, FX_TYPE_OBJECT)
|
||||
FX_INTERFACE_ENTRY(to_string) = NULL;
|
||||
FX_TYPE_CLASS_INTERFACE_END(fx_object, FX_TYPE_OBJECT)
|
||||
FX_TYPE_CLASS_DEFINITION_END(fx_function_context)
|
||||
|
||||
FX_TYPE_DEFINITION_BEGIN(fx_function_context)
|
||||
FX_TYPE_ID(0x97d98a1a, 0x6312, 0x409e, 0xb47d, 0xc5d80daf9e50);
|
||||
FX_TYPE_CLASS(fx_function_context_class);
|
||||
FX_TYPE_INSTANCE_PRIVATE(struct fx_function_context_p);
|
||||
FX_TYPE_INSTANCE_INIT(function_context_init);
|
||||
FX_TYPE_INSTANCE_FINI(function_context_fini);
|
||||
FX_TYPE_DEFINITION_END(fx_function_context)
|
||||
Reference in New Issue
Block a user