Update print function

This commit is contained in:
iabdalkader 2015-07-18 07:05:13 +02:00
parent 7fbe54ad4e
commit f34b07f015
4 changed files with 15 additions and 20 deletions

View File

@ -19,7 +19,6 @@
#include "parse.h"
#include "compile.h"
#include "runtime.h"
#include "pfenv.h"
#include "obj.h"
#include "objmodule.h"
#include "gc.h"
@ -336,7 +335,7 @@ soft_reset:
mp_call_function_0(script);
nlr_pop();
} else {
mp_obj_print_exception(printf_wrapper, NULL, (mp_obj_t)nlr.ret_val);
mp_obj_print_exception(&mp_plat_print, (mp_obj_t)nlr.ret_val);
}
pyexec_pop_scope();
}

View File

@ -34,11 +34,11 @@ void *py_cascade_cobj(mp_obj_t cascade)
return &((py_cascade_obj_t *)cascade)->_cobj;
}
static void py_cascade_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t self_in, mp_print_kind_t kind)
static void py_cascade_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind)
{
py_cascade_obj_t *self = self_in;
/* print some info */
print(env, "width:%d height:%d n_stages:%d n_features:%d n_rectangles:%d\n", self->_cobj.window.w,
mp_printf(print, "width:%d height:%d n_stages:%d n_features:%d n_rectangles:%d\n", self->_cobj.window.w,
self->_cobj.window.h, self->_cobj.n_stages, self->_cobj.n_features, self->_cobj.n_rectangles);
}
@ -57,10 +57,10 @@ typedef struct _py_kp_obj_t {
bool normalized;
} py_kp_obj_t;
static void py_kp_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t self_in, mp_print_kind_t kind)
static void py_kp_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind)
{
py_kp_obj_t *self = self_in;
print(env, "size:%d threshold:%d normalized:%d\n", self->size, self->threshold, self->normalized);
mp_printf(print, "size:%d threshold:%d normalized:%d\n", self->size, self->threshold, self->normalized);
}
static const mp_obj_type_t py_kp_type = {
@ -75,9 +75,9 @@ typedef struct _py_lbp_obj_t {
uint8_t *hist;
} py_lbp_obj_t;
static void py_lbp_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t self_in, mp_print_kind_t kind)
static void py_lbp_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind)
{
print(env, "<lbp descriptor>");
mp_printf(print, "<lbp descriptor>");
}
static const mp_obj_type_t py_lbp_type = {
@ -98,10 +98,10 @@ void *py_image_cobj(mp_obj_t image)
return &((py_image_obj_t *)image)->_cobj;
}
static void py_image_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t self_in, mp_print_kind_t kind)
static void py_image_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind)
{
py_image_obj_t *self = self_in;
print(env, "<image width:%d height:%d bpp:%d>", self->_cobj.w, self->_cobj.h, self->_cobj.bpp);
mp_printf(print, "<image width:%d height:%d bpp:%d>", self->_cobj.w, self->_cobj.h, self->_cobj.bpp);
}
static mp_int_t py_image_get_buffer(mp_obj_t self_in, mp_buffer_info_t *bufinfo, mp_uint_t flags) {

View File

@ -151,13 +151,10 @@ static mp_obj_t py_sensor_read_reg(mp_obj_t addr) {
return mp_obj_new_int(SCCB_Read(mp_obj_get_int(addr)));
}
#if 0
static void py_sensor_print(void (*print)(void *env, const char *fmt, ...),
void *env, mp_obj_t self_in, mp_print_kind_t kind) {
// printf(env, "<Sensor MID:0x%.2X%.2X PID:0x%.2X VER:0x%.2X>",
// sensor.id.MIDH, sensor.id.MIDL, sensor.id.PID, sensor.id.VER);
}
#endif
//static void py_sensor_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
// mp_printf(print, "<Sensor MID:0x%.2X%.2X PID:0x%.2X VER:0x%.2X>",
// sensor.id.MIDH, sensor.id.MIDL, sensor.id.PID, sensor.id.VER);
//}
STATIC MP_DEFINE_CONST_FUN_OBJ_0(py_sensor_reset_obj, py_sensor_reset);
STATIC MP_DEFINE_CONST_FUN_OBJ_0(py_sensor_snapshot_obj, py_sensor_snapshot);

View File

@ -46,13 +46,12 @@ mp_obj_t py_clock_reset(py_clock_obj_t *clock)
return mp_const_none;
}
static void py_clock_print(void (*print)(void *env, const char *fmt, ...),
void *env, mp_obj_t self_in, mp_print_kind_t kind)
static void py_clock_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind)
{
py_clock_obj_t *self = self_in;
/* print some info */
print(env, "t_start:%d t_ticks:%d t_frame:%d\n",
mp_printf(print, "t_start:%d t_ticks:%d t_frame:%d\n",
self->t_start, self->t_ticks, self->t_frame);
}