[Rcpp-commits] r430 - in pkg: inst/unitTests src src/Rcpp

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Fri Jan 22 18:13:50 CET 2010


Author: romain
Date: 2010-01-22 18:13:49 +0100 (Fri, 22 Jan 2010)
New Revision: 430

Modified:
   pkg/inst/unitTests/runit.GenericVector.R
   pkg/src/Environment.cpp
   pkg/src/Rcpp/GenericVector.h
   pkg/src/Rcpp/as.h
   pkg/src/Rcpp/wrap.h
   pkg/src/RcppCommon.h
   pkg/src/as.cpp
   pkg/src/exceptions.cpp
Log:
fix chicken and egg problem

Modified: pkg/inst/unitTests/runit.GenericVector.R
===================================================================
--- pkg/inst/unitTests/runit.GenericVector.R	2010-01-22 16:31:10 UTC (rev 429)
+++ pkg/inst/unitTests/runit.GenericVector.R	2010-01-22 17:13:49 UTC (rev 430)
@@ -52,18 +52,18 @@
 	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/Environment.cpp
===================================================================
--- pkg/src/Environment.cpp	2010-01-22 16:31:10 UTC (rev 429)
+++ pkg/src/Environment.cpp	2010-01-22 17:13:49 UTC (rev 430)
@@ -286,7 +286,7 @@
     	return Binding( *this, name ) ;
     }
     
-    Environment Environment::RCPP_NAMESPACE = Environment::namespace_env("Rcpp") ;
+    Environment Environment::RCPP_NAMESPACE = Rf_eval( Rf_lcons( Rf_install("getNamespace"), Rf_cons( Rf_mkString("Rcpp") , R_NilValue) ), R_GlobalEnv );
     Environment& Environment::Rcpp_namespace() throw() {
     	    return RCPP_NAMESPACE ;
     }

Modified: pkg/src/Rcpp/GenericVector.h
===================================================================
--- pkg/src/Rcpp/GenericVector.h	2010-01-22 16:31:10 UTC (rev 429)
+++ pkg/src/Rcpp/GenericVector.h	2010-01-22 17:13:49 UTC (rev 430)
@@ -66,13 +66,7 @@
 
 	GenericVector(SEXP x) throw(not_compatible);
 	GenericVector( int size) ;
-	
-#ifdef HAS_INIT_LISTS	
-	GenericVector( std::initializer_list<RObject> 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) ;
 	

Modified: pkg/src/Rcpp/as.h
===================================================================
--- pkg/src/Rcpp/as.h	2010-01-22 16:31:10 UTC (rev 429)
+++ pkg/src/Rcpp/as.h	2010-01-22 17:13:49 UTC (rev 430)
@@ -64,9 +64,9 @@
 
 inline Rbyte Rboolean_to_Rbyte(int x){ return x == TRUE ? static_cast<Rbyte>(1) : static_cast<Rbyte>(0) ;}
 inline Rbyte double_to_Rbyte(double x){ 
-	if( x == NA_REAL) return static_cast<Rbyte>(0) ; 
+	if( x == NA_REAL) return (Rbyte)0 ; 
 	int y = static_cast<int>(x) ;
-	return (y < 0 || y > 255) ? static_cast<Rbyte>(0) : static_cast<Rbyte>(y) ;
+	return (y < 0 || y > 255) ? (Rbyte)0 : (Rbyte)y ;
 } 
 inline Rbyte int_to_Rbyte(int x){
 	return (x < 0 || x > 255) ? static_cast<Rbyte>(0) : static_cast<Rbyte>(x) ;

Modified: pkg/src/Rcpp/wrap.h
===================================================================
--- pkg/src/Rcpp/wrap.h	2010-01-22 16:31:10 UTC (rev 429)
+++ pkg/src/Rcpp/wrap.h	2010-01-22 17:13:49 UTC (rev 430)
@@ -69,7 +69,6 @@
 inline LogicalVector wrap( std::initializer_list<bool> list) { return LogicalVector(list); }
 inline RawVector wrap(std::initializer_list<Rbyte> list) { return RawVector(list) ; }
 inline CharacterVector wrap(std::initializer_list<std::string> list ){ return CharacterVector(list) ; }
-inline List wrap( std::initializer_list<RObject> list) { return List(list); }
 #endif
 
 } // namespace Rcpp

