From 51d27f3bcaacefda78dc033021b6a85152ab972e Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Mon, 1 Jun 2020 14:53:59 +0200 Subject: GTAD parts: new home and format updates for GTAD 0.7 All GTAD-related files (gtad.yaml and templates) from now live in their dedicated gtad/ directory - this helps against removing them accidentally along with the rest of the generated files. The format to list generated files in gtad.yaml has changed a bit before GTAD 0.7 beta2; gtad.yaml in this commit conforms to the new structure. --- gtad/gtad.yaml | 169 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 169 insertions(+) create mode 100644 gtad/gtad.yaml (limited to 'gtad/gtad.yaml') diff --git a/gtad/gtad.yaml b/gtad/gtad.yaml new file mode 100644 index 00000000..51f9e26b --- /dev/null +++ b/gtad/gtad.yaml @@ -0,0 +1,169 @@ +analyzer: + subst: + "%CLIENT_RELEASE_LABEL%": r0 + "%CLIENT_MAJOR_VERSION%": r0 + identifiers: + signed: signedData + unsigned: unsignedData + PushRule/default: isDefault + default: defaultVersion # getCapabilities/RoomVersionsCapability + origin_server_ts: originServerTimestamp # Instead of originServerTs + start: begin # Because start() is a method in BaseJob + m.upload.size: uploadSize + m.homeserver: homeserver + m.identity_server: identityServer + m.change_password: changePassword + m.room_versions: roomVersions + AuthenticationData/additionalProperties: authInfo + + # Structure inside `types`: + # - swaggerType: + # OR + # - swaggerType: + # - swaggerFormat: + # - /swaggerFormatRegEx/: + # - //: # default, if the format doesn't mach anything above + # WHERE + # targetTypeSpec = targetType OR + # { type: targetType, imports: , } + # swaggerType can be +set/+on pair; attributes from the map under +set + # are added to each type from the sequence under +on. + types: + - +set: &UseOmittable + useOmittable: + imports: [ '"converters.h"' ] + omittedValue: 'none' # See `none` in converters.h + +on: + - integer: + - int64: qint64 + - int32: qint32 + - //: int + - number: + - float: float + - //: double + - boolean: bool + - string: + - byte: &ByteStream + type: QIODevice* + imports: + - binary: *ByteStream + - +set: { avoidCopy: } + +on: + - date: + type: QDate + initializer: QDate::fromString("{{defaultValue}}") + imports: + - dateTime: + type: QDateTime + initializer: QDateTime::fromString("{{defaultValue}}") + imports: + - //: &QString + type: QString + initializer: QStringLiteral("{{defaultValue}}") + isString: + - file: *ByteStream + - +set: { avoidCopy: } + +on: + - object: &QJsonObject { type: QJsonObject, imports: } + - $ref: + - +set: { moveOnly: } + +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$/: pass # This $ref is only used in an array, see below + - //: *UseOmittable # Also apply "avoidCopy" to all other ref'ed types + - schema: # Properties of inline structure definitions + - TurnServerCredentials: *QJsonObject # Because it's used as is + - //: *UseOmittable + - array: + - string: QStringList + - +set: { moveOnly: } + +on: + - /^Notification|Result$/: + type: "std::vector<{{1}}>" + imports: '"events/eventloader.h"' + - /m\.room\.member$/: + type: "EventsArray" + imports: '"events/roommemberevent.h"' + - /state_event.yaml$/: StateEvents + - /room_event.yaml$/: RoomEvents + - /event.yaml$/: Events + - //: { type: "QVector<{{1}}>", imports: } + - map: # `additionalProperties` in OpenAPI + - RoomState: + type: "UnorderedMap" + moveOnly: + imports: '"util.h"' + - /.+/: + type: "QHash" + imports: + - //: + type: QVariantHash + imports: + - variant: # A sequence `type` (multitype) in OpenAPI + - /^string,null|null,string$/: *QString + - //: { type: QVariant, imports: } + + #operations: + +mustache: + constants: + # Syntax elements used by GTAD +# _quote: '"' # Common quote for left and right +# _leftQuote: '"' +# _rightQuote: '"' +# _joinChar: ',' # The character used by {{_join}} - not working yet + _comment: '//' + copyrightName: Kitsune Ral + copyrightEmail: + + partials: + _typeRenderer: "{{#scope}}{{scopeCamelCase}}Job::{{/scope}}{{>name}}" + omittedValue: '{}' # default value to initialize omitted parameters with + initializer: '{{defaultValue}}' + cjoin: '{{#hasMore}}, {{/hasMore}}' + + openOmittable: "{{^required?}}{{#useOmittable}}{{^defaultValue}}Omittable<{{/defaultValue}}{{/useOmittable}}{{/required?}}" + closeOmittable: "{{^required?}}{{#useOmittable}}{{^defaultValue}}>{{/defaultValue}}{{/useOmittable}}{{/required?}}" + + maybeOmittableType: "{{>openOmittable}}{{dataType.name}}{{>closeOmittable}}" + qualifiedMaybeOmittableType: "{{>openOmittable}}{{dataType.qualifiedName}}{{>closeOmittable}}" + + maybeCrefType: "{{#avoidCopy}}const {{/avoidCopy}}{{>maybeOmittableType}}{{#avoidCopy}}&{{/avoidCopy}}{{#moveOnly}}&&{{/moveOnly}}" + qualifiedMaybeCrefType: + "{{#avoidCopy}}const {{/avoidCopy}}{{>qualifiedMaybeOmittableType}}{{#avoidCopy}}&{{/avoidCopy}}{{#moveOnly}}&&{{/moveOnly}}" + + maybeCrefJsonObject: "{{^propertyMap}}const QJsonObject&{{/propertyMap}}{{#propertyMap}}QJsonObject{{/propertyMap}}" + takeOrValue: "{{#propertyMap}}take{{/propertyMap}}{{^propertyMap}}value{{/propertyMap}}" + + initializeDefaultValue: "{{#defaultValue}}{{>initializer}}{{/defaultValue}}{{^defaultValue}}{{>omittedValue}}{{/defaultValue}}" + joinedParamDecl: '{{>maybeCrefType}} {{paramName}}{{^required?}} = {{>initializeDefaultValue}}{{/required?}}{{>cjoin}}' + joinedParamDef: '{{>maybeCrefType}} {{paramName}}{{>cjoin}}' + passQueryParams: '{{#queryParams}}{{paramName}}{{>cjoin}}{{/queryParams}}' + + # Doc-comment blocks. Comment indent is managed by clang-format + # (without clang-format there'd have to be a separate partial definition + # for each indent...) + + # For structures that are not supposed to have a summary (e.g., JSON schema) + docCommentShort: |- + {{#description}} + /// {{_}}{{/description}} + docCommentSummary: |- + {{#summary}} \brief {{summary}} + *{{/summary}} + + templates: + data: + .h: "{{>template.h.mustache}}" + .cpp: "{{>template.cpp.mustache}}" + api: + .h: "{{>template.h.mustache}}" + .cpp: "{{>template.cpp.mustache}}" + + #outFilesList: apifiles.txt + -- cgit v1.2.3 From a0430b1fb722a77ad7cbd28f181727d46d92b3a2 Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Sat, 6 Jun 2020 20:47:56 +0200 Subject: gtad/*: optimise and use latest GTAD features - The generated code is updated to be compatible with the BaseJob changes introduced in the previous commit. This includes greatly reducing the number of header files that have to be explicitly #included, as basejob.h now #includes converters.h. Also, thanks to the changes in BaseJob, none of generated job classes needs a pimpl Private class. - gtad/template.*.mustache files are replaced with data.h.mustache for data structures (entirely defined in header files from now on) and operation.*.mustache for API operations (also massively moved to header files, possibly also becoming header-only in the future). - New variable-dropping and title-overring features in GTAD 0.7 allow to use the upstream matrix-doc repo to generate the code. - CMakeLists.txt makes use of file globbing with CONFIGURE_DEPENDS where possible to alleviate build reconfiguration after a GTAD call. --- gtad/gtad.yaml | 102 ++++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 69 insertions(+), 33 deletions(-) (limited to 'gtad/gtad.yaml') diff --git a/gtad/gtad.yaml b/gtad/gtad.yaml index 51f9e26b..045f5f35 100644 --- a/gtad/gtad.yaml +++ b/gtad/gtad.yaml @@ -15,6 +15,11 @@ analyzer: m.change_password: changePassword m.room_versions: roomVersions AuthenticationData/additionalProperties: authInfo + /\b(Location|Protocol|User)$/: 'ThirdParty$&' + # These parameters are deprecated and unused in Quotient; so drop them + login>/user: "" + login>/medium: "" + login>/address: "" # Structure inside `types`: # - swaggerType: @@ -31,8 +36,7 @@ analyzer: types: - +set: &UseOmittable useOmittable: - imports: [ '"converters.h"' ] - omittedValue: 'none' # See `none` in converters.h + omittedValue: 'none' # Quotient::none in lib/util.h +on: - integer: - int64: qint64 @@ -52,11 +56,9 @@ analyzer: - date: type: QDate initializer: QDate::fromString("{{defaultValue}}") - imports: - dateTime: type: QDateTime initializer: QDateTime::fromString("{{defaultValue}}") - imports: - //: &QString type: QString initializer: QStringLiteral("{{defaultValue}}") @@ -64,7 +66,7 @@ analyzer: - file: *ByteStream - +set: { avoidCopy: } +on: - - object: &QJsonObject { type: QJsonObject, imports: } + - object: &QJsonObject { type: QJsonObject } - $ref: - +set: { moveOnly: } +on: @@ -74,10 +76,16 @@ analyzer: { type: RoomEventPtr, imports: '"events/eventloader.h"' } - /event.yaml$/: { type: EventPtr, imports: '"events/eventloader.h"' } - - /m\.room\.member$/: pass # This $ref is only used in an array, see below + - /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<> - //: *UseOmittable # Also apply "avoidCopy" to all other ref'ed types - - schema: # Properties of inline structure definitions - - TurnServerCredentials: *QJsonObject # Because it's used as is + - schema: + - getTurnServer<: *QJsonObject # It's used as an opaque JSON object + - RoomFilter: # A structure inside Filter, same story as with other filters - //: *UseOmittable - array: - string: QStringList @@ -86,27 +94,23 @@ analyzer: - /^Notification|Result$/: type: "std::vector<{{1}}>" imports: '"events/eventloader.h"' - - /m\.room\.member$/: + - /m\.room\.member$/: # Only used in an array (see also above) type: "EventsArray" imports: '"events/roommemberevent.h"' - /state_event.yaml$/: StateEvents - /room_event.yaml$/: RoomEvents - /event.yaml$/: Events - - //: { type: "QVector<{{1}}>", imports: } + - //: "QVector<{{1}}>" - map: # `additionalProperties` in OpenAPI - RoomState: type: "UnorderedMap" moveOnly: - imports: '"util.h"' - /.+/: type: "QHash" - imports: - - //: - type: QVariantHash - imports: + - //: QVariantHash - variant: # A sequence `type` (multitype) in OpenAPI - /^string,null|null,string$/: *QString - - //: { type: QVariant, imports: } + - //: QVariant #operations: @@ -127,43 +131,75 @@ mustache: initializer: '{{defaultValue}}' cjoin: '{{#hasMore}}, {{/hasMore}}' - openOmittable: "{{^required?}}{{#useOmittable}}{{^defaultValue}}Omittable<{{/defaultValue}}{{/useOmittable}}{{/required?}}" - closeOmittable: "{{^required?}}{{#useOmittable}}{{^defaultValue}}>{{/defaultValue}}{{/useOmittable}}{{/required?}}" + openOmittable: + "{{^required?}}{{#useOmittable}}\ + {{^defaultValue}}Omittable<{{/defaultValue}}\ + {{/useOmittable}}{{/required?}}" + closeOmittable: + "{{^required?}}{{#useOmittable}}\ + {{^defaultValue}}>{{/defaultValue}}\ + {{/useOmittable}}{{/required?}}" maybeOmittableType: "{{>openOmittable}}{{dataType.name}}{{>closeOmittable}}" - qualifiedMaybeOmittableType: "{{>openOmittable}}{{dataType.qualifiedName}}{{>closeOmittable}}" + qualifiedMaybeOmittableType: + "{{>openOmittable}}{{dataType.qualifiedName}}{{>closeOmittable}}" - maybeCrefType: "{{#avoidCopy}}const {{/avoidCopy}}{{>maybeOmittableType}}{{#avoidCopy}}&{{/avoidCopy}}{{#moveOnly}}&&{{/moveOnly}}" + ref: "{{#avoidCopy}}&{{/avoidCopy}}{{#moveOnly}}&&{{/moveOnly}}" + maybeCrefType: + "{{#avoidCopy}}const {{/avoidCopy}}{{>maybeOmittableType}}{{>ref}}" qualifiedMaybeCrefType: - "{{#avoidCopy}}const {{/avoidCopy}}{{>qualifiedMaybeOmittableType}}{{#avoidCopy}}&{{/avoidCopy}}{{#moveOnly}}&&{{/moveOnly}}" + "{{#avoidCopy}}const {{/avoidCopy}}{{>qualifiedMaybeOmittableType}}{{>ref}}" - maybeCrefJsonObject: "{{^propertyMap}}const QJsonObject&{{/propertyMap}}{{#propertyMap}}QJsonObject{{/propertyMap}}" - takeOrValue: "{{#propertyMap}}take{{/propertyMap}}{{^propertyMap}}value{{/propertyMap}}" + maybeCrefJsonObject: + "{{^propertyMap}}const QJsonObject&{{/propertyMap}}\ + {{#propertyMap}}QJsonObject{{/propertyMap}}" - initializeDefaultValue: "{{#defaultValue}}{{>initializer}}{{/defaultValue}}{{^defaultValue}}{{>omittedValue}}{{/defaultValue}}" - joinedParamDecl: '{{>maybeCrefType}} {{paramName}}{{^required?}} = {{>initializeDefaultValue}}{{/required?}}{{>cjoin}}' - joinedParamDef: '{{>maybeCrefType}} {{paramName}}{{>cjoin}}' - passQueryParams: '{{#queryParams}}{{paramName}}{{>cjoin}}{{/queryParams}}' + takeOrValue: + "{{#propertyMap}}take{{/propertyMap}}{{^propertyMap}}value{{/propertyMap}}" + takeOrLoad: "{{#moveOnly}}take{{/moveOnly}}{{^moveOnly}}load{{/moveOnly}}" + + initializeDefaultValue: + "{{#defaultValue}}{{>initializer}}{{/defaultValue}}\ + {{^defaultValue}}{{>omittedValue}}{{/defaultValue}}" + + # No inner indents in folded values! + + joinedParamDecl: >- + {{>maybeCrefType}} {{paramName}} + {{^required?}} = {{>initializeDefaultValue}}{{/required?}}{{>cjoin}} + joinedParamDef: "{{>maybeCrefType}} {{paramName}}{{>cjoin}}" + + passPathAndMaybeQuery: >- + QStringLiteral("{{basePathWithoutHost}}") + {{#pathParts}} % {{_}}{{/pathParts}}{{#queryParams?}}, + queryTo{{camelCaseOperationId}}( + {{#queryParams}}{{paramName}}{{>cjoin}}{{/queryParams}}){{/queryParams?}} + + nonInlineResponseSignature: |- + {{>docCommentShort}} + {{>maybeOmittableType}} {{paramName}}(){{^moveOnly}} const{{/moveOnly}} # Doc-comment blocks. Comment indent is managed by clang-format # (without clang-format there'd have to be a separate partial definition - # for each indent...) + # for each indent...) but we take care of line breaks to maintain + # some sanity even before clang-format - # For structures that are not supposed to have a summary (e.g., JSON schema) + # This is for structures that don't expect a summary (e.g., JSON schema) docCommentShort: |- {{#description}} /// {{_}}{{/description}} + # For structures with the summary, a common partial for summary is here; + # the main part is different in different places docCommentSummary: |- {{#summary}} \brief {{summary}} *{{/summary}} templates: data: - .h: "{{>template.h.mustache}}" - .cpp: "{{>template.cpp.mustache}}" + .h: "{{>data.h.mustache}}" api: - .h: "{{>template.h.mustache}}" - .cpp: "{{>template.cpp.mustache}}" + .h: "{{>operation.h.mustache}}" + .cpp: "{{>operation.cpp.mustache}}" #outFilesList: apifiles.txt -- cgit v1.2.3 From 767b97dd885bcc04aac022763e5011115769196a Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Thu, 18 Jun 2020 07:31:44 +0200 Subject: gtad: restrict the identifier regex --- gtad/gtad.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gtad/gtad.yaml') diff --git a/gtad/gtad.yaml b/gtad/gtad.yaml index 045f5f35..0197e870 100644 --- a/gtad/gtad.yaml +++ b/gtad/gtad.yaml @@ -15,7 +15,7 @@ analyzer: m.change_password: changePassword m.room_versions: roomVersions AuthenticationData/additionalProperties: authInfo - /\b(Location|Protocol|User)$/: 'ThirdParty$&' + /^/(Location|Protocol|User)$/: 'ThirdParty$1' # These parameters are deprecated and unused in Quotient; so drop them login>/user: "" login>/medium: "" -- cgit v1.2.3 From cbd107e595bbb78ef3411a4a92f66d495c6fc5b4 Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Thu, 18 Jun 2020 22:20:00 +0200 Subject: Rename a few 'data' responses --- gtad/gtad.yaml | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) (limited to 'gtad/gtad.yaml') diff --git a/gtad/gtad.yaml b/gtad/gtad.yaml index 0197e870..adf5024a 100644 --- a/gtad/gtad.yaml +++ b/gtad/gtad.yaml @@ -16,6 +16,15 @@ analyzer: m.room_versions: roomVersions AuthenticationData/additionalProperties: authInfo /^/(Location|Protocol|User)$/: 'ThirdParty$1' + # Change some response names + /requestTokenTo.*/user: "" login>/medium: "" @@ -71,21 +80,27 @@ analyzer: - +set: { moveOnly: } +on: - /state_event.yaml$/: - { type: StateEventPtr, imports: '"events/eventloader.h"' } + { type: StateEventPtr, imports: "events/eventloader.h" } - /room_event.yaml$/: - { type: RoomEventPtr, imports: '"events/eventloader.h"' } + { type: RoomEventPtr, imports: "events/eventloader.h" } - /event.yaml$/: - { type: EventPtr, imports: '"events/eventloader.h"' } + { 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 - schema: - getTurnServer<: *QJsonObject # It's used as an opaque JSON object - - RoomFilter: # A structure inside Filter, same story as with other filters + - PublicRoomResponse: { _inline: true } +# - defineFilter>: &Filter # Force folding into a structure +# type: Filter +# imports: "csapi/definitions/sync_filter.h" +# - getFilter<: *Filter + - RoomFilter: # A structure inside Filter, same story as with *_filter.yaml - //: *UseOmittable - array: - string: QStringList @@ -93,10 +108,10 @@ analyzer: +on: - /^Notification|Result$/: type: "std::vector<{{1}}>" - imports: '"events/eventloader.h"' + imports: "events/eventloader.h" - /m\.room\.member$/: # Only used in an array (see also above) type: "EventsArray" - imports: '"events/roommemberevent.h"' + imports: "events/roommemberevent.h" - /state_event.yaml$/: StateEvents - /room_event.yaml$/: RoomEvents - /event.yaml$/: Events @@ -105,8 +120,7 @@ analyzer: - RoomState: type: "UnorderedMap" moveOnly: - - /.+/: - type: "QHash" + - /.+/: "QHash" - //: QVariantHash - variant: # A sequence `type` (multitype) in OpenAPI - /^string,null|null,string$/: *QString -- cgit v1.2.3