[Rcpp-commits] r1125 - in pkg/Rcpp/inst: . include/Rcpp unitTests

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Apr 28 10:06:53 CEST 2010


Author: romain
Date: 2010-04-28 10:06:53 +0200 (Wed, 28 Apr 2010)
New Revision: 1125

Modified:
   pkg/Rcpp/inst/ChangeLog
   pkg/Rcpp/inst/include/Rcpp/Vector.h
   pkg/Rcpp/inst/unitTests/runit.IntegerVector.R
Log:
allow Vector(0)

Modified: pkg/Rcpp/inst/ChangeLog
===================================================================
--- pkg/Rcpp/inst/ChangeLog	2010-04-28 07:25:15 UTC (rev 1124)
+++ pkg/Rcpp/inst/ChangeLog	2010-04-28 08:06:53 UTC (rev 1125)
@@ -1,3 +1,8 @@
+2010-04-28	Romain Francois <romain at r-enthusiasts.com>
+
+	* inst/include/Rcpp/Vector.h: changed Vector( size_t ) to Vector( int )
+	to allow Vector( 0 ) and Vector::create()
+
 2010-04-27	Romain Francois <romain at r-enthusiasts.com>
 
 	* inst/include/Rcpp/preprocessor.h: new macro RCPP_ENUM_TRAITS to 
@@ -3,4 +8,6 @@
 	generate traits needed to support wrap for an enum type (used in 
 	RProtoBuf)
+	
+	* R/Rcpp.package.skeleton.R: correctly handle the example_code argument
 
 2010-04-26	Romain Francois <romain at r-enthusiasts.com>

Modified: pkg/Rcpp/inst/include/Rcpp/Vector.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/Vector.h	2010-04-28 07:25:15 UTC (rev 1124)
+++ pkg/Rcpp/inst/include/Rcpp/Vector.h	2010-04-28 08:06:53 UTC (rev 1125)
@@ -508,13 +508,13 @@
     	RCPP_DEBUG( "===========", 0) ;
     }
     
-    Vector( const size_t& size ) : Base()  {
+    Vector( const int& size ) : Base()  {
     	Base::setSEXP( Rf_allocVector( RTYPE, size) ) ;
 		init() ;
     }
     
     template <typename U>
-    Vector( const size_t& size, const U& u){
+    Vector( const int& size, const U& u){
     	Base::setSEXP( Rf_allocVector( RTYPE, size) ) ;
 		fill( u ) ;	
     }
@@ -769,6 +769,10 @@
 		cache.update(*this) ;
 	}
 		
+	Vector create(){
+		return Vector( 0 ) ;
+	}
+	
 /* <code-bloat>
 
 public:

Modified: pkg/Rcpp/inst/unitTests/runit.IntegerVector.R
===================================================================
--- pkg/Rcpp/inst/unitTests/runit.IntegerVector.R	2010-04-28 07:25:15 UTC (rev 1124)
+++ pkg/Rcpp/inst/unitTests/runit.IntegerVector.R	2010-04-28 08:06:53 UTC (rev 1125)
@@ -246,3 +246,14 @@
 	checkEquals( x, rep(10L, 10 ), msg = "IntegerVector.fill" )
 }
 
+test.IntegerVector.zero <- function( ){
+	funx <- cppfunction(signature(x = "integer"), 'return IntegerVector(0);' )
+	checkEquals( funx(), integer(0), msg = "IntegerVector(0)" )
+}
+
+test.IntegerVector.create.zero <- function( ){
+	funx <- cppfunction(signature(x = "integer"), 'return IntegerVector::create();' )
+	checkEquals( funx(), integer(0), msg = "IntegerVector::create()" )
+}
+
+



More information about the Rcpp-commits mailing list