Sha256: ee7d1bb3adb0d81054b46c069eb0d021b541f11360952e3635a1339f36b48453

Contents?: true

Size: 830 Bytes

Versions: 3

Compression:

Stored size: 830 Bytes

Contents

/*
** mrb_throw.h - mruby exception throwing handler
**
** See Copyright Notice in mruby.h
*/

#ifndef MRB_THROW_H
#define MRB_THROW_H

#ifdef MRB_ENABLE_CXX_EXCEPTION

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

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

#else

#include <setjmp.h>

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

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

#endif

struct mrb_jmpbuf {
  mrb_jmpbuf_impl impl;

#ifdef MRB_ENABLE_CXX_EXCEPTION
  static mrb_int jmpbuf_id;
  mrb_jmpbuf() : impl(jmpbuf_id++) {}
#endif
};

#endif  /* MRB_THROW_H */

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
webruby-0.9.3 modules/mruby/src/mrb_throw.h
webruby-0.9.2 modules/mruby/src/mrb_throw.h
webruby-0.9.1 modules/mruby/src/mrb_throw.h