@@ -430,11 +430,11 @@ void *reverce_memcpy(void *dest, const void *src, size_t len) {
430
430
return dest ;
431
431
}
432
432
433
- mp_obj_t mp_obj_integer_from_bytes_impl (bool big_endian , bool signd , size_t len , const byte * buf ) {
433
+ mp_obj_t mp_obj_integer_from_bytes_impl (bool big_endian , bool is_signed , size_t len , const byte * buf ) {
434
434
if (len > sizeof (mp_int_t )) {
435
435
#if MICROPY_LONGINT_IMPL != MICROPY_LONGINT_IMPL_NONE
436
436
// Result will overflow a small-int size so construct a big-int
437
- return mp_obj_int_from_bytes_impl (big_endian , signd , len , buf );
437
+ return mp_obj_int_from_bytes_impl (big_endian , is_signed , len , buf );
438
438
#else
439
439
mp_raise_msg (& mp_type_OverflowError , MP_ERROR_TEXT ("small-int overflow" ));
440
440
#endif
@@ -454,7 +454,7 @@ mp_obj_t mp_obj_integer_from_bytes_impl(bool big_endian, bool signd, size_t len,
454
454
memcpy (& result , buf , len );
455
455
}
456
456
457
- if ((signd ) && (sizeof (result ) > len ) && (result .buf [len - 1 ] & 0x80 )) {
457
+ if ((is_signed ) && (sizeof (result ) > len ) && (result .buf [len - 1 ] & 0x80 )) {
458
458
// Sign propagation in little-endian
459
459
// x = 2
460
460
// x.to_bytes(1, 'little', True) -> b'\x02'
@@ -476,13 +476,13 @@ mp_obj_t mp_obj_integer_from_bytes_impl(bool big_endian, bool signd, size_t len,
476
476
}
477
477
debug_printf ("" );
478
478
}
479
- // debug_printf("big_endian:%d signed:%d len:%d sizeof(result):%d result.value:%ld=0x%X", big_endian, signd , len, sizeof(result), result.value, result.value);
479
+ // debug_printf("big_endian:%d signed:%d len:%d sizeof(result):%d result.value:%ld=0x%X", big_endian, is_signed , len, sizeof(result), result.value, result.value);
480
480
debug_printf ("MP_SMALL_INT_MAX=%d=0x%X, MP_SMALL_INT_MIN=%d=0x%X, MP_SMALL_INT_POSITIVE_MASK=%d=0x%X" , MP_SMALL_INT_MAX , MP_SMALL_INT_MAX , MP_SMALL_INT_MIN , MP_SMALL_INT_MIN , MP_SMALL_INT_POSITIVE_MASK , MP_SMALL_INT_POSITIVE_MASK );
481
481
// debug_printf("(MP_SMALL_INT_MAX << 1) + 1=%d=0x%X", (MP_SMALL_INT_MAX << 1) + 1, (MP_SMALL_INT_MAX << 1) + 1);
482
- if (((!signd ) && (result .uvalue > MP_SMALL_INT_MAX )) || (signd && ((result .value < MP_SMALL_INT_MIN ) || (result .value > MP_SMALL_INT_MAX )))) {
482
+ if (((!is_signed ) && (result .uvalue > MP_SMALL_INT_MAX )) || (is_signed && ((result .value < MP_SMALL_INT_MIN ) || (result .value > MP_SMALL_INT_MAX )))) {
483
483
// Result will overflow a small-int so construct a big-int
484
484
#if MICROPY_LONGINT_IMPL != MICROPY_LONGINT_IMPL_NONE
485
- return mp_obj_int_from_bytes_impl (big_endian , signd , len , buf );
485
+ return mp_obj_int_from_bytes_impl (big_endian , is_signed , len , buf );
486
486
#else
487
487
mp_raise_msg (& mp_type_OverflowError , MP_ERROR_TEXT ("small-int overflow" ));
488
488
#endif
@@ -497,9 +497,9 @@ static mp_obj_t int_from_bytes(size_t n_args, const mp_obj_t *args) {
497
497
mp_buffer_info_t bufinfo ;
498
498
mp_get_buffer_raise (args [1 ], & bufinfo , MP_BUFFER_READ );
499
499
bool big_endian = n_args < 3 || args [2 ] != MP_OBJ_NEW_QSTR (MP_QSTR_little );
500
- bool signd = (n_args > 3 ) && mp_obj_is_true (args [3 ]);
500
+ bool is_signed = (n_args > 3 ) && mp_obj_is_true (args [3 ]);
501
501
502
- return mp_obj_integer_from_bytes_impl (big_endian , signd , bufinfo .len , bufinfo .buf );
502
+ return mp_obj_integer_from_bytes_impl (big_endian , is_signed , bufinfo .len , bufinfo .buf );
503
503
}
504
504
505
505
static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN (int_from_bytes_fun_obj , 2 , 4 , int_from_bytes ) ;
0 commit comments