loci: add a function to determine whether a class is an inheritance root
diff --git a/c_gen/build_of_g.py b/c_gen/build_of_g.py
index d919e42..047b254 100755
--- a/c_gen/build_of_g.py
+++ b/c_gen/build_of_g.py
@@ -373,7 +373,7 @@
for wire_version, ordered_classes in of_g.ordered_classes.items():
classes = versions[of_g.of_version_wire2name[wire_version]]['classes']
for cls in ordered_classes:
- if cls in type_maps.inheritance_map:
+ if type_maps.class_is_inheritance_root(cls):
new_cls = cls + '_header'
of_g.ordered_classes[wire_version].append(new_cls)
classes[new_cls] = classes[cls]
diff --git a/c_gen/c_code_gen.py b/c_gen/c_code_gen.py
index 6556d3b..c63b882 100644
--- a/c_gen/c_code_gen.py
+++ b/c_gen/c_code_gen.py
@@ -1069,7 +1069,7 @@
out.write("typedef union %(cls)s_u %(cls)s_t;\n" % dict(cls=cls))
out.write("\n/* LOCI object typedefs */\n")
for cls in of_g.standard_class_order:
- if cls in type_maps.inheritance_map:
+ if type_maps.class_is_inheritance_root(cls):
continue
template = "typedef of_object_t %(cls)s_t;\n"
out.write(template % dict(cls=cls))
@@ -1109,7 +1109,7 @@
****************************************************************/
""")
for cls in of_g.standard_class_order:
- if cls in type_maps.inheritance_map:
+ if type_maps.class_is_inheritance_root(cls):
continue
out.write("\n/* Unified accessor functions for %s */\n" % cls)
for m_name in of_g.ordered_members[cls]:
@@ -1629,7 +1629,7 @@
@param cls The class name for the function
@param out The file to which to write
"""
- if cls in type_maps.inheritance_map:
+ if type_maps.class_is_inheritance_root(cls):
param = "obj_p"
else:
param = "obj"
@@ -1659,7 +1659,7 @@
""" % dict(cls=cls, param=param))
# Use an extra pointer to deal with inheritance classes
- if cls in type_maps.inheritance_map:
+ if type_maps.class_is_inheritance_root(cls):
out.write("""\
%s_header_t *obj;
@@ -1862,7 +1862,7 @@
****************************************************************/
""")
for cls in of_g.standard_class_order:
-# if cls in type_maps.inheritance_map:
+# if type_maps.class_is_inheritance_root(cls):
# continue
out.write("""
/**
@@ -1921,7 +1921,7 @@
out.write("/* DOCUMENTATION ONLY */\n")
for cls in of_g.standard_class_order:
- if cls in type_maps.inheritance_map:
+ if type_maps.class_is_inheritance_root(cls):
pass # Check this
out.write("""
diff --git a/c_gen/c_dump_gen.py b/c_gen/c_dump_gen.py
index d4a016c..2f41c35 100644
--- a/c_gen/c_dump_gen.py
+++ b/c_gen/c_dump_gen.py
@@ -90,7 +90,7 @@
for cls in of_g.standard_class_order:
if not loxi_utils.class_in_version(cls, version):
continue
- if cls in type_maps.inheritance_map:
+ if type_maps.class_is_inheritance_root(cls):
continue
out.write("""\
int %(cls)s_%(ver_name)s_dump(loci_writer_f writer, void* cookie, %(cls)s_t *obj);
@@ -129,7 +129,7 @@
for cls in of_g.standard_class_order:
if not loxi_utils.class_in_version(cls, version):
continue
- if cls in type_maps.inheritance_map:
+ if type_maps.class_is_inheritance_root(cls):
continue
out.write("""
int
@@ -234,7 +234,7 @@
comma = ","
if (not loxi_utils.class_in_version(cls, version) or
- cls in type_maps.inheritance_map):
+ type_maps.class_is_inheritance_root(cls)):
out.write(" unknown_dump%s\n" % comma);
else:
out.write(" %s_%s_dump%s\n" %
diff --git a/c_gen/c_show_gen.py b/c_gen/c_show_gen.py
index 9d84477..91eb595 100644
--- a/c_gen/c_show_gen.py
+++ b/c_gen/c_show_gen.py
@@ -91,7 +91,7 @@
for cls in of_g.standard_class_order:
if not loxi_utils.class_in_version(cls, version):
continue
- if cls in type_maps.inheritance_map:
+ if type_maps.class_is_inheritance_root(cls):
continue
out.write("""\
int %(cls)s_%(ver_name)s_show(loci_writer_f writer, void* cookie, %(cls)s_t *obj);
@@ -130,7 +130,7 @@
for cls in of_g.standard_class_order:
if not loxi_utils.class_in_version(cls, version):
continue
- if cls in type_maps.inheritance_map:
+ if type_maps.class_is_inheritance_root(cls):
continue
out.write("""
int
@@ -233,7 +233,7 @@
comma = ","
if (not loxi_utils.class_in_version(cls, version) or
- cls in type_maps.inheritance_map):
+ type_maps.class_is_inheritance_root(cls)):
out.write(" unknown_show%s\n" % comma);
else:
out.write(" %s_%s_show%s\n" %
diff --git a/c_gen/c_test_gen.py b/c_gen/c_test_gen.py
index 52b00a4..cd2743c 100644
--- a/c_gen/c_test_gen.py
+++ b/c_gen/c_test_gen.py
@@ -372,7 +372,7 @@
for cls in of_g.standard_class_order:
if not loxi_utils.class_in_version(cls, version):
continue
- if cls in type_maps.inheritance_map:
+ if type_maps.class_is_inheritance_root(cls):
continue
out.write("""
extern int %(cls)s_%(v_name)s_populate(
@@ -507,7 +507,7 @@
*/
""" % v_name)
for cls in of_g.standard_class_order:
- if cls in type_maps.inheritance_map:
+ if type_maps.class_is_inheritance_root(cls):
continue
if version in of_g.unified[cls]:
message_scalar_test(out, version, cls)
@@ -520,7 +520,7 @@
for version in of_g.of_version_range:
v_name = loxi_utils.version_to_name(version)
for cls in of_g.standard_class_order:
- if cls in type_maps.inheritance_map:
+ if type_maps.class_is_inheritance_root(cls):
continue
if version in of_g.unified[cls]:
test_name = "%s_%s" % (cls, v_name)
@@ -1565,7 +1565,7 @@
for cls in of_g.standard_class_order:
if not loxi_utils.class_in_version(cls, version):
continue
- if cls in type_maps.inheritance_map:
+ if type_maps.class_is_inheritance_root(cls):
continue
elif loxi_utils.class_is_list(cls):
gen_list_setup_check(out, cls, version)
@@ -1588,7 +1588,7 @@
for cls in of_g.standard_class_order:
if not loxi_utils.class_in_version(cls, version):
continue
- if cls in type_maps.inheritance_map:
+ if type_maps.class_is_inheritance_root(cls):
continue
unified_accessor_test_case(out, cls, version)
@@ -1602,7 +1602,7 @@
for cls in of_g.standard_class_order:
if not loxi_utils.class_in_version(cls, version):
continue
- if cls in type_maps.inheritance_map:
+ if type_maps.class_is_inheritance_root(cls):
continue
test_name = "%s_%s" % (cls, v_name)
out.write(" RUN_TEST(%s);\n" % test_name)
@@ -1814,7 +1814,7 @@
for cls in of_g.standard_class_order:
if not loxi_utils.class_in_version(cls, version):
continue
- if cls in type_maps.inheritance_map:
+ if type_maps.class_is_inheritance_root(cls):
gen_dup_inheritance(out, cls, version)
elif loxi_utils.class_is_list(cls):
gen_dup_list(out, cls, version)
@@ -1836,7 +1836,7 @@
for version in of_g.of_version_range:
if not loxi_utils.class_in_version(cls, version):
continue
- hdr = "header." if cls in type_maps.inheritance_map else ""
+ hdr = "header." if type_maps.class_is_inheritance_root(cls) else ""
ver_name = loxi_utils.version_to_name(version)
out.write("""
@@ -1940,7 +1940,7 @@
for j, cls in enumerate(of_g.all_class_order):
if not loxi_utils.class_in_version(cls, version):
continue
- if cls in type_maps.inheritance_map:
+ if type_maps.class_is_inheritance_root(cls):
continue
if cls == "of_bsn_virtual_port_create_request": # test q_in_q
out.write("""
diff --git a/c_gen/type_maps.py b/c_gen/type_maps.py
index 69ecd41..abbc2d5 100644
--- a/c_gen/type_maps.py
+++ b/c_gen/type_maps.py
@@ -53,6 +53,9 @@
return True
return loxi_globals.unified.class_by_name(cls).virtual
+def class_is_inheritance_root(cls):
+ return cls in inheritance_roots
+
# map from parent class name to set of subclass names
inheritance_map = dict()