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

* lib/yaml/rubytypes.rb (to_yaml): added instance variable handling

for Ranges, Strings, Structs, Regexps.

* lib/yaml/rubytypes.rb (to_yaml_fold): new method for setting a
  String's flow style.

* lib/yaml.rb (YAML::object_maker): now uses Object.allocate.

* ext/syck/gram.c: fixed transfer methods on structs, broke it
  last commit.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@6252 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
why 2004-05-06 06:29:56 +00:00
parent f77db2ed9c
commit 2fa9a0b08c
14 changed files with 456 additions and 311 deletions

View file

@ -1,3 +1,16 @@
Thu May 6 14:22:29 2004 why the lucky stiff <why@ruby-lang.org>
* lib/yaml/rubytypes.rb (to_yaml): added instance variable handling
for Ranges, Strings, Structs, Regexps.
* lib/yaml/rubytypes.rb (to_yaml_fold): new method for setting a
String's flow style.
* lib/yaml.rb (YAML::object_maker): now uses Object.allocate.
* ext/syck/gram.c: fixed transfer methods on structs, broke it
last commit.
Thu May 6 14:38:02 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
* dir.c (rb_push_glob): simplified code (not change behavior)

View file

@ -8,8 +8,8 @@
*
* Copyright (C) 2003 why the lucky stiff
*/
#include "syck.h"
#include "ruby.h"
#include "syck.h"
#include "gram.h"
#define QUOTELEN 128

View file

@ -9,11 +9,12 @@
* All Base64 code from Ruby's pack.c.
* Ruby is Copyright (C) 1993-2003 Yukihiro Matsumoto
*/
#include "ruby.h"
#include <stdio.h>
#include <string.h>
#include "syck.h"
#include "ruby.h"
#define DEFAULT_ANCHOR_FORMAT "id%03d"

View file

