pyloxi: move OFType interface functions to module level
This removes the need to replace the LOXI IR OFType object in members with our
own version. If/when the core OFType is upgraded to an inheritance hierachy we
won't need to duplicate it in pyloxi.
diff --git a/py_gen/templates/_unpack.py b/py_gen/templates/_unpack.py
index 211043e..133e831 100644
--- a/py_gen/templates/_unpack.py
+++ b/py_gen/templates/_unpack.py
@@ -27,6 +27,7 @@
::
:: # TODO coalesce format strings
:: from loxi_ir import *
+:: from py_gen.oftype import gen_unpack_expr
if type(buf) == loxi.generic_util.OFReader:
reader = buf
else:
@@ -36,12 +37,12 @@
:: if type(m) == OFPadMember:
reader.skip(${m.length})
:: elif type(m) == OFLengthMember:
- _${m.name} = ${m.oftype.gen_unpack_expr('reader')}
+ _${m.name} = ${gen_unpack_expr(m.oftype, 'reader')}
:: elif type(m) == OFFieldLengthMember:
:: field_length_members[m.field_name] = m
- _${m.name} = ${m.oftype.gen_unpack_expr('reader')}
+ _${m.name} = ${gen_unpack_expr(m.oftype, 'reader')}
:: elif type(m) == OFTypeMember:
- _${m.name} = ${m.oftype.gen_unpack_expr('reader')}
+ _${m.name} = ${gen_unpack_expr(m.oftype, 'reader')}
assert(_${m.name} == ${m.value})
:: elif type(m) == OFDataMember:
:: if m.name in field_length_members:
@@ -49,7 +50,7 @@
:: else:
:: reader_expr = 'reader'
:: #endif
- obj.${m.name} = ${m.oftype.gen_unpack_expr(reader_expr)}
+ obj.${m.name} = ${gen_unpack_expr(m.oftype, reader_expr)}
:: #endif
:: #endfor
:: if ofclass.name == 'of_match_v3':