1 MODULE LibFFI
["ffi/ffi.h"];
3 IMPORT SYSTEM
, types
:= PosixCtypes
, sys_types
:= PosixCsys_types
;
12 DEFAULT_ABI
* = DARWIN
;
13 LAST_ABI
* = DEFAULT_ABI
+ 1;
16 OK
* = 0; BAD_TYPEDEF
* = 1; BAD_ABI
* = 2;
35 TYPE_LAST
* = TYPE_COMPLEX
;
38 abi
* ["ffi_abi"] = types
.int
; (* !!! enum *)
39 status
* ["ffi_status"] = types
.int
; (* !!! enum *)
41 (* Ptype* = POINTER [untagged] TO type;
42 PPtype* = POINTER [untagged] TO ARRAY [untagged] OF Ptype; *)
43 type
* ["ffi_type"] = RECORD [untagged
]
44 size
*: sys_types
.size_t
;
45 alignment
*: types
.unsigned_short
;
46 type
*: types
.unsigned_short
;
47 elements
*: POINTER [untagged
] TO ARRAY [untagged
] OF POINTER TO type
;
50 (* Pcif* = POINTER TO cif; *)
51 cif
* ["ffi_cif"] = RECORD [untagged
]
53 nargs
*: types
.unsigned
;
54 arg_type
*: POINTER [untagged
] TO ARRAY [untagged
] OF POINTER TO type
;
55 rtype
*: POINTER TO type
;
56 bytes
*: types
.unsigned
;
57 flags
*: types
.unsigned
;
61 type_void
- ["ffi_type_void"]: type
;
62 type_uint8
- ["ffi_type_uint8"]: type
;
63 type_sint8
- ["ffi_type_sint8"]: type
;
64 type_uint16
- ["ffi_type_uint16"]: type
;
65 type_sint16
- ["ffi_type_sint16"]: type
;
66 type_uint32
- ["ffi_type_uint32"]: type
;
67 type_sint32
- ["ffi_type_sint32"]: type
;
68 type_uint64
- ["ffi_type_uint64"]: type
;
69 type_sint64
- ["ffi_type_sint64"]: type
;
70 type_float
- ["ffi_type_float"]: type
;
71 type_double
- ["ffi_type_double"]: type
;
72 type_pointer
- ["ffi_type_pointer"]: type
;
73 type_longdouble
- ["ffi_type_longdouble"]: type
;
75 type_complex_single
- ["ffi_type_complex_single"]: type
;
76 type_complex_double
- ["ffi_type_complex_double"]: type
;
77 type_complex_longdouble
- ["ffi_type_complex_longdouble"]: type
;
79 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
;
80 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
;
81 PROCEDURE [ccall
] call
* ["ffi_call"] (VAR c
: cif
; fn
, rvalue
, avalue
: INTEGER);