Modified: pkg/src/RcppCommon.h
===================================================================
--- pkg/src/RcppCommon.h	2010-01-22 16:31:10 UTC (rev 429)
+++ pkg/src/RcppCommon.h	2010-01-22 17:13:49 UTC (rev 430)
@@ -94,26 +94,26 @@
 
 RcppExport SEXP initRcpp() ;
 
-namespace Rcpp{
-	
-	class RObject ;
-	class Environment;
-	class Evaluator ;
-	class Symbol ;
-	class Language ;
-	class Named ;
-	class Pairlist ;
-	class Function ;
-	class IntegerVector; 
-	class NumericVector; 
-	class RawVector; 
-	class LogicalVector; 
-	class GenericVector; 
-	class WeakReference; 
-	class CharacterVector; 
-	class ExpressionVector; 
-	class ComplexVector; 
-}
+// namespace Rcpp{
+// 	
+// 	class RObject ;
+// 	class Environment;
+// 	class Evaluator ;
+// 	class Symbol ;
+// 	class Language ;
+// 	class Named ;
+// 	class Pairlist ;
+// 	class Function ;
+// 	class IntegerVector; 
+// 	class NumericVector; 
+// 	class RawVector; 
+// 	class LogicalVector; 
+// 	class GenericVector; 
+// 	class WeakReference; 
+// 	class CharacterVector; 
+// 	class ExpressionVector; 
+// 	class ComplexVector; 
+// } 
 
 
 #endif

