From dbc9314360aa082607686689e748a6f93300fb91 Mon Sep 17 00:00:00 2001 From: akr Date: Thu, 1 Jan 2009 07:09:19 +0000 Subject: * ext/socket/mkconstants.rb: generate init_constants function. * ext/socket/socket.c (Init_socket): call init_constants. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@21238 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ext/socket/mkconstants.rb | 4 ++++ ext/socket/socket.c | 4 +++- 2 files changed, 7 insertions(+), 1 deletion(-) (limited to 'ext/socket') diff --git a/ext/socket/mkconstants.rb b/ext/socket/mkconstants.rb index 02d7e17b7..257b315c1 100644 --- a/ext/socket/mkconstants.rb +++ b/ext/socket/mkconstants.rb @@ -53,6 +53,9 @@ def each_data end result << ERB.new(<<'EOS', nil, '%').result(binding) +static void +init_constants(VALUE mConst) +{ % each_data {|guard, define, name, default_value| % if guard #if <%=guard%> @@ -69,6 +72,7 @@ result << ERB.new(<<'EOS', nil, '%').result(binding) % end % } +} EOS if opt_o diff --git a/ext/socket/socket.c b/ext/socket/socket.c index b91e1396c..fe972ce5f 100644 --- a/ext/socket/socket.c +++ b/ext/socket/socket.c @@ -3592,6 +3592,8 @@ sock_define_uconst(const char *name, unsigned int value, VALUE mConst) #define sock_define_const(name, value) sock_define_const(name, value, mConst) #define sock_define_uconst(name, value) sock_define_uconst(name, value, mConst) +#include "constants.h" + /* * Class +Socket+ provides access to the underlying operating system * socket implementations. It can be used to provide more operating system @@ -3732,5 +3734,5 @@ Init_socket() /* constants */ mConst = rb_define_module_under(rb_cSocket, "Constants"); -#include "constants.h" + init_constants(mConst); } -- cgit