all: Remove the "STATIC" macro and just use "static" instead.
The STATIC macro was introduced a very long time ago in commit
d5df6cd44a. The original reason for this was
to have the option to define it to nothing so that all static functions
become global functions and therefore visible to certain debug tools, so
one could do function size comparison and other things.
This STATIC feature is rarely (if ever) used. And with the use of LTO and
heavy inline optimisation, analysing the size of individual functions when
they are not static is not a good representation of the size of code when
fully optimised.
So the macro does not have much use and it's simpler to just remove it.
Then you know exactly what it's doing. For example, newcomers don't have
to learn what the STATIC macro is and why it exists. Reading the code is
also less "loud" with a lowercase static.
One other minor point in favour of removing it, is that it stops bugs with
`STATIC inline`, which should always be `static inline`.
Methodology for this commit was:
1) git ls-files | egrep '\.[ch]$' | \
xargs sed -Ei "s/(^| )STATIC($| )/\1static\2/"
2) Do some manual cleanup in the diff by searching for the word STATIC in
comments and changing those back.
3) "git-grep STATIC docs/", manually fixed those cases.
4) "rg -t python STATIC", manually fixed codegen lines that used STATIC.
This work was funded through GitHub Sponsors.
Signed-off-by: Angus Gratton <angus@redyak.com.au>
This commit is contained in:
committed by
Damien George
parent
b3f2f18f92
commit
decf8e6a8b
@@ -32,33 +32,33 @@
|
||||
|
||||
// The port must provide implementations of these low-level ADC functions.
|
||||
|
||||
STATIC void mp_machine_adc_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind);
|
||||
STATIC mp_obj_t mp_machine_adc_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args);
|
||||
STATIC mp_int_t mp_machine_adc_read_u16(machine_adc_obj_t *self);
|
||||
static void mp_machine_adc_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind);
|
||||
static mp_obj_t mp_machine_adc_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args);
|
||||
static mp_int_t mp_machine_adc_read_u16(machine_adc_obj_t *self);
|
||||
|
||||
#if MICROPY_PY_MACHINE_ADC_INIT
|
||||
STATIC void mp_machine_adc_init_helper(machine_adc_obj_t *self, size_t n_pos_args, const mp_obj_t *pos_args, mp_map_t *kw_args);
|
||||
static void mp_machine_adc_init_helper(machine_adc_obj_t *self, size_t n_pos_args, const mp_obj_t *pos_args, mp_map_t *kw_args);
|
||||
#endif
|
||||
|
||||
#if MICROPY_PY_MACHINE_ADC_DEINIT
|
||||
STATIC void mp_machine_adc_deinit(machine_adc_obj_t *self);
|
||||
static void mp_machine_adc_deinit(machine_adc_obj_t *self);
|
||||
#endif
|
||||
|
||||
#if MICROPY_PY_MACHINE_ADC_BLOCK
|
||||
STATIC mp_obj_t mp_machine_adc_block(machine_adc_obj_t *self);
|
||||
static mp_obj_t mp_machine_adc_block(machine_adc_obj_t *self);
|
||||
#endif
|
||||
|
||||
#if MICROPY_PY_MACHINE_ADC_READ_UV
|
||||
STATIC mp_int_t mp_machine_adc_read_uv(machine_adc_obj_t *self);
|
||||
static mp_int_t mp_machine_adc_read_uv(machine_adc_obj_t *self);
|
||||
#endif
|
||||
|
||||
#if MICROPY_PY_MACHINE_ADC_ATTEN_WIDTH
|
||||
STATIC void mp_machine_adc_atten_set(machine_adc_obj_t *self, mp_int_t atten);
|
||||
STATIC void mp_machine_adc_width_set(machine_adc_obj_t *self, mp_int_t width);
|
||||
static void mp_machine_adc_atten_set(machine_adc_obj_t *self, mp_int_t atten);
|
||||
static void mp_machine_adc_width_set(machine_adc_obj_t *self, mp_int_t width);
|
||||
#endif
|
||||
|
||||
#if MICROPY_PY_MACHINE_ADC_READ
|
||||
STATIC mp_int_t mp_machine_adc_read(machine_adc_obj_t *self);
|
||||
static mp_int_t mp_machine_adc_read(machine_adc_obj_t *self);
|
||||
#endif
|
||||
|
||||
// The port provides implementations of the above in this file.
|
||||
@@ -66,81 +66,81 @@ STATIC mp_int_t mp_machine_adc_read(machine_adc_obj_t *self);
|
||||
|
||||
#if MICROPY_PY_MACHINE_ADC_INIT
|
||||
// ADC.init(...)
|
||||
STATIC mp_obj_t machine_adc_init(size_t n_pos_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
|
||||
static mp_obj_t machine_adc_init(size_t n_pos_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
|
||||
machine_adc_obj_t *self = MP_OBJ_TO_PTR(pos_args[0]);
|
||||
mp_machine_adc_init_helper(self, n_pos_args - 1, pos_args + 1, kw_args);
|
||||
return mp_const_none;
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(machine_adc_init_obj, 1, machine_adc_init);
|
||||
static MP_DEFINE_CONST_FUN_OBJ_KW(machine_adc_init_obj, 1, machine_adc_init);
|
||||
#endif
|
||||
|
||||
#if MICROPY_PY_MACHINE_ADC_DEINIT
|
||||
// ADC.deinit()
|
||||
STATIC mp_obj_t machine_adc_deinit(mp_obj_t self_in) {
|
||||
static mp_obj_t machine_adc_deinit(mp_obj_t self_in) {
|
||||
machine_adc_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
mp_machine_adc_deinit(self);
|
||||
return mp_const_none;
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_1(machine_adc_deinit_obj, machine_adc_deinit);
|
||||
static MP_DEFINE_CONST_FUN_OBJ_1(machine_adc_deinit_obj, machine_adc_deinit);
|
||||
#endif
|
||||
|
||||
#if MICROPY_PY_MACHINE_ADC_BLOCK
|
||||
// ADC.block()
|
||||
STATIC mp_obj_t machine_adc_block(mp_obj_t self_in) {
|
||||
static mp_obj_t machine_adc_block(mp_obj_t self_in) {
|
||||
machine_adc_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
return mp_machine_adc_block(self);
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_1(machine_adc_block_obj, machine_adc_block);
|
||||
static MP_DEFINE_CONST_FUN_OBJ_1(machine_adc_block_obj, machine_adc_block);
|
||||
#endif
|
||||
|
||||
// ADC.read_u16()
|
||||
STATIC mp_obj_t machine_adc_read_u16(mp_obj_t self_in) {
|
||||
static mp_obj_t machine_adc_read_u16(mp_obj_t self_in) {
|
||||
machine_adc_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
return MP_OBJ_NEW_SMALL_INT(mp_machine_adc_read_u16(self));
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_1(machine_adc_read_u16_obj, machine_adc_read_u16);
|
||||
static MP_DEFINE_CONST_FUN_OBJ_1(machine_adc_read_u16_obj, machine_adc_read_u16);
|
||||
|
||||
#if MICROPY_PY_MACHINE_ADC_READ_UV
|
||||
// ADC.read_uv()
|
||||
STATIC mp_obj_t machine_adc_read_uv(mp_obj_t self_in) {
|
||||
static mp_obj_t machine_adc_read_uv(mp_obj_t self_in) {
|
||||
machine_adc_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
return MP_OBJ_NEW_SMALL_INT(mp_machine_adc_read_uv(self));
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_1(machine_adc_read_uv_obj, machine_adc_read_uv);
|
||||
static MP_DEFINE_CONST_FUN_OBJ_1(machine_adc_read_uv_obj, machine_adc_read_uv);
|
||||
#endif
|
||||
|
||||
#if MICROPY_PY_MACHINE_ADC_ATTEN_WIDTH
|
||||
|
||||
// ADC.atten(value) -- this is a legacy method.
|
||||
STATIC mp_obj_t machine_adc_atten(mp_obj_t self_in, mp_obj_t atten_in) {
|
||||
static mp_obj_t machine_adc_atten(mp_obj_t self_in, mp_obj_t atten_in) {
|
||||
machine_adc_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
mp_int_t atten = mp_obj_get_int(atten_in);
|
||||
mp_machine_adc_atten_set(self, atten);
|
||||
return mp_const_none;
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_2(machine_adc_atten_obj, machine_adc_atten);
|
||||
static MP_DEFINE_CONST_FUN_OBJ_2(machine_adc_atten_obj, machine_adc_atten);
|
||||
|
||||
// ADC.width(value) -- this is a legacy method.
|
||||
STATIC mp_obj_t machine_adc_width(mp_obj_t self_in, mp_obj_t width_in) {
|
||||
static mp_obj_t machine_adc_width(mp_obj_t self_in, mp_obj_t width_in) {
|
||||
machine_adc_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
mp_int_t width = mp_obj_get_int(width_in);
|
||||
mp_machine_adc_width_set(self, width);
|
||||
return mp_const_none;
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_2(machine_adc_width_obj, machine_adc_width);
|
||||
static MP_DEFINE_CONST_FUN_OBJ_2(machine_adc_width_obj, machine_adc_width);
|
||||
|
||||
#endif
|
||||
|
||||
#if MICROPY_PY_MACHINE_ADC_READ
|
||||
// ADC.read() -- this is a legacy method.
|
||||
STATIC mp_obj_t machine_adc_read(mp_obj_t self_in) {
|
||||
static mp_obj_t machine_adc_read(mp_obj_t self_in) {
|
||||
machine_adc_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
return MP_OBJ_NEW_SMALL_INT(mp_machine_adc_read(self));
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_1(machine_adc_read_obj, machine_adc_read);
|
||||
static MP_DEFINE_CONST_FUN_OBJ_1(machine_adc_read_obj, machine_adc_read);
|
||||
#endif
|
||||
|
||||
STATIC const mp_rom_map_elem_t machine_adc_locals_dict_table[] = {
|
||||
static const mp_rom_map_elem_t machine_adc_locals_dict_table[] = {
|
||||
#if MICROPY_PY_MACHINE_ADC_INIT
|
||||
{ MP_ROM_QSTR(MP_QSTR_init), MP_ROM_PTR(&machine_adc_init_obj) },
|
||||
#endif
|
||||
@@ -169,7 +169,7 @@ STATIC const mp_rom_map_elem_t machine_adc_locals_dict_table[] = {
|
||||
// It can be defined to nothing if there are no constants.
|
||||
MICROPY_PY_MACHINE_ADC_CLASS_CONSTANTS
|
||||
};
|
||||
STATIC MP_DEFINE_CONST_DICT(machine_adc_locals_dict, machine_adc_locals_dict_table);
|
||||
static MP_DEFINE_CONST_DICT(machine_adc_locals_dict, machine_adc_locals_dict_table);
|
||||
|
||||
MP_DEFINE_CONST_OBJ_TYPE(
|
||||
machine_adc_type,
|
||||
|
||||
Reference in New Issue
Block a user