summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChuck Lever <chuck.lever@oracle.com>2024-10-03 21:54:32 +0300
committerChuck Lever <chuck.lever@oracle.com>2024-11-11 21:42:01 +0300
commit189f55d93d3eb76d733c28f0c70fd2d162a9ffc5 (patch)
treef75bcdf52d5f620a0325e204e45fb104940501ee
parent1acd13cbc7c9c69a09e5d8325cf6c3e3f0a75049 (diff)
downloadlinux-189f55d93d3eb76d733c28f0c70fd2d162a9ffc5.tar.xz
xdrgen: Track constant values
In order to compute the numeric on-the-wire width of XDR types, xdrgen needs to keep track of the numeric value of constants that are defined in the input specification so it can perform calculations with those values. Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
-rw-r--r--tools/net/sunrpc/xdrgen/xdr_ast.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/tools/net/sunrpc/xdrgen/xdr_ast.py b/tools/net/sunrpc/xdrgen/xdr_ast.py
index 68f09945f2c4..b7df45f47707 100644
--- a/tools/net/sunrpc/xdrgen/xdr_ast.py
+++ b/tools/net/sunrpc/xdrgen/xdr_ast.py
@@ -19,6 +19,8 @@ public_apis = []
structs = set()
pass_by_reference = set()
+constants = {}
+
@dataclass
class _XdrAst(ast_utils.Ast):
@@ -156,6 +158,10 @@ class _XdrConstant(_XdrAst):
name: str
value: str
+ def __post_init__(self):
+ if self.value not in constants:
+ constants[self.name] = int(self.value, 0)
+
@dataclass
class _XdrEnumerator(_XdrAst):
@@ -164,6 +170,10 @@ class _XdrEnumerator(_XdrAst):
name: str
value: str
+ def __post_init__(self):
+ if self.value not in constants:
+ constants[self.name] = int(self.value, 0)
+
@dataclass
class _XdrEnum(_XdrAst):