Sha256: e0de2776c42d5786cd8895a9aff8271d49d5626bb26af50e59ffb501b9de76db
Contents?: true
Size: 1.8 KB
Versions: 20
Compression:
Stored size: 1.8 KB
Contents
#include "rucy.h" using namespace Rucy; /* raise ruby's exception. */ static VALUE raise_ruby_exception(VALUE self) { throw RubyException(rb_eStandardError, "raise_ruby_exception"); } /* raise in eval. */ static VALUE raise_in_eval(VALUE self) { eval("raise 'raise_in_eval'"); } /* throw nothing. */ static VALUE throw_nothing(VALUE self) { throw; } /* throw std::exception. */ static VALUE throw_std_exception(VALUE self) { throw std::exception(); } /* throw std::runtime_error. */ static VALUE throw_std_runtime_error(VALUE self) { throw std::runtime_error("std::runtime_error"); } struct MyException : public std::runtime_error { MyException() : runtime_error("") {} }; /* throw custom exception class. */ static VALUE throw_custom_exception(VALUE self) { throw MyException(); } /* throw std::string. */ static VALUE throw_std_string(VALUE self) { throw std::string("std::string"); } /* throw char*. */ static VALUE throw_cstring(VALUE self) { throw "cstring"; } void Init_exception () { Module mRucy = rb_define_module("Rucy"); Module mTester = rb_define_module_under(mRucy, "Tester"); rb_define_method(mTester, "raise_ruby_exception", RUBY_METHOD_FUNC(raise_ruby_exception), 0); rb_define_method(mTester, "raise_in_eval", RUBY_METHOD_FUNC(raise_in_eval), 0); rb_define_method(mTester, "throw_nothing", RUBY_METHOD_FUNC(throw_nothing), 0); rb_define_method(mTester, "throw_std_exception", RUBY_METHOD_FUNC(throw_std_exception), 0); rb_define_method(mTester, "throw_std_runtime_error", RUBY_METHOD_FUNC(throw_std_runtime_error), 0); rb_define_method(mTester, "throw_custom_exception", RUBY_METHOD_FUNC(throw_custom_exception), 0); rb_define_method(mTester, "throw_std_string", RUBY_METHOD_FUNC(throw_std_string), 0); rb_define_method(mTester, "throw_cstring", RUBY_METHOD_FUNC(throw_cstring), 0); }
Version data entries
20 entries across 20 versions & 1 rubygems