X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=src%2Flibffi.c;h=be9edfd26ec1cb4a5df3a7210fc3a5b94f482907;hb=b6a04e85779e14399f03e91939b8cb47eb330ef7;hp=1f5bf016a8a714add395b3fb7a0de32b801eda43;hpb=b4a3c33fc143fd57288fcfe0878e7a22eeaf61bf;p=m6w6%2Fext-psi diff --git a/src/libffi.c b/src/libffi.c index 1f5bf01..be9edfd 100644 --- a/src/libffi.c +++ b/src/libffi.c @@ -88,6 +88,7 @@ static inline ffi_type *psi_ffi_token_type(token_t t) { case PSI_T_BOOL: return &ffi_type_uchar; case PSI_T_INT: + case PSI_T_ENUM: return &ffi_type_sint; case PSI_T_LONG: return &ffi_type_slong; @@ -100,6 +101,7 @@ static inline ffi_type *psi_ffi_token_type(token_t t) { return &ffi_type_longdouble; #endif case PSI_T_POINTER: + case PSI_T_FUNCTION: return &ffi_type_pointer; } } @@ -191,7 +193,8 @@ static ffi_type **psi_ffi_struct_type_elements(decl_struct *strct) { static inline ffi_type *psi_ffi_decl_type(decl_type *type) { decl_type *real = real_decl_type(type); - if (real->type == PSI_T_STRUCT) { + switch (real->type) { + case PSI_T_STRUCT: if (!real->strct->engine.type) { ffi_type *strct = calloc(1, sizeof(ffi_type)); @@ -204,8 +207,13 @@ static inline ffi_type *psi_ffi_decl_type(decl_type *type) { } return real->strct->engine.type; + + case PSI_T_UNION: + return psi_ffi_decl_arg_type(real->unn->args->args[0]); + + default: + return psi_ffi_token_type(real->type); } - return psi_ffi_token_type(real->type); } static inline ffi_type *psi_ffi_decl_arg_type(decl_arg *darg) { if (darg->var->pointer_level) {