process_attributes: Process package attributes

Description Usage Arguments Value Export Export External / External2 Callable Init

View source: R/process.R

Description

process_attributes() processes C level comment attributes. It automates a number of tasks, such as:

process_attributes() determines the functions to include in the init.c file through the use of C comments placed directly above the function of interest and formatted like // [[ export() ]]. See the sections below for a complete description.

Usage

1

Arguments

path

[character(1)]

The relative file path to the top level of your package.

debug

[logical(1)]

Should the lines that will be used to construct the init.c and API files be returned as a named list of character vectors rather than written to disk?

Value

A named list of 3 elements: init, api_c, and api_h. These contain the lines written to their corresponding file. If debug = FALSE, this is returned invisibly. If debug = TRUE, it is returned visibly and the lines are not written to file.

Export

Export a C function to the R side as a CallRoutine, suitable for use with .Call().

1
// [[ export(name = NA_character_) ]]

Export External / External2

Export a C function to the R side as an ExternalRoutine, suitable for use with .External() or .External2().

1
2
// [[ export_external(n, name = NA_character_) ]]
// [[ export_external2(n, name = NA_character_) ]]

Callable

Register a C function to be callable by other R packages.

1
// [[ callable(name = NA_character_, hidden = FALSE) ]]

Init

Sometimes you need to initialize extra objects at package load time. By marking a function with init(), it will get included at the end of the call to R_init_<pkg>(), which is called whenever the package is loaded. The function marked with init() should return void and take 1 argument, a DllInfo*, typically given the variable name dll.

1
// [[ init() ]]

DavisVaughan/cbuild documentation built on Dec. 25, 2019, 5:11 a.m.