121 #ifndef __CCL_EXCEPTION_H__
122 # define __CCL_EXCEPTION_H__
140 typedef struct ccl_exception_local_variable_st ccl_exception_local_variable;
142 struct ccl_exception_st {
145 ccl_exception_local_variable *vars;
149 struct ccl_exception_type_st {
159 # define CCL_THROW(_args_)
167 # define CCL_DECLARE_EXCEPTION(exc,super) \
168 extern const ccl_exception_type CCL_EXCEPTION_NAME (exc)
175 # define CCL_DEFINE_EXCEPTION(exc,super) \
176 const ccl_exception_type CCL_EXCEPTION_NAME (exc) = { \
177 # exc, &CCL_EXCEPTION_NAME (super) \
185 # define CCL_EXCEPTION_NAME(exc) ccl_exception_ ## exc
229 # define ccl_try(_extype_) \
231 ccl_exception here; \
232 ccl_exception_push (&here, &CCL_EXCEPTION_NAME (_extype_)); \
233 if (setjmp (here.context) == 0) \
243 ccl_exception_cleanup_local_variables (0); \
244 ccl_exception_pop (); \
246 ccl_exception_cleanup_local_variables (1); \
247 ccl_exception_pop ();
249 # define ccl_catch_rethrow ccl_catch { ccl_rethrow (); } ccl_end_try
255 # define ccl_end_try \
263 # define ccl_trycatch(_extype_,_stmt_) \
264 ccl_try (_extype_) _stmt_ ccl_catch ccl_end_try
271 # define ccl_no_catch \
273 ccl_exception_pop (); \
285 # define ccl_throw(_extype,_msg) \
286 ccl_throw__ (&CCL_EXCEPTION_NAME (_extype), _msg, __FILE__, __LINE__)
292 # define ccl_throw_no_msg(_extype) ccl_throw (_extype, # _extype)
300 # define ccl_rethrow() ccl_rethrow__ (__FILE__, __LINE__)
306 # define ccl_exception_is_raised(_e_) \
307 ccl_exception_is_raised__ (&CCL_EXCEPTION_NAME (_e_))
322 const char *file,
int line);
325 ccl_rethrow__ (
const char *file,
int line);
331 ccl_exception_pop (
void);
337 # define ccl_exception_local_variable(del, pvar) \
338 ccl_exception_local_variable__ ((ccl_delete_proc *)(del), (pvar))
344 ccl_exception_cleanup_local_variables (
int usedel);
Frequently used prototypes of generic functions.
const char * ccl_exception_current_message
Message of the last raised exception. If no exception has been raised the content of this variable is...
struct ccl_exception_st ccl_exception
Type of exception objects.
void ccl_delete_proc(void *ptr)
Prototype of procedures used to release the resources allocated to the object pointed by ptr...
void ccl_exception_print(void)
Print a message on CCL_LOG_ERROR that locates the last exception and its associated error message...
Some useful and common macros.
#define CCL_DECLARE_EXCEPTION(exc, super)
Macro-function used to declare an exception exc.
struct ccl_exception_type_st ccl_exception_type
Type encoding the kind of an exception.