Skip to content

Commit 88972b0

Browse files
committed
modffi: Describe typecodes where they differ from used by struct module.
Exact behavior of typecodes may be not yet enforced.
1 parent ca045d9 commit 88972b0

1 file changed

Lines changed: 18 additions & 2 deletions

File tree

unix/modffi.c

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,22 @@
1212
#include "runtime.h"
1313
#include "binary.h"
1414

15+
/*
16+
* modffi uses character codes to encode a value type, based on "struct"
17+
* module type codes, with some extensions and overridings.
18+
*
19+
* Extra/overridden typecodes:
20+
* v - void, can be used only as return type
21+
* P - const void*, pointer to read-only memory
22+
* p - void*, meaning pointer to a writable memory (note that this
23+
* clashes with struct's "p" as "Pascal string").
24+
* s - as argument, the same as "p", as return value, causes string
25+
* to be allocated and returned, instead of pointer value.
26+
*
27+
* Note: all constraint specified by typecode can be not enforced at this time,
28+
* but may be later.
29+
*/
30+
1531
typedef struct _mp_obj_opaque_t {
1632
mp_obj_base_t base;
1733
void *val;
@@ -63,8 +79,8 @@ STATIC ffi_type *char2ffi_type(char c)
6379
case 'L': return &ffi_type_ulong;
6480
case 'f': return &ffi_type_float;
6581
case 'd': return &ffi_type_double;
66-
case 'p': // Deprecated - conflicts with struct module
67-
case 'P':
82+
case 'P': // const void*
83+
case 'p': // void*
6884
case 's': return &ffi_type_pointer;
6985
case 'v': return &ffi_type_void;
7086
default: return NULL;

0 commit comments

Comments
 (0)