How to use the qface.helper.qtcpp.Filters.parameterType 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
types = {
        'bool': 'bool {0}'.format(name),
        'int': 'int {0}'.format(name),
        'real': 'qreal {0}'.format(name),
        'string': 'const QString &{0}'.format(name),
        'var': 'const QVariant &{0}'.format(name)
    }

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

    # check for struct
    prop = interface._propertyMap['message']
    answer = qtcpp.Filters.parameterType(prop)
    assert answer == 'const Message &{0}'.format(prop.name)
    # check for enum
    prop = interface._propertyMap['status']
    answer = qtcpp.Filters.parameterType(prop)
    assert answer == 'Status::StatusEnum {0}'.format(prop.name)

    # check for list of primitive
    prop = interface._propertyMap['list001']
    answer = qtcpp.Filters.parameterType(prop)
    assert answer == 'const QVariantList &{0}'.format(prop.name)

    # check for list of structs
    prop = interface._propertyMap['list002']
    answer = qtcpp.Filters.parameterType(prop)
    assert answer == 'const QVariantList &{0}'.format(prop.name)
github Pelagicore / qface / tests / test_qtcpp_helper.py View on Github external
'string': 'const QString &{0}'.format(name),
        'var': 'const QVariant &{0}'.format(name)
    }

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

    # check for struct
    prop = interface._propertyMap['message']
    answer = qtcpp.Filters.parameterType(prop)
    assert answer == 'const Message &{0}'.format(prop.name)
    # check for enum
    prop = interface._propertyMap['status']
    answer = qtcpp.Filters.parameterType(prop)
    assert answer == 'Status::StatusEnum {0}'.format(prop.name)

    # check for list of primitive
    prop = interface._propertyMap['list001']
    answer = qtcpp.Filters.parameterType(prop)
    assert answer == 'const QVariantList &{0}'.format(prop.name)

    # check for list of structs
    prop = interface._propertyMap['list002']
    answer = qtcpp.Filters.parameterType(prop)
    assert answer == 'const QVariantList &{0}'.format(prop.name)

    # check for model of primitive
    prop = interface._propertyMap['model001']
    answer = qtcpp.Filters.parameterType(prop)
    assert answer == 'QAbstractItemModel *{0}'.format(prop.name)
github Pelagicore / qface / tests / test_qtcpp_helper.py View on Github external
operation = interface._operationMap['echo']
    assert operation
    parameter = operation._parameterMap['message']
    name = parameter.name

    types = {
        'bool': 'bool {0}'.format(name),
        'int': 'int {0}'.format(name),
        'real': 'qreal {0}'.format(name),
        'string': 'const QString &{0}'.format(name),
        'var': 'const QVariant &{0}'.format(name)
    }

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

    # check for struct
    prop = interface._propertyMap['message']
    answer = qtcpp.Filters.parameterType(prop)
    assert answer == 'const Message &{0}'.format(prop.name)
    # check for enum
    prop = interface._propertyMap['status']
    answer = qtcpp.Filters.parameterType(prop)
    assert answer == 'Status::StatusEnum {0}'.format(prop.name)

    # check for list of primitive
    prop = interface._propertyMap['list001']
    answer = qtcpp.Filters.parameterType(prop)
    assert answer == 'const QVariantList &{0}'.format(prop.name)
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)
        generator.write('generated/generated.pri', 'generated/generated.pri', ctx)
github Pelagicore / qface / qface / helper / qtcpp.py View on Github external
def get_filters():
        return {
            'qt.defaultValue': Filters.defaultValue,
            'qt.returnType': Filters.returnType,
            'qt.parameterType': Filters.parameterType,
            'qt.open_ns': Filters.open_ns,
            'qt.close_ns': Filters.close_ns,
            'qt.using_ns': Filters.using_ns,
            'qt.ns': Filters.ns,
            'qt.fqn': Filters.fqn,
            'qt.signalName': Filters.signalName,
            'qt.parameters': Filters.parameters,
            'qt.signature': Filters.signature,
            'qt.identifier': Filters.identifier,
            'qt.path': Filters.path,
            'qt.className': Filters.className,
            'qt.source_dependencies': Filters.source_dependencies,
            'qt.header_dependencies': Filters.header_dependencies,
        }
github Pelagicore / qface / qface / helper / qtcpp.py View on Github external
def parameters(env, s, filter=None, spaces=True):
        if not filter:
            filter = Filters.parameterType
        elif isinstance(filter, str):
            filter = env.filters[filter]
        args = []
        indent = ', '
        if not spaces:
            indent = ','
        if isinstance(s, domain.Operation):
            args = s.parameters
        elif isinstance(s, domain.Signal):
            args = s.parameters
        elif isinstance(s, domain.Struct):
            args = s.fields
        elif isinstance(s, domain.Property):
            args = [s]
        return indent.join([filter(a) for a in args])