Skip to content

Commit 5978d82

Browse files
authored
Make nClass interfaces (R6 classes) use the same scoping for compiled as uncompiled
This PR sets the parent_env of the R6 class generated to interface to a compiled nClass object to achieve the same scoping as the uncompiled nClass. See #96
1 parent c5292a1 commit 5978d82

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

nCompiler/R/NC_FullCompiledInterface.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
#' @export
5656
build_compiled_nClass <- function(NCgenerator,
5757
newCobjFun,
58-
env = parent.frame(),
58+
env = NCgenerator$parent_env,
5959
quoted = FALSE) {
6060
# One might wonder if we can have an R6 class created here to
6161
# interface with a compiled C++ class be established with

nCompiler/R/nCompile.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -670,8 +670,8 @@ nCompile_finish_nonpackage <- function(units,
670670
} else {
671671
if(expect_createFromR[i]) createFromR_fun <- compiledFuns[[iRes]]
672672
R6interfaces[[i]] <- try(build_compiled_nClass(units[[i]],
673-
createFromR_fun,
674-
env = resultEnv))
673+
createFromR_fun))
674+
# env = resultEnv))
675675
if(inherits(R6interfaces[[i]], "try-error")) {
676676
warning(paste0("There was a problem building a full nClass interface for ", exportNames[i], "."))
677677
R6interfaces[[i]] <- NULL

0 commit comments

Comments
 (0)