[Rcpp-commits] r452 - in pkg: inst/unitTests src/Rcpp
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Mon Jan 25 13:32:01 CET 2010
Author: romain
Date: 2010-01-25 13:32:01 +0100 (Mon, 25 Jan 2010)
New Revision: 452
Modified:
pkg/inst/unitTests/runit.GenericVector.R
pkg/src/Rcpp/CharacterVector.h
pkg/src/Rcpp/ExpressionVector.h
pkg/src/Rcpp/GenericVector.h
pkg/src/Rcpp/wrap.h
Log:
re-enable GenericVector::GenericVector( initializer_list<SEXP> and wrap( initializer_list<SEXP> ), some cleaning
Modified: pkg/inst/unitTests/runit.GenericVector.R
===================================================================
--- pkg/inst/unitTests/runit.GenericVector.R 2010-01-25 12:21:33 UTC (rev 451)
+++ pkg/inst/unitTests/runit.GenericVector.R 2010-01-25 12:32:01 UTC (rev 452)
@@ -52,18 +52,17 @@
checkEquals( funx(list(1,2)), list(1,2), msg = "GenericVector( VECSXP) " )
}
-# test.List.initializer.list <- function(){
-# if( Rcpp:::capabilities()[["initializer lists"]] ){
-# funx <- cfunction(signature(), '
-# SEXP x0 = PROTECT( Rf_ScalarInteger( 0 ) ) ;
-# SEXP x1 = PROTECT( Rf_ScalarInteger( 1 ) ) ;
-# SEXP x2 = PROTECT( Rf_ScalarInteger( 2 ) ) ;
-# List x = { x0, x1, x2} ;
-# UNPROTECT(3) ;
-# return x ;',
-# Rcpp=TRUE, verbose=FALSE, includes = "using namespace Rcpp;", cxxargs="-std=c++0x" )
-# checkEquals( funx(), as.list(0:2), msg = "List( initializer list) " )
-# }
-# }
+test.List.initializer.list <- function(){
+ if( Rcpp:::capabilities()[["initializer lists"]] ){
+ funx <- cfunction(signature(), '
+ SEXP x0 = PROTECT( Rf_ScalarInteger( 0 ) ) ;
+ SEXP x1 = PROTECT( Rf_ScalarInteger( 1 ) ) ;
+ SEXP x2 = PROTECT( Rf_ScalarInteger( 2 ) ) ;
+ List x = { x0, x1, x2} ;
+ UNPROTECT(3) ;
+ return x ;',
+ Rcpp=TRUE, verbose=FALSE, includes = "using namespace Rcpp;", cxxargs="-std=c++0x" )
+ checkEquals( funx(), as.list(0:2), msg = "List( initializer list) " )
+ }
+}
-
Modified: pkg/src/Rcpp/CharacterVector.h
===================================================================
--- pkg/src/Rcpp/CharacterVector.h 2010-01-25 12:21:33 UTC (rev 451)
+++ pkg/src/Rcpp/CharacterVector.h 2010-01-25 12:32:01 UTC (rev 452)
@@ -26,11 +26,6 @@
#include <Rcpp/RObject.h>
#include <Rcpp/VectorBase.h>
-#ifdef HAS_INIT_LISTS
-#include <initializer_list>
-#include <algorithm>
-#endif
-
namespace Rcpp{
class CharacterVector : public VectorBase {
Modified: pkg/src/Rcpp/ExpressionVector.h
===================================================================
--- pkg/src/Rcpp/ExpressionVector.h 2010-01-25 12:21:33 UTC (rev 451)
+++ pkg/src/Rcpp/ExpressionVector.h 2010-01-25 12:32:01 UTC (rev 452)
@@ -28,11 +28,6 @@
#include <Rcpp/Evaluator.h>
#include <Rcpp/Environment.h>
-#ifdef HAS_INIT_LISTS
-#include <initializer_list>
-#include <algorithm>
-#endif
-
namespace Rcpp{
class ExpressionVector : public VectorBase {
Modified: pkg/src/Rcpp/GenericVector.h
===================================================================
--- pkg/src/Rcpp/GenericVector.h 2010-01-25 12:21:33 UTC (rev 451)
+++ pkg/src/Rcpp/GenericVector.h 2010-01-25 12:32:01 UTC (rev 452)
@@ -30,10 +30,6 @@
#include <Rcpp/Evaluator.h>
#include <Rcpp/Symbol.h>
-#ifdef HAS_INIT_LISTS
-#include <initializer_list>
-#endif
-
namespace Rcpp{
class GenericVector : public VectorBase {
@@ -67,6 +63,12 @@
GenericVector(SEXP x) throw(not_compatible);
GenericVector( int size) ;
+#ifdef HAS_INIT_LISTS
+ GenericVector( std::initializer_list<SEXP> list) : VectorBase(){
+ fill( list.begin(), list.end() ) ;
+ } ;
+#endif
+
const Proxy operator[]( int i ) const throw(index_out_of_bounds);
Proxy operator[]( int i ) throw(index_out_of_bounds) ;
@@ -87,6 +89,10 @@
typedef GenericVector List ;
+#ifdef HAS_INIT_LISTS
+inline GenericVector wrap(std::initializer_list<SEXP> list ){ return GenericVector(list) ; }
+#endif
+
} // namespace
#endif
Modified: pkg/src/Rcpp/wrap.h
===================================================================
--- pkg/src/Rcpp/wrap.h 2010-01-25 12:21:33 UTC (rev 451)
+++ pkg/src/Rcpp/wrap.h 2010-01-25 12:32:01 UTC (rev 452)
@@ -24,10 +24,6 @@
#include <RcppCommon.h>
-#ifdef HAS_INIT_LISTS
-#include <initializer_list>
-#endif
-
#include <Rcpp/RObject.h>
#include <set>
#include <Rcpp/IntegerVector.h>
@@ -35,6 +31,7 @@
#include <Rcpp/NumericVector.h>
#include <Rcpp/LogicalVector.h>
#include <Rcpp/CharacterVector.h>
+// #include <Rcpp/GenericVector.h>
namespace Rcpp{
More information about the Rcpp-commits
mailing list