1627 global_vars.append(tempvar) |
1627 global_vars.append(tempvar) |
1628 return global_vars |
1628 return global_vars |
1629 |
1629 |
1630 # Function that returns the block definition associated to the block type given |
1630 # Function that returns the block definition associated to the block type given |
1631 def GetBlockType(self, typename, inputs=None, debug=False): |
1631 def GetBlockType(self, typename, inputs=None, debug=False): |
1632 result_blocktype = None |
1632 result_blocktype = {} |
1633 for _sectioname, blocktype in self.TotalTypesDict.get(typename, []): |
1633 for _sectioname, blocktype in self.TotalTypesDict.get(typename, []): |
1634 if inputs is not None and inputs != "undefined": |
1634 if inputs is not None and inputs != "undefined": |
1635 block_inputs = tuple([var_type for _name, var_type, _modifier in blocktype["inputs"]]) |
1635 block_inputs = tuple([var_type for _name, var_type, _modifier in blocktype["inputs"]]) |
1636 if reduce(lambda x, y: x and y, map(lambda x: x[0] == "ANY" or self.IsOfType(*x), zip(inputs, block_inputs)), True): |
1636 if reduce(lambda x, y: x and y, map(lambda x: x[0] == "ANY" or self.IsOfType(*x), zip(inputs, block_inputs)), True): |
1637 return blocktype |
1637 return blocktype |
1638 else: |
1638 else: |
1639 if result_blocktype is not None: |
1639 if result_blocktype: |
1640 if inputs == "undefined": |
1640 if inputs == "undefined": |
1641 return None |
1641 return None |
1642 else: |
1642 else: |
1643 result_blocktype["inputs"] = [(i[0], "ANY", i[2]) for i in result_blocktype["inputs"]] |
1643 result_blocktype["inputs"] = [(i[0], "ANY", i[2]) for i in result_blocktype["inputs"]] |
1644 result_blocktype["outputs"] = [(o[0], "ANY", o[2]) for o in result_blocktype["outputs"]] |
1644 result_blocktype["outputs"] = [(o[0], "ANY", o[2]) for o in result_blocktype["outputs"]] |
1645 return result_blocktype |
1645 return result_blocktype |
1646 result_blocktype = blocktype.copy() |
1646 result_blocktype = blocktype.copy() |
1647 if result_blocktype is not None: |
1647 if result_blocktype: |
1648 return result_blocktype |
1648 return result_blocktype |
1649 project = self.GetProject(debug) |
1649 project = self.GetProject(debug) |
1650 if project is not None: |
1650 if project is not None: |
1651 blocktype = project.getpou(typename) |
1651 blocktype = project.getpou(typename) |
1652 if blocktype is not None: |
1652 if blocktype is not None: |