diff --git a/ChangeLog b/ChangeLog index ed044b7d8d..147d975c25 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Tue Sep 30 22:25:32 2014 Nobuyoshi Nakada + + * parse.y (parser_data_type): separate ripper data type for from + parser. + Tue Sep 30 18:46:31 2014 Masaki Suketa * ext/win32ole/win32ole_typelib.c: use typed data. diff --git a/parse.y b/parse.y index 241e7f8fe3..58877be382 100644 --- a/parse.y +++ b/parse.y @@ -5465,11 +5465,9 @@ lex_getline(struct parser_params *parser) 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) 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) 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 flag) 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) void Init_ripper(void) { - parser_data_type.parent = RTYPEDDATA_TYPE(rb_parser_new()); - ripper_init_eventids1(); ripper_init_eventids2(); /* ensure existing in symbol table */ diff --git a/test/ripper/test_ripper.rb b/test/ripper/test_ripper.rb index b582de5163..0b50bee2c0 100644 --- a/test/ripper/test_ripper.rb +++ b/test/ripper/test_ripper.rb @@ -18,10 +18,17 @@ class TestRipper::Ripper < Test::Unit::TestCase 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::TestCase 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