flush
[m6w6/ext-psi] / src / libffi.c
index 5962b5e7431aedaff1d362aed1b5bae373712e72..301995e5903d9bc377c3d2630f1be48fed9e0513 100644 (file)
@@ -8,6 +8,7 @@
 
 #include "php_psi.h"
 #include "libffi.h"
 
 #include "php_psi.h"
 #include "libffi.h"
+#include "engine.h"
 
 #undef PACKAGE
 #undef PACKAGE_BUGREPORT
 
 #undef PACKAGE
 #undef PACKAGE_BUGREPORT
@@ -87,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_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;
                return &ffi_type_sint;
        case PSI_T_LONG:
                return &ffi_type_slong;
@@ -94,6 +96,10 @@ static inline ffi_type *psi_ffi_token_type(token_t t) {
                return &ffi_type_float;
        case PSI_T_DOUBLE:
                return &ffi_type_double;
                return &ffi_type_float;
        case PSI_T_DOUBLE:
                return &ffi_type_double;
+#ifdef HAVE_LONG_DOUBLE
+       case PSI_T_LONG_DOUBLE:
+               return &ffi_type_longdouble;
+#endif
        case PSI_T_POINTER:
                return &ffi_type_pointer;
        }
        case PSI_T_POINTER:
                return &ffi_type_pointer;
        }
@@ -186,7 +192,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);
 
 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));
 
                if (!real->strct->engine.type) {
                        ffi_type *strct = calloc(1, sizeof(ffi_type));
 
@@ -199,8 +206,13 @@ static inline ffi_type *psi_ffi_decl_type(decl_type *type) {
                }
 
                return real->strct->engine.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) {
 }
 static inline ffi_type *psi_ffi_decl_arg_type(decl_arg *darg) {
        if (darg->var->pointer_level) {