Ejemplo n.º 1
0
    def make_member_of(self,
                       module,
                       complex_type,
                       field_type,
                       field_name,
                       visible,
                       wire,
                       auto,
                       enum=None):
        '''
        Default method for making a data type a member of a structure.
        Extend this if the data type needs to add an additional length field or something.

        module is the global module object.
        complex_type is the structure object.
        see Field for the meaning of the other parameters.
        '''
        new_field = Field(self, field_type, field_name, visible, wire, auto,
                          enum)

        # We dump the _placeholder_byte if any fields are added.
        for (idx, field) in enumerate(complex_type.fields):
            if field == _placeholder_byte:
                complex_type.fields[idx] = new_field
                return

        complex_type.fields.append(new_field)
        new_field.parent = complex_type
Ejemplo n.º 2
0
 def add_event_header():
     self.fields.append(
         Field(tcard8, tcard8.name, 'response_type', False, True, True))
     if self.has_seq:
         self.fields.append(_placeholder_byte)
         self.fields.append(
             Field(tcard16, tcard16.name, 'sequence', False, True,
                   True))
Ejemplo n.º 3
0
    def resolve(self, module):
        if self.resolved:
            return

        # Add the automatic protocol fields
        self.fields.append(Field(tcard8, tcard8.name, 'response_type', False, True, True))
        self.fields.append(Field(tcard8, tcard8.name, 'error_code', False, True, True))
        self.fields.append(Field(tcard16, tcard16.name, 'sequence', False, True, True))
        ComplexType.resolve(self, module)
Ejemplo n.º 4
0
 def resolve(self, module):
     if self.resolved:
         return
     # Add the automatic protocol fields
     self.fields.append(Field(tcard8, tcard8.name, 'response_type', False, True, True))
     self.fields.append(_placeholder_byte)
     self.fields.append(Field(tcard16, tcard16.name, 'sequence', False, True, True))
     self.fields.append(Field(tcard32, tcard32.name, 'length', False, True, True))
     ComplexType.resolve(self, module)
Ejemplo n.º 5
0
 def add_ge_event_header():
     self.fields.append(
         Field(tcard8, tcard8.name, 'response_type', False, True, True))
     self.fields.append(
         Field(tcard8, tcard8.name, 'extension', False, True, True))
     self.fields.append(
         Field(tcard16, tcard16.name, 'sequence', False, True, True))
     self.fields.append(
         Field(tcard32, tcard32.name, 'length', False, True, True))
     self.fields.append(
         Field(tcard16, tcard16.name, 'event_type', False, True, True))
Ejemplo n.º 6
0
    def make_member_of(self,
                       module,
                       switch_type,
                       field_type,
                       field_name,
                       visible,
                       wire,
                       auto,
                       enum=None):
        '''
        register BitcaseType with the corresponding SwitchType

        module is the global module object.
        complex_type is the structure object.
        see Field for the meaning of the other parameters.
        '''
        new_field = Field(self, field_type, field_name, visible, wire, auto,
                          enum)

        # We dump the _placeholder_byte if any bitcases are added.
        for (idx, field) in enumerate(switch_type.bitcases):
            if field == _placeholder_byte:
                switch_type.bitcases[idx] = new_field
                return

        switch_type.bitcases.append(new_field)
Ejemplo n.º 7
0
    def resolve(self, module):
        if self.resolved:
            return
        # Add the automatic protocol fields
        if module.namespace.is_ext:
            self.fields.append(Field(tcard8, tcard8.name, 'major_opcode', False, True, True))
            self.fields.append(Field(tcard8, tcard8.name, 'minor_opcode', False, True, True))
            self.fields.append(Field(tcard16, tcard16.name, 'length', False, True, True))
            ComplexType.resolve(self, module)
        else:
            self.fields.append(Field(tcard8, tcard8.name, 'major_opcode', False, True, True))
            self.fields.append(_placeholder_byte)
            self.fields.append(Field(tcard16, tcard16.name, 'length', False, True, True))
            ComplexType.resolve(self, module)

        if self.reply:
            self.reply.resolve(module)
    def make_member_of(self, module, complex_type, field_type, field_name, visible, wire, auto, enum=None):
        '''
        Default method for making a data type a member of a structure.
        Extend this if the data type needs to add an additional length field or something.

        module is the global module object.
        complex_type is the structure object.
        see Field for the meaning of the other parameters.
        '''
        new_field = Field(self, field_type, field_name, visible, wire, auto, enum)

        # We dump the _placeholder_byte if any fields are added.
        for (idx, field) in enumerate(complex_type.fields):
            if field == _placeholder_byte:
                complex_type.fields[idx] = new_field
                return

        complex_type.fields.append(new_field)
        new_field.parent = complex_type
Ejemplo n.º 9
0
    def make_fd_of(self, module, complex_type, fd_name):
        '''
        Method for making a fd member of a structure.
        '''
        new_fd = Field(self, module.get_type_name('INT32'), fd_name, True, False, False, None, True)
        # We dump the _placeholder_byte if any fields are added.
        for (idx, field) in enumerate(complex_type.fields):
            if field == _placeholder_byte:
                complex_type.fields[idx] = new_fd
                return

        complex_type.fields.append(new_fd)
Ejemplo n.º 10
0
    '''
    Class representing a <doc> tag.
    '''
    def __init__(self, name, elt):
        self.name = name
        self.description = None
        self.brief = 'BRIEF DESCRIPTION MISSING'
        self.fields = {}
        self.errors = {}
        self.see = {}
        self.example = None

        for child in list(elt):
            text = child.text if child.text else ''
            if child.tag == 'description':
                self.description = text.strip()
            if child.tag == 'brief':
                self.brief = text.strip()
            if child.tag == 'field':
                self.fields[child.get('name')] = text.strip()
            if child.tag == 'error':
                self.errors[child.get('type')] = text.strip()
            if child.tag == 'see':
                self.see[child.get('name')] = child.get('type')
            if child.tag == 'example':
                self.example = text.strip()



_placeholder_byte = Field(PadType(None), tcard8.name, 'pad0', False, True, False)