1 #ifndef RLANG_CND_H
2 #define RLANG_CND_H
3
4 #include <stdbool.h>
5
6
7 void r_inform(const char* fmt, ...);
8 void r_warn(const char* fmt, ...);
9 void r_abort(const char* fmt, ...) __attribute__((noreturn));
10 void r_interrupt();
11
12 void r_signal_soft_deprecated(const char* msg, const char* id, sexp* env);
13 void r_warn_deprecated(const char* id, const char* fmt, ...);
14 void r_stop_defunct(const char* fmt, ...);
15
16 sexp* r_interp_str(const char* fmt, ...);
17
18 sexp* r_new_condition(sexp* type, sexp* msg, sexp* data);
19
r_is_condition(sexp * x)20 static inline bool r_is_condition(sexp* x) {
21 return TYPEOF(x) == VECSXP && Rf_inherits(x, "condition");
22 }
23
24 void r_cnd_signal(sexp* cnd);
25 void r_cnd_inform(sexp* cnd, bool mufflable);
26 void r_cnd_warn(sexp* cnd, bool mufflable);
27 void r_cnd_abort(sexp* cnd, bool mufflable);
28
29 enum r_condition_type {
30 r_cnd_type_condition = 0,
31 r_cnd_type_message = 1,
32 r_cnd_type_warning = 2,
33 r_cnd_type_error = 3,
34 r_cnd_type_interrupt = 4
35 };
36
37 enum r_condition_type r_cnd_type(sexp* cnd);
38
39 static inline
40 __attribute__((noreturn))
r_stop_internal(const char * fn,const char * msg)41 void r_stop_internal(const char* fn, const char* msg) {
42 r_abort("Internal error in `%s()`: %s", fn, msg);
43 }
44
45
46 #endif
47