Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
micropython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
micropython
Commits
c9089e71
Commit
c9089e71
authored
Sep 05, 2023
by
Damien George
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
py/runtime: Add helpers to call a general function on nlr jump callback.
Signed-off-by:
Damien George
<
damien@micropython.org
>
parent
dc99840b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
0 deletions
+20
-0
py/runtime.c
py/runtime.c
+5
-0
py/runtime.h
py/runtime.h
+15
-0
No files found.
py/runtime.c
View file @
c9089e71
...
...
@@ -197,6 +197,11 @@ void mp_globals_locals_set_from_nlr_jump_callback(void *ctx_in) {
mp_locals_set
(
ctx
->
locals
);
}
void
mp_call_function_1_from_nlr_jump_callback
(
void
*
ctx_in
)
{
nlr_jump_callback_node_call_function_1_t
*
ctx
=
ctx_in
;
ctx
->
func
(
ctx
->
arg
);
}
mp_obj_t
MICROPY_WRAP_MP_LOAD_NAME
(
mp_load_name
)(
qstr
qst
)
{
// logic: search locals, globals, builtins
DEBUG_OP_printf
(
"load name %s
\n
"
,
qstr_str
(
qst
));
...
...
py/runtime.h
View file @
c9089e71
...
...
@@ -29,6 +29,13 @@
#include "py/mpstate.h"
#include "py/pystack.h"
// For use with mp_call_function_1_from_nlr_jump_callback.
#define MP_DEFINE_NLR_JUMP_CALLBACK_FUNCTION_1(ctx, f, a) \
nlr_jump_callback_node_call_function_1_t ctx = { \
.func = (void (*)(void *))(f), \
.arg = (a), \
}
typedef
enum
{
MP_VM_RETURN_NORMAL
,
MP_VM_RETURN_YIELD
,
...
...
@@ -73,6 +80,13 @@ typedef struct _nlr_jump_callback_node_globals_locals_t {
mp_obj_dict_t
*
locals
;
}
nlr_jump_callback_node_globals_locals_t
;
// For use with mp_call_function_1_from_nlr_jump_callback.
typedef
struct
_nlr_jump_callback_node_call_function_1_t
{
nlr_jump_callback_node_t
callback
;
void
(
*
func
)(
void
*
);
void
*
arg
;
}
nlr_jump_callback_node_call_function_1_t
;
// Tables mapping operator enums to qstrs, defined in objtype.c
extern
const
byte
mp_unary_op_method_name
[];
extern
const
byte
mp_binary_op_method_name
[];
...
...
@@ -121,6 +135,7 @@ static inline void mp_globals_set(mp_obj_dict_t *d) {
}
void
mp_globals_locals_set_from_nlr_jump_callback
(
void
*
ctx_in
);
void
mp_call_function_1_from_nlr_jump_callback
(
void
*
ctx_in
);
mp_obj_t
mp_load_name
(
qstr
qst
);
mp_obj_t
mp_load_global
(
qstr
qst
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment