Skip to main content

Module fixgen

Module fixgen 

Source

Functionsยง

apply_fixes_c
Apply C/C++ struct reorderings in-place, returning the modified source. Each layout in layouts is looked up by name; matched structs are replaced with the optimally-ordered definition. Field declarations (including comments and annotations such as GUARDED_BY) are preserved verbatim from the original source when possible; IR-based generation is used as a fallback. Replacements are applied back-to-front so byte offsets remain valid.
apply_fixes_go
Apply Go struct reorderings in-place, returning the modified source. Preserves field tags and comments verbatim; falls back to IR-based generation.
apply_fixes_rust
Apply Rust struct reorderings in-place, returning the modified source. Preserves pub, pub(crate), #[serde(...)], /// doc-comments, and other attributes verbatim; falls back to IR-based generation when source cannot be parsed.
apply_fixes_zig
Apply Zig struct reorderings in-place, returning the modified source. Preserves field comments and annotations verbatim; falls back to IR-based generation.
extract_c_field_chunks
Split a C/C++ struct body (text between { and }, exclusive) into field chunks separated by ; at depth 0.
extract_go_field_chunks
Split a Go struct body (text between { and }, exclusive) into field chunks, one per non-blank non-comment line.
extract_rust_field_chunks
Split a Rust struct body (the text between { and }, exclusive) into field chunks, preserving attributes, doc comments, and visibility modifiers.
extract_zig_field_chunks
Split a Zig struct body (text between { and }, exclusive) into field chunks separated by , at depth 0.
find_c_struct_span
Find the byte range of a named struct/union in C/C++ source. The range covers from struct/union Name through the closing };.
find_go_struct_span
Find the byte range of a named struct in Go source (type Name struct { ... }).
find_rust_struct_span
Find the byte range of a named struct in Rust source (struct Name { ... }).
find_zig_struct_span
Find the byte range of a named Zig struct in source. Matches const Name = [packed|extern ]struct { ... };.
generate_c_fix
Render a reordered C/C++ struct definition as source text.
generate_c_fix_from_source
Generate a source-preserving C/C++ fix.
generate_go_fix
Render a reordered Go struct definition as source text.
generate_go_fix_from_source
Generate a source-preserving Go fix.
generate_rust_fix
Render a reordered Rust struct definition as source text.
generate_rust_fix_from_source
Generate a source-preserving Rust fix: reorder field chunks extracted from struct_source (the original struct Name { ... } text) according to the optimal field order.
generate_zig_fix
Render a reordered Zig struct definition as source text. Zig structs are declared as const Name = struct { ... };. If the layout is packed, the output uses packed struct.
generate_zig_fix_from_source
Generate a source-preserving Zig fix.
unified_diff
Produce a unified diff between original and fixed source text.