Sha256: 5872f1ebc6453c14e2902d4b3698d6a99da53fdbc2fc2615a82020a4af43e829

Contents?: true

Size: 1.2 KB

Versions: 8

Compression:

Stored size: 1.2 KB

Contents

/**
** @file mruby/throw.h - mruby exception throwing handler
**
** See Copyright Notice in mruby.h
*/

#ifndef MRB_THROW_H
#define MRB_THROW_H

#if defined(MRB_ENABLE_CXX_ABI)
# if !defined(__cplusplus)
#  error Trying to use C++ exception handling in C code
# endif
#endif

#if defined(MRB_ENABLE_CXX_EXCEPTION) && defined(__cplusplus)

#define MRB_TRY(buf) try {
#define MRB_CATCH(buf) } catch(mrb_jmpbuf_impl e) { if (e != (buf)->impl) { throw e; }
#define MRB_END_EXC(buf)  }

#define MRB_THROW(buf) throw((buf)->impl)
typedef mrb_int mrb_jmpbuf_impl;

#else

#include <setjmp.h>

#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
#define MRB_SETJMP _setjmp
#define MRB_LONGJMP _longjmp
#else
#define MRB_SETJMP setjmp
#define MRB_LONGJMP longjmp
#endif

#define MRB_TRY(buf) if (MRB_SETJMP((buf)->impl) == 0) {
#define MRB_CATCH(buf) } else {
#define MRB_END_EXC(buf) }

#define MRB_THROW(buf) MRB_LONGJMP((buf)->impl, 1);
#define mrb_jmpbuf_impl jmp_buf

#endif

struct mrb_jmpbuf {
  mrb_jmpbuf_impl impl;

#if defined(MRB_ENABLE_CXX_EXCEPTION) && defined(__cplusplus)
  static mrb_int jmpbuf_id;
  mrb_jmpbuf() : impl(jmpbuf_id++) {}
#endif
};

#endif  /* MRB_THROW_H */

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
script_core-0.2.7 ext/enterprise_script_service/mruby/include/mruby/throw.h
script_core-0.2.6 ext/enterprise_script_service/mruby/include/mruby/throw.h
script_core-0.2.5 ext/enterprise_script_service/mruby/include/mruby/throw.h
script_core-0.2.4 ext/enterprise_script_service/mruby/include/mruby/throw.h
script_core-0.2.3 ext/enterprise_script_service/mruby/include/mruby/throw.h
script_core-0.2.2 ext/enterprise_script_service/mruby/include/mruby/throw.h
script_core-0.2.1 ext/enterprise_script_service/mruby/include/mruby/throw.h
script_core-0.2.0 ext/enterprise_script_service/mruby/include/mruby/throw.h