home *** CD-ROM | disk | FTP | other *** search
/ PC Pro 2002 April / pcpro0402.iso / essentials / graphics / Gimp / gimp-src-20001226.exe / src / gimp / unofficial-plug-ins / mathmap / jump.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-04-21  |  2.1 KB  |  65 lines

  1. /* -*- c -*- */
  2.  
  3. /*
  4.  * jump.h
  5.  *
  6.  * MathMap
  7.  *
  8.  * Copyright (C) 1998 Mark Probst
  9.  *
  10.  * This program is free software; you can redistribute it and/or
  11.  * modify it under the terms of the GNU General Public License
  12.  * as published by the Free Software Foundation; either version 2
  13.  * of the License, or (at your option) any later version.
  14.  *
  15.  * This program is distributed in the hope that it will be useful,
  16.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  18.  * GNU General Public License for more details.
  19.  *
  20.  * You should have received a copy of the GNU General Public License
  21.  * along with this program; if not, write to the Free Software
  22.  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  23.  */
  24.  
  25.  
  26. #ifndef __JUMP_H__
  27. #define __JUMP_H__
  28.  
  29. #include <setjmp.h>
  30.  
  31. extern jmp_buf *topmostJmpBuf;
  32.  
  33. #define DO_JUMP_CODE              { \
  34.                                       jmp_buf jmpBuf, \
  35.                                           *lastTopmost = topmostJmpBuf; \
  36.                                       int jumpResult; \
  37.                                       \
  38.                                       topmostJmpBuf = &jmpBuf; \
  39.                                       jumpResult = setjmp(jmpBuf); \
  40.                                       if (jumpResult != 0) \
  41.                                           topmostJmpBuf = lastTopmost; \
  42.                                       else
  43.  
  44. #define WITH_JUMP_HANDLER             if (jumpResult != 0)
  45.  
  46. #define END_JUMP_HANDLER              else \
  47.                                           topmostJmpBuf = lastTopmost; \
  48.                                   }
  49.  
  50. #define JUMP(result)              longjmp(*topmostJmpBuf, (result))
  51. #define REJUMP                    JUMP(jumpResult)
  52.  
  53. #define JUMP_CODE_RETURN          0x01000000
  54. #define JUMP_CODE_BREAK           0x02000000
  55.  
  56. #define JUMP_CODE_MASK            0xff000000
  57. #define JUMP_INFO_MASK            0x00ffffff
  58.  
  59. #define JUMP_CODE                 (jumpResult & JUMP_CODE_MASK)
  60. #define JUMP_INFO                 (jumpResult & JUMP_INFO_MASK)
  61.  
  62. #define JUMP_HANDLE_RETURN        if (JUMP_CODE == JUMP_CODE_RETURN) REJUMP
  63.  
  64. #endif
  65.