123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420 |
- #ifndef __PJ_EXCEPTION_H__
- #define __PJ_EXCEPTION_H__
- #include <pj/types.h>
- #include <pj/compat/setjmp.h>
- #include <pj/log.h>
- PJ_BEGIN_DECL
- PJ_DECL(pj_status_t) pj_exception_id_alloc(const char *name,
- pj_exception_id_t *id);
- PJ_DECL(pj_status_t) pj_exception_id_free(pj_exception_id_t id);
- PJ_DECL(const char*) pj_exception_id_name(pj_exception_id_t id);
- #if defined(PJ_EXCEPTION_USE_WIN32_SEH) && PJ_EXCEPTION_USE_WIN32_SEH != 0
- #define WIN32_LEAN_AND_MEAN
- #include <windows.h>
- PJ_IDECL_NO_RETURN(void)
- pj_throw_exception_(pj_exception_id_t id) PJ_ATTR_NORETURN
- {
- RaiseException(id,1,0,NULL);
- }
- #define PJ_USE_EXCEPTION
- #define PJ_TRY __try
- #define PJ_CATCH(id) __except(GetExceptionCode()==id ? \
- EXCEPTION_EXECUTE_HANDLER : \
- EXCEPTION_CONTINUE_SEARCH)
- #define PJ_CATCH_ANY __except(EXCEPTION_EXECUTE_HANDLER)
- #define PJ_END
- #define PJ_THROW(id) pj_throw_exception_(id)
- #define PJ_GET_EXCEPTION() GetExceptionCode()
- #elif defined(PJ_SYMBIAN) && PJ_SYMBIAN!=0
- #ifdef __cplusplus
- class TPjException
- {
- public:
- int code_;
- };
- #define PJ_USE_EXCEPTION
- #define PJ_TRY try
- #define PJ_CATCH_ANY catch (const TPjException & pj_excp_)
- #define PJ_END
- #define PJ_THROW(x_id) do { TPjException e; e.code_=x_id; throw e;} \
- while (0)
- #define PJ_GET_EXCEPTION() pj_excp_.code_
- #else
- #define PJ_USE_EXCEPTION
- #define PJ_TRY
- #define PJ_CATCH_ANY if (0)
- #define PJ_END
- #define PJ_THROW(x_id) do { PJ_LOG(1,("PJ_THROW"," error code = %d",x_id)); } while (0)
- #define PJ_GET_EXCEPTION() 0
- #endif
- #else
- struct pj_exception_state_t
- {
- pj_jmp_buf state;
- struct pj_exception_state_t *prev;
- };
- PJ_DECL_NO_RETURN(void)
- pj_throw_exception_(pj_exception_id_t id) PJ_ATTR_NORETURN;
- PJ_DECL(void) pj_push_exception_handler_(struct pj_exception_state_t *rec);
- PJ_DECL(void) pj_pop_exception_handler_(struct pj_exception_state_t *rec);
- #define PJ_USE_EXCEPTION struct pj_exception_state_t pj_x_except__; int pj_x_code__
- #define PJ_TRY if (1) { \
- pj_push_exception_handler_(&pj_x_except__); \
- pj_x_code__ = pj_setjmp(pj_x_except__.state); \
- if (pj_x_code__ == 0)
- #define PJ_CATCH(id) else if (pj_x_code__ == (id))
- #define PJ_CATCH_ANY else
- #define PJ_END pj_pop_exception_handler_(&pj_x_except__); \
- } else {}
- #define PJ_THROW(exception_id) pj_throw_exception_(exception_id)
- #define PJ_GET_EXCEPTION() (pj_x_code__)
- #endif
- PJ_END_DECL
- #endif
|