[Rcpp-commits] r1098 - in pkg/Rcpp: inst/include/Rcpp inst/unitTests src
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Wed Apr 21 22:39:11 CEST 2010
Author: romain
Date: 2010-04-21 22:39:11 +0200 (Wed, 21 Apr 2010)
New Revision: 1098
Modified:
pkg/Rcpp/inst/include/Rcpp/Environment.h
pkg/Rcpp/inst/include/Rcpp/exceptions.h
pkg/Rcpp/inst/unitTests/runit.Language.R
pkg/Rcpp/inst/unitTests/runit.environments.R
pkg/Rcpp/src/Environment.cpp
pkg/Rcpp/src/RcppCommon.cpp
Log:
moving no_such_binding exception outside of Environment class
Modified: pkg/Rcpp/inst/include/Rcpp/Environment.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/Environment.h 2010-04-21 13:37:58 UTC (rev 1097)
+++ pkg/Rcpp/inst/include/Rcpp/Environment.h 2010-04-21 20:39:11 UTC (rev 1098)
@@ -23,7 +23,7 @@
#define Rcpp_Environment_h
#include <RcppCommon.h>
-
+#include <Rcpp/exceptions.h>
#include <Rcpp/Evaluator.h>
#include <Rcpp/Symbol.h>
#include <Rcpp/Language.h>
@@ -44,28 +44,6 @@
std::string binding ;
} ;
- /**
- * Exception thrown when attempting to perform an operation on
- * a binding and there is no such binding
- */
- class no_such_binding: public std::exception{
- public:
- /**
- * @param binding name of the binding
- */
- no_such_binding( const std::string& binding) ;
-
- virtual ~no_such_binding() throw() ;
-
- /**
- * The message: no such binding : '{binding}'
- */
- virtual const char* what() const throw();
-
- private:
- std::string message ;
- } ;
-
/**
* Exception thrown when attempting to assign a value to a binding
* that is locked
Modified: pkg/Rcpp/inst/include/Rcpp/exceptions.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/exceptions.h 2010-04-21 13:37:58 UTC (rev 1097)
+++ pkg/Rcpp/inst/include/Rcpp/exceptions.h 2010-04-21 20:39:11 UTC (rev 1098)
@@ -55,7 +55,39 @@
private:
std::string message ;
} ;
-
+
+
+/**
+ * Exception thrown when attempting to perform an operation on
+ * a binding and there is no such binding
+ */
+ class no_such_binding: public std::exception{
+ public:
+
+ no_such_binding() throw() : message(){}
+ no_such_binding(const no_such_binding& other) throw() : message(other.message){} ;
+ no_such_binding& operator=( const no_such_binding& other ){
+ message = other.message ;
+ return *this ;
+ }
+ /**
+ * @param binding name of the binding
+ */
+ no_such_binding( const std::string& binding) throw() :
+ message( std::string("no such binding : '") + binding + "'" ) {};
+
+ virtual ~no_such_binding() throw(){} ;
+
+ /**
+ * The message: no such binding : '{binding}'
+ */
+ virtual const char* what() const throw(){ return message.c_str() ; }
+
+ private:
+ std::string message ;
+ } ;
+
+
} // namesapce Rcpp
#endif
Modified: pkg/Rcpp/inst/unitTests/runit.Language.R
===================================================================
--- pkg/Rcpp/inst/unitTests/runit.Language.R 2010-04-21 13:37:58 UTC (rev 1097)
+++ pkg/Rcpp/inst/unitTests/runit.Language.R 2010-04-21 20:39:11 UTC (rev 1098)
@@ -20,8 +20,6 @@
test.Language <- function(){
funx <- cppfunction(signature(x="ANY"), 'return Language(x) ;' )
checkEquals( funx( call("rnorm") ), call("rnorm" ), msg = "Language( LANGSXP )" )
- # checkEquals( funx( list( as.name("rnorm") ) ), call("rnorm" ),
- # msg = "Language( list with 1st arg symbol )" )
checkException( funx(funx), msg = "Language not compatible with function" )
checkException( funx(new.env()), msg = "Language not compatible with environment" )
checkException( funx(1:10), msg = "Language not compatible with integer" )
Modified: pkg/Rcpp/inst/unitTests/runit.environments.R
===================================================================
--- pkg/Rcpp/inst/unitTests/runit.environments.R 2010-04-21 13:37:58 UTC (rev 1097)
+++ pkg/Rcpp/inst/unitTests/runit.environments.R 2010-04-21 20:39:11 UTC (rev 1098)
@@ -146,7 +146,7 @@
checkTrue( !funx(e, "a" ), msg = "Environment::bindingIsActive( non active ) -> false" )
checkTrue( funx(e, "b" ), msg = "Environment::bindingIsActive( active ) -> true" )
checkTrue(
- tryCatch( { funx(e, "xx" ) ; FALSE}, "Rcpp::Environment::no_such_binding" = function(e) TRUE ),
+ tryCatch( { funx(e, "xx" ) ; FALSE}, "Rcpp::no_such_binding" = function(e) TRUE ),
msg = "Environment::bindingIsActive(no binding) -> exception)" )
}
@@ -167,7 +167,7 @@
checkTrue( !funx(e, "a" ), msg = "Environment::bindingIsActive( non active ) -> false" )
checkTrue( funx(e, "b" ), msg = "Environment::bindingIsActive( active ) -> true" )
checkTrue(
- tryCatch( { funx(e, "xx" ) ; FALSE}, "Rcpp::Environment::no_such_binding" = function(e) TRUE ),
+ tryCatch( { funx(e, "xx" ) ; FALSE}, "Rcpp::no_such_binding" = function(e) TRUE ),
msg = "Environment::bindingIsLocked(no binding) -> exception)" )
}
@@ -195,7 +195,7 @@
funx(e, "b")
checkTrue( bindingIsLocked("b", e ), msg = "Environment::lockBinding()" )
checkTrue(
- tryCatch( { funx(e, "xx" ) ; FALSE}, "Rcpp::Environment::no_such_binding" = function(e) TRUE ),
+ tryCatch( { funx(e, "xx" ) ; FALSE}, "Rcpp::no_such_binding" = function(e) TRUE ),
msg = "Environment::lockBinding(no binding) -> exception)" )
}
@@ -215,7 +215,7 @@
funx(e, "b")
checkTrue( !bindingIsLocked("b", e ), msg = "Environment::lockBinding()" )
checkTrue(
- tryCatch( { funx(e, "xx" ) ; FALSE}, "Rcpp::Environment::no_such_binding" = function(e) TRUE ),
+ tryCatch( { funx(e, "xx" ) ; FALSE}, "Rcpp::no_such_binding" = function(e) TRUE ),
msg = "Environment::unlockBinding(no binding) -> exception)" )
}
Modified: pkg/Rcpp/src/Environment.cpp
===================================================================
--- pkg/Rcpp/src/Environment.cpp 2010-04-21 13:37:58 UTC (rev 1097)
+++ pkg/Rcpp/src/Environment.cpp 2010-04-21 20:39:11 UTC (rev 1098)
@@ -225,15 +225,7 @@
return Environment( ENCLOS(m_sexp) ) ;
}
- /* exceptions */
-
- Environment::no_such_binding::no_such_binding(const std::string& binding) :
- message( "no such binding : '" + binding + "'" ) {}
- const char* Environment::no_such_binding::what() const throw(){
- return message.c_str() ;
- }
- Environment::no_such_binding::~no_such_binding() throw() {}
-
+ /* exceptions */
Environment::binding_is_locked::binding_is_locked(const std::string& binding) :
message("binding is locked : '" + binding + "'" ) {}
const char* Environment::binding_is_locked::what() const throw(){
Modified: pkg/Rcpp/src/RcppCommon.cpp
===================================================================
--- pkg/Rcpp/src/RcppCommon.cpp 2010-04-21 13:37:58 UTC (rev 1097)
+++ pkg/Rcpp/src/RcppCommon.cpp 2010-04-21 20:39:11 UTC (rev 1098)
@@ -120,9 +120,8 @@
}
}
-void R_init_Rcpp(DllInfo* info){
- // initUncaughtExceptionHandler() ;
- // return R_NilValue ;
+extern "C" void R_init_Rcpp(DllInfo* info){
+ initUncaughtExceptionHandler() ;
}
namespace Rcpp{
More information about the Rcpp-commits
mailing list