jonkeane commented on a change in pull request #11919:
URL: https://github.com/apache/arrow/pull/11919#discussion_r766141468
##########
File path: r/tests/testthat/test-python.R
##########
@@ -143,3 +143,70 @@ test_that("RecordBatchReader from python", {
expect_r6_class(rt_table, "Table")
expect_identical(as.data.frame(rt_table), example_data)
})
+
+test_that("Pointer wrapper accepts external pointers", {
Review comment:
It's totally fine to keep these here, they certainly are mostly tested
with Python, but I wonder if these should go in a file dedicated to c-stream
interactions (especially now that we have DuckDB using some of the same
infrastructure
##########
File path: r/src/arrow_cpp11.h
##########
@@ -57,13 +57,45 @@ namespace r {
template <typename T>
struct Pointer {
Pointer() : ptr_(new T()) {}
- explicit Pointer(SEXP x)
- : ptr_(reinterpret_cast<T*>(static_cast<uintptr_t>(REAL(x)[0]))) {}
+ explicit Pointer(SEXP x) {
+ if (TYPEOF(x) == EXTPTRSXP) {
+ ptr_ = (T*)R_ExternalPtrAddr(x);
+ } else if (TYPEOF(x) == STRSXP && Rf_length(x) == 1) {
+ // User passed an character representation of the pointer address
Review comment:
Super minor
```suggestion
// User passed a character representation of the pointer address
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]