[Rcpp-commits] r4173 - in pkg/Rcpp: . R src

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Dec 26 18:44:21 CET 2012


Author: jjallaire
Date: 2012-12-26 18:44:21 +0100 (Wed, 26 Dec 2012)
New Revision: 4173

Modified:
   pkg/Rcpp/ChangeLog
   pkg/Rcpp/R/Attributes.R
   pkg/Rcpp/TODO
   pkg/Rcpp/src/attributes.cpp
Log:
return invisibly from void functions

Modified: pkg/Rcpp/ChangeLog
===================================================================
--- pkg/Rcpp/ChangeLog	2012-12-24 11:56:32 UTC (rev 4172)
+++ pkg/Rcpp/ChangeLog	2012-12-26 17:44:21 UTC (rev 4173)
@@ -1,3 +1,8 @@
+2012-12-26  JJ Allaire <jj at rstudio.org>
+
+        * R/Attributes.R: return invisibly from void functions
+        * src/attributes.cpp: return invisibly from void functions
+
 2012-12-20 Romain Francois <romain at r-enthusiasts.com>
 
         * NAMESPACE : remove C++ObjectS3 and C++ClassRepresentation classes

Modified: pkg/Rcpp/R/Attributes.R
===================================================================
--- pkg/Rcpp/R/Attributes.R	2012-12-24 11:56:32 UTC (rev 4172)
+++ pkg/Rcpp/R/Attributes.R	2012-12-26 17:44:21 UTC (rev 4173)
@@ -313,7 +313,7 @@
 
 
 # Take an empty function body and connect it to the specified external symbol
-sourceCppFunction <- function(func, dll, symbol) {
+sourceCppFunction <- function(func, isVoid, dll, symbol) {
     
     args <- names(formals(func))
     
@@ -325,6 +325,9 @@
     body[[1L]] <- .Call
     body[[2L]] <- getNativeSymbolInfo(symbol, dll)$address
     
+    if (isVoid)
+        body <- call("invisible", body)
+    
     body(func) <- body
     
     func

Modified: pkg/Rcpp/TODO
===================================================================
--- pkg/Rcpp/TODO	2012-12-24 11:56:32 UTC (rev 4172)
+++ pkg/Rcpp/TODO	2012-12-26 17:44:21 UTC (rev 4173)
@@ -107,8 +107,6 @@
 
     o   Allow sourceCpp to build an entire directory
 
-    o   Functions with void return should return invisibly
-
 Testing
 
     o	all r* functions : rnorm, etc ...

Modified: pkg/Rcpp/src/attributes.cpp
===================================================================
--- pkg/Rcpp/src/attributes.cpp	2012-12-24 11:56:32 UTC (rev 4172)
+++ pkg/Rcpp/src/attributes.cpp	2012-12-26 17:44:21 UTC (rev 4173)
@@ -2410,6 +2410,7 @@
                 ostr <<  attribute.exportedName()
                      << " <- Rcpp:::sourceCppFunction("
                      << "function(" << generateRArgList(function) << ") {}, " 
+                     << (function.type().isVoid() ? "TRUE" : "FALSE") << ", "
                      << dllInfo << ", " 
                      << "'" << contextId_ + "_" + function.name() 
                      << "')" << std::endl;



More information about the Rcpp-commits mailing list