diff options
author | Juergen Bocklage-Ryannel <jbocklage-ryannel@luxoft.com> | 2017-08-09 15:58:19 +0200 |
---|---|---|
committer | Juergen Bocklage-Ryannel <jbocklage-ryannel@luxoft.com> | 2017-08-09 15:58:19 +0200 |
commit | 953fc0794f1aad157d68952f0ac75c4eadf82203 (patch) | |
tree | ccdc255c7482508fc9ab6ea917c52b7be167ddd6 | |
parent | db45d764e4e4dbb64ea78716c3bb853ea8263e27 (diff) | |
download | qtivi-qface-953fc0794f1aad157d68952f0ac75c4eadf82203.tar.gz |
Fixed some smaller issues and renamed variant to var is checks
-rw-r--r-- | qface/helper/qtcpp.py | 30 | ||||
-rw-r--r-- | qface/idl/domain.py | 10 | ||||
-rw-r--r-- | qface/templates/qface/qtcpp.j2 | 4 |
3 files changed, 28 insertions, 16 deletions
diff --git a/qface/helper/qtcpp.py b/qface/helper/qtcpp.py index 5561fe5..aa94c84 100644 --- a/qface/helper/qtcpp.py +++ b/qface/helper/qtcpp.py @@ -28,7 +28,7 @@ class Filters(object): return 'QString()' if t.is_real: return 'qreal(0.0)' - if t.is_variant: + if t.is_var: return 'QVariant()' elif t.is_void: return '' @@ -58,12 +58,16 @@ class Filters(object): if symbol.type.is_enum: return '{0}{1}Module::{2} {3}'.format(prefix, module_name, symbol.type, symbol) if symbol.type.is_void or symbol.type.is_primitive: - if symbol.type.name == 'string': + if symbol.type.is_string: return 'const QString &{0}'.format(symbol) - if symbol.type.name == 'var': + if symbol.type.is_var: return 'const QVariant &{0}'.format(symbol) - if symbol.type.name == 'real': + if symbol.type.is_real: return 'qreal {0}'.format(symbol) + if symbol.type.is_bool: + return 'bool {0}'.format(symbol) + if symbol.type.is_int: + return 'int {0}'.format(symbol) return '{0} {1}'.format(symbol.type, symbol) elif symbol.type.is_list: nested = Filters.returnType(symbol.type.nested) @@ -82,16 +86,24 @@ class Filters(object): def returnType(symbol): prefix = Filters.classPrefix module_name = upper_first(symbol.module.module_name) - if symbol.type.is_enum: + t = symbol.type + if t.is_enum: return '{0}{1}Module::{2}'.format(prefix, module_name, symbol.type) if symbol.type.is_void or symbol.type.is_primitive: - if symbol.type.name == 'string': + if t.is_string: return 'QString' - if symbol.type.name == 'var': + if t.is_var: return 'QVariant' - if symbol.type.name == 'real': + if t.is_real: return 'qreal' - return symbol.type.name + if t.is_int: + return 'int' + if t.is_bool: + return 'bool' + if t.is_void: + return 'void' + print(t) + assert False elif symbol.type.is_list: nested = Filters.returnType(symbol.type.nested) return 'QVariantList'.format(nested) diff --git a/qface/idl/domain.py b/qface/idl/domain.py index defdca3..d4f87ca 100644 --- a/qface/idl/domain.py +++ b/qface/idl/domain.py @@ -220,6 +220,11 @@ class TypeSymbol(NamedElement): return self.is_primitive and self.name == 'string' @property + def is_var(self): + '''checks if type is primitive and var''' + return self.is_primitive and self.name == 'var' + + @property def is_enumeration(self): '''checks if type is complex and insytance of type Enum''' return self.is_complex and isinstance(self.reference, Enum) @@ -245,11 +250,6 @@ class TypeSymbol(NamedElement): return self.is_complex and isinstance(self.reference, Interface) @property - def is_variant(self): - '''checks if type is primitive and string''' - return self.is_primitive and self.name == 'var' - - @property def reference(self): """returns the symbol reference of the type name""" if not self.__is_resolved: diff --git a/qface/templates/qface/qtcpp.j2 b/qface/templates/qface/qtcpp.j2 index bf7824f..c2b13db 100644 --- a/qface/templates/qface/qtcpp.j2 +++ b/qface/templates/qface/qtcpp.j2 @@ -30,7 +30,7 @@ void {{symbol}}{{postfix}}({{symbol|parameters}}); {% macro property_setter_impl(class, property) -%} /*! - \qmlproperty {{property.type}} {{interface}}::{{property}} + \qmlproperty {{property.type}} {{class}}::{{property}} {% with doc = property.comment|parse_doc %} \brief {{doc.brief}} @@ -42,7 +42,7 @@ void {{class}}::set{{property|upperfirst}}({{ property|parameterType }}) { if (m_{{property}} != {{property}}) { m_{{property}} = {{property}}; - emit {{property}}Changed({{property}}); + Q_EMIT {{property}}Changed({{property}}); } } {%- endmacro %} |