aboutsummaryrefslogtreecommitdiff
path: root/gtad
diff options
context:
space:
mode:
Diffstat (limited to 'gtad')
-rw-r--r--gtad/data.h.mustache3
-rw-r--r--gtad/gtad.yaml52
-rw-r--r--gtad/operation.cpp.mustache9
-rw-r--r--gtad/operation.h.mustache3
4 files changed, 34 insertions, 33 deletions
diff --git a/gtad/data.h.mustache b/gtad/data.h.mustache
index a2193380..1b511262 100644
--- a/gtad/data.h.mustache
+++ b/gtad/data.h.mustache
@@ -1,8 +1,7 @@
{{!
SPDX-FileCopyrightText: 2020 Kitsune Ral <Kitsune-Ral@users.sf.net>
SPDX-License-Identifier: LGPL-2.1-or-later
-}}
-{{>preamble}}
+}}{{>preamble}}
#pragma once
#include "converters.h"
diff --git a/gtad/gtad.yaml b/gtad/gtad.yaml
index adf5024a..943ac013 100644
--- a/gtad/gtad.yaml
+++ b/gtad/gtad.yaml
@@ -68,6 +68,9 @@ analyzer:
- dateTime:
type: QDateTime
initializer: QDateTime::fromString("{{defaultValue}}")
+ - uri:
+ type: QUrl
+ initializer: QUrl::fromEncoded("{{defaultValue}}")
- //: &QString
type: QString
initializer: QStringLiteral("{{defaultValue}}")
@@ -77,28 +80,31 @@ analyzer:
+on:
- object: &QJsonObject { type: QJsonObject }
- $ref:
- - +set: { moveOnly: }
+ - +set:
+ moveOnly:
+ imports: '"events/eventloader.h"'
+ +on:
+ - /state_event.yaml$/: StateEventPtr
+ - /room_event.yaml$/: RoomEventPtr
+ - /event.yaml$/: EventPtr
+ - /m\.room\.member/: void # Skip resolving; see EventsArray<> below
+ - +set:
+ # This renderer actually applies to all $ref things
+ _importRenderer: '"{{#segments}}{{_}}{{#_join}}/{{/_join}}{{/segments}}.h"'
+on:
- - /state_event.yaml$/:
- { type: StateEventPtr, imports: "events/eventloader.h" }
- - /room_event.yaml$/:
- { type: RoomEventPtr, imports: "events/eventloader.h" }
- - /event.yaml$/:
- { type: EventPtr, imports: "events/eventloader.h" }
- - /m\.room\.member$/: void # Skip resolving; see EventsArray<> below
- - '/^(\./)?definitions/request_email_validation.yaml$/':
- title: EmailValidationData
- - '/^(\./)?definitions/request_msisdn_validation.yaml$/':
- title: MsisdnValidationData
- - /_filter.yaml$/: # Event/RoomEventFilters do NOT need Omittable<>
- - /public_rooms_response.yaml$/: { _inline: true }
- - //: *UseOmittable # Also apply "avoidCopy" to all other ref'ed types
+ - '/^(\./)?definitions/request_email_validation.yaml$/':
+ title: EmailValidationData
+ - '/^(\./)?definitions/request_msisdn_validation.yaml$/':
+ title: MsisdnValidationData
+ - /_filter.yaml$/: # Event/RoomEventFilters do NOT need Omittable<>
+ - /public_rooms_response.yaml$/: { _inline: true }
+ - //: *UseOmittable # Also apply "avoidCopy" to all other ref'ed types
- schema:
- getTurnServer<: *QJsonObject # It's used as an opaque JSON object
- PublicRoomResponse: { _inline: true }
# - defineFilter>: &Filter # Force folding into a structure
# type: Filter
-# imports: "csapi/definitions/sync_filter.h"
+# imports: '"csapi/definitions/sync_filter.h"'
# - getFilter<: *Filter
- RoomFilter: # A structure inside Filter, same story as with *_filter.yaml
- //: *UseOmittable
@@ -108,10 +114,10 @@ analyzer:
+on:
- /^Notification|Result$/:
type: "std::vector<{{1}}>"
- imports: "events/eventloader.h"
- - /m\.room\.member$/: # Only used in an array (see also above)
+ imports: '"events/eventloader.h"'
+ - /m\.room\.member/: # Only used in an array (see also above)
type: "EventsArray<RoomMemberEvent>"
- imports: "events/roommemberevent.h"
+ imports: '"events/roommemberevent.h"'
- /state_event.yaml$/: StateEvents
- /room_event.yaml$/: RoomEvents
- /event.yaml$/: Events
@@ -129,12 +135,12 @@ analyzer:
#operations:
mustache:
+# delimiter: '%| |%' # or something else instead of '{{ }}'
constants:
# Syntax elements used by GTAD
# _quote: '"' # Common quote for left and right
# _leftQuote: '"'
-# _rightQuote: '"'
-# _joinChar: ',' # The character used by {{_join}} - not working yet
+# _rightQuote: '"_ls'
_comment: '//'
copyrightName: Kitsune Ral
copyrightEmail: <kitsune-ral@users.sf.net>
@@ -184,8 +190,8 @@ mustache:
joinedParamDef: "{{>maybeCrefType}} {{paramName}}{{>cjoin}}"
passPathAndMaybeQuery: >-
- QStringLiteral("{{basePathWithoutHost}}")
- {{#pathParts}} % {{_}}{{/pathParts}}{{#queryParams?}},
+ makePath("{{basePathWithoutHost}}"{{#pathParts}},
+ {{_}}{{/pathParts}}){{#queryParams?}},
queryTo{{camelCaseOperationId}}(
{{#queryParams}}{{paramName}}{{>cjoin}}{{/queryParams}}){{/queryParams?}}
diff --git a/gtad/operation.cpp.mustache b/gtad/operation.cpp.mustache
index 1d0ae476..3d26ec73 100644
--- a/gtad/operation.cpp.mustache
+++ b/gtad/operation.cpp.mustache
@@ -1,12 +1,9 @@
{{!
SPDX-FileCopyrightText: 2020 Kitsune Ral <Kitsune-Ral@users.sf.net>
SPDX-License-Identifier: LGPL-2.1-or-later
-}}
-{{>preamble}}
+}}{{>preamble}}
#include "{{filenameBase}}.h"
-#include <QtCore/QStringBuilder>
-
using namespace Quotient;
{{#operations}}{{#operation}}
{{#queryParams?}}
@@ -14,7 +11,7 @@ using namespace Quotient;
auto queryTo{{camelCaseOperationId}}(
{{#queryParams}}{{>joinedParamDef}}{{/queryParams}})
{
- BaseJob::Query _q;{{#queryParams}}
+ QUrlQuery _q;{{#queryParams}}
addParam<{{^required?}}IfNotEmpty{{/required?}}>(_q,
QStringLiteral("{{baseName}}"), {{paramName}});{{/queryParams}}
return _q;
@@ -37,7 +34,7 @@ QUrl {{camelCaseOperationId}}Job::makeRequestUrl(QUrl baseUrl{{#allParams?}},
{ {{#headerParams}}
setRequestHeader("{{baseName}}", {{paramName}}.toLatin1());
{{/headerParams}}{{#inlineBody}}{{^propertyMap}}{{^bodyParams?}}
- setRequestData(Data({{#consumesNonJson?}}{{nameCamelCase}}{{/consumesNonJson?
+ setRequestData(RequestData({{#consumesNonJson?}}{{nameCamelCase}}{{/consumesNonJson?
}}{{^consumesNonJson?}}toJson({{nameCamelCase}}){{/consumesNonJson?}}));
{{/bodyParams?}}{{/propertyMap}}{{/inlineBody
}}{{^consumesNonJson?}}{{#bodyParams?}}
diff --git a/gtad/operation.h.mustache b/gtad/operation.h.mustache
index 135eee55..f91dc66c 100644
--- a/gtad/operation.h.mustache
+++ b/gtad/operation.h.mustache
@@ -1,8 +1,7 @@
{{!
SPDX-FileCopyrightText: 2020 Kitsune Ral <Kitsune-Ral@users.sf.net>
SPDX-License-Identifier: LGPL-2.1-or-later
-}}
-{{>preamble}}
+}}{{>preamble}}
#pragma once
#include "jobs/basejob.h"