C Wrapper Generator

The Clang.jl wrapper generator is designed to be simple but flexible. The most basic invocation looks like this:

context = wrap_c.init()

headers = ["all.h", "your.h", "headers.h"]
wrap_c.wrap_c_headers(context, headers)

However, it is usually necessary to set compiler arguments or customize output. The init function provides several arguments to configure the compiler, as well as callback functions used to determine various aspects of the output.

init(; index, output_file, clang_args, clang_includes, clang_diagnostics, header_wrapped, header_library, header_outputfile)

init: Create wrapping context. Keyword args are available to specify options, but all options are given sane defaults.

  • index – Union{}
  • output_file (String) –
  • common_file (String) – Name of common output file (types, constants, typealiases)
  • clang_args (Vector{String}) –
  • clang_includes (Vector{String}) – List of include paths for Clang to search.
  • clang_diagnostics (Bool) – Display Clang diagnostics
  • header_wrapped (Function(header_file::String, cursor_name::String) -> Bool) – Function called to determine whether a header should be wrapped.
  • header_library – Function called to determine the library name for a given header.
  • header_outputfile (Function(header::String) -> Bool) – Function called to determine the output filename for a given header.
  • rewriter (Function(Expr)) – Function to rewrite generated expressions
wrap_c_headers(wc::WrapContext, headers::Vector{String})

Generate a wrapping using given WrapContext for a list of headers. All parameters are governed by the WrapContext, see wrap_c.init for full listing of options.


WrapContext stores all information about the wrapping job.

Field index:CXIndex to reuse for parsing.
Field output_file:
 Name of main output file.
Field common_file:
 Name of common output file (constants, types, and aliases)
Field clang_includes:
 Clang include paths
Field clang_args:
 additional {“-Arg”, “value”} pairs for clang
Field header_wrapped:
 called to determine cursor inclusion status
Field header_library:
 called to determine shared library for given header
Field header_outfile:
 called to determine output file group for given header
Field common_buf:
Field cache_wrapped:
 [Internal] Set{String}
Field output_bufs:
 [Internal] DefaultOrderedDict{String, Array{Any}}
Field options:InternalOptions