mirror of
https://github.com/micropython/micropython.git
synced 2025-12-16 09:50:15 +01:00
py: Make struct-initializing macros compatible with C++.
This requires explicitly naming and initializing all members so add that where needed and possible. For MP_DEFINE_NLR_JUMP_CALLBACK_FUNCTION_1 this would require initializing the .callback member, but that's a bit of a waste since the macro is always followed by a call to nlr_push_jump_callback() to initialize exactly that member, so rewrite the macro without initializers. Signed-off-by: stijn <stijn@ignitron.net>
This commit is contained in:
10
py/runtime.h
10
py/runtime.h
@@ -30,12 +30,12 @@
|
||||
#include "py/pystack.h"
|
||||
#include "py/cstack.h"
|
||||
|
||||
// For use with mp_call_function_1_from_nlr_jump_callback.
|
||||
// Initialize an nlr_jump_callback_node_call_function_1_t struct for use with
|
||||
// nlr_push_jump_callback(&ctx.callback, 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), \
|
||||
}
|
||||
nlr_jump_callback_node_call_function_1_t ctx; \
|
||||
ctx.func = (void (*)(void *))(f); \
|
||||
ctx.arg = (a)
|
||||
|
||||
typedef enum {
|
||||
MP_VM_RETURN_NORMAL,
|
||||
|
||||
Reference in New Issue
Block a user