Skip to content

Commit

Permalink
Merge pull request #334 from melonedo/split-common-api
Browse files Browse the repository at this point in the history
Support separating common and API file
  • Loading branch information
Gnimuc authored Sep 13, 2021
2 parents 197e780 + e3fead6 commit 31b196c
Show file tree
Hide file tree
Showing 3 changed files with 9 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
4 changes: 3 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 Down
2 changes: 1 addition & 1 deletion src/generator/passes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -865,7 +865,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 31b196c

Please sign in to comment.