From 14c689313ce8e5247f279cc6d7352f04cd843217 Mon Sep 17 00:00:00 2001 From: Harald Eilertsen Date: Sat, 27 Mar 2021 15:35:28 +0100 Subject: LV2/makeplugin: Get variable decls from plugin header. --- plugins/LV2/Template/Plugin.h | 1 + plugins/LV2/lib/makeplugin/plugin_info.rb | 13 ++++++++++++- plugins/LV2/makeplugin | 1 + 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/plugins/LV2/Template/Plugin.h b/plugins/LV2/Template/Plugin.h index 7569955..3d17d0f 100644 --- a/plugins/LV2/Template/Plugin.h +++ b/plugins/LV2/Template/Plugin.h @@ -22,6 +22,7 @@ private: /* * Members needed by the processing functions. */ + @VARDECLS@ }; #endif diff --git a/plugins/LV2/lib/makeplugin/plugin_info.rb b/plugins/LV2/lib/makeplugin/plugin_info.rb index 59b7590..15de9d3 100644 --- a/plugins/LV2/lib/makeplugin/plugin_info.rb +++ b/plugins/LV2/lib/makeplugin/plugin_info.rb @@ -27,10 +27,12 @@ module MakePlugin attr_reader :use attr_reader :desc attr_reader :comment + attr_reader :var_decls def initialize(root, name) @name = name @ctrl_ports = [] + @var_decls = [] self.find_plugin_info(root) if @n_ctrl_ports != @ctrl_ports.length raise "Expected #{@n_ctrl_ports} but found #{@ctrl_ports.length}" @@ -80,9 +82,18 @@ module MakePlugin header_file = File.join(root, '../WinVST', @name, "#{@name}.h") File.open(header_file) do |f| + vars = false f.each_line do |line| - if line =~ /kNumParameters\s*=\s*(\d+)/ + if vars + if line =~ /^\};$/ + vars = false + else + @var_decls << line.chomp + end + elsif line =~ /kNumParameters\s*=\s*(\d+)/ @n_ctrl_ports = $1.to_i + elsif line =~ /std::set<[^>]+>\s*_canDo;/ + vars = true end end end diff --git a/plugins/LV2/makeplugin b/plugins/LV2/makeplugin index 915117b..061d712 100755 --- a/plugins/LV2/makeplugin +++ b/plugins/LV2/makeplugin @@ -48,6 +48,7 @@ begin .gsub('@plugin@', pi.slug) .gsub('@NCtrlPorts@', pi.n_ctrl_ports.to_s) .gsub('@AssignParams@', make_param_assigns(pi.ctrl_ports)) + .gsub('@VARDECLS@', pi.var_decls.join("\n")) fname = t.sub('Plugin', pi.name) -- cgit v1.2.3