Expand description
This is responsible for generating the C functions that act as wrappers of the exported Rust functions.
extendr relies on the .Call-interface
In short, it is necessary the the signature of the C-function have SEXP
as the type for return type, and argument types.
For instance, if your function returns nothing, the return type is not
allowed to be void, instead SEXP must be used, and one should return
R_NilValue.
Β§R wrappers
Within R, you may call rextendr::document() to generate R functions,
that use the .Call-interface, to call the wrapped Rust functions.
You may also manually implement these wrappers, in order to do special
type-checking, or other annotation, that could be more convenient to do
on the R-side. The C-functions are named according to "{WRAP_PREFIX}{prefix}{mod_name}".
See WRAP_PREFIX, and note that prefix is set specifically for methods in
extendr-impl blocks, while for functions have no prefix.
Re-exportsΒ§
use proc_macro2::Ident;πuse quote::format_ident;πuse quote::quote;πuse std::collections::HashMap;πuse std::sync::Mutex;πuse syn::parse_quote;πuse syn::punctuated::Punctuated;πuse syn::Expr;πuse syn::ExprLit;πuse syn::FnArg;πuse syn::ItemFn;πuse syn::Token;πuse syn::Type;πuse crate::extendr_options::ExtendrOptions;π
StructsΒ§
- STRUCT_
DOCS π
ConstantsΒ§
FunctionsΒ§
- get_
defaults π - get_
doc_ string - get_
named_ πlit - get_
return_ type - get_
struct_ doc - Retrieve the structβlevel docs (or empty if none).
- make_
function_ πwrappers - mangled_
type_ name - register_
struct_ doc - Called by the structβlevel
extendr-macro to register docstrings. - sanitize_
identifier π - translate_
actual π - translate_
formal - translate_
meta_ πarg - translate_
only_ πalias - Returns only the alias from a function argument.
- translate_
to_ πrobj - Convert
SEXParguments intoRobj. This maintains the lifetime of references. - type_
name - Return a simplified type name that will be meaningful to R. Defaults to a digest.
- type_
needs_ πmut_ robj