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:
stijn
2025-04-22 14:53:07 +02:00
parent 076e07197e
commit 02eea0da24
3 changed files with 13 additions and 13 deletions

View File

@@ -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,