Skip to content

Commit

Permalink
[libc][newhdrgen] add_function by alphabetical order (#102527)
Browse files Browse the repository at this point in the history
- add_function now adds the function by alphabetical order
  • Loading branch information
aaryanshukla authored Aug 8, 2024
1 parent ba97697 commit 86cf67f
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion libc/newhdrgen/yaml_to_classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,15 @@ def add_function_to_yaml(yaml_file, function_details):
if new_function.attributes:
function_dict["attributes"] = new_function.attributes

yaml_data["functions"].append(function_dict)
insert_index = 0
for i, func in enumerate(yaml_data["functions"]):
if func["name"] > new_function.name:
insert_index = i
break
else:
insert_index = len(yaml_data["functions"])

yaml_data["functions"].insert(insert_index, function_dict)

class IndentYamlListDumper(yaml.Dumper):
def increase_indent(self, flow=False, indentless=False):
Expand Down

0 comments on commit 86cf67f

Please sign in to comment.