Partial support for --ts-flat-files and --gen-all (#7446)

* Partial support for --ts-flat-files and --gen-all

* Add generated code changes

* remove some debugging code left over

* missed grpc files
This commit is contained in:
Derek Bailey
2022-08-15 16:11:45 -07:00
committed by GitHub
parent a3508f36d5
commit a66de58af9
38 changed files with 241 additions and 99 deletions

View File

@@ -7,7 +7,7 @@ import * as flatbuffers from 'flatbuffers';
export class HelloReply { export class HelloReply {
bb: flatbuffers.ByteBuffer|null = null; bb: flatbuffers.ByteBuffer|null = null;
bb_pos = 0; bb_pos = 0;
__init(i:number, bb:flatbuffers.ByteBuffer):HelloReply { __init(i:number, bb:flatbuffers.ByteBuffer):HelloReply {
this.bb_pos = i; this.bb_pos = i;
this.bb = bb; this.bb = bb;
return this; return this;

View File

@@ -7,7 +7,7 @@ import * as flatbuffers from 'flatbuffers';
export class HelloRequest { export class HelloRequest {
bb: flatbuffers.ByteBuffer|null = null; bb: flatbuffers.ByteBuffer|null = null;
bb_pos = 0; bb_pos = 0;
__init(i:number, bb:flatbuffers.ByteBuffer):HelloRequest { __init(i:number, bb:flatbuffers.ByteBuffer):HelloRequest {
this.bb_pos = i; this.bb_pos = i;
this.bb = bb; this.bb = bb;
return this; return this;

View File

@@ -643,10 +643,6 @@ int FlatCompiler::Compile(int argc, const char **argv) {
"well."); "well.");
} }
if (opts.ts_flat_file && opts.generate_all) {
Error("Combining --ts-flat-file and --gen-all is not supported.");
}
flatbuffers::Parser conform_parser; flatbuffers::Parser conform_parser;
if (!conform_to_schema.empty()) { if (!conform_to_schema.empty()) {
std::string contents; std::string contents;

View File

@@ -38,7 +38,7 @@ struct ImportDefinition {
}; };
enum AnnotationType { kParam = 0, kType = 1, kReturns = 2 }; enum AnnotationType { kParam = 0, kType = 1, kReturns = 2 };
} } // namespace
namespace ts { namespace ts {
// Iterate through all definitions we haven't generate code for (enums, structs, // Iterate through all definitions we haven't generate code for (enums, structs,
@@ -111,10 +111,6 @@ class TsGenerator : public BaseGenerator {
for (auto kw = keywords; *kw; kw++) keywords_.insert(*kw); for (auto kw = keywords; *kw; kw++) keywords_.insert(*kw);
} }
bool generate() { bool generate() {
if (parser_.opts.ts_flat_file && parser_.opts.generate_all) {
// Not implemented; warning message should have been emitted by flatc.
return false;
}
generateEnums(); generateEnums();
generateStructs(); generateStructs();
generateEntry(); generateEntry();
@@ -227,39 +223,45 @@ class TsGenerator : public BaseGenerator {
// Generate code for a single entry point module. // Generate code for a single entry point module.
void generateEntry() { void generateEntry() {
std::string code; std::string code =
"// " + std::string(FlatBuffersGeneratedWarning()) + "\n\n";
if (parser_.opts.ts_flat_file) { if (parser_.opts.ts_flat_file) {
if (import_flatbuffers_lib_) { if (import_flatbuffers_lib_) {
code += "import * as flatbuffers from 'flatbuffers';\n"; code += "import * as flatbuffers from 'flatbuffers';\n";
code += "\n";
} }
for (const auto &it : flat_file_import_declarations_) { // Only include import statements when not generating all.
// Note that we do end up generating an import for ourselves, which if (!parser_.opts.generate_all) {
// should generally be harmless. for (const auto &it : flat_file_import_declarations_) {
// TODO: Make it so we don't generate a self-import; this will also // Note that we do end up generating an import for ourselves, which
// require modifying AddImport to ensure that we don't use // should generally be harmless.
// namespace-prefixed names anywhere... // TODO: Make it so we don't generate a self-import; this will also
std::string file = it.first; // require modifying AddImport to ensure that we don't use
if (file.empty()) { continue; } // namespace-prefixed names anywhere...
std::string noext = flatbuffers::StripExtension(file); std::string file = it.first;
std::string basename = flatbuffers::StripPath(noext); if (file.empty()) { continue; }
std::string include_file = GeneratedFileName( std::string noext = flatbuffers::StripExtension(file);
parser_.opts.include_prefix, std::string basename = flatbuffers::StripPath(noext);
parser_.opts.keep_prefix ? noext : basename, parser_.opts); std::string include_file = GeneratedFileName(
// TODO: what is the right behavior when different include flags are parser_.opts.include_prefix,
// specified here? Should we always be adding the "./" for a relative parser_.opts.keep_prefix ? noext : basename, parser_.opts);
// path or turn it off if --include-prefix is specified, or something // TODO: what is the right behavior when different include flags are
// else? // specified here? Should we always be adding the "./" for a relative
std::string include_name = // path or turn it off if --include-prefix is specified, or something
"./" + flatbuffers::StripExtension(include_file); // else?
code += "import {"; std::string include_name =
for (const auto &pair : it.second) { "./" + flatbuffers::StripExtension(include_file);
code += EscapeKeyword(pair.first) + " as " + code += "import {";
EscapeKeyword(pair.second) + ", "; for (const auto &pair : it.second) {
code += EscapeKeyword(pair.first) + " as " +
EscapeKeyword(pair.second) + ", ";
}
code.resize(code.size() - 2);
code += "} from '" + include_name + "';\n";
} }
code.resize(code.size() - 2); code += "\n";
code += "} from '" + include_name + "';\n";
} }
code += "\n\n";
code += flat_file_; code += flat_file_;
const std::string filename = const std::string filename =
GeneratedFileName(path_, file_name_, parser_.opts); GeneratedFileName(path_, file_name_, parser_.opts);
@@ -305,7 +307,9 @@ class TsGenerator : public BaseGenerator {
if (reverse) return; // FIXME. if (reverse) return; // FIXME.
std::string &code = *code_ptr; std::string &code = *code_ptr;
GenDocComment(enum_def.doc_comment, code_ptr); GenDocComment(enum_def.doc_comment, code_ptr);
code += "export enum " + EscapeKeyword(enum_def.name) + "{\n"; code += "export enum ";
// TODO(7445): figure out if the export needs a namespace for ts-flat-files
code += EscapeKeyword(enum_def.name) + " {\n";
for (auto it = enum_def.Vals().begin(); it != enum_def.Vals().end(); ++it) { for (auto it = enum_def.Vals().begin(); it != enum_def.Vals().end(); ++it) {
auto &ev = **it; auto &ev = **it;
if (!ev.doc_comment.empty()) { if (!ev.doc_comment.empty()) {
@@ -659,19 +663,14 @@ class TsGenerator : public BaseGenerator {
// above, but since we force all non-self-imports to use namespace-based // above, but since we force all non-self-imports to use namespace-based
// names in flat file generation, it's fine). // names in flat file generation, it's fine).
if (dependent.file == dependency.file) { if (dependent.file == dependency.file) {
// Should already be caught elsewhere, but if we ever try to get flat
// file generation and --gen-all working concurrently, then we'll need
// to update this import logic.
FLATBUFFERS_ASSERT(!parser_.opts.generate_all);
long_import_name = import_name; long_import_name = import_name;
} else { } else {
long_import_name = ns + import_name; long_import_name = ns + import_name;
std::string file = dependency.declaration_file == nullptr std::string file =
? dependency.file RelativeToRootPath(StripFileName(AbsolutePath(dependent.file)),
: dependency.declaration_file->substr(2); dependency.file)
file = RelativeToRootPath(StripFileName(AbsolutePath(dependent.file)), // Strip the leading //
dependency.file) .substr(2);
.substr(2);
flat_file_import_declarations_[file][import_name] = long_import_name; flat_file_import_declarations_[file][import_name] = long_import_name;
if (parser_.opts.generate_object_based_api) { if (parser_.opts.generate_object_based_api) {
flat_file_import_declarations_[file][import_name + "T"] = flat_file_import_declarations_[file][import_name + "T"] =
@@ -753,19 +752,14 @@ class TsGenerator : public BaseGenerator {
// above, but since we force all non-self-imports to use namespace-based // above, but since we force all non-self-imports to use namespace-based
// names in flat file generation, it's fine). // names in flat file generation, it's fine).
if (dependent.file == dependency.file) { if (dependent.file == dependency.file) {
// Should already be caught elsewhere, but if we ever try to get flat
// file generation and --gen-all working concurrently, then we'll need
// to update this import logic.
FLATBUFFERS_ASSERT(!parser_.opts.generate_all);
long_import_name = import_name; long_import_name = import_name;
} else { } else {
long_import_name = ns + import_name; long_import_name = ns + import_name;
std::string file = dependency.declaration_file == nullptr std::string file =
? dependency.file RelativeToRootPath(StripFileName(AbsolutePath(dependent.file)),
: dependency.declaration_file->substr(2); dependency.file)
file = RelativeToRootPath(StripFileName(AbsolutePath(dependent.file)), // Strip the leading //
dependency.file) .substr(2);
.substr(2);
flat_file_import_declarations_[file][import_name] = long_import_name; flat_file_import_declarations_[file][import_name] = long_import_name;
} }
} }
@@ -1347,7 +1341,9 @@ class TsGenerator : public BaseGenerator {
// Emit constructor // Emit constructor
object_name = EscapeKeyword(struct_def.name); object_name = EscapeKeyword(struct_def.name);
GenDocComment(struct_def.doc_comment, code_ptr); GenDocComment(struct_def.doc_comment, code_ptr);
code += "export class " + object_name; code += "export class ";
// TODO(7445): figure out if the export needs a namespace for ts-flat-files
code += object_name;
code += " {\n"; code += " {\n";
code += " bb: flatbuffers.ByteBuffer|null = null;\n"; code += " bb: flatbuffers.ByteBuffer|null = null;\n";
code += " bb_pos = 0;\n"; code += " bb_pos = 0;\n";
@@ -1355,7 +1351,7 @@ class TsGenerator : public BaseGenerator {
// Generate the __init method that sets the field in a pre-existing // Generate the __init method that sets the field in a pre-existing
// accessor object. This is to allow object reuse. // accessor object. This is to allow object reuse.
code += code +=
"__init(i:number, bb:flatbuffers.ByteBuffer):" + object_name + " {\n"; " __init(i:number, bb:flatbuffers.ByteBuffer):" + object_name + " {\n";
code += " this.bb_pos = i;\n"; code += " this.bb_pos = i;\n";
code += " this.bb = bb;\n"; code += " this.bb = bb;\n";
code += " return this;\n"; code += " return this;\n";

View File

@@ -1,3 +1,6 @@
table Baz { enum Baz : short {
a:int; None = 0,
Red,
Green,
Blue,
} }

View File

@@ -77,8 +77,22 @@ def assert_file_contains(file, needles):
return file return file
def assert_file_and_contents(file, needle, path=script_path, unlink=True): def assert_file_doesnt_contains(file, needles):
with open(file) as file:
contents = file.read()
for needle in [needles] if isinstance(needles, str) else needles:
assert needle not in contents, (
"Found unexpected '" + needle + "' in file: " + str(file)
)
return file
def assert_file_and_contents(
file, needle, doesnt_contain=None, path=script_path, unlink=True
):
assert_file_contains(assert_file_exists(file, path), needle) assert_file_contains(assert_file_exists(file, path), needle)
if doesnt_contain:
assert_file_doesnt_contains(assert_file_exists(file, path), doesnt_contain)
if unlink: if unlink:
Path(path, file).unlink() Path(path, file).unlink()
@@ -102,7 +116,7 @@ def run_all(*modules):
module_passing = module_passing + 1 module_passing = module_passing + 1
except Exception as e: except Exception as e:
print(" [FAILED]: " + str(e)) print(" [FAILED]: " + str(e))
failingmodule_failing = failingmodule_failing + 1 module_failing = module_failing + 1
print( print(
"{0}: {1} of {2} passsed".format( "{0}: {1} of {2} passsed".format(
module.__name__, module_passing, module_passing + module_failing module.__name__, module_passing, module_passing + module_failing

View File

@@ -14,6 +14,7 @@
from flatc_test import * from flatc_test import *
class TsTests(): class TsTests():
def Base(self): def Base(self):
@@ -24,7 +25,10 @@ class TsTests():
# include, bar. # include, bar.
assert_file_and_contents( assert_file_and_contents(
"foo_generated.ts", "foo_generated.ts",
["export { Bar } from './bar';", "export { Foo } from './foo';"], [
"export { Bar } from './bar';",
"export { Foo } from './foo';",
],
) )
# Foo should be generated in place and exports the Foo table. # Foo should be generated in place and exports the Foo table.
@@ -33,6 +37,26 @@ class TsTests():
# Included files, like bar, should not be generated. # Included files, like bar, should not be generated.
assert_file_doesnt_exists("bar.ts") assert_file_doesnt_exists("bar.ts")
def BaseMultipleFiles(self):
# Generate both foo and bar with no extra arguments
flatc(["--ts", "foo.fbs", "bar/bar.fbs"])
# Should generate the module that exports both foo and its direct
# include, bar.
assert_file_and_contents(
"foo_generated.ts",
[
"export { Bar } from './bar';",
"export { Foo } from './foo';",
],
)
# Foo should be generated in place and exports the Foo table.
assert_file_and_contents("foo.ts", "export class Foo {")
# Bar should also be generatd in place and exports the Bar table.
assert_file_and_contents("bar.ts", "export class Bar {")
def BaseWithNamespace(self): def BaseWithNamespace(self):
# Generate foo with namespacing, with no extra arguments # Generate foo with namespacing, with no extra arguments
flatc(["--ts", "foo_with_ns.fbs"]) flatc(["--ts", "foo_with_ns.fbs"])
@@ -41,29 +65,132 @@ class TsTests():
# directory and its direct include, bar. # directory and its direct include, bar.
assert_file_and_contents( assert_file_and_contents(
"foo_with_ns_generated.ts", "foo_with_ns_generated.ts",
["export { Bar } from './bar';", "export { Foo } from './something/foo';"], [
"export { Bar } from './bar';",
"export { Foo } from './something/foo';",
],
) )
# Foo should be placed in the namespaced directory. It should export # Foo should be placed in the namespaced directory. It should export
# Foo, and the import of Bar should be relative to its location. # Foo, and the import of Bar should be relative to its location.
assert_file_and_contents( assert_file_and_contents(
"something/foo.ts", "something/foo.ts",
["export class Foo {", "import { Bar } from '../bar';"], [
"export class Foo {",
"import { Bar } from '../bar';",
],
) )
# Included files, like bar, should not be generated. # Included files, like bar, should not be generated.
assert_file_doesnt_exists("bar.ts") assert_file_doesnt_exists("bar.ts")
def GenAll(self):
# Generate foo with generate all options
flatc(["--ts", "--gen-all", "foo.fbs"])
# Should generate a single file that exports all the generated types.
assert_file_and_contents(
"foo_generated.ts",
[
"export { Bar } from './bar'",
"export { Baz } from './baz'",
"export { Foo } from './foo'",
],
)
# Foo should be generated with an import to Bar and an export of itself.
assert_file_and_contents(
"foo.ts",
[
"import { Bar } from './bar';",
"export class Foo {",
],
)
# Bar should be generated with an import to Baz and an export of itself.
assert_file_and_contents(
"bar.ts",
[
"import { Baz } from './baz';",
"export class Bar {",
],
)
# Baz should be generated with an export of itself.
assert_file_and_contents(
"baz.ts",
[
"export enum Baz {",
],
)
def FlatFiles(self): def FlatFiles(self):
# Generate just foo the flat files option # Generate just foo with the flat files option
flatc(["--ts", "--ts-flat-files", "foo.fbs"]) flatc(["--ts", "--ts-flat-files", "foo.fbs"])
# Should generate a single file that imports bar as a single file, and] # Should generate a single file that imports bar as a single file, and
# exports the Foo table. # exports the Foo table.
assert_file_and_contents( assert_file_and_contents(
"foo_generated.ts", "foo_generated.ts",
["import {Bar as Bar} from './bar_generated';", "export class Foo {"], [
"import {Bar as Bar} from './bar_generated';",
"export class Foo {",
],
) )
# The root type Foo should not be generated in its own file. # The root type Foo should not be generated in its own file.
assert_file_doesnt_exists("foo.ts") assert_file_doesnt_exists("foo.ts")
def FlatFilesMultipleFiles(self):
# Generate both foo and bar with the flat files option
flatc(["--ts", "--ts-flat-files", "foo.fbs", "bar/bar.fbs"])
# Should generate a single foo file that imports bar as a single file,
# and exports the Foo table.
assert_file_and_contents(
"foo_generated.ts",
[
"import {Bar as Bar} from './bar_generated';",
"export class Foo {",
],
)
# Should generate a single bar file that imports bar as a single file,
# and exports the Bar table.
assert_file_and_contents(
"bar_generated.ts",
[
"import {Baz as Baz} from './baz_generated';",
"export class Bar {",
],
)
# The types Foo and Bar should not be generated in their own files
assert_file_doesnt_exists("foo.ts")
assert_file_doesnt_exists("bar.ts")
def FlatFilesGenAll(self):
# Generate foo with all of its dependents with the flat files option
flatc(["--ts", "--ts-flat-files", "--gen-all", "foo.fbs"])
# Should generate a single foo file
assert_file_and_contents(
"foo_generated.ts",
# Should export each of the types within the single file
[
"export class Foo {",
"export class Bar {",
"export enum Baz {",
],
# No includes for the dependent types should be present.
doesnt_contain=[
"import {Bar as Bar}",
"import {Baz as Baz}",
],
)
# The types Foo, Bar and Baz should not be generated in their own files.
assert_file_doesnt_exists("foo.ts")
assert_file_doesnt_exists("bar.ts")
assert_file_doesnt_exists("baz.ts")

View File

@@ -1,3 +1,5 @@
// automatically generated by the FlatBuffers compiler, do not modify
export { Monster } from './my-game/example/monster'; export { Monster } from './my-game/example/monster';
export { Monster as MyGameExample2Monster, MonsterT as MyGameExample2MonsterT } from './my-game/example2/monster'; export { Monster as MyGameExample2Monster, MonsterT as MyGameExample2MonsterT } from './my-game/example2/monster';
export { Ability, AbilityT } from './my-game/example/ability'; export { Ability, AbilityT } from './my-game/example/ability';

View File

@@ -7,7 +7,7 @@ import * as flatbuffers from 'flatbuffers';
export class Ability { export class Ability {
bb: flatbuffers.ByteBuffer|null = null; bb: flatbuffers.ByteBuffer|null = null;
bb_pos = 0; bb_pos = 0;
__init(i:number, bb:flatbuffers.ByteBuffer):Ability { __init(i:number, bb:flatbuffers.ByteBuffer):Ability {
this.bb_pos = i; this.bb_pos = i;
this.bb = bb; this.bb = bb;
return this; return this;

View File

@@ -3,7 +3,7 @@
import { Monster, MonsterT } from '../../my-game/example/monster'; import { Monster, MonsterT } from '../../my-game/example/monster';
export enum AnyAmbiguousAliases{ export enum AnyAmbiguousAliases {
NONE = 0, NONE = 0,
M1 = 1, M1 = 1,
M2 = 2, M2 = 2,

View File

@@ -5,7 +5,7 @@ import { Monster, MonsterT } from '../../my-game/example/monster';
import { TestSimpleTableWithEnum, TestSimpleTableWithEnumT } from '../../my-game/example/test-simple-table-with-enum'; import { TestSimpleTableWithEnum, TestSimpleTableWithEnumT } from '../../my-game/example/test-simple-table-with-enum';
export enum AnyUniqueAliases{ export enum AnyUniqueAliases {
NONE = 0, NONE = 0,
M = 1, M = 1,
TS = 2, TS = 2,

View File

@@ -5,7 +5,7 @@ import { Monster, MonsterT } from '../../my-game/example/monster';
import { TestSimpleTableWithEnum, TestSimpleTableWithEnumT } from '../../my-game/example/test-simple-table-with-enum'; import { TestSimpleTableWithEnum, TestSimpleTableWithEnumT } from '../../my-game/example/test-simple-table-with-enum';
export enum Any{ export enum Any {
NONE = 0, NONE = 0,
Monster = 1, Monster = 1,
TestSimpleTableWithEnum = 2, TestSimpleTableWithEnum = 2,

View File

@@ -3,7 +3,7 @@
/** /**
* Composite components of Monster color. * Composite components of Monster color.
*/ */
export enum Color{ export enum Color {
Red = 1, Red = 1,
/** /**

View File

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

View File

@@ -23,7 +23,7 @@ import { InParentNamespace, InParentNamespaceT } from '../../my-game/in-parent-n
export class Monster { export class Monster {
bb: flatbuffers.ByteBuffer|null = null; bb: flatbuffers.ByteBuffer|null = null;
bb_pos = 0; bb_pos = 0;
__init(i:number, bb:flatbuffers.ByteBuffer):Monster { __init(i:number, bb:flatbuffers.ByteBuffer):Monster {
this.bb_pos = i; this.bb_pos = i;
this.bb = bb; this.bb = bb;
return this; return this;

View File

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

View File

@@ -7,7 +7,7 @@ import * as flatbuffers from 'flatbuffers';
export class Referrable { export class Referrable {
bb: flatbuffers.ByteBuffer|null = null; bb: flatbuffers.ByteBuffer|null = null;
bb_pos = 0; bb_pos = 0;
__init(i:number, bb:flatbuffers.ByteBuffer):Referrable { __init(i:number, bb:flatbuffers.ByteBuffer):Referrable {
this.bb_pos = i; this.bb_pos = i;
this.bb = bb; this.bb = bb;
return this; return this;

View File

@@ -7,7 +7,7 @@ import * as flatbuffers from 'flatbuffers';
export class Stat { export class Stat {
bb: flatbuffers.ByteBuffer|null = null; bb: flatbuffers.ByteBuffer|null = null;
bb_pos = 0; bb_pos = 0;
__init(i:number, bb:flatbuffers.ByteBuffer):Stat { __init(i:number, bb:flatbuffers.ByteBuffer):Stat {
this.bb_pos = i; this.bb_pos = i;
this.bb = bb; this.bb = bb;
return this; return this;

View File

@@ -8,7 +8,7 @@ import { StructOfStructs, StructOfStructsT } from '../../my-game/example/struct-
export class StructOfStructsOfStructs { export class StructOfStructsOfStructs {
bb: flatbuffers.ByteBuffer|null = null; bb: flatbuffers.ByteBuffer|null = null;
bb_pos = 0; bb_pos = 0;
__init(i:number, bb:flatbuffers.ByteBuffer):StructOfStructsOfStructs { __init(i:number, bb:flatbuffers.ByteBuffer):StructOfStructsOfStructs {
this.bb_pos = i; this.bb_pos = i;
this.bb = bb; this.bb = bb;
return this; return this;

View File

@@ -9,7 +9,7 @@ import { Test, TestT } from '../../my-game/example/test';
export class StructOfStructs { export class StructOfStructs {
bb: flatbuffers.ByteBuffer|null = null; bb: flatbuffers.ByteBuffer|null = null;
bb_pos = 0; bb_pos = 0;
__init(i:number, bb:flatbuffers.ByteBuffer):StructOfStructs { __init(i:number, bb:flatbuffers.ByteBuffer):StructOfStructs {
this.bb_pos = i; this.bb_pos = i;
this.bb = bb; this.bb = bb;
return this; return this;

View File

@@ -8,7 +8,7 @@ import { Color } from '../../my-game/example/color';
export class TestSimpleTableWithEnum { export class TestSimpleTableWithEnum {
bb: flatbuffers.ByteBuffer|null = null; bb: flatbuffers.ByteBuffer|null = null;
bb_pos = 0; bb_pos = 0;
__init(i:number, bb:flatbuffers.ByteBuffer):TestSimpleTableWithEnum { __init(i:number, bb:flatbuffers.ByteBuffer):TestSimpleTableWithEnum {
this.bb_pos = i; this.bb_pos = i;
this.bb = bb; this.bb = bb;
return this; return this;

View File

@@ -7,7 +7,7 @@ import * as flatbuffers from 'flatbuffers';
export class Test { export class Test {
bb: flatbuffers.ByteBuffer|null = null; bb: flatbuffers.ByteBuffer|null = null;
bb_pos = 0; bb_pos = 0;
__init(i:number, bb:flatbuffers.ByteBuffer):Test { __init(i:number, bb:flatbuffers.ByteBuffer):Test {
this.bb_pos = i; this.bb_pos = i;
this.bb = bb; this.bb = bb;
return this; return this;

View File

@@ -7,7 +7,7 @@ import * as flatbuffers from 'flatbuffers';
export class TypeAliases { export class TypeAliases {
bb: flatbuffers.ByteBuffer|null = null; bb: flatbuffers.ByteBuffer|null = null;
bb_pos = 0; bb_pos = 0;
__init(i:number, bb:flatbuffers.ByteBuffer):TypeAliases { __init(i:number, bb:flatbuffers.ByteBuffer):TypeAliases {
this.bb_pos = i; this.bb_pos = i;
this.bb = bb; this.bb = bb;
return this; return this;

View File

@@ -9,7 +9,7 @@ import { Test, TestT } from '../../my-game/example/test';
export class Vec3 { export class Vec3 {
bb: flatbuffers.ByteBuffer|null = null; bb: flatbuffers.ByteBuffer|null = null;
bb_pos = 0; bb_pos = 0;
__init(i:number, bb:flatbuffers.ByteBuffer):Vec3 { __init(i:number, bb:flatbuffers.ByteBuffer):Vec3 {
this.bb_pos = i; this.bb_pos = i;
this.bb = bb; this.bb = bb;
return this; return this;

View File

@@ -7,7 +7,7 @@ import * as flatbuffers from 'flatbuffers';
export class Monster { export class Monster {
bb: flatbuffers.ByteBuffer|null = null; bb: flatbuffers.ByteBuffer|null = null;
bb_pos = 0; bb_pos = 0;
__init(i:number, bb:flatbuffers.ByteBuffer):Monster { __init(i:number, bb:flatbuffers.ByteBuffer):Monster {
this.bb_pos = i; this.bb_pos = i;
this.bb = bb; this.bb = bb;
return this; return this;

View File

@@ -7,7 +7,7 @@ import * as flatbuffers from 'flatbuffers';
export class InParentNamespace { export class InParentNamespace {
bb: flatbuffers.ByteBuffer|null = null; bb: flatbuffers.ByteBuffer|null = null;
bb_pos = 0; bb_pos = 0;
__init(i:number, bb:flatbuffers.ByteBuffer):InParentNamespace { __init(i:number, bb:flatbuffers.ByteBuffer):InParentNamespace {
this.bb_pos = i; this.bb_pos = i;
this.bb = bb; this.bb = bb;
return this; return this;

View File

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

View File

@@ -8,7 +8,7 @@ import { OptionalByte } from '../optional-scalars/optional-byte';
export class ScalarStuff { export class ScalarStuff {
bb: flatbuffers.ByteBuffer|null = null; bb: flatbuffers.ByteBuffer|null = null;
bb_pos = 0; bb_pos = 0;
__init(i:number, bb:flatbuffers.ByteBuffer):ScalarStuff { __init(i:number, bb:flatbuffers.ByteBuffer):ScalarStuff {
this.bb_pos = i; this.bb_pos = i;
this.bb = bb; this.bb = bb;
return this; return this;

View File

@@ -1,2 +1,4 @@
// automatically generated by the FlatBuffers compiler, do not modify
export { ScalarStuff } from './optional-scalars/scalar-stuff'; export { ScalarStuff } from './optional-scalars/scalar-stuff';
export { OptionalByte } from './optional-scalars/optional-byte'; export { OptionalByte } from './optional-scalars/optional-byte';

View File

@@ -7,7 +7,7 @@ import * as flatbuffers from 'flatbuffers';
export class Attacker { export class Attacker {
bb: flatbuffers.ByteBuffer|null = null; bb: flatbuffers.ByteBuffer|null = null;
bb_pos = 0; bb_pos = 0;
__init(i:number, bb:flatbuffers.ByteBuffer):Attacker { __init(i:number, bb:flatbuffers.ByteBuffer):Attacker {
this.bb_pos = i; this.bb_pos = i;
this.bb = bb; this.bb = bb;
return this; return this;

View File

@@ -7,7 +7,7 @@ import * as flatbuffers from 'flatbuffers';
export class BookReader { export class BookReader {
bb: flatbuffers.ByteBuffer|null = null; bb: flatbuffers.ByteBuffer|null = null;
bb_pos = 0; bb_pos = 0;
__init(i:number, bb:flatbuffers.ByteBuffer):BookReader { __init(i:number, bb:flatbuffers.ByteBuffer):BookReader {
this.bb_pos = i; this.bb_pos = i;
this.bb = bb; this.bb = bb;
return this; return this;

View File

@@ -5,7 +5,7 @@ import { BookReader, BookReaderT } from './book-reader';
import { Rapunzel, RapunzelT } from './rapunzel'; import { Rapunzel, RapunzelT } from './rapunzel';
export enum Character{ export enum Character {
NONE = 0, NONE = 0,
MuLan = 1, MuLan = 1,
Rapunzel = 2, Rapunzel = 2,

View File

@@ -7,7 +7,7 @@ import * as flatbuffers from 'flatbuffers';
export class FallingTub { export class FallingTub {
bb: flatbuffers.ByteBuffer|null = null; bb: flatbuffers.ByteBuffer|null = null;
bb_pos = 0; bb_pos = 0;
__init(i:number, bb:flatbuffers.ByteBuffer):FallingTub { __init(i:number, bb:flatbuffers.ByteBuffer):FallingTub {
this.bb_pos = i; this.bb_pos = i;
this.bb = bb; this.bb = bb;
return this; return this;

View File

@@ -4,7 +4,7 @@ import { FallingTub, FallingTubT } from './falling-tub';
import { HandFan, HandFanT } from './hand-fan'; import { HandFan, HandFanT } from './hand-fan';
export enum Gadget{ export enum Gadget {
NONE = 0, NONE = 0,
FallingTub = 1, FallingTub = 1,
HandFan = 2 HandFan = 2

View File

@@ -7,7 +7,7 @@ import * as flatbuffers from 'flatbuffers';
export class HandFan { export class HandFan {
bb: flatbuffers.ByteBuffer|null = null; bb: flatbuffers.ByteBuffer|null = null;
bb_pos = 0; bb_pos = 0;
__init(i:number, bb:flatbuffers.ByteBuffer):HandFan { __init(i:number, bb:flatbuffers.ByteBuffer):HandFan {
this.bb_pos = i; this.bb_pos = i;
this.bb = bb; this.bb = bb;
return this; return this;

View File

@@ -11,7 +11,7 @@ import { Rapunzel, RapunzelT } from './rapunzel';
export class Movie { export class Movie {
bb: flatbuffers.ByteBuffer|null = null; bb: flatbuffers.ByteBuffer|null = null;
bb_pos = 0; bb_pos = 0;
__init(i:number, bb:flatbuffers.ByteBuffer):Movie { __init(i:number, bb:flatbuffers.ByteBuffer):Movie {
this.bb_pos = i; this.bb_pos = i;
this.bb = bb; this.bb = bb;
return this; return this;

View File

@@ -7,7 +7,7 @@ import * as flatbuffers from 'flatbuffers';
export class Rapunzel { export class Rapunzel {
bb: flatbuffers.ByteBuffer|null = null; bb: flatbuffers.ByteBuffer|null = null;
bb_pos = 0; bb_pos = 0;
__init(i:number, bb:flatbuffers.ByteBuffer):Rapunzel { __init(i:number, bb:flatbuffers.ByteBuffer):Rapunzel {
this.bb_pos = i; this.bb_pos = i;
this.bb = bb; this.bb = bb;
return this; return this;

View File

@@ -1,3 +1,5 @@
// automatically generated by the FlatBuffers compiler, do not modify
export { Attacker, AttackerT } from './attacker'; export { Attacker, AttackerT } from './attacker';
export { BookReader, BookReaderT } from './book-reader'; export { BookReader, BookReaderT } from './book-reader';
export { Character, unionToCharacter, unionListToCharacter } from './character'; export { Character, unionToCharacter, unionListToCharacter } from './character';