loci: generate less code and tests for virtual classes
Most uses of type_maps.class_is_inheritance_root are bugs. Generally you
actually want to know if a class is virtual. This is complicated somewhat by
lists also being virtual.
diff --git a/c_gen/c_code_gen.py b/c_gen/c_code_gen.py
index a6868ce..968d939 100644
--- a/c_gen/c_code_gen.py
+++ b/c_gen/c_code_gen.py
@@ -1011,7 +1011,7 @@
****************************************************************/
""")
for cls in of_g.standard_class_order:
- if type_maps.class_is_inheritance_root(cls):
+ if type_maps.class_is_virtual(cls) and not loxi_utils.class_is_list(cls):
continue
out.write("\n/* Unified accessor functions for %s */\n" % cls)
for m_name in of_g.ordered_members[cls]:
@@ -1690,8 +1690,6 @@
****************************************************************/
""")
for cls in of_g.standard_class_order:
-# if type_maps.class_is_inheritance_root(cls):
-# continue
out.write("""
/**
* Delete an object of type %(cls)s_t
@@ -1749,8 +1747,8 @@
out.write("/* DOCUMENTATION ONLY */\n")
for cls in of_g.standard_class_order:
- if type_maps.class_is_inheritance_root(cls):
- pass # Check this
+ if type_maps.class_is_virtual(cls):
+ pass
out.write("""
/**
diff --git a/c_gen/c_dump_gen.py b/c_gen/c_dump_gen.py
index 6a9b8f8..799dc09 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 type_maps.class_is_inheritance_root(cls):
+ if type_maps.class_is_virtual(cls):
continue
out.write("""\
int %(cls)s_%(ver_name)s_dump(loci_writer_f writer, void* cookie, of_object_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 type_maps.class_is_inheritance_root(cls):
+ if type_maps.class_is_virtual(cls):
continue
out.write("""
int
@@ -234,7 +234,7 @@
comma = ","
if (not loxi_utils.class_in_version(cls, version) or
- type_maps.class_is_inheritance_root(cls)):
+ type_maps.class_is_virtual(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 03a55d5..d1cbbdb 100644
--- a/c_gen/c_show_gen.py
+++ b/c_gen/c_show_gen.py
@@ -163,7 +163,7 @@
for cls in of_g.standard_class_order:
if not loxi_utils.class_in_version(cls, version):
continue
- if type_maps.class_is_inheritance_root(cls):
+ if type_maps.class_is_virtual(cls):
continue
out.write("""\
int %(cls)s_%(ver_name)s_show(loci_writer_f writer, void* cookie, of_object_t *obj);
@@ -202,7 +202,7 @@
for cls in of_g.standard_class_order:
if not loxi_utils.class_in_version(cls, version):
continue
- if type_maps.class_is_inheritance_root(cls):
+ if type_maps.class_is_virtual(cls):
continue
out.write("""
int
@@ -302,7 +302,7 @@
comma = ","
if (not loxi_utils.class_in_version(cls, version) or
- type_maps.class_is_inheritance_root(cls)):
+ type_maps.class_is_virtual(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 cb7ff7d..109ab9b 100644
--- a/c_gen/c_test_gen.py
+++ b/c_gen/c_test_gen.py
@@ -380,7 +380,7 @@
for cls in of_g.standard_class_order:
if not loxi_utils.class_in_version(cls, version):
continue
- if type_maps.class_is_inheritance_root(cls):
+ if type_maps.class_is_virtual(cls) and not loxi_utils.class_is_list(cls):
continue
out.write("""
extern int %(cls)s_%(v_name)s_populate(
@@ -515,7 +515,7 @@
*/
""" % v_name)
for cls in of_g.standard_class_order:
- if type_maps.class_is_inheritance_root(cls):
+ if type_maps.class_is_virtual(cls):
continue
if version in of_g.unified[cls]:
message_scalar_test(out, version, cls)
@@ -528,7 +528,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 type_maps.class_is_inheritance_root(cls):
+ if type_maps.class_is_virtual(cls):
continue
if version in of_g.unified[cls]:
test_name = "%s_%s" % (cls, v_name)
@@ -701,7 +701,7 @@
"""
for version in of_g.of_version_range:
for cls in of_g.standard_class_order:
- if type_maps.class_is_inheritance_root(cls):
+ if type_maps.class_is_virtual(cls):
continue
(members, member_types) = scalar_member_types_get(cls, version)
scalar_funs_instance(out, cls, version, members, member_types)
@@ -1588,11 +1588,9 @@
for cls in of_g.standard_class_order:
if not loxi_utils.class_in_version(cls, version):
continue
- if type_maps.class_is_inheritance_root(cls):
- continue
elif loxi_utils.class_is_list(cls):
gen_list_setup_check(out, cls, version)
- else:
+ elif not type_maps.class_is_virtual(cls):
gen_class_setup_check(out, cls, version)
def gen_unified_accessor_tests(out, name):
@@ -1611,7 +1609,7 @@
for cls in of_g.standard_class_order:
if not loxi_utils.class_in_version(cls, version):
continue
- if type_maps.class_is_inheritance_root(cls):
+ if type_maps.class_is_virtual(cls):
continue
unified_accessor_test_case(out, cls, version)
@@ -1625,7 +1623,7 @@
for cls in of_g.standard_class_order:
if not loxi_utils.class_in_version(cls, version):
continue
- if type_maps.class_is_inheritance_root(cls):
+ if type_maps.class_is_virtual(cls):
continue
test_name = "%s_%s" % (cls, v_name)
out.write(" RUN_TEST(%s);\n" % test_name)
@@ -1708,6 +1706,8 @@
sub_classes = type_maps.sub_class_map(cls, version)
for (_, sub_cls) in sub_classes:
sub_enum = sub_cls.upper()
+ if type_maps.class_is_virtual(sub_cls):
+ continue
out.write("""
if (src->object_id == %(sub_enum)s) {
return %(sub_cls)s_%(ver_name)s_dup(src);
@@ -1841,7 +1841,7 @@
gen_dup_inheritance(out, cls, version)
elif loxi_utils.class_is_list(cls):
gen_dup_list(out, cls, version)
- else:
+ elif not type_maps.class_is_virtual(cls):
gen_dup_cls(out, cls, version)
def gen_dup(out=sys.stdout):
@@ -1859,7 +1859,12 @@
for version in of_g.of_version_range:
if not loxi_utils.class_in_version(cls, version):
continue
-
+ elif type_maps.class_is_inheritance_root(cls):
+ pass
+ elif loxi_utils.class_is_list(cls):
+ pass
+ elif type_maps.class_is_virtual(cls):
+ continue
ver_name = loxi_utils.version_to_name(version)
out.write("""
if (src->version == %(ver_name)s) {
@@ -1928,6 +1933,12 @@
for cls in of_g.standard_class_order:
if not loxi_utils.class_in_version(cls, version):
continue
+ elif type_maps.class_is_inheritance_root(cls):
+ pass
+ elif loxi_utils.class_is_list(cls):
+ pass
+ elif type_maps.class_is_virtual(cls):
+ continue
ver_name = loxi_utils.version_to_name(version)
out.write("""
extern of_object_t *
@@ -1962,7 +1973,7 @@
for j, cls in enumerate(of_g.all_class_order):
if not loxi_utils.class_in_version(cls, version):
continue
- if type_maps.class_is_inheritance_root(cls):
+ if type_maps.class_is_virtual(cls):
continue
if cls == "of_bsn_virtual_port_create_request": # test q_in_q
out.write("""