22 #ifndef Rcpp_macros_macros_h
23 #define Rcpp_macros_macros_h
34 size_t index = f.find(
"/include/");
35 if (index != std::string::npos)
36 f = f.substr(index + 9);
44 #define RCPP_DECORATE(__FUN__) __FUN__##__rcpp__wrapper__
45 #define RCPP_GET_NAMES(x) Rf_getAttrib(x, R_NamesSymbol)
46 #define RCPP_GET_CLASS(x) Rf_getAttrib(x, R_ClassSymbol)
50 int rcpp_output_type = 0 ; \
52 (void)rcpp_output_type; \
53 SEXP rcpp_output_condition = R_NilValue ; \
54 (void)rcpp_output_condition; \
55 static SEXP stop_sym = Rf_install("stop"); \
60 #define VOID_END_RCPP \
62 catch( Rcpp::internal::InterruptedException &__ex__) { \
63 rcpp_output_type = 1 ; \
65 catch (Rcpp::LongjumpException& __ex__) { \
66 rcpp_output_type = 3 ; \
67 rcpp_output_condition = __ex__.token; \
69 catch(Rcpp::exception& __ex__) { \
70 rcpp_output_type = 2 ; \
71 rcpp_output_condition = PROTECT(rcpp_exception_to_r_condition(__ex__)) ; \
74 catch( std::exception& __ex__ ){ \
75 rcpp_output_type = 2 ; \
76 rcpp_output_condition = PROTECT(exception_to_r_condition(__ex__)) ; \
80 rcpp_output_type = 2 ; \
81 rcpp_output_condition = PROTECT(string_to_try_error("c++ exception (unknown reason)")) ; \
84 if( rcpp_output_type == 1 ){ \
87 if( rcpp_output_type == 2 ){ \
88 SEXP expr = PROTECT( Rf_lang2( stop_sym , rcpp_output_condition ) ) ; \
90 Rf_eval( expr, R_BaseEnv ) ; \
92 if (rcpp_output_type == 3) { \
93 Rcpp::internal::resumeJump(rcpp_output_condition); \
99 #define END_RCPP VOID_END_RCPP return R_NilValue;
105 #ifndef END_RCPP_RETURN_ERROR
106 #define END_RCPP_RETURN_ERROR \
108 catch (Rcpp::internal::InterruptedException &__ex__) { \
109 return Rcpp::internal::interruptedError(); \
111 catch (Rcpp::LongjumpException& __ex__) { \
112 return Rcpp::internal::longjumpSentinel(__ex__.token); \
114 catch (std::exception &__ex__) { \
115 return exception_to_try_error(__ex__); \
118 return string_to_try_error("c++ exception (unknown reason)"); \
125 #define Rcpp_error(MESSAGE) throw Rcpp::exception(MESSAGE, __FILE__, __LINE__)
std::string short_file_name(const char *file)