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

3 minor NFC changes #365

Merged
merged 3 commits into from
Jan 3, 2022
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ using Clang.LibClang.Clang_jll # replace this with your jll package

cd(@__DIR__)

include_dir = joinpath(Clang_jll.artifact_dir, "include") |> normpath
include_dir = normpath(Clang_jll.artifact_dir, "include")
clang_dir = joinpath(include_dir, "clang-c")

options = load_options(joinpath(@__DIR__, "generator.toml"))
Expand Down
4 changes: 2 additions & 2 deletions docs/src/generator.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ using Clang.LibClang.Clang_jll

cd(@__DIR__)

include_dir = joinpath(Clang_jll.artifact_dir, "include") |> normpath
include_dir = normpath(Clang_jll.artifact_dir, "include")

# wrapper generator options
options = load_options(joinpath(@__DIR__, "generator.toml"))
Expand Down Expand Up @@ -47,7 +47,7 @@ You also need an options file `generator.toml` that to make this script work, yo
### Skipping specific symbols
The C header may contain some symbols that are not correctly handled by Clang.jl or may need manual wrapping. For example, julia provides `tm` as `Libc.TmStruct`, so you may not want to map it to a new struct. As a workaround, you can skip these symbols. After that, if this symbol is needed, you can add it back in the prologue. Prologue is specified by the `prologue_file_path` option.

* Add the symbol to `printer_blacklist` to avoid it from being wrapped.
* Add the symbol to `output_ignorelist` to avoid it from being wrapped.
* If the symbol is in system headers and causes Clang.jl to error before printing, apart from posting an issue, write `@add_def symbol_name` before generating to suppress it from being wrapped.

### Rewrite expressions before printing
Expand Down
2 changes: 1 addition & 1 deletion docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ using Clang.LibClang.Clang_jll

cd(@__DIR__)

include_dir = joinpath(Clang_jll.artifact_dir, "include") |> normpath
include_dir = normpath(Clang_jll.artifact_dir, "include")
clang_dir = joinpath(include_dir, "clang-c")

# wrapper generator options
Expand Down
2 changes: 1 addition & 1 deletion gen/generator.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ using Clang.LibClang.Clang_jll

cd(@__DIR__)

const INCLUDE_DIR = joinpath(Clang_jll.artifact_dir, "include") |> normpath
const INCLUDE_DIR = normpath(Clang_jll.artifact_dir, "include")
const CLANG_C_DIR = joinpath(INCLUDE_DIR, "clang-c")

options = load_options(joinpath(@__DIR__, "generator.toml"))
Expand Down
26 changes: 13 additions & 13 deletions gen/generator.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ output_file_path = "../lib/LibClang.jl"

# if this entry is not empty, the generator will print the code below to the `output_file_path`.
# module module_name
#
#
# end # module
module_name = "LibClang"

Expand All @@ -44,8 +44,8 @@ prologue_file_path = "./prologue.jl"
# this is often used for applying custom patches.
epilogue_file_path = ""

# node with an id in the `output_ignorelist` will be ignored in the printing passes.
# this is very useful for custom editing.
# node with an id in the `output_ignorelist` will be ignored in the printing passes.
# this is very useful for custom editing.
output_ignorelist = [
"CINDEX_EXPORTS",
"CINDEX_VERSION",
Expand All @@ -58,9 +58,9 @@ output_ignorelist = [
"LLVM_CLANG_C_EXTERN_C_END"
]

# Julia's `@enum` do not allow duplicated values, so by default, C enums are translated to
# CEnum.jl's `@cenum`.
# if this entry is true, `@enum` is used and those duplicated enum constants are just commented.
# Julia's `@enum` do not allow duplicated values, so by default, C enums are translated to
# CEnum.jl's `@cenum`.
# if this entry is true, `@enum` is used and those duplicated enum constants are just commented.
use_julia_native_enum_type = false

# use `@cenum` but do not print `using CEnum`.
Expand All @@ -74,8 +74,8 @@ print_enum_as_integer = false
# use deterministic symbol instead of `gensym`-generated `var"##XXX"`
use_deterministic_symbol = true

# by default, only those declarations in the local header file are processed.
# those declarations in the system headers will be treated sepcially and will be generated if necessary.
# by default, only those declarations in the local header file are processed.
# those declarations in the system headers will be treated sepcially and will be generated if necessary.
# if you'd like to generate all of the symbols in the system headers, please set this option to false.
is_local_header_only = true

Expand All @@ -101,15 +101,15 @@ is_local_header_only = true
smart_de_anonymize = true

# EXPERIMENTAL
# if this option is set to true, those structs that are not necessary to be an
# immutable struct will be generated as a mutable struct.
# if this option is set to true, those structs that are not necessary to be an
# immutable struct will be generated as a mutable struct.
# this option is default to false, do read the paragraph below before using this feature.
auto_mutability = false

# add inner constructor `Foo() = new()`
auto_mutability_with_new = true

# if you feel like certain structs should not be generated as mutable struct, please add them in the following list.
# if you feel like certain structs should not be generated as mutable struct, please add them in the following list.
# for example, if a C function accepts a `Vector` of some type as its argument like:
# void foo(mutable_type *list, int n);
# when calling this function via `ccall`, passing a `Vector{mutable_type}(undef, n)` to the first
Expand Down Expand Up @@ -156,7 +156,7 @@ opaque_func_arg_as_PtrCvoid = false
# if true, opaque types are translated to `mutable struct` instead of `Cvoid`.
opaque_as_mutable_struct = true

# if true, use Julia 1.5's new `@ccall` macro
# if true, use Julia 1.5's new `@ccall` macro
use_ccall_macro = true

# if true, variadic functions are wrapped with `@ccall` macro. Otherwise variadic functions are ignored.
Expand All @@ -165,7 +165,7 @@ wrap_variadic_function = false
# generate getproperty/setproperty! methods for the types in the following list
field_access_method_list = []

# the generator will prefix the function argument names in the following list with a "_" to
# the generator will prefix the function argument names in the following list with a "_" to
# prevent the generated symbols from conflicting with the symbols defined and exported in Base.
function_argument_conflict_symbols = []

Expand Down
2 changes: 1 addition & 1 deletion test/generators.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ using Clang.Generators: strip_comment_markers
include("rewriter.jl")

@testset "Generators" begin
INCLUDE_DIR = joinpath(Clang_jll.artifact_dir, "include") |> normpath
INCLUDE_DIR = normpath(Clang_jll.artifact_dir, "include")
CLANG_C_DIR = joinpath(INCLUDE_DIR, "clang-c")

options = load_options(joinpath(@__DIR__, "test.toml"))
Expand Down