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