diff options
author | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2018-01-05 17:23:55 +0900 |
---|---|---|
committer | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2018-01-05 17:36:20 +0900 |
commit | bd5b10c8d59b971379799b164eb968eea939079a (patch) | |
tree | 6db21748739aec8d817a6936ebf75aeb332bf711 | |
parent | 5d85fc6335d4b49438a83e1e592ccac5a41d2332 (diff) | |
download | libquotient-bd5b10c8d59b971379799b164eb968eea939079a.tar.gz libquotient-bd5b10c8d59b971379799b164eb968eea939079a.zip |
jobs/generated: Make default values propagate properly
Thanks to the latest GTAD. initializeDefaultValue is a partial that in turn inserts a type-specific {{>initializer}} if there is a non-trivial default value.
-rw-r--r-- | jobs/gtad.yaml | 16 | ||||
-rw-r--r-- | jobs/{{base}}.h.mustache | 2 |
2 files changed, 13 insertions, 5 deletions
diff --git a/jobs/gtad.yaml b/jobs/gtad.yaml index 86eacc3d..ad8dc80f 100644 --- a/jobs/gtad.yaml +++ b/jobs/gtad.yaml @@ -3,9 +3,9 @@ preprocess: "%CLIENT_MAJOR_VERSION%": r0 # FIXME: the below only fixes C++ compilation but not actual work - the code # will try to reach out for wrong values in JSON payloads - "signed:": "signedData:" - "unsigned:": "unsignedData:" - "default:": "isDefault:" + #"signed:": "signedData:" + #"unsigned:": "unsignedData:" + #"default:": "isDefault:" # Structure: # swaggerType: <targetTypeSpec> @@ -29,16 +29,23 @@ types: string: - byte: &QByteArray type: QByteArray + initializer: '"{{defaultValue}}"' string?: true imports: <QtCore/QByteArray> - binary: *QByteArray - - date: { type: QDate, "avoidCopy?": true, imports: <QtCore/QDate> } + - date: + type: QDate + initializer: QDate::fromString("{{defaultValue}}") + avoidCopy?: true + imports: <QtCore/QDate> - dateTime: type: QDateTime + initializer: QDateTime::fromString("{{defaultValue}}") avoidCopy?: true imports: <QtCore/QDateTime> - //: type: QString + initializer: QStringLiteral("{{defaultValue}}") string?: true avoidCopy?: true imports: <QtCore/QString> @@ -65,6 +72,7 @@ env: _literalQuote: '"' maybeCrefType: "{{#avoidCopy?}}const {{/avoidCopy?}}{{dataType.name}}{{#avoidCopy?}}&{{/avoidCopy?}}" qualifiedMaybeCrefType: "{{#avoidCopy?}}const {{/avoidCopy?}}{{dataType.qualifiedName}}{{#avoidCopy?}}&{{/avoidCopy?}}" + initializeDefaultValue: "{{#defaultValue}}{{>initializer}}{{/defaultValue}}{{^defaultValue}}{}{{/defaultValue}}" # preamble: preamble.mustache copyrightName: Kitsune Ral copyrightEmail: <kitsune-ral@users.sf.net> diff --git a/jobs/{{base}}.h.mustache b/jobs/{{base}}.h.mustache index b5106dbe..69e0e6d3 100644 --- a/jobs/{{base}}.h.mustache +++ b/jobs/{{base}}.h.mustache @@ -43,7 +43,7 @@ namespace QMatrixClient {{/ trivial?}}{{/model}} // End of inner data structures {{/models}} - explicit {{camelCaseOperationId}}Job({{#allParams}}{{>maybeCrefType}} {{paramName}}{{^required?}} = {{defaultValue}}{{^defaultValue}}{}{{/defaultValue}}{{/required?}}{{#@join}}, {{/@join}}{{/allParams}});{{!skip EOL + explicit {{camelCaseOperationId}}Job({{#allParams}}{{>maybeCrefType}} {{paramName}}{{^required?}} = {{>initializeDefaultValue}}{{/required?}}{{#@join}}, {{/@join}}{{/allParams}});{{!skip EOL }}{{# responses}}{{#normalResponse?}}{{#allProperties?}} ~{{camelCaseOperationId}}Job() override; {{#allProperties}} |