Whitespace cleanup in corelib/global
Change-Id: I087d7d949cfd43e48e8a008621a4eeaa9d104ceb Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
33617c03a4
commit
ff776a3059
@ -45,8 +45,7 @@
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
namespace QContainerTraits
|
||||
{
|
||||
namespace QContainerTraits {
|
||||
|
||||
template<typename C>
|
||||
using value_type = typename C::value_type;
|
||||
|
@ -891,7 +891,8 @@ void *bswapLoop(const uchar *src, size_t n, uchar *dst) noexcept
|
||||
return dst + i;
|
||||
}
|
||||
|
||||
template <> void *qbswap<2>(const void *source, qsizetype n, void *dest) noexcept
|
||||
template<>
|
||||
void *qbswap<2>(const void *source, qsizetype n, void *dest) noexcept
|
||||
{
|
||||
const uchar *src = reinterpret_cast<const uchar *>(source);
|
||||
uchar *dst = reinterpret_cast<uchar *>(dest);
|
||||
@ -899,7 +900,8 @@ template <> void *qbswap<2>(const void *source, qsizetype n, void *dest) noexcep
|
||||
return bswapLoop<quint16>(src, n << 1, dst);
|
||||
}
|
||||
|
||||
template <> void *qbswap<4>(const void *source, qsizetype n, void *dest) noexcept
|
||||
template<>
|
||||
void *qbswap<4>(const void *source, qsizetype n, void *dest) noexcept
|
||||
{
|
||||
const uchar *src = reinterpret_cast<const uchar *>(source);
|
||||
uchar *dst = reinterpret_cast<uchar *>(dest);
|
||||
@ -907,7 +909,8 @@ template <> void *qbswap<4>(const void *source, qsizetype n, void *dest) noexcep
|
||||
return bswapLoop<quint32>(src, n << 2, dst);
|
||||
}
|
||||
|
||||
template <> void *qbswap<8>(const void *source, qsizetype n, void *dest) noexcept
|
||||
template<>
|
||||
void *qbswap<8>(const void *source, qsizetype n, void *dest) noexcept
|
||||
{
|
||||
const uchar *src = reinterpret_cast<const uchar *>(source);
|
||||
uchar *dst = reinterpret_cast<uchar *>(dest);
|
||||
|
@ -95,30 +95,24 @@ public:
|
||||
|
||||
bool operator!() const { return !(val & S::toSpecial(mask())); }
|
||||
bool operator==(QSpecialIntegerBitfield<S, pos, width> i) const
|
||||
{ return ((val ^ i.val) & S::toSpecial(mask())) == 0; }
|
||||
{
|
||||
return ((val ^ i.val) & S::toSpecial(mask())) == 0;
|
||||
}
|
||||
bool operator!=(QSpecialIntegerBitfield<S, pos, width> i) const
|
||||
{ return ((val ^ i.val) & S::toSpecial(mask())) != 0; }
|
||||
{
|
||||
return ((val ^ i.val) & S::toSpecial(mask())) != 0;
|
||||
}
|
||||
|
||||
QSpecialIntegerBitfield &operator +=(T i)
|
||||
{ return (*this = (T(*this) + i)); }
|
||||
QSpecialIntegerBitfield &operator -=(T i)
|
||||
{ return (*this = (T(*this) - i)); }
|
||||
QSpecialIntegerBitfield &operator *=(T i)
|
||||
{ return (*this = (T(*this) * i)); }
|
||||
QSpecialIntegerBitfield &operator /=(T i)
|
||||
{ return (*this = (T(*this) / i)); }
|
||||
QSpecialIntegerBitfield &operator %=(T i)
|
||||
{ return (*this = (T(*this) % i)); }
|
||||
QSpecialIntegerBitfield &operator |=(T i)
|
||||
{ return (*this = (T(*this) | i)); }
|
||||
QSpecialIntegerBitfield &operator &=(T i)
|
||||
{ return (*this = (T(*this) & i)); }
|
||||
QSpecialIntegerBitfield &operator ^=(T i)
|
||||
{ return (*this = (T(*this) ^ i)); }
|
||||
QSpecialIntegerBitfield &operator >>=(T i)
|
||||
{ return (*this = (T(*this) >> i)); }
|
||||
QSpecialIntegerBitfield &operator <<=(T i)
|
||||
{ return (*this = (T(*this) << i)); }
|
||||
QSpecialIntegerBitfield &operator+=(T i) { return (*this = (T(*this) + i)); }
|
||||
QSpecialIntegerBitfield &operator-=(T i) { return (*this = (T(*this) - i)); }
|
||||
QSpecialIntegerBitfield &operator*=(T i) { return (*this = (T(*this) * i)); }
|
||||
QSpecialIntegerBitfield &operator/=(T i) { return (*this = (T(*this) / i)); }
|
||||
QSpecialIntegerBitfield &operator%=(T i) { return (*this = (T(*this) % i)); }
|
||||
QSpecialIntegerBitfield &operator|=(T i) { return (*this = (T(*this) | i)); }
|
||||
QSpecialIntegerBitfield &operator&=(T i) { return (*this = (T(*this) & i)); }
|
||||
QSpecialIntegerBitfield &operator^=(T i) { return (*this = (T(*this) ^ i)); }
|
||||
QSpecialIntegerBitfield &operator>>=(T i) { return (*this = (T(*this) >> i)); }
|
||||
QSpecialIntegerBitfield &operator<<=(T i) { return (*this = (T(*this) << i)); }
|
||||
};
|
||||
|
||||
template<typename T, int pos, int width>
|
||||
@ -136,7 +130,6 @@ using qint32_be_bitfield = QBEIntegerBitfield<int, pos, width>;
|
||||
template<int pos, int width>
|
||||
using quint32_be_bitfield = QBEIntegerBitfield<uint, pos, width>;
|
||||
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QENDIAN_P_H
|
||||
|
@ -3229,7 +3229,6 @@ QByteArray qgetenv(const char *varName)
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
\fn QString qEnvironmentVariable(const char *varName, const QString &defaultValue)
|
||||
\fn QString qEnvironmentVariable(const char *varName)
|
||||
@ -4024,7 +4023,8 @@ bool qunsetenv(const char *varName)
|
||||
with meaningful parameter names in their signatures.
|
||||
*/
|
||||
|
||||
struct QInternal_CallBackTable {
|
||||
struct QInternal_CallBackTable
|
||||
{
|
||||
QList<QList<qInternalCallback>> callbacks;
|
||||
};
|
||||
|
||||
@ -4046,7 +4046,7 @@ bool QInternal::unregisterCallback(Callback cb, qInternalCallback callback)
|
||||
if (unsigned(cb) < unsigned(QInternal::LastCallback)) {
|
||||
if (global_callback_table.exists()) {
|
||||
QInternal_CallBackTable *cbt = global_callback_table();
|
||||
return (bool) cbt->callbacks[cb].removeAll(callback);
|
||||
return cbt->callbacks[cb].removeAll(callback) > 0;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
@ -132,16 +132,28 @@ struct QGlobalStatic
|
||||
|
||||
bool isDestroyed() const { return guard.loadRelaxed() <= QtGlobalStatic::Destroyed; }
|
||||
bool exists() const { return guard.loadRelaxed() == QtGlobalStatic::Initialized; }
|
||||
operator Type *() { if (isDestroyed()) return nullptr; return innerFunction(); }
|
||||
Type *operator()() { if (isDestroyed()) return nullptr; return innerFunction(); }
|
||||
operator Type *()
|
||||
{
|
||||
if (isDestroyed())
|
||||
return nullptr;
|
||||
return innerFunction();
|
||||
}
|
||||
Type *operator()()
|
||||
{
|
||||
if (isDestroyed())
|
||||
return nullptr;
|
||||
return innerFunction();
|
||||
}
|
||||
Type *operator->()
|
||||
{
|
||||
Q_ASSERT_X(!isDestroyed(), "Q_GLOBAL_STATIC", "The global static was used after being destroyed");
|
||||
Q_ASSERT_X(!isDestroyed(), "Q_GLOBAL_STATIC",
|
||||
"The global static was used after being destroyed");
|
||||
return innerFunction();
|
||||
}
|
||||
Type &operator*()
|
||||
{
|
||||
Q_ASSERT_X(!isDestroyed(), "Q_GLOBAL_STATIC", "The global static was used after being destroyed");
|
||||
Q_ASSERT_X(!isDestroyed(), "Q_GLOBAL_STATIC",
|
||||
"The global static was used after being destroyed");
|
||||
return *innerFunction();
|
||||
}
|
||||
};
|
||||
|
@ -57,8 +57,7 @@ public:
|
||||
static QVersionNumber version() noexcept Q_DECL_CONST_FUNCTION;
|
||||
#endif
|
||||
|
||||
enum LibraryPath
|
||||
{
|
||||
enum LibraryPath {
|
||||
PrefixPath = 0,
|
||||
DocumentationPath,
|
||||
HeadersPath,
|
||||
|
@ -1069,8 +1069,8 @@ static const char emptyTokenC[] = "";
|
||||
|
||||
static const char defaultPattern[] = "%{if-category}%{category}: %{endif}%{message}";
|
||||
|
||||
|
||||
struct QMessagePattern {
|
||||
struct QMessagePattern
|
||||
{
|
||||
QMessagePattern();
|
||||
~QMessagePattern();
|
||||
|
||||
@ -1084,7 +1084,8 @@ struct QMessagePattern {
|
||||
QElapsedTimer timer;
|
||||
#endif
|
||||
#ifdef QLOGGING_HAVE_BACKTRACE
|
||||
struct BacktraceParams {
|
||||
struct BacktraceParams
|
||||
{
|
||||
QString backtraceSeparator;
|
||||
int backtraceDepth;
|
||||
};
|
||||
@ -1115,8 +1116,7 @@ QMessagePattern::QMessagePattern()
|
||||
}
|
||||
}
|
||||
|
||||
QMessagePattern::~QMessagePattern()
|
||||
= default;
|
||||
QMessagePattern::~QMessagePattern() = default;
|
||||
|
||||
void QMessagePattern::setPattern(const QString &pattern)
|
||||
{
|
||||
@ -1642,11 +1642,21 @@ static bool android_default_message_handler(QtMsgType type,
|
||||
|
||||
android_LogPriority priority = ANDROID_LOG_DEBUG;
|
||||
switch (type) {
|
||||
case QtDebugMsg: priority = ANDROID_LOG_DEBUG; break;
|
||||
case QtInfoMsg: priority = ANDROID_LOG_INFO; break;
|
||||
case QtWarningMsg: priority = ANDROID_LOG_WARN; break;
|
||||
case QtCriticalMsg: priority = ANDROID_LOG_ERROR; break;
|
||||
case QtFatalMsg: priority = ANDROID_LOG_FATAL; break;
|
||||
case QtDebugMsg:
|
||||
priority = ANDROID_LOG_DEBUG;
|
||||
break;
|
||||
case QtInfoMsg:
|
||||
priority = ANDROID_LOG_INFO;
|
||||
break;
|
||||
case QtWarningMsg:
|
||||
priority = ANDROID_LOG_WARN;
|
||||
break;
|
||||
case QtCriticalMsg:
|
||||
priority = ANDROID_LOG_ERROR;
|
||||
break;
|
||||
case QtFatalMsg:
|
||||
priority = ANDROID_LOG_FATAL;
|
||||
break;
|
||||
};
|
||||
|
||||
__android_log_print(priority, qPrintable(QCoreApplication::applicationName()), "%s\n", qPrintable(formattedMessage));
|
||||
|
@ -57,7 +57,14 @@ QT_BEGIN_NAMESPACE
|
||||
class QDebug;
|
||||
class QNoDebug;
|
||||
|
||||
enum QtMsgType { QtDebugMsg, QtWarningMsg, QtCriticalMsg, QtFatalMsg, QtInfoMsg, QtSystemMsg = QtCriticalMsg };
|
||||
enum QtMsgType {
|
||||
QtDebugMsg,
|
||||
QtWarningMsg,
|
||||
QtCriticalMsg,
|
||||
QtFatalMsg,
|
||||
QtInfoMsg,
|
||||
QtSystemMsg = QtCriticalMsg
|
||||
};
|
||||
|
||||
class QMessageLogContext
|
||||
{
|
||||
|
@ -112,4 +112,3 @@ void qFreeAligned(void *ptr)
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
|
@ -203,7 +203,8 @@ namespace {
|
||||
This function works for v containing infinities, but not NaN. It's the
|
||||
caller's responsibility to exclude that possibility before calling it.
|
||||
*/
|
||||
template <typename T> static inline bool convertDoubleTo(double v, T *value, bool allow_precision_upgrade = true)
|
||||
template<typename T>
|
||||
static inline bool convertDoubleTo(double v, T *value, bool allow_precision_upgrade = true)
|
||||
{
|
||||
static_assert(std::numeric_limits<T>::is_integer);
|
||||
|
||||
|
@ -181,7 +181,8 @@ struct QRandomGenerator::SystemGenerator
|
||||
|
||||
// For std::mersenne_twister_engine implementations that use something
|
||||
// other than quint32 (unsigned int) to fill their buffers.
|
||||
template <typename T> void generate(T *begin, T *end)
|
||||
template<typename T>
|
||||
void generate(T *begin, T *end)
|
||||
{
|
||||
static_assert(sizeof(T) >= sizeof(quint32));
|
||||
if (sizeof(T) == sizeof(quint32)) {
|
||||
@ -414,7 +415,8 @@ struct QRandomGenerator::SystemAndGlobalGenerators
|
||||
new (&rng->storage.engine()) RandomEngine(self()->sys);
|
||||
}
|
||||
|
||||
struct PRNGLocker {
|
||||
struct PRNGLocker
|
||||
{
|
||||
const bool locked;
|
||||
PRNGLocker(const QRandomGenerator *that)
|
||||
: locked(that == globalNoInit())
|
||||
|
@ -76,13 +76,12 @@ Q_CORE_EXPORT QBasicAtomicInteger<uint> qt_randomdevice_control = Q_BASIC_ATOMIC
|
||||
#elif defined(QT_BUILD_INTERNAL)
|
||||
extern Q_CORE_EXPORT QBasicAtomicInteger<uint> qt_randomdevice_control;
|
||||
#else
|
||||
static const struct {
|
||||
static const struct
|
||||
{
|
||||
uint loadAcquire() const { return 0; }
|
||||
} qt_randomdevice_control;
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QRANDOM_P_H
|
||||
|
@ -428,19 +428,22 @@ static quint64 detectProcessorFeatures()
|
||||
// QSimpleBuffer, which has the bare minimum needed to use memory
|
||||
// dynamically and read lines from /proc/cpuinfo of arbitrary sizes.
|
||||
//
|
||||
struct QSimpleBuffer {
|
||||
struct QSimpleBuffer
|
||||
{
|
||||
static const int chunk_size = 256;
|
||||
char *data;
|
||||
unsigned alloc;
|
||||
unsigned size;
|
||||
|
||||
QSimpleBuffer(): data(0), alloc(0), size(0) {}
|
||||
QSimpleBuffer() : data(nullptr), alloc(0), size(0) { }
|
||||
~QSimpleBuffer() { ::free(data); }
|
||||
|
||||
void resize(unsigned newsize) {
|
||||
void resize(unsigned newsize)
|
||||
{
|
||||
if (newsize > alloc) {
|
||||
unsigned newalloc = chunk_size * ((newsize / chunk_size) + 1);
|
||||
if (newalloc < newsize) newalloc = newsize;
|
||||
if (newalloc < newsize)
|
||||
newalloc = newsize;
|
||||
if (newalloc != alloc) {
|
||||
data = static_cast<char *>(::realloc(data, newalloc));
|
||||
alloc = newalloc;
|
||||
@ -448,18 +451,23 @@ struct QSimpleBuffer {
|
||||
}
|
||||
size = newsize;
|
||||
}
|
||||
void append(const QSimpleBuffer &other, unsigned appendsize) {
|
||||
void append(const QSimpleBuffer &other, unsigned appendsize)
|
||||
{
|
||||
unsigned oldsize = size;
|
||||
resize(oldsize + appendsize);
|
||||
::memcpy(data + oldsize, other.data, appendsize);
|
||||
}
|
||||
void popleft(unsigned amount) {
|
||||
if (amount >= size) return resize(0);
|
||||
void popleft(unsigned amount)
|
||||
{
|
||||
if (amount >= size)
|
||||
return resize(0);
|
||||
size -= amount;
|
||||
::memmove(data, data + amount, size);
|
||||
}
|
||||
char* cString() {
|
||||
if (!alloc) resize(1);
|
||||
char *cString()
|
||||
{
|
||||
if (!alloc)
|
||||
resize(1);
|
||||
return (data[size] = '\0', data);
|
||||
}
|
||||
};
|
||||
@ -486,9 +494,12 @@ static void bufReadLine(int fd, QSimpleBuffer &line, QSimpleBuffer &buffer)
|
||||
buffer.resize(buffer.size + QSimpleBuffer::chunk_size);
|
||||
buffer.size = oldsize;
|
||||
}
|
||||
ssize_t read_bytes = ::qt_safe_read(fd, buffer.data + buffer.size, QSimpleBuffer::chunk_size);
|
||||
if (read_bytes > 0) buffer.size += read_bytes;
|
||||
else return;
|
||||
ssize_t read_bytes =
|
||||
::qt_safe_read(fd, buffer.data + buffer.size, QSimpleBuffer::chunk_size);
|
||||
if (read_bytes > 0)
|
||||
buffer.size += read_bytes;
|
||||
else
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -50,7 +50,8 @@ QT_BEGIN_NAMESPACE
|
||||
*/
|
||||
|
||||
class QString;
|
||||
class Q_CORE_EXPORT QSysInfo {
|
||||
class Q_CORE_EXPORT QSysInfo
|
||||
{
|
||||
public:
|
||||
enum Sizes {
|
||||
WordSize = (sizeof(void *)<<3)
|
||||
|
Loading…
x
Reference in New Issue
Block a user