From 47baef3107e92f27bae4c239cb4f89c887ed5ce4 Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Mon, 30 Nov 2020 21:29:57 +0100 Subject: [PATCH] Rename architecture related functions and structs --- src/common/plugins.cpp | 6 +++--- src/common/plugins.h | 13 ++++++------- src/plugin/bridges/vst2.cpp | 2 +- src/plugin/host-process.cpp | 8 ++++---- src/plugin/host-process.h | 10 +++++----- src/plugin/utils.cpp | 10 +++++----- src/plugin/utils.h | 4 ++-- 7 files changed, 26 insertions(+), 27 deletions(-) diff --git a/src/common/plugins.cpp b/src/common/plugins.cpp index 449cd21c..1aae7397 100644 --- a/src/common/plugins.cpp +++ b/src/common/plugins.cpp @@ -5,7 +5,7 @@ namespace fs = boost::filesystem; -PluginArchitecture find_vst_architecture(fs::path plugin_path) { +LibArchitecture find_dll_architecture(fs::path plugin_path) { std::ifstream file(plugin_path, std::ifstream::binary | std::ifstream::in); // The linker will place the offset where the PE signature is placed at the @@ -34,11 +34,11 @@ PluginArchitecture find_vst_architecture(fs::path plugin_path) { // https://docs.microsoft.com/en-us/windows/win32/debug/pe-format#machine-types switch (machine_type) { case 0x014c: // IMAGE_FILE_MACHINE_I386 - return PluginArchitecture::vst_32; + return LibArchitecture::dll_32; break; case 0x8664: // IMAGE_FILE_MACHINE_AMD64 case 0x0000: // IMAGE_FILE_MACHINE_UNKNOWN - return PluginArchitecture::vst_64; + return LibArchitecture::dll_64; break; } diff --git a/src/common/plugins.h b/src/common/plugins.h index 478b9e75..2dd310dd 100644 --- a/src/common/plugins.h +++ b/src/common/plugins.h @@ -24,21 +24,20 @@ // Utilities and tags for plugin types and architectures /** - * A tag to differentiate between 32 and 64-bit plugins, used to determine which - * host application to use. + * A tag to differentiate between 32 and 64-bit `.dll` files, used to determine + * which host application to use. */ -enum class PluginArchitecture { vst_32, vst_64 }; +enum class LibArchitecture { dll_32, dll_64 }; /** - * Determine the architecture of a VST plugin (or rather, a .dll file) based on - * it's header values. + * Determine the architecture of a `.dll` file based on the file header. * * See https://docs.microsoft.com/en-us/windows/win32/debug/pe-format for more * information on the PE32 format. * - * @param plugin_path The path to the .dll file we're going to check. + * @param path The path to the .dll file we're going to check. * * @return The detected architecture. * @throw std::runtime_error If the file is not a .dll file. */ -PluginArchitecture find_vst_architecture(boost::filesystem::path); +LibArchitecture find_dll_architecture(boost::filesystem::path); diff --git a/src/plugin/bridges/vst2.cpp b/src/plugin/bridges/vst2.cpp index 4572bab2..c4db6042 100644 --- a/src/plugin/bridges/vst2.cpp +++ b/src/plugin/bridges/vst2.cpp @@ -656,7 +656,7 @@ void Vst2PluginBridge::log_init_message() { } else { init_msg << "individually"; } - if (vst_host->architecture() == PluginArchitecture::vst_32) { + if (vst_host->architecture() == LibArchitecture::dll_32) { init_msg << ", 32-bit"; } else { init_msg << ", 64-bit"; diff --git a/src/plugin/host-process.cpp b/src/plugin/host-process.cpp index 3af6ef9a..94e67563 100644 --- a/src/plugin/host-process.cpp +++ b/src/plugin/host-process.cpp @@ -89,7 +89,7 @@ IndividualHost::IndividualHost(boost::asio::io_context& io_context, fs::path plugin_path, const Sockets& sockets) : HostProcess(io_context, logger), - plugin_arch(find_vst_architecture(plugin_path)), + plugin_arch(find_dll_architecture(plugin_path)), host_path(find_vst_host(plugin_arch, false)), host(launch_host(host_path, #ifdef WITH_WINEDBG @@ -114,7 +114,7 @@ IndividualHost::IndividualHost(boost::asio::io_context& io_context, #endif } -PluginArchitecture IndividualHost::architecture() { +LibArchitecture IndividualHost::architecture() { return plugin_arch; } @@ -137,7 +137,7 @@ GroupHost::GroupHost(boost::asio::io_context& io_context, Sockets& sockets, std::string group_name) : HostProcess(io_context, logger), - plugin_arch(find_vst_architecture(plugin_path)), + plugin_arch(find_dll_architecture(plugin_path)), host_path(find_vst_host(plugin_arch, true)), sockets(sockets) { #ifdef WITH_WINEDBG @@ -233,7 +233,7 @@ GroupHost::GroupHost(boost::asio::io_context& io_context, } } -PluginArchitecture GroupHost::architecture() { +LibArchitecture GroupHost::architecture() { return plugin_arch; } diff --git a/src/plugin/host-process.h b/src/plugin/host-process.h index 299dab72..ca0dc25e 100644 --- a/src/plugin/host-process.h +++ b/src/plugin/host-process.h @@ -44,7 +44,7 @@ class HostProcess { * Return the architecture of the plugin we are loading, i.e. whether it is * 32-bit or 64-bit. */ - virtual PluginArchitecture architecture() = 0; + virtual LibArchitecture architecture() = 0; /** * Return the full path to the host application in use. The host application @@ -130,13 +130,13 @@ class IndividualHost : public HostProcess { boost::filesystem::path plugin_path, const Sockets& sockets); - PluginArchitecture architecture() override; + LibArchitecture architecture() override; boost::filesystem::path path() override; bool running() override; void terminate() override; private: - PluginArchitecture plugin_arch; + LibArchitecture plugin_arch; boost::filesystem::path host_path; boost::process::child host; }; @@ -173,13 +173,13 @@ class GroupHost : public HostProcess { Sockets& socket_endpoint, std::string group_name); - PluginArchitecture architecture() override; + LibArchitecture architecture() override; boost::filesystem::path path() override; bool running() override; void terminate() override; private: - PluginArchitecture plugin_arch; + LibArchitecture plugin_arch; boost::filesystem::path host_path; /** diff --git a/src/plugin/utils.cpp b/src/plugin/utils.cpp index ab14641e..a9e7d894 100644 --- a/src/plugin/utils.cpp +++ b/src/plugin/utils.cpp @@ -54,10 +54,10 @@ std::optional find_wineprefix() { return dosdevices_dir->parent_path(); } -fs::path find_vst_host(PluginArchitecture plugin_arch, bool use_plugin_groups) { +fs::path find_vst_host(LibArchitecture plugin_arch, bool use_plugin_groups) { auto host_name = use_plugin_groups ? yabridge_group_host_name : yabridge_individual_host_name; - if (plugin_arch == PluginArchitecture::vst_32) { + if (plugin_arch == LibArchitecture::dll_32) { host_name = use_plugin_groups ? yabridge_group_host_name_32bit : yabridge_individual_host_name_32bit; } @@ -110,17 +110,17 @@ fs::path find_vst_plugin() { boost::filesystem::path generate_group_endpoint( const std::string& group_name, const boost::filesystem::path& wine_prefix, - const PluginArchitecture architecture) { + const LibArchitecture architecture) { std::ostringstream socket_name; socket_name << "yabridge-group-" << group_name << "-" << std::to_string( std::hash{}(wine_prefix.string())) << "-"; switch (architecture) { - case PluginArchitecture::vst_32: + case LibArchitecture::dll_32: socket_name << "x32"; break; - case PluginArchitecture::vst_64: + case LibArchitecture::dll_64: socket_name << "x64"; break; } diff --git a/src/plugin/utils.h b/src/plugin/utils.h index 67d32bf2..c68175be 100644 --- a/src/plugin/utils.h +++ b/src/plugin/utils.h @@ -71,7 +71,7 @@ std::string create_logger_prefix( * @return The a path to the VST host, if found. * @throw std::runtime_error If the Wine VST host could not be found. */ -boost::filesystem::path find_vst_host(PluginArchitecture plugin_arch, +boost::filesystem::path find_vst_host(LibArchitecture plugin_arch, bool use_plugin_groups); /** @@ -125,7 +125,7 @@ std::optional find_wineprefix(); boost::filesystem::path generate_group_endpoint( const std::string& group_name, const boost::filesystem::path& wine_prefix, - const PluginArchitecture architecture); + const LibArchitecture architecture); /** * Return the search path as defined in `$PATH`, with `~/.local/share/yabridge`