summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorCharles Oliver Nutter <headius@headius.com>2018-04-16 10:14:44 -0500
committerCharles Oliver Nutter <headius@headius.com>2018-04-16 10:14:44 -0500
commit51f395cf7313e91a31c03053cade3641877defc7 (patch)
tree67662eb41a030431354eb0a2122adb3ee0a4881e /ext
parentfe4e4555ea86b5252f46ba6696b03a08d9f64961 (diff)
downloadpsych-51f395cf7313e91a31c03053cade3641877defc7.tar.gz
Update to SnakeYAML 1.21 to fix jruby/jruby#5098.
This will be released in Psych 3.0.3. See #352.
Diffstat (limited to 'ext')
-rw-r--r--ext/java/PsychEmitter.java22
-rw-r--r--ext/java/PsychParser.java33
2 files changed, 29 insertions, 26 deletions
diff --git a/ext/java/PsychEmitter.java b/ext/java/PsychEmitter.java
index 35eff96..2866a8a 100644
--- a/ext/java/PsychEmitter.java
+++ b/ext/java/PsychEmitter.java
@@ -202,7 +202,7 @@ public class PsychEmitter extends RubyObject {
value.asJavaString(),
NULL_MARK,
NULL_MARK,
- SCALAR_STYLES[(int)style.convertToInteger().getLongValue()]);
+ SCALAR_STYLES[style.convertToInteger().getIntValue()]);
emit(context, event);
return this;
}
@@ -222,7 +222,7 @@ public class PsychEmitter extends RubyObject {
implicit.isTrue(),
NULL_MARK,
NULL_MARK,
- SEQUENCE_BLOCK != style.convertToInteger().getLongValue());
+ SEQUENCE_BLOCK != style.convertToInteger().getLongValue() ? DumperOptions.FlowStyle.BLOCK : DumperOptions.FlowStyle.FLOW);
emit(context, event);
return this;
}
@@ -249,7 +249,7 @@ public class PsychEmitter extends RubyObject {
implicit.isTrue(),
NULL_MARK,
NULL_MARK,
- MAPPING_BLOCK != style.convertToInteger().getLongValue());
+ MAPPING_BLOCK != style.convertToInteger().getLongValue() ? DumperOptions.FlowStyle.BLOCK : DumperOptions.FlowStyle.FLOW);
emit(context, event);
return this;
}
@@ -332,16 +332,16 @@ public class PsychEmitter extends RubyObject {
DumperOptions options = new DumperOptions();
IRubyObject io;
- private static final Mark NULL_MARK = new Mark(null, 0, 0, 0, null, 0);
+ private static final Mark NULL_MARK = new Mark(null, 0, 0, 0, new int[0], 0);
// Map style constants from Psych values (ANY = 0 ... FOLDED = 5)
// to SnakeYaml values; see psych/nodes/scalar.rb.
- private static final Character[] SCALAR_STYLES = new Character[] {
- null, // ANY; we'll choose plain
- null, // PLAIN
- '\'', // SINGLE_QUOTED
- '"', // DOUBLE_QUOTED
- '|', // LITERAL
- '>', // FOLDED
+ private static final DumperOptions.ScalarStyle[] SCALAR_STYLES = new DumperOptions.ScalarStyle[] {
+ DumperOptions.ScalarStyle.PLAIN, // ANY
+ DumperOptions.ScalarStyle.PLAIN,
+ DumperOptions.ScalarStyle.SINGLE_QUOTED,
+ DumperOptions.ScalarStyle.DOUBLE_QUOTED,
+ DumperOptions.ScalarStyle.LITERAL,
+ DumperOptions.ScalarStyle.FOLDED
};
}
diff --git a/ext/java/PsychParser.java b/ext/java/PsychParser.java
index db0306b..aa6ab01 100644
--- a/ext/java/PsychParser.java
+++ b/ext/java/PsychParser.java
@@ -41,6 +41,7 @@ import org.jruby.Ruby;
import org.jruby.RubyArray;
import org.jruby.RubyClass;
import org.jruby.RubyEncoding;
+import org.jruby.RubyFixnum;
import org.jruby.RubyIO;
import org.jruby.RubyKernel;
import org.jruby.RubyModule;
@@ -359,24 +360,26 @@ public class PsychParser extends RubyObject {
RubyKernel.raise(context, runtime.getKernel(), new IRubyObject[] { exception }, Block.NULL_BLOCK);
}
- private static int translateStyle(Character style) {
+ private static int translateStyle(DumperOptions.ScalarStyle style) {
if (style == null) return 0; // any
switch (style) {
- case 0: return 1; // plain
- case '\'': return 2; // single-quoted
- case '"': return 3; // double-quoted
- case '|': return 4; // literal
- case '>': return 5; // folded
+ case PLAIN: return 1; // plain
+ case SINGLE_QUOTED: return 2; // single-quoted
+ case DOUBLE_QUOTED: return 3; // double-quoted
+ case LITERAL: return 4; // literal
+ case FOLDED: return 5; // folded
default: return 0; // any
}
}
- private static int translateFlowStyle(Boolean flowStyle) {
- if (flowStyle == null) return 0; // any
-
- if (flowStyle) return 2;
- return 1;
+ private static int translateFlowStyle(DumperOptions.FlowStyle flowStyle) {
+ switch (flowStyle) {
+ case AUTO: return 0;
+ case BLOCK: return 1;
+ case FLOW:
+ default: return 2;
+ }
}
@JRubyMethod
@@ -394,9 +397,9 @@ public class PsychParser extends RubyObject {
if (event == null) {
return ((RubyClass)context.runtime.getClassFromPath("Psych::Parser::Mark")).newInstance(
context,
- runtime.newFixnum(0),
- runtime.newFixnum(0),
- runtime.newFixnum(0),
+ RubyFixnum.zero(runtime),
+ RubyFixnum.zero(runtime),
+ RubyFixnum.zero(runtime),
Block.NULL_BLOCK
);
}
@@ -405,7 +408,7 @@ public class PsychParser extends RubyObject {
return ((RubyClass)context.runtime.getClassFromPath("Psych::Parser::Mark")).newInstance(
context,
- runtime.newFixnum(mark.getIndex()),
+ RubyFixnum.zero(runtime),
runtime.newFixnum(mark.getLine()),
runtime.newFixnum(mark.getColumn()),
Block.NULL_BLOCK