Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GH-43194: [R] R_existsVarInFrame isn't available earlier than R 4.2 #43243

Merged
merged 1 commit into from
Jul 14, 2024
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
8 changes: 8 additions & 0 deletions r/src/arrow_cpp11.h
Original file line number Diff line number Diff line change
Expand Up @@ -378,9 +378,17 @@ SEXP to_r6(const std::shared_ptr<T>& ptr, const char* r6_class_name) {
cpp11::external_pointer<std::shared_ptr<T>> xp(new std::shared_ptr<T>(ptr));
SEXP r6_class = Rf_install(r6_class_name);

// R_existsVarInFrame doesn't exist before R 4.2, so we need to fall back to
// Rf_findVarInFrame3 if it is not defined.
#ifdef R_existsVarInFrame
if (!R_existsVarInFrame(arrow::r::ns::arrow, r6_class)) {
cpp11::stop("No arrow R6 class named '%s'", r6_class_name);
}
#else
if (Rf_findVarInFrame3(arrow::r::ns::arrow, r6_class, FALSE) == R_UnboundValue) {
cpp11::stop("No arrow R6 class named '%s'", r6_class_name);
}
#endif

// make call: <symbol>$new(<x>)
SEXP call = PROTECT(Rf_lang3(R_DollarSymbol, r6_class, arrow::r::symbols::new_));
Expand Down
Loading