ruby-changes:37359
From: mrkn <ko1@a...>
Date: Thu, 29 Jan 2015 23:34:56 +0900 (JST)
Subject: [ruby-changes:37359] mrkn:r49440 (trunk): * ext/bigdecimal/bigdecimal.c (rb_rational_num): add fallback function
mrkn 2015-01-29 23:34:43 +0900 (Thu, 29 Jan 2015) New Revision: 49440 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=49440 Log: * ext/bigdecimal/bigdecimal.c (rb_rational_num): add fallback function for rubies lower than 2.2.0. * ext/bigdecimal/bigdecimal.c (rb_rational_den): ditto. * ext/bigdecimal/extconf.rb: check the existences of struct RRational, rb_rational_num, and rb_rational_den. * ext/bigdecimal/bigdecimal.bundle: bump version. Modified files: trunk/ChangeLog trunk/ext/bigdecimal/bigdecimal.c trunk/ext/bigdecimal/bigdecimal.gemspec trunk/ext/bigdecimal/extconf.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 49439) +++ ChangeLog (revision 49440) @@ -1,3 +1,15 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Thu Jan 29 23:30:00 2015 Kenta Murata <mrkn@m...> + + * ext/bigdecimal/bigdecimal.c (rb_rational_num): add fallback function + for rubies lower than 2.2.0. + + * ext/bigdecimal/bigdecimal.c (rb_rational_den): ditto. + + * ext/bigdecimal/extconf.rb: check the existences of struct RRational, + rb_rational_num, and rb_rational_den. + + * ext/bigdecimal/bigdecimal.bundle: bump version. + Thu Jan 29 20:28:25 2015 SHIBATA Hiroshi <shibata.hiroshi@g...> * tool/make-snapshot: removed md5 digest with package infomation Index: ext/bigdecimal/bigdecimal.c =================================================================== --- ext/bigdecimal/bigdecimal.c (revision 49439) +++ ext/bigdecimal/bigdecimal.c (revision 49440) @@ -109,6 +109,30 @@ static ID id_eq; https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L109 # define RB_OBJ_STRING(obj) StringValueCStr(obj) #endif +#ifndef HAVE_RB_RATIONAL_NUM +static inline VALUE +rb_rational_num(VALUE rat) +{ +#ifdef HAVE_TYPE_STRUCT_RRATIONAL + return RRATIONAL(rat)->num; +#else + return rb_funcall(rat, rb_intern("numerator")); +#endif +} +#endif + +#ifndef HAVE_RB_RATIONAL_DEN +static inline VALUE +rb_rational_den(VALUE rat) +{ +#ifdef HAVE_TYPE_STRUCT_RRATIONAL + return RRATIONAL(rat)->den; +#else + return rb_funcall(rat, rb_intern("denominator")); +#endif +} +#endif + /* * ================== Ruby Interface part ========================== */ Index: ext/bigdecimal/bigdecimal.gemspec =================================================================== --- ext/bigdecimal/bigdecimal.gemspec (revision 49439) +++ ext/bigdecimal/bigdecimal.gemspec (revision 49440) @@ -1,5 +1,5 @@ https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.gemspec#L1 # -*- ruby -*- -_VERSION = "1.2.6" +_VERSION = "1.2.7" date = %w$Date:: $[1] Gem::Specification.new do |s| Index: ext/bigdecimal/extconf.rb =================================================================== --- ext/bigdecimal/extconf.rb (revision 49439) +++ ext/bigdecimal/extconf.rb (revision 49440) @@ -3,4 +3,8 @@ require 'mkmf' https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/extconf.rb#L3 have_func("labs", "stdlib.h") have_func("llabs", "stdlib.h") +have_type("struct RRational", "ruby.h") +have_func("rb_rational_num", "ruby.h") +have_func("rb_rational_den", "ruby.h") + create_makefile('bigdecimal') -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/