[Rcpp-commits] r4133 - in pkg/Rcpp: inst/include inst/include/Rcpp src
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Mon Dec 10 16:37:39 CET 2012
Author: romain
Date: 2012-12-10 16:37:39 +0100 (Mon, 10 Dec 2012)
New Revision: 4133
Modified:
pkg/Rcpp/inst/include/Rcpp/exceptions.h
pkg/Rcpp/inst/include/RcppCommon.h
pkg/Rcpp/src/Date.cpp
pkg/Rcpp/src/api.cpp
Log:
simplify string_to_try_error
Modified: pkg/Rcpp/inst/include/Rcpp/exceptions.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/exceptions.h 2012-12-10 15:24:26 UTC (rev 4132)
+++ pkg/Rcpp/inst/include/Rcpp/exceptions.h 2012-12-10 15:37:39 UTC (rev 4133)
@@ -133,4 +133,18 @@
std::string demangle( const std::string& name) ;
#define DEMANGLE(__TYPE__) demangle( typeid(__TYPE__).name() ).c_str()
+namespace Rcpp{
+ /* internal namespace for things not intended to be used by the user */
+ namespace internal{
+
+ SEXP try_catch( SEXP expr, SEXP env );
+ SEXP try_catch( SEXP expr );
+
+ } // namespace internal
+} // namespace Rcpp
+
+namespace Rcpp {
+ inline void stop(const std::string& message) { throw Rcpp::exception(message.c_str()); }
+} // namespace Rcpp
+
#endif
Modified: pkg/Rcpp/inst/include/RcppCommon.h
===================================================================
--- pkg/Rcpp/inst/include/RcppCommon.h 2012-12-10 15:24:26 UTC (rev 4132)
+++ pkg/Rcpp/inst/include/RcppCommon.h 2012-12-10 15:37:39 UTC (rev 4133)
@@ -91,20 +91,6 @@
#include <Rcpp/exceptions.h>
namespace Rcpp{
- /* internal namespace for things not intended to be used by the user */
- namespace internal{
-
- SEXP try_catch( SEXP expr, SEXP env );
- SEXP try_catch( SEXP expr );
-
- } // namespace internal
-} // namespace Rcpp
-
-namespace Rcpp {
- inline void stop(const std::string& message) { throw Rcpp::exception(message.c_str()); }
-} // namespace Rcpp
-
-namespace Rcpp{
template <typename T> class object ;
class String ;
namespace internal{
Modified: pkg/Rcpp/src/Date.cpp
===================================================================
--- pkg/Rcpp/src/Date.cpp 2012-12-10 15:24:26 UTC (rev 4132)
+++ pkg/Rcpp/src/Date.cpp 2012-12-10 15:37:39 UTC (rev 4133)
@@ -34,7 +34,8 @@
#include <Rcpp/Function.h>
#include <Rmath.h> // for Rf_fround
#include <time.h> // for gmtime
-
+#include <Rcpp/exceptions.h>
+
namespace Rcpp {
static struct tm * gmtime_(const time_t * const timep); // see below
Modified: pkg/Rcpp/src/api.cpp
===================================================================
--- pkg/Rcpp/src/api.cpp 2012-12-10 15:24:26 UTC (rev 4132)
+++ pkg/Rcpp/src/api.cpp 2012-12-10 15:37:39 UTC (rev 4133)
@@ -1325,18 +1325,15 @@
using namespace Rcpp;
// form simple error condition based on a string
- SEXP rcppNS = PROTECT(R_FindNamespace(Rf_mkString("Rcpp")));
- SEXP simpleErrorExpr = PROTECT(::Rcpp_lcons(::Rf_install("simpleError"),
- pairlist(str, R_NilValue)));
- SEXP simpleError = PROTECT(Rf_eval(simpleErrorExpr, rcppNS));
+ SEXP simpleErrorExpr = PROTECT(::Rf_lang2(::Rf_install("simpleError"), Rf_mkString(str.c_str())));
+ SEXP simpleError = PROTECT(Rf_eval(simpleErrorExpr, R_GlobalEnv));
- // create the try-error structure
- SEXP structureExpr = PROTECT(::Rcpp_lcons(::Rf_install("structure"),
- pairlist(str, _["class"] = "try-error", _["condition"] = simpleError)));
- SEXP tryError = PROTECT(Rf_eval(structureExpr, rcppNS));
-
+ SEXP tryError = PROTECT( Rf_mkString( str.c_str() ) ) ;
+ Rf_setAttrib( tryError, R_ClassSymbol, Rf_mkString("try-error") ) ;
+ Rf_setAttrib( tryError, Rf_install( "condition") , simpleError ) ;
+
// unprotect and return
- UNPROTECT(5);
+ UNPROTECT(3);
return tryError;
}
More information about the Rcpp-commits
mailing list