Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 5babc3c

Browse files
committed
Update 'usocket' module
allow 'getaddrinfo' to accep additional arguments
1 parent 7bfb2f1 commit 5babc3c

File tree

20 files changed

+6
-5
lines changed

20 files changed

+6
-5
lines changed

‎MicroPython_BUILD/components/micropython/esp32/modsocket.c‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ static int _socket_getaddrinfo2(const mp_obj_t host, const mp_obj_t portx, struc
107107
if (MP_OBJ_IS_SMALL_INT(port)) {
108108
// This is perverse, because lwip_getaddrinfo promptly converts it back to an int, but
109109
// that's the API we have to work with ...
110-
port = mp_obj_str_binary_op(MP_BINARY_OP_MODULO, mp_obj_new_str("%s", 2), port);
110+
port = mp_obj_str_binary_op(MP_BINARY_OP_MODULO, mp_obj_new_str_via_qstr("%s", 2), port);
111111
}
112112

113113
const char *host_str = mp_obj_str_get_str(host);
@@ -581,9 +581,11 @@ STATIC mp_obj_t get_socket(size_t n_args, const mp_obj_t *args) {
581581
}
582582
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(get_socket_obj, 0, 3, get_socket);
583583

584-
STATIC mp_obj_t esp_socket_getaddrinfo(const mp_obj_t host, const mp_obj_t port) {
584+
STATIC mp_obj_t esp_socket_getaddrinfo(size_t n_args, const mp_obj_t *args) {
585+
// TODO support additional args beyond the first two
586+
585587
struct addrinfo *res = NULL;
586-
_socket_getaddrinfo2(host, port, &res);
588+
_socket_getaddrinfo2(args[0], args[1], &res);
587589
mp_obj_t ret_list = mp_obj_new_list(0, NULL);
588590

589591
for (struct addrinfo *resi = res; resi; resi = resi->ai_next) {
@@ -613,7 +615,7 @@ STATIC mp_obj_t esp_socket_getaddrinfo(const mp_obj_t host, const mp_obj_t port)
613615
if (res) lwip_freeaddrinfo(res);
614616
return ret_list;
615617
}
616-
STATIC MP_DEFINE_CONST_FUN_OBJ_2(esp_socket_getaddrinfo_obj, esp_socket_getaddrinfo);
618+
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(esp_socket_getaddrinfo_obj, 2, 6, esp_socket_getaddrinfo);
617619

618620
STATIC mp_obj_t esp_socket_initialize() {
619621
static int initialized = 0;

‎MicroPython_BUILD/components/micropython/esp32/moduos.c‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,6 @@ STATIC mp_obj_t os_sdcard_config(size_t n_args, const mp_obj_t *pos_args, mp_map
176176
}
177177
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(os_sdcard_config_obj, 0, os_sdcard_config);
178178

179-
180179
#if CONFIG_MICROPY_FILESYSTEM_TYPE == 2
181180
//----------------------------------------------------------
182181
STATIC mp_obj_t os_trim(size_t n_args, const mp_obj_t *args)
-17 Bytes
Binary file not shown.
6 Bytes
Binary file not shown.
14 Bytes
Binary file not shown.
6 Bytes
Binary file not shown.
-1 Bytes
Binary file not shown.
-19 Bytes
Binary file not shown.
16 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /