xdrgen: XDR widths for enum types

RFC 4506 says that an XDR enum is represented as a signed integer
on the wire; thus its width is 1 XDR_UNIT.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
This commit is contained in:
Chuck Lever
2024-10-03 14:54:34 -04:00
parent 631c2925ba
commit 3f890755c8
+12
View File
@@ -227,6 +227,18 @@ class _XdrEnum(_XdrAst):
maximum: int
enumerators: List[_XdrEnumerator]
def max_width(self) -> int:
"""Return width of type in XDR_UNITS"""
return 1
def symbolic_width(self) -> List:
"""Return list containing XDR width of type's components"""
return ["XDR_int"]
def __post_init__(self):
max_widths[self.name] = self.max_width()
symbolic_widths[self.name] = self.symbolic_width()
@dataclass
class _XdrStruct(_XdrAst):