Modified: pkg/src/as.cpp
===================================================================
--- pkg/src/as.cpp	2010-01-22 16:31:10 UTC (rev 429)
+++ pkg/src/as.cpp	2010-01-22 17:13:49 UTC (rev 430)
@@ -114,16 +114,20 @@
     std::vector<bool> v(n);
     switch( TYPEOF(m_sexp) ){
     case LGLSXP:
-    	transform( LOGICAL(m_sexp), LOGICAL(m_sexp)+n, v.begin(), Rboolean_to_bool ) ;
+    	// transform( LOGICAL(m_sexp), LOGICAL(m_sexp)+n, v.begin(), Rboolean_to_bool ) ;
+    	v.assign( LOGICAL(m_sexp), LOGICAL(m_sexp)+n ) ;
     	break ;
     case INTSXP:
-    	transform( INTEGER(m_sexp), INTEGER(m_sexp)+n, v.begin(), int_to_bool ) ;
+    	// transform( INTEGER(m_sexp), INTEGER(m_sexp)+n, v.begin(), int_to_bool ) ;
+    	v.assign( INTEGER(m_sexp), INTEGER(m_sexp)+n ) ;
     	break;
     case REALSXP:
-    	transform( REAL(m_sexp), REAL(m_sexp)+n, v.begin(), double_to_bool ) ;
+    	// transform( REAL(m_sexp), REAL(m_sexp)+n, v.begin(), double_to_bool ) ;
+    	v.assign( REAL(m_sexp), REAL(m_sexp)+n ) ;
     	break;
     case RAWSXP:
-    	transform( RAW(m_sexp), RAW(m_sexp)+n, v.begin(), Rbyte_to_bool ) ;
+    	// transform( RAW(m_sexp), RAW(m_sexp)+n, v.begin(), Rbyte_to_bool ) ;
+    	v.assign( RAW(m_sexp), RAW(m_sexp)+n ) ;
     	break;
     default:
     		throw std::range_error( "as< vector<bool> >: invalid R type" ) ; 
@@ -140,13 +144,16 @@
     	v.assign( INTEGER(m_sexp), INTEGER(m_sexp)+n ) ;
     	break;
     case LGLSXP:
-    	transform( LOGICAL(m_sexp), LOGICAL(m_sexp)+n, v.begin(), Rboolean_to_int ) ;
+    	// transform( LOGICAL(m_sexp), LOGICAL(m_sexp)+n, v.begin(), Rboolean_to_int ) ;
+    	v.assign( LOGICAL(m_sexp), LOGICAL(m_sexp)+n) ;
     	break;
     case REALSXP:
-    	transform( LOGICAL(m_sexp), LOGICAL(m_sexp)+n, v.begin(), double_to_int ) ;
+    	// transform( REAL(m_sexp), REAL(m_sexp)+n, v.begin(), double_to_int ) ;
+    	v.assign( REAL(m_sexp), REAL(m_sexp) + n) ;
     	break;
     case RAWSXP:
-    	transform( RAW(m_sexp), RAW(m_sexp)+n, v.begin(), Rbyte_to_int ) ;
+    	// transform( RAW(m_sexp), RAW(m_sexp)+n, v.begin(), Rbyte_to_int ) ;
+    	v.assign( RAW(m_sexp), RAW(m_sexp)+n) ;
     	break;
     default:
     		throw std::range_error( "as< vector<int> >: invalid R type" ) ; 
@@ -159,16 +166,19 @@
     std::vector<Rbyte> v(n);
     switch( TYPEOF(m_sexp) ){
     case LGLSXP:
-    	transform( LOGICAL(m_sexp), LOGICAL(m_sexp)+n, v.begin(), Rboolean_to_Rbyte ) ;
+    	// transform( LOGICAL(m_sexp), LOGICAL(m_sexp)+n, v.begin(), Rboolean_to_Rbyte ) ;
+    	v.assign( LOGICAL(m_sexp), LOGICAL(m_sexp)+n) ;
     	break ;
     case RAWSXP:
     	v.assign( RAW(m_sexp), RAW(m_sexp)+n ) ;
     	break ;
     case REALSXP:
-    	transform( REAL(m_sexp), REAL(m_sexp)+n, v.begin(), double_to_Rbyte ) ;
+    	// transform( REAL(m_sexp), REAL(m_sexp)+n, v.begin(), double_to_Rbyte ) ;
+    	v.assign( REAL(m_sexp), REAL(m_sexp) + n ) ;
     	break;
     case INTSXP:
-    	transform( INTEGER(m_sexp), INTEGER(m_sexp)+n, v.begin(), int_to_Rbyte ) ;
+    	// transform( INTEGER(m_sexp), INTEGER(m_sexp)+n, v.begin(), int_to_Rbyte ) ;
+    	v.assign( INTEGER(m_sexp), INTEGER(m_sexp)+n) ;
     	break;
     default:
     	throw std::range_error("as< vector<Rbyte> > expects raw, double or int");
@@ -181,16 +191,19 @@
     std::vector<double> v(n);
     switch( TYPEOF(m_sexp) ){
     case LGLSXP:
-    	transform( LOGICAL(m_sexp), LOGICAL(m_sexp)+n, v.begin(), Rboolean_to_double ) ;
+    	// transform( LOGICAL(m_sexp), LOGICAL(m_sexp)+n, v.begin(), Rboolean_to_double ) ;
+    	v.assign( LOGICAL(m_sexp), LOGICAL(m_sexp)+n ); 
     	break ;
     case RAWSXP:
-    	transform( RAW(m_sexp), RAW(m_sexp)+n, v.begin(), Rbyte_to_double ) ;
+    	// transform( RAW(m_sexp), RAW(m_sexp)+n, v.begin(), Rbyte_to_double ) ;
+    	v.assign( RAW(m_sexp), RAW(m_sexp)+n ) ;
     	break ;
     case REALSXP:
     	v.assign( REAL(m_sexp), REAL(m_sexp)+n) ;
     	break;
     case INTSXP:
-    	transform( INTEGER(m_sexp), INTEGER(m_sexp)+n, v.begin(), int_to_double) ;
+    	// transform( INTEGER(m_sexp), INTEGER(m_sexp)+n, v.begin(), int_to_double) ;
+    	v.assign( INTEGER(m_sexp), INTEGER(m_sexp)+n ) ;
     	break;
     default:
     	    throw std::range_error("as< vector<double> >:  expects raw, double or int");

Modified: pkg/src/exceptions.cpp
===================================================================
--- pkg/src/exceptions.cpp	2010-01-22 16:31:10 UTC (rev 429)
+++ pkg/src/exceptions.cpp	2010-01-22 17:13:49 UTC (rev 430)
@@ -19,7 +19,7 @@
 // You should have received a copy of the GNU General Public License
 // along with Rcpp.  If not, see <http://www.gnu.org/licenses/>.
 
-#include <RcppCommon.h>
+#include <Rcpp.h>
 
 /* for now, the fancy exception handling is only available in GCC, 
    simply because we've not investigated if it is available in other 
@@ -78,7 +78,6 @@
 	     ) ; 
 }
 
-
 #else
 void forward_uncaught_exceptions_to_r(){
 	Rf_eval( 



More information about the Rcpp-commits mailing list