mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-20 07:25:07 +00:00
[TS] Add Build TS to CI jobs (#6524)
* Add Build TS to CI jobs * Add npm compile step * Fix syntax * Add required code gen for TS * Exit on failure * Make TS code gen identical to test run * Remove duplicate TS code gen artifacts * Remove bad gitignore * Forgot parts of generate_code and make sure same settings for test run * Don't forget about the bat * Try and fix flatc args * Another attempt to fix args * Fix typo * Commit up to date code gen * Another attempt to fix sh/bat * Move -o param to after -I * Commit missing code gen file * Fix grpc code gen and test * Another grpc code gen fix * Rework to not use ts folder * Fix env vars in bat and make less churn * Move TS code gen to dedicated folder * Fix transpilation output folder and module paths * Fixes to code gen * Include generated js * Moved ts code gen * Remove test ts code gen folder
This commit is contained in:
54
tests/my-game/example/ability.js
Normal file
54
tests/my-game/example/ability.js
Normal file
@@ -0,0 +1,54 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
export class Ability {
|
||||
constructor() {
|
||||
this.bb = null;
|
||||
this.bb_pos = 0;
|
||||
}
|
||||
__init(i, bb) {
|
||||
this.bb_pos = i;
|
||||
this.bb = bb;
|
||||
return this;
|
||||
}
|
||||
id() {
|
||||
return this.bb.readUint32(this.bb_pos);
|
||||
}
|
||||
mutate_id(value) {
|
||||
this.bb.writeUint32(this.bb_pos + 0, value);
|
||||
return true;
|
||||
}
|
||||
distance() {
|
||||
return this.bb.readUint32(this.bb_pos + 4);
|
||||
}
|
||||
mutate_distance(value) {
|
||||
this.bb.writeUint32(this.bb_pos + 4, value);
|
||||
return true;
|
||||
}
|
||||
static getFullyQualifiedName() {
|
||||
return 'MyGame.Example.Ability';
|
||||
}
|
||||
static sizeOf() {
|
||||
return 8;
|
||||
}
|
||||
static createAbility(builder, id, distance) {
|
||||
builder.prep(4, 8);
|
||||
builder.writeInt32(distance);
|
||||
builder.writeInt32(id);
|
||||
return builder.offset();
|
||||
}
|
||||
unpack() {
|
||||
return new AbilityT(this.id(), this.distance());
|
||||
}
|
||||
unpackTo(_o) {
|
||||
_o.id = this.id();
|
||||
_o.distance = this.distance();
|
||||
}
|
||||
}
|
||||
export class AbilityT {
|
||||
constructor(id = 0, distance = 0) {
|
||||
this.id = id;
|
||||
this.distance = distance;
|
||||
}
|
||||
pack(builder) {
|
||||
return Ability.createAbility(builder, this.id, this.distance);
|
||||
}
|
||||
}
|
||||
@@ -31,6 +31,10 @@ mutate_distance(value:number):boolean {
|
||||
return true;
|
||||
}
|
||||
|
||||
static getFullyQualifiedName():string {
|
||||
return 'MyGame.Example.Ability';
|
||||
}
|
||||
|
||||
static sizeOf():number {
|
||||
return 8;
|
||||
}
|
||||
|
||||
27
tests/my-game/example/any-ambiguous-aliases.js
Normal file
27
tests/my-game/example/any-ambiguous-aliases.js
Normal file
@@ -0,0 +1,27 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
import { Monster } from '../../my-game/example/monster';
|
||||
export var AnyAmbiguousAliases;
|
||||
(function (AnyAmbiguousAliases) {
|
||||
AnyAmbiguousAliases[AnyAmbiguousAliases["NONE"] = 0] = "NONE";
|
||||
AnyAmbiguousAliases[AnyAmbiguousAliases["M1"] = 1] = "M1";
|
||||
AnyAmbiguousAliases[AnyAmbiguousAliases["M2"] = 2] = "M2";
|
||||
AnyAmbiguousAliases[AnyAmbiguousAliases["M3"] = 3] = "M3";
|
||||
})(AnyAmbiguousAliases || (AnyAmbiguousAliases = {}));
|
||||
export function unionToAnyAmbiguousAliases(type, accessor) {
|
||||
switch (AnyAmbiguousAliases[type]) {
|
||||
case 'NONE': return null;
|
||||
case 'M1': return accessor(new Monster());
|
||||
case 'M2': return accessor(new Monster());
|
||||
case 'M3': return accessor(new Monster());
|
||||
default: return null;
|
||||
}
|
||||
}
|
||||
export function unionListToAnyAmbiguousAliases(type, accessor, index) {
|
||||
switch (AnyAmbiguousAliases[type]) {
|
||||
case 'NONE': return null;
|
||||
case 'M1': return accessor(index, new Monster());
|
||||
case 'M2': return accessor(index, new Monster());
|
||||
case 'M3': return accessor(index, new Monster());
|
||||
default: return null;
|
||||
}
|
||||
}
|
||||
29
tests/my-game/example/any-unique-aliases.js
Normal file
29
tests/my-game/example/any-unique-aliases.js
Normal file
@@ -0,0 +1,29 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
import { Monster as MyGameExample2Monster } from '../../my-game/example2/monster';
|
||||
import { Monster } from '../../my-game/example/monster';
|
||||
import { TestSimpleTableWithEnum } from '../../my-game/example/test-simple-table-with-enum';
|
||||
export var AnyUniqueAliases;
|
||||
(function (AnyUniqueAliases) {
|
||||
AnyUniqueAliases[AnyUniqueAliases["NONE"] = 0] = "NONE";
|
||||
AnyUniqueAliases[AnyUniqueAliases["M"] = 1] = "M";
|
||||
AnyUniqueAliases[AnyUniqueAliases["TS"] = 2] = "TS";
|
||||
AnyUniqueAliases[AnyUniqueAliases["M2"] = 3] = "M2";
|
||||
})(AnyUniqueAliases || (AnyUniqueAliases = {}));
|
||||
export function unionToAnyUniqueAliases(type, accessor) {
|
||||
switch (AnyUniqueAliases[type]) {
|
||||
case 'NONE': return null;
|
||||
case 'M': return accessor(new Monster());
|
||||
case 'TS': return accessor(new TestSimpleTableWithEnum());
|
||||
case 'M2': return accessor(new MyGameExample2Monster());
|
||||
default: return null;
|
||||
}
|
||||
}
|
||||
export function unionListToAnyUniqueAliases(type, accessor, index) {
|
||||
switch (AnyUniqueAliases[type]) {
|
||||
case 'NONE': return null;
|
||||
case 'M': return accessor(index, new Monster());
|
||||
case 'TS': return accessor(index, new TestSimpleTableWithEnum());
|
||||
case 'M2': return accessor(index, new MyGameExample2Monster());
|
||||
default: return null;
|
||||
}
|
||||
}
|
||||
29
tests/my-game/example/any.js
Normal file
29
tests/my-game/example/any.js
Normal file
@@ -0,0 +1,29 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
import { Monster as MyGameExample2Monster } from '../../my-game/example2/monster';
|
||||
import { Monster } from '../../my-game/example/monster';
|
||||
import { TestSimpleTableWithEnum } from '../../my-game/example/test-simple-table-with-enum';
|
||||
export var Any;
|
||||
(function (Any) {
|
||||
Any[Any["NONE"] = 0] = "NONE";
|
||||
Any[Any["Monster"] = 1] = "Monster";
|
||||
Any[Any["TestSimpleTableWithEnum"] = 2] = "TestSimpleTableWithEnum";
|
||||
Any[Any["MyGame_Example2_Monster"] = 3] = "MyGame_Example2_Monster";
|
||||
})(Any || (Any = {}));
|
||||
export function unionToAny(type, accessor) {
|
||||
switch (Any[type]) {
|
||||
case 'NONE': return null;
|
||||
case 'Monster': return accessor(new Monster());
|
||||
case 'TestSimpleTableWithEnum': return accessor(new TestSimpleTableWithEnum());
|
||||
case 'MyGame_Example2_Monster': return accessor(new MyGameExample2Monster());
|
||||
default: return null;
|
||||
}
|
||||
}
|
||||
export function unionListToAny(type, accessor, index) {
|
||||
switch (Any[type]) {
|
||||
case 'NONE': return null;
|
||||
case 'Monster': return accessor(index, new Monster());
|
||||
case 'TestSimpleTableWithEnum': return accessor(index, new TestSimpleTableWithEnum());
|
||||
case 'MyGame_Example2_Monster': return accessor(index, new MyGameExample2Monster());
|
||||
default: return null;
|
||||
}
|
||||
}
|
||||
17
tests/my-game/example/color.js
Normal file
17
tests/my-game/example/color.js
Normal file
@@ -0,0 +1,17 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
/**
|
||||
* Composite components of Monster color.
|
||||
*/
|
||||
export var Color;
|
||||
(function (Color) {
|
||||
Color[Color["Red"] = 1] = "Red";
|
||||
/**
|
||||
* \brief color Green
|
||||
* Green is bit_flag with value (1u << 1)
|
||||
*/
|
||||
Color[Color["Green"] = 2] = "Green";
|
||||
/**
|
||||
* \brief color Blue (1u << 3)
|
||||
*/
|
||||
Color[Color["Blue"] = 8] = "Blue";
|
||||
})(Color || (Color = {}));
|
||||
1079
tests/my-game/example/monster.js
Normal file
1079
tests/my-game/example/monster.js
Normal file
File diff suppressed because it is too large
Load Diff
@@ -646,6 +646,10 @@ scalarKeySortedTablesLength():number {
|
||||
return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
|
||||
}
|
||||
|
||||
static getFullyQualifiedName():string {
|
||||
return 'MyGame.Example.Monster';
|
||||
}
|
||||
|
||||
static startMonster(builder:flatbuffers.Builder) {
|
||||
builder.startObject(51);
|
||||
}
|
||||
|
||||
8
tests/my-game/example/race.js
Normal file
8
tests/my-game/example/race.js
Normal file
@@ -0,0 +1,8 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
export var Race;
|
||||
(function (Race) {
|
||||
Race[Race["None"] = -1] = "None";
|
||||
Race[Race["Human"] = 0] = "Human";
|
||||
Race[Race["Dwarf"] = 1] = "Dwarf";
|
||||
Race[Race["Elf"] = 2] = "Elf";
|
||||
})(Race || (Race = {}));
|
||||
70
tests/my-game/example/referrable.js
Normal file
70
tests/my-game/example/referrable.js
Normal file
@@ -0,0 +1,70 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
import * as flatbuffers from 'flatbuffers';
|
||||
export class Referrable {
|
||||
constructor() {
|
||||
this.bb = null;
|
||||
this.bb_pos = 0;
|
||||
}
|
||||
__init(i, bb) {
|
||||
this.bb_pos = i;
|
||||
this.bb = bb;
|
||||
return this;
|
||||
}
|
||||
static getRootAsReferrable(bb, obj) {
|
||||
return (obj || new Referrable()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
|
||||
}
|
||||
static getSizePrefixedRootAsReferrable(bb, obj) {
|
||||
bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
|
||||
return (obj || new Referrable()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
|
||||
}
|
||||
id() {
|
||||
const offset = this.bb.__offset(this.bb_pos, 4);
|
||||
return offset ? this.bb.readUint64(this.bb_pos + offset) : this.bb.createLong(0, 0);
|
||||
}
|
||||
mutate_id(value) {
|
||||
const offset = this.bb.__offset(this.bb_pos, 4);
|
||||
if (offset === 0) {
|
||||
return false;
|
||||
}
|
||||
this.bb.writeUint64(this.bb_pos + offset, value);
|
||||
return true;
|
||||
}
|
||||
static getFullyQualifiedName() {
|
||||
return 'MyGame.Example.Referrable';
|
||||
}
|
||||
static startReferrable(builder) {
|
||||
builder.startObject(1);
|
||||
}
|
||||
static addId(builder, id) {
|
||||
builder.addFieldInt64(0, id, builder.createLong(0, 0));
|
||||
}
|
||||
static endReferrable(builder) {
|
||||
const offset = builder.endObject();
|
||||
return offset;
|
||||
}
|
||||
static createReferrable(builder, id) {
|
||||
Referrable.startReferrable(builder);
|
||||
Referrable.addId(builder, id);
|
||||
return Referrable.endReferrable(builder);
|
||||
}
|
||||
serialize() {
|
||||
return this.bb.bytes();
|
||||
}
|
||||
static deserialize(buffer) {
|
||||
return Referrable.getRootAsReferrable(new flatbuffers.ByteBuffer(buffer));
|
||||
}
|
||||
unpack() {
|
||||
return new ReferrableT(this.id());
|
||||
}
|
||||
unpackTo(_o) {
|
||||
_o.id = this.id();
|
||||
}
|
||||
}
|
||||
export class ReferrableT {
|
||||
constructor(id = flatbuffers.createLong(0, 0)) {
|
||||
this.id = id;
|
||||
}
|
||||
pack(builder) {
|
||||
return Referrable.createReferrable(builder, this.id);
|
||||
}
|
||||
}
|
||||
@@ -38,6 +38,10 @@ mutate_id(value:flatbuffers.Long):boolean {
|
||||
return true;
|
||||
}
|
||||
|
||||
static getFullyQualifiedName():string {
|
||||
return 'MyGame.Example.Referrable';
|
||||
}
|
||||
|
||||
static startReferrable(builder:flatbuffers.Builder) {
|
||||
builder.startObject(1);
|
||||
}
|
||||
|
||||
99
tests/my-game/example/stat.js
Normal file
99
tests/my-game/example/stat.js
Normal file
@@ -0,0 +1,99 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
import * as flatbuffers from 'flatbuffers';
|
||||
export class Stat {
|
||||
constructor() {
|
||||
this.bb = null;
|
||||
this.bb_pos = 0;
|
||||
}
|
||||
__init(i, bb) {
|
||||
this.bb_pos = i;
|
||||
this.bb = bb;
|
||||
return this;
|
||||
}
|
||||
static getRootAsStat(bb, obj) {
|
||||
return (obj || new Stat()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
|
||||
}
|
||||
static getSizePrefixedRootAsStat(bb, obj) {
|
||||
bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
|
||||
return (obj || new Stat()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
|
||||
}
|
||||
id(optionalEncoding) {
|
||||
const offset = this.bb.__offset(this.bb_pos, 4);
|
||||
return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null;
|
||||
}
|
||||
val() {
|
||||
const offset = this.bb.__offset(this.bb_pos, 6);
|
||||
return offset ? this.bb.readInt64(this.bb_pos + offset) : this.bb.createLong(0, 0);
|
||||
}
|
||||
mutate_val(value) {
|
||||
const offset = this.bb.__offset(this.bb_pos, 6);
|
||||
if (offset === 0) {
|
||||
return false;
|
||||
}
|
||||
this.bb.writeInt64(this.bb_pos + offset, value);
|
||||
return true;
|
||||
}
|
||||
count() {
|
||||
const offset = this.bb.__offset(this.bb_pos, 8);
|
||||
return offset ? this.bb.readUint16(this.bb_pos + offset) : 0;
|
||||
}
|
||||
mutate_count(value) {
|
||||
const offset = this.bb.__offset(this.bb_pos, 8);
|
||||
if (offset === 0) {
|
||||
return false;
|
||||
}
|
||||
this.bb.writeUint16(this.bb_pos + offset, value);
|
||||
return true;
|
||||
}
|
||||
static getFullyQualifiedName() {
|
||||
return 'MyGame.Example.Stat';
|
||||
}
|
||||
static startStat(builder) {
|
||||
builder.startObject(3);
|
||||
}
|
||||
static addId(builder, idOffset) {
|
||||
builder.addFieldOffset(0, idOffset, 0);
|
||||
}
|
||||
static addVal(builder, val) {
|
||||
builder.addFieldInt64(1, val, builder.createLong(0, 0));
|
||||
}
|
||||
static addCount(builder, count) {
|
||||
builder.addFieldInt16(2, count, 0);
|
||||
}
|
||||
static endStat(builder) {
|
||||
const offset = builder.endObject();
|
||||
return offset;
|
||||
}
|
||||
static createStat(builder, idOffset, val, count) {
|
||||
Stat.startStat(builder);
|
||||
Stat.addId(builder, idOffset);
|
||||
Stat.addVal(builder, val);
|
||||
Stat.addCount(builder, count);
|
||||
return Stat.endStat(builder);
|
||||
}
|
||||
serialize() {
|
||||
return this.bb.bytes();
|
||||
}
|
||||
static deserialize(buffer) {
|
||||
return Stat.getRootAsStat(new flatbuffers.ByteBuffer(buffer));
|
||||
}
|
||||
unpack() {
|
||||
return new StatT(this.id(), this.val(), this.count());
|
||||
}
|
||||
unpackTo(_o) {
|
||||
_o.id = this.id();
|
||||
_o.val = this.val();
|
||||
_o.count = this.count();
|
||||
}
|
||||
}
|
||||
export class StatT {
|
||||
constructor(id = null, val = flatbuffers.createLong(0, 0), count = 0) {
|
||||
this.id = id;
|
||||
this.val = val;
|
||||
this.count = count;
|
||||
}
|
||||
pack(builder) {
|
||||
const id = (this.id !== null ? builder.createString(this.id) : 0);
|
||||
return Stat.createStat(builder, id, this.val, this.count);
|
||||
}
|
||||
}
|
||||
@@ -61,6 +61,10 @@ mutate_count(value:number):boolean {
|
||||
return true;
|
||||
}
|
||||
|
||||
static getFullyQualifiedName():string {
|
||||
return 'MyGame.Example.Stat';
|
||||
}
|
||||
|
||||
static startStat(builder:flatbuffers.Builder) {
|
||||
builder.startObject(3);
|
||||
}
|
||||
|
||||
61
tests/my-game/example/struct-of-structs.js
Normal file
61
tests/my-game/example/struct-of-structs.js
Normal file
@@ -0,0 +1,61 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
import { Ability } from '../../my-game/example/ability';
|
||||
import { Test } from '../../my-game/example/test';
|
||||
export class StructOfStructs {
|
||||
constructor() {
|
||||
this.bb = null;
|
||||
this.bb_pos = 0;
|
||||
}
|
||||
__init(i, bb) {
|
||||
this.bb_pos = i;
|
||||
this.bb = bb;
|
||||
return this;
|
||||
}
|
||||
a(obj) {
|
||||
return (obj || new Ability()).__init(this.bb_pos, this.bb);
|
||||
}
|
||||
b(obj) {
|
||||
return (obj || new Test()).__init(this.bb_pos + 8, this.bb);
|
||||
}
|
||||
c(obj) {
|
||||
return (obj || new Ability()).__init(this.bb_pos + 12, this.bb);
|
||||
}
|
||||
static getFullyQualifiedName() {
|
||||
return 'MyGame.Example.StructOfStructs';
|
||||
}
|
||||
static sizeOf() {
|
||||
return 20;
|
||||
}
|
||||
static createStructOfStructs(builder, a_id, a_distance, b_a, b_b, c_id, c_distance) {
|
||||
builder.prep(4, 20);
|
||||
builder.prep(4, 8);
|
||||
builder.writeInt32(c_distance);
|
||||
builder.writeInt32(c_id);
|
||||
builder.prep(2, 4);
|
||||
builder.pad(1);
|
||||
builder.writeInt8(b_b);
|
||||
builder.writeInt16(b_a);
|
||||
builder.prep(4, 8);
|
||||
builder.writeInt32(a_distance);
|
||||
builder.writeInt32(a_id);
|
||||
return builder.offset();
|
||||
}
|
||||
unpack() {
|
||||
return new StructOfStructsT((this.a() !== null ? this.a().unpack() : null), (this.b() !== null ? this.b().unpack() : null), (this.c() !== null ? this.c().unpack() : null));
|
||||
}
|
||||
unpackTo(_o) {
|
||||
_o.a = (this.a() !== null ? this.a().unpack() : null);
|
||||
_o.b = (this.b() !== null ? this.b().unpack() : null);
|
||||
_o.c = (this.c() !== null ? this.c().unpack() : null);
|
||||
}
|
||||
}
|
||||
export class StructOfStructsT {
|
||||
constructor(a = null, b = null, c = null) {
|
||||
this.a = a;
|
||||
this.b = b;
|
||||
this.c = c;
|
||||
}
|
||||
pack(builder) {
|
||||
return StructOfStructs.createStructOfStructs(builder, (this.a === null ? 0 : this.a.id), (this.a === null ? 0 : this.a.distance), (this.b === null ? 0 : this.b.a), (this.b === null ? 0 : this.b.b), (this.c === null ? 0 : this.c.id), (this.c === null ? 0 : this.c.distance));
|
||||
}
|
||||
}
|
||||
@@ -27,6 +27,10 @@ c(obj?:Ability):Ability|null {
|
||||
return (obj || new Ability()).__init(this.bb_pos + 12, this.bb!);
|
||||
}
|
||||
|
||||
static getFullyQualifiedName():string {
|
||||
return 'MyGame.Example.StructOfStructs';
|
||||
}
|
||||
|
||||
static sizeOf():number {
|
||||
return 20;
|
||||
}
|
||||
|
||||
71
tests/my-game/example/test-simple-table-with-enum.js
Normal file
71
tests/my-game/example/test-simple-table-with-enum.js
Normal file
@@ -0,0 +1,71 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
import * as flatbuffers from 'flatbuffers';
|
||||
import { Color } from '../../my-game/example/color';
|
||||
export class TestSimpleTableWithEnum {
|
||||
constructor() {
|
||||
this.bb = null;
|
||||
this.bb_pos = 0;
|
||||
}
|
||||
__init(i, bb) {
|
||||
this.bb_pos = i;
|
||||
this.bb = bb;
|
||||
return this;
|
||||
}
|
||||
static getRootAsTestSimpleTableWithEnum(bb, obj) {
|
||||
return (obj || new TestSimpleTableWithEnum()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
|
||||
}
|
||||
static getSizePrefixedRootAsTestSimpleTableWithEnum(bb, obj) {
|
||||
bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
|
||||
return (obj || new TestSimpleTableWithEnum()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
|
||||
}
|
||||
color() {
|
||||
const offset = this.bb.__offset(this.bb_pos, 4);
|
||||
return offset ? this.bb.readUint8(this.bb_pos + offset) : Color.Green;
|
||||
}
|
||||
mutate_color(value) {
|
||||
const offset = this.bb.__offset(this.bb_pos, 4);
|
||||
if (offset === 0) {
|
||||
return false;
|
||||
}
|
||||
this.bb.writeUint8(this.bb_pos + offset, value);
|
||||
return true;
|
||||
}
|
||||
static getFullyQualifiedName() {
|
||||
return 'MyGame.Example.TestSimpleTableWithEnum';
|
||||
}
|
||||
static startTestSimpleTableWithEnum(builder) {
|
||||
builder.startObject(1);
|
||||
}
|
||||
static addColor(builder, color) {
|
||||
builder.addFieldInt8(0, color, Color.Green);
|
||||
}
|
||||
static endTestSimpleTableWithEnum(builder) {
|
||||
const offset = builder.endObject();
|
||||
return offset;
|
||||
}
|
||||
static createTestSimpleTableWithEnum(builder, color) {
|
||||
TestSimpleTableWithEnum.startTestSimpleTableWithEnum(builder);
|
||||
TestSimpleTableWithEnum.addColor(builder, color);
|
||||
return TestSimpleTableWithEnum.endTestSimpleTableWithEnum(builder);
|
||||
}
|
||||
serialize() {
|
||||
return this.bb.bytes();
|
||||
}
|
||||
static deserialize(buffer) {
|
||||
return TestSimpleTableWithEnum.getRootAsTestSimpleTableWithEnum(new flatbuffers.ByteBuffer(buffer));
|
||||
}
|
||||
unpack() {
|
||||
return new TestSimpleTableWithEnumT(this.color());
|
||||
}
|
||||
unpackTo(_o) {
|
||||
_o.color = this.color();
|
||||
}
|
||||
}
|
||||
export class TestSimpleTableWithEnumT {
|
||||
constructor(color = Color.Green) {
|
||||
this.color = color;
|
||||
}
|
||||
pack(builder) {
|
||||
return TestSimpleTableWithEnum.createTestSimpleTableWithEnum(builder, this.color);
|
||||
}
|
||||
}
|
||||
@@ -39,6 +39,10 @@ mutate_color(value:Color):boolean {
|
||||
return true;
|
||||
}
|
||||
|
||||
static getFullyQualifiedName():string {
|
||||
return 'MyGame.Example.TestSimpleTableWithEnum';
|
||||
}
|
||||
|
||||
static startTestSimpleTableWithEnum(builder:flatbuffers.Builder) {
|
||||
builder.startObject(1);
|
||||
}
|
||||
|
||||
55
tests/my-game/example/test.js
Normal file
55
tests/my-game/example/test.js
Normal file
@@ -0,0 +1,55 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
export class Test {
|
||||
constructor() {
|
||||
this.bb = null;
|
||||
this.bb_pos = 0;
|
||||
}
|
||||
__init(i, bb) {
|
||||
this.bb_pos = i;
|
||||
this.bb = bb;
|
||||
return this;
|
||||
}
|
||||
a() {
|
||||
return this.bb.readInt16(this.bb_pos);
|
||||
}
|
||||
mutate_a(value) {
|
||||
this.bb.writeInt16(this.bb_pos + 0, value);
|
||||
return true;
|
||||
}
|
||||
b() {
|
||||
return this.bb.readInt8(this.bb_pos + 2);
|
||||
}
|
||||
mutate_b(value) {
|
||||
this.bb.writeInt8(this.bb_pos + 2, value);
|
||||
return true;
|
||||
}
|
||||
static getFullyQualifiedName() {
|
||||
return 'MyGame.Example.Test';
|
||||
}
|
||||
static sizeOf() {
|
||||
return 4;
|
||||
}
|
||||
static createTest(builder, a, b) {
|
||||
builder.prep(2, 4);
|
||||
builder.pad(1);
|
||||
builder.writeInt8(b);
|
||||
builder.writeInt16(a);
|
||||
return builder.offset();
|
||||
}
|
||||
unpack() {
|
||||
return new TestT(this.a(), this.b());
|
||||
}
|
||||
unpackTo(_o) {
|
||||
_o.a = this.a();
|
||||
_o.b = this.b();
|
||||
}
|
||||
}
|
||||
export class TestT {
|
||||
constructor(a = 0, b = 0) {
|
||||
this.a = a;
|
||||
this.b = b;
|
||||
}
|
||||
pack(builder) {
|
||||
return Test.createTest(builder, this.a, this.b);
|
||||
}
|
||||
}
|
||||
@@ -31,6 +31,10 @@ mutate_b(value:number):boolean {
|
||||
return true;
|
||||
}
|
||||
|
||||
static getFullyQualifiedName():string {
|
||||
return 'MyGame.Example.Test';
|
||||
}
|
||||
|
||||
static sizeOf():number {
|
||||
return 4;
|
||||
}
|
||||
|
||||
290
tests/my-game/example/type-aliases.js
Normal file
290
tests/my-game/example/type-aliases.js
Normal file
@@ -0,0 +1,290 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
import * as flatbuffers from 'flatbuffers';
|
||||
export class TypeAliases {
|
||||
constructor() {
|
||||
this.bb = null;
|
||||
this.bb_pos = 0;
|
||||
}
|
||||
__init(i, bb) {
|
||||
this.bb_pos = i;
|
||||
this.bb = bb;
|
||||
return this;
|
||||
}
|
||||
static getRootAsTypeAliases(bb, obj) {
|
||||
return (obj || new TypeAliases()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
|
||||
}
|
||||
static getSizePrefixedRootAsTypeAliases(bb, obj) {
|
||||
bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
|
||||
return (obj || new TypeAliases()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
|
||||
}
|
||||
i8() {
|
||||
const offset = this.bb.__offset(this.bb_pos, 4);
|
||||
return offset ? this.bb.readInt8(this.bb_pos + offset) : 0;
|
||||
}
|
||||
mutate_i8(value) {
|
||||
const offset = this.bb.__offset(this.bb_pos, 4);
|
||||
if (offset === 0) {
|
||||
return false;
|
||||
}
|
||||
this.bb.writeInt8(this.bb_pos + offset, value);
|
||||
return true;
|
||||
}
|
||||
u8() {
|
||||
const offset = this.bb.__offset(this.bb_pos, 6);
|
||||
return offset ? this.bb.readUint8(this.bb_pos + offset) : 0;
|
||||
}
|
||||
mutate_u8(value) {
|
||||
const offset = this.bb.__offset(this.bb_pos, 6);
|
||||
if (offset === 0) {
|
||||
return false;
|
||||
}
|
||||
this.bb.writeUint8(this.bb_pos + offset, value);
|
||||
return true;
|
||||
}
|
||||
i16() {
|
||||
const offset = this.bb.__offset(this.bb_pos, 8);
|
||||
return offset ? this.bb.readInt16(this.bb_pos + offset) : 0;
|
||||
}
|
||||
mutate_i16(value) {
|
||||
const offset = this.bb.__offset(this.bb_pos, 8);
|
||||
if (offset === 0) {
|
||||
return false;
|
||||
}
|
||||
this.bb.writeInt16(this.bb_pos + offset, value);
|
||||
return true;
|
||||
}
|
||||
u16() {
|
||||
const offset = this.bb.__offset(this.bb_pos, 10);
|
||||
return offset ? this.bb.readUint16(this.bb_pos + offset) : 0;
|
||||
}
|
||||
mutate_u16(value) {
|
||||
const offset = this.bb.__offset(this.bb_pos, 10);
|
||||
if (offset === 0) {
|
||||
return false;
|
||||
}
|
||||
this.bb.writeUint16(this.bb_pos + offset, value);
|
||||
return true;
|
||||
}
|
||||
i32() {
|
||||
const offset = this.bb.__offset(this.bb_pos, 12);
|
||||
return offset ? this.bb.readInt32(this.bb_pos + offset) : 0;
|
||||
}
|
||||
mutate_i32(value) {
|
||||
const offset = this.bb.__offset(this.bb_pos, 12);
|
||||
if (offset === 0) {
|
||||
return false;
|
||||
}
|
||||
this.bb.writeInt32(this.bb_pos + offset, value);
|
||||
return true;
|
||||
}
|
||||
u32() {
|
||||
const offset = this.bb.__offset(this.bb_pos, 14);
|
||||
return offset ? this.bb.readUint32(this.bb_pos + offset) : 0;
|
||||
}
|
||||
mutate_u32(value) {
|
||||
const offset = this.bb.__offset(this.bb_pos, 14);
|
||||
if (offset === 0) {
|
||||
return false;
|
||||
}
|
||||
this.bb.writeUint32(this.bb_pos + offset, value);
|
||||
return true;
|
||||
}
|
||||
i64() {
|
||||
const offset = this.bb.__offset(this.bb_pos, 16);
|
||||
return offset ? this.bb.readInt64(this.bb_pos + offset) : this.bb.createLong(0, 0);
|
||||
}
|
||||
mutate_i64(value) {
|
||||
const offset = this.bb.__offset(this.bb_pos, 16);
|
||||
if (offset === 0) {
|
||||
return false;
|
||||
}
|
||||
this.bb.writeInt64(this.bb_pos + offset, value);
|
||||
return true;
|
||||
}
|
||||
u64() {
|
||||
const offset = this.bb.__offset(this.bb_pos, 18);
|
||||
return offset ? this.bb.readUint64(this.bb_pos + offset) : this.bb.createLong(0, 0);
|
||||
}
|
||||
mutate_u64(value) {
|
||||
const offset = this.bb.__offset(this.bb_pos, 18);
|
||||
if (offset === 0) {
|
||||
return false;
|
||||
}
|
||||
this.bb.writeUint64(this.bb_pos + offset, value);
|
||||
return true;
|
||||
}
|
||||
f32() {
|
||||
const offset = this.bb.__offset(this.bb_pos, 20);
|
||||
return offset ? this.bb.readFloat32(this.bb_pos + offset) : 0.0;
|
||||
}
|
||||
mutate_f32(value) {
|
||||
const offset = this.bb.__offset(this.bb_pos, 20);
|
||||
if (offset === 0) {
|
||||
return false;
|
||||
}
|
||||
this.bb.writeFloat32(this.bb_pos + offset, value);
|
||||
return true;
|
||||
}
|
||||
f64() {
|
||||
const offset = this.bb.__offset(this.bb_pos, 22);
|
||||
return offset ? this.bb.readFloat64(this.bb_pos + offset) : 0.0;
|
||||
}
|
||||
mutate_f64(value) {
|
||||
const offset = this.bb.__offset(this.bb_pos, 22);
|
||||
if (offset === 0) {
|
||||
return false;
|
||||
}
|
||||
this.bb.writeFloat64(this.bb_pos + offset, value);
|
||||
return true;
|
||||
}
|
||||
v8(index) {
|
||||
const offset = this.bb.__offset(this.bb_pos, 24);
|
||||
return offset ? this.bb.readInt8(this.bb.__vector(this.bb_pos + offset) + index) : 0;
|
||||
}
|
||||
v8Length() {
|
||||
const offset = this.bb.__offset(this.bb_pos, 24);
|
||||
return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0;
|
||||
}
|
||||
v8Array() {
|
||||
const offset = this.bb.__offset(this.bb_pos, 24);
|
||||
return offset ? new Int8Array(this.bb.bytes().buffer, this.bb.bytes().byteOffset + this.bb.__vector(this.bb_pos + offset), this.bb.__vector_len(this.bb_pos + offset)) : null;
|
||||
}
|
||||
vf64(index) {
|
||||
const offset = this.bb.__offset(this.bb_pos, 26);
|
||||
return offset ? this.bb.readFloat64(this.bb.__vector(this.bb_pos + offset) + index * 8) : 0;
|
||||
}
|
||||
vf64Length() {
|
||||
const offset = this.bb.__offset(this.bb_pos, 26);
|
||||
return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0;
|
||||
}
|
||||
vf64Array() {
|
||||
const offset = this.bb.__offset(this.bb_pos, 26);
|
||||
return offset ? new Float64Array(this.bb.bytes().buffer, this.bb.bytes().byteOffset + this.bb.__vector(this.bb_pos + offset), this.bb.__vector_len(this.bb_pos + offset)) : null;
|
||||
}
|
||||
static getFullyQualifiedName() {
|
||||
return 'MyGame.Example.TypeAliases';
|
||||
}
|
||||
static startTypeAliases(builder) {
|
||||
builder.startObject(12);
|
||||
}
|
||||
static addI8(builder, i8) {
|
||||
builder.addFieldInt8(0, i8, 0);
|
||||
}
|
||||
static addU8(builder, u8) {
|
||||
builder.addFieldInt8(1, u8, 0);
|
||||
}
|
||||
static addI16(builder, i16) {
|
||||
builder.addFieldInt16(2, i16, 0);
|
||||
}
|
||||
static addU16(builder, u16) {
|
||||
builder.addFieldInt16(3, u16, 0);
|
||||
}
|
||||
static addI32(builder, i32) {
|
||||
builder.addFieldInt32(4, i32, 0);
|
||||
}
|
||||
static addU32(builder, u32) {
|
||||
builder.addFieldInt32(5, u32, 0);
|
||||
}
|
||||
static addI64(builder, i64) {
|
||||
builder.addFieldInt64(6, i64, builder.createLong(0, 0));
|
||||
}
|
||||
static addU64(builder, u64) {
|
||||
builder.addFieldInt64(7, u64, builder.createLong(0, 0));
|
||||
}
|
||||
static addF32(builder, f32) {
|
||||
builder.addFieldFloat32(8, f32, 0.0);
|
||||
}
|
||||
static addF64(builder, f64) {
|
||||
builder.addFieldFloat64(9, f64, 0.0);
|
||||
}
|
||||
static addV8(builder, v8Offset) {
|
||||
builder.addFieldOffset(10, v8Offset, 0);
|
||||
}
|
||||
static createV8Vector(builder, data) {
|
||||
builder.startVector(1, data.length, 1);
|
||||
for (let i = data.length - 1; i >= 0; i--) {
|
||||
builder.addInt8(data[i]);
|
||||
}
|
||||
return builder.endVector();
|
||||
}
|
||||
static startV8Vector(builder, numElems) {
|
||||
builder.startVector(1, numElems, 1);
|
||||
}
|
||||
static addVf64(builder, vf64Offset) {
|
||||
builder.addFieldOffset(11, vf64Offset, 0);
|
||||
}
|
||||
static createVf64Vector(builder, data) {
|
||||
builder.startVector(8, data.length, 8);
|
||||
for (let i = data.length - 1; i >= 0; i--) {
|
||||
builder.addFloat64(data[i]);
|
||||
}
|
||||
return builder.endVector();
|
||||
}
|
||||
static startVf64Vector(builder, numElems) {
|
||||
builder.startVector(8, numElems, 8);
|
||||
}
|
||||
static endTypeAliases(builder) {
|
||||
const offset = builder.endObject();
|
||||
return offset;
|
||||
}
|
||||
static createTypeAliases(builder, i8, u8, i16, u16, i32, u32, i64, u64, f32, f64, v8Offset, vf64Offset) {
|
||||
TypeAliases.startTypeAliases(builder);
|
||||
TypeAliases.addI8(builder, i8);
|
||||
TypeAliases.addU8(builder, u8);
|
||||
TypeAliases.addI16(builder, i16);
|
||||
TypeAliases.addU16(builder, u16);
|
||||
TypeAliases.addI32(builder, i32);
|
||||
TypeAliases.addU32(builder, u32);
|
||||
TypeAliases.addI64(builder, i64);
|
||||
TypeAliases.addU64(builder, u64);
|
||||
TypeAliases.addF32(builder, f32);
|
||||
TypeAliases.addF64(builder, f64);
|
||||
TypeAliases.addV8(builder, v8Offset);
|
||||
TypeAliases.addVf64(builder, vf64Offset);
|
||||
return TypeAliases.endTypeAliases(builder);
|
||||
}
|
||||
serialize() {
|
||||
return this.bb.bytes();
|
||||
}
|
||||
static deserialize(buffer) {
|
||||
return TypeAliases.getRootAsTypeAliases(new flatbuffers.ByteBuffer(buffer));
|
||||
}
|
||||
unpack() {
|
||||
return new TypeAliasesT(this.i8(), this.u8(), this.i16(), this.u16(), this.i32(), this.u32(), this.i64(), this.u64(), this.f32(), this.f64(), this.bb.createScalarList(this.v8.bind(this), this.v8Length()), this.bb.createScalarList(this.vf64.bind(this), this.vf64Length()));
|
||||
}
|
||||
unpackTo(_o) {
|
||||
_o.i8 = this.i8();
|
||||
_o.u8 = this.u8();
|
||||
_o.i16 = this.i16();
|
||||
_o.u16 = this.u16();
|
||||
_o.i32 = this.i32();
|
||||
_o.u32 = this.u32();
|
||||
_o.i64 = this.i64();
|
||||
_o.u64 = this.u64();
|
||||
_o.f32 = this.f32();
|
||||
_o.f64 = this.f64();
|
||||
_o.v8 = this.bb.createScalarList(this.v8.bind(this), this.v8Length());
|
||||
_o.vf64 = this.bb.createScalarList(this.vf64.bind(this), this.vf64Length());
|
||||
}
|
||||
}
|
||||
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 = []) {
|
||||
this.i8 = i8;
|
||||
this.u8 = u8;
|
||||
this.i16 = i16;
|
||||
this.u16 = u16;
|
||||
this.i32 = i32;
|
||||
this.u32 = u32;
|
||||
this.i64 = i64;
|
||||
this.u64 = u64;
|
||||
this.f32 = f32;
|
||||
this.f64 = f64;
|
||||
this.v8 = v8;
|
||||
this.vf64 = vf64;
|
||||
}
|
||||
pack(builder) {
|
||||
const v8 = TypeAliases.createV8Vector(builder, this.v8);
|
||||
const vf64 = TypeAliases.createVf64Vector(builder, this.vf64);
|
||||
return TypeAliases.createTypeAliases(builder, this.i8, this.u8, this.i16, this.u16, this.i32, this.u32, this.i64, this.u64, this.f32, this.f64, v8, vf64);
|
||||
}
|
||||
}
|
||||
@@ -212,6 +212,10 @@ vf64Array():Float64Array|null {
|
||||
return offset ? new Float64Array(this.bb!.bytes().buffer, this.bb!.bytes().byteOffset + this.bb!.__vector(this.bb_pos + offset), this.bb!.__vector_len(this.bb_pos + offset)) : null;
|
||||
}
|
||||
|
||||
static getFullyQualifiedName():string {
|
||||
return 'MyGame.Example.TypeAliases';
|
||||
}
|
||||
|
||||
static startTypeAliases(builder:flatbuffers.Builder) {
|
||||
builder.startObject(12);
|
||||
}
|
||||
|
||||
97
tests/my-game/example/vec3.js
Normal file
97
tests/my-game/example/vec3.js
Normal file
@@ -0,0 +1,97 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
import { Test } from '../../my-game/example/test';
|
||||
export class Vec3 {
|
||||
constructor() {
|
||||
this.bb = null;
|
||||
this.bb_pos = 0;
|
||||
}
|
||||
__init(i, bb) {
|
||||
this.bb_pos = i;
|
||||
this.bb = bb;
|
||||
return this;
|
||||
}
|
||||
x() {
|
||||
return this.bb.readFloat32(this.bb_pos);
|
||||
}
|
||||
mutate_x(value) {
|
||||
this.bb.writeFloat32(this.bb_pos + 0, value);
|
||||
return true;
|
||||
}
|
||||
y() {
|
||||
return this.bb.readFloat32(this.bb_pos + 4);
|
||||
}
|
||||
mutate_y(value) {
|
||||
this.bb.writeFloat32(this.bb_pos + 4, value);
|
||||
return true;
|
||||
}
|
||||
z() {
|
||||
return this.bb.readFloat32(this.bb_pos + 8);
|
||||
}
|
||||
mutate_z(value) {
|
||||
this.bb.writeFloat32(this.bb_pos + 8, value);
|
||||
return true;
|
||||
}
|
||||
test1() {
|
||||
return this.bb.readFloat64(this.bb_pos + 16);
|
||||
}
|
||||
mutate_test1(value) {
|
||||
this.bb.writeFloat64(this.bb_pos + 16, value);
|
||||
return true;
|
||||
}
|
||||
test2() {
|
||||
return this.bb.readUint8(this.bb_pos + 24);
|
||||
}
|
||||
mutate_test2(value) {
|
||||
this.bb.writeUint8(this.bb_pos + 24, value);
|
||||
return true;
|
||||
}
|
||||
test3(obj) {
|
||||
return (obj || new Test()).__init(this.bb_pos + 26, this.bb);
|
||||
}
|
||||
static getFullyQualifiedName() {
|
||||
return 'MyGame.Example.Vec3';
|
||||
}
|
||||
static sizeOf() {
|
||||
return 32;
|
||||
}
|
||||
static createVec3(builder, x, y, z, test1, test2, test3_a, test3_b) {
|
||||
builder.prep(8, 32);
|
||||
builder.pad(2);
|
||||
builder.prep(2, 4);
|
||||
builder.pad(1);
|
||||
builder.writeInt8(test3_b);
|
||||
builder.writeInt16(test3_a);
|
||||
builder.pad(1);
|
||||
builder.writeInt8(test2);
|
||||
builder.writeFloat64(test1);
|
||||
builder.pad(4);
|
||||
builder.writeFloat32(z);
|
||||
builder.writeFloat32(y);
|
||||
builder.writeFloat32(x);
|
||||
return builder.offset();
|
||||
}
|
||||
unpack() {
|
||||
return new Vec3T(this.x(), this.y(), this.z(), this.test1(), this.test2(), (this.test3() !== null ? this.test3().unpack() : null));
|
||||
}
|
||||
unpackTo(_o) {
|
||||
_o.x = this.x();
|
||||
_o.y = this.y();
|
||||
_o.z = this.z();
|
||||
_o.test1 = this.test1();
|
||||
_o.test2 = this.test2();
|
||||
_o.test3 = (this.test3() !== null ? this.test3().unpack() : null);
|
||||
}
|
||||
}
|
||||
export class Vec3T {
|
||||
constructor(x = 0.0, y = 0.0, z = 0.0, test1 = 0.0, test2 = 0, test3 = null) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
this.test1 = test1;
|
||||
this.test2 = test2;
|
||||
this.test3 = test3;
|
||||
}
|
||||
pack(builder) {
|
||||
return Vec3.createVec3(builder, this.x, this.y, this.z, this.test1, this.test2, (this.test3 === null ? 0 : this.test3.a), (this.test3 === null ? 0 : this.test3.b));
|
||||
}
|
||||
}
|
||||
@@ -64,6 +64,10 @@ test3(obj?:Test):Test|null {
|
||||
return (obj || new Test()).__init(this.bb_pos + 26, this.bb!);
|
||||
}
|
||||
|
||||
static getFullyQualifiedName():string {
|
||||
return 'MyGame.Example.Vec3';
|
||||
}
|
||||
|
||||
static sizeOf():number {
|
||||
return 32;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user