From f2faf7acf4445fef2a149ebbdecb569a2d119d94 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 2 Jul 2018 08:20:47 +0200 Subject: nothing important --- api/plugin-api.hpp | 4 +-- compat/check-visible.cpp | 2 +- compat/correlation-calibrator.cpp | 2 +- compat/macros.hpp | 7 ++++- compat/meta.hpp | 35 +++++++++++----------- compat/timer.cpp | 3 +- logic/pipeline.cpp | 2 +- logic/win32-shortcuts.cpp | 2 +- logic/win32-shortcuts.h | 2 +- options/base-value.cpp | 4 +-- options/bundle.cpp | 19 ++++++------ options/bundle.hpp | 51 +++++++++++++++++++-------------- options/connector.cpp | 7 ++--- options/connector.hpp | 9 +++--- options/defs.hpp | 5 ++-- options/slider.cpp | 15 +++++++++- options/slider.hpp | 2 ++ options/value-traits.hpp | 7 ++--- proto-ft/ftnoir_protocol_ft.cpp | 10 +++---- proto-ft/lang/nl_NL.ts | 4 +-- proto-ft/lang/ru_RU.ts | 4 +-- proto-ft/lang/stub.ts | 4 +-- proto-ft/lang/zh_CN.ts | 4 +-- proto-simconnect/ftnoir_protocol_sc.cpp | 2 +- spline/axis-opts.cpp | 2 +- spline/axis-opts.hpp | 2 +- tracker-hatire/thread.cpp | 6 ++-- tracker-pt/module/frame.cpp | 7 ++--- tracker-pt/module/point_extractor.cpp | 2 +- tracker-pt/pt-settings.hpp | 4 +-- tracker-steamvr/steamvr.cpp | 2 +- tracker-wii/wii_frame.cpp | 4 +-- 32 files changed, 123 insertions(+), 112 deletions(-) diff --git a/api/plugin-api.hpp b/api/plugin-api.hpp index b23a5010..53d4fac6 100644 --- a/api/plugin-api.hpp +++ b/api/plugin-api.hpp @@ -27,8 +27,7 @@ enum Axis { NonAxis = -1, }; -namespace plugin_api { -namespace detail { +namespace plugin_api::detail { class OTR_API_EXPORT BaseDialog : public QDialog { @@ -43,7 +42,6 @@ private slots: void done(int) override; }; -} // ns } // ns #define OTR_PLUGIN_EXPORT OTR_GENERIC_EXPORT diff --git a/compat/check-visible.cpp b/compat/check-visible.cpp index 0f4c6e6d..0e154dd0 100644 --- a/compat/check-visible.cpp +++ b/compat/check-visible.cpp @@ -4,7 +4,7 @@ #include "timer.hpp" -#include +#include #include diff --git a/compat/correlation-calibrator.cpp b/compat/correlation-calibrator.cpp index 70455818..b2e83153 100644 --- a/compat/correlation-calibrator.cpp +++ b/compat/correlation-calibrator.cpp @@ -61,7 +61,7 @@ bool correlation_calibrator::check_buckets(const vec6& data) if (pos[k] >= nbuckets[k]) { - once_only(qDebug() << "idx" << k + eval_once(qDebug() << "idx" << k << "bucket" << (int)pos[k] << "outside bounds" << nbuckets[k]); diff --git a/compat/macros.hpp b/compat/macros.hpp index 61c49975..0807df4c 100644 --- a/compat/macros.hpp +++ b/compat/macros.hpp @@ -44,8 +44,13 @@ // from now only C++ +#include + //#define once_only(...) do { static bool once__ = false; if (!once__) { once__ = true; __VA_ARGS__; } } while(false) -#define once_only(expr) ([&] { static decltype(auto) ret___1132 = (expr); return ret___1132; }()) +//#define once_only(expr) ([&] { static decltype(auto) ret___1132 = (expr); return (decltype(ret___1132) const&) ret___1132; }()) + +#define eval_once__2(expr, ident) (([&] { static bool ident = ((expr), true); (void)(ident); })) +#define eval_once(expr) eval_once__2(expr, PP_CAT(eval_once_init__, __COUNTER__)) #include diff --git a/compat/meta.hpp b/compat/meta.hpp index 8682fdc8..11c5ca0f 100644 --- a/compat/meta.hpp +++ b/compat/meta.hpp @@ -11,9 +11,7 @@ static_assert(sizeof...(x) == ~0ul); \ static_assert(sizeof...(x) == 0u) -namespace meta { - -namespace detail { +namespace meta::detail { template struct tuple; @@ -47,27 +45,26 @@ namespace detail { { using type = to; }; -} // ns detail - - -template -using reverse = typename detail::reverse_, detail::tuple<>>::type; +} // ns meta::detail -// the to/from order is awkward but mimics function composition -template class to, typename from> -using lift = typename detail::lift_::type; +namespace meta { + template + using reverse = typename detail::reverse_, detail::tuple<>>::type; -template -using first = x; + // the to/from order is awkward but mimics function composition + template class to, typename from> + using lift = typename detail::lift_::type; -template -using rest = detail::tuple; + template + using first = x; -template -using butlast = reverse>>; + template + using rest = detail::tuple; -template -using last = lift>; + template + using butlast = reverse>>; + template + using last = lift>; } // ns meta diff --git a/compat/timer.cpp b/compat/timer.cpp index dc9808b1..b9664263 100644 --- a/compat/timer.cpp +++ b/compat/timer.cpp @@ -6,9 +6,8 @@ * notice appear in all copies. */ -#include - #include "timer.hpp" +#include #include using time_type = Timer::time_type; diff --git a/logic/pipeline.cpp b/logic/pipeline.cpp index bf264315..c8cdc72d 100644 --- a/logic/pipeline.cpp +++ b/logic/pipeline.cpp @@ -248,7 +248,7 @@ static cc_forceinline bool nan_check_(const x& datum, const y& next, const xs&.. static cc_noinline void emit_nan_check_msg(const char* text, const char* fun, int line) { - once_only( + eval_once( qDebug() << "nan check failed" << "for:" << text << "function:" << fun diff --git a/logic/win32-shortcuts.cpp b/logic/win32-shortcuts.cpp index 170d16fe..11764807 100644 --- a/logic/win32-shortcuts.cpp +++ b/logic/win32-shortcuts.cpp @@ -119,7 +119,7 @@ static const win_key windows_key_sequences[] { { DIK_PAUSE, Qt::Key_Pause}, { DIK_NUMLOCK, Qt::Key_NumLock}, { DIK_CAPSLOCK, Qt::Key_CapsLock}, -#define mod(x, y) static_cast((x) | (y)) +#define mod(x, y) Qt::Key(int(x) | int((y))) { DIK_NUMPAD0, mod(Qt::Key_0, Qt::KeypadModifier)}, { DIK_NUMPAD0, mod(Qt::Key_0, Qt::KeypadModifier)}, { DIK_NUMPAD1, mod(Qt::Key_1, Qt::KeypadModifier)}, diff --git a/logic/win32-shortcuts.h b/logic/win32-shortcuts.h index 8cd6bdc9..437d251a 100644 --- a/logic/win32-shortcuts.h +++ b/logic/win32-shortcuts.h @@ -10,7 +10,7 @@ struct OTR_LOGIC_EXPORT win_key { - win_key(int win, Qt::Key qt) : win(win), qt(qt) {} + //win_key(int win, Qt::Key qt) : win(win), qt(qt) {} int win; Qt::Key qt; static bool from_qt(QKeySequence qt_, int& dik, Qt::KeyboardModifiers &mods); diff --git a/options/base-value.cpp b/options/base-value.cpp index dbeabbea..d900ad0f 100644 --- a/options/base-value.cpp +++ b/options/base-value.cpp @@ -26,8 +26,7 @@ void value_::store(const QVariant& datum) b->store_kv(self_name, datum); } -namespace options { -namespace detail { +namespace options::detail { void set_base_value_to_default(value_* val) { @@ -35,5 +34,4 @@ void set_base_value_to_default(value_* val) } } // ns options::detail -} // ns options diff --git a/options/bundle.cpp b/options/bundle.cpp index e0db3fb3..b722338b 100644 --- a/options/bundle.cpp +++ b/options/bundle.cpp @@ -14,10 +14,7 @@ using options::value_; -namespace options -{ - -namespace detail { +namespace options::detail { bundle::bundle(const QString& group_name) : mtx(QMutex::Recursive), @@ -152,7 +149,7 @@ void bundler::after_profile_changed_() void bundler::refresh_all_bundles() { - singleton().after_profile_changed_(); + bundler_singleton().after_profile_changed_(); } bundler::bundler() : implsgl_mtx(QMutex::Recursive) @@ -164,7 +161,7 @@ bundler::~bundler() //qDebug() << "exit: bundle singleton"; } -std::shared_ptr bundler::make_bundle(const bundler::k& key) +std::shared_ptr bundler::make_bundle_(const bundler::k& key) { QMutexLocker l(&implsgl_mtx); @@ -193,7 +190,7 @@ std::shared_ptr bundler::make_bundle(const bundler::k& key) return shr; } -OTR_OPTIONS_EXPORT bundler& singleton() +bundler& bundler::bundler_singleton() { static bundler ret; return ret; @@ -201,14 +198,16 @@ OTR_OPTIONS_EXPORT bundler& singleton() QMutex* bundle::get_mtx() const { return mtx; } -} // end options::detail +} // ns options::detail + +namespace options { OTR_OPTIONS_EXPORT std::shared_ptr make_bundle(const QString& name) { if (name.size()) - return detail::singleton().make_bundle(name); + return detail::bundler::bundler_singleton().make_bundle_(name); else return std::make_shared(QString()); } -} // end options +} // ns options diff --git a/options/bundle.hpp b/options/bundle.hpp index 98e194db..a12a335c 100644 --- a/options/bundle.hpp +++ b/options/bundle.hpp @@ -27,11 +27,17 @@ #include "export.hpp" -namespace options { +namespace options::detail { + class bundle; +} // ns options::detail -namespace detail { +namespace options { + using bundle_ = detail::bundle; + using bundle = std::shared_ptr; + OTR_OPTIONS_EXPORT std::shared_ptr make_bundle(const QString& name); +} // ns options -void set_base_value_to_default(value_* val); +namespace options::detail { struct bundler; @@ -52,17 +58,18 @@ private: group saved; group transient; +signals: + void reloading(); + void saving() const; + void changed() const; + +public: bundle(const bundle&) = delete; bundle(bundle&&) = delete; bundle& operator=(bundle&&) = delete; bundle& operator=(const bundle&) = delete; QMutex* get_mtx() const override; -signals: - void reloading(); - void saving() const; - void changed() const; -public: cc_noinline bundle(const QString& group_name); cc_noinline ~bundle() override; QString name() const { return group_name; } @@ -82,32 +89,34 @@ public slots: void set_all_to_default(); }; -OTR_OPTIONS_EXPORT bundler& singleton(); - -struct OTR_OPTIONS_EXPORT bundler +struct OTR_OPTIONS_EXPORT bundler final { -public: using k = QString; using v = bundle; using weak = std::weak_ptr; using shared = std::shared_ptr; + private: QMutex implsgl_mtx; std::map implsgl_data; void after_profile_changed_(); + public: + static void refresh_all_bundles(); + +private: + friend OTR_OPTIONS_EXPORT + std::shared_ptr options::make_bundle(const QString& name); + + std::shared_ptr make_bundle_(const k& key); + + static bundler& bundler_singleton(); + bundler(); ~bundler(); - std::shared_ptr make_bundle(const k& key); - static void refresh_all_bundles(); }; -OTR_OPTIONS_EXPORT bundler& singleton(); -} // ns options::detail - -using bundle_ = detail::bundle; -using bundle = std::shared_ptr; +void set_base_value_to_default(value_* val); -OTR_OPTIONS_EXPORT std::shared_ptr make_bundle(const QString& name); +} // ns options::detail -} // ns options diff --git a/options/connector.cpp b/options/connector.cpp index 2d039ccf..0efac8f1 100644 --- a/options/connector.cpp +++ b/options/connector.cpp @@ -11,8 +11,7 @@ #include -namespace options { -namespace detail { +namespace options::detail { static bool generic_is_equal(const QVariant& val1, const QVariant& val2) { @@ -129,6 +128,4 @@ connector::connector() { } -} - -} +} // ns options::detail diff --git a/options/connector.hpp b/options/connector.hpp index 68e86096..26812e7f 100644 --- a/options/connector.hpp +++ b/options/connector.hpp @@ -21,10 +21,10 @@ #include "export.hpp" namespace options { + class value_; +} -class value_; - -namespace detail { +namespace options::detail { class OTR_OPTIONS_EXPORT connector { @@ -67,5 +67,4 @@ public: connector& operator=(connector&&) = default; }; -} // ns detail -} // ns options +} // ns options::detail diff --git a/options/defs.hpp b/options/defs.hpp index 58846cc3..2467a7a0 100644 --- a/options/defs.hpp +++ b/options/defs.hpp @@ -24,8 +24,7 @@ #define OPENTRACK_DEFINE_METATYPE(t) OPENTRACK_DEFINE_METATYPE2(t, __COUNTER__) -namespace options { -namespace detail { +namespace options::detail { struct custom_type_initializer final { @@ -39,4 +38,4 @@ struct custom_type_initializer final }; } // ns options::detail -} // ns options + diff --git a/options/slider.cpp b/options/slider.cpp index 4f4124c6..56d9ba16 100644 --- a/options/slider.cpp +++ b/options/slider.cpp @@ -24,8 +24,21 @@ slider_value::slider_value(double cur, double min, double max) : cur_ = min_; } -slider_value::slider_value(const slider_value& v) : slider_value(v.cur(), v.min(), v.max()) +slider_value& slider_value::operator=(const slider_value& v) { + if (this != &v) + { + cur_ = v.cur(); + min_ = v.min(); + max_ = v.max(); + } + + return *this; +} + +slider_value::slider_value(const slider_value& v) +{ + *this = v; } slider_value::slider_value() : slider_value(0, 0, 0) diff --git a/options/slider.hpp b/options/slider.hpp index 6c9c5a23..360c85b8 100644 --- a/options/slider.hpp +++ b/options/slider.hpp @@ -40,6 +40,8 @@ namespace options return t(cur_); } + slider_value& operator=(const slider_value& v); + slider_value(const slider_value& v); slider_value(); bool operator==(const slider_value& v) const; diff --git a/options/value-traits.hpp b/options/value-traits.hpp index 0b30248e..b507874c 100644 --- a/options/value-traits.hpp +++ b/options/value-traits.hpp @@ -8,8 +8,7 @@ #include -namespace options { -namespace detail { +namespace options::detail { template struct default_value_traits @@ -49,5 +48,5 @@ struct value_traits : public default_value_traits { }; -} // ns detail -} // ns options +} // ns options::detail + diff --git a/proto-ft/ftnoir_protocol_ft.cpp b/proto-ft/ftnoir_protocol_ft.cpp index bf99a94f..7bc85afa 100644 --- a/proto-ft/ftnoir_protocol_ft.cpp +++ b/proto-ft/ftnoir_protocol_ft.cpp @@ -20,8 +20,8 @@ freetrack::~freetrack() dummyTrackIR.close(); } -static_assert(sizeof(LONG) == sizeof(std::int32_t), ""); -static_assert(sizeof(LONG) == 4u, ""); +static_assert(sizeof(LONG) == sizeof(std::int32_t)); +static_assert(sizeof(LONG) == 4u); static constexpr inline float d2r = float(M_PI/180); @@ -35,8 +35,8 @@ cc_noinline void store(float volatile& place, const float value) value_.f32 = value; - static_assert(sizeof(value_) == sizeof(float), ""); - static_assert(offsetof(decltype(value_), f32) == offsetof(decltype(value_), i32), ""); + static_assert(sizeof(value_) == sizeof(float)); + static_assert(offsetof(decltype(value_), f32) == offsetof(decltype(value_), i32)); (void)InterlockedExchange((LONG volatile*)&place, value_.i32); } @@ -44,7 +44,7 @@ cc_noinline void store(float volatile& place, const float value) template cc_forceinline void store(t volatile& place, t value) { - static_assert(sizeof(t) == 4u, ""); + static_assert(sizeof(t) == 4u); (void)InterlockedExchange((LONG volatile*) &place, value); } diff --git a/proto-ft/lang/nl_NL.ts b/proto-ft/lang/nl_NL.ts index e2b72543..ec4f58da 100644 --- a/proto-ft/lang/nl_NL.ts +++ b/proto-ft/lang/nl_NL.ts @@ -56,11 +56,11 @@ Starting tracking will again overwrite the DLL locations. freetrack - Can't load freetrack memory mapping + Unknown game - Unknown game + Can't load freetrack memory mapping diff --git a/proto-ft/lang/ru_RU.ts b/proto-ft/lang/ru_RU.ts index d749121c..c793ae6b 100644 --- a/proto-ft/lang/ru_RU.ts +++ b/proto-ft/lang/ru_RU.ts @@ -58,11 +58,11 @@ Starting tracking will again overwrite the DLL locations. freetrack - Can't load freetrack memory mapping + Unknown game - Unknown game + Can't load freetrack memory mapping diff --git a/proto-ft/lang/stub.ts b/proto-ft/lang/stub.ts index 4962332f..635844a5 100644 --- a/proto-ft/lang/stub.ts +++ b/proto-ft/lang/stub.ts @@ -56,11 +56,11 @@ Starting tracking will again overwrite the DLL locations. freetrack - Can't load freetrack memory mapping + Unknown game - Unknown game + Can't load freetrack memory mapping diff --git a/proto-ft/lang/zh_CN.ts b/proto-ft/lang/zh_CN.ts index 903ce19b..442a1aa1 100644 --- a/proto-ft/lang/zh_CN.ts +++ b/proto-ft/lang/zh_CN.ts @@ -56,11 +56,11 @@ Starting tracking will again overwrite the DLL locations. freetrack - Can't load freetrack memory mapping + Unknown game - Unknown game + Can't load freetrack memory mapping diff --git a/proto-simconnect/ftnoir_protocol_sc.cpp b/proto-simconnect/ftnoir_protocol_sc.cpp index ab4a85dd..75815f1b 100644 --- a/proto-simconnect/ftnoir_protocol_sc.cpp +++ b/proto-simconnect/ftnoir_protocol_sc.cpp @@ -22,7 +22,7 @@ simconnect::~simconnect() void simconnect::run() { - HANDLE event = CreateEventA(NULL, FALSE, FALSE, nullptr); + HANDLE event = CreateEventA(nullptr, FALSE, FALSE, nullptr); if (event == nullptr) { diff --git a/spline/axis-opts.cpp b/spline/axis-opts.cpp index d7616939..b5f11aaa 100644 --- a/spline/axis-opts.cpp +++ b/spline/axis-opts.cpp @@ -39,7 +39,7 @@ QString const& axis_opts::prefix() const { return prefix_; } Axis axis_opts::axis() const { return axis_; } -QString axis_opts::n(QString pfx, QString name) +QString axis_opts::n(QString const& pfx, QString const& name) { return QString("%1-%2").arg(pfx, name); } diff --git a/spline/axis-opts.hpp b/spline/axis-opts.hpp index 2f0d8432..a76ea3cf 100644 --- a/spline/axis-opts.hpp +++ b/spline/axis-opts.hpp @@ -50,7 +50,7 @@ struct OTR_SPLINE_EXPORT axis_opts final QString const& prefix() const; Axis axis() const; private: - static inline QString n(QString pfx, QString name); + static inline QString n(QString const& pfx, QString const& name); QString prefix_; Axis axis_; diff --git a/tracker-hatire/thread.cpp b/tracker-hatire/thread.cpp index 6025d74c..07e97d78 100644 --- a/tracker-hatire/thread.cpp +++ b/tracker-hatire/thread.cpp @@ -25,7 +25,7 @@ void hatire_thread::sendcmd_impl(const QByteArray &cmd) Log(logMess); com_port.write(cmd); if (!com_port.waitForBytesWritten(1000)) { - emit serial_debug_info_str(tr("Timeout during writing command")); + serial_debug_info_str(tr("Timeout during writing command")); } else { Msg.append("\r\n"); @@ -43,7 +43,7 @@ void hatire_thread::sendcmd_impl(const QByteArray &cmd) emit serial_debug_info(Msg); #endif } else { - emit serial_debug_info_str(tr("COM port not open")); + serial_debug_info_str(tr("COM port not open")); } } #endif @@ -146,7 +146,7 @@ void hatire_thread::run() void hatire_thread::serial_debug_info_str(const QString& str) { - serial_debug_info(str.toUtf8()); + emit serial_debug_info(str.toLatin1()); } serial_result hatire_thread::init_serial_port_impl() diff --git a/tracker-pt/module/frame.cpp b/tracker-pt/module/frame.cpp index f54c2e36..6734edf6 100644 --- a/tracker-pt/module/frame.cpp +++ b/tracker-pt/module/frame.cpp @@ -2,9 +2,6 @@ #include "compat/math.hpp" -#include -#include - #include using namespace pt_module; @@ -16,7 +13,7 @@ Preview& Preview::operator=(const pt_frame& frame_) if (frame.channels() != 3) { - once_only(qDebug() << "tracker/pt: camera frame depth: 3 !=" << frame.channels()); + eval_once(qDebug() << "tracker/pt: camera frame depth: 3 !=" << frame.channels()); return *this; } @@ -42,7 +39,7 @@ QImage Preview::get_bitmap() if (stride < 64 || stride < frame_out.cols * 4) { - once_only(qDebug() << "bad stride" << stride + eval_once(qDebug() << "bad stride" << stride << "for bitmap size" << frame_copy.cols << frame_copy.rows); return QImage(); } diff --git a/tracker-pt/module/point_extractor.cpp b/tracker-pt/module/point_extractor.cpp index 1208da4e..00248029 100644 --- a/tracker-pt/module/point_extractor.cpp +++ b/tracker-pt/module/point_extractor.cpp @@ -147,7 +147,7 @@ void PointExtractor::color_to_grayscale(const cv::Mat& frame, cv::Mat1b& output) break; } default: - once_only(qDebug() << "wrong pt_color_type enum value" << int(s.blob_color)); + eval_once(qDebug() << "wrong pt_color_type enum value" << int(s.blob_color)); /*FALLTHROUGH*/ case pt_color_natural: cv::cvtColor(frame, output, cv::COLOR_BGR2GRAY); diff --git a/tracker-pt/pt-settings.hpp b/tracker-pt/pt-settings.hpp index a8e3497a..a35c248b 100644 --- a/tracker-pt/pt-settings.hpp +++ b/tracker-pt/pt-settings.hpp @@ -18,8 +18,8 @@ struct pt_settings final : options::opts { using slider_value = options::slider_value; - pt_settings(const QString& name) : opts(name) {} - ~pt_settings() {} + explicit pt_settings(const QString& name) : opts(name) {} + ~pt_settings() override = default; value camera_name { b, "camera-name", "" }; value cam_res_x { b, "camera-res-width", 640 }, diff --git a/tracker-steamvr/steamvr.cpp b/tracker-steamvr/steamvr.cpp index e4ac8835..cafdc556 100644 --- a/tracker-steamvr/steamvr.cpp +++ b/tracker-steamvr/steamvr.cpp @@ -140,7 +140,7 @@ device_list::maybe_pose device_list::get_pose(int k) if (pose.bPoseIsValid && pose.bDeviceIsConnected) return maybe_pose{ true, poses[k] }; else - once_only(qDebug() << "steamvr:" + eval_once(qDebug() << "steamvr:" << "no valid pose from device" << k << "valid" << pose.bPoseIsValid << "connected" << pose.bDeviceIsConnected); diff --git a/tracker-wii/wii_frame.cpp b/tracker-wii/wii_frame.cpp index 92e7fd35..df7b9ca4 100644 --- a/tracker-wii/wii_frame.cpp +++ b/tracker-wii/wii_frame.cpp @@ -27,7 +27,7 @@ WIIPreview& WIIPreview::operator=(const pt_frame& frame_) if (frame.channels() != 3) { - once_only(qDebug() << "tracker/pt: camera frame depth: 3 !=" << frame.channels()); + eval_once(qDebug() << "tracker/pt: camera frame depth: 3 !=" << frame.channels()); return *this; } @@ -61,7 +61,7 @@ QImage WIIPreview::get_bitmap() if (stride < 64 || stride < frame_out.cols * 4) { - once_only(qDebug() << "bad stride" << stride + eval_once(qDebug() << "bad stride" << stride << "for bitmap size" << frame_copy.cols << frame_copy.rows); return QImage(); } -- cgit v1.2.3