Esempio n. 1
0
    def get_member_info(node):
        """Return information of a member or field from a member element.

        A `member` element must have three attributes: `name`, `offset`,
        and `type`. Other attributes such as `mask` or `format' are optional.

        Args:
          node (xml.dom.Node): A `<member>` DOM element.

        Returns:
          (AbstractField): An instance which has information of the member or
            field.
        """

        attrs = {}

        attr_name = node.getAttribute('name')
        attr_type = node.getAttribute('type')
        attrs['offset'] = get_int(node.getAttribute('offset'))

        attr_mask = get_int(node.getAttribute('mask'))
        if attr_mask:
            attrs['mask'] = attr_mask

        attr_format = node.getAttribute('format')
        if format:
            attrs['format'] = attr_format

        # pylint: disable=star-args
        return make_field(attr_name, attr_type, **attrs)
Esempio n. 2
0
    def test_make_field_for_longfield(self):
        """Test function dqutils.database.field.make_field."""

        for i in ("long", "address", "3byte"):
            self.assertIsInstance(make_field("X", i, **self.params), LongField)
Esempio n. 3
0
    def test_make_field_for_wordfield(self):
        """Test function dqutils.database.field.make_field."""

        for i in ("word", "2byte"):
            self.assertIsInstance(make_field("X", i, **self.params), WordField)
Esempio n. 4
0
    def test_make_field_for_bytefield(self):
        """Test function dqutils.database.field.make_field."""

        for i in ("byte", "bytes", "1byte"):
            self.assertIsInstance(make_field("X", i, **self.params), ByteField)
Esempio n. 5
0
    def test_make_field_for_bitfield(self):
        """Test function dqutils.database.field.make_field."""

        for i in ("bit", "bits"):
            self.assertIsInstance(make_field("X", i, **self.params), BitField)