Skip to content
Snippets Groups Projects
Commit 91fc075a authored by Paul Sokolovsky's avatar Paul Sokolovsky
Browse files

py/objarray: Allow to create array of void pointers, as extension to CPython.

Using 'P' format specifier (matches struct module). This is another shortcut
for FFI, just as previously introduced "array of objects" ('O').
parent 3aa7dd23
No related branches found
No related tags found
Loading
...@@ -145,6 +145,9 @@ mp_obj_t mp_binary_get_val_array(char typecode, void *p, mp_uint_t index) { ...@@ -145,6 +145,9 @@ mp_obj_t mp_binary_get_val_array(char typecode, void *p, mp_uint_t index) {
// Extension to CPython: array of objects // Extension to CPython: array of objects
case 'O': case 'O':
return ((mp_obj_t*)p)[index]; return ((mp_obj_t*)p)[index];
// Extension to CPython: array of pointers
case 'P':
return mp_obj_new_int((mp_int_t)((void**)p)[index]);
} }
return MP_OBJ_NEW_SMALL_INT(val); return MP_OBJ_NEW_SMALL_INT(val);
} }
...@@ -369,5 +372,8 @@ void mp_binary_set_val_array_from_int(char typecode, void *p, mp_uint_t index, m ...@@ -369,5 +372,8 @@ void mp_binary_set_val_array_from_int(char typecode, void *p, mp_uint_t index, m
((double*)p)[index] = val; ((double*)p)[index] = val;
break; break;
#endif #endif
// Extension to CPython: array of pointers
case 'P':
((void**)p)[index] = (void*)val;
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment