Sha256: 00e5d541df9a3205e4beacd83d9beb3428b9bdec6770940a70f2d2cd29f0461b
Contents?: true
Size: 1.51 KB
Versions: 2
Compression:
Stored size: 1.51 KB
Contents
#include "ruby.h" static VALUE rb_mInterception; extern struct FRAME { VALUE self; int argc; ID last_func; ID orig_func; VALUE last_class; struct FRAME *prev; struct FRAME *tmp; struct RNode *node; int iter; int flags; unsigned long uniq; } *ruby_frame; #ifdef RUBY_19 void interception_hook(rb_event_flag_t evflag, VALUE data, VALUE self, ID mid, VALUE klass) { VALUE binding = rb_funcall(self, rb_intern("binding"), 0, NULL); rb_funcall(rb_mInterception, rb_intern("rescue"), 2, rb_errinfo(), binding); } VALUE interception_start(VALUE self) { rb_add_event_hook(interception_hook, RUBY_EVENT_RAISE, rb_mInterception); } #else #include "node.h" void interception_hook(rb_event_t event, NODE *node, VALUE self, ID mid, VALUE klass) { VALUE bself = ruby_frame->prev->self; if (node == ruby_frame->node) { bself = ruby_frame->prev->prev->self; } VALUE binding = rb_funcall(bself, rb_intern("binding"), 0, NULL); rb_funcall(rb_mInterception, rb_intern("rescue"), 2, ruby_errinfo, binding); } VALUE interception_start(VALUE self) { rb_add_event_hook(interception_hook, RUBY_EVENT_RAISE); } #endif VALUE interception_stop(VALUE self) { rb_remove_event_hook(interception_hook); return Qnil; } void Init_interception() { rb_mInterception = rb_define_module("Interception"); rb_define_singleton_method(rb_mInterception, "start", interception_start, 0); rb_define_singleton_method(rb_mInterception, "stop", interception_stop, 0); }
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
interception-0.1 | ext/interception.c |
interception-0.1.pre.2 | ext/interception.c |