Beispiel #1
0
    def _create_enumeration_of_all_msg_types(self):
        """Create an enumeration type containing all valid message types. These message types are collected from
        records with a msg_type element which has an enumerated data type."""

        msg_type_enumeration_types = []
        for record in self.record_types:
            if record.elements[0].identifier_list[0] == 'msg_type':
                msg_type_enumeration_types.append(
                    record.elements[0].subtype_indication.code)

        msg_type_enumeration_literals = []
        for enum in self.enumeration_types:
            if enum.identifier in msg_type_enumeration_types:
                for literal in enum.literals:
                    if literal in msg_type_enumeration_literals:
                        raise RuntimeError(
                            'Different msg_type enumerations may not have the same literals'
                        )

                    msg_type_enumeration_literals.append(literal)

        if msg_type_enumeration_literals:
            all_msg_types_enumeration_type = CodecVHDLEnumerationType(
                self.identifier + '_msg_type_t', msg_type_enumeration_literals)
        else:
            all_msg_types_enumeration_type = None

        return all_msg_types_enumeration_type, msg_type_enumeration_types
Beispiel #2
0
 def parse(cls, code):
     """
     Return a new VHDLPackage instance for a single package found within the code
     """
     code = remove_comments(code).lower()
     return cls(
         cls._package_start_re.match(code).group('id'),
         list(CodecVHDLEnumerationType.find(code)),
         list(CodecVHDLRecordType.find(code)),
         list(CodecVHDLArrayType.find(code)))
Beispiel #3
0
    def parse(cls, code):
        """
        Return a new VHDLPackage instance for a single package found within the code
        """
        # Extract identifier
        identifier = cls._package_start_re.match(code).group('id')
        enumeration_types = [e for e in CodecVHDLEnumerationType.find(code)]
        record_types = [r for r in CodecVHDLRecordType.find(code)]
        array_types = [a for a in CodecVHDLArrayType.find(code)]

        return cls(identifier, enumeration_types, record_types, array_types)
Beispiel #4
0
    def parse(cls, code):
        """
        Return a new VHDLPackage instance for a single package found within the code
        """
        code = remove_comments(code).lower()
        # Extract identifier
        identifier = cls._package_start_re.match(code).group('id')
        enumeration_types = [e for e in CodecVHDLEnumerationType.find(code)]
        record_types = [r for r in CodecVHDLRecordType.find(code)]
        array_types = [a for a in CodecVHDLArrayType.find(code)]

        return cls(identifier, enumeration_types, record_types, array_types)