@@ -57,8 +57,10 @@ size_t mp_binary_get_size(char struct_type, char val_type, mp_uint_t *palign) {
5757 size = 4 ; break ;
5858 case 'q' : case 'Q' :
5959 size = 8 ; break ;
60+ #if MICROPY_NONSTANDARD_TYPECODES
6061 case 'P' : case 'O' : case 'S' :
6162 size = sizeof (void * ); break ;
63+ #endif
6264 case 'f' :
6365 size = sizeof (float ); break ;
6466 case 'd' :
@@ -89,9 +91,11 @@ size_t mp_binary_get_size(char struct_type, char val_type, mp_uint_t *palign) {
8991 case 'q' : case 'Q' :
9092 align = alignof(long long );
9193 size = sizeof (long long ); break ;
94+ #if MICROPY_NONSTANDARD_TYPECODES
9295 case 'P' : case 'O' : case 'S' :
9396 align = alignof(void * );
9497 size = sizeof (void * ); break ;
98+ #endif
9599 case 'f' :
96100 align = alignof(float );
97101 size = sizeof (float ); break ;
@@ -148,12 +152,14 @@ mp_obj_t mp_binary_get_val_array(char typecode, void *p, mp_uint_t index) {
148152 case 'd' :
149153 return mp_obj_new_float (((double * )p )[index ]);
150154#endif
155+ #if MICROPY_NONSTANDARD_TYPECODES
151156 // Extension to CPython: array of objects
152157 case 'O' :
153158 return ((mp_obj_t * )p )[index ];
154159 // Extension to CPython: array of pointers
155160 case 'P' :
156161 return mp_obj_new_int ((mp_int_t )(uintptr_t )((void * * )p )[index ]);
162+ #endif
157163 }
158164 return MP_OBJ_NEW_SMALL_INT (val );
159165}
@@ -202,11 +208,13 @@ mp_obj_t mp_binary_get_val(char struct_type, char val_type, byte **ptr) {
202208
203209 long long val = mp_binary_get_int (size , is_signed (val_type ), (struct_type == '>' ), p );
204210
205- if (val_type == 'O' ) {
211+ if (MICROPY_NONSTANDARD_TYPECODES && ( val_type == 'O' ) ) {
206212 return (mp_obj_t )(mp_uint_t )val ;
213+ #if MICROPY_NONSTANDARD_TYPECODES
207214 } else if (val_type == 'S' ) {
208215 const char * s_val = (const char * )(uintptr_t )(mp_uint_t )val ;
209216 return mp_obj_new_str (s_val , strlen (s_val ), false);
217+ #endif
210218#if MICROPY_PY_BUILTINS_FLOAT
211219 } else if (val_type == 'f' ) {
212220 union { uint32_t i ; float f ; } fpu = {val };
@@ -267,9 +275,11 @@ void mp_binary_set_val(char struct_type, char val_type, mp_obj_t val_in, byte **
267275
268276 mp_uint_t val ;
269277 switch (val_type ) {
278+ #if MICROPY_NONSTANDARD_TYPECODES
270279 case 'O' :
271280 val = (mp_uint_t )val_in ;
272281 break ;
282+ #endif
273283#if MICROPY_PY_BUILTINS_FLOAT
274284 case 'f' : {
275285 union { uint32_t i ; float f ; } fp_sp ;
@@ -324,10 +334,12 @@ void mp_binary_set_val_array(char typecode, void *p, mp_uint_t index, mp_obj_t v
324334 ((double * )p )[index ] = mp_obj_get_float (val_in );
325335 break ;
326336#endif
337+ #if MICROPY_NONSTANDARD_TYPECODES
327338 // Extension to CPython: array of objects
328339 case 'O' :
329340 ((mp_obj_t * )p )[index ] = val_in ;
330341 break ;
342+ #endif
331343 default :
332344 #if MICROPY_LONGINT_IMPL != MICROPY_LONGINT_IMPL_NONE
333345 if (MP_OBJ_IS_TYPE (val_in , & mp_type_int )) {
@@ -384,9 +396,11 @@ void mp_binary_set_val_array_from_int(char typecode, void *p, mp_uint_t index, m
384396 ((double * )p )[index ] = val ;
385397 break ;
386398#endif
399+ #if MICROPY_NONSTANDARD_TYPECODES
387400 // Extension to CPython: array of pointers
388401 case 'P' :
389402 ((void * * )p )[index ] = (void * )(uintptr_t )val ;
390403 break ;
404+ #endif
391405 }
392406}
0 commit comments