Merge pull request #6730 from tannewt/remove_scanentry_all

Remove all kwarg from ScanEntry.matches
This commit is contained in:
Scott Shawcroft 2022-08-09 22:03:14 -07:00 committed by GitHub
commit e50fc237f8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -48,25 +48,22 @@
//| def matches(self, prefixes: ScanEntry, *, match_all: bool = True) -> bool: //| def matches(self, prefixes: ScanEntry, *, match_all: bool = True) -> bool:
//| """Returns True if the ScanEntry matches all prefixes when ``match_all`` is True. This is stricter //| """Returns True if the ScanEntry matches all prefixes when ``match_all`` is True. This is stricter
//| than the scan filtering which accepts any advertisements that match any of the prefixes //| than the scan filtering which accepts any advertisements that match any of the prefixes
//| where ``match_all`` is False. //| where ``match_all`` is False."""
//|
//| ``all`` also works for ``match_all`` but will be removed in CircuitPython 8."""
//| ... //| ...
//| //|
STATIC mp_obj_t bleio_scanentry_matches(mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { STATIC mp_obj_t bleio_scanentry_matches(mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
bleio_scanentry_obj_t *self = MP_OBJ_TO_PTR(pos_args[0]); bleio_scanentry_obj_t *self = MP_OBJ_TO_PTR(pos_args[0]);
enum { ARG_prefixes, ARG_all, ARG_match_all }; enum { ARG_prefixes, ARG_match_all };
static const mp_arg_t allowed_args[] = { static const mp_arg_t allowed_args[] = {
{ MP_QSTR_prefixes, MP_ARG_OBJ | MP_ARG_REQUIRED }, { MP_QSTR_prefixes, MP_ARG_OBJ | MP_ARG_REQUIRED },
{ MP_QSTR_all, MP_ARG_BOOL | MP_ARG_KW_ONLY, {.u_bool = true} },
{ MP_QSTR_match_all, MP_ARG_BOOL | MP_ARG_KW_ONLY, {.u_bool = true} }, { MP_QSTR_match_all, MP_ARG_BOOL | MP_ARG_KW_ONLY, {.u_bool = true} },
}; };
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
bool match_all = args[ARG_all].u_bool && args[ARG_match_all].u_bool; bool match_all = args[ARG_match_all].u_bool;
mp_buffer_info_t bufinfo; mp_buffer_info_t bufinfo;
mp_get_buffer_raise(args[ARG_prefixes].u_obj, &bufinfo, MP_BUFFER_READ); mp_get_buffer_raise(args[ARG_prefixes].u_obj, &bufinfo, MP_BUFFER_READ);