Skip to content

Commit 8f5cd61

Browse files
committed
Respond to commit review
+ Move NEWS.Rd entries to the bottom of the relevant section + Restore GET_STACKTRACE macro + Move open brace to conform to code style + Add copywrite comment block to Rcpp/exceptions_impl.h + Restore useless stack_trace API in Rcpp/routines.h + Restore RCPP_REGISTER(stack_trace)
1 parent 2815ae8 commit 8f5cd61

File tree

6 files changed

+40
-5
lines changed

6 files changed

+40
-5
lines changed

inst/NEWS.Rd

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
\itemize{
88
\item Changes in Rcpp API:
99
\itemize{
10-
\item \code{Rcpp::exception} is now thread-safe
1110
\item Safer \code{Rcpp_list*}, \code{Rcpp_lang*} and
1211
\code{Function.operator()} (Romain in \ghpr{1014}, \ghit{1015}).
1312
\item A number of \code{#nocov} markers were added (Dirk in
@@ -16,6 +15,9 @@
1615
Dirk in \ghpr{1038}).
1716
\item Scalar operations with a rhs matrix no longer change the
1817
matrix value (Qiang in \ghpr{1040} fixing (again) \ghit{365}).
18+
\item \code{Rcpp::exception} and \code{Rcpp::stop} are now
19+
thread-safe. Be cautioned that most of Rcpp continues to be not
20+
thread-safe.
1921
}
2022
\item Changes in Rcpp Attributes:
2123
\itemize{

inst/include/Rcpp/exceptions.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,21 +27,21 @@
2727
#define RCPP_DEFAULT_INCLUDE_CALL true
2828
#endif
2929

30+
#define GET_STACKTRACE() R_NilValue
31+
3032
namespace Rcpp {
3133

3234
// Throwing an exception must be thread-safe to avoid surprises w/ OpenMP.
3335
class exception : public std::exception {
3436
public:
3537
explicit exception(const char* message_, bool include_call = RCPP_DEFAULT_INCLUDE_CALL) : // #nocov start
3638
message(message_),
37-
include_call_(include_call)
38-
{
39+
include_call_(include_call) {
3940
record_stack_trace();
4041
}
4142
exception(const char* message_, const char*, int, bool include_call = RCPP_DEFAULT_INCLUDE_CALL) :
4243
message(message_),
43-
include_call_(include_call)
44-
{
44+
include_call_(include_call) {
4545
record_stack_trace();
4646
}
4747
bool include_call() const {

inst/include/Rcpp/exceptions_impl.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
1+
// exceptions_impl.h: Rcpp R/C++ interface class library -- exceptions
2+
//
3+
// Copyright (C) 2020 Dirk Eddelbuettel and Romain Francois
4+
//
5+
// This file is part of Rcpp.
6+
//
7+
// Rcpp is free software: you can redistribute it and/or modify it
8+
// under the terms of the GNU General Public License as published by
9+
// the Free Software Foundation, either version 2 of the License, or
10+
// (at your option) any later version.
11+
//
12+
// Rcpp is distributed in the hope that it will be useful, but
13+
// WITHOUT ANY WARRANTY; without even the implied warranty of
14+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
// GNU General Public License for more details.
16+
//
17+
// You should have received a copy of the GNU General Public License
18+
// along with Rcpp. If not, see <http://www.gnu.org/licenses/>.
19+
120
namespace Rcpp {
221
#if defined(__GNUC__) || defined(__clang__)
322
#if defined(_WIN32) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__CYGWIN__) || defined(__sun) || defined(_AIX) || defined(__MUSL__) || defined(__HAIKU__) || defined(__ANDROID__)

inst/include/Rcpp/routines.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ SEXP rcpp_set_stack_trace(SEXP);
4545
std::string demangle(const std::string& name);
4646
const char* short_file_name(const char* );
4747
int* get_cache(int n);
48+
SEXP stack_trace( const char *file = "", int line = -1);
4849
SEXP get_string_elt(SEXP s, R_xlen_t i);
4950
const char* char_get_string_elt(SEXP s, R_xlen_t i);
5051
void set_string_elt(SEXP s, R_xlen_t i, SEXP v);
@@ -156,6 +157,12 @@ inline attribute_hidden const char* short_file_name(const char* file) {
156157
return fun(file);
157158
}
158159

160+
inline attribute_hidden SEXP stack_trace( const char *file = "", int line = -1){
161+
typedef SEXP (*Fun)(const char*, int);
162+
static Fun fun = GET_CALLABLE("stack_trace");
163+
return fun(file, line);
164+
}
165+
159166
inline attribute_hidden SEXP get_string_elt(SEXP s, R_xlen_t i){
160167
typedef SEXP (*Fun)(SEXP, R_xlen_t);
161168
static Fun fun = GET_CALLABLE("get_string_elt");

src/api.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,12 @@ SEXP rcpp_can_use_cxx11() { // #nocov start
251251
} // #nocov end
252252

253253

254+
// [[Rcpp::register]]
255+
SEXP stack_trace(const char* file, int line) {
256+
return R_NilValue;
257+
}
258+
259+
254260
// // [ [ Rcpp::register ] ]
255261
// void print(SEXP s) {
256262
// Rf_PrintValue(s); // defined in Rinternals.h

src/rcpp_init.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ void registerFunctions(){
100100
RCPP_REGISTER(endSuspendRNGSynchronization);
101101
RCPP_REGISTER(get_Rcpp_namespace)
102102
RCPP_REGISTER(get_cache)
103+
RCPP_REGISTER(stack_trace)
103104
RCPP_REGISTER(get_string_elt)
104105
RCPP_REGISTER(char_get_string_elt)
105106
RCPP_REGISTER(set_string_elt)

0 commit comments

Comments
 (0)