How to use the qface.idl.domain.Symbol 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 / qface / idl / domain.py View on Github external
symbol = self._contentMap[name]
            if fragment:
                return symbol._contentMap[fragment]
            return symbol
        return self.system.lookup(name)

    def toJson(self):
        o = super().toJson()
        o['version'] = self.version
        o['interfaces'] = [s.toJson() for s in self.interfaces]
        o['structs'] = [s.toJson() for s in self.structs]
        o['enums'] = [s.toJson() for s in self.enums]
        return o


class Interface(Symbol):
    """A interface is an object with operations, properties and signals"""
    def __init__(self, name: str, module: Module):
        super().__init__(name, module)
        log.debug('Interface()')
        self.module._interfaceMap[name] = self
        self._propertyMap = OrderedDict()  # type: dict[str, Property]
        self._operationMap = OrderedDict()  # type: dict[str, Operation]
        self._signalMap = OrderedDict()  # type: dict[str, Signal]
        self._contentMap = ChainMap(self._propertyMap, self._operationMap, self._signalMap)
        self._extends = None

    @property
    def properties(self):
        '''returns ordered list of properties'''
        return self._propertyMap.values()
github Pelagicore / qface / qface / idl / domain.py View on Github external
def toJson(self):
        o = super().toJson()
        o['parameters'] = [s.toJson() for s in self.parameters]
        return o


class Parameter(Symbol):
    """An operation parameter"""
    def __init__(self, name: str, operation: Operation):
        super().__init__(name, operation.module)
        log.debug('Parameter()')
        self.operation = operation
        self.operation._parameterMap[name] = self


class Property(Symbol):
    """A typed property inside a interface"""
    def __init__(self, name: str, interface: Interface):
        super().__init__(name, interface.module)
        log.debug('Property()')
        self.interface = interface
        self.interface._propertyMap[name] = self
        self.readonly = False
        self.const = False

    @property
    def is_model(self):
        ''' true if type is a model '''
        return self.type.is_model

    @property
    def is_primitive_model(self):
github Pelagicore / qface / qface / idl / domain.py View on Github external
    @property
    def members(self):
        '''returns ordered list of members'''
        return self._memberMap.values()

    def toJson(self):
        o = super().toJson()
        if self.is_enum:
            o['enum'] = self.is_enum
        if self.is_flag:
            o['flag'] = self.is_flag
        o['members'] = [s.toJson() for s in self.members]
        return o


class EnumMember(Symbol):
    """A enum value"""
    def __init__(self, name: str, enum: Enum):
        super().__init__(name, enum.module)
        log.debug('EnumMember()')
        self.enum = enum
        self.enum._memberMap[name] = self
        self.value = 0

    def qualified_name(self):
        '''return the fully qualified name (`.#`)'''
        return '{0}.{1}#{2}'.format(self.module.name, self.enum.name, self.name)

    def toJson(self):
        o = super().toJson()
        o['value'] = self.value
        return o
github Pelagicore / qface / qface / idl / domain.py View on Github external
return '{0}.{1}#{2}'.format(self.module.name, self.interface.name, self.name)

    @property
    def writeable(self):
        return not self.readonly and not self.const

    def toJson(self):
        o = super().toJson()
        if self.readonly:
            o['readonly'] = True
        if self.const:
            o['const'] = True
        return o


class Struct(Symbol):
    """Represents a data container"""
    def __init__(self, name: str, module: Module):
        super().__init__(name, module)
        log.debug('Struct()')
        self.module._structMap[name] = self
        self._fieldMap = self._contentMap = OrderedDict()

    @property
    def fields(self):
        '''returns ordered list of members'''
        return self._fieldMap.values()

    def toJson(self):
        o = super().toJson()
        o['fields'] = [s.toJson() for s in self.fields]
        return o
github Pelagicore / qface / qface / idl / domain.py View on Github external
'''return the fully qualified name (`.#`)'''
        return '{0}.{1}#{2}'.format(self.module.name, self.interface.name, self.name)

    @property
    def parameters(self):
        '''returns ordered list of parameters'''
        return self._parameterMap.values()

    def toJson(self):
        o = super().toJson()
        o['parameters'] = [s.toJson() for s in self.parameters]
        o['type'] = self.type.toJson()
        return o


class Signal(Symbol):
    """A signal inside an interface"""
    def __init__(self, name: str, interface: Interface):
        super().__init__(name, interface.module)
        log.debug('Signal()')
        self.interface = interface
        self.interface._signalMap[name] = self
        self._parameterMap = self._contentMap = OrderedDict()  # type: dict[Parameter]

    @property
    def qualified_name(self):
        '''return the fully qualified name (`module + "." + name`)'''
        return '{0}.{1}#{2}'.format(self.module.name, self.interface.name, self.name)

    @property
    def parameters(self):
        '''returns ordered list of parameters'''
