[TS/JS] BigInt implementation (#6998)

* BigInt implementation

* Unit test reading long from existing bytebuffer

* Code review
This commit is contained in:
Alex E
2022-01-06 21:35:37 -05:00
committed by GitHub
parent f28c2b2936
commit ace4a37f22
22 changed files with 225 additions and 256 deletions

View File

@@ -291,8 +291,7 @@ class TsGenerator : public BaseGenerator {
std::string GenBBAccess() const { return "this.bb!"; } std::string GenBBAccess() const { return "this.bb!"; }
std::string GenDefaultValue(const FieldDef &field, const std::string &context, std::string GenDefaultValue(const FieldDef &field, import_set &imports) {
import_set &imports) {
if (field.IsScalarOptional()) { return "null"; } if (field.IsScalarOptional()) { return "null"; }
const auto &value = field.value; const auto &value = field.value;
@@ -319,10 +318,7 @@ class TsGenerator : public BaseGenerator {
case BASE_TYPE_LONG: case BASE_TYPE_LONG:
case BASE_TYPE_ULONG: { case BASE_TYPE_ULONG: {
int64_t constant = StringToInt(value.constant.c_str()); return "BigInt('" + value.constant + "')";
std::string createLong = context + ".createLong";
return createLong + "(" + NumToString(static_cast<int32_t>(constant)) +
", " + NumToString(static_cast<int32_t>(constant >> 32)) + ")";
} }
default: return value.constant; default: return value.constant;
@@ -348,7 +344,7 @@ class TsGenerator : public BaseGenerator {
case BASE_TYPE_BOOL: return allowNull ? "boolean|null" : "boolean"; case BASE_TYPE_BOOL: return allowNull ? "boolean|null" : "boolean";
case BASE_TYPE_LONG: case BASE_TYPE_LONG:
case BASE_TYPE_ULONG: case BASE_TYPE_ULONG:
return allowNull ? "flatbuffers.Long|null" : "flatbuffers.Long"; return allowNull ? "bigint|null" : "bigint";
default: default:
if (IsScalar(type.base_type)) { if (IsScalar(type.base_type)) {
if (type.enum_def) { if (type.enum_def) {
@@ -912,7 +908,7 @@ class TsGenerator : public BaseGenerator {
// the variable name from field_offset_decl // the variable name from field_offset_decl
std::string field_offset_val; std::string field_offset_val;
const auto field_default_val = const auto field_default_val =
GenDefaultValue(field, "flatbuffers", imports); GenDefaultValue(field, imports);
// Emit a scalar field // Emit a scalar field
const auto is_string = IsString(field.value.type); const auto is_string = IsString(field.value.type);
@@ -1232,7 +1228,7 @@ class TsGenerator : public BaseGenerator {
if (is_string) { index += ", optionalEncoding"; } if (is_string) { index += ", optionalEncoding"; }
code += offset_prefix + code += offset_prefix +
GenGetter(field.value.type, "(" + index + ")") + " : " + GenGetter(field.value.type, "(" + index + ")") + " : " +
GenDefaultValue(field, GenBBAccess(), imports); GenDefaultValue(field, imports);
code += ";\n"; code += ";\n";
} }
} }
@@ -1328,7 +1324,7 @@ class TsGenerator : public BaseGenerator {
code += "false"; code += "false";
} else if (field.value.type.element == BASE_TYPE_LONG || } else if (field.value.type.element == BASE_TYPE_LONG ||
field.value.type.element == BASE_TYPE_ULONG) { field.value.type.element == BASE_TYPE_ULONG) {
code += GenBBAccess() + ".createLong(0, 0)"; code += "BigInt(0)";
} else if (IsScalar(field.value.type.element)) { } else if (IsScalar(field.value.type.element)) {
if (field.value.type.enum_def) { if (field.value.type.enum_def) {
code += field.value.constant; code += field.value.constant;
@@ -1482,13 +1478,13 @@ class TsGenerator : public BaseGenerator {
code += "0"; code += "0";
} else if (HasNullDefault(field)) { } else if (HasNullDefault(field)) {
if (IsLong(field.value.type.base_type)) { if (IsLong(field.value.type.base_type)) {
code += "builder.createLong(0, 0)"; code += "BigInt(0)";
} else { } else {
code += "0"; code += "0";
} }
} else { } else {
if (field.value.type.base_type == BASE_TYPE_BOOL) { code += "+"; } if (field.value.type.base_type == BASE_TYPE_BOOL) { code += "+"; }
code += GenDefaultValue(field, "builder", imports); code += GenDefaultValue(field, imports);
} }
code += ");\n}\n\n"; code += ");\n}\n\n";

View File

@@ -918,7 +918,7 @@ CheckedError Parser::ParseField(StructDef &struct_def) {
} }
if (!SupportsOptionalScalars()) { if (!SupportsOptionalScalars()) {
return Error( return Error(
"Optional scalars are not yet supported in at least one the of " "Optional scalars are not yet supported in at least one of "
"the specified programming languages."); "the specified programming languages.");
} }
} }

View File

@@ -73,6 +73,11 @@ function createMonster(fbb) {
fbb.createString('test2') fbb.createString('test2')
]); ]);
var testVectorOfLongs = Monster.createVectorOfLongsVector(fbb, [
1n,
101010100n
]);
Monster.startMonster(fbb); Monster.startMonster(fbb);
Monster.addPos(fbb, Vec3.createVec3(fbb, 1, 2, 3, 3, Color.Green, 5, 6)); Monster.addPos(fbb, Vec3.createVec3(fbb, 1, 2, 3, 3, Color.Green, 5, 6));
Monster.addHp(fbb, 80); Monster.addHp(fbb, 80);
@@ -82,6 +87,7 @@ function createMonster(fbb) {
Monster.addTest(fbb, mon2); Monster.addTest(fbb, mon2);
Monster.addTest4(fbb, test4); Monster.addTest4(fbb, test4);
Monster.addTestarrayofstring(fbb, testArrayOfString); Monster.addTestarrayofstring(fbb, testArrayOfString);
Monster.addVectorOfLongs(fbb, testVectorOfLongs);
Monster.addTestbool(fbb, true); Monster.addTestbool(fbb, true);
var mon = Monster.endMonster(fbb); var mon = Monster.endMonster(fbb);
@@ -94,7 +100,7 @@ function serializeAndTest(fbb) {
// parser may serialize in a slightly different order than the above // parser may serialize in a slightly different order than the above
// JavaScript code. They are functionally equivalent though. // JavaScript code. They are functionally equivalent though.
fs.writeFileSync('monsterdata_javascript_wire.mon', new Buffer(fbb.asUint8Array())); fs.writeFileSync('monsterdata_javascript_wire.mon', Buffer.from(fbb.asUint8Array()));
// Tests mutation first. This will verify that we did not trample any other // Tests mutation first. This will verify that we did not trample any other
// part of the byte buffer. // part of the byte buffer.
@@ -207,6 +213,12 @@ function testBuffer(bb) {
} }
assert.strictEqual(invsum2, 10); assert.strictEqual(invsum2, 10);
let longSum = 0n;
for (let idx = 0; idx < monster.vectorOfLongsLength(); ++idx) {
longSum += monster.vectorOfLongs(idx);
}
assert.strictEqual(longSum, 101010101n);
var test_0 = monster.test4(0); var test_0 = monster.test4(0);
var test_1 = monster.test4(1); var test_1 = monster.test4(1);
assert.strictEqual(monster.test4Length(), 2); assert.strictEqual(monster.test4Length(), 2);
@@ -239,8 +251,8 @@ function test64bit() {
var mon2 = Monster.endMonster(fbb); var mon2 = Monster.endMonster(fbb);
Stat.startStat(fbb); Stat.startStat(fbb);
// 2541551405100253985 = 0x87654321(low part) + 0x23456789 * 0x100000000(high part); // 2541551405100253985 = 0x2345678987654321
Stat.addVal(fbb, new flatbuffers.Long(0x87654321, 0x23456789)); // the low part is Uint32 Stat.addVal(fbb, 0x2345678987654321n);
var stat = Stat.endStat(fbb); var stat = Stat.endStat(fbb);
Monster.startMonster(fbb); Monster.startMonster(fbb);
@@ -261,15 +273,14 @@ function test64bit() {
var stat = mon.testempty(); var stat = mon.testempty();
assert.strictEqual(stat != null, true); assert.strictEqual(stat != null, true);
assert.strictEqual(stat.val() != null, true); assert.strictEqual(stat.val() != null, true);
assert.strictEqual(stat.val().toFloat64(), 2541551405100253985); assert.strictEqual(stat.val(), 2541551405100253985n);
var mon2 = mon.enemy(); var mon2 = mon.enemy();
assert.strictEqual(mon2 != null, true); assert.strictEqual(mon2 != null, true);
stat = mon2.testempty(); stat = mon2.testempty();
assert.strictEqual(stat != null, true); assert.strictEqual(stat != null, true);
assert.strictEqual(stat.val() != null, true); assert.strictEqual(stat.val() != null, true);
assert.strictEqual(stat.val().low, 0); // default value assert.strictEqual(stat.val(), 0n); // default value
assert.strictEqual(stat.val().high, 0);
} }
function testUnicode() { function testUnicode() {
@@ -280,17 +291,17 @@ function testUnicode() {
function testReadingUnicode(bb) { function testReadingUnicode(bb) {
var monster = Monster.getRootAsMonster(bb); var monster = Monster.getRootAsMonster(bb);
assert.strictEqual(monster.name(), json.name); assert.strictEqual(monster.name(), json.name);
assert.deepEqual(new Buffer(monster.name(flatbuffers.Encoding.UTF8_BYTES)), new Buffer(json.name)); assert.deepEqual(Buffer.from(monster.name(flatbuffers.Encoding.UTF8_BYTES)), Buffer.from(json.name));
assert.strictEqual(monster.testarrayoftablesLength(), json.testarrayoftables.length); assert.strictEqual(monster.testarrayoftablesLength(), json.testarrayoftables.length);
json.testarrayoftables.forEach(function(table, i) { json.testarrayoftables.forEach(function(table, i) {
var value = monster.testarrayoftables(i); var value = monster.testarrayoftables(i);
assert.strictEqual(value.name(), table.name); assert.strictEqual(value.name(), table.name);
assert.deepEqual(new Buffer(value.name(flatbuffers.Encoding.UTF8_BYTES)), new Buffer(table.name)); assert.deepEqual(Buffer.from(value.name(flatbuffers.Encoding.UTF8_BYTES)), Buffer.from(table.name));
}); });
assert.strictEqual(monster.testarrayofstringLength(), json.testarrayofstring.length); assert.strictEqual(monster.testarrayofstringLength(), json.testarrayofstring.length);
json.testarrayofstring.forEach(function(string, i) { json.testarrayofstring.forEach(function(string, i) {
assert.strictEqual(monster.testarrayofstring(i), string); assert.strictEqual(monster.testarrayofstring(i), string);
assert.deepEqual(new Buffer(monster.testarrayofstring(i, flatbuffers.Encoding.UTF8_BYTES)), new Buffer(string)); assert.deepEqual(Buffer.from(monster.testarrayofstring(i, flatbuffers.Encoding.UTF8_BYTES)), Buffer.from(string));
}); });
} }
testReadingUnicode(new flatbuffers.ByteBuffer(new Uint8Array(correct))); testReadingUnicode(new flatbuffers.ByteBuffer(new Uint8Array(correct)));
@@ -299,7 +310,7 @@ function testUnicode() {
var fbb = new flatbuffers.Builder(); var fbb = new flatbuffers.Builder();
var name = fbb.createString(json.name); var name = fbb.createString(json.name);
var testarrayoftablesOffsets = json.testarrayoftables.map(function(table) { var testarrayoftablesOffsets = json.testarrayoftables.map(function(table) {
var name = fbb.createString(new Uint8Array(new Buffer(table.name))); var name = fbb.createString(new Uint8Array(Buffer.from(table.name)));
Monster.startMonster(fbb); Monster.startMonster(fbb);
Monster.addName(fbb, name); Monster.addName(fbb, name);
return Monster.endMonster(fbb); return Monster.endMonster(fbb);
@@ -359,8 +370,8 @@ function fuzzTest1() {
var ushort_val = 0xFEEE; var ushort_val = 0xFEEE;
var int_val = 0x83333333 | 0; var int_val = 0x83333333 | 0;
var uint_val = 0xFDDDDDDD; var uint_val = 0xFDDDDDDD;
var long_val = new flatbuffers.Long(0x44444444, 0x84444444); var long_val = BigInt.asIntN(64, 0x8444444444444444n);
var ulong_val = new flatbuffers.Long(0xCCCCCCCC, 0xFCCCCCCC); var ulong_val = BigInt.asUintN(64, 0xFCCCCCCCCCCCCCCCn);
var float_val = new Float32Array([3.14159])[0]; var float_val = new Float32Array([3.14159])[0];
var double_val = 3.14159265359; var double_val = 3.14159265359;
@@ -381,16 +392,16 @@ function fuzzTest1() {
for (var f = 0; f < fields_per_object; f++) { for (var f = 0; f < fields_per_object; f++) {
var choice = lcg_rand() % test_values_max; var choice = lcg_rand() % test_values_max;
switch (choice) { switch (choice) {
case 0: builder.addFieldInt8(f, bool_val, 0); break; case 0: builder.addFieldInt8(f, bool_val, 0); break;
case 1: builder.addFieldInt8(f, char_val, 0); break; case 1: builder.addFieldInt8(f, char_val, 0); break;
case 2: builder.addFieldInt8(f, uchar_val, 0); break; case 2: builder.addFieldInt8(f, uchar_val, 0); break;
case 3: builder.addFieldInt16(f, short_val, 0); break; case 3: builder.addFieldInt16(f, short_val, 0); break;
case 4: builder.addFieldInt16(f, ushort_val, 0); break; case 4: builder.addFieldInt16(f, ushort_val, 0); break;
case 5: builder.addFieldInt32(f, int_val, 0); break; case 5: builder.addFieldInt32(f, int_val, 0); break;
case 6: builder.addFieldInt32(f, uint_val, 0); break; case 6: builder.addFieldInt32(f, uint_val, 0); break;
case 7: builder.addFieldInt64(f, long_val, flatbuffers.Long.ZERO); break; case 7: builder.addFieldInt64(f, long_val, 0n); break;
case 8: builder.addFieldInt64(f, ulong_val, flatbuffers.Long.ZERO); break; case 8: builder.addFieldInt64(f, ulong_val, 0n); break;
case 9: builder.addFieldFloat32(f, float_val, 0); break; case 9: builder.addFieldFloat32(f, float_val, 0); break;
case 10: builder.addFieldFloat64(f, double_val, 0); break; case 10: builder.addFieldFloat64(f, double_val, 0); break;
} }
} }
@@ -423,8 +434,8 @@ function fuzzTest1() {
case 4: assert.strictEqual(view.getUint16(field_offset, true), ushort_val); break; case 4: assert.strictEqual(view.getUint16(field_offset, true), ushort_val); break;
case 5: assert.strictEqual(view.getInt32(field_offset, true), int_val); break; case 5: assert.strictEqual(view.getInt32(field_offset, true), int_val); break;
case 6: assert.strictEqual(view.getUint32(field_offset, true), uint_val); break; case 6: assert.strictEqual(view.getUint32(field_offset, true), uint_val); break;
case 7: assert.strictEqual(view.getInt32(field_offset, true), long_val.low); assert.strictEqual(view.getInt32(field_offset + 4, true), long_val.high); break; case 7: assert.strictEqual(view.getBigInt64(field_offset, true), long_val); break;
case 8: assert.strictEqual(view.getInt32(field_offset, true), ulong_val.low); assert.strictEqual(view.getInt32(field_offset + 4, true), ulong_val.high); break; case 8: assert.strictEqual(view.getBigUint64(field_offset, true), ulong_val); break;
case 9: assert.strictEqual(view.getFloat32(field_offset, true), float_val); break; case 9: assert.strictEqual(view.getFloat32(field_offset, true), float_val); break;
case 10: assert.strictEqual(view.getFloat64(field_offset, true), double_val); break; case 10: assert.strictEqual(view.getFloat64(field_offset, true), double_val); break;
} }

View File

@@ -2,6 +2,7 @@ npm install
../flatc.exe --ts --gen-name-strings --gen-mutable --gen-object-api -I include_test monster_test.fbs ../flatc.exe --ts --gen-name-strings --gen-mutable --gen-object-api -I include_test monster_test.fbs
../flatc.exe --gen-object-api -b -I include_test monster_test.fbs unicode_test.json ../flatc.exe --gen-object-api -b -I include_test monster_test.fbs unicode_test.json
../flatc.exe --ts --gen-name-strings --gen-mutable --gen-object-api -o union_vector union_vector/union_vector.fbs ../flatc.exe --ts --gen-name-strings --gen-mutable --gen-object-api -o union_vector union_vector/union_vector.fbs
../flatc.exe --ts --gen-name-strings optional_scalars.fbs
tsc tsc
node -r esm JavaScriptTest node -r esm JavaScriptTest
node -r esm JavaScriptUnionVectorTest node -r esm JavaScriptUnionVectorTest

View File

@@ -24,6 +24,7 @@ if [ -x ../flatc ]; then
../flatc --ts --gen-name-strings --gen-mutable --gen-object-api -I include_test monster_test.fbs ../flatc --ts --gen-name-strings --gen-mutable --gen-object-api -I include_test monster_test.fbs
../flatc --gen-object-api -b -I include_test monster_test.fbs unicode_test.json ../flatc --gen-object-api -b -I include_test monster_test.fbs unicode_test.json
../flatc --ts --gen-name-strings --gen-mutable --gen-object-api -o union_vector union_vector/union_vector.fbs ../flatc --ts --gen-name-strings --gen-mutable --gen-object-api -o union_vector union_vector/union_vector.fbs
../flatc --ts --gen-name-strings optional_scalars.fbs
fi fi
tsc tsc
node -r esm JavaScriptTest node -r esm JavaScriptTest

View File

@@ -184,7 +184,7 @@ export class Monster {
} }
testhashs64Fnv1() { testhashs64Fnv1() {
const offset = this.bb.__offset(this.bb_pos, 40); const offset = this.bb.__offset(this.bb_pos, 40);
return offset ? this.bb.readInt64(this.bb_pos + offset) : this.bb.createLong(0, 0); return offset ? this.bb.readInt64(this.bb_pos + offset) : BigInt('0');
} }
mutate_testhashs64_fnv1(value) { mutate_testhashs64_fnv1(value) {
const offset = this.bb.__offset(this.bb_pos, 40); const offset = this.bb.__offset(this.bb_pos, 40);
@@ -196,7 +196,7 @@ export class Monster {
} }
testhashu64Fnv1() { testhashu64Fnv1() {
const offset = this.bb.__offset(this.bb_pos, 42); const offset = this.bb.__offset(this.bb_pos, 42);
return offset ? this.bb.readUint64(this.bb_pos + offset) : this.bb.createLong(0, 0); return offset ? this.bb.readUint64(this.bb_pos + offset) : BigInt('0');
} }
mutate_testhashu64_fnv1(value) { mutate_testhashu64_fnv1(value) {
const offset = this.bb.__offset(this.bb_pos, 42); const offset = this.bb.__offset(this.bb_pos, 42);
@@ -232,7 +232,7 @@ export class Monster {
} }
testhashs64Fnv1a() { testhashs64Fnv1a() {
const offset = this.bb.__offset(this.bb_pos, 48); const offset = this.bb.__offset(this.bb_pos, 48);
return offset ? this.bb.readInt64(this.bb_pos + offset) : this.bb.createLong(0, 0); return offset ? this.bb.readInt64(this.bb_pos + offset) : BigInt('0');
} }
mutate_testhashs64_fnv1a(value) { mutate_testhashs64_fnv1a(value) {
const offset = this.bb.__offset(this.bb_pos, 48); const offset = this.bb.__offset(this.bb_pos, 48);
@@ -244,7 +244,7 @@ export class Monster {
} }
testhashu64Fnv1a() { testhashu64Fnv1a() {
const offset = this.bb.__offset(this.bb_pos, 50); const offset = this.bb.__offset(this.bb_pos, 50);
return offset ? this.bb.readUint64(this.bb_pos + offset) : this.bb.createLong(0, 0); return offset ? this.bb.readUint64(this.bb_pos + offset) : BigInt('0');
} }
mutate_testhashu64_fnv1a(value) { mutate_testhashu64_fnv1a(value) {
const offset = this.bb.__offset(this.bb_pos, 50); const offset = this.bb.__offset(this.bb_pos, 50);
@@ -340,7 +340,7 @@ export class Monster {
} }
vectorOfLongs(index) { vectorOfLongs(index) {
const offset = this.bb.__offset(this.bb_pos, 68); const offset = this.bb.__offset(this.bb_pos, 68);
return offset ? this.bb.readInt64(this.bb.__vector(this.bb_pos + offset) + index * 8) : this.bb.createLong(0, 0); return offset ? this.bb.readInt64(this.bb.__vector(this.bb_pos + offset) + index * 8) : BigInt(0);
} }
vectorOfLongsLength() { vectorOfLongsLength() {
const offset = this.bb.__offset(this.bb_pos, 68); const offset = this.bb.__offset(this.bb_pos, 68);
@@ -372,7 +372,7 @@ export class Monster {
} }
singleWeakReference() { singleWeakReference() {
const offset = this.bb.__offset(this.bb_pos, 76); const offset = this.bb.__offset(this.bb_pos, 76);
return offset ? this.bb.readUint64(this.bb_pos + offset) : this.bb.createLong(0, 0); return offset ? this.bb.readUint64(this.bb_pos + offset) : BigInt('0');
} }
mutate_single_weak_reference(value) { mutate_single_weak_reference(value) {
const offset = this.bb.__offset(this.bb_pos, 76); const offset = this.bb.__offset(this.bb_pos, 76);
@@ -384,7 +384,7 @@ export class Monster {
} }
vectorOfWeakReferences(index) { vectorOfWeakReferences(index) {
const offset = this.bb.__offset(this.bb_pos, 78); const offset = this.bb.__offset(this.bb_pos, 78);
return offset ? this.bb.readUint64(this.bb.__vector(this.bb_pos + offset) + index * 8) : this.bb.createLong(0, 0); return offset ? this.bb.readUint64(this.bb.__vector(this.bb_pos + offset) + index * 8) : BigInt(0);
} }
vectorOfWeakReferencesLength() { vectorOfWeakReferencesLength() {
const offset = this.bb.__offset(this.bb_pos, 78); const offset = this.bb.__offset(this.bb_pos, 78);
@@ -400,7 +400,7 @@ export class Monster {
} }
coOwningReference() { coOwningReference() {
const offset = this.bb.__offset(this.bb_pos, 82); const offset = this.bb.__offset(this.bb_pos, 82);
return offset ? this.bb.readUint64(this.bb_pos + offset) : this.bb.createLong(0, 0); return offset ? this.bb.readUint64(this.bb_pos + offset) : BigInt('0');
} }
mutate_co_owning_reference(value) { mutate_co_owning_reference(value) {
const offset = this.bb.__offset(this.bb_pos, 82); const offset = this.bb.__offset(this.bb_pos, 82);
@@ -412,7 +412,7 @@ export class Monster {
} }
vectorOfCoOwningReferences(index) { vectorOfCoOwningReferences(index) {
const offset = this.bb.__offset(this.bb_pos, 84); const offset = this.bb.__offset(this.bb_pos, 84);
return offset ? this.bb.readUint64(this.bb.__vector(this.bb_pos + offset) + index * 8) : this.bb.createLong(0, 0); return offset ? this.bb.readUint64(this.bb.__vector(this.bb_pos + offset) + index * 8) : BigInt(0);
} }
vectorOfCoOwningReferencesLength() { vectorOfCoOwningReferencesLength() {
const offset = this.bb.__offset(this.bb_pos, 84); const offset = this.bb.__offset(this.bb_pos, 84);
@@ -420,7 +420,7 @@ export class Monster {
} }
nonOwningReference() { nonOwningReference() {
const offset = this.bb.__offset(this.bb_pos, 86); const offset = this.bb.__offset(this.bb_pos, 86);
return offset ? this.bb.readUint64(this.bb_pos + offset) : this.bb.createLong(0, 0); return offset ? this.bb.readUint64(this.bb_pos + offset) : BigInt('0');
} }
mutate_non_owning_reference(value) { mutate_non_owning_reference(value) {
const offset = this.bb.__offset(this.bb_pos, 86); const offset = this.bb.__offset(this.bb_pos, 86);
@@ -432,7 +432,7 @@ export class Monster {
} }
vectorOfNonOwningReferences(index) { vectorOfNonOwningReferences(index) {
const offset = this.bb.__offset(this.bb_pos, 88); const offset = this.bb.__offset(this.bb_pos, 88);
return offset ? this.bb.readUint64(this.bb.__vector(this.bb_pos + offset) + index * 8) : this.bb.createLong(0, 0); return offset ? this.bb.readUint64(this.bb.__vector(this.bb_pos + offset) + index * 8) : BigInt(0);
} }
vectorOfNonOwningReferencesLength() { vectorOfNonOwningReferencesLength() {
const offset = this.bb.__offset(this.bb_pos, 88); const offset = this.bb.__offset(this.bb_pos, 88);
@@ -599,10 +599,10 @@ export class Monster {
builder.addFieldInt32(17, testhashu32Fnv1, 0); builder.addFieldInt32(17, testhashu32Fnv1, 0);
} }
static addTesthashs64Fnv1(builder, testhashs64Fnv1) { static addTesthashs64Fnv1(builder, testhashs64Fnv1) {
builder.addFieldInt64(18, testhashs64Fnv1, builder.createLong(0, 0)); builder.addFieldInt64(18, testhashs64Fnv1, BigInt('0'));
} }
static addTesthashu64Fnv1(builder, testhashu64Fnv1) { static addTesthashu64Fnv1(builder, testhashu64Fnv1) {
builder.addFieldInt64(19, testhashu64Fnv1, builder.createLong(0, 0)); builder.addFieldInt64(19, testhashu64Fnv1, BigInt('0'));
} }
static addTesthashs32Fnv1a(builder, testhashs32Fnv1a) { static addTesthashs32Fnv1a(builder, testhashs32Fnv1a) {
builder.addFieldInt32(20, testhashs32Fnv1a, 0); builder.addFieldInt32(20, testhashs32Fnv1a, 0);
@@ -611,10 +611,10 @@ export class Monster {
builder.addFieldInt32(21, testhashu32Fnv1a, 0); builder.addFieldInt32(21, testhashu32Fnv1a, 0);
} }
static addTesthashs64Fnv1a(builder, testhashs64Fnv1a) { static addTesthashs64Fnv1a(builder, testhashs64Fnv1a) {
builder.addFieldInt64(22, testhashs64Fnv1a, builder.createLong(0, 0)); builder.addFieldInt64(22, testhashs64Fnv1a, BigInt('0'));
} }
static addTesthashu64Fnv1a(builder, testhashu64Fnv1a) { static addTesthashu64Fnv1a(builder, testhashu64Fnv1a) {
builder.addFieldInt64(23, testhashu64Fnv1a, builder.createLong(0, 0)); builder.addFieldInt64(23, testhashu64Fnv1a, BigInt('0'));
} }
static addTestarrayofbools(builder, testarrayofboolsOffset) { static addTestarrayofbools(builder, testarrayofboolsOffset) {
builder.addFieldOffset(24, testarrayofboolsOffset, 0); builder.addFieldOffset(24, testarrayofboolsOffset, 0);
@@ -719,7 +719,7 @@ export class Monster {
builder.startVector(4, numElems, 4); builder.startVector(4, numElems, 4);
} }
static addSingleWeakReference(builder, singleWeakReference) { static addSingleWeakReference(builder, singleWeakReference) {
builder.addFieldInt64(36, singleWeakReference, builder.createLong(0, 0)); builder.addFieldInt64(36, singleWeakReference, BigInt('0'));
} }
static addVectorOfWeakReferences(builder, vectorOfWeakReferencesOffset) { static addVectorOfWeakReferences(builder, vectorOfWeakReferencesOffset) {
builder.addFieldOffset(37, vectorOfWeakReferencesOffset, 0); builder.addFieldOffset(37, vectorOfWeakReferencesOffset, 0);
@@ -748,7 +748,7 @@ export class Monster {
builder.startVector(4, numElems, 4); builder.startVector(4, numElems, 4);
} }
static addCoOwningReference(builder, coOwningReference) { static addCoOwningReference(builder, coOwningReference) {
builder.addFieldInt64(39, coOwningReference, builder.createLong(0, 0)); builder.addFieldInt64(39, coOwningReference, BigInt('0'));
} }
static addVectorOfCoOwningReferences(builder, vectorOfCoOwningReferencesOffset) { static addVectorOfCoOwningReferences(builder, vectorOfCoOwningReferencesOffset) {
builder.addFieldOffset(40, vectorOfCoOwningReferencesOffset, 0); builder.addFieldOffset(40, vectorOfCoOwningReferencesOffset, 0);
@@ -764,7 +764,7 @@ export class Monster {
builder.startVector(8, numElems, 8); builder.startVector(8, numElems, 8);
} }
static addNonOwningReference(builder, nonOwningReference) { static addNonOwningReference(builder, nonOwningReference) {
builder.addFieldInt64(41, nonOwningReference, builder.createLong(0, 0)); builder.addFieldInt64(41, nonOwningReference, BigInt('0'));
} }
static addVectorOfNonOwningReferences(builder, vectorOfNonOwningReferencesOffset) { static addVectorOfNonOwningReferences(builder, vectorOfNonOwningReferencesOffset) {
builder.addFieldOffset(42, vectorOfNonOwningReferencesOffset, 0); builder.addFieldOffset(42, vectorOfNonOwningReferencesOffset, 0);
@@ -943,7 +943,7 @@ export class Monster {
} }
} }
export class MonsterT { export class MonsterT {
constructor(pos = null, mana = 150, hp = 100, name = null, inventory = [], color = Color.Blue, testType = Any.NONE, test = null, test4 = [], testarrayofstring = [], testarrayoftables = [], enemy = null, testnestedflatbuffer = [], testempty = null, testbool = false, testhashs32Fnv1 = 0, testhashu32Fnv1 = 0, testhashs64Fnv1 = flatbuffers.createLong(0, 0), testhashu64Fnv1 = flatbuffers.createLong(0, 0), testhashs32Fnv1a = 0, testhashu32Fnv1a = 0, testhashs64Fnv1a = flatbuffers.createLong(0, 0), testhashu64Fnv1a = flatbuffers.createLong(0, 0), testarrayofbools = [], testf = 3.14159, testf2 = 3.0, testf3 = 0.0, testarrayofstring2 = [], testarrayofsortedstruct = [], flex = [], test5 = [], vectorOfLongs = [], vectorOfDoubles = [], parentNamespaceTest = null, vectorOfReferrables = [], singleWeakReference = flatbuffers.createLong(0, 0), vectorOfWeakReferences = [], vectorOfStrongReferrables = [], coOwningReference = flatbuffers.createLong(0, 0), vectorOfCoOwningReferences = [], nonOwningReference = flatbuffers.createLong(0, 0), vectorOfNonOwningReferences = [], anyUniqueType = AnyUniqueAliases.NONE, anyUnique = null, anyAmbiguousType = AnyAmbiguousAliases.NONE, anyAmbiguous = null, vectorOfEnums = [], signedEnum = Race.None, testrequirednestedflatbuffer = [], scalarKeySortedTables = []) { constructor(pos = null, mana = 150, hp = 100, name = null, inventory = [], color = Color.Blue, testType = Any.NONE, test = null, test4 = [], testarrayofstring = [], testarrayoftables = [], enemy = null, testnestedflatbuffer = [], testempty = null, testbool = false, testhashs32Fnv1 = 0, testhashu32Fnv1 = 0, testhashs64Fnv1 = BigInt('0'), testhashu64Fnv1 = BigInt('0'), testhashs32Fnv1a = 0, testhashu32Fnv1a = 0, testhashs64Fnv1a = BigInt('0'), testhashu64Fnv1a = BigInt('0'), testarrayofbools = [], testf = 3.14159, testf2 = 3.0, testf3 = 0.0, testarrayofstring2 = [], testarrayofsortedstruct = [], flex = [], test5 = [], vectorOfLongs = [], vectorOfDoubles = [], parentNamespaceTest = null, vectorOfReferrables = [], singleWeakReference = BigInt('0'), vectorOfWeakReferences = [], vectorOfStrongReferrables = [], coOwningReference = BigInt('0'), vectorOfCoOwningReferences = [], nonOwningReference = BigInt('0'), vectorOfNonOwningReferences = [], anyUniqueType = AnyUniqueAliases.NONE, anyUnique = null, anyAmbiguousType = AnyAmbiguousAliases.NONE, anyAmbiguous = null, vectorOfEnums = [], signedEnum = Race.None, testrequirednestedflatbuffer = [], scalarKeySortedTables = []) {
this.pos = pos; this.pos = pos;
this.mana = mana; this.mana = mana;
this.hp = hp; this.hp = hp;

View File

@@ -236,12 +236,12 @@ mutate_testhashu32_fnv1(value:number):boolean {
return true; return true;
} }
testhashs64Fnv1():flatbuffers.Long { testhashs64Fnv1():bigint {
const offset = this.bb!.__offset(this.bb_pos, 40); const offset = this.bb!.__offset(this.bb_pos, 40);
return offset ? this.bb!.readInt64(this.bb_pos + offset) : this.bb!.createLong(0, 0); return offset ? this.bb!.readInt64(this.bb_pos + offset) : BigInt('0');
} }
mutate_testhashs64_fnv1(value:flatbuffers.Long):boolean { mutate_testhashs64_fnv1(value:bigint):boolean {
const offset = this.bb!.__offset(this.bb_pos, 40); const offset = this.bb!.__offset(this.bb_pos, 40);
if (offset === 0) { if (offset === 0) {
@@ -252,12 +252,12 @@ mutate_testhashs64_fnv1(value:flatbuffers.Long):boolean {
return true; return true;
} }
testhashu64Fnv1():flatbuffers.Long { testhashu64Fnv1():bigint {
const offset = this.bb!.__offset(this.bb_pos, 42); const offset = this.bb!.__offset(this.bb_pos, 42);
return offset ? this.bb!.readUint64(this.bb_pos + offset) : this.bb!.createLong(0, 0); return offset ? this.bb!.readUint64(this.bb_pos + offset) : BigInt('0');
} }
mutate_testhashu64_fnv1(value:flatbuffers.Long):boolean { mutate_testhashu64_fnv1(value:bigint):boolean {
const offset = this.bb!.__offset(this.bb_pos, 42); const offset = this.bb!.__offset(this.bb_pos, 42);
if (offset === 0) { if (offset === 0) {
@@ -300,12 +300,12 @@ mutate_testhashu32_fnv1a(value:number):boolean {
return true; return true;
} }
testhashs64Fnv1a():flatbuffers.Long { testhashs64Fnv1a():bigint {
const offset = this.bb!.__offset(this.bb_pos, 48); const offset = this.bb!.__offset(this.bb_pos, 48);
return offset ? this.bb!.readInt64(this.bb_pos + offset) : this.bb!.createLong(0, 0); return offset ? this.bb!.readInt64(this.bb_pos + offset) : BigInt('0');
} }
mutate_testhashs64_fnv1a(value:flatbuffers.Long):boolean { mutate_testhashs64_fnv1a(value:bigint):boolean {
const offset = this.bb!.__offset(this.bb_pos, 48); const offset = this.bb!.__offset(this.bb_pos, 48);
if (offset === 0) { if (offset === 0) {
@@ -316,12 +316,12 @@ mutate_testhashs64_fnv1a(value:flatbuffers.Long):boolean {
return true; return true;
} }
testhashu64Fnv1a():flatbuffers.Long { testhashu64Fnv1a():bigint {
const offset = this.bb!.__offset(this.bb_pos, 50); const offset = this.bb!.__offset(this.bb_pos, 50);
return offset ? this.bb!.readUint64(this.bb_pos + offset) : this.bb!.createLong(0, 0); return offset ? this.bb!.readUint64(this.bb_pos + offset) : BigInt('0');
} }
mutate_testhashu64_fnv1a(value:flatbuffers.Long):boolean { mutate_testhashu64_fnv1a(value:bigint):boolean {
const offset = this.bb!.__offset(this.bb_pos, 50); const offset = this.bb!.__offset(this.bb_pos, 50);
if (offset === 0) { if (offset === 0) {
@@ -442,9 +442,9 @@ test5Length():number {
return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
} }
vectorOfLongs(index: number):flatbuffers.Long|null { vectorOfLongs(index: number):bigint|null {
const offset = this.bb!.__offset(this.bb_pos, 68); const offset = this.bb!.__offset(this.bb_pos, 68);
return offset ? this.bb!.readInt64(this.bb!.__vector(this.bb_pos + offset) + index * 8) : this.bb!.createLong(0, 0); return offset ? this.bb!.readInt64(this.bb!.__vector(this.bb_pos + offset) + index * 8) : BigInt(0);
} }
vectorOfLongsLength():number { vectorOfLongsLength():number {
@@ -482,12 +482,12 @@ vectorOfReferrablesLength():number {
return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
} }
singleWeakReference():flatbuffers.Long { singleWeakReference():bigint {
const offset = this.bb!.__offset(this.bb_pos, 76); const offset = this.bb!.__offset(this.bb_pos, 76);
return offset ? this.bb!.readUint64(this.bb_pos + offset) : this.bb!.createLong(0, 0); return offset ? this.bb!.readUint64(this.bb_pos + offset) : BigInt('0');
} }
mutate_single_weak_reference(value:flatbuffers.Long):boolean { mutate_single_weak_reference(value:bigint):boolean {
const offset = this.bb!.__offset(this.bb_pos, 76); const offset = this.bb!.__offset(this.bb_pos, 76);
if (offset === 0) { if (offset === 0) {
@@ -498,9 +498,9 @@ mutate_single_weak_reference(value:flatbuffers.Long):boolean {
return true; return true;
} }
vectorOfWeakReferences(index: number):flatbuffers.Long|null { vectorOfWeakReferences(index: number):bigint|null {
const offset = this.bb!.__offset(this.bb_pos, 78); const offset = this.bb!.__offset(this.bb_pos, 78);
return offset ? this.bb!.readUint64(this.bb!.__vector(this.bb_pos + offset) + index * 8) : this.bb!.createLong(0, 0); return offset ? this.bb!.readUint64(this.bb!.__vector(this.bb_pos + offset) + index * 8) : BigInt(0);
} }
vectorOfWeakReferencesLength():number { vectorOfWeakReferencesLength():number {
@@ -518,12 +518,12 @@ vectorOfStrongReferrablesLength():number {
return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
} }
coOwningReference():flatbuffers.Long { coOwningReference():bigint {
const offset = this.bb!.__offset(this.bb_pos, 82); const offset = this.bb!.__offset(this.bb_pos, 82);
return offset ? this.bb!.readUint64(this.bb_pos + offset) : this.bb!.createLong(0, 0); return offset ? this.bb!.readUint64(this.bb_pos + offset) : BigInt('0');
} }
mutate_co_owning_reference(value:flatbuffers.Long):boolean { mutate_co_owning_reference(value:bigint):boolean {
const offset = this.bb!.__offset(this.bb_pos, 82); const offset = this.bb!.__offset(this.bb_pos, 82);
if (offset === 0) { if (offset === 0) {
@@ -534,9 +534,9 @@ mutate_co_owning_reference(value:flatbuffers.Long):boolean {
return true; return true;
} }
vectorOfCoOwningReferences(index: number):flatbuffers.Long|null { vectorOfCoOwningReferences(index: number):bigint|null {
const offset = this.bb!.__offset(this.bb_pos, 84); const offset = this.bb!.__offset(this.bb_pos, 84);
return offset ? this.bb!.readUint64(this.bb!.__vector(this.bb_pos + offset) + index * 8) : this.bb!.createLong(0, 0); return offset ? this.bb!.readUint64(this.bb!.__vector(this.bb_pos + offset) + index * 8) : BigInt(0);
} }
vectorOfCoOwningReferencesLength():number { vectorOfCoOwningReferencesLength():number {
@@ -544,12 +544,12 @@ vectorOfCoOwningReferencesLength():number {
return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
} }
nonOwningReference():flatbuffers.Long { nonOwningReference():bigint {
const offset = this.bb!.__offset(this.bb_pos, 86); const offset = this.bb!.__offset(this.bb_pos, 86);
return offset ? this.bb!.readUint64(this.bb_pos + offset) : this.bb!.createLong(0, 0); return offset ? this.bb!.readUint64(this.bb_pos + offset) : BigInt('0');
} }
mutate_non_owning_reference(value:flatbuffers.Long):boolean { mutate_non_owning_reference(value:bigint):boolean {
const offset = this.bb!.__offset(this.bb_pos, 86); const offset = this.bb!.__offset(this.bb_pos, 86);
if (offset === 0) { if (offset === 0) {
@@ -560,9 +560,9 @@ mutate_non_owning_reference(value:flatbuffers.Long):boolean {
return true; return true;
} }
vectorOfNonOwningReferences(index: number):flatbuffers.Long|null { vectorOfNonOwningReferences(index: number):bigint|null {
const offset = this.bb!.__offset(this.bb_pos, 88); const offset = this.bb!.__offset(this.bb_pos, 88);
return offset ? this.bb!.readUint64(this.bb!.__vector(this.bb_pos + offset) + index * 8) : this.bb!.createLong(0, 0); return offset ? this.bb!.readUint64(this.bb!.__vector(this.bb_pos + offset) + index * 8) : BigInt(0);
} }
vectorOfNonOwningReferencesLength():number { vectorOfNonOwningReferencesLength():number {
@@ -774,12 +774,12 @@ static addTesthashu32Fnv1(builder:flatbuffers.Builder, testhashu32Fnv1:number) {
builder.addFieldInt32(17, testhashu32Fnv1, 0); builder.addFieldInt32(17, testhashu32Fnv1, 0);
} }
static addTesthashs64Fnv1(builder:flatbuffers.Builder, testhashs64Fnv1:flatbuffers.Long) { static addTesthashs64Fnv1(builder:flatbuffers.Builder, testhashs64Fnv1:bigint) {
builder.addFieldInt64(18, testhashs64Fnv1, builder.createLong(0, 0)); builder.addFieldInt64(18, testhashs64Fnv1, BigInt('0'));
} }
static addTesthashu64Fnv1(builder:flatbuffers.Builder, testhashu64Fnv1:flatbuffers.Long) { static addTesthashu64Fnv1(builder:flatbuffers.Builder, testhashu64Fnv1:bigint) {
builder.addFieldInt64(19, testhashu64Fnv1, builder.createLong(0, 0)); builder.addFieldInt64(19, testhashu64Fnv1, BigInt('0'));
} }
static addTesthashs32Fnv1a(builder:flatbuffers.Builder, testhashs32Fnv1a:number) { static addTesthashs32Fnv1a(builder:flatbuffers.Builder, testhashs32Fnv1a:number) {
@@ -790,12 +790,12 @@ static addTesthashu32Fnv1a(builder:flatbuffers.Builder, testhashu32Fnv1a:number)
builder.addFieldInt32(21, testhashu32Fnv1a, 0); builder.addFieldInt32(21, testhashu32Fnv1a, 0);
} }
static addTesthashs64Fnv1a(builder:flatbuffers.Builder, testhashs64Fnv1a:flatbuffers.Long) { static addTesthashs64Fnv1a(builder:flatbuffers.Builder, testhashs64Fnv1a:bigint) {
builder.addFieldInt64(22, testhashs64Fnv1a, builder.createLong(0, 0)); builder.addFieldInt64(22, testhashs64Fnv1a, BigInt('0'));
} }
static addTesthashu64Fnv1a(builder:flatbuffers.Builder, testhashu64Fnv1a:flatbuffers.Long) { static addTesthashu64Fnv1a(builder:flatbuffers.Builder, testhashu64Fnv1a:bigint) {
builder.addFieldInt64(23, testhashu64Fnv1a, builder.createLong(0, 0)); builder.addFieldInt64(23, testhashu64Fnv1a, BigInt('0'));
} }
static addTestarrayofbools(builder:flatbuffers.Builder, testarrayofboolsOffset:flatbuffers.Offset) { static addTestarrayofbools(builder:flatbuffers.Builder, testarrayofboolsOffset:flatbuffers.Offset) {
@@ -878,7 +878,7 @@ static addVectorOfLongs(builder:flatbuffers.Builder, vectorOfLongsOffset:flatbuf
builder.addFieldOffset(32, vectorOfLongsOffset, 0); builder.addFieldOffset(32, vectorOfLongsOffset, 0);
} }
static createVectorOfLongsVector(builder:flatbuffers.Builder, data:flatbuffers.Long[]):flatbuffers.Offset { static createVectorOfLongsVector(builder:flatbuffers.Builder, data:bigint[]):flatbuffers.Offset {
builder.startVector(8, data.length, 8); builder.startVector(8, data.length, 8);
for (let i = data.length - 1; i >= 0; i--) { for (let i = data.length - 1; i >= 0; i--) {
builder.addInt64(data[i]!); builder.addInt64(data[i]!);
@@ -931,15 +931,15 @@ static startVectorOfReferrablesVector(builder:flatbuffers.Builder, numElems:numb
builder.startVector(4, numElems, 4); builder.startVector(4, numElems, 4);
} }
static addSingleWeakReference(builder:flatbuffers.Builder, singleWeakReference:flatbuffers.Long) { static addSingleWeakReference(builder:flatbuffers.Builder, singleWeakReference:bigint) {
builder.addFieldInt64(36, singleWeakReference, builder.createLong(0, 0)); builder.addFieldInt64(36, singleWeakReference, BigInt('0'));
} }
static addVectorOfWeakReferences(builder:flatbuffers.Builder, vectorOfWeakReferencesOffset:flatbuffers.Offset) { static addVectorOfWeakReferences(builder:flatbuffers.Builder, vectorOfWeakReferencesOffset:flatbuffers.Offset) {
builder.addFieldOffset(37, vectorOfWeakReferencesOffset, 0); builder.addFieldOffset(37, vectorOfWeakReferencesOffset, 0);
} }
static createVectorOfWeakReferencesVector(builder:flatbuffers.Builder, data:flatbuffers.Long[]):flatbuffers.Offset { static createVectorOfWeakReferencesVector(builder:flatbuffers.Builder, data:bigint[]):flatbuffers.Offset {
builder.startVector(8, data.length, 8); builder.startVector(8, data.length, 8);
for (let i = data.length - 1; i >= 0; i--) { for (let i = data.length - 1; i >= 0; i--) {
builder.addInt64(data[i]!); builder.addInt64(data[i]!);
@@ -967,15 +967,15 @@ static startVectorOfStrongReferrablesVector(builder:flatbuffers.Builder, numElem
builder.startVector(4, numElems, 4); builder.startVector(4, numElems, 4);
} }
static addCoOwningReference(builder:flatbuffers.Builder, coOwningReference:flatbuffers.Long) { static addCoOwningReference(builder:flatbuffers.Builder, coOwningReference:bigint) {
builder.addFieldInt64(39, coOwningReference, builder.createLong(0, 0)); builder.addFieldInt64(39, coOwningReference, BigInt('0'));
} }
static addVectorOfCoOwningReferences(builder:flatbuffers.Builder, vectorOfCoOwningReferencesOffset:flatbuffers.Offset) { static addVectorOfCoOwningReferences(builder:flatbuffers.Builder, vectorOfCoOwningReferencesOffset:flatbuffers.Offset) {
builder.addFieldOffset(40, vectorOfCoOwningReferencesOffset, 0); builder.addFieldOffset(40, vectorOfCoOwningReferencesOffset, 0);
} }
static createVectorOfCoOwningReferencesVector(builder:flatbuffers.Builder, data:flatbuffers.Long[]):flatbuffers.Offset { static createVectorOfCoOwningReferencesVector(builder:flatbuffers.Builder, data:bigint[]):flatbuffers.Offset {
builder.startVector(8, data.length, 8); builder.startVector(8, data.length, 8);
for (let i = data.length - 1; i >= 0; i--) { for (let i = data.length - 1; i >= 0; i--) {
builder.addInt64(data[i]!); builder.addInt64(data[i]!);
@@ -987,15 +987,15 @@ static startVectorOfCoOwningReferencesVector(builder:flatbuffers.Builder, numEle
builder.startVector(8, numElems, 8); builder.startVector(8, numElems, 8);
} }
static addNonOwningReference(builder:flatbuffers.Builder, nonOwningReference:flatbuffers.Long) { static addNonOwningReference(builder:flatbuffers.Builder, nonOwningReference:bigint) {
builder.addFieldInt64(41, nonOwningReference, builder.createLong(0, 0)); builder.addFieldInt64(41, nonOwningReference, BigInt('0'));
} }
static addVectorOfNonOwningReferences(builder:flatbuffers.Builder, vectorOfNonOwningReferencesOffset:flatbuffers.Offset) { static addVectorOfNonOwningReferences(builder:flatbuffers.Builder, vectorOfNonOwningReferencesOffset:flatbuffers.Offset) {
builder.addFieldOffset(42, vectorOfNonOwningReferencesOffset, 0); builder.addFieldOffset(42, vectorOfNonOwningReferencesOffset, 0);
} }
static createVectorOfNonOwningReferencesVector(builder:flatbuffers.Builder, data:flatbuffers.Long[]):flatbuffers.Offset { static createVectorOfNonOwningReferencesVector(builder:flatbuffers.Builder, data:bigint[]):flatbuffers.Offset {
builder.startVector(8, data.length, 8); builder.startVector(8, data.length, 8);
for (let i = data.length - 1; i >= 0; i--) { for (let i = data.length - 1; i >= 0; i--) {
builder.addInt64(data[i]!); builder.addInt64(data[i]!);
@@ -1251,12 +1251,12 @@ constructor(
public testbool: boolean = false, public testbool: boolean = false,
public testhashs32Fnv1: number = 0, public testhashs32Fnv1: number = 0,
public testhashu32Fnv1: number = 0, public testhashu32Fnv1: number = 0,
public testhashs64Fnv1: flatbuffers.Long = flatbuffers.createLong(0, 0), public testhashs64Fnv1: bigint = BigInt('0'),
public testhashu64Fnv1: flatbuffers.Long = flatbuffers.createLong(0, 0), public testhashu64Fnv1: bigint = BigInt('0'),
public testhashs32Fnv1a: number = 0, public testhashs32Fnv1a: number = 0,
public testhashu32Fnv1a: number = 0, public testhashu32Fnv1a: number = 0,
public testhashs64Fnv1a: flatbuffers.Long = flatbuffers.createLong(0, 0), public testhashs64Fnv1a: bigint = BigInt('0'),
public testhashu64Fnv1a: flatbuffers.Long = flatbuffers.createLong(0, 0), public testhashu64Fnv1a: bigint = BigInt('0'),
public testarrayofbools: (boolean)[] = [], public testarrayofbools: (boolean)[] = [],
public testf: number = 3.14159, public testf: number = 3.14159,
public testf2: number = 3.0, public testf2: number = 3.0,
@@ -1265,17 +1265,17 @@ constructor(
public testarrayofsortedstruct: (AbilityT)[] = [], public testarrayofsortedstruct: (AbilityT)[] = [],
public flex: (number)[] = [], public flex: (number)[] = [],
public test5: (TestT)[] = [], public test5: (TestT)[] = [],
public vectorOfLongs: (flatbuffers.Long)[] = [], public vectorOfLongs: (bigint)[] = [],
public vectorOfDoubles: (number)[] = [], public vectorOfDoubles: (number)[] = [],
public parentNamespaceTest: InParentNamespaceT|null = null, public parentNamespaceTest: InParentNamespaceT|null = null,
public vectorOfReferrables: (ReferrableT)[] = [], public vectorOfReferrables: (ReferrableT)[] = [],
public singleWeakReference: flatbuffers.Long = flatbuffers.createLong(0, 0), public singleWeakReference: bigint = BigInt('0'),
public vectorOfWeakReferences: (flatbuffers.Long)[] = [], public vectorOfWeakReferences: (bigint)[] = [],
public vectorOfStrongReferrables: (ReferrableT)[] = [], public vectorOfStrongReferrables: (ReferrableT)[] = [],
public coOwningReference: flatbuffers.Long = flatbuffers.createLong(0, 0), public coOwningReference: bigint = BigInt('0'),
public vectorOfCoOwningReferences: (flatbuffers.Long)[] = [], public vectorOfCoOwningReferences: (bigint)[] = [],
public nonOwningReference: flatbuffers.Long = flatbuffers.createLong(0, 0), public nonOwningReference: bigint = BigInt('0'),
public vectorOfNonOwningReferences: (flatbuffers.Long)[] = [], public vectorOfNonOwningReferences: (bigint)[] = [],
public anyUniqueType: AnyUniqueAliases = AnyUniqueAliases.NONE, public anyUniqueType: AnyUniqueAliases = AnyUniqueAliases.NONE,
public anyUnique: MonsterT|MyGameExample2MonsterT|TestSimpleTableWithEnumT|null = null, public anyUnique: MonsterT|MyGameExample2MonsterT|TestSimpleTableWithEnumT|null = null,
public anyAmbiguousType: AnyAmbiguousAliases = AnyAmbiguousAliases.NONE, public anyAmbiguousType: AnyAmbiguousAliases = AnyAmbiguousAliases.NONE,

View File

@@ -19,7 +19,7 @@ export class Referrable {
} }
id() { id() {
const offset = this.bb.__offset(this.bb_pos, 4); const offset = this.bb.__offset(this.bb_pos, 4);
return offset ? this.bb.readUint64(this.bb_pos + offset) : this.bb.createLong(0, 0); return offset ? this.bb.readUint64(this.bb_pos + offset) : BigInt('0');
} }
mutate_id(value) { mutate_id(value) {
const offset = this.bb.__offset(this.bb_pos, 4); const offset = this.bb.__offset(this.bb_pos, 4);
@@ -36,7 +36,7 @@ export class Referrable {
builder.startObject(1); builder.startObject(1);
} }
static addId(builder, id) { static addId(builder, id) {
builder.addFieldInt64(0, id, builder.createLong(0, 0)); builder.addFieldInt64(0, id, BigInt('0'));
} }
static endReferrable(builder) { static endReferrable(builder) {
const offset = builder.endObject(); const offset = builder.endObject();
@@ -61,7 +61,7 @@ export class Referrable {
} }
} }
export class ReferrableT { export class ReferrableT {
constructor(id = flatbuffers.createLong(0, 0)) { constructor(id = BigInt('0')) {
this.id = id; this.id = id;
} }
pack(builder) { pack(builder) {

View File

@@ -22,12 +22,12 @@ static getSizePrefixedRootAsReferrable(bb:flatbuffers.ByteBuffer, obj?:Referrabl
return (obj || new Referrable()).__init(bb.readInt32(bb.position()) + bb.position(), bb); return (obj || new Referrable()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
} }
id():flatbuffers.Long { id():bigint {
const offset = this.bb!.__offset(this.bb_pos, 4); const offset = this.bb!.__offset(this.bb_pos, 4);
return offset ? this.bb!.readUint64(this.bb_pos + offset) : this.bb!.createLong(0, 0); return offset ? this.bb!.readUint64(this.bb_pos + offset) : BigInt('0');
} }
mutate_id(value:flatbuffers.Long):boolean { mutate_id(value:bigint):boolean {
const offset = this.bb!.__offset(this.bb_pos, 4); const offset = this.bb!.__offset(this.bb_pos, 4);
if (offset === 0) { if (offset === 0) {
@@ -46,8 +46,8 @@ static startReferrable(builder:flatbuffers.Builder) {
builder.startObject(1); builder.startObject(1);
} }
static addId(builder:flatbuffers.Builder, id:flatbuffers.Long) { static addId(builder:flatbuffers.Builder, id:bigint) {
builder.addFieldInt64(0, id, builder.createLong(0, 0)); builder.addFieldInt64(0, id, BigInt('0'));
} }
static endReferrable(builder:flatbuffers.Builder):flatbuffers.Offset { static endReferrable(builder:flatbuffers.Builder):flatbuffers.Offset {
@@ -55,7 +55,7 @@ static endReferrable(builder:flatbuffers.Builder):flatbuffers.Offset {
return offset; return offset;
} }
static createReferrable(builder:flatbuffers.Builder, id:flatbuffers.Long):flatbuffers.Offset { static createReferrable(builder:flatbuffers.Builder, id:bigint):flatbuffers.Offset {
Referrable.startReferrable(builder); Referrable.startReferrable(builder);
Referrable.addId(builder, id); Referrable.addId(builder, id);
return Referrable.endReferrable(builder); return Referrable.endReferrable(builder);
@@ -83,7 +83,7 @@ unpackTo(_o: ReferrableT): void {
export class ReferrableT { export class ReferrableT {
constructor( constructor(
public id: flatbuffers.Long = flatbuffers.createLong(0, 0) public id: bigint = BigInt('0')
){} ){}

View File

@@ -23,7 +23,7 @@ export class Stat {
} }
val() { val() {
const offset = this.bb.__offset(this.bb_pos, 6); const offset = this.bb.__offset(this.bb_pos, 6);
return offset ? this.bb.readInt64(this.bb_pos + offset) : this.bb.createLong(0, 0); return offset ? this.bb.readInt64(this.bb_pos + offset) : BigInt('0');
} }
mutate_val(value) { mutate_val(value) {
const offset = this.bb.__offset(this.bb_pos, 6); const offset = this.bb.__offset(this.bb_pos, 6);
@@ -55,7 +55,7 @@ export class Stat {
builder.addFieldOffset(0, idOffset, 0); builder.addFieldOffset(0, idOffset, 0);
} }
static addVal(builder, val) { static addVal(builder, val) {
builder.addFieldInt64(1, val, builder.createLong(0, 0)); builder.addFieldInt64(1, val, BigInt('0'));
} }
static addCount(builder, count) { static addCount(builder, count) {
builder.addFieldInt16(2, count, 0); builder.addFieldInt16(2, count, 0);
@@ -87,7 +87,7 @@ export class Stat {
} }
} }
export class StatT { export class StatT {
constructor(id = null, val = flatbuffers.createLong(0, 0), count = 0) { constructor(id = null, val = BigInt('0'), count = 0) {
this.id = id; this.id = id;
this.val = val; this.val = val;
this.count = count; this.count = count;

View File

@@ -29,12 +29,12 @@ id(optionalEncoding?:any):string|Uint8Array|null {
return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
} }
val():flatbuffers.Long { val():bigint {
const offset = this.bb!.__offset(this.bb_pos, 6); const offset = this.bb!.__offset(this.bb_pos, 6);
return offset ? this.bb!.readInt64(this.bb_pos + offset) : this.bb!.createLong(0, 0); return offset ? this.bb!.readInt64(this.bb_pos + offset) : BigInt('0');
} }
mutate_val(value:flatbuffers.Long):boolean { mutate_val(value:bigint):boolean {
const offset = this.bb!.__offset(this.bb_pos, 6); const offset = this.bb!.__offset(this.bb_pos, 6);
if (offset === 0) { if (offset === 0) {
@@ -73,8 +73,8 @@ static addId(builder:flatbuffers.Builder, idOffset:flatbuffers.Offset) {
builder.addFieldOffset(0, idOffset, 0); builder.addFieldOffset(0, idOffset, 0);
} }
static addVal(builder:flatbuffers.Builder, val:flatbuffers.Long) { static addVal(builder:flatbuffers.Builder, val:bigint) {
builder.addFieldInt64(1, val, builder.createLong(0, 0)); builder.addFieldInt64(1, val, BigInt('0'));
} }
static addCount(builder:flatbuffers.Builder, count:number) { static addCount(builder:flatbuffers.Builder, count:number) {
@@ -86,7 +86,7 @@ static endStat(builder:flatbuffers.Builder):flatbuffers.Offset {
return offset; return offset;
} }
static createStat(builder:flatbuffers.Builder, idOffset:flatbuffers.Offset, val:flatbuffers.Long, count:number):flatbuffers.Offset { static createStat(builder:flatbuffers.Builder, idOffset:flatbuffers.Offset, val:bigint, count:number):flatbuffers.Offset {
Stat.startStat(builder); Stat.startStat(builder);
Stat.addId(builder, idOffset); Stat.addId(builder, idOffset);
Stat.addVal(builder, val); Stat.addVal(builder, val);
@@ -121,7 +121,7 @@ unpackTo(_o: StatT): void {
export class StatT { export class StatT {
constructor( constructor(
public id: string|Uint8Array|null = null, public id: string|Uint8Array|null = null,
public val: flatbuffers.Long = flatbuffers.createLong(0, 0), public val: bigint = BigInt('0'),
public count: number = 0 public count: number = 0
){} ){}

View File

@@ -91,7 +91,7 @@ export class TypeAliases {
} }
i64() { i64() {
const offset = this.bb.__offset(this.bb_pos, 16); const offset = this.bb.__offset(this.bb_pos, 16);
return offset ? this.bb.readInt64(this.bb_pos + offset) : this.bb.createLong(0, 0); return offset ? this.bb.readInt64(this.bb_pos + offset) : BigInt('0');
} }
mutate_i64(value) { mutate_i64(value) {
const offset = this.bb.__offset(this.bb_pos, 16); const offset = this.bb.__offset(this.bb_pos, 16);
@@ -103,7 +103,7 @@ export class TypeAliases {
} }
u64() { u64() {
const offset = this.bb.__offset(this.bb_pos, 18); const offset = this.bb.__offset(this.bb_pos, 18);
return offset ? this.bb.readUint64(this.bb_pos + offset) : this.bb.createLong(0, 0); return offset ? this.bb.readUint64(this.bb_pos + offset) : BigInt('0');
} }
mutate_u64(value) { mutate_u64(value) {
const offset = this.bb.__offset(this.bb_pos, 18); const offset = this.bb.__offset(this.bb_pos, 18);
@@ -186,10 +186,10 @@ export class TypeAliases {
builder.addFieldInt32(5, u32, 0); builder.addFieldInt32(5, u32, 0);
} }
static addI64(builder, i64) { static addI64(builder, i64) {
builder.addFieldInt64(6, i64, builder.createLong(0, 0)); builder.addFieldInt64(6, i64, BigInt('0'));
} }
static addU64(builder, u64) { static addU64(builder, u64) {
builder.addFieldInt64(7, u64, builder.createLong(0, 0)); builder.addFieldInt64(7, u64, BigInt('0'));
} }
static addF32(builder, f32) { static addF32(builder, f32) {
builder.addFieldFloat32(8, f32, 0.0); builder.addFieldFloat32(8, f32, 0.0);
@@ -268,7 +268,7 @@ export class TypeAliases {
} }
} }
export class TypeAliasesT { export class TypeAliasesT {
constructor(i8 = 0, u8 = 0, i16 = 0, u16 = 0, i32 = 0, u32 = 0, i64 = flatbuffers.createLong(0, 0), u64 = flatbuffers.createLong(0, 0), f32 = 0.0, f64 = 0.0, v8 = [], vf64 = []) { constructor(i8 = 0, u8 = 0, i16 = 0, u16 = 0, i32 = 0, u32 = 0, i64 = BigInt('0'), u64 = BigInt('0'), f32 = 0.0, f64 = 0.0, v8 = [], vf64 = []) {
this.i8 = i8; this.i8 = i8;
this.u8 = u8; this.u8 = u8;
this.i16 = i16; this.i16 = i16;

View File

@@ -118,12 +118,12 @@ mutate_u32(value:number):boolean {
return true; return true;
} }
i64():flatbuffers.Long { i64():bigint {
const offset = this.bb!.__offset(this.bb_pos, 16); const offset = this.bb!.__offset(this.bb_pos, 16);
return offset ? this.bb!.readInt64(this.bb_pos + offset) : this.bb!.createLong(0, 0); return offset ? this.bb!.readInt64(this.bb_pos + offset) : BigInt('0');
} }
mutate_i64(value:flatbuffers.Long):boolean { mutate_i64(value:bigint):boolean {
const offset = this.bb!.__offset(this.bb_pos, 16); const offset = this.bb!.__offset(this.bb_pos, 16);
if (offset === 0) { if (offset === 0) {
@@ -134,12 +134,12 @@ mutate_i64(value:flatbuffers.Long):boolean {
return true; return true;
} }
u64():flatbuffers.Long { u64():bigint {
const offset = this.bb!.__offset(this.bb_pos, 18); const offset = this.bb!.__offset(this.bb_pos, 18);
return offset ? this.bb!.readUint64(this.bb_pos + offset) : this.bb!.createLong(0, 0); return offset ? this.bb!.readUint64(this.bb_pos + offset) : BigInt('0');
} }
mutate_u64(value:flatbuffers.Long):boolean { mutate_u64(value:bigint):boolean {
const offset = this.bb!.__offset(this.bb_pos, 18); const offset = this.bb!.__offset(this.bb_pos, 18);
if (offset === 0) { if (offset === 0) {
@@ -244,12 +244,12 @@ static addU32(builder:flatbuffers.Builder, u32:number) {
builder.addFieldInt32(5, u32, 0); builder.addFieldInt32(5, u32, 0);
} }
static addI64(builder:flatbuffers.Builder, i64:flatbuffers.Long) { static addI64(builder:flatbuffers.Builder, i64:bigint) {
builder.addFieldInt64(6, i64, builder.createLong(0, 0)); builder.addFieldInt64(6, i64, BigInt('0'));
} }
static addU64(builder:flatbuffers.Builder, u64:flatbuffers.Long) { static addU64(builder:flatbuffers.Builder, u64:bigint) {
builder.addFieldInt64(7, u64, builder.createLong(0, 0)); builder.addFieldInt64(7, u64, BigInt('0'));
} }
static addF32(builder:flatbuffers.Builder, f32:number) { static addF32(builder:flatbuffers.Builder, f32:number) {
@@ -307,7 +307,7 @@ static endTypeAliases(builder:flatbuffers.Builder):flatbuffers.Offset {
return offset; return offset;
} }
static createTypeAliases(builder:flatbuffers.Builder, i8:number, u8:number, i16:number, u16:number, i32:number, u32:number, i64:flatbuffers.Long, u64:flatbuffers.Long, f32:number, f64:number, v8Offset:flatbuffers.Offset, vf64Offset:flatbuffers.Offset):flatbuffers.Offset { static createTypeAliases(builder:flatbuffers.Builder, i8:number, u8:number, i16:number, u16:number, i32:number, u32:number, i64:bigint, u64:bigint, f32:number, f64:number, v8Offset:flatbuffers.Offset, vf64Offset:flatbuffers.Offset):flatbuffers.Offset {
TypeAliases.startTypeAliases(builder); TypeAliases.startTypeAliases(builder);
TypeAliases.addI8(builder, i8); TypeAliases.addI8(builder, i8);
TypeAliases.addU8(builder, u8); TypeAliases.addU8(builder, u8);
@@ -374,8 +374,8 @@ constructor(
public u16: number = 0, public u16: number = 0,
public i32: number = 0, public i32: number = 0,
public u32: number = 0, public u32: number = 0,
public i64: flatbuffers.Long = flatbuffers.createLong(0, 0), public i64: bigint = BigInt('0'),
public u64: flatbuffers.Long = flatbuffers.createLong(0, 0), public u64: bigint = BigInt('0'),
public f32: number = 0.0, public f32: number = 0.0,
public f64: number = 0.0, public f64: number = 0.0,
public v8: (number)[] = [], public v8: (number)[] = [],

View File

@@ -95,7 +95,7 @@ export class ScalarStuff {
} }
justI64() { justI64() {
const offset = this.bb.__offset(this.bb_pos, 40); const offset = this.bb.__offset(this.bb_pos, 40);
return offset ? this.bb.readInt64(this.bb_pos + offset) : this.bb.createLong(0, 0); return offset ? this.bb.readInt64(this.bb_pos + offset) : BigInt('0');
} }
maybeI64() { maybeI64() {
const offset = this.bb.__offset(this.bb_pos, 42); const offset = this.bb.__offset(this.bb_pos, 42);
@@ -103,11 +103,11 @@ export class ScalarStuff {
} }
defaultI64() { defaultI64() {
const offset = this.bb.__offset(this.bb_pos, 44); const offset = this.bb.__offset(this.bb_pos, 44);
return offset ? this.bb.readInt64(this.bb_pos + offset) : this.bb.createLong(42, 0); return offset ? this.bb.readInt64(this.bb_pos + offset) : BigInt('42');
} }
justU64() { justU64() {
const offset = this.bb.__offset(this.bb_pos, 46); const offset = this.bb.__offset(this.bb_pos, 46);
return offset ? this.bb.readUint64(this.bb_pos + offset) : this.bb.createLong(0, 0); return offset ? this.bb.readUint64(this.bb_pos + offset) : BigInt('0');
} }
maybeU64() { maybeU64() {
const offset = this.bb.__offset(this.bb_pos, 48); const offset = this.bb.__offset(this.bb_pos, 48);
@@ -115,7 +115,7 @@ export class ScalarStuff {
} }
defaultU64() { defaultU64() {
const offset = this.bb.__offset(this.bb_pos, 50); const offset = this.bb.__offset(this.bb_pos, 50);
return offset ? this.bb.readUint64(this.bb_pos + offset) : this.bb.createLong(42, 0); return offset ? this.bb.readUint64(this.bb_pos + offset) : BigInt('42');
} }
justF32() { justF32() {
const offset = this.bb.__offset(this.bb_pos, 52); const offset = this.bb.__offset(this.bb_pos, 52);
@@ -223,22 +223,22 @@ export class ScalarStuff {
builder.addFieldInt32(17, defaultU32, 42); builder.addFieldInt32(17, defaultU32, 42);
} }
static addJustI64(builder, justI64) { static addJustI64(builder, justI64) {
builder.addFieldInt64(18, justI64, builder.createLong(0, 0)); builder.addFieldInt64(18, justI64, BigInt('0'));
} }
static addMaybeI64(builder, maybeI64) { static addMaybeI64(builder, maybeI64) {
builder.addFieldInt64(19, maybeI64, builder.createLong(0, 0)); builder.addFieldInt64(19, maybeI64, BigInt(0));
} }
static addDefaultI64(builder, defaultI64) { static addDefaultI64(builder, defaultI64) {
builder.addFieldInt64(20, defaultI64, builder.createLong(42, 0)); builder.addFieldInt64(20, defaultI64, BigInt('42'));
} }
static addJustU64(builder, justU64) { static addJustU64(builder, justU64) {
builder.addFieldInt64(21, justU64, builder.createLong(0, 0)); builder.addFieldInt64(21, justU64, BigInt('0'));
} }
static addMaybeU64(builder, maybeU64) { static addMaybeU64(builder, maybeU64) {
builder.addFieldInt64(22, maybeU64, builder.createLong(0, 0)); builder.addFieldInt64(22, maybeU64, BigInt(0));
} }
static addDefaultU64(builder, defaultU64) { static addDefaultU64(builder, defaultU64) {
builder.addFieldInt64(23, defaultU64, builder.createLong(42, 0)); builder.addFieldInt64(23, defaultU64, BigInt('42'));
} }
static addJustF32(builder, justF32) { static addJustF32(builder, justF32) {
builder.addFieldFloat32(24, justF32, 0.0); builder.addFieldFloat32(24, justF32, 0.0);

View File

@@ -117,34 +117,34 @@ defaultU32():number {
return offset ? this.bb!.readUint32(this.bb_pos + offset) : 42; return offset ? this.bb!.readUint32(this.bb_pos + offset) : 42;
} }
justI64():flatbuffers.Long { justI64():bigint {
const offset = this.bb!.__offset(this.bb_pos, 40); const offset = this.bb!.__offset(this.bb_pos, 40);
return offset ? this.bb!.readInt64(this.bb_pos + offset) : this.bb!.createLong(0, 0); return offset ? this.bb!.readInt64(this.bb_pos + offset) : BigInt('0');
} }
maybeI64():flatbuffers.Long|null { maybeI64():bigint|null {
const offset = this.bb!.__offset(this.bb_pos, 42); const offset = this.bb!.__offset(this.bb_pos, 42);
return offset ? this.bb!.readInt64(this.bb_pos + offset) : null; return offset ? this.bb!.readInt64(this.bb_pos + offset) : null;
} }
defaultI64():flatbuffers.Long { defaultI64():bigint {
const offset = this.bb!.__offset(this.bb_pos, 44); const offset = this.bb!.__offset(this.bb_pos, 44);
return offset ? this.bb!.readInt64(this.bb_pos + offset) : this.bb!.createLong(42, 0); return offset ? this.bb!.readInt64(this.bb_pos + offset) : BigInt('42');
} }
justU64():flatbuffers.Long { justU64():bigint {
const offset = this.bb!.__offset(this.bb_pos, 46); const offset = this.bb!.__offset(this.bb_pos, 46);
return offset ? this.bb!.readUint64(this.bb_pos + offset) : this.bb!.createLong(0, 0); return offset ? this.bb!.readUint64(this.bb_pos + offset) : BigInt('0');
} }
maybeU64():flatbuffers.Long|null { maybeU64():bigint|null {
const offset = this.bb!.__offset(this.bb_pos, 48); const offset = this.bb!.__offset(this.bb_pos, 48);
return offset ? this.bb!.readUint64(this.bb_pos + offset) : null; return offset ? this.bb!.readUint64(this.bb_pos + offset) : null;
} }
defaultU64():flatbuffers.Long { defaultU64():bigint {
const offset = this.bb!.__offset(this.bb_pos, 50); const offset = this.bb!.__offset(this.bb_pos, 50);
return offset ? this.bb!.readUint64(this.bb_pos + offset) : this.bb!.createLong(42, 0); return offset ? this.bb!.readUint64(this.bb_pos + offset) : BigInt('42');
} }
justF32():number { justF32():number {
@@ -283,28 +283,28 @@ static addDefaultU32(builder:flatbuffers.Builder, defaultU32:number) {
builder.addFieldInt32(17, defaultU32, 42); builder.addFieldInt32(17, defaultU32, 42);
} }
static addJustI64(builder:flatbuffers.Builder, justI64:flatbuffers.Long) { static addJustI64(builder:flatbuffers.Builder, justI64:bigint) {
builder.addFieldInt64(18, justI64, builder.createLong(0, 0)); builder.addFieldInt64(18, justI64, BigInt('0'));
} }
static addMaybeI64(builder:flatbuffers.Builder, maybeI64:flatbuffers.Long) { static addMaybeI64(builder:flatbuffers.Builder, maybeI64:bigint) {
builder.addFieldInt64(19, maybeI64, builder.createLong(0, 0)); builder.addFieldInt64(19, maybeI64, BigInt(0));
} }
static addDefaultI64(builder:flatbuffers.Builder, defaultI64:flatbuffers.Long) { static addDefaultI64(builder:flatbuffers.Builder, defaultI64:bigint) {
builder.addFieldInt64(20, defaultI64, builder.createLong(42, 0)); builder.addFieldInt64(20, defaultI64, BigInt('42'));
} }
static addJustU64(builder:flatbuffers.Builder, justU64:flatbuffers.Long) { static addJustU64(builder:flatbuffers.Builder, justU64:bigint) {
builder.addFieldInt64(21, justU64, builder.createLong(0, 0)); builder.addFieldInt64(21, justU64, BigInt('0'));
} }
static addMaybeU64(builder:flatbuffers.Builder, maybeU64:flatbuffers.Long) { static addMaybeU64(builder:flatbuffers.Builder, maybeU64:bigint) {
builder.addFieldInt64(22, maybeU64, builder.createLong(0, 0)); builder.addFieldInt64(22, maybeU64, BigInt(0));
} }
static addDefaultU64(builder:flatbuffers.Builder, defaultU64:flatbuffers.Long) { static addDefaultU64(builder:flatbuffers.Builder, defaultU64:bigint) {
builder.addFieldInt64(23, defaultU64, builder.createLong(42, 0)); builder.addFieldInt64(23, defaultU64, BigInt('42'));
} }
static addJustF32(builder:flatbuffers.Builder, justF32:number) { static addJustF32(builder:flatbuffers.Builder, justF32:number) {
@@ -368,7 +368,7 @@ static finishSizePrefixedScalarStuffBuffer(builder:flatbuffers.Builder, offset:f
builder.finish(offset, 'NULL', true); builder.finish(offset, 'NULL', true);
} }
static createScalarStuff(builder:flatbuffers.Builder, justI8:number, maybeI8:number|null, defaultI8:number, justU8:number, maybeU8:number|null, defaultU8:number, justI16:number, maybeI16:number|null, defaultI16:number, justU16:number, maybeU16:number|null, defaultU16:number, justI32:number, maybeI32:number|null, defaultI32:number, justU32:number, maybeU32:number|null, defaultU32:number, justI64:flatbuffers.Long, maybeI64:flatbuffers.Long|null, defaultI64:flatbuffers.Long, justU64:flatbuffers.Long, maybeU64:flatbuffers.Long|null, defaultU64:flatbuffers.Long, justF32:number, maybeF32:number|null, defaultF32:number, justF64:number, maybeF64:number|null, defaultF64:number, justBool:boolean, maybeBool:boolean|null, defaultBool:boolean, justEnum:OptionalByte, maybeEnum:OptionalByte|null, defaultEnum:OptionalByte):flatbuffers.Offset { static createScalarStuff(builder:flatbuffers.Builder, justI8:number, maybeI8:number|null, defaultI8:number, justU8:number, maybeU8:number|null, defaultU8:number, justI16:number, maybeI16:number|null, defaultI16:number, justU16:number, maybeU16:number|null, defaultU16:number, justI32:number, maybeI32:number|null, defaultI32:number, justU32:number, maybeU32:number|null, defaultU32:number, justI64:bigint, maybeI64:bigint|null, defaultI64:bigint, justU64:bigint, maybeU64:bigint|null, defaultU64:bigint, justF32:number, maybeF32:number|null, defaultF32:number, justF64:number, maybeF64:number|null, defaultF64:number, justBool:boolean, maybeBool:boolean|null, defaultBool:boolean, justEnum:OptionalByte, maybeEnum:OptionalByte|null, defaultEnum:OptionalByte):flatbuffers.Offset {
ScalarStuff.startScalarStuff(builder); ScalarStuff.startScalarStuff(builder);
ScalarStuff.addJustI8(builder, justI8); ScalarStuff.addJustI8(builder, justI8);
if (maybeI8 !== null) if (maybeI8 !== null)

View File

@@ -1,5 +1,8 @@
export { Attacker, AttackerT } from './attacker'; export { Attacker, AttackerT } from './attacker';
export { BookReader, BookReaderT } from './book-reader'; export { BookReader, BookReaderT } from './book-reader';
export { Character, unionToCharacter, unionListToCharacter } from './character'; export { Character, unionToCharacter, unionListToCharacter } from './character';
export { FallingTub, FallingTubT } from './falling-tub';
export { Gadget, unionToGadget, unionListToGadget } from './gadget';
export { HandFan, HandFanT } from './hand-fan';
export { Movie, MovieT } from './movie'; export { Movie, MovieT } from './movie';
export { Rapunzel, RapunzelT } from './rapunzel'; export { Rapunzel, RapunzelT } from './rapunzel';

View File

@@ -1,7 +1,6 @@
import { ByteBuffer } from "./byte-buffer" import { ByteBuffer } from "./byte-buffer"
import { SIZEOF_SHORT, SIZE_PREFIX_LENGTH, SIZEOF_INT, FILE_IDENTIFIER_LENGTH } from "./constants" import { SIZEOF_SHORT, SIZE_PREFIX_LENGTH, SIZEOF_INT, FILE_IDENTIFIER_LENGTH } from "./constants"
import { Offset, IGeneratedObject } from "./types" import { Offset, IGeneratedObject } from "./types"
import { Long } from "./long"
export class Builder { export class Builder {
private bb: ByteBuffer private bb: ByteBuffer
@@ -136,7 +135,7 @@ export class Builder {
this.bb.writeInt32(this.space -= 4, value); this.bb.writeInt32(this.space -= 4, value);
} }
writeInt64(value: Long): void { writeInt64(value: bigint): void {
this.bb.writeInt64(this.space -= 8, value); this.bb.writeInt64(this.space -= 8, value);
} }
@@ -179,7 +178,7 @@ export class Builder {
* Add an `int64` to the buffer, properly aligned, and grows the buffer (if necessary). * Add an `int64` to the buffer, properly aligned, and grows the buffer (if necessary).
* @param value The `int64` to add the the buffer. * @param value The `int64` to add the the buffer.
*/ */
addInt64(value: Long): void { addInt64(value: bigint): void {
this.prep(8, 0); this.prep(8, 0);
this.writeInt64(value); this.writeInt64(value);
} }
@@ -223,8 +222,8 @@ export class Builder {
} }
} }
addFieldInt64(voffset: number, value: Long, defaultValue: Long): void { addFieldInt64(voffset: number, value: bigint, defaultValue: bigint): void {
if (this.force_defaults || !value.equals(defaultValue)) { if (this.force_defaults || value !== defaultValue) {
this.addInt64(value); this.addInt64(value);
this.slot(voffset); this.slot(voffset);
} }
@@ -574,13 +573,6 @@ export class Builder {
return this.endVector(); return this.endVector();
} }
/**
* A helper function to avoid generated code depending on this file directly.
*/
createLong(low: number, high: number): Long {
return Long.create(low, high);
}
/** /**
* A helper function to pack an object * A helper function to pack an object
* *

View File

@@ -1,5 +1,4 @@
import { FILE_IDENTIFIER_LENGTH, SIZEOF_INT } from "./constants"; import { FILE_IDENTIFIER_LENGTH, SIZEOF_INT } from "./constants";
import { Long } from "./long";
import { int32, isLittleEndian, float32, float64 } from "./utils"; import { int32, isLittleEndian, float32, float64 } from "./utils";
import { Offset, Table, IGeneratedObject } from "./types"; import { Offset, Table, IGeneratedObject } from "./types";
import { Encoding } from "./encoding"; import { Encoding } from "./encoding";
@@ -75,12 +74,12 @@ export class ByteBuffer {
return this.readInt32(offset) >>> 0; return this.readInt32(offset) >>> 0;
} }
readInt64(offset: number): Long { readInt64(offset: number): bigint {
return new Long(this.readInt32(offset), this.readInt32(offset + 4)); return BigInt.asIntN(64, BigInt(this.readUint32(offset)) + (BigInt(this.readUint32(offset + 4)) << BigInt(32)));
} }
readUint64(offset: number): Long { readUint64(offset: number): bigint {
return new Long(this.readUint32(offset), this.readUint32(offset + 4)); return BigInt.asUintN(64, BigInt(this.readUint32(offset)) + (BigInt(this.readUint32(offset + 4)) << BigInt(32)));
} }
readFloat32(offset: number): number { readFloat32(offset: number): number {
@@ -108,8 +107,8 @@ export class ByteBuffer {
} }
writeUint16(offset: number, value: number): void { writeUint16(offset: number, value: number): void {
this.bytes_[offset] = value; this.bytes_[offset] = value;
this.bytes_[offset + 1] = value >> 8; this.bytes_[offset + 1] = value >> 8;
} }
writeInt32(offset: number, value: number): void { writeInt32(offset: number, value: number): void {
@@ -120,20 +119,20 @@ export class ByteBuffer {
} }
writeUint32(offset: number, value: number): void { writeUint32(offset: number, value: number): void {
this.bytes_[offset] = value; this.bytes_[offset] = value;
this.bytes_[offset + 1] = value >> 8; this.bytes_[offset + 1] = value >> 8;
this.bytes_[offset + 2] = value >> 16; this.bytes_[offset + 2] = value >> 16;
this.bytes_[offset + 3] = value >> 24; this.bytes_[offset + 3] = value >> 24;
} }
writeInt64(offset: number, value: Long): void { writeInt64(offset: number, value: bigint): void {
this.writeInt32(offset, value.low); this.writeInt32(offset, Number(BigInt.asIntN(32, value)));
this.writeInt32(offset + 4, value.high); this.writeInt32(offset + 4, Number(BigInt.asIntN(32, value >> BigInt(32))));
} }
writeUint64(offset: number, value: Long): void { writeUint64(offset: number, value: bigint): void {
this.writeUint32(offset, value.low); this.writeUint32(offset, Number(BigInt.asUintN(32, value)));
this.writeUint32(offset + 4, value.high); this.writeUint32(offset + 4, Number(BigInt.asUintN(32, value >> BigInt(32))));
} }
writeFloat32(offset: number, value: number): void { writeFloat32(offset: number, value: number): void {
@@ -302,13 +301,6 @@ export class ByteBuffer {
return true; return true;
} }
/**
* A helper function to avoid generated code depending on this file directly.
*/
createLong(low: number, high: number): Long {
return Long.create(low, high);
}
/** /**
* A helper function for generating list for obj api * A helper function for generating list for obj api
*/ */

View File

@@ -7,7 +7,6 @@ export { Table, Offset } from './types'
export { int32, float32, float64, isLittleEndian } from './utils' export { int32, float32, float64, isLittleEndian } from './utils'
export { Long, createLong } from './long'
export { Encoding } from './encoding' export { Encoding } from './encoding'
export { Builder } from './builder' export { Builder } from './builder'
export { ByteBuffer } from './byte-buffer' export { ByteBuffer } from './byte-buffer'

View File

@@ -3,15 +3,13 @@ import { toByteWidth, fromByteWidth } from './bit-width-util'
import { toUTF8Array, fromUTF8Array } from './flexbuffers-util' import { toUTF8Array, fromUTF8Array } from './flexbuffers-util'
import { Reference } from './reference' import { Reference } from './reference'
import { Long } from '../long'
export function validateOffset(dataView: DataView, offset: number, width: number): void { export function validateOffset(dataView: DataView, offset: number, width: number): void {
if (dataView.byteLength <= offset + width || (offset & (toByteWidth(width) - 1)) !== 0) { if (dataView.byteLength <= offset + width || (offset & (toByteWidth(width) - 1)) !== 0) {
throw "Bad offset: " + offset + ", width: " + width; throw "Bad offset: " + offset + ", width: " + width;
} }
} }
export function readInt(dataView: DataView, offset: number, width: number): number | Long | bigint { export function readInt(dataView: DataView, offset: number, width: number): number | bigint {
if (width < 2) { if (width < 2) {
if (width < 1) { if (width < 1) {
return dataView.getInt8(offset); return dataView.getInt8(offset);
@@ -23,14 +21,14 @@ export function readInt(dataView: DataView, offset: number, width: number): numb
return dataView.getInt32(offset, true) return dataView.getInt32(offset, true)
} else { } else {
if (dataView.setBigInt64 === undefined) { if (dataView.setBigInt64 === undefined) {
return new Long(dataView.getUint32(offset, true), dataView.getUint32(offset + 4, true)) return BigInt(dataView.getUint32(offset, true)) + (BigInt(dataView.getUint32(offset + 4, true)) << BigInt(32));
} }
return dataView.getBigInt64(offset, true) return dataView.getBigInt64(offset, true)
} }
} }
} }
export function readUInt(dataView: DataView, offset: number, width: number): number | Long | bigint { export function readUInt(dataView: DataView, offset: number, width: number): number | bigint {
if (width < 2) { if (width < 2) {
if (width < 1) { if (width < 1) {
return dataView.getUint8(offset); return dataView.getUint8(offset);
@@ -42,7 +40,7 @@ export function readUInt(dataView: DataView, offset: number, width: number): num
return dataView.getUint32(offset, true) return dataView.getUint32(offset, true)
} else { } else {
if (dataView.getBigUint64 === undefined) { if (dataView.getBigUint64 === undefined) {
return new Long(dataView.getUint32(offset, true), dataView.getUint32(offset + 4, true)) return BigInt(dataView.getUint32(offset, true)) + (BigInt(dataView.getUint32(offset + 4, true)) << BigInt(32));
} }
return dataView.getBigUint64(offset, true) return dataView.getBigUint64(offset, true)
} }

View File

@@ -2,7 +2,6 @@ import { fromByteWidth } from './bit-width-util'
import { ValueType } from './value-type' import { ValueType } from './value-type'
import { isNumber, isIndirectNumber, isAVector, fixedTypedVectorElementSize, isFixedTypedVector, isTypedVector, typedVectorElementType, packedType, fixedTypedVectorElementType } from './value-type-util' import { isNumber, isIndirectNumber, isAVector, fixedTypedVectorElementSize, isFixedTypedVector, isTypedVector, typedVectorElementType, packedType, fixedTypedVectorElementType } from './value-type-util'
import { indirect, keyForIndex, keyIndex, readFloat, readInt, readUInt, valueForIndexWithKey } from './reference-util' import { indirect, keyForIndex, keyIndex, readFloat, readInt, readUInt, valueForIndexWithKey } from './reference-util'
import { Long } from '../long';
import { fromUTF8Array } from './flexbuffers-util'; import { fromUTF8Array } from './flexbuffers-util';
import { BitWidth } from './bit-width'; import { BitWidth } from './bit-width';
@@ -48,7 +47,7 @@ export class Reference {
return null; return null;
} }
intValue(): number | Long | bigint | null { intValue(): number | bigint | null {
if (this.valueType === ValueType.INT) { if (this.valueType === ValueType.INT) {
return readInt(this.dataView, this.offset, this.parentWidth); return readInt(this.dataView, this.offset, this.parentWidth);
} }
@@ -74,7 +73,7 @@ export class Reference {
return null; return null;
} }
numericValue(): number | Long | bigint | null { return this.floatValue() || this.intValue()} numericValue(): number | bigint | null { return this.floatValue() || this.intValue()}
stringValue(): string | null { stringValue(): string | null {
if (this.valueType === ValueType.STRING || this.valueType === ValueType.KEY) { if (this.valueType === ValueType.STRING || this.valueType === ValueType.KEY) {

View File

@@ -1,23 +0,0 @@
export function createLong(low: number, high: number): Long {
return Long.create(low, high);
}
export class Long {
static readonly ZERO = new Long(0, 0)
low: number
high: number
constructor(low: number, high: number) {
this.low = low | 0;
this.high = high | 0;
}
static create(low: number, high: number): Long {
// Special-case zero to avoid GC overhead for default values
return low == 0 && high == 0 ? Long.ZERO : new Long(low, high);
}
toFloat64(): number {
return (this.low >>> 0) + this.high * 0x100000000;
}
equals(other: Long): boolean {
return this.low == other.low && this.high == other.high;
}
}