[Rcpp-commits] r4026 - in pkg/Rcpp: . inst inst/include inst/include/Rcpp src
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Fri Nov 23 02:07:35 CET 2012
Author: jjallaire
Date: 2012-11-23 02:07:34 +0100 (Fri, 23 Nov 2012)
New Revision: 4026
Modified:
pkg/Rcpp/ChangeLog
pkg/Rcpp/inst/NEWS.Rd
pkg/Rcpp/inst/include/Rcpp/exceptions.h
pkg/Rcpp/inst/include/RcppCommon.h
pkg/Rcpp/src/exceptions.cpp
Log:
new exception constructor / stop function
Modified: pkg/Rcpp/ChangeLog
===================================================================
--- pkg/Rcpp/ChangeLog 2012-11-22 23:39:53 UTC (rev 4025)
+++ pkg/Rcpp/ChangeLog 2012-11-23 01:07:34 UTC (rev 4026)
@@ -1,3 +1,9 @@
+2012-11-22 JJ Allaire <jj at rstudio.org>
+
+ * include/exceptions.h: new exception constructor / stop function
+ * src/exceptions.cpp: new exception constructor / stop function
+ * include/RcppCommon.h: new exception constructor / stop function
+
2012-11-22 Romain Francois <romain at r-enthusiasts.com>
* include/Rcpp/iostream.h: use delete rdbuf() as recommended by Martyn Plummer
Modified: pkg/Rcpp/inst/NEWS.Rd
===================================================================
--- pkg/Rcpp/inst/NEWS.Rd 2012-11-22 23:39:53 UTC (rev 4025)
+++ pkg/Rcpp/inst/NEWS.Rd 2012-11-23 01:07:34 UTC (rev 4026)
@@ -21,6 +21,8 @@
\item New helper class \code{no_init} that can be used to
create a vector without initializing its data, e.g. :
\code{ IntegerVector out = no_init(n) ; }
+ \item New exception constructor requiring only a message; stop
+ function to throw an exception
}
\item Changes in Rcpp attributes:
\itemize{
Modified: pkg/Rcpp/inst/include/Rcpp/exceptions.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/exceptions.h 2012-11-22 23:39:53 UTC (rev 4025)
+++ pkg/Rcpp/inst/include/Rcpp/exceptions.h 2012-11-23 01:07:34 UTC (rev 4026)
@@ -26,6 +26,7 @@
class exception : public std::exception {
public:
+ explicit exception(const char* message_) ;
exception(const char* message_, const char* file, int line ) ;
virtual ~exception() throw() ;
virtual const char* what() const throw() ;
Modified: pkg/Rcpp/inst/include/RcppCommon.h
===================================================================
--- pkg/Rcpp/inst/include/RcppCommon.h 2012-11-22 23:39:53 UTC (rev 4025)
+++ pkg/Rcpp/inst/include/RcppCommon.h 2012-11-23 01:07:34 UTC (rev 4026)
@@ -260,8 +260,12 @@
SEXP stack_trace( const char *file, int line) ;
#define GET_STACKTRACE() stack_trace( __FILE__, __LINE__ )
-#define Rcpp_error(MESSAGE) throw new Rcpp::exception( MESSAGE, __FILE__, __LINE__ )
+#define Rcpp_error(MESSAGE) throw Rcpp::exception( MESSAGE, __FILE__, __LINE__ )
+namespace Rcpp {
+ inline void stop(const std::string& message) { throw Rcpp::exception(message.c_str()); }
+} // namespace Rcpp
+
#if RCPP_DEBUG_LEVEL > 0
#include <typeinfo>
#endif
Modified: pkg/Rcpp/src/exceptions.cpp
===================================================================
--- pkg/Rcpp/src/exceptions.cpp 2012-11-22 23:39:53 UTC (rev 4025)
+++ pkg/Rcpp/src/exceptions.cpp 2012-11-23 01:07:34 UTC (rev 4026)
@@ -22,6 +22,7 @@
#include <Rcpp.h>
namespace Rcpp{
+ exception::exception(const char* message_) : message(message_) {}
exception::exception( const char* message_, const char* file, int line) : message(message_){
rcpp_set_stack_trace( stack_trace(file,line) ) ;
}
More information about the Rcpp-commits
mailing list