[Rcpp-commits] r1026 - in pkg: Rcpp Rcpp/R Rcpp/inst/skeleton Rcpp/man RcppGSL/src

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Apr 7 11:37:37 CEST 2010


Author: romain
Date: 2010-04-07 11:37:37 +0200 (Wed, 07 Apr 2010)
New Revision: 1026

Modified:
   pkg/Rcpp/NEWS
   pkg/Rcpp/R/Rcpp.package.skeleton.R
   pkg/Rcpp/inst/skeleton/Makevars.win
   pkg/Rcpp/man/Rcpp.package.skeleton.Rd
   pkg/RcppGSL/src/Makevars.in
Log:
updating Rcpp.package.skeleton to use LinkingTo and added 'example_code' argument and ability to create a skeleton from an empty list of R objects

Modified: pkg/Rcpp/NEWS
===================================================================
--- pkg/Rcpp/NEWS	2010-04-07 08:39:33 UTC (rev 1025)
+++ pkg/Rcpp/NEWS	2010-04-07 09:37:37 UTC (rev 1026)
@@ -1,6 +1,17 @@
 0.7.12
 
 	o	new class Rcpp::Formula to help building formulae in C++
+	
+	o	Rcpp.package.skeleton gains an argument "example_code" and can now be 
+	used with an empty list, so that only the skeleton is generated
+	
+	o	wrap now supports containers of the following types: long, long double, 
+	unsigned long, short and unsigned short which are silently converted 
+	to the most acceptable R type.
+	
+	o	All Rcpp headers have been moved to the inst/include directory, allowing 
+	use of LinkingTo: Rcpp. But the Makevars and Makevars.win still need
+	to link against the user library. 
 
 0.7.11	2010-03-26
 

