Skip to content

Commit 65d40f9

Browse files
authored
Switch to R_getRegisteredNamespace (#1469)
* Further R-devel driven refinement for function-in-namespace lookup * Further refinement following rebase
1 parent 7f928e7 commit 65d40f9

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

ChangeLog

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
2026-04-02 Dirk Eddelbuettel <edd@debian.org>
2+
3+
* inst/include/Rcpp/Function.h: Further refinement for 4.6.0 to not
4+
require R_NamespaceRegistry, using R_getRegisteredNamespace() instead
5+
16
2026-04-01 Mattias Ellert <mattias.ellert@physics.uu.se>
27

38
* inst/discovery/cxx0x.R: Set execute permissions for script

inst/include/Rcpp/Function.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,21 @@ namespace Rcpp{
7171

7272
Function_Impl(const std::string& name, const std::string& ns) {
7373
#if R_VERSION < R_Version(4,5,0)
74+
// before R 4.5.0 we would use Rf_findVarInFrame
7475
Shield<SEXP> env(Rf_findVarInFrame(R_NamespaceRegistry, Rf_install(ns.c_str())));
7576
if (env == R_UnboundValue)
7677
stop("there is no namespace called \"%s\"", ns);
77-
#else
78+
#elif R_VERSION < R_Version(4,6,0) || R_SVN_REVISION < 89746
79+
// during R 4.5.* and before final R 4.6.0 we could use R_getVarEx
80+
// along with R_NamespaceRegistry but avoid R_UnboundValue
7881
Shield<SEXP> env(R_getVarEx(Rf_install(ns.c_str()), R_NamespaceRegistry, FALSE, R_NilValue));
7982
if (env == R_NilValue)
8083
stop("there is no namespace called \"%s\"", ns);
84+
#else
85+
// late R 4.6.0 development got us R_getRegisteredNamespace
86+
Shield<SEXP> env(R_getRegisteredNamespace(ns.c_str()));
87+
if (env == R_NilValue)
88+
stop("there is no namespace called \"%s\"", ns);
8189
#endif
8290
get_function(name, env);
8391
}

0 commit comments

Comments
 (0)