Debian Codegraph @

ext/-test-/array/concat/to_ary_concat.c

raw
1 #include "ruby.h"
2
3 // Bar
4
5 typedef struct {
6 int dummy;
7 } Bar;
8
9 static rb_data_type_t Bar_type = {
10 "Bar",
11 {NULL, RUBY_TYPED_DEFAULT_FREE, NULL },
12 };
13
14 static VALUE
15 Bar_alloc(VALUE klass)
16 {
17 return TypedData_Wrap_Struct(klass, &Bar_type, NULL);
18 }
19
20 static VALUE
21 Bar_to_ary(VALUE _self)
22 {
23 VALUE ary = rb_ary_new2(2);
24 VALUE foo = rb_ary_new2(0);
25 rb_ary_push(ary, foo);
26 rb_ary_push(ary, foo);
27 rb_ary_push(ary, foo);
28 return ary;
29 }
30
31 void
32 Init_to_ary_concat(void)
33 {
34 VALUE mBug = rb_define_module("Bug");
35 VALUE bar = rb_define_class_under(mBug, "Bar", rb_cObject);
36 rb_define_alloc_func(bar, Bar_alloc);
37 rb_define_method(bar, "to_ary", Bar_to_ary, 0);
38 }