Skip to content

Commit

Permalink
use Rf_findVarInFrame instead of Rf_findVarInFrame3
Browse files Browse the repository at this point in the history
  • Loading branch information
dipterix committed Jan 16, 2024
1 parent 6f01684 commit 5ec8ade
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: dipsaus
Type: Package
Title: A Dipping Sauce for Data Analysis and Visualizations
Version: 0.2.8.9002
Version: 0.2.8.9003
Authors@R: c(
person("Zhengjia", "Wang", email = "[email protected]", role = c("aut", "cre")),
person("John", "Magnotti", email = "[email protected]", role = c("ctb"),
Expand Down
15 changes: 11 additions & 4 deletions src/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -289,11 +289,10 @@ bool is_namespace(SEXP &rho) {
if (rho == R_BaseNamespace)
return true;
else if (TYPEOF(rho) == ENVSXP) {
Rboolean do_get = TRUE;
SEXP info = Rf_findVarInFrame3(rho, Rf_install(".__NAMESPACE__."), do_get);
SEXP info = Rf_findVarInFrame(rho, Rf_install(".__NAMESPACE__."));
if (info != R_UnboundValue && TYPEOF(info) == ENVSXP) {
PROTECT(info);
SEXP spec = Rf_findVarInFrame3(info, Rf_install("spec"), do_get);
SEXP spec = Rf_findVarInFrame(info, Rf_install("spec"));
UNPROTECT(1);
if (spec != R_UnboundValue &&
TYPEOF(spec) == STRSXP && LENGTH(spec) > 0)
Expand Down Expand Up @@ -337,7 +336,7 @@ bool is_env_from_package(SEXP &x, const bool& recursive) {
if( env == R_EmptyEnv ) { return false; }
if( env == R_BaseEnv ) { return true; }

if( is_namespace(x) ) { return true; }
if( is_namespace(env) ) { return true; }

// recursively check
if( recursive ) {
Expand All @@ -351,4 +350,12 @@ bool is_env_from_package(SEXP &x, const bool& recursive) {

/*** R
(function(...){ check_missing_dots(environment()) })()
b <- local({function(){2}})
get_sexpinfo_obj(b)
PackFlags(3, 0, 0, 0, 1)
b()
get_sexpinfo_obj(b)
# 263171
PackFlags(3, 64, 0, 0, 1)
a <- get_enclosing_env(b)
*/

0 comments on commit 5ec8ade

Please sign in to comment.