diff options
author | Angus Gratton <angus@redyak.com.au> | 2024-02-27 15:32:29 +1100 |
---|---|---|
committer | Damien George <damien@micropython.org> | 2024-03-07 14:20:42 +1100 |
commit | decf8e6a8bb940d5829ca3296790631fcece7b21 (patch) | |
tree | 55b7cd31de14b73e4b72d49344e9084f402767a9 /py/objobject.c | |
parent | b3f2f18f927fa2fad10daf63d8c391331f5edf58 (diff) | |
download | micropython-decf8e6a8bb940d5829ca3296790631fcece7b21.tar.gz micropython-decf8e6a8bb940d5829ca3296790631fcece7b21.zip |
all: Remove the "STATIC" macro and just use "static" instead.
The STATIC macro was introduced a very long time ago in commit
d5df6cd44a433d6253a61cb0f987835fbc06b2de. 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>
Diffstat (limited to 'py/objobject.c')
-rw-r--r-- | py/objobject.c | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/py/objobject.c b/py/objobject.c index 1acae6d00b..ff93fd0827 100644 --- a/py/objobject.c +++ b/py/objobject.c @@ -33,7 +33,7 @@ typedef struct _mp_obj_object_t { mp_obj_base_t base; } mp_obj_object_t; -STATIC mp_obj_t object_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { +static mp_obj_t object_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { (void)args; mp_arg_check_num(n_args, n_kw, 0, 0, false); mp_obj_object_t *o = mp_obj_malloc(mp_obj_object_t, type); @@ -41,13 +41,13 @@ STATIC mp_obj_t object_make_new(const mp_obj_type_t *type, size_t n_args, size_t } #if MICROPY_CPYTHON_COMPAT -STATIC mp_obj_t object___init__(mp_obj_t self) { +static mp_obj_t object___init__(mp_obj_t self) { (void)self; return mp_const_none; } -STATIC MP_DEFINE_CONST_FUN_OBJ_1(object___init___obj, object___init__); +static MP_DEFINE_CONST_FUN_OBJ_1(object___init___obj, object___init__); -STATIC mp_obj_t object___new__(mp_obj_t cls) { +static mp_obj_t object___new__(mp_obj_t cls) { if (!mp_obj_is_type(cls, &mp_type_type) || !mp_obj_is_instance_type((mp_obj_type_t *)MP_OBJ_TO_PTR(cls))) { mp_raise_TypeError(MP_ERROR_TEXT("arg must be user-type")); } @@ -58,11 +58,11 @@ STATIC mp_obj_t object___new__(mp_obj_t cls) { const mp_obj_type_t *native_base; return MP_OBJ_FROM_PTR(mp_obj_new_instance(MP_OBJ_TO_PTR(cls), &native_base)); } -STATIC MP_DEFINE_CONST_FUN_OBJ_1(object___new___fun_obj, object___new__); -STATIC MP_DEFINE_CONST_STATICMETHOD_OBJ(object___new___obj, MP_ROM_PTR(&object___new___fun_obj)); +static MP_DEFINE_CONST_FUN_OBJ_1(object___new___fun_obj, object___new__); +static MP_DEFINE_CONST_STATICMETHOD_OBJ(object___new___obj, MP_ROM_PTR(&object___new___fun_obj)); #if MICROPY_PY_DELATTR_SETATTR -STATIC mp_obj_t object___setattr__(mp_obj_t self_in, mp_obj_t attr, mp_obj_t value) { +static mp_obj_t object___setattr__(mp_obj_t self_in, mp_obj_t attr, mp_obj_t value) { if (!mp_obj_is_instance_type(mp_obj_get_type(self_in))) { mp_raise_TypeError(MP_ERROR_TEXT("arg must be user-type")); } @@ -75,9 +75,9 @@ STATIC mp_obj_t object___setattr__(mp_obj_t self_in, mp_obj_t attr, mp_obj_t val mp_map_lookup(&self->members, attr, MP_MAP_LOOKUP_ADD_IF_NOT_FOUND)->value = value; return mp_const_none; } -STATIC MP_DEFINE_CONST_FUN_OBJ_3(object___setattr___obj, object___setattr__); +static MP_DEFINE_CONST_FUN_OBJ_3(object___setattr___obj, object___setattr__); -STATIC mp_obj_t object___delattr__(mp_obj_t self_in, mp_obj_t attr) { +static mp_obj_t object___delattr__(mp_obj_t self_in, mp_obj_t attr) { if (!mp_obj_is_instance_type(mp_obj_get_type(self_in))) { mp_raise_TypeError(MP_ERROR_TEXT("arg must be user-type")); } @@ -92,10 +92,10 @@ STATIC mp_obj_t object___delattr__(mp_obj_t self_in, mp_obj_t attr) { } return mp_const_none; } -STATIC MP_DEFINE_CONST_FUN_OBJ_2(object___delattr___obj, object___delattr__); +static MP_DEFINE_CONST_FUN_OBJ_2(object___delattr___obj, object___delattr__); #endif -STATIC const mp_rom_map_elem_t object_locals_dict_table[] = { +static const mp_rom_map_elem_t object_locals_dict_table[] = { #if MICROPY_CPYTHON_COMPAT { MP_ROM_QSTR(MP_QSTR___init__), MP_ROM_PTR(&object___init___obj) }, #endif @@ -108,7 +108,7 @@ STATIC const mp_rom_map_elem_t object_locals_dict_table[] = { #endif }; -STATIC MP_DEFINE_CONST_DICT(object_locals_dict, object_locals_dict_table); +static MP_DEFINE_CONST_DICT(object_locals_dict, object_locals_dict_table); #endif #if MICROPY_CPYTHON_COMPAT |