1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* ext/socket: make sources rdoc friendly.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26998 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
akr 2010-03-21 10:50:52 +00:00
parent cce4892c1f
commit daa739876f
16 changed files with 66 additions and 38 deletions

View file

@ -1,3 +1,7 @@
Sun Mar 21 19:50:04 2010 Tanaka Akira <akr@fsij.org>
* ext/socket: make sources rdoc friendly.
Sun Mar 21 17:57:49 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
* io.c (IO_RBUF_CAPA_FOR): use large buffer as cbuf if readconv is

View file

@ -1325,13 +1325,13 @@ bsock_sendmsg_internal(int argc, VALUE *argv, VALUE sock, int nonblock)
* sock.sendmsg("\0", 0, nil, ancdata)
*
*/
static VALUE
bsock_sendmsg(int argc, VALUE *argv, VALUE sock)
VALUE
rsock_bsock_sendmsg(int argc, VALUE *argv, VALUE sock)
{
return bsock_sendmsg_internal(argc, argv, sock, 0);
}
#else
#define bsock_sendmsg rb_f_notimplement
#define rsock_bsock_sendmsg rb_f_notimplement
#endif
#if defined(HAVE_SENDMSG)
@ -1346,8 +1346,8 @@ bsock_sendmsg(int argc, VALUE *argv, VALUE sock)
* and it doesn't retry the system call.
*
*/
static VALUE
bsock_sendmsg_nonblock(int argc, VALUE *argv, VALUE sock)
VALUE
rsock_bsock_sendmsg_nonblock(int argc, VALUE *argv, VALUE sock)
{
return bsock_sendmsg_internal(argc, argv, sock, 1);
}
@ -1737,13 +1737,13 @@ bsock_recvmsg_internal(int argc, VALUE *argv, VALUE sock, int nonblock)
* }
*
*/
static VALUE
bsock_recvmsg(int argc, VALUE *argv, VALUE sock)
VALUE
rsock_bsock_recvmsg(int argc, VALUE *argv, VALUE sock)
{
return bsock_recvmsg_internal(argc, argv, sock, 0);
}
#else
#define bsock_recvmsg rb_f_notimplement
#define rsock_bsock_recvmsg rb_f_notimplement
#endif
#if defined(HAVE_RECVMSG)
@ -1758,27 +1758,21 @@ bsock_recvmsg(int argc, VALUE *argv, VALUE sock)
* and it doesn't retry the system call.
*
*/
static VALUE
bsock_recvmsg_nonblock(int argc, VALUE *argv, VALUE sock)
VALUE
rsock_bsock_recvmsg_nonblock(int argc, VALUE *argv, VALUE sock)
{
return bsock_recvmsg_internal(argc, argv, sock, 1);
}
#else
#define bsock_recvmsg_nonblock rb_f_notimplement
#define rsock_bsock_recvmsg_nonblock rb_f_notimplement
#endif
/*
* Document-class: ::Socket::AncillaryData
*/
void
Init_ancdata(void)
{
/* for rdoc */
/* rb_cBasicSocket = rb_define_class("BasicSocket", rb_cIO); */
/* rb_cSocket = rb_define_class("Socket", rb_cBasicSocket); */
rb_define_method(rb_cBasicSocket, "sendmsg", bsock_sendmsg, -1);
rb_define_method(rb_cBasicSocket, "sendmsg_nonblock", bsock_sendmsg_nonblock, -1);
rb_define_method(rb_cBasicSocket, "recvmsg", bsock_recvmsg, -1);
rb_define_method(rb_cBasicSocket, "recvmsg_nonblock", bsock_recvmsg_nonblock, -1);
#if defined(HAVE_ST_MSG_CONTROL)
rb_cAncillaryData = rb_define_class_under(rb_cSocket, "AncillaryData", rb_cObject);
rb_define_method(rb_cAncillaryData, "initialize", ancillary_initialize, 4);

View file

@ -747,4 +747,10 @@ Init_basicsocket(void)
rb_define_method(rb_cBasicSocket, "recv_nonblock", bsock_recv_nonblock, -1);
rb_define_method(rb_cBasicSocket, "do_not_reverse_lookup", bsock_do_not_reverse_lookup, 0);
rb_define_method(rb_cBasicSocket, "do_not_reverse_lookup=", bsock_do_not_reverse_lookup_set, 1);
rb_define_method(rb_cBasicSocket, "sendmsg", rsock_bsock_sendmsg, -1); /* in ancdata.c */
rb_define_method(rb_cBasicSocket, "sendmsg_nonblock", rsock_bsock_sendmsg_nonblock, -1); /* in ancdata.c */
rb_define_method(rb_cBasicSocket, "recvmsg", rsock_bsock_recvmsg, -1); /* in ancdata.c */
rb_define_method(rb_cBasicSocket, "recvmsg_nonblock", rsock_bsock_recvmsg_nonblock, -1); /* in ancdata.c */
}

