Commit 530d7016 authored by Damien George's avatar Damien George

py: Switch to use #if instead of if-stmt for JSON printing config.

parent 7b378cb1
......@@ -35,13 +35,19 @@ typedef struct _mp_obj_bool_t {
STATIC void bool_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
mp_obj_bool_t *self = MP_OBJ_TO_PTR(self_in);
if (MICROPY_PY_UJSON && kind == PRINT_JSON) {
#if MICROPY_PY_UJSON
if (kind == PRINT_JSON) {
if (self->value) {
mp_print_str(print, "true");
} else {
mp_print_str(print, "false");
}
} else {
return;
}
#else
(void)kind;
#endif
{
if (self->value) {
mp_print_str(print, "True");
} else {
......
......@@ -55,7 +55,10 @@ STATIC mp_map_elem_t *dict_iter_next(mp_obj_dict_t *dict, size_t *cur) {
STATIC void dict_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
mp_obj_dict_t *self = MP_OBJ_TO_PTR(self_in);
bool first = true;
if (!(MICROPY_PY_UJSON && kind == PRINT_JSON)) {
#if MICROPY_PY_UJSON
if (kind != PRINT_JSON)
#endif
{
kind = PRINT_REPR;
}
if (MICROPY_PY_COLLECTIONS_ORDEREDDICT && self->base.type != &mp_type_dict) {
......
......@@ -44,7 +44,10 @@ STATIC mp_obj_t list_pop(size_t n_args, const mp_obj_t *args);
STATIC void list_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) {
mp_obj_list_t *o = MP_OBJ_TO_PTR(o_in);
if (!(MICROPY_PY_UJSON && kind == PRINT_JSON)) {
#if MICROPY_PY_UJSON
if (kind != PRINT_JSON)
#endif
{
kind = PRINT_REPR;
}
mp_print_str(print, "[");
......
......@@ -34,9 +34,14 @@ typedef struct _mp_obj_none_t {
STATIC void none_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
(void)self_in;
if (MICROPY_PY_UJSON && kind == PRINT_JSON) {
#if MICROPY_PY_UJSON
if (kind == PRINT_JSON) {
mp_print_str(print, "null");
} else {
} else
#else
(void)kind;
#endif
{
mp_print_str(print, "None");
}
}
......
......@@ -35,9 +35,12 @@
void mp_obj_tuple_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) {
mp_obj_tuple_t *o = MP_OBJ_TO_PTR(o_in);
if (MICROPY_PY_UJSON && kind == PRINT_JSON) {
#if MICROPY_PY_UJSON
if (kind == PRINT_JSON) {
mp_print_str(print, "[");
} else {
} else
#endif
{
mp_print_str(print, "(");
kind = PRINT_REPR;
}
......@@ -47,9 +50,12 @@ void mp_obj_tuple_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t
}
mp_obj_print_helper(print, o->items[i], kind);
}
if (MICROPY_PY_UJSON && kind == PRINT_JSON) {
#if MICROPY_PY_UJSON
if (kind == PRINT_JSON) {
mp_print_str(print, "]");
} else {
} else
#endif
{
if (o->len == 1) {
mp_print_str(print, ",");
}
......
Markdown is supported
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