02f61d3ca3038e1e943a513dea1fc0ea56d2663c
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 *)
22 OK
* = 0; BAD_TYPEDEF
* = 1; BAD_ABI
* = 2;
41 TYPE_LAST
* = TYPE_COMPLEX
;
44 abi
* ["ffi_abi"] = types
.int
; (* !!! enum *)
45 status
* ["ffi_status"] = types
.int
; (* !!! enum *)
47 (* Ptype* = POINTER [untagged] TO type;
48 PPtype* = POINTER [untagged] TO ARRAY [untagged] OF Ptype; *)
49 type
* ["ffi_type"] = RECORD [untagged
]
50 size
*: sys_types
.size_t
;
51 alignment
*: types
.unsigned_short
;
52 type
*: types
.unsigned_short
;
53 elements
*: POINTER [untagged
] TO ARRAY [untagged
] OF POINTER TO type
;
56 (* Pcif* = POINTER TO cif; *)
57 cif
* ["ffi_cif"] = RECORD [untagged
]
59 nargs
*: types
.unsigned
;
60 arg_type
*: POINTER [untagged
] TO ARRAY [untagged
] OF POINTER TO type
;
61 rtype
*: POINTER TO type
;
62 bytes
*: types
.unsigned
;
63 flags
*: types
.unsigned
;
67 type_void
- ["ffi_type_void"]: type
;
68 type_uint8
- ["ffi_type_uint8"]: type
;
69 type_sint8
- ["ffi_type_sint8"]: type
;
70 type_uint16
- ["ffi_type_uint16"]: type
;
71 type_sint16
- ["ffi_type_sint16"]: type
;
72 type_uint32
- ["ffi_type_uint32"]: type
;
73 type_sint32
- ["ffi_type_sint32"]: type
;
74 type_uint64
- ["ffi_type_uint64"]: type
;
75 type_sint64
- ["ffi_type_sint64"]: type
;
76 type_float
- ["ffi_type_float"]: type
;
77 type_double
- ["ffi_type_double"]: type
;
78 type_pointer
- ["ffi_type_pointer"]: type
;
79 type_longdouble
- ["ffi_type_longdouble"]: type
;
81 type_complex_single
- ["ffi_type_complex_single"]: type
;
82 type_complex_double
- ["ffi_type_complex_double"]: type
;
83 type_complex_longdouble
- ["ffi_type_complex_longdouble"]: type
;
85 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
;
86 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
;
87 PROCEDURE [ccall
] call
* ["ffi_call"] (VAR c
: cif
; fn
, rvalue
, avalue
: SYSTEM
.ADDRESS
);