usb_cables: also generate optional pin pairs definittions

This commit is contained in:
King Kévin 2019-12-31 12:05:22 +01:00
parent 3bdad80428
commit cbd67810f4
1 changed files with 2 additions and 2 deletions

View File

@ -34,7 +34,7 @@ class String
end
# variable to process regexp
cable_regex = /static const uint8_t (?<variable>usb__(?<connector1>\w+)__(?<connector2>\w+)__(?<name>\w+)_pins)\[\]\[2\] = (?<array>\{[^;]+\});/m
cable_regex = /static const uint8_t (?<variable>usb__(?<connector1>\w+)__(?<connector2>\w+)__(?<name>\w+)_(?<type>pins|opts))\[\]\[2\] = (?<array>\{[^;]+\});/m
# read C definitions file
usb_cables_text = IO.read("usb_cables.c")
output_text = usb_cables_text.dup
@ -45,7 +45,7 @@ cables.each_index do |i|
next if 0 == i
cable = cables[i]
# find if there was a previously matching definition
template = cables[0, i].filter {|c| c[:name] == cable[:name]}.first
template = cables[0, i].filter {|c| c[:name] == cable[:name] and c[:type] == cable[:type]}.first
next unless template
puts "generate #{cable[:variable]} usng #{template[:variable]}"
array = template[:array]