github Pelagicore / qface / qface / idl / domain.py View on Github external
def qualified_name(self):
        '''return the fully qualified name (`module + "." + name`)'''
        return '{0}.{1}#{2}'.format(self.module.name, self.interface.name, self.name)

    @property
    def parameters(self):
        '''returns ordered list of parameters'''
        return self._parameterMap.values()

    def toJson(self):
        o = super().toJson()
        o['parameters'] = [s.toJson() for s in self.parameters]
        return o


class Parameter(Symbol):
    """An operation parameter"""
    def __init__(self, name: str, operation: Operation):
        super().__init__(name, operation.module)
        log.debug('Parameter()')
        self.operation = operation
        self.operation._parameterMap[name] = self


class Property(Symbol):
    """A typed property inside a interface"""
    def __init__(self, name: str, interface: Interface):
        super().__init__(name, interface.module)
        log.debug('Property()')
        self.interface = interface
        self.interface._propertyMap[name] = self
        self.readonly = False
github Pelagicore / qface / qface / idl / domain.py View on Github external
class Field(Symbol):
    """A member in a struct"""
    def __init__(self, name: str, struct: Struct):
        super().__init__(name, struct.module)
        log.debug('Field()')
        self.struct = struct  # type:Struct
        self.struct._fieldMap[name] = self

    @property
    def qualified_name(self):
        '''return the fully qualified name (`.#`)'''
        return '{0}.{1}#{2}'.format(self.module.name, self.struct.name, self.name)



class Enum(Symbol):
    """An enum (flag) inside a module"""
    def __init__(self, name: str, module: Module):
        super().__init__(name, module)
        log.debug('Enum()')
        self.is_enum = True
        self.is_flag = False
        self.module._enumMap[name] = self
        self._memberMap = self._contentMap = OrderedDict()  # type: dict[EnumMember]

    @property
    def members(self):
        '''returns ordered list of members'''
        return self._memberMap.values()

    def toJson(self):
        o = super().toJson()
github Pelagicore / qface / qface / idl / domain.py View on Github external
if self.is_primitive:
            o['primitive'] = self.is_primitive
        if self.is_complex:
            o['complex'] = self.is_complex
        if self.is_list:
            o['list'] = self.is_list
        if self.is_map:
            o['map'] = self.is_map
        if self.is_model:
            o['model'] = self.is_model
        if self.nested:
            o['nested'] = self.nested.toJson()
        return o


class Module(Symbol):
    """Module is a namespace for types, e.g. interfaces, enums, structs"""
    def __init__(self, name: str, system: System):
        """init"""
        super().__init__(name, self)
        log.debug('Module()')
        self.version = '1.0'
        self._system = system
        self._system._moduleMap[name] = self
        self._interfaceMap = OrderedDict()  # type: dict[str, Interface]
        self._structMap = OrderedDict()  # type: dict[str, Struct]
        self._enumMap = OrderedDict()  # type: dict[str, Enum]
        self._contentMap = ChainMap(self._interfaceMap, self._structMap, self._enumMap)
        self._importMap = OrderedDict()  # type: dict[str, Module]

    @property
    def interfaces(self):
github Pelagicore / qface / qface / idl / domain.py View on Github external
return self._signalMap.values()

    @property
    def extends(self):
        ''' returns the symbol defined by the extends interface attribute '''
        return self.module.lookup(self._extends)

    def toJson(self):
        o = super().toJson()
        o['properties'] = [s.toJson() for s in self.properties]
        o['operations'] = [s.toJson() for s in self.operations]
        o['signals'] = [s.toJson() for s in self.signals]
        return o


class Operation(Symbol):
    """An operation inside a interface"""
    def __init__(self, name: str, interface: Interface):
        super().__init__(name, interface.module)
        log.debug('Operation()')
        self.interface = interface
        """ the interface the operation is part of """
        self.interface._operationMap[name] = self
        self._parameterMap = self._contentMap = OrderedDict()  # type: dict[Parameter]
        self.is_const = False  # type: bool
        """reflects is the operation was declared as const operation"""

    @property
    def qualified_name(self):
        '''return the fully qualified name (`.#`)'''
        return '{0}.{1}#{2}'.format(self.module.name, self.interface.name, self.name)
github Pelagicore / qface / qface / idl / domain.py View on Github external
log.debug('Struct()')
        self.module._structMap[name] = self
        self._fieldMap = self._contentMap = OrderedDict()

    @property
    def fields(self):
        '''returns ordered list of members'''
        return self._fieldMap.values()

    def toJson(self):
        o = super().toJson()
        o['fields'] = [s.toJson() for s in self.fields]
        return o


class Field(Symbol):
    """A member in a struct"""
    def __init__(self, name: str, struct: Struct):
        super().__init__(name, struct.module)
        log.debug('Field()')
        self.struct = struct  # type:Struct
        self.struct._fieldMap[name] = self

    @property
    def qualified_name(self):
        '''return the fully qualified name (`.#`)'''
        return '{0}.{1}#{2}'.format(self.module.name, self.struct.name, self.name)



class Enum(Symbol):
    """An enum (flag) inside a module"""