diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index cb4e1f39b4fc..c39e23dcc803 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: @@ -460,7 +462,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 4cfd7ebfb0d9..f010f8c54db2 100644 --- a/include/flatbuffers/idl.h +++ b/include/flatbuffers/idl.h @@ -632,7 +632,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; // Possible options for the more general generator below. @@ -732,7 +733,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), mini_reflect(IDLOptions::kNone), require_explicit_ids(false), diff --git a/package.json b/package.json index 93b70de420a0..8df69dbf5277 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 9369655e6365..000000000000 --- 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 7111d8d313c9..31f8953aaac7 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 1d12a1769c7c..683f03b168e1 100644 --- a/src/flatc.cpp +++ b/src/flatc.cpp @@ -218,7 +218,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", "", @@ -598,7 +600,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 44e8cb6cbf02..c1dadc0b1068 100644 --- a/src/idl_gen_ts.cpp +++ b/src/idl_gen_ts.cpp @@ -16,8 +16,6 @@ #include #include -#include -#include #include "flatbuffers/code_generators.h" #include "flatbuffers/flatbuffers.h" @@ -38,6 +36,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, @@ -101,33 +107,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); @@ -143,58 +142,61 @@ 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 = + file_name_ + "/" + 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 = file_name_ + "/" + 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() { @@ -206,8 +208,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()); } } @@ -218,68 +221,97 @@ 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("./"); + // if root ns need to dive into folder + if (it.second.ns->components.size() == 0) + base_name_rel += file_name_ + "/"; + 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 './"; + // if root ns need to dive into folder + if (it.second.ns->components.size() == 0) code += file_name_ + "/"; + 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 = file_name_ + "/" + path + ".ts"; + symbolic_name = parser_.current_namespace_->components.back(); + } else { + inputpath = file_name_ + "/" + file_name_ + ".ts"; } - const std::string path = + const std::string bundlepath = GeneratedFileName(path_, file_name_, parser_.opts); - SaveFile(path.c_str(), code, false); + std::string cmd = "esbuild"; + cmd += " "; + cmd += inputpath; + // cmd += " --minify"; + cmd += " --bundle --outfile="; + cmd += bundlepath; + cmd += " --global-name="; + cmd += symbolic_name; + cmd += " --external:flatbuffers"; + if (system(cmd.c_str()) != 0) return false; } + return true; } // Generate a documentation comment, if available. @@ -714,28 +746,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.ts b/tests/my-game/example/ability.ts deleted file mode 100644 index 36b0eb8105d7..000000000000 --- 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 7cd2a85b682a..000000000000 --- 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 fb308fcdc612..000000000000 --- 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 98e559739d3c..000000000000 --- 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 7ca769f1ee5b..000000000000 --- 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 47bfb2511a15..000000000000 --- 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 f7bb94fe37f4..000000000000 --- 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/monster.js b/tests/my-game/example/monster.js deleted file mode 100644 index f9c8cca53334..000000000000 --- 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 d65b7c3a9ab0..000000000000 --- 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 74f51057abcb..000000000000 --- 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/referrable.ts b/tests/my-game/example/referrable.ts deleted file mode 100644 index ec02980037f3..000000000000 --- 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.ts b/tests/my-game/example/stat.ts deleted file mode 100644 index e45259950aa2..000000000000 --- 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 afe869fa7bde..000000000000 --- 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 09c79108fbea..000000000000 --- 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 0cb87ded5064..000000000000 --- 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 a31d011adfc9..000000000000 --- 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 86a19aa50463..000000000000 --- 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.ts b/tests/my-game/example/test.ts deleted file mode 100644 index b3d84eece954..000000000000 --- 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.ts b/tests/my-game/example/type-aliases.ts deleted file mode 100644 index 805c8cf3fcc1..000000000000 --- 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 82b2eab02c0f..000000000000 --- 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 3c692e28d6b7..000000000000 --- 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.ts b/tests/my-game/example2/monster.ts deleted file mode 100644 index 7240476bef6e..000000000000 --- 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.ts b/tests/my-game/in-parent-namespace.ts deleted file mode 100644 index 0de94df5e6c6..000000000000 --- 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 9105ed44f89d..000000000000 --- 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 918e238e0a98..000000000000 --- 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 4b10118e13cb..000000000000 --- 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 fca1668c46e8..000000000000 --- 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 5279fdbd57c0..000000000000 --- 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 b820bceacd6c..000000000000 --- 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 441ebf76c946..000000000000 --- 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 fe848e01f18b..000000000000 --- 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 9be34024c7e1..000000000000 --- 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 91bcc8569fd4..000000000000 --- 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 8e4d706bd242..000000000000 --- 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 d097a3c3b31f..000000000000 --- 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 7b924b8876d6..000000000000 --- 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 9d8cf3342db7..000000000000 --- 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 01f1bd4cfd28..000000000000 --- 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 7c8fd516d456..000000000000 --- 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.ts b/tests/optional_scalars/optional-byte.ts deleted file mode 100644 index 1db479f1a5bc..000000000000 --- 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.ts b/tests/optional_scalars/scalar-stuff.ts deleted file mode 100644 index 38d7cccb9931..000000000000 --- 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/JavaScriptTest.js b/tests/ts/JavaScriptTest.js index b76dd2ed5364..323be51c1e3b 100644 --- a/tests/ts/JavaScriptTest.js +++ b/tests/ts/JavaScriptTest.js @@ -3,12 +3,12 @@ import assert from 'assert' import fs from 'fs' import * as flatbuffers from 'flatbuffers' -import { Monster, MonsterT } from './my-game/example/monster.js' -import { Test, TestT } from './my-game/example/test.js' -import { Stat } from './my-game/example/stat.js' -import { Vec3 } from './my-game/example/vec3.js' -import { Color } from './my-game/example/color.js'; -import { Any } from './my-game/example/any.js'; +import { Monster, MonsterT } from './monster_test/my-game/example/monster.js' +import { Test, TestT } from './monster_test/my-game/example/test.js' +import { Stat } from './monster_test/my-game/example/stat.js' +import { Vec3 } from './monster_test/my-game/example/vec3.js' +import { Color } from './monster_test/my-game/example/color.js'; +import { Any } from './monster_test/my-game/example/any.js'; function main() { diff --git a/tests/ts/JavaScriptTestv1.cjs b/tests/ts/JavaScriptTestv1.cjs new file mode 100644 index 000000000000..6ca27275074a --- /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/JavaScriptUnionVectorTest.js b/tests/ts/JavaScriptUnionVectorTest.js index 18857d673af1..6af541981df2 100644 --- a/tests/ts/JavaScriptUnionVectorTest.js +++ b/tests/ts/JavaScriptUnionVectorTest.js @@ -1,10 +1,10 @@ import assert from 'assert' import * as flatbuffers from 'flatbuffers' -import { Character } from './union_vector/character.js' -import { BookReader, BookReaderT } from './union_vector/book-reader.js' -import { Attacker, AttackerT } from './union_vector/attacker.js' -import { Movie, MovieT } from './union_vector/movie.js' +import { Character } from './union_vector/union_vector/character.js' +import { BookReader, BookReaderT } from './union_vector/union_vector/book-reader.js' +import { Attacker, AttackerT } from './union_vector/union_vector/attacker.js' +import { Movie, MovieT } from './union_vector/union_vector/movie.js' var charTypes = [ Character.Belle, diff --git a/tests/ts/TypeScriptTest.py b/tests/ts/TypeScriptTest.py index 0b42bc638d56..7866a8e0f5e3 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"], schema="../union_vector/union_vector.fbs", prefix="union_vector", ) @@ -85,7 +85,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"], schema=[ "typescript_keywords.fbs", "test_dir/typescript_include.fbs", @@ -102,7 +102,6 @@ def flatc(options, schema, prefix=None, include=None, data=None, cwd=tests_path) "--gen-name-strings", "--gen-mutable", "--gen-object-api", - "--ts-flat-files", ], schema=[ "typescript_keywords.fbs", diff --git a/tests/ts/foobar/abc.js b/tests/ts/foobar/abc.js deleted file mode 100644 index cdef988d9415..000000000000 --- a/tests/ts/foobar/abc.js +++ /dev/null @@ -1,5 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify -export var Abc; -(function (Abc) { - Abc[Abc["a"] = 0] = "a"; -})(Abc || (Abc = {})); diff --git a/tests/ts/foobar/class.js b/tests/ts/foobar/class.js deleted file mode 100644 index e0e1df1bea24..000000000000 --- a/tests/ts/foobar/class.js +++ /dev/null @@ -1,5 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify -export var class_; -(function (class_) { - class_[class_["arguments_"] = 0] = "arguments_"; -})(class_ || (class_ = {})); diff --git a/tests/ts/monster_test.js b/tests/ts/monster_test.js index afc333eeb941..0c496195792e 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 './monster_test/table-a.js'; +export * as MyGame from './monster_test/my-game.js'; diff --git a/tests/ts/monster_test.ts b/tests/ts/monster_test.ts index afc333eeb941..ff0dff22d9b5 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 './monster_test/table-a.js'; +export * as MyGame from './monster_test/my-game.js'; diff --git a/tests/ts/monster_test/my-game.js b/tests/ts/monster_test/my-game.js new file mode 100644 index 000000000000..9db431c1604f --- /dev/null +++ b/tests/ts/monster_test/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/monster_test/my-game.ts b/tests/ts/monster_test/my-game.ts new file mode 100644 index 000000000000..017791646a57 --- /dev/null +++ b/tests/ts/monster_test/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/monster_test/my-game/example.js b/tests/ts/monster_test/my-game/example.js new file mode 100644 index 000000000000..e0236541d0c6 --- /dev/null +++ b/tests/ts/monster_test/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/monster_test/my-game/example.ts b/tests/ts/monster_test/my-game/example.ts new file mode 100644 index 000000000000..fbfb45d5e514 --- /dev/null +++ b/tests/ts/monster_test/my-game/example.ts @@ -0,0 +1,18 @@ +// 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/my-game/example/ability.js b/tests/ts/monster_test/my-game/example/ability.js similarity index 100% rename from tests/my-game/example/ability.js rename to tests/ts/monster_test/my-game/example/ability.js diff --git a/tests/ts/my-game/example/ability.ts b/tests/ts/monster_test/my-game/example/ability.ts similarity index 100% rename from tests/ts/my-game/example/ability.ts rename to tests/ts/monster_test/my-game/example/ability.ts diff --git a/tests/ts/my-game/example/any-ambiguous-aliases.js b/tests/ts/monster_test/my-game/example/any-ambiguous-aliases.js similarity index 93% rename from tests/ts/my-game/example/any-ambiguous-aliases.js rename to tests/ts/monster_test/my-game/example/any-ambiguous-aliases.js index ca8190848af6..7d379dc76406 100644 --- a/tests/ts/my-game/example/any-ambiguous-aliases.js +++ b/tests/ts/monster_test/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-ambiguous-aliases.ts b/tests/ts/monster_test/my-game/example/any-ambiguous-aliases.ts similarity index 100% rename from tests/ts/my-game/example/any-ambiguous-aliases.ts rename to tests/ts/monster_test/my-game/example/any-ambiguous-aliases.ts diff --git a/tests/ts/my-game/example/any-unique-aliases.js b/tests/ts/monster_test/my-game/example/any-unique-aliases.js similarity index 95% rename from tests/ts/my-game/example/any-unique-aliases.js rename to tests/ts/monster_test/my-game/example/any-unique-aliases.js index d1ac6bff1aba..a7fa2c02c238 100644 --- a/tests/ts/my-game/example/any-unique-aliases.js +++ b/tests/ts/monster_test/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-unique-aliases.ts b/tests/ts/monster_test/my-game/example/any-unique-aliases.ts similarity index 100% rename from tests/ts/my-game/example/any-unique-aliases.ts rename to tests/ts/monster_test/my-game/example/any-unique-aliases.ts diff --git a/tests/ts/my-game/example/any.js b/tests/ts/monster_test/my-game/example/any.js similarity index 97% rename from tests/ts/my-game/example/any.js rename to tests/ts/monster_test/my-game/example/any.js index 27be8f40809f..2b1c0184d276 100644 --- a/tests/ts/my-game/example/any.js +++ b/tests/ts/monster_test/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/any.ts b/tests/ts/monster_test/my-game/example/any.ts similarity index 100% rename from tests/ts/my-game/example/any.ts rename to tests/ts/monster_test/my-game/example/any.ts diff --git a/tests/my-game/example/color.js b/tests/ts/monster_test/my-game/example/color.js similarity index 92% rename from tests/my-game/example/color.js rename to tests/ts/monster_test/my-game/example/color.js index f95f75e9677d..0a057ccf64a6 100644 --- a/tests/my-game/example/color.js +++ b/tests/ts/monster_test/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/my-game/example/color.ts b/tests/ts/monster_test/my-game/example/color.ts similarity index 100% rename from tests/my-game/example/color.ts rename to tests/ts/monster_test/my-game/example/color.ts diff --git a/tests/ts/my-game/example/long-enum.js b/tests/ts/monster_test/my-game/example/long-enum.js similarity index 83% rename from tests/ts/my-game/example/long-enum.js rename to tests/ts/monster_test/my-game/example/long-enum.js index 040d8a672f94..0180c2bdf96a 100644 --- a/tests/ts/my-game/example/long-enum.js +++ b/tests/ts/monster_test/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/my-game/example/long-enum.ts b/tests/ts/monster_test/my-game/example/long-enum.ts similarity index 100% rename from tests/my-game/example/long-enum.ts rename to tests/ts/monster_test/my-game/example/long-enum.ts diff --git a/tests/ts/my-game/example/monster.js b/tests/ts/monster_test/my-game/example/monster.js similarity index 100% rename from tests/ts/my-game/example/monster.js rename to tests/ts/monster_test/my-game/example/monster.js diff --git a/tests/ts/my-game/example/monster.ts b/tests/ts/monster_test/my-game/example/monster.ts similarity index 100% rename from tests/ts/my-game/example/monster.ts rename to tests/ts/monster_test/my-game/example/monster.ts diff --git a/tests/ts/my-game/example/race.js b/tests/ts/monster_test/my-game/example/race.js similarity index 88% rename from tests/ts/my-game/example/race.js rename to tests/ts/monster_test/my-game/example/race.js index 74f51057abcb..11c7a41ecf46 100644 --- a/tests/ts/my-game/example/race.js +++ b/tests/ts/monster_test/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/my-game/example/race.ts b/tests/ts/monster_test/my-game/example/race.ts similarity index 100% rename from tests/my-game/example/race.ts rename to tests/ts/monster_test/my-game/example/race.ts diff --git a/tests/my-game/example/referrable.js b/tests/ts/monster_test/my-game/example/referrable.js similarity index 100% rename from tests/my-game/example/referrable.js rename to tests/ts/monster_test/my-game/example/referrable.js diff --git a/tests/ts/my-game/example/referrable.ts b/tests/ts/monster_test/my-game/example/referrable.ts similarity index 100% rename from tests/ts/my-game/example/referrable.ts rename to tests/ts/monster_test/my-game/example/referrable.ts diff --git a/tests/my-game/example/stat.js b/tests/ts/monster_test/my-game/example/stat.js similarity index 100% rename from tests/my-game/example/stat.js rename to tests/ts/monster_test/my-game/example/stat.js diff --git a/tests/ts/my-game/example/stat.ts b/tests/ts/monster_test/my-game/example/stat.ts similarity index 100% rename from tests/ts/my-game/example/stat.ts rename to tests/ts/monster_test/my-game/example/stat.ts diff --git a/tests/ts/my-game/example/struct-of-structs-of-structs.js b/tests/ts/monster_test/my-game/example/struct-of-structs-of-structs.js similarity index 60% rename from tests/ts/my-game/example/struct-of-structs-of-structs.js rename to tests/ts/monster_test/my-game/example/struct-of-structs-of-structs.js index a5fbc66dce69..151be475130a 100644 --- a/tests/ts/my-game/example/struct-of-structs-of-structs.js +++ b/tests/ts/monster_test/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-of-structs.ts b/tests/ts/monster_test/my-game/example/struct-of-structs-of-structs.ts similarity index 100% rename from tests/ts/my-game/example/struct-of-structs-of-structs.ts rename to tests/ts/monster_test/my-game/example/struct-of-structs-of-structs.ts diff --git a/tests/ts/my-game/example/struct-of-structs.js b/tests/ts/monster_test/my-game/example/struct-of-structs.js similarity index 71% rename from tests/ts/my-game/example/struct-of-structs.js rename to tests/ts/monster_test/my-game/example/struct-of-structs.js index 66aadc8e5436..f494c0f3c5dc 100644 --- a/tests/ts/my-game/example/struct-of-structs.js +++ b/tests/ts/monster_test/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/struct-of-structs.ts b/tests/ts/monster_test/my-game/example/struct-of-structs.ts similarity index 100% rename from tests/ts/my-game/example/struct-of-structs.ts rename to tests/ts/monster_test/my-game/example/struct-of-structs.ts diff --git a/tests/ts/my-game/example/test-simple-table-with-enum.js b/tests/ts/monster_test/my-game/example/test-simple-table-with-enum.js similarity index 100% rename from tests/ts/my-game/example/test-simple-table-with-enum.js rename to tests/ts/monster_test/my-game/example/test-simple-table-with-enum.js diff --git a/tests/ts/my-game/example/test-simple-table-with-enum.ts b/tests/ts/monster_test/my-game/example/test-simple-table-with-enum.ts similarity index 100% rename from tests/ts/my-game/example/test-simple-table-with-enum.ts rename to tests/ts/monster_test/my-game/example/test-simple-table-with-enum.ts diff --git a/tests/my-game/example/test.js b/tests/ts/monster_test/my-game/example/test.js similarity index 100% rename from tests/my-game/example/test.js rename to tests/ts/monster_test/my-game/example/test.js diff --git a/tests/ts/my-game/example/test.ts b/tests/ts/monster_test/my-game/example/test.ts similarity index 100% rename from tests/ts/my-game/example/test.ts rename to tests/ts/monster_test/my-game/example/test.ts diff --git a/tests/my-game/example/type-aliases.js b/tests/ts/monster_test/my-game/example/type-aliases.js similarity index 100% rename from tests/my-game/example/type-aliases.js rename to tests/ts/monster_test/my-game/example/type-aliases.js diff --git a/tests/ts/my-game/example/type-aliases.ts b/tests/ts/monster_test/my-game/example/type-aliases.ts similarity index 100% rename from tests/ts/my-game/example/type-aliases.ts rename to tests/ts/monster_test/my-game/example/type-aliases.ts diff --git a/tests/ts/my-game/example/vec3.js b/tests/ts/monster_test/my-game/example/vec3.js similarity index 91% rename from tests/ts/my-game/example/vec3.js rename to tests/ts/monster_test/my-game/example/vec3.js index cae64eb5557f..edf93f1abfff 100644 --- a/tests/ts/my-game/example/vec3.js +++ b/tests/ts/monster_test/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/ts/my-game/example/vec3.ts b/tests/ts/monster_test/my-game/example/vec3.ts similarity index 100% rename from tests/ts/my-game/example/vec3.ts rename to tests/ts/monster_test/my-game/example/vec3.ts diff --git a/tests/ts/monster_test/my-game/example2.js b/tests/ts/monster_test/my-game/example2.js new file mode 100644 index 000000000000..edab044cadd0 --- /dev/null +++ b/tests/ts/monster_test/my-game/example2.js @@ -0,0 +1,2 @@ +// automatically generated by the FlatBuffers compiler, do not modify +export { Monster } from './example2/monster.js'; diff --git a/tests/ts/monster_test/my-game/example2.ts b/tests/ts/monster_test/my-game/example2.ts new file mode 100644 index 000000000000..faf5b6381fbd --- /dev/null +++ b/tests/ts/monster_test/my-game/example2.ts @@ -0,0 +1,3 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +export { Monster } from './example2/monster.js'; diff --git a/tests/my-game/example2/monster.js b/tests/ts/monster_test/my-game/example2/monster.js similarity index 100% rename from tests/my-game/example2/monster.js rename to tests/ts/monster_test/my-game/example2/monster.js diff --git a/tests/ts/my-game/example2/monster.ts b/tests/ts/monster_test/my-game/example2/monster.ts similarity index 100% rename from tests/ts/my-game/example2/monster.ts rename to tests/ts/monster_test/my-game/example2/monster.ts diff --git a/tests/my-game/in-parent-namespace.js b/tests/ts/monster_test/my-game/in-parent-namespace.js similarity index 100% rename from tests/my-game/in-parent-namespace.js rename to tests/ts/monster_test/my-game/in-parent-namespace.js diff --git a/tests/ts/my-game/in-parent-namespace.ts b/tests/ts/monster_test/my-game/in-parent-namespace.ts similarity index 100% rename from tests/ts/my-game/in-parent-namespace.ts rename to tests/ts/monster_test/my-game/in-parent-namespace.ts diff --git a/tests/ts/monster_test/my-game/other-name-space.js b/tests/ts/monster_test/my-game/other-name-space.js new file mode 100644 index 000000000000..12e8e5a6a225 --- /dev/null +++ b/tests/ts/monster_test/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/monster_test/my-game/other-name-space.ts b/tests/ts/monster_test/my-game/other-name-space.ts new file mode 100644 index 000000000000..ea4a261ff05a --- /dev/null +++ b/tests/ts/monster_test/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/monster_test/my-game/other-name-space/from-include.js b/tests/ts/monster_test/my-game/other-name-space/from-include.js new file mode 100644 index 000000000000..c6e6d08339a0 --- /dev/null +++ b/tests/ts/monster_test/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/namespace_test/namespace-a/namespace-b/enum-in-nested-n-s.ts b/tests/ts/monster_test/my-game/other-name-space/from-include.ts similarity index 57% rename from tests/namespace_test/namespace-a/namespace-b/enum-in-nested-n-s.ts rename to tests/ts/monster_test/my-game/other-name-space/from-include.ts index 676b7e43ddc8..bdc066d5fe9c 100644 --- a/tests/namespace_test/namespace-a/namespace-b/enum-in-nested-n-s.ts +++ b/tests/ts/monster_test/my-game/other-name-space/from-include.ts @@ -1,8 +1,5 @@ // automatically generated by the FlatBuffers compiler, do not modify -export enum EnumInNestedNS{ - A = 0, - B = 1, - C = 2 +export enum FromInclude { + IncludeVal = '0' } - diff --git a/tests/ts/monster_test/my-game/other-name-space/table-b.js b/tests/ts/monster_test/my-game/other-name-space/table-b.js new file mode 100644 index 000000000000..464ab3e24a49 --- /dev/null +++ b/tests/ts/monster_test/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/monster_test/my-game/other-name-space/table-b.ts b/tests/ts/monster_test/my-game/other-name-space/table-b.ts new file mode 100644 index 000000000000..af01cd259108 --- /dev/null +++ b/tests/ts/monster_test/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/monster_test/my-game/other-name-space/unused.js similarity index 57% rename from tests/union_vector/rapunzel.js rename to tests/ts/monster_test/my-game/other-name-space/unused.js index 67a5e4453b3e..829454dbef4b 100644 --- a/tests/union_vector/rapunzel.js +++ b/tests/ts/monster_test/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/monster_test/my-game/other-name-space/unused.ts similarity index 50% rename from tests/union_vector/rapunzel.ts rename to tests/ts/monster_test/my-game/other-name-space/unused.ts index e1dc63ddf549..20802df7ee98 100644 --- a/tests/union_vector/rapunzel.ts +++ b/tests/ts/monster_test/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/monster_test/table-a.js b/tests/ts/monster_test/table-a.js new file mode 100644 index 000000000000..f0ade0dd6f07 --- /dev/null +++ b/tests/ts/monster_test/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/monster_test/table-a.ts b/tests/ts/monster_test/table-a.ts new file mode 100644 index 000000000000..5ed4b315c452 --- /dev/null +++ b/tests/ts/monster_test/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/monster_test_generated.ts b/tests/ts/monster_test_generated.ts index 18aec071fbbe..47503002b58d 100644 --- a/tests/ts/monster_test_generated.ts +++ b/tests/ts/monster_test_generated.ts @@ -1,19 +1,2219 @@ -// 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'; +"use strict"; +var Example = (() => { + 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 __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, { + get: (a, b) => (typeof require !== "undefined" ? require : a)[b] + }) : x)(function(x) { + if (typeof require !== "undefined") + return require.apply(this, arguments); + throw new Error('Dynamic require of "' + x + '" is not supported'); + }); + 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); + + // monster_test/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 + }); + + // monster_test/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); + } + }; + + // monster_test/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); + } + }; + + // monster_test/my-game/example/monster.js + var flatbuffers6 = __toESM(__require("flatbuffers"), 1); + + // monster_test/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; + } + } + + // monster_test/my-game/example/test-simple-table-with-enum.js + var flatbuffers2 = __toESM(__require("flatbuffers"), 1); + + // monster_test/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 = {})); + + // monster_test/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); + } + }; + + // monster_test/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; + } + } + + // monster_test/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 = {})); + + // monster_test/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); + } + }; + + // monster_test/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); + } + }; + + // monster_test/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); + } + }; + + // monster_test/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); + } + }; + + // monster_test/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); + } + }; + + // monster_test/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; + } + 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, 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 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()); + } + 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(); + } + }; + 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")) { + 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 = 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); + return Monster2.endMonster(builder); + } + }; + + // monster_test/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; + } + } + + // monster_test/my-game/example/long-enum.js + var LongEnum; + (function(LongEnum2) { + LongEnum2["LongOne"] = "2"; + LongEnum2["LongTwo"] = "4"; + LongEnum2["LongBig"] = "1099511627776"; + })(LongEnum = LongEnum || (LongEnum = {})); + + // monster_test/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); + } + }; + + // monster_test/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); + } + }; + + // monster_test/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); + } + }; + return __toCommonJS(example_exports); +})(); diff --git a/tests/ts/monster_test_grpc.d.ts b/tests/ts/monster_test_grpc.d.ts deleted file mode 100644 index e7a71d1a9d2c..000000000000 --- 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 34f8cb22ea55..000000000000 --- 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/example/ability.js b/tests/ts/my-game/example/ability.js deleted file mode 100644 index 4d7d3db72907..000000000000 --- a/tests/ts/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/ts/my-game/example/color.js b/tests/ts/my-game/example/color.js deleted file mode 100644 index f95f75e9677d..000000000000 --- a/tests/ts/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/ts/my-game/example/color.ts b/tests/ts/my-game/example/color.ts deleted file mode 100644 index 8ce58da67874..000000000000 --- a/tests/ts/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/ts/my-game/example/long-enum.ts b/tests/ts/my-game/example/long-enum.ts deleted file mode 100644 index 31ea18805f28..000000000000 --- a/tests/ts/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/ts/my-game/example/race.ts b/tests/ts/my-game/example/race.ts deleted file mode 100644 index 8cb9654ae30f..000000000000 --- a/tests/ts/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/ts/my-game/example/referrable.js b/tests/ts/my-game/example/referrable.js deleted file mode 100644 index 367034b06447..000000000000 --- a/tests/ts/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/ts/my-game/example/stat.js b/tests/ts/my-game/example/stat.js deleted file mode 100644 index 43b569f4e36d..000000000000 --- a/tests/ts/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/ts/my-game/example/test.js b/tests/ts/my-game/example/test.js deleted file mode 100644 index 9c43619e2109..000000000000 --- a/tests/ts/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/ts/my-game/example/type-aliases.js b/tests/ts/my-game/example/type-aliases.js deleted file mode 100644 index a4b5f89e3f54..000000000000 --- a/tests/ts/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/ts/my-game/example2/monster.js b/tests/ts/my-game/example2/monster.js deleted file mode 100644 index f50a2c85afdf..000000000000 --- a/tests/ts/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/ts/my-game/in-parent-namespace.js b/tests/ts/my-game/in-parent-namespace.js deleted file mode 100644 index 24b0ed787834..000000000000 --- a/tests/ts/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/ts/optional_scalars.ts b/tests/ts/optional_scalars.ts deleted file mode 100644 index 6d9830c022bf..000000000000 --- a/tests/ts/optional_scalars.ts +++ /dev/null @@ -1 +0,0 @@ -export { OptionalByte } from './optional-scalars/optional-byte'; diff --git a/tests/ts/optional_scalars/optional-scalars.js b/tests/ts/optional_scalars/optional-scalars.js new file mode 100644 index 000000000000..f930bbb4ce61 --- /dev/null +++ b/tests/ts/optional_scalars/optional-scalars.js @@ -0,0 +1,3 @@ +// automatically generated by the FlatBuffers compiler, do not modify +export { OptionalByte } from './optional-scalars/optional-byte.js'; +export { ScalarStuff } from './optional-scalars/scalar-stuff.js'; diff --git a/tests/ts/optional_scalars_generated.ts b/tests/ts/optional_scalars/optional-scalars.ts similarity index 100% rename from tests/ts/optional_scalars_generated.ts rename to tests/ts/optional_scalars/optional-scalars.ts diff --git a/tests/optional_scalars/optional-byte.js b/tests/ts/optional_scalars/optional-scalars/optional-byte.js similarity index 83% rename from tests/optional_scalars/optional-byte.js rename to tests/ts/optional_scalars/optional-scalars/optional-byte.js index 8257f93a460f..8b998708e7aa 100644 --- a/tests/optional_scalars/optional-byte.js +++ b/tests/ts/optional_scalars/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/optional-scalars/optional-byte.ts b/tests/ts/optional_scalars/optional-scalars/optional-byte.ts similarity index 100% rename from tests/optional-scalars/optional-byte.ts rename to tests/ts/optional_scalars/optional-scalars/optional-byte.ts diff --git a/tests/optional_scalars/scalar-stuff.js b/tests/ts/optional_scalars/optional-scalars/scalar-stuff.js similarity index 98% rename from tests/optional_scalars/scalar-stuff.js rename to tests/ts/optional_scalars/optional-scalars/scalar-stuff.js index f02b885ad6d4..cc0b8b45f196 100644 --- a/tests/optional_scalars/scalar-stuff.js +++ b/tests/ts/optional_scalars/optional-scalars/scalar-stuff.js @@ -1,6 +1,6 @@ // automatically generated by the FlatBuffers compiler, do not modify import * as flatbuffers from 'flatbuffers'; -import { OptionalByte } from '../optional_scalars/optional-byte'; +import { OptionalByte } from '../optional-scalars/optional-byte.js'; export class ScalarStuff { constructor() { this.bb = null; @@ -165,6 +165,9 @@ export class ScalarStuff { const offset = this.bb.__offset(this.bb_pos, 74); return offset ? this.bb.readInt8(this.bb_pos + offset) : OptionalByte.One; } + static getFullyQualifiedName() { + return 'optional_scalars_ScalarStuff'; + } static startScalarStuff(builder) { builder.startObject(36); } diff --git a/tests/ts/optional-scalars/scalar-stuff.ts b/tests/ts/optional_scalars/optional-scalars/scalar-stuff.ts similarity index 100% rename from tests/ts/optional-scalars/scalar-stuff.ts rename to tests/ts/optional_scalars/optional-scalars/scalar-stuff.ts diff --git a/tests/ts/reflection/base-type.js b/tests/ts/reflection/base-type.js deleted file mode 100644 index dccd0ac9e571..000000000000 --- a/tests/ts/reflection/base-type.js +++ /dev/null @@ -1,23 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify -export var BaseType; -(function (BaseType) { - BaseType[BaseType["None"] = 0] = "None"; - BaseType[BaseType["UType"] = 1] = "UType"; - BaseType[BaseType["Bool"] = 2] = "Bool"; - BaseType[BaseType["Byte"] = 3] = "Byte"; - BaseType[BaseType["UByte"] = 4] = "UByte"; - BaseType[BaseType["Short"] = 5] = "Short"; - BaseType[BaseType["UShort"] = 6] = "UShort"; - BaseType[BaseType["Int"] = 7] = "Int"; - BaseType[BaseType["UInt"] = 8] = "UInt"; - BaseType[BaseType["Long"] = 9] = "Long"; - BaseType[BaseType["ULong"] = 10] = "ULong"; - BaseType[BaseType["Float"] = 11] = "Float"; - BaseType[BaseType["Double"] = 12] = "Double"; - BaseType[BaseType["String"] = 13] = "String"; - BaseType[BaseType["Vector"] = 14] = "Vector"; - BaseType[BaseType["Obj"] = 15] = "Obj"; - BaseType[BaseType["Union"] = 16] = "Union"; - BaseType[BaseType["Array"] = 17] = "Array"; - BaseType[BaseType["MaxBaseType"] = 18] = "MaxBaseType"; -})(BaseType || (BaseType = {})); diff --git a/tests/ts/reflection/enum-val.js b/tests/ts/reflection/enum-val.js deleted file mode 100644 index f2ce03d1f11d..000000000000 --- a/tests/ts/reflection/enum-val.js +++ /dev/null @@ -1,110 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify -import * as flatbuffers from 'flatbuffers'; -import { Type } from '../reflection/type.js'; -export class EnumVal { - constructor() { - this.bb = null; - this.bb_pos = 0; - } - __init(i, bb) { - this.bb_pos = i; - this.bb = bb; - return this; - } - static getRootAsEnumVal(bb, obj) { - return (obj || new EnumVal()).__init(bb.readInt32(bb.position()) + bb.position(), bb); - } - static getSizePrefixedRootAsEnumVal(bb, obj) { - bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); - return (obj || new EnumVal()).__init(bb.readInt32(bb.position()) + bb.position(), bb); - } - name(optionalEncoding) { - const offset = this.bb.__offset(this.bb_pos, 4); - return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null; - } - value() { - const offset = this.bb.__offset(this.bb_pos, 6); - return offset ? this.bb.readInt64(this.bb_pos + offset) : BigInt('0'); - } - mutate_value(value) { - const offset = this.bb.__offset(this.bb_pos, 6); - if (offset === 0) { - return false; - } - this.bb.writeInt64(this.bb_pos + offset, value); - return true; - } - unionType(obj) { - const offset = this.bb.__offset(this.bb_pos, 10); - return offset ? (obj || new Type()).__init(this.bb.__indirect(this.bb_pos + offset), this.bb) : null; - } - documentation(index, optionalEncoding) { - const offset = this.bb.__offset(this.bb_pos, 12); - return offset ? this.bb.__string(this.bb.__vector(this.bb_pos + offset) + index * 4, optionalEncoding) : null; - } - documentationLength() { - const offset = this.bb.__offset(this.bb_pos, 12); - return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; - } - static getFullyQualifiedName() { - return 'reflection_EnumVal'; - } - static startEnumVal(builder) { - builder.startObject(5); - } - static addName(builder, nameOffset) { - builder.addFieldOffset(0, nameOffset, 0); - } - static addValue(builder, value) { - builder.addFieldInt64(1, value, BigInt('0')); - } - static addUnionType(builder, unionTypeOffset) { - builder.addFieldOffset(3, unionTypeOffset, 0); - } - static addDocumentation(builder, documentationOffset) { - builder.addFieldOffset(4, documentationOffset, 0); - } - static createDocumentationVector(builder, data) { - builder.startVector(4, data.length, 4); - for (let i = data.length - 1; i >= 0; i--) { - builder.addOffset(data[i]); - } - return builder.endVector(); - } - static startDocumentationVector(builder, numElems) { - builder.startVector(4, numElems, 4); - } - static endEnumVal(builder) { - const offset = builder.endObject(); - builder.requiredField(offset, 4); // name - return offset; - } - unpack() { - return new EnumValT(this.name(), this.value(), (this.unionType() !== null ? this.unionType().unpack() : null), this.bb.createScalarList(this.documentation.bind(this), this.documentationLength())); - } - unpackTo(_o) { - _o.name = this.name(); - _o.value = this.value(); - _o.unionType = (this.unionType() !== null ? this.unionType().unpack() : null); - _o.documentation = this.bb.createScalarList(this.documentation.bind(this), this.documentationLength()); - } -} -export class EnumValT { - constructor(name = null, value = BigInt('0'), unionType = null, documentation = []) { - this.name = name; - this.value = value; - this.unionType = unionType; - this.documentation = documentation; - } - pack(builder) { - const name = (this.name !== null ? builder.createString(this.name) : 0); - const unionType = (this.unionType !== null ? this.unionType.pack(builder) : 0); - const documentation = EnumVal.createDocumentationVector(builder, builder.createObjectOffsetList(this.documentation)); - EnumVal.startEnumVal(builder); - EnumVal.addName(builder, name); - EnumVal.addValue(builder, this.value); - EnumVal.addUnionType(builder, unionType); - EnumVal.addDocumentation(builder, documentation); - return EnumVal.endEnumVal(builder); - } -} diff --git a/tests/ts/reflection/enum.js b/tests/ts/reflection/enum.js deleted file mode 100644 index 49393072b395..000000000000 --- a/tests/ts/reflection/enum.js +++ /dev/null @@ -1,175 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify -import * as flatbuffers from 'flatbuffers'; -import { EnumVal } from '../reflection/enum-val.js'; -import { KeyValue } from '../reflection/key-value.js'; -import { Type } from '../reflection/type.js'; -export class Enum { - constructor() { - this.bb = null; - this.bb_pos = 0; - } - __init(i, bb) { - this.bb_pos = i; - this.bb = bb; - return this; - } - static getRootAsEnum(bb, obj) { - return (obj || new Enum()).__init(bb.readInt32(bb.position()) + bb.position(), bb); - } - static getSizePrefixedRootAsEnum(bb, obj) { - bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); - return (obj || new Enum()).__init(bb.readInt32(bb.position()) + bb.position(), bb); - } - name(optionalEncoding) { - const offset = this.bb.__offset(this.bb_pos, 4); - return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null; - } - values(index, obj) { - const offset = this.bb.__offset(this.bb_pos, 6); - return offset ? (obj || new EnumVal()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4), this.bb) : null; - } - valuesLength() { - const offset = this.bb.__offset(this.bb_pos, 6); - return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; - } - isUnion() { - const offset = this.bb.__offset(this.bb_pos, 8); - return offset ? !!this.bb.readInt8(this.bb_pos + offset) : false; - } - mutate_is_union(value) { - const offset = this.bb.__offset(this.bb_pos, 8); - if (offset === 0) { - return false; - } - this.bb.writeInt8(this.bb_pos + offset, +value); - return true; - } - underlyingType(obj) { - const offset = this.bb.__offset(this.bb_pos, 10); - return offset ? (obj || new Type()).__init(this.bb.__indirect(this.bb_pos + offset), this.bb) : null; - } - attributes(index, obj) { - const offset = this.bb.__offset(this.bb_pos, 12); - return offset ? (obj || new KeyValue()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4), this.bb) : null; - } - attributesLength() { - const offset = this.bb.__offset(this.bb_pos, 12); - return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; - } - documentation(index, optionalEncoding) { - const offset = this.bb.__offset(this.bb_pos, 14); - return offset ? this.bb.__string(this.bb.__vector(this.bb_pos + offset) + index * 4, optionalEncoding) : null; - } - documentationLength() { - const offset = this.bb.__offset(this.bb_pos, 14); - return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; - } - declarationFile(optionalEncoding) { - const offset = this.bb.__offset(this.bb_pos, 16); - return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null; - } - static getFullyQualifiedName() { - return 'reflection_Enum'; - } - static startEnum(builder) { - builder.startObject(7); - } - static addName(builder, nameOffset) { - builder.addFieldOffset(0, nameOffset, 0); - } - static addValues(builder, valuesOffset) { - builder.addFieldOffset(1, valuesOffset, 0); - } - static createValuesVector(builder, data) { - builder.startVector(4, data.length, 4); - for (let i = data.length - 1; i >= 0; i--) { - builder.addOffset(data[i]); - } - return builder.endVector(); - } - static startValuesVector(builder, numElems) { - builder.startVector(4, numElems, 4); - } - static addIsUnion(builder, isUnion) { - builder.addFieldInt8(2, +isUnion, +false); - } - static addUnderlyingType(builder, underlyingTypeOffset) { - builder.addFieldOffset(3, underlyingTypeOffset, 0); - } - static addAttributes(builder, attributesOffset) { - builder.addFieldOffset(4, attributesOffset, 0); - } - static createAttributesVector(builder, data) { - builder.startVector(4, data.length, 4); - for (let i = data.length - 1; i >= 0; i--) { - builder.addOffset(data[i]); - } - return builder.endVector(); - } - static startAttributesVector(builder, numElems) { - builder.startVector(4, numElems, 4); - } - static addDocumentation(builder, documentationOffset) { - builder.addFieldOffset(5, documentationOffset, 0); - } - static createDocumentationVector(builder, data) { - builder.startVector(4, data.length, 4); - for (let i = data.length - 1; i >= 0; i--) { - builder.addOffset(data[i]); - } - return builder.endVector(); - } - static startDocumentationVector(builder, numElems) { - builder.startVector(4, numElems, 4); - } - static addDeclarationFile(builder, declarationFileOffset) { - builder.addFieldOffset(6, declarationFileOffset, 0); - } - static endEnum(builder) { - const offset = builder.endObject(); - builder.requiredField(offset, 4); // name - builder.requiredField(offset, 6); // values - builder.requiredField(offset, 10); // underlying_type - return offset; - } - unpack() { - return new EnumT(this.name(), this.bb.createObjList(this.values.bind(this), this.valuesLength()), this.isUnion(), (this.underlyingType() !== null ? this.underlyingType().unpack() : null), this.bb.createObjList(this.attributes.bind(this), this.attributesLength()), this.bb.createScalarList(this.documentation.bind(this), this.documentationLength()), this.declarationFile()); - } - unpackTo(_o) { - _o.name = this.name(); - _o.values = this.bb.createObjList(this.values.bind(this), this.valuesLength()); - _o.isUnion = this.isUnion(); - _o.underlyingType = (this.underlyingType() !== null ? this.underlyingType().unpack() : null); - _o.attributes = this.bb.createObjList(this.attributes.bind(this), this.attributesLength()); - _o.documentation = this.bb.createScalarList(this.documentation.bind(this), this.documentationLength()); - _o.declarationFile = this.declarationFile(); - } -} -export class EnumT { - constructor(name = null, values = [], isUnion = false, underlyingType = null, attributes = [], documentation = [], declarationFile = null) { - this.name = name; - this.values = values; - this.isUnion = isUnion; - this.underlyingType = underlyingType; - this.attributes = attributes; - this.documentation = documentation; - this.declarationFile = declarationFile; - } - pack(builder) { - const name = (this.name !== null ? builder.createString(this.name) : 0); - const values = Enum.createValuesVector(builder, builder.createObjectOffsetList(this.values)); - const underlyingType = (this.underlyingType !== null ? this.underlyingType.pack(builder) : 0); - const attributes = Enum.createAttributesVector(builder, builder.createObjectOffsetList(this.attributes)); - const documentation = Enum.createDocumentationVector(builder, builder.createObjectOffsetList(this.documentation)); - const declarationFile = (this.declarationFile !== null ? builder.createString(this.declarationFile) : 0); - Enum.startEnum(builder); - Enum.addName(builder, name); - Enum.addValues(builder, values); - Enum.addIsUnion(builder, this.isUnion); - Enum.addUnderlyingType(builder, underlyingType); - Enum.addAttributes(builder, attributes); - Enum.addDocumentation(builder, documentation); - Enum.addDeclarationFile(builder, declarationFile); - return Enum.endEnum(builder); - } -} diff --git a/tests/ts/reflection/field.js b/tests/ts/reflection/field.js deleted file mode 100644 index 107b77bf0d58..000000000000 --- a/tests/ts/reflection/field.js +++ /dev/null @@ -1,284 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify -import * as flatbuffers from 'flatbuffers'; -import { KeyValue } from '../reflection/key-value.js'; -import { Type } from '../reflection/type.js'; -export class Field { - constructor() { - this.bb = null; - this.bb_pos = 0; - } - __init(i, bb) { - this.bb_pos = i; - this.bb = bb; - return this; - } - static getRootAsField(bb, obj) { - return (obj || new Field()).__init(bb.readInt32(bb.position()) + bb.position(), bb); - } - static getSizePrefixedRootAsField(bb, obj) { - bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); - return (obj || new Field()).__init(bb.readInt32(bb.position()) + bb.position(), bb); - } - name(optionalEncoding) { - const offset = this.bb.__offset(this.bb_pos, 4); - return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null; - } - type(obj) { - const offset = this.bb.__offset(this.bb_pos, 6); - return offset ? (obj || new Type()).__init(this.bb.__indirect(this.bb_pos + offset), this.bb) : null; - } - id() { - const offset = this.bb.__offset(this.bb_pos, 8); - return offset ? this.bb.readUint16(this.bb_pos + offset) : 0; - } - mutate_id(value) { - const offset = this.bb.__offset(this.bb_pos, 8); - if (offset === 0) { - return false; - } - this.bb.writeUint16(this.bb_pos + offset, value); - return true; - } - offset() { - const offset = this.bb.__offset(this.bb_pos, 10); - return offset ? this.bb.readUint16(this.bb_pos + offset) : 0; - } - mutate_offset(value) { - const offset = this.bb.__offset(this.bb_pos, 10); - if (offset === 0) { - return false; - } - this.bb.writeUint16(this.bb_pos + offset, value); - return true; - } - defaultInteger() { - const offset = this.bb.__offset(this.bb_pos, 12); - return offset ? this.bb.readInt64(this.bb_pos + offset) : BigInt('0'); - } - mutate_default_integer(value) { - const offset = this.bb.__offset(this.bb_pos, 12); - if (offset === 0) { - return false; - } - this.bb.writeInt64(this.bb_pos + offset, value); - return true; - } - defaultReal() { - const offset = this.bb.__offset(this.bb_pos, 14); - return offset ? this.bb.readFloat64(this.bb_pos + offset) : 0.0; - } - mutate_default_real(value) { - const offset = this.bb.__offset(this.bb_pos, 14); - if (offset === 0) { - return false; - } - this.bb.writeFloat64(this.bb_pos + offset, value); - return true; - } - deprecated() { - const offset = this.bb.__offset(this.bb_pos, 16); - return offset ? !!this.bb.readInt8(this.bb_pos + offset) : false; - } - mutate_deprecated(value) { - const offset = this.bb.__offset(this.bb_pos, 16); - if (offset === 0) { - return false; - } - this.bb.writeInt8(this.bb_pos + offset, +value); - return true; - } - required() { - const offset = this.bb.__offset(this.bb_pos, 18); - return offset ? !!this.bb.readInt8(this.bb_pos + offset) : false; - } - mutate_required(value) { - const offset = this.bb.__offset(this.bb_pos, 18); - if (offset === 0) { - return false; - } - this.bb.writeInt8(this.bb_pos + offset, +value); - return true; - } - key() { - const offset = this.bb.__offset(this.bb_pos, 20); - return offset ? !!this.bb.readInt8(this.bb_pos + offset) : false; - } - mutate_key(value) { - const offset = this.bb.__offset(this.bb_pos, 20); - if (offset === 0) { - return false; - } - this.bb.writeInt8(this.bb_pos + offset, +value); - return true; - } - attributes(index, obj) { - const offset = this.bb.__offset(this.bb_pos, 22); - return offset ? (obj || new KeyValue()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4), this.bb) : null; - } - attributesLength() { - const offset = this.bb.__offset(this.bb_pos, 22); - return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; - } - documentation(index, optionalEncoding) { - const offset = this.bb.__offset(this.bb_pos, 24); - return offset ? this.bb.__string(this.bb.__vector(this.bb_pos + offset) + index * 4, optionalEncoding) : null; - } - documentationLength() { - const offset = this.bb.__offset(this.bb_pos, 24); - return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; - } - optional() { - const offset = this.bb.__offset(this.bb_pos, 26); - return offset ? !!this.bb.readInt8(this.bb_pos + offset) : false; - } - mutate_optional(value) { - const offset = this.bb.__offset(this.bb_pos, 26); - if (offset === 0) { - return false; - } - this.bb.writeInt8(this.bb_pos + offset, +value); - return true; - } - /** - * Number of padding octets to always add after this field. Structs only. - */ - padding() { - const offset = this.bb.__offset(this.bb_pos, 28); - return offset ? this.bb.readUint16(this.bb_pos + offset) : 0; - } - mutate_padding(value) { - const offset = this.bb.__offset(this.bb_pos, 28); - if (offset === 0) { - return false; - } - this.bb.writeUint16(this.bb_pos + offset, value); - return true; - } - static getFullyQualifiedName() { - return 'reflection_Field'; - } - static startField(builder) { - builder.startObject(13); - } - static addName(builder, nameOffset) { - builder.addFieldOffset(0, nameOffset, 0); - } - static addType(builder, typeOffset) { - builder.addFieldOffset(1, typeOffset, 0); - } - static addId(builder, id) { - builder.addFieldInt16(2, id, 0); - } - static addOffset(builder, offset) { - builder.addFieldInt16(3, offset, 0); - } - static addDefaultInteger(builder, defaultInteger) { - builder.addFieldInt64(4, defaultInteger, BigInt('0')); - } - static addDefaultReal(builder, defaultReal) { - builder.addFieldFloat64(5, defaultReal, 0.0); - } - static addDeprecated(builder, deprecated) { - builder.addFieldInt8(6, +deprecated, +false); - } - static addRequired(builder, required) { - builder.addFieldInt8(7, +required, +false); - } - static addKey(builder, key) { - builder.addFieldInt8(8, +key, +false); - } - static addAttributes(builder, attributesOffset) { - builder.addFieldOffset(9, attributesOffset, 0); - } - static createAttributesVector(builder, data) { - builder.startVector(4, data.length, 4); - for (let i = data.length - 1; i >= 0; i--) { - builder.addOffset(data[i]); - } - return builder.endVector(); - } - static startAttributesVector(builder, numElems) { - builder.startVector(4, numElems, 4); - } - static addDocumentation(builder, documentationOffset) { - builder.addFieldOffset(10, documentationOffset, 0); - } - static createDocumentationVector(builder, data) { - builder.startVector(4, data.length, 4); - for (let i = data.length - 1; i >= 0; i--) { - builder.addOffset(data[i]); - } - return builder.endVector(); - } - static startDocumentationVector(builder, numElems) { - builder.startVector(4, numElems, 4); - } - static addOptional(builder, optional) { - builder.addFieldInt8(11, +optional, +false); - } - static addPadding(builder, padding) { - builder.addFieldInt16(12, padding, 0); - } - static endField(builder) { - const offset = builder.endObject(); - builder.requiredField(offset, 4); // name - builder.requiredField(offset, 6); // type - return offset; - } - unpack() { - return new FieldT(this.name(), (this.type() !== null ? this.type().unpack() : null), this.id(), this.offset(), this.defaultInteger(), this.defaultReal(), this.deprecated(), this.required(), this.key(), this.bb.createObjList(this.attributes.bind(this), this.attributesLength()), this.bb.createScalarList(this.documentation.bind(this), this.documentationLength()), this.optional(), this.padding()); - } - unpackTo(_o) { - _o.name = this.name(); - _o.type = (this.type() !== null ? this.type().unpack() : null); - _o.id = this.id(); - _o.offset = this.offset(); - _o.defaultInteger = this.defaultInteger(); - _o.defaultReal = this.defaultReal(); - _o.deprecated = this.deprecated(); - _o.required = this.required(); - _o.key = this.key(); - _o.attributes = this.bb.createObjList(this.attributes.bind(this), this.attributesLength()); - _o.documentation = this.bb.createScalarList(this.documentation.bind(this), this.documentationLength()); - _o.optional = this.optional(); - _o.padding = this.padding(); - } -} -export class FieldT { - constructor(name = null, type = null, id = 0, offset = 0, defaultInteger = BigInt('0'), defaultReal = 0.0, deprecated = false, required = false, key = false, attributes = [], documentation = [], optional = false, padding = 0) { - this.name = name; - this.type = type; - this.id = id; - this.offset = offset; - this.defaultInteger = defaultInteger; - this.defaultReal = defaultReal; - this.deprecated = deprecated; - this.required = required; - this.key = key; - this.attributes = attributes; - this.documentation = documentation; - this.optional = optional; - this.padding = padding; - } - pack(builder) { - const name = (this.name !== null ? builder.createString(this.name) : 0); - const type = (this.type !== null ? this.type.pack(builder) : 0); - const attributes = Field.createAttributesVector(builder, builder.createObjectOffsetList(this.attributes)); - const documentation = Field.createDocumentationVector(builder, builder.createObjectOffsetList(this.documentation)); - Field.startField(builder); - Field.addName(builder, name); - Field.addType(builder, type); - Field.addId(builder, this.id); - Field.addOffset(builder, this.offset); - Field.addDefaultInteger(builder, this.defaultInteger); - Field.addDefaultReal(builder, this.defaultReal); - Field.addDeprecated(builder, this.deprecated); - Field.addRequired(builder, this.required); - Field.addKey(builder, this.key); - Field.addAttributes(builder, attributes); - Field.addDocumentation(builder, documentation); - Field.addOptional(builder, this.optional); - Field.addPadding(builder, this.padding); - return Field.endField(builder); - } -} diff --git a/tests/ts/reflection/key-value.js b/tests/ts/reflection/key-value.js deleted file mode 100644 index 622b4f2a884a..000000000000 --- a/tests/ts/reflection/key-value.js +++ /dev/null @@ -1,69 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify -import * as flatbuffers from 'flatbuffers'; -export class KeyValue { - constructor() { - this.bb = null; - this.bb_pos = 0; - } - __init(i, bb) { - this.bb_pos = i; - this.bb = bb; - return this; - } - static getRootAsKeyValue(bb, obj) { - return (obj || new KeyValue()).__init(bb.readInt32(bb.position()) + bb.position(), bb); - } - static getSizePrefixedRootAsKeyValue(bb, obj) { - bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); - return (obj || new KeyValue()).__init(bb.readInt32(bb.position()) + bb.position(), bb); - } - key(optionalEncoding) { - const offset = this.bb.__offset(this.bb_pos, 4); - return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null; - } - value(optionalEncoding) { - const offset = this.bb.__offset(this.bb_pos, 6); - return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null; - } - static getFullyQualifiedName() { - return 'reflection_KeyValue'; - } - static startKeyValue(builder) { - builder.startObject(2); - } - static addKey(builder, keyOffset) { - builder.addFieldOffset(0, keyOffset, 0); - } - static addValue(builder, valueOffset) { - builder.addFieldOffset(1, valueOffset, 0); - } - static endKeyValue(builder) { - const offset = builder.endObject(); - builder.requiredField(offset, 4); // key - return offset; - } - static createKeyValue(builder, keyOffset, valueOffset) { - KeyValue.startKeyValue(builder); - KeyValue.addKey(builder, keyOffset); - KeyValue.addValue(builder, valueOffset); - return KeyValue.endKeyValue(builder); - } - unpack() { - return new KeyValueT(this.key(), this.value()); - } - unpackTo(_o) { - _o.key = this.key(); - _o.value = this.value(); - } -} -export class KeyValueT { - constructor(key = null, value = null) { - this.key = key; - this.value = value; - } - pack(builder) { - const key = (this.key !== null ? builder.createString(this.key) : 0); - const value = (this.value !== null ? builder.createString(this.value) : 0); - return KeyValue.createKeyValue(builder, key, value); - } -} diff --git a/tests/ts/reflection/object.js b/tests/ts/reflection/object.js deleted file mode 100644 index d2885455a7b8..000000000000 --- a/tests/ts/reflection/object.js +++ /dev/null @@ -1,201 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify -import * as flatbuffers from 'flatbuffers'; -import { Field } from '../reflection/field.js'; -import { KeyValue } from '../reflection/key-value.js'; -export class Object_ { - constructor() { - this.bb = null; - this.bb_pos = 0; - } - __init(i, bb) { - this.bb_pos = i; - this.bb = bb; - return this; - } - static getRootAsObject(bb, obj) { - return (obj || new Object_()).__init(bb.readInt32(bb.position()) + bb.position(), bb); - } - static getSizePrefixedRootAsObject(bb, obj) { - bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); - return (obj || new Object_()).__init(bb.readInt32(bb.position()) + bb.position(), bb); - } - name(optionalEncoding) { - const offset = this.bb.__offset(this.bb_pos, 4); - return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null; - } - fields(index, obj) { - const offset = this.bb.__offset(this.bb_pos, 6); - return offset ? (obj || new Field()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4), this.bb) : null; - } - fieldsLength() { - const offset = this.bb.__offset(this.bb_pos, 6); - return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; - } - isStruct() { - const offset = this.bb.__offset(this.bb_pos, 8); - return offset ? !!this.bb.readInt8(this.bb_pos + offset) : false; - } - mutate_is_struct(value) { - const offset = this.bb.__offset(this.bb_pos, 8); - if (offset === 0) { - return false; - } - this.bb.writeInt8(this.bb_pos + offset, +value); - return true; - } - minalign() { - const offset = this.bb.__offset(this.bb_pos, 10); - return offset ? this.bb.readInt32(this.bb_pos + offset) : 0; - } - mutate_minalign(value) { - const offset = this.bb.__offset(this.bb_pos, 10); - if (offset === 0) { - return false; - } - this.bb.writeInt32(this.bb_pos + offset, value); - return true; - } - bytesize() { - const offset = this.bb.__offset(this.bb_pos, 12); - return offset ? this.bb.readInt32(this.bb_pos + offset) : 0; - } - mutate_bytesize(value) { - const offset = this.bb.__offset(this.bb_pos, 12); - if (offset === 0) { - return false; - } - this.bb.writeInt32(this.bb_pos + offset, value); - return true; - } - attributes(index, obj) { - const offset = this.bb.__offset(this.bb_pos, 14); - return offset ? (obj || new KeyValue()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4), this.bb) : null; - } - attributesLength() { - const offset = this.bb.__offset(this.bb_pos, 14); - return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; - } - documentation(index, optionalEncoding) { - const offset = this.bb.__offset(this.bb_pos, 16); - return offset ? this.bb.__string(this.bb.__vector(this.bb_pos + offset) + index * 4, optionalEncoding) : null; - } - documentationLength() { - const offset = this.bb.__offset(this.bb_pos, 16); - return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; - } - declarationFile(optionalEncoding) { - const offset = this.bb.__offset(this.bb_pos, 18); - return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null; - } - static getFullyQualifiedName() { - return 'reflection_Object'; - } - static startObject(builder) { - builder.startObject(8); - } - static addName(builder, nameOffset) { - builder.addFieldOffset(0, nameOffset, 0); - } - static addFields(builder, fieldsOffset) { - builder.addFieldOffset(1, fieldsOffset, 0); - } - static createFieldsVector(builder, data) { - builder.startVector(4, data.length, 4); - for (let i = data.length - 1; i >= 0; i--) { - builder.addOffset(data[i]); - } - return builder.endVector(); - } - static startFieldsVector(builder, numElems) { - builder.startVector(4, numElems, 4); - } - static addIsStruct(builder, isStruct) { - builder.addFieldInt8(2, +isStruct, +false); - } - static addMinalign(builder, minalign) { - builder.addFieldInt32(3, minalign, 0); - } - static addBytesize(builder, bytesize) { - builder.addFieldInt32(4, bytesize, 0); - } - static addAttributes(builder, attributesOffset) { - builder.addFieldOffset(5, attributesOffset, 0); - } - static createAttributesVector(builder, data) { - builder.startVector(4, data.length, 4); - for (let i = data.length - 1; i >= 0; i--) { - builder.addOffset(data[i]); - } - return builder.endVector(); - } - static startAttributesVector(builder, numElems) { - builder.startVector(4, numElems, 4); - } - static addDocumentation(builder, documentationOffset) { - builder.addFieldOffset(6, documentationOffset, 0); - } - static createDocumentationVector(builder, data) { - builder.startVector(4, data.length, 4); - for (let i = data.length - 1; i >= 0; i--) { - builder.addOffset(data[i]); - } - return builder.endVector(); - } - static startDocumentationVector(builder, numElems) { - builder.startVector(4, numElems, 4); - } - static addDeclarationFile(builder, declarationFileOffset) { - builder.addFieldOffset(7, declarationFileOffset, 0); - } - static endObject(builder) { - const offset = builder.endObject(); - builder.requiredField(offset, 4); // name - builder.requiredField(offset, 6); // fields - return offset; - } - static createObject(builder, nameOffset, fieldsOffset, isStruct, minalign, bytesize, attributesOffset, documentationOffset, declarationFileOffset) { - Object_.startObject(builder); - Object_.addName(builder, nameOffset); - Object_.addFields(builder, fieldsOffset); - Object_.addIsStruct(builder, isStruct); - Object_.addMinalign(builder, minalign); - Object_.addBytesize(builder, bytesize); - Object_.addAttributes(builder, attributesOffset); - Object_.addDocumentation(builder, documentationOffset); - Object_.addDeclarationFile(builder, declarationFileOffset); - return Object_.endObject(builder); - } - unpack() { - return new Object_T(this.name(), this.bb.createObjList(this.fields.bind(this), this.fieldsLength()), this.isStruct(), this.minalign(), this.bytesize(), this.bb.createObjList(this.attributes.bind(this), this.attributesLength()), this.bb.createScalarList(this.documentation.bind(this), this.documentationLength()), this.declarationFile()); - } - unpackTo(_o) { - _o.name = this.name(); - _o.fields = this.bb.createObjList(this.fields.bind(this), this.fieldsLength()); - _o.isStruct = this.isStruct(); - _o.minalign = this.minalign(); - _o.bytesize = this.bytesize(); - _o.attributes = this.bb.createObjList(this.attributes.bind(this), this.attributesLength()); - _o.documentation = this.bb.createScalarList(this.documentation.bind(this), this.documentationLength()); - _o.declarationFile = this.declarationFile(); - } -} -export class Object_T { - constructor(name = null, fields = [], isStruct = false, minalign = 0, bytesize = 0, attributes = [], documentation = [], declarationFile = null) { - this.name = name; - this.fields = fields; - this.isStruct = isStruct; - this.minalign = minalign; - this.bytesize = bytesize; - this.attributes = attributes; - this.documentation = documentation; - this.declarationFile = declarationFile; - } - pack(builder) { - const name = (this.name !== null ? builder.createString(this.name) : 0); - const fields = Object_.createFieldsVector(builder, builder.createObjectOffsetList(this.fields)); - const attributes = Object_.createAttributesVector(builder, builder.createObjectOffsetList(this.attributes)); - const documentation = Object_.createDocumentationVector(builder, builder.createObjectOffsetList(this.documentation)); - const declarationFile = (this.declarationFile !== null ? builder.createString(this.declarationFile) : 0); - return Object_.createObject(builder, name, fields, this.isStruct, this.minalign, this.bytesize, attributes, documentation, declarationFile); - } -} diff --git a/tests/ts/reflection/reflection.ts b/tests/ts/reflection/reflection.ts new file mode 100644 index 000000000000..8440332d1610 --- /dev/null +++ b/tests/ts/reflection/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/advanced-features.ts b/tests/ts/reflection/reflection/advanced-features.ts similarity index 100% rename from tests/ts/reflection/advanced-features.ts rename to tests/ts/reflection/reflection/advanced-features.ts diff --git a/tests/ts/reflection/base-type.ts b/tests/ts/reflection/reflection/base-type.ts similarity index 100% rename from tests/ts/reflection/base-type.ts rename to tests/ts/reflection/reflection/base-type.ts diff --git a/tests/ts/reflection/enum-val.ts b/tests/ts/reflection/reflection/enum-val.ts similarity index 100% rename from tests/ts/reflection/enum-val.ts rename to tests/ts/reflection/reflection/enum-val.ts diff --git a/tests/ts/reflection/enum.ts b/tests/ts/reflection/reflection/enum.ts similarity index 100% rename from tests/ts/reflection/enum.ts rename to tests/ts/reflection/reflection/enum.ts diff --git a/tests/ts/reflection/field.ts b/tests/ts/reflection/reflection/field.ts similarity index 100% rename from tests/ts/reflection/field.ts rename to tests/ts/reflection/reflection/field.ts diff --git a/tests/ts/reflection/key-value.ts b/tests/ts/reflection/reflection/key-value.ts similarity index 100% rename from tests/ts/reflection/key-value.ts rename to tests/ts/reflection/reflection/key-value.ts diff --git a/tests/ts/reflection/object.ts b/tests/ts/reflection/reflection/object.ts similarity index 100% rename from tests/ts/reflection/object.ts rename to tests/ts/reflection/reflection/object.ts diff --git a/tests/ts/reflection/rpccall.ts b/tests/ts/reflection/reflection/rpccall.ts similarity index 100% rename from tests/ts/reflection/rpccall.ts rename to tests/ts/reflection/reflection/rpccall.ts diff --git a/tests/ts/reflection/schema-file.ts b/tests/ts/reflection/reflection/schema-file.ts similarity index 100% rename from tests/ts/reflection/schema-file.ts rename to tests/ts/reflection/reflection/schema-file.ts diff --git a/tests/ts/reflection/schema.ts b/tests/ts/reflection/reflection/schema.ts similarity index 100% rename from tests/ts/reflection/schema.ts rename to tests/ts/reflection/reflection/schema.ts diff --git a/tests/ts/reflection/service.ts b/tests/ts/reflection/reflection/service.ts similarity index 100% rename from tests/ts/reflection/service.ts rename to tests/ts/reflection/reflection/service.ts diff --git a/tests/ts/reflection/type.ts b/tests/ts/reflection/reflection/type.ts similarity index 100% rename from tests/ts/reflection/type.ts rename to tests/ts/reflection/reflection/type.ts diff --git a/tests/ts/reflection/rpccall.js b/tests/ts/reflection/rpccall.js deleted file mode 100644 index 96e92eb3f56b..000000000000 --- a/tests/ts/reflection/rpccall.js +++ /dev/null @@ -1,131 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify -import * as flatbuffers from 'flatbuffers'; -import { KeyValue } from '../reflection/key-value.js'; -import { Object_ } from '../reflection/object.js'; -export class RPCCall { - constructor() { - this.bb = null; - this.bb_pos = 0; - } - __init(i, bb) { - this.bb_pos = i; - this.bb = bb; - return this; - } - static getRootAsRPCCall(bb, obj) { - return (obj || new RPCCall()).__init(bb.readInt32(bb.position()) + bb.position(), bb); - } - static getSizePrefixedRootAsRPCCall(bb, obj) { - bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); - return (obj || new RPCCall()).__init(bb.readInt32(bb.position()) + bb.position(), bb); - } - name(optionalEncoding) { - const offset = this.bb.__offset(this.bb_pos, 4); - return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null; - } - request(obj) { - const offset = this.bb.__offset(this.bb_pos, 6); - return offset ? (obj || new Object_()).__init(this.bb.__indirect(this.bb_pos + offset), this.bb) : null; - } - response(obj) { - const offset = this.bb.__offset(this.bb_pos, 8); - return offset ? (obj || new Object_()).__init(this.bb.__indirect(this.bb_pos + offset), this.bb) : null; - } - attributes(index, obj) { - const offset = this.bb.__offset(this.bb_pos, 10); - return offset ? (obj || new KeyValue()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4), this.bb) : null; - } - attributesLength() { - const offset = this.bb.__offset(this.bb_pos, 10); - return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; - } - documentation(index, optionalEncoding) { - const offset = this.bb.__offset(this.bb_pos, 12); - return offset ? this.bb.__string(this.bb.__vector(this.bb_pos + offset) + index * 4, optionalEncoding) : null; - } - documentationLength() { - const offset = this.bb.__offset(this.bb_pos, 12); - return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; - } - static getFullyQualifiedName() { - return 'reflection_RPCCall'; - } - static startRPCCall(builder) { - builder.startObject(5); - } - static addName(builder, nameOffset) { - builder.addFieldOffset(0, nameOffset, 0); - } - static addRequest(builder, requestOffset) { - builder.addFieldOffset(1, requestOffset, 0); - } - static addResponse(builder, responseOffset) { - builder.addFieldOffset(2, responseOffset, 0); - } - static addAttributes(builder, attributesOffset) { - builder.addFieldOffset(3, attributesOffset, 0); - } - static createAttributesVector(builder, data) { - builder.startVector(4, data.length, 4); - for (let i = data.length - 1; i >= 0; i--) { - builder.addOffset(data[i]); - } - return builder.endVector(); - } - static startAttributesVector(builder, numElems) { - builder.startVector(4, numElems, 4); - } - static addDocumentation(builder, documentationOffset) { - builder.addFieldOffset(4, documentationOffset, 0); - } - static createDocumentationVector(builder, data) { - builder.startVector(4, data.length, 4); - for (let i = data.length - 1; i >= 0; i--) { - builder.addOffset(data[i]); - } - return builder.endVector(); - } - static startDocumentationVector(builder, numElems) { - builder.startVector(4, numElems, 4); - } - static endRPCCall(builder) { - const offset = builder.endObject(); - builder.requiredField(offset, 4); // name - builder.requiredField(offset, 6); // request - builder.requiredField(offset, 8); // response - return offset; - } - unpack() { - return new RPCCallT(this.name(), (this.request() !== null ? this.request().unpack() : null), (this.response() !== null ? this.response().unpack() : null), this.bb.createObjList(this.attributes.bind(this), this.attributesLength()), this.bb.createScalarList(this.documentation.bind(this), this.documentationLength())); - } - unpackTo(_o) { - _o.name = this.name(); - _o.request = (this.request() !== null ? this.request().unpack() : null); - _o.response = (this.response() !== null ? this.response().unpack() : null); - _o.attributes = this.bb.createObjList(this.attributes.bind(this), this.attributesLength()); - _o.documentation = this.bb.createScalarList(this.documentation.bind(this), this.documentationLength()); - } -} -export class RPCCallT { - constructor(name = null, request = null, response = null, attributes = [], documentation = []) { - this.name = name; - this.request = request; - this.response = response; - this.attributes = attributes; - this.documentation = documentation; - } - pack(builder) { - const name = (this.name !== null ? builder.createString(this.name) : 0); - const request = (this.request !== null ? this.request.pack(builder) : 0); - const response = (this.response !== null ? this.response.pack(builder) : 0); - const attributes = RPCCall.createAttributesVector(builder, builder.createObjectOffsetList(this.attributes)); - const documentation = RPCCall.createDocumentationVector(builder, builder.createObjectOffsetList(this.documentation)); - RPCCall.startRPCCall(builder); - RPCCall.addName(builder, name); - RPCCall.addRequest(builder, request); - RPCCall.addResponse(builder, response); - RPCCall.addAttributes(builder, attributes); - RPCCall.addDocumentation(builder, documentation); - return RPCCall.endRPCCall(builder); - } -} diff --git a/tests/ts/reflection/schema-file.js b/tests/ts/reflection/schema-file.js deleted file mode 100644 index 31c6145ddfec..000000000000 --- a/tests/ts/reflection/schema-file.js +++ /dev/null @@ -1,88 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify -import * as flatbuffers from 'flatbuffers'; -/** - * File specific information. - * Symbols declared within a file may be recovered by iterating over all - * symbols and examining the `declaration_file` field. - */ -export class SchemaFile { - constructor() { - this.bb = null; - this.bb_pos = 0; - } - __init(i, bb) { - this.bb_pos = i; - this.bb = bb; - return this; - } - static getRootAsSchemaFile(bb, obj) { - return (obj || new SchemaFile()).__init(bb.readInt32(bb.position()) + bb.position(), bb); - } - static getSizePrefixedRootAsSchemaFile(bb, obj) { - bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); - return (obj || new SchemaFile()).__init(bb.readInt32(bb.position()) + bb.position(), bb); - } - filename(optionalEncoding) { - const offset = this.bb.__offset(this.bb_pos, 4); - return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null; - } - includedFilenames(index, optionalEncoding) { - const offset = this.bb.__offset(this.bb_pos, 6); - return offset ? this.bb.__string(this.bb.__vector(this.bb_pos + offset) + index * 4, optionalEncoding) : null; - } - includedFilenamesLength() { - const offset = this.bb.__offset(this.bb_pos, 6); - return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; - } - static getFullyQualifiedName() { - return 'reflection_SchemaFile'; - } - static startSchemaFile(builder) { - builder.startObject(2); - } - static addFilename(builder, filenameOffset) { - builder.addFieldOffset(0, filenameOffset, 0); - } - static addIncludedFilenames(builder, includedFilenamesOffset) { - builder.addFieldOffset(1, includedFilenamesOffset, 0); - } - static createIncludedFilenamesVector(builder, data) { - builder.startVector(4, data.length, 4); - for (let i = data.length - 1; i >= 0; i--) { - builder.addOffset(data[i]); - } - return builder.endVector(); - } - static startIncludedFilenamesVector(builder, numElems) { - builder.startVector(4, numElems, 4); - } - static endSchemaFile(builder) { - const offset = builder.endObject(); - builder.requiredField(offset, 4); // filename - return offset; - } - static createSchemaFile(builder, filenameOffset, includedFilenamesOffset) { - SchemaFile.startSchemaFile(builder); - SchemaFile.addFilename(builder, filenameOffset); - SchemaFile.addIncludedFilenames(builder, includedFilenamesOffset); - return SchemaFile.endSchemaFile(builder); - } - unpack() { - return new SchemaFileT(this.filename(), this.bb.createScalarList(this.includedFilenames.bind(this), this.includedFilenamesLength())); - } - unpackTo(_o) { - _o.filename = this.filename(); - _o.includedFilenames = this.bb.createScalarList(this.includedFilenames.bind(this), this.includedFilenamesLength()); - } -} -export class SchemaFileT { - constructor(filename = null, includedFilenames = []) { - this.filename = filename; - this.includedFilenames = includedFilenames; - } - pack(builder) { - const filename = (this.filename !== null ? builder.createString(this.filename) : 0); - const includedFilenames = SchemaFile.createIncludedFilenamesVector(builder, builder.createObjectOffsetList(this.includedFilenames)); - return SchemaFile.createSchemaFile(builder, filename, includedFilenames); - } -} diff --git a/tests/ts/reflection/schema.js b/tests/ts/reflection/schema.js deleted file mode 100644 index d5022971526a..000000000000 --- a/tests/ts/reflection/schema.js +++ /dev/null @@ -1,213 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify -import * as flatbuffers from 'flatbuffers'; -import { Enum } from '../reflection/enum.js'; -import { Object_ } from '../reflection/object.js'; -import { SchemaFile } from '../reflection/schema-file.js'; -import { Service } from '../reflection/service.js'; -export class Schema { - constructor() { - this.bb = null; - this.bb_pos = 0; - } - __init(i, bb) { - this.bb_pos = i; - this.bb = bb; - return this; - } - static getRootAsSchema(bb, obj) { - return (obj || new Schema()).__init(bb.readInt32(bb.position()) + bb.position(), bb); - } - static getSizePrefixedRootAsSchema(bb, obj) { - bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); - return (obj || new Schema()).__init(bb.readInt32(bb.position()) + bb.position(), bb); - } - static bufferHasIdentifier(bb) { - return bb.__has_identifier('BFBS'); - } - objects(index, obj) { - const offset = this.bb.__offset(this.bb_pos, 4); - return offset ? (obj || new Object_()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4), this.bb) : null; - } - objectsLength() { - const offset = this.bb.__offset(this.bb_pos, 4); - return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; - } - enums(index, obj) { - const offset = this.bb.__offset(this.bb_pos, 6); - return offset ? (obj || new Enum()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4), this.bb) : null; - } - enumsLength() { - const offset = this.bb.__offset(this.bb_pos, 6); - return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; - } - fileIdent(optionalEncoding) { - const offset = this.bb.__offset(this.bb_pos, 8); - return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null; - } - fileExt(optionalEncoding) { - const offset = this.bb.__offset(this.bb_pos, 10); - return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null; - } - rootTable(obj) { - const offset = this.bb.__offset(this.bb_pos, 12); - return offset ? (obj || new Object_()).__init(this.bb.__indirect(this.bb_pos + offset), this.bb) : null; - } - services(index, obj) { - const offset = this.bb.__offset(this.bb_pos, 14); - return offset ? (obj || new Service()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4), this.bb) : null; - } - servicesLength() { - const offset = this.bb.__offset(this.bb_pos, 14); - return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; - } - advancedFeatures() { - const offset = this.bb.__offset(this.bb_pos, 16); - return offset ? this.bb.readUint64(this.bb_pos + offset) : BigInt('0'); - } - mutate_advanced_features(value) { - const offset = this.bb.__offset(this.bb_pos, 16); - if (offset === 0) { - return false; - } - this.bb.writeUint64(this.bb_pos + offset, value); - return true; - } - /** - * All the files used in this compilation. Files are relative to where - * flatc was invoked. - */ - fbsFiles(index, obj) { - const offset = this.bb.__offset(this.bb_pos, 18); - return offset ? (obj || new SchemaFile()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4), this.bb) : null; - } - fbsFilesLength() { - const offset = this.bb.__offset(this.bb_pos, 18); - return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; - } - static getFullyQualifiedName() { - return 'reflection_Schema'; - } - static startSchema(builder) { - builder.startObject(8); - } - static addObjects(builder, objectsOffset) { - builder.addFieldOffset(0, objectsOffset, 0); - } - static createObjectsVector(builder, data) { - builder.startVector(4, data.length, 4); - for (let i = data.length - 1; i >= 0; i--) { - builder.addOffset(data[i]); - } - return builder.endVector(); - } - static startObjectsVector(builder, numElems) { - builder.startVector(4, numElems, 4); - } - static addEnums(builder, enumsOffset) { - builder.addFieldOffset(1, enumsOffset, 0); - } - static createEnumsVector(builder, data) { - builder.startVector(4, data.length, 4); - for (let i = data.length - 1; i >= 0; i--) { - builder.addOffset(data[i]); - } - return builder.endVector(); - } - static startEnumsVector(builder, numElems) { - builder.startVector(4, numElems, 4); - } - static addFileIdent(builder, fileIdentOffset) { - builder.addFieldOffset(2, fileIdentOffset, 0); - } - static addFileExt(builder, fileExtOffset) { - builder.addFieldOffset(3, fileExtOffset, 0); - } - static addRootTable(builder, rootTableOffset) { - builder.addFieldOffset(4, rootTableOffset, 0); - } - static addServices(builder, servicesOffset) { - builder.addFieldOffset(5, servicesOffset, 0); - } - static createServicesVector(builder, data) { - builder.startVector(4, data.length, 4); - for (let i = data.length - 1; i >= 0; i--) { - builder.addOffset(data[i]); - } - return builder.endVector(); - } - static startServicesVector(builder, numElems) { - builder.startVector(4, numElems, 4); - } - static addAdvancedFeatures(builder, advancedFeatures) { - builder.addFieldInt64(6, advancedFeatures, BigInt('0')); - } - static addFbsFiles(builder, fbsFilesOffset) { - builder.addFieldOffset(7, fbsFilesOffset, 0); - } - static createFbsFilesVector(builder, data) { - builder.startVector(4, data.length, 4); - for (let i = data.length - 1; i >= 0; i--) { - builder.addOffset(data[i]); - } - return builder.endVector(); - } - static startFbsFilesVector(builder, numElems) { - builder.startVector(4, numElems, 4); - } - static endSchema(builder) { - const offset = builder.endObject(); - builder.requiredField(offset, 4); // objects - builder.requiredField(offset, 6); // enums - return offset; - } - static finishSchemaBuffer(builder, offset) { - builder.finish(offset, 'BFBS'); - } - static finishSizePrefixedSchemaBuffer(builder, offset) { - builder.finish(offset, 'BFBS', true); - } - unpack() { - return new SchemaT(this.bb.createObjList(this.objects.bind(this), this.objectsLength()), this.bb.createObjList(this.enums.bind(this), this.enumsLength()), this.fileIdent(), this.fileExt(), (this.rootTable() !== null ? this.rootTable().unpack() : null), this.bb.createObjList(this.services.bind(this), this.servicesLength()), this.advancedFeatures(), this.bb.createObjList(this.fbsFiles.bind(this), this.fbsFilesLength())); - } - unpackTo(_o) { - _o.objects = this.bb.createObjList(this.objects.bind(this), this.objectsLength()); - _o.enums = this.bb.createObjList(this.enums.bind(this), this.enumsLength()); - _o.fileIdent = this.fileIdent(); - _o.fileExt = this.fileExt(); - _o.rootTable = (this.rootTable() !== null ? this.rootTable().unpack() : null); - _o.services = this.bb.createObjList(this.services.bind(this), this.servicesLength()); - _o.advancedFeatures = this.advancedFeatures(); - _o.fbsFiles = this.bb.createObjList(this.fbsFiles.bind(this), this.fbsFilesLength()); - } -} -export class SchemaT { - constructor(objects = [], enums = [], fileIdent = null, fileExt = null, rootTable = null, services = [], advancedFeatures = BigInt('0'), fbsFiles = []) { - this.objects = objects; - this.enums = enums; - this.fileIdent = fileIdent; - this.fileExt = fileExt; - this.rootTable = rootTable; - this.services = services; - this.advancedFeatures = advancedFeatures; - this.fbsFiles = fbsFiles; - } - pack(builder) { - const objects = Schema.createObjectsVector(builder, builder.createObjectOffsetList(this.objects)); - const enums = Schema.createEnumsVector(builder, builder.createObjectOffsetList(this.enums)); - const fileIdent = (this.fileIdent !== null ? builder.createString(this.fileIdent) : 0); - const fileExt = (this.fileExt !== null ? builder.createString(this.fileExt) : 0); - const rootTable = (this.rootTable !== null ? this.rootTable.pack(builder) : 0); - const services = Schema.createServicesVector(builder, builder.createObjectOffsetList(this.services)); - const fbsFiles = Schema.createFbsFilesVector(builder, builder.createObjectOffsetList(this.fbsFiles)); - Schema.startSchema(builder); - Schema.addObjects(builder, objects); - Schema.addEnums(builder, enums); - Schema.addFileIdent(builder, fileIdent); - Schema.addFileExt(builder, fileExt); - Schema.addRootTable(builder, rootTable); - Schema.addServices(builder, services); - Schema.addAdvancedFeatures(builder, this.advancedFeatures); - Schema.addFbsFiles(builder, fbsFiles); - return Schema.endSchema(builder); - } -} diff --git a/tests/ts/reflection/service.js b/tests/ts/reflection/service.js deleted file mode 100644 index 8c66ef774aca..000000000000 --- a/tests/ts/reflection/service.js +++ /dev/null @@ -1,146 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify -import * as flatbuffers from 'flatbuffers'; -import { KeyValue } from '../reflection/key-value.js'; -import { RPCCall } from '../reflection/rpccall.js'; -export class Service { - constructor() { - this.bb = null; - this.bb_pos = 0; - } - __init(i, bb) { - this.bb_pos = i; - this.bb = bb; - return this; - } - static getRootAsService(bb, obj) { - return (obj || new Service()).__init(bb.readInt32(bb.position()) + bb.position(), bb); - } - static getSizePrefixedRootAsService(bb, obj) { - bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); - return (obj || new Service()).__init(bb.readInt32(bb.position()) + bb.position(), bb); - } - name(optionalEncoding) { - const offset = this.bb.__offset(this.bb_pos, 4); - return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null; - } - calls(index, obj) { - const offset = this.bb.__offset(this.bb_pos, 6); - return offset ? (obj || new RPCCall()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4), this.bb) : null; - } - callsLength() { - const offset = this.bb.__offset(this.bb_pos, 6); - return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; - } - attributes(index, obj) { - const offset = this.bb.__offset(this.bb_pos, 8); - return offset ? (obj || new KeyValue()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4), this.bb) : null; - } - attributesLength() { - const offset = this.bb.__offset(this.bb_pos, 8); - return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; - } - documentation(index, optionalEncoding) { - const offset = this.bb.__offset(this.bb_pos, 10); - return offset ? this.bb.__string(this.bb.__vector(this.bb_pos + offset) + index * 4, optionalEncoding) : null; - } - documentationLength() { - const offset = this.bb.__offset(this.bb_pos, 10); - return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; - } - declarationFile(optionalEncoding) { - const offset = this.bb.__offset(this.bb_pos, 12); - return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null; - } - static getFullyQualifiedName() { - return 'reflection_Service'; - } - static startService(builder) { - builder.startObject(5); - } - static addName(builder, nameOffset) { - builder.addFieldOffset(0, nameOffset, 0); - } - static addCalls(builder, callsOffset) { - builder.addFieldOffset(1, callsOffset, 0); - } - static createCallsVector(builder, data) { - builder.startVector(4, data.length, 4); - for (let i = data.length - 1; i >= 0; i--) { - builder.addOffset(data[i]); - } - return builder.endVector(); - } - static startCallsVector(builder, numElems) { - builder.startVector(4, numElems, 4); - } - static addAttributes(builder, attributesOffset) { - builder.addFieldOffset(2, attributesOffset, 0); - } - static createAttributesVector(builder, data) { - builder.startVector(4, data.length, 4); - for (let i = data.length - 1; i >= 0; i--) { - builder.addOffset(data[i]); - } - return builder.endVector(); - } - static startAttributesVector(builder, numElems) { - builder.startVector(4, numElems, 4); - } - static addDocumentation(builder, documentationOffset) { - builder.addFieldOffset(3, documentationOffset, 0); - } - static createDocumentationVector(builder, data) { - builder.startVector(4, data.length, 4); - for (let i = data.length - 1; i >= 0; i--) { - builder.addOffset(data[i]); - } - return builder.endVector(); - } - static startDocumentationVector(builder, numElems) { - builder.startVector(4, numElems, 4); - } - static addDeclarationFile(builder, declarationFileOffset) { - builder.addFieldOffset(4, declarationFileOffset, 0); - } - static endService(builder) { - const offset = builder.endObject(); - builder.requiredField(offset, 4); // name - return offset; - } - static createService(builder, nameOffset, callsOffset, attributesOffset, documentationOffset, declarationFileOffset) { - Service.startService(builder); - Service.addName(builder, nameOffset); - Service.addCalls(builder, callsOffset); - Service.addAttributes(builder, attributesOffset); - Service.addDocumentation(builder, documentationOffset); - Service.addDeclarationFile(builder, declarationFileOffset); - return Service.endService(builder); - } - unpack() { - return new ServiceT(this.name(), this.bb.createObjList(this.calls.bind(this), this.callsLength()), this.bb.createObjList(this.attributes.bind(this), this.attributesLength()), this.bb.createScalarList(this.documentation.bind(this), this.documentationLength()), this.declarationFile()); - } - unpackTo(_o) { - _o.name = this.name(); - _o.calls = this.bb.createObjList(this.calls.bind(this), this.callsLength()); - _o.attributes = this.bb.createObjList(this.attributes.bind(this), this.attributesLength()); - _o.documentation = this.bb.createScalarList(this.documentation.bind(this), this.documentationLength()); - _o.declarationFile = this.declarationFile(); - } -} -export class ServiceT { - constructor(name = null, calls = [], attributes = [], documentation = [], declarationFile = null) { - this.name = name; - this.calls = calls; - this.attributes = attributes; - this.documentation = documentation; - this.declarationFile = declarationFile; - } - pack(builder) { - const name = (this.name !== null ? builder.createString(this.name) : 0); - const calls = Service.createCallsVector(builder, builder.createObjectOffsetList(this.calls)); - const attributes = Service.createAttributesVector(builder, builder.createObjectOffsetList(this.attributes)); - const documentation = Service.createDocumentationVector(builder, builder.createObjectOffsetList(this.documentation)); - const declarationFile = (this.declarationFile !== null ? builder.createString(this.declarationFile) : 0); - return Service.createService(builder, name, calls, attributes, documentation, declarationFile); - } -} diff --git a/tests/ts/reflection/type.js b/tests/ts/reflection/type.js deleted file mode 100644 index f3ccbdfe688f..000000000000 --- a/tests/ts/reflection/type.js +++ /dev/null @@ -1,161 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify -import * as flatbuffers from 'flatbuffers'; -import { BaseType } from '../reflection/base-type.js'; -export class Type { - constructor() { - this.bb = null; - this.bb_pos = 0; - } - __init(i, bb) { - this.bb_pos = i; - this.bb = bb; - return this; - } - static getRootAsType(bb, obj) { - return (obj || new Type()).__init(bb.readInt32(bb.position()) + bb.position(), bb); - } - static getSizePrefixedRootAsType(bb, obj) { - bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); - return (obj || new Type()).__init(bb.readInt32(bb.position()) + bb.position(), bb); - } - baseType() { - const offset = this.bb.__offset(this.bb_pos, 4); - return offset ? this.bb.readInt8(this.bb_pos + offset) : BaseType.None; - } - mutate_base_type(value) { - const offset = this.bb.__offset(this.bb_pos, 4); - if (offset === 0) { - return false; - } - this.bb.writeInt8(this.bb_pos + offset, value); - return true; - } - element() { - const offset = this.bb.__offset(this.bb_pos, 6); - return offset ? this.bb.readInt8(this.bb_pos + offset) : BaseType.None; - } - mutate_element(value) { - const offset = this.bb.__offset(this.bb_pos, 6); - if (offset === 0) { - return false; - } - this.bb.writeInt8(this.bb_pos + offset, value); - return true; - } - index() { - const offset = this.bb.__offset(this.bb_pos, 8); - return offset ? this.bb.readInt32(this.bb_pos + offset) : -1; - } - mutate_index(value) { - const offset = this.bb.__offset(this.bb_pos, 8); - if (offset === 0) { - return false; - } - this.bb.writeInt32(this.bb_pos + offset, value); - return true; - } - fixedLength() { - const offset = this.bb.__offset(this.bb_pos, 10); - return offset ? this.bb.readUint16(this.bb_pos + offset) : 0; - } - mutate_fixed_length(value) { - const offset = this.bb.__offset(this.bb_pos, 10); - if (offset === 0) { - return false; - } - this.bb.writeUint16(this.bb_pos + offset, value); - return true; - } - /** - * The size (octets) of the `base_type` field. - */ - baseSize() { - const offset = this.bb.__offset(this.bb_pos, 12); - return offset ? this.bb.readUint32(this.bb_pos + offset) : 4; - } - mutate_base_size(value) { - const offset = this.bb.__offset(this.bb_pos, 12); - if (offset === 0) { - return false; - } - this.bb.writeUint32(this.bb_pos + offset, value); - return true; - } - /** - * The size (octets) of the `element` field, if present. - */ - elementSize() { - const offset = this.bb.__offset(this.bb_pos, 14); - return offset ? this.bb.readUint32(this.bb_pos + offset) : 0; - } - mutate_element_size(value) { - const offset = this.bb.__offset(this.bb_pos, 14); - if (offset === 0) { - return false; - } - this.bb.writeUint32(this.bb_pos + offset, value); - return true; - } - static getFullyQualifiedName() { - return 'reflection_Type'; - } - static startType(builder) { - builder.startObject(6); - } - static addBaseType(builder, baseType) { - builder.addFieldInt8(0, baseType, BaseType.None); - } - static addElement(builder, element) { - builder.addFieldInt8(1, element, BaseType.None); - } - static addIndex(builder, index) { - builder.addFieldInt32(2, index, -1); - } - static addFixedLength(builder, fixedLength) { - builder.addFieldInt16(3, fixedLength, 0); - } - static addBaseSize(builder, baseSize) { - builder.addFieldInt32(4, baseSize, 4); - } - static addElementSize(builder, elementSize) { - builder.addFieldInt32(5, elementSize, 0); - } - static endType(builder) { - const offset = builder.endObject(); - return offset; - } - static createType(builder, baseType, element, index, fixedLength, baseSize, elementSize) { - Type.startType(builder); - Type.addBaseType(builder, baseType); - Type.addElement(builder, element); - Type.addIndex(builder, index); - Type.addFixedLength(builder, fixedLength); - Type.addBaseSize(builder, baseSize); - Type.addElementSize(builder, elementSize); - return Type.endType(builder); - } - unpack() { - return new TypeT(this.baseType(), this.element(), this.index(), this.fixedLength(), this.baseSize(), this.elementSize()); - } - unpackTo(_o) { - _o.baseType = this.baseType(); - _o.element = this.element(); - _o.index = this.index(); - _o.fixedLength = this.fixedLength(); - _o.baseSize = this.baseSize(); - _o.elementSize = this.elementSize(); - } -} -export class TypeT { - constructor(baseType = BaseType.None, element = BaseType.None, index = -1, fixedLength = 0, baseSize = 4, elementSize = 0) { - this.baseType = baseType; - this.element = element; - this.index = index; - this.fixedLength = fixedLength; - this.baseSize = baseSize; - this.elementSize = elementSize; - } - pack(builder) { - return Type.createType(builder, this.baseType, this.element, this.index, this.fixedLength, this.baseSize, this.elementSize); - } -} diff --git a/tests/ts/reflection_generated.js b/tests/ts/reflection_generated.js deleted file mode 100644 index dd686cc9d67e..000000000000 --- a/tests/ts/reflection_generated.js +++ /dev/null @@ -1,1575 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify -import * as flatbuffers from 'flatbuffers'; -export var BaseType; -(function (BaseType) { - BaseType[BaseType["None"] = 0] = "None"; - BaseType[BaseType["UType"] = 1] = "UType"; - BaseType[BaseType["Bool"] = 2] = "Bool"; - BaseType[BaseType["Byte"] = 3] = "Byte"; - BaseType[BaseType["UByte"] = 4] = "UByte"; - BaseType[BaseType["Short"] = 5] = "Short"; - BaseType[BaseType["UShort"] = 6] = "UShort"; - BaseType[BaseType["Int"] = 7] = "Int"; - BaseType[BaseType["UInt"] = 8] = "UInt"; - BaseType[BaseType["Long"] = 9] = "Long"; - BaseType[BaseType["ULong"] = 10] = "ULong"; - BaseType[BaseType["Float"] = 11] = "Float"; - BaseType[BaseType["Double"] = 12] = "Double"; - BaseType[BaseType["String"] = 13] = "String"; - BaseType[BaseType["Vector"] = 14] = "Vector"; - BaseType[BaseType["Obj"] = 15] = "Obj"; - BaseType[BaseType["Union"] = 16] = "Union"; - BaseType[BaseType["Array"] = 17] = "Array"; - BaseType[BaseType["MaxBaseType"] = 18] = "MaxBaseType"; -})(BaseType || (BaseType = {})); -/** - * New schema language features that are not supported by old code generators. - */ -export var AdvancedFeatures; -(function (AdvancedFeatures) { - AdvancedFeatures["AdvancedArrayFeatures"] = "1"; - AdvancedFeatures["AdvancedUnionFeatures"] = "2"; - AdvancedFeatures["OptionalScalars"] = "4"; - AdvancedFeatures["DefaultVectorsAndStrings"] = "8"; -})(AdvancedFeatures || (AdvancedFeatures = {})); -export class Type { - constructor() { - this.bb = null; - this.bb_pos = 0; - } - __init(i, bb) { - this.bb_pos = i; - this.bb = bb; - return this; - } - static getRootAsType(bb, obj) { - return (obj || new Type()).__init(bb.readInt32(bb.position()) + bb.position(), bb); - } - static getSizePrefixedRootAsType(bb, obj) { - bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); - return (obj || new Type()).__init(bb.readInt32(bb.position()) + bb.position(), bb); - } - baseType() { - const offset = this.bb.__offset(this.bb_pos, 4); - return offset ? this.bb.readInt8(this.bb_pos + offset) : BaseType.None; - } - mutate_base_type(value) { - const offset = this.bb.__offset(this.bb_pos, 4); - if (offset === 0) { - return false; - } - this.bb.writeInt8(this.bb_pos + offset, value); - return true; - } - element() { - const offset = this.bb.__offset(this.bb_pos, 6); - return offset ? this.bb.readInt8(this.bb_pos + offset) : BaseType.None; - } - mutate_element(value) { - const offset = this.bb.__offset(this.bb_pos, 6); - if (offset === 0) { - return false; - } - this.bb.writeInt8(this.bb_pos + offset, value); - return true; - } - index() { - const offset = this.bb.__offset(this.bb_pos, 8); - return offset ? this.bb.readInt32(this.bb_pos + offset) : -1; - } - mutate_index(value) { - const offset = this.bb.__offset(this.bb_pos, 8); - if (offset === 0) { - return false; - } - this.bb.writeInt32(this.bb_pos + offset, value); - return true; - } - fixedLength() { - const offset = this.bb.__offset(this.bb_pos, 10); - return offset ? this.bb.readUint16(this.bb_pos + offset) : 0; - } - mutate_fixed_length(value) { - const offset = this.bb.__offset(this.bb_pos, 10); - if (offset === 0) { - return false; - } - this.bb.writeUint16(this.bb_pos + offset, value); - return true; - } - /** - * The size (octets) of the `base_type` field. - */ - baseSize() { - const offset = this.bb.__offset(this.bb_pos, 12); - return offset ? this.bb.readUint32(this.bb_pos + offset) : 4; - } - mutate_base_size(value) { - const offset = this.bb.__offset(this.bb_pos, 12); - if (offset === 0) { - return false; - } - this.bb.writeUint32(this.bb_pos + offset, value); - return true; - } - /** - * The size (octets) of the `element` field, if present. - */ - elementSize() { - const offset = this.bb.__offset(this.bb_pos, 14); - return offset ? this.bb.readUint32(this.bb_pos + offset) : 0; - } - mutate_element_size(value) { - const offset = this.bb.__offset(this.bb_pos, 14); - if (offset === 0) { - return false; - } - this.bb.writeUint32(this.bb_pos + offset, value); - return true; - } - static getFullyQualifiedName() { - return 'reflection_Type'; - } - static startType(builder) { - builder.startObject(6); - } - static addBaseType(builder, baseType) { - builder.addFieldInt8(0, baseType, BaseType.None); - } - static addElement(builder, element) { - builder.addFieldInt8(1, element, BaseType.None); - } - static addIndex(builder, index) { - builder.addFieldInt32(2, index, -1); - } - static addFixedLength(builder, fixedLength) { - builder.addFieldInt16(3, fixedLength, 0); - } - static addBaseSize(builder, baseSize) { - builder.addFieldInt32(4, baseSize, 4); - } - static addElementSize(builder, elementSize) { - builder.addFieldInt32(5, elementSize, 0); - } - static endType(builder) { - const offset = builder.endObject(); - return offset; - } - static createType(builder, baseType, element, index, fixedLength, baseSize, elementSize) { - Type.startType(builder); - Type.addBaseType(builder, baseType); - Type.addElement(builder, element); - Type.addIndex(builder, index); - Type.addFixedLength(builder, fixedLength); - Type.addBaseSize(builder, baseSize); - Type.addElementSize(builder, elementSize); - return Type.endType(builder); - } - unpack() { - return new TypeT(this.baseType(), this.element(), this.index(), this.fixedLength(), this.baseSize(), this.elementSize()); - } - unpackTo(_o) { - _o.baseType = this.baseType(); - _o.element = this.element(); - _o.index = this.index(); - _o.fixedLength = this.fixedLength(); - _o.baseSize = this.baseSize(); - _o.elementSize = this.elementSize(); - } -} -export class TypeT { - constructor(baseType = BaseType.None, element = BaseType.None, index = -1, fixedLength = 0, baseSize = 4, elementSize = 0) { - this.baseType = baseType; - this.element = element; - this.index = index; - this.fixedLength = fixedLength; - this.baseSize = baseSize; - this.elementSize = elementSize; - } - pack(builder) { - return Type.createType(builder, this.baseType, this.element, this.index, this.fixedLength, this.baseSize, this.elementSize); - } -} -export class KeyValue { - constructor() { - this.bb = null; - this.bb_pos = 0; - } - __init(i, bb) { - this.bb_pos = i; - this.bb = bb; - return this; - } - static getRootAsKeyValue(bb, obj) { - return (obj || new KeyValue()).__init(bb.readInt32(bb.position()) + bb.position(), bb); - } - static getSizePrefixedRootAsKeyValue(bb, obj) { - bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); - return (obj || new KeyValue()).__init(bb.readInt32(bb.position()) + bb.position(), bb); - } - key(optionalEncoding) { - const offset = this.bb.__offset(this.bb_pos, 4); - return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null; - } - value(optionalEncoding) { - const offset = this.bb.__offset(this.bb_pos, 6); - return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null; - } - static getFullyQualifiedName() { - return 'reflection_KeyValue'; - } - static startKeyValue(builder) { - builder.startObject(2); - } - static addKey(builder, keyOffset) { - builder.addFieldOffset(0, keyOffset, 0); - } - static addValue(builder, valueOffset) { - builder.addFieldOffset(1, valueOffset, 0); - } - static endKeyValue(builder) { - const offset = builder.endObject(); - builder.requiredField(offset, 4); // key - return offset; - } - static createKeyValue(builder, keyOffset, valueOffset) { - KeyValue.startKeyValue(builder); - KeyValue.addKey(builder, keyOffset); - KeyValue.addValue(builder, valueOffset); - return KeyValue.endKeyValue(builder); - } - unpack() { - return new KeyValueT(this.key(), this.value()); - } - unpackTo(_o) { - _o.key = this.key(); - _o.value = this.value(); - } -} -export class KeyValueT { - constructor(key = null, value = null) { - this.key = key; - this.value = value; - } - pack(builder) { - const key = (this.key !== null ? builder.createString(this.key) : 0); - const value = (this.value !== null ? builder.createString(this.value) : 0); - return KeyValue.createKeyValue(builder, key, value); - } -} -export class EnumVal { - constructor() { - this.bb = null; - this.bb_pos = 0; - } - __init(i, bb) { - this.bb_pos = i; - this.bb = bb; - return this; - } - static getRootAsEnumVal(bb, obj) { - return (obj || new EnumVal()).__init(bb.readInt32(bb.position()) + bb.position(), bb); - } - static getSizePrefixedRootAsEnumVal(bb, obj) { - bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); - return (obj || new EnumVal()).__init(bb.readInt32(bb.position()) + bb.position(), bb); - } - name(optionalEncoding) { - const offset = this.bb.__offset(this.bb_pos, 4); - return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null; - } - value() { - const offset = this.bb.__offset(this.bb_pos, 6); - return offset ? this.bb.readInt64(this.bb_pos + offset) : BigInt('0'); - } - mutate_value(value) { - const offset = this.bb.__offset(this.bb_pos, 6); - if (offset === 0) { - return false; - } - this.bb.writeInt64(this.bb_pos + offset, value); - return true; - } - unionType(obj) { - const offset = this.bb.__offset(this.bb_pos, 10); - return offset ? (obj || new Type()).__init(this.bb.__indirect(this.bb_pos + offset), this.bb) : null; - } - documentation(index, optionalEncoding) { - const offset = this.bb.__offset(this.bb_pos, 12); - return offset ? this.bb.__string(this.bb.__vector(this.bb_pos + offset) + index * 4, optionalEncoding) : null; - } - documentationLength() { - const offset = this.bb.__offset(this.bb_pos, 12); - return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; - } - static getFullyQualifiedName() { - return 'reflection_EnumVal'; - } - static startEnumVal(builder) { - builder.startObject(5); - } - static addName(builder, nameOffset) { - builder.addFieldOffset(0, nameOffset, 0); - } - static addValue(builder, value) { - builder.addFieldInt64(1, value, BigInt('0')); - } - static addUnionType(builder, unionTypeOffset) { - builder.addFieldOffset(3, unionTypeOffset, 0); - } - static addDocumentation(builder, documentationOffset) { - builder.addFieldOffset(4, documentationOffset, 0); - } - static createDocumentationVector(builder, data) { - builder.startVector(4, data.length, 4); - for (let i = data.length - 1; i >= 0; i--) { - builder.addOffset(data[i]); - } - return builder.endVector(); - } - static startDocumentationVector(builder, numElems) { - builder.startVector(4, numElems, 4); - } - static endEnumVal(builder) { - const offset = builder.endObject(); - builder.requiredField(offset, 4); // name - return offset; - } - unpack() { - return new EnumValT(this.name(), this.value(), (this.unionType() !== null ? this.unionType().unpack() : null), this.bb.createScalarList(this.documentation.bind(this), this.documentationLength())); - } - unpackTo(_o) { - _o.name = this.name(); - _o.value = this.value(); - _o.unionType = (this.unionType() !== null ? this.unionType().unpack() : null); - _o.documentation = this.bb.createScalarList(this.documentation.bind(this), this.documentationLength()); - } -} -export class EnumValT { - constructor(name = null, value = BigInt('0'), unionType = null, documentation = []) { - this.name = name; - this.value = value; - this.unionType = unionType; - this.documentation = documentation; - } - pack(builder) { - const name = (this.name !== null ? builder.createString(this.name) : 0); - const unionType = (this.unionType !== null ? this.unionType.pack(builder) : 0); - const documentation = EnumVal.createDocumentationVector(builder, builder.createObjectOffsetList(this.documentation)); - EnumVal.startEnumVal(builder); - EnumVal.addName(builder, name); - EnumVal.addValue(builder, this.value); - EnumVal.addUnionType(builder, unionType); - EnumVal.addDocumentation(builder, documentation); - return EnumVal.endEnumVal(builder); - } -} -export class Enum { - constructor() { - this.bb = null; - this.bb_pos = 0; - } - __init(i, bb) { - this.bb_pos = i; - this.bb = bb; - return this; - } - static getRootAsEnum(bb, obj) { - return (obj || new Enum()).__init(bb.readInt32(bb.position()) + bb.position(), bb); - } - static getSizePrefixedRootAsEnum(bb, obj) { - bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); - return (obj || new Enum()).__init(bb.readInt32(bb.position()) + bb.position(), bb); - } - name(optionalEncoding) { - const offset = this.bb.__offset(this.bb_pos, 4); - return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null; - } - values(index, obj) { - const offset = this.bb.__offset(this.bb_pos, 6); - return offset ? (obj || new EnumVal()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4), this.bb) : null; - } - valuesLength() { - const offset = this.bb.__offset(this.bb_pos, 6); - return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; - } - isUnion() { - const offset = this.bb.__offset(this.bb_pos, 8); - return offset ? !!this.bb.readInt8(this.bb_pos + offset) : false; - } - mutate_is_union(value) { - const offset = this.bb.__offset(this.bb_pos, 8); - if (offset === 0) { - return false; - } - this.bb.writeInt8(this.bb_pos + offset, +value); - return true; - } - underlyingType(obj) { - const offset = this.bb.__offset(this.bb_pos, 10); - return offset ? (obj || new Type()).__init(this.bb.__indirect(this.bb_pos + offset), this.bb) : null; - } - attributes(index, obj) { - const offset = this.bb.__offset(this.bb_pos, 12); - return offset ? (obj || new KeyValue()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4), this.bb) : null; - } - attributesLength() { - const offset = this.bb.__offset(this.bb_pos, 12); - return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; - } - documentation(index, optionalEncoding) { - const offset = this.bb.__offset(this.bb_pos, 14); - return offset ? this.bb.__string(this.bb.__vector(this.bb_pos + offset) + index * 4, optionalEncoding) : null; - } - documentationLength() { - const offset = this.bb.__offset(this.bb_pos, 14); - return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; - } - declarationFile(optionalEncoding) { - const offset = this.bb.__offset(this.bb_pos, 16); - return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null; - } - static getFullyQualifiedName() { - return 'reflection_Enum'; - } - static startEnum(builder) { - builder.startObject(7); - } - static addName(builder, nameOffset) { - builder.addFieldOffset(0, nameOffset, 0); - } - static addValues(builder, valuesOffset) { - builder.addFieldOffset(1, valuesOffset, 0); - } - static createValuesVector(builder, data) { - builder.startVector(4, data.length, 4); - for (let i = data.length - 1; i >= 0; i--) { - builder.addOffset(data[i]); - } - return builder.endVector(); - } - static startValuesVector(builder, numElems) { - builder.startVector(4, numElems, 4); - } - static addIsUnion(builder, isUnion) { - builder.addFieldInt8(2, +isUnion, +false); - } - static addUnderlyingType(builder, underlyingTypeOffset) { - builder.addFieldOffset(3, underlyingTypeOffset, 0); - } - static addAttributes(builder, attributesOffset) { - builder.addFieldOffset(4, attributesOffset, 0); - } - static createAttributesVector(builder, data) { - builder.startVector(4, data.length, 4); - for (let i = data.length - 1; i >= 0; i--) { - builder.addOffset(data[i]); - } - return builder.endVector(); - } - static startAttributesVector(builder, numElems) { - builder.startVector(4, numElems, 4); - } - static addDocumentation(builder, documentationOffset) { - builder.addFieldOffset(5, documentationOffset, 0); - } - static createDocumentationVector(builder, data) { - builder.startVector(4, data.length, 4); - for (let i = data.length - 1; i >= 0; i--) { - builder.addOffset(data[i]); - } - return builder.endVector(); - } - static startDocumentationVector(builder, numElems) { - builder.startVector(4, numElems, 4); - } - static addDeclarationFile(builder, declarationFileOffset) { - builder.addFieldOffset(6, declarationFileOffset, 0); - } - static endEnum(builder) { - const offset = builder.endObject(); - builder.requiredField(offset, 4); // name - builder.requiredField(offset, 6); // values - builder.requiredField(offset, 10); // underlying_type - return offset; - } - unpack() { - return new EnumT(this.name(), this.bb.createObjList(this.values.bind(this), this.valuesLength()), this.isUnion(), (this.underlyingType() !== null ? this.underlyingType().unpack() : null), this.bb.createObjList(this.attributes.bind(this), this.attributesLength()), this.bb.createScalarList(this.documentation.bind(this), this.documentationLength()), this.declarationFile()); - } - unpackTo(_o) { - _o.name = this.name(); - _o.values = this.bb.createObjList(this.values.bind(this), this.valuesLength()); - _o.isUnion = this.isUnion(); - _o.underlyingType = (this.underlyingType() !== null ? this.underlyingType().unpack() : null); - _o.attributes = this.bb.createObjList(this.attributes.bind(this), this.attributesLength()); - _o.documentation = this.bb.createScalarList(this.documentation.bind(this), this.documentationLength()); - _o.declarationFile = this.declarationFile(); - } -} -export class EnumT { - constructor(name = null, values = [], isUnion = false, underlyingType = null, attributes = [], documentation = [], declarationFile = null) { - this.name = name; - this.values = values; - this.isUnion = isUnion; - this.underlyingType = underlyingType; - this.attributes = attributes; - this.documentation = documentation; - this.declarationFile = declarationFile; - } - pack(builder) { - const name = (this.name !== null ? builder.createString(this.name) : 0); - const values = Enum.createValuesVector(builder, builder.createObjectOffsetList(this.values)); - const underlyingType = (this.underlyingType !== null ? this.underlyingType.pack(builder) : 0); - const attributes = Enum.createAttributesVector(builder, builder.createObjectOffsetList(this.attributes)); - const documentation = Enum.createDocumentationVector(builder, builder.createObjectOffsetList(this.documentation)); - const declarationFile = (this.declarationFile !== null ? builder.createString(this.declarationFile) : 0); - Enum.startEnum(builder); - Enum.addName(builder, name); - Enum.addValues(builder, values); - Enum.addIsUnion(builder, this.isUnion); - Enum.addUnderlyingType(builder, underlyingType); - Enum.addAttributes(builder, attributes); - Enum.addDocumentation(builder, documentation); - Enum.addDeclarationFile(builder, declarationFile); - return Enum.endEnum(builder); - } -} -export class Field { - constructor() { - this.bb = null; - this.bb_pos = 0; - } - __init(i, bb) { - this.bb_pos = i; - this.bb = bb; - return this; - } - static getRootAsField(bb, obj) { - return (obj || new Field()).__init(bb.readInt32(bb.position()) + bb.position(), bb); - } - static getSizePrefixedRootAsField(bb, obj) { - bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); - return (obj || new Field()).__init(bb.readInt32(bb.position()) + bb.position(), bb); - } - name(optionalEncoding) { - const offset = this.bb.__offset(this.bb_pos, 4); - return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null; - } - type(obj) { - const offset = this.bb.__offset(this.bb_pos, 6); - return offset ? (obj || new Type()).__init(this.bb.__indirect(this.bb_pos + offset), this.bb) : null; - } - id() { - const offset = this.bb.__offset(this.bb_pos, 8); - return offset ? this.bb.readUint16(this.bb_pos + offset) : 0; - } - mutate_id(value) { - const offset = this.bb.__offset(this.bb_pos, 8); - if (offset === 0) { - return false; - } - this.bb.writeUint16(this.bb_pos + offset, value); - return true; - } - offset() { - const offset = this.bb.__offset(this.bb_pos, 10); - return offset ? this.bb.readUint16(this.bb_pos + offset) : 0; - } - mutate_offset(value) { - const offset = this.bb.__offset(this.bb_pos, 10); - if (offset === 0) { - return false; - } - this.bb.writeUint16(this.bb_pos + offset, value); - return true; - } - defaultInteger() { - const offset = this.bb.__offset(this.bb_pos, 12); - return offset ? this.bb.readInt64(this.bb_pos + offset) : BigInt('0'); - } - mutate_default_integer(value) { - const offset = this.bb.__offset(this.bb_pos, 12); - if (offset === 0) { - return false; - } - this.bb.writeInt64(this.bb_pos + offset, value); - return true; - } - defaultReal() { - const offset = this.bb.__offset(this.bb_pos, 14); - return offset ? this.bb.readFloat64(this.bb_pos + offset) : 0.0; - } - mutate_default_real(value) { - const offset = this.bb.__offset(this.bb_pos, 14); - if (offset === 0) { - return false; - } - this.bb.writeFloat64(this.bb_pos + offset, value); - return true; - } - deprecated() { - const offset = this.bb.__offset(this.bb_pos, 16); - return offset ? !!this.bb.readInt8(this.bb_pos + offset) : false; - } - mutate_deprecated(value) { - const offset = this.bb.__offset(this.bb_pos, 16); - if (offset === 0) { - return false; - } - this.bb.writeInt8(this.bb_pos + offset, +value); - return true; - } - required() { - const offset = this.bb.__offset(this.bb_pos, 18); - return offset ? !!this.bb.readInt8(this.bb_pos + offset) : false; - } - mutate_required(value) { - const offset = this.bb.__offset(this.bb_pos, 18); - if (offset === 0) { - return false; - } - this.bb.writeInt8(this.bb_pos + offset, +value); - return true; - } - key() { - const offset = this.bb.__offset(this.bb_pos, 20); - return offset ? !!this.bb.readInt8(this.bb_pos + offset) : false; - } - mutate_key(value) { - const offset = this.bb.__offset(this.bb_pos, 20); - if (offset === 0) { - return false; - } - this.bb.writeInt8(this.bb_pos + offset, +value); - return true; - } - attributes(index, obj) { - const offset = this.bb.__offset(this.bb_pos, 22); - return offset ? (obj || new KeyValue()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4), this.bb) : null; - } - attributesLength() { - const offset = this.bb.__offset(this.bb_pos, 22); - return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; - } - documentation(index, optionalEncoding) { - const offset = this.bb.__offset(this.bb_pos, 24); - return offset ? this.bb.__string(this.bb.__vector(this.bb_pos + offset) + index * 4, optionalEncoding) : null; - } - documentationLength() { - const offset = this.bb.__offset(this.bb_pos, 24); - return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; - } - optional() { - const offset = this.bb.__offset(this.bb_pos, 26); - return offset ? !!this.bb.readInt8(this.bb_pos + offset) : false; - } - mutate_optional(value) { - const offset = this.bb.__offset(this.bb_pos, 26); - if (offset === 0) { - return false; - } - this.bb.writeInt8(this.bb_pos + offset, +value); - return true; - } - /** - * Number of padding octets to always add after this field. Structs only. - */ - padding() { - const offset = this.bb.__offset(this.bb_pos, 28); - return offset ? this.bb.readUint16(this.bb_pos + offset) : 0; - } - mutate_padding(value) { - const offset = this.bb.__offset(this.bb_pos, 28); - if (offset === 0) { - return false; - } - this.bb.writeUint16(this.bb_pos + offset, value); - return true; - } - static getFullyQualifiedName() { - return 'reflection_Field'; - } - static startField(builder) { - builder.startObject(13); - } - static addName(builder, nameOffset) { - builder.addFieldOffset(0, nameOffset, 0); - } - static addType(builder, typeOffset) { - builder.addFieldOffset(1, typeOffset, 0); - } - static addId(builder, id) { - builder.addFieldInt16(2, id, 0); - } - static addOffset(builder, offset) { - builder.addFieldInt16(3, offset, 0); - } - static addDefaultInteger(builder, defaultInteger) { - builder.addFieldInt64(4, defaultInteger, BigInt('0')); - } - static addDefaultReal(builder, defaultReal) { - builder.addFieldFloat64(5, defaultReal, 0.0); - } - static addDeprecated(builder, deprecated) { - builder.addFieldInt8(6, +deprecated, +false); - } - static addRequired(builder, required) { - builder.addFieldInt8(7, +required, +false); - } - static addKey(builder, key) { - builder.addFieldInt8(8, +key, +false); - } - static addAttributes(builder, attributesOffset) { - builder.addFieldOffset(9, attributesOffset, 0); - } - static createAttributesVector(builder, data) { - builder.startVector(4, data.length, 4); - for (let i = data.length - 1; i >= 0; i--) { - builder.addOffset(data[i]); - } - return builder.endVector(); - } - static startAttributesVector(builder, numElems) { - builder.startVector(4, numElems, 4); - } - static addDocumentation(builder, documentationOffset) { - builder.addFieldOffset(10, documentationOffset, 0); - } - static createDocumentationVector(builder, data) { - builder.startVector(4, data.length, 4); - for (let i = data.length - 1; i >= 0; i--) { - builder.addOffset(data[i]); - } - return builder.endVector(); - } - static startDocumentationVector(builder, numElems) { - builder.startVector(4, numElems, 4); - } - static addOptional(builder, optional) { - builder.addFieldInt8(11, +optional, +false); - } - static addPadding(builder, padding) { - builder.addFieldInt16(12, padding, 0); - } - static endField(builder) { - const offset = builder.endObject(); - builder.requiredField(offset, 4); // name - builder.requiredField(offset, 6); // type - return offset; - } - unpack() { - return new FieldT(this.name(), (this.type() !== null ? this.type().unpack() : null), this.id(), this.offset(), this.defaultInteger(), this.defaultReal(), this.deprecated(), this.required(), this.key(), this.bb.createObjList(this.attributes.bind(this), this.attributesLength()), this.bb.createScalarList(this.documentation.bind(this), this.documentationLength()), this.optional(), this.padding()); - } - unpackTo(_o) { - _o.name = this.name(); - _o.type = (this.type() !== null ? this.type().unpack() : null); - _o.id = this.id(); - _o.offset = this.offset(); - _o.defaultInteger = this.defaultInteger(); - _o.defaultReal = this.defaultReal(); - _o.deprecated = this.deprecated(); - _o.required = this.required(); - _o.key = this.key(); - _o.attributes = this.bb.createObjList(this.attributes.bind(this), this.attributesLength()); - _o.documentation = this.bb.createScalarList(this.documentation.bind(this), this.documentationLength()); - _o.optional = this.optional(); - _o.padding = this.padding(); - } -} -export class FieldT { - constructor(name = null, type = null, id = 0, offset = 0, defaultInteger = BigInt('0'), defaultReal = 0.0, deprecated = false, required = false, key = false, attributes = [], documentation = [], optional = false, padding = 0) { - this.name = name; - this.type = type; - this.id = id; - this.offset = offset; - this.defaultInteger = defaultInteger; - this.defaultReal = defaultReal; - this.deprecated = deprecated; - this.required = required; - this.key = key; - this.attributes = attributes; - this.documentation = documentation; - this.optional = optional; - this.padding = padding; - } - pack(builder) { - const name = (this.name !== null ? builder.createString(this.name) : 0); - const type = (this.type !== null ? this.type.pack(builder) : 0); - const attributes = Field.createAttributesVector(builder, builder.createObjectOffsetList(this.attributes)); - const documentation = Field.createDocumentationVector(builder, builder.createObjectOffsetList(this.documentation)); - Field.startField(builder); - Field.addName(builder, name); - Field.addType(builder, type); - Field.addId(builder, this.id); - Field.addOffset(builder, this.offset); - Field.addDefaultInteger(builder, this.defaultInteger); - Field.addDefaultReal(builder, this.defaultReal); - Field.addDeprecated(builder, this.deprecated); - Field.addRequired(builder, this.required); - Field.addKey(builder, this.key); - Field.addAttributes(builder, attributes); - Field.addDocumentation(builder, documentation); - Field.addOptional(builder, this.optional); - Field.addPadding(builder, this.padding); - return Field.endField(builder); - } -} -export class Object_ { - constructor() { - this.bb = null; - this.bb_pos = 0; - } - __init(i, bb) { - this.bb_pos = i; - this.bb = bb; - return this; - } - static getRootAsObject(bb, obj) { - return (obj || new Object_()).__init(bb.readInt32(bb.position()) + bb.position(), bb); - } - static getSizePrefixedRootAsObject(bb, obj) { - bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); - return (obj || new Object_()).__init(bb.readInt32(bb.position()) + bb.position(), bb); - } - name(optionalEncoding) { - const offset = this.bb.__offset(this.bb_pos, 4); - return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null; - } - fields(index, obj) { - const offset = this.bb.__offset(this.bb_pos, 6); - return offset ? (obj || new Field()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4), this.bb) : null; - } - fieldsLength() { - const offset = this.bb.__offset(this.bb_pos, 6); - return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; - } - isStruct() { - const offset = this.bb.__offset(this.bb_pos, 8); - return offset ? !!this.bb.readInt8(this.bb_pos + offset) : false; - } - mutate_is_struct(value) { - const offset = this.bb.__offset(this.bb_pos, 8); - if (offset === 0) { - return false; - } - this.bb.writeInt8(this.bb_pos + offset, +value); - return true; - } - minalign() { - const offset = this.bb.__offset(this.bb_pos, 10); - return offset ? this.bb.readInt32(this.bb_pos + offset) : 0; - } - mutate_minalign(value) { - const offset = this.bb.__offset(this.bb_pos, 10); - if (offset === 0) { - return false; - } - this.bb.writeInt32(this.bb_pos + offset, value); - return true; - } - bytesize() { - const offset = this.bb.__offset(this.bb_pos, 12); - return offset ? this.bb.readInt32(this.bb_pos + offset) : 0; - } - mutate_bytesize(value) { - const offset = this.bb.__offset(this.bb_pos, 12); - if (offset === 0) { - return false; - } - this.bb.writeInt32(this.bb_pos + offset, value); - return true; - } - attributes(index, obj) { - const offset = this.bb.__offset(this.bb_pos, 14); - return offset ? (obj || new KeyValue()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4), this.bb) : null; - } - attributesLength() { - const offset = this.bb.__offset(this.bb_pos, 14); - return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; - } - documentation(index, optionalEncoding) { - const offset = this.bb.__offset(this.bb_pos, 16); - return offset ? this.bb.__string(this.bb.__vector(this.bb_pos + offset) + index * 4, optionalEncoding) : null; - } - documentationLength() { - const offset = this.bb.__offset(this.bb_pos, 16); - return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; - } - declarationFile(optionalEncoding) { - const offset = this.bb.__offset(this.bb_pos, 18); - return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null; - } - static getFullyQualifiedName() { - return 'reflection_Object'; - } - static startObject(builder) { - builder.startObject(8); - } - static addName(builder, nameOffset) { - builder.addFieldOffset(0, nameOffset, 0); - } - static addFields(builder, fieldsOffset) { - builder.addFieldOffset(1, fieldsOffset, 0); - } - static createFieldsVector(builder, data) { - builder.startVector(4, data.length, 4); - for (let i = data.length - 1; i >= 0; i--) { - builder.addOffset(data[i]); - } - return builder.endVector(); - } - static startFieldsVector(builder, numElems) { - builder.startVector(4, numElems, 4); - } - static addIsStruct(builder, isStruct) { - builder.addFieldInt8(2, +isStruct, +false); - } - static addMinalign(builder, minalign) { - builder.addFieldInt32(3, minalign, 0); - } - static addBytesize(builder, bytesize) { - builder.addFieldInt32(4, bytesize, 0); - } - static addAttributes(builder, attributesOffset) { - builder.addFieldOffset(5, attributesOffset, 0); - } - static createAttributesVector(builder, data) { - builder.startVector(4, data.length, 4); - for (let i = data.length - 1; i >= 0; i--) { - builder.addOffset(data[i]); - } - return builder.endVector(); - } - static startAttributesVector(builder, numElems) { - builder.startVector(4, numElems, 4); - } - static addDocumentation(builder, documentationOffset) { - builder.addFieldOffset(6, documentationOffset, 0); - } - static createDocumentationVector(builder, data) { - builder.startVector(4, data.length, 4); - for (let i = data.length - 1; i >= 0; i--) { - builder.addOffset(data[i]); - } - return builder.endVector(); - } - static startDocumentationVector(builder, numElems) { - builder.startVector(4, numElems, 4); - } - static addDeclarationFile(builder, declarationFileOffset) { - builder.addFieldOffset(7, declarationFileOffset, 0); - } - static endObject(builder) { - const offset = builder.endObject(); - builder.requiredField(offset, 4); // name - builder.requiredField(offset, 6); // fields - return offset; - } - static createObject(builder, nameOffset, fieldsOffset, isStruct, minalign, bytesize, attributesOffset, documentationOffset, declarationFileOffset) { - Object_.startObject(builder); - Object_.addName(builder, nameOffset); - Object_.addFields(builder, fieldsOffset); - Object_.addIsStruct(builder, isStruct); - Object_.addMinalign(builder, minalign); - Object_.addBytesize(builder, bytesize); - Object_.addAttributes(builder, attributesOffset); - Object_.addDocumentation(builder, documentationOffset); - Object_.addDeclarationFile(builder, declarationFileOffset); - return Object_.endObject(builder); - } - unpack() { - return new Object_T(this.name(), this.bb.createObjList(this.fields.bind(this), this.fieldsLength()), this.isStruct(), this.minalign(), this.bytesize(), this.bb.createObjList(this.attributes.bind(this), this.attributesLength()), this.bb.createScalarList(this.documentation.bind(this), this.documentationLength()), this.declarationFile()); - } - unpackTo(_o) { - _o.name = this.name(); - _o.fields = this.bb.createObjList(this.fields.bind(this), this.fieldsLength()); - _o.isStruct = this.isStruct(); - _o.minalign = this.minalign(); - _o.bytesize = this.bytesize(); - _o.attributes = this.bb.createObjList(this.attributes.bind(this), this.attributesLength()); - _o.documentation = this.bb.createScalarList(this.documentation.bind(this), this.documentationLength()); - _o.declarationFile = this.declarationFile(); - } -} -export class Object_T { - constructor(name = null, fields = [], isStruct = false, minalign = 0, bytesize = 0, attributes = [], documentation = [], declarationFile = null) { - this.name = name; - this.fields = fields; - this.isStruct = isStruct; - this.minalign = minalign; - this.bytesize = bytesize; - this.attributes = attributes; - this.documentation = documentation; - this.declarationFile = declarationFile; - } - pack(builder) { - const name = (this.name !== null ? builder.createString(this.name) : 0); - const fields = Object_.createFieldsVector(builder, builder.createObjectOffsetList(this.fields)); - const attributes = Object_.createAttributesVector(builder, builder.createObjectOffsetList(this.attributes)); - const documentation = Object_.createDocumentationVector(builder, builder.createObjectOffsetList(this.documentation)); - const declarationFile = (this.declarationFile !== null ? builder.createString(this.declarationFile) : 0); - return Object_.createObject(builder, name, fields, this.isStruct, this.minalign, this.bytesize, attributes, documentation, declarationFile); - } -} -export class RPCCall { - constructor() { - this.bb = null; - this.bb_pos = 0; - } - __init(i, bb) { - this.bb_pos = i; - this.bb = bb; - return this; - } - static getRootAsRPCCall(bb, obj) { - return (obj || new RPCCall()).__init(bb.readInt32(bb.position()) + bb.position(), bb); - } - static getSizePrefixedRootAsRPCCall(bb, obj) { - bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); - return (obj || new RPCCall()).__init(bb.readInt32(bb.position()) + bb.position(), bb); - } - name(optionalEncoding) { - const offset = this.bb.__offset(this.bb_pos, 4); - return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null; - } - request(obj) { - const offset = this.bb.__offset(this.bb_pos, 6); - return offset ? (obj || new Object_()).__init(this.bb.__indirect(this.bb_pos + offset), this.bb) : null; - } - response(obj) { - const offset = this.bb.__offset(this.bb_pos, 8); - return offset ? (obj || new Object_()).__init(this.bb.__indirect(this.bb_pos + offset), this.bb) : null; - } - attributes(index, obj) { - const offset = this.bb.__offset(this.bb_pos, 10); - return offset ? (obj || new KeyValue()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4), this.bb) : null; - } - attributesLength() { - const offset = this.bb.__offset(this.bb_pos, 10); - return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; - } - documentation(index, optionalEncoding) { - const offset = this.bb.__offset(this.bb_pos, 12); - return offset ? this.bb.__string(this.bb.__vector(this.bb_pos + offset) + index * 4, optionalEncoding) : null; - } - documentationLength() { - const offset = this.bb.__offset(this.bb_pos, 12); - return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; - } - static getFullyQualifiedName() { - return 'reflection_RPCCall'; - } - static startRPCCall(builder) { - builder.startObject(5); - } - static addName(builder, nameOffset) { - builder.addFieldOffset(0, nameOffset, 0); - } - static addRequest(builder, requestOffset) { - builder.addFieldOffset(1, requestOffset, 0); - } - static addResponse(builder, responseOffset) { - builder.addFieldOffset(2, responseOffset, 0); - } - static addAttributes(builder, attributesOffset) { - builder.addFieldOffset(3, attributesOffset, 0); - } - static createAttributesVector(builder, data) { - builder.startVector(4, data.length, 4); - for (let i = data.length - 1; i >= 0; i--) { - builder.addOffset(data[i]); - } - return builder.endVector(); - } - static startAttributesVector(builder, numElems) { - builder.startVector(4, numElems, 4); - } - static addDocumentation(builder, documentationOffset) { - builder.addFieldOffset(4, documentationOffset, 0); - } - static createDocumentationVector(builder, data) { - builder.startVector(4, data.length, 4); - for (let i = data.length - 1; i >= 0; i--) { - builder.addOffset(data[i]); - } - return builder.endVector(); - } - static startDocumentationVector(builder, numElems) { - builder.startVector(4, numElems, 4); - } - static endRPCCall(builder) { - const offset = builder.endObject(); - builder.requiredField(offset, 4); // name - builder.requiredField(offset, 6); // request - builder.requiredField(offset, 8); // response - return offset; - } - unpack() { - return new RPCCallT(this.name(), (this.request() !== null ? this.request().unpack() : null), (this.response() !== null ? this.response().unpack() : null), this.bb.createObjList(this.attributes.bind(this), this.attributesLength()), this.bb.createScalarList(this.documentation.bind(this), this.documentationLength())); - } - unpackTo(_o) { - _o.name = this.name(); - _o.request = (this.request() !== null ? this.request().unpack() : null); - _o.response = (this.response() !== null ? this.response().unpack() : null); - _o.attributes = this.bb.createObjList(this.attributes.bind(this), this.attributesLength()); - _o.documentation = this.bb.createScalarList(this.documentation.bind(this), this.documentationLength()); - } -} -export class RPCCallT { - constructor(name = null, request = null, response = null, attributes = [], documentation = []) { - this.name = name; - this.request = request; - this.response = response; - this.attributes = attributes; - this.documentation = documentation; - } - pack(builder) { - const name = (this.name !== null ? builder.createString(this.name) : 0); - const request = (this.request !== null ? this.request.pack(builder) : 0); - const response = (this.response !== null ? this.response.pack(builder) : 0); - const attributes = RPCCall.createAttributesVector(builder, builder.createObjectOffsetList(this.attributes)); - const documentation = RPCCall.createDocumentationVector(builder, builder.createObjectOffsetList(this.documentation)); - RPCCall.startRPCCall(builder); - RPCCall.addName(builder, name); - RPCCall.addRequest(builder, request); - RPCCall.addResponse(builder, response); - RPCCall.addAttributes(builder, attributes); - RPCCall.addDocumentation(builder, documentation); - return RPCCall.endRPCCall(builder); - } -} -export class Service { - constructor() { - this.bb = null; - this.bb_pos = 0; - } - __init(i, bb) { - this.bb_pos = i; - this.bb = bb; - return this; - } - static getRootAsService(bb, obj) { - return (obj || new Service()).__init(bb.readInt32(bb.position()) + bb.position(), bb); - } - static getSizePrefixedRootAsService(bb, obj) { - bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); - return (obj || new Service()).__init(bb.readInt32(bb.position()) + bb.position(), bb); - } - name(optionalEncoding) { - const offset = this.bb.__offset(this.bb_pos, 4); - return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null; - } - calls(index, obj) { - const offset = this.bb.__offset(this.bb_pos, 6); - return offset ? (obj || new RPCCall()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4), this.bb) : null; - } - callsLength() { - const offset = this.bb.__offset(this.bb_pos, 6); - return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; - } - attributes(index, obj) { - const offset = this.bb.__offset(this.bb_pos, 8); - return offset ? (obj || new KeyValue()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4), this.bb) : null; - } - attributesLength() { - const offset = this.bb.__offset(this.bb_pos, 8); - return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; - } - documentation(index, optionalEncoding) { - const offset = this.bb.__offset(this.bb_pos, 10); - return offset ? this.bb.__string(this.bb.__vector(this.bb_pos + offset) + index * 4, optionalEncoding) : null; - } - documentationLength() { - const offset = this.bb.__offset(this.bb_pos, 10); - return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; - } - declarationFile(optionalEncoding) { - const offset = this.bb.__offset(this.bb_pos, 12); - return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null; - } - static getFullyQualifiedName() { - return 'reflection_Service'; - } - static startService(builder) { - builder.startObject(5); - } - static addName(builder, nameOffset) { - builder.addFieldOffset(0, nameOffset, 0); - } - static addCalls(builder, callsOffset) { - builder.addFieldOffset(1, callsOffset, 0); - } - static createCallsVector(builder, data) { - builder.startVector(4, data.length, 4); - for (let i = data.length - 1; i >= 0; i--) { - builder.addOffset(data[i]); - } - return builder.endVector(); - } - static startCallsVector(builder, numElems) { - builder.startVector(4, numElems, 4); - } - static addAttributes(builder, attributesOffset) { - builder.addFieldOffset(2, attributesOffset, 0); - } - static createAttributesVector(builder, data) { - builder.startVector(4, data.length, 4); - for (let i = data.length - 1; i >= 0; i--) { - builder.addOffset(data[i]); - } - return builder.endVector(); - } - static startAttributesVector(builder, numElems) { - builder.startVector(4, numElems, 4); - } - static addDocumentation(builder, documentationOffset) { - builder.addFieldOffset(3, documentationOffset, 0); - } - static createDocumentationVector(builder, data) { - builder.startVector(4, data.length, 4); - for (let i = data.length - 1; i >= 0; i--) { - builder.addOffset(data[i]); - } - return builder.endVector(); - } - static startDocumentationVector(builder, numElems) { - builder.startVector(4, numElems, 4); - } - static addDeclarationFile(builder, declarationFileOffset) { - builder.addFieldOffset(4, declarationFileOffset, 0); - } - static endService(builder) { - const offset = builder.endObject(); - builder.requiredField(offset, 4); // name - return offset; - } - static createService(builder, nameOffset, callsOffset, attributesOffset, documentationOffset, declarationFileOffset) { - Service.startService(builder); - Service.addName(builder, nameOffset); - Service.addCalls(builder, callsOffset); - Service.addAttributes(builder, attributesOffset); - Service.addDocumentation(builder, documentationOffset); - Service.addDeclarationFile(builder, declarationFileOffset); - return Service.endService(builder); - } - unpack() { - return new ServiceT(this.name(), this.bb.createObjList(this.calls.bind(this), this.callsLength()), this.bb.createObjList(this.attributes.bind(this), this.attributesLength()), this.bb.createScalarList(this.documentation.bind(this), this.documentationLength()), this.declarationFile()); - } - unpackTo(_o) { - _o.name = this.name(); - _o.calls = this.bb.createObjList(this.calls.bind(this), this.callsLength()); - _o.attributes = this.bb.createObjList(this.attributes.bind(this), this.attributesLength()); - _o.documentation = this.bb.createScalarList(this.documentation.bind(this), this.documentationLength()); - _o.declarationFile = this.declarationFile(); - } -} -export class ServiceT { - constructor(name = null, calls = [], attributes = [], documentation = [], declarationFile = null) { - this.name = name; - this.calls = calls; - this.attributes = attributes; - this.documentation = documentation; - this.declarationFile = declarationFile; - } - pack(builder) { - const name = (this.name !== null ? builder.createString(this.name) : 0); - const calls = Service.createCallsVector(builder, builder.createObjectOffsetList(this.calls)); - const attributes = Service.createAttributesVector(builder, builder.createObjectOffsetList(this.attributes)); - const documentation = Service.createDocumentationVector(builder, builder.createObjectOffsetList(this.documentation)); - const declarationFile = (this.declarationFile !== null ? builder.createString(this.declarationFile) : 0); - return Service.createService(builder, name, calls, attributes, documentation, declarationFile); - } -} -/** - * File specific information. - * Symbols declared within a file may be recovered by iterating over all - * symbols and examining the `declaration_file` field. - */ -export class SchemaFile { - constructor() { - this.bb = null; - this.bb_pos = 0; - } - __init(i, bb) { - this.bb_pos = i; - this.bb = bb; - return this; - } - static getRootAsSchemaFile(bb, obj) { - return (obj || new SchemaFile()).__init(bb.readInt32(bb.position()) + bb.position(), bb); - } - static getSizePrefixedRootAsSchemaFile(bb, obj) { - bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); - return (obj || new SchemaFile()).__init(bb.readInt32(bb.position()) + bb.position(), bb); - } - filename(optionalEncoding) { - const offset = this.bb.__offset(this.bb_pos, 4); - return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null; - } - includedFilenames(index, optionalEncoding) { - const offset = this.bb.__offset(this.bb_pos, 6); - return offset ? this.bb.__string(this.bb.__vector(this.bb_pos + offset) + index * 4, optionalEncoding) : null; - } - includedFilenamesLength() { - const offset = this.bb.__offset(this.bb_pos, 6); - return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; - } - static getFullyQualifiedName() { - return 'reflection_SchemaFile'; - } - static startSchemaFile(builder) { - builder.startObject(2); - } - static addFilename(builder, filenameOffset) { - builder.addFieldOffset(0, filenameOffset, 0); - } - static addIncludedFilenames(builder, includedFilenamesOffset) { - builder.addFieldOffset(1, includedFilenamesOffset, 0); - } - static createIncludedFilenamesVector(builder, data) { - builder.startVector(4, data.length, 4); - for (let i = data.length - 1; i >= 0; i--) { - builder.addOffset(data[i]); - } - return builder.endVector(); - } - static startIncludedFilenamesVector(builder, numElems) { - builder.startVector(4, numElems, 4); - } - static endSchemaFile(builder) { - const offset = builder.endObject(); - builder.requiredField(offset, 4); // filename - return offset; - } - static createSchemaFile(builder, filenameOffset, includedFilenamesOffset) { - SchemaFile.startSchemaFile(builder); - SchemaFile.addFilename(builder, filenameOffset); - SchemaFile.addIncludedFilenames(builder, includedFilenamesOffset); - return SchemaFile.endSchemaFile(builder); - } - unpack() { - return new SchemaFileT(this.filename(), this.bb.createScalarList(this.includedFilenames.bind(this), this.includedFilenamesLength())); - } - unpackTo(_o) { - _o.filename = this.filename(); - _o.includedFilenames = this.bb.createScalarList(this.includedFilenames.bind(this), this.includedFilenamesLength()); - } -} -export class SchemaFileT { - constructor(filename = null, includedFilenames = []) { - this.filename = filename; - this.includedFilenames = includedFilenames; - } - pack(builder) { - const filename = (this.filename !== null ? builder.createString(this.filename) : 0); - const includedFilenames = SchemaFile.createIncludedFilenamesVector(builder, builder.createObjectOffsetList(this.includedFilenames)); - return SchemaFile.createSchemaFile(builder, filename, includedFilenames); - } -} -export class Schema { - constructor() { - this.bb = null; - this.bb_pos = 0; - } - __init(i, bb) { - this.bb_pos = i; - this.bb = bb; - return this; - } - static getRootAsSchema(bb, obj) { - return (obj || new Schema()).__init(bb.readInt32(bb.position()) + bb.position(), bb); - } - static getSizePrefixedRootAsSchema(bb, obj) { - bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); - return (obj || new Schema()).__init(bb.readInt32(bb.position()) + bb.position(), bb); - } - static bufferHasIdentifier(bb) { - return bb.__has_identifier('BFBS'); - } - objects(index, obj) { - const offset = this.bb.__offset(this.bb_pos, 4); - return offset ? (obj || new Object_()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4), this.bb) : null; - } - objectsLength() { - const offset = this.bb.__offset(this.bb_pos, 4); - return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; - } - enums(index, obj) { - const offset = this.bb.__offset(this.bb_pos, 6); - return offset ? (obj || new Enum()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4), this.bb) : null; - } - enumsLength() { - const offset = this.bb.__offset(this.bb_pos, 6); - return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; - } - fileIdent(optionalEncoding) { - const offset = this.bb.__offset(this.bb_pos, 8); - return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null; - } - fileExt(optionalEncoding) { - const offset = this.bb.__offset(this.bb_pos, 10); - return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null; - } - rootTable(obj) { - const offset = this.bb.__offset(this.bb_pos, 12); - return offset ? (obj || new Object_()).__init(this.bb.__indirect(this.bb_pos + offset), this.bb) : null; - } - services(index, obj) { - const offset = this.bb.__offset(this.bb_pos, 14); - return offset ? (obj || new Service()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4), this.bb) : null; - } - servicesLength() { - const offset = this.bb.__offset(this.bb_pos, 14); - return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; - } - advancedFeatures() { - const offset = this.bb.__offset(this.bb_pos, 16); - return offset ? this.bb.readUint64(this.bb_pos + offset) : BigInt('0'); - } - mutate_advanced_features(value) { - const offset = this.bb.__offset(this.bb_pos, 16); - if (offset === 0) { - return false; - } - this.bb.writeUint64(this.bb_pos + offset, value); - return true; - } - /** - * All the files used in this compilation. Files are relative to where - * flatc was invoked. - */ - fbsFiles(index, obj) { - const offset = this.bb.__offset(this.bb_pos, 18); - return offset ? (obj || new SchemaFile()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4), this.bb) : null; - } - fbsFilesLength() { - const offset = this.bb.__offset(this.bb_pos, 18); - return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; - } - static getFullyQualifiedName() { - return 'reflection_Schema'; - } - static startSchema(builder) { - builder.startObject(8); - } - static addObjects(builder, objectsOffset) { - builder.addFieldOffset(0, objectsOffset, 0); - } - static createObjectsVector(builder, data) { - builder.startVector(4, data.length, 4); - for (let i = data.length - 1; i >= 0; i--) { - builder.addOffset(data[i]); - } - return builder.endVector(); - } - static startObjectsVector(builder, numElems) { - builder.startVector(4, numElems, 4); - } - static addEnums(builder, enumsOffset) { - builder.addFieldOffset(1, enumsOffset, 0); - } - static createEnumsVector(builder, data) { - builder.startVector(4, data.length, 4); - for (let i = data.length - 1; i >= 0; i--) { - builder.addOffset(data[i]); - } - return builder.endVector(); - } - static startEnumsVector(builder, numElems) { - builder.startVector(4, numElems, 4); - } - static addFileIdent(builder, fileIdentOffset) { - builder.addFieldOffset(2, fileIdentOffset, 0); - } - static addFileExt(builder, fileExtOffset) { - builder.addFieldOffset(3, fileExtOffset, 0); - } - static addRootTable(builder, rootTableOffset) { - builder.addFieldOffset(4, rootTableOffset, 0); - } - static addServices(builder, servicesOffset) { - builder.addFieldOffset(5, servicesOffset, 0); - } - static createServicesVector(builder, data) { - builder.startVector(4, data.length, 4); - for (let i = data.length - 1; i >= 0; i--) { - builder.addOffset(data[i]); - } - return builder.endVector(); - } - static startServicesVector(builder, numElems) { - builder.startVector(4, numElems, 4); - } - static addAdvancedFeatures(builder, advancedFeatures) { - builder.addFieldInt64(6, advancedFeatures, BigInt('0')); - } - static addFbsFiles(builder, fbsFilesOffset) { - builder.addFieldOffset(7, fbsFilesOffset, 0); - } - static createFbsFilesVector(builder, data) { - builder.startVector(4, data.length, 4); - for (let i = data.length - 1; i >= 0; i--) { - builder.addOffset(data[i]); - } - return builder.endVector(); - } - static startFbsFilesVector(builder, numElems) { - builder.startVector(4, numElems, 4); - } - static endSchema(builder) { - const offset = builder.endObject(); - builder.requiredField(offset, 4); // objects - builder.requiredField(offset, 6); // enums - return offset; - } - static finishSchemaBuffer(builder, offset) { - builder.finish(offset, 'BFBS'); - } - static finishSizePrefixedSchemaBuffer(builder, offset) { - builder.finish(offset, 'BFBS', true); - } - unpack() { - return new SchemaT(this.bb.createObjList(this.objects.bind(this), this.objectsLength()), this.bb.createObjList(this.enums.bind(this), this.enumsLength()), this.fileIdent(), this.fileExt(), (this.rootTable() !== null ? this.rootTable().unpack() : null), this.bb.createObjList(this.services.bind(this), this.servicesLength()), this.advancedFeatures(), this.bb.createObjList(this.fbsFiles.bind(this), this.fbsFilesLength())); - } - unpackTo(_o) { - _o.objects = this.bb.createObjList(this.objects.bind(this), this.objectsLength()); - _o.enums = this.bb.createObjList(this.enums.bind(this), this.enumsLength()); - _o.fileIdent = this.fileIdent(); - _o.fileExt = this.fileExt(); - _o.rootTable = (this.rootTable() !== null ? this.rootTable().unpack() : null); - _o.services = this.bb.createObjList(this.services.bind(this), this.servicesLength()); - _o.advancedFeatures = this.advancedFeatures(); - _o.fbsFiles = this.bb.createObjList(this.fbsFiles.bind(this), this.fbsFilesLength()); - } -} -export class SchemaT { - constructor(objects = [], enums = [], fileIdent = null, fileExt = null, rootTable = null, services = [], advancedFeatures = BigInt('0'), fbsFiles = []) { - this.objects = objects; - this.enums = enums; - this.fileIdent = fileIdent; - this.fileExt = fileExt; - this.rootTable = rootTable; - this.services = services; - this.advancedFeatures = advancedFeatures; - this.fbsFiles = fbsFiles; - } - pack(builder) { - const objects = Schema.createObjectsVector(builder, builder.createObjectOffsetList(this.objects)); - const enums = Schema.createEnumsVector(builder, builder.createObjectOffsetList(this.enums)); - const fileIdent = (this.fileIdent !== null ? builder.createString(this.fileIdent) : 0); - const fileExt = (this.fileExt !== null ? builder.createString(this.fileExt) : 0); - const rootTable = (this.rootTable !== null ? this.rootTable.pack(builder) : 0); - const services = Schema.createServicesVector(builder, builder.createObjectOffsetList(this.services)); - const fbsFiles = Schema.createFbsFilesVector(builder, builder.createObjectOffsetList(this.fbsFiles)); - Schema.startSchema(builder); - Schema.addObjects(builder, objects); - Schema.addEnums(builder, enums); - Schema.addFileIdent(builder, fileIdent); - Schema.addFileExt(builder, fileExt); - Schema.addRootTable(builder, rootTable); - Schema.addServices(builder, services); - Schema.addAdvancedFeatures(builder, this.advancedFeatures); - Schema.addFbsFiles(builder, fbsFiles); - return Schema.endSchema(builder); - } -} diff --git a/tests/ts/reflection_generated.ts b/tests/ts/reflection_generated.ts deleted file mode 100644 index ec17d64b016c..000000000000 --- a/tests/ts/reflection_generated.ts +++ /dev/null @@ -1,2100 +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; -} - -static getFullyQualifiedName():string { - return 'reflection_EnumVal'; -} - -static startEnumVal(builder:flatbuffers.Builder) { - builder.startObject(5); -} - -static addName(builder:flatbuffers.Builder, nameOffset:flatbuffers.Offset) { - builder.addFieldOffset(0, nameOffset, 0); -} - -static addValue(builder:flatbuffers.Builder, value:bigint) { - builder.addFieldInt64(1, value, BigInt('0')); -} - -static addUnionType(builder:flatbuffers.Builder, unionTypeOffset:flatbuffers.Offset) { - builder.addFieldOffset(3, unionTypeOffset, 0); -} - -static addDocumentation(builder:flatbuffers.Builder, documentationOffset:flatbuffers.Offset) { - builder.addFieldOffset(4, documentationOffset, 0); -} - -static createDocumentationVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset { - builder.startVector(4, data.length, 4); - for (let i = data.length - 1; i >= 0; i--) { - builder.addOffset(data[i]!); - } - return builder.endVector(); -} - -static startDocumentationVector(builder:flatbuffers.Builder, numElems:number) { - builder.startVector(4, numElems, 4); -} - -static endEnumVal(builder:flatbuffers.Builder):flatbuffers.Offset { - const offset = builder.endObject(); - builder.requiredField(offset, 4) // name - return offset; -} - - -unpack(): EnumValT { - return new EnumValT( - this.name(), - this.value(), - (this.unionType() !== null ? this.unionType()!.unpack() : null), - this.bb!.createScalarList(this.documentation.bind(this), this.documentationLength()) - ); -} - - -unpackTo(_o: EnumValT): void { - _o.name = this.name(); - _o.value = this.value(); - _o.unionType = (this.unionType() !== null ? this.unionType()!.unpack() : null); - _o.documentation = this.bb!.createScalarList(this.documentation.bind(this), this.documentationLength()); -} -} - -export class EnumValT implements flatbuffers.IGeneratedObject { -constructor( - public name: string|Uint8Array|null = null, - public value: bigint = BigInt('0'), - public unionType: TypeT|null = null, - public documentation: (string)[] = [] -){} - - -pack(builder:flatbuffers.Builder): flatbuffers.Offset { - const name = (this.name !== null ? builder.createString(this.name!) : 0); - const unionType = (this.unionType !== null ? this.unionType!.pack(builder) : 0); - const documentation = EnumVal.createDocumentationVector(builder, builder.createObjectOffsetList(this.documentation)); - - EnumVal.startEnumVal(builder); - EnumVal.addName(builder, name); - EnumVal.addValue(builder, this.value); - EnumVal.addUnionType(builder, unionType); - EnumVal.addDocumentation(builder, documentation); - - return EnumVal.endEnumVal(builder); -} -} - -export class Enum 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 8a768f2e8345..000000000000 --- a/tests/ts/ts-flat-files/monster_test_generated.ts +++ /dev/null @@ -1,1830 +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'); -} - -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: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 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/tsconfig.json b/tests/ts/tsconfig.json index 27196b356194..bbf3c7d24175 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/class.js b/tests/ts/typescript/class.js deleted file mode 100644 index 9b0f2c00b6d1..000000000000 --- a/tests/ts/typescript/class.js +++ /dev/null @@ -1,6 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify -export var class_; -(function (class_) { - class_[class_["new_"] = 0] = "new_"; - class_[class_["instanceof_"] = 1] = "instanceof_"; -})(class_ || (class_ = {})); diff --git a/tests/ts/typescript/object.js b/tests/ts/typescript/object.js deleted file mode 100644 index 05ffb1a5692c..000000000000 --- a/tests/ts/typescript/object.js +++ /dev/null @@ -1,166 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify -import * as flatbuffers from 'flatbuffers'; -import { Abc } from '../foobar/abc.js'; -import { class_ as foobar_class_ } from '../foobar/class.js'; -import { Schema } from '../reflection/schema.js'; -import { class_ } from '../typescript/class.js'; -export class Object_ { - constructor() { - this.bb = null; - this.bb_pos = 0; - } - __init(i, bb) { - this.bb_pos = i; - this.bb = bb; - return this; - } - static getRootAsObject(bb, obj) { - return (obj || new Object_()).__init(bb.readInt32(bb.position()) + bb.position(), bb); - } - static getSizePrefixedRootAsObject(bb, obj) { - bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); - return (obj || new Object_()).__init(bb.readInt32(bb.position()) + bb.position(), bb); - } - return_() { - const offset = this.bb.__offset(this.bb_pos, 4); - return offset ? this.bb.readInt32(this.bb_pos + offset) : 0; - } - mutate_return(value) { - const offset = this.bb.__offset(this.bb_pos, 4); - if (offset === 0) { - return false; - } - this.bb.writeInt32(this.bb_pos + offset, value); - return true; - } - if_() { - const offset = this.bb.__offset(this.bb_pos, 6); - return offset ? this.bb.readInt32(this.bb_pos + offset) : 0; - } - mutate_if(value) { - const offset = this.bb.__offset(this.bb_pos, 6); - if (offset === 0) { - return false; - } - this.bb.writeInt32(this.bb_pos + offset, value); - return true; - } - switch_() { - const offset = this.bb.__offset(this.bb_pos, 8); - return offset ? this.bb.readInt32(this.bb_pos + offset) : 0; - } - mutate_switch(value) { - const offset = this.bb.__offset(this.bb_pos, 8); - if (offset === 0) { - return false; - } - this.bb.writeInt32(this.bb_pos + offset, value); - return true; - } - enum_() { - const offset = this.bb.__offset(this.bb_pos, 10); - return offset ? this.bb.readInt32(this.bb_pos + offset) : class_.new_; - } - mutate_enum(value) { - const offset = this.bb.__offset(this.bb_pos, 10); - if (offset === 0) { - return false; - } - this.bb.writeInt32(this.bb_pos + offset, value); - return true; - } - enum2() { - const offset = this.bb.__offset(this.bb_pos, 12); - return offset ? this.bb.readInt32(this.bb_pos + offset) : foobar_class_.arguments_; - } - mutate_enum2(value) { - const offset = this.bb.__offset(this.bb_pos, 12); - if (offset === 0) { - return false; - } - this.bb.writeInt32(this.bb_pos + offset, value); - return true; - } - enum3() { - const offset = this.bb.__offset(this.bb_pos, 14); - return offset ? this.bb.readInt32(this.bb_pos + offset) : Abc.a; - } - mutate_enum3(value) { - const offset = this.bb.__offset(this.bb_pos, 14); - if (offset === 0) { - return false; - } - this.bb.writeInt32(this.bb_pos + offset, value); - return true; - } - reflect(obj) { - const offset = this.bb.__offset(this.bb_pos, 16); - return offset ? (obj || new Schema()).__init(this.bb.__indirect(this.bb_pos + offset), this.bb) : null; - } - static getFullyQualifiedName() { - return 'typescript_Object'; - } - static startObject(builder) { - builder.startObject(7); - } - static addReturn(builder, return_) { - builder.addFieldInt32(0, return_, 0); - } - static addIf(builder, if_) { - builder.addFieldInt32(1, if_, 0); - } - static addSwitch(builder, switch_) { - builder.addFieldInt32(2, switch_, 0); - } - static addEnum(builder, enum_) { - builder.addFieldInt32(3, enum_, class_.new_); - } - static addEnum2(builder, enum2) { - builder.addFieldInt32(4, enum2, foobar_class_.arguments_); - } - static addEnum3(builder, enum3) { - builder.addFieldInt32(5, enum3, Abc.a); - } - static addReflect(builder, reflectOffset) { - builder.addFieldOffset(6, reflectOffset, 0); - } - static endObject(builder) { - const offset = builder.endObject(); - return offset; - } - unpack() { - return new Object_T(this.return_(), this.if_(), this.switch_(), this.enum_(), this.enum2(), this.enum3(), (this.reflect() !== null ? this.reflect().unpack() : null)); - } - unpackTo(_o) { - _o.return_ = this.return_(); - _o.if_ = this.if_(); - _o.switch_ = this.switch_(); - _o.enum_ = this.enum_(); - _o.enum2 = this.enum2(); - _o.enum3 = this.enum3(); - _o.reflect = (this.reflect() !== null ? this.reflect().unpack() : null); - } -} -export class Object_T { - constructor(return_ = 0, if_ = 0, switch_ = 0, enum_ = class_.new_, enum2 = foobar_class_.arguments_, enum3 = Abc.a, reflect = null) { - this.return_ = return_; - this.if_ = if_; - this.switch_ = switch_; - this.enum_ = enum_; - this.enum2 = enum2; - this.enum3 = enum3; - this.reflect = reflect; - } - pack(builder) { - const reflect = (this.reflect !== null ? this.reflect.pack(builder) : 0); - Object_.startObject(builder); - Object_.addReturn(builder, this.return_); - Object_.addIf(builder, this.if_); - Object_.addSwitch(builder, this.switch_); - Object_.addEnum(builder, this.enum_); - Object_.addEnum2(builder, this.enum2); - Object_.addEnum3(builder, this.enum3); - Object_.addReflect(builder, reflect); - return Object_.endObject(builder); - } -} diff --git a/tests/ts/typescript_include/foobar.ts b/tests/ts/typescript_include/foobar.ts new file mode 100644 index 000000000000..6c7949e81652 --- /dev/null +++ b/tests/ts/typescript_include/foobar.ts @@ -0,0 +1,4 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +export { Abc } from './foobar/abc.js'; +export { class_ } from './foobar/class.js'; diff --git a/tests/ts/foobar/abc.ts b/tests/ts/typescript_include/foobar/abc.ts similarity index 100% rename from tests/ts/foobar/abc.ts rename to tests/ts/typescript_include/foobar/abc.ts diff --git a/tests/ts/foobar/class.ts b/tests/ts/typescript_include/foobar/class.ts similarity index 100% rename from tests/ts/foobar/class.ts rename to tests/ts/typescript_include/foobar/class.ts diff --git a/tests/ts/typescript_include_generated.js b/tests/ts/typescript_include_generated.js deleted file mode 100644 index e0e1df1bea24..000000000000 --- a/tests/ts/typescript_include_generated.js +++ /dev/null @@ -1,5 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify -export var class_; -(function (class_) { - class_[class_["arguments_"] = 0] = "arguments_"; -})(class_ || (class_ = {})); diff --git a/tests/ts/typescript_keywords/foobar.ts b/tests/ts/typescript_keywords/foobar.ts new file mode 100644 index 000000000000..6c7949e81652 --- /dev/null +++ b/tests/ts/typescript_keywords/foobar.ts @@ -0,0 +1,4 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +export { Abc } from './foobar/abc.js'; +export { class_ } from './foobar/class.js'; diff --git a/tests/ts/typescript_transitive_include_generated.ts b/tests/ts/typescript_keywords/foobar/abc.ts similarity index 98% rename from tests/ts/typescript_transitive_include_generated.ts rename to tests/ts/typescript_keywords/foobar/abc.ts index 6bb160148269..ef8842b22b53 100644 --- a/tests/ts/typescript_transitive_include_generated.ts +++ b/tests/ts/typescript_keywords/foobar/abc.ts @@ -1,7 +1,5 @@ // automatically generated by the FlatBuffers compiler, do not modify - export enum Abc { a = 0 } - diff --git a/tests/ts/typescript_include_generated.ts b/tests/ts/typescript_keywords/foobar/class.ts similarity index 98% rename from tests/ts/typescript_include_generated.ts rename to tests/ts/typescript_keywords/foobar/class.ts index d419431cfdff..d26fb2879435 100644 --- a/tests/ts/typescript_include_generated.ts +++ b/tests/ts/typescript_keywords/foobar/class.ts @@ -1,7 +1,5 @@ // automatically generated by the FlatBuffers compiler, do not modify - export enum class_ { arguments_ = 0 } - diff --git a/tests/ts/typescript_keywords/reflection.ts b/tests/ts/typescript_keywords/reflection.ts new file mode 100644 index 000000000000..8440332d1610 --- /dev/null +++ b/tests/ts/typescript_keywords/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/typescript_keywords/reflection/advanced-features.ts b/tests/ts/typescript_keywords/reflection/advanced-features.ts new file mode 100644 index 000000000000..dd3b865063b4 --- /dev/null +++ b/tests/ts/typescript_keywords/reflection/advanced-features.ts @@ -0,0 +1,11 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +/** + * New schema language features that are not supported by old code generators. + */ +export enum AdvancedFeatures { + AdvancedArrayFeatures = '1', + AdvancedUnionFeatures = '2', + OptionalScalars = '4', + DefaultVectorsAndStrings = '8' +} diff --git a/tests/ts/typescript_keywords/reflection/base-type.ts b/tests/ts/typescript_keywords/reflection/base-type.ts new file mode 100644 index 000000000000..7ee98ed998de --- /dev/null +++ b/tests/ts/typescript_keywords/reflection/base-type.ts @@ -0,0 +1,23 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +export enum BaseType { + None = 0, + UType = 1, + Bool = 2, + Byte = 3, + UByte = 4, + Short = 5, + UShort = 6, + Int = 7, + UInt = 8, + Long = 9, + ULong = 10, + Float = 11, + Double = 12, + String = 13, + Vector = 14, + Obj = 15, + Union = 16, + Array = 17, + MaxBaseType = 18 +} diff --git a/tests/ts/typescript_keywords/reflection/enum-val.ts b/tests/ts/typescript_keywords/reflection/enum-val.ts new file mode 100644 index 000000000000..2364dab2fa84 --- /dev/null +++ b/tests/ts/typescript_keywords/reflection/enum-val.ts @@ -0,0 +1,149 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +import * as flatbuffers from 'flatbuffers'; + +import { Type, TypeT } from '../reflection/type.js'; + + +export class EnumVal 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; +} + +static getFullyQualifiedName():string { + return 'reflection_EnumVal'; +} + +static startEnumVal(builder:flatbuffers.Builder) { + builder.startObject(5); +} + +static addName(builder:flatbuffers.Builder, nameOffset:flatbuffers.Offset) { + builder.addFieldOffset(0, nameOffset, 0); +} + +static addValue(builder:flatbuffers.Builder, value:bigint) { + builder.addFieldInt64(1, value, BigInt('0')); +} + +static addUnionType(builder:flatbuffers.Builder, unionTypeOffset:flatbuffers.Offset) { + builder.addFieldOffset(3, unionTypeOffset, 0); +} + +static addDocumentation(builder:flatbuffers.Builder, documentationOffset:flatbuffers.Offset) { + builder.addFieldOffset(4, documentationOffset, 0); +} + +static createDocumentationVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addOffset(data[i]!); + } + return builder.endVector(); +} + +static startDocumentationVector(builder:flatbuffers.Builder, numElems:number) { + builder.startVector(4, numElems, 4); +} + +static endEnumVal(builder:flatbuffers.Builder):flatbuffers.Offset { + const offset = builder.endObject(); + builder.requiredField(offset, 4) // name + return offset; +} + + +unpack(): EnumValT { + return new EnumValT( + this.name(), + this.value(), + (this.unionType() !== null ? this.unionType()!.unpack() : null), + this.bb!.createScalarList(this.documentation.bind(this), this.documentationLength()) + ); +} + + +unpackTo(_o: EnumValT): void { + _o.name = this.name(); + _o.value = this.value(); + _o.unionType = (this.unionType() !== null ? this.unionType()!.unpack() : null); + _o.documentation = this.bb!.createScalarList(this.documentation.bind(this), this.documentationLength()); +} +} + +export class EnumValT implements flatbuffers.IGeneratedObject { +constructor( + public name: string|Uint8Array|null = null, + public value: bigint = BigInt('0'), + public unionType: TypeT|null = null, + public documentation: (string)[] = [] +){} + + +pack(builder:flatbuffers.Builder): flatbuffers.Offset { + const name = (this.name !== null ? builder.createString(this.name!) : 0); + const unionType = (this.unionType !== null ? this.unionType!.pack(builder) : 0); + const documentation = EnumVal.createDocumentationVector(builder, builder.createObjectOffsetList(this.documentation)); + + EnumVal.startEnumVal(builder); + EnumVal.addName(builder, name); + EnumVal.addValue(builder, this.value); + EnumVal.addUnionType(builder, unionType); + EnumVal.addDocumentation(builder, documentation); + + return EnumVal.endEnumVal(builder); +} +} diff --git a/tests/ts/typescript_keywords/reflection/enum.ts b/tests/ts/typescript_keywords/reflection/enum.ts new file mode 100644 index 000000000000..34d137757ee6 --- /dev/null +++ b/tests/ts/typescript_keywords/reflection/enum.ts @@ -0,0 +1,234 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +import * as flatbuffers from 'flatbuffers'; + +import { EnumVal, EnumValT } from '../reflection/enum-val.js'; +import { KeyValue, KeyValueT } from '../reflection/key-value.js'; +import { Type, TypeT } from '../reflection/type.js'; + + +export class Enum 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); +} +} diff --git a/tests/ts/typescript_keywords/reflection/field.ts b/tests/ts/typescript_keywords/reflection/field.ts new file mode 100644 index 000000000000..9734fbab5ec6 --- /dev/null +++ b/tests/ts/typescript_keywords/reflection/field.ts @@ -0,0 +1,377 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +import * as flatbuffers from 'flatbuffers'; + +import { KeyValue, KeyValueT } from '../reflection/key-value.js'; +import { Type, TypeT } from '../reflection/type.js'; + + +export class Field 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); +} +} diff --git a/tests/ts/typescript_keywords/reflection/key-value.ts b/tests/ts/typescript_keywords/reflection/key-value.ts new file mode 100644 index 000000000000..93262f42f6bb --- /dev/null +++ b/tests/ts/typescript_keywords/reflection/key-value.ts @@ -0,0 +1,98 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +import * as flatbuffers from 'flatbuffers'; + + + +export class KeyValue 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 + ); +} +} diff --git a/tests/ts/typescript_keywords/reflection/object.ts b/tests/ts/typescript_keywords/reflection/object.ts new file mode 100644 index 000000000000..fbe700615806 --- /dev/null +++ b/tests/ts/typescript_keywords/reflection/object.ts @@ -0,0 +1,277 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +import * as flatbuffers from 'flatbuffers'; + +import { Field, FieldT } from '../reflection/field.js'; +import { KeyValue, KeyValueT } from '../reflection/key-value.js'; + + +export class Object_ 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 + ); +} +} diff --git a/tests/ts/typescript_keywords/reflection/rpccall.ts b/tests/ts/typescript_keywords/reflection/rpccall.ts new file mode 100644 index 000000000000..320de51695cb --- /dev/null +++ b/tests/ts/typescript_keywords/reflection/rpccall.ts @@ -0,0 +1,173 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +import * as flatbuffers from 'flatbuffers'; + +import { KeyValue, KeyValueT } from '../reflection/key-value.js'; +import { Object_, Object_T } from '../reflection/object.js'; + + +export class RPCCall 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); +} +} diff --git a/tests/ts/typescript_keywords/reflection/schema-file.ts b/tests/ts/typescript_keywords/reflection/schema-file.ts new file mode 100644 index 000000000000..eda23dede0af --- /dev/null +++ b/tests/ts/typescript_keywords/reflection/schema-file.ts @@ -0,0 +1,126 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +import * as flatbuffers from 'flatbuffers'; + + + +/** + * File specific information. + * Symbols declared within a file may be recovered by iterating over all + * symbols and examining the `declaration_file` field. + */ +export class SchemaFile 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 + ); +} +} diff --git a/tests/ts/typescript_keywords/reflection/schema.ts b/tests/ts/typescript_keywords/reflection/schema.ts new file mode 100644 index 000000000000..d3f1286ec572 --- /dev/null +++ b/tests/ts/typescript_keywords/reflection/schema.ts @@ -0,0 +1,264 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +import * as flatbuffers from 'flatbuffers'; + +import { Enum, EnumT } from '../reflection/enum.js'; +import { Object_, Object_T } from '../reflection/object.js'; +import { SchemaFile, SchemaFileT } from '../reflection/schema-file.js'; +import { Service, ServiceT } from '../reflection/service.js'; + + +export class Schema 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); +} + +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; +} + + +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/typescript_keywords/reflection/service.ts b/tests/ts/typescript_keywords/reflection/service.ts new file mode 100644 index 000000000000..c0ad8adbe641 --- /dev/null +++ b/tests/ts/typescript_keywords/reflection/service.ts @@ -0,0 +1,201 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +import * as flatbuffers from 'flatbuffers'; + +import { KeyValue, KeyValueT } from '../reflection/key-value.js'; +import { RPCCall, RPCCallT } from '../reflection/rpccall.js'; + + +export class Service 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 + ); +} +} diff --git a/tests/ts/typescript_keywords/reflection/type.ts b/tests/ts/typescript_keywords/reflection/type.ts new file mode 100644 index 000000000000..37316959d5c8 --- /dev/null +++ b/tests/ts/typescript_keywords/reflection/type.ts @@ -0,0 +1,219 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +import * as flatbuffers from 'flatbuffers'; + +import { BaseType } from '../reflection/base-type.js'; + + +export class Type 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 + ); +} +} diff --git a/tests/ts/typescript_keywords/typescript.ts b/tests/ts/typescript_keywords/typescript.ts new file mode 100644 index 000000000000..216026ef09c4 --- /dev/null +++ b/tests/ts/typescript_keywords/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.ts b/tests/ts/typescript_keywords/typescript/class.ts similarity index 100% rename from tests/ts/typescript/class.ts rename to tests/ts/typescript_keywords/typescript/class.ts diff --git a/tests/ts/typescript/object.ts b/tests/ts/typescript_keywords/typescript/object.ts similarity index 100% rename from tests/ts/typescript/object.ts rename to tests/ts/typescript_keywords/typescript/object.ts diff --git a/tests/ts/typescript_keywords_generated.js b/tests/ts/typescript_keywords_generated.js deleted file mode 100644 index 4525da7de4a6..000000000000 --- a/tests/ts/typescript_keywords_generated.js +++ /dev/null @@ -1,170 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify -import * as flatbuffers from 'flatbuffers'; -import { Schema as Schema } from './reflection_generated.js'; -import { class_ as foobar_class_ } from './typescript_include_generated.js'; -import { Abc as Abc } from './typescript_transitive_include_generated.js'; -export var class_; -(function (class_) { - class_[class_["new_"] = 0] = "new_"; - class_[class_["instanceof_"] = 1] = "instanceof_"; -})(class_ || (class_ = {})); -export class Object_ { - constructor() { - this.bb = null; - this.bb_pos = 0; - } - __init(i, bb) { - this.bb_pos = i; - this.bb = bb; - return this; - } - static getRootAsObject(bb, obj) { - return (obj || new Object_()).__init(bb.readInt32(bb.position()) + bb.position(), bb); - } - static getSizePrefixedRootAsObject(bb, obj) { - bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); - return (obj || new Object_()).__init(bb.readInt32(bb.position()) + bb.position(), bb); - } - return_() { - const offset = this.bb.__offset(this.bb_pos, 4); - return offset ? this.bb.readInt32(this.bb_pos + offset) : 0; - } - mutate_return(value) { - const offset = this.bb.__offset(this.bb_pos, 4); - if (offset === 0) { - return false; - } - this.bb.writeInt32(this.bb_pos + offset, value); - return true; - } - if_() { - const offset = this.bb.__offset(this.bb_pos, 6); - return offset ? this.bb.readInt32(this.bb_pos + offset) : 0; - } - mutate_if(value) { - const offset = this.bb.__offset(this.bb_pos, 6); - if (offset === 0) { - return false; - } - this.bb.writeInt32(this.bb_pos + offset, value); - return true; - } - switch_() { - const offset = this.bb.__offset(this.bb_pos, 8); - return offset ? this.bb.readInt32(this.bb_pos + offset) : 0; - } - mutate_switch(value) { - const offset = this.bb.__offset(this.bb_pos, 8); - if (offset === 0) { - return false; - } - this.bb.writeInt32(this.bb_pos + offset, value); - return true; - } - enum_() { - const offset = this.bb.__offset(this.bb_pos, 10); - return offset ? this.bb.readInt32(this.bb_pos + offset) : class_.new_; - } - mutate_enum(value) { - const offset = this.bb.__offset(this.bb_pos, 10); - if (offset === 0) { - return false; - } - this.bb.writeInt32(this.bb_pos + offset, value); - return true; - } - enum2() { - const offset = this.bb.__offset(this.bb_pos, 12); - return offset ? this.bb.readInt32(this.bb_pos + offset) : foobar_class_.arguments_; - } - mutate_enum2(value) { - const offset = this.bb.__offset(this.bb_pos, 12); - if (offset === 0) { - return false; - } - this.bb.writeInt32(this.bb_pos + offset, value); - return true; - } - enum3() { - const offset = this.bb.__offset(this.bb_pos, 14); - return offset ? this.bb.readInt32(this.bb_pos + offset) : Abc.a; - } - mutate_enum3(value) { - const offset = this.bb.__offset(this.bb_pos, 14); - if (offset === 0) { - return false; - } - this.bb.writeInt32(this.bb_pos + offset, value); - return true; - } - reflect(obj) { - const offset = this.bb.__offset(this.bb_pos, 16); - return offset ? (obj || new Schema()).__init(this.bb.__indirect(this.bb_pos + offset), this.bb) : null; - } - static getFullyQualifiedName() { - return 'typescript_Object'; - } - static startObject(builder) { - builder.startObject(7); - } - static addReturn(builder, return_) { - builder.addFieldInt32(0, return_, 0); - } - static addIf(builder, if_) { - builder.addFieldInt32(1, if_, 0); - } - static addSwitch(builder, switch_) { - builder.addFieldInt32(2, switch_, 0); - } - static addEnum(builder, enum_) { - builder.addFieldInt32(3, enum_, class_.new_); - } - static addEnum2(builder, enum2) { - builder.addFieldInt32(4, enum2, foobar_class_.arguments_); - } - static addEnum3(builder, enum3) { - builder.addFieldInt32(5, enum3, Abc.a); - } - static addReflect(builder, reflectOffset) { - builder.addFieldOffset(6, reflectOffset, 0); - } - static endObject(builder) { - const offset = builder.endObject(); - return offset; - } - unpack() { - return new Object_T(this.return_(), this.if_(), this.switch_(), this.enum_(), this.enum2(), this.enum3(), (this.reflect() !== null ? this.reflect().unpack() : null)); - } - unpackTo(_o) { - _o.return_ = this.return_(); - _o.if_ = this.if_(); - _o.switch_ = this.switch_(); - _o.enum_ = this.enum_(); - _o.enum2 = this.enum2(); - _o.enum3 = this.enum3(); - _o.reflect = (this.reflect() !== null ? this.reflect().unpack() : null); - } -} -export class Object_T { - constructor(return_ = 0, if_ = 0, switch_ = 0, enum_ = class_.new_, enum2 = foobar_class_.arguments_, enum3 = Abc.a, reflect = null) { - this.return_ = return_; - this.if_ = if_; - this.switch_ = switch_; - this.enum_ = enum_; - this.enum2 = enum2; - this.enum3 = enum3; - this.reflect = reflect; - } - pack(builder) { - const reflect = (this.reflect !== null ? this.reflect.pack(builder) : 0); - Object_.startObject(builder); - Object_.addReturn(builder, this.return_); - Object_.addIf(builder, this.if_); - Object_.addSwitch(builder, this.switch_); - Object_.addEnum(builder, this.enum_); - Object_.addEnum2(builder, this.enum2); - Object_.addEnum3(builder, this.enum3); - Object_.addReflect(builder, reflect); - return Object_.endObject(builder); - } -} diff --git a/tests/ts/typescript_keywords_generated.ts b/tests/ts/typescript_keywords_generated.ts deleted file mode 100644 index bcc61102dd5e..000000000000 --- 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/foobar.ts b/tests/ts/typescript_transitive_include/foobar.ts new file mode 100644 index 000000000000..067b4860ee50 --- /dev/null +++ b/tests/ts/typescript_transitive_include/foobar.ts @@ -0,0 +1,3 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +export { Abc } from './foobar/abc.js'; diff --git a/tests/ts/optional-scalars/optional-byte.ts b/tests/ts/typescript_transitive_include/foobar/abc.ts similarity index 54% rename from tests/ts/optional-scalars/optional-byte.ts rename to tests/ts/typescript_transitive_include/foobar/abc.ts index f4db265e2ba7..ef8842b22b53 100644 --- a/tests/ts/optional-scalars/optional-byte.ts +++ b/tests/ts/typescript_transitive_include/foobar/abc.ts @@ -1,7 +1,5 @@ // automatically generated by the FlatBuffers compiler, do not modify -export enum OptionalByte { - None = 0, - One = 1, - Two = 2 +export enum Abc { + a = 0 } diff --git a/tests/ts/typescript_transitive_include_generated.js b/tests/ts/typescript_transitive_include_generated.js deleted file mode 100644 index cdef988d9415..000000000000 --- a/tests/ts/typescript_transitive_include_generated.js +++ /dev/null @@ -1,5 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify -export var Abc; -(function (Abc) { - Abc[Abc["a"] = 0] = "a"; -})(Abc || (Abc = {})); diff --git a/tests/ts/union_vector.ts b/tests/ts/union_vector.ts new file mode 100644 index 000000000000..70f15f6109c6 --- /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/union_vector/attacker.js'; +export { BookReader } from './union_vector/union_vector/book-reader.js'; +export { Character } from './union_vector/union_vector/character.js'; +export { FallingTub } from './union_vector/union_vector/falling-tub.js'; +export { Gadget } from './union_vector/union_vector/gadget.js'; +export { HandFan } from './union_vector/union_vector/hand-fan.js'; +export { Movie } from './union_vector/union_vector/movie.js'; +export { Rapunzel } from './union_vector/union_vector/rapunzel.js'; diff --git a/tests/ts/union_vector/attacker.js b/tests/ts/union_vector/union_vector/attacker.js similarity index 100% rename from tests/ts/union_vector/attacker.js rename to tests/ts/union_vector/union_vector/attacker.js diff --git a/tests/ts/union_vector/attacker.ts b/tests/ts/union_vector/union_vector/attacker.ts similarity index 100% rename from tests/ts/union_vector/attacker.ts rename to tests/ts/union_vector/union_vector/attacker.ts diff --git a/tests/ts/union_vector/book-reader.js b/tests/ts/union_vector/union_vector/book-reader.js similarity index 100% rename from tests/ts/union_vector/book-reader.js rename to tests/ts/union_vector/union_vector/book-reader.js diff --git a/tests/ts/union_vector/book-reader.ts b/tests/ts/union_vector/union_vector/book-reader.ts similarity index 100% rename from tests/ts/union_vector/book-reader.ts rename to tests/ts/union_vector/union_vector/book-reader.ts diff --git a/tests/ts/union_vector/character.js b/tests/ts/union_vector/union_vector/character.js similarity index 97% rename from tests/ts/union_vector/character.js rename to tests/ts/union_vector/union_vector/character.js index 04e3294ccd9e..0ef2ed16d829 100644 --- a/tests/ts/union_vector/character.js +++ b/tests/ts/union_vector/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/character.ts b/tests/ts/union_vector/union_vector/character.ts similarity index 100% rename from tests/ts/union_vector/character.ts rename to tests/ts/union_vector/union_vector/character.ts diff --git a/tests/ts/union_vector/falling-tub.js b/tests/ts/union_vector/union_vector/falling-tub.js similarity index 100% rename from tests/ts/union_vector/falling-tub.js rename to tests/ts/union_vector/union_vector/falling-tub.js diff --git a/tests/ts/union_vector/falling-tub.ts b/tests/ts/union_vector/union_vector/falling-tub.ts similarity index 100% rename from tests/ts/union_vector/falling-tub.ts rename to tests/ts/union_vector/union_vector/falling-tub.ts diff --git a/tests/ts/union_vector/gadget.js b/tests/ts/union_vector/union_vector/gadget.js similarity index 95% rename from tests/ts/union_vector/gadget.js rename to tests/ts/union_vector/union_vector/gadget.js index 202a214b5d1e..5eb339b948b7 100644 --- a/tests/ts/union_vector/gadget.js +++ b/tests/ts/union_vector/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/gadget.ts b/tests/ts/union_vector/union_vector/gadget.ts similarity index 100% rename from tests/ts/union_vector/gadget.ts rename to tests/ts/union_vector/union_vector/gadget.ts diff --git a/tests/ts/union_vector/hand-fan.js b/tests/ts/union_vector/union_vector/hand-fan.js similarity index 100% rename from tests/ts/union_vector/hand-fan.js rename to tests/ts/union_vector/union_vector/hand-fan.js diff --git a/tests/ts/union_vector/hand-fan.ts b/tests/ts/union_vector/union_vector/hand-fan.ts similarity index 100% rename from tests/ts/union_vector/hand-fan.ts rename to tests/ts/union_vector/union_vector/hand-fan.ts diff --git a/tests/ts/union_vector/movie.js b/tests/ts/union_vector/union_vector/movie.js similarity index 100% rename from tests/ts/union_vector/movie.js rename to tests/ts/union_vector/union_vector/movie.js diff --git a/tests/ts/union_vector/movie.ts b/tests/ts/union_vector/union_vector/movie.ts similarity index 100% rename from tests/ts/union_vector/movie.ts rename to tests/ts/union_vector/union_vector/movie.ts diff --git a/tests/ts/union_vector/rapunzel.js b/tests/ts/union_vector/union_vector/rapunzel.js similarity index 100% rename from tests/ts/union_vector/rapunzel.js rename to tests/ts/union_vector/union_vector/rapunzel.js diff --git a/tests/ts/union_vector/rapunzel.ts b/tests/ts/union_vector/union_vector/rapunzel.ts similarity index 100% rename from tests/ts/union_vector/rapunzel.ts rename to tests/ts/union_vector/union_vector/rapunzel.ts diff --git a/tests/ts/union_vector/union_vector_generated.js b/tests/ts/union_vector/union_vector_generated.js deleted file mode 100644 index 69ea199096e8..000000000000 --- a/tests/ts/union_vector/union_vector_generated.js +++ /dev/null @@ -1,9 +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/ts/union_vector/union_vector_generated.ts b/tests/ts/union_vector/union_vector_generated.ts deleted file mode 100644 index 5527abe17d8f..000000000000 --- 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 32be94e2cbd4..000000000000 --- 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 6b3fc0fc1408..000000000000 --- 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 0d9e1a57cd44..000000000000 --- 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 7a31278125a9..000000000000 --- 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 c06029817150..000000000000 --- 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 d8ffbc2a1ebc..000000000000 --- 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 b32f99d0ff41..000000000000 --- 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 328071ebbcca..000000000000 --- 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 f90b4dd31953..000000000000 --- 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 b4d8099441f4..000000000000 --- 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 fceadaa2977a..000000000000 --- 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 f3a118b7de09..000000000000 --- 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 f3a118b7de09..000000000000 --- 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 d3b41c495457..000000000000 --- 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 605329ed3ec5..cb3cb0f2607f 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 7c0010bf063b..a60851245133 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 a60851245133..000000000000 --- 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 9af4075eff11..1636255e792a 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 5af9460d7eec..4c58d8492527 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 f112f34f958e..4e2115cbfdbe 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 8636de9b9863..13c6665a949e 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"