Skip to content
Open
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
21 changes: 9 additions & 12 deletions r/src/arrow_cpp11.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,6 @@
#define ARROW_R_DCHECK(EXPR)
#endif

#if (R_VERSION < R_Version(3, 5, 0))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed this dead code as we're not supporting such old R versions any more

#define LOGICAL_RO(x) ((const int*)LOGICAL(x))
#define INTEGER_RO(x) ((const int*)INTEGER(x))
#define REAL_RO(x) ((const double*)REAL(x))
#define COMPLEX_RO(x) ((const Rcomplex*)COMPLEX(x))
#define STRING_PTR_RO(x) ((const SEXP*)STRING_PTR(x))
#define RAW_RO(x) ((const Rbyte*)RAW(x))
#define DATAPTR_RO(x) ((const void*)STRING_PTR(x))
#define DATAPTR(x) (void*)STRING_PTR(x)
#endif

// R_altrep_class_name and R_altrep_class_package don't exist before R 4.6
#if R_VERSION < R_Version(4, 6, 0)
inline SEXP R_altrep_class_name(SEXP x) {
Expand Down Expand Up @@ -219,8 +208,12 @@ 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)
SEXP xp = R_getVarEx(arrow::r::symbols::xp, self, FALSE, R_UnboundValue);
#else
SEXP xp = Rf_findVarInFrame(self, arrow::r::symbols::xp);
if (xp == R_NilValue) {
#endif
if (xp == R_UnboundValue || xp == R_NilValue) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you know why we need to add the xp == R_UnboundValue here? That's new right?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My understanding is because the call to R_getVarEx() returns R_UnboundValue if it doesn't return anything for xp[1]

[1] r-devel/r-svn@29a2fda#diff-5272e85b221848a45cc500d6792e9aba179ddbbaa817e48757b686deead11245R2274-R2294

cpp11::stop("Invalid: self$`.:xp:.` is NULL");
}

Expand All @@ -234,7 +227,11 @@ Pointer r6_to_pointer(SEXP self) {

template <typename T>
void r6_reset_pointer(SEXP r6) {
#if 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);
#endif
void* p = R_ExternalPtrAddr(xp);
if (p != nullptr) {
delete reinterpret_cast<const std::shared_ptr<T>*>(p);
Expand Down
Loading