Commit 138a7b50 authored by Daniel Vrátil's avatar Daniel Vrátil 🤖

Fix Protocol build in some environments

Apparently the compiler on CI is less strict about ADL when it
comes to overloaded operator<< of namespaced classes. This is an
attempt to fix it.
parent e1d6e967
......@@ -46,8 +46,8 @@ inline const Class##Private* Class::d_func() const {\
#define COMPARE(prop) \
(prop == ((decltype(this)) other)->prop)
using namespace Akonadi;
using namespace Akonadi::Protocol;
namespace Akonadi {
namespace Protocol {
QDebug operator<<(QDebug _dbg, Command::Type type)
{
......@@ -819,6 +819,10 @@ QDebug operator<<(QDebug _dbg, const ChangeNotification::Relation &rel)
return dbg << "Left: " << rel.leftId << ", Right:" << rel.rightId << ", Type: " << rel.type;
}
} // namespace Protocol
} // namespace Akonadi
/******************************************************************************/
// Here comes the generated protocol implementation
......
......@@ -62,12 +62,15 @@ class FetchScope;
class ScopeContext;
class ChangeNotification;
using CommandPtr = QSharedPointer<Command>;
using Attributes = QMap<QByteArray, QByteArray>;
} // namespace Protocol
} // namespace Akonadi
namespace Akonadi {
namespace Protocol {
AKONADIPRIVATE_EXPORT Akonadi::Protocol::DataStream &operator<<(
Akonadi::Protocol::DataStream &stream,
const Akonadi::Protocol::Command &cmd);
......@@ -76,8 +79,7 @@ AKONADIPRIVATE_EXPORT Akonadi::Protocol::DataStream &operator>>(
Akonadi::Protocol::Command &cmd);
AKONADIPRIVATE_EXPORT QDebug operator<<(QDebug dbg, const Akonadi::Protocol::Command &cmd);
namespace Akonadi {
namespace Protocol {
using CommandPtr = QSharedPointer<Command>;
class AKONADIPRIVATE_EXPORT Command
{
......@@ -168,11 +170,11 @@ protected:
private:
friend class Factory;
friend Akonadi::Protocol::DataStream &::operator<<(Akonadi::Protocol::DataStream &stream,
friend Akonadi::Protocol::DataStream &operator<<(Akonadi::Protocol::DataStream &stream,
const Akonadi::Protocol::Command &cmd);
friend Akonadi::Protocol::DataStream &::operator>>(Akonadi::Protocol::DataStream &stream,
friend Akonadi::Protocol::DataStream &operator>>(Akonadi::Protocol::DataStream &stream,
Akonadi::Protocol::Command &cmd);
friend QDebug (::operator<<(::QDebug dbg, const Akonadi::Protocol::Command &cmd));
friend QDebug operator<<(::QDebug dbg, const Akonadi::Protocol::Command &cmd);
};
} // namespace Protocol
......@@ -182,6 +184,9 @@ Q_DECLARE_METATYPE(Akonadi::Protocol::Command::Type)
Q_DECLARE_METATYPE(Akonadi::Protocol::CommandPtr)
namespace Akonadi {
namespace Protocol {
AKONADIPRIVATE_EXPORT Akonadi::Protocol::DataStream &operator<<(
Akonadi::Protocol::DataStream &stream,
const Akonadi::Protocol::Response &cmd);
......@@ -190,8 +195,6 @@ AKONADIPRIVATE_EXPORT Akonadi::Protocol::DataStream &operator>>(
Akonadi::Protocol::Response &cmd);
AKONADIPRIVATE_EXPORT QDebug operator<<(QDebug dbg, const Akonadi::Protocol::Response &response);
namespace Akonadi {
namespace Protocol {
using ResponsePtr = QSharedPointer<Response>;
......@@ -224,11 +227,11 @@ protected:
private:
friend class Factory;
friend Akonadi::Protocol::DataStream &::operator<<(Akonadi::Protocol::DataStream &stream,
friend Akonadi::Protocol::DataStream &operator<<(Akonadi::Protocol::DataStream &stream,
const Akonadi::Protocol::Response &cmd);
friend Akonadi::Protocol::DataStream &::operator>>(Akonadi::Protocol::DataStream &stream,
friend Akonadi::Protocol::DataStream &operator>>(Akonadi::Protocol::DataStream &stream,
Akonadi::Protocol::Response &cmd);
friend QDebug (::operator<<(QDebug dbg, const Akonadi::Protocol::Response &cmd));
friend QDebug operator<<(QDebug dbg, const Akonadi::Protocol::Response &cmd);
};
} // namespace Protocol
......@@ -274,6 +277,8 @@ AKONADIPRIVATE_EXPORT inline QString debugString(const CommandPtr &command)
} // namespace Akonadi
namespace Akonadi {
namespace Protocol {
AKONADIPRIVATE_EXPORT Akonadi::Protocol::DataStream &operator<<(
Akonadi::Protocol::DataStream &stream,
......@@ -283,8 +288,6 @@ AKONADIPRIVATE_EXPORT Akonadi::Protocol::DataStream &operator>>(
Akonadi::Protocol::FetchScope &scope);
AKONADIPRIVATE_EXPORT QDebug operator<<(QDebug dbg, const Akonadi::Protocol::FetchScope &scope);
namespace Akonadi {
namespace Protocol {
class AKONADIPRIVATE_EXPORT FetchScope
{
......@@ -365,11 +368,11 @@ private:
QDateTime mChangedSince;
QSet<QByteArray> mTagFetchScope;
friend Akonadi::Protocol::DataStream &::operator<<(Akonadi::Protocol::DataStream &stream,
friend Akonadi::Protocol::DataStream &operator<<(Akonadi::Protocol::DataStream &stream,
const Akonadi::Protocol::FetchScope &scope);
friend Akonadi::Protocol::DataStream &::operator>>(Akonadi::Protocol::DataStream &stream,
friend Akonadi::Protocol::DataStream &operator>>(Akonadi::Protocol::DataStream &stream,
Akonadi::Protocol::FetchScope &scope);
friend QDebug (::operator<<(QDebug dbg, const Akonadi::Protocol::FetchScope &scope));
friend QDebug operator<<(QDebug dbg, const Akonadi::Protocol::FetchScope &scope);
};
} // namespace Protocol
......@@ -377,6 +380,8 @@ private:
Q_DECLARE_OPERATORS_FOR_FLAGS(Akonadi::Protocol::FetchScope::FetchFlags)
namespace Akonadi {
namespace Protocol {
AKONADIPRIVATE_EXPORT Akonadi::Protocol::DataStream &operator<<(
Akonadi::Protocol::DataStream &stream,
......@@ -386,9 +391,6 @@ AKONADIPRIVATE_EXPORT Akonadi::Protocol::DataStream &operator>>(
Akonadi::Protocol::ScopeContext &ctx);
AKONADIPRIVATE_EXPORT QDebug operator<<(QDebug dbg, const Akonadi::Protocol::ScopeContext &ctx);
namespace Akonadi {
namespace Protocol {
class AKONADIPRIVATE_EXPORT ScopeContext
{
public:
......@@ -454,17 +456,20 @@ private:
}
}
friend Akonadi::Protocol::DataStream &::operator<<(Akonadi::Protocol::DataStream &stream,
friend Akonadi::Protocol::DataStream &operator<<(Akonadi::Protocol::DataStream &stream,
const Akonadi::Protocol::ScopeContext &context);
friend Akonadi::Protocol::DataStream &::operator>>(Akonadi::Protocol::DataStream &stream,
friend Akonadi::Protocol::DataStream &operator>>(Akonadi::Protocol::DataStream &stream,
Akonadi::Protocol::ScopeContext &context);
friend QDebug (::operator<<(QDebug dbg, const Akonadi::Protocol::ScopeContext &ctx));
friend QDebug operator<<(QDebug dbg, const Akonadi::Protocol::ScopeContext &ctx);
};
} // namespace Protocol
} // namespace akonadi
namespace Akonadi {
namespace Protocol {
AKONADIPRIVATE_EXPORT Akonadi::Protocol::DataStream &operator<<(
Akonadi::Protocol::DataStream &stream,
const Akonadi::Protocol::ChangeNotification &ntf);
......@@ -473,9 +478,6 @@ AKONADIPRIVATE_EXPORT Akonadi::Protocol::DataStream &operator>>(
Akonadi::Protocol::ChangeNotification &ntf);
AKONADIPRIVATE_EXPORT QDebug operator<<(QDebug dbg, const Akonadi::Protocol::ChangeNotification &ntf);
namespace Akonadi {
namespace Protocol {
using ChangeNotificationPtr = QSharedPointer<ChangeNotification>;
using ChangeNotificationList = QVector<ChangeNotificationPtr>;
......@@ -574,11 +576,11 @@ protected:
// it is never transferred to clients
QVector<QByteArray> mMetaData;
friend Akonadi::Protocol::DataStream &::operator<<(Akonadi::Protocol::DataStream &stream,
friend Akonadi::Protocol::DataStream &operator<<(Akonadi::Protocol::DataStream &stream,
const Akonadi::Protocol::ChangeNotification &ntf);
friend Akonadi::Protocol::DataStream &::operator>>(Akonadi::Protocol::DataStream &stream,
friend Akonadi::Protocol::DataStream &operator>>(Akonadi::Protocol::DataStream &stream,
Akonadi::Protocol::ChangeNotification &ntf);
friend QDebug (::operator<<(QDebug dbg, const Akonadi::Protocol::ChangeNotification &ntf));
friend QDebug operator<<(QDebug dbg, const Akonadi::Protocol::ChangeNotification &ntf);
};
inline uint qHash(const ChangeNotification::Relation &rel)
......@@ -586,8 +588,6 @@ inline uint qHash(const ChangeNotification::Relation &rel)
return ::qHash(rel.leftId + rel.rightId);
}
} // namespace Protocol
} // namespace Akonadi
// TODO: Internalize?
......@@ -603,12 +603,15 @@ AKONADIPRIVATE_EXPORT Akonadi::Protocol::DataStream &operator>>(
Akonadi::Protocol::DataStream &stream,
Akonadi::Protocol::ChangeNotification::Relation &relation);
} // namespace Protocol
} // namespace Akonadi
Q_DECLARE_METATYPE(Akonadi::Protocol::ChangeNotificationPtr)
Q_DECLARE_METATYPE(Akonadi::Protocol::ChangeNotificationList)
/******************************************************************************/
// Here comes the actual generated Protocol. See protocol.xml for definitions,
// and genprotocol folder for the generator.
#include "protocol_gen.h"
......
......@@ -95,15 +95,13 @@ void CppGenerator::writeImplHeader(DocumentNode const *node)
"{\n"
" return " << node->version() << ";\n"
"}\n"
"\n"
"} // namespace Protocol\n"
"} // namespace Akonadi\n"
"\n";
}
void CppGenerator::writeImplFooter(DocumentNode const *)
{
// nothing
mImpl << "} // namespace Protocol\n"
"} // namespace Akonadi\n";
}
......@@ -128,7 +126,7 @@ bool CppGenerator::generateDocument(DocumentNode const *node)
void CppGenerator::writeImplSerializer(DocumentNode const *node)
{
mImpl << "void Protocol::serialize(QIODevice *device, const CommandPtr &cmd)\n"
mImpl << "void serialize(QIODevice *device, const CommandPtr &cmd)\n"
"{\n"
" DataStream stream(device);\n"
" switch (static_cast<int>(cmd->type() | (cmd->isResponse() ? Command::_ResponseBit : 0))) {\n"
......@@ -157,7 +155,7 @@ void CppGenerator::writeImplSerializer(DocumentNode const *node)
mImpl << " }\n"
"}\n\n";
mImpl << "CommandPtr Protocol::deserialize(QIODevice *device)\n"
mImpl << "CommandPtr deserialize(QIODevice *device)\n"
"{\n"
" DataStream stream(device);\n"
" stream.waitForData(sizeof(Command::Type));\n"
......@@ -200,7 +198,7 @@ void CppGenerator::writeImplSerializer(DocumentNode const *node)
"\n";
mImpl << "QString Protocol::debugString(const Command &cmd)\n"
mImpl << "QString debugString(const Command &cmd)\n"
"{\n"
" QString out;\n"
" switch (static_cast<int>(cmd.type() | (cmd.isResponse() ? Command::_ResponseBit : 0))) {\n"
......@@ -257,17 +255,11 @@ void CppGenerator::writeHeaderClass(ClassNode const *node)
const QString parentClass = node->parentClassName();
const bool isTypeClass = node->classType() == ClassNode::Class;
mHeader << "AKONADIPRIVATE_EXPORT Akonadi::Protocol::DataStream &operator<<(\n"
" Akonadi::Protocol::DataStream &stream,\n"
" const Akonadi::Protocol::" << node->className() << " &obj);\n"
"AKONADIPRIVATE_EXPORT Akonadi::Protocol::DataStream &operator>>(\n"
" Akonadi::Protocol::DataStream &stream,\n"
" Akonadi::Protocol::" << node->className() << " &obj);\n"
"AKONADIPRIVATE_EXPORT QDebug operator<<(QDebug dbg,\n"
" const Akonadi::Protocol::" << node->className() << " &obj);\n"
"\n"
"namespace Akonadi {\n"
"namespace Protocol {\n"
mHeader << "namespace Akonadi {\n"
"namespace Protocol {\n\n"
"AKONADIPRIVATE_EXPORT DataStream &operator<<(DataStream &stream, const " << node->className() << " &obj);\n"
"AKONADIPRIVATE_EXPORT DataStream &operator>>(DataStream &stream, " << node->className() << " &obj);\n"
"AKONADIPRIVATE_EXPORT QDebug operator<<(QDebug dbg, const " << node->className() << " &obj);\n"
"\n"
"using " << node->className() << "Ptr = QSharedPointer<" << node->className() << ">;\n"
"\n";
......@@ -349,9 +341,9 @@ void CppGenerator::writeHeaderClass(ClassNode const *node)
mHeader << "\n"
"private:\n"
" friend Akonadi::Protocol::DataStream &::operator<<(Akonadi::Protocol::DataStream &stream, const Akonadi::Protocol::" << node->className() << " &obj);\n"
" friend Akonadi::Protocol::DataStream &::operator>>(Akonadi::Protocol::DataStream &stream, Akonadi::Protocol::" << node->className() << " &obj);\n"
" friend QDebug (::operator<<(QDebug dbg, const Akonadi::Protocol::" << node->className() << " &obj));\n"
" friend Akonadi::Protocol::DataStream &operator<<(Akonadi::Protocol::DataStream &stream, const Akonadi::Protocol::" << node->className() << " &obj);\n"
" friend Akonadi::Protocol::DataStream &operator>>(Akonadi::Protocol::DataStream &stream, Akonadi::Protocol::" << node->className() << " &obj);\n"
" friend QDebug operator<<(QDebug dbg, const Akonadi::Protocol::" << node->className() << " &obj);\n"
"};\n\n"
"} // namespace Protocol\n"
"} // namespace Akonadi\n"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment