summaryrefslogtreecommitdiff
path: root/shared-bindings/socket
diff options
context:
space:
mode:
authorTaku Fukada <naninunenor@gmail.com>2020-08-03 13:35:43 +0900
committerTaku Fukada <naninunenor@gmail.com>2020-08-07 01:01:28 +0900
commit56c898da80df57d0e83f4e8d1ee44f4351ce1d8c (patch)
tree06f32bb910bca32cd33e96c134b5a18f86f5c5e7 /shared-bindings/socket
parent887eb3b6d9a3ef8c6300448492f1177a609feef6 (diff)
Modify some Python stubs
Diffstat (limited to 'shared-bindings/socket')
-rw-r--r--shared-bindings/socket/__init__.c49
1 files changed, 29 insertions, 20 deletions
diff --git a/shared-bindings/socket/__init__.c b/shared-bindings/socket/__init__.c
index 53ac57d11..38840da5e 100644
--- a/shared-bindings/socket/__init__.c
+++ b/shared-bindings/socket/__init__.c
@@ -52,11 +52,17 @@ STATIC const mp_obj_type_t socket_type;
//| def __init__(self, family: int, type: int, proto: int) -> None:
//| """Create a new socket
//|
-//| :param ~int family: AF_INET or AF_INET6
-//| :param ~int type: SOCK_STREAM, SOCK_DGRAM or SOCK_RAW
-//| :param ~int proto: IPPROTO_TCP, IPPROTO_UDP or IPPROTO_RAW (ignored)"""
+//| :param int family: AF_INET or AF_INET6
+//| :param int type: SOCK_STREAM, SOCK_DGRAM or SOCK_RAW
+//| :param int proto: IPPROTO_TCP, IPPROTO_UDP or IPPROTO_RAW (ignored)"""
//| ...
//|
+//| AF_INET: int
+//| AF_INET6: int
+//| SOCK_STREAM: int
+//| SOCK_DGRAM: int
+//| SOCK_RAW: int
+//|
STATIC mp_obj_t socket_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) {
mp_arg_check_num(n_args, kw_args, 0, 4, false);
@@ -96,10 +102,11 @@ STATIC void socket_select_nic(mod_network_socket_obj_t *self, const byte *ip) {
}
}
-//| def bind(self, address: tuple) -> None:
+//| def bind(self, address: Tuple[str, int]) -> None:
//| """Bind a socket to an address
//|
-//| :param ~tuple address: tuple of (remote_address, remote_port)"""
+//| :param address: tuple of (remote_address, remote_port)
+//| :type address: tuple(str, int)"""
//| ...
//|
@@ -126,7 +133,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_2(socket_bind_obj, socket_bind);
//| def listen(self, backlog: int) -> None:
//| """Set socket to listen for incoming connections
//|
-//| :param ~int backlog: length of backlog queue for waiting connetions"""
+//| :param int backlog: length of backlog queue for waiting connetions"""
//| ...
//|
@@ -148,7 +155,7 @@ STATIC mp_obj_t socket_listen(mp_obj_t self_in, mp_obj_t backlog) {
}
STATIC MP_DEFINE_CONST_FUN_OBJ_2(socket_listen_obj, socket_listen);
-//| def accept(self) -> tuple:
+//| def accept(self) -> Tuple[socket, str]:
//| """Accept a connection on a listening socket of type SOCK_STREAM,
//| creating a new socket of type SOCK_STREAM.
//| Returns a tuple of (new_socket, remote_address)"""
@@ -185,10 +192,11 @@ STATIC mp_obj_t socket_accept(mp_obj_t self_in) {
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(socket_accept_obj, socket_accept);
-//| def connect(self, address: tuple) -> None:
+//| def connect(self, address: Tuple[str, int]) -> None:
//| """Connect a socket to a remote address
//|
-//| :param ~tuple address: tuple of (remote_address, remote_port)"""
+//| :param address: tuple of (remote_address, remote_port)
+//| :type address: tuple(str, int)"""
//| ...
//|
@@ -216,7 +224,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_2(socket_connect_obj, socket_connect);
//| """Send some bytes to the connected remote address.
//| Suits sockets of type SOCK_STREAM
//|
-//| :param ~bytes bytes: some bytes to send"""
+//| :param ~_typing.ReadableBuffer bytes: some bytes to send"""
//| ...
//|
@@ -259,7 +267,7 @@ STATIC mp_int_t _socket_recv_into(mod_network_socket_obj_t *sock, byte *buf, mp_
//| Suits sockets of type SOCK_STREAM
//| Returns an int of number of bytes read.
//|
-//| :param bytearray buffer: buffer to receive into
+//| :param ~_typing.WriteableBuffer buffer: buffer to receive into
//| :param int bufsize: optionally, a maximum number of bytes to read."""
//| ...
//|
@@ -290,7 +298,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(socket_recv_into_obj, 2, 3, socket_re
//| Suits sockets of type SOCK_STREAM
//| Returns a bytes() of length <= bufsize
//|
-//| :param ~int bufsize: maximum number of bytes to receive"""
+//| :param int bufsize: maximum number of bytes to receive"""
//| ...
//|
@@ -312,12 +320,13 @@ STATIC mp_obj_t socket_recv(mp_obj_t self_in, mp_obj_t len_in) {
}
STATIC MP_DEFINE_CONST_FUN_OBJ_2(socket_recv_obj, socket_recv);
-//| def sendto(self, bytes: ReadableBuffer, address: tuple) -> int:
+//| def sendto(self, bytes: ReadableBuffer, address: Tuple[str, int]) -> int:
//| """Send some bytes to a specific address.
//| Suits sockets of type SOCK_DGRAM
//|
-//| :param ~bytes bytes: some bytes to send
-//| :param ~tuple address: tuple of (remote_address, remote_port)"""
+//| :param ~_typing.ReadableBuffer bytes: some bytes to send
+//| :param address: tuple of (remote_address, remote_port)
+//| :type address: tuple(str, int)"""
//| ...
//|
@@ -346,7 +355,7 @@ STATIC mp_obj_t socket_sendto(mp_obj_t self_in, mp_obj_t data_in, mp_obj_t addr_
}
STATIC MP_DEFINE_CONST_FUN_OBJ_3(socket_sendto_obj, socket_sendto);
-//| def recvfrom(self, bufsize: int) -> Tuple[bytes, tuple]:
+//| def recvfrom(self, bufsize: int) -> Tuple[bytes, Tuple[str, int]]:
//| """Reads some bytes from the connected remote address.
//| Suits sockets of type SOCK_STREAM
//|
@@ -354,7 +363,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_3(socket_sendto_obj, socket_sendto);
//| * a bytes() of length <= bufsize
//| * a remote_address, which is a tuple of ip address and port number
//|
-//| :param ~int bufsize: maximum number of bytes to receive"""
+//| :param int bufsize: maximum number of bytes to receive"""
//| ...
//|
@@ -422,7 +431,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(socket_setsockopt_obj, 4, 4, socket_s
//| def settimeout(self, value: int) -> None:
//| """Set the timeout value for this socket.
//|
-//| :param ~int value: timeout in seconds. 0 means non-blocking. None means block indefinitely."""
+//| :param int value: timeout in seconds. 0 means non-blocking. None means block indefinitely."""
//| ...
//|
@@ -453,7 +462,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_2(socket_settimeout_obj, socket_settimeout);
//| def setblocking(self, flag: bool) -> Optional[int]:
//| """Set the blocking behaviour of this socket.
//|
-//| :param ~bool flag: False means non-blocking, True means block indefinitely."""
+//| :param bool flag: False means non-blocking, True means block indefinitely."""
//| ...
//|
@@ -512,7 +521,7 @@ STATIC const mp_obj_type_t socket_type = {
.locals_dict = (mp_obj_dict_t*)&socket_locals_dict,
};
-//| def getaddrinfo(host: str, port: int) -> tuple:
+//| def getaddrinfo(host: str, port: int) -> Tuple[int, int, int, str, str]:
//| """Gets the address information for a hostname and port
//|
//| Returns the appropriate family, socket type, socket protocol and