diff options
| author | Stanislaw Halik <sthalik@misaki.pl> | 2018-04-03 12:26:38 +0200 | 
|---|---|---|
| committer | Stanislaw Halik <sthalik@misaki.pl> | 2018-04-05 03:23:13 +0200 | 
| commit | eb32a2ac02c6d1adcfeb0a1a5522f8aaea442489 (patch) | |
| tree | b15b4ab34600e9c5d5da17eac33ea687167bbfc7 /compat | |
| parent | 22a853b388597e9549125df69508c1c38706dd1d (diff) | |
i18n: provide for non-QObject classes
See compat/tr.hpp for comment.
Diffstat (limited to 'compat')
| -rw-r--r-- | compat/macros.hpp | 15 | ||||
| -rw-r--r-- | compat/tr.cpp | 17 | ||||
| -rw-r--r-- | compat/tr.hpp | 19 | 
3 files changed, 42 insertions, 9 deletions
| diff --git a/compat/macros.hpp b/compat/macros.hpp index c8fbca20..b0c7a51d 100644 --- a/compat/macros.hpp +++ b/compat/macros.hpp @@ -1,16 +1,9 @@  #pragma once -#if !defined __WINE__ -#   include <QCoreApplication> -#   define otr_tr(...) (QCoreApplication::translate(OTR_MODULE_NAME, __VA_ARGS__)) -#   define _(...) (otr_tr(__VA_ARGS__)) -#endif -  #if defined _MSC_VER -# -#   define MEMORY_BARRIER _ReadWriteBarrier() +#   define MEMORY_BARRIER() _ReadWriteBarrier()  #else -#   define MEMORY_BARRIER asm volatile("" ::: "memory") +#   define MEMORY_BARRIER() asm volatile("" ::: "memory")  #endif  #if defined _MSC_VER @@ -52,3 +45,7 @@  #else  #   define OTR_FUNNAME (__PRETTY_FUNCTION__)  #endif + +#if defined __cplusplus +#   define thunk(...) ([&]() { __VA_ARGS__; }) +#endif diff --git a/compat/tr.cpp b/compat/tr.cpp new file mode 100644 index 00000000..b3349435 --- /dev/null +++ b/compat/tr.cpp @@ -0,0 +1,17 @@ +#include "tr.hpp" + + +TR::TR() {} + +TR::TR(const TR&) {} + +TR&TR::operator=(const TR& other) +{ +    if (this == &other) +        return *this; + +    TR::~TR(); +    return *new (this) TR; +} + +TR::~TR() {} diff --git a/compat/tr.hpp b/compat/tr.hpp new file mode 100644 index 00000000..7bb4fb71 --- /dev/null +++ b/compat/tr.hpp @@ -0,0 +1,19 @@ +#pragma once + +#include <QObject> +#include "export.hpp" + +// The class does nothing except provide a fake assignment operator for QObject +// It's meant to be used inside classes that need i18n support but are returned by value. + +class OTR_COMPAT_EXPORT TR : public QObject +{ +    Q_OBJECT + +public: +    TR(); +    TR(const TR&); +    ~TR() override; + +    TR& operator=(const TR& other); +}; | 
