Skip to content

Commit 23b3b04

Browse files
committed
unix: Rename "microsocket" module to "usocket".
Per new conventions, we'd like to consistently use "u*" naming conventions for modules which don't offer complete CPython compatibility, while offer subset or similar API.
1 parent a2d8f98 commit 23b3b04

6 files changed

Lines changed: 17 additions & 21 deletions

File tree

examples/unix/http-client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
try:
2-
import microsocket as _socket
2+
import usocket as _socket
33
except:
44
import _socket
55

examples/unix/http-server.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
try:
2-
import microsocket as socket
2+
import usocket as socket
33
except:
44
import socket
55

unix/main.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,6 @@ mp_uint_t mp_verbose_flag = 0;
6464
long heap_size = 128*1024 * (sizeof(mp_uint_t) / 4);
6565
#endif
6666

67-
void microsocket_init();
68-
void time_init();
69-
void ffi_init();
70-
7167
#define FORCED_EXIT (0x100)
7268
// returns standard error codes: 0 for success, 1 for all other errors
7369
// if FORCED_EXIT bit is set then script raised SystemExit and the

unix/modsocket.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,11 @@
5353
/*
5454
The idea of this module is to implement reasonable minimum of
5555
socket-related functions to write typical clients and servers.
56-
The module named "microsocket" on purpose, to allow to make
56+
The module named "usocket" on purpose, to allow to make
5757
Python-level module more (or fully) compatible with CPython
5858
"socket", e.g.:
5959
---- socket.py ----
60-
from microsocket import *
60+
from usocket import *
6161
from socket_more_funcs import *
6262
from socket_more_funcs2 import *
6363
-------------------
@@ -72,7 +72,7 @@ typedef struct _mp_obj_socket_t {
7272
int fd;
7373
} mp_obj_socket_t;
7474

75-
STATIC const mp_obj_type_t microsocket_type;
75+
STATIC const mp_obj_type_t usocket_type;
7676

7777
// Helper functions
7878
#define RAISE_ERRNO(err_flag, error_val) \
@@ -81,7 +81,7 @@ STATIC const mp_obj_type_t microsocket_type;
8181

8282
STATIC mp_obj_socket_t *socket_new(int fd) {
8383
mp_obj_socket_t *o = m_new_obj(mp_obj_socket_t);
84-
o->base.type = &microsocket_type;
84+
o->base.type = &usocket_type;
8585
o->fd = fd;
8686
return o;
8787
}
@@ -284,7 +284,7 @@ STATIC mp_obj_t socket_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_
284284
return socket_new(fd);
285285
}
286286

287-
STATIC const mp_map_elem_t microsocket_locals_dict_table[] = {
287+
STATIC const mp_map_elem_t usocket_locals_dict_table[] = {
288288
{ MP_OBJ_NEW_QSTR(MP_QSTR_fileno), (mp_obj_t)&socket_fileno_obj },
289289
{ MP_OBJ_NEW_QSTR(MP_QSTR_makefile), (mp_obj_t)&socket_makefile_obj },
290290
{ MP_OBJ_NEW_QSTR(MP_QSTR_read), (mp_obj_t)&mp_stream_read_obj },
@@ -302,22 +302,22 @@ STATIC const mp_map_elem_t microsocket_locals_dict_table[] = {
302302
{ MP_OBJ_NEW_QSTR(MP_QSTR_close), (mp_obj_t)&socket_close_obj },
303303
};
304304

305-
STATIC MP_DEFINE_CONST_DICT(microsocket_locals_dict, microsocket_locals_dict_table);
305+
STATIC MP_DEFINE_CONST_DICT(usocket_locals_dict, usocket_locals_dict_table);
306306

307-
STATIC const mp_stream_p_t microsocket_stream_p = {
307+
STATIC const mp_stream_p_t usocket_stream_p = {
308308
.read = socket_read,
309309
.write = socket_write,
310310
};
311311

312-
STATIC const mp_obj_type_t microsocket_type = {
312+
STATIC const mp_obj_type_t usocket_type = {
313313
{ &mp_type_type },
314314
.name = MP_QSTR_socket,
315315
.print = socket_print,
316316
.make_new = socket_make_new,
317317
.getiter = NULL,
318318
.iternext = NULL,
319-
.stream_p = &microsocket_stream_p,
320-
.locals_dict = (mp_obj_t)&microsocket_locals_dict,
319+
.stream_p = &usocket_stream_p,
320+
.locals_dict = (mp_obj_t)&usocket_locals_dict,
321321
};
322322

323323
#if MICROPY_SOCKET_EXTRA
@@ -420,8 +420,8 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_socket_getaddrinfo_obj, 2, 6, mod
420420
extern mp_obj_type_t sockaddr_in_type;
421421

422422
STATIC const mp_map_elem_t mp_module_socket_globals_table[] = {
423-
{ MP_OBJ_NEW_QSTR(MP_QSTR___name__), MP_OBJ_NEW_QSTR(MP_QSTR_microsocket) },
424-
{ MP_OBJ_NEW_QSTR(MP_QSTR_socket), (mp_obj_t)&microsocket_type },
423+
{ MP_OBJ_NEW_QSTR(MP_QSTR___name__), MP_OBJ_NEW_QSTR(MP_QSTR_usocket) },
424+
{ MP_OBJ_NEW_QSTR(MP_QSTR_socket), (mp_obj_t)&usocket_type },
425425
{ MP_OBJ_NEW_QSTR(MP_QSTR_getaddrinfo), (mp_obj_t)&mod_socket_getaddrinfo_obj },
426426
#if MICROPY_SOCKET_EXTRA
427427
{ MP_OBJ_NEW_QSTR(MP_QSTR_sockaddr_in), (mp_obj_t)&sockaddr_in_type },
@@ -463,6 +463,6 @@ STATIC const mp_obj_dict_t mp_module_socket_globals = {
463463

464464
const mp_obj_module_t mp_module_socket = {
465465
.base = { &mp_type_module },
466-
.name = MP_QSTR_microsocket,
466+
.name = MP_QSTR_usocket,
467467
.globals = (mp_obj_dict_t*)&mp_module_socket_globals,
468468
};

unix/mpconfigport.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ extern const struct _mp_obj_module_t mp_module_ffi;
9999
#define MICROPY_PORT_BUILTIN_MODULES \
100100
MICROPY_PY_FFI_DEF \
101101
MICROPY_PY_TIME_DEF \
102-
{ MP_OBJ_NEW_QSTR(MP_QSTR_microsocket), (mp_obj_t)&mp_module_socket }, \
102+
{ MP_OBJ_NEW_QSTR(MP_QSTR_usocket), (mp_obj_t)&mp_module_socket }, \
103103
{ MP_OBJ_NEW_QSTR(MP_QSTR__os), (mp_obj_t)&mp_module_os }, \
104104
MICROPY_PY_TERMIOS_DEF \
105105

unix/qstrdefsport.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ Q(htons)
5858
Q(inet_aton)
5959
Q(gethostbyname)
6060
Q(getaddrinfo)
61-
Q(microsocket)
61+
Q(usocket)
6262
Q(connect)
6363
Q(bind)
6464
Q(listen)

0 commit comments

Comments
 (0)