How to use the qface.helper.qtcpp.Filters.returnType function in qface

To help you get started, we’ve selected a few qface examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Pelagicore / qface / tests / test_qtcpp_helper.py View on Github external
assert interface
    operation = interface._operationMap['echo']
    assert operation
    parameter = operation._parameterMap['message']

    types = {
        'bool': 'bool',
        'int': 'int',
        'real': 'qreal',
        'string': 'QString',
        'var': 'QVariant'
    }

    for key, value in types.items():
        parameter.type.name = key
        answer = qtcpp.Filters.returnType(parameter)
        assert answer == value

    # check for struct
    prop = interface._propertyMap['message']
    answer = qtcpp.Filters.returnType(prop)
    assert answer == 'Message'
    # check for enum
    prop = interface._propertyMap['status']
    answer = qtcpp.Filters.returnType(prop)
    assert answer == 'Status::StatusEnum'

    # check for list of primitive
    prop = interface._propertyMap['list001']
    answer = qtcpp.Filters.returnType(prop)
    assert answer == 'QVariantList'
github Pelagicore / qface / tests / test_qtcpp_helper.py View on Github external
'string': 'QString',
        'var': 'QVariant'
    }

    for key, value in types.items():
        parameter.type.name = key
        answer = qtcpp.Filters.returnType(parameter)
        assert answer == value

    # check for struct
    prop = interface._propertyMap['message']
    answer = qtcpp.Filters.returnType(prop)
    assert answer == 'Message'
    # check for enum
    prop = interface._propertyMap['status']
    answer = qtcpp.Filters.returnType(prop)
    assert answer == 'Status::StatusEnum'

    # check for list of primitive
    prop = interface._propertyMap['list001']
    answer = qtcpp.Filters.returnType(prop)
    assert answer == 'QVariantList'

    # check for list of structs
    prop = interface._propertyMap['list002']
    answer = qtcpp.Filters.returnType(prop)
    assert answer == 'QVariantList'

    # check for model of primitive
    prop = interface._propertyMap['model001']
    answer = qtcpp.Filters.returnType(prop)
    assert answer == 'QAbstractItemModel *'
github Pelagicore / qface / tests / test_qtcpp_helper.py View on Github external
answer = qtcpp.Filters.returnType(prop)
    assert answer == 'QVariantList'

    # check for list of structs
    prop = interface._propertyMap['list002']
    answer = qtcpp.Filters.returnType(prop)
    assert answer == 'QVariantList'

    # check for model of primitive
    prop = interface._propertyMap['model001']
    answer = qtcpp.Filters.returnType(prop)
    assert answer == 'QAbstractItemModel *'

    # check for model of structs
    prop = interface._propertyMap['model002']
    answer = qtcpp.Filters.returnType(prop)
    assert answer == 'QAbstractItemModel *'
github qt / qtivi / src / tools / ivigenerator / generate.py View on Github external
return 'QString()'
        if t.is_real:
            return 'qreal(0.0)'
        if t.is_var:
            return 'QVariant()'
    elif t.is_void:
        return ''
    elif t.is_enum:
        module_name = t.reference.module.module_name
        value = next(iter(t.reference.members))
        return '{0}{1}Module::{2}'.format(prefix, upper_first(module_name), value)
    elif t.is_flag:
        module_name = t.reference.module.module_name
        return '{0}{1}Module::{2}()'.format(prefix, upper_first(module_name), flag_type(symbol))
    elif symbol.type.is_list:
        nested = Filters.returnType(symbol.type.nested)
        return 'QVariantList()'.format(nested)
    elif symbol.type.is_struct:
        return '{0}{1}()'.format(prefix, symbol.type)
    elif symbol.type.is_model:
        return 'nullptr'
    jinja_error('default_type_value: Unknown parameter {0} of type {1}'.format(symbol, symbol.type))
github Pelagicore / qface / qface / builtin / qtcpp / qtcpp.py View on Github external
def run(src, dst):
    log.debug('run {0} {1}'.format(src, dst))
    system = FileSystem.parse(src)
    generator = Generator(search_path=here / 'templates')
    generator.register_filter('returnType', Filters.returnType)
    generator.register_filter('parameterType', Filters.parameterType)
    generator.register_filter('defaultValue', Filters.defaultValue)
    generator.register_filter('parameters', Filters.parameters)
    generator.register_filter('parse_doc', parse_doc)
    ctx = {'dst': dst}
    for module in system.modules:
        log.debug('generate code for module %s', module)
        ctx.update({'module': module})
        dst = generator.apply('{{dst}}/{{module|lower|replace(".", "-")}}', ctx)
        generator.destination = dst
        generator.write('.qmake.conf', 'qmake.conf', ctx)
        generator.write('{{module|lower|replace(".", "-")}}.pro', 'plugin.pro', ctx, preserve=True)
        generator.write('CMakeLists.txt', 'CMakeLists.txt', ctx)
        generator.write('plugin.cpp', 'plugin.cpp', ctx, preserve=True)
        generator.write('plugin.h', 'plugin.h', ctx, preserve=True)
        generator.write('qmldir', 'qmldir', ctx, preserve=True)
github Pelagicore / qface / qface / helper / qtcpp.py View on Github external
if t.is_string:
                return 'QString'
            if t.is_var:
                return 'QVariant'
            if t.is_real:
                return 'qreal'
            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)
        elif symbol.type.is_model:
            return 'QAbstractItemModel *'
        elif symbol.type.is_complex:
            if symbol.type.is_interface:
                return '{0}Base *'.format(symbol.type)
            else:
                return '{0}{1}'.format(prefix, symbol.type)
        raise Exception("Unknown symbol type")
github Pelagicore / qface / qface / helper / qtcpp.py View on Github external
def signature(env, s, expand=False, filter=None):
        if not filter:
            filter = Filters.returnType
        elif isinstance(filter, str):
            filter = env.filters[filter]
        if isinstance(s, domain.Operation):
            args = s.parameters
        elif isinstance(s, domain.Signal):
            args = s.parameters
        elif isinstance(s, domain.Property):
            args = [s]  # for Changed()
        elif isinstance(s, domain.Struct):
            args = s.fields
        else:
            args = []
        if expand:
            return ', '.join(['{0} {1}'.format(filter(a), a.name) for a in args])
        return ','.join([filter(a) for a in args])