From e93f88b97590b446e84037861ae38208e9bca84d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Harrtell?= Date: Tue, 4 Oct 2022 19:59:23 +0200 Subject: [PATCH 01/39] [TS/JS] Entry point per namespace --- .github/workflows/build.yml | 8 +- include/flatbuffers/idl.h | 6 +- package.json | 20 +- rollup.config.js | 8 - scripts/generate_code.py | 2 +- src/flatc.cpp | 11 +- src/idl_gen_ts.cpp | 243 +- tests/my-game/example/ability.js | 54 - tests/my-game/example/ability.ts | 77 - .../my-game/example/any-ambiguous-aliases.js | 27 - .../my-game/example/any-ambiguous-aliases.ts | 38 - tests/my-game/example/any-unique-aliases.js | 29 - tests/my-game/example/any-unique-aliases.ts | 40 - tests/my-game/example/any.js | 29 - tests/my-game/example/any.ts | 40 - tests/my-game/example/color.js | 17 - tests/my-game/example/color.ts | 19 - tests/my-game/example/long-enum.ts | 7 - tests/my-game/example/monster.js | 1125 -------- tests/my-game/example/monster.ts | 1434 ---------- tests/my-game/example/race.js | 8 - tests/my-game/example/race.ts | 8 - tests/my-game/example/referrable.js | 70 - tests/my-game/example/referrable.ts | 95 - tests/my-game/example/stat.js | 99 - tests/my-game/example/stat.ts | 138 - .../example/struct-of-structs-of-structs.ts | 74 - tests/my-game/example/struct-of-structs.js | 62 - tests/my-game/example/struct-of-structs.ts | 88 - .../example/test-simple-table-with-enum.js | 71 - .../example/test-simple-table-with-enum.ts | 96 - tests/my-game/example/test.js | 55 - tests/my-game/example/test.ts | 78 - tests/my-game/example/type-aliases.js | 290 -- tests/my-game/example/type-aliases.ts | 405 --- tests/my-game/example/vec3.js | 98 - tests/my-game/example/vec3.ts | 137 - tests/my-game/example2/monster.js | 50 - tests/my-game/example2/monster.ts | 66 - tests/my-game/in-parent-namespace.js | 50 - tests/my-game/in-parent-namespace.ts | 66 - .../namespace-b/enum-in-nested-n-s.js | 7 - .../namespace-b/struct-in-nested-n-s.js | 54 - .../namespace-b/struct-in-nested-n-s.ts | 77 - .../namespace-b/table-in-nested-n-s.js | 64 - .../namespace-b/table-in-nested-n-s.ts | 87 - .../namespace-b/union-in-nested-n-s.js | 21 - .../namespace-b/union-in-nested-n-s.ts | 33 - .../namespace-a/second-table-in-a.js | 58 - .../namespace-a/second-table-in-a.ts | 79 - .../namespace-a/table-in-first-n-s.js | 119 - .../namespace-a/table-in-first-n-s.ts | 150 -- .../namespace_test/namespace-c/table-in-c.js | 67 - .../namespace_test/namespace-c/table-in-c.ts | 90 - tests/namespace_test/namespace_test1.ts | 3 - tests/namespace_test/namespace_test2.ts | 7 - tests/optional-scalars/scalar-stuff.ts | 423 --- tests/optional_scalars/optional-byte.js | 7 - tests/optional_scalars/optional-byte.ts | 8 - tests/optional_scalars/scalar-stuff.js | 341 --- tests/optional_scalars/scalar-stuff.ts | 423 --- tests/ts/JavaScriptTestv1.cjs | 367 +++ tests/ts/TypeScriptTest.py | 24 +- ...nsitive_include_generated.ts => foobar.ts} | 6 +- tests/ts/foobar/abc.js | 2 +- tests/ts/foobar/class.js | 2 +- tests/ts/monster_test.js | 20 +- tests/ts/monster_test.ts | 21 +- tests/ts/monster_test_generated.js | 2336 +++++++++++++++++ tests/ts/monster_test_generated.ts | 19 - tests/ts/monster_test_grpc.d.ts | 94 - tests/ts/monster_test_grpc.js | 80 - tests/ts/my-game.js | 5 + tests/ts/my-game.ts | 6 + tests/ts/my-game/example.js | 17 + tests/ts/my-game/example.ts | 8 + .../my-game/example/any-ambiguous-aliases.js | 2 +- .../ts/my-game/example/any-unique-aliases.js | 2 +- tests/ts/my-game/example/any.js | 2 +- tests/ts/my-game/example/color.js | 2 +- tests/ts/my-game/example/long-enum.js | 2 +- tests/ts/my-game/example/race.js | 2 +- .../example/struct-of-structs-of-structs.js | 3 +- tests/ts/my-game/example/struct-of-structs.js | 3 +- tests/ts/my-game/example/vec3.js | 3 +- .../my-game/example2.js} | 7 +- .../my-game/example2.ts} | 7 +- tests/ts/my-game/other-name-space.js | 4 + tests/ts/my-game/other-name-space.ts | 5 + .../my-game/other-name-space/from-include.js | 5 + .../other-name-space/from-include.ts} | 6 +- tests/ts/my-game/other-name-space/table-b.js | 64 + tests/ts/my-game/other-name-space/table-b.ts | 87 + .../my-game/other-name-space/unused.js} | 24 +- .../my-game/other-name-space/unused.ts} | 32 +- ...alars_generated.ts => optional-scalars.ts} | 0 tests/ts/optional_scalars.ts | 1 - tests/ts/reflection.ts | 14 + tests/ts/reflection/base-type.js | 2 +- tests/ts/table-a.js | 64 + tests/ts/table-a.ts | 87 + tests/ts/tsconfig.json | 15 +- tests/ts/typescript.ts | 4 + tests/ts/typescript/class.js | 2 +- tests/ts/typescript_include_generated.js | 43 +- tests/ts/typescript_keywords_generated.js | 1975 ++++++++++++-- tests/ts/typescript_keywords_generated.ts | 226 -- ...typescript_transitive_include_generated.js | 36 +- tests/ts/union_vector.ts | 10 + tests/ts/union_vector/character.js | 2 +- tests/ts/union_vector/gadget.js | 2 +- .../ts/union_vector/union_vector_generated.js | 557 +++- .../ts/union_vector/union_vector_generated.ts | 10 - tests/union_vector/attacker.js | 64 - tests/union_vector/attacker.ts | 87 - tests/union_vector/book-reader.js | 44 - tests/union_vector/book-reader.ts | 63 - tests/union_vector/character.js | 38 - tests/union_vector/character.ts | 49 - tests/union_vector/falling-tub.ts | 63 - tests/union_vector/gadget.ts | 36 - tests/union_vector/hand-fan.ts | 87 - tests/union_vector/movie.js | 185 -- tests/union_vector/movie.ts | 211 -- tests/union_vector/union_vector.js | 8 - tests/union_vector/union_vector.ts | 8 - tests/union_vector/union_vector_generated.ts | 10 - ts/BUILD.bazel | 2 +- ts/flatbuffers.ts | 13 +- ts/index.ts | 12 - tsconfig.json | 7 +- tsconfig.mjs.json | 7 +- typescript.bzl | 1 - yarn.lock | 150 +- 134 files changed, 5884 insertions(+), 9036 deletions(-) delete mode 100644 rollup.config.js delete mode 100644 tests/my-game/example/ability.js delete mode 100644 tests/my-game/example/ability.ts delete mode 100644 tests/my-game/example/any-ambiguous-aliases.js delete mode 100644 tests/my-game/example/any-ambiguous-aliases.ts delete mode 100644 tests/my-game/example/any-unique-aliases.js delete mode 100644 tests/my-game/example/any-unique-aliases.ts delete mode 100644 tests/my-game/example/any.js delete mode 100644 tests/my-game/example/any.ts delete mode 100644 tests/my-game/example/color.js delete mode 100644 tests/my-game/example/color.ts delete mode 100644 tests/my-game/example/long-enum.ts delete mode 100644 tests/my-game/example/monster.js delete mode 100644 tests/my-game/example/monster.ts delete mode 100644 tests/my-game/example/race.js delete mode 100644 tests/my-game/example/race.ts delete mode 100644 tests/my-game/example/referrable.js delete mode 100644 tests/my-game/example/referrable.ts delete mode 100644 tests/my-game/example/stat.js delete mode 100644 tests/my-game/example/stat.ts delete mode 100644 tests/my-game/example/struct-of-structs-of-structs.ts delete mode 100644 tests/my-game/example/struct-of-structs.js delete mode 100644 tests/my-game/example/struct-of-structs.ts delete mode 100644 tests/my-game/example/test-simple-table-with-enum.js delete mode 100644 tests/my-game/example/test-simple-table-with-enum.ts delete mode 100644 tests/my-game/example/test.js delete mode 100644 tests/my-game/example/test.ts delete mode 100644 tests/my-game/example/type-aliases.js delete mode 100644 tests/my-game/example/type-aliases.ts delete mode 100644 tests/my-game/example/vec3.js delete mode 100644 tests/my-game/example/vec3.ts delete mode 100644 tests/my-game/example2/monster.js delete mode 100644 tests/my-game/example2/monster.ts delete mode 100644 tests/my-game/in-parent-namespace.js delete mode 100644 tests/my-game/in-parent-namespace.ts delete mode 100644 tests/namespace_test/namespace-a/namespace-b/enum-in-nested-n-s.js delete mode 100644 tests/namespace_test/namespace-a/namespace-b/struct-in-nested-n-s.js delete mode 100644 tests/namespace_test/namespace-a/namespace-b/struct-in-nested-n-s.ts delete mode 100644 tests/namespace_test/namespace-a/namespace-b/table-in-nested-n-s.js delete mode 100644 tests/namespace_test/namespace-a/namespace-b/table-in-nested-n-s.ts delete mode 100644 tests/namespace_test/namespace-a/namespace-b/union-in-nested-n-s.js delete mode 100644 tests/namespace_test/namespace-a/namespace-b/union-in-nested-n-s.ts delete mode 100644 tests/namespace_test/namespace-a/second-table-in-a.js delete mode 100644 tests/namespace_test/namespace-a/second-table-in-a.ts delete mode 100644 tests/namespace_test/namespace-a/table-in-first-n-s.js delete mode 100644 tests/namespace_test/namespace-a/table-in-first-n-s.ts delete mode 100644 tests/namespace_test/namespace-c/table-in-c.js delete mode 100644 tests/namespace_test/namespace-c/table-in-c.ts delete mode 100644 tests/namespace_test/namespace_test1.ts delete mode 100644 tests/namespace_test/namespace_test2.ts delete mode 100644 tests/optional-scalars/scalar-stuff.ts delete mode 100644 tests/optional_scalars/optional-byte.js delete mode 100644 tests/optional_scalars/optional-byte.ts delete mode 100644 tests/optional_scalars/scalar-stuff.js delete mode 100644 tests/optional_scalars/scalar-stuff.ts create mode 100644 tests/ts/JavaScriptTestv1.cjs rename tests/ts/{typescript_transitive_include_generated.ts => foobar.ts} (64%) create mode 100644 tests/ts/monster_test_generated.js delete mode 100644 tests/ts/monster_test_generated.ts delete mode 100644 tests/ts/monster_test_grpc.d.ts delete mode 100644 tests/ts/monster_test_grpc.js create mode 100644 tests/ts/my-game.js create mode 100644 tests/ts/my-game.ts create mode 100644 tests/ts/my-game/example.js create mode 100644 tests/ts/my-game/example.ts rename tests/{optional-scalars/optional-byte.ts => ts/my-game/example2.js} (52%) rename tests/{namespace_test/namespace-a/namespace-b/enum-in-nested-n-s.ts => ts/my-game/example2.ts} (55%) create mode 100644 tests/ts/my-game/other-name-space.js create mode 100644 tests/ts/my-game/other-name-space.ts create mode 100644 tests/ts/my-game/other-name-space/from-include.js rename tests/ts/{typescript_include_generated.ts => my-game/other-name-space/from-include.ts} (61%) create mode 100644 tests/ts/my-game/other-name-space/table-b.js create mode 100644 tests/ts/my-game/other-name-space/table-b.ts rename tests/{union_vector/rapunzel.js => ts/my-game/other-name-space/unused.js} (57%) rename tests/{union_vector/rapunzel.ts => ts/my-game/other-name-space/unused.ts} (50%) rename tests/ts/{optional_scalars_generated.ts => optional-scalars.ts} (100%) delete mode 100644 tests/ts/optional_scalars.ts create mode 100644 tests/ts/reflection.ts create mode 100644 tests/ts/table-a.js create mode 100644 tests/ts/table-a.ts create mode 100644 tests/ts/typescript.ts delete mode 100644 tests/ts/typescript_keywords_generated.ts create mode 100644 tests/ts/union_vector.ts delete mode 100644 tests/ts/union_vector/union_vector_generated.ts delete mode 100644 tests/union_vector/attacker.js delete mode 100644 tests/union_vector/attacker.ts delete mode 100644 tests/union_vector/book-reader.js delete mode 100644 tests/union_vector/book-reader.ts delete mode 100644 tests/union_vector/character.js delete mode 100644 tests/union_vector/character.ts delete mode 100644 tests/union_vector/falling-tub.ts delete mode 100644 tests/union_vector/gadget.ts delete mode 100644 tests/union_vector/hand-fan.ts delete mode 100644 tests/union_vector/movie.js delete mode 100644 tests/union_vector/movie.ts delete mode 100644 tests/union_vector/union_vector.js delete mode 100644 tests/union_vector/union_vector.ts delete mode 100644 tests/union_vector/union_vector_generated.ts delete mode 100644 ts/index.ts diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ae700e2b61f..ed14f87c5b0 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -39,7 +39,9 @@ jobs: chmod +x flatc ./flatc --version - name: flatc tests - run: python3 tests/flatc/main.py + run: | + yarn global add esbuild + python3 tests/flatc/main.py - name: upload build artifacts uses: actions/upload-artifact@v1 with: @@ -462,7 +464,9 @@ jobs: run: yarn compile - name: test working-directory: tests/ts - run: python3 TypeScriptTest.py + run: | + yarn global add esbuild + python3 TypeScriptTest.py build-dart: name: Build Dart diff --git a/include/flatbuffers/idl.h b/include/flatbuffers/idl.h index 4044828128d..77dc41efd5e 100644 --- a/include/flatbuffers/idl.h +++ b/include/flatbuffers/idl.h @@ -642,7 +642,8 @@ struct IDLOptions { bool json_nested_flatbuffers; bool json_nested_flexbuffers; bool json_nested_legacy_flatbuffers; - bool ts_flat_file; + bool ts_flat_files; + bool ts_entry_points; bool no_leak_private_annotations; bool require_json_eof; @@ -745,7 +746,8 @@ struct IDLOptions { json_nested_flatbuffers(true), json_nested_flexbuffers(true), json_nested_legacy_flatbuffers(false), - ts_flat_file(false), + ts_flat_files(false), + ts_entry_points(false), no_leak_private_annotations(false), require_json_eof(true), mini_reflect(IDLOptions::kNone), diff --git a/package.json b/package.json index 3f811324e9f..101e8ed1474 100644 --- a/package.json +++ b/package.json @@ -9,8 +9,20 @@ "mjs/**/*.d.ts", "ts/**/*.ts" ], - "main": "js/index.js", - "module": "mjs/index.js", + "main": "js/flatbuffers.js", + "module": "mjs/flatbuffers.js", + "exports": { + ".": { + "node": { + "import": "./mjs/flatbuffers.js", + "require": "./js/flatbuffers.js" + }, + "default": "./js/flatbuffers.js" + }, + "./js/flexbuffers.js": { + "default": "./js/flexbuffers.js" + } + }, "directories": { "doc": "docs", "test": "tests" @@ -18,7 +30,7 @@ "scripts": { "test": "npm run compile && cd tests/ts && python3 ./TypeScriptTest.py", "lint": "eslint ts", - "compile": "tsc && tsc -p tsconfig.mjs.json && rollup -c", + "compile": "tsc && tsc -p tsconfig.mjs.json && esbuild js/flatbuffers.js --minify --global-name=flatbuffers --bundle --outfile=js/flatbuffers.min.js", "prepublishOnly": "npm install --only=dev && npm run compile" }, "repository": { @@ -40,8 +52,8 @@ "@types/node": "18.7.16", "@typescript-eslint/eslint-plugin": "^5.36.2", "@typescript-eslint/parser": "^5.36.2", + "esbuild": "^0.15.10", "eslint": "^8.23.1", - "rollup": "^2.79.0", "typescript": "^4.8.3" } } diff --git a/rollup.config.js b/rollup.config.js deleted file mode 100644 index 9369655e636..00000000000 --- a/rollup.config.js +++ /dev/null @@ -1,8 +0,0 @@ -export default { - input: 'mjs/index.js', - output: { - file: 'flatbuffers.js', - format: 'iife', - name: 'flatbuffers' - } -} \ No newline at end of file diff --git a/scripts/generate_code.py b/scripts/generate_code.py index dd84cfdfb0f..aa990c1d9e5 100755 --- a/scripts/generate_code.py +++ b/scripts/generate_code.py @@ -263,7 +263,7 @@ def glob(path, pattern): # Generate the complete flat file TS of monster. flatc( - ["--ts", "--gen-all", "--ts-flat-files"], + ["--ts", "--gen-all"], include="include_test", schema="monster_test.fbs", prefix="ts/ts-flat-files" diff --git a/src/flatc.cpp b/src/flatc.cpp index deb45ec88f3..415742af479 100644 --- a/src/flatc.cpp +++ b/src/flatc.cpp @@ -220,7 +220,9 @@ const static FlatCOption options[] = { "Allow a nested_flatbuffer field to be parsed as a vector of bytes " "in JSON, which is unsafe unless checked by a verifier afterwards." }, { "", "ts-flat-files", "", - "Only generated one typescript file per .fbs file." }, + "Generate a single typescript file per .fbs file. Implies ts_entry_points." }, + { "", "ts-entry-points", "", + "Generate entry point typescript per namespace. Implies gen-all." }, { "", "annotate", "SCHEMA", "Annotate the provided BINARY_FILE with the specified SCHEMA file." }, { "", "no-leak-private-annotation", "", @@ -602,7 +604,12 @@ int FlatCompiler::Compile(int argc, const char **argv) { } else if (arg == "--json-nested-bytes") { opts.json_nested_legacy_flatbuffers = true; } else if (arg == "--ts-flat-files") { - opts.ts_flat_file = true; + opts.ts_flat_files = true; + opts.ts_entry_points = true; + opts.generate_all = true; + } else if (arg == "--ts-entry-points") { + opts.ts_entry_points = true; + opts.generate_all = true; } else if (arg == "--no-leak-private-annotation") { opts.no_leak_private_annotations = true; } else if (arg == "--annotate") { diff --git a/src/idl_gen_ts.cpp b/src/idl_gen_ts.cpp index 9fd1203f588..01f6e477b24 100644 --- a/src/idl_gen_ts.cpp +++ b/src/idl_gen_ts.cpp @@ -39,6 +39,14 @@ struct ImportDefinition { const Definition *dependency = nullptr; }; +struct NsDefinition { + std::string path; + std::string filepath; + std::string symbolic_name; + const Namespace *ns; + std::map definitions; +}; + Namer::Config TypeScriptDefaultConfig() { return { /*types=*/Case::kKeep, /*constants=*/Case::kUnknown, @@ -102,33 +110,26 @@ class TsGenerator : public BaseGenerator { generateEnums(); generateStructs(); generateEntry(); + if (!generateBundle()) return false; return true; } - bool IncludeNamespace() const { - // When generating a single flat file and all its includes, namespaces are - // important to avoid type name clashes. - return parser_.opts.ts_flat_file && parser_.opts.generate_all; - } - std::string GetTypeName(const EnumDef &def, const bool = false, const bool force_ns_wrap = false) { - if (IncludeNamespace() || force_ns_wrap) { - return namer_.NamespacedType(def); - } + if (force_ns_wrap) { return namer_.NamespacedType(def); } return namer_.Type(def); } std::string GetTypeName(const StructDef &def, const bool object_api = false, const bool force_ns_wrap = false) { if (object_api && parser_.opts.generate_object_based_api) { - if (IncludeNamespace() || force_ns_wrap) { + if (force_ns_wrap) { return namer_.NamespacedObjectType(def); } else { return namer_.ObjectType(def); } } else { - if (IncludeNamespace() || force_ns_wrap) { + if (force_ns_wrap) { return namer_.NamespacedType(def); } else { return namer_.Type(def); @@ -144,58 +145,60 @@ class TsGenerator : public BaseGenerator { std::string code; - if (!parser_.opts.ts_flat_file) { - code += "// " + std::string(FlatBuffersGeneratedWarning()) + "\n\n"; + code += "// " + std::string(FlatBuffersGeneratedWarning()) + "\n\n"; - for (auto it = bare_imports.begin(); it != bare_imports.end(); it++) { - code += it->second.import_statement + "\n"; - } - if (!bare_imports.empty()) code += "\n"; + for (auto it = bare_imports.begin(); it != bare_imports.end(); it++) { + code += it->second.import_statement + "\n"; + } + if (!bare_imports.empty()) code += "\n"; - for (auto it = imports.begin(); it != imports.end(); it++) { - if (it->second.dependency != &definition) { - code += it->second.import_statement + "\n"; - } + for (auto it = imports.begin(); it != imports.end(); it++) { + if (it->second.dependency != &definition) { + code += it->second.import_statement + "\n"; } - if (!imports.empty()) code += "\n\n"; } + if (!imports.empty()) code += "\n\n"; code += class_code; - if (parser_.opts.ts_flat_file) { - flat_file_ += code; - flat_file_ += "\n"; - flat_file_definitions_.insert(&definition); - return true; - } else { - auto dirs = namer_.Directories(*definition.defined_namespace); - EnsureDirExists(dirs); - auto basename = dirs + namer_.File(definition, SkipFile::Suffix); + auto dirs = namer_.Directories(*definition.defined_namespace); + EnsureDirExists(dirs); + auto basename = dirs + namer_.File(definition, SkipFile::Suffix); + + return SaveFile(basename.c_str(), code, false); + } - return SaveFile(basename.c_str(), code, false); + void TrackNsDef(const Definition &definition, std::string type_name) { + std::string path; + std::string filepath; + std::string symbolic_name; + if (definition.defined_namespace->components.size() > 0) { + path = namer_.Directories(*definition.defined_namespace, + SkipDir::OutputPathAndTrailingPathSeparator); + filepath = path + ".ts"; + symbolic_name = definition.defined_namespace->components.back(); + } else { + auto def_mod_name = namer_.File(definition, SkipFile::SuffixAndExtension); + symbolic_name = file_name_; + filepath = symbolic_name + ".ts"; + } + if (ns_defs_.count(path) == 0) { + NsDefinition nsDef; + nsDef.path = path; + nsDef.filepath = filepath; + nsDef.ns = definition.defined_namespace; + nsDef.definitions.insert(std::make_pair(type_name, &definition)); + nsDef.symbolic_name = symbolic_name; + ns_defs_[path] = nsDef; + } else { + ns_defs_[path].definitions.insert(std::make_pair(type_name, &definition)); } } private: IdlNamer namer_; - import_set imports_all_; - - // The following three members are used when generating typescript code into a - // single file rather than creating separate files for each type. - - // flat_file_ contains the aggregated contents of the file prior to being - // written to disk. - std::string flat_file_; - // flat_file_definitions_ tracks which types have been written to flat_file_. - std::unordered_set flat_file_definitions_; - // This maps from import names to types to import. - std::map> - flat_file_import_declarations_; - // For flat file codegen, tracks whether we need to import the flatbuffers - // library itself (not necessary for files that solely consist of enum - // definitions). - bool import_flatbuffers_lib_ = false; + std::map ns_defs_; // Generate code for all enums. void generateEnums() { @@ -207,8 +210,9 @@ class TsGenerator : public BaseGenerator { auto &enum_def = **it; GenEnum(enum_def, &enumcode, imports, false); GenEnum(enum_def, &enumcode, imports, true); + std::string type_name = GetTypeName(enum_def); + TrackNsDef(enum_def, type_name); SaveType(enum_def, enumcode, imports, bare_imports); - imports_all_.insert(imports.begin(), imports.end()); } } @@ -219,68 +223,91 @@ class TsGenerator : public BaseGenerator { import_set bare_imports; import_set imports; AddImport(bare_imports, "* as flatbuffers", "flatbuffers"); - import_flatbuffers_lib_ = true; auto &struct_def = **it; std::string declcode; GenStruct(parser_, struct_def, &declcode, imports); + std::string type_name = GetTypeName(struct_def); + TrackNsDef(struct_def, type_name); SaveType(struct_def, declcode, imports, bare_imports); - imports_all_.insert(imports.begin(), imports.end()); } } // Generate code for a single entry point module. void generateEntry() { - std::string code = - "// " + std::string(FlatBuffersGeneratedWarning()) + "\n\n"; - if (parser_.opts.ts_flat_file) { - if (import_flatbuffers_lib_) { - code += "import * as flatbuffers from 'flatbuffers';\n"; - code += "\n"; + std::string code; + + for (const auto &it : ns_defs_) { + code = "// " + std::string(FlatBuffersGeneratedWarning()) + "\n\n"; + + // export all definitions in ns entry point module + int export_counter = 0; + for (const auto &def : it.second.definitions) { + std::vector rel_components; + // build path for root level vs child level + if (it.second.ns->components.size() > 1) + std::copy(it.second.ns->components.begin() + 1, + it.second.ns->components.end(), + std::back_inserter(rel_components)); + else + std::copy(it.second.ns->components.begin(), + it.second.ns->components.end(), + std::back_inserter(rel_components)); + auto base_file_name = + namer_.File(*(def.second), SkipFile::SuffixAndExtension); + auto base_name = + namer_.Directories(it.second.ns->components, SkipDir::None) + + base_file_name; + auto ts_file_path = base_name + ".ts"; + auto base_name_rel = std::string("./"); + base_name_rel += namer_.Directories(rel_components, SkipDir::None); + base_name_rel += base_file_name; + auto ts_file_path_rel = base_name_rel + ".ts"; + auto type_name = def.first; + code += "export { " + type_name + " } from '"; + code += base_name_rel + ".js';\n"; + export_counter++; } - // Only include import statements when not generating all. - if (!parser_.opts.generate_all) { - for (const auto &it : flat_file_import_declarations_) { - // Note that we do end up generating an import for ourselves, which - // should generally be harmless. - // TODO: Make it so we don't generate a self-import; this will also - // require modifying AddImport to ensure that we don't use - // namespace-prefixed names anywhere... - std::string file = it.first; - if (file.empty()) { continue; } - std::string noext = flatbuffers::StripExtension(file); - std::string basename = flatbuffers::StripPath(noext); - std::string include_file = GeneratedFileName( - parser_.opts.include_prefix, - parser_.opts.keep_prefix ? noext : basename, parser_.opts); - // TODO: what is the right behavior when different include flags are - // specified here? Should we always be adding the "./" for a relative - // path or turn it off if --include-prefix is specified, or something - // else? - std::string include_name = - "./" + flatbuffers::StripExtension(include_file); - code += "import {"; - for (const auto &pair : it.second) { - code += namer_.EscapeKeyword(pair.first) + " as " + - namer_.EscapeKeyword(pair.second) + ", "; - } - code.resize(code.size() - 2); - code += "} from '" + include_name + ".js';\n"; - } - code += "\n"; + + // re-export child namespace(s) in parent + const auto child_ns_level = it.second.ns->components.size() + 1; + for (const auto &it2 : ns_defs_) { + if (it2.second.ns->components.size() != child_ns_level) continue; + auto ts_file_path = it2.second.path + ".ts"; + code += "export * as " + it2.second.symbolic_name + " from './"; + code += it2.second.path + ".js';\n"; + export_counter++; } - code += flat_file_; - const std::string filename = - GeneratedFileName(path_, file_name_, parser_.opts); - SaveFile(filename.c_str(), code, false); - } else { - for (auto it = imports_all_.begin(); it != imports_all_.end(); it++) { - code += it->second.export_statement + "\n"; + if (export_counter > 0) SaveFile(it.second.filepath.c_str(), code, false); + } + } + + bool generateBundle() { + if (parser_.opts.ts_flat_files) { + std::string inputpath; + std::string symbolic_name = file_name_; + if (parser_.current_namespace_->components.size() > 0) { + std::string path = + namer_.Directories(*parser_.current_namespace_, + SkipDir::OutputPathAndTrailingPathSeparator); + inputpath = path + ".ts"; + symbolic_name = parser_.current_namespace_->components.back(); + } else { + inputpath = file_name_ + ".ts"; } - const std::string path = + std::string bundlepath = GeneratedFileName(path_, file_name_, parser_.opts); - SaveFile(path.c_str(), code, false); + bundlepath = bundlepath.substr(0, bundlepath.size() - 3) + ".js"; + std::string cmd = "esbuild"; + cmd += " "; + cmd += inputpath; + // cmd += " --minify"; + cmd += " --format=cjs --bundle --outfile="; + cmd += bundlepath; + cmd += " --external:flatbuffers"; + if (system(cmd.c_str()) != 0) return false; } + return true; } // Generate a documentation comment, if available. @@ -832,28 +859,6 @@ class TsGenerator : public BaseGenerator { const std::string object_name = GetTypeName(dependency, /*object_api=*/true, has_name_clash); - if (parser_.opts.ts_flat_file) { - // In flat-file generation, do not attempt to import things from ourselves - // *and* do not wrap namespaces (note that this does override the logic - // above, but since we force all non-self-imports to use namespace-based - // names in flat file generation, it's fine). - if (dependent.file == dependency.file) { - name = import_name; - } else { - const std::string file = - RelativeToRootPath(StripFileName(AbsolutePath(dependent.file)), - dependency.file) - // Strip the leading // - .substr(2); - flat_file_import_declarations_[file][import_name] = name; - - if (parser_.opts.generate_object_based_api && - SupportsObjectAPI::value) { - flat_file_import_declarations_[file][import_name + "T"] = object_name; - } - } - } - const std::string symbols_expression = GenSymbolExpression( dependency, has_name_clash, import_name, name, object_name); diff --git a/tests/my-game/example/ability.js b/tests/my-game/example/ability.js deleted file mode 100644 index 4d7d3db7290..00000000000 --- a/tests/my-game/example/ability.js +++ /dev/null @@ -1,54 +0,0 @@ -// 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/my-game/example/ability.ts b/tests/my-game/example/ability.ts deleted file mode 100644 index 36b0eb8105d..00000000000 --- a/tests/my-game/example/ability.ts +++ /dev/null @@ -1,77 +0,0 @@ -// 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/my-game/example/any-ambiguous-aliases.js b/tests/my-game/example/any-ambiguous-aliases.js deleted file mode 100644 index 7cd2a85b682..00000000000 --- a/tests/my-game/example/any-ambiguous-aliases.js +++ /dev/null @@ -1,27 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify -import { Monster } from '../../my-game/example/monster'; -export var AnyAmbiguousAliases; -(function (AnyAmbiguousAliases) { - AnyAmbiguousAliases[AnyAmbiguousAliases["NONE"] = 0] = "NONE"; - AnyAmbiguousAliases[AnyAmbiguousAliases["M1"] = 1] = "M1"; - AnyAmbiguousAliases[AnyAmbiguousAliases["M2"] = 2] = "M2"; - AnyAmbiguousAliases[AnyAmbiguousAliases["M3"] = 3] = "M3"; -})(AnyAmbiguousAliases || (AnyAmbiguousAliases = {})); -export function unionToAnyAmbiguousAliases(type, accessor) { - switch (AnyAmbiguousAliases[type]) { - case 'NONE': return null; - case 'M1': return accessor(new Monster()); - case 'M2': return accessor(new Monster()); - case 'M3': return accessor(new Monster()); - default: return null; - } -} -export function unionListToAnyAmbiguousAliases(type, accessor, index) { - switch (AnyAmbiguousAliases[type]) { - case 'NONE': return null; - case 'M1': return accessor(index, new Monster()); - case 'M2': return accessor(index, new Monster()); - case 'M3': return accessor(index, new Monster()); - default: return null; - } -} diff --git a/tests/my-game/example/any-ambiguous-aliases.ts b/tests/my-game/example/any-ambiguous-aliases.ts deleted file mode 100644 index fb308fcdc61..00000000000 --- a/tests/my-game/example/any-ambiguous-aliases.ts +++ /dev/null @@ -1,38 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -import { Monster, MonsterT } from '../../my-game/example/monster'; - - -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/my-game/example/any-unique-aliases.js b/tests/my-game/example/any-unique-aliases.js deleted file mode 100644 index 98e559739d3..00000000000 --- a/tests/my-game/example/any-unique-aliases.js +++ /dev/null @@ -1,29 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify -import { Monster as MyGame_Example2_Monster } from '../../my-game/example2/monster'; -import { Monster } from '../../my-game/example/monster'; -import { TestSimpleTableWithEnum } from '../../my-game/example/test-simple-table-with-enum'; -export var AnyUniqueAliases; -(function (AnyUniqueAliases) { - AnyUniqueAliases[AnyUniqueAliases["NONE"] = 0] = "NONE"; - AnyUniqueAliases[AnyUniqueAliases["M"] = 1] = "M"; - AnyUniqueAliases[AnyUniqueAliases["TS"] = 2] = "TS"; - AnyUniqueAliases[AnyUniqueAliases["M2"] = 3] = "M2"; -})(AnyUniqueAliases || (AnyUniqueAliases = {})); -export function unionToAnyUniqueAliases(type, accessor) { - switch (AnyUniqueAliases[type]) { - case 'NONE': return null; - case 'M': return accessor(new Monster()); - case 'TS': return accessor(new TestSimpleTableWithEnum()); - case 'M2': return accessor(new 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/my-game/example/any-unique-aliases.ts b/tests/my-game/example/any-unique-aliases.ts deleted file mode 100644 index 7ca769f1ee5..00000000000 --- a/tests/my-game/example/any-unique-aliases.ts +++ /dev/null @@ -1,40 +0,0 @@ -// 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'; -import { Monster, MonsterT } from '../../my-game/example/monster'; -import { TestSimpleTableWithEnum, TestSimpleTableWithEnumT } from '../../my-game/example/test-simple-table-with-enum'; - - -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/my-game/example/any.js b/tests/my-game/example/any.js deleted file mode 100644 index 47bfb2511a1..00000000000 --- a/tests/my-game/example/any.js +++ /dev/null @@ -1,29 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify -import { Monster as MyGame_Example2_Monster } from '../../my-game/example2/monster'; -import { Monster } from '../../my-game/example/monster'; -import { TestSimpleTableWithEnum } from '../../my-game/example/test-simple-table-with-enum'; -export var Any; -(function (Any) { - Any[Any["NONE"] = 0] = "NONE"; - Any[Any["Monster"] = 1] = "Monster"; - Any[Any["TestSimpleTableWithEnum"] = 2] = "TestSimpleTableWithEnum"; - Any[Any["MyGame_Example2_Monster"] = 3] = "MyGame_Example2_Monster"; -})(Any || (Any = {})); -export function unionToAny(type, accessor) { - switch (Any[type]) { - case 'NONE': return null; - case 'Monster': return accessor(new Monster()); - case 'TestSimpleTableWithEnum': return accessor(new TestSimpleTableWithEnum()); - case 'MyGame_Example2_Monster': return accessor(new 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/my-game/example/any.ts b/tests/my-game/example/any.ts deleted file mode 100644 index f7bb94fe37f..00000000000 --- a/tests/my-game/example/any.ts +++ /dev/null @@ -1,40 +0,0 @@ -// 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'; -import { Monster, MonsterT } from '../../my-game/example/monster'; -import { TestSimpleTableWithEnum, TestSimpleTableWithEnumT } from '../../my-game/example/test-simple-table-with-enum'; - - -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/my-game/example/color.js b/tests/my-game/example/color.js deleted file mode 100644 index f95f75e9677..00000000000 --- a/tests/my-game/example/color.js +++ /dev/null @@ -1,17 +0,0 @@ -// 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/my-game/example/color.ts b/tests/my-game/example/color.ts deleted file mode 100644 index 8ce58da6787..00000000000 --- a/tests/my-game/example/color.ts +++ /dev/null @@ -1,19 +0,0 @@ -// 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/my-game/example/long-enum.ts b/tests/my-game/example/long-enum.ts deleted file mode 100644 index 31ea18805f2..00000000000 --- a/tests/my-game/example/long-enum.ts +++ /dev/null @@ -1,7 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -export enum LongEnum { - LongOne = '2', - LongTwo = '4', - LongBig = '1099511627776' -} diff --git a/tests/my-game/example/monster.js b/tests/my-game/example/monster.js deleted file mode 100644 index f9c8cca5333..00000000000 --- a/tests/my-game/example/monster.js +++ /dev/null @@ -1,1125 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify -import * as flatbuffers from 'flatbuffers'; -import { Ability } from '../../my-game/example/ability'; -import { Any, unionToAny } from '../../my-game/example/any'; -import { AnyAmbiguousAliases, unionToAnyAmbiguousAliases } from '../../my-game/example/any-ambiguous-aliases'; -import { AnyUniqueAliases, unionToAnyUniqueAliases } from '../../my-game/example/any-unique-aliases'; -import { Color } from '../../my-game/example/color'; -import { Race } from '../../my-game/example/race'; -import { Referrable } from '../../my-game/example/referrable'; -import { Stat } from '../../my-game/example/stat'; -import { Test } from '../../my-game/example/test'; -import { Vec3 } from '../../my-game/example/vec3'; -import { InParentNamespace } from '../../my-game/in-parent-namespace'; -/** - * 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/my-game/example/monster.ts b/tests/my-game/example/monster.ts deleted file mode 100644 index d65b7c3a9ab..00000000000 --- a/tests/my-game/example/monster.ts +++ /dev/null @@ -1,1434 +0,0 @@ -// 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'; -import { Ability, AbilityT } from '../../my-game/example/ability'; -import { Any, unionToAny, unionListToAny } from '../../my-game/example/any'; -import { AnyAmbiguousAliases, unionToAnyAmbiguousAliases, unionListToAnyAmbiguousAliases } from '../../my-game/example/any-ambiguous-aliases'; -import { AnyUniqueAliases, unionToAnyUniqueAliases, unionListToAnyUniqueAliases } from '../../my-game/example/any-unique-aliases'; -import { Color } from '../../my-game/example/color'; -import { Race } from '../../my-game/example/race'; -import { Referrable, ReferrableT } from '../../my-game/example/referrable'; -import { Stat, StatT } from '../../my-game/example/stat'; -import { Test, TestT } from '../../my-game/example/test'; -import { TestSimpleTableWithEnum, TestSimpleTableWithEnumT } from '../../my-game/example/test-simple-table-with-enum'; -import { Vec3, Vec3T } from '../../my-game/example/vec3'; -import { InParentNamespace, InParentNamespaceT } from '../../my-game/in-parent-namespace'; - - -/** - * 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/my-game/example/race.js b/tests/my-game/example/race.js deleted file mode 100644 index 74f51057abc..00000000000 --- a/tests/my-game/example/race.js +++ /dev/null @@ -1,8 +0,0 @@ -// 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/my-game/example/race.ts b/tests/my-game/example/race.ts deleted file mode 100644 index 8cb9654ae30..00000000000 --- a/tests/my-game/example/race.ts +++ /dev/null @@ -1,8 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -export enum Race { - None = -1, - Human = 0, - Dwarf = 1, - Elf = 2 -} diff --git a/tests/my-game/example/referrable.js b/tests/my-game/example/referrable.js deleted file mode 100644 index 367034b0644..00000000000 --- a/tests/my-game/example/referrable.js +++ /dev/null @@ -1,70 +0,0 @@ -// 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/my-game/example/referrable.ts b/tests/my-game/example/referrable.ts deleted file mode 100644 index ec02980037f..00000000000 --- a/tests/my-game/example/referrable.ts +++ /dev/null @@ -1,95 +0,0 @@ -// 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/my-game/example/stat.js b/tests/my-game/example/stat.js deleted file mode 100644 index 43b569f4e36..00000000000 --- a/tests/my-game/example/stat.js +++ /dev/null @@ -1,99 +0,0 @@ -// 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/my-game/example/stat.ts b/tests/my-game/example/stat.ts deleted file mode 100644 index e45259950aa..00000000000 --- a/tests/my-game/example/stat.ts +++ /dev/null @@ -1,138 +0,0 @@ -// 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/my-game/example/struct-of-structs-of-structs.ts b/tests/my-game/example/struct-of-structs-of-structs.ts deleted file mode 100644 index afe869fa7bd..00000000000 --- a/tests/my-game/example/struct-of-structs-of-structs.ts +++ /dev/null @@ -1,74 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -import * as flatbuffers from 'flatbuffers'; - -import { StructOfStructs, StructOfStructsT } from '../../my-game/example/struct-of-structs'; - - -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/my-game/example/struct-of-structs.js b/tests/my-game/example/struct-of-structs.js deleted file mode 100644 index 09c79108fbe..00000000000 --- a/tests/my-game/example/struct-of-structs.js +++ /dev/null @@ -1,62 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify -import { Ability } from '../../my-game/example/ability'; -import { Test } from '../../my-game/example/test'; -export class StructOfStructs { - constructor() { - this.bb = null; - this.bb_pos = 0; - } - __init(i, bb) { - this.bb_pos = i; - this.bb = bb; - return this; - } - a(obj) { - return (obj || new Ability()).__init(this.bb_pos, this.bb); - } - b(obj) { - return (obj || new Test()).__init(this.bb_pos + 8, this.bb); - } - c(obj) { - return (obj || new Ability()).__init(this.bb_pos + 12, this.bb); - } - static getFullyQualifiedName() { - return 'MyGame_Example_StructOfStructs'; - } - static sizeOf() { - return 20; - } - static createStructOfStructs(builder, a_id, a_distance, b_a, b_b, c_id, c_distance) { - builder.prep(4, 20); - builder.prep(4, 8); - builder.writeInt32(c_distance); - builder.writeInt32(c_id); - builder.prep(2, 4); - builder.pad(1); - builder.writeInt8(b_b); - builder.writeInt16(b_a); - builder.prep(4, 8); - builder.writeInt32(a_distance); - builder.writeInt32(a_id); - return builder.offset(); - } - unpack() { - return new StructOfStructsT((this.a() !== null ? this.a().unpack() : null), (this.b() !== null ? this.b().unpack() : null), (this.c() !== null ? this.c().unpack() : null)); - } - unpackTo(_o) { - _o.a = (this.a() !== null ? this.a().unpack() : null); - _o.b = (this.b() !== null ? this.b().unpack() : null); - _o.c = (this.c() !== null ? this.c().unpack() : null); - } -} -export class StructOfStructsT { - constructor(a = null, b = null, c = null) { - this.a = a; - this.b = b; - this.c = c; - } - pack(builder) { - 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/my-game/example/struct-of-structs.ts b/tests/my-game/example/struct-of-structs.ts deleted file mode 100644 index 0cb87ded506..00000000000 --- a/tests/my-game/example/struct-of-structs.ts +++ /dev/null @@ -1,88 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -import * as flatbuffers from 'flatbuffers'; - -import { Ability, AbilityT } from '../../my-game/example/ability'; -import { Test, TestT } from '../../my-game/example/test'; - - -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/my-game/example/test-simple-table-with-enum.js b/tests/my-game/example/test-simple-table-with-enum.js deleted file mode 100644 index a31d011adfc..00000000000 --- a/tests/my-game/example/test-simple-table-with-enum.js +++ /dev/null @@ -1,71 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify -import * as flatbuffers from 'flatbuffers'; -import { Color } from '../../my-game/example/color'; -export class TestSimpleTableWithEnum { - constructor() { - this.bb = null; - this.bb_pos = 0; - } - __init(i, bb) { - this.bb_pos = i; - this.bb = bb; - return this; - } - static getRootAsTestSimpleTableWithEnum(bb, obj) { - return (obj || new TestSimpleTableWithEnum()).__init(bb.readInt32(bb.position()) + bb.position(), bb); - } - static getSizePrefixedRootAsTestSimpleTableWithEnum(bb, obj) { - bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); - return (obj || new TestSimpleTableWithEnum()).__init(bb.readInt32(bb.position()) + bb.position(), bb); - } - color() { - const offset = this.bb.__offset(this.bb_pos, 4); - return offset ? this.bb.readUint8(this.bb_pos + offset) : Color.Green; - } - mutate_color(value) { - const offset = this.bb.__offset(this.bb_pos, 4); - if (offset === 0) { - return false; - } - this.bb.writeUint8(this.bb_pos + offset, value); - return true; - } - static getFullyQualifiedName() { - return 'MyGame_Example_TestSimpleTableWithEnum'; - } - static startTestSimpleTableWithEnum(builder) { - builder.startObject(1); - } - static addColor(builder, color) { - builder.addFieldInt8(0, color, Color.Green); - } - static endTestSimpleTableWithEnum(builder) { - const offset = builder.endObject(); - return offset; - } - static createTestSimpleTableWithEnum(builder, color) { - TestSimpleTableWithEnum.startTestSimpleTableWithEnum(builder); - TestSimpleTableWithEnum.addColor(builder, color); - return TestSimpleTableWithEnum.endTestSimpleTableWithEnum(builder); - } - serialize() { - return this.bb.bytes(); - } - static deserialize(buffer) { - return TestSimpleTableWithEnum.getRootAsTestSimpleTableWithEnum(new flatbuffers.ByteBuffer(buffer)); - } - unpack() { - return new TestSimpleTableWithEnumT(this.color()); - } - unpackTo(_o) { - _o.color = this.color(); - } -} -export class TestSimpleTableWithEnumT { - constructor(color = Color.Green) { - this.color = color; - } - pack(builder) { - return TestSimpleTableWithEnum.createTestSimpleTableWithEnum(builder, this.color); - } -} diff --git a/tests/my-game/example/test-simple-table-with-enum.ts b/tests/my-game/example/test-simple-table-with-enum.ts deleted file mode 100644 index 86a19aa5046..00000000000 --- a/tests/my-game/example/test-simple-table-with-enum.ts +++ /dev/null @@ -1,96 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -import * as flatbuffers from 'flatbuffers'; - -import { Color } from '../../my-game/example/color'; - - -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/my-game/example/test.js b/tests/my-game/example/test.js deleted file mode 100644 index 9c43619e210..00000000000 --- a/tests/my-game/example/test.js +++ /dev/null @@ -1,55 +0,0 @@ -// 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/my-game/example/test.ts b/tests/my-game/example/test.ts deleted file mode 100644 index b3d84eece95..00000000000 --- a/tests/my-game/example/test.ts +++ /dev/null @@ -1,78 +0,0 @@ -// 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/my-game/example/type-aliases.js b/tests/my-game/example/type-aliases.js deleted file mode 100644 index a4b5f89e3f5..00000000000 --- a/tests/my-game/example/type-aliases.js +++ /dev/null @@ -1,290 +0,0 @@ -// 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/my-game/example/type-aliases.ts b/tests/my-game/example/type-aliases.ts deleted file mode 100644 index 805c8cf3fcc..00000000000 --- a/tests/my-game/example/type-aliases.ts +++ /dev/null @@ -1,405 +0,0 @@ -// 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/my-game/example/vec3.js b/tests/my-game/example/vec3.js deleted file mode 100644 index 82b2eab02c0..00000000000 --- a/tests/my-game/example/vec3.js +++ /dev/null @@ -1,98 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify -import { Test } from '../../my-game/example/test'; -export class Vec3 { - constructor() { - this.bb = null; - this.bb_pos = 0; - } - __init(i, bb) { - this.bb_pos = i; - this.bb = bb; - return this; - } - x() { - return this.bb.readFloat32(this.bb_pos); - } - mutate_x(value) { - this.bb.writeFloat32(this.bb_pos + 0, value); - return true; - } - y() { - return this.bb.readFloat32(this.bb_pos + 4); - } - mutate_y(value) { - this.bb.writeFloat32(this.bb_pos + 4, value); - return true; - } - z() { - return this.bb.readFloat32(this.bb_pos + 8); - } - mutate_z(value) { - this.bb.writeFloat32(this.bb_pos + 8, value); - return true; - } - test1() { - return this.bb.readFloat64(this.bb_pos + 16); - } - mutate_test1(value) { - this.bb.writeFloat64(this.bb_pos + 16, value); - return true; - } - test2() { - return this.bb.readUint8(this.bb_pos + 24); - } - mutate_test2(value) { - this.bb.writeUint8(this.bb_pos + 24, value); - return true; - } - test3(obj) { - return (obj || new Test()).__init(this.bb_pos + 26, this.bb); - } - static getFullyQualifiedName() { - return 'MyGame_Example_Vec3'; - } - static sizeOf() { - return 32; - } - static createVec3(builder, x, y, z, test1, test2, test3_a, test3_b) { - builder.prep(8, 32); - builder.pad(2); - builder.prep(2, 4); - builder.pad(1); - builder.writeInt8(test3_b); - builder.writeInt16(test3_a); - builder.pad(1); - builder.writeInt8(test2); - builder.writeFloat64(test1); - builder.pad(4); - builder.writeFloat32(z); - builder.writeFloat32(y); - builder.writeFloat32(x); - return builder.offset(); - } - unpack() { - return new Vec3T(this.x(), this.y(), this.z(), this.test1(), this.test2(), (this.test3() !== null ? this.test3().unpack() : null)); - } - unpackTo(_o) { - _o.x = this.x(); - _o.y = this.y(); - _o.z = this.z(); - _o.test1 = this.test1(); - _o.test2 = this.test2(); - _o.test3 = (this.test3() !== null ? this.test3().unpack() : null); - } -} -export class Vec3T { - constructor(x = 0.0, y = 0.0, z = 0.0, test1 = 0.0, test2 = 0, test3 = null) { - this.x = x; - this.y = y; - this.z = z; - this.test1 = test1; - this.test2 = test2; - this.test3 = test3; - } - pack(builder) { - 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/my-game/example/vec3.ts b/tests/my-game/example/vec3.ts deleted file mode 100644 index 3c692e28d6b..00000000000 --- a/tests/my-game/example/vec3.ts +++ /dev/null @@ -1,137 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -import * as flatbuffers from 'flatbuffers'; - -import { Color } from '../../my-game/example/color'; -import { Test, TestT } from '../../my-game/example/test'; - - -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/my-game/example2/monster.js b/tests/my-game/example2/monster.js deleted file mode 100644 index f50a2c85afd..00000000000 --- a/tests/my-game/example2/monster.js +++ /dev/null @@ -1,50 +0,0 @@ -// 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/my-game/example2/monster.ts b/tests/my-game/example2/monster.ts deleted file mode 100644 index 7240476bef6..00000000000 --- a/tests/my-game/example2/monster.ts +++ /dev/null @@ -1,66 +0,0 @@ -// 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/my-game/in-parent-namespace.js b/tests/my-game/in-parent-namespace.js deleted file mode 100644 index 24b0ed78783..00000000000 --- a/tests/my-game/in-parent-namespace.js +++ /dev/null @@ -1,50 +0,0 @@ -// 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/my-game/in-parent-namespace.ts b/tests/my-game/in-parent-namespace.ts deleted file mode 100644 index 0de94df5e6c..00000000000 --- a/tests/my-game/in-parent-namespace.ts +++ /dev/null @@ -1,66 +0,0 @@ -// 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/namespace_test/namespace-a/namespace-b/enum-in-nested-n-s.js b/tests/namespace_test/namespace-a/namespace-b/enum-in-nested-n-s.js deleted file mode 100644 index 9105ed44f89..00000000000 --- a/tests/namespace_test/namespace-a/namespace-b/enum-in-nested-n-s.js +++ /dev/null @@ -1,7 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify -export var EnumInNestedNS; -(function (EnumInNestedNS) { - EnumInNestedNS[EnumInNestedNS["A"] = 0] = "A"; - EnumInNestedNS[EnumInNestedNS["B"] = 1] = "B"; - EnumInNestedNS[EnumInNestedNS["C"] = 2] = "C"; -})(EnumInNestedNS || (EnumInNestedNS = {})); diff --git a/tests/namespace_test/namespace-a/namespace-b/struct-in-nested-n-s.js b/tests/namespace_test/namespace-a/namespace-b/struct-in-nested-n-s.js deleted file mode 100644 index 918e238e0a9..00000000000 --- a/tests/namespace_test/namespace-a/namespace-b/struct-in-nested-n-s.js +++ /dev/null @@ -1,54 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify -export class StructInNestedNS { - constructor() { - this.bb = null; - this.bb_pos = 0; - } - __init(i, bb) { - this.bb_pos = i; - this.bb = bb; - return this; - } - a() { - return this.bb.readInt32(this.bb_pos); - } - mutate_a(value) { - this.bb.writeInt32(this.bb_pos + 0, value); - return true; - } - b() { - return this.bb.readInt32(this.bb_pos + 4); - } - mutate_b(value) { - this.bb.writeInt32(this.bb_pos + 4, value); - return true; - } - static getFullyQualifiedName() { - return 'NamespaceA.NamespaceB.StructInNestedNS'; - } - static sizeOf() { - return 8; - } - static createStructInNestedNS(builder, a, b) { - builder.prep(4, 8); - builder.writeInt32(b); - builder.writeInt32(a); - return builder.offset(); - } - unpack() { - return new StructInNestedNST(this.a(), this.b()); - } - unpackTo(_o) { - _o.a = this.a(); - _o.b = this.b(); - } -} -export class StructInNestedNST { - constructor(a = 0, b = 0) { - this.a = a; - this.b = b; - } - pack(builder) { - return StructInNestedNS.createStructInNestedNS(builder, this.a, this.b); - } -} diff --git a/tests/namespace_test/namespace-a/namespace-b/struct-in-nested-n-s.ts b/tests/namespace_test/namespace-a/namespace-b/struct-in-nested-n-s.ts deleted file mode 100644 index 4b10118e13c..00000000000 --- a/tests/namespace_test/namespace-a/namespace-b/struct-in-nested-n-s.ts +++ /dev/null @@ -1,77 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -import * as flatbuffers from 'flatbuffers'; - - - -export class StructInNestedNS { - bb: flatbuffers.ByteBuffer|null = null; - bb_pos = 0; -__init(i:number, bb:flatbuffers.ByteBuffer):StructInNestedNS { - this.bb_pos = i; - this.bb = bb; - return this; -} - -a():number { - return this.bb!.readInt32(this.bb_pos); -} - -mutate_a(value:number):boolean { - this.bb!.writeInt32(this.bb_pos + 0, value); - return true; -} - -b():number { - return this.bb!.readInt32(this.bb_pos + 4); -} - -mutate_b(value:number):boolean { - this.bb!.writeInt32(this.bb_pos + 4, value); - return true; -} - -static getFullyQualifiedName():string { - return 'NamespaceA.NamespaceB.StructInNestedNS'; -} - -static sizeOf():number { - return 8; -} - -static createStructInNestedNS(builder:flatbuffers.Builder, a: number, b: number):flatbuffers.Offset { - builder.prep(4, 8); - builder.writeInt32(b); - builder.writeInt32(a); - return builder.offset(); -} - - -unpack(): StructInNestedNST { - return new StructInNestedNST( - this.a(), - this.b() - ); -} - - -unpackTo(_o: StructInNestedNST): void { - _o.a = this.a(); - _o.b = this.b(); -} -} - -export class StructInNestedNST { -constructor( - public a: number = 0, - public b: number = 0 -){} - - -pack(builder:flatbuffers.Builder): flatbuffers.Offset { - return StructInNestedNS.createStructInNestedNS(builder, - this.a, - this.b - ); -} -} diff --git a/tests/namespace_test/namespace-a/namespace-b/table-in-nested-n-s.js b/tests/namespace_test/namespace-a/namespace-b/table-in-nested-n-s.js deleted file mode 100644 index fca1668c46e..00000000000 --- a/tests/namespace_test/namespace-a/namespace-b/table-in-nested-n-s.js +++ /dev/null @@ -1,64 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify -import * as flatbuffers from 'flatbuffers'; -export class TableInNestedNS { - constructor() { - this.bb = null; - this.bb_pos = 0; - } - __init(i, bb) { - this.bb_pos = i; - this.bb = bb; - return this; - } - static getRootAsTableInNestedNS(bb, obj) { - return (obj || new TableInNestedNS()).__init(bb.readInt32(bb.position()) + bb.position(), bb); - } - static getSizePrefixedRootAsTableInNestedNS(bb, obj) { - bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); - return (obj || new TableInNestedNS()).__init(bb.readInt32(bb.position()) + bb.position(), bb); - } - foo() { - const offset = this.bb.__offset(this.bb_pos, 4); - return offset ? this.bb.readInt32(this.bb_pos + offset) : 0; - } - mutate_foo(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 'NamespaceA.NamespaceB.TableInNestedNS'; - } - static startTableInNestedNS(builder) { - builder.startObject(1); - } - static addFoo(builder, foo) { - builder.addFieldInt32(0, foo, 0); - } - static endTableInNestedNS(builder) { - const offset = builder.endObject(); - return offset; - } - static createTableInNestedNS(builder, foo) { - TableInNestedNS.startTableInNestedNS(builder); - TableInNestedNS.addFoo(builder, foo); - return TableInNestedNS.endTableInNestedNS(builder); - } - unpack() { - return new TableInNestedNST(this.foo()); - } - unpackTo(_o) { - _o.foo = this.foo(); - } -} -export class TableInNestedNST { - constructor(foo = 0) { - this.foo = foo; - } - pack(builder) { - return TableInNestedNS.createTableInNestedNS(builder, this.foo); - } -} diff --git a/tests/namespace_test/namespace-a/namespace-b/table-in-nested-n-s.ts b/tests/namespace_test/namespace-a/namespace-b/table-in-nested-n-s.ts deleted file mode 100644 index 5279fdbd57c..00000000000 --- a/tests/namespace_test/namespace-a/namespace-b/table-in-nested-n-s.ts +++ /dev/null @@ -1,87 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -import * as flatbuffers from 'flatbuffers'; - - - -export class TableInNestedNS { - bb: flatbuffers.ByteBuffer|null = null; - bb_pos = 0; -__init(i:number, bb:flatbuffers.ByteBuffer):TableInNestedNS { - this.bb_pos = i; - this.bb = bb; - return this; -} - -static getRootAsTableInNestedNS(bb:flatbuffers.ByteBuffer, obj?:TableInNestedNS):TableInNestedNS { - return (obj || new TableInNestedNS()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -} - -static getSizePrefixedRootAsTableInNestedNS(bb:flatbuffers.ByteBuffer, obj?:TableInNestedNS):TableInNestedNS { - bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); - return (obj || new TableInNestedNS()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -} - -foo():number { - const offset = this.bb!.__offset(this.bb_pos, 4); - return offset ? this.bb!.readInt32(this.bb_pos + offset) : 0; -} - -mutate_foo(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 'NamespaceA.NamespaceB.TableInNestedNS'; -} - -static startTableInNestedNS(builder:flatbuffers.Builder) { - builder.startObject(1); -} - -static addFoo(builder:flatbuffers.Builder, foo:number) { - builder.addFieldInt32(0, foo, 0); -} - -static endTableInNestedNS(builder:flatbuffers.Builder):flatbuffers.Offset { - const offset = builder.endObject(); - return offset; -} - -static createTableInNestedNS(builder:flatbuffers.Builder, foo:number):flatbuffers.Offset { - TableInNestedNS.startTableInNestedNS(builder); - TableInNestedNS.addFoo(builder, foo); - return TableInNestedNS.endTableInNestedNS(builder); -} - -unpack(): TableInNestedNST { - return new TableInNestedNST( - this.foo() - ); -} - - -unpackTo(_o: TableInNestedNST): void { - _o.foo = this.foo(); -} -} - -export class TableInNestedNST { -constructor( - public foo: number = 0 -){} - - -pack(builder:flatbuffers.Builder): flatbuffers.Offset { - return TableInNestedNS.createTableInNestedNS(builder, - this.foo - ); -} -} diff --git a/tests/namespace_test/namespace-a/namespace-b/union-in-nested-n-s.js b/tests/namespace_test/namespace-a/namespace-b/union-in-nested-n-s.js deleted file mode 100644 index b820bceacd6..00000000000 --- a/tests/namespace_test/namespace-a/namespace-b/union-in-nested-n-s.js +++ /dev/null @@ -1,21 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify -import { TableInNestedNS } from '../../namespace-a/namespace-b/table-in-nested-n-s'; -export var UnionInNestedNS; -(function (UnionInNestedNS) { - UnionInNestedNS[UnionInNestedNS["NONE"] = 0] = "NONE"; - UnionInNestedNS[UnionInNestedNS["TableInNestedNS"] = 1] = "TableInNestedNS"; -})(UnionInNestedNS || (UnionInNestedNS = {})); -export function unionToUnionInNestedNS(type, accessor) { - switch (UnionInNestedNS[type]) { - case 'NONE': return null; - case 'TableInNestedNS': return accessor(new TableInNestedNS()); - default: return null; - } -} -export function unionListToUnionInNestedNS(type, accessor, index) { - switch (UnionInNestedNS[type]) { - case 'NONE': return null; - case 'TableInNestedNS': return accessor(index, new TableInNestedNS()); - default: return null; - } -} diff --git a/tests/namespace_test/namespace-a/namespace-b/union-in-nested-n-s.ts b/tests/namespace_test/namespace-a/namespace-b/union-in-nested-n-s.ts deleted file mode 100644 index 441ebf76c94..00000000000 --- a/tests/namespace_test/namespace-a/namespace-b/union-in-nested-n-s.ts +++ /dev/null @@ -1,33 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -import { TableInNestedNS, TableInNestedNST } from '../../namespace-a/namespace-b/table-in-nested-n-s'; - - -export enum UnionInNestedNS{ - NONE = 0, - TableInNestedNS = 1 -} - -export function unionToUnionInNestedNS( - type: UnionInNestedNS, - accessor: (obj:TableInNestedNS) => TableInNestedNS|null -): TableInNestedNS|null { - switch(UnionInNestedNS[type]) { - case 'NONE': return null; - case 'TableInNestedNS': return accessor(new TableInNestedNS())! as TableInNestedNS; - default: return null; - } -} - -export function unionListToUnionInNestedNS( - type: UnionInNestedNS, - accessor: (index: number, obj:TableInNestedNS) => TableInNestedNS|null, - index: number -): TableInNestedNS|null { - switch(UnionInNestedNS[type]) { - case 'NONE': return null; - case 'TableInNestedNS': return accessor(index, new TableInNestedNS())! as TableInNestedNS; - default: return null; - } -} - diff --git a/tests/namespace_test/namespace-a/second-table-in-a.js b/tests/namespace_test/namespace-a/second-table-in-a.js deleted file mode 100644 index fe848e01f18..00000000000 --- a/tests/namespace_test/namespace-a/second-table-in-a.js +++ /dev/null @@ -1,58 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify -import * as flatbuffers from 'flatbuffers'; -import { TableInC } from '../namespace-c/table-in-c'; -export class SecondTableInA { - constructor() { - this.bb = null; - this.bb_pos = 0; - } - __init(i, bb) { - this.bb_pos = i; - this.bb = bb; - return this; - } - static getRootAsSecondTableInA(bb, obj) { - return (obj || new SecondTableInA()).__init(bb.readInt32(bb.position()) + bb.position(), bb); - } - static getSizePrefixedRootAsSecondTableInA(bb, obj) { - bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); - return (obj || new SecondTableInA()).__init(bb.readInt32(bb.position()) + bb.position(), bb); - } - referToC(obj) { - const offset = this.bb.__offset(this.bb_pos, 4); - return offset ? (obj || new TableInC()).__init(this.bb.__indirect(this.bb_pos + offset), this.bb) : null; - } - static getFullyQualifiedName() { - return 'NamespaceA.SecondTableInA'; - } - static startSecondTableInA(builder) { - builder.startObject(1); - } - static addReferToC(builder, referToCOffset) { - builder.addFieldOffset(0, referToCOffset, 0); - } - static endSecondTableInA(builder) { - const offset = builder.endObject(); - return offset; - } - static createSecondTableInA(builder, referToCOffset) { - SecondTableInA.startSecondTableInA(builder); - SecondTableInA.addReferToC(builder, referToCOffset); - return SecondTableInA.endSecondTableInA(builder); - } - unpack() { - return new SecondTableInAT((this.referToC() !== null ? this.referToC().unpack() : null)); - } - unpackTo(_o) { - _o.referToC = (this.referToC() !== null ? this.referToC().unpack() : null); - } -} -export class SecondTableInAT { - constructor(referToC = null) { - this.referToC = referToC; - } - pack(builder) { - const referToC = (this.referToC !== null ? this.referToC.pack(builder) : 0); - return SecondTableInA.createSecondTableInA(builder, referToC); - } -} diff --git a/tests/namespace_test/namespace-a/second-table-in-a.ts b/tests/namespace_test/namespace-a/second-table-in-a.ts deleted file mode 100644 index 9be34024c7e..00000000000 --- a/tests/namespace_test/namespace-a/second-table-in-a.ts +++ /dev/null @@ -1,79 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -import * as flatbuffers from 'flatbuffers'; - -import { TableInC, TableInCT } from '../namespace-c/table-in-c'; - - -export class SecondTableInA { - bb: flatbuffers.ByteBuffer|null = null; - bb_pos = 0; -__init(i:number, bb:flatbuffers.ByteBuffer):SecondTableInA { - this.bb_pos = i; - this.bb = bb; - return this; -} - -static getRootAsSecondTableInA(bb:flatbuffers.ByteBuffer, obj?:SecondTableInA):SecondTableInA { - return (obj || new SecondTableInA()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -} - -static getSizePrefixedRootAsSecondTableInA(bb:flatbuffers.ByteBuffer, obj?:SecondTableInA):SecondTableInA { - bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); - return (obj || new SecondTableInA()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -} - -referToC(obj?:TableInC):TableInC|null { - const offset = this.bb!.__offset(this.bb_pos, 4); - return offset ? (obj || new TableInC()).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null; -} - -static getFullyQualifiedName():string { - return 'NamespaceA.SecondTableInA'; -} - -static startSecondTableInA(builder:flatbuffers.Builder) { - builder.startObject(1); -} - -static addReferToC(builder:flatbuffers.Builder, referToCOffset:flatbuffers.Offset) { - builder.addFieldOffset(0, referToCOffset, 0); -} - -static endSecondTableInA(builder:flatbuffers.Builder):flatbuffers.Offset { - const offset = builder.endObject(); - return offset; -} - -static createSecondTableInA(builder:flatbuffers.Builder, referToCOffset:flatbuffers.Offset):flatbuffers.Offset { - SecondTableInA.startSecondTableInA(builder); - SecondTableInA.addReferToC(builder, referToCOffset); - return SecondTableInA.endSecondTableInA(builder); -} - -unpack(): SecondTableInAT { - return new SecondTableInAT( - (this.referToC() !== null ? this.referToC()!.unpack() : null) - ); -} - - -unpackTo(_o: SecondTableInAT): void { - _o.referToC = (this.referToC() !== null ? this.referToC()!.unpack() : null); -} -} - -export class SecondTableInAT { -constructor( - public referToC: TableInCT|null = null -){} - - -pack(builder:flatbuffers.Builder): flatbuffers.Offset { - const referToC = (this.referToC !== null ? this.referToC!.pack(builder) : 0); - - return SecondTableInA.createSecondTableInA(builder, - referToC - ); -} -} diff --git a/tests/namespace_test/namespace-a/table-in-first-n-s.js b/tests/namespace_test/namespace-a/table-in-first-n-s.js deleted file mode 100644 index 91bcc8569fd..00000000000 --- a/tests/namespace_test/namespace-a/table-in-first-n-s.js +++ /dev/null @@ -1,119 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify -import * as flatbuffers from 'flatbuffers'; -import { EnumInNestedNS } from '../namespace-a/namespace-b/enum-in-nested-n-s'; -import { StructInNestedNS } from '../namespace-a/namespace-b/struct-in-nested-n-s'; -import { TableInNestedNS } from '../namespace-a/namespace-b/table-in-nested-n-s'; -import { UnionInNestedNS, unionToUnionInNestedNS } from '../namespace-a/namespace-b/union-in-nested-n-s'; -export class TableInFirstNS { - constructor() { - this.bb = null; - this.bb_pos = 0; - } - __init(i, bb) { - this.bb_pos = i; - this.bb = bb; - return this; - } - static getRootAsTableInFirstNS(bb, obj) { - return (obj || new TableInFirstNS()).__init(bb.readInt32(bb.position()) + bb.position(), bb); - } - static getSizePrefixedRootAsTableInFirstNS(bb, obj) { - bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); - return (obj || new TableInFirstNS()).__init(bb.readInt32(bb.position()) + bb.position(), bb); - } - fooTable(obj) { - const offset = this.bb.__offset(this.bb_pos, 4); - return offset ? (obj || new TableInNestedNS()).__init(this.bb.__indirect(this.bb_pos + offset), this.bb) : null; - } - fooEnum() { - const offset = this.bb.__offset(this.bb_pos, 6); - return offset ? this.bb.readInt8(this.bb_pos + offset) : EnumInNestedNS.A; - } - mutate_foo_enum(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; - } - fooUnionType() { - const offset = this.bb.__offset(this.bb_pos, 8); - return offset ? this.bb.readUint8(this.bb_pos + offset) : UnionInNestedNS.NONE; - } - fooUnion(obj) { - const offset = this.bb.__offset(this.bb_pos, 10); - return offset ? this.bb.__union(obj, this.bb_pos + offset) : null; - } - fooStruct(obj) { - const offset = this.bb.__offset(this.bb_pos, 12); - return offset ? (obj || new StructInNestedNS()).__init(this.bb_pos + offset, this.bb) : null; - } - static getFullyQualifiedName() { - return 'NamespaceA.TableInFirstNS'; - } - static startTableInFirstNS(builder) { - builder.startObject(5); - } - static addFooTable(builder, fooTableOffset) { - builder.addFieldOffset(0, fooTableOffset, 0); - } - static addFooEnum(builder, fooEnum) { - builder.addFieldInt8(1, fooEnum, EnumInNestedNS.A); - } - static addFooUnionType(builder, fooUnionType) { - builder.addFieldInt8(2, fooUnionType, UnionInNestedNS.NONE); - } - static addFooUnion(builder, fooUnionOffset) { - builder.addFieldOffset(3, fooUnionOffset, 0); - } - static addFooStruct(builder, fooStructOffset) { - builder.addFieldStruct(4, fooStructOffset, 0); - } - static endTableInFirstNS(builder) { - const offset = builder.endObject(); - return offset; - } - unpack() { - return new TableInFirstNST((this.fooTable() !== null ? this.fooTable().unpack() : null), this.fooEnum(), this.fooUnionType(), (() => { - let temp = unionToUnionInNestedNS(this.fooUnionType(), this.fooUnion.bind(this)); - if (temp === null) { - return null; - } - return temp.unpack(); - })(), (this.fooStruct() !== null ? this.fooStruct().unpack() : null)); - } - unpackTo(_o) { - _o.fooTable = (this.fooTable() !== null ? this.fooTable().unpack() : null); - _o.fooEnum = this.fooEnum(); - _o.fooUnionType = this.fooUnionType(); - _o.fooUnion = (() => { - let temp = unionToUnionInNestedNS(this.fooUnionType(), this.fooUnion.bind(this)); - if (temp === null) { - return null; - } - return temp.unpack(); - })(); - _o.fooStruct = (this.fooStruct() !== null ? this.fooStruct().unpack() : null); - } -} -export class TableInFirstNST { - constructor(fooTable = null, fooEnum = EnumInNestedNS.A, fooUnionType = UnionInNestedNS.NONE, fooUnion = null, fooStruct = null) { - this.fooTable = fooTable; - this.fooEnum = fooEnum; - this.fooUnionType = fooUnionType; - this.fooUnion = fooUnion; - this.fooStruct = fooStruct; - } - pack(builder) { - const fooTable = (this.fooTable !== null ? this.fooTable.pack(builder) : 0); - const fooUnion = builder.createObjectOffset(this.fooUnion); - TableInFirstNS.startTableInFirstNS(builder); - TableInFirstNS.addFooTable(builder, fooTable); - TableInFirstNS.addFooEnum(builder, this.fooEnum); - TableInFirstNS.addFooUnionType(builder, this.fooUnionType); - TableInFirstNS.addFooUnion(builder, fooUnion); - TableInFirstNS.addFooStruct(builder, (this.fooStruct !== null ? this.fooStruct.pack(builder) : 0)); - return TableInFirstNS.endTableInFirstNS(builder); - } -} diff --git a/tests/namespace_test/namespace-a/table-in-first-n-s.ts b/tests/namespace_test/namespace-a/table-in-first-n-s.ts deleted file mode 100644 index 8e4d706bd24..00000000000 --- a/tests/namespace_test/namespace-a/table-in-first-n-s.ts +++ /dev/null @@ -1,150 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -import * as flatbuffers from 'flatbuffers'; - -import { EnumInNestedNS } from '../namespace-a/namespace-b/enum-in-nested-n-s'; -import { StructInNestedNS, StructInNestedNST } from '../namespace-a/namespace-b/struct-in-nested-n-s'; -import { TableInNestedNS, TableInNestedNST } from '../namespace-a/namespace-b/table-in-nested-n-s'; -import { UnionInNestedNS, unionToUnionInNestedNS, unionListToUnionInNestedNS } from '../namespace-a/namespace-b/union-in-nested-n-s'; - - -export class TableInFirstNS { - bb: flatbuffers.ByteBuffer|null = null; - bb_pos = 0; -__init(i:number, bb:flatbuffers.ByteBuffer):TableInFirstNS { - this.bb_pos = i; - this.bb = bb; - return this; -} - -static getRootAsTableInFirstNS(bb:flatbuffers.ByteBuffer, obj?:TableInFirstNS):TableInFirstNS { - return (obj || new TableInFirstNS()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -} - -static getSizePrefixedRootAsTableInFirstNS(bb:flatbuffers.ByteBuffer, obj?:TableInFirstNS):TableInFirstNS { - bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); - return (obj || new TableInFirstNS()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -} - -fooTable(obj?:TableInNestedNS):TableInNestedNS|null { - const offset = this.bb!.__offset(this.bb_pos, 4); - return offset ? (obj || new TableInNestedNS()).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null; -} - -fooEnum():EnumInNestedNS { - const offset = this.bb!.__offset(this.bb_pos, 6); - return offset ? this.bb!.readInt8(this.bb_pos + offset) : EnumInNestedNS.A; -} - -mutate_foo_enum(value:EnumInNestedNS):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; -} - -fooUnionType():UnionInNestedNS { - const offset = this.bb!.__offset(this.bb_pos, 8); - return offset ? this.bb!.readUint8(this.bb_pos + offset) : UnionInNestedNS.NONE; -} - -fooUnion(obj:any):any|null { - const offset = this.bb!.__offset(this.bb_pos, 10); - return offset ? this.bb!.__union(obj, this.bb_pos + offset) : null; -} - -fooStruct(obj?:StructInNestedNS):StructInNestedNS|null { - const offset = this.bb!.__offset(this.bb_pos, 12); - return offset ? (obj || new StructInNestedNS()).__init(this.bb_pos + offset, this.bb!) : null; -} - -static getFullyQualifiedName():string { - return 'NamespaceA.TableInFirstNS'; -} - -static startTableInFirstNS(builder:flatbuffers.Builder) { - builder.startObject(5); -} - -static addFooTable(builder:flatbuffers.Builder, fooTableOffset:flatbuffers.Offset) { - builder.addFieldOffset(0, fooTableOffset, 0); -} - -static addFooEnum(builder:flatbuffers.Builder, fooEnum:EnumInNestedNS) { - builder.addFieldInt8(1, fooEnum, EnumInNestedNS.A); -} - -static addFooUnionType(builder:flatbuffers.Builder, fooUnionType:UnionInNestedNS) { - builder.addFieldInt8(2, fooUnionType, UnionInNestedNS.NONE); -} - -static addFooUnion(builder:flatbuffers.Builder, fooUnionOffset:flatbuffers.Offset) { - builder.addFieldOffset(3, fooUnionOffset, 0); -} - -static addFooStruct(builder:flatbuffers.Builder, fooStructOffset:flatbuffers.Offset) { - builder.addFieldStruct(4, fooStructOffset, 0); -} - -static endTableInFirstNS(builder:flatbuffers.Builder):flatbuffers.Offset { - const offset = builder.endObject(); - return offset; -} - - -unpack(): TableInFirstNST { - return new TableInFirstNST( - (this.fooTable() !== null ? this.fooTable()!.unpack() : null), - this.fooEnum(), - this.fooUnionType(), - (() => { - let temp = unionToUnionInNestedNS(this.fooUnionType(), this.fooUnion.bind(this)); - if(temp === null) { return null; } - return temp.unpack() - })(), - (this.fooStruct() !== null ? this.fooStruct()!.unpack() : null) - ); -} - - -unpackTo(_o: TableInFirstNST): void { - _o.fooTable = (this.fooTable() !== null ? this.fooTable()!.unpack() : null); - _o.fooEnum = this.fooEnum(); - _o.fooUnionType = this.fooUnionType(); - _o.fooUnion = (() => { - let temp = unionToUnionInNestedNS(this.fooUnionType(), this.fooUnion.bind(this)); - if(temp === null) { return null; } - return temp.unpack() - })(); - _o.fooStruct = (this.fooStruct() !== null ? this.fooStruct()!.unpack() : null); -} -} - -export class TableInFirstNST { -constructor( - public fooTable: TableInNestedNST|null = null, - public fooEnum: EnumInNestedNS = EnumInNestedNS.A, - public fooUnionType: UnionInNestedNS = UnionInNestedNS.NONE, - public fooUnion: TableInNestedNST|null = null, - public fooStruct: StructInNestedNST|null = null -){} - - -pack(builder:flatbuffers.Builder): flatbuffers.Offset { - const fooTable = (this.fooTable !== null ? this.fooTable!.pack(builder) : 0); - const fooUnion = builder.createObjectOffset(this.fooUnion); - - TableInFirstNS.startTableInFirstNS(builder); - TableInFirstNS.addFooTable(builder, fooTable); - TableInFirstNS.addFooEnum(builder, this.fooEnum); - TableInFirstNS.addFooUnionType(builder, this.fooUnionType); - TableInFirstNS.addFooUnion(builder, fooUnion); - TableInFirstNS.addFooStruct(builder, (this.fooStruct !== null ? this.fooStruct!.pack(builder) : 0)); - - return TableInFirstNS.endTableInFirstNS(builder); -} -} diff --git a/tests/namespace_test/namespace-c/table-in-c.js b/tests/namespace_test/namespace-c/table-in-c.js deleted file mode 100644 index d097a3c3b31..00000000000 --- a/tests/namespace_test/namespace-c/table-in-c.js +++ /dev/null @@ -1,67 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify -import * as flatbuffers from 'flatbuffers'; -import { SecondTableInA } from '../namespace-a/second-table-in-a'; -import { TableInFirstNS } from '../namespace-a/table-in-first-n-s'; -export class TableInC { - constructor() { - this.bb = null; - this.bb_pos = 0; - } - __init(i, bb) { - this.bb_pos = i; - this.bb = bb; - return this; - } - static getRootAsTableInC(bb, obj) { - return (obj || new TableInC()).__init(bb.readInt32(bb.position()) + bb.position(), bb); - } - static getSizePrefixedRootAsTableInC(bb, obj) { - bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); - return (obj || new TableInC()).__init(bb.readInt32(bb.position()) + bb.position(), bb); - } - referToA1(obj) { - const offset = this.bb.__offset(this.bb_pos, 4); - return offset ? (obj || new TableInFirstNS()).__init(this.bb.__indirect(this.bb_pos + offset), this.bb) : null; - } - referToA2(obj) { - const offset = this.bb.__offset(this.bb_pos, 6); - return offset ? (obj || new SecondTableInA()).__init(this.bb.__indirect(this.bb_pos + offset), this.bb) : null; - } - static getFullyQualifiedName() { - return 'NamespaceC.TableInC'; - } - static startTableInC(builder) { - builder.startObject(2); - } - static addReferToA1(builder, referToA1Offset) { - builder.addFieldOffset(0, referToA1Offset, 0); - } - static addReferToA2(builder, referToA2Offset) { - builder.addFieldOffset(1, referToA2Offset, 0); - } - static endTableInC(builder) { - const offset = builder.endObject(); - return offset; - } - unpack() { - return new TableInCT((this.referToA1() !== null ? this.referToA1().unpack() : null), (this.referToA2() !== null ? this.referToA2().unpack() : null)); - } - unpackTo(_o) { - _o.referToA1 = (this.referToA1() !== null ? this.referToA1().unpack() : null); - _o.referToA2 = (this.referToA2() !== null ? this.referToA2().unpack() : null); - } -} -export class TableInCT { - constructor(referToA1 = null, referToA2 = null) { - this.referToA1 = referToA1; - this.referToA2 = referToA2; - } - pack(builder) { - const referToA1 = (this.referToA1 !== null ? this.referToA1.pack(builder) : 0); - const referToA2 = (this.referToA2 !== null ? this.referToA2.pack(builder) : 0); - TableInC.startTableInC(builder); - TableInC.addReferToA1(builder, referToA1); - TableInC.addReferToA2(builder, referToA2); - return TableInC.endTableInC(builder); - } -} diff --git a/tests/namespace_test/namespace-c/table-in-c.ts b/tests/namespace_test/namespace-c/table-in-c.ts deleted file mode 100644 index 7b924b8876d..00000000000 --- a/tests/namespace_test/namespace-c/table-in-c.ts +++ /dev/null @@ -1,90 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -import * as flatbuffers from 'flatbuffers'; - -import { SecondTableInA, SecondTableInAT } from '../namespace-a/second-table-in-a'; -import { TableInFirstNS, TableInFirstNST } from '../namespace-a/table-in-first-n-s'; - - -export class TableInC { - bb: flatbuffers.ByteBuffer|null = null; - bb_pos = 0; -__init(i:number, bb:flatbuffers.ByteBuffer):TableInC { - this.bb_pos = i; - this.bb = bb; - return this; -} - -static getRootAsTableInC(bb:flatbuffers.ByteBuffer, obj?:TableInC):TableInC { - return (obj || new TableInC()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -} - -static getSizePrefixedRootAsTableInC(bb:flatbuffers.ByteBuffer, obj?:TableInC):TableInC { - bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); - return (obj || new TableInC()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -} - -referToA1(obj?:TableInFirstNS):TableInFirstNS|null { - const offset = this.bb!.__offset(this.bb_pos, 4); - return offset ? (obj || new TableInFirstNS()).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null; -} - -referToA2(obj?:SecondTableInA):SecondTableInA|null { - const offset = this.bb!.__offset(this.bb_pos, 6); - return offset ? (obj || new SecondTableInA()).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null; -} - -static getFullyQualifiedName():string { - return 'NamespaceC.TableInC'; -} - -static startTableInC(builder:flatbuffers.Builder) { - builder.startObject(2); -} - -static addReferToA1(builder:flatbuffers.Builder, referToA1Offset:flatbuffers.Offset) { - builder.addFieldOffset(0, referToA1Offset, 0); -} - -static addReferToA2(builder:flatbuffers.Builder, referToA2Offset:flatbuffers.Offset) { - builder.addFieldOffset(1, referToA2Offset, 0); -} - -static endTableInC(builder:flatbuffers.Builder):flatbuffers.Offset { - const offset = builder.endObject(); - return offset; -} - - -unpack(): TableInCT { - return new TableInCT( - (this.referToA1() !== null ? this.referToA1()!.unpack() : null), - (this.referToA2() !== null ? this.referToA2()!.unpack() : null) - ); -} - - -unpackTo(_o: TableInCT): void { - _o.referToA1 = (this.referToA1() !== null ? this.referToA1()!.unpack() : null); - _o.referToA2 = (this.referToA2() !== null ? this.referToA2()!.unpack() : null); -} -} - -export class TableInCT { -constructor( - public referToA1: TableInFirstNST|null = null, - public referToA2: SecondTableInAT|null = null -){} - - -pack(builder:flatbuffers.Builder): flatbuffers.Offset { - const referToA1 = (this.referToA1 !== null ? this.referToA1!.pack(builder) : 0); - const referToA2 = (this.referToA2 !== null ? this.referToA2!.pack(builder) : 0); - - TableInC.startTableInC(builder); - TableInC.addReferToA1(builder, referToA1); - TableInC.addReferToA2(builder, referToA2); - - return TableInC.endTableInC(builder); -} -} diff --git a/tests/namespace_test/namespace_test1.ts b/tests/namespace_test/namespace_test1.ts deleted file mode 100644 index 9d8cf3342db..00000000000 --- a/tests/namespace_test/namespace_test1.ts +++ /dev/null @@ -1,3 +0,0 @@ -export { StructInNestedNS, StructInNestedNST } from './namespace-a/namespace-b/struct-in-nested-n-s'; -export { TableInNestedNS, TableInNestedNST } from './namespace-a/namespace-b/table-in-nested-n-s'; -export { UnionInNestedNS, unionToUnionInNestedNS, unionListToUnionInNestedNS } from './namespace-a/namespace-b/union-in-nested-n-s'; diff --git a/tests/namespace_test/namespace_test2.ts b/tests/namespace_test/namespace_test2.ts deleted file mode 100644 index 01f1bd4cfd2..00000000000 --- a/tests/namespace_test/namespace_test2.ts +++ /dev/null @@ -1,7 +0,0 @@ -export { EnumInNestedNS } from './namespace-a/namespace-b/enum-in-nested-n-s'; -export { StructInNestedNS, StructInNestedNST } from './namespace-a/namespace-b/struct-in-nested-n-s'; -export { TableInNestedNS, TableInNestedNST } from './namespace-a/namespace-b/table-in-nested-n-s'; -export { UnionInNestedNS, unionToUnionInNestedNS, unionListToUnionInNestedNS } from './namespace-a/namespace-b/union-in-nested-n-s'; -export { SecondTableInA, SecondTableInAT } from './namespace-a/second-table-in-a'; -export { TableInFirstNS, TableInFirstNST } from './namespace-a/table-in-first-n-s'; -export { TableInC, TableInCT } from './namespace-c/table-in-c'; diff --git a/tests/optional-scalars/scalar-stuff.ts b/tests/optional-scalars/scalar-stuff.ts deleted file mode 100644 index 7c8fd516d45..00000000000 --- a/tests/optional-scalars/scalar-stuff.ts +++ /dev/null @@ -1,423 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -import * as flatbuffers from 'flatbuffers'; - -import { OptionalByte } from '../optional-scalars/optional-byte'; - - -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 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/optional-byte.js b/tests/optional_scalars/optional-byte.js deleted file mode 100644 index 8257f93a460..00000000000 --- a/tests/optional_scalars/optional-byte.js +++ /dev/null @@ -1,7 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify -export var OptionalByte; -(function (OptionalByte) { - OptionalByte[OptionalByte["None"] = 0] = "None"; - OptionalByte[OptionalByte["One"] = 1] = "One"; - OptionalByte[OptionalByte["Two"] = 2] = "Two"; -})(OptionalByte || (OptionalByte = {})); diff --git a/tests/optional_scalars/optional-byte.ts b/tests/optional_scalars/optional-byte.ts deleted file mode 100644 index 1db479f1a5b..00000000000 --- a/tests/optional_scalars/optional-byte.ts +++ /dev/null @@ -1,8 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -export enum OptionalByte{ - None = 0, - One = 1, - Two = 2 -} - diff --git a/tests/optional_scalars/scalar-stuff.js b/tests/optional_scalars/scalar-stuff.js deleted file mode 100644 index f02b885ad6d..00000000000 --- a/tests/optional_scalars/scalar-stuff.js +++ /dev/null @@ -1,341 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify -import * as flatbuffers from 'flatbuffers'; -import { OptionalByte } from '../optional_scalars/optional-byte'; -export class ScalarStuff { - constructor() { - this.bb = null; - this.bb_pos = 0; - } - __init(i, bb) { - this.bb_pos = i; - this.bb = bb; - return this; - } - static getRootAsScalarStuff(bb, obj) { - return (obj || new ScalarStuff()).__init(bb.readInt32(bb.position()) + bb.position(), bb); - } - static getSizePrefixedRootAsScalarStuff(bb, obj) { - bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); - return (obj || new ScalarStuff()).__init(bb.readInt32(bb.position()) + bb.position(), bb); - } - static bufferHasIdentifier(bb) { - return bb.__has_identifier('NULL'); - } - justI8() { - const offset = this.bb.__offset(this.bb_pos, 4); - return offset ? this.bb.readInt8(this.bb_pos + offset) : 0; - } - maybeI8() { - const offset = this.bb.__offset(this.bb_pos, 6); - return offset ? this.bb.readInt8(this.bb_pos + offset) : null; - } - defaultI8() { - const offset = this.bb.__offset(this.bb_pos, 8); - return offset ? this.bb.readInt8(this.bb_pos + offset) : 42; - } - justU8() { - const offset = this.bb.__offset(this.bb_pos, 10); - return offset ? this.bb.readUint8(this.bb_pos + offset) : 0; - } - maybeU8() { - const offset = this.bb.__offset(this.bb_pos, 12); - return offset ? this.bb.readUint8(this.bb_pos + offset) : null; - } - defaultU8() { - const offset = this.bb.__offset(this.bb_pos, 14); - return offset ? this.bb.readUint8(this.bb_pos + offset) : 42; - } - justI16() { - const offset = this.bb.__offset(this.bb_pos, 16); - return offset ? this.bb.readInt16(this.bb_pos + offset) : 0; - } - maybeI16() { - const offset = this.bb.__offset(this.bb_pos, 18); - return offset ? this.bb.readInt16(this.bb_pos + offset) : null; - } - defaultI16() { - const offset = this.bb.__offset(this.bb_pos, 20); - return offset ? this.bb.readInt16(this.bb_pos + offset) : 42; - } - justU16() { - const offset = this.bb.__offset(this.bb_pos, 22); - return offset ? this.bb.readUint16(this.bb_pos + offset) : 0; - } - maybeU16() { - const offset = this.bb.__offset(this.bb_pos, 24); - return offset ? this.bb.readUint16(this.bb_pos + offset) : null; - } - defaultU16() { - const offset = this.bb.__offset(this.bb_pos, 26); - return offset ? this.bb.readUint16(this.bb_pos + offset) : 42; - } - justI32() { - const offset = this.bb.__offset(this.bb_pos, 28); - return offset ? this.bb.readInt32(this.bb_pos + offset) : 0; - } - maybeI32() { - const offset = this.bb.__offset(this.bb_pos, 30); - return offset ? this.bb.readInt32(this.bb_pos + offset) : null; - } - defaultI32() { - const offset = this.bb.__offset(this.bb_pos, 32); - return offset ? this.bb.readInt32(this.bb_pos + offset) : 42; - } - justU32() { - const offset = this.bb.__offset(this.bb_pos, 34); - return offset ? this.bb.readUint32(this.bb_pos + offset) : 0; - } - maybeU32() { - const offset = this.bb.__offset(this.bb_pos, 36); - return offset ? this.bb.readUint32(this.bb_pos + offset) : null; - } - defaultU32() { - const offset = this.bb.__offset(this.bb_pos, 38); - return offset ? this.bb.readUint32(this.bb_pos + offset) : 42; - } - justI64() { - const offset = this.bb.__offset(this.bb_pos, 40); - return offset ? this.bb.readInt64(this.bb_pos + offset) : BigInt('0'); - } - maybeI64() { - const offset = this.bb.__offset(this.bb_pos, 42); - return offset ? this.bb.readInt64(this.bb_pos + offset) : null; - } - defaultI64() { - const offset = this.bb.__offset(this.bb_pos, 44); - return offset ? this.bb.readInt64(this.bb_pos + offset) : BigInt('42'); - } - justU64() { - const offset = this.bb.__offset(this.bb_pos, 46); - return offset ? this.bb.readUint64(this.bb_pos + offset) : BigInt('0'); - } - maybeU64() { - const offset = this.bb.__offset(this.bb_pos, 48); - return offset ? this.bb.readUint64(this.bb_pos + offset) : null; - } - defaultU64() { - const offset = this.bb.__offset(this.bb_pos, 50); - return offset ? this.bb.readUint64(this.bb_pos + offset) : BigInt('42'); - } - justF32() { - const offset = this.bb.__offset(this.bb_pos, 52); - return offset ? this.bb.readFloat32(this.bb_pos + offset) : 0.0; - } - maybeF32() { - const offset = this.bb.__offset(this.bb_pos, 54); - return offset ? this.bb.readFloat32(this.bb_pos + offset) : null; - } - defaultF32() { - const offset = this.bb.__offset(this.bb_pos, 56); - return offset ? this.bb.readFloat32(this.bb_pos + offset) : 42.0; - } - justF64() { - const offset = this.bb.__offset(this.bb_pos, 58); - return offset ? this.bb.readFloat64(this.bb_pos + offset) : 0.0; - } - maybeF64() { - const offset = this.bb.__offset(this.bb_pos, 60); - return offset ? this.bb.readFloat64(this.bb_pos + offset) : null; - } - defaultF64() { - const offset = this.bb.__offset(this.bb_pos, 62); - return offset ? this.bb.readFloat64(this.bb_pos + offset) : 42.0; - } - justBool() { - const offset = this.bb.__offset(this.bb_pos, 64); - return offset ? !!this.bb.readInt8(this.bb_pos + offset) : false; - } - maybeBool() { - const offset = this.bb.__offset(this.bb_pos, 66); - return offset ? !!this.bb.readInt8(this.bb_pos + offset) : null; - } - defaultBool() { - const offset = this.bb.__offset(this.bb_pos, 68); - return offset ? !!this.bb.readInt8(this.bb_pos + offset) : true; - } - justEnum() { - const offset = this.bb.__offset(this.bb_pos, 70); - return offset ? this.bb.readInt8(this.bb_pos + offset) : OptionalByte.None; - } - maybeEnum() { - const offset = this.bb.__offset(this.bb_pos, 72); - return offset ? this.bb.readInt8(this.bb_pos + offset) : null; - } - defaultEnum() { - const offset = this.bb.__offset(this.bb_pos, 74); - return offset ? this.bb.readInt8(this.bb_pos + offset) : OptionalByte.One; - } - static startScalarStuff(builder) { - builder.startObject(36); - } - static addJustI8(builder, justI8) { - builder.addFieldInt8(0, justI8, 0); - } - static addMaybeI8(builder, maybeI8) { - builder.addFieldInt8(1, maybeI8, 0); - } - static addDefaultI8(builder, defaultI8) { - builder.addFieldInt8(2, defaultI8, 42); - } - static addJustU8(builder, justU8) { - builder.addFieldInt8(3, justU8, 0); - } - static addMaybeU8(builder, maybeU8) { - builder.addFieldInt8(4, maybeU8, 0); - } - static addDefaultU8(builder, defaultU8) { - builder.addFieldInt8(5, defaultU8, 42); - } - static addJustI16(builder, justI16) { - builder.addFieldInt16(6, justI16, 0); - } - static addMaybeI16(builder, maybeI16) { - builder.addFieldInt16(7, maybeI16, 0); - } - static addDefaultI16(builder, defaultI16) { - builder.addFieldInt16(8, defaultI16, 42); - } - static addJustU16(builder, justU16) { - builder.addFieldInt16(9, justU16, 0); - } - static addMaybeU16(builder, maybeU16) { - builder.addFieldInt16(10, maybeU16, 0); - } - static addDefaultU16(builder, defaultU16) { - builder.addFieldInt16(11, defaultU16, 42); - } - static addJustI32(builder, justI32) { - builder.addFieldInt32(12, justI32, 0); - } - static addMaybeI32(builder, maybeI32) { - builder.addFieldInt32(13, maybeI32, 0); - } - static addDefaultI32(builder, defaultI32) { - builder.addFieldInt32(14, defaultI32, 42); - } - static addJustU32(builder, justU32) { - builder.addFieldInt32(15, justU32, 0); - } - static addMaybeU32(builder, maybeU32) { - builder.addFieldInt32(16, maybeU32, 0); - } - static addDefaultU32(builder, defaultU32) { - builder.addFieldInt32(17, defaultU32, 42); - } - static addJustI64(builder, justI64) { - builder.addFieldInt64(18, justI64, BigInt('0')); - } - static addMaybeI64(builder, maybeI64) { - builder.addFieldInt64(19, maybeI64, BigInt(0)); - } - static addDefaultI64(builder, defaultI64) { - builder.addFieldInt64(20, defaultI64, BigInt('42')); - } - static addJustU64(builder, justU64) { - builder.addFieldInt64(21, justU64, BigInt('0')); - } - static addMaybeU64(builder, maybeU64) { - builder.addFieldInt64(22, maybeU64, BigInt(0)); - } - static addDefaultU64(builder, defaultU64) { - builder.addFieldInt64(23, defaultU64, BigInt('42')); - } - static addJustF32(builder, justF32) { - builder.addFieldFloat32(24, justF32, 0.0); - } - static addMaybeF32(builder, maybeF32) { - builder.addFieldFloat32(25, maybeF32, 0); - } - static addDefaultF32(builder, defaultF32) { - builder.addFieldFloat32(26, defaultF32, 42.0); - } - static addJustF64(builder, justF64) { - builder.addFieldFloat64(27, justF64, 0.0); - } - static addMaybeF64(builder, maybeF64) { - builder.addFieldFloat64(28, maybeF64, 0); - } - static addDefaultF64(builder, defaultF64) { - builder.addFieldFloat64(29, defaultF64, 42.0); - } - static addJustBool(builder, justBool) { - builder.addFieldInt8(30, +justBool, +false); - } - static addMaybeBool(builder, maybeBool) { - builder.addFieldInt8(31, +maybeBool, 0); - } - static addDefaultBool(builder, defaultBool) { - builder.addFieldInt8(32, +defaultBool, +true); - } - static addJustEnum(builder, justEnum) { - builder.addFieldInt8(33, justEnum, OptionalByte.None); - } - static addMaybeEnum(builder, maybeEnum) { - builder.addFieldInt8(34, maybeEnum, 0); - } - static addDefaultEnum(builder, defaultEnum) { - builder.addFieldInt8(35, defaultEnum, OptionalByte.One); - } - static endScalarStuff(builder) { - const offset = builder.endObject(); - return offset; - } - static finishScalarStuffBuffer(builder, offset) { - builder.finish(offset, 'NULL'); - } - static finishSizePrefixedScalarStuffBuffer(builder, offset) { - builder.finish(offset, 'NULL', true); - } - static createScalarStuff(builder, justI8, maybeI8, defaultI8, justU8, maybeU8, defaultU8, justI16, maybeI16, defaultI16, justU16, maybeU16, defaultU16, justI32, maybeI32, defaultI32, justU32, maybeU32, defaultU32, justI64, maybeI64, defaultI64, justU64, maybeU64, defaultU64, justF32, maybeF32, defaultF32, justF64, maybeF64, defaultF64, justBool, maybeBool, defaultBool, justEnum, maybeEnum, defaultEnum) { - 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/scalar-stuff.ts b/tests/optional_scalars/scalar-stuff.ts deleted file mode 100644 index 38d7cccb993..00000000000 --- a/tests/optional_scalars/scalar-stuff.ts +++ /dev/null @@ -1,423 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -import * as flatbuffers from 'flatbuffers'; - -import { OptionalByte } from '../optional_scalars/optional-byte'; - - -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 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/ts/JavaScriptTestv1.cjs b/tests/ts/JavaScriptTestv1.cjs new file mode 100644 index 00000000000..6ca27275074 --- /dev/null +++ b/tests/ts/JavaScriptTestv1.cjs @@ -0,0 +1,367 @@ +// Run this using JavaScriptTest.sh +var assert = require('assert'); +var fs = require('fs'); + +var flatbuffers = require('../../js/flatbuffers'); +var MyGame = require(process.argv[2]).MyGame; + +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')); + + // Now test it: + + var bb = new flatbuffers.ByteBuffer(data); + testBuffer(bb); + + // Second, let's create a FlatBuffer from scratch in JavaScript, and test it also. + // We use an initial size of 1 to exercise the reallocation algorithm, + // normally a size larger than the typical FlatBuffer you generate would be + // better for performance. + var fbb = new flatbuffers.Builder(1); + createMonster(fbb); + serializeAndTest(fbb); + + // clear the builder, repeat tests + var clearIterations = 100; + var startingCapacity = fbb.bb.capacity(); + for (var i = 0; i < clearIterations; i++) { + fbb.clear(); + createMonster(fbb); + serializeAndTest(fbb); + } + // the capacity of our buffer shouldn't increase with the same size payload + assert.strictEqual(fbb.bb.capacity(), startingCapacity); + + test64bit(); + testUnicode(); + fuzzTest1(); + + console.log('FlatBuffers test: completed successfully'); +} + +function createMonster(fbb) { + // We set up the same values as monsterdata.json: + + var str = fbb.createString('MyMonster'); + + var inv = MyGame.Example.Monster.createInventoryVector(fbb, [0, 1, 2, 3, 4]); + + var fred = fbb.createString('Fred'); + MyGame.Example.Monster.startMonster(fbb); + MyGame.Example.Monster.addName(fbb, fred); + var mon2 = MyGame.Example.Monster.endMonster(fbb); + + MyGame.Example.Monster.startTest4Vector(fbb, 2); + MyGame.Example.Test.createTest(fbb, 10, 20); + MyGame.Example.Test.createTest(fbb, 30, 40); + var test4 = fbb.endVector(); + + var testArrayOfString = MyGame.Example.Monster.createTestarrayofstringVector(fbb, [ + fbb.createString('test1'), + fbb.createString('test2') + ]); + + MyGame.Example.Monster.startMonster(fbb); + MyGame.Example.Monster.addPos(fbb, MyGame.Example.Vec3.createVec3(fbb, 1, 2, 3, 3, MyGame.Example.Color.Green, 5, 6)); + MyGame.Example.Monster.addHp(fbb, 80); + MyGame.Example.Monster.addName(fbb, str); + MyGame.Example.Monster.addInventory(fbb, inv); + MyGame.Example.Monster.addTestType(fbb, MyGame.Example.Any.Monster); + MyGame.Example.Monster.addTest(fbb, mon2); + MyGame.Example.Monster.addTest4(fbb, test4); + MyGame.Example.Monster.addTestarrayofstring(fbb, testArrayOfString); + MyGame.Example.Monster.addTestbool(fbb, true); + var mon = MyGame.Example.Monster.endMonster(fbb); + + MyGame.Example.Monster.finishMonsterBuffer(fbb, mon); +} + +function serializeAndTest(fbb) { + // Write the result to a file for debugging purposes: + // Note that the binaries are not necessarily identical, since the JSON + // parser may serialize in a slightly different order than the above + // JavaScript code. They are functionally equivalent though. + + fs.writeFileSync('monsterdata_javascript_wire.mon', new Buffer(fbb.asUint8Array())); + + // Tests mutation first. This will verify that we did not trample any other + // part of the byte buffer. + testMutation(fbb.dataBuffer()); + + testBuffer(fbb.dataBuffer()); +} + +function testMutation(bb) { + var monster = MyGame.Example.Monster.getRootAsMonster(bb); + + monster.mutate_hp(120); + assert.strictEqual(monster.hp(), 120); + + monster.mutate_hp(80); + assert.strictEqual(monster.hp(), 80); + + var manaRes = monster.mutate_mana(10); + assert.strictEqual(manaRes, false); // Field was NOT present, because default value. + + // TODO: There is not the availability to mutate structs or vectors. +} + +function testBuffer(bb) { + assert.ok(MyGame.Example.Monster.bufferHasIdentifier(bb)); + + var monster = MyGame.Example.Monster.getRootAsMonster(bb); + + assert.strictEqual(monster.hp(), 80); + assert.strictEqual(monster.mana(), 150); // default + + assert.strictEqual(monster.name(), 'MyMonster'); + + var pos = monster.pos(); + assert.strictEqual(pos.x(), 1); + assert.strictEqual(pos.y(), 2); + assert.strictEqual(pos.z(), 3); + assert.strictEqual(pos.test1(), 3); + assert.strictEqual(pos.test2(), MyGame.Example.Color.Green); + var t = pos.test3(); + assert.strictEqual(t.a(), 5); + assert.strictEqual(t.b(), 6); + + assert.strictEqual(monster.testType(), MyGame.Example.Any.Monster); + var monster2 = new MyGame.Example.Monster(); + assert.strictEqual(monster.test(monster2) != null, true); + assert.strictEqual(monster2.name(), 'Fred'); + + assert.strictEqual(monster.inventoryLength(), 5); + var invsum = 0; + for (var i = 0; i < monster.inventoryLength(); i++) { + invsum += monster.inventory(i); + } + assert.strictEqual(invsum, 10); + + var invsum2 = 0; + var invArr = monster.inventoryArray(); + for (var i = 0; i < invArr.length; i++) { + invsum2 += invArr[i]; + } + assert.strictEqual(invsum2, 10); + + var test_0 = monster.test4(0); + var test_1 = monster.test4(1); + assert.strictEqual(monster.test4Length(), 2); + assert.strictEqual(test_0.a() + test_0.b() + test_1.a() + test_1.b(), 100); + + assert.strictEqual(monster.testarrayofstringLength(), 2); + assert.strictEqual(monster.testarrayofstring(0), 'test1'); + assert.strictEqual(monster.testarrayofstring(1), 'test2'); + + assert.strictEqual(monster.testbool(), true); +} + +function test64bit() { + var fbb = new flatbuffers.Builder(); + var required = fbb.createString('required'); + + MyGame.Example.Stat.startStat(fbb); + var stat2 = MyGame.Example.Stat.endStat(fbb); + + MyGame.Example.Monster.startMonster(fbb); + MyGame.Example.Monster.addName(fbb, required); + MyGame.Example.Monster.addTestempty(fbb, stat2); + var mon2 = MyGame.Example.Monster.endMonster(fbb); + + MyGame.Example.Stat.startStat(fbb); + MyGame.Example.Stat.addVal(fbb, 0x2345678987654321n); + var stat = MyGame.Example.Stat.endStat(fbb); + + MyGame.Example.Monster.startMonster(fbb); + MyGame.Example.Monster.addName(fbb, required); + MyGame.Example.Monster.addEnemy(fbb, mon2); + MyGame.Example.Monster.addTestempty(fbb, stat); + var mon = MyGame.Example.Monster.endMonster(fbb); + + MyGame.Example.Monster.finishMonsterBuffer(fbb, mon); + var bytes = fbb.asUint8Array(); + + //////////////////////////////////////////////////////////////// + + var bb = new flatbuffers.ByteBuffer(bytes); + assert.ok(MyGame.Example.Monster.bufferHasIdentifier(bb)); + var mon = MyGame.Example.Monster.getRootAsMonster(bb); + + var stat = mon.testempty(); + assert.strictEqual(stat != null, true); + assert.strictEqual(stat.val() != null, true); + assert.strictEqual(stat.val(), 2541551405100253985n); + + var mon2 = mon.enemy(); + assert.strictEqual(mon2 != null, true); + stat = mon2.testempty(); + assert.strictEqual(stat != null, true); + assert.strictEqual(stat.val() != null, true); + assert.strictEqual(stat.val(), 0n); // default value +} + +function testUnicode() { + var correct = fs.readFileSync('unicode_test.mon'); + var json = JSON.parse(fs.readFileSync('../unicode_test.json', 'utf8')); + + // Test reading + function testReadingUnicode(bb) { + var monster = MyGame.Example.Monster.getRootAsMonster(bb); + assert.strictEqual(monster.name(), json.name); + assert.deepEqual(new Buffer(monster.name(flatbuffers.Encoding.UTF8_BYTES)), new Buffer(json.name)); + assert.strictEqual(monster.testarrayoftablesLength(), json.testarrayoftables.length); + json.testarrayoftables.forEach(function(table, i) { + var value = monster.testarrayoftables(i); + assert.strictEqual(value.name(), table.name); + assert.deepEqual(new Buffer(value.name(flatbuffers.Encoding.UTF8_BYTES)), new Buffer(table.name)); + }); + assert.strictEqual(monster.testarrayofstringLength(), json.testarrayofstring.length); + json.testarrayofstring.forEach(function(string, i) { + assert.strictEqual(monster.testarrayofstring(i), string); + assert.deepEqual(new Buffer(monster.testarrayofstring(i, flatbuffers.Encoding.UTF8_BYTES)), new Buffer(string)); + }); + } + testReadingUnicode(new flatbuffers.ByteBuffer(new Uint8Array(correct))); + + // Test writing + var fbb = new flatbuffers.Builder(); + var name = fbb.createString(json.name); + var testarrayoftablesOffsets = json.testarrayoftables.map(function(table) { + var name = fbb.createString(new Uint8Array(new Buffer(table.name))); + MyGame.Example.Monster.startMonster(fbb); + MyGame.Example.Monster.addName(fbb, name); + return MyGame.Example.Monster.endMonster(fbb); + }); + var testarrayoftablesOffset = MyGame.Example.Monster.createTestarrayoftablesVector(fbb, + testarrayoftablesOffsets); + var testarrayofstringOffset = MyGame.Example.Monster.createTestarrayofstringVector(fbb, + json.testarrayofstring.map(function(string) { return fbb.createString(string); })); + MyGame.Example.Monster.startMonster(fbb); + MyGame.Example.Monster.addTestarrayofstring(fbb, testarrayofstringOffset); + MyGame.Example.Monster.addTestarrayoftables(fbb, testarrayoftablesOffset); + MyGame.Example.Monster.addName(fbb, name); + MyGame.Example.Monster.finishSizePrefixedMonsterBuffer(fbb, MyGame.Example.Monster.endMonster(fbb)); + var bb = new flatbuffers.ByteBuffer(fbb.asUint8Array()) + bb.setPosition(4); + testReadingUnicode(bb); +} + +var __imul = Math.imul ? Math.imul : function(a, b) { + var ah = a >> 16 & 65535; + var bh = b >> 16 & 65535; + var al = a & 65535; + var bl = b & 65535; + return al * bl + (ah * bl + al * bh << 16) | 0; +}; + +// Include simple random number generator to ensure results will be the +// same cross platform. +// http://en.wikipedia.org/wiki/Park%E2%80%93Miller_random_number_generator +var lcg_seed = 48271; + +function lcg_rand() { + return lcg_seed = (__imul(lcg_seed, 279470273) >>> 0) % 4294967291; +} + +function lcg_reset() { + lcg_seed = 48271; +} + +// Converts a Field ID to a virtual table offset. +function fieldIndexToOffset(field_id) { + // Should correspond to what EndTable() below builds up. + var fixed_fields = 2; // Vtable size and Object Size. + return (field_id + fixed_fields) * 2; +} + +// Low level stress/fuzz test: serialize/deserialize a variety of +// different kinds of data in different combinations +function fuzzTest1() { + + // Values we're testing against: chosen to ensure no bits get chopped + // off anywhere, and also be different from eachother. + var bool_val = true; + var char_val = -127; // 0x81 + var uchar_val = 0xFF; + var short_val = -32222; // 0x8222; + var ushort_val = 0xFEEE; + var int_val = 0x83333333 | 0; + var uint_val = 0xFDDDDDDD; + var long_val = BigInt.asIntN(64, 0x8444444444444444n); + var ulong_val = BigInt.asUintN(64, 0xFCCCCCCCCCCCCCCCn); + var float_val = new Float32Array([3.14159])[0]; + var double_val = 3.14159265359; + + var test_values_max = 11; + var fields_per_object = 4; + var num_fuzz_objects = 10000; // The higher, the more thorough :) + + var builder = new flatbuffers.Builder(); + + lcg_reset(); // Keep it deterministic. + + var objects = []; + + // Generate num_fuzz_objects random objects each consisting of + // fields_per_object fields, each of a random type. + for (var i = 0; i < num_fuzz_objects; i++) { + builder.startObject(fields_per_object); + for (var f = 0; f < fields_per_object; f++) { + var choice = lcg_rand() % test_values_max; + switch (choice) { + case 0: builder.addFieldInt8(f, bool_val, 0); break; + case 1: builder.addFieldInt8(f, char_val, 0); break; + case 2: builder.addFieldInt8(f, uchar_val, 0); break; + case 3: builder.addFieldInt16(f, short_val, 0); break; + case 4: builder.addFieldInt16(f, ushort_val, 0); break; + case 5: builder.addFieldInt32(f, int_val, 0); break; + case 6: builder.addFieldInt32(f, uint_val, 0); break; + case 7: builder.addFieldInt64(f, long_val, 0n); break; + case 8: builder.addFieldInt64(f, ulong_val, 0n); break; + case 9: builder.addFieldFloat32(f, float_val, 0); break; + case 10: builder.addFieldFloat64(f, double_val, 0); break; + } + } + objects.push(builder.endObject()); + } + builder.prep(8, 0); // Align whole buffer. + + lcg_reset(); // Reset. + + builder.finish(objects[objects.length - 1]); + var bytes = new Uint8Array(builder.asUint8Array()); + var view = new DataView(bytes.buffer); + + // Test that all objects we generated are readable and return the + // expected values. We generate random objects in the same order + // so this is deterministic. + for (var i = 0; i < num_fuzz_objects; i++) { + var offset = bytes.length - objects[i]; + for (var f = 0; f < fields_per_object; f++) { + var choice = lcg_rand() % test_values_max; + var vtable_offset = fieldIndexToOffset(f); + var vtable = offset - view.getInt32(offset, true); + assert.ok(vtable_offset < view.getInt16(vtable, true)); + var field_offset = offset + view.getInt16(vtable + vtable_offset, true); + switch (choice) { + case 0: assert.strictEqual(!!view.getInt8(field_offset), bool_val); break; + case 1: assert.strictEqual(view.getInt8(field_offset), char_val); break; + case 2: assert.strictEqual(view.getUint8(field_offset), uchar_val); break; + case 3: assert.strictEqual(view.getInt16(field_offset, true), short_val); break; + case 4: assert.strictEqual(view.getUint16(field_offset, true), ushort_val); break; + case 5: assert.strictEqual(view.getInt32(field_offset, true), int_val); break; + case 6: assert.strictEqual(view.getUint32(field_offset, true), uint_val); break; + case 7: assert.strictEqual(view.getBigInt64(field_offset, true), long_val); break; + case 8: assert.strictEqual(view.getBigUint64(field_offset, true), ulong_val); break; + case 9: assert.strictEqual(view.getFloat32(field_offset, true), float_val); break; + case 10: assert.strictEqual(view.getFloat64(field_offset, true), double_val); break; + } + } + } +} + +main(); \ No newline at end of file diff --git a/tests/ts/TypeScriptTest.py b/tests/ts/TypeScriptTest.py index bb8dfcad439..52d0001001e 100755 --- a/tests/ts/TypeScriptTest.py +++ b/tests/ts/TypeScriptTest.py @@ -61,7 +61,7 @@ def flatc(options, schema, prefix=None, include=None, data=None, cwd=tests_path) print("Invoking flatc...") flatc( - options=["--ts", "--reflect-names", "--gen-name-strings", "--gen-mutable", "--gen-object-api"], + options=["--ts", "--reflect-names", "--gen-name-strings", "--gen-mutable", "--gen-object-api", "--ts-entry-points", "--ts-flat-files"], schema="../monster_test.fbs", include="../include_test", ) @@ -74,7 +74,7 @@ def flatc(options, schema, prefix=None, include=None, data=None, cwd=tests_path) ) flatc( - options=["--ts", "--reflect-names", "--gen-name-strings", "--gen-mutable", "--gen-object-api"], + options=["--ts", "--reflect-names", "--gen-name-strings", "--gen-mutable", "--gen-object-api", "--ts-entry-points", "--ts-flat-files"], schema="../union_vector/union_vector.fbs", prefix="union_vector", ) @@ -84,17 +84,6 @@ def flatc(options, schema, prefix=None, include=None, data=None, cwd=tests_path) schema="../optional_scalars.fbs", ) -flatc( - options=["--ts", "--reflect-names", "--gen-name-strings", "--gen-mutable", "--gen-object-api"], - schema=[ - "typescript_keywords.fbs", - "test_dir/typescript_include.fbs", - "test_dir/typescript_transitive_include.fbs", - "../../reflection/reflection.fbs", - ], - include="../../", -) - flatc( options=["--ts", "--reflect-names", "--ts-flat-files", "--gen-name-strings", "--gen-object-api"], schema="arrays_test_complex/arrays_test_complex.fbs", @@ -102,14 +91,7 @@ def flatc(options, schema, prefix=None, include=None, data=None, cwd=tests_path) ) flatc( - options=[ - "--ts", - "--reflect-names", - "--gen-name-strings", - "--gen-mutable", - "--gen-object-api", - "--ts-flat-files", - ], + options=["--ts", "--reflect-names", "--gen-name-strings", "--gen-mutable", "--gen-object-api", "--ts-entry-points", "--ts-flat-files"], schema=[ "typescript_keywords.fbs", "test_dir/typescript_include.fbs", diff --git a/tests/ts/typescript_transitive_include_generated.ts b/tests/ts/foobar.ts similarity index 64% rename from tests/ts/typescript_transitive_include_generated.ts rename to tests/ts/foobar.ts index 6bb16014826..067b4860ee5 100644 --- a/tests/ts/typescript_transitive_include_generated.ts +++ b/tests/ts/foobar.ts @@ -1,7 +1,3 @@ // automatically generated by the FlatBuffers compiler, do not modify - -export enum Abc { - a = 0 -} - +export { Abc } from './foobar/abc.js'; diff --git a/tests/ts/foobar/abc.js b/tests/ts/foobar/abc.js index cdef988d941..40f0d7a2b4e 100644 --- a/tests/ts/foobar/abc.js +++ b/tests/ts/foobar/abc.js @@ -2,4 +2,4 @@ export var Abc; (function (Abc) { Abc[Abc["a"] = 0] = "a"; -})(Abc || (Abc = {})); +})(Abc = Abc || (Abc = {})); diff --git a/tests/ts/foobar/class.js b/tests/ts/foobar/class.js index e0e1df1bea2..d278ac94638 100644 --- a/tests/ts/foobar/class.js +++ b/tests/ts/foobar/class.js @@ -2,4 +2,4 @@ export var class_; (function (class_) { class_[class_["arguments_"] = 0] = "arguments_"; -})(class_ || (class_ = {})); +})(class_ = class_ || (class_ = {})); diff --git a/tests/ts/monster_test.js b/tests/ts/monster_test.js index afc333eeb94..da2897c6e95 100644 --- a/tests/ts/monster_test.js +++ b/tests/ts/monster_test.js @@ -1,17 +1,3 @@ -export { Monster as MyGameExample2Monster, MonsterT as MyGameExample2MonsterT } from './my-game/example2/monster'; -export { Ability, AbilityT } from './my-game/example/ability'; -export { Any, unionToAny, unionListToAny } from './my-game/example/any'; -export { AnyAmbiguousAliases, unionToAnyAmbiguousAliases, unionListToAnyAmbiguousAliases } from './my-game/example/any-ambiguous-aliases'; -export { AnyUniqueAliases, unionToAnyUniqueAliases, unionListToAnyUniqueAliases } from './my-game/example/any-unique-aliases'; -export { Color } from './my-game/example/color'; -export { Monster, MonsterT } from './my-game/example/monster'; -export { Race } from './my-game/example/race'; -export { Referrable, ReferrableT } from './my-game/example/referrable'; -export { Stat, StatT } from './my-game/example/stat'; -export { StructOfStructs, StructOfStructsT } from './my-game/example/struct-of-structs'; -export { StructOfStructsOfStructs, StructOfStructsOfStructsT } from './my-game/example/struct-of-structs-of-structs'; -export { Test, TestT } from './my-game/example/test'; -export { TestSimpleTableWithEnum, TestSimpleTableWithEnumT } from './my-game/example/test-simple-table-with-enum'; -export { TypeAliases, TypeAliasesT } from './my-game/example/type-aliases'; -export { Vec3, Vec3T } from './my-game/example/vec3'; -export { InParentNamespace, InParentNamespaceT } from './my-game/in-parent-namespace'; +// automatically generated by the FlatBuffers compiler, do not modify +export { TableA } from './table-a.js'; +export * as MyGame from './my-game.js'; diff --git a/tests/ts/monster_test.ts b/tests/ts/monster_test.ts index afc333eeb94..771db3b38e1 100644 --- a/tests/ts/monster_test.ts +++ b/tests/ts/monster_test.ts @@ -1,17 +1,4 @@ -export { Monster as MyGameExample2Monster, MonsterT as MyGameExample2MonsterT } from './my-game/example2/monster'; -export { Ability, AbilityT } from './my-game/example/ability'; -export { Any, unionToAny, unionListToAny } from './my-game/example/any'; -export { AnyAmbiguousAliases, unionToAnyAmbiguousAliases, unionListToAnyAmbiguousAliases } from './my-game/example/any-ambiguous-aliases'; -export { AnyUniqueAliases, unionToAnyUniqueAliases, unionListToAnyUniqueAliases } from './my-game/example/any-unique-aliases'; -export { Color } from './my-game/example/color'; -export { Monster, MonsterT } from './my-game/example/monster'; -export { Race } from './my-game/example/race'; -export { Referrable, ReferrableT } from './my-game/example/referrable'; -export { Stat, StatT } from './my-game/example/stat'; -export { StructOfStructs, StructOfStructsT } from './my-game/example/struct-of-structs'; -export { StructOfStructsOfStructs, StructOfStructsOfStructsT } from './my-game/example/struct-of-structs-of-structs'; -export { Test, TestT } from './my-game/example/test'; -export { TestSimpleTableWithEnum, TestSimpleTableWithEnumT } from './my-game/example/test-simple-table-with-enum'; -export { TypeAliases, TypeAliasesT } from './my-game/example/type-aliases'; -export { Vec3, Vec3T } from './my-game/example/vec3'; -export { InParentNamespace, InParentNamespaceT } from './my-game/in-parent-namespace'; +// automatically generated by the FlatBuffers compiler, do not modify + +export { TableA } from './table-a.js'; +export * as MyGame from './my-game.js'; diff --git a/tests/ts/monster_test_generated.js b/tests/ts/monster_test_generated.js new file mode 100644 index 00000000000..ffd9dedc1c3 --- /dev/null +++ b/tests/ts/monster_test_generated.js @@ -0,0 +1,2336 @@ +"use strict"; +var __create = Object.create; +var __defProp = Object.defineProperty; +var __getOwnPropDesc = Object.getOwnPropertyDescriptor; +var __getOwnPropNames = Object.getOwnPropertyNames; +var __getProtoOf = Object.getPrototypeOf; +var __hasOwnProp = Object.prototype.hasOwnProperty; +var __export = (target, all) => { + for (var name in all) + __defProp(target, name, { get: all[name], enumerable: true }); +}; +var __copyProps = (to, from, except, desc) => { + if (from && typeof from === "object" || typeof from === "function") { + for (let key of __getOwnPropNames(from)) + if (!__hasOwnProp.call(to, key) && key !== except) + __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); + } + return to; +}; +var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( + isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, + mod +)); +var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); + +// my-game/example.ts +var example_exports = {}; +__export(example_exports, { + Ability: () => Ability, + Any: () => Any, + AnyAmbiguousAliases: () => AnyAmbiguousAliases, + AnyUniqueAliases: () => AnyUniqueAliases, + Color: () => Color, + LongEnum: () => LongEnum, + Monster: () => Monster2, + Race: () => Race, + Referrable: () => Referrable, + Stat: () => Stat, + StructOfStructs: () => StructOfStructs, + StructOfStructsOfStructs: () => StructOfStructsOfStructs, + Test: () => Test, + TestSimpleTableWithEnum: () => TestSimpleTableWithEnum, + TypeAliases: () => TypeAliases, + Vec3: () => Vec3 +}); +module.exports = __toCommonJS(example_exports); + +// my-game/example/ability.js +var Ability = class { + 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(); + } +}; +var AbilityT = class { + constructor(id = 0, distance = 0) { + this.id = id; + this.distance = distance; + } + pack(builder) { + return Ability.createAbility(builder, this.id, this.distance); + } +}; + +// my-game/example2/monster.js +var flatbuffers = __toESM(require("flatbuffers"), 1); +var Monster = class { + 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) { + } +}; +var MonsterT = class { + constructor() { + } + pack(builder) { + return Monster.createMonster(builder); + } +}; + +// my-game/example/monster.js +var flatbuffers6 = __toESM(require("flatbuffers"), 1); + +// my-game/example/any-ambiguous-aliases.js +var AnyAmbiguousAliases; +(function(AnyAmbiguousAliases2) { + AnyAmbiguousAliases2[AnyAmbiguousAliases2["NONE"] = 0] = "NONE"; + AnyAmbiguousAliases2[AnyAmbiguousAliases2["M1"] = 1] = "M1"; + AnyAmbiguousAliases2[AnyAmbiguousAliases2["M2"] = 2] = "M2"; + AnyAmbiguousAliases2[AnyAmbiguousAliases2["M3"] = 3] = "M3"; +})(AnyAmbiguousAliases = AnyAmbiguousAliases || (AnyAmbiguousAliases = {})); +function unionToAnyAmbiguousAliases(type, accessor) { + switch (AnyAmbiguousAliases[type]) { + case "NONE": + return null; + case "M1": + return accessor(new Monster2()); + case "M2": + return accessor(new Monster2()); + case "M3": + return accessor(new Monster2()); + default: + return null; + } +} + +// my-game/example/test-simple-table-with-enum.js +var flatbuffers2 = __toESM(require("flatbuffers"), 1); + +// my-game/example/color.js +var Color; +(function(Color2) { + Color2[Color2["Red"] = 1] = "Red"; + Color2[Color2["Green"] = 2] = "Green"; + Color2[Color2["Blue"] = 8] = "Blue"; +})(Color = Color || (Color = {})); + +// my-game/example/test-simple-table-with-enum.js +var TestSimpleTableWithEnum = class { + 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() + flatbuffers2.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 flatbuffers2.ByteBuffer(buffer)); + } + unpack() { + return new TestSimpleTableWithEnumT(this.color()); + } + unpackTo(_o) { + _o.color = this.color(); + } +}; +var TestSimpleTableWithEnumT = class { + constructor(color = Color.Green) { + this.color = color; + } + pack(builder) { + return TestSimpleTableWithEnum.createTestSimpleTableWithEnum(builder, this.color); + } +}; + +// my-game/example/any-unique-aliases.js +var AnyUniqueAliases; +(function(AnyUniqueAliases2) { + AnyUniqueAliases2[AnyUniqueAliases2["NONE"] = 0] = "NONE"; + AnyUniqueAliases2[AnyUniqueAliases2["M"] = 1] = "M"; + AnyUniqueAliases2[AnyUniqueAliases2["TS"] = 2] = "TS"; + AnyUniqueAliases2[AnyUniqueAliases2["M2"] = 3] = "M2"; +})(AnyUniqueAliases = AnyUniqueAliases || (AnyUniqueAliases = {})); +function unionToAnyUniqueAliases(type, accessor) { + switch (AnyUniqueAliases[type]) { + case "NONE": + return null; + case "M": + return accessor(new Monster2()); + case "TS": + return accessor(new TestSimpleTableWithEnum()); + case "M2": + return accessor(new Monster()); + default: + return null; + } +} + +// my-game/example/race.js +var Race; +(function(Race2) { + Race2[Race2["None"] = -1] = "None"; + Race2[Race2["Human"] = 0] = "Human"; + Race2[Race2["Dwarf"] = 1] = "Dwarf"; + Race2[Race2["Elf"] = 2] = "Elf"; +})(Race = Race || (Race = {})); + +// my-game/example/referrable.js +var flatbuffers3 = __toESM(require("flatbuffers"), 1); +var Referrable = class { + 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() + flatbuffers3.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 flatbuffers3.ByteBuffer(buffer)); + } + unpack() { + return new ReferrableT(this.id()); + } + unpackTo(_o) { + _o.id = this.id(); + } +}; +var ReferrableT = class { + constructor(id = BigInt("0")) { + this.id = id; + } + pack(builder) { + return Referrable.createReferrable(builder, this.id); + } +}; + +// my-game/example/stat.js +var flatbuffers4 = __toESM(require("flatbuffers"), 1); +var Stat = class { + 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() + flatbuffers4.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 flatbuffers4.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(); + } +}; +var StatT = class { + 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); + } +}; + +// my-game/example/test.js +var Test = class { + 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(); + } +}; +var TestT = class { + constructor(a = 0, b = 0) { + this.a = a; + this.b = b; + } + pack(builder) { + return Test.createTest(builder, this.a, this.b); + } +}; + +// my-game/example/vec3.js +var Vec3 = class { + 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; + } +}; +var Vec3T = class { + constructor(x = 0, y = 0, z = 0, test1 = 0, test2 = 0, test3 = null) { + this.x = x; + this.y = y; + this.z = z; + this.test1 = test1; + this.test2 = test2; + this.test3 = test3; + } + pack(builder) { + return Vec3.createVec3(builder, this.x, this.y, this.z, this.test1, this.test2, this.test3?.a ?? 0, this.test3?.b ?? 0); + } +}; + +// my-game/in-parent-namespace.js +var flatbuffers5 = __toESM(require("flatbuffers"), 1); +var InParentNamespace = class { + 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() + flatbuffers5.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 flatbuffers5.ByteBuffer(buffer)); + } + unpack() { + return new InParentNamespaceT(); + } + unpackTo(_o) { + } +}; +var InParentNamespaceT = class { + constructor() { + } + pack(builder) { + return InParentNamespace.createInParentNamespace(builder); + } +}; + +// my-game/example/monster.js +var Monster2 = class { + 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 Monster2()).__init(bb.readInt32(bb.position()) + bb.position(), bb); + } + static getSizePrefixedRootAsMonster(bb, obj) { + bb.setPosition(bb.position() + flatbuffers6.SIZE_PREFIX_LENGTH); + return (obj || new Monster2()).__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; + } + testarrayoftables(index, obj) { + const offset = this.bb.__offset(this.bb_pos, 26); + return offset ? (obj || new Monster2()).__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 Monster2()).__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; + } + 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; + } + 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; + } + nanDefault() { + const offset = this.bb.__offset(this.bb_pos, 112); + return offset ? this.bb.readFloat32(this.bb_pos + offset) : NaN; + } + mutate_nan_default(value) { + const offset = this.bb.__offset(this.bb_pos, 112); + if (offset === 0) { + return false; + } + this.bb.writeFloat32(this.bb_pos + offset, value); + return true; + } + infDefault() { + const offset = this.bb.__offset(this.bb_pos, 114); + return offset ? this.bb.readFloat32(this.bb_pos + offset) : Infinity; + } + mutate_inf_default(value) { + const offset = this.bb.__offset(this.bb_pos, 114); + if (offset === 0) { + return false; + } + this.bb.writeFloat32(this.bb_pos + offset, value); + return true; + } + positiveInfDefault() { + const offset = this.bb.__offset(this.bb_pos, 116); + return offset ? this.bb.readFloat32(this.bb_pos + offset) : Infinity; + } + mutate_positive_inf_default(value) { + const offset = this.bb.__offset(this.bb_pos, 116); + if (offset === 0) { + return false; + } + this.bb.writeFloat32(this.bb_pos + offset, value); + return true; + } + infinityDefault() { + const offset = this.bb.__offset(this.bb_pos, 118); + return offset ? this.bb.readFloat32(this.bb_pos + offset) : Infinity; + } + mutate_infinity_default(value) { + const offset = this.bb.__offset(this.bb_pos, 118); + if (offset === 0) { + return false; + } + this.bb.writeFloat32(this.bb_pos + offset, value); + return true; + } + positiveInfinityDefault() { + const offset = this.bb.__offset(this.bb_pos, 120); + return offset ? this.bb.readFloat32(this.bb_pos + offset) : Infinity; + } + mutate_positive_infinity_default(value) { + const offset = this.bb.__offset(this.bb_pos, 120); + if (offset === 0) { + return false; + } + this.bb.writeFloat32(this.bb_pos + offset, value); + return true; + } + negativeInfDefault() { + const offset = this.bb.__offset(this.bb_pos, 122); + return offset ? this.bb.readFloat32(this.bb_pos + offset) : -Infinity; + } + mutate_negative_inf_default(value) { + const offset = this.bb.__offset(this.bb_pos, 122); + if (offset === 0) { + return false; + } + this.bb.writeFloat32(this.bb_pos + offset, value); + return true; + } + negativeInfinityDefault() { + const offset = this.bb.__offset(this.bb_pos, 124); + return offset ? this.bb.readFloat32(this.bb_pos + offset) : -Infinity; + } + mutate_negative_infinity_default(value) { + const offset = this.bb.__offset(this.bb_pos, 124); + if (offset === 0) { + return false; + } + this.bb.writeFloat32(this.bb_pos + offset, value); + return true; + } + static getFullyQualifiedName() { + return "MyGame_Example_Monster"; + } + static startMonster(builder) { + builder.startObject(61); + } + 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, 0); + } + 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); + } + static addTestf3(builder, testf3) { + builder.addFieldFloat32(27, testf3, 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 addNanDefault(builder, nanDefault) { + builder.addFieldFloat32(54, nanDefault, NaN); + } + static addInfDefault(builder, infDefault) { + builder.addFieldFloat32(55, infDefault, Infinity); + } + static addPositiveInfDefault(builder, positiveInfDefault) { + builder.addFieldFloat32(56, positiveInfDefault, Infinity); + } + static addInfinityDefault(builder, infinityDefault) { + builder.addFieldFloat32(57, infinityDefault, Infinity); + } + static addPositiveInfinityDefault(builder, positiveInfinityDefault) { + builder.addFieldFloat32(58, positiveInfinityDefault, Infinity); + } + static addNegativeInfDefault(builder, negativeInfDefault) { + builder.addFieldFloat32(59, negativeInfDefault, -Infinity); + } + static addNegativeInfinityDefault(builder, negativeInfinityDefault) { + builder.addFieldFloat32(60, negativeInfinityDefault, -Infinity); + } + static endMonster(builder) { + const offset = builder.endObject(); + builder.requiredField(offset, 10); + 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 Monster2.getRootAsMonster(new flatbuffers6.ByteBuffer(buffer)); + } + unpack() { + return new MonsterT2(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(), (() => { + const 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(), (() => { + const temp = unionToAnyUniqueAliases(this.anyUniqueType(), this.anyUnique.bind(this)); + if (temp === null) { + return null; + } + return temp.unpack(); + })(), this.anyAmbiguousType(), (() => { + const 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(), this.nanDefault(), this.infDefault(), this.positiveInfDefault(), this.infinityDefault(), this.positiveInfinityDefault(), this.negativeInfDefault(), this.negativeInfinityDefault()); + } + 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 = (() => { + const 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 = (() => { + const temp = unionToAnyUniqueAliases(this.anyUniqueType(), this.anyUnique.bind(this)); + if (temp === null) { + return null; + } + return temp.unpack(); + })(); + _o.anyAmbiguousType = this.anyAmbiguousType(); + _o.anyAmbiguous = (() => { + const 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(); + _o.nanDefault = this.nanDefault(); + _o.infDefault = this.infDefault(); + _o.positiveInfDefault = this.positiveInfDefault(); + _o.infinityDefault = this.infinityDefault(); + _o.positiveInfinityDefault = this.positiveInfinityDefault(); + _o.negativeInfDefault = this.negativeInfDefault(); + _o.negativeInfinityDefault = this.negativeInfinityDefault(); + } +}; +var MonsterT2 = class { + 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, testf3 = 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"), nanDefault = NaN, infDefault = Infinity, positiveInfDefault = Infinity, infinityDefault = Infinity, positiveInfinityDefault = Infinity, negativeInfDefault = -Infinity, negativeInfinityDefault = -Infinity) { + 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; + this.nanDefault = nanDefault; + this.infDefault = infDefault; + this.positiveInfDefault = positiveInfDefault; + this.infinityDefault = infinityDefault; + this.positiveInfinityDefault = positiveInfinityDefault; + this.negativeInfDefault = negativeInfDefault; + this.negativeInfinityDefault = negativeInfinityDefault; + } + pack(builder) { + const name = this.name !== null ? builder.createString(this.name) : 0; + const inventory = Monster2.createInventoryVector(builder, this.inventory); + const test = builder.createObjectOffset(this.test); + const test4 = builder.createStructOffsetList(this.test4, Monster2.startTest4Vector); + const testarrayofstring = Monster2.createTestarrayofstringVector(builder, builder.createObjectOffsetList(this.testarrayofstring)); + const testarrayoftables = Monster2.createTestarrayoftablesVector(builder, builder.createObjectOffsetList(this.testarrayoftables)); + const enemy = this.enemy !== null ? this.enemy.pack(builder) : 0; + const testnestedflatbuffer = Monster2.createTestnestedflatbufferVector(builder, this.testnestedflatbuffer); + const testempty = this.testempty !== null ? this.testempty.pack(builder) : 0; + const testarrayofbools = Monster2.createTestarrayofboolsVector(builder, this.testarrayofbools); + const testarrayofstring2 = Monster2.createTestarrayofstring2Vector(builder, builder.createObjectOffsetList(this.testarrayofstring2)); + const testarrayofsortedstruct = builder.createStructOffsetList(this.testarrayofsortedstruct, Monster2.startTestarrayofsortedstructVector); + const flex = Monster2.createFlexVector(builder, this.flex); + const test5 = builder.createStructOffsetList(this.test5, Monster2.startTest5Vector); + const vectorOfLongs = Monster2.createVectorOfLongsVector(builder, this.vectorOfLongs); + const vectorOfDoubles = Monster2.createVectorOfDoublesVector(builder, this.vectorOfDoubles); + const parentNamespaceTest = this.parentNamespaceTest !== null ? this.parentNamespaceTest.pack(builder) : 0; + const vectorOfReferrables = Monster2.createVectorOfReferrablesVector(builder, builder.createObjectOffsetList(this.vectorOfReferrables)); + const vectorOfWeakReferences = Monster2.createVectorOfWeakReferencesVector(builder, this.vectorOfWeakReferences); + const vectorOfStrongReferrables = Monster2.createVectorOfStrongReferrablesVector(builder, builder.createObjectOffsetList(this.vectorOfStrongReferrables)); + const vectorOfCoOwningReferences = Monster2.createVectorOfCoOwningReferencesVector(builder, this.vectorOfCoOwningReferences); + const vectorOfNonOwningReferences = Monster2.createVectorOfNonOwningReferencesVector(builder, this.vectorOfNonOwningReferences); + const anyUnique = builder.createObjectOffset(this.anyUnique); + const anyAmbiguous = builder.createObjectOffset(this.anyAmbiguous); + const vectorOfEnums = Monster2.createVectorOfEnumsVector(builder, this.vectorOfEnums); + const testrequirednestedflatbuffer = Monster2.createTestrequirednestedflatbufferVector(builder, this.testrequirednestedflatbuffer); + const scalarKeySortedTables = Monster2.createScalarKeySortedTablesVector(builder, builder.createObjectOffsetList(this.scalarKeySortedTables)); + Monster2.startMonster(builder); + Monster2.addPos(builder, this.pos !== null ? this.pos.pack(builder) : 0); + Monster2.addMana(builder, this.mana); + Monster2.addHp(builder, this.hp); + Monster2.addName(builder, name); + Monster2.addInventory(builder, inventory); + Monster2.addColor(builder, this.color); + Monster2.addTestType(builder, this.testType); + Monster2.addTest(builder, test); + Monster2.addTest4(builder, test4); + Monster2.addTestarrayofstring(builder, testarrayofstring); + Monster2.addTestarrayoftables(builder, testarrayoftables); + Monster2.addEnemy(builder, enemy); + Monster2.addTestnestedflatbuffer(builder, testnestedflatbuffer); + Monster2.addTestempty(builder, testempty); + Monster2.addTestbool(builder, this.testbool); + Monster2.addTesthashs32Fnv1(builder, this.testhashs32Fnv1); + Monster2.addTesthashu32Fnv1(builder, this.testhashu32Fnv1); + Monster2.addTesthashs64Fnv1(builder, this.testhashs64Fnv1); + Monster2.addTesthashu64Fnv1(builder, this.testhashu64Fnv1); + Monster2.addTesthashs32Fnv1a(builder, this.testhashs32Fnv1a); + Monster2.addTesthashu32Fnv1a(builder, this.testhashu32Fnv1a); + Monster2.addTesthashs64Fnv1a(builder, this.testhashs64Fnv1a); + Monster2.addTesthashu64Fnv1a(builder, this.testhashu64Fnv1a); + Monster2.addTestarrayofbools(builder, testarrayofbools); + Monster2.addTestf(builder, this.testf); + Monster2.addTestf2(builder, this.testf2); + Monster2.addTestf3(builder, this.testf3); + Monster2.addTestarrayofstring2(builder, testarrayofstring2); + Monster2.addTestarrayofsortedstruct(builder, testarrayofsortedstruct); + Monster2.addFlex(builder, flex); + Monster2.addTest5(builder, test5); + Monster2.addVectorOfLongs(builder, vectorOfLongs); + Monster2.addVectorOfDoubles(builder, vectorOfDoubles); + Monster2.addParentNamespaceTest(builder, parentNamespaceTest); + Monster2.addVectorOfReferrables(builder, vectorOfReferrables); + Monster2.addSingleWeakReference(builder, this.singleWeakReference); + Monster2.addVectorOfWeakReferences(builder, vectorOfWeakReferences); + Monster2.addVectorOfStrongReferrables(builder, vectorOfStrongReferrables); + Monster2.addCoOwningReference(builder, this.coOwningReference); + Monster2.addVectorOfCoOwningReferences(builder, vectorOfCoOwningReferences); + Monster2.addNonOwningReference(builder, this.nonOwningReference); + Monster2.addVectorOfNonOwningReferences(builder, vectorOfNonOwningReferences); + Monster2.addAnyUniqueType(builder, this.anyUniqueType); + Monster2.addAnyUnique(builder, anyUnique); + Monster2.addAnyAmbiguousType(builder, this.anyAmbiguousType); + Monster2.addAnyAmbiguous(builder, anyAmbiguous); + Monster2.addVectorOfEnums(builder, vectorOfEnums); + Monster2.addSignedEnum(builder, this.signedEnum); + Monster2.addTestrequirednestedflatbuffer(builder, testrequirednestedflatbuffer); + Monster2.addScalarKeySortedTables(builder, scalarKeySortedTables); + Monster2.addNativeInline(builder, this.nativeInline !== null ? this.nativeInline.pack(builder) : 0); + Monster2.addLongEnumNonEnumDefault(builder, this.longEnumNonEnumDefault); + Monster2.addLongEnumNormalDefault(builder, this.longEnumNormalDefault); + Monster2.addNanDefault(builder, this.nanDefault); + Monster2.addInfDefault(builder, this.infDefault); + Monster2.addPositiveInfDefault(builder, this.positiveInfDefault); + Monster2.addInfinityDefault(builder, this.infinityDefault); + Monster2.addPositiveInfinityDefault(builder, this.positiveInfinityDefault); + Monster2.addNegativeInfDefault(builder, this.negativeInfDefault); + Monster2.addNegativeInfinityDefault(builder, this.negativeInfinityDefault); + return Monster2.endMonster(builder); + } +}; + +// my-game/example/any.js +var Any; +(function(Any2) { + Any2[Any2["NONE"] = 0] = "NONE"; + Any2[Any2["Monster"] = 1] = "Monster"; + Any2[Any2["TestSimpleTableWithEnum"] = 2] = "TestSimpleTableWithEnum"; + Any2[Any2["MyGame_Example2_Monster"] = 3] = "MyGame_Example2_Monster"; +})(Any = Any || (Any = {})); +function unionToAny(type, accessor) { + switch (Any[type]) { + case "NONE": + return null; + case "Monster": + return accessor(new Monster2()); + case "TestSimpleTableWithEnum": + return accessor(new TestSimpleTableWithEnum()); + case "MyGame_Example2_Monster": + return accessor(new Monster()); + default: + return null; + } +} + +// my-game/example/long-enum.js +var LongEnum; +(function(LongEnum2) { + LongEnum2["LongOne"] = "2"; + LongEnum2["LongTwo"] = "4"; + LongEnum2["LongBig"] = "1099511627776"; +})(LongEnum = LongEnum || (LongEnum = {})); + +// my-game/example/struct-of-structs.js +var StructOfStructs = class { + 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; + } +}; +var StructOfStructsT = class { + constructor(a = null, b = null, c = null) { + this.a = a; + this.b = b; + this.c = c; + } + pack(builder) { + 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); + } +}; + +// my-game/example/struct-of-structs-of-structs.js +var StructOfStructsOfStructs = class { + 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; + } +}; +var StructOfStructsOfStructsT = class { + constructor(a = null) { + this.a = a; + } + pack(builder) { + 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); + } +}; + +// my-game/example/type-aliases.js +var flatbuffers7 = __toESM(require("flatbuffers"), 1); +var TypeAliases = class { + 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() + flatbuffers7.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; + } + 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; + } + 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); + } + static addF64(builder, f64) { + builder.addFieldFloat64(9, f64, 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 flatbuffers7.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()); + } +}; +var TypeAliasesT = class { + constructor(i8 = 0, u8 = 0, i16 = 0, u16 = 0, i32 = 0, u32 = 0, i64 = BigInt("0"), u64 = BigInt("0"), f32 = 0, f64 = 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/monster_test_generated.ts b/tests/ts/monster_test_generated.ts deleted file mode 100644 index 18aec071fbb..00000000000 --- a/tests/ts/monster_test_generated.ts +++ /dev/null @@ -1,19 +0,0 @@ -// 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/ts/monster_test_grpc.d.ts b/tests/ts/monster_test_grpc.d.ts deleted file mode 100644 index e7a71d1a9d2..00000000000 --- a/tests/ts/monster_test_grpc.d.ts +++ /dev/null @@ -1,94 +0,0 @@ -// Generated GRPC code for FlatBuffers TS *** DO NOT EDIT *** -import * as flatbuffers from 'flatbuffers'; -import { Stat as MyGame_Example_Stat } from './my-game/example/stat'; -import { Monster as MyGame_Example_Monster } from './my-game/example/monster'; - -import * as grpc from '@grpc/grpc-js'; - -interface IMonsterStorageService extends grpc.ServiceDefinition { - Store: IMonsterStorageService_IStore; - Retrieve: IMonsterStorageService_IRetrieve; - GetMaxHitPoint: IMonsterStorageService_IGetMaxHitPoint; - GetMinMaxHitPoints: IMonsterStorageService_IGetMinMaxHitPoints; -} -interface IMonsterStorageService_IStore extends grpc.MethodDefinition { - path: string; // /MyGame.Example.MonsterStorage/Store - requestStream: boolean; // false - responseStream: boolean; // false - requestSerialize: grpc.serialize; - requestDeserialize: grpc.deserialize; - responseSerialize: grpc.serialize; - responseDeserialize: grpc.deserialize; -} - -interface IMonsterStorageService_IRetrieve extends grpc.MethodDefinition { - path: string; // /MyGame.Example.MonsterStorage/Retrieve - requestStream: boolean; // false - responseStream: boolean; // true - requestSerialize: grpc.serialize; - requestDeserialize: grpc.deserialize; - responseSerialize: grpc.serialize; - responseDeserialize: grpc.deserialize; -} - -interface IMonsterStorageService_IGetMaxHitPoint extends grpc.MethodDefinition { - path: string; // /MyGame.Example.MonsterStorage/GetMaxHitPoint - requestStream: boolean; // true - responseStream: boolean; // false - requestSerialize: grpc.serialize; - requestDeserialize: grpc.deserialize; - responseSerialize: grpc.serialize; - responseDeserialize: grpc.deserialize; -} - -interface IMonsterStorageService_IGetMinMaxHitPoints extends grpc.MethodDefinition { - path: string; // /MyGame.Example.MonsterStorage/GetMinMaxHitPoints - requestStream: boolean; // true - responseStream: boolean; // true - requestSerialize: grpc.serialize; - requestDeserialize: grpc.deserialize; - responseSerialize: grpc.serialize; - responseDeserialize: grpc.deserialize; -} - - -export const MonsterStorageService: IMonsterStorageService; - -export interface IMonsterStorageServer extends grpc.UntypedServiceImplementation { - Store: grpc.handleUnaryCall; - Retrieve: grpc.handleServerStreamingCall; - GetMaxHitPoint: grpc.handleClientStreamingCall; - GetMinMaxHitPoints: grpc.handleBidiStreamingCall; -} - -export interface IMonsterStorageClient { - Store(request: MyGame_Example_Monster, callback: (error: grpc.ServiceError | null, response: MyGame_Example_Stat) => void): grpc.ClientUnaryCall; - Store(request: MyGame_Example_Monster, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: MyGame_Example_Stat) => void): grpc.ClientUnaryCall; - Store(request: MyGame_Example_Monster, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: MyGame_Example_Stat) => void): grpc.ClientUnaryCall; - Retrieve(request: MyGame_Example_Stat, metadata: grpc.Metadata): grpc.ClientReadableStream; - Retrieve(request: MyGame_Example_Stat, options: Partial): grpc.ClientReadableStream; - GetMaxHitPoint(callback: (error: grpc.ServiceError | null, response: MyGame_Example_Monster) => void): grpc.ClientWritableStream; - GetMaxHitPoint(metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: MyGame_Example_Monster) => void): grpc.ClientWritableStream; - GetMaxHitPoint(options: Partial, callback: (error: grpc.ServiceError | null, response: MyGame_Example_Monster) => void): grpc.ClientWritableStream; - GetMaxHitPoint(metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: MyGame_Example_Monster) => void): grpc.ClientWritableStream; - GetMinMaxHitPoints(): grpc.ClientDuplexStream; - GetMinMaxHitPoints(options: Partial): grpc.ClientDuplexStream; - GetMinMaxHitPoints(metadata: grpc.Metadata, options?: Partial): grpc.ClientDuplexStream; -} - -export class MonsterStorageClient extends grpc.Client implements IMonsterStorageClient { - constructor(address: string, credentials: grpc.ChannelCredentials, options?: object); - public Store(request: MyGame_Example_Monster, callback: (error: grpc.ServiceError | null, response: MyGame_Example_Stat) => void): grpc.ClientUnaryCall; - public Store(request: MyGame_Example_Monster, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: MyGame_Example_Stat) => void): grpc.ClientUnaryCall; - public Store(request: MyGame_Example_Monster, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: MyGame_Example_Stat) => void): grpc.ClientUnaryCall; - public Retrieve(request: MyGame_Example_Stat, metadata: grpc.Metadata): grpc.ClientReadableStream; - public Retrieve(request: MyGame_Example_Stat, options: Partial): grpc.ClientReadableStream; - public GetMaxHitPoint(callback: (error: grpc.ServiceError | null, response: MyGame_Example_Monster) => void): grpc.ClientWritableStream; - public GetMaxHitPoint(metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: MyGame_Example_Monster) => void): grpc.ClientWritableStream; - public GetMaxHitPoint(options: Partial, callback: (error: grpc.ServiceError | null, response: MyGame_Example_Monster) => void): grpc.ClientWritableStream; - public GetMaxHitPoint(metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: MyGame_Example_Monster) => void): grpc.ClientWritableStream; - public GetMinMaxHitPoints(): grpc.ClientDuplexStream; - public GetMinMaxHitPoints(options: Partial): grpc.ClientDuplexStream; - public GetMinMaxHitPoints(metadata: grpc.Metadata, options?: Partial): grpc.ClientDuplexStream; -} - diff --git a/tests/ts/monster_test_grpc.js b/tests/ts/monster_test_grpc.js deleted file mode 100644 index 34f8cb22ea5..00000000000 --- a/tests/ts/monster_test_grpc.js +++ /dev/null @@ -1,80 +0,0 @@ -// Generated GRPC code for FlatBuffers TS *** DO NOT EDIT *** -import * as flatbuffers from 'flatbuffers'; -import { Stat as MyGame_Example_Stat } from './my-game/example/stat'; -import { Monster as MyGame_Example_Monster } from './my-game/example/monster'; - -var grpc = require('@grpc/grpc-js'); - -function serialize_MyGame_Example_Stat(buffer_args) { - if (!(buffer_args instanceof MyGame_Example_Stat)) { - throw new Error('Expected argument of type Stat'); - } - return Buffer.from(buffer_args.serialize()); -} - -function deserialize_MyGame_Example_Stat(buffer) { - return MyGame_Example_Stat.getRootAsStat(new flatbuffers.ByteBuffer(buffer)) -} - - -function serialize_MyGame_Example_Monster(buffer_args) { - if (!(buffer_args instanceof MyGame_Example_Monster)) { - throw new Error('Expected argument of type Monster'); - } - return Buffer.from(buffer_args.serialize()); -} - -function deserialize_MyGame_Example_Monster(buffer) { - return MyGame_Example_Monster.getRootAsMonster(new flatbuffers.ByteBuffer(buffer)) -} - - - - -var MonsterStorageService = exports.MonsterStorageService = { - Store: { - path: '/MyGame.Example.MonsterStorage/Store', - requestStream: false, - responseStream: false, - requestType: flatbuffers.ByteBuffer, - responseType: MyGame_Example_Stat, - requestSerialize: serialize_MyGame_Example_Monster, - requestDeserialize: deserialize_MyGame_Example_Monster, - responseSerialize: serialize_MyGame_Example_Stat, - responseDeserialize: deserialize_MyGame_Example_Stat, - }, - Retrieve: { - path: '/MyGame.Example.MonsterStorage/Retrieve', - requestStream: false, - responseStream: true, - requestType: flatbuffers.ByteBuffer, - responseType: MyGame_Example_Monster, - requestSerialize: serialize_MyGame_Example_Stat, - requestDeserialize: deserialize_MyGame_Example_Stat, - responseSerialize: serialize_MyGame_Example_Monster, - responseDeserialize: deserialize_MyGame_Example_Monster, - }, - GetMaxHitPoint: { - path: '/MyGame.Example.MonsterStorage/GetMaxHitPoint', - requestStream: true, - responseStream: false, - requestType: flatbuffers.ByteBuffer, - responseType: MyGame_Example_Stat, - requestSerialize: serialize_MyGame_Example_Monster, - requestDeserialize: deserialize_MyGame_Example_Monster, - responseSerialize: serialize_MyGame_Example_Stat, - responseDeserialize: deserialize_MyGame_Example_Stat, - }, - GetMinMaxHitPoints: { - path: '/MyGame.Example.MonsterStorage/GetMinMaxHitPoints', - requestStream: true, - responseStream: true, - requestType: flatbuffers.ByteBuffer, - responseType: MyGame_Example_Stat, - requestSerialize: serialize_MyGame_Example_Monster, - requestDeserialize: deserialize_MyGame_Example_Monster, - responseSerialize: serialize_MyGame_Example_Stat, - responseDeserialize: deserialize_MyGame_Example_Stat, - }, -}; -exports.MonsterStorageClient = grpc.makeGenericClientConstructor(MonsterStorageService); diff --git a/tests/ts/my-game.js b/tests/ts/my-game.js new file mode 100644 index 00000000000..9db431c1604 --- /dev/null +++ b/tests/ts/my-game.js @@ -0,0 +1,5 @@ +// automatically generated by the FlatBuffers compiler, do not modify +export { InParentNamespace } from './my-game/in-parent-namespace.js'; +export * as Example from './my-game/example.js'; +export * as Example2 from './my-game/example2.js'; +export * as OtherNameSpace from './my-game/other-name-space.js'; diff --git a/tests/ts/my-game.ts b/tests/ts/my-game.ts new file mode 100644 index 00000000000..017791646a5 --- /dev/null +++ b/tests/ts/my-game.ts @@ -0,0 +1,6 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +export { InParentNamespace } from './my-game/in-parent-namespace.js'; +export * as Example from './my-game/example.js'; +export * as Example2 from './my-game/example2.js'; +export * as OtherNameSpace from './my-game/other-name-space.js'; diff --git a/tests/ts/my-game/example.js b/tests/ts/my-game/example.js new file mode 100644 index 00000000000..e0236541d0c --- /dev/null +++ b/tests/ts/my-game/example.js @@ -0,0 +1,17 @@ +// automatically generated by the FlatBuffers compiler, do not modify +export { Ability } from './example/ability.js'; +export { Any } from './example/any.js'; +export { AnyAmbiguousAliases } from './example/any-ambiguous-aliases.js'; +export { AnyUniqueAliases } from './example/any-unique-aliases.js'; +export { Color } from './example/color.js'; +export { LongEnum } from './example/long-enum.js'; +export { Monster } from './example/monster.js'; +export { Race } from './example/race.js'; +export { Referrable } from './example/referrable.js'; +export { Stat } from './example/stat.js'; +export { StructOfStructs } from './example/struct-of-structs.js'; +export { StructOfStructsOfStructs } from './example/struct-of-structs-of-structs.js'; +export { Test } from './example/test.js'; +export { TestSimpleTableWithEnum } from './example/test-simple-table-with-enum.js'; +export { TypeAliases } from './example/type-aliases.js'; +export { Vec3 } from './example/vec3.js'; diff --git a/tests/ts/my-game/example.ts b/tests/ts/my-game/example.ts new file mode 100644 index 00000000000..62ac2782e6e --- /dev/null +++ b/tests/ts/my-game/example.ts @@ -0,0 +1,8 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +export { ArrayStruct } from './arrays_test_complex/example/array-struct.js'; +export { ArrayTable } from './arrays_test_complex/example/array-table.js'; +export { InnerStruct } from './arrays_test_complex/example/inner-struct.js'; +export { NestedStruct } from './arrays_test_complex/example/nested-struct.js'; +export { OuterStruct } from './arrays_test_complex/example/outer-struct.js'; +export { TestEnum } from './arrays_test_complex/example/test-enum.js'; diff --git a/tests/ts/my-game/example/any-ambiguous-aliases.js b/tests/ts/my-game/example/any-ambiguous-aliases.js index ca8190848af..7d379dc7640 100644 --- a/tests/ts/my-game/example/any-ambiguous-aliases.js +++ b/tests/ts/my-game/example/any-ambiguous-aliases.js @@ -6,7 +6,7 @@ export var AnyAmbiguousAliases; AnyAmbiguousAliases[AnyAmbiguousAliases["M1"] = 1] = "M1"; AnyAmbiguousAliases[AnyAmbiguousAliases["M2"] = 2] = "M2"; AnyAmbiguousAliases[AnyAmbiguousAliases["M3"] = 3] = "M3"; -})(AnyAmbiguousAliases || (AnyAmbiguousAliases = {})); +})(AnyAmbiguousAliases = AnyAmbiguousAliases || (AnyAmbiguousAliases = {})); export function unionToAnyAmbiguousAliases(type, accessor) { switch (AnyAmbiguousAliases[type]) { case 'NONE': return null; diff --git a/tests/ts/my-game/example/any-unique-aliases.js b/tests/ts/my-game/example/any-unique-aliases.js index d1ac6bff1ab..a7fa2c02c23 100644 --- a/tests/ts/my-game/example/any-unique-aliases.js +++ b/tests/ts/my-game/example/any-unique-aliases.js @@ -8,7 +8,7 @@ export var AnyUniqueAliases; AnyUniqueAliases[AnyUniqueAliases["M"] = 1] = "M"; AnyUniqueAliases[AnyUniqueAliases["TS"] = 2] = "TS"; AnyUniqueAliases[AnyUniqueAliases["M2"] = 3] = "M2"; -})(AnyUniqueAliases || (AnyUniqueAliases = {})); +})(AnyUniqueAliases = AnyUniqueAliases || (AnyUniqueAliases = {})); export function unionToAnyUniqueAliases(type, accessor) { switch (AnyUniqueAliases[type]) { case 'NONE': return null; diff --git a/tests/ts/my-game/example/any.js b/tests/ts/my-game/example/any.js index 27be8f40809..2b1c0184d27 100644 --- a/tests/ts/my-game/example/any.js +++ b/tests/ts/my-game/example/any.js @@ -8,7 +8,7 @@ export var Any; Any[Any["Monster"] = 1] = "Monster"; Any[Any["TestSimpleTableWithEnum"] = 2] = "TestSimpleTableWithEnum"; Any[Any["MyGame_Example2_Monster"] = 3] = "MyGame_Example2_Monster"; -})(Any || (Any = {})); +})(Any = Any || (Any = {})); export function unionToAny(type, accessor) { switch (Any[type]) { case 'NONE': return null; diff --git a/tests/ts/my-game/example/color.js b/tests/ts/my-game/example/color.js index f95f75e9677..0a057ccf64a 100644 --- a/tests/ts/my-game/example/color.js +++ b/tests/ts/my-game/example/color.js @@ -14,4 +14,4 @@ export var Color; * \brief color Blue (1u << 3) */ Color[Color["Blue"] = 8] = "Blue"; -})(Color || (Color = {})); +})(Color = Color || (Color = {})); diff --git a/tests/ts/my-game/example/long-enum.js b/tests/ts/my-game/example/long-enum.js index 040d8a672f9..0180c2bdf96 100644 --- a/tests/ts/my-game/example/long-enum.js +++ b/tests/ts/my-game/example/long-enum.js @@ -4,4 +4,4 @@ export var LongEnum; LongEnum["LongOne"] = "2"; LongEnum["LongTwo"] = "4"; LongEnum["LongBig"] = "1099511627776"; -})(LongEnum || (LongEnum = {})); +})(LongEnum = LongEnum || (LongEnum = {})); diff --git a/tests/ts/my-game/example/race.js b/tests/ts/my-game/example/race.js index 74f51057abc..11c7a41ecf4 100644 --- a/tests/ts/my-game/example/race.js +++ b/tests/ts/my-game/example/race.js @@ -5,4 +5,4 @@ export var Race; Race[Race["Human"] = 0] = "Human"; Race[Race["Dwarf"] = 1] = "Dwarf"; Race[Race["Elf"] = 2] = "Elf"; -})(Race || (Race = {})); +})(Race = Race || (Race = {})); 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 index a5fbc66dce6..151be475130 100644 --- a/tests/ts/my-game/example/struct-of-structs-of-structs.js +++ b/tests/ts/my-game/example/struct-of-structs-of-structs.js @@ -46,7 +46,6 @@ export class StructOfStructsOfStructsT { 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)); + 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 index 66aadc8e543..f494c0f3c5d 100644 --- a/tests/ts/my-game/example/struct-of-structs.js +++ b/tests/ts/my-game/example/struct-of-structs.js @@ -56,7 +56,6 @@ export class StructOfStructsT { 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)); + 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/vec3.js b/tests/ts/my-game/example/vec3.js index cae64eb5557..edf93f1abff 100644 --- a/tests/ts/my-game/example/vec3.js +++ b/tests/ts/my-game/example/vec3.js @@ -92,7 +92,6 @@ export class Vec3T { 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)); + 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/optional-scalars/optional-byte.ts b/tests/ts/my-game/example2.js similarity index 52% rename from tests/optional-scalars/optional-byte.ts rename to tests/ts/my-game/example2.js index f4db265e2ba..edab044cadd 100644 --- a/tests/optional-scalars/optional-byte.ts +++ b/tests/ts/my-game/example2.js @@ -1,7 +1,2 @@ // automatically generated by the FlatBuffers compiler, do not modify - -export enum OptionalByte { - None = 0, - One = 1, - Two = 2 -} +export { Monster } from './example2/monster.js'; diff --git a/tests/namespace_test/namespace-a/namespace-b/enum-in-nested-n-s.ts b/tests/ts/my-game/example2.ts similarity index 55% rename from tests/namespace_test/namespace-a/namespace-b/enum-in-nested-n-s.ts rename to tests/ts/my-game/example2.ts index 676b7e43ddc..faf5b6381fb 100644 --- a/tests/namespace_test/namespace-a/namespace-b/enum-in-nested-n-s.ts +++ b/tests/ts/my-game/example2.ts @@ -1,8 +1,3 @@ // automatically generated by the FlatBuffers compiler, do not modify -export enum EnumInNestedNS{ - A = 0, - B = 1, - C = 2 -} - +export { Monster } from './example2/monster.js'; diff --git a/tests/ts/my-game/other-name-space.js b/tests/ts/my-game/other-name-space.js new file mode 100644 index 00000000000..12e8e5a6a22 --- /dev/null +++ b/tests/ts/my-game/other-name-space.js @@ -0,0 +1,4 @@ +// automatically generated by the FlatBuffers compiler, do not modify +export { FromInclude } from './other-name-space/from-include.js'; +export { TableB } from './other-name-space/table-b.js'; +export { Unused } from './other-name-space/unused.js'; diff --git a/tests/ts/my-game/other-name-space.ts b/tests/ts/my-game/other-name-space.ts new file mode 100644 index 00000000000..ea4a261ff05 --- /dev/null +++ b/tests/ts/my-game/other-name-space.ts @@ -0,0 +1,5 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +export { FromInclude } from './other-name-space/from-include.js'; +export { TableB } from './other-name-space/table-b.js'; +export { Unused } from './other-name-space/unused.js'; diff --git a/tests/ts/my-game/other-name-space/from-include.js b/tests/ts/my-game/other-name-space/from-include.js new file mode 100644 index 00000000000..c6e6d08339a --- /dev/null +++ b/tests/ts/my-game/other-name-space/from-include.js @@ -0,0 +1,5 @@ +// automatically generated by the FlatBuffers compiler, do not modify +export var FromInclude; +(function (FromInclude) { + FromInclude["IncludeVal"] = "0"; +})(FromInclude = FromInclude || (FromInclude = {})); diff --git a/tests/ts/typescript_include_generated.ts b/tests/ts/my-game/other-name-space/from-include.ts similarity index 61% rename from tests/ts/typescript_include_generated.ts rename to tests/ts/my-game/other-name-space/from-include.ts index d419431cfdf..bdc066d5fe9 100644 --- a/tests/ts/typescript_include_generated.ts +++ b/tests/ts/my-game/other-name-space/from-include.ts @@ -1,7 +1,5 @@ // automatically generated by the FlatBuffers compiler, do not modify - -export enum class_ { - arguments_ = 0 +export enum FromInclude { + IncludeVal = '0' } - diff --git a/tests/ts/my-game/other-name-space/table-b.js b/tests/ts/my-game/other-name-space/table-b.js new file mode 100644 index 00000000000..464ab3e24a4 --- /dev/null +++ b/tests/ts/my-game/other-name-space/table-b.js @@ -0,0 +1,64 @@ +// automatically generated by the FlatBuffers compiler, do not modify +import * as flatbuffers from 'flatbuffers'; +import { TableA } from '../../table-a.js'; +export class TableB { + constructor() { + this.bb = null; + this.bb_pos = 0; + } + __init(i, bb) { + this.bb_pos = i; + this.bb = bb; + return this; + } + static getRootAsTableB(bb, obj) { + return (obj || new TableB()).__init(bb.readInt32(bb.position()) + bb.position(), bb); + } + static getSizePrefixedRootAsTableB(bb, obj) { + bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); + return (obj || new TableB()).__init(bb.readInt32(bb.position()) + bb.position(), bb); + } + a(obj) { + const offset = this.bb.__offset(this.bb_pos, 4); + return offset ? (obj || new TableA()).__init(this.bb.__indirect(this.bb_pos + offset), this.bb) : null; + } + static getFullyQualifiedName() { + return 'MyGame_OtherNameSpace_TableB'; + } + static startTableB(builder) { + builder.startObject(1); + } + static addA(builder, aOffset) { + builder.addFieldOffset(0, aOffset, 0); + } + static endTableB(builder) { + const offset = builder.endObject(); + return offset; + } + static createTableB(builder, aOffset) { + TableB.startTableB(builder); + TableB.addA(builder, aOffset); + return TableB.endTableB(builder); + } + serialize() { + return this.bb.bytes(); + } + static deserialize(buffer) { + return TableB.getRootAsTableB(new flatbuffers.ByteBuffer(buffer)); + } + unpack() { + return new TableBT((this.a() !== null ? this.a().unpack() : null)); + } + unpackTo(_o) { + _o.a = (this.a() !== null ? this.a().unpack() : null); + } +} +export class TableBT { + constructor(a = null) { + this.a = a; + } + pack(builder) { + const a = (this.a !== null ? this.a.pack(builder) : 0); + return TableB.createTableB(builder, a); + } +} diff --git a/tests/ts/my-game/other-name-space/table-b.ts b/tests/ts/my-game/other-name-space/table-b.ts new file mode 100644 index 00000000000..af01cd25910 --- /dev/null +++ b/tests/ts/my-game/other-name-space/table-b.ts @@ -0,0 +1,87 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +import * as flatbuffers from 'flatbuffers'; + +import { TableA, TableAT } from '../../table-a.js'; + + +export class TableB implements flatbuffers.IUnpackableObject { + bb: flatbuffers.ByteBuffer|null = null; + bb_pos = 0; + __init(i:number, bb:flatbuffers.ByteBuffer):TableB { + this.bb_pos = i; + this.bb = bb; + return this; +} + +static getRootAsTableB(bb:flatbuffers.ByteBuffer, obj?:TableB):TableB { + return (obj || new TableB()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +static getSizePrefixedRootAsTableB(bb:flatbuffers.ByteBuffer, obj?:TableB):TableB { + bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); + return (obj || new TableB()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +a(obj?:TableA):TableA|null { + const offset = this.bb!.__offset(this.bb_pos, 4); + return offset ? (obj || new TableA()).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null; +} + +static getFullyQualifiedName():string { + return 'MyGame_OtherNameSpace_TableB'; +} + +static startTableB(builder:flatbuffers.Builder) { + builder.startObject(1); +} + +static addA(builder:flatbuffers.Builder, aOffset:flatbuffers.Offset) { + builder.addFieldOffset(0, aOffset, 0); +} + +static endTableB(builder:flatbuffers.Builder):flatbuffers.Offset { + const offset = builder.endObject(); + return offset; +} + +static createTableB(builder:flatbuffers.Builder, aOffset:flatbuffers.Offset):flatbuffers.Offset { + TableB.startTableB(builder); + TableB.addA(builder, aOffset); + return TableB.endTableB(builder); +} + +serialize():Uint8Array { + return this.bb!.bytes(); +} + +static deserialize(buffer: Uint8Array):TableB { + return TableB.getRootAsTableB(new flatbuffers.ByteBuffer(buffer)) +} + +unpack(): TableBT { + return new TableBT( + (this.a() !== null ? this.a()!.unpack() : null) + ); +} + + +unpackTo(_o: TableBT): void { + _o.a = (this.a() !== null ? this.a()!.unpack() : null); +} +} + +export class TableBT implements flatbuffers.IGeneratedObject { +constructor( + public a: TableAT|null = null +){} + + +pack(builder:flatbuffers.Builder): flatbuffers.Offset { + const a = (this.a !== null ? this.a!.pack(builder) : 0); + + return TableB.createTableB(builder, + a + ); +} +} diff --git a/tests/union_vector/rapunzel.js b/tests/ts/my-game/other-name-space/unused.js similarity index 57% rename from tests/union_vector/rapunzel.js rename to tests/ts/my-game/other-name-space/unused.js index 67a5e4453b3..829454dbef4 100644 --- a/tests/union_vector/rapunzel.js +++ b/tests/ts/my-game/other-name-space/unused.js @@ -1,5 +1,5 @@ // automatically generated by the FlatBuffers compiler, do not modify -export class Rapunzel { +export class Unused { constructor() { this.bb = null; this.bb_pos = 0; @@ -9,36 +9,36 @@ export class Rapunzel { this.bb = bb; return this; } - hairLength() { + a() { return this.bb.readInt32(this.bb_pos); } - mutate_hair_length(value) { + mutate_a(value) { this.bb.writeInt32(this.bb_pos + 0, value); return true; } static getFullyQualifiedName() { - return 'Rapunzel'; + return 'MyGame_OtherNameSpace_Unused'; } static sizeOf() { return 4; } - static createRapunzel(builder, hair_length) { + static createUnused(builder, a) { builder.prep(4, 4); - builder.writeInt32(hair_length); + builder.writeInt32(a); return builder.offset(); } unpack() { - return new RapunzelT(this.hairLength()); + return new UnusedT(this.a()); } unpackTo(_o) { - _o.hairLength = this.hairLength(); + _o.a = this.a(); } } -export class RapunzelT { - constructor(hairLength = 0) { - this.hairLength = hairLength; +export class UnusedT { + constructor(a = 0) { + this.a = a; } pack(builder) { - return Rapunzel.createRapunzel(builder, this.hairLength); + return Unused.createUnused(builder, this.a); } } diff --git a/tests/union_vector/rapunzel.ts b/tests/ts/my-game/other-name-space/unused.ts similarity index 50% rename from tests/union_vector/rapunzel.ts rename to tests/ts/my-game/other-name-space/unused.ts index e1dc63ddf54..20802df7ee9 100644 --- a/tests/union_vector/rapunzel.ts +++ b/tests/ts/my-game/other-name-space/unused.ts @@ -4,60 +4,60 @@ import * as flatbuffers from 'flatbuffers'; -export class Rapunzel { +export class Unused implements flatbuffers.IUnpackableObject { bb: flatbuffers.ByteBuffer|null = null; bb_pos = 0; - __init(i:number, bb:flatbuffers.ByteBuffer):Rapunzel { + __init(i:number, bb:flatbuffers.ByteBuffer):Unused { this.bb_pos = i; this.bb = bb; return this; } -hairLength():number { +a():number { return this.bb!.readInt32(this.bb_pos); } -mutate_hair_length(value:number):boolean { +mutate_a(value:number):boolean { this.bb!.writeInt32(this.bb_pos + 0, value); return true; } static getFullyQualifiedName():string { - return 'Rapunzel'; + return 'MyGame_OtherNameSpace_Unused'; } static sizeOf():number { return 4; } -static createRapunzel(builder:flatbuffers.Builder, hair_length: number):flatbuffers.Offset { +static createUnused(builder:flatbuffers.Builder, a: number):flatbuffers.Offset { builder.prep(4, 4); - builder.writeInt32(hair_length); + builder.writeInt32(a); return builder.offset(); } -unpack(): RapunzelT { - return new RapunzelT( - this.hairLength() +unpack(): UnusedT { + return new UnusedT( + this.a() ); } -unpackTo(_o: RapunzelT): void { - _o.hairLength = this.hairLength(); +unpackTo(_o: UnusedT): void { + _o.a = this.a(); } } -export class RapunzelT { +export class UnusedT implements flatbuffers.IGeneratedObject { constructor( - public hairLength: number = 0 + public a: number = 0 ){} pack(builder:flatbuffers.Builder): flatbuffers.Offset { - return Rapunzel.createRapunzel(builder, - this.hairLength + return Unused.createUnused(builder, + this.a ); } } diff --git a/tests/ts/optional_scalars_generated.ts b/tests/ts/optional-scalars.ts similarity index 100% rename from tests/ts/optional_scalars_generated.ts rename to tests/ts/optional-scalars.ts diff --git a/tests/ts/optional_scalars.ts b/tests/ts/optional_scalars.ts deleted file mode 100644 index 6d9830c022b..00000000000 --- a/tests/ts/optional_scalars.ts +++ /dev/null @@ -1 +0,0 @@ -export { OptionalByte } from './optional-scalars/optional-byte'; diff --git a/tests/ts/reflection.ts b/tests/ts/reflection.ts new file mode 100644 index 00000000000..8440332d161 --- /dev/null +++ b/tests/ts/reflection.ts @@ -0,0 +1,14 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +export { AdvancedFeatures } from './reflection/advanced-features.js'; +export { BaseType } from './reflection/base-type.js'; +export { Enum } from './reflection/enum.js'; +export { EnumVal } from './reflection/enum-val.js'; +export { Field } from './reflection/field.js'; +export { KeyValue } from './reflection/key-value.js'; +export { Object_ } from './reflection/object.js'; +export { RPCCall } from './reflection/rpccall.js'; +export { Schema } from './reflection/schema.js'; +export { SchemaFile } from './reflection/schema-file.js'; +export { Service } from './reflection/service.js'; +export { Type } from './reflection/type.js'; diff --git a/tests/ts/reflection/base-type.js b/tests/ts/reflection/base-type.js index dccd0ac9e57..b49e64b3bed 100644 --- a/tests/ts/reflection/base-type.js +++ b/tests/ts/reflection/base-type.js @@ -20,4 +20,4 @@ export var BaseType; BaseType[BaseType["Union"] = 16] = "Union"; BaseType[BaseType["Array"] = 17] = "Array"; BaseType[BaseType["MaxBaseType"] = 18] = "MaxBaseType"; -})(BaseType || (BaseType = {})); +})(BaseType = BaseType || (BaseType = {})); diff --git a/tests/ts/table-a.js b/tests/ts/table-a.js new file mode 100644 index 00000000000..f0ade0dd6f0 --- /dev/null +++ b/tests/ts/table-a.js @@ -0,0 +1,64 @@ +// automatically generated by the FlatBuffers compiler, do not modify +import * as flatbuffers from 'flatbuffers'; +import { TableB } from './my-game/other-name-space/table-b.js'; +export class TableA { + constructor() { + this.bb = null; + this.bb_pos = 0; + } + __init(i, bb) { + this.bb_pos = i; + this.bb = bb; + return this; + } + static getRootAsTableA(bb, obj) { + return (obj || new TableA()).__init(bb.readInt32(bb.position()) + bb.position(), bb); + } + static getSizePrefixedRootAsTableA(bb, obj) { + bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); + return (obj || new TableA()).__init(bb.readInt32(bb.position()) + bb.position(), bb); + } + b(obj) { + const offset = this.bb.__offset(this.bb_pos, 4); + return offset ? (obj || new TableB()).__init(this.bb.__indirect(this.bb_pos + offset), this.bb) : null; + } + static getFullyQualifiedName() { + return 'TableA'; + } + static startTableA(builder) { + builder.startObject(1); + } + static addB(builder, bOffset) { + builder.addFieldOffset(0, bOffset, 0); + } + static endTableA(builder) { + const offset = builder.endObject(); + return offset; + } + static createTableA(builder, bOffset) { + TableA.startTableA(builder); + TableA.addB(builder, bOffset); + return TableA.endTableA(builder); + } + serialize() { + return this.bb.bytes(); + } + static deserialize(buffer) { + return TableA.getRootAsTableA(new flatbuffers.ByteBuffer(buffer)); + } + unpack() { + return new TableAT((this.b() !== null ? this.b().unpack() : null)); + } + unpackTo(_o) { + _o.b = (this.b() !== null ? this.b().unpack() : null); + } +} +export class TableAT { + constructor(b = null) { + this.b = b; + } + pack(builder) { + const b = (this.b !== null ? this.b.pack(builder) : 0); + return TableA.createTableA(builder, b); + } +} diff --git a/tests/ts/table-a.ts b/tests/ts/table-a.ts new file mode 100644 index 00000000000..5ed4b315c45 --- /dev/null +++ b/tests/ts/table-a.ts @@ -0,0 +1,87 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +import * as flatbuffers from 'flatbuffers'; + +import { TableB, TableBT } from './my-game/other-name-space/table-b.js'; + + +export class TableA implements flatbuffers.IUnpackableObject { + bb: flatbuffers.ByteBuffer|null = null; + bb_pos = 0; + __init(i:number, bb:flatbuffers.ByteBuffer):TableA { + this.bb_pos = i; + this.bb = bb; + return this; +} + +static getRootAsTableA(bb:flatbuffers.ByteBuffer, obj?:TableA):TableA { + return (obj || new TableA()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +static getSizePrefixedRootAsTableA(bb:flatbuffers.ByteBuffer, obj?:TableA):TableA { + bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); + return (obj || new TableA()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +b(obj?:TableB):TableB|null { + const offset = this.bb!.__offset(this.bb_pos, 4); + return offset ? (obj || new TableB()).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null; +} + +static getFullyQualifiedName():string { + return 'TableA'; +} + +static startTableA(builder:flatbuffers.Builder) { + builder.startObject(1); +} + +static addB(builder:flatbuffers.Builder, bOffset:flatbuffers.Offset) { + builder.addFieldOffset(0, bOffset, 0); +} + +static endTableA(builder:flatbuffers.Builder):flatbuffers.Offset { + const offset = builder.endObject(); + return offset; +} + +static createTableA(builder:flatbuffers.Builder, bOffset:flatbuffers.Offset):flatbuffers.Offset { + TableA.startTableA(builder); + TableA.addB(builder, bOffset); + return TableA.endTableA(builder); +} + +serialize():Uint8Array { + return this.bb!.bytes(); +} + +static deserialize(buffer: Uint8Array):TableA { + return TableA.getRootAsTableA(new flatbuffers.ByteBuffer(buffer)) +} + +unpack(): TableAT { + return new TableAT( + (this.b() !== null ? this.b()!.unpack() : null) + ); +} + + +unpackTo(_o: TableAT): void { + _o.b = (this.b() !== null ? this.b()!.unpack() : null); +} +} + +export class TableAT implements flatbuffers.IGeneratedObject { +constructor( + public b: TableBT|null = null +){} + + +pack(builder:flatbuffers.Builder): flatbuffers.Offset { + const b = (this.b !== null ? this.b!.pack(builder) : 0); + + return TableA.createTableA(builder, + b + ); +} +} diff --git a/tests/ts/tsconfig.json b/tests/ts/tsconfig.json index 4678c63e6cd..99c043cbf94 100644 --- a/tests/ts/tsconfig.json +++ b/tests/ts/tsconfig.json @@ -1,16 +1,9 @@ { "compilerOptions": { - "target": "ES6", - "lib": ["ES2015", "ES2020.BigInt", "DOM"], - "moduleResolution": "Node", - "noImplicitAny": true, - "strict": true, - "noUnusedParameters": false, - "noUnusedLocals": false, - "noImplicitReturns": true, - "strictNullChecks": true, - "baseUrl": ".", - "noEmit": false + "target": "ES2020", + "lib": ["ES2020", "DOM"], + "module": "NodeNext", + "strict": true }, "include": [ "monster_test.ts", diff --git a/tests/ts/typescript.ts b/tests/ts/typescript.ts new file mode 100644 index 00000000000..216026ef09c --- /dev/null +++ b/tests/ts/typescript.ts @@ -0,0 +1,4 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +export { Object_ } from './typescript/object.js'; +export { class_ } from './typescript/class.js'; diff --git a/tests/ts/typescript/class.js b/tests/ts/typescript/class.js index 9b0f2c00b6d..5d84d974a50 100644 --- a/tests/ts/typescript/class.js +++ b/tests/ts/typescript/class.js @@ -3,4 +3,4 @@ export var class_; (function (class_) { class_[class_["new_"] = 0] = "new_"; class_[class_["instanceof_"] = 1] = "instanceof_"; -})(class_ || (class_ = {})); +})(class_ = class_ || (class_ = {})); diff --git a/tests/ts/typescript_include_generated.js b/tests/ts/typescript_include_generated.js index e0e1df1bea2..2c9abd21f2e 100644 --- a/tests/ts/typescript_include_generated.js +++ b/tests/ts/typescript_include_generated.js @@ -1,5 +1,38 @@ -// automatically generated by the FlatBuffers compiler, do not modify -export var class_; -(function (class_) { - class_[class_["arguments_"] = 0] = "arguments_"; -})(class_ || (class_ = {})); +"use strict"; +var __defProp = Object.defineProperty; +var __getOwnPropDesc = Object.getOwnPropertyDescriptor; +var __getOwnPropNames = Object.getOwnPropertyNames; +var __hasOwnProp = Object.prototype.hasOwnProperty; +var __export = (target, all) => { + for (var name in all) + __defProp(target, name, { get: all[name], enumerable: true }); +}; +var __copyProps = (to, from, except, desc) => { + if (from && typeof from === "object" || typeof from === "function") { + for (let key of __getOwnPropNames(from)) + if (!__hasOwnProp.call(to, key) && key !== except) + __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); + } + return to; +}; +var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); + +// foobar.ts +var foobar_exports = {}; +__export(foobar_exports, { + Abc: () => Abc, + class_: () => class_ +}); +module.exports = __toCommonJS(foobar_exports); + +// foobar/abc.js +var Abc; +(function(Abc2) { + Abc2[Abc2["a"] = 0] = "a"; +})(Abc = Abc || (Abc = {})); + +// foobar/class.js +var class_; +(function(class_2) { + class_2[class_2["arguments_"] = 0] = "arguments_"; +})(class_ = class_ || (class_ = {})); diff --git a/tests/ts/typescript_keywords_generated.js b/tests/ts/typescript_keywords_generated.js index 4525da7de4a..56d9364f7f3 100644 --- a/tests/ts/typescript_keywords_generated.js +++ b/tests/ts/typescript_keywords_generated.js @@ -1,170 +1,1805 @@ -// 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); - } -} +"use strict"; +var __create = Object.create; +var __defProp = Object.defineProperty; +var __getOwnPropDesc = Object.getOwnPropertyDescriptor; +var __getOwnPropNames = Object.getOwnPropertyNames; +var __getProtoOf = Object.getPrototypeOf; +var __hasOwnProp = Object.prototype.hasOwnProperty; +var __export = (target, all) => { + for (var name in all) + __defProp(target, name, { get: all[name], enumerable: true }); +}; +var __copyProps = (to, from, except, desc) => { + if (from && typeof from === "object" || typeof from === "function") { + for (let key of __getOwnPropNames(from)) + if (!__hasOwnProp.call(to, key) && key !== except) + __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); + } + return to; +}; +var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( + isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, + mod +)); +var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); + +// typescript.ts +var typescript_exports = {}; +__export(typescript_exports, { + Object_: () => Object_2, + class_: () => class_2 +}); +module.exports = __toCommonJS(typescript_exports); + +// typescript/object.js +var flatbuffers11 = __toESM(require("flatbuffers"), 1); + +// foobar/abc.js +var Abc; +(function(Abc2) { + Abc2[Abc2["a"] = 0] = "a"; +})(Abc = Abc || (Abc = {})); + +// foobar/class.js +var class_; +(function(class_3) { + class_3[class_3["arguments_"] = 0] = "arguments_"; +})(class_ = class_ || (class_ = {})); + +// reflection/schema.js +var flatbuffers10 = __toESM(require("flatbuffers"), 1); + +// reflection/enum.js +var flatbuffers4 = __toESM(require("flatbuffers"), 1); + +// reflection/enum-val.js +var flatbuffers2 = __toESM(require("flatbuffers"), 1); + +// reflection/type.js +var flatbuffers = __toESM(require("flatbuffers"), 1); + +// reflection/base-type.js +var BaseType; +(function(BaseType2) { + BaseType2[BaseType2["None"] = 0] = "None"; + BaseType2[BaseType2["UType"] = 1] = "UType"; + BaseType2[BaseType2["Bool"] = 2] = "Bool"; + BaseType2[BaseType2["Byte"] = 3] = "Byte"; + BaseType2[BaseType2["UByte"] = 4] = "UByte"; + BaseType2[BaseType2["Short"] = 5] = "Short"; + BaseType2[BaseType2["UShort"] = 6] = "UShort"; + BaseType2[BaseType2["Int"] = 7] = "Int"; + BaseType2[BaseType2["UInt"] = 8] = "UInt"; + BaseType2[BaseType2["Long"] = 9] = "Long"; + BaseType2[BaseType2["ULong"] = 10] = "ULong"; + BaseType2[BaseType2["Float"] = 11] = "Float"; + BaseType2[BaseType2["Double"] = 12] = "Double"; + BaseType2[BaseType2["String"] = 13] = "String"; + BaseType2[BaseType2["Vector"] = 14] = "Vector"; + BaseType2[BaseType2["Obj"] = 15] = "Obj"; + BaseType2[BaseType2["Union"] = 16] = "Union"; + BaseType2[BaseType2["Array"] = 17] = "Array"; + BaseType2[BaseType2["MaxBaseType"] = 18] = "MaxBaseType"; +})(BaseType = BaseType || (BaseType = {})); + +// reflection/type.js +var Type = class { + 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; + } + 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; + } + 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(); + } +}; +var TypeT = class { + 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); + } +}; + +// reflection/enum-val.js +var EnumVal = class { + 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() + flatbuffers2.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); + 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()); + } +}; +var EnumValT = class { + 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); + } +}; + +// reflection/key-value.js +var flatbuffers3 = __toESM(require("flatbuffers"), 1); +var KeyValue = class { + 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() + flatbuffers3.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); + 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(); + } +}; +var KeyValueT = class { + 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); + } +}; + +// reflection/enum.js +var Enum = class { + 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() + flatbuffers4.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, 0); + } + 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); + builder.requiredField(offset, 6); + builder.requiredField(offset, 10); + 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(); + } +}; +var EnumT = class { + 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); + } +}; + +// reflection/object.js +var flatbuffers6 = __toESM(require("flatbuffers"), 1); + +// reflection/field.js +var flatbuffers5 = __toESM(require("flatbuffers"), 1); +var Field = class { + 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() + flatbuffers5.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; + } + 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; + } + 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); + } + static addDeprecated(builder, deprecated) { + builder.addFieldInt8(6, +deprecated, 0); + } + static addRequired(builder, required) { + builder.addFieldInt8(7, +required, 0); + } + static addKey(builder, key) { + builder.addFieldInt8(8, +key, 0); + } + 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, 0); + } + static addPadding(builder, padding) { + builder.addFieldInt16(12, padding, 0); + } + static endField(builder) { + const offset = builder.endObject(); + builder.requiredField(offset, 4); + builder.requiredField(offset, 6); + 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(); + } +}; +var FieldT = class { + constructor(name = null, type = null, id = 0, offset = 0, defaultInteger = BigInt("0"), defaultReal = 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); + } +}; + +// reflection/object.js +var Object_ = class { + 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() + flatbuffers6.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, 0); + } + 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); + builder.requiredField(offset, 6); + 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(); + } +}; +var Object_T = class { + 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); + } +}; + +// reflection/schema-file.js +var flatbuffers7 = __toESM(require("flatbuffers"), 1); +var SchemaFile = class { + 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() + flatbuffers7.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); + 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()); + } +}; +var SchemaFileT = class { + 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); + } +}; + +// reflection/service.js +var flatbuffers9 = __toESM(require("flatbuffers"), 1); + +// reflection/rpccall.js +var flatbuffers8 = __toESM(require("flatbuffers"), 1); +var RPCCall = class { + 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() + flatbuffers8.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); + builder.requiredField(offset, 6); + builder.requiredField(offset, 8); + 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()); + } +}; +var RPCCallT = class { + 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); + } +}; + +// reflection/service.js +var Service = class { + 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() + flatbuffers9.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); + 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(); + } +}; +var ServiceT = class { + 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); + } +}; + +// reflection/schema.js +var Schema = class { + 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() + flatbuffers10.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; + } + 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); + builder.requiredField(offset, 6); + 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()); + } +}; +var SchemaT = class { + 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); + } +}; + +// typescript/class.js +var class_2; +(function(class_3) { + class_3[class_3["new_"] = 0] = "new_"; + class_3[class_3["instanceof_"] = 1] = "instanceof_"; +})(class_2 = class_2 || (class_2 = {})); + +// typescript/object.js +var Object_2 = class { + 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_2()).__init(bb.readInt32(bb.position()) + bb.position(), bb); + } + static getSizePrefixedRootAsObject(bb, obj) { + bb.setPosition(bb.position() + flatbuffers11.SIZE_PREFIX_LENGTH); + return (obj || new Object_2()).__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_2.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) : 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_2.new_); + } + static addEnum2(builder, enum2) { + builder.addFieldInt32(4, enum2, 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_T2(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; + } +}; +var Object_T2 = class { + constructor(return_ = 0, if_ = 0, switch_ = 0, enum_ = class_2.new_, enum2 = 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_2.startObject(builder); + Object_2.addReturn(builder, this.return_); + Object_2.addIf(builder, this.if_); + Object_2.addSwitch(builder, this.switch_); + Object_2.addEnum(builder, this.enum_); + Object_2.addEnum2(builder, this.enum2); + Object_2.addEnum3(builder, this.enum3); + Object_2.addReflect(builder, reflect); + return Object_2.endObject(builder); + } +}; diff --git a/tests/ts/typescript_keywords_generated.ts b/tests/ts/typescript_keywords_generated.ts deleted file mode 100644 index bcc61102dd5..00000000000 --- a/tests/ts/typescript_keywords_generated.ts +++ /dev/null @@ -1,226 +0,0 @@ -// 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_ implements flatbuffers.IUnpackableObject { - 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 implements flatbuffers.IGeneratedObject { -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 index cdef988d941..a54eecfb4bf 100644 --- a/tests/ts/typescript_transitive_include_generated.js +++ b/tests/ts/typescript_transitive_include_generated.js @@ -1,5 +1,31 @@ -// automatically generated by the FlatBuffers compiler, do not modify -export var Abc; -(function (Abc) { - Abc[Abc["a"] = 0] = "a"; -})(Abc || (Abc = {})); +"use strict"; +var __defProp = Object.defineProperty; +var __getOwnPropDesc = Object.getOwnPropertyDescriptor; +var __getOwnPropNames = Object.getOwnPropertyNames; +var __hasOwnProp = Object.prototype.hasOwnProperty; +var __export = (target, all) => { + for (var name in all) + __defProp(target, name, { get: all[name], enumerable: true }); +}; +var __copyProps = (to, from, except, desc) => { + if (from && typeof from === "object" || typeof from === "function") { + for (let key of __getOwnPropNames(from)) + if (!__hasOwnProp.call(to, key) && key !== except) + __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); + } + return to; +}; +var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); + +// foobar.ts +var foobar_exports = {}; +__export(foobar_exports, { + Abc: () => Abc +}); +module.exports = __toCommonJS(foobar_exports); + +// foobar/abc.js +var Abc; +(function(Abc2) { + Abc2[Abc2["a"] = 0] = "a"; +})(Abc = Abc || (Abc = {})); diff --git a/tests/ts/union_vector.ts b/tests/ts/union_vector.ts new file mode 100644 index 00000000000..60d840fc188 --- /dev/null +++ b/tests/ts/union_vector.ts @@ -0,0 +1,10 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +export { Attacker } from './union_vector/attacker.js'; +export { BookReader } from './union_vector/book-reader.js'; +export { Character } from './union_vector/character.js'; +export { FallingTub } from './union_vector/falling-tub.js'; +export { Gadget } from './union_vector/gadget.js'; +export { HandFan } from './union_vector/hand-fan.js'; +export { Movie } from './union_vector/movie.js'; +export { Rapunzel } from './union_vector/rapunzel.js'; diff --git a/tests/ts/union_vector/character.js b/tests/ts/union_vector/character.js index 04e3294ccd9..0ef2ed16d82 100644 --- a/tests/ts/union_vector/character.js +++ b/tests/ts/union_vector/character.js @@ -11,7 +11,7 @@ export var Character; Character[Character["BookFan"] = 4] = "BookFan"; Character[Character["Other"] = 5] = "Other"; Character[Character["Unused"] = 6] = "Unused"; -})(Character || (Character = {})); +})(Character = Character || (Character = {})); export function unionToCharacter(type, accessor) { switch (Character[type]) { case 'NONE': return null; diff --git a/tests/ts/union_vector/gadget.js b/tests/ts/union_vector/gadget.js index 202a214b5d1..5eb339b948b 100644 --- a/tests/ts/union_vector/gadget.js +++ b/tests/ts/union_vector/gadget.js @@ -6,7 +6,7 @@ export var Gadget; Gadget[Gadget["NONE"] = 0] = "NONE"; Gadget[Gadget["FallingTub"] = 1] = "FallingTub"; Gadget[Gadget["HandFan"] = 2] = "HandFan"; -})(Gadget || (Gadget = {})); +})(Gadget = Gadget || (Gadget = {})); export function unionToGadget(type, accessor) { switch (Gadget[type]) { case 'NONE': return null; diff --git a/tests/ts/union_vector/union_vector_generated.js b/tests/ts/union_vector/union_vector_generated.js index 69ea199096e..5f0006a2755 100644 --- a/tests/ts/union_vector/union_vector_generated.js +++ b/tests/ts/union_vector/union_vector_generated.js @@ -1,9 +1,548 @@ -// 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'; +"use strict"; +var __create = Object.create; +var __defProp = Object.defineProperty; +var __getOwnPropDesc = Object.getOwnPropertyDescriptor; +var __getOwnPropNames = Object.getOwnPropertyNames; +var __getProtoOf = Object.getPrototypeOf; +var __hasOwnProp = Object.prototype.hasOwnProperty; +var __export = (target, all) => { + for (var name in all) + __defProp(target, name, { get: all[name], enumerable: true }); +}; +var __copyProps = (to, from, except, desc) => { + if (from && typeof from === "object" || typeof from === "function") { + for (let key of __getOwnPropNames(from)) + if (!__hasOwnProp.call(to, key) && key !== except) + __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); + } + return to; +}; +var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( + isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, + mod +)); +var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); + +// union_vector.ts +var union_vector_exports = {}; +__export(union_vector_exports, { + Attacker: () => Attacker, + BookReader: () => BookReader, + Character: () => Character, + FallingTub: () => FallingTub, + Gadget: () => Gadget, + HandFan: () => HandFan, + Movie: () => Movie, + Rapunzel: () => Rapunzel +}); +module.exports = __toCommonJS(union_vector_exports); + +// union_vector/attacker.js +var flatbuffers = __toESM(require("flatbuffers"), 1); +var Attacker = class { + 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(); + } +}; +var AttackerT = class { + constructor(swordAttackDamage = 0) { + this.swordAttackDamage = swordAttackDamage; + } + pack(builder) { + return Attacker.createAttacker(builder, this.swordAttackDamage); + } +}; + +// union_vector/book-reader.js +var BookReader = class { + 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(); + } +}; +var BookReaderT = class { + constructor(booksRead = 0) { + this.booksRead = booksRead; + } + pack(builder) { + return BookReader.createBookReader(builder, this.booksRead); + } +}; + +// union_vector/rapunzel.js +var Rapunzel = class { + 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(); + } +}; +var RapunzelT = class { + constructor(hairLength = 0) { + this.hairLength = hairLength; + } + pack(builder) { + return Rapunzel.createRapunzel(builder, this.hairLength); + } +}; + +// union_vector/character.js +var Character; +(function(Character2) { + Character2[Character2["NONE"] = 0] = "NONE"; + Character2[Character2["MuLan"] = 1] = "MuLan"; + Character2[Character2["Rapunzel"] = 2] = "Rapunzel"; + Character2[Character2["Belle"] = 3] = "Belle"; + Character2[Character2["BookFan"] = 4] = "BookFan"; + Character2[Character2["Other"] = 5] = "Other"; + Character2[Character2["Unused"] = 6] = "Unused"; +})(Character = Character || (Character = {})); +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; + } +} +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; + } +} + +// union_vector/falling-tub.js +var FallingTub = class { + 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(); + } +}; +var FallingTubT = class { + constructor(weight = 0) { + this.weight = weight; + } + pack(builder) { + return FallingTub.createFallingTub(builder, this.weight); + } +}; + +// union_vector/hand-fan.js +var flatbuffers2 = __toESM(require("flatbuffers"), 1); +var HandFan = class { + 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() + flatbuffers2.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(); + } +}; +var HandFanT = class { + constructor(length = 0) { + this.length = length; + } + pack(builder) { + return HandFan.createHandFan(builder, this.length); + } +}; + +// union_vector/gadget.js +var Gadget; +(function(Gadget2) { + Gadget2[Gadget2["NONE"] = 0] = "NONE"; + Gadget2[Gadget2["FallingTub"] = 1] = "FallingTub"; + Gadget2[Gadget2["HandFan"] = 2] = "HandFan"; +})(Gadget = Gadget || (Gadget = {})); + +// union_vector/movie.js +var flatbuffers3 = __toESM(require("flatbuffers"), 1); +var Movie = class { + 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() + flatbuffers3.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(), (() => { + const 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()), (() => { + const ret = []; + for (let targetEnumIndex = 0; targetEnumIndex < this.charactersTypeLength(); ++targetEnumIndex) { + const targetEnum = this.charactersType(targetEnumIndex); + if (targetEnum === null || Character[targetEnum] === "NONE") { + continue; + } + const 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 = (() => { + const 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 = (() => { + const ret = []; + for (let targetEnumIndex = 0; targetEnumIndex < this.charactersTypeLength(); ++targetEnumIndex) { + const targetEnum = this.charactersType(targetEnumIndex); + if (targetEnum === null || Character[targetEnum] === "NONE") { + continue; + } + const 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; + })(); + } +}; +var MovieT = class { + 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/union_vector_generated.ts b/tests/ts/union_vector/union_vector_generated.ts deleted file mode 100644 index 5527abe17d8..00000000000 --- a/tests/ts/union_vector/union_vector_generated.ts +++ /dev/null @@ -1,10 +0,0 @@ -// 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/attacker.js b/tests/union_vector/attacker.js deleted file mode 100644 index 32be94e2cbd..00000000000 --- a/tests/union_vector/attacker.js +++ /dev/null @@ -1,64 +0,0 @@ -// 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/union_vector/attacker.ts b/tests/union_vector/attacker.ts deleted file mode 100644 index 6b3fc0fc140..00000000000 --- a/tests/union_vector/attacker.ts +++ /dev/null @@ -1,87 +0,0 @@ -// 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/union_vector/book-reader.js b/tests/union_vector/book-reader.js deleted file mode 100644 index 0d9e1a57cd4..00000000000 --- a/tests/union_vector/book-reader.js +++ /dev/null @@ -1,44 +0,0 @@ -// 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/union_vector/book-reader.ts b/tests/union_vector/book-reader.ts deleted file mode 100644 index 7a31278125a..00000000000 --- a/tests/union_vector/book-reader.ts +++ /dev/null @@ -1,63 +0,0 @@ -// 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/union_vector/character.js b/tests/union_vector/character.js deleted file mode 100644 index c0602981715..00000000000 --- a/tests/union_vector/character.js +++ /dev/null @@ -1,38 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify -import { Attacker } from './attacker'; -import { BookReader } from './book-reader'; -import { Rapunzel } from './rapunzel'; -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/union_vector/character.ts b/tests/union_vector/character.ts deleted file mode 100644 index d8ffbc2a1eb..00000000000 --- a/tests/union_vector/character.ts +++ /dev/null @@ -1,49 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -import { Attacker, AttackerT } from './attacker'; -import { BookReader, BookReaderT } from './book-reader'; -import { Rapunzel, RapunzelT } from './rapunzel'; - - -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/union_vector/falling-tub.ts b/tests/union_vector/falling-tub.ts deleted file mode 100644 index b32f99d0ff4..00000000000 --- a/tests/union_vector/falling-tub.ts +++ /dev/null @@ -1,63 +0,0 @@ -// 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/union_vector/gadget.ts b/tests/union_vector/gadget.ts deleted file mode 100644 index 328071ebbcc..00000000000 --- a/tests/union_vector/gadget.ts +++ /dev/null @@ -1,36 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -import { FallingTub, FallingTubT } from './falling-tub'; -import { HandFan, HandFanT } from './hand-fan'; - - -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/union_vector/hand-fan.ts b/tests/union_vector/hand-fan.ts deleted file mode 100644 index f90b4dd3195..00000000000 --- a/tests/union_vector/hand-fan.ts +++ /dev/null @@ -1,87 +0,0 @@ -// 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/union_vector/movie.js b/tests/union_vector/movie.js deleted file mode 100644 index b4d8099441f..00000000000 --- a/tests/union_vector/movie.js +++ /dev/null @@ -1,185 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify -import * as flatbuffers from 'flatbuffers'; -import { Character, unionToCharacter, unionListToCharacter } from './character'; -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/union_vector/movie.ts b/tests/union_vector/movie.ts deleted file mode 100644 index fceadaa2977..00000000000 --- a/tests/union_vector/movie.ts +++ /dev/null @@ -1,211 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -import * as flatbuffers from 'flatbuffers'; - -import { Attacker, AttackerT } from './attacker'; -import { BookReader, BookReaderT } from './book-reader'; -import { Character, unionToCharacter, unionListToCharacter } from './character'; -import { Rapunzel, RapunzelT } from './rapunzel'; - - -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/union_vector/union_vector.js b/tests/union_vector/union_vector.js deleted file mode 100644 index f3a118b7de0..00000000000 --- a/tests/union_vector/union_vector.js +++ /dev/null @@ -1,8 +0,0 @@ -export { Attacker, AttackerT } from './attacker'; -export { BookReader, BookReaderT } from './book-reader'; -export { Character, unionToCharacter, unionListToCharacter } from './character'; -export { FallingTub, FallingTubT } from './falling-tub'; -export { Gadget, unionToGadget, unionListToGadget } from './gadget'; -export { HandFan, HandFanT } from './hand-fan'; -export { Movie, MovieT } from './movie'; -export { Rapunzel, RapunzelT } from './rapunzel'; diff --git a/tests/union_vector/union_vector.ts b/tests/union_vector/union_vector.ts deleted file mode 100644 index f3a118b7de0..00000000000 --- a/tests/union_vector/union_vector.ts +++ /dev/null @@ -1,8 +0,0 @@ -export { Attacker, AttackerT } from './attacker'; -export { BookReader, BookReaderT } from './book-reader'; -export { Character, unionToCharacter, unionListToCharacter } from './character'; -export { FallingTub, FallingTubT } from './falling-tub'; -export { Gadget, unionToGadget, unionListToGadget } from './gadget'; -export { HandFan, HandFanT } from './hand-fan'; -export { Movie, MovieT } from './movie'; -export { Rapunzel, RapunzelT } from './rapunzel'; diff --git a/tests/union_vector/union_vector_generated.ts b/tests/union_vector/union_vector_generated.ts deleted file mode 100644 index d3b41c49545..00000000000 --- a/tests/union_vector/union_vector_generated.ts +++ /dev/null @@ -1,10 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -export { Attacker, AttackerT } from './attacker'; -export { BookReader, BookReaderT } from './book-reader'; -export { Character, unionToCharacter, unionListToCharacter } from './character'; -export { FallingTub, FallingTubT } from './falling-tub'; -export { Gadget, unionToGadget, unionListToGadget } from './gadget'; -export { HandFan, HandFanT } from './hand-fan'; -export { Movie, MovieT } from './movie'; -export { Rapunzel, RapunzelT } from './rapunzel'; diff --git a/ts/BUILD.bazel b/ts/BUILD.bazel index 605329ed3ec..cb3cb0f2607 100644 --- a/ts/BUILD.bazel +++ b/ts/BUILD.bazel @@ -8,7 +8,7 @@ ts_project( "byte-buffer.ts", "constants.ts", "encoding.ts", - "index.ts", + "flatbuffers.ts", "types.ts", "utils.ts", ], diff --git a/ts/flatbuffers.ts b/ts/flatbuffers.ts index 7c0010bf063..a6085124513 100644 --- a/ts/flatbuffers.ts +++ b/ts/flatbuffers.ts @@ -1 +1,12 @@ -export * as flatbuffers from './index.js' \ No newline at end of file +export { SIZEOF_SHORT } from './constants.js' +export { SIZEOF_INT } from './constants.js' +export { FILE_IDENTIFIER_LENGTH } from './constants.js' +export { SIZE_PREFIX_LENGTH } from './constants.js' + +export { Table, Offset, IGeneratedObject, IUnpackableObject } from './types.js' + +export { int32, float32, float64, isLittleEndian } from './utils.js' + +export { Encoding } from './encoding.js' +export { Builder } from './builder.js' +export { ByteBuffer } from './byte-buffer.js' diff --git a/ts/index.ts b/ts/index.ts deleted file mode 100644 index a6085124513..00000000000 --- a/ts/index.ts +++ /dev/null @@ -1,12 +0,0 @@ -export { SIZEOF_SHORT } from './constants.js' -export { SIZEOF_INT } from './constants.js' -export { FILE_IDENTIFIER_LENGTH } from './constants.js' -export { SIZE_PREFIX_LENGTH } from './constants.js' - -export { Table, Offset, IGeneratedObject, IUnpackableObject } from './types.js' - -export { int32, float32, float64, isLittleEndian } from './utils.js' - -export { Encoding } from './encoding.js' -export { Builder } from './builder.js' -export { ByteBuffer } from './byte-buffer.js' diff --git a/tsconfig.json b/tsconfig.json index 9af4075eff1..1636255e792 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,13 +1,12 @@ { "compilerOptions": { - "target": "ES5", - "module": "commonjs", - "lib": ["ES2015", "ES2020.BigInt", "DOM"], + "target": "ES2020", + "module": "CommonJS", + "lib": ["ES2020", "DOM"], "declaration": true, "outDir": "./js", "strict": true, "esModuleInterop": true, - "skipLibCheck": true, "forceConsistentCasingInFileNames": true }, "include": [ diff --git a/tsconfig.mjs.json b/tsconfig.mjs.json index 5af9460d7ee..4c58d849252 100644 --- a/tsconfig.mjs.json +++ b/tsconfig.mjs.json @@ -1,13 +1,12 @@ { "compilerOptions": { - "target": "ES2017", - "module": "ES2015", - "lib": ["ES2017", "ES2020.BigInt", "DOM"], + "target": "ES2020", + "module": "NodeNext", + "lib": ["ES2020", "DOM"], "declaration": true, "outDir": "./mjs", "strict": true, "esModuleInterop": true, - "skipLibCheck": true, "forceConsistentCasingInFileNames": true }, "include": [ diff --git a/typescript.bzl b/typescript.bzl index f112f34f958..4e2115cbfdb 100644 --- a/typescript.bzl +++ b/typescript.bzl @@ -11,7 +11,6 @@ DEFAULT_FLATC_TS_ARGS = [ "--gen-mutable", "--reflect-names", "--gen-name-strings", - "--ts-flat-files", "--keep-prefix", ] diff --git a/yarn.lock b/yarn.lock index 8636de9b986..13c6665a949 100644 --- a/yarn.lock +++ b/yarn.lock @@ -20,6 +20,16 @@ dependencies: google-protobuf "^3.6.1" +"@esbuild/android-arm@0.15.10": + version "0.15.10" + resolved "https://registry.yarnpkg.com/@esbuild/android-arm/-/android-arm-0.15.10.tgz#a5f9432eb221afc243c321058ef25fe899886892" + integrity sha512-FNONeQPy/ox+5NBkcSbYJxoXj9GWu8gVGJTVmUyoOCKQFDTrHVKgNSzChdNt0I8Aj/iKcsDf2r9BFwv+FSNUXg== + +"@esbuild/linux-loong64@0.15.10": + version "0.15.10" + resolved "https://registry.yarnpkg.com/@esbuild/linux-loong64/-/linux-loong64-0.15.10.tgz#78a42897c2cf8db9fd5f1811f7590393b77774c7" + integrity sha512-w0Ou3Z83LOYEkwaui2M8VwIp+nLi/NA60lBLMvaJ+vXVMcsARYdEzLNE7RSm4+lSg4zq4d7fAVuzk7PNQ5JFgg== + "@eslint/eslintrc@^1.3.2": version "1.3.2" resolved "https://registry.yarnpkg.com/@eslint/eslintrc/-/eslintrc-1.3.2.tgz#58b69582f3b7271d8fa67fe5251767a5b38ea356" @@ -366,6 +376,134 @@ doctrine@^3.0.0: dependencies: esutils "^2.0.2" +esbuild-android-64@0.15.10: + version "0.15.10" + resolved "https://registry.yarnpkg.com/esbuild-android-64/-/esbuild-android-64-0.15.10.tgz#8a59a84acbf2eca96996cadc35642cf055c494f0" + integrity sha512-UI7krF8OYO1N7JYTgLT9ML5j4+45ra3amLZKx7LO3lmLt1Ibn8t3aZbX5Pu4BjWiqDuJ3m/hsvhPhK/5Y/YpnA== + +esbuild-android-arm64@0.15.10: + version "0.15.10" + resolved "https://registry.yarnpkg.com/esbuild-android-arm64/-/esbuild-android-arm64-0.15.10.tgz#f453851dc1d8c5409a38cf7613a33852faf4915d" + integrity sha512-EOt55D6xBk5O05AK8brXUbZmoFj4chM8u3riGflLa6ziEoVvNjRdD7Cnp82NHQGfSHgYR06XsPI8/sMuA/cUwg== + +esbuild-darwin-64@0.15.10: + version "0.15.10" + resolved "https://registry.yarnpkg.com/esbuild-darwin-64/-/esbuild-darwin-64-0.15.10.tgz#778bd29c8186ff47b176c8af58c08cf0fb8e6b86" + integrity sha512-hbDJugTicqIm+WKZgp208d7FcXcaK8j2c0l+fqSJ3d2AzQAfjEYDRM3Z2oMeqSJ9uFxyj/muSACLdix7oTstRA== + +esbuild-darwin-arm64@0.15.10: + version "0.15.10" + resolved "https://registry.yarnpkg.com/esbuild-darwin-arm64/-/esbuild-darwin-arm64-0.15.10.tgz#b30bbefb46dc3c5d4708b0435e52f6456578d6df" + integrity sha512-M1t5+Kj4IgSbYmunf2BB6EKLkWUq+XlqaFRiGOk8bmBapu9bCDrxjf4kUnWn59Dka3I27EiuHBKd1rSO4osLFQ== + +esbuild-freebsd-64@0.15.10: + version "0.15.10" + resolved "https://registry.yarnpkg.com/esbuild-freebsd-64/-/esbuild-freebsd-64-0.15.10.tgz#ab301c5f6ded5110dbdd611140bef1a7c2e99236" + integrity sha512-KMBFMa7C8oc97nqDdoZwtDBX7gfpolkk6Bcmj6YFMrtCMVgoU/x2DI1p74DmYl7CSS6Ppa3xgemrLrr5IjIn0w== + +esbuild-freebsd-arm64@0.15.10: + version "0.15.10" + resolved "https://registry.yarnpkg.com/esbuild-freebsd-arm64/-/esbuild-freebsd-arm64-0.15.10.tgz#a5b09b867a6ff49110f52343b6f12265db63d43f" + integrity sha512-m2KNbuCX13yQqLlbSojFMHpewbn8wW5uDS6DxRpmaZKzyq8Dbsku6hHvh2U+BcLwWY4mpgXzFUoENEf7IcioGg== + +esbuild-linux-32@0.15.10: + version "0.15.10" + resolved "https://registry.yarnpkg.com/esbuild-linux-32/-/esbuild-linux-32-0.15.10.tgz#5282fe9915641caf9c8070e4ba2c3e16d358f837" + integrity sha512-guXrwSYFAvNkuQ39FNeV4sNkNms1bLlA5vF1H0cazZBOLdLFIny6BhT+TUbK/hdByMQhtWQ5jI9VAmPKbVPu1w== + +esbuild-linux-64@0.15.10: + version "0.15.10" + resolved "https://registry.yarnpkg.com/esbuild-linux-64/-/esbuild-linux-64-0.15.10.tgz#f3726e85a00149580cb19f8abfabcbb96f5d52bb" + integrity sha512-jd8XfaSJeucMpD63YNMO1JCrdJhckHWcMv6O233bL4l6ogQKQOxBYSRP/XLWP+6kVTu0obXovuckJDcA0DKtQA== + +esbuild-linux-arm64@0.15.10: + version "0.15.10" + resolved "https://registry.yarnpkg.com/esbuild-linux-arm64/-/esbuild-linux-arm64-0.15.10.tgz#2f0056e9d5286edb0185b56655caa8c574d8dbe7" + integrity sha512-GByBi4fgkvZFTHFDYNftu1DQ1GzR23jws0oWyCfhnI7eMOe+wgwWrc78dbNk709Ivdr/evefm2PJiUBMiusS1A== + +esbuild-linux-arm@0.15.10: + version "0.15.10" + resolved "https://registry.yarnpkg.com/esbuild-linux-arm/-/esbuild-linux-arm-0.15.10.tgz#40a9270da3c8ffa32cf72e24a79883e323dff08d" + integrity sha512-6N8vThLL/Lysy9y4Ex8XoLQAlbZKUyExCWyayGi2KgTBelKpPgj6RZnUaKri0dHNPGgReJriKVU6+KDGQwn10A== + +esbuild-linux-mips64le@0.15.10: + version "0.15.10" + resolved "https://registry.yarnpkg.com/esbuild-linux-mips64le/-/esbuild-linux-mips64le-0.15.10.tgz#90ce1c4ee0202edb4ac69807dea77f7e5804abc4" + integrity sha512-BxP+LbaGVGIdQNJUNF7qpYjEGWb0YyHVSKqYKrn+pTwH/SiHUxFyJYSP3pqkku61olQiSBnSmWZ+YUpj78Tw7Q== + +esbuild-linux-ppc64le@0.15.10: + version "0.15.10" + resolved "https://registry.yarnpkg.com/esbuild-linux-ppc64le/-/esbuild-linux-ppc64le-0.15.10.tgz#782837ae7bd5b279178106c9dd801755a21fabdf" + integrity sha512-LoSQCd6498PmninNgqd/BR7z3Bsk/mabImBWuQ4wQgmQEeanzWd5BQU2aNi9mBURCLgyheuZS6Xhrw5luw3OkQ== + +esbuild-linux-riscv64@0.15.10: + version "0.15.10" + resolved "https://registry.yarnpkg.com/esbuild-linux-riscv64/-/esbuild-linux-riscv64-0.15.10.tgz#d7420d806ece5174f24f4634303146f915ab4207" + integrity sha512-Lrl9Cr2YROvPV4wmZ1/g48httE8z/5SCiXIyebiB5N8VT7pX3t6meI7TQVHw/wQpqP/AF4SksDuFImPTM7Z32Q== + +esbuild-linux-s390x@0.15.10: + version "0.15.10" + resolved "https://registry.yarnpkg.com/esbuild-linux-s390x/-/esbuild-linux-s390x-0.15.10.tgz#21fdf0cb3494a7fb520a71934e4dffce67fe47be" + integrity sha512-ReP+6q3eLVVP2lpRrvl5EodKX7EZ1bS1/z5j6hsluAlZP5aHhk6ghT6Cq3IANvvDdscMMCB4QEbI+AjtvoOFpA== + +esbuild-netbsd-64@0.15.10: + version "0.15.10" + resolved "https://registry.yarnpkg.com/esbuild-netbsd-64/-/esbuild-netbsd-64-0.15.10.tgz#6c06b3107e3df53de381e6299184d4597db0440f" + integrity sha512-iGDYtJCMCqldMskQ4eIV+QSS/CuT7xyy9i2/FjpKvxAuCzrESZXiA1L64YNj6/afuzfBe9i8m/uDkFHy257hTw== + +esbuild-openbsd-64@0.15.10: + version "0.15.10" + resolved "https://registry.yarnpkg.com/esbuild-openbsd-64/-/esbuild-openbsd-64-0.15.10.tgz#4daef5f5d8e74bbda53b65160029445d582570cf" + integrity sha512-ftMMIwHWrnrYnvuJQRJs/Smlcb28F9ICGde/P3FUTCgDDM0N7WA0o9uOR38f5Xe2/OhNCgkjNeb7QeaE3cyWkQ== + +esbuild-sunos-64@0.15.10: + version "0.15.10" + resolved "https://registry.yarnpkg.com/esbuild-sunos-64/-/esbuild-sunos-64-0.15.10.tgz#5fe7bef267a02f322fd249a8214d0274937388a7" + integrity sha512-mf7hBL9Uo2gcy2r3rUFMjVpTaGpFJJE5QTDDqUFf1632FxteYANffDZmKbqX0PfeQ2XjUDE604IcE7OJeoHiyg== + +esbuild-windows-32@0.15.10: + version "0.15.10" + resolved "https://registry.yarnpkg.com/esbuild-windows-32/-/esbuild-windows-32-0.15.10.tgz#48e3dde25ab0135579a288b30ab6ddef6d1f0b28" + integrity sha512-ttFVo+Cg8b5+qHmZHbEc8Vl17kCleHhLzgT8X04y8zudEApo0PxPg9Mz8Z2cKH1bCYlve1XL8LkyXGFjtUYeGg== + +esbuild-windows-64@0.15.10: + version "0.15.10" + resolved "https://registry.yarnpkg.com/esbuild-windows-64/-/esbuild-windows-64-0.15.10.tgz#387a9515bef3fee502d277a5d0a2db49a4ecda05" + integrity sha512-2H0gdsyHi5x+8lbng3hLbxDWR7mKHWh5BXZGKVG830KUmXOOWFE2YKJ4tHRkejRduOGDrBvHBriYsGtmTv3ntA== + +esbuild-windows-arm64@0.15.10: + version "0.15.10" + resolved "https://registry.yarnpkg.com/esbuild-windows-arm64/-/esbuild-windows-arm64-0.15.10.tgz#5a6fcf2fa49e895949bf5495cf088ab1b43ae879" + integrity sha512-S+th4F+F8VLsHLR0zrUcG+Et4hx0RKgK1eyHc08kztmLOES8BWwMiaGdoW9hiXuzznXQ0I/Fg904MNbr11Nktw== + +esbuild@^0.15.10: + version "0.15.10" + resolved "https://registry.yarnpkg.com/esbuild/-/esbuild-0.15.10.tgz#85c2f8446e9b1fe04fae68daceacba033eedbd42" + integrity sha512-N7wBhfJ/E5fzn/SpNgX+oW2RLRjwaL8Y0ezqNqhjD6w0H2p0rDuEz2FKZqpqLnO8DCaWumKe8dsC/ljvVSSxng== + optionalDependencies: + "@esbuild/android-arm" "0.15.10" + "@esbuild/linux-loong64" "0.15.10" + esbuild-android-64 "0.15.10" + esbuild-android-arm64 "0.15.10" + esbuild-darwin-64 "0.15.10" + esbuild-darwin-arm64 "0.15.10" + esbuild-freebsd-64 "0.15.10" + esbuild-freebsd-arm64 "0.15.10" + esbuild-linux-32 "0.15.10" + esbuild-linux-64 "0.15.10" + esbuild-linux-arm "0.15.10" + esbuild-linux-arm64 "0.15.10" + esbuild-linux-mips64le "0.15.10" + esbuild-linux-ppc64le "0.15.10" + esbuild-linux-riscv64 "0.15.10" + esbuild-linux-s390x "0.15.10" + esbuild-netbsd-64 "0.15.10" + esbuild-openbsd-64 "0.15.10" + esbuild-sunos-64 "0.15.10" + esbuild-windows-32 "0.15.10" + esbuild-windows-64 "0.15.10" + esbuild-windows-arm64 "0.15.10" + 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" @@ -560,11 +698,6 @@ fs.realpath@^1.0.0: resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f" integrity sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw== -fsevents@~2.3.2: - version "2.3.2" - resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.2.tgz#8a526f78b8fdf4623b709e0b975c52c24c02fd1a" - integrity sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA== - 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" @@ -888,13 +1021,6 @@ rimraf@^3.0.2: dependencies: glob "^7.1.3" -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" - run-parallel@^1.1.9: version "1.2.0" resolved "https://registry.yarnpkg.com/run-parallel/-/run-parallel-1.2.0.tgz#66d1368da7bdf921eb9d95bd1a9229e7f21a43ee" From 72cae79907e11e3b9f38ebfbdbfc6a61d1e3dd1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Harrtell?= Date: Sat, 12 Nov 2022 14:44:15 +0100 Subject: [PATCH 02/39] Fix handling of outputpath and array_test --- src/idl_gen_ts.cpp | 16 +- tests/ts/JavaScriptComplexArraysTest.js | 15 +- tests/ts/TypeScriptTest.py | 2 +- .../arrays_test_complex_generated.js | 860 ++--- .../arrays_test_complex_generated.ts | 626 ---- .../ts/arrays_test_complex/my-game/example.js | 7 + .../ts/arrays_test_complex/my-game/example.ts | 8 + .../my-game/example/array-struct.js | 98 + .../my-game/example/array-struct.ts | 166 + .../my-game/example/array-table.js | 74 + .../my-game/example/array-table.ts | 102 + .../my-game/example/inner-struct.js | 61 + .../my-game/example/inner-struct.ts | 91 + .../my-game/example/nested-struct.js | 80 + .../my-game/example/nested-struct.ts | 135 + .../my-game/example/outer-struct.js | 95 + .../my-game/example/outer-struct.ts | 152 + .../my-game/example/test-enum.js | 7 + .../my-game/example/test-enum.ts | 7 + tests/ts/monster_test_generated.js | 24 +- tests/ts/my-game/example.ts | 22 +- tests/ts/my-game/example/monster.js | 24 +- tests/ts/reflection_generated.js | 3259 +++++++++-------- tests/ts/reflection_generated.ts | 2131 ----------- .../ts-flat-files/monster_test_generated.ts | 1902 ---------- tests/ts/typescript_keywords_generated.js | 179 +- tests/ts/union_vector.ts | 10 - tests/ts/union_vector/union_vector.js | 9 + tests/ts/union_vector/union_vector.ts | 10 + .../ts/union_vector/union_vector_generated.js | 2 +- 30 files changed, 3388 insertions(+), 6786 deletions(-) delete mode 100644 tests/ts/arrays_test_complex/arrays_test_complex_generated.ts create mode 100644 tests/ts/arrays_test_complex/my-game/example.js create mode 100644 tests/ts/arrays_test_complex/my-game/example.ts create mode 100644 tests/ts/arrays_test_complex/my-game/example/array-struct.js create mode 100644 tests/ts/arrays_test_complex/my-game/example/array-struct.ts create mode 100644 tests/ts/arrays_test_complex/my-game/example/array-table.js create mode 100644 tests/ts/arrays_test_complex/my-game/example/array-table.ts create mode 100644 tests/ts/arrays_test_complex/my-game/example/inner-struct.js create mode 100644 tests/ts/arrays_test_complex/my-game/example/inner-struct.ts create mode 100644 tests/ts/arrays_test_complex/my-game/example/nested-struct.js create mode 100644 tests/ts/arrays_test_complex/my-game/example/nested-struct.ts create mode 100644 tests/ts/arrays_test_complex/my-game/example/outer-struct.js create mode 100644 tests/ts/arrays_test_complex/my-game/example/outer-struct.ts create mode 100644 tests/ts/arrays_test_complex/my-game/example/test-enum.js create mode 100644 tests/ts/arrays_test_complex/my-game/example/test-enum.ts delete mode 100644 tests/ts/reflection_generated.ts delete mode 100644 tests/ts/ts-flat-files/monster_test_generated.ts delete mode 100644 tests/ts/union_vector.ts create mode 100644 tests/ts/union_vector/union_vector.js create mode 100644 tests/ts/union_vector/union_vector.ts diff --git a/src/idl_gen_ts.cpp b/src/idl_gen_ts.cpp index 01f6e477b24..6fe4eaef543 100644 --- a/src/idl_gen_ts.cpp +++ b/src/idl_gen_ts.cpp @@ -174,13 +174,13 @@ class TsGenerator : public BaseGenerator { std::string symbolic_name; if (definition.defined_namespace->components.size() > 0) { path = namer_.Directories(*definition.defined_namespace, - SkipDir::OutputPathAndTrailingPathSeparator); + SkipDir::TrailingPathSeperator); filepath = path + ".ts"; symbolic_name = definition.defined_namespace->components.back(); } else { auto def_mod_name = namer_.File(definition, SkipFile::SuffixAndExtension); symbolic_name = file_name_; - filepath = symbolic_name + ".ts"; + filepath = path_ + symbolic_name + ".ts"; } if (ns_defs_.count(path) == 0) { NsDefinition nsDef; @@ -255,11 +255,12 @@ class TsGenerator : public BaseGenerator { auto base_file_name = namer_.File(*(def.second), SkipFile::SuffixAndExtension); auto base_name = - namer_.Directories(it.second.ns->components, SkipDir::None) + + namer_.Directories(it.second.ns->components, SkipDir::OutputPath) + base_file_name; auto ts_file_path = base_name + ".ts"; auto base_name_rel = std::string("./"); - base_name_rel += namer_.Directories(rel_components, SkipDir::None); + base_name_rel += + namer_.Directories(rel_components, SkipDir::OutputPath); base_name_rel += base_file_name; auto ts_file_path_rel = base_name_rel + ".ts"; auto type_name = def.first; @@ -287,13 +288,12 @@ class TsGenerator : public BaseGenerator { std::string inputpath; std::string symbolic_name = file_name_; if (parser_.current_namespace_->components.size() > 0) { - std::string path = - namer_.Directories(*parser_.current_namespace_, - SkipDir::OutputPathAndTrailingPathSeparator); + std::string path = namer_.Directories(*parser_.current_namespace_, + SkipDir::TrailingPathSeperator); inputpath = path + ".ts"; symbolic_name = parser_.current_namespace_->components.back(); } else { - inputpath = file_name_ + ".ts"; + inputpath = path_ + file_name_ + ".ts"; } std::string bundlepath = GeneratedFileName(path_, file_name_, parser_.opts); diff --git a/tests/ts/JavaScriptComplexArraysTest.js b/tests/ts/JavaScriptComplexArraysTest.js index f8601edfbe8..36469e577e6 100644 --- a/tests/ts/JavaScriptComplexArraysTest.js +++ b/tests/ts/JavaScriptComplexArraysTest.js @@ -3,15 +3,12 @@ import assert from 'assert'; import { readFileSync, writeFileSync } from 'fs'; import * as flatbuffers from 'flatbuffers'; -import { - ArrayStructT, - ArrayTable, - ArrayTableT, - InnerStructT, - NestedStructT, - OuterStructT, - TestEnum, -} from './arrays_test_complex/arrays_test_complex_generated.js'; +import { ArrayStructT } from './arrays_test_complex/my-game/example/array-struct.js' +import { ArrayTable, ArrayTableT } from './arrays_test_complex/my-game/example/array-table.js' +import { InnerStructT } from './arrays_test_complex/my-game/example/inner-struct.js' +import { NestedStructT } from './arrays_test_complex/my-game/example/nested-struct.js' +import { OuterStructT } from './arrays_test_complex/my-game/example/outer-struct.js' +import { TestEnum } from './arrays_test_complex/my-game/example/test-enum.js' // eslint-disable-next-line @typescript-eslint/no-explicit-any BigInt.prototype.toJSON = function () { return this.toString(); diff --git a/tests/ts/TypeScriptTest.py b/tests/ts/TypeScriptTest.py index 52d0001001e..bb7c50e7a62 100755 --- a/tests/ts/TypeScriptTest.py +++ b/tests/ts/TypeScriptTest.py @@ -85,7 +85,7 @@ def flatc(options, schema, prefix=None, include=None, data=None, cwd=tests_path) ) flatc( - options=["--ts", "--reflect-names", "--ts-flat-files", "--gen-name-strings", "--gen-object-api"], + options=["--ts", "--reflect-names", "--gen-name-strings", "--gen-object-api", "--ts-entry-points", "--ts-flat-files"], schema="arrays_test_complex/arrays_test_complex.fbs", prefix="arrays_test_complex" ) diff --git a/tests/ts/arrays_test_complex/arrays_test_complex_generated.js b/tests/ts/arrays_test_complex/arrays_test_complex_generated.js index 7530e846330..f23c9ea92ff 100644 --- a/tests/ts/arrays_test_complex/arrays_test_complex_generated.js +++ b/tests/ts/arrays_test_complex/arrays_test_complex_generated.js @@ -1,409 +1,451 @@ -// automatically generated by the FlatBuffers compiler, do not modify -import * as flatbuffers from 'flatbuffers'; -export var TestEnum; -(function (TestEnum) { - TestEnum[TestEnum["A"] = 0] = "A"; - TestEnum[TestEnum["B"] = 1] = "B"; - TestEnum[TestEnum["C"] = 2] = "C"; -})(TestEnum || (TestEnum = {})); -export class InnerStruct { - constructor() { - this.bb = null; - this.bb_pos = 0; - } - __init(i, bb) { - this.bb_pos = i; - this.bb = bb; - return this; - } - a() { - return this.bb.readFloat64(this.bb_pos); - } - b(index) { - return this.bb.readUint8(this.bb_pos + 8 + index); - } - c() { - return this.bb.readInt8(this.bb_pos + 21); - } - dUnderscore() { - return this.bb.readInt64(this.bb_pos + 24); - } - static getFullyQualifiedName() { - return 'MyGame_Example_InnerStruct'; - } - static sizeOf() { - return 32; - } - static createInnerStruct(builder, a, b, c, d_underscore) { - var _a; - builder.prep(8, 32); - builder.writeInt64(BigInt(d_underscore !== null && d_underscore !== void 0 ? d_underscore : 0)); - builder.pad(2); - builder.writeInt8(c); - for (let i = 12; i >= 0; --i) { - builder.writeInt8(((_a = b === null || b === void 0 ? void 0 : b[i]) !== null && _a !== void 0 ? _a : 0)); - } - builder.writeFloat64(a); - return builder.offset(); - } - unpack() { - return new InnerStructT(this.a(), this.bb.createScalarList(this.b.bind(this), 13), this.c(), this.dUnderscore()); - } - unpackTo(_o) { - _o.a = this.a(); - _o.b = this.bb.createScalarList(this.b.bind(this), 13); - _o.c = this.c(); - _o.dUnderscore = this.dUnderscore(); - } -} -export class InnerStructT { - constructor(a = 0.0, b = [], c = 0, dUnderscore = BigInt('0')) { - this.a = a; - this.b = b; - this.c = c; - this.dUnderscore = dUnderscore; - } - pack(builder) { - return InnerStruct.createInnerStruct(builder, this.a, this.b, this.c, this.dUnderscore); - } -} -export class OuterStruct { - constructor() { - this.bb = null; - this.bb_pos = 0; - } - __init(i, bb) { - this.bb_pos = i; - this.bb = bb; - return this; - } - a() { - return !!this.bb.readInt8(this.bb_pos); - } - b() { - return this.bb.readFloat64(this.bb_pos + 8); - } - cUnderscore(obj) { - return (obj || new InnerStruct()).__init(this.bb_pos + 16, this.bb); - } - d(index, obj) { - return (obj || new InnerStruct()).__init(this.bb_pos + 48 + index * 32, this.bb); - } - e(obj) { - return (obj || new InnerStruct()).__init(this.bb_pos + 144, this.bb); - } - f(index) { - return this.bb.readFloat64(this.bb_pos + 176 + index * 8); - } - static getFullyQualifiedName() { - return 'MyGame_Example_OuterStruct'; - } - static sizeOf() { - return 208; - } - static createOuterStruct(builder, a, b, c_underscore_a, c_underscore_b, c_underscore_c, c_underscore_d_underscore, d, e_a, e_b, e_c, e_d_underscore, f) { - var _a, _b, _c; - builder.prep(8, 208); - for (let i = 3; i >= 0; --i) { - builder.writeFloat64(((_a = f === null || f === void 0 ? void 0 : f[i]) !== null && _a !== void 0 ? _a : 0)); - } - builder.prep(8, 32); - builder.writeInt64(BigInt(e_d_underscore !== null && e_d_underscore !== void 0 ? e_d_underscore : 0)); - builder.pad(2); - builder.writeInt8(e_c); - for (let i = 12; i >= 0; --i) { - builder.writeInt8(((_b = e_b === null || e_b === void 0 ? void 0 : e_b[i]) !== null && _b !== void 0 ? _b : 0)); - } - builder.writeFloat64(e_a); - for (let i = 2; i >= 0; --i) { - const item = d === null || d === void 0 ? void 0 : d[i]; - if (item instanceof InnerStructT) { - item.pack(builder); - continue; - } - InnerStruct.createInnerStruct(builder, item === null || item === void 0 ? void 0 : item.a, item === null || item === void 0 ? void 0 : item.b, item === null || item === void 0 ? void 0 : item.c, item === null || item === void 0 ? void 0 : item.dUnderscore); - } - builder.prep(8, 32); - builder.writeInt64(BigInt(c_underscore_d_underscore !== null && c_underscore_d_underscore !== void 0 ? c_underscore_d_underscore : 0)); - builder.pad(2); - builder.writeInt8(c_underscore_c); - for (let i = 12; i >= 0; --i) { - builder.writeInt8(((_c = c_underscore_b === null || c_underscore_b === void 0 ? void 0 : c_underscore_b[i]) !== null && _c !== void 0 ? _c : 0)); - } - builder.writeFloat64(c_underscore_a); - builder.writeFloat64(b); - builder.pad(7); - builder.writeInt8(Number(Boolean(a))); - return builder.offset(); - } - unpack() { - return new OuterStructT(this.a(), this.b(), (this.cUnderscore() !== null ? this.cUnderscore().unpack() : null), this.bb.createObjList(this.d.bind(this), 3), (this.e() !== null ? this.e().unpack() : null), this.bb.createScalarList(this.f.bind(this), 4)); - } - unpackTo(_o) { - _o.a = this.a(); - _o.b = this.b(); - _o.cUnderscore = (this.cUnderscore() !== null ? this.cUnderscore().unpack() : null); - _o.d = this.bb.createObjList(this.d.bind(this), 3); - _o.e = (this.e() !== null ? this.e().unpack() : null); - _o.f = this.bb.createScalarList(this.f.bind(this), 4); - } -} -export class OuterStructT { - constructor(a = false, b = 0.0, cUnderscore = null, d = [], e = null, f = []) { - this.a = a; - this.b = b; - this.cUnderscore = cUnderscore; - this.d = d; - this.e = e; - this.f = f; - } - pack(builder) { - var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _p, _q, _r, _s; - return OuterStruct.createOuterStruct(builder, this.a, this.b, ((_b = (_a = this.cUnderscore) === null || _a === void 0 ? void 0 : _a.a) !== null && _b !== void 0 ? _b : 0), ((_d = (_c = this.cUnderscore) === null || _c === void 0 ? void 0 : _c.b) !== null && _d !== void 0 ? _d : []), ((_f = (_e = this.cUnderscore) === null || _e === void 0 ? void 0 : _e.c) !== null && _f !== void 0 ? _f : 0), ((_h = (_g = this.cUnderscore) === null || _g === void 0 ? void 0 : _g.dUnderscore) !== null && _h !== void 0 ? _h : BigInt(0)), this.d, ((_k = (_j = this.e) === null || _j === void 0 ? void 0 : _j.a) !== null && _k !== void 0 ? _k : 0), ((_m = (_l = this.e) === null || _l === void 0 ? void 0 : _l.b) !== null && _m !== void 0 ? _m : []), ((_q = (_p = this.e) === null || _p === void 0 ? void 0 : _p.c) !== null && _q !== void 0 ? _q : 0), ((_s = (_r = this.e) === null || _r === void 0 ? void 0 : _r.dUnderscore) !== null && _s !== void 0 ? _s : BigInt(0)), this.f); - } -} -export class NestedStruct { - constructor() { - this.bb = null; - this.bb_pos = 0; - } - __init(i, bb) { - this.bb_pos = i; - this.bb = bb; - return this; - } - a(index) { - return this.bb.readInt32(this.bb_pos + 0 + index * 4); - } - b() { - return this.bb.readInt8(this.bb_pos + 8); - } - cUnderscore(index) { - return this.bb.readInt8(this.bb_pos + 9 + index); - } - dOuter(index, obj) { - return (obj || new OuterStruct()).__init(this.bb_pos + 16 + index * 208, this.bb); - } - e(index) { - return this.bb.readInt64(this.bb_pos + 1056 + index * 8); - } - static getFullyQualifiedName() { - return 'MyGame_Example_NestedStruct'; - } - static sizeOf() { - return 1072; - } - static createNestedStruct(builder, a, b, c_underscore, d_outer, e) { - var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _p, _q, _r, _s, _t, _u, _v; - builder.prep(8, 1072); - for (let i = 1; i >= 0; --i) { - builder.writeInt64(BigInt((_a = e === null || e === void 0 ? void 0 : e[i]) !== null && _a !== void 0 ? _a : 0)); - } - for (let i = 4; i >= 0; --i) { - const item = d_outer === null || d_outer === void 0 ? void 0 : d_outer[i]; - if (item instanceof OuterStructT) { - item.pack(builder); - continue; - } - OuterStruct.createOuterStruct(builder, item === null || item === void 0 ? void 0 : item.a, item === null || item === void 0 ? void 0 : item.b, ((_c = (_b = item === null || item === void 0 ? void 0 : item.cUnderscore) === null || _b === void 0 ? void 0 : _b.a) !== null && _c !== void 0 ? _c : 0), ((_e = (_d = item === null || item === void 0 ? void 0 : item.cUnderscore) === null || _d === void 0 ? void 0 : _d.b) !== null && _e !== void 0 ? _e : []), ((_g = (_f = item === null || item === void 0 ? void 0 : item.cUnderscore) === null || _f === void 0 ? void 0 : _f.c) !== null && _g !== void 0 ? _g : 0), ((_j = (_h = item === null || item === void 0 ? void 0 : item.cUnderscore) === null || _h === void 0 ? void 0 : _h.dUnderscore) !== null && _j !== void 0 ? _j : BigInt(0)), item === null || item === void 0 ? void 0 : item.d, ((_l = (_k = item === null || item === void 0 ? void 0 : item.e) === null || _k === void 0 ? void 0 : _k.a) !== null && _l !== void 0 ? _l : 0), ((_p = (_m = item === null || item === void 0 ? void 0 : item.e) === null || _m === void 0 ? void 0 : _m.b) !== null && _p !== void 0 ? _p : []), ((_r = (_q = item === null || item === void 0 ? void 0 : item.e) === null || _q === void 0 ? void 0 : _q.c) !== null && _r !== void 0 ? _r : 0), ((_t = (_s = item === null || item === void 0 ? void 0 : item.e) === null || _s === void 0 ? void 0 : _s.dUnderscore) !== null && _t !== void 0 ? _t : BigInt(0)), item === null || item === void 0 ? void 0 : item.f); - } - builder.pad(5); - for (let i = 1; i >= 0; --i) { - builder.writeInt8(((_u = c_underscore === null || c_underscore === void 0 ? void 0 : c_underscore[i]) !== null && _u !== void 0 ? _u : 0)); - } - builder.writeInt8(b); - for (let i = 1; i >= 0; --i) { - builder.writeInt32(((_v = a === null || a === void 0 ? void 0 : a[i]) !== null && _v !== void 0 ? _v : 0)); - } - return builder.offset(); - } - unpack() { - return new NestedStructT(this.bb.createScalarList(this.a.bind(this), 2), this.b(), this.bb.createScalarList(this.cUnderscore.bind(this), 2), this.bb.createObjList(this.dOuter.bind(this), 5), this.bb.createScalarList(this.e.bind(this), 2)); - } - unpackTo(_o) { - _o.a = this.bb.createScalarList(this.a.bind(this), 2); - _o.b = this.b(); - _o.cUnderscore = this.bb.createScalarList(this.cUnderscore.bind(this), 2); - _o.dOuter = this.bb.createObjList(this.dOuter.bind(this), 5); - _o.e = this.bb.createScalarList(this.e.bind(this), 2); - } -} -export class NestedStructT { - constructor(a = [], b = TestEnum.A, cUnderscore = [TestEnum.A, TestEnum.A], dOuter = [], e = []) { - this.a = a; - this.b = b; - this.cUnderscore = cUnderscore; - this.dOuter = dOuter; - this.e = e; - } - pack(builder) { - return NestedStruct.createNestedStruct(builder, this.a, this.b, this.cUnderscore, this.dOuter, this.e); - } -} -export class ArrayStruct { - constructor() { - this.bb = null; - this.bb_pos = 0; - } - __init(i, bb) { - this.bb_pos = i; - this.bb = bb; - return this; - } - aUnderscore() { - return this.bb.readFloat32(this.bb_pos); - } - bUnderscore(index) { - return this.bb.readInt32(this.bb_pos + 4 + index * 4); - } - c() { - return this.bb.readInt8(this.bb_pos + 64); - } - d(index, obj) { - return (obj || new NestedStruct()).__init(this.bb_pos + 72 + index * 1072, this.bb); - } - e() { - return this.bb.readInt32(this.bb_pos + 2216); - } - f(index, obj) { - return (obj || new OuterStruct()).__init(this.bb_pos + 2224 + index * 208, this.bb); - } - g(index) { - return this.bb.readInt64(this.bb_pos + 2640 + index * 8); - } - static getFullyQualifiedName() { - return 'MyGame_Example_ArrayStruct'; - } - static sizeOf() { - return 2656; - } - static createArrayStruct(builder, a_underscore, b_underscore, c, d, e, f, g) { - var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _p, _q, _r, _s, _t, _u; - builder.prep(8, 2656); - for (let i = 1; i >= 0; --i) { - builder.writeInt64(BigInt((_a = g === null || g === void 0 ? void 0 : g[i]) !== null && _a !== void 0 ? _a : 0)); - } - for (let i = 1; i >= 0; --i) { - const item = f === null || f === void 0 ? void 0 : f[i]; - if (item instanceof OuterStructT) { - item.pack(builder); - continue; - } - OuterStruct.createOuterStruct(builder, item === null || item === void 0 ? void 0 : item.a, item === null || item === void 0 ? void 0 : item.b, ((_c = (_b = item === null || item === void 0 ? void 0 : item.cUnderscore) === null || _b === void 0 ? void 0 : _b.a) !== null && _c !== void 0 ? _c : 0), ((_e = (_d = item === null || item === void 0 ? void 0 : item.cUnderscore) === null || _d === void 0 ? void 0 : _d.b) !== null && _e !== void 0 ? _e : []), ((_g = (_f = item === null || item === void 0 ? void 0 : item.cUnderscore) === null || _f === void 0 ? void 0 : _f.c) !== null && _g !== void 0 ? _g : 0), ((_j = (_h = item === null || item === void 0 ? void 0 : item.cUnderscore) === null || _h === void 0 ? void 0 : _h.dUnderscore) !== null && _j !== void 0 ? _j : BigInt(0)), item === null || item === void 0 ? void 0 : item.d, ((_l = (_k = item === null || item === void 0 ? void 0 : item.e) === null || _k === void 0 ? void 0 : _k.a) !== null && _l !== void 0 ? _l : 0), ((_p = (_m = item === null || item === void 0 ? void 0 : item.e) === null || _m === void 0 ? void 0 : _m.b) !== null && _p !== void 0 ? _p : []), ((_r = (_q = item === null || item === void 0 ? void 0 : item.e) === null || _q === void 0 ? void 0 : _q.c) !== null && _r !== void 0 ? _r : 0), ((_t = (_s = item === null || item === void 0 ? void 0 : item.e) === null || _s === void 0 ? void 0 : _s.dUnderscore) !== null && _t !== void 0 ? _t : BigInt(0)), item === null || item === void 0 ? void 0 : item.f); - } - builder.pad(4); - builder.writeInt32(e); - for (let i = 1; i >= 0; --i) { - const item = d === null || d === void 0 ? void 0 : d[i]; - if (item instanceof NestedStructT) { - item.pack(builder); - continue; - } - NestedStruct.createNestedStruct(builder, item === null || item === void 0 ? void 0 : item.a, item === null || item === void 0 ? void 0 : item.b, item === null || item === void 0 ? void 0 : item.cUnderscore, item === null || item === void 0 ? void 0 : item.dOuter, item === null || item === void 0 ? void 0 : item.e); - } - builder.pad(7); - builder.writeInt8(c); - for (let i = 14; i >= 0; --i) { - builder.writeInt32(((_u = b_underscore === null || b_underscore === void 0 ? void 0 : b_underscore[i]) !== null && _u !== void 0 ? _u : 0)); - } - builder.writeFloat32(a_underscore); - return builder.offset(); - } - unpack() { - return new ArrayStructT(this.aUnderscore(), this.bb.createScalarList(this.bUnderscore.bind(this), 15), this.c(), this.bb.createObjList(this.d.bind(this), 2), this.e(), this.bb.createObjList(this.f.bind(this), 2), this.bb.createScalarList(this.g.bind(this), 2)); - } - unpackTo(_o) { - _o.aUnderscore = this.aUnderscore(); - _o.bUnderscore = this.bb.createScalarList(this.bUnderscore.bind(this), 15); - _o.c = this.c(); - _o.d = this.bb.createObjList(this.d.bind(this), 2); - _o.e = this.e(); - _o.f = this.bb.createObjList(this.f.bind(this), 2); - _o.g = this.bb.createScalarList(this.g.bind(this), 2); - } -} -export class ArrayStructT { - constructor(aUnderscore = 0.0, bUnderscore = [], c = 0, d = [], e = 0, f = [], g = []) { - this.aUnderscore = aUnderscore; - this.bUnderscore = bUnderscore; - this.c = c; - this.d = d; - this.e = e; - this.f = f; - this.g = g; - } - pack(builder) { - return ArrayStruct.createArrayStruct(builder, this.aUnderscore, this.bUnderscore, this.c, this.d, this.e, this.f, this.g); - } -} -export class ArrayTable { - constructor() { - this.bb = null; - this.bb_pos = 0; - } - __init(i, bb) { - this.bb_pos = i; - this.bb = bb; - return this; - } - static getRootAsArrayTable(bb, obj) { - return (obj || new ArrayTable()).__init(bb.readInt32(bb.position()) + bb.position(), bb); - } - static getSizePrefixedRootAsArrayTable(bb, obj) { - bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); - return (obj || new ArrayTable()).__init(bb.readInt32(bb.position()) + bb.position(), bb); - } - static bufferHasIdentifier(bb) { - return bb.__has_identifier('RHUB'); - } - a(optionalEncoding) { - const offset = this.bb.__offset(this.bb_pos, 4); - return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null; - } - cUnderscore(obj) { - const offset = this.bb.__offset(this.bb_pos, 6); - return offset ? (obj || new ArrayStruct()).__init(this.bb_pos + offset, this.bb) : null; - } - static getFullyQualifiedName() { - return 'MyGame_Example_ArrayTable'; - } - static startArrayTable(builder) { - builder.startObject(2); - } - static addA(builder, aOffset) { - builder.addFieldOffset(0, aOffset, 0); - } - static addCUnderscore(builder, cUnderscoreOffset) { - builder.addFieldStruct(1, cUnderscoreOffset, 0); - } - static endArrayTable(builder) { - const offset = builder.endObject(); - return offset; - } - static finishArrayTableBuffer(builder, offset) { - builder.finish(offset, 'RHUB'); - } - static finishSizePrefixedArrayTableBuffer(builder, offset) { - builder.finish(offset, 'RHUB', true); - } - unpack() { - return new ArrayTableT(this.a(), (this.cUnderscore() !== null ? this.cUnderscore().unpack() : null)); - } - unpackTo(_o) { - _o.a = this.a(); - _o.cUnderscore = (this.cUnderscore() !== null ? this.cUnderscore().unpack() : null); - } -} -export class ArrayTableT { - constructor(a = null, cUnderscore = null) { - this.a = a; - this.cUnderscore = cUnderscore; - } - pack(builder) { - const a = (this.a !== null ? builder.createString(this.a) : 0); - ArrayTable.startArrayTable(builder); - ArrayTable.addA(builder, a); - ArrayTable.addCUnderscore(builder, (this.cUnderscore !== null ? this.cUnderscore.pack(builder) : 0)); - return ArrayTable.endArrayTable(builder); - } -} +"use strict"; +var __create = Object.create; +var __defProp = Object.defineProperty; +var __getOwnPropDesc = Object.getOwnPropertyDescriptor; +var __getOwnPropNames = Object.getOwnPropertyNames; +var __getProtoOf = Object.getPrototypeOf; +var __hasOwnProp = Object.prototype.hasOwnProperty; +var __export = (target, all) => { + for (var name in all) + __defProp(target, name, { get: all[name], enumerable: true }); +}; +var __copyProps = (to, from, except, desc) => { + if (from && typeof from === "object" || typeof from === "function") { + for (let key of __getOwnPropNames(from)) + if (!__hasOwnProp.call(to, key) && key !== except) + __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); + } + return to; +}; +var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( + isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, + mod +)); +var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); + +// arrays_test_complex/my-game/example.ts +var example_exports = {}; +__export(example_exports, { + ArrayStruct: () => ArrayStruct, + ArrayTable: () => ArrayTable, + InnerStruct: () => InnerStruct, + NestedStruct: () => NestedStruct, + OuterStruct: () => OuterStruct, + TestEnum: () => TestEnum +}); +module.exports = __toCommonJS(example_exports); + +// arrays_test_complex/my-game/example/inner-struct.js +var InnerStruct = class { + constructor() { + this.bb = null; + this.bb_pos = 0; + } + __init(i, bb) { + this.bb_pos = i; + this.bb = bb; + return this; + } + a() { + return this.bb.readFloat64(this.bb_pos); + } + b(index) { + return this.bb.readUint8(this.bb_pos + 8 + index); + } + c() { + return this.bb.readInt8(this.bb_pos + 21); + } + dUnderscore() { + return this.bb.readInt64(this.bb_pos + 24); + } + static getFullyQualifiedName() { + return "MyGame_Example_InnerStruct"; + } + static sizeOf() { + return 32; + } + static createInnerStruct(builder, a, b, c, d_underscore) { + builder.prep(8, 32); + builder.writeInt64(BigInt(d_underscore ?? 0)); + builder.pad(2); + builder.writeInt8(c); + for (let i = 12; i >= 0; --i) { + builder.writeInt8(b?.[i] ?? 0); + } + builder.writeFloat64(a); + return builder.offset(); + } + unpack() { + return new InnerStructT(this.a(), this.bb.createScalarList(this.b.bind(this), 13), this.c(), this.dUnderscore()); + } + unpackTo(_o) { + _o.a = this.a(); + _o.b = this.bb.createScalarList(this.b.bind(this), 13); + _o.c = this.c(); + _o.dUnderscore = this.dUnderscore(); + } +}; +var InnerStructT = class { + constructor(a = 0, b = [], c = 0, dUnderscore = BigInt("0")) { + this.a = a; + this.b = b; + this.c = c; + this.dUnderscore = dUnderscore; + } + pack(builder) { + return InnerStruct.createInnerStruct(builder, this.a, this.b, this.c, this.dUnderscore); + } +}; + +// arrays_test_complex/my-game/example/outer-struct.js +var OuterStruct = class { + constructor() { + this.bb = null; + this.bb_pos = 0; + } + __init(i, bb) { + this.bb_pos = i; + this.bb = bb; + return this; + } + a() { + return !!this.bb.readInt8(this.bb_pos); + } + b() { + return this.bb.readFloat64(this.bb_pos + 8); + } + cUnderscore(obj) { + return (obj || new InnerStruct()).__init(this.bb_pos + 16, this.bb); + } + d(index, obj) { + return (obj || new InnerStruct()).__init(this.bb_pos + 48 + index * 32, this.bb); + } + e(obj) { + return (obj || new InnerStruct()).__init(this.bb_pos + 144, this.bb); + } + f(index) { + return this.bb.readFloat64(this.bb_pos + 176 + index * 8); + } + static getFullyQualifiedName() { + return "MyGame_Example_OuterStruct"; + } + static sizeOf() { + return 208; + } + static createOuterStruct(builder, a, b, c_underscore_a, c_underscore_b, c_underscore_c, c_underscore_d_underscore, d, e_a, e_b, e_c, e_d_underscore, f) { + builder.prep(8, 208); + for (let i = 3; i >= 0; --i) { + builder.writeFloat64(f?.[i] ?? 0); + } + builder.prep(8, 32); + builder.writeInt64(BigInt(e_d_underscore ?? 0)); + builder.pad(2); + builder.writeInt8(e_c); + for (let i = 12; i >= 0; --i) { + builder.writeInt8(e_b?.[i] ?? 0); + } + builder.writeFloat64(e_a); + for (let i = 2; i >= 0; --i) { + const item = d?.[i]; + if (item instanceof InnerStructT) { + item.pack(builder); + continue; + } + InnerStruct.createInnerStruct(builder, item?.a, item?.b, item?.c, item?.dUnderscore); + } + builder.prep(8, 32); + builder.writeInt64(BigInt(c_underscore_d_underscore ?? 0)); + builder.pad(2); + builder.writeInt8(c_underscore_c); + for (let i = 12; i >= 0; --i) { + builder.writeInt8(c_underscore_b?.[i] ?? 0); + } + builder.writeFloat64(c_underscore_a); + builder.writeFloat64(b); + builder.pad(7); + builder.writeInt8(Number(Boolean(a))); + return builder.offset(); + } + unpack() { + return new OuterStructT(this.a(), this.b(), this.cUnderscore() !== null ? this.cUnderscore().unpack() : null, this.bb.createObjList(this.d.bind(this), 3), this.e() !== null ? this.e().unpack() : null, this.bb.createScalarList(this.f.bind(this), 4)); + } + unpackTo(_o) { + _o.a = this.a(); + _o.b = this.b(); + _o.cUnderscore = this.cUnderscore() !== null ? this.cUnderscore().unpack() : null; + _o.d = this.bb.createObjList(this.d.bind(this), 3); + _o.e = this.e() !== null ? this.e().unpack() : null; + _o.f = this.bb.createScalarList(this.f.bind(this), 4); + } +}; +var OuterStructT = class { + constructor(a = false, b = 0, cUnderscore = null, d = [], e = null, f = []) { + this.a = a; + this.b = b; + this.cUnderscore = cUnderscore; + this.d = d; + this.e = e; + this.f = f; + } + pack(builder) { + return OuterStruct.createOuterStruct(builder, this.a, this.b, this.cUnderscore?.a ?? 0, this.cUnderscore?.b ?? [], this.cUnderscore?.c ?? 0, this.cUnderscore?.dUnderscore ?? BigInt(0), this.d, this.e?.a ?? 0, this.e?.b ?? [], this.e?.c ?? 0, this.e?.dUnderscore ?? BigInt(0), this.f); + } +}; + +// arrays_test_complex/my-game/example/test-enum.js +var TestEnum; +(function(TestEnum2) { + TestEnum2[TestEnum2["A"] = 0] = "A"; + TestEnum2[TestEnum2["B"] = 1] = "B"; + TestEnum2[TestEnum2["C"] = 2] = "C"; +})(TestEnum = TestEnum || (TestEnum = {})); + +// arrays_test_complex/my-game/example/nested-struct.js +var NestedStruct = class { + constructor() { + this.bb = null; + this.bb_pos = 0; + } + __init(i, bb) { + this.bb_pos = i; + this.bb = bb; + return this; + } + a(index) { + return this.bb.readInt32(this.bb_pos + 0 + index * 4); + } + b() { + return this.bb.readInt8(this.bb_pos + 8); + } + cUnderscore(index) { + return this.bb.readInt8(this.bb_pos + 9 + index); + } + dOuter(index, obj) { + return (obj || new OuterStruct()).__init(this.bb_pos + 16 + index * 208, this.bb); + } + e(index) { + return this.bb.readInt64(this.bb_pos + 1056 + index * 8); + } + static getFullyQualifiedName() { + return "MyGame_Example_NestedStruct"; + } + static sizeOf() { + return 1072; + } + static createNestedStruct(builder, a, b, c_underscore, d_outer, e) { + builder.prep(8, 1072); + for (let i = 1; i >= 0; --i) { + builder.writeInt64(BigInt(e?.[i] ?? 0)); + } + for (let i = 4; i >= 0; --i) { + const item = d_outer?.[i]; + if (item instanceof OuterStructT) { + item.pack(builder); + continue; + } + OuterStruct.createOuterStruct(builder, item?.a, item?.b, item?.cUnderscore?.a ?? 0, item?.cUnderscore?.b ?? [], item?.cUnderscore?.c ?? 0, item?.cUnderscore?.dUnderscore ?? BigInt(0), item?.d, item?.e?.a ?? 0, item?.e?.b ?? [], item?.e?.c ?? 0, item?.e?.dUnderscore ?? BigInt(0), item?.f); + } + builder.pad(5); + for (let i = 1; i >= 0; --i) { + builder.writeInt8(c_underscore?.[i] ?? 0); + } + builder.writeInt8(b); + for (let i = 1; i >= 0; --i) { + builder.writeInt32(a?.[i] ?? 0); + } + return builder.offset(); + } + unpack() { + return new NestedStructT(this.bb.createScalarList(this.a.bind(this), 2), this.b(), this.bb.createScalarList(this.cUnderscore.bind(this), 2), this.bb.createObjList(this.dOuter.bind(this), 5), this.bb.createScalarList(this.e.bind(this), 2)); + } + unpackTo(_o) { + _o.a = this.bb.createScalarList(this.a.bind(this), 2); + _o.b = this.b(); + _o.cUnderscore = this.bb.createScalarList(this.cUnderscore.bind(this), 2); + _o.dOuter = this.bb.createObjList(this.dOuter.bind(this), 5); + _o.e = this.bb.createScalarList(this.e.bind(this), 2); + } +}; +var NestedStructT = class { + constructor(a = [], b = TestEnum.A, cUnderscore = [TestEnum.A, TestEnum.A], dOuter = [], e = []) { + this.a = a; + this.b = b; + this.cUnderscore = cUnderscore; + this.dOuter = dOuter; + this.e = e; + } + pack(builder) { + return NestedStruct.createNestedStruct(builder, this.a, this.b, this.cUnderscore, this.dOuter, this.e); + } +}; + +// arrays_test_complex/my-game/example/array-struct.js +var ArrayStruct = class { + constructor() { + this.bb = null; + this.bb_pos = 0; + } + __init(i, bb) { + this.bb_pos = i; + this.bb = bb; + return this; + } + aUnderscore() { + return this.bb.readFloat32(this.bb_pos); + } + bUnderscore(index) { + return this.bb.readInt32(this.bb_pos + 4 + index * 4); + } + c() { + return this.bb.readInt8(this.bb_pos + 64); + } + d(index, obj) { + return (obj || new NestedStruct()).__init(this.bb_pos + 72 + index * 1072, this.bb); + } + e() { + return this.bb.readInt32(this.bb_pos + 2216); + } + f(index, obj) { + return (obj || new OuterStruct()).__init(this.bb_pos + 2224 + index * 208, this.bb); + } + g(index) { + return this.bb.readInt64(this.bb_pos + 2640 + index * 8); + } + static getFullyQualifiedName() { + return "MyGame_Example_ArrayStruct"; + } + static sizeOf() { + return 2656; + } + static createArrayStruct(builder, a_underscore, b_underscore, c, d, e, f, g) { + builder.prep(8, 2656); + for (let i = 1; i >= 0; --i) { + builder.writeInt64(BigInt(g?.[i] ?? 0)); + } + for (let i = 1; i >= 0; --i) { + const item = f?.[i]; + if (item instanceof OuterStructT) { + item.pack(builder); + continue; + } + OuterStruct.createOuterStruct(builder, item?.a, item?.b, item?.cUnderscore?.a ?? 0, item?.cUnderscore?.b ?? [], item?.cUnderscore?.c ?? 0, item?.cUnderscore?.dUnderscore ?? BigInt(0), item?.d, item?.e?.a ?? 0, item?.e?.b ?? [], item?.e?.c ?? 0, item?.e?.dUnderscore ?? BigInt(0), item?.f); + } + builder.pad(4); + builder.writeInt32(e); + for (let i = 1; i >= 0; --i) { + const item = d?.[i]; + if (item instanceof NestedStructT) { + item.pack(builder); + continue; + } + NestedStruct.createNestedStruct(builder, item?.a, item?.b, item?.cUnderscore, item?.dOuter, item?.e); + } + builder.pad(7); + builder.writeInt8(c); + for (let i = 14; i >= 0; --i) { + builder.writeInt32(b_underscore?.[i] ?? 0); + } + builder.writeFloat32(a_underscore); + return builder.offset(); + } + unpack() { + return new ArrayStructT(this.aUnderscore(), this.bb.createScalarList(this.bUnderscore.bind(this), 15), this.c(), this.bb.createObjList(this.d.bind(this), 2), this.e(), this.bb.createObjList(this.f.bind(this), 2), this.bb.createScalarList(this.g.bind(this), 2)); + } + unpackTo(_o) { + _o.aUnderscore = this.aUnderscore(); + _o.bUnderscore = this.bb.createScalarList(this.bUnderscore.bind(this), 15); + _o.c = this.c(); + _o.d = this.bb.createObjList(this.d.bind(this), 2); + _o.e = this.e(); + _o.f = this.bb.createObjList(this.f.bind(this), 2); + _o.g = this.bb.createScalarList(this.g.bind(this), 2); + } +}; +var ArrayStructT = class { + constructor(aUnderscore = 0, bUnderscore = [], c = 0, d = [], e = 0, f = [], g = []) { + this.aUnderscore = aUnderscore; + this.bUnderscore = bUnderscore; + this.c = c; + this.d = d; + this.e = e; + this.f = f; + this.g = g; + } + pack(builder) { + return ArrayStruct.createArrayStruct(builder, this.aUnderscore, this.bUnderscore, this.c, this.d, this.e, this.f, this.g); + } +}; + +// arrays_test_complex/my-game/example/array-table.js +var flatbuffers = __toESM(require("flatbuffers"), 1); +var ArrayTable = class { + constructor() { + this.bb = null; + this.bb_pos = 0; + } + __init(i, bb) { + this.bb_pos = i; + this.bb = bb; + return this; + } + static getRootAsArrayTable(bb, obj) { + return (obj || new ArrayTable()).__init(bb.readInt32(bb.position()) + bb.position(), bb); + } + static getSizePrefixedRootAsArrayTable(bb, obj) { + bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); + return (obj || new ArrayTable()).__init(bb.readInt32(bb.position()) + bb.position(), bb); + } + static bufferHasIdentifier(bb) { + return bb.__has_identifier("RHUB"); + } + a(optionalEncoding) { + const offset = this.bb.__offset(this.bb_pos, 4); + return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null; + } + cUnderscore(obj) { + const offset = this.bb.__offset(this.bb_pos, 6); + return offset ? (obj || new ArrayStruct()).__init(this.bb_pos + offset, this.bb) : null; + } + static getFullyQualifiedName() { + return "MyGame_Example_ArrayTable"; + } + static startArrayTable(builder) { + builder.startObject(2); + } + static addA(builder, aOffset) { + builder.addFieldOffset(0, aOffset, 0); + } + static addCUnderscore(builder, cUnderscoreOffset) { + builder.addFieldStruct(1, cUnderscoreOffset, 0); + } + static endArrayTable(builder) { + const offset = builder.endObject(); + return offset; + } + static finishArrayTableBuffer(builder, offset) { + builder.finish(offset, "RHUB"); + } + static finishSizePrefixedArrayTableBuffer(builder, offset) { + builder.finish(offset, "RHUB", true); + } + unpack() { + return new ArrayTableT(this.a(), this.cUnderscore() !== null ? this.cUnderscore().unpack() : null); + } + unpackTo(_o) { + _o.a = this.a(); + _o.cUnderscore = this.cUnderscore() !== null ? this.cUnderscore().unpack() : null; + } +}; +var ArrayTableT = class { + constructor(a = null, cUnderscore = null) { + this.a = a; + this.cUnderscore = cUnderscore; + } + pack(builder) { + const a = this.a !== null ? builder.createString(this.a) : 0; + ArrayTable.startArrayTable(builder); + ArrayTable.addA(builder, a); + ArrayTable.addCUnderscore(builder, this.cUnderscore !== null ? this.cUnderscore.pack(builder) : 0); + return ArrayTable.endArrayTable(builder); + } +}; diff --git a/tests/ts/arrays_test_complex/arrays_test_complex_generated.ts b/tests/ts/arrays_test_complex/arrays_test_complex_generated.ts deleted file mode 100644 index eea0ed996d2..00000000000 --- a/tests/ts/arrays_test_complex/arrays_test_complex_generated.ts +++ /dev/null @@ -1,626 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -import * as flatbuffers from 'flatbuffers'; - - -export enum TestEnum { - A = 0, - B = 1, - C = 2 -} - -export class InnerStruct implements flatbuffers.IUnpackableObject { - bb: flatbuffers.ByteBuffer|null = null; - bb_pos = 0; - __init(i:number, bb:flatbuffers.ByteBuffer):InnerStruct { - this.bb_pos = i; - this.bb = bb; - return this; -} - -a():number { - return this.bb!.readFloat64(this.bb_pos); -} - -b(index: number):number|null { - return this.bb!.readUint8(this.bb_pos + 8 + index); -} - -c():number { - return this.bb!.readInt8(this.bb_pos + 21); -} - -dUnderscore():bigint { - return this.bb!.readInt64(this.bb_pos + 24); -} - -static getFullyQualifiedName():string { - return 'MyGame_Example_InnerStruct'; -} - -static sizeOf():number { - return 32; -} - -static createInnerStruct(builder:flatbuffers.Builder, a: number, b: number[]|null, c: number, d_underscore: bigint):flatbuffers.Offset { - builder.prep(8, 32); - builder.writeInt64(BigInt(d_underscore ?? 0)); - builder.pad(2); - builder.writeInt8(c); - - for (let i = 12; i >= 0; --i) { - builder.writeInt8((b?.[i] ?? 0)); - - } - - builder.writeFloat64(a); - return builder.offset(); -} - - -unpack(): InnerStructT { - return new InnerStructT( - this.a(), - this.bb!.createScalarList(this.b.bind(this), 13), - this.c(), - this.dUnderscore() - ); -} - - -unpackTo(_o: InnerStructT): void { - _o.a = this.a(); - _o.b = this.bb!.createScalarList(this.b.bind(this), 13); - _o.c = this.c(); - _o.dUnderscore = this.dUnderscore(); -} -} - -export class InnerStructT implements flatbuffers.IGeneratedObject { -constructor( - public a: number = 0.0, - public b: (number)[] = [], - public c: number = 0, - public dUnderscore: bigint = BigInt('0') -){} - - -pack(builder:flatbuffers.Builder): flatbuffers.Offset { - return InnerStruct.createInnerStruct(builder, - this.a, - this.b, - this.c, - this.dUnderscore - ); -} -} - -export class OuterStruct implements flatbuffers.IUnpackableObject { - bb: flatbuffers.ByteBuffer|null = null; - bb_pos = 0; - __init(i:number, bb:flatbuffers.ByteBuffer):OuterStruct { - this.bb_pos = i; - this.bb = bb; - return this; -} - -a():boolean { - return !!this.bb!.readInt8(this.bb_pos); -} - -b():number { - return this.bb!.readFloat64(this.bb_pos + 8); -} - -cUnderscore(obj?:InnerStruct):InnerStruct|null { - return (obj || new InnerStruct()).__init(this.bb_pos + 16, this.bb!); -} - -d(index: number, obj?:InnerStruct):InnerStruct|null { - return (obj || new InnerStruct()).__init(this.bb_pos + 48 + index * 32, this.bb!); -} - -e(obj?:InnerStruct):InnerStruct|null { - return (obj || new InnerStruct()).__init(this.bb_pos + 144, this.bb!); -} - -f(index: number):number|null { - return this.bb!.readFloat64(this.bb_pos + 176 + index * 8); -} - -static getFullyQualifiedName():string { - return 'MyGame_Example_OuterStruct'; -} - -static sizeOf():number { - return 208; -} - -static createOuterStruct(builder:flatbuffers.Builder, a: boolean, b: number, c_underscore_a: number, c_underscore_b: number[]|null, c_underscore_c: number, c_underscore_d_underscore: bigint, d: (any|InnerStructT)[]|null, e_a: number, e_b: number[]|null, e_c: number, e_d_underscore: bigint, f: number[]|null):flatbuffers.Offset { - builder.prep(8, 208); - - for (let i = 3; i >= 0; --i) { - builder.writeFloat64((f?.[i] ?? 0)); - - } - - builder.prep(8, 32); - builder.writeInt64(BigInt(e_d_underscore ?? 0)); - builder.pad(2); - builder.writeInt8(e_c); - - for (let i = 12; i >= 0; --i) { - builder.writeInt8((e_b?.[i] ?? 0)); - - } - - builder.writeFloat64(e_a); - - for (let i = 2; i >= 0; --i) { - const item = d?.[i]; - - if (item instanceof InnerStructT) { - item.pack(builder); - continue; - } - - InnerStruct.createInnerStruct(builder, - item?.a, - item?.b, - item?.c, - item?.dUnderscore - ); - } - - builder.prep(8, 32); - builder.writeInt64(BigInt(c_underscore_d_underscore ?? 0)); - builder.pad(2); - builder.writeInt8(c_underscore_c); - - for (let i = 12; i >= 0; --i) { - builder.writeInt8((c_underscore_b?.[i] ?? 0)); - - } - - builder.writeFloat64(c_underscore_a); - builder.writeFloat64(b); - builder.pad(7); - builder.writeInt8(Number(Boolean(a))); - return builder.offset(); -} - - -unpack(): OuterStructT { - return new OuterStructT( - this.a(), - this.b(), - (this.cUnderscore() !== null ? this.cUnderscore()!.unpack() : null), - this.bb!.createObjList(this.d.bind(this), 3), - (this.e() !== null ? this.e()!.unpack() : null), - this.bb!.createScalarList(this.f.bind(this), 4) - ); -} - - -unpackTo(_o: OuterStructT): void { - _o.a = this.a(); - _o.b = this.b(); - _o.cUnderscore = (this.cUnderscore() !== null ? this.cUnderscore()!.unpack() : null); - _o.d = this.bb!.createObjList(this.d.bind(this), 3); - _o.e = (this.e() !== null ? this.e()!.unpack() : null); - _o.f = this.bb!.createScalarList(this.f.bind(this), 4); -} -} - -export class OuterStructT implements flatbuffers.IGeneratedObject { -constructor( - public a: boolean = false, - public b: number = 0.0, - public cUnderscore: InnerStructT|null = null, - public d: (InnerStructT)[] = [], - public e: InnerStructT|null = null, - public f: (number)[] = [] -){} - - -pack(builder:flatbuffers.Builder): flatbuffers.Offset { - return OuterStruct.createOuterStruct(builder, - this.a, - this.b, - (this.cUnderscore?.a ?? 0), - (this.cUnderscore?.b ?? []), - (this.cUnderscore?.c ?? 0), - (this.cUnderscore?.dUnderscore ?? BigInt(0)), - this.d, - (this.e?.a ?? 0), - (this.e?.b ?? []), - (this.e?.c ?? 0), - (this.e?.dUnderscore ?? BigInt(0)), - this.f - ); -} -} - -export class NestedStruct implements flatbuffers.IUnpackableObject { - bb: flatbuffers.ByteBuffer|null = null; - bb_pos = 0; - __init(i:number, bb:flatbuffers.ByteBuffer):NestedStruct { - this.bb_pos = i; - this.bb = bb; - return this; -} - -a(index: number):number|null { - return this.bb!.readInt32(this.bb_pos + 0 + index * 4); -} - -b():TestEnum { - return this.bb!.readInt8(this.bb_pos + 8); -} - -cUnderscore(index: number):TestEnum|null { - return this.bb!.readInt8(this.bb_pos + 9 + index); -} - -dOuter(index: number, obj?:OuterStruct):OuterStruct|null { - return (obj || new OuterStruct()).__init(this.bb_pos + 16 + index * 208, this.bb!); -} - -e(index: number):bigint|null { - return this.bb!.readInt64(this.bb_pos + 1056 + index * 8); -} - -static getFullyQualifiedName():string { - return 'MyGame_Example_NestedStruct'; -} - -static sizeOf():number { - return 1072; -} - -static createNestedStruct(builder:flatbuffers.Builder, a: number[]|null, b: TestEnum, c_underscore: number[]|null, d_outer: (any|OuterStructT)[]|null, e: bigint[]|null):flatbuffers.Offset { - builder.prep(8, 1072); - - for (let i = 1; i >= 0; --i) { - builder.writeInt64(BigInt(e?.[i] ?? 0)); - } - - - for (let i = 4; i >= 0; --i) { - const item = d_outer?.[i]; - - if (item instanceof OuterStructT) { - item.pack(builder); - continue; - } - - OuterStruct.createOuterStruct(builder, - item?.a, - item?.b, - (item?.cUnderscore?.a ?? 0), - (item?.cUnderscore?.b ?? []), - (item?.cUnderscore?.c ?? 0), - (item?.cUnderscore?.dUnderscore ?? BigInt(0)), - item?.d, - (item?.e?.a ?? 0), - (item?.e?.b ?? []), - (item?.e?.c ?? 0), - (item?.e?.dUnderscore ?? BigInt(0)), - item?.f - ); - } - - builder.pad(5); - - for (let i = 1; i >= 0; --i) { - builder.writeInt8((c_underscore?.[i] ?? 0)); - - } - - builder.writeInt8(b); - - for (let i = 1; i >= 0; --i) { - builder.writeInt32((a?.[i] ?? 0)); - - } - - return builder.offset(); -} - - -unpack(): NestedStructT { - return new NestedStructT( - this.bb!.createScalarList(this.a.bind(this), 2), - this.b(), - this.bb!.createScalarList(this.cUnderscore.bind(this), 2), - this.bb!.createObjList(this.dOuter.bind(this), 5), - this.bb!.createScalarList(this.e.bind(this), 2) - ); -} - - -unpackTo(_o: NestedStructT): void { - _o.a = this.bb!.createScalarList(this.a.bind(this), 2); - _o.b = this.b(); - _o.cUnderscore = this.bb!.createScalarList(this.cUnderscore.bind(this), 2); - _o.dOuter = this.bb!.createObjList(this.dOuter.bind(this), 5); - _o.e = this.bb!.createScalarList(this.e.bind(this), 2); -} -} - -export class NestedStructT implements flatbuffers.IGeneratedObject { -constructor( - public a: (number)[] = [], - public b: TestEnum = TestEnum.A, - public cUnderscore: (TestEnum)[] = [TestEnum.A, TestEnum.A], - public dOuter: (OuterStructT)[] = [], - public e: (bigint)[] = [] -){} - - -pack(builder:flatbuffers.Builder): flatbuffers.Offset { - return NestedStruct.createNestedStruct(builder, - this.a, - this.b, - this.cUnderscore, - this.dOuter, - this.e - ); -} -} - -export class ArrayStruct implements flatbuffers.IUnpackableObject { - bb: flatbuffers.ByteBuffer|null = null; - bb_pos = 0; - __init(i:number, bb:flatbuffers.ByteBuffer):ArrayStruct { - this.bb_pos = i; - this.bb = bb; - return this; -} - -aUnderscore():number { - return this.bb!.readFloat32(this.bb_pos); -} - -bUnderscore(index: number):number|null { - return this.bb!.readInt32(this.bb_pos + 4 + index * 4); -} - -c():number { - return this.bb!.readInt8(this.bb_pos + 64); -} - -d(index: number, obj?:NestedStruct):NestedStruct|null { - return (obj || new NestedStruct()).__init(this.bb_pos + 72 + index * 1072, this.bb!); -} - -e():number { - return this.bb!.readInt32(this.bb_pos + 2216); -} - -f(index: number, obj?:OuterStruct):OuterStruct|null { - return (obj || new OuterStruct()).__init(this.bb_pos + 2224 + index * 208, this.bb!); -} - -g(index: number):bigint|null { - return this.bb!.readInt64(this.bb_pos + 2640 + index * 8); -} - -static getFullyQualifiedName():string { - return 'MyGame_Example_ArrayStruct'; -} - -static sizeOf():number { - return 2656; -} - -static createArrayStruct(builder:flatbuffers.Builder, a_underscore: number, b_underscore: number[]|null, c: number, d: (any|NestedStructT)[]|null, e: number, f: (any|OuterStructT)[]|null, g: bigint[]|null):flatbuffers.Offset { - builder.prep(8, 2656); - - for (let i = 1; i >= 0; --i) { - builder.writeInt64(BigInt(g?.[i] ?? 0)); - } - - - for (let i = 1; i >= 0; --i) { - const item = f?.[i]; - - if (item instanceof OuterStructT) { - item.pack(builder); - continue; - } - - OuterStruct.createOuterStruct(builder, - item?.a, - item?.b, - (item?.cUnderscore?.a ?? 0), - (item?.cUnderscore?.b ?? []), - (item?.cUnderscore?.c ?? 0), - (item?.cUnderscore?.dUnderscore ?? BigInt(0)), - item?.d, - (item?.e?.a ?? 0), - (item?.e?.b ?? []), - (item?.e?.c ?? 0), - (item?.e?.dUnderscore ?? BigInt(0)), - item?.f - ); - } - - builder.pad(4); - builder.writeInt32(e); - - for (let i = 1; i >= 0; --i) { - const item = d?.[i]; - - if (item instanceof NestedStructT) { - item.pack(builder); - continue; - } - - NestedStruct.createNestedStruct(builder, - item?.a, - item?.b, - item?.cUnderscore, - item?.dOuter, - item?.e - ); - } - - builder.pad(7); - builder.writeInt8(c); - - for (let i = 14; i >= 0; --i) { - builder.writeInt32((b_underscore?.[i] ?? 0)); - - } - - builder.writeFloat32(a_underscore); - return builder.offset(); -} - - -unpack(): ArrayStructT { - return new ArrayStructT( - this.aUnderscore(), - this.bb!.createScalarList(this.bUnderscore.bind(this), 15), - this.c(), - this.bb!.createObjList(this.d.bind(this), 2), - this.e(), - this.bb!.createObjList(this.f.bind(this), 2), - this.bb!.createScalarList(this.g.bind(this), 2) - ); -} - - -unpackTo(_o: ArrayStructT): void { - _o.aUnderscore = this.aUnderscore(); - _o.bUnderscore = this.bb!.createScalarList(this.bUnderscore.bind(this), 15); - _o.c = this.c(); - _o.d = this.bb!.createObjList(this.d.bind(this), 2); - _o.e = this.e(); - _o.f = this.bb!.createObjList(this.f.bind(this), 2); - _o.g = this.bb!.createScalarList(this.g.bind(this), 2); -} -} - -export class ArrayStructT implements flatbuffers.IGeneratedObject { -constructor( - public aUnderscore: number = 0.0, - public bUnderscore: (number)[] = [], - public c: number = 0, - public d: (NestedStructT)[] = [], - public e: number = 0, - public f: (OuterStructT)[] = [], - public g: (bigint)[] = [] -){} - - -pack(builder:flatbuffers.Builder): flatbuffers.Offset { - return ArrayStruct.createArrayStruct(builder, - this.aUnderscore, - this.bUnderscore, - this.c, - this.d, - this.e, - this.f, - this.g - ); -} -} - -export class ArrayTable implements flatbuffers.IUnpackableObject { - bb: flatbuffers.ByteBuffer|null = null; - bb_pos = 0; - __init(i:number, bb:flatbuffers.ByteBuffer):ArrayTable { - this.bb_pos = i; - this.bb = bb; - return this; -} - -static getRootAsArrayTable(bb:flatbuffers.ByteBuffer, obj?:ArrayTable):ArrayTable { - return (obj || new ArrayTable()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -} - -static getSizePrefixedRootAsArrayTable(bb:flatbuffers.ByteBuffer, obj?:ArrayTable):ArrayTable { - bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); - return (obj || new ArrayTable()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -} - -static bufferHasIdentifier(bb:flatbuffers.ByteBuffer):boolean { - return bb.__has_identifier('RHUB'); -} - -a():string|null -a(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null -a(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; -} - -cUnderscore(obj?:ArrayStruct):ArrayStruct|null { - const offset = this.bb!.__offset(this.bb_pos, 6); - return offset ? (obj || new ArrayStruct()).__init(this.bb_pos + offset, this.bb!) : null; -} - -static getFullyQualifiedName():string { - return 'MyGame_Example_ArrayTable'; -} - -static startArrayTable(builder:flatbuffers.Builder) { - builder.startObject(2); -} - -static addA(builder:flatbuffers.Builder, aOffset:flatbuffers.Offset) { - builder.addFieldOffset(0, aOffset, 0); -} - -static addCUnderscore(builder:flatbuffers.Builder, cUnderscoreOffset:flatbuffers.Offset) { - builder.addFieldStruct(1, cUnderscoreOffset, 0); -} - -static endArrayTable(builder:flatbuffers.Builder):flatbuffers.Offset { - const offset = builder.endObject(); - return offset; -} - -static finishArrayTableBuffer(builder:flatbuffers.Builder, offset:flatbuffers.Offset) { - builder.finish(offset, 'RHUB'); -} - -static finishSizePrefixedArrayTableBuffer(builder:flatbuffers.Builder, offset:flatbuffers.Offset) { - builder.finish(offset, 'RHUB', true); -} - - -unpack(): ArrayTableT { - return new ArrayTableT( - this.a(), - (this.cUnderscore() !== null ? this.cUnderscore()!.unpack() : null) - ); -} - - -unpackTo(_o: ArrayTableT): void { - _o.a = this.a(); - _o.cUnderscore = (this.cUnderscore() !== null ? this.cUnderscore()!.unpack() : null); -} -} - -export class ArrayTableT implements flatbuffers.IGeneratedObject { -constructor( - public a: string|Uint8Array|null = null, - public cUnderscore: ArrayStructT|null = null -){} - - -pack(builder:flatbuffers.Builder): flatbuffers.Offset { - const a = (this.a !== null ? builder.createString(this.a!) : 0); - - ArrayTable.startArrayTable(builder); - ArrayTable.addA(builder, a); - ArrayTable.addCUnderscore(builder, (this.cUnderscore !== null ? this.cUnderscore!.pack(builder) : 0)); - - return ArrayTable.endArrayTable(builder); -} -} - diff --git a/tests/ts/arrays_test_complex/my-game/example.js b/tests/ts/arrays_test_complex/my-game/example.js new file mode 100644 index 00000000000..bc149dab9c9 --- /dev/null +++ b/tests/ts/arrays_test_complex/my-game/example.js @@ -0,0 +1,7 @@ +// automatically generated by the FlatBuffers compiler, do not modify +export { ArrayStruct } from './example/array-struct.js'; +export { ArrayTable } from './example/array-table.js'; +export { InnerStruct } from './example/inner-struct.js'; +export { NestedStruct } from './example/nested-struct.js'; +export { OuterStruct } from './example/outer-struct.js'; +export { TestEnum } from './example/test-enum.js'; diff --git a/tests/ts/arrays_test_complex/my-game/example.ts b/tests/ts/arrays_test_complex/my-game/example.ts new file mode 100644 index 00000000000..9643b93b1ba --- /dev/null +++ b/tests/ts/arrays_test_complex/my-game/example.ts @@ -0,0 +1,8 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +export { ArrayStruct } from './example/array-struct.js'; +export { ArrayTable } from './example/array-table.js'; +export { InnerStruct } from './example/inner-struct.js'; +export { NestedStruct } from './example/nested-struct.js'; +export { OuterStruct } from './example/outer-struct.js'; +export { TestEnum } from './example/test-enum.js'; diff --git a/tests/ts/arrays_test_complex/my-game/example/array-struct.js b/tests/ts/arrays_test_complex/my-game/example/array-struct.js new file mode 100644 index 00000000000..e445b3ca675 --- /dev/null +++ b/tests/ts/arrays_test_complex/my-game/example/array-struct.js @@ -0,0 +1,98 @@ +// automatically generated by the FlatBuffers compiler, do not modify +import { NestedStruct, NestedStructT } from '../../my-game/example/nested-struct.js'; +import { OuterStruct, OuterStructT } from '../../my-game/example/outer-struct.js'; +export class ArrayStruct { + constructor() { + this.bb = null; + this.bb_pos = 0; + } + __init(i, bb) { + this.bb_pos = i; + this.bb = bb; + return this; + } + aUnderscore() { + return this.bb.readFloat32(this.bb_pos); + } + bUnderscore(index) { + return this.bb.readInt32(this.bb_pos + 4 + index * 4); + } + c() { + return this.bb.readInt8(this.bb_pos + 64); + } + d(index, obj) { + return (obj || new NestedStruct()).__init(this.bb_pos + 72 + index * 1072, this.bb); + } + e() { + return this.bb.readInt32(this.bb_pos + 2216); + } + f(index, obj) { + return (obj || new OuterStruct()).__init(this.bb_pos + 2224 + index * 208, this.bb); + } + g(index) { + return this.bb.readInt64(this.bb_pos + 2640 + index * 8); + } + static getFullyQualifiedName() { + return 'MyGame_Example_ArrayStruct'; + } + static sizeOf() { + return 2656; + } + static createArrayStruct(builder, a_underscore, b_underscore, c, d, e, f, g) { + builder.prep(8, 2656); + for (let i = 1; i >= 0; --i) { + builder.writeInt64(BigInt(g?.[i] ?? 0)); + } + for (let i = 1; i >= 0; --i) { + const item = f?.[i]; + if (item instanceof OuterStructT) { + item.pack(builder); + continue; + } + OuterStruct.createOuterStruct(builder, item?.a, item?.b, (item?.cUnderscore?.a ?? 0), (item?.cUnderscore?.b ?? []), (item?.cUnderscore?.c ?? 0), (item?.cUnderscore?.dUnderscore ?? BigInt(0)), item?.d, (item?.e?.a ?? 0), (item?.e?.b ?? []), (item?.e?.c ?? 0), (item?.e?.dUnderscore ?? BigInt(0)), item?.f); + } + builder.pad(4); + builder.writeInt32(e); + for (let i = 1; i >= 0; --i) { + const item = d?.[i]; + if (item instanceof NestedStructT) { + item.pack(builder); + continue; + } + NestedStruct.createNestedStruct(builder, item?.a, item?.b, item?.cUnderscore, item?.dOuter, item?.e); + } + builder.pad(7); + builder.writeInt8(c); + for (let i = 14; i >= 0; --i) { + builder.writeInt32((b_underscore?.[i] ?? 0)); + } + builder.writeFloat32(a_underscore); + return builder.offset(); + } + unpack() { + return new ArrayStructT(this.aUnderscore(), this.bb.createScalarList(this.bUnderscore.bind(this), 15), this.c(), this.bb.createObjList(this.d.bind(this), 2), this.e(), this.bb.createObjList(this.f.bind(this), 2), this.bb.createScalarList(this.g.bind(this), 2)); + } + unpackTo(_o) { + _o.aUnderscore = this.aUnderscore(); + _o.bUnderscore = this.bb.createScalarList(this.bUnderscore.bind(this), 15); + _o.c = this.c(); + _o.d = this.bb.createObjList(this.d.bind(this), 2); + _o.e = this.e(); + _o.f = this.bb.createObjList(this.f.bind(this), 2); + _o.g = this.bb.createScalarList(this.g.bind(this), 2); + } +} +export class ArrayStructT { + constructor(aUnderscore = 0.0, bUnderscore = [], c = 0, d = [], e = 0, f = [], g = []) { + this.aUnderscore = aUnderscore; + this.bUnderscore = bUnderscore; + this.c = c; + this.d = d; + this.e = e; + this.f = f; + this.g = g; + } + pack(builder) { + return ArrayStruct.createArrayStruct(builder, this.aUnderscore, this.bUnderscore, this.c, this.d, this.e, this.f, this.g); + } +} diff --git a/tests/ts/arrays_test_complex/my-game/example/array-struct.ts b/tests/ts/arrays_test_complex/my-game/example/array-struct.ts new file mode 100644 index 00000000000..7b614877c3a --- /dev/null +++ b/tests/ts/arrays_test_complex/my-game/example/array-struct.ts @@ -0,0 +1,166 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +import * as flatbuffers from 'flatbuffers'; + +import { NestedStruct, NestedStructT } from '../../my-game/example/nested-struct.js'; +import { OuterStruct, OuterStructT } from '../../my-game/example/outer-struct.js'; + + +export class ArrayStruct implements flatbuffers.IUnpackableObject { + bb: flatbuffers.ByteBuffer|null = null; + bb_pos = 0; + __init(i:number, bb:flatbuffers.ByteBuffer):ArrayStruct { + this.bb_pos = i; + this.bb = bb; + return this; +} + +aUnderscore():number { + return this.bb!.readFloat32(this.bb_pos); +} + +bUnderscore(index: number):number|null { + return this.bb!.readInt32(this.bb_pos + 4 + index * 4); +} + +c():number { + return this.bb!.readInt8(this.bb_pos + 64); +} + +d(index: number, obj?:NestedStruct):NestedStruct|null { + return (obj || new NestedStruct()).__init(this.bb_pos + 72 + index * 1072, this.bb!); +} + +e():number { + return this.bb!.readInt32(this.bb_pos + 2216); +} + +f(index: number, obj?:OuterStruct):OuterStruct|null { + return (obj || new OuterStruct()).__init(this.bb_pos + 2224 + index * 208, this.bb!); +} + +g(index: number):bigint|null { + return this.bb!.readInt64(this.bb_pos + 2640 + index * 8); +} + +static getFullyQualifiedName():string { + return 'MyGame_Example_ArrayStruct'; +} + +static sizeOf():number { + return 2656; +} + +static createArrayStruct(builder:flatbuffers.Builder, a_underscore: number, b_underscore: number[]|null, c: number, d: (any|NestedStructT)[]|null, e: number, f: (any|OuterStructT)[]|null, g: bigint[]|null):flatbuffers.Offset { + builder.prep(8, 2656); + + for (let i = 1; i >= 0; --i) { + builder.writeInt64(BigInt(g?.[i] ?? 0)); + } + + + for (let i = 1; i >= 0; --i) { + const item = f?.[i]; + + if (item instanceof OuterStructT) { + item.pack(builder); + continue; + } + + OuterStruct.createOuterStruct(builder, + item?.a, + item?.b, + (item?.cUnderscore?.a ?? 0), + (item?.cUnderscore?.b ?? []), + (item?.cUnderscore?.c ?? 0), + (item?.cUnderscore?.dUnderscore ?? BigInt(0)), + item?.d, + (item?.e?.a ?? 0), + (item?.e?.b ?? []), + (item?.e?.c ?? 0), + (item?.e?.dUnderscore ?? BigInt(0)), + item?.f + ); + } + + builder.pad(4); + builder.writeInt32(e); + + for (let i = 1; i >= 0; --i) { + const item = d?.[i]; + + if (item instanceof NestedStructT) { + item.pack(builder); + continue; + } + + NestedStruct.createNestedStruct(builder, + item?.a, + item?.b, + item?.cUnderscore, + item?.dOuter, + item?.e + ); + } + + builder.pad(7); + builder.writeInt8(c); + + for (let i = 14; i >= 0; --i) { + builder.writeInt32((b_underscore?.[i] ?? 0)); + + } + + builder.writeFloat32(a_underscore); + return builder.offset(); +} + + +unpack(): ArrayStructT { + return new ArrayStructT( + this.aUnderscore(), + this.bb!.createScalarList(this.bUnderscore.bind(this), 15), + this.c(), + this.bb!.createObjList(this.d.bind(this), 2), + this.e(), + this.bb!.createObjList(this.f.bind(this), 2), + this.bb!.createScalarList(this.g.bind(this), 2) + ); +} + + +unpackTo(_o: ArrayStructT): void { + _o.aUnderscore = this.aUnderscore(); + _o.bUnderscore = this.bb!.createScalarList(this.bUnderscore.bind(this), 15); + _o.c = this.c(); + _o.d = this.bb!.createObjList(this.d.bind(this), 2); + _o.e = this.e(); + _o.f = this.bb!.createObjList(this.f.bind(this), 2); + _o.g = this.bb!.createScalarList(this.g.bind(this), 2); +} +} + +export class ArrayStructT implements flatbuffers.IGeneratedObject { +constructor( + public aUnderscore: number = 0.0, + public bUnderscore: (number)[] = [], + public c: number = 0, + public d: (NestedStructT)[] = [], + public e: number = 0, + public f: (OuterStructT)[] = [], + public g: (bigint)[] = [] +){} + + +pack(builder:flatbuffers.Builder): flatbuffers.Offset { + return ArrayStruct.createArrayStruct(builder, + this.aUnderscore, + this.bUnderscore, + this.c, + this.d, + this.e, + this.f, + this.g + ); +} +} diff --git a/tests/ts/arrays_test_complex/my-game/example/array-table.js b/tests/ts/arrays_test_complex/my-game/example/array-table.js new file mode 100644 index 00000000000..08819e7fc30 --- /dev/null +++ b/tests/ts/arrays_test_complex/my-game/example/array-table.js @@ -0,0 +1,74 @@ +// automatically generated by the FlatBuffers compiler, do not modify +import * as flatbuffers from 'flatbuffers'; +import { ArrayStruct } from '../../my-game/example/array-struct.js'; +export class ArrayTable { + constructor() { + this.bb = null; + this.bb_pos = 0; + } + __init(i, bb) { + this.bb_pos = i; + this.bb = bb; + return this; + } + static getRootAsArrayTable(bb, obj) { + return (obj || new ArrayTable()).__init(bb.readInt32(bb.position()) + bb.position(), bb); + } + static getSizePrefixedRootAsArrayTable(bb, obj) { + bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); + return (obj || new ArrayTable()).__init(bb.readInt32(bb.position()) + bb.position(), bb); + } + static bufferHasIdentifier(bb) { + return bb.__has_identifier('RHUB'); + } + a(optionalEncoding) { + const offset = this.bb.__offset(this.bb_pos, 4); + return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null; + } + cUnderscore(obj) { + const offset = this.bb.__offset(this.bb_pos, 6); + return offset ? (obj || new ArrayStruct()).__init(this.bb_pos + offset, this.bb) : null; + } + static getFullyQualifiedName() { + return 'MyGame_Example_ArrayTable'; + } + static startArrayTable(builder) { + builder.startObject(2); + } + static addA(builder, aOffset) { + builder.addFieldOffset(0, aOffset, 0); + } + static addCUnderscore(builder, cUnderscoreOffset) { + builder.addFieldStruct(1, cUnderscoreOffset, 0); + } + static endArrayTable(builder) { + const offset = builder.endObject(); + return offset; + } + static finishArrayTableBuffer(builder, offset) { + builder.finish(offset, 'RHUB'); + } + static finishSizePrefixedArrayTableBuffer(builder, offset) { + builder.finish(offset, 'RHUB', true); + } + unpack() { + return new ArrayTableT(this.a(), (this.cUnderscore() !== null ? this.cUnderscore().unpack() : null)); + } + unpackTo(_o) { + _o.a = this.a(); + _o.cUnderscore = (this.cUnderscore() !== null ? this.cUnderscore().unpack() : null); + } +} +export class ArrayTableT { + constructor(a = null, cUnderscore = null) { + this.a = a; + this.cUnderscore = cUnderscore; + } + pack(builder) { + const a = (this.a !== null ? builder.createString(this.a) : 0); + ArrayTable.startArrayTable(builder); + ArrayTable.addA(builder, a); + ArrayTable.addCUnderscore(builder, (this.cUnderscore !== null ? this.cUnderscore.pack(builder) : 0)); + return ArrayTable.endArrayTable(builder); + } +} diff --git a/tests/ts/arrays_test_complex/my-game/example/array-table.ts b/tests/ts/arrays_test_complex/my-game/example/array-table.ts new file mode 100644 index 00000000000..7711c257ecf --- /dev/null +++ b/tests/ts/arrays_test_complex/my-game/example/array-table.ts @@ -0,0 +1,102 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +import * as flatbuffers from 'flatbuffers'; + +import { ArrayStruct, ArrayStructT } from '../../my-game/example/array-struct.js'; + + +export class ArrayTable implements flatbuffers.IUnpackableObject { + bb: flatbuffers.ByteBuffer|null = null; + bb_pos = 0; + __init(i:number, bb:flatbuffers.ByteBuffer):ArrayTable { + this.bb_pos = i; + this.bb = bb; + return this; +} + +static getRootAsArrayTable(bb:flatbuffers.ByteBuffer, obj?:ArrayTable):ArrayTable { + return (obj || new ArrayTable()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +static getSizePrefixedRootAsArrayTable(bb:flatbuffers.ByteBuffer, obj?:ArrayTable):ArrayTable { + bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); + return (obj || new ArrayTable()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +static bufferHasIdentifier(bb:flatbuffers.ByteBuffer):boolean { + return bb.__has_identifier('RHUB'); +} + +a():string|null +a(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null +a(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; +} + +cUnderscore(obj?:ArrayStruct):ArrayStruct|null { + const offset = this.bb!.__offset(this.bb_pos, 6); + return offset ? (obj || new ArrayStruct()).__init(this.bb_pos + offset, this.bb!) : null; +} + +static getFullyQualifiedName():string { + return 'MyGame_Example_ArrayTable'; +} + +static startArrayTable(builder:flatbuffers.Builder) { + builder.startObject(2); +} + +static addA(builder:flatbuffers.Builder, aOffset:flatbuffers.Offset) { + builder.addFieldOffset(0, aOffset, 0); +} + +static addCUnderscore(builder:flatbuffers.Builder, cUnderscoreOffset:flatbuffers.Offset) { + builder.addFieldStruct(1, cUnderscoreOffset, 0); +} + +static endArrayTable(builder:flatbuffers.Builder):flatbuffers.Offset { + const offset = builder.endObject(); + return offset; +} + +static finishArrayTableBuffer(builder:flatbuffers.Builder, offset:flatbuffers.Offset) { + builder.finish(offset, 'RHUB'); +} + +static finishSizePrefixedArrayTableBuffer(builder:flatbuffers.Builder, offset:flatbuffers.Offset) { + builder.finish(offset, 'RHUB', true); +} + + +unpack(): ArrayTableT { + return new ArrayTableT( + this.a(), + (this.cUnderscore() !== null ? this.cUnderscore()!.unpack() : null) + ); +} + + +unpackTo(_o: ArrayTableT): void { + _o.a = this.a(); + _o.cUnderscore = (this.cUnderscore() !== null ? this.cUnderscore()!.unpack() : null); +} +} + +export class ArrayTableT implements flatbuffers.IGeneratedObject { +constructor( + public a: string|Uint8Array|null = null, + public cUnderscore: ArrayStructT|null = null +){} + + +pack(builder:flatbuffers.Builder): flatbuffers.Offset { + const a = (this.a !== null ? builder.createString(this.a!) : 0); + + ArrayTable.startArrayTable(builder); + ArrayTable.addA(builder, a); + ArrayTable.addCUnderscore(builder, (this.cUnderscore !== null ? this.cUnderscore!.pack(builder) : 0)); + + return ArrayTable.endArrayTable(builder); +} +} diff --git a/tests/ts/arrays_test_complex/my-game/example/inner-struct.js b/tests/ts/arrays_test_complex/my-game/example/inner-struct.js new file mode 100644 index 00000000000..aecdff2cd44 --- /dev/null +++ b/tests/ts/arrays_test_complex/my-game/example/inner-struct.js @@ -0,0 +1,61 @@ +// automatically generated by the FlatBuffers compiler, do not modify +export class InnerStruct { + constructor() { + this.bb = null; + this.bb_pos = 0; + } + __init(i, bb) { + this.bb_pos = i; + this.bb = bb; + return this; + } + a() { + return this.bb.readFloat64(this.bb_pos); + } + b(index) { + return this.bb.readUint8(this.bb_pos + 8 + index); + } + c() { + return this.bb.readInt8(this.bb_pos + 21); + } + dUnderscore() { + return this.bb.readInt64(this.bb_pos + 24); + } + static getFullyQualifiedName() { + return 'MyGame_Example_InnerStruct'; + } + static sizeOf() { + return 32; + } + static createInnerStruct(builder, a, b, c, d_underscore) { + builder.prep(8, 32); + builder.writeInt64(BigInt(d_underscore ?? 0)); + builder.pad(2); + builder.writeInt8(c); + for (let i = 12; i >= 0; --i) { + builder.writeInt8((b?.[i] ?? 0)); + } + builder.writeFloat64(a); + return builder.offset(); + } + unpack() { + return new InnerStructT(this.a(), this.bb.createScalarList(this.b.bind(this), 13), this.c(), this.dUnderscore()); + } + unpackTo(_o) { + _o.a = this.a(); + _o.b = this.bb.createScalarList(this.b.bind(this), 13); + _o.c = this.c(); + _o.dUnderscore = this.dUnderscore(); + } +} +export class InnerStructT { + constructor(a = 0.0, b = [], c = 0, dUnderscore = BigInt('0')) { + this.a = a; + this.b = b; + this.c = c; + this.dUnderscore = dUnderscore; + } + pack(builder) { + return InnerStruct.createInnerStruct(builder, this.a, this.b, this.c, this.dUnderscore); + } +} diff --git a/tests/ts/arrays_test_complex/my-game/example/inner-struct.ts b/tests/ts/arrays_test_complex/my-game/example/inner-struct.ts new file mode 100644 index 00000000000..0f97eedab1e --- /dev/null +++ b/tests/ts/arrays_test_complex/my-game/example/inner-struct.ts @@ -0,0 +1,91 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +import * as flatbuffers from 'flatbuffers'; + + + +export class InnerStruct implements flatbuffers.IUnpackableObject { + bb: flatbuffers.ByteBuffer|null = null; + bb_pos = 0; + __init(i:number, bb:flatbuffers.ByteBuffer):InnerStruct { + this.bb_pos = i; + this.bb = bb; + return this; +} + +a():number { + return this.bb!.readFloat64(this.bb_pos); +} + +b(index: number):number|null { + return this.bb!.readUint8(this.bb_pos + 8 + index); +} + +c():number { + return this.bb!.readInt8(this.bb_pos + 21); +} + +dUnderscore():bigint { + return this.bb!.readInt64(this.bb_pos + 24); +} + +static getFullyQualifiedName():string { + return 'MyGame_Example_InnerStruct'; +} + +static sizeOf():number { + return 32; +} + +static createInnerStruct(builder:flatbuffers.Builder, a: number, b: number[]|null, c: number, d_underscore: bigint):flatbuffers.Offset { + builder.prep(8, 32); + builder.writeInt64(BigInt(d_underscore ?? 0)); + builder.pad(2); + builder.writeInt8(c); + + for (let i = 12; i >= 0; --i) { + builder.writeInt8((b?.[i] ?? 0)); + + } + + builder.writeFloat64(a); + return builder.offset(); +} + + +unpack(): InnerStructT { + return new InnerStructT( + this.a(), + this.bb!.createScalarList(this.b.bind(this), 13), + this.c(), + this.dUnderscore() + ); +} + + +unpackTo(_o: InnerStructT): void { + _o.a = this.a(); + _o.b = this.bb!.createScalarList(this.b.bind(this), 13); + _o.c = this.c(); + _o.dUnderscore = this.dUnderscore(); +} +} + +export class InnerStructT implements flatbuffers.IGeneratedObject { +constructor( + public a: number = 0.0, + public b: (number)[] = [], + public c: number = 0, + public dUnderscore: bigint = BigInt('0') +){} + + +pack(builder:flatbuffers.Builder): flatbuffers.Offset { + return InnerStruct.createInnerStruct(builder, + this.a, + this.b, + this.c, + this.dUnderscore + ); +} +} diff --git a/tests/ts/arrays_test_complex/my-game/example/nested-struct.js b/tests/ts/arrays_test_complex/my-game/example/nested-struct.js new file mode 100644 index 00000000000..99413b41654 --- /dev/null +++ b/tests/ts/arrays_test_complex/my-game/example/nested-struct.js @@ -0,0 +1,80 @@ +// automatically generated by the FlatBuffers compiler, do not modify +import { OuterStruct, OuterStructT } from '../../my-game/example/outer-struct.js'; +import { TestEnum } from '../../my-game/example/test-enum.js'; +export class NestedStruct { + constructor() { + this.bb = null; + this.bb_pos = 0; + } + __init(i, bb) { + this.bb_pos = i; + this.bb = bb; + return this; + } + a(index) { + return this.bb.readInt32(this.bb_pos + 0 + index * 4); + } + b() { + return this.bb.readInt8(this.bb_pos + 8); + } + cUnderscore(index) { + return this.bb.readInt8(this.bb_pos + 9 + index); + } + dOuter(index, obj) { + return (obj || new OuterStruct()).__init(this.bb_pos + 16 + index * 208, this.bb); + } + e(index) { + return this.bb.readInt64(this.bb_pos + 1056 + index * 8); + } + static getFullyQualifiedName() { + return 'MyGame_Example_NestedStruct'; + } + static sizeOf() { + return 1072; + } + static createNestedStruct(builder, a, b, c_underscore, d_outer, e) { + builder.prep(8, 1072); + for (let i = 1; i >= 0; --i) { + builder.writeInt64(BigInt(e?.[i] ?? 0)); + } + for (let i = 4; i >= 0; --i) { + const item = d_outer?.[i]; + if (item instanceof OuterStructT) { + item.pack(builder); + continue; + } + OuterStruct.createOuterStruct(builder, item?.a, item?.b, (item?.cUnderscore?.a ?? 0), (item?.cUnderscore?.b ?? []), (item?.cUnderscore?.c ?? 0), (item?.cUnderscore?.dUnderscore ?? BigInt(0)), item?.d, (item?.e?.a ?? 0), (item?.e?.b ?? []), (item?.e?.c ?? 0), (item?.e?.dUnderscore ?? BigInt(0)), item?.f); + } + builder.pad(5); + for (let i = 1; i >= 0; --i) { + builder.writeInt8((c_underscore?.[i] ?? 0)); + } + builder.writeInt8(b); + for (let i = 1; i >= 0; --i) { + builder.writeInt32((a?.[i] ?? 0)); + } + return builder.offset(); + } + unpack() { + return new NestedStructT(this.bb.createScalarList(this.a.bind(this), 2), this.b(), this.bb.createScalarList(this.cUnderscore.bind(this), 2), this.bb.createObjList(this.dOuter.bind(this), 5), this.bb.createScalarList(this.e.bind(this), 2)); + } + unpackTo(_o) { + _o.a = this.bb.createScalarList(this.a.bind(this), 2); + _o.b = this.b(); + _o.cUnderscore = this.bb.createScalarList(this.cUnderscore.bind(this), 2); + _o.dOuter = this.bb.createObjList(this.dOuter.bind(this), 5); + _o.e = this.bb.createScalarList(this.e.bind(this), 2); + } +} +export class NestedStructT { + constructor(a = [], b = TestEnum.A, cUnderscore = [TestEnum.A, TestEnum.A], dOuter = [], e = []) { + this.a = a; + this.b = b; + this.cUnderscore = cUnderscore; + this.dOuter = dOuter; + this.e = e; + } + pack(builder) { + return NestedStruct.createNestedStruct(builder, this.a, this.b, this.cUnderscore, this.dOuter, this.e); + } +} diff --git a/tests/ts/arrays_test_complex/my-game/example/nested-struct.ts b/tests/ts/arrays_test_complex/my-game/example/nested-struct.ts new file mode 100644 index 00000000000..b01a99c6410 --- /dev/null +++ b/tests/ts/arrays_test_complex/my-game/example/nested-struct.ts @@ -0,0 +1,135 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +import * as flatbuffers from 'flatbuffers'; + +import { OuterStruct, OuterStructT } from '../../my-game/example/outer-struct.js'; +import { TestEnum } from '../../my-game/example/test-enum.js'; + + +export class NestedStruct implements flatbuffers.IUnpackableObject { + bb: flatbuffers.ByteBuffer|null = null; + bb_pos = 0; + __init(i:number, bb:flatbuffers.ByteBuffer):NestedStruct { + this.bb_pos = i; + this.bb = bb; + return this; +} + +a(index: number):number|null { + return this.bb!.readInt32(this.bb_pos + 0 + index * 4); +} + +b():TestEnum { + return this.bb!.readInt8(this.bb_pos + 8); +} + +cUnderscore(index: number):TestEnum|null { + return this.bb!.readInt8(this.bb_pos + 9 + index); +} + +dOuter(index: number, obj?:OuterStruct):OuterStruct|null { + return (obj || new OuterStruct()).__init(this.bb_pos + 16 + index * 208, this.bb!); +} + +e(index: number):bigint|null { + return this.bb!.readInt64(this.bb_pos + 1056 + index * 8); +} + +static getFullyQualifiedName():string { + return 'MyGame_Example_NestedStruct'; +} + +static sizeOf():number { + return 1072; +} + +static createNestedStruct(builder:flatbuffers.Builder, a: number[]|null, b: TestEnum, c_underscore: number[]|null, d_outer: (any|OuterStructT)[]|null, e: bigint[]|null):flatbuffers.Offset { + builder.prep(8, 1072); + + for (let i = 1; i >= 0; --i) { + builder.writeInt64(BigInt(e?.[i] ?? 0)); + } + + + for (let i = 4; i >= 0; --i) { + const item = d_outer?.[i]; + + if (item instanceof OuterStructT) { + item.pack(builder); + continue; + } + + OuterStruct.createOuterStruct(builder, + item?.a, + item?.b, + (item?.cUnderscore?.a ?? 0), + (item?.cUnderscore?.b ?? []), + (item?.cUnderscore?.c ?? 0), + (item?.cUnderscore?.dUnderscore ?? BigInt(0)), + item?.d, + (item?.e?.a ?? 0), + (item?.e?.b ?? []), + (item?.e?.c ?? 0), + (item?.e?.dUnderscore ?? BigInt(0)), + item?.f + ); + } + + builder.pad(5); + + for (let i = 1; i >= 0; --i) { + builder.writeInt8((c_underscore?.[i] ?? 0)); + + } + + builder.writeInt8(b); + + for (let i = 1; i >= 0; --i) { + builder.writeInt32((a?.[i] ?? 0)); + + } + + return builder.offset(); +} + + +unpack(): NestedStructT { + return new NestedStructT( + this.bb!.createScalarList(this.a.bind(this), 2), + this.b(), + this.bb!.createScalarList(this.cUnderscore.bind(this), 2), + this.bb!.createObjList(this.dOuter.bind(this), 5), + this.bb!.createScalarList(this.e.bind(this), 2) + ); +} + + +unpackTo(_o: NestedStructT): void { + _o.a = this.bb!.createScalarList(this.a.bind(this), 2); + _o.b = this.b(); + _o.cUnderscore = this.bb!.createScalarList(this.cUnderscore.bind(this), 2); + _o.dOuter = this.bb!.createObjList(this.dOuter.bind(this), 5); + _o.e = this.bb!.createScalarList(this.e.bind(this), 2); +} +} + +export class NestedStructT implements flatbuffers.IGeneratedObject { +constructor( + public a: (number)[] = [], + public b: TestEnum = TestEnum.A, + public cUnderscore: (TestEnum)[] = [TestEnum.A, TestEnum.A], + public dOuter: (OuterStructT)[] = [], + public e: (bigint)[] = [] +){} + + +pack(builder:flatbuffers.Builder): flatbuffers.Offset { + return NestedStruct.createNestedStruct(builder, + this.a, + this.b, + this.cUnderscore, + this.dOuter, + this.e + ); +} +} diff --git a/tests/ts/arrays_test_complex/my-game/example/outer-struct.js b/tests/ts/arrays_test_complex/my-game/example/outer-struct.js new file mode 100644 index 00000000000..f940d8c0570 --- /dev/null +++ b/tests/ts/arrays_test_complex/my-game/example/outer-struct.js @@ -0,0 +1,95 @@ +// automatically generated by the FlatBuffers compiler, do not modify +import { InnerStruct, InnerStructT } from '../../my-game/example/inner-struct.js'; +export class OuterStruct { + constructor() { + this.bb = null; + this.bb_pos = 0; + } + __init(i, bb) { + this.bb_pos = i; + this.bb = bb; + return this; + } + a() { + return !!this.bb.readInt8(this.bb_pos); + } + b() { + return this.bb.readFloat64(this.bb_pos + 8); + } + cUnderscore(obj) { + return (obj || new InnerStruct()).__init(this.bb_pos + 16, this.bb); + } + d(index, obj) { + return (obj || new InnerStruct()).__init(this.bb_pos + 48 + index * 32, this.bb); + } + e(obj) { + return (obj || new InnerStruct()).__init(this.bb_pos + 144, this.bb); + } + f(index) { + return this.bb.readFloat64(this.bb_pos + 176 + index * 8); + } + static getFullyQualifiedName() { + return 'MyGame_Example_OuterStruct'; + } + static sizeOf() { + return 208; + } + static createOuterStruct(builder, a, b, c_underscore_a, c_underscore_b, c_underscore_c, c_underscore_d_underscore, d, e_a, e_b, e_c, e_d_underscore, f) { + builder.prep(8, 208); + for (let i = 3; i >= 0; --i) { + builder.writeFloat64((f?.[i] ?? 0)); + } + builder.prep(8, 32); + builder.writeInt64(BigInt(e_d_underscore ?? 0)); + builder.pad(2); + builder.writeInt8(e_c); + for (let i = 12; i >= 0; --i) { + builder.writeInt8((e_b?.[i] ?? 0)); + } + builder.writeFloat64(e_a); + for (let i = 2; i >= 0; --i) { + const item = d?.[i]; + if (item instanceof InnerStructT) { + item.pack(builder); + continue; + } + InnerStruct.createInnerStruct(builder, item?.a, item?.b, item?.c, item?.dUnderscore); + } + builder.prep(8, 32); + builder.writeInt64(BigInt(c_underscore_d_underscore ?? 0)); + builder.pad(2); + builder.writeInt8(c_underscore_c); + for (let i = 12; i >= 0; --i) { + builder.writeInt8((c_underscore_b?.[i] ?? 0)); + } + builder.writeFloat64(c_underscore_a); + builder.writeFloat64(b); + builder.pad(7); + builder.writeInt8(Number(Boolean(a))); + return builder.offset(); + } + unpack() { + return new OuterStructT(this.a(), this.b(), (this.cUnderscore() !== null ? this.cUnderscore().unpack() : null), this.bb.createObjList(this.d.bind(this), 3), (this.e() !== null ? this.e().unpack() : null), this.bb.createScalarList(this.f.bind(this), 4)); + } + unpackTo(_o) { + _o.a = this.a(); + _o.b = this.b(); + _o.cUnderscore = (this.cUnderscore() !== null ? this.cUnderscore().unpack() : null); + _o.d = this.bb.createObjList(this.d.bind(this), 3); + _o.e = (this.e() !== null ? this.e().unpack() : null); + _o.f = this.bb.createScalarList(this.f.bind(this), 4); + } +} +export class OuterStructT { + constructor(a = false, b = 0.0, cUnderscore = null, d = [], e = null, f = []) { + this.a = a; + this.b = b; + this.cUnderscore = cUnderscore; + this.d = d; + this.e = e; + this.f = f; + } + pack(builder) { + return OuterStruct.createOuterStruct(builder, this.a, this.b, (this.cUnderscore?.a ?? 0), (this.cUnderscore?.b ?? []), (this.cUnderscore?.c ?? 0), (this.cUnderscore?.dUnderscore ?? BigInt(0)), this.d, (this.e?.a ?? 0), (this.e?.b ?? []), (this.e?.c ?? 0), (this.e?.dUnderscore ?? BigInt(0)), this.f); + } +} diff --git a/tests/ts/arrays_test_complex/my-game/example/outer-struct.ts b/tests/ts/arrays_test_complex/my-game/example/outer-struct.ts new file mode 100644 index 00000000000..bb7d7644fc5 --- /dev/null +++ b/tests/ts/arrays_test_complex/my-game/example/outer-struct.ts @@ -0,0 +1,152 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +import * as flatbuffers from 'flatbuffers'; + +import { InnerStruct, InnerStructT } from '../../my-game/example/inner-struct.js'; + + +export class OuterStruct implements flatbuffers.IUnpackableObject { + bb: flatbuffers.ByteBuffer|null = null; + bb_pos = 0; + __init(i:number, bb:flatbuffers.ByteBuffer):OuterStruct { + this.bb_pos = i; + this.bb = bb; + return this; +} + +a():boolean { + return !!this.bb!.readInt8(this.bb_pos); +} + +b():number { + return this.bb!.readFloat64(this.bb_pos + 8); +} + +cUnderscore(obj?:InnerStruct):InnerStruct|null { + return (obj || new InnerStruct()).__init(this.bb_pos + 16, this.bb!); +} + +d(index: number, obj?:InnerStruct):InnerStruct|null { + return (obj || new InnerStruct()).__init(this.bb_pos + 48 + index * 32, this.bb!); +} + +e(obj?:InnerStruct):InnerStruct|null { + return (obj || new InnerStruct()).__init(this.bb_pos + 144, this.bb!); +} + +f(index: number):number|null { + return this.bb!.readFloat64(this.bb_pos + 176 + index * 8); +} + +static getFullyQualifiedName():string { + return 'MyGame_Example_OuterStruct'; +} + +static sizeOf():number { + return 208; +} + +static createOuterStruct(builder:flatbuffers.Builder, a: boolean, b: number, c_underscore_a: number, c_underscore_b: number[]|null, c_underscore_c: number, c_underscore_d_underscore: bigint, d: (any|InnerStructT)[]|null, e_a: number, e_b: number[]|null, e_c: number, e_d_underscore: bigint, f: number[]|null):flatbuffers.Offset { + builder.prep(8, 208); + + for (let i = 3; i >= 0; --i) { + builder.writeFloat64((f?.[i] ?? 0)); + + } + + builder.prep(8, 32); + builder.writeInt64(BigInt(e_d_underscore ?? 0)); + builder.pad(2); + builder.writeInt8(e_c); + + for (let i = 12; i >= 0; --i) { + builder.writeInt8((e_b?.[i] ?? 0)); + + } + + builder.writeFloat64(e_a); + + for (let i = 2; i >= 0; --i) { + const item = d?.[i]; + + if (item instanceof InnerStructT) { + item.pack(builder); + continue; + } + + InnerStruct.createInnerStruct(builder, + item?.a, + item?.b, + item?.c, + item?.dUnderscore + ); + } + + builder.prep(8, 32); + builder.writeInt64(BigInt(c_underscore_d_underscore ?? 0)); + builder.pad(2); + builder.writeInt8(c_underscore_c); + + for (let i = 12; i >= 0; --i) { + builder.writeInt8((c_underscore_b?.[i] ?? 0)); + + } + + builder.writeFloat64(c_underscore_a); + builder.writeFloat64(b); + builder.pad(7); + builder.writeInt8(Number(Boolean(a))); + return builder.offset(); +} + + +unpack(): OuterStructT { + return new OuterStructT( + this.a(), + this.b(), + (this.cUnderscore() !== null ? this.cUnderscore()!.unpack() : null), + this.bb!.createObjList(this.d.bind(this), 3), + (this.e() !== null ? this.e()!.unpack() : null), + this.bb!.createScalarList(this.f.bind(this), 4) + ); +} + + +unpackTo(_o: OuterStructT): void { + _o.a = this.a(); + _o.b = this.b(); + _o.cUnderscore = (this.cUnderscore() !== null ? this.cUnderscore()!.unpack() : null); + _o.d = this.bb!.createObjList(this.d.bind(this), 3); + _o.e = (this.e() !== null ? this.e()!.unpack() : null); + _o.f = this.bb!.createScalarList(this.f.bind(this), 4); +} +} + +export class OuterStructT implements flatbuffers.IGeneratedObject { +constructor( + public a: boolean = false, + public b: number = 0.0, + public cUnderscore: InnerStructT|null = null, + public d: (InnerStructT)[] = [], + public e: InnerStructT|null = null, + public f: (number)[] = [] +){} + + +pack(builder:flatbuffers.Builder): flatbuffers.Offset { + return OuterStruct.createOuterStruct(builder, + this.a, + this.b, + (this.cUnderscore?.a ?? 0), + (this.cUnderscore?.b ?? []), + (this.cUnderscore?.c ?? 0), + (this.cUnderscore?.dUnderscore ?? BigInt(0)), + this.d, + (this.e?.a ?? 0), + (this.e?.b ?? []), + (this.e?.c ?? 0), + (this.e?.dUnderscore ?? BigInt(0)), + this.f + ); +} +} diff --git a/tests/ts/arrays_test_complex/my-game/example/test-enum.js b/tests/ts/arrays_test_complex/my-game/example/test-enum.js new file mode 100644 index 00000000000..1fb1550535c --- /dev/null +++ b/tests/ts/arrays_test_complex/my-game/example/test-enum.js @@ -0,0 +1,7 @@ +// automatically generated by the FlatBuffers compiler, do not modify +export var TestEnum; +(function (TestEnum) { + TestEnum[TestEnum["A"] = 0] = "A"; + TestEnum[TestEnum["B"] = 1] = "B"; + TestEnum[TestEnum["C"] = 2] = "C"; +})(TestEnum = TestEnum || (TestEnum = {})); diff --git a/tests/ts/arrays_test_complex/my-game/example/test-enum.ts b/tests/ts/arrays_test_complex/my-game/example/test-enum.ts new file mode 100644 index 00000000000..a450fc82a74 --- /dev/null +++ b/tests/ts/arrays_test_complex/my-game/example/test-enum.ts @@ -0,0 +1,7 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +export enum TestEnum { + A = 0, + B = 1, + C = 2 +} diff --git a/tests/ts/monster_test_generated.js b/tests/ts/monster_test_generated.js index ffd9dedc1c3..609305356ba 100644 --- a/tests/ts/monster_test_generated.js +++ b/tests/ts/monster_test_generated.js @@ -1262,11 +1262,23 @@ var Monster2 = class { this.bb.writeFloat32(this.bb_pos + offset, value); return true; } + doubleInfDefault() { + const offset = this.bb.__offset(this.bb_pos, 126); + return offset ? this.bb.readFloat64(this.bb_pos + offset) : Infinity; + } + mutate_double_inf_default(value) { + const offset = this.bb.__offset(this.bb_pos, 126); + if (offset === 0) { + return false; + } + this.bb.writeFloat64(this.bb_pos + offset, value); + return true; + } static getFullyQualifiedName() { return "MyGame_Example_Monster"; } static startMonster(builder) { - builder.startObject(61); + builder.startObject(62); } static addPos(builder, posOffset) { builder.addFieldStruct(0, posOffset, 0); @@ -1627,6 +1639,9 @@ var Monster2 = class { static addNegativeInfinityDefault(builder, negativeInfinityDefault) { builder.addFieldFloat32(60, negativeInfinityDefault, -Infinity); } + static addDoubleInfDefault(builder, doubleInfDefault) { + builder.addFieldFloat64(61, doubleInfDefault, Infinity); + } static endMonster(builder) { const offset = builder.endObject(); builder.requiredField(offset, 10); @@ -1663,7 +1678,7 @@ var Monster2 = class { 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(), this.nanDefault(), this.infDefault(), this.positiveInfDefault(), this.infinityDefault(), this.positiveInfinityDefault(), this.negativeInfDefault(), this.negativeInfinityDefault()); + })(), 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(), this.nanDefault(), this.infDefault(), this.positiveInfDefault(), this.infinityDefault(), this.positiveInfinityDefault(), this.negativeInfDefault(), this.negativeInfinityDefault(), this.doubleInfDefault()); } unpackTo(_o) { _o.pos = this.pos() !== null ? this.pos().unpack() : null; @@ -1744,10 +1759,11 @@ var Monster2 = class { _o.positiveInfinityDefault = this.positiveInfinityDefault(); _o.negativeInfDefault = this.negativeInfDefault(); _o.negativeInfinityDefault = this.negativeInfinityDefault(); + _o.doubleInfDefault = this.doubleInfDefault(); } }; var MonsterT2 = class { - 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, testf3 = 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"), nanDefault = NaN, infDefault = Infinity, positiveInfDefault = Infinity, infinityDefault = Infinity, positiveInfinityDefault = Infinity, negativeInfDefault = -Infinity, negativeInfinityDefault = -Infinity) { + 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, testf3 = 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"), nanDefault = NaN, infDefault = Infinity, positiveInfDefault = Infinity, infinityDefault = Infinity, positiveInfinityDefault = Infinity, negativeInfDefault = -Infinity, negativeInfinityDefault = -Infinity, doubleInfDefault = Infinity) { this.pos = pos; this.mana = mana; this.hp = hp; @@ -1808,6 +1824,7 @@ var MonsterT2 = class { this.positiveInfinityDefault = positiveInfinityDefault; this.negativeInfDefault = negativeInfDefault; this.negativeInfinityDefault = negativeInfinityDefault; + this.doubleInfDefault = doubleInfDefault; } pack(builder) { const name = this.name !== null ? builder.createString(this.name) : 0; @@ -1898,6 +1915,7 @@ var MonsterT2 = class { Monster2.addPositiveInfinityDefault(builder, this.positiveInfinityDefault); Monster2.addNegativeInfDefault(builder, this.negativeInfDefault); Monster2.addNegativeInfinityDefault(builder, this.negativeInfinityDefault); + Monster2.addDoubleInfDefault(builder, this.doubleInfDefault); return Monster2.endMonster(builder); } }; diff --git a/tests/ts/my-game/example.ts b/tests/ts/my-game/example.ts index 62ac2782e6e..fbfb45d5e51 100644 --- a/tests/ts/my-game/example.ts +++ b/tests/ts/my-game/example.ts @@ -1,8 +1,18 @@ // automatically generated by the FlatBuffers compiler, do not modify -export { ArrayStruct } from './arrays_test_complex/example/array-struct.js'; -export { ArrayTable } from './arrays_test_complex/example/array-table.js'; -export { InnerStruct } from './arrays_test_complex/example/inner-struct.js'; -export { NestedStruct } from './arrays_test_complex/example/nested-struct.js'; -export { OuterStruct } from './arrays_test_complex/example/outer-struct.js'; -export { TestEnum } from './arrays_test_complex/example/test-enum.js'; +export { Ability } from './example/ability.js'; +export { Any } from './example/any.js'; +export { AnyAmbiguousAliases } from './example/any-ambiguous-aliases.js'; +export { AnyUniqueAliases } from './example/any-unique-aliases.js'; +export { Color } from './example/color.js'; +export { LongEnum } from './example/long-enum.js'; +export { Monster } from './example/monster.js'; +export { Race } from './example/race.js'; +export { Referrable } from './example/referrable.js'; +export { Stat } from './example/stat.js'; +export { StructOfStructs } from './example/struct-of-structs.js'; +export { StructOfStructsOfStructs } from './example/struct-of-structs-of-structs.js'; +export { Test } from './example/test.js'; +export { TestSimpleTableWithEnum } from './example/test-simple-table-with-enum.js'; +export { TypeAliases } from './example/type-aliases.js'; +export { Vec3 } from './example/vec3.js'; diff --git a/tests/ts/my-game/example/monster.js b/tests/ts/my-game/example/monster.js index 97c93991c83..7a97bc32bd6 100644 --- a/tests/ts/my-game/example/monster.js +++ b/tests/ts/my-game/example/monster.js @@ -610,11 +610,23 @@ export class Monster { this.bb.writeFloat32(this.bb_pos + offset, value); return true; } + doubleInfDefault() { + const offset = this.bb.__offset(this.bb_pos, 126); + return offset ? this.bb.readFloat64(this.bb_pos + offset) : Infinity; + } + mutate_double_inf_default(value) { + const offset = this.bb.__offset(this.bb_pos, 126); + if (offset === 0) { + return false; + } + this.bb.writeFloat64(this.bb_pos + offset, value); + return true; + } static getFullyQualifiedName() { return 'MyGame_Example_Monster'; } static startMonster(builder) { - builder.startObject(61); + builder.startObject(62); } static addPos(builder, posOffset) { builder.addFieldStruct(0, posOffset, 0); @@ -975,6 +987,9 @@ export class Monster { static addNegativeInfinityDefault(builder, negativeInfinityDefault) { builder.addFieldFloat32(60, negativeInfinityDefault, -Infinity); } + static addDoubleInfDefault(builder, doubleInfDefault) { + builder.addFieldFloat64(61, doubleInfDefault, Infinity); + } static endMonster(builder) { const offset = builder.endObject(); builder.requiredField(offset, 10); // name @@ -1011,7 +1026,7 @@ export class Monster { 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(), this.nanDefault(), this.infDefault(), this.positiveInfDefault(), this.infinityDefault(), this.positiveInfinityDefault(), this.negativeInfDefault(), this.negativeInfinityDefault()); + })(), 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(), this.nanDefault(), this.infDefault(), this.positiveInfDefault(), this.infinityDefault(), this.positiveInfinityDefault(), this.negativeInfDefault(), this.negativeInfinityDefault(), this.doubleInfDefault()); } unpackTo(_o) { _o.pos = (this.pos() !== null ? this.pos().unpack() : null); @@ -1092,10 +1107,11 @@ export class Monster { _o.positiveInfinityDefault = this.positiveInfinityDefault(); _o.negativeInfDefault = this.negativeInfDefault(); _o.negativeInfinityDefault = this.negativeInfinityDefault(); + _o.doubleInfDefault = this.doubleInfDefault(); } } 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'), nanDefault = NaN, infDefault = Infinity, positiveInfDefault = Infinity, infinityDefault = Infinity, positiveInfinityDefault = Infinity, negativeInfDefault = -Infinity, negativeInfinityDefault = -Infinity) { + 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'), nanDefault = NaN, infDefault = Infinity, positiveInfDefault = Infinity, infinityDefault = Infinity, positiveInfinityDefault = Infinity, negativeInfDefault = -Infinity, negativeInfinityDefault = -Infinity, doubleInfDefault = Infinity) { this.pos = pos; this.mana = mana; this.hp = hp; @@ -1156,6 +1172,7 @@ export class MonsterT { this.positiveInfinityDefault = positiveInfinityDefault; this.negativeInfDefault = negativeInfDefault; this.negativeInfinityDefault = negativeInfinityDefault; + this.doubleInfDefault = doubleInfDefault; } pack(builder) { const name = (this.name !== null ? builder.createString(this.name) : 0); @@ -1246,6 +1263,7 @@ export class MonsterT { Monster.addPositiveInfinityDefault(builder, this.positiveInfinityDefault); Monster.addNegativeInfDefault(builder, this.negativeInfDefault); Monster.addNegativeInfinityDefault(builder, this.negativeInfinityDefault); + Monster.addDoubleInfDefault(builder, this.doubleInfDefault); return Monster.endMonster(builder); } } diff --git a/tests/ts/reflection_generated.js b/tests/ts/reflection_generated.js index e0ed0076a82..45a4a1e711d 100644 --- a/tests/ts/reflection_generated.js +++ b/tests/ts/reflection_generated.js @@ -1,1600 +1,1659 @@ -// 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; - } - 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; - } - static getFullyQualifiedName() { - return 'reflection_EnumVal'; - } - static startEnumVal(builder) { - builder.startObject(6); - } - 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 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 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()), this.bb.createObjList(this.attributes.bind(this), this.attributesLength())); - } - 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()); - _o.attributes = this.bb.createObjList(this.attributes.bind(this), this.attributesLength()); - } -} -export class EnumValT { - constructor(name = null, value = BigInt('0'), unionType = null, documentation = [], attributes = []) { - this.name = name; - this.value = value; - this.unionType = unionType; - this.documentation = documentation; - this.attributes = attributes; - } - 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)); - const attributes = EnumVal.createAttributesVector(builder, builder.createObjectOffsetList(this.attributes)); - EnumVal.startEnumVal(builder); - EnumVal.addName(builder, name); - EnumVal.addValue(builder, this.value); - EnumVal.addUnionType(builder, unionType); - EnumVal.addDocumentation(builder, documentation); - EnumVal.addAttributes(builder, attributes); - 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); - } -} +"use strict"; +var __create = Object.create; +var __defProp = Object.defineProperty; +var __getOwnPropDesc = Object.getOwnPropertyDescriptor; +var __getOwnPropNames = Object.getOwnPropertyNames; +var __getProtoOf = Object.getPrototypeOf; +var __hasOwnProp = Object.prototype.hasOwnProperty; +var __export = (target, all) => { + for (var name in all) + __defProp(target, name, { get: all[name], enumerable: true }); +}; +var __copyProps = (to, from, except, desc) => { + if (from && typeof from === "object" || typeof from === "function") { + for (let key of __getOwnPropNames(from)) + if (!__hasOwnProp.call(to, key) && key !== except) + __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); + } + return to; +}; +var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( + isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, + mod +)); +var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); + +// reflection.ts +var reflection_exports = {}; +__export(reflection_exports, { + AdvancedFeatures: () => AdvancedFeatures, + BaseType: () => BaseType, + Enum: () => Enum, + EnumVal: () => EnumVal, + Field: () => Field, + KeyValue: () => KeyValue, + Object_: () => Object_, + RPCCall: () => RPCCall, + Schema: () => Schema, + SchemaFile: () => SchemaFile, + Service: () => Service, + Type: () => Type +}); +module.exports = __toCommonJS(reflection_exports); + +// reflection/advanced-features.ts +var AdvancedFeatures = /* @__PURE__ */ ((AdvancedFeatures2) => { + AdvancedFeatures2["AdvancedArrayFeatures"] = "1"; + AdvancedFeatures2["AdvancedUnionFeatures"] = "2"; + AdvancedFeatures2["OptionalScalars"] = "4"; + AdvancedFeatures2["DefaultVectorsAndStrings"] = "8"; + return AdvancedFeatures2; +})(AdvancedFeatures || {}); + +// reflection/base-type.js +var BaseType; +(function(BaseType2) { + BaseType2[BaseType2["None"] = 0] = "None"; + BaseType2[BaseType2["UType"] = 1] = "UType"; + BaseType2[BaseType2["Bool"] = 2] = "Bool"; + BaseType2[BaseType2["Byte"] = 3] = "Byte"; + BaseType2[BaseType2["UByte"] = 4] = "UByte"; + BaseType2[BaseType2["Short"] = 5] = "Short"; + BaseType2[BaseType2["UShort"] = 6] = "UShort"; + BaseType2[BaseType2["Int"] = 7] = "Int"; + BaseType2[BaseType2["UInt"] = 8] = "UInt"; + BaseType2[BaseType2["Long"] = 9] = "Long"; + BaseType2[BaseType2["ULong"] = 10] = "ULong"; + BaseType2[BaseType2["Float"] = 11] = "Float"; + BaseType2[BaseType2["Double"] = 12] = "Double"; + BaseType2[BaseType2["String"] = 13] = "String"; + BaseType2[BaseType2["Vector"] = 14] = "Vector"; + BaseType2[BaseType2["Obj"] = 15] = "Obj"; + BaseType2[BaseType2["Union"] = 16] = "Union"; + BaseType2[BaseType2["Array"] = 17] = "Array"; + BaseType2[BaseType2["MaxBaseType"] = 18] = "MaxBaseType"; +})(BaseType = BaseType || (BaseType = {})); + +// reflection/enum.js +var flatbuffers4 = __toESM(require("flatbuffers"), 1); + +// reflection/enum-val.js +var flatbuffers3 = __toESM(require("flatbuffers"), 1); + +// reflection/key-value.js +var flatbuffers = __toESM(require("flatbuffers"), 1); +var KeyValue = class { + 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); + 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(); + } +}; +var KeyValueT = class { + 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); + } +}; + +// reflection/type.js +var flatbuffers2 = __toESM(require("flatbuffers"), 1); +var Type = class { + 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() + flatbuffers2.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; + } + 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; + } + 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(); + } +}; +var TypeT = class { + 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); + } +}; + +// reflection/enum-val.js +var EnumVal = class { + 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() + flatbuffers3.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; + } + 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; + } + static getFullyQualifiedName() { + return "reflection_EnumVal"; + } + static startEnumVal(builder) { + builder.startObject(6); + } + 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 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 endEnumVal(builder) { + const offset = builder.endObject(); + builder.requiredField(offset, 4); + 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()), this.bb.createObjList(this.attributes.bind(this), this.attributesLength())); + } + 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()); + _o.attributes = this.bb.createObjList(this.attributes.bind(this), this.attributesLength()); + } +}; +var EnumValT = class { + constructor(name = null, value = BigInt("0"), unionType = null, documentation = [], attributes = []) { + this.name = name; + this.value = value; + this.unionType = unionType; + this.documentation = documentation; + this.attributes = attributes; + } + 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)); + const attributes = EnumVal.createAttributesVector(builder, builder.createObjectOffsetList(this.attributes)); + EnumVal.startEnumVal(builder); + EnumVal.addName(builder, name); + EnumVal.addValue(builder, this.value); + EnumVal.addUnionType(builder, unionType); + EnumVal.addDocumentation(builder, documentation); + EnumVal.addAttributes(builder, attributes); + return EnumVal.endEnumVal(builder); + } +}; + +// reflection/enum.js +var Enum = class { + 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() + flatbuffers4.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, 0); + } + 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); + builder.requiredField(offset, 6); + builder.requiredField(offset, 10); + 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(); + } +}; +var EnumT = class { + 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); + } +}; + +// reflection/field.js +var flatbuffers5 = __toESM(require("flatbuffers"), 1); +var Field = class { + 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() + flatbuffers5.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; + } + 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; + } + 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); + } + static addDeprecated(builder, deprecated) { + builder.addFieldInt8(6, +deprecated, 0); + } + static addRequired(builder, required) { + builder.addFieldInt8(7, +required, 0); + } + static addKey(builder, key) { + builder.addFieldInt8(8, +key, 0); + } + 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, 0); + } + static addPadding(builder, padding) { + builder.addFieldInt16(12, padding, 0); + } + static endField(builder) { + const offset = builder.endObject(); + builder.requiredField(offset, 4); + builder.requiredField(offset, 6); + 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(); + } +}; +var FieldT = class { + constructor(name = null, type = null, id = 0, offset = 0, defaultInteger = BigInt("0"), defaultReal = 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); + } +}; + +// reflection/object.js +var flatbuffers6 = __toESM(require("flatbuffers"), 1); +var Object_ = class { + 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() + flatbuffers6.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, 0); + } + 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); + builder.requiredField(offset, 6); + 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(); + } +}; +var Object_T = class { + 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); + } +}; + +// reflection/rpccall.js +var flatbuffers7 = __toESM(require("flatbuffers"), 1); +var RPCCall = class { + 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() + flatbuffers7.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); + builder.requiredField(offset, 6); + builder.requiredField(offset, 8); + 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()); + } +}; +var RPCCallT = class { + 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); + } +}; + +// reflection/schema.js +var flatbuffers10 = __toESM(require("flatbuffers"), 1); + +// reflection/schema-file.js +var flatbuffers8 = __toESM(require("flatbuffers"), 1); +var SchemaFile = class { + 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() + flatbuffers8.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); + 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()); + } +}; +var SchemaFileT = class { + 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); + } +}; + +// reflection/service.js +var flatbuffers9 = __toESM(require("flatbuffers"), 1); +var Service = class { + 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() + flatbuffers9.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); + 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(); + } +}; +var ServiceT = class { + 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); + } +}; + +// reflection/schema.js +var Schema = class { + 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() + flatbuffers10.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; + } + 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); + builder.requiredField(offset, 6); + 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()); + } +}; +var SchemaT = class { + 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 deleted file mode 100644 index 6b553b1a064..00000000000 --- a/tests/ts/reflection_generated.ts +++ /dev/null @@ -1,2131 +0,0 @@ -// 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 implements flatbuffers.IUnpackableObject { - 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 implements flatbuffers.IGeneratedObject { -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 implements flatbuffers.IUnpackableObject { - 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 implements flatbuffers.IGeneratedObject { -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 implements flatbuffers.IUnpackableObject { - 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; -} - -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; -} - -static getFullyQualifiedName():string { - return 'reflection_EnumVal'; -} - -static startEnumVal(builder:flatbuffers.Builder) { - builder.startObject(6); -} - -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 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 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()), - this.bb!.createObjList(this.attributes.bind(this), this.attributesLength()) - ); -} - - -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()); - _o.attributes = this.bb!.createObjList(this.attributes.bind(this), this.attributesLength()); -} -} - -export class EnumValT implements flatbuffers.IGeneratedObject { -constructor( - public name: string|Uint8Array|null = null, - public value: bigint = BigInt('0'), - public unionType: TypeT|null = null, - public documentation: (string)[] = [], - public attributes: (KeyValueT)[] = [] -){} - - -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)); - const attributes = EnumVal.createAttributesVector(builder, builder.createObjectOffsetList(this.attributes)); - - EnumVal.startEnumVal(builder); - EnumVal.addName(builder, name); - EnumVal.addValue(builder, this.value); - EnumVal.addUnionType(builder, unionType); - EnumVal.addDocumentation(builder, documentation); - EnumVal.addAttributes(builder, attributes); - - return EnumVal.endEnumVal(builder); -} -} - -export class Enum implements flatbuffers.IUnpackableObject { - 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 implements flatbuffers.IGeneratedObject { -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 implements flatbuffers.IUnpackableObject { - 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 implements flatbuffers.IGeneratedObject { -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_ implements flatbuffers.IUnpackableObject { - 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 implements flatbuffers.IGeneratedObject { -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 implements flatbuffers.IUnpackableObject { - 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 implements flatbuffers.IGeneratedObject { -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 implements flatbuffers.IUnpackableObject { - 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 implements flatbuffers.IGeneratedObject { -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 implements flatbuffers.IUnpackableObject { - 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 implements flatbuffers.IGeneratedObject { -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 implements flatbuffers.IUnpackableObject { - 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 implements flatbuffers.IGeneratedObject { -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/ts-flat-files/monster_test_generated.ts b/tests/ts/ts-flat-files/monster_test_generated.ts deleted file mode 100644 index f1566c61d28..00000000000 --- a/tests/ts/ts-flat-files/monster_test_generated.ts +++ /dev/null @@ -1,1902 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -import * as flatbuffers from 'flatbuffers'; - -export enum MyGame_OtherNameSpace_FromInclude { - IncludeVal = '0' -} - -/** - * Composite components of Monster color. - */ -export enum MyGame_Example_Color { - Red = 1, - - /** - * \brief color Green - * Green is bit_flag with value (1u << 1) - */ - Green = 2, - - /** - * \brief color Blue (1u << 3) - */ - Blue = 8 -} - -export enum MyGame_Example_Race { - None = -1, - Human = 0, - Dwarf = 1, - Elf = 2 -} - -export enum MyGame_Example_LongEnum { - LongOne = '2', - LongTwo = '4', - LongBig = '1099511627776' -} - -export enum MyGame_Example_Any { - NONE = 0, - Monster = 1, - TestSimpleTableWithEnum = 2, - MyGame_Example2_Monster = 3 -} - -export function unionToAny( - type: MyGame_Example_Any, - accessor: (obj:MyGame_Example2_Monster|MyGame_Example_Monster|MyGame_Example_TestSimpleTableWithEnum) => MyGame_Example2_Monster|MyGame_Example_Monster|MyGame_Example_TestSimpleTableWithEnum|null -): MyGame_Example2_Monster|MyGame_Example_Monster|MyGame_Example_TestSimpleTableWithEnum|null { - switch(MyGame_Example_Any[type]) { - case 'NONE': return null; - case 'Monster': return accessor(new MyGame_Example_Monster())! as MyGame_Example_Monster; - case 'TestSimpleTableWithEnum': return accessor(new MyGame_Example_TestSimpleTableWithEnum())! as MyGame_Example_TestSimpleTableWithEnum; - case 'MyGame_Example2_Monster': return accessor(new MyGame_Example2_Monster())! as MyGame_Example2_Monster; - default: return null; - } -} - -export function unionListToAny( - type: MyGame_Example_Any, - accessor: (index: number, obj:MyGame_Example2_Monster|MyGame_Example_Monster|MyGame_Example_TestSimpleTableWithEnum) => MyGame_Example2_Monster|MyGame_Example_Monster|MyGame_Example_TestSimpleTableWithEnum|null, - index: number -): MyGame_Example2_Monster|MyGame_Example_Monster|MyGame_Example_TestSimpleTableWithEnum|null { - switch(MyGame_Example_Any[type]) { - case 'NONE': return null; - case 'Monster': return accessor(index, new MyGame_Example_Monster())! as MyGame_Example_Monster; - case 'TestSimpleTableWithEnum': return accessor(index, new MyGame_Example_TestSimpleTableWithEnum())! as MyGame_Example_TestSimpleTableWithEnum; - case 'MyGame_Example2_Monster': return accessor(index, new MyGame_Example2_Monster())! as MyGame_Example2_Monster; - default: return null; - } -} - -export enum MyGame_Example_AnyUniqueAliases { - NONE = 0, - M = 1, - TS = 2, - M2 = 3 -} - -export function unionToAnyUniqueAliases( - type: MyGame_Example_AnyUniqueAliases, - accessor: (obj:MyGame_Example2_Monster|MyGame_Example_Monster|MyGame_Example_TestSimpleTableWithEnum) => MyGame_Example2_Monster|MyGame_Example_Monster|MyGame_Example_TestSimpleTableWithEnum|null -): MyGame_Example2_Monster|MyGame_Example_Monster|MyGame_Example_TestSimpleTableWithEnum|null { - switch(MyGame_Example_AnyUniqueAliases[type]) { - case 'NONE': return null; - case 'M': return accessor(new MyGame_Example_Monster())! as MyGame_Example_Monster; - case 'TS': return accessor(new MyGame_Example_TestSimpleTableWithEnum())! as MyGame_Example_TestSimpleTableWithEnum; - case 'M2': return accessor(new MyGame_Example2_Monster())! as MyGame_Example2_Monster; - default: return null; - } -} - -export function unionListToAnyUniqueAliases( - type: MyGame_Example_AnyUniqueAliases, - accessor: (index: number, obj:MyGame_Example2_Monster|MyGame_Example_Monster|MyGame_Example_TestSimpleTableWithEnum) => MyGame_Example2_Monster|MyGame_Example_Monster|MyGame_Example_TestSimpleTableWithEnum|null, - index: number -): MyGame_Example2_Monster|MyGame_Example_Monster|MyGame_Example_TestSimpleTableWithEnum|null { - switch(MyGame_Example_AnyUniqueAliases[type]) { - case 'NONE': return null; - case 'M': return accessor(index, new MyGame_Example_Monster())! as MyGame_Example_Monster; - case 'TS': return accessor(index, new MyGame_Example_TestSimpleTableWithEnum())! as MyGame_Example_TestSimpleTableWithEnum; - case 'M2': return accessor(index, new MyGame_Example2_Monster())! as MyGame_Example2_Monster; - default: return null; - } -} - -export enum MyGame_Example_AnyAmbiguousAliases { - NONE = 0, - M1 = 1, - M2 = 2, - M3 = 3 -} - -export function unionToAnyAmbiguousAliases( - type: MyGame_Example_AnyAmbiguousAliases, - accessor: (obj:MyGame_Example_Monster) => MyGame_Example_Monster|null -): MyGame_Example_Monster|null { - switch(MyGame_Example_AnyAmbiguousAliases[type]) { - case 'NONE': return null; - case 'M1': return accessor(new MyGame_Example_Monster())! as MyGame_Example_Monster; - case 'M2': return accessor(new MyGame_Example_Monster())! as MyGame_Example_Monster; - case 'M3': return accessor(new MyGame_Example_Monster())! as MyGame_Example_Monster; - default: return null; - } -} - -export function unionListToAnyAmbiguousAliases( - type: MyGame_Example_AnyAmbiguousAliases, - accessor: (index: number, obj:MyGame_Example_Monster) => MyGame_Example_Monster|null, - index: number -): MyGame_Example_Monster|null { - switch(MyGame_Example_AnyAmbiguousAliases[type]) { - case 'NONE': return null; - case 'M1': return accessor(index, new MyGame_Example_Monster())! as MyGame_Example_Monster; - case 'M2': return accessor(index, new MyGame_Example_Monster())! as MyGame_Example_Monster; - case 'M3': return accessor(index, new MyGame_Example_Monster())! as MyGame_Example_Monster; - default: return null; - } -} - -export class MyGame_OtherNameSpace_Unused { - bb: flatbuffers.ByteBuffer|null = null; - bb_pos = 0; - __init(i:number, bb:flatbuffers.ByteBuffer):MyGame_OtherNameSpace_Unused { - this.bb_pos = i; - this.bb = bb; - return this; -} - -a():number { - return this.bb!.readInt32(this.bb_pos); -} - -static sizeOf():number { - return 4; -} - -static createUnused(builder:flatbuffers.Builder, a: number):flatbuffers.Offset { - builder.prep(4, 4); - builder.writeInt32(a); - return builder.offset(); -} - -} - -export class MyGame_OtherNameSpace_TableB { - bb: flatbuffers.ByteBuffer|null = null; - bb_pos = 0; - __init(i:number, bb:flatbuffers.ByteBuffer):MyGame_OtherNameSpace_TableB { - this.bb_pos = i; - this.bb = bb; - return this; -} - -static getRootAsTableB(bb:flatbuffers.ByteBuffer, obj?:MyGame_OtherNameSpace_TableB):MyGame_OtherNameSpace_TableB { - return (obj || new MyGame_OtherNameSpace_TableB()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -} - -static getSizePrefixedRootAsTableB(bb:flatbuffers.ByteBuffer, obj?:MyGame_OtherNameSpace_TableB):MyGame_OtherNameSpace_TableB { - bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); - return (obj || new MyGame_OtherNameSpace_TableB()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -} - -a(obj?:TableA):TableA|null { - const offset = this.bb!.__offset(this.bb_pos, 4); - return offset ? (obj || new TableA()).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null; -} - -static startTableB(builder:flatbuffers.Builder) { - builder.startObject(1); -} - -static addA(builder:flatbuffers.Builder, aOffset:flatbuffers.Offset) { - builder.addFieldOffset(0, aOffset, 0); -} - -static endTableB(builder:flatbuffers.Builder):flatbuffers.Offset { - const offset = builder.endObject(); - return offset; -} - -static createTableB(builder:flatbuffers.Builder, aOffset:flatbuffers.Offset):flatbuffers.Offset { - MyGame_OtherNameSpace_TableB.startTableB(builder); - MyGame_OtherNameSpace_TableB.addA(builder, aOffset); - return MyGame_OtherNameSpace_TableB.endTableB(builder); -} - -serialize():Uint8Array { - return this.bb!.bytes(); -} - -static deserialize(buffer: Uint8Array):TableB { - return MyGame_OtherNameSpace_TableB.getRootAsTableB(new flatbuffers.ByteBuffer(buffer)) -} -} - -export class TableA { - bb: flatbuffers.ByteBuffer|null = null; - bb_pos = 0; - __init(i:number, bb:flatbuffers.ByteBuffer):TableA { - this.bb_pos = i; - this.bb = bb; - return this; -} - -static getRootAsTableA(bb:flatbuffers.ByteBuffer, obj?:TableA):TableA { - return (obj || new TableA()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -} - -static getSizePrefixedRootAsTableA(bb:flatbuffers.ByteBuffer, obj?:TableA):TableA { - bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); - return (obj || new TableA()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -} - -b(obj?:MyGame_OtherNameSpace_TableB):MyGame_OtherNameSpace_TableB|null { - const offset = this.bb!.__offset(this.bb_pos, 4); - return offset ? (obj || new MyGame_OtherNameSpace_TableB()).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null; -} - -static startTableA(builder:flatbuffers.Builder) { - builder.startObject(1); -} - -static addB(builder:flatbuffers.Builder, bOffset:flatbuffers.Offset) { - builder.addFieldOffset(0, bOffset, 0); -} - -static endTableA(builder:flatbuffers.Builder):flatbuffers.Offset { - const offset = builder.endObject(); - return offset; -} - -static createTableA(builder:flatbuffers.Builder, bOffset:flatbuffers.Offset):flatbuffers.Offset { - TableA.startTableA(builder); - TableA.addB(builder, bOffset); - return TableA.endTableA(builder); -} - -serialize():Uint8Array { - return this.bb!.bytes(); -} - -static deserialize(buffer: Uint8Array):TableA { - return TableA.getRootAsTableA(new flatbuffers.ByteBuffer(buffer)) -} -} - -export class MyGame_InParentNamespace { - bb: flatbuffers.ByteBuffer|null = null; - bb_pos = 0; - __init(i:number, bb:flatbuffers.ByteBuffer):MyGame_InParentNamespace { - this.bb_pos = i; - this.bb = bb; - return this; -} - -static getRootAsInParentNamespace(bb:flatbuffers.ByteBuffer, obj?:MyGame_InParentNamespace):MyGame_InParentNamespace { - return (obj || new MyGame_InParentNamespace()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -} - -static getSizePrefixedRootAsInParentNamespace(bb:flatbuffers.ByteBuffer, obj?:MyGame_InParentNamespace):MyGame_InParentNamespace { - bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); - return (obj || new MyGame_InParentNamespace()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -} - -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 { - MyGame_InParentNamespace.startInParentNamespace(builder); - return MyGame_InParentNamespace.endInParentNamespace(builder); -} - -serialize():Uint8Array { - return this.bb!.bytes(); -} - -static deserialize(buffer: Uint8Array):InParentNamespace { - return MyGame_InParentNamespace.getRootAsInParentNamespace(new flatbuffers.ByteBuffer(buffer)) -} -} - -export class MyGame_Example2_Monster { - bb: flatbuffers.ByteBuffer|null = null; - bb_pos = 0; - __init(i:number, bb:flatbuffers.ByteBuffer):MyGame_Example2_Monster { - this.bb_pos = i; - this.bb = bb; - return this; -} - -static getRootAsMonster(bb:flatbuffers.ByteBuffer, obj?:MyGame_Example2_Monster):MyGame_Example2_Monster { - return (obj || new MyGame_Example2_Monster()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -} - -static getSizePrefixedRootAsMonster(bb:flatbuffers.ByteBuffer, obj?:MyGame_Example2_Monster):MyGame_Example2_Monster { - bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); - return (obj || new MyGame_Example2_Monster()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -} - -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 { - MyGame_Example2_Monster.startMonster(builder); - return MyGame_Example2_Monster.endMonster(builder); -} - -serialize():Uint8Array { - return this.bb!.bytes(); -} - -static deserialize(buffer: Uint8Array):Monster { - return MyGame_Example2_Monster.getRootAsMonster(new flatbuffers.ByteBuffer(buffer)) -} -} - -export class MyGame_Example_Test { - bb: flatbuffers.ByteBuffer|null = null; - bb_pos = 0; - __init(i:number, bb:flatbuffers.ByteBuffer):MyGame_Example_Test { - this.bb_pos = i; - this.bb = bb; - return this; -} - -a():number { - return this.bb!.readInt16(this.bb_pos); -} - -b():number { - return this.bb!.readInt8(this.bb_pos + 2); -} - -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(); -} - -} - -export class MyGame_Example_TestSimpleTableWithEnum { - bb: flatbuffers.ByteBuffer|null = null; - bb_pos = 0; - __init(i:number, bb:flatbuffers.ByteBuffer):MyGame_Example_TestSimpleTableWithEnum { - this.bb_pos = i; - this.bb = bb; - return this; -} - -static getRootAsTestSimpleTableWithEnum(bb:flatbuffers.ByteBuffer, obj?:MyGame_Example_TestSimpleTableWithEnum):MyGame_Example_TestSimpleTableWithEnum { - return (obj || new MyGame_Example_TestSimpleTableWithEnum()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -} - -static getSizePrefixedRootAsTestSimpleTableWithEnum(bb:flatbuffers.ByteBuffer, obj?:MyGame_Example_TestSimpleTableWithEnum):MyGame_Example_TestSimpleTableWithEnum { - bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); - return (obj || new MyGame_Example_TestSimpleTableWithEnum()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -} - -color():MyGame_Example_Color { - const offset = this.bb!.__offset(this.bb_pos, 4); - return offset ? this.bb!.readUint8(this.bb_pos + offset) : MyGame_Example_Color.Green; -} - -static startTestSimpleTableWithEnum(builder:flatbuffers.Builder) { - builder.startObject(1); -} - -static addColor(builder:flatbuffers.Builder, color:MyGame_Example_Color) { - builder.addFieldInt8(0, color, MyGame_Example_Color.Green); -} - -static endTestSimpleTableWithEnum(builder:flatbuffers.Builder):flatbuffers.Offset { - const offset = builder.endObject(); - return offset; -} - -static createTestSimpleTableWithEnum(builder:flatbuffers.Builder, color:MyGame_Example_Color):flatbuffers.Offset { - MyGame_Example_TestSimpleTableWithEnum.startTestSimpleTableWithEnum(builder); - MyGame_Example_TestSimpleTableWithEnum.addColor(builder, color); - return MyGame_Example_TestSimpleTableWithEnum.endTestSimpleTableWithEnum(builder); -} - -serialize():Uint8Array { - return this.bb!.bytes(); -} - -static deserialize(buffer: Uint8Array):TestSimpleTableWithEnum { - return MyGame_Example_TestSimpleTableWithEnum.getRootAsTestSimpleTableWithEnum(new flatbuffers.ByteBuffer(buffer)) -} -} - -export class MyGame_Example_Vec3 { - bb: flatbuffers.ByteBuffer|null = null; - bb_pos = 0; - __init(i:number, bb:flatbuffers.ByteBuffer):MyGame_Example_Vec3 { - this.bb_pos = i; - this.bb = bb; - return this; -} - -x():number { - return this.bb!.readFloat32(this.bb_pos); -} - -y():number { - return this.bb!.readFloat32(this.bb_pos + 4); -} - -z():number { - return this.bb!.readFloat32(this.bb_pos + 8); -} - -test1():number { - return this.bb!.readFloat64(this.bb_pos + 16); -} - -test2():MyGame_Example_Color { - return this.bb!.readUint8(this.bb_pos + 24); -} - -test3(obj?:MyGame_Example_Test):MyGame_Example_Test|null { - return (obj || new MyGame_Example_Test()).__init(this.bb_pos + 26, this.bb!); -} - -static sizeOf():number { - return 32; -} - -static createVec3(builder:flatbuffers.Builder, x: number, y: number, z: number, test1: number, test2: MyGame_Example_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(); -} - -} - -export class MyGame_Example_Ability { - bb: flatbuffers.ByteBuffer|null = null; - bb_pos = 0; - __init(i:number, bb:flatbuffers.ByteBuffer):MyGame_Example_Ability { - this.bb_pos = i; - this.bb = bb; - return this; -} - -id():number { - return this.bb!.readUint32(this.bb_pos); -} - -distance():number { - return this.bb!.readUint32(this.bb_pos + 4); -} - -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(); -} - -} - -export class MyGame_Example_StructOfStructs { - bb: flatbuffers.ByteBuffer|null = null; - bb_pos = 0; - __init(i:number, bb:flatbuffers.ByteBuffer):MyGame_Example_StructOfStructs { - this.bb_pos = i; - this.bb = bb; - return this; -} - -a(obj?:MyGame_Example_Ability):MyGame_Example_Ability|null { - return (obj || new MyGame_Example_Ability()).__init(this.bb_pos, this.bb!); -} - -b(obj?:MyGame_Example_Test):MyGame_Example_Test|null { - return (obj || new MyGame_Example_Test()).__init(this.bb_pos + 8, this.bb!); -} - -c(obj?:MyGame_Example_Ability):MyGame_Example_Ability|null { - return (obj || new MyGame_Example_Ability()).__init(this.bb_pos + 12, this.bb!); -} - -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(); -} - -} - -export class MyGame_Example_StructOfStructsOfStructs { - bb: flatbuffers.ByteBuffer|null = null; - bb_pos = 0; - __init(i:number, bb:flatbuffers.ByteBuffer):MyGame_Example_StructOfStructsOfStructs { - this.bb_pos = i; - this.bb = bb; - return this; -} - -a(obj?:MyGame_Example_StructOfStructs):MyGame_Example_StructOfStructs|null { - return (obj || new MyGame_Example_StructOfStructs()).__init(this.bb_pos, this.bb!); -} - -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(); -} - -} - -export class MyGame_Example_Stat { - bb: flatbuffers.ByteBuffer|null = null; - bb_pos = 0; - __init(i:number, bb:flatbuffers.ByteBuffer):MyGame_Example_Stat { - this.bb_pos = i; - this.bb = bb; - return this; -} - -static getRootAsStat(bb:flatbuffers.ByteBuffer, obj?:MyGame_Example_Stat):MyGame_Example_Stat { - return (obj || new MyGame_Example_Stat()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -} - -static getSizePrefixedRootAsStat(bb:flatbuffers.ByteBuffer, obj?:MyGame_Example_Stat):MyGame_Example_Stat { - bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); - return (obj || new MyGame_Example_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'); -} - -count():number { - const offset = this.bb!.__offset(this.bb_pos, 8); - return offset ? this.bb!.readUint16(this.bb_pos + offset) : 0; -} - -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 { - MyGame_Example_Stat.startStat(builder); - MyGame_Example_Stat.addId(builder, idOffset); - MyGame_Example_Stat.addVal(builder, val); - MyGame_Example_Stat.addCount(builder, count); - return MyGame_Example_Stat.endStat(builder); -} - -serialize():Uint8Array { - return this.bb!.bytes(); -} - -static deserialize(buffer: Uint8Array):Stat { - return MyGame_Example_Stat.getRootAsStat(new flatbuffers.ByteBuffer(buffer)) -} -} - -export class MyGame_Example_Referrable { - bb: flatbuffers.ByteBuffer|null = null; - bb_pos = 0; - __init(i:number, bb:flatbuffers.ByteBuffer):MyGame_Example_Referrable { - this.bb_pos = i; - this.bb = bb; - return this; -} - -static getRootAsReferrable(bb:flatbuffers.ByteBuffer, obj?:MyGame_Example_Referrable):MyGame_Example_Referrable { - return (obj || new MyGame_Example_Referrable()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -} - -static getSizePrefixedRootAsReferrable(bb:flatbuffers.ByteBuffer, obj?:MyGame_Example_Referrable):MyGame_Example_Referrable { - bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); - return (obj || new MyGame_Example_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'); -} - -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 { - MyGame_Example_Referrable.startReferrable(builder); - MyGame_Example_Referrable.addId(builder, id); - return MyGame_Example_Referrable.endReferrable(builder); -} - -serialize():Uint8Array { - return this.bb!.bytes(); -} - -static deserialize(buffer: Uint8Array):Referrable { - return MyGame_Example_Referrable.getRootAsReferrable(new flatbuffers.ByteBuffer(buffer)) -} -} - -/** - * an example documentation comment: "monster object" - */ -export class MyGame_Example_Monster { - bb: flatbuffers.ByteBuffer|null = null; - bb_pos = 0; - __init(i:number, bb:flatbuffers.ByteBuffer):MyGame_Example_Monster { - this.bb_pos = i; - this.bb = bb; - return this; -} - -static getRootAsMonster(bb:flatbuffers.ByteBuffer, obj?:MyGame_Example_Monster):MyGame_Example_Monster { - return (obj || new MyGame_Example_Monster()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -} - -static getSizePrefixedRootAsMonster(bb:flatbuffers.ByteBuffer, obj?:MyGame_Example_Monster):MyGame_Example_Monster { - bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); - return (obj || new MyGame_Example_Monster()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -} - -static bufferHasIdentifier(bb:flatbuffers.ByteBuffer):boolean { - return bb.__has_identifier('MONS'); -} - -pos(obj?:MyGame_Example_Vec3):MyGame_Example_Vec3|null { - const offset = this.bb!.__offset(this.bb_pos, 4); - return offset ? (obj || new MyGame_Example_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; -} - -hp():number { - const offset = this.bb!.__offset(this.bb_pos, 8); - return offset ? this.bb!.readInt16(this.bb_pos + offset) : 100; -} - -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():MyGame_Example_Color { - const offset = this.bb!.__offset(this.bb_pos, 16); - return offset ? this.bb!.readUint8(this.bb_pos + offset) : MyGame_Example_Color.Blue; -} - -testType():MyGame_Example_Any { - const offset = this.bb!.__offset(this.bb_pos, 18); - return offset ? this.bb!.readUint8(this.bb_pos + offset) : MyGame_Example_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?:MyGame_Example_Test):MyGame_Example_Test|null { - const offset = this.bb!.__offset(this.bb_pos, 22); - return offset ? (obj || new MyGame_Example_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?:MyGame_Example_Monster):MyGame_Example_Monster|null { - const offset = this.bb!.__offset(this.bb_pos, 26); - return offset ? (obj || new MyGame_Example_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?:MyGame_Example_Monster):MyGame_Example_Monster|null { - const offset = this.bb!.__offset(this.bb_pos, 28); - return offset ? (obj || new MyGame_Example_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?:MyGame_Example_Stat):MyGame_Example_Stat|null { - const offset = this.bb!.__offset(this.bb_pos, 32); - return offset ? (obj || new MyGame_Example_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; -} - -testhashs32Fnv1():number { - const offset = this.bb!.__offset(this.bb_pos, 36); - return offset ? this.bb!.readInt32(this.bb_pos + offset) : 0; -} - -testhashu32Fnv1():number { - const offset = this.bb!.__offset(this.bb_pos, 38); - return offset ? this.bb!.readUint32(this.bb_pos + offset) : 0; -} - -testhashs64Fnv1():bigint { - const offset = this.bb!.__offset(this.bb_pos, 40); - return offset ? this.bb!.readInt64(this.bb_pos + offset) : BigInt('0'); -} - -testhashu64Fnv1():bigint { - const offset = this.bb!.__offset(this.bb_pos, 42); - return offset ? this.bb!.readUint64(this.bb_pos + offset) : BigInt('0'); -} - -testhashs32Fnv1a():number { - const offset = this.bb!.__offset(this.bb_pos, 44); - return offset ? this.bb!.readInt32(this.bb_pos + offset) : 0; -} - -testhashu32Fnv1a():number { - const offset = this.bb!.__offset(this.bb_pos, 46); - return offset ? this.bb!.readUint32(this.bb_pos + offset) : 0; -} - -testhashs64Fnv1a():bigint { - const offset = this.bb!.__offset(this.bb_pos, 48); - return offset ? this.bb!.readInt64(this.bb_pos + offset) : BigInt('0'); -} - -testhashu64Fnv1a():bigint { - const offset = this.bb!.__offset(this.bb_pos, 50); - return offset ? this.bb!.readUint64(this.bb_pos + offset) : BigInt('0'); -} - -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; -} - -testf2():number { - const offset = this.bb!.__offset(this.bb_pos, 56); - return offset ? this.bb!.readFloat32(this.bb_pos + offset) : 3.0; -} - -testf3():number { - const offset = this.bb!.__offset(this.bb_pos, 58); - return offset ? this.bb!.readFloat32(this.bb_pos + offset) : 0.0; -} - -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?:MyGame_Example_Ability):MyGame_Example_Ability|null { - const offset = this.bb!.__offset(this.bb_pos, 62); - return offset ? (obj || new MyGame_Example_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?:MyGame_Example_Test):MyGame_Example_Test|null { - const offset = this.bb!.__offset(this.bb_pos, 66); - return offset ? (obj || new MyGame_Example_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?:MyGame_InParentNamespace):MyGame_InParentNamespace|null { - const offset = this.bb!.__offset(this.bb_pos, 72); - return offset ? (obj || new MyGame_InParentNamespace()).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null; -} - -vectorOfReferrables(index: number, obj?:MyGame_Example_Referrable):MyGame_Example_Referrable|null { - const offset = this.bb!.__offset(this.bb_pos, 74); - return offset ? (obj || new MyGame_Example_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'); -} - -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?:MyGame_Example_Referrable):MyGame_Example_Referrable|null { - const offset = this.bb!.__offset(this.bb_pos, 80); - return offset ? (obj || new MyGame_Example_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'); -} - -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'); -} - -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():MyGame_Example_AnyUniqueAliases { - const offset = this.bb!.__offset(this.bb_pos, 90); - return offset ? this.bb!.readUint8(this.bb_pos + offset) : MyGame_Example_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():MyGame_Example_AnyAmbiguousAliases { - const offset = this.bb!.__offset(this.bb_pos, 94); - return offset ? this.bb!.readUint8(this.bb_pos + offset) : MyGame_Example_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):MyGame_Example_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():MyGame_Example_Race { - const offset = this.bb!.__offset(this.bb_pos, 100); - return offset ? this.bb!.readInt8(this.bb_pos + offset) : MyGame_Example_Race.None; -} - -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?:MyGame_Example_Stat):MyGame_Example_Stat|null { - const offset = this.bb!.__offset(this.bb_pos, 104); - return offset ? (obj || new MyGame_Example_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?:MyGame_Example_Test):MyGame_Example_Test|null { - const offset = this.bb!.__offset(this.bb_pos, 106); - return offset ? (obj || new MyGame_Example_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'); -} - -longEnumNormalDefault():bigint { - const offset = this.bb!.__offset(this.bb_pos, 110); - return offset ? this.bb!.readUint64(this.bb_pos + offset) : BigInt('2'); -} - -nanDefault():number { - const offset = this.bb!.__offset(this.bb_pos, 112); - return offset ? this.bb!.readFloat32(this.bb_pos + offset) : NaN; -} - -infDefault():number { - const offset = this.bb!.__offset(this.bb_pos, 114); - return offset ? this.bb!.readFloat32(this.bb_pos + offset) : Infinity; -} - -positiveInfDefault():number { - const offset = this.bb!.__offset(this.bb_pos, 116); - return offset ? this.bb!.readFloat32(this.bb_pos + offset) : Infinity; -} - -infinityDefault():number { - const offset = this.bb!.__offset(this.bb_pos, 118); - return offset ? this.bb!.readFloat32(this.bb_pos + offset) : Infinity; -} - -positiveInfinityDefault():number { - const offset = this.bb!.__offset(this.bb_pos, 120); - return offset ? this.bb!.readFloat32(this.bb_pos + offset) : Infinity; -} - -negativeInfDefault():number { - const offset = this.bb!.__offset(this.bb_pos, 122); - return offset ? this.bb!.readFloat32(this.bb_pos + offset) : -Infinity; -} - -negativeInfinityDefault():number { - const offset = this.bb!.__offset(this.bb_pos, 124); - return offset ? this.bb!.readFloat32(this.bb_pos + offset) : -Infinity; -} - -doubleInfDefault():number { - const offset = this.bb!.__offset(this.bb_pos, 126); - return offset ? this.bb!.readFloat64(this.bb_pos + offset) : Infinity; -} - -static startMonster(builder:flatbuffers.Builder) { - builder.startObject(62); -} - -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:MyGame_Example_Color) { - builder.addFieldInt8(6, color, MyGame_Example_Color.Blue); -} - -static addTestType(builder:flatbuffers.Builder, testType:MyGame_Example_Any) { - builder.addFieldInt8(7, testType, MyGame_Example_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:MyGame_Example_AnyUniqueAliases) { - builder.addFieldInt8(43, anyUniqueType, MyGame_Example_AnyUniqueAliases.NONE); -} - -static addAnyUnique(builder:flatbuffers.Builder, anyUniqueOffset:flatbuffers.Offset) { - builder.addFieldOffset(44, anyUniqueOffset, 0); -} - -static addAnyAmbiguousType(builder:flatbuffers.Builder, anyAmbiguousType:MyGame_Example_AnyAmbiguousAliases) { - builder.addFieldInt8(45, anyAmbiguousType, MyGame_Example_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:MyGame_Example_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:MyGame_Example_Race) { - builder.addFieldInt8(48, signedEnum, MyGame_Example_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 addNanDefault(builder:flatbuffers.Builder, nanDefault:number) { - builder.addFieldFloat32(54, nanDefault, NaN); -} - -static addInfDefault(builder:flatbuffers.Builder, infDefault:number) { - builder.addFieldFloat32(55, infDefault, Infinity); -} - -static addPositiveInfDefault(builder:flatbuffers.Builder, positiveInfDefault:number) { - builder.addFieldFloat32(56, positiveInfDefault, Infinity); -} - -static addInfinityDefault(builder:flatbuffers.Builder, infinityDefault:number) { - builder.addFieldFloat32(57, infinityDefault, Infinity); -} - -static addPositiveInfinityDefault(builder:flatbuffers.Builder, positiveInfinityDefault:number) { - builder.addFieldFloat32(58, positiveInfinityDefault, Infinity); -} - -static addNegativeInfDefault(builder:flatbuffers.Builder, negativeInfDefault:number) { - builder.addFieldFloat32(59, negativeInfDefault, -Infinity); -} - -static addNegativeInfinityDefault(builder:flatbuffers.Builder, negativeInfinityDefault:number) { - builder.addFieldFloat32(60, negativeInfinityDefault, -Infinity); -} - -static addDoubleInfDefault(builder:flatbuffers.Builder, doubleInfDefault:number) { - builder.addFieldFloat64(61, doubleInfDefault, Infinity); -} - -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 MyGame_Example_Monster.getRootAsMonster(new flatbuffers.ByteBuffer(buffer)) -} -} - -export class MyGame_Example_TypeAliases { - bb: flatbuffers.ByteBuffer|null = null; - bb_pos = 0; - __init(i:number, bb:flatbuffers.ByteBuffer):MyGame_Example_TypeAliases { - this.bb_pos = i; - this.bb = bb; - return this; -} - -static getRootAsTypeAliases(bb:flatbuffers.ByteBuffer, obj?:MyGame_Example_TypeAliases):MyGame_Example_TypeAliases { - return (obj || new MyGame_Example_TypeAliases()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -} - -static getSizePrefixedRootAsTypeAliases(bb:flatbuffers.ByteBuffer, obj?:MyGame_Example_TypeAliases):MyGame_Example_TypeAliases { - bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); - return (obj || new MyGame_Example_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; -} - -u8():number { - const offset = this.bb!.__offset(this.bb_pos, 6); - return offset ? this.bb!.readUint8(this.bb_pos + offset) : 0; -} - -i16():number { - const offset = this.bb!.__offset(this.bb_pos, 8); - return offset ? this.bb!.readInt16(this.bb_pos + offset) : 0; -} - -u16():number { - const offset = this.bb!.__offset(this.bb_pos, 10); - return offset ? this.bb!.readUint16(this.bb_pos + offset) : 0; -} - -i32():number { - const offset = this.bb!.__offset(this.bb_pos, 12); - return offset ? this.bb!.readInt32(this.bb_pos + offset) : 0; -} - -u32():number { - const offset = this.bb!.__offset(this.bb_pos, 14); - return offset ? this.bb!.readUint32(this.bb_pos + offset) : 0; -} - -i64():bigint { - const offset = this.bb!.__offset(this.bb_pos, 16); - return offset ? this.bb!.readInt64(this.bb_pos + offset) : BigInt('0'); -} - -u64():bigint { - const offset = this.bb!.__offset(this.bb_pos, 18); - return offset ? this.bb!.readUint64(this.bb_pos + offset) : BigInt('0'); -} - -f32():number { - const offset = this.bb!.__offset(this.bb_pos, 20); - return offset ? this.bb!.readFloat32(this.bb_pos + offset) : 0.0; -} - -f64():number { - const offset = this.bb!.__offset(this.bb_pos, 22); - return offset ? this.bb!.readFloat64(this.bb_pos + offset) : 0.0; -} - -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 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 { - MyGame_Example_TypeAliases.startTypeAliases(builder); - MyGame_Example_TypeAliases.addI8(builder, i8); - MyGame_Example_TypeAliases.addU8(builder, u8); - MyGame_Example_TypeAliases.addI16(builder, i16); - MyGame_Example_TypeAliases.addU16(builder, u16); - MyGame_Example_TypeAliases.addI32(builder, i32); - MyGame_Example_TypeAliases.addU32(builder, u32); - MyGame_Example_TypeAliases.addI64(builder, i64); - MyGame_Example_TypeAliases.addU64(builder, u64); - MyGame_Example_TypeAliases.addF32(builder, f32); - MyGame_Example_TypeAliases.addF64(builder, f64); - MyGame_Example_TypeAliases.addV8(builder, v8Offset); - MyGame_Example_TypeAliases.addVf64(builder, vf64Offset); - return MyGame_Example_TypeAliases.endTypeAliases(builder); -} - -serialize():Uint8Array { - return this.bb!.bytes(); -} - -static deserialize(buffer: Uint8Array):TypeAliases { - return MyGame_Example_TypeAliases.getRootAsTypeAliases(new flatbuffers.ByteBuffer(buffer)) -} -} - diff --git a/tests/ts/typescript_keywords_generated.js b/tests/ts/typescript_keywords_generated.js index 56d9364f7f3..74e00dccb31 100644 --- a/tests/ts/typescript_keywords_generated.js +++ b/tests/ts/typescript_keywords_generated.js @@ -53,10 +53,80 @@ var flatbuffers10 = __toESM(require("flatbuffers"), 1); var flatbuffers4 = __toESM(require("flatbuffers"), 1); // reflection/enum-val.js -var flatbuffers2 = __toESM(require("flatbuffers"), 1); +var flatbuffers3 = __toESM(require("flatbuffers"), 1); -// reflection/type.js +// reflection/key-value.js var flatbuffers = __toESM(require("flatbuffers"), 1); +var KeyValue = class { + 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); + 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(); + } +}; +var KeyValueT = class { + 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); + } +}; + +// reflection/type.js +var flatbuffers2 = __toESM(require("flatbuffers"), 1); // reflection/base-type.js var BaseType; @@ -97,7 +167,7 @@ var Type = class { return (obj || new Type()).__init(bb.readInt32(bb.position()) + bb.position(), bb); } static getSizePrefixedRootAsType(bb, obj) { - bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); + bb.setPosition(bb.position() + flatbuffers2.SIZE_PREFIX_LENGTH); return (obj || new Type()).__init(bb.readInt32(bb.position()) + bb.position(), bb); } baseType() { @@ -251,7 +321,7 @@ var EnumVal = class { return (obj || new EnumVal()).__init(bb.readInt32(bb.position()) + bb.position(), bb); } static getSizePrefixedRootAsEnumVal(bb, obj) { - bb.setPosition(bb.position() + flatbuffers2.SIZE_PREFIX_LENGTH); + bb.setPosition(bb.position() + flatbuffers3.SIZE_PREFIX_LENGTH); return (obj || new EnumVal()).__init(bb.readInt32(bb.position()) + bb.position(), bb); } name(optionalEncoding) { @@ -282,11 +352,19 @@ var EnumVal = class { const offset = this.bb.__offset(this.bb_pos, 12); return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; } + 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; + } static getFullyQualifiedName() { return "reflection_EnumVal"; } static startEnumVal(builder) { - builder.startObject(5); + builder.startObject(6); } static addName(builder, nameOffset) { builder.addFieldOffset(0, nameOffset, 0); @@ -310,111 +388,58 @@ var EnumVal = class { static startDocumentationVector(builder, numElems) { builder.startVector(4, numElems, 4); } + 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 endEnumVal(builder) { const offset = builder.endObject(); builder.requiredField(offset, 4); 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())); + return new EnumValT(this.name(), this.value(), this.unionType() !== null ? this.unionType().unpack() : null, this.bb.createScalarList(this.documentation.bind(this), this.documentationLength()), this.bb.createObjList(this.attributes.bind(this), this.attributesLength())); } 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()); + _o.attributes = this.bb.createObjList(this.attributes.bind(this), this.attributesLength()); } }; var EnumValT = class { - constructor(name = null, value = BigInt("0"), unionType = null, documentation = []) { + constructor(name = null, value = BigInt("0"), unionType = null, documentation = [], attributes = []) { this.name = name; this.value = value; this.unionType = unionType; this.documentation = documentation; + this.attributes = attributes; } 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)); + const attributes = EnumVal.createAttributesVector(builder, builder.createObjectOffsetList(this.attributes)); EnumVal.startEnumVal(builder); EnumVal.addName(builder, name); EnumVal.addValue(builder, this.value); EnumVal.addUnionType(builder, unionType); EnumVal.addDocumentation(builder, documentation); + EnumVal.addAttributes(builder, attributes); return EnumVal.endEnumVal(builder); } }; -// reflection/key-value.js -var flatbuffers3 = __toESM(require("flatbuffers"), 1); -var KeyValue = class { - 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() + flatbuffers3.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); - 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(); - } -}; -var KeyValueT = class { - 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); - } -}; - // reflection/enum.js var Enum = class { constructor() { diff --git a/tests/ts/union_vector.ts b/tests/ts/union_vector.ts deleted file mode 100644 index 60d840fc188..00000000000 --- a/tests/ts/union_vector.ts +++ /dev/null @@ -1,10 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -export { Attacker } from './union_vector/attacker.js'; -export { BookReader } from './union_vector/book-reader.js'; -export { Character } from './union_vector/character.js'; -export { FallingTub } from './union_vector/falling-tub.js'; -export { Gadget } from './union_vector/gadget.js'; -export { HandFan } from './union_vector/hand-fan.js'; -export { Movie } from './union_vector/movie.js'; -export { Rapunzel } from './union_vector/rapunzel.js'; diff --git a/tests/ts/union_vector/union_vector.js b/tests/ts/union_vector/union_vector.js new file mode 100644 index 00000000000..29b895f59f8 --- /dev/null +++ b/tests/ts/union_vector/union_vector.js @@ -0,0 +1,9 @@ +// automatically generated by the FlatBuffers compiler, do not modify +export { Attacker } from './attacker.js'; +export { BookReader } from './book-reader.js'; +export { Character } from './character.js'; +export { FallingTub } from './falling-tub.js'; +export { Gadget } from './gadget.js'; +export { HandFan } from './hand-fan.js'; +export { Movie } from './movie.js'; +export { Rapunzel } from './rapunzel.js'; diff --git a/tests/ts/union_vector/union_vector.ts b/tests/ts/union_vector/union_vector.ts new file mode 100644 index 00000000000..22209859ecd --- /dev/null +++ b/tests/ts/union_vector/union_vector.ts @@ -0,0 +1,10 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +export { Attacker } from './attacker.js'; +export { BookReader } from './book-reader.js'; +export { Character } from './character.js'; +export { FallingTub } from './falling-tub.js'; +export { Gadget } from './gadget.js'; +export { HandFan } from './hand-fan.js'; +export { Movie } from './movie.js'; +export { Rapunzel } from './rapunzel.js'; diff --git a/tests/ts/union_vector/union_vector_generated.js b/tests/ts/union_vector/union_vector_generated.js index 5f0006a2755..0677b13754f 100644 --- a/tests/ts/union_vector/union_vector_generated.js +++ b/tests/ts/union_vector/union_vector_generated.js @@ -23,7 +23,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge )); var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); -// union_vector.ts +// union_vector/union_vector.ts var union_vector_exports = {}; __export(union_vector_exports, { Attacker: () => Attacker, From b4a17f5151f50aa52843acb54eb5c81d7b822387 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Harrtell?= Date: Sat, 12 Nov 2022 15:11:55 +0100 Subject: [PATCH 03/39] Attempt to fix generate_code --- scripts/generate_code.py | 32 +++++++++++++------------------- 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/scripts/generate_code.py b/scripts/generate_code.py index aa990c1d9e5..0e7e03a0cda 100755 --- a/scripts/generate_code.py +++ b/scripts/generate_code.py @@ -182,9 +182,9 @@ def glob(path, pattern): flatc( NO_INCL_OPTS + TS_OPTS, - schema="monster_test.fbs", - prefix="ts", - include="include_test", + cwd="ts", + schema="../monster_test.fbs", + include="../include_test", data="monsterdata_test.json", ) @@ -250,36 +250,30 @@ def glob(path, pattern): flatc( BASE_OPTS + TS_OPTS, - prefix="ts/union_vector", + cwd="ts", + prefix="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", -) - -# Generate the complete flat file TS of monster. -flatc( - ["--ts", "--gen-all"], - include="include_test", - schema="monster_test.fbs", - prefix="ts/ts-flat-files" + cwd="ts", + include="../include_test", + schema="../monster_test.fbs", ) flatc( BASE_OPTS + TS_OPTS + ["-b"], - include="include_test", - prefix="ts", + cwd="ts", + include="../include_test", schema="monster_test.fbs", data="unicode_test.json", ) flatc( BASE_OPTS + TS_OPTS + ["--gen-name-strings"], - prefix="ts/union_vector", + cwd="ts", + prefix="union_vector", schema="union_vector/union_vector.fbs", ) @@ -380,7 +374,7 @@ def glob(path, pattern): # Optional Scalars optional_scalars_schema = "optional_scalars.fbs" flatc(["--java", "--kotlin", "--lobster"], schema=optional_scalars_schema) -flatc(TS_OPTS, schema=optional_scalars_schema, prefix="ts") +flatc(TS_OPTS, cwd="ts", schema=optional_scalars_schema) flatc(["--csharp", "--python", "--gen-object-api"], schema=optional_scalars_schema) From fa26bdf22c1e28ab6e698dca8dd1407ae5151cfc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Harrtell?= Date: Mon, 14 Nov 2022 18:28:16 +0100 Subject: [PATCH 04/39] Fix cwd for ts in generate_code --- grpc/examples/ts/greeter/src/models.ts | 4 ++++ scripts/generate_code.py | 23 ++++++++++++----------- 2 files changed, 16 insertions(+), 11 deletions(-) create mode 100644 grpc/examples/ts/greeter/src/models.ts diff --git a/grpc/examples/ts/greeter/src/models.ts b/grpc/examples/ts/greeter/src/models.ts new file mode 100644 index 00000000000..c48afe53845 --- /dev/null +++ b/grpc/examples/ts/greeter/src/models.ts @@ -0,0 +1,4 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +export { HelloReply } from './models/hello-reply.js'; +export { HelloRequest } from './models/hello-request.js'; diff --git a/scripts/generate_code.py b/scripts/generate_code.py index 41888667b06..0475e035ece 100755 --- a/scripts/generate_code.py +++ b/scripts/generate_code.py @@ -65,6 +65,7 @@ # Specify the other paths that will be referenced tests_path = Path(root_path, "tests") swift_code_gen = Path(root_path, "tests/swift/tests/CodeGenerationTests") +ts_code_gen = Path(root_path, "tests/ts") samples_path = Path(root_path, "samples") reflection_path = Path(root_path, "reflection") @@ -182,10 +183,10 @@ def glob(path, pattern): flatc( NO_INCL_OPTS + TS_OPTS, - cwd="ts", + cwd=ts_code_gen, schema="../monster_test.fbs", include="../include_test", - data="monsterdata_test.json", + data="../monsterdata_test.json", ) flatc( @@ -250,31 +251,31 @@ def glob(path, pattern): flatc( BASE_OPTS + TS_OPTS, - cwd="ts", + cwd=ts_code_gen, prefix="union_vector", - schema="union_vector/union_vector.fbs", + schema="../union_vector/union_vector.fbs", ) flatc( BASE_OPTS + TS_OPTS + ["--gen-name-strings", "--gen-mutable"], - cwd="ts", + cwd=ts_code_gen, include="../include_test", schema="../monster_test.fbs", ) flatc( BASE_OPTS + TS_OPTS + ["-b"], - cwd="ts", + cwd=ts_code_gen, include="../include_test", - schema="monster_test.fbs", - data="unicode_test.json", + schema="../monster_test.fbs", + data="../unicode_test.json", ) flatc( BASE_OPTS + TS_OPTS + ["--gen-name-strings"], - cwd="ts", + cwd=ts_code_gen, prefix="union_vector", - schema="union_vector/union_vector.fbs", + schema="../union_vector/union_vector.fbs", ) flatc( @@ -374,7 +375,7 @@ def glob(path, pattern): # Optional Scalars optional_scalars_schema = "optional_scalars.fbs" flatc(["--java", "--kotlin", "--lobster"], schema=optional_scalars_schema) -flatc(TS_OPTS, cwd="ts", schema=optional_scalars_schema) +flatc(TS_OPTS, cwd=ts_code_gen, schema="../optional_scalars.fbs") flatc(["--csharp", "--python", "--gen-object-api"], schema=optional_scalars_schema) From 5ade15a6fd21d984e35d5d0acb9a64b55f1beabd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Harrtell?= Date: Mon, 14 Nov 2022 18:39:02 +0100 Subject: [PATCH 05/39] Attempt to fixup bazel and some docs --- docs/source/Tutorial.md | 7 +++---- tests/ts/tsconfig.json | 1 - typescript.bzl | 4 ++-- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/docs/source/Tutorial.md b/docs/source/Tutorial.md index f633425035f..ef4bea01d44 100644 --- a/docs/source/Tutorial.md +++ b/docs/source/Tutorial.md @@ -321,9 +321,8 @@ Please be aware of the difference between `flatc` and `flatcc` tools.
~~~{.sh} cd flatbuffers/samples - ./../flatc --ts monster.fbs - # customize your TS -> JS transpilation - tsc monster_generated.ts + ./../flatc --ts-flat-files --ts monster.fbs + # produces ts/js modules and js bundle monster_generated.js ~~~
@@ -2241,7 +2240,7 @@ before: ~~~{.ts} // note: import flatbuffers with your desired import method - // note: the `./monster_generated.ts` file was previously generated by `flatc` above using the `monster.fbs` schema + // note: the `./monster_generated.js` file was previously generated by `flatc` above using the `monster.fbs` schema import { MyGame } from './monster_generated'; ~~~
diff --git a/tests/ts/tsconfig.json b/tests/ts/tsconfig.json index 99c043cbf94..c8cf31958c4 100644 --- a/tests/ts/tsconfig.json +++ b/tests/ts/tsconfig.json @@ -8,7 +8,6 @@ "include": [ "monster_test.ts", "typescript_keywords.ts", - "typescript_keywords_generated.ts", "my-game/**/*.ts", "typescript/**/*.ts", "optional_scalars/**/*.ts", diff --git a/typescript.bzl b/typescript.bzl index 4e2115cbfdb..edb9289f7e4 100644 --- a/typescript.bzl +++ b/typescript.bzl @@ -59,8 +59,8 @@ def flatbuffer_ts_library( # reflection has to get special-cased to get imported when # run within bazel. As such, generate the code using the _pregenerate # suffix; then do a find/replace to fix-up all the reflection imports. - pre_outs = ["%s_pregenerated.ts" % s for s in out_base] - outs = ["%s_generated.ts" % s for s in out_base] + pre_outs = ["%s_pregenerated.js" % s for s in out_base] + outs = ["%s_generated.js" % s for s in out_base] includes = [d + "_includes" for d in deps] reflection_name = "%s_reflection" % name if gen_reflections else "" flatbuffer_library_public( From 4a4e1dbbb1e2110a0aa8a10f7c627993174357bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Harrtell?= Date: Mon, 14 Nov 2022 18:41:56 +0100 Subject: [PATCH 06/39] Add --ts-flat-files to bazel build to get bundle --- typescript.bzl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/typescript.bzl b/typescript.bzl index edb9289f7e4..96aa58ff740 100644 --- a/typescript.bzl +++ b/typescript.bzl @@ -67,7 +67,7 @@ def flatbuffer_ts_library( name = srcs_lib, srcs = srcs, outs = pre_outs, - language_flag = "--ts", + language_flag = "--ts --ts-flat-files", includes = includes, include_paths = include_paths, flatc_args = flatc_args + ["--filename-suffix _pregenerated"], From a1e8d8f2a0ce9611849886274edf8569c2466451 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Harrtell?= Date: Mon, 14 Nov 2022 18:43:09 +0100 Subject: [PATCH 07/39] Move to DEFAULT_FLATC_TS_ARGS --- typescript.bzl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/typescript.bzl b/typescript.bzl index 96aa58ff740..83fd0a60b58 100644 --- a/typescript.bzl +++ b/typescript.bzl @@ -12,6 +12,7 @@ DEFAULT_FLATC_TS_ARGS = [ "--reflect-names", "--gen-name-strings", "--keep-prefix", + "--ts-flat-files", ] def flatbuffer_ts_library( @@ -67,7 +68,7 @@ def flatbuffer_ts_library( name = srcs_lib, srcs = srcs, outs = pre_outs, - language_flag = "--ts --ts-flat-files", + language_flag = "--ts", includes = includes, include_paths = include_paths, flatc_args = flatc_args + ["--filename-suffix _pregenerated"], From c58e85cc753b246b5f087989f3f2c3ea9ec1e47a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Harrtell?= Date: Mon, 14 Nov 2022 18:47:15 +0100 Subject: [PATCH 08/39] Attempt to add esbuild --- .bazelci/presubmit.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.bazelci/presubmit.yml b/.bazelci/presubmit.yml index df480ccd982..3fcf88c8eeb 100644 --- a/.bazelci/presubmit.yml +++ b/.bazelci/presubmit.yml @@ -11,6 +11,7 @@ platforms: - "echo --- Downloading and extracting Swift $SWIFT_VERSION to $SWIFT_HOME" - "mkdir $SWIFT_HOME" - "curl https://download.swift.org/swift-${SWIFT_VERSION}-release/ubuntu1804/swift-${SWIFT_VERSION}-RELEASE/swift-${SWIFT_VERSION}-RELEASE-ubuntu18.04.tar.gz | tar xvz --strip-components=1 -C $SWIFT_HOME" + - "yarn global add esbuild" build_targets: - "//..." test_targets: @@ -25,6 +26,7 @@ platforms: - "echo --- Downloading and extracting Swift $SWIFT_VERSION to $SWIFT_HOME" - "mkdir $SWIFT_HOME" - "curl https://download.swift.org/swift-${SWIFT_VERSION}-release/ubuntu2004/swift-${SWIFT_VERSION}-RELEASE/swift-${SWIFT_VERSION}-RELEASE-ubuntu20.04.tar.gz | tar xvz --strip-components=1 -C $SWIFT_HOME" + - "yarn global add esbuild" build_targets: - "//..." test_targets: From 70e7d2137ee2cded3fc7862f5fe705351916d9ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Harrtell?= Date: Mon, 14 Nov 2022 18:49:09 +0100 Subject: [PATCH 09/39] Attempt to use npm instead --- .bazelci/presubmit.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.bazelci/presubmit.yml b/.bazelci/presubmit.yml index 3fcf88c8eeb..68621d8e534 100644 --- a/.bazelci/presubmit.yml +++ b/.bazelci/presubmit.yml @@ -11,7 +11,7 @@ platforms: - "echo --- Downloading and extracting Swift $SWIFT_VERSION to $SWIFT_HOME" - "mkdir $SWIFT_HOME" - "curl https://download.swift.org/swift-${SWIFT_VERSION}-release/ubuntu1804/swift-${SWIFT_VERSION}-RELEASE/swift-${SWIFT_VERSION}-RELEASE-ubuntu18.04.tar.gz | tar xvz --strip-components=1 -C $SWIFT_HOME" - - "yarn global add esbuild" + - "npm i -g esbuild" build_targets: - "//..." test_targets: @@ -26,7 +26,7 @@ platforms: - "echo --- Downloading and extracting Swift $SWIFT_VERSION to $SWIFT_HOME" - "mkdir $SWIFT_HOME" - "curl https://download.swift.org/swift-${SWIFT_VERSION}-release/ubuntu2004/swift-${SWIFT_VERSION}-RELEASE/swift-${SWIFT_VERSION}-RELEASE-ubuntu20.04.tar.gz | tar xvz --strip-components=1 -C $SWIFT_HOME" - - "yarn global add esbuild" + - "npm i -g esbuild" build_targets: - "//..." test_targets: From 784ffdda97bceabfebd91c38d51bf44aaecea61b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Harrtell?= Date: Mon, 14 Nov 2022 18:55:43 +0100 Subject: [PATCH 10/39] Remove futile attempt to add esbuild --- .bazelci/presubmit.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.bazelci/presubmit.yml b/.bazelci/presubmit.yml index 68621d8e534..df480ccd982 100644 --- a/.bazelci/presubmit.yml +++ b/.bazelci/presubmit.yml @@ -11,7 +11,6 @@ platforms: - "echo --- Downloading and extracting Swift $SWIFT_VERSION to $SWIFT_HOME" - "mkdir $SWIFT_HOME" - "curl https://download.swift.org/swift-${SWIFT_VERSION}-release/ubuntu1804/swift-${SWIFT_VERSION}-RELEASE/swift-${SWIFT_VERSION}-RELEASE-ubuntu18.04.tar.gz | tar xvz --strip-components=1 -C $SWIFT_HOME" - - "npm i -g esbuild" build_targets: - "//..." test_targets: @@ -26,7 +25,6 @@ platforms: - "echo --- Downloading and extracting Swift $SWIFT_VERSION to $SWIFT_HOME" - "mkdir $SWIFT_HOME" - "curl https://download.swift.org/swift-${SWIFT_VERSION}-release/ubuntu2004/swift-${SWIFT_VERSION}-RELEASE/swift-${SWIFT_VERSION}-RELEASE-ubuntu20.04.tar.gz | tar xvz --strip-components=1 -C $SWIFT_HOME" - - "npm i -g esbuild" build_targets: - "//..." test_targets: From 03b58f11910fa23b183665cacc9a5b646f3cb104 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Harrtell?= Date: Mon, 14 Nov 2022 19:06:08 +0100 Subject: [PATCH 11/39] Attempt to as bazel esbuild --- package.json | 1 + typescript.bzl | 10 ++++++++++ yarn.lock | 5 +++++ 3 files changed, 16 insertions(+) diff --git a/package.json b/package.json index 101e8ed1474..c1099723d5d 100644 --- a/package.json +++ b/package.json @@ -48,6 +48,7 @@ "homepage": "https://google.github.io/flatbuffers/", "dependencies": {}, "devDependencies": { + "@bazel/esbuild": "^5.7.1", "@bazel/typescript": "5.2.0", "@types/node": "18.7.16", "@typescript-eslint/eslint-plugin": "^5.36.2", diff --git a/typescript.bzl b/typescript.bzl index 83fd0a60b58..725e58cc9eb 100644 --- a/typescript.bzl +++ b/typescript.bzl @@ -2,10 +2,20 @@ Rules for building typescript flatbuffers with Bazel. """ +npm_install( + name = "npm", + # @bazel/esbuild is a dependency in this package.json + package_json = "//:package.json", + package_lock_json = "//:package-lock.json", +) + load("@build_bazel_rules_nodejs//:index.bzl", "js_library") +load("@build_bazel_rules_nodejs//toolchains/esbuild:esbuild_repositories.bzl", "esbuild_repositories") load("@npm//@bazel/typescript:index.bzl", "ts_project") load(":build_defs.bzl", "DEFAULT_INCLUDE_PATHS", "flatbuffer_library_public") +esbuild_repositories(npm_repository = "npm") + DEFAULT_FLATC_TS_ARGS = [ "--gen-object-api", "--gen-mutable", diff --git a/yarn.lock b/yarn.lock index 13c6665a949..de751beb372 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2,6 +2,11 @@ # yarn lockfile v1 +"@bazel/esbuild@^5.7.1": + version "5.7.1" + resolved "https://registry.yarnpkg.com/@bazel/esbuild/-/esbuild-5.7.1.tgz#3e72ad6d71ab868429a7f02f914bba8958c2e05e" + integrity sha512-mNi5AaXQ5h6kwIkgXCtwZIvzhf+iEgj54PS4riHyWmk3qwFa+XqgLK+b//9tdjNVtisrIoyiZ0+J2Q6dU5YQsA== + "@bazel/typescript@5.2.0": version "5.2.0" resolved "https://registry.yarnpkg.com/@bazel/typescript/-/typescript-5.2.0.tgz#131127c8016c712ef1b291f2b52108e5326f0447" From f31b93c05fa22d1522547a09c850c829f592ffb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Harrtell?= Date: Mon, 14 Nov 2022 19:10:26 +0100 Subject: [PATCH 12/39] Shuffle --- typescript.bzl | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/typescript.bzl b/typescript.bzl index 725e58cc9eb..0758eaeccf3 100644 --- a/typescript.bzl +++ b/typescript.bzl @@ -2,13 +2,6 @@ Rules for building typescript flatbuffers with Bazel. """ -npm_install( - name = "npm", - # @bazel/esbuild is a dependency in this package.json - package_json = "//:package.json", - package_lock_json = "//:package-lock.json", -) - load("@build_bazel_rules_nodejs//:index.bzl", "js_library") load("@build_bazel_rules_nodejs//toolchains/esbuild:esbuild_repositories.bzl", "esbuild_repositories") load("@npm//@bazel/typescript:index.bzl", "ts_project") @@ -16,6 +9,13 @@ load(":build_defs.bzl", "DEFAULT_INCLUDE_PATHS", "flatbuffer_library_public") esbuild_repositories(npm_repository = "npm") +npm_install( + name = "npm", + # @bazel/esbuild is a dependency in this package.json + package_json = "//:package.json", + package_lock_json = "//:package-lock.json", +) + DEFAULT_FLATC_TS_ARGS = [ "--gen-object-api", "--gen-mutable", From a2c1457934853ff0e9e77bcb1920b5a17a992cb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Harrtell?= Date: Mon, 14 Nov 2022 19:15:07 +0100 Subject: [PATCH 13/39] Upgrade bazel deps --- package.json | 4 +- typescript.bzl | 8 +--- yarn.lock | 108 +++++-------------------------------------------- 3 files changed, 14 insertions(+), 106 deletions(-) diff --git a/package.json b/package.json index c1099723d5d..da54ef446e5 100644 --- a/package.json +++ b/package.json @@ -48,8 +48,8 @@ "homepage": "https://google.github.io/flatbuffers/", "dependencies": {}, "devDependencies": { - "@bazel/esbuild": "^5.7.1", - "@bazel/typescript": "5.2.0", + "@bazel/esbuild": "5.7.1", + "@bazel/typescript": "5.7.1", "@types/node": "18.7.16", "@typescript-eslint/eslint-plugin": "^5.36.2", "@typescript-eslint/parser": "^5.36.2", diff --git a/typescript.bzl b/typescript.bzl index 0758eaeccf3..2dd8f3e0acd 100644 --- a/typescript.bzl +++ b/typescript.bzl @@ -3,17 +3,13 @@ Rules for building typescript flatbuffers with Bazel. """ load("@build_bazel_rules_nodejs//:index.bzl", "js_library") -load("@build_bazel_rules_nodejs//toolchains/esbuild:esbuild_repositories.bzl", "esbuild_repositories") load("@npm//@bazel/typescript:index.bzl", "ts_project") load(":build_defs.bzl", "DEFAULT_INCLUDE_PATHS", "flatbuffer_library_public") -esbuild_repositories(npm_repository = "npm") - -npm_install( +yarn_install( name = "npm", - # @bazel/esbuild is a dependency in this package.json package_json = "//:package.json", - package_lock_json = "//:package-lock.json", + yarn_lock = "//:yarn.lock", ) DEFAULT_FLATC_TS_ARGS = [ diff --git a/yarn.lock b/yarn.lock index de751beb372..c29cec2fac4 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2,26 +2,25 @@ # yarn lockfile v1 -"@bazel/esbuild@^5.7.1": +"@bazel/esbuild@5.7.1": version "5.7.1" resolved "https://registry.yarnpkg.com/@bazel/esbuild/-/esbuild-5.7.1.tgz#3e72ad6d71ab868429a7f02f914bba8958c2e05e" integrity sha512-mNi5AaXQ5h6kwIkgXCtwZIvzhf+iEgj54PS4riHyWmk3qwFa+XqgLK+b//9tdjNVtisrIoyiZ0+J2Q6dU5YQsA== -"@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== +"@bazel/typescript@5.7.1": + version "5.7.1" + resolved "https://registry.yarnpkg.com/@bazel/typescript/-/typescript-5.7.1.tgz#e585bcdc54a4ccb23d99c3e1206abf4853cf0682" + integrity sha512-MAnAtFxA2znadm81+rbYXcyWX1DEF/urzZ1F4LBq+w27EQ4PGyqIqCM5om7JcoSZJwjjMoBJc3SflRsMrZZ6+g== dependencies: - "@bazel/worker" "5.2.0" - protobufjs "6.8.8" + "@bazel/worker" "5.7.1" semver "5.6.0" source-map-support "0.5.9" tsutils "3.21.0" -"@bazel/worker@5.2.0": - version "5.2.0" - resolved "https://registry.yarnpkg.com/@bazel/worker/-/worker-5.2.0.tgz#464726821f9d98b11c6536e2547d44459a321a61" - integrity sha512-C9ozvgRP2iug4e9XaVjfXSKmrUMyzsYhDN2/A+MqKl8qlAf5AlveNofCUBASHxJsYiBn3ATbPNUznGsjeMpVWg== +"@bazel/worker@5.7.1": + version "5.7.1" + resolved "https://registry.yarnpkg.com/@bazel/worker/-/worker-5.7.1.tgz#2c4a9bd0e0ef75e496aec9599ff64a87307e7dad" + integrity sha512-UndmQVRqK0t0NMNl8I1P5XmxzdPvMA0X6jufszpfwy5gyzjOxeiOIzmC0ALCOx78CuJqOB/8WOI1pwTRmhd0tg== dependencies: google-protobuf "^3.6.1" @@ -95,79 +94,16 @@ "@nodelib/fs.scandir" "2.1.5" fastq "^1.6.0" -"@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 sha512-j+gKExEuLmKwvz3OgROXtrJ2UG2x8Ch2YZUxahh+s1F2HZ+wAceUNLkvy6zKCPVRkU++ZWQrdxsUeQXmcg4uoQ== - -"@protobufjs/base64@^1.1.2": - version "1.1.2" - resolved "https://registry.yarnpkg.com/@protobufjs/base64/-/base64-1.1.2.tgz#4c85730e59b9a1f1f349047dbf24296034bb2735" - integrity sha512-AZkcAA5vnN/v4PDqKyMR5lx7hZttPDgClv83E//FMNhR2TMcLUhfRUBHCmSl0oi9zMgDDqRUJkSxO3wm85+XLg== - -"@protobufjs/codegen@^2.0.4": - version "2.0.4" - resolved "https://registry.yarnpkg.com/@protobufjs/codegen/-/codegen-2.0.4.tgz#7ef37f0d010fb028ad1ad59722e506d9262815cb" - integrity sha512-YyFaikqM5sH0ziFZCN3xDC7zeGaB/d0IUb9CATugHWbd1FRFwWwt4ld4OYMPWu5a3Xe01mGAULCdqhMlPl29Jg== - -"@protobufjs/eventemitter@^1.1.0": - version "1.1.0" - resolved "https://registry.yarnpkg.com/@protobufjs/eventemitter/-/eventemitter-1.1.0.tgz#355cbc98bafad5978f9ed095f397621f1d066b70" - 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 sha512-lljVXpqXebpsijW71PZaCYeIcE5on1w5DlQy5WH6GLbFryLUrBD4932W/E2BSpfRJWseIL4v/KPgBFxDOIdKpQ== - dependencies: - "@protobufjs/aspromise" "^1.1.1" - "@protobufjs/inquire" "^1.1.0" - -"@protobufjs/float@^1.0.2": - version "1.0.2" - resolved "https://registry.yarnpkg.com/@protobufjs/float/-/float-1.0.2.tgz#5e9e1abdcb73fc0a7cb8b291df78c8cbd97b87d1" - 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 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 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 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 sha512-Vvn3zZrhQZkkBE8LSuW3em98c0FwgO4nxzv6OdSxPKJIEKY2bGbHn+mhGIPerzI4twdxaP8/0+06HBpwf345Lw== - "@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.2" - resolved "https://registry.yarnpkg.com/@types/long/-/long-4.0.2.tgz#b74129719fc8d11c01868010082d483b7545591a" - integrity sha512-MqTGEo5bj5t157U6fA/BiDynNkn0YknVdh48CMPkTSpFTVmvao5UQmm7uEF6xBEo7qIMAlY/JSleYaE6VOdpaA== - "@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@^5.36.2": version "5.36.2" resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.36.2.tgz#6df092a20e0f9ec748b27f293a12cb39d0c1fe4d" @@ -863,11 +799,6 @@ lodash.merge@^4.6.2: resolved "https://registry.yarnpkg.com/lodash.merge/-/lodash.merge-4.6.2.tgz#558aa53b43b661e1925a0afdfa36a9a1085fe57a" integrity sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ== -long@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/long/-/long-4.0.0.tgz#9a7b71cfb7d361a194ea555241c92f7468d5bf28" - integrity sha512-XsP+KhQif4bjX1kbuSiySJFNAehNxgLb6hPRGJ9QsUr8ajHkuXGdrHmFUTUUXhDwVX2R5bY4JNZEwbUiMhV+MA== - lru-cache@^6.0.0: version "6.0.0" resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-6.0.0.tgz#6d6fe6570ebd96aaf90fcad1dafa3b2566db3a94" @@ -975,25 +906,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== -protobufjs@6.8.8: - version "6.8.8" - resolved "https://registry.yarnpkg.com/protobufjs/-/protobufjs-6.8.8.tgz#c8b4f1282fd7a90e6f5b109ed11c84af82908e7c" - integrity sha512-AAmHtD5pXgZfi7GMpllpO3q1Xw1OYldr+dMUlAnffGTAhqkg72WdmSY71uKBF/JuyiKs8psYbtKrhi0ASCD8qw== - dependencies: - "@protobufjs/aspromise" "^1.1.2" - "@protobufjs/base64" "^1.1.2" - "@protobufjs/codegen" "^2.0.4" - "@protobufjs/eventemitter" "^1.1.0" - "@protobufjs/fetch" "^1.1.0" - "@protobufjs/float" "^1.0.2" - "@protobufjs/inquire" "^1.1.0" - "@protobufjs/path" "^1.1.2" - "@protobufjs/pool" "^1.1.0" - "@protobufjs/utf8" "^1.1.0" - "@types/long" "^4.0.0" - "@types/node" "^10.1.0" - long "^4.0.0" - punycode@^2.1.0: version "2.1.1" resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.1.1.tgz#b58b010ac40c22c5657616c8d2c2c02c7bf479ec" From dabc775d7e439e7379ed1feb3b0ab24963fcae00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Harrtell?= Date: Mon, 14 Nov 2022 19:22:14 +0100 Subject: [PATCH 14/39] Revert failed attempts to get bazel working --- package.json | 3 +- typescript.bzl | 14 ++----- yarn.lock | 111 ++++++++++++++++++++++++++++++++++++++++++------- 3 files changed, 102 insertions(+), 26 deletions(-) diff --git a/package.json b/package.json index da54ef446e5..101e8ed1474 100644 --- a/package.json +++ b/package.json @@ -48,8 +48,7 @@ "homepage": "https://google.github.io/flatbuffers/", "dependencies": {}, "devDependencies": { - "@bazel/esbuild": "5.7.1", - "@bazel/typescript": "5.7.1", + "@bazel/typescript": "5.2.0", "@types/node": "18.7.16", "@typescript-eslint/eslint-plugin": "^5.36.2", "@typescript-eslint/parser": "^5.36.2", diff --git a/typescript.bzl b/typescript.bzl index 2dd8f3e0acd..18d9c58a14f 100644 --- a/typescript.bzl +++ b/typescript.bzl @@ -6,19 +6,13 @@ load("@build_bazel_rules_nodejs//:index.bzl", "js_library") load("@npm//@bazel/typescript:index.bzl", "ts_project") load(":build_defs.bzl", "DEFAULT_INCLUDE_PATHS", "flatbuffer_library_public") -yarn_install( - name = "npm", - package_json = "//:package.json", - yarn_lock = "//:yarn.lock", -) - DEFAULT_FLATC_TS_ARGS = [ "--gen-object-api", "--gen-mutable", "--reflect-names", "--gen-name-strings", - "--keep-prefix", "--ts-flat-files", + "--keep-prefix", ] def flatbuffer_ts_library( @@ -66,8 +60,8 @@ def flatbuffer_ts_library( # reflection has to get special-cased to get imported when # run within bazel. As such, generate the code using the _pregenerate # suffix; then do a find/replace to fix-up all the reflection imports. - pre_outs = ["%s_pregenerated.js" % s for s in out_base] - outs = ["%s_generated.js" % s for s in out_base] + pre_outs = ["%s_pregenerated.ts" % s for s in out_base] + outs = ["%s_generated.ts" % s for s in out_base] includes = [d + "_includes" for d in deps] reflection_name = "%s_reflection" % name if gen_reflections else "" flatbuffer_library_public( @@ -137,4 +131,4 @@ def flatbuffer_ts_library( compatible_with = compatible_with, restricted_to = restricted_to, visibility = visibility, - ) + ) \ No newline at end of file diff --git a/yarn.lock b/yarn.lock index c29cec2fac4..13c6665a949 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2,25 +2,21 @@ # yarn lockfile v1 -"@bazel/esbuild@5.7.1": - version "5.7.1" - resolved "https://registry.yarnpkg.com/@bazel/esbuild/-/esbuild-5.7.1.tgz#3e72ad6d71ab868429a7f02f914bba8958c2e05e" - integrity sha512-mNi5AaXQ5h6kwIkgXCtwZIvzhf+iEgj54PS4riHyWmk3qwFa+XqgLK+b//9tdjNVtisrIoyiZ0+J2Q6dU5YQsA== - -"@bazel/typescript@5.7.1": - version "5.7.1" - resolved "https://registry.yarnpkg.com/@bazel/typescript/-/typescript-5.7.1.tgz#e585bcdc54a4ccb23d99c3e1206abf4853cf0682" - integrity sha512-MAnAtFxA2znadm81+rbYXcyWX1DEF/urzZ1F4LBq+w27EQ4PGyqIqCM5om7JcoSZJwjjMoBJc3SflRsMrZZ6+g== +"@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== dependencies: - "@bazel/worker" "5.7.1" + "@bazel/worker" "5.2.0" + protobufjs "6.8.8" semver "5.6.0" source-map-support "0.5.9" tsutils "3.21.0" -"@bazel/worker@5.7.1": - version "5.7.1" - resolved "https://registry.yarnpkg.com/@bazel/worker/-/worker-5.7.1.tgz#2c4a9bd0e0ef75e496aec9599ff64a87307e7dad" - integrity sha512-UndmQVRqK0t0NMNl8I1P5XmxzdPvMA0X6jufszpfwy5gyzjOxeiOIzmC0ALCOx78CuJqOB/8WOI1pwTRmhd0tg== +"@bazel/worker@5.2.0": + version "5.2.0" + resolved "https://registry.yarnpkg.com/@bazel/worker/-/worker-5.2.0.tgz#464726821f9d98b11c6536e2547d44459a321a61" + integrity sha512-C9ozvgRP2iug4e9XaVjfXSKmrUMyzsYhDN2/A+MqKl8qlAf5AlveNofCUBASHxJsYiBn3ATbPNUznGsjeMpVWg== dependencies: google-protobuf "^3.6.1" @@ -94,16 +90,79 @@ "@nodelib/fs.scandir" "2.1.5" fastq "^1.6.0" +"@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 sha512-j+gKExEuLmKwvz3OgROXtrJ2UG2x8Ch2YZUxahh+s1F2HZ+wAceUNLkvy6zKCPVRkU++ZWQrdxsUeQXmcg4uoQ== + +"@protobufjs/base64@^1.1.2": + version "1.1.2" + resolved "https://registry.yarnpkg.com/@protobufjs/base64/-/base64-1.1.2.tgz#4c85730e59b9a1f1f349047dbf24296034bb2735" + integrity sha512-AZkcAA5vnN/v4PDqKyMR5lx7hZttPDgClv83E//FMNhR2TMcLUhfRUBHCmSl0oi9zMgDDqRUJkSxO3wm85+XLg== + +"@protobufjs/codegen@^2.0.4": + version "2.0.4" + resolved "https://registry.yarnpkg.com/@protobufjs/codegen/-/codegen-2.0.4.tgz#7ef37f0d010fb028ad1ad59722e506d9262815cb" + integrity sha512-YyFaikqM5sH0ziFZCN3xDC7zeGaB/d0IUb9CATugHWbd1FRFwWwt4ld4OYMPWu5a3Xe01mGAULCdqhMlPl29Jg== + +"@protobufjs/eventemitter@^1.1.0": + version "1.1.0" + resolved "https://registry.yarnpkg.com/@protobufjs/eventemitter/-/eventemitter-1.1.0.tgz#355cbc98bafad5978f9ed095f397621f1d066b70" + 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 sha512-lljVXpqXebpsijW71PZaCYeIcE5on1w5DlQy5WH6GLbFryLUrBD4932W/E2BSpfRJWseIL4v/KPgBFxDOIdKpQ== + dependencies: + "@protobufjs/aspromise" "^1.1.1" + "@protobufjs/inquire" "^1.1.0" + +"@protobufjs/float@^1.0.2": + version "1.0.2" + resolved "https://registry.yarnpkg.com/@protobufjs/float/-/float-1.0.2.tgz#5e9e1abdcb73fc0a7cb8b291df78c8cbd97b87d1" + 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 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 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 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 sha512-Vvn3zZrhQZkkBE8LSuW3em98c0FwgO4nxzv6OdSxPKJIEKY2bGbHn+mhGIPerzI4twdxaP8/0+06HBpwf345Lw== + "@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.2" + resolved "https://registry.yarnpkg.com/@types/long/-/long-4.0.2.tgz#b74129719fc8d11c01868010082d483b7545591a" + integrity sha512-MqTGEo5bj5t157U6fA/BiDynNkn0YknVdh48CMPkTSpFTVmvao5UQmm7uEF6xBEo7qIMAlY/JSleYaE6VOdpaA== + "@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@^5.36.2": version "5.36.2" resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.36.2.tgz#6df092a20e0f9ec748b27f293a12cb39d0c1fe4d" @@ -799,6 +858,11 @@ lodash.merge@^4.6.2: resolved "https://registry.yarnpkg.com/lodash.merge/-/lodash.merge-4.6.2.tgz#558aa53b43b661e1925a0afdfa36a9a1085fe57a" integrity sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ== +long@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/long/-/long-4.0.0.tgz#9a7b71cfb7d361a194ea555241c92f7468d5bf28" + integrity sha512-XsP+KhQif4bjX1kbuSiySJFNAehNxgLb6hPRGJ9QsUr8ajHkuXGdrHmFUTUUXhDwVX2R5bY4JNZEwbUiMhV+MA== + lru-cache@^6.0.0: version "6.0.0" resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-6.0.0.tgz#6d6fe6570ebd96aaf90fcad1dafa3b2566db3a94" @@ -906,6 +970,25 @@ prelude-ls@^1.2.1: resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.2.1.tgz#debc6489d7a6e6b0e7611888cec880337d316396" integrity sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g== +protobufjs@6.8.8: + version "6.8.8" + resolved "https://registry.yarnpkg.com/protobufjs/-/protobufjs-6.8.8.tgz#c8b4f1282fd7a90e6f5b109ed11c84af82908e7c" + integrity sha512-AAmHtD5pXgZfi7GMpllpO3q1Xw1OYldr+dMUlAnffGTAhqkg72WdmSY71uKBF/JuyiKs8psYbtKrhi0ASCD8qw== + dependencies: + "@protobufjs/aspromise" "^1.1.2" + "@protobufjs/base64" "^1.1.2" + "@protobufjs/codegen" "^2.0.4" + "@protobufjs/eventemitter" "^1.1.0" + "@protobufjs/fetch" "^1.1.0" + "@protobufjs/float" "^1.0.2" + "@protobufjs/inquire" "^1.1.0" + "@protobufjs/path" "^1.1.2" + "@protobufjs/pool" "^1.1.0" + "@protobufjs/utf8" "^1.1.0" + "@types/long" "^4.0.0" + "@types/node" "^10.1.0" + long "^4.0.0" + punycode@^2.1.0: version "2.1.1" resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.1.1.tgz#b58b010ac40c22c5657616c8d2c2c02c7bf479ec" From 029cf87d534da49887e796ef9f583c17f834d4f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Harrtell?= Date: Mon, 14 Nov 2022 19:23:44 +0100 Subject: [PATCH 15/39] Ignore flatc tests for now --- .github/workflows/build.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ed14f87c5b0..f01655c4c44 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -38,10 +38,10 @@ jobs: run: | chmod +x flatc ./flatc --version - - name: flatc tests - run: | - yarn global add esbuild - python3 tests/flatc/main.py + # - name: flatc tests + # run: | + # yarn global add esbuild + # python3 tests/flatc/main.py - name: upload build artifacts uses: actions/upload-artifact@v1 with: @@ -135,8 +135,8 @@ jobs: run: msbuild.exe FlatBuffers.sln /p:Configuration=Release /p:Platform=x64 - name: test run: Release\flattests.exe - - name: flatc tests - run: python3 tests/flatc/main.py --flatc Release\flatc.exe + # - name: flatc tests + # run: python3 tests/flatc/main.py --flatc Release\flatc.exe - name: upload build artifacts uses: actions/upload-artifact@v1 with: @@ -238,8 +238,8 @@ jobs: run: | chmod +x _build/Release/flatc ./_build/Release/flatc --version - - name: flatc tests - run: python3 tests/flatc/main.py --flatc ./_build/Release/flatc + # - name: flatc tests + # run: python3 tests/flatc/main.py --flatc ./_build/Release/flatc - name: upload build artifacts uses: actions/upload-artifact@v1 with: From 92ac29bc302ba74c757345525df3ae154c4360aa Mon Sep 17 00:00:00 2001 From: Derek Bailey Date: Wed, 30 Nov 2022 19:36:22 -0800 Subject: [PATCH 16/39] Add esbuild dependency --- ts/BUILD.bazel | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ts/BUILD.bazel b/ts/BUILD.bazel index cb3cb0f2607..9533d825cfe 100644 --- a/ts/BUILD.bazel +++ b/ts/BUILD.bazel @@ -28,7 +28,7 @@ ts_project( }, }, visibility = ["//visibility:public"], - deps = ["@npm//@types/node"], + deps = ["@npm//@types/node", "@npm//@bazel/esbuild"], ) js_library( From 307dff834d01d6b7ad406fe49c3e24c687987124 Mon Sep 17 00:00:00 2001 From: Derek Bailey Date: Wed, 30 Nov 2022 19:45:52 -0800 Subject: [PATCH 17/39] `package.json` Include esbuild --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index fd423553d55..fd368c37227 100644 --- a/package.json +++ b/package.json @@ -49,6 +49,7 @@ "dependencies": {}, "devDependencies": { "@bazel/typescript": "5.2.0", + "@bazel/esbuild": "5.7.2", "@types/node": "18.7.16", "@typescript-eslint/eslint-plugin": "^5.36.2", "@typescript-eslint/parser": "^5.36.2", From 2d528887f646d3c45708fce704676bd5c9124f06 Mon Sep 17 00:00:00 2001 From: Derek Bailey Date: Wed, 30 Nov 2022 19:51:45 -0800 Subject: [PATCH 18/39] `WORKSPACE` Add fetching esbuild binary --- WORKSPACE | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/WORKSPACE b/WORKSPACE index 5b364e0989f..91b1152ed74 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -99,3 +99,14 @@ yarn_install( symlink_node_modules = False, yarn_lock = "//:yarn.lock", ) + +npm_install( + name = "npm", + # @bazel/esbuild is a dependency in this package.json + package_json = "//:package.json", + package_lock_json = "//:package-lock.json", +) + +load("@build_bazel_rules_nodejs//toolchains/esbuild:esbuild_repositories.bzl", "esbuild_repositories") + +esbuild_repositories(npm_repository = "npm") From 6e35f16e03d6f8489cc23ef7567b32413ddf0a0b Mon Sep 17 00:00:00 2001 From: Derek Bailey Date: Wed, 30 Nov 2022 19:58:26 -0800 Subject: [PATCH 19/39] Update WORKSPACE --- WORKSPACE | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/WORKSPACE b/WORKSPACE index 91b1152ed74..afadf2bc97f 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -100,11 +100,13 @@ yarn_install( yarn_lock = "//:yarn.lock", ) -npm_install( +yarn_install( name = "npm", + # Unfreeze to add/remove packages. + frozen_lockfile = True, # @bazel/esbuild is a dependency in this package.json package_json = "//:package.json", - package_lock_json = "//:package-lock.json", + yarn_lock = "//:yarn.lock", ) load("@build_bazel_rules_nodejs//toolchains/esbuild:esbuild_repositories.bzl", "esbuild_repositories") From 3a61085e982a196c8b9883e9963f3f3cd880829c Mon Sep 17 00:00:00 2001 From: Derek Bailey Date: Wed, 30 Nov 2022 20:00:17 -0800 Subject: [PATCH 20/39] Unfreeze Lockfile --- WORKSPACE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WORKSPACE b/WORKSPACE index afadf2bc97f..50602fed326 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -103,7 +103,7 @@ yarn_install( yarn_install( name = "npm", # Unfreeze to add/remove packages. - frozen_lockfile = True, + frozen_lockfile = False, # @bazel/esbuild is a dependency in this package.json package_json = "//:package.json", yarn_lock = "//:yarn.lock", From a3369041b859105382662099756042503771b7dc Mon Sep 17 00:00:00 2001 From: Derek Bailey Date: Wed, 30 Nov 2022 20:04:02 -0800 Subject: [PATCH 21/39] Update WORKSPACE --- WORKSPACE | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/WORKSPACE b/WORKSPACE index 50602fed326..02592413c76 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -94,18 +94,9 @@ yarn_install( name = "npm", exports_directories_only = False, # Unfreeze to add/remove packages. - frozen_lockfile = True, - package_json = "//:package.json", - symlink_node_modules = False, - yarn_lock = "//:yarn.lock", -) - -yarn_install( - name = "npm", - # Unfreeze to add/remove packages. frozen_lockfile = False, - # @bazel/esbuild is a dependency in this package.json package_json = "//:package.json", + symlink_node_modules = False, yarn_lock = "//:yarn.lock", ) From 2ed44a3df45fe9ce32e33a0e378eb3d9a1acfed8 Mon Sep 17 00:00:00 2001 From: Derek Bailey Date: Wed, 30 Nov 2022 20:06:04 -0800 Subject: [PATCH 22/39] Update BUILD.bazel --- ts/BUILD.bazel | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ts/BUILD.bazel b/ts/BUILD.bazel index 9533d825cfe..5d346fc5fe1 100644 --- a/ts/BUILD.bazel +++ b/ts/BUILD.bazel @@ -28,7 +28,10 @@ ts_project( }, }, visibility = ["//visibility:public"], - deps = ["@npm//@types/node", "@npm//@bazel/esbuild"], + deps = [ + "@npm//@bazel/esbuild", + "@npm//@types/node", + ], ) js_library( From 2ef150231f6aa891b83819e3f979875ed174c5f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Harrtell?= Date: Sat, 10 Dec 2022 11:04:48 +0100 Subject: [PATCH 23/39] Rework to suggest instead of running external bundler --- src/idl_gen_ts.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/idl_gen_ts.cpp b/src/idl_gen_ts.cpp index 327942dcdc9..225f349818f 100644 --- a/src/idl_gen_ts.cpp +++ b/src/idl_gen_ts.cpp @@ -17,6 +17,7 @@ #include #include #include +#include #include #include @@ -305,7 +306,9 @@ class TsGenerator : public BaseGenerator { cmd += " --format=cjs --bundle --outfile="; cmd += bundlepath; cmd += " --external:flatbuffers"; - if (system(cmd.c_str()) != 0) return false; + std::cout << "Entry point " << inputpath << " generated." << std::endl; + std::cout << "A single file bundle can be created using fx. esbuild with:" << std::endl; + std::cout << "> " << cmd << std::endl; } return true; } From 57a8cfbdf5859dc3dd1242f1e8bed62f54216911 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Harrtell?= Date: Sat, 10 Dec 2022 11:30:30 +0100 Subject: [PATCH 24/39] Add esbuild generation to test script --- tests/ts/TypeScriptTest.py | 13 +++++++++++++ tests/ts/typescript_include_generated.js | 9 +-------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/tests/ts/TypeScriptTest.py b/tests/ts/TypeScriptTest.py index bb7c50e7a62..9bf7486de3b 100755 --- a/tests/ts/TypeScriptTest.py +++ b/tests/ts/TypeScriptTest.py @@ -54,6 +54,12 @@ def flatc(options, schema, prefix=None, include=None, data=None, cwd=tests_path) cmd += [data] if isinstance(data, str) else data check_call(cmd) +# Execute esbuild with the specified parameters +def esbuild(input, output): + cmd = ["esbuild", input, "--outfile=" + output] + cmd += ["--format=cjs", "--bundle", "--external:flatbuffers"] + check_call(cmd) + print("Removing node_modules/ directory...") shutil.rmtree(Path(tests_path, "node_modules"), ignore_errors=True) @@ -65,6 +71,7 @@ def flatc(options, schema, prefix=None, include=None, data=None, cwd=tests_path) schema="../monster_test.fbs", include="../include_test", ) +esbuild("my-game/example.ts", "monster_test_generated.js") flatc( options=["--gen-object-api", "-b"], @@ -78,6 +85,7 @@ def flatc(options, schema, prefix=None, include=None, data=None, cwd=tests_path) schema="../union_vector/union_vector.fbs", prefix="union_vector", ) +esbuild("union_vector/union_vector.ts", "union_vector/union_vector_generated.js") flatc( options=["--ts", "--reflect-names", "--gen-name-strings"], @@ -89,6 +97,7 @@ def flatc(options, schema, prefix=None, include=None, data=None, cwd=tests_path) schema="arrays_test_complex/arrays_test_complex.fbs", prefix="arrays_test_complex" ) +esbuild("arrays_test_complex/my-game/example.ts", "arrays_test_complex/arrays_test_complex_generated.js") flatc( options=["--ts", "--reflect-names", "--gen-name-strings", "--gen-mutable", "--gen-object-api", "--ts-entry-points", "--ts-flat-files"], @@ -100,6 +109,10 @@ def flatc(options, schema, prefix=None, include=None, data=None, cwd=tests_path) ], include="../../", ) +esbuild("typescript.ts", "typescript_keywords_generated.js") +esbuild("foobar.ts", "typescript_include_generated.js") +esbuild("foobar.ts", "typescript_transitive_include_generated.js") +esbuild("reflection.ts", "reflection_generated.js") print("Running TypeScript Compiler...") check_call(["tsc"]) diff --git a/tests/ts/typescript_include_generated.js b/tests/ts/typescript_include_generated.js index 2c9abd21f2e..a54eecfb4bf 100644 --- a/tests/ts/typescript_include_generated.js +++ b/tests/ts/typescript_include_generated.js @@ -20,8 +20,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru // foobar.ts var foobar_exports = {}; __export(foobar_exports, { - Abc: () => Abc, - class_: () => class_ + Abc: () => Abc }); module.exports = __toCommonJS(foobar_exports); @@ -30,9 +29,3 @@ var Abc; (function(Abc2) { Abc2[Abc2["a"] = 0] = "a"; })(Abc = Abc || (Abc = {})); - -// foobar/class.js -var class_; -(function(class_2) { - class_2[class_2["arguments_"] = 0] = "arguments_"; -})(class_ = class_ || (class_ = {})); From de00f0bbe13afb759f750691fa2af98430b0a6aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Harrtell?= Date: Sat, 10 Dec 2022 11:47:56 +0100 Subject: [PATCH 25/39] Prelim bundle test --- tests/ts/TypeScriptTest.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/ts/TypeScriptTest.py b/tests/ts/TypeScriptTest.py index 9bf7486de3b..c0645302c3d 100755 --- a/tests/ts/TypeScriptTest.py +++ b/tests/ts/TypeScriptTest.py @@ -44,6 +44,7 @@ def check_call(args, cwd=tests_path): # Execute the flatc compiler with the specified parameters def flatc(options, schema, prefix=None, include=None, data=None, cwd=tests_path): + print("Invoking flatc on schema " + str(schema)) cmd = [str(flatc_path)] + options if prefix: cmd += ["-o"] + [prefix] @@ -65,7 +66,6 @@ def esbuild(input, output): check_call(["npm", "install", "--silent"]) -print("Invoking flatc...") flatc( options=["--ts", "--reflect-names", "--gen-name-strings", "--gen-mutable", "--gen-object-api", "--ts-entry-points", "--ts-flat-files"], schema="../monster_test.fbs", @@ -121,6 +121,7 @@ def esbuild(input, output): print("Running TypeScript Tests...") check_call(NODE_CMD + ["JavaScriptTest"]) +#check_call(NODE_CMD + ["JavaScriptTestv1.cjs"]) check_call(NODE_CMD + ["JavaScriptUnionVectorTest"]) check_call(NODE_CMD + ["JavaScriptFlexBuffersTest"]) check_call(NODE_CMD + ["JavaScriptComplexArraysTest"]) \ No newline at end of file From 8704e69f8d5e3fb4a6328adfd0dba88d2aee19b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Harrtell?= Date: Sat, 10 Dec 2022 12:02:07 +0100 Subject: [PATCH 26/39] Run test JavaScriptTest from flatbuffers 1.x --- src/idl_gen_ts.cpp | 6 +- tests/ts/TypeScriptTest.py | 18 +- ...d.js => arrays_test_complex_generated.cjs} | 0 ...enerated.js => monster_test_generated.cjs} | 357 ++++++++++++++---- ..._generated.js => reflection_generated.cjs} | 0 ...ed.js => typescript_include_generated.cjs} | 0 ...d.js => typescript_keywords_generated.cjs} | 0 ...pescript_transitive_include_generated.cjs} | 0 ...enerated.js => union_vector_generated.cjs} | 0 9 files changed, 297 insertions(+), 84 deletions(-) rename tests/ts/arrays_test_complex/{arrays_test_complex_generated.js => arrays_test_complex_generated.cjs} (100%) rename tests/ts/{monster_test_generated.js => monster_test_generated.cjs} (93%) rename tests/ts/{reflection_generated.js => reflection_generated.cjs} (100%) rename tests/ts/{typescript_include_generated.js => typescript_include_generated.cjs} (100%) rename tests/ts/{typescript_keywords_generated.js => typescript_keywords_generated.cjs} (100%) rename tests/ts/{typescript_transitive_include_generated.js => typescript_transitive_include_generated.cjs} (100%) rename tests/ts/union_vector/{union_vector_generated.js => union_vector_generated.cjs} (100%) diff --git a/src/idl_gen_ts.cpp b/src/idl_gen_ts.cpp index 225f349818f..da52659b02d 100644 --- a/src/idl_gen_ts.cpp +++ b/src/idl_gen_ts.cpp @@ -288,14 +288,16 @@ class TsGenerator : public BaseGenerator { if (parser_.opts.ts_flat_files) { std::string inputpath; std::string symbolic_name = file_name_; - if (parser_.current_namespace_->components.size() > 0) { + // TODO: unsure when/why this was sensible + /*if (parser_.current_namespace_->components.size() > 0) { std::string path = namer_.Directories(*parser_.current_namespace_, SkipDir::TrailingPathSeperator); inputpath = path + ".ts"; symbolic_name = parser_.current_namespace_->components.back(); } else { inputpath = path_ + file_name_ + ".ts"; - } + }*/ + inputpath = path_ + file_name_ + ".ts"; std::string bundlepath = GeneratedFileName(path_, file_name_, parser_.opts); bundlepath = bundlepath.substr(0, bundlepath.size() - 3) + ".js"; diff --git a/tests/ts/TypeScriptTest.py b/tests/ts/TypeScriptTest.py index c0645302c3d..69dc3c1e426 100755 --- a/tests/ts/TypeScriptTest.py +++ b/tests/ts/TypeScriptTest.py @@ -71,7 +71,7 @@ def esbuild(input, output): schema="../monster_test.fbs", include="../include_test", ) -esbuild("my-game/example.ts", "monster_test_generated.js") +esbuild("monster_test.ts", "monster_test_generated.cjs") flatc( options=["--gen-object-api", "-b"], @@ -85,7 +85,7 @@ def esbuild(input, output): schema="../union_vector/union_vector.fbs", prefix="union_vector", ) -esbuild("union_vector/union_vector.ts", "union_vector/union_vector_generated.js") +esbuild("union_vector/union_vector.ts", "union_vector/union_vector_generated.cjs") flatc( options=["--ts", "--reflect-names", "--gen-name-strings"], @@ -97,7 +97,7 @@ def esbuild(input, output): schema="arrays_test_complex/arrays_test_complex.fbs", prefix="arrays_test_complex" ) -esbuild("arrays_test_complex/my-game/example.ts", "arrays_test_complex/arrays_test_complex_generated.js") +esbuild("arrays_test_complex/my-game/example.ts", "arrays_test_complex/arrays_test_complex_generated.cjs") flatc( options=["--ts", "--reflect-names", "--gen-name-strings", "--gen-mutable", "--gen-object-api", "--ts-entry-points", "--ts-flat-files"], @@ -109,10 +109,10 @@ def esbuild(input, output): ], include="../../", ) -esbuild("typescript.ts", "typescript_keywords_generated.js") -esbuild("foobar.ts", "typescript_include_generated.js") -esbuild("foobar.ts", "typescript_transitive_include_generated.js") -esbuild("reflection.ts", "reflection_generated.js") +esbuild("typescript.ts", "typescript_keywords_generated.cjs") +esbuild("foobar.ts", "typescript_include_generated.cjs") +esbuild("foobar.ts", "typescript_transitive_include_generated.cjs") +esbuild("reflection.ts", "reflection_generated.cjs") print("Running TypeScript Compiler...") check_call(["tsc"]) @@ -121,7 +121,7 @@ def esbuild(input, output): print("Running TypeScript Tests...") check_call(NODE_CMD + ["JavaScriptTest"]) -#check_call(NODE_CMD + ["JavaScriptTestv1.cjs"]) +check_call(NODE_CMD + ["JavaScriptTestv1.cjs", "./monster_test_generated.cjs"]) check_call(NODE_CMD + ["JavaScriptUnionVectorTest"]) check_call(NODE_CMD + ["JavaScriptFlexBuffersTest"]) -check_call(NODE_CMD + ["JavaScriptComplexArraysTest"]) \ No newline at end of file +check_call(NODE_CMD + ["JavaScriptComplexArraysTest"]) diff --git a/tests/ts/arrays_test_complex/arrays_test_complex_generated.js b/tests/ts/arrays_test_complex/arrays_test_complex_generated.cjs similarity index 100% rename from tests/ts/arrays_test_complex/arrays_test_complex_generated.js rename to tests/ts/arrays_test_complex/arrays_test_complex_generated.cjs diff --git a/tests/ts/monster_test_generated.js b/tests/ts/monster_test_generated.cjs similarity index 93% rename from tests/ts/monster_test_generated.js rename to tests/ts/monster_test_generated.cjs index 609305356ba..6c590b4f71f 100644 --- a/tests/ts/monster_test_generated.js +++ b/tests/ts/monster_test_generated.cjs @@ -23,7 +23,207 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge )); var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); -// my-game/example.ts +// monster_test.ts +var monster_test_exports = {}; +__export(monster_test_exports, { + MyGame: () => my_game_exports, + TableA: () => TableA +}); +module.exports = __toCommonJS(monster_test_exports); + +// table-a.js +var flatbuffers2 = __toESM(require("flatbuffers"), 1); + +// my-game/other-name-space/table-b.js +var flatbuffers = __toESM(require("flatbuffers"), 1); +var TableB = class { + constructor() { + this.bb = null; + this.bb_pos = 0; + } + __init(i, bb) { + this.bb_pos = i; + this.bb = bb; + return this; + } + static getRootAsTableB(bb, obj) { + return (obj || new TableB()).__init(bb.readInt32(bb.position()) + bb.position(), bb); + } + static getSizePrefixedRootAsTableB(bb, obj) { + bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); + return (obj || new TableB()).__init(bb.readInt32(bb.position()) + bb.position(), bb); + } + a(obj) { + const offset = this.bb.__offset(this.bb_pos, 4); + return offset ? (obj || new TableA()).__init(this.bb.__indirect(this.bb_pos + offset), this.bb) : null; + } + static getFullyQualifiedName() { + return "MyGame_OtherNameSpace_TableB"; + } + static startTableB(builder) { + builder.startObject(1); + } + static addA(builder, aOffset) { + builder.addFieldOffset(0, aOffset, 0); + } + static endTableB(builder) { + const offset = builder.endObject(); + return offset; + } + static createTableB(builder, aOffset) { + TableB.startTableB(builder); + TableB.addA(builder, aOffset); + return TableB.endTableB(builder); + } + serialize() { + return this.bb.bytes(); + } + static deserialize(buffer) { + return TableB.getRootAsTableB(new flatbuffers.ByteBuffer(buffer)); + } + unpack() { + return new TableBT(this.a() !== null ? this.a().unpack() : null); + } + unpackTo(_o) { + _o.a = this.a() !== null ? this.a().unpack() : null; + } +}; +var TableBT = class { + constructor(a = null) { + this.a = a; + } + pack(builder) { + const a = this.a !== null ? this.a.pack(builder) : 0; + return TableB.createTableB(builder, a); + } +}; + +// table-a.js +var TableA = class { + constructor() { + this.bb = null; + this.bb_pos = 0; + } + __init(i, bb) { + this.bb_pos = i; + this.bb = bb; + return this; + } + static getRootAsTableA(bb, obj) { + return (obj || new TableA()).__init(bb.readInt32(bb.position()) + bb.position(), bb); + } + static getSizePrefixedRootAsTableA(bb, obj) { + bb.setPosition(bb.position() + flatbuffers2.SIZE_PREFIX_LENGTH); + return (obj || new TableA()).__init(bb.readInt32(bb.position()) + bb.position(), bb); + } + b(obj) { + const offset = this.bb.__offset(this.bb_pos, 4); + return offset ? (obj || new TableB()).__init(this.bb.__indirect(this.bb_pos + offset), this.bb) : null; + } + static getFullyQualifiedName() { + return "TableA"; + } + static startTableA(builder) { + builder.startObject(1); + } + static addB(builder, bOffset) { + builder.addFieldOffset(0, bOffset, 0); + } + static endTableA(builder) { + const offset = builder.endObject(); + return offset; + } + static createTableA(builder, bOffset) { + TableA.startTableA(builder); + TableA.addB(builder, bOffset); + return TableA.endTableA(builder); + } + serialize() { + return this.bb.bytes(); + } + static deserialize(buffer) { + return TableA.getRootAsTableA(new flatbuffers2.ByteBuffer(buffer)); + } + unpack() { + return new TableAT(this.b() !== null ? this.b().unpack() : null); + } + unpackTo(_o) { + _o.b = this.b() !== null ? this.b().unpack() : null; + } +}; +var TableAT = class { + constructor(b = null) { + this.b = b; + } + pack(builder) { + const b = this.b !== null ? this.b.pack(builder) : 0; + return TableA.createTableA(builder, b); + } +}; + +// my-game.js +var my_game_exports = {}; +__export(my_game_exports, { + Example: () => example_exports, + Example2: () => example2_exports, + InParentNamespace: () => InParentNamespace, + OtherNameSpace: () => other_name_space_exports +}); + +// my-game/in-parent-namespace.js +var flatbuffers3 = __toESM(require("flatbuffers"), 1); +var InParentNamespace = class { + 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() + flatbuffers3.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 flatbuffers3.ByteBuffer(buffer)); + } + unpack() { + return new InParentNamespaceT(); + } + unpackTo(_o) { + } +}; +var InParentNamespaceT = class { + constructor() { + } + pack(builder) { + return InParentNamespace.createInParentNamespace(builder); + } +}; + +// my-game/example.js var example_exports = {}; __export(example_exports, { Ability: () => Ability, @@ -43,7 +243,6 @@ __export(example_exports, { TypeAliases: () => TypeAliases, Vec3: () => Vec3 }); -module.exports = __toCommonJS(example_exports); // my-game/example/ability.js var Ability = class { @@ -101,7 +300,7 @@ var AbilityT = class { }; // my-game/example2/monster.js -var flatbuffers = __toESM(require("flatbuffers"), 1); +var flatbuffers4 = __toESM(require("flatbuffers"), 1); var Monster = class { constructor() { this.bb = null; @@ -116,7 +315,7 @@ var Monster = class { return (obj || new Monster()).__init(bb.readInt32(bb.position()) + bb.position(), bb); } static getSizePrefixedRootAsMonster(bb, obj) { - bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); + bb.setPosition(bb.position() + flatbuffers4.SIZE_PREFIX_LENGTH); return (obj || new Monster()).__init(bb.readInt32(bb.position()) + bb.position(), bb); } static getFullyQualifiedName() { @@ -137,7 +336,7 @@ var Monster = class { return this.bb.bytes(); } static deserialize(buffer) { - return Monster.getRootAsMonster(new flatbuffers.ByteBuffer(buffer)); + return Monster.getRootAsMonster(new flatbuffers4.ByteBuffer(buffer)); } unpack() { return new MonsterT(); @@ -154,7 +353,7 @@ var MonsterT = class { }; // my-game/example/monster.js -var flatbuffers6 = __toESM(require("flatbuffers"), 1); +var flatbuffers8 = __toESM(require("flatbuffers"), 1); // my-game/example/any-ambiguous-aliases.js var AnyAmbiguousAliases; @@ -180,7 +379,7 @@ function unionToAnyAmbiguousAliases(type, accessor) { } // my-game/example/test-simple-table-with-enum.js -var flatbuffers2 = __toESM(require("flatbuffers"), 1); +var flatbuffers5 = __toESM(require("flatbuffers"), 1); // my-game/example/color.js var Color; @@ -205,7 +404,7 @@ var TestSimpleTableWithEnum = class { return (obj || new TestSimpleTableWithEnum()).__init(bb.readInt32(bb.position()) + bb.position(), bb); } static getSizePrefixedRootAsTestSimpleTableWithEnum(bb, obj) { - bb.setPosition(bb.position() + flatbuffers2.SIZE_PREFIX_LENGTH); + bb.setPosition(bb.position() + flatbuffers5.SIZE_PREFIX_LENGTH); return (obj || new TestSimpleTableWithEnum()).__init(bb.readInt32(bb.position()) + bb.position(), bb); } color() { @@ -242,7 +441,7 @@ var TestSimpleTableWithEnum = class { return this.bb.bytes(); } static deserialize(buffer) { - return TestSimpleTableWithEnum.getRootAsTestSimpleTableWithEnum(new flatbuffers2.ByteBuffer(buffer)); + return TestSimpleTableWithEnum.getRootAsTestSimpleTableWithEnum(new flatbuffers5.ByteBuffer(buffer)); } unpack() { return new TestSimpleTableWithEnumT(this.color()); @@ -293,7 +492,7 @@ var Race; })(Race = Race || (Race = {})); // my-game/example/referrable.js -var flatbuffers3 = __toESM(require("flatbuffers"), 1); +var flatbuffers6 = __toESM(require("flatbuffers"), 1); var Referrable = class { constructor() { this.bb = null; @@ -308,7 +507,7 @@ var Referrable = class { return (obj || new Referrable()).__init(bb.readInt32(bb.position()) + bb.position(), bb); } static getSizePrefixedRootAsReferrable(bb, obj) { - bb.setPosition(bb.position() + flatbuffers3.SIZE_PREFIX_LENGTH); + bb.setPosition(bb.position() + flatbuffers6.SIZE_PREFIX_LENGTH); return (obj || new Referrable()).__init(bb.readInt32(bb.position()) + bb.position(), bb); } id() { @@ -345,7 +544,7 @@ var Referrable = class { return this.bb.bytes(); } static deserialize(buffer) { - return Referrable.getRootAsReferrable(new flatbuffers3.ByteBuffer(buffer)); + return Referrable.getRootAsReferrable(new flatbuffers6.ByteBuffer(buffer)); } unpack() { return new ReferrableT(this.id()); @@ -364,7 +563,7 @@ var ReferrableT = class { }; // my-game/example/stat.js -var flatbuffers4 = __toESM(require("flatbuffers"), 1); +var flatbuffers7 = __toESM(require("flatbuffers"), 1); var Stat = class { constructor() { this.bb = null; @@ -379,7 +578,7 @@ var Stat = class { return (obj || new Stat()).__init(bb.readInt32(bb.position()) + bb.position(), bb); } static getSizePrefixedRootAsStat(bb, obj) { - bb.setPosition(bb.position() + flatbuffers4.SIZE_PREFIX_LENGTH); + bb.setPosition(bb.position() + flatbuffers7.SIZE_PREFIX_LENGTH); return (obj || new Stat()).__init(bb.readInt32(bb.position()) + bb.position(), bb); } id(optionalEncoding) { @@ -440,7 +639,7 @@ var Stat = class { return this.bb.bytes(); } static deserialize(buffer) { - return Stat.getRootAsStat(new flatbuffers4.ByteBuffer(buffer)); + return Stat.getRootAsStat(new flatbuffers7.ByteBuffer(buffer)); } unpack() { return new StatT(this.id(), this.val(), this.count()); @@ -616,59 +815,6 @@ var Vec3T = class { } }; -// my-game/in-parent-namespace.js -var flatbuffers5 = __toESM(require("flatbuffers"), 1); -var InParentNamespace = class { - 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() + flatbuffers5.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 flatbuffers5.ByteBuffer(buffer)); - } - unpack() { - return new InParentNamespaceT(); - } - unpackTo(_o) { - } -}; -var InParentNamespaceT = class { - constructor() { - } - pack(builder) { - return InParentNamespace.createInParentNamespace(builder); - } -}; - // my-game/example/monster.js var Monster2 = class { constructor() { @@ -684,7 +830,7 @@ var Monster2 = class { return (obj || new Monster2()).__init(bb.readInt32(bb.position()) + bb.position(), bb); } static getSizePrefixedRootAsMonster(bb, obj) { - bb.setPosition(bb.position() + flatbuffers6.SIZE_PREFIX_LENGTH); + bb.setPosition(bb.position() + flatbuffers8.SIZE_PREFIX_LENGTH); return (obj || new Monster2()).__init(bb.readInt32(bb.position()) + bb.position(), bb); } static bufferHasIdentifier(bb) { @@ -1657,7 +1803,7 @@ var Monster2 = class { return this.bb.bytes(); } static deserialize(buffer) { - return Monster2.getRootAsMonster(new flatbuffers6.ByteBuffer(buffer)); + return Monster2.getRootAsMonster(new flatbuffers8.ByteBuffer(buffer)); } unpack() { return new MonsterT2(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(), (() => { @@ -2063,7 +2209,7 @@ var StructOfStructsOfStructsT = class { }; // my-game/example/type-aliases.js -var flatbuffers7 = __toESM(require("flatbuffers"), 1); +var flatbuffers9 = __toESM(require("flatbuffers"), 1); var TypeAliases = class { constructor() { this.bb = null; @@ -2078,7 +2224,7 @@ var TypeAliases = class { return (obj || new TypeAliases()).__init(bb.readInt32(bb.position()) + bb.position(), bb); } static getSizePrefixedRootAsTypeAliases(bb, obj) { - bb.setPosition(bb.position() + flatbuffers7.SIZE_PREFIX_LENGTH); + bb.setPosition(bb.position() + flatbuffers9.SIZE_PREFIX_LENGTH); return (obj || new TypeAliases()).__init(bb.readInt32(bb.position()) + bb.position(), bb); } i8() { @@ -2311,7 +2457,7 @@ var TypeAliases = class { return this.bb.bytes(); } static deserialize(buffer) { - return TypeAliases.getRootAsTypeAliases(new flatbuffers7.ByteBuffer(buffer)); + return TypeAliases.getRootAsTypeAliases(new flatbuffers9.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())); @@ -2352,3 +2498,68 @@ var TypeAliasesT = class { 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); } }; + +// my-game/example2.js +var example2_exports = {}; +__export(example2_exports, { + Monster: () => Monster +}); + +// my-game/other-name-space.js +var other_name_space_exports = {}; +__export(other_name_space_exports, { + FromInclude: () => FromInclude, + TableB: () => TableB, + Unused: () => Unused +}); + +// my-game/other-name-space/from-include.js +var FromInclude; +(function(FromInclude2) { + FromInclude2["IncludeVal"] = "0"; +})(FromInclude = FromInclude || (FromInclude = {})); + +// my-game/other-name-space/unused.js +var Unused = class { + constructor() { + this.bb = null; + this.bb_pos = 0; + } + __init(i, bb) { + this.bb_pos = i; + this.bb = bb; + return this; + } + a() { + return this.bb.readInt32(this.bb_pos); + } + mutate_a(value) { + this.bb.writeInt32(this.bb_pos + 0, value); + return true; + } + static getFullyQualifiedName() { + return "MyGame_OtherNameSpace_Unused"; + } + static sizeOf() { + return 4; + } + static createUnused(builder, a) { + builder.prep(4, 4); + builder.writeInt32(a); + return builder.offset(); + } + unpack() { + return new UnusedT(this.a()); + } + unpackTo(_o) { + _o.a = this.a(); + } +}; +var UnusedT = class { + constructor(a = 0) { + this.a = a; + } + pack(builder) { + return Unused.createUnused(builder, this.a); + } +}; diff --git a/tests/ts/reflection_generated.js b/tests/ts/reflection_generated.cjs similarity index 100% rename from tests/ts/reflection_generated.js rename to tests/ts/reflection_generated.cjs diff --git a/tests/ts/typescript_include_generated.js b/tests/ts/typescript_include_generated.cjs similarity index 100% rename from tests/ts/typescript_include_generated.js rename to tests/ts/typescript_include_generated.cjs diff --git a/tests/ts/typescript_keywords_generated.js b/tests/ts/typescript_keywords_generated.cjs similarity index 100% rename from tests/ts/typescript_keywords_generated.js rename to tests/ts/typescript_keywords_generated.cjs diff --git a/tests/ts/typescript_transitive_include_generated.js b/tests/ts/typescript_transitive_include_generated.cjs similarity index 100% rename from tests/ts/typescript_transitive_include_generated.js rename to tests/ts/typescript_transitive_include_generated.cjs diff --git a/tests/ts/union_vector/union_vector_generated.js b/tests/ts/union_vector/union_vector_generated.cjs similarity index 100% rename from tests/ts/union_vector/union_vector_generated.js rename to tests/ts/union_vector/union_vector_generated.cjs From 6441b029d96f55ea3c1242266b2ecbf345571bd2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Harrtell?= Date: Sat, 10 Dec 2022 12:16:31 +0100 Subject: [PATCH 27/39] Deps upgrade --- package.json | 10 +- yarn.lock | 444 ++++++++++++++++++++++++++------------------------- 2 files changed, 233 insertions(+), 221 deletions(-) diff --git a/package.json b/package.json index e9e174ef73f..abee035e916 100644 --- a/package.json +++ b/package.json @@ -49,12 +49,12 @@ "dependencies": {}, "devDependencies": { "@bazel/typescript": "5.2.0", - "@bazel/esbuild": "5.7.2", + "@bazel/esbuild": "5.7.3", "@types/node": "18.7.16", - "@typescript-eslint/eslint-plugin": "^5.36.2", - "@typescript-eslint/parser": "^5.36.2", - "esbuild": "^0.15.10", - "eslint": "^8.23.1", + "@typescript-eslint/eslint-plugin": "^5.46.0", + "@typescript-eslint/parser": "^5.46.0", + "esbuild": "^0.16.4", + "eslint": "^8.29.0", "typescript": "^4.8.3" } } diff --git a/yarn.lock b/yarn.lock index 13c6665a949..c6d0b8b7c07 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2,6 +2,11 @@ # yarn lockfile v1 +"@bazel/esbuild@5.7.3": + version "5.7.3" + resolved "https://registry.yarnpkg.com/@bazel/esbuild/-/esbuild-5.7.3.tgz#98a82b69bafd9b68dcf9aba340d67727a777bcbc" + integrity sha512-SzOmPlvI3rzYz73tHNVl3GlvfSo+NFZzuQQeJWhUq3JMHLYjUU14A9nY0WhBKTamD4MatJg9mUJOdOnXvOVtxQ== + "@bazel/typescript@5.2.0": version "5.2.0" resolved "https://registry.yarnpkg.com/@bazel/typescript/-/typescript-5.2.0.tgz#131127c8016c712ef1b291f2b52108e5326f0447" @@ -20,20 +25,120 @@ dependencies: google-protobuf "^3.6.1" -"@esbuild/android-arm@0.15.10": - version "0.15.10" - resolved "https://registry.yarnpkg.com/@esbuild/android-arm/-/android-arm-0.15.10.tgz#a5f9432eb221afc243c321058ef25fe899886892" - integrity sha512-FNONeQPy/ox+5NBkcSbYJxoXj9GWu8gVGJTVmUyoOCKQFDTrHVKgNSzChdNt0I8Aj/iKcsDf2r9BFwv+FSNUXg== - -"@esbuild/linux-loong64@0.15.10": - version "0.15.10" - resolved "https://registry.yarnpkg.com/@esbuild/linux-loong64/-/linux-loong64-0.15.10.tgz#78a42897c2cf8db9fd5f1811f7590393b77774c7" - integrity sha512-w0Ou3Z83LOYEkwaui2M8VwIp+nLi/NA60lBLMvaJ+vXVMcsARYdEzLNE7RSm4+lSg4zq4d7fAVuzk7PNQ5JFgg== - -"@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== +"@esbuild/android-arm64@0.16.4": + version "0.16.4" + resolved "https://registry.yarnpkg.com/@esbuild/android-arm64/-/android-arm64-0.16.4.tgz#4b31b9e3da2e4c12a8170bd682f713c775f68ab1" + integrity sha512-VPuTzXFm/m2fcGfN6CiwZTlLzxrKsWbPkG7ArRFpuxyaHUm/XFHQPD4xNwZT6uUmpIHhnSjcaCmcla8COzmZ5Q== + +"@esbuild/android-arm@0.16.4": + version "0.16.4" + resolved "https://registry.yarnpkg.com/@esbuild/android-arm/-/android-arm-0.16.4.tgz#057d3e8b0ee41ff59386c33ba6dcf20f4bedd1f7" + integrity sha512-rZzb7r22m20S1S7ufIc6DC6W659yxoOrl7sKP1nCYhuvUlnCFHVSbATG4keGUtV8rDz11sRRDbWkvQZpzPaHiw== + +"@esbuild/android-x64@0.16.4": + version "0.16.4" + resolved "https://registry.yarnpkg.com/@esbuild/android-x64/-/android-x64-0.16.4.tgz#62ccab8ac1d3e6ef1df3fa2e1974bc2b8528d74a" + integrity sha512-MW+B2O++BkcOfMWmuHXB15/l1i7wXhJFqbJhp82IBOais8RBEQv2vQz/jHrDEHaY2X0QY7Wfw86SBL2PbVOr0g== + +"@esbuild/darwin-arm64@0.16.4": + version "0.16.4" + resolved "https://registry.yarnpkg.com/@esbuild/darwin-arm64/-/darwin-arm64-0.16.4.tgz#c19a6489d626c36fc611c85ccd8a3333c1f2a930" + integrity sha512-a28X1O//aOfxwJVZVs7ZfM8Tyih2Za4nKJrBwW5Wm4yKsnwBy9aiS/xwpxiiTRttw3EaTg4Srerhcm6z0bu9Wg== + +"@esbuild/darwin-x64@0.16.4": + version "0.16.4" + resolved "https://registry.yarnpkg.com/@esbuild/darwin-x64/-/darwin-x64-0.16.4.tgz#b726bbc84a1e277f6ec2509d10b8ee03f242b776" + integrity sha512-e3doCr6Ecfwd7VzlaQqEPrnbvvPjE9uoTpxG5pyLzr2rI2NMjDHmvY1E5EO81O/e9TUOLLkXA5m6T8lfjK9yAA== + +"@esbuild/freebsd-arm64@0.16.4": + version "0.16.4" + resolved "https://registry.yarnpkg.com/@esbuild/freebsd-arm64/-/freebsd-arm64-0.16.4.tgz#364568e6ca2901297f247de0681c9b14bbe658c8" + integrity sha512-Oup3G/QxBgvvqnXWrBed7xxkFNwAwJVHZcklWyQt7YCAL5bfUkaa6FVWnR78rNQiM8MqqLiT6ZTZSdUFuVIg1w== + +"@esbuild/freebsd-x64@0.16.4": + version "0.16.4" + resolved "https://registry.yarnpkg.com/@esbuild/freebsd-x64/-/freebsd-x64-0.16.4.tgz#44701ba4a5497ba64eec0a6c9e221d8f46a25e72" + integrity sha512-vAP+eYOxlN/Bpo/TZmzEQapNS8W1njECrqkTpNgvXskkkJC2AwOXwZWai/Kc2vEFZUXQttx6UJbj9grqjD/+9Q== + +"@esbuild/linux-arm64@0.16.4": + version "0.16.4" + resolved "https://registry.yarnpkg.com/@esbuild/linux-arm64/-/linux-arm64-0.16.4.tgz#b58fb418ec9ac714d8dbb38c787ff2441eb1d9db" + integrity sha512-2zXoBhv4r5pZiyjBKrOdFP4CXOChxXiYD50LRUU+65DkdS5niPFHbboKZd/c81l0ezpw7AQnHeoCy5hFrzzs4g== + +"@esbuild/linux-arm@0.16.4": + version "0.16.4" + resolved "https://registry.yarnpkg.com/@esbuild/linux-arm/-/linux-arm-0.16.4.tgz#b37f15ecddb53eeea466e5960e31a58f33e0e87e" + integrity sha512-A47ZmtpIPyERxkSvIv+zLd6kNIOtJH03XA0Hy7jaceRDdQaQVGSDt4mZqpWqJYgDk9rg96aglbF6kCRvPGDSUA== + +"@esbuild/linux-ia32@0.16.4": + version "0.16.4" + resolved "https://registry.yarnpkg.com/@esbuild/linux-ia32/-/linux-ia32-0.16.4.tgz#117e32a9680b5deac184ebee122f8575369fad1b" + integrity sha512-uxdSrpe9wFhz4yBwt2kl2TxS/NWEINYBUFIxQtaEVtglm1eECvsj1vEKI0KX2k2wCe17zDdQ3v+jVxfwVfvvjw== + +"@esbuild/linux-loong64@0.16.4": + version "0.16.4" + resolved "https://registry.yarnpkg.com/@esbuild/linux-loong64/-/linux-loong64-0.16.4.tgz#dd504fb83c280752d4b485d9acb3cf391cb7bf5b" + integrity sha512-peDrrUuxbZ9Jw+DwLCh/9xmZAk0p0K1iY5d2IcwmnN+B87xw7kujOkig6ZRcZqgrXgeRGurRHn0ENMAjjD5DEg== + +"@esbuild/linux-mips64el@0.16.4": + version "0.16.4" + resolved "https://registry.yarnpkg.com/@esbuild/linux-mips64el/-/linux-mips64el-0.16.4.tgz#9ab77e31cf3be1e35572afff94b51df8149d15bd" + integrity sha512-sD9EEUoGtVhFjjsauWjflZklTNr57KdQ6xfloO4yH1u7vNQlOfAlhEzbyBKfgbJlW7rwXYBdl5/NcZ+Mg2XhQA== + +"@esbuild/linux-ppc64@0.16.4": + version "0.16.4" + resolved "https://registry.yarnpkg.com/@esbuild/linux-ppc64/-/linux-ppc64-0.16.4.tgz#69d56c2a960808bee1c7b9b84a115220ec9ce05c" + integrity sha512-X1HSqHUX9D+d0l6/nIh4ZZJ94eQky8d8z6yxAptpZE3FxCWYWvTDd9X9ST84MGZEJx04VYUD/AGgciddwO0b8g== + +"@esbuild/linux-riscv64@0.16.4": + version "0.16.4" + resolved "https://registry.yarnpkg.com/@esbuild/linux-riscv64/-/linux-riscv64-0.16.4.tgz#9fc23583f4a1508a8d352bd376340e42217e8a90" + integrity sha512-97ANpzyNp0GTXCt6SRdIx1ngwncpkV/z453ZuxbnBROCJ5p/55UjhbaG23UdHj88fGWLKPFtMoU4CBacz4j9FA== + +"@esbuild/linux-s390x@0.16.4": + version "0.16.4" + resolved "https://registry.yarnpkg.com/@esbuild/linux-s390x/-/linux-s390x-0.16.4.tgz#4cae1f70ac2943f076dd130c3c80d28f57bf75d1" + integrity sha512-pUvPQLPmbEeJRPjP0DYTC1vjHyhrnCklQmCGYbipkep+oyfTn7GTBJXoPodR7ZS5upmEyc8lzAkn2o29wD786A== + +"@esbuild/linux-x64@0.16.4": + version "0.16.4" + resolved "https://registry.yarnpkg.com/@esbuild/linux-x64/-/linux-x64-0.16.4.tgz#fdf494de07cda23a2dc4b71ff1e0848e4ee6539c" + integrity sha512-N55Q0mJs3Sl8+utPRPBrL6NLYZKBCLLx0bme/+RbjvMforTGGzFvsRl4xLTZMUBFC1poDzBEPTEu5nxizQ9Nlw== + +"@esbuild/netbsd-x64@0.16.4": + version "0.16.4" + resolved "https://registry.yarnpkg.com/@esbuild/netbsd-x64/-/netbsd-x64-0.16.4.tgz#b59ecb49087119c575c0f64d7e66001d52799e24" + integrity sha512-LHSJLit8jCObEQNYkgsDYBh2JrJT53oJO2HVdkSYLa6+zuLJh0lAr06brXIkljrlI+N7NNW1IAXGn/6IZPi3YQ== + +"@esbuild/openbsd-x64@0.16.4": + version "0.16.4" + resolved "https://registry.yarnpkg.com/@esbuild/openbsd-x64/-/openbsd-x64-0.16.4.tgz#c51e36db875948b7b11d08bafa355605a1aa289c" + integrity sha512-nLgdc6tWEhcCFg/WVFaUxHcPK3AP/bh+KEwKtl69Ay5IBqUwKDaq/6Xk0E+fh/FGjnLwqFSsarsbPHeKM8t8Sw== + +"@esbuild/sunos-x64@0.16.4": + version "0.16.4" + resolved "https://registry.yarnpkg.com/@esbuild/sunos-x64/-/sunos-x64-0.16.4.tgz#0b50e941cd44f069e9f2573321aec984244ec228" + integrity sha512-08SluG24GjPO3tXKk95/85n9kpyZtXCVwURR2i4myhrOfi3jspClV0xQQ0W0PYWHioJj+LejFMt41q+PG3mlAQ== + +"@esbuild/win32-arm64@0.16.4": + version "0.16.4" + resolved "https://registry.yarnpkg.com/@esbuild/win32-arm64/-/win32-arm64-0.16.4.tgz#d1c93b20f17355ab2221cd18e13ae2f1b68013e3" + integrity sha512-yYiRDQcqLYQSvNQcBKN7XogbrSvBE45FEQdH8fuXPl7cngzkCvpsG2H9Uey39IjQ6gqqc+Q4VXYHsQcKW0OMjQ== + +"@esbuild/win32-ia32@0.16.4": + version "0.16.4" + resolved "https://registry.yarnpkg.com/@esbuild/win32-ia32/-/win32-ia32-0.16.4.tgz#df5910e76660e0acbbdceb8d4ae6bf1efeade6ae" + integrity sha512-5rabnGIqexekYkh9zXG5waotq8mrdlRoBqAktjx2W3kb0zsI83mdCwrcAeKYirnUaTGztR5TxXcXmQrEzny83w== + +"@esbuild/win32-x64@0.16.4": + version "0.16.4" + resolved "https://registry.yarnpkg.com/@esbuild/win32-x64/-/win32-x64-0.16.4.tgz#6ec594468610c176933da1387c609558371d37e0" + integrity sha512-sN/I8FMPtmtT2Yw+Dly8Ur5vQ5a/RmC8hW7jO9PtPSQUPkowxWpcUZnqOggU7VwyT3Xkj6vcXWd3V/qTXwultQ== + +"@eslint/eslintrc@^1.3.3": + version "1.3.3" + resolved "https://registry.yarnpkg.com/@eslint/eslintrc/-/eslintrc-1.3.3.tgz#2b044ab39fdfa75b4688184f9e573ce3c5b0ff95" + integrity sha512-uj3pT6Mg+3t39fvLrj8iuCIJ38zKO9FpGtJ4BBJebJhEwjoT+KLVNCcHT5QC9NGRIEi7fZ0ZR8YRb884auB4Lg== dependencies: ajv "^6.12.4" debug "^4.3.2" @@ -45,19 +150,14 @@ minimatch "^3.1.2" strip-json-comments "^3.1.1" -"@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== +"@humanwhocodes/config-array@^0.11.6": + version "0.11.7" + resolved "https://registry.yarnpkg.com/@humanwhocodes/config-array/-/config-array-0.11.7.tgz#38aec044c6c828f6ed51d5d7ae3d9b9faf6dbb0f" + integrity sha512-kBbPWzN8oVMLb0hOUYXhmxggL/1cJE6ydvjDIGi9EnAGUyA7cLVKQg+d/Dsm+KZwx2czGHrCmMVLiyg8s5JPKw== dependencies: "@humanwhocodes/object-schema" "^1.2.1" debug "^4.1.1" - minimatch "^3.0.4" - -"@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== + minimatch "^3.0.5" "@humanwhocodes/module-importer@^1.0.1": version "1.0.1" @@ -82,7 +182,7 @@ resolved "https://registry.yarnpkg.com/@nodelib/fs.stat/-/fs.stat-2.0.5.tgz#5bd262af94e9d25bd1e71b05deed44876a222e8b" integrity sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A== -"@nodelib/fs.walk@^1.2.3": +"@nodelib/fs.walk@^1.2.3", "@nodelib/fs.walk@^1.2.8": version "1.2.8" resolved "https://registry.yarnpkg.com/@nodelib/fs.walk/-/fs.walk-1.2.8.tgz#e95737e8bb6746ddedf69c556953494f196fe69a" integrity sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg== @@ -163,85 +263,92 @@ resolved "https://registry.yarnpkg.com/@types/node/-/node-10.17.60.tgz#35f3d6213daed95da7f0f73e75bcc6980e90597b" integrity sha512-F0KIgDJfy2nA3zMLmWGKxcH2ZVEtCZXHHdOQs2gSaQ27+lNeEfGxzkIw90aXswATX7AZ33tahPbzy6KAfUreVw== -"@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== +"@types/semver@^7.3.12": + version "7.3.13" + resolved "https://registry.yarnpkg.com/@types/semver/-/semver-7.3.13.tgz#da4bfd73f49bd541d28920ab0e2bf0ee80f71c91" + integrity sha512-21cFJr9z3g5dW8B0CVI9g2O9beqaThGQ6ZFBqHfwhzLDKUxaqTIy3vnfah/UPkfOiF2pLq+tGz+W8RyCskuslw== + +"@typescript-eslint/eslint-plugin@^5.46.0": + version "5.46.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.46.0.tgz#9a96a713b9616c783501a3c1774c9e2b40217ad0" + integrity sha512-QrZqaIOzJAjv0sfjY4EjbXUi3ZOFpKfzntx22gPGr9pmFcTjcFw/1sS1LJhEubfAGwuLjNrPV0rH+D1/XZFy7Q== dependencies: - "@typescript-eslint/scope-manager" "5.36.2" - "@typescript-eslint/type-utils" "5.36.2" - "@typescript-eslint/utils" "5.36.2" + "@typescript-eslint/scope-manager" "5.46.0" + "@typescript-eslint/type-utils" "5.46.0" + "@typescript-eslint/utils" "5.46.0" debug "^4.3.4" - functional-red-black-tree "^1.0.1" ignore "^5.2.0" + natural-compare-lite "^1.4.0" regexpp "^3.2.0" semver "^7.3.7" tsutils "^3.21.0" -"@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== +"@typescript-eslint/parser@^5.46.0": + version "5.46.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-5.46.0.tgz#002d8e67122947922a62547acfed3347cbf2c0b6" + integrity sha512-joNO6zMGUZg+C73vwrKXCd8usnsmOYmgW/w5ZW0pG0RGvqeznjtGDk61EqqTpNrFLUYBW2RSBFrxdAZMqA4OZA== dependencies: - "@typescript-eslint/scope-manager" "5.36.2" - "@typescript-eslint/types" "5.36.2" - "@typescript-eslint/typescript-estree" "5.36.2" + "@typescript-eslint/scope-manager" "5.46.0" + "@typescript-eslint/types" "5.46.0" + "@typescript-eslint/typescript-estree" "5.46.0" debug "^4.3.4" -"@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== +"@typescript-eslint/scope-manager@5.46.0": + version "5.46.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-5.46.0.tgz#60790b14d0c687dd633b22b8121374764f76ce0d" + integrity sha512-7wWBq9d/GbPiIM6SqPK9tfynNxVbfpihoY5cSFMer19OYUA3l4powA2uv0AV2eAZV6KoAh6lkzxv4PoxOLh1oA== dependencies: - "@typescript-eslint/types" "5.36.2" - "@typescript-eslint/visitor-keys" "5.36.2" + "@typescript-eslint/types" "5.46.0" + "@typescript-eslint/visitor-keys" "5.46.0" -"@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== +"@typescript-eslint/type-utils@5.46.0": + version "5.46.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/type-utils/-/type-utils-5.46.0.tgz#3a4507b3b437e2fd9e95c3e5eea5ae16f79d64b3" + integrity sha512-dwv4nimVIAsVS2dTA0MekkWaRnoYNXY26dKz8AN5W3cBFYwYGFQEqm/cG+TOoooKlncJS4RTbFKgcFY/pOiBCg== dependencies: - "@typescript-eslint/typescript-estree" "5.36.2" - "@typescript-eslint/utils" "5.36.2" + "@typescript-eslint/typescript-estree" "5.46.0" + "@typescript-eslint/utils" "5.46.0" 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/types@5.46.0": + version "5.46.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-5.46.0.tgz#f4d76622a996b88153bbd829ea9ccb9f7a5d28bc" + integrity sha512-wHWgQHFB+qh6bu0IAPAJCdeCdI0wwzZnnWThlmHNY01XJ9Z97oKqKOzWYpR2I83QmshhQJl6LDM9TqMiMwJBTw== -"@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== +"@typescript-eslint/typescript-estree@5.46.0": + version "5.46.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-5.46.0.tgz#a6c2b84b9351f78209a1d1f2d99ca553f7fa29a5" + integrity sha512-kDLNn/tQP+Yp8Ro2dUpyyVV0Ksn2rmpPpB0/3MO874RNmXtypMwSeazjEN/Q6CTp8D7ExXAAekPEcCEB/vtJkw== dependencies: - "@typescript-eslint/types" "5.36.2" - "@typescript-eslint/visitor-keys" "5.36.2" + "@typescript-eslint/types" "5.46.0" + "@typescript-eslint/visitor-keys" "5.46.0" debug "^4.3.4" globby "^11.1.0" is-glob "^4.0.3" semver "^7.3.7" tsutils "^3.21.0" -"@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== +"@typescript-eslint/utils@5.46.0": + version "5.46.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-5.46.0.tgz#600cd873ba471b7d8b0b9f35de34cf852c6fcb31" + integrity sha512-4O+Ps1CRDw+D+R40JYh5GlKLQERXRKW5yIQoNDpmXPJ+C7kaPF9R7GWl+PxGgXjB3PQCqsaaZUpZ9dG4U6DO7g== dependencies: "@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" + "@types/semver" "^7.3.12" + "@typescript-eslint/scope-manager" "5.46.0" + "@typescript-eslint/types" "5.46.0" + "@typescript-eslint/typescript-estree" "5.46.0" eslint-scope "^5.1.1" eslint-utils "^3.0.0" + semver "^7.3.7" -"@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== +"@typescript-eslint/visitor-keys@5.46.0": + version "5.46.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-5.46.0.tgz#36d87248ae20c61ef72404bcd61f14aa2563915f" + integrity sha512-E13gBoIXmaNhwjipuvQg1ByqSAu/GbEpP/qzFihugJ+MomtoJtFAJG/+2DRPByf57B863m0/q7Zt16V9ohhANw== dependencies: - "@typescript-eslint/types" "5.36.2" + "@typescript-eslint/types" "5.46.0" eslint-visitor-keys "^3.3.0" acorn-jsx@^5.3.2: @@ -376,133 +483,33 @@ doctrine@^3.0.0: dependencies: esutils "^2.0.2" -esbuild-android-64@0.15.10: - version "0.15.10" - resolved "https://registry.yarnpkg.com/esbuild-android-64/-/esbuild-android-64-0.15.10.tgz#8a59a84acbf2eca96996cadc35642cf055c494f0" - integrity sha512-UI7krF8OYO1N7JYTgLT9ML5j4+45ra3amLZKx7LO3lmLt1Ibn8t3aZbX5Pu4BjWiqDuJ3m/hsvhPhK/5Y/YpnA== - -esbuild-android-arm64@0.15.10: - version "0.15.10" - resolved "https://registry.yarnpkg.com/esbuild-android-arm64/-/esbuild-android-arm64-0.15.10.tgz#f453851dc1d8c5409a38cf7613a33852faf4915d" - integrity sha512-EOt55D6xBk5O05AK8brXUbZmoFj4chM8u3riGflLa6ziEoVvNjRdD7Cnp82NHQGfSHgYR06XsPI8/sMuA/cUwg== - -esbuild-darwin-64@0.15.10: - version "0.15.10" - resolved "https://registry.yarnpkg.com/esbuild-darwin-64/-/esbuild-darwin-64-0.15.10.tgz#778bd29c8186ff47b176c8af58c08cf0fb8e6b86" - integrity sha512-hbDJugTicqIm+WKZgp208d7FcXcaK8j2c0l+fqSJ3d2AzQAfjEYDRM3Z2oMeqSJ9uFxyj/muSACLdix7oTstRA== - -esbuild-darwin-arm64@0.15.10: - version "0.15.10" - resolved "https://registry.yarnpkg.com/esbuild-darwin-arm64/-/esbuild-darwin-arm64-0.15.10.tgz#b30bbefb46dc3c5d4708b0435e52f6456578d6df" - integrity sha512-M1t5+Kj4IgSbYmunf2BB6EKLkWUq+XlqaFRiGOk8bmBapu9bCDrxjf4kUnWn59Dka3I27EiuHBKd1rSO4osLFQ== - -esbuild-freebsd-64@0.15.10: - version "0.15.10" - resolved "https://registry.yarnpkg.com/esbuild-freebsd-64/-/esbuild-freebsd-64-0.15.10.tgz#ab301c5f6ded5110dbdd611140bef1a7c2e99236" - integrity sha512-KMBFMa7C8oc97nqDdoZwtDBX7gfpolkk6Bcmj6YFMrtCMVgoU/x2DI1p74DmYl7CSS6Ppa3xgemrLrr5IjIn0w== - -esbuild-freebsd-arm64@0.15.10: - version "0.15.10" - resolved "https://registry.yarnpkg.com/esbuild-freebsd-arm64/-/esbuild-freebsd-arm64-0.15.10.tgz#a5b09b867a6ff49110f52343b6f12265db63d43f" - integrity sha512-m2KNbuCX13yQqLlbSojFMHpewbn8wW5uDS6DxRpmaZKzyq8Dbsku6hHvh2U+BcLwWY4mpgXzFUoENEf7IcioGg== - -esbuild-linux-32@0.15.10: - version "0.15.10" - resolved "https://registry.yarnpkg.com/esbuild-linux-32/-/esbuild-linux-32-0.15.10.tgz#5282fe9915641caf9c8070e4ba2c3e16d358f837" - integrity sha512-guXrwSYFAvNkuQ39FNeV4sNkNms1bLlA5vF1H0cazZBOLdLFIny6BhT+TUbK/hdByMQhtWQ5jI9VAmPKbVPu1w== - -esbuild-linux-64@0.15.10: - version "0.15.10" - resolved "https://registry.yarnpkg.com/esbuild-linux-64/-/esbuild-linux-64-0.15.10.tgz#f3726e85a00149580cb19f8abfabcbb96f5d52bb" - integrity sha512-jd8XfaSJeucMpD63YNMO1JCrdJhckHWcMv6O233bL4l6ogQKQOxBYSRP/XLWP+6kVTu0obXovuckJDcA0DKtQA== - -esbuild-linux-arm64@0.15.10: - version "0.15.10" - resolved "https://registry.yarnpkg.com/esbuild-linux-arm64/-/esbuild-linux-arm64-0.15.10.tgz#2f0056e9d5286edb0185b56655caa8c574d8dbe7" - integrity sha512-GByBi4fgkvZFTHFDYNftu1DQ1GzR23jws0oWyCfhnI7eMOe+wgwWrc78dbNk709Ivdr/evefm2PJiUBMiusS1A== - -esbuild-linux-arm@0.15.10: - version "0.15.10" - resolved "https://registry.yarnpkg.com/esbuild-linux-arm/-/esbuild-linux-arm-0.15.10.tgz#40a9270da3c8ffa32cf72e24a79883e323dff08d" - integrity sha512-6N8vThLL/Lysy9y4Ex8XoLQAlbZKUyExCWyayGi2KgTBelKpPgj6RZnUaKri0dHNPGgReJriKVU6+KDGQwn10A== - -esbuild-linux-mips64le@0.15.10: - version "0.15.10" - resolved "https://registry.yarnpkg.com/esbuild-linux-mips64le/-/esbuild-linux-mips64le-0.15.10.tgz#90ce1c4ee0202edb4ac69807dea77f7e5804abc4" - integrity sha512-BxP+LbaGVGIdQNJUNF7qpYjEGWb0YyHVSKqYKrn+pTwH/SiHUxFyJYSP3pqkku61olQiSBnSmWZ+YUpj78Tw7Q== - -esbuild-linux-ppc64le@0.15.10: - version "0.15.10" - resolved "https://registry.yarnpkg.com/esbuild-linux-ppc64le/-/esbuild-linux-ppc64le-0.15.10.tgz#782837ae7bd5b279178106c9dd801755a21fabdf" - integrity sha512-LoSQCd6498PmninNgqd/BR7z3Bsk/mabImBWuQ4wQgmQEeanzWd5BQU2aNi9mBURCLgyheuZS6Xhrw5luw3OkQ== - -esbuild-linux-riscv64@0.15.10: - version "0.15.10" - resolved "https://registry.yarnpkg.com/esbuild-linux-riscv64/-/esbuild-linux-riscv64-0.15.10.tgz#d7420d806ece5174f24f4634303146f915ab4207" - integrity sha512-Lrl9Cr2YROvPV4wmZ1/g48httE8z/5SCiXIyebiB5N8VT7pX3t6meI7TQVHw/wQpqP/AF4SksDuFImPTM7Z32Q== - -esbuild-linux-s390x@0.15.10: - version "0.15.10" - resolved "https://registry.yarnpkg.com/esbuild-linux-s390x/-/esbuild-linux-s390x-0.15.10.tgz#21fdf0cb3494a7fb520a71934e4dffce67fe47be" - integrity sha512-ReP+6q3eLVVP2lpRrvl5EodKX7EZ1bS1/z5j6hsluAlZP5aHhk6ghT6Cq3IANvvDdscMMCB4QEbI+AjtvoOFpA== - -esbuild-netbsd-64@0.15.10: - version "0.15.10" - resolved "https://registry.yarnpkg.com/esbuild-netbsd-64/-/esbuild-netbsd-64-0.15.10.tgz#6c06b3107e3df53de381e6299184d4597db0440f" - integrity sha512-iGDYtJCMCqldMskQ4eIV+QSS/CuT7xyy9i2/FjpKvxAuCzrESZXiA1L64YNj6/afuzfBe9i8m/uDkFHy257hTw== - -esbuild-openbsd-64@0.15.10: - version "0.15.10" - resolved "https://registry.yarnpkg.com/esbuild-openbsd-64/-/esbuild-openbsd-64-0.15.10.tgz#4daef5f5d8e74bbda53b65160029445d582570cf" - integrity sha512-ftMMIwHWrnrYnvuJQRJs/Smlcb28F9ICGde/P3FUTCgDDM0N7WA0o9uOR38f5Xe2/OhNCgkjNeb7QeaE3cyWkQ== - -esbuild-sunos-64@0.15.10: - version "0.15.10" - resolved "https://registry.yarnpkg.com/esbuild-sunos-64/-/esbuild-sunos-64-0.15.10.tgz#5fe7bef267a02f322fd249a8214d0274937388a7" - integrity sha512-mf7hBL9Uo2gcy2r3rUFMjVpTaGpFJJE5QTDDqUFf1632FxteYANffDZmKbqX0PfeQ2XjUDE604IcE7OJeoHiyg== - -esbuild-windows-32@0.15.10: - version "0.15.10" - resolved "https://registry.yarnpkg.com/esbuild-windows-32/-/esbuild-windows-32-0.15.10.tgz#48e3dde25ab0135579a288b30ab6ddef6d1f0b28" - integrity sha512-ttFVo+Cg8b5+qHmZHbEc8Vl17kCleHhLzgT8X04y8zudEApo0PxPg9Mz8Z2cKH1bCYlve1XL8LkyXGFjtUYeGg== - -esbuild-windows-64@0.15.10: - version "0.15.10" - resolved "https://registry.yarnpkg.com/esbuild-windows-64/-/esbuild-windows-64-0.15.10.tgz#387a9515bef3fee502d277a5d0a2db49a4ecda05" - integrity sha512-2H0gdsyHi5x+8lbng3hLbxDWR7mKHWh5BXZGKVG830KUmXOOWFE2YKJ4tHRkejRduOGDrBvHBriYsGtmTv3ntA== - -esbuild-windows-arm64@0.15.10: - version "0.15.10" - resolved "https://registry.yarnpkg.com/esbuild-windows-arm64/-/esbuild-windows-arm64-0.15.10.tgz#5a6fcf2fa49e895949bf5495cf088ab1b43ae879" - integrity sha512-S+th4F+F8VLsHLR0zrUcG+Et4hx0RKgK1eyHc08kztmLOES8BWwMiaGdoW9hiXuzznXQ0I/Fg904MNbr11Nktw== - -esbuild@^0.15.10: - version "0.15.10" - resolved "https://registry.yarnpkg.com/esbuild/-/esbuild-0.15.10.tgz#85c2f8446e9b1fe04fae68daceacba033eedbd42" - integrity sha512-N7wBhfJ/E5fzn/SpNgX+oW2RLRjwaL8Y0ezqNqhjD6w0H2p0rDuEz2FKZqpqLnO8DCaWumKe8dsC/ljvVSSxng== +esbuild@^0.16.4: + version "0.16.4" + resolved "https://registry.yarnpkg.com/esbuild/-/esbuild-0.16.4.tgz#06c86298d233386f5e41bcc14d36086daf3f40bd" + integrity sha512-qQrPMQpPTWf8jHugLWHoGqZjApyx3OEm76dlTXobHwh/EBbavbRdjXdYi/GWr43GyN0sfpap14GPkb05NH3ROA== optionalDependencies: - "@esbuild/android-arm" "0.15.10" - "@esbuild/linux-loong64" "0.15.10" - esbuild-android-64 "0.15.10" - esbuild-android-arm64 "0.15.10" - esbuild-darwin-64 "0.15.10" - esbuild-darwin-arm64 "0.15.10" - esbuild-freebsd-64 "0.15.10" - esbuild-freebsd-arm64 "0.15.10" - esbuild-linux-32 "0.15.10" - esbuild-linux-64 "0.15.10" - esbuild-linux-arm "0.15.10" - esbuild-linux-arm64 "0.15.10" - esbuild-linux-mips64le "0.15.10" - esbuild-linux-ppc64le "0.15.10" - esbuild-linux-riscv64 "0.15.10" - esbuild-linux-s390x "0.15.10" - esbuild-netbsd-64 "0.15.10" - esbuild-openbsd-64 "0.15.10" - esbuild-sunos-64 "0.15.10" - esbuild-windows-32 "0.15.10" - esbuild-windows-64 "0.15.10" - esbuild-windows-arm64 "0.15.10" + "@esbuild/android-arm" "0.16.4" + "@esbuild/android-arm64" "0.16.4" + "@esbuild/android-x64" "0.16.4" + "@esbuild/darwin-arm64" "0.16.4" + "@esbuild/darwin-x64" "0.16.4" + "@esbuild/freebsd-arm64" "0.16.4" + "@esbuild/freebsd-x64" "0.16.4" + "@esbuild/linux-arm" "0.16.4" + "@esbuild/linux-arm64" "0.16.4" + "@esbuild/linux-ia32" "0.16.4" + "@esbuild/linux-loong64" "0.16.4" + "@esbuild/linux-mips64el" "0.16.4" + "@esbuild/linux-ppc64" "0.16.4" + "@esbuild/linux-riscv64" "0.16.4" + "@esbuild/linux-s390x" "0.16.4" + "@esbuild/linux-x64" "0.16.4" + "@esbuild/netbsd-x64" "0.16.4" + "@esbuild/openbsd-x64" "0.16.4" + "@esbuild/sunos-x64" "0.16.4" + "@esbuild/win32-arm64" "0.16.4" + "@esbuild/win32-ia32" "0.16.4" + "@esbuild/win32-x64" "0.16.4" escape-string-regexp@^4.0.0: version "4.0.0" @@ -542,15 +549,15 @@ eslint-visitor-keys@^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== +eslint@^8.29.0: + version "8.29.0" + resolved "https://registry.yarnpkg.com/eslint/-/eslint-8.29.0.tgz#d74a88a20fb44d59c51851625bc4ee8d0ec43f87" + integrity sha512-isQ4EEiyUjZFbEKvEGJKKGBwXtvXX+zJbkVKCgTuB9t/+jUBcy8avhkEwWJecI15BkRkOYmvIM5ynbhRjEkoeg== dependencies: - "@eslint/eslintrc" "^1.3.2" - "@humanwhocodes/config-array" "^0.10.4" - "@humanwhocodes/gitignore-to-minimatch" "^1.0.2" + "@eslint/eslintrc" "^1.3.3" + "@humanwhocodes/config-array" "^0.11.6" "@humanwhocodes/module-importer" "^1.0.1" + "@nodelib/fs.walk" "^1.2.8" ajv "^6.10.0" chalk "^4.0.0" cross-spawn "^7.0.2" @@ -566,14 +573,14 @@ eslint@^8.23.1: fast-deep-equal "^3.1.3" file-entry-cache "^6.0.1" find-up "^5.0.0" - glob-parent "^6.0.1" + glob-parent "^6.0.2" 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" + is-path-inside "^3.0.3" js-sdsl "^4.1.4" js-yaml "^4.1.0" json-stable-stringify-without-jsonify "^1.0.1" @@ -698,11 +705,6 @@ fs.realpath@^1.0.0: resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f" integrity sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw== -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 sha512-dsKNQNdj6xA3T+QlADDA7mOSlX0qiMINjn0cgr+eGHGsbSHzTabcIogz2+p/iqP1Xs6EP/sS2SbqH+brGTbq0g== - glob-parent@^5.1.2: version "5.1.2" resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-5.1.2.tgz#869832c58034fe68a4093c17dc15e8340d8401c4" @@ -710,7 +712,7 @@ glob-parent@^5.1.2: dependencies: is-glob "^4.0.1" -glob-parent@^6.0.1: +glob-parent@^6.0.2: version "6.0.2" resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-6.0.2.tgz#6d237d99083950c79290f24c7642a3de9a28f9e3" integrity sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A== @@ -811,6 +813,11 @@ is-number@^7.0.0: resolved "https://registry.yarnpkg.com/is-number/-/is-number-7.0.0.tgz#7535345b896734d5f80c4d06c50955527a14f12b" integrity sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng== +is-path-inside@^3.0.3: + version "3.0.3" + resolved "https://registry.yarnpkg.com/is-path-inside/-/is-path-inside-3.0.3.tgz#d231362e53a07ff2b0e0ea7fed049161ffd16283" + integrity sha512-Fd4gABb+ycGAmKou8eMftCupSir5lRxqf4aD/vd0cD2qc4HL07OjCeuHMr8Ro4CoMaeCKDB0/ECBOVWjTwUvPQ== + isexe@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10" @@ -883,7 +890,7 @@ micromatch@^4.0.4: braces "^3.0.2" picomatch "^2.3.1" -minimatch@^3.0.4, minimatch@^3.1.1, minimatch@^3.1.2: +minimatch@^3.0.5, 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== @@ -895,6 +902,11 @@ ms@2.1.2: resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.2.tgz#d09d1f357b443f493382a8eb3ccd183872ae6009" integrity sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w== +natural-compare-lite@^1.4.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/natural-compare-lite/-/natural-compare-lite-1.4.0.tgz#17b09581988979fddafe0201e931ba933c96cbb4" + integrity sha512-Tj+HTDSJJKaZnfiuw+iaF9skdPpTo2GtEly5JHnWV/hfv2Qj/9RKsGISQtLh2ox3l5EAGw487hnBee0sIJ6v2g== + natural-compare@^1.4.0: version "1.4.0" resolved "https://registry.yarnpkg.com/natural-compare/-/natural-compare-1.4.0.tgz#4abebfeed7541f2c27acfb29bdbbd15c8d5ba4f7" From 595bf4f9ee533e7c2a2acf9dc0f46f0cc6c26842 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Harrtell?= Date: Sat, 10 Dec 2022 12:17:45 +0100 Subject: [PATCH 28/39] Clang format fix --- src/idl_gen_ts.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/idl_gen_ts.cpp b/src/idl_gen_ts.cpp index da52659b02d..20df9bfae69 100644 --- a/src/idl_gen_ts.cpp +++ b/src/idl_gen_ts.cpp @@ -309,7 +309,8 @@ class TsGenerator : public BaseGenerator { cmd += bundlepath; cmd += " --external:flatbuffers"; std::cout << "Entry point " << inputpath << " generated." << std::endl; - std::cout << "A single file bundle can be created using fx. esbuild with:" << std::endl; + std::cout << "A single file bundle can be created using fx. esbuild with:" + << std::endl; std::cout << "> " << cmd << std::endl; } return true; From 11271d4f0cd0c4dcd44e84a89135869aef297baf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Harrtell?= Date: Sat, 10 Dec 2022 12:21:19 +0100 Subject: [PATCH 29/39] Revert bazel changes --- package.json | 1 - ts/BUILD.bazel | 5 +---- yarn.lock | 5 ----- 3 files changed, 1 insertion(+), 10 deletions(-) diff --git a/package.json b/package.json index abee035e916..60a3aa7f437 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,6 @@ "dependencies": {}, "devDependencies": { "@bazel/typescript": "5.2.0", - "@bazel/esbuild": "5.7.3", "@types/node": "18.7.16", "@typescript-eslint/eslint-plugin": "^5.46.0", "@typescript-eslint/parser": "^5.46.0", diff --git a/ts/BUILD.bazel b/ts/BUILD.bazel index 5d346fc5fe1..cb3cb0f2607 100644 --- a/ts/BUILD.bazel +++ b/ts/BUILD.bazel @@ -28,10 +28,7 @@ ts_project( }, }, visibility = ["//visibility:public"], - deps = [ - "@npm//@bazel/esbuild", - "@npm//@types/node", - ], + deps = ["@npm//@types/node"], ) js_library( diff --git a/yarn.lock b/yarn.lock index c6d0b8b7c07..0150fa9813e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2,11 +2,6 @@ # yarn lockfile v1 -"@bazel/esbuild@5.7.3": - version "5.7.3" - resolved "https://registry.yarnpkg.com/@bazel/esbuild/-/esbuild-5.7.3.tgz#98a82b69bafd9b68dcf9aba340d67727a777bcbc" - integrity sha512-SzOmPlvI3rzYz73tHNVl3GlvfSo+NFZzuQQeJWhUq3JMHLYjUU14A9nY0WhBKTamD4MatJg9mUJOdOnXvOVtxQ== - "@bazel/typescript@5.2.0": version "5.2.0" resolved "https://registry.yarnpkg.com/@bazel/typescript/-/typescript-5.2.0.tgz#131127c8016c712ef1b291f2b52108e5326f0447" From 63b28c6cc34a6cd88ba85e6b98e0d157f715c77c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Harrtell?= Date: Sat, 10 Dec 2022 12:23:28 +0100 Subject: [PATCH 30/39] Fix newline --- typescript.bzl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/typescript.bzl b/typescript.bzl index 18d9c58a14f..f112f34f958 100644 --- a/typescript.bzl +++ b/typescript.bzl @@ -131,4 +131,4 @@ def flatbuffer_ts_library( compatible_with = compatible_with, restricted_to = restricted_to, visibility = visibility, - ) \ No newline at end of file + ) From 4aca077ab264cbb2b43ef436c7af63b1938e9646 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Harrtell?= Date: Fri, 23 Dec 2022 16:01:08 +0100 Subject: [PATCH 31/39] Generate with type declarations --- .../arrays_test_complex/my-game/example.d.ts | 6 + .../my-game/example/array-struct.d.ts | 31 ++ .../my-game/example/array-table.d.ts | 28 ++ .../my-game/example/inner-struct.d.ts | 23 ++ .../my-game/example/nested-struct.d.ts | 27 ++ .../my-game/example/outer-struct.d.ts | 28 ++ .../my-game/example/test-enum.d.ts | 5 + tests/ts/foobar/abc.d.ts | 3 + tests/ts/foobar/class.d.ts | 3 + tests/ts/monster_test.d.ts | 2 + tests/ts/monster_test_generated.cjs | 24 +- tests/ts/my-game.d.ts | 4 + tests/ts/my-game/example.d.ts | 16 + tests/ts/my-game/example/ability.d.ts | 21 ++ .../example/any-ambiguous-aliases.d.ts | 9 + .../my-game/example/any-unique-aliases.d.ts | 11 + tests/ts/my-game/example/any.d.ts | 11 + tests/ts/my-game/example/color.d.ts | 15 + tests/ts/my-game/example/long-enum.d.ts | 5 + tests/ts/my-game/example/monster.d.ts | 325 ++++++++++++++++++ tests/ts/my-game/example/race.d.ts | 6 + tests/ts/my-game/example/referrable.d.ts | 24 ++ tests/ts/my-game/example/stat.d.ts | 32 ++ .../example/struct-of-structs-of-structs.d.ts | 18 + .../ts/my-game/example/struct-of-structs.d.ts | 23 ++ .../example/test-simple-table-with-enum.d.ts | 25 ++ tests/ts/my-game/example/test.d.ts | 21 ++ tests/ts/my-game/example/type-aliases.d.ts | 82 +++++ tests/ts/my-game/example/vec3.d.ts | 34 ++ tests/ts/my-game/example2.d.ts | 1 + tests/ts/my-game/example2/monster.d.ts | 20 ++ tests/ts/my-game/in-parent-namespace.d.ts | 20 ++ tests/ts/my-game/other-name-space.d.ts | 3 + .../other-name-space/from-include.d.ts | 3 + .../ts/my-game/other-name-space/table-b.d.ts | 24 ++ tests/ts/my-game/other-name-space/unused.d.ts | 18 + tests/ts/reflection/base-type.d.ts | 21 ++ tests/ts/reflection/enum-val.d.ts | 43 +++ tests/ts/reflection/enum.d.ts | 57 +++ tests/ts/reflection/field.d.ts | 78 +++++ tests/ts/reflection/key-value.d.ts | 26 ++ tests/ts/reflection/object.d.ts | 62 ++++ tests/ts/reflection/rpccall.d.ts | 42 +++ tests/ts/reflection/schema-file.d.ts | 40 +++ tests/ts/reflection/schema.d.ts | 67 ++++ tests/ts/reflection/service.d.ts | 50 +++ tests/ts/reflection/type.d.ts | 49 +++ tests/ts/reflection_generated.cjs | 20 +- tests/ts/table-a.d.ts | 24 ++ tests/ts/tsconfig.json | 1 + tests/ts/typescript/class.d.ts | 4 + tests/ts/typescript/object.d.ts | 48 +++ tests/ts/typescript_keywords_generated.cjs | 22 +- tests/ts/union_vector/attacker.d.ts | 22 ++ tests/ts/union_vector/book-reader.d.ts | 18 + tests/ts/union_vector/character.d.ts | 14 + tests/ts/union_vector/falling-tub.d.ts | 18 + tests/ts/union_vector/gadget.d.ts | 9 + tests/ts/union_vector/hand-fan.d.ts | 22 ++ tests/ts/union_vector/movie.d.ts | 44 +++ tests/ts/union_vector/rapunzel.d.ts | 18 + tests/ts/union_vector/union_vector.d.ts | 8 + 62 files changed, 1745 insertions(+), 33 deletions(-) create mode 100644 tests/ts/arrays_test_complex/my-game/example.d.ts create mode 100644 tests/ts/arrays_test_complex/my-game/example/array-struct.d.ts create mode 100644 tests/ts/arrays_test_complex/my-game/example/array-table.d.ts create mode 100644 tests/ts/arrays_test_complex/my-game/example/inner-struct.d.ts create mode 100644 tests/ts/arrays_test_complex/my-game/example/nested-struct.d.ts create mode 100644 tests/ts/arrays_test_complex/my-game/example/outer-struct.d.ts create mode 100644 tests/ts/arrays_test_complex/my-game/example/test-enum.d.ts create mode 100644 tests/ts/foobar/abc.d.ts create mode 100644 tests/ts/foobar/class.d.ts create mode 100644 tests/ts/monster_test.d.ts create mode 100644 tests/ts/my-game.d.ts create mode 100644 tests/ts/my-game/example.d.ts create mode 100644 tests/ts/my-game/example/ability.d.ts create mode 100644 tests/ts/my-game/example/any-ambiguous-aliases.d.ts create mode 100644 tests/ts/my-game/example/any-unique-aliases.d.ts create mode 100644 tests/ts/my-game/example/any.d.ts create mode 100644 tests/ts/my-game/example/color.d.ts create mode 100644 tests/ts/my-game/example/long-enum.d.ts create mode 100644 tests/ts/my-game/example/monster.d.ts create mode 100644 tests/ts/my-game/example/race.d.ts create mode 100644 tests/ts/my-game/example/referrable.d.ts create mode 100644 tests/ts/my-game/example/stat.d.ts create mode 100644 tests/ts/my-game/example/struct-of-structs-of-structs.d.ts create mode 100644 tests/ts/my-game/example/struct-of-structs.d.ts create mode 100644 tests/ts/my-game/example/test-simple-table-with-enum.d.ts create mode 100644 tests/ts/my-game/example/test.d.ts create mode 100644 tests/ts/my-game/example/type-aliases.d.ts create mode 100644 tests/ts/my-game/example/vec3.d.ts create mode 100644 tests/ts/my-game/example2.d.ts create mode 100644 tests/ts/my-game/example2/monster.d.ts create mode 100644 tests/ts/my-game/in-parent-namespace.d.ts create mode 100644 tests/ts/my-game/other-name-space.d.ts create mode 100644 tests/ts/my-game/other-name-space/from-include.d.ts create mode 100644 tests/ts/my-game/other-name-space/table-b.d.ts create mode 100644 tests/ts/my-game/other-name-space/unused.d.ts create mode 100644 tests/ts/reflection/base-type.d.ts create mode 100644 tests/ts/reflection/enum-val.d.ts create mode 100644 tests/ts/reflection/enum.d.ts create mode 100644 tests/ts/reflection/field.d.ts create mode 100644 tests/ts/reflection/key-value.d.ts create mode 100644 tests/ts/reflection/object.d.ts create mode 100644 tests/ts/reflection/rpccall.d.ts create mode 100644 tests/ts/reflection/schema-file.d.ts create mode 100644 tests/ts/reflection/schema.d.ts create mode 100644 tests/ts/reflection/service.d.ts create mode 100644 tests/ts/reflection/type.d.ts create mode 100644 tests/ts/table-a.d.ts create mode 100644 tests/ts/typescript/class.d.ts create mode 100644 tests/ts/typescript/object.d.ts create mode 100644 tests/ts/union_vector/attacker.d.ts create mode 100644 tests/ts/union_vector/book-reader.d.ts create mode 100644 tests/ts/union_vector/character.d.ts create mode 100644 tests/ts/union_vector/falling-tub.d.ts create mode 100644 tests/ts/union_vector/gadget.d.ts create mode 100644 tests/ts/union_vector/hand-fan.d.ts create mode 100644 tests/ts/union_vector/movie.d.ts create mode 100644 tests/ts/union_vector/rapunzel.d.ts create mode 100644 tests/ts/union_vector/union_vector.d.ts diff --git a/tests/ts/arrays_test_complex/my-game/example.d.ts b/tests/ts/arrays_test_complex/my-game/example.d.ts new file mode 100644 index 00000000000..93eb52518e9 --- /dev/null +++ b/tests/ts/arrays_test_complex/my-game/example.d.ts @@ -0,0 +1,6 @@ +export { ArrayStruct } from './example/array-struct.js'; +export { ArrayTable } from './example/array-table.js'; +export { InnerStruct } from './example/inner-struct.js'; +export { NestedStruct } from './example/nested-struct.js'; +export { OuterStruct } from './example/outer-struct.js'; +export { TestEnum } from './example/test-enum.js'; diff --git a/tests/ts/arrays_test_complex/my-game/example/array-struct.d.ts b/tests/ts/arrays_test_complex/my-game/example/array-struct.d.ts new file mode 100644 index 00000000000..80acd750766 --- /dev/null +++ b/tests/ts/arrays_test_complex/my-game/example/array-struct.d.ts @@ -0,0 +1,31 @@ +import * as flatbuffers from 'flatbuffers'; +import { NestedStruct, NestedStructT } from '../../my-game/example/nested-struct.js'; +import { OuterStruct, OuterStructT } from '../../my-game/example/outer-struct.js'; +export declare class ArrayStruct implements flatbuffers.IUnpackableObject { + bb: flatbuffers.ByteBuffer | null; + bb_pos: number; + __init(i: number, bb: flatbuffers.ByteBuffer): ArrayStruct; + aUnderscore(): number; + bUnderscore(index: number): number | null; + c(): number; + d(index: number, obj?: NestedStruct): NestedStruct | null; + e(): number; + f(index: number, obj?: OuterStruct): OuterStruct | null; + g(index: number): bigint | null; + static getFullyQualifiedName(): string; + static sizeOf(): number; + static createArrayStruct(builder: flatbuffers.Builder, a_underscore: number, b_underscore: number[] | null, c: number, d: (any | NestedStructT)[] | null, e: number, f: (any | OuterStructT)[] | null, g: bigint[] | null): flatbuffers.Offset; + unpack(): ArrayStructT; + unpackTo(_o: ArrayStructT): void; +} +export declare class ArrayStructT implements flatbuffers.IGeneratedObject { + aUnderscore: number; + bUnderscore: (number)[]; + c: number; + d: (NestedStructT)[]; + e: number; + f: (OuterStructT)[]; + g: (bigint)[]; + constructor(aUnderscore?: number, bUnderscore?: (number)[], c?: number, d?: (NestedStructT)[], e?: number, f?: (OuterStructT)[], g?: (bigint)[]); + pack(builder: flatbuffers.Builder): flatbuffers.Offset; +} diff --git a/tests/ts/arrays_test_complex/my-game/example/array-table.d.ts b/tests/ts/arrays_test_complex/my-game/example/array-table.d.ts new file mode 100644 index 00000000000..d4ddd067762 --- /dev/null +++ b/tests/ts/arrays_test_complex/my-game/example/array-table.d.ts @@ -0,0 +1,28 @@ +import * as flatbuffers from 'flatbuffers'; +import { ArrayStruct, ArrayStructT } from '../../my-game/example/array-struct.js'; +export declare class ArrayTable implements flatbuffers.IUnpackableObject { + bb: flatbuffers.ByteBuffer | null; + bb_pos: number; + __init(i: number, bb: flatbuffers.ByteBuffer): ArrayTable; + static getRootAsArrayTable(bb: flatbuffers.ByteBuffer, obj?: ArrayTable): ArrayTable; + static getSizePrefixedRootAsArrayTable(bb: flatbuffers.ByteBuffer, obj?: ArrayTable): ArrayTable; + static bufferHasIdentifier(bb: flatbuffers.ByteBuffer): boolean; + a(): string | null; + a(optionalEncoding: flatbuffers.Encoding): string | Uint8Array | null; + cUnderscore(obj?: ArrayStruct): ArrayStruct | null; + static getFullyQualifiedName(): string; + static startArrayTable(builder: flatbuffers.Builder): void; + static addA(builder: flatbuffers.Builder, aOffset: flatbuffers.Offset): void; + static addCUnderscore(builder: flatbuffers.Builder, cUnderscoreOffset: flatbuffers.Offset): void; + static endArrayTable(builder: flatbuffers.Builder): flatbuffers.Offset; + static finishArrayTableBuffer(builder: flatbuffers.Builder, offset: flatbuffers.Offset): void; + static finishSizePrefixedArrayTableBuffer(builder: flatbuffers.Builder, offset: flatbuffers.Offset): void; + unpack(): ArrayTableT; + unpackTo(_o: ArrayTableT): void; +} +export declare class ArrayTableT implements flatbuffers.IGeneratedObject { + a: string | Uint8Array | null; + cUnderscore: ArrayStructT | null; + constructor(a?: string | Uint8Array | null, cUnderscore?: ArrayStructT | null); + pack(builder: flatbuffers.Builder): flatbuffers.Offset; +} diff --git a/tests/ts/arrays_test_complex/my-game/example/inner-struct.d.ts b/tests/ts/arrays_test_complex/my-game/example/inner-struct.d.ts new file mode 100644 index 00000000000..a54d02bcb10 --- /dev/null +++ b/tests/ts/arrays_test_complex/my-game/example/inner-struct.d.ts @@ -0,0 +1,23 @@ +import * as flatbuffers from 'flatbuffers'; +export declare class InnerStruct implements flatbuffers.IUnpackableObject { + bb: flatbuffers.ByteBuffer | null; + bb_pos: number; + __init(i: number, bb: flatbuffers.ByteBuffer): InnerStruct; + a(): number; + b(index: number): number | null; + c(): number; + dUnderscore(): bigint; + static getFullyQualifiedName(): string; + static sizeOf(): number; + static createInnerStruct(builder: flatbuffers.Builder, a: number, b: number[] | null, c: number, d_underscore: bigint): flatbuffers.Offset; + unpack(): InnerStructT; + unpackTo(_o: InnerStructT): void; +} +export declare class InnerStructT implements flatbuffers.IGeneratedObject { + a: number; + b: (number)[]; + c: number; + dUnderscore: bigint; + constructor(a?: number, b?: (number)[], c?: number, dUnderscore?: bigint); + pack(builder: flatbuffers.Builder): flatbuffers.Offset; +} diff --git a/tests/ts/arrays_test_complex/my-game/example/nested-struct.d.ts b/tests/ts/arrays_test_complex/my-game/example/nested-struct.d.ts new file mode 100644 index 00000000000..98fe48d0ab1 --- /dev/null +++ b/tests/ts/arrays_test_complex/my-game/example/nested-struct.d.ts @@ -0,0 +1,27 @@ +import * as flatbuffers from 'flatbuffers'; +import { OuterStruct, OuterStructT } from '../../my-game/example/outer-struct.js'; +import { TestEnum } from '../../my-game/example/test-enum.js'; +export declare class NestedStruct implements flatbuffers.IUnpackableObject { + bb: flatbuffers.ByteBuffer | null; + bb_pos: number; + __init(i: number, bb: flatbuffers.ByteBuffer): NestedStruct; + a(index: number): number | null; + b(): TestEnum; + cUnderscore(index: number): TestEnum | null; + dOuter(index: number, obj?: OuterStruct): OuterStruct | null; + e(index: number): bigint | null; + static getFullyQualifiedName(): string; + static sizeOf(): number; + static createNestedStruct(builder: flatbuffers.Builder, a: number[] | null, b: TestEnum, c_underscore: number[] | null, d_outer: (any | OuterStructT)[] | null, e: bigint[] | null): flatbuffers.Offset; + unpack(): NestedStructT; + unpackTo(_o: NestedStructT): void; +} +export declare class NestedStructT implements flatbuffers.IGeneratedObject { + a: (number)[]; + b: TestEnum; + cUnderscore: (TestEnum)[]; + dOuter: (OuterStructT)[]; + e: (bigint)[]; + constructor(a?: (number)[], b?: TestEnum, cUnderscore?: (TestEnum)[], dOuter?: (OuterStructT)[], e?: (bigint)[]); + pack(builder: flatbuffers.Builder): flatbuffers.Offset; +} diff --git a/tests/ts/arrays_test_complex/my-game/example/outer-struct.d.ts b/tests/ts/arrays_test_complex/my-game/example/outer-struct.d.ts new file mode 100644 index 00000000000..9c62cea782f --- /dev/null +++ b/tests/ts/arrays_test_complex/my-game/example/outer-struct.d.ts @@ -0,0 +1,28 @@ +import * as flatbuffers from 'flatbuffers'; +import { InnerStruct, InnerStructT } from '../../my-game/example/inner-struct.js'; +export declare class OuterStruct implements flatbuffers.IUnpackableObject { + bb: flatbuffers.ByteBuffer | null; + bb_pos: number; + __init(i: number, bb: flatbuffers.ByteBuffer): OuterStruct; + a(): boolean; + b(): number; + cUnderscore(obj?: InnerStruct): InnerStruct | null; + d(index: number, obj?: InnerStruct): InnerStruct | null; + e(obj?: InnerStruct): InnerStruct | null; + f(index: number): number | null; + static getFullyQualifiedName(): string; + static sizeOf(): number; + static createOuterStruct(builder: flatbuffers.Builder, a: boolean, b: number, c_underscore_a: number, c_underscore_b: number[] | null, c_underscore_c: number, c_underscore_d_underscore: bigint, d: (any | InnerStructT)[] | null, e_a: number, e_b: number[] | null, e_c: number, e_d_underscore: bigint, f: number[] | null): flatbuffers.Offset; + unpack(): OuterStructT; + unpackTo(_o: OuterStructT): void; +} +export declare class OuterStructT implements flatbuffers.IGeneratedObject { + a: boolean; + b: number; + cUnderscore: InnerStructT | null; + d: (InnerStructT)[]; + e: InnerStructT | null; + f: (number)[]; + constructor(a?: boolean, b?: number, cUnderscore?: InnerStructT | null, d?: (InnerStructT)[], e?: InnerStructT | null, f?: (number)[]); + pack(builder: flatbuffers.Builder): flatbuffers.Offset; +} diff --git a/tests/ts/arrays_test_complex/my-game/example/test-enum.d.ts b/tests/ts/arrays_test_complex/my-game/example/test-enum.d.ts new file mode 100644 index 00000000000..291e04971fe --- /dev/null +++ b/tests/ts/arrays_test_complex/my-game/example/test-enum.d.ts @@ -0,0 +1,5 @@ +export declare enum TestEnum { + A = 0, + B = 1, + C = 2 +} diff --git a/tests/ts/foobar/abc.d.ts b/tests/ts/foobar/abc.d.ts new file mode 100644 index 00000000000..874a35db0e9 --- /dev/null +++ b/tests/ts/foobar/abc.d.ts @@ -0,0 +1,3 @@ +export declare enum Abc { + a = 0 +} diff --git a/tests/ts/foobar/class.d.ts b/tests/ts/foobar/class.d.ts new file mode 100644 index 00000000000..2815be18c25 --- /dev/null +++ b/tests/ts/foobar/class.d.ts @@ -0,0 +1,3 @@ +export declare enum class_ { + arguments_ = 0 +} diff --git a/tests/ts/monster_test.d.ts b/tests/ts/monster_test.d.ts new file mode 100644 index 00000000000..b8d81d45fca --- /dev/null +++ b/tests/ts/monster_test.d.ts @@ -0,0 +1,2 @@ +export { TableA } from './table-a.js'; +export * as MyGame from './my-game.js'; diff --git a/tests/ts/monster_test_generated.cjs b/tests/ts/monster_test_generated.cjs index b5d649b6db9..6c590b4f71f 100644 --- a/tests/ts/monster_test_generated.cjs +++ b/tests/ts/monster_test_generated.cjs @@ -190,7 +190,7 @@ var InParentNamespace = class { return (obj || new InParentNamespace()).__init(bb.readInt32(bb.position()) + bb.position(), bb); } static getFullyQualifiedName() { - return "MyGame.InParentNamespace"; + return "MyGame_InParentNamespace"; } static startInParentNamespace(builder) { builder.startObject(0); @@ -270,7 +270,7 @@ var Ability = class { return true; } static getFullyQualifiedName() { - return "MyGame.Example.Ability"; + return "MyGame_Example_Ability"; } static sizeOf() { return 8; @@ -319,7 +319,7 @@ var Monster = class { return (obj || new Monster()).__init(bb.readInt32(bb.position()) + bb.position(), bb); } static getFullyQualifiedName() { - return "MyGame.Example2.Monster"; + return "MyGame_Example2_Monster"; } static startMonster(builder) { builder.startObject(0); @@ -420,7 +420,7 @@ var TestSimpleTableWithEnum = class { return true; } static getFullyQualifiedName() { - return "MyGame.Example.TestSimpleTableWithEnum"; + return "MyGame_Example_TestSimpleTableWithEnum"; } static startTestSimpleTableWithEnum(builder) { builder.startObject(1); @@ -523,7 +523,7 @@ var Referrable = class { return true; } static getFullyQualifiedName() { - return "MyGame.Example.Referrable"; + return "MyGame_Example_Referrable"; } static startReferrable(builder) { builder.startObject(1); @@ -610,7 +610,7 @@ var Stat = class { return true; } static getFullyQualifiedName() { - return "MyGame.Example.Stat"; + return "MyGame_Example_Stat"; } static startStat(builder) { builder.startObject(3); @@ -688,7 +688,7 @@ var Test = class { return true; } static getFullyQualifiedName() { - return "MyGame.Example.Test"; + return "MyGame_Example_Test"; } static sizeOf() { return 4; @@ -768,7 +768,7 @@ var Vec3 = class { return (obj || new Test()).__init(this.bb_pos + 26, this.bb); } static getFullyQualifiedName() { - return "MyGame.Example.Vec3"; + return "MyGame_Example_Vec3"; } static sizeOf() { return 32; @@ -1421,7 +1421,7 @@ var Monster2 = class { return true; } static getFullyQualifiedName() { - return "MyGame.Example.Monster"; + return "MyGame_Example_Monster"; } static startMonster(builder) { builder.startObject(62); @@ -2118,7 +2118,7 @@ var StructOfStructs = class { return (obj || new Ability()).__init(this.bb_pos + 12, this.bb); } static getFullyQualifiedName() { - return "MyGame.Example.StructOfStructs"; + return "MyGame_Example_StructOfStructs"; } static sizeOf() { return 20; @@ -2172,7 +2172,7 @@ var StructOfStructsOfStructs = class { return (obj || new StructOfStructs()).__init(this.bb_pos, this.bb); } static getFullyQualifiedName() { - return "MyGame.Example.StructOfStructsOfStructs"; + return "MyGame_Example_StructOfStructsOfStructs"; } static sizeOf() { return 20; @@ -2372,7 +2372,7 @@ var TypeAliases = class { 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"; + return "MyGame_Example_TypeAliases"; } static startTypeAliases(builder) { builder.startObject(12); diff --git a/tests/ts/my-game.d.ts b/tests/ts/my-game.d.ts new file mode 100644 index 00000000000..b7f6e9d3f0d --- /dev/null +++ b/tests/ts/my-game.d.ts @@ -0,0 +1,4 @@ +export { InParentNamespace } from './my-game/in-parent-namespace.js'; +export * as Example from './my-game/example.js'; +export * as Example2 from './my-game/example2.js'; +export * as OtherNameSpace from './my-game/other-name-space.js'; diff --git a/tests/ts/my-game/example.d.ts b/tests/ts/my-game/example.d.ts new file mode 100644 index 00000000000..076bdf58c43 --- /dev/null +++ b/tests/ts/my-game/example.d.ts @@ -0,0 +1,16 @@ +export { Ability } from './example/ability.js'; +export { Any } from './example/any.js'; +export { AnyAmbiguousAliases } from './example/any-ambiguous-aliases.js'; +export { AnyUniqueAliases } from './example/any-unique-aliases.js'; +export { Color } from './example/color.js'; +export { LongEnum } from './example/long-enum.js'; +export { Monster } from './example/monster.js'; +export { Race } from './example/race.js'; +export { Referrable } from './example/referrable.js'; +export { Stat } from './example/stat.js'; +export { StructOfStructs } from './example/struct-of-structs.js'; +export { StructOfStructsOfStructs } from './example/struct-of-structs-of-structs.js'; +export { Test } from './example/test.js'; +export { TestSimpleTableWithEnum } from './example/test-simple-table-with-enum.js'; +export { TypeAliases } from './example/type-aliases.js'; +export { Vec3 } from './example/vec3.js'; diff --git a/tests/ts/my-game/example/ability.d.ts b/tests/ts/my-game/example/ability.d.ts new file mode 100644 index 00000000000..bbd00f0a1f5 --- /dev/null +++ b/tests/ts/my-game/example/ability.d.ts @@ -0,0 +1,21 @@ +import * as flatbuffers from 'flatbuffers'; +export declare class Ability implements flatbuffers.IUnpackableObject { + bb: flatbuffers.ByteBuffer | null; + bb_pos: number; + __init(i: number, bb: flatbuffers.ByteBuffer): Ability; + id(): number; + mutate_id(value: number): boolean; + distance(): number; + mutate_distance(value: number): boolean; + static getFullyQualifiedName(): string; + static sizeOf(): number; + static createAbility(builder: flatbuffers.Builder, id: number, distance: number): flatbuffers.Offset; + unpack(): AbilityT; + unpackTo(_o: AbilityT): void; +} +export declare class AbilityT implements flatbuffers.IGeneratedObject { + id: number; + distance: number; + constructor(id?: number, distance?: number); + pack(builder: flatbuffers.Builder): flatbuffers.Offset; +} diff --git a/tests/ts/my-game/example/any-ambiguous-aliases.d.ts b/tests/ts/my-game/example/any-ambiguous-aliases.d.ts new file mode 100644 index 00000000000..d625b0abb2f --- /dev/null +++ b/tests/ts/my-game/example/any-ambiguous-aliases.d.ts @@ -0,0 +1,9 @@ +import { Monster } from '../../my-game/example/monster.js'; +export declare enum AnyAmbiguousAliases { + NONE = 0, + M1 = 1, + M2 = 2, + M3 = 3 +} +export declare function unionToAnyAmbiguousAliases(type: AnyAmbiguousAliases, accessor: (obj: Monster) => Monster | null): Monster | null; +export declare function unionListToAnyAmbiguousAliases(type: AnyAmbiguousAliases, accessor: (index: number, obj: Monster) => Monster | null, index: number): Monster | null; diff --git a/tests/ts/my-game/example/any-unique-aliases.d.ts b/tests/ts/my-game/example/any-unique-aliases.d.ts new file mode 100644 index 00000000000..14463bc5e11 --- /dev/null +++ b/tests/ts/my-game/example/any-unique-aliases.d.ts @@ -0,0 +1,11 @@ +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 declare enum AnyUniqueAliases { + NONE = 0, + M = 1, + TS = 2, + M2 = 3 +} +export declare function unionToAnyUniqueAliases(type: AnyUniqueAliases, accessor: (obj: Monster | MyGame_Example2_Monster | TestSimpleTableWithEnum) => Monster | MyGame_Example2_Monster | TestSimpleTableWithEnum | null): Monster | MyGame_Example2_Monster | TestSimpleTableWithEnum | null; +export declare 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; diff --git a/tests/ts/my-game/example/any.d.ts b/tests/ts/my-game/example/any.d.ts new file mode 100644 index 00000000000..6d3e84c9cba --- /dev/null +++ b/tests/ts/my-game/example/any.d.ts @@ -0,0 +1,11 @@ +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 declare enum Any { + NONE = 0, + Monster = 1, + TestSimpleTableWithEnum = 2, + MyGame_Example2_Monster = 3 +} +export declare function unionToAny(type: Any, accessor: (obj: Monster | MyGame_Example2_Monster | TestSimpleTableWithEnum) => Monster | MyGame_Example2_Monster | TestSimpleTableWithEnum | null): Monster | MyGame_Example2_Monster | TestSimpleTableWithEnum | null; +export declare 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; diff --git a/tests/ts/my-game/example/color.d.ts b/tests/ts/my-game/example/color.d.ts new file mode 100644 index 00000000000..79906f4b1e7 --- /dev/null +++ b/tests/ts/my-game/example/color.d.ts @@ -0,0 +1,15 @@ +/** + * Composite components of Monster color. + */ +export declare 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.d.ts b/tests/ts/my-game/example/long-enum.d.ts new file mode 100644 index 00000000000..72e656f14ae --- /dev/null +++ b/tests/ts/my-game/example/long-enum.d.ts @@ -0,0 +1,5 @@ +export declare enum LongEnum { + LongOne = "2", + LongTwo = "4", + LongBig = "1099511627776" +} diff --git a/tests/ts/my-game/example/monster.d.ts b/tests/ts/my-game/example/monster.d.ts new file mode 100644 index 00000000000..86488391cbb --- /dev/null +++ b/tests/ts/my-game/example/monster.d.ts @@ -0,0 +1,325 @@ +import * as flatbuffers from 'flatbuffers'; +import { MonsterT as MyGame_Example2_MonsterT } from '../../my-game/example2/monster.js'; +import { Ability, AbilityT } from '../../my-game/example/ability.js'; +import { Any } from '../../my-game/example/any.js'; +import { AnyAmbiguousAliases } from '../../my-game/example/any-ambiguous-aliases.js'; +import { AnyUniqueAliases } 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 { 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 declare class Monster implements flatbuffers.IUnpackableObject { + bb: flatbuffers.ByteBuffer | null; + bb_pos: number; + __init(i: number, bb: flatbuffers.ByteBuffer): Monster; + static getRootAsMonster(bb: flatbuffers.ByteBuffer, obj?: Monster): Monster; + static getSizePrefixedRootAsMonster(bb: flatbuffers.ByteBuffer, obj?: Monster): Monster; + static bufferHasIdentifier(bb: flatbuffers.ByteBuffer): boolean; + pos(obj?: Vec3): Vec3 | null; + mana(): number; + mutate_mana(value: number): boolean; + hp(): number; + mutate_hp(value: number): boolean; + name(): string | null; + name(optionalEncoding: flatbuffers.Encoding): string | Uint8Array | null; + inventory(index: number): number | null; + inventoryLength(): number; + inventoryArray(): Uint8Array | null; + color(): Color; + mutate_color(value: Color): boolean; + testType(): Any; + test(obj: any): any | null; + test4(index: number, obj?: Test): Test | null; + test4Length(): number; + testarrayofstring(index: number): string; + testarrayofstring(index: number, optionalEncoding: flatbuffers.Encoding): string | Uint8Array; + testarrayofstringLength(): number; + /** + * an example documentation comment: this will end up in the generated code + * multiline too + */ + testarrayoftables(index: number, obj?: Monster): Monster | null; + testarrayoftablesLength(): number; + enemy(obj?: Monster): Monster | null; + testnestedflatbuffer(index: number): number | null; + testnestedflatbufferLength(): number; + testnestedflatbufferArray(): Uint8Array | null; + testempty(obj?: Stat): Stat | null; + testbool(): boolean; + mutate_testbool(value: boolean): boolean; + testhashs32Fnv1(): number; + mutate_testhashs32_fnv1(value: number): boolean; + testhashu32Fnv1(): number; + mutate_testhashu32_fnv1(value: number): boolean; + testhashs64Fnv1(): bigint; + mutate_testhashs64_fnv1(value: bigint): boolean; + testhashu64Fnv1(): bigint; + mutate_testhashu64_fnv1(value: bigint): boolean; + testhashs32Fnv1a(): number; + mutate_testhashs32_fnv1a(value: number): boolean; + testhashu32Fnv1a(): number; + mutate_testhashu32_fnv1a(value: number): boolean; + testhashs64Fnv1a(): bigint; + mutate_testhashs64_fnv1a(value: bigint): boolean; + testhashu64Fnv1a(): bigint; + mutate_testhashu64_fnv1a(value: bigint): boolean; + testarrayofbools(index: number): boolean | null; + testarrayofboolsLength(): number; + testarrayofboolsArray(): Int8Array | null; + testf(): number; + mutate_testf(value: number): boolean; + testf2(): number; + mutate_testf2(value: number): boolean; + testf3(): number; + mutate_testf3(value: number): boolean; + testarrayofstring2(index: number): string; + testarrayofstring2(index: number, optionalEncoding: flatbuffers.Encoding): string | Uint8Array; + testarrayofstring2Length(): number; + testarrayofsortedstruct(index: number, obj?: Ability): Ability | null; + testarrayofsortedstructLength(): number; + flex(index: number): number | null; + flexLength(): number; + flexArray(): Uint8Array | null; + test5(index: number, obj?: Test): Test | null; + test5Length(): number; + vectorOfLongs(index: number): bigint | null; + vectorOfLongsLength(): number; + vectorOfDoubles(index: number): number | null; + vectorOfDoublesLength(): number; + vectorOfDoublesArray(): Float64Array | null; + parentNamespaceTest(obj?: InParentNamespace): InParentNamespace | null; + vectorOfReferrables(index: number, obj?: Referrable): Referrable | null; + vectorOfReferrablesLength(): number; + singleWeakReference(): bigint; + mutate_single_weak_reference(value: bigint): boolean; + vectorOfWeakReferences(index: number): bigint | null; + vectorOfWeakReferencesLength(): number; + vectorOfStrongReferrables(index: number, obj?: Referrable): Referrable | null; + vectorOfStrongReferrablesLength(): number; + coOwningReference(): bigint; + mutate_co_owning_reference(value: bigint): boolean; + vectorOfCoOwningReferences(index: number): bigint | null; + vectorOfCoOwningReferencesLength(): number; + nonOwningReference(): bigint; + mutate_non_owning_reference(value: bigint): boolean; + vectorOfNonOwningReferences(index: number): bigint | null; + vectorOfNonOwningReferencesLength(): number; + anyUniqueType(): AnyUniqueAliases; + anyUnique(obj: any): any | null; + anyAmbiguousType(): AnyAmbiguousAliases; + anyAmbiguous(obj: any): any | null; + vectorOfEnums(index: number): Color | null; + vectorOfEnumsLength(): number; + vectorOfEnumsArray(): Uint8Array | null; + signedEnum(): Race; + mutate_signed_enum(value: Race): boolean; + testrequirednestedflatbuffer(index: number): number | null; + testrequirednestedflatbufferLength(): number; + testrequirednestedflatbufferArray(): Uint8Array | null; + scalarKeySortedTables(index: number, obj?: Stat): Stat | null; + scalarKeySortedTablesLength(): number; + nativeInline(obj?: Test): Test | null; + longEnumNonEnumDefault(): bigint; + mutate_long_enum_non_enum_default(value: bigint): boolean; + longEnumNormalDefault(): bigint; + mutate_long_enum_normal_default(value: bigint): boolean; + nanDefault(): number; + mutate_nan_default(value: number): boolean; + infDefault(): number; + mutate_inf_default(value: number): boolean; + positiveInfDefault(): number; + mutate_positive_inf_default(value: number): boolean; + infinityDefault(): number; + mutate_infinity_default(value: number): boolean; + positiveInfinityDefault(): number; + mutate_positive_infinity_default(value: number): boolean; + negativeInfDefault(): number; + mutate_negative_inf_default(value: number): boolean; + negativeInfinityDefault(): number; + mutate_negative_infinity_default(value: number): boolean; + doubleInfDefault(): number; + mutate_double_inf_default(value: number): boolean; + static getFullyQualifiedName(): string; + static startMonster(builder: flatbuffers.Builder): void; + static addPos(builder: flatbuffers.Builder, posOffset: flatbuffers.Offset): void; + static addMana(builder: flatbuffers.Builder, mana: number): void; + static addHp(builder: flatbuffers.Builder, hp: number): void; + static addName(builder: flatbuffers.Builder, nameOffset: flatbuffers.Offset): void; + static addInventory(builder: flatbuffers.Builder, inventoryOffset: flatbuffers.Offset): void; + static createInventoryVector(builder: flatbuffers.Builder, data: number[] | Uint8Array): flatbuffers.Offset; + static startInventoryVector(builder: flatbuffers.Builder, numElems: number): void; + static addColor(builder: flatbuffers.Builder, color: Color): void; + static addTestType(builder: flatbuffers.Builder, testType: Any): void; + static addTest(builder: flatbuffers.Builder, testOffset: flatbuffers.Offset): void; + static addTest4(builder: flatbuffers.Builder, test4Offset: flatbuffers.Offset): void; + static startTest4Vector(builder: flatbuffers.Builder, numElems: number): void; + static addTestarrayofstring(builder: flatbuffers.Builder, testarrayofstringOffset: flatbuffers.Offset): void; + static createTestarrayofstringVector(builder: flatbuffers.Builder, data: flatbuffers.Offset[]): flatbuffers.Offset; + static startTestarrayofstringVector(builder: flatbuffers.Builder, numElems: number): void; + static addTestarrayoftables(builder: flatbuffers.Builder, testarrayoftablesOffset: flatbuffers.Offset): void; + static createTestarrayoftablesVector(builder: flatbuffers.Builder, data: flatbuffers.Offset[]): flatbuffers.Offset; + static startTestarrayoftablesVector(builder: flatbuffers.Builder, numElems: number): void; + static addEnemy(builder: flatbuffers.Builder, enemyOffset: flatbuffers.Offset): void; + static addTestnestedflatbuffer(builder: flatbuffers.Builder, testnestedflatbufferOffset: flatbuffers.Offset): void; + static createTestnestedflatbufferVector(builder: flatbuffers.Builder, data: number[] | Uint8Array): flatbuffers.Offset; + static startTestnestedflatbufferVector(builder: flatbuffers.Builder, numElems: number): void; + static addTestempty(builder: flatbuffers.Builder, testemptyOffset: flatbuffers.Offset): void; + static addTestbool(builder: flatbuffers.Builder, testbool: boolean): void; + static addTesthashs32Fnv1(builder: flatbuffers.Builder, testhashs32Fnv1: number): void; + static addTesthashu32Fnv1(builder: flatbuffers.Builder, testhashu32Fnv1: number): void; + static addTesthashs64Fnv1(builder: flatbuffers.Builder, testhashs64Fnv1: bigint): void; + static addTesthashu64Fnv1(builder: flatbuffers.Builder, testhashu64Fnv1: bigint): void; + static addTesthashs32Fnv1a(builder: flatbuffers.Builder, testhashs32Fnv1a: number): void; + static addTesthashu32Fnv1a(builder: flatbuffers.Builder, testhashu32Fnv1a: number): void; + static addTesthashs64Fnv1a(builder: flatbuffers.Builder, testhashs64Fnv1a: bigint): void; + static addTesthashu64Fnv1a(builder: flatbuffers.Builder, testhashu64Fnv1a: bigint): void; + static addTestarrayofbools(builder: flatbuffers.Builder, testarrayofboolsOffset: flatbuffers.Offset): void; + static createTestarrayofboolsVector(builder: flatbuffers.Builder, data: boolean[]): flatbuffers.Offset; + static startTestarrayofboolsVector(builder: flatbuffers.Builder, numElems: number): void; + static addTestf(builder: flatbuffers.Builder, testf: number): void; + static addTestf2(builder: flatbuffers.Builder, testf2: number): void; + static addTestf3(builder: flatbuffers.Builder, testf3: number): void; + static addTestarrayofstring2(builder: flatbuffers.Builder, testarrayofstring2Offset: flatbuffers.Offset): void; + static createTestarrayofstring2Vector(builder: flatbuffers.Builder, data: flatbuffers.Offset[]): flatbuffers.Offset; + static startTestarrayofstring2Vector(builder: flatbuffers.Builder, numElems: number): void; + static addTestarrayofsortedstruct(builder: flatbuffers.Builder, testarrayofsortedstructOffset: flatbuffers.Offset): void; + static startTestarrayofsortedstructVector(builder: flatbuffers.Builder, numElems: number): void; + static addFlex(builder: flatbuffers.Builder, flexOffset: flatbuffers.Offset): void; + static createFlexVector(builder: flatbuffers.Builder, data: number[] | Uint8Array): flatbuffers.Offset; + static startFlexVector(builder: flatbuffers.Builder, numElems: number): void; + static addTest5(builder: flatbuffers.Builder, test5Offset: flatbuffers.Offset): void; + static startTest5Vector(builder: flatbuffers.Builder, numElems: number): void; + static addVectorOfLongs(builder: flatbuffers.Builder, vectorOfLongsOffset: flatbuffers.Offset): void; + static createVectorOfLongsVector(builder: flatbuffers.Builder, data: bigint[]): flatbuffers.Offset; + static startVectorOfLongsVector(builder: flatbuffers.Builder, numElems: number): void; + static addVectorOfDoubles(builder: flatbuffers.Builder, vectorOfDoublesOffset: flatbuffers.Offset): void; + 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 startVectorOfDoublesVector(builder: flatbuffers.Builder, numElems: number): void; + static addParentNamespaceTest(builder: flatbuffers.Builder, parentNamespaceTestOffset: flatbuffers.Offset): void; + static addVectorOfReferrables(builder: flatbuffers.Builder, vectorOfReferrablesOffset: flatbuffers.Offset): void; + static createVectorOfReferrablesVector(builder: flatbuffers.Builder, data: flatbuffers.Offset[]): flatbuffers.Offset; + static startVectorOfReferrablesVector(builder: flatbuffers.Builder, numElems: number): void; + static addSingleWeakReference(builder: flatbuffers.Builder, singleWeakReference: bigint): void; + static addVectorOfWeakReferences(builder: flatbuffers.Builder, vectorOfWeakReferencesOffset: flatbuffers.Offset): void; + static createVectorOfWeakReferencesVector(builder: flatbuffers.Builder, data: bigint[]): flatbuffers.Offset; + static startVectorOfWeakReferencesVector(builder: flatbuffers.Builder, numElems: number): void; + static addVectorOfStrongReferrables(builder: flatbuffers.Builder, vectorOfStrongReferrablesOffset: flatbuffers.Offset): void; + static createVectorOfStrongReferrablesVector(builder: flatbuffers.Builder, data: flatbuffers.Offset[]): flatbuffers.Offset; + static startVectorOfStrongReferrablesVector(builder: flatbuffers.Builder, numElems: number): void; + static addCoOwningReference(builder: flatbuffers.Builder, coOwningReference: bigint): void; + static addVectorOfCoOwningReferences(builder: flatbuffers.Builder, vectorOfCoOwningReferencesOffset: flatbuffers.Offset): void; + static createVectorOfCoOwningReferencesVector(builder: flatbuffers.Builder, data: bigint[]): flatbuffers.Offset; + static startVectorOfCoOwningReferencesVector(builder: flatbuffers.Builder, numElems: number): void; + static addNonOwningReference(builder: flatbuffers.Builder, nonOwningReference: bigint): void; + static addVectorOfNonOwningReferences(builder: flatbuffers.Builder, vectorOfNonOwningReferencesOffset: flatbuffers.Offset): void; + static createVectorOfNonOwningReferencesVector(builder: flatbuffers.Builder, data: bigint[]): flatbuffers.Offset; + static startVectorOfNonOwningReferencesVector(builder: flatbuffers.Builder, numElems: number): void; + static addAnyUniqueType(builder: flatbuffers.Builder, anyUniqueType: AnyUniqueAliases): void; + static addAnyUnique(builder: flatbuffers.Builder, anyUniqueOffset: flatbuffers.Offset): void; + static addAnyAmbiguousType(builder: flatbuffers.Builder, anyAmbiguousType: AnyAmbiguousAliases): void; + static addAnyAmbiguous(builder: flatbuffers.Builder, anyAmbiguousOffset: flatbuffers.Offset): void; + static addVectorOfEnums(builder: flatbuffers.Builder, vectorOfEnumsOffset: flatbuffers.Offset): void; + static createVectorOfEnumsVector(builder: flatbuffers.Builder, data: Color[]): flatbuffers.Offset; + static startVectorOfEnumsVector(builder: flatbuffers.Builder, numElems: number): void; + static addSignedEnum(builder: flatbuffers.Builder, signedEnum: Race): void; + static addTestrequirednestedflatbuffer(builder: flatbuffers.Builder, testrequirednestedflatbufferOffset: flatbuffers.Offset): void; + static createTestrequirednestedflatbufferVector(builder: flatbuffers.Builder, data: number[] | Uint8Array): flatbuffers.Offset; + static startTestrequirednestedflatbufferVector(builder: flatbuffers.Builder, numElems: number): void; + static addScalarKeySortedTables(builder: flatbuffers.Builder, scalarKeySortedTablesOffset: flatbuffers.Offset): void; + static createScalarKeySortedTablesVector(builder: flatbuffers.Builder, data: flatbuffers.Offset[]): flatbuffers.Offset; + static startScalarKeySortedTablesVector(builder: flatbuffers.Builder, numElems: number): void; + static addNativeInline(builder: flatbuffers.Builder, nativeInlineOffset: flatbuffers.Offset): void; + static addLongEnumNonEnumDefault(builder: flatbuffers.Builder, longEnumNonEnumDefault: bigint): void; + static addLongEnumNormalDefault(builder: flatbuffers.Builder, longEnumNormalDefault: bigint): void; + static addNanDefault(builder: flatbuffers.Builder, nanDefault: number): void; + static addInfDefault(builder: flatbuffers.Builder, infDefault: number): void; + static addPositiveInfDefault(builder: flatbuffers.Builder, positiveInfDefault: number): void; + static addInfinityDefault(builder: flatbuffers.Builder, infinityDefault: number): void; + static addPositiveInfinityDefault(builder: flatbuffers.Builder, positiveInfinityDefault: number): void; + static addNegativeInfDefault(builder: flatbuffers.Builder, negativeInfDefault: number): void; + static addNegativeInfinityDefault(builder: flatbuffers.Builder, negativeInfinityDefault: number): void; + static addDoubleInfDefault(builder: flatbuffers.Builder, doubleInfDefault: number): void; + static endMonster(builder: flatbuffers.Builder): flatbuffers.Offset; + static finishMonsterBuffer(builder: flatbuffers.Builder, offset: flatbuffers.Offset): void; + static finishSizePrefixedMonsterBuffer(builder: flatbuffers.Builder, offset: flatbuffers.Offset): void; + serialize(): Uint8Array; + static deserialize(buffer: Uint8Array): Monster; + unpack(): MonsterT; + unpackTo(_o: MonsterT): void; +} +export declare class MonsterT implements flatbuffers.IGeneratedObject { + pos: Vec3T | null; + mana: number; + hp: number; + name: string | Uint8Array | null; + inventory: (number)[]; + color: Color; + testType: Any; + test: MonsterT | MyGame_Example2_MonsterT | TestSimpleTableWithEnumT | null; + test4: (TestT)[]; + testarrayofstring: (string)[]; + testarrayoftables: (MonsterT)[]; + enemy: MonsterT | null; + testnestedflatbuffer: (number)[]; + testempty: StatT | null; + testbool: boolean; + testhashs32Fnv1: number; + testhashu32Fnv1: number; + testhashs64Fnv1: bigint; + testhashu64Fnv1: bigint; + testhashs32Fnv1a: number; + testhashu32Fnv1a: number; + testhashs64Fnv1a: bigint; + testhashu64Fnv1a: bigint; + testarrayofbools: (boolean)[]; + testf: number; + testf2: number; + testf3: number; + testarrayofstring2: (string)[]; + testarrayofsortedstruct: (AbilityT)[]; + flex: (number)[]; + test5: (TestT)[]; + vectorOfLongs: (bigint)[]; + vectorOfDoubles: (number)[]; + parentNamespaceTest: InParentNamespaceT | null; + vectorOfReferrables: (ReferrableT)[]; + singleWeakReference: bigint; + vectorOfWeakReferences: (bigint)[]; + vectorOfStrongReferrables: (ReferrableT)[]; + coOwningReference: bigint; + vectorOfCoOwningReferences: (bigint)[]; + nonOwningReference: bigint; + vectorOfNonOwningReferences: (bigint)[]; + anyUniqueType: AnyUniqueAliases; + anyUnique: MonsterT | MyGame_Example2_MonsterT | TestSimpleTableWithEnumT | null; + anyAmbiguousType: AnyAmbiguousAliases; + anyAmbiguous: MonsterT | null; + vectorOfEnums: (Color)[]; + signedEnum: Race; + testrequirednestedflatbuffer: (number)[]; + scalarKeySortedTables: (StatT)[]; + nativeInline: TestT | null; + longEnumNonEnumDefault: bigint; + longEnumNormalDefault: bigint; + nanDefault: number; + infDefault: number; + positiveInfDefault: number; + infinityDefault: number; + positiveInfinityDefault: number; + negativeInfDefault: number; + negativeInfinityDefault: number; + doubleInfDefault: number; + constructor(pos?: Vec3T | null, mana?: number, hp?: number, name?: string | Uint8Array | null, inventory?: (number)[], color?: Color, testType?: Any, test?: MonsterT | MyGame_Example2_MonsterT | TestSimpleTableWithEnumT | null, test4?: (TestT)[], testarrayofstring?: (string)[], testarrayoftables?: (MonsterT)[], enemy?: MonsterT | null, testnestedflatbuffer?: (number)[], testempty?: StatT | null, testbool?: boolean, testhashs32Fnv1?: number, testhashu32Fnv1?: number, testhashs64Fnv1?: bigint, testhashu64Fnv1?: bigint, testhashs32Fnv1a?: number, testhashu32Fnv1a?: number, testhashs64Fnv1a?: bigint, testhashu64Fnv1a?: bigint, testarrayofbools?: (boolean)[], testf?: number, testf2?: number, testf3?: number, testarrayofstring2?: (string)[], testarrayofsortedstruct?: (AbilityT)[], flex?: (number)[], test5?: (TestT)[], vectorOfLongs?: (bigint)[], vectorOfDoubles?: (number)[], parentNamespaceTest?: InParentNamespaceT | null, vectorOfReferrables?: (ReferrableT)[], singleWeakReference?: bigint, vectorOfWeakReferences?: (bigint)[], vectorOfStrongReferrables?: (ReferrableT)[], coOwningReference?: bigint, vectorOfCoOwningReferences?: (bigint)[], nonOwningReference?: bigint, vectorOfNonOwningReferences?: (bigint)[], anyUniqueType?: AnyUniqueAliases, anyUnique?: MonsterT | MyGame_Example2_MonsterT | TestSimpleTableWithEnumT | null, anyAmbiguousType?: AnyAmbiguousAliases, anyAmbiguous?: MonsterT | null, vectorOfEnums?: (Color)[], signedEnum?: Race, testrequirednestedflatbuffer?: (number)[], scalarKeySortedTables?: (StatT)[], nativeInline?: TestT | null, longEnumNonEnumDefault?: bigint, longEnumNormalDefault?: bigint, nanDefault?: number, infDefault?: number, positiveInfDefault?: number, infinityDefault?: number, positiveInfinityDefault?: number, negativeInfDefault?: number, negativeInfinityDefault?: number, doubleInfDefault?: number); + pack(builder: flatbuffers.Builder): flatbuffers.Offset; +} diff --git a/tests/ts/my-game/example/race.d.ts b/tests/ts/my-game/example/race.d.ts new file mode 100644 index 00000000000..393807db471 --- /dev/null +++ b/tests/ts/my-game/example/race.d.ts @@ -0,0 +1,6 @@ +export declare enum Race { + None = -1, + Human = 0, + Dwarf = 1, + Elf = 2 +} diff --git a/tests/ts/my-game/example/referrable.d.ts b/tests/ts/my-game/example/referrable.d.ts new file mode 100644 index 00000000000..e1967fd8830 --- /dev/null +++ b/tests/ts/my-game/example/referrable.d.ts @@ -0,0 +1,24 @@ +import * as flatbuffers from 'flatbuffers'; +export declare class Referrable implements flatbuffers.IUnpackableObject { + bb: flatbuffers.ByteBuffer | null; + bb_pos: number; + __init(i: number, bb: flatbuffers.ByteBuffer): Referrable; + static getRootAsReferrable(bb: flatbuffers.ByteBuffer, obj?: Referrable): Referrable; + static getSizePrefixedRootAsReferrable(bb: flatbuffers.ByteBuffer, obj?: Referrable): Referrable; + id(): bigint; + mutate_id(value: bigint): boolean; + static getFullyQualifiedName(): string; + static startReferrable(builder: flatbuffers.Builder): void; + static addId(builder: flatbuffers.Builder, id: bigint): void; + static endReferrable(builder: flatbuffers.Builder): flatbuffers.Offset; + static createReferrable(builder: flatbuffers.Builder, id: bigint): flatbuffers.Offset; + serialize(): Uint8Array; + static deserialize(buffer: Uint8Array): Referrable; + unpack(): ReferrableT; + unpackTo(_o: ReferrableT): void; +} +export declare class ReferrableT implements flatbuffers.IGeneratedObject { + id: bigint; + constructor(id?: bigint); + pack(builder: flatbuffers.Builder): flatbuffers.Offset; +} diff --git a/tests/ts/my-game/example/stat.d.ts b/tests/ts/my-game/example/stat.d.ts new file mode 100644 index 00000000000..9ccb1aa48e0 --- /dev/null +++ b/tests/ts/my-game/example/stat.d.ts @@ -0,0 +1,32 @@ +import * as flatbuffers from 'flatbuffers'; +export declare class Stat implements flatbuffers.IUnpackableObject { + bb: flatbuffers.ByteBuffer | null; + bb_pos: number; + __init(i: number, bb: flatbuffers.ByteBuffer): Stat; + static getRootAsStat(bb: flatbuffers.ByteBuffer, obj?: Stat): Stat; + static getSizePrefixedRootAsStat(bb: flatbuffers.ByteBuffer, obj?: Stat): Stat; + id(): string | null; + id(optionalEncoding: flatbuffers.Encoding): string | Uint8Array | null; + val(): bigint; + mutate_val(value: bigint): boolean; + count(): number; + mutate_count(value: number): boolean; + static getFullyQualifiedName(): string; + static startStat(builder: flatbuffers.Builder): void; + static addId(builder: flatbuffers.Builder, idOffset: flatbuffers.Offset): void; + static addVal(builder: flatbuffers.Builder, val: bigint): void; + static addCount(builder: flatbuffers.Builder, count: number): void; + static endStat(builder: flatbuffers.Builder): flatbuffers.Offset; + static createStat(builder: flatbuffers.Builder, idOffset: flatbuffers.Offset, val: bigint, count: number): flatbuffers.Offset; + serialize(): Uint8Array; + static deserialize(buffer: Uint8Array): Stat; + unpack(): StatT; + unpackTo(_o: StatT): void; +} +export declare class StatT implements flatbuffers.IGeneratedObject { + id: string | Uint8Array | null; + val: bigint; + count: number; + constructor(id?: string | Uint8Array | null, val?: bigint, count?: number); + pack(builder: flatbuffers.Builder): flatbuffers.Offset; +} diff --git a/tests/ts/my-game/example/struct-of-structs-of-structs.d.ts b/tests/ts/my-game/example/struct-of-structs-of-structs.d.ts new file mode 100644 index 00000000000..bd676b7c7c5 --- /dev/null +++ b/tests/ts/my-game/example/struct-of-structs-of-structs.d.ts @@ -0,0 +1,18 @@ +import * as flatbuffers from 'flatbuffers'; +import { StructOfStructs, StructOfStructsT } from '../../my-game/example/struct-of-structs.js'; +export declare class StructOfStructsOfStructs implements flatbuffers.IUnpackableObject { + bb: flatbuffers.ByteBuffer | null; + bb_pos: number; + __init(i: number, bb: flatbuffers.ByteBuffer): StructOfStructsOfStructs; + a(obj?: StructOfStructs): StructOfStructs | null; + static getFullyQualifiedName(): string; + static sizeOf(): number; + 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; + unpack(): StructOfStructsOfStructsT; + unpackTo(_o: StructOfStructsOfStructsT): void; +} +export declare class StructOfStructsOfStructsT implements flatbuffers.IGeneratedObject { + a: StructOfStructsT | null; + constructor(a?: StructOfStructsT | null); + pack(builder: flatbuffers.Builder): flatbuffers.Offset; +} diff --git a/tests/ts/my-game/example/struct-of-structs.d.ts b/tests/ts/my-game/example/struct-of-structs.d.ts new file mode 100644 index 00000000000..cb299c4d2cc --- /dev/null +++ b/tests/ts/my-game/example/struct-of-structs.d.ts @@ -0,0 +1,23 @@ +import * as flatbuffers from 'flatbuffers'; +import { Ability, AbilityT } from '../../my-game/example/ability.js'; +import { Test, TestT } from '../../my-game/example/test.js'; +export declare class StructOfStructs implements flatbuffers.IUnpackableObject { + bb: flatbuffers.ByteBuffer | null; + bb_pos: number; + __init(i: number, bb: flatbuffers.ByteBuffer): StructOfStructs; + a(obj?: Ability): Ability | null; + b(obj?: Test): Test | null; + c(obj?: Ability): Ability | null; + static getFullyQualifiedName(): string; + static sizeOf(): number; + 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; + unpack(): StructOfStructsT; + unpackTo(_o: StructOfStructsT): void; +} +export declare class StructOfStructsT implements flatbuffers.IGeneratedObject { + a: AbilityT | null; + b: TestT | null; + c: AbilityT | null; + constructor(a?: AbilityT | null, b?: TestT | null, c?: AbilityT | null); + pack(builder: flatbuffers.Builder): flatbuffers.Offset; +} diff --git a/tests/ts/my-game/example/test-simple-table-with-enum.d.ts b/tests/ts/my-game/example/test-simple-table-with-enum.d.ts new file mode 100644 index 00000000000..7a3f6905c3e --- /dev/null +++ b/tests/ts/my-game/example/test-simple-table-with-enum.d.ts @@ -0,0 +1,25 @@ +import * as flatbuffers from 'flatbuffers'; +import { Color } from '../../my-game/example/color.js'; +export declare class TestSimpleTableWithEnum implements flatbuffers.IUnpackableObject { + bb: flatbuffers.ByteBuffer | null; + bb_pos: number; + __init(i: number, bb: flatbuffers.ByteBuffer): TestSimpleTableWithEnum; + static getRootAsTestSimpleTableWithEnum(bb: flatbuffers.ByteBuffer, obj?: TestSimpleTableWithEnum): TestSimpleTableWithEnum; + static getSizePrefixedRootAsTestSimpleTableWithEnum(bb: flatbuffers.ByteBuffer, obj?: TestSimpleTableWithEnum): TestSimpleTableWithEnum; + color(): Color; + mutate_color(value: Color): boolean; + static getFullyQualifiedName(): string; + static startTestSimpleTableWithEnum(builder: flatbuffers.Builder): void; + static addColor(builder: flatbuffers.Builder, color: Color): void; + static endTestSimpleTableWithEnum(builder: flatbuffers.Builder): flatbuffers.Offset; + static createTestSimpleTableWithEnum(builder: flatbuffers.Builder, color: Color): flatbuffers.Offset; + serialize(): Uint8Array; + static deserialize(buffer: Uint8Array): TestSimpleTableWithEnum; + unpack(): TestSimpleTableWithEnumT; + unpackTo(_o: TestSimpleTableWithEnumT): void; +} +export declare class TestSimpleTableWithEnumT implements flatbuffers.IGeneratedObject { + color: Color; + constructor(color?: Color); + pack(builder: flatbuffers.Builder): flatbuffers.Offset; +} diff --git a/tests/ts/my-game/example/test.d.ts b/tests/ts/my-game/example/test.d.ts new file mode 100644 index 00000000000..98764dcf7ba --- /dev/null +++ b/tests/ts/my-game/example/test.d.ts @@ -0,0 +1,21 @@ +import * as flatbuffers from 'flatbuffers'; +export declare class Test implements flatbuffers.IUnpackableObject { + bb: flatbuffers.ByteBuffer | null; + bb_pos: number; + __init(i: number, bb: flatbuffers.ByteBuffer): Test; + a(): number; + mutate_a(value: number): boolean; + b(): number; + mutate_b(value: number): boolean; + static getFullyQualifiedName(): string; + static sizeOf(): number; + static createTest(builder: flatbuffers.Builder, a: number, b: number): flatbuffers.Offset; + unpack(): TestT; + unpackTo(_o: TestT): void; +} +export declare class TestT implements flatbuffers.IGeneratedObject { + a: number; + b: number; + constructor(a?: number, b?: number); + pack(builder: flatbuffers.Builder): flatbuffers.Offset; +} diff --git a/tests/ts/my-game/example/type-aliases.d.ts b/tests/ts/my-game/example/type-aliases.d.ts new file mode 100644 index 00000000000..b552add17df --- /dev/null +++ b/tests/ts/my-game/example/type-aliases.d.ts @@ -0,0 +1,82 @@ +import * as flatbuffers from 'flatbuffers'; +export declare class TypeAliases implements flatbuffers.IUnpackableObject { + bb: flatbuffers.ByteBuffer | null; + bb_pos: number; + __init(i: number, bb: flatbuffers.ByteBuffer): TypeAliases; + static getRootAsTypeAliases(bb: flatbuffers.ByteBuffer, obj?: TypeAliases): TypeAliases; + static getSizePrefixedRootAsTypeAliases(bb: flatbuffers.ByteBuffer, obj?: TypeAliases): TypeAliases; + i8(): number; + mutate_i8(value: number): boolean; + u8(): number; + mutate_u8(value: number): boolean; + i16(): number; + mutate_i16(value: number): boolean; + u16(): number; + mutate_u16(value: number): boolean; + i32(): number; + mutate_i32(value: number): boolean; + u32(): number; + mutate_u32(value: number): boolean; + i64(): bigint; + mutate_i64(value: bigint): boolean; + u64(): bigint; + mutate_u64(value: bigint): boolean; + f32(): number; + mutate_f32(value: number): boolean; + f64(): number; + mutate_f64(value: number): boolean; + v8(index: number): number | null; + v8Length(): number; + v8Array(): Int8Array | null; + vf64(index: number): number | null; + vf64Length(): number; + vf64Array(): Float64Array | null; + static getFullyQualifiedName(): string; + static startTypeAliases(builder: flatbuffers.Builder): void; + static addI8(builder: flatbuffers.Builder, i8: number): void; + static addU8(builder: flatbuffers.Builder, u8: number): void; + static addI16(builder: flatbuffers.Builder, i16: number): void; + static addU16(builder: flatbuffers.Builder, u16: number): void; + static addI32(builder: flatbuffers.Builder, i32: number): void; + static addU32(builder: flatbuffers.Builder, u32: number): void; + static addI64(builder: flatbuffers.Builder, i64: bigint): void; + static addU64(builder: flatbuffers.Builder, u64: bigint): void; + static addF32(builder: flatbuffers.Builder, f32: number): void; + static addF64(builder: flatbuffers.Builder, f64: number): void; + static addV8(builder: flatbuffers.Builder, v8Offset: flatbuffers.Offset): void; + 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 startV8Vector(builder: flatbuffers.Builder, numElems: number): void; + static addVf64(builder: flatbuffers.Builder, vf64Offset: flatbuffers.Offset): void; + 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 startVf64Vector(builder: flatbuffers.Builder, numElems: number): void; + static endTypeAliases(builder: flatbuffers.Builder): flatbuffers.Offset; + static createTypeAliases(builder: flatbuffers.Builder, i8: number, u8: number, i16: number, u16: number, i32: number, u32: number, i64: bigint, u64: bigint, f32: number, f64: number, v8Offset: flatbuffers.Offset, vf64Offset: flatbuffers.Offset): flatbuffers.Offset; + serialize(): Uint8Array; + static deserialize(buffer: Uint8Array): TypeAliases; + unpack(): TypeAliasesT; + unpackTo(_o: TypeAliasesT): void; +} +export declare class TypeAliasesT implements flatbuffers.IGeneratedObject { + i8: number; + u8: number; + i16: number; + u16: number; + i32: number; + u32: number; + i64: bigint; + u64: bigint; + f32: number; + f64: number; + v8: (number)[]; + vf64: (number)[]; + constructor(i8?: number, u8?: number, i16?: number, u16?: number, i32?: number, u32?: number, i64?: bigint, u64?: bigint, f32?: number, f64?: number, v8?: (number)[], vf64?: (number)[]); + pack(builder: flatbuffers.Builder): flatbuffers.Offset; +} diff --git a/tests/ts/my-game/example/vec3.d.ts b/tests/ts/my-game/example/vec3.d.ts new file mode 100644 index 00000000000..c5a6be285c7 --- /dev/null +++ b/tests/ts/my-game/example/vec3.d.ts @@ -0,0 +1,34 @@ +import * as flatbuffers from 'flatbuffers'; +import { Color } from '../../my-game/example/color.js'; +import { Test, TestT } from '../../my-game/example/test.js'; +export declare class Vec3 implements flatbuffers.IUnpackableObject { + bb: flatbuffers.ByteBuffer | null; + bb_pos: number; + __init(i: number, bb: flatbuffers.ByteBuffer): Vec3; + x(): number; + mutate_x(value: number): boolean; + y(): number; + mutate_y(value: number): boolean; + z(): number; + mutate_z(value: number): boolean; + test1(): number; + mutate_test1(value: number): boolean; + test2(): Color; + mutate_test2(value: Color): boolean; + test3(obj?: Test): Test | null; + static getFullyQualifiedName(): string; + static sizeOf(): number; + static createVec3(builder: flatbuffers.Builder, x: number, y: number, z: number, test1: number, test2: Color, test3_a: number, test3_b: number): flatbuffers.Offset; + unpack(): Vec3T; + unpackTo(_o: Vec3T): void; +} +export declare class Vec3T implements flatbuffers.IGeneratedObject { + x: number; + y: number; + z: number; + test1: number; + test2: Color; + test3: TestT | null; + constructor(x?: number, y?: number, z?: number, test1?: number, test2?: Color, test3?: TestT | null); + pack(builder: flatbuffers.Builder): flatbuffers.Offset; +} diff --git a/tests/ts/my-game/example2.d.ts b/tests/ts/my-game/example2.d.ts new file mode 100644 index 00000000000..6d0d750861c --- /dev/null +++ b/tests/ts/my-game/example2.d.ts @@ -0,0 +1 @@ +export { Monster } from './example2/monster.js'; diff --git a/tests/ts/my-game/example2/monster.d.ts b/tests/ts/my-game/example2/monster.d.ts new file mode 100644 index 00000000000..9da773b7d42 --- /dev/null +++ b/tests/ts/my-game/example2/monster.d.ts @@ -0,0 +1,20 @@ +import * as flatbuffers from 'flatbuffers'; +export declare class Monster implements flatbuffers.IUnpackableObject { + bb: flatbuffers.ByteBuffer | null; + bb_pos: number; + __init(i: number, bb: flatbuffers.ByteBuffer): Monster; + static getRootAsMonster(bb: flatbuffers.ByteBuffer, obj?: Monster): Monster; + static getSizePrefixedRootAsMonster(bb: flatbuffers.ByteBuffer, obj?: Monster): Monster; + static getFullyQualifiedName(): string; + static startMonster(builder: flatbuffers.Builder): void; + static endMonster(builder: flatbuffers.Builder): flatbuffers.Offset; + static createMonster(builder: flatbuffers.Builder): flatbuffers.Offset; + serialize(): Uint8Array; + static deserialize(buffer: Uint8Array): Monster; + unpack(): MonsterT; + unpackTo(_o: MonsterT): void; +} +export declare class MonsterT implements flatbuffers.IGeneratedObject { + constructor(); + pack(builder: flatbuffers.Builder): flatbuffers.Offset; +} diff --git a/tests/ts/my-game/in-parent-namespace.d.ts b/tests/ts/my-game/in-parent-namespace.d.ts new file mode 100644 index 00000000000..07dc15659af --- /dev/null +++ b/tests/ts/my-game/in-parent-namespace.d.ts @@ -0,0 +1,20 @@ +import * as flatbuffers from 'flatbuffers'; +export declare class InParentNamespace implements flatbuffers.IUnpackableObject { + bb: flatbuffers.ByteBuffer | null; + bb_pos: number; + __init(i: number, bb: flatbuffers.ByteBuffer): InParentNamespace; + static getRootAsInParentNamespace(bb: flatbuffers.ByteBuffer, obj?: InParentNamespace): InParentNamespace; + static getSizePrefixedRootAsInParentNamespace(bb: flatbuffers.ByteBuffer, obj?: InParentNamespace): InParentNamespace; + static getFullyQualifiedName(): string; + static startInParentNamespace(builder: flatbuffers.Builder): void; + static endInParentNamespace(builder: flatbuffers.Builder): flatbuffers.Offset; + static createInParentNamespace(builder: flatbuffers.Builder): flatbuffers.Offset; + serialize(): Uint8Array; + static deserialize(buffer: Uint8Array): InParentNamespace; + unpack(): InParentNamespaceT; + unpackTo(_o: InParentNamespaceT): void; +} +export declare class InParentNamespaceT implements flatbuffers.IGeneratedObject { + constructor(); + pack(builder: flatbuffers.Builder): flatbuffers.Offset; +} diff --git a/tests/ts/my-game/other-name-space.d.ts b/tests/ts/my-game/other-name-space.d.ts new file mode 100644 index 00000000000..d6cab69e85e --- /dev/null +++ b/tests/ts/my-game/other-name-space.d.ts @@ -0,0 +1,3 @@ +export { FromInclude } from './other-name-space/from-include.js'; +export { TableB } from './other-name-space/table-b.js'; +export { Unused } from './other-name-space/unused.js'; diff --git a/tests/ts/my-game/other-name-space/from-include.d.ts b/tests/ts/my-game/other-name-space/from-include.d.ts new file mode 100644 index 00000000000..dc12fa4b68f --- /dev/null +++ b/tests/ts/my-game/other-name-space/from-include.d.ts @@ -0,0 +1,3 @@ +export declare enum FromInclude { + IncludeVal = "0" +} diff --git a/tests/ts/my-game/other-name-space/table-b.d.ts b/tests/ts/my-game/other-name-space/table-b.d.ts new file mode 100644 index 00000000000..d4e1bcfc580 --- /dev/null +++ b/tests/ts/my-game/other-name-space/table-b.d.ts @@ -0,0 +1,24 @@ +import * as flatbuffers from 'flatbuffers'; +import { TableA, TableAT } from '../../table-a.js'; +export declare class TableB implements flatbuffers.IUnpackableObject { + bb: flatbuffers.ByteBuffer | null; + bb_pos: number; + __init(i: number, bb: flatbuffers.ByteBuffer): TableB; + static getRootAsTableB(bb: flatbuffers.ByteBuffer, obj?: TableB): TableB; + static getSizePrefixedRootAsTableB(bb: flatbuffers.ByteBuffer, obj?: TableB): TableB; + a(obj?: TableA): TableA | null; + static getFullyQualifiedName(): string; + static startTableB(builder: flatbuffers.Builder): void; + static addA(builder: flatbuffers.Builder, aOffset: flatbuffers.Offset): void; + static endTableB(builder: flatbuffers.Builder): flatbuffers.Offset; + static createTableB(builder: flatbuffers.Builder, aOffset: flatbuffers.Offset): flatbuffers.Offset; + serialize(): Uint8Array; + static deserialize(buffer: Uint8Array): TableB; + unpack(): TableBT; + unpackTo(_o: TableBT): void; +} +export declare class TableBT implements flatbuffers.IGeneratedObject { + a: TableAT | null; + constructor(a?: TableAT | null); + pack(builder: flatbuffers.Builder): flatbuffers.Offset; +} diff --git a/tests/ts/my-game/other-name-space/unused.d.ts b/tests/ts/my-game/other-name-space/unused.d.ts new file mode 100644 index 00000000000..6d929f24b37 --- /dev/null +++ b/tests/ts/my-game/other-name-space/unused.d.ts @@ -0,0 +1,18 @@ +import * as flatbuffers from 'flatbuffers'; +export declare class Unused implements flatbuffers.IUnpackableObject { + bb: flatbuffers.ByteBuffer | null; + bb_pos: number; + __init(i: number, bb: flatbuffers.ByteBuffer): Unused; + a(): number; + mutate_a(value: number): boolean; + static getFullyQualifiedName(): string; + static sizeOf(): number; + static createUnused(builder: flatbuffers.Builder, a: number): flatbuffers.Offset; + unpack(): UnusedT; + unpackTo(_o: UnusedT): void; +} +export declare class UnusedT implements flatbuffers.IGeneratedObject { + a: number; + constructor(a?: number); + pack(builder: flatbuffers.Builder): flatbuffers.Offset; +} diff --git a/tests/ts/reflection/base-type.d.ts b/tests/ts/reflection/base-type.d.ts new file mode 100644 index 00000000000..43ff4feb770 --- /dev/null +++ b/tests/ts/reflection/base-type.d.ts @@ -0,0 +1,21 @@ +export declare 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.d.ts b/tests/ts/reflection/enum-val.d.ts new file mode 100644 index 00000000000..ba436fffa20 --- /dev/null +++ b/tests/ts/reflection/enum-val.d.ts @@ -0,0 +1,43 @@ +import * as flatbuffers from 'flatbuffers'; +import { KeyValue, KeyValueT } from '../reflection/key-value.js'; +import { Type, TypeT } from '../reflection/type.js'; +export declare class EnumVal implements flatbuffers.IUnpackableObject { + bb: flatbuffers.ByteBuffer | null; + bb_pos: number; + __init(i: number, bb: flatbuffers.ByteBuffer): EnumVal; + static getRootAsEnumVal(bb: flatbuffers.ByteBuffer, obj?: EnumVal): EnumVal; + static getSizePrefixedRootAsEnumVal(bb: flatbuffers.ByteBuffer, obj?: EnumVal): EnumVal; + name(): string | null; + name(optionalEncoding: flatbuffers.Encoding): string | Uint8Array | null; + value(): bigint; + mutate_value(value: bigint): boolean; + unionType(obj?: Type): Type | null; + documentation(index: number): string; + documentation(index: number, optionalEncoding: flatbuffers.Encoding): string | Uint8Array; + documentationLength(): number; + attributes(index: number, obj?: KeyValue): KeyValue | null; + attributesLength(): number; + static getFullyQualifiedName(): string; + static startEnumVal(builder: flatbuffers.Builder): void; + static addName(builder: flatbuffers.Builder, nameOffset: flatbuffers.Offset): void; + static addValue(builder: flatbuffers.Builder, value: bigint): void; + static addUnionType(builder: flatbuffers.Builder, unionTypeOffset: flatbuffers.Offset): void; + static addDocumentation(builder: flatbuffers.Builder, documentationOffset: flatbuffers.Offset): void; + static createDocumentationVector(builder: flatbuffers.Builder, data: flatbuffers.Offset[]): flatbuffers.Offset; + static startDocumentationVector(builder: flatbuffers.Builder, numElems: number): void; + static addAttributes(builder: flatbuffers.Builder, attributesOffset: flatbuffers.Offset): void; + static createAttributesVector(builder: flatbuffers.Builder, data: flatbuffers.Offset[]): flatbuffers.Offset; + static startAttributesVector(builder: flatbuffers.Builder, numElems: number): void; + static endEnumVal(builder: flatbuffers.Builder): flatbuffers.Offset; + unpack(): EnumValT; + unpackTo(_o: EnumValT): void; +} +export declare class EnumValT implements flatbuffers.IGeneratedObject { + name: string | Uint8Array | null; + value: bigint; + unionType: TypeT | null; + documentation: (string)[]; + attributes: (KeyValueT)[]; + constructor(name?: string | Uint8Array | null, value?: bigint, unionType?: TypeT | null, documentation?: (string)[], attributes?: (KeyValueT)[]); + pack(builder: flatbuffers.Builder): flatbuffers.Offset; +} diff --git a/tests/ts/reflection/enum.d.ts b/tests/ts/reflection/enum.d.ts new file mode 100644 index 00000000000..e4226bf5244 --- /dev/null +++ b/tests/ts/reflection/enum.d.ts @@ -0,0 +1,57 @@ +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 declare class Enum implements flatbuffers.IUnpackableObject { + bb: flatbuffers.ByteBuffer | null; + bb_pos: number; + __init(i: number, bb: flatbuffers.ByteBuffer): Enum; + static getRootAsEnum(bb: flatbuffers.ByteBuffer, obj?: Enum): Enum; + static getSizePrefixedRootAsEnum(bb: flatbuffers.ByteBuffer, obj?: Enum): Enum; + name(): string | null; + name(optionalEncoding: flatbuffers.Encoding): string | Uint8Array | null; + values(index: number, obj?: EnumVal): EnumVal | null; + valuesLength(): number; + isUnion(): boolean; + mutate_is_union(value: boolean): boolean; + underlyingType(obj?: Type): Type | null; + attributes(index: number, obj?: KeyValue): KeyValue | null; + attributesLength(): number; + documentation(index: number): string; + documentation(index: number, optionalEncoding: flatbuffers.Encoding): string | Uint8Array; + documentationLength(): number; + /** + * File that this Enum is declared in. + */ + declarationFile(): string | null; + declarationFile(optionalEncoding: flatbuffers.Encoding): string | Uint8Array | null; + static getFullyQualifiedName(): string; + static startEnum(builder: flatbuffers.Builder): void; + static addName(builder: flatbuffers.Builder, nameOffset: flatbuffers.Offset): void; + static addValues(builder: flatbuffers.Builder, valuesOffset: flatbuffers.Offset): void; + static createValuesVector(builder: flatbuffers.Builder, data: flatbuffers.Offset[]): flatbuffers.Offset; + static startValuesVector(builder: flatbuffers.Builder, numElems: number): void; + static addIsUnion(builder: flatbuffers.Builder, isUnion: boolean): void; + static addUnderlyingType(builder: flatbuffers.Builder, underlyingTypeOffset: flatbuffers.Offset): void; + static addAttributes(builder: flatbuffers.Builder, attributesOffset: flatbuffers.Offset): void; + static createAttributesVector(builder: flatbuffers.Builder, data: flatbuffers.Offset[]): flatbuffers.Offset; + static startAttributesVector(builder: flatbuffers.Builder, numElems: number): void; + static addDocumentation(builder: flatbuffers.Builder, documentationOffset: flatbuffers.Offset): void; + static createDocumentationVector(builder: flatbuffers.Builder, data: flatbuffers.Offset[]): flatbuffers.Offset; + static startDocumentationVector(builder: flatbuffers.Builder, numElems: number): void; + static addDeclarationFile(builder: flatbuffers.Builder, declarationFileOffset: flatbuffers.Offset): void; + static endEnum(builder: flatbuffers.Builder): flatbuffers.Offset; + unpack(): EnumT; + unpackTo(_o: EnumT): void; +} +export declare class EnumT implements flatbuffers.IGeneratedObject { + name: string | Uint8Array | null; + values: (EnumValT)[]; + isUnion: boolean; + underlyingType: TypeT | null; + attributes: (KeyValueT)[]; + documentation: (string)[]; + declarationFile: string | Uint8Array | null; + constructor(name?: string | Uint8Array | null, values?: (EnumValT)[], isUnion?: boolean, underlyingType?: TypeT | null, attributes?: (KeyValueT)[], documentation?: (string)[], declarationFile?: string | Uint8Array | null); + pack(builder: flatbuffers.Builder): flatbuffers.Offset; +} diff --git a/tests/ts/reflection/field.d.ts b/tests/ts/reflection/field.d.ts new file mode 100644 index 00000000000..42a2142b6d9 --- /dev/null +++ b/tests/ts/reflection/field.d.ts @@ -0,0 +1,78 @@ +import * as flatbuffers from 'flatbuffers'; +import { KeyValue, KeyValueT } from '../reflection/key-value.js'; +import { Type, TypeT } from '../reflection/type.js'; +export declare class Field implements flatbuffers.IUnpackableObject { + bb: flatbuffers.ByteBuffer | null; + bb_pos: number; + __init(i: number, bb: flatbuffers.ByteBuffer): Field; + static getRootAsField(bb: flatbuffers.ByteBuffer, obj?: Field): Field; + static getSizePrefixedRootAsField(bb: flatbuffers.ByteBuffer, obj?: Field): Field; + name(): string | null; + name(optionalEncoding: flatbuffers.Encoding): string | Uint8Array | null; + type(obj?: Type): Type | null; + id(): number; + mutate_id(value: number): boolean; + offset(): number; + mutate_offset(value: number): boolean; + defaultInteger(): bigint; + mutate_default_integer(value: bigint): boolean; + defaultReal(): number; + mutate_default_real(value: number): boolean; + deprecated(): boolean; + mutate_deprecated(value: boolean): boolean; + required(): boolean; + mutate_required(value: boolean): boolean; + key(): boolean; + mutate_key(value: boolean): boolean; + attributes(index: number, obj?: KeyValue): KeyValue | null; + attributesLength(): number; + documentation(index: number): string; + documentation(index: number, optionalEncoding: flatbuffers.Encoding): string | Uint8Array; + documentationLength(): number; + optional(): boolean; + mutate_optional(value: boolean): boolean; + /** + * Number of padding octets to always add after this field. Structs only. + */ + padding(): number; + mutate_padding(value: number): boolean; + static getFullyQualifiedName(): string; + static startField(builder: flatbuffers.Builder): void; + static addName(builder: flatbuffers.Builder, nameOffset: flatbuffers.Offset): void; + static addType(builder: flatbuffers.Builder, typeOffset: flatbuffers.Offset): void; + static addId(builder: flatbuffers.Builder, id: number): void; + static addOffset(builder: flatbuffers.Builder, offset: number): void; + static addDefaultInteger(builder: flatbuffers.Builder, defaultInteger: bigint): void; + static addDefaultReal(builder: flatbuffers.Builder, defaultReal: number): void; + static addDeprecated(builder: flatbuffers.Builder, deprecated: boolean): void; + static addRequired(builder: flatbuffers.Builder, required: boolean): void; + static addKey(builder: flatbuffers.Builder, key: boolean): void; + static addAttributes(builder: flatbuffers.Builder, attributesOffset: flatbuffers.Offset): void; + static createAttributesVector(builder: flatbuffers.Builder, data: flatbuffers.Offset[]): flatbuffers.Offset; + static startAttributesVector(builder: flatbuffers.Builder, numElems: number): void; + static addDocumentation(builder: flatbuffers.Builder, documentationOffset: flatbuffers.Offset): void; + static createDocumentationVector(builder: flatbuffers.Builder, data: flatbuffers.Offset[]): flatbuffers.Offset; + static startDocumentationVector(builder: flatbuffers.Builder, numElems: number): void; + static addOptional(builder: flatbuffers.Builder, optional: boolean): void; + static addPadding(builder: flatbuffers.Builder, padding: number): void; + static endField(builder: flatbuffers.Builder): flatbuffers.Offset; + unpack(): FieldT; + unpackTo(_o: FieldT): void; +} +export declare class FieldT implements flatbuffers.IGeneratedObject { + name: string | Uint8Array | null; + type: TypeT | null; + id: number; + offset: number; + defaultInteger: bigint; + defaultReal: number; + deprecated: boolean; + required: boolean; + key: boolean; + attributes: (KeyValueT)[]; + documentation: (string)[]; + optional: boolean; + padding: number; + constructor(name?: string | Uint8Array | null, type?: TypeT | null, id?: number, offset?: number, defaultInteger?: bigint, defaultReal?: number, deprecated?: boolean, required?: boolean, key?: boolean, attributes?: (KeyValueT)[], documentation?: (string)[], optional?: boolean, padding?: number); + pack(builder: flatbuffers.Builder): flatbuffers.Offset; +} diff --git a/tests/ts/reflection/key-value.d.ts b/tests/ts/reflection/key-value.d.ts new file mode 100644 index 00000000000..23f5f1d442a --- /dev/null +++ b/tests/ts/reflection/key-value.d.ts @@ -0,0 +1,26 @@ +import * as flatbuffers from 'flatbuffers'; +export declare class KeyValue implements flatbuffers.IUnpackableObject { + bb: flatbuffers.ByteBuffer | null; + bb_pos: number; + __init(i: number, bb: flatbuffers.ByteBuffer): KeyValue; + static getRootAsKeyValue(bb: flatbuffers.ByteBuffer, obj?: KeyValue): KeyValue; + static getSizePrefixedRootAsKeyValue(bb: flatbuffers.ByteBuffer, obj?: KeyValue): KeyValue; + key(): string | null; + key(optionalEncoding: flatbuffers.Encoding): string | Uint8Array | null; + value(): string | null; + value(optionalEncoding: flatbuffers.Encoding): string | Uint8Array | null; + static getFullyQualifiedName(): string; + static startKeyValue(builder: flatbuffers.Builder): void; + static addKey(builder: flatbuffers.Builder, keyOffset: flatbuffers.Offset): void; + static addValue(builder: flatbuffers.Builder, valueOffset: flatbuffers.Offset): void; + static endKeyValue(builder: flatbuffers.Builder): flatbuffers.Offset; + static createKeyValue(builder: flatbuffers.Builder, keyOffset: flatbuffers.Offset, valueOffset: flatbuffers.Offset): flatbuffers.Offset; + unpack(): KeyValueT; + unpackTo(_o: KeyValueT): void; +} +export declare class KeyValueT implements flatbuffers.IGeneratedObject { + key: string | Uint8Array | null; + value: string | Uint8Array | null; + constructor(key?: string | Uint8Array | null, value?: string | Uint8Array | null); + pack(builder: flatbuffers.Builder): flatbuffers.Offset; +} diff --git a/tests/ts/reflection/object.d.ts b/tests/ts/reflection/object.d.ts new file mode 100644 index 00000000000..8f8c5400df8 --- /dev/null +++ b/tests/ts/reflection/object.d.ts @@ -0,0 +1,62 @@ +import * as flatbuffers from 'flatbuffers'; +import { Field, FieldT } from '../reflection/field.js'; +import { KeyValue, KeyValueT } from '../reflection/key-value.js'; +export declare class Object_ implements flatbuffers.IUnpackableObject { + bb: flatbuffers.ByteBuffer | null; + bb_pos: number; + __init(i: number, bb: flatbuffers.ByteBuffer): Object_; + static getRootAsObject(bb: flatbuffers.ByteBuffer, obj?: Object_): Object_; + static getSizePrefixedRootAsObject(bb: flatbuffers.ByteBuffer, obj?: Object_): Object_; + name(): string | null; + name(optionalEncoding: flatbuffers.Encoding): string | Uint8Array | null; + fields(index: number, obj?: Field): Field | null; + fieldsLength(): number; + isStruct(): boolean; + mutate_is_struct(value: boolean): boolean; + minalign(): number; + mutate_minalign(value: number): boolean; + bytesize(): number; + mutate_bytesize(value: number): boolean; + attributes(index: number, obj?: KeyValue): KeyValue | null; + attributesLength(): number; + documentation(index: number): string; + documentation(index: number, optionalEncoding: flatbuffers.Encoding): string | Uint8Array; + documentationLength(): number; + /** + * File that this Object is declared in. + */ + declarationFile(): string | null; + declarationFile(optionalEncoding: flatbuffers.Encoding): string | Uint8Array | null; + static getFullyQualifiedName(): string; + static startObject(builder: flatbuffers.Builder): void; + static addName(builder: flatbuffers.Builder, nameOffset: flatbuffers.Offset): void; + static addFields(builder: flatbuffers.Builder, fieldsOffset: flatbuffers.Offset): void; + static createFieldsVector(builder: flatbuffers.Builder, data: flatbuffers.Offset[]): flatbuffers.Offset; + static startFieldsVector(builder: flatbuffers.Builder, numElems: number): void; + static addIsStruct(builder: flatbuffers.Builder, isStruct: boolean): void; + static addMinalign(builder: flatbuffers.Builder, minalign: number): void; + static addBytesize(builder: flatbuffers.Builder, bytesize: number): void; + static addAttributes(builder: flatbuffers.Builder, attributesOffset: flatbuffers.Offset): void; + static createAttributesVector(builder: flatbuffers.Builder, data: flatbuffers.Offset[]): flatbuffers.Offset; + static startAttributesVector(builder: flatbuffers.Builder, numElems: number): void; + static addDocumentation(builder: flatbuffers.Builder, documentationOffset: flatbuffers.Offset): void; + static createDocumentationVector(builder: flatbuffers.Builder, data: flatbuffers.Offset[]): flatbuffers.Offset; + static startDocumentationVector(builder: flatbuffers.Builder, numElems: number): void; + static addDeclarationFile(builder: flatbuffers.Builder, declarationFileOffset: flatbuffers.Offset): void; + static endObject(builder: flatbuffers.Builder): flatbuffers.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; + unpack(): Object_T; + unpackTo(_o: Object_T): void; +} +export declare class Object_T implements flatbuffers.IGeneratedObject { + name: string | Uint8Array | null; + fields: (FieldT)[]; + isStruct: boolean; + minalign: number; + bytesize: number; + attributes: (KeyValueT)[]; + documentation: (string)[]; + declarationFile: string | Uint8Array | null; + constructor(name?: string | Uint8Array | null, fields?: (FieldT)[], isStruct?: boolean, minalign?: number, bytesize?: number, attributes?: (KeyValueT)[], documentation?: (string)[], declarationFile?: string | Uint8Array | null); + pack(builder: flatbuffers.Builder): flatbuffers.Offset; +} diff --git a/tests/ts/reflection/rpccall.d.ts b/tests/ts/reflection/rpccall.d.ts new file mode 100644 index 00000000000..e70ba917495 --- /dev/null +++ b/tests/ts/reflection/rpccall.d.ts @@ -0,0 +1,42 @@ +import * as flatbuffers from 'flatbuffers'; +import { KeyValue, KeyValueT } from '../reflection/key-value.js'; +import { Object_, Object_T } from '../reflection/object.js'; +export declare class RPCCall implements flatbuffers.IUnpackableObject { + bb: flatbuffers.ByteBuffer | null; + bb_pos: number; + __init(i: number, bb: flatbuffers.ByteBuffer): RPCCall; + static getRootAsRPCCall(bb: flatbuffers.ByteBuffer, obj?: RPCCall): RPCCall; + static getSizePrefixedRootAsRPCCall(bb: flatbuffers.ByteBuffer, obj?: RPCCall): RPCCall; + name(): string | null; + name(optionalEncoding: flatbuffers.Encoding): string | Uint8Array | null; + request(obj?: Object_): Object_ | null; + response(obj?: Object_): Object_ | null; + attributes(index: number, obj?: KeyValue): KeyValue | null; + attributesLength(): number; + documentation(index: number): string; + documentation(index: number, optionalEncoding: flatbuffers.Encoding): string | Uint8Array; + documentationLength(): number; + static getFullyQualifiedName(): string; + static startRPCCall(builder: flatbuffers.Builder): void; + static addName(builder: flatbuffers.Builder, nameOffset: flatbuffers.Offset): void; + static addRequest(builder: flatbuffers.Builder, requestOffset: flatbuffers.Offset): void; + static addResponse(builder: flatbuffers.Builder, responseOffset: flatbuffers.Offset): void; + static addAttributes(builder: flatbuffers.Builder, attributesOffset: flatbuffers.Offset): void; + static createAttributesVector(builder: flatbuffers.Builder, data: flatbuffers.Offset[]): flatbuffers.Offset; + static startAttributesVector(builder: flatbuffers.Builder, numElems: number): void; + static addDocumentation(builder: flatbuffers.Builder, documentationOffset: flatbuffers.Offset): void; + static createDocumentationVector(builder: flatbuffers.Builder, data: flatbuffers.Offset[]): flatbuffers.Offset; + static startDocumentationVector(builder: flatbuffers.Builder, numElems: number): void; + static endRPCCall(builder: flatbuffers.Builder): flatbuffers.Offset; + unpack(): RPCCallT; + unpackTo(_o: RPCCallT): void; +} +export declare class RPCCallT implements flatbuffers.IGeneratedObject { + name: string | Uint8Array | null; + request: Object_T | null; + response: Object_T | null; + attributes: (KeyValueT)[]; + documentation: (string)[]; + constructor(name?: string | Uint8Array | null, request?: Object_T | null, response?: Object_T | null, attributes?: (KeyValueT)[], documentation?: (string)[]); + pack(builder: flatbuffers.Builder): flatbuffers.Offset; +} diff --git a/tests/ts/reflection/schema-file.d.ts b/tests/ts/reflection/schema-file.d.ts new file mode 100644 index 00000000000..18f943caa42 --- /dev/null +++ b/tests/ts/reflection/schema-file.d.ts @@ -0,0 +1,40 @@ +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 declare class SchemaFile implements flatbuffers.IUnpackableObject { + bb: flatbuffers.ByteBuffer | null; + bb_pos: number; + __init(i: number, bb: flatbuffers.ByteBuffer): SchemaFile; + static getRootAsSchemaFile(bb: flatbuffers.ByteBuffer, obj?: SchemaFile): SchemaFile; + static getSizePrefixedRootAsSchemaFile(bb: flatbuffers.ByteBuffer, obj?: SchemaFile): SchemaFile; + /** + * Filename, relative to project root. + */ + filename(): string | null; + filename(optionalEncoding: flatbuffers.Encoding): string | Uint8Array | null; + /** + * Names of included files, relative to project root. + */ + includedFilenames(index: number): string; + includedFilenames(index: number, optionalEncoding: flatbuffers.Encoding): string | Uint8Array; + includedFilenamesLength(): number; + static getFullyQualifiedName(): string; + static startSchemaFile(builder: flatbuffers.Builder): void; + static addFilename(builder: flatbuffers.Builder, filenameOffset: flatbuffers.Offset): void; + static addIncludedFilenames(builder: flatbuffers.Builder, includedFilenamesOffset: flatbuffers.Offset): void; + static createIncludedFilenamesVector(builder: flatbuffers.Builder, data: flatbuffers.Offset[]): flatbuffers.Offset; + static startIncludedFilenamesVector(builder: flatbuffers.Builder, numElems: number): void; + static endSchemaFile(builder: flatbuffers.Builder): flatbuffers.Offset; + static createSchemaFile(builder: flatbuffers.Builder, filenameOffset: flatbuffers.Offset, includedFilenamesOffset: flatbuffers.Offset): flatbuffers.Offset; + unpack(): SchemaFileT; + unpackTo(_o: SchemaFileT): void; +} +export declare class SchemaFileT implements flatbuffers.IGeneratedObject { + filename: string | Uint8Array | null; + includedFilenames: (string)[]; + constructor(filename?: string | Uint8Array | null, includedFilenames?: (string)[]); + pack(builder: flatbuffers.Builder): flatbuffers.Offset; +} diff --git a/tests/ts/reflection/schema.d.ts b/tests/ts/reflection/schema.d.ts new file mode 100644 index 00000000000..40a38afa169 --- /dev/null +++ b/tests/ts/reflection/schema.d.ts @@ -0,0 +1,67 @@ +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 declare class Schema implements flatbuffers.IUnpackableObject { + bb: flatbuffers.ByteBuffer | null; + bb_pos: number; + __init(i: number, bb: flatbuffers.ByteBuffer): Schema; + static getRootAsSchema(bb: flatbuffers.ByteBuffer, obj?: Schema): Schema; + static getSizePrefixedRootAsSchema(bb: flatbuffers.ByteBuffer, obj?: Schema): Schema; + static bufferHasIdentifier(bb: flatbuffers.ByteBuffer): boolean; + objects(index: number, obj?: Object_): Object_ | null; + objectsLength(): number; + enums(index: number, obj?: Enum): Enum | null; + enumsLength(): number; + fileIdent(): string | null; + fileIdent(optionalEncoding: flatbuffers.Encoding): string | Uint8Array | null; + fileExt(): string | null; + fileExt(optionalEncoding: flatbuffers.Encoding): string | Uint8Array | null; + rootTable(obj?: Object_): Object_ | null; + services(index: number, obj?: Service): Service | null; + servicesLength(): number; + advancedFeatures(): bigint; + mutate_advanced_features(value: bigint): boolean; + /** + * All the files used in this compilation. Files are relative to where + * flatc was invoked. + */ + fbsFiles(index: number, obj?: SchemaFile): SchemaFile | null; + fbsFilesLength(): number; + static getFullyQualifiedName(): string; + static startSchema(builder: flatbuffers.Builder): void; + static addObjects(builder: flatbuffers.Builder, objectsOffset: flatbuffers.Offset): void; + static createObjectsVector(builder: flatbuffers.Builder, data: flatbuffers.Offset[]): flatbuffers.Offset; + static startObjectsVector(builder: flatbuffers.Builder, numElems: number): void; + static addEnums(builder: flatbuffers.Builder, enumsOffset: flatbuffers.Offset): void; + static createEnumsVector(builder: flatbuffers.Builder, data: flatbuffers.Offset[]): flatbuffers.Offset; + static startEnumsVector(builder: flatbuffers.Builder, numElems: number): void; + static addFileIdent(builder: flatbuffers.Builder, fileIdentOffset: flatbuffers.Offset): void; + static addFileExt(builder: flatbuffers.Builder, fileExtOffset: flatbuffers.Offset): void; + static addRootTable(builder: flatbuffers.Builder, rootTableOffset: flatbuffers.Offset): void; + static addServices(builder: flatbuffers.Builder, servicesOffset: flatbuffers.Offset): void; + static createServicesVector(builder: flatbuffers.Builder, data: flatbuffers.Offset[]): flatbuffers.Offset; + static startServicesVector(builder: flatbuffers.Builder, numElems: number): void; + static addAdvancedFeatures(builder: flatbuffers.Builder, advancedFeatures: bigint): void; + static addFbsFiles(builder: flatbuffers.Builder, fbsFilesOffset: flatbuffers.Offset): void; + static createFbsFilesVector(builder: flatbuffers.Builder, data: flatbuffers.Offset[]): flatbuffers.Offset; + static startFbsFilesVector(builder: flatbuffers.Builder, numElems: number): void; + static endSchema(builder: flatbuffers.Builder): flatbuffers.Offset; + static finishSchemaBuffer(builder: flatbuffers.Builder, offset: flatbuffers.Offset): void; + static finishSizePrefixedSchemaBuffer(builder: flatbuffers.Builder, offset: flatbuffers.Offset): void; + unpack(): SchemaT; + unpackTo(_o: SchemaT): void; +} +export declare class SchemaT implements flatbuffers.IGeneratedObject { + objects: (Object_T)[]; + enums: (EnumT)[]; + fileIdent: string | Uint8Array | null; + fileExt: string | Uint8Array | null; + rootTable: Object_T | null; + services: (ServiceT)[]; + advancedFeatures: bigint; + fbsFiles: (SchemaFileT)[]; + constructor(objects?: (Object_T)[], enums?: (EnumT)[], fileIdent?: string | Uint8Array | null, fileExt?: string | Uint8Array | null, rootTable?: Object_T | null, services?: (ServiceT)[], advancedFeatures?: bigint, fbsFiles?: (SchemaFileT)[]); + pack(builder: flatbuffers.Builder): flatbuffers.Offset; +} diff --git a/tests/ts/reflection/service.d.ts b/tests/ts/reflection/service.d.ts new file mode 100644 index 00000000000..6bea22bb6fb --- /dev/null +++ b/tests/ts/reflection/service.d.ts @@ -0,0 +1,50 @@ +import * as flatbuffers from 'flatbuffers'; +import { KeyValue, KeyValueT } from '../reflection/key-value.js'; +import { RPCCall, RPCCallT } from '../reflection/rpccall.js'; +export declare class Service implements flatbuffers.IUnpackableObject { + bb: flatbuffers.ByteBuffer | null; + bb_pos: number; + __init(i: number, bb: flatbuffers.ByteBuffer): Service; + static getRootAsService(bb: flatbuffers.ByteBuffer, obj?: Service): Service; + static getSizePrefixedRootAsService(bb: flatbuffers.ByteBuffer, obj?: Service): Service; + name(): string | null; + name(optionalEncoding: flatbuffers.Encoding): string | Uint8Array | null; + calls(index: number, obj?: RPCCall): RPCCall | null; + callsLength(): number; + attributes(index: number, obj?: KeyValue): KeyValue | null; + attributesLength(): number; + documentation(index: number): string; + documentation(index: number, optionalEncoding: flatbuffers.Encoding): string | Uint8Array; + documentationLength(): number; + /** + * File that this Service is declared in. + */ + declarationFile(): string | null; + declarationFile(optionalEncoding: flatbuffers.Encoding): string | Uint8Array | null; + static getFullyQualifiedName(): string; + static startService(builder: flatbuffers.Builder): void; + static addName(builder: flatbuffers.Builder, nameOffset: flatbuffers.Offset): void; + static addCalls(builder: flatbuffers.Builder, callsOffset: flatbuffers.Offset): void; + static createCallsVector(builder: flatbuffers.Builder, data: flatbuffers.Offset[]): flatbuffers.Offset; + static startCallsVector(builder: flatbuffers.Builder, numElems: number): void; + static addAttributes(builder: flatbuffers.Builder, attributesOffset: flatbuffers.Offset): void; + static createAttributesVector(builder: flatbuffers.Builder, data: flatbuffers.Offset[]): flatbuffers.Offset; + static startAttributesVector(builder: flatbuffers.Builder, numElems: number): void; + static addDocumentation(builder: flatbuffers.Builder, documentationOffset: flatbuffers.Offset): void; + static createDocumentationVector(builder: flatbuffers.Builder, data: flatbuffers.Offset[]): flatbuffers.Offset; + static startDocumentationVector(builder: flatbuffers.Builder, numElems: number): void; + static addDeclarationFile(builder: flatbuffers.Builder, declarationFileOffset: flatbuffers.Offset): void; + static endService(builder: flatbuffers.Builder): flatbuffers.Offset; + static createService(builder: flatbuffers.Builder, nameOffset: flatbuffers.Offset, callsOffset: flatbuffers.Offset, attributesOffset: flatbuffers.Offset, documentationOffset: flatbuffers.Offset, declarationFileOffset: flatbuffers.Offset): flatbuffers.Offset; + unpack(): ServiceT; + unpackTo(_o: ServiceT): void; +} +export declare class ServiceT implements flatbuffers.IGeneratedObject { + name: string | Uint8Array | null; + calls: (RPCCallT)[]; + attributes: (KeyValueT)[]; + documentation: (string)[]; + declarationFile: string | Uint8Array | null; + constructor(name?: string | Uint8Array | null, calls?: (RPCCallT)[], attributes?: (KeyValueT)[], documentation?: (string)[], declarationFile?: string | Uint8Array | null); + pack(builder: flatbuffers.Builder): flatbuffers.Offset; +} diff --git a/tests/ts/reflection/type.d.ts b/tests/ts/reflection/type.d.ts new file mode 100644 index 00000000000..811732c6f47 --- /dev/null +++ b/tests/ts/reflection/type.d.ts @@ -0,0 +1,49 @@ +import * as flatbuffers from 'flatbuffers'; +import { BaseType } from '../reflection/base-type.js'; +export declare class Type implements flatbuffers.IUnpackableObject { + bb: flatbuffers.ByteBuffer | null; + bb_pos: number; + __init(i: number, bb: flatbuffers.ByteBuffer): Type; + static getRootAsType(bb: flatbuffers.ByteBuffer, obj?: Type): Type; + static getSizePrefixedRootAsType(bb: flatbuffers.ByteBuffer, obj?: Type): Type; + baseType(): BaseType; + mutate_base_type(value: BaseType): boolean; + element(): BaseType; + mutate_element(value: BaseType): boolean; + index(): number; + mutate_index(value: number): boolean; + fixedLength(): number; + mutate_fixed_length(value: number): boolean; + /** + * The size (octets) of the `base_type` field. + */ + baseSize(): number; + mutate_base_size(value: number): boolean; + /** + * The size (octets) of the `element` field, if present. + */ + elementSize(): number; + mutate_element_size(value: number): boolean; + static getFullyQualifiedName(): string; + static startType(builder: flatbuffers.Builder): void; + static addBaseType(builder: flatbuffers.Builder, baseType: BaseType): void; + static addElement(builder: flatbuffers.Builder, element: BaseType): void; + static addIndex(builder: flatbuffers.Builder, index: number): void; + static addFixedLength(builder: flatbuffers.Builder, fixedLength: number): void; + static addBaseSize(builder: flatbuffers.Builder, baseSize: number): void; + static addElementSize(builder: flatbuffers.Builder, elementSize: number): void; + static endType(builder: flatbuffers.Builder): flatbuffers.Offset; + static createType(builder: flatbuffers.Builder, baseType: BaseType, element: BaseType, index: number, fixedLength: number, baseSize: number, elementSize: number): flatbuffers.Offset; + unpack(): TypeT; + unpackTo(_o: TypeT): void; +} +export declare class TypeT implements flatbuffers.IGeneratedObject { + baseType: BaseType; + element: BaseType; + index: number; + fixedLength: number; + baseSize: number; + elementSize: number; + constructor(baseType?: BaseType, element?: BaseType, index?: number, fixedLength?: number, baseSize?: number, elementSize?: number); + pack(builder: flatbuffers.Builder): flatbuffers.Offset; +} diff --git a/tests/ts/reflection_generated.cjs b/tests/ts/reflection_generated.cjs index 1dea5b17a49..45a4a1e711d 100644 --- a/tests/ts/reflection_generated.cjs +++ b/tests/ts/reflection_generated.cjs @@ -108,7 +108,7 @@ var KeyValue = class { return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null; } static getFullyQualifiedName() { - return "reflection.KeyValue"; + return "reflection_KeyValue"; } static startKeyValue(builder) { builder.startObject(2); @@ -242,7 +242,7 @@ var Type = class { return true; } static getFullyQualifiedName() { - return "reflection.Type"; + return "reflection_Type"; } static startType(builder) { builder.startObject(6); @@ -360,7 +360,7 @@ var EnumVal = class { return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; } static getFullyQualifiedName() { - return "reflection.EnumVal"; + return "reflection_EnumVal"; } static startEnumVal(builder) { builder.startObject(6); @@ -506,7 +506,7 @@ var Enum = class { return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null; } static getFullyQualifiedName() { - return "reflection.Enum"; + return "reflection_Enum"; } static startEnum(builder) { builder.startObject(7); @@ -763,7 +763,7 @@ var Field = class { return true; } static getFullyQualifiedName() { - return "reflection.Field"; + return "reflection_Field"; } static startField(builder) { builder.startObject(13); @@ -979,7 +979,7 @@ var Object_ = class { return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null; } static getFullyQualifiedName() { - return "reflection.Object"; + return "reflection_Object"; } static startObject(builder) { builder.startObject(8); @@ -1139,7 +1139,7 @@ var RPCCall = class { return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; } static getFullyQualifiedName() { - return "reflection.RPCCall"; + return "reflection_RPCCall"; } static startRPCCall(builder) { builder.startObject(5); @@ -1256,7 +1256,7 @@ var SchemaFile = class { return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; } static getFullyQualifiedName() { - return "reflection.SchemaFile"; + return "reflection_SchemaFile"; } static startSchemaFile(builder) { builder.startObject(2); @@ -1360,7 +1360,7 @@ var Service = class { return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null; } static getFullyQualifiedName() { - return "reflection.Service"; + return "reflection_Service"; } static startService(builder) { builder.startObject(5); @@ -1531,7 +1531,7 @@ var Schema = class { return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; } static getFullyQualifiedName() { - return "reflection.Schema"; + return "reflection_Schema"; } static startSchema(builder) { builder.startObject(8); diff --git a/tests/ts/table-a.d.ts b/tests/ts/table-a.d.ts new file mode 100644 index 00000000000..f6708354c3e --- /dev/null +++ b/tests/ts/table-a.d.ts @@ -0,0 +1,24 @@ +import * as flatbuffers from 'flatbuffers'; +import { TableB, TableBT } from './my-game/other-name-space/table-b.js'; +export declare class TableA implements flatbuffers.IUnpackableObject { + bb: flatbuffers.ByteBuffer | null; + bb_pos: number; + __init(i: number, bb: flatbuffers.ByteBuffer): TableA; + static getRootAsTableA(bb: flatbuffers.ByteBuffer, obj?: TableA): TableA; + static getSizePrefixedRootAsTableA(bb: flatbuffers.ByteBuffer, obj?: TableA): TableA; + b(obj?: TableB): TableB | null; + static getFullyQualifiedName(): string; + static startTableA(builder: flatbuffers.Builder): void; + static addB(builder: flatbuffers.Builder, bOffset: flatbuffers.Offset): void; + static endTableA(builder: flatbuffers.Builder): flatbuffers.Offset; + static createTableA(builder: flatbuffers.Builder, bOffset: flatbuffers.Offset): flatbuffers.Offset; + serialize(): Uint8Array; + static deserialize(buffer: Uint8Array): TableA; + unpack(): TableAT; + unpackTo(_o: TableAT): void; +} +export declare class TableAT implements flatbuffers.IGeneratedObject { + b: TableBT | null; + constructor(b?: TableBT | null); + pack(builder: flatbuffers.Builder): flatbuffers.Offset; +} diff --git a/tests/ts/tsconfig.json b/tests/ts/tsconfig.json index c8cf31958c4..d9ef7410c3a 100644 --- a/tests/ts/tsconfig.json +++ b/tests/ts/tsconfig.json @@ -3,6 +3,7 @@ "target": "ES2020", "lib": ["ES2020", "DOM"], "module": "NodeNext", + "declaration": true, "strict": true }, "include": [ diff --git a/tests/ts/typescript/class.d.ts b/tests/ts/typescript/class.d.ts new file mode 100644 index 00000000000..ff6c5422265 --- /dev/null +++ b/tests/ts/typescript/class.d.ts @@ -0,0 +1,4 @@ +export declare enum class_ { + new_ = 0, + instanceof_ = 1 +} diff --git a/tests/ts/typescript/object.d.ts b/tests/ts/typescript/object.d.ts new file mode 100644 index 00000000000..c8e8b75e8aa --- /dev/null +++ b/tests/ts/typescript/object.d.ts @@ -0,0 +1,48 @@ +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 declare class Object_ implements flatbuffers.IUnpackableObject { + bb: flatbuffers.ByteBuffer | null; + bb_pos: number; + __init(i: number, bb: flatbuffers.ByteBuffer): Object_; + static getRootAsObject(bb: flatbuffers.ByteBuffer, obj?: Object_): Object_; + static getSizePrefixedRootAsObject(bb: flatbuffers.ByteBuffer, obj?: Object_): Object_; + return_(): number; + mutate_return(value: number): boolean; + if_(): number; + mutate_if(value: number): boolean; + switch_(): number; + mutate_switch(value: number): boolean; + enum_(): class_; + mutate_enum(value: class_): boolean; + enum2(): foobar_class_; + mutate_enum2(value: foobar_class_): boolean; + enum3(): Abc; + mutate_enum3(value: Abc): boolean; + reflect(obj?: Schema): Schema | null; + static getFullyQualifiedName(): string; + static startObject(builder: flatbuffers.Builder): void; + static addReturn(builder: flatbuffers.Builder, return_: number): void; + static addIf(builder: flatbuffers.Builder, if_: number): void; + static addSwitch(builder: flatbuffers.Builder, switch_: number): void; + static addEnum(builder: flatbuffers.Builder, enum_: class_): void; + static addEnum2(builder: flatbuffers.Builder, enum2: foobar_class_): void; + static addEnum3(builder: flatbuffers.Builder, enum3: Abc): void; + static addReflect(builder: flatbuffers.Builder, reflectOffset: flatbuffers.Offset): void; + static endObject(builder: flatbuffers.Builder): flatbuffers.Offset; + unpack(): Object_T; + unpackTo(_o: Object_T): void; +} +export declare class Object_T implements flatbuffers.IGeneratedObject { + return_: number; + if_: number; + switch_: number; + enum_: class_; + enum2: foobar_class_; + enum3: Abc; + reflect: SchemaT | null; + constructor(return_?: number, if_?: number, switch_?: number, enum_?: class_, enum2?: foobar_class_, enum3?: Abc, reflect?: SchemaT | null); + pack(builder: flatbuffers.Builder): flatbuffers.Offset; +} diff --git a/tests/ts/typescript_keywords_generated.cjs b/tests/ts/typescript_keywords_generated.cjs index 5318a35c38e..74e00dccb31 100644 --- a/tests/ts/typescript_keywords_generated.cjs +++ b/tests/ts/typescript_keywords_generated.cjs @@ -83,7 +83,7 @@ var KeyValue = class { return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null; } static getFullyQualifiedName() { - return "reflection.KeyValue"; + return "reflection_KeyValue"; } static startKeyValue(builder) { builder.startObject(2); @@ -243,7 +243,7 @@ var Type = class { return true; } static getFullyQualifiedName() { - return "reflection.Type"; + return "reflection_Type"; } static startType(builder) { builder.startObject(6); @@ -361,7 +361,7 @@ var EnumVal = class { return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; } static getFullyQualifiedName() { - return "reflection.EnumVal"; + return "reflection_EnumVal"; } static startEnumVal(builder) { builder.startObject(6); @@ -507,7 +507,7 @@ var Enum = class { return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null; } static getFullyQualifiedName() { - return "reflection.Enum"; + return "reflection_Enum"; } static startEnum(builder) { builder.startObject(7); @@ -767,7 +767,7 @@ var Field = class { return true; } static getFullyQualifiedName() { - return "reflection.Field"; + return "reflection_Field"; } static startField(builder) { builder.startObject(13); @@ -982,7 +982,7 @@ var Object_ = class { return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null; } static getFullyQualifiedName() { - return "reflection.Object"; + return "reflection_Object"; } static startObject(builder) { builder.startObject(8); @@ -1126,7 +1126,7 @@ var SchemaFile = class { return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; } static getFullyQualifiedName() { - return "reflection.SchemaFile"; + return "reflection_SchemaFile"; } static startSchemaFile(builder) { builder.startObject(2); @@ -1229,7 +1229,7 @@ var RPCCall = class { return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; } static getFullyQualifiedName() { - return "reflection.RPCCall"; + return "reflection_RPCCall"; } static startRPCCall(builder) { builder.startObject(5); @@ -1362,7 +1362,7 @@ var Service = class { return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null; } static getFullyQualifiedName() { - return "reflection.Service"; + return "reflection_Service"; } static startService(builder) { builder.startObject(5); @@ -1533,7 +1533,7 @@ var Schema = class { return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; } static getFullyQualifiedName() { - return "reflection.Schema"; + return "reflection_Schema"; } static startSchema(builder) { builder.startObject(8); @@ -1762,7 +1762,7 @@ var Object_2 = class { return offset ? (obj || new Schema()).__init(this.bb.__indirect(this.bb_pos + offset), this.bb) : null; } static getFullyQualifiedName() { - return "typescript.Object"; + return "typescript_Object"; } static startObject(builder) { builder.startObject(7); diff --git a/tests/ts/union_vector/attacker.d.ts b/tests/ts/union_vector/attacker.d.ts new file mode 100644 index 00000000000..302e1d0e950 --- /dev/null +++ b/tests/ts/union_vector/attacker.d.ts @@ -0,0 +1,22 @@ +import * as flatbuffers from 'flatbuffers'; +export declare class Attacker implements flatbuffers.IUnpackableObject { + bb: flatbuffers.ByteBuffer | null; + bb_pos: number; + __init(i: number, bb: flatbuffers.ByteBuffer): Attacker; + static getRootAsAttacker(bb: flatbuffers.ByteBuffer, obj?: Attacker): Attacker; + static getSizePrefixedRootAsAttacker(bb: flatbuffers.ByteBuffer, obj?: Attacker): Attacker; + swordAttackDamage(): number; + mutate_sword_attack_damage(value: number): boolean; + static getFullyQualifiedName(): string; + static startAttacker(builder: flatbuffers.Builder): void; + static addSwordAttackDamage(builder: flatbuffers.Builder, swordAttackDamage: number): void; + static endAttacker(builder: flatbuffers.Builder): flatbuffers.Offset; + static createAttacker(builder: flatbuffers.Builder, swordAttackDamage: number): flatbuffers.Offset; + unpack(): AttackerT; + unpackTo(_o: AttackerT): void; +} +export declare class AttackerT implements flatbuffers.IGeneratedObject { + swordAttackDamage: number; + constructor(swordAttackDamage?: number); + pack(builder: flatbuffers.Builder): flatbuffers.Offset; +} diff --git a/tests/ts/union_vector/book-reader.d.ts b/tests/ts/union_vector/book-reader.d.ts new file mode 100644 index 00000000000..42b7198fef1 --- /dev/null +++ b/tests/ts/union_vector/book-reader.d.ts @@ -0,0 +1,18 @@ +import * as flatbuffers from 'flatbuffers'; +export declare class BookReader implements flatbuffers.IUnpackableObject { + bb: flatbuffers.ByteBuffer | null; + bb_pos: number; + __init(i: number, bb: flatbuffers.ByteBuffer): BookReader; + booksRead(): number; + mutate_books_read(value: number): boolean; + static getFullyQualifiedName(): string; + static sizeOf(): number; + static createBookReader(builder: flatbuffers.Builder, books_read: number): flatbuffers.Offset; + unpack(): BookReaderT; + unpackTo(_o: BookReaderT): void; +} +export declare class BookReaderT implements flatbuffers.IGeneratedObject { + booksRead: number; + constructor(booksRead?: number); + pack(builder: flatbuffers.Builder): flatbuffers.Offset; +} diff --git a/tests/ts/union_vector/character.d.ts b/tests/ts/union_vector/character.d.ts new file mode 100644 index 00000000000..dbdb4d960c9 --- /dev/null +++ b/tests/ts/union_vector/character.d.ts @@ -0,0 +1,14 @@ +import { Attacker } from './attacker.js'; +import { BookReader } from './book-reader.js'; +import { Rapunzel } from './rapunzel.js'; +export declare enum Character { + NONE = 0, + MuLan = 1, + Rapunzel = 2, + Belle = 3, + BookFan = 4, + Other = 5, + Unused = 6 +} +export declare function unionToCharacter(type: Character, accessor: (obj: Attacker | BookReader | Rapunzel | string) => Attacker | BookReader | Rapunzel | string | null): Attacker | BookReader | Rapunzel | string | null; +export declare function unionListToCharacter(type: Character, accessor: (index: number, obj: Attacker | BookReader | Rapunzel | string) => Attacker | BookReader | Rapunzel | string | null, index: number): Attacker | BookReader | Rapunzel | string | null; diff --git a/tests/ts/union_vector/falling-tub.d.ts b/tests/ts/union_vector/falling-tub.d.ts new file mode 100644 index 00000000000..3cde3fc7149 --- /dev/null +++ b/tests/ts/union_vector/falling-tub.d.ts @@ -0,0 +1,18 @@ +import * as flatbuffers from 'flatbuffers'; +export declare class FallingTub implements flatbuffers.IUnpackableObject { + bb: flatbuffers.ByteBuffer | null; + bb_pos: number; + __init(i: number, bb: flatbuffers.ByteBuffer): FallingTub; + weight(): number; + mutate_weight(value: number): boolean; + static getFullyQualifiedName(): string; + static sizeOf(): number; + static createFallingTub(builder: flatbuffers.Builder, weight: number): flatbuffers.Offset; + unpack(): FallingTubT; + unpackTo(_o: FallingTubT): void; +} +export declare class FallingTubT implements flatbuffers.IGeneratedObject { + weight: number; + constructor(weight?: number); + pack(builder: flatbuffers.Builder): flatbuffers.Offset; +} diff --git a/tests/ts/union_vector/gadget.d.ts b/tests/ts/union_vector/gadget.d.ts new file mode 100644 index 00000000000..46eaa5e7c6c --- /dev/null +++ b/tests/ts/union_vector/gadget.d.ts @@ -0,0 +1,9 @@ +import { FallingTub } from './falling-tub.js'; +import { HandFan } from './hand-fan.js'; +export declare enum Gadget { + NONE = 0, + FallingTub = 1, + HandFan = 2 +} +export declare function unionToGadget(type: Gadget, accessor: (obj: FallingTub | HandFan) => FallingTub | HandFan | null): FallingTub | HandFan | null; +export declare function unionListToGadget(type: Gadget, accessor: (index: number, obj: FallingTub | HandFan) => FallingTub | HandFan | null, index: number): FallingTub | HandFan | null; diff --git a/tests/ts/union_vector/hand-fan.d.ts b/tests/ts/union_vector/hand-fan.d.ts new file mode 100644 index 00000000000..a1981dfdfd5 --- /dev/null +++ b/tests/ts/union_vector/hand-fan.d.ts @@ -0,0 +1,22 @@ +import * as flatbuffers from 'flatbuffers'; +export declare class HandFan implements flatbuffers.IUnpackableObject { + bb: flatbuffers.ByteBuffer | null; + bb_pos: number; + __init(i: number, bb: flatbuffers.ByteBuffer): HandFan; + static getRootAsHandFan(bb: flatbuffers.ByteBuffer, obj?: HandFan): HandFan; + static getSizePrefixedRootAsHandFan(bb: flatbuffers.ByteBuffer, obj?: HandFan): HandFan; + length(): number; + mutate_length(value: number): boolean; + static getFullyQualifiedName(): string; + static startHandFan(builder: flatbuffers.Builder): void; + static addLength(builder: flatbuffers.Builder, length: number): void; + static endHandFan(builder: flatbuffers.Builder): flatbuffers.Offset; + static createHandFan(builder: flatbuffers.Builder, length: number): flatbuffers.Offset; + unpack(): HandFanT; + unpackTo(_o: HandFanT): void; +} +export declare class HandFanT implements flatbuffers.IGeneratedObject { + length: number; + constructor(length?: number); + pack(builder: flatbuffers.Builder): flatbuffers.Offset; +} diff --git a/tests/ts/union_vector/movie.d.ts b/tests/ts/union_vector/movie.d.ts new file mode 100644 index 00000000000..68c9e1671d8 --- /dev/null +++ b/tests/ts/union_vector/movie.d.ts @@ -0,0 +1,44 @@ +import * as flatbuffers from 'flatbuffers'; +import { AttackerT } from './attacker.js'; +import { BookReaderT } from './book-reader.js'; +import { Character } from './character.js'; +import { RapunzelT } from './rapunzel.js'; +export declare class Movie implements flatbuffers.IUnpackableObject { + bb: flatbuffers.ByteBuffer | null; + bb_pos: number; + __init(i: number, bb: flatbuffers.ByteBuffer): Movie; + static getRootAsMovie(bb: flatbuffers.ByteBuffer, obj?: Movie): Movie; + static getSizePrefixedRootAsMovie(bb: flatbuffers.ByteBuffer, obj?: Movie): Movie; + static bufferHasIdentifier(bb: flatbuffers.ByteBuffer): boolean; + mainCharacterType(): Character; + mainCharacter(obj: any | string): any | string | null; + charactersType(index: number): Character | null; + charactersTypeLength(): number; + charactersTypeArray(): Uint8Array | null; + characters(index: number, obj: any | string): any | string | null; + charactersLength(): number; + static getFullyQualifiedName(): string; + static startMovie(builder: flatbuffers.Builder): void; + static addMainCharacterType(builder: flatbuffers.Builder, mainCharacterType: Character): void; + static addMainCharacter(builder: flatbuffers.Builder, mainCharacterOffset: flatbuffers.Offset): void; + static addCharactersType(builder: flatbuffers.Builder, charactersTypeOffset: flatbuffers.Offset): void; + static createCharactersTypeVector(builder: flatbuffers.Builder, data: Character[]): flatbuffers.Offset; + static startCharactersTypeVector(builder: flatbuffers.Builder, numElems: number): void; + static addCharacters(builder: flatbuffers.Builder, charactersOffset: flatbuffers.Offset): void; + static createCharactersVector(builder: flatbuffers.Builder, data: flatbuffers.Offset[]): flatbuffers.Offset; + static startCharactersVector(builder: flatbuffers.Builder, numElems: number): void; + static endMovie(builder: flatbuffers.Builder): flatbuffers.Offset; + static finishMovieBuffer(builder: flatbuffers.Builder, offset: flatbuffers.Offset): void; + static finishSizePrefixedMovieBuffer(builder: flatbuffers.Builder, offset: flatbuffers.Offset): void; + static createMovie(builder: flatbuffers.Builder, mainCharacterType: Character, mainCharacterOffset: flatbuffers.Offset, charactersTypeOffset: flatbuffers.Offset, charactersOffset: flatbuffers.Offset): flatbuffers.Offset; + unpack(): MovieT; + unpackTo(_o: MovieT): void; +} +export declare class MovieT implements flatbuffers.IGeneratedObject { + mainCharacterType: Character; + mainCharacter: AttackerT | BookReaderT | RapunzelT | string | null; + charactersType: (Character)[]; + characters: (AttackerT | BookReaderT | RapunzelT | string)[]; + constructor(mainCharacterType?: Character, mainCharacter?: AttackerT | BookReaderT | RapunzelT | string | null, charactersType?: (Character)[], characters?: (AttackerT | BookReaderT | RapunzelT | string)[]); + pack(builder: flatbuffers.Builder): flatbuffers.Offset; +} diff --git a/tests/ts/union_vector/rapunzel.d.ts b/tests/ts/union_vector/rapunzel.d.ts new file mode 100644 index 00000000000..c28f1b87d0d --- /dev/null +++ b/tests/ts/union_vector/rapunzel.d.ts @@ -0,0 +1,18 @@ +import * as flatbuffers from 'flatbuffers'; +export declare class Rapunzel implements flatbuffers.IUnpackableObject { + bb: flatbuffers.ByteBuffer | null; + bb_pos: number; + __init(i: number, bb: flatbuffers.ByteBuffer): Rapunzel; + hairLength(): number; + mutate_hair_length(value: number): boolean; + static getFullyQualifiedName(): string; + static sizeOf(): number; + static createRapunzel(builder: flatbuffers.Builder, hair_length: number): flatbuffers.Offset; + unpack(): RapunzelT; + unpackTo(_o: RapunzelT): void; +} +export declare class RapunzelT implements flatbuffers.IGeneratedObject { + hairLength: number; + constructor(hairLength?: number); + pack(builder: flatbuffers.Builder): flatbuffers.Offset; +} diff --git a/tests/ts/union_vector/union_vector.d.ts b/tests/ts/union_vector/union_vector.d.ts new file mode 100644 index 00000000000..3e2be4f470b --- /dev/null +++ b/tests/ts/union_vector/union_vector.d.ts @@ -0,0 +1,8 @@ +export { Attacker } from './attacker.js'; +export { BookReader } from './book-reader.js'; +export { Character } from './character.js'; +export { FallingTub } from './falling-tub.js'; +export { Gadget } from './gadget.js'; +export { HandFan } from './hand-fan.js'; +export { Movie } from './movie.js'; +export { Rapunzel } from './rapunzel.js'; From 74e136eb35c1abb722213256aa7e4fca752012c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Harrtell?= Date: Wed, 11 Jan 2023 23:24:36 +0100 Subject: [PATCH 32/39] Handle "empty" root namespace --- src/idl_gen_ts.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/idl_gen_ts.cpp b/src/idl_gen_ts.cpp index 1ebb173f168..105e9e38904 100644 --- a/src/idl_gen_ts.cpp +++ b/src/idl_gen_ts.cpp @@ -237,6 +237,17 @@ class TsGenerator : public BaseGenerator { void generateEntry() { std::string code; + // add root namespace def if not already existing from defs tracking + std::string root; + if (ns_defs_.count(root) == 0) { + NsDefinition nsDef; + nsDef.path = root; + nsDef.symbolic_name = file_name_; + nsDef.filepath = path_ + file_name_ + ".ts"; + nsDef.ns = new Namespace(); + ns_defs_[nsDef.path] = nsDef; + } + for (const auto &it : ns_defs_) { code = "// " + std::string(FlatBuffersGeneratedWarning()) + "\n\n"; From 7ac6be5f96dabe702c7c851170cf60a0a3e91cbf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Harrtell?= Date: Wed, 11 Jan 2023 23:27:59 +0100 Subject: [PATCH 33/39] Adjust tests for typescript_keywords.ts --- tests/ts/TypeScriptTest.py | 5 +- .../arrays_test_complex_generated.cjs | 10 +- .../my-game/example/array-struct.js | 2 +- .../my-game/example/array-struct.ts | 2 +- .../my-game/example/array-table.js | 2 +- .../my-game/example/array-table.ts | 2 +- .../my-game/example/inner-struct.js | 2 +- .../my-game/example/inner-struct.ts | 2 +- .../my-game/example/nested-struct.js | 2 +- .../my-game/example/nested-struct.ts | 2 +- .../my-game/example/outer-struct.js | 2 +- .../my-game/example/outer-struct.ts | 2 +- tests/ts/foobar.d.ts | 1 + tests/ts/foobar.js | 2 + tests/ts/monster_test_generated.cjs | 28 +- tests/ts/my-game/example/ability.js | 2 +- tests/ts/my-game/example/ability.ts | 2 +- tests/ts/my-game/example/monster.js | 2 +- tests/ts/my-game/example/monster.ts | 2 +- tests/ts/my-game/example/referrable.js | 2 +- tests/ts/my-game/example/referrable.ts | 2 +- tests/ts/my-game/example/stat.js | 2 +- tests/ts/my-game/example/stat.ts | 2 +- .../example/struct-of-structs-of-structs.js | 2 +- .../example/struct-of-structs-of-structs.ts | 2 +- tests/ts/my-game/example/struct-of-structs.js | 2 +- tests/ts/my-game/example/struct-of-structs.ts | 2 +- .../example/test-simple-table-with-enum.js | 2 +- .../example/test-simple-table-with-enum.ts | 2 +- tests/ts/my-game/example/test.js | 2 +- tests/ts/my-game/example/test.ts | 2 +- tests/ts/my-game/example/type-aliases.js | 2 +- tests/ts/my-game/example/type-aliases.ts | 2 +- tests/ts/my-game/example/vec3.js | 2 +- tests/ts/my-game/example/vec3.ts | 2 +- tests/ts/my-game/example2/monster.js | 2 +- tests/ts/my-game/example2/monster.ts | 2 +- tests/ts/my-game/in-parent-namespace.js | 2 +- tests/ts/my-game/in-parent-namespace.ts | 2 +- tests/ts/my-game/other-name-space/table-b.js | 2 +- tests/ts/my-game/other-name-space/table-b.ts | 2 +- tests/ts/my-game/other-name-space/unused.js | 2 +- tests/ts/my-game/other-name-space/unused.ts | 2 +- tests/ts/optional-scalars/scalar-stuff.ts | 2 +- tests/ts/optional_scalars.ts | 3 + tests/ts/reflection.d.ts | 12 + tests/ts/reflection.js | 13 + tests/ts/reflection/advanced-features.d.ts | 9 + tests/ts/reflection/advanced-features.js | 11 + tests/ts/reflection/enum-val.js | 2 +- tests/ts/reflection/enum-val.ts | 2 +- tests/ts/reflection/enum.js | 2 +- tests/ts/reflection/enum.ts | 2 +- tests/ts/reflection/field.js | 2 +- tests/ts/reflection/field.ts | 2 +- tests/ts/reflection/key-value.js | 2 +- tests/ts/reflection/key-value.ts | 2 +- tests/ts/reflection/object.js | 2 +- tests/ts/reflection/object.ts | 2 +- tests/ts/reflection/rpccall.js | 2 +- tests/ts/reflection/rpccall.ts | 2 +- tests/ts/reflection/schema-file.js | 2 +- tests/ts/reflection/schema-file.ts | 2 +- tests/ts/reflection/schema.js | 2 +- tests/ts/reflection/schema.ts | 2 +- tests/ts/reflection/service.js | 2 +- tests/ts/reflection/service.ts | 2 +- tests/ts/reflection/type.js | 2 +- tests/ts/reflection/type.ts | 2 +- tests/ts/typescript.d.ts | 2 + tests/ts/typescript.js | 3 + tests/ts/typescript/object.js | 2 +- tests/ts/typescript/object.ts | 2 +- tests/ts/typescript_include.ts | 3 + tests/ts/typescript_keywords.d.ts | 3 + tests/ts/typescript_keywords.js | 4 + tests/ts/typescript_keywords.ts | 5 + tests/ts/typescript_keywords_generated.cjs | 320 ++++++++++-------- tests/ts/typescript_transitive_include.ts | 3 + 79 files changed, 332 insertions(+), 227 deletions(-) create mode 100644 tests/ts/foobar.d.ts create mode 100644 tests/ts/foobar.js create mode 100644 tests/ts/optional_scalars.ts create mode 100644 tests/ts/reflection.d.ts create mode 100644 tests/ts/reflection.js create mode 100644 tests/ts/reflection/advanced-features.d.ts create mode 100644 tests/ts/reflection/advanced-features.js create mode 100644 tests/ts/typescript.d.ts create mode 100644 tests/ts/typescript.js create mode 100644 tests/ts/typescript_include.ts create mode 100644 tests/ts/typescript_keywords.d.ts create mode 100644 tests/ts/typescript_keywords.js create mode 100644 tests/ts/typescript_keywords.ts create mode 100644 tests/ts/typescript_transitive_include.ts diff --git a/tests/ts/TypeScriptTest.py b/tests/ts/TypeScriptTest.py index 69dc3c1e426..cafb05d7282 100755 --- a/tests/ts/TypeScriptTest.py +++ b/tests/ts/TypeScriptTest.py @@ -109,10 +109,7 @@ def esbuild(input, output): ], include="../../", ) -esbuild("typescript.ts", "typescript_keywords_generated.cjs") -esbuild("foobar.ts", "typescript_include_generated.cjs") -esbuild("foobar.ts", "typescript_transitive_include_generated.cjs") -esbuild("reflection.ts", "reflection_generated.cjs") +esbuild("typescript_keywords.ts", "typescript_keywords_generated.cjs") print("Running TypeScript Compiler...") check_call(["tsc"]) diff --git a/tests/ts/arrays_test_complex/arrays_test_complex_generated.cjs b/tests/ts/arrays_test_complex/arrays_test_complex_generated.cjs index f23c9ea92ff..35f3db731b4 100644 --- a/tests/ts/arrays_test_complex/arrays_test_complex_generated.cjs +++ b/tests/ts/arrays_test_complex/arrays_test_complex_generated.cjs @@ -59,7 +59,7 @@ var InnerStruct = class { return this.bb.readInt64(this.bb_pos + 24); } static getFullyQualifiedName() { - return "MyGame_Example_InnerStruct"; + return "MyGame.Example.InnerStruct"; } static sizeOf() { return 32; @@ -127,7 +127,7 @@ var OuterStruct = class { return this.bb.readFloat64(this.bb_pos + 176 + index * 8); } static getFullyQualifiedName() { - return "MyGame_Example_OuterStruct"; + return "MyGame.Example.OuterStruct"; } static sizeOf() { return 208; @@ -227,7 +227,7 @@ var NestedStruct = class { return this.bb.readInt64(this.bb_pos + 1056 + index * 8); } static getFullyQualifiedName() { - return "MyGame_Example_NestedStruct"; + return "MyGame.Example.NestedStruct"; } static sizeOf() { return 1072; @@ -312,7 +312,7 @@ var ArrayStruct = class { return this.bb.readInt64(this.bb_pos + 2640 + index * 8); } static getFullyQualifiedName() { - return "MyGame_Example_ArrayStruct"; + return "MyGame.Example.ArrayStruct"; } static sizeOf() { return 2656; @@ -407,7 +407,7 @@ var ArrayTable = class { return offset ? (obj || new ArrayStruct()).__init(this.bb_pos + offset, this.bb) : null; } static getFullyQualifiedName() { - return "MyGame_Example_ArrayTable"; + return "MyGame.Example.ArrayTable"; } static startArrayTable(builder) { builder.startObject(2); diff --git a/tests/ts/arrays_test_complex/my-game/example/array-struct.js b/tests/ts/arrays_test_complex/my-game/example/array-struct.js index e445b3ca675..9350571d52d 100644 --- a/tests/ts/arrays_test_complex/my-game/example/array-struct.js +++ b/tests/ts/arrays_test_complex/my-game/example/array-struct.js @@ -33,7 +33,7 @@ export class ArrayStruct { return this.bb.readInt64(this.bb_pos + 2640 + index * 8); } static getFullyQualifiedName() { - return 'MyGame_Example_ArrayStruct'; + return 'MyGame.Example.ArrayStruct'; } static sizeOf() { return 2656; diff --git a/tests/ts/arrays_test_complex/my-game/example/array-struct.ts b/tests/ts/arrays_test_complex/my-game/example/array-struct.ts index 7b614877c3a..eb81e05d475 100644 --- a/tests/ts/arrays_test_complex/my-game/example/array-struct.ts +++ b/tests/ts/arrays_test_complex/my-game/example/array-struct.ts @@ -44,7 +44,7 @@ g(index: number):bigint|null { } static getFullyQualifiedName():string { - return 'MyGame_Example_ArrayStruct'; + return 'MyGame.Example.ArrayStruct'; } static sizeOf():number { diff --git a/tests/ts/arrays_test_complex/my-game/example/array-table.js b/tests/ts/arrays_test_complex/my-game/example/array-table.js index 08819e7fc30..b171023b1f3 100644 --- a/tests/ts/arrays_test_complex/my-game/example/array-table.js +++ b/tests/ts/arrays_test_complex/my-game/example/array-table.js @@ -30,7 +30,7 @@ export class ArrayTable { return offset ? (obj || new ArrayStruct()).__init(this.bb_pos + offset, this.bb) : null; } static getFullyQualifiedName() { - return 'MyGame_Example_ArrayTable'; + return 'MyGame.Example.ArrayTable'; } static startArrayTable(builder) { builder.startObject(2); diff --git a/tests/ts/arrays_test_complex/my-game/example/array-table.ts b/tests/ts/arrays_test_complex/my-game/example/array-table.ts index 7711c257ecf..b744aa3e177 100644 --- a/tests/ts/arrays_test_complex/my-game/example/array-table.ts +++ b/tests/ts/arrays_test_complex/my-game/example/array-table.ts @@ -40,7 +40,7 @@ cUnderscore(obj?:ArrayStruct):ArrayStruct|null { } static getFullyQualifiedName():string { - return 'MyGame_Example_ArrayTable'; + return 'MyGame.Example.ArrayTable'; } static startArrayTable(builder:flatbuffers.Builder) { diff --git a/tests/ts/arrays_test_complex/my-game/example/inner-struct.js b/tests/ts/arrays_test_complex/my-game/example/inner-struct.js index aecdff2cd44..e8ed9736221 100644 --- a/tests/ts/arrays_test_complex/my-game/example/inner-struct.js +++ b/tests/ts/arrays_test_complex/my-game/example/inner-struct.js @@ -22,7 +22,7 @@ export class InnerStruct { return this.bb.readInt64(this.bb_pos + 24); } static getFullyQualifiedName() { - return 'MyGame_Example_InnerStruct'; + return 'MyGame.Example.InnerStruct'; } static sizeOf() { return 32; diff --git a/tests/ts/arrays_test_complex/my-game/example/inner-struct.ts b/tests/ts/arrays_test_complex/my-game/example/inner-struct.ts index 0f97eedab1e..4ebaafba2a1 100644 --- a/tests/ts/arrays_test_complex/my-game/example/inner-struct.ts +++ b/tests/ts/arrays_test_complex/my-game/example/inner-struct.ts @@ -30,7 +30,7 @@ dUnderscore():bigint { } static getFullyQualifiedName():string { - return 'MyGame_Example_InnerStruct'; + return 'MyGame.Example.InnerStruct'; } static sizeOf():number { diff --git a/tests/ts/arrays_test_complex/my-game/example/nested-struct.js b/tests/ts/arrays_test_complex/my-game/example/nested-struct.js index 99413b41654..067061769a7 100644 --- a/tests/ts/arrays_test_complex/my-game/example/nested-struct.js +++ b/tests/ts/arrays_test_complex/my-game/example/nested-struct.js @@ -27,7 +27,7 @@ export class NestedStruct { return this.bb.readInt64(this.bb_pos + 1056 + index * 8); } static getFullyQualifiedName() { - return 'MyGame_Example_NestedStruct'; + return 'MyGame.Example.NestedStruct'; } static sizeOf() { return 1072; diff --git a/tests/ts/arrays_test_complex/my-game/example/nested-struct.ts b/tests/ts/arrays_test_complex/my-game/example/nested-struct.ts index b01a99c6410..39e62600de7 100644 --- a/tests/ts/arrays_test_complex/my-game/example/nested-struct.ts +++ b/tests/ts/arrays_test_complex/my-game/example/nested-struct.ts @@ -36,7 +36,7 @@ e(index: number):bigint|null { } static getFullyQualifiedName():string { - return 'MyGame_Example_NestedStruct'; + return 'MyGame.Example.NestedStruct'; } static sizeOf():number { diff --git a/tests/ts/arrays_test_complex/my-game/example/outer-struct.js b/tests/ts/arrays_test_complex/my-game/example/outer-struct.js index f940d8c0570..fab2c9633ab 100644 --- a/tests/ts/arrays_test_complex/my-game/example/outer-struct.js +++ b/tests/ts/arrays_test_complex/my-game/example/outer-struct.js @@ -29,7 +29,7 @@ export class OuterStruct { return this.bb.readFloat64(this.bb_pos + 176 + index * 8); } static getFullyQualifiedName() { - return 'MyGame_Example_OuterStruct'; + return 'MyGame.Example.OuterStruct'; } static sizeOf() { return 208; diff --git a/tests/ts/arrays_test_complex/my-game/example/outer-struct.ts b/tests/ts/arrays_test_complex/my-game/example/outer-struct.ts index bb7d7644fc5..50fb64b63a5 100644 --- a/tests/ts/arrays_test_complex/my-game/example/outer-struct.ts +++ b/tests/ts/arrays_test_complex/my-game/example/outer-struct.ts @@ -39,7 +39,7 @@ f(index: number):number|null { } static getFullyQualifiedName():string { - return 'MyGame_Example_OuterStruct'; + return 'MyGame.Example.OuterStruct'; } static sizeOf():number { diff --git a/tests/ts/foobar.d.ts b/tests/ts/foobar.d.ts new file mode 100644 index 00000000000..c920a8c3c11 --- /dev/null +++ b/tests/ts/foobar.d.ts @@ -0,0 +1 @@ +export { Abc } from './foobar/abc.js'; diff --git a/tests/ts/foobar.js b/tests/ts/foobar.js new file mode 100644 index 00000000000..6a84acc5e14 --- /dev/null +++ b/tests/ts/foobar.js @@ -0,0 +1,2 @@ +// automatically generated by the FlatBuffers compiler, do not modify +export { Abc } from './foobar/abc.js'; diff --git a/tests/ts/monster_test_generated.cjs b/tests/ts/monster_test_generated.cjs index 6c590b4f71f..eafb6a4ae9b 100644 --- a/tests/ts/monster_test_generated.cjs +++ b/tests/ts/monster_test_generated.cjs @@ -58,7 +58,7 @@ var TableB = class { return offset ? (obj || new TableA()).__init(this.bb.__indirect(this.bb_pos + offset), this.bb) : null; } static getFullyQualifiedName() { - return "MyGame_OtherNameSpace_TableB"; + return "MyGame.OtherNameSpace.TableB"; } static startTableB(builder) { builder.startObject(1); @@ -190,7 +190,7 @@ var InParentNamespace = class { return (obj || new InParentNamespace()).__init(bb.readInt32(bb.position()) + bb.position(), bb); } static getFullyQualifiedName() { - return "MyGame_InParentNamespace"; + return "MyGame.InParentNamespace"; } static startInParentNamespace(builder) { builder.startObject(0); @@ -270,7 +270,7 @@ var Ability = class { return true; } static getFullyQualifiedName() { - return "MyGame_Example_Ability"; + return "MyGame.Example.Ability"; } static sizeOf() { return 8; @@ -319,7 +319,7 @@ var Monster = class { return (obj || new Monster()).__init(bb.readInt32(bb.position()) + bb.position(), bb); } static getFullyQualifiedName() { - return "MyGame_Example2_Monster"; + return "MyGame.Example2.Monster"; } static startMonster(builder) { builder.startObject(0); @@ -420,7 +420,7 @@ var TestSimpleTableWithEnum = class { return true; } static getFullyQualifiedName() { - return "MyGame_Example_TestSimpleTableWithEnum"; + return "MyGame.Example.TestSimpleTableWithEnum"; } static startTestSimpleTableWithEnum(builder) { builder.startObject(1); @@ -523,7 +523,7 @@ var Referrable = class { return true; } static getFullyQualifiedName() { - return "MyGame_Example_Referrable"; + return "MyGame.Example.Referrable"; } static startReferrable(builder) { builder.startObject(1); @@ -610,7 +610,7 @@ var Stat = class { return true; } static getFullyQualifiedName() { - return "MyGame_Example_Stat"; + return "MyGame.Example.Stat"; } static startStat(builder) { builder.startObject(3); @@ -688,7 +688,7 @@ var Test = class { return true; } static getFullyQualifiedName() { - return "MyGame_Example_Test"; + return "MyGame.Example.Test"; } static sizeOf() { return 4; @@ -768,7 +768,7 @@ var Vec3 = class { return (obj || new Test()).__init(this.bb_pos + 26, this.bb); } static getFullyQualifiedName() { - return "MyGame_Example_Vec3"; + return "MyGame.Example.Vec3"; } static sizeOf() { return 32; @@ -1421,7 +1421,7 @@ var Monster2 = class { return true; } static getFullyQualifiedName() { - return "MyGame_Example_Monster"; + return "MyGame.Example.Monster"; } static startMonster(builder) { builder.startObject(62); @@ -2118,7 +2118,7 @@ var StructOfStructs = class { return (obj || new Ability()).__init(this.bb_pos + 12, this.bb); } static getFullyQualifiedName() { - return "MyGame_Example_StructOfStructs"; + return "MyGame.Example.StructOfStructs"; } static sizeOf() { return 20; @@ -2172,7 +2172,7 @@ var StructOfStructsOfStructs = class { return (obj || new StructOfStructs()).__init(this.bb_pos, this.bb); } static getFullyQualifiedName() { - return "MyGame_Example_StructOfStructsOfStructs"; + return "MyGame.Example.StructOfStructsOfStructs"; } static sizeOf() { return 20; @@ -2372,7 +2372,7 @@ var TypeAliases = class { 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"; + return "MyGame.Example.TypeAliases"; } static startTypeAliases(builder) { builder.startObject(12); @@ -2538,7 +2538,7 @@ var Unused = class { return true; } static getFullyQualifiedName() { - return "MyGame_OtherNameSpace_Unused"; + return "MyGame.OtherNameSpace.Unused"; } static sizeOf() { return 4; diff --git a/tests/ts/my-game/example/ability.js b/tests/ts/my-game/example/ability.js index 4d7d3db7290..9fea3d6b4e5 100644 --- a/tests/ts/my-game/example/ability.js +++ b/tests/ts/my-game/example/ability.js @@ -24,7 +24,7 @@ export class Ability { return true; } static getFullyQualifiedName() { - return 'MyGame_Example_Ability'; + return 'MyGame.Example.Ability'; } static sizeOf() { return 8; diff --git a/tests/ts/my-game/example/ability.ts b/tests/ts/my-game/example/ability.ts index b0bea8fe847..86604ad11f6 100644 --- a/tests/ts/my-game/example/ability.ts +++ b/tests/ts/my-game/example/ability.ts @@ -32,7 +32,7 @@ mutate_distance(value:number):boolean { } static getFullyQualifiedName():string { - return 'MyGame_Example_Ability'; + return 'MyGame.Example.Ability'; } static sizeOf():number { diff --git a/tests/ts/my-game/example/monster.js b/tests/ts/my-game/example/monster.js index 7a97bc32bd6..6d71945dfe7 100644 --- a/tests/ts/my-game/example/monster.js +++ b/tests/ts/my-game/example/monster.js @@ -623,7 +623,7 @@ export class Monster { return true; } static getFullyQualifiedName() { - return 'MyGame_Example_Monster'; + return 'MyGame.Example.Monster'; } static startMonster(builder) { builder.startObject(62); diff --git a/tests/ts/my-game/example/monster.ts b/tests/ts/my-game/example/monster.ts index 7e205ee195b..78590c66863 100644 --- a/tests/ts/my-game/example/monster.ts +++ b/tests/ts/my-game/example/monster.ts @@ -812,7 +812,7 @@ mutate_double_inf_default(value:number):boolean { } static getFullyQualifiedName():string { - return 'MyGame_Example_Monster'; + return 'MyGame.Example.Monster'; } static startMonster(builder:flatbuffers.Builder) { diff --git a/tests/ts/my-game/example/referrable.js b/tests/ts/my-game/example/referrable.js index 367034b0644..0370768dd65 100644 --- a/tests/ts/my-game/example/referrable.js +++ b/tests/ts/my-game/example/referrable.js @@ -30,7 +30,7 @@ export class Referrable { return true; } static getFullyQualifiedName() { - return 'MyGame_Example_Referrable'; + return 'MyGame.Example.Referrable'; } static startReferrable(builder) { builder.startObject(1); diff --git a/tests/ts/my-game/example/referrable.ts b/tests/ts/my-game/example/referrable.ts index 52603629aa9..8e199bb62a6 100644 --- a/tests/ts/my-game/example/referrable.ts +++ b/tests/ts/my-game/example/referrable.ts @@ -39,7 +39,7 @@ mutate_id(value:bigint):boolean { } static getFullyQualifiedName():string { - return 'MyGame_Example_Referrable'; + return 'MyGame.Example.Referrable'; } static startReferrable(builder:flatbuffers.Builder) { diff --git a/tests/ts/my-game/example/stat.js b/tests/ts/my-game/example/stat.js index 43b569f4e36..46eec434414 100644 --- a/tests/ts/my-game/example/stat.js +++ b/tests/ts/my-game/example/stat.js @@ -46,7 +46,7 @@ export class Stat { return true; } static getFullyQualifiedName() { - return 'MyGame_Example_Stat'; + return 'MyGame.Example.Stat'; } static startStat(builder) { builder.startObject(3); diff --git a/tests/ts/my-game/example/stat.ts b/tests/ts/my-game/example/stat.ts index c1597b2a912..b5d87ff3e2a 100644 --- a/tests/ts/my-game/example/stat.ts +++ b/tests/ts/my-game/example/stat.ts @@ -62,7 +62,7 @@ mutate_count(value:number):boolean { } static getFullyQualifiedName():string { - return 'MyGame_Example_Stat'; + return 'MyGame.Example.Stat'; } static startStat(builder:flatbuffers.Builder) { 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 index 151be475130..0fc45ae160f 100644 --- a/tests/ts/my-game/example/struct-of-structs-of-structs.js +++ b/tests/ts/my-game/example/struct-of-structs-of-structs.js @@ -14,7 +14,7 @@ export class StructOfStructsOfStructs { return (obj || new StructOfStructs()).__init(this.bb_pos, this.bb); } static getFullyQualifiedName() { - return 'MyGame_Example_StructOfStructsOfStructs'; + return 'MyGame.Example.StructOfStructsOfStructs'; } static sizeOf() { return 20; 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 index fa17939b875..2464e56f996 100644 --- a/tests/ts/my-game/example/struct-of-structs-of-structs.ts +++ b/tests/ts/my-game/example/struct-of-structs-of-structs.ts @@ -19,7 +19,7 @@ a(obj?:StructOfStructs):StructOfStructs|null { } static getFullyQualifiedName():string { - return 'MyGame_Example_StructOfStructsOfStructs'; + return 'MyGame.Example.StructOfStructsOfStructs'; } static sizeOf():number { diff --git a/tests/ts/my-game/example/struct-of-structs.js b/tests/ts/my-game/example/struct-of-structs.js index f494c0f3c5d..1f41f85a8b0 100644 --- a/tests/ts/my-game/example/struct-of-structs.js +++ b/tests/ts/my-game/example/struct-of-structs.js @@ -21,7 +21,7 @@ export class StructOfStructs { return (obj || new Ability()).__init(this.bb_pos + 12, this.bb); } static getFullyQualifiedName() { - return 'MyGame_Example_StructOfStructs'; + return 'MyGame.Example.StructOfStructs'; } static sizeOf() { return 20; diff --git a/tests/ts/my-game/example/struct-of-structs.ts b/tests/ts/my-game/example/struct-of-structs.ts index 10d3607f157..f1e3146fb67 100644 --- a/tests/ts/my-game/example/struct-of-structs.ts +++ b/tests/ts/my-game/example/struct-of-structs.ts @@ -28,7 +28,7 @@ c(obj?:Ability):Ability|null { } static getFullyQualifiedName():string { - return 'MyGame_Example_StructOfStructs'; + return 'MyGame.Example.StructOfStructs'; } static sizeOf():number { 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 index 3690feeb76c..821cca99266 100644 --- a/tests/ts/my-game/example/test-simple-table-with-enum.js +++ b/tests/ts/my-game/example/test-simple-table-with-enum.js @@ -31,7 +31,7 @@ export class TestSimpleTableWithEnum { return true; } static getFullyQualifiedName() { - return 'MyGame_Example_TestSimpleTableWithEnum'; + return 'MyGame.Example.TestSimpleTableWithEnum'; } static startTestSimpleTableWithEnum(builder) { builder.startObject(1); 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 index 903ab99cbfa..e28c80f01b3 100644 --- a/tests/ts/my-game/example/test-simple-table-with-enum.ts +++ b/tests/ts/my-game/example/test-simple-table-with-enum.ts @@ -40,7 +40,7 @@ mutate_color(value:Color):boolean { } static getFullyQualifiedName():string { - return 'MyGame_Example_TestSimpleTableWithEnum'; + return 'MyGame.Example.TestSimpleTableWithEnum'; } static startTestSimpleTableWithEnum(builder:flatbuffers.Builder) { diff --git a/tests/ts/my-game/example/test.js b/tests/ts/my-game/example/test.js index 9c43619e210..ba6ebfb7af6 100644 --- a/tests/ts/my-game/example/test.js +++ b/tests/ts/my-game/example/test.js @@ -24,7 +24,7 @@ export class Test { return true; } static getFullyQualifiedName() { - return 'MyGame_Example_Test'; + return 'MyGame.Example.Test'; } static sizeOf() { return 4; diff --git a/tests/ts/my-game/example/test.ts b/tests/ts/my-game/example/test.ts index 7484f2c1589..0bad68292df 100644 --- a/tests/ts/my-game/example/test.ts +++ b/tests/ts/my-game/example/test.ts @@ -32,7 +32,7 @@ mutate_b(value:number):boolean { } static getFullyQualifiedName():string { - return 'MyGame_Example_Test'; + return 'MyGame.Example.Test'; } static sizeOf():number { diff --git a/tests/ts/my-game/example/type-aliases.js b/tests/ts/my-game/example/type-aliases.js index a4b5f89e3f5..f26f226c8bf 100644 --- a/tests/ts/my-game/example/type-aliases.js +++ b/tests/ts/my-game/example/type-aliases.js @@ -162,7 +162,7 @@ export class TypeAliases { 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'; + return 'MyGame.Example.TypeAliases'; } static startTypeAliases(builder) { builder.startObject(12); diff --git a/tests/ts/my-game/example/type-aliases.ts b/tests/ts/my-game/example/type-aliases.ts index 93262d702f3..3c727356cb9 100644 --- a/tests/ts/my-game/example/type-aliases.ts +++ b/tests/ts/my-game/example/type-aliases.ts @@ -213,7 +213,7 @@ vf64Array():Float64Array|null { } static getFullyQualifiedName():string { - return 'MyGame_Example_TypeAliases'; + return 'MyGame.Example.TypeAliases'; } static startTypeAliases(builder:flatbuffers.Builder) { diff --git a/tests/ts/my-game/example/vec3.js b/tests/ts/my-game/example/vec3.js index edf93f1abff..655fa7e5ee1 100644 --- a/tests/ts/my-game/example/vec3.js +++ b/tests/ts/my-game/example/vec3.js @@ -49,7 +49,7 @@ export class Vec3 { return (obj || new Test()).__init(this.bb_pos + 26, this.bb); } static getFullyQualifiedName() { - return 'MyGame_Example_Vec3'; + return 'MyGame.Example.Vec3'; } static sizeOf() { return 32; diff --git a/tests/ts/my-game/example/vec3.ts b/tests/ts/my-game/example/vec3.ts index 84516e09ccd..ad6cafaa73b 100644 --- a/tests/ts/my-game/example/vec3.ts +++ b/tests/ts/my-game/example/vec3.ts @@ -65,7 +65,7 @@ test3(obj?:Test):Test|null { } static getFullyQualifiedName():string { - return 'MyGame_Example_Vec3'; + return 'MyGame.Example.Vec3'; } static sizeOf():number { diff --git a/tests/ts/my-game/example2/monster.js b/tests/ts/my-game/example2/monster.js index f50a2c85afd..17f02b11ecf 100644 --- a/tests/ts/my-game/example2/monster.js +++ b/tests/ts/my-game/example2/monster.js @@ -18,7 +18,7 @@ export class Monster { return (obj || new Monster()).__init(bb.readInt32(bb.position()) + bb.position(), bb); } static getFullyQualifiedName() { - return 'MyGame_Example2_Monster'; + return 'MyGame.Example2.Monster'; } static startMonster(builder) { builder.startObject(0); diff --git a/tests/ts/my-game/example2/monster.ts b/tests/ts/my-game/example2/monster.ts index 071448699b5..66c555dded3 100644 --- a/tests/ts/my-game/example2/monster.ts +++ b/tests/ts/my-game/example2/monster.ts @@ -23,7 +23,7 @@ static getSizePrefixedRootAsMonster(bb:flatbuffers.ByteBuffer, obj?:Monster):Mon } static getFullyQualifiedName():string { - return 'MyGame_Example2_Monster'; + return 'MyGame.Example2.Monster'; } static startMonster(builder:flatbuffers.Builder) { diff --git a/tests/ts/my-game/in-parent-namespace.js b/tests/ts/my-game/in-parent-namespace.js index 24b0ed78783..48817411bc8 100644 --- a/tests/ts/my-game/in-parent-namespace.js +++ b/tests/ts/my-game/in-parent-namespace.js @@ -18,7 +18,7 @@ export class InParentNamespace { return (obj || new InParentNamespace()).__init(bb.readInt32(bb.position()) + bb.position(), bb); } static getFullyQualifiedName() { - return 'MyGame_InParentNamespace'; + return 'MyGame.InParentNamespace'; } static startInParentNamespace(builder) { builder.startObject(0); diff --git a/tests/ts/my-game/in-parent-namespace.ts b/tests/ts/my-game/in-parent-namespace.ts index 0e2f4128760..4c0e4163def 100644 --- a/tests/ts/my-game/in-parent-namespace.ts +++ b/tests/ts/my-game/in-parent-namespace.ts @@ -23,7 +23,7 @@ static getSizePrefixedRootAsInParentNamespace(bb:flatbuffers.ByteBuffer, obj?:In } static getFullyQualifiedName():string { - return 'MyGame_InParentNamespace'; + return 'MyGame.InParentNamespace'; } static startInParentNamespace(builder:flatbuffers.Builder) { diff --git a/tests/ts/my-game/other-name-space/table-b.js b/tests/ts/my-game/other-name-space/table-b.js index 464ab3e24a4..5d951320284 100644 --- a/tests/ts/my-game/other-name-space/table-b.js +++ b/tests/ts/my-game/other-name-space/table-b.js @@ -23,7 +23,7 @@ export class TableB { return offset ? (obj || new TableA()).__init(this.bb.__indirect(this.bb_pos + offset), this.bb) : null; } static getFullyQualifiedName() { - return 'MyGame_OtherNameSpace_TableB'; + return 'MyGame.OtherNameSpace.TableB'; } static startTableB(builder) { builder.startObject(1); diff --git a/tests/ts/my-game/other-name-space/table-b.ts b/tests/ts/my-game/other-name-space/table-b.ts index af01cd25910..d18712b2611 100644 --- a/tests/ts/my-game/other-name-space/table-b.ts +++ b/tests/ts/my-game/other-name-space/table-b.ts @@ -29,7 +29,7 @@ a(obj?:TableA):TableA|null { } static getFullyQualifiedName():string { - return 'MyGame_OtherNameSpace_TableB'; + return 'MyGame.OtherNameSpace.TableB'; } static startTableB(builder:flatbuffers.Builder) { diff --git a/tests/ts/my-game/other-name-space/unused.js b/tests/ts/my-game/other-name-space/unused.js index 829454dbef4..0b42918d1ea 100644 --- a/tests/ts/my-game/other-name-space/unused.js +++ b/tests/ts/my-game/other-name-space/unused.js @@ -17,7 +17,7 @@ export class Unused { return true; } static getFullyQualifiedName() { - return 'MyGame_OtherNameSpace_Unused'; + return 'MyGame.OtherNameSpace.Unused'; } static sizeOf() { return 4; diff --git a/tests/ts/my-game/other-name-space/unused.ts b/tests/ts/my-game/other-name-space/unused.ts index 20802df7ee9..7f3dbd50893 100644 --- a/tests/ts/my-game/other-name-space/unused.ts +++ b/tests/ts/my-game/other-name-space/unused.ts @@ -23,7 +23,7 @@ mutate_a(value:number):boolean { } static getFullyQualifiedName():string { - return 'MyGame_OtherNameSpace_Unused'; + return 'MyGame.OtherNameSpace.Unused'; } static sizeOf():number { diff --git a/tests/ts/optional-scalars/scalar-stuff.ts b/tests/ts/optional-scalars/scalar-stuff.ts index 2adf31b3393..fe74b2cb473 100644 --- a/tests/ts/optional-scalars/scalar-stuff.ts +++ b/tests/ts/optional-scalars/scalar-stuff.ts @@ -208,7 +208,7 @@ defaultEnum():OptionalByte { } static getFullyQualifiedName():string { - return 'optional_scalars_ScalarStuff'; + return 'optional_scalars.ScalarStuff'; } static startScalarStuff(builder:flatbuffers.Builder) { diff --git a/tests/ts/optional_scalars.ts b/tests/ts/optional_scalars.ts new file mode 100644 index 00000000000..18ded6e4f79 --- /dev/null +++ b/tests/ts/optional_scalars.ts @@ -0,0 +1,3 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +export * as optional_scalars from './optional-scalars.js'; diff --git a/tests/ts/reflection.d.ts b/tests/ts/reflection.d.ts new file mode 100644 index 00000000000..f296e54f0b8 --- /dev/null +++ b/tests/ts/reflection.d.ts @@ -0,0 +1,12 @@ +export { AdvancedFeatures } from './reflection/advanced-features.js'; +export { BaseType } from './reflection/base-type.js'; +export { Enum } from './reflection/enum.js'; +export { EnumVal } from './reflection/enum-val.js'; +export { Field } from './reflection/field.js'; +export { KeyValue } from './reflection/key-value.js'; +export { Object_ } from './reflection/object.js'; +export { RPCCall } from './reflection/rpccall.js'; +export { Schema } from './reflection/schema.js'; +export { SchemaFile } from './reflection/schema-file.js'; +export { Service } from './reflection/service.js'; +export { Type } from './reflection/type.js'; diff --git a/tests/ts/reflection.js b/tests/ts/reflection.js new file mode 100644 index 00000000000..881519a2862 --- /dev/null +++ b/tests/ts/reflection.js @@ -0,0 +1,13 @@ +// automatically generated by the FlatBuffers compiler, do not modify +export { AdvancedFeatures } from './reflection/advanced-features.js'; +export { BaseType } from './reflection/base-type.js'; +export { Enum } from './reflection/enum.js'; +export { EnumVal } from './reflection/enum-val.js'; +export { Field } from './reflection/field.js'; +export { KeyValue } from './reflection/key-value.js'; +export { Object_ } from './reflection/object.js'; +export { RPCCall } from './reflection/rpccall.js'; +export { Schema } from './reflection/schema.js'; +export { SchemaFile } from './reflection/schema-file.js'; +export { Service } from './reflection/service.js'; +export { Type } from './reflection/type.js'; diff --git a/tests/ts/reflection/advanced-features.d.ts b/tests/ts/reflection/advanced-features.d.ts new file mode 100644 index 00000000000..a51745e45e8 --- /dev/null +++ b/tests/ts/reflection/advanced-features.d.ts @@ -0,0 +1,9 @@ +/** + * New schema language features that are not supported by old code generators. + */ +export declare enum AdvancedFeatures { + AdvancedArrayFeatures = "1", + AdvancedUnionFeatures = "2", + OptionalScalars = "4", + DefaultVectorsAndStrings = "8" +} diff --git a/tests/ts/reflection/advanced-features.js b/tests/ts/reflection/advanced-features.js new file mode 100644 index 00000000000..432bb44f528 --- /dev/null +++ b/tests/ts/reflection/advanced-features.js @@ -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 var AdvancedFeatures; +(function (AdvancedFeatures) { + AdvancedFeatures["AdvancedArrayFeatures"] = "1"; + AdvancedFeatures["AdvancedUnionFeatures"] = "2"; + AdvancedFeatures["OptionalScalars"] = "4"; + AdvancedFeatures["DefaultVectorsAndStrings"] = "8"; +})(AdvancedFeatures = AdvancedFeatures || (AdvancedFeatures = {})); diff --git a/tests/ts/reflection/enum-val.js b/tests/ts/reflection/enum-val.js index 93926a61ae7..b4d0769d543 100644 --- a/tests/ts/reflection/enum-val.js +++ b/tests/ts/reflection/enum-val.js @@ -56,7 +56,7 @@ export class EnumVal { return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; } static getFullyQualifiedName() { - return 'reflection_EnumVal'; + return 'reflection.EnumVal'; } static startEnumVal(builder) { builder.startObject(6); diff --git a/tests/ts/reflection/enum-val.ts b/tests/ts/reflection/enum-val.ts index 3119a206386..2576e7026c4 100644 --- a/tests/ts/reflection/enum-val.ts +++ b/tests/ts/reflection/enum-val.ts @@ -75,7 +75,7 @@ attributesLength():number { } static getFullyQualifiedName():string { - return 'reflection_EnumVal'; + return 'reflection.EnumVal'; } static startEnumVal(builder:flatbuffers.Builder) { diff --git a/tests/ts/reflection/enum.js b/tests/ts/reflection/enum.js index 49393072b39..a08a8cbfa66 100644 --- a/tests/ts/reflection/enum.js +++ b/tests/ts/reflection/enum.js @@ -69,7 +69,7 @@ export class Enum { return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null; } static getFullyQualifiedName() { - return 'reflection_Enum'; + return 'reflection.Enum'; } static startEnum(builder) { builder.startObject(7); diff --git a/tests/ts/reflection/enum.ts b/tests/ts/reflection/enum.ts index 34d137757ee..edf29f65bd9 100644 --- a/tests/ts/reflection/enum.ts +++ b/tests/ts/reflection/enum.ts @@ -96,7 +96,7 @@ declarationFile(optionalEncoding?:any):string|Uint8Array|null { } static getFullyQualifiedName():string { - return 'reflection_Enum'; + return 'reflection.Enum'; } static startEnum(builder:flatbuffers.Builder) { diff --git a/tests/ts/reflection/field.js b/tests/ts/reflection/field.js index 107b77bf0d5..5d7e2f88c46 100644 --- a/tests/ts/reflection/field.js +++ b/tests/ts/reflection/field.js @@ -155,7 +155,7 @@ export class Field { return true; } static getFullyQualifiedName() { - return 'reflection_Field'; + return 'reflection.Field'; } static startField(builder) { builder.startObject(13); diff --git a/tests/ts/reflection/field.ts b/tests/ts/reflection/field.ts index 9734fbab5ec..653611710e3 100644 --- a/tests/ts/reflection/field.ts +++ b/tests/ts/reflection/field.ts @@ -206,7 +206,7 @@ mutate_padding(value:number):boolean { } static getFullyQualifiedName():string { - return 'reflection_Field'; + return 'reflection.Field'; } static startField(builder:flatbuffers.Builder) { diff --git a/tests/ts/reflection/key-value.js b/tests/ts/reflection/key-value.js index 622b4f2a884..f8c6b856fb4 100644 --- a/tests/ts/reflection/key-value.js +++ b/tests/ts/reflection/key-value.js @@ -26,7 +26,7 @@ export class KeyValue { return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null; } static getFullyQualifiedName() { - return 'reflection_KeyValue'; + return 'reflection.KeyValue'; } static startKeyValue(builder) { builder.startObject(2); diff --git a/tests/ts/reflection/key-value.ts b/tests/ts/reflection/key-value.ts index 93262f42f6b..8a1e4a09bef 100644 --- a/tests/ts/reflection/key-value.ts +++ b/tests/ts/reflection/key-value.ts @@ -37,7 +37,7 @@ value(optionalEncoding?:any):string|Uint8Array|null { } static getFullyQualifiedName():string { - return 'reflection_KeyValue'; + return 'reflection.KeyValue'; } static startKeyValue(builder:flatbuffers.Builder) { diff --git a/tests/ts/reflection/object.js b/tests/ts/reflection/object.js index d2885455a7b..e3d15ecdef1 100644 --- a/tests/ts/reflection/object.js +++ b/tests/ts/reflection/object.js @@ -88,7 +88,7 @@ export class Object_ { return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null; } static getFullyQualifiedName() { - return 'reflection_Object'; + return 'reflection.Object'; } static startObject(builder) { builder.startObject(8); diff --git a/tests/ts/reflection/object.ts b/tests/ts/reflection/object.ts index fbe70061580..3a05effce15 100644 --- a/tests/ts/reflection/object.ts +++ b/tests/ts/reflection/object.ts @@ -122,7 +122,7 @@ declarationFile(optionalEncoding?:any):string|Uint8Array|null { } static getFullyQualifiedName():string { - return 'reflection_Object'; + return 'reflection.Object'; } static startObject(builder:flatbuffers.Builder) { diff --git a/tests/ts/reflection/rpccall.js b/tests/ts/reflection/rpccall.js index 96e92eb3f56..9dd1541a0ac 100644 --- a/tests/ts/reflection/rpccall.js +++ b/tests/ts/reflection/rpccall.js @@ -48,7 +48,7 @@ export class RPCCall { return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; } static getFullyQualifiedName() { - return 'reflection_RPCCall'; + return 'reflection.RPCCall'; } static startRPCCall(builder) { builder.startObject(5); diff --git a/tests/ts/reflection/rpccall.ts b/tests/ts/reflection/rpccall.ts index 320de51695c..61a862fc9b3 100644 --- a/tests/ts/reflection/rpccall.ts +++ b/tests/ts/reflection/rpccall.ts @@ -64,7 +64,7 @@ documentationLength():number { } static getFullyQualifiedName():string { - return 'reflection_RPCCall'; + return 'reflection.RPCCall'; } static startRPCCall(builder:flatbuffers.Builder) { diff --git a/tests/ts/reflection/schema-file.js b/tests/ts/reflection/schema-file.js index 31c6145ddfe..1aeeac84863 100644 --- a/tests/ts/reflection/schema-file.js +++ b/tests/ts/reflection/schema-file.js @@ -35,7 +35,7 @@ export class SchemaFile { return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; } static getFullyQualifiedName() { - return 'reflection_SchemaFile'; + return 'reflection.SchemaFile'; } static startSchemaFile(builder) { builder.startObject(2); diff --git a/tests/ts/reflection/schema-file.ts b/tests/ts/reflection/schema-file.ts index eda23dede0a..6060b800d46 100644 --- a/tests/ts/reflection/schema-file.ts +++ b/tests/ts/reflection/schema-file.ts @@ -53,7 +53,7 @@ includedFilenamesLength():number { } static getFullyQualifiedName():string { - return 'reflection_SchemaFile'; + return 'reflection.SchemaFile'; } static startSchemaFile(builder:flatbuffers.Builder) { diff --git a/tests/ts/reflection/schema.js b/tests/ts/reflection/schema.js index d5022971526..8cdb0c68ab0 100644 --- a/tests/ts/reflection/schema.js +++ b/tests/ts/reflection/schema.js @@ -85,7 +85,7 @@ export class Schema { return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; } static getFullyQualifiedName() { - return 'reflection_Schema'; + return 'reflection.Schema'; } static startSchema(builder) { builder.startObject(8); diff --git a/tests/ts/reflection/schema.ts b/tests/ts/reflection/schema.ts index c99652226d8..21e0e2cee12 100644 --- a/tests/ts/reflection/schema.ts +++ b/tests/ts/reflection/schema.ts @@ -110,7 +110,7 @@ fbsFilesLength():number { } static getFullyQualifiedName():string { - return 'reflection_Schema'; + return 'reflection.Schema'; } static startSchema(builder:flatbuffers.Builder) { diff --git a/tests/ts/reflection/service.js b/tests/ts/reflection/service.js index 8c66ef774ac..3ce83f44fdc 100644 --- a/tests/ts/reflection/service.js +++ b/tests/ts/reflection/service.js @@ -52,7 +52,7 @@ export class Service { return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null; } static getFullyQualifiedName() { - return 'reflection_Service'; + return 'reflection.Service'; } static startService(builder) { builder.startObject(5); diff --git a/tests/ts/reflection/service.ts b/tests/ts/reflection/service.ts index c0ad8adbe64..7fd396f0ef3 100644 --- a/tests/ts/reflection/service.ts +++ b/tests/ts/reflection/service.ts @@ -74,7 +74,7 @@ declarationFile(optionalEncoding?:any):string|Uint8Array|null { } static getFullyQualifiedName():string { - return 'reflection_Service'; + return 'reflection.Service'; } static startService(builder:flatbuffers.Builder) { diff --git a/tests/ts/reflection/type.js b/tests/ts/reflection/type.js index f3ccbdfe688..8deec2f8b0a 100644 --- a/tests/ts/reflection/type.js +++ b/tests/ts/reflection/type.js @@ -97,7 +97,7 @@ export class Type { return true; } static getFullyQualifiedName() { - return 'reflection_Type'; + return 'reflection.Type'; } static startType(builder) { builder.startObject(6); diff --git a/tests/ts/reflection/type.ts b/tests/ts/reflection/type.ts index 37316959d5c..118aee848a3 100644 --- a/tests/ts/reflection/type.ts +++ b/tests/ts/reflection/type.ts @@ -126,7 +126,7 @@ mutate_element_size(value:number):boolean { } static getFullyQualifiedName():string { - return 'reflection_Type'; + return 'reflection.Type'; } static startType(builder:flatbuffers.Builder) { diff --git a/tests/ts/typescript.d.ts b/tests/ts/typescript.d.ts new file mode 100644 index 00000000000..3c9fcbf2f04 --- /dev/null +++ b/tests/ts/typescript.d.ts @@ -0,0 +1,2 @@ +export { Object_ } from './typescript/object.js'; +export { class_ } from './typescript/class.js'; diff --git a/tests/ts/typescript.js b/tests/ts/typescript.js new file mode 100644 index 00000000000..0ea0702fc67 --- /dev/null +++ b/tests/ts/typescript.js @@ -0,0 +1,3 @@ +// automatically generated by the FlatBuffers compiler, do not modify +export { Object_ } from './typescript/object.js'; +export { class_ } from './typescript/class.js'; diff --git a/tests/ts/typescript/object.js b/tests/ts/typescript/object.js index 05ffb1a5692..bde535ca228 100644 --- a/tests/ts/typescript/object.js +++ b/tests/ts/typescript/object.js @@ -98,7 +98,7 @@ export class Object_ { return offset ? (obj || new Schema()).__init(this.bb.__indirect(this.bb_pos + offset), this.bb) : null; } static getFullyQualifiedName() { - return 'typescript_Object'; + return 'typescript.Object'; } static startObject(builder) { builder.startObject(7); diff --git a/tests/ts/typescript/object.ts b/tests/ts/typescript/object.ts index 5baf6ed3b87..f9cbc4881bc 100644 --- a/tests/ts/typescript/object.ts +++ b/tests/ts/typescript/object.ts @@ -128,7 +128,7 @@ reflect(obj?:Schema):Schema|null { } static getFullyQualifiedName():string { - return 'typescript_Object'; + return 'typescript.Object'; } static startObject(builder:flatbuffers.Builder) { diff --git a/tests/ts/typescript_include.ts b/tests/ts/typescript_include.ts new file mode 100644 index 00000000000..b3242dd94e0 --- /dev/null +++ b/tests/ts/typescript_include.ts @@ -0,0 +1,3 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +export * as foobar from './foobar.js'; diff --git a/tests/ts/typescript_keywords.d.ts b/tests/ts/typescript_keywords.d.ts new file mode 100644 index 00000000000..cd607f1f9fc --- /dev/null +++ b/tests/ts/typescript_keywords.d.ts @@ -0,0 +1,3 @@ +export * as foobar from './foobar.js'; +export * as reflection from './reflection.js'; +export * as typescript from './typescript.js'; diff --git a/tests/ts/typescript_keywords.js b/tests/ts/typescript_keywords.js new file mode 100644 index 00000000000..4d637f9ae23 --- /dev/null +++ b/tests/ts/typescript_keywords.js @@ -0,0 +1,4 @@ +// automatically generated by the FlatBuffers compiler, do not modify +export * as foobar from './foobar.js'; +export * as reflection from './reflection.js'; +export * as typescript from './typescript.js'; diff --git a/tests/ts/typescript_keywords.ts b/tests/ts/typescript_keywords.ts new file mode 100644 index 00000000000..dda7dd409e9 --- /dev/null +++ b/tests/ts/typescript_keywords.ts @@ -0,0 +1,5 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +export * as foobar from './foobar.js'; +export * as reflection from './reflection.js'; +export * as typescript from './typescript.js'; diff --git a/tests/ts/typescript_keywords_generated.cjs b/tests/ts/typescript_keywords_generated.cjs index 74e00dccb31..65601436081 100644 --- a/tests/ts/typescript_keywords_generated.cjs +++ b/tests/ts/typescript_keywords_generated.cjs @@ -23,16 +23,20 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge )); var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); -// typescript.ts -var typescript_exports = {}; -__export(typescript_exports, { - Object_: () => Object_2, - class_: () => class_2 +// typescript_keywords.ts +var typescript_keywords_exports = {}; +__export(typescript_keywords_exports, { + foobar: () => foobar_exports, + reflection: () => reflection_exports, + typescript: () => typescript_exports }); -module.exports = __toCommonJS(typescript_exports); +module.exports = __toCommonJS(typescript_keywords_exports); -// typescript/object.js -var flatbuffers11 = __toESM(require("flatbuffers"), 1); +// foobar.js +var foobar_exports = {}; +__export(foobar_exports, { + Abc: () => Abc +}); // foobar/abc.js var Abc; @@ -40,14 +44,55 @@ var Abc; Abc2[Abc2["a"] = 0] = "a"; })(Abc = Abc || (Abc = {})); -// foobar/class.js -var class_; -(function(class_3) { - class_3[class_3["arguments_"] = 0] = "arguments_"; -})(class_ = class_ || (class_ = {})); +// reflection.js +var reflection_exports = {}; +__export(reflection_exports, { + AdvancedFeatures: () => AdvancedFeatures, + BaseType: () => BaseType, + Enum: () => Enum, + EnumVal: () => EnumVal, + Field: () => Field, + KeyValue: () => KeyValue, + Object_: () => Object_, + RPCCall: () => RPCCall, + Schema: () => Schema, + SchemaFile: () => SchemaFile, + Service: () => Service, + Type: () => Type +}); -// reflection/schema.js -var flatbuffers10 = __toESM(require("flatbuffers"), 1); +// reflection/advanced-features.js +var AdvancedFeatures; +(function(AdvancedFeatures2) { + AdvancedFeatures2["AdvancedArrayFeatures"] = "1"; + AdvancedFeatures2["AdvancedUnionFeatures"] = "2"; + AdvancedFeatures2["OptionalScalars"] = "4"; + AdvancedFeatures2["DefaultVectorsAndStrings"] = "8"; +})(AdvancedFeatures = AdvancedFeatures || (AdvancedFeatures = {})); + +// reflection/base-type.js +var BaseType; +(function(BaseType2) { + BaseType2[BaseType2["None"] = 0] = "None"; + BaseType2[BaseType2["UType"] = 1] = "UType"; + BaseType2[BaseType2["Bool"] = 2] = "Bool"; + BaseType2[BaseType2["Byte"] = 3] = "Byte"; + BaseType2[BaseType2["UByte"] = 4] = "UByte"; + BaseType2[BaseType2["Short"] = 5] = "Short"; + BaseType2[BaseType2["UShort"] = 6] = "UShort"; + BaseType2[BaseType2["Int"] = 7] = "Int"; + BaseType2[BaseType2["UInt"] = 8] = "UInt"; + BaseType2[BaseType2["Long"] = 9] = "Long"; + BaseType2[BaseType2["ULong"] = 10] = "ULong"; + BaseType2[BaseType2["Float"] = 11] = "Float"; + BaseType2[BaseType2["Double"] = 12] = "Double"; + BaseType2[BaseType2["String"] = 13] = "String"; + BaseType2[BaseType2["Vector"] = 14] = "Vector"; + BaseType2[BaseType2["Obj"] = 15] = "Obj"; + BaseType2[BaseType2["Union"] = 16] = "Union"; + BaseType2[BaseType2["Array"] = 17] = "Array"; + BaseType2[BaseType2["MaxBaseType"] = 18] = "MaxBaseType"; +})(BaseType = BaseType || (BaseType = {})); // reflection/enum.js var flatbuffers4 = __toESM(require("flatbuffers"), 1); @@ -83,7 +128,7 @@ var KeyValue = class { return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null; } static getFullyQualifiedName() { - return "reflection_KeyValue"; + return "reflection.KeyValue"; } static startKeyValue(builder) { builder.startObject(2); @@ -127,32 +172,6 @@ var KeyValueT = class { // reflection/type.js var flatbuffers2 = __toESM(require("flatbuffers"), 1); - -// reflection/base-type.js -var BaseType; -(function(BaseType2) { - BaseType2[BaseType2["None"] = 0] = "None"; - BaseType2[BaseType2["UType"] = 1] = "UType"; - BaseType2[BaseType2["Bool"] = 2] = "Bool"; - BaseType2[BaseType2["Byte"] = 3] = "Byte"; - BaseType2[BaseType2["UByte"] = 4] = "UByte"; - BaseType2[BaseType2["Short"] = 5] = "Short"; - BaseType2[BaseType2["UShort"] = 6] = "UShort"; - BaseType2[BaseType2["Int"] = 7] = "Int"; - BaseType2[BaseType2["UInt"] = 8] = "UInt"; - BaseType2[BaseType2["Long"] = 9] = "Long"; - BaseType2[BaseType2["ULong"] = 10] = "ULong"; - BaseType2[BaseType2["Float"] = 11] = "Float"; - BaseType2[BaseType2["Double"] = 12] = "Double"; - BaseType2[BaseType2["String"] = 13] = "String"; - BaseType2[BaseType2["Vector"] = 14] = "Vector"; - BaseType2[BaseType2["Obj"] = 15] = "Obj"; - BaseType2[BaseType2["Union"] = 16] = "Union"; - BaseType2[BaseType2["Array"] = 17] = "Array"; - BaseType2[BaseType2["MaxBaseType"] = 18] = "MaxBaseType"; -})(BaseType = BaseType || (BaseType = {})); - -// reflection/type.js var Type = class { constructor() { this.bb = null; @@ -243,7 +262,7 @@ var Type = class { return true; } static getFullyQualifiedName() { - return "reflection_Type"; + return "reflection.Type"; } static startType(builder) { builder.startObject(6); @@ -361,7 +380,7 @@ var EnumVal = class { return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; } static getFullyQualifiedName() { - return "reflection_EnumVal"; + return "reflection.EnumVal"; } static startEnumVal(builder) { builder.startObject(6); @@ -507,7 +526,7 @@ var Enum = class { return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null; } static getFullyQualifiedName() { - return "reflection_Enum"; + return "reflection.Enum"; } static startEnum(builder) { builder.startObject(7); @@ -612,9 +631,6 @@ var EnumT = class { } }; -// reflection/object.js -var flatbuffers6 = __toESM(require("flatbuffers"), 1); - // reflection/field.js var flatbuffers5 = __toESM(require("flatbuffers"), 1); var Field = class { @@ -767,7 +783,7 @@ var Field = class { return true; } static getFullyQualifiedName() { - return "reflection_Field"; + return "reflection.Field"; } static startField(builder) { builder.startObject(13); @@ -896,6 +912,7 @@ var FieldT = class { }; // reflection/object.js +var flatbuffers6 = __toESM(require("flatbuffers"), 1); var Object_ = class { constructor() { this.bb = null; @@ -982,7 +999,7 @@ var Object_ = class { return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null; } static getFullyQualifiedName() { - return "reflection_Object"; + return "reflection.Object"; } static startObject(builder) { builder.startObject(8); @@ -1094,95 +1111,8 @@ var Object_T = class { } }; -// reflection/schema-file.js -var flatbuffers7 = __toESM(require("flatbuffers"), 1); -var SchemaFile = class { - 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() + flatbuffers7.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); - 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()); - } -}; -var SchemaFileT = class { - 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); - } -}; - -// reflection/service.js -var flatbuffers9 = __toESM(require("flatbuffers"), 1); - // reflection/rpccall.js -var flatbuffers8 = __toESM(require("flatbuffers"), 1); +var flatbuffers7 = __toESM(require("flatbuffers"), 1); var RPCCall = class { constructor() { this.bb = null; @@ -1197,7 +1127,7 @@ var RPCCall = class { return (obj || new RPCCall()).__init(bb.readInt32(bb.position()) + bb.position(), bb); } static getSizePrefixedRootAsRPCCall(bb, obj) { - bb.setPosition(bb.position() + flatbuffers8.SIZE_PREFIX_LENGTH); + bb.setPosition(bb.position() + flatbuffers7.SIZE_PREFIX_LENGTH); return (obj || new RPCCall()).__init(bb.readInt32(bb.position()) + bb.position(), bb); } name(optionalEncoding) { @@ -1229,7 +1159,7 @@ var RPCCall = class { return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; } static getFullyQualifiedName() { - return "reflection_RPCCall"; + return "reflection.RPCCall"; } static startRPCCall(builder) { builder.startObject(5); @@ -1311,7 +1241,95 @@ var RPCCallT = class { } }; +// reflection/schema.js +var flatbuffers10 = __toESM(require("flatbuffers"), 1); + +// reflection/schema-file.js +var flatbuffers8 = __toESM(require("flatbuffers"), 1); +var SchemaFile = class { + 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() + flatbuffers8.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); + 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()); + } +}; +var SchemaFileT = class { + 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); + } +}; + // reflection/service.js +var flatbuffers9 = __toESM(require("flatbuffers"), 1); var Service = class { constructor() { this.bb = null; @@ -1362,7 +1380,7 @@ var Service = class { return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null; } static getFullyQualifiedName() { - return "reflection_Service"; + return "reflection.Service"; } static startService(builder) { builder.startObject(5); @@ -1533,7 +1551,7 @@ var Schema = class { return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; } static getFullyQualifiedName() { - return "reflection_Schema"; + return "reflection.Schema"; } static startSchema(builder) { builder.startObject(8); @@ -1660,6 +1678,22 @@ var SchemaT = class { } }; +// typescript.js +var typescript_exports = {}; +__export(typescript_exports, { + Object_: () => Object_2, + class_: () => class_2 +}); + +// typescript/object.js +var flatbuffers11 = __toESM(require("flatbuffers"), 1); + +// foobar/class.js +var class_; +(function(class_3) { + class_3[class_3["arguments_"] = 0] = "arguments_"; +})(class_ = class_ || (class_ = {})); + // typescript/class.js var class_2; (function(class_3) { @@ -1762,7 +1796,7 @@ var Object_2 = class { return offset ? (obj || new Schema()).__init(this.bb.__indirect(this.bb_pos + offset), this.bb) : null; } static getFullyQualifiedName() { - return "typescript_Object"; + return "typescript.Object"; } static startObject(builder) { builder.startObject(7); diff --git a/tests/ts/typescript_transitive_include.ts b/tests/ts/typescript_transitive_include.ts new file mode 100644 index 00000000000..b3242dd94e0 --- /dev/null +++ b/tests/ts/typescript_transitive_include.ts @@ -0,0 +1,3 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +export * as foobar from './foobar.js'; From 6fafede94a61677fba6a5c6ba724579b47af2943 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Harrtell?= Date: Thu, 12 Jan 2023 14:06:01 +0100 Subject: [PATCH 34/39] Separate test procedure for old node resolution module output --- tests/ts/TypeScriptTest.py | 2 ++ .../no_import_ext/optional-scalars/optional-byte.js | 2 +- tests/ts/no_import_ext/optional_scalars.js | 3 ++- .../ts/no_import_ext/optional_scalars_generated.d.ts | 2 -- tests/ts/no_import_ext/optional_scalars_generated.js | 3 --- tests/ts/no_import_ext/optional_scalars_generated.ts | 4 ---- tests/ts/tsconfig.json | 3 +-- tests/ts/tsconfig.node.json | 12 ++++++++++++ 8 files changed, 18 insertions(+), 13 deletions(-) delete mode 100644 tests/ts/no_import_ext/optional_scalars_generated.d.ts delete mode 100644 tests/ts/no_import_ext/optional_scalars_generated.js delete mode 100644 tests/ts/no_import_ext/optional_scalars_generated.ts create mode 100644 tests/ts/tsconfig.node.json diff --git a/tests/ts/TypeScriptTest.py b/tests/ts/TypeScriptTest.py index 68cbdd6d488..de607983eae 100755 --- a/tests/ts/TypeScriptTest.py +++ b/tests/ts/TypeScriptTest.py @@ -119,6 +119,8 @@ def esbuild(input, output): print("Running TypeScript Compiler...") check_call(["tsc"]) +print("Running TypeScript Compiler in old node resolution mode for no_import_ext...") +check_call(["tsc", "-p", "./tsconfig.node.json"]) NODE_CMD = ["node"] diff --git a/tests/ts/no_import_ext/optional-scalars/optional-byte.js b/tests/ts/no_import_ext/optional-scalars/optional-byte.js index 8b998708e7a..8257f93a460 100644 --- a/tests/ts/no_import_ext/optional-scalars/optional-byte.js +++ b/tests/ts/no_import_ext/optional-scalars/optional-byte.js @@ -4,4 +4,4 @@ export var OptionalByte; OptionalByte[OptionalByte["None"] = 0] = "None"; OptionalByte[OptionalByte["One"] = 1] = "One"; OptionalByte[OptionalByte["Two"] = 2] = "Two"; -})(OptionalByte = OptionalByte || (OptionalByte = {})); +})(OptionalByte || (OptionalByte = {})); diff --git a/tests/ts/no_import_ext/optional_scalars.js b/tests/ts/no_import_ext/optional_scalars.js index 7bcc3a61ae4..92bbd86f192 100644 --- a/tests/ts/no_import_ext/optional_scalars.js +++ b/tests/ts/no_import_ext/optional_scalars.js @@ -1,2 +1,3 @@ // automatically generated by the FlatBuffers compiler, do not modify -export * as optional_scalars from './no_import_ext/optional-scalars.js'; +import * as optional_scalars_1 from './no_import_ext/optional-scalars.js'; +export { optional_scalars_1 as optional_scalars }; diff --git a/tests/ts/no_import_ext/optional_scalars_generated.d.ts b/tests/ts/no_import_ext/optional_scalars_generated.d.ts deleted file mode 100644 index 40a0ac6fea9..00000000000 --- a/tests/ts/no_import_ext/optional_scalars_generated.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -export { OptionalByte } from './optional-scalars/optional-byte'; -export { ScalarStuff } from './optional-scalars/scalar-stuff'; diff --git a/tests/ts/no_import_ext/optional_scalars_generated.js b/tests/ts/no_import_ext/optional_scalars_generated.js deleted file mode 100644 index 09e2631cfc0..00000000000 --- a/tests/ts/no_import_ext/optional_scalars_generated.js +++ /dev/null @@ -1,3 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify -export { OptionalByte } from './optional-scalars/optional-byte'; -export { ScalarStuff } from './optional-scalars/scalar-stuff'; diff --git a/tests/ts/no_import_ext/optional_scalars_generated.ts b/tests/ts/no_import_ext/optional_scalars_generated.ts deleted file mode 100644 index 4a83c439fcf..00000000000 --- a/tests/ts/no_import_ext/optional_scalars_generated.ts +++ /dev/null @@ -1,4 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -export { OptionalByte } from './optional-scalars/optional-byte'; -export { ScalarStuff } from './optional-scalars/scalar-stuff'; diff --git a/tests/ts/tsconfig.json b/tests/ts/tsconfig.json index 762ea3aca6a..d9ef7410c3a 100644 --- a/tests/ts/tsconfig.json +++ b/tests/ts/tsconfig.json @@ -14,7 +14,6 @@ "optional_scalars/**/*.ts", "namespace_test/**/*.ts", "union_vector/**/*.ts", - "arrays_test_complex/**/*.ts", - "no_import_ext/**/*.ts" + "arrays_test_complex/**/*.ts" ] } diff --git a/tests/ts/tsconfig.node.json b/tests/ts/tsconfig.node.json new file mode 100644 index 00000000000..63cc8682740 --- /dev/null +++ b/tests/ts/tsconfig.node.json @@ -0,0 +1,12 @@ +{ + "compilerOptions": { + "target": "ES2020", + "lib": ["ES2020", "DOM"], + "moduleResolution": "node", + "declaration": true, + "strict": true + }, + "include": [ + "no_import_ext/**/*.ts" + ] +} From 6c07d62c6a7bd32b8fbe0582235d3d716dd973fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Harrtell?= Date: Thu, 12 Jan 2023 14:32:44 +0100 Subject: [PATCH 35/39] Fix rel path for root level re-exports --- src/idl_gen_ts.cpp | 14 ++++---------- tests/ts/no_import_ext/optional_scalars.d.ts | 2 +- tests/ts/no_import_ext/optional_scalars.js | 2 +- tests/ts/no_import_ext/optional_scalars.ts | 2 +- 4 files changed, 7 insertions(+), 13 deletions(-) diff --git a/src/idl_gen_ts.cpp b/src/idl_gen_ts.cpp index 1d132174d79..e267ad3f55c 100644 --- a/src/idl_gen_ts.cpp +++ b/src/idl_gen_ts.cpp @@ -177,6 +177,8 @@ class TsGenerator : public BaseGenerator { path = namer_.Directories(*definition.defined_namespace, SkipDir::TrailingPathSeperator); filepath = path + ".ts"; + path = namer_.Directories(*definition.defined_namespace, + SkipDir::OutputPathAndTrailingPathSeparator); symbolic_name = definition.defined_namespace->components.back(); } else { auto def_mod_name = namer_.File(definition, SkipFile::SuffixAndExtension); @@ -288,7 +290,8 @@ class TsGenerator : public BaseGenerator { if (it2.second.ns->components.size() != child_ns_level) continue; auto ts_file_path = it2.second.path + ".ts"; code += "export * as " + it2.second.symbolic_name + " from './"; - code += it2.second.path + ".js';\n"; + std::string rel_path = it2.second.path; + code += rel_path + ".js';\n"; export_counter++; } @@ -300,15 +303,6 @@ class TsGenerator : public BaseGenerator { if (parser_.opts.ts_flat_files) { std::string inputpath; std::string symbolic_name = file_name_; - // TODO: unsure when/why this was sensible - /*if (parser_.current_namespace_->components.size() > 0) { - std::string path = namer_.Directories(*parser_.current_namespace_, - SkipDir::TrailingPathSeperator); - inputpath = path + ".ts"; - symbolic_name = parser_.current_namespace_->components.back(); - } else { - inputpath = path_ + file_name_ + ".ts"; - }*/ inputpath = path_ + file_name_ + ".ts"; std::string bundlepath = GeneratedFileName(path_, file_name_, parser_.opts); diff --git a/tests/ts/no_import_ext/optional_scalars.d.ts b/tests/ts/no_import_ext/optional_scalars.d.ts index 6422ea18304..de14740c35c 100644 --- a/tests/ts/no_import_ext/optional_scalars.d.ts +++ b/tests/ts/no_import_ext/optional_scalars.d.ts @@ -1 +1 @@ -export * as optional_scalars from './no_import_ext/optional-scalars.js'; +export * as optional_scalars from './optional-scalars.js'; diff --git a/tests/ts/no_import_ext/optional_scalars.js b/tests/ts/no_import_ext/optional_scalars.js index 92bbd86f192..d519b38fa48 100644 --- a/tests/ts/no_import_ext/optional_scalars.js +++ b/tests/ts/no_import_ext/optional_scalars.js @@ -1,3 +1,3 @@ // automatically generated by the FlatBuffers compiler, do not modify -import * as optional_scalars_1 from './no_import_ext/optional-scalars.js'; +import * as optional_scalars_1 from './optional-scalars.js'; export { optional_scalars_1 as optional_scalars }; diff --git a/tests/ts/no_import_ext/optional_scalars.ts b/tests/ts/no_import_ext/optional_scalars.ts index 460a969fff2..18ded6e4f79 100644 --- a/tests/ts/no_import_ext/optional_scalars.ts +++ b/tests/ts/no_import_ext/optional_scalars.ts @@ -1,3 +1,3 @@ // automatically generated by the FlatBuffers compiler, do not modify -export * as optional_scalars from './no_import_ext/optional-scalars.js'; +export * as optional_scalars from './optional-scalars.js'; From 5f28a5371ed0f69f8f650dfef4f117be4da6473e Mon Sep 17 00:00:00 2001 From: James Kuszmaul Date: Sat, 17 Dec 2022 17:37:57 -0800 Subject: [PATCH 36/39] Bazel support for esbuild-based flatc Unfortunately, we lose typing information because the new esbuild method of generating single files does not generate type information. The method used here is a bit hack-ish because it relies on parsing the console output of flatc to figure out what to do. --- build_defs.bzl | 23 ++++++++++++----- ts/BUILD.bazel | 15 +++++++++++ ts/compile_flat_file.sh | 22 ++++++++++++++++ typescript.bzl | 57 +++++++---------------------------------- 4 files changed, 63 insertions(+), 54 deletions(-) create mode 100755 ts/compile_flat_file.sh diff --git a/build_defs.bzl b/build_defs.bzl index 22949b9ee1d..530518a2cc8 100644 --- a/build_defs.bzl +++ b/build_defs.bzl @@ -7,7 +7,7 @@ Rules for building C++ flatbuffers with Bazel. load("@rules_cc//cc:defs.bzl", "cc_library") -flatc_path = "@com_github_google_flatbuffers//:flatc" +TRUE_FLATC_PATH = "@com_github_google_flatbuffers//:flatc" DEFAULT_INCLUDE_PATHS = [ "./", @@ -16,6 +16,14 @@ DEFAULT_INCLUDE_PATHS = [ "$(execpath @com_github_google_flatbuffers//:flatc).runfiles/com_github_google_flatbuffers", ] +def default_include_paths(flatc_path): + return [ + "./", + "$(GENDIR)", + "$(BINDIR)", + "$(execpath %s).runfiles/com_github_google_flatbuffers" % (flatc_path), + ] + DEFAULT_FLATC_ARGS = [ "--gen-object-api", "--gen-compare", @@ -32,13 +40,14 @@ def flatbuffer_library_public( language_flag, out_prefix = "", includes = [], - include_paths = DEFAULT_INCLUDE_PATHS, + include_paths = None, flatc_args = DEFAULT_FLATC_ARGS, reflection_name = "", reflection_visibility = None, compatible_with = None, restricted_to = None, target_compatible_with = None, + flatc_path = "@com_github_google_flatbuffers//:flatc", output_to_bindir = False): """Generates code files for reading/writing the given flatbuffers in the requested language using the public compiler. @@ -69,6 +78,8 @@ def flatbuffer_library_public( optionally a Fileset([reflection_name]) with all generated reflection binaries. """ + if include_paths == None: + include_paths = default_include_paths(flatc_path) include_paths_cmd = ["-I %s" % (s) for s in include_paths] # '$(@D)' when given a single source target will give the appropriate @@ -80,7 +91,7 @@ def flatbuffer_library_public( genrule_cmd = " ".join([ "SRCS=($(SRCS));", "for f in $${SRCS[@]:0:%s}; do" % len(srcs), - "$(location %s)" % (flatc_path), + "OUTPUT_FILE=\"$(OUTS)\" $(location %s)" % (flatc_path), " ".join(include_paths_cmd), " ".join(flatc_args), language_flag, @@ -104,7 +115,7 @@ def flatbuffer_library_public( reflection_genrule_cmd = " ".join([ "SRCS=($(SRCS));", "for f in $${SRCS[@]:0:%s}; do" % len(srcs), - "$(location %s)" % (flatc_path), + "$(location %s)" % (TRUE_FLATC_PATH), "-b --schema", " ".join(flatc_args), " ".join(include_paths_cmd), @@ -122,7 +133,7 @@ def flatbuffer_library_public( srcs = srcs + includes, outs = reflection_outs, output_to_bindir = output_to_bindir, - tools = [flatc_path], + tools = [TRUE_FLATC_PATH], compatible_with = compatible_with, restricted_to = restricted_to, target_compatible_with = target_compatible_with, @@ -145,7 +156,7 @@ def flatbuffer_cc_library( out_prefix = "", deps = [], includes = [], - include_paths = DEFAULT_INCLUDE_PATHS, + include_paths = None, cc_include_paths = [], flatc_args = DEFAULT_FLATC_ARGS, visibility = None, diff --git a/ts/BUILD.bazel b/ts/BUILD.bazel index cb3cb0f2607..bc4da2adadd 100644 --- a/ts/BUILD.bazel +++ b/ts/BUILD.bazel @@ -37,3 +37,18 @@ js_library( visibility = ["//visibility:public"], deps = [":flatbuffers_ts"], ) + +sh_binary( + name = "compile_flat_file", + srcs = ["compile_flat_file.sh"], + data = [ + "@com_github_google_flatbuffers//:flatc", + "@npm//esbuild/bin:esbuild", + ], + env = { + "FLATC": "$(location @com_github_google_flatbuffers//:flatc)", + "ESBUILD": "$(location @npm//esbuild/bin:esbuild)", + }, + visibility = ["//visibility:public"], + deps = ["@bazel_tools//tools/bash/runfiles"], +) diff --git a/ts/compile_flat_file.sh b/ts/compile_flat_file.sh new file mode 100755 index 00000000000..95fb9518e91 --- /dev/null +++ b/ts/compile_flat_file.sh @@ -0,0 +1,22 @@ +#!/bin/bash +# This is a script used by the typescript flatbuffer bazel rules to compile +# a flatbuffer schema (.fbs file) to typescript and then use esbuild to +# generate a single output. +# Note: This relies on parsing the stdout of flatc to figure out how to +# run esbuild. +# --- begin runfiles.bash initialization v2 --- +# Copy-pasted from the Bazel Bash runfiles library v2. +set -uo pipefail; set +e; f=bazel_tools/tools/bash/runfiles/runfiles.bash +source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null || \ + source "$(grep -sm1 "^$f " "${RUNFILES_MANIFEST_FILE:-/dev/null}" | cut -f2- -d' ')" 2>/dev/null || \ + source "$0.runfiles/$f" 2>/dev/null || \ + source "$(grep -sm1 "^$f " "$0.runfiles_manifest" | cut -f2- -d' ')" 2>/dev/null || \ + source "$(grep -sm1 "^$f " "$0.exe.runfiles_manifest" | cut -f2- -d' ')" 2>/dev/null || \ + { echo>&2 "ERROR: cannot find $f"; exit 1; }; f=; set -e +# --- end runfiles.bash initialization v2 --- +set -e +runfiles_export_envvars +FLATC=$(rlocation com_github_google_flatbuffers/flatc) +ESBUILD=$(rlocation npm/node_modules/esbuild/bin/esbuild) +TS_FILE=$(${FLATC} $@ | grep "Entry point.*generated" | grep -o "bazel-out.*ts") +${ESBUILD} ${TS_FILE} --format=cjs --bundle --outfile="${OUTPUT_FILE}" --external:flatbuffers --log-level=warning diff --git a/typescript.bzl b/typescript.bzl index f112f34f958..af55f14ff75 100644 --- a/typescript.bzl +++ b/typescript.bzl @@ -21,7 +21,7 @@ def flatbuffer_ts_library( compatible_with = None, target_compatible_with = None, deps = [], - include_paths = DEFAULT_INCLUDE_PATHS, + include_paths = None, flatc_args = DEFAULT_FLATC_TS_ARGS, visibility = None, restricted_to = None, @@ -56,65 +56,26 @@ def flatbuffer_ts_library( srcs_lib = "%s_srcs" % (name) out_base = [s.replace(".fbs", "").split("/")[-1].split(":")[-1] for s in srcs] - # Because of how we have to manage the bazel rules for typescript, - # reflection has to get special-cased to get imported when - # run within bazel. As such, generate the code using the _pregenerate - # suffix; then do a find/replace to fix-up all the reflection imports. - pre_outs = ["%s_pregenerated.ts" % s for s in out_base] - outs = ["%s_generated.ts" % s for s in out_base] + if len(srcs) != 1: + fail("flatbuffer_ts_library only supports one .fbs file per target currently.") + + outs = ["%s_generated.cjs" % s for s in out_base] includes = [d + "_includes" for d in deps] reflection_name = "%s_reflection" % name if gen_reflections else "" flatbuffer_library_public( name = srcs_lib, srcs = srcs, - outs = pre_outs, + outs = outs, language_flag = "--ts", includes = includes, include_paths = include_paths, - flatc_args = flatc_args + ["--filename-suffix _pregenerated"], + flatc_args = flatc_args + ["--filename-suffix _generated"], compatible_with = compatible_with, restricted_to = restricted_to, reflection_name = reflection_name, reflection_visibility = visibility, target_compatible_with = target_compatible_with, - ) - fix_import_cmd = " ".join([ - "SRCS=($(SRCS));", - "OUTS=($(OUTS));", - "for i in $${!SRCS[@]}; do", - "sed \"s/'.*reflection\\/reflection_pregenerated/'flatbuffers_reflection\\/reflection_generated/; s/_pregenerated/_generated/\" $${SRCS[i]} > $${OUTS[i]};", - "done", - ]) - native.genrule( - name = name + "_reimporter", - srcs = pre_outs, - outs = outs, - cmd = fix_import_cmd, - ) - ts_project( - name = name + "_ts", - srcs = outs, - declaration = True, - visibility = visibility, - compatible_with = compatible_with, - restricted_to = restricted_to, - target_compatible_with = target_compatible_with, - tsconfig = { - "compilerOptions": { - "declaration": True, - "lib": [ - "ES2015", - "ES2020.BigInt", - "DOM", - ], - "module": "commonjs", - "moduleResolution": "node", - "noUnusedLocals": True, - "strict": True, - "types": ["node"], - }, - }, - deps = deps + ["@com_github_google_flatbuffers//ts:flatbuffers"] + (["@com_github_google_flatbuffers//reflection/ts:reflection_ts_fbs"] if include_reflection else []), + flatc_path = "@com_github_google_flatbuffers//ts:compile_flat_file", ) js_library( name = name, @@ -122,7 +83,7 @@ def flatbuffer_ts_library( compatible_with = compatible_with, restricted_to = restricted_to, target_compatible_with = target_compatible_with, - deps = [name + "_ts"], + srcs = outs, package_name = package_name, ) native.filegroup( From 96ddf2c1735c47757e64548c77f5c2991c9ad95b Mon Sep 17 00:00:00 2001 From: James Kuszmaul Date: Sun, 15 Jan 2023 13:36:55 -0800 Subject: [PATCH 37/39] Try to fix bazel build for when node isn't present on host --- build_defs.bzl | 1 + reflection/ts/BUILD.bazel | 1 - ts/BUILD.bazel | 11 +++++++---- ts/compile_flat_file.sh | 1 + typescript.bzl | 7 +------ 5 files changed, 10 insertions(+), 11 deletions(-) diff --git a/build_defs.bzl b/build_defs.bzl index 530518a2cc8..66b22d2ea6f 100644 --- a/build_defs.bzl +++ b/build_defs.bzl @@ -71,6 +71,7 @@ def flatbuffer_library_public( for, instead of default-supported environments. target_compatible_with: Optional, The list of target platform constraints to use. + flatc_path: Bazel target corresponding to the flatc compiler to use. output_to_bindir: Passed to genrule for output to bin directory. diff --git a/reflection/ts/BUILD.bazel b/reflection/ts/BUILD.bazel index 3f8a41873d0..b9bd70848bc 100644 --- a/reflection/ts/BUILD.bazel +++ b/reflection/ts/BUILD.bazel @@ -11,6 +11,5 @@ flatbuffer_ts_library( name = "reflection_ts_fbs", package_name = "flatbuffers_reflection", srcs = [":reflection.fbs"], - include_reflection = False, visibility = ["//visibility:public"], ) diff --git a/ts/BUILD.bazel b/ts/BUILD.bazel index bc4da2adadd..34fa6746aa7 100644 --- a/ts/BUILD.bazel +++ b/ts/BUILD.bazel @@ -43,12 +43,15 @@ sh_binary( srcs = ["compile_flat_file.sh"], data = [ "@com_github_google_flatbuffers//:flatc", + "@nodejs_linux_amd64//:node_bin", "@npm//esbuild/bin:esbuild", ], - env = { - "FLATC": "$(location @com_github_google_flatbuffers//:flatc)", - "ESBUILD": "$(location @npm//esbuild/bin:esbuild)", - }, + # We just depend directly on the linux amd64 nodejs binary, so only support + # running this script on amd64 for now. + target_compatible_with = [ + "@platforms//cpu:x86_64", + "@platforms//os:linux", + ], visibility = ["//visibility:public"], deps = ["@bazel_tools//tools/bash/runfiles"], ) diff --git a/ts/compile_flat_file.sh b/ts/compile_flat_file.sh index 95fb9518e91..0aeaebeaea8 100755 --- a/ts/compile_flat_file.sh +++ b/ts/compile_flat_file.sh @@ -19,4 +19,5 @@ runfiles_export_envvars FLATC=$(rlocation com_github_google_flatbuffers/flatc) ESBUILD=$(rlocation npm/node_modules/esbuild/bin/esbuild) TS_FILE=$(${FLATC} $@ | grep "Entry point.*generated" | grep -o "bazel-out.*ts") +export PATH=$(rlocation nodejs_linux_amd64/bin/nodejs/bin) ${ESBUILD} ${TS_FILE} --format=cjs --bundle --outfile="${OUTPUT_FILE}" --external:flatbuffers --log-level=warning diff --git a/typescript.bzl b/typescript.bzl index af55f14ff75..41eb335cc03 100644 --- a/typescript.bzl +++ b/typescript.bzl @@ -3,8 +3,7 @@ Rules for building typescript flatbuffers with Bazel. """ load("@build_bazel_rules_nodejs//:index.bzl", "js_library") -load("@npm//@bazel/typescript:index.bzl", "ts_project") -load(":build_defs.bzl", "DEFAULT_INCLUDE_PATHS", "flatbuffer_library_public") +load(":build_defs.bzl", "flatbuffer_library_public") DEFAULT_FLATC_TS_ARGS = [ "--gen-object-api", @@ -25,7 +24,6 @@ def flatbuffer_ts_library( flatc_args = DEFAULT_FLATC_TS_ARGS, visibility = None, restricted_to = None, - include_reflection = True, gen_reflections = False, package_name = None): """Generates a ts_library rule for a given flatbuffer definition. @@ -46,9 +44,6 @@ def flatbuffer_ts_library( for, instead of default-supported environments. target_compatible_with: Optional, The list of target platform constraints to use. - include_reflection: Optional, Whether to depend on the flatbuffer - reflection library automatically. Only really relevant for the - target that builds the reflection library itself. gen_reflections: Optional, if true this will generate the flatbuffer reflection binaries for the schemas. package_name: Optional, Package name to use for the generated code. From 027bc8bc7d75a3860219ced0bede235207d261a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Harrtell?= Date: Mon, 16 Jan 2023 13:57:05 +0100 Subject: [PATCH 38/39] Auto formatting fixes --- src/flatc.cpp | 3 ++- src/idl_gen_ts.cpp | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/flatc.cpp b/src/flatc.cpp index c0d336582c0..d43b4ed0057 100644 --- a/src/flatc.cpp +++ b/src/flatc.cpp @@ -230,7 +230,8 @@ const static FlatCOption flatc_options[] = { "Allow a nested_flatbuffer field to be parsed as a vector of bytes " "in JSON, which is unsafe unless checked by a verifier afterwards." }, { "", "ts-flat-files", "", - "Generate a single typescript file per .fbs file. Implies ts_entry_points." }, + "Generate a single typescript file per .fbs file. Implies " + "ts_entry_points." }, { "", "ts-entry-points", "", "Generate entry point typescript per namespace. Implies gen-all." }, { "", "annotate", "SCHEMA", diff --git a/src/idl_gen_ts.cpp b/src/idl_gen_ts.cpp index e267ad3f55c..322d54f9d1f 100644 --- a/src/idl_gen_ts.cpp +++ b/src/idl_gen_ts.cpp @@ -279,7 +279,8 @@ class TsGenerator : public BaseGenerator { auto ts_file_path_rel = base_name_rel + ".ts"; auto type_name = def.first; code += "export { " + type_name + " } from '"; - std::string import_extension = parser_.opts.ts_no_import_ext ? "" : ".js"; + std::string import_extension = + parser_.opts.ts_no_import_ext ? "" : ".js"; code += base_name_rel + import_extension + "';\n"; export_counter++; } From 9ffa2acd95a70a0213ac8444d100e5ea1bc4c5d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Harrtell?= Date: Mon, 16 Jan 2023 13:58:38 +0100 Subject: [PATCH 39/39] Fix missing generated code --- grpc/examples/ts/greeter/src/greeter.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/grpc/examples/ts/greeter/src/greeter.ts b/grpc/examples/ts/greeter/src/greeter.ts index 5e62d999401..56620ccb52f 100644 --- a/grpc/examples/ts/greeter/src/greeter.ts +++ b/grpc/examples/ts/greeter/src/greeter.ts @@ -1,2 +1,3 @@ -export { HelloReply } from './models/hello-reply'; -export { HelloRequest } from './models/hello-request'; +// automatically generated by the FlatBuffers compiler, do not modify + +export * as models from './models.js';