ruby-changes:21958
From: nobu <ko1@a...>
Date: Sun, 11 Dec 2011 10:38:03 +0900 (JST)
Subject: [ruby-changes:21958] nobu:r34007 (trunk): * object.c (rb_check_to_int): new function to convert a VALUE to
nobu 2011-12-11 10:37:50 +0900 (Sun, 11 Dec 2011) New Revision: 34007 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=34007 Log: * object.c (rb_check_to_int): new function to convert a VALUE to an Integer if possible, but returns nil instead of raising an exception otherwise. Modified files: trunk/ChangeLog trunk/include/ruby/intern.h trunk/object.c Index: include/ruby/intern.h =================================================================== --- include/ruby/intern.h (revision 34006) +++ include/ruby/intern.h (revision 34007) @@ -553,6 +553,7 @@ VALUE rb_check_to_integer(VALUE, const char *); VALUE rb_check_to_float(VALUE); VALUE rb_to_int(VALUE); +VALUE rb_check_to_int(VALUE); VALUE rb_Integer(VALUE); VALUE rb_to_float(VALUE); VALUE rb_Float(VALUE); Index: ChangeLog =================================================================== --- ChangeLog (revision 34006) +++ ChangeLog (revision 34007) @@ -1,3 +1,9 @@ +Sun Dec 11 10:37:47 2011 Nobuyoshi Nakada <nobu@r...> + + * object.c (rb_check_to_int): new function to convert a VALUE to + an Integer if possible, but returns nil instead of raising an + exception otherwise. + Sun Dec 11 10:34:39 2011 Nobuyoshi Nakada <nobu@r...> * process.c (rb_exit_status_code): extract from rb_f_exit_bang and Index: object.c =================================================================== --- object.c (revision 34006) +++ object.c (revision 34007) @@ -2187,6 +2187,12 @@ return rb_to_integer(val, "to_int"); } +VALUE +rb_check_to_int(VALUE val) +{ + return rb_check_to_integer(val, "to_int"); +} + static VALUE rb_convert_to_integer(VALUE val, int base) { -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/