Skip to content

Commit

Permalink
Avoid generating duplicated anonymous records
Browse files Browse the repository at this point in the history
  • Loading branch information
Gnimuc committed Feb 25, 2019
1 parent 7304770 commit a676920
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
17 changes: 11 additions & 6 deletions src/wrap_c.jl
Original file line number Diff line number Diff line change
Expand Up @@ -161,12 +161,17 @@ function wrap!(ctx::AbstractContext, cursor::CLStructDecl)
idx -= 1
anonymous_record = struct_fields[idx]
end
ctx.anonymous_counter += 1
anon_name = "ANONYMOUS$(ctx.anonymous_counter)_"*spelling(field_cursor)
ctx.force_name = anon_name
wrap!(ctx, anonymous_record)
ctx.force_name = ""
repr = symbol_safe(anon_name)
if idx == field_idx-1
ctx.anonymous_counter += 1
anon_name = "ANONYMOUS$(ctx.anonymous_counter)_"*spelling(field_cursor)
ctx.force_name = anon_name
wrap!(ctx, anonymous_record)
ctx.force_name = ""
repr = symbol_safe(anon_name)
else
anon_name = "ANONYMOUS$(ctx.anonymous_counter)_"*spelling(struct_fields[idx+1])
repr = symbol_safe(anon_name)
end
else
repr = clang2julia(field_cursor)
end
Expand Down
7 changes: 1 addition & 6 deletions test/struct.jl
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,9 @@ end
end)
Base.remove_linenums!(expr)
@test ctx.common_buffer[:ANONYMOUS2_nest2].items[1] == expr
expr = :(struct ANONYMOUS3_nest3
x::Cint
end)
Base.remove_linenums!(expr)
@test ctx.common_buffer[:ANONYMOUS3_nest3].items[1] == expr
expr = :(struct ANONYMOUS1_nest1
nest2::ANONYMOUS2_nest2
nest3::ANONYMOUS3_nest3
nest3::ANONYMOUS2_nest2
s::UInt8
end)
Base.remove_linenums!(expr)
Expand Down

0 comments on commit a676920

Please sign in to comment.