summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjörn Harrtell <bjornharrtell@users.noreply.github.com>2021-01-19 21:51:13 +0100
committerGitHub <noreply@github.com>2021-01-19 12:51:13 -0800
commit760c657551230c0c29d4c9a43fbf62602fe4b5a8 (patch)
treef66f6ef768184610373a45e6ef436642413ed57b
parent75c859e98f360b07fa7168afcf1b3902c6a19540 (diff)
downloadflatbuffers-760c657551230c0c29d4c9a43fbf62602fe4b5a8.tar.gz
flatbuffers-760c657551230c0c29d4c9a43fbf62602fe4b5a8.tar.bz2
flatbuffers-760c657551230c0c29d4c9a43fbf62602fe4b5a8.zip
[TS/JS] New gen TS code gen (#6302)
* TS/ES6 modules spike iteration 1 * Initial modularized dasherized output * Remove obsoleted parts and namespace wrapping * Use _flatbuffers_ prefix * First part of imports logic * Second part of imports logic * Fix TS/JS code removal mixup * Alias imported symbols if same name from different namespaces and some fixes * Use star import for bare imports * Fix messed up string concat * var to const and remove not needed semi * Remove some cases of ns prefixing * Add missing space * Cleanups * Completed initial import tracking logic * Compilable output * Adjust TypeScriptTest and dependents to work * Use local flatbuffers package for tests * Refactor away use of any * Remove obsolete imported_fileset and reexport_map * Still need any and fix JavaScriptTest.sh * Fix test runs out of the box * Temp add generated files * TypeScriptTest replaces JavaScriptTest and cleanups * Also remove reference to JavaScriptTest in TestAll.sh * Remove old generated ts/js files * Remove use of --js in generate_code scripts * idl_gen_js_ts to idl_gen_ts and removal of js gen * Remove obsoleted options * Fix obsolete ts test detection * Tweak ts compilation be as strict as possible * Remove jsdoc type annotation generation * Generated test ts files * Fix search and replace messup * Regenerated ts test output * Use CharToLower * Use normal for loop * Rework namespacedir * Revert "Rework namespacedir" This reverts commit 6f4eb0104ceeb86011bb076ebca901138c48e068. * Revert "Use normal for loop" This reverts commit 676b2135bfaa1853dfbb06c92b5c16a0d81bb13a. * Revert "Use CharToLower" This reverts commit 2d08648d0d72d0af201fad80d54cdc76412b35e9. * Again do rework but correct * Avoid runtime cast * Fix test runs * Also add npm install to get tsc * Bump node test versions * for range to std for loop * Clang format * Missed one clang format * Move accessor to later * Attempt to make windows version of TypeScriptTest * Want to see the output * Try to get newer node at appveyor * Style changes
-rw-r--r--appveyor.yml9
-rw-r--r--docs/source/Compiler.md16
-rw-r--r--docs/source/TypeScriptUsage.md2
-rw-r--r--include/flatbuffers/code_generators.h8
-rw-r--r--include/flatbuffers/idl.h27
-rw-r--r--include/flatbuffers/util.h3
-rw-r--r--package.json16
-rw-r--r--src/code_generators.cpp27
-rw-r--r--src/flatc.cpp21
-rw-r--r--src/flatc_main.cpp9
-rw-r--r--src/idl_gen_ts.cpp1500
-rw-r--r--src/idl_parser.cpp10
-rw-r--r--tests/JavaScriptFlexBuffersTest.js12
-rw-r--r--tests/JavaScriptTest.js161
-rwxr-xr-xtests/JavaScriptTest.sh24
-rw-r--r--tests/JavaScriptUnionVectorTest.js120
-rwxr-xr-xtests/TestAll.sh6
-rwxr-xr-xtests/TypeScriptTest.bat8
-rwxr-xr-xtests/TypeScriptTest.sh24
-rw-r--r--tests/docker/languages/Dockerfile.testing.node.10_13_010
-rw-r--r--tests/docker/languages/Dockerfile.testing.node.11_2_010
-rw-r--r--tests/docker/languages/Dockerfile.testing.node.12_20_16
-rw-r--r--tests/docker/languages/Dockerfile.testing.node.14_15_46
-rw-r--r--tests/generate_code.bat12
-rwxr-xr-xtests/generate_code.sh10
-rw-r--r--tests/monster_test_grpc.d.ts92
-rw-r--r--tests/monster_test_grpc.js79
-rw-r--r--tests/optional_scalars_generated.js782
-rw-r--r--tests/optional_scalars_generated.ts722
-rw-r--r--tests/package.json6
-rw-r--r--tests/ts/attacker.ts76
-rw-r--r--tests/ts/book-reader.ts58
-rw-r--r--tests/ts/character.ts50
-rw-r--r--tests/ts/movie.ts211
-rw-r--r--tests/ts/my-game/example/ability.ts77
-rw-r--r--tests/ts/my-game/example/any-ambiguous-aliases.ts39
-rw-r--r--tests/ts/my-game/example/any-unique-aliases.ts41
-rw-r--r--tests/ts/my-game/example/any.ts41
-rw-r--r--tests/ts/my-game/example/color.ts20
-rw-r--r--tests/ts/my-game/example/monster.ts1370
-rw-r--r--tests/ts/my-game/example/race.ts9
-rw-r--r--tests/ts/my-game/example/referrable.ts95
-rw-r--r--tests/ts/my-game/example/stat.ts138
-rw-r--r--tests/ts/my-game/example/test-simple-table-with-enum.ts96
-rw-r--r--tests/ts/my-game/example/test.ts78
-rw-r--r--tests/ts/my-game/example/type-aliases.ts405
-rw-r--r--tests/ts/my-game/example/vec3.ts137
-rw-r--r--tests/ts/my-game/example2/monster.ts66
-rw-r--r--tests/ts/my-game/in-parent-namespace.ts66
-rw-r--r--tests/ts/rapunzel.ts58
-rw-r--r--tests/tsconfig.json18
-rw-r--r--ts/builder.ts6
-rw-r--r--ts/byte-buffer.ts17
-rw-r--r--ts/flatbuffers.ts41
-rw-r--r--ts/flexbuffers.ts18
-rw-r--r--yarn.lock956
56 files changed, 3880 insertions, 4045 deletions
diff --git a/appveyor.yml b/appveyor.yml
index 8ae3800b..b6e641a2 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -3,6 +3,7 @@ branches:
- master
environment:
+ nodejs_version: "14"
global:
# Workaround for https://github.com/conda/conda-build/issues/636
@@ -50,6 +51,7 @@ after_build:
install:
- set PATH=%CONDA_INSTALL_LOCN%;%CONDA_INSTALL_LOCN%\scripts;%PATH%;
+ - ps: Install-Product node $env:nodejs_version
test_script:
- call .appveyor\check-generate-code.bat -b %CONFIGURATION%
@@ -60,13 +62,12 @@ test_script:
- rem "---------------- C++ -----------------"
- "cd .."
- "%CONFIGURATION%\\flattests.exe"
- - "cd tests"
- rem "---------------- JS -----------------"
- "node --version"
- - "..\\%CONFIGURATION%\\flatc -b -I include_test monster_test.fbs unicode_test.json"
- "npm install"
- - "npm run pretest"
- - "node JavaScriptTest ./monster_test_generated"
+ - "npm run compile"
+ - "cd tests"
+ - "TypeScriptTest.bat"
- rem "---------------- C# -----------------"
# Have to compile this here rather than in "build" above because AppVeyor only
# supports building one project??
diff --git a/docs/source/Compiler.md b/docs/source/Compiler.md
index 296e998e..0d2d51ff 100644
--- a/docs/source/Compiler.md
+++ b/docs/source/Compiler.md
@@ -150,16 +150,6 @@ Additional options:
- `--object-suffix` : Customise class suffix for C++ object-based API.
-- `--no-js-exports` : Removes Node.js style export lines (useful for JS)
-
-- `--goog-js-export` : Uses goog.exportsSymbol and goog.exportsProperty
- instead of Node.js style exporting. Needed for compatibility with the
- Google closure compiler (useful for JS).
-
-- `--es6-js-export` : Generates ECMAScript v6 style export definitions
- instead of Node.js style exporting. Useful when integrating flatbuffers
- with modern Javascript projects.
-
- `--go-namespace` : Generate the overrided namespace in Golang.
- `--go-import` : Generate the overrided import for flatbuffers in Golang.
@@ -207,12 +197,6 @@ Additional options:
- `--keep-prefix` : Keep original prefix of schema include statement.
-- `--no-fb-import` : Don't include flatbuffers import statement for TypeScript.
-
-- `--no-ts-reexport` : Don't re-export imported dependencies for TypeScript.
-
-- `--short-names` : Use short function names for JS and TypeScript.
-
- `--reflect-types` : Add minimal type reflection to code generation.
- `--reflect-names` : Add minimal type/name reflection.
diff --git a/docs/source/TypeScriptUsage.md b/docs/source/TypeScriptUsage.md
index 0b9739ee..59fbbf66 100644
--- a/docs/source/TypeScriptUsage.md
+++ b/docs/source/TypeScriptUsage.md
@@ -70,8 +70,6 @@ For times when efficiency is less important a more convenient object based API
can be used (through `--gen-object-api`) that is able to unpack & pack a
FlatBuffer into objects and standard TS types.
-**When using the obj based API, the flatbuffers import need to be in the global namespace if you don't have `--no-fb-import` enabled** since creating default values require accessing the `flatbuffers.js` file.
-
To use:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.ts}
diff --git a/include/flatbuffers/code_generators.h b/include/flatbuffers/code_generators.h
index d64ab03c..d1f7b5a4 100644
--- a/include/flatbuffers/code_generators.h
+++ b/include/flatbuffers/code_generators.h
@@ -94,7 +94,10 @@ class BaseGenerator {
virtual bool generate() = 0;
static std::string NamespaceDir(const Parser &parser, const std::string &path,
- const Namespace &ns);
+ const Namespace &ns,
+ const bool dasherize = false);
+
+ static std::string ToDasherizedCase(const std::string pascal_case);
std::string GeneratedFileName(const std::string &path,
const std::string &file_name,
@@ -116,7 +119,8 @@ class BaseGenerator {
BaseGenerator &operator=(const BaseGenerator &);
BaseGenerator(const BaseGenerator &);
- std::string NamespaceDir(const Namespace &ns) const;
+ std::string NamespaceDir(const Namespace &ns,
+ const bool dasherize = false) const;
static const char *FlatBuffersGeneratedWarning();
diff --git a/include/flatbuffers/idl.h b/include/flatbuffers/idl.h
index 1a0e4a0f..74d8bdc9 100644
--- a/include/flatbuffers/idl.h
+++ b/include/flatbuffers/idl.h
@@ -521,9 +521,6 @@ struct IDLOptions {
// Use flexbuffers instead for binary and text generation
bool use_flexbuffers;
bool strict_json;
- bool skip_js_exports;
- bool use_goog_js_export_format;
- bool use_ES6_js_export_format;
bool output_default_scalars_in_json;
int indent_step;
bool output_enum_identifiers;
@@ -556,11 +553,8 @@ struct IDLOptions {
bool binary_schema_comments;
bool binary_schema_builtins;
bool binary_schema_gen_embed;
- bool skip_flatbuffers_import;
std::string go_import;
std::string go_namespace;
- bool reexport_ts_modules;
- bool js_ts_short_names;
bool protobuf_ascii_alike;
bool size_prefixed;
std::string root_type;
@@ -580,7 +574,6 @@ struct IDLOptions {
kCSharp = 1 << 1,
kGo = 1 << 2,
kCpp = 1 << 3,
- kJs = 1 << 4,
kPython = 1 << 5,
kPhp = 1 << 6,
kJson = 1 << 7,
@@ -621,9 +614,6 @@ struct IDLOptions {
: gen_jvmstatic(false),
use_flexbuffers(false),
strict_json(false),
- skip_js_exports(false),
- use_goog_js_export_format(false),
- use_ES6_js_export_format(false),
output_default_scalars_in_json(false),
indent_step(2),
output_enum_identifiers(true),
@@ -653,9 +643,6 @@ struct IDLOptions {
binary_schema_comments(false),
binary_schema_builtins(false),
binary_schema_gen_embed(false),
- skip_flatbuffers_import(false),
- reexport_ts_modules(true),
- js_ts_short_names(false),
protobuf_ascii_alike(false),
size_prefixed(false),
force_defaults(false),
@@ -1054,8 +1041,8 @@ extern bool GenerateJava(const Parser &parser, const std::string &path,
// Generate JavaScript or TypeScript code from the definitions in the Parser
// object. See idl_gen_js.
-extern bool GenerateJSTS(const Parser &parser, const std::string &path,
- const std::string &file_name);
+extern bool GenerateTS(const Parser &parser, const std::string &path,
+ const std::string &file_name);
// Generate Go files from the definitions in the Parser object.
// See idl_gen_go.cpp.
@@ -1107,10 +1094,10 @@ extern std::string GenerateFBS(const Parser &parser,
extern bool GenerateFBS(const Parser &parser, const std::string &path,
const std::string &file_name);
-// Generate a make rule for the generated JavaScript or TypeScript code.
-// See idl_gen_js.cpp.
-extern std::string JSTSMakeRule(const Parser &parser, const std::string &path,
- const std::string &file_name);
+// Generate a make rule for the generated TypeScript code.
+// See idl_gen_ts.cpp.
+extern std::string TSMakeRule(const Parser &parser, const std::string &path,
+ const std::string &file_name);
// Generate a make rule for the generated C++ header.
// See idl_gen_cpp.cpp.
@@ -1169,7 +1156,7 @@ extern bool GenerateSwiftGRPC(const Parser &parser, const std::string &path,
const std::string &file_name);
extern bool GenerateTSGRPC(const Parser &parser, const std::string &path,
- const std::string &file_name);
+ const std::string &file_name);
} // namespace flatbuffers
#endif // FLATBUFFERS_IDL_H_
diff --git a/include/flatbuffers/util.h b/include/flatbuffers/util.h
index 2aafa482..7a3e12f3 100644
--- a/include/flatbuffers/util.h
+++ b/include/flatbuffers/util.h
@@ -51,6 +51,9 @@ inline bool is_alpha(char c) {
return check_ascii_range(c & 0xDF, 'a' & 0xDF, 'z' & 0xDF);
}
+// Check for uppercase alpha
+inline bool is_alpha_upper(char c) { return check_ascii_range(c, 'A', 'Z'); }
+
// Check (case-insensitive) that `c` is equal to alpha.
inline bool is_alpha_char(char c, char alpha) {
FLATBUFFERS_ASSERT(is_alpha(alpha));
diff --git a/package.json b/package.json
index 0ff0bd84..04ed26b9 100644
--- a/package.json
+++ b/package.json
@@ -16,11 +16,9 @@
"test": "tests"
},
"scripts": {
- "test": "cd tests && ./JavaScriptTest.sh",
- "compile-ts": "tsc && tsc -p tsconfig.mjs.json",
- "pretest": "npm run compile-ts",
- "append-esm-export": "sed \"s/this.flatbuffers = flatbuffers;/export { flatbuffers };/\" js/flatbuffers.js > js/flatbuffers.mjs",
- "prepublishOnly": "npm run compile-ts && npm run append-esm-export"
+ "test": "npm run compile && cd tests && ./TypeScriptTest.sh",
+ "compile": "tsc && tsc -p tsconfig.mjs.json",
+ "prepublishOnly": "npm run compile"
},
"repository": {
"type": "git",
@@ -37,9 +35,9 @@
"homepage": "https://google.github.io/flatbuffers/",
"dependencies": {},
"devDependencies": {
- "@typescript-eslint/eslint-plugin": "^4.1.0",
- "@typescript-eslint/parser": "^4.1.0",
- "eslint": "^7.8.1",
- "typescript": "^4.0.2"
+ "@typescript-eslint/eslint-plugin": "^4.12.0",
+ "@typescript-eslint/parser": "^4.12.0",
+ "eslint": "^7.17.0",
+ "typescript": "^4.1.3"
}
}
diff --git a/src/code_generators.cpp b/src/code_generators.cpp
index 46d65f7c..745406ba 100644
--- a/src/code_generators.cpp
+++ b/src/code_generators.cpp
@@ -84,20 +84,39 @@ const char *BaseGenerator::FlatBuffersGeneratedWarning() {
std::string BaseGenerator::NamespaceDir(const Parser &parser,
const std::string &path,
- const Namespace &ns) {
+ const Namespace &ns,
+ const bool dasherize) {
EnsureDirExists(path);
if (parser.opts.one_file) return path;
std::string namespace_dir = path; // Either empty or ends in separator.
auto &namespaces = ns.components;
for (auto it = namespaces.begin(); it != namespaces.end(); ++it) {
- namespace_dir += *it + kPathSeparator;
+ namespace_dir += !dasherize ? *it : ToDasherizedCase(*it);
+ namespace_dir += kPathSeparator;
EnsureDirExists(namespace_dir);
}
return namespace_dir;
}
-std::string BaseGenerator::NamespaceDir(const Namespace &ns) const {
- return BaseGenerator::NamespaceDir(parser_, path_, ns);
+std::string BaseGenerator::NamespaceDir(const Namespace &ns,
+ const bool dasherize) const {
+ return BaseGenerator::NamespaceDir(parser_, path_, ns, dasherize);
+}
+
+std::string BaseGenerator::ToDasherizedCase(const std::string pascal_case) {
+ std::string dasherized_case;
+ char p = 0;
+ for (size_t i = 0; i < pascal_case.length(); i++) {
+ char const &c = pascal_case[i];
+ if (is_alpha_upper(c)) {
+ if (i > 0 && p != kPathSeparator) dasherized_case += "-";
+ dasherized_case += CharToLower(c);
+ } else {
+ dasherized_case += c;
+ }
+ p = c;
+ }
+ return dasherized_case;
}
std::string BaseGenerator::FullNamespace(const char *separator,
diff --git a/src/flatc.cpp b/src/flatc.cpp
index d51120fe..6eeefab6 100644
--- a/src/flatc.cpp
+++ b/src/flatc.cpp
@@ -129,9 +129,6 @@ std::string FlatCompiler::GetUsageString(const char *program_name) const {
" --object-prefix Customise class prefix for C++ object-based API.\n"
" --object-suffix Customise class suffix for C++ object-based API.\n"
" Default value is \"T\".\n"
- " --no-js-exports Removes Node.js style export lines in JS.\n"
- " --goog-js-export Uses goog.exports* for closure compiler exporting in JS.\n"
- " --es6-js-export Uses ECMAScript 6 export style lines in JS.\n"
" --go-namespace Generate the overriding namespace in Golang.\n"
" --go-import Generate the overriding import for flatbuffers in Golang\n"
" (default is \"github.com/google/flatbuffers/go\").\n"
@@ -157,9 +154,6 @@ std::string FlatCompiler::GetUsageString(const char *program_name) const {
" --include-prefix Prefix this path to any generated include statements.\n"
" PATH\n"
" --keep-prefix Keep original prefix of schema include statement.\n"
- " --no-fb-import Don't include flatbuffers import statement for TypeScript.\n"
- " --no-ts-reexport Don't re-export imported dependencies for TypeScript.\n"
- " --short-names Use short function names for JS and TypeScript.\n"
" --reflect-types Add minimal type reflection to code generation.\n"
" --reflect-names Add minimal type/name reflection.\n"
" --root-type T Select or override the default root_type\n"
@@ -240,14 +234,6 @@ int FlatCompiler::Compile(int argc, const char **argv) {
opts.allow_non_utf8 = true;
} else if (arg == "--natural-utf8") {
opts.natural_utf8 = true;
- } else if (arg == "--no-js-exports") {
- opts.skip_js_exports = true;
- } else if (arg == "--goog-js-export") {
- opts.use_goog_js_export_format = true;
- opts.use_ES6_js_export_format = false;
- } else if (arg == "--es6-js-export") {
- opts.use_goog_js_export_format = false;
- opts.use_ES6_js_export_format = true;
} else if (arg == "--go-namespace") {
if (++argi >= argc) Error("missing golang namespace" + arg, true);
opts.go_namespace = argv[argi];
@@ -301,7 +287,6 @@ int FlatCompiler::Compile(int argc, const char **argv) {
} else if (arg == "--gen-all") {
opts.generate_all = true;
opts.include_dependence_headers = false;
- opts.reexport_ts_modules = false;
} else if (arg == "--gen-includes") {
// Deprecated, remove this option some time in the future.
Warn("warning: --gen-includes is deprecated (it is now default)\n");
@@ -337,12 +322,6 @@ int FlatCompiler::Compile(int argc, const char **argv) {
opts.binary_schema_builtins = true;
} else if (arg == "--bfbs-gen-embed") {
opts.binary_schema_gen_embed = true;
- } else if (arg == "--no-fb-import") {
- opts.skip_flatbuffers_import = true;
- } else if (arg == "--no-ts-reexport") {
- opts.reexport_ts_modules = false;
- } else if (arg == "--short-names") {
- opts.js_ts_short_names = true;
} else if (arg == "--reflect-types") {
opts.mini_reflect = IDLOptions::kTypes;
} else if (arg == "--reflect-names") {
diff --git a/src/flatc_main.cpp b/src/flatc_main.cpp
index c942bdac..b1966660 100644
--- a/src/flatc_main.cpp
+++ b/src/flatc_main.cpp
@@ -71,17 +71,12 @@ int main(int argc, const char *argv[]) {
flatbuffers::GenerateJavaGRPC, flatbuffers::IDLOptions::kJava,
"Generate Java classes for tables/structs",
flatbuffers::JavaCSharpMakeRule },
- { flatbuffers::GenerateJSTS, "-s", "--js", "JavaScript", true, nullptr,
- flatbuffers::IDLOptions::kJs,
- "Generate JavaScript code for tables/structs",
- flatbuffers::JSTSMakeRule },
{ flatbuffers::GenerateDart, "-d", "--dart", "Dart", true, nullptr,
flatbuffers::IDLOptions::kDart,
"Generate Dart classes for tables/structs", flatbuffers::DartMakeRule },
- { flatbuffers::GenerateJSTS, "-T", "--ts", "TypeScript", true,
+ { flatbuffers::GenerateTS, "-T", "--ts", "TypeScript", true,
flatbuffers::GenerateTSGRPC, flatbuffers::IDLOptions::kTs,
- "Generate TypeScript code for tables/structs",
- flatbuffers::JSTSMakeRule },
+ "Generate TypeScript code for tables/structs", flatbuffers::TSMakeRule },
{ flatbuffers::GenerateCSharp, "-n", "--csharp", "C#", true, nullptr,
flatbuffers::IDLOptions::kCSharp,
"Generate C# classes for tables/structs",
diff --git a/src/idl_gen_ts.cpp b/src/idl_gen_ts.cpp
index 0240f513..37b6d272 100644
--- a/src/idl_gen_ts.cpp
+++ b/src/idl_gen_ts.cpp
@@ -27,229 +27,89 @@
namespace flatbuffers {
-struct JsTsLanguageParameters {
- IDLOptions::Language language;
- std::string file_extension;
-};
-
-struct ReexportDescription {
- std::string symbol;
- std::string source_namespace;
- std::string target_namespace;
+struct ImportDefinition {
+ std::string name;
+ std::string statement;
+ const Definition *dependent;
+ const Definition *dependency;
};
enum AnnotationType { kParam = 0, kType = 1, kReturns = 2 };
-const JsTsLanguageParameters &GetJsLangParams(IDLOptions::Language lang) {
- static JsTsLanguageParameters js_language_parameters[] = {
- {
- IDLOptions::kJs,
- ".js",
- },
- {
- IDLOptions::kTs,
- ".ts",
- },
- };
-
- if (lang == IDLOptions::kJs) {
- return js_language_parameters[0];
- } else {
- FLATBUFFERS_ASSERT(lang == IDLOptions::kTs);
- return js_language_parameters[1];
- }
-}
-
-namespace jsts {
+namespace ts {
// Iterate through all definitions we haven't generate code for (enums, structs,
// and tables) and output them to a single file.
-class JsTsGenerator : public BaseGenerator {
+class TsGenerator : public BaseGenerator {
public:
- typedef std::unordered_set<std::string> imported_fileset;
- typedef std::unordered_multimap<std::string, ReexportDescription>
- reexport_map;
-
- JsTsGenerator(const Parser &parser, const std::string &path,
- const std::string &file_name)
- : BaseGenerator(parser, path, file_name, "", ".",
- parser.opts.lang == IDLOptions::kJs ? "js" : "ts"),
- lang_(GetJsLangParams(parser_.opts.lang)) {}
- // Iterate through all definitions we haven't generate code for (enums,
- // structs, and tables) and output them to a single file.
- bool generate() {
- imported_fileset imported_files;
- reexport_map reexports;
-
- std::string enum_code, struct_code, import_code, exports_code, code;
- generateEnums(&enum_code, &exports_code, reexports, imported_files);
- generateStructs(&struct_code, &exports_code, imported_files);
- generateImportDependencies(&import_code, imported_files);
- generateReexports(&import_code, reexports, imported_files);
-
- code = code + "// " + FlatBuffersGeneratedWarning() + "\n\n";
-
- // Generate code for all the namespace declarations.
- GenNamespaces(&code, &exports_code);
-
- // Output the main declaration code from above.
- code += import_code;
-
- code += enum_code;
- code += struct_code;
-
- if (lang_.language == IDLOptions::kJs && !exports_code.empty() &&
- !parser_.opts.skip_js_exports) {
- if (parser_.opts.use_ES6_js_export_format)
- code += "// Exports for ECMAScript6 Modules\n";
- else
- code += "// Exports for Node.js and RequireJS\n";
- code += exports_code;
- }
-
- return SaveFile(GeneratedFileName(path_, file_name_, parser_.opts).c_str(),
- code, false);
- }
-
- private:
- JsTsLanguageParameters lang_;
+ typedef std::map<std::string, ImportDefinition> import_set;
- // Generate code for imports
- void generateImportDependencies(std::string *code_ptr,
- const imported_fileset &imported_files) {
- std::string &code = *code_ptr;
- for (auto it = imported_files.begin(); it != imported_files.end(); ++it) {
- const auto &file = *it;
- const auto basename =
- flatbuffers::StripPath(flatbuffers::StripExtension(file));
- if (basename != file_name_) { code += GenPrefixedImport(file, basename); }
- }
+ TsGenerator(const Parser &parser, const std::string &path,
+ const std::string &file_name)
+ : BaseGenerator(parser, path, file_name, "", ".", "ts") {}
+ bool generate() {
+ generateEnums();
+ generateStructs();
+ return true;
}
- // Generate reexports, which might not have been explicitly imported using the
- // "export import" trick
- void generateReexports(std::string *code_ptr, const reexport_map &reexports,
- imported_fileset imported_files) {
- if (!parser_.opts.reexport_ts_modules ||
- lang_.language != IDLOptions::kTs) {
- return;
- }
+ // Save out the generated code for a single class while adding
+ // declaration boilerplate.
+ bool SaveType(const Definition &definition, const std::string &classcode,
+ import_set &imports, import_set &bare_imports) const {
+ if (!classcode.length()) return true;
- std::unordered_set<std::string> imported;
+ std::string code =
+ "// " + std::string(FlatBuffersGeneratedWarning()) + "\n\n";
- std::string &code = *code_ptr;
- for (auto it = reexports.begin(); it != reexports.end(); ++it) {
- const auto &file = *it;
- const auto basename =
- flatbuffers::StripPath(flatbuffers::StripExtension(file.first));
- if (basename != file_name_ &&
- imported.find(file.second.symbol) == imported.end()) {
- if (imported_files.find(file.first) == imported_files.end()) {
- code += GenPrefixedImport(file.first, basename);
- imported_files.emplace(file.first);
- }
+ for (auto it = bare_imports.begin(); it != bare_imports.end(); it++)
+ code += it->second.statement + "\n";
+ if (!bare_imports.empty()) code += "\n";
- if (!file.second.target_namespace.empty()) {
- code += "export namespace " + file.second.target_namespace + " { \n";
- }
- code += "export import " + file.second.symbol + " = ";
- code += GenFileNamespacePrefix(file.first) + ".";
- if (!file.second.source_namespace.empty()) {
- code += file.second.source_namespace + ".";
- }
- code += file.second.symbol + ";\n";
- if (!file.second.target_namespace.empty()) { code += "}\n"; }
+ for (auto it = imports.begin(); it != imports.end(); it++)
+ if (it->second.dependency != &definition) // do not import itself
+ code += it->second.statement + "\n";
+ if (!imports.empty()) code += "\n\n";
- imported.emplace(file.second.symbol);
- }
- }
+ code += classcode;
+ auto filename = NamespaceDir(*definition.defined_namespace, true) +
+ ToDasherizedCase(definition.name) + ".ts";
+ return SaveFile(filename.c_str(), code, false);
}
+ private:
// Generate code for all enums.
- void generateEnums(std::string *enum_code_ptr, std::string *exports_code_ptr,
- reexport_map &reexports,
- imported_fileset &imported_files) {
+ void generateEnums() {
for (auto it = parser_.enums_.vec.begin(); it != parser_.enums_.vec.end();
++it) {
+ import_set bare_imports;
+ import_set imports;
+ std::string enumcode;
auto &enum_def = **it;
- GenEnum(enum_def, enum_code_ptr, exports_code_ptr, reexports,
- imported_files, false);
- GenEnum(enum_def, enum_code_ptr, exports_code_ptr, reexports,
- imported_files, true);
+ GenEnum(enum_def, &enumcode, imports, false);
+ GenEnum(enum_def, &enumcode, imports, true);
+ SaveType(enum_def, enumcode, imports, bare_imports);
}
}
// Generate code for all structs.
- void generateStructs(std::string *decl_code_ptr,
- std::string *exports_code_ptr,
- imported_fileset &imported_files) {
+ void generateStructs() {
for (auto it = parser_.structs_.vec.begin();
it != parser_.structs_.vec.end(); ++it) {
+ import_set bare_imports;
+ import_set imports;
+ AddImport(bare_imports, "* as flatbuffers", "flatbuffers");
auto &struct_def = **it;
- GenStruct(parser_, struct_def, decl_code_ptr, exports_code_ptr,
- imported_files);
- }
- }
- void GenNamespaces(std::string *code_ptr, std::string *exports_ptr) {
- if (lang_.language == IDLOptions::kTs &&
- parser_.opts.skip_flatbuffers_import) {
- return;
- }
-
- std::set<std::string> namespaces;
-
- for (auto it = parser_.namespaces_.begin(); it != parser_.namespaces_.end();
- ++it) {
- std::string namespace_so_far;
-
- // Gather all parent namespaces for this namespace
- for (auto component = (*it)->components.begin();
- component != (*it)->components.end(); ++component) {
- if (!namespace_so_far.empty()) { namespace_so_far += '.'; }
- namespace_so_far += *component;
- namespaces.insert(namespace_so_far);
- }
- }
-
- // Make sure parent namespaces come before child namespaces
- std::vector<std::string> sorted_namespaces(namespaces.begin(),
- namespaces.end());
- std::sort(sorted_namespaces.begin(), sorted_namespaces.end());
-
- // Emit namespaces in a form that Closure Compiler can optimize
- std::string &code = *code_ptr;
- std::string &exports = *exports_ptr;
-
- if (lang_.language == IDLOptions::kTs) {
- code += "import * as flatbuffers from 'flatbuffers';\n";
- }
-
- for (auto it = sorted_namespaces.begin(); it != sorted_namespaces.end();
- ++it) {
- if (lang_.language == IDLOptions::kTs) {
- if (it->find('.') == std::string::npos) { break; }
- } else {
- code += "/**\n * @const\n * @namespace\n */\n";
- if (it->find('.') == std::string::npos) {
- code += "var ";
- if (parser_.opts.use_goog_js_export_format) {
- exports += "goog.exportSymbol('" + *it + "', " + *it + ");\n";
- } else if (parser_.opts.use_ES6_js_export_format) {
- exports += "export {" + *it + "};\n";
- } else {
- exports += "this." + *it + " = " + *it + ";\n";
- }
- }
- code += *it + " = " + *it + " || {};\n\n";
- }
+ std::string declcode;
+ GenStruct(parser_, struct_def, &declcode, imports);
+ SaveType(struct_def, declcode, imports, bare_imports);
}
}
// Generate a documentation comment, if available.
static void GenDocComment(const std::vector<std::string> &dc,
std::string *code_ptr,
- const std::string &extra_lines,
const char *indent = nullptr) {
- if (dc.empty() && extra_lines.empty()) {
+ if (dc.empty()) {
// Don't output empty comment blocks with 0 lines of comment content.
return;
}
@@ -261,135 +121,48 @@ class JsTsGenerator : public BaseGenerator {
if (indent) code += indent;
code += " *" + *it + "\n";
}
- if (!extra_lines.empty()) {
- if (!dc.empty()) {
- if (indent) code += indent;
- code += " *\n";
- }
- if (indent) code += indent;
- std::string::size_type start = 0;
- for (;;) {
- auto end = extra_lines.find('\n', start);
- if (end != std::string::npos) {
- code += " * " + extra_lines.substr(start, end - start) + "\n";
- start = end + 1;
- } else {
- code += " * " + extra_lines.substr(start) + "\n";
- break;
- }
- }
- }
if (indent) code += indent;
code += " */\n";
}
- static void GenDocComment(std::string *code_ptr,
- const std::string &extra_lines) {
- GenDocComment(std::vector<std::string>(), code_ptr, extra_lines);
- }
-
- std::string GenTypeAnnotation(AnnotationType annotation_type,
- const std::string &type_name,
- const std::string &arg_name,
- bool include_newline = true) {
- std::string result = "";
- switch (annotation_type) {
- case kParam: {
- result += "@param";
- break;
- }
- case kType: {
- if (lang_.language != IDLOptions::kTs) {
- result += "@type";
- } else {
- return "";
- }
- break;
- }
- case kReturns: {
- result += "@returns";
- break;
- }
- }
- switch (lang_.language) {
- case IDLOptions::kTs: {
- result += " " + type_name;
- break;
- }
- default: {
- result += " {" + type_name + "}";
- }
- }
- if (!arg_name.empty()) { result += " " + arg_name; }
- if (include_newline) { result += "\n"; }
-
- return result;
+ static void GenDocComment(std::string *code_ptr) {
+ GenDocComment(std::vector<std::string>(), code_ptr);
}
// Generate an enum declaration and an enum string lookup table.
- void GenEnum(EnumDef &enum_def, std::string *code_ptr,
- std::string *exports_ptr, reexport_map &reexports,
- imported_fileset &imported_files, bool reverse) {
+ void GenEnum(EnumDef &enum_def, std::string *code_ptr, import_set &imports,
+ bool reverse) {
if (enum_def.generated) return;
- if (reverse && lang_.language == IDLOptions::kTs) return; // FIXME.
+ if (reverse) return; // FIXME.
std::string &code = *code_ptr;
- std::string &exports = *exports_ptr;
- GenDocComment(enum_def.doc_comment, code_ptr,
- reverse ? "@enum {string}" : "@enum {number}");
+ GenDocComment(enum_def.doc_comment, code_ptr);
std::string ns = GetNameSpace(enum_def);
std::string enum_def_name = enum_def.name + (reverse ? "Name" : "");
- if (lang_.language == IDLOptions::kTs) {
- if (!ns.empty()) { code += "export namespace " + ns + "{\n"; }
- code += "export enum " + enum_def.name + "{\n";
- } else {
- if (enum_def.defined_namespace->components.empty()) {
- code += "var ";
- if (parser_.opts.use_goog_js_export_format) {
- exports += "goog.exportSymbol('" + enum_def_name + "', " +
- enum_def.name + ");\n";
- } else if (parser_.opts.use_ES6_js_export_format) {
- exports += "export {" + enum_def_name + "};\n";
- } else {
- exports += "this." + enum_def_name + " = " + enum_def_name + ";\n";
- }
- }
- code += WrapInNameSpace(enum_def) + (reverse ? "Name" : "") + " = {\n";
- }
+ code += "export enum " + enum_def.name + "{\n";
for (auto it = enum_def.Vals().begin(); it != enum_def.Vals().end(); ++it) {
auto &ev = **it;
if (!ev.doc_comment.empty()) {
if (it != enum_def.Vals().begin()) { code += '\n'; }
- GenDocComment(ev.doc_comment, code_ptr, "", " ");
+ GenDocComment(ev.doc_comment, code_ptr, " ");
}
// Generate mapping between EnumName: EnumValue(int)
if (reverse) {
code += " '" + enum_def.ToString(ev) + "'";
- code += lang_.language == IDLOptions::kTs ? "= " : ": ";
+ code += " = ";
code += "'" + ev.name + "'";
} else {
code += " " + ev.name;
- code += lang_.language == IDLOptions::kTs ? "= " : ": ";
+ code += " = ";
code += enum_def.ToString(ev);
}
code += (it + 1) != enum_def.Vals().end() ? ",\n" : "\n";
-
- if (ev.union_type.struct_def) {
- ReexportDescription desc = { ev.union_type.struct_def->name,
- GetNameSpace(*ev.union_type.struct_def),
- GetNameSpace(enum_def) };
- reexports.insert(
- std::make_pair(ev.union_type.struct_def->file, std::move(desc)));
- }
}
- code += "};";
+ code += "}";
- if (lang_.language == IDLOptions::kTs) {
- if (enum_def.is_union) {
- code += GenUnionConvFunc(enum_def.underlying_type, imported_files);
- }
- if (!ns.empty()) { code += "\n}"; }
+ if (enum_def.is_union) {
+ code += GenUnionConvFunc(enum_def.underlying_type, imports);
}
code += "\n\n";
@@ -412,7 +185,7 @@ class JsTsGenerator : public BaseGenerator {
case BASE_TYPE_STRING: return "String";
case BASE_TYPE_VECTOR: return GenType(type.VectorType());
case BASE_TYPE_STRUCT: return type.struct_def->name;
- default: return "Table";
+ default: return "flatbuffers.Table";
}
}
@@ -421,8 +194,7 @@ class JsTsGenerator : public BaseGenerator {
case BASE_TYPE_STRING: return GenBBAccess() + ".__string" + arguments;
case BASE_TYPE_STRUCT: return GenBBAccess() + ".__struct" + arguments;
case BASE_TYPE_UNION:
- if (!UnionHasStringType(*type.enum_def) ||
- lang_.language == IDLOptions::kJs) {
+ if (!UnionHasStringType(*type.enum_def)) {
return GenBBAccess() + ".__union" + arguments;
}
return GenBBAccess() + ".__union_with_string" + arguments;
@@ -431,42 +203,25 @@ class JsTsGenerator : public BaseGenerator {
auto getter =
GenBBAccess() + ".read" + MakeCamel(GenType(type)) + arguments;
if (type.base_type == BASE_TYPE_BOOL) { getter = "!!" + getter; }
- if (type.enum_def) {
- getter = "/** " +
- GenTypeAnnotation(kType, WrapInNameSpace(*type.enum_def), "",
- false) +
- " */ (" + getter + ")";
- }
return getter;
}
}
}
- std::string GenBBAccess() const {
- return lang_.language == IDLOptions::kTs ? "this.bb!" : "this.bb";
- }
+ std::string GenBBAccess() const { return "this.bb!"; }
- std::string GenDefaultValue(const FieldDef &field, const std::string &context) {
- if (field.IsScalarOptional()) {
- return "null";
- }
+ std::string GenDefaultValue(const FieldDef &field, const std::string &context,
+ import_set &imports) {
+ if (field.IsScalarOptional()) { return "null"; }
const auto &value = field.value;
if (value.type.enum_def && value.type.base_type != BASE_TYPE_UNION &&
value.type.base_type != BASE_TYPE_VECTOR) {
if (auto val = value.type.enum_def->FindByValue(value.constant)) {
- if (lang_.language == IDLOptions::kTs) {
- return GenPrefixedTypeName(WrapInNameSpace(*value.type.enum_def),
- value.type.enum_def->file) +
- "." + val->name;
- } else {
- return WrapInNameSpace(*value.type.enum_def) + "." + val->name;
- }
+ return AddImport(imports, *value.type.enum_def, *value.type.enum_def) +
+ "." + val->name;
} else {
- return "/** " +
- GenTypeAnnotation(kType, WrapInNameSpace(*value.type.enum_def),
- "", false) +
- "} */ (" + value.constant + ")";
+ return value.constant;
}
}
@@ -484,16 +239,17 @@ class JsTsGenerator : public BaseGenerator {
case BASE_TYPE_LONG:
case BASE_TYPE_ULONG: {
int64_t constant = StringToInt(value.constant.c_str());
- return context + ".createLong(" +
- NumToString(static_cast<int32_t>(constant)) + ", " +
- NumToString(static_cast<int32_t>(constant >> 32)) + ")";
+ std::string createLong = context + ".createLong";
+ return createLong + "(" + NumToString(static_cast<int32_t>(constant)) +
+ ", " + NumToString(static_cast<int32_t>(constant >> 32)) + ")";
}
default: return value.constant;
}
}
- std::string GenTypeName(const Type &type, bool input,
+ std::string GenTypeName(import_set &imports, const Definition &owner,
+ const Type &type, bool input,
bool allowNull = false) {
if (!input) {
if (IsString(type) || type.base_type == BASE_TYPE_STRUCT) {
@@ -501,24 +257,24 @@ class JsTsGenerator : public BaseGenerator {
if (IsString(type)) {
name = "string|Uint8Array";
} else {
- name = WrapInNameSpace(*type.struct_def);
+ name = AddImport(imports, owner, *type.struct_def);
}
- return (allowNull) ? (name + "|null") : (name);
+ return allowNull ? (name + "|null") : name;
}
}
switch (type.base_type) {
- case BASE_TYPE_BOOL: return (allowNull) ? ("boolean|null") : ("boolean");
+ case BASE_TYPE_BOOL: return allowNull ? "boolean|null" : "boolean";
case BASE_TYPE_LONG:
- case BASE_TYPE_ULONG: return (allowNull) ? ("flatbuffers.Long|null") : ("flatbuffers.Long");
+ case BASE_TYPE_ULONG:
+ return allowNull ? "flatbuffers.Long|null" : "flatbuffers.Long";
default:
if (IsScalar(type.base_type)) {
if (type.enum_def) {
- const auto enum_name = WrapInNameSpace(*type.enum_def);
- return (allowNull) ? (enum_name + "|null") : (enum_name);
+ const auto enum_name = AddImport(imports, owner, *type.enum_def);
+ return allowNull ? (enum_name + "|null") : enum_name;
}
-
- return (allowNull) ? ("number|null") : ("number");
+ return allowNull ? "number|null" : "number";
}
return "flatbuffers.Offset";
}
@@ -549,7 +305,7 @@ class JsTsGenerator : public BaseGenerator {
}
static std::string GenFileNamespacePrefix(const std::string &file) {
- return "NS" + std::to_string(HashFnv1a<uint64_t>(file.c_str()));
+ return "NS" + NumToString(HashFnv1a<uint64_t>(file.c_str()));
}
std::string GenPrefixedImport(const std::string &full_file_name,
@@ -585,7 +341,7 @@ class JsTsGenerator : public BaseGenerator {
return GenFileNamespacePrefix(file) + "." + typeName;
}
- void GenStructArgs(const StructDef &struct_def, std::string *annotations,
+ void GenStructArgs(import_set &imports, const StructDef &struct_def,
std::string *arguments, const std::string &nameprefix) {
for (auto it = struct_def.fields.vec.begin();
it != struct_def.fields.vec.end(); ++it) {
@@ -594,18 +350,12 @@ class JsTsGenerator : public BaseGenerator {
// Generate arguments for a struct inside a struct. To ensure names
// don't clash, and to make it obvious these arguments are constructing
// a nested struct, prefix the name with the field name.
- GenStructArgs(*field.value.type.struct_def, annotations, arguments,
+ GenStructArgs(imports, *field.value.type.struct_def, arguments,
nameprefix + field.name + "_");
} else {
- *annotations +=
- GenTypeAnnotation(kParam, GenTypeName(field.value.type, true, field.optional),
- nameprefix + field.name);
- if (lang_.language == IDLOptions::kTs) {
- *arguments += ", " + nameprefix + field.name + ": " +
- GenTypeName(field.value.type, true, field.optional);
- } else {
- *arguments += ", " + nameprefix + field.name;
- }
+ *arguments +=
+ ", " + nameprefix + field.name + ": " +
+ GenTypeName(imports, field, field.value.type, true, field.optional);
}
}
}
@@ -637,29 +387,19 @@ class JsTsGenerator : public BaseGenerator {
}
std::string GenerateNewExpression(const std::string &object_name) {
- return "new " + object_name +
- (lang_.language == IDLOptions::kTs ? "()" : "");
+ return "new " + object_name + "()";
}
void GenerateRootAccessor(StructDef &struct_def, std::string *code_ptr,
- std::string &code, std::string &object_name,
+ std::string &code, const std::string &object_name,
bool size_prefixed) {
if (!struct_def.fixed) {
- GenDocComment(code_ptr,
- GenTypeAnnotation(kParam, "flatbuffers.ByteBuffer", "bb") +
- GenTypeAnnotation(kParam, object_name + "=", "obj") +
- GenTypeAnnotation(kReturns, object_name, "", false));
+ GenDocComment(code_ptr);
std::string sizePrefixed("SizePrefixed");
- if (lang_.language == IDLOptions::kTs) {
- code += "static get" + (size_prefixed ? sizePrefixed : "") + "Root" +
- Verbose(struct_def, "As");
- code += "(bb:flatbuffers.ByteBuffer, obj?:" + object_name +
- "):" + object_name + " {\n";
- } else {
- code += object_name + ".get" + (size_prefixed ? sizePrefixed : "") +
- "Root" + Verbose(struct_def, "As");
- code += " = function(bb, obj) {\n";
- }
+ code += "static get" + (size_prefixed ? sizePrefixed : "") + "Root" +
+ GetPrefixedName(struct_def, "As");
+ code += "(bb:flatbuffers.ByteBuffer, obj?:" + object_name +
+ "):" + object_name + " {\n";
if (size_prefixed) {
code +=
" bb.setPosition(bb.position() + "
@@ -667,30 +407,19 @@ class JsTsGenerator : public BaseGenerator {
}
code += " return (obj || " + GenerateNewExpression(object_name);
code += ").__init(bb.readInt32(bb.position()) + bb.position(), bb);\n";
- code += "};\n\n";
+ code += "}\n\n";
}
}
void GenerateFinisher(StructDef &struct_def, std::string *code_ptr,
- std::string &code, std::string &object_name,
- bool size_prefixed) {
+ std::string &code, bool size_prefixed) {
if (parser_.root_struct_def_ == &struct_def) {
std::string sizePrefixed("SizePrefixed");
- GenDocComment(
- code_ptr,
- GenTypeAnnotation(kParam, "flatbuffers.Builder", "builder") +
- GenTypeAnnotation(kParam, "flatbuffers.Offset", "offset", false));
-
- if (lang_.language == IDLOptions::kTs) {
- code += "static finish" + (size_prefixed ? sizePrefixed : "") +
- Verbose(struct_def) + "Buffer";
- code += "(builder:flatbuffers.Builder, offset:flatbuffers.Offset) {\n";
- } else {
- code += object_name + ".finish" + (size_prefixed ? sizePrefixed : "") +
- Verbose(struct_def) + "Buffer";
- code += " = function(builder, offset) {\n";
- }
+ GenDocComment(code_ptr);
+ code += "static finish" + (size_prefixed ? sizePrefixed : "") +
+ GetPrefixedName(struct_def) + "Buffer";
+ code += "(builder:flatbuffers.Builder, offset:flatbuffers.Offset) {\n";
code += " builder.finish(offset";
if (!parser_.file_identifier_.empty()) {
code += ", '" + parser_.file_identifier_ + "'";
@@ -700,7 +429,7 @@ class JsTsGenerator : public BaseGenerator {
code += ", true";
}
code += ");\n";
- code += "};\n\n";
+ code += "}\n\n";
}
}
@@ -717,17 +446,19 @@ class JsTsGenerator : public BaseGenerator {
bool UnionHasStringType(const EnumDef &union_enum) {
return std::any_of(union_enum.Vals().begin(), union_enum.Vals().end(),
[](const EnumVal *ev) {
- return !(ev->IsZero()) &&
- (IsString(ev->union_type));
+ return !ev->IsZero() && IsString(ev->union_type);
});
}
std::string GenUnionGenericTypeTS(const EnumDef &union_enum) {
- return std::string("T") + (UnionHasStringType(union_enum) ? "|string" : "");
+ // TODO: make it work without any
+ // return std::string("T") + (UnionHasStringType(union_enum) ? "|string" :
+ // "");
+ return std::string("any") +
+ (UnionHasStringType(union_enum) ? "|string" : "");
}
- std::string GenUnionTypeTS(const EnumDef &union_enum,
- imported_fileset &imported_files) {
+ std::string GenUnionTypeTS(const EnumDef &union_enum, import_set &imports) {
std::string ret;
std::set<std::string> type_list;
@@ -740,12 +471,7 @@ class JsTsGenerator : public BaseGenerator {
if (IsString(ev.union_type)) {
type = "string"; // no need to wrap string type in namespace
} else if (ev.union_type.base_type == BASE_TYPE_STRUCT) {
- if (!parser_.opts.generate_all) {
- imported_files.insert(ev.union_type.struct_def->file);
- }
-
- type = GenPrefixedTypeName(WrapInNameSpace(*(ev.union_type.struct_def)),
- ev.union_type.struct_def->file);
+ type = AddImport(imports, union_enum, *ev.union_type.struct_def);
} else {
FLATBUFFERS_ASSERT(false);
}
@@ -759,8 +485,110 @@ class JsTsGenerator : public BaseGenerator {
return ret;
}
+ std::string AddImport(import_set &imports, const Definition &dependent,
+ const StructDef &dependency) {
+ std::string ns;
+ const auto &depc_comps = dependency.defined_namespace->components;
+ for (auto it = depc_comps.begin(); it != depc_comps.end(); it++) ns += *it;
+ std::string unique_name = ns + dependency.name;
+ std::string import_name = dependency.name;
+ std::string long_import_name;
+ if (imports.find(unique_name) != imports.end())
+ return imports.find(unique_name)->second.name;
+ for (auto it = imports.begin(); it != imports.end(); it++) {
+ if (it->second.name == import_name) {
+ long_import_name = ns + import_name;
+ break;
+ }
+ }
+ std::string import_statement;
+ import_statement += "import { ";
+ if (long_import_name.empty()) {
+ import_statement += import_name;
+ if (parser_.opts.generate_object_based_api)
+ import_statement += ", " + import_name + "T";
+ } else {
+ import_statement += dependency.name + " as " + long_import_name;
+ if (parser_.opts.generate_object_based_api)
+ import_statement +=
+ ", " + dependency.name + "T as " + long_import_name + "T";
+ }
+ import_statement += " } from '";
+ std::string file_name;
+ const auto &dep_comps = dependent.defined_namespace->components;
+ for (size_t i = 0; i < dep_comps.size(); i++)
+ file_name += i == 0 ? ".." : (kPathSeparator + std::string(".."));
+ if (dep_comps.size() == 0) file_name += ".";
+ for (auto it = depc_comps.begin(); it != depc_comps.end(); it++)
+ file_name += kPathSeparator + ToDasherizedCase(*it);
+ file_name += kPathSeparator + ToDasherizedCase(dependency.name);
+ import_statement += file_name + "';";
+ ImportDefinition import;
+ import.name = long_import_name.empty() ? import_name : long_import_name;
+ import.statement = import_statement;
+ import.dependency = &dependency;
+ import.dependent = &dependent;
+ imports.insert(std::make_pair(unique_name, import));
+ return import.name;
+ }
+
+ // TODO: largely (but not identical) duplicated code from above couln't find a
+ // good way to refactor
+ std::string AddImport(import_set &imports, const Definition &dependent,
+ const EnumDef &dependency) {
+ std::string ns;
+ const auto &depc_comps = dependency.defined_namespace->components;
+ for (auto it = depc_comps.begin(); it != depc_comps.end(); it++) ns += *it;
+ std::string unique_name = ns + dependency.name;
+ std::string import_name = dependency.name;
+ std::string long_import_name;
+ if (imports.find(unique_name) != imports.end())
+ return imports.find(unique_name)->second.name;
+ for (auto it = imports.begin(); it != imports.end(); it++) {
+ if (it->second.name == import_name) {
+ long_import_name = ns + import_name;
+ break;
+ }
+ }
+ std::string import_statement;
+ import_statement += "import { ";
+ if (long_import_name.empty())
+ import_statement += import_name;
+ else
+ import_statement += dependency.name + " as " + long_import_name;
+ if (dependency.is_union) {
+ import_statement += ", unionTo" + import_name;
+ import_statement += ", unionListTo" + import_name;
+ }
+ import_statement += " } from '";
+ std::string file_name;
+ const auto &dep_comps = dependent.defined_namespace->components;
+ for (size_t i = 0; i < dep_comps.size(); i++)
+ file_name += i == 0 ? ".." : (kPathSeparator + std::string(".."));
+ if (dep_comps.size() == 0) file_name += ".";
+ for (auto it = depc_comps.begin(); it != depc_comps.end(); it++)
+ file_name += kPathSeparator + ToDasherizedCase(*it);
+ file_name += kPathSeparator + ToDasherizedCase(dependency.name);
+ import_statement += file_name + "';";
+ ImportDefinition import;
+ import.name = long_import_name.empty() ? import_name : long_import_name;
+ import.statement = import_statement;
+ import.dependency = &dependency;
+ import.dependent = &dependent;
+ imports.insert(std::make_pair(unique_name, import));
+ return import.name;
+ }
+
+ void AddImport(import_set &imports, std::string import_name,
+ std::string fileName) {
+ ImportDefinition import;
+ import.name = import_name;
+ import.statement = "import " + import_name + " from '" + fileName + "';";
+ imports.insert(std::make_pair(import_name, import));
+ }
+
// Generate a TS union type based on a union's enum
- std::string GenObjApiUnionTypeTS(const IDLOptions &opts,
+ std::string GenObjApiUnionTypeTS(import_set &imports, const IDLOptions &opts,
const EnumDef &union_enum) {
std::string ret = "";
std::set<std::string> type_list;
@@ -774,10 +602,8 @@ class JsTsGenerator : public BaseGenerator {
if (IsString(ev.union_type)) {
type = "string"; // no need to wrap string type in namespace
} else if (ev.union_type.base_type == BASE_TYPE_STRUCT) {
- type = GenPrefixedTypeName(
- GetObjApiClassName(WrapInNameSpace(*(ev.union_type.struct_def)),
- opts),
- union_enum.file);
+ type = GetObjApiClassName(
+ AddImport(imports, union_enum, *ev.union_type.struct_def), opts);
} else {
FLATBUFFERS_ASSERT(false);
}
@@ -801,12 +627,11 @@ class JsTsGenerator : public BaseGenerator {
return "unionListTo" + enum_def.name;
}
- std::string GenUnionConvFunc(const Type &union_type,
- imported_fileset &imported_files) {
+ std::string GenUnionConvFunc(const Type &union_type, import_set &imports) {
if (union_type.enum_def) {
const auto &enum_def = *union_type.enum_def;
- const auto valid_union_type = GenUnionTypeTS(enum_def, imported_files);
+ const auto valid_union_type = GenUnionTypeTS(enum_def, imports);
const auto valid_union_type_with_null = valid_union_type + "|null";
auto ret = "\n\nexport function " + GenUnionConvFuncName(enum_def) +
@@ -815,19 +640,13 @@ class JsTsGenerator : public BaseGenerator {
valid_union_type_with_null +
"\n): " + valid_union_type_with_null + " {\n";
- if (!parser_.opts.generate_all) {
- imported_files.insert(union_type.enum_def->file);
- }
-
- const auto enum_type = GenPrefixedTypeName(
- WrapInNameSpace(*(union_type.enum_def)), union_type.enum_def->file);
- const auto &union_enum = *(union_type.enum_def);
+ const auto enum_type = AddImport(imports, enum_def, enum_def);
const auto union_enum_loop = [&](const std::string &accessor_str) {
ret += " switch(" + enum_type + "[type]) {\n";
ret += " case 'NONE': return null; \n";
- for (auto it = union_enum.Vals().begin(); it != union_enum.Vals().end();
+ for (auto it = enum_def.Vals().begin(); it != enum_def.Vals().end();
++it) {
const auto &ev = **it;
if (ev.IsZero()) { continue; }
@@ -837,9 +656,8 @@ class JsTsGenerator : public BaseGenerator {
if (IsString(ev.union_type)) {
ret += "return " + accessor_str + "'') as string;";
} else if (ev.union_type.base_type == BASE_TYPE_STRUCT) {
- const auto type = GenPrefixedTypeName(
- WrapInNameSpace(*(ev.union_type.struct_def)),
- ev.union_type.struct_def->file);
+ const auto type =
+ AddImport(imports, enum_def, *ev.union_type.struct_def);
ret += "return " + accessor_str + "new " + type + "())! as " +
type + ";";
} else {
@@ -872,13 +690,12 @@ class JsTsGenerator : public BaseGenerator {
// Used for generating a short function that returns the correct class
// based on union enum type. Assume the context is inside the non object api
// type
- std::string GenUnionValTS(const std::string &field_name,
+ std::string GenUnionValTS(import_set &imports, const std::string &field_name,
const Type &union_type,
const bool is_array = false) {
if (union_type.enum_def) {
const auto &enum_def = *union_type.enum_def;
- const auto enum_type =
- GenPrefixedTypeName(WrapInNameSpace(enum_def), enum_def.file);
+ const auto enum_type = AddImport(imports, enum_def, enum_def);
const std::string union_accessor = "this." + field_name;
const auto union_has_string = UnionHasStringType(enum_def);
@@ -887,10 +704,7 @@ class JsTsGenerator : public BaseGenerator {
std::string ret;
if (!is_array) {
- const auto conversion_function =
- GenPrefixedTypeName(WrapInNameSpace(enum_def.defined_namespace,
- GenUnionConvFuncName(enum_def)),
- enum_def.file);
+ const auto conversion_function = GenUnionConvFuncName(enum_def);
const auto target_enum = "this." + field_name + "Type()";
ret = "(() => {\n";
@@ -903,10 +717,7 @@ class JsTsGenerator : public BaseGenerator {
ret += " return temp.unpack()\n";
ret += " })()";
} else {
- const auto conversion_function = GenPrefixedTypeName(
- WrapInNameSpace(enum_def.defined_namespace,
- GenUnionListConvFuncName(enum_def)),
- enum_def.file);
+ const auto conversion_function = GenUnionListConvFuncName(enum_def);
const auto target_enum_accesor = "this." + field_name + "Type";
const auto target_enum_length = target_enum_accesor + "Length()";
@@ -940,9 +751,9 @@ class JsTsGenerator : public BaseGenerator {
return "";
}
- static std::string GenNullCheckConditional(const std::string &nullCheckVar,
- const std::string &trueVal,
- const std::string &falseVal = "null") {
+ static std::string GenNullCheckConditional(
+ const std::string &nullCheckVar, const std::string &trueVal,
+ const std::string &falseVal = "null") {
return "(" + nullCheckVar + " !== null ? " + trueVal + " : " + falseVal +
")";
}
@@ -978,20 +789,15 @@ class JsTsGenerator : public BaseGenerator {
void GenObjApi(const Parser &parser, StructDef &struct_def,
std::string &obj_api_unpack_func, std::string &obj_api_class,
- imported_fileset &imported_files) {
+ import_set &imports) {
const auto class_name = GetObjApiClassName(struct_def, parser.opts);
- std::string unpack_func =
- "\n/**\n * " + GenTypeAnnotation(kReturns, class_name, "") +
- " */\nunpack(): " + class_name + " {\n return new " + class_name +
- "(" + (struct_def.fields.vec.empty() ? "" : "\n");
- std::string unpack_to_func =
- "/**\n * " + GenTypeAnnotation(kParam, class_name, "_o") +
- " */\nunpackTo(_o: " + class_name + "): void {" +
- +(struct_def.fields.vec.empty() ? "" : "\n");
-
- std::string constructor_annotation = "/**\n * @constructor";
- constructor_annotation += (struct_def.fields.vec.empty() ? "" : "\n");
+ std::string unpack_func = "\nunpack(): " + class_name +
+ " {\n return new " + class_name + "(" +
+ (struct_def.fields.vec.empty() ? "" : "\n");
+ std::string unpack_to_func = "\nunpackTo(_o: " + class_name + "): void {" +
+ +(struct_def.fields.vec.empty() ? "" : "\n");
+
std::string constructor_func = "constructor(";
constructor_func += (struct_def.fields.vec.empty() ? "" : "\n");
@@ -999,23 +805,20 @@ class JsTsGenerator : public BaseGenerator {
struct_def.fixed || CanCreateFactoryMethod(struct_def);
std::string pack_func_prototype =
- "/**\n * " +
- GenTypeAnnotation(kParam, "flatbuffers.Builder", "builder") + " * " +
- GenTypeAnnotation(kReturns, "flatbuffers.Offset", "") +
- " */\npack(builder:flatbuffers.Builder): flatbuffers.Offset {\n";
+ "\npack(builder:flatbuffers.Builder): flatbuffers.Offset {\n";
std::string pack_func_offset_decl;
std::string pack_func_create_call;
- const auto struct_name =
- GenPrefixedTypeName(WrapInNameSpace(struct_def), struct_def.file);
+ const auto struct_name = AddImport(imports, struct_def, struct_def);
if (has_create) {
pack_func_create_call = " return " + struct_name + ".create" +
- Verbose(struct_def) + "(builder" +
+ GetPrefixedName(struct_def) + "(builder" +
(struct_def.fields.vec.empty() ? "" : ",\n ");
} else {
- pack_func_create_call = " " + struct_name + ".start(builder);\n";
+ pack_func_create_call = " " + struct_name + ".start" +
+ GetPrefixedName(struct_def) + "(builder);\n";
}
if (struct_def.fixed) {
@@ -1044,24 +847,15 @@ class JsTsGenerator : public BaseGenerator {
// the variable name from field_offset_decl
std::string field_offset_val;
const auto field_default_val =
- GenDefaultValue(field, "flatbuffers");
+ GenDefaultValue(field, "flatbuffers", imports);
// Emit a scalar field
const auto is_string = IsString(field.value.type);
if (IsScalar(field.value.type.base_type) || is_string) {
const auto has_null_default = is_string || HasNullDefault(field);
- if (field.value.type.enum_def) {
- if (!parser_.opts.generate_all) {
- imported_files.insert(field.value.type.enum_def->file);
- }
-
- field_type +=
- GenPrefixedTypeName(GenTypeName(field.value.type, false, has_null_default),
- field.value.type.enum_def->file);
- } else {
- field_type += GenTypeName(field.value.type, false, has_null_default);
- }
+ field_type += GenTypeName(imports, field, field.value.type, false,
+ has_null_default);
field_val = "this." + field_name + "()";
if (field.value.type.base_type != BASE_TYPE_STRING) {
@@ -1079,10 +873,7 @@ class JsTsGenerator : public BaseGenerator {
switch (field.value.type.base_type) {
case BASE_TYPE_STRUCT: {
const auto &sd = *field.value.type.struct_def;
- field_type += GenPrefixedTypeName(
- WrapInNameSpace(sd.defined_namespace,
- GetObjApiClassName(sd, parser.opts)),
- field.value.type.struct_def->file);
+ field_type += GetObjApiClassName(sd, parser.opts);
const std::string field_accessor = "this." + field_name + "()";
field_val = GenNullCheckConditional(field_accessor,
@@ -1096,7 +887,8 @@ class JsTsGenerator : public BaseGenerator {
case BASE_TYPE_VECTOR: {
auto vectortype = field.value.type.VectorType();
- auto vectortypename = GenTypeName(vectortype, false);
+ auto vectortypename =
+ GenTypeName(imports, struct_def, vectortype, false);
is_vector = true;
field_type = "(";
@@ -1104,10 +896,7 @@ class JsTsGenerator : public BaseGenerator {
switch (vectortype.base_type) {
case BASE_TYPE_STRUCT: {
const auto &sd = *field.value.type.struct_def;
- field_type += GenPrefixedTypeName(
- WrapInNameSpace(sd.defined_namespace,
- GetObjApiClassName(sd, parser.opts)),
- field.value.type.struct_def->file);
+ field_type += GetObjApiClassName(sd, parser.opts);
field_type += ")[]";
field_val = GenBBAccess() + ".createObjList(" +
@@ -1117,15 +906,12 @@ class JsTsGenerator : public BaseGenerator {
if (sd.fixed) {
field_offset_decl =
"builder.createStructOffsetList(this." + field_name +
- ", " +
- GenPrefixedTypeName(WrapInNameSpace(struct_def),
- struct_def.file) +
+ ", " + AddImport(imports, struct_def, struct_def) +
".start" + MakeCamel(field_name) + "Vector)";
} else {
field_offset_decl =
- GenPrefixedTypeName(WrapInNameSpace(struct_def),
- struct_def.file) +
- ".create" + MakeCamel(field_name) +
+ AddImport(imports, struct_def, struct_def) + ".create" +
+ MakeCamel(field_name) +
"Vector(builder, builder.createObjectOffsetList(" +
"this." + field_name + "))";
}
@@ -1135,28 +921,27 @@ class JsTsGenerator : public BaseGenerator {
case BASE_TYPE_STRING: {
field_type += "string)[]";
- field_val = GenBBAccess() + ".createStringList(" +
+ field_val = GenBBAccess() + ".createScalarList(" +
field_binded_method + ", this." + field_name +
"Length())";
field_offset_decl =
- GenPrefixedTypeName(WrapInNameSpace(struct_def),
- struct_def.file) +
- ".create" + MakeCamel(field_name) +
+ AddImport(imports, struct_def, struct_def) + ".create" +
+ MakeCamel(field_name) +
"Vector(builder, builder.createObjectOffsetList(" +
"this." + field_name + "))";
break;
}
case BASE_TYPE_UNION: {
- field_type +=
- GenObjApiUnionTypeTS(parser.opts, *(vectortype.enum_def));
+ field_type += GenObjApiUnionTypeTS(imports, parser.opts,
+ *(vectortype.enum_def));
field_type += ")[]";
- field_val = GenUnionValTS(field_name, vectortype, true);
+ field_val =
+ GenUnionValTS(imports, field_name, vectortype, true);
field_offset_decl =
- GenPrefixedTypeName(WrapInNameSpace(struct_def),
- struct_def.file) +
- ".create" + MakeCamel(field_name) +
+ AddImport(imports, struct_def, struct_def) + ".create" +
+ MakeCamel(field_name) +
"Vector(builder, builder.createObjectOffsetList(" +
"this." + field_name + "))";
@@ -1164,13 +949,8 @@ class JsTsGenerator : public BaseGenerator {
}
default: {
if (vectortype.enum_def) {
- if (!parser_.opts.generate_all) {
- imported_files.insert(vectortype.enum_def->file);
- }
-
- field_type +=
- GenPrefixedTypeName(GenTypeName(vectortype, false, HasNullDefault(field)),
- vectortype.enum_def->file);
+ field_type += GenTypeName(imports, struct_def, vectortype,
+ false, HasNullDefault(field));
} else {
field_type += vectortypename;
}
@@ -1179,11 +959,9 @@ class JsTsGenerator : public BaseGenerator {
field_binded_method + ", this." + field_name +
"Length())";
- field_offset_decl =
- GenPrefixedTypeName(WrapInNameSpace(struct_def),
- struct_def.file) +
- ".create" + MakeCamel(field_name) +
- "Vector(builder, this." + field_name + ")";
+ field_offset_decl = AddImport(imports, struct_def, struct_def) +
+ ".create" + MakeCamel(field_name) +
+ "Vector(builder, this." + field_name + ")";
break;
}
@@ -1193,14 +971,10 @@ class JsTsGenerator : public BaseGenerator {
}
case BASE_TYPE_UNION: {
- if (!parser_.opts.generate_all) {
- imported_files.insert(field.value.type.enum_def->file);
- }
-
- field_type +=
- GenObjApiUnionTypeTS(parser.opts, *(field.value.type.enum_def));
+ field_type += GenObjApiUnionTypeTS(imports, parser.opts,
+ *(field.value.type.enum_def));
- field_val = GenUnionValTS(field_name, field.value.type);
+ field_val = GenUnionValTS(imports, field_name, field.value.type);
field_offset_decl =
"builder.createObjectOffset(this." + field_name + ")";
break;
@@ -1222,8 +996,6 @@ class JsTsGenerator : public BaseGenerator {
unpack_func += " " + field_val;
unpack_to_func += " _o." + field_name + " = " + field_val + ";";
- constructor_annotation +=
- " * " + GenTypeAnnotation(kParam, field_type, field_name, false);
constructor_func += " public " + field_name + ": " + field_type + " = " +
field_default_val;
@@ -1242,7 +1014,6 @@ class JsTsGenerator : public BaseGenerator {
}
if (std::next(it) != struct_def.fields.vec.end()) {
- constructor_annotation += "\n";
constructor_func += ",\n";
if (!struct_def.fixed && has_create) {
@@ -1263,27 +1034,26 @@ class JsTsGenerator : public BaseGenerator {
}
}
- constructor_annotation += "\n */\n";
- constructor_func += "){};\n\n";
+ constructor_func += "){}\n\n";
if (has_create) {
pack_func_create_call += ");";
} else {
- pack_func_create_call += "return " + struct_name + ".end(builder);";
+ pack_func_create_call += "return " + struct_name + ".end" +
+ GetPrefixedName(struct_def) + "(builder);";
}
obj_api_class = "\nexport class " +
GetObjApiClassName(struct_def, parser.opts) + " {\n";
- obj_api_class += constructor_annotation + constructor_func;
-
+ obj_api_class += constructor_func;
obj_api_class += pack_func_prototype + pack_func_offset_decl +
- pack_func_create_call + "\n};";
+ pack_func_create_call + "\n}";
obj_api_class += "\n}\n";
- unpack_func += ");\n};";
- unpack_to_func += "};\n";
+ unpack_func += ");\n}";
+ unpack_to_func += "}\n";
obj_api_unpack_func = unpack_func + "\n\n" + unpack_to_func;
}
@@ -1302,88 +1072,29 @@ class JsTsGenerator : public BaseGenerator {
// Generate an accessor struct with constructor for a flatbuffers struct.
void GenStruct(const Parser &parser, StructDef &struct_def,
- std::string *code_ptr, std::string *exports_ptr,
- imported_fileset &imported_files) {
+ std::string *code_ptr, import_set &imports) {
if (struct_def.generated) return;
std::string &code = *code_ptr;
- std::string &exports = *exports_ptr;
std::string object_name;
std::string object_namespace = GetNameSpace(struct_def);
// Emit constructor
- if (lang_.language == IDLOptions::kTs) {
- object_name = struct_def.name;
- GenDocComment(struct_def.doc_comment, code_ptr, "@constructor");
- if (!object_namespace.empty()) {
- code += "export namespace " + object_namespace + "{\n";
- }
- code += "export class " + struct_def.name;
- code += " {\n";
- if (lang_.language != IDLOptions::kTs) {
- code += " /**\n";
- code +=
- " * " + GenTypeAnnotation(kType, "flatbuffers.ByteBuffer", "");
- code += " */\n";
- }
- code += " bb: flatbuffers.ByteBuffer|null = null;\n";
- code += "\n";
- if (lang_.language != IDLOptions::kTs) {
- code += " /**\n";
- code += " * " + GenTypeAnnotation(kType, "number", "");
- code += " */\n";
- }
- code += " bb_pos:number = 0;\n";
- } else {
- bool isStatement = struct_def.defined_namespace->components.empty();
- object_name = WrapInNameSpace(struct_def);
- GenDocComment(struct_def.doc_comment, code_ptr, "@constructor");
- if (isStatement) {
- if (parser_.opts.use_goog_js_export_format) {
- exports += "goog.exportSymbol('" + struct_def.name + "', " +
- struct_def.name + ");\n";
- } else if (parser_.opts.use_ES6_js_export_format) {
- exports += "export {" + struct_def.name + "};\n";
- } else {
- exports +=
- "this." + struct_def.name + " = " + struct_def.name + ";\n";
- }
- code += "function " + object_name;
- } else {
- code += object_name + " = function";
- }
- code += "() {\n";
- code += " /**\n";
- code += " * " + GenTypeAnnotation(kType, "flatbuffers.ByteBuffer", "");
- code += " */\n";
- code += " this.bb = null;\n";
- code += "\n";
- code += " /**\n";
- code += " * " + GenTypeAnnotation(kType, "number", "");
- code += " */\n";
- code += " this.bb_pos = 0;\n";
- code += isStatement ? "}\n\n" : "};\n\n";
- }
+ object_name = struct_def.name;
+ GenDocComment(struct_def.doc_comment, code_ptr);
+ code += "export class " + struct_def.name;
+ code += " {\n";
+ code += " bb: flatbuffers.ByteBuffer|null = null;\n";
+ code += " bb_pos = 0;\n";
// Generate the __init method that sets the field in a pre-existing
// accessor object. This is to allow object reuse.
- code += "/**\n";
- code += " * " + GenTypeAnnotation(kParam, "number", "i");
- code += " * " + GenTypeAnnotation(kParam, "flatbuffers.ByteBuffer", "bb");
- code += " * " + GenTypeAnnotation(kReturns, object_name, "");
- code += " */\n";
-
- if (lang_.language == IDLOptions::kTs) {
- code +=
- "__init(i:number, bb:flatbuffers.ByteBuffer):" + object_name + " {\n";
- } else {
- code += object_name + ".prototype.__init = function(i, bb) {\n";
- }
-
+ code +=
+ "__init(i:number, bb:flatbuffers.ByteBuffer):" + object_name + " {\n";
code += " this.bb_pos = i;\n";
code += " this.bb = bb;\n";
code += " return this;\n";
- code += "};\n\n";
+ code += "}\n\n";
// Generate special accessors for the table that when used as the root of a
// FlatBuffer
@@ -1393,19 +1104,12 @@ class JsTsGenerator : public BaseGenerator {
// Generate the identifier check method
if (!struct_def.fixed && parser_.root_struct_def_ == &struct_def &&
!parser_.file_identifier_.empty()) {
- GenDocComment(code_ptr,
- GenTypeAnnotation(kParam, "flatbuffers.ByteBuffer", "bb") +
- GenTypeAnnotation(kReturns, "boolean", "", false));
- if (lang_.language == IDLOptions::kTs) {
- code +=
- "static bufferHasIdentifier(bb:flatbuffers.ByteBuffer):boolean "
- "{\n";
- } else {
- code += object_name + ".bufferHasIdentifier = function(bb) {\n";
- }
-
+ GenDocComment(code_ptr);
+ code +=
+ "static bufferHasIdentifier(bb:flatbuffers.ByteBuffer):boolean "
+ "{\n";
code += " return bb.__has_identifier('" + parser_.file_identifier_;
- code += "');\n};\n\n";
+ code += "');\n}\n\n";
}
// Emit field accessors
@@ -1414,7 +1118,7 @@ class JsTsGenerator : public BaseGenerator {
auto &field = **it;
if (field.deprecated) continue;
auto offset_prefix =
- " var offset = " + GenBBAccess() + ".__offset(this.bb_pos, " +
+ " const offset = " + GenBBAccess() + ".__offset(this.bb_pos, " +
NumToString(field.value.offset) + ");\n return offset ? ";
// Emit a scalar field
@@ -1422,45 +1126,28 @@ class JsTsGenerator : public BaseGenerator {
if (IsScalar(field.value.type.base_type) || is_string) {
const auto has_null_default = is_string || HasNullDefault(field);
- GenDocComment(
- field.doc_comment, code_ptr,
- std::string(is_string
- ? GenTypeAnnotation(kParam, "flatbuffers.Encoding=",
- "optionalEncoding")
- : "") +
- GenTypeAnnotation(kReturns,
- GenTypeName(field.value.type, false, has_null_default),
- "", false));
- if (lang_.language == IDLOptions::kTs) {
- std::string prefix = MakeCamel(field.name, false) + "(";
- if (is_string) {
- code += prefix + "):string|null\n";
- code += prefix + "optionalEncoding:flatbuffers.Encoding" +
- "):" + GenTypeName(field.value.type, false, true) + "\n";
- code += prefix + "optionalEncoding?:any";
- } else {
- code += prefix;
- }
- if (field.value.type.enum_def) {
- code +=
- "):" +
- GenPrefixedTypeName(GenTypeName(field.value.type, false, field.optional),
- field.value.type.enum_def->file) +
- " {\n";
-
- if (!parser_.opts.generate_all) {
- imported_files.insert(field.value.type.enum_def->file);
- }
- } else {
- code += "):" + GenTypeName(field.value.type, false, has_null_default) + " {\n";
- }
+ GenDocComment(field.doc_comment, code_ptr);
+ std::string prefix = MakeCamel(field.name, false) + "(";
+ if (is_string) {
+ code += prefix + "):string|null\n";
+ code +=
+ prefix + "optionalEncoding:flatbuffers.Encoding" + "):" +
+ GenTypeName(imports, struct_def, field.value.type, false, true) +
+ "\n";
+ code += prefix + "optionalEncoding?:any";
} else {
- code += object_name + ".prototype." + MakeCamel(field.name, false);
- code += " = function(";
- if (is_string) {
- code += "optionalEncoding";
- }
- code += ") {\n";
+ code += prefix;
+ }
+ if (field.value.type.enum_def) {
+ code += "):" +
+ GenTypeName(imports, struct_def, field.value.type, false,
+ field.optional) +
+ " {\n";
+ } else {
+ code += "):" +
+ GenTypeName(imports, struct_def, field.value.type, false,
+ has_null_default) +
+ " {\n";
}
if (struct_def.fixed) {
@@ -1471,12 +1158,10 @@ class JsTsGenerator : public BaseGenerator {
";\n";
} else {
std::string index = "this.bb_pos + offset";
- if (is_string) {
- index += ", optionalEncoding";
- }
+ if (is_string) { index += ", optionalEncoding"; }
code += offset_prefix +
GenGetter(field.value.type, "(" + index + ")") + " : " +
- GenDefaultValue(field, GenBBAccess());
+ GenDefaultValue(field, GenBBAccess(), imports);
code += ";\n";
}
}
@@ -1485,21 +1170,12 @@ class JsTsGenerator : public BaseGenerator {
else {
switch (field.value.type.base_type) {
case BASE_TYPE_STRUCT: {
- auto type = WrapInNameSpace(*field.value.type.struct_def);
- GenDocComment(
- field.doc_comment, code_ptr,
- GenTypeAnnotation(kParam, type + "=", "obj") +
- GenTypeAnnotation(kReturns, type + "|null", "", false));
- if (lang_.language == IDLOptions::kTs) {
- type =
- GenPrefixedTypeName(type, field.value.type.struct_def->file);
- code += MakeCamel(field.name, false);
- code += "(obj?:" + type + "):" + type + "|null {\n";
- } else {
- code +=
- object_name + ".prototype." + MakeCamel(field.name, false);
- code += " = function(obj) {\n";
- }
+ auto type =
+ AddImport(imports, struct_def, *field.value.type.struct_def);
+ GenDocComment(field.doc_comment, code_ptr);
+ type = GenPrefixedTypeName(type, field.value.type.struct_def->file);
+ code += MakeCamel(field.name, false);
+ code += "(obj?:" + type + "):" + type + "|null {\n";
if (struct_def.fixed) {
code += " return (obj || " + GenerateNewExpression(type);
@@ -1515,92 +1191,51 @@ class JsTsGenerator : public BaseGenerator {
code += ", " + GenBBAccess() + ") : null;\n";
}
- if (lang_.language == IDLOptions::kTs &&
- !parser_.opts.generate_all) {
- imported_files.insert(field.value.type.struct_def->file);
- }
-
break;
}
case BASE_TYPE_VECTOR: {
auto vectortype = field.value.type.VectorType();
- auto vectortypename = GenTypeName(vectortype, false);
-
- if (vectortype.enum_def) {
- vectortypename = GenPrefixedTypeName(vectortypename,
- vectortype.enum_def->file);
- }
-
+ auto vectortypename =
+ GenTypeName(imports, struct_def, vectortype, false);
auto inline_size = InlineSize(vectortype);
auto index = GenBBAccess() +
".__vector(this.bb_pos + offset) + index" +
MaybeScale(inline_size);
- std::string args = GenTypeAnnotation(kParam, "number", "index");
std::string ret_type;
bool is_union = false;
switch (vectortype.base_type) {
- case BASE_TYPE_STRUCT:
- args += GenTypeAnnotation(kParam, vectortypename + "=", "obj");
- ret_type = vectortypename;
- break;
- case BASE_TYPE_STRING:
- args += GenTypeAnnotation(
- kParam, "flatbuffers.Encoding=", "optionalEncoding");
- ret_type = vectortypename;
- break;
+ case BASE_TYPE_STRUCT: ret_type = vectortypename; break;
+ case BASE_TYPE_STRING: ret_type = vectortypename; break;
case BASE_TYPE_UNION:
- args += GenTypeAnnotation(kParam, "flatbuffers.Table=", "obj");
ret_type = "?flatbuffers.Table";
is_union = true;
break;
default: ret_type = vectortypename;
}
- GenDocComment(
- field.doc_comment, code_ptr,
- args + GenTypeAnnotation(kReturns, ret_type, "", false));
- if (lang_.language == IDLOptions::kTs) {
- std::string prefix = MakeCamel(field.name, false);
- if (is_union) { prefix += "<T extends flatbuffers.Table>"; }
- prefix += "(index: number";
- if (is_union) {
- const auto union_type =
- GenUnionGenericTypeTS(*(field.value.type.enum_def));
-
- vectortypename = union_type;
- code += prefix + ", obj:" + union_type;
- } else if (vectortype.base_type == BASE_TYPE_STRUCT) {
- vectortypename = GenPrefixedTypeName(
- vectortypename, vectortype.struct_def->file);
- code += prefix + ", obj?:" + vectortypename;
-
- if (!parser_.opts.generate_all) {
- imported_files.insert(vectortype.struct_def->file);
- }
- } else if (IsString(vectortype)) {
- code += prefix + "):string\n";
- code += prefix + ",optionalEncoding:flatbuffers.Encoding" +
- "):" + vectortypename + "\n";
- code += prefix + ",optionalEncoding?:any";
- } else {
- code += prefix;
-
- if (vectortype.enum_def && !parser_.opts.generate_all) {
- imported_files.insert(vectortype.enum_def->file);
- }
- }
- code += "):" + vectortypename + "|null {\n";
+ GenDocComment(field.doc_comment, code_ptr);
+ std::string prefix = MakeCamel(field.name, false);
+ // TODO: make it work without any
+ // if (is_union) { prefix += "<T extends flatbuffers.Table>"; }
+ if (is_union) { prefix += ""; }
+ prefix += "(index: number";
+ if (is_union) {
+ const auto union_type =
+ GenUnionGenericTypeTS(*(field.value.type.enum_def));
+
+ vectortypename = union_type;
+ code += prefix + ", obj:" + union_type;
+ } else if (vectortype.base_type == BASE_TYPE_STRUCT) {
+ code += prefix + ", obj?:" + vectortypename;
+ } else if (IsString(vectortype)) {
+ code += prefix + "):string\n";
+ code += prefix + ",optionalEncoding:flatbuffers.Encoding" +
+ "):" + vectortypename + "\n";
+ code += prefix + ",optionalEncoding?:any";
} else {
- code +=
- object_name + ".prototype." + MakeCamel(field.name, false);
- code += " = function(index";
- if (vectortype.base_type == BASE_TYPE_STRUCT || is_union) {
- code += ", obj";
- } else if (IsString(vectortype)) {
- code += ", optionalEncoding";
- }
- code += ") {\n";
+ code += prefix;
}
+ code += "):" + vectortypename + "|null {\n";
if (vectortype.base_type == BASE_TYPE_STRUCT) {
code += offset_prefix + "(obj || " +
@@ -1626,11 +1261,7 @@ class JsTsGenerator : public BaseGenerator {
code += GenBBAccess() + ".createLong(0, 0)";
} else if (IsScalar(field.value.type.element)) {
if (field.value.type.enum_def) {
- code += "/** " +
- GenTypeAnnotation(
- kType, WrapInNameSpace(*field.value.type.enum_def),
- "", false) +
- " */ (" + field.value.constant + ")";
+ code += field.value.constant;
} else {
code += "0";
}
@@ -1641,77 +1272,41 @@ class JsTsGenerator : public BaseGenerator {
break;
}
- case BASE_TYPE_UNION:
- GenDocComment(
- field.doc_comment, code_ptr,
- GenTypeAnnotation(kParam, "flatbuffers.Table", "obj") +
- GenTypeAnnotation(kReturns, "?flatbuffers.Table", "",
- false));
- if (lang_.language == IDLOptions::kTs) {
- code += MakeCamel(field.name, false);
-
- const auto &union_enum = *(field.value.type.enum_def);
- const auto union_type = GenUnionGenericTypeTS(union_enum);
- code += "<T extends flatbuffers.Table>(obj:" + union_type +
- "):" + union_type +
- "|null "
- "{\n";
- } else {
- code +=
- object_name + ".prototype." + MakeCamel(field.name, false);
- code += " = function(obj) {\n";
- }
+ case BASE_TYPE_UNION: {
+ GenDocComment(field.doc_comment, code_ptr);
+ code += MakeCamel(field.name, false);
+
+ const auto &union_enum = *(field.value.type.enum_def);
+ const auto union_type = GenUnionGenericTypeTS(union_enum);
+ code += "<T extends flatbuffers.Table>(obj:" + union_type +
+ "):" + union_type +
+ "|null "
+ "{\n";
code += offset_prefix +
GenGetter(field.value.type, "(obj, this.bb_pos + offset)") +
" : null;\n";
break;
-
+ }
default: FLATBUFFERS_ASSERT(0);
}
}
- code += "};\n\n";
-
- if (parser_.opts.use_goog_js_export_format) {
- exports += "goog.exportProperty(" + object_name + ".prototype, '" +
- MakeCamel(field.name, false) + "', " + object_name +
- ".prototype." + MakeCamel(field.name, false) + ");\n";
- }
+ code += "}\n\n";
// Adds the mutable scalar value to the output
if (IsScalar(field.value.type.base_type) && parser.opts.mutable_buffer &&
!IsUnion(field.value.type)) {
- std::string annotations = GenTypeAnnotation(
- kParam, GenTypeName(field.value.type, true), "value");
- GenDocComment(
- code_ptr,
- annotations + GenTypeAnnotation(kReturns, "boolean", "", false));
-
- if (lang_.language == IDLOptions::kTs) {
- std::string type;
- if (field.value.type.enum_def) {
- if (!parser_.opts.generate_all) {
- imported_files.insert(field.value.type.enum_def->file);
- }
+ std::string type =
+ GenTypeName(imports, struct_def, field.value.type, true);
- type = GenPrefixedTypeName(GenTypeName(field.value.type, true),
- field.value.type.enum_def->file);
- } else {
- type = GenTypeName(field.value.type, true);
- }
-
- code += "mutate_" + field.name + "(value:" + type + "):boolean {\n";
- } else {
- code += object_name + ".prototype.mutate_" + field.name +
- " = function(value) {\n";
- }
+ code += "mutate_" + field.name + "(value:" + type + "):boolean {\n";
if (struct_def.fixed) {
code += " " + GenBBAccess() + ".write" +
MakeCamel(GenType(field.value.type)) + "(this.bb_pos + " +
NumToString(field.value.offset) + ", ";
} else {
- code += " var offset = " + GenBBAccess() +
+ code += " const offset = " + GenBBAccess() +
".__offset(this.bb_pos, " + NumToString(field.value.offset) +
");\n\n";
code += " if (offset === 0) {\n";
@@ -1722,140 +1317,80 @@ class JsTsGenerator : public BaseGenerator {
code += " " + GenBBAccess() + ".write" +
MakeCamel(GenType(field.value.type)) +
"(this.bb_pos + offset, ";
- if (field.value.type.base_type == BASE_TYPE_BOOL &&
- lang_.language == IDLOptions::kTs) {
- code += "+";
- }
+ if (field.value.type.base_type == BASE_TYPE_BOOL) { code += "+"; }
}
code += "value);\n";
code += " return true;\n";
- code += "};\n\n";
-
- if (parser_.opts.use_goog_js_export_format) {
- exports += "goog.exportProperty(" + object_name +
- ".prototype, 'mutate_" + field.name + "', " + object_name +
- ".prototype.mutate_" + field.name + ");\n";
- }
+ code += "}\n\n";
}
// Emit vector helpers
if (IsVector(field.value.type)) {
// Emit a length helper
- GenDocComment(code_ptr,
- GenTypeAnnotation(kReturns, "number", "", false));
- if (lang_.language == IDLOptions::kTs) {
- code += MakeCamel(field.name, false);
- code += "Length():number {\n" + offset_prefix;
- } else {
- code += object_name + ".prototype." + MakeCamel(field.name, false);
- code += "Length = function() {\n" + offset_prefix;
- }
+ GenDocComment(code_ptr);
+ code += MakeCamel(field.name, false);
+ code += "Length():number {\n" + offset_prefix;
code +=
- GenBBAccess() + ".__vector_len(this.bb_pos + offset) : 0;\n};\n\n";
-
- if (parser_.opts.use_goog_js_export_format) {
- exports += "goog.exportProperty(" + object_name + ".prototype, '" +
- MakeCamel(field.name, false) + "Length', " + object_name +
- ".prototype." + MakeCamel(field.name, false) +
- "Length);\n";
- }
+ GenBBAccess() + ".__vector_len(this.bb_pos + offset) : 0;\n}\n\n";
// For scalar types, emit a typed array helper
auto vectorType = field.value.type.VectorType();
if (IsScalar(vectorType.base_type) && !IsLong(vectorType.base_type)) {
- GenDocComment(code_ptr, GenTypeAnnotation(
- kReturns, GenType(vectorType) + "Array",
- "", false));
+ GenDocComment(code_ptr);
- if (lang_.language == IDLOptions::kTs) {
- code += MakeCamel(field.name, false);
- code += "Array():" + GenType(vectorType) + "Array|null {\n" +
- offset_prefix;
- } else {
- code += object_name + ".prototype." + MakeCamel(field.name, false);
- code += "Array = function() {\n" + offset_prefix;
- }
+ code += MakeCamel(field.name, false);
+ code += "Array():" + GenType(vectorType) + "Array|null {\n" +
+ offset_prefix;
code += "new " + GenType(vectorType) + "Array(" + GenBBAccess() +
".bytes().buffer, " + GenBBAccess() +
".bytes().byteOffset + " + GenBBAccess() +
".__vector(this.bb_pos + offset), " + GenBBAccess() +
- ".__vector_len(this.bb_pos + offset)) : null;\n};\n\n";
-
- if (parser_.opts.use_goog_js_export_format) {
- exports += "goog.exportProperty(" + object_name + ".prototype, '" +
- MakeCamel(field.name, false) + "Array', " + object_name +
- ".prototype." + MakeCamel(field.name, false) +
- "Array);\n";
- }
+ ".__vector_len(this.bb_pos + offset)) : null;\n}\n\n";
}
}
}
// Emit the fully qualified name
if (parser_.opts.generate_name_strings) {
- GenDocComment(code_ptr, GenTypeAnnotation(kReturns, "string", "", false));
- if (lang_.language == IDLOptions::kTs) {
- code += "static getFullyQualifiedName():string {\n";
- } else {
- code += object_name + ".getFullyQualifiedName = function() {\n";
- }
+ GenDocComment(code_ptr);
+ code += "static getFullyQualifiedName():string {\n";
code += " return '" + WrapInNameSpace(struct_def) + "';\n";
code += "}\n\n";
}
// Emit the size of the struct.
if (struct_def.fixed) {
- GenDocComment(code_ptr, GenTypeAnnotation(kReturns, "number", "", false));
- if (lang_.language == IDLOptions::kTs) {
- code += "static sizeOf():number {\n";
- } else {
- code += object_name + ".sizeOf = function() {\n";
- }
+ GenDocComment(code_ptr);
+ code += "static sizeOf():number {\n";
code += " return " + NumToString(struct_def.bytesize) + ";\n";
code += "}\n\n";
}
// Emit a factory constructor
if (struct_def.fixed) {
- std::string annotations =
- GenTypeAnnotation(kParam, "flatbuffers.Builder", "builder");
std::string arguments;
- GenStructArgs(struct_def, &annotations, &arguments, "");
- GenDocComment(code_ptr, annotations + GenTypeAnnotation(
- kReturns, "flatbuffers.Offset",
- "", false));
-
- if (lang_.language == IDLOptions::kTs) {
- code += "static create" + Verbose(struct_def) +
- "(builder:flatbuffers.Builder";
- code += arguments + "):flatbuffers.Offset {\n";
- } else {
- code += object_name + ".create" + Verbose(struct_def);
- code += " = function(builder";
- code += arguments + ") {\n";
- }
+ GenStructArgs(imports, struct_def, &arguments, "");
+ GenDocComment(code_ptr);
+
+ code += "static create" + GetPrefixedName(struct_def) +
+ "(builder:flatbuffers.Builder";
+ code += arguments + "):flatbuffers.Offset {\n";
GenStructBody(struct_def, &code, "");
- code += " return builder.offset();\n};\n\n";
+ code += " return builder.offset();\n}\n\n";
} else {
// Generate a method to start building a new object
- GenDocComment(code_ptr, GenTypeAnnotation(kParam, "flatbuffers.Builder",
- "builder", false));
+ GenDocComment(code_ptr);
- if (lang_.language == IDLOptions::kTs) {
- code += "static start" + Verbose(struct_def) +
- "(builder:flatbuffers.Builder) {\n";
- } else {
- code += object_name + ".start" + Verbose(struct_def);
- code += " = function(builder) {\n";
- }
+ code += "static start" + GetPrefixedName(struct_def) +
+ "(builder:flatbuffers.Builder) {\n";
code += " builder.startObject(" +
NumToString(struct_def.fields.vec.size()) + ");\n";
- code += "};\n\n";
+ code += "}\n\n";
// Generate a set of static methods that allow table construction
for (auto it = struct_def.fields.vec.begin();
@@ -1865,21 +1400,10 @@ class JsTsGenerator : public BaseGenerator {
const auto argname = GetArgName(field);
// Generate the field insertion method
- GenDocComment(
- code_ptr,
- GenTypeAnnotation(kParam, "flatbuffers.Builder", "builder") +
- GenTypeAnnotation(kParam, GenTypeName(field.value.type, true),
- argname, false));
-
- if (lang_.language == IDLOptions::kTs) {
- code += "static add" + MakeCamel(field.name);
- code += "(builder:flatbuffers.Builder, " + argname + ":" +
- GetArgType(field, false) + ") {\n";
- } else {
- code += object_name + ".add" + MakeCamel(field.name);
- code += " = function(builder, " + argname + ") {\n";
- }
-
+ GenDocComment(code_ptr);
+ code += "static add" + MakeCamel(field.name);
+ code += "(builder:flatbuffers.Builder, " + argname + ":" +
+ GetArgType(imports, struct_def, field, false) + ") {\n";
code += " builder.addField" + GenWriteMethod(field.value.type) + "(";
code += NumToString(it - struct_def.fields.vec.begin()) + ", ";
if (field.value.type.base_type == BASE_TYPE_BOOL) { code += "+"; }
@@ -1894,9 +1418,9 @@ class JsTsGenerator : public BaseGenerator {
}
} else {
if (field.value.type.base_type == BASE_TYPE_BOOL) { code += "+"; }
- code += GenDefaultValue(field, "builder");
+ code += GenDefaultValue(field, "builder", imports);
}
- code += ");\n};\n\n";
+ code += ");\n}\n\n";
if (IsVector(field.value.type)) {
auto vector_type = field.value.type.VectorType();
@@ -1905,165 +1429,95 @@ class JsTsGenerator : public BaseGenerator {
// Generate a method to create a vector from a JavaScript array
if (!IsStruct(vector_type)) {
- GenDocComment(
- code_ptr,
- GenTypeAnnotation(kParam, "flatbuffers.Builder", "builder") +
- GenTypeAnnotation(
- kParam,
- "Array.<" + GenTypeName(vector_type, true) + ">",
- "data") +
- GenTypeAnnotation(kReturns, "flatbuffers.Offset", "",
- false));
-
- if (lang_.language == IDLOptions::kTs) {
- const std::string sig_begin =
- "static create" + MakeCamel(field.name) +
- "Vector(builder:flatbuffers.Builder, data:";
- const std::string sig_end = "):flatbuffers.Offset";
- std::string type = GenTypeName(vector_type, true) + "[]";
- if (type == "number[]") {
- const auto &array_type = GenType(vector_type);
- // the old type should be deprecated in the future
- std::string type_old = "number[]|Uint8Array";
- std::string type_new = "number[]|" + array_type + "Array";
- if (type_old == type_new) {
- type = type_new;
- } else {
- // add function overloads
- code += sig_begin + type_new + sig_end + ";\n";
- code +=
- "/**\n * @deprecated This Uint8Array overload will "
- "be removed in the future.\n */\n";
- code += sig_begin + type_old + sig_end + ";\n";
- type = type_new + "|Uint8Array";
- }
+ GenDocComment(code_ptr);
+
+ const std::string sig_begin =
+ "static create" + MakeCamel(field.name) +
+ "Vector(builder:flatbuffers.Builder, data:";
+ const std::string sig_end = "):flatbuffers.Offset";
+ std::string type =
+ GenTypeName(imports, struct_def, vector_type, true) + "[]";
+ if (type == "number[]") {
+ const auto &array_type = GenType(vector_type);
+ // the old type should be deprecated in the future
+ std::string type_old = "number[]|Uint8Array";
+ std::string type_new = "number[]|" + array_type + "Array";
+ if (type_old == type_new) {
+ type = type_new;
} else {
- if (vector_type.enum_def) {
- if (!parser_.opts.generate_all) {
- imported_files.insert(vector_type.enum_def->file);
- }
-
- type = GenPrefixedTypeName(type, vector_type.enum_def->file);
- }
+ // add function overloads
+ code += sig_begin + type_new + sig_end + ";\n";
+ code +=
+ "/**\n * @deprecated This Uint8Array overload will "
+ "be removed in the future.\n */\n";
+ code += sig_begin + type_old + sig_end + ";\n";
+ type = type_new + "|Uint8Array";
}
- code += sig_begin + type + sig_end + " {\n";
- } else {
- code += object_name + ".create" + MakeCamel(field.name);
- code += "Vector = function(builder, data) {\n";
}
-
+ code += sig_begin + type + sig_end + " {\n";
code += " builder.startVector(" + NumToString(elem_size);
code += ", data.length, " + NumToString(alignment) + ");\n";
- code += " for (var i = data.length - 1; i >= 0; i--) {\n";
+ code += " for (let i = data.length - 1; i >= 0; i--) {\n";
code += " builder.add" + GenWriteMethod(vector_type) + "(";
if (vector_type.base_type == BASE_TYPE_BOOL) { code += "+"; }
code += "data[i]);\n";
code += " }\n";
code += " return builder.endVector();\n";
- code += "};\n\n";
+ code += "}\n\n";
}
// Generate a method to start a vector, data to be added manually
// after
- GenDocComment(
- code_ptr,
- GenTypeAnnotation(kParam, "flatbuffers.Builder", "builder") +
- GenTypeAnnotation(kParam, "number", "numElems", false));
-
- if (lang_.language == IDLOptions::kTs) {
- code += "static start" + MakeCamel(field.name);
- code += "Vector(builder:flatbuffers.Builder, numElems:number) {\n";
- } else {
- code += object_name + ".start" + MakeCamel(field.name);
- code += "Vector = function(builder, numElems) {\n";
- }
+ GenDocComment(code_ptr);
+ code += "static start" + MakeCamel(field.name);
+ code += "Vector(builder:flatbuffers.Builder, numElems:number) {\n";
code += " builder.startVector(" + NumToString(elem_size);
code += ", numElems, " + NumToString(alignment) + ");\n";
- code += "};\n\n";
+ code += "}\n\n";
}
}
// Generate a method to stop building a new object
- GenDocComment(
- code_ptr,
- GenTypeAnnotation(kParam, "flatbuffers.Builder", "builder") +
- GenTypeAnnotation(kReturns, "flatbuffers.Offset", "", false));
-
- if (lang_.language == IDLOptions::kTs) {
- code += "static end" + Verbose(struct_def);
- code += "(builder:flatbuffers.Builder):flatbuffers.Offset {\n";
- } else {
- code += object_name + ".end" + Verbose(struct_def);
- code += " = function(builder) {\n";
- }
+ GenDocComment(code_ptr);
+
+ code += "static end" + GetPrefixedName(struct_def);
+ code += "(builder:flatbuffers.Builder):flatbuffers.Offset {\n";
- code += " var offset = builder.endObject();\n";
+ code += " const offset = builder.endObject();\n";
for (auto it = struct_def.fields.vec.begin();
it != struct_def.fields.vec.end(); ++it) {
auto &field = **it;
if (!field.deprecated && field.required) {
code += " builder.requiredField(offset, ";
code += NumToString(field.value.offset);
- code += "); // " + field.name + "\n";
+ code += ") // " + field.name + "\n";
}
}
code += " return offset;\n";
- code += "};\n\n";
+ code += "}\n\n";
// Generate the methods to complete buffer construction
- GenerateFinisher(struct_def, code_ptr, code, object_name, false);
- GenerateFinisher(struct_def, code_ptr, code, object_name, true);
+ GenerateFinisher(struct_def, code_ptr, code, false);
+ GenerateFinisher(struct_def, code_ptr, code, true);
// Generate a convenient CreateX function
if (CanCreateFactoryMethod(struct_def)) {
- if (lang_.language == IDLOptions::kJs) {
- std::string paramDoc =
- GenTypeAnnotation(kParam, "flatbuffers.Builder", "builder");
- for (auto it = struct_def.fields.vec.begin();
- it != struct_def.fields.vec.end(); ++it) {
- const auto &field = **it;
- if (field.deprecated) continue;
- paramDoc +=
- GenTypeAnnotation(kParam, GetArgType(field, true), GetArgName(field));
- }
- paramDoc +=
- GenTypeAnnotation(kReturns, "flatbuffers.Offset", "", false);
-
- GenDocComment(code_ptr, paramDoc);
- }
-
- if (lang_.language == IDLOptions::kTs) {
- code += "static create" + Verbose(struct_def);
- code += "(builder:flatbuffers.Builder";
- } else {
- code += object_name + ".create" + Verbose(struct_def);
- code += " = function(builder";
- }
+ code += "static create" + GetPrefixedName(struct_def);
+ code += "(builder:flatbuffers.Builder";
for (auto it = struct_def.fields.vec.begin();
it != struct_def.fields.vec.end(); ++it) {
const auto &field = **it;
if (field.deprecated) continue;
-
- if (lang_.language == IDLOptions::kTs) {
- code += ", " + GetArgName(field) + ":" + GetArgType(field, true);
- } else {
- code += ", " + GetArgName(field);
- }
+ code += ", " + GetArgName(field) + ":" +
+ GetArgType(imports, struct_def, field, true);
}
- if (lang_.language == IDLOptions::kTs) {
- code += "):flatbuffers.Offset {\n";
- code += " " + struct_def.name + ".start" + Verbose(struct_def) +
- "(builder);\n";
- } else {
- code += ") {\n";
- code += " " + object_name + ".start" + Verbose(struct_def) +
- "(builder);\n";
- }
+ code += "):flatbuffers.Offset {\n";
+ code += " " + struct_def.name + ".start" +
+ GetPrefixedName(struct_def) + "(builder);\n";
- std::string methodPrefix =
- lang_.language == IDLOptions::kTs ? struct_def.name : object_name;
+ std::string methodPrefix = struct_def.name;
for (auto it = struct_def.fields.vec.begin();
it != struct_def.fields.vec.end(); ++it) {
const auto &field = **it;
@@ -2079,57 +1533,46 @@ class JsTsGenerator : public BaseGenerator {
code += "builder, " + arg_name + ");\n";
}
- code += " return " + methodPrefix + ".end" + Verbose(struct_def) +
- "(builder);\n";
+ code += " return " + methodPrefix + ".end" +
+ GetPrefixedName(struct_def) + "(builder);\n";
code += "}\n";
- if (lang_.language == IDLOptions::kJs) code += "\n";
}
}
- if (!struct_def.fixed && parser_.services_.vec.size() != 0 &&
- lang_.language == IDLOptions::kTs) {
- auto name = Verbose(struct_def, "");
+ if (!struct_def.fixed && parser_.services_.vec.size() != 0) {
+ auto name = GetPrefixedName(struct_def, "");
code += "\n";
code += "serialize():Uint8Array {\n";
code += " return this.bb!.bytes();\n";
code += "}\n";
code += "\n";
- code += "static deserialize(buffer: Uint8Array):"+ name +" {\n";
- code += " return " + name + ".getRootAs" + name +
- "(new flatbuffers.ByteBuffer(buffer))\n";
+ code += "static deserialize(buffer: Uint8Array):" + name + " {\n";
+ code += " return " + AddImport(imports, struct_def, struct_def) +
+ ".getRootAs" + name + "(new flatbuffers.ByteBuffer(buffer))\n";
code += "}\n";
}
- if (lang_.language == IDLOptions::kTs) {
- if (parser_.opts.generate_object_based_api) {
- std::string obj_api_class;
- std::string obj_api_unpack_func;
- GenObjApi(parser_, struct_def, obj_api_unpack_func, obj_api_class,
- imported_files);
+ if (parser_.opts.generate_object_based_api) {
+ std::string obj_api_class;
+ std::string obj_api_unpack_func;
+ GenObjApi(parser_, struct_def, obj_api_unpack_func, obj_api_class,
+ imports);
- code += obj_api_unpack_func + "}\n" + obj_api_class;
- } else {
- code += "}\n";
- }
- if (!object_namespace.empty()) { code += "}\n"; }
+ code += obj_api_unpack_func + "}\n" + obj_api_class;
+ } else {
+ code += "}\n";
}
}
-
+
static bool HasNullDefault(const FieldDef &field) {
return field.optional && field.value.constant == "null";
}
- std::string GetArgType(const FieldDef &field, bool allowNull) {
- auto type_name = GenTypeName(field.value.type, true, allowNull && field.optional);
-
- if (field.value.type.enum_def) {
- if (IsScalar(field.value.type.base_type)) {
- return GenPrefixedTypeName(type_name, field.value.type.enum_def->file);
- }
- }
-
- return type_name;
+ std::string GetArgType(import_set &imports, const Definition &owner,
+ const FieldDef &field, bool allowNull) {
+ return GenTypeName(imports, owner, field.value.type, true,
+ allowNull && field.optional);
}
static std::string GetArgName(const FieldDef &field) {
@@ -2139,25 +1582,26 @@ class JsTsGenerator : public BaseGenerator {
return argname;
}
- std::string Verbose(const StructDef &struct_def, const char *prefix = "") {
- return parser_.opts.js_ts_short_names ? "" : prefix + struct_def.name;
+ std::string GetPrefixedName(const StructDef &struct_def,
+ const char *prefix = "") {
+ return prefix + struct_def.name;
}
-}; // namespace jsts
-} // namespace jsts
+}; // namespace ts
+} // namespace ts
-bool GenerateJSTS(const Parser &parser, const std::string &path,
- const std::string &file_name) {
- jsts::JsTsGenerator generator(parser, path, file_name);
+bool GenerateTS(const Parser &parser, const std::string &path,
+ const std::string &file_name) {
+ ts::TsGenerator generator(parser, path, file_name);
return generator.generate();
}
-std::string JSTSMakeRule(const Parser &parser, const std::string &path,
- const std::string &file_name) {
+std::string TSMakeRule(const Parser &parser, const std::string &path,
+ const std::string &file_name) {
FLATBUFFERS_ASSERT(parser.opts.lang <= IDLOptions::kMAX);
std::string filebase =
flatbuffers::StripPath(flatbuffers::StripExtension(file_name));
- jsts::JsTsGenerator generator(parser, path, file_name);
+ ts::TsGenerator generator(parser, path, file_name);
std::string make_rule =
generator.GeneratedFileName(path, filebase, parser.opts) + ": ";
diff --git a/src/idl_parser.cpp b/src/idl_parser.cpp
index ac5e30bd..324ba930 100644
--- a/src/idl_parser.cpp
+++ b/src/idl_parser.cpp
@@ -2388,8 +2388,7 @@ bool Parser::SupportsOptionalScalars(const flatbuffers::IDLOptions &opts) {
static FLATBUFFERS_CONSTEXPR unsigned long supported_langs =
IDLOptions::kRust | IDLOptions::kSwift | IDLOptions::kLobster |
IDLOptions::kKotlin | IDLOptions::kCpp | IDLOptions::kJava |
- IDLOptions::kCSharp | IDLOptions::kTs | IDLOptions::kJs |
- IDLOptions::kBinary;
+ IDLOptions::kCSharp | IDLOptions::kTs | IDLOptions::kBinary;
unsigned long langs = opts.lang_to_generate;
return (langs > 0 && langs < IDLOptions::kMAX) && !(langs & ~supported_langs);
}
@@ -2402,10 +2401,9 @@ bool Parser::SupportsOptionalScalars() const {
bool Parser::SupportsAdvancedUnionFeatures() const {
return opts.lang_to_generate != 0 &&
(opts.lang_to_generate &
- ~(IDLOptions::kCpp | IDLOptions::kJs | IDLOptions::kTs |
- IDLOptions::kPhp | IDLOptions::kJava | IDLOptions::kCSharp |
- IDLOptions::kKotlin | IDLOptions::kBinary | IDLOptions::kSwift)) ==
- 0;
+ ~(IDLOptions::kCpp | IDLOptions::kTs | IDLOptions::kPhp |
+ IDLOptions::kJava | IDLOptions::kCSharp | IDLOptions::kKotlin |
+ IDLOptions::kBinary | IDLOptions::kSwift)) == 0;
}
bool Parser::SupportsAdvancedArrayFeatures() const {
diff --git a/tests/JavaScriptFlexBuffersTest.js b/tests/JavaScriptFlexBuffersTest.js
index 11c46c97..d2462c67 100644
--- a/tests/JavaScriptFlexBuffersTest.js
+++ b/tests/JavaScriptFlexBuffersTest.js
@@ -1,9 +1,7 @@
// Run this using JavaScriptTest.sh
-var assert = require('assert');
-var fs = require('fs');
-
-var flexbuffers = require('../js/flexbuffers').flexbuffers;
-global.flexbuffers = flexbuffers;
+import assert from 'assert'
+import fs from 'fs'
+import * as flexbuffers from 'flatbuffers/js/flexbuffers'
function main() {
testSingleValueBuffers();
@@ -16,10 +14,12 @@ function main() {
testRoundTripWithBuilder();
testDeduplicationOff();
testBugWhereOffestWereStoredAsIntInsteadOfUInt();
+
+ console.log('FlexBuffers test: completed successfully');
}
function testSingleValueBuffers() {
- { // null
+ {
const ref = flexbuffers.toReference(new Uint8Array([0, 0, 1]).buffer);
assert.strictEqual(true, ref.isNull());
}
diff --git a/tests/JavaScriptTest.js b/tests/JavaScriptTest.js
index 2d7afc55..3e37f599 100644
--- a/tests/JavaScriptTest.js
+++ b/tests/JavaScriptTest.js
@@ -1,13 +1,14 @@
// Run this using JavaScriptTest.sh
-var assert = require('assert');
-var fs = require('fs');
+import assert from 'assert'
+import fs from 'fs'
+import * as flatbuffers from 'flatbuffers'
-var flatbuffers = require('../js/flatbuffers').flatbuffers;
-global.flatbuffers = flatbuffers;
-
-var MyGame = require(process.argv[2]).MyGame;
-
-var isTsTest = !!process.env.FB_TS_TEST;
+import { Monster, MonsterT } from './ts/my-game/example/monster'
+import { Test } from './ts/my-game/example/test'
+import { Stat } from './ts/my-game/example/stat'
+import { Vec3 } from './ts/my-game/example/vec3'
+import { Color } from './ts/my-game/example/color';
+import { Any } from './ts/my-game/example/any';
function main() {
@@ -27,11 +28,8 @@ function main() {
var fbb = new flatbuffers.Builder(1);
createMonster(fbb);
serializeAndTest(fbb);
+ testObjApiPack(fbb);
- if(isTsTest) {
- testObjApiPack(fbb);
- }
-
// clear the builder, repeat tests
var clearIterations = 100;
var startingCapacity = fbb.bb.capacity();
@@ -39,10 +37,7 @@ function main() {
fbb.clear();
createMonster(fbb);
serializeAndTest(fbb);
-
- if(isTsTest) {
- testObjApiPack(fbb);
- }
+ testObjApiPack(fbb);
}
// the capacity of our buffer shouldn't increase with the same size payload
assert.strictEqual(fbb.bb.capacity(), startingCapacity);
@@ -52,7 +47,7 @@ function main() {
fuzzTest1();
testNullStrings();
testSharedStrings();
-
+
console.log('FlatBuffers test: completed successfully');
}
@@ -61,36 +56,36 @@ function createMonster(fbb) {
var str = fbb.createString('MyMonster');
- var inv = MyGame.Example.Monster.createInventoryVector(fbb, [0, 1, 2, 3, 4]);
+ var inv = 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);
+ Monster.startMonster(fbb);
+ Monster.addName(fbb, fred);
+ var mon2 = Monster.endMonster(fbb);
- MyGame.Example.Monster.startTest4Vector(fbb, 2);
- MyGame.Example.Test.createTest(fbb, 10, 20);
- MyGame.Example.Test.createTest(fbb, 30, 40);
+ Monster.startTest4Vector(fbb, 2);
+ Test.createTest(fbb, 10, 20);
+ Test.createTest(fbb, 30, 40);
var test4 = fbb.endVector();
- var testArrayOfString = MyGame.Example.Monster.createTestarrayofstringVector(fbb, [
+ var testArrayOfString = 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);
+ Monster.startMonster(fbb);
+ Monster.addPos(fbb, Vec3.createVec3(fbb, 1, 2, 3, 3, Color.Green, 5, 6));
+ Monster.addHp(fbb, 80);
+ Monster.addName(fbb, str);
+ Monster.addInventory(fbb, inv);
+ Monster.addTestType(fbb, Any.Monster);
+ Monster.addTest(fbb, mon2);
+ Monster.addTest4(fbb, test4);
+ Monster.addTestarrayofstring(fbb, testArrayOfString);
+ Monster.addTestbool(fbb, true);
+ var mon = Monster.endMonster(fbb);
+
+ Monster.finishMonsterBuffer(fbb, mon);
}
function serializeAndTest(fbb) {
@@ -109,7 +104,7 @@ function serializeAndTest(fbb) {
}
function testMutation(bb) {
- var monster = MyGame.Example.Monster.getRootAsMonster(bb);
+ var monster = Monster.getRootAsMonster(bb);
monster.mutate_hp(120);
assert.strictEqual(monster.hp(), 120);
@@ -126,9 +121,9 @@ function testMutation(bb) {
function testObjApiPack(fbb) {
fbb.clear();
createMonster(fbb);
- let monster_t = MyGame.Example.Monster.getRootAsMonster(fbb.dataBuffer()).unpack();
+ let monster_t = Monster.getRootAsMonster(fbb.dataBuffer()).unpack();
fbb.clear();
- MyGame.Example.Monster.finishMonsterBuffer(fbb, monster_t.pack(fbb));
+ Monster.finishMonsterBuffer(fbb, monster_t.pack(fbb));
serializeAndTest(fbb);
}
@@ -143,15 +138,15 @@ function testObjApiUnpack(monster) {
assert.strictEqual(pos.y, 2);
assert.strictEqual(pos.z, 3);
assert.strictEqual(pos.test1, 3);
- assert.strictEqual(pos.test2, MyGame.Example.Color.Green);
+ assert.strictEqual(pos.test2, Color.Green);
let test3 = pos.test3;
assert.strictEqual(test3.a, 5);
assert.strictEqual(test3.b, 6);
- assert.strictEqual(monster.testType, MyGame.Example.Any.Monster);
+ assert.strictEqual(monster.testType, Any.Monster);
let monster2 = monster.test;
assert.strictEqual(monster2 != null, true);
- assert.strictEqual(monster2 instanceof MyGame.Example.MonsterT, true);
+ assert.strictEqual(monster2 instanceof MonsterT, true);
assert.strictEqual(monster2.name, 'Fred');
assert.strictEqual(monster.inventory.length, 5);
@@ -174,9 +169,9 @@ function testObjApiUnpack(monster) {
}
function testBuffer(bb) {
- assert.ok(MyGame.Example.Monster.bufferHasIdentifier(bb));
+ assert.ok(Monster.bufferHasIdentifier(bb));
- var monster = MyGame.Example.Monster.getRootAsMonster(bb);
+ var monster = Monster.getRootAsMonster(bb);
assert.strictEqual(monster.hp(), 80);
assert.strictEqual(monster.mana(), 150); // default
@@ -188,13 +183,13 @@ function testBuffer(bb) {
assert.strictEqual(pos.y(), 2);
assert.strictEqual(pos.z(), 3);
assert.strictEqual(pos.test1(), 3);
- assert.strictEqual(pos.test2(), MyGame.Example.Color.Green);
+ assert.strictEqual(pos.test2(), 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.testType(), Any.Monster);
+ var monster2 = new Monster();
assert.strictEqual(monster.test(monster2) != null, true);
assert.strictEqual(monster2.name(), 'Fred');
@@ -223,47 +218,45 @@ function testBuffer(bb) {
assert.strictEqual(monster.testbool(), true);
- if(isTsTest) {
- let monster_t = monster.unpack();
- testObjApiUnpack(monster_t);
+ let monster_t = monster.unpack();
+ testObjApiUnpack(monster_t);
- let monster2_t = new MyGame.Example.MonsterT();
- monster.unpackTo(monster2_t);
- testObjApiUnpack(monster2_t);
- }
+ let monster2_t = new MonsterT();
+ monster.unpackTo(monster2_t);
+ testObjApiUnpack(monster2_t);
}
function test64bit() {
var fbb = new flatbuffers.Builder();
var required = fbb.createString('required');
- MyGame.Example.Stat.startStat(fbb);
- var stat2 = MyGame.Example.Stat.endStat(fbb);
+ Stat.startStat(fbb);
+ var stat2 = 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);
+ Monster.startMonster(fbb);
+ Monster.addName(fbb, required);
+ Monster.addTestempty(fbb, stat2);
+ var mon2 = Monster.endMonster(fbb);
- MyGame.Example.Stat.startStat(fbb);
+ Stat.startStat(fbb);
// 2541551405100253985 = 0x87654321(low part) + 0x23456789 * 0x100000000(high part);
- MyGame.Example.Stat.addVal(fbb, new flatbuffers.Long(0x87654321, 0x23456789)); // the low part is Uint32
- var stat = MyGame.Example.Stat.endStat(fbb);
+ Stat.addVal(fbb, new flatbuffers.Long(0x87654321, 0x23456789)); // the low part is Uint32
+ var stat = 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);
+ Monster.startMonster(fbb);
+ Monster.addName(fbb, required);
+ Monster.addEnemy(fbb, mon2);
+ Monster.addTestempty(fbb, stat);
+ var mon = Monster.endMonster(fbb);
- MyGame.Example.Monster.finishMonsterBuffer(fbb, mon);
+ 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);
+ assert.ok(Monster.bufferHasIdentifier(bb));
+ var mon = Monster.getRootAsMonster(bb);
var stat = mon.testempty();
assert.strictEqual(stat != null, true);
@@ -285,7 +278,7 @@ function testUnicode() {
// Test reading
function testReadingUnicode(bb) {
- var monster = MyGame.Example.Monster.getRootAsMonster(bb);
+ var monster = 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);
@@ -307,19 +300,19 @@ function testUnicode() {
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);
+ Monster.startMonster(fbb);
+ Monster.addName(fbb, name);
+ return Monster.endMonster(fbb);
});
- var testarrayoftablesOffset = MyGame.Example.Monster.createTestarrayoftablesVector(fbb,
+ var testarrayoftablesOffset = Monster.createTestarrayoftablesVector(fbb,
testarrayoftablesOffsets);
- var testarrayofstringOffset = MyGame.Example.Monster.createTestarrayofstringVector(fbb,
+ var testarrayofstringOffset = 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));
+ Monster.startMonster(fbb);
+ Monster.addTestarrayofstring(fbb, testarrayofstringOffset);
+ Monster.addTestarrayoftables(fbb, testarrayoftablesOffset);
+ Monster.addName(fbb, name);
+ Monster.finishSizePrefixedMonsterBuffer(fbb, Monster.endMonster(fbb));
var bb = new flatbuffers.ByteBuffer(fbb.asUint8Array())
bb.setPosition(4);
testReadingUnicode(bb);
diff --git a/tests/JavaScriptTest.sh b/tests/JavaScriptTest.sh
deleted file mode 100755
index 707af71c..00000000
--- a/tests/JavaScriptTest.sh
+++ /dev/null
@@ -1,24 +0,0 @@
-#!/bin/sh
-#
-# Copyright 2016 Google Inc. All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-pushd "$(dirname $0)" >/dev/null
-../flatc -b -I include_test monster_test.fbs unicode_test.json
-../flatc --js -o js --gen-name-strings --gen-mutable --no-fb-import -I include_test monster_test.fbs
-node JavaScriptTest ./js/monster_test_generated
-
-../flatc --js --gen-name-strings -o js --no-fb-import union_vector/union_vector.fbs
-node JavaScriptUnionVectorTest ./js/union_vector_generated
-node JavaScriptFlexBuffersTest
diff --git a/tests/JavaScriptUnionVectorTest.js b/tests/JavaScriptUnionVectorTest.js
index f03a3279..aea6d900 100644
--- a/tests/JavaScriptUnionVectorTest.js
+++ b/tests/JavaScriptUnionVectorTest.js
@@ -1,16 +1,17 @@
-var assert = require('assert');
+import assert from 'assert'
+import * as flatbuffers from 'flatbuffers'
-var flatbuffers = require('../js/flatbuffers').flatbuffers;
-var Test = require(process.argv[2]);
-
-var isTsTest = !!process.env.FB_TS_TEST;
+import { Character } from './ts/character'
+import { BookReader, BookReaderT } from './ts/book-reader'
+import { Attacker, AttackerT } from './ts/attacker'
+import { Movie, MovieT } from './ts/movie'
var charTypes = [
- Test.Character.Belle,
- Test.Character.MuLan,
- Test.Character.BookFan,
+ Character.Belle,
+ Character.MuLan,
+ Character.BookFan,
+ Character.Other
];
-if(isTsTest) { charTypes.push(Test.Character.Other); }
function testMovieBuf(movie) {
assert.strictEqual(movie.charactersTypeLength(), charTypes.length);
@@ -20,19 +21,17 @@ function testMovieBuf(movie) {
assert.strictEqual(movie.charactersType(i), charTypes[i]);
}
- var bookReader7 = movie.characters(0, new Test.BookReader());
+ var bookReader7 = movie.characters(0, new BookReader());
assert.strictEqual(bookReader7.booksRead(), 7);
- var attacker = movie.characters(1, new Test.Attacker());
+ var attacker = movie.characters(1, new Attacker());
assert.strictEqual(attacker.swordAttackDamage(), 5);
- var bookReader2 = movie.characters(2, new Test.BookReader());
+ var bookReader2 = movie.characters(2, new BookReader());
assert.strictEqual(bookReader2.booksRead(), 2);
- if(isTsTest) {
- var other = movie.characters(3, '');
- assert.strictEqual(other, "I am other");
- }
+ var other = movie.characters(3, '');
+ assert.strictEqual(other, "I am other");
}
function testMovieUnpack(movie) {
@@ -44,58 +43,45 @@ function testMovieUnpack(movie) {
}
var bookReader7 = movie.characters[0];
- assert.strictEqual(bookReader7 instanceof Test.BookReaderT, true);
+ assert.strictEqual(bookReader7 instanceof BookReaderT, true);
assert.strictEqual(bookReader7.booksRead, 7);
-
+
var attacker = movie.characters[1];
- assert.strictEqual(attacker instanceof Test.AttackerT, true);
+ assert.strictEqual(attacker instanceof AttackerT, true);
assert.strictEqual(attacker.swordAttackDamage, 5);
-
+
var bookReader2 = movie.characters[2];
- assert.strictEqual(bookReader2 instanceof Test.BookReaderT, true);
+ assert.strictEqual(bookReader2 instanceof BookReaderT, true);
assert.strictEqual(bookReader2.booksRead, 2);
- if(isTsTest) {
- var other = movie.characters[3];
- assert.strictEqual(other, "I am other");
- }
+ var other = movie.characters[3];
+ assert.strictEqual(other, "I am other");
}
function createMovie(fbb) {
- Test.Attacker.startAttacker(fbb);
- Test.Attacker.addSwordAttackDamage(fbb, 5);
- var attackerOffset = Test.Attacker.endAttacker(fbb);
+ Attacker.startAttacker(fbb);
+ Attacker.addSwordAttackDamage(fbb, 5);
+ var attackerOffset = Attacker.endAttacker(fbb);
- var charTypesOffset = Test.Movie.createCharactersTypeVector(fbb, charTypes);
+ var charTypesOffset = Movie.createCharactersTypeVector(fbb, charTypes);
var charsOffset = 0;
- if(isTsTest) {
- let otherOffset = fbb.createString("I am other");
-
- charsOffset = Test.Movie.createCharactersVector(
- fbb,
- [
- Test.BookReader.createBookReader(fbb, 7),
- attackerOffset,
- Test.BookReader.createBookReader(fbb, 2),
- otherOffset
- ]
- );
- } else {
- charsOffset = Test.Movie.createCharactersVector(
- fbb,
- [
- Test.BookReader.createBookReader(fbb, 7),
- attackerOffset,
- Test.BookReader.createBookReader(fbb, 2)
- ]
- );
- }
-
- Test.Movie.startMovie(fbb);
- Test.Movie.addCharactersType(fbb, charTypesOffset);
- Test.Movie.addCharacters(fbb, charsOffset);
- Test.Movie.finishMovieBuffer(fbb, Test.Movie.endMovie(fbb))
+ let otherOffset = fbb.createString("I am other");
+
+ charsOffset = Movie.createCharactersVector(
+ fbb,
+ [
+ BookReader.createBookReader(fbb, 7),
+ attackerOffset,
+ BookReader.createBookReader(fbb, 2),
+ otherOffset
+ ]
+ );
+
+ Movie.startMovie(fbb);
+ Movie.addCharactersType(fbb, charTypesOffset);
+ Movie.addCharacters(fbb, charsOffset);
+ Movie.finishMovieBuffer(fbb, Movie.endMovie(fbb))
}
function main() {
@@ -105,22 +91,20 @@ function main() {
var buf = new flatbuffers.ByteBuffer(fbb.asUint8Array());
- var movie = Test.Movie.getRootAsMovie(buf);
+ var movie = Movie.getRootAsMovie(buf);
testMovieBuf(movie);
- if(isTsTest) {
- testMovieUnpack(movie.unpack());
+ testMovieUnpack(movie.unpack());
- var movie_to = new Test.MovieT();
- movie.unpackTo(movie_to);
- testMovieUnpack(movie_to);
-
- fbb.clear();
- Test.Movie.finishMovieBuffer(fbb, movie_to.pack(fbb));
- var unpackBuf = new flatbuffers.ByteBuffer(fbb.asUint8Array());
- testMovieBuf(Test.Movie.getRootAsMovie(unpackBuf));
- }
+ var movie_to = new MovieT();
+ movie.unpackTo(movie_to);
+ testMovieUnpack(movie_to);
+ fbb.clear();
+ Movie.finishMovieBuffer(fbb, movie_to.pack(fbb));
+ var unpackBuf = new flatbuffers.ByteBuffer(fbb.asUint8Array());
+ testMovieBuf(Movie.getRootAsMovie(unpackBuf));
+
console.log('FlatBuffers union vector test: completed successfully');
}
diff --git a/tests/TestAll.sh b/tests/TestAll.sh
index e20431c3..06548a21 100755
--- a/tests/TestAll.sh
+++ b/tests/TestAll.sh
@@ -14,12 +14,6 @@ echo "************************ Python:"
sh PythonTest.sh
-echo "************************ JavaScript:"
-
-sh JavaScriptTest.sh
-# FIXME does not exist:
-# sh JavaScriptUnionVectorTest.sh
-
echo "************************ TypeScript:"
sh TypeScriptTest.sh
diff --git a/tests/TypeScriptTest.bat b/tests/TypeScriptTest.bat
new file mode 100755
index 00000000..87c4b58f
--- /dev/null
+++ b/tests/TypeScriptTest.bat
@@ -0,0 +1,8 @@
+npm install
+../flatc.exe --ts --gen-name-strings --gen-mutable --gen-object-api -o ts -I include_test monster_test.fbs
+../flatc.exe --gen-object-api -b -I include_test monster_test.fbs unicode_test.json
+../flatc.exe --ts --gen-name-strings --gen-object-api -o ts union_vector/union_vector.fbs
+tsc
+node -r esm JavaScriptTest
+node -r esm JavaScriptUnionVectorTest
+node -r esm JavaScriptFlexBuffersTest
diff --git a/tests/TypeScriptTest.sh b/tests/TypeScriptTest.sh
index f1143545..f9ce3edc 100755
--- a/tests/TypeScriptTest.sh
+++ b/tests/TypeScriptTest.sh
@@ -16,20 +16,14 @@
pushd "$(dirname $0)" >/dev/null
-npm install @types/flatbuffers
-npm run pretest
+# clean node_modules to make sure we depend on latest local flatbuffers at ../
+rm -rf node_modules
+npm install
-export FB_TS_TEST="TRUE"
-
-../flatc --ts --no-fb-import --gen-name-strings --gen-mutable --gen-object-api -o ts -I include_test monster_test.fbs
+../flatc --ts --gen-name-strings --gen-mutable --gen-object-api -o ts -I include_test monster_test.fbs
../flatc --gen-object-api -b -I include_test monster_test.fbs unicode_test.json
-tsc --strict --noUnusedParameters --noUnusedLocals --noImplicitReturns --strictNullChecks ts/monster_test_generated.ts
-node JavaScriptTest ./ts/monster_test_generated
-
-../flatc --ts --gen-name-strings --no-fb-import --gen-object-api -o ts union_vector/union_vector.fbs
-tsc --strict --noUnusedParameters --noUnusedLocals --noImplicitReturns --strictNullChecks ts/union_vector_generated.ts
-node JavaScriptUnionVectorTest ./ts/union_vector_generated
-
-unset FB_TS_TEST
-
-npm uninstall @types/flatbuffers
+../flatc --ts --gen-name-strings --gen-object-api -o ts union_vector/union_vector.fbs
+tsc
+node -r esm JavaScriptTest
+node -r esm JavaScriptUnionVectorTest
+node -r esm JavaScriptFlexBuffersTest
diff --git a/tests/docker/languages/Dockerfile.testing.node.10_13_0 b/tests/docker/languages/Dockerfile.testing.node.10_13_0
deleted file mode 100644
index 8e48c23c..00000000
--- a/tests/docker/languages/Dockerfile.testing.node.10_13_0
+++ /dev/null
@@ -1,10 +0,0 @@
-FROM node:10.13.0-stretch as base
-WORKDIR /code
-ADD . .
-RUN cp flatc_debian_stretch flatc
-WORKDIR /code/tests
-RUN node --version
-RUN ../flatc -b -I include_test monster_test.fbs unicode_test.json
-RUN npm install
-RUN npm run pretest
-RUN node JavaScriptTest ./monster_test_generated
diff --git a/tests/docker/languages/Dockerfile.testing.node.11_2_0 b/tests/docker/languages/Dockerfile.testing.node.11_2_0
deleted file mode 100644
index 090bb457..00000000
--- a/tests/docker/languages/Dockerfile.testing.node.11_2_0
+++ /dev/null
@@ -1,10 +0,0 @@
-FROM node:11.2.0-stretch as base
-WORKDIR /code
-ADD . .
-RUN cp flatc_debian_stretch flatc
-WORKDIR /code/tests
-RUN node --version
-RUN ../flatc -b -I include_test monster_test.fbs unicode_test.json
-RUN npm install
-RUN npm run pretest
-RUN node JavaScriptTest ./monster_test_generated
diff --git a/tests/docker/languages/Dockerfile.testing.node.12_20_1 b/tests/docker/languages/Dockerfile.testing.node.12_20_1
new file mode 100644
index 00000000..013661f5
--- /dev/null
+++ b/tests/docker/languages/Dockerfile.testing.node.12_20_1
@@ -0,0 +1,6 @@
+FROM node:12.20.1-stretch as base
+WORKDIR /code
+ADD . .
+RUN cp flatc_debian_stretch flatc
+RUN npm install
+RUN npm test
diff --git a/tests/docker/languages/Dockerfile.testing.node.14_15_4 b/tests/docker/languages/Dockerfile.testing.node.14_15_4
new file mode 100644
index 00000000..fb546bcb
--- /dev/null
+++ b/tests/docker/languages/Dockerfile.testing.node.14_15_4
@@ -0,0 +1,6 @@
+FROM node:14.15.4-stretch as base
+WORKDIR /code
+ADD . .
+RUN cp flatc_debian_stretch flatc
+RUN npm install
+RUN npm test
diff --git a/tests/generate_code.bat b/tests/generate_code.bat
index 764e3f41..045e6883 100644
--- a/tests/generate_code.bat
+++ b/tests/generate_code.bat
@@ -32,18 +32,18 @@ set TEST_CS_FLAGS=--cs-gen-json-serializer
set TEST_JS_TS_FLAGS=--gen-name-strings
set TEST_RUST_FLAGS=--gen-name-strings
set TEST_BASE_FLAGS=--reflect-names --gen-mutable --gen-object-api
-set TEST_NOINCL_FLAGS=%TEST_BASE_FLAGS% --no-includes --no-fb-import
+set TEST_NOINCL_FLAGS=%TEST_BASE_FLAGS% --no-includes
-..\%buildtype%\flatc.exe --binary --cpp --java --kotlin --csharp --dart --go --lobster --lua --js --ts --php --grpc ^
+..\%buildtype%\flatc.exe --binary --cpp --java --kotlin --csharp --dart --go --lobster --lua --ts --php --grpc ^
%TEST_NOINCL_FLAGS% %TEST_CPP_FLAGS% %TEST_CS_FLAGS% -I include_test monster_test.fbs monsterdata_test.json || goto FAIL
..\%buildtype%\flatc.exe --rust %TEST_NOINCL_FLAGS% %TEST_RUST_FLAGS% -I include_test monster_test.fbs monsterdata_test.json || goto FAIL
-..\%buildtype%\flatc.exe --python %TEST_BASE_FLAGS% --no-fb-import -I include_test monster_test.fbs monsterdata_test.json || goto FAIL
+..\%buildtype%\flatc.exe --python %TEST_BASE_FLAGS% -I include_test monster_test.fbs monsterdata_test.json || goto FAIL
-..\%buildtype%\flatc.exe --binary --cpp --java --csharp --dart --go --lobster --lua --js --ts --php --python --rust ^
+..\%buildtype%\flatc.exe --binary --cpp --java --csharp --dart --go --lobster --lua --ts --php --python --rust ^
%TEST_NOINCL_FLAGS% %TEST_CPP_FLAGS% %TEST_CS_FLAGS% %TEST_JS_TS_FLAGS% -o namespace_test namespace_test/namespace_test1.fbs namespace_test/namespace_test2.fbs || goto FAIL
-..\%buildtype%\flatc.exe --cpp --java --csharp --js --ts --php %TEST_BASE_FLAGS% %TEST_CPP_FLAGS% %TEST_CS_FLAGS% %TEST_JS_TS_FLAGS% -o union_vector ./union_vector/union_vector.fbs || goto FAIL
+..\%buildtype%\flatc.exe --cpp --java --csharp --ts --php %TEST_BASE_FLAGS% %TEST_CPP_FLAGS% %TEST_CS_FLAGS% %TEST_JS_TS_FLAGS% -o union_vector ./union_vector/union_vector.fbs || goto FAIL
..\%buildtype%\flatc.exe --rust -I include_test -o include_test include_test/include_test1.fbs || goto FAIL
..\%buildtype%\flatc.exe --rust -I include_test -o include_test/sub include_test/sub/include_test2.fbs || goto FAIL
..\%buildtype%\flatc.exe -b --schema --bfbs-comments --bfbs-builtins -I include_test monster_test.fbs || goto FAIL
@@ -55,7 +55,7 @@ set TEST_NOINCL_FLAGS=%TEST_BASE_FLAGS% --no-includes --no-fb-import
..\%buildtype%\flatc.exe --cpp %TEST_BASE_FLAGS% --cpp-ptr-type flatbuffers::unique_ptr native_type_test.fbs || goto FAIL
@rem Generate the optional scalar code for tests.
-..\%buildtype%\flatc.exe --java --kotlin --rust --lobster --ts --js optional_scalars.fbs || goto FAIL
+..\%buildtype%\flatc.exe --java --kotlin --rust --lobster --ts optional_scalars.fbs || goto FAIL
..\%buildtype%\flatc.exe --csharp --gen-object-api optional_scalars.fbs || goto FAIL
..\%buildtype%\flatc.exe %TEST_NOINCL_FLAGS% %TEST_CPP_FLAGS% --cpp optional_scalars.fbs || goto FAIL
diff --git a/tests/generate_code.sh b/tests/generate_code.sh
index 671bfbe6..e0744623 100755
--- a/tests/generate_code.sh
+++ b/tests/generate_code.sh
@@ -29,18 +29,18 @@ TEST_CS_FLAGS="--cs-gen-json-serializer"
TEST_JS_TS_FLAGS="--gen-name-strings"
TEST_BASE_FLAGS="--reflect-names --gen-mutable --gen-object-api"
TEST_RUST_FLAGS="$TEST_BASE_FLAGS --gen-name-strings"
-TEST_NOINCL_FLAGS="$TEST_BASE_FLAGS --no-includes --no-fb-import"
+TEST_NOINCL_FLAGS="$TEST_BASE_FLAGS --no-includes"
-../flatc --binary --cpp --java --kotlin --csharp --dart --go --lobster --lua --js --ts --php --grpc \
+../flatc --binary --cpp --java --kotlin --csharp --dart --go --lobster --lua --ts --php --grpc \
$TEST_NOINCL_FLAGS $TEST_CPP_FLAGS $TEST_CS_FLAGS -I include_test monster_test.fbs monsterdata_test.json
../flatc --rust $TEST_RUST_FLAGS -I include_test monster_test.fbs monsterdata_test.json
../flatc --python $TEST_BASE_FLAGS -I include_test monster_test.fbs monsterdata_test.json
-../flatc --cpp --java --kotlin --csharp --dart --go --binary --lobster --lua --js --ts --php --python --rust \
+../flatc --cpp --java --kotlin --csharp --dart --go --binary --lobster --lua --ts --php --python --rust \
$TEST_NOINCL_FLAGS $TEST_CPP_FLAGS $TEST_CS_FLAGS $TEST_JS_TS_FLAGS -o namespace_test namespace_test/namespace_test1.fbs namespace_test/namespace_test2.fbs
-../flatc --cpp --java --kotlin --csharp --js --ts --php $TEST_BASE_FLAGS $TEST_CPP_FLAGS $TEST_CS_FLAGS $TEST_JS_TS_FLAGS -o union_vector ./union_vector/union_vector.fbs
+../flatc --cpp --java --kotlin --csharp --ts --php $TEST_BASE_FLAGS $TEST_CPP_FLAGS $TEST_CS_FLAGS $TEST_JS_TS_FLAGS -o union_vector ./union_vector/union_vector.fbs
../flatc --rust -I include_test -o include_test include_test/include_test1.fbs
../flatc --rust -I include_test -o include_test/sub include_test/sub/include_test2.fbs
../flatc -b --schema --bfbs-comments --bfbs-builtins -I include_test monster_test.fbs
@@ -53,7 +53,7 @@ $TEST_NOINCL_FLAGS $TEST_CPP_FLAGS $TEST_CS_FLAGS $TEST_JS_TS_FLAGS -o namespace
../flatc --dart monster_extra.fbs
# Generate optional scalar code for tests.
-../flatc --java --kotlin --rust --lobster --ts --js optional_scalars.fbs
+../flatc --java --kotlin --rust --lobster --ts optional_scalars.fbs
../flatc --csharp --gen-object-api optional_scalars.fbs
../flatc $TEST_NOINCL_FLAGS $TEST_CPP_FLAGS --cpp optional_scalars.fbs
diff --git a/tests/monster_test_grpc.d.ts b/tests/monster_test_grpc.d.ts
deleted file mode 100644
index 128c6022..00000000
--- a/tests/monster_test_grpc.d.ts
+++ /dev/null
@@ -1,92 +0,0 @@
-// Generated GRPC code for FlatBuffers TS *** DO NOT EDIT ***
-import { flatbuffers } from 'flatbuffers';
-import * as MonsterStorage_fbs from './monster_test_generated';
-
-import * as grpc from 'grpc';
-
-interface IMonsterStorageService extends grpc.ServiceDefinition<grpc.UntypedServiceImplementation> {
- Store: IMonsterStorageService_IStore;
- Retrieve: IMonsterStorageService_IRetrieve;
- GetMaxHitPoint: IMonsterStorageService_IGetMaxHitPoint;
- GetMinMaxHitPoints: IMonsterStorageService_IGetMinMaxHitPoints;
-}
-interface IMonsterStorageService_IStore extends grpc.MethodDefinition<MonsterStorage_fbs.Monster, MonsterStorage_fbs.Stat> {
- path: string; // /MyGame.Example.MonsterStorage/Store
- requestStream: boolean; // false
- responseStream: boolean; // false
- requestSerialize: grpc.serialize<MonsterStorage_fbs.Monster>;
- requestDeserialize: grpc.deserialize<MonsterStorage_fbs.Monster>;
- responseSerialize: grpc.serialize<MonsterStorage_fbs.Stat>;
- responseDeserialize: grpc.deserialize<MonsterStorage_fbs.Stat>;
-}
-
-interface IMonsterStorageService_IRetrieve extends grpc.MethodDefinition<MonsterStorage_fbs.Stat, MonsterStorage_fbs.Monster> {
- path: string; // /MyGame.Example.MonsterStorage/Retrieve
- requestStream: boolean; // false
- responseStream: boolean; // true
- requestSerialize: grpc.serialize<MonsterStorage_fbs.Stat>;
- requestDeserialize: grpc.deserialize<MonsterStorage_fbs.Stat>;
- responseSerialize: grpc.serialize<MonsterStorage_fbs.Monster>;
- responseDeserialize: grpc.deserialize<MonsterStorage_fbs.Monster>;
-}
-
-interface IMonsterStorageService_IGetMaxHitPoint extends grpc.MethodDefinition<MonsterStorage_fbs.Monster, MonsterStorage_fbs.Stat> {
- path: string; // /MyGame.Example.MonsterStorage/GetMaxHitPoint
- requestStream: boolean; // true
- responseStream: boolean; // false
- requestSerialize: grpc.serialize<MonsterStorage_fbs.Monster>;
- requestDeserialize: grpc.deserialize<MonsterStorage_fbs.Monster>;
- responseSerialize: grpc.serialize<MonsterStorage_fbs.Stat>;
- responseDeserialize: grpc.deserialize<MonsterStorage_fbs.Stat>;
-}
-
-interface IMonsterStorageService_IGetMinMaxHitPoints extends grpc.MethodDefinition<MonsterStorage_fbs.Monster, MonsterStorage_fbs.Stat> {
- path: string; // /MyGame.Example.MonsterStorage/GetMinMaxHitPoints
- requestStream: boolean; // true
- responseStream: boolean; // true
- requestSerialize: grpc.serialize<MonsterStorage_fbs.Monster>;
- requestDeserialize: grpc.deserialize<MonsterStorage_fbs.Monster>;
- responseSerialize: grpc.serialize<MonsterStorage_fbs.Stat>;
- responseDeserialize: grpc.deserialize<MonsterStorage_fbs.Stat>;
-}
-
-
-export const MonsterStorageService: IMonsterStorageService;
-
-export interface IMonsterStorageServer {
- Store: grpc.handleUnaryCall<MonsterStorage_fbs.Monster, MonsterStorage_fbs.Stat>;
- Retrieve: grpc.handleServerStreamingCall<MonsterStorage_fbs.Stat, MonsterStorage_fbs.Monster>;
- GetMaxHitPoint: grpc.handleClientStreamingCall<MonsterStorage_fbs.Monster, MonsterStorage_fbs.Stat>;
- GetMinMaxHitPoints: grpc.handleBidiStreamingCall<MonsterStorage_fbs.Monster, MonsterStorage_fbs.Stat>;
-}
-
-export interface IMonsterStorageClient {
- Store(request: MonsterStorage_fbs.Monster, callback: (error: grpc.ServiceError | null, response: MonsterStorage_fbs.Stat) => void): grpc.ClientUnaryCall;
- Store(request: MonsterStorage_fbs.Monster, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: MonsterStorage_fbs.Stat) => void): grpc.ClientUnaryCall;
- Store(request: MonsterStorage_fbs.Monster, metadata: grpc.Metadata, options: Partial<grpc.CallOptions>, callback: (error: grpc.ServiceError | null, response: MonsterStorage_fbs.Stat) => void): grpc.ClientUnaryCall;
- Retrieve(request: MonsterStorage_fbs.Stat, metadata: grpc.Metadata): grpc.ClientReadableStream<MonsterStorage_fbs.Monster>;
- Retrieve(request: MonsterStorage_fbs.Stat, options: Partial<grpc.CallOptions>): grpc.ClientReadableStream<MonsterStorage_fbs.Monster>;
- GetMaxHitPoint(callback: (error: grpc.ServiceError | null, response: MonsterStorage_fbs.Monster) => void): grpc.ClientWritableStream<MonsterStorage_fbs.Stat>;
- GetMaxHitPoint(metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: MonsterStorage_fbs.Monster) => void): grpc.ClientWritableStream<MonsterStorage_fbs.Stat>;
- GetMaxHitPoint(options: Partial<grpc.CallOptions>, callback: (error: grpc.ServiceError | null, response: MonsterStorage_fbs.Monster) => void): grpc.ClientWritableStream<MonsterStorage_fbs.Stat>;
- GetMaxHitPoint(metadata: grpc.Metadata, options: Partial<grpc.CallOptions>, callback: (error: grpc.ServiceError | null, response: MonsterStorage_fbs.Monster) => void): grpc.ClientWritableStream<MonsterStorage_fbs.Stat>;
- GetMinMaxHitPoints(): grpc.ClientDuplexStream<MonsterStorage_fbs.Monster, MonsterStorage_fbs.Stat>;
- GetMinMaxHitPoints(options: Partial<grpc.CallOptions>): grpc.ClientDuplexStream<MonsterStorage_fbs.Monster, MonsterStorage_fbs.Stat>;
- GetMinMaxHitPoints(metadata: grpc.Metadata, options?: Partial<grpc.CallOptions>): grpc.ClientDuplexStream<MonsterStorage_fbs.Monster, MonsterStorage_fbs.Stat>;
-}
-
-export class MonsterStorageClient extends grpc.Client implements IMonsterStorageClient {
- constructor(address: string, credentials: grpc.ChannelCredentials, options?: object); public Store(request: MonsterStorage_fbs.Monster, callback: (error: grpc.ServiceError | null, response: MonsterStorage_fbs.Stat) => void): grpc.ClientUnaryCall;
- public Store(request: MonsterStorage_fbs.Monster, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: MonsterStorage_fbs.Stat) => void): grpc.ClientUnaryCall;
- public Store(request: MonsterStorage_fbs.Monster, metadata: grpc.Metadata, options: Partial<grpc.CallOptions>, callback: (error: grpc.ServiceError | null, response: MonsterStorage_fbs.Stat) => void): grpc.ClientUnaryCall;
- public Retrieve(request: MonsterStorage_fbs.Stat, metadata: grpc.Metadata): grpc.ClientReadableStream<MonsterStorage_fbs.Monster>;
- public Retrieve(request: MonsterStorage_fbs.Stat, options: Partial<grpc.CallOptions>): grpc.ClientReadableStream<MonsterStorage_fbs.Monster>;
- public GetMaxHitPoint(callback: (error: grpc.ServiceError | null, response: MonsterStorage_fbs.Monster) => void): grpc.ClientWritableStream<MonsterStorage_fbs.Stat>;
- public GetMaxHitPoint(metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: MonsterStorage_fbs.Monster) => void): grpc.ClientWritableStream<MonsterStorage_fbs.Stat>;
- public GetMaxHitPoint(options: Partial<grpc.CallOptions>, callback: (error: grpc.ServiceError | null, response: MonsterStorage_fbs.Monster) => void): grpc.ClientWritableStream<MonsterStorage_fbs.Stat>;
- public GetMaxHitPoint(metadata: grpc.Metadata, options: Partial<grpc.CallOptions>, callback: (error: grpc.ServiceError | null, response: MonsterStorage_fbs.Monster) => void): grpc.ClientWritableStream<MonsterStorage_fbs.Stat>;
- public GetMinMaxHitPoints(): grpc.ClientDuplexStream<MonsterStorage_fbs.Monster, MonsterStorage_fbs.Stat>;
- public GetMinMaxHitPoints(options: Partial<grpc.CallOptions>): grpc.ClientDuplexStream<MonsterStorage_fbs.Monster, MonsterStorage_fbs.Stat>;
- public GetMinMaxHitPoints(metadata: grpc.Metadata, options?: Partial<grpc.CallOptions>): grpc.ClientDuplexStream<MonsterStorage_fbs.Monster, MonsterStorage_fbs.Stat>;
-}
-
diff --git a/tests/monster_test_grpc.js b/tests/monster_test_grpc.js
deleted file mode 100644
index c12d7895..00000000
--- a/tests/monster_test_grpc.js
+++ /dev/null
@@ -1,79 +0,0 @@
-// Generated GRPC code for FlatBuffers TS *** DO NOT EDIT ***
-import { flatbuffers } from 'flatbuffers';
-import * as MonsterStorage_fbs from './monster_test_generated';
-
-var grpc = require('grpc');
-
-function serialize_Stat(buffer_args) {
- if (!(buffer_args instanceof MonsterStorage_fbs.Stat)) {
- throw new Error('Expected argument of type MonsterStorage_fbs.Stat');
- }
- return buffer_args.serialize();
-}
-
-function deserialize_Stat(buffer) {
- return MonsterStorage_fbs.Stat.getRootAsStat(new flatbuffers.ByteBuffer(buffer))
-}
-
-
-function serialize_Monster(buffer_args) {
- if (!(buffer_args instanceof MonsterStorage_fbs.Monster)) {
- throw new Error('Expected argument of type MonsterStorage_fbs.Monster');
- }
- return buffer_args.serialize();
-}
-
-function deserialize_Monster(buffer) {
- return MonsterStorage_fbs.Monster.getRootAsMonster(new flatbuffers.ByteBuffer(buffer))
-}
-
-
-
-
-var MonsterStorageService = exports.MonsterStorageService = {
- Store: {
- path: '/MyGame.Example.MonsterStorage/Store',
- requestStream: false,
- responseStream: false,
- requestType: flatbuffers.ByteBuffer,
- responseType: MonsterStorage_fbs.Stat,
- requestSerialize: serialize_Monster,
- requestDeserialize: deserialize_Monster,
- responseSerialize: serialize_Stat,
- responseDeserialize: deserialize_Stat,
- },
- Retrieve: {
- path: '/MyGame.Example.MonsterStorage/Retrieve',
- requestStream: false,
- responseStream: true,
- requestType: flatbuffers.ByteBuffer,
- responseType: MonsterStorage_fbs.Monster,
- requestSerialize: serialize_Stat,
- requestDeserialize: deserialize_Stat,
- responseSerialize: serialize_Monster,
- responseDeserialize: deserialize_Monster,
- },
- GetMaxHitPoint: {
- path: '/MyGame.Example.MonsterStorage/GetMaxHitPoint',
- requestStream: true,
- responseStream: false,
- requestType: flatbuffers.ByteBuffer,
- responseType: MonsterStorage_fbs.Stat,
- requestSerialize: serialize_Monster,
- requestDeserialize: deserialize_Monster,
- responseSerialize: serialize_Stat,
- responseDeserialize: deserialize_Stat,
- },
- GetMinMaxHitPoints: {
- path: '/MyGame.Example.MonsterStorage/GetMinMaxHitPoints',
- requestStream: true,
- responseStream: true,
- requestType: flatbuffers.ByteBuffer,
- responseType: MonsterStorage_fbs.Stat,
- requestSerialize: serialize_Monster,
- requestDeserialize: deserialize_Monster,
- responseSerialize: serialize_Stat,
- responseDeserialize: deserialize_Stat,
- },
-};
-exports.MonsterStorageClient = grpc.makeGenericClientConstructor(MonsterStorageService);
diff --git a/tests/optional_scalars_generated.js b/tests/optional_scalars_generated.js
deleted file mode 100644
index 60a25a09..00000000
--- a/tests/optional_scalars_generated.js
+++ /dev/null
@@ -1,782 +0,0 @@
-// automatically generated by the FlatBuffers compiler, do not modify
-
-/**
- * @const
- * @namespace
- */
-var optional_scalars = optional_scalars || {};
-
-/**
- * @enum {number}
- */
-optional_scalars.OptionalByte = {
- None: 0,
- One: 1,
- Two: 2
-};
-
-/**
- * @enum {string}
- */
-optional_scalars.OptionalByteName = {
- '0': 'None',
- '1': 'One',
- '2': 'Two'
-};
-
-/**
- * @constructor
- */
-optional_scalars.ScalarStuff = function() {
- /**
- * @type {flatbuffers.ByteBuffer}
- */
- this.bb = null;
-
- /**
- * @type {number}
- */
- this.bb_pos = 0;
-};
-
-/**
- * @param {number} i
- * @param {flatbuffers.ByteBuffer} bb
- * @returns {optional_scalars.ScalarStuff}
- */
-optional_scalars.ScalarStuff.prototype.__init = function(i, bb) {
- this.bb_pos = i;
- this.bb = bb;
- return this;
-};
-
-/**
- * @param {flatbuffers.ByteBuffer} bb
- * @param {optional_scalars.ScalarStuff=} obj
- * @returns {optional_scalars.ScalarStuff}
- */
-optional_scalars.ScalarStuff.getRootAsScalarStuff = function(bb, obj) {
- return (obj || new optional_scalars.ScalarStuff).__init(bb.readInt32(bb.position()) + bb.position(), bb);
-};
-
-/**
- * @param {flatbuffers.ByteBuffer} bb
- * @param {optional_scalars.ScalarStuff=} obj
- * @returns {optional_scalars.ScalarStuff}
- */
-optional_scalars.ScalarStuff.getSizePrefixedRootAsScalarStuff = function(bb, obj) {
- bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
- return (obj || new optional_scalars.ScalarStuff).__init(bb.readInt32(bb.position()) + bb.position(), bb);
-};
-
-/**
- * @param {flatbuffers.ByteBuffer} bb
- * @returns {boolean}
- */
-optional_scalars.ScalarStuff.bufferHasIdentifier = function(bb) {
- return bb.__has_identifier('NULL');
-};
-
-/**
- * @returns {number}
- */
-optional_scalars.ScalarStuff.prototype.justI8 = function() {
- var offset = this.bb.__offset(this.bb_pos, 4);
- return offset ? this.bb.readInt8(this.bb_pos + offset) : 0;
-};
-
-/**
- * @returns {number|null}
- */
-optional_scalars.ScalarStuff.prototype.maybeI8 = function() {
- var offset = this.bb.__offset(this.bb_pos, 6);
- return offset ? this.bb.readInt8(this.bb_pos + offset) : null;
-};
-
-/**
- * @returns {number}
- */
-optional_scalars.ScalarStuff.prototype.defaultI8 = function() {
- var offset = this.bb.__offset(this.bb_pos, 8);
- return offset ? this.bb.readInt8(this.bb_pos + offset) : 42;
-};
-
-/**
- * @returns {number}
- */
-optional_scalars.ScalarStuff.prototype.justU8 = function() {
- var offset = this.bb.__offset(this.bb_pos, 10);
- return offset ? this.bb.readUint8(this.bb_pos + offset) : 0;
-};
-
-/**
- * @returns {number|null}
- */
-optional_scalars.ScalarStuff.prototype.maybeU8 = function() {
- var offset = this.bb.__offset(this.bb_pos, 12);
- return offset ? this.bb.readUint8(this.bb_pos + offset) : null;
-};
-
-/**
- * @returns {number}
- */
-optional_scalars.ScalarStuff.prototype.defaultU8 = function() {
- var offset = this.bb.__offset(this.bb_pos, 14);
- return offset ? this.bb.readUint8(this.bb_pos + offset) : 42;
-};
-
-/**
- * @returns {number}
- */
-optional_scalars.ScalarStuff.prototype.justI16 = function() {
- var offset = this.bb.__offset(this.bb_pos, 16);
- return offset ? this.bb.readInt16(this.bb_pos + offset) : 0;
-};
-
-/**
- * @returns {number|null}
- */
-optional_scalars.ScalarStuff.prototype.maybeI16 = function() {
- var offset = this.bb.__offset(this.bb_pos, 18);
- return offset ? this.bb.readInt16(this.bb_pos + offset) : null;
-};
-
-/**
- * @returns {number}
- */
-optional_scalars.ScalarStuff.prototype.defaultI16 = function() {
- var offset = this.bb.__offset(this.bb_pos, 20);
- return offset ? this.bb.readInt16(this.bb_pos + offset) : 42;
-};
-
-/**
- * @returns {number}
- */
-optional_scalars.ScalarStuff.prototype.justU16 = function() {
- var offset = this.bb.__offset(this.bb_pos, 22);
- return offset ? this.bb.readUint16(this.bb_pos + offset) : 0;
-};
-
-/**
- * @returns {number|null}
- */
-optional_scalars.ScalarStuff.prototype.maybeU16 = function() {
- var offset = this.bb.__offset(this.bb_pos, 24);
- return offset ? this.bb.readUint16(this.bb_pos + offset) : null;
-};
-
-/**
- * @returns {number}
- */
-optional_scalars.ScalarStuff.prototype.defaultU16 = function() {
- var offset = this.bb.__offset(this.bb_pos, 26);
- return offset ? this.bb.readUint16(this.bb_pos + offset) : 42;
-};
-
-/**
- * @returns {number}
- */
-optional_scalars.ScalarStuff.prototype.justI32 = function() {
- var offset = this.bb.__offset(this.bb_pos, 28);
- return offset ? this.bb.readInt32(this.bb_pos + offset) : 0;
-};
-
-/**
- * @returns {number|null}
- */
-optional_scalars.ScalarStuff.prototype.maybeI32 = function() {
- var offset = this.bb.__offset(this.bb_pos, 30);
- return offset ? this.bb.readInt32(this.bb_pos + offset) : null;
-};
-
-/**
- * @returns {number}
- */
-optional_scalars.ScalarStuff.prototype.defaultI32 = function() {
- var offset = this.bb.__offset(this.bb_pos, 32);
- return offset ? this.bb.readInt32(this.bb_pos + offset) : 42;
-};
-
-/**
- * @returns {number}
- */
-optional_scalars.ScalarStuff.prototype.justU32 = function() {
- var offset = this.bb.__offset(this.bb_pos, 34);
- return offset ? this.bb.readUint32(this.bb_pos + offset) : 0;
-};
-
-/**
- * @returns {number|null}
- */
-optional_scalars.ScalarStuff.prototype.maybeU32 = function() {
- var offset = this.bb.__offset(this.bb_pos, 36);
- return offset ? this.bb.readUint32(this.bb_pos + offset) : null;
-};
-
-/**
- * @returns {number}
- */
-optional_scalars.ScalarStuff.prototype.defaultU32 = function() {
- var offset = this.bb.__offset(this.bb_pos, 38);
- return offset ? this.bb.readUint32(this.bb_pos + offset) : 42;
-};
-
-/**
- * @returns {flatbuffers.Long}
- */
-optional_scalars.ScalarStuff.prototype.justI64 = function() {
- var offset = this.bb.__offset(this.bb_pos, 40);
- return offset ? this.bb.readInt64(this.bb_pos + offset) : this.bb.createLong(0, 0);
-};
-
-/**
- * @returns {flatbuffers.Long|null}
- */
-optional_scalars.ScalarStuff.prototype.maybeI64 = function() {
- var offset = this.bb.__offset(this.bb_pos, 42);
- return offset ? this.bb.readInt64(this.bb_pos + offset) : null;
-};
-
-/**
- * @returns {flatbuffers.Long}
- */
-optional_scalars.ScalarStuff.prototype.defaultI64 = function() {
- var offset = this.bb.__offset(this.bb_pos, 44);
- return offset ? this.bb.readInt64(this.bb_pos + offset) : this.bb.createLong(42, 0);
-};
-
-/**
- * @returns {flatbuffers.Long}
- */
-optional_scalars.ScalarStuff.prototype.justU64 = function() {
- var offset = this.bb.__offset(this.bb_pos, 46);
- return offset ? this.bb.readUint64(this.bb_pos + offset) : this.bb.createLong(0, 0);
-};
-
-/**
- * @returns {flatbuffers.Long|null}
- */
-optional_scalars.ScalarStuff.prototype.maybeU64 = function() {
- var offset = this.bb.__offset(this.bb_pos, 48);
- return offset ? this.bb.readUint64(this.bb_pos + offset) : null;
-};
-
-/**
- * @returns {flatbuffers.Long}
- */
-optional_scalars.ScalarStuff.prototype.defaultU64 = function() {
- var offset = this.bb.__offset(this.bb_pos, 50);
- return offset ? this.bb.readUint64(this.bb_pos + offset) : this.bb.createLong(42, 0);
-};
-
-/**
- * @returns {number}
- */
-optional_scalars.ScalarStuff.prototype.justF32 = function() {
- var offset = this.bb.__offset(this.bb_pos, 52);
- return offset ? this.bb.readFloat32(this.bb_pos + offset) : 0.0;
-};
-
-/**
- * @returns {number|null}
- */
-optional_scalars.ScalarStuff.prototype.maybeF32 = function() {
- var offset = this.bb.__offset(this.bb_pos, 54);
- return offset ? this.bb.readFloat32(this.bb_pos + offset) : null;
-};
-
-/**
- * @returns {number}
- */
-optional_scalars.ScalarStuff.prototype.defaultF32 = function() {
- var offset = this.bb.__offset(this.bb_pos, 56);
- return offset ? this.bb.readFloat32(this.bb_pos + offset) : 42.0;
-};
-
-/**
- * @returns {number}
- */
-optional_scalars.ScalarStuff.prototype.justF64 = function() {
- var offset = this.bb.__offset(this.bb_pos, 58);
- return offset ? this.bb.readFloat64(this.bb_pos + offset) : 0.0;
-};
-
-/**
- * @returns {number|null}
- */
-optional_scalars.ScalarStuff.prototype.maybeF64 = function() {
- var offset = this.bb.__offset(this.bb_pos, 60);
- return offset ? this.bb.readFloat64(this.bb_pos + offset) : null;
-};
-
-/**
- * @returns {number}
- */
-optional_scalars.ScalarStuff.prototype.defaultF64 = function() {
- var offset = this.bb.__offset(this.bb_pos, 62);
- return offset ? this.bb.readFloat64(this.bb_pos + offset) : 42.0;
-};
-
-/**
- * @returns {boolean}
- */
-optional_scalars.ScalarStuff.prototype.justBool = function() {
- var offset = this.bb.__offset(this.bb_pos, 64);
- return offset ? !!this.bb.readInt8(this.bb_pos + offset) : false;
-};
-
-/**
- * @returns {boolean|null}
- */
-optional_scalars.ScalarStuff.prototype.maybeBool = function() {
- var offset = this.bb.__offset(this.bb_pos, 66);
- return offset ? !!this.bb.readInt8(this.bb_pos + offset) : null;
-};
-
-/**
- * @returns {boolean}
- */
-optional_scalars.ScalarStuff.prototype.defaultBool = function() {
- var offset = this.bb.__offset(this.bb_pos, 68);
- return offset ? !!this.bb.readInt8(this.bb_pos + offset) : true;
-};
-
-/**
- * @returns {optional_scalars.OptionalByte}
- */
-optional_scalars.ScalarStuff.prototype.justEnum = function() {
- var offset = this.bb.__offset(this.bb_pos, 70);
- return offset ? /** @type {optional_scalars.OptionalByte} */ (this.bb.readInt8(this.bb_pos + offset)) : optional_scalars.OptionalByte.None;
-};
-
-/**
- * @returns {optional_scalars.OptionalByte|null}
- */
-optional_scalars.ScalarStuff.prototype.maybeEnum = function() {
- var offset = this.bb.__offset(this.bb_pos, 72);
- return offset ? /** @type {optional_scalars.OptionalByte} */ (this.bb.readInt8(this.bb_pos + offset)) : null;
-};
-
-/**
- * @returns {optional_scalars.OptionalByte}
- */
-optional_scalars.ScalarStuff.prototype.defaultEnum = function() {
- var offset = this.bb.__offset(this.bb_pos, 74);
- return offset ? /** @type {optional_scalars.OptionalByte} */ (this.bb.readInt8(this.bb_pos + offset)) : optional_scalars.OptionalByte.One;
-};
-
-/**
- * @param {flatbuffers.Builder} builder
- */
-optional_scalars.ScalarStuff.startScalarStuff = function(builder) {
- builder.startObject(36);
-};
-
-/**
- * @param {flatbuffers.Builder} builder
- * @param {number} justI8
- */
-optional_scalars.ScalarStuff.addJustI8 = function(builder, justI8) {
- builder.addFieldInt8(0, justI8, 0);
-};
-
-/**
- * @param {flatbuffers.Builder} builder
- * @param {number} maybeI8
- */
-optional_scalars.ScalarStuff.addMaybeI8 = function(builder, maybeI8) {
- builder.addFieldInt8(1, maybeI8, 0);
-};
-
-/**
- * @param {flatbuffers.Builder} builder
- * @param {number} defaultI8
- */
-optional_scalars.ScalarStuff.addDefaultI8 = function(builder, defaultI8) {
- builder.addFieldInt8(2, defaultI8, 42);
-};
-
-/**
- * @param {flatbuffers.Builder} builder
- * @param {number} justU8
- */
-optional_scalars.ScalarStuff.addJustU8 = function(builder, justU8) {
- builder.addFieldInt8(3, justU8, 0);
-};
-
-/**
- * @param {flatbuffers.Builder} builder
- * @param {number} maybeU8
- */
-optional_scalars.ScalarStuff.addMaybeU8 = function(builder, maybeU8) {
- builder.addFieldInt8(4, maybeU8, 0);
-};
-
-/**
- * @param {flatbuffers.Builder} builder
- * @param {number} defaultU8
- */
-optional_scalars.ScalarStuff.addDefaultU8 = function(builder, defaultU8) {
- builder.addFieldInt8(5, defaultU8, 42);
-};
-
-/**
- * @param {flatbuffers.Builder} builder
- * @param {number} justI16
- */
-optional_scalars.ScalarStuff.addJustI16 = function(builder, justI16) {
- builder.addFieldInt16(6, justI16, 0);
-};
-
-/**
- * @param {flatbuffers.Builder} builder
- * @param {number} maybeI16
- */
-optional_scalars.ScalarStuff.addMaybeI16 = function(builder, maybeI16) {
- builder.addFieldInt16(7, maybeI16, 0);
-};
-
-/**
- * @param {flatbuffers.Builder} builder
- * @param {number} defaultI16
- */
-optional_scalars.ScalarStuff.addDefaultI16 = function(builder, defaultI16) {
- builder.addFieldInt16(8, defaultI16, 42);
-};
-
-/**
- * @param {flatbuffers.Builder} builder
- * @param {number} justU16
- */
-optional_scalars.ScalarStuff.addJustU16 = function(builder, justU16) {
- builder.addFieldInt16(9, justU16, 0);
-};
-
-/**
- * @param {flatbuffers.Builder} builder
- * @param {number} maybeU16
- */
-optional_scalars.ScalarStuff.addMaybeU16 = function(builder, maybeU16) {
- builder.addFieldInt16(10, maybeU16, 0);
-};
-
-/**
- * @param {flatbuffers.Builder} builder
- * @param {number} defaultU16
- */
-optional_scalars.ScalarStuff.addDefaultU16 = function(builder, defaultU16) {
- builder.addFieldInt16(11, defaultU16, 42);
-};
-
-/**
- * @param {flatbuffers.Builder} builder
- * @param {number} justI32
- */
-optional_scalars.ScalarStuff.addJustI32 = function(builder, justI32) {
- builder.addFieldInt32(12, justI32, 0);
-};
-
-/**
- * @param {flatbuffers.Builder} builder
- * @param {number} maybeI32
- */
-optional_scalars.ScalarStuff.addMaybeI32 = function(builder, maybeI32) {
- builder.addFieldInt32(13, maybeI32, 0);
-};
-
-/**
- * @param {flatbuffers.Builder} builder
- * @param {number} defaultI32
- */
-optional_scalars.ScalarStuff.addDefaultI32 = function(builder, defaultI32) {
- builder.addFieldInt32(14, defaultI32, 42);
-};
-
-/**
- * @param {flatbuffers.Builder} builder
- * @param {number} justU32
- */
-optional_scalars.ScalarStuff.addJustU32 = function(builder, justU32) {
- builder.addFieldInt32(15, justU32, 0);
-};
-
-/**
- * @param {flatbuffers.Builder} builder
- * @param {number} maybeU32
- */
-optional_scalars.ScalarStuff.addMaybeU32 = function(builder, maybeU32) {
- builder.addFieldInt32(16, maybeU32, 0);
-};
-
-/**
- * @param {flatbuffers.Builder} builder
- * @param {number} defaultU32
- */
-optional_scalars.ScalarStuff.addDefaultU32 = function(builder, defaultU32) {
- builder.addFieldInt32(17, defaultU32, 42);
-};
-
-/**
- * @param {flatbuffers.Builder} builder
- * @param {flatbuffers.Long} justI64
- */
-optional_scalars.ScalarStuff.addJustI64 = function(builder, justI64) {
- builder.addFieldInt64(18, justI64, builder.createLong(0, 0));
-};
-
-/**
- * @param {flatbuffers.Builder} builder
- * @param {flatbuffers.Long} maybeI64
- */
-optional_scalars.ScalarStuff.addMaybeI64 = function(builder, maybeI64) {
- builder.addFieldInt64(19, maybeI64, builder.createLong(0, 0));
-};
-
-/**
- * @param {flatbuffers.Builder} builder
- * @param {flatbuffers.Long} defaultI64
- */
-optional_scalars.ScalarStuff.addDefaultI64 = function(builder, defaultI64) {
- builder.addFieldInt64(20, defaultI64, builder.createLong(42, 0));
-};
-
-/**
- * @param {flatbuffers.Builder} builder
- * @param {flatbuffers.Long} justU64
- */
-optional_scalars.ScalarStuff.addJustU64 = function(builder, justU64) {
- builder.addFieldInt64(21, justU64, builder.createLong(0, 0));
-};
-
-/**
- * @param {flatbuffers.Builder} builder
- * @param {flatbuffers.Long} maybeU64
- */
-optional_scalars.ScalarStuff.addMaybeU64 = function(builder, maybeU64) {
- builder.addFieldInt64(22, maybeU64, builder.createLong(0, 0));
-};
-
-/**
- * @param {flatbuffers.Builder} builder
- * @param {flatbuffers.Long} defaultU64
- */
-optional_scalars.ScalarStuff.addDefaultU64 = function(builder, defaultU64) {
- builder.addFieldInt64(23, defaultU64, builder.createLong(42, 0));
-};
-
-/**
- * @param {flatbuffers.Builder} builder
- * @param {number} justF32
- */
-optional_scalars.ScalarStuff.addJustF32 = function(builder, justF32) {
- builder.addFieldFloat32(24, justF32, 0.0);
-};
-
-/**
- * @param {flatbuffers.Builder} builder
- * @param {number} maybeF32
- */
-optional_scalars.ScalarStuff.addMaybeF32 = function(builder, maybeF32) {
- builder.addFieldFloat32(25, maybeF32, 0);
-};
-
-/**
- * @param {flatbuffers.Builder} builder
- * @param {number} defaultF32
- */
-optional_scalars.ScalarStuff.addDefaultF32 = function(builder, defaultF32) {
- builder.addFieldFloat32(26, defaultF32, 42.0);
-};
-
-/**
- * @param {flatbuffers.Builder} builder
- * @param {number} justF64
- */
-optional_scalars.ScalarStuff.addJustF64 = function(builder, justF64) {
- builder.addFieldFloat64(27, justF64, 0.0);
-};
-
-/**
- * @param {flatbuffers.Builder} builder
- * @param {number} maybeF64
- */
-optional_scalars.ScalarStuff.addMaybeF64 = function(builder, maybeF64) {
- builder.addFieldFloat64(28, maybeF64, 0);
-};
-
-/**
- * @param {flatbuffers.Builder} builder
- * @param {number} defaultF64
- */
-optional_scalars.ScalarStuff.addDefaultF64 = function(builder, defaultF64) {
- builder.addFieldFloat64(29, defaultF64, 42.0);
-};
-
-/**
- * @param {flatbuffers.Builder} builder
- * @param {boolean} justBool
- */
-optional_scalars.ScalarStuff.addJustBool = function(builder, justBool) {
- builder.addFieldInt8(30, +justBool, +false);
-};
-
-/**
- * @param {flatbuffers.Builder} builder
- * @param {boolean} maybeBool
- */
-optional_scalars.ScalarStuff.addMaybeBool = function(builder, maybeBool) {
- builder.addFieldInt8(31, +maybeBool, 0);
-};
-
-/**
- * @param {flatbuffers.Builder} builder
- * @param {boolean} defaultBool
- */
-optional_scalars.ScalarStuff.addDefaultBool = function(builder, defaultBool) {
- builder.addFieldInt8(32, +defaultBool, +true);
-};
-
-/**
- * @param {flatbuffers.Builder} builder
- * @param {optional_scalars.OptionalByte} justEnum
- */
-optional_scalars.ScalarStuff.addJustEnum = function(builder, justEnum) {
- builder.addFieldInt8(33, justEnum, optional_scalars.OptionalByte.None);
-};
-
-/**
- * @param {flatbuffers.Builder} builder
- * @param {optional_scalars.OptionalByte} maybeEnum
- */
-optional_scalars.ScalarStuff.addMaybeEnum = function(builder, maybeEnum) {
- builder.addFieldInt8(34, maybeEnum, 0);
-};
-
-/**
- * @param {flatbuffers.Builder} builder
- * @param {optional_scalars.OptionalByte} defaultEnum
- */
-optional_scalars.ScalarStuff.addDefaultEnum = function(builder, defaultEnum) {
- builder.addFieldInt8(35, defaultEnum, optional_scalars.OptionalByte.One);
-};
-
-/**
- * @param {flatbuffers.Builder} builder
- * @returns {flatbuffers.Offset}
- */
-optional_scalars.ScalarStuff.endScalarStuff = function(builder) {
- var offset = builder.endObject();
- return offset;
-};
-
-/**
- * @param {flatbuffers.Builder} builder
- * @param {flatbuffers.Offset} offset
- */
-optional_scalars.ScalarStuff.finishScalarStuffBuffer = function(builder, offset) {
- builder.finish(offset, 'NULL');
-};
-
-/**
- * @param {flatbuffers.Builder} builder
- * @param {flatbuffers.Offset} offset
- */
-optional_scalars.ScalarStuff.finishSizePrefixedScalarStuffBuffer = function(builder, offset) {
- builder.finish(offset, 'NULL', true);
-};
-
-/**
- * @param {flatbuffers.Builder} builder
- * @param {number} justI8
- * @param {number|null} maybeI8
- * @param {number} defaultI8
- * @param {number} justU8
- * @param {number|null} maybeU8
- * @param {number} defaultU8
- * @param {number} justI16
- * @param {number|null} maybeI16
- * @param {number} defaultI16
- * @param {number} justU16
- * @param {number|null} maybeU16
- * @param {number} defaultU16
- * @param {number} justI32
- * @param {number|null} maybeI32
- * @param {number} defaultI32
- * @param {number} justU32
- * @param {number|null} maybeU32
- * @param {number} defaultU32
- * @param {flatbuffers.Long} justI64
- * @param {flatbuffers.Long|null} maybeI64
- * @param {flatbuffers.Long} defaultI64
- * @param {flatbuffers.Long} justU64
- * @param {flatbuffers.Long|null} maybeU64
- * @param {flatbuffers.Long} defaultU64
- * @param {number} justF32
- * @param {number|null} maybeF32
- * @param {number} defaultF32
- * @param {number} justF64
- * @param {number|null} maybeF64
- * @param {number} defaultF64
- * @param {boolean} justBool
- * @param {boolean|null} maybeBool
- * @param {boolean} defaultBool
- * @param {optional_scalars.OptionalByte} justEnum
- * @param {optional_scalars.OptionalByte|null} maybeEnum
- * @param {optional_scalars.OptionalByte} defaultEnum
- * @returns {flatbuffers.Offset}
- */
-optional_scalars.ScalarStuff.createScalarStuff = function(builder, justI8, maybeI8, defaultI8, justU8, maybeU8, defaultU8, justI16, maybeI16, defaultI16, justU16, maybeU16, defaultU16, justI32, maybeI32, defaultI32, justU32, maybeU32, defaultU32, justI64, maybeI64, defaultI64, justU64, maybeU64, defaultU64, justF32, maybeF32, defaultF32, justF64, maybeF64, defaultF64, justBool, maybeBool, defaultBool, justEnum, maybeEnum, defaultEnum) {
- optional_scalars.ScalarStuff.startScalarStuff(builder);
- optional_scalars.ScalarStuff.addJustI8(builder, justI8);
- if (maybeI8 !== null)
- optional_scalars.ScalarStuff.addMaybeI8(builder, maybeI8);
- optional_scalars.ScalarStuff.addDefaultI8(builder, defaultI8);
- optional_scalars.ScalarStuff.addJustU8(builder, justU8);
- if (maybeU8 !== null)
- optional_scalars.ScalarStuff.addMaybeU8(builder, maybeU8);
- optional_scalars.ScalarStuff.addDefaultU8(builder, defaultU8);
- optional_scalars.ScalarStuff.addJustI16(builder, justI16);
- if (maybeI16 !== null)
- optional_scalars.ScalarStuff.addMaybeI16(builder, maybeI16);
- optional_scalars.ScalarStuff.addDefaultI16(builder, defaultI16);
- optional_scalars.ScalarStuff.addJustU16(builder, justU16);
- if (maybeU16 !== null)
- optional_scalars.ScalarStuff.addMaybeU16(builder, maybeU16);
- optional_scalars.ScalarStuff.addDefaultU16(builder, defaultU16);
- optional_scalars.ScalarStuff.addJustI32(builder, justI32);
- if (maybeI32 !== null)
- optional_scalars.ScalarStuff.addMaybeI32(builder, maybeI32);
- optional_scalars.ScalarStuff.addDefaultI32(builder, defaultI32);
- optional_scalars.ScalarStuff.addJustU32(builder, justU32);
- if (maybeU32 !== null)
- optional_scalars.ScalarStuff.addMaybeU32(builder, maybeU32);
- optional_scalars.ScalarStuff.addDefaultU32(builder, defaultU32);
- optional_scalars.ScalarStuff.addJustI64(builder, justI64);
- if (maybeI64 !== null)
- optional_scalars.ScalarStuff.addMaybeI64(builder, maybeI64);
- optional_scalars.ScalarStuff.addDefaultI64(builder, defaultI64);
- optional_scalars.ScalarStuff.addJustU64(builder, justU64);
- if (maybeU64 !== null)
- optional_scalars.ScalarStuff.addMaybeU64(builder, maybeU64);
- optional_scalars.ScalarStuff.addDefaultU64(builder, defaultU64);
- optional_scalars.ScalarStuff.addJustF32(builder, justF32);
- if (maybeF32 !== null)
- optional_scalars.ScalarStuff.addMaybeF32(builder, maybeF32);
- optional_scalars.ScalarStuff.addDefaultF32(builder, defaultF32);
- optional_scalars.ScalarStuff.addJustF64(builder, justF64);
- if (maybeF64 !== null)
- optional_scalars.ScalarStuff.addMaybeF64(builder, maybeF64);
- optional_scalars.ScalarStuff.addDefaultF64(builder, defaultF64);
- optional_scalars.ScalarStuff.addJustBool(builder, justBool);
- if (maybeBool !== null)
- optional_scalars.ScalarStuff.addMaybeBool(builder, maybeBool);
- optional_scalars.ScalarStuff.addDefaultBool(builder, defaultBool);
- optional_scalars.ScalarStuff.addJustEnum(builder, justEnum);
- if (maybeEnum !== null)
- optional_scalars.ScalarStuff.addMaybeEnum(builder, maybeEnum);
- optional_scalars.ScalarStuff.addDefaultEnum(builder, defaultEnum);
- return optional_scalars.ScalarStuff.endScalarStuff(builder);
-}
-
-// Exports for Node.js and RequireJS
-this.optional_scalars = optional_scalars;
diff --git a/tests/optional_scalars_generated.ts b/tests/optional_scalars_generated.ts
deleted file mode 100644
index 668da8bb..00000000
--- a/tests/optional_scalars_generated.ts
+++ /dev/null
@@ -1,722 +0,0 @@
-// automatically generated by the FlatBuffers compiler, do not modify
-
-import * as flatbuffers from 'flatbuffers';
-/**
- * @enum {number}
- */
-export namespace optional_scalars{
-export enum OptionalByte{
- None= 0,
- One= 1,
- Two= 2
-};
-}
-
-/**
- * @constructor
- */
-export namespace optional_scalars{
-export class ScalarStuff {
- bb: flatbuffers.ByteBuffer|null = null;
-
- bb_pos:number = 0;
-/**
- * @param number i
- * @param flatbuffers.ByteBuffer bb
- * @returns ScalarStuff
- */
-__init(i:number, bb:flatbuffers.ByteBuffer):ScalarStuff {
- this.bb_pos = i;
- this.bb = bb;
- return this;
-};
-
-/**
- * @param flatbuffers.ByteBuffer bb
- * @param ScalarStuff= obj
- * @returns ScalarStuff
- */
-static getRootAsScalarStuff(bb:flatbuffers.ByteBuffer, obj?:ScalarStuff):ScalarStuff {
- return (obj || new ScalarStuff()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
-};
-
-/**
- * @param flatbuffers.ByteBuffer bb
- * @param ScalarStuff= obj
- * @returns ScalarStuff
- */
-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);
-};
-
-/**
- * @param flatbuffers.ByteBuffer bb
- * @returns boolean
- */
-static bufferHasIdentifier(bb:flatbuffers.ByteBuffer):boolean {
- return bb.__has_identifier('NULL');
-};
-
-/**
- * @returns number
- */
-justI8():number {
- var offset = this.bb!.__offset(this.bb_pos, 4);
- return offset ? this.bb!.readInt8(this.bb_pos + offset) : 0;
-};
-
-/**
- * @returns number|null
- */
-maybeI8():number|null {
- var offset = this.bb!.__offset(this.bb_pos, 6);
- return offset ? this.bb!.readInt8(this.bb_pos + offset) : null;
-};
-
-/**
- * @returns number
- */
-defaultI8():number {
- var offset = this.bb!.__offset(this.bb_pos, 8);
- return offset ? this.bb!.readInt8(this.bb_pos + offset) : 42;
-};
-
-/**
- * @returns number
- */
-justU8():number {
- var offset = this.bb!.__offset(this.bb_pos, 10);
- return offset ? this.bb!.readUint8(this.bb_pos + offset) : 0;
-};
-
-/**
- * @returns number|null
- */
-maybeU8():number|null {
- var offset = this.bb!.__offset(this.bb_pos, 12);
- return offset ? this.bb!.readUint8(this.bb_pos + offset) : null;
-};
-
-/**
- * @returns number
- */
-defaultU8():number {
- var offset = this.bb!.__offset(this.bb_pos, 14);
- return offset ? this.bb!.readUint8(this.bb_pos + offset) : 42;
-};
-
-/**
- * @returns number
- */
-justI16():number {
- var offset = this.bb!.__offset(this.bb_pos, 16);
- return offset ? this.bb!.readInt16(this.bb_pos + offset) : 0;
-};
-
-/**
- * @returns number|null
- */
-maybeI16():number|null {
- var offset = this.bb!.__offset(this.bb_pos, 18);
- return offset ? this.bb!.readInt16(this.bb_pos + offset) : null;
-};
-
-/**
- * @returns number
- */
-defaultI16():number {
- var offset = this.bb!.__offset(this.bb_pos, 20);
- return offset ? this.bb!.readInt16(this.bb_pos + offset) : 42;
-};
-
-/**
- * @returns number
- */
-justU16():number {
- var offset = this.bb!.__offset(this.bb_pos, 22);
- return offset ? this.bb!.readUint16(this.bb_pos + offset) : 0;
-};
-
-/**
- * @returns number|null
- */
-maybeU16():number|null {
- var offset = this.bb!.__offset(this.bb_pos, 24);
- return offset ? this.bb!.readUint16(this.bb_pos + offset) : null;
-};
-
-/**
- * @returns number
- */
-defaultU16():number {
- var offset = this.bb!.__offset(this.bb_pos, 26);
- return offset ? this.bb!.readUint16(this.bb_pos + offset) : 42;
-};
-
-/**
- * @returns number
- */
-justI32():number {
- var offset = this.bb!.__offset(this.bb_pos, 28);
- return offset ? this.bb!.readInt32(this.bb_pos + offset) : 0;
-};
-
-/**
- * @returns number|null
- */
-maybeI32():number|null {
- var offset = this.bb!.__offset(this.bb_pos, 30);
- return offset ? this.bb!.readInt32(this.bb_pos + offset) : null;
-};
-
-/**
- * @returns number
- */
-defaultI32():number {
- var offset = this.bb!.__offset(this.bb_pos, 32);
- return offset ? this.bb!.readInt32(this.bb_pos + offset) : 42;
-};
-
-/**
- * @returns number
- */
-justU32():number {
- var offset = this.bb!.__offset(this.bb_pos, 34);
- return offset ? this.bb!.readUint32(this.bb_pos + offset) : 0;
-};
-
-/**
- * @returns number|null
- */
-maybeU32():number|null {
- var offset = this.bb!.__offset(this.bb_pos, 36);
- return offset ? this.bb!.readUint32(this.bb_pos + offset) : null;
-};
-
-/**
- * @returns number
- */
-defaultU32():number {
- var offset = this.bb!.__offset(this.bb_pos, 38);
- return offset ? this.bb!.readUint32(this.bb_pos + offset) : 42;
-};
-
-/**
- * @returns flatbuffers.Long
- */
-justI64():flatbuffers.Long {
- var offset = this.bb!.__offset(this.bb_pos, 40);
- return offset ? this.bb!.readInt64(this.bb_pos + offset) : this.bb!.createLong(0, 0);
-};
-
-/**
- * @returns flatbuffers.Long|null
- */
-maybeI64():flatbuffers.Long|null {
- var offset = this.bb!.__offset(this.bb_pos, 42);
- return offset ? this.bb!.readInt64(this.bb_pos + offset) : null;
-};
-
-/**
- * @returns flatbuffers.Long
- */
-defaultI64():flatbuffers.Long {
- var offset = this.bb!.__offset(this.bb_pos, 44);
- return offset ? this.bb!.readInt64(this.bb_pos + offset) : this.bb!.createLong(42, 0);
-};
-
-/**
- * @returns flatbuffers.Long
- */
-justU64():flatbuffers.Long {
- var offset = this.bb!.__offset(this.bb_pos, 46);
- return offset ? this.bb!.readUint64(this.bb_pos + offset) : this.bb!.createLong(0, 0);
-};
-
-/**
- * @returns flatbuffers.Long|null
- */
-maybeU64():flatbuffers.Long|null {
- var offset = this.bb!.__offset(this.bb_pos, 48);
- return offset ? this.bb!.readUint64(this.bb_pos + offset) : null;
-};
-
-/**
- * @returns flatbuffers.Long
- */
-defaultU64():flatbuffers.Long {
- var offset = this.bb!.__offset(this.bb_pos, 50);
- return offset ? this.bb!.readUint64(this.bb_pos + offset) : this.bb!.createLong(42, 0);
-};
-
-/**
- * @returns number
- */
-justF32():number {
- var offset = this.bb!.__offset(this.bb_pos, 52);
- return offset ? this.bb!.readFloat32(this.bb_pos + offset) : 0.0;
-};
-
-/**
- * @returns number|null
- */
-maybeF32():number|null {
- var offset = this.bb!.__offset(this.bb_pos, 54);
- return offset ? this.bb!.readFloat32(this.bb_pos + offset) : null;
-};
-
-/**
- * @returns number
- */
-defaultF32():number {
- var offset = this.bb!.__offset(this.bb_pos, 56);
- return offset ? this.bb!.readFloat32(this.bb_pos + offset) : 42.0;
-};
-
-/**
- * @returns number
- */
-justF64():number {
- var offset = this.bb!.__offset(this.bb_pos, 58);
- return offset ? this.bb!.readFloat64(this.bb_pos + offset) : 0.0;
-};
-
-/**
- * @returns number|null
- */
-maybeF64():number|null {
- var offset = this.bb!.__offset(this.bb_pos, 60);
- return offset ? this.bb!.readFloat64(this.bb_pos + offset) : null;
-};
-
-/**
- * @returns number
- */
-defaultF64():number {
- var offset = this.bb!.__offset(this.bb_pos, 62);
- return offset ? this.bb!.readFloat64(this.bb_pos + offset) : 42.0;
-};
-
-/**
- * @returns boolean
- */
-justBool():boolean {
- var offset = this.bb!.__offset(this.bb_pos, 64);
- return offset ? !!this.bb!.readInt8(this.bb_pos + offset) : false;
-};
-
-/**
- * @returns boolean|null
- */
-maybeBool():boolean|null {
- var offset = this.bb!.__offset(this.bb_pos, 66);
- return offset ? !!this.bb!.readInt8(this.bb_pos + offset) : null;
-};
-
-/**
- * @returns boolean
- */
-defaultBool():boolean {
- var offset = this.bb!.__offset(this.bb_pos, 68);
- return offset ? !!this.bb!.readInt8(this.bb_pos + offset) : true;
-};
-
-/**
- * @returns optional_scalars.OptionalByte
- */
-justEnum():optional_scalars.OptionalByte {
- var offset = this.bb!.__offset(this.bb_pos, 70);
- return offset ? /** */ (this.bb!.readInt8(this.bb_pos + offset)) : optional_scalars.OptionalByte.None;
-};
-
-/**
- * @returns optional_scalars.OptionalByte|null
- */
-maybeEnum():optional_scalars.OptionalByte|null {
- var offset = this.bb!.__offset(this.bb_pos, 72);
- return offset ? /** */ (this.bb!.readInt8(this.bb_pos + offset)) : null;
-};
-
-/**
- * @returns optional_scalars.OptionalByte
- */
-defaultEnum():optional_scalars.OptionalByte {
- var offset = this.bb!.__offset(this.bb_pos, 74);
- return offset ? /** */ (this.bb!.readInt8(this.bb_pos + offset)) : optional_scalars.OptionalByte.One;
-};
-
-/**
- * @param flatbuffers.Builder builder
- */
-static startScalarStuff(builder:flatbuffers.Builder) {
- builder.startObject(36);
-};
-
-/**
- * @param flatbuffers.Builder builder
- * @param number justI8
- */
-static addJustI8(builder:flatbuffers.Builder, justI8:number) {
- builder.addFieldInt8(0, justI8, 0);
-};
-
-/**
- * @param flatbuffers.Builder builder
- * @param number maybeI8
- */
-static addMaybeI8(builder:flatbuffers.Builder, maybeI8:number) {
- builder.addFieldInt8(1, maybeI8, 0);
-};
-
-/**
- * @param flatbuffers.Builder builder
- * @param number defaultI8
- */
-static addDefaultI8(builder:flatbuffers.Builder, defaultI8:number) {
- builder.addFieldInt8(2, defaultI8, 42);
-};
-
-/**
- * @param flatbuffers.Builder builder
- * @param number justU8
- */
-static addJustU8(builder:flatbuffers.Builder, justU8:number) {
- builder.addFieldInt8(3, justU8, 0);
-};
-
-/**
- * @param flatbuffers.Builder builder
- * @param number maybeU8
- */
-static addMaybeU8(builder:flatbuffers.Builder, maybeU8:number) {
- builder.addFieldInt8(4, maybeU8, 0);
-};
-
-/**
- * @param flatbuffers.Builder builder
- * @param number defaultU8
- */
-static addDefaultU8(builder:flatbuffers.Builder, defaultU8:number) {
- builder.addFieldInt8(5, defaultU8, 42);
-};
-
-/**
- * @param flatbuffers.Builder builder
- * @param number justI16
- */
-static addJustI16(builder:flatbuffers.Builder, justI16:number) {
- builder.addFieldInt16(6, justI16, 0);
-};
-
-/**
- * @param flatbuffers.Builder builder
- * @param number maybeI16
- */
-static addMaybeI16(builder:flatbuffers.Builder, maybeI16:number) {
- builder.addFieldInt16(7, maybeI16, 0);
-};
-
-/**
- * @param flatbuffers.Builder builder
- * @param number defaultI16
- */
-static addDefaultI16(builder:flatbuffers.Builder, defaultI16:number) {
- builder.addFieldInt16(8, defaultI16, 42);
-};
-
-/**
- * @param flatbuffers.Builder builder
- * @param number justU16
- */
-static addJustU16(builder:flatbuffers.Builder, justU16:number) {
- builder.addFieldInt16(9, justU16, 0);
-};
-
-/**
- * @param flatbuffers.Builder builder
- * @param number maybeU16
- */
-static addMaybeU16(builder:flatbuffers.Builder, maybeU16:number) {
- builder.addFieldInt16(10, maybeU16, 0);
-};
-
-/**
- * @param flatbuffers.Builder builder
- * @param number defaultU16
- */
-static addDefaultU16(builder:flatbuffers.Builder, defaultU16:number) {
- builder.addFieldInt16(11, defaultU16, 42);
-};
-
-/**
- * @param flatbuffers.Builder builder
- * @param number justI32
- */
-static addJustI32(builder:flatbuffers.Builder, justI32:number) {
- builder.addFieldInt32(12, justI32, 0);
-};
-
-/**
- * @param flatbuffers.Builder builder
- * @param number maybeI32
- */
-static addMaybeI32(builder:flatbuffers.Builder, maybeI32:number) {
- builder.addFieldInt32(13, maybeI32, 0);
-};
-
-/**
- * @param flatbuffers.Builder builder
- * @param number defaultI32
- */
-static addDefaultI32(builder:flatbuffers.Builder, defaultI32:number) {
- builder.addFieldInt32(14, defaultI32, 42);
-};
-
-/**
- * @param flatbuffers.Builder builder
- * @param number justU32
- */
-static addJustU32(builder:flatbuffers.Builder, justU32:number) {
- builder.addFieldInt32(15, justU32, 0);
-};
-
-/**
- * @param flatbuffers.Builder builder
- * @param number maybeU32
- */
-static addMaybeU32(builder:flatbuffers.Builder, maybeU32:number) {
- builder.addFieldInt32(16, maybeU32, 0);
-};
-
-/**
- * @param flatbuffers.Builder builder
- * @param number defaultU32
- */
-static addDefaultU32(builder:flatbuffers.Builder, defaultU32:number) {
- builder.addFieldInt32(17, defaultU32, 42);
-};
-
-/**
- * @param flatbuffers.Builder builder
- * @param flatbuffers.Long justI64
- */
-static addJustI64(builder:flatbuffers.Builder, justI64:flatbuffers.Long) {
- builder.addFieldInt64(18, justI64, builder.createLong(0, 0));
-};
-
-/**
- * @param flatbuffers.Builder builder
- * @param flatbuffers.Long maybeI64
- */
-static addMaybeI64(builder:flatbuffers.Builder, maybeI64:flatbuffers.Long) {
- builder.addFieldInt64(19, maybeI64, builder.createLong(0, 0));
-};
-
-/**
- * @param flatbuffers.Builder builder
- * @param flatbuffers.Long defaultI64
- */
-static addDefaultI64(builder:flatbuffers.Builder, defaultI64:flatbuffers.Long) {
- builder.addFieldInt64(20, defaultI64, builder.createLong(42, 0));
-};
-
-/**
- * @param flatbuffers.Builder builder
- * @param flatbuffers.Long justU64
- */
-static addJustU64(builder:flatbuffers.Builder, justU64:flatbuffers.Long) {
- builder.addFieldInt64(21, justU64, builder.createLong(0, 0));
-};
-
-/**
- * @param flatbuffers.Builder builder
- * @param flatbuffers.Long maybeU64
- */
-static addMaybeU64(builder:flatbuffers.Builder, maybeU64:flatbuffers.Long) {
- builder.addFieldInt64(22, maybeU64, builder.createLong(0, 0));
-};
-
-/**
- * @param flatbuffers.Builder builder
- * @param flatbuffers.Long defaultU64
- */
-static addDefaultU64(builder:flatbuffers.Builder, defaultU64:flatbuffers.Long) {
- builder.addFieldInt64(23, defaultU64, builder.createLong(42, 0));
-};
-
-/**
- * @param flatbuffers.Builder builder
- * @param number justF32
- */
-static addJustF32(builder:flatbuffers.Builder, justF32:number) {
- builder.addFieldFloat32(24, justF32, 0.0);
-};
-
-/**
- * @param flatbuffers.Builder builder
- * @param number maybeF32
- */
-static addMaybeF32(builder:flatbuffers.Builder, maybeF32:number) {
- builder.addFieldFloat32(25, maybeF32, 0);
-};
-
-/**
- * @param flatbuffers.Builder builder
- * @param number defaultF32
- */
-static addDefaultF32(builder:flatbuffers.Builder, defaultF32:number) {
- builder.addFieldFloat32(26, defaultF32, 42.0);
-};
-
-/**
- * @param flatbuffers.Builder builder
- * @param number justF64
- */
-static addJustF64(builder:flatbuffers.Builder, justF64:number) {
- builder.addFieldFloat64(27, justF64, 0.0);
-};
-
-/**
- * @param flatbuffers.Builder builder
- * @param number maybeF64
- */
-static addMaybeF64(builder:flatbuffers.Builder, maybeF64:number) {
- builder.addFieldFloat64(28, maybeF64, 0);
-};
-
-/**
- * @param flatbuffers.Builder builder
- * @param number defaultF64
- */
-static addDefaultF64(builder:flatbuffers.Builder, defaultF64:number) {
- builder.addFieldFloat64(29, defaultF64, 42.0);
-};
-
-/**
- * @param flatbuffers.Builder builder
- * @param boolean justBool
- */
-static addJustBool(builder:flatbuffers.Builder, justBool:boolean) {
- builder.addFieldInt8(30, +justBool, +false);
-};
-
-/**
- * @param flatbuffers.Builder builder
- * @param boolean maybeBool
- */
-static addMaybeBool(builder:flatbuffers.Builder, maybeBool:boolean) {
- builder.addFieldInt8(31, +maybeBool, 0);
-};
-
-/**
- * @param flatbuffers.Builder builder
- * @param boolean defaultBool
- */
-static addDefaultBool(builder:flatbuffers.Builder, defaultBool:boolean) {
- builder.addFieldInt8(32, +defaultBool, +true);
-};
-
-/**
- * @param flatbuffers.Builder builder
- * @param optional_scalars.OptionalByte justEnum
- */
-static addJustEnum(builder:flatbuffers.Builder, justEnum:optional_scalars.OptionalByte) {
- builder.addFieldInt8(33, justEnum, optional_scalars.OptionalByte.None);
-};
-
-/**
- * @param flatbuffers.Builder builder
- * @param optional_scalars.OptionalByte maybeEnum
- */
-static addMaybeEnum(builder:flatbuffers.Builder, maybeEnum:optional_scalars.OptionalByte) {
- builder.addFieldInt8(34, maybeEnum, 0);
-};
-
-/**
- * @param flatbuffers.Builder builder
- * @param optional_scalars.OptionalByte defaultEnum
- */
-static addDefaultEnum(builder:flatbuffers.Builder, defaultEnum:optional_scalars.OptionalByte) {
- builder.addFieldInt8(35, defaultEnum, optional_scalars.OptionalByte.One);
-};
-
-/**
- * @param flatbuffers.Builder builder
- * @returns flatbuffers.Offset
- */
-static endScalarStuff(builder:flatbuffers.Builder):flatbuffers.Offset {
- var offset = builder.endObject();
- return offset;
-};
-
-/**
- * @param flatbuffers.Builder builder
- * @param flatbuffers.Offset offset
- */
-static finishScalarStuffBuffer(builder:flatbuffers.Builder, offset:flatbuffers.Offset) {
- builder.finish(offset, 'NULL');
-};
-
-/**
- * @param flatbuffers.Builder builder
- * @param flatbuffers.Offset offset
- */
-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:flatbuffers.Long, maybeI64:flatbuffers.Long|null, defaultI64:flatbuffers.Long, justU64:flatbuffers.Long, maybeU64:flatbuffers.Long|null, defaultU64:flatbuffers.Long, justF32:number, maybeF32:number|null, defaultF32:number, justF64:number, maybeF64:number|null, defaultF64:number, justBool:boolean, maybeBool:boolean|null, defaultBool:boolean, justEnum:optional_scalars.OptionalByte, maybeEnum:optional_scalars.OptionalByte|null, defaultEnum:optional_scalars.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/package.json b/tests/package.json
new file mode 100644
index 00000000..bb9fd7c1
--- /dev/null
+++ b/tests/package.json
@@ -0,0 +1,6 @@
+{
+ "dependencies": {
+ "esm": "^3.2.25",
+ "flatbuffers": "../"
+ }
+}
diff --git a/tests/ts/attacker.ts b/tests/ts/attacker.ts
new file mode 100644
index 00000000..cd8083d1
--- /dev/null
+++ b/tests/ts/attacker.ts
@@ -0,0 +1,76 @@
+// 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;
+}
+
+static getFullyQualifiedName():string {
+ return 'Attacker';
+}
+
+static startAttacker(builder:flatbuffers.Builder) {
+ builder.startObject(1);
+}
+
+static addSwordAttackDamage(builder:flatbuffers.Builder, swordAttackDamage:number) {
+ builder.addFieldInt32(0, swordAttackDamage, 0);
+}
+
+static endAttacker(builder:flatbuffers.Builder):flatbuffers.Offset {
+ const offset = builder.endObject();
+ return offset;
+}
+
+static createAttacker(builder:flatbuffers.Builder, swordAttackDamage:number):flatbuffers.Offset {
+ Attacker.startAttacker(builder);
+ Attacker.addSwordAttackDamage(builder, swordAttackDamage);
+ return Attacker.endAttacker(builder);
+}
+
+unpack(): AttackerT {
+ return new AttackerT(
+ this.swordAttackDamage()
+ );
+}
+
+
+unpackTo(_o: AttackerT): void {
+ _o.swordAttackDamage = this.swordAttackDamage();
+}
+}
+
+export class AttackerT {
+constructor(
+ public swordAttackDamage: number = 0
+){}
+
+
+pack(builder:flatbuffers.Builder): flatbuffers.Offset {
+ return Attacker.createAttacker(builder,
+ this.swordAttackDamage
+ );
+}
+}
diff --git a/tests/ts/book-reader.ts b/tests/ts/book-reader.ts
new file mode 100644
index 00000000..f8fb0169
--- /dev/null
+++ b/tests/ts/book-reader.ts
@@ -0,0 +1,58 @@
+// 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);
+}
+
+static getFullyQualifiedName():string {
+ return 'BookReader';
+}
+
+static sizeOf():number {
+ return 4;
+}
+
+static createBookReader(builder:flatbuffers.Builder, books_read: number):flatbuffers.Offset {
+ builder.prep(4, 4);
+ builder.writeInt32(books_read);
+ return builder.offset();
+}
+
+
+unpack(): BookReaderT {
+ return new BookReaderT(
+ this.booksRead()
+ );
+}
+
+
+unpackTo(_o: BookReaderT): void {
+ _o.booksRead = this.booksRead();
+}
+}
+
+export class BookReaderT {
+constructor(
+ public booksRead: number = 0
+){}
+
+
+pack(builder:flatbuffers.Builder): flatbuffers.Offset {
+ return BookReader.createBookReader(builder,
+ this.booksRead
+ );
+}
+}
diff --git a/tests/ts/character.ts b/tests/ts/character.ts
new file mode 100644
index 00000000..dbf8d51d
--- /dev/null
+++ b/tests/ts/character.ts
@@ -0,0 +1,50 @@
+// 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/ts/movie.ts b/tests/ts/movie.ts
new file mode 100644
index 00000000..a07b6eaa
--- /dev/null
+++ b/tests/ts/movie.ts
@@ -0,0 +1,211 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+
+import * as flatbuffers from 'flatbuffers';
+
+import { Attacker, AttackerT } from './attacker';
+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<T extends flatbuffers.Table>(obj:any|string):any|string|null {
+ const offset = this.bb!.__offset(this.bb_pos, 6);
+ return offset ? this.bb!.__union_with_string(obj, this.bb_pos + offset) : null;
+}
+
+charactersType(index: number):Character|null {
+ const offset = this.bb!.__offset(this.bb_pos, 8);
+ return offset ? this.bb!.readUint8(this.bb!.__vector(this.bb_pos + offset) + index) : 0;
+}
+
+charactersTypeLength():number {
+ const offset = this.bb!.__offset(this.bb_pos, 8);
+ return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
+}
+
+charactersTypeArray():Uint8Array|null {
+ const offset = this.bb!.__offset(this.bb_pos, 8);
+ return offset ? new Uint8Array(this.bb!.bytes().buffer, this.bb!.bytes().byteOffset + this.bb!.__vector(this.bb_pos + offset), this.bb!.__vector_len(this.bb_pos + offset)) : null;
+}
+
+characters(index: number, obj:any|string):any|string|null {
+ const offset = this.bb!.__offset(this.bb_pos, 10);
+ return offset ? this.bb!.__union_with_string(obj, this.bb!.__vector(this.bb_pos + offset) + index * 4) : null;
+}
+
+charactersLength():number {
+ const offset = this.bb!.__offset(this.bb_pos, 10);
+ return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
+}
+
+static getFullyQualifiedName():string {
+ return 'Movie';
+}
+
+static startMovie(builder:flatbuffers.Builder) {
+ builder.startObject(4);
+}
+
+static addMainCharacterType(builder:flatbuffers.Builder, mainCharacterType:Character) {
+ builder.addFieldInt8(0, mainCharacterType, Character.NONE);
+}
+
+static addMainCharacter(builder:flatbuffers.Builder, mainCharacterOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(1, mainCharacterOffset, 0);
+}
+
+static addCharactersType(builder:flatbuffers.Builder, charactersTypeOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(2, charactersTypeOffset, 0);
+}
+
+static createCharactersTypeVector(builder:flatbuffers.Builder, data:Character[]):flatbuffers.Offset {
+ builder.startVector(1, data.length, 1);
+ for (let i = data.length - 1; i >= 0; i--) {
+ builder.addInt8(data[i]);
+ }
+ return builder.endVector();
+}
+
+static startCharactersTypeVector(builder:flatbuffers.Builder, numElems:number) {
+ builder.startVector(1, numElems, 1);
+}
+
+static addCharacters(builder:flatbuffers.Builder, charactersOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(3, charactersOffset, 0);
+}
+
+static createCharactersVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset {
+ builder.startVector(4, data.length, 4);
+ for (let i = data.length - 1; i >= 0; i--) {
+ builder.addOffset(data[i]);
+ }
+ return builder.endVector();
+}
+
+static startCharactersVector(builder:flatbuffers.Builder, numElems:number) {
+ builder.startVector(4, numElems, 4);
+}
+
+static endMovie(builder:flatbuffers.Builder):flatbuffers.Offset {
+ const offset = builder.endObject();
+ return offset;
+}
+
+static finishMovieBuffer(builder:flatbuffers.Builder, offset:flatbuffers.Offset) {
+ builder.finish(offset, 'MOVI');
+}
+
+static finishSizePrefixedMovieBuffer(builder:flatbuffers.Builder, offset:flatbuffers.Offset) {
+ builder.finish(offset, 'MOVI', true);
+}
+
+static createMovie(builder:flatbuffers.Builder, mainCharacterType:Character, mainCharacterOffset:flatbuffers.Offset, charactersTypeOffset:flatbuffers.Offset, charactersOffset:flatbuffers.Offset):flatbuffers.Offset {
+ Movie.startMovie(builder);
+ Movie.addMainCharacterType(builder, mainCharacterType);
+ Movie.addMainCharacter(builder, mainCharacterOffset);
+ Movie.addCharactersType(builder, charactersTypeOffset);
+ Movie.addCharacters(builder, charactersOffset);
+ return Movie.endMovie(builder);
+}
+
+unpack(): MovieT {
+ return new MovieT(
+ this.mainCharacterType(),
+ (() => {
+ let temp = unionToCharacter(this.mainCharacterType(), this.mainCharacter.bind(this));
+ if(temp === null) { return null; }
+ if(typeof temp === 'string') { return temp; }
+ return temp.unpack()
+ })(),
+ this.bb!.createScalarList(this.charactersType.bind(this), this.charactersTypeLength()),
+ (() => {
+ let ret = [];
+ for(let targetEnumIndex = 0; targetEnumIndex < this.charactersTypeLength(); ++targetEnumIndex) {
+ let targetEnum = this.charactersType(targetEnumIndex);
+ if(targetEnum === null || Character[targetEnum!] === 'NONE') { continue; }
+
+ let temp = unionListToCharacter(targetEnum, this.characters.bind(this), targetEnumIndex);
+ if(temp === null) { continue; }
+ if(typeof temp === 'string') { ret.push(temp); continue; }
+ ret.push(temp.unpack());
+ }
+ return ret;
+ })()
+ );
+}
+
+
+unpackTo(_o: MovieT): void {
+ _o.mainCharacterType = this.mainCharacterType();
+ _o.mainCharacter = (() => {
+ let temp = unionToCharacter(this.mainCharacterType(), this.mainCharacter.bind(this));
+ if(temp === null) { return null; }
+ if(typeof temp === 'string') { return temp; }
+ return temp.unpack()
+ })();
+ _o.charactersType = this.bb!.createScalarList(this.charactersType.bind(this), this.charactersTypeLength());
+ _o.characters = (() => {
+ let ret = [];
+ for(let targetEnumIndex = 0; targetEnumIndex < this.charactersTypeLength(); ++targetEnumIndex) {
+ let targetEnum = this.charactersType(targetEnumIndex);
+ if(targetEnum === null || Character[targetEnum!] === 'NONE') { continue; }
+
+ let temp = unionListToCharacter(targetEnum, this.characters.bind(this), targetEnumIndex);
+ if(temp === null) { continue; }
+ if(typeof temp === 'string') { ret.push(temp); continue; }
+ ret.push(temp.unpack());
+ }
+ return ret;
+ })();
+}
+}
+
+export class MovieT {
+constructor(
+ public mainCharacterType: Character = Character.NONE,
+ public mainCharacter: AttackerT|BookReaderT|RapunzelT|string|null = null,
+ public charactersType: (Character)[] = [],
+ public characters: (AttackerT|BookReaderT|RapunzelT|string)[] = []
+){}
+
+
+pack(builder:flatbuffers.Builder): flatbuffers.Offset {
+ const mainCharacter = builder.createObjectOffset(this.mainCharacter);
+ const charactersType = Movie.createCharactersTypeVector(builder, this.charactersType);
+ const characters = Movie.createCharactersVector(builder, builder.createObjectOffsetList(this.characters));
+
+ return Movie.createMovie(builder,
+ this.mainCharacterType,
+ mainCharacter,
+ charactersType,
+ characters
+ );
+}
+}
diff --git a/tests/ts/my-game/example/ability.ts b/tests/ts/my-game/example/ability.ts
new file mode 100644
index 00000000..26395fba
--- /dev/null
+++ b/tests/ts/my-game/example/ability.ts
@@ -0,0 +1,77 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+
+import * as flatbuffers from 'flatbuffers';
+
+
+
+export class Ability {
+ bb: flatbuffers.ByteBuffer|null = null;
+ bb_pos = 0;
+__init(i:number, bb:flatbuffers.ByteBuffer):Ability {
+ this.bb_pos = i;
+ this.bb = bb;
+ return this;
+}
+
+id():number {
+ return this.bb!.readUint32(this.bb_pos);
+}
+
+mutate_id(value:number):boolean {
+ this.bb!.writeUint32(this.bb_pos + 0, value);
+ return true;
+}
+
+distance():number {
+ return this.bb!.readUint32(this.bb_pos + 4);
+}
+
+mutate_distance(value:number):boolean {
+ this.bb!.writeUint32(this.bb_pos + 4, value);
+ return true;
+}
+
+static getFullyQualifiedName():string {
+ return 'MyGame.Example.Ability';
+}
+
+static sizeOf():number {
+ return 8;
+}
+
+static createAbility(builder:flatbuffers.Builder, id: number, distance: number):flatbuffers.Offset {
+ builder.prep(4, 8);
+ builder.writeInt32(distance);
+ builder.writeInt32(id);
+ return builder.offset();
+}
+
+
+unpack(): AbilityT {
+ return new AbilityT(
+ this.id(),
+ this.distance()
+ );
+}
+
+
+unpackTo(_o: AbilityT): void {
+ _o.id = this.id();
+ _o.distance = this.distance();
+}
+}
+
+export class AbilityT {
+constructor(
+ public id: number = 0,
+ public distance: number = 0
+){}
+
+
+pack(builder:flatbuffers.Builder): flatbuffers.Offset {
+ return Ability.createAbility(builder,
+ this.id,
+ this.distance
+ );
+}
+}
diff --git a/tests/ts/my-game/example/any-ambiguous-aliases.ts b/tests/ts/my-game/example/any-ambiguous-aliases.ts
new file mode 100644
index 00000000..6687a419
--- /dev/null
+++ b/tests/ts/my-game/example/any-ambiguous-aliases.ts
@@ -0,0 +1,39 @@
+// 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/ts/my-game/example/any-unique-aliases.ts b/tests/ts/my-game/example/any-unique-aliases.ts
new file mode 100644
index 00000000..51061488
--- /dev/null
+++ b/tests/ts/my-game/example/any-unique-aliases.ts
@@ -0,0 +1,41 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+
+import { Monster as MyGameExample2Monster, MonsterT as MyGameExample2MonsterT } 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|MyGameExample2Monster|TestSimpleTableWithEnum) => Monster|MyGameExample2Monster|TestSimpleTableWithEnum|null
+): Monster|MyGameExample2Monster|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 MyGameExample2Monster())! as MyGameExample2Monster;
+ default: return null;
+ }
+}
+
+export function unionListToAnyUniqueAliases(
+ type: AnyUniqueAliases,
+ accessor: (index: number, obj:Monster|MyGameExample2Monster|TestSimpleTableWithEnum) => Monster|MyGameExample2Monster|TestSimpleTableWithEnum|null,
+ index: number
+): Monster|MyGameExample2Monster|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 MyGameExample2Monster())! as MyGameExample2Monster;
+ default: return null;
+ }
+}
+
diff --git a/tests/ts/my-game/example/any.ts b/tests/ts/my-game/example/any.ts
new file mode 100644
index 00000000..9d8b2a61
--- /dev/null
+++ b/tests/ts/my-game/example/any.ts
@@ -0,0 +1,41 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+
+import { Monster as MyGameExample2Monster, MonsterT as MyGameExample2MonsterT } 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|MyGameExample2Monster|TestSimpleTableWithEnum) => Monster|MyGameExample2Monster|TestSimpleTableWithEnum|null
+): Monster|MyGameExample2Monster|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 MyGameExample2Monster())! as MyGameExample2Monster;
+ default: return null;
+ }
+}
+
+export function unionListToAny(
+ type: Any,
+ accessor: (index: number, obj:Monster|MyGameExample2Monster|TestSimpleTableWithEnum) => Monster|MyGameExample2Monster|TestSimpleTableWithEnum|null,
+ index: number
+): Monster|MyGameExample2Monster|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 MyGameExample2Monster())! as MyGameExample2Monster;
+ default: return null;
+ }
+}
+
diff --git a/tests/ts/my-game/example/color.ts b/tests/ts/my-game/example/color.ts
new file mode 100644
index 00000000..ceb31f82
--- /dev/null
+++ b/tests/ts/my-game/example/color.ts
@@ -0,0 +1,20 @@
+// 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/monster.ts b/tests/ts/my-game/example/monster.ts
new file mode 100644
index 00000000..b334782e
--- /dev/null
+++ b/tests/ts/my-game/example/monster.ts
@@ -0,0 +1,1370 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+
+import * as flatbuffers from 'flatbuffers';
+
+import { Monster as MyGameExample2Monster, MonsterT as MyGameExample2MonsterT } 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<T extends flatbuffers.Table>(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():flatbuffers.Long {
+ const offset = this.bb!.__offset(this.bb_pos, 40);
+ return offset ? this.bb!.readInt64(this.bb_pos + offset) : this.bb!.createLong(0, 0);
+}
+
+mutate_testhashs64_fnv1(value:flatbuffers.Long):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():flatbuffers.Long {
+ const offset = this.bb!.__offset(this.bb_pos, 42);
+ return offset ? this.bb!.readUint64(this.bb_pos + offset) : this.bb!.createLong(0, 0);
+}
+
+mutate_testhashu64_fnv1(value:flatbuffers.Long):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():flatbuffers.Long {
+ const offset = this.bb!.__offset(this.bb_pos, 48);
+ return offset ? this.bb!.readInt64(this.bb_pos + offset) : this.bb!.createLong(0, 0);
+}
+
+mutate_testhashs64_fnv1a(value:flatbuffers.Long):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():flatbuffers.Long {
+ const offset = this.bb!.__offset(this.bb_pos, 50);
+ return offset ? this.bb!.readUint64(this.bb_pos + offset) : this.bb!.createLong(0, 0);
+}
+
+mutate_testhashu64_fnv1a(value:flatbuffers.Long):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):flatbuffers.Long|null {
+ const offset = this.bb!.__offset(this.bb_pos, 68);
+ return offset ? this.bb!.readInt64(this.bb!.__vector(this.bb_pos + offset) + index * 8) : this.bb!.createLong(0, 0);
+}
+
+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():flatbuffers.Long {
+ const offset = this.bb!.__offset(this.bb_pos, 76);
+ return offset ? this.bb!.readUint64(this.bb_pos + offset) : this.bb!.createLong(0, 0);
+}
+
+mutate_single_weak_reference(value:flatbuffers.Long):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):flatbuffers.Long|null {
+ const offset = this.bb!.__offset(this.bb_pos, 78);
+ return offset ? this.bb!.readUint64(this.bb!.__vector(this.bb_pos + offset) + index * 8) : this.bb!.createLong(0, 0);
+}
+
+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():flatbuffers.Long {
+ const offset = this.bb!.__offset(this.bb_pos, 82);
+ return offset ? this.bb!.readUint64(this.bb_pos + offset) : this.bb!.createLong(0, 0);
+}
+
+mutate_co_owning_reference(value:flatbuffers.Long):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):flatbuffers.Long|null {
+ const offset = this.bb!.__offset(this.bb_pos, 84);
+ return offset ? this.bb!.readUint64(this.bb!.__vector(this.bb_pos + offset) + index * 8) : this.bb!.createLong(0, 0);
+}
+
+vectorOfCoOwningReferencesLength():number {
+ const offset = this.bb!.__offset(this.bb_pos, 84);
+ return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
+}
+
+nonOwningReference():flatbuffers.Long {
+ const offset = this.bb!.__offset(this.bb_pos, 86);
+ return offset ? this.bb!.readUint64(this.bb_pos + offset) : this.bb!.createLong(0, 0);
+}
+
+mutate_non_owning_reference(value:flatbuffers.Long):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):flatbuffers.Long|null {
+ const offset = this.bb!.__offset(this.bb_pos, 88);
+ return offset ? this.bb!.readUint64(this.bb!.__vector(this.bb_pos + offset) + index * 8) : this.bb!.createLong(0, 0);
+}
+
+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<T extends flatbuffers.Table>(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<T extends flatbuffers.Table>(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;
+}
+
+static getFullyQualifiedName():string {
+ return 'MyGame.Example.Monster';
+}
+
+static startMonster(builder:flatbuffers.Builder) {
+ builder.startObject(51);
+}
+
+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:flatbuffers.Long) {
+ builder.addFieldInt64(18, testhashs64Fnv1, builder.createLong(0, 0));
+}
+
+static addTesthashu64Fnv1(builder:flatbuffers.Builder, testhashu64Fnv1:flatbuffers.Long) {
+ builder.addFieldInt64(19, testhashu64Fnv1, builder.createLong(0, 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:flatbuffers.Long) {
+ builder.addFieldInt64(22, testhashs64Fnv1a, builder.createLong(0, 0));
+}
+
+static addTesthashu64Fnv1a(builder:flatbuffers.Builder, testhashu64Fnv1a:flatbuffers.Long) {
+ builder.addFieldInt64(23, testhashu64Fnv1a, builder.createLong(0, 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:flatbuffers.Long[]):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:flatbuffers.Long) {
+ builder.addFieldInt64(36, singleWeakReference, builder.createLong(0, 0));
+}
+
+static addVectorOfWeakReferences(builder:flatbuffers.Builder, vectorOfWeakReferencesOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(37, vectorOfWeakReferencesOffset, 0);
+}
+
+static createVectorOfWeakReferencesVector(builder:flatbuffers.Builder, data:flatbuffers.Long[]):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:flatbuffers.Long) {
+ builder.addFieldInt64(39, coOwningReference, builder.createLong(0, 0));
+}
+
+static addVectorOfCoOwningReferences(builder:flatbuffers.Builder, vectorOfCoOwningReferencesOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(40, vectorOfCoOwningReferencesOffset, 0);
+}
+
+static createVectorOfCoOwningReferencesVector(builder:flatbuffers.Builder, data:flatbuffers.Long[]):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:flatbuffers.Long) {
+ builder.addFieldInt64(41, nonOwningReference, builder.createLong(0, 0));
+}
+
+static addVectorOfNonOwningReferences(builder:flatbuffers.Builder, vectorOfNonOwningReferencesOffset:flatbuffers.Offset) {
+ builder.addFieldOffset(42, vectorOfNonOwningReferencesOffset, 0);
+}
+
+static createVectorOfNonOwningReferencesVector(builder:flatbuffers.Builder, data:flatbuffers.Long[]):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 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())
+ );
+}
+
+
+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());
+}
+}
+
+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|MyGameExample2MonsterT|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: flatbuffers.Long = flatbuffers.createLong(0, 0),
+ public testhashu64Fnv1: flatbuffers.Long = flatbuffers.createLong(0, 0),
+ public testhashs32Fnv1a: number = 0,
+ public testhashu32Fnv1a: number = 0,
+ public testhashs64Fnv1a: flatbuffers.Long = flatbuffers.createLong(0, 0),
+ public testhashu64Fnv1a: flatbuffers.Long = flatbuffers.createLong(0, 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: (flatbuffers.Long)[] = [],
+ public vectorOfDoubles: (number)[] = [],
+ public parentNamespaceTest: InParentNamespaceT|null = null,
+ public vectorOfReferrables: (ReferrableT)[] = [],
+ public singleWeakReference: flatbuffers.Long = flatbuffers.createLong(0, 0),
+ public vectorOfWeakReferences: (flatbuffers.Long)[] = [],
+ public vectorOfStrongReferrables: (ReferrableT)[] = [],
+ public coOwningReference: flatbuffers.Long = flatbuffers.createLong(0, 0),
+ public vectorOfCoOwningReferences: (flatbuffers.Long)[] = [],
+ public nonOwningReference: flatbuffers.Long = flatbuffers.createLong(0, 0),
+ public vectorOfNonOwningReferences: (flatbuffers.Long)[] = [],
+ public anyUniqueType: AnyUniqueAliases = AnyUniqueAliases.NONE,
+ public anyUnique: MonsterT|MyGameExample2MonsterT|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)[] = []
+){}
+
+
+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 testnestedflatbuffer = Monster.createTestnestedflatbufferVector(builder, this.testnestedflatbuffer);
+ 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 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, (this.enemy !== null ? this.enemy!.pack(builder) : 0));
+ Monster.addTestnestedflatbuffer(builder, testnestedflatbuffer);
+ Monster.addTestempty(builder, (this.testempty !== null ? this.testempty!.pack(builder) : 0));
+ 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, (this.parentNamespaceTest !== null ? this.parentNamespaceTest!.pack(builder) : 0));
+ 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);
+
+ return Monster.endMonster(builder);
+}
+}
diff --git a/tests/ts/my-game/example/race.ts b/tests/ts/my-game/example/race.ts
new file mode 100644
index 00000000..06ca128b
--- /dev/null
+++ b/tests/ts/my-game/example/race.ts
@@ -0,0 +1,9 @@
+// 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.ts b/tests/ts/my-game/example/referrable.ts
new file mode 100644
index 00000000..ce24debb
--- /dev/null
+++ b/tests/ts/my-game/example/referrable.ts
@@ -0,0 +1,95 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+
+import * as flatbuffers from 'flatbuffers';
+
+
+
+export class Referrable {
+ bb: flatbuffers.ByteBuffer|null = null;
+ bb_pos = 0;
+__init(i:number, bb:flatbuffers.ByteBuffer):Referrable {
+ this.bb_pos = i;
+ this.bb = bb;
+ return this;
+}
+
+static getRootAsReferrable(bb:flatbuffers.ByteBuffer, obj?:Referrable):Referrable {
+ return (obj || new Referrable()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+}
+
+static getSizePrefixedRootAsReferrable(bb:flatbuffers.ByteBuffer, obj?:Referrable):Referrable {
+ bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
+ return (obj || new Referrable()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+}
+
+id():flatbuffers.Long {
+ const offset = this.bb!.__offset(this.bb_pos, 4);
+ return offset ? this.bb!.readUint64(this.bb_pos + offset) : this.bb!.createLong(0, 0);
+}
+
+mutate_id(value:flatbuffers.Long):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:flatbuffers.Long) {
+ builder.addFieldInt64(0, id, builder.createLong(0, 0));
+}
+
+static endReferrable(builder:flatbuffers.Builder):flatbuffers.Offset {
+ const offset = builder.endObject();
+ return offset;
+}
+
+static createReferrable(builder:flatbuffers.Builder, id:flatbuffers.Long):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: flatbuffers.Long = flatbuffers.createLong(0, 0)
+){}
+
+
+pack(builder:flatbuffers.Builder): flatbuffers.Offset {
+ return Referrable.createReferrable(builder,
+ this.id
+ );
+}
+}
diff --git a/tests/ts/my-game/example/stat.ts b/tests/ts/my-game/example/stat.ts
new file mode 100644
index 00000000..c0ef62c7
--- /dev/null
+++ b/tests/ts/my-game/example/stat.ts
@@ -0,0 +1,138 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+
+import * as flatbuffers from 'flatbuffers';
+
+
+
+export class Stat {
+ bb: flatbuffers.ByteBuffer|null = null;
+ bb_pos = 0;
+__init(i:number, bb:flatbuffers.ByteBuffer):Stat {
+ this.bb_pos = i;
+ this.bb = bb;
+ return this;
+}
+
+static getRootAsStat(bb:flatbuffers.ByteBuffer, obj?:Stat):Stat {
+ return (obj || new Stat()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+}
+
+static getSizePrefixedRootAsStat(bb:flatbuffers.ByteBuffer, obj?:Stat):Stat {
+ bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
+ return (obj || new Stat()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+}
+
+id():string|null
+id(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
+id(optionalEncoding?:any):string|Uint8Array|null {
+ const offset = this.bb!.__offset(this.bb_pos, 4);
+ return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
+}
+
+val():flatbuffers.Long {
+ const offset = this.bb!.__offset(this.bb_pos, 6);
+ return offset ? this.bb!.readInt64(this.bb_pos + offset) : this.bb!.createLong(0, 0);
+}
+
+mutate_val(value:flatbuffers.Long):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:flatbuffers.Long) {
+ builder.addFieldInt64(1, val, builder.createLong(0, 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:flatbuffers.Long, 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: flatbuffers.Long = flatbuffers.createLong(0, 0),
+ public count: number = 0
+){}
+
+
+pack(builder:flatbuffers.Builder): flatbuffers.Offset {
+ const id = (this.id !== null ? builder.createString(this.id!) : 0);
+
+ return Stat.createStat(builder,
+ id,
+ this.val,
+ this.count
+ );
+}
+}
diff --git a/tests/ts/my-game/example/test-simple-table-with-enum.ts b/tests/ts/my-game/example/test-simple-table-with-enum.ts
new file mode 100644
index 00000000..99a541f9
--- /dev/null
+++ b/tests/ts/my-game/example/test-simple-table-with-enum.ts
@@ -0,0 +1,96 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+
+import * as flatbuffers from 'flatbuffers';
+
+import { Color } from '../../my-game/example/color';
+
+
+export class TestSimpleTableWithEnum {
+ bb: flatbuffers.ByteBuffer|null = null;
+ bb_pos = 0;
+__init(i:number, bb:flatbuffers.ByteBuffer):TestSimpleTableWithEnum {
+ this.bb_pos = i;
+ this.bb = bb;
+ return this;
+}
+
+static getRootAsTestSimpleTableWithEnum(bb:flatbuffers.ByteBuffer, obj?:TestSimpleTableWithEnum):TestSimpleTableWithEnum {
+ return (obj || new TestSimpleTableWithEnum()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+}
+
+static getSizePrefixedRootAsTestSimpleTableWithEnum(bb:flatbuffers.ByteBuffer, obj?:TestSimpleTableWithEnum):TestSimpleTableWithEnum {
+ bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
+ return (obj || new TestSimpleTableWithEnum()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+}
+
+color():Color {
+ const offset = this.bb!.__offset(this.bb_pos, 4);
+ return offset ? this.bb!.readUint8(this.bb_pos + offset) : Color.Green;
+}
+
+mutate_color(value:Color):boolean {
+ const offset = this.bb!.__offset(this.bb_pos, 4);
+
+ if (offset === 0) {
+ return false;
+ }
+
+ this.bb!.writeUint8(this.bb_pos + offset, value);
+ return true;
+}
+
+static getFullyQualifiedName():string {
+ return 'MyGame.Example.TestSimpleTableWithEnum';
+}
+
+static startTestSimpleTableWithEnum(builder:flatbuffers.Builder) {
+ builder.startObject(1);
+}
+
+static addColor(builder:flatbuffers.Builder, color:Color) {
+ builder.addFieldInt8(0, color, Color.Green);
+}
+
+static endTestSimpleTableWithEnum(builder:flatbuffers.Builder):flatbuffers.Offset {
+ const offset = builder.endObject();
+ return offset;
+}
+
+static createTestSimpleTableWithEnum(builder:flatbuffers.Builder, color:Color):flatbuffers.Offset {
+ TestSimpleTableWithEnum.startTestSimpleTableWithEnum(builder);
+ TestSimpleTableWithEnum.addColor(builder, color);
+ return TestSimpleTableWithEnum.endTestSimpleTableWithEnum(builder);
+}
+
+serialize():Uint8Array {
+ return this.bb!.bytes();
+}
+
+static deserialize(buffer: Uint8Array):TestSimpleTableWithEnum {
+ return TestSimpleTableWithEnum.getRootAsTestSimpleTableWithEnum(new flatbuffers.ByteBuffer(buffer))
+}
+
+unpack(): TestSimpleTableWithEnumT {
+ return new TestSimpleTableWithEnumT(
+ this.color()
+ );
+}
+
+
+unpackTo(_o: TestSimpleTableWithEnumT): void {
+ _o.color = this.color();
+}
+}
+
+export class TestSimpleTableWithEnumT {
+constructor(
+ public color: Color = Color.Green
+){}
+
+
+pack(builder:flatbuffers.Builder): flatbuffers.Offset {
+ return TestSimpleTableWithEnum.createTestSimpleTableWithEnum(builder,
+ this.color
+ );
+}
+}
diff --git a/tests/ts/my-game/example/test.ts b/tests/ts/my-game/example/test.ts
new file mode 100644
index 00000000..afed125e
--- /dev/null
+++ b/tests/ts/my-game/example/test.ts
@@ -0,0 +1,78 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+
+import * as flatbuffers from 'flatbuffers';
+
+
+
+export class Test {
+ bb: flatbuffers.ByteBuffer|null = null;
+ bb_pos = 0;
+__init(i:number, bb:flatbuffers.ByteBuffer):Test {
+ this.bb_pos = i;
+ this.bb = bb;
+ return this;
+}
+
+a():number {
+ return this.bb!.readInt16(this.bb_pos);
+}
+
+mutate_a(value:number):boolean {
+ this.bb!.writeInt16(this.bb_pos + 0, value);
+ return true;
+}
+
+b():number {
+ return this.bb!.readInt8(this.bb_pos + 2);
+}
+
+mutate_b(value:number):boolean {
+ this.bb!.writeInt8(this.bb_pos + 2, value);
+ return true;
+}
+
+static getFullyQualifiedName():string {
+ return 'MyGame.Example.Test';
+}
+
+static sizeOf():number {
+ return 4;
+}
+
+static createTest(builder:flatbuffers.Builder, a: number, b: number):flatbuffers.Offset {
+ builder.prep(2, 4);
+ builder.pad(1);
+ builder.writeInt8(b);
+ builder.writeInt16(a);
+ return builder.offset();
+}
+
+
+unpack(): TestT {
+ return new TestT(
+ this.a(),
+ this.b()
+ );
+}
+
+
+unpackTo(_o: TestT): void {
+ _o.a = this.a();
+ _o.b = this.b();
+}
+}
+
+export class TestT {
+constructor(
+ public a: number = 0,
+ public b: number = 0
+){}
+
+
+pack(builder:flatbuffers.Builder): flatbuffers.Offset {
+ return Test.createTest(builder,
+ this.a,
+ this.b
+ );
+}
+}
diff --git a/tests/ts/my-game/example/type-aliases.ts b/tests/ts/my-game/example/type-aliases.ts
new file mode 100644
index 00000000..9409eafc
--- /dev/null
+++ b/tests/ts/my-game/example/type-aliases.ts
@@ -0,0 +1,405 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+
+import * as flatbuffers from 'flatbuffers';
+
+
+
+export class TypeAliases {
+ bb: flatbuffers.ByteBuffer|null = null;
+ bb_pos = 0;
+__init(i:number, bb:flatbuffers.ByteBuffer):TypeAliases {
+ this.bb_pos = i;
+ this.bb = bb;
+ return this;
+}
+
+static getRootAsTypeAliases(bb:flatbuffers.ByteBuffer, obj?:TypeAliases):TypeAliases {
+ return (obj || new TypeAliases()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+}
+
+static getSizePrefixedRootAsTypeAliases(bb:flatbuffers.ByteBuffer, obj?:TypeAliases):TypeAliases {
+ bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
+ return (obj || new TypeAliases()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+}
+
+i8():number {
+ const offset = this.bb!.__offset(this.bb_pos, 4);
+ return offset ? this.bb!.readInt8(this.bb_pos + offset) : 0;
+}
+
+mutate_i8(value:number):boolean {
+ const offset = this.bb!.__offset(this.bb_pos, 4);
+
+ if (offset === 0) {
+ return false;
+ }
+
+ this.bb!.writeInt8(this.bb_pos + offset, value);
+ return true;
+}
+
+u8():number {
+ const offset = this.bb!.__offset(this.bb_pos, 6);
+ return offset ? this.bb!.readUint8(this.bb_pos + offset) : 0;
+}
+
+mutate_u8(value:number):boolean {
+ const offset = this.bb!.__offset(this.bb_pos, 6);
+
+ if (offset === 0) {
+ return false;
+ }
+
+ this.bb!.writeUint8(this.bb_pos + offset, value);
+ return true;
+}
+
+i16():number {
+ const offset = this.bb!.__offset(this.bb_pos, 8);
+ return offset ? this.bb!.readInt16(this.bb_pos + offset) : 0;
+}
+
+mutate_i16(value:number):boolean {
+ const offset = this.bb!.__offset(this.bb_pos, 8);
+
+ if (offset === 0) {
+ return false;
+ }
+
+ this.bb!.writeInt16(this.bb_pos + offset, value);
+ return true;
+}
+
+u16():number {
+ const offset = this.bb!.__offset(this.bb_pos, 10);
+ return offset ? this.bb!.readUint16(this.bb_pos + offset) : 0;
+}
+
+mutate_u16(value:number):boolean {
+ const offset = this.bb!.__offset(this.bb_pos, 10);
+
+ if (offset === 0) {
+ return false;
+ }
+
+ this.bb!.writeUint16(this.bb_pos + offset, value);
+ return true;
+}
+
+i32():number {
+ const offset = this.bb!.__offset(this.bb_pos, 12);
+ return offset ? this.bb!.readInt32(this.bb_pos + offset) : 0;
+}
+
+mutate_i32(value:number):boolean {
+ const offset = this.bb!.__offset(this.bb_pos, 12);
+
+ if (offset === 0) {
+ return false;
+ }
+
+ this.bb!.writeInt32(this.bb_pos + offset, value);
+ return true;
+}
+
+u32():number {
+ const offset = this.bb!.__offset(this.bb_pos, 14);
+ return offset ? this.bb!.readUint32(this.bb_pos + offset) : 0;
+}
+
+mutate_u32(value:number):boolean {
+ const offset = this.bb!.__offset(this.bb_pos, 14);
+
+ if (offset === 0) {
+ return false;
+ }
+
+ this.bb!.writeUint32(this.bb_pos + offset, value);
+ return true;
+}
+
+i64():flatbuffers.Long {
+ const offset = this.bb!.__offset(this.bb_pos, 16);
+ return offset ? this.bb!.readInt64(this.bb_pos + offset) : this.bb!.createLong(0, 0);
+}
+
+mutate_i64(value:flatbuffers.Long):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():flatbuffers.Long {
+ const offset = this.bb!.__offset(this.bb_pos, 18);
+ return offset ? this.bb!.readUint64(this.bb_pos + offset) : this.bb!.createLong(0, 0);
+}
+
+mutate_u64(value:flatbuffers.Long):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:flatbuffers.Long) {
+ builder.addFieldInt64(6, i64, builder.createLong(0, 0));
+}
+
+static addU64(builder:flatbuffers.Builder, u64:flatbuffers.Long) {
+ builder.addFieldInt64(7, u64, builder.createLong(0, 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:flatbuffers.Long, u64:flatbuffers.Long, 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: flatbuffers.Long = flatbuffers.createLong(0, 0),
+ public u64: flatbuffers.Long = flatbuffers.createLong(0, 0),
+ public f32: number = 0.0,
+ public f64: number = 0.0,
+ public v8: (number)[] = [],
+ public vf64: (number)[] = []
+){}
+
+
+pack(builder:flatbuffers.Builder): flatbuffers.Offset {
+ const v8 = TypeAliases.createV8Vector(builder, this.v8);
+ const vf64 = TypeAliases.createVf64Vector(builder, this.vf64);
+
+ return TypeAliases.createTypeAliases(builder,
+ this.i8,
+ this.u8,
+ this.i16,
+ this.u16,
+ this.i32,
+ this.u32,
+ this.i64,
+ this.u64,
+ this.f32,
+ this.f64,
+ v8,
+ vf64
+ );
+}
+}
diff --git a/tests/ts/my-game/example/vec3.ts b/tests/ts/my-game/example/vec3.ts
new file mode 100644
index 00000000..9756977d
--- /dev/null
+++ b/tests/ts/my-game/example/vec3.ts
@@ -0,0 +1,137 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+
+import * as flatbuffers from 'flatbuffers';
+
+import { Color } from '../../my-game/example/color';
+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 === null ? 0 : this.test3.a!),
+ (this.test3 === null ? 0 : this.test3.b!)
+ );
+}
+}
diff --git a/tests/ts/my-game/example2/monster.ts b/tests/ts/my-game/example2/monster.ts
new file mode 100644
index 00000000..14d7685f
--- /dev/null
+++ b/tests/ts/my-game/example2/monster.ts
@@ -0,0 +1,66 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+
+import * as flatbuffers from 'flatbuffers';
+
+
+
+export class Monster {
+ bb: flatbuffers.ByteBuffer|null = null;
+ bb_pos = 0;
+__init(i:number, bb:flatbuffers.ByteBuffer):Monster {
+ this.bb_pos = i;
+ this.bb = bb;
+ return this;
+}
+
+static getRootAsMonster(bb:flatbuffers.ByteBuffer, obj?:Monster):Monster {
+ return (obj || new Monster()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+}
+
+static getSizePrefixedRootAsMonster(bb:flatbuffers.ByteBuffer, obj?:Monster):Monster {
+ bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
+ return (obj || new Monster()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+}
+
+static getFullyQualifiedName():string {
+ return 'MyGame.Example2.Monster';
+}
+
+static startMonster(builder:flatbuffers.Builder) {
+ builder.startObject(0);
+}
+
+static endMonster(builder:flatbuffers.Builder):flatbuffers.Offset {
+ const offset = builder.endObject();
+ return offset;
+}
+
+static createMonster(builder:flatbuffers.Builder):flatbuffers.Offset {
+ Monster.startMonster(builder);
+ return Monster.endMonster(builder);
+}
+
+serialize():Uint8Array {
+ return this.bb!.bytes();
+}
+
+static deserialize(buffer: Uint8Array):Monster {
+ return Monster.getRootAsMonster(new flatbuffers.ByteBuffer(buffer))
+}
+
+unpack(): MonsterT {
+ return new MonsterT();
+}
+
+
+unpackTo(_o: MonsterT): void {}
+}
+
+export class MonsterT {
+constructor(){}
+
+
+pack(builder:flatbuffers.Builder): flatbuffers.Offset {
+ return Monster.createMonster(builder);
+}
+}
diff --git a/tests/ts/my-game/in-parent-namespace.ts b/tests/ts/my-game/in-parent-namespace.ts
new file mode 100644
index 00000000..8cfe9b60
--- /dev/null
+++ b/tests/ts/my-game/in-parent-namespace.ts
@@ -0,0 +1,66 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+
+import * as flatbuffers from 'flatbuffers';
+
+
+
+export class InParentNamespace {
+ bb: flatbuffers.ByteBuffer|null = null;
+ bb_pos = 0;
+__init(i:number, bb:flatbuffers.ByteBuffer):InParentNamespace {
+ this.bb_pos = i;
+ this.bb = bb;
+ return this;
+}
+
+static getRootAsInParentNamespace(bb:flatbuffers.ByteBuffer, obj?:InParentNamespace):InParentNamespace {
+ return (obj || new InParentNamespace()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+}
+
+static getSizePrefixedRootAsInParentNamespace(bb:flatbuffers.ByteBuffer, obj?:InParentNamespace):InParentNamespace {
+ bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
+ return (obj || new InParentNamespace()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+}
+
+static getFullyQualifiedName():string {
+ return 'MyGame.InParentNamespace';
+}
+
+static startInParentNamespace(builder:flatbuffers.Builder) {
+ builder.startObject(0);
+}
+
+static endInParentNamespace(builder:flatbuffers.Builder):flatbuffers.Offset {
+ const offset = builder.endObject();
+ return offset;
+}
+
+static createInParentNamespace(builder:flatbuffers.Builder):flatbuffers.Offset {
+ InParentNamespace.startInParentNamespace(builder);
+ return InParentNamespace.endInParentNamespace(builder);
+}
+
+serialize():Uint8Array {
+ return this.bb!.bytes();
+}
+
+static deserialize(buffer: Uint8Array):InParentNamespace {
+ return InParentNamespace.getRootAsInParentNamespace(new flatbuffers.ByteBuffer(buffer))
+}
+
+unpack(): InParentNamespaceT {
+ return new InParentNamespaceT();
+}
+
+
+unpackTo(_o: InParentNamespaceT): void {}
+}
+
+export class InParentNamespaceT {
+constructor(){}
+
+
+pack(builder:flatbuffers.Builder): flatbuffers.Offset {
+ return InParentNamespace.createInParentNamespace(builder);
+}
+}
diff --git a/tests/ts/rapunzel.ts b/tests/ts/rapunzel.ts
new file mode 100644
index 00000000..382dc158
--- /dev/null
+++ b/tests/ts/rapunzel.ts
@@ -0,0 +1,58 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+
+import * as flatbuffers from 'flatbuffers';
+
+
+
+export class Rapunzel {
+ bb: flatbuffers.ByteBuffer|null = null;
+ bb_pos = 0;
+__init(i:number, bb:flatbuffers.ByteBuffer):Rapunzel {
+ this.bb_pos = i;
+ this.bb = bb;
+ return this;
+}
+
+hairLength():number {
+ return this.bb!.readInt32(this.bb_pos);
+}
+
+static getFullyQualifiedName():string {
+ return 'Rapunzel';
+}
+
+static sizeOf():number {
+ return 4;
+}
+
+static createRapunzel(builder:flatbuffers.Builder, hair_length: number):flatbuffers.Offset {
+ builder.prep(4, 4);
+ builder.writeInt32(hair_length);
+ return builder.offset();
+}
+
+
+unpack(): RapunzelT {
+ return new RapunzelT(
+ this.hairLength()
+ );
+}
+
+
+unpackTo(_o: RapunzelT): void {
+ _o.hairLength = this.hairLength();
+}
+}
+
+export class RapunzelT {
+constructor(
+ public hairLength: number = 0
+){}
+
+
+pack(builder:flatbuffers.Builder): flatbuffers.Offset {
+ return Rapunzel.createRapunzel(builder,
+ this.hairLength
+ );
+}
+}
diff --git a/tests/tsconfig.json b/tests/tsconfig.json
new file mode 100644
index 00000000..4daff463
--- /dev/null
+++ b/tests/tsconfig.json
@@ -0,0 +1,18 @@
+{
+ "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,
+ "outDir": "./ts"
+ },
+ "include": [ "ts/**/*.ts" ],
+ "exclude": []
+}
diff --git a/ts/builder.ts b/ts/builder.ts
index 137031ee..7aad15e2 100644
--- a/ts/builder.ts
+++ b/ts/builder.ts
@@ -586,7 +586,7 @@ export class Builder {
*
* @returns offset of obj
*/
- createObjectOffset(obj: string | IGeneratedObject): Offset {
+ createObjectOffset(obj: string | any): Offset {
if(obj === null) {
return 0
}
@@ -603,7 +603,7 @@ export class Builder {
*
* @returns list of offsets of each non null object
*/
- createObjectOffsetList(list: string[]): Offset[] {
+ createObjectOffsetList(list: string[] | any[]): Offset[] {
const ret: number[] = [];
for(let i = 0; i < list.length; ++i) {
@@ -620,7 +620,7 @@ export class Builder {
return ret;
}
- createStructOffsetList(list: string[], startFunc: (builder: Builder, length: number) => void): Offset {
+ createStructOffsetList(list: string[] | any[], startFunc: (builder: Builder, length: number) => void): Offset {
startFunc(this, list.length);
this.createObjectOffsetList(list);
return this.endVector();
diff --git a/ts/byte-buffer.ts b/ts/byte-buffer.ts
index b936c7b4..f802548a 100644
--- a/ts/byte-buffer.ts
+++ b/ts/byte-buffer.ts
@@ -312,8 +312,8 @@ export class ByteBuffer {
/**
* A helper function for generating list for obj api
*/
- createScalarList(listAccessor: (i: number) => unknown, listLength: number) : unknown[] {
- const ret: unknown[] = [];
+ createScalarList(listAccessor: (i: number) => unknown, listLength: number): any[] {
+ const ret: any[] = [];
for(let i = 0; i < listLength; ++i) {
if(listAccessor(i) !== null) {
ret.push(listAccessor(i));
@@ -324,24 +324,17 @@ export class ByteBuffer {
}
/**
- * This function is here only to get around typescript type system
- */
- createStringList(listAccessor: (i: number) => unknown, listLength: number): unknown[] {
- return this.createScalarList(listAccessor, listLength);
- }
-
- /**
* A helper function for generating list for obj api
* @param listAccessor function that accepts an index and return data at that index
* @param listLength listLength
* @param res result list
*/
- createObjList(listAccessor: (i: number) => IGeneratedObject, listLength: number): IGeneratedObject[] {
- const ret: IGeneratedObject[] = [];
+ createObjList(listAccessor: (i: number) => unknown, listLength: number): any[] {
+ const ret: any[] = [];
for(let i = 0; i < listLength; ++i) {
const val = listAccessor(i);
if(val !== null) {
- ret.push(val.unpack());
+ ret.push((val as IGeneratedObject).unpack());
}
}
diff --git a/ts/flatbuffers.ts b/ts/flatbuffers.ts
index 91845275..e7b0729b 100644
--- a/ts/flatbuffers.ts
+++ b/ts/flatbuffers.ts
@@ -1,34 +1,13 @@
-/* eslint-disable @typescript-eslint/no-namespace */
-import * as constants from './constants'
-import * as types from './types'
-import * as utils from './utils'
+export { SIZEOF_SHORT } from './constants'
+export { SIZEOF_INT } from './constants'
+export { FILE_IDENTIFIER_LENGTH } from './constants'
+export { SIZE_PREFIX_LENGTH } from './constants'
-import { Long as LongClass } from './long'
-import { Encoding as EncodingEnum } from './encoding'
-import { Builder as BuilderClass } from './builder'
-import { ByteBuffer as ByteBufferClass } from './byte-buffer'
+export { Table, Offset } from './types'
-export namespace flatbuffers {
+export { int32, float32, float64, isLittleEndian } from './utils'
- export type Offset = types.Offset;
-
- export type Table = types.Table;
-
- export const SIZEOF_SHORT = constants.SIZEOF_SHORT;
- export const SIZEOF_INT = constants.SIZEOF_INT;
- export const FILE_IDENTIFIER_LENGTH = constants.FILE_IDENTIFIER_LENGTH;
- export const SIZE_PREFIX_LENGTH = constants.SIZE_PREFIX_LENGTH;
-
- export const Encoding = EncodingEnum;
-
- export const int32 = utils.int32;
- export const float32 = utils.float32;
- export const float64 = utils.float64;
- export const isLittleEndian = utils.isLittleEndian;
-
- export const Long = LongClass;
- export const Builder = BuilderClass;
- export const ByteBuffer = ByteBufferClass;
-}
-
-export default flatbuffers;
+export { Long, createLong } from './long'
+export { Encoding } from './encoding'
+export { Builder } from './builder'
+export { ByteBuffer } from './byte-buffer'
diff --git a/ts/flexbuffers.ts b/ts/flexbuffers.ts
index 40482dcb..fa518ecd 100644
--- a/ts/flexbuffers.ts
+++ b/ts/flexbuffers.ts
@@ -1,13 +1,14 @@
/* eslint-disable @typescript-eslint/no-namespace */
import { Builder } from './flexbuffers/builder'
-import { toReference as toReferenceFunction } from './flexbuffers/reference';
+import { toReference } from './flexbuffers/reference'
+export { toReference } from './flexbuffers/reference'
export function builder(): Builder {
return new Builder();
}
export function toObject(buffer: Uint8Array): unknown {
- return toReferenceFunction(buffer).toObject();
+ return toReference(buffer).toObject();
}
export function encode(object: unknown, size = 2048, deduplicateStrings = true, deduplicateKeys = true, deduplicateKeyVectors = true): Uint8Array {
@@ -15,16 +16,3 @@ export function encode(object: unknown, size = 2048, deduplicateStrings = true,
builder.add(object);
return builder.finish();
}
-
-const builderFunction = builder
-const toObjectFunction = toObject
-const encodeFunction = encode
-
-export namespace flexbuffers {
- export const builder = builderFunction;
- export const toObject = toObjectFunction;
- export const encode = encodeFunction;
- export const toReference = toReferenceFunction;
-}
-
-export default flexbuffers;
diff --git a/yarn.lock b/yarn.lock
deleted file mode 100644
index 0ec94ddc..00000000
--- a/yarn.lock
+++ /dev/null
@@ -1,956 +0,0 @@
-# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
-# yarn lockfile v1
-
-
-"@babel/code-frame@^7.0.0":
- version "7.10.4"
- resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.10.4.tgz#168da1a36e90da68ae8d49c0f1b48c7c6249213a"
- integrity sha512-vG6SvB6oYEhvgisZNFRmRCUkLz11c7rp+tbNTynGqc6mS1d5ATd/sGyV6W0KZZnXRKMTzZDRgQT3Ou9jhpAfUg==
- dependencies:
- "@babel/highlight" "^7.10.4"
-
-"@babel/helper-validator-identifier@^7.10.4":
- version "7.10.4"
- resolved "https://registry.yarnpkg.com/@babel/helper-validator-identifier/-/helper-validator-identifier-7.10.4.tgz#a78c7a7251e01f616512d31b10adcf52ada5e0d2"
- integrity sha512-3U9y+43hz7ZM+rzG24Qe2mufW5KhvFg/NhnNph+i9mgCtdTCtMJuI1TMkrIUiK7Ix4PYlRF9I5dhqaLYA/ADXw==
-
-"@babel/highlight@^7.10.4":
- version "7.10.4"
- resolved "https://registry.yarnpkg.com/@babel/highlight/-/highlight-7.10.4.tgz#7d1bdfd65753538fabe6c38596cdb76d9ac60143"
- integrity sha512-i6rgnR/YgPEQzZZnbTHHuZdlE8qyoBNalD6F+q4vAFlcMEcqmkoG+mPqJYJCo63qPf74+Y1UZsl3l6f7/RIkmA==
- dependencies:
- "@babel/helper-validator-identifier" "^7.10.4"
- chalk "^2.0.0"
- js-tokens "^4.0.0"
-
-"@eslint/eslintrc@^0.1.3":
- version "0.1.3"
- resolved "https://registry.yarnpkg.com/@eslint/eslintrc/-/eslintrc-0.1.3.tgz#7d1a2b2358552cc04834c0979bd4275362e37085"
- integrity sha512-4YVwPkANLeNtRjMekzux1ci8hIaH5eGKktGqR0d3LWsKNn5B2X/1Z6Trxy7jQXl9EBGE6Yj02O+t09FMeRllaA==
- dependencies:
- ajv "^6.12.4"
- debug "^4.1.1"
- espree "^7.3.0"
- globals "^12.1.0"
- ignore "^4.0.6"
- import-fresh "^3.2.1"
- js-yaml "^3.13.1"
- lodash "^4.17.19"
- minimatch "^3.0.4"
- strip-json-comments "^3.1.1"
-
-"@nodelib/fs.scandir@2.1.3":
- version "2.1.3"
- resolved "https://registry.yarnpkg.com/@nodelib/fs.scandir/-/fs.scandir-2.1.3.tgz#3a582bdb53804c6ba6d146579c46e52130cf4a3b"
- integrity sha512-eGmwYQn3gxo4r7jdQnkrrN6bY478C3P+a/y72IJukF8LjB6ZHeB3c+Ehacj3sYeSmUXGlnA67/PmbM9CVwL7Dw==
- dependencies:
- "@nodelib/fs.stat" "2.0.3"
- run-parallel "^1.1.9"
-
-"@nodelib/fs.stat@2.0.3", "@nodelib/fs.stat@^2.0.2":
- version "2.0.3"
- resolved "https://registry.yarnpkg.com/@nodelib/fs.stat/-/fs.stat-2.0.3.tgz#34dc5f4cabbc720f4e60f75a747e7ecd6c175bd3"
- integrity sha512-bQBFruR2TAwoevBEd/NWMoAAtNGzTRgdrqnYCc7dhzfoNvqPzLyqlEQnzZ3kVnNrSp25iyxE00/3h2fqGAGArA==
-
-"@nodelib/fs.walk@^1.2.3":
- version "1.2.4"
- resolved "https://registry.yarnpkg.com/@nodelib/fs.walk/-/fs.walk-1.2.4.tgz#011b9202a70a6366e436ca5c065844528ab04976"
- integrity sha512-1V9XOY4rDW0rehzbrcqAmHnz8e7SKvX27gh8Gt2WgB0+pdzdiLV83p72kZPU+jvMbS1qU5mauP2iOvO8rhmurQ==
- dependencies:
- "@nodelib/fs.scandir" "2.1.3"
- fastq "^1.6.0"
-
-"@types/color-name@^1.1.1":
- version "1.1.1"
- resolved "https://registry.yarnpkg.com/@types/color-name/-/color-name-1.1.1.tgz#1c1261bbeaa10a8055bbc5d8ab84b7b2afc846a0"
- integrity sha512-rr+OQyAjxze7GgWrSaJwydHStIhHq2lvY3BOC2Mj7KnzI7XK0Uw1TOOdI9lDoajEbSWLiYgoo4f1R51erQfhPQ==
-
-"@types/json-schema@^7.0.3":
- version "7.0.6"
- resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.6.tgz#f4c7ec43e81b319a9815115031709f26987891f0"
- integrity sha512-3c+yGKvVP5Y9TYBEibGNR+kLtijnj7mYrXRg+WpFb2X9xm04g/DXYkfg4hmzJQosc9snFNUPkbYIhu+KAm6jJw==
-
-"@typescript-eslint/eslint-plugin@^4.1.0":
- version "4.1.0"
- resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-4.1.0.tgz#7d309f60815ff35e9627ad85e41928d7b7fd443f"
- integrity sha512-U+nRJx8XDUqJxYF0FCXbpmD9nWt/xHDDG0zsw1vrVYAmEAuD/r49iowfurjSL2uTA2JsgtpsyG7mjO7PHf2dYw==
- dependencies:
- "@typescript-eslint/experimental-utils" "4.1.0"
- "@typescript-eslint/scope-manager" "4.1.0"
- debug "^4.1.1"
- functional-red-black-tree "^1.0.1"
- regexpp "^3.0.0"
- semver "^7.3.2"
- tsutils "^3.17.1"
-
-"@typescript-eslint/experimental-utils@4.1.0":
- version "4.1.0"
- resolved "https://registry.yarnpkg.com/@typescript-eslint/experimental-utils/-/experimental-utils-4.1.0.tgz#263d7225645c09a411c8735eeffd417f50f49026"
- integrity sha512-paEYLA37iqRIDPeQwAmoYSiZ3PiHsaAc3igFeBTeqRHgPnHjHLJ9OGdmP6nwAkF65p2QzEsEBtpjNUBWByNWzA==
- dependencies:
- "@types/json-schema" "^7.0.3"
- "@typescript-eslint/scope-manager" "4.1.0"
- "@typescript-eslint/types" "4.1.0"
- "@typescript-eslint/typescript-estree" "4.1.0"
- eslint-scope "^5.0.0"
- eslint-utils "^2.0.0"
-
-"@typescript-eslint/parser@^4.1.0":
- version "4.1.0"
- resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-4.1.0.tgz#9b0409411725f14cd7faa81a664e5051225961db"
- integrity sha512-hM/WNCQTzDHgS0Ke3cR9zPndL3OTKr9OoN9CL3UqulsAjYDrglSwIIgswSmHBcSbOzLmgaMARwrQEbIumIglvQ==
- dependencies:
- "@typescript-eslint/scope-manager" "4.1.0"
- "@typescript-eslint/types" "4.1.0"
- "@typescript-eslint/typescript-estree" "4.1.0"
- debug "^4.1.1"
-
-"@typescript-eslint/scope-manager@4.1.0":
- version "4.1.0"
- resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-4.1.0.tgz#9e389745ee9cfe12252ed1e9958808abd6b3a683"
- integrity sha512-HD1/u8vFNnxwiHqlWKC/Pigdn0Mvxi84Y6GzbZ5f5sbLrFKu0al02573Er+D63Sw67IffVUXR0uR8rpdfdk+vA==
- dependencies:
- "@typescript-eslint/types" "4.1.0"
- "@typescript-eslint/visitor-keys" "4.1.0"
-
-"@typescript-eslint/types@4.1.0":
- version "4.1.0"
- resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-4.1.0.tgz#edbd3fec346f34e13ce7aa176b03b497a32c496a"
- integrity sha512-rkBqWsO7m01XckP9R2YHVN8mySOKKY2cophGM8K5uDK89ArCgahItQYdbg/3n8xMxzu2elss+an1TphlUpDuJw==
-
-"@typescript-eslint/typescript-estree@4.1.0":
- version "4.1.0"
- resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-4.1.0.tgz#394046ead25164494218c0e3d6b960695ea967f6"
- integrity sha512-r6et57qqKAWU173nWyw31x7OfgmKfMEcjJl9vlJEzS+kf9uKNRr4AVTRXfTCwebr7bdiVEkfRY5xGnpPaNPe4Q==
- dependencies:
- "@typescript-eslint/types" "4.1.0"
- "@typescript-eslint/visitor-keys" "4.1.0"
- debug "^4.1.1"
- globby "^11.0.1"
- is-glob "^4.0.1"
- lodash "^4.17.15"
- semver "^7.3.2"
- tsutils "^3.17.1"
-
-"@typescript-eslint/visitor-keys@4.1.0":
- version "4.1.0"
- resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-4.1.0.tgz#b2d528c9484e7eda1aa4f86ccf0432fb16e4d545"
- integrity sha512-+taO0IZGCtCEsuNTTF2Q/5o8+fHrlml8i9YsZt2AiDCdYEJzYlsmRY991l/6f3jNXFyAWepdQj7n8Na6URiDRQ==
- dependencies:
- "@typescript-eslint/types" "4.1.0"
- eslint-visitor-keys "^2.0.0"
-
-acorn-jsx@^5.2.0:
- version "5.3.1"
- resolved "https://registry.yarnpkg.com/acorn-jsx/-/acorn-jsx-5.3.1.tgz#fc8661e11b7ac1539c47dbfea2e72b3af34d267b"
- integrity sha512-K0Ptm/47OKfQRpNQ2J/oIN/3QYiK6FwW+eJbILhsdxh2WTLdl+30o8aGdTbm5JbffpFFAg/g+zi1E+jvJha5ng==
-
-acorn@^7.4.0:
- version "7.4.0"
- resolved "https://registry.yarnpkg.com/acorn/-/acorn-7.4.0.tgz#e1ad486e6c54501634c6c397c5c121daa383607c"
- integrity sha512-+G7P8jJmCHr+S+cLfQxygbWhXy+8YTVGzAkpEbcLo2mLoL7tij/VG41QSHACSf5QgYRhMZYHuNc6drJaO0Da+w==
-
-ajv@^6.10.0, ajv@^6.10.2, ajv@^6.12.4:
- version "6.12.4"
- resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.12.4.tgz#0614facc4522127fa713445c6bfd3ebd376e2234"
- integrity sha512-eienB2c9qVQs2KWexhkrdMLVDoIQCz5KSeLxwg9Lzk4DOfBtIK9PQwwufcsn1jjGuf9WZmqPMbGxOzfcuphJCQ==
- dependencies:
- fast-deep-equal "^3.1.1"
- fast-json-stable-stringify "^2.0.0"
- json-schema-traverse "^0.4.1"
- uri-js "^4.2.2"
-
-ansi-colors@^4.1.1:
- version "4.1.1"
- resolved "https://registry.yarnpkg.com/ansi-colors/-/ansi-colors-4.1.1.tgz#cbb9ae256bf750af1eab344f229aa27fe94ba348"
- integrity sha512-JoX0apGbHaUJBNl6yF+p6JAFYZ666/hhCGKN5t9QFjbJQKUU/g8MNbFDbvfrgKXvI1QpZplPOnwIo99lX/AAmA==
-
-ansi-regex@^4.1.0:
- version "4.1.0"
- resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-4.1.0.tgz#8b9f8f08cf1acb843756a839ca8c7e3168c51997"
- integrity sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==
-
-ansi-regex@^5.0.0:
- version "5.0.0"
- resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-5.0.0.tgz#388539f55179bf39339c81af30a654d69f87cb75"
- integrity sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg==
-
-ansi-styles@^3.2.0, ansi-styles@^3.2.1:
- version "3.2.1"
- resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-3.2.1.tgz#41fbb20243e50b12be0f04b8dedbf07520ce841d"
- integrity sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==
- dependencies:
- color-convert "^1.9.0"
-
-ansi-styles@^4.1.0:
- version "4.2.1"
- resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-4.2.1.tgz#90ae75c424d008d2624c5bf29ead3177ebfcf359"
- integrity sha512-9VGjrMsG1vePxcSweQsN20KY/c4zN0h9fLjqAbwbPfahM3t+NL+M9HC8xeXG2I8pX5NoamTGNuomEUFI7fcUjA==
- dependencies:
- "@types/color-name" "^1.1.1"
- color-convert "^2.0.1"
-
-argparse@^1.0.7:
- version "1.0.10"
- resolved "https://registry.yarnpkg.com/argparse/-/argparse-1.0.10.tgz#bcd6791ea5ae09725e17e5ad988134cd40b3d911"
- integrity sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==
- dependencies:
- sprintf-js "~1.0.2"
-
-array-union@^2.1.0:
- version "2.1.0"
- resolved "https://registry.yarnpkg.com/array-union/-/array-union-2.1.0.tgz#b798420adbeb1de828d84acd8a2e23d3efe85e8d"
- integrity sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw==
-
-astral-regex@^1.0.0:
- version "1.0.0"
- resolved "https://registry.yarnpkg.com/astral-regex/-/astral-regex-1.0.0.tgz#6c8c3fb827dd43ee3918f27b82782ab7658a6fd9"
- integrity sha512-+Ryf6g3BKoRc7jfp7ad8tM4TtMiaWvbF/1/sQcZPkkS7ag3D5nMBCe2UfOTONtAkaG0tO0ij3C5Lwmf1EiyjHg==
-
-balanced-match@^1.0.0:
- version "1.0.0"
- resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.0.tgz#89b4d199ab2bee49de164ea02b89ce462d71b767"
- integrity sha1-ibTRmasr7kneFk6gK4nORi1xt2c=
-
-brace-expansion@^1.1.7:
- version "1.1.11"
- resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd"
- integrity sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==
- dependencies:
- balanced-match "^1.0.0"
- concat-map "0.0.1"
-
-braces@^3.0.1:
- version "3.0.2"
- resolved "https://registry.yarnpkg.com/braces/-/braces-3.0.2.tgz#3454e1a462ee8d599e236df336cd9ea4f8afe107"
- integrity sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==
- dependencies:
- fill-range "^7.0.1"
-
-callsites@^3.0.0:
- version "3.1.0"
- resolved "https://registry.yarnpkg.com/callsites/-/callsites-3.1.0.tgz#b3630abd8943432f54b3f0519238e33cd7df2f73"
- integrity sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==
-
-chalk@^2.0.0:
- version "2.4.2"
- resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.2.tgz#cd42541677a54333cf541a49108c1432b44c9424"
- integrity sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==
- dependencies:
- ansi-styles "^3.2.1"
- escape-string-regexp "^1.0.5"
- supports-color "^5.3.0"
-
-chalk@^4.0.0:
- version "4.1.0"
- resolved "https://registry.yarnpkg.com/chalk/-/chalk-4.1.0.tgz#4e14870a618d9e2edd97dd8345fd9d9dc315646a"
- integrity sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A==
- dependencies:
- ansi-styles "^4.1.0"
- supports-color "^7.1.0"
-
-color-convert@^1.9.0:
- version "1.9.3"
- resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-1.9.3.tgz#bb71850690e1f136567de629d2d5471deda4c1e8"
- integrity sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==
- dependencies:
- color-name "1.1.3"
-
-color-convert@^2.0.1:
- version "2.0.1"
- resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-2.0.1.tgz#72d3a68d598c9bdb3af2ad1e84f21d896abd4de3"
- integrity sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==
- dependencies:
- color-name "~1.1.4"
-
-color-name@1.1.3:
- version "1.1.3"
- resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.3.tgz#a7d0558bd89c42f795dd42328f740831ca53bc25"
- integrity sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=
-
-color-name@~1.1.4:
- version "1.1.4"
- resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.4.tgz#c2a09a87acbde69543de6f63fa3995c826c536a2"
- integrity sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==
-
-concat-map@0.0.1:
- version "0.0.1"
- resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b"
- integrity sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=
-
-cross-spawn@^7.0.2:
- version "7.0.3"
- resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-7.0.3.tgz#f73a85b9d5d41d045551c177e2882d4ac85728a6"
- integrity sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==
- dependencies:
- path-key "^3.1.0"
- shebang-command "^2.0.0"
- which "^2.0.1"
-
-debug@^4.0.1, debug@^4.1.1:
- version "4.1.1"
- resolved "https://registry.yarnpkg.com/debug/-/debug-4.1.1.tgz#3b72260255109c6b589cee050f1d516139664791"
- integrity sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==
- dependencies:
- ms "^2.1.1"
-
-deep-is@^0.1.3:
- version "0.1.3"
- resolved "https://registry.yarnpkg.com/deep-is/-/deep-is-0.1.3.tgz#b369d6fb5dbc13eecf524f91b070feedc357cf34"
- integrity sha1-s2nW+128E+7PUk+RsHD+7cNXzzQ=
-
-dir-glob@^3.0.1:
- version "3.0.1"
- resolved "https://registry.yarnpkg.com/dir-glob/-/dir-glob-3.0.1.tgz#56dbf73d992a4a93ba1584f4534063fd2e41717f"
- integrity sha512-WkrWp9GR4KXfKGYzOLmTuGVi1UWFfws377n9cc55/tb6DuqyF6pcQ5AbiHEshaDpY9v6oaSr2XCDidGmMwdzIA==
- dependencies:
- path-type "^4.0.0"
-
-doctrine@^3.0.0:
- version "3.0.0"
- resolved "https://registry.yarnpkg.com/doctrine/-/doctrine-3.0.0.tgz#addebead72a6574db783639dc87a121773973961"
- integrity sha512-yS+Q5i3hBf7GBkd4KG8a7eBNNWNGLTaEwwYWUijIYM7zrlYDM0BFXHjjPWlWZ1Rg7UaddZeIDmi9jF3HmqiQ2w==
- dependencies:
- esutils "^2.0.2"
-
-emoji-regex@^7.0.1:
- version "7.0.3"
- resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-7.0.3.tgz#933a04052860c85e83c122479c4748a8e4c72156"
- integrity sha512-CwBLREIQ7LvYFB0WyRvwhq5N5qPhc6PMjD6bYggFlI5YyDgl+0vxq5VHbMOFqLg7hfWzmu8T5Z1QofhmTIhItA==
-
-enquirer@^2.3.5:
- version "2.3.6"
- resolved "https://registry.yarnpkg.com/enquirer/-/enquirer-2.3.6.tgz#2a7fe5dd634a1e4125a975ec994ff5456dc3734d"
- integrity sha512-yjNnPr315/FjS4zIsUxYguYUPP2e1NK4d7E7ZOLiyYCcbFBiTMyID+2wvm2w6+pZ/odMA7cRkjhsPbltwBOrLg==
- dependencies:
- ansi-colors "^4.1.1"
-
-escape-string-regexp@^1.0.5:
- version "1.0.5"
- resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4"
- integrity sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=
-
-eslint-scope@^5.0.0, eslint-scope@^5.1.0:
- version "5.1.0"
- resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-5.1.0.tgz#d0f971dfe59c69e0cada684b23d49dbf82600ce5"
- integrity sha512-iiGRvtxWqgtx5m8EyQUJihBloE4EnYeGE/bz1wSPwJE6tZuJUtHlhqDM4Xj2ukE8Dyy1+HCZ4hE0fzIVMzb58w==
- dependencies:
- esrecurse "^4.1.0"
- estraverse "^4.1.1"
-
-eslint-utils@^2.0.0, eslint-utils@^2.1.0:
- version "2.1.0"
- resolved "https://registry.yarnpkg.com/eslint-utils/-/eslint-utils-2.1.0.tgz#d2de5e03424e707dc10c74068ddedae708741b27"
- integrity sha512-w94dQYoauyvlDc43XnGB8lU3Zt713vNChgt4EWwhXAP2XkBvndfxF0AgIqKOOasjPIPzj9JqgwkwbCYD0/V3Zg==
- dependencies:
- eslint-visitor-keys "^1.1.0"
-
-eslint-visitor-keys@^1.1.0, eslint-visitor-keys@^1.3.0:
- version "1.3.0"
- resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-1.3.0.tgz#30ebd1ef7c2fdff01c3a4f151044af25fab0523e"
- integrity sha512-6J72N8UNa462wa/KFODt/PJ3IU60SDpC3QXC1Hjc1BXXpfL2C9R5+AU7jhe0F6GREqVMh4Juu+NY7xn+6dipUQ==
-
-eslint-visitor-keys@^2.0.0:
- version "2.0.0"
- resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-2.0.0.tgz#21fdc8fbcd9c795cc0321f0563702095751511a8"
- integrity sha512-QudtT6av5WXels9WjIM7qz1XD1cWGvX4gGXvp/zBn9nXG02D0utdU3Em2m/QjTnrsk6bBjmCygl3rmj118msQQ==
-
-eslint@^7.8.1:
- version "7.8.1"
- resolved "https://registry.yarnpkg.com/eslint/-/eslint-7.8.1.tgz#e59de3573fb6a5be8ff526c791571646d124a8fa"
- integrity sha512-/2rX2pfhyUG0y+A123d0ccXtMm7DV7sH1m3lk9nk2DZ2LReq39FXHueR9xZwshE5MdfSf0xunSaMWRqyIA6M1w==
- dependencies:
- "@babel/code-frame" "^7.0.0"
- "@eslint/eslintrc" "^0.1.3"
- ajv "^6.10.0"
- chalk "^4.0.0"
- cross-spawn "^7.0.2"
- debug "^4.0.1"
- doctrine "^3.0.0"
- enquirer "^2.3.5"
- eslint-scope "^5.1.0"
- eslint-utils "^2.1.0"
- eslint-visitor-keys "^1.3.0"
- espree "^7.3.0"
- esquery "^1.2.0"
- esutils "^2.0.2"
- file-entry-cache "^5.0.1"
- functional-red-black-tree "^1.0.1"
- glob-parent "^5.0.0"
- globals "^12.1.0"
- ignore "^4.0.6"
- import-fresh "^3.0.0"
- imurmurhash "^0.1.4"
- is-glob "^4.0.0"
- js-yaml "^3.13.1"
- json-stable-stringify-without-jsonify "^1.0.1"
- levn "^0.4.1"
- lodash "^4.17.19"
- minimatch "^3.0.4"
- natural-compare "^1.4.0"
- optionator "^0.9.1"
- progress "^2.0.0"
- regexpp "^3.1.0"
- semver "^7.2.1"
- strip-ansi "^6.0.0"
- strip-json-comments "^3.1.0"
- table "^5.2.3"
- text-table "^0.2.0"
- v8-compile-cache "^2.0.3"
-
-espree@^7.3.0:
- version "7.3.0"
- resolved "https://registry.yarnpkg.com/espree/-/espree-7.3.0.tgz#dc30437cf67947cf576121ebd780f15eeac72348"
- integrity sha512-dksIWsvKCixn1yrEXO8UosNSxaDoSYpq9reEjZSbHLpT5hpaCAKTLBwq0RHtLrIr+c0ByiYzWT8KTMRzoRCNlw==
- dependencies:
- acorn "^7.4.0"
- acorn-jsx "^5.2.0"
- eslint-visitor-keys "^1.3.0"
-
-esprima@^4.0.0:
- version "4.0.1"
- resolved "https://registry.yarnpkg.com/esprima/-/esprima-4.0.1.tgz#13b04cdb3e6c5d19df91ab6987a8695619b0aa71"
- integrity sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==
-
-esquery@^1.2.0:
- version "1.3.1"
- resolved "https://registry.yarnpkg.com/esquery/-/esquery-1.3.1.tgz#b78b5828aa8e214e29fb74c4d5b752e1c033da57"
- integrity sha512-olpvt9QG0vniUBZspVRN6lwB7hOZoTRtT+jzR+tS4ffYx2mzbw+z0XCOk44aaLYKApNX5nMm+E+P6o25ip/DHQ==
- dependencies:
- estraverse "^5.1.0"
-
-esrecurse@^4.1.0:
- version "4.3.0"
- resolved "https://registry.yarnpkg.com/esrecurse/-/esrecurse-4.3.0.tgz#7ad7964d679abb28bee72cec63758b1c5d2c9921"
- integrity sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag==
- dependencies:
- estraverse "^5.2.0"
-
-estraverse@^4.1.1:
- version "4.3.0"
- resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-4.3.0.tgz#398ad3f3c5a24948be7725e83d11a7de28cdbd1d"
- integrity sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==
-
-estraverse@^5.1.0, estraverse@^5.2.0:
- version "5.2.0"
- resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-5.2.0.tgz#307df42547e6cc7324d3cf03c155d5cdb8c53880"
- integrity sha512-BxbNGGNm0RyRYvUdHpIwv9IWzeM9XClbOxwoATuFdOE7ZE6wHL+HQ5T8hoPM+zHvmKzzsEqhgy0GrQ5X13afiQ==
-
-esutils@^2.0.2:
- version "2.0.3"
- resolved "https://registry.yarnpkg.com/esutils/-/esutils-2.0.3.tgz#74d2eb4de0b8da1293711910d50775b9b710ef64"
- integrity sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==
-
-fast-deep-equal@^3.1.1:
- version "3.1.3"
- resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz#3a7d56b559d6cbc3eb512325244e619a65c6c525"
- integrity sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==
-
-fast-glob@^3.1.1:
- version "3.2.4"
- resolved "https://registry.yarnpkg.com/fast-glob/-/fast-glob-3.2.4.tgz#d20aefbf99579383e7f3cc66529158c9b98554d3"
- integrity sha512-kr/Oo6PX51265qeuCYsyGypiO5uJFgBS0jksyG7FUeCyQzNwYnzrNIMR1NXfkZXsMYXYLRAHgISHBz8gQcxKHQ==
- dependencies:
- "@nodelib/fs.stat" "^2.0.2"
- "@nodelib/fs.walk" "^1.2.3"
- glob-parent "^5.1.0"
- merge2 "^1.3.0"
- micromatch "^4.0.2"
- picomatch "^2.2.1"
-
-fast-json-stable-stringify@^2.0.0:
- version "2.1.0"
- resolved "https://registry.yarnpkg.com/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz#874bf69c6f404c2b5d99c481341399fd55892633"
- integrity sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==
-
-fast-levenshtein@^2.0.6:
- version "2.0.6"
- resolved "https://registry.yarnpkg.com/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz#3d8a5c66883a16a30ca8643e851f19baa7797917"
- integrity sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=
-
-fastq@^1.6.0:
- version "1.8.0"
- resolved "https://registry.yarnpkg.com/fastq/-/fastq-1.8.0.tgz#550e1f9f59bbc65fe185cb6a9b4d95357107f481"
- integrity sha512-SMIZoZdLh/fgofivvIkmknUXyPnvxRE3DhtZ5Me3Mrsk5gyPL42F0xr51TdRXskBxHfMp+07bcYzfsYEsSQA9Q==
- dependencies:
- reusify "^1.0.4"
-
-file-entry-cache@^5.0.1:
- version "5.0.1"
- resolved "https://registry.yarnpkg.com/file-entry-cache/-/file-entry-cache-5.0.1.tgz#ca0f6efa6dd3d561333fb14515065c2fafdf439c"
- integrity sha512-bCg29ictuBaKUwwArK4ouCaqDgLZcysCFLmM/Yn/FDoqndh/9vNuQfXRDvTuXKLxfD/JtZQGKFT8MGcJBK644g==
- dependencies:
- flat-cache "^2.0.1"
-
-fill-range@^7.0.1:
- version "7.0.1"
- resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-7.0.1.tgz#1919a6a7c75fe38b2c7c77e5198535da9acdda40"
- integrity sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==
- dependencies:
- to-regex-range "^5.0.1"
-
-flat-cache@^2.0.1:
- version "2.0.1"
- resolved "https://registry.yarnpkg.com/flat-cache/-/flat-cache-2.0.1.tgz#5d296d6f04bda44a4630a301413bdbc2ec085ec0"
- integrity sha512-LoQe6yDuUMDzQAEH8sgmh4Md6oZnc/7PjtwjNFSzveXqSHt6ka9fPBuso7IGf9Rz4uqnSnWiFH2B/zj24a5ReA==
- dependencies:
- flatted "^2.0.0"
- rimraf "2.6.3"
- write "1.0.3"
-
-flatted@^2.0.0:
- version "2.0.2"
- resolved "https://registry.yarnpkg.com/flatted/-/flatted-2.0.2.tgz#4575b21e2bcee7434aa9be662f4b7b5f9c2b5138"
- integrity sha512-r5wGx7YeOwNWNlCA0wQ86zKyDLMQr+/RB8xy74M4hTphfmjlijTSSXGuH8rnvKZnfT9i+75zmd8jcKdMR4O6jA==
-
-fs.realpath@^1.0.0:
- version "1.0.0"
- resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f"
- integrity sha1-FQStJSMVjKpA20onh8sBQRmU6k8=
-
-functional-red-black-tree@^1.0.1:
- version "1.0.1"
- resolved "https://registry.yarnpkg.com/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz#1b0ab3bd553b2a0d6399d29c0e3ea0b252078327"
- integrity sha1-GwqzvVU7Kg1jmdKcDj6gslIHgyc=
-
-glob-parent@^5.0.0, glob-parent@^5.1.0:
- version "5.1.1"
- resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-5.1.1.tgz#b6c1ef417c4e5663ea498f1c45afac6916bbc229"
- integrity sha512-FnI+VGOpnlGHWZxthPGR+QhR78fuiK0sNLkHQv+bL9fQi57lNNdquIbna/WrfROrolq8GK5Ek6BiMwqL/voRYQ==
- dependencies:
- is-glob "^4.0.1"
-
-glob@^7.1.3:
- version "7.1.6"
- resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.6.tgz#141f33b81a7c2492e125594307480c46679278a6"
- integrity sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==
- dependencies:
- fs.realpath "^1.0.0"
- inflight "^1.0.4"
- inherits "2"
- minimatch "^3.0.4"
- once "^1.3.0"
- path-is-absolute "^1.0.0"
-
-globals@^12.1.0:
- version "12.4.0"
- resolved "https://registry.yarnpkg.com/globals/-/globals-12.4.0.tgz#a18813576a41b00a24a97e7f815918c2e19925f8"
- integrity sha512-BWICuzzDvDoH54NHKCseDanAhE3CeDorgDL5MT6LMXXj2WCnd9UC2szdk4AWLfjdgNBCXLUanXYcpBBKOSWGwg==
- dependencies:
- type-fest "^0.8.1"
-
-globby@^11.0.1:
- version "11.0.1"
- resolved "https://registry.yarnpkg.com/globby/-/globby-11.0.1.tgz#9a2bf107a068f3ffeabc49ad702c79ede8cfd357"
- integrity sha512-iH9RmgwCmUJHi2z5o2l3eTtGBtXek1OYlHrbcxOYugyHLmAsZrPj43OtHThd62Buh/Vv6VyCBD2bdyWcGNQqoQ==
- dependencies:
- array-union "^2.1.0"
- dir-glob "^3.0.1"
- fast-glob "^3.1.1"
- ignore "^5.1.4"
- merge2 "^1.3.0"
- slash "^3.0.0"
-
-has-flag@^3.0.0:
- version "3.0.0"
- resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-3.0.0.tgz#b5d454dc2199ae225699f3467e5a07f3b955bafd"
- integrity sha1-tdRU3CGZriJWmfNGfloH87lVuv0=
-
-has-flag@^4.0.0:
- version "4.0.0"
- resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-4.0.0.tgz#944771fd9c81c81265c4d6941860da06bb59479b"
- integrity sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==
-
-ignore@^4.0.6:
- version "4.0.6"
- resolved "https://registry.yarnpkg.com/ignore/-/ignore-4.0.6.tgz#750e3db5862087b4737ebac8207ffd1ef27b25fc"
- integrity sha512-cyFDKrqc/YdcWFniJhzI42+AzS+gNwmUzOSFcRCQYwySuBBBy/KjuxWLZ/FHEH6Moq1NizMOBWyTcv8O4OZIMg==
-
-ignore@^5.1.4:
- version "5.1.8"
- resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.1.8.tgz#f150a8b50a34289b33e22f5889abd4d8016f0e57"
- integrity sha512-BMpfD7PpiETpBl/A6S498BaIJ6Y/ABT93ETbby2fP00v4EbvPBXWEoaR1UBPKs3iR53pJY7EtZk5KACI57i1Uw==
-
-import-fresh@^3.0.0, import-fresh@^3.2.1:
- version "3.2.1"
- resolved "https://registry.yarnpkg.com/import-fresh/-/import-fresh-3.2.1.tgz#633ff618506e793af5ac91bf48b72677e15cbe66"
- integrity sha512-6e1q1cnWP2RXD9/keSkxHScg508CdXqXWgWBaETNhyuBFz+kUZlKboh+ISK+bU++DmbHimVBrOz/zzPe0sZ3sQ==
- dependencies:
- parent-module "^1.0.0"
- resolve-from "^4.0.0"
-
-imurmurhash@^0.1.4:
- version "0.1.4"
- resolved "https://registry.yarnpkg.com/imurmurhash/-/imurmurhash-0.1.4.tgz#9218b9b2b928a238b13dc4fb6b6d576f231453ea"
- integrity sha1-khi5srkoojixPcT7a21XbyMUU+o=
-
-inflight@^1.0.4:
- version "1.0.6"
- resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9"
- integrity sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=
- dependencies:
- once "^1.3.0"
- wrappy "1"
-
-inherits@2:
- version "2.0.4"
- resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c"
- integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==
-
-is-extglob@^2.1.1:
- version "2.1.1"
- resolved "https://registry.yarnpkg.com/is-extglob/-/is-extglob-2.1.1.tgz#a88c02535791f02ed37c76a1b9ea9773c833f8c2"
- integrity sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=
-
-is-fullwidth-code-point@^2.0.0:
- version "2.0.0"
- resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz#a3b30a5c4f199183167aaab93beefae3ddfb654f"
- integrity sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=
-
-is-glob@^4.0.0, is-glob@^4.0.1:
- version "4.0.1"
- resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-4.0.1.tgz#7567dbe9f2f5e2467bc77ab83c4a29482407a5dc"
- integrity sha512-5G0tKtBTFImOqDnLB2hG6Bp2qcKEFduo4tZu9MT/H6NQv/ghhy30o55ufafxJ/LdH79LLs2Kfrn85TLKyA7BUg==
- dependencies:
- is-extglob "^2.1.1"
-
-is-number@^7.0.0:
- version "7.0.0"
- resolved "https://registry.yarnpkg.com/is-number/-/is-number-7.0.0.tgz#7535345b896734d5f80c4d06c50955527a14f12b"
- integrity sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==
-
-isexe@^2.0.0:
- version "2.0.0"
- resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10"
- integrity sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=
-
-js-tokens@^4.0.0:
- version "4.0.0"
- resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499"
- integrity sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==
-
-js-yaml@^3.13.1:
- version "3.14.0"
- resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.14.0.tgz#a7a34170f26a21bb162424d8adacb4113a69e482"
- integrity sha512-/4IbIeHcD9VMHFqDR/gQ7EdZdLimOvW2DdcxFjdyyZ9NsbS+ccrXqVWDtab/lRl5AlUqmpBx8EhPaWR+OtY17A==
- dependencies:
- argparse "^1.0.7"
- esprima "^4.0.0"
-
-json-schema-traverse@^0.4.1:
- version "0.4.1"
- resolved "https://registry.yarnpkg.com/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz#69f6a87d9513ab8bb8fe63bdb0979c448e684660"
- integrity sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==
-
-json-stable-stringify-without-jsonify@^1.0.1:
- version "1.0.1"
- resolved "https://registry.yarnpkg.com/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz#9db7b59496ad3f3cfef30a75142d2d930ad72651"
- integrity sha1-nbe1lJatPzz+8wp1FC0tkwrXJlE=
-
-levn@^0.4.1:
- version "0.4.1"
- resolved "https://registry.yarnpkg.com/levn/-/levn-0.4.1.tgz#ae4562c007473b932a6200d403268dd2fffc6ade"
- integrity sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==
- dependencies:
- prelude-ls "^1.2.1"
- type-check "~0.4.0"
-
-lodash@^4.17.14, lodash@^4.17.15, lodash@^4.17.19:
- version "4.17.20"
- resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.20.tgz#b44a9b6297bcb698f1c51a3545a2b3b368d59c52"
- integrity sha512-PlhdFcillOINfeV7Ni6oF1TAEayyZBoZ8bcshTHqOYJYlrqzRK5hagpagky5o4HfCzzd1TRkXPMFq6cKk9rGmA==
-
-merge2@^1.3.0:
- version "1.4.1"
- resolved "https://registry.yarnpkg.com/merge2/-/merge2-1.4.1.tgz#4368892f885e907455a6fd7dc55c0c9d404990ae"
- integrity sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==
-
-micromatch@^4.0.2:
- version "4.0.2"
- resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-4.0.2.tgz#4fcb0999bf9fbc2fcbdd212f6d629b9a56c39259"
- integrity sha512-y7FpHSbMUMoyPbYUSzO6PaZ6FyRnQOpHuKwbo1G+Knck95XVU4QAiKdGEnj5wwoS7PlOgthX/09u5iFJ+aYf5Q==
- dependencies:
- braces "^3.0.1"
- picomatch "^2.0.5"
-
-minimatch@^3.0.4:
- version "3.0.4"
- resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083"
- integrity sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==
- dependencies:
- brace-expansion "^1.1.7"
-
-minimist@^1.2.5:
- version "1.2.5"
- resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.5.tgz#67d66014b66a6a8aaa0c083c5fd58df4e4e97602"
- integrity sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==
-
-mkdirp@^0.5.1:
- version "0.5.5"
- resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.5.tgz#d91cefd62d1436ca0f41620e251288d420099def"
- integrity sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==
- dependencies:
- minimist "^1.2.5"
-
-ms@^2.1.1:
- version "2.1.2"
- resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.2.tgz#d09d1f357b443f493382a8eb3ccd183872ae6009"
- integrity sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==
-
-natural-compare@^1.4.0:
- version "1.4.0"
- resolved "https://registry.yarnpkg.com/natural-compare/-/natural-compare-1.4.0.tgz#4abebfeed7541f2c27acfb29bdbbd15c8d5ba4f7"
- integrity sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc=
-
-once@^1.3.0:
- version "1.4.0"
- resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1"
- integrity sha1-WDsap3WWHUsROsF9nFC6753Xa9E=
- dependencies:
- wrappy "1"
-
-optionator@^0.9.1:
- version "0.9.1"
- resolved "https://registry.yarnpkg.com/optionator/-/optionator-0.9.1.tgz#4f236a6373dae0566a6d43e1326674f50c291499"
- integrity sha512-74RlY5FCnhq4jRxVUPKDaRwrVNXMqsGsiW6AJw4XK8hmtm10wC0ypZBLw5IIp85NZMr91+qd1RvvENwg7jjRFw==
- dependencies:
- deep-is "^0.1.3"
- fast-levenshtein "^2.0.6"
- levn "^0.4.1"
- prelude-ls "^1.2.1"
- type-check "^0.4.0"
- word-wrap "^1.2.3"
-
-parent-module@^1.0.0:
- version "1.0.1"
- resolved "https://registry.yarnpkg.com/parent-module/-/parent-module-1.0.1.tgz#691d2709e78c79fae3a156622452d00762caaaa2"
- integrity sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==
- dependencies:
- callsites "^3.0.0"
-
-path-is-absolute@^1.0.0:
- version "1.0.1"
- resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f"
- integrity sha1-F0uSaHNVNP+8es5r9TpanhtcX18=
-
-path-key@^3.1.0:
- version "3.1.1"
- resolved "https://registry.yarnpkg.com/path-key/-/path-key-3.1.1.tgz#581f6ade658cbba65a0d3380de7753295054f375"
- integrity sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==
-
-path-type@^4.0.0:
- version "4.0.0"
- resolved "https://registry.yarnpkg.com/path-type/-/path-type-4.0.0.tgz#84ed01c0a7ba380afe09d90a8c180dcd9d03043b"
- integrity sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==
-
-picomatch@^2.0.5, picomatch@^2.2.1:
- version "2.2.2"
- resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.2.2.tgz#21f333e9b6b8eaff02468f5146ea406d345f4dad"
- integrity sha512-q0M/9eZHzmr0AulXyPwNfZjtwZ/RBZlbN3K3CErVrk50T2ASYI7Bye0EvekFY3IP1Nt2DHu0re+V2ZHIpMkuWg==
-
-prelude-ls@^1.2.1:
- version "1.2.1"
- resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.2.1.tgz#debc6489d7a6e6b0e7611888cec880337d316396"
- integrity sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==
-
-progress@^2.0.0:
- version "2.0.3"
- resolved "https://registry.yarnpkg.com/progress/-/progress-2.0.3.tgz#7e8cf8d8f5b8f239c1bc68beb4eb78567d572ef8"
- integrity sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA==
-
-punycode@^2.1.0:
- version "2.1.1"
- resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.1.1.tgz#b58b010ac40c22c5657616c8d2c2c02c7bf479ec"
- integrity sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==
-
-regexpp@^3.0.0, regexpp@^3.1.0:
- version "3.1.0"
- resolved "https://registry.yarnpkg.com/regexpp/-/regexpp-3.1.0.tgz#206d0ad0a5648cffbdb8ae46438f3dc51c9f78e2"
- integrity sha512-ZOIzd8yVsQQA7j8GCSlPGXwg5PfmA1mrq0JP4nGhh54LaKN3xdai/vHUDu74pKwV8OxseMS65u2NImosQcSD0Q==
-
-resolve-from@^4.0.0:
- version "4.0.0"
- resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-4.0.0.tgz#4abcd852ad32dd7baabfe9b40e00a36db5f392e6"
- integrity sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==
-
-reusify@^1.0.4:
- version "1.0.4"
- resolved "https://registry.yarnpkg.com/reusify/-/reusify-1.0.4.tgz#90da382b1e126efc02146e90845a88db12925d76"
- integrity sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw==
-
-rimraf@2.6.3:
- version "2.6.3"
- resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.6.3.tgz#b2d104fe0d8fb27cf9e0a1cda8262dd3833c6cab"
- integrity sha512-mwqeW5XsA2qAejG46gYdENaxXjx9onRNCfn7L0duuP4hCuTIi/QO7PDK07KJfp1d+izWPrzEJDcSqBa0OZQriA==
- dependencies:
- glob "^7.1.3"
-
-run-parallel@^1.1.9:
- version "1.1.9"
- resolved "https://registry.yarnpkg.com/run-parallel/-/run-parallel-1.1.9.tgz#c9dd3a7cf9f4b2c4b6244e173a6ed866e61dd679"
- integrity sha512-DEqnSRTDw/Tc3FXf49zedI638Z9onwUotBMiUFKmrO2sdFKIbXamXGQ3Axd4qgphxKB4kw/qP1w5kTxnfU1B9Q==
-
-semver@^7.2.1, semver@^7.3.2:
- version "7.3.2"
- resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.2.tgz#604962b052b81ed0786aae84389ffba70ffd3938"
- integrity sha512-OrOb32TeeambH6UrhtShmF7CRDqhL6/5XpPNp2DuRH6+9QLw/orhp72j87v8Qa1ScDkvrrBNpZcDejAirJmfXQ==
-
-shebang-command@^2.0.0:
- version "2.0.0"
- resolved "https://registry.yarnpkg.com/shebang-command/-/shebang-command-2.0.0.tgz#ccd0af4f8835fbdc265b82461aaf0c36663f34ea"
- integrity sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==
- dependencies:
- shebang-regex "^3.0.0"
-
-shebang-regex@^3.0.0:
- version "3.0.0"
- resolved "https://registry.yarnpkg.com/shebang-regex/-/shebang-regex-3.0.0.tgz#ae16f1644d873ecad843b0307b143362d4c42172"
- integrity sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==
-
-slash@^3.0.0:
- version "3.0.0"
- resolved "https://registry.yarnpkg.com/slash/-/slash-3.0.0.tgz#6539be870c165adbd5240220dbe361f1bc4d4634"
- integrity sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==
-
-slice-ansi@^2.1.0:
- version "2.1.0"
- resolved "https://registry.yarnpkg.com/slice-ansi/-/slice-ansi-2.1.0.tgz#cacd7693461a637a5788d92a7dd4fba068e81636"
- integrity sha512-Qu+VC3EwYLldKa1fCxuuvULvSJOKEgk9pi8dZeCVK7TqBfUNTH4sFkk4joj8afVSfAYgJoSOetjx9QWOJ5mYoQ==
- dependencies:
- ansi-styles "^3.2.0"
- astral-regex "^1.0.0"
- is-fullwidth-code-point "^2.0.0"
-
-sprintf-js@~1.0.2:
- version "1.0.3"
- resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c"
- integrity sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=
-
-string-width@^3.0.0:
- version "3.1.0"
- resolved "https://registry.yarnpkg.com/string-width/-/string-width-3.1.0.tgz#22767be21b62af1081574306f69ac51b62203961"
- integrity sha512-vafcv6KjVZKSgz06oM/H6GDBrAtz8vdhQakGjFIvNrHA6y3HCF1CInLy+QLq8dTJPQ1b+KDUqDFctkdRW44e1w==
- dependencies:
- emoji-regex "^7.0.1"
- is-fullwidth-code-point "^2.0.0"
- strip-ansi "^5.1.0"
-
-strip-ansi@^5.1.0:
- version "5.2.0"
- resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-5.2.0.tgz#8c9a536feb6afc962bdfa5b104a5091c1ad9c0ae"
- integrity sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==
- dependencies:
- ansi-regex "^4.1.0"
-
-strip-ansi@^6.0.0:
- version "6.0.0"
- resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.0.tgz#0b1571dd7669ccd4f3e06e14ef1eed26225ae532"
- integrity sha512-AuvKTrTfQNYNIctbR1K/YGTR1756GycPsg7b9bdV9Duqur4gv6aKqHXah67Z8ImS7WEz5QVcOtlfW2rZEugt6w==
- dependencies:
- ansi-regex "^5.0.0"
-
-strip-json-comments@^3.1.0, strip-json-comments@^3.1.1:
- version "3.1.1"
- resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-3.1.1.tgz#31f1281b3832630434831c310c01cccda8cbe006"
- integrity sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==
-
-supports-color@^5.3.0:
- version "5.5.0"
- resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-5.5.0.tgz#e2e69a44ac8772f78a1ec0b35b689df6530efc8f"
- integrity sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==
- dependencies:
- has-flag "^3.0.0"
-
-supports-color@^7.1.0:
- version "7.2.0"
- resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-7.2.0.tgz#1b7dcdcb32b8138801b3e478ba6a51caa89648da"
- integrity sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==
- dependencies:
- has-flag "^4.0.0"
-
-table@^5.2.3:
- version "5.4.6"
- resolved "https://registry.yarnpkg.com/table/-/table-5.4.6.tgz#1292d19500ce3f86053b05f0e8e7e4a3bb21079e"
- integrity sha512-wmEc8m4fjnob4gt5riFRtTu/6+4rSe12TpAELNSqHMfF3IqnA+CH37USM6/YR3qRZv7e56kAEAtd6nKZaxe0Ug==
- dependencies:
- ajv "^6.10.2"
- lodash "^4.17.14"
- slice-ansi "^2.1.0"
- string-width "^3.0.0"
-
-text-table@^0.2.0:
- version "0.2.0"
- resolved "https://registry.yarnpkg.com/text-table/-/text-table-0.2.0.tgz#7f5ee823ae805207c00af2df4a84ec3fcfa570b4"
- integrity sha1-f17oI66AUgfACvLfSoTsP8+lcLQ=
-
-to-regex-range@^5.0.1:
- version "5.0.1"
- resolved "https://registry.yarnpkg.com/to-regex-range/-/to-regex-range-5.0.1.tgz#1648c44aae7c8d988a326018ed72f5b4dd0392e4"
- integrity sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==
- dependencies:
- is-number "^7.0.0"
-
-tslib@^1.8.1:
- version "1.13.0"
- resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.13.0.tgz#c881e13cc7015894ed914862d276436fa9a47043"
- integrity sha512-i/6DQjL8Xf3be4K/E6Wgpekn5Qasl1usyw++dAA35Ue5orEn65VIxOA+YvNNl9HV3qv70T7CNwjODHZrLwvd1Q==
-
-tsutils@^3.17.1:
- version "3.17.1"
- resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-3.17.1.tgz#ed719917f11ca0dee586272b2ac49e015a2dd759"
- integrity sha512-kzeQ5B8H3w60nFY2g8cJIuH7JDpsALXySGtwGJ0p2LSjLgay3NdIpqq5SoOBe46bKDW2iq25irHCr8wjomUS2g==
- dependencies:
- tslib "^1.8.1"
-
-type-check@^0.4.0, type-check@~0.4.0:
- version "0.4.0"
- resolved "https://registry.yarnpkg.com/type-check/-/type-check-0.4.0.tgz#07b8203bfa7056c0657050e3ccd2c37730bab8f1"
- integrity sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==
- dependencies:
- prelude-ls "^1.2.1"
-
-type-fest@^0.8.1:
- version "0.8.1"
- resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.8.1.tgz#09e249ebde851d3b1e48d27c105444667f17b83d"
- integrity sha512-4dbzIzqvjtgiM5rw1k5rEHtBANKmdudhGyBEajN01fEyhaAIhsoKNy6y7+IN93IfpFtwY9iqi7kD+xwKhQsNJA==
-
-typescript@^4.0.2:
- version "4.0.2"
- resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.0.2.tgz#7ea7c88777c723c681e33bf7988be5d008d05ac2"
- integrity sha512-e4ERvRV2wb+rRZ/IQeb3jm2VxBsirQLpQhdxplZ2MEzGvDkkMmPglecnNDfSUBivMjP93vRbngYYDQqQ/78bcQ==
-
-uri-js@^4.2.2:
- version "4.4.0"
- resolved "https://registry.yarnpkg.com/uri-js/-/uri-js-4.4.0.tgz#aa714261de793e8a82347a7bcc9ce74e86f28602"
- integrity sha512-B0yRTzYdUCCn9n+F4+Gh4yIDtMQcaJsmYBDsTSG8g/OejKBodLQ2IHfN3bM7jUsRXndopT7OIXWdYqc1fjmV6g==
- dependencies:
- punycode "^2.1.0"
-
-v8-compile-cache@^2.0.3:
- version "2.1.1"
- resolved "https://registry.yarnpkg.com/v8-compile-cache/-/v8-compile-cache-2.1.1.tgz#54bc3cdd43317bca91e35dcaf305b1a7237de745"
- integrity sha512-8OQ9CL+VWyt3JStj7HX7/ciTL2V3Rl1Wf5OL+SNTm0yK1KvtReVulksyeRnCANHHuUxHlQig+JJDlUhBt1NQDQ==
-
-which@^2.0.1:
- version "2.0.2"
- resolved "https://registry.yarnpkg.com/which/-/which-2.0.2.tgz#7c6a8dd0a636a0327e10b59c9286eee93f3f51b1"
- integrity sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==
- dependencies:
- isexe "^2.0.0"
-
-word-wrap@^1.2.3:
- version "1.2.3"
- resolved "https://registry.yarnpkg.com/word-wrap/-/word-wrap-1.2.3.tgz#610636f6b1f703891bd34771ccb17fb93b47079c"
- integrity sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ==
-
-wrappy@1:
- version "1.0.2"
- resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f"
- integrity sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=
-
-write@1.0.3:
- version "1.0.3"
- resolved "https://registry.yarnpkg.com/write/-/write-1.0.3.tgz#0800e14523b923a387e415123c865616aae0f5c3"
- integrity sha512-/lg70HAjtkUgWPVZhZcm+T4hkL8Zbtp1nFNOn3lRrxnlv50SRBv7cR7RqR+GMsd3hUXy9hWBo4CHTbFTcOYwig==
- dependencies:
- mkdirp "^0.5.1"