From d3e5a1c09486135903df8cb8f846fd8429d3b52f Mon Sep 17 00:00:00 2001 From: Dirk Eddelbuettel Date: Fri, 12 Dec 2025 14:41:51 -0600 Subject: [PATCH 1/3] Switch from Rf_findVarInFrame to R_getVarEx --- ChangeLog | 4 ++++ DESCRIPTION | 2 +- inst/include/Rcpp/Environment.h | 27 ++++++++++++++++++++++----- inst/include/Rcpp/Function.h | 9 ++++++--- src/barrier.cpp | 6 +++++- 5 files changed, 38 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index 97f52ffaf..06f796762 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,10 @@ * inst/tinytest/test_system.R: Wrap suppressMessages() around three tests for long-obsolete linker and compiler flags + * inst/include/Rcpp/Environment.h: Replace use of Rf_findVarInFrame + with R_getVarEx (or R_getVar) if R 4.5.0 or later is used + * inst/include/Rcpp/Function.h: Idem + * src/barrier.cpp: Idem 2025-12-10 Dirk Eddelbuettel diff --git a/DESCRIPTION b/DESCRIPTION index ad2585f2d..b2232f239 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: Rcpp Title: Seamless R and C++ Integration Version: 1.1.0.9 -Date: 2025-12-10 +Date: 2025-12-13 Authors@R: c(person("Dirk", "Eddelbuettel", role = c("aut", "cre"), email = "edd@debian.org", comment = c(ORCID = "0000-0001-6419-907X")), person("Romain", "Francois", role = "aut", diff --git a/inst/include/Rcpp/Environment.h b/inst/include/Rcpp/Environment.h index 901b3fb5e..95292baf9 100644 --- a/inst/include/Rcpp/Environment.h +++ b/inst/include/Rcpp/Environment.h @@ -1,9 +1,8 @@ -// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; indent-tabs-mode: nil; -*- -// + // Environment.h: Rcpp R/C++ interface class library -- access R environments // // Copyright (C) 2009 - 2013 Dirk Eddelbuettel and Romain Francois -// Copyright (C) 2014 - 2020 Dirk Eddelbuettel, Romain Francois and Kevin Ushey +// Copyright (C) 2014 - 2025 Dirk Eddelbuettel, Romain Francois and Kevin Ushey // // This file is part of Rcpp. // @@ -98,8 +97,11 @@ namespace Rcpp{ SEXP get(const std::string& name) const { SEXP env = Storage::get__() ; SEXP nameSym = Rf_install(name.c_str()); +#if R_VERSION < R_Version(4,5,0) SEXP res = Rf_findVarInFrame( env, nameSym ) ; - +#else + SEXP res = R_getVarEx(nameSym, env, TRUE, R_UnboundValue); +#endif if( res == R_UnboundValue ) return R_NilValue ; /* We need to evaluate if it is a promise */ @@ -118,7 +120,11 @@ namespace Rcpp{ */ SEXP get(Symbol name) const { SEXP env = Storage::get__() ; +#if R_VERSION < R_Version(4,5,0) SEXP res = Rf_findVarInFrame( env, name ) ; +#else + SEXP res = R_getVarEx(name, env, TRUE, R_UnboundValue); +#endif if( res == R_UnboundValue ) return R_NilValue ; @@ -140,7 +146,11 @@ namespace Rcpp{ SEXP find( const std::string& name) const{ SEXP env = Storage::get__() ; SEXP nameSym = Rf_install(name.c_str()); +#if R_VERSION < R_Version(4,5,0) SEXP res = Rf_findVar( nameSym, env ) ; +#else + SEXP res = R_getVarEx(nameSym, env, TRUE, R_UnboundValue); +#endif if( res == R_UnboundValue ) throw binding_not_found(name) ; @@ -159,8 +169,11 @@ namespace Rcpp{ */ SEXP find(Symbol name) const{ SEXP env = Storage::get__() ; +#if R_VERSION < R_Version(4,5,0) SEXP res = Rf_findVar( name, env ) ; - +#else + SEXP res = R_getVarEx(name, env, TRUE, R_UnboundValue); +#endif if( res == R_UnboundValue ) { // Pass on the const char* to the RCPP_EXCEPTION_CLASS's // const std::string& requirement @@ -184,7 +197,11 @@ namespace Rcpp{ */ bool exists( const std::string& name ) const { SEXP nameSym = Rf_install(name.c_str()); +#if R_VERSION < R_Version(4,5,0) SEXP res = Rf_findVarInFrame( Storage::get__() , nameSym ) ; +#else + SEXP res = R_getVarEx(nameSym, Storage::get__(), FALSE, R_UnboundValue); +#endif return res != R_UnboundValue ; } diff --git a/inst/include/Rcpp/Function.h b/inst/include/Rcpp/Function.h index c06f65cc8..3c1e21e99 100644 --- a/inst/include/Rcpp/Function.h +++ b/inst/include/Rcpp/Function.h @@ -1,8 +1,7 @@ -// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; indent-tabs-mode: nil; -*- -// + // Function.h: Rcpp R/C++ interface class library -- functions (also primitives and builtins) // -// Copyright (C) 2010 - 2013 Dirk Eddelbuettel and Romain Francois +// Copyright (C) 2010 - 2025 Dirk Eddelbuettel and Romain Francois // // This file is part of Rcpp. // @@ -70,7 +69,11 @@ namespace Rcpp{ } Function_Impl(const std::string& name, const std::string& ns) { +#if R_VERSION < R_Version(4,5,0) Shield env(Rf_findVarInFrame(R_NamespaceRegistry, Rf_install(ns.c_str()))); +#else + Shield env(R_getVarEx(Rf_install(ns.c_str()), R_NamespaceRegistry, FALSE, R_UnboundValue)); +#endif if (env == R_UnboundValue) { stop("there is no namespace called \"%s\"", ns); } diff --git a/src/barrier.cpp b/src/barrier.cpp index e3ac21a6a..06ae0e0ab 100644 --- a/src/barrier.cpp +++ b/src/barrier.cpp @@ -2,7 +2,7 @@ // barrier.cpp: Rcpp R/C++ interface class library -- write barrier // // Copyright (C) 2010 - 2020 Dirk Eddelbuettel and Romain Francois -// Copyright (C) 2021 - 2022 Dirk Eddelbuettel, Romain Francois and Iñaki Ucar +// Copyright (C) 2021 - 2025 Dirk Eddelbuettel, Romain Francois and Iñaki Ucar // // This file is part of Rcpp. // @@ -150,7 +150,11 @@ SEXP get_rcpp_cache() { Rcpp::Shield call(Rf_lang2(getNamespaceSym, RcppString)); Rcpp::Shield RCPP(Rf_eval(call, R_GlobalEnv)); +#if R_VERSION < R_Version(4,5,0) Rcpp_cache = Rf_findVarInFrame(RCPP, Rf_install(".rcpp_cache")); +#else + Rcpp_cache = R_getVar(Rf_install(".rcpp_cache"), RCPP, TRUE); +#endif Rcpp_cache_know = true; } return Rcpp_cache; From daeaa114f02a20997dcc6b5e69b1bd5b0b62aa7b Mon Sep 17 00:00:00 2001 From: Dirk Eddelbuettel Date: Fri, 12 Dec 2025 17:04:29 -0600 Subject: [PATCH 2/3] Micro whitespace edit following rebase [ci skip] --- ChangeLog | 1 + 1 file changed, 1 insertion(+) diff --git a/ChangeLog b/ChangeLog index 06f796762..2027a2714 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,7 @@ * inst/tinytest/test_system.R: Wrap suppressMessages() around three tests for long-obsolete linker and compiler flags + * inst/include/Rcpp/Environment.h: Replace use of Rf_findVarInFrame with R_getVarEx (or R_getVar) if R 4.5.0 or later is used * inst/include/Rcpp/Function.h: Idem From 3f4ff02864874acc8d9aacd4a9aa36d15eea9535 Mon Sep 17 00:00:00 2001 From: Dirk Eddelbuettel Date: Fri, 12 Dec 2025 20:06:58 -0600 Subject: [PATCH 3/3] Adjust two 'inherits'-alike arguments following review comments --- inst/include/Rcpp/Environment.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/inst/include/Rcpp/Environment.h b/inst/include/Rcpp/Environment.h index 95292baf9..4072755f7 100644 --- a/inst/include/Rcpp/Environment.h +++ b/inst/include/Rcpp/Environment.h @@ -100,7 +100,7 @@ namespace Rcpp{ #if R_VERSION < R_Version(4,5,0) SEXP res = Rf_findVarInFrame( env, nameSym ) ; #else - SEXP res = R_getVarEx(nameSym, env, TRUE, R_UnboundValue); + SEXP res = R_getVarEx(nameSym, env, FALSE, R_UnboundValue); #endif if( res == R_UnboundValue ) return R_NilValue ; @@ -123,7 +123,7 @@ namespace Rcpp{ #if R_VERSION < R_Version(4,5,0) SEXP res = Rf_findVarInFrame( env, name ) ; #else - SEXP res = R_getVarEx(name, env, TRUE, R_UnboundValue); + SEXP res = R_getVarEx(name, env, FALSE, R_UnboundValue); #endif if( res == R_UnboundValue ) return R_NilValue ;