psych 5.0.1-java → 5.0.2-java
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Rakefile +2 -2
- data/ext/java/org/jruby/ext/psych/PsychEmitter.java +10 -11
- data/ext/java/org/jruby/ext/psych/PsychLibrary.java +0 -1
- data/ext/java/org/jruby/ext/psych/PsychParser.java +104 -88
- data/ext/psych/extconf.rb +1 -1
- data/lib/psych/class_loader.rb +1 -1
- data/lib/psych/tree_builder.rb +2 -2
- data/lib/psych/versions.rb +1 -1
- data/lib/psych.jar +0 -0
- data/psych.gemspec +2 -1
- metadata +4 -4
- data/ext/java/org/jruby/ext/psych/PsychYamlTree.java +0 -47
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: edb7088f7df001d7420b8b753d89a65ffdfc242cddcf7cd2de1dd9718b901be7
|
4
|
+
data.tar.gz: dde4cab753d72ade698f930d83bced9717fd19294c1f9069f3d2e0498e5c521f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d8fe730222b14400fab71d34af04b5f385a8c7aab74faad9004d70d9d2a37f5314cfc4b40245f6c140d65d3466519fe89abff30b26a8897a0dbec379460c7643
|
7
|
+
data.tar.gz: 02535d4ce60ee2410d54b784b146e5a24a4485d1ce3d6ba47ab93002dac04e867dd1fc0d6bcf57c09d3dbfdf1b29284c94f91b3723414b022e68cf4a6ebc5427
|
data/Rakefile
CHANGED
@@ -21,8 +21,8 @@ if RUBY_PLATFORM =~ /java/
|
|
21
21
|
# this is basically the same as running from the commandline:
|
22
22
|
# rmvn dependency:build-classpath -Dsnakeyaml.version='use version from Psych::DEFAULT_SNAKEYAML_VERSION here'
|
23
23
|
Maven::Ruby::Maven.new.exec('dependency:build-classpath', "-Dsnakeyaml.version=#{Psych::DEFAULT_SNAKEYAML_VERSION}", '-Dverbose=true')
|
24
|
-
ext.source_version = '1.
|
25
|
-
ext.target_version = '1.
|
24
|
+
ext.source_version = '1.8'
|
25
|
+
ext.target_version = '1.8'
|
26
26
|
ext.classpath = File.read('pkg/classpath')
|
27
27
|
ext.ext_dir = 'ext/java'
|
28
28
|
end
|
@@ -73,11 +73,7 @@ import static org.jruby.runtime.Visibility.*;
|
|
73
73
|
public class PsychEmitter extends RubyObject {
|
74
74
|
public static void initPsychEmitter(Ruby runtime, RubyModule psych) {
|
75
75
|
RubyClass psychHandler = runtime.defineClassUnder("Handler", runtime.getObject(), runtime.getObject().getAllocator(), psych);
|
76
|
-
RubyClass psychEmitter = runtime.defineClassUnder("Emitter", psychHandler, new
|
77
|
-
public IRubyObject allocate(Ruby runtime, RubyClass klazz) {
|
78
|
-
return new PsychEmitter(runtime, klazz);
|
79
|
-
}
|
80
|
-
}, psych);
|
76
|
+
RubyClass psychEmitter = runtime.defineClassUnder("Emitter", psychHandler, PsychEmitter::new, psych);
|
81
77
|
|
82
78
|
psychEmitter.defineAnnotatedMethods(PsychEmitter.class);
|
83
79
|
}
|
@@ -135,16 +131,19 @@ public class PsychEmitter extends RubyObject {
|
|
135
131
|
|
136
132
|
@JRubyMethod
|
137
133
|
public IRubyObject start_document(ThreadContext context, IRubyObject _version, IRubyObject tags, IRubyObject implicit) {
|
134
|
+
Ruby runtime = context.runtime;
|
135
|
+
|
138
136
|
DumperOptions.Version version = null;
|
139
137
|
boolean implicitBool = implicit.isTrue();
|
140
138
|
Map<String, String> tagsMap = null;
|
141
139
|
|
142
|
-
|
140
|
+
RubyClass arrayClass = runtime.getArray();
|
141
|
+
TypeConverter.checkType(context, _version, arrayClass);
|
143
142
|
|
144
143
|
RubyArray versionAry = _version.convertToArray();
|
145
144
|
if (versionAry.size() == 2) {
|
146
|
-
int versionInt0 =
|
147
|
-
int versionInt1 =
|
145
|
+
int versionInt0 = versionAry.eltInternal(0).convertToInteger().getIntValue();
|
146
|
+
int versionInt1 = versionAry.eltInternal(1).convertToInteger().getIntValue();
|
148
147
|
|
149
148
|
if (versionInt0 == 1) {
|
150
149
|
if (versionInt1 == 0) {
|
@@ -154,12 +153,12 @@ public class PsychEmitter extends RubyObject {
|
|
154
153
|
}
|
155
154
|
}
|
156
155
|
if (version == null) {
|
157
|
-
throw
|
156
|
+
throw runtime.newArgumentError("invalid YAML version: " + versionAry);
|
158
157
|
}
|
159
158
|
}
|
160
159
|
|
161
160
|
if (!tags.isNil()) {
|
162
|
-
TypeConverter.checkType(context, tags,
|
161
|
+
TypeConverter.checkType(context, tags, arrayClass);
|
163
162
|
|
164
163
|
RubyArray tagsAry = tags.convertToArray();
|
165
164
|
if (tagsAry.size() > 0) {
|
@@ -167,7 +166,7 @@ public class PsychEmitter extends RubyObject {
|
|
167
166
|
for (int i = 0; i < tagsAry.size(); i++) {
|
168
167
|
RubyArray tagsTuple = tagsAry.eltInternal(i).convertToArray();
|
169
168
|
if (tagsTuple.size() != 2) {
|
170
|
-
throw
|
169
|
+
throw runtime.newRuntimeError("tags tuple must be of length 2");
|
171
170
|
}
|
172
171
|
IRubyObject key = tagsTuple.eltInternal(0);
|
173
172
|
IRubyObject value = tagsTuple.eltInternal(1);
|
@@ -105,7 +105,6 @@ public class PsychLibrary implements Library {
|
|
105
105
|
PsychParser.initPsychParser(runtime, psych);
|
106
106
|
PsychEmitter.initPsychEmitter(runtime, psych);
|
107
107
|
PsychToRuby.initPsychToRuby(runtime, psych);
|
108
|
-
PsychYamlTree.initPsychYamlTree(runtime, psych);
|
109
108
|
}
|
110
109
|
|
111
110
|
public enum YAMLEncoding {
|
@@ -33,6 +33,7 @@ import java.nio.charset.Charset;
|
|
33
33
|
import java.nio.charset.CharsetDecoder;
|
34
34
|
import java.nio.charset.CodingErrorAction;
|
35
35
|
import java.nio.charset.MalformedInputException;
|
36
|
+
import java.util.Arrays;
|
36
37
|
import java.util.Map;
|
37
38
|
|
38
39
|
import org.jcodings.Encoding;
|
@@ -54,13 +55,12 @@ import org.jruby.anno.JRubyMethod;
|
|
54
55
|
import static org.jruby.ext.psych.PsychLibrary.YAMLEncoding.*;
|
55
56
|
import org.jruby.runtime.Block;
|
56
57
|
import org.jruby.runtime.Helpers;
|
57
|
-
import org.jruby.runtime.ObjectAllocator;
|
58
58
|
import org.jruby.runtime.ThreadContext;
|
59
59
|
import org.jruby.runtime.builtin.IRubyObject;
|
60
|
+
import org.jruby.runtime.callsite.CachingCallSite;
|
61
|
+
import org.jruby.runtime.callsite.FunctionalCachingCallSite;
|
60
62
|
import org.jruby.util.IOInputStream;
|
61
63
|
import org.jruby.util.io.EncodingUtils;
|
62
|
-
import org.jruby.util.log.Logger;
|
63
|
-
import org.jruby.util.log.LoggerFactory;
|
64
64
|
import org.yaml.snakeyaml.DumperOptions;
|
65
65
|
import org.yaml.snakeyaml.error.Mark;
|
66
66
|
import org.yaml.snakeyaml.error.MarkedYAMLException;
|
@@ -86,14 +86,22 @@ import org.jruby.util.ByteList;
|
|
86
86
|
|
87
87
|
public class PsychParser extends RubyObject {
|
88
88
|
|
89
|
-
|
90
|
-
|
89
|
+
public static final String JRUBY_CALL_SITES = "_jruby_call_sites";
|
90
|
+
|
91
|
+
private enum Call {
|
92
|
+
path, event_location, start_stream, start_document, end_document, alias, scalar, start_sequence, end_sequence, start_mapping, end_mapping, end_stream
|
93
|
+
}
|
94
|
+
|
95
|
+
final CachingCallSite[] sites;
|
96
|
+
|
91
97
|
public static void initPsychParser(Ruby runtime, RubyModule psych) {
|
92
|
-
RubyClass psychParser = runtime.defineClassUnder("Parser", runtime.getObject(), new
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
98
|
+
RubyClass psychParser = runtime.defineClassUnder("Parser", runtime.getObject(), PsychParser::new, psych);
|
99
|
+
|
100
|
+
CachingCallSite[] sites =
|
101
|
+
Arrays.stream(Call.values())
|
102
|
+
.map((call) -> new FunctionalCachingCallSite(call.name()))
|
103
|
+
.toArray(CachingCallSite[]::new);
|
104
|
+
psychParser.setInternalVariable(JRUBY_CALL_SITES, sites);
|
97
105
|
|
98
106
|
runtime.getLoadService().require("psych/syntax_error");
|
99
107
|
psychParser.defineConstant("ANY", runtime.newFixnum(YAML_ANY_ENCODING.ordinal()));
|
@@ -106,15 +114,17 @@ public class PsychParser extends RubyObject {
|
|
106
114
|
|
107
115
|
public PsychParser(Ruby runtime, RubyClass klass) {
|
108
116
|
super(runtime, klass);
|
117
|
+
|
118
|
+
this.sites = (CachingCallSite[]) klass.getInternalVariable(JRUBY_CALL_SITES);
|
109
119
|
}
|
110
120
|
|
111
|
-
private IRubyObject stringOrNilFor(ThreadContext context, String value
|
121
|
+
private IRubyObject stringOrNilFor(ThreadContext context, String value) {
|
112
122
|
if (value == null) return context.nil;
|
113
123
|
|
114
|
-
return stringFor(context, value
|
124
|
+
return stringFor(context, value);
|
115
125
|
}
|
116
126
|
|
117
|
-
private RubyString stringFor(ThreadContext context, String value
|
127
|
+
private RubyString stringFor(ThreadContext context, String value) {
|
118
128
|
Ruby runtime = context.runtime;
|
119
129
|
|
120
130
|
Encoding encoding = runtime.getDefaultInternalEncoding();
|
@@ -130,52 +140,35 @@ public class PsychParser extends RubyObject {
|
|
130
140
|
ByteList bytes = new ByteList(value.getBytes(charset), encoding);
|
131
141
|
RubyString string = RubyString.newString(runtime, bytes);
|
132
142
|
|
133
|
-
string.setTaint(tainted);
|
134
|
-
|
135
143
|
return string;
|
136
144
|
}
|
137
145
|
|
138
146
|
private StreamReader readerFor(ThreadContext context, IRubyObject yaml) {
|
139
147
|
if (yaml instanceof RubyString) {
|
140
|
-
|
141
|
-
Encoding enc = byteList.getEncoding();
|
142
|
-
|
143
|
-
// if not unicode, transcode to UTF8
|
144
|
-
if (!(enc instanceof UnicodeEncoding)) {
|
145
|
-
byteList = EncodingUtils.strConvEnc(context, byteList, enc, UTF8Encoding.INSTANCE);
|
146
|
-
enc = UTF8Encoding.INSTANCE;
|
147
|
-
}
|
148
|
-
|
149
|
-
ByteArrayInputStream bais = new ByteArrayInputStream(byteList.getUnsafeBytes(), byteList.getBegin(), byteList.getRealSize());
|
150
|
-
|
151
|
-
Charset charset = enc.getCharset();
|
152
|
-
|
153
|
-
assert charset != null : "charset for encoding " + enc + " should not be null";
|
154
|
-
|
155
|
-
InputStreamReader isr = new InputStreamReader(bais, charset);
|
156
|
-
|
157
|
-
return new StreamReader(isr);
|
148
|
+
return readerForString(context, (RubyString) yaml);
|
158
149
|
}
|
159
150
|
|
160
151
|
// fall back on IOInputStream, using default charset
|
161
|
-
|
162
|
-
|
163
|
-
|
152
|
+
return readerForIO(context, yaml);
|
153
|
+
}
|
154
|
+
|
155
|
+
private static StreamReader readerForIO(ThreadContext context, IRubyObject yaml) {
|
156
|
+
boolean isIO = yaml instanceof RubyIO;
|
157
|
+
if (isIO || yaml.respondsTo("read")) {
|
158
|
+
// default to UTF8 unless RubyIO has UTF16 as encoding
|
159
|
+
Charset charset = RubyEncoding.UTF8;
|
160
|
+
|
161
|
+
if (isIO) {
|
164
162
|
Encoding enc = ((RubyIO) yaml).getReadEncoding();
|
165
|
-
charset = enc.getCharset();
|
166
163
|
|
167
164
|
// libyaml treats non-utf encodings as utf-8 and hopes for the best.
|
168
|
-
if (
|
169
|
-
charset =
|
165
|
+
if (enc instanceof UTF16LEEncoding || enc instanceof UTF16BEEncoding) {
|
166
|
+
charset = enc.getCharset();
|
170
167
|
}
|
171
168
|
}
|
172
|
-
|
173
|
-
// If we can't get it from the IO or it doesn't have a charset, fall back on UTF-8
|
174
|
-
charset = UTF8Encoding.INSTANCE.getCharset();
|
175
|
-
}
|
169
|
+
|
176
170
|
CharsetDecoder decoder = charset.newDecoder();
|
177
171
|
decoder.onMalformedInput(CodingErrorAction.REPORT);
|
178
|
-
decoder.onMalformedInput(CodingErrorAction.REPORT);
|
179
172
|
|
180
173
|
return new StreamReader(new InputStreamReader(new IOInputStream(yaml), decoder));
|
181
174
|
} else {
|
@@ -185,59 +178,83 @@ public class PsychParser extends RubyObject {
|
|
185
178
|
}
|
186
179
|
}
|
187
180
|
|
181
|
+
private static StreamReader readerForString(ThreadContext context, RubyString string) {
|
182
|
+
ByteList byteList = string.getByteList();
|
183
|
+
Encoding enc = byteList.getEncoding();
|
184
|
+
|
185
|
+
// if not unicode, transcode to UTF8
|
186
|
+
if (!(enc instanceof UnicodeEncoding)) {
|
187
|
+
byteList = EncodingUtils.strConvEnc(context, byteList, enc, UTF8Encoding.INSTANCE);
|
188
|
+
enc = UTF8Encoding.INSTANCE;
|
189
|
+
}
|
190
|
+
|
191
|
+
ByteArrayInputStream bais = new ByteArrayInputStream(byteList.getUnsafeBytes(), byteList.getBegin(), byteList.getRealSize());
|
192
|
+
|
193
|
+
Charset charset = enc.getCharset();
|
194
|
+
|
195
|
+
assert charset != null : "charset for encoding " + enc + " should not be null";
|
196
|
+
|
197
|
+
InputStreamReader isr = new InputStreamReader(bais, charset);
|
198
|
+
|
199
|
+
return new StreamReader(isr);
|
200
|
+
}
|
201
|
+
|
188
202
|
@JRubyMethod(name = "_native_parse")
|
189
203
|
public IRubyObject parse(ThreadContext context, IRubyObject handler, IRubyObject yaml, IRubyObject path) {
|
190
204
|
Ruby runtime = context.runtime;
|
191
|
-
boolean tainted = yaml.isTaint() || yaml instanceof RubyIO;
|
192
205
|
|
193
206
|
try {
|
194
207
|
parser = new ParserImpl(readerFor(context, yaml));
|
195
208
|
|
196
209
|
if (path.isNil() && yaml.respondsTo("path")) {
|
197
|
-
path =
|
210
|
+
path = sites[Call.path.ordinal()].call(context, this, yaml);
|
198
211
|
}
|
199
212
|
|
200
213
|
while (true) {
|
201
214
|
event = parser.getEvent();
|
202
215
|
|
203
|
-
|
204
|
-
IRubyObject
|
205
|
-
IRubyObject
|
206
|
-
|
207
|
-
|
216
|
+
Mark start = event.getStartMark();
|
217
|
+
IRubyObject start_line = runtime.newFixnum(start.getLine());
|
218
|
+
IRubyObject start_column = runtime.newFixnum(start.getColumn());
|
219
|
+
|
220
|
+
Mark end = event.getEndMark();
|
221
|
+
IRubyObject end_line = runtime.newFixnum(end.getLine());
|
222
|
+
IRubyObject end_column = runtime.newFixnum(end.getColumn());
|
223
|
+
|
224
|
+
sites[Call.event_location.ordinal()].call(context, this, handler, start_line, start_column, end_line, end_column);
|
208
225
|
|
209
226
|
// FIXME: Event should expose a getID, so it can be switched
|
210
227
|
if (event.is(ID.StreamStart)) {
|
211
|
-
|
228
|
+
sites[Call.start_stream.ordinal()].call(context, this, handler, runtime.newFixnum(YAML_ANY_ENCODING.ordinal()));
|
212
229
|
} else if (event.is(ID.DocumentStart)) {
|
213
|
-
handleDocumentStart(context, (DocumentStartEvent) event,
|
230
|
+
handleDocumentStart(context, (DocumentStartEvent) event, handler);
|
214
231
|
} else if (event.is(ID.DocumentEnd)) {
|
215
232
|
IRubyObject notExplicit = runtime.newBoolean(!((DocumentEndEvent) event).getExplicit());
|
216
|
-
|
217
|
-
|
233
|
+
|
234
|
+
sites[Call.end_document.ordinal()].call(context, this, handler, notExplicit);
|
218
235
|
} else if (event.is(ID.Alias)) {
|
219
|
-
IRubyObject alias = stringOrNilFor(context, ((AliasEvent)event).getAnchor()
|
236
|
+
IRubyObject alias = stringOrNilFor(context, ((AliasEvent)event).getAnchor());
|
220
237
|
|
221
|
-
|
238
|
+
sites[Call.alias.ordinal()].call(context, this, handler, alias);
|
222
239
|
} else if (event.is(ID.Scalar)) {
|
223
|
-
handleScalar(context, (ScalarEvent) event,
|
240
|
+
handleScalar(context, (ScalarEvent) event, handler);
|
224
241
|
} else if (event.is(ID.SequenceStart)) {
|
225
|
-
handleSequenceStart(context,(SequenceStartEvent) event,
|
242
|
+
handleSequenceStart(context, (SequenceStartEvent) event, handler);
|
226
243
|
} else if (event.is(ID.SequenceEnd)) {
|
227
|
-
|
244
|
+
sites[Call.end_sequence.ordinal()].call(context, this, handler);
|
228
245
|
} else if (event.is(ID.MappingStart)) {
|
229
|
-
handleMappingStart(context, (MappingStartEvent) event,
|
246
|
+
handleMappingStart(context, (MappingStartEvent) event, handler);
|
230
247
|
} else if (event.is(ID.MappingEnd)) {
|
231
|
-
|
248
|
+
sites[Call.end_mapping.ordinal()].call(context, this, handler);
|
232
249
|
} else if (event.is(ID.StreamEnd)) {
|
233
|
-
|
250
|
+
sites[Call.end_stream.ordinal()].call(context, this, handler);
|
234
251
|
|
235
252
|
break;
|
236
253
|
}
|
237
254
|
}
|
238
255
|
} catch (ParserException pe) {
|
239
256
|
parser = null;
|
240
|
-
raiseParserException(context,
|
257
|
+
raiseParserException(context, pe, path);
|
241
258
|
|
242
259
|
} catch (ScannerException se) {
|
243
260
|
parser = null;
|
@@ -245,18 +262,18 @@ public class PsychParser extends RubyObject {
|
|
245
262
|
if (se.getProblemMark() != null) {
|
246
263
|
message.append(se.getProblemMark().toString());
|
247
264
|
}
|
248
|
-
raiseParserException(context,
|
265
|
+
raiseParserException(context, se, path);
|
249
266
|
|
250
267
|
} catch (ReaderException re) {
|
251
268
|
parser = null;
|
252
|
-
raiseParserException(context,
|
269
|
+
raiseParserException(context, re, path);
|
253
270
|
|
254
271
|
} catch (YAMLException ye) {
|
255
272
|
Throwable cause = ye.getCause();
|
256
273
|
|
257
274
|
if (cause instanceof MalformedInputException) {
|
258
275
|
// failure due to improperly encoded input
|
259
|
-
raiseParserException(context,
|
276
|
+
raiseParserException(context, (MalformedInputException) cause, path);
|
260
277
|
}
|
261
278
|
|
262
279
|
throw ye;
|
@@ -269,7 +286,7 @@ public class PsychParser extends RubyObject {
|
|
269
286
|
return this;
|
270
287
|
}
|
271
288
|
|
272
|
-
private void handleDocumentStart(ThreadContext context, DocumentStartEvent dse,
|
289
|
+
private void handleDocumentStart(ThreadContext context, DocumentStartEvent dse, IRubyObject handler) {
|
273
290
|
Ruby runtime = context.runtime;
|
274
291
|
DumperOptions.Version _version = dse.getVersion();
|
275
292
|
IRubyObject version = _version == null ?
|
@@ -280,8 +297,8 @@ public class PsychParser extends RubyObject {
|
|
280
297
|
RubyArray tags = RubyArray.newArray(runtime);
|
281
298
|
if (tagsMap != null && tagsMap.size() > 0) {
|
282
299
|
for (Map.Entry<String, String> tag : tagsMap.entrySet()) {
|
283
|
-
IRubyObject key = stringFor(context, tag.getKey()
|
284
|
-
IRubyObject value = stringFor(context, tag.getValue()
|
300
|
+
IRubyObject key = stringFor(context, tag.getKey());
|
301
|
+
IRubyObject value = stringFor(context, tag.getValue());
|
285
302
|
|
286
303
|
tags.append(RubyArray.newArray(runtime, key, value));
|
287
304
|
}
|
@@ -291,41 +308,41 @@ public class PsychParser extends RubyObject {
|
|
291
308
|
invoke(context, handler, "start_document", version, tags, notExplicit);
|
292
309
|
}
|
293
310
|
|
294
|
-
private void handleMappingStart(ThreadContext context, MappingStartEvent mse,
|
311
|
+
private void handleMappingStart(ThreadContext context, MappingStartEvent mse, IRubyObject handler) {
|
295
312
|
Ruby runtime = context.runtime;
|
296
|
-
IRubyObject anchor = stringOrNilFor(context, mse.getAnchor()
|
297
|
-
IRubyObject tag = stringOrNilFor(context, mse.getTag()
|
313
|
+
IRubyObject anchor = stringOrNilFor(context, mse.getAnchor());
|
314
|
+
IRubyObject tag = stringOrNilFor(context, mse.getTag());
|
298
315
|
IRubyObject implicit = runtime.newBoolean(mse.getImplicit());
|
299
316
|
IRubyObject style = runtime.newFixnum(translateFlowStyle(mse.getFlowStyle()));
|
300
317
|
|
301
|
-
|
318
|
+
sites[Call.start_mapping.ordinal()].call(context, this, handler, anchor, tag, implicit, style);
|
302
319
|
}
|
303
320
|
|
304
|
-
private void handleScalar(ThreadContext context, ScalarEvent se,
|
321
|
+
private void handleScalar(ThreadContext context, ScalarEvent se, IRubyObject handler) {
|
305
322
|
Ruby runtime = context.runtime;
|
306
323
|
|
307
|
-
IRubyObject anchor = stringOrNilFor(context, se.getAnchor()
|
308
|
-
IRubyObject tag = stringOrNilFor(context, se.getTag()
|
324
|
+
IRubyObject anchor = stringOrNilFor(context, se.getAnchor());
|
325
|
+
IRubyObject tag = stringOrNilFor(context, se.getTag());
|
309
326
|
IRubyObject plain_implicit = runtime.newBoolean(se.getImplicit().canOmitTagInPlainScalar());
|
310
327
|
IRubyObject quoted_implicit = runtime.newBoolean(se.getImplicit().canOmitTagInNonPlainScalar());
|
311
328
|
IRubyObject style = runtime.newFixnum(translateStyle(se.getScalarStyle()));
|
312
|
-
IRubyObject val = stringFor(context, se.getValue()
|
329
|
+
IRubyObject val = stringFor(context, se.getValue());
|
313
330
|
|
314
|
-
|
331
|
+
sites[Call.scalar.ordinal()].call(context, this, handler, val, anchor, tag, plain_implicit,
|
315
332
|
quoted_implicit, style);
|
316
333
|
}
|
317
334
|
|
318
|
-
private void handleSequenceStart(ThreadContext context, SequenceStartEvent sse,
|
335
|
+
private void handleSequenceStart(ThreadContext context, SequenceStartEvent sse, IRubyObject handler) {
|
319
336
|
Ruby runtime = context.runtime;
|
320
|
-
IRubyObject anchor = stringOrNilFor(context, sse.getAnchor()
|
321
|
-
IRubyObject tag = stringOrNilFor(context, sse.getTag()
|
337
|
+
IRubyObject anchor = stringOrNilFor(context, sse.getAnchor());
|
338
|
+
IRubyObject tag = stringOrNilFor(context, sse.getTag());
|
322
339
|
IRubyObject implicit = runtime.newBoolean(sse.getImplicit());
|
323
340
|
IRubyObject style = runtime.newFixnum(translateFlowStyle(sse.getFlowStyle()));
|
324
341
|
|
325
|
-
|
342
|
+
sites[Call.start_sequence.ordinal()].call(context, this, handler, anchor, tag, implicit, style);
|
326
343
|
}
|
327
344
|
|
328
|
-
private static void raiseParserException(ThreadContext context,
|
345
|
+
private static void raiseParserException(ThreadContext context, ReaderException re, IRubyObject rbPath) {
|
329
346
|
Ruby runtime;
|
330
347
|
RubyClass se;
|
331
348
|
IRubyObject exception;
|
@@ -347,7 +364,7 @@ public class PsychParser extends RubyObject {
|
|
347
364
|
RubyKernel.raise(context, runtime.getKernel(), new IRubyObject[] { exception }, Block.NULL_BLOCK);
|
348
365
|
}
|
349
366
|
|
350
|
-
private static void raiseParserException(ThreadContext context,
|
367
|
+
private static void raiseParserException(ThreadContext context, MarkedYAMLException mye, IRubyObject rbPath) {
|
351
368
|
Ruby runtime;
|
352
369
|
Mark mark;
|
353
370
|
RubyClass se;
|
@@ -372,9 +389,8 @@ public class PsychParser extends RubyObject {
|
|
372
389
|
RubyKernel.raise(context, runtime.getKernel(), new IRubyObject[] { exception }, Block.NULL_BLOCK);
|
373
390
|
}
|
374
391
|
|
375
|
-
private static void raiseParserException(ThreadContext context,
|
376
|
-
Ruby runtime
|
377
|
-
Mark mark;
|
392
|
+
private static void raiseParserException(ThreadContext context, MalformedInputException mie, IRubyObject rbPath) {
|
393
|
+
Ruby runtime;;
|
378
394
|
RubyClass se;
|
379
395
|
IRubyObject exception;
|
380
396
|
|
data/ext/psych/extconf.rb
CHANGED
@@ -22,7 +22,7 @@ if yaml_source
|
|
22
22
|
args = [
|
23
23
|
yaml_configure,
|
24
24
|
"--enable-#{shared ? 'shared' : 'static'}",
|
25
|
-
"--host=#{RbConfig::CONFIG['host'].sub(/-unknown-/, '-')}",
|
25
|
+
"--host=#{RbConfig::CONFIG['host'].sub(/-unknown-/, '-').sub(/arm64/, 'arm')}",
|
26
26
|
"CC=#{RbConfig::CONFIG['CC']}",
|
27
27
|
*(["CFLAGS=-w"] if RbConfig::CONFIG["GCC"] == "yes"),
|
28
28
|
]
|
data/lib/psych/class_loader.rb
CHANGED
data/lib/psych/tree_builder.rb
CHANGED
@@ -41,7 +41,7 @@ module Psych
|
|
41
41
|
Sequence
|
42
42
|
Mapping
|
43
43
|
}.each do |node|
|
44
|
-
class_eval
|
44
|
+
class_eval <<~RUBY, __FILE__, __LINE__ + 1
|
45
45
|
def start_#{node.downcase}(anchor, tag, implicit, style)
|
46
46
|
n = Nodes::#{node}.new(anchor, tag, implicit, style)
|
47
47
|
set_start_location(n)
|
@@ -54,7 +54,7 @@ module Psych
|
|
54
54
|
set_end_location(n)
|
55
55
|
n
|
56
56
|
end
|
57
|
-
|
57
|
+
RUBY
|
58
58
|
end
|
59
59
|
|
60
60
|
###
|
data/lib/psych/versions.rb
CHANGED
data/lib/psych.jar
CHANGED
Binary file
|
data/psych.gemspec
CHANGED
@@ -52,7 +52,6 @@ DESCRIPTION
|
|
52
52
|
"ext/java/org/jruby/ext/psych/PsychLibrary.java",
|
53
53
|
"ext/java/org/jruby/ext/psych/PsychParser.java",
|
54
54
|
"ext/java/org/jruby/ext/psych/PsychToRuby.java",
|
55
|
-
"ext/java/org/jruby/ext/psych/PsychYamlTree.java",
|
56
55
|
"lib/psych_jars.rb",
|
57
56
|
"lib/psych.jar"
|
58
57
|
]
|
@@ -63,4 +62,6 @@ DESCRIPTION
|
|
63
62
|
s.add_dependency 'stringio'
|
64
63
|
end
|
65
64
|
|
65
|
+
s.metadata['msys2_mingw_dependencies'] = 'libyaml'
|
66
|
+
|
66
67
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: psych
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.0.
|
4
|
+
version: 5.0.2
|
5
5
|
platform: java
|
6
6
|
authors:
|
7
7
|
- Aaron Patterson
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2023-01-18 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
@@ -51,7 +51,6 @@ files:
|
|
51
51
|
- ext/java/org/jruby/ext/psych/PsychLibrary.java
|
52
52
|
- ext/java/org/jruby/ext/psych/PsychParser.java
|
53
53
|
- ext/java/org/jruby/ext/psych/PsychToRuby.java
|
54
|
-
- ext/java/org/jruby/ext/psych/PsychYamlTree.java
|
55
54
|
- ext/psych/depend
|
56
55
|
- ext/psych/extconf.rb
|
57
56
|
- ext/psych/psych.c
|
@@ -107,7 +106,8 @@ files:
|
|
107
106
|
homepage: https://github.com/ruby/psych
|
108
107
|
licenses:
|
109
108
|
- MIT
|
110
|
-
metadata:
|
109
|
+
metadata:
|
110
|
+
msys2_mingw_dependencies: libyaml
|
111
111
|
post_install_message:
|
112
112
|
rdoc_options:
|
113
113
|
- "--main"
|
@@ -1,47 +0,0 @@
|
|
1
|
-
/***** BEGIN LICENSE BLOCK *****
|
2
|
-
* Version: EPL 1.0/GPL 2.0/LGPL 2.1
|
3
|
-
*
|
4
|
-
* The contents of this file are subject to the Eclipse Public
|
5
|
-
* License Version 1.0 (the "License"); you may not use this file
|
6
|
-
* except in compliance with the License. You may obtain a copy of
|
7
|
-
* the License at http://www.eclipse.org/legal/epl-v10.html
|
8
|
-
*
|
9
|
-
* Software distributed under the License is distributed on an "AS
|
10
|
-
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
11
|
-
* implied. See the License for the specific language governing
|
12
|
-
* rights and limitations under the License.
|
13
|
-
*
|
14
|
-
* Copyright (C) 2010 Charles O Nutter <headius@headius.com>
|
15
|
-
*
|
16
|
-
* Alternatively, the contents of this file may be used under the terms of
|
17
|
-
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
18
|
-
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
19
|
-
* in which case the provisions of the GPL or the LGPL are applicable instead
|
20
|
-
* of those above. If you wish to allow use of your version of this file only
|
21
|
-
* under the terms of either the GPL or the LGPL, and not to allow others to
|
22
|
-
* use your version of this file under the terms of the EPL, indicate your
|
23
|
-
* decision by deleting the provisions above and replace them with the notice
|
24
|
-
* and other provisions required by the GPL or the LGPL. If you do not delete
|
25
|
-
* the provisions above, a recipient may use your version of this file under
|
26
|
-
* the terms of any one of the EPL, the GPL or the LGPL.
|
27
|
-
***** END LICENSE BLOCK *****/
|
28
|
-
package org.jruby.ext.psych;
|
29
|
-
|
30
|
-
import org.jruby.Ruby;
|
31
|
-
import org.jruby.RubyClass;
|
32
|
-
import org.jruby.RubyModule;
|
33
|
-
import org.jruby.RubyObject;
|
34
|
-
import org.jruby.anno.JRubyMethod;
|
35
|
-
import org.jruby.runtime.ThreadContext;
|
36
|
-
import org.jruby.runtime.builtin.IRubyObject;
|
37
|
-
import static org.jruby.runtime.Visibility.*;
|
38
|
-
|
39
|
-
public class PsychYamlTree {
|
40
|
-
public static void initPsychYamlTree(Ruby runtime, RubyModule psych) {
|
41
|
-
RubyModule visitors = (RubyModule)psych.getConstant("Visitors");
|
42
|
-
RubyClass visitor = (RubyClass)visitors.getConstant("Visitor");
|
43
|
-
RubyClass psychYamlTree = runtime.defineClassUnder("YAMLTree", visitor, RubyObject.OBJECT_ALLOCATOR, visitors);
|
44
|
-
|
45
|
-
psychYamlTree.defineAnnotatedMethods(PsychYamlTree.class);
|
46
|
-
}
|
47
|
-
}
|