[Rcpp-commits] r372 - in pkg: . R inst man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Wed Jan 13 11:01:52 CET 2010
Author: romain
Date: 2010-01-13 11:01:52 +0100 (Wed, 13 Jan 2010)
New Revision: 372
Added:
pkg/R/cpp.package.skeleton.R
pkg/man/cpp.package.skeleton.Rd
Modified:
pkg/NAMESPACE
pkg/R/exceptions.R
pkg/inst/ChangeLog
Log:
minimal version of cpp.package.skeleton
Modified: pkg/NAMESPACE
===================================================================
--- pkg/NAMESPACE 2010-01-13 09:00:55 UTC (rev 371)
+++ pkg/NAMESPACE 2010-01-13 10:01:52 UTC (rev 372)
@@ -4,5 +4,6 @@
print.RcppExample,
RcppDateExample,
RcppParamsExample,
- RcppVectorExample
+ RcppVectorExample,
+ cpp.package.skeleton
)
Added: pkg/R/cpp.package.skeleton.R
===================================================================
--- pkg/R/cpp.package.skeleton.R (rev 0)
+++ pkg/R/cpp.package.skeleton.R 2010-01-13 10:01:52 UTC (rev 372)
@@ -0,0 +1,74 @@
+# Copyright (C) 2009 - 2010 Dirk Eddelbuettel and Romain Francois
+#
+# This file is part of Rcpp.
+#
+# Rcpp is free software: you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 2 of the License, or
+# (at your option) any later version.
+#
+# Rcpp is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Rcpp. If not, see <http://www.gnu.org/licenses/>.
+
+cpp.package.skeleton <- function(
+ name = "anRpackage", list = character(), environment = .GlobalEnv,
+ path = ".", force = FALSE, namespace = TRUE, code_files = character() ){
+
+ # 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)
+
+ tryCatch( eval( call, envir = env ), error = function(e){
+ stop( "error while calling `package.skeleton`" )
+ } )
+
+ message( "\nAdding Rcpp settings" )
+
+ # now pick things up
+ root <- file.path( path, name )
+
+ # Add Rcpp to the DESCRIPTION
+ DESCRIPTION <- file.path( root, "DESCRIPTION" )
+ if( file.exists( DESCRIPTION ) ){
+ x <- cbind( read.dcf( DESCRIPTION ),
+ "Depends" = sprintf( "Rcpp (>= %s)", packageDescription("Rcpp")[["Version"]] ) )
+ write.dcf( x, file = DESCRIPTION )
+ message( " >> added Rcpp to Depends" )
+ }
+
+ # if there is a NAMESPACE, add a useDynLib
+ NAMESPACE <- file.path( root, "NAMESPACE")
+ if( file.exists( NAMESPACE ) ){
+ lines <- readLines( NAMESPACE )
+ if( ! grepl( "useDynLib", lines ) ){
+ lines <- c( sprintf( "useDynLib(%s)", name), lines)
+ writeLines( lines, con = NAMESPACE )
+ message( " >> added useDynLib directive to NAMESPACE" )
+ }
+ }
+
+ # lay things out in the src directory
+ src <- file.path( root, "src")
+ if( !file.exists( src )){
+ dir.create( src )
+ }
+ Makevars <- file.path( src, "Makevars" )
+ if( !file.exists( Makevars ) ){
+ writeLines( c(
+ "PKG_CXXFLAGS=`Rscript -e \"Rcpp:::CxxFlags()\" `" ,
+ "PKG_LIBS = `Rscript -e \"Rcpp:::LdFlasgs()\" `" ),
+ , con = Makevars )
+ message( " >> added Makevars file with Rcpp settings" )
+ }
+
+ invisible( NULL )
+}
+
Modified: pkg/R/exceptions.R
===================================================================
--- pkg/R/exceptions.R 2010-01-13 09:00:55 UTC (rev 371)
+++ pkg/R/exceptions.R 2010-01-13 10:01:52 UTC (rev 372)
@@ -1,4 +1,4 @@
-# Copyright (C) 2009 Romain Francois
+# Copyright (C) 2009 - 2010 Dirk Eddelbuettel and Romain Francois
#
# This file is part of Rcpp.
#
Modified: pkg/inst/ChangeLog
===================================================================
--- pkg/inst/ChangeLog 2010-01-13 09:00:55 UTC (rev 371)
+++ pkg/inst/ChangeLog 2010-01-13 10:01:52 UTC (rev 372)
@@ -1,5 +1,11 @@
2010-01-13 Romain Francois <francoisromain at free.fr>
+ * R/cpp.package.skeleton.R: new function cpp.package.skeleton
+ to extend the code generation performed by package.skeleton
+ to Rcpp features
+
+ * man/cpp.package.skeleton.Rd: documentation for cpp.package.skeleton
+
* src/Rcpp/VectorBase.h: new virtual class Rcpp::VectorBase
to manage common things of all vectors (length, names, etc ...)
all Vector classes now derive from VectorBase
Added: pkg/man/cpp.package.skeleton.Rd
===================================================================
--- pkg/man/cpp.package.skeleton.Rd (rev 0)
+++ pkg/man/cpp.package.skeleton.Rd 2010-01-13 10:01:52 UTC (rev 372)
@@ -0,0 +1,53 @@
+\name{cpp.package.skeleton}
+\alias{cpp.package.skeleton}
+\title{
+Create a skeleton for a new package depending on Rcpp
+}
+\description{
+ \code{cpp.package.skeleton} automates the creation of
+ a new source package that intends to use features of Rcpp.
+
+ It is based on the \link[utils]{package.skeleton} function
+ which it executes first.
+}
+\usage{
+cpp.package.skeleton(name = "anRpackage", list = character(),
+ environment = .GlobalEnv, path = ".", force = FALSE,
+ namespace = TRUE, code_files = character())
+}
+\arguments{
+ \item{name}{See \link[utils]{package.skeleton}}
+ \item{list}{See \link[utils]{package.skeleton}}
+ \item{environment}{See \link[utils]{package.skeleton}}
+ \item{path}{See \link[utils]{package.skeleton}}
+ \item{force}{See \link[utils]{package.skeleton}}
+ \item{namespace}{See \link[utils]{package.skeleton}}
+ \item{code_files}{See \link[utils]{package.skeleton}}
+}
+\details{
+ In addition to \link[utils]{package.skeleton} :
+
+ The \samp{DESCRIPTION} file gains a Depends line requesting that
+ the package depends on Rcpp
+
+ The \samp{NAMESPACE}, if any, gains a \code{useDynLib} directove
+
+ The \samp{src} directory is created if it does not exists and
+ a \samp{Makevars} file is added setting the environment variables
+ \samp{PKG_CXXFLAGS} and \samp{PKG_LIBS}
+
+}
+\value{
+Nothing, used for its side effects
+}
+\seealso{
+\link[utils]{package.skeleton}
+}
+\examples{
+\dontrun{
+f <- function(){}
+cpp.package.skeleton( "foobar", "f" )
+}
+}
+\keyword{ programming }
+
More information about the Rcpp-commits
mailing list