2021-08-31 19:58:29 -04:00
|
|
|
#include "ruby.h"
|
|
|
|
|
|
|
|
// Bar
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
int dummy;
|
|
|
|
} Bar;
|
|
|
|
|
|
|
|
static rb_data_type_t Bar_type = {
|
|
|
|
"Bar",
|
2021-09-01 20:11:41 -04:00
|
|
|
{NULL, RUBY_TYPED_DEFAULT_FREE, NULL },
|
2021-08-31 19:58:29 -04:00
|
|
|
};
|
|
|
|
|
2021-09-01 20:11:41 -04:00
|
|
|
static VALUE
|
|
|
|
Bar_alloc(VALUE klass)
|
|
|
|
{
|
|
|
|
return TypedData_Wrap_Struct(klass, &Bar_type, NULL);
|
2021-08-31 19:58:29 -04:00
|
|
|
}
|
|
|
|
|
2021-11-08 02:56:28 -05:00
|
|
|
static VALUE
|
|
|
|
Bar_to_ary(VALUE _self)
|
|
|
|
{
|
2021-08-31 19:58:29 -04:00
|
|
|
VALUE ary = rb_ary_new2(2);
|
2021-09-01 20:11:41 -04:00
|
|
|
VALUE foo = rb_ary_new2(0);
|
|
|
|
rb_ary_push(ary, foo);
|
|
|
|
rb_ary_push(ary, foo);
|
|
|
|
rb_ary_push(ary, foo);
|
2021-08-31 19:58:29 -04:00
|
|
|
return ary;
|
|
|
|
}
|
|
|
|
|
2021-11-08 02:56:28 -05:00
|
|
|
void
|
|
|
|
Init_to_ary_concat(void)
|
|
|
|
{
|
2021-08-31 19:58:29 -04:00
|
|
|
VALUE mBug = rb_define_module("Bug");
|
|
|
|
VALUE bar = rb_define_class_under(mBug, "Bar", rb_cObject);
|
|
|
|
rb_define_alloc_func(bar, Bar_alloc);
|
|
|
|
rb_define_method(bar, "to_ary", Bar_to_ary, 0);
|
|
|
|
}
|