blob: cba1980579acae2fb4aa0cc584ec9a9ff5f8def6 [file] [log] [blame]
Damiend99b0522013-12-21 18:17:45 +00001#include <stdlib.h>
2#include <stdint.h>
3#include <assert.h>
4
5#include "nlr.h"
6#include "misc.h"
7#include "mpconfig.h"
8#include "obj.h"
9#include "runtime.h"
10
11typedef struct _mp_obj_cell_t {
12 mp_obj_base_t base;
13 mp_obj_t obj;
14} mp_obj_cell_t;
15
16mp_obj_t mp_obj_cell_get(mp_obj_t self_in) {
17 mp_obj_cell_t *self = self_in;
18 return self->obj;
19}
20
21void mp_obj_cell_set(mp_obj_t self_in, mp_obj_t obj) {
22 mp_obj_cell_t *self = self_in;
23 self->obj = obj;
24}
25
26const mp_obj_type_t cell_type = {
27 { &mp_const_type },
28 "cell",
29 NULL, // print
30 NULL, // call_n
31 NULL, // unary_op
32 NULL, // binary_op
33 NULL, // getiter
34 NULL, // iternext
35 {{NULL, NULL},}, // method list
36};
37
38mp_obj_t mp_obj_new_cell(mp_obj_t obj) {
39 mp_obj_cell_t *o = m_new_obj(mp_obj_cell_t);
40 o->base.type = &cell_type;
41 o->obj = obj;
42 return o;
43}