psych 3.3.2 → 5.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CONTRIBUTING.md +24 -0
- data/README.md +6 -5
- data/ext/psych/depend +13 -1
- data/ext/psych/extconf.rb +40 -30
- data/ext/psych/psych.c +1 -1
- data/ext/psych/psych_emitter.c +155 -120
- data/ext/psych/psych_parser.c +267 -281
- data/lib/psych/class_loader.rb +5 -5
- data/lib/psych/core_ext.rb +1 -1
- data/lib/psych/exception.rb +16 -2
- data/lib/psych/handlers/document_stream.rb +1 -1
- data/lib/psych/handlers/recorder.rb +1 -1
- data/lib/psych/json/stream.rb +2 -2
- data/lib/psych/json/tree_builder.rb +1 -1
- data/lib/psych/nodes/node.rb +5 -5
- data/lib/psych/nodes.rb +7 -7
- data/lib/psych/parser.rb +13 -0
- data/lib/psych/scalar_scanner.rb +24 -19
- data/lib/psych/syntax_error.rb +1 -1
- data/lib/psych/tree_builder.rb +3 -3
- data/lib/psych/versions.rb +2 -2
- data/lib/psych/visitors/json_tree.rb +1 -1
- data/lib/psych/visitors/to_ruby.rb +12 -11
- data/lib/psych/visitors/yaml_tree.rb +71 -27
- data/lib/psych/visitors.rb +6 -6
- data/lib/psych.rb +204 -106
- metadata +37 -25
- data/.gitignore +0 -16
- data/Gemfile +0 -9
- data/Mavenfile +0 -7
- data/Rakefile +0 -41
- data/bin/console +0 -7
- data/bin/setup +0 -6
- data/ext/psych/yaml/LICENSE +0 -19
- data/ext/psych/yaml/api.c +0 -1393
- data/ext/psych/yaml/config.h +0 -80
- data/ext/psych/yaml/dumper.c +0 -394
- data/ext/psych/yaml/emitter.c +0 -2358
- data/ext/psych/yaml/loader.c +0 -544
- data/ext/psych/yaml/parser.c +0 -1375
- data/ext/psych/yaml/reader.c +0 -469
- data/ext/psych/yaml/scanner.c +0 -3598
- data/ext/psych/yaml/writer.c +0 -141
- data/ext/psych/yaml/yaml.h +0 -1985
- data/ext/psych/yaml/yaml_private.h +0 -688
- data/psych.gemspec +0 -67
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e81adcfc8e167dbe8951e4b32794238a09003e57e75cc9e7f807d90c20aee917
|
4
|
+
data.tar.gz: 98cab7d17c5f91abbd84c95b089e71b4928b9554d5a8b154841c1d6d96c63f69
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9297958a815fe84220641506bc65e17133d2c551cc34d50d0261f95e51d7a19e706b06bb98b59bbde587825f9256f0579a68d250346134f2f766a79c93fa1288
|
7
|
+
data.tar.gz: a86c4526fb081f9b18cc13e6f8326c3335e80913013f448bf9ef0d0f741af7d1bdc52392014076fe3b709427e47ae42dce7f4ffe0e896de82c8d3d218e23cfb0
|
data/CONTRIBUTING.md
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
## How to contribute to Psych
|
2
|
+
|
3
|
+
Full details [here](https://bugs.ruby-lang.org/projects/ruby/wiki/HowToContribute)
|
4
|
+
|
5
|
+
#### **Did you find a bug?**
|
6
|
+
|
7
|
+
* **Do not open an issue if the bug is a security vulnerability
|
8
|
+
in Psych**, instead refer to our [security policy](https://www.ruby-lang.org/en/security/) and email [here](security@ruby-lang.org).
|
9
|
+
|
10
|
+
* **Ensure the bug was not already reported** by searching on ruby-core, the ruby github repo and on Psych's github repo. More info [here](https://bugs.ruby-lang.org/projects/ruby/wiki/HowToReport)
|
11
|
+
|
12
|
+
* If you're unable to find an open issue addressing the problem, [open a new one](https://bugs.ruby-lang.org/). Be sure to include a **title and clear description**, as much relevant information as possible, and a **code sample** or an **executable test case** demonstrating the expected behavior that is not occurring.
|
13
|
+
|
14
|
+
#### **Did you write a patch that fixes a bug?**
|
15
|
+
|
16
|
+
* Open a new GitHub pull request with the patch for small fixes. Anything larger look [here](https://bugs.ruby-lang.org/projects/ruby/wiki/HowToContribute); submit a Feature.
|
17
|
+
|
18
|
+
* Ensure you clearly describe the problem and solution. Include the relevant ticket/issue number if applicable.
|
19
|
+
|
20
|
+
Psych is a volunteer effort. We encourage you to pitch in and [join the team](https://github.com/ruby/psych/contributors)!
|
21
|
+
|
22
|
+
Thanks! :heart: :heart: :heart:
|
23
|
+
|
24
|
+
The Psych Team
|
data/README.md
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# Psych
|
2
2
|
|
3
3
|
* https://github.com/ruby/psych
|
4
|
+
* https://docs.ruby-lang.org/en/master/Psych.html
|
4
5
|
|
5
6
|
## Description
|
6
7
|
|
@@ -32,6 +33,11 @@ If you want a newer gem release of Psych, you can use rubygems:
|
|
32
33
|
|
33
34
|
gem install psych
|
34
35
|
|
36
|
+
|
37
|
+
Psych supported the static build with specific version of libyaml sources. You can build psych with libyaml-0.2.5 like this.
|
38
|
+
|
39
|
+
gem install psych -- --with-libyaml-source-dir=/path/to/libyaml-0.2.5
|
40
|
+
|
35
41
|
In order to use the gem release in your app, and not the stdlib version,
|
36
42
|
you'll need the following:
|
37
43
|
|
@@ -44,11 +50,6 @@ Or if you use Bundler add this to your `Gemfile`:
|
|
44
50
|
|
45
51
|
JRuby ships with a pure Java implementation of Psych.
|
46
52
|
|
47
|
-
If you're on Rubinius, Psych is available in 1.9 mode, please refer to the
|
48
|
-
Language Modes section of the [Rubinius
|
49
|
-
README](https://github.com/rubinius/rubinius#readme) for more information on
|
50
|
-
building and 1.9 mode.
|
51
|
-
|
52
53
|
## License
|
53
54
|
|
54
55
|
Copyright 2009 Aaron Patterson, et al.
|
data/ext/psych/depend
CHANGED
@@ -1,4 +1,16 @@
|
|
1
|
-
$(
|
1
|
+
$(TARGET_SO): $(LIBYAML)
|
2
|
+
|
3
|
+
libyaml $(LIBYAML):
|
4
|
+
cd libyaml && $(MAKE)
|
5
|
+
$(AR) $(ARFLAGS) $(LIBYAML) $(LIBYAML_OBJDIR)/*.$(OBJEXT)
|
6
|
+
$(RANLIB) $(LIBYAML)
|
7
|
+
|
8
|
+
clean-so::
|
9
|
+
-cd libyaml && $(MAKE) clean
|
10
|
+
|
11
|
+
distclean-so::
|
12
|
+
-cd libyaml && $(MAKE) distclean
|
13
|
+
-$(Q)$(RMDIRS) libyaml/* libyaml
|
2
14
|
|
3
15
|
$(OBJS): $(HDRS) $(ruby_headers) \
|
4
16
|
$(hdrdir)/ruby/encoding.h \
|
data/ext/psych/extconf.rb
CHANGED
@@ -1,43 +1,53 @@
|
|
1
1
|
# -*- coding: us-ascii -*-
|
2
2
|
# frozen_string_literal: true
|
3
3
|
require 'mkmf'
|
4
|
-
require 'fileutils'
|
5
4
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
if enable_config("bundled-libyaml", false) || !(find_header('yaml.h') && find_library('yaml', 'yaml_get_version'))
|
11
|
-
# Embed libyaml since we could not find it.
|
12
|
-
|
13
|
-
$VPATH << "$(srcdir)/yaml"
|
14
|
-
$INCFLAGS << " -I$(srcdir)/yaml"
|
15
|
-
|
16
|
-
$srcs = Dir.glob("#{$srcdir}/{,yaml/}*.c").map {|n| File.basename(n)}.sort
|
5
|
+
if $mswin or $mingw or $cygwin
|
6
|
+
$CPPFLAGS << " -DYAML_DECLARE_STATIC"
|
7
|
+
end
|
17
8
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
9
|
+
yaml_source = with_config("libyaml-source-dir")
|
10
|
+
if yaml_source
|
11
|
+
yaml_source = yaml_source.gsub(/\$\((\w+)\)|\$\{(\w+)\}/) {ENV[$1||$2]}
|
12
|
+
yaml_source = yaml_source.chomp("/")
|
13
|
+
yaml_configure = "#{File.expand_path(yaml_source)}/configure"
|
14
|
+
unless File.exist?(yaml_configure)
|
15
|
+
raise "Configure script not found in #{yaml_source.quote}"
|
22
16
|
end
|
23
17
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
18
|
+
puts("Configuring libyaml source in #{yaml_source.quote}")
|
19
|
+
yaml = "libyaml"
|
20
|
+
Dir.mkdir(yaml) unless File.directory?(yaml)
|
21
|
+
shared = $enable_shared || !$static
|
22
|
+
args = [
|
23
|
+
yaml_configure,
|
24
|
+
"--enable-#{shared ? 'shared' : 'static'}",
|
25
|
+
"--host=#{RbConfig::CONFIG['host'].sub(/-unknown-/, '-').sub(/arm64/, 'arm')}",
|
26
|
+
"CC=#{RbConfig::CONFIG['CC']}",
|
27
|
+
*(["CFLAGS=-w"] if RbConfig::CONFIG["GCC"] == "yes"),
|
28
|
+
]
|
29
|
+
puts(args.quote.join(' '))
|
30
|
+
unless system(*args, chdir: yaml)
|
31
|
+
raise "failed to configure libyaml"
|
32
|
+
end
|
33
|
+
inc = yaml_source.start_with?("#$srcdir/") ? "$(srcdir)#{yaml_source[$srcdir.size..-1]}" : yaml_source
|
34
|
+
$INCFLAGS << " -I#{yaml}/include -I#{inc}/include"
|
35
|
+
puts("INCFLAGS=#$INCFLAGS")
|
36
|
+
libyaml = "libyaml.#$LIBEXT"
|
37
|
+
$cleanfiles << libyaml
|
38
|
+
$LOCAL_LIBS.prepend("$(LIBYAML) ")
|
39
|
+
else # default to pre-installed libyaml
|
40
|
+
pkg_config('yaml-0.1')
|
41
|
+
dir_config('libyaml')
|
42
|
+
find_header('yaml.h') or abort "yaml.h not found"
|
43
|
+
find_library('yaml', 'yaml_get_version') or abort "libyaml not found"
|
37
44
|
end
|
38
45
|
|
39
46
|
create_makefile 'psych' do |mk|
|
40
|
-
mk << "
|
47
|
+
mk << "LIBYAML = #{libyaml}".strip << "\n"
|
48
|
+
mk << "LIBYAML_OBJDIR = libyaml/src#{shared ? '/.libs' : ''}\n"
|
49
|
+
mk << "OBJEXT = #$OBJEXT"
|
50
|
+
mk << "RANLIB = #{config_string('RANLIB') || config_string('NULLCMD')}\n"
|
41
51
|
end
|
42
52
|
|
43
53
|
# :startdoc:
|
data/ext/psych/psych.c
CHANGED
data/ext/psych/psych_emitter.c
CHANGED
@@ -17,7 +17,7 @@ static ID id_canonical;
|
|
17
17
|
static void emit(yaml_emitter_t * emitter, yaml_event_t * event)
|
18
18
|
{
|
19
19
|
if(!yaml_emitter_emit(emitter, event))
|
20
|
-
|
20
|
+
rb_raise(rb_eRuntimeError, "%s", emitter->problem);
|
21
21
|
}
|
22
22
|
|
23
23
|
static int writer(void *ctx, unsigned char *buffer, size_t size)
|
@@ -82,13 +82,13 @@ static VALUE initialize(int argc, VALUE *argv, VALUE self)
|
|
82
82
|
TypedData_Get_Struct(self, yaml_emitter_t, &psych_emitter_type, emitter);
|
83
83
|
|
84
84
|
if (rb_scan_args(argc, argv, "11", &io, &options) == 2) {
|
85
|
-
|
86
|
-
|
87
|
-
|
85
|
+
line_width = rb_funcall(options, id_line_width, 0);
|
86
|
+
indent = rb_funcall(options, id_indentation, 0);
|
87
|
+
canonical = rb_funcall(options, id_canonical, 0);
|
88
88
|
|
89
|
-
|
90
|
-
|
91
|
-
|
89
|
+
yaml_emitter_set_width(emitter, NUM2INT(line_width));
|
90
|
+
yaml_emitter_set_indent(emitter, NUM2INT(indent));
|
91
|
+
yaml_emitter_set_canonical(emitter, Qtrue == canonical ? 1 : 0);
|
92
92
|
}
|
93
93
|
|
94
94
|
rb_ivar_set(self, id_io, io);
|
@@ -136,84 +136,118 @@ static VALUE end_stream(VALUE self)
|
|
136
136
|
return self;
|
137
137
|
}
|
138
138
|
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
139
|
+
struct start_document_data {
|
140
|
+
VALUE self;
|
141
|
+
VALUE version;
|
142
|
+
VALUE tags;
|
143
|
+
VALUE imp;
|
144
|
+
|
145
|
+
yaml_tag_directive_t * head;
|
146
|
+
};
|
147
|
+
|
148
|
+
static VALUE start_document_try(VALUE d)
|
147
149
|
{
|
150
|
+
struct start_document_data * data = (struct start_document_data *)d;
|
151
|
+
VALUE self = data->self;
|
152
|
+
VALUE version = data->version;
|
153
|
+
VALUE tags = data->tags;
|
154
|
+
VALUE imp = data->imp;
|
155
|
+
|
148
156
|
yaml_emitter_t * emitter;
|
149
|
-
yaml_tag_directive_t * head = NULL;
|
150
157
|
yaml_tag_directive_t * tail = NULL;
|
151
158
|
yaml_event_t event;
|
152
159
|
yaml_version_directive_t version_directive;
|
153
160
|
TypedData_Get_Struct(self, yaml_emitter_t, &psych_emitter_type, emitter);
|
154
161
|
|
155
|
-
|
156
162
|
Check_Type(version, T_ARRAY);
|
157
163
|
|
158
164
|
if(RARRAY_LEN(version) > 0) {
|
159
|
-
|
160
|
-
|
165
|
+
VALUE major = rb_ary_entry(version, (long)0);
|
166
|
+
VALUE minor = rb_ary_entry(version, (long)1);
|
161
167
|
|
162
|
-
|
163
|
-
|
168
|
+
version_directive.major = NUM2INT(major);
|
169
|
+
version_directive.minor = NUM2INT(minor);
|
164
170
|
}
|
165
171
|
|
166
172
|
if(RTEST(tags)) {
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
173
|
+
long i = 0;
|
174
|
+
long len;
|
175
|
+
rb_encoding * encoding = rb_utf8_encoding();
|
176
|
+
|
177
|
+
Check_Type(tags, T_ARRAY);
|
178
|
+
|
179
|
+
len = RARRAY_LEN(tags);
|
180
|
+
data->head = xcalloc((size_t)len, sizeof(yaml_tag_directive_t));
|
181
|
+
tail = data->head;
|
182
|
+
|
183
|
+
for(i = 0; i < len && i < RARRAY_LEN(tags); i++) {
|
184
|
+
VALUE tuple = RARRAY_AREF(tags, i);
|
185
|
+
VALUE name;
|
186
|
+
VALUE value;
|
187
|
+
|
188
|
+
Check_Type(tuple, T_ARRAY);
|
189
|
+
|
190
|
+
if(RARRAY_LEN(tuple) < 2) {
|
191
|
+
rb_raise(rb_eRuntimeError, "tag tuple must be of length 2");
|
192
|
+
}
|
193
|
+
|
194
|
+
name = RARRAY_AREF(tuple, 0);
|
195
|
+
value = RARRAY_AREF(tuple, 1);
|
196
|
+
StringValue(name);
|
197
|
+
StringValue(value);
|
198
|
+
name = rb_str_export_to_enc(name, encoding);
|
199
|
+
value = rb_str_export_to_enc(value, encoding);
|
200
|
+
|
201
|
+
tail->handle = (yaml_char_t *)StringValueCStr(name);
|
202
|
+
tail->prefix = (yaml_char_t *)StringValueCStr(value);
|
203
|
+
|
204
|
+
tail++;
|
205
|
+
}
|
200
206
|
}
|
201
207
|
|
202
208
|
yaml_document_start_event_initialize(
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
+
&event,
|
210
|
+
(RARRAY_LEN(version) > 0) ? &version_directive : NULL,
|
211
|
+
data->head,
|
212
|
+
tail,
|
213
|
+
imp ? 1 : 0
|
214
|
+
);
|
209
215
|
|
210
216
|
emit(emitter, &event);
|
211
217
|
|
212
|
-
if(head) xfree(head);
|
213
|
-
|
214
218
|
return self;
|
215
219
|
}
|
216
220
|
|
221
|
+
static VALUE start_document_ensure(VALUE d)
|
222
|
+
{
|
223
|
+
struct start_document_data * data = (struct start_document_data *)d;
|
224
|
+
|
225
|
+
xfree(data->head);
|
226
|
+
|
227
|
+
return Qnil;
|
228
|
+
}
|
229
|
+
|
230
|
+
/* call-seq: emitter.start_document(version, tags, implicit)
|
231
|
+
*
|
232
|
+
* Start a document emission with YAML +version+, +tags+, and an +implicit+
|
233
|
+
* start.
|
234
|
+
*
|
235
|
+
* See Psych::Handler#start_document
|
236
|
+
*/
|
237
|
+
static VALUE start_document(VALUE self, VALUE version, VALUE tags, VALUE imp)
|
238
|
+
{
|
239
|
+
struct start_document_data data = {
|
240
|
+
.self = self,
|
241
|
+
.version = version,
|
242
|
+
.tags = tags,
|
243
|
+
.imp = imp,
|
244
|
+
|
245
|
+
.head = NULL,
|
246
|
+
};
|
247
|
+
|
248
|
+
return rb_ensure(start_document_try, (VALUE)&data, start_document_ensure, (VALUE)&data);
|
249
|
+
}
|
250
|
+
|
217
251
|
/* call-seq: emitter.end_document(implicit)
|
218
252
|
*
|
219
253
|
* End a document emission with an +implicit+ ending.
|
@@ -241,14 +275,14 @@ static VALUE end_document(VALUE self, VALUE imp)
|
|
241
275
|
* See Psych::Handler#scalar
|
242
276
|
*/
|
243
277
|
static VALUE scalar(
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
278
|
+
VALUE self,
|
279
|
+
VALUE value,
|
280
|
+
VALUE anchor,
|
281
|
+
VALUE tag,
|
282
|
+
VALUE plain,
|
283
|
+
VALUE quoted,
|
284
|
+
VALUE style
|
285
|
+
) {
|
252
286
|
yaml_emitter_t * emitter;
|
253
287
|
yaml_event_t event;
|
254
288
|
rb_encoding *encoding;
|
@@ -261,25 +295,26 @@ static VALUE scalar(
|
|
261
295
|
value = rb_str_export_to_enc(value, encoding);
|
262
296
|
|
263
297
|
if(!NIL_P(anchor)) {
|
264
|
-
|
265
|
-
|
298
|
+
Check_Type(anchor, T_STRING);
|
299
|
+
anchor = rb_str_export_to_enc(anchor, encoding);
|
266
300
|
}
|
267
301
|
|
268
302
|
if(!NIL_P(tag)) {
|
269
|
-
|
270
|
-
|
303
|
+
Check_Type(tag, T_STRING);
|
304
|
+
tag = rb_str_export_to_enc(tag, encoding);
|
271
305
|
}
|
272
306
|
|
307
|
+
const char *value_ptr = StringValuePtr(value);
|
273
308
|
yaml_scalar_event_initialize(
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
309
|
+
&event,
|
310
|
+
(yaml_char_t *)(NIL_P(anchor) ? NULL : StringValueCStr(anchor)),
|
311
|
+
(yaml_char_t *)(NIL_P(tag) ? NULL : StringValueCStr(tag)),
|
312
|
+
(yaml_char_t*)value_ptr,
|
313
|
+
(int)RSTRING_LEN(value),
|
314
|
+
plain ? 1 : 0,
|
315
|
+
quoted ? 1 : 0,
|
316
|
+
(yaml_scalar_style_t)NUM2INT(style)
|
317
|
+
);
|
283
318
|
|
284
319
|
emit(emitter, &event);
|
285
320
|
|
@@ -294,36 +329,36 @@ static VALUE scalar(
|
|
294
329
|
* See Psych::Handler#start_sequence
|
295
330
|
*/
|
296
331
|
static VALUE start_sequence(
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
332
|
+
VALUE self,
|
333
|
+
VALUE anchor,
|
334
|
+
VALUE tag,
|
335
|
+
VALUE implicit,
|
336
|
+
VALUE style
|
337
|
+
) {
|
303
338
|
yaml_emitter_t * emitter;
|
304
339
|
yaml_event_t event;
|
305
340
|
|
306
341
|
rb_encoding * encoding = rb_utf8_encoding();
|
307
342
|
|
308
343
|
if(!NIL_P(anchor)) {
|
309
|
-
|
310
|
-
|
344
|
+
Check_Type(anchor, T_STRING);
|
345
|
+
anchor = rb_str_export_to_enc(anchor, encoding);
|
311
346
|
}
|
312
347
|
|
313
348
|
if(!NIL_P(tag)) {
|
314
|
-
|
315
|
-
|
349
|
+
Check_Type(tag, T_STRING);
|
350
|
+
tag = rb_str_export_to_enc(tag, encoding);
|
316
351
|
}
|
317
352
|
|
318
353
|
TypedData_Get_Struct(self, yaml_emitter_t, &psych_emitter_type, emitter);
|
319
354
|
|
320
355
|
yaml_sequence_start_event_initialize(
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
356
|
+
&event,
|
357
|
+
(yaml_char_t *)(NIL_P(anchor) ? NULL : StringValueCStr(anchor)),
|
358
|
+
(yaml_char_t *)(NIL_P(tag) ? NULL : StringValueCStr(tag)),
|
359
|
+
implicit ? 1 : 0,
|
360
|
+
(yaml_sequence_style_t)NUM2INT(style)
|
361
|
+
);
|
327
362
|
|
328
363
|
emit(emitter, &event);
|
329
364
|
|
@@ -357,12 +392,12 @@ static VALUE end_sequence(VALUE self)
|
|
357
392
|
* See Psych::Handler#start_mapping
|
358
393
|
*/
|
359
394
|
static VALUE start_mapping(
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
395
|
+
VALUE self,
|
396
|
+
VALUE anchor,
|
397
|
+
VALUE tag,
|
398
|
+
VALUE implicit,
|
399
|
+
VALUE style
|
400
|
+
) {
|
366
401
|
yaml_emitter_t * emitter;
|
367
402
|
yaml_event_t event;
|
368
403
|
rb_encoding *encoding;
|
@@ -372,22 +407,22 @@ static VALUE start_mapping(
|
|
372
407
|
encoding = rb_utf8_encoding();
|
373
408
|
|
374
409
|
if(!NIL_P(anchor)) {
|
375
|
-
|
376
|
-
|
410
|
+
Check_Type(anchor, T_STRING);
|
411
|
+
anchor = rb_str_export_to_enc(anchor, encoding);
|
377
412
|
}
|
378
413
|
|
379
414
|
if(!NIL_P(tag)) {
|
380
|
-
|
381
|
-
|
415
|
+
Check_Type(tag, T_STRING);
|
416
|
+
tag = rb_str_export_to_enc(tag, encoding);
|
382
417
|
}
|
383
418
|
|
384
419
|
yaml_mapping_start_event_initialize(
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
420
|
+
&event,
|
421
|
+
(yaml_char_t *)(NIL_P(anchor) ? NULL : StringValueCStr(anchor)),
|
422
|
+
(yaml_char_t *)(NIL_P(tag) ? NULL : StringValueCStr(tag)),
|
423
|
+
implicit ? 1 : 0,
|
424
|
+
(yaml_mapping_style_t)NUM2INT(style)
|
425
|
+
);
|
391
426
|
|
392
427
|
emit(emitter, &event);
|
393
428
|
|
@@ -426,14 +461,14 @@ static VALUE alias(VALUE self, VALUE anchor)
|
|
426
461
|
TypedData_Get_Struct(self, yaml_emitter_t, &psych_emitter_type, emitter);
|
427
462
|
|
428
463
|
if(!NIL_P(anchor)) {
|
429
|
-
|
430
|
-
|
464
|
+
Check_Type(anchor, T_STRING);
|
465
|
+
anchor = rb_str_export_to_enc(anchor, rb_utf8_encoding());
|
431
466
|
}
|
432
467
|
|
433
468
|
yaml_alias_event_initialize(
|
434
|
-
|
435
|
-
|
436
|
-
|
469
|
+
&event,
|
470
|
+
(yaml_char_t *)(NIL_P(anchor) ? NULL : StringValueCStr(anchor))
|
471
|
+
);
|
437
472
|
|
438
473
|
emit(emitter, &event);
|
439
474
|
|