зеркало из https://github.com/github/ruby.git
Drop support for old ERB
This commit is contained in:
Родитель
71d511615b
Коммит
e9a7801a93
|
@ -121,11 +121,7 @@ ENCS, ENC_DEPS = target_encodings
|
|||
ATRANS, TRANS = target_transcoders
|
||||
|
||||
if File.exist?(depend = File.join($srcdir, "depend"))
|
||||
if ERB.instance_method(:initialize).parameters.assoc(:key) # Ruby 2.6+
|
||||
erb = ERB.new(File.read(depend), trim_mode: '%')
|
||||
else
|
||||
erb = ERB.new(File.read(depend), nil, '%')
|
||||
end
|
||||
erb = ERB.new(File.read(depend), trim_mode: '%')
|
||||
erb.filename = depend
|
||||
tmp = erb.result(binding)
|
||||
dep = "\n#### depend ####\n\n" << depend_rules(tmp).join
|
||||
|
@ -139,11 +135,7 @@ File.open(ARGV[0], 'wb') {|f|
|
|||
}
|
||||
if MODULE_TYPE == :static
|
||||
filename = "encinit.c.erb"
|
||||
if ERB.instance_method(:initialize).parameters.assoc(:key) # Ruby 2.6+
|
||||
erb = ERB.new(File.read(File.join($srcdir, filename)), trim_mode: '%-')
|
||||
else
|
||||
erb = ERB.new(File.read(File.join($srcdir, filename)), nil, '%-')
|
||||
end
|
||||
erb = ERB.new(File.read(File.join($srcdir, filename)), trim_mode: '%-')
|
||||
erb.filename = "enc/#{filename}"
|
||||
tmp = erb.result(binding)
|
||||
begin
|
||||
|
|
|
@ -76,15 +76,11 @@ def each_name(pat)
|
|||
}
|
||||
end
|
||||
|
||||
erb_new = lambda do |src, safe, trim|
|
||||
if ERB.instance_method(:initialize).parameters.assoc(:key) # Ruby 2.6+
|
||||
ERB.new(src, trim_mode: trim)
|
||||
else
|
||||
ERB.new(src, safe, trim)
|
||||
end
|
||||
erb_new = lambda do |src, trim|
|
||||
ERB.new(src, trim_mode: trim)
|
||||
end
|
||||
|
||||
erb_new.call(<<'EOS', nil, '%').def_method(Object, "gen_const_decls")
|
||||
erb_new.call(<<'EOS', '%').def_method(Object, "gen_const_decls")
|
||||
% each_const {|guard, name, default_value|
|
||||
#if !defined(<%=name%>)
|
||||
# if defined(HAVE_CONST_<%=name.upcase%>)
|
||||
|
@ -98,7 +94,7 @@ erb_new.call(<<'EOS', nil, '%').def_method(Object, "gen_const_decls")
|
|||
% }
|
||||
EOS
|
||||
|
||||
erb_new.call(<<'EOS', nil, '%').def_method(Object, "gen_const_defs_in_guard(name, default_value)")
|
||||
erb_new.call(<<'EOS', '%').def_method(Object, "gen_const_defs_in_guard(name, default_value)")
|
||||
#if defined(<%=name%>)
|
||||
/* <%= COMMENTS[name] %> */
|
||||
rb_define_const(rb_cSocket, <%=c_str name%>, INTEGER2NUM(<%=name%>));
|
||||
|
@ -107,7 +103,7 @@ erb_new.call(<<'EOS', nil, '%').def_method(Object, "gen_const_defs_in_guard(name
|
|||
#endif
|
||||
EOS
|
||||
|
||||
erb_new.call(<<'EOS', nil, '%').def_method(Object, "gen_const_defs")
|
||||
erb_new.call(<<'EOS', '%').def_method(Object, "gen_const_defs")
|
||||
% each_const {|guard, name, default_value|
|
||||
% if guard
|
||||
#if <%=guard%>
|
||||
|
@ -157,7 +153,7 @@ def each_names_with_len(pat, prefix_optional=nil)
|
|||
}
|
||||
end
|
||||
|
||||
erb_new.call(<<'EOS', nil, '%').def_method(Object, "gen_name_to_int_decl(funcname, pat, prefix_optional, guard=nil)")
|
||||
erb_new.call(<<'EOS', '%').def_method(Object, "gen_name_to_int_decl(funcname, pat, prefix_optional, guard=nil)")
|
||||
%if guard
|
||||
#ifdef <%=guard%>
|
||||
int <%=funcname%>(const char *str, long len, int *valp);
|
||||
|
@ -167,7 +163,7 @@ int <%=funcname%>(const char *str, long len, int *valp);
|
|||
%end
|
||||
EOS
|
||||
|
||||
erb_new.call(<<'EOS', nil, '%').def_method(Object, "gen_name_to_int_func_in_guard(funcname, pat, prefix_optional, guard=nil)")
|
||||
erb_new.call(<<'EOS', '%').def_method(Object, "gen_name_to_int_func_in_guard(funcname, pat, prefix_optional, guard=nil)")
|
||||
int
|
||||
<%=funcname%>(const char *str, long len, int *valp)
|
||||
{
|
||||
|
@ -189,7 +185,7 @@ int
|
|||
}
|
||||
EOS
|
||||
|
||||
erb_new.call(<<'EOS', nil, '%').def_method(Object, "gen_name_to_int_func(funcname, pat, prefix_optional, guard=nil)")
|
||||
erb_new.call(<<'EOS', '%').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)%>
|
||||
|
@ -218,7 +214,7 @@ def reverse_each_name_with_prefix_optional(pat, prefix_pat)
|
|||
end
|
||||
end
|
||||
|
||||
erb_new.call(<<'EOS', nil, '%').def_method(Object, "gen_int_to_name_hash(hash_var, pat, prefix_pat)")
|
||||
erb_new.call(<<'EOS', '%').def_method(Object, "gen_int_to_name_hash(hash_var, pat, prefix_pat)")
|
||||
<%=hash_var%> = st_init_numtable();
|
||||
% reverse_each_name_with_prefix_optional(pat, prefix_pat) {|n,s|
|
||||
#ifdef <%=n%>
|
||||
|
@ -227,7 +223,7 @@ erb_new.call(<<'EOS', nil, '%').def_method(Object, "gen_int_to_name_hash(hash_va
|
|||
% }
|
||||
EOS
|
||||
|
||||
erb_new.call(<<'EOS', nil, '%').def_method(Object, "gen_int_to_name_func(func_name, hash_var)")
|
||||
erb_new.call(<<'EOS', '%').def_method(Object, "gen_int_to_name_func(func_name, hash_var)")
|
||||
ID
|
||||
<%=func_name%>(int val)
|
||||
{
|
||||
|
@ -238,7 +234,7 @@ ID
|
|||
}
|
||||
EOS
|
||||
|
||||
erb_new.call(<<'EOS', nil, '%').def_method(Object, "gen_int_to_name_decl(func_name, hash_var)")
|
||||
erb_new.call(<<'EOS', '%').def_method(Object, "gen_int_to_name_decl(func_name, hash_var)")
|
||||
ID <%=func_name%>(int val);
|
||||
EOS
|
||||
|
||||
|
@ -287,7 +283,7 @@ def_intern('rsock_intern_udp_optname', /\AUDP_/, "UDP_")
|
|||
def_intern('rsock_intern_scm_optname', /\ASCM_/, "SCM_")
|
||||
def_intern('rsock_intern_local_optname', /\ALOCAL_/, "LOCAL_")
|
||||
|
||||
result = erb_new.call(<<'EOS', nil, '%').result(binding)
|
||||
result = erb_new.call(<<'EOS', '%').result(binding)
|
||||
/* autogenerated file */
|
||||
|
||||
<%= INTERN_DEFS.map {|vardef, gen_hash, decl, func| vardef }.join("\n") %>
|
||||
|
@ -330,7 +326,7 @@ init_constants(void)
|
|||
|
||||
EOS
|
||||
|
||||
header_result = erb_new.call(<<'EOS', nil, '%').result(binding)
|
||||
header_result = erb_new.call(<<'EOS', '%').result(binding)
|
||||
/* autogenerated file */
|
||||
<%= gen_const_decls %>
|
||||
<%= NAME_TO_INT_DEFS.map {|decl, func| decl }.join("\n") %>
|
||||
|
|
|
@ -27,11 +27,7 @@ vpath = out.vpath
|
|||
output, vpath = output, vpath
|
||||
|
||||
result = templates.map do |template|
|
||||
if ERB.instance_method(:initialize).parameters.assoc(:key) # Ruby 2.6+
|
||||
erb = ERB.new(File.read(template), trim_mode: '%-')
|
||||
else
|
||||
erb = ERB.new(File.read(template), nil, '%-')
|
||||
end
|
||||
erb = ERB.new(File.read(template), trim_mode: '%-')
|
||||
erb.filename = template
|
||||
source ? erb.src : proc{erb.result(binding)}.call
|
||||
end
|
||||
|
|
|
@ -33,11 +33,7 @@ class RubyVM::Dumper
|
|||
rescue Errno::ENOENT
|
||||
raise "don't know how to generate #{path}"
|
||||
else
|
||||
if ERB.instance_method(:initialize).parameters.assoc(:key) # Ruby 2.6+
|
||||
erb = ERB.new(src, trim_mode: '%-')
|
||||
else
|
||||
erb = ERB.new(src, nil, '%-')
|
||||
end
|
||||
erb = ERB.new(src, trim_mode: '%-')
|
||||
erb.filename = path.to_path
|
||||
return erb
|
||||
end
|
||||
|
|
|
@ -1078,11 +1078,7 @@ if __FILE__ == $0
|
|||
end
|
||||
|
||||
libs1 = $".dup
|
||||
if ERB.instance_method(:initialize).parameters.assoc(:key) # Ruby 2.6+
|
||||
erb = ERB.new(src, trim_mode: '%')
|
||||
else
|
||||
erb = ERB.new(src, nil, '%')
|
||||
end
|
||||
erb = ERB.new(src, trim_mode: '%')
|
||||
erb.filename = arg
|
||||
erb_result = erb.result(binding)
|
||||
libs2 = $".dup
|
||||
|
|
Загрузка…
Ссылка в новой задаче