[Rcpp-commits] r2512 - in pkg/Rcpp: . R man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Wed Nov 24 19:56:28 CET 2010
Author: romain
Date: 2010-11-24 19:56:28 +0100 (Wed, 24 Nov 2010)
New Revision: 2512
Added:
pkg/Rcpp/man/formals.Rd
Modified:
pkg/Rcpp/ChangeLog
pkg/Rcpp/NAMESPACE
pkg/Rcpp/R/00_classes.R
Log:
formals<-.C++Function
Modified: pkg/Rcpp/ChangeLog
===================================================================
--- pkg/Rcpp/ChangeLog 2010-11-24 02:20:23 UTC (rev 2511)
+++ pkg/Rcpp/ChangeLog 2010-11-24 18:56:28 UTC (rev 2512)
@@ -1,3 +1,8 @@
+2010-11-24 Romain Francois <romain at r-enthusiasts.com>
+
+ * R/00_classes.R: formals<- method for C++Function that allows to set default
+ arguments, etc .. to a C++ function
+
2010-11-23 Dirk Eddelbuettel <edd at debian.org>
* inst/doc/Makefile: Call Rscript with --vanilla to skip user settings
Modified: pkg/Rcpp/NAMESPACE
===================================================================
--- pkg/Rcpp/NAMESPACE 2010-11-24 02:20:23 UTC (rev 2511)
+++ pkg/Rcpp/NAMESPACE 2010-11-24 18:56:28 UTC (rev 2512)
@@ -35,7 +35,7 @@
S3method( .DollarNames, "C++Object" )
S3method( .DollarNames, "Module" )
-exportMethods( prompt, show, .DollarNames )
+exportMethods( prompt, show, .DollarNames, "formals<-" )
export(
Module, Rcpp.package.skeleton
Modified: pkg/Rcpp/R/00_classes.R
===================================================================
--- pkg/Rcpp/R/00_classes.R 2010-11-24 02:20:23 UTC (rev 2511)
+++ pkg/Rcpp/R/00_classes.R 2010-11-24 18:56:28 UTC (rev 2512)
@@ -94,3 +94,18 @@
contains = "function"
)
+.cppfunction_formals_gets <- function (fun, envir = environment(fun), value) {
+ bd <- body(fun)
+ b2 <- bd[[2L]]
+ for( i in seq_along(value) ){
+ b2[[3L+i]] <- as.name( names(value)[i] )
+ }
+ bd[[2]] <- b2
+ f <- fun at .Data
+ formals(f) <- value
+ body(f) <- bd
+ fun at .Data <- f
+ fun
+}
+setGeneric( "formals<-" )
+setMethod( "formals<-", "C++Function", .cppfunction_formals_gets )
Added: pkg/Rcpp/man/formals.Rd
===================================================================
--- pkg/Rcpp/man/formals.Rd (rev 0)
+++ pkg/Rcpp/man/formals.Rd 2010-11-24 18:56:28 UTC (rev 2512)
@@ -0,0 +1,16 @@
+\name{formals<--methods}
+\docType{methods}
+\alias{formals<--methods}
+\alias{formals<-,C++Function-method}
+\title{Set the formal arguments of a C++ function}
+\description{
+Set the formal arguments of a C++ function
+}
+\section{Methods}{
+\describe{
+
+\item{\code{signature(fun = "C++Function")}}{
+Set the formal arguments of a C++ function
+}
+}}
+\keyword{methods}
More information about the Rcpp-commits
mailing list