Add objtuple.h to allow embedding of tuples inside other objects.

This is useful because tuple is closest analog of C static array.
This commit is contained in:
Paul Sokolovsky 2014-01-12 23:23:10 +02:00
parent ca318bba0d
commit 8eec8bcad9
2 changed files with 9 additions and 7 deletions

View File

@ -9,19 +9,14 @@
#include "obj.h"
#include "runtime0.h"
#include "runtime.h"
typedef struct _mp_obj_tuple_t {
mp_obj_base_t base;
machine_uint_t len;
mp_obj_t items[];
} mp_obj_tuple_t;
#include "objtuple.h"
static mp_obj_t mp_obj_new_tuple_iterator(mp_obj_tuple_t *tuple, int cur);
/******************************************************************************/
/* tuple */
static void tuple_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t o_in) {
void tuple_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t o_in) {
mp_obj_tuple_t *o = o_in;
print(env, "(");
for (int i = 0; i < o->len; i++) {

7
py/objtuple.h Normal file
View File

@ -0,0 +1,7 @@
typedef struct _mp_obj_tuple_t {
mp_obj_base_t base;
machine_uint_t len;
mp_obj_t items[];
} mp_obj_tuple_t;
void tuple_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t o_in);