diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2b7c06f50d9..cb4e1f39b4f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -459,7 +459,7 @@ jobs: - name: compile run: yarn compile - name: test - working-directory: tests + working-directory: tests/ts run: python3 TypeScriptTest.py build-dart: diff --git a/grpc/examples/ts/greeter/src/greeter_generated.ts b/grpc/examples/ts/greeter/src/greeter_generated.ts index ddda80de875..c48afe53845 100644 --- a/grpc/examples/ts/greeter/src/greeter_generated.ts +++ b/grpc/examples/ts/greeter/src/greeter_generated.ts @@ -1,4 +1,4 @@ // automatically generated by the FlatBuffers compiler, do not modify -export { HelloReply } from './models/hello-reply'; -export { HelloRequest } from './models/hello-request'; +export { HelloReply } from './models/hello-reply.js'; +export { HelloRequest } from './models/hello-request.js'; diff --git a/package.json b/package.json index 178d848c018..26e08416342 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "test": "tests" }, "scripts": { - "test": "npm run compile && cd tests && python3 ./TypeScriptTest.py", + "test": "npm run compile && cd tests/ts && python3 ./TypeScriptTest.py", "compile": "tsc && tsc -p tsconfig.mjs.json && rollup -c", "prepublishOnly": "npm install --only=dev && npm run compile" }, @@ -35,12 +35,12 @@ "homepage": "https://google.github.io/flatbuffers/", "dependencies": {}, "devDependencies": { - "@bazel/typescript": "^5.2.0", - "@types/node": "17.0.21", - "@typescript-eslint/eslint-plugin": "^4.12.0", - "@typescript-eslint/parser": "^4.12.0", - "eslint": "^7.17.0", - "rollup": "^2.78.0", - "typescript": "^4.5.5" + "@bazel/typescript": "5.2.0", + "@types/node": "18.7.16", + "@typescript-eslint/eslint-plugin": "^5.36.2", + "@typescript-eslint/parser": "^5.36.2", + "eslint": "^8.23.1", + "rollup": "^2.79.0", + "typescript": "^4.8.3" } } diff --git a/scripts/generate_code.py b/scripts/generate_code.py index 743280240e1..7111d8d313c 100755 --- a/scripts/generate_code.py +++ b/scripts/generate_code.py @@ -165,7 +165,6 @@ def glob(path, pattern): NO_INCL_OPTS + CPP_OPTS + CS_OPTS - + TS_OPTS + [ "--binary", "--java", @@ -180,6 +179,15 @@ def glob(path, pattern): data="monsterdata_test.json", ) +flatc( + NO_INCL_OPTS + + TS_OPTS, + schema="monster_test.fbs", + prefix="ts", + include="include_test", + data="monsterdata_test.json", +) + flatc( ["--lua", "--bfbs-filenames", str(tests_path)], schema="monster_test.fbs", @@ -235,14 +243,21 @@ def glob(path, pattern): ) flatc( - BASE_OPTS + CPP_OPTS + CS_OPTS + TS_OPTS + JAVA_OPTS + KOTLIN_OPTS + PHP_OPTS, + BASE_OPTS + CPP_OPTS + CS_OPTS + JAVA_OPTS + KOTLIN_OPTS + PHP_OPTS, prefix="union_vector", schema="union_vector/union_vector.fbs", ) +flatc( + BASE_OPTS + TS_OPTS, + prefix="ts/union_vector", + schema="union_vector/union_vector.fbs", +) + flatc( BASE_OPTS + TS_OPTS + ["--gen-name-strings", "--gen-mutable"], include="include_test", + prefix="ts", schema="monster_test.fbs", ) @@ -257,13 +272,14 @@ def glob(path, pattern): flatc( BASE_OPTS + TS_OPTS + ["-b"], include="include_test", + prefix="ts", schema="monster_test.fbs", data="unicode_test.json", ) flatc( BASE_OPTS + TS_OPTS + ["--gen-name-strings"], - prefix="union_vector", + prefix="ts/union_vector", schema="union_vector/union_vector.fbs", ) @@ -357,7 +373,8 @@ def glob(path, pattern): # Optional Scalars optional_scalars_schema = "optional_scalars.fbs" -flatc(["--java", "--kotlin", "--lobster", "--ts"], schema=optional_scalars_schema) +flatc(["--java", "--kotlin", "--lobster"], schema=optional_scalars_schema) +flatc(TS_OPTS, schema=optional_scalars_schema, prefix="ts") flatc(["--csharp", "--python", "--gen-object-api"], schema=optional_scalars_schema) diff --git a/src/idl_gen_ts.cpp b/src/idl_gen_ts.cpp index 8b9381c4954..32ab863edc9 100644 --- a/src/idl_gen_ts.cpp +++ b/src/idl_gen_ts.cpp @@ -263,7 +263,7 @@ class TsGenerator : public BaseGenerator { namer_.EscapeKeyword(pair.second) + ", "; } code.resize(code.size() - 2); - code += "} from '" + include_name + "';\n"; + code += "} from '" + include_name + ".js';\n"; } code += "\n"; } @@ -760,9 +760,9 @@ class TsGenerator : public BaseGenerator { import.bare_file_path = bare_file_path; import.rel_file_path = rel_file_path; import.import_statement = - "import { " + symbols_expression + " } from '" + rel_file_path + "';"; + "import { " + symbols_expression + " } from '" + rel_file_path + ".js';"; import.export_statement = - "export { " + symbols_expression + " } from '." + bare_file_path + "';"; + "export { " + symbols_expression + " } from '." + bare_file_path + ".js';"; import.dependency = &dependency; import.dependent = &dependent; diff --git a/tests/BUILD.bazel b/tests/BUILD.bazel index 1e8ccc0772d..3330bfc530a 100644 --- a/tests/BUILD.bazel +++ b/tests/BUILD.bazel @@ -1,6 +1,5 @@ load("@rules_cc//cc:defs.bzl", "cc_test") load("//:build_defs.bzl", "flatbuffer_cc_library") -load("//:typescript.bzl", "flatbuffer_ts_library") package(default_visibility = ["//visibility:private"]) @@ -215,12 +214,3 @@ flatbuffer_cc_library( "--cpp-ptr-type flatbuffers::unique_ptr", ], ) - -flatbuffer_ts_library( - name = "typescript_ts_fbs", - srcs = ["typescript_keywords.fbs"], - deps = [ - "//tests/test_dir:include_ts_fbs", - "//tests/test_dir:typescript_transitive_ts_fbs", - ], -) diff --git a/tests/flatc/flatc_ts_tests.py b/tests/flatc/flatc_ts_tests.py index a0c7f823d57..6e444bc417f 100755 --- a/tests/flatc/flatc_ts_tests.py +++ b/tests/flatc/flatc_ts_tests.py @@ -26,8 +26,8 @@ def Base(self): assert_file_and_contents( "foo_generated.ts", [ - "export { Bar } from './bar';", - "export { Foo } from './foo';", + "export { Bar } from './bar.js';", + "export { Foo } from './foo.js';", ], ) @@ -46,8 +46,8 @@ def BaseMultipleFiles(self): assert_file_and_contents( "foo_generated.ts", [ - "export { Bar } from './bar';", - "export { Foo } from './foo';", + "export { Bar } from './bar.js';", + "export { Foo } from './foo.js';", ], ) @@ -66,8 +66,8 @@ def BaseWithNamespace(self): assert_file_and_contents( "foo_with_ns_generated.ts", [ - "export { Bar } from './bar/bar';", - "export { Foo } from './something/foo';", + "export { Bar } from './bar/bar.js';", + "export { Foo } from './something/foo.js';", ], ) @@ -77,7 +77,7 @@ def BaseWithNamespace(self): "something/foo.ts", [ "export class Foo {", - "import { Bar } from '../bar/bar';", + "import { Bar } from '../bar/bar.js';", ], ) @@ -92,9 +92,9 @@ def GenAll(self): assert_file_and_contents( "foo_generated.ts", [ - "export { Bar } from './bar'", - "export { Baz } from './baz'", - "export { Foo } from './foo'", + "export { Bar } from './bar.js'", + "export { Baz } from './baz.js'", + "export { Foo } from './foo.js'", ], ) @@ -102,7 +102,7 @@ def GenAll(self): assert_file_and_contents( "foo.ts", [ - "import { Bar } from './bar';", + "import { Bar } from './bar.js';", "export class Foo {", ], ) @@ -111,7 +111,7 @@ def GenAll(self): assert_file_and_contents( "bar.ts", [ - "import { Baz } from './baz';", + "import { Baz } from './baz.js';", "export class Bar {", ], ) @@ -134,7 +134,7 @@ def FlatFiles(self): assert_file_and_contents( "foo_generated.ts", [ - "import {Bar as Bar} from './bar_generated';", + "import {Bar as Bar} from './bar_generated.js';", "export class Foo {", ], ) @@ -151,7 +151,7 @@ def FlatFilesWithNamespace(self): assert_file_and_contents( "foo_with_ns_generated.ts", [ - "import {Bar as Bar} from './bar_with_ns_generated';", + "import {Bar as Bar} from './bar_with_ns_generated.js';", "export class Foo {", ], ) @@ -168,7 +168,7 @@ def FlatFilesMultipleFiles(self): assert_file_and_contents( "foo_generated.ts", [ - "import {Bar as Bar} from './bar_generated';", + "import {Bar as Bar} from './bar_generated.js';", "export class Foo {", ], ) @@ -178,7 +178,7 @@ def FlatFilesMultipleFiles(self): assert_file_and_contents( "bar_generated.ts", [ - "import {Baz as Baz} from './baz_generated';", + "import {Baz as Baz} from './baz_generated.js';", "export class Bar {", ], ) diff --git a/tests/package.json b/tests/package.json deleted file mode 100644 index 654e57fe256..00000000000 --- a/tests/package.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "dependencies": { - "esm": "^3.2.25", - "flatbuffers": "../", - "grpc": "^1.24.6" - } -} diff --git a/tests/ts/BUILD.bazel b/tests/ts/BUILD.bazel new file mode 100644 index 00000000000..054011a57b4 --- /dev/null +++ b/tests/ts/BUILD.bazel @@ -0,0 +1,12 @@ +load("//:typescript.bzl", "flatbuffer_ts_library") + +package(default_visibility = ["//visibility:private"]) + +flatbuffer_ts_library( + name = "typescript_ts_fbs", + srcs = ["typescript_keywords.fbs"], + deps = [ + "//tests/ts/test_dir:include_ts_fbs", + "//tests/ts/test_dir:typescript_transitive_ts_fbs", + ], +) diff --git a/tests/JavaScriptFlexBuffersTest.js b/tests/ts/JavaScriptFlexBuffersTest.js similarity index 98% rename from tests/JavaScriptFlexBuffersTest.js rename to tests/ts/JavaScriptFlexBuffersTest.js index f7ea85fb8b5..04e670c2e77 100644 --- a/tests/JavaScriptFlexBuffersTest.js +++ b/tests/ts/JavaScriptFlexBuffersTest.js @@ -1,7 +1,7 @@ // Run this using JavaScriptTest.sh import assert from 'assert' import fs from 'fs' -import * as flexbuffers from 'flatbuffers/js/flexbuffers' +import * as flexbuffers from 'flatbuffers/js/flexbuffers.js' function main() { testSingleValueBuffers(); @@ -341,7 +341,7 @@ function testRoundTripWithBuilder() { } function testGoldBuffer() { - const data = new Uint8Array(fs.readFileSync('gold_flexbuffer_example.bin')).buffer; + const data = new Uint8Array(fs.readFileSync('../gold_flexbuffer_example.bin')).buffer; const b1 = flexbuffers.toReference(data).get("bools").get(1); assert.strictEqual(b1.isBool(), true); assert.strictEqual(b1.boolValue(), false); diff --git a/tests/JavaScriptTest.js b/tests/ts/JavaScriptTest.js similarity index 96% rename from tests/JavaScriptTest.js rename to tests/ts/JavaScriptTest.js index 5e70056b397..b76dd2ed536 100644 --- a/tests/JavaScriptTest.js +++ b/tests/ts/JavaScriptTest.js @@ -3,18 +3,18 @@ import assert from 'assert' import fs from 'fs' import * as flatbuffers from 'flatbuffers' -import { Monster, MonsterT } from './my-game/example/monster' -import { Test, TestT } from './my-game/example/test' -import { Stat } from './my-game/example/stat' -import { Vec3 } from './my-game/example/vec3' -import { Color } from './my-game/example/color'; -import { Any } from './my-game/example/any'; +import { Monster, MonsterT } from './my-game/example/monster.js' +import { Test, TestT } from './my-game/example/test.js' +import { Stat } from './my-game/example/stat.js' +import { Vec3 } from './my-game/example/vec3.js' +import { Color } from './my-game/example/color.js'; +import { Any } from './my-game/example/any.js'; function main() { // First, let's test reading a FlatBuffer generated by C++ code: // This file was generated from monsterdata_test.json - var data = new Uint8Array(fs.readFileSync('monsterdata_test.mon')); + var data = new Uint8Array(fs.readFileSync('../monsterdata_test.mon')); // Now test it: @@ -285,8 +285,8 @@ function test64bit() { } function testUnicode() { - var correct = fs.readFileSync('unicode_test.mon'); - var json = JSON.parse(fs.readFileSync('unicode_test.json', 'utf8')); + var correct = fs.readFileSync('../unicode_test.mon'); + var json = JSON.parse(fs.readFileSync('../unicode_test.json', 'utf8')); // Test reading function testReadingUnicode(bb) { diff --git a/tests/JavaScriptUnionVectorTest.js b/tests/ts/JavaScriptUnionVectorTest.js similarity index 94% rename from tests/JavaScriptUnionVectorTest.js rename to tests/ts/JavaScriptUnionVectorTest.js index b80e37f15e3..18857d673af 100644 --- a/tests/JavaScriptUnionVectorTest.js +++ b/tests/ts/JavaScriptUnionVectorTest.js @@ -1,10 +1,10 @@ import assert from 'assert' import * as flatbuffers from 'flatbuffers' -import { Character } from './union_vector/character' -import { BookReader, BookReaderT } from './union_vector/book-reader' -import { Attacker, AttackerT } from './union_vector/attacker' -import { Movie, MovieT } from './union_vector/movie' +import { Character } from './union_vector/character.js' +import { BookReader, BookReaderT } from './union_vector/book-reader.js' +import { Attacker, AttackerT } from './union_vector/attacker.js' +import { Movie, MovieT } from './union_vector/movie.js' var charTypes = [ Character.Belle, diff --git a/tests/TypeScriptTest.py b/tests/ts/TypeScriptTest.py similarity index 86% rename from tests/TypeScriptTest.py rename to tests/ts/TypeScriptTest.py index 925eb19de71..c95ed722619 100755 --- a/tests/TypeScriptTest.py +++ b/tests/ts/TypeScriptTest.py @@ -25,7 +25,7 @@ tests_path = Path(__file__).parent.resolve() # Get the root path as an absolute path, so all derived paths are absolute. -root_path = tests_path.parent.absolute() +root_path = tests_path.parent.parent.absolute() # Windows works with subprocess.run a bit differently. is_windows = platform.system() == "Windows" @@ -62,26 +62,26 @@ def flatc(options, schema, prefix=None, include=None, data=None, cwd=tests_path) print("Invoking flatc...") flatc( options=["--ts", "--gen-name-strings", "--gen-mutable", "--gen-object-api"], - schema="monster_test.fbs", - include="include_test", + schema="../monster_test.fbs", + include="../include_test", ) flatc( options=["--gen-object-api", "-b"], - schema="monster_test.fbs", - include="include_test", - data="unicode_test.json", + schema="../monster_test.fbs", + include="../include_test", + data="../unicode_test.json", ) flatc( options=["--ts", "--gen-name-strings", "--gen-mutable", "--gen-object-api"], - schema="union_vector/union_vector.fbs", + schema="../union_vector/union_vector.fbs", prefix="union_vector", ) flatc( options=["--ts", "--gen-name-strings"], - schema="optional_scalars.fbs", + schema="../optional_scalars.fbs", ) flatc( @@ -90,9 +90,9 @@ def flatc(options, schema, prefix=None, include=None, data=None, cwd=tests_path) "typescript_keywords.fbs", "test_dir/typescript_include.fbs", "test_dir/typescript_transitive_include.fbs", - "../reflection/reflection.fbs", + "../../reflection/reflection.fbs", ], - include="../", + include="../../", ) flatc( @@ -107,15 +107,15 @@ def flatc(options, schema, prefix=None, include=None, data=None, cwd=tests_path) "typescript_keywords.fbs", "test_dir/typescript_include.fbs", "test_dir/typescript_transitive_include.fbs", - "../reflection/reflection.fbs", + "../../reflection/reflection.fbs", ], - include="../", + include="../../", ) print("Running TypeScript Compiler...") check_call(["tsc"]) -NODE_CMD = ["node", "-r", "esm"] +NODE_CMD = ["node"] print("Running TypeScript Tests...") check_call(NODE_CMD + ["JavaScriptTest"]) diff --git a/tests/ts/foobar/abc.js b/tests/ts/foobar/abc.js new file mode 100644 index 00000000000..cdef988d941 --- /dev/null +++ b/tests/ts/foobar/abc.js @@ -0,0 +1,5 @@ +// automatically generated by the FlatBuffers compiler, do not modify +export var Abc; +(function (Abc) { + Abc[Abc["a"] = 0] = "a"; +})(Abc || (Abc = {})); diff --git a/tests/ts/foobar/abc.ts b/tests/ts/foobar/abc.ts new file mode 100644 index 00000000000..ef8842b22b5 --- /dev/null +++ b/tests/ts/foobar/abc.ts @@ -0,0 +1,5 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +export enum Abc { + a = 0 +} diff --git a/tests/ts/foobar/class.js b/tests/ts/foobar/class.js new file mode 100644 index 00000000000..e0e1df1bea2 --- /dev/null +++ b/tests/ts/foobar/class.js @@ -0,0 +1,5 @@ +// automatically generated by the FlatBuffers compiler, do not modify +export var class_; +(function (class_) { + class_[class_["arguments_"] = 0] = "arguments_"; +})(class_ || (class_ = {})); diff --git a/tests/ts/foobar/class.ts b/tests/ts/foobar/class.ts new file mode 100644 index 00000000000..d26fb287943 --- /dev/null +++ b/tests/ts/foobar/class.ts @@ -0,0 +1,5 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +export enum class_ { + arguments_ = 0 +} diff --git a/tests/monster_test.js b/tests/ts/monster_test.js similarity index 100% rename from tests/monster_test.js rename to tests/ts/monster_test.js diff --git a/tests/monster_test.ts b/tests/ts/monster_test.ts similarity index 100% rename from tests/monster_test.ts rename to tests/ts/monster_test.ts diff --git a/tests/ts/monster_test_generated.ts b/tests/ts/monster_test_generated.ts new file mode 100644 index 00000000000..18aec071fbb --- /dev/null +++ b/tests/ts/monster_test_generated.ts @@ -0,0 +1,19 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +export { Monster as MyGame_Example2_Monster, MonsterT as MyGame_Example2_MonsterT } from './my-game/example2/monster.js'; +export { Ability, AbilityT } from './my-game/example/ability.js'; +export { Any, unionToAny, unionListToAny } from './my-game/example/any.js'; +export { AnyAmbiguousAliases, unionToAnyAmbiguousAliases, unionListToAnyAmbiguousAliases } from './my-game/example/any-ambiguous-aliases.js'; +export { AnyUniqueAliases, unionToAnyUniqueAliases, unionListToAnyUniqueAliases } from './my-game/example/any-unique-aliases.js'; +export { Color } from './my-game/example/color.js'; +export { Monster, MonsterT } from './my-game/example/monster.js'; +export { Race } from './my-game/example/race.js'; +export { Referrable, ReferrableT } from './my-game/example/referrable.js'; +export { Stat, StatT } from './my-game/example/stat.js'; +export { StructOfStructs, StructOfStructsT } from './my-game/example/struct-of-structs.js'; +export { StructOfStructsOfStructs, StructOfStructsOfStructsT } from './my-game/example/struct-of-structs-of-structs.js'; +export { Test, TestT } from './my-game/example/test.js'; +export { TestSimpleTableWithEnum, TestSimpleTableWithEnumT } from './my-game/example/test-simple-table-with-enum.js'; +export { TypeAliases, TypeAliasesT } from './my-game/example/type-aliases.js'; +export { Vec3, Vec3T } from './my-game/example/vec3.js'; +export { InParentNamespace, InParentNamespaceT } from './my-game/in-parent-namespace.js'; diff --git a/tests/monster_test_grpc.d.ts b/tests/ts/monster_test_grpc.d.ts similarity index 100% rename from tests/monster_test_grpc.d.ts rename to tests/ts/monster_test_grpc.d.ts diff --git a/tests/monster_test_grpc.js b/tests/ts/monster_test_grpc.js similarity index 100% rename from tests/monster_test_grpc.js rename to tests/ts/monster_test_grpc.js diff --git a/tests/ts/monsterdata_javascript_wire.mon b/tests/ts/monsterdata_javascript_wire.mon new file mode 100644 index 00000000000..c6020a2eb20 Binary files /dev/null and b/tests/ts/monsterdata_javascript_wire.mon differ diff --git a/tests/ts/my-game/example/ability.js b/tests/ts/my-game/example/ability.js new file mode 100644 index 00000000000..4d7d3db7290 --- /dev/null +++ b/tests/ts/my-game/example/ability.js @@ -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); + } +} diff --git a/tests/ts/my-game/example/ability.ts b/tests/ts/my-game/example/ability.ts new file mode 100644 index 00000000000..36b0eb8105d --- /dev/null +++ b/tests/ts/my-game/example/ability.ts @@ -0,0 +1,77 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +import * as flatbuffers from 'flatbuffers'; + + + +export class Ability { + bb: flatbuffers.ByteBuffer|null = null; + bb_pos = 0; + __init(i:number, bb:flatbuffers.ByteBuffer):Ability { + this.bb_pos = i; + this.bb = bb; + return this; +} + +id():number { + return this.bb!.readUint32(this.bb_pos); +} + +mutate_id(value:number):boolean { + this.bb!.writeUint32(this.bb_pos + 0, value); + return true; +} + +distance():number { + return this.bb!.readUint32(this.bb_pos + 4); +} + +mutate_distance(value:number):boolean { + this.bb!.writeUint32(this.bb_pos + 4, value); + return true; +} + +static getFullyQualifiedName():string { + return 'MyGame_Example_Ability'; +} + +static sizeOf():number { + return 8; +} + +static createAbility(builder:flatbuffers.Builder, id: number, distance: number):flatbuffers.Offset { + builder.prep(4, 8); + builder.writeInt32(distance); + builder.writeInt32(id); + return builder.offset(); +} + + +unpack(): AbilityT { + return new AbilityT( + this.id(), + this.distance() + ); +} + + +unpackTo(_o: AbilityT): void { + _o.id = this.id(); + _o.distance = this.distance(); +} +} + +export class AbilityT { +constructor( + public id: number = 0, + public distance: number = 0 +){} + + +pack(builder:flatbuffers.Builder): flatbuffers.Offset { + return Ability.createAbility(builder, + this.id, + this.distance + ); +} +} diff --git a/tests/ts/my-game/example/any-ambiguous-aliases.js b/tests/ts/my-game/example/any-ambiguous-aliases.js new file mode 100644 index 00000000000..ca8190848af --- /dev/null +++ b/tests/ts/my-game/example/any-ambiguous-aliases.js @@ -0,0 +1,27 @@ +// automatically generated by the FlatBuffers compiler, do not modify +import { Monster } from '../../my-game/example/monster.js'; +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; + } +} diff --git a/tests/ts/my-game/example/any-ambiguous-aliases.ts b/tests/ts/my-game/example/any-ambiguous-aliases.ts new file mode 100644 index 00000000000..a7a63b721b9 --- /dev/null +++ b/tests/ts/my-game/example/any-ambiguous-aliases.ts @@ -0,0 +1,38 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +import { Monster, MonsterT } from '../../my-game/example/monster.js'; + + +export enum AnyAmbiguousAliases { + NONE = 0, + M1 = 1, + M2 = 2, + M3 = 3 +} + +export function unionToAnyAmbiguousAliases( + type: AnyAmbiguousAliases, + accessor: (obj:Monster) => Monster|null +): Monster|null { + switch(AnyAmbiguousAliases[type]) { + case 'NONE': return null; + case 'M1': return accessor(new Monster())! as Monster; + case 'M2': return accessor(new Monster())! as Monster; + case 'M3': return accessor(new Monster())! as Monster; + default: return null; + } +} + +export function unionListToAnyAmbiguousAliases( + type: AnyAmbiguousAliases, + accessor: (index: number, obj:Monster) => Monster|null, + index: number +): Monster|null { + switch(AnyAmbiguousAliases[type]) { + case 'NONE': return null; + case 'M1': return accessor(index, new Monster())! as Monster; + case 'M2': return accessor(index, new Monster())! as Monster; + case 'M3': return accessor(index, new Monster())! as Monster; + default: return null; + } +} diff --git a/tests/ts/my-game/example/any-unique-aliases.js b/tests/ts/my-game/example/any-unique-aliases.js new file mode 100644 index 00000000000..d1ac6bff1ab --- /dev/null +++ b/tests/ts/my-game/example/any-unique-aliases.js @@ -0,0 +1,29 @@ +// automatically generated by the FlatBuffers compiler, do not modify +import { Monster as MyGame_Example2_Monster } from '../../my-game/example2/monster.js'; +import { Monster } from '../../my-game/example/monster.js'; +import { TestSimpleTableWithEnum } from '../../my-game/example/test-simple-table-with-enum.js'; +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 MyGame_Example2_Monster()); + 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 MyGame_Example2_Monster()); + default: return null; + } +} diff --git a/tests/ts/my-game/example/any-unique-aliases.ts b/tests/ts/my-game/example/any-unique-aliases.ts new file mode 100644 index 00000000000..16aa378c35b --- /dev/null +++ b/tests/ts/my-game/example/any-unique-aliases.ts @@ -0,0 +1,40 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +import { Monster as MyGame_Example2_Monster, MonsterT as MyGame_Example2_MonsterT } from '../../my-game/example2/monster.js'; +import { Monster, MonsterT } from '../../my-game/example/monster.js'; +import { TestSimpleTableWithEnum, TestSimpleTableWithEnumT } from '../../my-game/example/test-simple-table-with-enum.js'; + + +export enum AnyUniqueAliases { + NONE = 0, + M = 1, + TS = 2, + M2 = 3 +} + +export function unionToAnyUniqueAliases( + type: AnyUniqueAliases, + accessor: (obj:Monster|MyGame_Example2_Monster|TestSimpleTableWithEnum) => Monster|MyGame_Example2_Monster|TestSimpleTableWithEnum|null +): Monster|MyGame_Example2_Monster|TestSimpleTableWithEnum|null { + switch(AnyUniqueAliases[type]) { + case 'NONE': return null; + case 'M': return accessor(new Monster())! as Monster; + case 'TS': return accessor(new TestSimpleTableWithEnum())! as TestSimpleTableWithEnum; + case 'M2': return accessor(new MyGame_Example2_Monster())! as MyGame_Example2_Monster; + default: return null; + } +} + +export function unionListToAnyUniqueAliases( + type: AnyUniqueAliases, + accessor: (index: number, obj:Monster|MyGame_Example2_Monster|TestSimpleTableWithEnum) => Monster|MyGame_Example2_Monster|TestSimpleTableWithEnum|null, + index: number +): Monster|MyGame_Example2_Monster|TestSimpleTableWithEnum|null { + switch(AnyUniqueAliases[type]) { + case 'NONE': return null; + case 'M': return accessor(index, new Monster())! as Monster; + case 'TS': return accessor(index, new TestSimpleTableWithEnum())! as TestSimpleTableWithEnum; + case 'M2': return accessor(index, new MyGame_Example2_Monster())! as MyGame_Example2_Monster; + default: return null; + } +} diff --git a/tests/ts/my-game/example/any.js b/tests/ts/my-game/example/any.js new file mode 100644 index 00000000000..27be8f40809 --- /dev/null +++ b/tests/ts/my-game/example/any.js @@ -0,0 +1,29 @@ +// automatically generated by the FlatBuffers compiler, do not modify +import { Monster as MyGame_Example2_Monster } from '../../my-game/example2/monster.js'; +import { Monster } from '../../my-game/example/monster.js'; +import { TestSimpleTableWithEnum } from '../../my-game/example/test-simple-table-with-enum.js'; +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 MyGame_Example2_Monster()); + 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 MyGame_Example2_Monster()); + default: return null; + } +} diff --git a/tests/ts/my-game/example/any.ts b/tests/ts/my-game/example/any.ts new file mode 100644 index 00000000000..de1cbfd963c --- /dev/null +++ b/tests/ts/my-game/example/any.ts @@ -0,0 +1,40 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +import { Monster as MyGame_Example2_Monster, MonsterT as MyGame_Example2_MonsterT } from '../../my-game/example2/monster.js'; +import { Monster, MonsterT } from '../../my-game/example/monster.js'; +import { TestSimpleTableWithEnum, TestSimpleTableWithEnumT } from '../../my-game/example/test-simple-table-with-enum.js'; + + +export enum Any { + NONE = 0, + Monster = 1, + TestSimpleTableWithEnum = 2, + MyGame_Example2_Monster = 3 +} + +export function unionToAny( + type: Any, + accessor: (obj:Monster|MyGame_Example2_Monster|TestSimpleTableWithEnum) => Monster|MyGame_Example2_Monster|TestSimpleTableWithEnum|null +): Monster|MyGame_Example2_Monster|TestSimpleTableWithEnum|null { + switch(Any[type]) { + case 'NONE': return null; + case 'Monster': return accessor(new Monster())! as Monster; + case 'TestSimpleTableWithEnum': return accessor(new TestSimpleTableWithEnum())! as TestSimpleTableWithEnum; + case 'MyGame_Example2_Monster': return accessor(new MyGame_Example2_Monster())! as MyGame_Example2_Monster; + default: return null; + } +} + +export function unionListToAny( + type: Any, + accessor: (index: number, obj:Monster|MyGame_Example2_Monster|TestSimpleTableWithEnum) => Monster|MyGame_Example2_Monster|TestSimpleTableWithEnum|null, + index: number +): Monster|MyGame_Example2_Monster|TestSimpleTableWithEnum|null { + switch(Any[type]) { + case 'NONE': return null; + case 'Monster': return accessor(index, new Monster())! as Monster; + case 'TestSimpleTableWithEnum': return accessor(index, new TestSimpleTableWithEnum())! as TestSimpleTableWithEnum; + case 'MyGame_Example2_Monster': return accessor(index, new MyGame_Example2_Monster())! as MyGame_Example2_Monster; + default: return null; + } +} diff --git a/tests/ts/my-game/example/color.js b/tests/ts/my-game/example/color.js new file mode 100644 index 00000000000..f95f75e9677 --- /dev/null +++ b/tests/ts/my-game/example/color.js @@ -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 = {})); diff --git a/tests/ts/my-game/example/color.ts b/tests/ts/my-game/example/color.ts new file mode 100644 index 00000000000..8ce58da6787 --- /dev/null +++ b/tests/ts/my-game/example/color.ts @@ -0,0 +1,19 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +/** + * Composite components of Monster color. + */ +export enum Color { + Red = 1, + + /** + * \brief color Green + * Green is bit_flag with value (1u << 1) + */ + Green = 2, + + /** + * \brief color Blue (1u << 3) + */ + Blue = 8 +} diff --git a/tests/ts/my-game/example/long-enum.js b/tests/ts/my-game/example/long-enum.js new file mode 100644 index 00000000000..040d8a672f9 --- /dev/null +++ b/tests/ts/my-game/example/long-enum.js @@ -0,0 +1,7 @@ +// automatically generated by the FlatBuffers compiler, do not modify +export var LongEnum; +(function (LongEnum) { + LongEnum["LongOne"] = "2"; + LongEnum["LongTwo"] = "4"; + LongEnum["LongBig"] = "1099511627776"; +})(LongEnum || (LongEnum = {})); diff --git a/tests/ts/my-game/example/long-enum.ts b/tests/ts/my-game/example/long-enum.ts new file mode 100644 index 00000000000..31ea18805f2 --- /dev/null +++ b/tests/ts/my-game/example/long-enum.ts @@ -0,0 +1,7 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +export enum LongEnum { + LongOne = '2', + LongTwo = '4', + LongBig = '1099511627776' +} diff --git a/tests/ts/my-game/example/monster.js b/tests/ts/my-game/example/monster.js new file mode 100644 index 00000000000..e4ef970ab68 --- /dev/null +++ b/tests/ts/my-game/example/monster.js @@ -0,0 +1,1125 @@ +// automatically generated by the FlatBuffers compiler, do not modify +import * as flatbuffers from 'flatbuffers'; +import { Ability } from '../../my-game/example/ability.js'; +import { Any, unionToAny } from '../../my-game/example/any.js'; +import { AnyAmbiguousAliases, unionToAnyAmbiguousAliases } from '../../my-game/example/any-ambiguous-aliases.js'; +import { AnyUniqueAliases, unionToAnyUniqueAliases } from '../../my-game/example/any-unique-aliases.js'; +import { Color } from '../../my-game/example/color.js'; +import { Race } from '../../my-game/example/race.js'; +import { Referrable } from '../../my-game/example/referrable.js'; +import { Stat } from '../../my-game/example/stat.js'; +import { Test } from '../../my-game/example/test.js'; +import { Vec3 } from '../../my-game/example/vec3.js'; +import { InParentNamespace } from '../../my-game/in-parent-namespace.js'; +/** + * an example documentation comment: "monster object" + */ +export class Monster { + constructor() { + this.bb = null; + this.bb_pos = 0; + } + __init(i, bb) { + this.bb_pos = i; + this.bb = bb; + return this; + } + static getRootAsMonster(bb, obj) { + return (obj || new Monster()).__init(bb.readInt32(bb.position()) + bb.position(), bb); + } + static getSizePrefixedRootAsMonster(bb, obj) { + bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); + return (obj || new Monster()).__init(bb.readInt32(bb.position()) + bb.position(), bb); + } + static bufferHasIdentifier(bb) { + return bb.__has_identifier('MONS'); + } + pos(obj) { + const offset = this.bb.__offset(this.bb_pos, 4); + return offset ? (obj || new Vec3()).__init(this.bb_pos + offset, this.bb) : null; + } + mana() { + const offset = this.bb.__offset(this.bb_pos, 6); + return offset ? this.bb.readInt16(this.bb_pos + offset) : 150; + } + mutate_mana(value) { + const offset = this.bb.__offset(this.bb_pos, 6); + if (offset === 0) { + return false; + } + this.bb.writeInt16(this.bb_pos + offset, value); + return true; + } + hp() { + const offset = this.bb.__offset(this.bb_pos, 8); + return offset ? this.bb.readInt16(this.bb_pos + offset) : 100; + } + mutate_hp(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; + } + name(optionalEncoding) { + const offset = this.bb.__offset(this.bb_pos, 10); + return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null; + } + inventory(index) { + const offset = this.bb.__offset(this.bb_pos, 14); + return offset ? this.bb.readUint8(this.bb.__vector(this.bb_pos + offset) + index) : 0; + } + inventoryLength() { + const offset = this.bb.__offset(this.bb_pos, 14); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; + } + inventoryArray() { + const offset = this.bb.__offset(this.bb_pos, 14); + return offset ? new Uint8Array(this.bb.bytes().buffer, this.bb.bytes().byteOffset + this.bb.__vector(this.bb_pos + offset), this.bb.__vector_len(this.bb_pos + offset)) : null; + } + color() { + const offset = this.bb.__offset(this.bb_pos, 16); + return offset ? this.bb.readUint8(this.bb_pos + offset) : Color.Blue; + } + mutate_color(value) { + const offset = this.bb.__offset(this.bb_pos, 16); + if (offset === 0) { + return false; + } + this.bb.writeUint8(this.bb_pos + offset, value); + return true; + } + testType() { + const offset = this.bb.__offset(this.bb_pos, 18); + return offset ? this.bb.readUint8(this.bb_pos + offset) : Any.NONE; + } + test(obj) { + const offset = this.bb.__offset(this.bb_pos, 20); + return offset ? this.bb.__union(obj, this.bb_pos + offset) : null; + } + test4(index, obj) { + const offset = this.bb.__offset(this.bb_pos, 22); + return offset ? (obj || new Test()).__init(this.bb.__vector(this.bb_pos + offset) + index * 4, this.bb) : null; + } + test4Length() { + const offset = this.bb.__offset(this.bb_pos, 22); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; + } + testarrayofstring(index, optionalEncoding) { + const offset = this.bb.__offset(this.bb_pos, 24); + return offset ? this.bb.__string(this.bb.__vector(this.bb_pos + offset) + index * 4, optionalEncoding) : null; + } + testarrayofstringLength() { + const offset = this.bb.__offset(this.bb_pos, 24); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; + } + /** + * an example documentation comment: this will end up in the generated code + * multiline too + */ + testarrayoftables(index, obj) { + const offset = this.bb.__offset(this.bb_pos, 26); + return offset ? (obj || new Monster()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4), this.bb) : null; + } + testarrayoftablesLength() { + const offset = this.bb.__offset(this.bb_pos, 26); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; + } + enemy(obj) { + const offset = this.bb.__offset(this.bb_pos, 28); + return offset ? (obj || new Monster()).__init(this.bb.__indirect(this.bb_pos + offset), this.bb) : null; + } + testnestedflatbuffer(index) { + const offset = this.bb.__offset(this.bb_pos, 30); + return offset ? this.bb.readUint8(this.bb.__vector(this.bb_pos + offset) + index) : 0; + } + testnestedflatbufferLength() { + const offset = this.bb.__offset(this.bb_pos, 30); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; + } + testnestedflatbufferArray() { + const offset = this.bb.__offset(this.bb_pos, 30); + return offset ? new Uint8Array(this.bb.bytes().buffer, this.bb.bytes().byteOffset + this.bb.__vector(this.bb_pos + offset), this.bb.__vector_len(this.bb_pos + offset)) : null; + } + testempty(obj) { + const offset = this.bb.__offset(this.bb_pos, 32); + return offset ? (obj || new Stat()).__init(this.bb.__indirect(this.bb_pos + offset), this.bb) : null; + } + testbool() { + const offset = this.bb.__offset(this.bb_pos, 34); + return offset ? !!this.bb.readInt8(this.bb_pos + offset) : false; + } + mutate_testbool(value) { + const offset = this.bb.__offset(this.bb_pos, 34); + if (offset === 0) { + return false; + } + this.bb.writeInt8(this.bb_pos + offset, +value); + return true; + } + testhashs32Fnv1() { + const offset = this.bb.__offset(this.bb_pos, 36); + return offset ? this.bb.readInt32(this.bb_pos + offset) : 0; + } + mutate_testhashs32_fnv1(value) { + const offset = this.bb.__offset(this.bb_pos, 36); + if (offset === 0) { + return false; + } + this.bb.writeInt32(this.bb_pos + offset, value); + return true; + } + testhashu32Fnv1() { + const offset = this.bb.__offset(this.bb_pos, 38); + return offset ? this.bb.readUint32(this.bb_pos + offset) : 0; + } + mutate_testhashu32_fnv1(value) { + const offset = this.bb.__offset(this.bb_pos, 38); + if (offset === 0) { + return false; + } + this.bb.writeUint32(this.bb_pos + offset, value); + return true; + } + testhashs64Fnv1() { + const offset = this.bb.__offset(this.bb_pos, 40); + return offset ? this.bb.readInt64(this.bb_pos + offset) : BigInt('0'); + } + mutate_testhashs64_fnv1(value) { + const offset = this.bb.__offset(this.bb_pos, 40); + if (offset === 0) { + return false; + } + this.bb.writeInt64(this.bb_pos + offset, value); + return true; + } + testhashu64Fnv1() { + const offset = this.bb.__offset(this.bb_pos, 42); + return offset ? this.bb.readUint64(this.bb_pos + offset) : BigInt('0'); + } + mutate_testhashu64_fnv1(value) { + const offset = this.bb.__offset(this.bb_pos, 42); + if (offset === 0) { + return false; + } + this.bb.writeUint64(this.bb_pos + offset, value); + return true; + } + testhashs32Fnv1a() { + const offset = this.bb.__offset(this.bb_pos, 44); + return offset ? this.bb.readInt32(this.bb_pos + offset) : 0; + } + mutate_testhashs32_fnv1a(value) { + const offset = this.bb.__offset(this.bb_pos, 44); + if (offset === 0) { + return false; + } + this.bb.writeInt32(this.bb_pos + offset, value); + return true; + } + testhashu32Fnv1a() { + const offset = this.bb.__offset(this.bb_pos, 46); + return offset ? this.bb.readUint32(this.bb_pos + offset) : 0; + } + mutate_testhashu32_fnv1a(value) { + const offset = this.bb.__offset(this.bb_pos, 46); + if (offset === 0) { + return false; + } + this.bb.writeUint32(this.bb_pos + offset, value); + return true; + } + testhashs64Fnv1a() { + const offset = this.bb.__offset(this.bb_pos, 48); + return offset ? this.bb.readInt64(this.bb_pos + offset) : BigInt('0'); + } + mutate_testhashs64_fnv1a(value) { + const offset = this.bb.__offset(this.bb_pos, 48); + if (offset === 0) { + return false; + } + this.bb.writeInt64(this.bb_pos + offset, value); + return true; + } + testhashu64Fnv1a() { + const offset = this.bb.__offset(this.bb_pos, 50); + return offset ? this.bb.readUint64(this.bb_pos + offset) : BigInt('0'); + } + mutate_testhashu64_fnv1a(value) { + const offset = this.bb.__offset(this.bb_pos, 50); + if (offset === 0) { + return false; + } + this.bb.writeUint64(this.bb_pos + offset, value); + return true; + } + testarrayofbools(index) { + const offset = this.bb.__offset(this.bb_pos, 52); + return offset ? !!this.bb.readInt8(this.bb.__vector(this.bb_pos + offset) + index) : false; + } + testarrayofboolsLength() { + const offset = this.bb.__offset(this.bb_pos, 52); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; + } + testarrayofboolsArray() { + const offset = this.bb.__offset(this.bb_pos, 52); + 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; + } + testf() { + const offset = this.bb.__offset(this.bb_pos, 54); + return offset ? this.bb.readFloat32(this.bb_pos + offset) : 3.14159; + } + mutate_testf(value) { + const offset = this.bb.__offset(this.bb_pos, 54); + if (offset === 0) { + return false; + } + this.bb.writeFloat32(this.bb_pos + offset, value); + return true; + } + testf2() { + const offset = this.bb.__offset(this.bb_pos, 56); + return offset ? this.bb.readFloat32(this.bb_pos + offset) : 3.0; + } + mutate_testf2(value) { + const offset = this.bb.__offset(this.bb_pos, 56); + if (offset === 0) { + return false; + } + this.bb.writeFloat32(this.bb_pos + offset, value); + return true; + } + testf3() { + const offset = this.bb.__offset(this.bb_pos, 58); + return offset ? this.bb.readFloat32(this.bb_pos + offset) : 0.0; + } + mutate_testf3(value) { + const offset = this.bb.__offset(this.bb_pos, 58); + if (offset === 0) { + return false; + } + this.bb.writeFloat32(this.bb_pos + offset, value); + return true; + } + testarrayofstring2(index, optionalEncoding) { + const offset = this.bb.__offset(this.bb_pos, 60); + return offset ? this.bb.__string(this.bb.__vector(this.bb_pos + offset) + index * 4, optionalEncoding) : null; + } + testarrayofstring2Length() { + const offset = this.bb.__offset(this.bb_pos, 60); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; + } + testarrayofsortedstruct(index, obj) { + const offset = this.bb.__offset(this.bb_pos, 62); + return offset ? (obj || new Ability()).__init(this.bb.__vector(this.bb_pos + offset) + index * 8, this.bb) : null; + } + testarrayofsortedstructLength() { + const offset = this.bb.__offset(this.bb_pos, 62); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; + } + flex(index) { + const offset = this.bb.__offset(this.bb_pos, 64); + return offset ? this.bb.readUint8(this.bb.__vector(this.bb_pos + offset) + index) : 0; + } + flexLength() { + const offset = this.bb.__offset(this.bb_pos, 64); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; + } + flexArray() { + const offset = this.bb.__offset(this.bb_pos, 64); + return offset ? new Uint8Array(this.bb.bytes().buffer, this.bb.bytes().byteOffset + this.bb.__vector(this.bb_pos + offset), this.bb.__vector_len(this.bb_pos + offset)) : null; + } + test5(index, obj) { + const offset = this.bb.__offset(this.bb_pos, 66); + return offset ? (obj || new Test()).__init(this.bb.__vector(this.bb_pos + offset) + index * 4, this.bb) : null; + } + test5Length() { + const offset = this.bb.__offset(this.bb_pos, 66); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; + } + vectorOfLongs(index) { + const offset = this.bb.__offset(this.bb_pos, 68); + return offset ? this.bb.readInt64(this.bb.__vector(this.bb_pos + offset) + index * 8) : BigInt(0); + } + vectorOfLongsLength() { + const offset = this.bb.__offset(this.bb_pos, 68); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; + } + vectorOfDoubles(index) { + const offset = this.bb.__offset(this.bb_pos, 70); + return offset ? this.bb.readFloat64(this.bb.__vector(this.bb_pos + offset) + index * 8) : 0; + } + vectorOfDoublesLength() { + const offset = this.bb.__offset(this.bb_pos, 70); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; + } + vectorOfDoublesArray() { + const offset = this.bb.__offset(this.bb_pos, 70); + 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; + } + parentNamespaceTest(obj) { + const offset = this.bb.__offset(this.bb_pos, 72); + return offset ? (obj || new InParentNamespace()).__init(this.bb.__indirect(this.bb_pos + offset), this.bb) : null; + } + vectorOfReferrables(index, obj) { + const offset = this.bb.__offset(this.bb_pos, 74); + return offset ? (obj || new Referrable()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4), this.bb) : null; + } + vectorOfReferrablesLength() { + const offset = this.bb.__offset(this.bb_pos, 74); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; + } + singleWeakReference() { + const offset = this.bb.__offset(this.bb_pos, 76); + return offset ? this.bb.readUint64(this.bb_pos + offset) : BigInt('0'); + } + mutate_single_weak_reference(value) { + const offset = this.bb.__offset(this.bb_pos, 76); + if (offset === 0) { + return false; + } + this.bb.writeUint64(this.bb_pos + offset, value); + return true; + } + vectorOfWeakReferences(index) { + const offset = this.bb.__offset(this.bb_pos, 78); + return offset ? this.bb.readUint64(this.bb.__vector(this.bb_pos + offset) + index * 8) : BigInt(0); + } + vectorOfWeakReferencesLength() { + const offset = this.bb.__offset(this.bb_pos, 78); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; + } + vectorOfStrongReferrables(index, obj) { + const offset = this.bb.__offset(this.bb_pos, 80); + return offset ? (obj || new Referrable()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4), this.bb) : null; + } + vectorOfStrongReferrablesLength() { + const offset = this.bb.__offset(this.bb_pos, 80); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; + } + coOwningReference() { + const offset = this.bb.__offset(this.bb_pos, 82); + return offset ? this.bb.readUint64(this.bb_pos + offset) : BigInt('0'); + } + mutate_co_owning_reference(value) { + const offset = this.bb.__offset(this.bb_pos, 82); + if (offset === 0) { + return false; + } + this.bb.writeUint64(this.bb_pos + offset, value); + return true; + } + vectorOfCoOwningReferences(index) { + const offset = this.bb.__offset(this.bb_pos, 84); + return offset ? this.bb.readUint64(this.bb.__vector(this.bb_pos + offset) + index * 8) : BigInt(0); + } + vectorOfCoOwningReferencesLength() { + const offset = this.bb.__offset(this.bb_pos, 84); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; + } + nonOwningReference() { + const offset = this.bb.__offset(this.bb_pos, 86); + return offset ? this.bb.readUint64(this.bb_pos + offset) : BigInt('0'); + } + mutate_non_owning_reference(value) { + const offset = this.bb.__offset(this.bb_pos, 86); + if (offset === 0) { + return false; + } + this.bb.writeUint64(this.bb_pos + offset, value); + return true; + } + vectorOfNonOwningReferences(index) { + const offset = this.bb.__offset(this.bb_pos, 88); + return offset ? this.bb.readUint64(this.bb.__vector(this.bb_pos + offset) + index * 8) : BigInt(0); + } + vectorOfNonOwningReferencesLength() { + const offset = this.bb.__offset(this.bb_pos, 88); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; + } + anyUniqueType() { + const offset = this.bb.__offset(this.bb_pos, 90); + return offset ? this.bb.readUint8(this.bb_pos + offset) : AnyUniqueAliases.NONE; + } + anyUnique(obj) { + const offset = this.bb.__offset(this.bb_pos, 92); + return offset ? this.bb.__union(obj, this.bb_pos + offset) : null; + } + anyAmbiguousType() { + const offset = this.bb.__offset(this.bb_pos, 94); + return offset ? this.bb.readUint8(this.bb_pos + offset) : AnyAmbiguousAliases.NONE; + } + anyAmbiguous(obj) { + const offset = this.bb.__offset(this.bb_pos, 96); + return offset ? this.bb.__union(obj, this.bb_pos + offset) : null; + } + vectorOfEnums(index) { + const offset = this.bb.__offset(this.bb_pos, 98); + return offset ? this.bb.readUint8(this.bb.__vector(this.bb_pos + offset) + index) : 0; + } + vectorOfEnumsLength() { + const offset = this.bb.__offset(this.bb_pos, 98); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; + } + vectorOfEnumsArray() { + const offset = this.bb.__offset(this.bb_pos, 98); + return offset ? new Uint8Array(this.bb.bytes().buffer, this.bb.bytes().byteOffset + this.bb.__vector(this.bb_pos + offset), this.bb.__vector_len(this.bb_pos + offset)) : null; + } + signedEnum() { + const offset = this.bb.__offset(this.bb_pos, 100); + return offset ? this.bb.readInt8(this.bb_pos + offset) : Race.None; + } + mutate_signed_enum(value) { + const offset = this.bb.__offset(this.bb_pos, 100); + if (offset === 0) { + return false; + } + this.bb.writeInt8(this.bb_pos + offset, value); + return true; + } + testrequirednestedflatbuffer(index) { + const offset = this.bb.__offset(this.bb_pos, 102); + return offset ? this.bb.readUint8(this.bb.__vector(this.bb_pos + offset) + index) : 0; + } + testrequirednestedflatbufferLength() { + const offset = this.bb.__offset(this.bb_pos, 102); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; + } + testrequirednestedflatbufferArray() { + const offset = this.bb.__offset(this.bb_pos, 102); + return offset ? new Uint8Array(this.bb.bytes().buffer, this.bb.bytes().byteOffset + this.bb.__vector(this.bb_pos + offset), this.bb.__vector_len(this.bb_pos + offset)) : null; + } + scalarKeySortedTables(index, obj) { + const offset = this.bb.__offset(this.bb_pos, 104); + return offset ? (obj || new Stat()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4), this.bb) : null; + } + scalarKeySortedTablesLength() { + const offset = this.bb.__offset(this.bb_pos, 104); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; + } + nativeInline(obj) { + const offset = this.bb.__offset(this.bb_pos, 106); + return offset ? (obj || new Test()).__init(this.bb_pos + offset, this.bb) : null; + } + longEnumNonEnumDefault() { + const offset = this.bb.__offset(this.bb_pos, 108); + return offset ? this.bb.readUint64(this.bb_pos + offset) : BigInt('0'); + } + mutate_long_enum_non_enum_default(value) { + const offset = this.bb.__offset(this.bb_pos, 108); + if (offset === 0) { + return false; + } + this.bb.writeUint64(this.bb_pos + offset, value); + return true; + } + longEnumNormalDefault() { + const offset = this.bb.__offset(this.bb_pos, 110); + return offset ? this.bb.readUint64(this.bb_pos + offset) : BigInt('2'); + } + mutate_long_enum_normal_default(value) { + const offset = this.bb.__offset(this.bb_pos, 110); + if (offset === 0) { + return false; + } + this.bb.writeUint64(this.bb_pos + offset, value); + return true; + } + static getFullyQualifiedName() { + return 'MyGame_Example_Monster'; + } + static startMonster(builder) { + builder.startObject(54); + } + static addPos(builder, posOffset) { + builder.addFieldStruct(0, posOffset, 0); + } + static addMana(builder, mana) { + builder.addFieldInt16(1, mana, 150); + } + static addHp(builder, hp) { + builder.addFieldInt16(2, hp, 100); + } + static addName(builder, nameOffset) { + builder.addFieldOffset(3, nameOffset, 0); + } + static addInventory(builder, inventoryOffset) { + builder.addFieldOffset(5, inventoryOffset, 0); + } + static createInventoryVector(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 startInventoryVector(builder, numElems) { + builder.startVector(1, numElems, 1); + } + static addColor(builder, color) { + builder.addFieldInt8(6, color, Color.Blue); + } + static addTestType(builder, testType) { + builder.addFieldInt8(7, testType, Any.NONE); + } + static addTest(builder, testOffset) { + builder.addFieldOffset(8, testOffset, 0); + } + static addTest4(builder, test4Offset) { + builder.addFieldOffset(9, test4Offset, 0); + } + static startTest4Vector(builder, numElems) { + builder.startVector(4, numElems, 2); + } + static addTestarrayofstring(builder, testarrayofstringOffset) { + builder.addFieldOffset(10, testarrayofstringOffset, 0); + } + static createTestarrayofstringVector(builder, data) { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addOffset(data[i]); + } + return builder.endVector(); + } + static startTestarrayofstringVector(builder, numElems) { + builder.startVector(4, numElems, 4); + } + static addTestarrayoftables(builder, testarrayoftablesOffset) { + builder.addFieldOffset(11, testarrayoftablesOffset, 0); + } + static createTestarrayoftablesVector(builder, data) { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addOffset(data[i]); + } + return builder.endVector(); + } + static startTestarrayoftablesVector(builder, numElems) { + builder.startVector(4, numElems, 4); + } + static addEnemy(builder, enemyOffset) { + builder.addFieldOffset(12, enemyOffset, 0); + } + static addTestnestedflatbuffer(builder, testnestedflatbufferOffset) { + builder.addFieldOffset(13, testnestedflatbufferOffset, 0); + } + static createTestnestedflatbufferVector(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 startTestnestedflatbufferVector(builder, numElems) { + builder.startVector(1, numElems, 1); + } + static addTestempty(builder, testemptyOffset) { + builder.addFieldOffset(14, testemptyOffset, 0); + } + static addTestbool(builder, testbool) { + builder.addFieldInt8(15, +testbool, +false); + } + static addTesthashs32Fnv1(builder, testhashs32Fnv1) { + builder.addFieldInt32(16, testhashs32Fnv1, 0); + } + static addTesthashu32Fnv1(builder, testhashu32Fnv1) { + builder.addFieldInt32(17, testhashu32Fnv1, 0); + } + static addTesthashs64Fnv1(builder, testhashs64Fnv1) { + builder.addFieldInt64(18, testhashs64Fnv1, BigInt('0')); + } + static addTesthashu64Fnv1(builder, testhashu64Fnv1) { + builder.addFieldInt64(19, testhashu64Fnv1, BigInt('0')); + } + static addTesthashs32Fnv1a(builder, testhashs32Fnv1a) { + builder.addFieldInt32(20, testhashs32Fnv1a, 0); + } + static addTesthashu32Fnv1a(builder, testhashu32Fnv1a) { + builder.addFieldInt32(21, testhashu32Fnv1a, 0); + } + static addTesthashs64Fnv1a(builder, testhashs64Fnv1a) { + builder.addFieldInt64(22, testhashs64Fnv1a, BigInt('0')); + } + static addTesthashu64Fnv1a(builder, testhashu64Fnv1a) { + builder.addFieldInt64(23, testhashu64Fnv1a, BigInt('0')); + } + static addTestarrayofbools(builder, testarrayofboolsOffset) { + builder.addFieldOffset(24, testarrayofboolsOffset, 0); + } + static createTestarrayofboolsVector(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 startTestarrayofboolsVector(builder, numElems) { + builder.startVector(1, numElems, 1); + } + static addTestf(builder, testf) { + builder.addFieldFloat32(25, testf, 3.14159); + } + static addTestf2(builder, testf2) { + builder.addFieldFloat32(26, testf2, 3.0); + } + static addTestf3(builder, testf3) { + builder.addFieldFloat32(27, testf3, 0.0); + } + static addTestarrayofstring2(builder, testarrayofstring2Offset) { + builder.addFieldOffset(28, testarrayofstring2Offset, 0); + } + static createTestarrayofstring2Vector(builder, data) { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addOffset(data[i]); + } + return builder.endVector(); + } + static startTestarrayofstring2Vector(builder, numElems) { + builder.startVector(4, numElems, 4); + } + static addTestarrayofsortedstruct(builder, testarrayofsortedstructOffset) { + builder.addFieldOffset(29, testarrayofsortedstructOffset, 0); + } + static startTestarrayofsortedstructVector(builder, numElems) { + builder.startVector(8, numElems, 4); + } + static addFlex(builder, flexOffset) { + builder.addFieldOffset(30, flexOffset, 0); + } + static createFlexVector(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 startFlexVector(builder, numElems) { + builder.startVector(1, numElems, 1); + } + static addTest5(builder, test5Offset) { + builder.addFieldOffset(31, test5Offset, 0); + } + static startTest5Vector(builder, numElems) { + builder.startVector(4, numElems, 2); + } + static addVectorOfLongs(builder, vectorOfLongsOffset) { + builder.addFieldOffset(32, vectorOfLongsOffset, 0); + } + static createVectorOfLongsVector(builder, data) { + builder.startVector(8, data.length, 8); + for (let i = data.length - 1; i >= 0; i--) { + builder.addInt64(data[i]); + } + return builder.endVector(); + } + static startVectorOfLongsVector(builder, numElems) { + builder.startVector(8, numElems, 8); + } + static addVectorOfDoubles(builder, vectorOfDoublesOffset) { + builder.addFieldOffset(33, vectorOfDoublesOffset, 0); + } + static createVectorOfDoublesVector(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 startVectorOfDoublesVector(builder, numElems) { + builder.startVector(8, numElems, 8); + } + static addParentNamespaceTest(builder, parentNamespaceTestOffset) { + builder.addFieldOffset(34, parentNamespaceTestOffset, 0); + } + static addVectorOfReferrables(builder, vectorOfReferrablesOffset) { + builder.addFieldOffset(35, vectorOfReferrablesOffset, 0); + } + static createVectorOfReferrablesVector(builder, data) { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addOffset(data[i]); + } + return builder.endVector(); + } + static startVectorOfReferrablesVector(builder, numElems) { + builder.startVector(4, numElems, 4); + } + static addSingleWeakReference(builder, singleWeakReference) { + builder.addFieldInt64(36, singleWeakReference, BigInt('0')); + } + static addVectorOfWeakReferences(builder, vectorOfWeakReferencesOffset) { + builder.addFieldOffset(37, vectorOfWeakReferencesOffset, 0); + } + static createVectorOfWeakReferencesVector(builder, data) { + builder.startVector(8, data.length, 8); + for (let i = data.length - 1; i >= 0; i--) { + builder.addInt64(data[i]); + } + return builder.endVector(); + } + static startVectorOfWeakReferencesVector(builder, numElems) { + builder.startVector(8, numElems, 8); + } + static addVectorOfStrongReferrables(builder, vectorOfStrongReferrablesOffset) { + builder.addFieldOffset(38, vectorOfStrongReferrablesOffset, 0); + } + static createVectorOfStrongReferrablesVector(builder, data) { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addOffset(data[i]); + } + return builder.endVector(); + } + static startVectorOfStrongReferrablesVector(builder, numElems) { + builder.startVector(4, numElems, 4); + } + static addCoOwningReference(builder, coOwningReference) { + builder.addFieldInt64(39, coOwningReference, BigInt('0')); + } + static addVectorOfCoOwningReferences(builder, vectorOfCoOwningReferencesOffset) { + builder.addFieldOffset(40, vectorOfCoOwningReferencesOffset, 0); + } + static createVectorOfCoOwningReferencesVector(builder, data) { + builder.startVector(8, data.length, 8); + for (let i = data.length - 1; i >= 0; i--) { + builder.addInt64(data[i]); + } + return builder.endVector(); + } + static startVectorOfCoOwningReferencesVector(builder, numElems) { + builder.startVector(8, numElems, 8); + } + static addNonOwningReference(builder, nonOwningReference) { + builder.addFieldInt64(41, nonOwningReference, BigInt('0')); + } + static addVectorOfNonOwningReferences(builder, vectorOfNonOwningReferencesOffset) { + builder.addFieldOffset(42, vectorOfNonOwningReferencesOffset, 0); + } + static createVectorOfNonOwningReferencesVector(builder, data) { + builder.startVector(8, data.length, 8); + for (let i = data.length - 1; i >= 0; i--) { + builder.addInt64(data[i]); + } + return builder.endVector(); + } + static startVectorOfNonOwningReferencesVector(builder, numElems) { + builder.startVector(8, numElems, 8); + } + static addAnyUniqueType(builder, anyUniqueType) { + builder.addFieldInt8(43, anyUniqueType, AnyUniqueAliases.NONE); + } + static addAnyUnique(builder, anyUniqueOffset) { + builder.addFieldOffset(44, anyUniqueOffset, 0); + } + static addAnyAmbiguousType(builder, anyAmbiguousType) { + builder.addFieldInt8(45, anyAmbiguousType, AnyAmbiguousAliases.NONE); + } + static addAnyAmbiguous(builder, anyAmbiguousOffset) { + builder.addFieldOffset(46, anyAmbiguousOffset, 0); + } + static addVectorOfEnums(builder, vectorOfEnumsOffset) { + builder.addFieldOffset(47, vectorOfEnumsOffset, 0); + } + static createVectorOfEnumsVector(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 startVectorOfEnumsVector(builder, numElems) { + builder.startVector(1, numElems, 1); + } + static addSignedEnum(builder, signedEnum) { + builder.addFieldInt8(48, signedEnum, Race.None); + } + static addTestrequirednestedflatbuffer(builder, testrequirednestedflatbufferOffset) { + builder.addFieldOffset(49, testrequirednestedflatbufferOffset, 0); + } + static createTestrequirednestedflatbufferVector(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 startTestrequirednestedflatbufferVector(builder, numElems) { + builder.startVector(1, numElems, 1); + } + static addScalarKeySortedTables(builder, scalarKeySortedTablesOffset) { + builder.addFieldOffset(50, scalarKeySortedTablesOffset, 0); + } + static createScalarKeySortedTablesVector(builder, data) { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addOffset(data[i]); + } + return builder.endVector(); + } + static startScalarKeySortedTablesVector(builder, numElems) { + builder.startVector(4, numElems, 4); + } + static addNativeInline(builder, nativeInlineOffset) { + builder.addFieldStruct(51, nativeInlineOffset, 0); + } + static addLongEnumNonEnumDefault(builder, longEnumNonEnumDefault) { + builder.addFieldInt64(52, longEnumNonEnumDefault, BigInt('0')); + } + static addLongEnumNormalDefault(builder, longEnumNormalDefault) { + builder.addFieldInt64(53, longEnumNormalDefault, BigInt('2')); + } + static endMonster(builder) { + const offset = builder.endObject(); + builder.requiredField(offset, 10); // name + return offset; + } + static finishMonsterBuffer(builder, offset) { + builder.finish(offset, 'MONS'); + } + static finishSizePrefixedMonsterBuffer(builder, offset) { + builder.finish(offset, 'MONS', true); + } + serialize() { + return this.bb.bytes(); + } + static deserialize(buffer) { + return Monster.getRootAsMonster(new flatbuffers.ByteBuffer(buffer)); + } + unpack() { + return new MonsterT((this.pos() !== null ? this.pos().unpack() : null), this.mana(), this.hp(), this.name(), this.bb.createScalarList(this.inventory.bind(this), this.inventoryLength()), this.color(), this.testType(), (() => { + let temp = unionToAny(this.testType(), this.test.bind(this)); + if (temp === null) { + return null; + } + return temp.unpack(); + })(), this.bb.createObjList(this.test4.bind(this), this.test4Length()), this.bb.createScalarList(this.testarrayofstring.bind(this), this.testarrayofstringLength()), this.bb.createObjList(this.testarrayoftables.bind(this), this.testarrayoftablesLength()), (this.enemy() !== null ? this.enemy().unpack() : null), this.bb.createScalarList(this.testnestedflatbuffer.bind(this), this.testnestedflatbufferLength()), (this.testempty() !== null ? this.testempty().unpack() : null), this.testbool(), this.testhashs32Fnv1(), this.testhashu32Fnv1(), this.testhashs64Fnv1(), this.testhashu64Fnv1(), this.testhashs32Fnv1a(), this.testhashu32Fnv1a(), this.testhashs64Fnv1a(), this.testhashu64Fnv1a(), this.bb.createScalarList(this.testarrayofbools.bind(this), this.testarrayofboolsLength()), this.testf(), this.testf2(), this.testf3(), this.bb.createScalarList(this.testarrayofstring2.bind(this), this.testarrayofstring2Length()), this.bb.createObjList(this.testarrayofsortedstruct.bind(this), this.testarrayofsortedstructLength()), this.bb.createScalarList(this.flex.bind(this), this.flexLength()), this.bb.createObjList(this.test5.bind(this), this.test5Length()), this.bb.createScalarList(this.vectorOfLongs.bind(this), this.vectorOfLongsLength()), this.bb.createScalarList(this.vectorOfDoubles.bind(this), this.vectorOfDoublesLength()), (this.parentNamespaceTest() !== null ? this.parentNamespaceTest().unpack() : null), this.bb.createObjList(this.vectorOfReferrables.bind(this), this.vectorOfReferrablesLength()), this.singleWeakReference(), this.bb.createScalarList(this.vectorOfWeakReferences.bind(this), this.vectorOfWeakReferencesLength()), this.bb.createObjList(this.vectorOfStrongReferrables.bind(this), this.vectorOfStrongReferrablesLength()), this.coOwningReference(), this.bb.createScalarList(this.vectorOfCoOwningReferences.bind(this), this.vectorOfCoOwningReferencesLength()), this.nonOwningReference(), this.bb.createScalarList(this.vectorOfNonOwningReferences.bind(this), this.vectorOfNonOwningReferencesLength()), this.anyUniqueType(), (() => { + let temp = unionToAnyUniqueAliases(this.anyUniqueType(), this.anyUnique.bind(this)); + if (temp === null) { + return null; + } + return temp.unpack(); + })(), this.anyAmbiguousType(), (() => { + let temp = unionToAnyAmbiguousAliases(this.anyAmbiguousType(), this.anyAmbiguous.bind(this)); + if (temp === null) { + return null; + } + return temp.unpack(); + })(), this.bb.createScalarList(this.vectorOfEnums.bind(this), this.vectorOfEnumsLength()), this.signedEnum(), this.bb.createScalarList(this.testrequirednestedflatbuffer.bind(this), this.testrequirednestedflatbufferLength()), this.bb.createObjList(this.scalarKeySortedTables.bind(this), this.scalarKeySortedTablesLength()), (this.nativeInline() !== null ? this.nativeInline().unpack() : null), this.longEnumNonEnumDefault(), this.longEnumNormalDefault()); + } + unpackTo(_o) { + _o.pos = (this.pos() !== null ? this.pos().unpack() : null); + _o.mana = this.mana(); + _o.hp = this.hp(); + _o.name = this.name(); + _o.inventory = this.bb.createScalarList(this.inventory.bind(this), this.inventoryLength()); + _o.color = this.color(); + _o.testType = this.testType(); + _o.test = (() => { + let temp = unionToAny(this.testType(), this.test.bind(this)); + if (temp === null) { + return null; + } + return temp.unpack(); + })(); + _o.test4 = this.bb.createObjList(this.test4.bind(this), this.test4Length()); + _o.testarrayofstring = this.bb.createScalarList(this.testarrayofstring.bind(this), this.testarrayofstringLength()); + _o.testarrayoftables = this.bb.createObjList(this.testarrayoftables.bind(this), this.testarrayoftablesLength()); + _o.enemy = (this.enemy() !== null ? this.enemy().unpack() : null); + _o.testnestedflatbuffer = this.bb.createScalarList(this.testnestedflatbuffer.bind(this), this.testnestedflatbufferLength()); + _o.testempty = (this.testempty() !== null ? this.testempty().unpack() : null); + _o.testbool = this.testbool(); + _o.testhashs32Fnv1 = this.testhashs32Fnv1(); + _o.testhashu32Fnv1 = this.testhashu32Fnv1(); + _o.testhashs64Fnv1 = this.testhashs64Fnv1(); + _o.testhashu64Fnv1 = this.testhashu64Fnv1(); + _o.testhashs32Fnv1a = this.testhashs32Fnv1a(); + _o.testhashu32Fnv1a = this.testhashu32Fnv1a(); + _o.testhashs64Fnv1a = this.testhashs64Fnv1a(); + _o.testhashu64Fnv1a = this.testhashu64Fnv1a(); + _o.testarrayofbools = this.bb.createScalarList(this.testarrayofbools.bind(this), this.testarrayofboolsLength()); + _o.testf = this.testf(); + _o.testf2 = this.testf2(); + _o.testf3 = this.testf3(); + _o.testarrayofstring2 = this.bb.createScalarList(this.testarrayofstring2.bind(this), this.testarrayofstring2Length()); + _o.testarrayofsortedstruct = this.bb.createObjList(this.testarrayofsortedstruct.bind(this), this.testarrayofsortedstructLength()); + _o.flex = this.bb.createScalarList(this.flex.bind(this), this.flexLength()); + _o.test5 = this.bb.createObjList(this.test5.bind(this), this.test5Length()); + _o.vectorOfLongs = this.bb.createScalarList(this.vectorOfLongs.bind(this), this.vectorOfLongsLength()); + _o.vectorOfDoubles = this.bb.createScalarList(this.vectorOfDoubles.bind(this), this.vectorOfDoublesLength()); + _o.parentNamespaceTest = (this.parentNamespaceTest() !== null ? this.parentNamespaceTest().unpack() : null); + _o.vectorOfReferrables = this.bb.createObjList(this.vectorOfReferrables.bind(this), this.vectorOfReferrablesLength()); + _o.singleWeakReference = this.singleWeakReference(); + _o.vectorOfWeakReferences = this.bb.createScalarList(this.vectorOfWeakReferences.bind(this), this.vectorOfWeakReferencesLength()); + _o.vectorOfStrongReferrables = this.bb.createObjList(this.vectorOfStrongReferrables.bind(this), this.vectorOfStrongReferrablesLength()); + _o.coOwningReference = this.coOwningReference(); + _o.vectorOfCoOwningReferences = this.bb.createScalarList(this.vectorOfCoOwningReferences.bind(this), this.vectorOfCoOwningReferencesLength()); + _o.nonOwningReference = this.nonOwningReference(); + _o.vectorOfNonOwningReferences = this.bb.createScalarList(this.vectorOfNonOwningReferences.bind(this), this.vectorOfNonOwningReferencesLength()); + _o.anyUniqueType = this.anyUniqueType(); + _o.anyUnique = (() => { + let temp = unionToAnyUniqueAliases(this.anyUniqueType(), this.anyUnique.bind(this)); + if (temp === null) { + return null; + } + return temp.unpack(); + })(); + _o.anyAmbiguousType = this.anyAmbiguousType(); + _o.anyAmbiguous = (() => { + let temp = unionToAnyAmbiguousAliases(this.anyAmbiguousType(), this.anyAmbiguous.bind(this)); + if (temp === null) { + return null; + } + return temp.unpack(); + })(); + _o.vectorOfEnums = this.bb.createScalarList(this.vectorOfEnums.bind(this), this.vectorOfEnumsLength()); + _o.signedEnum = this.signedEnum(); + _o.testrequirednestedflatbuffer = this.bb.createScalarList(this.testrequirednestedflatbuffer.bind(this), this.testrequirednestedflatbufferLength()); + _o.scalarKeySortedTables = this.bb.createObjList(this.scalarKeySortedTables.bind(this), this.scalarKeySortedTablesLength()); + _o.nativeInline = (this.nativeInline() !== null ? this.nativeInline().unpack() : null); + _o.longEnumNonEnumDefault = this.longEnumNonEnumDefault(); + _o.longEnumNormalDefault = this.longEnumNormalDefault(); + } +} +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 = 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 = [], nativeInline = null, longEnumNonEnumDefault = BigInt('0'), longEnumNormalDefault = BigInt('2')) { + this.pos = pos; + this.mana = mana; + this.hp = hp; + this.name = name; + this.inventory = inventory; + this.color = color; + this.testType = testType; + this.test = test; + this.test4 = test4; + this.testarrayofstring = testarrayofstring; + this.testarrayoftables = testarrayoftables; + this.enemy = enemy; + this.testnestedflatbuffer = testnestedflatbuffer; + this.testempty = testempty; + this.testbool = testbool; + this.testhashs32Fnv1 = testhashs32Fnv1; + this.testhashu32Fnv1 = testhashu32Fnv1; + this.testhashs64Fnv1 = testhashs64Fnv1; + this.testhashu64Fnv1 = testhashu64Fnv1; + this.testhashs32Fnv1a = testhashs32Fnv1a; + this.testhashu32Fnv1a = testhashu32Fnv1a; + this.testhashs64Fnv1a = testhashs64Fnv1a; + this.testhashu64Fnv1a = testhashu64Fnv1a; + this.testarrayofbools = testarrayofbools; + this.testf = testf; + this.testf2 = testf2; + this.testf3 = testf3; + this.testarrayofstring2 = testarrayofstring2; + this.testarrayofsortedstruct = testarrayofsortedstruct; + this.flex = flex; + this.test5 = test5; + this.vectorOfLongs = vectorOfLongs; + this.vectorOfDoubles = vectorOfDoubles; + this.parentNamespaceTest = parentNamespaceTest; + this.vectorOfReferrables = vectorOfReferrables; + this.singleWeakReference = singleWeakReference; + this.vectorOfWeakReferences = vectorOfWeakReferences; + this.vectorOfStrongReferrables = vectorOfStrongReferrables; + this.coOwningReference = coOwningReference; + this.vectorOfCoOwningReferences = vectorOfCoOwningReferences; + this.nonOwningReference = nonOwningReference; + this.vectorOfNonOwningReferences = vectorOfNonOwningReferences; + this.anyUniqueType = anyUniqueType; + this.anyUnique = anyUnique; + this.anyAmbiguousType = anyAmbiguousType; + this.anyAmbiguous = anyAmbiguous; + this.vectorOfEnums = vectorOfEnums; + this.signedEnum = signedEnum; + this.testrequirednestedflatbuffer = testrequirednestedflatbuffer; + this.scalarKeySortedTables = scalarKeySortedTables; + this.nativeInline = nativeInline; + this.longEnumNonEnumDefault = longEnumNonEnumDefault; + this.longEnumNormalDefault = longEnumNormalDefault; + } + pack(builder) { + const name = (this.name !== null ? builder.createString(this.name) : 0); + const inventory = Monster.createInventoryVector(builder, this.inventory); + const test = builder.createObjectOffset(this.test); + const test4 = builder.createStructOffsetList(this.test4, Monster.startTest4Vector); + const testarrayofstring = Monster.createTestarrayofstringVector(builder, builder.createObjectOffsetList(this.testarrayofstring)); + const testarrayoftables = Monster.createTestarrayoftablesVector(builder, builder.createObjectOffsetList(this.testarrayoftables)); + const enemy = (this.enemy !== null ? this.enemy.pack(builder) : 0); + const testnestedflatbuffer = Monster.createTestnestedflatbufferVector(builder, this.testnestedflatbuffer); + const testempty = (this.testempty !== null ? this.testempty.pack(builder) : 0); + const testarrayofbools = Monster.createTestarrayofboolsVector(builder, this.testarrayofbools); + const testarrayofstring2 = Monster.createTestarrayofstring2Vector(builder, builder.createObjectOffsetList(this.testarrayofstring2)); + const testarrayofsortedstruct = builder.createStructOffsetList(this.testarrayofsortedstruct, Monster.startTestarrayofsortedstructVector); + const flex = Monster.createFlexVector(builder, this.flex); + const test5 = builder.createStructOffsetList(this.test5, Monster.startTest5Vector); + const vectorOfLongs = Monster.createVectorOfLongsVector(builder, this.vectorOfLongs); + const vectorOfDoubles = Monster.createVectorOfDoublesVector(builder, this.vectorOfDoubles); + const parentNamespaceTest = (this.parentNamespaceTest !== null ? this.parentNamespaceTest.pack(builder) : 0); + const vectorOfReferrables = Monster.createVectorOfReferrablesVector(builder, builder.createObjectOffsetList(this.vectorOfReferrables)); + const vectorOfWeakReferences = Monster.createVectorOfWeakReferencesVector(builder, this.vectorOfWeakReferences); + const vectorOfStrongReferrables = Monster.createVectorOfStrongReferrablesVector(builder, builder.createObjectOffsetList(this.vectorOfStrongReferrables)); + const vectorOfCoOwningReferences = Monster.createVectorOfCoOwningReferencesVector(builder, this.vectorOfCoOwningReferences); + const vectorOfNonOwningReferences = Monster.createVectorOfNonOwningReferencesVector(builder, this.vectorOfNonOwningReferences); + const anyUnique = builder.createObjectOffset(this.anyUnique); + const anyAmbiguous = builder.createObjectOffset(this.anyAmbiguous); + const vectorOfEnums = Monster.createVectorOfEnumsVector(builder, this.vectorOfEnums); + const testrequirednestedflatbuffer = Monster.createTestrequirednestedflatbufferVector(builder, this.testrequirednestedflatbuffer); + const scalarKeySortedTables = Monster.createScalarKeySortedTablesVector(builder, builder.createObjectOffsetList(this.scalarKeySortedTables)); + Monster.startMonster(builder); + Monster.addPos(builder, (this.pos !== null ? this.pos.pack(builder) : 0)); + Monster.addMana(builder, this.mana); + Monster.addHp(builder, this.hp); + Monster.addName(builder, name); + Monster.addInventory(builder, inventory); + Monster.addColor(builder, this.color); + Monster.addTestType(builder, this.testType); + Monster.addTest(builder, test); + Monster.addTest4(builder, test4); + Monster.addTestarrayofstring(builder, testarrayofstring); + Monster.addTestarrayoftables(builder, testarrayoftables); + Monster.addEnemy(builder, enemy); + Monster.addTestnestedflatbuffer(builder, testnestedflatbuffer); + Monster.addTestempty(builder, testempty); + Monster.addTestbool(builder, this.testbool); + Monster.addTesthashs32Fnv1(builder, this.testhashs32Fnv1); + Monster.addTesthashu32Fnv1(builder, this.testhashu32Fnv1); + Monster.addTesthashs64Fnv1(builder, this.testhashs64Fnv1); + Monster.addTesthashu64Fnv1(builder, this.testhashu64Fnv1); + Monster.addTesthashs32Fnv1a(builder, this.testhashs32Fnv1a); + Monster.addTesthashu32Fnv1a(builder, this.testhashu32Fnv1a); + Monster.addTesthashs64Fnv1a(builder, this.testhashs64Fnv1a); + Monster.addTesthashu64Fnv1a(builder, this.testhashu64Fnv1a); + Monster.addTestarrayofbools(builder, testarrayofbools); + Monster.addTestf(builder, this.testf); + Monster.addTestf2(builder, this.testf2); + Monster.addTestf3(builder, this.testf3); + Monster.addTestarrayofstring2(builder, testarrayofstring2); + Monster.addTestarrayofsortedstruct(builder, testarrayofsortedstruct); + Monster.addFlex(builder, flex); + Monster.addTest5(builder, test5); + Monster.addVectorOfLongs(builder, vectorOfLongs); + Monster.addVectorOfDoubles(builder, vectorOfDoubles); + Monster.addParentNamespaceTest(builder, parentNamespaceTest); + Monster.addVectorOfReferrables(builder, vectorOfReferrables); + Monster.addSingleWeakReference(builder, this.singleWeakReference); + Monster.addVectorOfWeakReferences(builder, vectorOfWeakReferences); + Monster.addVectorOfStrongReferrables(builder, vectorOfStrongReferrables); + Monster.addCoOwningReference(builder, this.coOwningReference); + Monster.addVectorOfCoOwningReferences(builder, vectorOfCoOwningReferences); + Monster.addNonOwningReference(builder, this.nonOwningReference); + Monster.addVectorOfNonOwningReferences(builder, vectorOfNonOwningReferences); + Monster.addAnyUniqueType(builder, this.anyUniqueType); + Monster.addAnyUnique(builder, anyUnique); + Monster.addAnyAmbiguousType(builder, this.anyAmbiguousType); + Monster.addAnyAmbiguous(builder, anyAmbiguous); + Monster.addVectorOfEnums(builder, vectorOfEnums); + Monster.addSignedEnum(builder, this.signedEnum); + Monster.addTestrequirednestedflatbuffer(builder, testrequirednestedflatbuffer); + Monster.addScalarKeySortedTables(builder, scalarKeySortedTables); + Monster.addNativeInline(builder, (this.nativeInline !== null ? this.nativeInline.pack(builder) : 0)); + Monster.addLongEnumNonEnumDefault(builder, this.longEnumNonEnumDefault); + Monster.addLongEnumNormalDefault(builder, this.longEnumNormalDefault); + return Monster.endMonster(builder); + } +} diff --git a/tests/ts/my-game/example/monster.ts b/tests/ts/my-game/example/monster.ts new file mode 100644 index 00000000000..63e5768e585 --- /dev/null +++ b/tests/ts/my-game/example/monster.ts @@ -0,0 +1,1434 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +import * as flatbuffers from 'flatbuffers'; + +import { Monster as MyGame_Example2_Monster, MonsterT as MyGame_Example2_MonsterT } from '../../my-game/example2/monster.js'; +import { Ability, AbilityT } from '../../my-game/example/ability.js'; +import { Any, unionToAny, unionListToAny } from '../../my-game/example/any.js'; +import { AnyAmbiguousAliases, unionToAnyAmbiguousAliases, unionListToAnyAmbiguousAliases } from '../../my-game/example/any-ambiguous-aliases.js'; +import { AnyUniqueAliases, unionToAnyUniqueAliases, unionListToAnyUniqueAliases } from '../../my-game/example/any-unique-aliases.js'; +import { Color } from '../../my-game/example/color.js'; +import { Race } from '../../my-game/example/race.js'; +import { Referrable, ReferrableT } from '../../my-game/example/referrable.js'; +import { Stat, StatT } from '../../my-game/example/stat.js'; +import { Test, TestT } from '../../my-game/example/test.js'; +import { TestSimpleTableWithEnum, TestSimpleTableWithEnumT } from '../../my-game/example/test-simple-table-with-enum.js'; +import { Vec3, Vec3T } from '../../my-game/example/vec3.js'; +import { InParentNamespace, InParentNamespaceT } from '../../my-game/in-parent-namespace.js'; + + +/** + * an example documentation comment: "monster object" + */ +export class Monster { + bb: flatbuffers.ByteBuffer|null = null; + bb_pos = 0; + __init(i:number, bb:flatbuffers.ByteBuffer):Monster { + this.bb_pos = i; + this.bb = bb; + return this; +} + +static getRootAsMonster(bb:flatbuffers.ByteBuffer, obj?:Monster):Monster { + return (obj || new Monster()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +static getSizePrefixedRootAsMonster(bb:flatbuffers.ByteBuffer, obj?:Monster):Monster { + bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); + return (obj || new Monster()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +static bufferHasIdentifier(bb:flatbuffers.ByteBuffer):boolean { + return bb.__has_identifier('MONS'); +} + +pos(obj?:Vec3):Vec3|null { + const offset = this.bb!.__offset(this.bb_pos, 4); + return offset ? (obj || new Vec3()).__init(this.bb_pos + offset, this.bb!) : null; +} + +mana():number { + const offset = this.bb!.__offset(this.bb_pos, 6); + return offset ? this.bb!.readInt16(this.bb_pos + offset) : 150; +} + +mutate_mana(value:number):boolean { + const offset = this.bb!.__offset(this.bb_pos, 6); + + if (offset === 0) { + return false; + } + + this.bb!.writeInt16(this.bb_pos + offset, value); + return true; +} + +hp():number { + const offset = this.bb!.__offset(this.bb_pos, 8); + return offset ? this.bb!.readInt16(this.bb_pos + offset) : 100; +} + +mutate_hp(value:number):boolean { + const offset = this.bb!.__offset(this.bb_pos, 8); + + if (offset === 0) { + return false; + } + + this.bb!.writeInt16(this.bb_pos + offset, value); + return true; +} + +name():string|null +name(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null +name(optionalEncoding?:any):string|Uint8Array|null { + const offset = this.bb!.__offset(this.bb_pos, 10); + return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; +} + +inventory(index: number):number|null { + const offset = this.bb!.__offset(this.bb_pos, 14); + return offset ? this.bb!.readUint8(this.bb!.__vector(this.bb_pos + offset) + index) : 0; +} + +inventoryLength():number { + const offset = this.bb!.__offset(this.bb_pos, 14); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +} + +inventoryArray():Uint8Array|null { + const offset = this.bb!.__offset(this.bb_pos, 14); + return offset ? new Uint8Array(this.bb!.bytes().buffer, this.bb!.bytes().byteOffset + this.bb!.__vector(this.bb_pos + offset), this.bb!.__vector_len(this.bb_pos + offset)) : null; +} + +color():Color { + const offset = this.bb!.__offset(this.bb_pos, 16); + return offset ? this.bb!.readUint8(this.bb_pos + offset) : Color.Blue; +} + +mutate_color(value:Color):boolean { + const offset = this.bb!.__offset(this.bb_pos, 16); + + if (offset === 0) { + return false; + } + + this.bb!.writeUint8(this.bb_pos + offset, value); + return true; +} + +testType():Any { + const offset = this.bb!.__offset(this.bb_pos, 18); + return offset ? this.bb!.readUint8(this.bb_pos + offset) : Any.NONE; +} + +test(obj:any):any|null { + const offset = this.bb!.__offset(this.bb_pos, 20); + return offset ? this.bb!.__union(obj, this.bb_pos + offset) : null; +} + +test4(index: number, obj?:Test):Test|null { + const offset = this.bb!.__offset(this.bb_pos, 22); + return offset ? (obj || new Test()).__init(this.bb!.__vector(this.bb_pos + offset) + index * 4, this.bb!) : null; +} + +test4Length():number { + const offset = this.bb!.__offset(this.bb_pos, 22); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +} + +testarrayofstring(index: number):string +testarrayofstring(index: number,optionalEncoding:flatbuffers.Encoding):string|Uint8Array +testarrayofstring(index: number,optionalEncoding?:any):string|Uint8Array|null { + const offset = this.bb!.__offset(this.bb_pos, 24); + return offset ? this.bb!.__string(this.bb!.__vector(this.bb_pos + offset) + index * 4, optionalEncoding) : null; +} + +testarrayofstringLength():number { + const offset = this.bb!.__offset(this.bb_pos, 24); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +} + +/** + * an example documentation comment: this will end up in the generated code + * multiline too + */ +testarrayoftables(index: number, obj?:Monster):Monster|null { + const offset = this.bb!.__offset(this.bb_pos, 26); + return offset ? (obj || new Monster()).__init(this.bb!.__indirect(this.bb!.__vector(this.bb_pos + offset) + index * 4), this.bb!) : null; +} + +testarrayoftablesLength():number { + const offset = this.bb!.__offset(this.bb_pos, 26); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +} + +enemy(obj?:Monster):Monster|null { + const offset = this.bb!.__offset(this.bb_pos, 28); + return offset ? (obj || new Monster()).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null; +} + +testnestedflatbuffer(index: number):number|null { + const offset = this.bb!.__offset(this.bb_pos, 30); + return offset ? this.bb!.readUint8(this.bb!.__vector(this.bb_pos + offset) + index) : 0; +} + +testnestedflatbufferLength():number { + const offset = this.bb!.__offset(this.bb_pos, 30); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +} + +testnestedflatbufferArray():Uint8Array|null { + const offset = this.bb!.__offset(this.bb_pos, 30); + return offset ? new Uint8Array(this.bb!.bytes().buffer, this.bb!.bytes().byteOffset + this.bb!.__vector(this.bb_pos + offset), this.bb!.__vector_len(this.bb_pos + offset)) : null; +} + +testempty(obj?:Stat):Stat|null { + const offset = this.bb!.__offset(this.bb_pos, 32); + return offset ? (obj || new Stat()).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null; +} + +testbool():boolean { + const offset = this.bb!.__offset(this.bb_pos, 34); + return offset ? !!this.bb!.readInt8(this.bb_pos + offset) : false; +} + +mutate_testbool(value:boolean):boolean { + const offset = this.bb!.__offset(this.bb_pos, 34); + + if (offset === 0) { + return false; + } + + this.bb!.writeInt8(this.bb_pos + offset, +value); + return true; +} + +testhashs32Fnv1():number { + const offset = this.bb!.__offset(this.bb_pos, 36); + return offset ? this.bb!.readInt32(this.bb_pos + offset) : 0; +} + +mutate_testhashs32_fnv1(value:number):boolean { + const offset = this.bb!.__offset(this.bb_pos, 36); + + if (offset === 0) { + return false; + } + + this.bb!.writeInt32(this.bb_pos + offset, value); + return true; +} + +testhashu32Fnv1():number { + const offset = this.bb!.__offset(this.bb_pos, 38); + return offset ? this.bb!.readUint32(this.bb_pos + offset) : 0; +} + +mutate_testhashu32_fnv1(value:number):boolean { + const offset = this.bb!.__offset(this.bb_pos, 38); + + if (offset === 0) { + return false; + } + + this.bb!.writeUint32(this.bb_pos + offset, value); + return true; +} + +testhashs64Fnv1():bigint { + const offset = this.bb!.__offset(this.bb_pos, 40); + return offset ? this.bb!.readInt64(this.bb_pos + offset) : BigInt('0'); +} + +mutate_testhashs64_fnv1(value:bigint):boolean { + const offset = this.bb!.__offset(this.bb_pos, 40); + + if (offset === 0) { + return false; + } + + this.bb!.writeInt64(this.bb_pos + offset, value); + return true; +} + +testhashu64Fnv1():bigint { + const offset = this.bb!.__offset(this.bb_pos, 42); + return offset ? this.bb!.readUint64(this.bb_pos + offset) : BigInt('0'); +} + +mutate_testhashu64_fnv1(value:bigint):boolean { + const offset = this.bb!.__offset(this.bb_pos, 42); + + if (offset === 0) { + return false; + } + + this.bb!.writeUint64(this.bb_pos + offset, value); + return true; +} + +testhashs32Fnv1a():number { + const offset = this.bb!.__offset(this.bb_pos, 44); + return offset ? this.bb!.readInt32(this.bb_pos + offset) : 0; +} + +mutate_testhashs32_fnv1a(value:number):boolean { + const offset = this.bb!.__offset(this.bb_pos, 44); + + if (offset === 0) { + return false; + } + + this.bb!.writeInt32(this.bb_pos + offset, value); + return true; +} + +testhashu32Fnv1a():number { + const offset = this.bb!.__offset(this.bb_pos, 46); + return offset ? this.bb!.readUint32(this.bb_pos + offset) : 0; +} + +mutate_testhashu32_fnv1a(value:number):boolean { + const offset = this.bb!.__offset(this.bb_pos, 46); + + if (offset === 0) { + return false; + } + + this.bb!.writeUint32(this.bb_pos + offset, value); + return true; +} + +testhashs64Fnv1a():bigint { + const offset = this.bb!.__offset(this.bb_pos, 48); + return offset ? this.bb!.readInt64(this.bb_pos + offset) : BigInt('0'); +} + +mutate_testhashs64_fnv1a(value:bigint):boolean { + const offset = this.bb!.__offset(this.bb_pos, 48); + + if (offset === 0) { + return false; + } + + this.bb!.writeInt64(this.bb_pos + offset, value); + return true; +} + +testhashu64Fnv1a():bigint { + const offset = this.bb!.__offset(this.bb_pos, 50); + return offset ? this.bb!.readUint64(this.bb_pos + offset) : BigInt('0'); +} + +mutate_testhashu64_fnv1a(value:bigint):boolean { + const offset = this.bb!.__offset(this.bb_pos, 50); + + if (offset === 0) { + return false; + } + + this.bb!.writeUint64(this.bb_pos + offset, value); + return true; +} + +testarrayofbools(index: number):boolean|null { + const offset = this.bb!.__offset(this.bb_pos, 52); + return offset ? !!this.bb!.readInt8(this.bb!.__vector(this.bb_pos + offset) + index) : false; +} + +testarrayofboolsLength():number { + const offset = this.bb!.__offset(this.bb_pos, 52); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +} + +testarrayofboolsArray():Int8Array|null { + const offset = this.bb!.__offset(this.bb_pos, 52); + 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; +} + +testf():number { + const offset = this.bb!.__offset(this.bb_pos, 54); + return offset ? this.bb!.readFloat32(this.bb_pos + offset) : 3.14159; +} + +mutate_testf(value:number):boolean { + const offset = this.bb!.__offset(this.bb_pos, 54); + + if (offset === 0) { + return false; + } + + this.bb!.writeFloat32(this.bb_pos + offset, value); + return true; +} + +testf2():number { + const offset = this.bb!.__offset(this.bb_pos, 56); + return offset ? this.bb!.readFloat32(this.bb_pos + offset) : 3.0; +} + +mutate_testf2(value:number):boolean { + const offset = this.bb!.__offset(this.bb_pos, 56); + + if (offset === 0) { + return false; + } + + this.bb!.writeFloat32(this.bb_pos + offset, value); + return true; +} + +testf3():number { + const offset = this.bb!.__offset(this.bb_pos, 58); + return offset ? this.bb!.readFloat32(this.bb_pos + offset) : 0.0; +} + +mutate_testf3(value:number):boolean { + const offset = this.bb!.__offset(this.bb_pos, 58); + + if (offset === 0) { + return false; + } + + this.bb!.writeFloat32(this.bb_pos + offset, value); + return true; +} + +testarrayofstring2(index: number):string +testarrayofstring2(index: number,optionalEncoding:flatbuffers.Encoding):string|Uint8Array +testarrayofstring2(index: number,optionalEncoding?:any):string|Uint8Array|null { + const offset = this.bb!.__offset(this.bb_pos, 60); + return offset ? this.bb!.__string(this.bb!.__vector(this.bb_pos + offset) + index * 4, optionalEncoding) : null; +} + +testarrayofstring2Length():number { + const offset = this.bb!.__offset(this.bb_pos, 60); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +} + +testarrayofsortedstruct(index: number, obj?:Ability):Ability|null { + const offset = this.bb!.__offset(this.bb_pos, 62); + return offset ? (obj || new Ability()).__init(this.bb!.__vector(this.bb_pos + offset) + index * 8, this.bb!) : null; +} + +testarrayofsortedstructLength():number { + const offset = this.bb!.__offset(this.bb_pos, 62); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +} + +flex(index: number):number|null { + const offset = this.bb!.__offset(this.bb_pos, 64); + return offset ? this.bb!.readUint8(this.bb!.__vector(this.bb_pos + offset) + index) : 0; +} + +flexLength():number { + const offset = this.bb!.__offset(this.bb_pos, 64); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +} + +flexArray():Uint8Array|null { + const offset = this.bb!.__offset(this.bb_pos, 64); + return offset ? new Uint8Array(this.bb!.bytes().buffer, this.bb!.bytes().byteOffset + this.bb!.__vector(this.bb_pos + offset), this.bb!.__vector_len(this.bb_pos + offset)) : null; +} + +test5(index: number, obj?:Test):Test|null { + const offset = this.bb!.__offset(this.bb_pos, 66); + return offset ? (obj || new Test()).__init(this.bb!.__vector(this.bb_pos + offset) + index * 4, this.bb!) : null; +} + +test5Length():number { + const offset = this.bb!.__offset(this.bb_pos, 66); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +} + +vectorOfLongs(index: number):bigint|null { + const offset = this.bb!.__offset(this.bb_pos, 68); + return offset ? this.bb!.readInt64(this.bb!.__vector(this.bb_pos + offset) + index * 8) : BigInt(0); +} + +vectorOfLongsLength():number { + const offset = this.bb!.__offset(this.bb_pos, 68); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +} + +vectorOfDoubles(index: number):number|null { + const offset = this.bb!.__offset(this.bb_pos, 70); + return offset ? this.bb!.readFloat64(this.bb!.__vector(this.bb_pos + offset) + index * 8) : 0; +} + +vectorOfDoublesLength():number { + const offset = this.bb!.__offset(this.bb_pos, 70); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +} + +vectorOfDoublesArray():Float64Array|null { + const offset = this.bb!.__offset(this.bb_pos, 70); + 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; +} + +parentNamespaceTest(obj?:InParentNamespace):InParentNamespace|null { + const offset = this.bb!.__offset(this.bb_pos, 72); + return offset ? (obj || new InParentNamespace()).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null; +} + +vectorOfReferrables(index: number, obj?:Referrable):Referrable|null { + const offset = this.bb!.__offset(this.bb_pos, 74); + return offset ? (obj || new Referrable()).__init(this.bb!.__indirect(this.bb!.__vector(this.bb_pos + offset) + index * 4), this.bb!) : null; +} + +vectorOfReferrablesLength():number { + const offset = this.bb!.__offset(this.bb_pos, 74); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +} + +singleWeakReference():bigint { + const offset = this.bb!.__offset(this.bb_pos, 76); + return offset ? this.bb!.readUint64(this.bb_pos + offset) : BigInt('0'); +} + +mutate_single_weak_reference(value:bigint):boolean { + const offset = this.bb!.__offset(this.bb_pos, 76); + + if (offset === 0) { + return false; + } + + this.bb!.writeUint64(this.bb_pos + offset, value); + return true; +} + +vectorOfWeakReferences(index: number):bigint|null { + const offset = this.bb!.__offset(this.bb_pos, 78); + return offset ? this.bb!.readUint64(this.bb!.__vector(this.bb_pos + offset) + index * 8) : BigInt(0); +} + +vectorOfWeakReferencesLength():number { + const offset = this.bb!.__offset(this.bb_pos, 78); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +} + +vectorOfStrongReferrables(index: number, obj?:Referrable):Referrable|null { + const offset = this.bb!.__offset(this.bb_pos, 80); + return offset ? (obj || new Referrable()).__init(this.bb!.__indirect(this.bb!.__vector(this.bb_pos + offset) + index * 4), this.bb!) : null; +} + +vectorOfStrongReferrablesLength():number { + const offset = this.bb!.__offset(this.bb_pos, 80); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +} + +coOwningReference():bigint { + const offset = this.bb!.__offset(this.bb_pos, 82); + return offset ? this.bb!.readUint64(this.bb_pos + offset) : BigInt('0'); +} + +mutate_co_owning_reference(value:bigint):boolean { + const offset = this.bb!.__offset(this.bb_pos, 82); + + if (offset === 0) { + return false; + } + + this.bb!.writeUint64(this.bb_pos + offset, value); + return true; +} + +vectorOfCoOwningReferences(index: number):bigint|null { + const offset = this.bb!.__offset(this.bb_pos, 84); + return offset ? this.bb!.readUint64(this.bb!.__vector(this.bb_pos + offset) + index * 8) : BigInt(0); +} + +vectorOfCoOwningReferencesLength():number { + const offset = this.bb!.__offset(this.bb_pos, 84); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +} + +nonOwningReference():bigint { + const offset = this.bb!.__offset(this.bb_pos, 86); + return offset ? this.bb!.readUint64(this.bb_pos + offset) : BigInt('0'); +} + +mutate_non_owning_reference(value:bigint):boolean { + const offset = this.bb!.__offset(this.bb_pos, 86); + + if (offset === 0) { + return false; + } + + this.bb!.writeUint64(this.bb_pos + offset, value); + return true; +} + +vectorOfNonOwningReferences(index: number):bigint|null { + const offset = this.bb!.__offset(this.bb_pos, 88); + return offset ? this.bb!.readUint64(this.bb!.__vector(this.bb_pos + offset) + index * 8) : BigInt(0); +} + +vectorOfNonOwningReferencesLength():number { + const offset = this.bb!.__offset(this.bb_pos, 88); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +} + +anyUniqueType():AnyUniqueAliases { + const offset = this.bb!.__offset(this.bb_pos, 90); + return offset ? this.bb!.readUint8(this.bb_pos + offset) : AnyUniqueAliases.NONE; +} + +anyUnique(obj:any):any|null { + const offset = this.bb!.__offset(this.bb_pos, 92); + return offset ? this.bb!.__union(obj, this.bb_pos + offset) : null; +} + +anyAmbiguousType():AnyAmbiguousAliases { + const offset = this.bb!.__offset(this.bb_pos, 94); + return offset ? this.bb!.readUint8(this.bb_pos + offset) : AnyAmbiguousAliases.NONE; +} + +anyAmbiguous(obj:any):any|null { + const offset = this.bb!.__offset(this.bb_pos, 96); + return offset ? this.bb!.__union(obj, this.bb_pos + offset) : null; +} + +vectorOfEnums(index: number):Color|null { + const offset = this.bb!.__offset(this.bb_pos, 98); + return offset ? this.bb!.readUint8(this.bb!.__vector(this.bb_pos + offset) + index) : 0; +} + +vectorOfEnumsLength():number { + const offset = this.bb!.__offset(this.bb_pos, 98); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +} + +vectorOfEnumsArray():Uint8Array|null { + const offset = this.bb!.__offset(this.bb_pos, 98); + return offset ? new Uint8Array(this.bb!.bytes().buffer, this.bb!.bytes().byteOffset + this.bb!.__vector(this.bb_pos + offset), this.bb!.__vector_len(this.bb_pos + offset)) : null; +} + +signedEnum():Race { + const offset = this.bb!.__offset(this.bb_pos, 100); + return offset ? this.bb!.readInt8(this.bb_pos + offset) : Race.None; +} + +mutate_signed_enum(value:Race):boolean { + const offset = this.bb!.__offset(this.bb_pos, 100); + + if (offset === 0) { + return false; + } + + this.bb!.writeInt8(this.bb_pos + offset, value); + return true; +} + +testrequirednestedflatbuffer(index: number):number|null { + const offset = this.bb!.__offset(this.bb_pos, 102); + return offset ? this.bb!.readUint8(this.bb!.__vector(this.bb_pos + offset) + index) : 0; +} + +testrequirednestedflatbufferLength():number { + const offset = this.bb!.__offset(this.bb_pos, 102); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +} + +testrequirednestedflatbufferArray():Uint8Array|null { + const offset = this.bb!.__offset(this.bb_pos, 102); + return offset ? new Uint8Array(this.bb!.bytes().buffer, this.bb!.bytes().byteOffset + this.bb!.__vector(this.bb_pos + offset), this.bb!.__vector_len(this.bb_pos + offset)) : null; +} + +scalarKeySortedTables(index: number, obj?:Stat):Stat|null { + const offset = this.bb!.__offset(this.bb_pos, 104); + return offset ? (obj || new Stat()).__init(this.bb!.__indirect(this.bb!.__vector(this.bb_pos + offset) + index * 4), this.bb!) : null; +} + +scalarKeySortedTablesLength():number { + const offset = this.bb!.__offset(this.bb_pos, 104); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +} + +nativeInline(obj?:Test):Test|null { + const offset = this.bb!.__offset(this.bb_pos, 106); + return offset ? (obj || new Test()).__init(this.bb_pos + offset, this.bb!) : null; +} + +longEnumNonEnumDefault():bigint { + const offset = this.bb!.__offset(this.bb_pos, 108); + return offset ? this.bb!.readUint64(this.bb_pos + offset) : BigInt('0'); +} + +mutate_long_enum_non_enum_default(value:bigint):boolean { + const offset = this.bb!.__offset(this.bb_pos, 108); + + if (offset === 0) { + return false; + } + + this.bb!.writeUint64(this.bb_pos + offset, value); + return true; +} + +longEnumNormalDefault():bigint { + const offset = this.bb!.__offset(this.bb_pos, 110); + return offset ? this.bb!.readUint64(this.bb_pos + offset) : BigInt('2'); +} + +mutate_long_enum_normal_default(value:bigint):boolean { + const offset = this.bb!.__offset(this.bb_pos, 110); + + if (offset === 0) { + return false; + } + + this.bb!.writeUint64(this.bb_pos + offset, value); + return true; +} + +static getFullyQualifiedName():string { + return 'MyGame_Example_Monster'; +} + +static startMonster(builder:flatbuffers.Builder) { + builder.startObject(54); +} + +static addPos(builder:flatbuffers.Builder, posOffset:flatbuffers.Offset) { + builder.addFieldStruct(0, posOffset, 0); +} + +static addMana(builder:flatbuffers.Builder, mana:number) { + builder.addFieldInt16(1, mana, 150); +} + +static addHp(builder:flatbuffers.Builder, hp:number) { + builder.addFieldInt16(2, hp, 100); +} + +static addName(builder:flatbuffers.Builder, nameOffset:flatbuffers.Offset) { + builder.addFieldOffset(3, nameOffset, 0); +} + +static addInventory(builder:flatbuffers.Builder, inventoryOffset:flatbuffers.Offset) { + builder.addFieldOffset(5, inventoryOffset, 0); +} + +static createInventoryVector(builder:flatbuffers.Builder, data:number[]|Uint8Array):flatbuffers.Offset { + builder.startVector(1, data.length, 1); + for (let i = data.length - 1; i >= 0; i--) { + builder.addInt8(data[i]!); + } + return builder.endVector(); +} + +static startInventoryVector(builder:flatbuffers.Builder, numElems:number) { + builder.startVector(1, numElems, 1); +} + +static addColor(builder:flatbuffers.Builder, color:Color) { + builder.addFieldInt8(6, color, Color.Blue); +} + +static addTestType(builder:flatbuffers.Builder, testType:Any) { + builder.addFieldInt8(7, testType, Any.NONE); +} + +static addTest(builder:flatbuffers.Builder, testOffset:flatbuffers.Offset) { + builder.addFieldOffset(8, testOffset, 0); +} + +static addTest4(builder:flatbuffers.Builder, test4Offset:flatbuffers.Offset) { + builder.addFieldOffset(9, test4Offset, 0); +} + +static startTest4Vector(builder:flatbuffers.Builder, numElems:number) { + builder.startVector(4, numElems, 2); +} + +static addTestarrayofstring(builder:flatbuffers.Builder, testarrayofstringOffset:flatbuffers.Offset) { + builder.addFieldOffset(10, testarrayofstringOffset, 0); +} + +static createTestarrayofstringVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addOffset(data[i]!); + } + return builder.endVector(); +} + +static startTestarrayofstringVector(builder:flatbuffers.Builder, numElems:number) { + builder.startVector(4, numElems, 4); +} + +static addTestarrayoftables(builder:flatbuffers.Builder, testarrayoftablesOffset:flatbuffers.Offset) { + builder.addFieldOffset(11, testarrayoftablesOffset, 0); +} + +static createTestarrayoftablesVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addOffset(data[i]!); + } + return builder.endVector(); +} + +static startTestarrayoftablesVector(builder:flatbuffers.Builder, numElems:number) { + builder.startVector(4, numElems, 4); +} + +static addEnemy(builder:flatbuffers.Builder, enemyOffset:flatbuffers.Offset) { + builder.addFieldOffset(12, enemyOffset, 0); +} + +static addTestnestedflatbuffer(builder:flatbuffers.Builder, testnestedflatbufferOffset:flatbuffers.Offset) { + builder.addFieldOffset(13, testnestedflatbufferOffset, 0); +} + +static createTestnestedflatbufferVector(builder:flatbuffers.Builder, data:number[]|Uint8Array):flatbuffers.Offset { + builder.startVector(1, data.length, 1); + for (let i = data.length - 1; i >= 0; i--) { + builder.addInt8(data[i]!); + } + return builder.endVector(); +} + +static startTestnestedflatbufferVector(builder:flatbuffers.Builder, numElems:number) { + builder.startVector(1, numElems, 1); +} + +static addTestempty(builder:flatbuffers.Builder, testemptyOffset:flatbuffers.Offset) { + builder.addFieldOffset(14, testemptyOffset, 0); +} + +static addTestbool(builder:flatbuffers.Builder, testbool:boolean) { + builder.addFieldInt8(15, +testbool, +false); +} + +static addTesthashs32Fnv1(builder:flatbuffers.Builder, testhashs32Fnv1:number) { + builder.addFieldInt32(16, testhashs32Fnv1, 0); +} + +static addTesthashu32Fnv1(builder:flatbuffers.Builder, testhashu32Fnv1:number) { + builder.addFieldInt32(17, testhashu32Fnv1, 0); +} + +static addTesthashs64Fnv1(builder:flatbuffers.Builder, testhashs64Fnv1:bigint) { + builder.addFieldInt64(18, testhashs64Fnv1, BigInt('0')); +} + +static addTesthashu64Fnv1(builder:flatbuffers.Builder, testhashu64Fnv1:bigint) { + builder.addFieldInt64(19, testhashu64Fnv1, BigInt('0')); +} + +static addTesthashs32Fnv1a(builder:flatbuffers.Builder, testhashs32Fnv1a:number) { + builder.addFieldInt32(20, testhashs32Fnv1a, 0); +} + +static addTesthashu32Fnv1a(builder:flatbuffers.Builder, testhashu32Fnv1a:number) { + builder.addFieldInt32(21, testhashu32Fnv1a, 0); +} + +static addTesthashs64Fnv1a(builder:flatbuffers.Builder, testhashs64Fnv1a:bigint) { + builder.addFieldInt64(22, testhashs64Fnv1a, BigInt('0')); +} + +static addTesthashu64Fnv1a(builder:flatbuffers.Builder, testhashu64Fnv1a:bigint) { + builder.addFieldInt64(23, testhashu64Fnv1a, BigInt('0')); +} + +static addTestarrayofbools(builder:flatbuffers.Builder, testarrayofboolsOffset:flatbuffers.Offset) { + builder.addFieldOffset(24, testarrayofboolsOffset, 0); +} + +static createTestarrayofboolsVector(builder:flatbuffers.Builder, data:boolean[]):flatbuffers.Offset { + builder.startVector(1, data.length, 1); + for (let i = data.length - 1; i >= 0; i--) { + builder.addInt8(+data[i]!); + } + return builder.endVector(); +} + +static startTestarrayofboolsVector(builder:flatbuffers.Builder, numElems:number) { + builder.startVector(1, numElems, 1); +} + +static addTestf(builder:flatbuffers.Builder, testf:number) { + builder.addFieldFloat32(25, testf, 3.14159); +} + +static addTestf2(builder:flatbuffers.Builder, testf2:number) { + builder.addFieldFloat32(26, testf2, 3.0); +} + +static addTestf3(builder:flatbuffers.Builder, testf3:number) { + builder.addFieldFloat32(27, testf3, 0.0); +} + +static addTestarrayofstring2(builder:flatbuffers.Builder, testarrayofstring2Offset:flatbuffers.Offset) { + builder.addFieldOffset(28, testarrayofstring2Offset, 0); +} + +static createTestarrayofstring2Vector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addOffset(data[i]!); + } + return builder.endVector(); +} + +static startTestarrayofstring2Vector(builder:flatbuffers.Builder, numElems:number) { + builder.startVector(4, numElems, 4); +} + +static addTestarrayofsortedstruct(builder:flatbuffers.Builder, testarrayofsortedstructOffset:flatbuffers.Offset) { + builder.addFieldOffset(29, testarrayofsortedstructOffset, 0); +} + +static startTestarrayofsortedstructVector(builder:flatbuffers.Builder, numElems:number) { + builder.startVector(8, numElems, 4); +} + +static addFlex(builder:flatbuffers.Builder, flexOffset:flatbuffers.Offset) { + builder.addFieldOffset(30, flexOffset, 0); +} + +static createFlexVector(builder:flatbuffers.Builder, data:number[]|Uint8Array):flatbuffers.Offset { + builder.startVector(1, data.length, 1); + for (let i = data.length - 1; i >= 0; i--) { + builder.addInt8(data[i]!); + } + return builder.endVector(); +} + +static startFlexVector(builder:flatbuffers.Builder, numElems:number) { + builder.startVector(1, numElems, 1); +} + +static addTest5(builder:flatbuffers.Builder, test5Offset:flatbuffers.Offset) { + builder.addFieldOffset(31, test5Offset, 0); +} + +static startTest5Vector(builder:flatbuffers.Builder, numElems:number) { + builder.startVector(4, numElems, 2); +} + +static addVectorOfLongs(builder:flatbuffers.Builder, vectorOfLongsOffset:flatbuffers.Offset) { + builder.addFieldOffset(32, vectorOfLongsOffset, 0); +} + +static createVectorOfLongsVector(builder:flatbuffers.Builder, data:bigint[]):flatbuffers.Offset { + builder.startVector(8, data.length, 8); + for (let i = data.length - 1; i >= 0; i--) { + builder.addInt64(data[i]!); + } + return builder.endVector(); +} + +static startVectorOfLongsVector(builder:flatbuffers.Builder, numElems:number) { + builder.startVector(8, numElems, 8); +} + +static addVectorOfDoubles(builder:flatbuffers.Builder, vectorOfDoublesOffset:flatbuffers.Offset) { + builder.addFieldOffset(33, vectorOfDoublesOffset, 0); +} + +static createVectorOfDoublesVector(builder:flatbuffers.Builder, data:number[]|Float64Array):flatbuffers.Offset; +/** + * @deprecated This Uint8Array overload will be removed in the future. + */ +static createVectorOfDoublesVector(builder:flatbuffers.Builder, data:number[]|Uint8Array):flatbuffers.Offset; +static createVectorOfDoublesVector(builder:flatbuffers.Builder, data:number[]|Float64Array|Uint8Array):flatbuffers.Offset { + builder.startVector(8, data.length, 8); + for (let i = data.length - 1; i >= 0; i--) { + builder.addFloat64(data[i]!); + } + return builder.endVector(); +} + +static startVectorOfDoublesVector(builder:flatbuffers.Builder, numElems:number) { + builder.startVector(8, numElems, 8); +} + +static addParentNamespaceTest(builder:flatbuffers.Builder, parentNamespaceTestOffset:flatbuffers.Offset) { + builder.addFieldOffset(34, parentNamespaceTestOffset, 0); +} + +static addVectorOfReferrables(builder:flatbuffers.Builder, vectorOfReferrablesOffset:flatbuffers.Offset) { + builder.addFieldOffset(35, vectorOfReferrablesOffset, 0); +} + +static createVectorOfReferrablesVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addOffset(data[i]!); + } + return builder.endVector(); +} + +static startVectorOfReferrablesVector(builder:flatbuffers.Builder, numElems:number) { + builder.startVector(4, numElems, 4); +} + +static addSingleWeakReference(builder:flatbuffers.Builder, singleWeakReference:bigint) { + builder.addFieldInt64(36, singleWeakReference, BigInt('0')); +} + +static addVectorOfWeakReferences(builder:flatbuffers.Builder, vectorOfWeakReferencesOffset:flatbuffers.Offset) { + builder.addFieldOffset(37, vectorOfWeakReferencesOffset, 0); +} + +static createVectorOfWeakReferencesVector(builder:flatbuffers.Builder, data:bigint[]):flatbuffers.Offset { + builder.startVector(8, data.length, 8); + for (let i = data.length - 1; i >= 0; i--) { + builder.addInt64(data[i]!); + } + return builder.endVector(); +} + +static startVectorOfWeakReferencesVector(builder:flatbuffers.Builder, numElems:number) { + builder.startVector(8, numElems, 8); +} + +static addVectorOfStrongReferrables(builder:flatbuffers.Builder, vectorOfStrongReferrablesOffset:flatbuffers.Offset) { + builder.addFieldOffset(38, vectorOfStrongReferrablesOffset, 0); +} + +static createVectorOfStrongReferrablesVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addOffset(data[i]!); + } + return builder.endVector(); +} + +static startVectorOfStrongReferrablesVector(builder:flatbuffers.Builder, numElems:number) { + builder.startVector(4, numElems, 4); +} + +static addCoOwningReference(builder:flatbuffers.Builder, coOwningReference:bigint) { + builder.addFieldInt64(39, coOwningReference, BigInt('0')); +} + +static addVectorOfCoOwningReferences(builder:flatbuffers.Builder, vectorOfCoOwningReferencesOffset:flatbuffers.Offset) { + builder.addFieldOffset(40, vectorOfCoOwningReferencesOffset, 0); +} + +static createVectorOfCoOwningReferencesVector(builder:flatbuffers.Builder, data:bigint[]):flatbuffers.Offset { + builder.startVector(8, data.length, 8); + for (let i = data.length - 1; i >= 0; i--) { + builder.addInt64(data[i]!); + } + return builder.endVector(); +} + +static startVectorOfCoOwningReferencesVector(builder:flatbuffers.Builder, numElems:number) { + builder.startVector(8, numElems, 8); +} + +static addNonOwningReference(builder:flatbuffers.Builder, nonOwningReference:bigint) { + builder.addFieldInt64(41, nonOwningReference, BigInt('0')); +} + +static addVectorOfNonOwningReferences(builder:flatbuffers.Builder, vectorOfNonOwningReferencesOffset:flatbuffers.Offset) { + builder.addFieldOffset(42, vectorOfNonOwningReferencesOffset, 0); +} + +static createVectorOfNonOwningReferencesVector(builder:flatbuffers.Builder, data:bigint[]):flatbuffers.Offset { + builder.startVector(8, data.length, 8); + for (let i = data.length - 1; i >= 0; i--) { + builder.addInt64(data[i]!); + } + return builder.endVector(); +} + +static startVectorOfNonOwningReferencesVector(builder:flatbuffers.Builder, numElems:number) { + builder.startVector(8, numElems, 8); +} + +static addAnyUniqueType(builder:flatbuffers.Builder, anyUniqueType:AnyUniqueAliases) { + builder.addFieldInt8(43, anyUniqueType, AnyUniqueAliases.NONE); +} + +static addAnyUnique(builder:flatbuffers.Builder, anyUniqueOffset:flatbuffers.Offset) { + builder.addFieldOffset(44, anyUniqueOffset, 0); +} + +static addAnyAmbiguousType(builder:flatbuffers.Builder, anyAmbiguousType:AnyAmbiguousAliases) { + builder.addFieldInt8(45, anyAmbiguousType, AnyAmbiguousAliases.NONE); +} + +static addAnyAmbiguous(builder:flatbuffers.Builder, anyAmbiguousOffset:flatbuffers.Offset) { + builder.addFieldOffset(46, anyAmbiguousOffset, 0); +} + +static addVectorOfEnums(builder:flatbuffers.Builder, vectorOfEnumsOffset:flatbuffers.Offset) { + builder.addFieldOffset(47, vectorOfEnumsOffset, 0); +} + +static createVectorOfEnumsVector(builder:flatbuffers.Builder, data:Color[]):flatbuffers.Offset { + builder.startVector(1, data.length, 1); + for (let i = data.length - 1; i >= 0; i--) { + builder.addInt8(data[i]!); + } + return builder.endVector(); +} + +static startVectorOfEnumsVector(builder:flatbuffers.Builder, numElems:number) { + builder.startVector(1, numElems, 1); +} + +static addSignedEnum(builder:flatbuffers.Builder, signedEnum:Race) { + builder.addFieldInt8(48, signedEnum, Race.None); +} + +static addTestrequirednestedflatbuffer(builder:flatbuffers.Builder, testrequirednestedflatbufferOffset:flatbuffers.Offset) { + builder.addFieldOffset(49, testrequirednestedflatbufferOffset, 0); +} + +static createTestrequirednestedflatbufferVector(builder:flatbuffers.Builder, data:number[]|Uint8Array):flatbuffers.Offset { + builder.startVector(1, data.length, 1); + for (let i = data.length - 1; i >= 0; i--) { + builder.addInt8(data[i]!); + } + return builder.endVector(); +} + +static startTestrequirednestedflatbufferVector(builder:flatbuffers.Builder, numElems:number) { + builder.startVector(1, numElems, 1); +} + +static addScalarKeySortedTables(builder:flatbuffers.Builder, scalarKeySortedTablesOffset:flatbuffers.Offset) { + builder.addFieldOffset(50, scalarKeySortedTablesOffset, 0); +} + +static createScalarKeySortedTablesVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addOffset(data[i]!); + } + return builder.endVector(); +} + +static startScalarKeySortedTablesVector(builder:flatbuffers.Builder, numElems:number) { + builder.startVector(4, numElems, 4); +} + +static addNativeInline(builder:flatbuffers.Builder, nativeInlineOffset:flatbuffers.Offset) { + builder.addFieldStruct(51, nativeInlineOffset, 0); +} + +static addLongEnumNonEnumDefault(builder:flatbuffers.Builder, longEnumNonEnumDefault:bigint) { + builder.addFieldInt64(52, longEnumNonEnumDefault, BigInt('0')); +} + +static addLongEnumNormalDefault(builder:flatbuffers.Builder, longEnumNormalDefault:bigint) { + builder.addFieldInt64(53, longEnumNormalDefault, BigInt('2')); +} + +static endMonster(builder:flatbuffers.Builder):flatbuffers.Offset { + const offset = builder.endObject(); + builder.requiredField(offset, 10) // name + return offset; +} + +static finishMonsterBuffer(builder:flatbuffers.Builder, offset:flatbuffers.Offset) { + builder.finish(offset, 'MONS'); +} + +static finishSizePrefixedMonsterBuffer(builder:flatbuffers.Builder, offset:flatbuffers.Offset) { + builder.finish(offset, 'MONS', true); +} + + +serialize():Uint8Array { + return this.bb!.bytes(); +} + +static deserialize(buffer: Uint8Array):Monster { + return Monster.getRootAsMonster(new flatbuffers.ByteBuffer(buffer)) +} + +unpack(): MonsterT { + return new MonsterT( + (this.pos() !== null ? this.pos()!.unpack() : null), + this.mana(), + this.hp(), + this.name(), + this.bb!.createScalarList(this.inventory.bind(this), this.inventoryLength()), + this.color(), + this.testType(), + (() => { + let temp = unionToAny(this.testType(), this.test.bind(this)); + if(temp === null) { return null; } + return temp.unpack() + })(), + this.bb!.createObjList(this.test4.bind(this), this.test4Length()), + this.bb!.createScalarList(this.testarrayofstring.bind(this), this.testarrayofstringLength()), + this.bb!.createObjList(this.testarrayoftables.bind(this), this.testarrayoftablesLength()), + (this.enemy() !== null ? this.enemy()!.unpack() : null), + this.bb!.createScalarList(this.testnestedflatbuffer.bind(this), this.testnestedflatbufferLength()), + (this.testempty() !== null ? this.testempty()!.unpack() : null), + this.testbool(), + this.testhashs32Fnv1(), + this.testhashu32Fnv1(), + this.testhashs64Fnv1(), + this.testhashu64Fnv1(), + this.testhashs32Fnv1a(), + this.testhashu32Fnv1a(), + this.testhashs64Fnv1a(), + this.testhashu64Fnv1a(), + this.bb!.createScalarList(this.testarrayofbools.bind(this), this.testarrayofboolsLength()), + this.testf(), + this.testf2(), + this.testf3(), + this.bb!.createScalarList(this.testarrayofstring2.bind(this), this.testarrayofstring2Length()), + this.bb!.createObjList(this.testarrayofsortedstruct.bind(this), this.testarrayofsortedstructLength()), + this.bb!.createScalarList(this.flex.bind(this), this.flexLength()), + this.bb!.createObjList(this.test5.bind(this), this.test5Length()), + this.bb!.createScalarList(this.vectorOfLongs.bind(this), this.vectorOfLongsLength()), + this.bb!.createScalarList(this.vectorOfDoubles.bind(this), this.vectorOfDoublesLength()), + (this.parentNamespaceTest() !== null ? this.parentNamespaceTest()!.unpack() : null), + this.bb!.createObjList(this.vectorOfReferrables.bind(this), this.vectorOfReferrablesLength()), + this.singleWeakReference(), + this.bb!.createScalarList(this.vectorOfWeakReferences.bind(this), this.vectorOfWeakReferencesLength()), + this.bb!.createObjList(this.vectorOfStrongReferrables.bind(this), this.vectorOfStrongReferrablesLength()), + this.coOwningReference(), + this.bb!.createScalarList(this.vectorOfCoOwningReferences.bind(this), this.vectorOfCoOwningReferencesLength()), + this.nonOwningReference(), + this.bb!.createScalarList(this.vectorOfNonOwningReferences.bind(this), this.vectorOfNonOwningReferencesLength()), + this.anyUniqueType(), + (() => { + let temp = unionToAnyUniqueAliases(this.anyUniqueType(), this.anyUnique.bind(this)); + if(temp === null) { return null; } + return temp.unpack() + })(), + this.anyAmbiguousType(), + (() => { + let temp = unionToAnyAmbiguousAliases(this.anyAmbiguousType(), this.anyAmbiguous.bind(this)); + if(temp === null) { return null; } + return temp.unpack() + })(), + this.bb!.createScalarList(this.vectorOfEnums.bind(this), this.vectorOfEnumsLength()), + this.signedEnum(), + this.bb!.createScalarList(this.testrequirednestedflatbuffer.bind(this), this.testrequirednestedflatbufferLength()), + this.bb!.createObjList(this.scalarKeySortedTables.bind(this), this.scalarKeySortedTablesLength()), + (this.nativeInline() !== null ? this.nativeInline()!.unpack() : null), + this.longEnumNonEnumDefault(), + this.longEnumNormalDefault() + ); +} + + +unpackTo(_o: MonsterT): void { + _o.pos = (this.pos() !== null ? this.pos()!.unpack() : null); + _o.mana = this.mana(); + _o.hp = this.hp(); + _o.name = this.name(); + _o.inventory = this.bb!.createScalarList(this.inventory.bind(this), this.inventoryLength()); + _o.color = this.color(); + _o.testType = this.testType(); + _o.test = (() => { + let temp = unionToAny(this.testType(), this.test.bind(this)); + if(temp === null) { return null; } + return temp.unpack() + })(); + _o.test4 = this.bb!.createObjList(this.test4.bind(this), this.test4Length()); + _o.testarrayofstring = this.bb!.createScalarList(this.testarrayofstring.bind(this), this.testarrayofstringLength()); + _o.testarrayoftables = this.bb!.createObjList(this.testarrayoftables.bind(this), this.testarrayoftablesLength()); + _o.enemy = (this.enemy() !== null ? this.enemy()!.unpack() : null); + _o.testnestedflatbuffer = this.bb!.createScalarList(this.testnestedflatbuffer.bind(this), this.testnestedflatbufferLength()); + _o.testempty = (this.testempty() !== null ? this.testempty()!.unpack() : null); + _o.testbool = this.testbool(); + _o.testhashs32Fnv1 = this.testhashs32Fnv1(); + _o.testhashu32Fnv1 = this.testhashu32Fnv1(); + _o.testhashs64Fnv1 = this.testhashs64Fnv1(); + _o.testhashu64Fnv1 = this.testhashu64Fnv1(); + _o.testhashs32Fnv1a = this.testhashs32Fnv1a(); + _o.testhashu32Fnv1a = this.testhashu32Fnv1a(); + _o.testhashs64Fnv1a = this.testhashs64Fnv1a(); + _o.testhashu64Fnv1a = this.testhashu64Fnv1a(); + _o.testarrayofbools = this.bb!.createScalarList(this.testarrayofbools.bind(this), this.testarrayofboolsLength()); + _o.testf = this.testf(); + _o.testf2 = this.testf2(); + _o.testf3 = this.testf3(); + _o.testarrayofstring2 = this.bb!.createScalarList(this.testarrayofstring2.bind(this), this.testarrayofstring2Length()); + _o.testarrayofsortedstruct = this.bb!.createObjList(this.testarrayofsortedstruct.bind(this), this.testarrayofsortedstructLength()); + _o.flex = this.bb!.createScalarList(this.flex.bind(this), this.flexLength()); + _o.test5 = this.bb!.createObjList(this.test5.bind(this), this.test5Length()); + _o.vectorOfLongs = this.bb!.createScalarList(this.vectorOfLongs.bind(this), this.vectorOfLongsLength()); + _o.vectorOfDoubles = this.bb!.createScalarList(this.vectorOfDoubles.bind(this), this.vectorOfDoublesLength()); + _o.parentNamespaceTest = (this.parentNamespaceTest() !== null ? this.parentNamespaceTest()!.unpack() : null); + _o.vectorOfReferrables = this.bb!.createObjList(this.vectorOfReferrables.bind(this), this.vectorOfReferrablesLength()); + _o.singleWeakReference = this.singleWeakReference(); + _o.vectorOfWeakReferences = this.bb!.createScalarList(this.vectorOfWeakReferences.bind(this), this.vectorOfWeakReferencesLength()); + _o.vectorOfStrongReferrables = this.bb!.createObjList(this.vectorOfStrongReferrables.bind(this), this.vectorOfStrongReferrablesLength()); + _o.coOwningReference = this.coOwningReference(); + _o.vectorOfCoOwningReferences = this.bb!.createScalarList(this.vectorOfCoOwningReferences.bind(this), this.vectorOfCoOwningReferencesLength()); + _o.nonOwningReference = this.nonOwningReference(); + _o.vectorOfNonOwningReferences = this.bb!.createScalarList(this.vectorOfNonOwningReferences.bind(this), this.vectorOfNonOwningReferencesLength()); + _o.anyUniqueType = this.anyUniqueType(); + _o.anyUnique = (() => { + let temp = unionToAnyUniqueAliases(this.anyUniqueType(), this.anyUnique.bind(this)); + if(temp === null) { return null; } + return temp.unpack() + })(); + _o.anyAmbiguousType = this.anyAmbiguousType(); + _o.anyAmbiguous = (() => { + let temp = unionToAnyAmbiguousAliases(this.anyAmbiguousType(), this.anyAmbiguous.bind(this)); + if(temp === null) { return null; } + return temp.unpack() + })(); + _o.vectorOfEnums = this.bb!.createScalarList(this.vectorOfEnums.bind(this), this.vectorOfEnumsLength()); + _o.signedEnum = this.signedEnum(); + _o.testrequirednestedflatbuffer = this.bb!.createScalarList(this.testrequirednestedflatbuffer.bind(this), this.testrequirednestedflatbufferLength()); + _o.scalarKeySortedTables = this.bb!.createObjList(this.scalarKeySortedTables.bind(this), this.scalarKeySortedTablesLength()); + _o.nativeInline = (this.nativeInline() !== null ? this.nativeInline()!.unpack() : null); + _o.longEnumNonEnumDefault = this.longEnumNonEnumDefault(); + _o.longEnumNormalDefault = this.longEnumNormalDefault(); +} +} + +export class MonsterT { +constructor( + public pos: Vec3T|null = null, + public mana: number = 150, + public hp: number = 100, + public name: string|Uint8Array|null = null, + public inventory: (number)[] = [], + public color: Color = Color.Blue, + public testType: Any = Any.NONE, + public test: MonsterT|MyGame_Example2_MonsterT|TestSimpleTableWithEnumT|null = null, + public test4: (TestT)[] = [], + public testarrayofstring: (string)[] = [], + public testarrayoftables: (MonsterT)[] = [], + public enemy: MonsterT|null = null, + public testnestedflatbuffer: (number)[] = [], + public testempty: StatT|null = null, + public testbool: boolean = false, + public testhashs32Fnv1: number = 0, + public testhashu32Fnv1: number = 0, + public testhashs64Fnv1: bigint = BigInt('0'), + public testhashu64Fnv1: bigint = BigInt('0'), + public testhashs32Fnv1a: number = 0, + public testhashu32Fnv1a: number = 0, + public testhashs64Fnv1a: bigint = BigInt('0'), + public testhashu64Fnv1a: bigint = BigInt('0'), + public testarrayofbools: (boolean)[] = [], + public testf: number = 3.14159, + public testf2: number = 3.0, + public testf3: number = 0.0, + public testarrayofstring2: (string)[] = [], + public testarrayofsortedstruct: (AbilityT)[] = [], + public flex: (number)[] = [], + public test5: (TestT)[] = [], + public vectorOfLongs: (bigint)[] = [], + public vectorOfDoubles: (number)[] = [], + public parentNamespaceTest: InParentNamespaceT|null = null, + public vectorOfReferrables: (ReferrableT)[] = [], + public singleWeakReference: bigint = BigInt('0'), + public vectorOfWeakReferences: (bigint)[] = [], + public vectorOfStrongReferrables: (ReferrableT)[] = [], + public coOwningReference: bigint = BigInt('0'), + public vectorOfCoOwningReferences: (bigint)[] = [], + public nonOwningReference: bigint = BigInt('0'), + public vectorOfNonOwningReferences: (bigint)[] = [], + public anyUniqueType: AnyUniqueAliases = AnyUniqueAliases.NONE, + public anyUnique: MonsterT|MyGame_Example2_MonsterT|TestSimpleTableWithEnumT|null = null, + public anyAmbiguousType: AnyAmbiguousAliases = AnyAmbiguousAliases.NONE, + public anyAmbiguous: MonsterT|null = null, + public vectorOfEnums: (Color)[] = [], + public signedEnum: Race = Race.None, + public testrequirednestedflatbuffer: (number)[] = [], + public scalarKeySortedTables: (StatT)[] = [], + public nativeInline: TestT|null = null, + public longEnumNonEnumDefault: bigint = BigInt('0'), + public longEnumNormalDefault: bigint = BigInt('2') +){} + + +pack(builder:flatbuffers.Builder): flatbuffers.Offset { + const name = (this.name !== null ? builder.createString(this.name!) : 0); + const inventory = Monster.createInventoryVector(builder, this.inventory); + const test = builder.createObjectOffset(this.test); + const test4 = builder.createStructOffsetList(this.test4, Monster.startTest4Vector); + const testarrayofstring = Monster.createTestarrayofstringVector(builder, builder.createObjectOffsetList(this.testarrayofstring)); + const testarrayoftables = Monster.createTestarrayoftablesVector(builder, builder.createObjectOffsetList(this.testarrayoftables)); + const enemy = (this.enemy !== null ? this.enemy!.pack(builder) : 0); + const testnestedflatbuffer = Monster.createTestnestedflatbufferVector(builder, this.testnestedflatbuffer); + const testempty = (this.testempty !== null ? this.testempty!.pack(builder) : 0); + const testarrayofbools = Monster.createTestarrayofboolsVector(builder, this.testarrayofbools); + const testarrayofstring2 = Monster.createTestarrayofstring2Vector(builder, builder.createObjectOffsetList(this.testarrayofstring2)); + const testarrayofsortedstruct = builder.createStructOffsetList(this.testarrayofsortedstruct, Monster.startTestarrayofsortedstructVector); + const flex = Monster.createFlexVector(builder, this.flex); + const test5 = builder.createStructOffsetList(this.test5, Monster.startTest5Vector); + const vectorOfLongs = Monster.createVectorOfLongsVector(builder, this.vectorOfLongs); + const vectorOfDoubles = Monster.createVectorOfDoublesVector(builder, this.vectorOfDoubles); + const parentNamespaceTest = (this.parentNamespaceTest !== null ? this.parentNamespaceTest!.pack(builder) : 0); + const vectorOfReferrables = Monster.createVectorOfReferrablesVector(builder, builder.createObjectOffsetList(this.vectorOfReferrables)); + const vectorOfWeakReferences = Monster.createVectorOfWeakReferencesVector(builder, this.vectorOfWeakReferences); + const vectorOfStrongReferrables = Monster.createVectorOfStrongReferrablesVector(builder, builder.createObjectOffsetList(this.vectorOfStrongReferrables)); + const vectorOfCoOwningReferences = Monster.createVectorOfCoOwningReferencesVector(builder, this.vectorOfCoOwningReferences); + const vectorOfNonOwningReferences = Monster.createVectorOfNonOwningReferencesVector(builder, this.vectorOfNonOwningReferences); + const anyUnique = builder.createObjectOffset(this.anyUnique); + const anyAmbiguous = builder.createObjectOffset(this.anyAmbiguous); + const vectorOfEnums = Monster.createVectorOfEnumsVector(builder, this.vectorOfEnums); + const testrequirednestedflatbuffer = Monster.createTestrequirednestedflatbufferVector(builder, this.testrequirednestedflatbuffer); + const scalarKeySortedTables = Monster.createScalarKeySortedTablesVector(builder, builder.createObjectOffsetList(this.scalarKeySortedTables)); + + Monster.startMonster(builder); + Monster.addPos(builder, (this.pos !== null ? this.pos!.pack(builder) : 0)); + Monster.addMana(builder, this.mana); + Monster.addHp(builder, this.hp); + Monster.addName(builder, name); + Monster.addInventory(builder, inventory); + Monster.addColor(builder, this.color); + Monster.addTestType(builder, this.testType); + Monster.addTest(builder, test); + Monster.addTest4(builder, test4); + Monster.addTestarrayofstring(builder, testarrayofstring); + Monster.addTestarrayoftables(builder, testarrayoftables); + Monster.addEnemy(builder, enemy); + Monster.addTestnestedflatbuffer(builder, testnestedflatbuffer); + Monster.addTestempty(builder, testempty); + Monster.addTestbool(builder, this.testbool); + Monster.addTesthashs32Fnv1(builder, this.testhashs32Fnv1); + Monster.addTesthashu32Fnv1(builder, this.testhashu32Fnv1); + Monster.addTesthashs64Fnv1(builder, this.testhashs64Fnv1); + Monster.addTesthashu64Fnv1(builder, this.testhashu64Fnv1); + Monster.addTesthashs32Fnv1a(builder, this.testhashs32Fnv1a); + Monster.addTesthashu32Fnv1a(builder, this.testhashu32Fnv1a); + Monster.addTesthashs64Fnv1a(builder, this.testhashs64Fnv1a); + Monster.addTesthashu64Fnv1a(builder, this.testhashu64Fnv1a); + Monster.addTestarrayofbools(builder, testarrayofbools); + Monster.addTestf(builder, this.testf); + Monster.addTestf2(builder, this.testf2); + Monster.addTestf3(builder, this.testf3); + Monster.addTestarrayofstring2(builder, testarrayofstring2); + Monster.addTestarrayofsortedstruct(builder, testarrayofsortedstruct); + Monster.addFlex(builder, flex); + Monster.addTest5(builder, test5); + Monster.addVectorOfLongs(builder, vectorOfLongs); + Monster.addVectorOfDoubles(builder, vectorOfDoubles); + Monster.addParentNamespaceTest(builder, parentNamespaceTest); + Monster.addVectorOfReferrables(builder, vectorOfReferrables); + Monster.addSingleWeakReference(builder, this.singleWeakReference); + Monster.addVectorOfWeakReferences(builder, vectorOfWeakReferences); + Monster.addVectorOfStrongReferrables(builder, vectorOfStrongReferrables); + Monster.addCoOwningReference(builder, this.coOwningReference); + Monster.addVectorOfCoOwningReferences(builder, vectorOfCoOwningReferences); + Monster.addNonOwningReference(builder, this.nonOwningReference); + Monster.addVectorOfNonOwningReferences(builder, vectorOfNonOwningReferences); + Monster.addAnyUniqueType(builder, this.anyUniqueType); + Monster.addAnyUnique(builder, anyUnique); + Monster.addAnyAmbiguousType(builder, this.anyAmbiguousType); + Monster.addAnyAmbiguous(builder, anyAmbiguous); + Monster.addVectorOfEnums(builder, vectorOfEnums); + Monster.addSignedEnum(builder, this.signedEnum); + Monster.addTestrequirednestedflatbuffer(builder, testrequirednestedflatbuffer); + Monster.addScalarKeySortedTables(builder, scalarKeySortedTables); + Monster.addNativeInline(builder, (this.nativeInline !== null ? this.nativeInline!.pack(builder) : 0)); + Monster.addLongEnumNonEnumDefault(builder, this.longEnumNonEnumDefault); + Monster.addLongEnumNormalDefault(builder, this.longEnumNormalDefault); + + return Monster.endMonster(builder); +} +} diff --git a/tests/ts/my-game/example/race.js b/tests/ts/my-game/example/race.js new file mode 100644 index 00000000000..74f51057abc --- /dev/null +++ b/tests/ts/my-game/example/race.js @@ -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 = {})); diff --git a/tests/ts/my-game/example/race.ts b/tests/ts/my-game/example/race.ts new file mode 100644 index 00000000000..8cb9654ae30 --- /dev/null +++ b/tests/ts/my-game/example/race.ts @@ -0,0 +1,8 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +export enum Race { + None = -1, + Human = 0, + Dwarf = 1, + Elf = 2 +} diff --git a/tests/ts/my-game/example/referrable.js b/tests/ts/my-game/example/referrable.js new file mode 100644 index 00000000000..367034b0644 --- /dev/null +++ b/tests/ts/my-game/example/referrable.js @@ -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) : BigInt('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, BigInt('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 = BigInt('0')) { + this.id = id; + } + pack(builder) { + return Referrable.createReferrable(builder, this.id); + } +} diff --git a/tests/ts/my-game/example/referrable.ts b/tests/ts/my-game/example/referrable.ts new file mode 100644 index 00000000000..ec02980037f --- /dev/null +++ b/tests/ts/my-game/example/referrable.ts @@ -0,0 +1,95 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +import * as flatbuffers from 'flatbuffers'; + + + +export class Referrable { + bb: flatbuffers.ByteBuffer|null = null; + bb_pos = 0; + __init(i:number, bb:flatbuffers.ByteBuffer):Referrable { + this.bb_pos = i; + this.bb = bb; + return this; +} + +static getRootAsReferrable(bb:flatbuffers.ByteBuffer, obj?:Referrable):Referrable { + return (obj || new Referrable()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +static getSizePrefixedRootAsReferrable(bb:flatbuffers.ByteBuffer, obj?:Referrable):Referrable { + bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); + return (obj || new Referrable()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +id():bigint { + const offset = this.bb!.__offset(this.bb_pos, 4); + return offset ? this.bb!.readUint64(this.bb_pos + offset) : BigInt('0'); +} + +mutate_id(value:bigint):boolean { + 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():string { + return 'MyGame_Example_Referrable'; +} + +static startReferrable(builder:flatbuffers.Builder) { + builder.startObject(1); +} + +static addId(builder:flatbuffers.Builder, id:bigint) { + builder.addFieldInt64(0, id, BigInt('0')); +} + +static endReferrable(builder:flatbuffers.Builder):flatbuffers.Offset { + const offset = builder.endObject(); + return offset; +} + +static createReferrable(builder:flatbuffers.Builder, id:bigint):flatbuffers.Offset { + Referrable.startReferrable(builder); + Referrable.addId(builder, id); + return Referrable.endReferrable(builder); +} + +serialize():Uint8Array { + return this.bb!.bytes(); +} + +static deserialize(buffer: Uint8Array):Referrable { + return Referrable.getRootAsReferrable(new flatbuffers.ByteBuffer(buffer)) +} + +unpack(): ReferrableT { + return new ReferrableT( + this.id() + ); +} + + +unpackTo(_o: ReferrableT): void { + _o.id = this.id(); +} +} + +export class ReferrableT { +constructor( + public id: bigint = BigInt('0') +){} + + +pack(builder:flatbuffers.Builder): flatbuffers.Offset { + return Referrable.createReferrable(builder, + this.id + ); +} +} diff --git a/tests/ts/my-game/example/stat.js b/tests/ts/my-game/example/stat.js new file mode 100644 index 00000000000..43b569f4e36 --- /dev/null +++ b/tests/ts/my-game/example/stat.js @@ -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) : BigInt('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, BigInt('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 = BigInt('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); + } +} diff --git a/tests/ts/my-game/example/stat.ts b/tests/ts/my-game/example/stat.ts new file mode 100644 index 00000000000..e45259950aa --- /dev/null +++ b/tests/ts/my-game/example/stat.ts @@ -0,0 +1,138 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +import * as flatbuffers from 'flatbuffers'; + + + +export class Stat { + bb: flatbuffers.ByteBuffer|null = null; + bb_pos = 0; + __init(i:number, bb:flatbuffers.ByteBuffer):Stat { + this.bb_pos = i; + this.bb = bb; + return this; +} + +static getRootAsStat(bb:flatbuffers.ByteBuffer, obj?:Stat):Stat { + return (obj || new Stat()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +static getSizePrefixedRootAsStat(bb:flatbuffers.ByteBuffer, obj?:Stat):Stat { + bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); + return (obj || new Stat()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +id():string|null +id(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null +id(optionalEncoding?:any):string|Uint8Array|null { + const offset = this.bb!.__offset(this.bb_pos, 4); + return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; +} + +val():bigint { + const offset = this.bb!.__offset(this.bb_pos, 6); + return offset ? this.bb!.readInt64(this.bb_pos + offset) : BigInt('0'); +} + +mutate_val(value:bigint):boolean { + 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():number { + const offset = this.bb!.__offset(this.bb_pos, 8); + return offset ? this.bb!.readUint16(this.bb_pos + offset) : 0; +} + +mutate_count(value:number):boolean { + 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():string { + return 'MyGame_Example_Stat'; +} + +static startStat(builder:flatbuffers.Builder) { + builder.startObject(3); +} + +static addId(builder:flatbuffers.Builder, idOffset:flatbuffers.Offset) { + builder.addFieldOffset(0, idOffset, 0); +} + +static addVal(builder:flatbuffers.Builder, val:bigint) { + builder.addFieldInt64(1, val, BigInt('0')); +} + +static addCount(builder:flatbuffers.Builder, count:number) { + builder.addFieldInt16(2, count, 0); +} + +static endStat(builder:flatbuffers.Builder):flatbuffers.Offset { + const offset = builder.endObject(); + return offset; +} + +static createStat(builder:flatbuffers.Builder, idOffset:flatbuffers.Offset, val:bigint, count:number):flatbuffers.Offset { + Stat.startStat(builder); + Stat.addId(builder, idOffset); + Stat.addVal(builder, val); + Stat.addCount(builder, count); + return Stat.endStat(builder); +} + +serialize():Uint8Array { + return this.bb!.bytes(); +} + +static deserialize(buffer: Uint8Array):Stat { + return Stat.getRootAsStat(new flatbuffers.ByteBuffer(buffer)) +} + +unpack(): StatT { + return new StatT( + this.id(), + this.val(), + this.count() + ); +} + + +unpackTo(_o: StatT): void { + _o.id = this.id(); + _o.val = this.val(); + _o.count = this.count(); +} +} + +export class StatT { +constructor( + public id: string|Uint8Array|null = null, + public val: bigint = BigInt('0'), + public count: number = 0 +){} + + +pack(builder:flatbuffers.Builder): flatbuffers.Offset { + const id = (this.id !== null ? builder.createString(this.id!) : 0); + + return Stat.createStat(builder, + id, + this.val, + this.count + ); +} +} diff --git a/tests/ts/my-game/example/struct-of-structs-of-structs.js b/tests/ts/my-game/example/struct-of-structs-of-structs.js new file mode 100644 index 00000000000..a5fbc66dce6 --- /dev/null +++ b/tests/ts/my-game/example/struct-of-structs-of-structs.js @@ -0,0 +1,52 @@ +// automatically generated by the FlatBuffers compiler, do not modify +import { StructOfStructs } from '../../my-game/example/struct-of-structs.js'; +export class StructOfStructsOfStructs { + 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 StructOfStructs()).__init(this.bb_pos, this.bb); + } + static getFullyQualifiedName() { + return 'MyGame_Example_StructOfStructsOfStructs'; + } + static sizeOf() { + return 20; + } + static createStructOfStructsOfStructs(builder, a_a_id, a_a_distance, a_b_a, a_b_b, a_c_id, a_c_distance) { + builder.prep(4, 20); + builder.prep(4, 20); + builder.prep(4, 8); + builder.writeInt32(a_c_distance); + builder.writeInt32(a_c_id); + builder.prep(2, 4); + builder.pad(1); + builder.writeInt8(a_b_b); + builder.writeInt16(a_b_a); + builder.prep(4, 8); + builder.writeInt32(a_a_distance); + builder.writeInt32(a_a_id); + return builder.offset(); + } + unpack() { + return new StructOfStructsOfStructsT((this.a() !== null ? this.a().unpack() : null)); + } + unpackTo(_o) { + _o.a = (this.a() !== null ? this.a().unpack() : null); + } +} +export class StructOfStructsOfStructsT { + constructor(a = null) { + this.a = a; + } + pack(builder) { + var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _p, _q, _r, _s, _t, _u; + return StructOfStructsOfStructs.createStructOfStructsOfStructs(builder, ((_c = (_b = (_a = this.a) === null || _a === void 0 ? void 0 : _a.a) === null || _b === void 0 ? void 0 : _b.id) !== null && _c !== void 0 ? _c : 0), ((_f = (_e = (_d = this.a) === null || _d === void 0 ? void 0 : _d.a) === null || _e === void 0 ? void 0 : _e.distance) !== null && _f !== void 0 ? _f : 0), ((_j = (_h = (_g = this.a) === null || _g === void 0 ? void 0 : _g.b) === null || _h === void 0 ? void 0 : _h.a) !== null && _j !== void 0 ? _j : 0), ((_m = (_l = (_k = this.a) === null || _k === void 0 ? void 0 : _k.b) === null || _l === void 0 ? void 0 : _l.b) !== null && _m !== void 0 ? _m : 0), ((_r = (_q = (_p = this.a) === null || _p === void 0 ? void 0 : _p.c) === null || _q === void 0 ? void 0 : _q.id) !== null && _r !== void 0 ? _r : 0), ((_u = (_t = (_s = this.a) === null || _s === void 0 ? void 0 : _s.c) === null || _t === void 0 ? void 0 : _t.distance) !== null && _u !== void 0 ? _u : 0)); + } +} diff --git a/tests/ts/my-game/example/struct-of-structs-of-structs.ts b/tests/ts/my-game/example/struct-of-structs-of-structs.ts new file mode 100644 index 00000000000..52efc120540 --- /dev/null +++ b/tests/ts/my-game/example/struct-of-structs-of-structs.ts @@ -0,0 +1,74 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +import * as flatbuffers from 'flatbuffers'; + +import { StructOfStructs, StructOfStructsT } from '../../my-game/example/struct-of-structs.js'; + + +export class StructOfStructsOfStructs { + bb: flatbuffers.ByteBuffer|null = null; + bb_pos = 0; + __init(i:number, bb:flatbuffers.ByteBuffer):StructOfStructsOfStructs { + this.bb_pos = i; + this.bb = bb; + return this; +} + +a(obj?:StructOfStructs):StructOfStructs|null { + return (obj || new StructOfStructs()).__init(this.bb_pos, this.bb!); +} + +static getFullyQualifiedName():string { + return 'MyGame_Example_StructOfStructsOfStructs'; +} + +static sizeOf():number { + return 20; +} + +static createStructOfStructsOfStructs(builder:flatbuffers.Builder, a_a_id: number, a_a_distance: number, a_b_a: number, a_b_b: number, a_c_id: number, a_c_distance: number):flatbuffers.Offset { + builder.prep(4, 20); + builder.prep(4, 20); + builder.prep(4, 8); + builder.writeInt32(a_c_distance); + builder.writeInt32(a_c_id); + builder.prep(2, 4); + builder.pad(1); + builder.writeInt8(a_b_b); + builder.writeInt16(a_b_a); + builder.prep(4, 8); + builder.writeInt32(a_a_distance); + builder.writeInt32(a_a_id); + return builder.offset(); +} + + +unpack(): StructOfStructsOfStructsT { + return new StructOfStructsOfStructsT( + (this.a() !== null ? this.a()!.unpack() : null) + ); +} + + +unpackTo(_o: StructOfStructsOfStructsT): void { + _o.a = (this.a() !== null ? this.a()!.unpack() : null); +} +} + +export class StructOfStructsOfStructsT { +constructor( + public a: StructOfStructsT|null = null +){} + + +pack(builder:flatbuffers.Builder): flatbuffers.Offset { + return StructOfStructsOfStructs.createStructOfStructsOfStructs(builder, + (this.a?.a?.id ?? 0), + (this.a?.a?.distance ?? 0), + (this.a?.b?.a ?? 0), + (this.a?.b?.b ?? 0), + (this.a?.c?.id ?? 0), + (this.a?.c?.distance ?? 0) + ); +} +} diff --git a/tests/ts/my-game/example/struct-of-structs.js b/tests/ts/my-game/example/struct-of-structs.js new file mode 100644 index 00000000000..66aadc8e543 --- /dev/null +++ b/tests/ts/my-game/example/struct-of-structs.js @@ -0,0 +1,62 @@ +// automatically generated by the FlatBuffers compiler, do not modify +import { Ability } from '../../my-game/example/ability.js'; +import { Test } from '../../my-game/example/test.js'; +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) { + var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m; + return StructOfStructs.createStructOfStructs(builder, ((_b = (_a = this.a) === null || _a === void 0 ? void 0 : _a.id) !== null && _b !== void 0 ? _b : 0), ((_d = (_c = this.a) === null || _c === void 0 ? void 0 : _c.distance) !== null && _d !== void 0 ? _d : 0), ((_f = (_e = this.b) === null || _e === void 0 ? void 0 : _e.a) !== null && _f !== void 0 ? _f : 0), ((_h = (_g = this.b) === null || _g === void 0 ? void 0 : _g.b) !== null && _h !== void 0 ? _h : 0), ((_k = (_j = this.c) === null || _j === void 0 ? void 0 : _j.id) !== null && _k !== void 0 ? _k : 0), ((_m = (_l = this.c) === null || _l === void 0 ? void 0 : _l.distance) !== null && _m !== void 0 ? _m : 0)); + } +} diff --git a/tests/ts/my-game/example/struct-of-structs.ts b/tests/ts/my-game/example/struct-of-structs.ts new file mode 100644 index 00000000000..749a73cb1d9 --- /dev/null +++ b/tests/ts/my-game/example/struct-of-structs.ts @@ -0,0 +1,88 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +import * as flatbuffers from 'flatbuffers'; + +import { Ability, AbilityT } from '../../my-game/example/ability.js'; +import { Test, TestT } from '../../my-game/example/test.js'; + + +export class StructOfStructs { + bb: flatbuffers.ByteBuffer|null = null; + bb_pos = 0; + __init(i:number, bb:flatbuffers.ByteBuffer):StructOfStructs { + this.bb_pos = i; + this.bb = bb; + return this; +} + +a(obj?:Ability):Ability|null { + return (obj || new Ability()).__init(this.bb_pos, this.bb!); +} + +b(obj?:Test):Test|null { + return (obj || new Test()).__init(this.bb_pos + 8, this.bb!); +} + +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; +} + +static createStructOfStructs(builder:flatbuffers.Builder, a_id: number, a_distance: number, b_a: number, b_b: number, c_id: number, c_distance: number):flatbuffers.Offset { + 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(): StructOfStructsT { + 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: StructOfStructsT): void { + _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( + public a: AbilityT|null = null, + public b: TestT|null = null, + public c: AbilityT|null = null +){} + + +pack(builder:flatbuffers.Builder): flatbuffers.Offset { + return StructOfStructs.createStructOfStructs(builder, + (this.a?.id ?? 0), + (this.a?.distance ?? 0), + (this.b?.a ?? 0), + (this.b?.b ?? 0), + (this.c?.id ?? 0), + (this.c?.distance ?? 0) + ); +} +} diff --git a/tests/ts/my-game/example/test-simple-table-with-enum.js b/tests/ts/my-game/example/test-simple-table-with-enum.js new file mode 100644 index 00000000000..3690feeb76c --- /dev/null +++ b/tests/ts/my-game/example/test-simple-table-with-enum.js @@ -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.js'; +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); + } +} diff --git a/tests/ts/my-game/example/test-simple-table-with-enum.ts b/tests/ts/my-game/example/test-simple-table-with-enum.ts new file mode 100644 index 00000000000..cfca00b4a13 --- /dev/null +++ b/tests/ts/my-game/example/test-simple-table-with-enum.ts @@ -0,0 +1,96 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +import * as flatbuffers from 'flatbuffers'; + +import { Color } from '../../my-game/example/color.js'; + + +export class TestSimpleTableWithEnum { + bb: flatbuffers.ByteBuffer|null = null; + bb_pos = 0; + __init(i:number, bb:flatbuffers.ByteBuffer):TestSimpleTableWithEnum { + this.bb_pos = i; + this.bb = bb; + return this; +} + +static getRootAsTestSimpleTableWithEnum(bb:flatbuffers.ByteBuffer, obj?:TestSimpleTableWithEnum):TestSimpleTableWithEnum { + return (obj || new TestSimpleTableWithEnum()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +static getSizePrefixedRootAsTestSimpleTableWithEnum(bb:flatbuffers.ByteBuffer, obj?:TestSimpleTableWithEnum):TestSimpleTableWithEnum { + bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); + return (obj || new TestSimpleTableWithEnum()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +color():Color { + const offset = this.bb!.__offset(this.bb_pos, 4); + return offset ? this.bb!.readUint8(this.bb_pos + offset) : Color.Green; +} + +mutate_color(value:Color):boolean { + 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():string { + return 'MyGame_Example_TestSimpleTableWithEnum'; +} + +static startTestSimpleTableWithEnum(builder:flatbuffers.Builder) { + builder.startObject(1); +} + +static addColor(builder:flatbuffers.Builder, color:Color) { + builder.addFieldInt8(0, color, Color.Green); +} + +static endTestSimpleTableWithEnum(builder:flatbuffers.Builder):flatbuffers.Offset { + const offset = builder.endObject(); + return offset; +} + +static createTestSimpleTableWithEnum(builder:flatbuffers.Builder, color:Color):flatbuffers.Offset { + TestSimpleTableWithEnum.startTestSimpleTableWithEnum(builder); + TestSimpleTableWithEnum.addColor(builder, color); + return TestSimpleTableWithEnum.endTestSimpleTableWithEnum(builder); +} + +serialize():Uint8Array { + return this.bb!.bytes(); +} + +static deserialize(buffer: Uint8Array):TestSimpleTableWithEnum { + return TestSimpleTableWithEnum.getRootAsTestSimpleTableWithEnum(new flatbuffers.ByteBuffer(buffer)) +} + +unpack(): TestSimpleTableWithEnumT { + return new TestSimpleTableWithEnumT( + this.color() + ); +} + + +unpackTo(_o: TestSimpleTableWithEnumT): void { + _o.color = this.color(); +} +} + +export class TestSimpleTableWithEnumT { +constructor( + public color: Color = Color.Green +){} + + +pack(builder:flatbuffers.Builder): flatbuffers.Offset { + return TestSimpleTableWithEnum.createTestSimpleTableWithEnum(builder, + this.color + ); +} +} diff --git a/tests/ts/my-game/example/test.js b/tests/ts/my-game/example/test.js new file mode 100644 index 00000000000..9c43619e210 --- /dev/null +++ b/tests/ts/my-game/example/test.js @@ -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); + } +} diff --git a/tests/ts/my-game/example/test.ts b/tests/ts/my-game/example/test.ts new file mode 100644 index 00000000000..b3d84eece95 --- /dev/null +++ b/tests/ts/my-game/example/test.ts @@ -0,0 +1,78 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +import * as flatbuffers from 'flatbuffers'; + + + +export class Test { + bb: flatbuffers.ByteBuffer|null = null; + bb_pos = 0; + __init(i:number, bb:flatbuffers.ByteBuffer):Test { + this.bb_pos = i; + this.bb = bb; + return this; +} + +a():number { + return this.bb!.readInt16(this.bb_pos); +} + +mutate_a(value:number):boolean { + this.bb!.writeInt16(this.bb_pos + 0, value); + return true; +} + +b():number { + return this.bb!.readInt8(this.bb_pos + 2); +} + +mutate_b(value:number):boolean { + this.bb!.writeInt8(this.bb_pos + 2, value); + return true; +} + +static getFullyQualifiedName():string { + return 'MyGame_Example_Test'; +} + +static sizeOf():number { + return 4; +} + +static createTest(builder:flatbuffers.Builder, a: number, b: number):flatbuffers.Offset { + builder.prep(2, 4); + builder.pad(1); + builder.writeInt8(b); + builder.writeInt16(a); + return builder.offset(); +} + + +unpack(): TestT { + return new TestT( + this.a(), + this.b() + ); +} + + +unpackTo(_o: TestT): void { + _o.a = this.a(); + _o.b = this.b(); +} +} + +export class TestT { +constructor( + public a: number = 0, + public b: number = 0 +){} + + +pack(builder:flatbuffers.Builder): flatbuffers.Offset { + return Test.createTest(builder, + this.a, + this.b + ); +} +} diff --git a/tests/ts/my-game/example/type-aliases.js b/tests/ts/my-game/example/type-aliases.js new file mode 100644 index 00000000000..a4b5f89e3f5 --- /dev/null +++ b/tests/ts/my-game/example/type-aliases.js @@ -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) : BigInt('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) : BigInt('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, BigInt('0')); + } + static addU64(builder, u64) { + builder.addFieldInt64(7, u64, BigInt('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 = BigInt('0'), u64 = BigInt('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); + } +} diff --git a/tests/ts/my-game/example/type-aliases.ts b/tests/ts/my-game/example/type-aliases.ts new file mode 100644 index 00000000000..805c8cf3fcc --- /dev/null +++ b/tests/ts/my-game/example/type-aliases.ts @@ -0,0 +1,405 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +import * as flatbuffers from 'flatbuffers'; + + + +export class TypeAliases { + bb: flatbuffers.ByteBuffer|null = null; + bb_pos = 0; + __init(i:number, bb:flatbuffers.ByteBuffer):TypeAliases { + this.bb_pos = i; + this.bb = bb; + return this; +} + +static getRootAsTypeAliases(bb:flatbuffers.ByteBuffer, obj?:TypeAliases):TypeAliases { + return (obj || new TypeAliases()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +static getSizePrefixedRootAsTypeAliases(bb:flatbuffers.ByteBuffer, obj?:TypeAliases):TypeAliases { + bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); + return (obj || new TypeAliases()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +i8():number { + const offset = this.bb!.__offset(this.bb_pos, 4); + return offset ? this.bb!.readInt8(this.bb_pos + offset) : 0; +} + +mutate_i8(value:number):boolean { + 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():number { + const offset = this.bb!.__offset(this.bb_pos, 6); + return offset ? this.bb!.readUint8(this.bb_pos + offset) : 0; +} + +mutate_u8(value:number):boolean { + 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():number { + const offset = this.bb!.__offset(this.bb_pos, 8); + return offset ? this.bb!.readInt16(this.bb_pos + offset) : 0; +} + +mutate_i16(value:number):boolean { + 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():number { + const offset = this.bb!.__offset(this.bb_pos, 10); + return offset ? this.bb!.readUint16(this.bb_pos + offset) : 0; +} + +mutate_u16(value:number):boolean { + 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():number { + const offset = this.bb!.__offset(this.bb_pos, 12); + return offset ? this.bb!.readInt32(this.bb_pos + offset) : 0; +} + +mutate_i32(value:number):boolean { + 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():number { + const offset = this.bb!.__offset(this.bb_pos, 14); + return offset ? this.bb!.readUint32(this.bb_pos + offset) : 0; +} + +mutate_u32(value:number):boolean { + 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():bigint { + const offset = this.bb!.__offset(this.bb_pos, 16); + return offset ? this.bb!.readInt64(this.bb_pos + offset) : BigInt('0'); +} + +mutate_i64(value:bigint):boolean { + 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():bigint { + const offset = this.bb!.__offset(this.bb_pos, 18); + return offset ? this.bb!.readUint64(this.bb_pos + offset) : BigInt('0'); +} + +mutate_u64(value:bigint):boolean { + 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():number { + const offset = this.bb!.__offset(this.bb_pos, 20); + return offset ? this.bb!.readFloat32(this.bb_pos + offset) : 0.0; +} + +mutate_f32(value:number):boolean { + 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():number { + const offset = this.bb!.__offset(this.bb_pos, 22); + return offset ? this.bb!.readFloat64(this.bb_pos + offset) : 0.0; +} + +mutate_f64(value:number):boolean { + 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: number):number|null { + const offset = this.bb!.__offset(this.bb_pos, 24); + return offset ? this.bb!.readInt8(this.bb!.__vector(this.bb_pos + offset) + index) : 0; +} + +v8Length():number { + const offset = this.bb!.__offset(this.bb_pos, 24); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +} + +v8Array():Int8Array|null { + 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: number):number|null { + 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():number { + const offset = this.bb!.__offset(this.bb_pos, 26); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +} + +vf64Array():Float64Array|null { + 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():string { + return 'MyGame_Example_TypeAliases'; +} + +static startTypeAliases(builder:flatbuffers.Builder) { + builder.startObject(12); +} + +static addI8(builder:flatbuffers.Builder, i8:number) { + builder.addFieldInt8(0, i8, 0); +} + +static addU8(builder:flatbuffers.Builder, u8:number) { + builder.addFieldInt8(1, u8, 0); +} + +static addI16(builder:flatbuffers.Builder, i16:number) { + builder.addFieldInt16(2, i16, 0); +} + +static addU16(builder:flatbuffers.Builder, u16:number) { + builder.addFieldInt16(3, u16, 0); +} + +static addI32(builder:flatbuffers.Builder, i32:number) { + builder.addFieldInt32(4, i32, 0); +} + +static addU32(builder:flatbuffers.Builder, u32:number) { + builder.addFieldInt32(5, u32, 0); +} + +static addI64(builder:flatbuffers.Builder, i64:bigint) { + builder.addFieldInt64(6, i64, BigInt('0')); +} + +static addU64(builder:flatbuffers.Builder, u64:bigint) { + builder.addFieldInt64(7, u64, BigInt('0')); +} + +static addF32(builder:flatbuffers.Builder, f32:number) { + builder.addFieldFloat32(8, f32, 0.0); +} + +static addF64(builder:flatbuffers.Builder, f64:number) { + builder.addFieldFloat64(9, f64, 0.0); +} + +static addV8(builder:flatbuffers.Builder, v8Offset:flatbuffers.Offset) { + builder.addFieldOffset(10, v8Offset, 0); +} + +static createV8Vector(builder:flatbuffers.Builder, data:number[]|Int8Array):flatbuffers.Offset; +/** + * @deprecated This Uint8Array overload will be removed in the future. + */ +static createV8Vector(builder:flatbuffers.Builder, data:number[]|Uint8Array):flatbuffers.Offset; +static createV8Vector(builder:flatbuffers.Builder, data:number[]|Int8Array|Uint8Array):flatbuffers.Offset { + 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:flatbuffers.Builder, numElems:number) { + builder.startVector(1, numElems, 1); +} + +static addVf64(builder:flatbuffers.Builder, vf64Offset:flatbuffers.Offset) { + builder.addFieldOffset(11, vf64Offset, 0); +} + +static createVf64Vector(builder:flatbuffers.Builder, data:number[]|Float64Array):flatbuffers.Offset; +/** + * @deprecated This Uint8Array overload will be removed in the future. + */ +static createVf64Vector(builder:flatbuffers.Builder, data:number[]|Uint8Array):flatbuffers.Offset; +static createVf64Vector(builder:flatbuffers.Builder, data:number[]|Float64Array|Uint8Array):flatbuffers.Offset { + 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:flatbuffers.Builder, numElems:number) { + builder.startVector(8, numElems, 8); +} + +static endTypeAliases(builder:flatbuffers.Builder):flatbuffers.Offset { + const offset = builder.endObject(); + return 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.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():Uint8Array { + return this.bb!.bytes(); +} + +static deserialize(buffer: Uint8Array):TypeAliases { + return TypeAliases.getRootAsTypeAliases(new flatbuffers.ByteBuffer(buffer)) +} + +unpack(): TypeAliasesT { + 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: TypeAliasesT): void { + _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( + public i8: number = 0, + public u8: number = 0, + public i16: number = 0, + public u16: number = 0, + public i32: number = 0, + public u32: number = 0, + public i64: bigint = BigInt('0'), + public u64: bigint = BigInt('0'), + public f32: number = 0.0, + public f64: number = 0.0, + public v8: (number)[] = [], + public vf64: (number)[] = [] +){} + + +pack(builder:flatbuffers.Builder): flatbuffers.Offset { + 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 + ); +} +} diff --git a/tests/ts/my-game/example/vec3.js b/tests/ts/my-game/example/vec3.js new file mode 100644 index 00000000000..cae64eb5557 --- /dev/null +++ b/tests/ts/my-game/example/vec3.js @@ -0,0 +1,98 @@ +// automatically generated by the FlatBuffers compiler, do not modify +import { Test } from '../../my-game/example/test.js'; +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) { + var _a, _b, _c, _d; + return Vec3.createVec3(builder, this.x, this.y, this.z, this.test1, this.test2, ((_b = (_a = this.test3) === null || _a === void 0 ? void 0 : _a.a) !== null && _b !== void 0 ? _b : 0), ((_d = (_c = this.test3) === null || _c === void 0 ? void 0 : _c.b) !== null && _d !== void 0 ? _d : 0)); + } +} diff --git a/tests/ts/my-game/example/vec3.ts b/tests/ts/my-game/example/vec3.ts new file mode 100644 index 00000000000..bc4c473320a --- /dev/null +++ b/tests/ts/my-game/example/vec3.ts @@ -0,0 +1,137 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +import * as flatbuffers from 'flatbuffers'; + +import { Color } from '../../my-game/example/color.js'; +import { Test, TestT } from '../../my-game/example/test.js'; + + +export class Vec3 { + bb: flatbuffers.ByteBuffer|null = null; + bb_pos = 0; + __init(i:number, bb:flatbuffers.ByteBuffer):Vec3 { + this.bb_pos = i; + this.bb = bb; + return this; +} + +x():number { + return this.bb!.readFloat32(this.bb_pos); +} + +mutate_x(value:number):boolean { + this.bb!.writeFloat32(this.bb_pos + 0, value); + return true; +} + +y():number { + return this.bb!.readFloat32(this.bb_pos + 4); +} + +mutate_y(value:number):boolean { + this.bb!.writeFloat32(this.bb_pos + 4, value); + return true; +} + +z():number { + return this.bb!.readFloat32(this.bb_pos + 8); +} + +mutate_z(value:number):boolean { + this.bb!.writeFloat32(this.bb_pos + 8, value); + return true; +} + +test1():number { + return this.bb!.readFloat64(this.bb_pos + 16); +} + +mutate_test1(value:number):boolean { + this.bb!.writeFloat64(this.bb_pos + 16, value); + return true; +} + +test2():Color { + return this.bb!.readUint8(this.bb_pos + 24); +} + +mutate_test2(value:Color):boolean { + this.bb!.writeUint8(this.bb_pos + 24, value); + return true; +} + +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; +} + +static createVec3(builder:flatbuffers.Builder, x: number, y: number, z: number, test1: number, test2: Color, test3_a: number, test3_b: number):flatbuffers.Offset { + 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(): Vec3T { + return new Vec3T( + this.x(), + this.y(), + this.z(), + this.test1(), + this.test2(), + (this.test3() !== null ? this.test3()!.unpack() : null) + ); +} + + +unpackTo(_o: Vec3T): void { + _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( + public x: number = 0.0, + public y: number = 0.0, + public z: number = 0.0, + public test1: number = 0.0, + public test2: Color = 0, + public test3: TestT|null = null +){} + + +pack(builder:flatbuffers.Builder): flatbuffers.Offset { + return Vec3.createVec3(builder, + this.x, + this.y, + this.z, + this.test1, + this.test2, + (this.test3?.a ?? 0), + (this.test3?.b ?? 0) + ); +} +} diff --git a/tests/ts/my-game/example2/monster.js b/tests/ts/my-game/example2/monster.js new file mode 100644 index 00000000000..f50a2c85afd --- /dev/null +++ b/tests/ts/my-game/example2/monster.js @@ -0,0 +1,50 @@ +// automatically generated by the FlatBuffers compiler, do not modify +import * as flatbuffers from 'flatbuffers'; +export class Monster { + constructor() { + this.bb = null; + this.bb_pos = 0; + } + __init(i, bb) { + this.bb_pos = i; + this.bb = bb; + return this; + } + static getRootAsMonster(bb, obj) { + return (obj || new Monster()).__init(bb.readInt32(bb.position()) + bb.position(), bb); + } + static getSizePrefixedRootAsMonster(bb, obj) { + bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); + return (obj || new Monster()).__init(bb.readInt32(bb.position()) + bb.position(), bb); + } + static getFullyQualifiedName() { + return 'MyGame_Example2_Monster'; + } + static startMonster(builder) { + builder.startObject(0); + } + static endMonster(builder) { + const offset = builder.endObject(); + return offset; + } + static createMonster(builder) { + Monster.startMonster(builder); + return Monster.endMonster(builder); + } + serialize() { + return this.bb.bytes(); + } + static deserialize(buffer) { + return Monster.getRootAsMonster(new flatbuffers.ByteBuffer(buffer)); + } + unpack() { + return new MonsterT(); + } + unpackTo(_o) { } +} +export class MonsterT { + constructor() { } + pack(builder) { + return Monster.createMonster(builder); + } +} diff --git a/tests/ts/my-game/example2/monster.ts b/tests/ts/my-game/example2/monster.ts new file mode 100644 index 00000000000..7240476bef6 --- /dev/null +++ b/tests/ts/my-game/example2/monster.ts @@ -0,0 +1,66 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +import * as flatbuffers from 'flatbuffers'; + + + +export class Monster { + bb: flatbuffers.ByteBuffer|null = null; + bb_pos = 0; + __init(i:number, bb:flatbuffers.ByteBuffer):Monster { + this.bb_pos = i; + this.bb = bb; + return this; +} + +static getRootAsMonster(bb:flatbuffers.ByteBuffer, obj?:Monster):Monster { + return (obj || new Monster()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +static getSizePrefixedRootAsMonster(bb:flatbuffers.ByteBuffer, obj?:Monster):Monster { + bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); + return (obj || new Monster()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +static getFullyQualifiedName():string { + return 'MyGame_Example2_Monster'; +} + +static startMonster(builder:flatbuffers.Builder) { + builder.startObject(0); +} + +static endMonster(builder:flatbuffers.Builder):flatbuffers.Offset { + const offset = builder.endObject(); + return offset; +} + +static createMonster(builder:flatbuffers.Builder):flatbuffers.Offset { + Monster.startMonster(builder); + return Monster.endMonster(builder); +} + +serialize():Uint8Array { + return this.bb!.bytes(); +} + +static deserialize(buffer: Uint8Array):Monster { + return Monster.getRootAsMonster(new flatbuffers.ByteBuffer(buffer)) +} + +unpack(): MonsterT { + return new MonsterT(); +} + + +unpackTo(_o: MonsterT): void {} +} + +export class MonsterT { +constructor(){} + + +pack(builder:flatbuffers.Builder): flatbuffers.Offset { + return Monster.createMonster(builder); +} +} diff --git a/tests/ts/my-game/in-parent-namespace.js b/tests/ts/my-game/in-parent-namespace.js new file mode 100644 index 00000000000..24b0ed78783 --- /dev/null +++ b/tests/ts/my-game/in-parent-namespace.js @@ -0,0 +1,50 @@ +// automatically generated by the FlatBuffers compiler, do not modify +import * as flatbuffers from 'flatbuffers'; +export class InParentNamespace { + constructor() { + this.bb = null; + this.bb_pos = 0; + } + __init(i, bb) { + this.bb_pos = i; + this.bb = bb; + return this; + } + static getRootAsInParentNamespace(bb, obj) { + return (obj || new InParentNamespace()).__init(bb.readInt32(bb.position()) + bb.position(), bb); + } + static getSizePrefixedRootAsInParentNamespace(bb, obj) { + bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); + return (obj || new InParentNamespace()).__init(bb.readInt32(bb.position()) + bb.position(), bb); + } + static getFullyQualifiedName() { + return 'MyGame_InParentNamespace'; + } + static startInParentNamespace(builder) { + builder.startObject(0); + } + static endInParentNamespace(builder) { + const offset = builder.endObject(); + return offset; + } + static createInParentNamespace(builder) { + InParentNamespace.startInParentNamespace(builder); + return InParentNamespace.endInParentNamespace(builder); + } + serialize() { + return this.bb.bytes(); + } + static deserialize(buffer) { + return InParentNamespace.getRootAsInParentNamespace(new flatbuffers.ByteBuffer(buffer)); + } + unpack() { + return new InParentNamespaceT(); + } + unpackTo(_o) { } +} +export class InParentNamespaceT { + constructor() { } + pack(builder) { + return InParentNamespace.createInParentNamespace(builder); + } +} diff --git a/tests/ts/my-game/in-parent-namespace.ts b/tests/ts/my-game/in-parent-namespace.ts new file mode 100644 index 00000000000..0de94df5e6c --- /dev/null +++ b/tests/ts/my-game/in-parent-namespace.ts @@ -0,0 +1,66 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +import * as flatbuffers from 'flatbuffers'; + + + +export class InParentNamespace { + bb: flatbuffers.ByteBuffer|null = null; + bb_pos = 0; + __init(i:number, bb:flatbuffers.ByteBuffer):InParentNamespace { + this.bb_pos = i; + this.bb = bb; + return this; +} + +static getRootAsInParentNamespace(bb:flatbuffers.ByteBuffer, obj?:InParentNamespace):InParentNamespace { + return (obj || new InParentNamespace()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +static getSizePrefixedRootAsInParentNamespace(bb:flatbuffers.ByteBuffer, obj?:InParentNamespace):InParentNamespace { + bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); + return (obj || new InParentNamespace()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +static getFullyQualifiedName():string { + return 'MyGame_InParentNamespace'; +} + +static startInParentNamespace(builder:flatbuffers.Builder) { + builder.startObject(0); +} + +static endInParentNamespace(builder:flatbuffers.Builder):flatbuffers.Offset { + const offset = builder.endObject(); + return offset; +} + +static createInParentNamespace(builder:flatbuffers.Builder):flatbuffers.Offset { + InParentNamespace.startInParentNamespace(builder); + return InParentNamespace.endInParentNamespace(builder); +} + +serialize():Uint8Array { + return this.bb!.bytes(); +} + +static deserialize(buffer: Uint8Array):InParentNamespace { + return InParentNamespace.getRootAsInParentNamespace(new flatbuffers.ByteBuffer(buffer)) +} + +unpack(): InParentNamespaceT { + return new InParentNamespaceT(); +} + + +unpackTo(_o: InParentNamespaceT): void {} +} + +export class InParentNamespaceT { +constructor(){} + + +pack(builder:flatbuffers.Builder): flatbuffers.Offset { + return InParentNamespace.createInParentNamespace(builder); +} +} diff --git a/tests/ts/optional-scalars/optional-byte.ts b/tests/ts/optional-scalars/optional-byte.ts new file mode 100644 index 00000000000..f4db265e2ba --- /dev/null +++ b/tests/ts/optional-scalars/optional-byte.ts @@ -0,0 +1,7 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +export enum OptionalByte { + None = 0, + One = 1, + Two = 2 +} diff --git a/tests/ts/optional-scalars/scalar-stuff.ts b/tests/ts/optional-scalars/scalar-stuff.ts new file mode 100644 index 00000000000..2adf31b3393 --- /dev/null +++ b/tests/ts/optional-scalars/scalar-stuff.ts @@ -0,0 +1,427 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +import * as flatbuffers from 'flatbuffers'; + +import { OptionalByte } from '../optional-scalars/optional-byte.js'; + + +export class ScalarStuff { + bb: flatbuffers.ByteBuffer|null = null; + bb_pos = 0; + __init(i:number, bb:flatbuffers.ByteBuffer):ScalarStuff { + this.bb_pos = i; + this.bb = bb; + return this; +} + +static getRootAsScalarStuff(bb:flatbuffers.ByteBuffer, obj?:ScalarStuff):ScalarStuff { + return (obj || new ScalarStuff()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +static getSizePrefixedRootAsScalarStuff(bb:flatbuffers.ByteBuffer, obj?:ScalarStuff):ScalarStuff { + bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); + return (obj || new ScalarStuff()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +static bufferHasIdentifier(bb:flatbuffers.ByteBuffer):boolean { + return bb.__has_identifier('NULL'); +} + +justI8():number { + const offset = this.bb!.__offset(this.bb_pos, 4); + return offset ? this.bb!.readInt8(this.bb_pos + offset) : 0; +} + +maybeI8():number|null { + const offset = this.bb!.__offset(this.bb_pos, 6); + return offset ? this.bb!.readInt8(this.bb_pos + offset) : null; +} + +defaultI8():number { + const offset = this.bb!.__offset(this.bb_pos, 8); + return offset ? this.bb!.readInt8(this.bb_pos + offset) : 42; +} + +justU8():number { + const offset = this.bb!.__offset(this.bb_pos, 10); + return offset ? this.bb!.readUint8(this.bb_pos + offset) : 0; +} + +maybeU8():number|null { + const offset = this.bb!.__offset(this.bb_pos, 12); + return offset ? this.bb!.readUint8(this.bb_pos + offset) : null; +} + +defaultU8():number { + const offset = this.bb!.__offset(this.bb_pos, 14); + return offset ? this.bb!.readUint8(this.bb_pos + offset) : 42; +} + +justI16():number { + const offset = this.bb!.__offset(this.bb_pos, 16); + return offset ? this.bb!.readInt16(this.bb_pos + offset) : 0; +} + +maybeI16():number|null { + const offset = this.bb!.__offset(this.bb_pos, 18); + return offset ? this.bb!.readInt16(this.bb_pos + offset) : null; +} + +defaultI16():number { + const offset = this.bb!.__offset(this.bb_pos, 20); + return offset ? this.bb!.readInt16(this.bb_pos + offset) : 42; +} + +justU16():number { + const offset = this.bb!.__offset(this.bb_pos, 22); + return offset ? this.bb!.readUint16(this.bb_pos + offset) : 0; +} + +maybeU16():number|null { + const offset = this.bb!.__offset(this.bb_pos, 24); + return offset ? this.bb!.readUint16(this.bb_pos + offset) : null; +} + +defaultU16():number { + const offset = this.bb!.__offset(this.bb_pos, 26); + return offset ? this.bb!.readUint16(this.bb_pos + offset) : 42; +} + +justI32():number { + const offset = this.bb!.__offset(this.bb_pos, 28); + return offset ? this.bb!.readInt32(this.bb_pos + offset) : 0; +} + +maybeI32():number|null { + const offset = this.bb!.__offset(this.bb_pos, 30); + return offset ? this.bb!.readInt32(this.bb_pos + offset) : null; +} + +defaultI32():number { + const offset = this.bb!.__offset(this.bb_pos, 32); + return offset ? this.bb!.readInt32(this.bb_pos + offset) : 42; +} + +justU32():number { + const offset = this.bb!.__offset(this.bb_pos, 34); + return offset ? this.bb!.readUint32(this.bb_pos + offset) : 0; +} + +maybeU32():number|null { + const offset = this.bb!.__offset(this.bb_pos, 36); + return offset ? this.bb!.readUint32(this.bb_pos + offset) : null; +} + +defaultU32():number { + const offset = this.bb!.__offset(this.bb_pos, 38); + return offset ? this.bb!.readUint32(this.bb_pos + offset) : 42; +} + +justI64():bigint { + const offset = this.bb!.__offset(this.bb_pos, 40); + return offset ? this.bb!.readInt64(this.bb_pos + offset) : BigInt('0'); +} + +maybeI64():bigint|null { + const offset = this.bb!.__offset(this.bb_pos, 42); + return offset ? this.bb!.readInt64(this.bb_pos + offset) : null; +} + +defaultI64():bigint { + const offset = this.bb!.__offset(this.bb_pos, 44); + return offset ? this.bb!.readInt64(this.bb_pos + offset) : BigInt('42'); +} + +justU64():bigint { + const offset = this.bb!.__offset(this.bb_pos, 46); + return offset ? this.bb!.readUint64(this.bb_pos + offset) : BigInt('0'); +} + +maybeU64():bigint|null { + const offset = this.bb!.__offset(this.bb_pos, 48); + return offset ? this.bb!.readUint64(this.bb_pos + offset) : null; +} + +defaultU64():bigint { + const offset = this.bb!.__offset(this.bb_pos, 50); + return offset ? this.bb!.readUint64(this.bb_pos + offset) : BigInt('42'); +} + +justF32():number { + const offset = this.bb!.__offset(this.bb_pos, 52); + return offset ? this.bb!.readFloat32(this.bb_pos + offset) : 0.0; +} + +maybeF32():number|null { + const offset = this.bb!.__offset(this.bb_pos, 54); + return offset ? this.bb!.readFloat32(this.bb_pos + offset) : null; +} + +defaultF32():number { + const offset = this.bb!.__offset(this.bb_pos, 56); + return offset ? this.bb!.readFloat32(this.bb_pos + offset) : 42.0; +} + +justF64():number { + const offset = this.bb!.__offset(this.bb_pos, 58); + return offset ? this.bb!.readFloat64(this.bb_pos + offset) : 0.0; +} + +maybeF64():number|null { + const offset = this.bb!.__offset(this.bb_pos, 60); + return offset ? this.bb!.readFloat64(this.bb_pos + offset) : null; +} + +defaultF64():number { + const offset = this.bb!.__offset(this.bb_pos, 62); + return offset ? this.bb!.readFloat64(this.bb_pos + offset) : 42.0; +} + +justBool():boolean { + const offset = this.bb!.__offset(this.bb_pos, 64); + return offset ? !!this.bb!.readInt8(this.bb_pos + offset) : false; +} + +maybeBool():boolean|null { + const offset = this.bb!.__offset(this.bb_pos, 66); + return offset ? !!this.bb!.readInt8(this.bb_pos + offset) : null; +} + +defaultBool():boolean { + const offset = this.bb!.__offset(this.bb_pos, 68); + return offset ? !!this.bb!.readInt8(this.bb_pos + offset) : true; +} + +justEnum():OptionalByte { + const offset = this.bb!.__offset(this.bb_pos, 70); + return offset ? this.bb!.readInt8(this.bb_pos + offset) : OptionalByte.None; +} + +maybeEnum():OptionalByte|null { + const offset = this.bb!.__offset(this.bb_pos, 72); + return offset ? this.bb!.readInt8(this.bb_pos + offset) : null; +} + +defaultEnum():OptionalByte { + const offset = this.bb!.__offset(this.bb_pos, 74); + return offset ? this.bb!.readInt8(this.bb_pos + offset) : OptionalByte.One; +} + +static getFullyQualifiedName():string { + return 'optional_scalars_ScalarStuff'; +} + +static startScalarStuff(builder:flatbuffers.Builder) { + builder.startObject(36); +} + +static addJustI8(builder:flatbuffers.Builder, justI8:number) { + builder.addFieldInt8(0, justI8, 0); +} + +static addMaybeI8(builder:flatbuffers.Builder, maybeI8:number) { + builder.addFieldInt8(1, maybeI8, 0); +} + +static addDefaultI8(builder:flatbuffers.Builder, defaultI8:number) { + builder.addFieldInt8(2, defaultI8, 42); +} + +static addJustU8(builder:flatbuffers.Builder, justU8:number) { + builder.addFieldInt8(3, justU8, 0); +} + +static addMaybeU8(builder:flatbuffers.Builder, maybeU8:number) { + builder.addFieldInt8(4, maybeU8, 0); +} + +static addDefaultU8(builder:flatbuffers.Builder, defaultU8:number) { + builder.addFieldInt8(5, defaultU8, 42); +} + +static addJustI16(builder:flatbuffers.Builder, justI16:number) { + builder.addFieldInt16(6, justI16, 0); +} + +static addMaybeI16(builder:flatbuffers.Builder, maybeI16:number) { + builder.addFieldInt16(7, maybeI16, 0); +} + +static addDefaultI16(builder:flatbuffers.Builder, defaultI16:number) { + builder.addFieldInt16(8, defaultI16, 42); +} + +static addJustU16(builder:flatbuffers.Builder, justU16:number) { + builder.addFieldInt16(9, justU16, 0); +} + +static addMaybeU16(builder:flatbuffers.Builder, maybeU16:number) { + builder.addFieldInt16(10, maybeU16, 0); +} + +static addDefaultU16(builder:flatbuffers.Builder, defaultU16:number) { + builder.addFieldInt16(11, defaultU16, 42); +} + +static addJustI32(builder:flatbuffers.Builder, justI32:number) { + builder.addFieldInt32(12, justI32, 0); +} + +static addMaybeI32(builder:flatbuffers.Builder, maybeI32:number) { + builder.addFieldInt32(13, maybeI32, 0); +} + +static addDefaultI32(builder:flatbuffers.Builder, defaultI32:number) { + builder.addFieldInt32(14, defaultI32, 42); +} + +static addJustU32(builder:flatbuffers.Builder, justU32:number) { + builder.addFieldInt32(15, justU32, 0); +} + +static addMaybeU32(builder:flatbuffers.Builder, maybeU32:number) { + builder.addFieldInt32(16, maybeU32, 0); +} + +static addDefaultU32(builder:flatbuffers.Builder, defaultU32:number) { + builder.addFieldInt32(17, defaultU32, 42); +} + +static addJustI64(builder:flatbuffers.Builder, justI64:bigint) { + builder.addFieldInt64(18, justI64, BigInt('0')); +} + +static addMaybeI64(builder:flatbuffers.Builder, maybeI64:bigint) { + builder.addFieldInt64(19, maybeI64, BigInt(0)); +} + +static addDefaultI64(builder:flatbuffers.Builder, defaultI64:bigint) { + builder.addFieldInt64(20, defaultI64, BigInt('42')); +} + +static addJustU64(builder:flatbuffers.Builder, justU64:bigint) { + builder.addFieldInt64(21, justU64, BigInt('0')); +} + +static addMaybeU64(builder:flatbuffers.Builder, maybeU64:bigint) { + builder.addFieldInt64(22, maybeU64, BigInt(0)); +} + +static addDefaultU64(builder:flatbuffers.Builder, defaultU64:bigint) { + builder.addFieldInt64(23, defaultU64, BigInt('42')); +} + +static addJustF32(builder:flatbuffers.Builder, justF32:number) { + builder.addFieldFloat32(24, justF32, 0.0); +} + +static addMaybeF32(builder:flatbuffers.Builder, maybeF32:number) { + builder.addFieldFloat32(25, maybeF32, 0); +} + +static addDefaultF32(builder:flatbuffers.Builder, defaultF32:number) { + builder.addFieldFloat32(26, defaultF32, 42.0); +} + +static addJustF64(builder:flatbuffers.Builder, justF64:number) { + builder.addFieldFloat64(27, justF64, 0.0); +} + +static addMaybeF64(builder:flatbuffers.Builder, maybeF64:number) { + builder.addFieldFloat64(28, maybeF64, 0); +} + +static addDefaultF64(builder:flatbuffers.Builder, defaultF64:number) { + builder.addFieldFloat64(29, defaultF64, 42.0); +} + +static addJustBool(builder:flatbuffers.Builder, justBool:boolean) { + builder.addFieldInt8(30, +justBool, +false); +} + +static addMaybeBool(builder:flatbuffers.Builder, maybeBool:boolean) { + builder.addFieldInt8(31, +maybeBool, 0); +} + +static addDefaultBool(builder:flatbuffers.Builder, defaultBool:boolean) { + builder.addFieldInt8(32, +defaultBool, +true); +} + +static addJustEnum(builder:flatbuffers.Builder, justEnum:OptionalByte) { + builder.addFieldInt8(33, justEnum, OptionalByte.None); +} + +static addMaybeEnum(builder:flatbuffers.Builder, maybeEnum:OptionalByte) { + builder.addFieldInt8(34, maybeEnum, 0); +} + +static addDefaultEnum(builder:flatbuffers.Builder, defaultEnum:OptionalByte) { + builder.addFieldInt8(35, defaultEnum, OptionalByte.One); +} + +static endScalarStuff(builder:flatbuffers.Builder):flatbuffers.Offset { + const offset = builder.endObject(); + return offset; +} + +static finishScalarStuffBuffer(builder:flatbuffers.Builder, offset:flatbuffers.Offset) { + builder.finish(offset, 'NULL'); +} + +static finishSizePrefixedScalarStuffBuffer(builder:flatbuffers.Builder, offset:flatbuffers.Offset) { + 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: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.addJustI8(builder, justI8); + if (maybeI8 !== null) + ScalarStuff.addMaybeI8(builder, maybeI8); + ScalarStuff.addDefaultI8(builder, defaultI8); + ScalarStuff.addJustU8(builder, justU8); + if (maybeU8 !== null) + ScalarStuff.addMaybeU8(builder, maybeU8); + ScalarStuff.addDefaultU8(builder, defaultU8); + ScalarStuff.addJustI16(builder, justI16); + if (maybeI16 !== null) + ScalarStuff.addMaybeI16(builder, maybeI16); + ScalarStuff.addDefaultI16(builder, defaultI16); + ScalarStuff.addJustU16(builder, justU16); + if (maybeU16 !== null) + ScalarStuff.addMaybeU16(builder, maybeU16); + ScalarStuff.addDefaultU16(builder, defaultU16); + ScalarStuff.addJustI32(builder, justI32); + if (maybeI32 !== null) + ScalarStuff.addMaybeI32(builder, maybeI32); + ScalarStuff.addDefaultI32(builder, defaultI32); + ScalarStuff.addJustU32(builder, justU32); + if (maybeU32 !== null) + ScalarStuff.addMaybeU32(builder, maybeU32); + ScalarStuff.addDefaultU32(builder, defaultU32); + ScalarStuff.addJustI64(builder, justI64); + if (maybeI64 !== null) + ScalarStuff.addMaybeI64(builder, maybeI64); + ScalarStuff.addDefaultI64(builder, defaultI64); + ScalarStuff.addJustU64(builder, justU64); + if (maybeU64 !== null) + ScalarStuff.addMaybeU64(builder, maybeU64); + ScalarStuff.addDefaultU64(builder, defaultU64); + ScalarStuff.addJustF32(builder, justF32); + if (maybeF32 !== null) + ScalarStuff.addMaybeF32(builder, maybeF32); + ScalarStuff.addDefaultF32(builder, defaultF32); + ScalarStuff.addJustF64(builder, justF64); + if (maybeF64 !== null) + ScalarStuff.addMaybeF64(builder, maybeF64); + ScalarStuff.addDefaultF64(builder, defaultF64); + ScalarStuff.addJustBool(builder, justBool); + if (maybeBool !== null) + ScalarStuff.addMaybeBool(builder, maybeBool); + ScalarStuff.addDefaultBool(builder, defaultBool); + ScalarStuff.addJustEnum(builder, justEnum); + if (maybeEnum !== null) + ScalarStuff.addMaybeEnum(builder, maybeEnum); + ScalarStuff.addDefaultEnum(builder, defaultEnum); + return ScalarStuff.endScalarStuff(builder); +} +} diff --git a/tests/optional_scalars.ts b/tests/ts/optional_scalars.ts similarity index 100% rename from tests/optional_scalars.ts rename to tests/ts/optional_scalars.ts diff --git a/tests/ts/optional_scalars_generated.ts b/tests/ts/optional_scalars_generated.ts new file mode 100644 index 00000000000..ebd33509f77 --- /dev/null +++ b/tests/ts/optional_scalars_generated.ts @@ -0,0 +1,4 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +export { OptionalByte } from './optional-scalars/optional-byte.js'; +export { ScalarStuff } from './optional-scalars/scalar-stuff.js'; diff --git a/tests/ts/package.json b/tests/ts/package.json new file mode 100644 index 00000000000..ac2639e3ce3 --- /dev/null +++ b/tests/ts/package.json @@ -0,0 +1,7 @@ +{ + "type": "module", + "dependencies": { + "@grpc/grpc-js": "^1.7.0", + "flatbuffers": "../../" + } +} diff --git a/tests/ts/reflection/advanced-features.ts b/tests/ts/reflection/advanced-features.ts new file mode 100644 index 00000000000..dd3b865063b --- /dev/null +++ b/tests/ts/reflection/advanced-features.ts @@ -0,0 +1,11 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +/** + * New schema language features that are not supported by old code generators. + */ +export enum AdvancedFeatures { + AdvancedArrayFeatures = '1', + AdvancedUnionFeatures = '2', + OptionalScalars = '4', + DefaultVectorsAndStrings = '8' +} diff --git a/tests/ts/reflection/base-type.js b/tests/ts/reflection/base-type.js new file mode 100644 index 00000000000..dccd0ac9e57 --- /dev/null +++ b/tests/ts/reflection/base-type.js @@ -0,0 +1,23 @@ +// automatically generated by the FlatBuffers compiler, do not modify +export var BaseType; +(function (BaseType) { + BaseType[BaseType["None"] = 0] = "None"; + BaseType[BaseType["UType"] = 1] = "UType"; + BaseType[BaseType["Bool"] = 2] = "Bool"; + BaseType[BaseType["Byte"] = 3] = "Byte"; + BaseType[BaseType["UByte"] = 4] = "UByte"; + BaseType[BaseType["Short"] = 5] = "Short"; + BaseType[BaseType["UShort"] = 6] = "UShort"; + BaseType[BaseType["Int"] = 7] = "Int"; + BaseType[BaseType["UInt"] = 8] = "UInt"; + BaseType[BaseType["Long"] = 9] = "Long"; + BaseType[BaseType["ULong"] = 10] = "ULong"; + BaseType[BaseType["Float"] = 11] = "Float"; + BaseType[BaseType["Double"] = 12] = "Double"; + BaseType[BaseType["String"] = 13] = "String"; + BaseType[BaseType["Vector"] = 14] = "Vector"; + BaseType[BaseType["Obj"] = 15] = "Obj"; + BaseType[BaseType["Union"] = 16] = "Union"; + BaseType[BaseType["Array"] = 17] = "Array"; + BaseType[BaseType["MaxBaseType"] = 18] = "MaxBaseType"; +})(BaseType || (BaseType = {})); diff --git a/tests/ts/reflection/base-type.ts b/tests/ts/reflection/base-type.ts new file mode 100644 index 00000000000..7ee98ed998d --- /dev/null +++ b/tests/ts/reflection/base-type.ts @@ -0,0 +1,23 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +export enum BaseType { + None = 0, + UType = 1, + Bool = 2, + Byte = 3, + UByte = 4, + Short = 5, + UShort = 6, + Int = 7, + UInt = 8, + Long = 9, + ULong = 10, + Float = 11, + Double = 12, + String = 13, + Vector = 14, + Obj = 15, + Union = 16, + Array = 17, + MaxBaseType = 18 +} diff --git a/tests/ts/reflection/enum-val.js b/tests/ts/reflection/enum-val.js new file mode 100644 index 00000000000..f2ce03d1f11 --- /dev/null +++ b/tests/ts/reflection/enum-val.js @@ -0,0 +1,110 @@ +// automatically generated by the FlatBuffers compiler, do not modify +import * as flatbuffers from 'flatbuffers'; +import { Type } from '../reflection/type.js'; +export class EnumVal { + constructor() { + this.bb = null; + this.bb_pos = 0; + } + __init(i, bb) { + this.bb_pos = i; + this.bb = bb; + return this; + } + static getRootAsEnumVal(bb, obj) { + return (obj || new EnumVal()).__init(bb.readInt32(bb.position()) + bb.position(), bb); + } + static getSizePrefixedRootAsEnumVal(bb, obj) { + bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); + return (obj || new EnumVal()).__init(bb.readInt32(bb.position()) + bb.position(), bb); + } + name(optionalEncoding) { + const offset = this.bb.__offset(this.bb_pos, 4); + return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null; + } + value() { + const offset = this.bb.__offset(this.bb_pos, 6); + return offset ? this.bb.readInt64(this.bb_pos + offset) : BigInt('0'); + } + mutate_value(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; + } + unionType(obj) { + const offset = this.bb.__offset(this.bb_pos, 10); + return offset ? (obj || new Type()).__init(this.bb.__indirect(this.bb_pos + offset), this.bb) : null; + } + documentation(index, optionalEncoding) { + const offset = this.bb.__offset(this.bb_pos, 12); + return offset ? this.bb.__string(this.bb.__vector(this.bb_pos + offset) + index * 4, optionalEncoding) : null; + } + documentationLength() { + const offset = this.bb.__offset(this.bb_pos, 12); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; + } + static getFullyQualifiedName() { + return 'reflection_EnumVal'; + } + static startEnumVal(builder) { + builder.startObject(5); + } + static addName(builder, nameOffset) { + builder.addFieldOffset(0, nameOffset, 0); + } + static addValue(builder, value) { + builder.addFieldInt64(1, value, BigInt('0')); + } + static addUnionType(builder, unionTypeOffset) { + builder.addFieldOffset(3, unionTypeOffset, 0); + } + static addDocumentation(builder, documentationOffset) { + builder.addFieldOffset(4, documentationOffset, 0); + } + static createDocumentationVector(builder, data) { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addOffset(data[i]); + } + return builder.endVector(); + } + static startDocumentationVector(builder, numElems) { + builder.startVector(4, numElems, 4); + } + static endEnumVal(builder) { + const offset = builder.endObject(); + builder.requiredField(offset, 4); // name + return offset; + } + unpack() { + return new EnumValT(this.name(), this.value(), (this.unionType() !== null ? this.unionType().unpack() : null), this.bb.createScalarList(this.documentation.bind(this), this.documentationLength())); + } + unpackTo(_o) { + _o.name = this.name(); + _o.value = this.value(); + _o.unionType = (this.unionType() !== null ? this.unionType().unpack() : null); + _o.documentation = this.bb.createScalarList(this.documentation.bind(this), this.documentationLength()); + } +} +export class EnumValT { + constructor(name = null, value = BigInt('0'), unionType = null, documentation = []) { + this.name = name; + this.value = value; + this.unionType = unionType; + this.documentation = documentation; + } + pack(builder) { + const name = (this.name !== null ? builder.createString(this.name) : 0); + const unionType = (this.unionType !== null ? this.unionType.pack(builder) : 0); + const documentation = EnumVal.createDocumentationVector(builder, builder.createObjectOffsetList(this.documentation)); + EnumVal.startEnumVal(builder); + EnumVal.addName(builder, name); + EnumVal.addValue(builder, this.value); + EnumVal.addUnionType(builder, unionType); + EnumVal.addDocumentation(builder, documentation); + return EnumVal.endEnumVal(builder); + } +} diff --git a/tests/ts/reflection/enum-val.ts b/tests/ts/reflection/enum-val.ts new file mode 100644 index 00000000000..85278327b86 --- /dev/null +++ b/tests/ts/reflection/enum-val.ts @@ -0,0 +1,149 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +import * as flatbuffers from 'flatbuffers'; + +import { Type, TypeT } from '../reflection/type.js'; + + +export class EnumVal { + bb: flatbuffers.ByteBuffer|null = null; + bb_pos = 0; + __init(i:number, bb:flatbuffers.ByteBuffer):EnumVal { + this.bb_pos = i; + this.bb = bb; + return this; +} + +static getRootAsEnumVal(bb:flatbuffers.ByteBuffer, obj?:EnumVal):EnumVal { + return (obj || new EnumVal()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +static getSizePrefixedRootAsEnumVal(bb:flatbuffers.ByteBuffer, obj?:EnumVal):EnumVal { + bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); + return (obj || new EnumVal()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +name():string|null +name(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null +name(optionalEncoding?:any):string|Uint8Array|null { + const offset = this.bb!.__offset(this.bb_pos, 4); + return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; +} + +value():bigint { + const offset = this.bb!.__offset(this.bb_pos, 6); + return offset ? this.bb!.readInt64(this.bb_pos + offset) : BigInt('0'); +} + +mutate_value(value:bigint):boolean { + const offset = this.bb!.__offset(this.bb_pos, 6); + + if (offset === 0) { + return false; + } + + this.bb!.writeInt64(this.bb_pos + offset, value); + return true; +} + +unionType(obj?:Type):Type|null { + const offset = this.bb!.__offset(this.bb_pos, 10); + return offset ? (obj || new Type()).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null; +} + +documentation(index: number):string +documentation(index: number,optionalEncoding:flatbuffers.Encoding):string|Uint8Array +documentation(index: number,optionalEncoding?:any):string|Uint8Array|null { + const offset = this.bb!.__offset(this.bb_pos, 12); + return offset ? this.bb!.__string(this.bb!.__vector(this.bb_pos + offset) + index * 4, optionalEncoding) : null; +} + +documentationLength():number { + const offset = this.bb!.__offset(this.bb_pos, 12); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +} + +static getFullyQualifiedName():string { + return 'reflection_EnumVal'; +} + +static startEnumVal(builder:flatbuffers.Builder) { + builder.startObject(5); +} + +static addName(builder:flatbuffers.Builder, nameOffset:flatbuffers.Offset) { + builder.addFieldOffset(0, nameOffset, 0); +} + +static addValue(builder:flatbuffers.Builder, value:bigint) { + builder.addFieldInt64(1, value, BigInt('0')); +} + +static addUnionType(builder:flatbuffers.Builder, unionTypeOffset:flatbuffers.Offset) { + builder.addFieldOffset(3, unionTypeOffset, 0); +} + +static addDocumentation(builder:flatbuffers.Builder, documentationOffset:flatbuffers.Offset) { + builder.addFieldOffset(4, documentationOffset, 0); +} + +static createDocumentationVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addOffset(data[i]!); + } + return builder.endVector(); +} + +static startDocumentationVector(builder:flatbuffers.Builder, numElems:number) { + builder.startVector(4, numElems, 4); +} + +static endEnumVal(builder:flatbuffers.Builder):flatbuffers.Offset { + const offset = builder.endObject(); + builder.requiredField(offset, 4) // name + return offset; +} + + +unpack(): EnumValT { + return new EnumValT( + this.name(), + this.value(), + (this.unionType() !== null ? this.unionType()!.unpack() : null), + this.bb!.createScalarList(this.documentation.bind(this), this.documentationLength()) + ); +} + + +unpackTo(_o: EnumValT): void { + _o.name = this.name(); + _o.value = this.value(); + _o.unionType = (this.unionType() !== null ? this.unionType()!.unpack() : null); + _o.documentation = this.bb!.createScalarList(this.documentation.bind(this), this.documentationLength()); +} +} + +export class EnumValT { +constructor( + public name: string|Uint8Array|null = null, + public value: bigint = BigInt('0'), + public unionType: TypeT|null = null, + public documentation: (string)[] = [] +){} + + +pack(builder:flatbuffers.Builder): flatbuffers.Offset { + const name = (this.name !== null ? builder.createString(this.name!) : 0); + const unionType = (this.unionType !== null ? this.unionType!.pack(builder) : 0); + const documentation = EnumVal.createDocumentationVector(builder, builder.createObjectOffsetList(this.documentation)); + + EnumVal.startEnumVal(builder); + EnumVal.addName(builder, name); + EnumVal.addValue(builder, this.value); + EnumVal.addUnionType(builder, unionType); + EnumVal.addDocumentation(builder, documentation); + + return EnumVal.endEnumVal(builder); +} +} diff --git a/tests/ts/reflection/enum.js b/tests/ts/reflection/enum.js new file mode 100644 index 00000000000..49393072b39 --- /dev/null +++ b/tests/ts/reflection/enum.js @@ -0,0 +1,175 @@ +// automatically generated by the FlatBuffers compiler, do not modify +import * as flatbuffers from 'flatbuffers'; +import { EnumVal } from '../reflection/enum-val.js'; +import { KeyValue } from '../reflection/key-value.js'; +import { Type } from '../reflection/type.js'; +export class Enum { + constructor() { + this.bb = null; + this.bb_pos = 0; + } + __init(i, bb) { + this.bb_pos = i; + this.bb = bb; + return this; + } + static getRootAsEnum(bb, obj) { + return (obj || new Enum()).__init(bb.readInt32(bb.position()) + bb.position(), bb); + } + static getSizePrefixedRootAsEnum(bb, obj) { + bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); + return (obj || new Enum()).__init(bb.readInt32(bb.position()) + bb.position(), bb); + } + name(optionalEncoding) { + const offset = this.bb.__offset(this.bb_pos, 4); + return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null; + } + values(index, obj) { + const offset = this.bb.__offset(this.bb_pos, 6); + return offset ? (obj || new EnumVal()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4), this.bb) : null; + } + valuesLength() { + const offset = this.bb.__offset(this.bb_pos, 6); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; + } + isUnion() { + const offset = this.bb.__offset(this.bb_pos, 8); + return offset ? !!this.bb.readInt8(this.bb_pos + offset) : false; + } + mutate_is_union(value) { + const offset = this.bb.__offset(this.bb_pos, 8); + if (offset === 0) { + return false; + } + this.bb.writeInt8(this.bb_pos + offset, +value); + return true; + } + underlyingType(obj) { + const offset = this.bb.__offset(this.bb_pos, 10); + return offset ? (obj || new Type()).__init(this.bb.__indirect(this.bb_pos + offset), this.bb) : null; + } + attributes(index, obj) { + const offset = this.bb.__offset(this.bb_pos, 12); + return offset ? (obj || new KeyValue()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4), this.bb) : null; + } + attributesLength() { + const offset = this.bb.__offset(this.bb_pos, 12); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; + } + documentation(index, optionalEncoding) { + const offset = this.bb.__offset(this.bb_pos, 14); + return offset ? this.bb.__string(this.bb.__vector(this.bb_pos + offset) + index * 4, optionalEncoding) : null; + } + documentationLength() { + const offset = this.bb.__offset(this.bb_pos, 14); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; + } + declarationFile(optionalEncoding) { + const offset = this.bb.__offset(this.bb_pos, 16); + return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null; + } + static getFullyQualifiedName() { + return 'reflection_Enum'; + } + static startEnum(builder) { + builder.startObject(7); + } + static addName(builder, nameOffset) { + builder.addFieldOffset(0, nameOffset, 0); + } + static addValues(builder, valuesOffset) { + builder.addFieldOffset(1, valuesOffset, 0); + } + static createValuesVector(builder, data) { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addOffset(data[i]); + } + return builder.endVector(); + } + static startValuesVector(builder, numElems) { + builder.startVector(4, numElems, 4); + } + static addIsUnion(builder, isUnion) { + builder.addFieldInt8(2, +isUnion, +false); + } + static addUnderlyingType(builder, underlyingTypeOffset) { + builder.addFieldOffset(3, underlyingTypeOffset, 0); + } + static addAttributes(builder, attributesOffset) { + builder.addFieldOffset(4, attributesOffset, 0); + } + static createAttributesVector(builder, data) { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addOffset(data[i]); + } + return builder.endVector(); + } + static startAttributesVector(builder, numElems) { + builder.startVector(4, numElems, 4); + } + static addDocumentation(builder, documentationOffset) { + builder.addFieldOffset(5, documentationOffset, 0); + } + static createDocumentationVector(builder, data) { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addOffset(data[i]); + } + return builder.endVector(); + } + static startDocumentationVector(builder, numElems) { + builder.startVector(4, numElems, 4); + } + static addDeclarationFile(builder, declarationFileOffset) { + builder.addFieldOffset(6, declarationFileOffset, 0); + } + static endEnum(builder) { + const offset = builder.endObject(); + builder.requiredField(offset, 4); // name + builder.requiredField(offset, 6); // values + builder.requiredField(offset, 10); // underlying_type + return offset; + } + unpack() { + return new EnumT(this.name(), this.bb.createObjList(this.values.bind(this), this.valuesLength()), this.isUnion(), (this.underlyingType() !== null ? this.underlyingType().unpack() : null), this.bb.createObjList(this.attributes.bind(this), this.attributesLength()), this.bb.createScalarList(this.documentation.bind(this), this.documentationLength()), this.declarationFile()); + } + unpackTo(_o) { + _o.name = this.name(); + _o.values = this.bb.createObjList(this.values.bind(this), this.valuesLength()); + _o.isUnion = this.isUnion(); + _o.underlyingType = (this.underlyingType() !== null ? this.underlyingType().unpack() : null); + _o.attributes = this.bb.createObjList(this.attributes.bind(this), this.attributesLength()); + _o.documentation = this.bb.createScalarList(this.documentation.bind(this), this.documentationLength()); + _o.declarationFile = this.declarationFile(); + } +} +export class EnumT { + constructor(name = null, values = [], isUnion = false, underlyingType = null, attributes = [], documentation = [], declarationFile = null) { + this.name = name; + this.values = values; + this.isUnion = isUnion; + this.underlyingType = underlyingType; + this.attributes = attributes; + this.documentation = documentation; + this.declarationFile = declarationFile; + } + pack(builder) { + const name = (this.name !== null ? builder.createString(this.name) : 0); + const values = Enum.createValuesVector(builder, builder.createObjectOffsetList(this.values)); + const underlyingType = (this.underlyingType !== null ? this.underlyingType.pack(builder) : 0); + const attributes = Enum.createAttributesVector(builder, builder.createObjectOffsetList(this.attributes)); + const documentation = Enum.createDocumentationVector(builder, builder.createObjectOffsetList(this.documentation)); + const declarationFile = (this.declarationFile !== null ? builder.createString(this.declarationFile) : 0); + Enum.startEnum(builder); + Enum.addName(builder, name); + Enum.addValues(builder, values); + Enum.addIsUnion(builder, this.isUnion); + Enum.addUnderlyingType(builder, underlyingType); + Enum.addAttributes(builder, attributes); + Enum.addDocumentation(builder, documentation); + Enum.addDeclarationFile(builder, declarationFile); + return Enum.endEnum(builder); + } +} diff --git a/tests/ts/reflection/enum.ts b/tests/ts/reflection/enum.ts new file mode 100644 index 00000000000..7bba354ffaf --- /dev/null +++ b/tests/ts/reflection/enum.ts @@ -0,0 +1,234 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +import * as flatbuffers from 'flatbuffers'; + +import { EnumVal, EnumValT } from '../reflection/enum-val.js'; +import { KeyValue, KeyValueT } from '../reflection/key-value.js'; +import { Type, TypeT } from '../reflection/type.js'; + + +export class Enum { + bb: flatbuffers.ByteBuffer|null = null; + bb_pos = 0; + __init(i:number, bb:flatbuffers.ByteBuffer):Enum { + this.bb_pos = i; + this.bb = bb; + return this; +} + +static getRootAsEnum(bb:flatbuffers.ByteBuffer, obj?:Enum):Enum { + return (obj || new Enum()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +static getSizePrefixedRootAsEnum(bb:flatbuffers.ByteBuffer, obj?:Enum):Enum { + bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); + return (obj || new Enum()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +name():string|null +name(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null +name(optionalEncoding?:any):string|Uint8Array|null { + const offset = this.bb!.__offset(this.bb_pos, 4); + return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; +} + +values(index: number, obj?:EnumVal):EnumVal|null { + const offset = this.bb!.__offset(this.bb_pos, 6); + return offset ? (obj || new EnumVal()).__init(this.bb!.__indirect(this.bb!.__vector(this.bb_pos + offset) + index * 4), this.bb!) : null; +} + +valuesLength():number { + const offset = this.bb!.__offset(this.bb_pos, 6); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +} + +isUnion():boolean { + const offset = this.bb!.__offset(this.bb_pos, 8); + return offset ? !!this.bb!.readInt8(this.bb_pos + offset) : false; +} + +mutate_is_union(value:boolean):boolean { + const offset = this.bb!.__offset(this.bb_pos, 8); + + if (offset === 0) { + return false; + } + + this.bb!.writeInt8(this.bb_pos + offset, +value); + return true; +} + +underlyingType(obj?:Type):Type|null { + const offset = this.bb!.__offset(this.bb_pos, 10); + return offset ? (obj || new Type()).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null; +} + +attributes(index: number, obj?:KeyValue):KeyValue|null { + const offset = this.bb!.__offset(this.bb_pos, 12); + return offset ? (obj || new KeyValue()).__init(this.bb!.__indirect(this.bb!.__vector(this.bb_pos + offset) + index * 4), this.bb!) : null; +} + +attributesLength():number { + const offset = this.bb!.__offset(this.bb_pos, 12); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +} + +documentation(index: number):string +documentation(index: number,optionalEncoding:flatbuffers.Encoding):string|Uint8Array +documentation(index: number,optionalEncoding?:any):string|Uint8Array|null { + const offset = this.bb!.__offset(this.bb_pos, 14); + return offset ? this.bb!.__string(this.bb!.__vector(this.bb_pos + offset) + index * 4, optionalEncoding) : null; +} + +documentationLength():number { + const offset = this.bb!.__offset(this.bb_pos, 14); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +} + +/** + * File that this Enum is declared in. + */ +declarationFile():string|null +declarationFile(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null +declarationFile(optionalEncoding?:any):string|Uint8Array|null { + const offset = this.bb!.__offset(this.bb_pos, 16); + return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; +} + +static getFullyQualifiedName():string { + return 'reflection_Enum'; +} + +static startEnum(builder:flatbuffers.Builder) { + builder.startObject(7); +} + +static addName(builder:flatbuffers.Builder, nameOffset:flatbuffers.Offset) { + builder.addFieldOffset(0, nameOffset, 0); +} + +static addValues(builder:flatbuffers.Builder, valuesOffset:flatbuffers.Offset) { + builder.addFieldOffset(1, valuesOffset, 0); +} + +static createValuesVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addOffset(data[i]!); + } + return builder.endVector(); +} + +static startValuesVector(builder:flatbuffers.Builder, numElems:number) { + builder.startVector(4, numElems, 4); +} + +static addIsUnion(builder:flatbuffers.Builder, isUnion:boolean) { + builder.addFieldInt8(2, +isUnion, +false); +} + +static addUnderlyingType(builder:flatbuffers.Builder, underlyingTypeOffset:flatbuffers.Offset) { + builder.addFieldOffset(3, underlyingTypeOffset, 0); +} + +static addAttributes(builder:flatbuffers.Builder, attributesOffset:flatbuffers.Offset) { + builder.addFieldOffset(4, attributesOffset, 0); +} + +static createAttributesVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addOffset(data[i]!); + } + return builder.endVector(); +} + +static startAttributesVector(builder:flatbuffers.Builder, numElems:number) { + builder.startVector(4, numElems, 4); +} + +static addDocumentation(builder:flatbuffers.Builder, documentationOffset:flatbuffers.Offset) { + builder.addFieldOffset(5, documentationOffset, 0); +} + +static createDocumentationVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addOffset(data[i]!); + } + return builder.endVector(); +} + +static startDocumentationVector(builder:flatbuffers.Builder, numElems:number) { + builder.startVector(4, numElems, 4); +} + +static addDeclarationFile(builder:flatbuffers.Builder, declarationFileOffset:flatbuffers.Offset) { + builder.addFieldOffset(6, declarationFileOffset, 0); +} + +static endEnum(builder:flatbuffers.Builder):flatbuffers.Offset { + const offset = builder.endObject(); + builder.requiredField(offset, 4) // name + builder.requiredField(offset, 6) // values + builder.requiredField(offset, 10) // underlying_type + return offset; +} + + +unpack(): EnumT { + return new EnumT( + this.name(), + this.bb!.createObjList(this.values.bind(this), this.valuesLength()), + this.isUnion(), + (this.underlyingType() !== null ? this.underlyingType()!.unpack() : null), + this.bb!.createObjList(this.attributes.bind(this), this.attributesLength()), + this.bb!.createScalarList(this.documentation.bind(this), this.documentationLength()), + this.declarationFile() + ); +} + + +unpackTo(_o: EnumT): void { + _o.name = this.name(); + _o.values = this.bb!.createObjList(this.values.bind(this), this.valuesLength()); + _o.isUnion = this.isUnion(); + _o.underlyingType = (this.underlyingType() !== null ? this.underlyingType()!.unpack() : null); + _o.attributes = this.bb!.createObjList(this.attributes.bind(this), this.attributesLength()); + _o.documentation = this.bb!.createScalarList(this.documentation.bind(this), this.documentationLength()); + _o.declarationFile = this.declarationFile(); +} +} + +export class EnumT { +constructor( + public name: string|Uint8Array|null = null, + public values: (EnumValT)[] = [], + public isUnion: boolean = false, + public underlyingType: TypeT|null = null, + public attributes: (KeyValueT)[] = [], + public documentation: (string)[] = [], + public declarationFile: string|Uint8Array|null = null +){} + + +pack(builder:flatbuffers.Builder): flatbuffers.Offset { + const name = (this.name !== null ? builder.createString(this.name!) : 0); + const values = Enum.createValuesVector(builder, builder.createObjectOffsetList(this.values)); + const underlyingType = (this.underlyingType !== null ? this.underlyingType!.pack(builder) : 0); + const attributes = Enum.createAttributesVector(builder, builder.createObjectOffsetList(this.attributes)); + const documentation = Enum.createDocumentationVector(builder, builder.createObjectOffsetList(this.documentation)); + const declarationFile = (this.declarationFile !== null ? builder.createString(this.declarationFile!) : 0); + + Enum.startEnum(builder); + Enum.addName(builder, name); + Enum.addValues(builder, values); + Enum.addIsUnion(builder, this.isUnion); + Enum.addUnderlyingType(builder, underlyingType); + Enum.addAttributes(builder, attributes); + Enum.addDocumentation(builder, documentation); + Enum.addDeclarationFile(builder, declarationFile); + + return Enum.endEnum(builder); +} +} diff --git a/tests/ts/reflection/field.js b/tests/ts/reflection/field.js new file mode 100644 index 00000000000..107b77bf0d5 --- /dev/null +++ b/tests/ts/reflection/field.js @@ -0,0 +1,284 @@ +// automatically generated by the FlatBuffers compiler, do not modify +import * as flatbuffers from 'flatbuffers'; +import { KeyValue } from '../reflection/key-value.js'; +import { Type } from '../reflection/type.js'; +export class Field { + constructor() { + this.bb = null; + this.bb_pos = 0; + } + __init(i, bb) { + this.bb_pos = i; + this.bb = bb; + return this; + } + static getRootAsField(bb, obj) { + return (obj || new Field()).__init(bb.readInt32(bb.position()) + bb.position(), bb); + } + static getSizePrefixedRootAsField(bb, obj) { + bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); + return (obj || new Field()).__init(bb.readInt32(bb.position()) + bb.position(), bb); + } + name(optionalEncoding) { + const offset = this.bb.__offset(this.bb_pos, 4); + return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null; + } + type(obj) { + const offset = this.bb.__offset(this.bb_pos, 6); + return offset ? (obj || new Type()).__init(this.bb.__indirect(this.bb_pos + offset), this.bb) : null; + } + id() { + const offset = this.bb.__offset(this.bb_pos, 8); + return offset ? this.bb.readUint16(this.bb_pos + offset) : 0; + } + mutate_id(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; + } + offset() { + const offset = this.bb.__offset(this.bb_pos, 10); + return offset ? this.bb.readUint16(this.bb_pos + offset) : 0; + } + mutate_offset(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; + } + defaultInteger() { + const offset = this.bb.__offset(this.bb_pos, 12); + return offset ? this.bb.readInt64(this.bb_pos + offset) : BigInt('0'); + } + mutate_default_integer(value) { + const offset = this.bb.__offset(this.bb_pos, 12); + if (offset === 0) { + return false; + } + this.bb.writeInt64(this.bb_pos + offset, value); + return true; + } + defaultReal() { + const offset = this.bb.__offset(this.bb_pos, 14); + return offset ? this.bb.readFloat64(this.bb_pos + offset) : 0.0; + } + mutate_default_real(value) { + const offset = this.bb.__offset(this.bb_pos, 14); + if (offset === 0) { + return false; + } + this.bb.writeFloat64(this.bb_pos + offset, value); + return true; + } + deprecated() { + const offset = this.bb.__offset(this.bb_pos, 16); + return offset ? !!this.bb.readInt8(this.bb_pos + offset) : false; + } + mutate_deprecated(value) { + const offset = this.bb.__offset(this.bb_pos, 16); + if (offset === 0) { + return false; + } + this.bb.writeInt8(this.bb_pos + offset, +value); + return true; + } + required() { + const offset = this.bb.__offset(this.bb_pos, 18); + return offset ? !!this.bb.readInt8(this.bb_pos + offset) : false; + } + mutate_required(value) { + const offset = this.bb.__offset(this.bb_pos, 18); + if (offset === 0) { + return false; + } + this.bb.writeInt8(this.bb_pos + offset, +value); + return true; + } + key() { + const offset = this.bb.__offset(this.bb_pos, 20); + return offset ? !!this.bb.readInt8(this.bb_pos + offset) : false; + } + mutate_key(value) { + const offset = this.bb.__offset(this.bb_pos, 20); + if (offset === 0) { + return false; + } + this.bb.writeInt8(this.bb_pos + offset, +value); + return true; + } + attributes(index, obj) { + const offset = this.bb.__offset(this.bb_pos, 22); + return offset ? (obj || new KeyValue()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4), this.bb) : null; + } + attributesLength() { + const offset = this.bb.__offset(this.bb_pos, 22); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; + } + documentation(index, optionalEncoding) { + const offset = this.bb.__offset(this.bb_pos, 24); + return offset ? this.bb.__string(this.bb.__vector(this.bb_pos + offset) + index * 4, optionalEncoding) : null; + } + documentationLength() { + const offset = this.bb.__offset(this.bb_pos, 24); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; + } + optional() { + const offset = this.bb.__offset(this.bb_pos, 26); + return offset ? !!this.bb.readInt8(this.bb_pos + offset) : false; + } + mutate_optional(value) { + const offset = this.bb.__offset(this.bb_pos, 26); + if (offset === 0) { + return false; + } + this.bb.writeInt8(this.bb_pos + offset, +value); + return true; + } + /** + * Number of padding octets to always add after this field. Structs only. + */ + padding() { + const offset = this.bb.__offset(this.bb_pos, 28); + return offset ? this.bb.readUint16(this.bb_pos + offset) : 0; + } + mutate_padding(value) { + const offset = this.bb.__offset(this.bb_pos, 28); + if (offset === 0) { + return false; + } + this.bb.writeUint16(this.bb_pos + offset, value); + return true; + } + static getFullyQualifiedName() { + return 'reflection_Field'; + } + static startField(builder) { + builder.startObject(13); + } + static addName(builder, nameOffset) { + builder.addFieldOffset(0, nameOffset, 0); + } + static addType(builder, typeOffset) { + builder.addFieldOffset(1, typeOffset, 0); + } + static addId(builder, id) { + builder.addFieldInt16(2, id, 0); + } + static addOffset(builder, offset) { + builder.addFieldInt16(3, offset, 0); + } + static addDefaultInteger(builder, defaultInteger) { + builder.addFieldInt64(4, defaultInteger, BigInt('0')); + } + static addDefaultReal(builder, defaultReal) { + builder.addFieldFloat64(5, defaultReal, 0.0); + } + static addDeprecated(builder, deprecated) { + builder.addFieldInt8(6, +deprecated, +false); + } + static addRequired(builder, required) { + builder.addFieldInt8(7, +required, +false); + } + static addKey(builder, key) { + builder.addFieldInt8(8, +key, +false); + } + static addAttributes(builder, attributesOffset) { + builder.addFieldOffset(9, attributesOffset, 0); + } + static createAttributesVector(builder, data) { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addOffset(data[i]); + } + return builder.endVector(); + } + static startAttributesVector(builder, numElems) { + builder.startVector(4, numElems, 4); + } + static addDocumentation(builder, documentationOffset) { + builder.addFieldOffset(10, documentationOffset, 0); + } + static createDocumentationVector(builder, data) { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addOffset(data[i]); + } + return builder.endVector(); + } + static startDocumentationVector(builder, numElems) { + builder.startVector(4, numElems, 4); + } + static addOptional(builder, optional) { + builder.addFieldInt8(11, +optional, +false); + } + static addPadding(builder, padding) { + builder.addFieldInt16(12, padding, 0); + } + static endField(builder) { + const offset = builder.endObject(); + builder.requiredField(offset, 4); // name + builder.requiredField(offset, 6); // type + return offset; + } + unpack() { + return new FieldT(this.name(), (this.type() !== null ? this.type().unpack() : null), this.id(), this.offset(), this.defaultInteger(), this.defaultReal(), this.deprecated(), this.required(), this.key(), this.bb.createObjList(this.attributes.bind(this), this.attributesLength()), this.bb.createScalarList(this.documentation.bind(this), this.documentationLength()), this.optional(), this.padding()); + } + unpackTo(_o) { + _o.name = this.name(); + _o.type = (this.type() !== null ? this.type().unpack() : null); + _o.id = this.id(); + _o.offset = this.offset(); + _o.defaultInteger = this.defaultInteger(); + _o.defaultReal = this.defaultReal(); + _o.deprecated = this.deprecated(); + _o.required = this.required(); + _o.key = this.key(); + _o.attributes = this.bb.createObjList(this.attributes.bind(this), this.attributesLength()); + _o.documentation = this.bb.createScalarList(this.documentation.bind(this), this.documentationLength()); + _o.optional = this.optional(); + _o.padding = this.padding(); + } +} +export class FieldT { + constructor(name = null, type = null, id = 0, offset = 0, defaultInteger = BigInt('0'), defaultReal = 0.0, deprecated = false, required = false, key = false, attributes = [], documentation = [], optional = false, padding = 0) { + this.name = name; + this.type = type; + this.id = id; + this.offset = offset; + this.defaultInteger = defaultInteger; + this.defaultReal = defaultReal; + this.deprecated = deprecated; + this.required = required; + this.key = key; + this.attributes = attributes; + this.documentation = documentation; + this.optional = optional; + this.padding = padding; + } + pack(builder) { + const name = (this.name !== null ? builder.createString(this.name) : 0); + const type = (this.type !== null ? this.type.pack(builder) : 0); + const attributes = Field.createAttributesVector(builder, builder.createObjectOffsetList(this.attributes)); + const documentation = Field.createDocumentationVector(builder, builder.createObjectOffsetList(this.documentation)); + Field.startField(builder); + Field.addName(builder, name); + Field.addType(builder, type); + Field.addId(builder, this.id); + Field.addOffset(builder, this.offset); + Field.addDefaultInteger(builder, this.defaultInteger); + Field.addDefaultReal(builder, this.defaultReal); + Field.addDeprecated(builder, this.deprecated); + Field.addRequired(builder, this.required); + Field.addKey(builder, this.key); + Field.addAttributes(builder, attributes); + Field.addDocumentation(builder, documentation); + Field.addOptional(builder, this.optional); + Field.addPadding(builder, this.padding); + return Field.endField(builder); + } +} diff --git a/tests/ts/reflection/field.ts b/tests/ts/reflection/field.ts new file mode 100644 index 00000000000..48c1bed16e9 --- /dev/null +++ b/tests/ts/reflection/field.ts @@ -0,0 +1,377 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +import * as flatbuffers from 'flatbuffers'; + +import { KeyValue, KeyValueT } from '../reflection/key-value.js'; +import { Type, TypeT } from '../reflection/type.js'; + + +export class Field { + bb: flatbuffers.ByteBuffer|null = null; + bb_pos = 0; + __init(i:number, bb:flatbuffers.ByteBuffer):Field { + this.bb_pos = i; + this.bb = bb; + return this; +} + +static getRootAsField(bb:flatbuffers.ByteBuffer, obj?:Field):Field { + return (obj || new Field()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +static getSizePrefixedRootAsField(bb:flatbuffers.ByteBuffer, obj?:Field):Field { + bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); + return (obj || new Field()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +name():string|null +name(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null +name(optionalEncoding?:any):string|Uint8Array|null { + const offset = this.bb!.__offset(this.bb_pos, 4); + return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; +} + +type(obj?:Type):Type|null { + const offset = this.bb!.__offset(this.bb_pos, 6); + return offset ? (obj || new Type()).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null; +} + +id():number { + const offset = this.bb!.__offset(this.bb_pos, 8); + return offset ? this.bb!.readUint16(this.bb_pos + offset) : 0; +} + +mutate_id(value:number):boolean { + const offset = this.bb!.__offset(this.bb_pos, 8); + + if (offset === 0) { + return false; + } + + this.bb!.writeUint16(this.bb_pos + offset, value); + return true; +} + +offset():number { + const offset = this.bb!.__offset(this.bb_pos, 10); + return offset ? this.bb!.readUint16(this.bb_pos + offset) : 0; +} + +mutate_offset(value:number):boolean { + const offset = this.bb!.__offset(this.bb_pos, 10); + + if (offset === 0) { + return false; + } + + this.bb!.writeUint16(this.bb_pos + offset, value); + return true; +} + +defaultInteger():bigint { + const offset = this.bb!.__offset(this.bb_pos, 12); + return offset ? this.bb!.readInt64(this.bb_pos + offset) : BigInt('0'); +} + +mutate_default_integer(value:bigint):boolean { + const offset = this.bb!.__offset(this.bb_pos, 12); + + if (offset === 0) { + return false; + } + + this.bb!.writeInt64(this.bb_pos + offset, value); + return true; +} + +defaultReal():number { + const offset = this.bb!.__offset(this.bb_pos, 14); + return offset ? this.bb!.readFloat64(this.bb_pos + offset) : 0.0; +} + +mutate_default_real(value:number):boolean { + const offset = this.bb!.__offset(this.bb_pos, 14); + + if (offset === 0) { + return false; + } + + this.bb!.writeFloat64(this.bb_pos + offset, value); + return true; +} + +deprecated():boolean { + const offset = this.bb!.__offset(this.bb_pos, 16); + return offset ? !!this.bb!.readInt8(this.bb_pos + offset) : false; +} + +mutate_deprecated(value:boolean):boolean { + const offset = this.bb!.__offset(this.bb_pos, 16); + + if (offset === 0) { + return false; + } + + this.bb!.writeInt8(this.bb_pos + offset, +value); + return true; +} + +required():boolean { + const offset = this.bb!.__offset(this.bb_pos, 18); + return offset ? !!this.bb!.readInt8(this.bb_pos + offset) : false; +} + +mutate_required(value:boolean):boolean { + const offset = this.bb!.__offset(this.bb_pos, 18); + + if (offset === 0) { + return false; + } + + this.bb!.writeInt8(this.bb_pos + offset, +value); + return true; +} + +key():boolean { + const offset = this.bb!.__offset(this.bb_pos, 20); + return offset ? !!this.bb!.readInt8(this.bb_pos + offset) : false; +} + +mutate_key(value:boolean):boolean { + const offset = this.bb!.__offset(this.bb_pos, 20); + + if (offset === 0) { + return false; + } + + this.bb!.writeInt8(this.bb_pos + offset, +value); + return true; +} + +attributes(index: number, obj?:KeyValue):KeyValue|null { + const offset = this.bb!.__offset(this.bb_pos, 22); + return offset ? (obj || new KeyValue()).__init(this.bb!.__indirect(this.bb!.__vector(this.bb_pos + offset) + index * 4), this.bb!) : null; +} + +attributesLength():number { + const offset = this.bb!.__offset(this.bb_pos, 22); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +} + +documentation(index: number):string +documentation(index: number,optionalEncoding:flatbuffers.Encoding):string|Uint8Array +documentation(index: number,optionalEncoding?:any):string|Uint8Array|null { + const offset = this.bb!.__offset(this.bb_pos, 24); + return offset ? this.bb!.__string(this.bb!.__vector(this.bb_pos + offset) + index * 4, optionalEncoding) : null; +} + +documentationLength():number { + const offset = this.bb!.__offset(this.bb_pos, 24); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +} + +optional():boolean { + const offset = this.bb!.__offset(this.bb_pos, 26); + return offset ? !!this.bb!.readInt8(this.bb_pos + offset) : false; +} + +mutate_optional(value:boolean):boolean { + const offset = this.bb!.__offset(this.bb_pos, 26); + + if (offset === 0) { + return false; + } + + this.bb!.writeInt8(this.bb_pos + offset, +value); + return true; +} + +/** + * Number of padding octets to always add after this field. Structs only. + */ +padding():number { + const offset = this.bb!.__offset(this.bb_pos, 28); + return offset ? this.bb!.readUint16(this.bb_pos + offset) : 0; +} + +mutate_padding(value:number):boolean { + const offset = this.bb!.__offset(this.bb_pos, 28); + + if (offset === 0) { + return false; + } + + this.bb!.writeUint16(this.bb_pos + offset, value); + return true; +} + +static getFullyQualifiedName():string { + return 'reflection_Field'; +} + +static startField(builder:flatbuffers.Builder) { + builder.startObject(13); +} + +static addName(builder:flatbuffers.Builder, nameOffset:flatbuffers.Offset) { + builder.addFieldOffset(0, nameOffset, 0); +} + +static addType(builder:flatbuffers.Builder, typeOffset:flatbuffers.Offset) { + builder.addFieldOffset(1, typeOffset, 0); +} + +static addId(builder:flatbuffers.Builder, id:number) { + builder.addFieldInt16(2, id, 0); +} + +static addOffset(builder:flatbuffers.Builder, offset:number) { + builder.addFieldInt16(3, offset, 0); +} + +static addDefaultInteger(builder:flatbuffers.Builder, defaultInteger:bigint) { + builder.addFieldInt64(4, defaultInteger, BigInt('0')); +} + +static addDefaultReal(builder:flatbuffers.Builder, defaultReal:number) { + builder.addFieldFloat64(5, defaultReal, 0.0); +} + +static addDeprecated(builder:flatbuffers.Builder, deprecated:boolean) { + builder.addFieldInt8(6, +deprecated, +false); +} + +static addRequired(builder:flatbuffers.Builder, required:boolean) { + builder.addFieldInt8(7, +required, +false); +} + +static addKey(builder:flatbuffers.Builder, key:boolean) { + builder.addFieldInt8(8, +key, +false); +} + +static addAttributes(builder:flatbuffers.Builder, attributesOffset:flatbuffers.Offset) { + builder.addFieldOffset(9, attributesOffset, 0); +} + +static createAttributesVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addOffset(data[i]!); + } + return builder.endVector(); +} + +static startAttributesVector(builder:flatbuffers.Builder, numElems:number) { + builder.startVector(4, numElems, 4); +} + +static addDocumentation(builder:flatbuffers.Builder, documentationOffset:flatbuffers.Offset) { + builder.addFieldOffset(10, documentationOffset, 0); +} + +static createDocumentationVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addOffset(data[i]!); + } + return builder.endVector(); +} + +static startDocumentationVector(builder:flatbuffers.Builder, numElems:number) { + builder.startVector(4, numElems, 4); +} + +static addOptional(builder:flatbuffers.Builder, optional:boolean) { + builder.addFieldInt8(11, +optional, +false); +} + +static addPadding(builder:flatbuffers.Builder, padding:number) { + builder.addFieldInt16(12, padding, 0); +} + +static endField(builder:flatbuffers.Builder):flatbuffers.Offset { + const offset = builder.endObject(); + builder.requiredField(offset, 4) // name + builder.requiredField(offset, 6) // type + return offset; +} + + +unpack(): FieldT { + return new FieldT( + this.name(), + (this.type() !== null ? this.type()!.unpack() : null), + this.id(), + this.offset(), + this.defaultInteger(), + this.defaultReal(), + this.deprecated(), + this.required(), + this.key(), + this.bb!.createObjList(this.attributes.bind(this), this.attributesLength()), + this.bb!.createScalarList(this.documentation.bind(this), this.documentationLength()), + this.optional(), + this.padding() + ); +} + + +unpackTo(_o: FieldT): void { + _o.name = this.name(); + _o.type = (this.type() !== null ? this.type()!.unpack() : null); + _o.id = this.id(); + _o.offset = this.offset(); + _o.defaultInteger = this.defaultInteger(); + _o.defaultReal = this.defaultReal(); + _o.deprecated = this.deprecated(); + _o.required = this.required(); + _o.key = this.key(); + _o.attributes = this.bb!.createObjList(this.attributes.bind(this), this.attributesLength()); + _o.documentation = this.bb!.createScalarList(this.documentation.bind(this), this.documentationLength()); + _o.optional = this.optional(); + _o.padding = this.padding(); +} +} + +export class FieldT { +constructor( + public name: string|Uint8Array|null = null, + public type: TypeT|null = null, + public id: number = 0, + public offset: number = 0, + public defaultInteger: bigint = BigInt('0'), + public defaultReal: number = 0.0, + public deprecated: boolean = false, + public required: boolean = false, + public key: boolean = false, + public attributes: (KeyValueT)[] = [], + public documentation: (string)[] = [], + public optional: boolean = false, + public padding: number = 0 +){} + + +pack(builder:flatbuffers.Builder): flatbuffers.Offset { + const name = (this.name !== null ? builder.createString(this.name!) : 0); + const type = (this.type !== null ? this.type!.pack(builder) : 0); + const attributes = Field.createAttributesVector(builder, builder.createObjectOffsetList(this.attributes)); + const documentation = Field.createDocumentationVector(builder, builder.createObjectOffsetList(this.documentation)); + + Field.startField(builder); + Field.addName(builder, name); + Field.addType(builder, type); + Field.addId(builder, this.id); + Field.addOffset(builder, this.offset); + Field.addDefaultInteger(builder, this.defaultInteger); + Field.addDefaultReal(builder, this.defaultReal); + Field.addDeprecated(builder, this.deprecated); + Field.addRequired(builder, this.required); + Field.addKey(builder, this.key); + Field.addAttributes(builder, attributes); + Field.addDocumentation(builder, documentation); + Field.addOptional(builder, this.optional); + Field.addPadding(builder, this.padding); + + return Field.endField(builder); +} +} diff --git a/tests/ts/reflection/key-value.js b/tests/ts/reflection/key-value.js new file mode 100644 index 00000000000..622b4f2a884 --- /dev/null +++ b/tests/ts/reflection/key-value.js @@ -0,0 +1,69 @@ +// automatically generated by the FlatBuffers compiler, do not modify +import * as flatbuffers from 'flatbuffers'; +export class KeyValue { + constructor() { + this.bb = null; + this.bb_pos = 0; + } + __init(i, bb) { + this.bb_pos = i; + this.bb = bb; + return this; + } + static getRootAsKeyValue(bb, obj) { + return (obj || new KeyValue()).__init(bb.readInt32(bb.position()) + bb.position(), bb); + } + static getSizePrefixedRootAsKeyValue(bb, obj) { + bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); + return (obj || new KeyValue()).__init(bb.readInt32(bb.position()) + bb.position(), bb); + } + key(optionalEncoding) { + const offset = this.bb.__offset(this.bb_pos, 4); + return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null; + } + value(optionalEncoding) { + const offset = this.bb.__offset(this.bb_pos, 6); + return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null; + } + static getFullyQualifiedName() { + return 'reflection_KeyValue'; + } + static startKeyValue(builder) { + builder.startObject(2); + } + static addKey(builder, keyOffset) { + builder.addFieldOffset(0, keyOffset, 0); + } + static addValue(builder, valueOffset) { + builder.addFieldOffset(1, valueOffset, 0); + } + static endKeyValue(builder) { + const offset = builder.endObject(); + builder.requiredField(offset, 4); // key + return offset; + } + static createKeyValue(builder, keyOffset, valueOffset) { + KeyValue.startKeyValue(builder); + KeyValue.addKey(builder, keyOffset); + KeyValue.addValue(builder, valueOffset); + return KeyValue.endKeyValue(builder); + } + unpack() { + return new KeyValueT(this.key(), this.value()); + } + unpackTo(_o) { + _o.key = this.key(); + _o.value = this.value(); + } +} +export class KeyValueT { + constructor(key = null, value = null) { + this.key = key; + this.value = value; + } + pack(builder) { + const key = (this.key !== null ? builder.createString(this.key) : 0); + const value = (this.value !== null ? builder.createString(this.value) : 0); + return KeyValue.createKeyValue(builder, key, value); + } +} diff --git a/tests/ts/reflection/key-value.ts b/tests/ts/reflection/key-value.ts new file mode 100644 index 00000000000..736766b972a --- /dev/null +++ b/tests/ts/reflection/key-value.ts @@ -0,0 +1,98 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +import * as flatbuffers from 'flatbuffers'; + + + +export class KeyValue { + bb: flatbuffers.ByteBuffer|null = null; + bb_pos = 0; + __init(i:number, bb:flatbuffers.ByteBuffer):KeyValue { + this.bb_pos = i; + this.bb = bb; + return this; +} + +static getRootAsKeyValue(bb:flatbuffers.ByteBuffer, obj?:KeyValue):KeyValue { + return (obj || new KeyValue()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +static getSizePrefixedRootAsKeyValue(bb:flatbuffers.ByteBuffer, obj?:KeyValue):KeyValue { + bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); + return (obj || new KeyValue()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +key():string|null +key(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null +key(optionalEncoding?:any):string|Uint8Array|null { + const offset = this.bb!.__offset(this.bb_pos, 4); + return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; +} + +value():string|null +value(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null +value(optionalEncoding?:any):string|Uint8Array|null { + const offset = this.bb!.__offset(this.bb_pos, 6); + return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; +} + +static getFullyQualifiedName():string { + return 'reflection_KeyValue'; +} + +static startKeyValue(builder:flatbuffers.Builder) { + builder.startObject(2); +} + +static addKey(builder:flatbuffers.Builder, keyOffset:flatbuffers.Offset) { + builder.addFieldOffset(0, keyOffset, 0); +} + +static addValue(builder:flatbuffers.Builder, valueOffset:flatbuffers.Offset) { + builder.addFieldOffset(1, valueOffset, 0); +} + +static endKeyValue(builder:flatbuffers.Builder):flatbuffers.Offset { + const offset = builder.endObject(); + builder.requiredField(offset, 4) // key + return offset; +} + +static createKeyValue(builder:flatbuffers.Builder, keyOffset:flatbuffers.Offset, valueOffset:flatbuffers.Offset):flatbuffers.Offset { + KeyValue.startKeyValue(builder); + KeyValue.addKey(builder, keyOffset); + KeyValue.addValue(builder, valueOffset); + return KeyValue.endKeyValue(builder); +} + +unpack(): KeyValueT { + return new KeyValueT( + this.key(), + this.value() + ); +} + + +unpackTo(_o: KeyValueT): void { + _o.key = this.key(); + _o.value = this.value(); +} +} + +export class KeyValueT { +constructor( + public key: string|Uint8Array|null = null, + public value: string|Uint8Array|null = null +){} + + +pack(builder:flatbuffers.Builder): flatbuffers.Offset { + const key = (this.key !== null ? builder.createString(this.key!) : 0); + const value = (this.value !== null ? builder.createString(this.value!) : 0); + + return KeyValue.createKeyValue(builder, + key, + value + ); +} +} diff --git a/tests/ts/reflection/object.js b/tests/ts/reflection/object.js new file mode 100644 index 00000000000..d2885455a7b --- /dev/null +++ b/tests/ts/reflection/object.js @@ -0,0 +1,201 @@ +// automatically generated by the FlatBuffers compiler, do not modify +import * as flatbuffers from 'flatbuffers'; +import { Field } from '../reflection/field.js'; +import { KeyValue } from '../reflection/key-value.js'; +export class Object_ { + constructor() { + this.bb = null; + this.bb_pos = 0; + } + __init(i, bb) { + this.bb_pos = i; + this.bb = bb; + return this; + } + static getRootAsObject(bb, obj) { + return (obj || new Object_()).__init(bb.readInt32(bb.position()) + bb.position(), bb); + } + static getSizePrefixedRootAsObject(bb, obj) { + bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); + return (obj || new Object_()).__init(bb.readInt32(bb.position()) + bb.position(), bb); + } + name(optionalEncoding) { + const offset = this.bb.__offset(this.bb_pos, 4); + return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null; + } + fields(index, obj) { + const offset = this.bb.__offset(this.bb_pos, 6); + return offset ? (obj || new Field()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4), this.bb) : null; + } + fieldsLength() { + const offset = this.bb.__offset(this.bb_pos, 6); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; + } + isStruct() { + const offset = this.bb.__offset(this.bb_pos, 8); + return offset ? !!this.bb.readInt8(this.bb_pos + offset) : false; + } + mutate_is_struct(value) { + const offset = this.bb.__offset(this.bb_pos, 8); + if (offset === 0) { + return false; + } + this.bb.writeInt8(this.bb_pos + offset, +value); + return true; + } + minalign() { + const offset = this.bb.__offset(this.bb_pos, 10); + return offset ? this.bb.readInt32(this.bb_pos + offset) : 0; + } + mutate_minalign(value) { + const offset = this.bb.__offset(this.bb_pos, 10); + if (offset === 0) { + return false; + } + this.bb.writeInt32(this.bb_pos + offset, value); + return true; + } + bytesize() { + const offset = this.bb.__offset(this.bb_pos, 12); + return offset ? this.bb.readInt32(this.bb_pos + offset) : 0; + } + mutate_bytesize(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; + } + attributes(index, obj) { + const offset = this.bb.__offset(this.bb_pos, 14); + return offset ? (obj || new KeyValue()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4), this.bb) : null; + } + attributesLength() { + const offset = this.bb.__offset(this.bb_pos, 14); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; + } + documentation(index, optionalEncoding) { + const offset = this.bb.__offset(this.bb_pos, 16); + return offset ? this.bb.__string(this.bb.__vector(this.bb_pos + offset) + index * 4, optionalEncoding) : null; + } + documentationLength() { + const offset = this.bb.__offset(this.bb_pos, 16); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; + } + declarationFile(optionalEncoding) { + const offset = this.bb.__offset(this.bb_pos, 18); + return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null; + } + static getFullyQualifiedName() { + return 'reflection_Object'; + } + static startObject(builder) { + builder.startObject(8); + } + static addName(builder, nameOffset) { + builder.addFieldOffset(0, nameOffset, 0); + } + static addFields(builder, fieldsOffset) { + builder.addFieldOffset(1, fieldsOffset, 0); + } + static createFieldsVector(builder, data) { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addOffset(data[i]); + } + return builder.endVector(); + } + static startFieldsVector(builder, numElems) { + builder.startVector(4, numElems, 4); + } + static addIsStruct(builder, isStruct) { + builder.addFieldInt8(2, +isStruct, +false); + } + static addMinalign(builder, minalign) { + builder.addFieldInt32(3, minalign, 0); + } + static addBytesize(builder, bytesize) { + builder.addFieldInt32(4, bytesize, 0); + } + static addAttributes(builder, attributesOffset) { + builder.addFieldOffset(5, attributesOffset, 0); + } + static createAttributesVector(builder, data) { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addOffset(data[i]); + } + return builder.endVector(); + } + static startAttributesVector(builder, numElems) { + builder.startVector(4, numElems, 4); + } + static addDocumentation(builder, documentationOffset) { + builder.addFieldOffset(6, documentationOffset, 0); + } + static createDocumentationVector(builder, data) { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addOffset(data[i]); + } + return builder.endVector(); + } + static startDocumentationVector(builder, numElems) { + builder.startVector(4, numElems, 4); + } + static addDeclarationFile(builder, declarationFileOffset) { + builder.addFieldOffset(7, declarationFileOffset, 0); + } + static endObject(builder) { + const offset = builder.endObject(); + builder.requiredField(offset, 4); // name + builder.requiredField(offset, 6); // fields + return offset; + } + static createObject(builder, nameOffset, fieldsOffset, isStruct, minalign, bytesize, attributesOffset, documentationOffset, declarationFileOffset) { + Object_.startObject(builder); + Object_.addName(builder, nameOffset); + Object_.addFields(builder, fieldsOffset); + Object_.addIsStruct(builder, isStruct); + Object_.addMinalign(builder, minalign); + Object_.addBytesize(builder, bytesize); + Object_.addAttributes(builder, attributesOffset); + Object_.addDocumentation(builder, documentationOffset); + Object_.addDeclarationFile(builder, declarationFileOffset); + return Object_.endObject(builder); + } + unpack() { + return new Object_T(this.name(), this.bb.createObjList(this.fields.bind(this), this.fieldsLength()), this.isStruct(), this.minalign(), this.bytesize(), this.bb.createObjList(this.attributes.bind(this), this.attributesLength()), this.bb.createScalarList(this.documentation.bind(this), this.documentationLength()), this.declarationFile()); + } + unpackTo(_o) { + _o.name = this.name(); + _o.fields = this.bb.createObjList(this.fields.bind(this), this.fieldsLength()); + _o.isStruct = this.isStruct(); + _o.minalign = this.minalign(); + _o.bytesize = this.bytesize(); + _o.attributes = this.bb.createObjList(this.attributes.bind(this), this.attributesLength()); + _o.documentation = this.bb.createScalarList(this.documentation.bind(this), this.documentationLength()); + _o.declarationFile = this.declarationFile(); + } +} +export class Object_T { + constructor(name = null, fields = [], isStruct = false, minalign = 0, bytesize = 0, attributes = [], documentation = [], declarationFile = null) { + this.name = name; + this.fields = fields; + this.isStruct = isStruct; + this.minalign = minalign; + this.bytesize = bytesize; + this.attributes = attributes; + this.documentation = documentation; + this.declarationFile = declarationFile; + } + pack(builder) { + const name = (this.name !== null ? builder.createString(this.name) : 0); + const fields = Object_.createFieldsVector(builder, builder.createObjectOffsetList(this.fields)); + const attributes = Object_.createAttributesVector(builder, builder.createObjectOffsetList(this.attributes)); + const documentation = Object_.createDocumentationVector(builder, builder.createObjectOffsetList(this.documentation)); + const declarationFile = (this.declarationFile !== null ? builder.createString(this.declarationFile) : 0); + return Object_.createObject(builder, name, fields, this.isStruct, this.minalign, this.bytesize, attributes, documentation, declarationFile); + } +} diff --git a/tests/ts/reflection/object.ts b/tests/ts/reflection/object.ts new file mode 100644 index 00000000000..1e14f039bea --- /dev/null +++ b/tests/ts/reflection/object.ts @@ -0,0 +1,277 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +import * as flatbuffers from 'flatbuffers'; + +import { Field, FieldT } from '../reflection/field.js'; +import { KeyValue, KeyValueT } from '../reflection/key-value.js'; + + +export class Object_ { + bb: flatbuffers.ByteBuffer|null = null; + bb_pos = 0; + __init(i:number, bb:flatbuffers.ByteBuffer):Object_ { + this.bb_pos = i; + this.bb = bb; + return this; +} + +static getRootAsObject(bb:flatbuffers.ByteBuffer, obj?:Object_):Object_ { + return (obj || new Object_()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +static getSizePrefixedRootAsObject(bb:flatbuffers.ByteBuffer, obj?:Object_):Object_ { + bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); + return (obj || new Object_()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +name():string|null +name(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null +name(optionalEncoding?:any):string|Uint8Array|null { + const offset = this.bb!.__offset(this.bb_pos, 4); + return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; +} + +fields(index: number, obj?:Field):Field|null { + const offset = this.bb!.__offset(this.bb_pos, 6); + return offset ? (obj || new Field()).__init(this.bb!.__indirect(this.bb!.__vector(this.bb_pos + offset) + index * 4), this.bb!) : null; +} + +fieldsLength():number { + const offset = this.bb!.__offset(this.bb_pos, 6); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +} + +isStruct():boolean { + const offset = this.bb!.__offset(this.bb_pos, 8); + return offset ? !!this.bb!.readInt8(this.bb_pos + offset) : false; +} + +mutate_is_struct(value:boolean):boolean { + const offset = this.bb!.__offset(this.bb_pos, 8); + + if (offset === 0) { + return false; + } + + this.bb!.writeInt8(this.bb_pos + offset, +value); + return true; +} + +minalign():number { + const offset = this.bb!.__offset(this.bb_pos, 10); + return offset ? this.bb!.readInt32(this.bb_pos + offset) : 0; +} + +mutate_minalign(value:number):boolean { + const offset = this.bb!.__offset(this.bb_pos, 10); + + if (offset === 0) { + return false; + } + + this.bb!.writeInt32(this.bb_pos + offset, value); + return true; +} + +bytesize():number { + const offset = this.bb!.__offset(this.bb_pos, 12); + return offset ? this.bb!.readInt32(this.bb_pos + offset) : 0; +} + +mutate_bytesize(value:number):boolean { + const offset = this.bb!.__offset(this.bb_pos, 12); + + if (offset === 0) { + return false; + } + + this.bb!.writeInt32(this.bb_pos + offset, value); + return true; +} + +attributes(index: number, obj?:KeyValue):KeyValue|null { + const offset = this.bb!.__offset(this.bb_pos, 14); + return offset ? (obj || new KeyValue()).__init(this.bb!.__indirect(this.bb!.__vector(this.bb_pos + offset) + index * 4), this.bb!) : null; +} + +attributesLength():number { + const offset = this.bb!.__offset(this.bb_pos, 14); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +} + +documentation(index: number):string +documentation(index: number,optionalEncoding:flatbuffers.Encoding):string|Uint8Array +documentation(index: number,optionalEncoding?:any):string|Uint8Array|null { + const offset = this.bb!.__offset(this.bb_pos, 16); + return offset ? this.bb!.__string(this.bb!.__vector(this.bb_pos + offset) + index * 4, optionalEncoding) : null; +} + +documentationLength():number { + const offset = this.bb!.__offset(this.bb_pos, 16); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +} + +/** + * File that this Object is declared in. + */ +declarationFile():string|null +declarationFile(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null +declarationFile(optionalEncoding?:any):string|Uint8Array|null { + const offset = this.bb!.__offset(this.bb_pos, 18); + return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; +} + +static getFullyQualifiedName():string { + return 'reflection_Object'; +} + +static startObject(builder:flatbuffers.Builder) { + builder.startObject(8); +} + +static addName(builder:flatbuffers.Builder, nameOffset:flatbuffers.Offset) { + builder.addFieldOffset(0, nameOffset, 0); +} + +static addFields(builder:flatbuffers.Builder, fieldsOffset:flatbuffers.Offset) { + builder.addFieldOffset(1, fieldsOffset, 0); +} + +static createFieldsVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addOffset(data[i]!); + } + return builder.endVector(); +} + +static startFieldsVector(builder:flatbuffers.Builder, numElems:number) { + builder.startVector(4, numElems, 4); +} + +static addIsStruct(builder:flatbuffers.Builder, isStruct:boolean) { + builder.addFieldInt8(2, +isStruct, +false); +} + +static addMinalign(builder:flatbuffers.Builder, minalign:number) { + builder.addFieldInt32(3, minalign, 0); +} + +static addBytesize(builder:flatbuffers.Builder, bytesize:number) { + builder.addFieldInt32(4, bytesize, 0); +} + +static addAttributes(builder:flatbuffers.Builder, attributesOffset:flatbuffers.Offset) { + builder.addFieldOffset(5, attributesOffset, 0); +} + +static createAttributesVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addOffset(data[i]!); + } + return builder.endVector(); +} + +static startAttributesVector(builder:flatbuffers.Builder, numElems:number) { + builder.startVector(4, numElems, 4); +} + +static addDocumentation(builder:flatbuffers.Builder, documentationOffset:flatbuffers.Offset) { + builder.addFieldOffset(6, documentationOffset, 0); +} + +static createDocumentationVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addOffset(data[i]!); + } + return builder.endVector(); +} + +static startDocumentationVector(builder:flatbuffers.Builder, numElems:number) { + builder.startVector(4, numElems, 4); +} + +static addDeclarationFile(builder:flatbuffers.Builder, declarationFileOffset:flatbuffers.Offset) { + builder.addFieldOffset(7, declarationFileOffset, 0); +} + +static endObject(builder:flatbuffers.Builder):flatbuffers.Offset { + const offset = builder.endObject(); + builder.requiredField(offset, 4) // name + builder.requiredField(offset, 6) // fields + return offset; +} + +static createObject(builder:flatbuffers.Builder, nameOffset:flatbuffers.Offset, fieldsOffset:flatbuffers.Offset, isStruct:boolean, minalign:number, bytesize:number, attributesOffset:flatbuffers.Offset, documentationOffset:flatbuffers.Offset, declarationFileOffset:flatbuffers.Offset):flatbuffers.Offset { + Object_.startObject(builder); + Object_.addName(builder, nameOffset); + Object_.addFields(builder, fieldsOffset); + Object_.addIsStruct(builder, isStruct); + Object_.addMinalign(builder, minalign); + Object_.addBytesize(builder, bytesize); + Object_.addAttributes(builder, attributesOffset); + Object_.addDocumentation(builder, documentationOffset); + Object_.addDeclarationFile(builder, declarationFileOffset); + return Object_.endObject(builder); +} + +unpack(): Object_T { + return new Object_T( + this.name(), + this.bb!.createObjList(this.fields.bind(this), this.fieldsLength()), + this.isStruct(), + this.minalign(), + this.bytesize(), + this.bb!.createObjList(this.attributes.bind(this), this.attributesLength()), + this.bb!.createScalarList(this.documentation.bind(this), this.documentationLength()), + this.declarationFile() + ); +} + + +unpackTo(_o: Object_T): void { + _o.name = this.name(); + _o.fields = this.bb!.createObjList(this.fields.bind(this), this.fieldsLength()); + _o.isStruct = this.isStruct(); + _o.minalign = this.minalign(); + _o.bytesize = this.bytesize(); + _o.attributes = this.bb!.createObjList(this.attributes.bind(this), this.attributesLength()); + _o.documentation = this.bb!.createScalarList(this.documentation.bind(this), this.documentationLength()); + _o.declarationFile = this.declarationFile(); +} +} + +export class Object_T { +constructor( + public name: string|Uint8Array|null = null, + public fields: (FieldT)[] = [], + public isStruct: boolean = false, + public minalign: number = 0, + public bytesize: number = 0, + public attributes: (KeyValueT)[] = [], + public documentation: (string)[] = [], + public declarationFile: string|Uint8Array|null = null +){} + + +pack(builder:flatbuffers.Builder): flatbuffers.Offset { + const name = (this.name !== null ? builder.createString(this.name!) : 0); + const fields = Object_.createFieldsVector(builder, builder.createObjectOffsetList(this.fields)); + const attributes = Object_.createAttributesVector(builder, builder.createObjectOffsetList(this.attributes)); + const documentation = Object_.createDocumentationVector(builder, builder.createObjectOffsetList(this.documentation)); + const declarationFile = (this.declarationFile !== null ? builder.createString(this.declarationFile!) : 0); + + return Object_.createObject(builder, + name, + fields, + this.isStruct, + this.minalign, + this.bytesize, + attributes, + documentation, + declarationFile + ); +} +} diff --git a/tests/ts/reflection/rpccall.js b/tests/ts/reflection/rpccall.js new file mode 100644 index 00000000000..96e92eb3f56 --- /dev/null +++ b/tests/ts/reflection/rpccall.js @@ -0,0 +1,131 @@ +// automatically generated by the FlatBuffers compiler, do not modify +import * as flatbuffers from 'flatbuffers'; +import { KeyValue } from '../reflection/key-value.js'; +import { Object_ } from '../reflection/object.js'; +export class RPCCall { + constructor() { + this.bb = null; + this.bb_pos = 0; + } + __init(i, bb) { + this.bb_pos = i; + this.bb = bb; + return this; + } + static getRootAsRPCCall(bb, obj) { + return (obj || new RPCCall()).__init(bb.readInt32(bb.position()) + bb.position(), bb); + } + static getSizePrefixedRootAsRPCCall(bb, obj) { + bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); + return (obj || new RPCCall()).__init(bb.readInt32(bb.position()) + bb.position(), bb); + } + name(optionalEncoding) { + const offset = this.bb.__offset(this.bb_pos, 4); + return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null; + } + request(obj) { + const offset = this.bb.__offset(this.bb_pos, 6); + return offset ? (obj || new Object_()).__init(this.bb.__indirect(this.bb_pos + offset), this.bb) : null; + } + response(obj) { + const offset = this.bb.__offset(this.bb_pos, 8); + return offset ? (obj || new Object_()).__init(this.bb.__indirect(this.bb_pos + offset), this.bb) : null; + } + attributes(index, obj) { + const offset = this.bb.__offset(this.bb_pos, 10); + return offset ? (obj || new KeyValue()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4), this.bb) : null; + } + attributesLength() { + const offset = this.bb.__offset(this.bb_pos, 10); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; + } + documentation(index, optionalEncoding) { + const offset = this.bb.__offset(this.bb_pos, 12); + return offset ? this.bb.__string(this.bb.__vector(this.bb_pos + offset) + index * 4, optionalEncoding) : null; + } + documentationLength() { + const offset = this.bb.__offset(this.bb_pos, 12); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; + } + static getFullyQualifiedName() { + return 'reflection_RPCCall'; + } + static startRPCCall(builder) { + builder.startObject(5); + } + static addName(builder, nameOffset) { + builder.addFieldOffset(0, nameOffset, 0); + } + static addRequest(builder, requestOffset) { + builder.addFieldOffset(1, requestOffset, 0); + } + static addResponse(builder, responseOffset) { + builder.addFieldOffset(2, responseOffset, 0); + } + static addAttributes(builder, attributesOffset) { + builder.addFieldOffset(3, attributesOffset, 0); + } + static createAttributesVector(builder, data) { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addOffset(data[i]); + } + return builder.endVector(); + } + static startAttributesVector(builder, numElems) { + builder.startVector(4, numElems, 4); + } + static addDocumentation(builder, documentationOffset) { + builder.addFieldOffset(4, documentationOffset, 0); + } + static createDocumentationVector(builder, data) { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addOffset(data[i]); + } + return builder.endVector(); + } + static startDocumentationVector(builder, numElems) { + builder.startVector(4, numElems, 4); + } + static endRPCCall(builder) { + const offset = builder.endObject(); + builder.requiredField(offset, 4); // name + builder.requiredField(offset, 6); // request + builder.requiredField(offset, 8); // response + return offset; + } + unpack() { + return new RPCCallT(this.name(), (this.request() !== null ? this.request().unpack() : null), (this.response() !== null ? this.response().unpack() : null), this.bb.createObjList(this.attributes.bind(this), this.attributesLength()), this.bb.createScalarList(this.documentation.bind(this), this.documentationLength())); + } + unpackTo(_o) { + _o.name = this.name(); + _o.request = (this.request() !== null ? this.request().unpack() : null); + _o.response = (this.response() !== null ? this.response().unpack() : null); + _o.attributes = this.bb.createObjList(this.attributes.bind(this), this.attributesLength()); + _o.documentation = this.bb.createScalarList(this.documentation.bind(this), this.documentationLength()); + } +} +export class RPCCallT { + constructor(name = null, request = null, response = null, attributes = [], documentation = []) { + this.name = name; + this.request = request; + this.response = response; + this.attributes = attributes; + this.documentation = documentation; + } + pack(builder) { + const name = (this.name !== null ? builder.createString(this.name) : 0); + const request = (this.request !== null ? this.request.pack(builder) : 0); + const response = (this.response !== null ? this.response.pack(builder) : 0); + const attributes = RPCCall.createAttributesVector(builder, builder.createObjectOffsetList(this.attributes)); + const documentation = RPCCall.createDocumentationVector(builder, builder.createObjectOffsetList(this.documentation)); + RPCCall.startRPCCall(builder); + RPCCall.addName(builder, name); + RPCCall.addRequest(builder, request); + RPCCall.addResponse(builder, response); + RPCCall.addAttributes(builder, attributes); + RPCCall.addDocumentation(builder, documentation); + return RPCCall.endRPCCall(builder); + } +} diff --git a/tests/ts/reflection/rpccall.ts b/tests/ts/reflection/rpccall.ts new file mode 100644 index 00000000000..151d7b1bc81 --- /dev/null +++ b/tests/ts/reflection/rpccall.ts @@ -0,0 +1,173 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +import * as flatbuffers from 'flatbuffers'; + +import { KeyValue, KeyValueT } from '../reflection/key-value.js'; +import { Object_, Object_T } from '../reflection/object.js'; + + +export class RPCCall { + bb: flatbuffers.ByteBuffer|null = null; + bb_pos = 0; + __init(i:number, bb:flatbuffers.ByteBuffer):RPCCall { + this.bb_pos = i; + this.bb = bb; + return this; +} + +static getRootAsRPCCall(bb:flatbuffers.ByteBuffer, obj?:RPCCall):RPCCall { + return (obj || new RPCCall()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +static getSizePrefixedRootAsRPCCall(bb:flatbuffers.ByteBuffer, obj?:RPCCall):RPCCall { + bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); + return (obj || new RPCCall()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +name():string|null +name(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null +name(optionalEncoding?:any):string|Uint8Array|null { + const offset = this.bb!.__offset(this.bb_pos, 4); + return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; +} + +request(obj?:Object_):Object_|null { + const offset = this.bb!.__offset(this.bb_pos, 6); + return offset ? (obj || new Object_()).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null; +} + +response(obj?:Object_):Object_|null { + const offset = this.bb!.__offset(this.bb_pos, 8); + return offset ? (obj || new Object_()).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null; +} + +attributes(index: number, obj?:KeyValue):KeyValue|null { + const offset = this.bb!.__offset(this.bb_pos, 10); + return offset ? (obj || new KeyValue()).__init(this.bb!.__indirect(this.bb!.__vector(this.bb_pos + offset) + index * 4), this.bb!) : null; +} + +attributesLength():number { + const offset = this.bb!.__offset(this.bb_pos, 10); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +} + +documentation(index: number):string +documentation(index: number,optionalEncoding:flatbuffers.Encoding):string|Uint8Array +documentation(index: number,optionalEncoding?:any):string|Uint8Array|null { + const offset = this.bb!.__offset(this.bb_pos, 12); + return offset ? this.bb!.__string(this.bb!.__vector(this.bb_pos + offset) + index * 4, optionalEncoding) : null; +} + +documentationLength():number { + const offset = this.bb!.__offset(this.bb_pos, 12); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +} + +static getFullyQualifiedName():string { + return 'reflection_RPCCall'; +} + +static startRPCCall(builder:flatbuffers.Builder) { + builder.startObject(5); +} + +static addName(builder:flatbuffers.Builder, nameOffset:flatbuffers.Offset) { + builder.addFieldOffset(0, nameOffset, 0); +} + +static addRequest(builder:flatbuffers.Builder, requestOffset:flatbuffers.Offset) { + builder.addFieldOffset(1, requestOffset, 0); +} + +static addResponse(builder:flatbuffers.Builder, responseOffset:flatbuffers.Offset) { + builder.addFieldOffset(2, responseOffset, 0); +} + +static addAttributes(builder:flatbuffers.Builder, attributesOffset:flatbuffers.Offset) { + builder.addFieldOffset(3, attributesOffset, 0); +} + +static createAttributesVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addOffset(data[i]!); + } + return builder.endVector(); +} + +static startAttributesVector(builder:flatbuffers.Builder, numElems:number) { + builder.startVector(4, numElems, 4); +} + +static addDocumentation(builder:flatbuffers.Builder, documentationOffset:flatbuffers.Offset) { + builder.addFieldOffset(4, documentationOffset, 0); +} + +static createDocumentationVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addOffset(data[i]!); + } + return builder.endVector(); +} + +static startDocumentationVector(builder:flatbuffers.Builder, numElems:number) { + builder.startVector(4, numElems, 4); +} + +static endRPCCall(builder:flatbuffers.Builder):flatbuffers.Offset { + const offset = builder.endObject(); + builder.requiredField(offset, 4) // name + builder.requiredField(offset, 6) // request + builder.requiredField(offset, 8) // response + return offset; +} + + +unpack(): RPCCallT { + return new RPCCallT( + this.name(), + (this.request() !== null ? this.request()!.unpack() : null), + (this.response() !== null ? this.response()!.unpack() : null), + this.bb!.createObjList(this.attributes.bind(this), this.attributesLength()), + this.bb!.createScalarList(this.documentation.bind(this), this.documentationLength()) + ); +} + + +unpackTo(_o: RPCCallT): void { + _o.name = this.name(); + _o.request = (this.request() !== null ? this.request()!.unpack() : null); + _o.response = (this.response() !== null ? this.response()!.unpack() : null); + _o.attributes = this.bb!.createObjList(this.attributes.bind(this), this.attributesLength()); + _o.documentation = this.bb!.createScalarList(this.documentation.bind(this), this.documentationLength()); +} +} + +export class RPCCallT { +constructor( + public name: string|Uint8Array|null = null, + public request: Object_T|null = null, + public response: Object_T|null = null, + public attributes: (KeyValueT)[] = [], + public documentation: (string)[] = [] +){} + + +pack(builder:flatbuffers.Builder): flatbuffers.Offset { + const name = (this.name !== null ? builder.createString(this.name!) : 0); + const request = (this.request !== null ? this.request!.pack(builder) : 0); + const response = (this.response !== null ? this.response!.pack(builder) : 0); + const attributes = RPCCall.createAttributesVector(builder, builder.createObjectOffsetList(this.attributes)); + const documentation = RPCCall.createDocumentationVector(builder, builder.createObjectOffsetList(this.documentation)); + + RPCCall.startRPCCall(builder); + RPCCall.addName(builder, name); + RPCCall.addRequest(builder, request); + RPCCall.addResponse(builder, response); + RPCCall.addAttributes(builder, attributes); + RPCCall.addDocumentation(builder, documentation); + + return RPCCall.endRPCCall(builder); +} +} diff --git a/tests/ts/reflection/schema-file.js b/tests/ts/reflection/schema-file.js new file mode 100644 index 00000000000..31c6145ddfe --- /dev/null +++ b/tests/ts/reflection/schema-file.js @@ -0,0 +1,88 @@ +// automatically generated by the FlatBuffers compiler, do not modify +import * as flatbuffers from 'flatbuffers'; +/** + * File specific information. + * Symbols declared within a file may be recovered by iterating over all + * symbols and examining the `declaration_file` field. + */ +export class SchemaFile { + constructor() { + this.bb = null; + this.bb_pos = 0; + } + __init(i, bb) { + this.bb_pos = i; + this.bb = bb; + return this; + } + static getRootAsSchemaFile(bb, obj) { + return (obj || new SchemaFile()).__init(bb.readInt32(bb.position()) + bb.position(), bb); + } + static getSizePrefixedRootAsSchemaFile(bb, obj) { + bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); + return (obj || new SchemaFile()).__init(bb.readInt32(bb.position()) + bb.position(), bb); + } + filename(optionalEncoding) { + const offset = this.bb.__offset(this.bb_pos, 4); + return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null; + } + includedFilenames(index, optionalEncoding) { + const offset = this.bb.__offset(this.bb_pos, 6); + return offset ? this.bb.__string(this.bb.__vector(this.bb_pos + offset) + index * 4, optionalEncoding) : null; + } + includedFilenamesLength() { + const offset = this.bb.__offset(this.bb_pos, 6); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; + } + static getFullyQualifiedName() { + return 'reflection_SchemaFile'; + } + static startSchemaFile(builder) { + builder.startObject(2); + } + static addFilename(builder, filenameOffset) { + builder.addFieldOffset(0, filenameOffset, 0); + } + static addIncludedFilenames(builder, includedFilenamesOffset) { + builder.addFieldOffset(1, includedFilenamesOffset, 0); + } + static createIncludedFilenamesVector(builder, data) { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addOffset(data[i]); + } + return builder.endVector(); + } + static startIncludedFilenamesVector(builder, numElems) { + builder.startVector(4, numElems, 4); + } + static endSchemaFile(builder) { + const offset = builder.endObject(); + builder.requiredField(offset, 4); // filename + return offset; + } + static createSchemaFile(builder, filenameOffset, includedFilenamesOffset) { + SchemaFile.startSchemaFile(builder); + SchemaFile.addFilename(builder, filenameOffset); + SchemaFile.addIncludedFilenames(builder, includedFilenamesOffset); + return SchemaFile.endSchemaFile(builder); + } + unpack() { + return new SchemaFileT(this.filename(), this.bb.createScalarList(this.includedFilenames.bind(this), this.includedFilenamesLength())); + } + unpackTo(_o) { + _o.filename = this.filename(); + _o.includedFilenames = this.bb.createScalarList(this.includedFilenames.bind(this), this.includedFilenamesLength()); + } +} +export class SchemaFileT { + constructor(filename = null, includedFilenames = []) { + this.filename = filename; + this.includedFilenames = includedFilenames; + } + pack(builder) { + const filename = (this.filename !== null ? builder.createString(this.filename) : 0); + const includedFilenames = SchemaFile.createIncludedFilenamesVector(builder, builder.createObjectOffsetList(this.includedFilenames)); + return SchemaFile.createSchemaFile(builder, filename, includedFilenames); + } +} diff --git a/tests/ts/reflection/schema-file.ts b/tests/ts/reflection/schema-file.ts new file mode 100644 index 00000000000..e1f50357ddd --- /dev/null +++ b/tests/ts/reflection/schema-file.ts @@ -0,0 +1,126 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +import * as flatbuffers from 'flatbuffers'; + + + +/** + * File specific information. + * Symbols declared within a file may be recovered by iterating over all + * symbols and examining the `declaration_file` field. + */ +export class SchemaFile { + bb: flatbuffers.ByteBuffer|null = null; + bb_pos = 0; + __init(i:number, bb:flatbuffers.ByteBuffer):SchemaFile { + this.bb_pos = i; + this.bb = bb; + return this; +} + +static getRootAsSchemaFile(bb:flatbuffers.ByteBuffer, obj?:SchemaFile):SchemaFile { + return (obj || new SchemaFile()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +static getSizePrefixedRootAsSchemaFile(bb:flatbuffers.ByteBuffer, obj?:SchemaFile):SchemaFile { + bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); + return (obj || new SchemaFile()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +/** + * Filename, relative to project root. + */ +filename():string|null +filename(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null +filename(optionalEncoding?:any):string|Uint8Array|null { + const offset = this.bb!.__offset(this.bb_pos, 4); + return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; +} + +/** + * Names of included files, relative to project root. + */ +includedFilenames(index: number):string +includedFilenames(index: number,optionalEncoding:flatbuffers.Encoding):string|Uint8Array +includedFilenames(index: number,optionalEncoding?:any):string|Uint8Array|null { + const offset = this.bb!.__offset(this.bb_pos, 6); + return offset ? this.bb!.__string(this.bb!.__vector(this.bb_pos + offset) + index * 4, optionalEncoding) : null; +} + +includedFilenamesLength():number { + const offset = this.bb!.__offset(this.bb_pos, 6); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +} + +static getFullyQualifiedName():string { + return 'reflection_SchemaFile'; +} + +static startSchemaFile(builder:flatbuffers.Builder) { + builder.startObject(2); +} + +static addFilename(builder:flatbuffers.Builder, filenameOffset:flatbuffers.Offset) { + builder.addFieldOffset(0, filenameOffset, 0); +} + +static addIncludedFilenames(builder:flatbuffers.Builder, includedFilenamesOffset:flatbuffers.Offset) { + builder.addFieldOffset(1, includedFilenamesOffset, 0); +} + +static createIncludedFilenamesVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addOffset(data[i]!); + } + return builder.endVector(); +} + +static startIncludedFilenamesVector(builder:flatbuffers.Builder, numElems:number) { + builder.startVector(4, numElems, 4); +} + +static endSchemaFile(builder:flatbuffers.Builder):flatbuffers.Offset { + const offset = builder.endObject(); + builder.requiredField(offset, 4) // filename + return offset; +} + +static createSchemaFile(builder:flatbuffers.Builder, filenameOffset:flatbuffers.Offset, includedFilenamesOffset:flatbuffers.Offset):flatbuffers.Offset { + SchemaFile.startSchemaFile(builder); + SchemaFile.addFilename(builder, filenameOffset); + SchemaFile.addIncludedFilenames(builder, includedFilenamesOffset); + return SchemaFile.endSchemaFile(builder); +} + +unpack(): SchemaFileT { + return new SchemaFileT( + this.filename(), + this.bb!.createScalarList(this.includedFilenames.bind(this), this.includedFilenamesLength()) + ); +} + + +unpackTo(_o: SchemaFileT): void { + _o.filename = this.filename(); + _o.includedFilenames = this.bb!.createScalarList(this.includedFilenames.bind(this), this.includedFilenamesLength()); +} +} + +export class SchemaFileT { +constructor( + public filename: string|Uint8Array|null = null, + public includedFilenames: (string)[] = [] +){} + + +pack(builder:flatbuffers.Builder): flatbuffers.Offset { + const filename = (this.filename !== null ? builder.createString(this.filename!) : 0); + const includedFilenames = SchemaFile.createIncludedFilenamesVector(builder, builder.createObjectOffsetList(this.includedFilenames)); + + return SchemaFile.createSchemaFile(builder, + filename, + includedFilenames + ); +} +} diff --git a/tests/ts/reflection/schema.js b/tests/ts/reflection/schema.js new file mode 100644 index 00000000000..d5022971526 --- /dev/null +++ b/tests/ts/reflection/schema.js @@ -0,0 +1,213 @@ +// automatically generated by the FlatBuffers compiler, do not modify +import * as flatbuffers from 'flatbuffers'; +import { Enum } from '../reflection/enum.js'; +import { Object_ } from '../reflection/object.js'; +import { SchemaFile } from '../reflection/schema-file.js'; +import { Service } from '../reflection/service.js'; +export class Schema { + constructor() { + this.bb = null; + this.bb_pos = 0; + } + __init(i, bb) { + this.bb_pos = i; + this.bb = bb; + return this; + } + static getRootAsSchema(bb, obj) { + return (obj || new Schema()).__init(bb.readInt32(bb.position()) + bb.position(), bb); + } + static getSizePrefixedRootAsSchema(bb, obj) { + bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); + return (obj || new Schema()).__init(bb.readInt32(bb.position()) + bb.position(), bb); + } + static bufferHasIdentifier(bb) { + return bb.__has_identifier('BFBS'); + } + objects(index, obj) { + const offset = this.bb.__offset(this.bb_pos, 4); + return offset ? (obj || new Object_()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4), this.bb) : null; + } + objectsLength() { + const offset = this.bb.__offset(this.bb_pos, 4); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; + } + enums(index, obj) { + const offset = this.bb.__offset(this.bb_pos, 6); + return offset ? (obj || new Enum()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4), this.bb) : null; + } + enumsLength() { + const offset = this.bb.__offset(this.bb_pos, 6); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; + } + fileIdent(optionalEncoding) { + const offset = this.bb.__offset(this.bb_pos, 8); + return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null; + } + fileExt(optionalEncoding) { + const offset = this.bb.__offset(this.bb_pos, 10); + return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null; + } + rootTable(obj) { + const offset = this.bb.__offset(this.bb_pos, 12); + return offset ? (obj || new Object_()).__init(this.bb.__indirect(this.bb_pos + offset), this.bb) : null; + } + services(index, obj) { + const offset = this.bb.__offset(this.bb_pos, 14); + return offset ? (obj || new Service()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4), this.bb) : null; + } + servicesLength() { + const offset = this.bb.__offset(this.bb_pos, 14); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; + } + advancedFeatures() { + const offset = this.bb.__offset(this.bb_pos, 16); + return offset ? this.bb.readUint64(this.bb_pos + offset) : BigInt('0'); + } + mutate_advanced_features(value) { + const offset = this.bb.__offset(this.bb_pos, 16); + if (offset === 0) { + return false; + } + this.bb.writeUint64(this.bb_pos + offset, value); + return true; + } + /** + * All the files used in this compilation. Files are relative to where + * flatc was invoked. + */ + fbsFiles(index, obj) { + const offset = this.bb.__offset(this.bb_pos, 18); + return offset ? (obj || new SchemaFile()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4), this.bb) : null; + } + fbsFilesLength() { + const offset = this.bb.__offset(this.bb_pos, 18); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; + } + static getFullyQualifiedName() { + return 'reflection_Schema'; + } + static startSchema(builder) { + builder.startObject(8); + } + static addObjects(builder, objectsOffset) { + builder.addFieldOffset(0, objectsOffset, 0); + } + static createObjectsVector(builder, data) { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addOffset(data[i]); + } + return builder.endVector(); + } + static startObjectsVector(builder, numElems) { + builder.startVector(4, numElems, 4); + } + static addEnums(builder, enumsOffset) { + builder.addFieldOffset(1, enumsOffset, 0); + } + static createEnumsVector(builder, data) { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addOffset(data[i]); + } + return builder.endVector(); + } + static startEnumsVector(builder, numElems) { + builder.startVector(4, numElems, 4); + } + static addFileIdent(builder, fileIdentOffset) { + builder.addFieldOffset(2, fileIdentOffset, 0); + } + static addFileExt(builder, fileExtOffset) { + builder.addFieldOffset(3, fileExtOffset, 0); + } + static addRootTable(builder, rootTableOffset) { + builder.addFieldOffset(4, rootTableOffset, 0); + } + static addServices(builder, servicesOffset) { + builder.addFieldOffset(5, servicesOffset, 0); + } + static createServicesVector(builder, data) { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addOffset(data[i]); + } + return builder.endVector(); + } + static startServicesVector(builder, numElems) { + builder.startVector(4, numElems, 4); + } + static addAdvancedFeatures(builder, advancedFeatures) { + builder.addFieldInt64(6, advancedFeatures, BigInt('0')); + } + static addFbsFiles(builder, fbsFilesOffset) { + builder.addFieldOffset(7, fbsFilesOffset, 0); + } + static createFbsFilesVector(builder, data) { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addOffset(data[i]); + } + return builder.endVector(); + } + static startFbsFilesVector(builder, numElems) { + builder.startVector(4, numElems, 4); + } + static endSchema(builder) { + const offset = builder.endObject(); + builder.requiredField(offset, 4); // objects + builder.requiredField(offset, 6); // enums + return offset; + } + static finishSchemaBuffer(builder, offset) { + builder.finish(offset, 'BFBS'); + } + static finishSizePrefixedSchemaBuffer(builder, offset) { + builder.finish(offset, 'BFBS', true); + } + unpack() { + return new SchemaT(this.bb.createObjList(this.objects.bind(this), this.objectsLength()), this.bb.createObjList(this.enums.bind(this), this.enumsLength()), this.fileIdent(), this.fileExt(), (this.rootTable() !== null ? this.rootTable().unpack() : null), this.bb.createObjList(this.services.bind(this), this.servicesLength()), this.advancedFeatures(), this.bb.createObjList(this.fbsFiles.bind(this), this.fbsFilesLength())); + } + unpackTo(_o) { + _o.objects = this.bb.createObjList(this.objects.bind(this), this.objectsLength()); + _o.enums = this.bb.createObjList(this.enums.bind(this), this.enumsLength()); + _o.fileIdent = this.fileIdent(); + _o.fileExt = this.fileExt(); + _o.rootTable = (this.rootTable() !== null ? this.rootTable().unpack() : null); + _o.services = this.bb.createObjList(this.services.bind(this), this.servicesLength()); + _o.advancedFeatures = this.advancedFeatures(); + _o.fbsFiles = this.bb.createObjList(this.fbsFiles.bind(this), this.fbsFilesLength()); + } +} +export class SchemaT { + constructor(objects = [], enums = [], fileIdent = null, fileExt = null, rootTable = null, services = [], advancedFeatures = BigInt('0'), fbsFiles = []) { + this.objects = objects; + this.enums = enums; + this.fileIdent = fileIdent; + this.fileExt = fileExt; + this.rootTable = rootTable; + this.services = services; + this.advancedFeatures = advancedFeatures; + this.fbsFiles = fbsFiles; + } + pack(builder) { + const objects = Schema.createObjectsVector(builder, builder.createObjectOffsetList(this.objects)); + const enums = Schema.createEnumsVector(builder, builder.createObjectOffsetList(this.enums)); + const fileIdent = (this.fileIdent !== null ? builder.createString(this.fileIdent) : 0); + const fileExt = (this.fileExt !== null ? builder.createString(this.fileExt) : 0); + const rootTable = (this.rootTable !== null ? this.rootTable.pack(builder) : 0); + const services = Schema.createServicesVector(builder, builder.createObjectOffsetList(this.services)); + const fbsFiles = Schema.createFbsFilesVector(builder, builder.createObjectOffsetList(this.fbsFiles)); + Schema.startSchema(builder); + Schema.addObjects(builder, objects); + Schema.addEnums(builder, enums); + Schema.addFileIdent(builder, fileIdent); + Schema.addFileExt(builder, fileExt); + Schema.addRootTable(builder, rootTable); + Schema.addServices(builder, services); + Schema.addAdvancedFeatures(builder, this.advancedFeatures); + Schema.addFbsFiles(builder, fbsFiles); + return Schema.endSchema(builder); + } +} diff --git a/tests/ts/reflection/schema.ts b/tests/ts/reflection/schema.ts new file mode 100644 index 00000000000..d1839c7cb14 --- /dev/null +++ b/tests/ts/reflection/schema.ts @@ -0,0 +1,276 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +import * as flatbuffers from 'flatbuffers'; + +import { Enum, EnumT } from '../reflection/enum.js'; +import { Object_, Object_T } from '../reflection/object.js'; +import { SchemaFile, SchemaFileT } from '../reflection/schema-file.js'; +import { Service, ServiceT } from '../reflection/service.js'; + + +export class Schema { + bb: flatbuffers.ByteBuffer|null = null; + bb_pos = 0; + __init(i:number, bb:flatbuffers.ByteBuffer):Schema { + this.bb_pos = i; + this.bb = bb; + return this; +} + +static getRootAsSchema(bb:flatbuffers.ByteBuffer, obj?:Schema):Schema { + return (obj || new Schema()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +static getSizePrefixedRootAsSchema(bb:flatbuffers.ByteBuffer, obj?:Schema):Schema { + bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); + return (obj || new Schema()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +static bufferHasIdentifier(bb:flatbuffers.ByteBuffer):boolean { + return bb.__has_identifier('BFBS'); +} + +objects(index: number, obj?:Object_):Object_|null { + const offset = this.bb!.__offset(this.bb_pos, 4); + return offset ? (obj || new Object_()).__init(this.bb!.__indirect(this.bb!.__vector(this.bb_pos + offset) + index * 4), this.bb!) : null; +} + +objectsLength():number { + const offset = this.bb!.__offset(this.bb_pos, 4); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +} + +enums(index: number, obj?:Enum):Enum|null { + const offset = this.bb!.__offset(this.bb_pos, 6); + return offset ? (obj || new Enum()).__init(this.bb!.__indirect(this.bb!.__vector(this.bb_pos + offset) + index * 4), this.bb!) : null; +} + +enumsLength():number { + const offset = this.bb!.__offset(this.bb_pos, 6); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +} + +fileIdent():string|null +fileIdent(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null +fileIdent(optionalEncoding?:any):string|Uint8Array|null { + const offset = this.bb!.__offset(this.bb_pos, 8); + return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; +} + +fileExt():string|null +fileExt(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null +fileExt(optionalEncoding?:any):string|Uint8Array|null { + const offset = this.bb!.__offset(this.bb_pos, 10); + return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; +} + +rootTable(obj?:Object_):Object_|null { + const offset = this.bb!.__offset(this.bb_pos, 12); + return offset ? (obj || new Object_()).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null; +} + +services(index: number, obj?:Service):Service|null { + const offset = this.bb!.__offset(this.bb_pos, 14); + return offset ? (obj || new Service()).__init(this.bb!.__indirect(this.bb!.__vector(this.bb_pos + offset) + index * 4), this.bb!) : null; +} + +servicesLength():number { + const offset = this.bb!.__offset(this.bb_pos, 14); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +} + +advancedFeatures():bigint { + const offset = this.bb!.__offset(this.bb_pos, 16); + return offset ? this.bb!.readUint64(this.bb_pos + offset) : BigInt('0'); +} + +mutate_advanced_features(value:bigint):boolean { + const offset = this.bb!.__offset(this.bb_pos, 16); + + if (offset === 0) { + return false; + } + + this.bb!.writeUint64(this.bb_pos + offset, value); + return true; +} + +/** + * All the files used in this compilation. Files are relative to where + * flatc was invoked. + */ +fbsFiles(index: number, obj?:SchemaFile):SchemaFile|null { + const offset = this.bb!.__offset(this.bb_pos, 18); + return offset ? (obj || new SchemaFile()).__init(this.bb!.__indirect(this.bb!.__vector(this.bb_pos + offset) + index * 4), this.bb!) : null; +} + +fbsFilesLength():number { + const offset = this.bb!.__offset(this.bb_pos, 18); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +} + +static getFullyQualifiedName():string { + return 'reflection_Schema'; +} + +static startSchema(builder:flatbuffers.Builder) { + builder.startObject(8); +} + +static addObjects(builder:flatbuffers.Builder, objectsOffset:flatbuffers.Offset) { + builder.addFieldOffset(0, objectsOffset, 0); +} + +static createObjectsVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addOffset(data[i]!); + } + return builder.endVector(); +} + +static startObjectsVector(builder:flatbuffers.Builder, numElems:number) { + builder.startVector(4, numElems, 4); +} + +static addEnums(builder:flatbuffers.Builder, enumsOffset:flatbuffers.Offset) { + builder.addFieldOffset(1, enumsOffset, 0); +} + +static createEnumsVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addOffset(data[i]!); + } + return builder.endVector(); +} + +static startEnumsVector(builder:flatbuffers.Builder, numElems:number) { + builder.startVector(4, numElems, 4); +} + +static addFileIdent(builder:flatbuffers.Builder, fileIdentOffset:flatbuffers.Offset) { + builder.addFieldOffset(2, fileIdentOffset, 0); +} + +static addFileExt(builder:flatbuffers.Builder, fileExtOffset:flatbuffers.Offset) { + builder.addFieldOffset(3, fileExtOffset, 0); +} + +static addRootTable(builder:flatbuffers.Builder, rootTableOffset:flatbuffers.Offset) { + builder.addFieldOffset(4, rootTableOffset, 0); +} + +static addServices(builder:flatbuffers.Builder, servicesOffset:flatbuffers.Offset) { + builder.addFieldOffset(5, servicesOffset, 0); +} + +static createServicesVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addOffset(data[i]!); + } + return builder.endVector(); +} + +static startServicesVector(builder:flatbuffers.Builder, numElems:number) { + builder.startVector(4, numElems, 4); +} + +static addAdvancedFeatures(builder:flatbuffers.Builder, advancedFeatures:bigint) { + builder.addFieldInt64(6, advancedFeatures, BigInt('0')); +} + +static addFbsFiles(builder:flatbuffers.Builder, fbsFilesOffset:flatbuffers.Offset) { + builder.addFieldOffset(7, fbsFilesOffset, 0); +} + +static createFbsFilesVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addOffset(data[i]!); + } + return builder.endVector(); +} + +static startFbsFilesVector(builder:flatbuffers.Builder, numElems:number) { + builder.startVector(4, numElems, 4); +} + +static endSchema(builder:flatbuffers.Builder):flatbuffers.Offset { + const offset = builder.endObject(); + builder.requiredField(offset, 4) // objects + builder.requiredField(offset, 6) // enums + return offset; +} + +static finishSchemaBuffer(builder:flatbuffers.Builder, offset:flatbuffers.Offset) { + builder.finish(offset, 'BFBS'); +} + +static finishSizePrefixedSchemaBuffer(builder:flatbuffers.Builder, offset:flatbuffers.Offset) { + builder.finish(offset, 'BFBS', true); +} + + +unpack(): SchemaT { + return new SchemaT( + this.bb!.createObjList(this.objects.bind(this), this.objectsLength()), + this.bb!.createObjList(this.enums.bind(this), this.enumsLength()), + this.fileIdent(), + this.fileExt(), + (this.rootTable() !== null ? this.rootTable()!.unpack() : null), + this.bb!.createObjList(this.services.bind(this), this.servicesLength()), + this.advancedFeatures(), + this.bb!.createObjList(this.fbsFiles.bind(this), this.fbsFilesLength()) + ); +} + + +unpackTo(_o: SchemaT): void { + _o.objects = this.bb!.createObjList(this.objects.bind(this), this.objectsLength()); + _o.enums = this.bb!.createObjList(this.enums.bind(this), this.enumsLength()); + _o.fileIdent = this.fileIdent(); + _o.fileExt = this.fileExt(); + _o.rootTable = (this.rootTable() !== null ? this.rootTable()!.unpack() : null); + _o.services = this.bb!.createObjList(this.services.bind(this), this.servicesLength()); + _o.advancedFeatures = this.advancedFeatures(); + _o.fbsFiles = this.bb!.createObjList(this.fbsFiles.bind(this), this.fbsFilesLength()); +} +} + +export class SchemaT { +constructor( + public objects: (Object_T)[] = [], + public enums: (EnumT)[] = [], + public fileIdent: string|Uint8Array|null = null, + public fileExt: string|Uint8Array|null = null, + public rootTable: Object_T|null = null, + public services: (ServiceT)[] = [], + public advancedFeatures: bigint = BigInt('0'), + public fbsFiles: (SchemaFileT)[] = [] +){} + + +pack(builder:flatbuffers.Builder): flatbuffers.Offset { + const objects = Schema.createObjectsVector(builder, builder.createObjectOffsetList(this.objects)); + const enums = Schema.createEnumsVector(builder, builder.createObjectOffsetList(this.enums)); + const fileIdent = (this.fileIdent !== null ? builder.createString(this.fileIdent!) : 0); + const fileExt = (this.fileExt !== null ? builder.createString(this.fileExt!) : 0); + const rootTable = (this.rootTable !== null ? this.rootTable!.pack(builder) : 0); + const services = Schema.createServicesVector(builder, builder.createObjectOffsetList(this.services)); + const fbsFiles = Schema.createFbsFilesVector(builder, builder.createObjectOffsetList(this.fbsFiles)); + + Schema.startSchema(builder); + Schema.addObjects(builder, objects); + Schema.addEnums(builder, enums); + Schema.addFileIdent(builder, fileIdent); + Schema.addFileExt(builder, fileExt); + Schema.addRootTable(builder, rootTable); + Schema.addServices(builder, services); + Schema.addAdvancedFeatures(builder, this.advancedFeatures); + Schema.addFbsFiles(builder, fbsFiles); + + return Schema.endSchema(builder); +} +} diff --git a/tests/ts/reflection/service.js b/tests/ts/reflection/service.js new file mode 100644 index 00000000000..8c66ef774ac --- /dev/null +++ b/tests/ts/reflection/service.js @@ -0,0 +1,146 @@ +// automatically generated by the FlatBuffers compiler, do not modify +import * as flatbuffers from 'flatbuffers'; +import { KeyValue } from '../reflection/key-value.js'; +import { RPCCall } from '../reflection/rpccall.js'; +export class Service { + constructor() { + this.bb = null; + this.bb_pos = 0; + } + __init(i, bb) { + this.bb_pos = i; + this.bb = bb; + return this; + } + static getRootAsService(bb, obj) { + return (obj || new Service()).__init(bb.readInt32(bb.position()) + bb.position(), bb); + } + static getSizePrefixedRootAsService(bb, obj) { + bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); + return (obj || new Service()).__init(bb.readInt32(bb.position()) + bb.position(), bb); + } + name(optionalEncoding) { + const offset = this.bb.__offset(this.bb_pos, 4); + return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null; + } + calls(index, obj) { + const offset = this.bb.__offset(this.bb_pos, 6); + return offset ? (obj || new RPCCall()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4), this.bb) : null; + } + callsLength() { + const offset = this.bb.__offset(this.bb_pos, 6); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; + } + attributes(index, obj) { + const offset = this.bb.__offset(this.bb_pos, 8); + return offset ? (obj || new KeyValue()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4), this.bb) : null; + } + attributesLength() { + const offset = this.bb.__offset(this.bb_pos, 8); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; + } + documentation(index, optionalEncoding) { + const offset = this.bb.__offset(this.bb_pos, 10); + return offset ? this.bb.__string(this.bb.__vector(this.bb_pos + offset) + index * 4, optionalEncoding) : null; + } + documentationLength() { + const offset = this.bb.__offset(this.bb_pos, 10); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; + } + declarationFile(optionalEncoding) { + const offset = this.bb.__offset(this.bb_pos, 12); + return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null; + } + static getFullyQualifiedName() { + return 'reflection_Service'; + } + static startService(builder) { + builder.startObject(5); + } + static addName(builder, nameOffset) { + builder.addFieldOffset(0, nameOffset, 0); + } + static addCalls(builder, callsOffset) { + builder.addFieldOffset(1, callsOffset, 0); + } + static createCallsVector(builder, data) { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addOffset(data[i]); + } + return builder.endVector(); + } + static startCallsVector(builder, numElems) { + builder.startVector(4, numElems, 4); + } + static addAttributes(builder, attributesOffset) { + builder.addFieldOffset(2, attributesOffset, 0); + } + static createAttributesVector(builder, data) { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addOffset(data[i]); + } + return builder.endVector(); + } + static startAttributesVector(builder, numElems) { + builder.startVector(4, numElems, 4); + } + static addDocumentation(builder, documentationOffset) { + builder.addFieldOffset(3, documentationOffset, 0); + } + static createDocumentationVector(builder, data) { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addOffset(data[i]); + } + return builder.endVector(); + } + static startDocumentationVector(builder, numElems) { + builder.startVector(4, numElems, 4); + } + static addDeclarationFile(builder, declarationFileOffset) { + builder.addFieldOffset(4, declarationFileOffset, 0); + } + static endService(builder) { + const offset = builder.endObject(); + builder.requiredField(offset, 4); // name + return offset; + } + static createService(builder, nameOffset, callsOffset, attributesOffset, documentationOffset, declarationFileOffset) { + Service.startService(builder); + Service.addName(builder, nameOffset); + Service.addCalls(builder, callsOffset); + Service.addAttributes(builder, attributesOffset); + Service.addDocumentation(builder, documentationOffset); + Service.addDeclarationFile(builder, declarationFileOffset); + return Service.endService(builder); + } + unpack() { + return new ServiceT(this.name(), this.bb.createObjList(this.calls.bind(this), this.callsLength()), this.bb.createObjList(this.attributes.bind(this), this.attributesLength()), this.bb.createScalarList(this.documentation.bind(this), this.documentationLength()), this.declarationFile()); + } + unpackTo(_o) { + _o.name = this.name(); + _o.calls = this.bb.createObjList(this.calls.bind(this), this.callsLength()); + _o.attributes = this.bb.createObjList(this.attributes.bind(this), this.attributesLength()); + _o.documentation = this.bb.createScalarList(this.documentation.bind(this), this.documentationLength()); + _o.declarationFile = this.declarationFile(); + } +} +export class ServiceT { + constructor(name = null, calls = [], attributes = [], documentation = [], declarationFile = null) { + this.name = name; + this.calls = calls; + this.attributes = attributes; + this.documentation = documentation; + this.declarationFile = declarationFile; + } + pack(builder) { + const name = (this.name !== null ? builder.createString(this.name) : 0); + const calls = Service.createCallsVector(builder, builder.createObjectOffsetList(this.calls)); + const attributes = Service.createAttributesVector(builder, builder.createObjectOffsetList(this.attributes)); + const documentation = Service.createDocumentationVector(builder, builder.createObjectOffsetList(this.documentation)); + const declarationFile = (this.declarationFile !== null ? builder.createString(this.declarationFile) : 0); + return Service.createService(builder, name, calls, attributes, documentation, declarationFile); + } +} diff --git a/tests/ts/reflection/service.ts b/tests/ts/reflection/service.ts new file mode 100644 index 00000000000..c083cae0b49 --- /dev/null +++ b/tests/ts/reflection/service.ts @@ -0,0 +1,201 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +import * as flatbuffers from 'flatbuffers'; + +import { KeyValue, KeyValueT } from '../reflection/key-value.js'; +import { RPCCall, RPCCallT } from '../reflection/rpccall.js'; + + +export class Service { + bb: flatbuffers.ByteBuffer|null = null; + bb_pos = 0; + __init(i:number, bb:flatbuffers.ByteBuffer):Service { + this.bb_pos = i; + this.bb = bb; + return this; +} + +static getRootAsService(bb:flatbuffers.ByteBuffer, obj?:Service):Service { + return (obj || new Service()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +static getSizePrefixedRootAsService(bb:flatbuffers.ByteBuffer, obj?:Service):Service { + bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); + return (obj || new Service()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +name():string|null +name(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null +name(optionalEncoding?:any):string|Uint8Array|null { + const offset = this.bb!.__offset(this.bb_pos, 4); + return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; +} + +calls(index: number, obj?:RPCCall):RPCCall|null { + const offset = this.bb!.__offset(this.bb_pos, 6); + return offset ? (obj || new RPCCall()).__init(this.bb!.__indirect(this.bb!.__vector(this.bb_pos + offset) + index * 4), this.bb!) : null; +} + +callsLength():number { + const offset = this.bb!.__offset(this.bb_pos, 6); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +} + +attributes(index: number, obj?:KeyValue):KeyValue|null { + const offset = this.bb!.__offset(this.bb_pos, 8); + return offset ? (obj || new KeyValue()).__init(this.bb!.__indirect(this.bb!.__vector(this.bb_pos + offset) + index * 4), this.bb!) : null; +} + +attributesLength():number { + const offset = this.bb!.__offset(this.bb_pos, 8); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +} + +documentation(index: number):string +documentation(index: number,optionalEncoding:flatbuffers.Encoding):string|Uint8Array +documentation(index: number,optionalEncoding?:any):string|Uint8Array|null { + const offset = this.bb!.__offset(this.bb_pos, 10); + return offset ? this.bb!.__string(this.bb!.__vector(this.bb_pos + offset) + index * 4, optionalEncoding) : null; +} + +documentationLength():number { + const offset = this.bb!.__offset(this.bb_pos, 10); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +} + +/** + * File that this Service is declared in. + */ +declarationFile():string|null +declarationFile(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null +declarationFile(optionalEncoding?:any):string|Uint8Array|null { + const offset = this.bb!.__offset(this.bb_pos, 12); + return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; +} + +static getFullyQualifiedName():string { + return 'reflection_Service'; +} + +static startService(builder:flatbuffers.Builder) { + builder.startObject(5); +} + +static addName(builder:flatbuffers.Builder, nameOffset:flatbuffers.Offset) { + builder.addFieldOffset(0, nameOffset, 0); +} + +static addCalls(builder:flatbuffers.Builder, callsOffset:flatbuffers.Offset) { + builder.addFieldOffset(1, callsOffset, 0); +} + +static createCallsVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addOffset(data[i]!); + } + return builder.endVector(); +} + +static startCallsVector(builder:flatbuffers.Builder, numElems:number) { + builder.startVector(4, numElems, 4); +} + +static addAttributes(builder:flatbuffers.Builder, attributesOffset:flatbuffers.Offset) { + builder.addFieldOffset(2, attributesOffset, 0); +} + +static createAttributesVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addOffset(data[i]!); + } + return builder.endVector(); +} + +static startAttributesVector(builder:flatbuffers.Builder, numElems:number) { + builder.startVector(4, numElems, 4); +} + +static addDocumentation(builder:flatbuffers.Builder, documentationOffset:flatbuffers.Offset) { + builder.addFieldOffset(3, documentationOffset, 0); +} + +static createDocumentationVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addOffset(data[i]!); + } + return builder.endVector(); +} + +static startDocumentationVector(builder:flatbuffers.Builder, numElems:number) { + builder.startVector(4, numElems, 4); +} + +static addDeclarationFile(builder:flatbuffers.Builder, declarationFileOffset:flatbuffers.Offset) { + builder.addFieldOffset(4, declarationFileOffset, 0); +} + +static endService(builder:flatbuffers.Builder):flatbuffers.Offset { + const offset = builder.endObject(); + builder.requiredField(offset, 4) // name + return offset; +} + +static createService(builder:flatbuffers.Builder, nameOffset:flatbuffers.Offset, callsOffset:flatbuffers.Offset, attributesOffset:flatbuffers.Offset, documentationOffset:flatbuffers.Offset, declarationFileOffset:flatbuffers.Offset):flatbuffers.Offset { + Service.startService(builder); + Service.addName(builder, nameOffset); + Service.addCalls(builder, callsOffset); + Service.addAttributes(builder, attributesOffset); + Service.addDocumentation(builder, documentationOffset); + Service.addDeclarationFile(builder, declarationFileOffset); + return Service.endService(builder); +} + +unpack(): ServiceT { + return new ServiceT( + this.name(), + this.bb!.createObjList(this.calls.bind(this), this.callsLength()), + this.bb!.createObjList(this.attributes.bind(this), this.attributesLength()), + this.bb!.createScalarList(this.documentation.bind(this), this.documentationLength()), + this.declarationFile() + ); +} + + +unpackTo(_o: ServiceT): void { + _o.name = this.name(); + _o.calls = this.bb!.createObjList(this.calls.bind(this), this.callsLength()); + _o.attributes = this.bb!.createObjList(this.attributes.bind(this), this.attributesLength()); + _o.documentation = this.bb!.createScalarList(this.documentation.bind(this), this.documentationLength()); + _o.declarationFile = this.declarationFile(); +} +} + +export class ServiceT { +constructor( + public name: string|Uint8Array|null = null, + public calls: (RPCCallT)[] = [], + public attributes: (KeyValueT)[] = [], + public documentation: (string)[] = [], + public declarationFile: string|Uint8Array|null = null +){} + + +pack(builder:flatbuffers.Builder): flatbuffers.Offset { + const name = (this.name !== null ? builder.createString(this.name!) : 0); + const calls = Service.createCallsVector(builder, builder.createObjectOffsetList(this.calls)); + const attributes = Service.createAttributesVector(builder, builder.createObjectOffsetList(this.attributes)); + const documentation = Service.createDocumentationVector(builder, builder.createObjectOffsetList(this.documentation)); + const declarationFile = (this.declarationFile !== null ? builder.createString(this.declarationFile!) : 0); + + return Service.createService(builder, + name, + calls, + attributes, + documentation, + declarationFile + ); +} +} diff --git a/tests/ts/reflection/type.js b/tests/ts/reflection/type.js new file mode 100644 index 00000000000..f3ccbdfe688 --- /dev/null +++ b/tests/ts/reflection/type.js @@ -0,0 +1,161 @@ +// automatically generated by the FlatBuffers compiler, do not modify +import * as flatbuffers from 'flatbuffers'; +import { BaseType } from '../reflection/base-type.js'; +export class Type { + constructor() { + this.bb = null; + this.bb_pos = 0; + } + __init(i, bb) { + this.bb_pos = i; + this.bb = bb; + return this; + } + static getRootAsType(bb, obj) { + return (obj || new Type()).__init(bb.readInt32(bb.position()) + bb.position(), bb); + } + static getSizePrefixedRootAsType(bb, obj) { + bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); + return (obj || new Type()).__init(bb.readInt32(bb.position()) + bb.position(), bb); + } + baseType() { + const offset = this.bb.__offset(this.bb_pos, 4); + return offset ? this.bb.readInt8(this.bb_pos + offset) : BaseType.None; + } + mutate_base_type(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; + } + element() { + const offset = this.bb.__offset(this.bb_pos, 6); + return offset ? this.bb.readInt8(this.bb_pos + offset) : BaseType.None; + } + mutate_element(value) { + const offset = this.bb.__offset(this.bb_pos, 6); + if (offset === 0) { + return false; + } + this.bb.writeInt8(this.bb_pos + offset, value); + return true; + } + index() { + const offset = this.bb.__offset(this.bb_pos, 8); + return offset ? this.bb.readInt32(this.bb_pos + offset) : -1; + } + mutate_index(value) { + const offset = this.bb.__offset(this.bb_pos, 8); + if (offset === 0) { + return false; + } + this.bb.writeInt32(this.bb_pos + offset, value); + return true; + } + fixedLength() { + const offset = this.bb.__offset(this.bb_pos, 10); + return offset ? this.bb.readUint16(this.bb_pos + offset) : 0; + } + mutate_fixed_length(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; + } + /** + * The size (octets) of the `base_type` field. + */ + baseSize() { + const offset = this.bb.__offset(this.bb_pos, 12); + return offset ? this.bb.readUint32(this.bb_pos + offset) : 4; + } + mutate_base_size(value) { + const offset = this.bb.__offset(this.bb_pos, 12); + if (offset === 0) { + return false; + } + this.bb.writeUint32(this.bb_pos + offset, value); + return true; + } + /** + * The size (octets) of the `element` field, if present. + */ + elementSize() { + const offset = this.bb.__offset(this.bb_pos, 14); + return offset ? this.bb.readUint32(this.bb_pos + offset) : 0; + } + mutate_element_size(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; + } + static getFullyQualifiedName() { + return 'reflection_Type'; + } + static startType(builder) { + builder.startObject(6); + } + static addBaseType(builder, baseType) { + builder.addFieldInt8(0, baseType, BaseType.None); + } + static addElement(builder, element) { + builder.addFieldInt8(1, element, BaseType.None); + } + static addIndex(builder, index) { + builder.addFieldInt32(2, index, -1); + } + static addFixedLength(builder, fixedLength) { + builder.addFieldInt16(3, fixedLength, 0); + } + static addBaseSize(builder, baseSize) { + builder.addFieldInt32(4, baseSize, 4); + } + static addElementSize(builder, elementSize) { + builder.addFieldInt32(5, elementSize, 0); + } + static endType(builder) { + const offset = builder.endObject(); + return offset; + } + static createType(builder, baseType, element, index, fixedLength, baseSize, elementSize) { + Type.startType(builder); + Type.addBaseType(builder, baseType); + Type.addElement(builder, element); + Type.addIndex(builder, index); + Type.addFixedLength(builder, fixedLength); + Type.addBaseSize(builder, baseSize); + Type.addElementSize(builder, elementSize); + return Type.endType(builder); + } + unpack() { + return new TypeT(this.baseType(), this.element(), this.index(), this.fixedLength(), this.baseSize(), this.elementSize()); + } + unpackTo(_o) { + _o.baseType = this.baseType(); + _o.element = this.element(); + _o.index = this.index(); + _o.fixedLength = this.fixedLength(); + _o.baseSize = this.baseSize(); + _o.elementSize = this.elementSize(); + } +} +export class TypeT { + constructor(baseType = BaseType.None, element = BaseType.None, index = -1, fixedLength = 0, baseSize = 4, elementSize = 0) { + this.baseType = baseType; + this.element = element; + this.index = index; + this.fixedLength = fixedLength; + this.baseSize = baseSize; + this.elementSize = elementSize; + } + pack(builder) { + return Type.createType(builder, this.baseType, this.element, this.index, this.fixedLength, this.baseSize, this.elementSize); + } +} diff --git a/tests/ts/reflection/type.ts b/tests/ts/reflection/type.ts new file mode 100644 index 00000000000..e831e21dd41 --- /dev/null +++ b/tests/ts/reflection/type.ts @@ -0,0 +1,219 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +import * as flatbuffers from 'flatbuffers'; + +import { BaseType } from '../reflection/base-type.js'; + + +export class Type { + bb: flatbuffers.ByteBuffer|null = null; + bb_pos = 0; + __init(i:number, bb:flatbuffers.ByteBuffer):Type { + this.bb_pos = i; + this.bb = bb; + return this; +} + +static getRootAsType(bb:flatbuffers.ByteBuffer, obj?:Type):Type { + return (obj || new Type()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +static getSizePrefixedRootAsType(bb:flatbuffers.ByteBuffer, obj?:Type):Type { + bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); + return (obj || new Type()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +baseType():BaseType { + const offset = this.bb!.__offset(this.bb_pos, 4); + return offset ? this.bb!.readInt8(this.bb_pos + offset) : BaseType.None; +} + +mutate_base_type(value:BaseType):boolean { + const offset = this.bb!.__offset(this.bb_pos, 4); + + if (offset === 0) { + return false; + } + + this.bb!.writeInt8(this.bb_pos + offset, value); + return true; +} + +element():BaseType { + const offset = this.bb!.__offset(this.bb_pos, 6); + return offset ? this.bb!.readInt8(this.bb_pos + offset) : BaseType.None; +} + +mutate_element(value:BaseType):boolean { + const offset = this.bb!.__offset(this.bb_pos, 6); + + if (offset === 0) { + return false; + } + + this.bb!.writeInt8(this.bb_pos + offset, value); + return true; +} + +index():number { + const offset = this.bb!.__offset(this.bb_pos, 8); + return offset ? this.bb!.readInt32(this.bb_pos + offset) : -1; +} + +mutate_index(value:number):boolean { + const offset = this.bb!.__offset(this.bb_pos, 8); + + if (offset === 0) { + return false; + } + + this.bb!.writeInt32(this.bb_pos + offset, value); + return true; +} + +fixedLength():number { + const offset = this.bb!.__offset(this.bb_pos, 10); + return offset ? this.bb!.readUint16(this.bb_pos + offset) : 0; +} + +mutate_fixed_length(value:number):boolean { + const offset = this.bb!.__offset(this.bb_pos, 10); + + if (offset === 0) { + return false; + } + + this.bb!.writeUint16(this.bb_pos + offset, value); + return true; +} + +/** + * The size (octets) of the `base_type` field. + */ +baseSize():number { + const offset = this.bb!.__offset(this.bb_pos, 12); + return offset ? this.bb!.readUint32(this.bb_pos + offset) : 4; +} + +mutate_base_size(value:number):boolean { + const offset = this.bb!.__offset(this.bb_pos, 12); + + if (offset === 0) { + return false; + } + + this.bb!.writeUint32(this.bb_pos + offset, value); + return true; +} + +/** + * The size (octets) of the `element` field, if present. + */ +elementSize():number { + const offset = this.bb!.__offset(this.bb_pos, 14); + return offset ? this.bb!.readUint32(this.bb_pos + offset) : 0; +} + +mutate_element_size(value:number):boolean { + const offset = this.bb!.__offset(this.bb_pos, 14); + + if (offset === 0) { + return false; + } + + this.bb!.writeUint32(this.bb_pos + offset, value); + return true; +} + +static getFullyQualifiedName():string { + return 'reflection_Type'; +} + +static startType(builder:flatbuffers.Builder) { + builder.startObject(6); +} + +static addBaseType(builder:flatbuffers.Builder, baseType:BaseType) { + builder.addFieldInt8(0, baseType, BaseType.None); +} + +static addElement(builder:flatbuffers.Builder, element:BaseType) { + builder.addFieldInt8(1, element, BaseType.None); +} + +static addIndex(builder:flatbuffers.Builder, index:number) { + builder.addFieldInt32(2, index, -1); +} + +static addFixedLength(builder:flatbuffers.Builder, fixedLength:number) { + builder.addFieldInt16(3, fixedLength, 0); +} + +static addBaseSize(builder:flatbuffers.Builder, baseSize:number) { + builder.addFieldInt32(4, baseSize, 4); +} + +static addElementSize(builder:flatbuffers.Builder, elementSize:number) { + builder.addFieldInt32(5, elementSize, 0); +} + +static endType(builder:flatbuffers.Builder):flatbuffers.Offset { + const offset = builder.endObject(); + return offset; +} + +static createType(builder:flatbuffers.Builder, baseType:BaseType, element:BaseType, index:number, fixedLength:number, baseSize:number, elementSize:number):flatbuffers.Offset { + Type.startType(builder); + Type.addBaseType(builder, baseType); + Type.addElement(builder, element); + Type.addIndex(builder, index); + Type.addFixedLength(builder, fixedLength); + Type.addBaseSize(builder, baseSize); + Type.addElementSize(builder, elementSize); + return Type.endType(builder); +} + +unpack(): TypeT { + return new TypeT( + this.baseType(), + this.element(), + this.index(), + this.fixedLength(), + this.baseSize(), + this.elementSize() + ); +} + + +unpackTo(_o: TypeT): void { + _o.baseType = this.baseType(); + _o.element = this.element(); + _o.index = this.index(); + _o.fixedLength = this.fixedLength(); + _o.baseSize = this.baseSize(); + _o.elementSize = this.elementSize(); +} +} + +export class TypeT { +constructor( + public baseType: BaseType = BaseType.None, + public element: BaseType = BaseType.None, + public index: number = -1, + public fixedLength: number = 0, + public baseSize: number = 4, + public elementSize: number = 0 +){} + + +pack(builder:flatbuffers.Builder): flatbuffers.Offset { + return Type.createType(builder, + this.baseType, + this.element, + this.index, + this.fixedLength, + this.baseSize, + this.elementSize + ); +} +} diff --git a/tests/ts/reflection_generated.js b/tests/ts/reflection_generated.js new file mode 100644 index 00000000000..dd686cc9d67 --- /dev/null +++ b/tests/ts/reflection_generated.js @@ -0,0 +1,1575 @@ +// automatically generated by the FlatBuffers compiler, do not modify +import * as flatbuffers from 'flatbuffers'; +export var BaseType; +(function (BaseType) { + BaseType[BaseType["None"] = 0] = "None"; + BaseType[BaseType["UType"] = 1] = "UType"; + BaseType[BaseType["Bool"] = 2] = "Bool"; + BaseType[BaseType["Byte"] = 3] = "Byte"; + BaseType[BaseType["UByte"] = 4] = "UByte"; + BaseType[BaseType["Short"] = 5] = "Short"; + BaseType[BaseType["UShort"] = 6] = "UShort"; + BaseType[BaseType["Int"] = 7] = "Int"; + BaseType[BaseType["UInt"] = 8] = "UInt"; + BaseType[BaseType["Long"] = 9] = "Long"; + BaseType[BaseType["ULong"] = 10] = "ULong"; + BaseType[BaseType["Float"] = 11] = "Float"; + BaseType[BaseType["Double"] = 12] = "Double"; + BaseType[BaseType["String"] = 13] = "String"; + BaseType[BaseType["Vector"] = 14] = "Vector"; + BaseType[BaseType["Obj"] = 15] = "Obj"; + BaseType[BaseType["Union"] = 16] = "Union"; + BaseType[BaseType["Array"] = 17] = "Array"; + BaseType[BaseType["MaxBaseType"] = 18] = "MaxBaseType"; +})(BaseType || (BaseType = {})); +/** + * New schema language features that are not supported by old code generators. + */ +export var AdvancedFeatures; +(function (AdvancedFeatures) { + AdvancedFeatures["AdvancedArrayFeatures"] = "1"; + AdvancedFeatures["AdvancedUnionFeatures"] = "2"; + AdvancedFeatures["OptionalScalars"] = "4"; + AdvancedFeatures["DefaultVectorsAndStrings"] = "8"; +})(AdvancedFeatures || (AdvancedFeatures = {})); +export class Type { + constructor() { + this.bb = null; + this.bb_pos = 0; + } + __init(i, bb) { + this.bb_pos = i; + this.bb = bb; + return this; + } + static getRootAsType(bb, obj) { + return (obj || new Type()).__init(bb.readInt32(bb.position()) + bb.position(), bb); + } + static getSizePrefixedRootAsType(bb, obj) { + bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); + return (obj || new Type()).__init(bb.readInt32(bb.position()) + bb.position(), bb); + } + baseType() { + const offset = this.bb.__offset(this.bb_pos, 4); + return offset ? this.bb.readInt8(this.bb_pos + offset) : BaseType.None; + } + mutate_base_type(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; + } + element() { + const offset = this.bb.__offset(this.bb_pos, 6); + return offset ? this.bb.readInt8(this.bb_pos + offset) : BaseType.None; + } + mutate_element(value) { + const offset = this.bb.__offset(this.bb_pos, 6); + if (offset === 0) { + return false; + } + this.bb.writeInt8(this.bb_pos + offset, value); + return true; + } + index() { + const offset = this.bb.__offset(this.bb_pos, 8); + return offset ? this.bb.readInt32(this.bb_pos + offset) : -1; + } + mutate_index(value) { + const offset = this.bb.__offset(this.bb_pos, 8); + if (offset === 0) { + return false; + } + this.bb.writeInt32(this.bb_pos + offset, value); + return true; + } + fixedLength() { + const offset = this.bb.__offset(this.bb_pos, 10); + return offset ? this.bb.readUint16(this.bb_pos + offset) : 0; + } + mutate_fixed_length(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; + } + /** + * The size (octets) of the `base_type` field. + */ + baseSize() { + const offset = this.bb.__offset(this.bb_pos, 12); + return offset ? this.bb.readUint32(this.bb_pos + offset) : 4; + } + mutate_base_size(value) { + const offset = this.bb.__offset(this.bb_pos, 12); + if (offset === 0) { + return false; + } + this.bb.writeUint32(this.bb_pos + offset, value); + return true; + } + /** + * The size (octets) of the `element` field, if present. + */ + elementSize() { + const offset = this.bb.__offset(this.bb_pos, 14); + return offset ? this.bb.readUint32(this.bb_pos + offset) : 0; + } + mutate_element_size(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; + } + static getFullyQualifiedName() { + return 'reflection_Type'; + } + static startType(builder) { + builder.startObject(6); + } + static addBaseType(builder, baseType) { + builder.addFieldInt8(0, baseType, BaseType.None); + } + static addElement(builder, element) { + builder.addFieldInt8(1, element, BaseType.None); + } + static addIndex(builder, index) { + builder.addFieldInt32(2, index, -1); + } + static addFixedLength(builder, fixedLength) { + builder.addFieldInt16(3, fixedLength, 0); + } + static addBaseSize(builder, baseSize) { + builder.addFieldInt32(4, baseSize, 4); + } + static addElementSize(builder, elementSize) { + builder.addFieldInt32(5, elementSize, 0); + } + static endType(builder) { + const offset = builder.endObject(); + return offset; + } + static createType(builder, baseType, element, index, fixedLength, baseSize, elementSize) { + Type.startType(builder); + Type.addBaseType(builder, baseType); + Type.addElement(builder, element); + Type.addIndex(builder, index); + Type.addFixedLength(builder, fixedLength); + Type.addBaseSize(builder, baseSize); + Type.addElementSize(builder, elementSize); + return Type.endType(builder); + } + unpack() { + return new TypeT(this.baseType(), this.element(), this.index(), this.fixedLength(), this.baseSize(), this.elementSize()); + } + unpackTo(_o) { + _o.baseType = this.baseType(); + _o.element = this.element(); + _o.index = this.index(); + _o.fixedLength = this.fixedLength(); + _o.baseSize = this.baseSize(); + _o.elementSize = this.elementSize(); + } +} +export class TypeT { + constructor(baseType = BaseType.None, element = BaseType.None, index = -1, fixedLength = 0, baseSize = 4, elementSize = 0) { + this.baseType = baseType; + this.element = element; + this.index = index; + this.fixedLength = fixedLength; + this.baseSize = baseSize; + this.elementSize = elementSize; + } + pack(builder) { + return Type.createType(builder, this.baseType, this.element, this.index, this.fixedLength, this.baseSize, this.elementSize); + } +} +export class KeyValue { + constructor() { + this.bb = null; + this.bb_pos = 0; + } + __init(i, bb) { + this.bb_pos = i; + this.bb = bb; + return this; + } + static getRootAsKeyValue(bb, obj) { + return (obj || new KeyValue()).__init(bb.readInt32(bb.position()) + bb.position(), bb); + } + static getSizePrefixedRootAsKeyValue(bb, obj) { + bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); + return (obj || new KeyValue()).__init(bb.readInt32(bb.position()) + bb.position(), bb); + } + key(optionalEncoding) { + const offset = this.bb.__offset(this.bb_pos, 4); + return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null; + } + value(optionalEncoding) { + const offset = this.bb.__offset(this.bb_pos, 6); + return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null; + } + static getFullyQualifiedName() { + return 'reflection_KeyValue'; + } + static startKeyValue(builder) { + builder.startObject(2); + } + static addKey(builder, keyOffset) { + builder.addFieldOffset(0, keyOffset, 0); + } + static addValue(builder, valueOffset) { + builder.addFieldOffset(1, valueOffset, 0); + } + static endKeyValue(builder) { + const offset = builder.endObject(); + builder.requiredField(offset, 4); // key + return offset; + } + static createKeyValue(builder, keyOffset, valueOffset) { + KeyValue.startKeyValue(builder); + KeyValue.addKey(builder, keyOffset); + KeyValue.addValue(builder, valueOffset); + return KeyValue.endKeyValue(builder); + } + unpack() { + return new KeyValueT(this.key(), this.value()); + } + unpackTo(_o) { + _o.key = this.key(); + _o.value = this.value(); + } +} +export class KeyValueT { + constructor(key = null, value = null) { + this.key = key; + this.value = value; + } + pack(builder) { + const key = (this.key !== null ? builder.createString(this.key) : 0); + const value = (this.value !== null ? builder.createString(this.value) : 0); + return KeyValue.createKeyValue(builder, key, value); + } +} +export class EnumVal { + constructor() { + this.bb = null; + this.bb_pos = 0; + } + __init(i, bb) { + this.bb_pos = i; + this.bb = bb; + return this; + } + static getRootAsEnumVal(bb, obj) { + return (obj || new EnumVal()).__init(bb.readInt32(bb.position()) + bb.position(), bb); + } + static getSizePrefixedRootAsEnumVal(bb, obj) { + bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); + return (obj || new EnumVal()).__init(bb.readInt32(bb.position()) + bb.position(), bb); + } + name(optionalEncoding) { + const offset = this.bb.__offset(this.bb_pos, 4); + return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null; + } + value() { + const offset = this.bb.__offset(this.bb_pos, 6); + return offset ? this.bb.readInt64(this.bb_pos + offset) : BigInt('0'); + } + mutate_value(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; + } + unionType(obj) { + const offset = this.bb.__offset(this.bb_pos, 10); + return offset ? (obj || new Type()).__init(this.bb.__indirect(this.bb_pos + offset), this.bb) : null; + } + documentation(index, optionalEncoding) { + const offset = this.bb.__offset(this.bb_pos, 12); + return offset ? this.bb.__string(this.bb.__vector(this.bb_pos + offset) + index * 4, optionalEncoding) : null; + } + documentationLength() { + const offset = this.bb.__offset(this.bb_pos, 12); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; + } + static getFullyQualifiedName() { + return 'reflection_EnumVal'; + } + static startEnumVal(builder) { + builder.startObject(5); + } + static addName(builder, nameOffset) { + builder.addFieldOffset(0, nameOffset, 0); + } + static addValue(builder, value) { + builder.addFieldInt64(1, value, BigInt('0')); + } + static addUnionType(builder, unionTypeOffset) { + builder.addFieldOffset(3, unionTypeOffset, 0); + } + static addDocumentation(builder, documentationOffset) { + builder.addFieldOffset(4, documentationOffset, 0); + } + static createDocumentationVector(builder, data) { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addOffset(data[i]); + } + return builder.endVector(); + } + static startDocumentationVector(builder, numElems) { + builder.startVector(4, numElems, 4); + } + static endEnumVal(builder) { + const offset = builder.endObject(); + builder.requiredField(offset, 4); // name + return offset; + } + unpack() { + return new EnumValT(this.name(), this.value(), (this.unionType() !== null ? this.unionType().unpack() : null), this.bb.createScalarList(this.documentation.bind(this), this.documentationLength())); + } + unpackTo(_o) { + _o.name = this.name(); + _o.value = this.value(); + _o.unionType = (this.unionType() !== null ? this.unionType().unpack() : null); + _o.documentation = this.bb.createScalarList(this.documentation.bind(this), this.documentationLength()); + } +} +export class EnumValT { + constructor(name = null, value = BigInt('0'), unionType = null, documentation = []) { + this.name = name; + this.value = value; + this.unionType = unionType; + this.documentation = documentation; + } + pack(builder) { + const name = (this.name !== null ? builder.createString(this.name) : 0); + const unionType = (this.unionType !== null ? this.unionType.pack(builder) : 0); + const documentation = EnumVal.createDocumentationVector(builder, builder.createObjectOffsetList(this.documentation)); + EnumVal.startEnumVal(builder); + EnumVal.addName(builder, name); + EnumVal.addValue(builder, this.value); + EnumVal.addUnionType(builder, unionType); + EnumVal.addDocumentation(builder, documentation); + return EnumVal.endEnumVal(builder); + } +} +export class Enum { + constructor() { + this.bb = null; + this.bb_pos = 0; + } + __init(i, bb) { + this.bb_pos = i; + this.bb = bb; + return this; + } + static getRootAsEnum(bb, obj) { + return (obj || new Enum()).__init(bb.readInt32(bb.position()) + bb.position(), bb); + } + static getSizePrefixedRootAsEnum(bb, obj) { + bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); + return (obj || new Enum()).__init(bb.readInt32(bb.position()) + bb.position(), bb); + } + name(optionalEncoding) { + const offset = this.bb.__offset(this.bb_pos, 4); + return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null; + } + values(index, obj) { + const offset = this.bb.__offset(this.bb_pos, 6); + return offset ? (obj || new EnumVal()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4), this.bb) : null; + } + valuesLength() { + const offset = this.bb.__offset(this.bb_pos, 6); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; + } + isUnion() { + const offset = this.bb.__offset(this.bb_pos, 8); + return offset ? !!this.bb.readInt8(this.bb_pos + offset) : false; + } + mutate_is_union(value) { + const offset = this.bb.__offset(this.bb_pos, 8); + if (offset === 0) { + return false; + } + this.bb.writeInt8(this.bb_pos + offset, +value); + return true; + } + underlyingType(obj) { + const offset = this.bb.__offset(this.bb_pos, 10); + return offset ? (obj || new Type()).__init(this.bb.__indirect(this.bb_pos + offset), this.bb) : null; + } + attributes(index, obj) { + const offset = this.bb.__offset(this.bb_pos, 12); + return offset ? (obj || new KeyValue()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4), this.bb) : null; + } + attributesLength() { + const offset = this.bb.__offset(this.bb_pos, 12); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; + } + documentation(index, optionalEncoding) { + const offset = this.bb.__offset(this.bb_pos, 14); + return offset ? this.bb.__string(this.bb.__vector(this.bb_pos + offset) + index * 4, optionalEncoding) : null; + } + documentationLength() { + const offset = this.bb.__offset(this.bb_pos, 14); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; + } + declarationFile(optionalEncoding) { + const offset = this.bb.__offset(this.bb_pos, 16); + return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null; + } + static getFullyQualifiedName() { + return 'reflection_Enum'; + } + static startEnum(builder) { + builder.startObject(7); + } + static addName(builder, nameOffset) { + builder.addFieldOffset(0, nameOffset, 0); + } + static addValues(builder, valuesOffset) { + builder.addFieldOffset(1, valuesOffset, 0); + } + static createValuesVector(builder, data) { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addOffset(data[i]); + } + return builder.endVector(); + } + static startValuesVector(builder, numElems) { + builder.startVector(4, numElems, 4); + } + static addIsUnion(builder, isUnion) { + builder.addFieldInt8(2, +isUnion, +false); + } + static addUnderlyingType(builder, underlyingTypeOffset) { + builder.addFieldOffset(3, underlyingTypeOffset, 0); + } + static addAttributes(builder, attributesOffset) { + builder.addFieldOffset(4, attributesOffset, 0); + } + static createAttributesVector(builder, data) { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addOffset(data[i]); + } + return builder.endVector(); + } + static startAttributesVector(builder, numElems) { + builder.startVector(4, numElems, 4); + } + static addDocumentation(builder, documentationOffset) { + builder.addFieldOffset(5, documentationOffset, 0); + } + static createDocumentationVector(builder, data) { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addOffset(data[i]); + } + return builder.endVector(); + } + static startDocumentationVector(builder, numElems) { + builder.startVector(4, numElems, 4); + } + static addDeclarationFile(builder, declarationFileOffset) { + builder.addFieldOffset(6, declarationFileOffset, 0); + } + static endEnum(builder) { + const offset = builder.endObject(); + builder.requiredField(offset, 4); // name + builder.requiredField(offset, 6); // values + builder.requiredField(offset, 10); // underlying_type + return offset; + } + unpack() { + return new EnumT(this.name(), this.bb.createObjList(this.values.bind(this), this.valuesLength()), this.isUnion(), (this.underlyingType() !== null ? this.underlyingType().unpack() : null), this.bb.createObjList(this.attributes.bind(this), this.attributesLength()), this.bb.createScalarList(this.documentation.bind(this), this.documentationLength()), this.declarationFile()); + } + unpackTo(_o) { + _o.name = this.name(); + _o.values = this.bb.createObjList(this.values.bind(this), this.valuesLength()); + _o.isUnion = this.isUnion(); + _o.underlyingType = (this.underlyingType() !== null ? this.underlyingType().unpack() : null); + _o.attributes = this.bb.createObjList(this.attributes.bind(this), this.attributesLength()); + _o.documentation = this.bb.createScalarList(this.documentation.bind(this), this.documentationLength()); + _o.declarationFile = this.declarationFile(); + } +} +export class EnumT { + constructor(name = null, values = [], isUnion = false, underlyingType = null, attributes = [], documentation = [], declarationFile = null) { + this.name = name; + this.values = values; + this.isUnion = isUnion; + this.underlyingType = underlyingType; + this.attributes = attributes; + this.documentation = documentation; + this.declarationFile = declarationFile; + } + pack(builder) { + const name = (this.name !== null ? builder.createString(this.name) : 0); + const values = Enum.createValuesVector(builder, builder.createObjectOffsetList(this.values)); + const underlyingType = (this.underlyingType !== null ? this.underlyingType.pack(builder) : 0); + const attributes = Enum.createAttributesVector(builder, builder.createObjectOffsetList(this.attributes)); + const documentation = Enum.createDocumentationVector(builder, builder.createObjectOffsetList(this.documentation)); + const declarationFile = (this.declarationFile !== null ? builder.createString(this.declarationFile) : 0); + Enum.startEnum(builder); + Enum.addName(builder, name); + Enum.addValues(builder, values); + Enum.addIsUnion(builder, this.isUnion); + Enum.addUnderlyingType(builder, underlyingType); + Enum.addAttributes(builder, attributes); + Enum.addDocumentation(builder, documentation); + Enum.addDeclarationFile(builder, declarationFile); + return Enum.endEnum(builder); + } +} +export class Field { + constructor() { + this.bb = null; + this.bb_pos = 0; + } + __init(i, bb) { + this.bb_pos = i; + this.bb = bb; + return this; + } + static getRootAsField(bb, obj) { + return (obj || new Field()).__init(bb.readInt32(bb.position()) + bb.position(), bb); + } + static getSizePrefixedRootAsField(bb, obj) { + bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); + return (obj || new Field()).__init(bb.readInt32(bb.position()) + bb.position(), bb); + } + name(optionalEncoding) { + const offset = this.bb.__offset(this.bb_pos, 4); + return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null; + } + type(obj) { + const offset = this.bb.__offset(this.bb_pos, 6); + return offset ? (obj || new Type()).__init(this.bb.__indirect(this.bb_pos + offset), this.bb) : null; + } + id() { + const offset = this.bb.__offset(this.bb_pos, 8); + return offset ? this.bb.readUint16(this.bb_pos + offset) : 0; + } + mutate_id(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; + } + offset() { + const offset = this.bb.__offset(this.bb_pos, 10); + return offset ? this.bb.readUint16(this.bb_pos + offset) : 0; + } + mutate_offset(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; + } + defaultInteger() { + const offset = this.bb.__offset(this.bb_pos, 12); + return offset ? this.bb.readInt64(this.bb_pos + offset) : BigInt('0'); + } + mutate_default_integer(value) { + const offset = this.bb.__offset(this.bb_pos, 12); + if (offset === 0) { + return false; + } + this.bb.writeInt64(this.bb_pos + offset, value); + return true; + } + defaultReal() { + const offset = this.bb.__offset(this.bb_pos, 14); + return offset ? this.bb.readFloat64(this.bb_pos + offset) : 0.0; + } + mutate_default_real(value) { + const offset = this.bb.__offset(this.bb_pos, 14); + if (offset === 0) { + return false; + } + this.bb.writeFloat64(this.bb_pos + offset, value); + return true; + } + deprecated() { + const offset = this.bb.__offset(this.bb_pos, 16); + return offset ? !!this.bb.readInt8(this.bb_pos + offset) : false; + } + mutate_deprecated(value) { + const offset = this.bb.__offset(this.bb_pos, 16); + if (offset === 0) { + return false; + } + this.bb.writeInt8(this.bb_pos + offset, +value); + return true; + } + required() { + const offset = this.bb.__offset(this.bb_pos, 18); + return offset ? !!this.bb.readInt8(this.bb_pos + offset) : false; + } + mutate_required(value) { + const offset = this.bb.__offset(this.bb_pos, 18); + if (offset === 0) { + return false; + } + this.bb.writeInt8(this.bb_pos + offset, +value); + return true; + } + key() { + const offset = this.bb.__offset(this.bb_pos, 20); + return offset ? !!this.bb.readInt8(this.bb_pos + offset) : false; + } + mutate_key(value) { + const offset = this.bb.__offset(this.bb_pos, 20); + if (offset === 0) { + return false; + } + this.bb.writeInt8(this.bb_pos + offset, +value); + return true; + } + attributes(index, obj) { + const offset = this.bb.__offset(this.bb_pos, 22); + return offset ? (obj || new KeyValue()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4), this.bb) : null; + } + attributesLength() { + const offset = this.bb.__offset(this.bb_pos, 22); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; + } + documentation(index, optionalEncoding) { + const offset = this.bb.__offset(this.bb_pos, 24); + return offset ? this.bb.__string(this.bb.__vector(this.bb_pos + offset) + index * 4, optionalEncoding) : null; + } + documentationLength() { + const offset = this.bb.__offset(this.bb_pos, 24); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; + } + optional() { + const offset = this.bb.__offset(this.bb_pos, 26); + return offset ? !!this.bb.readInt8(this.bb_pos + offset) : false; + } + mutate_optional(value) { + const offset = this.bb.__offset(this.bb_pos, 26); + if (offset === 0) { + return false; + } + this.bb.writeInt8(this.bb_pos + offset, +value); + return true; + } + /** + * Number of padding octets to always add after this field. Structs only. + */ + padding() { + const offset = this.bb.__offset(this.bb_pos, 28); + return offset ? this.bb.readUint16(this.bb_pos + offset) : 0; + } + mutate_padding(value) { + const offset = this.bb.__offset(this.bb_pos, 28); + if (offset === 0) { + return false; + } + this.bb.writeUint16(this.bb_pos + offset, value); + return true; + } + static getFullyQualifiedName() { + return 'reflection_Field'; + } + static startField(builder) { + builder.startObject(13); + } + static addName(builder, nameOffset) { + builder.addFieldOffset(0, nameOffset, 0); + } + static addType(builder, typeOffset) { + builder.addFieldOffset(1, typeOffset, 0); + } + static addId(builder, id) { + builder.addFieldInt16(2, id, 0); + } + static addOffset(builder, offset) { + builder.addFieldInt16(3, offset, 0); + } + static addDefaultInteger(builder, defaultInteger) { + builder.addFieldInt64(4, defaultInteger, BigInt('0')); + } + static addDefaultReal(builder, defaultReal) { + builder.addFieldFloat64(5, defaultReal, 0.0); + } + static addDeprecated(builder, deprecated) { + builder.addFieldInt8(6, +deprecated, +false); + } + static addRequired(builder, required) { + builder.addFieldInt8(7, +required, +false); + } + static addKey(builder, key) { + builder.addFieldInt8(8, +key, +false); + } + static addAttributes(builder, attributesOffset) { + builder.addFieldOffset(9, attributesOffset, 0); + } + static createAttributesVector(builder, data) { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addOffset(data[i]); + } + return builder.endVector(); + } + static startAttributesVector(builder, numElems) { + builder.startVector(4, numElems, 4); + } + static addDocumentation(builder, documentationOffset) { + builder.addFieldOffset(10, documentationOffset, 0); + } + static createDocumentationVector(builder, data) { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addOffset(data[i]); + } + return builder.endVector(); + } + static startDocumentationVector(builder, numElems) { + builder.startVector(4, numElems, 4); + } + static addOptional(builder, optional) { + builder.addFieldInt8(11, +optional, +false); + } + static addPadding(builder, padding) { + builder.addFieldInt16(12, padding, 0); + } + static endField(builder) { + const offset = builder.endObject(); + builder.requiredField(offset, 4); // name + builder.requiredField(offset, 6); // type + return offset; + } + unpack() { + return new FieldT(this.name(), (this.type() !== null ? this.type().unpack() : null), this.id(), this.offset(), this.defaultInteger(), this.defaultReal(), this.deprecated(), this.required(), this.key(), this.bb.createObjList(this.attributes.bind(this), this.attributesLength()), this.bb.createScalarList(this.documentation.bind(this), this.documentationLength()), this.optional(), this.padding()); + } + unpackTo(_o) { + _o.name = this.name(); + _o.type = (this.type() !== null ? this.type().unpack() : null); + _o.id = this.id(); + _o.offset = this.offset(); + _o.defaultInteger = this.defaultInteger(); + _o.defaultReal = this.defaultReal(); + _o.deprecated = this.deprecated(); + _o.required = this.required(); + _o.key = this.key(); + _o.attributes = this.bb.createObjList(this.attributes.bind(this), this.attributesLength()); + _o.documentation = this.bb.createScalarList(this.documentation.bind(this), this.documentationLength()); + _o.optional = this.optional(); + _o.padding = this.padding(); + } +} +export class FieldT { + constructor(name = null, type = null, id = 0, offset = 0, defaultInteger = BigInt('0'), defaultReal = 0.0, deprecated = false, required = false, key = false, attributes = [], documentation = [], optional = false, padding = 0) { + this.name = name; + this.type = type; + this.id = id; + this.offset = offset; + this.defaultInteger = defaultInteger; + this.defaultReal = defaultReal; + this.deprecated = deprecated; + this.required = required; + this.key = key; + this.attributes = attributes; + this.documentation = documentation; + this.optional = optional; + this.padding = padding; + } + pack(builder) { + const name = (this.name !== null ? builder.createString(this.name) : 0); + const type = (this.type !== null ? this.type.pack(builder) : 0); + const attributes = Field.createAttributesVector(builder, builder.createObjectOffsetList(this.attributes)); + const documentation = Field.createDocumentationVector(builder, builder.createObjectOffsetList(this.documentation)); + Field.startField(builder); + Field.addName(builder, name); + Field.addType(builder, type); + Field.addId(builder, this.id); + Field.addOffset(builder, this.offset); + Field.addDefaultInteger(builder, this.defaultInteger); + Field.addDefaultReal(builder, this.defaultReal); + Field.addDeprecated(builder, this.deprecated); + Field.addRequired(builder, this.required); + Field.addKey(builder, this.key); + Field.addAttributes(builder, attributes); + Field.addDocumentation(builder, documentation); + Field.addOptional(builder, this.optional); + Field.addPadding(builder, this.padding); + return Field.endField(builder); + } +} +export class Object_ { + constructor() { + this.bb = null; + this.bb_pos = 0; + } + __init(i, bb) { + this.bb_pos = i; + this.bb = bb; + return this; + } + static getRootAsObject(bb, obj) { + return (obj || new Object_()).__init(bb.readInt32(bb.position()) + bb.position(), bb); + } + static getSizePrefixedRootAsObject(bb, obj) { + bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); + return (obj || new Object_()).__init(bb.readInt32(bb.position()) + bb.position(), bb); + } + name(optionalEncoding) { + const offset = this.bb.__offset(this.bb_pos, 4); + return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null; + } + fields(index, obj) { + const offset = this.bb.__offset(this.bb_pos, 6); + return offset ? (obj || new Field()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4), this.bb) : null; + } + fieldsLength() { + const offset = this.bb.__offset(this.bb_pos, 6); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; + } + isStruct() { + const offset = this.bb.__offset(this.bb_pos, 8); + return offset ? !!this.bb.readInt8(this.bb_pos + offset) : false; + } + mutate_is_struct(value) { + const offset = this.bb.__offset(this.bb_pos, 8); + if (offset === 0) { + return false; + } + this.bb.writeInt8(this.bb_pos + offset, +value); + return true; + } + minalign() { + const offset = this.bb.__offset(this.bb_pos, 10); + return offset ? this.bb.readInt32(this.bb_pos + offset) : 0; + } + mutate_minalign(value) { + const offset = this.bb.__offset(this.bb_pos, 10); + if (offset === 0) { + return false; + } + this.bb.writeInt32(this.bb_pos + offset, value); + return true; + } + bytesize() { + const offset = this.bb.__offset(this.bb_pos, 12); + return offset ? this.bb.readInt32(this.bb_pos + offset) : 0; + } + mutate_bytesize(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; + } + attributes(index, obj) { + const offset = this.bb.__offset(this.bb_pos, 14); + return offset ? (obj || new KeyValue()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4), this.bb) : null; + } + attributesLength() { + const offset = this.bb.__offset(this.bb_pos, 14); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; + } + documentation(index, optionalEncoding) { + const offset = this.bb.__offset(this.bb_pos, 16); + return offset ? this.bb.__string(this.bb.__vector(this.bb_pos + offset) + index * 4, optionalEncoding) : null; + } + documentationLength() { + const offset = this.bb.__offset(this.bb_pos, 16); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; + } + declarationFile(optionalEncoding) { + const offset = this.bb.__offset(this.bb_pos, 18); + return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null; + } + static getFullyQualifiedName() { + return 'reflection_Object'; + } + static startObject(builder) { + builder.startObject(8); + } + static addName(builder, nameOffset) { + builder.addFieldOffset(0, nameOffset, 0); + } + static addFields(builder, fieldsOffset) { + builder.addFieldOffset(1, fieldsOffset, 0); + } + static createFieldsVector(builder, data) { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addOffset(data[i]); + } + return builder.endVector(); + } + static startFieldsVector(builder, numElems) { + builder.startVector(4, numElems, 4); + } + static addIsStruct(builder, isStruct) { + builder.addFieldInt8(2, +isStruct, +false); + } + static addMinalign(builder, minalign) { + builder.addFieldInt32(3, minalign, 0); + } + static addBytesize(builder, bytesize) { + builder.addFieldInt32(4, bytesize, 0); + } + static addAttributes(builder, attributesOffset) { + builder.addFieldOffset(5, attributesOffset, 0); + } + static createAttributesVector(builder, data) { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addOffset(data[i]); + } + return builder.endVector(); + } + static startAttributesVector(builder, numElems) { + builder.startVector(4, numElems, 4); + } + static addDocumentation(builder, documentationOffset) { + builder.addFieldOffset(6, documentationOffset, 0); + } + static createDocumentationVector(builder, data) { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addOffset(data[i]); + } + return builder.endVector(); + } + static startDocumentationVector(builder, numElems) { + builder.startVector(4, numElems, 4); + } + static addDeclarationFile(builder, declarationFileOffset) { + builder.addFieldOffset(7, declarationFileOffset, 0); + } + static endObject(builder) { + const offset = builder.endObject(); + builder.requiredField(offset, 4); // name + builder.requiredField(offset, 6); // fields + return offset; + } + static createObject(builder, nameOffset, fieldsOffset, isStruct, minalign, bytesize, attributesOffset, documentationOffset, declarationFileOffset) { + Object_.startObject(builder); + Object_.addName(builder, nameOffset); + Object_.addFields(builder, fieldsOffset); + Object_.addIsStruct(builder, isStruct); + Object_.addMinalign(builder, minalign); + Object_.addBytesize(builder, bytesize); + Object_.addAttributes(builder, attributesOffset); + Object_.addDocumentation(builder, documentationOffset); + Object_.addDeclarationFile(builder, declarationFileOffset); + return Object_.endObject(builder); + } + unpack() { + return new Object_T(this.name(), this.bb.createObjList(this.fields.bind(this), this.fieldsLength()), this.isStruct(), this.minalign(), this.bytesize(), this.bb.createObjList(this.attributes.bind(this), this.attributesLength()), this.bb.createScalarList(this.documentation.bind(this), this.documentationLength()), this.declarationFile()); + } + unpackTo(_o) { + _o.name = this.name(); + _o.fields = this.bb.createObjList(this.fields.bind(this), this.fieldsLength()); + _o.isStruct = this.isStruct(); + _o.minalign = this.minalign(); + _o.bytesize = this.bytesize(); + _o.attributes = this.bb.createObjList(this.attributes.bind(this), this.attributesLength()); + _o.documentation = this.bb.createScalarList(this.documentation.bind(this), this.documentationLength()); + _o.declarationFile = this.declarationFile(); + } +} +export class Object_T { + constructor(name = null, fields = [], isStruct = false, minalign = 0, bytesize = 0, attributes = [], documentation = [], declarationFile = null) { + this.name = name; + this.fields = fields; + this.isStruct = isStruct; + this.minalign = minalign; + this.bytesize = bytesize; + this.attributes = attributes; + this.documentation = documentation; + this.declarationFile = declarationFile; + } + pack(builder) { + const name = (this.name !== null ? builder.createString(this.name) : 0); + const fields = Object_.createFieldsVector(builder, builder.createObjectOffsetList(this.fields)); + const attributes = Object_.createAttributesVector(builder, builder.createObjectOffsetList(this.attributes)); + const documentation = Object_.createDocumentationVector(builder, builder.createObjectOffsetList(this.documentation)); + const declarationFile = (this.declarationFile !== null ? builder.createString(this.declarationFile) : 0); + return Object_.createObject(builder, name, fields, this.isStruct, this.minalign, this.bytesize, attributes, documentation, declarationFile); + } +} +export class RPCCall { + constructor() { + this.bb = null; + this.bb_pos = 0; + } + __init(i, bb) { + this.bb_pos = i; + this.bb = bb; + return this; + } + static getRootAsRPCCall(bb, obj) { + return (obj || new RPCCall()).__init(bb.readInt32(bb.position()) + bb.position(), bb); + } + static getSizePrefixedRootAsRPCCall(bb, obj) { + bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); + return (obj || new RPCCall()).__init(bb.readInt32(bb.position()) + bb.position(), bb); + } + name(optionalEncoding) { + const offset = this.bb.__offset(this.bb_pos, 4); + return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null; + } + request(obj) { + const offset = this.bb.__offset(this.bb_pos, 6); + return offset ? (obj || new Object_()).__init(this.bb.__indirect(this.bb_pos + offset), this.bb) : null; + } + response(obj) { + const offset = this.bb.__offset(this.bb_pos, 8); + return offset ? (obj || new Object_()).__init(this.bb.__indirect(this.bb_pos + offset), this.bb) : null; + } + attributes(index, obj) { + const offset = this.bb.__offset(this.bb_pos, 10); + return offset ? (obj || new KeyValue()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4), this.bb) : null; + } + attributesLength() { + const offset = this.bb.__offset(this.bb_pos, 10); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; + } + documentation(index, optionalEncoding) { + const offset = this.bb.__offset(this.bb_pos, 12); + return offset ? this.bb.__string(this.bb.__vector(this.bb_pos + offset) + index * 4, optionalEncoding) : null; + } + documentationLength() { + const offset = this.bb.__offset(this.bb_pos, 12); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; + } + static getFullyQualifiedName() { + return 'reflection_RPCCall'; + } + static startRPCCall(builder) { + builder.startObject(5); + } + static addName(builder, nameOffset) { + builder.addFieldOffset(0, nameOffset, 0); + } + static addRequest(builder, requestOffset) { + builder.addFieldOffset(1, requestOffset, 0); + } + static addResponse(builder, responseOffset) { + builder.addFieldOffset(2, responseOffset, 0); + } + static addAttributes(builder, attributesOffset) { + builder.addFieldOffset(3, attributesOffset, 0); + } + static createAttributesVector(builder, data) { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addOffset(data[i]); + } + return builder.endVector(); + } + static startAttributesVector(builder, numElems) { + builder.startVector(4, numElems, 4); + } + static addDocumentation(builder, documentationOffset) { + builder.addFieldOffset(4, documentationOffset, 0); + } + static createDocumentationVector(builder, data) { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addOffset(data[i]); + } + return builder.endVector(); + } + static startDocumentationVector(builder, numElems) { + builder.startVector(4, numElems, 4); + } + static endRPCCall(builder) { + const offset = builder.endObject(); + builder.requiredField(offset, 4); // name + builder.requiredField(offset, 6); // request + builder.requiredField(offset, 8); // response + return offset; + } + unpack() { + return new RPCCallT(this.name(), (this.request() !== null ? this.request().unpack() : null), (this.response() !== null ? this.response().unpack() : null), this.bb.createObjList(this.attributes.bind(this), this.attributesLength()), this.bb.createScalarList(this.documentation.bind(this), this.documentationLength())); + } + unpackTo(_o) { + _o.name = this.name(); + _o.request = (this.request() !== null ? this.request().unpack() : null); + _o.response = (this.response() !== null ? this.response().unpack() : null); + _o.attributes = this.bb.createObjList(this.attributes.bind(this), this.attributesLength()); + _o.documentation = this.bb.createScalarList(this.documentation.bind(this), this.documentationLength()); + } +} +export class RPCCallT { + constructor(name = null, request = null, response = null, attributes = [], documentation = []) { + this.name = name; + this.request = request; + this.response = response; + this.attributes = attributes; + this.documentation = documentation; + } + pack(builder) { + const name = (this.name !== null ? builder.createString(this.name) : 0); + const request = (this.request !== null ? this.request.pack(builder) : 0); + const response = (this.response !== null ? this.response.pack(builder) : 0); + const attributes = RPCCall.createAttributesVector(builder, builder.createObjectOffsetList(this.attributes)); + const documentation = RPCCall.createDocumentationVector(builder, builder.createObjectOffsetList(this.documentation)); + RPCCall.startRPCCall(builder); + RPCCall.addName(builder, name); + RPCCall.addRequest(builder, request); + RPCCall.addResponse(builder, response); + RPCCall.addAttributes(builder, attributes); + RPCCall.addDocumentation(builder, documentation); + return RPCCall.endRPCCall(builder); + } +} +export class Service { + constructor() { + this.bb = null; + this.bb_pos = 0; + } + __init(i, bb) { + this.bb_pos = i; + this.bb = bb; + return this; + } + static getRootAsService(bb, obj) { + return (obj || new Service()).__init(bb.readInt32(bb.position()) + bb.position(), bb); + } + static getSizePrefixedRootAsService(bb, obj) { + bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); + return (obj || new Service()).__init(bb.readInt32(bb.position()) + bb.position(), bb); + } + name(optionalEncoding) { + const offset = this.bb.__offset(this.bb_pos, 4); + return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null; + } + calls(index, obj) { + const offset = this.bb.__offset(this.bb_pos, 6); + return offset ? (obj || new RPCCall()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4), this.bb) : null; + } + callsLength() { + const offset = this.bb.__offset(this.bb_pos, 6); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; + } + attributes(index, obj) { + const offset = this.bb.__offset(this.bb_pos, 8); + return offset ? (obj || new KeyValue()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4), this.bb) : null; + } + attributesLength() { + const offset = this.bb.__offset(this.bb_pos, 8); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; + } + documentation(index, optionalEncoding) { + const offset = this.bb.__offset(this.bb_pos, 10); + return offset ? this.bb.__string(this.bb.__vector(this.bb_pos + offset) + index * 4, optionalEncoding) : null; + } + documentationLength() { + const offset = this.bb.__offset(this.bb_pos, 10); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; + } + declarationFile(optionalEncoding) { + const offset = this.bb.__offset(this.bb_pos, 12); + return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null; + } + static getFullyQualifiedName() { + return 'reflection_Service'; + } + static startService(builder) { + builder.startObject(5); + } + static addName(builder, nameOffset) { + builder.addFieldOffset(0, nameOffset, 0); + } + static addCalls(builder, callsOffset) { + builder.addFieldOffset(1, callsOffset, 0); + } + static createCallsVector(builder, data) { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addOffset(data[i]); + } + return builder.endVector(); + } + static startCallsVector(builder, numElems) { + builder.startVector(4, numElems, 4); + } + static addAttributes(builder, attributesOffset) { + builder.addFieldOffset(2, attributesOffset, 0); + } + static createAttributesVector(builder, data) { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addOffset(data[i]); + } + return builder.endVector(); + } + static startAttributesVector(builder, numElems) { + builder.startVector(4, numElems, 4); + } + static addDocumentation(builder, documentationOffset) { + builder.addFieldOffset(3, documentationOffset, 0); + } + static createDocumentationVector(builder, data) { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addOffset(data[i]); + } + return builder.endVector(); + } + static startDocumentationVector(builder, numElems) { + builder.startVector(4, numElems, 4); + } + static addDeclarationFile(builder, declarationFileOffset) { + builder.addFieldOffset(4, declarationFileOffset, 0); + } + static endService(builder) { + const offset = builder.endObject(); + builder.requiredField(offset, 4); // name + return offset; + } + static createService(builder, nameOffset, callsOffset, attributesOffset, documentationOffset, declarationFileOffset) { + Service.startService(builder); + Service.addName(builder, nameOffset); + Service.addCalls(builder, callsOffset); + Service.addAttributes(builder, attributesOffset); + Service.addDocumentation(builder, documentationOffset); + Service.addDeclarationFile(builder, declarationFileOffset); + return Service.endService(builder); + } + unpack() { + return new ServiceT(this.name(), this.bb.createObjList(this.calls.bind(this), this.callsLength()), this.bb.createObjList(this.attributes.bind(this), this.attributesLength()), this.bb.createScalarList(this.documentation.bind(this), this.documentationLength()), this.declarationFile()); + } + unpackTo(_o) { + _o.name = this.name(); + _o.calls = this.bb.createObjList(this.calls.bind(this), this.callsLength()); + _o.attributes = this.bb.createObjList(this.attributes.bind(this), this.attributesLength()); + _o.documentation = this.bb.createScalarList(this.documentation.bind(this), this.documentationLength()); + _o.declarationFile = this.declarationFile(); + } +} +export class ServiceT { + constructor(name = null, calls = [], attributes = [], documentation = [], declarationFile = null) { + this.name = name; + this.calls = calls; + this.attributes = attributes; + this.documentation = documentation; + this.declarationFile = declarationFile; + } + pack(builder) { + const name = (this.name !== null ? builder.createString(this.name) : 0); + const calls = Service.createCallsVector(builder, builder.createObjectOffsetList(this.calls)); + const attributes = Service.createAttributesVector(builder, builder.createObjectOffsetList(this.attributes)); + const documentation = Service.createDocumentationVector(builder, builder.createObjectOffsetList(this.documentation)); + const declarationFile = (this.declarationFile !== null ? builder.createString(this.declarationFile) : 0); + return Service.createService(builder, name, calls, attributes, documentation, declarationFile); + } +} +/** + * File specific information. + * Symbols declared within a file may be recovered by iterating over all + * symbols and examining the `declaration_file` field. + */ +export class SchemaFile { + constructor() { + this.bb = null; + this.bb_pos = 0; + } + __init(i, bb) { + this.bb_pos = i; + this.bb = bb; + return this; + } + static getRootAsSchemaFile(bb, obj) { + return (obj || new SchemaFile()).__init(bb.readInt32(bb.position()) + bb.position(), bb); + } + static getSizePrefixedRootAsSchemaFile(bb, obj) { + bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); + return (obj || new SchemaFile()).__init(bb.readInt32(bb.position()) + bb.position(), bb); + } + filename(optionalEncoding) { + const offset = this.bb.__offset(this.bb_pos, 4); + return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null; + } + includedFilenames(index, optionalEncoding) { + const offset = this.bb.__offset(this.bb_pos, 6); + return offset ? this.bb.__string(this.bb.__vector(this.bb_pos + offset) + index * 4, optionalEncoding) : null; + } + includedFilenamesLength() { + const offset = this.bb.__offset(this.bb_pos, 6); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; + } + static getFullyQualifiedName() { + return 'reflection_SchemaFile'; + } + static startSchemaFile(builder) { + builder.startObject(2); + } + static addFilename(builder, filenameOffset) { + builder.addFieldOffset(0, filenameOffset, 0); + } + static addIncludedFilenames(builder, includedFilenamesOffset) { + builder.addFieldOffset(1, includedFilenamesOffset, 0); + } + static createIncludedFilenamesVector(builder, data) { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addOffset(data[i]); + } + return builder.endVector(); + } + static startIncludedFilenamesVector(builder, numElems) { + builder.startVector(4, numElems, 4); + } + static endSchemaFile(builder) { + const offset = builder.endObject(); + builder.requiredField(offset, 4); // filename + return offset; + } + static createSchemaFile(builder, filenameOffset, includedFilenamesOffset) { + SchemaFile.startSchemaFile(builder); + SchemaFile.addFilename(builder, filenameOffset); + SchemaFile.addIncludedFilenames(builder, includedFilenamesOffset); + return SchemaFile.endSchemaFile(builder); + } + unpack() { + return new SchemaFileT(this.filename(), this.bb.createScalarList(this.includedFilenames.bind(this), this.includedFilenamesLength())); + } + unpackTo(_o) { + _o.filename = this.filename(); + _o.includedFilenames = this.bb.createScalarList(this.includedFilenames.bind(this), this.includedFilenamesLength()); + } +} +export class SchemaFileT { + constructor(filename = null, includedFilenames = []) { + this.filename = filename; + this.includedFilenames = includedFilenames; + } + pack(builder) { + const filename = (this.filename !== null ? builder.createString(this.filename) : 0); + const includedFilenames = SchemaFile.createIncludedFilenamesVector(builder, builder.createObjectOffsetList(this.includedFilenames)); + return SchemaFile.createSchemaFile(builder, filename, includedFilenames); + } +} +export class Schema { + constructor() { + this.bb = null; + this.bb_pos = 0; + } + __init(i, bb) { + this.bb_pos = i; + this.bb = bb; + return this; + } + static getRootAsSchema(bb, obj) { + return (obj || new Schema()).__init(bb.readInt32(bb.position()) + bb.position(), bb); + } + static getSizePrefixedRootAsSchema(bb, obj) { + bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); + return (obj || new Schema()).__init(bb.readInt32(bb.position()) + bb.position(), bb); + } + static bufferHasIdentifier(bb) { + return bb.__has_identifier('BFBS'); + } + objects(index, obj) { + const offset = this.bb.__offset(this.bb_pos, 4); + return offset ? (obj || new Object_()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4), this.bb) : null; + } + objectsLength() { + const offset = this.bb.__offset(this.bb_pos, 4); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; + } + enums(index, obj) { + const offset = this.bb.__offset(this.bb_pos, 6); + return offset ? (obj || new Enum()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4), this.bb) : null; + } + enumsLength() { + const offset = this.bb.__offset(this.bb_pos, 6); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; + } + fileIdent(optionalEncoding) { + const offset = this.bb.__offset(this.bb_pos, 8); + return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null; + } + fileExt(optionalEncoding) { + const offset = this.bb.__offset(this.bb_pos, 10); + return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null; + } + rootTable(obj) { + const offset = this.bb.__offset(this.bb_pos, 12); + return offset ? (obj || new Object_()).__init(this.bb.__indirect(this.bb_pos + offset), this.bb) : null; + } + services(index, obj) { + const offset = this.bb.__offset(this.bb_pos, 14); + return offset ? (obj || new Service()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4), this.bb) : null; + } + servicesLength() { + const offset = this.bb.__offset(this.bb_pos, 14); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; + } + advancedFeatures() { + const offset = this.bb.__offset(this.bb_pos, 16); + return offset ? this.bb.readUint64(this.bb_pos + offset) : BigInt('0'); + } + mutate_advanced_features(value) { + const offset = this.bb.__offset(this.bb_pos, 16); + if (offset === 0) { + return false; + } + this.bb.writeUint64(this.bb_pos + offset, value); + return true; + } + /** + * All the files used in this compilation. Files are relative to where + * flatc was invoked. + */ + fbsFiles(index, obj) { + const offset = this.bb.__offset(this.bb_pos, 18); + return offset ? (obj || new SchemaFile()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4), this.bb) : null; + } + fbsFilesLength() { + const offset = this.bb.__offset(this.bb_pos, 18); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; + } + static getFullyQualifiedName() { + return 'reflection_Schema'; + } + static startSchema(builder) { + builder.startObject(8); + } + static addObjects(builder, objectsOffset) { + builder.addFieldOffset(0, objectsOffset, 0); + } + static createObjectsVector(builder, data) { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addOffset(data[i]); + } + return builder.endVector(); + } + static startObjectsVector(builder, numElems) { + builder.startVector(4, numElems, 4); + } + static addEnums(builder, enumsOffset) { + builder.addFieldOffset(1, enumsOffset, 0); + } + static createEnumsVector(builder, data) { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addOffset(data[i]); + } + return builder.endVector(); + } + static startEnumsVector(builder, numElems) { + builder.startVector(4, numElems, 4); + } + static addFileIdent(builder, fileIdentOffset) { + builder.addFieldOffset(2, fileIdentOffset, 0); + } + static addFileExt(builder, fileExtOffset) { + builder.addFieldOffset(3, fileExtOffset, 0); + } + static addRootTable(builder, rootTableOffset) { + builder.addFieldOffset(4, rootTableOffset, 0); + } + static addServices(builder, servicesOffset) { + builder.addFieldOffset(5, servicesOffset, 0); + } + static createServicesVector(builder, data) { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addOffset(data[i]); + } + return builder.endVector(); + } + static startServicesVector(builder, numElems) { + builder.startVector(4, numElems, 4); + } + static addAdvancedFeatures(builder, advancedFeatures) { + builder.addFieldInt64(6, advancedFeatures, BigInt('0')); + } + static addFbsFiles(builder, fbsFilesOffset) { + builder.addFieldOffset(7, fbsFilesOffset, 0); + } + static createFbsFilesVector(builder, data) { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addOffset(data[i]); + } + return builder.endVector(); + } + static startFbsFilesVector(builder, numElems) { + builder.startVector(4, numElems, 4); + } + static endSchema(builder) { + const offset = builder.endObject(); + builder.requiredField(offset, 4); // objects + builder.requiredField(offset, 6); // enums + return offset; + } + static finishSchemaBuffer(builder, offset) { + builder.finish(offset, 'BFBS'); + } + static finishSizePrefixedSchemaBuffer(builder, offset) { + builder.finish(offset, 'BFBS', true); + } + unpack() { + return new SchemaT(this.bb.createObjList(this.objects.bind(this), this.objectsLength()), this.bb.createObjList(this.enums.bind(this), this.enumsLength()), this.fileIdent(), this.fileExt(), (this.rootTable() !== null ? this.rootTable().unpack() : null), this.bb.createObjList(this.services.bind(this), this.servicesLength()), this.advancedFeatures(), this.bb.createObjList(this.fbsFiles.bind(this), this.fbsFilesLength())); + } + unpackTo(_o) { + _o.objects = this.bb.createObjList(this.objects.bind(this), this.objectsLength()); + _o.enums = this.bb.createObjList(this.enums.bind(this), this.enumsLength()); + _o.fileIdent = this.fileIdent(); + _o.fileExt = this.fileExt(); + _o.rootTable = (this.rootTable() !== null ? this.rootTable().unpack() : null); + _o.services = this.bb.createObjList(this.services.bind(this), this.servicesLength()); + _o.advancedFeatures = this.advancedFeatures(); + _o.fbsFiles = this.bb.createObjList(this.fbsFiles.bind(this), this.fbsFilesLength()); + } +} +export class SchemaT { + constructor(objects = [], enums = [], fileIdent = null, fileExt = null, rootTable = null, services = [], advancedFeatures = BigInt('0'), fbsFiles = []) { + this.objects = objects; + this.enums = enums; + this.fileIdent = fileIdent; + this.fileExt = fileExt; + this.rootTable = rootTable; + this.services = services; + this.advancedFeatures = advancedFeatures; + this.fbsFiles = fbsFiles; + } + pack(builder) { + const objects = Schema.createObjectsVector(builder, builder.createObjectOffsetList(this.objects)); + const enums = Schema.createEnumsVector(builder, builder.createObjectOffsetList(this.enums)); + const fileIdent = (this.fileIdent !== null ? builder.createString(this.fileIdent) : 0); + const fileExt = (this.fileExt !== null ? builder.createString(this.fileExt) : 0); + const rootTable = (this.rootTable !== null ? this.rootTable.pack(builder) : 0); + const services = Schema.createServicesVector(builder, builder.createObjectOffsetList(this.services)); + const fbsFiles = Schema.createFbsFilesVector(builder, builder.createObjectOffsetList(this.fbsFiles)); + Schema.startSchema(builder); + Schema.addObjects(builder, objects); + Schema.addEnums(builder, enums); + Schema.addFileIdent(builder, fileIdent); + Schema.addFileExt(builder, fileExt); + Schema.addRootTable(builder, rootTable); + Schema.addServices(builder, services); + Schema.addAdvancedFeatures(builder, this.advancedFeatures); + Schema.addFbsFiles(builder, fbsFiles); + return Schema.endSchema(builder); + } +} diff --git a/tests/ts/reflection_generated.ts b/tests/ts/reflection_generated.ts new file mode 100644 index 00000000000..4bb12220841 --- /dev/null +++ b/tests/ts/reflection_generated.ts @@ -0,0 +1,2100 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +import * as flatbuffers from 'flatbuffers'; + + +export enum BaseType { + None = 0, + UType = 1, + Bool = 2, + Byte = 3, + UByte = 4, + Short = 5, + UShort = 6, + Int = 7, + UInt = 8, + Long = 9, + ULong = 10, + Float = 11, + Double = 12, + String = 13, + Vector = 14, + Obj = 15, + Union = 16, + Array = 17, + MaxBaseType = 18 +} + +/** + * New schema language features that are not supported by old code generators. + */ +export enum AdvancedFeatures { + AdvancedArrayFeatures = '1', + AdvancedUnionFeatures = '2', + OptionalScalars = '4', + DefaultVectorsAndStrings = '8' +} + +export class Type { + bb: flatbuffers.ByteBuffer|null = null; + bb_pos = 0; + __init(i:number, bb:flatbuffers.ByteBuffer):Type { + this.bb_pos = i; + this.bb = bb; + return this; +} + +static getRootAsType(bb:flatbuffers.ByteBuffer, obj?:Type):Type { + return (obj || new Type()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +static getSizePrefixedRootAsType(bb:flatbuffers.ByteBuffer, obj?:Type):Type { + bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); + return (obj || new Type()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +baseType():BaseType { + const offset = this.bb!.__offset(this.bb_pos, 4); + return offset ? this.bb!.readInt8(this.bb_pos + offset) : BaseType.None; +} + +mutate_base_type(value:BaseType):boolean { + const offset = this.bb!.__offset(this.bb_pos, 4); + + if (offset === 0) { + return false; + } + + this.bb!.writeInt8(this.bb_pos + offset, value); + return true; +} + +element():BaseType { + const offset = this.bb!.__offset(this.bb_pos, 6); + return offset ? this.bb!.readInt8(this.bb_pos + offset) : BaseType.None; +} + +mutate_element(value:BaseType):boolean { + const offset = this.bb!.__offset(this.bb_pos, 6); + + if (offset === 0) { + return false; + } + + this.bb!.writeInt8(this.bb_pos + offset, value); + return true; +} + +index():number { + const offset = this.bb!.__offset(this.bb_pos, 8); + return offset ? this.bb!.readInt32(this.bb_pos + offset) : -1; +} + +mutate_index(value:number):boolean { + const offset = this.bb!.__offset(this.bb_pos, 8); + + if (offset === 0) { + return false; + } + + this.bb!.writeInt32(this.bb_pos + offset, value); + return true; +} + +fixedLength():number { + const offset = this.bb!.__offset(this.bb_pos, 10); + return offset ? this.bb!.readUint16(this.bb_pos + offset) : 0; +} + +mutate_fixed_length(value:number):boolean { + const offset = this.bb!.__offset(this.bb_pos, 10); + + if (offset === 0) { + return false; + } + + this.bb!.writeUint16(this.bb_pos + offset, value); + return true; +} + +/** + * The size (octets) of the `base_type` field. + */ +baseSize():number { + const offset = this.bb!.__offset(this.bb_pos, 12); + return offset ? this.bb!.readUint32(this.bb_pos + offset) : 4; +} + +mutate_base_size(value:number):boolean { + const offset = this.bb!.__offset(this.bb_pos, 12); + + if (offset === 0) { + return false; + } + + this.bb!.writeUint32(this.bb_pos + offset, value); + return true; +} + +/** + * The size (octets) of the `element` field, if present. + */ +elementSize():number { + const offset = this.bb!.__offset(this.bb_pos, 14); + return offset ? this.bb!.readUint32(this.bb_pos + offset) : 0; +} + +mutate_element_size(value:number):boolean { + const offset = this.bb!.__offset(this.bb_pos, 14); + + if (offset === 0) { + return false; + } + + this.bb!.writeUint32(this.bb_pos + offset, value); + return true; +} + +static getFullyQualifiedName():string { + return 'reflection_Type'; +} + +static startType(builder:flatbuffers.Builder) { + builder.startObject(6); +} + +static addBaseType(builder:flatbuffers.Builder, baseType:BaseType) { + builder.addFieldInt8(0, baseType, BaseType.None); +} + +static addElement(builder:flatbuffers.Builder, element:BaseType) { + builder.addFieldInt8(1, element, BaseType.None); +} + +static addIndex(builder:flatbuffers.Builder, index:number) { + builder.addFieldInt32(2, index, -1); +} + +static addFixedLength(builder:flatbuffers.Builder, fixedLength:number) { + builder.addFieldInt16(3, fixedLength, 0); +} + +static addBaseSize(builder:flatbuffers.Builder, baseSize:number) { + builder.addFieldInt32(4, baseSize, 4); +} + +static addElementSize(builder:flatbuffers.Builder, elementSize:number) { + builder.addFieldInt32(5, elementSize, 0); +} + +static endType(builder:flatbuffers.Builder):flatbuffers.Offset { + const offset = builder.endObject(); + return offset; +} + +static createType(builder:flatbuffers.Builder, baseType:BaseType, element:BaseType, index:number, fixedLength:number, baseSize:number, elementSize:number):flatbuffers.Offset { + Type.startType(builder); + Type.addBaseType(builder, baseType); + Type.addElement(builder, element); + Type.addIndex(builder, index); + Type.addFixedLength(builder, fixedLength); + Type.addBaseSize(builder, baseSize); + Type.addElementSize(builder, elementSize); + return Type.endType(builder); +} + +unpack(): TypeT { + return new TypeT( + this.baseType(), + this.element(), + this.index(), + this.fixedLength(), + this.baseSize(), + this.elementSize() + ); +} + + +unpackTo(_o: TypeT): void { + _o.baseType = this.baseType(); + _o.element = this.element(); + _o.index = this.index(); + _o.fixedLength = this.fixedLength(); + _o.baseSize = this.baseSize(); + _o.elementSize = this.elementSize(); +} +} + +export class TypeT { +constructor( + public baseType: BaseType = BaseType.None, + public element: BaseType = BaseType.None, + public index: number = -1, + public fixedLength: number = 0, + public baseSize: number = 4, + public elementSize: number = 0 +){} + + +pack(builder:flatbuffers.Builder): flatbuffers.Offset { + return Type.createType(builder, + this.baseType, + this.element, + this.index, + this.fixedLength, + this.baseSize, + this.elementSize + ); +} +} + +export class KeyValue { + bb: flatbuffers.ByteBuffer|null = null; + bb_pos = 0; + __init(i:number, bb:flatbuffers.ByteBuffer):KeyValue { + this.bb_pos = i; + this.bb = bb; + return this; +} + +static getRootAsKeyValue(bb:flatbuffers.ByteBuffer, obj?:KeyValue):KeyValue { + return (obj || new KeyValue()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +static getSizePrefixedRootAsKeyValue(bb:flatbuffers.ByteBuffer, obj?:KeyValue):KeyValue { + bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); + return (obj || new KeyValue()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +key():string|null +key(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null +key(optionalEncoding?:any):string|Uint8Array|null { + const offset = this.bb!.__offset(this.bb_pos, 4); + return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; +} + +value():string|null +value(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null +value(optionalEncoding?:any):string|Uint8Array|null { + const offset = this.bb!.__offset(this.bb_pos, 6); + return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; +} + +static getFullyQualifiedName():string { + return 'reflection_KeyValue'; +} + +static startKeyValue(builder:flatbuffers.Builder) { + builder.startObject(2); +} + +static addKey(builder:flatbuffers.Builder, keyOffset:flatbuffers.Offset) { + builder.addFieldOffset(0, keyOffset, 0); +} + +static addValue(builder:flatbuffers.Builder, valueOffset:flatbuffers.Offset) { + builder.addFieldOffset(1, valueOffset, 0); +} + +static endKeyValue(builder:flatbuffers.Builder):flatbuffers.Offset { + const offset = builder.endObject(); + builder.requiredField(offset, 4) // key + return offset; +} + +static createKeyValue(builder:flatbuffers.Builder, keyOffset:flatbuffers.Offset, valueOffset:flatbuffers.Offset):flatbuffers.Offset { + KeyValue.startKeyValue(builder); + KeyValue.addKey(builder, keyOffset); + KeyValue.addValue(builder, valueOffset); + return KeyValue.endKeyValue(builder); +} + +unpack(): KeyValueT { + return new KeyValueT( + this.key(), + this.value() + ); +} + + +unpackTo(_o: KeyValueT): void { + _o.key = this.key(); + _o.value = this.value(); +} +} + +export class KeyValueT { +constructor( + public key: string|Uint8Array|null = null, + public value: string|Uint8Array|null = null +){} + + +pack(builder:flatbuffers.Builder): flatbuffers.Offset { + const key = (this.key !== null ? builder.createString(this.key!) : 0); + const value = (this.value !== null ? builder.createString(this.value!) : 0); + + return KeyValue.createKeyValue(builder, + key, + value + ); +} +} + +export class EnumVal { + bb: flatbuffers.ByteBuffer|null = null; + bb_pos = 0; + __init(i:number, bb:flatbuffers.ByteBuffer):EnumVal { + this.bb_pos = i; + this.bb = bb; + return this; +} + +static getRootAsEnumVal(bb:flatbuffers.ByteBuffer, obj?:EnumVal):EnumVal { + return (obj || new EnumVal()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +static getSizePrefixedRootAsEnumVal(bb:flatbuffers.ByteBuffer, obj?:EnumVal):EnumVal { + bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); + return (obj || new EnumVal()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +name():string|null +name(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null +name(optionalEncoding?:any):string|Uint8Array|null { + const offset = this.bb!.__offset(this.bb_pos, 4); + return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; +} + +value():bigint { + const offset = this.bb!.__offset(this.bb_pos, 6); + return offset ? this.bb!.readInt64(this.bb_pos + offset) : BigInt('0'); +} + +mutate_value(value:bigint):boolean { + const offset = this.bb!.__offset(this.bb_pos, 6); + + if (offset === 0) { + return false; + } + + this.bb!.writeInt64(this.bb_pos + offset, value); + return true; +} + +unionType(obj?:Type):Type|null { + const offset = this.bb!.__offset(this.bb_pos, 10); + return offset ? (obj || new Type()).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null; +} + +documentation(index: number):string +documentation(index: number,optionalEncoding:flatbuffers.Encoding):string|Uint8Array +documentation(index: number,optionalEncoding?:any):string|Uint8Array|null { + const offset = this.bb!.__offset(this.bb_pos, 12); + return offset ? this.bb!.__string(this.bb!.__vector(this.bb_pos + offset) + index * 4, optionalEncoding) : null; +} + +documentationLength():number { + const offset = this.bb!.__offset(this.bb_pos, 12); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +} + +static getFullyQualifiedName():string { + return 'reflection_EnumVal'; +} + +static startEnumVal(builder:flatbuffers.Builder) { + builder.startObject(5); +} + +static addName(builder:flatbuffers.Builder, nameOffset:flatbuffers.Offset) { + builder.addFieldOffset(0, nameOffset, 0); +} + +static addValue(builder:flatbuffers.Builder, value:bigint) { + builder.addFieldInt64(1, value, BigInt('0')); +} + +static addUnionType(builder:flatbuffers.Builder, unionTypeOffset:flatbuffers.Offset) { + builder.addFieldOffset(3, unionTypeOffset, 0); +} + +static addDocumentation(builder:flatbuffers.Builder, documentationOffset:flatbuffers.Offset) { + builder.addFieldOffset(4, documentationOffset, 0); +} + +static createDocumentationVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addOffset(data[i]!); + } + return builder.endVector(); +} + +static startDocumentationVector(builder:flatbuffers.Builder, numElems:number) { + builder.startVector(4, numElems, 4); +} + +static endEnumVal(builder:flatbuffers.Builder):flatbuffers.Offset { + const offset = builder.endObject(); + builder.requiredField(offset, 4) // name + return offset; +} + + +unpack(): EnumValT { + return new EnumValT( + this.name(), + this.value(), + (this.unionType() !== null ? this.unionType()!.unpack() : null), + this.bb!.createScalarList(this.documentation.bind(this), this.documentationLength()) + ); +} + + +unpackTo(_o: EnumValT): void { + _o.name = this.name(); + _o.value = this.value(); + _o.unionType = (this.unionType() !== null ? this.unionType()!.unpack() : null); + _o.documentation = this.bb!.createScalarList(this.documentation.bind(this), this.documentationLength()); +} +} + +export class EnumValT { +constructor( + public name: string|Uint8Array|null = null, + public value: bigint = BigInt('0'), + public unionType: TypeT|null = null, + public documentation: (string)[] = [] +){} + + +pack(builder:flatbuffers.Builder): flatbuffers.Offset { + const name = (this.name !== null ? builder.createString(this.name!) : 0); + const unionType = (this.unionType !== null ? this.unionType!.pack(builder) : 0); + const documentation = EnumVal.createDocumentationVector(builder, builder.createObjectOffsetList(this.documentation)); + + EnumVal.startEnumVal(builder); + EnumVal.addName(builder, name); + EnumVal.addValue(builder, this.value); + EnumVal.addUnionType(builder, unionType); + EnumVal.addDocumentation(builder, documentation); + + return EnumVal.endEnumVal(builder); +} +} + +export class Enum { + bb: flatbuffers.ByteBuffer|null = null; + bb_pos = 0; + __init(i:number, bb:flatbuffers.ByteBuffer):Enum { + this.bb_pos = i; + this.bb = bb; + return this; +} + +static getRootAsEnum(bb:flatbuffers.ByteBuffer, obj?:Enum):Enum { + return (obj || new Enum()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +static getSizePrefixedRootAsEnum(bb:flatbuffers.ByteBuffer, obj?:Enum):Enum { + bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); + return (obj || new Enum()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +name():string|null +name(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null +name(optionalEncoding?:any):string|Uint8Array|null { + const offset = this.bb!.__offset(this.bb_pos, 4); + return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; +} + +values(index: number, obj?:EnumVal):EnumVal|null { + const offset = this.bb!.__offset(this.bb_pos, 6); + return offset ? (obj || new EnumVal()).__init(this.bb!.__indirect(this.bb!.__vector(this.bb_pos + offset) + index * 4), this.bb!) : null; +} + +valuesLength():number { + const offset = this.bb!.__offset(this.bb_pos, 6); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +} + +isUnion():boolean { + const offset = this.bb!.__offset(this.bb_pos, 8); + return offset ? !!this.bb!.readInt8(this.bb_pos + offset) : false; +} + +mutate_is_union(value:boolean):boolean { + const offset = this.bb!.__offset(this.bb_pos, 8); + + if (offset === 0) { + return false; + } + + this.bb!.writeInt8(this.bb_pos + offset, +value); + return true; +} + +underlyingType(obj?:Type):Type|null { + const offset = this.bb!.__offset(this.bb_pos, 10); + return offset ? (obj || new Type()).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null; +} + +attributes(index: number, obj?:KeyValue):KeyValue|null { + const offset = this.bb!.__offset(this.bb_pos, 12); + return offset ? (obj || new KeyValue()).__init(this.bb!.__indirect(this.bb!.__vector(this.bb_pos + offset) + index * 4), this.bb!) : null; +} + +attributesLength():number { + const offset = this.bb!.__offset(this.bb_pos, 12); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +} + +documentation(index: number):string +documentation(index: number,optionalEncoding:flatbuffers.Encoding):string|Uint8Array +documentation(index: number,optionalEncoding?:any):string|Uint8Array|null { + const offset = this.bb!.__offset(this.bb_pos, 14); + return offset ? this.bb!.__string(this.bb!.__vector(this.bb_pos + offset) + index * 4, optionalEncoding) : null; +} + +documentationLength():number { + const offset = this.bb!.__offset(this.bb_pos, 14); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +} + +/** + * File that this Enum is declared in. + */ +declarationFile():string|null +declarationFile(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null +declarationFile(optionalEncoding?:any):string|Uint8Array|null { + const offset = this.bb!.__offset(this.bb_pos, 16); + return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; +} + +static getFullyQualifiedName():string { + return 'reflection_Enum'; +} + +static startEnum(builder:flatbuffers.Builder) { + builder.startObject(7); +} + +static addName(builder:flatbuffers.Builder, nameOffset:flatbuffers.Offset) { + builder.addFieldOffset(0, nameOffset, 0); +} + +static addValues(builder:flatbuffers.Builder, valuesOffset:flatbuffers.Offset) { + builder.addFieldOffset(1, valuesOffset, 0); +} + +static createValuesVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addOffset(data[i]!); + } + return builder.endVector(); +} + +static startValuesVector(builder:flatbuffers.Builder, numElems:number) { + builder.startVector(4, numElems, 4); +} + +static addIsUnion(builder:flatbuffers.Builder, isUnion:boolean) { + builder.addFieldInt8(2, +isUnion, +false); +} + +static addUnderlyingType(builder:flatbuffers.Builder, underlyingTypeOffset:flatbuffers.Offset) { + builder.addFieldOffset(3, underlyingTypeOffset, 0); +} + +static addAttributes(builder:flatbuffers.Builder, attributesOffset:flatbuffers.Offset) { + builder.addFieldOffset(4, attributesOffset, 0); +} + +static createAttributesVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addOffset(data[i]!); + } + return builder.endVector(); +} + +static startAttributesVector(builder:flatbuffers.Builder, numElems:number) { + builder.startVector(4, numElems, 4); +} + +static addDocumentation(builder:flatbuffers.Builder, documentationOffset:flatbuffers.Offset) { + builder.addFieldOffset(5, documentationOffset, 0); +} + +static createDocumentationVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addOffset(data[i]!); + } + return builder.endVector(); +} + +static startDocumentationVector(builder:flatbuffers.Builder, numElems:number) { + builder.startVector(4, numElems, 4); +} + +static addDeclarationFile(builder:flatbuffers.Builder, declarationFileOffset:flatbuffers.Offset) { + builder.addFieldOffset(6, declarationFileOffset, 0); +} + +static endEnum(builder:flatbuffers.Builder):flatbuffers.Offset { + const offset = builder.endObject(); + builder.requiredField(offset, 4) // name + builder.requiredField(offset, 6) // values + builder.requiredField(offset, 10) // underlying_type + return offset; +} + + +unpack(): EnumT { + return new EnumT( + this.name(), + this.bb!.createObjList(this.values.bind(this), this.valuesLength()), + this.isUnion(), + (this.underlyingType() !== null ? this.underlyingType()!.unpack() : null), + this.bb!.createObjList(this.attributes.bind(this), this.attributesLength()), + this.bb!.createScalarList(this.documentation.bind(this), this.documentationLength()), + this.declarationFile() + ); +} + + +unpackTo(_o: EnumT): void { + _o.name = this.name(); + _o.values = this.bb!.createObjList(this.values.bind(this), this.valuesLength()); + _o.isUnion = this.isUnion(); + _o.underlyingType = (this.underlyingType() !== null ? this.underlyingType()!.unpack() : null); + _o.attributes = this.bb!.createObjList(this.attributes.bind(this), this.attributesLength()); + _o.documentation = this.bb!.createScalarList(this.documentation.bind(this), this.documentationLength()); + _o.declarationFile = this.declarationFile(); +} +} + +export class EnumT { +constructor( + public name: string|Uint8Array|null = null, + public values: (EnumValT)[] = [], + public isUnion: boolean = false, + public underlyingType: TypeT|null = null, + public attributes: (KeyValueT)[] = [], + public documentation: (string)[] = [], + public declarationFile: string|Uint8Array|null = null +){} + + +pack(builder:flatbuffers.Builder): flatbuffers.Offset { + const name = (this.name !== null ? builder.createString(this.name!) : 0); + const values = Enum.createValuesVector(builder, builder.createObjectOffsetList(this.values)); + const underlyingType = (this.underlyingType !== null ? this.underlyingType!.pack(builder) : 0); + const attributes = Enum.createAttributesVector(builder, builder.createObjectOffsetList(this.attributes)); + const documentation = Enum.createDocumentationVector(builder, builder.createObjectOffsetList(this.documentation)); + const declarationFile = (this.declarationFile !== null ? builder.createString(this.declarationFile!) : 0); + + Enum.startEnum(builder); + Enum.addName(builder, name); + Enum.addValues(builder, values); + Enum.addIsUnion(builder, this.isUnion); + Enum.addUnderlyingType(builder, underlyingType); + Enum.addAttributes(builder, attributes); + Enum.addDocumentation(builder, documentation); + Enum.addDeclarationFile(builder, declarationFile); + + return Enum.endEnum(builder); +} +} + +export class Field { + bb: flatbuffers.ByteBuffer|null = null; + bb_pos = 0; + __init(i:number, bb:flatbuffers.ByteBuffer):Field { + this.bb_pos = i; + this.bb = bb; + return this; +} + +static getRootAsField(bb:flatbuffers.ByteBuffer, obj?:Field):Field { + return (obj || new Field()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +static getSizePrefixedRootAsField(bb:flatbuffers.ByteBuffer, obj?:Field):Field { + bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); + return (obj || new Field()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +name():string|null +name(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null +name(optionalEncoding?:any):string|Uint8Array|null { + const offset = this.bb!.__offset(this.bb_pos, 4); + return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; +} + +type(obj?:Type):Type|null { + const offset = this.bb!.__offset(this.bb_pos, 6); + return offset ? (obj || new Type()).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null; +} + +id():number { + const offset = this.bb!.__offset(this.bb_pos, 8); + return offset ? this.bb!.readUint16(this.bb_pos + offset) : 0; +} + +mutate_id(value:number):boolean { + const offset = this.bb!.__offset(this.bb_pos, 8); + + if (offset === 0) { + return false; + } + + this.bb!.writeUint16(this.bb_pos + offset, value); + return true; +} + +offset():number { + const offset = this.bb!.__offset(this.bb_pos, 10); + return offset ? this.bb!.readUint16(this.bb_pos + offset) : 0; +} + +mutate_offset(value:number):boolean { + const offset = this.bb!.__offset(this.bb_pos, 10); + + if (offset === 0) { + return false; + } + + this.bb!.writeUint16(this.bb_pos + offset, value); + return true; +} + +defaultInteger():bigint { + const offset = this.bb!.__offset(this.bb_pos, 12); + return offset ? this.bb!.readInt64(this.bb_pos + offset) : BigInt('0'); +} + +mutate_default_integer(value:bigint):boolean { + const offset = this.bb!.__offset(this.bb_pos, 12); + + if (offset === 0) { + return false; + } + + this.bb!.writeInt64(this.bb_pos + offset, value); + return true; +} + +defaultReal():number { + const offset = this.bb!.__offset(this.bb_pos, 14); + return offset ? this.bb!.readFloat64(this.bb_pos + offset) : 0.0; +} + +mutate_default_real(value:number):boolean { + const offset = this.bb!.__offset(this.bb_pos, 14); + + if (offset === 0) { + return false; + } + + this.bb!.writeFloat64(this.bb_pos + offset, value); + return true; +} + +deprecated():boolean { + const offset = this.bb!.__offset(this.bb_pos, 16); + return offset ? !!this.bb!.readInt8(this.bb_pos + offset) : false; +} + +mutate_deprecated(value:boolean):boolean { + const offset = this.bb!.__offset(this.bb_pos, 16); + + if (offset === 0) { + return false; + } + + this.bb!.writeInt8(this.bb_pos + offset, +value); + return true; +} + +required():boolean { + const offset = this.bb!.__offset(this.bb_pos, 18); + return offset ? !!this.bb!.readInt8(this.bb_pos + offset) : false; +} + +mutate_required(value:boolean):boolean { + const offset = this.bb!.__offset(this.bb_pos, 18); + + if (offset === 0) { + return false; + } + + this.bb!.writeInt8(this.bb_pos + offset, +value); + return true; +} + +key():boolean { + const offset = this.bb!.__offset(this.bb_pos, 20); + return offset ? !!this.bb!.readInt8(this.bb_pos + offset) : false; +} + +mutate_key(value:boolean):boolean { + const offset = this.bb!.__offset(this.bb_pos, 20); + + if (offset === 0) { + return false; + } + + this.bb!.writeInt8(this.bb_pos + offset, +value); + return true; +} + +attributes(index: number, obj?:KeyValue):KeyValue|null { + const offset = this.bb!.__offset(this.bb_pos, 22); + return offset ? (obj || new KeyValue()).__init(this.bb!.__indirect(this.bb!.__vector(this.bb_pos + offset) + index * 4), this.bb!) : null; +} + +attributesLength():number { + const offset = this.bb!.__offset(this.bb_pos, 22); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +} + +documentation(index: number):string +documentation(index: number,optionalEncoding:flatbuffers.Encoding):string|Uint8Array +documentation(index: number,optionalEncoding?:any):string|Uint8Array|null { + const offset = this.bb!.__offset(this.bb_pos, 24); + return offset ? this.bb!.__string(this.bb!.__vector(this.bb_pos + offset) + index * 4, optionalEncoding) : null; +} + +documentationLength():number { + const offset = this.bb!.__offset(this.bb_pos, 24); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +} + +optional():boolean { + const offset = this.bb!.__offset(this.bb_pos, 26); + return offset ? !!this.bb!.readInt8(this.bb_pos + offset) : false; +} + +mutate_optional(value:boolean):boolean { + const offset = this.bb!.__offset(this.bb_pos, 26); + + if (offset === 0) { + return false; + } + + this.bb!.writeInt8(this.bb_pos + offset, +value); + return true; +} + +/** + * Number of padding octets to always add after this field. Structs only. + */ +padding():number { + const offset = this.bb!.__offset(this.bb_pos, 28); + return offset ? this.bb!.readUint16(this.bb_pos + offset) : 0; +} + +mutate_padding(value:number):boolean { + const offset = this.bb!.__offset(this.bb_pos, 28); + + if (offset === 0) { + return false; + } + + this.bb!.writeUint16(this.bb_pos + offset, value); + return true; +} + +static getFullyQualifiedName():string { + return 'reflection_Field'; +} + +static startField(builder:flatbuffers.Builder) { + builder.startObject(13); +} + +static addName(builder:flatbuffers.Builder, nameOffset:flatbuffers.Offset) { + builder.addFieldOffset(0, nameOffset, 0); +} + +static addType(builder:flatbuffers.Builder, typeOffset:flatbuffers.Offset) { + builder.addFieldOffset(1, typeOffset, 0); +} + +static addId(builder:flatbuffers.Builder, id:number) { + builder.addFieldInt16(2, id, 0); +} + +static addOffset(builder:flatbuffers.Builder, offset:number) { + builder.addFieldInt16(3, offset, 0); +} + +static addDefaultInteger(builder:flatbuffers.Builder, defaultInteger:bigint) { + builder.addFieldInt64(4, defaultInteger, BigInt('0')); +} + +static addDefaultReal(builder:flatbuffers.Builder, defaultReal:number) { + builder.addFieldFloat64(5, defaultReal, 0.0); +} + +static addDeprecated(builder:flatbuffers.Builder, deprecated:boolean) { + builder.addFieldInt8(6, +deprecated, +false); +} + +static addRequired(builder:flatbuffers.Builder, required:boolean) { + builder.addFieldInt8(7, +required, +false); +} + +static addKey(builder:flatbuffers.Builder, key:boolean) { + builder.addFieldInt8(8, +key, +false); +} + +static addAttributes(builder:flatbuffers.Builder, attributesOffset:flatbuffers.Offset) { + builder.addFieldOffset(9, attributesOffset, 0); +} + +static createAttributesVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addOffset(data[i]!); + } + return builder.endVector(); +} + +static startAttributesVector(builder:flatbuffers.Builder, numElems:number) { + builder.startVector(4, numElems, 4); +} + +static addDocumentation(builder:flatbuffers.Builder, documentationOffset:flatbuffers.Offset) { + builder.addFieldOffset(10, documentationOffset, 0); +} + +static createDocumentationVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addOffset(data[i]!); + } + return builder.endVector(); +} + +static startDocumentationVector(builder:flatbuffers.Builder, numElems:number) { + builder.startVector(4, numElems, 4); +} + +static addOptional(builder:flatbuffers.Builder, optional:boolean) { + builder.addFieldInt8(11, +optional, +false); +} + +static addPadding(builder:flatbuffers.Builder, padding:number) { + builder.addFieldInt16(12, padding, 0); +} + +static endField(builder:flatbuffers.Builder):flatbuffers.Offset { + const offset = builder.endObject(); + builder.requiredField(offset, 4) // name + builder.requiredField(offset, 6) // type + return offset; +} + + +unpack(): FieldT { + return new FieldT( + this.name(), + (this.type() !== null ? this.type()!.unpack() : null), + this.id(), + this.offset(), + this.defaultInteger(), + this.defaultReal(), + this.deprecated(), + this.required(), + this.key(), + this.bb!.createObjList(this.attributes.bind(this), this.attributesLength()), + this.bb!.createScalarList(this.documentation.bind(this), this.documentationLength()), + this.optional(), + this.padding() + ); +} + + +unpackTo(_o: FieldT): void { + _o.name = this.name(); + _o.type = (this.type() !== null ? this.type()!.unpack() : null); + _o.id = this.id(); + _o.offset = this.offset(); + _o.defaultInteger = this.defaultInteger(); + _o.defaultReal = this.defaultReal(); + _o.deprecated = this.deprecated(); + _o.required = this.required(); + _o.key = this.key(); + _o.attributes = this.bb!.createObjList(this.attributes.bind(this), this.attributesLength()); + _o.documentation = this.bb!.createScalarList(this.documentation.bind(this), this.documentationLength()); + _o.optional = this.optional(); + _o.padding = this.padding(); +} +} + +export class FieldT { +constructor( + public name: string|Uint8Array|null = null, + public type: TypeT|null = null, + public id: number = 0, + public offset: number = 0, + public defaultInteger: bigint = BigInt('0'), + public defaultReal: number = 0.0, + public deprecated: boolean = false, + public required: boolean = false, + public key: boolean = false, + public attributes: (KeyValueT)[] = [], + public documentation: (string)[] = [], + public optional: boolean = false, + public padding: number = 0 +){} + + +pack(builder:flatbuffers.Builder): flatbuffers.Offset { + const name = (this.name !== null ? builder.createString(this.name!) : 0); + const type = (this.type !== null ? this.type!.pack(builder) : 0); + const attributes = Field.createAttributesVector(builder, builder.createObjectOffsetList(this.attributes)); + const documentation = Field.createDocumentationVector(builder, builder.createObjectOffsetList(this.documentation)); + + Field.startField(builder); + Field.addName(builder, name); + Field.addType(builder, type); + Field.addId(builder, this.id); + Field.addOffset(builder, this.offset); + Field.addDefaultInteger(builder, this.defaultInteger); + Field.addDefaultReal(builder, this.defaultReal); + Field.addDeprecated(builder, this.deprecated); + Field.addRequired(builder, this.required); + Field.addKey(builder, this.key); + Field.addAttributes(builder, attributes); + Field.addDocumentation(builder, documentation); + Field.addOptional(builder, this.optional); + Field.addPadding(builder, this.padding); + + return Field.endField(builder); +} +} + +export class Object_ { + bb: flatbuffers.ByteBuffer|null = null; + bb_pos = 0; + __init(i:number, bb:flatbuffers.ByteBuffer):Object_ { + this.bb_pos = i; + this.bb = bb; + return this; +} + +static getRootAsObject(bb:flatbuffers.ByteBuffer, obj?:Object_):Object_ { + return (obj || new Object_()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +static getSizePrefixedRootAsObject(bb:flatbuffers.ByteBuffer, obj?:Object_):Object_ { + bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); + return (obj || new Object_()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +name():string|null +name(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null +name(optionalEncoding?:any):string|Uint8Array|null { + const offset = this.bb!.__offset(this.bb_pos, 4); + return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; +} + +fields(index: number, obj?:Field):Field|null { + const offset = this.bb!.__offset(this.bb_pos, 6); + return offset ? (obj || new Field()).__init(this.bb!.__indirect(this.bb!.__vector(this.bb_pos + offset) + index * 4), this.bb!) : null; +} + +fieldsLength():number { + const offset = this.bb!.__offset(this.bb_pos, 6); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +} + +isStruct():boolean { + const offset = this.bb!.__offset(this.bb_pos, 8); + return offset ? !!this.bb!.readInt8(this.bb_pos + offset) : false; +} + +mutate_is_struct(value:boolean):boolean { + const offset = this.bb!.__offset(this.bb_pos, 8); + + if (offset === 0) { + return false; + } + + this.bb!.writeInt8(this.bb_pos + offset, +value); + return true; +} + +minalign():number { + const offset = this.bb!.__offset(this.bb_pos, 10); + return offset ? this.bb!.readInt32(this.bb_pos + offset) : 0; +} + +mutate_minalign(value:number):boolean { + const offset = this.bb!.__offset(this.bb_pos, 10); + + if (offset === 0) { + return false; + } + + this.bb!.writeInt32(this.bb_pos + offset, value); + return true; +} + +bytesize():number { + const offset = this.bb!.__offset(this.bb_pos, 12); + return offset ? this.bb!.readInt32(this.bb_pos + offset) : 0; +} + +mutate_bytesize(value:number):boolean { + const offset = this.bb!.__offset(this.bb_pos, 12); + + if (offset === 0) { + return false; + } + + this.bb!.writeInt32(this.bb_pos + offset, value); + return true; +} + +attributes(index: number, obj?:KeyValue):KeyValue|null { + const offset = this.bb!.__offset(this.bb_pos, 14); + return offset ? (obj || new KeyValue()).__init(this.bb!.__indirect(this.bb!.__vector(this.bb_pos + offset) + index * 4), this.bb!) : null; +} + +attributesLength():number { + const offset = this.bb!.__offset(this.bb_pos, 14); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +} + +documentation(index: number):string +documentation(index: number,optionalEncoding:flatbuffers.Encoding):string|Uint8Array +documentation(index: number,optionalEncoding?:any):string|Uint8Array|null { + const offset = this.bb!.__offset(this.bb_pos, 16); + return offset ? this.bb!.__string(this.bb!.__vector(this.bb_pos + offset) + index * 4, optionalEncoding) : null; +} + +documentationLength():number { + const offset = this.bb!.__offset(this.bb_pos, 16); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +} + +/** + * File that this Object is declared in. + */ +declarationFile():string|null +declarationFile(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null +declarationFile(optionalEncoding?:any):string|Uint8Array|null { + const offset = this.bb!.__offset(this.bb_pos, 18); + return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; +} + +static getFullyQualifiedName():string { + return 'reflection_Object'; +} + +static startObject(builder:flatbuffers.Builder) { + builder.startObject(8); +} + +static addName(builder:flatbuffers.Builder, nameOffset:flatbuffers.Offset) { + builder.addFieldOffset(0, nameOffset, 0); +} + +static addFields(builder:flatbuffers.Builder, fieldsOffset:flatbuffers.Offset) { + builder.addFieldOffset(1, fieldsOffset, 0); +} + +static createFieldsVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addOffset(data[i]!); + } + return builder.endVector(); +} + +static startFieldsVector(builder:flatbuffers.Builder, numElems:number) { + builder.startVector(4, numElems, 4); +} + +static addIsStruct(builder:flatbuffers.Builder, isStruct:boolean) { + builder.addFieldInt8(2, +isStruct, +false); +} + +static addMinalign(builder:flatbuffers.Builder, minalign:number) { + builder.addFieldInt32(3, minalign, 0); +} + +static addBytesize(builder:flatbuffers.Builder, bytesize:number) { + builder.addFieldInt32(4, bytesize, 0); +} + +static addAttributes(builder:flatbuffers.Builder, attributesOffset:flatbuffers.Offset) { + builder.addFieldOffset(5, attributesOffset, 0); +} + +static createAttributesVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addOffset(data[i]!); + } + return builder.endVector(); +} + +static startAttributesVector(builder:flatbuffers.Builder, numElems:number) { + builder.startVector(4, numElems, 4); +} + +static addDocumentation(builder:flatbuffers.Builder, documentationOffset:flatbuffers.Offset) { + builder.addFieldOffset(6, documentationOffset, 0); +} + +static createDocumentationVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addOffset(data[i]!); + } + return builder.endVector(); +} + +static startDocumentationVector(builder:flatbuffers.Builder, numElems:number) { + builder.startVector(4, numElems, 4); +} + +static addDeclarationFile(builder:flatbuffers.Builder, declarationFileOffset:flatbuffers.Offset) { + builder.addFieldOffset(7, declarationFileOffset, 0); +} + +static endObject(builder:flatbuffers.Builder):flatbuffers.Offset { + const offset = builder.endObject(); + builder.requiredField(offset, 4) // name + builder.requiredField(offset, 6) // fields + return offset; +} + +static createObject(builder:flatbuffers.Builder, nameOffset:flatbuffers.Offset, fieldsOffset:flatbuffers.Offset, isStruct:boolean, minalign:number, bytesize:number, attributesOffset:flatbuffers.Offset, documentationOffset:flatbuffers.Offset, declarationFileOffset:flatbuffers.Offset):flatbuffers.Offset { + Object_.startObject(builder); + Object_.addName(builder, nameOffset); + Object_.addFields(builder, fieldsOffset); + Object_.addIsStruct(builder, isStruct); + Object_.addMinalign(builder, minalign); + Object_.addBytesize(builder, bytesize); + Object_.addAttributes(builder, attributesOffset); + Object_.addDocumentation(builder, documentationOffset); + Object_.addDeclarationFile(builder, declarationFileOffset); + return Object_.endObject(builder); +} + +unpack(): Object_T { + return new Object_T( + this.name(), + this.bb!.createObjList(this.fields.bind(this), this.fieldsLength()), + this.isStruct(), + this.minalign(), + this.bytesize(), + this.bb!.createObjList(this.attributes.bind(this), this.attributesLength()), + this.bb!.createScalarList(this.documentation.bind(this), this.documentationLength()), + this.declarationFile() + ); +} + + +unpackTo(_o: Object_T): void { + _o.name = this.name(); + _o.fields = this.bb!.createObjList(this.fields.bind(this), this.fieldsLength()); + _o.isStruct = this.isStruct(); + _o.minalign = this.minalign(); + _o.bytesize = this.bytesize(); + _o.attributes = this.bb!.createObjList(this.attributes.bind(this), this.attributesLength()); + _o.documentation = this.bb!.createScalarList(this.documentation.bind(this), this.documentationLength()); + _o.declarationFile = this.declarationFile(); +} +} + +export class Object_T { +constructor( + public name: string|Uint8Array|null = null, + public fields: (FieldT)[] = [], + public isStruct: boolean = false, + public minalign: number = 0, + public bytesize: number = 0, + public attributes: (KeyValueT)[] = [], + public documentation: (string)[] = [], + public declarationFile: string|Uint8Array|null = null +){} + + +pack(builder:flatbuffers.Builder): flatbuffers.Offset { + const name = (this.name !== null ? builder.createString(this.name!) : 0); + const fields = Object_.createFieldsVector(builder, builder.createObjectOffsetList(this.fields)); + const attributes = Object_.createAttributesVector(builder, builder.createObjectOffsetList(this.attributes)); + const documentation = Object_.createDocumentationVector(builder, builder.createObjectOffsetList(this.documentation)); + const declarationFile = (this.declarationFile !== null ? builder.createString(this.declarationFile!) : 0); + + return Object_.createObject(builder, + name, + fields, + this.isStruct, + this.minalign, + this.bytesize, + attributes, + documentation, + declarationFile + ); +} +} + +export class RPCCall { + bb: flatbuffers.ByteBuffer|null = null; + bb_pos = 0; + __init(i:number, bb:flatbuffers.ByteBuffer):RPCCall { + this.bb_pos = i; + this.bb = bb; + return this; +} + +static getRootAsRPCCall(bb:flatbuffers.ByteBuffer, obj?:RPCCall):RPCCall { + return (obj || new RPCCall()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +static getSizePrefixedRootAsRPCCall(bb:flatbuffers.ByteBuffer, obj?:RPCCall):RPCCall { + bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); + return (obj || new RPCCall()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +name():string|null +name(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null +name(optionalEncoding?:any):string|Uint8Array|null { + const offset = this.bb!.__offset(this.bb_pos, 4); + return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; +} + +request(obj?:Object_):Object_|null { + const offset = this.bb!.__offset(this.bb_pos, 6); + return offset ? (obj || new Object_()).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null; +} + +response(obj?:Object_):Object_|null { + const offset = this.bb!.__offset(this.bb_pos, 8); + return offset ? (obj || new Object_()).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null; +} + +attributes(index: number, obj?:KeyValue):KeyValue|null { + const offset = this.bb!.__offset(this.bb_pos, 10); + return offset ? (obj || new KeyValue()).__init(this.bb!.__indirect(this.bb!.__vector(this.bb_pos + offset) + index * 4), this.bb!) : null; +} + +attributesLength():number { + const offset = this.bb!.__offset(this.bb_pos, 10); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +} + +documentation(index: number):string +documentation(index: number,optionalEncoding:flatbuffers.Encoding):string|Uint8Array +documentation(index: number,optionalEncoding?:any):string|Uint8Array|null { + const offset = this.bb!.__offset(this.bb_pos, 12); + return offset ? this.bb!.__string(this.bb!.__vector(this.bb_pos + offset) + index * 4, optionalEncoding) : null; +} + +documentationLength():number { + const offset = this.bb!.__offset(this.bb_pos, 12); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +} + +static getFullyQualifiedName():string { + return 'reflection_RPCCall'; +} + +static startRPCCall(builder:flatbuffers.Builder) { + builder.startObject(5); +} + +static addName(builder:flatbuffers.Builder, nameOffset:flatbuffers.Offset) { + builder.addFieldOffset(0, nameOffset, 0); +} + +static addRequest(builder:flatbuffers.Builder, requestOffset:flatbuffers.Offset) { + builder.addFieldOffset(1, requestOffset, 0); +} + +static addResponse(builder:flatbuffers.Builder, responseOffset:flatbuffers.Offset) { + builder.addFieldOffset(2, responseOffset, 0); +} + +static addAttributes(builder:flatbuffers.Builder, attributesOffset:flatbuffers.Offset) { + builder.addFieldOffset(3, attributesOffset, 0); +} + +static createAttributesVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addOffset(data[i]!); + } + return builder.endVector(); +} + +static startAttributesVector(builder:flatbuffers.Builder, numElems:number) { + builder.startVector(4, numElems, 4); +} + +static addDocumentation(builder:flatbuffers.Builder, documentationOffset:flatbuffers.Offset) { + builder.addFieldOffset(4, documentationOffset, 0); +} + +static createDocumentationVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addOffset(data[i]!); + } + return builder.endVector(); +} + +static startDocumentationVector(builder:flatbuffers.Builder, numElems:number) { + builder.startVector(4, numElems, 4); +} + +static endRPCCall(builder:flatbuffers.Builder):flatbuffers.Offset { + const offset = builder.endObject(); + builder.requiredField(offset, 4) // name + builder.requiredField(offset, 6) // request + builder.requiredField(offset, 8) // response + return offset; +} + + +unpack(): RPCCallT { + return new RPCCallT( + this.name(), + (this.request() !== null ? this.request()!.unpack() : null), + (this.response() !== null ? this.response()!.unpack() : null), + this.bb!.createObjList(this.attributes.bind(this), this.attributesLength()), + this.bb!.createScalarList(this.documentation.bind(this), this.documentationLength()) + ); +} + + +unpackTo(_o: RPCCallT): void { + _o.name = this.name(); + _o.request = (this.request() !== null ? this.request()!.unpack() : null); + _o.response = (this.response() !== null ? this.response()!.unpack() : null); + _o.attributes = this.bb!.createObjList(this.attributes.bind(this), this.attributesLength()); + _o.documentation = this.bb!.createScalarList(this.documentation.bind(this), this.documentationLength()); +} +} + +export class RPCCallT { +constructor( + public name: string|Uint8Array|null = null, + public request: Object_T|null = null, + public response: Object_T|null = null, + public attributes: (KeyValueT)[] = [], + public documentation: (string)[] = [] +){} + + +pack(builder:flatbuffers.Builder): flatbuffers.Offset { + const name = (this.name !== null ? builder.createString(this.name!) : 0); + const request = (this.request !== null ? this.request!.pack(builder) : 0); + const response = (this.response !== null ? this.response!.pack(builder) : 0); + const attributes = RPCCall.createAttributesVector(builder, builder.createObjectOffsetList(this.attributes)); + const documentation = RPCCall.createDocumentationVector(builder, builder.createObjectOffsetList(this.documentation)); + + RPCCall.startRPCCall(builder); + RPCCall.addName(builder, name); + RPCCall.addRequest(builder, request); + RPCCall.addResponse(builder, response); + RPCCall.addAttributes(builder, attributes); + RPCCall.addDocumentation(builder, documentation); + + return RPCCall.endRPCCall(builder); +} +} + +export class Service { + bb: flatbuffers.ByteBuffer|null = null; + bb_pos = 0; + __init(i:number, bb:flatbuffers.ByteBuffer):Service { + this.bb_pos = i; + this.bb = bb; + return this; +} + +static getRootAsService(bb:flatbuffers.ByteBuffer, obj?:Service):Service { + return (obj || new Service()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +static getSizePrefixedRootAsService(bb:flatbuffers.ByteBuffer, obj?:Service):Service { + bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); + return (obj || new Service()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +name():string|null +name(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null +name(optionalEncoding?:any):string|Uint8Array|null { + const offset = this.bb!.__offset(this.bb_pos, 4); + return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; +} + +calls(index: number, obj?:RPCCall):RPCCall|null { + const offset = this.bb!.__offset(this.bb_pos, 6); + return offset ? (obj || new RPCCall()).__init(this.bb!.__indirect(this.bb!.__vector(this.bb_pos + offset) + index * 4), this.bb!) : null; +} + +callsLength():number { + const offset = this.bb!.__offset(this.bb_pos, 6); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +} + +attributes(index: number, obj?:KeyValue):KeyValue|null { + const offset = this.bb!.__offset(this.bb_pos, 8); + return offset ? (obj || new KeyValue()).__init(this.bb!.__indirect(this.bb!.__vector(this.bb_pos + offset) + index * 4), this.bb!) : null; +} + +attributesLength():number { + const offset = this.bb!.__offset(this.bb_pos, 8); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +} + +documentation(index: number):string +documentation(index: number,optionalEncoding:flatbuffers.Encoding):string|Uint8Array +documentation(index: number,optionalEncoding?:any):string|Uint8Array|null { + const offset = this.bb!.__offset(this.bb_pos, 10); + return offset ? this.bb!.__string(this.bb!.__vector(this.bb_pos + offset) + index * 4, optionalEncoding) : null; +} + +documentationLength():number { + const offset = this.bb!.__offset(this.bb_pos, 10); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +} + +/** + * File that this Service is declared in. + */ +declarationFile():string|null +declarationFile(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null +declarationFile(optionalEncoding?:any):string|Uint8Array|null { + const offset = this.bb!.__offset(this.bb_pos, 12); + return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; +} + +static getFullyQualifiedName():string { + return 'reflection_Service'; +} + +static startService(builder:flatbuffers.Builder) { + builder.startObject(5); +} + +static addName(builder:flatbuffers.Builder, nameOffset:flatbuffers.Offset) { + builder.addFieldOffset(0, nameOffset, 0); +} + +static addCalls(builder:flatbuffers.Builder, callsOffset:flatbuffers.Offset) { + builder.addFieldOffset(1, callsOffset, 0); +} + +static createCallsVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addOffset(data[i]!); + } + return builder.endVector(); +} + +static startCallsVector(builder:flatbuffers.Builder, numElems:number) { + builder.startVector(4, numElems, 4); +} + +static addAttributes(builder:flatbuffers.Builder, attributesOffset:flatbuffers.Offset) { + builder.addFieldOffset(2, attributesOffset, 0); +} + +static createAttributesVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addOffset(data[i]!); + } + return builder.endVector(); +} + +static startAttributesVector(builder:flatbuffers.Builder, numElems:number) { + builder.startVector(4, numElems, 4); +} + +static addDocumentation(builder:flatbuffers.Builder, documentationOffset:flatbuffers.Offset) { + builder.addFieldOffset(3, documentationOffset, 0); +} + +static createDocumentationVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addOffset(data[i]!); + } + return builder.endVector(); +} + +static startDocumentationVector(builder:flatbuffers.Builder, numElems:number) { + builder.startVector(4, numElems, 4); +} + +static addDeclarationFile(builder:flatbuffers.Builder, declarationFileOffset:flatbuffers.Offset) { + builder.addFieldOffset(4, declarationFileOffset, 0); +} + +static endService(builder:flatbuffers.Builder):flatbuffers.Offset { + const offset = builder.endObject(); + builder.requiredField(offset, 4) // name + return offset; +} + +static createService(builder:flatbuffers.Builder, nameOffset:flatbuffers.Offset, callsOffset:flatbuffers.Offset, attributesOffset:flatbuffers.Offset, documentationOffset:flatbuffers.Offset, declarationFileOffset:flatbuffers.Offset):flatbuffers.Offset { + Service.startService(builder); + Service.addName(builder, nameOffset); + Service.addCalls(builder, callsOffset); + Service.addAttributes(builder, attributesOffset); + Service.addDocumentation(builder, documentationOffset); + Service.addDeclarationFile(builder, declarationFileOffset); + return Service.endService(builder); +} + +unpack(): ServiceT { + return new ServiceT( + this.name(), + this.bb!.createObjList(this.calls.bind(this), this.callsLength()), + this.bb!.createObjList(this.attributes.bind(this), this.attributesLength()), + this.bb!.createScalarList(this.documentation.bind(this), this.documentationLength()), + this.declarationFile() + ); +} + + +unpackTo(_o: ServiceT): void { + _o.name = this.name(); + _o.calls = this.bb!.createObjList(this.calls.bind(this), this.callsLength()); + _o.attributes = this.bb!.createObjList(this.attributes.bind(this), this.attributesLength()); + _o.documentation = this.bb!.createScalarList(this.documentation.bind(this), this.documentationLength()); + _o.declarationFile = this.declarationFile(); +} +} + +export class ServiceT { +constructor( + public name: string|Uint8Array|null = null, + public calls: (RPCCallT)[] = [], + public attributes: (KeyValueT)[] = [], + public documentation: (string)[] = [], + public declarationFile: string|Uint8Array|null = null +){} + + +pack(builder:flatbuffers.Builder): flatbuffers.Offset { + const name = (this.name !== null ? builder.createString(this.name!) : 0); + const calls = Service.createCallsVector(builder, builder.createObjectOffsetList(this.calls)); + const attributes = Service.createAttributesVector(builder, builder.createObjectOffsetList(this.attributes)); + const documentation = Service.createDocumentationVector(builder, builder.createObjectOffsetList(this.documentation)); + const declarationFile = (this.declarationFile !== null ? builder.createString(this.declarationFile!) : 0); + + return Service.createService(builder, + name, + calls, + attributes, + documentation, + declarationFile + ); +} +} + +/** + * File specific information. + * Symbols declared within a file may be recovered by iterating over all + * symbols and examining the `declaration_file` field. + */ +export class SchemaFile { + bb: flatbuffers.ByteBuffer|null = null; + bb_pos = 0; + __init(i:number, bb:flatbuffers.ByteBuffer):SchemaFile { + this.bb_pos = i; + this.bb = bb; + return this; +} + +static getRootAsSchemaFile(bb:flatbuffers.ByteBuffer, obj?:SchemaFile):SchemaFile { + return (obj || new SchemaFile()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +static getSizePrefixedRootAsSchemaFile(bb:flatbuffers.ByteBuffer, obj?:SchemaFile):SchemaFile { + bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); + return (obj || new SchemaFile()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +/** + * Filename, relative to project root. + */ +filename():string|null +filename(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null +filename(optionalEncoding?:any):string|Uint8Array|null { + const offset = this.bb!.__offset(this.bb_pos, 4); + return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; +} + +/** + * Names of included files, relative to project root. + */ +includedFilenames(index: number):string +includedFilenames(index: number,optionalEncoding:flatbuffers.Encoding):string|Uint8Array +includedFilenames(index: number,optionalEncoding?:any):string|Uint8Array|null { + const offset = this.bb!.__offset(this.bb_pos, 6); + return offset ? this.bb!.__string(this.bb!.__vector(this.bb_pos + offset) + index * 4, optionalEncoding) : null; +} + +includedFilenamesLength():number { + const offset = this.bb!.__offset(this.bb_pos, 6); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +} + +static getFullyQualifiedName():string { + return 'reflection_SchemaFile'; +} + +static startSchemaFile(builder:flatbuffers.Builder) { + builder.startObject(2); +} + +static addFilename(builder:flatbuffers.Builder, filenameOffset:flatbuffers.Offset) { + builder.addFieldOffset(0, filenameOffset, 0); +} + +static addIncludedFilenames(builder:flatbuffers.Builder, includedFilenamesOffset:flatbuffers.Offset) { + builder.addFieldOffset(1, includedFilenamesOffset, 0); +} + +static createIncludedFilenamesVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addOffset(data[i]!); + } + return builder.endVector(); +} + +static startIncludedFilenamesVector(builder:flatbuffers.Builder, numElems:number) { + builder.startVector(4, numElems, 4); +} + +static endSchemaFile(builder:flatbuffers.Builder):flatbuffers.Offset { + const offset = builder.endObject(); + builder.requiredField(offset, 4) // filename + return offset; +} + +static createSchemaFile(builder:flatbuffers.Builder, filenameOffset:flatbuffers.Offset, includedFilenamesOffset:flatbuffers.Offset):flatbuffers.Offset { + SchemaFile.startSchemaFile(builder); + SchemaFile.addFilename(builder, filenameOffset); + SchemaFile.addIncludedFilenames(builder, includedFilenamesOffset); + return SchemaFile.endSchemaFile(builder); +} + +unpack(): SchemaFileT { + return new SchemaFileT( + this.filename(), + this.bb!.createScalarList(this.includedFilenames.bind(this), this.includedFilenamesLength()) + ); +} + + +unpackTo(_o: SchemaFileT): void { + _o.filename = this.filename(); + _o.includedFilenames = this.bb!.createScalarList(this.includedFilenames.bind(this), this.includedFilenamesLength()); +} +} + +export class SchemaFileT { +constructor( + public filename: string|Uint8Array|null = null, + public includedFilenames: (string)[] = [] +){} + + +pack(builder:flatbuffers.Builder): flatbuffers.Offset { + const filename = (this.filename !== null ? builder.createString(this.filename!) : 0); + const includedFilenames = SchemaFile.createIncludedFilenamesVector(builder, builder.createObjectOffsetList(this.includedFilenames)); + + return SchemaFile.createSchemaFile(builder, + filename, + includedFilenames + ); +} +} + +export class Schema { + bb: flatbuffers.ByteBuffer|null = null; + bb_pos = 0; + __init(i:number, bb:flatbuffers.ByteBuffer):Schema { + this.bb_pos = i; + this.bb = bb; + return this; +} + +static getRootAsSchema(bb:flatbuffers.ByteBuffer, obj?:Schema):Schema { + return (obj || new Schema()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +static getSizePrefixedRootAsSchema(bb:flatbuffers.ByteBuffer, obj?:Schema):Schema { + bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); + return (obj || new Schema()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +static bufferHasIdentifier(bb:flatbuffers.ByteBuffer):boolean { + return bb.__has_identifier('BFBS'); +} + +objects(index: number, obj?:Object_):Object_|null { + const offset = this.bb!.__offset(this.bb_pos, 4); + return offset ? (obj || new Object_()).__init(this.bb!.__indirect(this.bb!.__vector(this.bb_pos + offset) + index * 4), this.bb!) : null; +} + +objectsLength():number { + const offset = this.bb!.__offset(this.bb_pos, 4); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +} + +enums(index: number, obj?:Enum):Enum|null { + const offset = this.bb!.__offset(this.bb_pos, 6); + return offset ? (obj || new Enum()).__init(this.bb!.__indirect(this.bb!.__vector(this.bb_pos + offset) + index * 4), this.bb!) : null; +} + +enumsLength():number { + const offset = this.bb!.__offset(this.bb_pos, 6); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +} + +fileIdent():string|null +fileIdent(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null +fileIdent(optionalEncoding?:any):string|Uint8Array|null { + const offset = this.bb!.__offset(this.bb_pos, 8); + return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; +} + +fileExt():string|null +fileExt(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null +fileExt(optionalEncoding?:any):string|Uint8Array|null { + const offset = this.bb!.__offset(this.bb_pos, 10); + return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; +} + +rootTable(obj?:Object_):Object_|null { + const offset = this.bb!.__offset(this.bb_pos, 12); + return offset ? (obj || new Object_()).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null; +} + +services(index: number, obj?:Service):Service|null { + const offset = this.bb!.__offset(this.bb_pos, 14); + return offset ? (obj || new Service()).__init(this.bb!.__indirect(this.bb!.__vector(this.bb_pos + offset) + index * 4), this.bb!) : null; +} + +servicesLength():number { + const offset = this.bb!.__offset(this.bb_pos, 14); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +} + +advancedFeatures():bigint { + const offset = this.bb!.__offset(this.bb_pos, 16); + return offset ? this.bb!.readUint64(this.bb_pos + offset) : BigInt('0'); +} + +mutate_advanced_features(value:bigint):boolean { + const offset = this.bb!.__offset(this.bb_pos, 16); + + if (offset === 0) { + return false; + } + + this.bb!.writeUint64(this.bb_pos + offset, value); + return true; +} + +/** + * All the files used in this compilation. Files are relative to where + * flatc was invoked. + */ +fbsFiles(index: number, obj?:SchemaFile):SchemaFile|null { + const offset = this.bb!.__offset(this.bb_pos, 18); + return offset ? (obj || new SchemaFile()).__init(this.bb!.__indirect(this.bb!.__vector(this.bb_pos + offset) + index * 4), this.bb!) : null; +} + +fbsFilesLength():number { + const offset = this.bb!.__offset(this.bb_pos, 18); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +} + +static getFullyQualifiedName():string { + return 'reflection_Schema'; +} + +static startSchema(builder:flatbuffers.Builder) { + builder.startObject(8); +} + +static addObjects(builder:flatbuffers.Builder, objectsOffset:flatbuffers.Offset) { + builder.addFieldOffset(0, objectsOffset, 0); +} + +static createObjectsVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addOffset(data[i]!); + } + return builder.endVector(); +} + +static startObjectsVector(builder:flatbuffers.Builder, numElems:number) { + builder.startVector(4, numElems, 4); +} + +static addEnums(builder:flatbuffers.Builder, enumsOffset:flatbuffers.Offset) { + builder.addFieldOffset(1, enumsOffset, 0); +} + +static createEnumsVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addOffset(data[i]!); + } + return builder.endVector(); +} + +static startEnumsVector(builder:flatbuffers.Builder, numElems:number) { + builder.startVector(4, numElems, 4); +} + +static addFileIdent(builder:flatbuffers.Builder, fileIdentOffset:flatbuffers.Offset) { + builder.addFieldOffset(2, fileIdentOffset, 0); +} + +static addFileExt(builder:flatbuffers.Builder, fileExtOffset:flatbuffers.Offset) { + builder.addFieldOffset(3, fileExtOffset, 0); +} + +static addRootTable(builder:flatbuffers.Builder, rootTableOffset:flatbuffers.Offset) { + builder.addFieldOffset(4, rootTableOffset, 0); +} + +static addServices(builder:flatbuffers.Builder, servicesOffset:flatbuffers.Offset) { + builder.addFieldOffset(5, servicesOffset, 0); +} + +static createServicesVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addOffset(data[i]!); + } + return builder.endVector(); +} + +static startServicesVector(builder:flatbuffers.Builder, numElems:number) { + builder.startVector(4, numElems, 4); +} + +static addAdvancedFeatures(builder:flatbuffers.Builder, advancedFeatures:bigint) { + builder.addFieldInt64(6, advancedFeatures, BigInt('0')); +} + +static addFbsFiles(builder:flatbuffers.Builder, fbsFilesOffset:flatbuffers.Offset) { + builder.addFieldOffset(7, fbsFilesOffset, 0); +} + +static createFbsFilesVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addOffset(data[i]!); + } + return builder.endVector(); +} + +static startFbsFilesVector(builder:flatbuffers.Builder, numElems:number) { + builder.startVector(4, numElems, 4); +} + +static endSchema(builder:flatbuffers.Builder):flatbuffers.Offset { + const offset = builder.endObject(); + builder.requiredField(offset, 4) // objects + builder.requiredField(offset, 6) // enums + return offset; +} + +static finishSchemaBuffer(builder:flatbuffers.Builder, offset:flatbuffers.Offset) { + builder.finish(offset, 'BFBS'); +} + +static finishSizePrefixedSchemaBuffer(builder:flatbuffers.Builder, offset:flatbuffers.Offset) { + builder.finish(offset, 'BFBS', true); +} + + +unpack(): SchemaT { + return new SchemaT( + this.bb!.createObjList(this.objects.bind(this), this.objectsLength()), + this.bb!.createObjList(this.enums.bind(this), this.enumsLength()), + this.fileIdent(), + this.fileExt(), + (this.rootTable() !== null ? this.rootTable()!.unpack() : null), + this.bb!.createObjList(this.services.bind(this), this.servicesLength()), + this.advancedFeatures(), + this.bb!.createObjList(this.fbsFiles.bind(this), this.fbsFilesLength()) + ); +} + + +unpackTo(_o: SchemaT): void { + _o.objects = this.bb!.createObjList(this.objects.bind(this), this.objectsLength()); + _o.enums = this.bb!.createObjList(this.enums.bind(this), this.enumsLength()); + _o.fileIdent = this.fileIdent(); + _o.fileExt = this.fileExt(); + _o.rootTable = (this.rootTable() !== null ? this.rootTable()!.unpack() : null); + _o.services = this.bb!.createObjList(this.services.bind(this), this.servicesLength()); + _o.advancedFeatures = this.advancedFeatures(); + _o.fbsFiles = this.bb!.createObjList(this.fbsFiles.bind(this), this.fbsFilesLength()); +} +} + +export class SchemaT { +constructor( + public objects: (Object_T)[] = [], + public enums: (EnumT)[] = [], + public fileIdent: string|Uint8Array|null = null, + public fileExt: string|Uint8Array|null = null, + public rootTable: Object_T|null = null, + public services: (ServiceT)[] = [], + public advancedFeatures: bigint = BigInt('0'), + public fbsFiles: (SchemaFileT)[] = [] +){} + + +pack(builder:flatbuffers.Builder): flatbuffers.Offset { + const objects = Schema.createObjectsVector(builder, builder.createObjectOffsetList(this.objects)); + const enums = Schema.createEnumsVector(builder, builder.createObjectOffsetList(this.enums)); + const fileIdent = (this.fileIdent !== null ? builder.createString(this.fileIdent!) : 0); + const fileExt = (this.fileExt !== null ? builder.createString(this.fileExt!) : 0); + const rootTable = (this.rootTable !== null ? this.rootTable!.pack(builder) : 0); + const services = Schema.createServicesVector(builder, builder.createObjectOffsetList(this.services)); + const fbsFiles = Schema.createFbsFilesVector(builder, builder.createObjectOffsetList(this.fbsFiles)); + + Schema.startSchema(builder); + Schema.addObjects(builder, objects); + Schema.addEnums(builder, enums); + Schema.addFileIdent(builder, fileIdent); + Schema.addFileExt(builder, fileExt); + Schema.addRootTable(builder, rootTable); + Schema.addServices(builder, services); + Schema.addAdvancedFeatures(builder, this.advancedFeatures); + Schema.addFbsFiles(builder, fbsFiles); + + return Schema.endSchema(builder); +} +} + diff --git a/tests/test_dir/BUILD.bazel b/tests/ts/test_dir/BUILD.bazel similarity index 100% rename from tests/test_dir/BUILD.bazel rename to tests/ts/test_dir/BUILD.bazel diff --git a/tests/test_dir/typescript_include.fbs b/tests/ts/test_dir/typescript_include.fbs similarity index 100% rename from tests/test_dir/typescript_include.fbs rename to tests/ts/test_dir/typescript_include.fbs diff --git a/tests/test_dir/typescript_transitive_include.fbs b/tests/ts/test_dir/typescript_transitive_include.fbs similarity index 100% rename from tests/test_dir/typescript_transitive_include.fbs rename to tests/ts/test_dir/typescript_transitive_include.fbs diff --git a/tests/tsconfig.json b/tests/ts/tsconfig.json similarity index 100% rename from tests/tsconfig.json rename to tests/ts/tsconfig.json diff --git a/tests/ts/typescript/class.js b/tests/ts/typescript/class.js new file mode 100644 index 00000000000..9b0f2c00b6d --- /dev/null +++ b/tests/ts/typescript/class.js @@ -0,0 +1,6 @@ +// automatically generated by the FlatBuffers compiler, do not modify +export var class_; +(function (class_) { + class_[class_["new_"] = 0] = "new_"; + class_[class_["instanceof_"] = 1] = "instanceof_"; +})(class_ || (class_ = {})); diff --git a/tests/ts/typescript/class.ts b/tests/ts/typescript/class.ts new file mode 100644 index 00000000000..fd8f1457041 --- /dev/null +++ b/tests/ts/typescript/class.ts @@ -0,0 +1,6 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +export enum class_ { + new_ = 0, + instanceof_ = 1 +} diff --git a/tests/ts/typescript/object.js b/tests/ts/typescript/object.js new file mode 100644 index 00000000000..05ffb1a5692 --- /dev/null +++ b/tests/ts/typescript/object.js @@ -0,0 +1,166 @@ +// automatically generated by the FlatBuffers compiler, do not modify +import * as flatbuffers from 'flatbuffers'; +import { Abc } from '../foobar/abc.js'; +import { class_ as foobar_class_ } from '../foobar/class.js'; +import { Schema } from '../reflection/schema.js'; +import { class_ } from '../typescript/class.js'; +export class Object_ { + constructor() { + this.bb = null; + this.bb_pos = 0; + } + __init(i, bb) { + this.bb_pos = i; + this.bb = bb; + return this; + } + static getRootAsObject(bb, obj) { + return (obj || new Object_()).__init(bb.readInt32(bb.position()) + bb.position(), bb); + } + static getSizePrefixedRootAsObject(bb, obj) { + bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); + return (obj || new Object_()).__init(bb.readInt32(bb.position()) + bb.position(), bb); + } + return_() { + const offset = this.bb.__offset(this.bb_pos, 4); + return offset ? this.bb.readInt32(this.bb_pos + offset) : 0; + } + mutate_return(value) { + const offset = this.bb.__offset(this.bb_pos, 4); + if (offset === 0) { + return false; + } + this.bb.writeInt32(this.bb_pos + offset, value); + return true; + } + if_() { + const offset = this.bb.__offset(this.bb_pos, 6); + return offset ? this.bb.readInt32(this.bb_pos + offset) : 0; + } + mutate_if(value) { + const offset = this.bb.__offset(this.bb_pos, 6); + if (offset === 0) { + return false; + } + this.bb.writeInt32(this.bb_pos + offset, value); + return true; + } + switch_() { + const offset = this.bb.__offset(this.bb_pos, 8); + return offset ? this.bb.readInt32(this.bb_pos + offset) : 0; + } + mutate_switch(value) { + const offset = this.bb.__offset(this.bb_pos, 8); + if (offset === 0) { + return false; + } + this.bb.writeInt32(this.bb_pos + offset, value); + return true; + } + enum_() { + const offset = this.bb.__offset(this.bb_pos, 10); + return offset ? this.bb.readInt32(this.bb_pos + offset) : class_.new_; + } + mutate_enum(value) { + const offset = this.bb.__offset(this.bb_pos, 10); + if (offset === 0) { + return false; + } + this.bb.writeInt32(this.bb_pos + offset, value); + return true; + } + enum2() { + const offset = this.bb.__offset(this.bb_pos, 12); + return offset ? this.bb.readInt32(this.bb_pos + offset) : foobar_class_.arguments_; + } + mutate_enum2(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; + } + enum3() { + const offset = this.bb.__offset(this.bb_pos, 14); + return offset ? this.bb.readInt32(this.bb_pos + offset) : Abc.a; + } + mutate_enum3(value) { + const offset = this.bb.__offset(this.bb_pos, 14); + if (offset === 0) { + return false; + } + this.bb.writeInt32(this.bb_pos + offset, value); + return true; + } + reflect(obj) { + const offset = this.bb.__offset(this.bb_pos, 16); + return offset ? (obj || new Schema()).__init(this.bb.__indirect(this.bb_pos + offset), this.bb) : null; + } + static getFullyQualifiedName() { + return 'typescript_Object'; + } + static startObject(builder) { + builder.startObject(7); + } + static addReturn(builder, return_) { + builder.addFieldInt32(0, return_, 0); + } + static addIf(builder, if_) { + builder.addFieldInt32(1, if_, 0); + } + static addSwitch(builder, switch_) { + builder.addFieldInt32(2, switch_, 0); + } + static addEnum(builder, enum_) { + builder.addFieldInt32(3, enum_, class_.new_); + } + static addEnum2(builder, enum2) { + builder.addFieldInt32(4, enum2, foobar_class_.arguments_); + } + static addEnum3(builder, enum3) { + builder.addFieldInt32(5, enum3, Abc.a); + } + static addReflect(builder, reflectOffset) { + builder.addFieldOffset(6, reflectOffset, 0); + } + static endObject(builder) { + const offset = builder.endObject(); + return offset; + } + unpack() { + return new Object_T(this.return_(), this.if_(), this.switch_(), this.enum_(), this.enum2(), this.enum3(), (this.reflect() !== null ? this.reflect().unpack() : null)); + } + unpackTo(_o) { + _o.return_ = this.return_(); + _o.if_ = this.if_(); + _o.switch_ = this.switch_(); + _o.enum_ = this.enum_(); + _o.enum2 = this.enum2(); + _o.enum3 = this.enum3(); + _o.reflect = (this.reflect() !== null ? this.reflect().unpack() : null); + } +} +export class Object_T { + constructor(return_ = 0, if_ = 0, switch_ = 0, enum_ = class_.new_, enum2 = foobar_class_.arguments_, enum3 = Abc.a, reflect = null) { + this.return_ = return_; + this.if_ = if_; + this.switch_ = switch_; + this.enum_ = enum_; + this.enum2 = enum2; + this.enum3 = enum3; + this.reflect = reflect; + } + pack(builder) { + const reflect = (this.reflect !== null ? this.reflect.pack(builder) : 0); + Object_.startObject(builder); + Object_.addReturn(builder, this.return_); + Object_.addIf(builder, this.if_); + Object_.addSwitch(builder, this.switch_); + Object_.addEnum(builder, this.enum_); + Object_.addEnum2(builder, this.enum2); + Object_.addEnum3(builder, this.enum3); + Object_.addReflect(builder, reflect); + return Object_.endObject(builder); + } +} diff --git a/tests/ts/typescript/object.ts b/tests/ts/typescript/object.ts new file mode 100644 index 00000000000..041b6609388 --- /dev/null +++ b/tests/ts/typescript/object.ts @@ -0,0 +1,222 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +import * as flatbuffers from 'flatbuffers'; + +import { Abc } from '../foobar/abc.js'; +import { class_ as foobar_class_ } from '../foobar/class.js'; +import { Schema, SchemaT } from '../reflection/schema.js'; +import { class_ } from '../typescript/class.js'; + + +export class Object_ { + bb: flatbuffers.ByteBuffer|null = null; + bb_pos = 0; + __init(i:number, bb:flatbuffers.ByteBuffer):Object_ { + this.bb_pos = i; + this.bb = bb; + return this; +} + +static getRootAsObject(bb:flatbuffers.ByteBuffer, obj?:Object_):Object_ { + return (obj || new Object_()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +static getSizePrefixedRootAsObject(bb:flatbuffers.ByteBuffer, obj?:Object_):Object_ { + bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); + return (obj || new Object_()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +return_():number { + const offset = this.bb!.__offset(this.bb_pos, 4); + return offset ? this.bb!.readInt32(this.bb_pos + offset) : 0; +} + +mutate_return(value:number):boolean { + const offset = this.bb!.__offset(this.bb_pos, 4); + + if (offset === 0) { + return false; + } + + this.bb!.writeInt32(this.bb_pos + offset, value); + return true; +} + +if_():number { + const offset = this.bb!.__offset(this.bb_pos, 6); + return offset ? this.bb!.readInt32(this.bb_pos + offset) : 0; +} + +mutate_if(value:number):boolean { + const offset = this.bb!.__offset(this.bb_pos, 6); + + if (offset === 0) { + return false; + } + + this.bb!.writeInt32(this.bb_pos + offset, value); + return true; +} + +switch_():number { + const offset = this.bb!.__offset(this.bb_pos, 8); + return offset ? this.bb!.readInt32(this.bb_pos + offset) : 0; +} + +mutate_switch(value:number):boolean { + const offset = this.bb!.__offset(this.bb_pos, 8); + + if (offset === 0) { + return false; + } + + this.bb!.writeInt32(this.bb_pos + offset, value); + return true; +} + +enum_():class_ { + const offset = this.bb!.__offset(this.bb_pos, 10); + return offset ? this.bb!.readInt32(this.bb_pos + offset) : class_.new_; +} + +mutate_enum(value:class_):boolean { + const offset = this.bb!.__offset(this.bb_pos, 10); + + if (offset === 0) { + return false; + } + + this.bb!.writeInt32(this.bb_pos + offset, value); + return true; +} + +enum2():foobar_class_ { + const offset = this.bb!.__offset(this.bb_pos, 12); + return offset ? this.bb!.readInt32(this.bb_pos + offset) : foobar_class_.arguments_; +} + +mutate_enum2(value:foobar_class_):boolean { + const offset = this.bb!.__offset(this.bb_pos, 12); + + if (offset === 0) { + return false; + } + + this.bb!.writeInt32(this.bb_pos + offset, value); + return true; +} + +enum3():Abc { + const offset = this.bb!.__offset(this.bb_pos, 14); + return offset ? this.bb!.readInt32(this.bb_pos + offset) : Abc.a; +} + +mutate_enum3(value:Abc):boolean { + const offset = this.bb!.__offset(this.bb_pos, 14); + + if (offset === 0) { + return false; + } + + this.bb!.writeInt32(this.bb_pos + offset, value); + return true; +} + +reflect(obj?:Schema):Schema|null { + const offset = this.bb!.__offset(this.bb_pos, 16); + return offset ? (obj || new Schema()).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null; +} + +static getFullyQualifiedName():string { + return 'typescript_Object'; +} + +static startObject(builder:flatbuffers.Builder) { + builder.startObject(7); +} + +static addReturn(builder:flatbuffers.Builder, return_:number) { + builder.addFieldInt32(0, return_, 0); +} + +static addIf(builder:flatbuffers.Builder, if_:number) { + builder.addFieldInt32(1, if_, 0); +} + +static addSwitch(builder:flatbuffers.Builder, switch_:number) { + builder.addFieldInt32(2, switch_, 0); +} + +static addEnum(builder:flatbuffers.Builder, enum_:class_) { + builder.addFieldInt32(3, enum_, class_.new_); +} + +static addEnum2(builder:flatbuffers.Builder, enum2:foobar_class_) { + builder.addFieldInt32(4, enum2, foobar_class_.arguments_); +} + +static addEnum3(builder:flatbuffers.Builder, enum3:Abc) { + builder.addFieldInt32(5, enum3, Abc.a); +} + +static addReflect(builder:flatbuffers.Builder, reflectOffset:flatbuffers.Offset) { + builder.addFieldOffset(6, reflectOffset, 0); +} + +static endObject(builder:flatbuffers.Builder):flatbuffers.Offset { + const offset = builder.endObject(); + return offset; +} + + +unpack(): Object_T { + return new Object_T( + this.return_(), + this.if_(), + this.switch_(), + this.enum_(), + this.enum2(), + this.enum3(), + (this.reflect() !== null ? this.reflect()!.unpack() : null) + ); +} + + +unpackTo(_o: Object_T): void { + _o.return_ = this.return_(); + _o.if_ = this.if_(); + _o.switch_ = this.switch_(); + _o.enum_ = this.enum_(); + _o.enum2 = this.enum2(); + _o.enum3 = this.enum3(); + _o.reflect = (this.reflect() !== null ? this.reflect()!.unpack() : null); +} +} + +export class Object_T { +constructor( + public return_: number = 0, + public if_: number = 0, + public switch_: number = 0, + public enum_: class_ = class_.new_, + public enum2: foobar_class_ = foobar_class_.arguments_, + public enum3: Abc = Abc.a, + public reflect: SchemaT|null = null +){} + + +pack(builder:flatbuffers.Builder): flatbuffers.Offset { + const reflect = (this.reflect !== null ? this.reflect!.pack(builder) : 0); + + Object_.startObject(builder); + Object_.addReturn(builder, this.return_); + Object_.addIf(builder, this.if_); + Object_.addSwitch(builder, this.switch_); + Object_.addEnum(builder, this.enum_); + Object_.addEnum2(builder, this.enum2); + Object_.addEnum3(builder, this.enum3); + Object_.addReflect(builder, reflect); + + return Object_.endObject(builder); +} +} diff --git a/tests/ts/typescript_include_generated.js b/tests/ts/typescript_include_generated.js new file mode 100644 index 00000000000..e0e1df1bea2 --- /dev/null +++ b/tests/ts/typescript_include_generated.js @@ -0,0 +1,5 @@ +// automatically generated by the FlatBuffers compiler, do not modify +export var class_; +(function (class_) { + class_[class_["arguments_"] = 0] = "arguments_"; +})(class_ || (class_ = {})); diff --git a/tests/ts/typescript_include_generated.ts b/tests/ts/typescript_include_generated.ts new file mode 100644 index 00000000000..d419431cfdf --- /dev/null +++ b/tests/ts/typescript_include_generated.ts @@ -0,0 +1,7 @@ +// automatically generated by the FlatBuffers compiler, do not modify + + +export enum class_ { + arguments_ = 0 +} + diff --git a/tests/typescript_keywords.fbs b/tests/ts/typescript_keywords.fbs similarity index 100% rename from tests/typescript_keywords.fbs rename to tests/ts/typescript_keywords.fbs diff --git a/tests/ts/typescript_keywords_generated.js b/tests/ts/typescript_keywords_generated.js new file mode 100644 index 00000000000..4525da7de4a --- /dev/null +++ b/tests/ts/typescript_keywords_generated.js @@ -0,0 +1,170 @@ +// automatically generated by the FlatBuffers compiler, do not modify +import * as flatbuffers from 'flatbuffers'; +import { Schema as Schema } from './reflection_generated.js'; +import { class_ as foobar_class_ } from './typescript_include_generated.js'; +import { Abc as Abc } from './typescript_transitive_include_generated.js'; +export var class_; +(function (class_) { + class_[class_["new_"] = 0] = "new_"; + class_[class_["instanceof_"] = 1] = "instanceof_"; +})(class_ || (class_ = {})); +export class Object_ { + constructor() { + this.bb = null; + this.bb_pos = 0; + } + __init(i, bb) { + this.bb_pos = i; + this.bb = bb; + return this; + } + static getRootAsObject(bb, obj) { + return (obj || new Object_()).__init(bb.readInt32(bb.position()) + bb.position(), bb); + } + static getSizePrefixedRootAsObject(bb, obj) { + bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); + return (obj || new Object_()).__init(bb.readInt32(bb.position()) + bb.position(), bb); + } + return_() { + const offset = this.bb.__offset(this.bb_pos, 4); + return offset ? this.bb.readInt32(this.bb_pos + offset) : 0; + } + mutate_return(value) { + const offset = this.bb.__offset(this.bb_pos, 4); + if (offset === 0) { + return false; + } + this.bb.writeInt32(this.bb_pos + offset, value); + return true; + } + if_() { + const offset = this.bb.__offset(this.bb_pos, 6); + return offset ? this.bb.readInt32(this.bb_pos + offset) : 0; + } + mutate_if(value) { + const offset = this.bb.__offset(this.bb_pos, 6); + if (offset === 0) { + return false; + } + this.bb.writeInt32(this.bb_pos + offset, value); + return true; + } + switch_() { + const offset = this.bb.__offset(this.bb_pos, 8); + return offset ? this.bb.readInt32(this.bb_pos + offset) : 0; + } + mutate_switch(value) { + const offset = this.bb.__offset(this.bb_pos, 8); + if (offset === 0) { + return false; + } + this.bb.writeInt32(this.bb_pos + offset, value); + return true; + } + enum_() { + const offset = this.bb.__offset(this.bb_pos, 10); + return offset ? this.bb.readInt32(this.bb_pos + offset) : class_.new_; + } + mutate_enum(value) { + const offset = this.bb.__offset(this.bb_pos, 10); + if (offset === 0) { + return false; + } + this.bb.writeInt32(this.bb_pos + offset, value); + return true; + } + enum2() { + const offset = this.bb.__offset(this.bb_pos, 12); + return offset ? this.bb.readInt32(this.bb_pos + offset) : foobar_class_.arguments_; + } + mutate_enum2(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; + } + enum3() { + const offset = this.bb.__offset(this.bb_pos, 14); + return offset ? this.bb.readInt32(this.bb_pos + offset) : Abc.a; + } + mutate_enum3(value) { + const offset = this.bb.__offset(this.bb_pos, 14); + if (offset === 0) { + return false; + } + this.bb.writeInt32(this.bb_pos + offset, value); + return true; + } + reflect(obj) { + const offset = this.bb.__offset(this.bb_pos, 16); + return offset ? (obj || new Schema()).__init(this.bb.__indirect(this.bb_pos + offset), this.bb) : null; + } + static getFullyQualifiedName() { + return 'typescript_Object'; + } + static startObject(builder) { + builder.startObject(7); + } + static addReturn(builder, return_) { + builder.addFieldInt32(0, return_, 0); + } + static addIf(builder, if_) { + builder.addFieldInt32(1, if_, 0); + } + static addSwitch(builder, switch_) { + builder.addFieldInt32(2, switch_, 0); + } + static addEnum(builder, enum_) { + builder.addFieldInt32(3, enum_, class_.new_); + } + static addEnum2(builder, enum2) { + builder.addFieldInt32(4, enum2, foobar_class_.arguments_); + } + static addEnum3(builder, enum3) { + builder.addFieldInt32(5, enum3, Abc.a); + } + static addReflect(builder, reflectOffset) { + builder.addFieldOffset(6, reflectOffset, 0); + } + static endObject(builder) { + const offset = builder.endObject(); + return offset; + } + unpack() { + return new Object_T(this.return_(), this.if_(), this.switch_(), this.enum_(), this.enum2(), this.enum3(), (this.reflect() !== null ? this.reflect().unpack() : null)); + } + unpackTo(_o) { + _o.return_ = this.return_(); + _o.if_ = this.if_(); + _o.switch_ = this.switch_(); + _o.enum_ = this.enum_(); + _o.enum2 = this.enum2(); + _o.enum3 = this.enum3(); + _o.reflect = (this.reflect() !== null ? this.reflect().unpack() : null); + } +} +export class Object_T { + constructor(return_ = 0, if_ = 0, switch_ = 0, enum_ = class_.new_, enum2 = foobar_class_.arguments_, enum3 = Abc.a, reflect = null) { + this.return_ = return_; + this.if_ = if_; + this.switch_ = switch_; + this.enum_ = enum_; + this.enum2 = enum2; + this.enum3 = enum3; + this.reflect = reflect; + } + pack(builder) { + const reflect = (this.reflect !== null ? this.reflect.pack(builder) : 0); + Object_.startObject(builder); + Object_.addReturn(builder, this.return_); + Object_.addIf(builder, this.if_); + Object_.addSwitch(builder, this.switch_); + Object_.addEnum(builder, this.enum_); + Object_.addEnum2(builder, this.enum2); + Object_.addEnum3(builder, this.enum3); + Object_.addReflect(builder, reflect); + return Object_.endObject(builder); + } +} diff --git a/tests/ts/typescript_keywords_generated.ts b/tests/ts/typescript_keywords_generated.ts new file mode 100644 index 00000000000..4272425309e --- /dev/null +++ b/tests/ts/typescript_keywords_generated.ts @@ -0,0 +1,226 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +import * as flatbuffers from 'flatbuffers'; + +import {Schema as Schema, SchemaT as SchemaT} from './reflection_generated.js'; +import {class_ as foobar_class_} from './typescript_include_generated.js'; +import {Abc as Abc} from './typescript_transitive_include_generated.js'; + +export enum class_ { + new_ = 0, + instanceof_ = 1 +} + +export class Object_ { + bb: flatbuffers.ByteBuffer|null = null; + bb_pos = 0; + __init(i:number, bb:flatbuffers.ByteBuffer):Object_ { + this.bb_pos = i; + this.bb = bb; + return this; +} + +static getRootAsObject(bb:flatbuffers.ByteBuffer, obj?:Object_):Object_ { + return (obj || new Object_()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +static getSizePrefixedRootAsObject(bb:flatbuffers.ByteBuffer, obj?:Object_):Object_ { + bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); + return (obj || new Object_()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +return_():number { + const offset = this.bb!.__offset(this.bb_pos, 4); + return offset ? this.bb!.readInt32(this.bb_pos + offset) : 0; +} + +mutate_return(value:number):boolean { + const offset = this.bb!.__offset(this.bb_pos, 4); + + if (offset === 0) { + return false; + } + + this.bb!.writeInt32(this.bb_pos + offset, value); + return true; +} + +if_():number { + const offset = this.bb!.__offset(this.bb_pos, 6); + return offset ? this.bb!.readInt32(this.bb_pos + offset) : 0; +} + +mutate_if(value:number):boolean { + const offset = this.bb!.__offset(this.bb_pos, 6); + + if (offset === 0) { + return false; + } + + this.bb!.writeInt32(this.bb_pos + offset, value); + return true; +} + +switch_():number { + const offset = this.bb!.__offset(this.bb_pos, 8); + return offset ? this.bb!.readInt32(this.bb_pos + offset) : 0; +} + +mutate_switch(value:number):boolean { + const offset = this.bb!.__offset(this.bb_pos, 8); + + if (offset === 0) { + return false; + } + + this.bb!.writeInt32(this.bb_pos + offset, value); + return true; +} + +enum_():class_ { + const offset = this.bb!.__offset(this.bb_pos, 10); + return offset ? this.bb!.readInt32(this.bb_pos + offset) : class_.new_; +} + +mutate_enum(value:class_):boolean { + const offset = this.bb!.__offset(this.bb_pos, 10); + + if (offset === 0) { + return false; + } + + this.bb!.writeInt32(this.bb_pos + offset, value); + return true; +} + +enum2():foobar_class_ { + const offset = this.bb!.__offset(this.bb_pos, 12); + return offset ? this.bb!.readInt32(this.bb_pos + offset) : foobar_class_.arguments_; +} + +mutate_enum2(value:foobar_class_):boolean { + const offset = this.bb!.__offset(this.bb_pos, 12); + + if (offset === 0) { + return false; + } + + this.bb!.writeInt32(this.bb_pos + offset, value); + return true; +} + +enum3():Abc { + const offset = this.bb!.__offset(this.bb_pos, 14); + return offset ? this.bb!.readInt32(this.bb_pos + offset) : Abc.a; +} + +mutate_enum3(value:Abc):boolean { + const offset = this.bb!.__offset(this.bb_pos, 14); + + if (offset === 0) { + return false; + } + + this.bb!.writeInt32(this.bb_pos + offset, value); + return true; +} + +reflect(obj?:Schema):Schema|null { + const offset = this.bb!.__offset(this.bb_pos, 16); + return offset ? (obj || new Schema()).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null; +} + +static getFullyQualifiedName():string { + return 'typescript_Object'; +} + +static startObject(builder:flatbuffers.Builder) { + builder.startObject(7); +} + +static addReturn(builder:flatbuffers.Builder, return_:number) { + builder.addFieldInt32(0, return_, 0); +} + +static addIf(builder:flatbuffers.Builder, if_:number) { + builder.addFieldInt32(1, if_, 0); +} + +static addSwitch(builder:flatbuffers.Builder, switch_:number) { + builder.addFieldInt32(2, switch_, 0); +} + +static addEnum(builder:flatbuffers.Builder, enum_:class_) { + builder.addFieldInt32(3, enum_, class_.new_); +} + +static addEnum2(builder:flatbuffers.Builder, enum2:foobar_class_) { + builder.addFieldInt32(4, enum2, foobar_class_.arguments_); +} + +static addEnum3(builder:flatbuffers.Builder, enum3:Abc) { + builder.addFieldInt32(5, enum3, Abc.a); +} + +static addReflect(builder:flatbuffers.Builder, reflectOffset:flatbuffers.Offset) { + builder.addFieldOffset(6, reflectOffset, 0); +} + +static endObject(builder:flatbuffers.Builder):flatbuffers.Offset { + const offset = builder.endObject(); + return offset; +} + + +unpack(): Object_T { + return new Object_T( + this.return_(), + this.if_(), + this.switch_(), + this.enum_(), + this.enum2(), + this.enum3(), + (this.reflect() !== null ? this.reflect()!.unpack() : null) + ); +} + + +unpackTo(_o: Object_T): void { + _o.return_ = this.return_(); + _o.if_ = this.if_(); + _o.switch_ = this.switch_(); + _o.enum_ = this.enum_(); + _o.enum2 = this.enum2(); + _o.enum3 = this.enum3(); + _o.reflect = (this.reflect() !== null ? this.reflect()!.unpack() : null); +} +} + +export class Object_T { +constructor( + public return_: number = 0, + public if_: number = 0, + public switch_: number = 0, + public enum_: class_ = class_.new_, + public enum2: foobar_class_ = foobar_class_.arguments_, + public enum3: Abc = Abc.a, + public reflect: SchemaT|null = null +){} + + +pack(builder:flatbuffers.Builder): flatbuffers.Offset { + const reflect = (this.reflect !== null ? this.reflect!.pack(builder) : 0); + + Object_.startObject(builder); + Object_.addReturn(builder, this.return_); + Object_.addIf(builder, this.if_); + Object_.addSwitch(builder, this.switch_); + Object_.addEnum(builder, this.enum_); + Object_.addEnum2(builder, this.enum2); + Object_.addEnum3(builder, this.enum3); + Object_.addReflect(builder, reflect); + + return Object_.endObject(builder); +} +} + diff --git a/tests/ts/typescript_transitive_include_generated.js b/tests/ts/typescript_transitive_include_generated.js new file mode 100644 index 00000000000..cdef988d941 --- /dev/null +++ b/tests/ts/typescript_transitive_include_generated.js @@ -0,0 +1,5 @@ +// automatically generated by the FlatBuffers compiler, do not modify +export var Abc; +(function (Abc) { + Abc[Abc["a"] = 0] = "a"; +})(Abc || (Abc = {})); diff --git a/tests/ts/typescript_transitive_include_generated.ts b/tests/ts/typescript_transitive_include_generated.ts new file mode 100644 index 00000000000..6bb16014826 --- /dev/null +++ b/tests/ts/typescript_transitive_include_generated.ts @@ -0,0 +1,7 @@ +// automatically generated by the FlatBuffers compiler, do not modify + + +export enum Abc { + a = 0 +} + diff --git a/tests/ts/unicode_test.mon b/tests/ts/unicode_test.mon new file mode 100644 index 00000000000..14f5fb4d266 Binary files /dev/null and b/tests/ts/unicode_test.mon differ diff --git a/tests/ts/union_vector/attacker.js b/tests/ts/union_vector/attacker.js new file mode 100644 index 00000000000..32be94e2cbd --- /dev/null +++ b/tests/ts/union_vector/attacker.js @@ -0,0 +1,64 @@ +// automatically generated by the FlatBuffers compiler, do not modify +import * as flatbuffers from 'flatbuffers'; +export class Attacker { + constructor() { + this.bb = null; + this.bb_pos = 0; + } + __init(i, bb) { + this.bb_pos = i; + this.bb = bb; + return this; + } + static getRootAsAttacker(bb, obj) { + return (obj || new Attacker()).__init(bb.readInt32(bb.position()) + bb.position(), bb); + } + static getSizePrefixedRootAsAttacker(bb, obj) { + bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); + return (obj || new Attacker()).__init(bb.readInt32(bb.position()) + bb.position(), bb); + } + swordAttackDamage() { + const offset = this.bb.__offset(this.bb_pos, 4); + return offset ? this.bb.readInt32(this.bb_pos + offset) : 0; + } + mutate_sword_attack_damage(value) { + const offset = this.bb.__offset(this.bb_pos, 4); + if (offset === 0) { + return false; + } + this.bb.writeInt32(this.bb_pos + offset, value); + return true; + } + static getFullyQualifiedName() { + return 'Attacker'; + } + static startAttacker(builder) { + builder.startObject(1); + } + static addSwordAttackDamage(builder, swordAttackDamage) { + builder.addFieldInt32(0, swordAttackDamage, 0); + } + static endAttacker(builder) { + const offset = builder.endObject(); + return offset; + } + static createAttacker(builder, swordAttackDamage) { + Attacker.startAttacker(builder); + Attacker.addSwordAttackDamage(builder, swordAttackDamage); + return Attacker.endAttacker(builder); + } + unpack() { + return new AttackerT(this.swordAttackDamage()); + } + unpackTo(_o) { + _o.swordAttackDamage = this.swordAttackDamage(); + } +} +export class AttackerT { + constructor(swordAttackDamage = 0) { + this.swordAttackDamage = swordAttackDamage; + } + pack(builder) { + return Attacker.createAttacker(builder, this.swordAttackDamage); + } +} diff --git a/tests/ts/union_vector/attacker.ts b/tests/ts/union_vector/attacker.ts new file mode 100644 index 00000000000..6b3fc0fc140 --- /dev/null +++ b/tests/ts/union_vector/attacker.ts @@ -0,0 +1,87 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +import * as flatbuffers from 'flatbuffers'; + + + +export class Attacker { + bb: flatbuffers.ByteBuffer|null = null; + bb_pos = 0; + __init(i:number, bb:flatbuffers.ByteBuffer):Attacker { + this.bb_pos = i; + this.bb = bb; + return this; +} + +static getRootAsAttacker(bb:flatbuffers.ByteBuffer, obj?:Attacker):Attacker { + return (obj || new Attacker()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +static getSizePrefixedRootAsAttacker(bb:flatbuffers.ByteBuffer, obj?:Attacker):Attacker { + bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); + return (obj || new Attacker()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +swordAttackDamage():number { + const offset = this.bb!.__offset(this.bb_pos, 4); + return offset ? this.bb!.readInt32(this.bb_pos + offset) : 0; +} + +mutate_sword_attack_damage(value:number):boolean { + const offset = this.bb!.__offset(this.bb_pos, 4); + + if (offset === 0) { + return false; + } + + this.bb!.writeInt32(this.bb_pos + offset, value); + return true; +} + +static getFullyQualifiedName():string { + return 'Attacker'; +} + +static startAttacker(builder:flatbuffers.Builder) { + builder.startObject(1); +} + +static addSwordAttackDamage(builder:flatbuffers.Builder, swordAttackDamage:number) { + builder.addFieldInt32(0, swordAttackDamage, 0); +} + +static endAttacker(builder:flatbuffers.Builder):flatbuffers.Offset { + const offset = builder.endObject(); + return offset; +} + +static createAttacker(builder:flatbuffers.Builder, swordAttackDamage:number):flatbuffers.Offset { + Attacker.startAttacker(builder); + Attacker.addSwordAttackDamage(builder, swordAttackDamage); + return Attacker.endAttacker(builder); +} + +unpack(): AttackerT { + return new AttackerT( + this.swordAttackDamage() + ); +} + + +unpackTo(_o: AttackerT): void { + _o.swordAttackDamage = this.swordAttackDamage(); +} +} + +export class AttackerT { +constructor( + public swordAttackDamage: number = 0 +){} + + +pack(builder:flatbuffers.Builder): flatbuffers.Offset { + return Attacker.createAttacker(builder, + this.swordAttackDamage + ); +} +} diff --git a/tests/ts/union_vector/book-reader.js b/tests/ts/union_vector/book-reader.js new file mode 100644 index 00000000000..0d9e1a57cd4 --- /dev/null +++ b/tests/ts/union_vector/book-reader.js @@ -0,0 +1,44 @@ +// automatically generated by the FlatBuffers compiler, do not modify +export class BookReader { + constructor() { + this.bb = null; + this.bb_pos = 0; + } + __init(i, bb) { + this.bb_pos = i; + this.bb = bb; + return this; + } + booksRead() { + return this.bb.readInt32(this.bb_pos); + } + mutate_books_read(value) { + this.bb.writeInt32(this.bb_pos + 0, value); + return true; + } + static getFullyQualifiedName() { + return 'BookReader'; + } + static sizeOf() { + return 4; + } + static createBookReader(builder, books_read) { + builder.prep(4, 4); + builder.writeInt32(books_read); + return builder.offset(); + } + unpack() { + return new BookReaderT(this.booksRead()); + } + unpackTo(_o) { + _o.booksRead = this.booksRead(); + } +} +export class BookReaderT { + constructor(booksRead = 0) { + this.booksRead = booksRead; + } + pack(builder) { + return BookReader.createBookReader(builder, this.booksRead); + } +} diff --git a/tests/ts/union_vector/book-reader.ts b/tests/ts/union_vector/book-reader.ts new file mode 100644 index 00000000000..7a31278125a --- /dev/null +++ b/tests/ts/union_vector/book-reader.ts @@ -0,0 +1,63 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +import * as flatbuffers from 'flatbuffers'; + + + +export class BookReader { + bb: flatbuffers.ByteBuffer|null = null; + bb_pos = 0; + __init(i:number, bb:flatbuffers.ByteBuffer):BookReader { + this.bb_pos = i; + this.bb = bb; + return this; +} + +booksRead():number { + return this.bb!.readInt32(this.bb_pos); +} + +mutate_books_read(value:number):boolean { + this.bb!.writeInt32(this.bb_pos + 0, value); + return true; +} + +static getFullyQualifiedName():string { + return 'BookReader'; +} + +static sizeOf():number { + return 4; +} + +static createBookReader(builder:flatbuffers.Builder, books_read: number):flatbuffers.Offset { + builder.prep(4, 4); + builder.writeInt32(books_read); + return builder.offset(); +} + + +unpack(): BookReaderT { + return new BookReaderT( + this.booksRead() + ); +} + + +unpackTo(_o: BookReaderT): void { + _o.booksRead = this.booksRead(); +} +} + +export class BookReaderT { +constructor( + public booksRead: number = 0 +){} + + +pack(builder:flatbuffers.Builder): flatbuffers.Offset { + return BookReader.createBookReader(builder, + this.booksRead + ); +} +} diff --git a/tests/ts/union_vector/character.js b/tests/ts/union_vector/character.js new file mode 100644 index 00000000000..04e3294ccd9 --- /dev/null +++ b/tests/ts/union_vector/character.js @@ -0,0 +1,38 @@ +// automatically generated by the FlatBuffers compiler, do not modify +import { Attacker } from './attacker.js'; +import { BookReader } from './book-reader.js'; +import { Rapunzel } from './rapunzel.js'; +export var Character; +(function (Character) { + Character[Character["NONE"] = 0] = "NONE"; + Character[Character["MuLan"] = 1] = "MuLan"; + Character[Character["Rapunzel"] = 2] = "Rapunzel"; + Character[Character["Belle"] = 3] = "Belle"; + Character[Character["BookFan"] = 4] = "BookFan"; + Character[Character["Other"] = 5] = "Other"; + Character[Character["Unused"] = 6] = "Unused"; +})(Character || (Character = {})); +export function unionToCharacter(type, accessor) { + switch (Character[type]) { + case 'NONE': return null; + case 'MuLan': return accessor(new Attacker()); + case 'Rapunzel': return accessor(new Rapunzel()); + case 'Belle': return accessor(new BookReader()); + case 'BookFan': return accessor(new BookReader()); + case 'Other': return accessor(''); + case 'Unused': return accessor(''); + default: return null; + } +} +export function unionListToCharacter(type, accessor, index) { + switch (Character[type]) { + case 'NONE': return null; + case 'MuLan': return accessor(index, new Attacker()); + case 'Rapunzel': return accessor(index, new Rapunzel()); + case 'Belle': return accessor(index, new BookReader()); + case 'BookFan': return accessor(index, new BookReader()); + case 'Other': return accessor(index, ''); + case 'Unused': return accessor(index, ''); + default: return null; + } +} diff --git a/tests/ts/union_vector/character.ts b/tests/ts/union_vector/character.ts new file mode 100644 index 00000000000..ddad8758a7d --- /dev/null +++ b/tests/ts/union_vector/character.ts @@ -0,0 +1,49 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +import { Attacker, AttackerT } from './attacker.js'; +import { BookReader, BookReaderT } from './book-reader.js'; +import { Rapunzel, RapunzelT } from './rapunzel.js'; + + +export enum Character { + NONE = 0, + MuLan = 1, + Rapunzel = 2, + Belle = 3, + BookFan = 4, + Other = 5, + Unused = 6 +} + +export function unionToCharacter( + type: Character, + accessor: (obj:Attacker|BookReader|Rapunzel|string) => Attacker|BookReader|Rapunzel|string|null +): Attacker|BookReader|Rapunzel|string|null { + switch(Character[type]) { + case 'NONE': return null; + case 'MuLan': return accessor(new Attacker())! as Attacker; + case 'Rapunzel': return accessor(new Rapunzel())! as Rapunzel; + case 'Belle': return accessor(new BookReader())! as BookReader; + case 'BookFan': return accessor(new BookReader())! as BookReader; + case 'Other': return accessor('') as string; + case 'Unused': return accessor('') as string; + default: return null; + } +} + +export function unionListToCharacter( + type: Character, + accessor: (index: number, obj:Attacker|BookReader|Rapunzel|string) => Attacker|BookReader|Rapunzel|string|null, + index: number +): Attacker|BookReader|Rapunzel|string|null { + switch(Character[type]) { + case 'NONE': return null; + case 'MuLan': return accessor(index, new Attacker())! as Attacker; + case 'Rapunzel': return accessor(index, new Rapunzel())! as Rapunzel; + case 'Belle': return accessor(index, new BookReader())! as BookReader; + case 'BookFan': return accessor(index, new BookReader())! as BookReader; + case 'Other': return accessor(index, '') as string; + case 'Unused': return accessor(index, '') as string; + default: return null; + } +} diff --git a/tests/ts/union_vector/falling-tub.js b/tests/ts/union_vector/falling-tub.js new file mode 100644 index 00000000000..d3c4dfe05af --- /dev/null +++ b/tests/ts/union_vector/falling-tub.js @@ -0,0 +1,44 @@ +// automatically generated by the FlatBuffers compiler, do not modify +export class FallingTub { + constructor() { + this.bb = null; + this.bb_pos = 0; + } + __init(i, bb) { + this.bb_pos = i; + this.bb = bb; + return this; + } + weight() { + return this.bb.readInt32(this.bb_pos); + } + mutate_weight(value) { + this.bb.writeInt32(this.bb_pos + 0, value); + return true; + } + static getFullyQualifiedName() { + return 'FallingTub'; + } + static sizeOf() { + return 4; + } + static createFallingTub(builder, weight) { + builder.prep(4, 4); + builder.writeInt32(weight); + return builder.offset(); + } + unpack() { + return new FallingTubT(this.weight()); + } + unpackTo(_o) { + _o.weight = this.weight(); + } +} +export class FallingTubT { + constructor(weight = 0) { + this.weight = weight; + } + pack(builder) { + return FallingTub.createFallingTub(builder, this.weight); + } +} diff --git a/tests/ts/union_vector/falling-tub.ts b/tests/ts/union_vector/falling-tub.ts new file mode 100644 index 00000000000..b32f99d0ff4 --- /dev/null +++ b/tests/ts/union_vector/falling-tub.ts @@ -0,0 +1,63 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +import * as flatbuffers from 'flatbuffers'; + + + +export class FallingTub { + bb: flatbuffers.ByteBuffer|null = null; + bb_pos = 0; + __init(i:number, bb:flatbuffers.ByteBuffer):FallingTub { + this.bb_pos = i; + this.bb = bb; + return this; +} + +weight():number { + return this.bb!.readInt32(this.bb_pos); +} + +mutate_weight(value:number):boolean { + this.bb!.writeInt32(this.bb_pos + 0, value); + return true; +} + +static getFullyQualifiedName():string { + return 'FallingTub'; +} + +static sizeOf():number { + return 4; +} + +static createFallingTub(builder:flatbuffers.Builder, weight: number):flatbuffers.Offset { + builder.prep(4, 4); + builder.writeInt32(weight); + return builder.offset(); +} + + +unpack(): FallingTubT { + return new FallingTubT( + this.weight() + ); +} + + +unpackTo(_o: FallingTubT): void { + _o.weight = this.weight(); +} +} + +export class FallingTubT { +constructor( + public weight: number = 0 +){} + + +pack(builder:flatbuffers.Builder): flatbuffers.Offset { + return FallingTub.createFallingTub(builder, + this.weight + ); +} +} diff --git a/tests/ts/union_vector/gadget.js b/tests/ts/union_vector/gadget.js new file mode 100644 index 00000000000..202a214b5d1 --- /dev/null +++ b/tests/ts/union_vector/gadget.js @@ -0,0 +1,25 @@ +// automatically generated by the FlatBuffers compiler, do not modify +import { FallingTub } from './falling-tub.js'; +import { HandFan } from './hand-fan.js'; +export var Gadget; +(function (Gadget) { + Gadget[Gadget["NONE"] = 0] = "NONE"; + Gadget[Gadget["FallingTub"] = 1] = "FallingTub"; + Gadget[Gadget["HandFan"] = 2] = "HandFan"; +})(Gadget || (Gadget = {})); +export function unionToGadget(type, accessor) { + switch (Gadget[type]) { + case 'NONE': return null; + case 'FallingTub': return accessor(new FallingTub()); + case 'HandFan': return accessor(new HandFan()); + default: return null; + } +} +export function unionListToGadget(type, accessor, index) { + switch (Gadget[type]) { + case 'NONE': return null; + case 'FallingTub': return accessor(index, new FallingTub()); + case 'HandFan': return accessor(index, new HandFan()); + default: return null; + } +} diff --git a/tests/ts/union_vector/gadget.ts b/tests/ts/union_vector/gadget.ts new file mode 100644 index 00000000000..b6e117bccd1 --- /dev/null +++ b/tests/ts/union_vector/gadget.ts @@ -0,0 +1,36 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +import { FallingTub, FallingTubT } from './falling-tub.js'; +import { HandFan, HandFanT } from './hand-fan.js'; + + +export enum Gadget { + NONE = 0, + FallingTub = 1, + HandFan = 2 +} + +export function unionToGadget( + type: Gadget, + accessor: (obj:FallingTub|HandFan) => FallingTub|HandFan|null +): FallingTub|HandFan|null { + switch(Gadget[type]) { + case 'NONE': return null; + case 'FallingTub': return accessor(new FallingTub())! as FallingTub; + case 'HandFan': return accessor(new HandFan())! as HandFan; + default: return null; + } +} + +export function unionListToGadget( + type: Gadget, + accessor: (index: number, obj:FallingTub|HandFan) => FallingTub|HandFan|null, + index: number +): FallingTub|HandFan|null { + switch(Gadget[type]) { + case 'NONE': return null; + case 'FallingTub': return accessor(index, new FallingTub())! as FallingTub; + case 'HandFan': return accessor(index, new HandFan())! as HandFan; + default: return null; + } +} diff --git a/tests/ts/union_vector/hand-fan.js b/tests/ts/union_vector/hand-fan.js new file mode 100644 index 00000000000..21decca26f5 --- /dev/null +++ b/tests/ts/union_vector/hand-fan.js @@ -0,0 +1,64 @@ +// automatically generated by the FlatBuffers compiler, do not modify +import * as flatbuffers from 'flatbuffers'; +export class HandFan { + constructor() { + this.bb = null; + this.bb_pos = 0; + } + __init(i, bb) { + this.bb_pos = i; + this.bb = bb; + return this; + } + static getRootAsHandFan(bb, obj) { + return (obj || new HandFan()).__init(bb.readInt32(bb.position()) + bb.position(), bb); + } + static getSizePrefixedRootAsHandFan(bb, obj) { + bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); + return (obj || new HandFan()).__init(bb.readInt32(bb.position()) + bb.position(), bb); + } + length() { + const offset = this.bb.__offset(this.bb_pos, 4); + return offset ? this.bb.readInt32(this.bb_pos + offset) : 0; + } + mutate_length(value) { + const offset = this.bb.__offset(this.bb_pos, 4); + if (offset === 0) { + return false; + } + this.bb.writeInt32(this.bb_pos + offset, value); + return true; + } + static getFullyQualifiedName() { + return 'HandFan'; + } + static startHandFan(builder) { + builder.startObject(1); + } + static addLength(builder, length) { + builder.addFieldInt32(0, length, 0); + } + static endHandFan(builder) { + const offset = builder.endObject(); + return offset; + } + static createHandFan(builder, length) { + HandFan.startHandFan(builder); + HandFan.addLength(builder, length); + return HandFan.endHandFan(builder); + } + unpack() { + return new HandFanT(this.length()); + } + unpackTo(_o) { + _o.length = this.length(); + } +} +export class HandFanT { + constructor(length = 0) { + this.length = length; + } + pack(builder) { + return HandFan.createHandFan(builder, this.length); + } +} diff --git a/tests/ts/union_vector/hand-fan.ts b/tests/ts/union_vector/hand-fan.ts new file mode 100644 index 00000000000..f90b4dd3195 --- /dev/null +++ b/tests/ts/union_vector/hand-fan.ts @@ -0,0 +1,87 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +import * as flatbuffers from 'flatbuffers'; + + + +export class HandFan { + bb: flatbuffers.ByteBuffer|null = null; + bb_pos = 0; + __init(i:number, bb:flatbuffers.ByteBuffer):HandFan { + this.bb_pos = i; + this.bb = bb; + return this; +} + +static getRootAsHandFan(bb:flatbuffers.ByteBuffer, obj?:HandFan):HandFan { + return (obj || new HandFan()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +static getSizePrefixedRootAsHandFan(bb:flatbuffers.ByteBuffer, obj?:HandFan):HandFan { + bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); + return (obj || new HandFan()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +length():number { + const offset = this.bb!.__offset(this.bb_pos, 4); + return offset ? this.bb!.readInt32(this.bb_pos + offset) : 0; +} + +mutate_length(value:number):boolean { + const offset = this.bb!.__offset(this.bb_pos, 4); + + if (offset === 0) { + return false; + } + + this.bb!.writeInt32(this.bb_pos + offset, value); + return true; +} + +static getFullyQualifiedName():string { + return 'HandFan'; +} + +static startHandFan(builder:flatbuffers.Builder) { + builder.startObject(1); +} + +static addLength(builder:flatbuffers.Builder, length:number) { + builder.addFieldInt32(0, length, 0); +} + +static endHandFan(builder:flatbuffers.Builder):flatbuffers.Offset { + const offset = builder.endObject(); + return offset; +} + +static createHandFan(builder:flatbuffers.Builder, length:number):flatbuffers.Offset { + HandFan.startHandFan(builder); + HandFan.addLength(builder, length); + return HandFan.endHandFan(builder); +} + +unpack(): HandFanT { + return new HandFanT( + this.length() + ); +} + + +unpackTo(_o: HandFanT): void { + _o.length = this.length(); +} +} + +export class HandFanT { +constructor( + public length: number = 0 +){} + + +pack(builder:flatbuffers.Builder): flatbuffers.Offset { + return HandFan.createHandFan(builder, + this.length + ); +} +} diff --git a/tests/ts/union_vector/movie.js b/tests/ts/union_vector/movie.js new file mode 100644 index 00000000000..0245a43844f --- /dev/null +++ b/tests/ts/union_vector/movie.js @@ -0,0 +1,185 @@ +// automatically generated by the FlatBuffers compiler, do not modify +import * as flatbuffers from 'flatbuffers'; +import { Character, unionToCharacter, unionListToCharacter } from './character.js'; +export class Movie { + constructor() { + this.bb = null; + this.bb_pos = 0; + } + __init(i, bb) { + this.bb_pos = i; + this.bb = bb; + return this; + } + static getRootAsMovie(bb, obj) { + return (obj || new Movie()).__init(bb.readInt32(bb.position()) + bb.position(), bb); + } + static getSizePrefixedRootAsMovie(bb, obj) { + bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); + return (obj || new Movie()).__init(bb.readInt32(bb.position()) + bb.position(), bb); + } + static bufferHasIdentifier(bb) { + return bb.__has_identifier('MOVI'); + } + mainCharacterType() { + const offset = this.bb.__offset(this.bb_pos, 4); + return offset ? this.bb.readUint8(this.bb_pos + offset) : Character.NONE; + } + mainCharacter(obj) { + const offset = this.bb.__offset(this.bb_pos, 6); + return offset ? this.bb.__union_with_string(obj, this.bb_pos + offset) : null; + } + charactersType(index) { + const offset = this.bb.__offset(this.bb_pos, 8); + return offset ? this.bb.readUint8(this.bb.__vector(this.bb_pos + offset) + index) : 0; + } + charactersTypeLength() { + const offset = this.bb.__offset(this.bb_pos, 8); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; + } + charactersTypeArray() { + const offset = this.bb.__offset(this.bb_pos, 8); + return offset ? new Uint8Array(this.bb.bytes().buffer, this.bb.bytes().byteOffset + this.bb.__vector(this.bb_pos + offset), this.bb.__vector_len(this.bb_pos + offset)) : null; + } + characters(index, obj) { + const offset = this.bb.__offset(this.bb_pos, 10); + return offset ? this.bb.__union_with_string(obj, this.bb.__vector(this.bb_pos + offset) + index * 4) : null; + } + charactersLength() { + const offset = this.bb.__offset(this.bb_pos, 10); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; + } + static getFullyQualifiedName() { + return 'Movie'; + } + static startMovie(builder) { + builder.startObject(4); + } + static addMainCharacterType(builder, mainCharacterType) { + builder.addFieldInt8(0, mainCharacterType, Character.NONE); + } + static addMainCharacter(builder, mainCharacterOffset) { + builder.addFieldOffset(1, mainCharacterOffset, 0); + } + static addCharactersType(builder, charactersTypeOffset) { + builder.addFieldOffset(2, charactersTypeOffset, 0); + } + static createCharactersTypeVector(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 startCharactersTypeVector(builder, numElems) { + builder.startVector(1, numElems, 1); + } + static addCharacters(builder, charactersOffset) { + builder.addFieldOffset(3, charactersOffset, 0); + } + static createCharactersVector(builder, data) { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addOffset(data[i]); + } + return builder.endVector(); + } + static startCharactersVector(builder, numElems) { + builder.startVector(4, numElems, 4); + } + static endMovie(builder) { + const offset = builder.endObject(); + return offset; + } + static finishMovieBuffer(builder, offset) { + builder.finish(offset, 'MOVI'); + } + static finishSizePrefixedMovieBuffer(builder, offset) { + builder.finish(offset, 'MOVI', true); + } + static createMovie(builder, mainCharacterType, mainCharacterOffset, charactersTypeOffset, charactersOffset) { + Movie.startMovie(builder); + Movie.addMainCharacterType(builder, mainCharacterType); + Movie.addMainCharacter(builder, mainCharacterOffset); + Movie.addCharactersType(builder, charactersTypeOffset); + Movie.addCharacters(builder, charactersOffset); + return Movie.endMovie(builder); + } + unpack() { + return new MovieT(this.mainCharacterType(), (() => { + let temp = unionToCharacter(this.mainCharacterType(), this.mainCharacter.bind(this)); + if (temp === null) { + return null; + } + if (typeof temp === 'string') { + return temp; + } + return temp.unpack(); + })(), this.bb.createScalarList(this.charactersType.bind(this), this.charactersTypeLength()), (() => { + let ret = []; + for (let targetEnumIndex = 0; targetEnumIndex < this.charactersTypeLength(); ++targetEnumIndex) { + let targetEnum = this.charactersType(targetEnumIndex); + if (targetEnum === null || Character[targetEnum] === 'NONE') { + continue; + } + let temp = unionListToCharacter(targetEnum, this.characters.bind(this), targetEnumIndex); + if (temp === null) { + continue; + } + if (typeof temp === 'string') { + ret.push(temp); + continue; + } + ret.push(temp.unpack()); + } + return ret; + })()); + } + unpackTo(_o) { + _o.mainCharacterType = this.mainCharacterType(); + _o.mainCharacter = (() => { + let temp = unionToCharacter(this.mainCharacterType(), this.mainCharacter.bind(this)); + if (temp === null) { + return null; + } + if (typeof temp === 'string') { + return temp; + } + return temp.unpack(); + })(); + _o.charactersType = this.bb.createScalarList(this.charactersType.bind(this), this.charactersTypeLength()); + _o.characters = (() => { + let ret = []; + for (let targetEnumIndex = 0; targetEnumIndex < this.charactersTypeLength(); ++targetEnumIndex) { + let targetEnum = this.charactersType(targetEnumIndex); + if (targetEnum === null || Character[targetEnum] === 'NONE') { + continue; + } + let temp = unionListToCharacter(targetEnum, this.characters.bind(this), targetEnumIndex); + if (temp === null) { + continue; + } + if (typeof temp === 'string') { + ret.push(temp); + continue; + } + ret.push(temp.unpack()); + } + return ret; + })(); + } +} +export class MovieT { + constructor(mainCharacterType = Character.NONE, mainCharacter = null, charactersType = [], characters = []) { + this.mainCharacterType = mainCharacterType; + this.mainCharacter = mainCharacter; + this.charactersType = charactersType; + this.characters = characters; + } + pack(builder) { + const mainCharacter = builder.createObjectOffset(this.mainCharacter); + const charactersType = Movie.createCharactersTypeVector(builder, this.charactersType); + const characters = Movie.createCharactersVector(builder, builder.createObjectOffsetList(this.characters)); + return Movie.createMovie(builder, this.mainCharacterType, mainCharacter, charactersType, characters); + } +} diff --git a/tests/ts/union_vector/movie.ts b/tests/ts/union_vector/movie.ts new file mode 100644 index 00000000000..6edeb53cbe4 --- /dev/null +++ b/tests/ts/union_vector/movie.ts @@ -0,0 +1,211 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +import * as flatbuffers from 'flatbuffers'; + +import { Attacker, AttackerT } from './attacker.js'; +import { BookReader, BookReaderT } from './book-reader.js'; +import { Character, unionToCharacter, unionListToCharacter } from './character.js'; +import { Rapunzel, RapunzelT } from './rapunzel.js'; + + +export class Movie { + bb: flatbuffers.ByteBuffer|null = null; + bb_pos = 0; + __init(i:number, bb:flatbuffers.ByteBuffer):Movie { + this.bb_pos = i; + this.bb = bb; + return this; +} + +static getRootAsMovie(bb:flatbuffers.ByteBuffer, obj?:Movie):Movie { + return (obj || new Movie()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +static getSizePrefixedRootAsMovie(bb:flatbuffers.ByteBuffer, obj?:Movie):Movie { + bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); + return (obj || new Movie()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +static bufferHasIdentifier(bb:flatbuffers.ByteBuffer):boolean { + return bb.__has_identifier('MOVI'); +} + +mainCharacterType():Character { + const offset = this.bb!.__offset(this.bb_pos, 4); + return offset ? this.bb!.readUint8(this.bb_pos + offset) : Character.NONE; +} + +mainCharacter(obj:any|string):any|string|null { + const offset = this.bb!.__offset(this.bb_pos, 6); + return offset ? this.bb!.__union_with_string(obj, this.bb_pos + offset) : null; +} + +charactersType(index: number):Character|null { + const offset = this.bb!.__offset(this.bb_pos, 8); + return offset ? this.bb!.readUint8(this.bb!.__vector(this.bb_pos + offset) + index) : 0; +} + +charactersTypeLength():number { + const offset = this.bb!.__offset(this.bb_pos, 8); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +} + +charactersTypeArray():Uint8Array|null { + const offset = this.bb!.__offset(this.bb_pos, 8); + return offset ? new Uint8Array(this.bb!.bytes().buffer, this.bb!.bytes().byteOffset + this.bb!.__vector(this.bb_pos + offset), this.bb!.__vector_len(this.bb_pos + offset)) : null; +} + +characters(index: number, obj:any|string):any|string|null { + const offset = this.bb!.__offset(this.bb_pos, 10); + return offset ? this.bb!.__union_with_string(obj, this.bb!.__vector(this.bb_pos + offset) + index * 4) : null; +} + +charactersLength():number { + const offset = this.bb!.__offset(this.bb_pos, 10); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +} + +static getFullyQualifiedName():string { + return 'Movie'; +} + +static startMovie(builder:flatbuffers.Builder) { + builder.startObject(4); +} + +static addMainCharacterType(builder:flatbuffers.Builder, mainCharacterType:Character) { + builder.addFieldInt8(0, mainCharacterType, Character.NONE); +} + +static addMainCharacter(builder:flatbuffers.Builder, mainCharacterOffset:flatbuffers.Offset) { + builder.addFieldOffset(1, mainCharacterOffset, 0); +} + +static addCharactersType(builder:flatbuffers.Builder, charactersTypeOffset:flatbuffers.Offset) { + builder.addFieldOffset(2, charactersTypeOffset, 0); +} + +static createCharactersTypeVector(builder:flatbuffers.Builder, data:Character[]):flatbuffers.Offset { + builder.startVector(1, data.length, 1); + for (let i = data.length - 1; i >= 0; i--) { + builder.addInt8(data[i]!); + } + return builder.endVector(); +} + +static startCharactersTypeVector(builder:flatbuffers.Builder, numElems:number) { + builder.startVector(1, numElems, 1); +} + +static addCharacters(builder:flatbuffers.Builder, charactersOffset:flatbuffers.Offset) { + builder.addFieldOffset(3, charactersOffset, 0); +} + +static createCharactersVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addOffset(data[i]!); + } + return builder.endVector(); +} + +static startCharactersVector(builder:flatbuffers.Builder, numElems:number) { + builder.startVector(4, numElems, 4); +} + +static endMovie(builder:flatbuffers.Builder):flatbuffers.Offset { + const offset = builder.endObject(); + return offset; +} + +static finishMovieBuffer(builder:flatbuffers.Builder, offset:flatbuffers.Offset) { + builder.finish(offset, 'MOVI'); +} + +static finishSizePrefixedMovieBuffer(builder:flatbuffers.Builder, offset:flatbuffers.Offset) { + builder.finish(offset, 'MOVI', true); +} + +static createMovie(builder:flatbuffers.Builder, mainCharacterType:Character, mainCharacterOffset:flatbuffers.Offset, charactersTypeOffset:flatbuffers.Offset, charactersOffset:flatbuffers.Offset):flatbuffers.Offset { + Movie.startMovie(builder); + Movie.addMainCharacterType(builder, mainCharacterType); + Movie.addMainCharacter(builder, mainCharacterOffset); + Movie.addCharactersType(builder, charactersTypeOffset); + Movie.addCharacters(builder, charactersOffset); + return Movie.endMovie(builder); +} + +unpack(): MovieT { + return new MovieT( + this.mainCharacterType(), + (() => { + let temp = unionToCharacter(this.mainCharacterType(), this.mainCharacter.bind(this)); + if(temp === null) { return null; } + if(typeof temp === 'string') { return temp; } + return temp.unpack() + })(), + this.bb!.createScalarList(this.charactersType.bind(this), this.charactersTypeLength()), + (() => { + let ret = []; + for(let targetEnumIndex = 0; targetEnumIndex < this.charactersTypeLength(); ++targetEnumIndex) { + let targetEnum = this.charactersType(targetEnumIndex); + if(targetEnum === null || Character[targetEnum!] === 'NONE') { continue; } + + let temp = unionListToCharacter(targetEnum, this.characters.bind(this), targetEnumIndex); + if(temp === null) { continue; } + if(typeof temp === 'string') { ret.push(temp); continue; } + ret.push(temp.unpack()); + } + return ret; + })() + ); +} + + +unpackTo(_o: MovieT): void { + _o.mainCharacterType = this.mainCharacterType(); + _o.mainCharacter = (() => { + let temp = unionToCharacter(this.mainCharacterType(), this.mainCharacter.bind(this)); + if(temp === null) { return null; } + if(typeof temp === 'string') { return temp; } + return temp.unpack() + })(); + _o.charactersType = this.bb!.createScalarList(this.charactersType.bind(this), this.charactersTypeLength()); + _o.characters = (() => { + let ret = []; + for(let targetEnumIndex = 0; targetEnumIndex < this.charactersTypeLength(); ++targetEnumIndex) { + let targetEnum = this.charactersType(targetEnumIndex); + if(targetEnum === null || Character[targetEnum!] === 'NONE') { continue; } + + let temp = unionListToCharacter(targetEnum, this.characters.bind(this), targetEnumIndex); + if(temp === null) { continue; } + if(typeof temp === 'string') { ret.push(temp); continue; } + ret.push(temp.unpack()); + } + return ret; + })(); +} +} + +export class MovieT { +constructor( + public mainCharacterType: Character = Character.NONE, + public mainCharacter: AttackerT|BookReaderT|RapunzelT|string|null = null, + public charactersType: (Character)[] = [], + public characters: (AttackerT|BookReaderT|RapunzelT|string)[] = [] +){} + + +pack(builder:flatbuffers.Builder): flatbuffers.Offset { + const mainCharacter = builder.createObjectOffset(this.mainCharacter); + const charactersType = Movie.createCharactersTypeVector(builder, this.charactersType); + const characters = Movie.createCharactersVector(builder, builder.createObjectOffsetList(this.characters)); + + return Movie.createMovie(builder, + this.mainCharacterType, + mainCharacter, + charactersType, + characters + ); +} +} diff --git a/tests/ts/union_vector/rapunzel.js b/tests/ts/union_vector/rapunzel.js new file mode 100644 index 00000000000..67a5e4453b3 --- /dev/null +++ b/tests/ts/union_vector/rapunzel.js @@ -0,0 +1,44 @@ +// automatically generated by the FlatBuffers compiler, do not modify +export class Rapunzel { + constructor() { + this.bb = null; + this.bb_pos = 0; + } + __init(i, bb) { + this.bb_pos = i; + this.bb = bb; + return this; + } + hairLength() { + return this.bb.readInt32(this.bb_pos); + } + mutate_hair_length(value) { + this.bb.writeInt32(this.bb_pos + 0, value); + return true; + } + static getFullyQualifiedName() { + return 'Rapunzel'; + } + static sizeOf() { + return 4; + } + static createRapunzel(builder, hair_length) { + builder.prep(4, 4); + builder.writeInt32(hair_length); + return builder.offset(); + } + unpack() { + return new RapunzelT(this.hairLength()); + } + unpackTo(_o) { + _o.hairLength = this.hairLength(); + } +} +export class RapunzelT { + constructor(hairLength = 0) { + this.hairLength = hairLength; + } + pack(builder) { + return Rapunzel.createRapunzel(builder, this.hairLength); + } +} diff --git a/tests/ts/union_vector/rapunzel.ts b/tests/ts/union_vector/rapunzel.ts new file mode 100644 index 00000000000..e1dc63ddf54 --- /dev/null +++ b/tests/ts/union_vector/rapunzel.ts @@ -0,0 +1,63 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +import * as flatbuffers from 'flatbuffers'; + + + +export class Rapunzel { + bb: flatbuffers.ByteBuffer|null = null; + bb_pos = 0; + __init(i:number, bb:flatbuffers.ByteBuffer):Rapunzel { + this.bb_pos = i; + this.bb = bb; + return this; +} + +hairLength():number { + return this.bb!.readInt32(this.bb_pos); +} + +mutate_hair_length(value:number):boolean { + this.bb!.writeInt32(this.bb_pos + 0, value); + return true; +} + +static getFullyQualifiedName():string { + return 'Rapunzel'; +} + +static sizeOf():number { + return 4; +} + +static createRapunzel(builder:flatbuffers.Builder, hair_length: number):flatbuffers.Offset { + builder.prep(4, 4); + builder.writeInt32(hair_length); + return builder.offset(); +} + + +unpack(): RapunzelT { + return new RapunzelT( + this.hairLength() + ); +} + + +unpackTo(_o: RapunzelT): void { + _o.hairLength = this.hairLength(); +} +} + +export class RapunzelT { +constructor( + public hairLength: number = 0 +){} + + +pack(builder:flatbuffers.Builder): flatbuffers.Offset { + return Rapunzel.createRapunzel(builder, + this.hairLength + ); +} +} diff --git a/tests/ts/union_vector/union_vector_generated.js b/tests/ts/union_vector/union_vector_generated.js new file mode 100644 index 00000000000..69ea199096e --- /dev/null +++ b/tests/ts/union_vector/union_vector_generated.js @@ -0,0 +1,9 @@ +// automatically generated by the FlatBuffers compiler, do not modify +export { Attacker, AttackerT } from './attacker.js'; +export { BookReader, BookReaderT } from './book-reader.js'; +export { Character, unionToCharacter, unionListToCharacter } from './character.js'; +export { FallingTub, FallingTubT } from './falling-tub.js'; +export { Gadget, unionToGadget, unionListToGadget } from './gadget.js'; +export { HandFan, HandFanT } from './hand-fan.js'; +export { Movie, MovieT } from './movie.js'; +export { Rapunzel, RapunzelT } from './rapunzel.js'; diff --git a/tests/ts/union_vector/union_vector_generated.ts b/tests/ts/union_vector/union_vector_generated.ts new file mode 100644 index 00000000000..5527abe17d8 --- /dev/null +++ b/tests/ts/union_vector/union_vector_generated.ts @@ -0,0 +1,10 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +export { Attacker, AttackerT } from './attacker.js'; +export { BookReader, BookReaderT } from './book-reader.js'; +export { Character, unionToCharacter, unionListToCharacter } from './character.js'; +export { FallingTub, FallingTubT } from './falling-tub.js'; +export { Gadget, unionToGadget, unionListToGadget } from './gadget.js'; +export { HandFan, HandFanT } from './hand-fan.js'; +export { Movie, MovieT } from './movie.js'; +export { Rapunzel, RapunzelT } from './rapunzel.js'; diff --git a/tests/union_vector/union_vector_generated.h b/tests/union_vector/union_vector_generated.h index 44946620333..5198b7c7663 100644 --- a/tests/union_vector/union_vector_generated.h +++ b/tests/union_vector/union_vector_generated.h @@ -356,9 +356,6 @@ FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(4) Rapunzel FLATBUFFERS_FINAL_CLASS { static const flatbuffers::TypeTable *MiniReflectTypeTable() { return RapunzelTypeTable(); } - static FLATBUFFERS_CONSTEXPR_CPP11 const char *GetFullyQualifiedName() { - return "Rapunzel"; - } Rapunzel() : hair_length_(0) { } @@ -392,9 +389,6 @@ FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(4) BookReader FLATBUFFERS_FINAL_CLASS { static const flatbuffers::TypeTable *MiniReflectTypeTable() { return BookReaderTypeTable(); } - static FLATBUFFERS_CONSTEXPR_CPP11 const char *GetFullyQualifiedName() { - return "BookReader"; - } BookReader() : books_read_(0) { } @@ -428,9 +422,6 @@ FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(4) FallingTub FLATBUFFERS_FINAL_CLASS { static const flatbuffers::TypeTable *MiniReflectTypeTable() { return FallingTubTypeTable(); } - static FLATBUFFERS_CONSTEXPR_CPP11 const char *GetFullyQualifiedName() { - return "FallingTub"; - } FallingTub() : weight_(0) { } @@ -458,9 +449,6 @@ inline bool operator!=(const FallingTub &lhs, const FallingTub &rhs) { struct AttackerT : public flatbuffers::NativeTable { typedef Attacker TableType; - static FLATBUFFERS_CONSTEXPR_CPP11 const char *GetFullyQualifiedName() { - return "AttackerT"; - } int32_t sword_attack_damage = 0; }; @@ -470,9 +458,6 @@ struct Attacker FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { static const flatbuffers::TypeTable *MiniReflectTypeTable() { return AttackerTypeTable(); } - static FLATBUFFERS_CONSTEXPR_CPP11 const char *GetFullyQualifiedName() { - return "Attacker"; - } enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { VT_SWORD_ATTACK_DAMAGE = 4 }; @@ -522,9 +507,6 @@ flatbuffers::Offset CreateAttacker(flatbuffers::FlatBufferBuilder &_fb struct HandFanT : public flatbuffers::NativeTable { typedef HandFan TableType; - static FLATBUFFERS_CONSTEXPR_CPP11 const char *GetFullyQualifiedName() { - return "HandFanT"; - } int32_t length = 0; }; @@ -534,9 +516,6 @@ struct HandFan FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { static const flatbuffers::TypeTable *MiniReflectTypeTable() { return HandFanTypeTable(); } - static FLATBUFFERS_CONSTEXPR_CPP11 const char *GetFullyQualifiedName() { - return "HandFan"; - } enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { VT_LENGTH = 4 }; @@ -586,9 +565,6 @@ flatbuffers::Offset CreateHandFan(flatbuffers::FlatBufferBuilder &_fbb, struct MovieT : public flatbuffers::NativeTable { typedef Movie TableType; - static FLATBUFFERS_CONSTEXPR_CPP11 const char *GetFullyQualifiedName() { - return "MovieT"; - } CharacterUnion main_character{}; std::vector characters{}; }; @@ -599,9 +575,6 @@ struct Movie FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { static const flatbuffers::TypeTable *MiniReflectTypeTable() { return MovieTypeTable(); } - static FLATBUFFERS_CONSTEXPR_CPP11 const char *GetFullyQualifiedName() { - return "Movie"; - } enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { VT_MAIN_CHARACTER_TYPE = 4, VT_MAIN_CHARACTER = 6, diff --git a/yarn.lock b/yarn.lock index a1d9ed0c1de..8636de9b986 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2,28 +2,7 @@ # yarn lockfile v1 -"@babel/code-frame@7.12.11": - version "7.12.11" - resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.12.11.tgz#f4ad435aa263db935b8f10f2c552d23fb716a63f" - integrity sha512-Zt1yodBx1UcyiePMSkWnU4hPqhwq7hGi2nFL1LeA3EUl+q2LQx16MISgJ0+z7dnmgvP9QtIleuETGOiOH1RcIw== - dependencies: - "@babel/highlight" "^7.10.4" - -"@babel/helper-validator-identifier@^7.16.7": - version "7.16.7" - resolved "https://registry.yarnpkg.com/@babel/helper-validator-identifier/-/helper-validator-identifier-7.16.7.tgz#e8c602438c4a8195751243da9031d1607d247cad" - integrity sha512-hsEnFemeiW4D08A5gUAZxLBTXpZ39P+a+DGDsHw1yxqyQ/jzFEnxf5uTEGp+3bzAbNOxU1paTgYS4ECU/IgfDw== - -"@babel/highlight@^7.10.4": - version "7.16.10" - resolved "https://registry.yarnpkg.com/@babel/highlight/-/highlight-7.16.10.tgz#744f2eb81579d6eea753c227b0f570ad785aba88" - integrity sha512-5FnTQLSLswEj6IkgVw5KusNUUFY9ZGqe/TRFnP/BKYHYgfh7tc+C7mwiy95/yNP7Dh9x580Vv8r7u7ZfTBFxdw== - dependencies: - "@babel/helper-validator-identifier" "^7.16.7" - chalk "^2.0.0" - js-tokens "^4.0.0" - -"@bazel/typescript@^5.2.0": +"@bazel/typescript@5.2.0": version "5.2.0" resolved "https://registry.yarnpkg.com/@bazel/typescript/-/typescript-5.2.0.tgz#131127c8016c712ef1b291f2b52108e5326f0447" integrity sha512-hNpSCQj5dOX95iC4Yf/fuyxfMU5uTAe84thqPcTCvOJFmpypN6qzxH24S5UiXkwbsL8sQM9DP0+qFyT/TRKdNw== @@ -41,31 +20,41 @@ dependencies: google-protobuf "^3.6.1" -"@eslint/eslintrc@^0.4.3": - version "0.4.3" - resolved "https://registry.yarnpkg.com/@eslint/eslintrc/-/eslintrc-0.4.3.tgz#9e42981ef035beb3dd49add17acb96e8ff6f394c" - integrity sha512-J6KFFz5QCYUJq3pf0mjEcCJVERbzv71PUIDczuh9JkwGEzced6CO5ADLHB1rbf/+oPBtoPfMYNOpGDzCANlbXw== +"@eslint/eslintrc@^1.3.2": + version "1.3.2" + resolved "https://registry.yarnpkg.com/@eslint/eslintrc/-/eslintrc-1.3.2.tgz#58b69582f3b7271d8fa67fe5251767a5b38ea356" + integrity sha512-AXYd23w1S/bv3fTs3Lz0vjiYemS08jWkI3hYyS9I1ry+0f+Yjs1wm+sU0BS8qDOPrBIkp4qHYC16I8uVtpLajQ== dependencies: ajv "^6.12.4" - debug "^4.1.1" - espree "^7.3.0" - globals "^13.9.0" - ignore "^4.0.6" + debug "^4.3.2" + espree "^9.4.0" + globals "^13.15.0" + ignore "^5.2.0" import-fresh "^3.2.1" - js-yaml "^3.13.1" - minimatch "^3.0.4" + js-yaml "^4.1.0" + minimatch "^3.1.2" strip-json-comments "^3.1.1" -"@humanwhocodes/config-array@^0.5.0": - version "0.5.0" - resolved "https://registry.yarnpkg.com/@humanwhocodes/config-array/-/config-array-0.5.0.tgz#1407967d4c6eecd7388f83acf1eaf4d0c6e58ef9" - integrity sha512-FagtKFz74XrTl7y6HCzQpwDfXP0yhxe9lHLD1UZxjvZIcbyRz8zTFF/yYNfSfzU414eDwZ1SrO0Qvtyf+wFMQg== +"@humanwhocodes/config-array@^0.10.4": + version "0.10.4" + resolved "https://registry.yarnpkg.com/@humanwhocodes/config-array/-/config-array-0.10.4.tgz#01e7366e57d2ad104feea63e72248f22015c520c" + integrity sha512-mXAIHxZT3Vcpg83opl1wGlVZ9xydbfZO3r5YfRSH6Gpp2J/PfdBP0wbDa2sO6/qRbcalpoevVyW6A/fI6LfeMw== dependencies: - "@humanwhocodes/object-schema" "^1.2.0" + "@humanwhocodes/object-schema" "^1.2.1" debug "^4.1.1" minimatch "^3.0.4" -"@humanwhocodes/object-schema@^1.2.0": +"@humanwhocodes/gitignore-to-minimatch@^1.0.2": + version "1.0.2" + resolved "https://registry.yarnpkg.com/@humanwhocodes/gitignore-to-minimatch/-/gitignore-to-minimatch-1.0.2.tgz#316b0a63b91c10e53f242efb4ace5c3b34e8728d" + integrity sha512-rSqmMJDdLFUsyxR6FMtD00nfQKKLFb1kv+qBbOVKqErvloEIJLo5bDTJTQNTYgeyp78JsA7u/NPi5jT1GR/MuA== + +"@humanwhocodes/module-importer@^1.0.1": + version "1.0.1" + resolved "https://registry.yarnpkg.com/@humanwhocodes/module-importer/-/module-importer-1.0.1.tgz#af5b2691a22b44be847b0ca81641c5fb6ad0172c" + integrity sha512-bxveV4V8v5Yb4ncFTT3rPSgZBOpCkjfK0y4oVVVJwIuDVBRMDXrPyXRL988i5ap9m9bnyEEjWfm5WkBmtffLfA== + +"@humanwhocodes/object-schema@^1.2.1": version "1.2.1" resolved "https://registry.yarnpkg.com/@humanwhocodes/object-schema/-/object-schema-1.2.1.tgz#b520529ec21d8e5945a1851dfd1c32e94e39ff45" integrity sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA== @@ -94,7 +83,7 @@ "@protobufjs/aspromise@^1.1.1", "@protobufjs/aspromise@^1.1.2": version "1.1.2" resolved "https://registry.yarnpkg.com/@protobufjs/aspromise/-/aspromise-1.1.2.tgz#9b8b0cc663d669a7d8f6f5d0893a14d348f30fbf" - integrity sha1-m4sMxmPWaafY9vXQiToU00jzD78= + integrity sha512-j+gKExEuLmKwvz3OgROXtrJ2UG2x8Ch2YZUxahh+s1F2HZ+wAceUNLkvy6zKCPVRkU++ZWQrdxsUeQXmcg4uoQ== "@protobufjs/base64@^1.1.2": version "1.1.2" @@ -109,12 +98,12 @@ "@protobufjs/eventemitter@^1.1.0": version "1.1.0" resolved "https://registry.yarnpkg.com/@protobufjs/eventemitter/-/eventemitter-1.1.0.tgz#355cbc98bafad5978f9ed095f397621f1d066b70" - integrity sha1-NVy8mLr61ZePntCV85diHx0Ga3A= + integrity sha512-j9ednRT81vYJ9OfVuXG6ERSTdEL1xVsNgqpkxMsbIabzSo3goCjDIveeGv5d03om39ML71RdmrGNjG5SReBP/Q== "@protobufjs/fetch@^1.1.0": version "1.1.0" resolved "https://registry.yarnpkg.com/@protobufjs/fetch/-/fetch-1.1.0.tgz#ba99fb598614af65700c1619ff06d454b0d84c45" - integrity sha1-upn7WYYUr2VwDBYZ/wbUVLDYTEU= + integrity sha512-lljVXpqXebpsijW71PZaCYeIcE5on1w5DlQy5WH6GLbFryLUrBD4932W/E2BSpfRJWseIL4v/KPgBFxDOIdKpQ== dependencies: "@protobufjs/aspromise" "^1.1.1" "@protobufjs/inquire" "^1.1.0" @@ -122,127 +111,138 @@ "@protobufjs/float@^1.0.2": version "1.0.2" resolved "https://registry.yarnpkg.com/@protobufjs/float/-/float-1.0.2.tgz#5e9e1abdcb73fc0a7cb8b291df78c8cbd97b87d1" - integrity sha1-Xp4avctz/Ap8uLKR33jIy9l7h9E= + integrity sha512-Ddb+kVXlXst9d+R9PfTIxh1EdNkgoRe5tOX6t01f1lYWOvJnSPDBlG241QLzcyPdoNTsblLUdujGSE4RzrTZGQ== "@protobufjs/inquire@^1.1.0": version "1.1.0" resolved "https://registry.yarnpkg.com/@protobufjs/inquire/-/inquire-1.1.0.tgz#ff200e3e7cf2429e2dcafc1140828e8cc638f089" - integrity sha1-/yAOPnzyQp4tyvwRQIKOjMY48Ik= + integrity sha512-kdSefcPdruJiFMVSbn801t4vFK7KB/5gd2fYvrxhuJYg8ILrmn9SKSX2tZdV6V+ksulWqS7aXjBcRXl3wHoD9Q== "@protobufjs/path@^1.1.2": version "1.1.2" resolved "https://registry.yarnpkg.com/@protobufjs/path/-/path-1.1.2.tgz#6cc2b20c5c9ad6ad0dccfd21ca7673d8d7fbf68d" - integrity sha1-bMKyDFya1q0NzP0hynZz2Nf79o0= + integrity sha512-6JOcJ5Tm08dOHAbdR3GrvP+yUUfkjG5ePsHYczMFLq3ZmMkAD98cDgcT2iA1lJ9NVwFd4tH/iSSoe44YWkltEA== "@protobufjs/pool@^1.1.0": version "1.1.0" resolved "https://registry.yarnpkg.com/@protobufjs/pool/-/pool-1.1.0.tgz#09fd15f2d6d3abfa9b65bc366506d6ad7846ff54" - integrity sha1-Cf0V8tbTq/qbZbw2ZQbWrXhG/1Q= + integrity sha512-0kELaGSIDBKvcgS4zkjz1PeddatrjYcmMWOlAuAPwAeccUrPHdUqo/J6LiymHHEiJT5NrF1UVwxY14f+fy4WQw== "@protobufjs/utf8@^1.1.0": version "1.1.0" resolved "https://registry.yarnpkg.com/@protobufjs/utf8/-/utf8-1.1.0.tgz#a777360b5b39a1a2e5106f8e858f2fd2d060c570" - integrity sha1-p3c2C1s5oaLlEG+OhY8v0tBgxXA= + integrity sha512-Vvn3zZrhQZkkBE8LSuW3em98c0FwgO4nxzv6OdSxPKJIEKY2bGbHn+mhGIPerzI4twdxaP8/0+06HBpwf345Lw== -"@types/json-schema@^7.0.7": - version "7.0.9" - resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.9.tgz#97edc9037ea0c38585320b28964dde3b39e4660d" - integrity sha512-qcUXuemtEu+E5wZSJHNxUXeCZhAfXKQ41D+duX+VYPde7xyEVZci+/oXKJL13tnRs9lR2pr4fod59GT6/X1/yQ== +"@types/json-schema@^7.0.9": + version "7.0.11" + resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.11.tgz#d421b6c527a3037f7c84433fd2c4229e016863d3" + integrity sha512-wOuvG1SN4Us4rez+tylwwwCV1psiNVOkJeM3AUWUNWg/jDQY2+HE/444y5gc+jBmRqASOm2Oeh5c1axHobwRKQ== "@types/long@^4.0.0": - version "4.0.1" - resolved "https://registry.yarnpkg.com/@types/long/-/long-4.0.1.tgz#459c65fa1867dafe6a8f322c4c51695663cc55e9" - integrity sha512-5tXH6Bx/kNGd3MgffdmP4dy2Z+G4eaXw0SE81Tq3BNadtnMR5/ySMzX4SLEzHJzSmPNn4HIdpQsBvXMUykr58w== + version "4.0.2" + resolved "https://registry.yarnpkg.com/@types/long/-/long-4.0.2.tgz#b74129719fc8d11c01868010082d483b7545591a" + integrity sha512-MqTGEo5bj5t157U6fA/BiDynNkn0YknVdh48CMPkTSpFTVmvao5UQmm7uEF6xBEo7qIMAlY/JSleYaE6VOdpaA== -"@types/node@17.0.21": - version "17.0.21" - resolved "https://registry.yarnpkg.com/@types/node/-/node-17.0.21.tgz#864b987c0c68d07b4345845c3e63b75edd143644" - integrity sha512-DBZCJbhII3r90XbQxI8Y9IjjiiOGlZ0Hr32omXIZvwwZ7p4DMMXGrKXVyPfuoBOri9XNtL0UK69jYIBIsRX3QQ== +"@types/node@18.7.16": + version "18.7.16" + resolved "https://registry.yarnpkg.com/@types/node/-/node-18.7.16.tgz#0eb3cce1e37c79619943d2fd903919fc30850601" + integrity sha512-EQHhixfu+mkqHMZl1R2Ovuvn47PUw18azMJOTwSZr9/fhzHNGXAJ0ma0dayRVchprpCj0Kc1K1xKoWaATWF1qg== "@types/node@^10.1.0": version "10.17.60" resolved "https://registry.yarnpkg.com/@types/node/-/node-10.17.60.tgz#35f3d6213daed95da7f0f73e75bcc6980e90597b" integrity sha512-F0KIgDJfy2nA3zMLmWGKxcH2ZVEtCZXHHdOQs2gSaQ27+lNeEfGxzkIw90aXswATX7AZ33tahPbzy6KAfUreVw== -"@typescript-eslint/eslint-plugin@^4.12.0": - version "4.33.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-4.33.0.tgz#c24dc7c8069c7706bc40d99f6fa87edcb2005276" - integrity sha512-aINiAxGVdOl1eJyVjaWn/YcVAq4Gi/Yo35qHGCnqbWVz61g39D0h23veY/MA0rFFGfxK7TySg2uwDeNv+JgVpg== +"@typescript-eslint/eslint-plugin@^5.36.2": + version "5.36.2" + resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.36.2.tgz#6df092a20e0f9ec748b27f293a12cb39d0c1fe4d" + integrity sha512-OwwR8LRwSnI98tdc2z7mJYgY60gf7I9ZfGjN5EjCwwns9bdTuQfAXcsjSB2wSQ/TVNYSGKf4kzVXbNGaZvwiXw== dependencies: - "@typescript-eslint/experimental-utils" "4.33.0" - "@typescript-eslint/scope-manager" "4.33.0" - debug "^4.3.1" + "@typescript-eslint/scope-manager" "5.36.2" + "@typescript-eslint/type-utils" "5.36.2" + "@typescript-eslint/utils" "5.36.2" + debug "^4.3.4" functional-red-black-tree "^1.0.1" - ignore "^5.1.8" - regexpp "^3.1.0" - semver "^7.3.5" + ignore "^5.2.0" + regexpp "^3.2.0" + semver "^7.3.7" tsutils "^3.21.0" -"@typescript-eslint/experimental-utils@4.33.0": - version "4.33.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/experimental-utils/-/experimental-utils-4.33.0.tgz#6f2a786a4209fa2222989e9380b5331b2810f7fd" - integrity sha512-zeQjOoES5JFjTnAhI5QY7ZviczMzDptls15GFsI6jyUOq0kOf9+WonkhtlIhh0RgHRnqj5gdNxW5j1EvAyYg6Q== +"@typescript-eslint/parser@^5.36.2": + version "5.36.2" + resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-5.36.2.tgz#3ddf323d3ac85a25295a55fcb9c7a49ab4680ddd" + integrity sha512-qS/Kb0yzy8sR0idFspI9Z6+t7mqk/oRjnAYfewG+VN73opAUvmYL3oPIMmgOX6CnQS6gmVIXGshlb5RY/R22pA== dependencies: - "@types/json-schema" "^7.0.7" - "@typescript-eslint/scope-manager" "4.33.0" - "@typescript-eslint/types" "4.33.0" - "@typescript-eslint/typescript-estree" "4.33.0" - eslint-scope "^5.1.1" - eslint-utils "^3.0.0" + "@typescript-eslint/scope-manager" "5.36.2" + "@typescript-eslint/types" "5.36.2" + "@typescript-eslint/typescript-estree" "5.36.2" + debug "^4.3.4" -"@typescript-eslint/parser@^4.12.0": - version "4.33.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-4.33.0.tgz#dfe797570d9694e560528d18eecad86c8c744899" - integrity sha512-ZohdsbXadjGBSK0/r+d87X0SBmKzOq4/S5nzK6SBgJspFo9/CUDJ7hjayuze+JK7CZQLDMroqytp7pOcFKTxZA== - dependencies: - "@typescript-eslint/scope-manager" "4.33.0" - "@typescript-eslint/types" "4.33.0" - "@typescript-eslint/typescript-estree" "4.33.0" - debug "^4.3.1" - -"@typescript-eslint/scope-manager@4.33.0": - version "4.33.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-4.33.0.tgz#d38e49280d983e8772e29121cf8c6e9221f280a3" - integrity sha512-5IfJHpgTsTZuONKbODctL4kKuQje/bzBRkwHE8UOZ4f89Zeddg+EGZs8PD8NcN4LdM3ygHWYB3ukPAYjvl/qbQ== - dependencies: - "@typescript-eslint/types" "4.33.0" - "@typescript-eslint/visitor-keys" "4.33.0" - -"@typescript-eslint/types@4.33.0": - version "4.33.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-4.33.0.tgz#a1e59036a3b53ae8430ceebf2a919dc7f9af6d72" - integrity sha512-zKp7CjQzLQImXEpLt2BUw1tvOMPfNoTAfb8l51evhYbOEEzdWyQNmHWWGPR6hwKJDAi+1VXSBmnhL9kyVTTOuQ== - -"@typescript-eslint/typescript-estree@4.33.0": - version "4.33.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-4.33.0.tgz#0dfb51c2908f68c5c08d82aefeaf166a17c24609" - integrity sha512-rkWRY1MPFzjwnEVHsxGemDzqqddw2QbTJlICPD9p9I9LfsO8fdmfQPOX3uKfUaGRDFJbfrtm/sXhVXN4E+bzCA== - dependencies: - "@typescript-eslint/types" "4.33.0" - "@typescript-eslint/visitor-keys" "4.33.0" - debug "^4.3.1" - globby "^11.0.3" - is-glob "^4.0.1" - semver "^7.3.5" +"@typescript-eslint/scope-manager@5.36.2": + version "5.36.2" + resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-5.36.2.tgz#a75eb588a3879ae659514780831370642505d1cd" + integrity sha512-cNNP51L8SkIFSfce8B1NSUBTJTu2Ts4nWeWbFrdaqjmn9yKrAaJUBHkyTZc0cL06OFHpb+JZq5AUHROS398Orw== + dependencies: + "@typescript-eslint/types" "5.36.2" + "@typescript-eslint/visitor-keys" "5.36.2" + +"@typescript-eslint/type-utils@5.36.2": + version "5.36.2" + resolved "https://registry.yarnpkg.com/@typescript-eslint/type-utils/-/type-utils-5.36.2.tgz#752373f4babf05e993adf2cd543a763632826391" + integrity sha512-rPQtS5rfijUWLouhy6UmyNquKDPhQjKsaKH0WnY6hl/07lasj8gPaH2UD8xWkePn6SC+jW2i9c2DZVDnL+Dokw== + dependencies: + "@typescript-eslint/typescript-estree" "5.36.2" + "@typescript-eslint/utils" "5.36.2" + debug "^4.3.4" + tsutils "^3.21.0" + +"@typescript-eslint/types@5.36.2": + version "5.36.2" + resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-5.36.2.tgz#a5066e500ebcfcee36694186ccc57b955c05faf9" + integrity sha512-9OJSvvwuF1L5eS2EQgFUbECb99F0mwq501w0H0EkYULkhFa19Qq7WFbycdw1PexAc929asupbZcgjVIe6OK/XQ== + +"@typescript-eslint/typescript-estree@5.36.2": + version "5.36.2" + resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-5.36.2.tgz#0c93418b36c53ba0bc34c61fe9405c4d1d8fe560" + integrity sha512-8fyH+RfbKc0mTspfuEjlfqA4YywcwQK2Amcf6TDOwaRLg7Vwdu4bZzyvBZp4bjt1RRjQ5MDnOZahxMrt2l5v9w== + dependencies: + "@typescript-eslint/types" "5.36.2" + "@typescript-eslint/visitor-keys" "5.36.2" + debug "^4.3.4" + globby "^11.1.0" + is-glob "^4.0.3" + semver "^7.3.7" tsutils "^3.21.0" -"@typescript-eslint/visitor-keys@4.33.0": - version "4.33.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-4.33.0.tgz#2a22f77a41604289b7a186586e9ec48ca92ef1dd" - integrity sha512-uqi/2aSz9g2ftcHWf8uLPJA70rUv6yuMW5Bohw+bwcuzaxQIHaKFZCKGoGXIrc9vkTJ3+0txM73K0Hq3d5wgIg== +"@typescript-eslint/utils@5.36.2": + version "5.36.2" + resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-5.36.2.tgz#b01a76f0ab244404c7aefc340c5015d5ce6da74c" + integrity sha512-uNcopWonEITX96v9pefk9DC1bWMdkweeSsewJ6GeC7L6j2t0SJywisgkr9wUTtXk90fi2Eljj90HSHm3OGdGRg== dependencies: - "@typescript-eslint/types" "4.33.0" - eslint-visitor-keys "^2.0.0" + "@types/json-schema" "^7.0.9" + "@typescript-eslint/scope-manager" "5.36.2" + "@typescript-eslint/types" "5.36.2" + "@typescript-eslint/typescript-estree" "5.36.2" + eslint-scope "^5.1.1" + eslint-utils "^3.0.0" -acorn-jsx@^5.3.1: +"@typescript-eslint/visitor-keys@5.36.2": + version "5.36.2" + resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-5.36.2.tgz#2f8f78da0a3bad3320d2ac24965791ac39dace5a" + integrity sha512-BtRvSR6dEdrNt7Net2/XDjbYKU5Ml6GqJgVfXT0CxTCJlnIqK7rAGreuWKMT2t8cFUT2Msv5oxw0GMRD7T5J7A== + dependencies: + "@typescript-eslint/types" "5.36.2" + eslint-visitor-keys "^3.3.0" + +acorn-jsx@^5.3.2: version "5.3.2" resolved "https://registry.yarnpkg.com/acorn-jsx/-/acorn-jsx-5.3.2.tgz#7ed5bb55908b3b2f1bc55c6af1653bada7f07937" integrity sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ== -acorn@^7.4.0: - version "7.4.1" - resolved "https://registry.yarnpkg.com/acorn/-/acorn-7.4.1.tgz#feaed255973d2e77555b83dbc08851a6c63520fa" - integrity sha512-nQyp0o1/mNdbTO1PO6kHkwSrmgZ0MT/jCCpNiwbUjGoRN4dlBhqJtoQuCnEOKzgTVwg0ZWiCoQy6SxMebQVh8A== +acorn@^8.8.0: + version "8.8.0" + resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.8.0.tgz#88c0187620435c7f6015803f5539dae05a9dbea8" + integrity sha512-QOxyigPVrpZ2GXT+PFyZTl6TtOFc5egxHIP9IlQ+RbupQuX4RkT/Bee4/kQuC02Xkzg84JcT7oLYtDIQxp+v7w== ajv@^6.10.0, ajv@^6.12.4: version "6.12.6" @@ -254,57 +254,28 @@ ajv@^6.10.0, ajv@^6.12.4: json-schema-traverse "^0.4.1" uri-js "^4.2.2" -ajv@^8.0.1: - version "8.10.0" - resolved "https://registry.yarnpkg.com/ajv/-/ajv-8.10.0.tgz#e573f719bd3af069017e3b66538ab968d040e54d" - integrity sha512-bzqAEZOjkrUMl2afH8dknrq5KEk2SrwdBROR+vH1EKVQTqaUbJVPdc/gEdggTMM0Se+s+Ja4ju4TlNcStKl2Hw== - dependencies: - fast-deep-equal "^3.1.1" - json-schema-traverse "^1.0.0" - require-from-string "^2.0.2" - uri-js "^4.2.2" - -ansi-colors@^4.1.1: - version "4.1.1" - resolved "https://registry.yarnpkg.com/ansi-colors/-/ansi-colors-4.1.1.tgz#cbb9ae256bf750af1eab344f229aa27fe94ba348" - integrity sha512-JoX0apGbHaUJBNl6yF+p6JAFYZ666/hhCGKN5t9QFjbJQKUU/g8MNbFDbvfrgKXvI1QpZplPOnwIo99lX/AAmA== - ansi-regex@^5.0.1: version "5.0.1" resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-5.0.1.tgz#082cb2c89c9fe8659a311a53bd6a4dc5301db304" integrity sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ== -ansi-styles@^3.2.1: - version "3.2.1" - resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-3.2.1.tgz#41fbb20243e50b12be0f04b8dedbf07520ce841d" - integrity sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA== - dependencies: - color-convert "^1.9.0" - -ansi-styles@^4.0.0, ansi-styles@^4.1.0: +ansi-styles@^4.1.0: version "4.3.0" resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-4.3.0.tgz#edd803628ae71c04c85ae7a0906edad34b648937" integrity sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg== dependencies: color-convert "^2.0.1" -argparse@^1.0.7: - version "1.0.10" - resolved "https://registry.yarnpkg.com/argparse/-/argparse-1.0.10.tgz#bcd6791ea5ae09725e17e5ad988134cd40b3d911" - integrity sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg== - dependencies: - sprintf-js "~1.0.2" +argparse@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/argparse/-/argparse-2.0.1.tgz#246f50f3ca78a3240f6c997e8a9bd1eac49e4b38" + integrity sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q== array-union@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/array-union/-/array-union-2.1.0.tgz#b798420adbeb1de828d84acd8a2e23d3efe85e8d" integrity sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw== -astral-regex@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/astral-regex/-/astral-regex-2.0.0.tgz#483143c567aeed4785759c0865786dc77d7d2e31" - integrity sha512-Z7tMw1ytTXt5jqMcOP+OQteU1VuNK9Y02uuJtKQ1Sv69jXQKKg5cibLwGJow8yzZP+eAc18EmLGPal0bp36rvQ== - balanced-match@^1.0.0: version "1.0.2" resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.2.tgz#e83e3a7e3f300b34cb9d87f615fa0cbf357690ee" @@ -318,7 +289,7 @@ brace-expansion@^1.1.7: balanced-match "^1.0.0" concat-map "0.0.1" -braces@^3.0.1: +braces@^3.0.2: version "3.0.2" resolved "https://registry.yarnpkg.com/braces/-/braces-3.0.2.tgz#3454e1a462ee8d599e236df336cd9ea4f8afe107" integrity sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A== @@ -335,15 +306,6 @@ callsites@^3.0.0: resolved "https://registry.yarnpkg.com/callsites/-/callsites-3.1.0.tgz#b3630abd8943432f54b3f0519238e33cd7df2f73" integrity sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ== -chalk@^2.0.0: - version "2.4.2" - resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.2.tgz#cd42541677a54333cf541a49108c1432b44c9424" - integrity sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ== - dependencies: - ansi-styles "^3.2.1" - escape-string-regexp "^1.0.5" - supports-color "^5.3.0" - chalk@^4.0.0: version "4.1.2" resolved "https://registry.yarnpkg.com/chalk/-/chalk-4.1.2.tgz#aac4e2b7734a740867aeb16bf02aad556a1e7a01" @@ -352,13 +314,6 @@ chalk@^4.0.0: ansi-styles "^4.1.0" supports-color "^7.1.0" -color-convert@^1.9.0: - version "1.9.3" - resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-1.9.3.tgz#bb71850690e1f136567de629d2d5471deda4c1e8" - integrity sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg== - dependencies: - color-name "1.1.3" - color-convert@^2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-2.0.1.tgz#72d3a68d598c9bdb3af2ad1e84f21d896abd4de3" @@ -366,11 +321,6 @@ color-convert@^2.0.1: dependencies: color-name "~1.1.4" -color-name@1.1.3: - version "1.1.3" - resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.3.tgz#a7d0558bd89c42f795dd42328f740831ca53bc25" - integrity sha1-p9BVi9icQveV3UIyj3QIMcpTvCU= - color-name@~1.1.4: version "1.1.4" resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.4.tgz#c2a09a87acbde69543de6f63fa3995c826c536a2" @@ -379,7 +329,7 @@ color-name@~1.1.4: concat-map@0.0.1: version "0.0.1" resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" - integrity sha1-2Klr13/Wjfd5OnMDajug1UBdR3s= + integrity sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg== cross-spawn@^7.0.2: version "7.0.3" @@ -390,10 +340,10 @@ cross-spawn@^7.0.2: shebang-command "^2.0.0" which "^2.0.1" -debug@^4.0.1, debug@^4.1.1, debug@^4.3.1: - version "4.3.3" - resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.3.tgz#04266e0b70a98d4462e6e288e38259213332b664" - integrity sha512-/zxw5+vh1Tfv+4Qn7a5nsbcJKPaSvCDhojn6FEl9vupwK2VCSDtEiEtqr8DFtzYFOdz63LBkxec7DYuc2jon6Q== +debug@^4.1.1, debug@^4.3.2, debug@^4.3.4: + version "4.3.4" + resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.4.tgz#1319f6579357f2338d3337d2cdd4914bb5dcc865" + integrity sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ== dependencies: ms "2.1.2" @@ -416,23 +366,6 @@ doctrine@^3.0.0: dependencies: esutils "^2.0.2" -emoji-regex@^8.0.0: - version "8.0.0" - resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-8.0.0.tgz#e818fd69ce5ccfcb404594f842963bf53164cc37" - integrity sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A== - -enquirer@^2.3.5: - version "2.3.6" - resolved "https://registry.yarnpkg.com/enquirer/-/enquirer-2.3.6.tgz#2a7fe5dd634a1e4125a975ec994ff5456dc3734d" - integrity sha512-yjNnPr315/FjS4zIsUxYguYUPP2e1NK4d7E7ZOLiyYCcbFBiTMyID+2wvm2w6+pZ/odMA7cRkjhsPbltwBOrLg== - dependencies: - ansi-colors "^4.1.1" - -escape-string-regexp@^1.0.5: - version "1.0.5" - resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4" - integrity sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ= - escape-string-regexp@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz#14ba83a5d373e3d311e5afca29cf5bfad965bf34" @@ -446,12 +379,13 @@ eslint-scope@^5.1.1: esrecurse "^4.3.0" estraverse "^4.1.1" -eslint-utils@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/eslint-utils/-/eslint-utils-2.1.0.tgz#d2de5e03424e707dc10c74068ddedae708741b27" - integrity sha512-w94dQYoauyvlDc43XnGB8lU3Zt713vNChgt4EWwhXAP2XkBvndfxF0AgIqKOOasjPIPzj9JqgwkwbCYD0/V3Zg== +eslint-scope@^7.1.1: + version "7.1.1" + resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-7.1.1.tgz#fff34894c2f65e5226d3041ac480b4513a163642" + integrity sha512-QKQM/UXpIiHcLqJ5AOyIW7XZmzjkzQXYE54n1++wb0u9V/abW3l9uQnxX8Z5Xd18xyKIMTUAyQ0k1e8pz6LUrw== dependencies: - eslint-visitor-keys "^1.1.0" + esrecurse "^4.3.0" + estraverse "^5.2.0" eslint-utils@^3.0.0: version "3.0.0" @@ -460,75 +394,69 @@ eslint-utils@^3.0.0: dependencies: eslint-visitor-keys "^2.0.0" -eslint-visitor-keys@^1.1.0, eslint-visitor-keys@^1.3.0: - version "1.3.0" - resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-1.3.0.tgz#30ebd1ef7c2fdff01c3a4f151044af25fab0523e" - integrity sha512-6J72N8UNa462wa/KFODt/PJ3IU60SDpC3QXC1Hjc1BXXpfL2C9R5+AU7jhe0F6GREqVMh4Juu+NY7xn+6dipUQ== - eslint-visitor-keys@^2.0.0: version "2.1.0" resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-2.1.0.tgz#f65328259305927392c938ed44eb0a5c9b2bd303" integrity sha512-0rSmRBzXgDzIsD6mGdJgevzgezI534Cer5L/vyMX0kHzT/jiB43jRhd9YUlMGYLQy2zprNmoT8qasCGtY+QaKw== -eslint@^7.17.0: - version "7.32.0" - resolved "https://registry.yarnpkg.com/eslint/-/eslint-7.32.0.tgz#c6d328a14be3fb08c8d1d21e12c02fdb7a2a812d" - integrity sha512-VHZ8gX+EDfz+97jGcgyGCyRia/dPOd6Xh9yPv8Bl1+SoaIwD+a/vlrOmGRUyOYu7MwUhc7CxqeaDZU13S4+EpA== - dependencies: - "@babel/code-frame" "7.12.11" - "@eslint/eslintrc" "^0.4.3" - "@humanwhocodes/config-array" "^0.5.0" +eslint-visitor-keys@^3.3.0: + version "3.3.0" + resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-3.3.0.tgz#f6480fa6b1f30efe2d1968aa8ac745b862469826" + integrity sha512-mQ+suqKJVyeuwGYHAdjMFqjCyfl8+Ldnxuyp3ldiMBFKkvytrXUZWaiPCEav8qDHKty44bD+qV1IP4T+w+xXRA== + +eslint@^8.23.1: + version "8.23.1" + resolved "https://registry.yarnpkg.com/eslint/-/eslint-8.23.1.tgz#cfd7b3f7fdd07db8d16b4ac0516a29c8d8dca5dc" + integrity sha512-w7C1IXCc6fNqjpuYd0yPlcTKKmHlHHktRkzmBPZ+7cvNBQuiNjx0xaMTjAJGCafJhQkrFJooREv0CtrVzmHwqg== + dependencies: + "@eslint/eslintrc" "^1.3.2" + "@humanwhocodes/config-array" "^0.10.4" + "@humanwhocodes/gitignore-to-minimatch" "^1.0.2" + "@humanwhocodes/module-importer" "^1.0.1" ajv "^6.10.0" chalk "^4.0.0" cross-spawn "^7.0.2" - debug "^4.0.1" + debug "^4.3.2" doctrine "^3.0.0" - enquirer "^2.3.5" escape-string-regexp "^4.0.0" - eslint-scope "^5.1.1" - eslint-utils "^2.1.0" - eslint-visitor-keys "^2.0.0" - espree "^7.3.1" + eslint-scope "^7.1.1" + eslint-utils "^3.0.0" + eslint-visitor-keys "^3.3.0" + espree "^9.4.0" esquery "^1.4.0" esutils "^2.0.2" fast-deep-equal "^3.1.3" file-entry-cache "^6.0.1" - functional-red-black-tree "^1.0.1" - glob-parent "^5.1.2" - globals "^13.6.0" - ignore "^4.0.6" + find-up "^5.0.0" + glob-parent "^6.0.1" + globals "^13.15.0" + globby "^11.1.0" + grapheme-splitter "^1.0.4" + ignore "^5.2.0" import-fresh "^3.0.0" imurmurhash "^0.1.4" is-glob "^4.0.0" - js-yaml "^3.13.1" + js-sdsl "^4.1.4" + js-yaml "^4.1.0" json-stable-stringify-without-jsonify "^1.0.1" levn "^0.4.1" lodash.merge "^4.6.2" - minimatch "^3.0.4" + minimatch "^3.1.2" natural-compare "^1.4.0" optionator "^0.9.1" - progress "^2.0.0" - regexpp "^3.1.0" - semver "^7.2.1" - strip-ansi "^6.0.0" + regexpp "^3.2.0" + strip-ansi "^6.0.1" strip-json-comments "^3.1.0" - table "^6.0.9" text-table "^0.2.0" - v8-compile-cache "^2.0.3" -espree@^7.3.0, espree@^7.3.1: - version "7.3.1" - resolved "https://registry.yarnpkg.com/espree/-/espree-7.3.1.tgz#f2df330b752c6f55019f8bd89b7660039c1bbbb6" - integrity sha512-v3JCNCE64umkFpmkFGqzVKsOT0tN1Zr+ueqLZfpV1Ob8e+CEgPWa+OxCoGH3tnhimMKIaBm4m/vaRpJ/krRz2g== +espree@^9.4.0: + version "9.4.0" + resolved "https://registry.yarnpkg.com/espree/-/espree-9.4.0.tgz#cd4bc3d6e9336c433265fc0aa016fc1aaf182f8a" + integrity sha512-DQmnRpLj7f6TgN/NYb0MTzJXL+vJF9h3pHy4JhCIs3zwcgez8xmGg3sXHcEO97BrmO2OSvCwMdfdlyl+E9KjOw== dependencies: - acorn "^7.4.0" - acorn-jsx "^5.3.1" - eslint-visitor-keys "^1.3.0" - -esprima@^4.0.0: - version "4.0.1" - resolved "https://registry.yarnpkg.com/esprima/-/esprima-4.0.1.tgz#13b04cdb3e6c5d19df91ab6987a8695619b0aa71" - integrity sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A== + acorn "^8.8.0" + acorn-jsx "^5.3.2" + eslint-visitor-keys "^3.3.0" esquery@^1.4.0: version "1.4.0" @@ -583,7 +511,7 @@ fast-json-stable-stringify@^2.0.0: fast-levenshtein@^2.0.6: version "2.0.6" resolved "https://registry.yarnpkg.com/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz#3d8a5c66883a16a30ca8643e851f19baa7797917" - integrity sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc= + integrity sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw== fastq@^1.6.0: version "1.13.0" @@ -606,6 +534,14 @@ fill-range@^7.0.1: dependencies: to-regex-range "^5.0.1" +find-up@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/find-up/-/find-up-5.0.0.tgz#4c92819ecb7083561e4f4a240a86be5198f536fc" + integrity sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng== + dependencies: + locate-path "^6.0.0" + path-exists "^4.0.0" + flat-cache@^3.0.4: version "3.0.4" resolved "https://registry.yarnpkg.com/flat-cache/-/flat-cache-3.0.4.tgz#61b0338302b2fe9f957dcc32fc2a87f1c3048b11" @@ -615,14 +551,14 @@ flat-cache@^3.0.4: rimraf "^3.0.2" flatted@^3.1.0: - version "3.2.5" - resolved "https://registry.yarnpkg.com/flatted/-/flatted-3.2.5.tgz#76c8584f4fc843db64702a6bd04ab7a8bd666da3" - integrity sha512-WIWGi2L3DyTUvUrwRKgGi9TwxQMUEqPOPQBVi71R96jZXJdFskXEmf54BoZaS1kknGODoIGASGEzBUYdyMCBJg== + version "3.2.7" + resolved "https://registry.yarnpkg.com/flatted/-/flatted-3.2.7.tgz#609f39207cb614b89d0765b477cb2d437fbf9787" + integrity sha512-5nqDSxl8nn5BSNxyR3n4I6eDmbolI6WT+QqR547RwxQapgjQBmtktdP+HTBb/a/zLsbzERTONyUB5pefh5TtjQ== fs.realpath@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f" - integrity sha1-FQStJSMVjKpA20onh8sBQRmU6k8= + integrity sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw== fsevents@~2.3.2: version "2.3.2" @@ -632,7 +568,7 @@ fsevents@~2.3.2: functional-red-black-tree@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz#1b0ab3bd553b2a0d6399d29c0e3ea0b252078327" - integrity sha1-GwqzvVU7Kg1jmdKcDj6gslIHgyc= + integrity sha512-dsKNQNdj6xA3T+QlADDA7mOSlX0qiMINjn0cgr+eGHGsbSHzTabcIogz2+p/iqP1Xs6EP/sS2SbqH+brGTbq0g== glob-parent@^5.1.2: version "5.1.2" @@ -641,26 +577,33 @@ glob-parent@^5.1.2: dependencies: is-glob "^4.0.1" +glob-parent@^6.0.1: + version "6.0.2" + resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-6.0.2.tgz#6d237d99083950c79290f24c7642a3de9a28f9e3" + integrity sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A== + dependencies: + is-glob "^4.0.3" + glob@^7.1.3: - version "7.2.0" - resolved "https://registry.yarnpkg.com/glob/-/glob-7.2.0.tgz#d15535af7732e02e948f4c41628bd910293f6023" - integrity sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q== + version "7.2.3" + resolved "https://registry.yarnpkg.com/glob/-/glob-7.2.3.tgz#b8df0fb802bbfa8e89bd1d938b4e16578ed44f2b" + integrity sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q== dependencies: fs.realpath "^1.0.0" inflight "^1.0.4" inherits "2" - minimatch "^3.0.4" + minimatch "^3.1.1" once "^1.3.0" path-is-absolute "^1.0.0" -globals@^13.6.0, globals@^13.9.0: - version "13.12.1" - resolved "https://registry.yarnpkg.com/globals/-/globals-13.12.1.tgz#ec206be932e6c77236677127577aa8e50bf1c5cb" - integrity sha512-317dFlgY2pdJZ9rspXDks7073GpDmXdfbM3vYYp0HAMKGDh1FfWPleI2ljVNLQX5M5lXcAslTcPTrOrMEFOjyw== +globals@^13.15.0: + version "13.17.0" + resolved "https://registry.yarnpkg.com/globals/-/globals-13.17.0.tgz#902eb1e680a41da93945adbdcb5a9f361ba69bd4" + integrity sha512-1C+6nQRb1GwGMKm2dH/E7enFAMxGTmGI7/dEdhy/DNelv85w9B72t3uc5frtMNXIbzrarJJ/lTCjcaZwbLJmyw== dependencies: type-fest "^0.20.2" -globby@^11.0.3: +globby@^11.1.0: version "11.1.0" resolved "https://registry.yarnpkg.com/globby/-/globby-11.1.0.tgz#bd4be98bb042f83d796f7e3811991fbe82a0d34b" integrity sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g== @@ -673,26 +616,21 @@ globby@^11.0.3: slash "^3.0.0" google-protobuf@^3.6.1: - version "3.19.4" - resolved "https://registry.yarnpkg.com/google-protobuf/-/google-protobuf-3.19.4.tgz#8d32c3e34be9250956f28c0fb90955d13f311888" - integrity sha512-OIPNCxsG2lkIvf+P5FNfJ/Km95CsXOBecS9ZcAU6m2Rq3svc0Apl9nB3GMDNKfQ9asNv4KjyAqGwPQFrVle3Yg== + version "3.21.0" + resolved "https://registry.yarnpkg.com/google-protobuf/-/google-protobuf-3.21.0.tgz#8dfa3fca16218618d373d414d3c1139e28034d6e" + integrity sha512-byR7MBTK4tZ5PZEb+u5ZTzpt4SfrTxv5682MjPlHN16XeqgZE2/8HOIWeiXe8JKnT9OVbtBGhbq8mtvkK8cd5g== -has-flag@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-3.0.0.tgz#b5d454dc2199ae225699f3467e5a07f3b955bafd" - integrity sha1-tdRU3CGZriJWmfNGfloH87lVuv0= +grapheme-splitter@^1.0.4: + version "1.0.4" + resolved "https://registry.yarnpkg.com/grapheme-splitter/-/grapheme-splitter-1.0.4.tgz#9cf3a665c6247479896834af35cf1dbb4400767e" + integrity sha512-bzh50DW9kTPM00T8y4o8vQg89Di9oLJVLW/KaOGIXJWP/iqCN6WKYkbNOF04vFLJhwcpYUh9ydh/+5vpOqV4YQ== has-flag@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-4.0.0.tgz#944771fd9c81c81265c4d6941860da06bb59479b" integrity sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ== -ignore@^4.0.6: - version "4.0.6" - resolved "https://registry.yarnpkg.com/ignore/-/ignore-4.0.6.tgz#750e3db5862087b4737ebac8207ffd1ef27b25fc" - integrity sha512-cyFDKrqc/YdcWFniJhzI42+AzS+gNwmUzOSFcRCQYwySuBBBy/KjuxWLZ/FHEH6Moq1NizMOBWyTcv8O4OZIMg== - -ignore@^5.1.8, ignore@^5.2.0: +ignore@^5.2.0: version "5.2.0" resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.2.0.tgz#6d3bac8fa7fe0d45d9f9be7bac2fc279577e345a" integrity sha512-CmxgYGiEPCLhfLnpPp1MoRmifwEIOgjcHXxOBjv7mY96c+eWScsOP9c112ZyLdWHi0FxHjI+4uVhKYp/gcdRmQ== @@ -708,12 +646,12 @@ import-fresh@^3.0.0, import-fresh@^3.2.1: imurmurhash@^0.1.4: version "0.1.4" resolved "https://registry.yarnpkg.com/imurmurhash/-/imurmurhash-0.1.4.tgz#9218b9b2b928a238b13dc4fb6b6d576f231453ea" - integrity sha1-khi5srkoojixPcT7a21XbyMUU+o= + integrity sha512-JmXMZ6wuvDmLiHEml9ykzqO6lwFbof0GG4IkcGaENdCRDDmMVnny7s5HsIgHCbaq0w2MyPhDqkhTUgS2LU2PHA== inflight@^1.0.4: version "1.0.6" resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9" - integrity sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk= + integrity sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA== dependencies: once "^1.3.0" wrappy "1" @@ -726,14 +664,9 @@ inherits@2: is-extglob@^2.1.1: version "2.1.1" resolved "https://registry.yarnpkg.com/is-extglob/-/is-extglob-2.1.1.tgz#a88c02535791f02ed37c76a1b9ea9773c833f8c2" - integrity sha1-qIwCU1eR8C7TfHahueqXc8gz+MI= + integrity sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ== -is-fullwidth-code-point@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz#f116f8064fe90b3f7844a38997c0b75051269f1d" - integrity sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg== - -is-glob@^4.0.0, is-glob@^4.0.1: +is-glob@^4.0.0, is-glob@^4.0.1, is-glob@^4.0.3: version "4.0.3" resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-4.0.3.tgz#64f61e42cbbb2eec2071a9dac0b28ba1e65d5084" integrity sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg== @@ -748,35 +681,29 @@ is-number@^7.0.0: isexe@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10" - integrity sha1-6PvzdNxVb/iUehDcsFctYz8s+hA= + integrity sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw== -js-tokens@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499" - integrity sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ== +js-sdsl@^4.1.4: + version "4.1.4" + resolved "https://registry.yarnpkg.com/js-sdsl/-/js-sdsl-4.1.4.tgz#78793c90f80e8430b7d8dc94515b6c77d98a26a6" + integrity sha512-Y2/yD55y5jteOAmY50JbUZYwk3CP3wnLPEZnlR1w9oKhITrBEtAxwuWKebFf8hMrPMgbYwFoWK/lH2sBkErELw== -js-yaml@^3.13.1: - version "3.14.1" - resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.14.1.tgz#dae812fdb3825fa306609a8717383c50c36a0537" - integrity sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g== +js-yaml@^4.1.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-4.1.0.tgz#c1fb65f8f5017901cdd2c951864ba18458a10602" + integrity sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA== dependencies: - argparse "^1.0.7" - esprima "^4.0.0" + argparse "^2.0.1" json-schema-traverse@^0.4.1: version "0.4.1" resolved "https://registry.yarnpkg.com/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz#69f6a87d9513ab8bb8fe63bdb0979c448e684660" integrity sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg== -json-schema-traverse@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz#ae7bcb3656ab77a73ba5c49bf654f38e6b6860e2" - integrity sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug== - json-stable-stringify-without-jsonify@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz#9db7b59496ad3f3cfef30a75142d2d930ad72651" - integrity sha1-nbe1lJatPzz+8wp1FC0tkwrXJlE= + integrity sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw== levn@^0.4.1: version "0.4.1" @@ -786,16 +713,18 @@ levn@^0.4.1: prelude-ls "^1.2.1" type-check "~0.4.0" +locate-path@^6.0.0: + version "6.0.0" + resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-6.0.0.tgz#55321eb309febbc59c4801d931a72452a681d286" + integrity sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw== + dependencies: + p-locate "^5.0.0" + lodash.merge@^4.6.2: version "4.6.2" resolved "https://registry.yarnpkg.com/lodash.merge/-/lodash.merge-4.6.2.tgz#558aa53b43b661e1925a0afdfa36a9a1085fe57a" integrity sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ== -lodash.truncate@^4.4.2: - version "4.4.2" - resolved "https://registry.yarnpkg.com/lodash.truncate/-/lodash.truncate-4.4.2.tgz#5a350da0b1113b837ecfffd5812cbe58d6eae193" - integrity sha1-WjUNoLERO4N+z//VgSy+WNbq4ZM= - long@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/long/-/long-4.0.0.tgz#9a7b71cfb7d361a194ea555241c92f7468d5bf28" @@ -814,14 +743,14 @@ merge2@^1.3.0, merge2@^1.4.1: integrity sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg== micromatch@^4.0.4: - version "4.0.4" - resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-4.0.4.tgz#896d519dfe9db25fce94ceb7a500919bf881ebf9" - integrity sha512-pRmzw/XUcwXGpD9aI9q/0XOwLNygjETJ8y0ao0wdqprrzDa4YnxLcz7fQRZr8voh8V10kGhABbNcHVk5wHgWwg== + version "4.0.5" + resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-4.0.5.tgz#bc8999a7cbbf77cdc89f132f6e467051b49090c6" + integrity sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA== dependencies: - braces "^3.0.1" - picomatch "^2.2.3" + braces "^3.0.2" + picomatch "^2.3.1" -minimatch@^3.0.4: +minimatch@^3.0.4, minimatch@^3.1.1, minimatch@^3.1.2: version "3.1.2" resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.1.2.tgz#19cd194bfd3e428f049a70817c038d89ab4be35b" integrity sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw== @@ -836,12 +765,12 @@ ms@2.1.2: natural-compare@^1.4.0: version "1.4.0" resolved "https://registry.yarnpkg.com/natural-compare/-/natural-compare-1.4.0.tgz#4abebfeed7541f2c27acfb29bdbbd15c8d5ba4f7" - integrity sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc= + integrity sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw== once@^1.3.0: version "1.4.0" resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1" - integrity sha1-WDsap3WWHUsROsF9nFC6753Xa9E= + integrity sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w== dependencies: wrappy "1" @@ -857,6 +786,20 @@ optionator@^0.9.1: type-check "^0.4.0" word-wrap "^1.2.3" +p-limit@^3.0.2: + version "3.1.0" + resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-3.1.0.tgz#e1daccbe78d0d1388ca18c64fea38e3e57e3706b" + integrity sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ== + dependencies: + yocto-queue "^0.1.0" + +p-locate@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/p-locate/-/p-locate-5.0.0.tgz#83c8315c6785005e3bd021839411c9e110e6d834" + integrity sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw== + dependencies: + p-limit "^3.0.2" + parent-module@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/parent-module/-/parent-module-1.0.1.tgz#691d2709e78c79fae3a156622452d00762caaaa2" @@ -864,10 +807,15 @@ parent-module@^1.0.0: dependencies: callsites "^3.0.0" +path-exists@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-4.0.0.tgz#513bdbe2d3b95d7762e8c1137efa195c6c61b5b3" + integrity sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w== + path-is-absolute@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f" - integrity sha1-F0uSaHNVNP+8es5r9TpanhtcX18= + integrity sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg== path-key@^3.1.0: version "3.1.1" @@ -879,7 +827,7 @@ path-type@^4.0.0: resolved "https://registry.yarnpkg.com/path-type/-/path-type-4.0.0.tgz#84ed01c0a7ba380afe09d90a8c180dcd9d03043b" integrity sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw== -picomatch@^2.2.3: +picomatch@^2.3.1: version "2.3.1" resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.3.1.tgz#3ba3833733646d9d3e4995946c1365a67fb07a42" integrity sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA== @@ -889,11 +837,6 @@ prelude-ls@^1.2.1: resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.2.1.tgz#debc6489d7a6e6b0e7611888cec880337d316396" integrity sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g== -progress@^2.0.0: - version "2.0.3" - resolved "https://registry.yarnpkg.com/progress/-/progress-2.0.3.tgz#7e8cf8d8f5b8f239c1bc68beb4eb78567d572ef8" - integrity sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA== - protobufjs@6.8.8: version "6.8.8" resolved "https://registry.yarnpkg.com/protobufjs/-/protobufjs-6.8.8.tgz#c8b4f1282fd7a90e6f5b109ed11c84af82908e7c" @@ -923,16 +866,11 @@ queue-microtask@^1.2.2: resolved "https://registry.yarnpkg.com/queue-microtask/-/queue-microtask-1.2.3.tgz#4929228bbc724dfac43e0efb058caf7b6cfb6243" integrity sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A== -regexpp@^3.1.0: +regexpp@^3.2.0: version "3.2.0" resolved "https://registry.yarnpkg.com/regexpp/-/regexpp-3.2.0.tgz#0425a2768d8f23bad70ca4b90461fa2f1213e1b2" integrity sha512-pq2bWo9mVD43nbts2wGv17XLiNLya+GklZ8kaDLV2Z08gDCsGpnKn9BFMepvWuHCbyVvY7J5o5+BVvoQbmlJLg== -require-from-string@^2.0.2: - version "2.0.2" - resolved "https://registry.yarnpkg.com/require-from-string/-/require-from-string-2.0.2.tgz#89a7fdd938261267318eafe14f9c32e598c36909" - integrity sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw== - resolve-from@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-4.0.0.tgz#4abcd852ad32dd7baabfe9b40e00a36db5f392e6" @@ -950,10 +888,10 @@ rimraf@^3.0.2: dependencies: glob "^7.1.3" -rollup@^2.78.0: - version "2.78.0" - resolved "https://registry.yarnpkg.com/rollup/-/rollup-2.78.0.tgz#00995deae70c0f712ea79ad904d5f6b033209d9e" - integrity sha512-4+YfbQC9QEVvKTanHhIAFVUFSRsezvQF8vFOJwtGfb9Bb+r014S+qryr9PSmw8x6sMnPkmFBGAvIFVQxvJxjtg== +rollup@^2.79.0: + version "2.79.0" + resolved "https://registry.yarnpkg.com/rollup/-/rollup-2.79.0.tgz#9177992c9f09eb58c5e56cbfa641607a12b57ce2" + integrity sha512-x4KsrCgwQ7ZJPcFA/SUu6QVcYlO7uRLfLAy0DSA4NS2eG8japdbpM50ToH7z4iObodRYOJ0soneF0iaQRJ6zhA== optionalDependencies: fsevents "~2.3.2" @@ -969,10 +907,10 @@ semver@5.6.0: resolved "https://registry.yarnpkg.com/semver/-/semver-5.6.0.tgz#7e74256fbaa49c75aa7c7a205cc22799cac80004" integrity sha512-RS9R6R35NYgQn++fkDWaOmqGoj4Ek9gGs+DPxNUZKuwE183xjJroKvyo1IzVFeXvUrvmALy6FWD5xrdJT25gMg== -semver@^7.2.1, semver@^7.3.5: - version "7.3.5" - resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.5.tgz#0b621c879348d8998e4b0e4be94b3f12e6018ef7" - integrity sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ== +semver@^7.3.7: + version "7.3.7" + resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.7.tgz#12c5b649afdbf9049707796e22a4028814ce523f" + integrity sha512-QlYTucUYOews+WeEujDoEGziz4K6c47V/Bd+LjSSYcA94p+DmINdf7ncaUinThfvZyu13lN9OY1XDxt8C0Tw0g== dependencies: lru-cache "^6.0.0" @@ -993,15 +931,6 @@ slash@^3.0.0: resolved "https://registry.yarnpkg.com/slash/-/slash-3.0.0.tgz#6539be870c165adbd5240220dbe361f1bc4d4634" integrity sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q== -slice-ansi@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/slice-ansi/-/slice-ansi-4.0.0.tgz#500e8dd0fd55b05815086255b3195adf2a45fe6b" - integrity sha512-qMCMfhY040cVHT43K9BFygqYbUPFZKHOg7K73mtTWJRb8pyP3fzf4Ixd5SzdEJQ6MRUg/WBnOLxghZtKKurENQ== - dependencies: - ansi-styles "^4.0.0" - astral-regex "^2.0.0" - is-fullwidth-code-point "^3.0.0" - source-map-support@0.5.9: version "0.5.9" resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.9.tgz#41bc953b2534267ea2d605bccfa7bfa3111ced5f" @@ -1015,21 +944,7 @@ source-map@^0.6.0: resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263" integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g== -sprintf-js@~1.0.2: - version "1.0.3" - resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c" - integrity sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw= - -string-width@^4.2.3: - version "4.2.3" - resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" - integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== - dependencies: - emoji-regex "^8.0.0" - is-fullwidth-code-point "^3.0.0" - strip-ansi "^6.0.1" - -strip-ansi@^6.0.0, strip-ansi@^6.0.1: +strip-ansi@^6.0.1: version "6.0.1" resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== @@ -1041,13 +956,6 @@ strip-json-comments@^3.1.0, strip-json-comments@^3.1.1: resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-3.1.1.tgz#31f1281b3832630434831c310c01cccda8cbe006" integrity sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig== -supports-color@^5.3.0: - version "5.5.0" - resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-5.5.0.tgz#e2e69a44ac8772f78a1ec0b35b689df6530efc8f" - integrity sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow== - dependencies: - has-flag "^3.0.0" - supports-color@^7.1.0: version "7.2.0" resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-7.2.0.tgz#1b7dcdcb32b8138801b3e478ba6a51caa89648da" @@ -1055,21 +963,10 @@ supports-color@^7.1.0: dependencies: has-flag "^4.0.0" -table@^6.0.9: - version "6.8.0" - resolved "https://registry.yarnpkg.com/table/-/table-6.8.0.tgz#87e28f14fa4321c3377ba286f07b79b281a3b3ca" - integrity sha512-s/fitrbVeEyHKFa7mFdkuQMWlH1Wgw/yEXMt5xACT4ZpzWFluehAxRtUUQKPuWhaLAWhFcVx6w3oC8VKaUfPGA== - dependencies: - ajv "^8.0.1" - lodash.truncate "^4.4.2" - slice-ansi "^4.0.0" - string-width "^4.2.3" - strip-ansi "^6.0.1" - text-table@^0.2.0: version "0.2.0" resolved "https://registry.yarnpkg.com/text-table/-/text-table-0.2.0.tgz#7f5ee823ae805207c00af2df4a84ec3fcfa570b4" - integrity sha1-f17oI66AUgfACvLfSoTsP8+lcLQ= + integrity sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw== to-regex-range@^5.0.1: version "5.0.1" @@ -1102,10 +999,10 @@ type-fest@^0.20.2: resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.20.2.tgz#1bf207f4b28f91583666cb5fbd327887301cd5f4" integrity sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ== -typescript@^4.5.5: - version "4.6.2" - resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.6.2.tgz#fe12d2727b708f4eef40f51598b3398baa9611d4" - integrity sha512-HM/hFigTBHZhLXshn9sN37H085+hQGeJHJ/X7LpBWLID/fbc2acUMfU+lGD98X81sKP+pFa9f0DZmCwB9GnbAg== +typescript@^4.8.3: + version "4.8.3" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.8.3.tgz#d59344522c4bc464a65a730ac695007fdb66dd88" + integrity sha512-goMHfm00nWPa8UvR/CPSvykqf6dVV8x/dp0c5mFTMTIu0u0FlGWRioyy7Nn0PGAdHxpJZnuO/ut+PpQ8UiHAig== uri-js@^4.2.2: version "4.4.1" @@ -1114,11 +1011,6 @@ uri-js@^4.2.2: dependencies: punycode "^2.1.0" -v8-compile-cache@^2.0.3: - version "2.3.0" - resolved "https://registry.yarnpkg.com/v8-compile-cache/-/v8-compile-cache-2.3.0.tgz#2de19618c66dc247dcfb6f99338035d8245a2cee" - integrity sha512-l8lCEmLcLYZh4nbunNZvQCJc5pv7+RCwa8q/LdUx8u7lsWvPDKmpodJAJNwkAhJC//dFY48KuIEmjtd4RViDrA== - which@^2.0.1: version "2.0.2" resolved "https://registry.yarnpkg.com/which/-/which-2.0.2.tgz#7c6a8dd0a636a0327e10b59c9286eee93f3f51b1" @@ -1134,9 +1026,14 @@ word-wrap@^1.2.3: wrappy@1: version "1.0.2" resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" - integrity sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8= + integrity sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ== yallist@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/yallist/-/yallist-4.0.0.tgz#9bb92790d9c0effec63be73519e11a35019a3a72" integrity sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A== + +yocto-queue@^0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/yocto-queue/-/yocto-queue-0.1.0.tgz#0294eb3dee05028d31ee1a5fa2c556a6aaf10a1b" + integrity sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==