summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDominik Holland <dominik.holland@qt.io>2020-01-24 14:32:04 +0100
committerDominik Holland <dominik.holland@qt.io>2020-01-24 17:14:53 +0100
commit2cbee7815a6be32d3ce367d6109451049fda061d (patch)
tree396c5b3b26b07f5f25db0fc25bef36cabecadb38
parent10a66233eea4ff4b055bcd587b578af182e3ef07 (diff)
downloadqtivi-2cbee7815a6be32d3ce367d6109451049fda061d.tar.gz
ivigenerator: Report an error for 'unsupported' types within qface files
E.g. Using interfaces as properties or arguments is currently not supported. This change checks the parsed system before starting the autogenerator for the types 'interface' and 'maps' and reports an error Change-Id: I2288e56e4f59d4d2e9f69ea46db86d93cfe89e58 Fixes: AUTOSUITE-1293 Reviewed-by: Robert Griebl <robert.griebl@qt.io>
-rwxr-xr-xsrc/tools/ivigenerator/generate.py32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/tools/ivigenerator/generate.py b/src/tools/ivigenerator/generate.py
index dcad893..ba35506 100755
--- a/src/tools/ivigenerator/generate.py
+++ b/src/tools/ivigenerator/generate.py
@@ -40,6 +40,7 @@
# SPDX-License-Identifier: LGPL-3.0
import os
+import sys
import fnmatch
import click
import logging.config
@@ -61,6 +62,35 @@ builtinTemplatesPath = Path(here / 'templates')
builtinTemplates = [os.path.splitext(f)[0] for f in os.listdir(builtinTemplatesPath) if fnmatch.fnmatch(f, '*.yaml')]
+def validateType(srcFile, type, errorString):
+ if type.is_interface:
+ sys.exit("{0}: {1} of type 'interface' are not supported".format(srcFile, errorString))
+ if type.is_map:
+ sys.exit("{0}: {1} of type 'map' are not supported".format(srcFile, errorString))
+
+
+def validateSystem(srcFile, system):
+ """
+ Searches for types we don't support and reports an error
+ """
+ for module in system.modules:
+ for interface in module.interfaces:
+ for property in interface.properties:
+ validateType(srcFile, property.type, "Properties")
+ for operation in interface.operations:
+ for param in operation.parameters:
+ validateType(srcFile, param.type, "Arguments")
+ validateType(srcFile, operation.type, "Return values")
+
+ for signal in interface.signals:
+ for param in signal.parameters:
+ validateType(srcFile, param.type, "Arguments")
+
+ for struct in module.structs:
+ for field in struct.fields:
+ validateType(srcFile, field.type, "Fields")
+
+
def generate(tplconfig, moduleConfig, annotations, imports, src, dst):
log.debug('run {0} {1}'.format(src, dst))
FileSystem.strict = True
@@ -94,6 +124,8 @@ def generate(tplconfig, moduleConfig, annotations, imports, src, dst):
register_global_functions(generator)
register_filters(generator)
+ validateSystem(srcFile, system)
+
# Make sure the config tag is available for all our symbols
for module in system.modules:
module.add_tag('config')