/********************************************************************* * * exception.h * * Author: Marten Cho (marten@marten.pe.kr) * First created: 2002/12/30 * Last modified: 2003/09/01 * * Copyright (C) 2002 - 2003 Marten Cho. All rights reserved. * * Revision: * ********************************************************************/ #ifndef _M_EXCEPTION_H_ #define _M_EXCEPTION_H_ #include #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ typedef struct MException { struct MException * down; jmp_buf save; } MException; extern MException * _CurrentException; #define _m_try \ do { \ int _m_value; \ MException context; \ \ context.down = _CurrentException; \ _CurrentException = &context; \ \ _m_value = setjmp(context.save); \ \ if (_m_value == 0) \ { \ do { #define _m_catch(exception) \ } while (0); \ } \ else if (_m_value == exception) \ { \ _CurrentException = context.down; \ do { #define _m_catch_any \ } while (0); \ } \ else \ { \ _CurrentException = context.down; \ do { #define _m_end_try \ } while (0); \ } \ } while (0) #define _m_throw(exception) m_exception_throw(exception) void m_exception_throw( int exception ); #ifdef __cplusplus } #endif /* __cplusplus */ #endif /* _M_EXCEPTION_H_ */