View file

@ -141,6 +141,5 @@ void
Init_socket_constants(void)
{
/* constants */
rb_mSockConst = rb_define_module_under(rb_cSocket, "Constants");
init_constants();
}

View file

@ -284,6 +284,8 @@ ip_s_getaddress(VALUE obj, VALUE host)
}
/*
* Document-class: ::IPSocket < BasicSocket
*
* IPSocket class
*/
void

View file

@ -158,7 +158,7 @@ class Addrinfo
end
end
class BasicSocket
class BasicSocket < IO
# Returns an address of the socket suitable for connect in the local machine.
#
# This method returns _self_.local_address, except following condition.
@ -200,7 +200,7 @@ class BasicSocket
end
end
class Socket
class Socket < BasicSocket
# enable the socket option IPV6_V6ONLY if IPV6_V6ONLY is available.
def ipv6only!
if defined? Socket::IPV6_V6ONLY

View file

@ -83,7 +83,9 @@ EOS
ERB.new(<<'EOS', nil, '%').def_method(Object, "gen_const_defs_in_guard(make_value, name, default_value)")
#if defined(<%=name%>)
/* <%=name%>: */
rb_define_const(rb_cSocket, <%=c_str name%>, <%=make_value%>(<%=name%>));
/* <%=name%>: */
rb_define_const(rb_mSockConst, <%=c_str name%>, <%=make_value%>(<%=name%>));
#endif
EOS
@ -272,12 +274,13 @@ result = ERB.new(<<'EOS', nil, '%').result(binding)
<%= INTERN_DEFS.map {|vardef, gen_hash, decl, func| vardef }.join("\n") %>
/*
* Document-module: Socket::Constants
*/
static void
init_constants(void)
{
/* for rdoc */
/* rb_cSocket = rb_define_class("Socket", rb_cBasicSocket); */
/* rb_mSockConst = rb_define_module_under(rb_cSocket, "Constants"); */
rb_mSockConst = rb_define_module_under(rb_cSocket, "Constants");
<%= gen_const_defs %>
<%= INTERN_DEFS.map {|vardef, gen_hash, decl, func| gen_hash }.join("\n") %>

View file

@ -658,12 +658,12 @@ sockopt_unpack(VALUE self, VALUE template)
return rb_funcall(sockopt_data(self), rb_intern("unpack"), 1, template);
}
/*
* Document-class: ::Socket::Option
*/
void
Init_sockopt(void)
{
/* for rdoc */
/* rb_cSocket = rb_define_class("Socket", rb_cBasicSocket); */
rb_cSockOpt = rb_define_class_under(rb_cSocket, "Option", rb_cObject);
rb_define_method(rb_cSockOpt, "initialize", sockopt_initialize, 4);
rb_define_method(rb_cSockOpt, "family", sockopt_family_m, 0);

View file

@ -254,9 +254,19 @@ int rsock_connect(int fd, const struct sockaddr *sockaddr, int len, int socks);
VALUE rsock_s_accept(VALUE klass, int fd, struct sockaddr *sockaddr, socklen_t *len);
VALUE rsock_s_accept_nonblock(VALUE klass, rb_io_t *fptr, struct sockaddr *sockaddr, socklen_t *len);
VALUE rsock_sock_listen(VALUE sock, VALUE log);
VALUE rsock_sockopt_new(int family, int level, int optname, VALUE data);
#if defined(HAVE_SENDMSG)
VALUE rsock_bsock_sendmsg(int argc, VALUE *argv, VALUE sock);
VALUE rsock_bsock_sendmsg_nonblock(int argc, VALUE *argv, VALUE sock);
#endif
#if defined(HAVE_RECVMSG)
VALUE rsock_bsock_recvmsg(int argc, VALUE *argv, VALUE sock);
VALUE rsock_bsock_recvmsg_nonblock(int argc, VALUE *argv, VALUE sock);
#endif
#ifdef HAVE_ST_MSG_CONTROL
void rsock_discard_cmsg_resource(struct msghdr *mh);
#endif

View file

@ -485,8 +485,8 @@ sock_bind(VALUE sock, VALUE addr)
* * listen manual pages on unix-based systems
* * listen function in Microsoft's Winsock functions reference
*/
static VALUE
sock_listen(VALUE sock, VALUE log)
VALUE
rsock_sock_listen(VALUE sock, VALUE log)
{
rb_io_t *fptr;
int backlog;
@ -1780,6 +1780,8 @@ socket_s_ip_address_list(VALUE self)
#endif
/*
* Document-class: ::Socket < BasicSocket
*
* Class +Socket+ provides access to the underlying operating system
* socket implementations. It can be used to provide more operating system
* specific functionality than the protocol-specific socket classes but at the
@ -1817,7 +1819,7 @@ Init_socket()
rb_define_method(rb_cSocket, "connect", sock_connect, 1);
rb_define_method(rb_cSocket, "connect_nonblock", sock_connect_nonblock, 1);
rb_define_method(rb_cSocket, "bind", sock_bind, 1);
rb_define_method(rb_cSocket, "listen", sock_listen, 1);
rb_define_method(rb_cSocket, "listen", rsock_sock_listen, 1);
rb_define_method(rb_cSocket, "accept", sock_accept, 0);
rb_define_method(rb_cSocket, "accept_nonblock", sock_accept_nonblock, 0);
rb_define_method(rb_cSocket, "sysaccept", sock_sysaccept, 0);
@ -1844,10 +1846,4 @@ Init_socket()
#endif
rb_define_singleton_method(rb_cSocket, "ip_address_list", socket_s_ip_address_list, 0);
/* defined here for rdoc */
rb_define_method(rb_cTCPServer, "listen", sock_listen, 1);
#ifdef HAVE_SYS_UN_H
rb_define_method(rb_cUNIXServer, "listen", sock_listen, 1);
#endif
}

View file

@ -41,6 +41,8 @@ socks_s_close(VALUE sock)
#endif
/*
* Document-class: ::SOCKSSocket < TCPSocket
*
* SOCKSSocket class
*/
void

View file

@ -129,6 +129,8 @@ tcp_sysaccept(VALUE sock)
}
/*
* Document-class: ::TCPServer < TCPSocket
*
* TCPServer class
*/
void
@ -139,4 +141,5 @@ Init_tcpserver(void)
rb_define_method(rb_cTCPServer, "accept_nonblock", tcp_accept_nonblock, 0);
rb_define_method(rb_cTCPServer, "sysaccept", tcp_sysaccept, 0);
rb_define_method(rb_cTCPServer, "initialize", tcp_svr_init, -1);
rb_define_method(rb_cTCPServer, "listen", rsock_sock_listen, 1); /* in socket.c */
}

