summaryrefslogtreecommitdiffstats
path: root/src/tools
diff options
context:
space:
mode:
Diffstat (limited to 'src/tools')
-rw-r--r--src/tools/ifcodegen/CMakeLists.txt9
-rw-r--r--src/tools/ifcodegen/generator/filters.py10
-rw-r--r--src/tools/ifcodegen/generator/global_functions.py2
-rw-r--r--src/tools/ifcodegen/templates/common/backend_simulation.cpp.jinja4
-rw-r--r--src/tools/ifcodegen/templates/common/qtif_macros.j2205
5 files changed, 226 insertions, 4 deletions
diff --git a/src/tools/ifcodegen/CMakeLists.txt b/src/tools/ifcodegen/CMakeLists.txt
index 82bff2ca..00f629e6 100644
--- a/src/tools/ifcodegen/CMakeLists.txt
+++ b/src/tools/ifcodegen/CMakeLists.txt
@@ -204,12 +204,17 @@ file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/.config "---\n")
file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/.config "VERSION: \"${QT_REPO_MODULE_VERSION}\"\n")
if(NOT DEFINED QT_DISABLE_DEPRECATED_UP_TO)
- set(QT_DISABLE_DEPRECATED_UP_TO 5.0.0 CACHE STRING "Give error for using deprecated up to this Qt version.")
+ set(QT_DISABLE_DEPRECATED_UP_TO "0x050000" CACHE STRING "Give error for using deprecated up to this Qt version.")
endif()
file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/.config "QT_DISABLE_DEPRECATED_UP_TO: \"${QT_DISABLE_DEPRECATED_UP_TO}\"\n")
if(NOT DEFINED QT_WARN_DEPRECATED_UP_TO)
- set(QT_WARN_DEPRECATED_UP_TO ${QT_REPO_MODULE_VERSION} CACHE STRING "Warn for using deprecated up to this Qt version.")
+ if(${QT_REPO_MODULE_VERSION} MATCHES "([0-9]+)\.([0-9]+)\.([0-9]+)")
+ math(EXPR REPO_VERSION_HEX "(${CMAKE_MATCH_1} << 16) + (${CMAKE_MATCH_2} << 8) + ${CMAKE_MATCH_3}" OUTPUT_FORMAT HEXADECIMAL)
+ else()
+ set(REPO_VERSION_HEX "0x060000")
+ endif()
+ set(QT_WARN_DEPRECATED_UP_TO ${REPO_VERSION_HEX} CACHE STRING "Warn for using deprecated up to this Qt version.")
endif()
file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/.config "QT_WARN_DEPRECATED_UP_TO: \"${QT_WARN_DEPRECATED_UP_TO}\"\n")
diff --git a/src/tools/ifcodegen/generator/filters.py b/src/tools/ifcodegen/generator/filters.py
index 051dc49d..66c9ac60 100644
--- a/src/tools/ifcodegen/generator/filters.py
+++ b/src/tools/ifcodegen/generator/filters.py
@@ -6,13 +6,21 @@
# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
import json
+import inspect
from qface.idl.domain import Module, Interface, Property, Parameter, Field, Struct
from qface.helper.generic import lower_first, upper_first
from qface.helper.qtcpp import Filters
-from .global_functions import jinja_error, jinja_warning
+from .global_functions import jinja_error, jinja_warning, jinja_deprecate_with_qt7_removal
+def deprecated_filter(name=None):
+ jinja_deprecate_with_qt7_removal('6.11', 'Use the new deprecate_with_qt7_removal function instead')
+
+ if not name:
+ name = inspect.stack()[1][3]
+ jinja_warning("The '{0}' filter is deprecated and will be removed in future Qt "
+ "versions".format(name))
def enum_value_to_cppliteral(value, module_name):
value = value.strip().rsplit('.', 1)[-1]
diff --git a/src/tools/ifcodegen/generator/global_functions.py b/src/tools/ifcodegen/generator/global_functions.py
index d65e94e5..4eaa1732 100644
--- a/src/tools/ifcodegen/generator/global_functions.py
+++ b/src/tools/ifcodegen/generator/global_functions.py
@@ -67,6 +67,8 @@ def deprecate_helper(version, removal, message):
"""
def version_to_int(version_string):
+ if version_string.find('.') == -1:
+ return int(version_string, 0)
version_val = 0
i = 0
for ver in version_string.split('.'):
diff --git a/src/tools/ifcodegen/templates/common/backend_simulation.cpp.jinja b/src/tools/ifcodegen/templates/common/backend_simulation.cpp.jinja
index 55b62c5a..3cdf7718 100644
--- a/src/tools/ifcodegen/templates/common/backend_simulation.cpp.jinja
+++ b/src/tools/ifcodegen/templates/common/backend_simulation.cpp.jinja
@@ -74,7 +74,11 @@
{% endif %}
{% endfor %}
{% if interface_zoned %}
+#if QT_VERSION < QT_VERSION_CHECK(6, 11, 0)
+ , m_zones(new QQmlPropertyMap(this))
+#else
, m_zones(QQmlPropertyMap::create(this))
+#endif
{% endif %}
{
//In some cases the engine is unused, this doesn't do any harm if it is still used
diff --git a/src/tools/ifcodegen/templates/common/qtif_macros.j2 b/src/tools/ifcodegen/templates/common/qtif_macros.j2
index ccfe2e44..eb30f617 100644
--- a/src/tools/ifcodegen/templates/common/qtif_macros.j2
+++ b/src/tools/ifcodegen/templates/common/qtif_macros.j2
@@ -1,2 +1,205 @@
-{% include 'common/qtif_macros.jinja' %}
+# Copyright (C) 2021 The Qt Company Ltd.
+# Copyright (C) 2019 Luxoft Sweden AB
+# Copyright (C) 2018 Pelagicore AG
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+#}
+
{{ deprecate_with_qt7_removal('6.11', 'Use .jinja extension instead of the deprecated .j2 extension for this file.') }}
+
+{# these macros can be used to generate content for QtInterfaceFramework code. The macros
+# provide snippets that are commonly found in multiple templates and are not
+# too template specific.
+# Function macros do not generate the whole body of the function, but just
+# the header line, so remember to add potential virtuals, overrides,
+# semicolons etc. yourself!
+#}
+
+{# join operation parameters, with type and name, into a comma separated list,
+# optionally including the zone.
+#}
+{% macro join_params(operation, zoned = false, default_values = false) %}
+{% if default_values %}
+{% set params = operation.parameters|map('parameter_type_default')|join(', ') %}
+{% else %}
+{% set params = operation.parameters|map('parameter_type')|join(', ') %}
+{% endif %}
+{% if zoned %}
+{% if params|length %}
+{% set params = params + ', const QString &zone' %}
+{% else %}
+{% set params = 'const QString &zone' %}
+{% endif %}
+{% endif %}
+{{params}}
+{%- endmacro %}
+
+{# function header for a custom slot. pass the class parameter in order to add
+# the scope:: -specifier. use zoned to add the zone-specifier
+#}
+{% macro operation(operation, class = '', zoned = false) %}
+{% if class|count %}
+{% set scope = class+'::' %}
+{% else %}
+{% set scope = '' %}
+{% endif %}
+{% if operation.const %}
+{% set const = ' const' %}
+{% else%}
+{% set const = '' %}
+{% endif %}
+QIfPendingReply<{{operation|return_type}}> {{scope}}{{operation}}({{join_params(operation, zoned)}}){{const}}
+{%- endmacro %}
+
+
+{# property declaration, Q_PROPERTY(...) #}
+{% macro property(property, notify = true) %}
+{% if property.readonly or property.const or property.type.is_model %}
+{% set write = '' %}
+{% else %}
+{% set write = ' WRITE ' + property|setter_name %}
+{% endif %}
+{% if notify %}
+{% set _notify = ' NOTIFY ' + property.name + 'Changed' %}
+{% else %}
+{% set _notify = ''%}
+{% endif %}
+Q_PROPERTY({{property|return_type}} {{property}} READ {{property|getter_name}}{{write}}{{_notify}} FINAL)
+{%- endmacro %}
+
+
+{# function header for a property setter: setProperty(...)
+# pass the class parameter in order to add the scope:: -specifier.
+# use zoned to add the zone-specifier
+#}
+{% macro prop_setter(property, class = '', zoned = false, model_interface = false, default_zone = false) %}
+{% if class|count %}
+{% set scope = class+'::' %}
+{% else %}
+{% set scope = '' %}
+{% endif %}
+{% if zoned %}
+{% if default_zone %}
+{% set zone = ', const QString &zone = QString()' %}
+{% else %}
+{% set zone = ', const QString &zone' %}
+{% endif %}
+{% else %}
+{% set zone = '' %}
+{% endif %}
+{% if property.type.is_model and model_interface %}
+{% set type = 'QIfPagingModelInterface *'+property.name %}
+{% else %}
+{% set type = property|parameter_type %}
+{% endif %}
+void {{scope}}{{property|setter_name}}({{type}}{{zone}})
+{%- endmacro %}
+
+
+{# function header for a property getter.
+# pass the class parameter in order to add the scope:: -specifier.
+#}
+{% macro prop_getter(property, class = '', model_interface = false) %}
+{% if class|count %}
+{% set scope = class+'::' %}
+{% else %}
+{% set scope = '' %}
+{% endif %}
+{% if property.type.is_model and model_interface %}
+{% set type = 'QIfPagingModelInterface *' %}
+{% else %}
+{% set type = property|return_type %}
+{% endif %}
+{{type}} {{scope}}{{property|getter_name}}() const
+{%- endmacro %}
+
+
+{# helper macro for defining a property notifier and a corresponding callback.
+# This is an internal function and not intended to be used inside a template.
+#}
+{% macro _prop_notify(property, class, zoned, prefix, model_interface, default_values = false) %}
+{% if prefix|count %}
+{% set prop = prefix + property|upperfirst %}
+{% else %}
+{% set prop = property %}
+{% endif %}
+{% if class|count %}
+{% set scope = class+'::' %}
+{% else %}
+{% set scope = '' %}
+{% endif %}
+{% if zoned %}
+{% if default_values %}
+{% set zone = ', const QString &zone=QString()' %}
+{% else %}
+{% set zone = ', const QString &zone' %}
+{% endif %}
+{% else %}
+{% set zone = '' %}
+{% endif %}
+{% if property.type.is_model and model_interface %}
+{% set type = 'QIfPagingModelInterface *'+property.name %}
+{% set default_value = type + '=nullptr'%}
+{% else %}
+{% set type = property|parameter_type %}
+{% set default_value = property|parameter_type_default %}
+{% endif %}
+{% if default_values %}
+{% set type = default_value %}
+{% endif %}
+void {{scope}}{{prop}}Changed({{type}}{{zone}})
+{%- endmacro %}
+
+{# signal declaration for property notifier.
+# pass the class parameter in order to add the scope:: -specifier.
+# use zoned to add the zone-specifier
+#}
+{% macro prop_notify(property, class = '', zoned = false, model_interface = false, default_values = false) %}
+{{_prop_notify(property, class, zoned, '', model_interface, default_values)}}
+{%- endmacro %}
+
+{# callback slot declaration for property notifier.
+# pass the class parameter in order to add the scope:: -specifier.
+# use zoned to add the zone-specifier
+#}
+{% macro on_prop_changed(property, class = '', zoned = false, model_interface = false) %}
+{{_prop_notify(property, class, zoned, 'on', model_interface)}}
+{%- endmacro %}
+
+
+{# helper macro for defining a signal and a corresponding callback.
+# This is an internal function and not intended to be used inside a template.
+#}
+{% macro _signal(signal, class, zoned, prefix, default_values = false) %}
+{% if prefix|count %}
+{% set sig = prefix + signal|upperfirst %}
+{% else %}
+{% set sig = signal %}
+{% endif %}
+{% if class|count %}
+{% set scope = class+'::' %}
+{% else %}
+{% set scope = '' %}
+{% endif %}
+void {{scope}}{{sig}}({{join_params(signal, zoned, default_values)}})
+{%- endmacro %}
+
+{# custom signal declaration
+# pass the class parameter in order to add the scope:: -specifier.
+# use zoned to add the zone-specifier
+#}
+{% macro signal(signal, class = '', zoned = false) %}
+{{_signal(signal, class, zoned, '')}}
+{%- endmacro %}
+
+{# custom signal callback declaration
+# pass the class parameter in order to add the scope:: -specifier.
+# use zoned to add the zone-specifier
+#}
+{% macro on_signal(signal, class = '', zoned = false) %}
+{{_signal(signal, class, zoned, 'on')}}
+{%- endmacro %}
+
+
+{% macro format_comments(comments) -%}
+{{comments|comment_text|join('\n ')}}
+{% endmacro -%}