1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* ext/syck/rubyext.c (syck_parser_mark): was a bit heavy on the GC.

* lib/yaml.rb (YAML::transfer): added.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3912 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
why 2003-06-05 17:42:06 +00:00
parent b5d717afda
commit 56796022a6
5 changed files with 76 additions and 63 deletions

View file

@ -7,6 +7,12 @@ Thu Jun 5 18:33:46 2003 WATANABE Hirofumi <eban@ruby-lang.org>
* ext/curses/curses.c (window_s_allocate,curses_finalize): * ext/curses/curses.c (window_s_allocate,curses_finalize):
avoid VC++ warnings. avoid VC++ warnings.
Thu Jun 5 17:44:11 2003 why the lucky stiff <ruby-cvs@whytheluckystiff.net>
* ext/syck/rubyext.c (syck_parser_mark): was a bit heavy on the GC.
* lib/yaml.rb (YAML::transfer): added.
Thu Jun 5 16:11:50 2003 NAKAMURA Usaku <usa@ruby-lang.org> Thu Jun 5 16:11:50 2003 NAKAMURA Usaku <usa@ruby-lang.org>
* bcc32/Makefile.sub, win32/Makefile.sub, wince/Makefile.sub * bcc32/Makefile.sub, win32/Makefile.sub, wince/Makefile.sub

View file

@ -454,12 +454,6 @@ syck_mark_parser(parser)
{ {
rb_gc_mark(parser->root); rb_gc_mark(parser->root);
rb_gc_mark(parser->root_on_error); rb_gc_mark(parser->root_on_error);
if ( parser->bonus != 0 )
{
struct parser_xtra *bonus = (struct parser_xtra *)parser->bonus;
rb_gc_mark(bonus->proc);
rb_gc_mark(bonus->data);
}
} }
/* /*

View file

@ -10,7 +10,7 @@
#ifndef SYCK_H #ifndef SYCK_H
#define SYCK_H #define SYCK_H
#define SYCK_VERSION "0.34" #define SYCK_VERSION "0.35"
#define YAML_DOMAIN "yaml.org,2002" #define YAML_DOMAIN "yaml.org,2002"
#include <stdio.h> #include <stdio.h>

View file

@ -1,4 +1,4 @@
/* Generated by re2c 0.5 on Mon Jun 2 23:45:51 2003 */ /* Generated by re2c 0.5 on Thu Jun 5 11:08:22 2003 */
#line 1 "token.re" #line 1 "token.re"
/* /*
* token.re * token.re
@ -260,7 +260,7 @@ yy2: yyaccept = 0;
default: goto yy3; default: goto yy3;
} }
yy3: yy3:
#line 285 #line 286
{ YYPOS(0); { YYPOS(0);
goto Document; goto Document;
} }
@ -275,12 +275,13 @@ yy7:
#line 275 #line 275
{ SyckLevel *lvl = CURRENT_LEVEL(); { SyckLevel *lvl = CURRENT_LEVEL();
ENSURE_IEND(lvl, -1); ENSURE_IEND(lvl, -1);
YYPOS(0);
return 0; return 0;
} }
yy8: yych = *++YYCURSOR; yy8: yych = *++YYCURSOR;
goto yy12; goto yy12;
yy9: yy9:
#line 280 #line 281
{ int indt_len; { int indt_len;
GOBBLE_UP_INDENT( indt_len, YYTOKEN ); GOBBLE_UP_INDENT( indt_len, YYTOKEN );
goto Header; goto Header;
@ -347,7 +348,7 @@ yy22: switch(yych){
default: goto yy20; default: goto yy20;
} }
} }
#line 289 #line 290
Document: Document:
@ -388,7 +389,7 @@ yy23:
yy25: yych = *++YYCURSOR; yy25: yych = *++YYCURSOR;
goto yy77; goto yy77;
yy26: yy26:
#line 303 #line 304
{ // Isolate spaces { // Isolate spaces
int indt_len; int indt_len;
GOBBLE_UP_INDENT( indt_len, YYTOKEN ); GOBBLE_UP_INDENT( indt_len, YYTOKEN );
@ -405,7 +406,7 @@ yy26:
} }
yy27: yych = *++YYCURSOR; yy27: yych = *++YYCURSOR;
yy28: yy28:
#line 318 #line 319
{ ENSURE_IOPEN(lvl, 0, 1); { ENSURE_IOPEN(lvl, 0, 1);
lvl = CURRENT_LEVEL(); lvl = CURRENT_LEVEL();
ADD_LEVEL(lvl->spaces + 1, syck_lvl_inline); ADD_LEVEL(lvl->spaces + 1, syck_lvl_inline);
@ -413,7 +414,7 @@ yy28:
} }
yy29: yych = *++YYCURSOR; yy29: yych = *++YYCURSOR;
yy30: yy30:
#line 324 #line 325
{ POP_LEVEL(); { POP_LEVEL();
return YYTOKEN[0]; return YYTOKEN[0];
} }
@ -424,7 +425,7 @@ yy31: yych = *++YYCURSOR;
default: goto yy32; default: goto yy32;
} }
yy32: yy32:
#line 382 #line 384
{ ENSURE_IOPEN(lvl, 0, 1); { ENSURE_IOPEN(lvl, 0, 1);
goto Plain; goto Plain;
} }
@ -564,17 +565,17 @@ yy35: yych = *++YYCURSOR;
} }
yy36: yych = *++YYCURSOR; yy36: yych = *++YYCURSOR;
yy37: yy37:
#line 356 #line 357
{ ENSURE_IOPEN(lvl, 0, 1); { ENSURE_IOPEN(lvl, 0, 1);
goto TransferMethod; } goto TransferMethod; }
yy38: yych = *++YYCURSOR; yy38: yych = *++YYCURSOR;
yy39: yy39:
#line 359 #line 360
{ ENSURE_IOPEN(lvl, 0, 1); { ENSURE_IOPEN(lvl, 0, 1);
goto SingleQuote; } goto SingleQuote; }
yy40: yych = *++YYCURSOR; yy40: yych = *++YYCURSOR;
yy41: yy41:
#line 362 #line 363
{ ENSURE_IOPEN(lvl, 0, 1); { ENSURE_IOPEN(lvl, 0, 1);
goto DoubleQuote; } goto DoubleQuote; }
yy42: yyaccept = 0; yy42: yyaccept = 0;
@ -596,19 +597,20 @@ yy42: yyaccept = 0;
} }
yy43: yych = *++YYCURSOR; yy43: yych = *++YYCURSOR;
yy44: yy44:
#line 372 #line 373
{ eat_comments( parser ); { eat_comments( parser );
goto Document; goto Document;
} }
yy45: yych = *++YYCURSOR; yy45: yych = *++YYCURSOR;
goto yy51; goto yy51;
yy46: yy46:
#line 376 #line 377
{ goto Document; } { goto Document; }
yy47: yych = *++YYCURSOR; yy47: yych = *++YYCURSOR;
yy48: yy48:
#line 378 #line 379
{ ENSURE_IEND(lvl, -1); { ENSURE_IEND(lvl, -1);
YYPOS(0);
return 0; return 0;
} }
yy49: yych = *++YYCURSOR; yy49: yych = *++YYCURSOR;
@ -650,7 +652,7 @@ yy56: switch(yych){
default: goto yy57; default: goto yy57;
} }
yy57: yy57:
#line 365 #line 366
{ if ( *( YYCURSOR - 1 ) == '\n' ) { if ( *( YYCURSOR - 1 ) == '\n' )
{ {
YYCURSOR--; YYCURSOR--;
@ -731,7 +733,7 @@ yy61: switch(yych){
default: goto yy62; default: goto yy62;
} }
yy62: yy62:
#line 351 #line 352
{ ENSURE_IOPEN(lvl, 0, 1); { ENSURE_IOPEN(lvl, 0, 1);
yylval->name = syck_strndup( YYTOKEN + 1, YYCURSOR - YYTOKEN - 1 ); yylval->name = syck_strndup( YYTOKEN + 1, YYCURSOR - YYTOKEN - 1 );
return ALIAS; return ALIAS;
@ -803,7 +805,7 @@ yy64: switch(yych){
default: goto yy65; default: goto yy65;
} }
yy65: yy65:
#line 346 #line 347
{ ENSURE_IOPEN(lvl, 0, 1); { ENSURE_IOPEN(lvl, 0, 1);
yylval->name = syck_strndup( YYTOKEN + 1, YYCURSOR - YYTOKEN - 1 ); yylval->name = syck_strndup( YYTOKEN + 1, YYCURSOR - YYTOKEN - 1 );
return ANCHOR; return ANCHOR;
@ -816,7 +818,7 @@ yy67: switch(yych){
default: goto yy68; default: goto yy68;
} }
yy68: yy68:
#line 332 #line 333
{ ENSURE_IOPEN(lvl, YYTOKEN - YYLINEPTR, 1); { ENSURE_IOPEN(lvl, YYTOKEN - YYLINEPTR, 1);
FORCE_NEXT_TOKEN(IOPEN); FORCE_NEXT_TOKEN(IOPEN);
if ( *YYCURSOR == '\n' || *( YYCURSOR - 1 ) == '\n' ) if ( *YYCURSOR == '\n' || *( YYCURSOR - 1 ) == '\n' )
@ -845,7 +847,7 @@ yy72: switch(yych){
default: goto yy73; default: goto yy73;
} }
yy73: yy73:
#line 328 #line 329
{ YYPOS(1); { YYPOS(1);
return YYTOKEN[0]; return YYTOKEN[0];
} }
@ -872,7 +874,7 @@ yy79: switch(yych){
default: goto yy26; default: goto yy26;
} }
} }
#line 386 #line 388
} }
@ -979,14 +981,14 @@ yy83: yyaccept = 0;
default: goto yy84; default: goto yy84;
} }
yy84: yy84:
#line 399 #line 401
{ YYCURSOR = YYTOKTMP; { YYCURSOR = YYTOKTMP;
return DOCSEP; return DOCSEP;
} }
yy85: yych = *++YYCURSOR; yy85: yych = *++YYCURSOR;
goto yy89; goto yy89;
yy86: yy86:
#line 397 #line 399
{ goto Directive; } { goto Directive; }
yy87: yych = *++YYCURSOR; yy87: yych = *++YYCURSOR;
goto yy84; goto yy84;
@ -1238,10 +1240,10 @@ yy94: switch(yych){
default: goto yy95; default: goto yy95;
} }
yy95: yy95:
#line 395 #line 397
{ goto Directive; } { goto Directive; }
} }
#line 402 #line 404
} }
@ -1283,7 +1285,7 @@ yy96:
yy98: yych = *++YYCURSOR; yy98: yych = *++YYCURSOR;
goto yy122; goto yy122;
yy99: yy99:
#line 425 #line 427
{ int indt_len, nl_count = 0; { int indt_len, nl_count = 0;
SyckLevel *lvl; SyckLevel *lvl;
char *tok = YYTOKTMP; char *tok = YYTOKTMP;
@ -1322,16 +1324,19 @@ yy100: yych = *++YYCURSOR;
default: goto yy101; default: goto yy101;
} }
yy101: yy101:
#line 476 #line 481
{ QUOTECATS(qstr, qcapa, qidx, YYTOKTMP, YYCURSOR - YYTOKTMP); { QUOTECATS(qstr, qcapa, qidx, YYTOKTMP, YYCURSOR - YYTOKTMP);
goto Plain2; goto Plain2;
} }
yy102: yych = *++YYCURSOR; yy102: yych = *++YYCURSOR;
yy103: yy103:
#line 459 #line 461
{ if ( plvl->status != syck_lvl_inline ) { if ( plvl->status != syck_lvl_inline )
{ {
YYCURSOR--; if ( *(YYCURSOR - 1) == ' ' || *(YYCURSOR - 1) == '\n' )
{
YYCURSOR--;
}
QUOTECATS(qstr, qcapa, qidx, YYTOKTMP, YYCURSOR - YYTOKTMP); QUOTECATS(qstr, qcapa, qidx, YYTOKTMP, YYCURSOR - YYTOKTMP);
goto Plain2; goto Plain2;
} }
@ -1349,17 +1354,17 @@ yy105: yych = *++YYCURSOR;
default: goto yy106; default: goto yy106;
} }
yy106: yy106:
#line 474 #line 479
{ goto Plain3; } { goto Plain3; }
yy107: yych = *++YYCURSOR; yy107: yych = *++YYCURSOR;
yy108: yy108:
#line 472 #line 477
{ RETURN_IMPLICIT(); } { RETURN_IMPLICIT(); }
yy109: yych = *++YYCURSOR; yy109: yych = *++YYCURSOR;
goto yy101; goto yy101;
yy110: yych = *++YYCURSOR; yy110: yych = *++YYCURSOR;
yy111: yy111:
#line 468 #line 473
{ eat_comments( parser ); { eat_comments( parser );
RETURN_IMPLICIT(); RETURN_IMPLICIT();
} }
@ -1385,7 +1390,7 @@ yy117: switch(yych){
default: goto yy118; default: goto yy118;
} }
yy118: yy118:
#line 457 #line 459
{ RETURN_IMPLICIT(); } { RETURN_IMPLICIT(); }
yy119: ++YYCURSOR; yy119: ++YYCURSOR;
if(YYLIMIT == YYCURSOR) YYFILL(1); if(YYLIMIT == YYCURSOR) YYFILL(1);
@ -1410,7 +1415,7 @@ yy124: switch(yych){
default: goto yy99; default: goto yy99;
} }
} }
#line 480 #line 485
} }
@ -1440,7 +1445,7 @@ yy125:
yy127: yych = *++YYCURSOR; yy127: yych = *++YYCURSOR;
goto yy137; goto yy137;
yy128: yy128:
#line 494 #line 499
{ int indt_len; { int indt_len;
int nl_count = 0; int nl_count = 0;
SyckLevel *lvl; SyckLevel *lvl;
@ -1482,7 +1487,7 @@ yy129: yych = *++YYCURSOR;
default: goto yy130; default: goto yy130;
} }
yy130: yy130:
#line 534 #line 539
{ SyckLevel *lvl; { SyckLevel *lvl;
SyckNode *n = syck_alloc_str(); SyckNode *n = syck_alloc_str();
lvl = CURRENT_LEVEL(); lvl = CURRENT_LEVEL();
@ -1500,13 +1505,13 @@ yy131: yych = *++YYCURSOR;
goto yy130; goto yy130;
yy132: yych = *++YYCURSOR; yy132: yych = *++YYCURSOR;
yy133: yy133:
#line 548 #line 553
{ QUOTECAT(qstr, qcapa, qidx, *(YYCURSOR - 1)); { QUOTECAT(qstr, qcapa, qidx, *(YYCURSOR - 1));
goto SingleQuote2; goto SingleQuote2;
} }
yy134: yych = *++YYCURSOR; yy134: yych = *++YYCURSOR;
yy135: yy135:
#line 530 #line 535
{ QUOTECAT(qstr, qcapa, qidx, '\''); { QUOTECAT(qstr, qcapa, qidx, '\'');
goto SingleQuote2; goto SingleQuote2;
} }
@ -1526,7 +1531,7 @@ yy139: switch(yych){
default: goto yy128; default: goto yy128;
} }
} }
#line 552 #line 557
} }
@ -1561,7 +1566,7 @@ yy140:
yy142: yych = *++YYCURSOR; yy142: yych = *++YYCURSOR;
goto yy162; goto yy162;
yy143: yy143:
#line 570 #line 575
{ int indt_len; { int indt_len;
int nl_count = 0; int nl_count = 0;
SyckLevel *lvl; SyckLevel *lvl;
@ -1613,13 +1618,13 @@ yy144: yyaccept = 0;
default: goto yy145; default: goto yy145;
} }
yy145: yy145:
#line 654 #line 659
{ QUOTECAT(qstr, qcapa, qidx, *(YYCURSOR - 1)); { QUOTECAT(qstr, qcapa, qidx, *(YYCURSOR - 1));
goto DoubleQuote2; goto DoubleQuote2;
} }
yy146: yych = *++YYCURSOR; yy146: yych = *++YYCURSOR;
yy147: yy147:
#line 640 #line 645
{ SyckLevel *lvl; { SyckLevel *lvl;
SyckNode *n = syck_alloc_str(); SyckNode *n = syck_alloc_str();
lvl = CURRENT_LEVEL(); lvl = CURRENT_LEVEL();
@ -1651,7 +1656,7 @@ yy152: YYCURSOR = YYMARKER;
} }
yy153: yych = *++YYCURSOR; yy153: yych = *++YYCURSOR;
yy154: yy154:
#line 635 #line 640
{ keep_nl = 0; { keep_nl = 0;
YYCURSOR--; YYCURSOR--;
goto DoubleQuote2; goto DoubleQuote2;
@ -1682,7 +1687,7 @@ yy155: yych = *++YYCURSOR;
} }
yy156: yych = *++YYCURSOR; yy156: yych = *++YYCURSOR;
yy157: yy157:
#line 610 #line 615
{ char ch = *( YYCURSOR - 1 ); { char ch = *( YYCURSOR - 1 );
switch ( ch ) switch ( ch )
{ {
@ -1724,7 +1729,7 @@ yy158: yych = *++YYCURSOR;
} }
yy159: yych = *++YYCURSOR; yy159: yych = *++YYCURSOR;
yy160: yy160:
#line 626 #line 631
{ long ch; { long ch;
char *chr_text = syck_strndup( YYTOKTMP, 4 ); char *chr_text = syck_strndup( YYTOKTMP, 4 );
chr_text[0] = '0'; chr_text[0] = '0';
@ -1749,7 +1754,7 @@ yy164: switch(yych){
default: goto yy143; default: goto yy143;
} }
} }
#line 658 #line 663
} }
@ -1774,7 +1779,7 @@ yy165:
yy167:yy168: yych = *++YYCURSOR; yy167:yy168: yych = *++YYCURSOR;
goto yy176; goto yy176;
yy169: yy169:
#line 667 #line 672
{ SyckLevel *lvl; { SyckLevel *lvl;
YYCURSOR = YYTOKTMP; YYCURSOR = YYTOKTMP;
if ( YYCURSOR == YYTOKEN + 1 ) if ( YYCURSOR == YYTOKEN + 1 )
@ -1824,7 +1829,7 @@ yy170: yych = *++YYCURSOR;
goto yy174; goto yy174;
yy171: yych = *++YYCURSOR; yy171: yych = *++YYCURSOR;
yy172: yy172:
#line 713 #line 718
{ goto TransferMethod; } { goto TransferMethod; }
yy173: ++YYCURSOR; yy173: ++YYCURSOR;
if(YYLIMIT == YYCURSOR) YYFILL(1); if(YYLIMIT == YYCURSOR) YYFILL(1);
@ -1841,7 +1846,7 @@ yy176: switch(yych){
default: goto yy169; default: goto yy169;
} }
} }
#line 715 #line 720
} }
@ -1905,7 +1910,7 @@ yy177:
yy179: yych = *++YYCURSOR; yy179: yych = *++YYCURSOR;
goto yy188; goto yy188;
yy180: yy180:
#line 763 #line 768
{ char *pacer; { char *pacer;
char *tok = YYTOKTMP; char *tok = YYTOKTMP;
int indt_len = 0, nl_count = 0, fold_nl = 0; int indt_len = 0, nl_count = 0, fold_nl = 0;
@ -1975,7 +1980,7 @@ yy180:
} }
yy181: yych = *++YYCURSOR; yy181: yych = *++YYCURSOR;
yy182: yy182:
#line 832 #line 837
{ lvl = CURRENT_LEVEL(); { lvl = CURRENT_LEVEL();
if ( lvl->status != syck_lvl_block ) if ( lvl->status != syck_lvl_block )
{ {
@ -1990,14 +1995,14 @@ yy182:
} }
yy183: yych = *++YYCURSOR; yy183: yych = *++YYCURSOR;
yy184: yy184:
#line 846 #line 851
{ YYCURSOR--; { YYCURSOR--;
POP_LEVEL(); POP_LEVEL();
RETURN_BLOCK(); RETURN_BLOCK();
} }
yy185: yych = *++YYCURSOR; yy185: yych = *++YYCURSOR;
yy186: yy186:
#line 851 #line 856
{ QUOTECAT(qstr, qcapa, qidx, *YYTOKTMP); { QUOTECAT(qstr, qcapa, qidx, *YYTOKTMP);
goto ScalarBlock2; goto ScalarBlock2;
} }
@ -2017,7 +2022,7 @@ yy190: switch(yych){
default: goto yy180; default: goto yy180;
} }
} }
#line 856 #line 861
} }
@ -2047,7 +2052,7 @@ yy191:
} }
yy193: yych = *++YYCURSOR; yy193: yych = *++YYCURSOR;
yy194: yy194:
#line 872 #line 877
{ SyckLevel *lvl = CURRENT_LEVEL(); { SyckLevel *lvl = CURRENT_LEVEL();
YYCURSOR = tok; YYCURSOR = tok;
return; return;
@ -2056,7 +2061,7 @@ yy195: yych = *++YYCURSOR;
goto yy199; goto yy199;
yy196: yych = *++YYCURSOR; yy196: yych = *++YYCURSOR;
yy197: yy197:
#line 877 #line 882
{ goto Comment; { goto Comment;
} }
yy198: ++YYCURSOR; yy198: ++YYCURSOR;
@ -2067,7 +2072,7 @@ yy199: switch(yych){
default: goto yy194; default: goto yy194;
} }
} }
#line 880 #line 885
} }

View file

@ -111,6 +111,13 @@ module YAML
@@loader.detect_implicit( val ) @@loader.detect_implicit( val )
end end
#
# Apply a transfer method to a Ruby object
#
def YAML.transfer( type_id, obj )
@@loader.transfer( type_id, obj )
end
# #
# Method to extract colon-seperated type and class, returning # Method to extract colon-seperated type and class, returning
# the type and the constant of the class # the type and the constant of the class
@ -147,6 +154,7 @@ module YAML
end end
require 'yaml/rubytypes' require 'yaml/rubytypes'
require 'yaml/types'
# #
# ryan: You know how Kernel.p is a really convenient way to dump ruby # ryan: You know how Kernel.p is a really convenient way to dump ruby