1+ #include "umka_common.h"
12#include "umka_gen.h"
23#include "umka_lexer.h"
34#include "umka_types.h"
@@ -124,7 +125,7 @@ ffi_type *mapToFfiType(Umka *umka,const struct tagType *type) {
124125 case TYPE_PTR :
125126 return & ffi_type_uint64 ;
126127 case TYPE_BOOL :
127- return & ffi_type_uchar ;
128+ return & ffi_type_uint8 ;
128129 case TYPE_CHAR :
129130 return & ffi_type_uchar ;
130131
@@ -133,7 +134,6 @@ ffi_type *mapToFfiType(Umka *umka,const struct tagType *type) {
133134 // probabbly should be only created once for each struct, then looked up here
134135 return mapToFfiStruct (umka , type -> typeIdent -> type );
135136
136-
137137 // float types
138138 case TYPE_REAL32 :
139139 return & ffi_type_float ;
@@ -171,7 +171,10 @@ int assignFfiTypes(Umka *umka, ffi_type **types, const Signature *sig)
171171 for (int i = 0 ; i < sig -> numParams && i < 16 ; i ++ ) {
172172 const Param * param = sig -> param [i ];
173173 ffi_type * type = mapToFfiType (umka , param -> type );
174- if (type == NULL ) continue ;
174+
175+ if (strcmp (param -> name , "#upvalues" ) == 0 ) continue ;
176+ if (strcmp (param -> name , "#result" ) == 0 ) continue ;
177+
175178 types [numArgs ++ ] = type ;
176179 }
177180 return numArgs ;
@@ -225,13 +228,13 @@ void doResolveExtern(Umka *umka)
225228
226229 // todo: free?
227230 ffi_type * * types = malloc (sizeof (ffi_type )* 16 );
228- dynamicCall -> numArgs = assignFfiTypes (umka , types , & ident -> type -> sig );
229-
230231 ffi_type * retType = mapToFfiType (umka , ident -> type -> sig .resultType );
232+ int numArgs = assignFfiTypes (umka , types , & ident -> type -> sig );
233+
231234 if (retType == NULL )
232235 umka -> error .handler (umka -> error .context , "Unsupported return type for ffi function: %d" , ident -> type -> sig .resultType -> typeIdent -> name );
233236
234- ffi_status status = ffi_prep_cif (& dynamicCall -> cif , FFI_DEFAULT_ABI , dynamicCall -> numArgs , retType , types );
237+ ffi_status status = ffi_prep_cif (& dynamicCall -> cif , FFI_DEFAULT_ABI , numArgs , retType , types );
235238 if (status != FFI_OK )
236239 umka -> error .handler (umka -> error .context , "Error creating ffi_cif: %d" , status );
237240
0 commit comments