summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorPaul Sokolovsky <pfalcon@users.sourceforge.net>2014-10-09 20:43:10 +0300
committerPaul Sokolovsky <pfalcon@users.sourceforge.net>2014-10-09 20:43:10 +0300
commit23b3b04072345c372ff202e39357ceb4422c16db (patch)
tree31ab6c219f8c219229eda826fa6c037f8539c132
parenta2d8f98a7ebff40e0e6271566d7d49b43966f12b (diff)
downloadmicropython-23b3b04072345c372ff202e39357ceb4422c16db.tar.gz
micropython-23b3b04072345c372ff202e39357ceb4422c16db.zip
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.
-rw-r--r--examples/unix/http-client.py2
-rw-r--r--examples/unix/http-server.py2
-rw-r--r--unix/main.c4
-rw-r--r--unix/modsocket.c26
-rw-r--r--unix/mpconfigport.h2
-rw-r--r--unix/qstrdefsport.h2
6 files changed, 17 insertions, 21 deletions
diff --git a/examples/unix/http-client.py b/examples/unix/http-client.py
index 858420b99f..f042bfeb83 100644
--- a/examples/unix/http-client.py
+++ b/examples/unix/http-client.py
@@ -1,5 +1,5 @@
try:
- import microsocket as _socket
+ import usocket as _socket
except:
import _socket
diff --git a/examples/unix/http-server.py b/examples/unix/http-server.py
index f99d7974a7..7affafcfd6 100644
--- a/examples/unix/http-server.py
+++ b/examples/unix/http-server.py
@@ -1,5 +1,5 @@
try:
- import microsocket as socket
+ import usocket as socket
except:
import socket
diff --git a/unix/main.c b/unix/main.c
index 51a741841f..86d7e9eb4b 100644
--- a/unix/main.c
+++ b/unix/main.c
@@ -64,10 +64,6 @@ mp_uint_t mp_verbose_flag = 0;
long heap_size = 128*1024 * (sizeof(mp_uint_t) / 4);
#endif
-void microsocket_init();
-void time_init();
-void ffi_init();
-
#define FORCED_EXIT (0x100)
// returns standard error codes: 0 for success, 1 for all other errors
// if FORCED_EXIT bit is set then script raised SystemExit and the
diff --git a/unix/modsocket.c b/unix/modsocket.c
index 76787184a0..483b6c8004 100644
--- a/unix/modsocket.c
+++ b/unix/modsocket.c
@@ -53,11 +53,11 @@
/*
The idea of this module is to implement reasonable minimum of
socket-related functions to write typical clients and servers.
- The module named "microsocket" on purpose, to allow to make
+ The module named "usocket" on purpose, to allow to make
Python-level module more (or fully) compatible with CPython
"socket", e.g.:
---- socket.py ----
- from microsocket import *
+ from usocket import *
from socket_more_funcs import *
from socket_more_funcs2 import *
-------------------
@@ -72,7 +72,7 @@ typedef struct _mp_obj_socket_t {
int fd;
} mp_obj_socket_t;
-STATIC const mp_obj_type_t microsocket_type;
+STATIC const mp_obj_type_t usocket_type;
// Helper functions
#define RAISE_ERRNO(err_flag, error_val) \
@@ -81,7 +81,7 @@ STATIC const mp_obj_type_t microsocket_type;
STATIC mp_obj_socket_t *socket_new(int fd) {
mp_obj_socket_t *o = m_new_obj(mp_obj_socket_t);
- o->base.type = &microsocket_type;
+ o->base.type = &usocket_type;
o->fd = fd;
return o;
}
@@ -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_
return socket_new(fd);
}
-STATIC const mp_map_elem_t microsocket_locals_dict_table[] = {
+STATIC const mp_map_elem_t usocket_locals_dict_table[] = {
{ MP_OBJ_NEW_QSTR(MP_QSTR_fileno), (mp_obj_t)&socket_fileno_obj },
{ MP_OBJ_NEW_QSTR(MP_QSTR_makefile), (mp_obj_t)&socket_makefile_obj },
{ 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[] = {
{ MP_OBJ_NEW_QSTR(MP_QSTR_close), (mp_obj_t)&socket_close_obj },
};
-STATIC MP_DEFINE_CONST_DICT(microsocket_locals_dict, microsocket_locals_dict_table);
+STATIC MP_DEFINE_CONST_DICT(usocket_locals_dict, usocket_locals_dict_table);
-STATIC const mp_stream_p_t microsocket_stream_p = {
+STATIC const mp_stream_p_t usocket_stream_p = {
.read = socket_read,
.write = socket_write,
};
-STATIC const mp_obj_type_t microsocket_type = {
+STATIC const mp_obj_type_t usocket_type = {
{ &mp_type_type },
.name = MP_QSTR_socket,
.print = socket_print,
.make_new = socket_make_new,
.getiter = NULL,
.iternext = NULL,
- .stream_p = &microsocket_stream_p,
- .locals_dict = (mp_obj_t)&microsocket_locals_dict,
+ .stream_p = &usocket_stream_p,
+ .locals_dict = (mp_obj_t)&usocket_locals_dict,
};
#if MICROPY_SOCKET_EXTRA
@@ -420,8 +420,8 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_socket_getaddrinfo_obj, 2, 6, mod
extern mp_obj_type_t sockaddr_in_type;
STATIC const mp_map_elem_t mp_module_socket_globals_table[] = {
- { MP_OBJ_NEW_QSTR(MP_QSTR___name__), MP_OBJ_NEW_QSTR(MP_QSTR_microsocket) },
- { MP_OBJ_NEW_QSTR(MP_QSTR_socket), (mp_obj_t)&microsocket_type },
+ { MP_OBJ_NEW_QSTR(MP_QSTR___name__), MP_OBJ_NEW_QSTR(MP_QSTR_usocket) },
+ { MP_OBJ_NEW_QSTR(MP_QSTR_socket), (mp_obj_t)&usocket_type },
{ MP_OBJ_NEW_QSTR(MP_QSTR_getaddrinfo), (mp_obj_t)&mod_socket_getaddrinfo_obj },
#if MICROPY_SOCKET_EXTRA
{ 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 = {
const mp_obj_module_t mp_module_socket = {
.base = { &mp_type_module },
- .name = MP_QSTR_microsocket,
+ .name = MP_QSTR_usocket,
.globals = (mp_obj_dict_t*)&mp_module_socket_globals,
};
diff --git a/unix/mpconfigport.h b/unix/mpconfigport.h
index 4475c93f70..6ca0808628 100644
--- a/unix/mpconfigport.h
+++ b/unix/mpconfigport.h
@@ -99,7 +99,7 @@ extern const struct _mp_obj_module_t mp_module_ffi;
#define MICROPY_PORT_BUILTIN_MODULES \
MICROPY_PY_FFI_DEF \
MICROPY_PY_TIME_DEF \
- { MP_OBJ_NEW_QSTR(MP_QSTR_microsocket), (mp_obj_t)&mp_module_socket }, \
+ { MP_OBJ_NEW_QSTR(MP_QSTR_usocket), (mp_obj_t)&mp_module_socket }, \
{ MP_OBJ_NEW_QSTR(MP_QSTR__os), (mp_obj_t)&mp_module_os }, \
MICROPY_PY_TERMIOS_DEF \
diff --git a/unix/qstrdefsport.h b/unix/qstrdefsport.h
index 1e2f79fc99..dcc57da7e1 100644
--- a/unix/qstrdefsport.h
+++ b/unix/qstrdefsport.h
@@ -58,7 +58,7 @@ Q(htons)
Q(inet_aton)
Q(gethostbyname)
Q(getaddrinfo)
-Q(microsocket)
+Q(usocket)
Q(connect)
Q(bind)
Q(listen)