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

objarray: Support array('O'), array of objects, as extension to CPython.

Might be useful at least for memoryview hacks.
parent 16b1f5e8
No related branches found
No related tags found
No related merge requests found
...@@ -141,6 +141,9 @@ mp_obj_t mp_binary_get_val_array(char typecode, void *p, mp_uint_t index) { ...@@ -141,6 +141,9 @@ mp_obj_t mp_binary_get_val_array(char typecode, void *p, mp_uint_t index) {
case 'd': case 'd':
return mp_obj_new_float(((double*)p)[index]); return mp_obj_new_float(((double*)p)[index]);
#endif #endif
// Extension to CPython: array of objects
case 'O':
return ((mp_obj_t*)p)[index];
} }
return MP_OBJ_NEW_SMALL_INT(val); return MP_OBJ_NEW_SMALL_INT(val);
} }
...@@ -300,6 +303,10 @@ void mp_binary_set_val_array(char typecode, void *p, mp_uint_t index, mp_obj_t v ...@@ -300,6 +303,10 @@ void mp_binary_set_val_array(char typecode, void *p, mp_uint_t index, mp_obj_t v
((double*)p)[index] = mp_obj_get_float(val_in); ((double*)p)[index] = mp_obj_get_float(val_in);
break; break;
#endif #endif
// Extension to CPython: array of objects
case 'O':
((mp_obj_t*)p)[index] = val_in;
break;
default: default:
mp_binary_set_val_array_from_int(typecode, p, index, mp_obj_get_int(val_in)); mp_binary_set_val_array_from_int(typecode, p, index, mp_obj_get_int(val_in));
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment