Skip to content

Commit

Permalink
Fix issue with anonymous structures having multiple fields
Browse files Browse the repository at this point in the history
  • Loading branch information
Victorious3 committed Aug 25, 2023
1 parent 3f8bb43 commit 00d4134
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
13 changes: 4 additions & 9 deletions include/gencstd.py
Original file line number Diff line number Diff line change
Expand Up @@ -415,25 +415,20 @@ def parse_struct(name: str, inner: clang.Type, file: File, lookup: bool = False)
else: name = None

declaration = inner.get_declaration()
children = declaration.get_children()
children = list(declaration.get_children())

fields = []
field: clang.Cursor
index = 0
last_unnamed_struct: clang.Cursor = None

for field in children:
for i, field in enumerate(children):
if field.kind == clang.CursorKind.STRUCT_DECL:
if len(list(field.get_children())) == 0: continue
field_type = parse_type(field.type, file, is_in_struct = True)
if not field_type: return None

if last_unnamed_struct and field.type.get_declaration() == last_unnamed_struct:
del fields[-1]

last_unnamed_struct = None
if is_anonymous(field.type.spelling):
last_unnamed_struct = field.type.get_declaration()
if is_anonymous(field.spelling) and i + 1 < len(children) and field.type.get_declaration() == children[i + 1].type.get_declaration():
continue

spelling = field.spelling
if not spelling:
Expand Down
2 changes: 1 addition & 1 deletion include/linux/bfd.pr
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export type s_relax_table
export type s_reloc_cache_entry
export type s_relent_chain
export type s_bfd_link_order
export type s_bfd_section = struct { name: *char; id: uint; index: uint; next: *s_bfd_section; prev: *s_bfd_section; flags: uint; #bits(1) user_set_vma: uint; #bits(1) linker_mark: uint; #bits(1) linker_has_input: uint; #bits(1) gc_mark: uint; #bits(2) compress_status: uint; #bits(1) segment_mark: uint; #bits(3) sec_info_type: uint; #bits(1) use_rela_p: uint; #bits(1) sec_flg0: uint; #bits(1) sec_flg1: uint; #bits(1) sec_flg2: uint; #bits(1) sec_flg3: uint; #bits(1) sec_flg4: uint; #bits(1) sec_flg5: uint; vma: ulong; lma: ulong; size: ulong; rawsize: ulong; compressed_size: ulong; relax: *s_relax_table; relax_count: int; output_offset: ulong; output_section: *s_bfd_section; alignment_power: uint; relocation: *s_reloc_cache_entry; orelocation: **s_reloc_cache_entry; reloc_count: uint; filepos: long; rel_filepos: long; line_filepos: long; userdata: *; contents: *uint8; lineno: *s_lineno_cache_entry; lineno_count: uint; entsize: uint; kept_section: *s_bfd_section; moving_line_filepos: long; target_index: int; used_by_bfd: *; constructor_chain: *s_relent_chain; owner: *s_bfd; symbol: *s_bfd_symbol; symbol_ptr_ptr: **s_bfd_symbol; map_tail: struct #union { link_order: *s_bfd_link_order; s: *s_bfd_section; }; }
export type s_bfd_section = struct { name: *char; id: uint; index: uint; next: *s_bfd_section; prev: *s_bfd_section; flags: uint; #bits(1) user_set_vma: uint; #bits(1) linker_mark: uint; #bits(1) linker_has_input: uint; #bits(1) gc_mark: uint; #bits(2) compress_status: uint; #bits(1) segment_mark: uint; #bits(3) sec_info_type: uint; #bits(1) use_rela_p: uint; #bits(1) sec_flg0: uint; #bits(1) sec_flg1: uint; #bits(1) sec_flg2: uint; #bits(1) sec_flg3: uint; #bits(1) sec_flg4: uint; #bits(1) sec_flg5: uint; vma: ulong; lma: ulong; size: ulong; rawsize: ulong; compressed_size: ulong; relax: *s_relax_table; relax_count: int; output_offset: ulong; output_section: *s_bfd_section; alignment_power: uint; relocation: *s_reloc_cache_entry; orelocation: **s_reloc_cache_entry; reloc_count: uint; filepos: long; rel_filepos: long; line_filepos: long; userdata: *; contents: *uint8; lineno: *s_lineno_cache_entry; lineno_count: uint; entsize: uint; kept_section: *s_bfd_section; moving_line_filepos: long; target_index: int; used_by_bfd: *; constructor_chain: *s_relent_chain; owner: *s_bfd; symbol: *s_bfd_symbol; symbol_ptr_ptr: **s_bfd_symbol; map_head: struct #union { link_order: *s_bfd_link_order; s: *s_bfd_section; }; map_tail: struct #union { link_order: *s_bfd_link_order; s: *s_bfd_section; }; }
export type e_bfd_architecture = enum { bfd_arch_unknown; bfd_arch_obscure = 1; bfd_arch_m68k = 2; bfd_arch_vax = 3; bfd_arch_or1k = 4; bfd_arch_sparc = 5; bfd_arch_spu = 6; bfd_arch_mips = 7; bfd_arch_i386 = 8; bfd_arch_l1om = 9; bfd_arch_k1om = 10; bfd_arch_iamcu = 11; bfd_arch_romp = 12; bfd_arch_convex = 13; bfd_arch_m98k = 14; bfd_arch_pyramid = 15; bfd_arch_h8300 = 16; bfd_arch_pdp11 = 17; bfd_arch_plugin = 18; bfd_arch_powerpc = 19; bfd_arch_rs6000 = 20; bfd_arch_hppa = 21; bfd_arch_d10v = 22; bfd_arch_d30v = 23; bfd_arch_dlx = 24; bfd_arch_m68hc11 = 25; bfd_arch_m68hc12 = 26; bfd_arch_m9s12x = 27; bfd_arch_m9s12xg = 28; bfd_arch_s12z = 29; bfd_arch_z8k = 30; bfd_arch_sh = 31; bfd_arch_alpha = 32; bfd_arch_arm = 33; bfd_arch_nds32 = 34; bfd_arch_ns32k = 35; bfd_arch_tic30 = 36; bfd_arch_tic4x = 37; bfd_arch_tic54x = 38; bfd_arch_tic6x = 39; bfd_arch_v850 = 40; bfd_arch_v850_rh850 = 41; bfd_arch_arc = 42; bfd_arch_m32c = 43; bfd_arch_m32r = 44; bfd_arch_mn10200 = 45; bfd_arch_mn10300 = 46; bfd_arch_fr30 = 47; bfd_arch_frv = 48; bfd_arch_moxie = 49; bfd_arch_ft32 = 50; bfd_arch_mcore = 51; bfd_arch_mep = 52; bfd_arch_metag = 53; bfd_arch_ia64 = 54; bfd_arch_ip2k = 55; bfd_arch_iq2000 = 56; bfd_arch_bpf = 57; bfd_arch_epiphany = 58; bfd_arch_mt = 59; bfd_arch_pj = 60; bfd_arch_avr = 61; bfd_arch_bfin = 62; bfd_arch_cr16 = 63; bfd_arch_crx = 64; bfd_arch_cris = 65; bfd_arch_riscv = 66; bfd_arch_rl78 = 67; bfd_arch_rx = 68; bfd_arch_s390 = 69; bfd_arch_score = 70; bfd_arch_mmix = 71; bfd_arch_xstormy16 = 72; bfd_arch_msp430 = 73; bfd_arch_xc16x = 74; bfd_arch_xgate = 75; bfd_arch_xtensa = 76; bfd_arch_z80 = 77; bfd_arch_lm32 = 78; bfd_arch_microblaze = 79; bfd_arch_tilepro = 80; bfd_arch_tilegx = 81; bfd_arch_aarch64 = 82; bfd_arch_nios2 = 83; bfd_arch_visium = 84; bfd_arch_wasm32 = 85; bfd_arch_pru = 86; bfd_arch_nfp = 87; bfd_arch_csky = 88; bfd_arch_last = 89; }
export type s_bfd_arch_info
export type s_bfd_arch_info = struct { bits_per_word: int; bits_per_address: int; bits_per_byte: int; arch: e_bfd_architecture; mach: ulong; arch_name: *char; printable_name: *char; section_align_power: uint; the_default: int; compatible: def (*s_bfd_arch_info, *s_bfd_arch_info) -> (*s_bfd_arch_info); scan: def (*s_bfd_arch_info, *char) -> (int); fill: def (ulong, int, int) -> (*); next: *s_bfd_arch_info; max_reloc_offset_into_insn: int; }
Expand Down

0 comments on commit 00d4134

Please sign in to comment.