[Rcpp-commits] r1172 - in pkg/Rcpp/inst/include/Rcpp: . traits

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed May 5 13:31:51 CEST 2010


Author: romain
Date: 2010-05-05 13:31:50 +0200 (Wed, 05 May 2010)
New Revision: 1172

Modified:
   pkg/Rcpp/inst/include/Rcpp/Vector.h
   pkg/Rcpp/inst/include/Rcpp/traits/Exporter.h
Log:
track a few more undeclared exceptions

Modified: pkg/Rcpp/inst/include/Rcpp/Vector.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/Vector.h	2010-05-05 11:03:32 UTC (rev 1171)
+++ pkg/Rcpp/inst/include/Rcpp/Vector.h	2010-05-05 11:31:50 UTC (rev 1172)
@@ -260,12 +260,12 @@
 	} ;
 	
 	template <int RTYPE>
-	SEXP vector_from_string( const std::string& st ){
+	SEXP vector_from_string( const std::string& st ) throw(not_compatible) {
 		return r_cast<RTYPE>( Rf_mkString( st.c_str() ) ) ;
 	}
 	
 	template <int RTYPE>
-	SEXP vector_from_string_expr( const std::string& code){
+	SEXP vector_from_string_expr( const std::string& code) throw(parse_error) {
 		ParseStatus status;
 		SEXP expr = PROTECT( ::Rf_mkString( code.c_str() ) );
 		SEXP res  = PROTECT( ::R_ParseVector(expr, -1, &status, R_NilValue));
@@ -550,7 +550,7 @@
 		assign( first, last ) ;
 	}
 
-	Vector( const std::string& st ) : Base(){
+	Vector( const std::string& st ) throw(parse_error,not_compatible) : Base(){
 		Base::setSEXP( internal::vector_from_string<RTYPE>(st) );
 	}
 	
@@ -570,18 +570,18 @@
      */
     inline R_len_t size() const { return ::Rf_length( Base::m_sexp ) ; }
     
-    inline int ncol() const {
+    inline int ncol() const throw(not_a_matrix) {
     	return dims()[1]; 
     }
     
-    inline int nrow() const {
+    inline int nrow() const throw(not_a_matrix){
     	return dims()[0]; 
     }
 
-    inline int cols() const { 
+    inline int cols() const throw(not_a_matrix){ 
 	return dims()[1]; 
     }
-    inline int rows() const { 
+    inline int rows() const throw(not_a_matrix){ 
 	return dims()[0]; 
     }
 	
@@ -2249,7 +2249,7 @@
 		return result ;
 	}
 	
-	inline int* dims() const {
+	inline int* dims() const throw(not_a_matrix) {
 		if( !::Rf_isMatrix(Base::m_sexp) ) throw not_a_matrix() ;
 		return INTEGER( ::Rf_getAttrib( Base::m_sexp, ::Rf_install( "dim") ) ) ;
 	}

Modified: pkg/Rcpp/inst/include/Rcpp/traits/Exporter.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/traits/Exporter.h	2010-05-05 11:03:32 UTC (rev 1171)
+++ pkg/Rcpp/inst/include/Rcpp/traits/Exporter.h	2010-05-05 11:31:50 UTC (rev 1172)
@@ -80,10 +80,10 @@
 	MatrixExporter( SEXP x) : object(x){}
 	~MatrixExporter(){}
 	
-	T get(){
+	T get() throw(::Rcpp::not_a_matrix) {
 		SEXP dims = PROTECT( ::Rf_getAttrib( object, Rf_install("dim") ) ) ;
 		if( dims == R_NilValue || ::Rf_length(dims) != 2 ){
-			throw std::range_error( "not a matrix" ) ;
+			throw ::Rcpp::not_a_matrix() ;
 		}
 		int* dims_ = INTEGER(dims) ;
 		T result( dims_[0], dims_[1] ) ;



More information about the Rcpp-commits mailing list