Damien | d99b052 | 2013-12-21 18:17:45 +0000 | [diff] [blame^] | 1 | #include <stdlib.h> |
| 2 | #include <stdint.h> |
| 3 | |
| 4 | #include "nlr.h" |
| 5 | #include "misc.h" |
| 6 | #include "mpconfig.h" |
| 7 | #include "obj.h" |
| 8 | |
| 9 | typedef struct _mp_obj_none_t { |
| 10 | mp_obj_base_t base; |
| 11 | } mp_obj_none_t; |
| 12 | |
| 13 | void none_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t self_in) { |
| 14 | print(env, "None"); |
| 15 | } |
| 16 | |
| 17 | const mp_obj_type_t none_type = { |
| 18 | { &mp_const_type }, |
| 19 | "NoneType", |
| 20 | none_print, // print |
| 21 | NULL, // call_n |
| 22 | NULL, // unary_op |
| 23 | NULL, // binary_op |
| 24 | NULL, // getiter |
| 25 | NULL, // iternext |
| 26 | {{NULL, NULL},}, // method list |
| 27 | }; |
| 28 | |
| 29 | static const mp_obj_none_t none_obj = {{&none_type}}; |
| 30 | const mp_obj_t mp_const_none = (mp_obj_t)&none_obj; |
| 31 | |
| 32 | // the stop-iteration object just needs to be something unique |
| 33 | // it's not the StopIteration exception |
| 34 | static const mp_obj_none_t stop_it_obj = {{&none_type}}; |
| 35 | const mp_obj_t mp_const_stop_iteration = (mp_obj_t)&stop_it_obj; |