Debian Codegraph @

xs/names.c

raw
1 #include "ffi_platypus.h"
2 #include <stdio.h>
3
4 ffi_type *
5 ffi_pl_type_to_libffi_type(ffi_pl_type *type)
6 {
7 int type_code = type->type_code;
8 if((type_code & FFI_PL_SHAPE_MASK) == FFI_PL_SHAPE_CUSTOM_PERL)
9 type_code = type_code & ~(FFI_PL_SHAPE_MASK);
10 if((type_code & FFI_PL_SHAPE_MASK) == FFI_PL_SHAPE_OBJECT)
11 type_code = type_code & ~(FFI_PL_SHAPE_MASK);
12 switch(type_code)
13 {
14 case FFI_PL_TYPE_VOID:
15 return &ffi_type_void;
16 case FFI_PL_TYPE_SINT8:
17 return &ffi_type_sint8;
18 case FFI_PL_TYPE_SINT16:
19 return &ffi_type_sint16;
20 case FFI_PL_TYPE_SINT32:
21 return &ffi_type_sint32;
22 case FFI_PL_TYPE_SINT64:
23 return &ffi_type_sint64;
24 case FFI_PL_TYPE_UINT8:
25 return &ffi_type_uint8;
26 case FFI_PL_TYPE_UINT16:
27 return &ffi_type_uint16;
28 case FFI_PL_TYPE_UINT32:
29 return &ffi_type_uint32;
30 case FFI_PL_TYPE_UINT64:
31 return &ffi_type_uint64;
32 case FFI_PL_TYPE_FLOAT:
33 return &ffi_type_float;
34 case FFI_PL_TYPE_DOUBLE:
35 return &ffi_type_double;
36 #ifdef FFI_PL_PROBE_LONGDOUBLE
37 case FFI_PL_TYPE_LONG_DOUBLE:
38 return &ffi_type_longdouble;
39 #endif
40 #if FFI_PL_PROBE_COMPLEX
41 case FFI_PL_TYPE_COMPLEX_FLOAT:
42 return &ffi_type_complex_float;
43 case FFI_PL_TYPE_COMPLEX_DOUBLE:
44 return &ffi_type_complex_double;
45 #endif
46 case FFI_PL_TYPE_OPAQUE:
47 case FFI_PL_TYPE_STRING:
48 case FFI_PL_TYPE_CLOSURE:
49 case FFI_PL_TYPE_RECORD:
50 return &ffi_type_pointer;
51 case FFI_PL_TYPE_RECORD_VALUE:
52 return type->extra[0].record.meta != NULL ? &type->extra[0].record.meta->ffi_type : NULL;
53 }
54 switch(type_code & (FFI_PL_SHAPE_MASK))
55 {
56 case FFI_PL_SHAPE_POINTER:
57 case FFI_PL_SHAPE_ARRAY:
58 return &ffi_type_pointer;
59 default:
60 fprintf(stderr, "FFI::Platypus: internal error: type = %04x\n", type_code);
61 fflush(stderr);
62 return NULL;
63 }
64 }