Skip to content
Open
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
7 changes: 7 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ links = "R"
documentation = "https://docs.rs/libR-sys/latest/libR_sys/"
repository = "https://github.com/extendr/libR-sys"

[features]
default = []
# Expose a small set of R "non-API" entry points (promise/environment/closure
# accessors) in the `non_api` module. Off by default: these are not part of R's
# stable C API and may not be available on every R version.
non-api = []

[lib]
# Some code comments on R's source code might be accidentally treated as Rust's
# doc test. See https://github.com/extendr/libR-sys/issues/194 for the details.
Expand Down
3 changes: 3 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@

include!(concat!(env!("OUT_DIR"), "/bindings.rs"));

#[cfg(feature = "non-api")]
pub mod non_api;

#[non_exhaustive]
#[repr(transparent)]
#[derive(Debug)]
Expand Down
32 changes: 32 additions & 0 deletions src/non_api.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
//! R "non-API" entry points, gated behind the off-by-default `non-api` feature.
//!
//! These are not part of R's stable C API; some are not exported by every R
//! version (e.g. `SET_FORMALS`, `SET_BODY`, `SET_CLOENV`, `PRSEEN`,
//! `Rf_isValidStringF` are not exported by R 4.6), so calling them may fail to
//! link depending on the R you build against. Use with care.
//!
//! Ported from `extendr-ffi` (`src/non_api.rs`).
use crate::{Rboolean, SEXP, SEXPTYPE};
extern "C" {
pub fn Rf_isValidString(arg1: SEXP) -> Rboolean;
pub fn Rf_isValidStringF(arg1: SEXP) -> Rboolean;
pub fn SYMVALUE(x: SEXP) -> SEXP;
pub fn PRSEEN(x: SEXP) -> ::std::os::raw::c_int;
pub fn SET_ENCLOS(x: SEXP, v: SEXP);
pub fn ENVFLAGS(x: SEXP) -> ::std::os::raw::c_int;
pub fn SET_ENVFLAGS(x: SEXP, v: ::std::os::raw::c_int);
pub fn ENCLOS(x: SEXP) -> SEXP;
pub fn HASHTAB(x: SEXP) -> SEXP;
pub fn FRAME(x: SEXP) -> SEXP;
pub fn Rf_allocSExp(arg1: SEXPTYPE) -> SEXP;
pub fn SET_FORMALS(x: SEXP, v: SEXP);
pub fn SET_BODY(x: SEXP, v: SEXP);
pub fn SET_CLOENV(x: SEXP, v: SEXP);
pub fn SET_PRCODE(x: SEXP, v: SEXP);
pub fn SET_PRENV(x: SEXP, v: SEXP);
pub fn SET_PRVALUE(x: SEXP, v: SEXP);
#[doc = "Promise Access Functions"]
pub fn PRCODE(x: SEXP) -> SEXP;
pub fn PRENV(x: SEXP) -> SEXP;
pub fn PRVALUE(x: SEXP) -> SEXP;
}
Loading