Permalink
Browse files

Update to SnakeYAML 1.11 in an attempt to fix #314.

  • Loading branch information...
1 parent e80917e commit 900c537079ecbd739fa834d987baf907bcdc2351 @headius headius committed Sep 26, 2012
View
@@ -378,7 +378,7 @@
jffi-x86_64-Windows.jar
jffi-s390x-Linux.jar
joda-time-${joda.time.version}.jar
- snakeyaml-1.10.jar
+ snakeyaml-1.11-SNAPSHOT.jar
yecht.jar
yydebug.jar
nailgun-0.7.1.jar
Binary file not shown.
Binary file not shown.
View
@@ -418,15 +418,6 @@
<orderEntry type="module-library">
<library>
<CLASSES>
- <root url="jar://$MODULE_DIR$/build_lib/snakeyaml-1.10.jar!/" />
- </CLASSES>
- <JAVADOC />
- <SOURCES />
- </library>
- </orderEntry>
- <orderEntry type="module-library">
- <library>
- <CLASSES>
<root url="jar://$MODULE_DIR$/build_lib/asm-tree-4.0.jar!/" />
</CLASSES>
<JAVADOC />
@@ -532,6 +523,15 @@
<SOURCES />
</library>
</orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/build_lib/snakeyaml-1.11-SNAPSHOT.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
</component>
</module>
@@ -59,6 +59,7 @@
import org.yaml.snakeyaml.events.SequenceStartEvent;
import org.yaml.snakeyaml.events.StreamEndEvent;
import org.yaml.snakeyaml.events.StreamStartEvent;
+
import static org.jruby.runtime.Visibility.*;
public class PsychEmitter extends RubyObject {
@@ -122,16 +123,19 @@ public IRubyObject end_stream(ThreadContext context) {
}
@JRubyMethod
- public IRubyObject start_document(ThreadContext context, IRubyObject version, IRubyObject tags, IRubyObject implicit) {
- Integer[] versionInts = null;
+ public IRubyObject start_document(ThreadContext context, IRubyObject _version, IRubyObject tags, IRubyObject implicit) {
+ DumperOptions.Version version = null;
boolean implicitBool = implicit.isTrue();
Map<String, String> tagsMap = null;
- RubyArray versionAry = version.convertToArray();
+ RubyArray versionAry = _version.convertToArray();
if (versionAry.size() == 2) {
- versionInts = new Integer[] {1, 1};
- versionInts[0] = (int)versionAry.eltInternal(0).convertToInteger().getLongValue();
- versionInts[1] = (int)versionAry.eltInternal(1).convertToInteger().getLongValue();
+ int versionInt0 = (int)versionAry.eltInternal(0).convertToInteger().getLongValue();
+ int versionInt1 = (int)versionAry.eltInternal(1).convertToInteger().getLongValue();
+
+ if (versionInt0 != 1 && !(versionInt1 == 0 || versionInt1 == 1)) {
+ throw context.runtime.newArgumentError("invalid YAML version: " + versionAry);
+ }
}
RubyArray tagsAry = tags.convertToArray();
@@ -150,7 +154,7 @@ public IRubyObject start_document(ThreadContext context, IRubyObject version, IR
}
}
- DocumentStartEvent event = new DocumentStartEvent(NULL_MARK, NULL_MARK, !implicitBool, versionInts, tagsMap);
+ DocumentStartEvent event = new DocumentStartEvent(NULL_MARK, NULL_MARK, !implicitBool, version, tagsMap);
emit(context, event);
return this;
}
@@ -52,6 +52,7 @@
import org.jruby.util.log.Logger;
import org.jruby.util.log.LoggerFactory;
import org.jruby.util.unsafe.UnsafeFactory;
+import org.yaml.snakeyaml.DumperOptions;
import org.yaml.snakeyaml.error.Mark;
import org.yaml.snakeyaml.error.MarkedYAMLException;
import org.yaml.snakeyaml.events.AliasEvent;
@@ -206,7 +207,8 @@ public IRubyObject parse(ThreadContext context, IRubyObject yaml, IRubyObject pa
private void handleDocumentStart(ThreadContext context, DocumentStartEvent dse, boolean tainted, IRubyObject handler) {
Ruby runtime = context.runtime;
- Integer[] versionInts = dse.getVersion();
+ DumperOptions.Version _version = dse.getVersion();
+ Integer[] versionInts = _version == null ? null : _version.getArray();
IRubyObject version = versionInts == null ?
RubyArray.newArray(runtime) :
RubyArray.newArray(runtime, runtime.newFixnum(versionInts[0]), runtime.newFixnum(versionInts[1]));

0 comments on commit 900c537

Please sign in to comment.