From fb723852db95d9fffd5c0d26f901fb21f5210e82 Mon Sep 17 00:00:00 2001 From: nishi Date: Wed, 24 Apr 2024 06:09:28 +0000 Subject: [PATCH] uhh git-svn-id: file:///raid/svn-main/nishi-serenade/trunk@30 0f02c867-ac3d-714e-8a88-971ba1f6efcf --- Serenade/ffi_binding.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/Serenade/ffi_binding.c b/Serenade/ffi_binding.c index f6621b8..d42aa99 100644 --- a/Serenade/ffi_binding.c +++ b/Serenade/ffi_binding.c @@ -44,6 +44,12 @@ ffi_cif cif; +struct ffi_info { + void* ptr; + ffi_cif cif; + ffi_type** argtypes; +}; + struct sn_generic* ffi_symbol_handler(struct sn_interpreter* sn, int args, struct sn_generic** gens) { struct sn_generic* gen = malloc(sizeof(struct sn_generic)); gen->type = SN_TYPE_VOID; @@ -62,6 +68,20 @@ struct sn_generic* ffi_symbol_handler(struct sn_interpreter* sn, int args, struc return gen; } +struct sn_generic* ffi_function_handler(struct sn_interpreter* sn, int args, struct sn_generic** gens) { + struct sn_generic* gen = malloc(sizeof(struct sn_generic)); + gen->type = SN_TYPE_VOID; + if(args > 1){ + if(gens[1]->type == SN_TYPE_PTR){ + struct ffi_info* info = malloc(sizeof(struct ffi_info)); + int i; + for(i = 2; i < args; i++){ + } + } + } + return gen; +} + struct sn_generic* ffi_load_handler(struct sn_interpreter* sn, int args, struct sn_generic** gens) { struct sn_generic* gen = malloc(sizeof(struct sn_generic)); gen->type = SN_TYPE_VOID; @@ -87,4 +107,5 @@ void ffi_init(struct sn_interpreter* sn) { sn_set_variable(sn, "ffi-loaded", gen); sn_set_handler(sn, "ffi-symbol", ffi_symbol_handler); sn_set_handler(sn, "ffi-load", ffi_load_handler); + sn_set_handler(sn, "ffi-function", ffi_function_handler); } -- 2.43.0