diff options
author | stijn <stijn@ignitron.net> | 2024-08-21 16:22:01 +0200 |
---|---|---|
committer | Damien George <damien@micropython.org> | 2024-10-07 11:37:52 +1100 |
commit | 338df1ae357eefe987df4429b88d3094f9c7b8c2 (patch) | |
tree | f2d3d9197a8d14c2be602a820a38126e77781c32 /py/obj.h | |
parent | 548f88d2bd254f1328014a303f8bf602a0646421 (diff) |
py/objtype: Allow passing keyword arguments to native base __init__.
Allowing passing keyword arguments to a native base's __init__, i.e.
`make_new` in the C code. Previously only positional arguments were
allowed.
The main trade-off in this commit is that every call to the native base's
`make_new` is now going to be preceded by a call to
`mp_map_init_fixed_table` even though most of what that does is unused and
instead it merely serves as a way to pass the number of keyword arguments.
Fixes issue #15465.
Signed-off-by: stijn <stijn@ignitron.net>
Diffstat (limited to 'py/obj.h')
-rw-r--r-- | py/obj.h | 3 |
1 files changed, 3 insertions, 0 deletions
@@ -516,6 +516,9 @@ typedef mp_obj_t (*mp_fun_3_t)(mp_obj_t, mp_obj_t, mp_obj_t); typedef mp_obj_t (*mp_fun_var_t)(size_t n, const mp_obj_t *); // mp_fun_kw_t takes mp_map_t* (and not const mp_map_t*) to ease passing // this arg to mp_map_lookup(). +// Note that the mp_obj_t* array will contain all arguments, positional and keyword, with the keyword +// ones starting at offset n, like: arg0 arg1 ... arg<n> key0 value0 key1 value1 ..., and the mp_map_t* +// gets those same keyword arguments but as a map for convenience; see fun_builtin_var_call. typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *); // Flags for type behaviour (mp_obj_type_t.flags) |