Parse a directory of headers and return named list of data.frames with
Source:R/parse-headers.R
parse_headers_collect.Rdfunctions, structs, struct members, enums, unions, globals, and macros.
Arguments
- dir
Directory to search for header files. Defaults to
R.home("include").- recursive
Whether to search recursively for headers. Default
TRUE.- pattern
File name pattern to match header files. Default is
\.h$and\.H$.- preprocess
Run the C preprocessor (using R's configured CC) on header files before parsing. Defaults to
FALSE.- cc
The C compiler to use for preprocessing. If
NULLthe function queriesR CMD config CCand falls back toSys.getenv("CC")and theccon PATH.- ccflags
Extra flags to pass to the compiler when preprocessing. If
NULLflags are taken fromR CMD config CFLAGSandR CMD config CPPFLAGS.- include_dirs
Additional directories to add to the include path for preprocessing. A character vector of directories.
- extract_params
Logical; whether to extract parameter types for functions. Default
FALSE.- extract_return
Logical; whether to extract return types for functions. Default
FALSE.- ...
Additional arguments passed to preprocess_header (e.g., extra compiler flags)
Value
A named list of data frames with components: functions, structs, struct_members, enums, unions, globals, defines.
Details
This helper loops over headers found in a directory and returns a list with tidy data.frames. Useful for programmatic analysis of header collections.
Examples
if (FALSE) { # \dontrun{
if (requireNamespace("treesitter", quietly = TRUE)) {
res <- parse_headers_collect(dir = R.home("include"), preprocess = FALSE)
head(res$functions)
}
} # }