ruby-changes:35665
From: nobu <ko1@a...>
Date: Tue, 30 Sep 2014 22:25:41 +0900 (JST)
Subject: [ruby-changes:35665] nobu:r47747 (trunk): parse.y: separate ripper data type
nobu 2014-09-30 22:25:28 +0900 (Tue, 30 Sep 2014) New Revision: 47747 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=47747 Log: parse.y: separate ripper data type * parse.y (parser_data_type): separate ripper data type for from parser. Modified files: trunk/ChangeLog trunk/parse.y trunk/test/ripper/test_ripper.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 47746) +++ ChangeLog (revision 47747) @@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Tue Sep 30 22:25:32 2014 Nobuyoshi Nakada <nobu@r...> + + * parse.y (parser_data_type): separate ripper data type for from + parser. + Tue Sep 30 18:46:31 2014 Masaki Suketa <masaki.suketa@n...> * ext/win32ole/win32ole_typelib.c: use typed data. Index: parse.y =================================================================== --- parse.y (revision 47746) +++ parse.y (revision 47747) @@ -5465,11 +5465,9 @@ lex_getline(struct parser_params *parser https://github.com/ruby/ruby/blob/trunk/parse.y#L5465 return line; } -#ifdef RIPPER -static rb_data_type_t parser_data_type; -#else static const rb_data_type_t parser_data_type; +#ifndef RIPPER static NODE* parser_compile_string(volatile VALUE vparser, VALUE fname, VALUE s, int line) { @@ -10246,12 +10244,12 @@ parser_memsize(const void *ptr) https://github.com/ruby/ruby/blob/trunk/parse.y#L10244 return size; } -static +static const rb_data_type_t parser_data_type = { #ifndef RIPPER -const -#endif -rb_data_type_t parser_data_type = { "parser", +#else + "ripper", +#endif { parser_mark, parser_free, @@ -10286,6 +10284,18 @@ rb_parser_new(void) https://github.com/ruby/ruby/blob/trunk/parse.y#L10284 return TypedData_Wrap_Struct(0, &parser_data_type, p); } +#endif + +#ifdef RIPPER +#define rb_parser_end_seen_p ripper_parser_end_seen_p +#define rb_parser_encoding ripper_parser_encoding +#define rb_parser_get_yydebug ripper_parser_get_yydebug +#define rb_parser_set_yydebug ripper_parser_set_yydebug +static VALUE ripper_parser_end_seen_p(VALUE vparser); +static VALUE ripper_parser_encoding(VALUE vparser); +static VALUE ripper_parser_get_yydebug(VALUE self); +static VALUE ripper_parser_set_yydebug(VALUE self, VALUE flag); +#endif /* * call-seq: @@ -10348,6 +10358,7 @@ rb_parser_set_yydebug(VALUE self, VALUE https://github.com/ruby/ruby/blob/trunk/parse.y#L10358 return flag; } +#ifndef RIPPER #ifdef YYMALLOC #define HEAPCNT(n, size) ((n) * (size) / sizeof(YYSTYPE)) #define NEWHEAP() rb_node_newnode(NODE_ALLOCA, 0, (VALUE)parser->heap, 0) @@ -10899,8 +10910,6 @@ ripper_value(VALUE self, VALUE obj) https://github.com/ruby/ruby/blob/trunk/parse.y#L10910 void Init_ripper(void) { - parser_data_type.parent = RTYPEDDATA_TYPE(rb_parser_new()); - ripper_init_eventids1(); ripper_init_eventids2(); /* ensure existing in symbol table */ Index: test/ripper/test_ripper.rb =================================================================== --- test/ripper/test_ripper.rb (revision 47746) +++ test/ripper/test_ripper.rb (revision 47747) @@ -18,10 +18,17 @@ class TestRipper::Ripper < Test::Unit::T https://github.com/ruby/ruby/blob/trunk/test/ripper/test_ripper.rb#L18 def test_encoding assert_equal Encoding::UTF_8, @ripper.encoding + ripper = Ripper.new('# coding: iso-8859-15') + ripper.parse + assert_equal Encoding::ISO_8859_15, ripper.encoding end def test_end_seen_eh - refute @ripper.end_seen? + @ripper.parse + assert_not_predicate @ripper, :end_seen? + ripper = Ripper.new('__END__') + ripper.parse + assert_predicate ripper, :end_seen? end def test_filename @@ -37,17 +44,17 @@ class TestRipper::Ripper < Test::Unit::T https://github.com/ruby/ruby/blob/trunk/test/ripper/test_ripper.rb#L44 end def test_parse - refute @ripper.parse + assert_nil @ripper.parse end def test_yydebug - refute @ripper.yydebug + assert_not_predicate @ripper, :yydebug end def test_yydebug_equals @ripper.yydebug = true - assert @ripper.yydebug + assert_predicate @ripper, :yydebug end end if ripper_test -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/