From e9906ac3d771a312b05d76e42aee8e806dd0d128 Mon Sep 17 00:00:00 2001 From: Damien George Date: Sat, 4 Jan 2014 18:44:46 +0000 Subject: Add ellipsis object. --- py/objslice.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'py/objslice.c') diff --git a/py/objslice.c b/py/objslice.c index 03607e4c3..d99325fd7 100644 --- a/py/objslice.c +++ b/py/objslice.c @@ -9,6 +9,35 @@ #include "obj.h" #include "runtime0.h" +/******************************************************************************/ +/* ellipsis object, a singleton */ + +typedef struct _mp_obj_ellipsis_t { + mp_obj_base_t base; +} mp_obj_ellipsis_t; + +void ellipsis_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t self_in) { + print(env, "Ellipsis"); +} + +const mp_obj_type_t ellipsis_type = { + { &mp_const_type }, + "ellipsis", + ellipsis_print, // print + NULL, // call_n + NULL, // unary_op + NULL, // binary_op + NULL, // getiter + NULL, // iternext + {{NULL, NULL},}, // method list +}; + +static const mp_obj_ellipsis_t ellipsis_obj = {{&ellipsis_type}}; +const mp_obj_t mp_const_ellipsis = (mp_obj_t)&ellipsis_obj; + +/******************************************************************************/ +/* slice object */ + #if MICROPY_ENABLE_SLICE // TODO: This implements only variant of slice with 2 integer args only. -- cgit v1.2.3 From 71c5181a8dfa69ba9f5ca322a3aba0660be2e166 Mon Sep 17 00:00:00 2001 From: Damien George Date: Sat, 4 Jan 2014 20:21:15 +0000 Subject: Convert Python types to proper Python type hierarchy. Now much more inline with how CPython does types. --- py/objslice.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'py/objslice.c') diff --git a/py/objslice.c b/py/objslice.c index d99325fd7..a624be963 100644 --- a/py/objslice.c +++ b/py/objslice.c @@ -24,6 +24,7 @@ const mp_obj_type_t ellipsis_type = { { &mp_const_type }, "ellipsis", ellipsis_print, // print + NULL, // make_new NULL, // call_n NULL, // unary_op NULL, // binary_op @@ -58,6 +59,7 @@ const mp_obj_type_t slice_type = { "slice", slice_print, NULL, // call_n + NULL, // make_new NULL, // unary_op NULL, // binary_op NULL, // getiter -- cgit v1.2.3