Skip to content

Commit 582376a

Browse files
authored
Switch from Rf_findVarInFrame to R_getVarEx (#1423)
* Switch from Rf_findVarInFrame to R_getVarEx * Micro whitespace edit following rebase [ci skip] * Adjust two 'inherits'-alike arguments following review comments
1 parent 8926946 commit 582376a

File tree

5 files changed

+39
-10
lines changed

5 files changed

+39
-10
lines changed

ChangeLog

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
* inst/tinytest/test_system.R: Wrap suppressMessages() around three
44
tests for long-obsolete linker and compiler flags
55

6+
* inst/include/Rcpp/Environment.h: Replace use of Rf_findVarInFrame
7+
with R_getVarEx (or R_getVar) if R 4.5.0 or later is used
8+
* inst/include/Rcpp/Function.h: Idem
9+
* src/barrier.cpp: Idem
10+
611
2025-12-10 Dirk Eddelbuettel <edd@debian.org>
712

813
* DESCRIPTION (Version, Date): Roll micro version and date

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Package: Rcpp
22
Title: Seamless R and C++ Integration
33
Version: 1.1.0.9
4-
Date: 2025-12-10
4+
Date: 2025-12-13
55
Authors@R: c(person("Dirk", "Eddelbuettel", role = c("aut", "cre"), email = "edd@debian.org",
66
comment = c(ORCID = "0000-0001-6419-907X")),
77
person("Romain", "Francois", role = "aut",

inst/include/Rcpp/Environment.h

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; indent-tabs-mode: nil; -*-
2-
//
1+
32
// Environment.h: Rcpp R/C++ interface class library -- access R environments
43
//
54
// Copyright (C) 2009 - 2013 Dirk Eddelbuettel and Romain Francois
6-
// Copyright (C) 2014 - 2020 Dirk Eddelbuettel, Romain Francois and Kevin Ushey
5+
// Copyright (C) 2014 - 2025 Dirk Eddelbuettel, Romain Francois and Kevin Ushey
76
//
87
// This file is part of Rcpp.
98
//
@@ -98,8 +97,11 @@ namespace Rcpp{
9897
SEXP get(const std::string& name) const {
9998
SEXP env = Storage::get__() ;
10099
SEXP nameSym = Rf_install(name.c_str());
100+
#if R_VERSION < R_Version(4,5,0)
101101
SEXP res = Rf_findVarInFrame( env, nameSym ) ;
102-
102+
#else
103+
SEXP res = R_getVarEx(nameSym, env, FALSE, R_UnboundValue);
104+
#endif
103105
if( res == R_UnboundValue ) return R_NilValue ;
104106

105107
/* We need to evaluate if it is a promise */
@@ -118,7 +120,11 @@ namespace Rcpp{
118120
*/
119121
SEXP get(Symbol name) const {
120122
SEXP env = Storage::get__() ;
123+
#if R_VERSION < R_Version(4,5,0)
121124
SEXP res = Rf_findVarInFrame( env, name ) ;
125+
#else
126+
SEXP res = R_getVarEx(name, env, FALSE, R_UnboundValue);
127+
#endif
122128

123129
if( res == R_UnboundValue ) return R_NilValue ;
124130

@@ -140,7 +146,11 @@ namespace Rcpp{
140146
SEXP find( const std::string& name) const{
141147
SEXP env = Storage::get__() ;
142148
SEXP nameSym = Rf_install(name.c_str());
149+
#if R_VERSION < R_Version(4,5,0)
143150
SEXP res = Rf_findVar( nameSym, env ) ;
151+
#else
152+
SEXP res = R_getVarEx(nameSym, env, TRUE, R_UnboundValue);
153+
#endif
144154

145155
if( res == R_UnboundValue ) throw binding_not_found(name) ;
146156

@@ -159,8 +169,11 @@ namespace Rcpp{
159169
*/
160170
SEXP find(Symbol name) const{
161171
SEXP env = Storage::get__() ;
172+
#if R_VERSION < R_Version(4,5,0)
162173
SEXP res = Rf_findVar( name, env ) ;
163-
174+
#else
175+
SEXP res = R_getVarEx(name, env, TRUE, R_UnboundValue);
176+
#endif
164177
if( res == R_UnboundValue ) {
165178
// Pass on the const char* to the RCPP_EXCEPTION_CLASS's
166179
// const std::string& requirement
@@ -184,7 +197,11 @@ namespace Rcpp{
184197
*/
185198
bool exists( const std::string& name ) const {
186199
SEXP nameSym = Rf_install(name.c_str());
200+
#if R_VERSION < R_Version(4,5,0)
187201
SEXP res = Rf_findVarInFrame( Storage::get__() , nameSym ) ;
202+
#else
203+
SEXP res = R_getVarEx(nameSym, Storage::get__(), FALSE, R_UnboundValue);
204+
#endif
188205
return res != R_UnboundValue ;
189206
}
190207

inst/include/Rcpp/Function.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; indent-tabs-mode: nil; -*-
2-
//
1+
32
// Function.h: Rcpp R/C++ interface class library -- functions (also primitives and builtins)
43
//
5-
// Copyright (C) 2010 - 2013 Dirk Eddelbuettel and Romain Francois
4+
// Copyright (C) 2010 - 2025 Dirk Eddelbuettel and Romain Francois
65
//
76
// This file is part of Rcpp.
87
//
@@ -70,7 +69,11 @@ namespace Rcpp{
7069
}
7170

7271
Function_Impl(const std::string& name, const std::string& ns) {
72+
#if R_VERSION < R_Version(4,5,0)
7373
Shield<SEXP> env(Rf_findVarInFrame(R_NamespaceRegistry, Rf_install(ns.c_str())));
74+
#else
75+
Shield<SEXP> env(R_getVarEx(Rf_install(ns.c_str()), R_NamespaceRegistry, FALSE, R_UnboundValue));
76+
#endif
7477
if (env == R_UnboundValue) {
7578
stop("there is no namespace called \"%s\"", ns);
7679
}

src/barrier.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// barrier.cpp: Rcpp R/C++ interface class library -- write barrier
33
//
44
// Copyright (C) 2010 - 2020 Dirk Eddelbuettel and Romain Francois
5-
// Copyright (C) 2021 - 2022 Dirk Eddelbuettel, Romain Francois and Iñaki Ucar
5+
// Copyright (C) 2021 - 2025 Dirk Eddelbuettel, Romain Francois and Iñaki Ucar
66
//
77
// This file is part of Rcpp.
88
//
@@ -150,7 +150,11 @@ SEXP get_rcpp_cache() {
150150
Rcpp::Shield<SEXP> call(Rf_lang2(getNamespaceSym, RcppString));
151151
Rcpp::Shield<SEXP> RCPP(Rf_eval(call, R_GlobalEnv));
152152

153+
#if R_VERSION < R_Version(4,5,0)
153154
Rcpp_cache = Rf_findVarInFrame(RCPP, Rf_install(".rcpp_cache"));
155+
#else
156+
Rcpp_cache = R_getVar(Rf_install(".rcpp_cache"), RCPP, TRUE);
157+
#endif
154158
Rcpp_cache_know = true;
155159
}
156160
return Rcpp_cache;

0 commit comments

Comments
 (0)