mirror of
https://github.com/micropython/micropython.git
synced 2025-12-16 09:50:15 +01:00
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
@@ -56,7 +56,7 @@ typedef struct _esp_hosted_obj_t {
|
||||
static esp_hosted_obj_t esp_hosted_sta_if = {{(mp_obj_type_t *)&mod_network_esp_hosted_type}, ESP_HOSTED_STA_IF};
|
||||
static esp_hosted_obj_t esp_hosted_ap_if = {{(mp_obj_type_t *)&mod_network_esp_hosted_type}, ESP_HOSTED_AP_IF};
|
||||
|
||||
STATIC mp_obj_t network_esp_hosted_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 network_esp_hosted_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
|
||||
mp_arg_check_num(n_args, n_kw, 0, 1, false);
|
||||
mp_obj_t esp_hosted_obj;
|
||||
// TODO fix
|
||||
@@ -70,7 +70,7 @@ STATIC mp_obj_t network_esp_hosted_make_new(const mp_obj_type_t *type, size_t n_
|
||||
return esp_hosted_obj;
|
||||
}
|
||||
|
||||
STATIC mp_obj_t network_esp_hosted_active(size_t n_args, const mp_obj_t *args) {
|
||||
static mp_obj_t network_esp_hosted_active(size_t n_args, const mp_obj_t *args) {
|
||||
esp_hosted_obj_t *self = MP_OBJ_TO_PTR(args[0]);
|
||||
|
||||
if (n_args == 2) {
|
||||
@@ -95,9 +95,9 @@ STATIC mp_obj_t network_esp_hosted_active(size_t n_args, const mp_obj_t *args) {
|
||||
}
|
||||
return mp_obj_new_bool(esp_hosted_wifi_link_status(self->itf));
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(network_esp_hosted_active_obj, 1, 2, network_esp_hosted_active);
|
||||
static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(network_esp_hosted_active_obj, 1, 2, network_esp_hosted_active);
|
||||
|
||||
STATIC int esp_hosted_scan_callback(esp_hosted_scan_result_t *scan_result, void *arg) {
|
||||
static int esp_hosted_scan_callback(esp_hosted_scan_result_t *scan_result, void *arg) {
|
||||
mp_obj_t scan_list = (mp_obj_t)arg;
|
||||
mp_obj_t ap[6] = {
|
||||
mp_obj_new_bytes((uint8_t *)scan_result->ssid, strlen(scan_result->ssid)),
|
||||
@@ -111,15 +111,15 @@ STATIC int esp_hosted_scan_callback(esp_hosted_scan_result_t *scan_result, void
|
||||
return 0;
|
||||
}
|
||||
|
||||
STATIC mp_obj_t network_esp_hosted_scan(mp_obj_t self_in) {
|
||||
static mp_obj_t network_esp_hosted_scan(mp_obj_t self_in) {
|
||||
mp_obj_t scan_list;
|
||||
scan_list = mp_obj_new_list(0, NULL);
|
||||
esp_hosted_wifi_scan(esp_hosted_scan_callback, scan_list, 10000);
|
||||
return scan_list;
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_1(network_esp_hosted_scan_obj, network_esp_hosted_scan);
|
||||
static MP_DEFINE_CONST_FUN_OBJ_1(network_esp_hosted_scan_obj, network_esp_hosted_scan);
|
||||
|
||||
STATIC mp_obj_t network_esp_hosted_connect(mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
|
||||
static mp_obj_t network_esp_hosted_connect(mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
|
||||
enum { ARG_ssid, ARG_key, ARG_security, ARG_bssid, ARG_channel };
|
||||
static const mp_arg_t allowed_args[] = {
|
||||
{ MP_QSTR_ssid, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} },
|
||||
@@ -182,29 +182,29 @@ STATIC mp_obj_t network_esp_hosted_connect(mp_uint_t n_args, const mp_obj_t *pos
|
||||
|
||||
return mp_const_none;
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(network_esp_hosted_connect_obj, 1, network_esp_hosted_connect);
|
||||
static MP_DEFINE_CONST_FUN_OBJ_KW(network_esp_hosted_connect_obj, 1, network_esp_hosted_connect);
|
||||
|
||||
STATIC mp_obj_t network_esp_hosted_disconnect(mp_obj_t self_in) {
|
||||
static mp_obj_t network_esp_hosted_disconnect(mp_obj_t self_in) {
|
||||
esp_hosted_obj_t *self = self_in;
|
||||
esp_hosted_wifi_disconnect(self->itf);
|
||||
return mp_const_none;
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_1(network_esp_hosted_disconnect_obj, network_esp_hosted_disconnect);
|
||||
static MP_DEFINE_CONST_FUN_OBJ_1(network_esp_hosted_disconnect_obj, network_esp_hosted_disconnect);
|
||||
|
||||
STATIC mp_obj_t network_esp_hosted_isconnected(mp_obj_t self_in) {
|
||||
static mp_obj_t network_esp_hosted_isconnected(mp_obj_t self_in) {
|
||||
esp_hosted_obj_t *self = self_in;
|
||||
return mp_obj_new_bool(esp_hosted_wifi_is_connected(self->itf));
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_1(network_esp_hosted_isconnected_obj, network_esp_hosted_isconnected);
|
||||
static MP_DEFINE_CONST_FUN_OBJ_1(network_esp_hosted_isconnected_obj, network_esp_hosted_isconnected);
|
||||
|
||||
STATIC mp_obj_t network_esp_hosted_ifconfig(size_t n_args, const mp_obj_t *args) {
|
||||
static mp_obj_t network_esp_hosted_ifconfig(size_t n_args, const mp_obj_t *args) {
|
||||
esp_hosted_obj_t *self = MP_OBJ_TO_PTR(args[0]);
|
||||
void *netif = esp_hosted_wifi_get_netif(self->itf);
|
||||
return mod_network_nic_ifconfig(netif, n_args - 1, args + 1);
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(network_esp_hosted_ifconfig_obj, 1, 2, network_esp_hosted_ifconfig);
|
||||
static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(network_esp_hosted_ifconfig_obj, 1, 2, network_esp_hosted_ifconfig);
|
||||
|
||||
STATIC mp_obj_t network_esp_hosted_config(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs) {
|
||||
static mp_obj_t network_esp_hosted_config(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs) {
|
||||
esp_hosted_obj_t *self = MP_OBJ_TO_PTR(args[0]);
|
||||
|
||||
if (kwargs->used == 0) {
|
||||
@@ -253,9 +253,9 @@ STATIC mp_obj_t network_esp_hosted_config(size_t n_args, const mp_obj_t *args, m
|
||||
|
||||
return mp_const_none;
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(network_esp_hosted_config_obj, 1, network_esp_hosted_config);
|
||||
static MP_DEFINE_CONST_FUN_OBJ_KW(network_esp_hosted_config_obj, 1, network_esp_hosted_config);
|
||||
|
||||
STATIC mp_obj_t network_esp_hosted_status(size_t n_args, const mp_obj_t *args) {
|
||||
static mp_obj_t network_esp_hosted_status(size_t n_args, const mp_obj_t *args) {
|
||||
esp_hosted_obj_t *self = MP_OBJ_TO_PTR(args[0]);
|
||||
|
||||
if (n_args == 1) {
|
||||
@@ -290,9 +290,9 @@ STATIC mp_obj_t network_esp_hosted_status(size_t n_args, const mp_obj_t *args) {
|
||||
|
||||
mp_raise_ValueError(MP_ERROR_TEXT("unknown status param"));
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(network_esp_hosted_status_obj, 1, 2, network_esp_hosted_status);
|
||||
static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(network_esp_hosted_status_obj, 1, 2, network_esp_hosted_status);
|
||||
|
||||
STATIC const mp_rom_map_elem_t network_esp_hosted_locals_dict_table[] = {
|
||||
static const mp_rom_map_elem_t network_esp_hosted_locals_dict_table[] = {
|
||||
{ MP_ROM_QSTR(MP_QSTR_active), MP_ROM_PTR(&network_esp_hosted_active_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_scan), MP_ROM_PTR(&network_esp_hosted_scan_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_connect), MP_ROM_PTR(&network_esp_hosted_connect_obj) },
|
||||
@@ -305,7 +305,7 @@ STATIC const mp_rom_map_elem_t network_esp_hosted_locals_dict_table[] = {
|
||||
{ MP_ROM_QSTR(MP_QSTR_WEP), MP_ROM_INT(ESP_HOSTED_SEC_WEP) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_WPA_PSK), MP_ROM_INT(ESP_HOSTED_SEC_WPA_WPA2_PSK) },
|
||||
};
|
||||
STATIC MP_DEFINE_CONST_DICT(network_esp_hosted_locals_dict, network_esp_hosted_locals_dict_table);
|
||||
static MP_DEFINE_CONST_DICT(network_esp_hosted_locals_dict, network_esp_hosted_locals_dict_table);
|
||||
|
||||
MP_DEFINE_CONST_OBJ_TYPE(
|
||||
mod_network_esp_hosted_type,
|
||||
|
||||
Reference in New Issue
Block a user