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", |
Paul Sokolovsky | 860ffb0 | 2014-01-05 22:34:09 +0200 | [diff] [blame] | 20 | .print = none_print, |
| 21 | .methods = {{NULL, NULL},}, |
Damien | d99b052 | 2013-12-21 18:17:45 +0000 | [diff] [blame] | 22 | }; |
| 23 | |
| 24 | static const mp_obj_none_t none_obj = {{&none_type}}; |
| 25 | const mp_obj_t mp_const_none = (mp_obj_t)&none_obj; |
| 26 | |
| 27 | // the stop-iteration object just needs to be something unique |
| 28 | // it's not the StopIteration exception |
| 29 | static const mp_obj_none_t stop_it_obj = {{&none_type}}; |
| 30 | const mp_obj_t mp_const_stop_iteration = (mp_obj_t)&stop_it_obj; |