make generate.rb executable and covert line endings to unix
This commit is contained in:
1 parent
72be82ba05
commit
8ba8303868
1 file changed
+30
-30
Regular → Executable
+30
-30
@@ -1,30 +1,30 @@
|
||||
#!/usr/bin/env ruby
|
||||
|
||||
##############################################################
|
||||
# script to generate signal*.h files from signal_template.h
|
||||
##############################################################
|
||||
|
||||
def make_header_file(nargs)
|
||||
# hash to store our substitutions in
|
||||
subs = {}
|
||||
|
||||
# create subst strings for template and function arguments (template args follow T_return, so start with a comma)
|
||||
subs["===NARG==="] = nargs.to_s
|
||||
subs["===TEMPLATE_ARG_DECL==="] = (nargs > 0 ? ", ":"") + nargs.times.map { |i| "typename T_arg#{i}" }.join(", ")
|
||||
subs["===TEMPLATE_ARG==="] = (nargs > 0 ? ", ":"") + nargs.times.map { |i| "T_arg#{i}" }.join(", ")
|
||||
subs["===FORMAL_ARG_DECL==="] = nargs.times.map { |i| "T_arg#{i} a#{i}" }.join(", ")
|
||||
subs["===FORMAL_ARG==="] = nargs.times.map { |i| "a#{i}" }.join(", ")
|
||||
|
||||
# load template file
|
||||
text = IO.read("signal_template.h")
|
||||
|
||||
# do substitutions
|
||||
subs.each { |k,v| text.gsub!(k,v) }
|
||||
|
||||
# write output file
|
||||
File.open("signal#{nargs}.h","w") { |f| f.write(text) }
|
||||
end
|
||||
|
||||
# generate [signal0.h,signal16.h]
|
||||
(0..16).each { |i| make_header_file(i) }
|
||||
|
||||
#!/usr/bin/env ruby
|
||||
|
||||
##############################################################
|
||||
# script to generate signal*.h files from signal_template.h
|
||||
##############################################################
|
||||
|
||||
def make_header_file(nargs)
|
||||
# hash to store our substitutions in
|
||||
subs = {}
|
||||
|
||||
# create subst strings for template and function arguments (template args follow T_return, so start with a comma)
|
||||
subs["===NARG==="] = nargs.to_s
|
||||
subs["===TEMPLATE_ARG_DECL==="] = (nargs > 0 ? ", ":"") + nargs.times.map { |i| "typename T_arg#{i}" }.join(", ")
|
||||
subs["===TEMPLATE_ARG==="] = (nargs > 0 ? ", ":"") + nargs.times.map { |i| "T_arg#{i}" }.join(", ")
|
||||
subs["===FORMAL_ARG_DECL==="] = nargs.times.map { |i| "T_arg#{i} a#{i}" }.join(", ")
|
||||
subs["===FORMAL_ARG==="] = nargs.times.map { |i| "a#{i}" }.join(", ")
|
||||
|
||||
# load template file
|
||||
text = IO.read("signal_template.h")
|
||||
|
||||
# do substitutions
|
||||
subs.each { |k,v| text.gsub!(k,v) }
|
||||
|
||||
# write output file
|
||||
File.open("signal#{nargs}.h","w") { |f| f.write(text) }
|
||||
end
|
||||
|
||||
# generate [signal0.h,signal16.h]
|
||||
(0..16).each { |i| make_header_file(i) }
|
||||
|
||||
Reference in new issue
Block a user