11# # RcppEigen.package.skeleton.R: makes a skeleton for a package that wants to use RcppEigen
22# #
3- # # Copyright (C) 2011 - 2015 Douglas Bates, Dirk Eddelbuettel and Romain Francois
3+ # # Copyright (C) 2011 - 2019 Douglas Bates, Dirk Eddelbuettel and Romain Francois
44# #
55# # This file is part of RcppEigen.
66# #
1919
2020RcppEigen.package.skeleton <- function (name = " anRpackage" , list = character (),
2121 environment = .GlobalEnv ,
22- path = " ." , force = FALSE ,
23- code_files = character (),
22+ path = " ." , force = FALSE ,
23+ code_files = character (),
2424 example_code = TRUE ) {
25-
25+
2626 env <- parent.frame(1 )
27-
27+
2828 if (! length(list )) {
2929 fake <- TRUE
3030 assign(" Rcpp.fake.fun" , function () {}, envir = env )
@@ -40,39 +40,39 @@ RcppEigen.package.skeleton <- function(name= "anRpackage", list = character(),
4040 # # first let the traditional version do its business
4141 call <- match.call()
4242 call [[1 ]] <- skelFunUsed
43+ if (" example_code" %in% names(call )) {
44+ call [[" example_code" ]] <- NULL # remove the example_code argument
45+ }
4346 if (! haveKitten ) { # in the package.skeleton() case
44- if (" example_code" %in% names(call )) {
45- call [[" example_code" ]] <- NULL # remove the example_code argument
46- }
4747 if (fake ) {
4848 call [[" list" ]] <- " Rcpp.fake.fun"
4949 }
5050 }
51-
51+
5252 tryCatch(eval(call , envir = env ),
5353 error = function (e ) {
5454 cat(paste(e , " \n " )) # print error
5555 stop(paste(" error while calling `" , skelFunName , " `" , sep = " " ))
5656 })
57-
57+
5858 message(" \n Adding RcppEigen settings" )
59-
60- # # now pick things up
59+
60+ # # now pick things up
6161 root <- file.path(path , name )
62-
62+
6363 # # Add Rcpp to the DESCRIPTION
6464 DESCRIPTION <- file.path(root , " DESCRIPTION" )
6565 if (file.exists(DESCRIPTION )) {
66- x <- cbind(read.dcf(DESCRIPTION ),
67- " Imports" = sprintf(" Rcpp (>= %s)" ,
68- packageDescription(" Rcpp" )[[" Version" ]]),
66+ x <- cbind(read.dcf(DESCRIPTION ),
67+ " Imports" = sprintf(" Rcpp (>= %s)" ,
68+ packageDescription(" Rcpp" )[[" Version" ]]),
6969 " LinkingTo" = " Rcpp, RcppEigen" )
7070 write.dcf(x , file = DESCRIPTION )
7171 message(" >> added Imports: Rcpp" )
7272 message(" >> added LinkingTo: Rcpp, RcppEigen" )
7373 }
74-
75- # # add a useDynLib to NAMESPACE,
74+
75+ # # add a useDynLib to NAMESPACE,
7676 NAMESPACE <- file.path(root , " NAMESPACE" )
7777 lines <- readLines(NAMESPACE )
7878 if (! grepl(" useDynLib" , lines )) {
@@ -83,7 +83,7 @@ RcppEigen.package.skeleton <- function(name= "anRpackage", list = character(),
8383 writeLines(lines , con = NAMESPACE )
8484 message(" >> added useDynLib and importFrom directives to NAMESPACE" )
8585 }
86-
86+
8787 # # lay things out in the src directory
8888 src <- file.path(root , " src" )
8989 if (! file.exists(src )) {
@@ -99,13 +99,13 @@ RcppEigen.package.skeleton <- function(name= "anRpackage", list = character(),
9999 file.copy(file.path(skeleton , " Makevars" ), Makevars )
100100 message(" >> added Makevars file with RcppEigen settings" )
101101 }
102-
102+
103103 Makevars.win <- file.path(src , " Makevars.win" )
104104 if (! file.exists(Makevars.win )) {
105105 file.copy(file.path(skeleton , " Makevars.win" ), Makevars.win )
106106 message(" >> added Makevars.win file with RcppEigen settings" )
107107 }
108-
108+
109109 if (example_code ) {
110110 file.copy(file.path(skeleton , " rcppeigen_hello_world.cpp" ), src )
111111 message(" >> added example src file using Eigen classes" )
@@ -115,13 +115,12 @@ RcppEigen.package.skeleton <- function(name= "anRpackage", list = character(),
115115 Rcpp :: compileAttributes(root )
116116 message(" >> invoked Rcpp::compileAttributes to create wrappers" )
117117 }
118-
118+
119119 if (fake ) {
120120 rm(" Rcpp.fake.fun" , envir = env )
121121 unlink(file.path(root , " R" , " Rcpp.fake.fun.R" ))
122122 unlink(file.path(root , " man" , " Rcpp.fake.fun.Rd" ))
123123 }
124-
124+
125125 invisible (NULL )
126126}
127-
0 commit comments