* ext/socket/mkconstants.rb (gen_int_to_name): don't compare constants

in preprocessor because the constants may be enum.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@21267 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
akr 2009-01-02 05:33:56 +00:00
parent 90a65796e7
commit 270f2034a7
2 changed files with 13 additions and 12 deletions

View File

@ -1,3 +1,8 @@
Fri Jan 2 14:33:12 2009 Tanaka Akira <akr@fsij.org>
* ext/socket/mkconstants.rb (gen_int_to_name): don't compare constants
in preprocessor because the constants may be enum.
Fri Jan 2 14:11:07 2009 Tanaka Akira <akr@fsij.org> Fri Jan 2 14:11:07 2009 Tanaka Akira <akr@fsij.org>
* ext/socket/mkconstants.rb (gen_int_to_name): add lenp argument. * ext/socket/mkconstants.rb (gen_int_to_name): add lenp argument.

View File

@ -104,19 +104,15 @@ def each_alias(pat)
end end
ERB.new(<<'EOS', nil, '%').def_method(Object, "gen_int_to_name(int_var, lenp_var, pat)") ERB.new(<<'EOS', nil, '%').def_method(Object, "gen_int_to_name(int_var, lenp_var, pat)")
switch (<%=int_var%>) { % each_name(pat) {|n|
% each_alias(pat) {|names| #ifdef <%=n%>
% names.each_with_index {|n, i| if (<%=int_var%> == <%=n%>) {
% cond = ["defined(#{n})"] if (<%=lenp_var%>) *<%=lenp_var%> = <%=n.bytesize%>;
% (0...i).each {|j| cond << "(!defined(#{names[j]}) || #{n} != #{names[j]})" } return <%=c_str n%>;
#if <%=cond.join(" && ")%> }
case <%=n%>: if (<%=lenp_var%>) *<%=lenp_var%> = <%=n.bytesize%>; return <%=c_str n%>;
#endif #endif
% } % }
% }
default:
return NULL; return NULL;
}
EOS EOS
result << ERB.new(<<'EOS', nil, '%').result(binding) result << ERB.new(<<'EOS', nil, '%').result(binding)