Exemplo n.º 1
0
def generate_lists(install_dir):
    # Collect all the lists in use
    list_oftypes = set()
    for uclass in loxi_globals.unified.classes:
        for ofclass in uclass.version_classes.values():
            for m in ofclass.members:
                if isinstance(m, ir.OFDataMember) and \
                        loxi_utils.oftype_is_list(m.oftype):
                    list_oftypes.add(m.oftype)

    for oftype in sorted(list(list_oftypes)):
        cls, e_cls = loxi_utils_legacy.list_name_extract(oftype)
        e_cls = e_cls[:-2]
        e_uclass = loxi_globals.unified.class_by_name(e_cls)
        with template_utils.open_output(install_dir,
                                        "loci/src/%s.c" % cls) as out:
            util.render_template(
                out,
                "list.c",
                cls=cls,
                e_cls=e_cls,
                e_uclass=e_uclass,
                wire_length_get=class_metadata_dict[e_cls].wire_length_get)
            # Append legacy generated code
            c_code_gen.gen_new_function_definitions(out, cls)
Exemplo n.º 2
0
def generate_classes(install_dir):
    for uclass in loxi_globals.unified.classes:
        with template_utils.open_output(install_dir, "loci/src/%s.c" % uclass.name) as out:
            util.render_template(out, "class.c",
                push_wire_types_data=push_wire_types_data(uclass))
            # Append legacy generated code
            c_code_gen.gen_new_function_definitions(out, uclass.name)
            c_code_gen.gen_accessor_definitions(out, uclass.name)
Exemplo n.º 3
0
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",
                push_wire_types_data=None)
            # Append legacy generated code
            c_code_gen.gen_new_function_definitions(out, cls)
            c_code_gen.gen_list_accessors(out, cls)
Exemplo n.º 4
0
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",
                push_wire_types_data=None,
                parse_wire_types_data=None)
            # Append legacy generated code
            c_code_gen.gen_new_function_definitions(out, cls)
            c_code_gen.gen_list_accessors(out, cls)
Exemplo n.º 5
0
def generate_classes(install_dir):
    for i, chunk in enumerate(chunks(loxi_globals.unified.classes, CLASS_CHUNK_SIZE)):
        with template_utils.open_output(install_dir, "loci/src/class%02d.c" % i) as out:
            for uclass in chunk:
                util.render_template(out, "class.c",
                    push_wire_types_data=push_wire_types_data(uclass))
                # Append legacy generated code
                c_code_gen.gen_new_function_definitions(out, uclass.name)
                c_code_gen.gen_accessor_definitions(out, uclass.name)
Exemplo n.º 6
0
def generate_header_classes(install_dir):
    for cls in of_g.standard_class_order:
        if cls.find("_header") < 0:
            continue
        with template_utils.open_output(install_dir, "loci/src/%s.c" % cls) as out:
            util.render_template(out, "class.c",
                push_wire_types_data=None)
            # Append legacy generated code
            c_code_gen.gen_new_function_definitions(out, cls)
            c_code_gen.gen_accessor_definitions(out, cls)
Exemplo n.º 7
0
def generate_classes(install_dir):
    for i, chunk in enumerate(chunks(loxi_globals.unified.classes, CLASS_CHUNK_SIZE)):
        with template_utils.open_output(install_dir, "loci/src/class%02d.c" % i) as out:
            for uclass in chunk:
                util.render_template(out, "class.c",
                    push_wire_types_data=push_wire_types_data(uclass),
                    parse_wire_types_data=parse_wire_types_data(uclass))
                # Append legacy generated code
                c_code_gen.gen_new_function_definitions(out, uclass.name)
                c_code_gen.gen_accessor_definitions(out, uclass.name)
Exemplo n.º 8
0
def generate_header_classes(install_dir):
    for cls in of_g.standard_class_order:
        if cls.find("_header") < 0 or cls in ["of_header", "of_bsn_header", "of_nicira_header"]:
            continue
        with template_utils.open_output(install_dir, "loci/src/%s.c" % cls) as out:
            util.render_template(out, "class.c",
                push_wire_types_data=None,
                parse_wire_types_data=None)
            # Append legacy generated code
            c_code_gen.gen_new_function_definitions(out, cls)
            c_code_gen.gen_accessor_definitions(out, cls)
Exemplo n.º 9
0
def generate_lists(install_dir):
    # Collect all the lists in use
    list_oftypes = set()
    for uclass in loxi_globals.unified.classes:
        for ofclass in uclass.version_classes.values():
            for m in ofclass.members:
                if isinstance(m, ir.OFDataMember) and \
                        loxi_utils.oftype_is_list(m.oftype):
                    list_oftypes.add(m.oftype)

    for oftype in sorted(list(list_oftypes)):
        cls, e_cls = loxi_utils_legacy.list_name_extract(oftype)
        e_cls = e_cls[:-2]
        e_uclass = loxi_globals.unified.class_by_name(e_cls)
        with template_utils.open_output(install_dir, "loci/src/%s.c" % cls) as out:
            util.render_template(out, "list.c", cls=cls, e_cls=e_cls, e_uclass=e_uclass,
                                 wire_length_get=class_metadata_dict[e_cls].wire_length_get)
            # Append legacy generated code
            c_code_gen.gen_new_function_definitions(out, cls)