Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions ctypeslib/codegen/codegenerator.py
Original file line number Diff line number Diff line change
Expand Up @@ -1082,6 +1082,14 @@ def generate_code(self, output):
self.filter_types()
self.filter_symbols()
self.filter_expressions()

# clang's AST does not guarantee a fixed declaration order
# sort items by name or location. This results in a reproducible output.
self.filtered_items = sorted(
self.filtered_items,
key=lambda x: (x.location[0], x.location[1], x.name) if hasattr(x, 'location') else x.name
)

log.debug("Left with %d items after filtering", len(self.filtered_items))
loops = self.generator.generate(self.parser, self.filtered_items)
if self.cfg.verbose:
Expand Down
Loading