Commit 287f946e authored by Wouter's avatar Wouter

Introspect return types of RPC methods

parent f71f1a8a
......@@ -671,6 +671,20 @@ RpcMethod* Introspector::introspectMethod(const QString& id, const QVariantMap&
method->addParameter(parameter);
}
if (data.contains("returns")) {
QVariantMap resultTypeMap = data.value("returns").toMap();
QString innerId = makeIdentifier(id) + "_Result";
Type *type = internalType(innerId, resultTypeMap, containerClass);
Q_ASSERT(type);
// Register anonymous types as nested types
if (type->isAnonymous()) {
InnerType *inner = new InnerType(type, containerClass);
containerClass->addMember(inner);
}
method->setReturnType(type);
}
return method;
}
......
......@@ -79,7 +79,7 @@ public:
{% if not class.rpcMethods|length_is:0 %}
protected:
virtual QVariantMap doCall(const QString& methodName, const QVariantMap& parameters) = 0;
virtual QVariant doCall(const QString& methodName, const QVariantMap& parameters) = 0;
{% endif %}
public:
......
......@@ -105,7 +105,18 @@
{% endswitch %}
{% endfor %}
doCall("{{ member.originalName }}", _rpcParameters);
{% switch member.returnType.type.metaType %}
{% default %}
QVariantMap resultMap = doCall("{{ member.originalName }}", _rpcParameters).toMap();
return {{ member.returnType.type.className }}::fromVariant(resultMap);
{% case "type" %}
{% ifequal member.returnType.type.fullName "void" %}
doCall("{{ member.originalName }}", _rpcParameters);
{% else %}
QVariant result = doCall("{{ member.originalName }}", _rpcParameters);
return result.value<{{ member.returnType.type.fullName }}>();
{% endifequal %}
{% endswitch %}
}
{% endif %}{% endif %}{# inline, pureVirtual #}
......
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