summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
Diffstat (limited to 'ext')
-rw-r--r--ext/-test-/integer/extconf.rb8
-rw-r--r--ext/-test-/integer/init.c11
-rw-r--r--ext/-test-/integer/my_integer.c16
3 files changed, 35 insertions, 0 deletions
diff --git a/ext/-test-/integer/extconf.rb b/ext/-test-/integer/extconf.rb
new file mode 100644
index 00000000000..20bfffbec28
--- /dev/null
+++ b/ext/-test-/integer/extconf.rb
@@ -0,0 +1,8 @@
+# frozen_string_literal: false
+$INCFLAGS << " -I$(topdir) -I$(top_srcdir)"
+$srcs = Dir[File.join($srcdir, "*.{#{SRC_EXT.join(%q{,})}}")]
+inits = $srcs.map {|s| File.basename(s, ".*")}
+inits.delete("init")
+inits.map! {|s|"X(#{s})"}
+$defs << "-DTEST_INIT_FUNCS(X)=\"#{inits.join(' ')}\""
+create_makefile("-test-/integer")
diff --git a/ext/-test-/integer/init.c b/ext/-test-/integer/init.c
new file mode 100644
index 00000000000..fc256ea16bf
--- /dev/null
+++ b/ext/-test-/integer/init.c
@@ -0,0 +1,11 @@
+#include "ruby.h"
+
+#define init(n) {void Init_##n(VALUE klass); Init_##n(klass);}
+
+void
+Init_integer(void)
+{
+ VALUE mBug = rb_define_module("Bug");
+ VALUE klass = rb_define_class_under(mBug, "Integer", rb_cObject);
+ TEST_INIT_FUNCS(init);
+}
diff --git a/ext/-test-/integer/my_integer.c b/ext/-test-/integer/my_integer.c
new file mode 100644
index 00000000000..d86474bd7df
--- /dev/null
+++ b/ext/-test-/integer/my_integer.c
@@ -0,0 +1,16 @@
+#include "ruby.h"
+
+static VALUE
+my_integer_s_new(VALUE klass)
+{
+ return Data_Wrap_Struct(klass, 0, 0, 0);
+}
+
+void
+Init_my_integer(VALUE klass)
+{
+ VALUE cMyInteger;
+
+ cMyInteger = rb_define_class_under(klass, "MyInteger", rb_cInteger);
+ rb_define_singleton_method(cMyInteger, "new", my_integer_s_new, 0);
+}