summaryrefslogtreecommitdiff
path: root/py
diff options
context:
space:
mode:
Diffstat (limited to 'py')
-rw-r--r--py/dynruntime.h5
-rw-r--r--py/nativeglue.c4
-rw-r--r--py/nativeglue.h5
3 files changed, 14 insertions, 0 deletions
diff --git a/py/dynruntime.h b/py/dynruntime.h
index 7765fca40..d07b1dce2 100644
--- a/py/dynruntime.h
+++ b/py/dynruntime.h
@@ -29,6 +29,7 @@
// This header file contains definitions to dynamically implement the static
// MicroPython runtime API defined in py/obj.h and py/runtime.h.
+#include "py/binary.h"
#include "py/nativeglue.h"
#include "py/objfun.h"
#include "py/objstr.h"
@@ -184,6 +185,10 @@ static inline void *mp_obj_malloc_helper_dyn(size_t num_bytes, const mp_obj_type
/******************************************************************************/
// General runtime functions
+#define mp_binary_get_size(struct_type, val_type, palign) (mp_fun_table.binary_get_size((struct_type), (val_type), (palign)))
+#define mp_binary_get_val_array(typecode, p, index) (mp_fun_table.binary_get_val_array((typecode), (p), (index)))
+#define mp_binary_set_val_array(typecode, p, index, val_in) (mp_fun_table.binary_set_val_array((typecode), (p), (index), (val_in)))
+
#define mp_load_name(qst) (mp_fun_table.load_name((qst)))
#define mp_load_global(qst) (mp_fun_table.load_global((qst)))
#define mp_load_attr(base, attr) (mp_fun_table.load_attr((base), (attr)))
diff --git a/py/nativeglue.c b/py/nativeglue.c
index 4cd090c0a..ba3d93f76 100644
--- a/py/nativeglue.c
+++ b/py/nativeglue.c
@@ -29,6 +29,7 @@
#include <string.h>
#include <assert.h>
+#include "py/binary.h"
#include "py/runtime.h"
#include "py/smallint.h"
#include "py/nativeglue.h"
@@ -330,6 +331,9 @@ const mp_fun_table_t mp_fun_table = {
mp_obj_get_float_to_d,
mp_get_buffer,
mp_get_stream_raise,
+ mp_binary_get_size,
+ mp_binary_get_val_array,
+ mp_binary_set_val_array,
&mp_plat_print,
&mp_type_type,
&mp_type_str,
diff --git a/py/nativeglue.h b/py/nativeglue.h
index 113f5fde6..1fa859334 100644
--- a/py/nativeglue.h
+++ b/py/nativeglue.h
@@ -156,7 +156,12 @@ typedef struct _mp_fun_table_t {
double (*obj_get_float_to_d)(mp_obj_t o);
bool (*get_buffer)(mp_obj_t obj, mp_buffer_info_t *bufinfo, mp_uint_t flags);
const mp_stream_p_t *(*get_stream_raise)(mp_obj_t self_in, int flags);
+ size_t (*binary_get_size)(char struct_type, char val_type, size_t *palign);
+ mp_obj_t (*binary_get_val_array)(char typecode, void *p, size_t index);
+ void (*binary_set_val_array)(char typecode, void *p, size_t index, mp_obj_t val_in);
const mp_print_t *plat_print;
+ // The following entries start at index 70 and are referenced by tools-mpy_ld.py,
+ // see constant MP_FUN_TABLE_MP_TYPE_TYPE_OFFSET.
const mp_obj_type_t *type_type;
const mp_obj_type_t *type_str;
const mp_obj_type_t *type_list;