Skip to content

Commit 6d5e840

Browse files
committed
py/objint: Rename signd to is_signed.
According to the micropython#16311. Signed-off-by: Ihor Nehrutsa <Ihor.Nehrutsa@gmail.com>
1 parent 9957726 commit 6d5e840

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

py/objint.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -430,11 +430,11 @@ void *reverce_memcpy(void *dest, const void *src, size_t len) {
430430
return dest;
431431
}
432432

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) {
434434
if (len > sizeof(mp_int_t)) {
435435
#if MICROPY_LONGINT_IMPL != MICROPY_LONGINT_IMPL_NONE
436436
// 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);
438438
#else
439439
mp_raise_msg(&mp_type_OverflowError, MP_ERROR_TEXT("small-int overflow"));
440440
#endif
@@ -454,7 +454,7 @@ mp_obj_t mp_obj_integer_from_bytes_impl(bool big_endian, bool signd, size_t len,
454454
memcpy(&result, buf, len);
455455
}
456456

457-
if ((signd) && (sizeof(result) > len) && (result.buf[len - 1] & 0x80)) {
457+
if ((is_signed) && (sizeof(result) > len) && (result.buf[len - 1] & 0x80)) {
458458
// Sign propagation in little-endian
459459
// x = 2
460460
// 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,
476476
}
477477
debug_printf("");
478478
}
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);
480480
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);
481481
// 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)))) {
483483
// Result will overflow a small-int so construct a big-int
484484
#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);
486486
#else
487487
mp_raise_msg(&mp_type_OverflowError, MP_ERROR_TEXT("small-int overflow"));
488488
#endif
@@ -497,9 +497,9 @@ static mp_obj_t int_from_bytes(size_t n_args, const mp_obj_t *args) {
497497
mp_buffer_info_t bufinfo;
498498
mp_get_buffer_raise(args[1], &bufinfo, MP_BUFFER_READ);
499499
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]);
501501

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);
503503
}
504504

505505
static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(int_from_bytes_fun_obj, 2, 4, int_from_bytes);

py/objint.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ char *mp_obj_int_formatted(char **buf, size_t *buf_size, size_t *fmt_size, mp_co
5454
char *mp_obj_int_formatted_impl(char **buf, size_t *buf_size, size_t *fmt_size, mp_const_obj_t self_in,
5555
int base, const char *prefix, char base_char, char comma);
5656
mp_int_t mp_obj_int_hash(mp_obj_t self_in);
57-
mp_obj_t mp_obj_int_from_bytes_impl(bool big_endian, bool signd, size_t len, const byte *buf);
58-
mp_obj_t mp_obj_integer_from_bytes_impl(bool big_endian, bool signd, size_t len, const byte *buf);
57+
mp_obj_t mp_obj_int_from_bytes_impl(bool big_endian, bool is_signed, size_t len, const byte *buf);
58+
mp_obj_t mp_obj_integer_from_bytes_impl(bool big_endian, bool is_signed, size_t len, const byte *buf);
5959
// Returns true if 'self_in' fit into 'len' bytes of 'buf' without overflowing, 'buf' is truncated otherwise.
6060
bool mp_obj_int_to_bytes_impl(mp_obj_t self_in, bool big_endian, size_t len, byte *buf);
6161
int mp_obj_int_sign(mp_obj_t self_in);

py/objint_longlong.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ mp_obj_t mp_obj_int_from_bytes_impl(bool big_endian, size_t len, const byte *buf
6161
#define debug_printf(...) // mp_printf(&mp_plat_print, __VA_ARGS__); mp_printf(&mp_plat_print, "\n"); // mp_printf(&mp_plat_print, " | func:%s line:%d at %s\n", __FUNCTION__, __LINE__, __FILE__);
6262
#define _debug_printf(...) // mp_printf(&mp_plat_print, __VA_ARGS__);
6363

64-
mp_obj_t mp_obj_int_from_bytes_impl(bool big_endian, bool signd, size_t len, const byte *buf) {
64+
mp_obj_t mp_obj_int_from_bytes_impl(bool big_endian, bool is_signed, size_t len, const byte *buf) {
6565
if (len > sizeof(mp_longint_impl_t)) {
6666
mp_raise_msg(&mp_type_OverflowError, MP_ERROR_TEXT("big-int overflow"));
6767
}
@@ -76,7 +76,7 @@ mp_obj_t mp_obj_int_from_bytes_impl(bool big_endian, bool signd, size_t len, con
7676
memcpy(&result, buf, len);
7777
}
7878

79-
if ((signd) && (sizeof(result) > len) && (result.buf[len - 1] & 0x80)) {
79+
if ((is_signed) && (sizeof(result) > len) && (result.buf[len - 1] & 0x80)) {
8080
// Sign propagation in little-endian
8181
// x = 2
8282
// x.to_bytes(1, 'little', True) -> b'\x02'

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy