]> Nishi Git Mirror - serenade.git/commitdiff
uhh
authornishi <nishi@0f02c867-ac3d-714e-8a88-971ba1f6efcf>
Wed, 24 Apr 2024 06:09:28 +0000 (06:09 +0000)
committernishi <nishi@0f02c867-ac3d-714e-8a88-971ba1f6efcf>
Wed, 24 Apr 2024 06:09:28 +0000 (06:09 +0000)
git-svn-id: file:///raid/svn-main/nishi-serenade/trunk@30 0f02c867-ac3d-714e-8a88-971ba1f6efcf

Serenade/ffi_binding.c

index f6621b8225c52da8c03459e74093e8bbbbec5622..d42aa99a2850ca5d8b357d210fa6fd168a0a0a7f 100644 (file)
 
 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);
 }