Skip to content

Commit

Permalink
Support common and API file
Browse files Browse the repository at this point in the history
  • Loading branch information
melonedo committed Aug 28, 2021
1 parent 317845b commit 86f973d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
5 changes: 5 additions & 0 deletions gen/generator.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ library_names = {}
# output file path relative to the working directory
output_file_path = "../lib/LibClang.jl"

# if these are set, common file (types and constants) and API file (functions) will be seperated
# this is for compatibility, so prologue and epilogue are not supported.
# output_api_file_path = "api.jl"
# output_common_file_path = "common.jl"

# if this entry is not empty, the generator will print the code below to the `output_file_path`.
# module module_name
#
Expand Down
8 changes: 7 additions & 1 deletion src/generator/context.jl
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,9 @@ function create_context(headers::Vector, args::Vector=String[], options::Dict=Di
push!(ctx.passes, StdPrinter())
end
else
# TODO: impl
# let the user handle prologue and epilogue on their own
push!(ctx.passes, FunctionPrinter(api_file))
push!(ctx.passes, CommonPrinter(common_file))
end

return ctx
Expand All @@ -157,6 +159,10 @@ Run all passes.
function build!(ctx::Context, stage=BUILDSTAGE_ALL)
reset_counter()
for pass in ctx.passes
if pass isa ResolveDependency
println("hello")
end

pass isa CollectDependentSystemNode && stage != BUILDSTAGE_PRINTING_ONLY && @info "Building the DAG..."
pass isa Codegen && stage != BUILDSTAGE_PRINTING_ONLY && @info "Emit Julia expressions..."
if stage == BUILDSTAGE_NO_PRINTING
Expand Down
2 changes: 1 addition & 1 deletion src/generator/passes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -873,7 +873,7 @@ function (x::CommonPrinter)(dag::ExprDAG, options::Dict)
open(x.file, "w") do io
for node in dag.nodes
string(node.id) blacklist && continue
node.type isa AbstractMacroNodeType && continue
(node.type isa AbstractMacroNodeType || node.type isa AbstractFunctionNodeType) && continue
pretty_print(io, node, general_options)
end
# print macros in the bottom of the file
Expand Down

0 comments on commit 86f973d

Please sign in to comment.