class Param(Element):
- def __init__(self, block, n, types):
+ def __init__(self, block, n):
"""
Make a new param from nested data.
@param block the parent element
@param n the nested odict
- @param types a list of possible types
"""
- self._types = types
#grab the data
self._name = n.find('name')
self._key = n.find('key')
The value must be evaluated and type must a possible type.
"""
Element.validate(self)
- try: assert self.get_type() in self._types
+ try: assert self.get_type() in self.get_types()
except AssertionError: self.add_error_message('Type "%s" is not a possible type.'%self.get_type())
def get_evaluated(self): raise NotImplementedError
"""
raise NotImplementedError
+ def get_types(self):
+ """
+ Get a list of all possible param types.
+ @throw NotImplementedError
+ """
+ raise NotImplementedError
+
def get_color(self): return '#FFFFFF'
def __str__(self): return 'Param - %s(%s)'%(self.get_name(), self.get_key())
def is_param(self): return True
class Port(Element):
- def __init__(self, block, n, dir, types):
+ def __init__(self, block, n, dir):
"""
Make a new port from nested data.
@param block the parent element
@param n the nested odict
@param dir the direction source or sink
- @param types a list of possible types
"""
- self._types = types
#build the port
Element.__init__(self, block)
#grab the data
The port must be non-empty and type must a possible type.
"""
Element.validate(self)
- try: assert self.get_type() in self._types
+ try: assert self.get_type() in self.get_types()
except AssertionError: self.add_error_message('Type "%s" is not a possible type.'%self.get_type())
def __str__(self):
if self.is_sink():
return 'Sink - %s(%s)'%(self.get_name(), self.get_key())
+ def get_types(self):
+ """
+ Get a list of all possible port types.
+ @throw NotImplementedError
+ """
+ raise NotImplementedError
+
def is_port(self): return True
def get_color(self): return '#FFFFFF'
def get_name(self): return self._name
REAL_TYPES = tuple(REAL_TYPES + INT_TYPES)
INT_TYPES = tuple(INT_TYPES)
-##possible param types
-TYPES = [
- 'raw', 'enum',
- 'complex', 'real', 'int',
- 'complex_vector', 'real_vector', 'int_vector',
- 'hex', 'string', 'bool',
- 'file_open', 'file_save',
- 'id', 'stream_id',
- 'grid_pos', 'notebook',
- 'import',
-]
-
class Param(_Param):
- _init = False
- _hostage_cells = list()
-
- def __init__(self, block, n, **kwargs):
+ def __init__(self, block, n):
_Param.__init__(
self,
block=block,
n=n,
- types=TYPES,
)
+ self._init = False
+ self._hostage_cells = list()
+
+ def get_types(self): return (
+ 'raw', 'enum',
+ 'complex', 'real', 'int',
+ 'complex_vector', 'real_vector', 'int_vector',
+ 'hex', 'string', 'bool',
+ 'file_open', 'file_save',
+ 'id', 'stream_id',
+ 'grid_pos', 'notebook',
+ 'import',
+ )
def __repr__(self):
"""
)
except: raise Exception, 'Could not resolve source for virtual source port %s'%vsp
-##possible port types
-TYPES = ['complex', 'float', 'int', 'short', 'byte', 'msg', '']
-
class Port(_Port):
- def __init__(self, block, n, dir, **kwargs):
+ def __init__(self, block, n, dir):
"""
Make a new port from nested data.
@param block the parent element
block=block,
n=n,
dir=dir,
- types=TYPES,
)
self._nports = n.find('nports') or ''
self._vlen = n.find('vlen') or ''
self._optional = bool(n.find('optional'))
+ def get_types(self): return ('complex', 'float', 'int', 'short', 'byte', 'msg', '')
+
def validate(self):
_Port.validate(self)
try: assert self.get_enabled_connections() or self.get_optional()