Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make TypedefElaborated respect @add_def #321

Merged
merged 4 commits into from
Sep 14, 2021
Merged
Show file tree
Hide file tree
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
1 change: 0 additions & 1 deletion src/generator/definitions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ const DEFAULT_EXTRA_DEFINITIONS = Dict{Symbol,AbstractJuliaType}(
:int16_t => JuliaCint16_t(),
:int8_t => JuliaCint8_t(),
:uintptr_t => JuliaCuintptr_t(),
:tm => JuliaCtm(),
:wchar_t => JuliaCwchar_t(),
:va_list => JuliaUnsupported(),
:FILE => JuliaCFILE(),
Expand Down
2 changes: 2 additions & 0 deletions src/generator/resolve_deps.jl
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ function resolve_dependency!(dag::ExprDAG, node::ExprNode{TypedefElaborated}, op

if haskey(dag.tags, leaf_ty.sym)
push!(node.adj, dag.tags[leaf_ty.sym])
elseif haskey(dag.ids_extra, leaf_ty.sym)
# pass
else
tycu = getTypeDeclaration(ty)
file, line, col = get_file_line_column(cursor)
Expand Down
2 changes: 1 addition & 1 deletion src/generator/system_deps.jl
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ function collect_dependent_system_nodes!(dag::ExprDAG, node::ExprNode{TypedefEla

is_jl_basic(leaf_ty) && return system_nodes

if !haskey(dag.tags, leaf_ty.sym)
if !(haskey(dag.tags, leaf_ty.sym) || haskey(dag.ids_extra, leaf_ty.sym))
# add all sys nodes with the same id
for (i, n) in enumerate(dag.sys)
if n.id == leaf_ty.sym
Expand Down
12 changes: 11 additions & 1 deletion test/generators.jl
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,16 @@ end
@test include("LibDependency.jl") isa Any
end

@testset "Issue 320" begin
args = get_default_args()
dir = joinpath(@__DIR__, "sys")
push!(args, "-isystem$dir")
headers = [joinpath(@__DIR__, "include", "test.h")]
ctx = create_context(headers, args)
@add_def stat
@test build!(ctx, BUILDSTAGE_NO_PRINTING) isa Any
end

@testset "Escape anonymous name with var\"\"" begin
args = get_default_args()
headers = joinpath(@__DIR__, "include", "escape-with-var.h")
Expand All @@ -64,4 +74,4 @@ end
ctx = create_context(headers, args, options)
build!(ctx)
@test include("LibEscapeWithVar.jl") isa Any
end
end
7 changes: 7 additions & 0 deletions test/include/test.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#ifndef TEST
#define TEST
#include "system.h"

typedef struct stat mystat;

#endif /* TEST */
6 changes: 6 additions & 0 deletions test/sys/system.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#ifndef SYSTEM
#define SYSTEM
void stat(void);
struct stat {};

#endif /* SYSTEM */