[Rcpp-commits] r3916 - in pkg/Rcpp: . R src
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Thu Nov 8 08:54:29 CET 2012
Author: romain
Date: 2012-11-08 08:54:28 +0100 (Thu, 08 Nov 2012)
New Revision: 3916
Modified:
pkg/Rcpp/ChangeLog
pkg/Rcpp/R/Module.R
pkg/Rcpp/src/Module.cpp
Log:
dealing with the ellipsis
Modified: pkg/Rcpp/ChangeLog
===================================================================
--- pkg/Rcpp/ChangeLog 2012-11-07 22:18:34 UTC (rev 3915)
+++ pkg/Rcpp/ChangeLog 2012-11-08 07:54:28 UTC (rev 3916)
@@ -1,3 +1,9 @@
+2012-11-08 Romain Francois <romain at r-enthusiasts.com>
+
+ * R/Module.R: Module functions taking no arguments don't get the ellipsis
+ anymore in their formals
+ * src/Module.cpp: passing up the number of arguments of the function
+
2012-11-07 JJ Allaire <jj at rstudio.org>
* R/Attributes.R: derive depends from package LinkingTo; change
Modified: pkg/Rcpp/R/Module.R
===================================================================
--- pkg/Rcpp/R/Module.R 2012-11-07 22:18:34 UTC (rev 3915)
+++ pkg/Rcpp/R/Module.R 2012-11-08 07:54:28 UTC (rev 3916)
@@ -71,20 +71,36 @@
pointer <- .getModulePointer(x)
info <- .Call( Module__get_function, pointer, name )
fun_ptr <- info[[1L]]
+ is_void <- info[[2L]]
doc <- info[[3L]]
sign <- info[[4L]]
formal_args <- info[[5L]]
+ nargs <- info[[6L]]
f <- function(...) NULL
+ if( nargs == 0L ) formals(f) <- NULL
stuff <- list( fun_pointer = fun_ptr, InternalFunction_invoke = InternalFunction_invoke )
- body(f) <- if( info[[2]] ) {
- substitute( {
- .External( InternalFunction_invoke, fun_pointer, ... )
- invisible(NULL)
- }, stuff )
+ body(f) <- if( nargs == 0L ){
+ if( is_void ) {
+ substitute( {
+ .External( InternalFunction_invoke, fun_pointer)
+ invisible(NULL)
+ }, stuff )
+ } else {
+ substitute( {
+ .External( InternalFunction_invoke, fun_pointer)
+ }, stuff )
+ }
} else {
- substitute( {
- .External( InternalFunction_invoke, fun_pointer, ... )
- }, stuff )
+ if( is_void ) {
+ substitute( {
+ .External( InternalFunction_invoke, fun_pointer, ... )
+ invisible(NULL)
+ }, stuff )
+ } else {
+ substitute( {
+ .External( InternalFunction_invoke, fun_pointer, ... )
+ }, stuff )
+ }
}
out <- new( "C++Function", f, pointer = fun_ptr, docstring = doc, signature = sign )
if( ! is.null( formal_args ) ){
Modified: pkg/Rcpp/src/Module.cpp
===================================================================
--- pkg/Rcpp/src/Module.cpp 2012-11-07 22:18:34 UTC (rev 3915)
+++ pkg/Rcpp/src/Module.cpp 2012-11-08 07:54:28 UTC (rev 3916)
@@ -309,7 +309,8 @@
fun->is_void(),
fun->docstring,
sign,
- fun->get_formals()
+ fun->get_formals(),
+ fun->nargs()
) ;
}
More information about the Rcpp-commits
mailing list