mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-04 12:43:24 +00:00
Fix handling of +/-inf defaults in TS/rust/go/dart codegen (#7588)
+/-inf were not being handled, and so invalid typescript was being generated when a float/double had an infinite default value. NaN was being handled correctly. Co-authored-by: Derek Bailey <derekbailey@google.com> Co-authored-by: Casper <casperneo@uchicago.edu>
This commit is contained in:
@@ -58,6 +58,14 @@ public class MonsterT {
|
||||
private MyGame.Example.TestT nativeInline;
|
||||
private long longEnumNonEnumDefault;
|
||||
private long longEnumNormalDefault;
|
||||
private float nanDefault;
|
||||
private float infDefault;
|
||||
private float positiveInfDefault;
|
||||
private float infinityDefault;
|
||||
private float positiveInfinityDefault;
|
||||
private float negativeInfDefault;
|
||||
private float negativeInfinityDefault;
|
||||
private double doubleInfDefault;
|
||||
|
||||
public MyGame.Example.Vec3T getPos() { return pos; }
|
||||
|
||||
@@ -259,6 +267,38 @@ public class MonsterT {
|
||||
|
||||
public void setLongEnumNormalDefault(long longEnumNormalDefault) { this.longEnumNormalDefault = longEnumNormalDefault; }
|
||||
|
||||
public float getNanDefault() { return nanDefault; }
|
||||
|
||||
public void setNanDefault(float nanDefault) { this.nanDefault = nanDefault; }
|
||||
|
||||
public float getInfDefault() { return infDefault; }
|
||||
|
||||
public void setInfDefault(float infDefault) { this.infDefault = infDefault; }
|
||||
|
||||
public float getPositiveInfDefault() { return positiveInfDefault; }
|
||||
|
||||
public void setPositiveInfDefault(float positiveInfDefault) { this.positiveInfDefault = positiveInfDefault; }
|
||||
|
||||
public float getInfinityDefault() { return infinityDefault; }
|
||||
|
||||
public void setInfinityDefault(float infinityDefault) { this.infinityDefault = infinityDefault; }
|
||||
|
||||
public float getPositiveInfinityDefault() { return positiveInfinityDefault; }
|
||||
|
||||
public void setPositiveInfinityDefault(float positiveInfinityDefault) { this.positiveInfinityDefault = positiveInfinityDefault; }
|
||||
|
||||
public float getNegativeInfDefault() { return negativeInfDefault; }
|
||||
|
||||
public void setNegativeInfDefault(float negativeInfDefault) { this.negativeInfDefault = negativeInfDefault; }
|
||||
|
||||
public float getNegativeInfinityDefault() { return negativeInfinityDefault; }
|
||||
|
||||
public void setNegativeInfinityDefault(float negativeInfinityDefault) { this.negativeInfinityDefault = negativeInfinityDefault; }
|
||||
|
||||
public double getDoubleInfDefault() { return doubleInfDefault; }
|
||||
|
||||
public void setDoubleInfDefault(double doubleInfDefault) { this.doubleInfDefault = doubleInfDefault; }
|
||||
|
||||
|
||||
public MonsterT() {
|
||||
this.pos = new MyGame.Example.Vec3T();
|
||||
@@ -311,6 +351,14 @@ public class MonsterT {
|
||||
this.nativeInline = new MyGame.Example.TestT();
|
||||
this.longEnumNonEnumDefault = 0L;
|
||||
this.longEnumNormalDefault = 2L;
|
||||
this.nanDefault = Float.NaN;
|
||||
this.infDefault = Float.POSITIVE_INFINITY;
|
||||
this.positiveInfDefault = Float.POSITIVE_INFINITY;
|
||||
this.infinityDefault = Float.POSITIVE_INFINITY;
|
||||
this.positiveInfinityDefault = Float.POSITIVE_INFINITY;
|
||||
this.negativeInfDefault = Float.NEGATIVE_INFINITY;
|
||||
this.negativeInfinityDefault = Float.NEGATIVE_INFINITY;
|
||||
this.doubleInfDefault = Double.POSITIVE_INFINITY;
|
||||
}
|
||||
public static MonsterT deserializeFromBinary(byte[] fbBuffer) {
|
||||
return Monster.getRootAsMonster(ByteBuffer.wrap(fbBuffer)).unpack();
|
||||
|
||||
Reference in New Issue
Block a user