/
C_wrappers.R
36 lines (30 loc) · 1.16 KB
/
C_wrappers.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#' @useDynLib constructive
NULL
#' Build a pointer from a memory address
#'
#' Base R doesn't provide utilities to build or manipulate external pointers
#' (objects of type "externalptr"), so we provide our own. Be warned that
#' objects defined with `.xptr()` are not stable across sessions,
#' however this is the best we can
#' @param address Memory address
#' @return The external pointer (type "externalptr") that the memory address points to.
#' @export
.xptr <- function(address) {
.Call("external_pointer", PACKAGE = "constructive", address)
}
external_pointer_address <- function(s) {
if (identical(Sys.getenv("TESTTHAT"), "true")) return("0x123456789")
.Call("external_pointer_address", PACKAGE = "constructive", s)
}
env_impl <- function(address) {
.Call("objectFromAddress", PACKAGE = "constructive", address)
}
is_promise <- function(name, env = parent.frame()) {
.Call("is_promise", PACKAGE = "constructive", name, env)
}
promise_code <- function(name, env = parent.frame()) {
.Call("promise_code", PACKAGE = "constructive", name, env)
}
promise_env <- function(name, env = parent.frame()) {
.Call("promise_env", PACKAGE = "constructive", name, env)
}