Browse Source

py/dynruntime: Add mp_get_buffer.

Signed-off-by: Damien George <damien@micropython.org>
pull/12679/head
Damien George 1 year ago
parent
commit
9b63421fb3
  1. 3
      py/dynruntime.h
  2. 2
      py/nativeglue.c
  3. 2
      py/nativeglue.h

3
py/dynruntime.h

@ -125,7 +125,8 @@ static inline void *m_realloc_dyn(void *ptr, size_t new_num_bytes) {
#define mp_obj_get_int_truncated(o) (mp_fun_table.native_from_obj(o, MP_NATIVE_TYPE_UINT))
#define mp_obj_str_get_str(s) (mp_obj_str_get_data_dyn((s), NULL))
#define mp_obj_str_get_data(o, len) (mp_obj_str_get_data_dyn((o), (len)))
#define mp_get_buffer_raise(o, bufinfo, fl) (mp_fun_table.get_buffer_raise((o), (bufinfo), (fl)))
#define mp_get_buffer(o, bufinfo, fl) (mp_fun_table.get_buffer((o), (bufinfo), (fl)))
#define mp_get_buffer_raise(o, bufinfo, fl) (mp_fun_table.get_buffer((o), (bufinfo), (fl) | MP_BUFFER_RAISE_IF_UNSUPPORTED))
#define mp_get_stream_raise(s, flags) (mp_fun_table.get_stream_raise((s), (flags)))
#define mp_obj_is_true(o) (mp_fun_table.native_from_obj(o, MP_NATIVE_TYPE_BOOL))

2
py/nativeglue.c

@ -328,7 +328,7 @@ const mp_fun_table_t mp_fun_table = {
mp_obj_new_float_from_d,
mp_obj_get_float_to_f,
mp_obj_get_float_to_d,
mp_get_buffer_raise,
mp_get_buffer,
mp_get_stream_raise,
&mp_plat_print,
&mp_type_type,

2
py/nativeglue.h

@ -154,7 +154,7 @@ typedef struct _mp_fun_table_t {
mp_obj_t (*obj_new_float_from_d)(double d);
float (*obj_get_float_to_f)(mp_obj_t o);
double (*obj_get_float_to_d)(mp_obj_t o);
void (*get_buffer_raise)(mp_obj_t obj, mp_buffer_info_t *bufinfo, mp_uint_t flags);
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);
const mp_print_t *plat_print;
const mp_obj_type_t *type_type;

Loading…
Cancel
Save