Sha256: e10109b3b80c7f1de97cb080b9828b171f9e4f0049213262b43419159bfe4531
Contents?: true
Size: 1.62 KB
Versions: 3
Compression:
Stored size: 1.62 KB
Contents
#include <rucy.h> using namespace Rucy; /* raise ruby's exception. */ static RUBY_DEF0(raise_ruby_exception) { throw RubyException(rb_eStandardError, "raise_ruby_exception"); } RUBY_END /* raise in eval. */ static RUBY_DEF0(raise_in_eval) { eval("raise 'raise_in_eval'"); } RUBY_END /* throw nothing. */ static RUBY_DEF0(throw_nothing) { throw; } RUBY_END /* throw std::exception. */ static RUBY_DEF0(throw_std_exception) { throw std::exception(); } RUBY_END /* throw std::runtime_error. */ static RUBY_DEF0(throw_std_runtime_error) { throw std::runtime_error("std::runtime_error"); } RUBY_END struct MyException : public std::runtime_error { MyException() : runtime_error("") {} }; /* throw custom exception class. */ static RUBY_DEF0(throw_custom_exception) { throw MyException(); } RUBY_END /* throw std::string. */ static RUBY_DEF0(throw_std_string) { throw std::string("std::string"); } RUBY_END /* throw char*. */ static RUBY_DEF0(throw_cstring) { throw "cstring"; } RUBY_END void Init_exception () { Module mRucy = define_module("Rucy"); Module mTester = mRucy.define_module("Tester"); mTester.define_method("raise_ruby_exception", raise_ruby_exception); mTester.define_method("raise_in_eval", raise_in_eval); mTester.define_method("throw_nothing", throw_nothing); mTester.define_method("throw_std_exception", throw_std_exception); mTester.define_method("throw_std_runtime_error", throw_std_runtime_error); mTester.define_method("throw_custom_exception", throw_custom_exception); mTester.define_method("throw_std_string", throw_std_string); mTester.define_method("throw_cstring", throw_cstring); }
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
rucy-0.1.6 | ext/rucy/exception.cpp |
rucy-0.1.5 | ext/rucy/exception.cpp |
rucy-0.1.4 | ext/rucy/exception.cpp |