ruby-changes:42951
From: akr <ko1@a...>
Date: Tue, 17 May 2016 17:26:02 +0900 (JST)
Subject: [ruby-changes:42951] akr:r55025 (trunk): forgot to commit.
akr 2016-05-17 17:25:58 +0900 (Tue, 17 May 2016) New Revision: 55025 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=55025 Log: forgot to commit. Added directories: trunk/ext/-test-/testutil/ Added files: trunk/ext/-test-/testutil/extconf.rb trunk/ext/-test-/testutil/init.c trunk/ext/-test-/testutil/integer.c Index: ext/-test-/testutil/init.c =================================================================== --- ext/-test-/testutil/init.c (revision 0) +++ ext/-test-/testutil/init.c (revision 55025) @@ -0,0 +1,11 @@ https://github.com/ruby/ruby/blob/trunk/ext/-test-/testutil/init.c#L1 +#include "ruby.h" + +#define init(n) {void Init_##n(VALUE klass); Init_##n(klass);} + +void +Init_testutil(void) +{ + VALUE mBug = rb_define_module("Bug"); + VALUE klass = rb_define_class_under(mBug, "TestUtil", rb_cObject); + TEST_INIT_FUNCS(init); +} Index: ext/-test-/testutil/extconf.rb =================================================================== --- ext/-test-/testutil/extconf.rb (revision 0) +++ ext/-test-/testutil/extconf.rb (revision 55025) @@ -0,0 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ext/-test-/testutil/extconf.rb#L1 +# 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-/testutil") Index: ext/-test-/testutil/integer.c =================================================================== --- ext/-test-/testutil/integer.c (revision 0) +++ ext/-test-/testutil/integer.c (revision 55025) @@ -0,0 +1,29 @@ https://github.com/ruby/ruby/blob/trunk/ext/-test-/testutil/integer.c#L1 +#include "internal.h" + +static VALUE +int_bignum_p(VALUE self) +{ + return RB_TYPE_P(self, T_BIGNUM) ? Qtrue : Qfalse; +} + +static VALUE +int_fixnum_p(VALUE self) +{ + return FIXNUM_P(self) ? Qtrue : Qfalse; +} + +static VALUE +rb_int_to_bignum(VALUE x) +{ + if (FIXNUM_P(x)) + x = rb_int2big(FIX2LONG(x)); + return x; +} + +void +Init_integer(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); +} -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/