Skip to content
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions src/altrep.cc
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@ bool vroom_altrep(SEXP x) {

if (ALTREP(x)) {

auto csym = CAR(ATTRIB(ALTREP_CLASS(x)));
auto psym = CADR(ATTRIB(ALTREP_CLASS(x)));
auto csym = R_altrep_class_name(x);
auto psym = R_altrep_class_package(x);
bool is_altrep = ALTREP(x);
bool materialzied = R_altrep_data2(x) != R_NilValue;

Expand Down
14 changes: 14 additions & 0 deletions src/altrep.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#pragma once
Copy link
Member Author

Choose a reason for hiding this comment

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

This should have really been here before, but it becomes absolutely necessary now that we've got some inline function definitions here.


#include <cpp11/R.hpp>

#include <R_ext/Rdynload.h>
Expand All @@ -10,3 +12,15 @@ extern "C" {
#if R_VERSION < R_Version(4, 6, 0)
#define DATAPTR_RW(x) DATAPTR(x)
#endif

// Backport ALTREP class accessors for R < 4.6.0
// These were introduced in R-devel:
// https://github.com/wch/r-source/commit/37eb29515a83672b53743cba11e88167ca063d06
#if R_VERSION < R_Version(4, 6, 0)
inline SEXP R_altrep_class_name(SEXP x) {
return ALTREP(x) ? CAR(ATTRIB(ALTREP_CLASS(x))) : R_NilValue;
}
inline SEXP R_altrep_class_package(SEXP x) {
return ALTREP(x) ? CADR(ATTRIB(ALTREP_CLASS(x))) : R_NilValue;
}
#endif