2013-10-17 05:10:35 +04:00
|
|
|
#include <ruby.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
int rb_bug_reporter_add(void (*func)(FILE *, void *), void *data);
|
|
|
|
|
|
|
|
static void
|
|
|
|
sample_bug_reporter(FILE *out, void *ptr)
|
|
|
|
{
|
2013-10-17 16:49:16 +04:00
|
|
|
int n = (int)(uintptr_t)ptr;
|
2013-10-17 05:10:35 +04:00
|
|
|
fprintf(out, "Sample bug reporter: %d\n", n);
|
|
|
|
}
|
|
|
|
|
|
|
|
static VALUE
|
|
|
|
register_sample_bug_reporter(VALUE self, VALUE obj)
|
|
|
|
{
|
2013-10-17 16:49:16 +04:00
|
|
|
rb_bug_reporter_add(sample_bug_reporter, (void *)(uintptr_t)NUM2INT(obj));
|
2013-10-17 05:10:35 +04:00
|
|
|
return Qnil;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Init_bug_reporter(void)
|
|
|
|
{
|
|
|
|
rb_define_global_function("register_sample_bug_reporter", register_sample_bug_reporter, 1);
|
|
|
|
}
|