* ext/socket/mkconstants.rb (Socket::AF_INET6): moved from socket.c.

(Socket::PF_INET6): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@21237 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
akr 2009-01-01 07:04:31 +00:00
parent 1c0e798d5c
commit 2b3e480bef
3 changed files with 21 additions and 7 deletions

View File

@ -1,3 +1,8 @@
Thu Jan 1 16:03:04 2009 Tanaka Akira <akr@fsij.org>
* ext/socket/mkconstants.rb (Socket::AF_INET6): moved from socket.c.
(Socket::PF_INET6): ditto.
Thu Jan 1 15:27:07 2009 Tanaka Akira <akr@fsij.org> Thu Jan 1 15:27:07 2009 Tanaka Akira <akr@fsij.org>
* ext/socket/mkconstants.rb: use erb. * ext/socket/mkconstants.rb: use erb.

View File

@ -43,19 +43,30 @@ def each_data
else else
define = "sock_define_const" define = "sock_define_const"
end end
yield define, name, default_value guard = nil
if /\A(AF_INET6|PF_INET6)\z/ =~ name
# IPv6 is not supported although AF_INET6 is defined on bcc32/mingw
guard = "defined(INET6)"
end
yield guard, define, name, default_value
} }
end end
result << ERB.new(<<'EOS', nil, '%').result(binding) result << ERB.new(<<'EOS', nil, '%').result(binding)
% each_data {|define, name, default_value| % each_data {|guard, define, name, default_value|
#ifdef <%=name%> % if guard
#if <%=guard%>
% end
#if defined(<%=name%>)
<%=define%>(<%=c_str name%>, <%=name%>); <%=define%>(<%=c_str name%>, <%=name%>);
% if default_value % if default_value
#else #else
<%=define%>(<%=c_str name%>, <%=default_value%>); <%=define%>(<%=c_str name%>, <%=default_value%>);
% end % end
#endif #endif
% if guard
#endif
% end
% } % }
EOS EOS
@ -79,6 +90,8 @@ SOCK_PACKET
AF_INET AF_INET
PF_INET PF_INET
AF_INET6
PF_INET6
AF_UNIX AF_UNIX
PF_UNIX PF_UNIX
AF_AX25 AF_AX25

View File

@ -3733,8 +3733,4 @@ Init_socket()
/* constants */ /* constants */
mConst = rb_define_module_under(rb_cSocket, "Constants"); mConst = rb_define_module_under(rb_cSocket, "Constants");
#include "constants.h" #include "constants.h"
#ifdef INET6 /* IPv6 is not supported although AF_INET6 is defined on bcc32/mingw */
sock_define_const("AF_INET6", AF_INET6);
sock_define_const("PF_INET6", PF_INET6);
#endif
} }