DEADSOFTWARE

add osx-ppc support via cpfront
[cpc.git] / src / cpfront / osx / powerpc / Lib / Mod / FFI.cp
1 MODULE LibFFI ["ffi/ffi.h"];
3 IMPORT SYSTEM, types := PosixCtypes, sys_types := PosixCsys_types;
5 CONST
6 SIZEOF_ARG* = 4;
8 CONST (* abi *)
9 FIRST_ABI* = 0;
10 AIX* = 1;
11 DARWIN* = 2;
12 DEFAULT_ABI* = DARWIN;
13 LAST_ABI* = DEFAULT_ABI + 1;
15 CONST (* status *)
16 OK* = 0; BAD_TYPEDEF* = 1; BAD_ABI* = 2;
18 CONST
19 TYPE_VOID* = 0;
20 TYPE_INT* = 1;
21 TYPE_FLOAT* = 2;
22 TYPE_DOUBLE* = 3;
23 TYPE_LONGDOUBLE* = 4;
24 TYPE_UINT8* = 5;
25 TYPE_SINT8* = 6;
26 TYPE_UINT16* = 7;
27 TYPE_SINT16* = 8;
28 TYPE_UINT32* = 9;
29 TYPE_SINT32* = 10;
30 TYPE_UINT64* = 11;
31 TYPE_SINT64* = 12;
32 TYPE_STRUCT* = 13;
33 TYPE_POINTER* = 14;
34 TYPE_COMPLEX* = 15;
35 TYPE_LAST* = TYPE_COMPLEX;
37 TYPE
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;
48 END;
50 (* Pcif* = POINTER TO cif; *)
51 cif* ["ffi_cif"] = RECORD [untagged]
52 abi*: abi;
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;
58 END;
60 VAR
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);
83 END LibFFI.