ruby-changes:15121
From: akr <ko1@a...>
Date: Sun, 21 Mar 2010 19:55:06 +0900 (JST)
Subject: [ruby-changes:15121] Ruby:r26998 (trunk): * ext/socket: make sources rdoc friendly.
akr 2010-03-21 19:50:52 +0900 (Sun, 21 Mar 2010) New Revision: 26998 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=26998 Log: * ext/socket: make sources rdoc friendly. Modified files: trunk/ChangeLog trunk/ext/socket/ancdata.c trunk/ext/socket/basicsocket.c trunk/ext/socket/constants.c trunk/ext/socket/ipsocket.c trunk/ext/socket/lib/socket.rb trunk/ext/socket/mkconstants.rb trunk/ext/socket/option.c trunk/ext/socket/rubysocket.h trunk/ext/socket/socket.c trunk/ext/socket/sockssocket.c trunk/ext/socket/tcpserver.c trunk/ext/socket/tcpsocket.c trunk/ext/socket/udpsocket.c trunk/ext/socket/unixserver.c trunk/ext/socket/unixsocket.c Index: ChangeLog =================================================================== --- ChangeLog (revision 26997) +++ ChangeLog (revision 26998) @@ -1,3 +1,7 @@ +Sun Mar 21 19:50:04 2010 Tanaka Akira <akr@f...> + + * ext/socket: make sources rdoc friendly. + Sun Mar 21 17:57:49 2010 Nobuyoshi Nakada <nobu@r...> * io.c (IO_RBUF_CAPA_FOR): use large buffer as cbuf if readconv is Index: ext/socket/tcpsocket.c =================================================================== --- ext/socket/tcpsocket.c (revision 26997) +++ ext/socket/tcpsocket.c (revision 26998) @@ -56,6 +56,8 @@ } /* + * Document-class: ::TCPSocket < IPSocket + * * TCPSocket class */ void Index: ext/socket/rubysocket.h =================================================================== --- ext/socket/rubysocket.h (revision 26997) +++ ext/socket/rubysocket.h (revision 26998) @@ -254,9 +254,19 @@ 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 Index: ext/socket/udpsocket.c =================================================================== --- ext/socket/udpsocket.c (revision 26997) +++ ext/socket/udpsocket.c (revision 26998) @@ -247,6 +247,8 @@ } /* + * Document-class: ::UDPSocket < IPSocket + * * UDPSocket class */ void Index: ext/socket/option.c =================================================================== --- ext/socket/option.c (revision 26997) +++ ext/socket/option.c (revision 26998) @@ -658,12 +658,12 @@ 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); Index: ext/socket/unixserver.c =================================================================== --- ext/socket/unixserver.c (revision 26997) +++ ext/socket/unixserver.c (revision 26998) @@ -136,6 +136,8 @@ #endif /* + * Document-class: ::UNIXServer < UNIXSocket + * * UNIXServer class */ void @@ -147,5 +149,6 @@ 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 } Index: ext/socket/constants.c =================================================================== --- ext/socket/constants.c (revision 26997) +++ ext/socket/constants.c (revision 26998) @@ -141,6 +141,5 @@ Init_socket_constants(void) { /* constants */ - rb_mSockConst = rb_define_module_under(rb_cSocket, "Constants"); init_constants(); } Index: ext/socket/tcpserver.c =================================================================== --- ext/socket/tcpserver.c (revision 26997) +++ ext/socket/tcpserver.c (revision 26998) @@ -129,6 +129,8 @@ } /* + * Document-class: ::TCPServer < TCPSocket + * * TCPServer class */ void @@ -139,4 +141,5 @@ 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 */ } Index: ext/socket/ipsocket.c =================================================================== --- ext/socket/ipsocket.c (revision 26997) +++ ext/socket/ipsocket.c (revision 26998) @@ -284,6 +284,8 @@ } /* + * Document-class: ::IPSocket < BasicSocket + * * IPSocket class */ void Index: ext/socket/lib/socket.rb =================================================================== --- ext/socket/lib/socket.rb (revision 26997) +++ ext/socket/lib/socket.rb (revision 26998) @@ -158,7 +158,7 @@ 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 @@ 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 Index: ext/socket/mkconstants.rb =================================================================== --- ext/socket/mkconstants.rb (revision 26997) +++ ext/socket/mkconstants.rb (revision 26998) @@ -83,7 +83,9 @@ 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 @@ <%= 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") %> Index: ext/socket/socket.c =================================================================== --- ext/socket/socket.c (revision 26997) +++ ext/socket/socket.c (revision 26998) @@ -485,8 +485,8 @@ * * 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 @@ #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 @@ 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 @@ #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 } Index: ext/socket/basicsocket.c =================================================================== --- ext/socket/basicsocket.c (revision 26997) +++ ext/socket/basicsocket.c (revision 26998) @@ -747,4 +747,10 @@ 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 */ + } Index: ext/socket/ancdata.c =================================================================== --- ext/socket/ancdata.c (revision 26997) +++ ext/socket/ancdata.c (revision 26998) @@ -1325,13 +1325,13 @@ * 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 @@ * 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 @@ * } * */ -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 @@ * 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); Index: ext/socket/sockssocket.c =================================================================== --- ext/socket/sockssocket.c (revision 26997) +++ ext/socket/sockssocket.c (revision 26998) @@ -41,6 +41,8 @@ #endif /* + * Document-class: ::SOCKSSocket < TCPSocket + * * SOCKSSocket class */ void Index: ext/socket/unixsocket.c =================================================================== --- ext/socket/unixsocket.c (revision 26997) +++ ext/socket/unixsocket.c (revision 26998) @@ -485,6 +485,8 @@ #endif /* + * Document-class: ::UNIXSocket < BasicSocket + * * UNIXSocket class */ void -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/