diff options
author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-01-19 13:32:31 +0000 |
---|---|---|
committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-01-19 13:32:31 +0000 |
commit | b1956f058f0192edb0242aab3c501d6b24581a1c (patch) | |
tree | bc0ea1971534bcb31b59d8e128969dc883732a65 /ext/socket | |
parent | 42d9223a2db7da93cf2f937b75b9ae287f6c7a0d (diff) | |
download | ruby-b1956f058f0192edb0242aab3c501d6b24581a1c.tar.gz |
* ext/socket/mkconstants.rb: use erb for generating code.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@21672 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/socket')
-rw-r--r-- | ext/socket/mkconstants.rb | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/ext/socket/mkconstants.rb b/ext/socket/mkconstants.rb index 1d4e90ba79..6b3174b83c 100644 --- a/ext/socket/mkconstants.rb +++ b/ext/socket/mkconstants.rb @@ -74,12 +74,17 @@ def each_name(pat) } end -MISSING_DEFS = {} +ERB.new(<<'EOS', nil, '%').def_method(Object, "gen_const_decls") +% each_const {|guard, define, name, default_value| +% if default_value +#ifndef <%=name%> +# define <%=name%> <%=default_value%> +#endif +% end +% } +EOS ERB.new(<<'EOS', nil, '%').def_method(Object, "gen_const_defs_in_guard(define, name, default_value)") -% if default_value -% MISSING_DEFS[name] = default_value -% end #if defined(<%=name%>) <%=define%>(<%=c_str name%>, <%=name%>); #endif @@ -271,10 +276,8 @@ init_constants(VALUE mConst) EOS header_result = ERB.new(<<'EOS', nil, '%').result(binding) -<%= MISSING_DEFS.map {|name, value| ["\#ifndef #{name}", "\# define #{name} #{value}", '#endif']}.join("\n") %> - +<%= gen_const_decls %> <%= NAME_TO_INT_DEFS.map {|decl, func| decl }.join("\n") %> - <%= INTERN_DEFS.map {|vardef, gen_hash, decl, func| decl }.join("\n") %> EOS |