py: Change mp_print_strn_t func type to use size_t for the str length.

This commit is contained in:
Damien George 2015-11-27 12:19:25 +00:00
parent fad7d9317b
commit 4e7107a572
6 changed files with 10 additions and 10 deletions

View File

@ -92,7 +92,7 @@ typedef struct _strn_print_env_t {
size_t remain;
} strn_print_env_t;
STATIC void strn_print_strn(void *data, const char *str, mp_uint_t len) {
STATIC void strn_print_strn(void *data, const char *str, size_t len) {
strn_print_env_t *strn_print_env = data;
if (len > strn_print_env->remain) {
len = strn_print_env->remain;

View File

@ -606,8 +606,8 @@ void mp_raw_code_save(mp_raw_code_t *rc, mp_print_t *print) {
#include <sys/stat.h>
#include <fcntl.h>
STATIC void fd_print_strn(void *env, const char *str, mp_uint_t len) {
int fd = (mp_int_t)env;
STATIC void fd_print_strn(void *env, const char *str, size_t len) {
int fd = (intptr_t)env;
ssize_t ret = write(fd, str, len);
(void)ret;
}

View File

@ -43,7 +43,7 @@
static const char pad_spaces[] = " ";
static const char pad_zeroes[] = "0000000000000000";
STATIC void plat_print_strn(void *env, const char *str, mp_uint_t len) {
STATIC void plat_print_strn(void *env, const char *str, size_t len) {
(void)env;
MP_PLAT_PRINT_STRN(str, len);
}
@ -51,14 +51,14 @@ STATIC void plat_print_strn(void *env, const char *str, mp_uint_t len) {
const mp_print_t mp_plat_print = {NULL, plat_print_strn};
int mp_print_str(const mp_print_t *print, const char *str) {
mp_uint_t len = strlen(str);
size_t len = strlen(str);
if (len) {
print->print_strn(print->data, str, len);
}
return len;
}
int mp_print_strn(const mp_print_t *print, const char *str, mp_uint_t len, int flags, char fill, int width) {
int mp_print_strn(const mp_print_t *print, const char *str, size_t len, int flags, char fill, int width) {
int left_pad = 0;
int right_pad = 0;
int pad = width - len;

View File

@ -39,7 +39,7 @@
#define PF_FLAG_ADD_PERCENT (0x100)
#define PF_FLAG_SHOW_OCTAL_LETTER (0x200)
typedef void (*mp_print_strn_t)(void *data, const char *str, mp_uint_t len);
typedef void (*mp_print_strn_t)(void *data, const char *str, size_t len);
typedef struct _mp_print_t {
void *data;
@ -55,7 +55,7 @@ extern const mp_print_t mp_sys_stdout_print;
#endif
int mp_print_str(const mp_print_t *print, const char *str);
int mp_print_strn(const mp_print_t *print, const char *str, mp_uint_t len, int flags, char fill, int width);
int mp_print_strn(const mp_print_t *print, const char *str, size_t len, int flags, char fill, int width);
#if MICROPY_PY_BUILTINS_FLOAT
int mp_print_float(const mp_print_t *print, mp_float_t f, char fmt, int flags, char fill, int width, int prec);
#endif

View File

@ -174,7 +174,7 @@ STATIC mp_obj_t stream_read(mp_uint_t n_args, const mp_obj_t *args) {
}
}
mp_obj_t mp_stream_write(mp_obj_t self_in, const void *buf, mp_uint_t len) {
mp_obj_t mp_stream_write(mp_obj_t self_in, const void *buf, size_t len) {
struct _mp_obj_base_t *o = (struct _mp_obj_base_t *)self_in;
if (o->type->stream_p == NULL || o->type->stream_p->write == NULL) {
// CPython: io.UnsupportedOperation, OSError subclass

View File

@ -40,7 +40,7 @@ MP_DECLARE_CONST_FUN_OBJ(mp_stream_tell_obj);
// Iterator which uses mp_stream_unbuffered_readline_obj
mp_obj_t mp_stream_unbuffered_iter(mp_obj_t self);
mp_obj_t mp_stream_write(mp_obj_t self_in, const void *buf, mp_uint_t len);
mp_obj_t mp_stream_write(mp_obj_t self_in, const void *buf, size_t len);
#if MICROPY_STREAMS_NON_BLOCK
// TODO: This is POSIX-specific (but then POSIX is the only real thing,