View file

@ -56,6 +56,8 @@ tcp_s_gethostbyname(VALUE obj, VALUE host)
}
/*
* Document-class: ::TCPSocket < IPSocket
*
* TCPSocket class
*/
void

View file

@ -247,6 +247,8 @@ udp_recvfrom_nonblock(int argc, VALUE *argv, VALUE sock)
}
/*
* Document-class: ::UDPSocket < IPSocket
*
* UDPSocket class
*/
void

View file

@ -136,6 +136,8 @@ unix_sysaccept(VALUE sock)
#endif
/*
* Document-class: ::UNIXServer < UNIXSocket
*
* UNIXServer class
*/
void
@ -147,5 +149,6 @@ Init_unixserver(void)
rb_define_method(rb_cUNIXServer, "accept", unix_accept, 0);
rb_define_method(rb_cUNIXServer, "accept_nonblock", unix_accept_nonblock, 0);
rb_define_method(rb_cUNIXServer, "sysaccept", unix_sysaccept, 0);
rb_define_method(rb_cUNIXServer, "listen", rsock_sock_listen, 1); /* in socket.c */
#endif
}

View file

@ -485,6 +485,8 @@ unix_s_socketpair(int argc, VALUE *argv, VALUE klass)
#endif
/*
* Document-class: ::UNIXSocket < BasicSocket
*
* UNIXSocket class
*/
void