Modified: pkg/Rcpp/R/Rcpp.package.skeleton.R
===================================================================
--- pkg/Rcpp/R/Rcpp.package.skeleton.R	2010-04-07 08:39:33 UTC (rev 1025)
+++ pkg/Rcpp/R/Rcpp.package.skeleton.R	2010-04-07 09:37:37 UTC (rev 1026)
@@ -18,14 +18,27 @@
 Rcpp.package.skeleton <- function(
 	name = "anRpackage", list = character(), environment = .GlobalEnv,
 	path = ".", force = FALSE, namespace = TRUE, 
-	code_files = character() ){
+	code_files = character(), 
+	example_code = TRUE ){
 	
+	env <- parent.frame(1)
+	
+	if( !length(list) ){
+		fake <- TRUE
+		assign( "Rcpp.fake.fun", function(){}, envir = env )
+		list <- "Rcpp.fake.fun"
+	} else {
+		fake <- FALSE
+	}
+	
 	# first let the traditional version do its business
 	call <- match.call()
 	call[[1]] <- as.name("package.skeleton")
 	call[["namespace"]] <- namespace
-	print( call )	
-	env <- parent.frame(1)
+	if( "example_code" %in% names( call ) ){
+		# remove the example_code argument
+		call[["example_code"]] <- NULL
+	}
 	
 	tryCatch( eval( call, envir = env ), error = function(e){
 		stop( "error while calling `package.skeleton`" )
@@ -76,19 +89,27 @@
 		message( " >> added Makevars.win file with Rcpp settings" )
 	}
 	
-	header <- readLines( file.path( skeleton, "rcpp_hello_world.h" ) )
-	header <- gsub( "@PKG@", name, header, fixed = TRUE )
-	writeLines( header , file.path( src, "rcpp_hello_world.h" ) )
-	message( " >> added example header file using Rcpp classes")
+	if( example_code ){
+		header <- readLines( file.path( skeleton, "rcpp_hello_world.h" ) )
+		header <- gsub( "@PKG@", name, header, fixed = TRUE )
+		writeLines( header , file.path( src, "rcpp_hello_world.h" ) )
+		message( " >> added example header file using Rcpp classes")
+		
+		file.copy( file.path( skeleton, "rcpp_hello_world.cpp" ), src )
+		message( " >> added example src file using Rcpp classes")
+		
+		rcode <- readLines( file.path( skeleton, "rcpp_hello_world.R" ) )
+		rcode <- gsub( "@PKG@", name, rcode, fixed = TRUE )
+		writeLines( rcode , file.path( root, "R", "rcpp_hello_world.R" ) )
+		message( " >> added example R file calling the C++ example")
+	}
+	if( fake ){
+		rm( "Rcpp.fake.fun", envir = env )
+		unlink( file.path( root, "R"  , "Rcpp.fake.fun.R" ) )
+		unlink( file.path( root, "man", "Rcpp.fake.fun.Rd" ) )
+		
+	}
 	
-	file.copy( file.path( skeleton, "rcpp_hello_world.cpp" ), src )
-	message( " >> added example src file using Rcpp classes")
-	
-	rcode <- readLines( file.path( skeleton, "rcpp_hello_world.R" ) )
-	rcode <- gsub( "@PKG@", name, rcode, fixed = TRUE )
-	writeLines( rcode , file.path( root, "R", "rcpp_hello_world.R" ) )
-	message( " >> added example R file calling the C++ example")
-	
 	invisible( NULL )
 }
 

Modified: pkg/Rcpp/inst/skeleton/Makevars.win
===================================================================
--- pkg/Rcpp/inst/skeleton/Makevars.win	2010-04-07 08:39:33 UTC (rev 1025)
+++ pkg/Rcpp/inst/skeleton/Makevars.win	2010-04-07 09:37:37 UTC (rev 1026)
@@ -1,5 +1,5 @@
 
 ## This assume that we can call Rscript to ask Rcpp about its locations
 ## Use the R_HOME indirection to support installations of multiple R version
-PKG_LIBS = `$(R_HOME)/bin/Rscript --vanilla -e 'Rcpp:::LdFlags()'`
+PKG_LIBS = $(shell Rscript.exe --vanilla -e "Rcpp:::LdFlags()")
 

Modified: pkg/Rcpp/man/Rcpp.package.skeleton.Rd
===================================================================
--- pkg/Rcpp/man/Rcpp.package.skeleton.Rd	2010-04-07 08:39:33 UTC (rev 1025)
+++ pkg/Rcpp/man/Rcpp.package.skeleton.Rd	2010-04-07 09:37:37 UTC (rev 1026)
@@ -13,7 +13,8 @@
 \usage{
 Rcpp.package.skeleton(name = "anRpackage", list = character(), 
 	environment = .GlobalEnv, path = ".", force = FALSE, 
-	namespace = TRUE, code_files = character())
+	namespace = TRUE, code_files = character(), 
+	example_code = TRUE )
 }
 \arguments{
 	\item{name}{See \link[utils]{package.skeleton}}
@@ -23,6 +24,7 @@
 	\item{force}{See \link[utils]{package.skeleton}}
 	\item{namespace}{See \link[utils]{package.skeleton}}
 	\item{code_files}{See \link[utils]{package.skeleton}}
+	\item{example_code}{If TRUE, example c++ code using Rcpp is added to the package}
 }
 \details{
 	In addition to \link[utils]{package.skeleton} : 
@@ -38,7 +40,8 @@
 	\samp{PKG_CXXFLAGS} and \samp{PKG_LIBS} to accomodate the necessary flags
 	to link with the Rcpp library. 
 	
-	Example files \samp{rcpp_hello_world.h} and \samp{rcpp_hello_world.cpp}
+	If the \code{example_code} argument is set to \code{TRUE}, 
+	xample files \samp{rcpp_hello_world.h} and \samp{rcpp_hello_world.cpp}
 	are also created in the \samp{src}. An R file \samp{rcpp_hello_world.R} is 
 	expanded in the \samp{R} directory, the \code{rcpp_hello_world} function
 	defined in this files makes use of the C++ function \samp{rcpp_hello_world}

Modified: pkg/RcppGSL/src/Makevars.in
===================================================================
--- pkg/RcppGSL/src/Makevars.in	2010-04-07 08:39:33 UTC (rev 1025)
+++ pkg/RcppGSL/src/Makevars.in	2010-04-07 09:37:37 UTC (rev 1026)
@@ -8,4 +8,3 @@
 PKG_CPPFLAGS = -W $(GSL_CFLAGS) -I../inst/include
 PKG_LIBS = $(GSL_LIBS) $(RCPP_LDFLAGS)
 
-



More information about the Rcpp-commits mailing list