Skip to content

Commit 8eec8bc

Browse files
committed
Add objtuple.h to allow embedding of tuples inside other objects.
This is useful because tuple is closest analog of C static array.
1 parent ca318bb commit 8eec8bc

2 files changed

Lines changed: 9 additions & 7 deletions

File tree

py/objtuple.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,14 @@
99
#include "obj.h"
1010
#include "runtime0.h"
1111
#include "runtime.h"
12-
13-
typedef struct _mp_obj_tuple_t {
14-
mp_obj_base_t base;
15-
machine_uint_t len;
16-
mp_obj_t items[];
17-
} mp_obj_tuple_t;
12+
#include "objtuple.h"
1813

1914
static mp_obj_t mp_obj_new_tuple_iterator(mp_obj_tuple_t *tuple, int cur);
2015

2116
/******************************************************************************/
2217
/* tuple */
2318

24-
static void tuple_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t o_in) {
19+
void tuple_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t o_in) {
2520
mp_obj_tuple_t *o = o_in;
2621
print(env, "(");
2722
for (int i = 0; i < o->len; i++) {

py/objtuple.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
typedef struct _mp_obj_tuple_t {
2+
mp_obj_base_t base;
3+
machine_uint_t len;
4+
mp_obj_t items[];
5+
} mp_obj_tuple_t;
6+
7+
void tuple_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t o_in);

0 commit comments

Comments
 (0)