@ -249,8 +249,8 @@ union yyalloc
#endif
/* YYFINAL -- State number of the termination state. */
#define YYFINAL 43
#define YYLAST 486
#define YYFINAL 38
#define YYLAST 422
/* YYNTOKENS -- Number of terminals. */
#define YYNTOKENS 23
@ -259,7 +259,7 @@ union yyalloc
/* YYNRULES -- Number of rules. */
#define YYNRULES 75
/* YYNRULES -- Number of states. */
#define YYNSTATES 132
#define YYNSTATES 128
/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
#define YYUNDEFTOK 2
@ -306,9 +306,9 @@ static const unsigned char yytranslate[] =
static const unsigned char yyprhs[] =
{
0, 0, 3, 5, 8, 9, 11, 13, 15, 19,
21, 24, 28, 30, 33, 34, 36, 39, 41, 43,
45, 48, 51, 54, 57, 60, 62, 64, 66, 70,
73, 76, 78, 80, 82, 84, 86, 90, 93, 95,
21, 24, 27, 30, 34, 36, 39, 40, 42, 45,
47, 49, 51, 54, 57, 60, 63, 66, 68, 70,
72, 76, 78, 80, 82, 84, 86, 90, 93, 95,
99, 102, 106, 109, 113, 116, 118, 122, 125, 129,
132, 134, 138, 140, 142, 146, 150, 154, 157, 161,
164, 168, 171, 175, 177, 183, 185, 189, 193, 196,
@ -320,12 +320,12 @@ static const yysigned_char yyrhs[] =
{
24, 0, -1, 26, -1, 11, 28, -1, -1, 33,
-1, 27, -1, 34, -1, 29, 26, 32, -1, 34,
-1, 3, 27, -1, 29, 27, 32, -1, 25, -1,
29, 30, -1, -1, 12, -1, 29, 13, -1, 14,
-1, 13, -1, 14, -1, 31, 32, -1, 5, 33,
-1, 6, 33, -1, 7, 33, -1, 3, 33, -1,
4, -1, 8, -1, 9, -1, 29, 33, 32, -1,
5, 34, -1, 6, 34, -1, 10, -1, 35, -1,
-1, 5, 27, -1, 6, 27, -1, 3, 27, -1,
29, 27, 32, -1, 25, -1, 29, 30, -1, -1,
12, -1, 29, 13, -1, 14, -1, 13, -1, 14,
-1, 31, 32, -1, 5, 33, -1, 6, 33, -1,
7, 33, -1, 3, 33, -1, 4, -1, 8, -1,
9, -1, 29, 33, 32, -1, 10, -1, 35, -1,
39, -1, 42, -1, 48, -1, 29, 37, 30, -1,
15, 28, -1, 38, -1, 5, 31, 37, -1, 5,
37, -1, 6, 31, 37, -1, 6, 37, -1, 3,
@ -346,9 +346,9 @@ static const yysigned_char yyrhs[] =
static const unsigned short yyrline[] =
{
0, 54, 54, 58, 62, 68, 69, 72, 73, 79,
80, 89, 95, 96, 101, 111, 112, 115, 118, 121,
122, 130, 135, 140, 148, 152, 160, 173, 174, 184,
189, 194, 195, 196, 197, 198, 204, 210, 216, 217,
80, 85, 90, 99, 105, 106, 111, 121, 122, 125,
128, 131, 132, 140, 145, 150, 158, 162, 170, 183,
184, 194, 195, 196, 197, 198, 204, 210, 216, 217,
222, 227, 232, 237, 241, 247, 251, 256, 265, 269,
275, 279, 286, 287, 293, 298, 305, 310, 315, 320,
325, 329, 335, 350, 351, 369, 370, 382, 390, 399,
@ -390,9 +390,9 @@ static const unsigned short yytoknum[] =
static const unsigned char yyr1[] =
{
0, 23, 24, 24, 24, 25, 25, 26, 26, 27,
27, 27, 28, 28, 28, 29, 29, 30, 31, 32,
32, 33, 33, 33, 33, 33, 33, 33, 33, 34,
34, 34, 34, 34, 34, 34, 35, 36, 37, 37,
27, 27, 27, 27, 28, 28, 28, 29, 29, 30,
31, 32, 32, 33, 33, 33, 33, 33, 33, 33,
33, 34, 34, 34, 34, 34, 35, 36, 37, 37,
37, 37, 37, 37, 37, 38, 38, 38, 39, 39,
40, 40, 41, 41, 42, 42, 43, 43, 43, 43,
43, 43, 44, 45, 45, 46, 46, 46, 46, 47,
@ -403,9 +403,9 @@ static const unsigned char yyr1[] =
static const unsigned char yyr2[] =
{
0, 2, 1, 2, 0, 1, 1, 1, 3, 1,
2, 3, 1, 2, 0, 1, 2, 1, 1, 1,
2, 2, 2, 2, 2, 1, 1, 1, 3, 2,
2, 1, 1, 1, 1, 1, 3, 2, 1, 3,
2, 2, 2, 3, 1, 2, 0, 1, 2, 1,
1, 1, 2, 2, 2, 2, 2, 1, 1, 1,
3, 1, 1, 1, 1, 1, 3, 2, 1, 3,
2, 3, 2, 3, 2, 1, 3, 2, 3, 2,
1, 3, 1, 1, 3, 3, 3, 2, 3, 2,
3, 2, 3, 1, 5, 1, 3, 3, 2, 3,
@ -417,57 +417,55 @@ static const unsigned char yyr2[] =
means the default is an error. */
static const unsigned char yydefact[] =
{
4, 0, 0, 31, 14, 15, 0, 0, 0, 2,
0, 7, 32, 33, 34, 35, 0, 29, 30, 0,
25, 0, 0, 0, 26, 27, 12, 6, 3, 0,
5, 9, 49, 52, 0, 0, 50, 53, 71, 74,
75, 0, 72, 1, 0, 0, 0, 16, 14, 0,
0, 0, 0, 45, 0, 38, 0, 63, 65, 0,
0, 0, 0, 10, 24, 0, 0, 21, 22, 0,
0, 23, 0, 17, 0, 13, 0, 14, 48, 0,
70, 0, 18, 0, 44, 61, 0, 40, 57, 0,
42, 59, 37, 0, 19, 0, 8, 14, 36, 47,
54, 55, 68, 0, 11, 28, 69, 51, 73, 0,
0, 0, 43, 60, 39, 56, 41, 58, 0, 20,
62, 46, 66, 67, 0, 0, 0, 14, 0, 0,
0, 64
4, 31, 16, 17, 0, 0, 0, 2, 0, 7,
32, 33, 34, 35, 0, 27, 0, 0, 0, 28,
29, 14, 6, 3, 0, 5, 9, 49, 52, 0,
0, 50, 53, 71, 74, 75, 0, 72, 1, 0,
0, 0, 18, 16, 0, 0, 0, 0, 45, 0,
38, 0, 63, 65, 0, 12, 26, 10, 23, 11,
24, 0, 0, 0, 0, 25, 0, 0, 0, 19,
0, 15, 0, 16, 48, 0, 70, 0, 20, 0,
44, 61, 0, 40, 57, 0, 42, 59, 37, 0,
21, 0, 8, 16, 36, 47, 54, 55, 68, 0,
13, 30, 69, 51, 73, 0, 0, 0, 43, 60,
39, 56, 41, 58, 0, 22, 62, 46, 66, 67,
0, 0, 0, 16, 0, 0, 0, 64
};
/* YYDEFGOTO[NTERM-NUM]. */
static const yysigned_char yydefgoto[] =
{
-1, 8, 26, 50, 27, 28, 62, 75, 95, 105,
30, 31, 12, 53, 54, 55, 13, 35, 36, 14,
56, 57, 58, 59, 37, 15, 41, 42
-1, 6, 21, 45, 22, 23, 64, 71, 91, 101,
25, 26, 10, 48, 49, 50, 11, 30, 31, 12,
51, 52, 53, 54, 32, 13, 36, 37
};
/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
STATE-NUM. */
#define YYPACT_NINF -79
#define YYPACT_NINF -77
static const short yypact[] =
{
412, 420, 420, -79, 385, -79, 368, 316, 12, -79,
256, -79, -79, -79, -79, -79, 152, -79, -79, 385,
-79, 402, 402, 474, -79, -79, -79, -79, -79, 236,
-79, -79, -79, 14, 276, 22, -79, -79, -79, 14,
-79, -4, -79, -79, 437, 334, 334, -79, 385, 385,
62, 256, 23, -79, 4, 11, 4, -79, -79, 85,
437, 437, 463, -79, -79, 474, 152, -79, -79, 474,
474, -79, 351, -79, 62, -79, 127, 385, -79, 385,
-79, 385, -79, 201, -79, -79, 201, -79, -79, 201,
-79, -79, -79, 11, -79, 62, -79, 385, -79, 39,
-79, -79, 296, 62, -79, -79, -79, -79, -79, 450,
450, 450, -79, 11, -79, 11, -79, 11, 44, -79,
-79, -79, -79, -79, 32, 32, 32, 385, 65, 65,
65, -79
163, -77, 356, -77, 339, 304, 7, -77, 224, -77,
-77, -77, -77, -77, 356, -77, 356, 356, 410, -77,
-77, -77, -77, -77, 204, -77, -77, -77, -15, 244,
24, -77, -77, -77, -15, -77, 30, -77, -77, 373,
373, 373, -77, 356, 356, 41, 224, -3, -77, 18,
21, 18, -77, -77, 46, -77, -77, -77, -77, -77,
-77, 410, 410, 410, 399, -77, 322, 322, 322, -77,
41, -77, 14, 356, -77, 356, -77, 356, -77, 264,
-77, -77, 264, -77, -77, 264, -77, -77, -77, 21,
-77, 41, -77, 356, -77, 33, -77, -77, 284, 41,
-77, -77, -77, -77, -77, 386, 386, 386, -77, 21,
-77, 21, -77, 21, 22, -77, -77, -77, -77, -77,
20, 20, 20, 356, 91, 91, 91, -77
};
/* YYPGOTO[NTERM-NUM]. */
static const yysigned_char yypgoto[] =
static const short yypgoto[] =
{
-79, -79, 8, 64, -6, -45, 0, -23, 73, -30,
40, 93, -79, -44, 108, -79, -79, -79, -12, -79,
-19, -79, -29, -78, 2, -79, -79, 7
-77, -77, 5, 56, 138, -40, 0, 25, 59, -34,
23, 12, -77, -76, 71, -77, -77, -77, -14, -77,
75, -77, -33, -64, 1, -77, -77, -7
};
/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
@ -477,128 +475,115 @@ static const yysigned_char yypgoto[] =
#define YYTABLE_NINF -1
static const unsigned char yytable[] =
{
10, 16, 16, 92, 29, 113, 34, 34, 115, 40,
51, 117, 43, 63, 33, 39, 80, 81, 73, 34,
96, 66, 66, 74, 82, 85, 88, 91, 74, 34,
77, 98, 106, 100, 34, 128, 101, 129, 130, 97,
78, 88, 91, 79, 104, 66, 66, 48, 29, 34,
52, 51, 120, 85, 48, 121, 52, 93, 122, 64,
127, 67, 68, 71, 9, 119, 63, 107, 128, 76,
129, 130, 34, 123, 76, 82, 94, 29, 82, 34,
48, 34, 131, 40, 64, 67, 68, 33, 108, 39,
0, 76, 0, 11, 17, 18, 0, 29, 82, 73,
67, 68, 103, 11, 0, 64, 76, 0, 0, 67,
68, 0, 64, 0, 17, 18, 0, 83, 86, 89,
0, 0, 0, 52, 0, 0, 52, 29, 99, 52,
0, 0, 102, 86, 89, 0, 0, 0, 17, 18,
82, 94, 52, 97, 11, 83, 0, 0, 0, 64,
67, 68, 84, 87, 90, 44, 20, 60, 61, 23,
24, 25, 0, 0, 5, 47, 118, 48, 87, 90,
0, 0, 0, 0, 49, 0, 0, 0, 0, 0,
84, 0, 124, 125, 126, 0, 102, 0, 102, 0,
102, 112, 0, 0, 114, 0, 0, 116, 0, 0,
0, 124, 125, 126, 109, 20, 110, 111, 23, 24,
25, 0, 0, 5, 0, 0, 48, 84, 87, 90,
0, 0, 0, 49, 0, 0, 0, 0, 0, 0,
0, 0, 112, 114, 116, 0, 84, 87, 90, 72,
20, 45, 46, 23, 24, 25, 3, 0, 5, 47,
73, 48, 0, 6, 0, 7, 0, 0, 49, 44,
20, 45, 46, 23, 24, 25, 3, 0, 5, 47,
0, 48, 0, 6, 0, 7, 0, 0, 49, 72,
20, 45, 46, 23, 24, 25, 3, 0, 5, 47,
0, 48, 0, 6, 0, 7, 0, 0, 49, 65,
20, 69, 70, 23, 24, 25, 0, 0, 5, 0,
0, 48, 0, 0, 0, 0, 0, 0, 49, 19,
20, 21, 22, 23, 24, 25, 3, 0, 5, 0,
0, 0, 0, 6, 0, 7, 38, 44, 20, 45,
46, 23, 24, 25, 3, 0, 5, 82, 0, 48,
0, 6, 0, 7, 72, 20, 45, 46, 23, 24,
25, 3, 0, 5, 82, 0, 48, 0, 6, 0,
7, 19, 20, 21, 22, 23, 24, 25, 3, 0,
5, 0, 0, 0, 0, 6, 32, 7, 19, 20,
21, 22, 23, 24, 25, 3, 0, 5, 0, 0,
0, 0, 6, 0, 7, 65, 20, 21, 22, 23,
24, 25, 3, 0, 5, 0, 0, 1, 2, 6,
0, 7, 3, 4, 5, 1, 2, 0, 0, 6,
3, 7, 5, 0, 0, 0, 0, 6, 0, 7,
44, 20, 60, 61, 23, 24, 25, 0, 0, 5,
82, 0, 48, 109, 20, 110, 111, 23, 24, 25,
0, 0, 5, 82, 0, 48, 65, 20, 69, 70,
23, 24, 25, 0, 0, 5, 47, 65, 20, 69,
70, 23, 24, 25, 0, 0, 5
8, 73, 24, 88, 29, 29, 35, 38, 46, 28,
34, 92, 9, 93, 29, 109, 29, 29, 111, 117,
9, 113, 118, 124, 29, 125, 126, 78, 90, 29,
93, 47, 69, 102, 78, 43, 100, 56, 123, 58,
60, 65, 74, 24, 29, 75, 46, 72, 43, 89,
76, 77, 72, 116, 78, 90, 7, 115, 9, 78,
69, 103, 56, 58, 60, 119, 29, 29, 29, 72,
104, 0, 0, 24, 94, 29, 96, 29, 35, 97,
28, 0, 34, 127, 56, 58, 60, 99, 0, 56,
58, 60, 0, 24, 124, 0, 125, 126, 79, 82,
85, 0, 47, 0, 78, 47, 43, 0, 47, 95,
80, 83, 86, 98, 81, 84, 87, 0, 0, 0,
0, 47, 0, 24, 0, 79, 82, 85, 56, 58,
60, 0, 0, 0, 0, 0, 0, 80, 83, 86,
0, 81, 84, 87, 0, 0, 0, 0, 114, 0,
108, 0, 55, 110, 57, 59, 112, 0, 0, 0,
0, 0, 70, 0, 120, 121, 122, 70, 98, 0,
98, 0, 98, 1, 2, 3, 80, 83, 86, 0,
4, 0, 5, 120, 121, 122, 0, 0, 0, 0,
0, 108, 110, 112, 0, 80, 83, 86, 0, 0,
0, 0, 0, 0, 55, 57, 59, 66, 15, 67,
68, 18, 19, 20, 1, 0, 3, 42, 69, 43,
0, 4, 0, 5, 0, 0, 44, 39, 15, 40,
41, 18, 19, 20, 1, 0, 3, 42, 0, 43,
0, 4, 0, 5, 0, 0, 44, 66, 15, 67,
68, 18, 19, 20, 1, 0, 3, 42, 0, 43,
0, 4, 0, 5, 0, 0, 44, 105, 15, 106,
107, 18, 19, 20, 0, 0, 3, 0, 0, 43,
0, 0, 0, 0, 0, 0, 44, 61, 15, 62,
63, 18, 19, 20, 0, 0, 3, 0, 0, 43,
0, 0, 0, 0, 0, 0, 44, 14, 15, 16,
17, 18, 19, 20, 1, 0, 3, 0, 0, 0,
0, 4, 0, 5, 33, 66, 15, 67, 68, 18,
19, 20, 1, 0, 3, 78, 0, 43, 0, 4,
0, 5, 14, 15, 16, 17, 18, 19, 20, 1,
0, 3, 0, 0, 0, 0, 4, 27, 5, 14,
15, 16, 17, 18, 19, 20, 1, 0, 3, 0,
0, 0, 0, 4, 0, 5, 39, 15, 40, 41,
18, 19, 20, 0, 0, 3, 78, 0, 43, 105,
15, 106, 107, 18, 19, 20, 0, 0, 3, 78,
0, 43, 61, 15, 62, 63, 18, 19, 20, 0,
0, 3, 42, 61, 15, 62, 63, 18, 19, 20,
0, 0, 3
};
static const short yycheck[] =
static const yysigned_char yycheck[] =
{
0, 1, 2, 48, 4, 83, 6, 7, 86, 7,
10, 89, 0, 19, 6, 7, 20, 21, 14, 19,
50, 21, 22, 29, 13, 44, 45, 46, 34, 29,
16, 54, 77, 56, 34, 3, 59, 5, 6, 16,
18, 60, 61, 21, 74, 45, 46, 15, 48, 49,
10, 51, 97, 72, 15, 99, 16, 49, 102, 19,
16, 21, 22, 23, 0, 95, 72, 79, 3, 29,
5, 6, 72, 102, 34, 13, 14, 77, 13, 79,
15, 81, 127, 81, 44, 45, 46, 79, 81, 81,
-1, 51, -1, 0, 1, 2, -1, 97, 13, 14,
60, 61, 62, 10, -1, 65, 66, -1, -1, 69,
70, -1, 72, -1, 21, 22, -1, 44, 45, 46,
-1, -1, -1, 83, -1, -1, 86, 127, 55, 89,
-1, -1, 59, 60, 61, -1, -1, -1, 45, 46,
13, 14, 102, 16, 51, 72, -1, -1, -1, 109,
110, 111, 44, 45, 46, 3, 4, 5, 6, 7,
8, 9, -1, -1, 12, 13, 93, 15, 60, 61,
-1, -1, -1, -1, 22, -1, -1, -1, -1, -1,
72, -1, 109, 110, 111, -1, 113, -1, 115, -1,
117, 83, -1, -1, 86, -1, -1, 89, -1, -1,
-1, 128, 129, 130, 3, 4, 5, 6, 7, 8,
9, -1, -1, 12, -1, -1, 15, 109, 110, 111,
-1, -1, -1, 22, -1, -1, -1, -1, -1, -1,
-1, -1, 124, 125, 126, -1, 128, 129, 130, 3,
4, 5, 6, 7, 8, 9, 10, -1, 12, 13,
14, 15, -1, 17, -1, 19, -1, -1, 22, 3,
4, 5, 6, 7, 8, 9, 10, -1, 12, 13,
-1, 15, -1, 17, -1, 19, -1, -1, 22, 3,
4, 5, 6, 7, 8, 9, 10, -1, 12, 13,
-1, 15, -1, 17, -1, 19, -1, -1, 22, 3,
4, 5, 6, 7, 8, 9, -1, -1, 12, -1,
-1, 15, -1, -1, -1, -1, -1, -1, 22, 3,
4, 5, 6, 7, 8, 9, 10, -1, 12, -1,
-1, -1, -1, 17, -1, 19, 20, 3, 4, 5,
0, 16, 2, 43, 4, 5, 5, 0, 8, 4,
5, 45, 0, 16, 14, 79, 16, 17, 82, 95,
8, 85, 98, 3, 24, 5, 6, 13, 14, 29,
16, 8, 14, 73, 13, 15, 70, 14, 16, 16,
17, 18, 18, 43, 44, 21, 46, 24, 15, 44,
20, 21, 29, 93, 13, 14, 0, 91, 46, 13,
14, 75, 39, 40, 41, 98, 66, 67, 68, 46,
77, -1, -1, 73, 49, 75, 51, 77, 77, 54,
75, -1, 77, 123, 61, 62, 63, 64, -1, 66,
67, 68, -1, 93, 3, -1, 5, 6, 39, 40,
41, -1, 79, -1, 13, 82, 15, -1, 85, 50,
39, 40, 41, 54, 39, 40, 41, -1, -1, -1,
-1, 98, -1, 123, -1, 66, 67, 68, 105, 106,
107, -1, -1, -1, -1, -1, -1, 66, 67, 68,
-1, 66, 67, 68, -1, -1, -1, -1, 89, -1,
79, -1, 14, 82, 16, 17, 85, -1, -1, -1,
-1, -1, 24, -1, 105, 106, 107, 29, 109, -1,
111, -1, 113, 10, 11, 12, 105, 106, 107, -1,
17, -1, 19, 124, 125, 126, -1, -1, -1, -1,
-1, 120, 121, 122, -1, 124, 125, 126, -1, -1,
-1, -1, -1, -1, 66, 67, 68, 3, 4, 5,
6, 7, 8, 9, 10, -1, 12, 13, 14, 15,
-1, 17, -1, 19, -1, -1, 22, 3, 4, 5,
6, 7, 8, 9, 10, -1, 12, 13, -1, 15,
-1, 17, -1, 19, 3, 4, 5, 6, 7, 8,
9, 10, -1, 12, 13, -1, 15, -1, 17, -1,
19, 3, 4, 5, 6, 7, 8, 9, 10, -1,
12, -1, -1, -1, -1, 17, 18, 19, 3, 4,
5, 6, 7, 8, 9, 10, -1, 12, -1, -1,
-1, -1, 17, -1, 19, 3, 4, 5, 6, 7,
8, 9, 10, -1, 12, -1, -1, 5, 6, 17,
-1, 19, 10, 11, 12, 5, 6, -1, -1, 17,
10, 19, 12, -1, -1, -1, -1, 17, -1, 19,
3, 4, 5, 6, 7, 8, 9, -1, -1, 12,
13, -1, 15, 3, 4, 5, 6, 7, 8, 9,
-1, -1, 12, 13, -1, 15, 3, 4, 5, 6,
7, 8, 9, -1, -1, 12, 13, 3, 4, 5,
6, 7, 8, 9, -1, -1, 12
-1, 17, -1, 19, -1, -1, 22, 3, 4, 5,
6, 7, 8, 9, 10, -1, 12, 13, -1, 15,
-1, 17, -1, 19, -1, -1, 22, 3, 4, 5,
6, 7, 8, 9, -1, -1, 12, -1, -1, 15,
-1, -1, -1, -1, -1, -1, 22, 3, 4, 5,
6, 7, 8, 9, -1, -1, 12, -1, -1, 15,
-1, -1, -1, -1, -1, -1, 22, 3, 4, 5,
6, 7, 8, 9, 10, -1, 12, -1, -1, -1,
-1, 17, -1, 19, 20, 3, 4, 5, 6, 7,
8, 9, 10, -1, 12, 13, -1, 15, -1, 17,
-1, 19, 3, 4, 5, 6, 7, 8, 9, 10,
-1, 12, -1, -1, -1, -1, 17, 18, 19, 3,
4, 5, 6, 7, 8, 9, 10, -1, 12, -1,
-1, -1, -1, 17, -1, 19, 3, 4, 5, 6,
7, 8, 9, -1, -1, 12, 13, -1, 15, 3,
4, 5, 6, 7, 8, 9, -1, -1, 12, 13,
-1, 15, 3, 4, 5, 6, 7, 8, 9, -1,
-1, 12, 13, 3, 4, 5, 6, 7, 8, 9,
-1, -1, 12
};
/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
symbol of state STATE-NUM. */
static const unsigned char yystos[] =
{
0, 5, 6, 10, 11, 12, 17, 19, 24, 26,
29, 34, 35, 39, 42, 48, 29, 34, 34, 3,
4, 5, 6, 7, 8, 9, 25, 27, 28, 29,
33, 34, 18, 25, 29, 40, 41, 47, 20, 25,
47, 49, 50, 0, 3, 5, 6, 13, 15, 22,
26, 29, 33, 36, 37, 38, 43, 44, 45, 46,
5, 6, 29, 27, 33, 3, 29, 33, 33, 5,
6, 33, 3, 14, 27, 30, 33, 16, 18, 21,
20, 21, 13, 31, 37, 43, 31, 37, 43, 31,
37, 43, 28, 25, 14, 31, 32, 16, 30, 31,
30, 30, 31, 33, 32, 32, 28, 41, 50, 3,
5, 6, 37, 46, 37, 46, 37, 46, 31, 32,
28, 36, 36, 45, 31, 31, 31, 16, 3, 5,
6, 28
0, 10, 11, 12, 17, 19, 24, 26, 29, 34,
35, 39, 42, 48, 3, 4, 5, 6, 7, 8,
9, 25, 27, 28, 29, 33, 34, 18, 25, 29,
40, 41, 47, 20, 25, 47, 49, 50, 0, 3,
5, 6, 13, 15, 22, 26, 29, 33, 36, 37,
38, 43, 44, 45, 46, 27, 33, 27, 33, 27,
33, 3, 5, 6, 29, 33, 3, 5, 6, 14,
27, 30, 33, 16, 18, 21, 20, 21, 13, 31,
37, 43, 31, 37, 43, 31, 37, 43, 28, 25,
14, 31, 32, 16, 30, 31, 30, 30, 31, 33,
32, 32, 28, 41, 50, 3, 5, 6, 37, 46,
37, 46, 37, 46, 31, 32, 28, 36, 36, 45,
31, 31, 31, 16, 3, 5, 6, 28
};
#if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
@ -1182,6 +1167,22 @@ yyreduce:
case 10:
#line 81 "gram.y"
{
syck_add_transfer( yyvsp[-1].name, yyvsp[0].nodeData, ((SyckParser *)parser)->taguri_expansion );
yyval.nodeData = yyvsp[0].nodeData;
}
break;
case 11:
#line 86 "gram.y"
{
syck_add_transfer( yyvsp[-1].name, yyvsp[0].nodeData, 0 );
yyval.nodeData = yyvsp[0].nodeData;
}
break;
case 12:
#line 91 "gram.y"
{
/*
* _Anchors_: The language binding must keep a separate symbol table
@ -1192,47 +1193,47 @@ yyreduce:
}
break;
case 11:
#line 90 "gram.y"
case 13:
#line 100 "gram.y"
{
yyval.nodeData = yyvsp[-1].nodeData;
}
break;
case 13:
#line 97 "gram.y"
case 15:
#line 107 "gram.y"
{
NULL_NODE( parser, n );
yyval.nodeData = n;
}
break;
case 14:
#line 102 "gram.y"
case 16:
#line 112 "gram.y"
{
NULL_NODE( parser, n );
yyval.nodeData = n;
}
break;
case 21:
#line 131 "gram.y"
case 23:
#line 141 "gram.y"
{
syck_add_transfer( yyvsp[-1].name, yyvsp[0].nodeData, ((SyckParser *)parser)->taguri_expansion );
yyval.nodeData = yyvsp[0].nodeData;
}
break;
case 22:
#line 136 "gram.y"
case 24:
#line 146 "gram.y"
{
syck_add_transfer( yyvsp[-1].name, yyvsp[0].nodeData, 0 );
yyval.nodeData = yyvsp[0].nodeData;
}
break;
case 23:
#line 141 "gram.y"
case 25:
#line 151 "gram.y"
{
if ( ((SyckParser *)parser)->implicit_typing == 1 )
{
@ -1242,15 +1243,15 @@ yyreduce:
}
break;
case 24:
#line 149 "gram.y"
case 26:
#line 159 "gram.y"
{
yyval.nodeData = syck_hdlr_add_anchor( (SyckParser *)parser, yyvsp[-1].name, yyvsp[0].nodeData );
}
break;
case 25:
#line 153 "gram.y"
case 27:
#line 163 "gram.y"
{
/*
* _Aliases_: The anchor symbol table is scanned for the anchor name.
@ -1260,8 +1261,8 @@ yyreduce:
}
break;
case 26:
#line 161 "gram.y"
case 28:
#line 171 "gram.y"
{
SyckNode *n = yyvsp[0].nodeData;
if ( ((SyckParser *)parser)->taguri_expansion == 1 )
@ -1276,29 +1277,13 @@ yyreduce:
}
break;
case 28:
#line 175 "gram.y"
case 30:
#line 185 "gram.y"
{
yyval.nodeData = yyvsp[-1].nodeData;
}
break;
case 29:
#line 185 "gram.y"
{
syck_add_transfer( yyvsp[-1].name, yyvsp[0].nodeData, ((SyckParser *)parser)->taguri_expansion );
yyval.nodeData = yyvsp[0].nodeData;
}
break;
case 30:
#line 190 "gram.y"
{
syck_add_transfer( yyvsp[-1].name, yyvsp[0].nodeData, 0 );
yyval.nodeData = yyvsp[0].nodeData;
}
break;
case 36:
#line 205 "gram.y"
{
@ -1570,7 +1555,7 @@ yyreduce:
}
/* Line 1016 of /usr/local/share/bison/yacc.c. */
#line 1574 "y.tab.c"
#line 1559 "y.tab.c"
yyvsp -= yylen;
yyssp -= yylen;

View file

@ -7,8 +7,8 @@
* Copyright (C) 2003 why the lucky stiff
*/
#include "syck.h"
#include "ruby.h"
#include "syck.h"
SYMID
syck_hdlr_add_node( SyckParser *p, SyckNode *n )

View file

@ -9,8 +9,8 @@
* Copyright (C) 2003 why the lucky stiff
*/
#include "syck.h"
#include "ruby.h"
#include "syck.h"
#define YYCTYPE char
#define YYCURSOR cursor

View file

@ -7,8 +7,8 @@
* Copyright (C) 2003 why the lucky stiff
*/
#include "syck.h"
#include "ruby.h"
#include "syck.h"
/*
* Node allocation functions

View file

@ -15,25 +15,33 @@
typedef struct RVALUE {
union {
struct {
unsigned long flags; /* always 0 for freed obj */
struct RVALUE *next;
} free;
struct RBasic basic;
struct RObject object;
struct RClass klass;
struct RFloat flonum;
struct RString string;
struct RArray array;
struct RRegexp regexp;
struct RHash hash;
struct RData data;
struct RStruct rstruct;
struct RBignum bignum;
struct RFile file;
#if 0
struct {
unsigned long flags; /* always 0 for freed obj */
struct RVALUE *next;
} free;
struct RNode node;
struct RMatch match;
struct RVarmap varmap;
struct SCOPE scope;
#endif
struct RBasic basic;
struct RObject object;
struct RClass klass;
/*struct RFloat flonum;*/
/*struct RString string;*/
struct RArray array;
/*struct RRegexp regexp;*/
struct RHash hash;
/*struct RData data;*/
struct RStruct rstruct;
/*struct RBignum bignum;*/
/*struct RFile file;*/
} as;
#ifdef GC_DEBUG
char *file;
int line;
#endif
} RVALUE;
typedef struct {
@ -49,7 +57,7 @@ typedef struct {
/*
* symbols and constants
*/
static ID s_new, s_utc, s_at, s_to_f, s_to_i, s_read, s_binmode, s_call, s_transfer, s_update, s_dup, s_match, s_keys, s_to_str, s_unpack, s_tr_bang, s_anchors, s_default_set;
static ID s_new, s_utc, s_at, s_to_f, s_to_i, s_read, s_binmode, s_call, s_cmp, s_transfer, s_update, s_dup, s_match, s_keys, s_to_str, s_unpack, s_tr_bang, s_anchors, s_default_set;
static ID s_anchors, s_domain, s_families, s_kind, s_name, s_options, s_private_types, s_type_id, s_value;
static VALUE sym_model, sym_generic, sym_input, sym_bytecode;
static VALUE sym_scalar, sym_seq, sym_map;
@ -552,10 +560,9 @@ yaml_org_handler( n, ref )
}
else if ( strncmp( n->data.str->ptr, ":", 1 ) == 0 )
{
char *tmp;
tmp = syck_strndup( n->data.str->ptr + 1, n->data.str->len - 1 );
obj = ID2SYM( rb_intern( tmp ) );
free( tmp );
obj = rb_funcall( oDefaultLoader, s_transfer, 2,
rb_str_new2( "ruby/sym" ),
rb_str_new( n->data.str->ptr + 1, n->data.str->len - 1 ) );
}
else if ( strcmp( type_id, "str" ) == 0 )
{
@ -660,7 +667,7 @@ rb_syck_load_handler(p, n)
/*
* ID already set, let's alter the symbol table to accept the new object
*/
if (n->id > 0)
if (n->id > 0 && !NIL_P(obj))
{
MEMCPY((void *)n->id, (void *)obj, RVALUE, 1);
MEMZERO((void *)obj, RVALUE, 1);
@ -1146,6 +1153,19 @@ syck_badalias_initialize( self, val )
return self;
}
/*
* YAML::Syck::BadAlias.<=>
*/
VALUE
syck_badalias_cmp( alias1, alias2 )
VALUE alias1, alias2;
{
VALUE str1 = rb_ivar_get( alias1, s_name );
VALUE str2 = rb_ivar_get( alias2, s_name );
VALUE val = rb_funcall( str1, s_cmp, 1, str2 );
return val;
}
/*
* YAML::Syck::DomainType.initialize
*/
@ -1421,6 +1441,7 @@ Init_syck()
s_binmode = rb_intern("binmode");
s_transfer = rb_intern("transfer");
s_call = rb_intern("call");
s_cmp = rb_intern("<=>");
s_update = rb_intern("update");
s_dup = rb_intern("dup");
s_default_set = rb_intern("default=");
@ -1512,6 +1533,8 @@ Init_syck()
cBadAlias = rb_define_class_under( rb_syck, "BadAlias", rb_cObject );
rb_define_attr( cBadAlias, "name", 1, 1 );
rb_define_method( cBadAlias, "initialize", syck_badalias_initialize, 1);
rb_define_method( cBadAlias, "<=>", syck_badalias_cmp, 1);
rb_include_module( cBadAlias, rb_const_get( rb_cObject, rb_intern("Comparable") ) );
/*
* Define YAML::Syck::MergeKey class

View file

@ -6,11 +6,12 @@
*
* Copyright (C) 2003 why the lucky stiff
*/
#include "ruby.h"
#include <stdio.h>
#include <string.h>
#include "syck.h"
#include "ruby.h"
void syck_parser_pop_level( SyckParser * );

View file

@ -8,8 +8,8 @@
*
* Copyright (C) 2003 why the lucky stiff
*/
#include "syck.h"
#include "ruby.h"
#include "syck.h"
#include "gram.h"
/*

View file

@ -9,11 +9,11 @@
* WARNING WARNING WARNING --- THIS IS *NOT JUST* PLAYING
* ANYMORE! -- WHY HAS EMBRACED THIS AS THE REAL THING!
*/
#include "ruby.h"
#include <syck.h>
#include <assert.h>
#define YAMLBYTE_UTF8
#include "yamlbyte.h"
#include "ruby.h"
#include <stdio.h>
#define TRACE0(a) \

View file

@ -162,13 +162,13 @@ module YAML
#
def YAML.object_maker( obj_class, val, is_attr = false )
if Hash === val
name = obj_class.name
ostr = sprintf( "%c%co:%c%s\000", Marshal::MAJOR_VERSION, Marshal::MINOR_VERSION,
name.length + 5, name )
if is_attr
ostr[ -1, 1 ] = Marshal.dump( val ).sub( /^[^{]+\{/, '' )
end
o = ::Marshal.load( ostr )
# name = obj_class.name
# ostr = sprintf( "%c%co:%c%s\000", ::Marshal::MAJOR_VERSION, ::Marshal::MINOR_VERSION,
# name.length + 5, name )
# if is_attr
# ostr[ -1, 1 ] = ::Marshal.dump( val ).sub( /^[^{]+\{/, '' )
# end
o = obj_class.allocate
unless is_attr
val.each_pair { |k,v|
o.instance_variable_set("@#{k}", v)

View file

@ -36,28 +36,36 @@ module YAML
def node_text( value, block = '>' )
@seq_map = false
valx = value.dup
if options(:UseBlock)
block = '|'
elsif not options(:UseFold) and valx =~ /\n[ \t]/ and not valx =~ /#{YAML::ESCAPE_CHAR}/
block = '|'
end
str = block.dup
if valx =~ /\n\Z\n/
str << "+"
elsif valx =~ /\Z\n/
else
str << "-"
end
unless block
block =
if options(:UseBlock)
'|'
elsif not options(:UseFold) and valx =~ /\n[ \t]/ and not valx =~ /#{YAML::ESCAPE_CHAR}/
'|'
else
'>'
end
block +=
if valx =~ /\n\Z\n/
"+"
elsif valx =~ /\Z\n/
""
else
"-"
end
if valx =~ /\A[ \t#]/
block += options(:Indent).to_s
end
end
if valx =~ /#{YAML::ESCAPE_CHAR}/
valx = YAML::escape( valx )
end
if valx =~ /\A[ \t#]/
str << options(:Indent).to_s
end
if block == '>'
if block[0] == ?>
valx = fold( valx )
end
self << str + indent_text( valx ) + "\n"
indt = nil
indt = $&.to_i if block =~ /\d+/
self << block + indent_text( valx, indt ) + "\n"
end
#
@ -85,9 +93,9 @@ module YAML
#
# Write a text block with the current indent
#
def indent_text( text )
def indent_text( text, indt = nil )
return "" if text.to_s.empty?
spacing = " " * ( level * options(:Indent) )
spacing = " " * ( level * ( indt || options(:Indent) ) )
return "\n" + text.gsub( /^([^\n])/, "#{spacing}\\1" )
end

View file

@ -6,7 +6,7 @@ require 'date'
class Class
def to_yaml( opts = {} )
raise ArgumentError, "can't dump anonymous class %s" % self.class
raise TypeError, "can't dump anonymous class %s" % self.class
end
end
@ -161,6 +161,9 @@ class Struct
self.members.each { |m|
map.add( m, self[m] )
}
self.to_yaml_properties.each { |m|
map.add( m, instance_variable_get( m ) )
}
}
}
end
@ -173,6 +176,8 @@ YAML.add_ruby_type( /^struct/ ) { |type, val|
#
# Use existing Struct if it exists
#
props = {}
val.delete_if { |k,v| props[k] = v if k =~ /^@/ }
begin
struct_name, struct_type = YAML.read_type_class( type, Struct )
rescue NameError
@ -185,10 +190,13 @@ YAML.add_ruby_type( /^struct/ ) { |type, val|
#
# Set the Struct properties
#
st = struct_type.new
st = YAML::object_maker( struct_type, {} )
st.members.each { |m|
st.send( "#{m}=", val[m] )
}
props.each { |k,v|
st.instance_variable_set(k, v)
}
st
else
raise YAML::Error, "Invalid Ruby Struct: " + val.inspect
@ -276,10 +284,16 @@ YAML.add_ruby_type( /^exception/ ) { |type, val|
#
class String
def is_complex_yaml?
( self =~ /\n.+/ ? true : false )
to_yaml_fold or not to_yaml_properties.empty? or self =~ /\n.+/
end
def is_binary_data?
( self.count( "^ -~", "^\r\n" ) / self.size > 0.3 || self.count( "\x00" ) > 0 )
end
def to_yaml_type
"!ruby/string#{ if self.class != ::String; ":#{ self.class }"; end }"
end
def to_yaml_fold
nil
end
def to_yaml( opts = {} )
complex = false
@ -292,12 +306,19 @@ class String
end
YAML::quick_emit( complex ? self.object_id : nil, opts ) { |out|
if complex
if self.is_binary_data?
if not to_yaml_properties.empty?
out.map( self.to_yaml_type ) { |map|
map.add( 'str', "#{self}" )
to_yaml_properties.each { |m|
map.add( m, instance_variable_get( m ) )
}
}
elsif self.is_binary_data?
out.binary_base64( self )
elsif self =~ /^ |#{YAML::ESCAPE_CHAR}| $/
complex = false
else
out.node_text( self )
out.node_text( self, to_yaml_fold )
end
end
if not complex
@ -318,6 +339,21 @@ class String
end
end
YAML.add_ruby_type( /^string/ ) { |type, val|
type, obj_class = YAML.read_type_class( type, ::String )
if Hash === val
s = YAML::object_maker( obj_class, {} )
# Thank you, NaHi
String.instance_method(:initialize).
bind(s).
call( val.delete( 'str' ) )
val.each { |k,v| s.instance_variable_set( k, v ) }
s
else
raise YAML::Error, "Invalid String: " + val.inspect
end
}
#
# Symbol#to_yaml
#
@ -335,6 +371,7 @@ end
symbol_proc = Proc.new { |type, val|
if String === val
val = YAML::load( "--- #{val}") if val =~ /^["'].*["']$/
val.intern
else
raise YAML::Error, "Invalid Symbol: " + val.inspect
@ -348,102 +385,179 @@ YAML.add_ruby_type( 'sym', &symbol_proc )
#
class Range
def is_complex_yaml?
false
true
end
def to_yaml_type
"!ruby/range#{ if self.class != ::Range; ":#{ self.class }"; end }"
end
def to_yaml( opts = {} )
YAML::quick_emit( nil, opts ) { |out|
out << "!ruby/range '"
self.begin.to_yaml(:Emitter => out)
out << ( self.exclude_end? ? "..." : ".." )
self.end.to_yaml(:Emitter => out)
out << "'"
YAML::quick_emit( self.object_id, opts ) { |out|
if self.begin.is_complex_yaml? or self.end.is_complex_yaml? or not to_yaml_properties.empty?
out.map( to_yaml_type ) { |map|
map.add( 'begin', self.begin )
map.add( 'end', self.end )
map.add( 'excl', self.exclude_end? )
to_yaml_properties.each { |m|
map.add( m, instance_variable_get( m ) )
}
}
else
out << "#{ to_yaml_type } '"
self.begin.to_yaml(:Emitter => out)
out << ( self.exclude_end? ? "..." : ".." )
self.end.to_yaml(:Emitter => out)
out << "'"
end
}
end
end
YAML.add_ruby_type( 'range' ) { |type, val|
YAML.add_ruby_type( /^range/ ) { |type, val|
type, obj_class = YAML.read_type_class( type, ::Range )
inr = '(\w+|[+-]*\d+(?:\.\d+)?|"(?:[^\\"]|\\.)*")'
opts = {}
if String === val and val =~ /^#{inr}(\.{2,3})#{inr}$/
r1, rdots, r2 = $1, $2, $3
Range.new( YAML.load( "--- #{r1}" ), YAML.load( "--- #{r2}" ), rdots.length == 3 )
elsif Hash === val
Range.new( val['begin'], val['end'], val['exclude_end?'] )
opts = {
'begin' => YAML.load( "--- #{r1}" ),
'end' => YAML.load( "--- #{r2}" ),
'excl' => rdots.length == 3
}
val = {}
elsif Hash === val
opts['begin'] = val.delete('begin')
opts['end'] = val.delete('end')
opts['excl'] = val.delete('excl')
end
if Hash === opts
r = YAML::object_maker( obj_class, {} )
# Thank you, NaHi
Range.instance_method(:initialize).
bind(r).
call( opts['begin'], opts['end'], opts['excl'] )
val.each { |k,v| r.instance_variable_set( k, v ) }
r
else
raise YAML::Error, "Invalid Range: " + val.inspect
end
}
#
# Make an RegExp
# Make an Regexp
#
class Regexp
def is_complex_yaml?
false
self.class != Regexp or not to_yaml_properties.empty?
end
def to_yaml_type
"!ruby/regexp#{ if self.class != ::Regexp; ":#{ self.class }"; end }"
end
def to_yaml( opts = {} )
YAML::quick_emit( nil, opts ) { |out|
out << "!ruby/regexp "
self.inspect.to_yaml( :Emitter => out )
if self.is_complex_yaml?
out.map( self.to_yaml_type ) { |map|
src = self.inspect
if src =~ /\A\/(.*)\/([a-z]*)\Z/
map.add( 'regexp', $1 )
map.add( 'mods', $2 )
else
raise YAML::Error, "Invalid Regular expression: " + src
end
to_yaml_properties.each { |m|
map.add( m, instance_variable_get( m ) )
}
}
else
out << "#{ to_yaml_type } "
self.inspect.to_yaml( :Emitter => out )
end
}
end
end
regexp_proc = Proc.new { |type, val|
type, obj_class = YAML.read_type_class( type, ::Regexp )
if String === val and val =~ /^\/(.*)\/([mix]*)$/
val = { 'REGEXP' => $1, 'MODIFIERS' => $2 }
val = { 'regexp' => $1, 'mods' => $2 }
end
if Hash === val
mods = nil
unless val['MODIFIERS'].to_s.empty?
unless val['mods'].to_s.empty?
mods = 0x00
if val['MODIFIERS'].include?( 'x' )
mods |= Regexp::EXTENDED
elsif val['MODIFIERS'].include?( 'i' )
mods |= Regexp::IGNORECASE
elsif val['MODIFIERS'].include?( 'm' )
mods |= Regexp::POSIXLINE
end
mods |= Regexp::EXTENDED if val['mods'].include?( 'x' )
mods |= Regexp::IGNORECASE if val['mods'].include?( 'i' )
mods |= Regexp::MULTILINE if val['mods'].include?( 'm' )
end
Regexp::compile( val['REGEXP'], mods )
val.delete( 'mods' )
r = YAML::object_maker( obj_class, {} )
Regexp.instance_method(:initialize).
bind(r).
call( val.delete( 'regexp' ), mods )
val.each { |k,v| r.instance_variable_set( k, v ) }
r
else
raise YAML::Error, "Invalid Regular expression: " + val.inspect
end
}
YAML.add_domain_type( "perl.yaml.org,2002", /^regexp/, &regexp_proc )
YAML.add_ruby_type( 'regexp', &regexp_proc )
YAML.add_ruby_type( /^regexp/, &regexp_proc )
#
# Emit a Time object as an ISO 8601 timestamp
#
class Time
def is_complex_yaml?
false
self.class != Time or not to_yaml_properties.empty?
end
def to_yaml_type
"!ruby/time#{ if self.class != ::Time; ":#{ self.class }"; end }"
end
def to_yaml( opts = {} )
YAML::quick_emit( nil, opts ) { |out|
tz = "Z"
# from the tidy Tobias Peters <t-peters@gmx.de> Thanks!
unless self.utc?
utc_same_instant = self.dup.utc
utc_same_writing = Time.utc(year,month,day,hour,min,sec,usec)
difference_to_utc = utc_same_writing - utc_same_instant
if (difference_to_utc < 0)
difference_sign = '-'
absolute_difference = -difference_to_utc
else
difference_sign = '+'
absolute_difference = difference_to_utc
if self.is_complex_yaml?
out.map( self.to_yaml_type ) { |map|
map.add( 'at', ::Time.at( self ) )
to_yaml_properties.each { |m|
map.add( m, instance_variable_get( m ) )
}
}
else
tz = "Z"
# from the tidy Tobias Peters <t-peters@gmx.de> Thanks!
unless self.utc?
utc_same_instant = self.dup.utc
utc_same_writing = Time.utc(year,month,day,hour,min,sec,usec)
difference_to_utc = utc_same_writing - utc_same_instant
if (difference_to_utc < 0)
difference_sign = '-'
absolute_difference = -difference_to_utc
else
difference_sign = '+'
absolute_difference = difference_to_utc
end
difference_minutes = (absolute_difference/60).round
tz = "%s%02d:%02d" % [ difference_sign, difference_minutes / 60, difference_minutes % 60]
end
difference_minutes = (absolute_difference/60).round
tz = "%s%02d:%02d" % [ difference_sign, difference_minutes / 60, difference_minutes % 60]
standard = self.strftime( "%Y-%m-%d %H:%M:%S" )
standard += ".%06d" % [usec] if usec.nonzero?
standard += " %s" % [tz]
standard.to_yaml( :Emitter => out, :KeepValue => true )
end
( self.strftime( "%Y-%m-%d %H:%M:%S." ) +
"%06d %s" % [usec, tz] ).
to_yaml( :Emitter => out, :KeepValue => true )
}
end
end
YAML.add_ruby_type( /^time/ ) { |type, val|
type, obj_class = YAML.read_type_class( type, ::Time )
if Hash === val
t = obj_class.at( val.delete( 'at' ) )
val.each { |k,v| t.instance_variable_set( k, v ) }
t
else
raise YAML::Error, "Invalid Time: " + val.inspect
end
}
#
# Emit a Date object as a simple implicit
#