ruby-changes:34241
From: nobu <ko1@a...>
Date: Tue, 3 Jun 2014 05:24:10 +0900 (JST)
Subject: [ruby-changes:34241] nobu:r46323 (trunk): encoding.c: move ruby_encoding_index stuff
nobu 2014-06-03 05:23:52 +0900 (Tue, 03 Jun 2014) New Revision: 46323 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=46323 Log: encoding.c: move ruby_encoding_index stuff * encoding.c: move `ruby_encoding_index` stuff from include/ruby/encoding.h to hide the extra field. Modified files: trunk/encoding.c trunk/include/ruby/encoding.h Index: encoding.c =================================================================== --- encoding.c (revision 46322) +++ encoding.c (revision 46323) @@ -52,6 +52,13 @@ static struct { https://github.com/ruby/ruby/blob/trunk/encoding.c#L52 st_table *names; } enc_table; +#define ENC_DUMMY_FLAG (1<<24) +#define ENC_INDEX_MASK (~(~0U<<24)) + +#define ENC_TO_ENCINDEX(enc) (int)((enc)->ruby_encoding_index & ENC_INDEX_MASK) +#define ENC_DUMMY_P(enc) ((enc)->ruby_encoding_index & ENC_DUMMY_FLAG) +#define ENC_SET_DUMMY(enc) ((enc)->ruby_encoding_index |= ENC_DUMMY_FLAG) + void rb_enc_init(void); #define ENCODING_COUNT ENCINDEX_BUILTIN_MAX @@ -109,6 +116,18 @@ rb_enc_from_encoding(rb_encoding *encodi https://github.com/ruby/ruby/blob/trunk/encoding.c#L116 return rb_enc_from_encoding_index(idx); } +int +rb_enc_to_index(rb_encoding *enc) +{ + return enc ? ENC_TO_ENCINDEX(enc) : 0; +} + +int +rb_enc_dummy_p(rb_encoding *enc) +{ + return ENC_DUMMY_P(enc) != 0; +} + static int enc_autoload(rb_encoding *); static int @@ -352,7 +371,7 @@ set_base_encoding(int index, rb_encoding https://github.com/ruby/ruby/blob/trunk/encoding.c#L371 rb_encoding *enc = enc_table.list[index].enc; enc_table.list[index].base = base; - if (rb_enc_dummy_p(base)) ENC_SET_DUMMY((rb_raw_encoding *)enc); + if (ENC_DUMMY_P(base)) ENC_SET_DUMMY((rb_raw_encoding *)enc); return enc; } Index: include/ruby/encoding.h =================================================================== --- include/ruby/encoding.h (revision 46322) +++ include/ruby/encoding.h (revision 46323) @@ -74,7 +74,8 @@ int rb_char_to_option_kcode(int c, int * https://github.com/ruby/ruby/blob/trunk/include/ruby/encoding.h#L74 int rb_enc_replicate(const char *, rb_encoding *); int rb_define_dummy_encoding(const char *); -#define rb_enc_to_index(enc) ((enc) ? ENC_TO_ENCINDEX(enc) : 0) +int rb_enc_dummy_p(rb_encoding *enc); +int rb_enc_to_index(rb_encoding *enc); int rb_enc_get_index(VALUE obj); void rb_enc_set_index(VALUE obj, int encindex); int rb_enc_find_index(const char *name); @@ -233,19 +234,6 @@ const char *ruby_enc_find_extname(const https://github.com/ruby/ruby/blob/trunk/include/ruby/encoding.h#L234 ID rb_check_id_cstr(const char *ptr, long len, rb_encoding *enc); RUBY_EXTERN VALUE rb_cEncoding; -#define ENC_DUMMY_FLAG (1<<24) -#define ENC_INDEX_MASK (~(~0U<<24)) - -#define ENC_TO_ENCINDEX(enc) (int)((enc)->ruby_encoding_index & ENC_INDEX_MASK) - -#define ENC_DUMMY_P(enc) ((enc)->ruby_encoding_index & ENC_DUMMY_FLAG) -#define ENC_SET_DUMMY(enc) ((enc)->ruby_encoding_index |= ENC_DUMMY_FLAG) - -static inline int -rb_enc_dummy_p(rb_encoding *enc) -{ - return ENC_DUMMY_P(enc) != 0; -} /* econv stuff */ -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/