I really wonder what I had in mind when I put QStrings everywhere...
Of course SODEP says nothing about encoding so it's really byte arrays that we send/receive. MetaService being higher level I'll assume UTF8 encoding though (it's apparently what it's using. svn path=/branches/work/~ervin/qtjolie/; revision=975435
This commit is contained in:
parent
214c0348a3
commit
177be5f6af
@ -3,7 +3,7 @@ include(KDE4Defaults)
|
|||||||
include(MacroLibrary)
|
include(MacroLibrary)
|
||||||
|
|
||||||
add_definitions(${QT_DEFINITIONS} ${KDE4_DEFINITIONS})
|
add_definitions(${QT_DEFINITIONS} ${KDE4_DEFINITIONS})
|
||||||
#include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ${KDE4_INCLUDES})
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DQT_NO_CAST_FROM_ASCII -DQT_NO_CAST_TO_ASCII")
|
||||||
|
|
||||||
add_subdirectory(qtjolie)
|
add_subdirectory(qtjolie)
|
||||||
add_subdirectory(includes)
|
add_subdirectory(includes)
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
|
|
||||||
#include "fault.h"
|
#include "fault.h"
|
||||||
|
|
||||||
#include <QtCore/QString>
|
#include <QtCore/QByteArray>
|
||||||
|
|
||||||
#include "sodephelpers_p.h"
|
#include "sodephelpers_p.h"
|
||||||
|
|
||||||
@ -30,7 +30,7 @@ namespace Jolie
|
|||||||
class FaultPrivate
|
class FaultPrivate
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
QString name;
|
QByteArray name;
|
||||||
Value data;
|
Value data;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -44,7 +44,7 @@ Fault::Fault()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Fault::Fault(const QString &name, const Value &data)
|
Fault::Fault(const QByteArray &name, const Value &data)
|
||||||
: d(new FaultPrivate)
|
: d(new FaultPrivate)
|
||||||
{
|
{
|
||||||
d->name = name;
|
d->name = name;
|
||||||
@ -69,7 +69,7 @@ Fault &Fault::operator=(const Fault &other)
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Fault::name() const
|
QByteArray Fault::name() const
|
||||||
{
|
{
|
||||||
return d->name;
|
return d->name;
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@ class Q_DECL_EXPORT Fault
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Fault();
|
Fault();
|
||||||
explicit Fault(const QString &name, const Value &data = Value());
|
explicit Fault(const QByteArray &name, const Value &data = Value());
|
||||||
|
|
||||||
Fault(const Fault &other);
|
Fault(const Fault &other);
|
||||||
|
|
||||||
@ -39,7 +39,7 @@ public:
|
|||||||
|
|
||||||
Fault &operator=(const Fault &other);
|
Fault &operator=(const Fault &other);
|
||||||
|
|
||||||
QString name() const;
|
QByteArray name() const;
|
||||||
Value data() const;
|
Value data() const;
|
||||||
|
|
||||||
bool isValid() const;
|
bool isValid() const;
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
|
|
||||||
#include "message.h"
|
#include "message.h"
|
||||||
|
|
||||||
#include <QtCore/QString>
|
#include <QtCore/QByteArray>
|
||||||
|
|
||||||
#include "sodephelpers_p.h"
|
#include "sodephelpers_p.h"
|
||||||
|
|
||||||
@ -33,8 +33,8 @@ public:
|
|||||||
MessagePrivate() : id(0) {}
|
MessagePrivate() : id(0) {}
|
||||||
|
|
||||||
qint64 id;
|
qint64 id;
|
||||||
QString resourcePath;
|
QByteArray resourcePath;
|
||||||
QString operationName;
|
QByteArray operationName;
|
||||||
Fault fault;
|
Fault fault;
|
||||||
Value data;
|
Value data;
|
||||||
};
|
};
|
||||||
@ -48,7 +48,7 @@ Message::Message()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
Message::Message(const QString &resourcePath, const QString &operationName, qint64 id)
|
Message::Message(const QByteArray &resourcePath, const QByteArray &operationName, qint64 id)
|
||||||
: d(new MessagePrivate)
|
: d(new MessagePrivate)
|
||||||
{
|
{
|
||||||
static qint64 lastId = 0;
|
static qint64 lastId = 0;
|
||||||
@ -85,12 +85,12 @@ qint64 Message::id() const
|
|||||||
return d->id;
|
return d->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Message::resourcePath() const
|
QByteArray Message::resourcePath() const
|
||||||
{
|
{
|
||||||
return d->resourcePath;
|
return d->resourcePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Message::operationName() const
|
QByteArray Message::operationName() const
|
||||||
{
|
{
|
||||||
return d->operationName;
|
return d->operationName;
|
||||||
}
|
}
|
||||||
|
@ -32,9 +32,9 @@ class Q_DECL_EXPORT Message
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Message();
|
Message();
|
||||||
explicit Message(const QString &resourcePath,
|
explicit Message(const QByteArray &resourcePath,
|
||||||
const QString &operationName,
|
const QByteArray &operationName,
|
||||||
qint64 id = 0);
|
qint64 id = 0);
|
||||||
Message(const Message &other);
|
Message(const Message &other);
|
||||||
~Message();
|
~Message();
|
||||||
|
|
||||||
@ -42,8 +42,8 @@ public:
|
|||||||
|
|
||||||
qint64 id() const;
|
qint64 id() const;
|
||||||
|
|
||||||
QString resourcePath() const;
|
QByteArray resourcePath() const;
|
||||||
QString operationName() const;
|
QByteArray operationName() const;
|
||||||
|
|
||||||
Fault fault() const;
|
Fault fault() const;
|
||||||
void setFault(const Fault &fault);
|
void setFault(const Fault &fault);
|
||||||
|
@ -50,13 +50,13 @@ MetaService::~MetaService()
|
|||||||
|
|
||||||
bool MetaService::start()
|
bool MetaService::start()
|
||||||
{
|
{
|
||||||
d->metaserviceProcess.start("metaservice");
|
d->metaserviceProcess.start(QString::fromUtf8("metaservice"));
|
||||||
return d->metaserviceProcess.waitForStarted();
|
return d->metaserviceProcess.waitForStarted();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MetaService::stop()
|
bool MetaService::stop()
|
||||||
{
|
{
|
||||||
Client client("localhost", 9000);
|
Client client(QString::fromUtf8("localhost"), 9000);
|
||||||
Message message("/", "shutdown");
|
Message message("/", "shutdown");
|
||||||
client.callNoReply(message);
|
client.callNoReply(message);
|
||||||
return d->metaserviceProcess.waitForFinished(30000);
|
return d->metaserviceProcess.waitForFinished(30000);
|
||||||
@ -69,20 +69,20 @@ bool MetaService::isRunning() const
|
|||||||
|
|
||||||
QString MetaService::loadService(const QString &name, const QString &fileName)
|
QString MetaService::loadService(const QString &name, const QString &fileName)
|
||||||
{
|
{
|
||||||
Client client("localhost", 9000);
|
Client client(QString::fromUtf8("localhost"), 9000);
|
||||||
Message message("/", "loadEmbeddedJolieService");
|
Message message("/", "loadEmbeddedJolieService");
|
||||||
Value value;
|
Value value;
|
||||||
value.children("resourcePrefix") << Value(name);
|
value.children("resourcePrefix") << Value(name.toUtf8());
|
||||||
value.children("filepath") << Value(fileName);
|
value.children("filepath") << Value(fileName.toUtf8());
|
||||||
message.setData(value);
|
message.setData(value);
|
||||||
|
|
||||||
Message reply = client.call(message);
|
Message reply = client.call(message);
|
||||||
return reply.data().toString();
|
return QString::fromUtf8(reply.data().toByteArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList MetaService::loadedServices() const
|
QStringList MetaService::loadedServices() const
|
||||||
{
|
{
|
||||||
Client client("localhost", 9000);
|
Client client(QString::fromUtf8("localhost"), 9000);
|
||||||
Message message("/", "getServices");
|
Message message("/", "getServices");
|
||||||
|
|
||||||
Message reply = client.call(message);
|
Message reply = client.call(message);
|
||||||
@ -90,7 +90,7 @@ QStringList MetaService::loadedServices() const
|
|||||||
|
|
||||||
QStringList result;
|
QStringList result;
|
||||||
foreach (const Value &service, services) {
|
foreach (const Value &service, services) {
|
||||||
result << service.children("resourceName").first().toString();
|
result << QString::fromUtf8(service.children("resourceName").first().toByteArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
@ -98,9 +98,9 @@ QStringList MetaService::loadedServices() const
|
|||||||
|
|
||||||
void MetaService::unloadService(const QString &name)
|
void MetaService::unloadService(const QString &name)
|
||||||
{
|
{
|
||||||
Client client("localhost", 9000);
|
Client client(QString::fromUtf8("localhost"), 9000);
|
||||||
Message message("/", "unloadEmbeddedService");
|
Message message("/", "unloadEmbeddedService");
|
||||||
message.setData(Value(name));
|
message.setData(Value(name.toUtf8()));
|
||||||
|
|
||||||
client.call(message);
|
client.call(message);
|
||||||
}
|
}
|
||||||
|
@ -22,8 +22,7 @@
|
|||||||
#define QTJOLIE_SODEPHELPERS_P_H
|
#define QTJOLIE_SODEPHELPERS_P_H
|
||||||
|
|
||||||
#include <QtCore/QIODevice>
|
#include <QtCore/QIODevice>
|
||||||
#include <QtCore/QString>
|
#include <QtCore/QByteArray>
|
||||||
#include <QtCore/QStringList>
|
|
||||||
|
|
||||||
#include "value.h"
|
#include "value.h"
|
||||||
#include "fault.h"
|
#include "fault.h"
|
||||||
@ -68,11 +67,10 @@ inline void sodepWrite(QIODevice &io, qint64 value)
|
|||||||
io.write(out, 8);
|
io.write(out, 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void sodepWrite(QIODevice &io, const QString &value)
|
inline void sodepWrite(QIODevice &io, const QByteArray &value)
|
||||||
{
|
{
|
||||||
QByteArray data = value.toUtf8();
|
sodepWrite(io, value.size());
|
||||||
sodepWrite(io, data.size());
|
io.write(value);
|
||||||
io.write(data);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void sodepWrite(QIODevice &io, const Value &value)
|
inline void sodepWrite(QIODevice &io, const Value &value)
|
||||||
@ -83,16 +81,16 @@ inline void sodepWrite(QIODevice &io, const Value &value)
|
|||||||
} else if (value.isInt()) {
|
} else if (value.isInt()) {
|
||||||
io.putChar(2);
|
io.putChar(2);
|
||||||
sodepWrite(io, value.toInt());
|
sodepWrite(io, value.toInt());
|
||||||
} else if (value.isString()) {
|
} else if (value.isByteArray()) {
|
||||||
io.putChar(1);
|
io.putChar(1);
|
||||||
sodepWrite(io, value.toString());
|
sodepWrite(io, value.toByteArray());
|
||||||
} else {
|
} else {
|
||||||
io.putChar(0);
|
io.putChar(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
sodepWrite(io, value.childrenNames().size());
|
sodepWrite(io, value.childrenNames().size());
|
||||||
|
|
||||||
foreach (const QString &name, value.childrenNames()) {
|
foreach (const QByteArray &name, value.childrenNames()) {
|
||||||
sodepWrite(io, name);
|
sodepWrite(io, name);
|
||||||
|
|
||||||
QList<Value> values = value.children(name);
|
QList<Value> values = value.children(name);
|
||||||
@ -183,7 +181,7 @@ inline qint64 sodepReadInt64(QIODevice &io)
|
|||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline QString sodepReadString(QIODevice &io)
|
inline QByteArray sodepReadByteArray(QIODevice &io)
|
||||||
{
|
{
|
||||||
qint32 length = sodepReadInt32(io);
|
qint32 length = sodepReadInt32(io);
|
||||||
|
|
||||||
@ -195,7 +193,7 @@ inline QString sodepReadString(QIODevice &io)
|
|||||||
io.read(data, length);
|
io.read(data, length);
|
||||||
data[length] = '\0';
|
data[length] = '\0';
|
||||||
|
|
||||||
QString result = QString::fromUtf8(data);
|
QByteArray result(data);
|
||||||
delete[] data;
|
delete[] data;
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
@ -222,7 +220,7 @@ inline Value sodepReadValue(QIODevice &io)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 1: {
|
case 1: {
|
||||||
result = Value(sodepReadString(io));
|
result = Value(sodepReadByteArray(io));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
@ -232,7 +230,7 @@ inline Value sodepReadValue(QIODevice &io)
|
|||||||
qint32 childrenCount = sodepReadInt32(io);
|
qint32 childrenCount = sodepReadInt32(io);
|
||||||
|
|
||||||
for (int i=0; i<childrenCount; ++i) {
|
for (int i=0; i<childrenCount; ++i) {
|
||||||
QString name = sodepReadString(io);
|
QByteArray name = sodepReadByteArray(io);
|
||||||
|
|
||||||
qint32 valueCount = sodepReadInt32(io);
|
qint32 valueCount = sodepReadInt32(io);
|
||||||
for (int j=0; j<valueCount; ++j) {
|
for (int j=0; j<valueCount; ++j) {
|
||||||
@ -256,7 +254,7 @@ inline Fault sodepReadFault(QIODevice &io)
|
|||||||
return Fault();
|
return Fault();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString name = sodepReadString(io);
|
QByteArray name = sodepReadByteArray(io);
|
||||||
Value data = sodepReadValue(io);
|
Value data = sodepReadValue(io);
|
||||||
|
|
||||||
return Fault(name, data);
|
return Fault(name, data);
|
||||||
@ -265,8 +263,8 @@ inline Fault sodepReadFault(QIODevice &io)
|
|||||||
inline Message sodepReadMessage(QIODevice &io)
|
inline Message sodepReadMessage(QIODevice &io)
|
||||||
{
|
{
|
||||||
qint64 id = sodepReadInt64(io);
|
qint64 id = sodepReadInt64(io);
|
||||||
QString resourcePath = sodepReadString(io);
|
QByteArray resourcePath = sodepReadByteArray(io);
|
||||||
QString operationName = sodepReadString(io);
|
QByteArray operationName = sodepReadByteArray(io);
|
||||||
|
|
||||||
Message result(resourcePath, operationName, id);
|
Message result(resourcePath, operationName, id);
|
||||||
|
|
||||||
|
@ -20,7 +20,6 @@
|
|||||||
|
|
||||||
#include "value.h"
|
#include "value.h"
|
||||||
|
|
||||||
#include <QtCore/QStringList>
|
|
||||||
#include <QtCore/QVariant>
|
#include <QtCore/QVariant>
|
||||||
|
|
||||||
#include "sodephelpers_p.h"
|
#include "sodephelpers_p.h"
|
||||||
@ -32,7 +31,7 @@ class ValuePrivate
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
QVariant content;
|
QVariant content;
|
||||||
QMap<QString, QList<Value> > children;
|
QMap<QByteArray, QList<Value> > children;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Jolie
|
} // namespace Jolie
|
||||||
@ -44,7 +43,7 @@ Value::Value()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
Value::Value(const QString &content)
|
Value::Value(const QByteArray &content)
|
||||||
: d(new ValuePrivate)
|
: d(new ValuePrivate)
|
||||||
{
|
{
|
||||||
d->content = content;
|
d->content = content;
|
||||||
@ -80,27 +79,27 @@ Value &Value::operator=(const Value &other)
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList Value::childrenNames() const
|
QList<QByteArray> Value::childrenNames() const
|
||||||
{
|
{
|
||||||
return d->children.keys();
|
return d->children.keys();
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<Value> & Value::children(const QString &name)
|
QList<Value> & Value::children(const QByteArray &name)
|
||||||
{
|
{
|
||||||
return d->children[name];
|
return d->children[name];
|
||||||
}
|
}
|
||||||
|
|
||||||
const QList<Value> & Value::children(const QString &name) const
|
const QList<Value> & Value::children(const QByteArray &name) const
|
||||||
{
|
{
|
||||||
return d->children[name];
|
return d->children[name];
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Value::toString() const
|
QByteArray Value::toByteArray() const
|
||||||
{
|
{
|
||||||
if (isString()) {
|
if (isByteArray()) {
|
||||||
return d->content.toString();
|
return d->content.toByteArray();
|
||||||
} else {
|
} else {
|
||||||
return QString();
|
return QByteArray();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -122,9 +121,9 @@ double Value::toDouble() const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Value::isString() const
|
bool Value::isByteArray() const
|
||||||
{
|
{
|
||||||
return d->content.type()==QVariant::String;
|
return d->content.type()==QVariant::ByteArray;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Value::isInt() const
|
bool Value::isInt() const
|
||||||
@ -139,6 +138,6 @@ bool Value::isDouble() const
|
|||||||
|
|
||||||
bool Value::isValid() const
|
bool Value::isValid() const
|
||||||
{
|
{
|
||||||
return isString() || isInt() || isDouble();
|
return isByteArray() || isInt() || isDouble();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ class Q_DECL_EXPORT Value
|
|||||||
public:
|
public:
|
||||||
Value();
|
Value();
|
||||||
|
|
||||||
explicit Value(const QString &content);
|
explicit Value(const QByteArray &content);
|
||||||
explicit Value(qint32 content);
|
explicit Value(qint32 content);
|
||||||
explicit Value(double content);
|
explicit Value(double content);
|
||||||
|
|
||||||
@ -43,15 +43,15 @@ public:
|
|||||||
|
|
||||||
Value &operator=(const Value &other);
|
Value &operator=(const Value &other);
|
||||||
|
|
||||||
QStringList childrenNames() const;
|
QList<QByteArray> childrenNames() const;
|
||||||
QList<Value> &children(const QString &name);
|
QList<Value> &children(const QByteArray &name);
|
||||||
const QList<Value> &children(const QString &name) const;
|
const QList<Value> &children(const QByteArray &name) const;
|
||||||
|
|
||||||
QString toString() const;
|
QByteArray toByteArray() const;
|
||||||
qint32 toInt() const;
|
qint32 toInt() const;
|
||||||
double toDouble() const;
|
double toDouble() const;
|
||||||
|
|
||||||
bool isString() const;
|
bool isByteArray() const;
|
||||||
bool isInt() const;
|
bool isInt() const;
|
||||||
bool isDouble() const;
|
bool isDouble() const;
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ private slots:
|
|||||||
{
|
{
|
||||||
Fault f;
|
Fault f;
|
||||||
|
|
||||||
QCOMPARE(f.name(), QString());
|
QCOMPARE(f.name(), QByteArray());
|
||||||
QVERIFY(!f.data().isValid());
|
QVERIFY(!f.data().isValid());
|
||||||
|
|
||||||
QVERIFY(!f.isValid());
|
QVERIFY(!f.isValid());
|
||||||
@ -44,16 +44,16 @@ private slots:
|
|||||||
{
|
{
|
||||||
Fault f1("blup"), f2("blop", Value(42));
|
Fault f1("blup"), f2("blop", Value(42));
|
||||||
|
|
||||||
QCOMPARE(f1.name(), QString("blup"));
|
QCOMPARE(f1.name(), QByteArray("blup"));
|
||||||
QVERIFY(!f1.data().isValid());
|
QVERIFY(!f1.data().isValid());
|
||||||
|
|
||||||
QCOMPARE(f2.name(), QString("blop"));
|
QCOMPARE(f2.name(), QByteArray("blop"));
|
||||||
QVERIFY(f2.data().isValid());
|
QVERIFY(f2.data().isValid());
|
||||||
QCOMPARE(f2.data().toInt(), 42);
|
QCOMPARE(f2.data().toInt(), 42);
|
||||||
|
|
||||||
f1 = f2;
|
f1 = f2;
|
||||||
|
|
||||||
QCOMPARE(f1.name(), QString("blop"));
|
QCOMPARE(f1.name(), QByteArray("blop"));
|
||||||
QVERIFY(f1.data().isValid());
|
QVERIFY(f1.data().isValid());
|
||||||
QCOMPARE(f1.data().toInt(), 42);
|
QCOMPARE(f1.data().toInt(), 42);
|
||||||
}
|
}
|
||||||
|
@ -34,19 +34,19 @@ inline void sodepCompare(const Jolie::Value &v1, const Jolie::Value &v2)
|
|||||||
{
|
{
|
||||||
QCOMPARE(v1.isValid(), v2.isValid());
|
QCOMPARE(v1.isValid(), v2.isValid());
|
||||||
|
|
||||||
QCOMPARE(v1.isString(), v2.isString());
|
QCOMPARE(v1.isByteArray(), v2.isByteArray());
|
||||||
QCOMPARE(v1.isInt(), v2.isInt());
|
QCOMPARE(v1.isInt(), v2.isInt());
|
||||||
QCOMPARE(v1.isDouble(), v2.isDouble());
|
QCOMPARE(v1.isDouble(), v2.isDouble());
|
||||||
|
|
||||||
QCOMPARE(v1.toString(), v2.toString());
|
QCOMPARE(v1.toByteArray(), v2.toByteArray());
|
||||||
QCOMPARE(v1.toInt(), v2.toInt());
|
QCOMPARE(v1.toInt(), v2.toInt());
|
||||||
QCOMPARE(v1.toDouble(), v2.toDouble());
|
QCOMPARE(v1.toDouble(), v2.toDouble());
|
||||||
|
|
||||||
QStringList v1Names = v1.childrenNames();
|
QList<QByteArray> v1Names = v1.childrenNames();
|
||||||
QStringList v2Names = v2.childrenNames();
|
QList<QByteArray> v2Names = v2.childrenNames();
|
||||||
QCOMPARE(v1Names, v2Names);
|
QCOMPARE(v1Names, v2Names);
|
||||||
|
|
||||||
foreach (const QString &name, v1Names) {
|
foreach (const QByteArray &name, v1Names) {
|
||||||
QList<Jolie::Value> v1Values = v1.children(name);
|
QList<Jolie::Value> v1Values = v1.children(name);
|
||||||
QList<Jolie::Value> v2Values = v2.children(name);
|
QList<Jolie::Value> v2Values = v2.children(name);
|
||||||
|
|
||||||
|
@ -36,18 +36,18 @@ private slots:
|
|||||||
Message m1("/foo", "bar", 1);
|
Message m1("/foo", "bar", 1);
|
||||||
Message m2("/pata/pata", "pon", 2);
|
Message m2("/pata/pata", "pon", 2);
|
||||||
|
|
||||||
QCOMPARE(m1.resourcePath(), QString("/foo"));
|
QCOMPARE(m1.resourcePath(), QByteArray("/foo"));
|
||||||
QCOMPARE(m1.operationName(), QString("bar"));
|
QCOMPARE(m1.operationName(), QByteArray("bar"));
|
||||||
QCOMPARE(m1.id(), qint64(1));
|
QCOMPARE(m1.id(), qint64(1));
|
||||||
|
|
||||||
QCOMPARE(m2.resourcePath(), QString("/pata/pata"));
|
QCOMPARE(m2.resourcePath(), QByteArray("/pata/pata"));
|
||||||
QCOMPARE(m2.operationName(), QString("pon"));
|
QCOMPARE(m2.operationName(), QByteArray("pon"));
|
||||||
QCOMPARE(m2.id(), qint64(2));
|
QCOMPARE(m2.id(), qint64(2));
|
||||||
|
|
||||||
m1 = m2;
|
m1 = m2;
|
||||||
|
|
||||||
QCOMPARE(m1.resourcePath(), QString("/pata/pata"));
|
QCOMPARE(m1.resourcePath(), QByteArray("/pata/pata"));
|
||||||
QCOMPARE(m1.operationName(), QString("pon"));
|
QCOMPARE(m1.operationName(), QByteArray("pon"));
|
||||||
QCOMPARE(m2.id(), qint64(2));
|
QCOMPARE(m2.id(), qint64(2));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,15 +36,15 @@ using namespace Jolie;
|
|||||||
|
|
||||||
void dump(const Value &value, int level)
|
void dump(const Value &value, int level)
|
||||||
{
|
{
|
||||||
QString indent;
|
QByteArray indent;
|
||||||
|
|
||||||
while (level>0) {
|
while (level>0) {
|
||||||
indent+=" ";
|
indent+=" ";
|
||||||
level--;
|
level--;
|
||||||
}
|
}
|
||||||
|
|
||||||
qDebug() << (indent+value.toString()) << value.toInt() << value.toDouble();
|
qDebug() << (indent+value.toByteArray()) << value.toInt() << value.toDouble();
|
||||||
foreach (const QString &name, value.childrenNames()) {
|
foreach (const QByteArray &name, value.childrenNames()) {
|
||||||
QList<Value> children = value.children(name);
|
QList<Value> children = value.children(name);
|
||||||
qDebug() << (indent+"Children:") << name;
|
qDebug() << (indent+"Children:") << name;
|
||||||
foreach (const Value &child, children) {
|
foreach (const Value &child, children) {
|
||||||
@ -83,7 +83,7 @@ private slots:
|
|||||||
QVERIFY2(m_metaService.start(), "Looks like you don't have Jolie's metaservice command");
|
QVERIFY2(m_metaService.start(), "Looks like you don't have Jolie's metaservice command");
|
||||||
QTest::qWait(1000);
|
QTest::qWait(1000);
|
||||||
|
|
||||||
m_client = new Client("localhost", 9000);
|
m_client = new Client(QString::fromUtf8("localhost"), 9000);
|
||||||
}
|
}
|
||||||
|
|
||||||
void cleanupTestCase()
|
void cleanupTestCase()
|
||||||
@ -97,8 +97,8 @@ private slots:
|
|||||||
QTest::addColumn<QString>("resourcePrefix");
|
QTest::addColumn<QString>("resourcePrefix");
|
||||||
QTest::addColumn<QString>("fileName");
|
QTest::addColumn<QString>("fileName");
|
||||||
|
|
||||||
QTest::newRow("printer service") << "Printer" << "printer.ol";
|
QTest::newRow("printer service") << QString::fromUtf8("Printer") << QString::fromUtf8("printer.ol");
|
||||||
QTest::newRow("math service") << "Math" << "math.ol";
|
QTest::newRow("math service") << QString::fromUtf8("Math") << QString::fromUtf8("math.ol");
|
||||||
}
|
}
|
||||||
|
|
||||||
void shouldLoadService()
|
void shouldLoadService()
|
||||||
@ -106,32 +106,32 @@ private slots:
|
|||||||
QFETCH(QString, resourcePrefix);
|
QFETCH(QString, resourcePrefix);
|
||||||
QFETCH(QString, fileName);
|
QFETCH(QString, fileName);
|
||||||
|
|
||||||
QCOMPARE(m_metaService.loadService(resourcePrefix, QString(DATA_DIR"/")+fileName),
|
QCOMPARE(m_metaService.loadService(resourcePrefix, QString::fromUtf8(DATA_DIR"/")+fileName),
|
||||||
resourcePrefix);
|
resourcePrefix);
|
||||||
}
|
}
|
||||||
|
|
||||||
void shouldListServices()
|
void shouldListServices()
|
||||||
{
|
{
|
||||||
QStringList expected;
|
QStringList expected;
|
||||||
expected << "Math" << "Printer";
|
expected << QString::fromUtf8("Math") << QString::fromUtf8("Printer");
|
||||||
QCOMPARE(m_metaService.loadedServices(), expected);
|
QCOMPARE(m_metaService.loadedServices(), expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
void shouldPlaceServiceCalls_data()
|
void shouldPlaceServiceCalls_data()
|
||||||
{
|
{
|
||||||
QTest::addColumn<QString>("path");
|
QTest::addColumn<QByteArray>("path");
|
||||||
QTest::addColumn<QString>("method");
|
QTest::addColumn<QByteArray>("method");
|
||||||
QTest::addColumn<Value>("data");
|
QTest::addColumn<Value>("data");
|
||||||
QTest::addColumn<Value>("replyData");
|
QTest::addColumn<Value>("replyData");
|
||||||
|
|
||||||
QTest::newRow("printer service") << "/Printer" << "printInput" << Value("Patapatapon!") << Value("success");
|
QTest::newRow("printer service") << QByteArray("/Printer") << QByteArray("printInput") << Value("Patapatapon!") << Value("success");
|
||||||
QTest::newRow("math service") << "/Math" << "twice" << Value(10.5) << Value(21.0);
|
QTest::newRow("math service") << QByteArray("/Math") << QByteArray("twice") << Value(10.5) << Value(21.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void shouldPlaceServiceCalls()
|
void shouldPlaceServiceCalls()
|
||||||
{
|
{
|
||||||
QFETCH(QString, path);
|
QFETCH(QByteArray, path);
|
||||||
QFETCH(QString, method);
|
QFETCH(QByteArray, method);
|
||||||
QFETCH(Value, data);
|
QFETCH(Value, data);
|
||||||
QFETCH(Value, replyData);
|
QFETCH(Value, replyData);
|
||||||
|
|
||||||
@ -150,8 +150,8 @@ private slots:
|
|||||||
{
|
{
|
||||||
QTest::addColumn<QString>("serviceName");
|
QTest::addColumn<QString>("serviceName");
|
||||||
|
|
||||||
QTest::newRow("printer service") << "PrinterService";
|
QTest::newRow("printer service") << QString::fromUtf8("PrinterService");
|
||||||
QTest::newRow("math service") << "MathService";
|
QTest::newRow("math service") << QString::fromUtf8("MathService");
|
||||||
}
|
}
|
||||||
|
|
||||||
void shouldUnloadService()
|
void shouldUnloadService()
|
||||||
|
@ -42,12 +42,12 @@ public:
|
|||||||
layout()->addWidget(m_lineEdit);
|
layout()->addWidget(m_lineEdit);
|
||||||
|
|
||||||
QPushButton *button = new QPushButton(this);
|
QPushButton *button = new QPushButton(this);
|
||||||
button->setText("SEND");
|
button->setText(QString::fromUtf8("SEND"));
|
||||||
layout()->addWidget(button);
|
layout()->addWidget(button);
|
||||||
connect(button, SIGNAL(clicked()),
|
connect(button, SIGNAL(clicked()),
|
||||||
this, SLOT(sendMessage()));
|
this, SLOT(sendMessage()));
|
||||||
|
|
||||||
m_socket.connectToHost("localhost", 10000);
|
m_socket.connectToHost(QString::fromUtf8("localhost"), 10000);
|
||||||
if (!m_socket.waitForConnected(10000)) {
|
if (!m_socket.waitForConnected(10000)) {
|
||||||
qDebug("Failed to connect!");
|
qDebug("Failed to connect!");
|
||||||
return;
|
return;
|
||||||
@ -59,7 +59,7 @@ private slots:
|
|||||||
void sendMessage()
|
void sendMessage()
|
||||||
{
|
{
|
||||||
Message message("/", "printInput");
|
Message message("/", "printInput");
|
||||||
message.setData(Value(m_lineEdit->text()));
|
message.setData(Value(m_lineEdit->text().toUtf8()));
|
||||||
sodepWrite(m_socket, message);
|
sodepWrite(m_socket, message);
|
||||||
|
|
||||||
qDebug("Message sent:");
|
qDebug("Message sent:");
|
||||||
@ -67,7 +67,7 @@ private slots:
|
|||||||
buffer.open(QIODevice::WriteOnly);
|
buffer.open(QIODevice::WriteOnly);
|
||||||
sodepWrite(buffer, message);
|
sodepWrite(buffer, message);
|
||||||
buffer.close();
|
buffer.close();
|
||||||
qDebug(buffer.data().toHex());
|
qDebug("%s", buffer.data().toHex().constData());
|
||||||
|
|
||||||
qDebug("Message received:");
|
qDebug("Message received:");
|
||||||
buffer.setData(QByteArray());
|
buffer.setData(QByteArray());
|
||||||
@ -75,7 +75,7 @@ private slots:
|
|||||||
message = sodepReadMessage(m_socket);
|
message = sodepReadMessage(m_socket);
|
||||||
sodepWrite(buffer, message);
|
sodepWrite(buffer, message);
|
||||||
buffer.close();
|
buffer.close();
|
||||||
qDebug(buffer.data().toHex());
|
qDebug("%s", buffer.data().toHex().constData());
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
QLineEdit *m_lineEdit;
|
QLineEdit *m_lineEdit;
|
||||||
|
@ -38,11 +38,11 @@ private slots:
|
|||||||
|
|
||||||
QCOMPARE(v.toInt(), 0);
|
QCOMPARE(v.toInt(), 0);
|
||||||
QCOMPARE(v.toDouble(), 0.0);
|
QCOMPARE(v.toDouble(), 0.0);
|
||||||
QCOMPARE(v.toString(), QString());
|
QCOMPARE(v.toByteArray(), QByteArray());
|
||||||
|
|
||||||
QVERIFY(!v.isValid());
|
QVERIFY(!v.isValid());
|
||||||
|
|
||||||
QVERIFY(!v.isString());
|
QVERIFY(!v.isByteArray());
|
||||||
QVERIFY(!v.isInt());
|
QVERIFY(!v.isInt());
|
||||||
QVERIFY(!v.isDouble());
|
QVERIFY(!v.isDouble());
|
||||||
}
|
}
|
||||||
@ -63,7 +63,7 @@ private slots:
|
|||||||
QVERIFY(v2.isInt());
|
QVERIFY(v2.isInt());
|
||||||
|
|
||||||
QCOMPARE(v2.toDouble(), 0.0);
|
QCOMPARE(v2.toDouble(), 0.0);
|
||||||
QCOMPARE(v2.toString(), QString());
|
QCOMPARE(v2.toByteArray(), QByteArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
void shouldRespectDoubleValues()
|
void shouldRespectDoubleValues()
|
||||||
@ -82,23 +82,23 @@ private slots:
|
|||||||
QVERIFY(v2.isDouble());
|
QVERIFY(v2.isDouble());
|
||||||
|
|
||||||
QCOMPARE(v2.toInt(), 0);
|
QCOMPARE(v2.toInt(), 0);
|
||||||
QCOMPARE(v2.toString(), QString());
|
QCOMPARE(v2.toByteArray(), QByteArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
void shouldRespectStringValues()
|
void shouldRespectByteArrayValues()
|
||||||
{
|
{
|
||||||
Value v1("42"), v2;
|
Value v1("42"), v2;
|
||||||
|
|
||||||
QCOMPARE(v1.toString(), QString("42"));
|
QCOMPARE(v1.toByteArray(), QByteArray("42"));
|
||||||
QCOMPARE(v2.toString(), QString());
|
QCOMPARE(v2.toByteArray(), QByteArray());
|
||||||
|
|
||||||
QVERIFY(v1.isString());
|
QVERIFY(v1.isByteArray());
|
||||||
QVERIFY(!v2.isString());
|
QVERIFY(!v2.isByteArray());
|
||||||
|
|
||||||
v2 = v1;
|
v2 = v1;
|
||||||
|
|
||||||
QCOMPARE(v2.toString(), QString("42"));
|
QCOMPARE(v2.toByteArray(), QByteArray("42"));
|
||||||
QVERIFY(v2.isString());
|
QVERIFY(v2.isByteArray());
|
||||||
|
|
||||||
QCOMPARE(v2.toInt(), 0);
|
QCOMPARE(v2.toInt(), 0);
|
||||||
QCOMPARE(v2.toDouble(), 0.0);
|
QCOMPARE(v2.toDouble(), 0.0);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user