mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* ext/socket/mkconstants.rb: refactored to nest properly in statically
and dynamically. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@21416 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
2149577476
commit
8a1261995e
2 changed files with 39 additions and 23 deletions
|
@ -1,3 +1,8 @@
|
|||
Sat Jan 10 20:50:02 2009 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* ext/socket/mkconstants.rb: refactored to nest properly in statically
|
||||
and dynamically.
|
||||
|
||||
Sat Jan 10 20:26:17 2009 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* version.h: make version string succinct:
|
||||
|
|
|
@ -66,6 +66,31 @@ def each_name(pat)
|
|||
}
|
||||
end
|
||||
|
||||
ERB.new(<<'EOS', nil, '%').def_method(Object, "gen_const_defs_in_guard(define, name, default_value)")
|
||||
% if default_value
|
||||
#ifndef <%=name%>
|
||||
#define <%=name%> <%=default_value%>
|
||||
#endif
|
||||
<%=define%>(<%=c_str name%>, <%=name%>);
|
||||
% else
|
||||
#if defined(<%=name%>)
|
||||
<%=define%>(<%=c_str name%>, <%=name%>);
|
||||
#endif
|
||||
% end
|
||||
EOS
|
||||
|
||||
ERB.new(<<'EOS', nil, '%').def_method(Object, "gen_const_defs")
|
||||
% each_const {|guard, define, name, default_value|
|
||||
% if guard
|
||||
#if <%=guard%>
|
||||
<%= gen_const_defs_in_guard(define, name, default_value) %>
|
||||
#endif
|
||||
% else
|
||||
<%= gen_const_defs_in_guard(define, name, default_value) %>
|
||||
% end
|
||||
% }
|
||||
EOS
|
||||
|
||||
def reverse_each_name(pat)
|
||||
DEFS.reverse_each {|name, default_value|
|
||||
next if pat !~ name
|
||||
|
@ -104,10 +129,7 @@ def each_names_with_len(pat, prefix_optional=nil)
|
|||
}
|
||||
end
|
||||
|
||||
ERB.new(<<'EOS', nil, '%').def_method(Object, "gen_name_to_int_func(funcname, pat, prefix_optional, guard=nil)")
|
||||
%if guard
|
||||
#ifdef <%=guard%>
|
||||
%end
|
||||
ERB.new(<<'EOS', nil, '%').def_method(Object, "gen_name_to_int_func_in_guard(funcname, pat, prefix_optional, guard=nil)")
|
||||
static int
|
||||
<%=funcname%>(char *str, int len, int *valp)
|
||||
{
|
||||
|
@ -126,8 +148,15 @@ static int
|
|||
return -1;
|
||||
}
|
||||
}
|
||||
EOS
|
||||
|
||||
ERB.new(<<'EOS', nil, '%').def_method(Object, "gen_name_to_int_func(funcname, pat, prefix_optional, guard=nil)")
|
||||
%if guard
|
||||
#ifdef <%=guard%>
|
||||
<%=gen_name_to_int_func_in_guard(funcname, pat, prefix_optional, guard)%>
|
||||
#endif
|
||||
%else
|
||||
<%=gen_name_to_int_func_in_guard(funcname, pat, prefix_optional, guard)%>
|
||||
%end
|
||||
EOS
|
||||
|
||||
|
@ -193,25 +222,7 @@ result << ERB.new(<<'EOS', nil, '%').result(binding)
|
|||
static void
|
||||
init_constants(VALUE mConst)
|
||||
{
|
||||
% each_const {|guard, define, name, default_value|
|
||||
% if guard
|
||||
#if <%=guard%>
|
||||
% end
|
||||
% if default_value
|
||||
#ifndef <%=name%>
|
||||
#define <%=name%> <%=default_value%>
|
||||
#endif
|
||||
% else
|
||||
#if defined(<%=name%>)
|
||||
% end
|
||||
<%=define%>(<%=c_str name%>, <%=name%>);
|
||||
% unless default_value
|
||||
#endif
|
||||
% end
|
||||
% if guard
|
||||
#endif
|
||||
% end
|
||||
% }
|
||||
<%= gen_const_defs %>
|
||||
<%= INTERN_DEFS.map {|decl, gen_hash, func| gen_hash }.join("\n") %>
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue