objnone.c 760 Bytes
Newer Older
1
2
#include <stdlib.h>

3
#include "mpconfig.h"
4
5
#include "nlr.h"
#include "misc.h"
6
#include "qstr.h"
7
#include "obj.h"
8
#include "runtime0.h"
9
10
11
12
13

typedef struct _mp_obj_none_t {
    mp_obj_base_t base;
} mp_obj_none_t;

14
STATIC void none_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t self_in, mp_print_kind_t kind) {
15
16
17
    print(env, "None");
}

18
STATIC mp_obj_t none_unary_op(int op, mp_obj_t o_in) {
19
    switch (op) {
Damien George's avatar
Damien George committed
20
        case MP_UNARY_OP_BOOL: return mp_const_false;
21
        default: return MP_OBJ_NOT_SUPPORTED;
22
23
24
    }
}

25
const mp_obj_type_t mp_type_NoneType = {
26
    { &mp_type_type },
27
    .name = MP_QSTR_NoneType,
28
    .print = none_print,
29
    .unary_op = none_unary_op,
30
31
};

32
const mp_obj_none_t mp_const_none_obj = {{&mp_type_NoneType}};