1 MODULE LibFFI
["ffi.h"];
3 IMPORT SYSTEM
, types
:= PosixCtypes
, sys_types
:= PosixCsys_types
;
11 STDCALL_WIN32
* = 2; (* FFI_STDCALL for win32 *)
14 MS_CDECL_WIN32
* = 5; (* FFI_MS_CDECL for win32 *)
15 STDCALL_GENERIC
* = 5; (* FFI_STDCALL for ~win32 *)
25 OK
* = 0; BAD_TYPEDEF
* = 1; BAD_ABI
* = 2;
44 TYPE_LAST
* = TYPE_COMPLEX
;
47 abi
* ["ffi_abi"] = types
.int
; (* !!! enum *)
48 status
* ["ffi_status"] = types
.int
; (* !!! enum *)
50 (* Ptype* = POINTER [untagged] TO type;
51 PPtype* = POINTER [untagged] TO ARRAY [untagged] OF Ptype; *)
52 type
* ["ffi_type"] = RECORD [untagged
]
53 size
*: sys_types
.size_t
;
54 alignment
*: types
.unsigned_short
;
55 type
*: types
.unsigned_short
;
56 elements
*: POINTER [untagged
] TO ARRAY [untagged
] OF POINTER TO type
;
59 (* Pcif* = POINTER TO cif; *)
60 cif
* ["ffi_cif"] = RECORD [untagged
]
62 nargs
*: types
.unsigned
;
63 arg_type
*: POINTER [untagged
] TO ARRAY [untagged
] OF POINTER TO type
;
64 rtype
*: POINTER TO type
;
65 bytes
*: types
.unsigned
;
66 flags
*: types
.unsigned
;
70 type_void
- ["ffi_type_void"]: type
;
71 type_uint8
- ["ffi_type_uint8"]: type
;
72 type_sint8
- ["ffi_type_sint8"]: type
;
73 type_uint16
- ["ffi_type_uint16"]: type
;
74 type_sint16
- ["ffi_type_sint16"]: type
;
75 type_uint32
- ["ffi_type_uint32"]: type
;
76 type_sint32
- ["ffi_type_sint32"]: type
;
77 type_uint64
- ["ffi_type_uint64"]: type
;
78 type_sint64
- ["ffi_type_sint64"]: type
;
79 type_float
- ["ffi_type_float"]: type
;
80 type_double
- ["ffi_type_double"]: type
;
81 type_pointer
- ["ffi_type_pointer"]: type
;
82 type_longdouble
- ["ffi_type_longdouble"]: type
;
84 type_complex_single
- ["ffi_type_complex_single"]: type
;
85 type_complex_double
- ["ffi_type_complex_double"]: type
;
86 type_complex_longdouble
- ["ffi_type_complex_longdouble"]: type
;
88 PROCEDURE [ccall
] prep_cif
* ["ffi_prep_cif"] (VAR c
: cif
; a
: abi
; nargs
: types
.unsigned_int
; rtype
: POINTER TO type
; atypes
: POINTER [untagged
] TO ARRAY [untagged
] OF POINTER TO type
): status
;
89 PROCEDURE [ccall
] prep_cif_var
* ["ffi_prep_cif_var"] (VAR c
: cif
; a
: abi
; nfixedargs
, ntotalargs
: types
.unsigned_int
; rtype
: POINTER TO type
; atypes
: POINTER [untagged
] TO ARRAY [untagged
] OF POINTER TO type
): status
;
90 PROCEDURE [ccall
] call
* ["ffi_call"] (VAR c
: cif
; fn
, rvalue
, avalue
: INTEGER);