Skip to content

Commit 9d1983f

Browse files
jimmodpgeorge
authored andcommitted
py/dynruntime.h: Add mp_import_* and mp_load/store_*.
These functions already exist in the fun table, and this commit just adds convenience macros for them.
1 parent 8f20cdc commit 9d1983f

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

py/dynruntime.h

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,9 +163,15 @@ static inline mp_obj_t mp_obj_len_dyn(mp_obj_t o) {
163163
/******************************************************************************/
164164
// General runtime functions
165165

166-
#define mp_load_name(qst) (mp_fun_table.load_name(qst))
167-
#define mp_load_global(qst) (mp_fun_table.load_global(qst))
168-
#define mp_store_global(qst, obj) (mp_fun_table.store_global((qst), (obj)))
166+
#define mp_load_name(qst) (mp_fun_table.load_name((qst)))
167+
#define mp_load_global(qst) (mp_fun_table.load_global((qst)))
168+
#define mp_load_attr(base, attr) (mp_fun_table.load_attr((base), (attr)))
169+
#define mp_load_method(base, attr, dest) (mp_fun_table.load_method((base), (attr), (dest)))
170+
#define mp_load_super_method(attr, dest) (mp_fun_table.load_super_method((attr), (dest)))
171+
#define mp_store_name(qst, obj) (mp_fun_table.store_name((qst), (obj)))
172+
#define mp_store_global(qst, obj) (mp_fun_table.store_global((qst), (obj)))
173+
#define mp_store_attr(base, attr, val) (mp_fun_table.store_attr((base), (attr), (val)))
174+
169175
#define mp_unary_op(op, obj) (mp_fun_table.unary_op((op), (obj)))
170176
#define mp_binary_op(op, lhs, rhs) (mp_fun_table.binary_op((op), (lhs), (rhs)))
171177

@@ -193,6 +199,13 @@ static inline mp_obj_t mp_obj_len_dyn(mp_obj_t o) {
193199
#define MP_DYNRUNTIME_MAKE_FUNCTION(f) \
194200
(mp_make_function_from_raw_code((rc.fun_data = (f), &rc), MP_OBJ_NULL, MP_OBJ_NULL))
195201

202+
#define mp_import_name(name, fromlist, level) \
203+
(mp_fun_table.import_name((name), (fromlist), (level)))
204+
#define mp_import_from(module, name) \
205+
(mp_fun_table.import_from((module), (name)))
206+
#define mp_import_all(module) \
207+
(mp_fun_table.import_all((module))
208+
196209
/******************************************************************************/
197210
// Exceptions
198211

0 commit comments

Comments
 (0)