Type: | Package |
Title: | Manipulating External Pointers |
Version: | 1.2.0 |
Date: | 2025-10-03 |
URL: | https://github.com/eddelbuettel/xptr/, https://eddelbuettel.github.io/xptr/ |
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. |
License: | MIT + file LICENSE |
NeedsCompilation: | yes |
Encoding: | UTF-8 |
RoxygenNote: | 7.3.3 |
Packaged: | 2025-10-03 14:05:19 UTC; edd |
Author: | Randy Lai [aut], Dirk Eddelbuettel [aut, cre] |
Maintainer: | Dirk Eddelbuettel <edd@debian.org> |
Repository: | CRAN |
Date/Publication: | 2025-10-08 19:30:02 UTC |
Check if the external pointer is null.
Description
Check if the external pointer is null.
Usage
is_null_xptr(s)
Arguments
s |
An |
Value
A boolean
Check if an object is an external pointer.
Description
Check if an object is an external pointer.
Usage
is_xptr(s)
Arguments
s |
An |
Value
A boolean
Create an external pointer object.
Description
Create an external pointer object.
Usage
new_xptr(address = "", tag = NULL, protected = NULL)
null_xptr(tag = NULL, protected = NULL)
Arguments
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 |
Value
An externalptr
object
Register a finalizer for external pointer.
Description
Register a finalizer for external pointer.
Usage
register_xptr_finalizer(s, f, onexit = FALSE)
Arguments
s |
An |
f |
An R function |
onexit |
should the finalizer execute on exit? |
Value
No return value as the function is called for its side effect
See Also
Set the address of the external pointer.
Description
Set the address of the external pointer.
Usage
set_xptr_address(s, p)
Arguments
s |
An |
p |
A string of pointer address |
Value
No return value as the function is called for its side effect
Set a protected R object to the external pointer.
Description
Set a protected R object to the external pointer.
Usage
set_xptr_protected(s, protected)
Arguments
s |
An |
protected |
An R object |
Value
No return value as the function is called for its side effect
Set a tag to the external pointer.
Description
Set a tag to the external pointer.
Usage
set_xptr_tag(s, tag)
Arguments
s |
An |
tag |
An R object |
Value
No return value as the function is called for its side effect
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.
Author(s)
Randy Lai and Dirk Eddelbuettel
References
https://cran.r-project.org/doc/manuals/r-release/R-exts.html#External-pointers-and-weak-references
Examples
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.
Description
External pointer address.
Usage
xptr_address(s, pf = TRUE)
Arguments
s |
An |
pf |
A |
Value
A string of pointer address
Clear the pointer address of the external pointer.
Description
Clear the pointer address of the external pointer.
Usage
xptr_clear(s)
Arguments
s |
An |
Value
No return value as the function is called for its side effect
Protected R object of the external pointer.
Description
Protected R object of the external pointer.
Usage
xptr_protected(s)
Arguments
s |
An |
Value
An R object
Tag of the external pointer.
Description
Tag of the external pointer.
Usage
xptr_tag(s)
Arguments
s |
An |
Value
The R object stored in the tag slot