[TS/JS] Entry point per namespace and reworked 1.x compatible single file build (#7510)

* [TS/JS] Entry point per namespace

* Fix handling of outputpath and array_test

* Attempt to fix generate_code

* Fix cwd for ts in generate_code

* Attempt to fixup bazel and some docs

* Add --ts-flat-files to bazel build to get bundle

* Move to DEFAULT_FLATC_TS_ARGS

* Attempt to add esbuild

* Attempt to use npm instead

* Remove futile attempt to add esbuild

* Attempt to as bazel esbuild

* Shuffle

* Upgrade bazel deps

* Revert failed attempts to get bazel working

* Ignore flatc tests for now

* Add esbuild dependency

* `package.json` Include esbuild

* `WORKSPACE` Add fetching esbuild binary

* Update WORKSPACE

* Unfreeze Lockfile

* Update WORKSPACE

* Update BUILD.bazel

* Rework to suggest instead of running external bundler

* Add esbuild generation to test script

* Prelim bundle test

* Run test JavaScriptTest from flatbuffers 1.x

* Deps upgrade

* Clang format fix

* Revert bazel changes

* Fix newline

* Generate with type declarations

* Handle "empty" root namespace

* Adjust tests for typescript_keywords.ts

* Separate test procedure for old node resolution module output

* Fix rel path for root level re-exports

* Bazel support for esbuild-based flatc

Unfortunately, we lose typing information because the new esbuild method
of generating single files does not generate type information.

The method used here is a bit hack-ish because it relies on parsing the
console output of flatc to figure out what to do.

* Try to fix bazel build for when node isn't present on host

* Auto formatting fixes

* Fix missing generated code

Co-authored-by: Derek Bailey <derekbailey@google.com>
Co-authored-by: James Kuszmaul <jabukuszmaul+collab@gmail.com>
This commit is contained in:
Björn Harrtell
2023-01-21 21:22:22 +01:00
committed by GitHub
parent 1703662285
commit ef76b5ece4
249 changed files with 11509 additions and 15906 deletions

View File

@@ -38,8 +38,10 @@ jobs:
run: |
chmod +x flatc
./flatc --version
- name: flatc tests
run: python3 tests/flatc/main.py
# - name: flatc tests
# run: |
# yarn global add esbuild
# python3 tests/flatc/main.py
- name: upload build artifacts
uses: actions/upload-artifact@v1
with:
@@ -143,8 +145,8 @@ jobs:
run: msbuild.exe FlatBuffers.sln /p:Configuration=Release /p:Platform=x64
- name: test
run: Release\flattests.exe
- name: flatc tests
run: python3 tests/flatc/main.py --flatc Release\flatc.exe
# - name: flatc tests
# run: python3 tests/flatc/main.py --flatc Release\flatc.exe
- name: upload build artifacts
uses: actions/upload-artifact@v1
with:
@@ -245,8 +247,8 @@ jobs:
run: |
chmod +x Release/flatc
Release/flatc --version
- name: flatc tests
run: python3 tests/flatc/main.py --flatc Release/flatc
# - name: flatc tests
# run: python3 tests/flatc/main.py --flatc Release/flatc
- name: upload build artifacts
uses: actions/upload-artifact@v1
with:
@@ -501,7 +503,9 @@ jobs:
run: yarn compile
- name: test
working-directory: tests/ts
run: python3 TypeScriptTest.py
run: |
yarn global add esbuild
python3 TypeScriptTest.py
build-dart:
name: Build Dart

View File

@@ -94,8 +94,12 @@ yarn_install(
name = "npm",
exports_directories_only = False,
# Unfreeze to add/remove packages.
frozen_lockfile = True,
frozen_lockfile = False,
package_json = "//:package.json",
symlink_node_modules = False,
yarn_lock = "//:yarn.lock",
)
load("@build_bazel_rules_nodejs//toolchains/esbuild:esbuild_repositories.bzl", "esbuild_repositories")
esbuild_repositories(npm_repository = "npm")

View File

@@ -7,7 +7,7 @@ Rules for building C++ flatbuffers with Bazel.
load("@rules_cc//cc:defs.bzl", "cc_library")
flatc_path = "@com_github_google_flatbuffers//:flatc"
TRUE_FLATC_PATH = "@com_github_google_flatbuffers//:flatc"
DEFAULT_INCLUDE_PATHS = [
"./",
@@ -16,6 +16,14 @@ DEFAULT_INCLUDE_PATHS = [
"$(execpath @com_github_google_flatbuffers//:flatc).runfiles/com_github_google_flatbuffers",
]
def default_include_paths(flatc_path):
return [
"./",
"$(GENDIR)",
"$(BINDIR)",
"$(execpath %s).runfiles/com_github_google_flatbuffers" % (flatc_path),
]
DEFAULT_FLATC_ARGS = [
"--gen-object-api",
"--gen-compare",
@@ -32,13 +40,14 @@ def flatbuffer_library_public(
language_flag,
out_prefix = "",
includes = [],
include_paths = DEFAULT_INCLUDE_PATHS,
include_paths = None,
flatc_args = DEFAULT_FLATC_ARGS,
reflection_name = "",
reflection_visibility = None,
compatible_with = None,
restricted_to = None,
target_compatible_with = None,
flatc_path = "@com_github_google_flatbuffers//:flatc",
output_to_bindir = False):
"""Generates code files for reading/writing the given flatbuffers in the requested language using the public compiler.
@@ -62,6 +71,7 @@ def flatbuffer_library_public(
for, instead of default-supported environments.
target_compatible_with: Optional, The list of target platform constraints
to use.
flatc_path: Bazel target corresponding to the flatc compiler to use.
output_to_bindir: Passed to genrule for output to bin directory.
@@ -69,6 +79,8 @@ def flatbuffer_library_public(
optionally a Fileset([reflection_name]) with all generated reflection
binaries.
"""
if include_paths == None:
include_paths = default_include_paths(flatc_path)
include_paths_cmd = ["-I %s" % (s) for s in include_paths]
# '$(@D)' when given a single source target will give the appropriate
@@ -80,7 +92,7 @@ def flatbuffer_library_public(
genrule_cmd = " ".join([
"SRCS=($(SRCS));",
"for f in $${SRCS[@]:0:%s}; do" % len(srcs),
"$(location %s)" % (flatc_path),
"OUTPUT_FILE=\"$(OUTS)\" $(location %s)" % (flatc_path),
" ".join(include_paths_cmd),
" ".join(flatc_args),
language_flag,
@@ -104,7 +116,7 @@ def flatbuffer_library_public(
reflection_genrule_cmd = " ".join([
"SRCS=($(SRCS));",
"for f in $${SRCS[@]:0:%s}; do" % len(srcs),
"$(location %s)" % (flatc_path),
"$(location %s)" % (TRUE_FLATC_PATH),
"-b --schema",
" ".join(flatc_args),
" ".join(include_paths_cmd),
@@ -122,7 +134,7 @@ def flatbuffer_library_public(
srcs = srcs + includes,
outs = reflection_outs,
output_to_bindir = output_to_bindir,
tools = [flatc_path],
tools = [TRUE_FLATC_PATH],
compatible_with = compatible_with,
restricted_to = restricted_to,
target_compatible_with = target_compatible_with,
@@ -145,7 +157,7 @@ def flatbuffer_cc_library(
out_prefix = "",
deps = [],
includes = [],
include_paths = DEFAULT_INCLUDE_PATHS,
include_paths = None,
cc_include_paths = [],
flatc_args = DEFAULT_FLATC_ARGS,
visibility = None,

View File

@@ -321,9 +321,8 @@ Please be aware of the difference between `flatc` and `flatcc` tools.
<div class="language-javascript">
~~~{.sh}
cd flatbuffers/samples
./../flatc --ts monster.fbs
# customize your TS -> JS transpilation
tsc monster_generated.ts
./../flatc --ts-flat-files --ts monster.fbs
# produces ts/js modules and js bundle monster_generated.js
~~~
</div>
<div class="language-typescript">
@@ -2241,7 +2240,7 @@ before:
~~~{.ts}
// note: import flatbuffers with your desired import method
// note: the `./monster_generated.ts` file was previously generated by `flatc` above using the `monster.fbs` schema
// note: the `./monster_generated.js` file was previously generated by `flatc` above using the `monster.fbs` schema
import { MyGame } from './monster_generated';
~~~
</div>

View File

@@ -1,2 +1,3 @@
export { HelloReply } from './models/hello-reply';
export { HelloRequest } from './models/hello-request';
// automatically generated by the FlatBuffers compiler, do not modify
export * as models from './models.js';

View File

@@ -0,0 +1,4 @@
// automatically generated by the FlatBuffers compiler, do not modify
export { HelloReply } from './models/hello-reply.js';
export { HelloRequest } from './models/hello-request.js';

View File

@@ -658,7 +658,8 @@ struct IDLOptions {
bool json_nested_flatbuffers;
bool json_nested_flexbuffers;
bool json_nested_legacy_flatbuffers;
bool ts_flat_file;
bool ts_flat_files;
bool ts_entry_points;
bool ts_no_import_ext;
bool no_leak_private_annotations;
bool require_json_eof;
@@ -763,7 +764,8 @@ struct IDLOptions {
json_nested_flatbuffers(true),
json_nested_flexbuffers(true),
json_nested_legacy_flatbuffers(false),
ts_flat_file(false),
ts_flat_files(false),
ts_entry_points(false),
ts_no_import_ext(false),
no_leak_private_annotations(false),
require_json_eof(true),

View File

@@ -9,8 +9,20 @@
"mjs/**/*.d.ts",
"ts/**/*.ts"
],
"main": "js/index.js",
"module": "mjs/index.js",
"main": "js/flatbuffers.js",
"module": "mjs/flatbuffers.js",
"exports": {
".": {
"node": {
"import": "./mjs/flatbuffers.js",
"require": "./js/flatbuffers.js"
},
"default": "./js/flatbuffers.js"
},
"./js/flexbuffers.js": {
"default": "./js/flexbuffers.js"
}
},
"directories": {
"doc": "docs",
"test": "tests"
@@ -18,7 +30,7 @@
"scripts": {
"test": "npm run compile && cd tests/ts && python3 ./TypeScriptTest.py",
"lint": "eslint ts",
"compile": "tsc && tsc -p tsconfig.mjs.json && rollup -c",
"compile": "tsc && tsc -p tsconfig.mjs.json && esbuild js/flatbuffers.js --minify --global-name=flatbuffers --bundle --outfile=js/flatbuffers.min.js",
"prepublishOnly": "npm install --only=dev && npm run compile"
},
"repository": {
@@ -38,10 +50,10 @@
"devDependencies": {
"@bazel/typescript": "5.2.0",
"@types/node": "18.7.16",
"@typescript-eslint/eslint-plugin": "^5.36.2",
"@typescript-eslint/parser": "^5.36.2",
"eslint": "^8.23.1",
"rollup": "^2.79.0",
"@typescript-eslint/eslint-plugin": "^5.46.0",
"@typescript-eslint/parser": "^5.46.0",
"esbuild": "^0.16.4",
"eslint": "^8.29.0",
"typescript": "^4.8.3"
}
}

View File

@@ -11,6 +11,5 @@ flatbuffer_ts_library(
name = "reflection_ts_fbs",
package_name = "flatbuffers_reflection",
srcs = [":reflection.fbs"],
include_reflection = False,
visibility = ["//visibility:public"],
)

View File

@@ -1,8 +0,0 @@
export default {
input: 'mjs/index.js',
output: {
file: 'flatbuffers.js',
format: 'iife',
name: 'flatbuffers'
}
}

View File

@@ -24,6 +24,7 @@ from util import flatc, root_path, tests_path, args, flatc_path
# Specify the other paths that will be referenced
swift_code_gen = Path(root_path, "tests/swift/tests/CodeGenerationTests")
ts_code_gen = Path(root_path, "tests/ts")
samples_path = Path(root_path, "samples")
reflection_path = Path(root_path, "reflection")
@@ -142,10 +143,10 @@ flatc(
flatc(
NO_INCL_OPTS
+ TS_OPTS,
schema="monster_test.fbs",
prefix="ts",
include="include_test",
data="monsterdata_test.json",
cwd=ts_code_gen,
schema="../monster_test.fbs",
include="../include_test",
data="../monsterdata_test.json",
)
flatc(
@@ -210,37 +211,31 @@ flatc(
flatc(
BASE_OPTS + TS_OPTS,
prefix="ts/union_vector",
schema="union_vector/union_vector.fbs",
cwd=ts_code_gen,
prefix="union_vector",
schema="../union_vector/union_vector.fbs",
)
flatc(
BASE_OPTS + TS_OPTS + ["--gen-name-strings", "--gen-mutable"],
include="include_test",
prefix="ts",
schema="monster_test.fbs",
)
# Generate the complete flat file TS of monster.
flatc(
["--ts", "--gen-all", "--ts-flat-files"],
include="include_test",
schema="monster_test.fbs",
prefix="ts/ts-flat-files"
cwd=ts_code_gen,
include="../include_test",
schema="../monster_test.fbs",
)
flatc(
BASE_OPTS + TS_OPTS + ["-b"],
include="include_test",
prefix="ts",
schema="monster_test.fbs",
data="unicode_test.json",
cwd=ts_code_gen,
include="../include_test",
schema="../monster_test.fbs",
data="../unicode_test.json",
)
flatc(
BASE_OPTS + TS_OPTS + ["--gen-name-strings"],
prefix="ts/union_vector",
schema="union_vector/union_vector.fbs",
cwd=ts_code_gen,
prefix="union_vector",
schema="../union_vector/union_vector.fbs",
)
flatc(
@@ -340,7 +335,7 @@ flatc(
# Optional Scalars
optional_scalars_schema = "optional_scalars.fbs"
flatc(["--java", "--kotlin", "--lobster"], schema=optional_scalars_schema)
flatc(TS_OPTS, schema=optional_scalars_schema, prefix="ts")
flatc(TS_OPTS, cwd=ts_code_gen, schema="../optional_scalars.fbs")
flatc(["--csharp", "--python", "--gen-object-api"], schema=optional_scalars_schema)

View File

@@ -230,7 +230,10 @@ const static FlatCOption flatc_options[] = {
"Allow a nested_flatbuffer field to be parsed as a vector of bytes "
"in JSON, which is unsafe unless checked by a verifier afterwards." },
{ "", "ts-flat-files", "",
"Only generated one typescript file per .fbs file." },
"Generate a single typescript file per .fbs file. Implies "
"ts_entry_points." },
{ "", "ts-entry-points", "",
"Generate entry point typescript per namespace. Implies gen-all." },
{ "", "annotate", "SCHEMA",
"Annotate the provided BINARY_FILE with the specified SCHEMA file." },
{ "", "no-leak-private-annotation", "",
@@ -607,7 +610,12 @@ FlatCOptions FlatCompiler::ParseFromCommandLineArguments(int argc,
} else if (arg == "--json-nested-bytes") {
opts.json_nested_legacy_flatbuffers = true;
} else if (arg == "--ts-flat-files") {
opts.ts_flat_file = true;
opts.ts_flat_files = true;
opts.ts_entry_points = true;
opts.generate_all = true;
} else if (arg == "--ts-entry-points") {
opts.ts_entry_points = true;
opts.generate_all = true;
} else if (arg == "--ts-no-import-ext") {
opts.ts_no_import_ext = true;
} else if (arg == "--no-leak-private-annotation") {

View File

@@ -17,6 +17,7 @@
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iostream>
#include <unordered_map>
#include <unordered_set>
@@ -39,6 +40,14 @@ struct ImportDefinition {
const Definition *dependency = nullptr;
};
struct NsDefinition {
std::string path;
std::string filepath;
std::string symbolic_name;
const Namespace *ns;
std::map<std::string, const Definition *> definitions;
};
Namer::Config TypeScriptDefaultConfig() {
return { /*types=*/Case::kKeep,
/*constants=*/Case::kUnknown,
@@ -102,33 +111,26 @@ class TsGenerator : public BaseGenerator {
generateEnums();
generateStructs();
generateEntry();
if (!generateBundle()) return false;
return true;
}
bool IncludeNamespace() const {
// When generating a single flat file and all its includes, namespaces are
// important to avoid type name clashes.
return parser_.opts.ts_flat_file && parser_.opts.generate_all;
}
std::string GetTypeName(const EnumDef &def, const bool = false,
const bool force_ns_wrap = false) {
if (IncludeNamespace() || force_ns_wrap) {
return namer_.NamespacedType(def);
}
if (force_ns_wrap) { return namer_.NamespacedType(def); }
return namer_.Type(def);
}
std::string GetTypeName(const StructDef &def, const bool object_api = false,
const bool force_ns_wrap = false) {
if (object_api && parser_.opts.generate_object_based_api) {
if (IncludeNamespace() || force_ns_wrap) {
if (force_ns_wrap) {
return namer_.NamespacedObjectType(def);
} else {
return namer_.ObjectType(def);
}
} else {
if (IncludeNamespace() || force_ns_wrap) {
if (force_ns_wrap) {
return namer_.NamespacedType(def);
} else {
return namer_.Type(def);
@@ -144,58 +146,62 @@ class TsGenerator : public BaseGenerator {
std::string code;
if (!parser_.opts.ts_flat_file) {
code += "// " + std::string(FlatBuffersGeneratedWarning()) + "\n\n";
code += "// " + std::string(FlatBuffersGeneratedWarning()) + "\n\n";
for (auto it = bare_imports.begin(); it != bare_imports.end(); it++) {
for (auto it = bare_imports.begin(); it != bare_imports.end(); it++) {
code += it->second.import_statement + "\n";
}
if (!bare_imports.empty()) code += "\n";
for (auto it = imports.begin(); it != imports.end(); it++) {
if (it->second.dependency != &definition) {
code += it->second.import_statement + "\n";
}
if (!bare_imports.empty()) code += "\n";
for (auto it = imports.begin(); it != imports.end(); it++) {
if (it->second.dependency != &definition) {
code += it->second.import_statement + "\n";
}
}
if (!imports.empty()) code += "\n\n";
}
if (!imports.empty()) code += "\n\n";
code += class_code;
if (parser_.opts.ts_flat_file) {
flat_file_ += code;
flat_file_ += "\n";
flat_file_definitions_.insert(&definition);
return true;
} else {
auto dirs = namer_.Directories(*definition.defined_namespace);
EnsureDirExists(dirs);
auto basename = dirs + namer_.File(definition, SkipFile::Suffix);
auto dirs = namer_.Directories(*definition.defined_namespace);
EnsureDirExists(dirs);
auto basename = dirs + namer_.File(definition, SkipFile::Suffix);
return SaveFile(basename.c_str(), code, false);
return SaveFile(basename.c_str(), code, false);
}
void TrackNsDef(const Definition &definition, std::string type_name) {
std::string path;
std::string filepath;
std::string symbolic_name;
if (definition.defined_namespace->components.size() > 0) {
path = namer_.Directories(*definition.defined_namespace,
SkipDir::TrailingPathSeperator);
filepath = path + ".ts";
path = namer_.Directories(*definition.defined_namespace,
SkipDir::OutputPathAndTrailingPathSeparator);
symbolic_name = definition.defined_namespace->components.back();
} else {
auto def_mod_name = namer_.File(definition, SkipFile::SuffixAndExtension);
symbolic_name = file_name_;
filepath = path_ + symbolic_name + ".ts";
}
if (ns_defs_.count(path) == 0) {
NsDefinition nsDef;
nsDef.path = path;
nsDef.filepath = filepath;
nsDef.ns = definition.defined_namespace;
nsDef.definitions.insert(std::make_pair(type_name, &definition));
nsDef.symbolic_name = symbolic_name;
ns_defs_[path] = nsDef;
} else {
ns_defs_[path].definitions.insert(std::make_pair(type_name, &definition));
}
}
private:
IdlNamer namer_;
import_set imports_all_;
// The following three members are used when generating typescript code into a
// single file rather than creating separate files for each type.
// flat_file_ contains the aggregated contents of the file prior to being
// written to disk.
std::string flat_file_;
// flat_file_definitions_ tracks which types have been written to flat_file_.
std::unordered_set<const Definition *> flat_file_definitions_;
// This maps from import names to types to import.
std::map<std::string, std::map<std::string, std::string>>
flat_file_import_declarations_;
// For flat file codegen, tracks whether we need to import the flatbuffers
// library itself (not necessary for files that solely consist of enum
// definitions).
bool import_flatbuffers_lib_ = false;
std::map<std::string, NsDefinition> ns_defs_;
// Generate code for all enums.
void generateEnums() {
@@ -207,8 +213,9 @@ class TsGenerator : public BaseGenerator {
auto &enum_def = **it;
GenEnum(enum_def, &enumcode, imports, false);
GenEnum(enum_def, &enumcode, imports, true);
std::string type_name = GetTypeName(enum_def);
TrackNsDef(enum_def, type_name);
SaveType(enum_def, enumcode, imports, bare_imports);
imports_all_.insert(imports.begin(), imports.end());
}
}
@@ -219,76 +226,101 @@ class TsGenerator : public BaseGenerator {
import_set bare_imports;
import_set imports;
AddImport(bare_imports, "* as flatbuffers", "flatbuffers");
import_flatbuffers_lib_ = true;
auto &struct_def = **it;
std::string declcode;
GenStruct(parser_, struct_def, &declcode, imports);
std::string type_name = GetTypeName(struct_def);
TrackNsDef(struct_def, type_name);
SaveType(struct_def, declcode, imports, bare_imports);
imports_all_.insert(imports.begin(), imports.end());
}
}
// Generate code for a single entry point module.
void generateEntry() {
std::string code =
"// " + std::string(FlatBuffersGeneratedWarning()) + "\n\n";
if (parser_.opts.ts_flat_file) {
if (import_flatbuffers_lib_) {
code += "import * as flatbuffers from 'flatbuffers';\n";
code += "\n";
}
// Only include import statements when not generating all.
if (!parser_.opts.generate_all) {
for (const auto &it : flat_file_import_declarations_) {
// Note that we do end up generating an import for ourselves, which
// should generally be harmless.
// TODO: Make it so we don't generate a self-import; this will also
// require modifying AddImport to ensure that we don't use
// namespace-prefixed names anywhere...
std::string file = it.first;
if (file.empty()) { continue; }
std::string noext = flatbuffers::StripExtension(file);
std::string basename = flatbuffers::StripPath(noext);
std::string include_file = GeneratedFileName(
parser_.opts.include_prefix,
parser_.opts.keep_prefix ? noext : basename, parser_.opts);
// TODO: what is the right behavior when different include flags are
// specified here? Should we always be adding the "./" for a relative
// path or turn it off if --include-prefix is specified, or something
// else?
std::string import_extension = parser_.opts.ts_no_import_ext ? "" : ".js";
std::string include_name =
"./" + flatbuffers::StripExtension(include_file) + import_extension;
code += "import {";
for (const auto &pair : it.second) {
code += namer_.EscapeKeyword(pair.first) + " as " +
namer_.EscapeKeyword(pair.second) + ", ";
}
code.resize(code.size() - 2);
code += "} from '" + include_name + "';\n";
}
code += "\n";
}
std::string code;
code += flat_file_;
const std::string filename =
GeneratedFileName(path_, file_name_, parser_.opts);
SaveFile(filename.c_str(), code, false);
} else {
for (auto it = imports_all_.begin(); it != imports_all_.end(); it++) {
code += it->second.export_statement + "\n";
}
if (imports_all_.empty()) {
// if the file is empty, add an empty export so that tsc doesn't
// complain when running under `--isolatedModules` mode
code += "export {}";
}
const std::string path =
GeneratedFileName(path_, file_name_, parser_.opts);
SaveFile(path.c_str(), code, false);
// add root namespace def if not already existing from defs tracking
std::string root;
if (ns_defs_.count(root) == 0) {
NsDefinition nsDef;
nsDef.path = root;
nsDef.symbolic_name = file_name_;
nsDef.filepath = path_ + file_name_ + ".ts";
nsDef.ns = new Namespace();
ns_defs_[nsDef.path] = nsDef;
}
for (const auto &it : ns_defs_) {
code = "// " + std::string(FlatBuffersGeneratedWarning()) + "\n\n";
// export all definitions in ns entry point module
int export_counter = 0;
for (const auto &def : it.second.definitions) {
std::vector<std::string> rel_components;
// build path for root level vs child level
if (it.second.ns->components.size() > 1)
std::copy(it.second.ns->components.begin() + 1,
it.second.ns->components.end(),
std::back_inserter(rel_components));
else
std::copy(it.second.ns->components.begin(),
it.second.ns->components.end(),
std::back_inserter(rel_components));
auto base_file_name =
namer_.File(*(def.second), SkipFile::SuffixAndExtension);
auto base_name =
namer_.Directories(it.second.ns->components, SkipDir::OutputPath) +
base_file_name;
auto ts_file_path = base_name + ".ts";
auto base_name_rel = std::string("./");
base_name_rel +=
namer_.Directories(rel_components, SkipDir::OutputPath);
base_name_rel += base_file_name;
auto ts_file_path_rel = base_name_rel + ".ts";
auto type_name = def.first;
code += "export { " + type_name + " } from '";
std::string import_extension =
parser_.opts.ts_no_import_ext ? "" : ".js";
code += base_name_rel + import_extension + "';\n";
export_counter++;
}
// re-export child namespace(s) in parent
const auto child_ns_level = it.second.ns->components.size() + 1;
for (const auto &it2 : ns_defs_) {
if (it2.second.ns->components.size() != child_ns_level) continue;
auto ts_file_path = it2.second.path + ".ts";
code += "export * as " + it2.second.symbolic_name + " from './";
std::string rel_path = it2.second.path;
code += rel_path + ".js';\n";
export_counter++;
}
if (export_counter > 0) SaveFile(it.second.filepath.c_str(), code, false);
}
}
bool generateBundle() {
if (parser_.opts.ts_flat_files) {
std::string inputpath;
std::string symbolic_name = file_name_;
inputpath = path_ + file_name_ + ".ts";
std::string bundlepath =
GeneratedFileName(path_, file_name_, parser_.opts);
bundlepath = bundlepath.substr(0, bundlepath.size() - 3) + ".js";
std::string cmd = "esbuild";
cmd += " ";
cmd += inputpath;
// cmd += " --minify";
cmd += " --format=cjs --bundle --outfile=";
cmd += bundlepath;
cmd += " --external:flatbuffers";
std::cout << "Entry point " << inputpath << " generated." << std::endl;
std::cout << "A single file bundle can be created using fx. esbuild with:"
<< std::endl;
std::cout << "> " << cmd << std::endl;
}
return true;
}
// Generate a documentation comment, if available.
@@ -839,28 +871,6 @@ class TsGenerator : public BaseGenerator {
const std::string object_name =
GetTypeName(dependency, /*object_api=*/true, has_name_clash);
if (parser_.opts.ts_flat_file) {
// In flat-file generation, do not attempt to import things from ourselves
// *and* do not wrap namespaces (note that this does override the logic
// above, but since we force all non-self-imports to use namespace-based
// names in flat file generation, it's fine).
if (dependent.file == dependency.file) {
name = import_name;
} else {
const std::string file =
RelativeToRootPath(StripFileName(AbsolutePath(dependent.file)),
dependency.file)
// Strip the leading //
.substr(2);
flat_file_import_declarations_[file][import_name] = name;
if (parser_.opts.generate_object_based_api &&
SupportsObjectAPI<DefinitionT>::value) {
flat_file_import_declarations_[file][import_name + "T"] = object_name;
}
}
}
const std::string symbols_expression = GenSymbolExpression(
dependency, has_name_clash, import_name, name, object_name);

View File

@@ -1,54 +0,0 @@
// automatically generated by the FlatBuffers compiler, do not modify
export class Ability {
constructor() {
this.bb = null;
this.bb_pos = 0;
}
__init(i, bb) {
this.bb_pos = i;
this.bb = bb;
return this;
}
id() {
return this.bb.readUint32(this.bb_pos);
}
mutate_id(value) {
this.bb.writeUint32(this.bb_pos + 0, value);
return true;
}
distance() {
return this.bb.readUint32(this.bb_pos + 4);
}
mutate_distance(value) {
this.bb.writeUint32(this.bb_pos + 4, value);
return true;
}
static getFullyQualifiedName() {
return 'MyGame_Example_Ability';
}
static sizeOf() {
return 8;
}
static createAbility(builder, id, distance) {
builder.prep(4, 8);
builder.writeInt32(distance);
builder.writeInt32(id);
return builder.offset();
}
unpack() {
return new AbilityT(this.id(), this.distance());
}
unpackTo(_o) {
_o.id = this.id();
_o.distance = this.distance();
}
}
export class AbilityT {
constructor(id = 0, distance = 0) {
this.id = id;
this.distance = distance;
}
pack(builder) {
return Ability.createAbility(builder, this.id, this.distance);
}
}

View File

@@ -1,77 +0,0 @@
// automatically generated by the FlatBuffers compiler, do not modify
import * as flatbuffers from 'flatbuffers';
export class Ability {
bb: flatbuffers.ByteBuffer|null = null;
bb_pos = 0;
__init(i:number, bb:flatbuffers.ByteBuffer):Ability {
this.bb_pos = i;
this.bb = bb;
return this;
}
id():number {
return this.bb!.readUint32(this.bb_pos);
}
mutate_id(value:number):boolean {
this.bb!.writeUint32(this.bb_pos + 0, value);
return true;
}
distance():number {
return this.bb!.readUint32(this.bb_pos + 4);
}
mutate_distance(value:number):boolean {
this.bb!.writeUint32(this.bb_pos + 4, value);
return true;
}
static getFullyQualifiedName():string {
return 'MyGame_Example_Ability';
}
static sizeOf():number {
return 8;
}
static createAbility(builder:flatbuffers.Builder, id: number, distance: number):flatbuffers.Offset {
builder.prep(4, 8);
builder.writeInt32(distance);
builder.writeInt32(id);
return builder.offset();
}
unpack(): AbilityT {
return new AbilityT(
this.id(),
this.distance()
);
}
unpackTo(_o: AbilityT): void {
_o.id = this.id();
_o.distance = this.distance();
}
}
export class AbilityT {
constructor(
public id: number = 0,
public distance: number = 0
){}
pack(builder:flatbuffers.Builder): flatbuffers.Offset {
return Ability.createAbility(builder,
this.id,
this.distance
);
}
}

View File

@@ -1,27 +0,0 @@
// automatically generated by the FlatBuffers compiler, do not modify
import { Monster } from '../../my-game/example/monster';
export var AnyAmbiguousAliases;
(function (AnyAmbiguousAliases) {
AnyAmbiguousAliases[AnyAmbiguousAliases["NONE"] = 0] = "NONE";
AnyAmbiguousAliases[AnyAmbiguousAliases["M1"] = 1] = "M1";
AnyAmbiguousAliases[AnyAmbiguousAliases["M2"] = 2] = "M2";
AnyAmbiguousAliases[AnyAmbiguousAliases["M3"] = 3] = "M3";
})(AnyAmbiguousAliases || (AnyAmbiguousAliases = {}));
export function unionToAnyAmbiguousAliases(type, accessor) {
switch (AnyAmbiguousAliases[type]) {
case 'NONE': return null;
case 'M1': return accessor(new Monster());
case 'M2': return accessor(new Monster());
case 'M3': return accessor(new Monster());
default: return null;
}
}
export function unionListToAnyAmbiguousAliases(type, accessor, index) {
switch (AnyAmbiguousAliases[type]) {
case 'NONE': return null;
case 'M1': return accessor(index, new Monster());
case 'M2': return accessor(index, new Monster());
case 'M3': return accessor(index, new Monster());
default: return null;
}
}

View File

@@ -1,38 +0,0 @@
// automatically generated by the FlatBuffers compiler, do not modify
import { Monster, MonsterT } from '../../my-game/example/monster';
export enum AnyAmbiguousAliases {
NONE = 0,
M1 = 1,
M2 = 2,
M3 = 3
}
export function unionToAnyAmbiguousAliases(
type: AnyAmbiguousAliases,
accessor: (obj:Monster) => Monster|null
): Monster|null {
switch(AnyAmbiguousAliases[type]) {
case 'NONE': return null;
case 'M1': return accessor(new Monster())! as Monster;
case 'M2': return accessor(new Monster())! as Monster;
case 'M3': return accessor(new Monster())! as Monster;
default: return null;
}
}
export function unionListToAnyAmbiguousAliases(
type: AnyAmbiguousAliases,
accessor: (index: number, obj:Monster) => Monster|null,
index: number
): Monster|null {
switch(AnyAmbiguousAliases[type]) {
case 'NONE': return null;
case 'M1': return accessor(index, new Monster())! as Monster;
case 'M2': return accessor(index, new Monster())! as Monster;
case 'M3': return accessor(index, new Monster())! as Monster;
default: return null;
}
}

View File

@@ -1,29 +0,0 @@
// automatically generated by the FlatBuffers compiler, do not modify
import { Monster as MyGame_Example2_Monster } from '../../my-game/example2/monster';
import { Monster } from '../../my-game/example/monster';
import { TestSimpleTableWithEnum } from '../../my-game/example/test-simple-table-with-enum';
export var AnyUniqueAliases;
(function (AnyUniqueAliases) {
AnyUniqueAliases[AnyUniqueAliases["NONE"] = 0] = "NONE";
AnyUniqueAliases[AnyUniqueAliases["M"] = 1] = "M";
AnyUniqueAliases[AnyUniqueAliases["TS"] = 2] = "TS";
AnyUniqueAliases[AnyUniqueAliases["M2"] = 3] = "M2";
})(AnyUniqueAliases || (AnyUniqueAliases = {}));
export function unionToAnyUniqueAliases(type, accessor) {
switch (AnyUniqueAliases[type]) {
case 'NONE': return null;
case 'M': return accessor(new Monster());
case 'TS': return accessor(new TestSimpleTableWithEnum());
case 'M2': return accessor(new MyGame_Example2_Monster());
default: return null;
}
}
export function unionListToAnyUniqueAliases(type, accessor, index) {
switch (AnyUniqueAliases[type]) {
case 'NONE': return null;
case 'M': return accessor(index, new Monster());
case 'TS': return accessor(index, new TestSimpleTableWithEnum());
case 'M2': return accessor(index, new MyGame_Example2_Monster());
default: return null;
}
}

View File

@@ -1,40 +0,0 @@
// automatically generated by the FlatBuffers compiler, do not modify
import { Monster as MyGame_Example2_Monster, MonsterT as MyGame_Example2_MonsterT } from '../../my-game/example2/monster';
import { Monster, MonsterT } from '../../my-game/example/monster';
import { TestSimpleTableWithEnum, TestSimpleTableWithEnumT } from '../../my-game/example/test-simple-table-with-enum';
export enum AnyUniqueAliases {
NONE = 0,
M = 1,
TS = 2,
M2 = 3
}
export function unionToAnyUniqueAliases(
type: AnyUniqueAliases,
accessor: (obj:Monster|MyGame_Example2_Monster|TestSimpleTableWithEnum) => Monster|MyGame_Example2_Monster|TestSimpleTableWithEnum|null
): Monster|MyGame_Example2_Monster|TestSimpleTableWithEnum|null {
switch(AnyUniqueAliases[type]) {
case 'NONE': return null;
case 'M': return accessor(new Monster())! as Monster;
case 'TS': return accessor(new TestSimpleTableWithEnum())! as TestSimpleTableWithEnum;
case 'M2': return accessor(new MyGame_Example2_Monster())! as MyGame_Example2_Monster;
default: return null;
}
}
export function unionListToAnyUniqueAliases(
type: AnyUniqueAliases,
accessor: (index: number, obj:Monster|MyGame_Example2_Monster|TestSimpleTableWithEnum) => Monster|MyGame_Example2_Monster|TestSimpleTableWithEnum|null,
index: number
): Monster|MyGame_Example2_Monster|TestSimpleTableWithEnum|null {
switch(AnyUniqueAliases[type]) {
case 'NONE': return null;
case 'M': return accessor(index, new Monster())! as Monster;
case 'TS': return accessor(index, new TestSimpleTableWithEnum())! as TestSimpleTableWithEnum;
case 'M2': return accessor(index, new MyGame_Example2_Monster())! as MyGame_Example2_Monster;
default: return null;
}
}

View File

@@ -1,29 +0,0 @@
// automatically generated by the FlatBuffers compiler, do not modify
import { Monster as MyGame_Example2_Monster } from '../../my-game/example2/monster';
import { Monster } from '../../my-game/example/monster';
import { TestSimpleTableWithEnum } from '../../my-game/example/test-simple-table-with-enum';
export var Any;
(function (Any) {
Any[Any["NONE"] = 0] = "NONE";
Any[Any["Monster"] = 1] = "Monster";
Any[Any["TestSimpleTableWithEnum"] = 2] = "TestSimpleTableWithEnum";
Any[Any["MyGame_Example2_Monster"] = 3] = "MyGame_Example2_Monster";
})(Any || (Any = {}));
export function unionToAny(type, accessor) {
switch (Any[type]) {
case 'NONE': return null;
case 'Monster': return accessor(new Monster());
case 'TestSimpleTableWithEnum': return accessor(new TestSimpleTableWithEnum());
case 'MyGame_Example2_Monster': return accessor(new MyGame_Example2_Monster());
default: return null;
}
}
export function unionListToAny(type, accessor, index) {
switch (Any[type]) {
case 'NONE': return null;
case 'Monster': return accessor(index, new Monster());
case 'TestSimpleTableWithEnum': return accessor(index, new TestSimpleTableWithEnum());
case 'MyGame_Example2_Monster': return accessor(index, new MyGame_Example2_Monster());
default: return null;
}
}

View File

@@ -1,40 +0,0 @@
// automatically generated by the FlatBuffers compiler, do not modify
import { Monster as MyGame_Example2_Monster, MonsterT as MyGame_Example2_MonsterT } from '../../my-game/example2/monster';
import { Monster, MonsterT } from '../../my-game/example/monster';
import { TestSimpleTableWithEnum, TestSimpleTableWithEnumT } from '../../my-game/example/test-simple-table-with-enum';
export enum Any {
NONE = 0,
Monster = 1,
TestSimpleTableWithEnum = 2,
MyGame_Example2_Monster = 3
}
export function unionToAny(
type: Any,
accessor: (obj:Monster|MyGame_Example2_Monster|TestSimpleTableWithEnum) => Monster|MyGame_Example2_Monster|TestSimpleTableWithEnum|null
): Monster|MyGame_Example2_Monster|TestSimpleTableWithEnum|null {
switch(Any[type]) {
case 'NONE': return null;
case 'Monster': return accessor(new Monster())! as Monster;
case 'TestSimpleTableWithEnum': return accessor(new TestSimpleTableWithEnum())! as TestSimpleTableWithEnum;
case 'MyGame_Example2_Monster': return accessor(new MyGame_Example2_Monster())! as MyGame_Example2_Monster;
default: return null;
}
}
export function unionListToAny(
type: Any,
accessor: (index: number, obj:Monster|MyGame_Example2_Monster|TestSimpleTableWithEnum) => Monster|MyGame_Example2_Monster|TestSimpleTableWithEnum|null,
index: number
): Monster|MyGame_Example2_Monster|TestSimpleTableWithEnum|null {
switch(Any[type]) {
case 'NONE': return null;
case 'Monster': return accessor(index, new Monster())! as Monster;
case 'TestSimpleTableWithEnum': return accessor(index, new TestSimpleTableWithEnum())! as TestSimpleTableWithEnum;
case 'MyGame_Example2_Monster': return accessor(index, new MyGame_Example2_Monster())! as MyGame_Example2_Monster;
default: return null;
}
}

View File

@@ -1,17 +0,0 @@
// automatically generated by the FlatBuffers compiler, do not modify
/**
* Composite components of Monster color.
*/
export var Color;
(function (Color) {
Color[Color["Red"] = 1] = "Red";
/**
* \brief color Green
* Green is bit_flag with value (1u << 1)
*/
Color[Color["Green"] = 2] = "Green";
/**
* \brief color Blue (1u << 3)
*/
Color[Color["Blue"] = 8] = "Blue";
})(Color || (Color = {}));

View File

@@ -1,19 +0,0 @@
// automatically generated by the FlatBuffers compiler, do not modify
/**
* Composite components of Monster color.
*/
export enum Color {
Red = 1,
/**
* \brief color Green
* Green is bit_flag with value (1u << 1)
*/
Green = 2,
/**
* \brief color Blue (1u << 3)
*/
Blue = 8
}

View File

@@ -1,7 +0,0 @@
// automatically generated by the FlatBuffers compiler, do not modify
export enum LongEnum {
LongOne = '2',
LongTwo = '4',
LongBig = '1099511627776'
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,8 +0,0 @@
// automatically generated by the FlatBuffers compiler, do not modify
export var Race;
(function (Race) {
Race[Race["None"] = -1] = "None";
Race[Race["Human"] = 0] = "Human";
Race[Race["Dwarf"] = 1] = "Dwarf";
Race[Race["Elf"] = 2] = "Elf";
})(Race || (Race = {}));

View File

@@ -1,8 +0,0 @@
// automatically generated by the FlatBuffers compiler, do not modify
export enum Race {
None = -1,
Human = 0,
Dwarf = 1,
Elf = 2
}

View File

@@ -1,70 +0,0 @@
// automatically generated by the FlatBuffers compiler, do not modify
import * as flatbuffers from 'flatbuffers';
export class Referrable {
constructor() {
this.bb = null;
this.bb_pos = 0;
}
__init(i, bb) {
this.bb_pos = i;
this.bb = bb;
return this;
}
static getRootAsReferrable(bb, obj) {
return (obj || new Referrable()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}
static getSizePrefixedRootAsReferrable(bb, obj) {
bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
return (obj || new Referrable()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}
id() {
const offset = this.bb.__offset(this.bb_pos, 4);
return offset ? this.bb.readUint64(this.bb_pos + offset) : BigInt('0');
}
mutate_id(value) {
const offset = this.bb.__offset(this.bb_pos, 4);
if (offset === 0) {
return false;
}
this.bb.writeUint64(this.bb_pos + offset, value);
return true;
}
static getFullyQualifiedName() {
return 'MyGame_Example_Referrable';
}
static startReferrable(builder) {
builder.startObject(1);
}
static addId(builder, id) {
builder.addFieldInt64(0, id, BigInt('0'));
}
static endReferrable(builder) {
const offset = builder.endObject();
return offset;
}
static createReferrable(builder, id) {
Referrable.startReferrable(builder);
Referrable.addId(builder, id);
return Referrable.endReferrable(builder);
}
serialize() {
return this.bb.bytes();
}
static deserialize(buffer) {
return Referrable.getRootAsReferrable(new flatbuffers.ByteBuffer(buffer));
}
unpack() {
return new ReferrableT(this.id());
}
unpackTo(_o) {
_o.id = this.id();
}
}
export class ReferrableT {
constructor(id = BigInt('0')) {
this.id = id;
}
pack(builder) {
return Referrable.createReferrable(builder, this.id);
}
}

View File

@@ -1,95 +0,0 @@
// automatically generated by the FlatBuffers compiler, do not modify
import * as flatbuffers from 'flatbuffers';
export class Referrable {
bb: flatbuffers.ByteBuffer|null = null;
bb_pos = 0;
__init(i:number, bb:flatbuffers.ByteBuffer):Referrable {
this.bb_pos = i;
this.bb = bb;
return this;
}
static getRootAsReferrable(bb:flatbuffers.ByteBuffer, obj?:Referrable):Referrable {
return (obj || new Referrable()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}
static getSizePrefixedRootAsReferrable(bb:flatbuffers.ByteBuffer, obj?:Referrable):Referrable {
bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
return (obj || new Referrable()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}
id():bigint {
const offset = this.bb!.__offset(this.bb_pos, 4);
return offset ? this.bb!.readUint64(this.bb_pos + offset) : BigInt('0');
}
mutate_id(value:bigint):boolean {
const offset = this.bb!.__offset(this.bb_pos, 4);
if (offset === 0) {
return false;
}
this.bb!.writeUint64(this.bb_pos + offset, value);
return true;
}
static getFullyQualifiedName():string {
return 'MyGame_Example_Referrable';
}
static startReferrable(builder:flatbuffers.Builder) {
builder.startObject(1);
}
static addId(builder:flatbuffers.Builder, id:bigint) {
builder.addFieldInt64(0, id, BigInt('0'));
}
static endReferrable(builder:flatbuffers.Builder):flatbuffers.Offset {
const offset = builder.endObject();
return offset;
}
static createReferrable(builder:flatbuffers.Builder, id:bigint):flatbuffers.Offset {
Referrable.startReferrable(builder);
Referrable.addId(builder, id);
return Referrable.endReferrable(builder);
}
serialize():Uint8Array {
return this.bb!.bytes();
}
static deserialize(buffer: Uint8Array):Referrable {
return Referrable.getRootAsReferrable(new flatbuffers.ByteBuffer(buffer))
}
unpack(): ReferrableT {
return new ReferrableT(
this.id()
);
}
unpackTo(_o: ReferrableT): void {
_o.id = this.id();
}
}
export class ReferrableT {
constructor(
public id: bigint = BigInt('0')
){}
pack(builder:flatbuffers.Builder): flatbuffers.Offset {
return Referrable.createReferrable(builder,
this.id
);
}
}

View File

@@ -1,99 +0,0 @@
// automatically generated by the FlatBuffers compiler, do not modify
import * as flatbuffers from 'flatbuffers';
export class Stat {
constructor() {
this.bb = null;
this.bb_pos = 0;
}
__init(i, bb) {
this.bb_pos = i;
this.bb = bb;
return this;
}
static getRootAsStat(bb, obj) {
return (obj || new Stat()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}
static getSizePrefixedRootAsStat(bb, obj) {
bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
return (obj || new Stat()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}
id(optionalEncoding) {
const offset = this.bb.__offset(this.bb_pos, 4);
return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null;
}
val() {
const offset = this.bb.__offset(this.bb_pos, 6);
return offset ? this.bb.readInt64(this.bb_pos + offset) : BigInt('0');
}
mutate_val(value) {
const offset = this.bb.__offset(this.bb_pos, 6);
if (offset === 0) {
return false;
}
this.bb.writeInt64(this.bb_pos + offset, value);
return true;
}
count() {
const offset = this.bb.__offset(this.bb_pos, 8);
return offset ? this.bb.readUint16(this.bb_pos + offset) : 0;
}
mutate_count(value) {
const offset = this.bb.__offset(this.bb_pos, 8);
if (offset === 0) {
return false;
}
this.bb.writeUint16(this.bb_pos + offset, value);
return true;
}
static getFullyQualifiedName() {
return 'MyGame_Example_Stat';
}
static startStat(builder) {
builder.startObject(3);
}
static addId(builder, idOffset) {
builder.addFieldOffset(0, idOffset, 0);
}
static addVal(builder, val) {
builder.addFieldInt64(1, val, BigInt('0'));
}
static addCount(builder, count) {
builder.addFieldInt16(2, count, 0);
}
static endStat(builder) {
const offset = builder.endObject();
return offset;
}
static createStat(builder, idOffset, val, count) {
Stat.startStat(builder);
Stat.addId(builder, idOffset);
Stat.addVal(builder, val);
Stat.addCount(builder, count);
return Stat.endStat(builder);
}
serialize() {
return this.bb.bytes();
}
static deserialize(buffer) {
return Stat.getRootAsStat(new flatbuffers.ByteBuffer(buffer));
}
unpack() {
return new StatT(this.id(), this.val(), this.count());
}
unpackTo(_o) {
_o.id = this.id();
_o.val = this.val();
_o.count = this.count();
}
}
export class StatT {
constructor(id = null, val = BigInt('0'), count = 0) {
this.id = id;
this.val = val;
this.count = count;
}
pack(builder) {
const id = (this.id !== null ? builder.createString(this.id) : 0);
return Stat.createStat(builder, id, this.val, this.count);
}
}

View File

@@ -1,138 +0,0 @@
// automatically generated by the FlatBuffers compiler, do not modify
import * as flatbuffers from 'flatbuffers';
export class Stat {
bb: flatbuffers.ByteBuffer|null = null;
bb_pos = 0;
__init(i:number, bb:flatbuffers.ByteBuffer):Stat {
this.bb_pos = i;
this.bb = bb;
return this;
}
static getRootAsStat(bb:flatbuffers.ByteBuffer, obj?:Stat):Stat {
return (obj || new Stat()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}
static getSizePrefixedRootAsStat(bb:flatbuffers.ByteBuffer, obj?:Stat):Stat {
bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
return (obj || new Stat()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}
id():string|null
id(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
id(optionalEncoding?:any):string|Uint8Array|null {
const offset = this.bb!.__offset(this.bb_pos, 4);
return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
}
val():bigint {
const offset = this.bb!.__offset(this.bb_pos, 6);
return offset ? this.bb!.readInt64(this.bb_pos + offset) : BigInt('0');
}
mutate_val(value:bigint):boolean {
const offset = this.bb!.__offset(this.bb_pos, 6);
if (offset === 0) {
return false;
}
this.bb!.writeInt64(this.bb_pos + offset, value);
return true;
}
count():number {
const offset = this.bb!.__offset(this.bb_pos, 8);
return offset ? this.bb!.readUint16(this.bb_pos + offset) : 0;
}
mutate_count(value:number):boolean {
const offset = this.bb!.__offset(this.bb_pos, 8);
if (offset === 0) {
return false;
}
this.bb!.writeUint16(this.bb_pos + offset, value);
return true;
}
static getFullyQualifiedName():string {
return 'MyGame_Example_Stat';
}
static startStat(builder:flatbuffers.Builder) {
builder.startObject(3);
}
static addId(builder:flatbuffers.Builder, idOffset:flatbuffers.Offset) {
builder.addFieldOffset(0, idOffset, 0);
}
static addVal(builder:flatbuffers.Builder, val:bigint) {
builder.addFieldInt64(1, val, BigInt('0'));
}
static addCount(builder:flatbuffers.Builder, count:number) {
builder.addFieldInt16(2, count, 0);
}
static endStat(builder:flatbuffers.Builder):flatbuffers.Offset {
const offset = builder.endObject();
return offset;
}
static createStat(builder:flatbuffers.Builder, idOffset:flatbuffers.Offset, val:bigint, count:number):flatbuffers.Offset {
Stat.startStat(builder);
Stat.addId(builder, idOffset);
Stat.addVal(builder, val);
Stat.addCount(builder, count);
return Stat.endStat(builder);
}
serialize():Uint8Array {
return this.bb!.bytes();
}
static deserialize(buffer: Uint8Array):Stat {
return Stat.getRootAsStat(new flatbuffers.ByteBuffer(buffer))
}
unpack(): StatT {
return new StatT(
this.id(),
this.val(),
this.count()
);
}
unpackTo(_o: StatT): void {
_o.id = this.id();
_o.val = this.val();
_o.count = this.count();
}
}
export class StatT {
constructor(
public id: string|Uint8Array|null = null,
public val: bigint = BigInt('0'),
public count: number = 0
){}
pack(builder:flatbuffers.Builder): flatbuffers.Offset {
const id = (this.id !== null ? builder.createString(this.id!) : 0);
return Stat.createStat(builder,
id,
this.val,
this.count
);
}
}

View File

@@ -1,74 +0,0 @@
// automatically generated by the FlatBuffers compiler, do not modify
import * as flatbuffers from 'flatbuffers';
import { StructOfStructs, StructOfStructsT } from '../../my-game/example/struct-of-structs';
export class StructOfStructsOfStructs {
bb: flatbuffers.ByteBuffer|null = null;
bb_pos = 0;
__init(i:number, bb:flatbuffers.ByteBuffer):StructOfStructsOfStructs {
this.bb_pos = i;
this.bb = bb;
return this;
}
a(obj?:StructOfStructs):StructOfStructs|null {
return (obj || new StructOfStructs()).__init(this.bb_pos, this.bb!);
}
static getFullyQualifiedName():string {
return 'MyGame_Example_StructOfStructsOfStructs';
}
static sizeOf():number {
return 20;
}
static createStructOfStructsOfStructs(builder:flatbuffers.Builder, a_a_id: number, a_a_distance: number, a_b_a: number, a_b_b: number, a_c_id: number, a_c_distance: number):flatbuffers.Offset {
builder.prep(4, 20);
builder.prep(4, 20);
builder.prep(4, 8);
builder.writeInt32(a_c_distance);
builder.writeInt32(a_c_id);
builder.prep(2, 4);
builder.pad(1);
builder.writeInt8(a_b_b);
builder.writeInt16(a_b_a);
builder.prep(4, 8);
builder.writeInt32(a_a_distance);
builder.writeInt32(a_a_id);
return builder.offset();
}
unpack(): StructOfStructsOfStructsT {
return new StructOfStructsOfStructsT(
(this.a() !== null ? this.a()!.unpack() : null)
);
}
unpackTo(_o: StructOfStructsOfStructsT): void {
_o.a = (this.a() !== null ? this.a()!.unpack() : null);
}
}
export class StructOfStructsOfStructsT {
constructor(
public a: StructOfStructsT|null = null
){}
pack(builder:flatbuffers.Builder): flatbuffers.Offset {
return StructOfStructsOfStructs.createStructOfStructsOfStructs(builder,
(this.a?.a?.id ?? 0),
(this.a?.a?.distance ?? 0),
(this.a?.b?.a ?? 0),
(this.a?.b?.b ?? 0),
(this.a?.c?.id ?? 0),
(this.a?.c?.distance ?? 0)
);
}
}

View File

@@ -1,62 +0,0 @@
// automatically generated by the FlatBuffers compiler, do not modify
import { Ability } from '../../my-game/example/ability';
import { Test } from '../../my-game/example/test';
export class StructOfStructs {
constructor() {
this.bb = null;
this.bb_pos = 0;
}
__init(i, bb) {
this.bb_pos = i;
this.bb = bb;
return this;
}
a(obj) {
return (obj || new Ability()).__init(this.bb_pos, this.bb);
}
b(obj) {
return (obj || new Test()).__init(this.bb_pos + 8, this.bb);
}
c(obj) {
return (obj || new Ability()).__init(this.bb_pos + 12, this.bb);
}
static getFullyQualifiedName() {
return 'MyGame_Example_StructOfStructs';
}
static sizeOf() {
return 20;
}
static createStructOfStructs(builder, a_id, a_distance, b_a, b_b, c_id, c_distance) {
builder.prep(4, 20);
builder.prep(4, 8);
builder.writeInt32(c_distance);
builder.writeInt32(c_id);
builder.prep(2, 4);
builder.pad(1);
builder.writeInt8(b_b);
builder.writeInt16(b_a);
builder.prep(4, 8);
builder.writeInt32(a_distance);
builder.writeInt32(a_id);
return builder.offset();
}
unpack() {
return new StructOfStructsT((this.a() !== null ? this.a().unpack() : null), (this.b() !== null ? this.b().unpack() : null), (this.c() !== null ? this.c().unpack() : null));
}
unpackTo(_o) {
_o.a = (this.a() !== null ? this.a().unpack() : null);
_o.b = (this.b() !== null ? this.b().unpack() : null);
_o.c = (this.c() !== null ? this.c().unpack() : null);
}
}
export class StructOfStructsT {
constructor(a = null, b = null, c = null) {
this.a = a;
this.b = b;
this.c = c;
}
pack(builder) {
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
return StructOfStructs.createStructOfStructs(builder, ((_b = (_a = this.a) === null || _a === void 0 ? void 0 : _a.id) !== null && _b !== void 0 ? _b : 0), ((_d = (_c = this.a) === null || _c === void 0 ? void 0 : _c.distance) !== null && _d !== void 0 ? _d : 0), ((_f = (_e = this.b) === null || _e === void 0 ? void 0 : _e.a) !== null && _f !== void 0 ? _f : 0), ((_h = (_g = this.b) === null || _g === void 0 ? void 0 : _g.b) !== null && _h !== void 0 ? _h : 0), ((_k = (_j = this.c) === null || _j === void 0 ? void 0 : _j.id) !== null && _k !== void 0 ? _k : 0), ((_m = (_l = this.c) === null || _l === void 0 ? void 0 : _l.distance) !== null && _m !== void 0 ? _m : 0));
}
}

View File

@@ -1,88 +0,0 @@
// automatically generated by the FlatBuffers compiler, do not modify
import * as flatbuffers from 'flatbuffers';
import { Ability, AbilityT } from '../../my-game/example/ability';
import { Test, TestT } from '../../my-game/example/test';
export class StructOfStructs {
bb: flatbuffers.ByteBuffer|null = null;
bb_pos = 0;
__init(i:number, bb:flatbuffers.ByteBuffer):StructOfStructs {
this.bb_pos = i;
this.bb = bb;
return this;
}
a(obj?:Ability):Ability|null {
return (obj || new Ability()).__init(this.bb_pos, this.bb!);
}
b(obj?:Test):Test|null {
return (obj || new Test()).__init(this.bb_pos + 8, this.bb!);
}
c(obj?:Ability):Ability|null {
return (obj || new Ability()).__init(this.bb_pos + 12, this.bb!);
}
static getFullyQualifiedName():string {
return 'MyGame_Example_StructOfStructs';
}
static sizeOf():number {
return 20;
}
static createStructOfStructs(builder:flatbuffers.Builder, a_id: number, a_distance: number, b_a: number, b_b: number, c_id: number, c_distance: number):flatbuffers.Offset {
builder.prep(4, 20);
builder.prep(4, 8);
builder.writeInt32(c_distance);
builder.writeInt32(c_id);
builder.prep(2, 4);
builder.pad(1);
builder.writeInt8(b_b);
builder.writeInt16(b_a);
builder.prep(4, 8);
builder.writeInt32(a_distance);
builder.writeInt32(a_id);
return builder.offset();
}
unpack(): StructOfStructsT {
return new StructOfStructsT(
(this.a() !== null ? this.a()!.unpack() : null),
(this.b() !== null ? this.b()!.unpack() : null),
(this.c() !== null ? this.c()!.unpack() : null)
);
}
unpackTo(_o: StructOfStructsT): void {
_o.a = (this.a() !== null ? this.a()!.unpack() : null);
_o.b = (this.b() !== null ? this.b()!.unpack() : null);
_o.c = (this.c() !== null ? this.c()!.unpack() : null);
}
}
export class StructOfStructsT {
constructor(
public a: AbilityT|null = null,
public b: TestT|null = null,
public c: AbilityT|null = null
){}
pack(builder:flatbuffers.Builder): flatbuffers.Offset {
return StructOfStructs.createStructOfStructs(builder,
(this.a?.id ?? 0),
(this.a?.distance ?? 0),
(this.b?.a ?? 0),
(this.b?.b ?? 0),
(this.c?.id ?? 0),
(this.c?.distance ?? 0)
);
}
}

View File

@@ -1,71 +0,0 @@
// automatically generated by the FlatBuffers compiler, do not modify
import * as flatbuffers from 'flatbuffers';
import { Color } from '../../my-game/example/color';
export class TestSimpleTableWithEnum {
constructor() {
this.bb = null;
this.bb_pos = 0;
}
__init(i, bb) {
this.bb_pos = i;
this.bb = bb;
return this;
}
static getRootAsTestSimpleTableWithEnum(bb, obj) {
return (obj || new TestSimpleTableWithEnum()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}
static getSizePrefixedRootAsTestSimpleTableWithEnum(bb, obj) {
bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
return (obj || new TestSimpleTableWithEnum()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}
color() {
const offset = this.bb.__offset(this.bb_pos, 4);
return offset ? this.bb.readUint8(this.bb_pos + offset) : Color.Green;
}
mutate_color(value) {
const offset = this.bb.__offset(this.bb_pos, 4);
if (offset === 0) {
return false;
}
this.bb.writeUint8(this.bb_pos + offset, value);
return true;
}
static getFullyQualifiedName() {
return 'MyGame_Example_TestSimpleTableWithEnum';
}
static startTestSimpleTableWithEnum(builder) {
builder.startObject(1);
}
static addColor(builder, color) {
builder.addFieldInt8(0, color, Color.Green);
}
static endTestSimpleTableWithEnum(builder) {
const offset = builder.endObject();
return offset;
}
static createTestSimpleTableWithEnum(builder, color) {
TestSimpleTableWithEnum.startTestSimpleTableWithEnum(builder);
TestSimpleTableWithEnum.addColor(builder, color);
return TestSimpleTableWithEnum.endTestSimpleTableWithEnum(builder);
}
serialize() {
return this.bb.bytes();
}
static deserialize(buffer) {
return TestSimpleTableWithEnum.getRootAsTestSimpleTableWithEnum(new flatbuffers.ByteBuffer(buffer));
}
unpack() {
return new TestSimpleTableWithEnumT(this.color());
}
unpackTo(_o) {
_o.color = this.color();
}
}
export class TestSimpleTableWithEnumT {
constructor(color = Color.Green) {
this.color = color;
}
pack(builder) {
return TestSimpleTableWithEnum.createTestSimpleTableWithEnum(builder, this.color);
}
}

View File

@@ -1,96 +0,0 @@
// automatically generated by the FlatBuffers compiler, do not modify
import * as flatbuffers from 'flatbuffers';
import { Color } from '../../my-game/example/color';
export class TestSimpleTableWithEnum {
bb: flatbuffers.ByteBuffer|null = null;
bb_pos = 0;
__init(i:number, bb:flatbuffers.ByteBuffer):TestSimpleTableWithEnum {
this.bb_pos = i;
this.bb = bb;
return this;
}
static getRootAsTestSimpleTableWithEnum(bb:flatbuffers.ByteBuffer, obj?:TestSimpleTableWithEnum):TestSimpleTableWithEnum {
return (obj || new TestSimpleTableWithEnum()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}
static getSizePrefixedRootAsTestSimpleTableWithEnum(bb:flatbuffers.ByteBuffer, obj?:TestSimpleTableWithEnum):TestSimpleTableWithEnum {
bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
return (obj || new TestSimpleTableWithEnum()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}
color():Color {
const offset = this.bb!.__offset(this.bb_pos, 4);
return offset ? this.bb!.readUint8(this.bb_pos + offset) : Color.Green;
}
mutate_color(value:Color):boolean {
const offset = this.bb!.__offset(this.bb_pos, 4);
if (offset === 0) {
return false;
}
this.bb!.writeUint8(this.bb_pos + offset, value);
return true;
}
static getFullyQualifiedName():string {
return 'MyGame_Example_TestSimpleTableWithEnum';
}
static startTestSimpleTableWithEnum(builder:flatbuffers.Builder) {
builder.startObject(1);
}
static addColor(builder:flatbuffers.Builder, color:Color) {
builder.addFieldInt8(0, color, Color.Green);
}
static endTestSimpleTableWithEnum(builder:flatbuffers.Builder):flatbuffers.Offset {
const offset = builder.endObject();
return offset;
}
static createTestSimpleTableWithEnum(builder:flatbuffers.Builder, color:Color):flatbuffers.Offset {
TestSimpleTableWithEnum.startTestSimpleTableWithEnum(builder);
TestSimpleTableWithEnum.addColor(builder, color);
return TestSimpleTableWithEnum.endTestSimpleTableWithEnum(builder);
}
serialize():Uint8Array {
return this.bb!.bytes();
}
static deserialize(buffer: Uint8Array):TestSimpleTableWithEnum {
return TestSimpleTableWithEnum.getRootAsTestSimpleTableWithEnum(new flatbuffers.ByteBuffer(buffer))
}
unpack(): TestSimpleTableWithEnumT {
return new TestSimpleTableWithEnumT(
this.color()
);
}
unpackTo(_o: TestSimpleTableWithEnumT): void {
_o.color = this.color();
}
}
export class TestSimpleTableWithEnumT {
constructor(
public color: Color = Color.Green
){}
pack(builder:flatbuffers.Builder): flatbuffers.Offset {
return TestSimpleTableWithEnum.createTestSimpleTableWithEnum(builder,
this.color
);
}
}

View File

@@ -1,55 +0,0 @@
// automatically generated by the FlatBuffers compiler, do not modify
export class Test {
constructor() {
this.bb = null;
this.bb_pos = 0;
}
__init(i, bb) {
this.bb_pos = i;
this.bb = bb;
return this;
}
a() {
return this.bb.readInt16(this.bb_pos);
}
mutate_a(value) {
this.bb.writeInt16(this.bb_pos + 0, value);
return true;
}
b() {
return this.bb.readInt8(this.bb_pos + 2);
}
mutate_b(value) {
this.bb.writeInt8(this.bb_pos + 2, value);
return true;
}
static getFullyQualifiedName() {
return 'MyGame_Example_Test';
}
static sizeOf() {
return 4;
}
static createTest(builder, a, b) {
builder.prep(2, 4);
builder.pad(1);
builder.writeInt8(b);
builder.writeInt16(a);
return builder.offset();
}
unpack() {
return new TestT(this.a(), this.b());
}
unpackTo(_o) {
_o.a = this.a();
_o.b = this.b();
}
}
export class TestT {
constructor(a = 0, b = 0) {
this.a = a;
this.b = b;
}
pack(builder) {
return Test.createTest(builder, this.a, this.b);
}
}

View File

@@ -1,78 +0,0 @@
// automatically generated by the FlatBuffers compiler, do not modify
import * as flatbuffers from 'flatbuffers';
export class Test {
bb: flatbuffers.ByteBuffer|null = null;
bb_pos = 0;
__init(i:number, bb:flatbuffers.ByteBuffer):Test {
this.bb_pos = i;
this.bb = bb;
return this;
}
a():number {
return this.bb!.readInt16(this.bb_pos);
}
mutate_a(value:number):boolean {
this.bb!.writeInt16(this.bb_pos + 0, value);
return true;
}
b():number {
return this.bb!.readInt8(this.bb_pos + 2);
}
mutate_b(value:number):boolean {
this.bb!.writeInt8(this.bb_pos + 2, value);
return true;
}
static getFullyQualifiedName():string {
return 'MyGame_Example_Test';
}
static sizeOf():number {
return 4;
}
static createTest(builder:flatbuffers.Builder, a: number, b: number):flatbuffers.Offset {
builder.prep(2, 4);
builder.pad(1);
builder.writeInt8(b);
builder.writeInt16(a);
return builder.offset();
}
unpack(): TestT {
return new TestT(
this.a(),
this.b()
);
}
unpackTo(_o: TestT): void {
_o.a = this.a();
_o.b = this.b();
}
}
export class TestT {
constructor(
public a: number = 0,
public b: number = 0
){}
pack(builder:flatbuffers.Builder): flatbuffers.Offset {
return Test.createTest(builder,
this.a,
this.b
);
}
}

View File

@@ -1,290 +0,0 @@
// automatically generated by the FlatBuffers compiler, do not modify
import * as flatbuffers from 'flatbuffers';
export class TypeAliases {
constructor() {
this.bb = null;
this.bb_pos = 0;
}
__init(i, bb) {
this.bb_pos = i;
this.bb = bb;
return this;
}
static getRootAsTypeAliases(bb, obj) {
return (obj || new TypeAliases()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}
static getSizePrefixedRootAsTypeAliases(bb, obj) {
bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
return (obj || new TypeAliases()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}
i8() {
const offset = this.bb.__offset(this.bb_pos, 4);
return offset ? this.bb.readInt8(this.bb_pos + offset) : 0;
}
mutate_i8(value) {
const offset = this.bb.__offset(this.bb_pos, 4);
if (offset === 0) {
return false;
}
this.bb.writeInt8(this.bb_pos + offset, value);
return true;
}
u8() {
const offset = this.bb.__offset(this.bb_pos, 6);
return offset ? this.bb.readUint8(this.bb_pos + offset) : 0;
}
mutate_u8(value) {
const offset = this.bb.__offset(this.bb_pos, 6);
if (offset === 0) {
return false;
}
this.bb.writeUint8(this.bb_pos + offset, value);
return true;
}
i16() {
const offset = this.bb.__offset(this.bb_pos, 8);
return offset ? this.bb.readInt16(this.bb_pos + offset) : 0;
}
mutate_i16(value) {
const offset = this.bb.__offset(this.bb_pos, 8);
if (offset === 0) {
return false;
}
this.bb.writeInt16(this.bb_pos + offset, value);
return true;
}
u16() {
const offset = this.bb.__offset(this.bb_pos, 10);
return offset ? this.bb.readUint16(this.bb_pos + offset) : 0;
}
mutate_u16(value) {
const offset = this.bb.__offset(this.bb_pos, 10);
if (offset === 0) {
return false;
}
this.bb.writeUint16(this.bb_pos + offset, value);
return true;
}
i32() {
const offset = this.bb.__offset(this.bb_pos, 12);
return offset ? this.bb.readInt32(this.bb_pos + offset) : 0;
}
mutate_i32(value) {
const offset = this.bb.__offset(this.bb_pos, 12);
if (offset === 0) {
return false;
}
this.bb.writeInt32(this.bb_pos + offset, value);
return true;
}
u32() {
const offset = this.bb.__offset(this.bb_pos, 14);
return offset ? this.bb.readUint32(this.bb_pos + offset) : 0;
}
mutate_u32(value) {
const offset = this.bb.__offset(this.bb_pos, 14);
if (offset === 0) {
return false;
}
this.bb.writeUint32(this.bb_pos + offset, value);
return true;
}
i64() {
const offset = this.bb.__offset(this.bb_pos, 16);
return offset ? this.bb.readInt64(this.bb_pos + offset) : BigInt('0');
}
mutate_i64(value) {
const offset = this.bb.__offset(this.bb_pos, 16);
if (offset === 0) {
return false;
}
this.bb.writeInt64(this.bb_pos + offset, value);
return true;
}
u64() {
const offset = this.bb.__offset(this.bb_pos, 18);
return offset ? this.bb.readUint64(this.bb_pos + offset) : BigInt('0');
}
mutate_u64(value) {
const offset = this.bb.__offset(this.bb_pos, 18);
if (offset === 0) {
return false;
}
this.bb.writeUint64(this.bb_pos + offset, value);
return true;
}
f32() {
const offset = this.bb.__offset(this.bb_pos, 20);
return offset ? this.bb.readFloat32(this.bb_pos + offset) : 0.0;
}
mutate_f32(value) {
const offset = this.bb.__offset(this.bb_pos, 20);
if (offset === 0) {
return false;
}
this.bb.writeFloat32(this.bb_pos + offset, value);
return true;
}
f64() {
const offset = this.bb.__offset(this.bb_pos, 22);
return offset ? this.bb.readFloat64(this.bb_pos + offset) : 0.0;
}
mutate_f64(value) {
const offset = this.bb.__offset(this.bb_pos, 22);
if (offset === 0) {
return false;
}
this.bb.writeFloat64(this.bb_pos + offset, value);
return true;
}
v8(index) {
const offset = this.bb.__offset(this.bb_pos, 24);
return offset ? this.bb.readInt8(this.bb.__vector(this.bb_pos + offset) + index) : 0;
}
v8Length() {
const offset = this.bb.__offset(this.bb_pos, 24);
return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0;
}
v8Array() {
const offset = this.bb.__offset(this.bb_pos, 24);
return offset ? new Int8Array(this.bb.bytes().buffer, this.bb.bytes().byteOffset + this.bb.__vector(this.bb_pos + offset), this.bb.__vector_len(this.bb_pos + offset)) : null;
}
vf64(index) {
const offset = this.bb.__offset(this.bb_pos, 26);
return offset ? this.bb.readFloat64(this.bb.__vector(this.bb_pos + offset) + index * 8) : 0;
}
vf64Length() {
const offset = this.bb.__offset(this.bb_pos, 26);
return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0;
}
vf64Array() {
const offset = this.bb.__offset(this.bb_pos, 26);
return offset ? new Float64Array(this.bb.bytes().buffer, this.bb.bytes().byteOffset + this.bb.__vector(this.bb_pos + offset), this.bb.__vector_len(this.bb_pos + offset)) : null;
}
static getFullyQualifiedName() {
return 'MyGame_Example_TypeAliases';
}
static startTypeAliases(builder) {
builder.startObject(12);
}
static addI8(builder, i8) {
builder.addFieldInt8(0, i8, 0);
}
static addU8(builder, u8) {
builder.addFieldInt8(1, u8, 0);
}
static addI16(builder, i16) {
builder.addFieldInt16(2, i16, 0);
}
static addU16(builder, u16) {
builder.addFieldInt16(3, u16, 0);
}
static addI32(builder, i32) {
builder.addFieldInt32(4, i32, 0);
}
static addU32(builder, u32) {
builder.addFieldInt32(5, u32, 0);
}
static addI64(builder, i64) {
builder.addFieldInt64(6, i64, BigInt('0'));
}
static addU64(builder, u64) {
builder.addFieldInt64(7, u64, BigInt('0'));
}
static addF32(builder, f32) {
builder.addFieldFloat32(8, f32, 0.0);
}
static addF64(builder, f64) {
builder.addFieldFloat64(9, f64, 0.0);
}
static addV8(builder, v8Offset) {
builder.addFieldOffset(10, v8Offset, 0);
}
static createV8Vector(builder, data) {
builder.startVector(1, data.length, 1);
for (let i = data.length - 1; i >= 0; i--) {
builder.addInt8(data[i]);
}
return builder.endVector();
}
static startV8Vector(builder, numElems) {
builder.startVector(1, numElems, 1);
}
static addVf64(builder, vf64Offset) {
builder.addFieldOffset(11, vf64Offset, 0);
}
static createVf64Vector(builder, data) {
builder.startVector(8, data.length, 8);
for (let i = data.length - 1; i >= 0; i--) {
builder.addFloat64(data[i]);
}
return builder.endVector();
}
static startVf64Vector(builder, numElems) {
builder.startVector(8, numElems, 8);
}
static endTypeAliases(builder) {
const offset = builder.endObject();
return offset;
}
static createTypeAliases(builder, i8, u8, i16, u16, i32, u32, i64, u64, f32, f64, v8Offset, vf64Offset) {
TypeAliases.startTypeAliases(builder);
TypeAliases.addI8(builder, i8);
TypeAliases.addU8(builder, u8);
TypeAliases.addI16(builder, i16);
TypeAliases.addU16(builder, u16);
TypeAliases.addI32(builder, i32);
TypeAliases.addU32(builder, u32);
TypeAliases.addI64(builder, i64);
TypeAliases.addU64(builder, u64);
TypeAliases.addF32(builder, f32);
TypeAliases.addF64(builder, f64);
TypeAliases.addV8(builder, v8Offset);
TypeAliases.addVf64(builder, vf64Offset);
return TypeAliases.endTypeAliases(builder);
}
serialize() {
return this.bb.bytes();
}
static deserialize(buffer) {
return TypeAliases.getRootAsTypeAliases(new flatbuffers.ByteBuffer(buffer));
}
unpack() {
return new TypeAliasesT(this.i8(), this.u8(), this.i16(), this.u16(), this.i32(), this.u32(), this.i64(), this.u64(), this.f32(), this.f64(), this.bb.createScalarList(this.v8.bind(this), this.v8Length()), this.bb.createScalarList(this.vf64.bind(this), this.vf64Length()));
}
unpackTo(_o) {
_o.i8 = this.i8();
_o.u8 = this.u8();
_o.i16 = this.i16();
_o.u16 = this.u16();
_o.i32 = this.i32();
_o.u32 = this.u32();
_o.i64 = this.i64();
_o.u64 = this.u64();
_o.f32 = this.f32();
_o.f64 = this.f64();
_o.v8 = this.bb.createScalarList(this.v8.bind(this), this.v8Length());
_o.vf64 = this.bb.createScalarList(this.vf64.bind(this), this.vf64Length());
}
}
export class TypeAliasesT {
constructor(i8 = 0, u8 = 0, i16 = 0, u16 = 0, i32 = 0, u32 = 0, i64 = BigInt('0'), u64 = BigInt('0'), f32 = 0.0, f64 = 0.0, v8 = [], vf64 = []) {
this.i8 = i8;
this.u8 = u8;
this.i16 = i16;
this.u16 = u16;
this.i32 = i32;
this.u32 = u32;
this.i64 = i64;
this.u64 = u64;
this.f32 = f32;
this.f64 = f64;
this.v8 = v8;
this.vf64 = vf64;
}
pack(builder) {
const v8 = TypeAliases.createV8Vector(builder, this.v8);
const vf64 = TypeAliases.createVf64Vector(builder, this.vf64);
return TypeAliases.createTypeAliases(builder, this.i8, this.u8, this.i16, this.u16, this.i32, this.u32, this.i64, this.u64, this.f32, this.f64, v8, vf64);
}
}

View File

@@ -1,405 +0,0 @@
// automatically generated by the FlatBuffers compiler, do not modify
import * as flatbuffers from 'flatbuffers';
export class TypeAliases {
bb: flatbuffers.ByteBuffer|null = null;
bb_pos = 0;
__init(i:number, bb:flatbuffers.ByteBuffer):TypeAliases {
this.bb_pos = i;
this.bb = bb;
return this;
}
static getRootAsTypeAliases(bb:flatbuffers.ByteBuffer, obj?:TypeAliases):TypeAliases {
return (obj || new TypeAliases()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}
static getSizePrefixedRootAsTypeAliases(bb:flatbuffers.ByteBuffer, obj?:TypeAliases):TypeAliases {
bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
return (obj || new TypeAliases()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}
i8():number {
const offset = this.bb!.__offset(this.bb_pos, 4);
return offset ? this.bb!.readInt8(this.bb_pos + offset) : 0;
}
mutate_i8(value:number):boolean {
const offset = this.bb!.__offset(this.bb_pos, 4);
if (offset === 0) {
return false;
}
this.bb!.writeInt8(this.bb_pos + offset, value);
return true;
}
u8():number {
const offset = this.bb!.__offset(this.bb_pos, 6);
return offset ? this.bb!.readUint8(this.bb_pos + offset) : 0;
}
mutate_u8(value:number):boolean {
const offset = this.bb!.__offset(this.bb_pos, 6);
if (offset === 0) {
return false;
}
this.bb!.writeUint8(this.bb_pos + offset, value);
return true;
}
i16():number {
const offset = this.bb!.__offset(this.bb_pos, 8);
return offset ? this.bb!.readInt16(this.bb_pos + offset) : 0;
}
mutate_i16(value:number):boolean {
const offset = this.bb!.__offset(this.bb_pos, 8);
if (offset === 0) {
return false;
}
this.bb!.writeInt16(this.bb_pos + offset, value);
return true;
}
u16():number {
const offset = this.bb!.__offset(this.bb_pos, 10);
return offset ? this.bb!.readUint16(this.bb_pos + offset) : 0;
}
mutate_u16(value:number):boolean {
const offset = this.bb!.__offset(this.bb_pos, 10);
if (offset === 0) {
return false;
}
this.bb!.writeUint16(this.bb_pos + offset, value);
return true;
}
i32():number {
const offset = this.bb!.__offset(this.bb_pos, 12);
return offset ? this.bb!.readInt32(this.bb_pos + offset) : 0;
}
mutate_i32(value:number):boolean {
const offset = this.bb!.__offset(this.bb_pos, 12);
if (offset === 0) {
return false;
}
this.bb!.writeInt32(this.bb_pos + offset, value);
return true;
}
u32():number {
const offset = this.bb!.__offset(this.bb_pos, 14);
return offset ? this.bb!.readUint32(this.bb_pos + offset) : 0;
}
mutate_u32(value:number):boolean {
const offset = this.bb!.__offset(this.bb_pos, 14);
if (offset === 0) {
return false;
}
this.bb!.writeUint32(this.bb_pos + offset, value);
return true;
}
i64():bigint {
const offset = this.bb!.__offset(this.bb_pos, 16);
return offset ? this.bb!.readInt64(this.bb_pos + offset) : BigInt('0');
}
mutate_i64(value:bigint):boolean {
const offset = this.bb!.__offset(this.bb_pos, 16);
if (offset === 0) {
return false;
}
this.bb!.writeInt64(this.bb_pos + offset, value);
return true;
}
u64():bigint {
const offset = this.bb!.__offset(this.bb_pos, 18);
return offset ? this.bb!.readUint64(this.bb_pos + offset) : BigInt('0');
}
mutate_u64(value:bigint):boolean {
const offset = this.bb!.__offset(this.bb_pos, 18);
if (offset === 0) {
return false;
}
this.bb!.writeUint64(this.bb_pos + offset, value);
return true;
}
f32():number {
const offset = this.bb!.__offset(this.bb_pos, 20);
return offset ? this.bb!.readFloat32(this.bb_pos + offset) : 0.0;
}
mutate_f32(value:number):boolean {
const offset = this.bb!.__offset(this.bb_pos, 20);
if (offset === 0) {
return false;
}
this.bb!.writeFloat32(this.bb_pos + offset, value);
return true;
}
f64():number {
const offset = this.bb!.__offset(this.bb_pos, 22);
return offset ? this.bb!.readFloat64(this.bb_pos + offset) : 0.0;
}
mutate_f64(value:number):boolean {
const offset = this.bb!.__offset(this.bb_pos, 22);
if (offset === 0) {
return false;
}
this.bb!.writeFloat64(this.bb_pos + offset, value);
return true;
}
v8(index: number):number|null {
const offset = this.bb!.__offset(this.bb_pos, 24);
return offset ? this.bb!.readInt8(this.bb!.__vector(this.bb_pos + offset) + index) : 0;
}
v8Length():number {
const offset = this.bb!.__offset(this.bb_pos, 24);
return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
}
v8Array():Int8Array|null {
const offset = this.bb!.__offset(this.bb_pos, 24);
return offset ? new Int8Array(this.bb!.bytes().buffer, this.bb!.bytes().byteOffset + this.bb!.__vector(this.bb_pos + offset), this.bb!.__vector_len(this.bb_pos + offset)) : null;
}
vf64(index: number):number|null {
const offset = this.bb!.__offset(this.bb_pos, 26);
return offset ? this.bb!.readFloat64(this.bb!.__vector(this.bb_pos + offset) + index * 8) : 0;
}
vf64Length():number {
const offset = this.bb!.__offset(this.bb_pos, 26);
return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
}
vf64Array():Float64Array|null {
const offset = this.bb!.__offset(this.bb_pos, 26);
return offset ? new Float64Array(this.bb!.bytes().buffer, this.bb!.bytes().byteOffset + this.bb!.__vector(this.bb_pos + offset), this.bb!.__vector_len(this.bb_pos + offset)) : null;
}
static getFullyQualifiedName():string {
return 'MyGame_Example_TypeAliases';
}
static startTypeAliases(builder:flatbuffers.Builder) {
builder.startObject(12);
}
static addI8(builder:flatbuffers.Builder, i8:number) {
builder.addFieldInt8(0, i8, 0);
}
static addU8(builder:flatbuffers.Builder, u8:number) {
builder.addFieldInt8(1, u8, 0);
}
static addI16(builder:flatbuffers.Builder, i16:number) {
builder.addFieldInt16(2, i16, 0);
}
static addU16(builder:flatbuffers.Builder, u16:number) {
builder.addFieldInt16(3, u16, 0);
}
static addI32(builder:flatbuffers.Builder, i32:number) {
builder.addFieldInt32(4, i32, 0);
}
static addU32(builder:flatbuffers.Builder, u32:number) {
builder.addFieldInt32(5, u32, 0);
}
static addI64(builder:flatbuffers.Builder, i64:bigint) {
builder.addFieldInt64(6, i64, BigInt('0'));
}
static addU64(builder:flatbuffers.Builder, u64:bigint) {
builder.addFieldInt64(7, u64, BigInt('0'));
}
static addF32(builder:flatbuffers.Builder, f32:number) {
builder.addFieldFloat32(8, f32, 0.0);
}
static addF64(builder:flatbuffers.Builder, f64:number) {
builder.addFieldFloat64(9, f64, 0.0);
}
static addV8(builder:flatbuffers.Builder, v8Offset:flatbuffers.Offset) {
builder.addFieldOffset(10, v8Offset, 0);
}
static createV8Vector(builder:flatbuffers.Builder, data:number[]|Int8Array):flatbuffers.Offset;
/**
* @deprecated This Uint8Array overload will be removed in the future.
*/
static createV8Vector(builder:flatbuffers.Builder, data:number[]|Uint8Array):flatbuffers.Offset;
static createV8Vector(builder:flatbuffers.Builder, data:number[]|Int8Array|Uint8Array):flatbuffers.Offset {
builder.startVector(1, data.length, 1);
for (let i = data.length - 1; i >= 0; i--) {
builder.addInt8(data[i]!);
}
return builder.endVector();
}
static startV8Vector(builder:flatbuffers.Builder, numElems:number) {
builder.startVector(1, numElems, 1);
}
static addVf64(builder:flatbuffers.Builder, vf64Offset:flatbuffers.Offset) {
builder.addFieldOffset(11, vf64Offset, 0);
}
static createVf64Vector(builder:flatbuffers.Builder, data:number[]|Float64Array):flatbuffers.Offset;
/**
* @deprecated This Uint8Array overload will be removed in the future.
*/
static createVf64Vector(builder:flatbuffers.Builder, data:number[]|Uint8Array):flatbuffers.Offset;
static createVf64Vector(builder:flatbuffers.Builder, data:number[]|Float64Array|Uint8Array):flatbuffers.Offset {
builder.startVector(8, data.length, 8);
for (let i = data.length - 1; i >= 0; i--) {
builder.addFloat64(data[i]!);
}
return builder.endVector();
}
static startVf64Vector(builder:flatbuffers.Builder, numElems:number) {
builder.startVector(8, numElems, 8);
}
static endTypeAliases(builder:flatbuffers.Builder):flatbuffers.Offset {
const offset = builder.endObject();
return offset;
}
static createTypeAliases(builder:flatbuffers.Builder, i8:number, u8:number, i16:number, u16:number, i32:number, u32:number, i64:bigint, u64:bigint, f32:number, f64:number, v8Offset:flatbuffers.Offset, vf64Offset:flatbuffers.Offset):flatbuffers.Offset {
TypeAliases.startTypeAliases(builder);
TypeAliases.addI8(builder, i8);
TypeAliases.addU8(builder, u8);
TypeAliases.addI16(builder, i16);
TypeAliases.addU16(builder, u16);
TypeAliases.addI32(builder, i32);
TypeAliases.addU32(builder, u32);
TypeAliases.addI64(builder, i64);
TypeAliases.addU64(builder, u64);
TypeAliases.addF32(builder, f32);
TypeAliases.addF64(builder, f64);
TypeAliases.addV8(builder, v8Offset);
TypeAliases.addVf64(builder, vf64Offset);
return TypeAliases.endTypeAliases(builder);
}
serialize():Uint8Array {
return this.bb!.bytes();
}
static deserialize(buffer: Uint8Array):TypeAliases {
return TypeAliases.getRootAsTypeAliases(new flatbuffers.ByteBuffer(buffer))
}
unpack(): TypeAliasesT {
return new TypeAliasesT(
this.i8(),
this.u8(),
this.i16(),
this.u16(),
this.i32(),
this.u32(),
this.i64(),
this.u64(),
this.f32(),
this.f64(),
this.bb!.createScalarList(this.v8.bind(this), this.v8Length()),
this.bb!.createScalarList(this.vf64.bind(this), this.vf64Length())
);
}
unpackTo(_o: TypeAliasesT): void {
_o.i8 = this.i8();
_o.u8 = this.u8();
_o.i16 = this.i16();
_o.u16 = this.u16();
_o.i32 = this.i32();
_o.u32 = this.u32();
_o.i64 = this.i64();
_o.u64 = this.u64();
_o.f32 = this.f32();
_o.f64 = this.f64();
_o.v8 = this.bb!.createScalarList(this.v8.bind(this), this.v8Length());
_o.vf64 = this.bb!.createScalarList(this.vf64.bind(this), this.vf64Length());
}
}
export class TypeAliasesT {
constructor(
public i8: number = 0,
public u8: number = 0,
public i16: number = 0,
public u16: number = 0,
public i32: number = 0,
public u32: number = 0,
public i64: bigint = BigInt('0'),
public u64: bigint = BigInt('0'),
public f32: number = 0.0,
public f64: number = 0.0,
public v8: (number)[] = [],
public vf64: (number)[] = []
){}
pack(builder:flatbuffers.Builder): flatbuffers.Offset {
const v8 = TypeAliases.createV8Vector(builder, this.v8);
const vf64 = TypeAliases.createVf64Vector(builder, this.vf64);
return TypeAliases.createTypeAliases(builder,
this.i8,
this.u8,
this.i16,
this.u16,
this.i32,
this.u32,
this.i64,
this.u64,
this.f32,
this.f64,
v8,
vf64
);
}
}

View File

@@ -1,98 +0,0 @@
// automatically generated by the FlatBuffers compiler, do not modify
import { Test } from '../../my-game/example/test';
export class Vec3 {
constructor() {
this.bb = null;
this.bb_pos = 0;
}
__init(i, bb) {
this.bb_pos = i;
this.bb = bb;
return this;
}
x() {
return this.bb.readFloat32(this.bb_pos);
}
mutate_x(value) {
this.bb.writeFloat32(this.bb_pos + 0, value);
return true;
}
y() {
return this.bb.readFloat32(this.bb_pos + 4);
}
mutate_y(value) {
this.bb.writeFloat32(this.bb_pos + 4, value);
return true;
}
z() {
return this.bb.readFloat32(this.bb_pos + 8);
}
mutate_z(value) {
this.bb.writeFloat32(this.bb_pos + 8, value);
return true;
}
test1() {
return this.bb.readFloat64(this.bb_pos + 16);
}
mutate_test1(value) {
this.bb.writeFloat64(this.bb_pos + 16, value);
return true;
}
test2() {
return this.bb.readUint8(this.bb_pos + 24);
}
mutate_test2(value) {
this.bb.writeUint8(this.bb_pos + 24, value);
return true;
}
test3(obj) {
return (obj || new Test()).__init(this.bb_pos + 26, this.bb);
}
static getFullyQualifiedName() {
return 'MyGame_Example_Vec3';
}
static sizeOf() {
return 32;
}
static createVec3(builder, x, y, z, test1, test2, test3_a, test3_b) {
builder.prep(8, 32);
builder.pad(2);
builder.prep(2, 4);
builder.pad(1);
builder.writeInt8(test3_b);
builder.writeInt16(test3_a);
builder.pad(1);
builder.writeInt8(test2);
builder.writeFloat64(test1);
builder.pad(4);
builder.writeFloat32(z);
builder.writeFloat32(y);
builder.writeFloat32(x);
return builder.offset();
}
unpack() {
return new Vec3T(this.x(), this.y(), this.z(), this.test1(), this.test2(), (this.test3() !== null ? this.test3().unpack() : null));
}
unpackTo(_o) {
_o.x = this.x();
_o.y = this.y();
_o.z = this.z();
_o.test1 = this.test1();
_o.test2 = this.test2();
_o.test3 = (this.test3() !== null ? this.test3().unpack() : null);
}
}
export class Vec3T {
constructor(x = 0.0, y = 0.0, z = 0.0, test1 = 0.0, test2 = 0, test3 = null) {
this.x = x;
this.y = y;
this.z = z;
this.test1 = test1;
this.test2 = test2;
this.test3 = test3;
}
pack(builder) {
var _a, _b, _c, _d;
return Vec3.createVec3(builder, this.x, this.y, this.z, this.test1, this.test2, ((_b = (_a = this.test3) === null || _a === void 0 ? void 0 : _a.a) !== null && _b !== void 0 ? _b : 0), ((_d = (_c = this.test3) === null || _c === void 0 ? void 0 : _c.b) !== null && _d !== void 0 ? _d : 0));
}
}

View File

@@ -1,137 +0,0 @@
// automatically generated by the FlatBuffers compiler, do not modify
import * as flatbuffers from 'flatbuffers';
import { Color } from '../../my-game/example/color';
import { Test, TestT } from '../../my-game/example/test';
export class Vec3 {
bb: flatbuffers.ByteBuffer|null = null;
bb_pos = 0;
__init(i:number, bb:flatbuffers.ByteBuffer):Vec3 {
this.bb_pos = i;
this.bb = bb;
return this;
}
x():number {
return this.bb!.readFloat32(this.bb_pos);
}
mutate_x(value:number):boolean {
this.bb!.writeFloat32(this.bb_pos + 0, value);
return true;
}
y():number {
return this.bb!.readFloat32(this.bb_pos + 4);
}
mutate_y(value:number):boolean {
this.bb!.writeFloat32(this.bb_pos + 4, value);
return true;
}
z():number {
return this.bb!.readFloat32(this.bb_pos + 8);
}
mutate_z(value:number):boolean {
this.bb!.writeFloat32(this.bb_pos + 8, value);
return true;
}
test1():number {
return this.bb!.readFloat64(this.bb_pos + 16);
}
mutate_test1(value:number):boolean {
this.bb!.writeFloat64(this.bb_pos + 16, value);
return true;
}
test2():Color {
return this.bb!.readUint8(this.bb_pos + 24);
}
mutate_test2(value:Color):boolean {
this.bb!.writeUint8(this.bb_pos + 24, value);
return true;
}
test3(obj?:Test):Test|null {
return (obj || new Test()).__init(this.bb_pos + 26, this.bb!);
}
static getFullyQualifiedName():string {
return 'MyGame_Example_Vec3';
}
static sizeOf():number {
return 32;
}
static createVec3(builder:flatbuffers.Builder, x: number, y: number, z: number, test1: number, test2: Color, test3_a: number, test3_b: number):flatbuffers.Offset {
builder.prep(8, 32);
builder.pad(2);
builder.prep(2, 4);
builder.pad(1);
builder.writeInt8(test3_b);
builder.writeInt16(test3_a);
builder.pad(1);
builder.writeInt8(test2);
builder.writeFloat64(test1);
builder.pad(4);
builder.writeFloat32(z);
builder.writeFloat32(y);
builder.writeFloat32(x);
return builder.offset();
}
unpack(): Vec3T {
return new Vec3T(
this.x(),
this.y(),
this.z(),
this.test1(),
this.test2(),
(this.test3() !== null ? this.test3()!.unpack() : null)
);
}
unpackTo(_o: Vec3T): void {
_o.x = this.x();
_o.y = this.y();
_o.z = this.z();
_o.test1 = this.test1();
_o.test2 = this.test2();
_o.test3 = (this.test3() !== null ? this.test3()!.unpack() : null);
}
}
export class Vec3T {
constructor(
public x: number = 0.0,
public y: number = 0.0,
public z: number = 0.0,
public test1: number = 0.0,
public test2: Color = 0,
public test3: TestT|null = null
){}
pack(builder:flatbuffers.Builder): flatbuffers.Offset {
return Vec3.createVec3(builder,
this.x,
this.y,
this.z,
this.test1,
this.test2,
(this.test3?.a ?? 0),
(this.test3?.b ?? 0)
);
}
}

View File

@@ -1,50 +0,0 @@
// automatically generated by the FlatBuffers compiler, do not modify
import * as flatbuffers from 'flatbuffers';
export class Monster {
constructor() {
this.bb = null;
this.bb_pos = 0;
}
__init(i, bb) {
this.bb_pos = i;
this.bb = bb;
return this;
}
static getRootAsMonster(bb, obj) {
return (obj || new Monster()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}
static getSizePrefixedRootAsMonster(bb, obj) {
bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
return (obj || new Monster()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}
static getFullyQualifiedName() {
return 'MyGame_Example2_Monster';
}
static startMonster(builder) {
builder.startObject(0);
}
static endMonster(builder) {
const offset = builder.endObject();
return offset;
}
static createMonster(builder) {
Monster.startMonster(builder);
return Monster.endMonster(builder);
}
serialize() {
return this.bb.bytes();
}
static deserialize(buffer) {
return Monster.getRootAsMonster(new flatbuffers.ByteBuffer(buffer));
}
unpack() {
return new MonsterT();
}
unpackTo(_o) { }
}
export class MonsterT {
constructor() { }
pack(builder) {
return Monster.createMonster(builder);
}
}

View File

@@ -1,66 +0,0 @@
// automatically generated by the FlatBuffers compiler, do not modify
import * as flatbuffers from 'flatbuffers';
export class Monster {
bb: flatbuffers.ByteBuffer|null = null;
bb_pos = 0;
__init(i:number, bb:flatbuffers.ByteBuffer):Monster {
this.bb_pos = i;
this.bb = bb;
return this;
}
static getRootAsMonster(bb:flatbuffers.ByteBuffer, obj?:Monster):Monster {
return (obj || new Monster()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}
static getSizePrefixedRootAsMonster(bb:flatbuffers.ByteBuffer, obj?:Monster):Monster {
bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
return (obj || new Monster()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}
static getFullyQualifiedName():string {
return 'MyGame_Example2_Monster';
}
static startMonster(builder:flatbuffers.Builder) {
builder.startObject(0);
}
static endMonster(builder:flatbuffers.Builder):flatbuffers.Offset {
const offset = builder.endObject();
return offset;
}
static createMonster(builder:flatbuffers.Builder):flatbuffers.Offset {
Monster.startMonster(builder);
return Monster.endMonster(builder);
}
serialize():Uint8Array {
return this.bb!.bytes();
}
static deserialize(buffer: Uint8Array):Monster {
return Monster.getRootAsMonster(new flatbuffers.ByteBuffer(buffer))
}
unpack(): MonsterT {
return new MonsterT();
}
unpackTo(_o: MonsterT): void {}
}
export class MonsterT {
constructor(){}
pack(builder:flatbuffers.Builder): flatbuffers.Offset {
return Monster.createMonster(builder);
}
}

View File

@@ -1,50 +0,0 @@
// automatically generated by the FlatBuffers compiler, do not modify
import * as flatbuffers from 'flatbuffers';
export class InParentNamespace {
constructor() {
this.bb = null;
this.bb_pos = 0;
}
__init(i, bb) {
this.bb_pos = i;
this.bb = bb;
return this;
}
static getRootAsInParentNamespace(bb, obj) {
return (obj || new InParentNamespace()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}
static getSizePrefixedRootAsInParentNamespace(bb, obj) {
bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
return (obj || new InParentNamespace()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}
static getFullyQualifiedName() {
return 'MyGame_InParentNamespace';
}
static startInParentNamespace(builder) {
builder.startObject(0);
}
static endInParentNamespace(builder) {
const offset = builder.endObject();
return offset;
}
static createInParentNamespace(builder) {
InParentNamespace.startInParentNamespace(builder);
return InParentNamespace.endInParentNamespace(builder);
}
serialize() {
return this.bb.bytes();
}
static deserialize(buffer) {
return InParentNamespace.getRootAsInParentNamespace(new flatbuffers.ByteBuffer(buffer));
}
unpack() {
return new InParentNamespaceT();
}
unpackTo(_o) { }
}
export class InParentNamespaceT {
constructor() { }
pack(builder) {
return InParentNamespace.createInParentNamespace(builder);
}
}

View File

@@ -1,66 +0,0 @@
// automatically generated by the FlatBuffers compiler, do not modify
import * as flatbuffers from 'flatbuffers';
export class InParentNamespace {
bb: flatbuffers.ByteBuffer|null = null;
bb_pos = 0;
__init(i:number, bb:flatbuffers.ByteBuffer):InParentNamespace {
this.bb_pos = i;
this.bb = bb;
return this;
}
static getRootAsInParentNamespace(bb:flatbuffers.ByteBuffer, obj?:InParentNamespace):InParentNamespace {
return (obj || new InParentNamespace()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}
static getSizePrefixedRootAsInParentNamespace(bb:flatbuffers.ByteBuffer, obj?:InParentNamespace):InParentNamespace {
bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
return (obj || new InParentNamespace()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}
static getFullyQualifiedName():string {
return 'MyGame_InParentNamespace';
}
static startInParentNamespace(builder:flatbuffers.Builder) {
builder.startObject(0);
}
static endInParentNamespace(builder:flatbuffers.Builder):flatbuffers.Offset {
const offset = builder.endObject();
return offset;
}
static createInParentNamespace(builder:flatbuffers.Builder):flatbuffers.Offset {
InParentNamespace.startInParentNamespace(builder);
return InParentNamespace.endInParentNamespace(builder);
}
serialize():Uint8Array {
return this.bb!.bytes();
}
static deserialize(buffer: Uint8Array):InParentNamespace {
return InParentNamespace.getRootAsInParentNamespace(new flatbuffers.ByteBuffer(buffer))
}
unpack(): InParentNamespaceT {
return new InParentNamespaceT();
}
unpackTo(_o: InParentNamespaceT): void {}
}
export class InParentNamespaceT {
constructor(){}
pack(builder:flatbuffers.Builder): flatbuffers.Offset {
return InParentNamespace.createInParentNamespace(builder);
}
}

View File

@@ -1,7 +0,0 @@
// automatically generated by the FlatBuffers compiler, do not modify
export var EnumInNestedNS;
(function (EnumInNestedNS) {
EnumInNestedNS[EnumInNestedNS["A"] = 0] = "A";
EnumInNestedNS[EnumInNestedNS["B"] = 1] = "B";
EnumInNestedNS[EnumInNestedNS["C"] = 2] = "C";
})(EnumInNestedNS || (EnumInNestedNS = {}));

View File

@@ -1,54 +0,0 @@
// automatically generated by the FlatBuffers compiler, do not modify
export class StructInNestedNS {
constructor() {
this.bb = null;
this.bb_pos = 0;
}
__init(i, bb) {
this.bb_pos = i;
this.bb = bb;
return this;
}
a() {
return this.bb.readInt32(this.bb_pos);
}
mutate_a(value) {
this.bb.writeInt32(this.bb_pos + 0, value);
return true;
}
b() {
return this.bb.readInt32(this.bb_pos + 4);
}
mutate_b(value) {
this.bb.writeInt32(this.bb_pos + 4, value);
return true;
}
static getFullyQualifiedName() {
return 'NamespaceA.NamespaceB.StructInNestedNS';
}
static sizeOf() {
return 8;
}
static createStructInNestedNS(builder, a, b) {
builder.prep(4, 8);
builder.writeInt32(b);
builder.writeInt32(a);
return builder.offset();
}
unpack() {
return new StructInNestedNST(this.a(), this.b());
}
unpackTo(_o) {
_o.a = this.a();
_o.b = this.b();
}
}
export class StructInNestedNST {
constructor(a = 0, b = 0) {
this.a = a;
this.b = b;
}
pack(builder) {
return StructInNestedNS.createStructInNestedNS(builder, this.a, this.b);
}
}

View File

@@ -1,77 +0,0 @@
// automatically generated by the FlatBuffers compiler, do not modify
import * as flatbuffers from 'flatbuffers';
export class StructInNestedNS {
bb: flatbuffers.ByteBuffer|null = null;
bb_pos = 0;
__init(i:number, bb:flatbuffers.ByteBuffer):StructInNestedNS {
this.bb_pos = i;
this.bb = bb;
return this;
}
a():number {
return this.bb!.readInt32(this.bb_pos);
}
mutate_a(value:number):boolean {
this.bb!.writeInt32(this.bb_pos + 0, value);
return true;
}
b():number {
return this.bb!.readInt32(this.bb_pos + 4);
}
mutate_b(value:number):boolean {
this.bb!.writeInt32(this.bb_pos + 4, value);
return true;
}
static getFullyQualifiedName():string {
return 'NamespaceA.NamespaceB.StructInNestedNS';
}
static sizeOf():number {
return 8;
}
static createStructInNestedNS(builder:flatbuffers.Builder, a: number, b: number):flatbuffers.Offset {
builder.prep(4, 8);
builder.writeInt32(b);
builder.writeInt32(a);
return builder.offset();
}
unpack(): StructInNestedNST {
return new StructInNestedNST(
this.a(),
this.b()
);
}
unpackTo(_o: StructInNestedNST): void {
_o.a = this.a();
_o.b = this.b();
}
}
export class StructInNestedNST {
constructor(
public a: number = 0,
public b: number = 0
){}
pack(builder:flatbuffers.Builder): flatbuffers.Offset {
return StructInNestedNS.createStructInNestedNS(builder,
this.a,
this.b
);
}
}

View File

@@ -1,64 +0,0 @@
// automatically generated by the FlatBuffers compiler, do not modify
import * as flatbuffers from 'flatbuffers';
export class TableInNestedNS {
constructor() {
this.bb = null;
this.bb_pos = 0;
}
__init(i, bb) {
this.bb_pos = i;
this.bb = bb;
return this;
}
static getRootAsTableInNestedNS(bb, obj) {
return (obj || new TableInNestedNS()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}
static getSizePrefixedRootAsTableInNestedNS(bb, obj) {
bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
return (obj || new TableInNestedNS()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}
foo() {
const offset = this.bb.__offset(this.bb_pos, 4);
return offset ? this.bb.readInt32(this.bb_pos + offset) : 0;
}
mutate_foo(value) {
const offset = this.bb.__offset(this.bb_pos, 4);
if (offset === 0) {
return false;
}
this.bb.writeInt32(this.bb_pos + offset, value);
return true;
}
static getFullyQualifiedName() {
return 'NamespaceA.NamespaceB.TableInNestedNS';
}
static startTableInNestedNS(builder) {
builder.startObject(1);
}
static addFoo(builder, foo) {
builder.addFieldInt32(0, foo, 0);
}
static endTableInNestedNS(builder) {
const offset = builder.endObject();
return offset;
}
static createTableInNestedNS(builder, foo) {
TableInNestedNS.startTableInNestedNS(builder);
TableInNestedNS.addFoo(builder, foo);
return TableInNestedNS.endTableInNestedNS(builder);
}
unpack() {
return new TableInNestedNST(this.foo());
}
unpackTo(_o) {
_o.foo = this.foo();
}
}
export class TableInNestedNST {
constructor(foo = 0) {
this.foo = foo;
}
pack(builder) {
return TableInNestedNS.createTableInNestedNS(builder, this.foo);
}
}

View File

@@ -1,87 +0,0 @@
// automatically generated by the FlatBuffers compiler, do not modify
import * as flatbuffers from 'flatbuffers';
export class TableInNestedNS {
bb: flatbuffers.ByteBuffer|null = null;
bb_pos = 0;
__init(i:number, bb:flatbuffers.ByteBuffer):TableInNestedNS {
this.bb_pos = i;
this.bb = bb;
return this;
}
static getRootAsTableInNestedNS(bb:flatbuffers.ByteBuffer, obj?:TableInNestedNS):TableInNestedNS {
return (obj || new TableInNestedNS()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}
static getSizePrefixedRootAsTableInNestedNS(bb:flatbuffers.ByteBuffer, obj?:TableInNestedNS):TableInNestedNS {
bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
return (obj || new TableInNestedNS()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}
foo():number {
const offset = this.bb!.__offset(this.bb_pos, 4);
return offset ? this.bb!.readInt32(this.bb_pos + offset) : 0;
}
mutate_foo(value:number):boolean {
const offset = this.bb!.__offset(this.bb_pos, 4);
if (offset === 0) {
return false;
}
this.bb!.writeInt32(this.bb_pos + offset, value);
return true;
}
static getFullyQualifiedName():string {
return 'NamespaceA.NamespaceB.TableInNestedNS';
}
static startTableInNestedNS(builder:flatbuffers.Builder) {
builder.startObject(1);
}
static addFoo(builder:flatbuffers.Builder, foo:number) {
builder.addFieldInt32(0, foo, 0);
}
static endTableInNestedNS(builder:flatbuffers.Builder):flatbuffers.Offset {
const offset = builder.endObject();
return offset;
}
static createTableInNestedNS(builder:flatbuffers.Builder, foo:number):flatbuffers.Offset {
TableInNestedNS.startTableInNestedNS(builder);
TableInNestedNS.addFoo(builder, foo);
return TableInNestedNS.endTableInNestedNS(builder);
}
unpack(): TableInNestedNST {
return new TableInNestedNST(
this.foo()
);
}
unpackTo(_o: TableInNestedNST): void {
_o.foo = this.foo();
}
}
export class TableInNestedNST {
constructor(
public foo: number = 0
){}
pack(builder:flatbuffers.Builder): flatbuffers.Offset {
return TableInNestedNS.createTableInNestedNS(builder,
this.foo
);
}
}

View File

@@ -1,21 +0,0 @@
// automatically generated by the FlatBuffers compiler, do not modify
import { TableInNestedNS } from '../../namespace-a/namespace-b/table-in-nested-n-s';
export var UnionInNestedNS;
(function (UnionInNestedNS) {
UnionInNestedNS[UnionInNestedNS["NONE"] = 0] = "NONE";
UnionInNestedNS[UnionInNestedNS["TableInNestedNS"] = 1] = "TableInNestedNS";
})(UnionInNestedNS || (UnionInNestedNS = {}));
export function unionToUnionInNestedNS(type, accessor) {
switch (UnionInNestedNS[type]) {
case 'NONE': return null;
case 'TableInNestedNS': return accessor(new TableInNestedNS());
default: return null;
}
}
export function unionListToUnionInNestedNS(type, accessor, index) {
switch (UnionInNestedNS[type]) {
case 'NONE': return null;
case 'TableInNestedNS': return accessor(index, new TableInNestedNS());
default: return null;
}
}

View File

@@ -1,33 +0,0 @@
// automatically generated by the FlatBuffers compiler, do not modify
import { TableInNestedNS, TableInNestedNST } from '../../namespace-a/namespace-b/table-in-nested-n-s';
export enum UnionInNestedNS{
NONE = 0,
TableInNestedNS = 1
}
export function unionToUnionInNestedNS(
type: UnionInNestedNS,
accessor: (obj:TableInNestedNS) => TableInNestedNS|null
): TableInNestedNS|null {
switch(UnionInNestedNS[type]) {
case 'NONE': return null;
case 'TableInNestedNS': return accessor(new TableInNestedNS())! as TableInNestedNS;
default: return null;
}
}
export function unionListToUnionInNestedNS(
type: UnionInNestedNS,
accessor: (index: number, obj:TableInNestedNS) => TableInNestedNS|null,
index: number
): TableInNestedNS|null {
switch(UnionInNestedNS[type]) {
case 'NONE': return null;
case 'TableInNestedNS': return accessor(index, new TableInNestedNS())! as TableInNestedNS;
default: return null;
}
}

View File

@@ -1,58 +0,0 @@
// automatically generated by the FlatBuffers compiler, do not modify
import * as flatbuffers from 'flatbuffers';
import { TableInC } from '../namespace-c/table-in-c';
export class SecondTableInA {
constructor() {
this.bb = null;
this.bb_pos = 0;
}
__init(i, bb) {
this.bb_pos = i;
this.bb = bb;
return this;
}
static getRootAsSecondTableInA(bb, obj) {
return (obj || new SecondTableInA()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}
static getSizePrefixedRootAsSecondTableInA(bb, obj) {
bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
return (obj || new SecondTableInA()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}
referToC(obj) {
const offset = this.bb.__offset(this.bb_pos, 4);
return offset ? (obj || new TableInC()).__init(this.bb.__indirect(this.bb_pos + offset), this.bb) : null;
}
static getFullyQualifiedName() {
return 'NamespaceA.SecondTableInA';
}
static startSecondTableInA(builder) {
builder.startObject(1);
}
static addReferToC(builder, referToCOffset) {
builder.addFieldOffset(0, referToCOffset, 0);
}
static endSecondTableInA(builder) {
const offset = builder.endObject();
return offset;
}
static createSecondTableInA(builder, referToCOffset) {
SecondTableInA.startSecondTableInA(builder);
SecondTableInA.addReferToC(builder, referToCOffset);
return SecondTableInA.endSecondTableInA(builder);
}
unpack() {
return new SecondTableInAT((this.referToC() !== null ? this.referToC().unpack() : null));
}
unpackTo(_o) {
_o.referToC = (this.referToC() !== null ? this.referToC().unpack() : null);
}
}
export class SecondTableInAT {
constructor(referToC = null) {
this.referToC = referToC;
}
pack(builder) {
const referToC = (this.referToC !== null ? this.referToC.pack(builder) : 0);
return SecondTableInA.createSecondTableInA(builder, referToC);
}
}

View File

@@ -1,79 +0,0 @@
// automatically generated by the FlatBuffers compiler, do not modify
import * as flatbuffers from 'flatbuffers';
import { TableInC, TableInCT } from '../namespace-c/table-in-c';
export class SecondTableInA {
bb: flatbuffers.ByteBuffer|null = null;
bb_pos = 0;
__init(i:number, bb:flatbuffers.ByteBuffer):SecondTableInA {
this.bb_pos = i;
this.bb = bb;
return this;
}
static getRootAsSecondTableInA(bb:flatbuffers.ByteBuffer, obj?:SecondTableInA):SecondTableInA {
return (obj || new SecondTableInA()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}
static getSizePrefixedRootAsSecondTableInA(bb:flatbuffers.ByteBuffer, obj?:SecondTableInA):SecondTableInA {
bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
return (obj || new SecondTableInA()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}
referToC(obj?:TableInC):TableInC|null {
const offset = this.bb!.__offset(this.bb_pos, 4);
return offset ? (obj || new TableInC()).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null;
}
static getFullyQualifiedName():string {
return 'NamespaceA.SecondTableInA';
}
static startSecondTableInA(builder:flatbuffers.Builder) {
builder.startObject(1);
}
static addReferToC(builder:flatbuffers.Builder, referToCOffset:flatbuffers.Offset) {
builder.addFieldOffset(0, referToCOffset, 0);
}
static endSecondTableInA(builder:flatbuffers.Builder):flatbuffers.Offset {
const offset = builder.endObject();
return offset;
}
static createSecondTableInA(builder:flatbuffers.Builder, referToCOffset:flatbuffers.Offset):flatbuffers.Offset {
SecondTableInA.startSecondTableInA(builder);
SecondTableInA.addReferToC(builder, referToCOffset);
return SecondTableInA.endSecondTableInA(builder);
}
unpack(): SecondTableInAT {
return new SecondTableInAT(
(this.referToC() !== null ? this.referToC()!.unpack() : null)
);
}
unpackTo(_o: SecondTableInAT): void {
_o.referToC = (this.referToC() !== null ? this.referToC()!.unpack() : null);
}
}
export class SecondTableInAT {
constructor(
public referToC: TableInCT|null = null
){}
pack(builder:flatbuffers.Builder): flatbuffers.Offset {
const referToC = (this.referToC !== null ? this.referToC!.pack(builder) : 0);
return SecondTableInA.createSecondTableInA(builder,
referToC
);
}
}

View File

@@ -1,119 +0,0 @@
// automatically generated by the FlatBuffers compiler, do not modify
import * as flatbuffers from 'flatbuffers';
import { EnumInNestedNS } from '../namespace-a/namespace-b/enum-in-nested-n-s';
import { StructInNestedNS } from '../namespace-a/namespace-b/struct-in-nested-n-s';
import { TableInNestedNS } from '../namespace-a/namespace-b/table-in-nested-n-s';
import { UnionInNestedNS, unionToUnionInNestedNS } from '../namespace-a/namespace-b/union-in-nested-n-s';
export class TableInFirstNS {
constructor() {
this.bb = null;
this.bb_pos = 0;
}
__init(i, bb) {
this.bb_pos = i;
this.bb = bb;
return this;
}
static getRootAsTableInFirstNS(bb, obj) {
return (obj || new TableInFirstNS()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}
static getSizePrefixedRootAsTableInFirstNS(bb, obj) {
bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
return (obj || new TableInFirstNS()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}
fooTable(obj) {
const offset = this.bb.__offset(this.bb_pos, 4);
return offset ? (obj || new TableInNestedNS()).__init(this.bb.__indirect(this.bb_pos + offset), this.bb) : null;
}
fooEnum() {
const offset = this.bb.__offset(this.bb_pos, 6);
return offset ? this.bb.readInt8(this.bb_pos + offset) : EnumInNestedNS.A;
}
mutate_foo_enum(value) {
const offset = this.bb.__offset(this.bb_pos, 6);
if (offset === 0) {
return false;
}
this.bb.writeInt8(this.bb_pos + offset, value);
return true;
}
fooUnionType() {
const offset = this.bb.__offset(this.bb_pos, 8);
return offset ? this.bb.readUint8(this.bb_pos + offset) : UnionInNestedNS.NONE;
}
fooUnion(obj) {
const offset = this.bb.__offset(this.bb_pos, 10);
return offset ? this.bb.__union(obj, this.bb_pos + offset) : null;
}
fooStruct(obj) {
const offset = this.bb.__offset(this.bb_pos, 12);
return offset ? (obj || new StructInNestedNS()).__init(this.bb_pos + offset, this.bb) : null;
}
static getFullyQualifiedName() {
return 'NamespaceA.TableInFirstNS';
}
static startTableInFirstNS(builder) {
builder.startObject(5);
}
static addFooTable(builder, fooTableOffset) {
builder.addFieldOffset(0, fooTableOffset, 0);
}
static addFooEnum(builder, fooEnum) {
builder.addFieldInt8(1, fooEnum, EnumInNestedNS.A);
}
static addFooUnionType(builder, fooUnionType) {
builder.addFieldInt8(2, fooUnionType, UnionInNestedNS.NONE);
}
static addFooUnion(builder, fooUnionOffset) {
builder.addFieldOffset(3, fooUnionOffset, 0);
}
static addFooStruct(builder, fooStructOffset) {
builder.addFieldStruct(4, fooStructOffset, 0);
}
static endTableInFirstNS(builder) {
const offset = builder.endObject();
return offset;
}
unpack() {
return new TableInFirstNST((this.fooTable() !== null ? this.fooTable().unpack() : null), this.fooEnum(), this.fooUnionType(), (() => {
let temp = unionToUnionInNestedNS(this.fooUnionType(), this.fooUnion.bind(this));
if (temp === null) {
return null;
}
return temp.unpack();
})(), (this.fooStruct() !== null ? this.fooStruct().unpack() : null));
}
unpackTo(_o) {
_o.fooTable = (this.fooTable() !== null ? this.fooTable().unpack() : null);
_o.fooEnum = this.fooEnum();
_o.fooUnionType = this.fooUnionType();
_o.fooUnion = (() => {
let temp = unionToUnionInNestedNS(this.fooUnionType(), this.fooUnion.bind(this));
if (temp === null) {
return null;
}
return temp.unpack();
})();
_o.fooStruct = (this.fooStruct() !== null ? this.fooStruct().unpack() : null);
}
}
export class TableInFirstNST {
constructor(fooTable = null, fooEnum = EnumInNestedNS.A, fooUnionType = UnionInNestedNS.NONE, fooUnion = null, fooStruct = null) {
this.fooTable = fooTable;
this.fooEnum = fooEnum;
this.fooUnionType = fooUnionType;
this.fooUnion = fooUnion;
this.fooStruct = fooStruct;
}
pack(builder) {
const fooTable = (this.fooTable !== null ? this.fooTable.pack(builder) : 0);
const fooUnion = builder.createObjectOffset(this.fooUnion);
TableInFirstNS.startTableInFirstNS(builder);
TableInFirstNS.addFooTable(builder, fooTable);
TableInFirstNS.addFooEnum(builder, this.fooEnum);
TableInFirstNS.addFooUnionType(builder, this.fooUnionType);
TableInFirstNS.addFooUnion(builder, fooUnion);
TableInFirstNS.addFooStruct(builder, (this.fooStruct !== null ? this.fooStruct.pack(builder) : 0));
return TableInFirstNS.endTableInFirstNS(builder);
}
}

View File

@@ -1,150 +0,0 @@
// automatically generated by the FlatBuffers compiler, do not modify
import * as flatbuffers from 'flatbuffers';
import { EnumInNestedNS } from '../namespace-a/namespace-b/enum-in-nested-n-s';
import { StructInNestedNS, StructInNestedNST } from '../namespace-a/namespace-b/struct-in-nested-n-s';
import { TableInNestedNS, TableInNestedNST } from '../namespace-a/namespace-b/table-in-nested-n-s';
import { UnionInNestedNS, unionToUnionInNestedNS, unionListToUnionInNestedNS } from '../namespace-a/namespace-b/union-in-nested-n-s';
export class TableInFirstNS {
bb: flatbuffers.ByteBuffer|null = null;
bb_pos = 0;
__init(i:number, bb:flatbuffers.ByteBuffer):TableInFirstNS {
this.bb_pos = i;
this.bb = bb;
return this;
}
static getRootAsTableInFirstNS(bb:flatbuffers.ByteBuffer, obj?:TableInFirstNS):TableInFirstNS {
return (obj || new TableInFirstNS()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}
static getSizePrefixedRootAsTableInFirstNS(bb:flatbuffers.ByteBuffer, obj?:TableInFirstNS):TableInFirstNS {
bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
return (obj || new TableInFirstNS()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}
fooTable(obj?:TableInNestedNS):TableInNestedNS|null {
const offset = this.bb!.__offset(this.bb_pos, 4);
return offset ? (obj || new TableInNestedNS()).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null;
}
fooEnum():EnumInNestedNS {
const offset = this.bb!.__offset(this.bb_pos, 6);
return offset ? this.bb!.readInt8(this.bb_pos + offset) : EnumInNestedNS.A;
}
mutate_foo_enum(value:EnumInNestedNS):boolean {
const offset = this.bb!.__offset(this.bb_pos, 6);
if (offset === 0) {
return false;
}
this.bb!.writeInt8(this.bb_pos + offset, value);
return true;
}
fooUnionType():UnionInNestedNS {
const offset = this.bb!.__offset(this.bb_pos, 8);
return offset ? this.bb!.readUint8(this.bb_pos + offset) : UnionInNestedNS.NONE;
}
fooUnion<T extends flatbuffers.Table>(obj:any):any|null {
const offset = this.bb!.__offset(this.bb_pos, 10);
return offset ? this.bb!.__union(obj, this.bb_pos + offset) : null;
}
fooStruct(obj?:StructInNestedNS):StructInNestedNS|null {
const offset = this.bb!.__offset(this.bb_pos, 12);
return offset ? (obj || new StructInNestedNS()).__init(this.bb_pos + offset, this.bb!) : null;
}
static getFullyQualifiedName():string {
return 'NamespaceA.TableInFirstNS';
}
static startTableInFirstNS(builder:flatbuffers.Builder) {
builder.startObject(5);
}
static addFooTable(builder:flatbuffers.Builder, fooTableOffset:flatbuffers.Offset) {
builder.addFieldOffset(0, fooTableOffset, 0);
}
static addFooEnum(builder:flatbuffers.Builder, fooEnum:EnumInNestedNS) {
builder.addFieldInt8(1, fooEnum, EnumInNestedNS.A);
}
static addFooUnionType(builder:flatbuffers.Builder, fooUnionType:UnionInNestedNS) {
builder.addFieldInt8(2, fooUnionType, UnionInNestedNS.NONE);
}
static addFooUnion(builder:flatbuffers.Builder, fooUnionOffset:flatbuffers.Offset) {
builder.addFieldOffset(3, fooUnionOffset, 0);
}
static addFooStruct(builder:flatbuffers.Builder, fooStructOffset:flatbuffers.Offset) {
builder.addFieldStruct(4, fooStructOffset, 0);
}
static endTableInFirstNS(builder:flatbuffers.Builder):flatbuffers.Offset {
const offset = builder.endObject();
return offset;
}
unpack(): TableInFirstNST {
return new TableInFirstNST(
(this.fooTable() !== null ? this.fooTable()!.unpack() : null),
this.fooEnum(),
this.fooUnionType(),
(() => {
let temp = unionToUnionInNestedNS(this.fooUnionType(), this.fooUnion.bind(this));
if(temp === null) { return null; }
return temp.unpack()
})(),
(this.fooStruct() !== null ? this.fooStruct()!.unpack() : null)
);
}
unpackTo(_o: TableInFirstNST): void {
_o.fooTable = (this.fooTable() !== null ? this.fooTable()!.unpack() : null);
_o.fooEnum = this.fooEnum();
_o.fooUnionType = this.fooUnionType();
_o.fooUnion = (() => {
let temp = unionToUnionInNestedNS(this.fooUnionType(), this.fooUnion.bind(this));
if(temp === null) { return null; }
return temp.unpack()
})();
_o.fooStruct = (this.fooStruct() !== null ? this.fooStruct()!.unpack() : null);
}
}
export class TableInFirstNST {
constructor(
public fooTable: TableInNestedNST|null = null,
public fooEnum: EnumInNestedNS = EnumInNestedNS.A,
public fooUnionType: UnionInNestedNS = UnionInNestedNS.NONE,
public fooUnion: TableInNestedNST|null = null,
public fooStruct: StructInNestedNST|null = null
){}
pack(builder:flatbuffers.Builder): flatbuffers.Offset {
const fooTable = (this.fooTable !== null ? this.fooTable!.pack(builder) : 0);
const fooUnion = builder.createObjectOffset(this.fooUnion);
TableInFirstNS.startTableInFirstNS(builder);
TableInFirstNS.addFooTable(builder, fooTable);
TableInFirstNS.addFooEnum(builder, this.fooEnum);
TableInFirstNS.addFooUnionType(builder, this.fooUnionType);
TableInFirstNS.addFooUnion(builder, fooUnion);
TableInFirstNS.addFooStruct(builder, (this.fooStruct !== null ? this.fooStruct!.pack(builder) : 0));
return TableInFirstNS.endTableInFirstNS(builder);
}
}

View File

@@ -1,67 +0,0 @@
// automatically generated by the FlatBuffers compiler, do not modify
import * as flatbuffers from 'flatbuffers';
import { SecondTableInA } from '../namespace-a/second-table-in-a';
import { TableInFirstNS } from '../namespace-a/table-in-first-n-s';
export class TableInC {
constructor() {
this.bb = null;
this.bb_pos = 0;
}
__init(i, bb) {
this.bb_pos = i;
this.bb = bb;
return this;
}
static getRootAsTableInC(bb, obj) {
return (obj || new TableInC()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}
static getSizePrefixedRootAsTableInC(bb, obj) {
bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
return (obj || new TableInC()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}
referToA1(obj) {
const offset = this.bb.__offset(this.bb_pos, 4);
return offset ? (obj || new TableInFirstNS()).__init(this.bb.__indirect(this.bb_pos + offset), this.bb) : null;
}
referToA2(obj) {
const offset = this.bb.__offset(this.bb_pos, 6);
return offset ? (obj || new SecondTableInA()).__init(this.bb.__indirect(this.bb_pos + offset), this.bb) : null;
}
static getFullyQualifiedName() {
return 'NamespaceC.TableInC';
}
static startTableInC(builder) {
builder.startObject(2);
}
static addReferToA1(builder, referToA1Offset) {
builder.addFieldOffset(0, referToA1Offset, 0);
}
static addReferToA2(builder, referToA2Offset) {
builder.addFieldOffset(1, referToA2Offset, 0);
}
static endTableInC(builder) {
const offset = builder.endObject();
return offset;
}
unpack() {
return new TableInCT((this.referToA1() !== null ? this.referToA1().unpack() : null), (this.referToA2() !== null ? this.referToA2().unpack() : null));
}
unpackTo(_o) {
_o.referToA1 = (this.referToA1() !== null ? this.referToA1().unpack() : null);
_o.referToA2 = (this.referToA2() !== null ? this.referToA2().unpack() : null);
}
}
export class TableInCT {
constructor(referToA1 = null, referToA2 = null) {
this.referToA1 = referToA1;
this.referToA2 = referToA2;
}
pack(builder) {
const referToA1 = (this.referToA1 !== null ? this.referToA1.pack(builder) : 0);
const referToA2 = (this.referToA2 !== null ? this.referToA2.pack(builder) : 0);
TableInC.startTableInC(builder);
TableInC.addReferToA1(builder, referToA1);
TableInC.addReferToA2(builder, referToA2);
return TableInC.endTableInC(builder);
}
}

View File

@@ -1,90 +0,0 @@
// automatically generated by the FlatBuffers compiler, do not modify
import * as flatbuffers from 'flatbuffers';
import { SecondTableInA, SecondTableInAT } from '../namespace-a/second-table-in-a';
import { TableInFirstNS, TableInFirstNST } from '../namespace-a/table-in-first-n-s';
export class TableInC {
bb: flatbuffers.ByteBuffer|null = null;
bb_pos = 0;
__init(i:number, bb:flatbuffers.ByteBuffer):TableInC {
this.bb_pos = i;
this.bb = bb;
return this;
}
static getRootAsTableInC(bb:flatbuffers.ByteBuffer, obj?:TableInC):TableInC {
return (obj || new TableInC()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}
static getSizePrefixedRootAsTableInC(bb:flatbuffers.ByteBuffer, obj?:TableInC):TableInC {
bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
return (obj || new TableInC()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}
referToA1(obj?:TableInFirstNS):TableInFirstNS|null {
const offset = this.bb!.__offset(this.bb_pos, 4);
return offset ? (obj || new TableInFirstNS()).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null;
}
referToA2(obj?:SecondTableInA):SecondTableInA|null {
const offset = this.bb!.__offset(this.bb_pos, 6);
return offset ? (obj || new SecondTableInA()).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null;
}
static getFullyQualifiedName():string {
return 'NamespaceC.TableInC';
}
static startTableInC(builder:flatbuffers.Builder) {
builder.startObject(2);
}
static addReferToA1(builder:flatbuffers.Builder, referToA1Offset:flatbuffers.Offset) {
builder.addFieldOffset(0, referToA1Offset, 0);
}
static addReferToA2(builder:flatbuffers.Builder, referToA2Offset:flatbuffers.Offset) {
builder.addFieldOffset(1, referToA2Offset, 0);
}
static endTableInC(builder:flatbuffers.Builder):flatbuffers.Offset {
const offset = builder.endObject();
return offset;
}
unpack(): TableInCT {
return new TableInCT(
(this.referToA1() !== null ? this.referToA1()!.unpack() : null),
(this.referToA2() !== null ? this.referToA2()!.unpack() : null)
);
}
unpackTo(_o: TableInCT): void {
_o.referToA1 = (this.referToA1() !== null ? this.referToA1()!.unpack() : null);
_o.referToA2 = (this.referToA2() !== null ? this.referToA2()!.unpack() : null);
}
}
export class TableInCT {
constructor(
public referToA1: TableInFirstNST|null = null,
public referToA2: SecondTableInAT|null = null
){}
pack(builder:flatbuffers.Builder): flatbuffers.Offset {
const referToA1 = (this.referToA1 !== null ? this.referToA1!.pack(builder) : 0);
const referToA2 = (this.referToA2 !== null ? this.referToA2!.pack(builder) : 0);
TableInC.startTableInC(builder);
TableInC.addReferToA1(builder, referToA1);
TableInC.addReferToA2(builder, referToA2);
return TableInC.endTableInC(builder);
}
}

View File

@@ -1,3 +0,0 @@
export { StructInNestedNS, StructInNestedNST } from './namespace-a/namespace-b/struct-in-nested-n-s';
export { TableInNestedNS, TableInNestedNST } from './namespace-a/namespace-b/table-in-nested-n-s';
export { UnionInNestedNS, unionToUnionInNestedNS, unionListToUnionInNestedNS } from './namespace-a/namespace-b/union-in-nested-n-s';

View File

@@ -1,7 +0,0 @@
export { EnumInNestedNS } from './namespace-a/namespace-b/enum-in-nested-n-s';
export { StructInNestedNS, StructInNestedNST } from './namespace-a/namespace-b/struct-in-nested-n-s';
export { TableInNestedNS, TableInNestedNST } from './namespace-a/namespace-b/table-in-nested-n-s';
export { UnionInNestedNS, unionToUnionInNestedNS, unionListToUnionInNestedNS } from './namespace-a/namespace-b/union-in-nested-n-s';
export { SecondTableInA, SecondTableInAT } from './namespace-a/second-table-in-a';
export { TableInFirstNS, TableInFirstNST } from './namespace-a/table-in-first-n-s';
export { TableInC, TableInCT } from './namespace-c/table-in-c';

View File

@@ -1,423 +0,0 @@
// automatically generated by the FlatBuffers compiler, do not modify
import * as flatbuffers from 'flatbuffers';
import { OptionalByte } from '../optional-scalars/optional-byte';
export class ScalarStuff {
bb: flatbuffers.ByteBuffer|null = null;
bb_pos = 0;
__init(i:number, bb:flatbuffers.ByteBuffer):ScalarStuff {
this.bb_pos = i;
this.bb = bb;
return this;
}
static getRootAsScalarStuff(bb:flatbuffers.ByteBuffer, obj?:ScalarStuff):ScalarStuff {
return (obj || new ScalarStuff()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}
static getSizePrefixedRootAsScalarStuff(bb:flatbuffers.ByteBuffer, obj?:ScalarStuff):ScalarStuff {
bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
return (obj || new ScalarStuff()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}
static bufferHasIdentifier(bb:flatbuffers.ByteBuffer):boolean {
return bb.__has_identifier('NULL');
}
justI8():number {
const offset = this.bb!.__offset(this.bb_pos, 4);
return offset ? this.bb!.readInt8(this.bb_pos + offset) : 0;
}
maybeI8():number|null {
const offset = this.bb!.__offset(this.bb_pos, 6);
return offset ? this.bb!.readInt8(this.bb_pos + offset) : null;
}
defaultI8():number {
const offset = this.bb!.__offset(this.bb_pos, 8);
return offset ? this.bb!.readInt8(this.bb_pos + offset) : 42;
}
justU8():number {
const offset = this.bb!.__offset(this.bb_pos, 10);
return offset ? this.bb!.readUint8(this.bb_pos + offset) : 0;
}
maybeU8():number|null {
const offset = this.bb!.__offset(this.bb_pos, 12);
return offset ? this.bb!.readUint8(this.bb_pos + offset) : null;
}
defaultU8():number {
const offset = this.bb!.__offset(this.bb_pos, 14);
return offset ? this.bb!.readUint8(this.bb_pos + offset) : 42;
}
justI16():number {
const offset = this.bb!.__offset(this.bb_pos, 16);
return offset ? this.bb!.readInt16(this.bb_pos + offset) : 0;
}
maybeI16():number|null {
const offset = this.bb!.__offset(this.bb_pos, 18);
return offset ? this.bb!.readInt16(this.bb_pos + offset) : null;
}
defaultI16():number {
const offset = this.bb!.__offset(this.bb_pos, 20);
return offset ? this.bb!.readInt16(this.bb_pos + offset) : 42;
}
justU16():number {
const offset = this.bb!.__offset(this.bb_pos, 22);
return offset ? this.bb!.readUint16(this.bb_pos + offset) : 0;
}
maybeU16():number|null {
const offset = this.bb!.__offset(this.bb_pos, 24);
return offset ? this.bb!.readUint16(this.bb_pos + offset) : null;
}
defaultU16():number {
const offset = this.bb!.__offset(this.bb_pos, 26);
return offset ? this.bb!.readUint16(this.bb_pos + offset) : 42;
}
justI32():number {
const offset = this.bb!.__offset(this.bb_pos, 28);
return offset ? this.bb!.readInt32(this.bb_pos + offset) : 0;
}
maybeI32():number|null {
const offset = this.bb!.__offset(this.bb_pos, 30);
return offset ? this.bb!.readInt32(this.bb_pos + offset) : null;
}
defaultI32():number {
const offset = this.bb!.__offset(this.bb_pos, 32);
return offset ? this.bb!.readInt32(this.bb_pos + offset) : 42;
}
justU32():number {
const offset = this.bb!.__offset(this.bb_pos, 34);
return offset ? this.bb!.readUint32(this.bb_pos + offset) : 0;
}
maybeU32():number|null {
const offset = this.bb!.__offset(this.bb_pos, 36);
return offset ? this.bb!.readUint32(this.bb_pos + offset) : null;
}
defaultU32():number {
const offset = this.bb!.__offset(this.bb_pos, 38);
return offset ? this.bb!.readUint32(this.bb_pos + offset) : 42;
}
justI64():bigint {
const offset = this.bb!.__offset(this.bb_pos, 40);
return offset ? this.bb!.readInt64(this.bb_pos + offset) : BigInt('0');
}
maybeI64():bigint|null {
const offset = this.bb!.__offset(this.bb_pos, 42);
return offset ? this.bb!.readInt64(this.bb_pos + offset) : null;
}
defaultI64():bigint {
const offset = this.bb!.__offset(this.bb_pos, 44);
return offset ? this.bb!.readInt64(this.bb_pos + offset) : BigInt('42');
}
justU64():bigint {
const offset = this.bb!.__offset(this.bb_pos, 46);
return offset ? this.bb!.readUint64(this.bb_pos + offset) : BigInt('0');
}
maybeU64():bigint|null {
const offset = this.bb!.__offset(this.bb_pos, 48);
return offset ? this.bb!.readUint64(this.bb_pos + offset) : null;
}
defaultU64():bigint {
const offset = this.bb!.__offset(this.bb_pos, 50);
return offset ? this.bb!.readUint64(this.bb_pos + offset) : BigInt('42');
}
justF32():number {
const offset = this.bb!.__offset(this.bb_pos, 52);
return offset ? this.bb!.readFloat32(this.bb_pos + offset) : 0.0;
}
maybeF32():number|null {
const offset = this.bb!.__offset(this.bb_pos, 54);
return offset ? this.bb!.readFloat32(this.bb_pos + offset) : null;
}
defaultF32():number {
const offset = this.bb!.__offset(this.bb_pos, 56);
return offset ? this.bb!.readFloat32(this.bb_pos + offset) : 42.0;
}
justF64():number {
const offset = this.bb!.__offset(this.bb_pos, 58);
return offset ? this.bb!.readFloat64(this.bb_pos + offset) : 0.0;
}
maybeF64():number|null {
const offset = this.bb!.__offset(this.bb_pos, 60);
return offset ? this.bb!.readFloat64(this.bb_pos + offset) : null;
}
defaultF64():number {
const offset = this.bb!.__offset(this.bb_pos, 62);
return offset ? this.bb!.readFloat64(this.bb_pos + offset) : 42.0;
}
justBool():boolean {
const offset = this.bb!.__offset(this.bb_pos, 64);
return offset ? !!this.bb!.readInt8(this.bb_pos + offset) : false;
}
maybeBool():boolean|null {
const offset = this.bb!.__offset(this.bb_pos, 66);
return offset ? !!this.bb!.readInt8(this.bb_pos + offset) : null;
}
defaultBool():boolean {
const offset = this.bb!.__offset(this.bb_pos, 68);
return offset ? !!this.bb!.readInt8(this.bb_pos + offset) : true;
}
justEnum():OptionalByte {
const offset = this.bb!.__offset(this.bb_pos, 70);
return offset ? this.bb!.readInt8(this.bb_pos + offset) : OptionalByte.None;
}
maybeEnum():OptionalByte|null {
const offset = this.bb!.__offset(this.bb_pos, 72);
return offset ? this.bb!.readInt8(this.bb_pos + offset) : null;
}
defaultEnum():OptionalByte {
const offset = this.bb!.__offset(this.bb_pos, 74);
return offset ? this.bb!.readInt8(this.bb_pos + offset) : OptionalByte.One;
}
static startScalarStuff(builder:flatbuffers.Builder) {
builder.startObject(36);
}
static addJustI8(builder:flatbuffers.Builder, justI8:number) {
builder.addFieldInt8(0, justI8, 0);
}
static addMaybeI8(builder:flatbuffers.Builder, maybeI8:number) {
builder.addFieldInt8(1, maybeI8, 0);
}
static addDefaultI8(builder:flatbuffers.Builder, defaultI8:number) {
builder.addFieldInt8(2, defaultI8, 42);
}
static addJustU8(builder:flatbuffers.Builder, justU8:number) {
builder.addFieldInt8(3, justU8, 0);
}
static addMaybeU8(builder:flatbuffers.Builder, maybeU8:number) {
builder.addFieldInt8(4, maybeU8, 0);
}
static addDefaultU8(builder:flatbuffers.Builder, defaultU8:number) {
builder.addFieldInt8(5, defaultU8, 42);
}
static addJustI16(builder:flatbuffers.Builder, justI16:number) {
builder.addFieldInt16(6, justI16, 0);
}
static addMaybeI16(builder:flatbuffers.Builder, maybeI16:number) {
builder.addFieldInt16(7, maybeI16, 0);
}
static addDefaultI16(builder:flatbuffers.Builder, defaultI16:number) {
builder.addFieldInt16(8, defaultI16, 42);
}
static addJustU16(builder:flatbuffers.Builder, justU16:number) {
builder.addFieldInt16(9, justU16, 0);
}
static addMaybeU16(builder:flatbuffers.Builder, maybeU16:number) {
builder.addFieldInt16(10, maybeU16, 0);
}
static addDefaultU16(builder:flatbuffers.Builder, defaultU16:number) {
builder.addFieldInt16(11, defaultU16, 42);
}
static addJustI32(builder:flatbuffers.Builder, justI32:number) {
builder.addFieldInt32(12, justI32, 0);
}
static addMaybeI32(builder:flatbuffers.Builder, maybeI32:number) {
builder.addFieldInt32(13, maybeI32, 0);
}
static addDefaultI32(builder:flatbuffers.Builder, defaultI32:number) {
builder.addFieldInt32(14, defaultI32, 42);
}
static addJustU32(builder:flatbuffers.Builder, justU32:number) {
builder.addFieldInt32(15, justU32, 0);
}
static addMaybeU32(builder:flatbuffers.Builder, maybeU32:number) {
builder.addFieldInt32(16, maybeU32, 0);
}
static addDefaultU32(builder:flatbuffers.Builder, defaultU32:number) {
builder.addFieldInt32(17, defaultU32, 42);
}
static addJustI64(builder:flatbuffers.Builder, justI64:bigint) {
builder.addFieldInt64(18, justI64, BigInt('0'));
}
static addMaybeI64(builder:flatbuffers.Builder, maybeI64:bigint) {
builder.addFieldInt64(19, maybeI64, BigInt(0));
}
static addDefaultI64(builder:flatbuffers.Builder, defaultI64:bigint) {
builder.addFieldInt64(20, defaultI64, BigInt('42'));
}
static addJustU64(builder:flatbuffers.Builder, justU64:bigint) {
builder.addFieldInt64(21, justU64, BigInt('0'));
}
static addMaybeU64(builder:flatbuffers.Builder, maybeU64:bigint) {
builder.addFieldInt64(22, maybeU64, BigInt(0));
}
static addDefaultU64(builder:flatbuffers.Builder, defaultU64:bigint) {
builder.addFieldInt64(23, defaultU64, BigInt('42'));
}
static addJustF32(builder:flatbuffers.Builder, justF32:number) {
builder.addFieldFloat32(24, justF32, 0.0);
}
static addMaybeF32(builder:flatbuffers.Builder, maybeF32:number) {
builder.addFieldFloat32(25, maybeF32, 0);
}
static addDefaultF32(builder:flatbuffers.Builder, defaultF32:number) {
builder.addFieldFloat32(26, defaultF32, 42.0);
}
static addJustF64(builder:flatbuffers.Builder, justF64:number) {
builder.addFieldFloat64(27, justF64, 0.0);
}
static addMaybeF64(builder:flatbuffers.Builder, maybeF64:number) {
builder.addFieldFloat64(28, maybeF64, 0);
}
static addDefaultF64(builder:flatbuffers.Builder, defaultF64:number) {
builder.addFieldFloat64(29, defaultF64, 42.0);
}
static addJustBool(builder:flatbuffers.Builder, justBool:boolean) {
builder.addFieldInt8(30, +justBool, +false);
}
static addMaybeBool(builder:flatbuffers.Builder, maybeBool:boolean) {
builder.addFieldInt8(31, +maybeBool, 0);
}
static addDefaultBool(builder:flatbuffers.Builder, defaultBool:boolean) {
builder.addFieldInt8(32, +defaultBool, +true);
}
static addJustEnum(builder:flatbuffers.Builder, justEnum:OptionalByte) {
builder.addFieldInt8(33, justEnum, OptionalByte.None);
}
static addMaybeEnum(builder:flatbuffers.Builder, maybeEnum:OptionalByte) {
builder.addFieldInt8(34, maybeEnum, 0);
}
static addDefaultEnum(builder:flatbuffers.Builder, defaultEnum:OptionalByte) {
builder.addFieldInt8(35, defaultEnum, OptionalByte.One);
}
static endScalarStuff(builder:flatbuffers.Builder):flatbuffers.Offset {
const offset = builder.endObject();
return offset;
}
static finishScalarStuffBuffer(builder:flatbuffers.Builder, offset:flatbuffers.Offset) {
builder.finish(offset, 'NULL');
}
static finishSizePrefixedScalarStuffBuffer(builder:flatbuffers.Builder, offset:flatbuffers.Offset) {
builder.finish(offset, 'NULL', true);
}
static createScalarStuff(builder:flatbuffers.Builder, justI8:number, maybeI8:number|null, defaultI8:number, justU8:number, maybeU8:number|null, defaultU8:number, justI16:number, maybeI16:number|null, defaultI16:number, justU16:number, maybeU16:number|null, defaultU16:number, justI32:number, maybeI32:number|null, defaultI32:number, justU32:number, maybeU32:number|null, defaultU32:number, justI64:bigint, maybeI64:bigint|null, defaultI64:bigint, justU64:bigint, maybeU64:bigint|null, defaultU64:bigint, justF32:number, maybeF32:number|null, defaultF32:number, justF64:number, maybeF64:number|null, defaultF64:number, justBool:boolean, maybeBool:boolean|null, defaultBool:boolean, justEnum:OptionalByte, maybeEnum:OptionalByte|null, defaultEnum:OptionalByte):flatbuffers.Offset {
ScalarStuff.startScalarStuff(builder);
ScalarStuff.addJustI8(builder, justI8);
if (maybeI8 !== null)
ScalarStuff.addMaybeI8(builder, maybeI8);
ScalarStuff.addDefaultI8(builder, defaultI8);
ScalarStuff.addJustU8(builder, justU8);
if (maybeU8 !== null)
ScalarStuff.addMaybeU8(builder, maybeU8);
ScalarStuff.addDefaultU8(builder, defaultU8);
ScalarStuff.addJustI16(builder, justI16);
if (maybeI16 !== null)
ScalarStuff.addMaybeI16(builder, maybeI16);
ScalarStuff.addDefaultI16(builder, defaultI16);
ScalarStuff.addJustU16(builder, justU16);
if (maybeU16 !== null)
ScalarStuff.addMaybeU16(builder, maybeU16);
ScalarStuff.addDefaultU16(builder, defaultU16);
ScalarStuff.addJustI32(builder, justI32);
if (maybeI32 !== null)
ScalarStuff.addMaybeI32(builder, maybeI32);
ScalarStuff.addDefaultI32(builder, defaultI32);
ScalarStuff.addJustU32(builder, justU32);
if (maybeU32 !== null)
ScalarStuff.addMaybeU32(builder, maybeU32);
ScalarStuff.addDefaultU32(builder, defaultU32);
ScalarStuff.addJustI64(builder, justI64);
if (maybeI64 !== null)
ScalarStuff.addMaybeI64(builder, maybeI64);
ScalarStuff.addDefaultI64(builder, defaultI64);
ScalarStuff.addJustU64(builder, justU64);
if (maybeU64 !== null)
ScalarStuff.addMaybeU64(builder, maybeU64);
ScalarStuff.addDefaultU64(builder, defaultU64);
ScalarStuff.addJustF32(builder, justF32);
if (maybeF32 !== null)
ScalarStuff.addMaybeF32(builder, maybeF32);
ScalarStuff.addDefaultF32(builder, defaultF32);
ScalarStuff.addJustF64(builder, justF64);
if (maybeF64 !== null)
ScalarStuff.addMaybeF64(builder, maybeF64);
ScalarStuff.addDefaultF64(builder, defaultF64);
ScalarStuff.addJustBool(builder, justBool);
if (maybeBool !== null)
ScalarStuff.addMaybeBool(builder, maybeBool);
ScalarStuff.addDefaultBool(builder, defaultBool);
ScalarStuff.addJustEnum(builder, justEnum);
if (maybeEnum !== null)
ScalarStuff.addMaybeEnum(builder, maybeEnum);
ScalarStuff.addDefaultEnum(builder, defaultEnum);
return ScalarStuff.endScalarStuff(builder);
}
}

View File

@@ -1,7 +0,0 @@
// automatically generated by the FlatBuffers compiler, do not modify
export var OptionalByte;
(function (OptionalByte) {
OptionalByte[OptionalByte["None"] = 0] = "None";
OptionalByte[OptionalByte["One"] = 1] = "One";
OptionalByte[OptionalByte["Two"] = 2] = "Two";
})(OptionalByte || (OptionalByte = {}));

View File

@@ -1,8 +0,0 @@
// automatically generated by the FlatBuffers compiler, do not modify
export enum OptionalByte{
None = 0,
One = 1,
Two = 2
}

View File

@@ -1,341 +0,0 @@
// automatically generated by the FlatBuffers compiler, do not modify
import * as flatbuffers from 'flatbuffers';
import { OptionalByte } from '../optional_scalars/optional-byte';
export class ScalarStuff {
constructor() {
this.bb = null;
this.bb_pos = 0;
}
__init(i, bb) {
this.bb_pos = i;
this.bb = bb;
return this;
}
static getRootAsScalarStuff(bb, obj) {
return (obj || new ScalarStuff()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}
static getSizePrefixedRootAsScalarStuff(bb, obj) {
bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
return (obj || new ScalarStuff()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}
static bufferHasIdentifier(bb) {
return bb.__has_identifier('NULL');
}
justI8() {
const offset = this.bb.__offset(this.bb_pos, 4);
return offset ? this.bb.readInt8(this.bb_pos + offset) : 0;
}
maybeI8() {
const offset = this.bb.__offset(this.bb_pos, 6);
return offset ? this.bb.readInt8(this.bb_pos + offset) : null;
}
defaultI8() {
const offset = this.bb.__offset(this.bb_pos, 8);
return offset ? this.bb.readInt8(this.bb_pos + offset) : 42;
}
justU8() {
const offset = this.bb.__offset(this.bb_pos, 10);
return offset ? this.bb.readUint8(this.bb_pos + offset) : 0;
}
maybeU8() {
const offset = this.bb.__offset(this.bb_pos, 12);
return offset ? this.bb.readUint8(this.bb_pos + offset) : null;
}
defaultU8() {
const offset = this.bb.__offset(this.bb_pos, 14);
return offset ? this.bb.readUint8(this.bb_pos + offset) : 42;
}
justI16() {
const offset = this.bb.__offset(this.bb_pos, 16);
return offset ? this.bb.readInt16(this.bb_pos + offset) : 0;
}
maybeI16() {
const offset = this.bb.__offset(this.bb_pos, 18);
return offset ? this.bb.readInt16(this.bb_pos + offset) : null;
}
defaultI16() {
const offset = this.bb.__offset(this.bb_pos, 20);
return offset ? this.bb.readInt16(this.bb_pos + offset) : 42;
}
justU16() {
const offset = this.bb.__offset(this.bb_pos, 22);
return offset ? this.bb.readUint16(this.bb_pos + offset) : 0;
}
maybeU16() {
const offset = this.bb.__offset(this.bb_pos, 24);
return offset ? this.bb.readUint16(this.bb_pos + offset) : null;
}
defaultU16() {
const offset = this.bb.__offset(this.bb_pos, 26);
return offset ? this.bb.readUint16(this.bb_pos + offset) : 42;
}
justI32() {
const offset = this.bb.__offset(this.bb_pos, 28);
return offset ? this.bb.readInt32(this.bb_pos + offset) : 0;
}
maybeI32() {
const offset = this.bb.__offset(this.bb_pos, 30);
return offset ? this.bb.readInt32(this.bb_pos + offset) : null;
}
defaultI32() {
const offset = this.bb.__offset(this.bb_pos, 32);
return offset ? this.bb.readInt32(this.bb_pos + offset) : 42;
}
justU32() {
const offset = this.bb.__offset(this.bb_pos, 34);
return offset ? this.bb.readUint32(this.bb_pos + offset) : 0;
}
maybeU32() {
const offset = this.bb.__offset(this.bb_pos, 36);
return offset ? this.bb.readUint32(this.bb_pos + offset) : null;
}
defaultU32() {
const offset = this.bb.__offset(this.bb_pos, 38);
return offset ? this.bb.readUint32(this.bb_pos + offset) : 42;
}
justI64() {
const offset = this.bb.__offset(this.bb_pos, 40);
return offset ? this.bb.readInt64(this.bb_pos + offset) : BigInt('0');
}
maybeI64() {
const offset = this.bb.__offset(this.bb_pos, 42);
return offset ? this.bb.readInt64(this.bb_pos + offset) : null;
}
defaultI64() {
const offset = this.bb.__offset(this.bb_pos, 44);
return offset ? this.bb.readInt64(this.bb_pos + offset) : BigInt('42');
}
justU64() {
const offset = this.bb.__offset(this.bb_pos, 46);
return offset ? this.bb.readUint64(this.bb_pos + offset) : BigInt('0');
}
maybeU64() {
const offset = this.bb.__offset(this.bb_pos, 48);
return offset ? this.bb.readUint64(this.bb_pos + offset) : null;
}
defaultU64() {
const offset = this.bb.__offset(this.bb_pos, 50);
return offset ? this.bb.readUint64(this.bb_pos + offset) : BigInt('42');
}
justF32() {
const offset = this.bb.__offset(this.bb_pos, 52);
return offset ? this.bb.readFloat32(this.bb_pos + offset) : 0.0;
}
maybeF32() {
const offset = this.bb.__offset(this.bb_pos, 54);
return offset ? this.bb.readFloat32(this.bb_pos + offset) : null;
}
defaultF32() {
const offset = this.bb.__offset(this.bb_pos, 56);
return offset ? this.bb.readFloat32(this.bb_pos + offset) : 42.0;
}
justF64() {
const offset = this.bb.__offset(this.bb_pos, 58);
return offset ? this.bb.readFloat64(this.bb_pos + offset) : 0.0;
}
maybeF64() {
const offset = this.bb.__offset(this.bb_pos, 60);
return offset ? this.bb.readFloat64(this.bb_pos + offset) : null;
}
defaultF64() {
const offset = this.bb.__offset(this.bb_pos, 62);
return offset ? this.bb.readFloat64(this.bb_pos + offset) : 42.0;
}
justBool() {
const offset = this.bb.__offset(this.bb_pos, 64);
return offset ? !!this.bb.readInt8(this.bb_pos + offset) : false;
}
maybeBool() {
const offset = this.bb.__offset(this.bb_pos, 66);
return offset ? !!this.bb.readInt8(this.bb_pos + offset) : null;
}
defaultBool() {
const offset = this.bb.__offset(this.bb_pos, 68);
return offset ? !!this.bb.readInt8(this.bb_pos + offset) : true;
}
justEnum() {
const offset = this.bb.__offset(this.bb_pos, 70);
return offset ? this.bb.readInt8(this.bb_pos + offset) : OptionalByte.None;
}
maybeEnum() {
const offset = this.bb.__offset(this.bb_pos, 72);
return offset ? this.bb.readInt8(this.bb_pos + offset) : null;
}
defaultEnum() {
const offset = this.bb.__offset(this.bb_pos, 74);
return offset ? this.bb.readInt8(this.bb_pos + offset) : OptionalByte.One;
}
static startScalarStuff(builder) {
builder.startObject(36);
}
static addJustI8(builder, justI8) {
builder.addFieldInt8(0, justI8, 0);
}
static addMaybeI8(builder, maybeI8) {
builder.addFieldInt8(1, maybeI8, 0);
}
static addDefaultI8(builder, defaultI8) {
builder.addFieldInt8(2, defaultI8, 42);
}
static addJustU8(builder, justU8) {
builder.addFieldInt8(3, justU8, 0);
}
static addMaybeU8(builder, maybeU8) {
builder.addFieldInt8(4, maybeU8, 0);
}
static addDefaultU8(builder, defaultU8) {
builder.addFieldInt8(5, defaultU8, 42);
}
static addJustI16(builder, justI16) {
builder.addFieldInt16(6, justI16, 0);
}
static addMaybeI16(builder, maybeI16) {
builder.addFieldInt16(7, maybeI16, 0);
}
static addDefaultI16(builder, defaultI16) {
builder.addFieldInt16(8, defaultI16, 42);
}
static addJustU16(builder, justU16) {
builder.addFieldInt16(9, justU16, 0);
}
static addMaybeU16(builder, maybeU16) {
builder.addFieldInt16(10, maybeU16, 0);
}
static addDefaultU16(builder, defaultU16) {
builder.addFieldInt16(11, defaultU16, 42);
}
static addJustI32(builder, justI32) {
builder.addFieldInt32(12, justI32, 0);
}
static addMaybeI32(builder, maybeI32) {
builder.addFieldInt32(13, maybeI32, 0);
}
static addDefaultI32(builder, defaultI32) {
builder.addFieldInt32(14, defaultI32, 42);
}
static addJustU32(builder, justU32) {
builder.addFieldInt32(15, justU32, 0);
}
static addMaybeU32(builder, maybeU32) {
builder.addFieldInt32(16, maybeU32, 0);
}
static addDefaultU32(builder, defaultU32) {
builder.addFieldInt32(17, defaultU32, 42);
}
static addJustI64(builder, justI64) {
builder.addFieldInt64(18, justI64, BigInt('0'));
}
static addMaybeI64(builder, maybeI64) {
builder.addFieldInt64(19, maybeI64, BigInt(0));
}
static addDefaultI64(builder, defaultI64) {
builder.addFieldInt64(20, defaultI64, BigInt('42'));
}
static addJustU64(builder, justU64) {
builder.addFieldInt64(21, justU64, BigInt('0'));
}
static addMaybeU64(builder, maybeU64) {
builder.addFieldInt64(22, maybeU64, BigInt(0));
}
static addDefaultU64(builder, defaultU64) {
builder.addFieldInt64(23, defaultU64, BigInt('42'));
}
static addJustF32(builder, justF32) {
builder.addFieldFloat32(24, justF32, 0.0);
}
static addMaybeF32(builder, maybeF32) {
builder.addFieldFloat32(25, maybeF32, 0);
}
static addDefaultF32(builder, defaultF32) {
builder.addFieldFloat32(26, defaultF32, 42.0);
}
static addJustF64(builder, justF64) {
builder.addFieldFloat64(27, justF64, 0.0);
}
static addMaybeF64(builder, maybeF64) {
builder.addFieldFloat64(28, maybeF64, 0);
}
static addDefaultF64(builder, defaultF64) {
builder.addFieldFloat64(29, defaultF64, 42.0);
}
static addJustBool(builder, justBool) {
builder.addFieldInt8(30, +justBool, +false);
}
static addMaybeBool(builder, maybeBool) {
builder.addFieldInt8(31, +maybeBool, 0);
}
static addDefaultBool(builder, defaultBool) {
builder.addFieldInt8(32, +defaultBool, +true);
}
static addJustEnum(builder, justEnum) {
builder.addFieldInt8(33, justEnum, OptionalByte.None);
}
static addMaybeEnum(builder, maybeEnum) {
builder.addFieldInt8(34, maybeEnum, 0);
}
static addDefaultEnum(builder, defaultEnum) {
builder.addFieldInt8(35, defaultEnum, OptionalByte.One);
}
static endScalarStuff(builder) {
const offset = builder.endObject();
return offset;
}
static finishScalarStuffBuffer(builder, offset) {
builder.finish(offset, 'NULL');
}
static finishSizePrefixedScalarStuffBuffer(builder, offset) {
builder.finish(offset, 'NULL', true);
}
static createScalarStuff(builder, justI8, maybeI8, defaultI8, justU8, maybeU8, defaultU8, justI16, maybeI16, defaultI16, justU16, maybeU16, defaultU16, justI32, maybeI32, defaultI32, justU32, maybeU32, defaultU32, justI64, maybeI64, defaultI64, justU64, maybeU64, defaultU64, justF32, maybeF32, defaultF32, justF64, maybeF64, defaultF64, justBool, maybeBool, defaultBool, justEnum, maybeEnum, defaultEnum) {
ScalarStuff.startScalarStuff(builder);
ScalarStuff.addJustI8(builder, justI8);
if (maybeI8 !== null)
ScalarStuff.addMaybeI8(builder, maybeI8);
ScalarStuff.addDefaultI8(builder, defaultI8);
ScalarStuff.addJustU8(builder, justU8);
if (maybeU8 !== null)
ScalarStuff.addMaybeU8(builder, maybeU8);
ScalarStuff.addDefaultU8(builder, defaultU8);
ScalarStuff.addJustI16(builder, justI16);
if (maybeI16 !== null)
ScalarStuff.addMaybeI16(builder, maybeI16);
ScalarStuff.addDefaultI16(builder, defaultI16);
ScalarStuff.addJustU16(builder, justU16);
if (maybeU16 !== null)
ScalarStuff.addMaybeU16(builder, maybeU16);
ScalarStuff.addDefaultU16(builder, defaultU16);
ScalarStuff.addJustI32(builder, justI32);
if (maybeI32 !== null)
ScalarStuff.addMaybeI32(builder, maybeI32);
ScalarStuff.addDefaultI32(builder, defaultI32);
ScalarStuff.addJustU32(builder, justU32);
if (maybeU32 !== null)
ScalarStuff.addMaybeU32(builder, maybeU32);
ScalarStuff.addDefaultU32(builder, defaultU32);
ScalarStuff.addJustI64(builder, justI64);
if (maybeI64 !== null)
ScalarStuff.addMaybeI64(builder, maybeI64);
ScalarStuff.addDefaultI64(builder, defaultI64);
ScalarStuff.addJustU64(builder, justU64);
if (maybeU64 !== null)
ScalarStuff.addMaybeU64(builder, maybeU64);
ScalarStuff.addDefaultU64(builder, defaultU64);
ScalarStuff.addJustF32(builder, justF32);
if (maybeF32 !== null)
ScalarStuff.addMaybeF32(builder, maybeF32);
ScalarStuff.addDefaultF32(builder, defaultF32);
ScalarStuff.addJustF64(builder, justF64);
if (maybeF64 !== null)
ScalarStuff.addMaybeF64(builder, maybeF64);
ScalarStuff.addDefaultF64(builder, defaultF64);
ScalarStuff.addJustBool(builder, justBool);
if (maybeBool !== null)
ScalarStuff.addMaybeBool(builder, maybeBool);
ScalarStuff.addDefaultBool(builder, defaultBool);
ScalarStuff.addJustEnum(builder, justEnum);
if (maybeEnum !== null)
ScalarStuff.addMaybeEnum(builder, maybeEnum);
ScalarStuff.addDefaultEnum(builder, defaultEnum);
return ScalarStuff.endScalarStuff(builder);
}
}

View File

@@ -1,423 +0,0 @@
// automatically generated by the FlatBuffers compiler, do not modify
import * as flatbuffers from 'flatbuffers';
import { OptionalByte } from '../optional_scalars/optional-byte';
export class ScalarStuff {
bb: flatbuffers.ByteBuffer|null = null;
bb_pos = 0;
__init(i:number, bb:flatbuffers.ByteBuffer):ScalarStuff {
this.bb_pos = i;
this.bb = bb;
return this;
}
static getRootAsScalarStuff(bb:flatbuffers.ByteBuffer, obj?:ScalarStuff):ScalarStuff {
return (obj || new ScalarStuff()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}
static getSizePrefixedRootAsScalarStuff(bb:flatbuffers.ByteBuffer, obj?:ScalarStuff):ScalarStuff {
bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
return (obj || new ScalarStuff()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}
static bufferHasIdentifier(bb:flatbuffers.ByteBuffer):boolean {
return bb.__has_identifier('NULL');
}
justI8():number {
const offset = this.bb!.__offset(this.bb_pos, 4);
return offset ? this.bb!.readInt8(this.bb_pos + offset) : 0;
}
maybeI8():number|null {
const offset = this.bb!.__offset(this.bb_pos, 6);
return offset ? this.bb!.readInt8(this.bb_pos + offset) : null;
}
defaultI8():number {
const offset = this.bb!.__offset(this.bb_pos, 8);
return offset ? this.bb!.readInt8(this.bb_pos + offset) : 42;
}
justU8():number {
const offset = this.bb!.__offset(this.bb_pos, 10);
return offset ? this.bb!.readUint8(this.bb_pos + offset) : 0;
}
maybeU8():number|null {
const offset = this.bb!.__offset(this.bb_pos, 12);
return offset ? this.bb!.readUint8(this.bb_pos + offset) : null;
}
defaultU8():number {
const offset = this.bb!.__offset(this.bb_pos, 14);
return offset ? this.bb!.readUint8(this.bb_pos + offset) : 42;
}
justI16():number {
const offset = this.bb!.__offset(this.bb_pos, 16);
return offset ? this.bb!.readInt16(this.bb_pos + offset) : 0;
}
maybeI16():number|null {
const offset = this.bb!.__offset(this.bb_pos, 18);
return offset ? this.bb!.readInt16(this.bb_pos + offset) : null;
}
defaultI16():number {
const offset = this.bb!.__offset(this.bb_pos, 20);
return offset ? this.bb!.readInt16(this.bb_pos + offset) : 42;
}
justU16():number {
const offset = this.bb!.__offset(this.bb_pos, 22);
return offset ? this.bb!.readUint16(this.bb_pos + offset) : 0;
}
maybeU16():number|null {
const offset = this.bb!.__offset(this.bb_pos, 24);
return offset ? this.bb!.readUint16(this.bb_pos + offset) : null;
}
defaultU16():number {
const offset = this.bb!.__offset(this.bb_pos, 26);
return offset ? this.bb!.readUint16(this.bb_pos + offset) : 42;
}
justI32():number {
const offset = this.bb!.__offset(this.bb_pos, 28);
return offset ? this.bb!.readInt32(this.bb_pos + offset) : 0;
}
maybeI32():number|null {
const offset = this.bb!.__offset(this.bb_pos, 30);
return offset ? this.bb!.readInt32(this.bb_pos + offset) : null;
}
defaultI32():number {
const offset = this.bb!.__offset(this.bb_pos, 32);
return offset ? this.bb!.readInt32(this.bb_pos + offset) : 42;
}
justU32():number {
const offset = this.bb!.__offset(this.bb_pos, 34);
return offset ? this.bb!.readUint32(this.bb_pos + offset) : 0;
}
maybeU32():number|null {
const offset = this.bb!.__offset(this.bb_pos, 36);
return offset ? this.bb!.readUint32(this.bb_pos + offset) : null;
}
defaultU32():number {
const offset = this.bb!.__offset(this.bb_pos, 38);
return offset ? this.bb!.readUint32(this.bb_pos + offset) : 42;
}
justI64():bigint {
const offset = this.bb!.__offset(this.bb_pos, 40);
return offset ? this.bb!.readInt64(this.bb_pos + offset) : BigInt('0');
}
maybeI64():bigint|null {
const offset = this.bb!.__offset(this.bb_pos, 42);
return offset ? this.bb!.readInt64(this.bb_pos + offset) : null;
}
defaultI64():bigint {
const offset = this.bb!.__offset(this.bb_pos, 44);
return offset ? this.bb!.readInt64(this.bb_pos + offset) : BigInt('42');
}
justU64():bigint {
const offset = this.bb!.__offset(this.bb_pos, 46);
return offset ? this.bb!.readUint64(this.bb_pos + offset) : BigInt('0');
}
maybeU64():bigint|null {
const offset = this.bb!.__offset(this.bb_pos, 48);
return offset ? this.bb!.readUint64(this.bb_pos + offset) : null;
}
defaultU64():bigint {
const offset = this.bb!.__offset(this.bb_pos, 50);
return offset ? this.bb!.readUint64(this.bb_pos + offset) : BigInt('42');
}
justF32():number {
const offset = this.bb!.__offset(this.bb_pos, 52);
return offset ? this.bb!.readFloat32(this.bb_pos + offset) : 0.0;
}
maybeF32():number|null {
const offset = this.bb!.__offset(this.bb_pos, 54);
return offset ? this.bb!.readFloat32(this.bb_pos + offset) : null;
}
defaultF32():number {
const offset = this.bb!.__offset(this.bb_pos, 56);
return offset ? this.bb!.readFloat32(this.bb_pos + offset) : 42.0;
}
justF64():number {
const offset = this.bb!.__offset(this.bb_pos, 58);
return offset ? this.bb!.readFloat64(this.bb_pos + offset) : 0.0;
}
maybeF64():number|null {
const offset = this.bb!.__offset(this.bb_pos, 60);
return offset ? this.bb!.readFloat64(this.bb_pos + offset) : null;
}
defaultF64():number {
const offset = this.bb!.__offset(this.bb_pos, 62);
return offset ? this.bb!.readFloat64(this.bb_pos + offset) : 42.0;
}
justBool():boolean {
const offset = this.bb!.__offset(this.bb_pos, 64);
return offset ? !!this.bb!.readInt8(this.bb_pos + offset) : false;
}
maybeBool():boolean|null {
const offset = this.bb!.__offset(this.bb_pos, 66);
return offset ? !!this.bb!.readInt8(this.bb_pos + offset) : null;
}
defaultBool():boolean {
const offset = this.bb!.__offset(this.bb_pos, 68);
return offset ? !!this.bb!.readInt8(this.bb_pos + offset) : true;
}
justEnum():OptionalByte {
const offset = this.bb!.__offset(this.bb_pos, 70);
return offset ? this.bb!.readInt8(this.bb_pos + offset) : OptionalByte.None;
}
maybeEnum():OptionalByte|null {
const offset = this.bb!.__offset(this.bb_pos, 72);
return offset ? this.bb!.readInt8(this.bb_pos + offset) : null;
}
defaultEnum():OptionalByte {
const offset = this.bb!.__offset(this.bb_pos, 74);
return offset ? this.bb!.readInt8(this.bb_pos + offset) : OptionalByte.One;
}
static startScalarStuff(builder:flatbuffers.Builder) {
builder.startObject(36);
}
static addJustI8(builder:flatbuffers.Builder, justI8:number) {
builder.addFieldInt8(0, justI8, 0);
}
static addMaybeI8(builder:flatbuffers.Builder, maybeI8:number) {
builder.addFieldInt8(1, maybeI8, 0);
}
static addDefaultI8(builder:flatbuffers.Builder, defaultI8:number) {
builder.addFieldInt8(2, defaultI8, 42);
}
static addJustU8(builder:flatbuffers.Builder, justU8:number) {
builder.addFieldInt8(3, justU8, 0);
}
static addMaybeU8(builder:flatbuffers.Builder, maybeU8:number) {
builder.addFieldInt8(4, maybeU8, 0);
}
static addDefaultU8(builder:flatbuffers.Builder, defaultU8:number) {
builder.addFieldInt8(5, defaultU8, 42);
}
static addJustI16(builder:flatbuffers.Builder, justI16:number) {
builder.addFieldInt16(6, justI16, 0);
}
static addMaybeI16(builder:flatbuffers.Builder, maybeI16:number) {
builder.addFieldInt16(7, maybeI16, 0);
}
static addDefaultI16(builder:flatbuffers.Builder, defaultI16:number) {
builder.addFieldInt16(8, defaultI16, 42);
}
static addJustU16(builder:flatbuffers.Builder, justU16:number) {
builder.addFieldInt16(9, justU16, 0);
}
static addMaybeU16(builder:flatbuffers.Builder, maybeU16:number) {
builder.addFieldInt16(10, maybeU16, 0);
}
static addDefaultU16(builder:flatbuffers.Builder, defaultU16:number) {
builder.addFieldInt16(11, defaultU16, 42);
}
static addJustI32(builder:flatbuffers.Builder, justI32:number) {
builder.addFieldInt32(12, justI32, 0);
}
static addMaybeI32(builder:flatbuffers.Builder, maybeI32:number) {
builder.addFieldInt32(13, maybeI32, 0);
}
static addDefaultI32(builder:flatbuffers.Builder, defaultI32:number) {
builder.addFieldInt32(14, defaultI32, 42);
}
static addJustU32(builder:flatbuffers.Builder, justU32:number) {
builder.addFieldInt32(15, justU32, 0);
}
static addMaybeU32(builder:flatbuffers.Builder, maybeU32:number) {
builder.addFieldInt32(16, maybeU32, 0);
}
static addDefaultU32(builder:flatbuffers.Builder, defaultU32:number) {
builder.addFieldInt32(17, defaultU32, 42);
}
static addJustI64(builder:flatbuffers.Builder, justI64:bigint) {
builder.addFieldInt64(18, justI64, BigInt('0'));
}
static addMaybeI64(builder:flatbuffers.Builder, maybeI64:bigint) {
builder.addFieldInt64(19, maybeI64, BigInt(0));
}
static addDefaultI64(builder:flatbuffers.Builder, defaultI64:bigint) {
builder.addFieldInt64(20, defaultI64, BigInt('42'));
}
static addJustU64(builder:flatbuffers.Builder, justU64:bigint) {
builder.addFieldInt64(21, justU64, BigInt('0'));
}
static addMaybeU64(builder:flatbuffers.Builder, maybeU64:bigint) {
builder.addFieldInt64(22, maybeU64, BigInt(0));
}
static addDefaultU64(builder:flatbuffers.Builder, defaultU64:bigint) {
builder.addFieldInt64(23, defaultU64, BigInt('42'));
}
static addJustF32(builder:flatbuffers.Builder, justF32:number) {
builder.addFieldFloat32(24, justF32, 0.0);
}
static addMaybeF32(builder:flatbuffers.Builder, maybeF32:number) {
builder.addFieldFloat32(25, maybeF32, 0);
}
static addDefaultF32(builder:flatbuffers.Builder, defaultF32:number) {
builder.addFieldFloat32(26, defaultF32, 42.0);
}
static addJustF64(builder:flatbuffers.Builder, justF64:number) {
builder.addFieldFloat64(27, justF64, 0.0);
}
static addMaybeF64(builder:flatbuffers.Builder, maybeF64:number) {
builder.addFieldFloat64(28, maybeF64, 0);
}
static addDefaultF64(builder:flatbuffers.Builder, defaultF64:number) {
builder.addFieldFloat64(29, defaultF64, 42.0);
}
static addJustBool(builder:flatbuffers.Builder, justBool:boolean) {
builder.addFieldInt8(30, +justBool, +false);
}
static addMaybeBool(builder:flatbuffers.Builder, maybeBool:boolean) {
builder.addFieldInt8(31, +maybeBool, 0);
}
static addDefaultBool(builder:flatbuffers.Builder, defaultBool:boolean) {
builder.addFieldInt8(32, +defaultBool, +true);
}
static addJustEnum(builder:flatbuffers.Builder, justEnum:OptionalByte) {
builder.addFieldInt8(33, justEnum, OptionalByte.None);
}
static addMaybeEnum(builder:flatbuffers.Builder, maybeEnum:OptionalByte) {
builder.addFieldInt8(34, maybeEnum, 0);
}
static addDefaultEnum(builder:flatbuffers.Builder, defaultEnum:OptionalByte) {
builder.addFieldInt8(35, defaultEnum, OptionalByte.One);
}
static endScalarStuff(builder:flatbuffers.Builder):flatbuffers.Offset {
const offset = builder.endObject();
return offset;
}
static finishScalarStuffBuffer(builder:flatbuffers.Builder, offset:flatbuffers.Offset) {
builder.finish(offset, 'NULL');
}
static finishSizePrefixedScalarStuffBuffer(builder:flatbuffers.Builder, offset:flatbuffers.Offset) {
builder.finish(offset, 'NULL', true);
}
static createScalarStuff(builder:flatbuffers.Builder, justI8:number, maybeI8:number|null, defaultI8:number, justU8:number, maybeU8:number|null, defaultU8:number, justI16:number, maybeI16:number|null, defaultI16:number, justU16:number, maybeU16:number|null, defaultU16:number, justI32:number, maybeI32:number|null, defaultI32:number, justU32:number, maybeU32:number|null, defaultU32:number, justI64:bigint, maybeI64:bigint|null, defaultI64:bigint, justU64:bigint, maybeU64:bigint|null, defaultU64:bigint, justF32:number, maybeF32:number|null, defaultF32:number, justF64:number, maybeF64:number|null, defaultF64:number, justBool:boolean, maybeBool:boolean|null, defaultBool:boolean, justEnum:OptionalByte, maybeEnum:OptionalByte|null, defaultEnum:OptionalByte):flatbuffers.Offset {
ScalarStuff.startScalarStuff(builder);
ScalarStuff.addJustI8(builder, justI8);
if (maybeI8 !== null)
ScalarStuff.addMaybeI8(builder, maybeI8);
ScalarStuff.addDefaultI8(builder, defaultI8);
ScalarStuff.addJustU8(builder, justU8);
if (maybeU8 !== null)
ScalarStuff.addMaybeU8(builder, maybeU8);
ScalarStuff.addDefaultU8(builder, defaultU8);
ScalarStuff.addJustI16(builder, justI16);
if (maybeI16 !== null)
ScalarStuff.addMaybeI16(builder, maybeI16);
ScalarStuff.addDefaultI16(builder, defaultI16);
ScalarStuff.addJustU16(builder, justU16);
if (maybeU16 !== null)
ScalarStuff.addMaybeU16(builder, maybeU16);
ScalarStuff.addDefaultU16(builder, defaultU16);
ScalarStuff.addJustI32(builder, justI32);
if (maybeI32 !== null)
ScalarStuff.addMaybeI32(builder, maybeI32);
ScalarStuff.addDefaultI32(builder, defaultI32);
ScalarStuff.addJustU32(builder, justU32);
if (maybeU32 !== null)
ScalarStuff.addMaybeU32(builder, maybeU32);
ScalarStuff.addDefaultU32(builder, defaultU32);
ScalarStuff.addJustI64(builder, justI64);
if (maybeI64 !== null)
ScalarStuff.addMaybeI64(builder, maybeI64);
ScalarStuff.addDefaultI64(builder, defaultI64);
ScalarStuff.addJustU64(builder, justU64);
if (maybeU64 !== null)
ScalarStuff.addMaybeU64(builder, maybeU64);
ScalarStuff.addDefaultU64(builder, defaultU64);
ScalarStuff.addJustF32(builder, justF32);
if (maybeF32 !== null)
ScalarStuff.addMaybeF32(builder, maybeF32);
ScalarStuff.addDefaultF32(builder, defaultF32);
ScalarStuff.addJustF64(builder, justF64);
if (maybeF64 !== null)
ScalarStuff.addMaybeF64(builder, maybeF64);
ScalarStuff.addDefaultF64(builder, defaultF64);
ScalarStuff.addJustBool(builder, justBool);
if (maybeBool !== null)
ScalarStuff.addMaybeBool(builder, maybeBool);
ScalarStuff.addDefaultBool(builder, defaultBool);
ScalarStuff.addJustEnum(builder, justEnum);
if (maybeEnum !== null)
ScalarStuff.addMaybeEnum(builder, maybeEnum);
ScalarStuff.addDefaultEnum(builder, defaultEnum);
return ScalarStuff.endScalarStuff(builder);
}
}

View File

@@ -3,15 +3,12 @@
import assert from 'assert';
import { readFileSync, writeFileSync } from 'fs';
import * as flatbuffers from 'flatbuffers';
import {
ArrayStructT,
ArrayTable,
ArrayTableT,
InnerStructT,
NestedStructT,
OuterStructT,
TestEnum,
} from './arrays_test_complex/arrays_test_complex_generated.js';
import { ArrayStructT } from './arrays_test_complex/my-game/example/array-struct.js'
import { ArrayTable, ArrayTableT } from './arrays_test_complex/my-game/example/array-table.js'
import { InnerStructT } from './arrays_test_complex/my-game/example/inner-struct.js'
import { NestedStructT } from './arrays_test_complex/my-game/example/nested-struct.js'
import { OuterStructT } from './arrays_test_complex/my-game/example/outer-struct.js'
import { TestEnum } from './arrays_test_complex/my-game/example/test-enum.js'
// eslint-disable-next-line @typescript-eslint/no-explicit-any
BigInt.prototype.toJSON = function () {
return this.toString();

View File

@@ -0,0 +1,367 @@
// Run this using JavaScriptTest.sh
var assert = require('assert');
var fs = require('fs');
var flatbuffers = require('../../js/flatbuffers');
var MyGame = require(process.argv[2]).MyGame;
function main() {
// First, let's test reading a FlatBuffer generated by C++ code:
// This file was generated from monsterdata_test.json
var data = new Uint8Array(fs.readFileSync('../monsterdata_test.mon'));
// Now test it:
var bb = new flatbuffers.ByteBuffer(data);
testBuffer(bb);
// Second, let's create a FlatBuffer from scratch in JavaScript, and test it also.
// We use an initial size of 1 to exercise the reallocation algorithm,
// normally a size larger than the typical FlatBuffer you generate would be
// better for performance.
var fbb = new flatbuffers.Builder(1);
createMonster(fbb);
serializeAndTest(fbb);
// clear the builder, repeat tests
var clearIterations = 100;
var startingCapacity = fbb.bb.capacity();
for (var i = 0; i < clearIterations; i++) {
fbb.clear();
createMonster(fbb);
serializeAndTest(fbb);
}
// the capacity of our buffer shouldn't increase with the same size payload
assert.strictEqual(fbb.bb.capacity(), startingCapacity);
test64bit();
testUnicode();
fuzzTest1();
console.log('FlatBuffers test: completed successfully');
}
function createMonster(fbb) {
// We set up the same values as monsterdata.json:
var str = fbb.createString('MyMonster');
var inv = MyGame.Example.Monster.createInventoryVector(fbb, [0, 1, 2, 3, 4]);
var fred = fbb.createString('Fred');
MyGame.Example.Monster.startMonster(fbb);
MyGame.Example.Monster.addName(fbb, fred);
var mon2 = MyGame.Example.Monster.endMonster(fbb);
MyGame.Example.Monster.startTest4Vector(fbb, 2);
MyGame.Example.Test.createTest(fbb, 10, 20);
MyGame.Example.Test.createTest(fbb, 30, 40);
var test4 = fbb.endVector();
var testArrayOfString = MyGame.Example.Monster.createTestarrayofstringVector(fbb, [
fbb.createString('test1'),
fbb.createString('test2')
]);
MyGame.Example.Monster.startMonster(fbb);
MyGame.Example.Monster.addPos(fbb, MyGame.Example.Vec3.createVec3(fbb, 1, 2, 3, 3, MyGame.Example.Color.Green, 5, 6));
MyGame.Example.Monster.addHp(fbb, 80);
MyGame.Example.Monster.addName(fbb, str);
MyGame.Example.Monster.addInventory(fbb, inv);
MyGame.Example.Monster.addTestType(fbb, MyGame.Example.Any.Monster);
MyGame.Example.Monster.addTest(fbb, mon2);
MyGame.Example.Monster.addTest4(fbb, test4);
MyGame.Example.Monster.addTestarrayofstring(fbb, testArrayOfString);
MyGame.Example.Monster.addTestbool(fbb, true);
var mon = MyGame.Example.Monster.endMonster(fbb);
MyGame.Example.Monster.finishMonsterBuffer(fbb, mon);
}
function serializeAndTest(fbb) {
// Write the result to a file for debugging purposes:
// Note that the binaries are not necessarily identical, since the JSON
// parser may serialize in a slightly different order than the above
// JavaScript code. They are functionally equivalent though.
fs.writeFileSync('monsterdata_javascript_wire.mon', new Buffer(fbb.asUint8Array()));
// Tests mutation first. This will verify that we did not trample any other
// part of the byte buffer.
testMutation(fbb.dataBuffer());
testBuffer(fbb.dataBuffer());
}
function testMutation(bb) {
var monster = MyGame.Example.Monster.getRootAsMonster(bb);
monster.mutate_hp(120);
assert.strictEqual(monster.hp(), 120);
monster.mutate_hp(80);
assert.strictEqual(monster.hp(), 80);
var manaRes = monster.mutate_mana(10);
assert.strictEqual(manaRes, false); // Field was NOT present, because default value.
// TODO: There is not the availability to mutate structs or vectors.
}
function testBuffer(bb) {
assert.ok(MyGame.Example.Monster.bufferHasIdentifier(bb));
var monster = MyGame.Example.Monster.getRootAsMonster(bb);
assert.strictEqual(monster.hp(), 80);
assert.strictEqual(monster.mana(), 150); // default
assert.strictEqual(monster.name(), 'MyMonster');
var pos = monster.pos();
assert.strictEqual(pos.x(), 1);
assert.strictEqual(pos.y(), 2);
assert.strictEqual(pos.z(), 3);
assert.strictEqual(pos.test1(), 3);
assert.strictEqual(pos.test2(), MyGame.Example.Color.Green);
var t = pos.test3();
assert.strictEqual(t.a(), 5);
assert.strictEqual(t.b(), 6);
assert.strictEqual(monster.testType(), MyGame.Example.Any.Monster);
var monster2 = new MyGame.Example.Monster();
assert.strictEqual(monster.test(monster2) != null, true);
assert.strictEqual(monster2.name(), 'Fred');
assert.strictEqual(monster.inventoryLength(), 5);
var invsum = 0;
for (var i = 0; i < monster.inventoryLength(); i++) {
invsum += monster.inventory(i);
}
assert.strictEqual(invsum, 10);
var invsum2 = 0;
var invArr = monster.inventoryArray();
for (var i = 0; i < invArr.length; i++) {
invsum2 += invArr[i];
}
assert.strictEqual(invsum2, 10);
var test_0 = monster.test4(0);
var test_1 = monster.test4(1);
assert.strictEqual(monster.test4Length(), 2);
assert.strictEqual(test_0.a() + test_0.b() + test_1.a() + test_1.b(), 100);
assert.strictEqual(monster.testarrayofstringLength(), 2);
assert.strictEqual(monster.testarrayofstring(0), 'test1');
assert.strictEqual(monster.testarrayofstring(1), 'test2');
assert.strictEqual(monster.testbool(), true);
}
function test64bit() {
var fbb = new flatbuffers.Builder();
var required = fbb.createString('required');
MyGame.Example.Stat.startStat(fbb);
var stat2 = MyGame.Example.Stat.endStat(fbb);
MyGame.Example.Monster.startMonster(fbb);
MyGame.Example.Monster.addName(fbb, required);
MyGame.Example.Monster.addTestempty(fbb, stat2);
var mon2 = MyGame.Example.Monster.endMonster(fbb);
MyGame.Example.Stat.startStat(fbb);
MyGame.Example.Stat.addVal(fbb, 0x2345678987654321n);
var stat = MyGame.Example.Stat.endStat(fbb);
MyGame.Example.Monster.startMonster(fbb);
MyGame.Example.Monster.addName(fbb, required);
MyGame.Example.Monster.addEnemy(fbb, mon2);
MyGame.Example.Monster.addTestempty(fbb, stat);
var mon = MyGame.Example.Monster.endMonster(fbb);
MyGame.Example.Monster.finishMonsterBuffer(fbb, mon);
var bytes = fbb.asUint8Array();
////////////////////////////////////////////////////////////////
var bb = new flatbuffers.ByteBuffer(bytes);
assert.ok(MyGame.Example.Monster.bufferHasIdentifier(bb));
var mon = MyGame.Example.Monster.getRootAsMonster(bb);
var stat = mon.testempty();
assert.strictEqual(stat != null, true);
assert.strictEqual(stat.val() != null, true);
assert.strictEqual(stat.val(), 2541551405100253985n);
var mon2 = mon.enemy();
assert.strictEqual(mon2 != null, true);
stat = mon2.testempty();
assert.strictEqual(stat != null, true);
assert.strictEqual(stat.val() != null, true);
assert.strictEqual(stat.val(), 0n); // default value
}
function testUnicode() {
var correct = fs.readFileSync('unicode_test.mon');
var json = JSON.parse(fs.readFileSync('../unicode_test.json', 'utf8'));
// Test reading
function testReadingUnicode(bb) {
var monster = MyGame.Example.Monster.getRootAsMonster(bb);
assert.strictEqual(monster.name(), json.name);
assert.deepEqual(new Buffer(monster.name(flatbuffers.Encoding.UTF8_BYTES)), new Buffer(json.name));
assert.strictEqual(monster.testarrayoftablesLength(), json.testarrayoftables.length);
json.testarrayoftables.forEach(function(table, i) {
var value = monster.testarrayoftables(i);
assert.strictEqual(value.name(), table.name);
assert.deepEqual(new Buffer(value.name(flatbuffers.Encoding.UTF8_BYTES)), new Buffer(table.name));
});
assert.strictEqual(monster.testarrayofstringLength(), json.testarrayofstring.length);
json.testarrayofstring.forEach(function(string, i) {
assert.strictEqual(monster.testarrayofstring(i), string);
assert.deepEqual(new Buffer(monster.testarrayofstring(i, flatbuffers.Encoding.UTF8_BYTES)), new Buffer(string));
});
}
testReadingUnicode(new flatbuffers.ByteBuffer(new Uint8Array(correct)));
// Test writing
var fbb = new flatbuffers.Builder();
var name = fbb.createString(json.name);
var testarrayoftablesOffsets = json.testarrayoftables.map(function(table) {
var name = fbb.createString(new Uint8Array(new Buffer(table.name)));
MyGame.Example.Monster.startMonster(fbb);
MyGame.Example.Monster.addName(fbb, name);
return MyGame.Example.Monster.endMonster(fbb);
});
var testarrayoftablesOffset = MyGame.Example.Monster.createTestarrayoftablesVector(fbb,
testarrayoftablesOffsets);
var testarrayofstringOffset = MyGame.Example.Monster.createTestarrayofstringVector(fbb,
json.testarrayofstring.map(function(string) { return fbb.createString(string); }));
MyGame.Example.Monster.startMonster(fbb);
MyGame.Example.Monster.addTestarrayofstring(fbb, testarrayofstringOffset);
MyGame.Example.Monster.addTestarrayoftables(fbb, testarrayoftablesOffset);
MyGame.Example.Monster.addName(fbb, name);
MyGame.Example.Monster.finishSizePrefixedMonsterBuffer(fbb, MyGame.Example.Monster.endMonster(fbb));
var bb = new flatbuffers.ByteBuffer(fbb.asUint8Array())
bb.setPosition(4);
testReadingUnicode(bb);
}
var __imul = Math.imul ? Math.imul : function(a, b) {
var ah = a >> 16 & 65535;
var bh = b >> 16 & 65535;
var al = a & 65535;
var bl = b & 65535;
return al * bl + (ah * bl + al * bh << 16) | 0;
};
// Include simple random number generator to ensure results will be the
// same cross platform.
// http://en.wikipedia.org/wiki/Park%E2%80%93Miller_random_number_generator
var lcg_seed = 48271;
function lcg_rand() {
return lcg_seed = (__imul(lcg_seed, 279470273) >>> 0) % 4294967291;
}
function lcg_reset() {
lcg_seed = 48271;
}
// Converts a Field ID to a virtual table offset.
function fieldIndexToOffset(field_id) {
// Should correspond to what EndTable() below builds up.
var fixed_fields = 2; // Vtable size and Object Size.
return (field_id + fixed_fields) * 2;
}
// Low level stress/fuzz test: serialize/deserialize a variety of
// different kinds of data in different combinations
function fuzzTest1() {
// Values we're testing against: chosen to ensure no bits get chopped
// off anywhere, and also be different from eachother.
var bool_val = true;
var char_val = -127; // 0x81
var uchar_val = 0xFF;
var short_val = -32222; // 0x8222;
var ushort_val = 0xFEEE;
var int_val = 0x83333333 | 0;
var uint_val = 0xFDDDDDDD;
var long_val = BigInt.asIntN(64, 0x8444444444444444n);
var ulong_val = BigInt.asUintN(64, 0xFCCCCCCCCCCCCCCCn);
var float_val = new Float32Array([3.14159])[0];
var double_val = 3.14159265359;
var test_values_max = 11;
var fields_per_object = 4;
var num_fuzz_objects = 10000; // The higher, the more thorough :)
var builder = new flatbuffers.Builder();
lcg_reset(); // Keep it deterministic.
var objects = [];
// Generate num_fuzz_objects random objects each consisting of
// fields_per_object fields, each of a random type.
for (var i = 0; i < num_fuzz_objects; i++) {
builder.startObject(fields_per_object);
for (var f = 0; f < fields_per_object; f++) {
var choice = lcg_rand() % test_values_max;
switch (choice) {
case 0: builder.addFieldInt8(f, bool_val, 0); break;
case 1: builder.addFieldInt8(f, char_val, 0); break;
case 2: builder.addFieldInt8(f, uchar_val, 0); break;
case 3: builder.addFieldInt16(f, short_val, 0); break;
case 4: builder.addFieldInt16(f, ushort_val, 0); break;
case 5: builder.addFieldInt32(f, int_val, 0); break;
case 6: builder.addFieldInt32(f, uint_val, 0); break;
case 7: builder.addFieldInt64(f, long_val, 0n); break;
case 8: builder.addFieldInt64(f, ulong_val, 0n); break;
case 9: builder.addFieldFloat32(f, float_val, 0); break;
case 10: builder.addFieldFloat64(f, double_val, 0); break;
}
}
objects.push(builder.endObject());
}
builder.prep(8, 0); // Align whole buffer.
lcg_reset(); // Reset.
builder.finish(objects[objects.length - 1]);
var bytes = new Uint8Array(builder.asUint8Array());
var view = new DataView(bytes.buffer);
// Test that all objects we generated are readable and return the
// expected values. We generate random objects in the same order
// so this is deterministic.
for (var i = 0; i < num_fuzz_objects; i++) {
var offset = bytes.length - objects[i];
for (var f = 0; f < fields_per_object; f++) {
var choice = lcg_rand() % test_values_max;
var vtable_offset = fieldIndexToOffset(f);
var vtable = offset - view.getInt32(offset, true);
assert.ok(vtable_offset < view.getInt16(vtable, true));
var field_offset = offset + view.getInt16(vtable + vtable_offset, true);
switch (choice) {
case 0: assert.strictEqual(!!view.getInt8(field_offset), bool_val); break;
case 1: assert.strictEqual(view.getInt8(field_offset), char_val); break;
case 2: assert.strictEqual(view.getUint8(field_offset), uchar_val); break;
case 3: assert.strictEqual(view.getInt16(field_offset, true), short_val); break;
case 4: assert.strictEqual(view.getUint16(field_offset, true), ushort_val); break;
case 5: assert.strictEqual(view.getInt32(field_offset, true), int_val); break;
case 6: assert.strictEqual(view.getUint32(field_offset, true), uint_val); break;
case 7: assert.strictEqual(view.getBigInt64(field_offset, true), long_val); break;
case 8: assert.strictEqual(view.getBigUint64(field_offset, true), ulong_val); break;
case 9: assert.strictEqual(view.getFloat32(field_offset, true), float_val); break;
case 10: assert.strictEqual(view.getFloat64(field_offset, true), double_val); break;
}
}
}
}
main();

View File

@@ -44,6 +44,7 @@ def check_call(args, cwd=tests_path):
# Execute the flatc compiler with the specified parameters
def flatc(options, schema, prefix=None, include=None, data=None, cwd=tests_path):
print("Invoking flatc on schema " + str(schema))
cmd = [str(flatc_path)] + options
if prefix:
cmd += ["-o"] + [prefix]
@@ -54,17 +55,23 @@ def flatc(options, schema, prefix=None, include=None, data=None, cwd=tests_path)
cmd += [data] if isinstance(data, str) else data
check_call(cmd)
# Execute esbuild with the specified parameters
def esbuild(input, output):
cmd = ["esbuild", input, "--outfile=" + output]
cmd += ["--format=cjs", "--bundle", "--external:flatbuffers"]
check_call(cmd)
print("Removing node_modules/ directory...")
shutil.rmtree(Path(tests_path, "node_modules"), ignore_errors=True)
check_call(["npm", "install", "--silent"])
print("Invoking flatc...")
flatc(
options=["--ts", "--reflect-names", "--gen-name-strings", "--gen-mutable", "--gen-object-api"],
options=["--ts", "--reflect-names", "--gen-name-strings", "--gen-mutable", "--gen-object-api", "--ts-entry-points", "--ts-flat-files"],
schema="../monster_test.fbs",
include="../include_test",
)
esbuild("monster_test.ts", "monster_test_generated.cjs")
flatc(
options=["--gen-object-api", "-b"],
@@ -74,10 +81,11 @@ flatc(
)
flatc(
options=["--ts", "--reflect-names", "--gen-name-strings", "--gen-mutable", "--gen-object-api"],
options=["--ts", "--reflect-names", "--gen-name-strings", "--gen-mutable", "--gen-object-api", "--ts-entry-points", "--ts-flat-files"],
schema="../union_vector/union_vector.fbs",
prefix="union_vector",
)
esbuild("union_vector/union_vector.ts", "union_vector/union_vector_generated.cjs")
flatc(
options=["--ts", "--reflect-names", "--gen-name-strings"],
@@ -91,31 +99,14 @@ flatc(
)
flatc(
options=["--ts", "--reflect-names", "--gen-name-strings", "--gen-mutable", "--gen-object-api"],
schema=[
"typescript_keywords.fbs",
"test_dir/typescript_include.fbs",
"test_dir/typescript_transitive_include.fbs",
"../../reflection/reflection.fbs",
],
include="../../",
)
flatc(
options=["--ts", "--reflect-names", "--ts-flat-files", "--gen-name-strings", "--gen-object-api"],
options=["--ts", "--reflect-names", "--gen-name-strings", "--gen-object-api", "--ts-entry-points", "--ts-flat-files"],
schema="arrays_test_complex/arrays_test_complex.fbs",
prefix="arrays_test_complex"
)
esbuild("arrays_test_complex/my-game/example.ts", "arrays_test_complex/arrays_test_complex_generated.cjs")
flatc(
options=[
"--ts",
"--reflect-names",
"--gen-name-strings",
"--gen-mutable",
"--gen-object-api",
"--ts-flat-files",
],
options=["--ts", "--reflect-names", "--gen-name-strings", "--gen-mutable", "--gen-object-api", "--ts-entry-points", "--ts-flat-files"],
schema=[
"typescript_keywords.fbs",
"test_dir/typescript_include.fbs",
@@ -124,15 +115,18 @@ flatc(
],
include="../../",
)
esbuild("typescript_keywords.ts", "typescript_keywords_generated.cjs")
print("Running TypeScript Compiler...")
check_call(["tsc"])
print("Running TypeScript Compiler in old node resolution mode for no_import_ext...")
check_call(["tsc", "-p", "./tsconfig.node.json"])
NODE_CMD = ["node"]
print("Running TypeScript Tests...")
check_call(NODE_CMD + ["JavaScriptTest"])
check_call(NODE_CMD + ["JavaScriptTestv1.cjs", "./monster_test_generated.cjs"])
check_call(NODE_CMD + ["JavaScriptUnionVectorTest"])
check_call(NODE_CMD + ["JavaScriptFlexBuffersTest"])
check_call(NODE_CMD + ["JavaScriptComplexArraysTest"])
check_call(NODE_CMD + ["JavaScriptRequiredStringTest"])

View File

@@ -0,0 +1,451 @@
"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// arrays_test_complex/my-game/example.ts
var example_exports = {};
__export(example_exports, {
ArrayStruct: () => ArrayStruct,
ArrayTable: () => ArrayTable,
InnerStruct: () => InnerStruct,
NestedStruct: () => NestedStruct,
OuterStruct: () => OuterStruct,
TestEnum: () => TestEnum
});
module.exports = __toCommonJS(example_exports);
// arrays_test_complex/my-game/example/inner-struct.js
var InnerStruct = class {
constructor() {
this.bb = null;
this.bb_pos = 0;
}
__init(i, bb) {
this.bb_pos = i;
this.bb = bb;
return this;
}
a() {
return this.bb.readFloat64(this.bb_pos);
}
b(index) {
return this.bb.readUint8(this.bb_pos + 8 + index);
}
c() {
return this.bb.readInt8(this.bb_pos + 21);
}
dUnderscore() {
return this.bb.readInt64(this.bb_pos + 24);
}
static getFullyQualifiedName() {
return "MyGame.Example.InnerStruct";
}
static sizeOf() {
return 32;
}
static createInnerStruct(builder, a, b, c, d_underscore) {
builder.prep(8, 32);
builder.writeInt64(BigInt(d_underscore ?? 0));
builder.pad(2);
builder.writeInt8(c);
for (let i = 12; i >= 0; --i) {
builder.writeInt8(b?.[i] ?? 0);
}
builder.writeFloat64(a);
return builder.offset();
}
unpack() {
return new InnerStructT(this.a(), this.bb.createScalarList(this.b.bind(this), 13), this.c(), this.dUnderscore());
}
unpackTo(_o) {
_o.a = this.a();
_o.b = this.bb.createScalarList(this.b.bind(this), 13);
_o.c = this.c();
_o.dUnderscore = this.dUnderscore();
}
};
var InnerStructT = class {
constructor(a = 0, b = [], c = 0, dUnderscore = BigInt("0")) {
this.a = a;
this.b = b;
this.c = c;
this.dUnderscore = dUnderscore;
}
pack(builder) {
return InnerStruct.createInnerStruct(builder, this.a, this.b, this.c, this.dUnderscore);
}
};
// arrays_test_complex/my-game/example/outer-struct.js
var OuterStruct = class {
constructor() {
this.bb = null;
this.bb_pos = 0;
}
__init(i, bb) {
this.bb_pos = i;
this.bb = bb;
return this;
}
a() {
return !!this.bb.readInt8(this.bb_pos);
}
b() {
return this.bb.readFloat64(this.bb_pos + 8);
}
cUnderscore(obj) {
return (obj || new InnerStruct()).__init(this.bb_pos + 16, this.bb);
}
d(index, obj) {
return (obj || new InnerStruct()).__init(this.bb_pos + 48 + index * 32, this.bb);
}
e(obj) {
return (obj || new InnerStruct()).__init(this.bb_pos + 144, this.bb);
}
f(index) {
return this.bb.readFloat64(this.bb_pos + 176 + index * 8);
}
static getFullyQualifiedName() {
return "MyGame.Example.OuterStruct";
}
static sizeOf() {
return 208;
}
static createOuterStruct(builder, a, b, c_underscore_a, c_underscore_b, c_underscore_c, c_underscore_d_underscore, d, e_a, e_b, e_c, e_d_underscore, f) {
builder.prep(8, 208);
for (let i = 3; i >= 0; --i) {
builder.writeFloat64(f?.[i] ?? 0);
}
builder.prep(8, 32);
builder.writeInt64(BigInt(e_d_underscore ?? 0));
builder.pad(2);
builder.writeInt8(e_c);
for (let i = 12; i >= 0; --i) {
builder.writeInt8(e_b?.[i] ?? 0);
}
builder.writeFloat64(e_a);
for (let i = 2; i >= 0; --i) {
const item = d?.[i];
if (item instanceof InnerStructT) {
item.pack(builder);
continue;
}
InnerStruct.createInnerStruct(builder, item?.a, item?.b, item?.c, item?.dUnderscore);
}
builder.prep(8, 32);
builder.writeInt64(BigInt(c_underscore_d_underscore ?? 0));
builder.pad(2);
builder.writeInt8(c_underscore_c);
for (let i = 12; i >= 0; --i) {
builder.writeInt8(c_underscore_b?.[i] ?? 0);
}
builder.writeFloat64(c_underscore_a);
builder.writeFloat64(b);
builder.pad(7);
builder.writeInt8(Number(Boolean(a)));
return builder.offset();
}
unpack() {
return new OuterStructT(this.a(), this.b(), this.cUnderscore() !== null ? this.cUnderscore().unpack() : null, this.bb.createObjList(this.d.bind(this), 3), this.e() !== null ? this.e().unpack() : null, this.bb.createScalarList(this.f.bind(this), 4));
}
unpackTo(_o) {
_o.a = this.a();
_o.b = this.b();
_o.cUnderscore = this.cUnderscore() !== null ? this.cUnderscore().unpack() : null;
_o.d = this.bb.createObjList(this.d.bind(this), 3);
_o.e = this.e() !== null ? this.e().unpack() : null;
_o.f = this.bb.createScalarList(this.f.bind(this), 4);
}
};
var OuterStructT = class {
constructor(a = false, b = 0, cUnderscore = null, d = [], e = null, f = []) {
this.a = a;
this.b = b;
this.cUnderscore = cUnderscore;
this.d = d;
this.e = e;
this.f = f;
}
pack(builder) {
return OuterStruct.createOuterStruct(builder, this.a, this.b, this.cUnderscore?.a ?? 0, this.cUnderscore?.b ?? [], this.cUnderscore?.c ?? 0, this.cUnderscore?.dUnderscore ?? BigInt(0), this.d, this.e?.a ?? 0, this.e?.b ?? [], this.e?.c ?? 0, this.e?.dUnderscore ?? BigInt(0), this.f);
}
};
// arrays_test_complex/my-game/example/test-enum.js
var TestEnum;
(function(TestEnum2) {
TestEnum2[TestEnum2["A"] = 0] = "A";
TestEnum2[TestEnum2["B"] = 1] = "B";
TestEnum2[TestEnum2["C"] = 2] = "C";
})(TestEnum = TestEnum || (TestEnum = {}));
// arrays_test_complex/my-game/example/nested-struct.js
var NestedStruct = class {
constructor() {
this.bb = null;
this.bb_pos = 0;
}
__init(i, bb) {
this.bb_pos = i;
this.bb = bb;
return this;
}
a(index) {
return this.bb.readInt32(this.bb_pos + 0 + index * 4);
}
b() {
return this.bb.readInt8(this.bb_pos + 8);
}
cUnderscore(index) {
return this.bb.readInt8(this.bb_pos + 9 + index);
}
dOuter(index, obj) {
return (obj || new OuterStruct()).__init(this.bb_pos + 16 + index * 208, this.bb);
}
e(index) {
return this.bb.readInt64(this.bb_pos + 1056 + index * 8);
}
static getFullyQualifiedName() {
return "MyGame.Example.NestedStruct";
}
static sizeOf() {
return 1072;
}
static createNestedStruct(builder, a, b, c_underscore, d_outer, e) {
builder.prep(8, 1072);
for (let i = 1; i >= 0; --i) {
builder.writeInt64(BigInt(e?.[i] ?? 0));
}
for (let i = 4; i >= 0; --i) {
const item = d_outer?.[i];
if (item instanceof OuterStructT) {
item.pack(builder);
continue;
}
OuterStruct.createOuterStruct(builder, item?.a, item?.b, item?.cUnderscore?.a ?? 0, item?.cUnderscore?.b ?? [], item?.cUnderscore?.c ?? 0, item?.cUnderscore?.dUnderscore ?? BigInt(0), item?.d, item?.e?.a ?? 0, item?.e?.b ?? [], item?.e?.c ?? 0, item?.e?.dUnderscore ?? BigInt(0), item?.f);
}
builder.pad(5);
for (let i = 1; i >= 0; --i) {
builder.writeInt8(c_underscore?.[i] ?? 0);
}
builder.writeInt8(b);
for (let i = 1; i >= 0; --i) {
builder.writeInt32(a?.[i] ?? 0);
}
return builder.offset();
}
unpack() {
return new NestedStructT(this.bb.createScalarList(this.a.bind(this), 2), this.b(), this.bb.createScalarList(this.cUnderscore.bind(this), 2), this.bb.createObjList(this.dOuter.bind(this), 5), this.bb.createScalarList(this.e.bind(this), 2));
}
unpackTo(_o) {
_o.a = this.bb.createScalarList(this.a.bind(this), 2);
_o.b = this.b();
_o.cUnderscore = this.bb.createScalarList(this.cUnderscore.bind(this), 2);
_o.dOuter = this.bb.createObjList(this.dOuter.bind(this), 5);
_o.e = this.bb.createScalarList(this.e.bind(this), 2);
}
};
var NestedStructT = class {
constructor(a = [], b = TestEnum.A, cUnderscore = [TestEnum.A, TestEnum.A], dOuter = [], e = []) {
this.a = a;
this.b = b;
this.cUnderscore = cUnderscore;
this.dOuter = dOuter;
this.e = e;
}
pack(builder) {
return NestedStruct.createNestedStruct(builder, this.a, this.b, this.cUnderscore, this.dOuter, this.e);
}
};
// arrays_test_complex/my-game/example/array-struct.js
var ArrayStruct = class {
constructor() {
this.bb = null;
this.bb_pos = 0;
}
__init(i, bb) {
this.bb_pos = i;
this.bb = bb;
return this;
}
aUnderscore() {
return this.bb.readFloat32(this.bb_pos);
}
bUnderscore(index) {
return this.bb.readInt32(this.bb_pos + 4 + index * 4);
}
c() {
return this.bb.readInt8(this.bb_pos + 64);
}
d(index, obj) {
return (obj || new NestedStruct()).__init(this.bb_pos + 72 + index * 1072, this.bb);
}
e() {
return this.bb.readInt32(this.bb_pos + 2216);
}
f(index, obj) {
return (obj || new OuterStruct()).__init(this.bb_pos + 2224 + index * 208, this.bb);
}
g(index) {
return this.bb.readInt64(this.bb_pos + 2640 + index * 8);
}
static getFullyQualifiedName() {
return "MyGame.Example.ArrayStruct";
}
static sizeOf() {
return 2656;
}
static createArrayStruct(builder, a_underscore, b_underscore, c, d, e, f, g) {
builder.prep(8, 2656);
for (let i = 1; i >= 0; --i) {
builder.writeInt64(BigInt(g?.[i] ?? 0));
}
for (let i = 1; i >= 0; --i) {
const item = f?.[i];
if (item instanceof OuterStructT) {
item.pack(builder);
continue;
}
OuterStruct.createOuterStruct(builder, item?.a, item?.b, item?.cUnderscore?.a ?? 0, item?.cUnderscore?.b ?? [], item?.cUnderscore?.c ?? 0, item?.cUnderscore?.dUnderscore ?? BigInt(0), item?.d, item?.e?.a ?? 0, item?.e?.b ?? [], item?.e?.c ?? 0, item?.e?.dUnderscore ?? BigInt(0), item?.f);
}
builder.pad(4);
builder.writeInt32(e);
for (let i = 1; i >= 0; --i) {
const item = d?.[i];
if (item instanceof NestedStructT) {
item.pack(builder);
continue;
}
NestedStruct.createNestedStruct(builder, item?.a, item?.b, item?.cUnderscore, item?.dOuter, item?.e);
}
builder.pad(7);
builder.writeInt8(c);
for (let i = 14; i >= 0; --i) {
builder.writeInt32(b_underscore?.[i] ?? 0);
}
builder.writeFloat32(a_underscore);
return builder.offset();
}
unpack() {
return new ArrayStructT(this.aUnderscore(), this.bb.createScalarList(this.bUnderscore.bind(this), 15), this.c(), this.bb.createObjList(this.d.bind(this), 2), this.e(), this.bb.createObjList(this.f.bind(this), 2), this.bb.createScalarList(this.g.bind(this), 2));
}
unpackTo(_o) {
_o.aUnderscore = this.aUnderscore();
_o.bUnderscore = this.bb.createScalarList(this.bUnderscore.bind(this), 15);
_o.c = this.c();
_o.d = this.bb.createObjList(this.d.bind(this), 2);
_o.e = this.e();
_o.f = this.bb.createObjList(this.f.bind(this), 2);
_o.g = this.bb.createScalarList(this.g.bind(this), 2);
}
};
var ArrayStructT = class {
constructor(aUnderscore = 0, bUnderscore = [], c = 0, d = [], e = 0, f = [], g = []) {
this.aUnderscore = aUnderscore;
this.bUnderscore = bUnderscore;
this.c = c;
this.d = d;
this.e = e;
this.f = f;
this.g = g;
}
pack(builder) {
return ArrayStruct.createArrayStruct(builder, this.aUnderscore, this.bUnderscore, this.c, this.d, this.e, this.f, this.g);
}
};
// arrays_test_complex/my-game/example/array-table.js
var flatbuffers = __toESM(require("flatbuffers"), 1);
var ArrayTable = class {
constructor() {
this.bb = null;
this.bb_pos = 0;
}
__init(i, bb) {
this.bb_pos = i;
this.bb = bb;
return this;
}
static getRootAsArrayTable(bb, obj) {
return (obj || new ArrayTable()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}
static getSizePrefixedRootAsArrayTable(bb, obj) {
bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
return (obj || new ArrayTable()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}
static bufferHasIdentifier(bb) {
return bb.__has_identifier("RHUB");
}
a(optionalEncoding) {
const offset = this.bb.__offset(this.bb_pos, 4);
return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null;
}
cUnderscore(obj) {
const offset = this.bb.__offset(this.bb_pos, 6);
return offset ? (obj || new ArrayStruct()).__init(this.bb_pos + offset, this.bb) : null;
}
static getFullyQualifiedName() {
return "MyGame.Example.ArrayTable";
}
static startArrayTable(builder) {
builder.startObject(2);
}
static addA(builder, aOffset) {
builder.addFieldOffset(0, aOffset, 0);
}
static addCUnderscore(builder, cUnderscoreOffset) {
builder.addFieldStruct(1, cUnderscoreOffset, 0);
}
static endArrayTable(builder) {
const offset = builder.endObject();
return offset;
}
static finishArrayTableBuffer(builder, offset) {
builder.finish(offset, "RHUB");
}
static finishSizePrefixedArrayTableBuffer(builder, offset) {
builder.finish(offset, "RHUB", true);
}
unpack() {
return new ArrayTableT(this.a(), this.cUnderscore() !== null ? this.cUnderscore().unpack() : null);
}
unpackTo(_o) {
_o.a = this.a();
_o.cUnderscore = this.cUnderscore() !== null ? this.cUnderscore().unpack() : null;
}
};
var ArrayTableT = class {
constructor(a = null, cUnderscore = null) {
this.a = a;
this.cUnderscore = cUnderscore;
}
pack(builder) {
const a = this.a !== null ? builder.createString(this.a) : 0;
ArrayTable.startArrayTable(builder);
ArrayTable.addA(builder, a);
ArrayTable.addCUnderscore(builder, this.cUnderscore !== null ? this.cUnderscore.pack(builder) : 0);
return ArrayTable.endArrayTable(builder);
}
};

View File

@@ -1,409 +0,0 @@
// automatically generated by the FlatBuffers compiler, do not modify
import * as flatbuffers from 'flatbuffers';
export var TestEnum;
(function (TestEnum) {
TestEnum[TestEnum["A"] = 0] = "A";
TestEnum[TestEnum["B"] = 1] = "B";
TestEnum[TestEnum["C"] = 2] = "C";
})(TestEnum || (TestEnum = {}));
export class InnerStruct {
constructor() {
this.bb = null;
this.bb_pos = 0;
}
__init(i, bb) {
this.bb_pos = i;
this.bb = bb;
return this;
}
a() {
return this.bb.readFloat64(this.bb_pos);
}
b(index) {
return this.bb.readUint8(this.bb_pos + 8 + index);
}
c() {
return this.bb.readInt8(this.bb_pos + 21);
}
dUnderscore() {
return this.bb.readInt64(this.bb_pos + 24);
}
static getFullyQualifiedName() {
return 'MyGame.Example.InnerStruct';
}
static sizeOf() {
return 32;
}
static createInnerStruct(builder, a, b, c, d_underscore) {
var _a;
builder.prep(8, 32);
builder.writeInt64(BigInt(d_underscore !== null && d_underscore !== void 0 ? d_underscore : 0));
builder.pad(2);
builder.writeInt8(c);
for (let i = 12; i >= 0; --i) {
builder.writeInt8(((_a = b === null || b === void 0 ? void 0 : b[i]) !== null && _a !== void 0 ? _a : 0));
}
builder.writeFloat64(a);
return builder.offset();
}
unpack() {
return new InnerStructT(this.a(), this.bb.createScalarList(this.b.bind(this), 13), this.c(), this.dUnderscore());
}
unpackTo(_o) {
_o.a = this.a();
_o.b = this.bb.createScalarList(this.b.bind(this), 13);
_o.c = this.c();
_o.dUnderscore = this.dUnderscore();
}
}
export class InnerStructT {
constructor(a = 0.0, b = [], c = 0, dUnderscore = BigInt('0')) {
this.a = a;
this.b = b;
this.c = c;
this.dUnderscore = dUnderscore;
}
pack(builder) {
return InnerStruct.createInnerStruct(builder, this.a, this.b, this.c, this.dUnderscore);
}
}
export class OuterStruct {
constructor() {
this.bb = null;
this.bb_pos = 0;
}
__init(i, bb) {
this.bb_pos = i;
this.bb = bb;
return this;
}
a() {
return !!this.bb.readInt8(this.bb_pos);
}
b() {
return this.bb.readFloat64(this.bb_pos + 8);
}
cUnderscore(obj) {
return (obj || new InnerStruct()).__init(this.bb_pos + 16, this.bb);
}
d(index, obj) {
return (obj || new InnerStruct()).__init(this.bb_pos + 48 + index * 32, this.bb);
}
e(obj) {
return (obj || new InnerStruct()).__init(this.bb_pos + 144, this.bb);
}
f(index) {
return this.bb.readFloat64(this.bb_pos + 176 + index * 8);
}
static getFullyQualifiedName() {
return 'MyGame.Example.OuterStruct';
}
static sizeOf() {
return 208;
}
static createOuterStruct(builder, a, b, c_underscore_a, c_underscore_b, c_underscore_c, c_underscore_d_underscore, d, e_a, e_b, e_c, e_d_underscore, f) {
var _a, _b, _c;
builder.prep(8, 208);
for (let i = 3; i >= 0; --i) {
builder.writeFloat64(((_a = f === null || f === void 0 ? void 0 : f[i]) !== null && _a !== void 0 ? _a : 0));
}
builder.prep(8, 32);
builder.writeInt64(BigInt(e_d_underscore !== null && e_d_underscore !== void 0 ? e_d_underscore : 0));
builder.pad(2);
builder.writeInt8(e_c);
for (let i = 12; i >= 0; --i) {
builder.writeInt8(((_b = e_b === null || e_b === void 0 ? void 0 : e_b[i]) !== null && _b !== void 0 ? _b : 0));
}
builder.writeFloat64(e_a);
for (let i = 2; i >= 0; --i) {
const item = d === null || d === void 0 ? void 0 : d[i];
if (item instanceof InnerStructT) {
item.pack(builder);
continue;
}
InnerStruct.createInnerStruct(builder, item === null || item === void 0 ? void 0 : item.a, item === null || item === void 0 ? void 0 : item.b, item === null || item === void 0 ? void 0 : item.c, item === null || item === void 0 ? void 0 : item.dUnderscore);
}
builder.prep(8, 32);
builder.writeInt64(BigInt(c_underscore_d_underscore !== null && c_underscore_d_underscore !== void 0 ? c_underscore_d_underscore : 0));
builder.pad(2);
builder.writeInt8(c_underscore_c);
for (let i = 12; i >= 0; --i) {
builder.writeInt8(((_c = c_underscore_b === null || c_underscore_b === void 0 ? void 0 : c_underscore_b[i]) !== null && _c !== void 0 ? _c : 0));
}
builder.writeFloat64(c_underscore_a);
builder.writeFloat64(b);
builder.pad(7);
builder.writeInt8(Number(Boolean(a)));
return builder.offset();
}
unpack() {
return new OuterStructT(this.a(), this.b(), (this.cUnderscore() !== null ? this.cUnderscore().unpack() : null), this.bb.createObjList(this.d.bind(this), 3), (this.e() !== null ? this.e().unpack() : null), this.bb.createScalarList(this.f.bind(this), 4));
}
unpackTo(_o) {
_o.a = this.a();
_o.b = this.b();
_o.cUnderscore = (this.cUnderscore() !== null ? this.cUnderscore().unpack() : null);
_o.d = this.bb.createObjList(this.d.bind(this), 3);
_o.e = (this.e() !== null ? this.e().unpack() : null);
_o.f = this.bb.createScalarList(this.f.bind(this), 4);
}
}
export class OuterStructT {
constructor(a = false, b = 0.0, cUnderscore = null, d = [], e = null, f = []) {
this.a = a;
this.b = b;
this.cUnderscore = cUnderscore;
this.d = d;
this.e = e;
this.f = f;
}
pack(builder) {
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _p, _q, _r, _s;
return OuterStruct.createOuterStruct(builder, this.a, this.b, ((_b = (_a = this.cUnderscore) === null || _a === void 0 ? void 0 : _a.a) !== null && _b !== void 0 ? _b : 0), ((_d = (_c = this.cUnderscore) === null || _c === void 0 ? void 0 : _c.b) !== null && _d !== void 0 ? _d : []), ((_f = (_e = this.cUnderscore) === null || _e === void 0 ? void 0 : _e.c) !== null && _f !== void 0 ? _f : 0), ((_h = (_g = this.cUnderscore) === null || _g === void 0 ? void 0 : _g.dUnderscore) !== null && _h !== void 0 ? _h : BigInt(0)), this.d, ((_k = (_j = this.e) === null || _j === void 0 ? void 0 : _j.a) !== null && _k !== void 0 ? _k : 0), ((_m = (_l = this.e) === null || _l === void 0 ? void 0 : _l.b) !== null && _m !== void 0 ? _m : []), ((_q = (_p = this.e) === null || _p === void 0 ? void 0 : _p.c) !== null && _q !== void 0 ? _q : 0), ((_s = (_r = this.e) === null || _r === void 0 ? void 0 : _r.dUnderscore) !== null && _s !== void 0 ? _s : BigInt(0)), this.f);
}
}
export class NestedStruct {
constructor() {
this.bb = null;
this.bb_pos = 0;
}
__init(i, bb) {
this.bb_pos = i;
this.bb = bb;
return this;
}
a(index) {
return this.bb.readInt32(this.bb_pos + 0 + index * 4);
}
b() {
return this.bb.readInt8(this.bb_pos + 8);
}
cUnderscore(index) {
return this.bb.readInt8(this.bb_pos + 9 + index);
}
dOuter(index, obj) {
return (obj || new OuterStruct()).__init(this.bb_pos + 16 + index * 208, this.bb);
}
e(index) {
return this.bb.readInt64(this.bb_pos + 1056 + index * 8);
}
static getFullyQualifiedName() {
return 'MyGame.Example.NestedStruct';
}
static sizeOf() {
return 1072;
}
static createNestedStruct(builder, a, b, c_underscore, d_outer, e) {
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _p, _q, _r, _s, _t, _u, _v;
builder.prep(8, 1072);
for (let i = 1; i >= 0; --i) {
builder.writeInt64(BigInt((_a = e === null || e === void 0 ? void 0 : e[i]) !== null && _a !== void 0 ? _a : 0));
}
for (let i = 4; i >= 0; --i) {
const item = d_outer === null || d_outer === void 0 ? void 0 : d_outer[i];
if (item instanceof OuterStructT) {
item.pack(builder);
continue;
}
OuterStruct.createOuterStruct(builder, item === null || item === void 0 ? void 0 : item.a, item === null || item === void 0 ? void 0 : item.b, ((_c = (_b = item === null || item === void 0 ? void 0 : item.cUnderscore) === null || _b === void 0 ? void 0 : _b.a) !== null && _c !== void 0 ? _c : 0), ((_e = (_d = item === null || item === void 0 ? void 0 : item.cUnderscore) === null || _d === void 0 ? void 0 : _d.b) !== null && _e !== void 0 ? _e : []), ((_g = (_f = item === null || item === void 0 ? void 0 : item.cUnderscore) === null || _f === void 0 ? void 0 : _f.c) !== null && _g !== void 0 ? _g : 0), ((_j = (_h = item === null || item === void 0 ? void 0 : item.cUnderscore) === null || _h === void 0 ? void 0 : _h.dUnderscore) !== null && _j !== void 0 ? _j : BigInt(0)), item === null || item === void 0 ? void 0 : item.d, ((_l = (_k = item === null || item === void 0 ? void 0 : item.e) === null || _k === void 0 ? void 0 : _k.a) !== null && _l !== void 0 ? _l : 0), ((_p = (_m = item === null || item === void 0 ? void 0 : item.e) === null || _m === void 0 ? void 0 : _m.b) !== null && _p !== void 0 ? _p : []), ((_r = (_q = item === null || item === void 0 ? void 0 : item.e) === null || _q === void 0 ? void 0 : _q.c) !== null && _r !== void 0 ? _r : 0), ((_t = (_s = item === null || item === void 0 ? void 0 : item.e) === null || _s === void 0 ? void 0 : _s.dUnderscore) !== null && _t !== void 0 ? _t : BigInt(0)), item === null || item === void 0 ? void 0 : item.f);
}
builder.pad(5);
for (let i = 1; i >= 0; --i) {
builder.writeInt8(((_u = c_underscore === null || c_underscore === void 0 ? void 0 : c_underscore[i]) !== null && _u !== void 0 ? _u : 0));
}
builder.writeInt8(b);
for (let i = 1; i >= 0; --i) {
builder.writeInt32(((_v = a === null || a === void 0 ? void 0 : a[i]) !== null && _v !== void 0 ? _v : 0));
}
return builder.offset();
}
unpack() {
return new NestedStructT(this.bb.createScalarList(this.a.bind(this), 2), this.b(), this.bb.createScalarList(this.cUnderscore.bind(this), 2), this.bb.createObjList(this.dOuter.bind(this), 5), this.bb.createScalarList(this.e.bind(this), 2));
}
unpackTo(_o) {
_o.a = this.bb.createScalarList(this.a.bind(this), 2);
_o.b = this.b();
_o.cUnderscore = this.bb.createScalarList(this.cUnderscore.bind(this), 2);
_o.dOuter = this.bb.createObjList(this.dOuter.bind(this), 5);
_o.e = this.bb.createScalarList(this.e.bind(this), 2);
}
}
export class NestedStructT {
constructor(a = [], b = TestEnum.A, cUnderscore = [TestEnum.A, TestEnum.A], dOuter = [], e = []) {
this.a = a;
this.b = b;
this.cUnderscore = cUnderscore;
this.dOuter = dOuter;
this.e = e;
}
pack(builder) {
return NestedStruct.createNestedStruct(builder, this.a, this.b, this.cUnderscore, this.dOuter, this.e);
}
}
export class ArrayStruct {
constructor() {
this.bb = null;
this.bb_pos = 0;
}
__init(i, bb) {
this.bb_pos = i;
this.bb = bb;
return this;
}
aUnderscore() {
return this.bb.readFloat32(this.bb_pos);
}
bUnderscore(index) {
return this.bb.readInt32(this.bb_pos + 4 + index * 4);
}
c() {
return this.bb.readInt8(this.bb_pos + 64);
}
d(index, obj) {
return (obj || new NestedStruct()).__init(this.bb_pos + 72 + index * 1072, this.bb);
}
e() {
return this.bb.readInt32(this.bb_pos + 2216);
}
f(index, obj) {
return (obj || new OuterStruct()).__init(this.bb_pos + 2224 + index * 208, this.bb);
}
g(index) {
return this.bb.readInt64(this.bb_pos + 2640 + index * 8);
}
static getFullyQualifiedName() {
return 'MyGame.Example.ArrayStruct';
}
static sizeOf() {
return 2656;
}
static createArrayStruct(builder, a_underscore, b_underscore, c, d, e, f, g) {
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _p, _q, _r, _s, _t, _u;
builder.prep(8, 2656);
for (let i = 1; i >= 0; --i) {
builder.writeInt64(BigInt((_a = g === null || g === void 0 ? void 0 : g[i]) !== null && _a !== void 0 ? _a : 0));
}
for (let i = 1; i >= 0; --i) {
const item = f === null || f === void 0 ? void 0 : f[i];
if (item instanceof OuterStructT) {
item.pack(builder);
continue;
}
OuterStruct.createOuterStruct(builder, item === null || item === void 0 ? void 0 : item.a, item === null || item === void 0 ? void 0 : item.b, ((_c = (_b = item === null || item === void 0 ? void 0 : item.cUnderscore) === null || _b === void 0 ? void 0 : _b.a) !== null && _c !== void 0 ? _c : 0), ((_e = (_d = item === null || item === void 0 ? void 0 : item.cUnderscore) === null || _d === void 0 ? void 0 : _d.b) !== null && _e !== void 0 ? _e : []), ((_g = (_f = item === null || item === void 0 ? void 0 : item.cUnderscore) === null || _f === void 0 ? void 0 : _f.c) !== null && _g !== void 0 ? _g : 0), ((_j = (_h = item === null || item === void 0 ? void 0 : item.cUnderscore) === null || _h === void 0 ? void 0 : _h.dUnderscore) !== null && _j !== void 0 ? _j : BigInt(0)), item === null || item === void 0 ? void 0 : item.d, ((_l = (_k = item === null || item === void 0 ? void 0 : item.e) === null || _k === void 0 ? void 0 : _k.a) !== null && _l !== void 0 ? _l : 0), ((_p = (_m = item === null || item === void 0 ? void 0 : item.e) === null || _m === void 0 ? void 0 : _m.b) !== null && _p !== void 0 ? _p : []), ((_r = (_q = item === null || item === void 0 ? void 0 : item.e) === null || _q === void 0 ? void 0 : _q.c) !== null && _r !== void 0 ? _r : 0), ((_t = (_s = item === null || item === void 0 ? void 0 : item.e) === null || _s === void 0 ? void 0 : _s.dUnderscore) !== null && _t !== void 0 ? _t : BigInt(0)), item === null || item === void 0 ? void 0 : item.f);
}
builder.pad(4);
builder.writeInt32(e);
for (let i = 1; i >= 0; --i) {
const item = d === null || d === void 0 ? void 0 : d[i];
if (item instanceof NestedStructT) {
item.pack(builder);
continue;
}
NestedStruct.createNestedStruct(builder, item === null || item === void 0 ? void 0 : item.a, item === null || item === void 0 ? void 0 : item.b, item === null || item === void 0 ? void 0 : item.cUnderscore, item === null || item === void 0 ? void 0 : item.dOuter, item === null || item === void 0 ? void 0 : item.e);
}
builder.pad(7);
builder.writeInt8(c);
for (let i = 14; i >= 0; --i) {
builder.writeInt32(((_u = b_underscore === null || b_underscore === void 0 ? void 0 : b_underscore[i]) !== null && _u !== void 0 ? _u : 0));
}
builder.writeFloat32(a_underscore);
return builder.offset();
}
unpack() {
return new ArrayStructT(this.aUnderscore(), this.bb.createScalarList(this.bUnderscore.bind(this), 15), this.c(), this.bb.createObjList(this.d.bind(this), 2), this.e(), this.bb.createObjList(this.f.bind(this), 2), this.bb.createScalarList(this.g.bind(this), 2));
}
unpackTo(_o) {
_o.aUnderscore = this.aUnderscore();
_o.bUnderscore = this.bb.createScalarList(this.bUnderscore.bind(this), 15);
_o.c = this.c();
_o.d = this.bb.createObjList(this.d.bind(this), 2);
_o.e = this.e();
_o.f = this.bb.createObjList(this.f.bind(this), 2);
_o.g = this.bb.createScalarList(this.g.bind(this), 2);
}
}
export class ArrayStructT {
constructor(aUnderscore = 0.0, bUnderscore = [], c = 0, d = [], e = 0, f = [], g = []) {
this.aUnderscore = aUnderscore;
this.bUnderscore = bUnderscore;
this.c = c;
this.d = d;
this.e = e;
this.f = f;
this.g = g;
}
pack(builder) {
return ArrayStruct.createArrayStruct(builder, this.aUnderscore, this.bUnderscore, this.c, this.d, this.e, this.f, this.g);
}
}
export class ArrayTable {
constructor() {
this.bb = null;
this.bb_pos = 0;
}
__init(i, bb) {
this.bb_pos = i;
this.bb = bb;
return this;
}
static getRootAsArrayTable(bb, obj) {
return (obj || new ArrayTable()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}
static getSizePrefixedRootAsArrayTable(bb, obj) {
bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
return (obj || new ArrayTable()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}
static bufferHasIdentifier(bb) {
return bb.__has_identifier('RHUB');
}
a(optionalEncoding) {
const offset = this.bb.__offset(this.bb_pos, 4);
return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null;
}
cUnderscore(obj) {
const offset = this.bb.__offset(this.bb_pos, 6);
return offset ? (obj || new ArrayStruct()).__init(this.bb_pos + offset, this.bb) : null;
}
static getFullyQualifiedName() {
return 'MyGame.Example.ArrayTable';
}
static startArrayTable(builder) {
builder.startObject(2);
}
static addA(builder, aOffset) {
builder.addFieldOffset(0, aOffset, 0);
}
static addCUnderscore(builder, cUnderscoreOffset) {
builder.addFieldStruct(1, cUnderscoreOffset, 0);
}
static endArrayTable(builder) {
const offset = builder.endObject();
return offset;
}
static finishArrayTableBuffer(builder, offset) {
builder.finish(offset, 'RHUB');
}
static finishSizePrefixedArrayTableBuffer(builder, offset) {
builder.finish(offset, 'RHUB', true);
}
unpack() {
return new ArrayTableT(this.a(), (this.cUnderscore() !== null ? this.cUnderscore().unpack() : null));
}
unpackTo(_o) {
_o.a = this.a();
_o.cUnderscore = (this.cUnderscore() !== null ? this.cUnderscore().unpack() : null);
}
}
export class ArrayTableT {
constructor(a = null, cUnderscore = null) {
this.a = a;
this.cUnderscore = cUnderscore;
}
pack(builder) {
const a = (this.a !== null ? builder.createString(this.a) : 0);
ArrayTable.startArrayTable(builder);
ArrayTable.addA(builder, a);
ArrayTable.addCUnderscore(builder, (this.cUnderscore !== null ? this.cUnderscore.pack(builder) : 0));
return ArrayTable.endArrayTable(builder);
}
}

View File

@@ -1,626 +0,0 @@
// automatically generated by the FlatBuffers compiler, do not modify
import * as flatbuffers from 'flatbuffers';
export enum TestEnum {
A = 0,
B = 1,
C = 2
}
export class InnerStruct implements flatbuffers.IUnpackableObject<InnerStructT> {
bb: flatbuffers.ByteBuffer|null = null;
bb_pos = 0;
__init(i:number, bb:flatbuffers.ByteBuffer):InnerStruct {
this.bb_pos = i;
this.bb = bb;
return this;
}
a():number {
return this.bb!.readFloat64(this.bb_pos);
}
b(index: number):number|null {
return this.bb!.readUint8(this.bb_pos + 8 + index);
}
c():number {
return this.bb!.readInt8(this.bb_pos + 21);
}
dUnderscore():bigint {
return this.bb!.readInt64(this.bb_pos + 24);
}
static getFullyQualifiedName():string {
return 'MyGame.Example.InnerStruct';
}
static sizeOf():number {
return 32;
}
static createInnerStruct(builder:flatbuffers.Builder, a: number, b: number[]|null, c: number, d_underscore: bigint):flatbuffers.Offset {
builder.prep(8, 32);
builder.writeInt64(BigInt(d_underscore ?? 0));
builder.pad(2);
builder.writeInt8(c);
for (let i = 12; i >= 0; --i) {
builder.writeInt8((b?.[i] ?? 0));
}
builder.writeFloat64(a);
return builder.offset();
}
unpack(): InnerStructT {
return new InnerStructT(
this.a(),
this.bb!.createScalarList<number>(this.b.bind(this), 13),
this.c(),
this.dUnderscore()
);
}
unpackTo(_o: InnerStructT): void {
_o.a = this.a();
_o.b = this.bb!.createScalarList<number>(this.b.bind(this), 13);
_o.c = this.c();
_o.dUnderscore = this.dUnderscore();
}
}
export class InnerStructT implements flatbuffers.IGeneratedObject {
constructor(
public a: number = 0.0,
public b: (number)[] = [],
public c: number = 0,
public dUnderscore: bigint = BigInt('0')
){}
pack(builder:flatbuffers.Builder): flatbuffers.Offset {
return InnerStruct.createInnerStruct(builder,
this.a,
this.b,
this.c,
this.dUnderscore
);
}
}
export class OuterStruct implements flatbuffers.IUnpackableObject<OuterStructT> {
bb: flatbuffers.ByteBuffer|null = null;
bb_pos = 0;
__init(i:number, bb:flatbuffers.ByteBuffer):OuterStruct {
this.bb_pos = i;
this.bb = bb;
return this;
}
a():boolean {
return !!this.bb!.readInt8(this.bb_pos);
}
b():number {
return this.bb!.readFloat64(this.bb_pos + 8);
}
cUnderscore(obj?:InnerStruct):InnerStruct|null {
return (obj || new InnerStruct()).__init(this.bb_pos + 16, this.bb!);
}
d(index: number, obj?:InnerStruct):InnerStruct|null {
return (obj || new InnerStruct()).__init(this.bb_pos + 48 + index * 32, this.bb!);
}
e(obj?:InnerStruct):InnerStruct|null {
return (obj || new InnerStruct()).__init(this.bb_pos + 144, this.bb!);
}
f(index: number):number|null {
return this.bb!.readFloat64(this.bb_pos + 176 + index * 8);
}
static getFullyQualifiedName():string {
return 'MyGame.Example.OuterStruct';
}
static sizeOf():number {
return 208;
}
static createOuterStruct(builder:flatbuffers.Builder, a: boolean, b: number, c_underscore_a: number, c_underscore_b: number[]|null, c_underscore_c: number, c_underscore_d_underscore: bigint, d: (any|InnerStructT)[]|null, e_a: number, e_b: number[]|null, e_c: number, e_d_underscore: bigint, f: number[]|null):flatbuffers.Offset {
builder.prep(8, 208);
for (let i = 3; i >= 0; --i) {
builder.writeFloat64((f?.[i] ?? 0));
}
builder.prep(8, 32);
builder.writeInt64(BigInt(e_d_underscore ?? 0));
builder.pad(2);
builder.writeInt8(e_c);
for (let i = 12; i >= 0; --i) {
builder.writeInt8((e_b?.[i] ?? 0));
}
builder.writeFloat64(e_a);
for (let i = 2; i >= 0; --i) {
const item = d?.[i];
if (item instanceof InnerStructT) {
item.pack(builder);
continue;
}
InnerStruct.createInnerStruct(builder,
item?.a,
item?.b,
item?.c,
item?.dUnderscore
);
}
builder.prep(8, 32);
builder.writeInt64(BigInt(c_underscore_d_underscore ?? 0));
builder.pad(2);
builder.writeInt8(c_underscore_c);
for (let i = 12; i >= 0; --i) {
builder.writeInt8((c_underscore_b?.[i] ?? 0));
}
builder.writeFloat64(c_underscore_a);
builder.writeFloat64(b);
builder.pad(7);
builder.writeInt8(Number(Boolean(a)));
return builder.offset();
}
unpack(): OuterStructT {
return new OuterStructT(
this.a(),
this.b(),
(this.cUnderscore() !== null ? this.cUnderscore()!.unpack() : null),
this.bb!.createObjList<InnerStruct, InnerStructT>(this.d.bind(this), 3),
(this.e() !== null ? this.e()!.unpack() : null),
this.bb!.createScalarList<number>(this.f.bind(this), 4)
);
}
unpackTo(_o: OuterStructT): void {
_o.a = this.a();
_o.b = this.b();
_o.cUnderscore = (this.cUnderscore() !== null ? this.cUnderscore()!.unpack() : null);
_o.d = this.bb!.createObjList<InnerStruct, InnerStructT>(this.d.bind(this), 3);
_o.e = (this.e() !== null ? this.e()!.unpack() : null);
_o.f = this.bb!.createScalarList<number>(this.f.bind(this), 4);
}
}
export class OuterStructT implements flatbuffers.IGeneratedObject {
constructor(
public a: boolean = false,
public b: number = 0.0,
public cUnderscore: InnerStructT|null = null,
public d: (InnerStructT)[] = [],
public e: InnerStructT|null = null,
public f: (number)[] = []
){}
pack(builder:flatbuffers.Builder): flatbuffers.Offset {
return OuterStruct.createOuterStruct(builder,
this.a,
this.b,
(this.cUnderscore?.a ?? 0),
(this.cUnderscore?.b ?? []),
(this.cUnderscore?.c ?? 0),
(this.cUnderscore?.dUnderscore ?? BigInt(0)),
this.d,
(this.e?.a ?? 0),
(this.e?.b ?? []),
(this.e?.c ?? 0),
(this.e?.dUnderscore ?? BigInt(0)),
this.f
);
}
}
export class NestedStruct implements flatbuffers.IUnpackableObject<NestedStructT> {
bb: flatbuffers.ByteBuffer|null = null;
bb_pos = 0;
__init(i:number, bb:flatbuffers.ByteBuffer):NestedStruct {
this.bb_pos = i;
this.bb = bb;
return this;
}
a(index: number):number|null {
return this.bb!.readInt32(this.bb_pos + 0 + index * 4);
}
b():TestEnum {
return this.bb!.readInt8(this.bb_pos + 8);
}
cUnderscore(index: number):TestEnum|null {
return this.bb!.readInt8(this.bb_pos + 9 + index);
}
dOuter(index: number, obj?:OuterStruct):OuterStruct|null {
return (obj || new OuterStruct()).__init(this.bb_pos + 16 + index * 208, this.bb!);
}
e(index: number):bigint|null {
return this.bb!.readInt64(this.bb_pos + 1056 + index * 8);
}
static getFullyQualifiedName():string {
return 'MyGame.Example.NestedStruct';
}
static sizeOf():number {
return 1072;
}
static createNestedStruct(builder:flatbuffers.Builder, a: number[]|null, b: TestEnum, c_underscore: number[]|null, d_outer: (any|OuterStructT)[]|null, e: bigint[]|null):flatbuffers.Offset {
builder.prep(8, 1072);
for (let i = 1; i >= 0; --i) {
builder.writeInt64(BigInt(e?.[i] ?? 0));
}
for (let i = 4; i >= 0; --i) {
const item = d_outer?.[i];
if (item instanceof OuterStructT) {
item.pack(builder);
continue;
}
OuterStruct.createOuterStruct(builder,
item?.a,
item?.b,
(item?.cUnderscore?.a ?? 0),
(item?.cUnderscore?.b ?? []),
(item?.cUnderscore?.c ?? 0),
(item?.cUnderscore?.dUnderscore ?? BigInt(0)),
item?.d,
(item?.e?.a ?? 0),
(item?.e?.b ?? []),
(item?.e?.c ?? 0),
(item?.e?.dUnderscore ?? BigInt(0)),
item?.f
);
}
builder.pad(5);
for (let i = 1; i >= 0; --i) {
builder.writeInt8((c_underscore?.[i] ?? 0));
}
builder.writeInt8(b);
for (let i = 1; i >= 0; --i) {
builder.writeInt32((a?.[i] ?? 0));
}
return builder.offset();
}
unpack(): NestedStructT {
return new NestedStructT(
this.bb!.createScalarList<number>(this.a.bind(this), 2),
this.b(),
this.bb!.createScalarList<TestEnum>(this.cUnderscore.bind(this), 2),
this.bb!.createObjList<OuterStruct, OuterStructT>(this.dOuter.bind(this), 5),
this.bb!.createScalarList<bigint>(this.e.bind(this), 2)
);
}
unpackTo(_o: NestedStructT): void {
_o.a = this.bb!.createScalarList<number>(this.a.bind(this), 2);
_o.b = this.b();
_o.cUnderscore = this.bb!.createScalarList<TestEnum>(this.cUnderscore.bind(this), 2);
_o.dOuter = this.bb!.createObjList<OuterStruct, OuterStructT>(this.dOuter.bind(this), 5);
_o.e = this.bb!.createScalarList<bigint>(this.e.bind(this), 2);
}
}
export class NestedStructT implements flatbuffers.IGeneratedObject {
constructor(
public a: (number)[] = [],
public b: TestEnum = TestEnum.A,
public cUnderscore: (TestEnum)[] = [TestEnum.A, TestEnum.A],
public dOuter: (OuterStructT)[] = [],
public e: (bigint)[] = []
){}
pack(builder:flatbuffers.Builder): flatbuffers.Offset {
return NestedStruct.createNestedStruct(builder,
this.a,
this.b,
this.cUnderscore,
this.dOuter,
this.e
);
}
}
export class ArrayStruct implements flatbuffers.IUnpackableObject<ArrayStructT> {
bb: flatbuffers.ByteBuffer|null = null;
bb_pos = 0;
__init(i:number, bb:flatbuffers.ByteBuffer):ArrayStruct {
this.bb_pos = i;
this.bb = bb;
return this;
}
aUnderscore():number {
return this.bb!.readFloat32(this.bb_pos);
}
bUnderscore(index: number):number|null {
return this.bb!.readInt32(this.bb_pos + 4 + index * 4);
}
c():number {
return this.bb!.readInt8(this.bb_pos + 64);
}
d(index: number, obj?:NestedStruct):NestedStruct|null {
return (obj || new NestedStruct()).__init(this.bb_pos + 72 + index * 1072, this.bb!);
}
e():number {
return this.bb!.readInt32(this.bb_pos + 2216);
}
f(index: number, obj?:OuterStruct):OuterStruct|null {
return (obj || new OuterStruct()).__init(this.bb_pos + 2224 + index * 208, this.bb!);
}
g(index: number):bigint|null {
return this.bb!.readInt64(this.bb_pos + 2640 + index * 8);
}
static getFullyQualifiedName():string {
return 'MyGame.Example.ArrayStruct';
}
static sizeOf():number {
return 2656;
}
static createArrayStruct(builder:flatbuffers.Builder, a_underscore: number, b_underscore: number[]|null, c: number, d: (any|NestedStructT)[]|null, e: number, f: (any|OuterStructT)[]|null, g: bigint[]|null):flatbuffers.Offset {
builder.prep(8, 2656);
for (let i = 1; i >= 0; --i) {
builder.writeInt64(BigInt(g?.[i] ?? 0));
}
for (let i = 1; i >= 0; --i) {
const item = f?.[i];
if (item instanceof OuterStructT) {
item.pack(builder);
continue;
}
OuterStruct.createOuterStruct(builder,
item?.a,
item?.b,
(item?.cUnderscore?.a ?? 0),
(item?.cUnderscore?.b ?? []),
(item?.cUnderscore?.c ?? 0),
(item?.cUnderscore?.dUnderscore ?? BigInt(0)),
item?.d,
(item?.e?.a ?? 0),
(item?.e?.b ?? []),
(item?.e?.c ?? 0),
(item?.e?.dUnderscore ?? BigInt(0)),
item?.f
);
}
builder.pad(4);
builder.writeInt32(e);
for (let i = 1; i >= 0; --i) {
const item = d?.[i];
if (item instanceof NestedStructT) {
item.pack(builder);
continue;
}
NestedStruct.createNestedStruct(builder,
item?.a,
item?.b,
item?.cUnderscore,
item?.dOuter,
item?.e
);
}
builder.pad(7);
builder.writeInt8(c);
for (let i = 14; i >= 0; --i) {
builder.writeInt32((b_underscore?.[i] ?? 0));
}
builder.writeFloat32(a_underscore);
return builder.offset();
}
unpack(): ArrayStructT {
return new ArrayStructT(
this.aUnderscore(),
this.bb!.createScalarList<number>(this.bUnderscore.bind(this), 15),
this.c(),
this.bb!.createObjList<NestedStruct, NestedStructT>(this.d.bind(this), 2),
this.e(),
this.bb!.createObjList<OuterStruct, OuterStructT>(this.f.bind(this), 2),
this.bb!.createScalarList<bigint>(this.g.bind(this), 2)
);
}
unpackTo(_o: ArrayStructT): void {
_o.aUnderscore = this.aUnderscore();
_o.bUnderscore = this.bb!.createScalarList<number>(this.bUnderscore.bind(this), 15);
_o.c = this.c();
_o.d = this.bb!.createObjList<NestedStruct, NestedStructT>(this.d.bind(this), 2);
_o.e = this.e();
_o.f = this.bb!.createObjList<OuterStruct, OuterStructT>(this.f.bind(this), 2);
_o.g = this.bb!.createScalarList<bigint>(this.g.bind(this), 2);
}
}
export class ArrayStructT implements flatbuffers.IGeneratedObject {
constructor(
public aUnderscore: number = 0.0,
public bUnderscore: (number)[] = [],
public c: number = 0,
public d: (NestedStructT)[] = [],
public e: number = 0,
public f: (OuterStructT)[] = [],
public g: (bigint)[] = []
){}
pack(builder:flatbuffers.Builder): flatbuffers.Offset {
return ArrayStruct.createArrayStruct(builder,
this.aUnderscore,
this.bUnderscore,
this.c,
this.d,
this.e,
this.f,
this.g
);
}
}
export class ArrayTable implements flatbuffers.IUnpackableObject<ArrayTableT> {
bb: flatbuffers.ByteBuffer|null = null;
bb_pos = 0;
__init(i:number, bb:flatbuffers.ByteBuffer):ArrayTable {
this.bb_pos = i;
this.bb = bb;
return this;
}
static getRootAsArrayTable(bb:flatbuffers.ByteBuffer, obj?:ArrayTable):ArrayTable {
return (obj || new ArrayTable()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}
static getSizePrefixedRootAsArrayTable(bb:flatbuffers.ByteBuffer, obj?:ArrayTable):ArrayTable {
bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
return (obj || new ArrayTable()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}
static bufferHasIdentifier(bb:flatbuffers.ByteBuffer):boolean {
return bb.__has_identifier('RHUB');
}
a():string|null
a(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
a(optionalEncoding?:any):string|Uint8Array|null {
const offset = this.bb!.__offset(this.bb_pos, 4);
return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
}
cUnderscore(obj?:ArrayStruct):ArrayStruct|null {
const offset = this.bb!.__offset(this.bb_pos, 6);
return offset ? (obj || new ArrayStruct()).__init(this.bb_pos + offset, this.bb!) : null;
}
static getFullyQualifiedName():string {
return 'MyGame.Example.ArrayTable';
}
static startArrayTable(builder:flatbuffers.Builder) {
builder.startObject(2);
}
static addA(builder:flatbuffers.Builder, aOffset:flatbuffers.Offset) {
builder.addFieldOffset(0, aOffset, 0);
}
static addCUnderscore(builder:flatbuffers.Builder, cUnderscoreOffset:flatbuffers.Offset) {
builder.addFieldStruct(1, cUnderscoreOffset, 0);
}
static endArrayTable(builder:flatbuffers.Builder):flatbuffers.Offset {
const offset = builder.endObject();
return offset;
}
static finishArrayTableBuffer(builder:flatbuffers.Builder, offset:flatbuffers.Offset) {
builder.finish(offset, 'RHUB');
}
static finishSizePrefixedArrayTableBuffer(builder:flatbuffers.Builder, offset:flatbuffers.Offset) {
builder.finish(offset, 'RHUB', true);
}
unpack(): ArrayTableT {
return new ArrayTableT(
this.a(),
(this.cUnderscore() !== null ? this.cUnderscore()!.unpack() : null)
);
}
unpackTo(_o: ArrayTableT): void {
_o.a = this.a();
_o.cUnderscore = (this.cUnderscore() !== null ? this.cUnderscore()!.unpack() : null);
}
}
export class ArrayTableT implements flatbuffers.IGeneratedObject {
constructor(
public a: string|Uint8Array|null = null,
public cUnderscore: ArrayStructT|null = null
){}
pack(builder:flatbuffers.Builder): flatbuffers.Offset {
const a = (this.a !== null ? builder.createString(this.a!) : 0);
ArrayTable.startArrayTable(builder);
ArrayTable.addA(builder, a);
ArrayTable.addCUnderscore(builder, (this.cUnderscore !== null ? this.cUnderscore!.pack(builder) : 0));
return ArrayTable.endArrayTable(builder);
}
}

View File

@@ -0,0 +1,6 @@
export { ArrayStruct } from './example/array-struct.js';
export { ArrayTable } from './example/array-table.js';
export { InnerStruct } from './example/inner-struct.js';
export { NestedStruct } from './example/nested-struct.js';
export { OuterStruct } from './example/outer-struct.js';
export { TestEnum } from './example/test-enum.js';

View File

@@ -0,0 +1,7 @@
// automatically generated by the FlatBuffers compiler, do not modify
export { ArrayStruct } from './example/array-struct.js';
export { ArrayTable } from './example/array-table.js';
export { InnerStruct } from './example/inner-struct.js';
export { NestedStruct } from './example/nested-struct.js';
export { OuterStruct } from './example/outer-struct.js';
export { TestEnum } from './example/test-enum.js';

View File

@@ -0,0 +1,8 @@
// automatically generated by the FlatBuffers compiler, do not modify
export { ArrayStruct } from './example/array-struct.js';
export { ArrayTable } from './example/array-table.js';
export { InnerStruct } from './example/inner-struct.js';
export { NestedStruct } from './example/nested-struct.js';
export { OuterStruct } from './example/outer-struct.js';
export { TestEnum } from './example/test-enum.js';

View File

@@ -0,0 +1,31 @@
import * as flatbuffers from 'flatbuffers';
import { NestedStruct, NestedStructT } from '../../my-game/example/nested-struct.js';
import { OuterStruct, OuterStructT } from '../../my-game/example/outer-struct.js';
export declare class ArrayStruct implements flatbuffers.IUnpackableObject<ArrayStructT> {
bb: flatbuffers.ByteBuffer | null;
bb_pos: number;
__init(i: number, bb: flatbuffers.ByteBuffer): ArrayStruct;
aUnderscore(): number;
bUnderscore(index: number): number | null;
c(): number;
d(index: number, obj?: NestedStruct): NestedStruct | null;
e(): number;
f(index: number, obj?: OuterStruct): OuterStruct | null;
g(index: number): bigint | null;
static getFullyQualifiedName(): string;
static sizeOf(): number;
static createArrayStruct(builder: flatbuffers.Builder, a_underscore: number, b_underscore: number[] | null, c: number, d: (any | NestedStructT)[] | null, e: number, f: (any | OuterStructT)[] | null, g: bigint[] | null): flatbuffers.Offset;
unpack(): ArrayStructT;
unpackTo(_o: ArrayStructT): void;
}
export declare class ArrayStructT implements flatbuffers.IGeneratedObject {
aUnderscore: number;
bUnderscore: (number)[];
c: number;
d: (NestedStructT)[];
e: number;
f: (OuterStructT)[];
g: (bigint)[];
constructor(aUnderscore?: number, bUnderscore?: (number)[], c?: number, d?: (NestedStructT)[], e?: number, f?: (OuterStructT)[], g?: (bigint)[]);
pack(builder: flatbuffers.Builder): flatbuffers.Offset;
}

View File

@@ -0,0 +1,98 @@
// automatically generated by the FlatBuffers compiler, do not modify
import { NestedStruct, NestedStructT } from '../../my-game/example/nested-struct.js';
import { OuterStruct, OuterStructT } from '../../my-game/example/outer-struct.js';
export class ArrayStruct {
constructor() {
this.bb = null;
this.bb_pos = 0;
}
__init(i, bb) {
this.bb_pos = i;
this.bb = bb;
return this;
}
aUnderscore() {
return this.bb.readFloat32(this.bb_pos);
}
bUnderscore(index) {
return this.bb.readInt32(this.bb_pos + 4 + index * 4);
}
c() {
return this.bb.readInt8(this.bb_pos + 64);
}
d(index, obj) {
return (obj || new NestedStruct()).__init(this.bb_pos + 72 + index * 1072, this.bb);
}
e() {
return this.bb.readInt32(this.bb_pos + 2216);
}
f(index, obj) {
return (obj || new OuterStruct()).__init(this.bb_pos + 2224 + index * 208, this.bb);
}
g(index) {
return this.bb.readInt64(this.bb_pos + 2640 + index * 8);
}
static getFullyQualifiedName() {
return 'MyGame.Example.ArrayStruct';
}
static sizeOf() {
return 2656;
}
static createArrayStruct(builder, a_underscore, b_underscore, c, d, e, f, g) {
builder.prep(8, 2656);
for (let i = 1; i >= 0; --i) {
builder.writeInt64(BigInt(g?.[i] ?? 0));
}
for (let i = 1; i >= 0; --i) {
const item = f?.[i];
if (item instanceof OuterStructT) {
item.pack(builder);
continue;
}
OuterStruct.createOuterStruct(builder, item?.a, item?.b, (item?.cUnderscore?.a ?? 0), (item?.cUnderscore?.b ?? []), (item?.cUnderscore?.c ?? 0), (item?.cUnderscore?.dUnderscore ?? BigInt(0)), item?.d, (item?.e?.a ?? 0), (item?.e?.b ?? []), (item?.e?.c ?? 0), (item?.e?.dUnderscore ?? BigInt(0)), item?.f);
}
builder.pad(4);
builder.writeInt32(e);
for (let i = 1; i >= 0; --i) {
const item = d?.[i];
if (item instanceof NestedStructT) {
item.pack(builder);
continue;
}
NestedStruct.createNestedStruct(builder, item?.a, item?.b, item?.cUnderscore, item?.dOuter, item?.e);
}
builder.pad(7);
builder.writeInt8(c);
for (let i = 14; i >= 0; --i) {
builder.writeInt32((b_underscore?.[i] ?? 0));
}
builder.writeFloat32(a_underscore);
return builder.offset();
}
unpack() {
return new ArrayStructT(this.aUnderscore(), this.bb.createScalarList(this.bUnderscore.bind(this), 15), this.c(), this.bb.createObjList(this.d.bind(this), 2), this.e(), this.bb.createObjList(this.f.bind(this), 2), this.bb.createScalarList(this.g.bind(this), 2));
}
unpackTo(_o) {
_o.aUnderscore = this.aUnderscore();
_o.bUnderscore = this.bb.createScalarList(this.bUnderscore.bind(this), 15);
_o.c = this.c();
_o.d = this.bb.createObjList(this.d.bind(this), 2);
_o.e = this.e();
_o.f = this.bb.createObjList(this.f.bind(this), 2);
_o.g = this.bb.createScalarList(this.g.bind(this), 2);
}
}
export class ArrayStructT {
constructor(aUnderscore = 0.0, bUnderscore = [], c = 0, d = [], e = 0, f = [], g = []) {
this.aUnderscore = aUnderscore;
this.bUnderscore = bUnderscore;
this.c = c;
this.d = d;
this.e = e;
this.f = f;
this.g = g;
}
pack(builder) {
return ArrayStruct.createArrayStruct(builder, this.aUnderscore, this.bUnderscore, this.c, this.d, this.e, this.f, this.g);
}
}

View File

@@ -0,0 +1,166 @@
// automatically generated by the FlatBuffers compiler, do not modify
import * as flatbuffers from 'flatbuffers';
import { NestedStruct, NestedStructT } from '../../my-game/example/nested-struct.js';
import { OuterStruct, OuterStructT } from '../../my-game/example/outer-struct.js';
export class ArrayStruct implements flatbuffers.IUnpackableObject<ArrayStructT> {
bb: flatbuffers.ByteBuffer|null = null;
bb_pos = 0;
__init(i:number, bb:flatbuffers.ByteBuffer):ArrayStruct {
this.bb_pos = i;
this.bb = bb;
return this;
}
aUnderscore():number {
return this.bb!.readFloat32(this.bb_pos);
}
bUnderscore(index: number):number|null {
return this.bb!.readInt32(this.bb_pos + 4 + index * 4);
}
c():number {
return this.bb!.readInt8(this.bb_pos + 64);
}
d(index: number, obj?:NestedStruct):NestedStruct|null {
return (obj || new NestedStruct()).__init(this.bb_pos + 72 + index * 1072, this.bb!);
}
e():number {
return this.bb!.readInt32(this.bb_pos + 2216);
}
f(index: number, obj?:OuterStruct):OuterStruct|null {
return (obj || new OuterStruct()).__init(this.bb_pos + 2224 + index * 208, this.bb!);
}
g(index: number):bigint|null {
return this.bb!.readInt64(this.bb_pos + 2640 + index * 8);
}
static getFullyQualifiedName():string {
return 'MyGame.Example.ArrayStruct';
}
static sizeOf():number {
return 2656;
}
static createArrayStruct(builder:flatbuffers.Builder, a_underscore: number, b_underscore: number[]|null, c: number, d: (any|NestedStructT)[]|null, e: number, f: (any|OuterStructT)[]|null, g: bigint[]|null):flatbuffers.Offset {
builder.prep(8, 2656);
for (let i = 1; i >= 0; --i) {
builder.writeInt64(BigInt(g?.[i] ?? 0));
}
for (let i = 1; i >= 0; --i) {
const item = f?.[i];
if (item instanceof OuterStructT) {
item.pack(builder);
continue;
}
OuterStruct.createOuterStruct(builder,
item?.a,
item?.b,
(item?.cUnderscore?.a ?? 0),
(item?.cUnderscore?.b ?? []),
(item?.cUnderscore?.c ?? 0),
(item?.cUnderscore?.dUnderscore ?? BigInt(0)),
item?.d,
(item?.e?.a ?? 0),
(item?.e?.b ?? []),
(item?.e?.c ?? 0),
(item?.e?.dUnderscore ?? BigInt(0)),
item?.f
);
}
builder.pad(4);
builder.writeInt32(e);
for (let i = 1; i >= 0; --i) {
const item = d?.[i];
if (item instanceof NestedStructT) {
item.pack(builder);
continue;
}
NestedStruct.createNestedStruct(builder,
item?.a,
item?.b,
item?.cUnderscore,
item?.dOuter,
item?.e
);
}
builder.pad(7);
builder.writeInt8(c);
for (let i = 14; i >= 0; --i) {
builder.writeInt32((b_underscore?.[i] ?? 0));
}
builder.writeFloat32(a_underscore);
return builder.offset();
}
unpack(): ArrayStructT {
return new ArrayStructT(
this.aUnderscore(),
this.bb!.createScalarList<number>(this.bUnderscore.bind(this), 15),
this.c(),
this.bb!.createObjList<NestedStruct, NestedStructT>(this.d.bind(this), 2),
this.e(),
this.bb!.createObjList<OuterStruct, OuterStructT>(this.f.bind(this), 2),
this.bb!.createScalarList<bigint>(this.g.bind(this), 2)
);
}
unpackTo(_o: ArrayStructT): void {
_o.aUnderscore = this.aUnderscore();
_o.bUnderscore = this.bb!.createScalarList<number>(this.bUnderscore.bind(this), 15);
_o.c = this.c();
_o.d = this.bb!.createObjList<NestedStruct, NestedStructT>(this.d.bind(this), 2);
_o.e = this.e();
_o.f = this.bb!.createObjList<OuterStruct, OuterStructT>(this.f.bind(this), 2);
_o.g = this.bb!.createScalarList<bigint>(this.g.bind(this), 2);
}
}
export class ArrayStructT implements flatbuffers.IGeneratedObject {
constructor(
public aUnderscore: number = 0.0,
public bUnderscore: (number)[] = [],
public c: number = 0,
public d: (NestedStructT)[] = [],
public e: number = 0,
public f: (OuterStructT)[] = [],
public g: (bigint)[] = []
){}
pack(builder:flatbuffers.Builder): flatbuffers.Offset {
return ArrayStruct.createArrayStruct(builder,
this.aUnderscore,
this.bUnderscore,
this.c,
this.d,
this.e,
this.f,
this.g
);
}
}

View File

@@ -0,0 +1,28 @@
import * as flatbuffers from 'flatbuffers';
import { ArrayStruct, ArrayStructT } from '../../my-game/example/array-struct.js';
export declare class ArrayTable implements flatbuffers.IUnpackableObject<ArrayTableT> {
bb: flatbuffers.ByteBuffer | null;
bb_pos: number;
__init(i: number, bb: flatbuffers.ByteBuffer): ArrayTable;
static getRootAsArrayTable(bb: flatbuffers.ByteBuffer, obj?: ArrayTable): ArrayTable;
static getSizePrefixedRootAsArrayTable(bb: flatbuffers.ByteBuffer, obj?: ArrayTable): ArrayTable;
static bufferHasIdentifier(bb: flatbuffers.ByteBuffer): boolean;
a(): string | null;
a(optionalEncoding: flatbuffers.Encoding): string | Uint8Array | null;
cUnderscore(obj?: ArrayStruct): ArrayStruct | null;
static getFullyQualifiedName(): string;
static startArrayTable(builder: flatbuffers.Builder): void;
static addA(builder: flatbuffers.Builder, aOffset: flatbuffers.Offset): void;
static addCUnderscore(builder: flatbuffers.Builder, cUnderscoreOffset: flatbuffers.Offset): void;
static endArrayTable(builder: flatbuffers.Builder): flatbuffers.Offset;
static finishArrayTableBuffer(builder: flatbuffers.Builder, offset: flatbuffers.Offset): void;
static finishSizePrefixedArrayTableBuffer(builder: flatbuffers.Builder, offset: flatbuffers.Offset): void;
unpack(): ArrayTableT;
unpackTo(_o: ArrayTableT): void;
}
export declare class ArrayTableT implements flatbuffers.IGeneratedObject {
a: string | Uint8Array | null;
cUnderscore: ArrayStructT | null;
constructor(a?: string | Uint8Array | null, cUnderscore?: ArrayStructT | null);
pack(builder: flatbuffers.Builder): flatbuffers.Offset;
}

View File

@@ -0,0 +1,74 @@
// automatically generated by the FlatBuffers compiler, do not modify
import * as flatbuffers from 'flatbuffers';
import { ArrayStruct } from '../../my-game/example/array-struct.js';
export class ArrayTable {
constructor() {
this.bb = null;
this.bb_pos = 0;
}
__init(i, bb) {
this.bb_pos = i;
this.bb = bb;
return this;
}
static getRootAsArrayTable(bb, obj) {
return (obj || new ArrayTable()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}
static getSizePrefixedRootAsArrayTable(bb, obj) {
bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
return (obj || new ArrayTable()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}
static bufferHasIdentifier(bb) {
return bb.__has_identifier('RHUB');
}
a(optionalEncoding) {
const offset = this.bb.__offset(this.bb_pos, 4);
return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null;
}
cUnderscore(obj) {
const offset = this.bb.__offset(this.bb_pos, 6);
return offset ? (obj || new ArrayStruct()).__init(this.bb_pos + offset, this.bb) : null;
}
static getFullyQualifiedName() {
return 'MyGame.Example.ArrayTable';
}
static startArrayTable(builder) {
builder.startObject(2);
}
static addA(builder, aOffset) {
builder.addFieldOffset(0, aOffset, 0);
}
static addCUnderscore(builder, cUnderscoreOffset) {
builder.addFieldStruct(1, cUnderscoreOffset, 0);
}
static endArrayTable(builder) {
const offset = builder.endObject();
return offset;
}
static finishArrayTableBuffer(builder, offset) {
builder.finish(offset, 'RHUB');
}
static finishSizePrefixedArrayTableBuffer(builder, offset) {
builder.finish(offset, 'RHUB', true);
}
unpack() {
return new ArrayTableT(this.a(), (this.cUnderscore() !== null ? this.cUnderscore().unpack() : null));
}
unpackTo(_o) {
_o.a = this.a();
_o.cUnderscore = (this.cUnderscore() !== null ? this.cUnderscore().unpack() : null);
}
}
export class ArrayTableT {
constructor(a = null, cUnderscore = null) {
this.a = a;
this.cUnderscore = cUnderscore;
}
pack(builder) {
const a = (this.a !== null ? builder.createString(this.a) : 0);
ArrayTable.startArrayTable(builder);
ArrayTable.addA(builder, a);
ArrayTable.addCUnderscore(builder, (this.cUnderscore !== null ? this.cUnderscore.pack(builder) : 0));
return ArrayTable.endArrayTable(builder);
}
}

View File

@@ -0,0 +1,102 @@
// automatically generated by the FlatBuffers compiler, do not modify
import * as flatbuffers from 'flatbuffers';
import { ArrayStruct, ArrayStructT } from '../../my-game/example/array-struct.js';
export class ArrayTable implements flatbuffers.IUnpackableObject<ArrayTableT> {
bb: flatbuffers.ByteBuffer|null = null;
bb_pos = 0;
__init(i:number, bb:flatbuffers.ByteBuffer):ArrayTable {
this.bb_pos = i;
this.bb = bb;
return this;
}
static getRootAsArrayTable(bb:flatbuffers.ByteBuffer, obj?:ArrayTable):ArrayTable {
return (obj || new ArrayTable()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}
static getSizePrefixedRootAsArrayTable(bb:flatbuffers.ByteBuffer, obj?:ArrayTable):ArrayTable {
bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
return (obj || new ArrayTable()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}
static bufferHasIdentifier(bb:flatbuffers.ByteBuffer):boolean {
return bb.__has_identifier('RHUB');
}
a():string|null
a(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
a(optionalEncoding?:any):string|Uint8Array|null {
const offset = this.bb!.__offset(this.bb_pos, 4);
return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
}
cUnderscore(obj?:ArrayStruct):ArrayStruct|null {
const offset = this.bb!.__offset(this.bb_pos, 6);
return offset ? (obj || new ArrayStruct()).__init(this.bb_pos + offset, this.bb!) : null;
}
static getFullyQualifiedName():string {
return 'MyGame.Example.ArrayTable';
}
static startArrayTable(builder:flatbuffers.Builder) {
builder.startObject(2);
}
static addA(builder:flatbuffers.Builder, aOffset:flatbuffers.Offset) {
builder.addFieldOffset(0, aOffset, 0);
}
static addCUnderscore(builder:flatbuffers.Builder, cUnderscoreOffset:flatbuffers.Offset) {
builder.addFieldStruct(1, cUnderscoreOffset, 0);
}
static endArrayTable(builder:flatbuffers.Builder):flatbuffers.Offset {
const offset = builder.endObject();
return offset;
}
static finishArrayTableBuffer(builder:flatbuffers.Builder, offset:flatbuffers.Offset) {
builder.finish(offset, 'RHUB');
}
static finishSizePrefixedArrayTableBuffer(builder:flatbuffers.Builder, offset:flatbuffers.Offset) {
builder.finish(offset, 'RHUB', true);
}
unpack(): ArrayTableT {
return new ArrayTableT(
this.a(),
(this.cUnderscore() !== null ? this.cUnderscore()!.unpack() : null)
);
}
unpackTo(_o: ArrayTableT): void {
_o.a = this.a();
_o.cUnderscore = (this.cUnderscore() !== null ? this.cUnderscore()!.unpack() : null);
}
}
export class ArrayTableT implements flatbuffers.IGeneratedObject {
constructor(
public a: string|Uint8Array|null = null,
public cUnderscore: ArrayStructT|null = null
){}
pack(builder:flatbuffers.Builder): flatbuffers.Offset {
const a = (this.a !== null ? builder.createString(this.a!) : 0);
ArrayTable.startArrayTable(builder);
ArrayTable.addA(builder, a);
ArrayTable.addCUnderscore(builder, (this.cUnderscore !== null ? this.cUnderscore!.pack(builder) : 0));
return ArrayTable.endArrayTable(builder);
}
}

View File

@@ -0,0 +1,23 @@
import * as flatbuffers from 'flatbuffers';
export declare class InnerStruct implements flatbuffers.IUnpackableObject<InnerStructT> {
bb: flatbuffers.ByteBuffer | null;
bb_pos: number;
__init(i: number, bb: flatbuffers.ByteBuffer): InnerStruct;
a(): number;
b(index: number): number | null;
c(): number;
dUnderscore(): bigint;
static getFullyQualifiedName(): string;
static sizeOf(): number;
static createInnerStruct(builder: flatbuffers.Builder, a: number, b: number[] | null, c: number, d_underscore: bigint): flatbuffers.Offset;
unpack(): InnerStructT;
unpackTo(_o: InnerStructT): void;
}
export declare class InnerStructT implements flatbuffers.IGeneratedObject {
a: number;
b: (number)[];
c: number;
dUnderscore: bigint;
constructor(a?: number, b?: (number)[], c?: number, dUnderscore?: bigint);
pack(builder: flatbuffers.Builder): flatbuffers.Offset;
}

View File

@@ -0,0 +1,61 @@
// automatically generated by the FlatBuffers compiler, do not modify
export class InnerStruct {
constructor() {
this.bb = null;
this.bb_pos = 0;
}
__init(i, bb) {
this.bb_pos = i;
this.bb = bb;
return this;
}
a() {
return this.bb.readFloat64(this.bb_pos);
}
b(index) {
return this.bb.readUint8(this.bb_pos + 8 + index);
}
c() {
return this.bb.readInt8(this.bb_pos + 21);
}
dUnderscore() {
return this.bb.readInt64(this.bb_pos + 24);
}
static getFullyQualifiedName() {
return 'MyGame.Example.InnerStruct';
}
static sizeOf() {
return 32;
}
static createInnerStruct(builder, a, b, c, d_underscore) {
builder.prep(8, 32);
builder.writeInt64(BigInt(d_underscore ?? 0));
builder.pad(2);
builder.writeInt8(c);
for (let i = 12; i >= 0; --i) {
builder.writeInt8((b?.[i] ?? 0));
}
builder.writeFloat64(a);
return builder.offset();
}
unpack() {
return new InnerStructT(this.a(), this.bb.createScalarList(this.b.bind(this), 13), this.c(), this.dUnderscore());
}
unpackTo(_o) {
_o.a = this.a();
_o.b = this.bb.createScalarList(this.b.bind(this), 13);
_o.c = this.c();
_o.dUnderscore = this.dUnderscore();
}
}
export class InnerStructT {
constructor(a = 0.0, b = [], c = 0, dUnderscore = BigInt('0')) {
this.a = a;
this.b = b;
this.c = c;
this.dUnderscore = dUnderscore;
}
pack(builder) {
return InnerStruct.createInnerStruct(builder, this.a, this.b, this.c, this.dUnderscore);
}
}

View File

@@ -0,0 +1,91 @@
// automatically generated by the FlatBuffers compiler, do not modify
import * as flatbuffers from 'flatbuffers';
export class InnerStruct implements flatbuffers.IUnpackableObject<InnerStructT> {
bb: flatbuffers.ByteBuffer|null = null;
bb_pos = 0;
__init(i:number, bb:flatbuffers.ByteBuffer):InnerStruct {
this.bb_pos = i;
this.bb = bb;
return this;
}
a():number {
return this.bb!.readFloat64(this.bb_pos);
}
b(index: number):number|null {
return this.bb!.readUint8(this.bb_pos + 8 + index);
}
c():number {
return this.bb!.readInt8(this.bb_pos + 21);
}
dUnderscore():bigint {
return this.bb!.readInt64(this.bb_pos + 24);
}
static getFullyQualifiedName():string {
return 'MyGame.Example.InnerStruct';
}
static sizeOf():number {
return 32;
}
static createInnerStruct(builder:flatbuffers.Builder, a: number, b: number[]|null, c: number, d_underscore: bigint):flatbuffers.Offset {
builder.prep(8, 32);
builder.writeInt64(BigInt(d_underscore ?? 0));
builder.pad(2);
builder.writeInt8(c);
for (let i = 12; i >= 0; --i) {
builder.writeInt8((b?.[i] ?? 0));
}
builder.writeFloat64(a);
return builder.offset();
}
unpack(): InnerStructT {
return new InnerStructT(
this.a(),
this.bb!.createScalarList<number>(this.b.bind(this), 13),
this.c(),
this.dUnderscore()
);
}
unpackTo(_o: InnerStructT): void {
_o.a = this.a();
_o.b = this.bb!.createScalarList<number>(this.b.bind(this), 13);
_o.c = this.c();
_o.dUnderscore = this.dUnderscore();
}
}
export class InnerStructT implements flatbuffers.IGeneratedObject {
constructor(
public a: number = 0.0,
public b: (number)[] = [],
public c: number = 0,
public dUnderscore: bigint = BigInt('0')
){}
pack(builder:flatbuffers.Builder): flatbuffers.Offset {
return InnerStruct.createInnerStruct(builder,
this.a,
this.b,
this.c,
this.dUnderscore
);
}
}

View File

@@ -0,0 +1,27 @@
import * as flatbuffers from 'flatbuffers';
import { OuterStruct, OuterStructT } from '../../my-game/example/outer-struct.js';
import { TestEnum } from '../../my-game/example/test-enum.js';
export declare class NestedStruct implements flatbuffers.IUnpackableObject<NestedStructT> {
bb: flatbuffers.ByteBuffer | null;
bb_pos: number;
__init(i: number, bb: flatbuffers.ByteBuffer): NestedStruct;
a(index: number): number | null;
b(): TestEnum;
cUnderscore(index: number): TestEnum | null;
dOuter(index: number, obj?: OuterStruct): OuterStruct | null;
e(index: number): bigint | null;
static getFullyQualifiedName(): string;
static sizeOf(): number;
static createNestedStruct(builder: flatbuffers.Builder, a: number[] | null, b: TestEnum, c_underscore: number[] | null, d_outer: (any | OuterStructT)[] | null, e: bigint[] | null): flatbuffers.Offset;
unpack(): NestedStructT;
unpackTo(_o: NestedStructT): void;
}
export declare class NestedStructT implements flatbuffers.IGeneratedObject {
a: (number)[];
b: TestEnum;
cUnderscore: (TestEnum)[];
dOuter: (OuterStructT)[];
e: (bigint)[];
constructor(a?: (number)[], b?: TestEnum, cUnderscore?: (TestEnum)[], dOuter?: (OuterStructT)[], e?: (bigint)[]);
pack(builder: flatbuffers.Builder): flatbuffers.Offset;
}

View File

@@ -0,0 +1,80 @@
// automatically generated by the FlatBuffers compiler, do not modify
import { OuterStruct, OuterStructT } from '../../my-game/example/outer-struct.js';
import { TestEnum } from '../../my-game/example/test-enum.js';
export class NestedStruct {
constructor() {
this.bb = null;
this.bb_pos = 0;
}
__init(i, bb) {
this.bb_pos = i;
this.bb = bb;
return this;
}
a(index) {
return this.bb.readInt32(this.bb_pos + 0 + index * 4);
}
b() {
return this.bb.readInt8(this.bb_pos + 8);
}
cUnderscore(index) {
return this.bb.readInt8(this.bb_pos + 9 + index);
}
dOuter(index, obj) {
return (obj || new OuterStruct()).__init(this.bb_pos + 16 + index * 208, this.bb);
}
e(index) {
return this.bb.readInt64(this.bb_pos + 1056 + index * 8);
}
static getFullyQualifiedName() {
return 'MyGame.Example.NestedStruct';
}
static sizeOf() {
return 1072;
}
static createNestedStruct(builder, a, b, c_underscore, d_outer, e) {
builder.prep(8, 1072);
for (let i = 1; i >= 0; --i) {
builder.writeInt64(BigInt(e?.[i] ?? 0));
}
for (let i = 4; i >= 0; --i) {
const item = d_outer?.[i];
if (item instanceof OuterStructT) {
item.pack(builder);
continue;
}
OuterStruct.createOuterStruct(builder, item?.a, item?.b, (item?.cUnderscore?.a ?? 0), (item?.cUnderscore?.b ?? []), (item?.cUnderscore?.c ?? 0), (item?.cUnderscore?.dUnderscore ?? BigInt(0)), item?.d, (item?.e?.a ?? 0), (item?.e?.b ?? []), (item?.e?.c ?? 0), (item?.e?.dUnderscore ?? BigInt(0)), item?.f);
}
builder.pad(5);
for (let i = 1; i >= 0; --i) {
builder.writeInt8((c_underscore?.[i] ?? 0));
}
builder.writeInt8(b);
for (let i = 1; i >= 0; --i) {
builder.writeInt32((a?.[i] ?? 0));
}
return builder.offset();
}
unpack() {
return new NestedStructT(this.bb.createScalarList(this.a.bind(this), 2), this.b(), this.bb.createScalarList(this.cUnderscore.bind(this), 2), this.bb.createObjList(this.dOuter.bind(this), 5), this.bb.createScalarList(this.e.bind(this), 2));
}
unpackTo(_o) {
_o.a = this.bb.createScalarList(this.a.bind(this), 2);
_o.b = this.b();
_o.cUnderscore = this.bb.createScalarList(this.cUnderscore.bind(this), 2);
_o.dOuter = this.bb.createObjList(this.dOuter.bind(this), 5);
_o.e = this.bb.createScalarList(this.e.bind(this), 2);
}
}
export class NestedStructT {
constructor(a = [], b = TestEnum.A, cUnderscore = [TestEnum.A, TestEnum.A], dOuter = [], e = []) {
this.a = a;
this.b = b;
this.cUnderscore = cUnderscore;
this.dOuter = dOuter;
this.e = e;
}
pack(builder) {
return NestedStruct.createNestedStruct(builder, this.a, this.b, this.cUnderscore, this.dOuter, this.e);
}
}

View File

@@ -0,0 +1,135 @@
// automatically generated by the FlatBuffers compiler, do not modify
import * as flatbuffers from 'flatbuffers';
import { OuterStruct, OuterStructT } from '../../my-game/example/outer-struct.js';
import { TestEnum } from '../../my-game/example/test-enum.js';
export class NestedStruct implements flatbuffers.IUnpackableObject<NestedStructT> {
bb: flatbuffers.ByteBuffer|null = null;
bb_pos = 0;
__init(i:number, bb:flatbuffers.ByteBuffer):NestedStruct {
this.bb_pos = i;
this.bb = bb;
return this;
}
a(index: number):number|null {
return this.bb!.readInt32(this.bb_pos + 0 + index * 4);
}
b():TestEnum {
return this.bb!.readInt8(this.bb_pos + 8);
}
cUnderscore(index: number):TestEnum|null {
return this.bb!.readInt8(this.bb_pos + 9 + index);
}
dOuter(index: number, obj?:OuterStruct):OuterStruct|null {
return (obj || new OuterStruct()).__init(this.bb_pos + 16 + index * 208, this.bb!);
}
e(index: number):bigint|null {
return this.bb!.readInt64(this.bb_pos + 1056 + index * 8);
}
static getFullyQualifiedName():string {
return 'MyGame.Example.NestedStruct';
}
static sizeOf():number {
return 1072;
}
static createNestedStruct(builder:flatbuffers.Builder, a: number[]|null, b: TestEnum, c_underscore: number[]|null, d_outer: (any|OuterStructT)[]|null, e: bigint[]|null):flatbuffers.Offset {
builder.prep(8, 1072);
for (let i = 1; i >= 0; --i) {
builder.writeInt64(BigInt(e?.[i] ?? 0));
}
for (let i = 4; i >= 0; --i) {
const item = d_outer?.[i];
if (item instanceof OuterStructT) {
item.pack(builder);
continue;
}
OuterStruct.createOuterStruct(builder,
item?.a,
item?.b,
(item?.cUnderscore?.a ?? 0),
(item?.cUnderscore?.b ?? []),
(item?.cUnderscore?.c ?? 0),
(item?.cUnderscore?.dUnderscore ?? BigInt(0)),
item?.d,
(item?.e?.a ?? 0),
(item?.e?.b ?? []),
(item?.e?.c ?? 0),
(item?.e?.dUnderscore ?? BigInt(0)),
item?.f
);
}
builder.pad(5);
for (let i = 1; i >= 0; --i) {
builder.writeInt8((c_underscore?.[i] ?? 0));
}
builder.writeInt8(b);
for (let i = 1; i >= 0; --i) {
builder.writeInt32((a?.[i] ?? 0));
}
return builder.offset();
}
unpack(): NestedStructT {
return new NestedStructT(
this.bb!.createScalarList<number>(this.a.bind(this), 2),
this.b(),
this.bb!.createScalarList<TestEnum>(this.cUnderscore.bind(this), 2),
this.bb!.createObjList<OuterStruct, OuterStructT>(this.dOuter.bind(this), 5),
this.bb!.createScalarList<bigint>(this.e.bind(this), 2)
);
}
unpackTo(_o: NestedStructT): void {
_o.a = this.bb!.createScalarList<number>(this.a.bind(this), 2);
_o.b = this.b();
_o.cUnderscore = this.bb!.createScalarList<TestEnum>(this.cUnderscore.bind(this), 2);
_o.dOuter = this.bb!.createObjList<OuterStruct, OuterStructT>(this.dOuter.bind(this), 5);
_o.e = this.bb!.createScalarList<bigint>(this.e.bind(this), 2);
}
}
export class NestedStructT implements flatbuffers.IGeneratedObject {
constructor(
public a: (number)[] = [],
public b: TestEnum = TestEnum.A,
public cUnderscore: (TestEnum)[] = [TestEnum.A, TestEnum.A],
public dOuter: (OuterStructT)[] = [],
public e: (bigint)[] = []
){}
pack(builder:flatbuffers.Builder): flatbuffers.Offset {
return NestedStruct.createNestedStruct(builder,
this.a,
this.b,
this.cUnderscore,
this.dOuter,
this.e
);
}
}

View File

@@ -0,0 +1,28 @@
import * as flatbuffers from 'flatbuffers';
import { InnerStruct, InnerStructT } from '../../my-game/example/inner-struct.js';
export declare class OuterStruct implements flatbuffers.IUnpackableObject<OuterStructT> {
bb: flatbuffers.ByteBuffer | null;
bb_pos: number;
__init(i: number, bb: flatbuffers.ByteBuffer): OuterStruct;
a(): boolean;
b(): number;
cUnderscore(obj?: InnerStruct): InnerStruct | null;
d(index: number, obj?: InnerStruct): InnerStruct | null;
e(obj?: InnerStruct): InnerStruct | null;
f(index: number): number | null;
static getFullyQualifiedName(): string;
static sizeOf(): number;
static createOuterStruct(builder: flatbuffers.Builder, a: boolean, b: number, c_underscore_a: number, c_underscore_b: number[] | null, c_underscore_c: number, c_underscore_d_underscore: bigint, d: (any | InnerStructT)[] | null, e_a: number, e_b: number[] | null, e_c: number, e_d_underscore: bigint, f: number[] | null): flatbuffers.Offset;
unpack(): OuterStructT;
unpackTo(_o: OuterStructT): void;
}
export declare class OuterStructT implements flatbuffers.IGeneratedObject {
a: boolean;
b: number;
cUnderscore: InnerStructT | null;
d: (InnerStructT)[];
e: InnerStructT | null;
f: (number)[];
constructor(a?: boolean, b?: number, cUnderscore?: InnerStructT | null, d?: (InnerStructT)[], e?: InnerStructT | null, f?: (number)[]);
pack(builder: flatbuffers.Builder): flatbuffers.Offset;
}

View File

@@ -0,0 +1,95 @@
// automatically generated by the FlatBuffers compiler, do not modify
import { InnerStruct, InnerStructT } from '../../my-game/example/inner-struct.js';
export class OuterStruct {
constructor() {
this.bb = null;
this.bb_pos = 0;
}
__init(i, bb) {
this.bb_pos = i;
this.bb = bb;
return this;
}
a() {
return !!this.bb.readInt8(this.bb_pos);
}
b() {
return this.bb.readFloat64(this.bb_pos + 8);
}
cUnderscore(obj) {
return (obj || new InnerStruct()).__init(this.bb_pos + 16, this.bb);
}
d(index, obj) {
return (obj || new InnerStruct()).__init(this.bb_pos + 48 + index * 32, this.bb);
}
e(obj) {
return (obj || new InnerStruct()).__init(this.bb_pos + 144, this.bb);
}
f(index) {
return this.bb.readFloat64(this.bb_pos + 176 + index * 8);
}
static getFullyQualifiedName() {
return 'MyGame.Example.OuterStruct';
}
static sizeOf() {
return 208;
}
static createOuterStruct(builder, a, b, c_underscore_a, c_underscore_b, c_underscore_c, c_underscore_d_underscore, d, e_a, e_b, e_c, e_d_underscore, f) {
builder.prep(8, 208);
for (let i = 3; i >= 0; --i) {
builder.writeFloat64((f?.[i] ?? 0));
}
builder.prep(8, 32);
builder.writeInt64(BigInt(e_d_underscore ?? 0));
builder.pad(2);
builder.writeInt8(e_c);
for (let i = 12; i >= 0; --i) {
builder.writeInt8((e_b?.[i] ?? 0));
}
builder.writeFloat64(e_a);
for (let i = 2; i >= 0; --i) {
const item = d?.[i];
if (item instanceof InnerStructT) {
item.pack(builder);
continue;
}
InnerStruct.createInnerStruct(builder, item?.a, item?.b, item?.c, item?.dUnderscore);
}
builder.prep(8, 32);
builder.writeInt64(BigInt(c_underscore_d_underscore ?? 0));
builder.pad(2);
builder.writeInt8(c_underscore_c);
for (let i = 12; i >= 0; --i) {
builder.writeInt8((c_underscore_b?.[i] ?? 0));
}
builder.writeFloat64(c_underscore_a);
builder.writeFloat64(b);
builder.pad(7);
builder.writeInt8(Number(Boolean(a)));
return builder.offset();
}
unpack() {
return new OuterStructT(this.a(), this.b(), (this.cUnderscore() !== null ? this.cUnderscore().unpack() : null), this.bb.createObjList(this.d.bind(this), 3), (this.e() !== null ? this.e().unpack() : null), this.bb.createScalarList(this.f.bind(this), 4));
}
unpackTo(_o) {
_o.a = this.a();
_o.b = this.b();
_o.cUnderscore = (this.cUnderscore() !== null ? this.cUnderscore().unpack() : null);
_o.d = this.bb.createObjList(this.d.bind(this), 3);
_o.e = (this.e() !== null ? this.e().unpack() : null);
_o.f = this.bb.createScalarList(this.f.bind(this), 4);
}
}
export class OuterStructT {
constructor(a = false, b = 0.0, cUnderscore = null, d = [], e = null, f = []) {
this.a = a;
this.b = b;
this.cUnderscore = cUnderscore;
this.d = d;
this.e = e;
this.f = f;
}
pack(builder) {
return OuterStruct.createOuterStruct(builder, this.a, this.b, (this.cUnderscore?.a ?? 0), (this.cUnderscore?.b ?? []), (this.cUnderscore?.c ?? 0), (this.cUnderscore?.dUnderscore ?? BigInt(0)), this.d, (this.e?.a ?? 0), (this.e?.b ?? []), (this.e?.c ?? 0), (this.e?.dUnderscore ?? BigInt(0)), this.f);
}
}

View File

@@ -0,0 +1,152 @@
// automatically generated by the FlatBuffers compiler, do not modify
import * as flatbuffers from 'flatbuffers';
import { InnerStruct, InnerStructT } from '../../my-game/example/inner-struct.js';
export class OuterStruct implements flatbuffers.IUnpackableObject<OuterStructT> {
bb: flatbuffers.ByteBuffer|null = null;
bb_pos = 0;
__init(i:number, bb:flatbuffers.ByteBuffer):OuterStruct {
this.bb_pos = i;
this.bb = bb;
return this;
}
a():boolean {
return !!this.bb!.readInt8(this.bb_pos);
}
b():number {
return this.bb!.readFloat64(this.bb_pos + 8);
}
cUnderscore(obj?:InnerStruct):InnerStruct|null {
return (obj || new InnerStruct()).__init(this.bb_pos + 16, this.bb!);
}
d(index: number, obj?:InnerStruct):InnerStruct|null {
return (obj || new InnerStruct()).__init(this.bb_pos + 48 + index * 32, this.bb!);
}
e(obj?:InnerStruct):InnerStruct|null {
return (obj || new InnerStruct()).__init(this.bb_pos + 144, this.bb!);
}
f(index: number):number|null {
return this.bb!.readFloat64(this.bb_pos + 176 + index * 8);
}
static getFullyQualifiedName():string {
return 'MyGame.Example.OuterStruct';
}
static sizeOf():number {
return 208;
}
static createOuterStruct(builder:flatbuffers.Builder, a: boolean, b: number, c_underscore_a: number, c_underscore_b: number[]|null, c_underscore_c: number, c_underscore_d_underscore: bigint, d: (any|InnerStructT)[]|null, e_a: number, e_b: number[]|null, e_c: number, e_d_underscore: bigint, f: number[]|null):flatbuffers.Offset {
builder.prep(8, 208);
for (let i = 3; i >= 0; --i) {
builder.writeFloat64((f?.[i] ?? 0));
}
builder.prep(8, 32);
builder.writeInt64(BigInt(e_d_underscore ?? 0));
builder.pad(2);
builder.writeInt8(e_c);
for (let i = 12; i >= 0; --i) {
builder.writeInt8((e_b?.[i] ?? 0));
}
builder.writeFloat64(e_a);
for (let i = 2; i >= 0; --i) {
const item = d?.[i];
if (item instanceof InnerStructT) {
item.pack(builder);
continue;
}
InnerStruct.createInnerStruct(builder,
item?.a,
item?.b,
item?.c,
item?.dUnderscore
);
}
builder.prep(8, 32);
builder.writeInt64(BigInt(c_underscore_d_underscore ?? 0));
builder.pad(2);
builder.writeInt8(c_underscore_c);
for (let i = 12; i >= 0; --i) {
builder.writeInt8((c_underscore_b?.[i] ?? 0));
}
builder.writeFloat64(c_underscore_a);
builder.writeFloat64(b);
builder.pad(7);
builder.writeInt8(Number(Boolean(a)));
return builder.offset();
}
unpack(): OuterStructT {
return new OuterStructT(
this.a(),
this.b(),
(this.cUnderscore() !== null ? this.cUnderscore()!.unpack() : null),
this.bb!.createObjList<InnerStruct, InnerStructT>(this.d.bind(this), 3),
(this.e() !== null ? this.e()!.unpack() : null),
this.bb!.createScalarList<number>(this.f.bind(this), 4)
);
}
unpackTo(_o: OuterStructT): void {
_o.a = this.a();
_o.b = this.b();
_o.cUnderscore = (this.cUnderscore() !== null ? this.cUnderscore()!.unpack() : null);
_o.d = this.bb!.createObjList<InnerStruct, InnerStructT>(this.d.bind(this), 3);
_o.e = (this.e() !== null ? this.e()!.unpack() : null);
_o.f = this.bb!.createScalarList<number>(this.f.bind(this), 4);
}
}
export class OuterStructT implements flatbuffers.IGeneratedObject {
constructor(
public a: boolean = false,
public b: number = 0.0,
public cUnderscore: InnerStructT|null = null,
public d: (InnerStructT)[] = [],
public e: InnerStructT|null = null,
public f: (number)[] = []
){}
pack(builder:flatbuffers.Builder): flatbuffers.Offset {
return OuterStruct.createOuterStruct(builder,
this.a,
this.b,
(this.cUnderscore?.a ?? 0),
(this.cUnderscore?.b ?? []),
(this.cUnderscore?.c ?? 0),
(this.cUnderscore?.dUnderscore ?? BigInt(0)),
this.d,
(this.e?.a ?? 0),
(this.e?.b ?? []),
(this.e?.c ?? 0),
(this.e?.dUnderscore ?? BigInt(0)),
this.f
);
}
}

View File

@@ -0,0 +1,5 @@
export declare enum TestEnum {
A = 0,
B = 1,
C = 2
}

View File

@@ -0,0 +1,7 @@
// automatically generated by the FlatBuffers compiler, do not modify
export var TestEnum;
(function (TestEnum) {
TestEnum[TestEnum["A"] = 0] = "A";
TestEnum[TestEnum["B"] = 1] = "B";
TestEnum[TestEnum["C"] = 2] = "C";
})(TestEnum = TestEnum || (TestEnum = {}));

View File

@@ -1,8 +1,7 @@
// automatically generated by the FlatBuffers compiler, do not modify
export enum EnumInNestedNS{
export enum TestEnum {
A = 0,
B = 1,
C = 2
}

1
tests/ts/foobar.d.ts vendored Normal file
View File

@@ -0,0 +1 @@
export { Abc } from './foobar/abc.js';

2
tests/ts/foobar.js Normal file
View File

@@ -0,0 +1,2 @@
// automatically generated by the FlatBuffers compiler, do not modify
export { Abc } from './foobar/abc.js';

View File

@@ -1,7 +1,3 @@
// automatically generated by the FlatBuffers compiler, do not modify
export enum Abc {
a = 0
}
export { Abc } from './foobar/abc.js';

3
tests/ts/foobar/abc.d.ts vendored Normal file
View File

@@ -0,0 +1,3 @@
export declare enum Abc {
a = 0
}

View File

@@ -2,4 +2,4 @@
export var Abc;
(function (Abc) {
Abc[Abc["a"] = 0] = "a";
})(Abc || (Abc = {}));
})(Abc = Abc || (Abc = {}));

3
tests/ts/foobar/class.d.ts vendored Normal file
View File

@@ -0,0 +1,3 @@
export declare enum class_ {
arguments_ = 0
}

Some files were not shown because too many files have changed in this diff Show More