зеркало из https://github.com/github/ruby.git
* 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
This commit is contained in:
Родитель
42d9223a2d
Коммит
b1956f058f
|
@ -1,3 +1,7 @@
|
|||
Mon Jan 19 22:31:35 2009 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* ext/socket/mkconstants.rb: use erb for generating code.
|
||||
|
||||
Mon Jan 19 17:33:47 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* string.c (hash): defaulted to MurmurHash 2.0.
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче