Skip to content

Commit

Permalink
Explicit Rcpp:: in the initalize method for C++ classes wrapped insid…
Browse files Browse the repository at this point in the history
…e modules. (#980)

* Otherwise the Rcpp functions are unknown when objects are initialized, unless Rcpp is attached.
* This is relevant for classes inside of modules created via Module(), both inline and in packages, but is not an issue when loadModule() is used for packages.
  • Loading branch information
riccardoporreca authored and eddelbuettel committed Jul 21, 2019
1 parent 84c787f commit 1bad53b
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions R/Module.R
Expand Up @@ -230,11 +230,11 @@ Module <- function( module, PACKAGE = methods::getPackageName(where), where = to
.self <- .refClassDef <- NULL
generator$methods(initialize =
if(cpp_hasDefaultConstructor(CLASS))
function(...) cpp_object_initializer(.self,.refClassDef, ...)
function(...) Rcpp::cpp_object_initializer(.self,.refClassDef, ...)
else
function(...) {
if(nargs()) cpp_object_initializer(.self,.refClassDef, ...)
else cpp_object_dummy(.self, .refClassDef)
if(nargs()) Rcpp::cpp_object_initializer(.self,.refClassDef, ...)
else Rcpp::cpp_object_dummy(.self, .refClassDef)
}
)
rm( .self, .refClassDef )
Expand Down

0 comments on commit 1bad53b

Please sign in to comment.