frontend: add name to OFInput
Just useful for debugging.
diff --git a/loxi_front_end/frontend.py b/loxi_front_end/frontend.py
index f4dece5..6746584 100644
--- a/loxi_front_end/frontend.py
+++ b/loxi_front_end/frontend.py
@@ -62,7 +62,7 @@
else:
raise InputError("Dont know how to create member: %s" % m_ast[0])
-def create_ofinput(ast):
+def create_ofinput(name, ast):
"""
Create an OFInput from an AST
@@ -72,7 +72,7 @@
@returns An OFInput object
"""
ctx = FrontendCtx(set())
- ofinput = OFInput(wire_versions=set(), classes=[], enums=[])
+ ofinput = OFInput(name, wire_versions=set(), classes=[], enums=[])
for decl_ast in ast:
if decl_ast[0] == 'struct':
diff --git a/loxi_ir.py b/loxi_ir.py
index a70f041..0fe5497 100644
--- a/loxi_ir.py
+++ b/loxi_ir.py
@@ -47,11 +47,12 @@
"""
One input file
+@param name Name of the input file
@param wire_versions Set of integer wire versions this file applies to
@param classes List of OFClass objects in the same order as in the file
@param enums List of Enum objects in the same order as in the file
"""
-OFInput = namedtuple('OFInput', ['wire_versions', 'classes', 'enums'])
+OFInput = namedtuple('OFInput', ['name', 'wire_versions', 'classes', 'enums'])
"""
One version of the OpenFlow protocol
diff --git a/loxigen.py b/loxigen.py
index 7b78f63..31214ba 100755
--- a/loxigen.py
+++ b/loxigen.py
@@ -332,7 +332,7 @@
# Create the OFInput from the AST
try:
- ofinput = frontend.create_ofinput(ast)
+ ofinput = frontend.create_ofinput(os.path.basename(filename), ast)
except frontend.InputError as e:
print "Error in %s: %s" % (os.path.basename(filename), str(e))
sys.exit(1)
diff --git a/utest/test_frontend.py b/utest/test_frontend.py
index 8febfde..19cde4e 100755
--- a/utest/test_frontend.py
+++ b/utest/test_frontend.py
@@ -109,7 +109,7 @@
]
self.assertEquals(expected_ast, ast)
- ofinput = frontend.create_ofinput(ast)
+ ofinput = frontend.create_ofinput("test", ast)
self.assertEquals(set([1, 2]), ofinput.wire_versions)
expected_classes = [
OFClass(name='of_echo_reply', superclass=None, members=[
@@ -180,7 +180,7 @@
]
self.assertEquals(expected_ast, ast)
- ofinput = frontend.create_ofinput(ast)
+ ofinput = frontend.create_ofinput("test", ast)
expected_classes = [
OFClass(name='of_queue_prop', superclass=None, members=[
OFDiscriminatorMember('type', 'uint16_t'),