general: add support for declaring enums as struct members
the enum types are resolved to the wiretypes for the benefit of c-loxi.
diff --git a/loxi_utils/loxi_utils.py b/loxi_utils/loxi_utils.py
index f5f9b63..601a65d 100644
--- a/loxi_utils/loxi_utils.py
+++ b/loxi_utils/loxi_utils.py
@@ -36,6 +36,7 @@
import sys
import of_g
import tenjin
+from generic_utils import find, memoize
def class_signature(members):
"""
@@ -517,6 +518,17 @@
with open(template_filename) as infile:
out.write(infile.read())
+@memoize
+def lookup_ir_wiretype(oftype, version):
+ """ if of is a reference to an enum in ir, resolve it to the wiretype
+ declared in that enum. Else return oftype """
+ enums = of_g.ir[version].enums
+ enum = find(lambda e: e.name == oftype, enums)
+ if enum and 'wire_type' in enum.params:
+ return enum.params['wire_type']
+ else:
+ return oftype
+
class TemplateEngine(tenjin.Engine):
def include(self, template_name, **kwargs):
"""