Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 21 additions & 3 deletions r/src/arrow_cpp11.h
Original file line number Diff line number Diff line change
Expand Up @@ -208,14 +208,26 @@ Pointer r6_to_pointer(SEXP self) {
cpp11::stop("Invalid R object for %s, must be an ArrowObject", type_name.c_str());
}

#if R_VERSION >= R_Version(4, 5, 0)
// R_UnboundValue and Rf_findVarInFrame are non-API as of R 4.6
#if R_VERSION >= R_Version(4, 6, 0)
SEXP xp = R_NilValue;
if (R_existsVarInFrame(self, arrow::r::symbols::xp)) {
xp = R_getVar(arrow::r::symbols::xp, self, FALSE);
}
if (xp == R_NilValue) {
cpp11::stop("Invalid: self$`.:xp:.` is NULL");
}
#elif R_VERSION >= R_Version(4, 5, 0)
SEXP xp = R_getVarEx(arrow::r::symbols::xp, self, FALSE, R_UnboundValue);
if (xp == R_UnboundValue || xp == R_NilValue) {
cpp11::stop("Invalid: self$`.:xp:.` is NULL");
}
#else
SEXP xp = Rf_findVarInFrame(self, arrow::r::symbols::xp);
#endif
if (xp == R_UnboundValue || xp == R_NilValue) {
cpp11::stop("Invalid: self$`.:xp:.` is NULL");
}
#endif

void* p = R_ExternalPtrAddr(xp);
if (p == nullptr) {
Expand All @@ -227,7 +239,13 @@ Pointer r6_to_pointer(SEXP self) {

template <typename T>
void r6_reset_pointer(SEXP r6) {
#if R_VERSION >= R_Version(4, 5, 0)
// R_UnboundValue and Rf_findVarInFrame are non-API as of R 4.6
#if R_VERSION >= R_Version(4, 6, 0)
if (!R_existsVarInFrame(r6, arrow::r::symbols::xp)) {
return;
}
SEXP xp = R_getVar(arrow::r::symbols::xp, r6, FALSE);
#elif R_VERSION >= R_Version(4, 5, 0)
SEXP xp = R_getVarEx(arrow::r::symbols::xp, r6, FALSE, R_UnboundValue);
#else
SEXP xp = Rf_findVarInFrame(r6, arrow::r::symbols::xp);
Expand Down
Loading