[Rcpp-commits] r1102 - in pkg/Rcpp: inst/include inst/include/Rcpp src
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Thu Apr 22 00:34:50 CEST 2010
Author: romain
Date: 2010-04-22 00:34:49 +0200 (Thu, 22 Apr 2010)
New Revision: 1102
Modified:
pkg/Rcpp/inst/include/Rcpp/r_cast.h
pkg/Rcpp/inst/include/RcppCommon.h
pkg/Rcpp/src/Evaluator.cpp
pkg/Rcpp/src/r_cast.cpp
Log:
careful use of not_compatible exception
Modified: pkg/Rcpp/inst/include/Rcpp/r_cast.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/r_cast.h 2010-04-21 22:25:09 UTC (rev 1101)
+++ pkg/Rcpp/inst/include/Rcpp/r_cast.h 2010-04-21 22:34:49 UTC (rev 1102)
@@ -30,20 +30,20 @@
// /* r_true_cast is only meant to be used when the target SEXP type
// is different from the SEXP type of x */
template <int TARGET>
-SEXP r_true_cast( SEXP x) throw(not_compatible) {
+SEXP r_true_cast( SEXP x) throw(::Rcpp::not_compatible) {
throw not_compatible( "not compatible" ) ;
}
-template<> SEXP r_true_cast<INTSXP>(SEXP x) throw(not_compatible) ;
-template<> SEXP r_true_cast<REALSXP>(SEXP x) throw(not_compatible) ;
-template<> SEXP r_true_cast<RAWSXP>(SEXP x) throw(not_compatible) ;
-template<> SEXP r_true_cast<CPLXSXP>(SEXP x) throw(not_compatible) ;
-template<> SEXP r_true_cast<LGLSXP>(SEXP x) throw(not_compatible) ;
-template<> SEXP r_true_cast<STRSXP>(SEXP x) throw(not_compatible) ;
-template<> SEXP r_true_cast<VECSXP>(SEXP x) throw(not_compatible) ;
-template<> SEXP r_true_cast<EXPRSXP>(SEXP x) throw(not_compatible) ;
-template<> SEXP r_true_cast<LISTSXP>(SEXP x) throw(not_compatible) ;
-template<> SEXP r_true_cast<LANGSXP>(SEXP x) throw(not_compatible) ;
+template<> SEXP r_true_cast<INTSXP>(SEXP x) throw(::Rcpp::not_compatible) ;
+template<> SEXP r_true_cast<REALSXP>(SEXP x) throw(::Rcpp::not_compatible) ;
+template<> SEXP r_true_cast<RAWSXP>(SEXP x) throw(::Rcpp::not_compatible) ;
+template<> SEXP r_true_cast<CPLXSXP>(SEXP x) throw(::Rcpp::not_compatible) ;
+template<> SEXP r_true_cast<LGLSXP>(SEXP x) throw(::Rcpp::not_compatible) ;
+template<> SEXP r_true_cast<STRSXP>(SEXP x) throw(::Rcpp::not_compatible) ;
+template<> SEXP r_true_cast<VECSXP>(SEXP x) throw(::Rcpp::not_compatible) ;
+template<> SEXP r_true_cast<EXPRSXP>(SEXP x) throw(::Rcpp::not_compatible) ;
+template<> SEXP r_true_cast<LISTSXP>(SEXP x) throw(::Rcpp::not_compatible) ;
+template<> SEXP r_true_cast<LANGSXP>(SEXP x) throw(::Rcpp::not_compatible) ;
} // namespace internal
Modified: pkg/Rcpp/inst/include/RcppCommon.h
===================================================================
--- pkg/Rcpp/inst/include/RcppCommon.h 2010-04-21 22:25:09 UTC (rev 1101)
+++ pkg/Rcpp/inst/include/RcppCommon.h 2010-04-21 22:34:49 UTC (rev 1102)
@@ -168,13 +168,15 @@
const char * sexp_to_name(int sexp_type);
+#include <Rcpp/exceptions.h>
+
namespace Rcpp{
/* internal namespace for things not intended to be used by the
user */
namespace internal{
/* defined in Evaluator.cpp */
- SEXP convert_using_rfunction(SEXP x, const char* const fun) ;
+ SEXP convert_using_rfunction(SEXP x, const char* const fun) throw(::Rcpp::not_compatible) ;
SEXP try_catch( SEXP expr, SEXP env ) ;
SEXP try_catch( SEXP expr ) ;
@@ -224,7 +226,6 @@
#include <Rcpp/internal/caster.h>
#include <Rcpp/internal/r_vector.h>
-#include <Rcpp/exceptions.h>
#include <Rcpp/r_cast.h>
#include <Rcpp/internal/export.h>
Modified: pkg/Rcpp/src/Evaluator.cpp
===================================================================
--- pkg/Rcpp/src/Evaluator.cpp 2010-04-21 22:25:09 UTC (rev 1101)
+++ pkg/Rcpp/src/Evaluator.cpp 2010-04-21 22:34:49 UTC (rev 1102)
@@ -59,12 +59,12 @@
namespace internal{
/* this is defined here because we need to be sure that Evaluator is
defined */
- SEXP convert_using_rfunction(SEXP x, const char* const fun) {
+ SEXP convert_using_rfunction(SEXP x, const char* const fun) throw(::Rcpp::not_compatible) {
SEXP res = R_NilValue ;
try{
res = Evaluator::run( Rf_lcons( Rf_install(fun), Rf_cons(x, R_NilValue) ) ) ;
} catch( Evaluator::eval_error& e){
- throw not_compatible( std::string("could not convert using R function : ") + fun ) ;
+ throw ::Rcpp::not_compatible( std::string("could not convert using R function : ") + fun ) ;
}
return res;
}
Modified: pkg/Rcpp/src/r_cast.cpp
===================================================================
--- pkg/Rcpp/src/r_cast.cpp 2010-04-21 22:25:09 UTC (rev 1101)
+++ pkg/Rcpp/src/r_cast.cpp 2010-04-21 22:34:49 UTC (rev 1102)
@@ -25,7 +25,7 @@
namespace Rcpp{
namespace internal{
-template<> SEXP r_true_cast<INTSXP>(SEXP x) throw(not_compatible){
+template<> SEXP r_true_cast<INTSXP>(SEXP x) throw(::Rcpp::not_compatible){
switch( TYPEOF(x) ){
case REALSXP:
case RAWSXP:
@@ -33,12 +33,12 @@
case CPLXSXP:
return Rf_coerceVector( x, INTSXP) ;
default:
- throw not_compatible( "not compatible with INTSXP" ) ;
+ throw ::Rcpp::not_compatible( "not compatible with INTSXP" ) ;
}
return R_NilValue ; /* -Wall */
}
-template<> SEXP r_true_cast<REALSXP>( SEXP x) throw(not_compatible){
+template<> SEXP r_true_cast<REALSXP>( SEXP x) throw(::Rcpp::not_compatible){
switch( TYPEOF( x ) ){
case INTSXP:
case LGLSXP:
@@ -46,12 +46,12 @@
case RAWSXP:
return Rf_coerceVector( x, REALSXP );
default:
- throw not_compatible( "not compatible with INTSXP" ) ;
+ throw ::Rcpp::not_compatible( "not compatible with INTSXP" ) ;
}
return R_NilValue ; /* -Wall */
}
-template<> SEXP r_true_cast<LGLSXP>( SEXP x) throw(not_compatible){
+template<> SEXP r_true_cast<LGLSXP>( SEXP x) throw(::Rcpp::not_compatible){
switch( TYPEOF( x ) ){
case REALSXP:
case INTSXP:
@@ -59,12 +59,12 @@
case RAWSXP:
return Rf_coerceVector( x, LGLSXP );
default:
- throw not_compatible( "not compatible with LGLSXP" ) ;
+ throw ::Rcpp::not_compatible( "not compatible with LGLSXP" ) ;
}
return R_NilValue ; /* -Wall */
}
-template<> SEXP r_true_cast<RAWSXP>( SEXP x) throw(not_compatible){
+template<> SEXP r_true_cast<RAWSXP>( SEXP x) throw(::Rcpp::not_compatible){
switch( TYPEOF( x ) ){
case LGLSXP:
case REALSXP:
@@ -72,13 +72,13 @@
case CPLXSXP:
return Rf_coerceVector( x, RAWSXP );
default:
- throw not_compatible( "not compatible with RAWSXP" ) ;
+ throw ::Rcpp::not_compatible( "not compatible with RAWSXP" ) ;
}
return R_NilValue ; /* -Wall */
}
-template<> SEXP r_true_cast<CPLXSXP>( SEXP x) throw(not_compatible){
+template<> SEXP r_true_cast<CPLXSXP>( SEXP x) throw(::Rcpp::not_compatible){
switch( TYPEOF( x ) ){
case RAWSXP:
case LGLSXP:
@@ -86,12 +86,12 @@
case INTSXP:
return Rf_coerceVector( x, CPLXSXP );
default:
- throw not_compatible( "not compatible with CPLXSXP" ) ;
+ throw ::Rcpp::not_compatible( "not compatible with CPLXSXP" ) ;
}
return R_NilValue ; /* -Wall */
}
-template<> SEXP r_true_cast<STRSXP>( SEXP x) throw(not_compatible){
+template<> SEXP r_true_cast<STRSXP>( SEXP x) throw(::Rcpp::not_compatible){
switch( TYPEOF( x ) ){
case CPLXSXP:
case RAWSXP:
@@ -104,20 +104,20 @@
case SYMSXP:
return Rf_ScalarString( PRINTNAME( x ) ) ;
default:
- throw not_compatible( "not compatible with STRSXP" ) ;
+ throw ::Rcpp::not_compatible( "not compatible with STRSXP" ) ;
}
return R_NilValue ; /* -Wall */
}
-template<> SEXP r_true_cast<VECSXP>(SEXP x) throw(not_compatible){
+template<> SEXP r_true_cast<VECSXP>(SEXP x) throw(::Rcpp::not_compatible){
return convert_using_rfunction(x, "as.list" ) ;
}
-template<> SEXP r_true_cast<EXPRSXP>(SEXP x) throw(not_compatible){
+template<> SEXP r_true_cast<EXPRSXP>(SEXP x) throw(::Rcpp::not_compatible){
return convert_using_rfunction(x, "as.expression" ) ;
}
-template<> SEXP r_true_cast<LISTSXP>(SEXP x) throw(not_compatible){
+template<> SEXP r_true_cast<LISTSXP>(SEXP x) throw(::Rcpp::not_compatible){
switch( TYPEOF(x) ){
case LANGSXP:
{
@@ -133,7 +133,7 @@
}
-template<> SEXP r_true_cast<LANGSXP>(SEXP x) throw(not_compatible) {
+template<> SEXP r_true_cast<LANGSXP>(SEXP x) throw(::Rcpp::not_compatible) {
return convert_using_rfunction(x, "as.call" ) ;
}
More information about the Rcpp-commits
mailing list