Commit 447dc1ef authored by Chuck Lever's avatar Chuck Lever
Browse files

xdrgen: XDR width for pointer types



The XDR width of a pointer type is the sum of the widths of each of
the struct's fields, except for the last field. The width of the
implicit boolean "value follows" field is added as well.

Signed-off-by: default avatarChuck Lever <chuck.lever@oracle.com>
parent f4bc1e99
Loading
Loading
Loading
Loading
+17 −0
Original line number Diff line number Diff line
@@ -378,9 +378,26 @@ class _XdrPointer(_XdrAst):
    name: str
    fields: List[_XdrDeclaration]

    def max_width(self) -> int:
        """Return width of type in XDR_UNITS"""
        width = 1
        for field in self.fields[0:-1]:
            width += field.max_width()
        return width

    def symbolic_width(self) -> List:
        """Return list containing XDR width of type's components"""
        widths = []
        widths += ["XDR_bool"]
        for field in self.fields[0:-1]:
            widths += field.symbolic_width()
        return widths

    def __post_init__(self):
        structs.add(self.name)
        pass_by_reference.add(self.name)
        max_widths[self.name] = self.max_width()
        symbolic_widths[self.name] = self.symbolic_width()


@dataclass