File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change 29
29
#ifndef BEGIN_RCPP
30
30
#define BEGIN_RCPP \
31
31
int rcpp_output_type = 0 ; \
32
+ int nprot = 0 ; \
32
33
(void )rcpp_output_type; \
33
34
SEXP rcpp_output_condition = R_NilValue ; \
34
35
(void )rcpp_output_condition; \
36
+ static SEXP stop_sym = Rf_install(" stop" ); \
35
37
try {
36
38
#endif
37
39
48
50
catch (Rcpp::exception& __ex__) { \
49
51
rcpp_output_type = 2 ; \
50
52
rcpp_output_condition = PROTECT (rcpp_exception_to_r_condition (__ex__)) ; \
53
+ ++nprot; \
51
54
} \
52
55
catch ( std::exception& __ex__ ){ \
53
56
rcpp_output_type = 2 ; \
54
57
rcpp_output_condition = PROTECT (exception_to_r_condition (__ex__)) ; \
58
+ ++nprot; \
55
59
} \
56
60
catch ( ... ){ \
57
61
rcpp_output_type = 2 ; \
58
62
rcpp_output_condition = PROTECT (string_to_try_error (" c++ exception (unknown reason)" )) ; \
63
+ ++nprot; \
59
64
} \
60
65
if ( rcpp_output_type == 1 ){ \
61
66
Rf_onintr () ; \
62
67
} \
63
68
if ( rcpp_output_type == 2 ){ \
64
- SEXP stop_sym = Rf_install ( " stop" ) ; \
65
69
SEXP expr = PROTECT ( Rf_lang2 ( stop_sym , rcpp_output_condition ) ) ; \
66
- Rf_eval ( expr, R_GlobalEnv ) ; \
70
+ ++nprot; \
71
+ Rf_eval ( expr, R_BaseEnv ) ; \
67
72
} \
68
73
if (rcpp_output_type == 3 ) { \
69
74
Rcpp::internal::resumeJump (rcpp_output_condition); \
70
- }
75
+ } \
76
+ UNPROTECT (nprot);
71
77
#endif
72
78
73
79
#ifndef END_RCPP
You can’t perform that action at this time.
0 commit comments