Skip to content

Add non_api module behind an off-by-default non-api feature#266

Open
CGMossa wants to merge 1 commit into
extendr:masterfrom
CGMossa:copy-extendr-non-api
Open

Add non_api module behind an off-by-default non-api feature#266
CGMossa wants to merge 1 commit into
extendr:masterfrom
CGMossa:copy-extendr-non-api

Conversation

@CGMossa

@CGMossa CGMossa commented Jun 30, 2026

Copy link
Copy Markdown
Member

TODO: replace this line with your own framing, in your own voice.

AI-written details

Summary

  • Ports extendr-ffi's non_api module (verbatim, with attribution) into src/non_api.rs: declarations for a small set of R "non-API" entry points (promise / environment / closure accessors such as PRCODE, ENCLOS, SET_PRVALUE, Rf_allocSExp, …).
  • Adds a non-api Cargo feature that is not in default (mirrors extendr-ffi's default = [] / non-api = []), so default builds are unchanged. The module is #[cfg(feature = "non-api")] pub mod non_api;.

Test plan

  • cargo build (default): compiles, module excluded.
  • cargo build --features non-api against R 4.6.0: compiles, 0 errors.
  • cargo metadata confirms default = [] (feature is opt-in).

Notes

  • Copied, not depended on, since libR-sys cannot depend on extendr-ffi.
  • These symbols are outside R's stable C API and some are not exported by every R version. Against R 4.6, SET_FORMALS, SET_BODY, SET_CLOENV, PRSEEN, and Rf_isValidStringF are not exported, so calling those specific functions on 4.6 would fail to link. The feature is opt-in and unsafe by nature; declarations are kept verbatim to match extendr-ffi rather than pruned per R version.

Drafted by Claude (claude-opus-4-8). Reviewed by the author.

Port extendr-ffi's `non_api` module (verbatim, with attribution): declarations
for a small set of R "non-API" entry points (promise/environment/closure
accessors such as PRCODE, ENCLOS, SET_PRVALUE, Rf_allocSExp).

Gated behind a new `non-api` feature that is NOT in `default`, mirroring
extendr-ffi's `non-api = []`. These symbols are outside R's stable C API and
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 they are
opt-in only.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant