diff options
author | Antti Hölttä <AHoelttae@luxoft.com> | 2018-05-04 14:27:28 +0200 |
---|---|---|
committer | Dominik Holland <dominik.holland@pelagicore.com> | 2018-05-15 13:48:23 +0000 |
commit | 96d543c1d28fe84d19c75e812cf4cf34df7c3ad9 (patch) | |
tree | 94b17fab0ff6c43a496c3ad4341b28d17aaf5bb8 /src/tools/ivigenerator/templates_frontend | |
parent | 8c264c39f7acd510636b85a36cc29a6a1e05af38 (diff) |
Update the ivigenerator templates to use macros
Replace repetitive or complex parts of ivigenerator's templates with
macros. Add a directory for common code. Also some cleanup.
Task-number: QTAUTO-847
Change-Id: I12d7d6c25db14d4ab05583274742aec9e35d2bbf
Reviewed-by: Dominik Holland <dominik.holland@pelagicore.com>
Diffstat (limited to 'src/tools/ivigenerator/templates_frontend')
14 files changed, 69 insertions, 189 deletions
diff --git a/src/tools/ivigenerator/templates_frontend/backendinterface.cpp.tpl b/src/tools/ivigenerator/templates_frontend/backendinterface.cpp.tpl index c4e453e..9bbb482 100644 --- a/src/tools/ivigenerator/templates_frontend/backendinterface.cpp.tpl +++ b/src/tools/ivigenerator/templates_frontend/backendinterface.cpp.tpl @@ -36,9 +36,9 @@ # # SPDX-License-Identifier: LGPL-3.0 #} +{% import 'qtivi_macros.j2' as ivi %} {% set class = '{0}BackendInterface'.format(interface) %} {% include 'generated_comment.cpp.tpl' %} -{% import 'utils.tpl' as utils %} #include "{{class|lower}}.h" @@ -79,11 +79,7 @@ QT_BEGIN_NAMESPACE {% for property in interface.properties %} {% if not property.readonly and not property.const %} /*! -{% if interface.tags.config.zoned %} - \fn void {{class}}::{{property|setter_name}}({{ property|parameter_type }}, const QString &zone); -{% else %} - \fn void {{class}}::{{property|setter_name}}({{ property|parameter_type }}); -{% endif %} + \fn {{ivi.prop_setter(property, class, interface.tags.config.zoned)}}; Setter for {{interface}}::{{property}}. Sets the property \e {{property}} to the new value passed by \a {{property}}. @@ -102,17 +98,9 @@ QT_BEGIN_NAMESPACE {% endfor %} {% for operation in interface.operations %} /*! -{% if interface.tags.config.zoned %} -{% if operation.parameters|length %} - \fn {{operation|return_type}} {{class}}::{{operation}}({{operation.parameters|map('parameter_type')|join(', ')}}, const QString &zone){%if operation.const %} const{% endif %}; -{% else %} - \fn {{operation|return_type}} {{class}}::{{operation}}(const QString &zone){%if operation.const %} const{% endif %}; -{% endif %} -{% else %} - \fn {{operation|return_type}} {{class}}::{{operation}}({{operation.parameters|map('parameter_type')|join(', ')}}){%if operation.const %} const{% endif %}; -{% endif %} + \fn {{ivi.operation(operation, class, interface.tags.config.zoned)}}; -{{ utils.format_comments(operation.comment) }} +{{ ivi.format_comments(operation.comment) }} {% if interface.tags.config.zoned %} The value of \a zone indicates the zone this operation should be done in. @@ -122,16 +110,9 @@ QT_BEGIN_NAMESPACE {% for signal in interface.signals %} /*! -{% if interface.tags.config.zoned %} -{% if signal.parameters|length %} - \fn void {{class}}::{{signal}}({{signal.parameters|map('parameter_type')|join(', ')}}, const QString &zone = QString()); -{% else %} - \fn void {{class}}::{{signal}}(const QString &zone = QString()); -{% endif %} -{% else %} - \fn void {{class}}::{{signal}}({{signal.parameters|map('parameter_type')|join(', ')}}); -{% endif %} -{{ utils.format_comments(signal.comment) }} + \fn {{ivi.signal(signal, class, interface.tags.config.zoned)}}; + +{{ ivi.format_comments(signal.comment) }} {% if interface.tags.config.zoned %} The value of \a zone indicates the zone this operation should be done in. @@ -140,11 +121,7 @@ QT_BEGIN_NAMESPACE {% endfor %} {% for property in interface.properties %} /*! -{% if interface.tags.config.zoned %} - \fn void {{class}}::{{property}}Changed({{ property|parameter_type }}, const QString &zone); -{% else %} - \fn void {{class}}::{{property}}Changed({{ property|parameter_type }}); -{% endif %} + \fn {{ivi.prop_notify(property, class, interface.tags.config.zoned)}}; The signal is emitted when the \e {{property}} property changed to \a {{property}}. diff --git a/src/tools/ivigenerator/templates_frontend/backendinterface.h.tpl b/src/tools/ivigenerator/templates_frontend/backendinterface.h.tpl index d06162f..83aeb58 100644 --- a/src/tools/ivigenerator/templates_frontend/backendinterface.h.tpl +++ b/src/tools/ivigenerator/templates_frontend/backendinterface.h.tpl @@ -36,7 +36,13 @@ # # SPDX-License-Identifier: LGPL-3.0 #} +{% import 'qtivi_macros.j2' as ivi %} {% set class = '{0}BackendInterface'.format(interface) %} +{% if interface.tags.config.zoned %} +{% set base_class = 'QIviZonedFeatureInterface' %} +{% else %} +{% set base_class = 'QIviFeatureInterface' %} +{% endif %} {% set oncedefine = '{0}_{1}_H_'.format(module.module_name|upper, class|upper) %} {% set exportsymbol = 'Q_{0}_EXPORT'.format(module.module_name|upper) %} {% include 'generated_comment.cpp.tpl' %} @@ -54,20 +60,12 @@ {{inc}} {% endfor %} -{% if interface.tags.config.zoned %} -#include <QtIviCore/QIviZonedFeatureInterface> -{% else %} -#include <QtIviCore/QIviFeatureInterface> -{% endif %} +#include <QtIviCore/{{base_class}}> #include <QtIviCore/QIviPendingReply> QT_BEGIN_NAMESPACE -{% if interface.tags.config.zoned %} -class {{exportsymbol}} {{class}} : public QIviZonedFeatureInterface -{% else %} -class {{exportsymbol}} {{class}} : public QIviFeatureInterface -{% endif %} +class {{exportsymbol}} {{class}} : public {{base_class}} { Q_OBJECT public: @@ -76,43 +74,19 @@ public: {% for property in interface.properties %} {% if not property.readonly and not property.const %} -{% if interface.tags.config.zoned %} - virtual void {{property|setter_name}}({{ property|parameter_type }}, const QString &zone) = 0; -{% else %} - virtual void {{property|setter_name}}({{ property|parameter_type }}) = 0; -{% endif %} + virtual {{ivi.prop_setter(property, zoned = interface.tags.config.zoned)}} = 0; {% endif %} {% endfor %} {% for operation in interface.operations %} -{% if interface.tags.config.zoned %} -{% if operation.parameters|length %} - virtual QIviPendingReply<{{operation|return_type}}> {{operation}}({{operation.parameters|map('parameter_type')|join(', ')}}, const QString &zone){%if operation.const %} const{% endif %} = 0; -{% else %} - virtual QIviPendingReply<{{operation|return_type}}> {{operation}}(const QString &zone){%if operation.const %} const{% endif %} = 0; -{% endif %} -{% else %} - virtual QIviPendingReply<{{operation|return_type}}> {{operation}}({{operation.parameters|map('parameter_type')|join(', ')}}){%if operation.const %} const{% endif %} = 0; -{% endif %} + virtual {{ivi.operation(operation, zoned = interface.tags.config.zoned)}} = 0; {% endfor %} Q_SIGNALS: {% for signal in interface.signals %} -{% if interface.tags.config.zoned %} -{% if signal.parameters|length %} - void {{signal}}({{signal.parameters|map('parameter_type')|join(', ')}}, const QString &zone = QString()); -{% else %} - void {{signal}}(const QString &zone = QString()); -{% endif %} -{% else %} - void {{signal}}({{signal.parameters|map('parameter_type')|join(', ')}}); -{% endif %} + {{ivi.signal(signal, zoned = interface.tags.config.zoned)}}; {% endfor %} {% for property in interface.properties %} -{% if interface.tags.config.zoned %} - void {{property}}Changed({{ property|parameter_type }}, const QString &zone); -{% else %} - void {{property}}Changed({{ property|parameter_type }}); -{% endif %} + {{ivi.prop_notify(property, zoned = interface.tags.config.zoned)}}; {% endfor %} }; diff --git a/src/tools/ivigenerator/templates_frontend/generated_comment.cpp.tpl b/src/tools/ivigenerator/templates_frontend/generated_comment.cpp.tpl deleted file mode 100644 index 95878f2..0000000 --- a/src/tools/ivigenerator/templates_frontend/generated_comment.cpp.tpl +++ /dev/null @@ -1,46 +0,0 @@ -{# -# Copyright (C) 2017 Klaralvdalens Datakonsult AB (KDAB). -# Contact: https://www.qt.io/licensing/ -# -# This file is part of the QtIvi module of the Qt Toolkit. -# -# $QT_BEGIN_LICENSE:LGPL-QTAS$ -# Commercial License Usage -# Licensees holding valid commercial Qt Automotive Suite licenses may use -# this file in accordance with the commercial license agreement provided -# with the Software or, alternatively, in accordance with the terms -# contained in a written agreement between you and The Qt Company. For -# licensing terms and conditions see https://www.qt.io/terms-conditions. -# For further information use the contact form at https://www.qt.io/contact-us. -# -# GNU Lesser General Public License Usage -# Alternatively, this file may be used under the terms of the GNU Lesser -# General Public License version 3 as published by the Free Software -# Foundation and appearing in the file LICENSE.LGPL3 included in the -# packaging of this file. Please review the following information to -# ensure the GNU Lesser General Public License version 3 requirements -# will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -# -# GNU General Public License Usage -# Alternatively, this file may be used under the terms of the GNU -# General Public License version 2.0 or (at your option) the GNU General -# Public license version 3 or any later version approved by the KDE Free -# Qt Foundation. The licenses are as published by the Free Software -# Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -# included in the packaging of this file. Please review the following -# information to ensure the GNU General Public License requirements will -# be met: https://www.gnu.org/licenses/gpl-2.0.html and -# https://www.gnu.org/licenses/gpl-3.0.html. -# -# $QT_END_LICENSE$ -# -# SPDX-License-Identifier: LGPL-3.0 -#} -/**************************************************************************** -** Generated from '{{module}}.qface' -** -** Created by: The QFace generator (QtAS {{qtASVersion}}) -** -** WARNING! All changes made in this file will be lost! -*****************************************************************************/ - diff --git a/src/tools/ivigenerator/templates_frontend/interface.cpp.tpl b/src/tools/ivigenerator/templates_frontend/interface.cpp.tpl index 8dc6002..1344082 100644 --- a/src/tools/ivigenerator/templates_frontend/interface.cpp.tpl +++ b/src/tools/ivigenerator/templates_frontend/interface.cpp.tpl @@ -36,9 +36,9 @@ # # SPDX-License-Identifier: LGPL-3.0 #} +{% import 'qtivi_macros.j2' as ivi %} {% set class = '{0}'.format(interface) %} {% include 'generated_comment.cpp.tpl' %} -{% import 'utils.tpl' as utils %} #include "{{class|lower}}.h" #include "{{class|lower}}_p.h" @@ -58,7 +58,7 @@ QT_BEGIN_NAMESPACE /*! \class {{interface}} \inmodule {{module}} -{{ utils.format_comments(interface.comment) }} +{{ ivi.format_comments(interface.comment) }} */ /*! @@ -73,7 +73,7 @@ QT_BEGIN_NAMESPACE \inherits AbstractFeature {% endif %} -{{ utils.format_comments(interface.comment) }} +{{ ivi.format_comments(interface.comment) }} */ /*! \internal */ @@ -178,7 +178,7 @@ void {{class}}Private::on{{property|upperfirst}}Changed({{property|parameter_typ {% for signal in interface.signals %} /*! \internal */ {% if interface.tags.config.zoned %} -void {{class}}Private::on{{signal|upperfirst}}({{signal.parameters|map('parameter_type')|join(', ')}}{%if signal.parameters|length %}, {%endif%}const QString &zone) +void {{class}}Private::on{{signal|upperfirst}}({{ivi.join_params(signal, true)}}) { auto q = getParent(); auto f = qobject_cast<{{class}}*>(q->zoneAt(zone)); @@ -189,7 +189,7 @@ void {{class}}Private::on{{signal|upperfirst}}({{signal.parameters|map('paramete emit f->{{signal}}({{signal.parameters|join(', ')}}); } {% else %} -void {{class}}Private::on{{signal|upperfirst}}({{signal.parameters|map('parameter_type')|join(', ')}}) +void {{class}}Private::on{{signal|upperfirst}}({{ivi.join_params(signal)}}) { auto q = getParent(); emit q->{{signal}}({{signal.parameters|join(', ')}}); @@ -279,7 +279,7 @@ void {{class}}::registerQmlTypes(const QString& uri, int majorVersion, int minor /*! \property {{class}}::{{property}} -{{ utils.format_comments(property.comment) }} +{{ ivi.format_comments(property.comment) }} {% if property.const %} \note This property is constant and the value will not change once the plugin is initialized. {% endif %} @@ -287,12 +287,12 @@ void {{class}}::registerQmlTypes(const QString& uri, int majorVersion, int minor /*! \qmlproperty {{property|return_type}} {{interface|qml_type}}::{{property}} -{{ utils.format_comments(property.comment) }} +{{ ivi.format_comments(property.comment) }} {% if property.const %} \note This property is constant and the value will not change once the plugin is initialized. {% endif %} */ -{{property|return_type}} {{class}}::{{property|getter_name}}() const +{{ivi.prop_getter(property, class)}} { const auto d = {{class}}Private::get(this); {% if not module.tags.config.disablePrivateIVI %} @@ -303,7 +303,7 @@ void {{class}}::registerQmlTypes(const QString& uri, int majorVersion, int minor } {% if not property.readonly and not property.const %} -void {{class}}::{{property|setter_name}}({{ property|parameter_type }}) +{{ivi.prop_setter(property, class)}} { auto d = {{class}}Private::get(this); bool forceUpdate = false; @@ -334,14 +334,13 @@ void {{class}}::{{property|setter_name}}({{ property|parameter_type }}) {%- for operation in interface.operations %} /*! - \qmlmethod {{interface|qml_type}}::{{operation}}({{operation.parameters|map('parameter_type')|join(', ')}}) -{{ utils.format_comments(operation.comment) }} + \qmlmethod {{interface|qml_type}}::{{operation}}({{ivi.join_params(operation)}}) +{{ ivi.format_comments(operation.comment) }} */ /*! -{{ utils.format_comments(operation.comment) }} +{{ ivi.format_comments(operation.comment) }} */ -QIviPendingReply<{{operation|return_type}}> {{class}}::{{operation}}({{operation.parameters|map('parameter_type')|join(', ')}}){% if operation.const %} const{% endif %} - +{{ivi.operation(operation, class)}} { if ({{class}}BackendInterface *backend = ({{class}}BackendInterface *) this->backend()) {% if interface.tags.config.zoned %} diff --git a/src/tools/ivigenerator/templates_frontend/interface.h.tpl b/src/tools/ivigenerator/templates_frontend/interface.h.tpl index 0c33c65..6db880a 100644 --- a/src/tools/ivigenerator/templates_frontend/interface.h.tpl +++ b/src/tools/ivigenerator/templates_frontend/interface.h.tpl @@ -36,7 +36,13 @@ # # SPDX-License-Identifier: LGPL-3.0 #} +{% import 'qtivi_macros.j2' as ivi %} {% set class = '{0}'.format(interface) %} +{% if interface.tags.config.zoned %} +{% set base_class = 'QIviAbstractZonedFeature' %} +{% else %} +{% set base_class = 'QIviAbstractFeature' %} +{% endif %} {% set oncedefine = '{0}_{1}_H_'.format(module.module_name|upper, class|upper) %} {% set exportsymbol = 'Q_{0}_EXPORT'.format(module.module_name|upper) %} {% include 'generated_comment.cpp.tpl' %} @@ -54,11 +60,7 @@ {{inc}} {% endfor %} -{% if interface.tags.config.zoned %} -#include <QtIviCore/QIviAbstractZonedFeature> -{% else %} -#include <QtIviCore/QIviAbstractFeature> -{% endif %} +#include <QtIviCore/{{base_class}}> #include <QtIviCore/QIviPendingReply> QT_BEGIN_NAMESPACE @@ -66,14 +68,10 @@ QT_BEGIN_NAMESPACE class {{class}}Private; class {{class}}BackendInterface; -{% if interface.tags.config.zoned %} -class {{exportsymbol}} {{class}} : public QIviAbstractZonedFeature { -{% else %} -class {{exportsymbol}} {{class}} : public QIviAbstractFeature { -{% endif %} +class {{exportsymbol}} {{class}} : public {{base_class}} { Q_OBJECT {% for property in interface.properties %} - Q_PROPERTY({{property|return_type}} {{property}} READ {{property|getter_name}}{% if not property.readonly and not property.const %} WRITE {{property|setter_name}}{% endif %} NOTIFY {{property}}Changed) + {{ivi.property(property)}} {% endfor %} Q_CLASSINFO("IviPropertyDomains", "{{ interface.properties|json_domain|replace("\"", "\\\"") }}") {% if interface.module.tags.config.validation_info %} @@ -90,25 +88,25 @@ public: static void registerQmlTypes(const QString& uri, int majorVersion=1, int minorVersion=0); {% for property in interface.properties %} - {{property|return_type}} {{property|getter_name}}() const; + {{ivi.prop_getter(property)}}; {% endfor %} public Q_SLOTS: {% for operation in interface.operations %} - QIviPendingReply<{{operation|return_type}}> {{operation}}({{operation.parameters|map('parameter_type')|join(', ')}}){% if operation.const %} const{% endif %}; + {{ ivi.operation(operation) }}; {% endfor %} {% for property in interface.properties %} {% if not property.readonly and not property.const %} - void {{property|setter_name}}({{property|parameter_type}}); + {{ivi.prop_setter(property)}}; {% endif %} {% endfor %} Q_SIGNALS: {% for signal in interface.signals %} - void {{signal}}({{signal.parameters|map('parameter_type')|join(', ')}}); + {{ivi.signal(signal)}}; {% endfor %} {% for property in interface.properties %} - void {{property}}Changed({{property|parameter_type}}); + {{ivi.prop_notify(property)}}; {% endfor %} protected: diff --git a/src/tools/ivigenerator/templates_frontend/interface_p.h.tpl b/src/tools/ivigenerator/templates_frontend/interface_p.h.tpl index cd7e65c..b51c749 100644 --- a/src/tools/ivigenerator/templates_frontend/interface_p.h.tpl +++ b/src/tools/ivigenerator/templates_frontend/interface_p.h.tpl @@ -36,7 +36,13 @@ # # SPDX-License-Identifier: LGPL-3.0 #} +{% import 'qtivi_macros.j2' as ivi %} {% set class = '{0}'.format(interface) %} +{% if interface.tags.config.zoned %} +{% set base_class = 'QIviAbstractZonedFeature' %} +{% else %} +{% set base_class = 'QIviAbstractFeature' %} +{% endif %} {% set oncedefine = '{0}_{1}PRIVATE_H_'.format(module.module_name|upper, class|upper) %} {% include 'generated_comment.cpp.tpl' %} @@ -59,11 +65,7 @@ {% if module.tags.config.disablePrivateIVI %} #include <QObject> {% else %} -{% if interface.tags.config.zoned %} -#include <QtIviCore/private/qiviabstractzonedfeature_p.h> -{% else %} -#include <QtIviCore/private/qiviabstractfeature_p.h> -{% endif %} +#include <QtIviCore/private/{{base_class|lower}}_p.h> {% endif %} QT_BEGIN_NAMESPACE @@ -73,11 +75,7 @@ class {{class}}; {% if module.tags.config.disablePrivateIVI %} class {{class}}Private : public QObject {% else %} -{% if interface.tags.config.zoned %} -class {{class}}Private : public QIviAbstractZonedFeaturePrivate -{% else %} -class {{class}}Private : public QIviAbstractFeaturePrivate -{% endif %} +class {{class}}Private : public {{base_class}}Private {% endif %} { public: @@ -98,18 +96,10 @@ public: void clearToDefaults(); {% for property in interface.properties %} -{% if interface.tags.config.zoned %} - void on{{property|upperfirst}}Changed({{property|parameter_type}}, const QString &zone); -{% else %} - void on{{property|upperfirst}}Changed({{property|parameter_type}}); -{% endif %} + {{ivi.on_prop_changed(property, zoned = interface.tags.config.zoned)}}; {% endfor %} {% for signal in interface.signals %} -{% if interface.tags.config.zoned %} - void on{{signal|upperfirst}}({{signal.parameters|map('parameter_type')|join(', ')}}{%if signal.parameters|length %}, {%endif%}const QString &zone); -{% else %} - void on{{signal|upperfirst}}({{signal.parameters|map('parameter_type')|join(', ')}}); -{% endif %} + void on{{signal|upperfirst}}({{ivi.join_params(signal, zoned = interface.tags.config.zoned)}}); {% endfor %} {% if not module.tags.config.disablePrivateIVI %} diff --git a/src/tools/ivigenerator/templates_frontend/module.cpp.tpl b/src/tools/ivigenerator/templates_frontend/module.cpp.tpl index ef6e112..96c9e4e 100644 --- a/src/tools/ivigenerator/templates_frontend/module.cpp.tpl +++ b/src/tools/ivigenerator/templates_frontend/module.cpp.tpl @@ -38,7 +38,7 @@ #} {% set class = '{0}Module'.format(module.module_name|upperfirst) %} {% include 'generated_comment.cpp.tpl' %} -{% import 'utils.tpl' as utils %} +{% import 'qtivi_macros.j2' as ivi %} #include "{{class|lower}}.h" #include "{{class|lower}}factory.h" @@ -71,11 +71,11 @@ QObject* {{class|lower}}_singletontype_provider(QQmlEngine*, QJSEngine*) {% for enum in module.enums %} /*! \enum {{class}}::{{enum}} - {{ utils.format_comments(enum.comment) }} + {{ ivi.format_comments(enum.comment) }} {% for member in enum.members %} \value {{member}} - {{ utils.format_comments(member.comment) }} + {{ ivi.format_comments(member.comment) }} {% endfor %} */ {% endfor %} diff --git a/src/tools/ivigenerator/templates_frontend/module.h.tpl b/src/tools/ivigenerator/templates_frontend/module.h.tpl index aa10866..12c1dcb 100644 --- a/src/tools/ivigenerator/templates_frontend/module.h.tpl +++ b/src/tools/ivigenerator/templates_frontend/module.h.tpl @@ -40,7 +40,6 @@ {% set class = '{0}Module'.format(module.module_name|upperfirst) %} {% set oncedefine = '{0}_H_'.format(class|upper) %} {% include 'generated_comment.cpp.tpl' %} -{% import 'utils.tpl' as utils %} #ifndef {{oncedefine}} #define {{oncedefine}} diff --git a/src/tools/ivigenerator/templates_frontend/modulefactory.cpp.tpl b/src/tools/ivigenerator/templates_frontend/modulefactory.cpp.tpl index d343f00..ede6670 100644 --- a/src/tools/ivigenerator/templates_frontend/modulefactory.cpp.tpl +++ b/src/tools/ivigenerator/templates_frontend/modulefactory.cpp.tpl @@ -38,7 +38,6 @@ #} {% set class = '{0}ModuleFactory'.format(module.module_name|upperfirst) %} {% include 'generated_comment.cpp.tpl' %} -{% import 'utils.tpl' as utils %} #include "{{class|lower}}.h" diff --git a/src/tools/ivigenerator/templates_frontend/modulefactory.h.tpl b/src/tools/ivigenerator/templates_frontend/modulefactory.h.tpl index c805956..a4c3274 100644 --- a/src/tools/ivigenerator/templates_frontend/modulefactory.h.tpl +++ b/src/tools/ivigenerator/templates_frontend/modulefactory.h.tpl @@ -40,7 +40,6 @@ {% set class = '{0}ModuleFactory'.format(module.module_name|upperfirst) %} {% set oncedefine = '{0}_H_'.format(class|upper) %} {% include 'generated_comment.cpp.tpl' %} -{% import 'utils.tpl' as utils %} #ifndef {{oncedefine}} #define {{oncedefine}} diff --git a/src/tools/ivigenerator/templates_frontend/struct.cpp.tpl b/src/tools/ivigenerator/templates_frontend/struct.cpp.tpl index 1447dfe..d0309c6 100644 --- a/src/tools/ivigenerator/templates_frontend/struct.cpp.tpl +++ b/src/tools/ivigenerator/templates_frontend/struct.cpp.tpl @@ -37,9 +37,9 @@ # # SPDX-License-Identifier: LGPL-3.0 #} +{% import 'qtivi_macros.j2' as ivi %} {% set class = '{0}'.format(struct) %} {% include 'generated_comment.cpp.tpl' %} -{% import 'utils.tpl' as utils %} #include "{{class|lower}}.h" @@ -48,7 +48,7 @@ QT_BEGIN_NAMESPACE /*! \class {{struct}} \inmodule {{module}} -{{ utils.format_comments(struct.comment) }} +{{ ivi.format_comments(struct.comment) }} */ {{class}}::{{class}}() @@ -74,18 +74,18 @@ QT_BEGIN_NAMESPACE /*! \property {{class}}::{{field}} -{{ utils.format_comments(field.comment) }} +{{ ivi.format_comments(field.comment) }} {% if field.const %} \note This property is constant and the value will not change once an instance has been created. {% endif %} */ -{{field|return_type}} {{class}}::{{field}}() const +{{ivi.prop_getter(field, class)}} { return m_{{field}}; } {% if not field.readonly and not field.const %} -void {{class}}::set{{field|upperfirst}}({{ field|parameter_type }}) +{{ivi.prop_setter(field, class)}} { m_{{field}} = {{field}}; } diff --git a/src/tools/ivigenerator/templates_frontend/struct.h.tpl b/src/tools/ivigenerator/templates_frontend/struct.h.tpl index ed97d4f..0f4a26f 100644 --- a/src/tools/ivigenerator/templates_frontend/struct.h.tpl +++ b/src/tools/ivigenerator/templates_frontend/struct.h.tpl @@ -37,6 +37,7 @@ # # SPDX-License-Identifier: LGPL-3.0 #} +{% import 'qtivi_macros.j2' as ivi %} {% set class = '{0}'.format(struct) %} {% set oncedefine = '{0}_{1}_H_'.format(module.module_name|upper, class|upper) %} {% set exportsymbol = 'Q_{0}_EXPORT'.format(module.module_name|upper) %} @@ -63,7 +64,7 @@ class {{exportsymbol}} {{class}} { Q_GADGET {% for field in struct.fields %} - Q_PROPERTY({{field|return_type}} {{field}} READ {{field}}{% if not field.readonly and not field.const %} WRITE set{{field|upperfirst}}{% endif %}) + {{ivi.property(field)}} {% endfor %} Q_CLASSINFO("IviPropertyDomains", "{{ struct.fields|json_domain|replace("\"", "\\\"") }}") public: @@ -72,9 +73,9 @@ public: ~{{class}}(); {% for field in struct.fields %} - {{field|return_type}} {{field}}() const; + {{ivi.prop_getter(field)}}; {% if not field.readonly and not field.const %} - void set{{field|upperfirst}}({{field|parameter_type}}); + {{ivi.prop_setter(field)}}; {% endif %} {% endfor %} diff --git a/src/tools/ivigenerator/templates_frontend/structmodel.cpp.tpl b/src/tools/ivigenerator/templates_frontend/structmodel.cpp.tpl index 64a6772..a372e78 100644 --- a/src/tools/ivigenerator/templates_frontend/structmodel.cpp.tpl +++ b/src/tools/ivigenerator/templates_frontend/structmodel.cpp.tpl @@ -39,7 +39,6 @@ #} {% set class = '{0}Model'.format(struct) %} {% include 'generated_comment.cpp.tpl' %} -{% import 'utils.tpl' as utils %} #include "{{class|lower}}.h" #include "{{class|lower}}_p.h" diff --git a/src/tools/ivigenerator/templates_frontend/utils.tpl b/src/tools/ivigenerator/templates_frontend/utils.tpl deleted file mode 100644 index e5cd338..0000000 --- a/src/tools/ivigenerator/templates_frontend/utils.tpl +++ /dev/null @@ -1,9 +0,0 @@ -{% macro format_comments(comments) -%} -{% with doc = comments|parse_doc -%} -{% if doc.brief %} \brief {{doc.brief|join(' ')| wordwrap(width=100, wrapstring='\n ')}} -{% endif %} - -{% if doc.description %} - {{doc.description|join(' ')| wordwrap(width=100, wrapstring='\n ')}}{% endif %} -{% endwith -%} -{% endmacro -%} |