loci: generate list accessors in their own files
diff --git a/c_gen/c_code_gen.py b/c_gen/c_code_gen.py
index 424c9f5..8450a20 100644
--- a/c_gen/c_code_gen.py
+++ b/c_gen/c_code_gen.py
@@ -542,8 +542,6 @@
""")
gen_object_enum_str(out)
- if config_check("gen_unified_fns"):
- gen_list_accessor_definitions(out)
gen_new_function_definitions(out)
gen_init_map(out)
out.write("\n/* This code should be broken out to a different file */\n")
@@ -2160,28 +2158,6 @@
out.write("%s\n%s_%s_get(\n %s)\n" % (ret_type, cls, m_name, params))
gen_unified_acc_body(out, cls, m_name, ver_type_map, "get", m_type)
-def gen_list_accessor_definitions(out):
- """
- Generate the body of each list accessor
-
- @param out The file to which to write the decs
- """
-
- out.write("""
-/****************************************************************
- *
- * List accessor function definitions
- *
- ****************************************************************/
-""")
- for cls in of_g.standard_class_order:
- if cls in type_maps.inheritance_map:
- continue
- if not loxi_utils.class_is_list(cls):
- continue
- out.write("\n/* Unified accessor functions for %s */\n" % cls)
- gen_list_accessors(out, cls)
-
def gen_accessor_definitions(out, cls):
for m_name in of_g.ordered_members[cls]:
if m_name in of_g.skip_members:
diff --git a/c_gen/codegen.py b/c_gen/codegen.py
index 7258514..d607626 100644
--- a/c_gen/codegen.py
+++ b/c_gen/codegen.py
@@ -38,6 +38,7 @@
import loxi_ir.ir as ir
import util
import c_code_gen
+import c_gen.of_g_legacy as of_g
PushWireTypesFn = namedtuple('PushWireTypesFn',
['class_name', 'versioned_type_members'])
@@ -85,3 +86,10 @@
util.render_template(out, "class.c")
# Append legacy generated code
c_code_gen.gen_accessor_definitions(out, uclass.name)
+
+def generate_lists(install_dir):
+ for cls in of_g.ordered_list_objects:
+ with template_utils.open_output(install_dir, "loci/src/%s.c" % cls) as out:
+ util.render_template(out, "class.c")
+ # Append legacy generated code
+ c_code_gen.gen_list_accessors(out, cls)
diff --git a/lang_c.py b/lang_c.py
index b8663ef..83cfb93 100644
--- a/lang_c.py
+++ b/lang_c.py
@@ -176,3 +176,4 @@
fn(outfile, os.path.basename(name))
c_gen.codegen.gen_push_wire_types(install_dir)
c_gen.codegen.generate_classes(install_dir)
+ c_gen.codegen.generate_lists(install_dir)