aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/LV2/lib/makeplugin/plugin_info.rb
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/LV2/lib/makeplugin/plugin_info.rb')
-rw-r--r--plugins/LV2/lib/makeplugin/plugin_info.rb38
1 files changed, 27 insertions, 11 deletions
diff --git a/plugins/LV2/lib/makeplugin/plugin_info.rb b/plugins/LV2/lib/makeplugin/plugin_info.rb
index c6f4adb..b9cae0d 100644
--- a/plugins/LV2/lib/makeplugin/plugin_info.rb
+++ b/plugins/LV2/lib/makeplugin/plugin_info.rb
@@ -21,8 +21,26 @@ module MakePlugin
class PluginInfo
PLUGIN_FIELDS = %w{Type Use Description Comment}
- def self.find_plugin_info(root, plugin_name)
- pi = { name: plugin_name }
+ attr_reader :name
+ attr_reader :n_ctrl_ports
+ attr_reader :ctrl_ports
+ attr_reader :type
+ attr_reader :use
+ attr_reader :desc
+ attr_reader :comment
+
+ def initialize(root, name)
+ @name = name
+ @ctrl_ports = []
+ self.find_plugin_info(root)
+ if @n_ctrl_ports != @ctrl_ports.length
+ raise "Expected #{@n_ctrl_ports} but found #{@ctrl_ports.length}"
+ end
+ end
+
+ private
+
+ def find_plugin_info(root)
found = false
db = File.join(root, '../../cheatsheet/src/database.js')
@@ -32,39 +50,37 @@ module MakePlugin
break if found && line =~ /^\s*\},$/
pat.match(line) do |m|
- if m[1] == 'Name' && m[2] == plugin_name
+ if m[1] == 'Name' && m[2] == @name
found = true
elsif found && PLUGIN_FIELDS.include?(m[1])
- pi[m[1].downcase.to_sym] = m[2]
+ eval(%Q{@#{m[1].downcase.to_sym} = "#{m[2]}"})
end
end
end
end
- header_file = File.join(root, '../WinVST', plugin_name, "#{plugin_name}.h")
+ header_file = File.join(root, '../WinVST', @name, "#{@name}.h")
File.open(header_file) do |f|
f.each_line do |line|
if line =~ /kNumParameters\s*=\s*(\d+)/
- pi[:n_ctrl_ports] = $1.to_i
+ @n_ctrl_ports = $1.to_i
end
end
end
- class_file = File.join(root, '../WinVST', plugin_name, "#{plugin_name}.cpp")
+ class_file = File.join(root, '../WinVST', @name, "#{@name}.cpp")
fun = ""
File.open(class_file) do |f|
f.each_line do |line|
- if line =~ /void #{plugin_name}::(\w+)/
+ if line =~ /void #{@name}::(\w+)/
fun = $1
elsif fun == 'getParameterName' and line =~ /case\s+kParam([A-Z])\:\s+vst_strncpy\s*\([^,]*,\s*\"(\w+)\",/
- pi["ctrl_port_#{$1}".to_sym] = $2
+ @ctrl_ports << $2
end
end
end
-
- return pi
end
end
end