summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
Diffstat (limited to 'ext')
-rw-r--r--ext/-test-/array/resize/resize.c6
-rw-r--r--ext/-test-/bignum/big2str.c12
-rw-r--r--ext/-test-/bignum/div.c8
-rw-r--r--ext/-test-/bignum/intpack.c40
-rw-r--r--ext/-test-/bignum/mul.c28
-rw-r--r--ext/-test-/bignum/str2big.c16
-rw-r--r--ext/-test-/fatal/rb_fatal.c3
-rw-r--r--ext/-test-/gvl/call_without_gvl/call_without_gvl.c10
-rw-r--r--ext/-test-/integer/core_ext.c16
-rw-r--r--ext/-test-/rational/rat.c15
-rw-r--r--ext/-test-/win32/console/attribute.c8
11 files changed, 85 insertions, 77 deletions
diff --git a/ext/-test-/array/resize/resize.c b/ext/-test-/array/resize/resize.c
index 08bcee3e7a2..cfe910ebed8 100644
--- a/ext/-test-/array/resize/resize.c
+++ b/ext/-test-/array/resize/resize.c
@@ -1,7 +1,7 @@
#include "ruby/ruby.h"
static VALUE
-ary_resize(VALUE ary, VALUE len)
+ary_resize(VALUE klass, VALUE ary, VALUE len)
{
rb_ary_resize(ary, NUM2LONG(len));
return ary;
@@ -10,5 +10,7 @@ ary_resize(VALUE ary, VALUE len)
void
Init_resize(void)
{
- rb_define_method(rb_cArray, "__resize__", ary_resize, 1);
+ VALUE mBug = rb_define_module("Bug");
+ VALUE klass = rb_define_class_under(mBug, "Array", rb_cObject);
+ rb_define_singleton_method(klass, "__resize__", ary_resize, 2);
}
diff --git a/ext/-test-/bignum/big2str.c b/ext/-test-/bignum/big2str.c
index bc5a933f825..255e8ad7293 100644
--- a/ext/-test-/bignum/big2str.c
+++ b/ext/-test-/bignum/big2str.c
@@ -12,7 +12,7 @@ big(VALUE x)
}
static VALUE
-big2str_generic(VALUE x, VALUE vbase)
+big2str_generic(VALUE klass, VALUE x, VALUE vbase)
{
int base = NUM2INT(vbase);
if (base < 2 || 36 < base)
@@ -23,7 +23,7 @@ big2str_generic(VALUE x, VALUE vbase)
#define POW2_P(x) (((x)&((x)-1))==0)
static VALUE
-big2str_poweroftwo(VALUE x, VALUE vbase)
+big2str_poweroftwo(VALUE klass, VALUE x, VALUE vbase)
{
int base = NUM2INT(vbase);
if (base < 2 || 36 < base || !POW2_P(base))
@@ -33,7 +33,7 @@ big2str_poweroftwo(VALUE x, VALUE vbase)
#if defined(HAVE_LIBGMP) && defined(HAVE_GMP_H)
static VALUE
-big2str_gmp(VALUE x, VALUE vbase)
+big2str_gmp(VALUE klass, VALUE x, VALUE vbase)
{
int base = NUM2INT(vbase);
if (base < 2 || 36 < base)
@@ -47,7 +47,7 @@ big2str_gmp(VALUE x, VALUE vbase)
void
Init_big2str(VALUE klass)
{
- rb_define_method(rb_cInteger, "big2str_generic", big2str_generic, 1);
- rb_define_method(rb_cInteger, "big2str_poweroftwo", big2str_poweroftwo, 1);
- rb_define_method(rb_cInteger, "big2str_gmp", big2str_gmp, 1);
+ rb_define_singleton_method(klass, "big2str_generic", big2str_generic, 2);
+ rb_define_singleton_method(klass, "big2str_poweroftwo", big2str_poweroftwo, 2);
+ rb_define_singleton_method(klass, "big2str_gmp", big2str_gmp, 2);
}
diff --git a/ext/-test-/bignum/div.c b/ext/-test-/bignum/div.c
index 2be0d2d62ad..85ee0677fa1 100644
--- a/ext/-test-/bignum/div.c
+++ b/ext/-test-/bignum/div.c
@@ -12,14 +12,14 @@ big(VALUE x)
}
static VALUE
-divrem_normal(VALUE x, VALUE y)
+divrem_normal(VALUE klass, VALUE x, VALUE y)
{
return rb_big_norm(rb_big_divrem_normal(big(x), big(y)));
}
#if defined(HAVE_LIBGMP) && defined(HAVE_GMP_H)
static VALUE
-divrem_gmp(VALUE x, VALUE y)
+divrem_gmp(VALUE klass, VALUE x, VALUE y)
{
return rb_big_norm(rb_big_divrem_gmp(big(x), big(y)));
}
@@ -30,6 +30,6 @@ divrem_gmp(VALUE x, VALUE y)
void
Init_div(VALUE klass)
{
- rb_define_method(rb_cInteger, "big_divrem_normal", divrem_normal, 1);
- rb_define_method(rb_cInteger, "big_divrem_gmp", divrem_gmp, 1);
+ rb_define_singleton_method(klass, "big_divrem_normal", divrem_normal, 2);
+ rb_define_singleton_method(klass, "big_divrem_gmp", divrem_gmp, 2);
}
diff --git a/ext/-test-/bignum/intpack.c b/ext/-test-/bignum/intpack.c
index 698362f96f5..d5591505e50 100644
--- a/ext/-test-/bignum/intpack.c
+++ b/ext/-test-/bignum/intpack.c
@@ -1,7 +1,7 @@
#include "internal/bignum.h"
static VALUE
-rb_integer_pack_raw_m(VALUE val, VALUE buf, VALUE numwords_arg, VALUE wordsize_arg, VALUE nails, VALUE flags)
+rb_integer_pack_raw_m(VALUE klass, VALUE val, VALUE buf, VALUE numwords_arg, VALUE wordsize_arg, VALUE nails, VALUE flags)
{
int sign;
size_t numwords = 0;
@@ -17,7 +17,7 @@ rb_integer_pack_raw_m(VALUE val, VALUE buf, VALUE numwords_arg, VALUE wordsize_a
}
static VALUE
-rb_integer_pack_m(VALUE val, VALUE numwords_arg, VALUE wordsize_arg, VALUE nails, VALUE flags)
+rb_integer_pack_m(VALUE klass, VALUE val, VALUE numwords_arg, VALUE wordsize_arg, VALUE nails, VALUE flags)
{
int sign;
size_t numwords = NUM2SIZET(numwords_arg);
@@ -45,7 +45,7 @@ rb_integer_unpack_m(VALUE klass, VALUE buf, VALUE numwords, VALUE wordsize, VALU
}
static VALUE
-rb_integer_test_numbits_2comp_without_sign(VALUE val)
+rb_integer_test_numbits_2comp_without_sign(VALUE klass, VALUE val)
{
size_t size;
int neg = FIXNUM_P(val) ? FIX2LONG(val) < 0 : BIGNUM_NEGATIVE_P(val);
@@ -54,7 +54,7 @@ rb_integer_test_numbits_2comp_without_sign(VALUE val)
}
static VALUE
-rb_integer_test_numbytes_2comp_with_sign(VALUE val)
+rb_integer_test_numbytes_2comp_with_sign(VALUE klass, VALUE val)
{
int neg = FIXNUM_P(val) ? FIX2LONG(val) < 0 : BIGNUM_NEGATIVE_P(val);
int nlz_bits;
@@ -67,21 +67,21 @@ rb_integer_test_numbytes_2comp_with_sign(VALUE val)
void
Init_intpack(VALUE klass)
{
- rb_define_method(rb_cInteger, "test_pack_raw", rb_integer_pack_raw_m, 5);
- rb_define_method(rb_cInteger, "test_pack", rb_integer_pack_m, 4);
- rb_define_singleton_method(rb_cInteger, "test_unpack", rb_integer_unpack_m, 5);
- rb_define_const(rb_cInteger, "INTEGER_PACK_MSWORD_FIRST", INT2NUM(INTEGER_PACK_MSWORD_FIRST));
- rb_define_const(rb_cInteger, "INTEGER_PACK_LSWORD_FIRST", INT2NUM(INTEGER_PACK_LSWORD_FIRST));
- rb_define_const(rb_cInteger, "INTEGER_PACK_MSBYTE_FIRST", INT2NUM(INTEGER_PACK_MSBYTE_FIRST));
- rb_define_const(rb_cInteger, "INTEGER_PACK_LSBYTE_FIRST", INT2NUM(INTEGER_PACK_LSBYTE_FIRST));
- rb_define_const(rb_cInteger, "INTEGER_PACK_NATIVE_BYTE_ORDER", INT2NUM(INTEGER_PACK_NATIVE_BYTE_ORDER));
- rb_define_const(rb_cInteger, "INTEGER_PACK_2COMP", INT2NUM(INTEGER_PACK_2COMP));
- rb_define_const(rb_cInteger, "INTEGER_PACK_LITTLE_ENDIAN", INT2NUM(INTEGER_PACK_LITTLE_ENDIAN));
- rb_define_const(rb_cInteger, "INTEGER_PACK_BIG_ENDIAN", INT2NUM(INTEGER_PACK_BIG_ENDIAN));
- rb_define_const(rb_cInteger, "INTEGER_PACK_FORCE_BIGNUM", INT2NUM(INTEGER_PACK_FORCE_BIGNUM));
- rb_define_const(rb_cInteger, "INTEGER_PACK_NEGATIVE", INT2NUM(INTEGER_PACK_NEGATIVE));
- rb_define_const(rb_cInteger, "INTEGER_PACK_FORCE_GENERIC_IMPLEMENTATION", INT2NUM(INTEGER_PACK_FORCE_GENERIC_IMPLEMENTATION));
+ rb_define_singleton_method(klass, "test_pack_raw", rb_integer_pack_raw_m, 6);
+ rb_define_singleton_method(klass, "test_pack", rb_integer_pack_m, 5);
+ rb_define_singleton_method(klass, "test_unpack", rb_integer_unpack_m, 5);
+ rb_define_const(klass, "INTEGER_PACK_MSWORD_FIRST", INT2NUM(INTEGER_PACK_MSWORD_FIRST));
+ rb_define_const(klass, "INTEGER_PACK_LSWORD_FIRST", INT2NUM(INTEGER_PACK_LSWORD_FIRST));
+ rb_define_const(klass, "INTEGER_PACK_MSBYTE_FIRST", INT2NUM(INTEGER_PACK_MSBYTE_FIRST));
+ rb_define_const(klass, "INTEGER_PACK_LSBYTE_FIRST", INT2NUM(INTEGER_PACK_LSBYTE_FIRST));
+ rb_define_const(klass, "INTEGER_PACK_NATIVE_BYTE_ORDER", INT2NUM(INTEGER_PACK_NATIVE_BYTE_ORDER));
+ rb_define_const(klass, "INTEGER_PACK_2COMP", INT2NUM(INTEGER_PACK_2COMP));
+ rb_define_const(klass, "INTEGER_PACK_LITTLE_ENDIAN", INT2NUM(INTEGER_PACK_LITTLE_ENDIAN));
+ rb_define_const(klass, "INTEGER_PACK_BIG_ENDIAN", INT2NUM(INTEGER_PACK_BIG_ENDIAN));
+ rb_define_const(klass, "INTEGER_PACK_FORCE_BIGNUM", INT2NUM(INTEGER_PACK_FORCE_BIGNUM));
+ rb_define_const(klass, "INTEGER_PACK_NEGATIVE", INT2NUM(INTEGER_PACK_NEGATIVE));
+ rb_define_const(klass, "INTEGER_PACK_FORCE_GENERIC_IMPLEMENTATION", INT2NUM(INTEGER_PACK_FORCE_GENERIC_IMPLEMENTATION));
- rb_define_method(rb_cInteger, "test_numbits_2comp_without_sign", rb_integer_test_numbits_2comp_without_sign, 0);
- rb_define_method(rb_cInteger, "test_numbytes_2comp_with_sign", rb_integer_test_numbytes_2comp_with_sign, 0);
+ rb_define_singleton_method(klass, "test_numbits_2comp_without_sign", rb_integer_test_numbits_2comp_without_sign, 1);
+ rb_define_singleton_method(klass, "test_numbytes_2comp_with_sign", rb_integer_test_numbytes_2comp_with_sign, 1);
}
diff --git a/ext/-test-/bignum/mul.c b/ext/-test-/bignum/mul.c
index 1b6eb911bde..05ba103c44b 100644
--- a/ext/-test-/bignum/mul.c
+++ b/ext/-test-/bignum/mul.c
@@ -12,38 +12,38 @@ big(VALUE x)
}
static VALUE
-mul_normal(VALUE x, VALUE y)
+mul_normal(VALUE klass, VALUE x, VALUE y)
{
return rb_big_norm(rb_big_mul_normal(big(x), big(y)));
}
static VALUE
-sq_fast(VALUE x)
+sq_fast(VALUE klass, VALUE x)
{
return rb_big_norm(rb_big_sq_fast(big(x)));
}
static VALUE
-mul_balance(VALUE x, VALUE y)
+mul_balance(VALUE klass, VALUE x, VALUE y)
{
return rb_big_norm(rb_big_mul_balance(big(x), big(y)));
}
static VALUE
-mul_karatsuba(VALUE x, VALUE y)
+mul_karatsuba(VALUE klass, VALUE x, VALUE y)
{
return rb_big_norm(rb_big_mul_karatsuba(big(x), big(y)));
}
static VALUE
-mul_toom3(VALUE x, VALUE y)
+mul_toom3(VALUE klass, VALUE x, VALUE y)
{
return rb_big_norm(rb_big_mul_toom3(big(x), big(y)));
}
#if defined(HAVE_LIBGMP) && defined(HAVE_GMP_H)
static VALUE
-mul_gmp(VALUE x, VALUE y)
+mul_gmp(VALUE klass, VALUE x, VALUE y)
{
return rb_big_norm(rb_big_mul_gmp(big(x), big(y)));
}
@@ -54,12 +54,12 @@ mul_gmp(VALUE x, VALUE y)
void
Init_mul(VALUE klass)
{
- rb_define_const(rb_cInteger, "SIZEOF_BDIGIT", INT2NUM(SIZEOF_BDIGIT));
- rb_define_const(rb_cInteger, "BITSPERDIG", INT2NUM(SIZEOF_BDIGIT * CHAR_BIT));
- rb_define_method(rb_cInteger, "big_mul_normal", mul_normal, 1);
- rb_define_method(rb_cInteger, "big_sq_fast", sq_fast, 0);
- rb_define_method(rb_cInteger, "big_mul_balance", mul_balance, 1);
- rb_define_method(rb_cInteger, "big_mul_karatsuba", mul_karatsuba, 1);
- rb_define_method(rb_cInteger, "big_mul_toom3", mul_toom3, 1);
- rb_define_method(rb_cInteger, "big_mul_gmp", mul_gmp, 1);
+ rb_define_const(klass, "SIZEOF_BDIGIT", INT2NUM(SIZEOF_BDIGIT));
+ rb_define_const(klass, "BITSPERDIG", INT2NUM(SIZEOF_BDIGIT * CHAR_BIT));
+ rb_define_singleton_method(klass, "big_mul_normal", mul_normal, 2);
+ rb_define_singleton_method(klass, "big_sq_fast", sq_fast, 1);
+ rb_define_singleton_method(klass, "big_mul_balance", mul_balance, 2);
+ rb_define_singleton_method(klass, "big_mul_karatsuba", mul_karatsuba, 2);
+ rb_define_singleton_method(klass, "big_mul_toom3", mul_toom3, 2);
+ rb_define_singleton_method(klass, "big_mul_gmp", mul_gmp, 2);
}
diff --git a/ext/-test-/bignum/str2big.c b/ext/-test-/bignum/str2big.c
index 7dd2da9a073..337cf8fb6df 100644
--- a/ext/-test-/bignum/str2big.c
+++ b/ext/-test-/bignum/str2big.c
@@ -1,26 +1,26 @@
#include "internal/bignum.h"
static VALUE
-str2big_poweroftwo(VALUE str, VALUE vbase, VALUE badcheck)
+str2big_poweroftwo(VALUE klass, VALUE str, VALUE vbase, VALUE badcheck)
{
return rb_str2big_poweroftwo(str, NUM2INT(vbase), RTEST(badcheck));
}
static VALUE
-str2big_normal(VALUE str, VALUE vbase, VALUE badcheck)
+str2big_normal(VALUE klass, VALUE str, VALUE vbase, VALUE badcheck)
{
return rb_str2big_normal(str, NUM2INT(vbase), RTEST(badcheck));
}
static VALUE
-str2big_karatsuba(VALUE str, VALUE vbase, VALUE badcheck)
+str2big_karatsuba(VALUE klass, VALUE str, VALUE vbase, VALUE badcheck)
{
return rb_str2big_karatsuba(str, NUM2INT(vbase), RTEST(badcheck));
}
#if defined(HAVE_LIBGMP) && defined(HAVE_GMP_H)
static VALUE
-str2big_gmp(VALUE str, VALUE vbase, VALUE badcheck)
+str2big_gmp(VALUE klass, VALUE str, VALUE vbase, VALUE badcheck)
{
return rb_str2big_gmp(str, NUM2INT(vbase), RTEST(badcheck));
}
@@ -31,8 +31,8 @@ str2big_gmp(VALUE str, VALUE vbase, VALUE badcheck)
void
Init_str2big(VALUE klass)
{
- rb_define_method(rb_cString, "str2big_poweroftwo", str2big_poweroftwo, 2);
- rb_define_method(rb_cString, "str2big_normal", str2big_normal, 2);
- rb_define_method(rb_cString, "str2big_karatsuba", str2big_karatsuba, 2);
- rb_define_method(rb_cString, "str2big_gmp", str2big_gmp, 2);
+ rb_define_singleton_method(klass, "str2big_poweroftwo", str2big_poweroftwo, 3);
+ rb_define_singleton_method(klass, "str2big_normal", str2big_normal, 3);
+ rb_define_singleton_method(klass, "str2big_karatsuba", str2big_karatsuba, 3);
+ rb_define_singleton_method(klass, "str2big_gmp", str2big_gmp, 3);
}
diff --git a/ext/-test-/fatal/rb_fatal.c b/ext/-test-/fatal/rb_fatal.c
index 71aef4658af..eedbc51f8b8 100644
--- a/ext/-test-/fatal/rb_fatal.c
+++ b/ext/-test-/fatal/rb_fatal.c
@@ -15,5 +15,6 @@ ruby_fatal(VALUE obj, VALUE msg)
void
Init_rb_fatal(void)
{
- rb_define_method(rb_mKernel, "rb_fatal", ruby_fatal, 1);
+ VALUE mBug = rb_define_module("Bug");
+ rb_define_singleton_method(mBug, "rb_fatal", ruby_fatal, 1);
}
diff --git a/ext/-test-/gvl/call_without_gvl/call_without_gvl.c b/ext/-test-/gvl/call_without_gvl/call_without_gvl.c
index d77c2f323e6..233635421b8 100644
--- a/ext/-test-/gvl/call_without_gvl/call_without_gvl.c
+++ b/ext/-test-/gvl/call_without_gvl/call_without_gvl.c
@@ -24,7 +24,7 @@ thread_runnable_sleep(VALUE thread, VALUE timeout)
rb_thread_call_without_gvl(native_sleep_callback, &timeval, RUBY_UBF_IO, NULL);
- return thread;
+ return Qnil;
}
struct loop_ctl {
@@ -65,12 +65,14 @@ thread_ubf_async_safe(VALUE thread, VALUE notify_fd)
ctl.stop = 0;
rb_nogvl(do_loop, &ctl, stop_set, &ctl, RB_NOGVL_UBF_ASYNC_SAFE);
- return thread;
+ return Qnil;
}
void
Init_call_without_gvl(void)
{
- rb_define_method(rb_cThread, "__runnable_sleep__", thread_runnable_sleep, 1);
- rb_define_method(rb_cThread, "__ubf_async_safe__", thread_ubf_async_safe, 1);
+ VALUE mBug = rb_define_module("Bug");
+ VALUE klass = rb_define_module_under(mBug, "Thread");
+ rb_define_singleton_method(klass, "runnable_sleep", thread_runnable_sleep, 1);
+ rb_define_singleton_method(klass, "ubf_async_safe", thread_ubf_async_safe, 1);
}
diff --git a/ext/-test-/integer/core_ext.c b/ext/-test-/integer/core_ext.c
index 2062fa3afa0..e364aa4b40a 100644
--- a/ext/-test-/integer/core_ext.c
+++ b/ext/-test-/integer/core_ext.c
@@ -1,19 +1,19 @@
#include "internal/numeric.h"
static VALUE
-int_bignum_p(VALUE self)
+int_bignum_p(VALUE klass, VALUE self)
{
return RB_TYPE_P(self, T_BIGNUM) ? Qtrue : Qfalse;
}
static VALUE
-int_fixnum_p(VALUE self)
+int_fixnum_p(VALUE klass, VALUE self)
{
return FIXNUM_P(self) ? Qtrue : Qfalse;
}
static VALUE
-rb_int_to_bignum(VALUE x)
+rb_int_to_bignum(VALUE klass, VALUE x)
{
if (FIXNUM_P(x))
x = rb_int2big(FIX2LONG(x));
@@ -21,7 +21,7 @@ rb_int_to_bignum(VALUE x)
}
static VALUE
-positive_pow(VALUE x, VALUE y)
+positive_pow(VALUE klass, VALUE x, VALUE y)
{
return rb_int_positive_pow(NUM2LONG(x), NUM2ULONG(y));
}
@@ -29,8 +29,8 @@ positive_pow(VALUE x, VALUE y)
void
Init_core_ext(VALUE klass)
{
- rb_define_method(rb_cInteger, "bignum?", int_bignum_p, 0);
- rb_define_method(rb_cInteger, "fixnum?", int_fixnum_p, 0);
- rb_define_method(rb_cInteger, "to_bignum", rb_int_to_bignum, 0);
- rb_define_method(rb_cInteger, "positive_pow", positive_pow, 1);
+ rb_define_singleton_method(klass, "bignum?", int_bignum_p, 1);
+ rb_define_singleton_method(klass, "fixnum?", int_fixnum_p, 1);
+ rb_define_singleton_method(klass, "to_bignum", rb_int_to_bignum, 1);
+ rb_define_singleton_method(klass, "positive_pow", positive_pow, 2);
}
diff --git a/ext/-test-/rational/rat.c b/ext/-test-/rational/rat.c
index b1ffbda1448..6489fe3d7ca 100644
--- a/ext/-test-/rational/rat.c
+++ b/ext/-test-/rational/rat.c
@@ -14,14 +14,14 @@ big(VALUE x)
#endif
static VALUE
-gcd_normal(VALUE x, VALUE y)
+gcd_normal(VALUE klass, VALUE x, VALUE y)
{
return rb_big_norm(rb_gcd_normal(rb_to_int(x), rb_to_int(y)));
}
#if defined(HAVE_LIBGMP) && defined(HAVE_GMP_H)
static VALUE
-gcd_gmp(VALUE x, VALUE y)
+gcd_gmp(VALUE klass, VALUE x, VALUE y)
{
return rb_big_norm(rb_gcd_gmp(big(x), big(y)));
}
@@ -36,10 +36,13 @@ s_rational_raw(VALUE klass, VALUE x, VALUE y)
}
void
-Init_rational(VALUE klass)
+Init_rational(void)
{
- rb_define_method(rb_cInteger, "gcd_normal", gcd_normal, 1);
- rb_define_method(rb_cInteger, "gcd_gmp", gcd_gmp, 1);
+ VALUE mBug = rb_define_module("Bug");
+ VALUE klass = rb_define_module_under(mBug, "Rational");
- rb_define_singleton_method(rb_cRational, "raw", s_rational_raw, 2);
+ rb_define_singleton_method(klass, "gcd_normal", gcd_normal, 2);
+ rb_define_singleton_method(klass, "gcd_gmp", gcd_gmp, 2);
+
+ rb_define_singleton_method(klass, "raw", s_rational_raw, 2);
}
diff --git a/ext/-test-/win32/console/attribute.c b/ext/-test-/win32/console/attribute.c
index a5f80fcaffc..e3e80a199f0 100644
--- a/ext/-test-/win32/console/attribute.c
+++ b/ext/-test-/win32/console/attribute.c
@@ -13,7 +13,7 @@ io_handle(VALUE io)
}
static VALUE
-console_info(VALUE io)
+console_info(VALUE klass, VALUE io)
{
HANDLE h = io_handle(io);
CONSOLE_SCREEN_BUFFER_INFO csbi;
@@ -29,7 +29,7 @@ console_info(VALUE io)
}
static VALUE
-console_set_attribute(VALUE io, VALUE attr)
+console_set_attribute(VALUE klass, VALUE io, VALUE attr)
{
HANDLE h = io_handle(io);
@@ -47,8 +47,8 @@ Init_attribute(VALUE m)
"size_x", "size_y",
"cur_x", "cur_y",
"attr", NULL);
- rb_define_method(rb_cIO, "console_info", console_info, 0);
- rb_define_method(rb_cIO, "console_attribute", console_set_attribute, 1);
+ rb_define_singleton_method(m, "console_info", console_info, 1);
+ rb_define_singleton_method(m, "console_attribute", console_set_attribute, 2);
rb_define_const(m, "FOREGROUND_MASK", INT2FIX(FOREGROUND_MASK));
rb_define_const(m, "FOREGROUND_BLUE", INT2FIX(FOREGROUND_BLUE));