add support for some more code formatters, or none at all
This commit is contained in:
parent
cd0ef356ba
commit
1268da14db
2 changed files with 27 additions and 3 deletions
18
generator.rb
18
generator.rb
|
|
@ -126,11 +126,12 @@ class Generator
|
||||||
value["values"].each do |val|
|
value["values"].each do |val|
|
||||||
@out << val["name"]
|
@out << val["name"]
|
||||||
if val["value"] then
|
if val["value"] then
|
||||||
@out << "= " << convert_expression(val["value"].to_s) << ","
|
@out << " = " << convert_expression(val["value"].to_s) << ","
|
||||||
else
|
else
|
||||||
@out << ","
|
@out << ","
|
||||||
end
|
end
|
||||||
@out << " // " << val["comment"].rstrip << "\n" if val["comment"]
|
@out << " // " << val["comment"].rstrip if val["comment"]
|
||||||
|
@out << "\n"
|
||||||
end
|
end
|
||||||
@out << "}"
|
@out << "}"
|
||||||
@out << value["name"] if value["name"]
|
@out << value["name"] if value["name"]
|
||||||
|
|
@ -217,6 +218,17 @@ class Generator
|
||||||
end
|
end
|
||||||
|
|
||||||
def formatted_file(name, &block)
|
def formatted_file(name, &block)
|
||||||
IO.popen("clang-format | grep -v \"// clang-format o\" > \"#{name}\"", "w", &block)
|
if not @format_command then
|
||||||
|
if system('which clang-format > /dev/null') then
|
||||||
|
@format_command = "clang-format | grep -v \"// clang-format o\""
|
||||||
|
elsif system('which uncrustify > /dev/null') then
|
||||||
|
@format_command = "uncrustify -q -c uncrustify.cfg | grep -v \"// clang-format o\""
|
||||||
|
elsif system('which astyle > /dev/null') then
|
||||||
|
@format_command = "astyle --style=allman --max-code-length=79 --mode=c | grep -v \"// clang-format o\""
|
||||||
|
else
|
||||||
|
@format_command = "grep -v \"// clang-format o\""
|
||||||
|
end
|
||||||
|
end
|
||||||
|
IO.popen("#{@format_command} > \"#{name}\"", "w", &block)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
12
uncrustify.cfg
Normal file
12
uncrustify.cfg
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
indent_align_assign=true
|
||||||
|
nl_after_semicolon=true
|
||||||
|
nl_after_brace_open=true
|
||||||
|
input_tab_size=4
|
||||||
|
output_tab_size=4
|
||||||
|
indent_columns=4
|
||||||
|
code_width=79
|
||||||
|
indent_with_tabs=0
|
||||||
|
nl_enum_brace=add
|
||||||
|
nl_struct_brace=add
|
||||||
|
nl_union_brace=add
|
||||||
|
nl_fdef_brace=add
|
||||||
Loading…
Reference in a new issue