xdrgen: XDR width for variable-length array
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
This commit is contained in:
@@ -220,6 +220,22 @@ class _XdrVariableLengthArray(_XdrDeclaration):
|
||||
maxsize: str
|
||||
template: str = "variable_length_array"
|
||||
|
||||
def max_width(self) -> int:
|
||||
"""Return width of type in XDR_UNITS"""
|
||||
return 1 + (xdr_quadlen(self.maxsize) * max_widths[self.spec.type_name])
|
||||
|
||||
def symbolic_width(self) -> List:
|
||||
"""Return list containing XDR width of type's components"""
|
||||
widths = ["XDR_unsigned_int"]
|
||||
if self.maxsize != "0":
|
||||
item_width = " + ".join(symbolic_widths[self.spec.type_name])
|
||||
widths.append("(" + self.maxsize + " * (" + item_width + "))")
|
||||
return widths
|
||||
|
||||
def __post_init__(self):
|
||||
max_widths[self.name] = self.max_width()
|
||||
symbolic_widths[self.name] = self.symbolic_width()
|
||||
|
||||
|
||||
@dataclass
|
||||
class _XdrOptionalData(_XdrDeclaration):
|
||||
|
||||
Reference in New Issue
Block a user