11# -*- tab-width: 4; -*-
22
3- # Copyright (C) 2009 - 2012 Dirk Eddelbuettel and Romain Francois
3+ # Copyright (C) 2009 - 2013 Dirk Eddelbuettel and Romain Francois
44#
55# This file is part of Rcpp.
66#
1717# You should have received a copy of the GNU General Public License
1818# along with Rcpp. If not, see <http://www.gnu.org/licenses/>.
1919
20- Rcpp.package.skeleton <- function (
21- name = " anRpackage" , list = character (), environment = .GlobalEnv ,
22- path = " ." , force = FALSE , namespace = TRUE ,
23- code_files = character (), cpp_files = character (),
24- example_code = TRUE ,
25- attributes = TRUE ,
26- module = FALSE ,
27- author = " Who wrote it" ,
28- maintainer = if (missing( author )) " Who to complain to" else author ,
29- email = " yourfault@somewhere.net" ,
30- license = " What Licence is it under ?"
31- ){
32-
33- if (! is.character(cpp_files ))
20+ Rcpp.package.skeleton <- function (name = " anRpackage" , list = character (),
21+ environment = .GlobalEnv ,
22+ path = " ." , force = FALSE ,
23+ code_files = character (), cpp_files = character (),
24+ example_code = TRUE , attributes = TRUE , module = FALSE ,
25+ author = " Who wrote it" ,
26+ maintainer = if (missing( author )) " Who to complain to" else author ,
27+ email = " yourfault@somewhere.net" ,
28+ license = " What Licence is it under ?" ) {
29+
30+ if (! is.character(cpp_files ))
3431 stop(" 'cpp_files' must be a character vector" )
3532 # set example_code if attributes is set
3633 if ( isTRUE(attributes ) )
@@ -40,7 +37,7 @@ Rcpp.package.skeleton <- function(
4037 if ( ! length(list ) ){
4138 fake <- TRUE
4239 assign( " Rcpp.fake.fun" , function (){}, envir = env )
43- if ( example_code && ! isTRUE(attributes )){
40+ if ( example_code && ! isTRUE(attributes )){
4441 assign( " rcpp_hello_world" , function (){}, envir = env )
4542 remove_hello_world <- TRUE
4643 } else {
@@ -59,7 +56,6 @@ Rcpp.package.skeleton <- function(
5956 # first let the traditional version do its business
6057 call <- match.call()
6158 call [[1 ]] <- as.name(" package.skeleton" )
62- call [[" namespace" ]] <- namespace
6359 # remove Rcpp specific arguments
6460
6561 call <- call [ c( 1L , which( names(call ) %in% names(formals(package.skeleton )))) ]
@@ -117,15 +113,15 @@ Rcpp.package.skeleton <- function(
117113 }
118114 close( ns )
119115 }
120-
116+
121117 # update the package description help page
122118 package_help_page <- file.path( root , " man" , sprintf( " %s-package.Rd" , name ) )
123119 if ( file.exists(package_help_page ) ){
124120 lines <- readLines(package_help_page )
125121 lines <- gsub( " What license is it under?" , license , lines , fixed = TRUE )
126- lines <- gsub( " Who to complain to <yourfault@somewhere.net>" ,
127- sprintf( " %s <%s>" , maintainer , email ),
128- lines ,
122+ lines <- gsub( " Who to complain to <yourfault@somewhere.net>" ,
123+ sprintf( " %s <%s>" , maintainer , email ),
124+ lines ,
129125 fixed = TRUE
130126 )
131127 lines <- gsub( " Who wrote it" , author , lines , fixed = TRUE )
@@ -149,18 +145,18 @@ Rcpp.package.skeleton <- function(
149145 file.copy( file.path( skeleton , " Makevars.win" ), Makevars.win )
150146 message( " >> added Makevars.win file with Rcpp settings" )
151147 }
152-
148+
153149 if ( length(cpp_files ) > 0L ) {
154150 for (file in cpp_files ) {
155151 file.copy(file , src )
156152 message( " >> copied " , file , " to src directory" )
157153 }
158154 compileAttributes(root )
159155 }
160-
156+
161157 if ( example_code ){
162158 if ( isTRUE( attributes ) ) {
163- file.copy( file.path( skeleton , " rcpp_hello_world_attributes.cpp" ),
159+ file.copy( file.path( skeleton , " rcpp_hello_world_attributes.cpp" ),
164160 file.path( src , " rcpp_hello_world.cpp" ) )
165161 message( " >> added example src file using Rcpp attributes" )
166162 compileAttributes(root )
@@ -170,16 +166,16 @@ Rcpp.package.skeleton <- function(
170166 header <- gsub( " @PKG@" , name , header , fixed = TRUE )
171167 writeLines( header , file.path( src , " rcpp_hello_world.h" ) )
172168 message( " >> added example header file using Rcpp classes" )
173-
169+
174170 file.copy( file.path( skeleton , " rcpp_hello_world.cpp" ), src )
175171 message( " >> added example src file using Rcpp classes" )
176-
172+
177173 rcode <- readLines( file.path( skeleton , " rcpp_hello_world.R" ) )
178174 rcode <- gsub( " @PKG@" , name , rcode , fixed = TRUE )
179175 writeLines( rcode , file.path( root , " R" , " rcpp_hello_world.R" ) )
180176 message( " >> added example R file calling the C++ example" )
181177 }
182-
178+
183179 hello.Rd <- file.path( root , " man" , " rcpp_hello_world.Rd" )
184180 unlink( hello.Rd )
185181 file.copy(
0 commit comments