commit e70477c00758909ef539c056f9bb1f5eb98420a3
parent 0b1ef0c341994ce0bffc51d4b5864035c8c0a63e
Author: cfillion <cfillion@users.noreply.github.com>
Date: Wed, 6 Sep 2017 13:10:19 -0700
(miscellaneous code cleanup)
Diffstat:
19 files changed, 36 insertions(+), 44 deletions(-)
diff --git a/src/about.cpp b/src/about.cpp
@@ -551,7 +551,7 @@ void AboutPackageDelegate::init(About *dialog)
void AboutPackageDelegate::updateList(const int index)
{
- static const map<Source::Section, string> sectionMap{
+ const pair<Source::Section, const char *> sectionMap[] = {
{Source::MainSection, "Main"},
{Source::MIDIEditorSection, "MIDI Editor"},
{Source::MIDIInlineEditorSection, "MIDI Inline Editor"},
diff --git a/src/config.cpp b/src/config.cpp
@@ -20,9 +20,9 @@
#include "path.hpp"
#ifdef _WIN32
-#include <windows.h>
+# include <windows.h>
#else
-#include <swell/swell.h>
+# include <swell/swell.h>
#endif
using namespace std;
@@ -137,8 +137,7 @@ void Config::read(const Path &path)
install.autoInstall = getBool(INSTALL_GRP, AUTOINSTALL_KEY, install.autoInstall);
install.bleedingEdge = getBool(INSTALL_GRP, PRERELEASES_KEY, install.bleedingEdge);
- install.promptObsolete = getBool(INSTALL_GRP,
- PROMPTOBSOLETE_KEY, install.promptObsolete);
+ install.promptObsolete = getBool(INSTALL_GRP, PROMPTOBSOLETE_KEY, install.promptObsolete);
network.proxy = getString(NETWORK_GRP, PROXY_KEY, network.proxy);
network.verifyPeer = getBool(NETWORK_GRP, VERIFYPEER_KEY, network.verifyPeer);
diff --git a/src/control.hpp b/src/control.hpp
@@ -21,9 +21,9 @@
#include <map>
#ifdef _WIN32
-#include <windows.h>
+# include <windows.h>
#else
-#include <swell/swell.h>
+# include <swell/swell.h>
#endif
class Dialog;
diff --git a/src/dialog.cpp b/src/dialog.cpp
@@ -26,7 +26,7 @@
#include <reaper_plugin_functions.h>
#ifdef _WIN32
-#include <windowsx.h>
+# include <windowsx.h>
#endif
using namespace std;
diff --git a/src/errors.hpp b/src/errors.hpp
@@ -23,7 +23,7 @@
class reapack_error : public std::runtime_error {
public:
- reapack_error(const char *what) : std::runtime_error(what) {}
+ using runtime_error::runtime_error;
reapack_error(const boost::format &f) : std::runtime_error(f.str()) {}
};
diff --git a/src/filedialog.cpp b/src/filedialog.cpp
@@ -20,7 +20,7 @@
#include "path.hpp"
#ifndef _WIN32
-#include <swell.h>
+# include <swell.h>
#endif
auto_string FileDialog::getOpenFileName(HWND parent, HINSTANCE instance,
diff --git a/src/filedialog.hpp b/src/filedialog.hpp
@@ -21,9 +21,9 @@
#include "encoding.hpp"
#ifdef _WIN32
-#include <windows.h>
+# include <windows.h>
#else
-#include <swell-types.h>
+# include <swell-types.h>
#endif
class Path;
diff --git a/src/filesystem.cpp b/src/filesystem.cpp
@@ -28,15 +28,12 @@
#include <reaper_plugin_functions.h>
#ifdef _WIN32
-#include <windows.h>
+# include <windows.h>
+# define stat _stat
#endif
using namespace std;
-#ifdef _WIN32
-#define stat _stat
-#endif
-
static bool stat(const Path &path, struct stat *out)
{
const Path &fullPath = Path::prefixRoot(path);
diff --git a/src/listview.cpp b/src/listview.cpp
@@ -24,7 +24,7 @@
#include <boost/algorithm/string.hpp>
#ifdef _WIN32
-#include <commctrl.h>
+# include <commctrl.h>
#endif
using namespace std;
diff --git a/src/main.cpp b/src/main.cpp
@@ -199,11 +199,9 @@ extern "C" REAPER_PLUGIN_DLL_EXPORT int REAPER_PLUGIN_ENTRYPOINT(
}
#ifndef _WIN32
-#include "resource.hpp"
-
-#include <swell/swell-dlggen.h>
-#include "resource.rc_mac_dlg"
-
-#include <swell/swell-menugen.h>
-#include "resource.rc_mac_menu"
+# include "resource.hpp"
+# include <swell/swell-dlggen.h>
+# include "resource.rc_mac_dlg"
+# include <swell/swell-menugen.h>
+# include "resource.rc_mac_menu"
#endif
diff --git a/src/package.hpp b/src/package.hpp
@@ -41,8 +41,7 @@ public:
static Type getType(const char *);
static std::string displayType(Type);
- static const std::string &displayName(const std::string &name,
- const std::string &desc);
+ static const std::string &displayName(const std::string &name, const std::string &desc);
Package(const Type, const std::string &name, const Category *);
~Package();
diff --git a/src/reapack.cpp b/src/reapack.cpp
@@ -69,7 +69,7 @@ static void CleanupTempFiles()
std::string ReaPack::resourcePath()
{
#ifdef _WIN32
- // convert from current system encoding to unicode...
+ // convert from the current system codepage to UTF-8
return from_autostring(make_autostring(GetResourcePath(), CP_ACP));
#else
return GetResourcePath();
diff --git a/src/resource.hpp b/src/resource.hpp
@@ -19,13 +19,13 @@
#define REAPACK_RESOURCE_HPP
#ifdef _WIN32
-#include <commctrl.h>
-#include <richedit.h>
+# include <commctrl.h>
+# include <richedit.h>
#else
-#define PROGRESS_CLASS "msctls_progress32"
-#define WC_LISTVIEW "SysListView32"
-#define WC_TABCONTROL "SysTabControl32"
-#define PBS_MARQUEE 0
+# define PROGRESS_CLASS "msctls_progress32"
+# define WC_LISTVIEW "SysListView32"
+# define WC_TABCONTROL "SysTabControl32"
+# define PBS_MARQUEE 0
#endif
#define DIALOG_STYLE \
diff --git a/src/resource.rc b/src/resource.rc
@@ -1,7 +1,7 @@
#include "resource.hpp"
#ifdef _WIN32
-#include "winres.h"
+# include "winres.h"
#endif
IDD_PROGRESS_DIALOG DIALOGEX 0, 0, 260, 80
diff --git a/src/tabbar.cpp b/src/tabbar.cpp
@@ -20,7 +20,7 @@
#include "dialog.hpp"
#ifdef _WIN32
-#include <commctrl.h>
+# include <commctrl.h>
#endif
TabBar::TabBar(HWND handle, Dialog *parent, const Tabs &tabs)
diff --git a/src/thread.hpp b/src/thread.hpp
@@ -30,9 +30,9 @@
#include <WDL/mutex.h>
#ifdef _WIN32
-#include <windows.h>
+# include <windows.h>
#else
-#include <swell-types.h>
+# include <swell-types.h>
#endif
class ThreadTask {
diff --git a/src/transaction.cpp b/src/transaction.cpp
@@ -330,7 +330,7 @@ void Transaction::registerQueued()
void Transaction::registerScript(const HostTicket ®, const bool isLastCall)
{
- static const map<Source::Section, int> sectionMap{
+ const pair<Source::Section, int> sectionMap[] = {
{Source::MainSection, 0},
{Source::MIDIEditorSection, 32060},
{Source::MIDIInlineEditorSection, 32062},
diff --git a/test/package.cpp b/test/package.cpp
@@ -9,7 +9,7 @@ using namespace std;
static const char *M = "[package]";
TEST_CASE("package type from string", M) {
- const vector<pair<const char *, Package::Type> > tests{
+ const pair<const char *, Package::Type> tests[] = {
{"yoyo", Package::UnknownType},
{"script", Package::ScriptType},
{"extension", Package::ExtensionType},
@@ -28,7 +28,7 @@ TEST_CASE("package type from string", M) {
}
TEST_CASE("package type to string", M) {
- const vector<pair<Package::Type, string> > tests{
+ const pair<Package::Type, string> tests[] = {
{Package::UnknownType, "Unknown"},
{Package::ScriptType, "Script"},
{Package::ExtensionType, "Extension"},
diff --git a/test/source.cpp b/test/source.cpp
@@ -144,9 +144,7 @@ TEST_CASE("empty source url", M) {
TEST_CASE("source target path", M) {
MAKE_VERSION;
- Source source("file.name", "url", &ver);
-
- const vector<pair<Package::Type, string> > tests{
+ const pair<Package::Type, string> tests[] = {
{Package::ScriptType, "Scripts/Index Name/Category Name/file.name"},
{Package::EffectType, "Effects/Index Name/Category Name/file.name"},
{Package::ExtensionType, "UserPlugins/file.name"},
@@ -159,6 +157,7 @@ TEST_CASE("source target path", M) {
{Package::MIDINoteNamesType, "MIDINoteNames/file.name"},
};
+ Source source("file.name", "url", &ver);
for(const auto &pair : tests) {
source.setTypeOverride(pair.first);
REQUIRE(source.targetPath() == Path(pair.second));