| Title: | Manipulating External Pointers |
|---|---|
| Description: | There is limited native support for external pointers in the R interface. This package provides some basic tools to verify, create and modify 'externalptr' objects. |
| Authors: | Randy Lai [aut], Dirk Eddelbuettel [aut, cre] |
| Maintainer: | Dirk Eddelbuettel <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 1.2.0 |
| Built: | 2026-05-12 05:16:31 UTC |
| Source: | https://github.com/eddelbuettel/xptr |
Check if the external pointer is null.
is_null_xptr(s)is_null_xptr(s)
s |
An |
A boolean
Check if an object is an external pointer.
is_xptr(s)is_xptr(s)
s |
An |
A boolean
Create an external pointer object.
new_xptr(address = "", tag = NULL, protected = NULL) null_xptr(tag = NULL, protected = NULL)new_xptr(address = "", tag = NULL, protected = NULL) null_xptr(tag = NULL, protected = NULL)
address |
A string of pointer address |
tag |
An optional tag |
protected |
an objected to be protected from gc within the lifetime of the external pointer |
An externalptr object
Register a finalizer for external pointer.
register_xptr_finalizer(s, f, onexit = FALSE)register_xptr_finalizer(s, f, onexit = FALSE)
s |
An |
f |
An R function |
onexit |
should the finalizer execute on exit? |
No return value as the function is called for its side effect
Set the address of the external pointer.
set_xptr_address(s, p)set_xptr_address(s, p)
s |
An |
p |
A string of pointer address |
No return value as the function is called for its side effect
Set a protected R object to the external pointer.
set_xptr_protected(s, protected)set_xptr_protected(s, protected)
s |
An |
protected |
An R object |
No return value as the function is called for its side effect
Set a tag to the external pointer.
set_xptr_tag(s, tag)set_xptr_tag(s, tag)
s |
An |
tag |
An R object |
No return value as the function is called for its side effect
There is limited native support for external pointers in the R interface. This package provides some basic tools to verify, create and modify 'externalptr' objects.
Randy Lai and Dirk Eddelbuettel
https://cran.r-project.org/doc/manuals/r-release/R-exts.html#External-pointers-and-weak-references
library(xptr) a <- new_xptr("0x11a888090") b <- new_xptr("0x11a888098") is_xptr(a) xptr_address(a) xptr_clear(a) is_null_xptr(a) set_xptr_address(a, xptr_address(b)) xptr_address(a) xptr_address(a, FALSE)library(xptr) a <- new_xptr("0x11a888090") b <- new_xptr("0x11a888098") is_xptr(a) xptr_address(a) xptr_clear(a) is_null_xptr(a) set_xptr_address(a, xptr_address(b)) xptr_address(a) xptr_address(a, FALSE)
External pointer address.
xptr_address(s, pf = TRUE)xptr_address(s, pf = TRUE)
s |
An |
pf |
A |
A string of pointer address
Clear the pointer address of the external pointer.
xptr_clear(s)xptr_clear(s)
s |
An |
No return value as the function is called for its side effect
Protected R object of the external pointer.
xptr_protected(s)xptr_protected(s)
s |
An |
An R object
Tag of the external pointer.
xptr_tag(s)xptr_tag(s)
s |
An |
The R object stored in the tag slot