ruby-changes:30114
From: nobu <ko1@a...>
Date: Thu, 25 Jul 2013 17:21:33 +0900 (JST)
Subject: [ruby-changes:30114] nobu:r42166 (trunk): encoding.c: is_obj_encoding
nobu 2013-07-25 17:21:23 +0900 (Thu, 25 Jul 2013) New Revision: 42166 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=42166 Log: encoding.c: is_obj_encoding * encoding.c (is_obj_encoding): new macro to check if obj is an Encoding. obj can be any type while is_data_encoding expects T_DATA only. Modified files: trunk/ChangeLog trunk/encoding.c Index: encoding.c =================================================================== --- encoding.c (revision 42165) +++ encoding.c (revision 42166) @@ -73,6 +73,7 @@ static const rb_data_type_t encoding_dat https://github.com/ruby/ruby/blob/trunk/encoding.c#L73 }; #define is_data_encoding(obj) (RTYPEDDATA_P(obj) && RTYPEDDATA_TYPE(obj) == &encoding_data_type) +#define is_obj_encoding(obj) (RB_TYPE_P((obj), T_DATA) && is_data_encoding(obj)) static VALUE enc_new(rb_encoding *encoding) @@ -121,7 +122,7 @@ check_encoding(rb_encoding *enc) https://github.com/ruby/ruby/blob/trunk/encoding.c#L122 static int enc_check_encoding(VALUE obj) { - if (!RB_TYPE_P(obj, T_DATA) || !is_data_encoding(obj)) { + if (!is_obj_encoding(obj)) { return -1; } return check_encoding(RDATA(obj)->data); @@ -1143,7 +1144,7 @@ static VALUE https://github.com/ruby/ruby/blob/trunk/encoding.c#L1144 enc_find(VALUE klass, VALUE enc) { int idx; - if (RB_TYPE_P(enc, T_DATA) && is_data_encoding(enc)) + if (is_obj_encoding(enc)) return enc; idx = str_to_encindex(enc); if (idx == UNSPECIFIED_ENCODING) return Qnil; Index: ChangeLog =================================================================== --- ChangeLog (revision 42165) +++ ChangeLog (revision 42166) @@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Thu Jul 25 17:21:21 2013 Nobuyoshi Nakada <nobu@r...> + + * encoding.c (is_obj_encoding): new macro to check if obj is an + Encoding. obj can be any type while is_data_encoding expects T_DATA + only. + Thu Jul 25 17:17:52 2013 Nobuyoshi Nakada <nobu@r...> * file.c (rb_file_expand_path_internal): should clear coderange after -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/