Commit 42f3de92 authored by Damien George's avatar Damien George
Browse files

py: Convert [u]int to mp_[u]int_t where appropriate.

Addressing issue #50.
parent 877dba3e
......@@ -38,12 +38,12 @@
typedef struct _pfenv_t {
void *data;
void (*print_strn)(void *, const char *str, unsigned int len);
void (*print_strn)(void *, const char *str, mp_uint_t len);
} pfenv_t;
void pfenv_vstr_add_strn(void *data, const char *str, unsigned int len);
void pfenv_vstr_add_strn(void *data, const char *str, mp_uint_t len);
int pfenv_print_strn(const pfenv_t *pfenv, const char *str, unsigned int len, int flags, char fill, int width);
int pfenv_print_strn(const pfenv_t *pfenv, const char *str, mp_uint_t len, int flags, char fill, int width);
int pfenv_print_int(const pfenv_t *pfenv, mp_uint_t x, int sgn, int base, int base_char, int flags, char fill, int width);
int pfenv_print_mp_int(const pfenv_t *pfenv, mp_obj_t x, int sgn, int base, int base_char, int flags, char fill, int width, int prec);
#if MICROPY_PY_BUILTINS_FLOAT
......
......@@ -31,7 +31,7 @@
#if MICROPY_HELPER_REPL
bool str_startswith_word(const char *str, const char *head) {
int i;
mp_uint_t i;
for (i = 0; str[i] && head[i]; i++) {
if (str[i] != head[i]) {
return false;
......
......@@ -44,7 +44,7 @@
// Implements backend of sequence * integer operation. Assumes elements are
// memory-adjacent in sequence.
void mp_seq_multiply(const void *items, mp_uint_t item_sz, mp_uint_t len, mp_uint_t times, void *dest) {
for (int i = 0; i < times; i++) {
for (mp_uint_t i = 0; i < times; i++) {
uint copy_sz = item_sz * len;
memcpy(dest, items, copy_sz);
dest = (char*)dest + copy_sz;
......@@ -185,8 +185,8 @@ bool mp_seq_cmp_objs(mp_uint_t op, const mp_obj_t *items1, mp_uint_t len1, const
}
}
int len = len1 < len2 ? len1 : len2;
for (int i = 0; i < len; i++) {
mp_uint_t len = len1 < len2 ? len1 : len2;
for (mp_uint_t i = 0; i < len; i++) {
// If current elements equal, can't decide anything - go on
if (mp_obj_equal(items1[i], items2[i])) {
continue;
......
......@@ -57,9 +57,7 @@
ip += sizeof(mp_uint_t); \
} while (0)
void mp_bytecode_print2(const byte *ip, int len);
void mp_bytecode_print(const void *descr, const byte *ip, int len) {
void mp_bytecode_print(const void *descr, const byte *ip, mp_uint_t len) {
const byte *ip_start = ip;
// get code info size
......@@ -115,14 +113,13 @@ void mp_bytecode_print(const void *descr, const byte *ip, int len) {
mp_bytecode_print2(ip, len - 0);
}
void mp_bytecode_print2(const byte *ip, int len) {
void mp_bytecode_print2(const byte *ip, mp_uint_t len) {
const byte *ip_start = ip;
mp_uint_t unum;
qstr qstr;
while (ip - ip_start < len) {
printf("%02u ", (uint)(ip - ip_start));
int op = *ip++;
switch (op) {
switch (*ip++) {
case MP_BC_LOAD_CONST_FALSE:
printf("LOAD_CONST_FALSE");
break;
......@@ -520,7 +517,7 @@ void mp_bytecode_print2(const byte *ip, int len) {
break;
default:
printf("code %p, byte code 0x%02x not implemented\n", ip, op);
printf("code %p, byte code 0x%02x not implemented\n", ip, ip[-1]);
assert(0);
return;
}
......
......@@ -263,24 +263,6 @@ copy:
vstr->buf[vstr->len] = 0;
}
/*
void vstr_add_le16(vstr_t *vstr, unsigned short v) {
byte *buf = (byte*)vstr_add_len(vstr, 2);
if (buf == NULL) {
return;
}
encode_le16(buf, v);
}
void vstr_add_le32(vstr_t *vstr, unsigned int v) {
byte *buf = (byte*)vstr_add_len(vstr, 4);
if (buf == NULL) {
return;
}
encode_le32(buf, v);
}
*/
char *vstr_ins_blank_bytes(vstr_t *vstr, size_t byte_pos, size_t byte_len) {
if (vstr->had_error) {
return NULL;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment