[TS] Make strict compliant and improve typings (#7549)

* [TS] Make strict compliant and improve typings

* clang-format

* Code gen harmonize

Co-authored-by: Derek Bailey <derekbailey@google.com>
This commit is contained in:
Björn Harrtell
2022-09-30 00:03:35 +02:00
committed by GitHub
parent 374f8fb5fb
commit d243b904cc
41 changed files with 279 additions and 268 deletions

View File

@@ -17,6 +17,7 @@
}, },
"scripts": { "scripts": {
"test": "npm run compile && cd tests/ts && python3 ./TypeScriptTest.py", "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 && rollup -c",
"prepublishOnly": "npm install --only=dev && npm run compile" "prepublishOnly": "npm install --only=dev && npm run compile"
}, },

View File

@@ -759,10 +759,10 @@ class TsGenerator : public BaseGenerator {
import.object_name = object_name; import.object_name = object_name;
import.bare_file_path = bare_file_path; import.bare_file_path = bare_file_path;
import.rel_file_path = rel_file_path; import.rel_file_path = rel_file_path;
import.import_statement = import.import_statement = "import { " + symbols_expression + " } from '" +
"import { " + symbols_expression + " } from '" + rel_file_path + ".js';"; rel_file_path + ".js';";
import.export_statement = import.export_statement = "export { " + symbols_expression + " } from '." +
"export { " + symbols_expression + " } from '." + bare_file_path + ".js';"; bare_file_path + ".js';";
import.dependency = &dependency; import.dependency = &dependency;
import.dependent = &dependent; import.dependent = &dependent;
@@ -903,7 +903,7 @@ class TsGenerator : public BaseGenerator {
const auto conversion_function = GenUnionConvFuncName(enum_def); const auto conversion_function = GenUnionConvFuncName(enum_def);
ret = "(() => {\n"; ret = "(() => {\n";
ret += " let temp = " + conversion_function + "(this." + ret += " const temp = " + conversion_function + "(this." +
namer_.Method(field_name, "Type") + "(), " + namer_.Method(field_name, "Type") + "(), " +
field_binded_method + ");\n"; field_binded_method + ");\n";
ret += " if(temp === null) { return null; }\n"; ret += " if(temp === null) { return null; }\n";
@@ -916,17 +916,17 @@ class TsGenerator : public BaseGenerator {
const auto conversion_function = GenUnionListConvFuncName(enum_def); const auto conversion_function = GenUnionListConvFuncName(enum_def);
ret = "(() => {\n"; ret = "(() => {\n";
ret += " let ret = [];\n"; ret += " const ret = [];\n";
ret += " for(let targetEnumIndex = 0; targetEnumIndex < this." + ret += " for(let targetEnumIndex = 0; targetEnumIndex < this." +
namer_.Method(field_name, "TypeLength") + "()" + namer_.Method(field_name, "TypeLength") + "()" +
"; " "; "
"++targetEnumIndex) {\n"; "++targetEnumIndex) {\n";
ret += " let targetEnum = this." + ret += " const targetEnum = this." +
namer_.Method(field_name, "Type") + "(targetEnumIndex);\n"; namer_.Method(field_name, "Type") + "(targetEnumIndex);\n";
ret += " if(targetEnum === null || " + enum_type + ret += " if(targetEnum === null || " + enum_type +
"[targetEnum!] === 'NONE') { " "[targetEnum!] === 'NONE') { "
"continue; }\n\n"; "continue; }\n\n";
ret += " let temp = " + conversion_function + "(targetEnum, " + ret += " const temp = " + conversion_function + "(targetEnum, " +
field_binded_method + ", targetEnumIndex);\n"; field_binded_method + ", targetEnumIndex);\n";
ret += " if(temp === null) { continue; }\n"; ret += " if(temp === null) { continue; }\n";
ret += union_has_string ? " if(typeof temp === 'string') { " ret += union_has_string ? " if(typeof temp === 'string') { "
@@ -1102,11 +1102,13 @@ class TsGenerator : public BaseGenerator {
switch (vectortype.base_type) { switch (vectortype.base_type) {
case BASE_TYPE_STRUCT: { case BASE_TYPE_STRUCT: {
const auto &sd = *field.value.type.struct_def; const auto &sd = *field.value.type.struct_def;
field_type += GetTypeName(sd, /*object_api=*/true); const auto field_type_name =
; GetTypeName(sd, /*object_api=*/true);
field_type += field_type_name;
field_type += ")[]"; field_type += ")[]";
field_val = GenBBAccess() + ".createObjList(" + field_val = GenBBAccess() + ".createObjList<" + vectortypename +
", " + field_type_name + ">(" +
field_binded_method + ", this." + field_binded_method + ", this." +
namer_.Method(field, "Length") + "())"; namer_.Method(field, "Length") + "())";
@@ -1128,7 +1130,7 @@ class TsGenerator : public BaseGenerator {
case BASE_TYPE_STRING: { case BASE_TYPE_STRING: {
field_type += "string)[]"; field_type += "string)[]";
field_val = GenBBAccess() + ".createScalarList(" + field_val = GenBBAccess() + ".createScalarList<string>(" +
field_binded_method + ", this." + field_binded_method + ", this." +
namer_.Field(field, "Length") + "())"; namer_.Field(field, "Length") + "())";
field_offset_decl = field_offset_decl =
@@ -1162,9 +1164,9 @@ class TsGenerator : public BaseGenerator {
field_type += vectortypename; field_type += vectortypename;
} }
field_type += ")[]"; field_type += ")[]";
field_val = GenBBAccess() + ".createScalarList(" + field_val = GenBBAccess() + ".createScalarList<" +
field_binded_method + ", this." + vectortypename + ">(" + field_binded_method +
namer_.Method(field, "Length") + "())"; ", this." + namer_.Method(field, "Length") + "())";
field_offset_decl = field_offset_decl =
AddImport(imports, struct_def, struct_def).name + "." + AddImport(imports, struct_def, struct_def).name + "." +
@@ -1260,7 +1262,7 @@ class TsGenerator : public BaseGenerator {
obj_api_class = "\n"; obj_api_class = "\n";
obj_api_class += "export class "; obj_api_class += "export class ";
obj_api_class += GetTypeName(struct_def, /*object_api=*/true); obj_api_class += GetTypeName(struct_def, /*object_api=*/true);
obj_api_class += " {\n"; obj_api_class += " implements flatbuffers.IGeneratedObject {\n";
obj_api_class += constructor_func; obj_api_class += constructor_func;
obj_api_class += pack_func_prototype + pack_func_offset_decl + obj_api_class += pack_func_prototype + pack_func_offset_decl +
pack_func_create_call + "\n}"; pack_func_create_call + "\n}";
@@ -1298,12 +1300,17 @@ class TsGenerator : public BaseGenerator {
} }
const std::string object_name = GetTypeName(struct_def); const std::string object_name = GetTypeName(struct_def);
const std::string object_api_name = GetTypeName(struct_def, true);
// Emit constructor // Emit constructor
GenDocComment(struct_def.doc_comment, code_ptr); GenDocComment(struct_def.doc_comment, code_ptr);
code += "export class "; code += "export class ";
code += object_name; code += object_name;
code += " {\n"; if (parser.opts.generate_object_based_api)
code += " implements flatbuffers.IUnpackableObject<" + object_api_name +
"> {\n";
else
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";

View File

@@ -61,7 +61,7 @@ check_call(["npm", "install", "--silent"])
print("Invoking flatc...") print("Invoking flatc...")
flatc( flatc(
options=["--ts", "--gen-name-strings", "--gen-mutable", "--gen-object-api"], options=["--ts", "--reflect-names", "--gen-name-strings", "--gen-mutable", "--gen-object-api"],
schema="../monster_test.fbs", schema="../monster_test.fbs",
include="../include_test", include="../include_test",
) )
@@ -74,18 +74,18 @@ flatc(
) )
flatc( flatc(
options=["--ts", "--gen-name-strings", "--gen-mutable", "--gen-object-api"], options=["--ts", "--reflect-names", "--gen-name-strings", "--gen-mutable", "--gen-object-api"],
schema="../union_vector/union_vector.fbs", schema="../union_vector/union_vector.fbs",
prefix="union_vector", prefix="union_vector",
) )
flatc( flatc(
options=["--ts", "--gen-name-strings"], options=["--ts", "--reflect-names", "--gen-name-strings"],
schema="../optional_scalars.fbs", schema="../optional_scalars.fbs",
) )
flatc( flatc(
options=["--ts", "--gen-name-strings", "--gen-mutable", "--gen-object-api"], options=["--ts", "--reflect-names", "--gen-name-strings", "--gen-mutable", "--gen-object-api"],
schema=[ schema=[
"typescript_keywords.fbs", "typescript_keywords.fbs",
"test_dir/typescript_include.fbs", "test_dir/typescript_include.fbs",
@@ -98,6 +98,7 @@ flatc(
flatc( flatc(
options=[ options=[
"--ts", "--ts",
"--reflect-names",
"--gen-name-strings", "--gen-name-strings",
"--gen-mutable", "--gen-mutable",
"--gen-object-api", "--gen-object-api",

View File

@@ -4,7 +4,7 @@ import * as flatbuffers from 'flatbuffers';
export class Ability { export class Ability implements flatbuffers.IUnpackableObject<AbilityT> {
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 {
@@ -61,7 +61,7 @@ unpackTo(_o: AbilityT): void {
} }
} }
export class AbilityT { export class AbilityT implements flatbuffers.IGeneratedObject {
constructor( constructor(
public id: number = 0, public id: number = 0,
public distance: number = 0 public distance: number = 0

View File

@@ -889,19 +889,19 @@ export class Monster {
} }
unpack() { unpack() {
return new MonsterT((this.pos() !== null ? this.pos().unpack() : null), this.mana(), this.hp(), this.name(), this.bb.createScalarList(this.inventory.bind(this), this.inventoryLength()), this.color(), this.testType(), (() => { return new MonsterT((this.pos() !== null ? this.pos().unpack() : null), this.mana(), this.hp(), this.name(), this.bb.createScalarList(this.inventory.bind(this), this.inventoryLength()), this.color(), this.testType(), (() => {
let temp = unionToAny(this.testType(), this.test.bind(this)); const temp = unionToAny(this.testType(), this.test.bind(this));
if (temp === null) { if (temp === null) {
return null; return null;
} }
return temp.unpack(); return temp.unpack();
})(), this.bb.createObjList(this.test4.bind(this), this.test4Length()), this.bb.createScalarList(this.testarrayofstring.bind(this), this.testarrayofstringLength()), this.bb.createObjList(this.testarrayoftables.bind(this), this.testarrayoftablesLength()), (this.enemy() !== null ? this.enemy().unpack() : null), this.bb.createScalarList(this.testnestedflatbuffer.bind(this), this.testnestedflatbufferLength()), (this.testempty() !== null ? this.testempty().unpack() : null), this.testbool(), this.testhashs32Fnv1(), this.testhashu32Fnv1(), this.testhashs64Fnv1(), this.testhashu64Fnv1(), this.testhashs32Fnv1a(), this.testhashu32Fnv1a(), this.testhashs64Fnv1a(), this.testhashu64Fnv1a(), this.bb.createScalarList(this.testarrayofbools.bind(this), this.testarrayofboolsLength()), this.testf(), this.testf2(), this.testf3(), this.bb.createScalarList(this.testarrayofstring2.bind(this), this.testarrayofstring2Length()), this.bb.createObjList(this.testarrayofsortedstruct.bind(this), this.testarrayofsortedstructLength()), this.bb.createScalarList(this.flex.bind(this), this.flexLength()), this.bb.createObjList(this.test5.bind(this), this.test5Length()), this.bb.createScalarList(this.vectorOfLongs.bind(this), this.vectorOfLongsLength()), this.bb.createScalarList(this.vectorOfDoubles.bind(this), this.vectorOfDoublesLength()), (this.parentNamespaceTest() !== null ? this.parentNamespaceTest().unpack() : null), this.bb.createObjList(this.vectorOfReferrables.bind(this), this.vectorOfReferrablesLength()), this.singleWeakReference(), this.bb.createScalarList(this.vectorOfWeakReferences.bind(this), this.vectorOfWeakReferencesLength()), this.bb.createObjList(this.vectorOfStrongReferrables.bind(this), this.vectorOfStrongReferrablesLength()), this.coOwningReference(), this.bb.createScalarList(this.vectorOfCoOwningReferences.bind(this), this.vectorOfCoOwningReferencesLength()), this.nonOwningReference(), this.bb.createScalarList(this.vectorOfNonOwningReferences.bind(this), this.vectorOfNonOwningReferencesLength()), this.anyUniqueType(), (() => { })(), this.bb.createObjList(this.test4.bind(this), this.test4Length()), this.bb.createScalarList(this.testarrayofstring.bind(this), this.testarrayofstringLength()), this.bb.createObjList(this.testarrayoftables.bind(this), this.testarrayoftablesLength()), (this.enemy() !== null ? this.enemy().unpack() : null), this.bb.createScalarList(this.testnestedflatbuffer.bind(this), this.testnestedflatbufferLength()), (this.testempty() !== null ? this.testempty().unpack() : null), this.testbool(), this.testhashs32Fnv1(), this.testhashu32Fnv1(), this.testhashs64Fnv1(), this.testhashu64Fnv1(), this.testhashs32Fnv1a(), this.testhashu32Fnv1a(), this.testhashs64Fnv1a(), this.testhashu64Fnv1a(), this.bb.createScalarList(this.testarrayofbools.bind(this), this.testarrayofboolsLength()), this.testf(), this.testf2(), this.testf3(), this.bb.createScalarList(this.testarrayofstring2.bind(this), this.testarrayofstring2Length()), this.bb.createObjList(this.testarrayofsortedstruct.bind(this), this.testarrayofsortedstructLength()), this.bb.createScalarList(this.flex.bind(this), this.flexLength()), this.bb.createObjList(this.test5.bind(this), this.test5Length()), this.bb.createScalarList(this.vectorOfLongs.bind(this), this.vectorOfLongsLength()), this.bb.createScalarList(this.vectorOfDoubles.bind(this), this.vectorOfDoublesLength()), (this.parentNamespaceTest() !== null ? this.parentNamespaceTest().unpack() : null), this.bb.createObjList(this.vectorOfReferrables.bind(this), this.vectorOfReferrablesLength()), this.singleWeakReference(), this.bb.createScalarList(this.vectorOfWeakReferences.bind(this), this.vectorOfWeakReferencesLength()), this.bb.createObjList(this.vectorOfStrongReferrables.bind(this), this.vectorOfStrongReferrablesLength()), this.coOwningReference(), this.bb.createScalarList(this.vectorOfCoOwningReferences.bind(this), this.vectorOfCoOwningReferencesLength()), this.nonOwningReference(), this.bb.createScalarList(this.vectorOfNonOwningReferences.bind(this), this.vectorOfNonOwningReferencesLength()), this.anyUniqueType(), (() => {
let temp = unionToAnyUniqueAliases(this.anyUniqueType(), this.anyUnique.bind(this)); const temp = unionToAnyUniqueAliases(this.anyUniqueType(), this.anyUnique.bind(this));
if (temp === null) { if (temp === null) {
return null; return null;
} }
return temp.unpack(); return temp.unpack();
})(), this.anyAmbiguousType(), (() => { })(), this.anyAmbiguousType(), (() => {
let temp = unionToAnyAmbiguousAliases(this.anyAmbiguousType(), this.anyAmbiguous.bind(this)); const temp = unionToAnyAmbiguousAliases(this.anyAmbiguousType(), this.anyAmbiguous.bind(this));
if (temp === null) { if (temp === null) {
return null; return null;
} }
@@ -917,7 +917,7 @@ export class Monster {
_o.color = this.color(); _o.color = this.color();
_o.testType = this.testType(); _o.testType = this.testType();
_o.test = (() => { _o.test = (() => {
let temp = unionToAny(this.testType(), this.test.bind(this)); const temp = unionToAny(this.testType(), this.test.bind(this));
if (temp === null) { if (temp === null) {
return null; return null;
} }
@@ -959,7 +959,7 @@ export class Monster {
_o.vectorOfNonOwningReferences = this.bb.createScalarList(this.vectorOfNonOwningReferences.bind(this), this.vectorOfNonOwningReferencesLength()); _o.vectorOfNonOwningReferences = this.bb.createScalarList(this.vectorOfNonOwningReferences.bind(this), this.vectorOfNonOwningReferencesLength());
_o.anyUniqueType = this.anyUniqueType(); _o.anyUniqueType = this.anyUniqueType();
_o.anyUnique = (() => { _o.anyUnique = (() => {
let temp = unionToAnyUniqueAliases(this.anyUniqueType(), this.anyUnique.bind(this)); const temp = unionToAnyUniqueAliases(this.anyUniqueType(), this.anyUnique.bind(this));
if (temp === null) { if (temp === null) {
return null; return null;
} }
@@ -967,7 +967,7 @@ export class Monster {
})(); })();
_o.anyAmbiguousType = this.anyAmbiguousType(); _o.anyAmbiguousType = this.anyAmbiguousType();
_o.anyAmbiguous = (() => { _o.anyAmbiguous = (() => {
let temp = unionToAnyAmbiguousAliases(this.anyAmbiguousType(), this.anyAmbiguous.bind(this)); const temp = unionToAnyAmbiguousAliases(this.anyAmbiguousType(), this.anyAmbiguous.bind(this));
if (temp === null) { if (temp === null) {
return null; return null;
} }

View File

@@ -20,7 +20,7 @@ import { InParentNamespace, InParentNamespaceT } from '../../my-game/in-parent-n
/** /**
* an example documentation comment: "monster object" * an example documentation comment: "monster object"
*/ */
export class Monster { export class Monster implements flatbuffers.IUnpackableObject<MonsterT> {
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 {
@@ -1153,19 +1153,19 @@ unpack(): MonsterT {
this.mana(), this.mana(),
this.hp(), this.hp(),
this.name(), this.name(),
this.bb!.createScalarList(this.inventory.bind(this), this.inventoryLength()), this.bb!.createScalarList<number>(this.inventory.bind(this), this.inventoryLength()),
this.color(), this.color(),
this.testType(), this.testType(),
(() => { (() => {
let temp = unionToAny(this.testType(), this.test.bind(this)); const temp = unionToAny(this.testType(), this.test.bind(this));
if(temp === null) { return null; } if(temp === null) { return null; }
return temp.unpack() return temp.unpack()
})(), })(),
this.bb!.createObjList(this.test4.bind(this), this.test4Length()), this.bb!.createObjList<Test, TestT>(this.test4.bind(this), this.test4Length()),
this.bb!.createScalarList(this.testarrayofstring.bind(this), this.testarrayofstringLength()), this.bb!.createScalarList<string>(this.testarrayofstring.bind(this), this.testarrayofstringLength()),
this.bb!.createObjList(this.testarrayoftables.bind(this), this.testarrayoftablesLength()), this.bb!.createObjList<Monster, MonsterT>(this.testarrayoftables.bind(this), this.testarrayoftablesLength()),
(this.enemy() !== null ? this.enemy()!.unpack() : null), (this.enemy() !== null ? this.enemy()!.unpack() : null),
this.bb!.createScalarList(this.testnestedflatbuffer.bind(this), this.testnestedflatbufferLength()), this.bb!.createScalarList<number>(this.testnestedflatbuffer.bind(this), this.testnestedflatbufferLength()),
(this.testempty() !== null ? this.testempty()!.unpack() : null), (this.testempty() !== null ? this.testempty()!.unpack() : null),
this.testbool(), this.testbool(),
this.testhashs32Fnv1(), this.testhashs32Fnv1(),
@@ -1176,41 +1176,41 @@ unpack(): MonsterT {
this.testhashu32Fnv1a(), this.testhashu32Fnv1a(),
this.testhashs64Fnv1a(), this.testhashs64Fnv1a(),
this.testhashu64Fnv1a(), this.testhashu64Fnv1a(),
this.bb!.createScalarList(this.testarrayofbools.bind(this), this.testarrayofboolsLength()), this.bb!.createScalarList<boolean>(this.testarrayofbools.bind(this), this.testarrayofboolsLength()),
this.testf(), this.testf(),
this.testf2(), this.testf2(),
this.testf3(), this.testf3(),
this.bb!.createScalarList(this.testarrayofstring2.bind(this), this.testarrayofstring2Length()), this.bb!.createScalarList<string>(this.testarrayofstring2.bind(this), this.testarrayofstring2Length()),
this.bb!.createObjList(this.testarrayofsortedstruct.bind(this), this.testarrayofsortedstructLength()), this.bb!.createObjList<Ability, AbilityT>(this.testarrayofsortedstruct.bind(this), this.testarrayofsortedstructLength()),
this.bb!.createScalarList(this.flex.bind(this), this.flexLength()), this.bb!.createScalarList<number>(this.flex.bind(this), this.flexLength()),
this.bb!.createObjList(this.test5.bind(this), this.test5Length()), this.bb!.createObjList<Test, TestT>(this.test5.bind(this), this.test5Length()),
this.bb!.createScalarList(this.vectorOfLongs.bind(this), this.vectorOfLongsLength()), this.bb!.createScalarList<bigint>(this.vectorOfLongs.bind(this), this.vectorOfLongsLength()),
this.bb!.createScalarList(this.vectorOfDoubles.bind(this), this.vectorOfDoublesLength()), this.bb!.createScalarList<number>(this.vectorOfDoubles.bind(this), this.vectorOfDoublesLength()),
(this.parentNamespaceTest() !== null ? this.parentNamespaceTest()!.unpack() : null), (this.parentNamespaceTest() !== null ? this.parentNamespaceTest()!.unpack() : null),
this.bb!.createObjList(this.vectorOfReferrables.bind(this), this.vectorOfReferrablesLength()), this.bb!.createObjList<Referrable, ReferrableT>(this.vectorOfReferrables.bind(this), this.vectorOfReferrablesLength()),
this.singleWeakReference(), this.singleWeakReference(),
this.bb!.createScalarList(this.vectorOfWeakReferences.bind(this), this.vectorOfWeakReferencesLength()), this.bb!.createScalarList<bigint>(this.vectorOfWeakReferences.bind(this), this.vectorOfWeakReferencesLength()),
this.bb!.createObjList(this.vectorOfStrongReferrables.bind(this), this.vectorOfStrongReferrablesLength()), this.bb!.createObjList<Referrable, ReferrableT>(this.vectorOfStrongReferrables.bind(this), this.vectorOfStrongReferrablesLength()),
this.coOwningReference(), this.coOwningReference(),
this.bb!.createScalarList(this.vectorOfCoOwningReferences.bind(this), this.vectorOfCoOwningReferencesLength()), this.bb!.createScalarList<bigint>(this.vectorOfCoOwningReferences.bind(this), this.vectorOfCoOwningReferencesLength()),
this.nonOwningReference(), this.nonOwningReference(),
this.bb!.createScalarList(this.vectorOfNonOwningReferences.bind(this), this.vectorOfNonOwningReferencesLength()), this.bb!.createScalarList<bigint>(this.vectorOfNonOwningReferences.bind(this), this.vectorOfNonOwningReferencesLength()),
this.anyUniqueType(), this.anyUniqueType(),
(() => { (() => {
let temp = unionToAnyUniqueAliases(this.anyUniqueType(), this.anyUnique.bind(this)); const temp = unionToAnyUniqueAliases(this.anyUniqueType(), this.anyUnique.bind(this));
if(temp === null) { return null; } if(temp === null) { return null; }
return temp.unpack() return temp.unpack()
})(), })(),
this.anyAmbiguousType(), this.anyAmbiguousType(),
(() => { (() => {
let temp = unionToAnyAmbiguousAliases(this.anyAmbiguousType(), this.anyAmbiguous.bind(this)); const temp = unionToAnyAmbiguousAliases(this.anyAmbiguousType(), this.anyAmbiguous.bind(this));
if(temp === null) { return null; } if(temp === null) { return null; }
return temp.unpack() return temp.unpack()
})(), })(),
this.bb!.createScalarList(this.vectorOfEnums.bind(this), this.vectorOfEnumsLength()), this.bb!.createScalarList<Color>(this.vectorOfEnums.bind(this), this.vectorOfEnumsLength()),
this.signedEnum(), this.signedEnum(),
this.bb!.createScalarList(this.testrequirednestedflatbuffer.bind(this), this.testrequirednestedflatbufferLength()), this.bb!.createScalarList<number>(this.testrequirednestedflatbuffer.bind(this), this.testrequirednestedflatbufferLength()),
this.bb!.createObjList(this.scalarKeySortedTables.bind(this), this.scalarKeySortedTablesLength()), this.bb!.createObjList<Stat, StatT>(this.scalarKeySortedTables.bind(this), this.scalarKeySortedTablesLength()),
(this.nativeInline() !== null ? this.nativeInline()!.unpack() : null), (this.nativeInline() !== null ? this.nativeInline()!.unpack() : null),
this.longEnumNonEnumDefault(), this.longEnumNonEnumDefault(),
this.longEnumNormalDefault() this.longEnumNormalDefault()
@@ -1223,19 +1223,19 @@ unpackTo(_o: MonsterT): void {
_o.mana = this.mana(); _o.mana = this.mana();
_o.hp = this.hp(); _o.hp = this.hp();
_o.name = this.name(); _o.name = this.name();
_o.inventory = this.bb!.createScalarList(this.inventory.bind(this), this.inventoryLength()); _o.inventory = this.bb!.createScalarList<number>(this.inventory.bind(this), this.inventoryLength());
_o.color = this.color(); _o.color = this.color();
_o.testType = this.testType(); _o.testType = this.testType();
_o.test = (() => { _o.test = (() => {
let temp = unionToAny(this.testType(), this.test.bind(this)); const temp = unionToAny(this.testType(), this.test.bind(this));
if(temp === null) { return null; } if(temp === null) { return null; }
return temp.unpack() return temp.unpack()
})(); })();
_o.test4 = this.bb!.createObjList(this.test4.bind(this), this.test4Length()); _o.test4 = this.bb!.createObjList<Test, TestT>(this.test4.bind(this), this.test4Length());
_o.testarrayofstring = this.bb!.createScalarList(this.testarrayofstring.bind(this), this.testarrayofstringLength()); _o.testarrayofstring = this.bb!.createScalarList<string>(this.testarrayofstring.bind(this), this.testarrayofstringLength());
_o.testarrayoftables = this.bb!.createObjList(this.testarrayoftables.bind(this), this.testarrayoftablesLength()); _o.testarrayoftables = this.bb!.createObjList<Monster, MonsterT>(this.testarrayoftables.bind(this), this.testarrayoftablesLength());
_o.enemy = (this.enemy() !== null ? this.enemy()!.unpack() : null); _o.enemy = (this.enemy() !== null ? this.enemy()!.unpack() : null);
_o.testnestedflatbuffer = this.bb!.createScalarList(this.testnestedflatbuffer.bind(this), this.testnestedflatbufferLength()); _o.testnestedflatbuffer = this.bb!.createScalarList<number>(this.testnestedflatbuffer.bind(this), this.testnestedflatbufferLength());
_o.testempty = (this.testempty() !== null ? this.testempty()!.unpack() : null); _o.testempty = (this.testempty() !== null ? this.testempty()!.unpack() : null);
_o.testbool = this.testbool(); _o.testbool = this.testbool();
_o.testhashs32Fnv1 = this.testhashs32Fnv1(); _o.testhashs32Fnv1 = this.testhashs32Fnv1();
@@ -1246,48 +1246,48 @@ unpackTo(_o: MonsterT): void {
_o.testhashu32Fnv1a = this.testhashu32Fnv1a(); _o.testhashu32Fnv1a = this.testhashu32Fnv1a();
_o.testhashs64Fnv1a = this.testhashs64Fnv1a(); _o.testhashs64Fnv1a = this.testhashs64Fnv1a();
_o.testhashu64Fnv1a = this.testhashu64Fnv1a(); _o.testhashu64Fnv1a = this.testhashu64Fnv1a();
_o.testarrayofbools = this.bb!.createScalarList(this.testarrayofbools.bind(this), this.testarrayofboolsLength()); _o.testarrayofbools = this.bb!.createScalarList<boolean>(this.testarrayofbools.bind(this), this.testarrayofboolsLength());
_o.testf = this.testf(); _o.testf = this.testf();
_o.testf2 = this.testf2(); _o.testf2 = this.testf2();
_o.testf3 = this.testf3(); _o.testf3 = this.testf3();
_o.testarrayofstring2 = this.bb!.createScalarList(this.testarrayofstring2.bind(this), this.testarrayofstring2Length()); _o.testarrayofstring2 = this.bb!.createScalarList<string>(this.testarrayofstring2.bind(this), this.testarrayofstring2Length());
_o.testarrayofsortedstruct = this.bb!.createObjList(this.testarrayofsortedstruct.bind(this), this.testarrayofsortedstructLength()); _o.testarrayofsortedstruct = this.bb!.createObjList<Ability, AbilityT>(this.testarrayofsortedstruct.bind(this), this.testarrayofsortedstructLength());
_o.flex = this.bb!.createScalarList(this.flex.bind(this), this.flexLength()); _o.flex = this.bb!.createScalarList<number>(this.flex.bind(this), this.flexLength());
_o.test5 = this.bb!.createObjList(this.test5.bind(this), this.test5Length()); _o.test5 = this.bb!.createObjList<Test, TestT>(this.test5.bind(this), this.test5Length());
_o.vectorOfLongs = this.bb!.createScalarList(this.vectorOfLongs.bind(this), this.vectorOfLongsLength()); _o.vectorOfLongs = this.bb!.createScalarList<bigint>(this.vectorOfLongs.bind(this), this.vectorOfLongsLength());
_o.vectorOfDoubles = this.bb!.createScalarList(this.vectorOfDoubles.bind(this), this.vectorOfDoublesLength()); _o.vectorOfDoubles = this.bb!.createScalarList<number>(this.vectorOfDoubles.bind(this), this.vectorOfDoublesLength());
_o.parentNamespaceTest = (this.parentNamespaceTest() !== null ? this.parentNamespaceTest()!.unpack() : null); _o.parentNamespaceTest = (this.parentNamespaceTest() !== null ? this.parentNamespaceTest()!.unpack() : null);
_o.vectorOfReferrables = this.bb!.createObjList(this.vectorOfReferrables.bind(this), this.vectorOfReferrablesLength()); _o.vectorOfReferrables = this.bb!.createObjList<Referrable, ReferrableT>(this.vectorOfReferrables.bind(this), this.vectorOfReferrablesLength());
_o.singleWeakReference = this.singleWeakReference(); _o.singleWeakReference = this.singleWeakReference();
_o.vectorOfWeakReferences = this.bb!.createScalarList(this.vectorOfWeakReferences.bind(this), this.vectorOfWeakReferencesLength()); _o.vectorOfWeakReferences = this.bb!.createScalarList<bigint>(this.vectorOfWeakReferences.bind(this), this.vectorOfWeakReferencesLength());
_o.vectorOfStrongReferrables = this.bb!.createObjList(this.vectorOfStrongReferrables.bind(this), this.vectorOfStrongReferrablesLength()); _o.vectorOfStrongReferrables = this.bb!.createObjList<Referrable, ReferrableT>(this.vectorOfStrongReferrables.bind(this), this.vectorOfStrongReferrablesLength());
_o.coOwningReference = this.coOwningReference(); _o.coOwningReference = this.coOwningReference();
_o.vectorOfCoOwningReferences = this.bb!.createScalarList(this.vectorOfCoOwningReferences.bind(this), this.vectorOfCoOwningReferencesLength()); _o.vectorOfCoOwningReferences = this.bb!.createScalarList<bigint>(this.vectorOfCoOwningReferences.bind(this), this.vectorOfCoOwningReferencesLength());
_o.nonOwningReference = this.nonOwningReference(); _o.nonOwningReference = this.nonOwningReference();
_o.vectorOfNonOwningReferences = this.bb!.createScalarList(this.vectorOfNonOwningReferences.bind(this), this.vectorOfNonOwningReferencesLength()); _o.vectorOfNonOwningReferences = this.bb!.createScalarList<bigint>(this.vectorOfNonOwningReferences.bind(this), this.vectorOfNonOwningReferencesLength());
_o.anyUniqueType = this.anyUniqueType(); _o.anyUniqueType = this.anyUniqueType();
_o.anyUnique = (() => { _o.anyUnique = (() => {
let temp = unionToAnyUniqueAliases(this.anyUniqueType(), this.anyUnique.bind(this)); const temp = unionToAnyUniqueAliases(this.anyUniqueType(), this.anyUnique.bind(this));
if(temp === null) { return null; } if(temp === null) { return null; }
return temp.unpack() return temp.unpack()
})(); })();
_o.anyAmbiguousType = this.anyAmbiguousType(); _o.anyAmbiguousType = this.anyAmbiguousType();
_o.anyAmbiguous = (() => { _o.anyAmbiguous = (() => {
let temp = unionToAnyAmbiguousAliases(this.anyAmbiguousType(), this.anyAmbiguous.bind(this)); const temp = unionToAnyAmbiguousAliases(this.anyAmbiguousType(), this.anyAmbiguous.bind(this));
if(temp === null) { return null; } if(temp === null) { return null; }
return temp.unpack() return temp.unpack()
})(); })();
_o.vectorOfEnums = this.bb!.createScalarList(this.vectorOfEnums.bind(this), this.vectorOfEnumsLength()); _o.vectorOfEnums = this.bb!.createScalarList<Color>(this.vectorOfEnums.bind(this), this.vectorOfEnumsLength());
_o.signedEnum = this.signedEnum(); _o.signedEnum = this.signedEnum();
_o.testrequirednestedflatbuffer = this.bb!.createScalarList(this.testrequirednestedflatbuffer.bind(this), this.testrequirednestedflatbufferLength()); _o.testrequirednestedflatbuffer = this.bb!.createScalarList<number>(this.testrequirednestedflatbuffer.bind(this), this.testrequirednestedflatbufferLength());
_o.scalarKeySortedTables = this.bb!.createObjList(this.scalarKeySortedTables.bind(this), this.scalarKeySortedTablesLength()); _o.scalarKeySortedTables = this.bb!.createObjList<Stat, StatT>(this.scalarKeySortedTables.bind(this), this.scalarKeySortedTablesLength());
_o.nativeInline = (this.nativeInline() !== null ? this.nativeInline()!.unpack() : null); _o.nativeInline = (this.nativeInline() !== null ? this.nativeInline()!.unpack() : null);
_o.longEnumNonEnumDefault = this.longEnumNonEnumDefault(); _o.longEnumNonEnumDefault = this.longEnumNonEnumDefault();
_o.longEnumNormalDefault = this.longEnumNormalDefault(); _o.longEnumNormalDefault = this.longEnumNormalDefault();
} }
} }
export class MonsterT { export class MonsterT implements flatbuffers.IGeneratedObject {
constructor( constructor(
public pos: Vec3T|null = null, public pos: Vec3T|null = null,
public mana: number = 150, public mana: number = 150,

View File

@@ -4,7 +4,7 @@ import * as flatbuffers from 'flatbuffers';
export class Referrable { export class Referrable implements flatbuffers.IUnpackableObject<ReferrableT> {
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 {
@@ -81,7 +81,7 @@ unpackTo(_o: ReferrableT): void {
} }
} }
export class ReferrableT { export class ReferrableT implements flatbuffers.IGeneratedObject {
constructor( constructor(
public id: bigint = BigInt('0') public id: bigint = BigInt('0')
){} ){}

View File

@@ -4,7 +4,7 @@ import * as flatbuffers from 'flatbuffers';
export class Stat { export class Stat implements flatbuffers.IUnpackableObject<StatT> {
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 {
@@ -118,7 +118,7 @@ unpackTo(_o: StatT): void {
} }
} }
export class StatT { export class StatT implements flatbuffers.IGeneratedObject {
constructor( constructor(
public id: string|Uint8Array|null = null, public id: string|Uint8Array|null = null,
public val: bigint = BigInt('0'), public val: bigint = BigInt('0'),

View File

@@ -5,7 +5,7 @@ import * as flatbuffers from 'flatbuffers';
import { StructOfStructs, StructOfStructsT } from '../../my-game/example/struct-of-structs.js'; import { StructOfStructs, StructOfStructsT } from '../../my-game/example/struct-of-structs.js';
export class StructOfStructsOfStructs { export class StructOfStructsOfStructs implements flatbuffers.IUnpackableObject<StructOfStructsOfStructsT> {
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 {
@@ -55,7 +55,7 @@ unpackTo(_o: StructOfStructsOfStructsT): void {
} }
} }
export class StructOfStructsOfStructsT { export class StructOfStructsOfStructsT implements flatbuffers.IGeneratedObject {
constructor( constructor(
public a: StructOfStructsT|null = null public a: StructOfStructsT|null = null
){} ){}

View File

@@ -6,7 +6,7 @@ import { Ability, AbilityT } from '../../my-game/example/ability.js';
import { Test, TestT } from '../../my-game/example/test.js'; import { Test, TestT } from '../../my-game/example/test.js';
export class StructOfStructs { export class StructOfStructs implements flatbuffers.IUnpackableObject<StructOfStructsT> {
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 {
@@ -67,7 +67,7 @@ unpackTo(_o: StructOfStructsT): void {
} }
} }
export class StructOfStructsT { export class StructOfStructsT implements flatbuffers.IGeneratedObject {
constructor( constructor(
public a: AbilityT|null = null, public a: AbilityT|null = null,
public b: TestT|null = null, public b: TestT|null = null,

View File

@@ -5,7 +5,7 @@ import * as flatbuffers from 'flatbuffers';
import { Color } from '../../my-game/example/color.js'; import { Color } from '../../my-game/example/color.js';
export class TestSimpleTableWithEnum { export class TestSimpleTableWithEnum implements flatbuffers.IUnpackableObject<TestSimpleTableWithEnumT> {
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 {
@@ -82,7 +82,7 @@ unpackTo(_o: TestSimpleTableWithEnumT): void {
} }
} }
export class TestSimpleTableWithEnumT { export class TestSimpleTableWithEnumT implements flatbuffers.IGeneratedObject {
constructor( constructor(
public color: Color = Color.Green public color: Color = Color.Green
){} ){}

View File

@@ -4,7 +4,7 @@ import * as flatbuffers from 'flatbuffers';
export class Test { export class Test implements flatbuffers.IUnpackableObject<TestT> {
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 {
@@ -62,7 +62,7 @@ unpackTo(_o: TestT): void {
} }
} }
export class TestT { export class TestT implements flatbuffers.IGeneratedObject {
constructor( constructor(
public a: number = 0, public a: number = 0,
public b: number = 0 public b: number = 0

View File

@@ -4,7 +4,7 @@ import * as flatbuffers from 'flatbuffers';
export class TypeAliases { export class TypeAliases implements flatbuffers.IUnpackableObject<TypeAliasesT> {
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 {
@@ -344,8 +344,8 @@ unpack(): TypeAliasesT {
this.u64(), this.u64(),
this.f32(), this.f32(),
this.f64(), this.f64(),
this.bb!.createScalarList(this.v8.bind(this), this.v8Length()), this.bb!.createScalarList<number>(this.v8.bind(this), this.v8Length()),
this.bb!.createScalarList(this.vf64.bind(this), this.vf64Length()) this.bb!.createScalarList<number>(this.vf64.bind(this), this.vf64Length())
); );
} }
@@ -361,12 +361,12 @@ unpackTo(_o: TypeAliasesT): void {
_o.u64 = this.u64(); _o.u64 = this.u64();
_o.f32 = this.f32(); _o.f32 = this.f32();
_o.f64 = this.f64(); _o.f64 = this.f64();
_o.v8 = this.bb!.createScalarList(this.v8.bind(this), this.v8Length()); _o.v8 = this.bb!.createScalarList<number>(this.v8.bind(this), this.v8Length());
_o.vf64 = this.bb!.createScalarList(this.vf64.bind(this), this.vf64Length()); _o.vf64 = this.bb!.createScalarList<number>(this.vf64.bind(this), this.vf64Length());
} }
} }
export class TypeAliasesT { export class TypeAliasesT implements flatbuffers.IGeneratedObject {
constructor( constructor(
public i8: number = 0, public i8: number = 0,
public u8: number = 0, public u8: number = 0,

View File

@@ -6,7 +6,7 @@ import { Color } from '../../my-game/example/color.js';
import { Test, TestT } from '../../my-game/example/test.js'; import { Test, TestT } from '../../my-game/example/test.js';
export class Vec3 { export class Vec3 implements flatbuffers.IUnpackableObject<Vec3T> {
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 {
@@ -112,7 +112,7 @@ unpackTo(_o: Vec3T): void {
} }
} }
export class Vec3T { export class Vec3T implements flatbuffers.IGeneratedObject {
constructor( constructor(
public x: number = 0.0, public x: number = 0.0,
public y: number = 0.0, public y: number = 0.0,

View File

@@ -4,7 +4,7 @@ import * as flatbuffers from 'flatbuffers';
export class Monster { export class Monster implements flatbuffers.IUnpackableObject<MonsterT> {
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 {
@@ -56,7 +56,7 @@ unpack(): MonsterT {
unpackTo(_o: MonsterT): void {} unpackTo(_o: MonsterT): void {}
} }
export class MonsterT { export class MonsterT implements flatbuffers.IGeneratedObject {
constructor(){} constructor(){}

View File

@@ -4,7 +4,7 @@ import * as flatbuffers from 'flatbuffers';
export class InParentNamespace { export class InParentNamespace implements flatbuffers.IUnpackableObject<InParentNamespaceT> {
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 {
@@ -56,7 +56,7 @@ unpack(): InParentNamespaceT {
unpackTo(_o: InParentNamespaceT): void {} unpackTo(_o: InParentNamespaceT): void {}
} }
export class InParentNamespaceT { export class InParentNamespaceT implements flatbuffers.IGeneratedObject {
constructor(){} constructor(){}

View File

@@ -5,7 +5,7 @@ import * as flatbuffers from 'flatbuffers';
import { Type, TypeT } from '../reflection/type.js'; import { Type, TypeT } from '../reflection/type.js';
export class EnumVal { export class EnumVal implements flatbuffers.IUnpackableObject<EnumValT> {
bb: flatbuffers.ByteBuffer|null = null; bb: flatbuffers.ByteBuffer|null = null;
bb_pos = 0; bb_pos = 0;
__init(i:number, bb:flatbuffers.ByteBuffer):EnumVal { __init(i:number, bb:flatbuffers.ByteBuffer):EnumVal {
@@ -111,7 +111,7 @@ unpack(): EnumValT {
this.name(), this.name(),
this.value(), this.value(),
(this.unionType() !== null ? this.unionType()!.unpack() : null), (this.unionType() !== null ? this.unionType()!.unpack() : null),
this.bb!.createScalarList(this.documentation.bind(this), this.documentationLength()) this.bb!.createScalarList<string>(this.documentation.bind(this), this.documentationLength())
); );
} }
@@ -120,11 +120,11 @@ unpackTo(_o: EnumValT): void {
_o.name = this.name(); _o.name = this.name();
_o.value = this.value(); _o.value = this.value();
_o.unionType = (this.unionType() !== null ? this.unionType()!.unpack() : null); _o.unionType = (this.unionType() !== null ? this.unionType()!.unpack() : null);
_o.documentation = this.bb!.createScalarList(this.documentation.bind(this), this.documentationLength()); _o.documentation = this.bb!.createScalarList<string>(this.documentation.bind(this), this.documentationLength());
} }
} }
export class EnumValT { export class EnumValT implements flatbuffers.IGeneratedObject {
constructor( constructor(
public name: string|Uint8Array|null = null, public name: string|Uint8Array|null = null,
public value: bigint = BigInt('0'), public value: bigint = BigInt('0'),

View File

@@ -7,7 +7,7 @@ import { KeyValue, KeyValueT } from '../reflection/key-value.js';
import { Type, TypeT } from '../reflection/type.js'; import { Type, TypeT } from '../reflection/type.js';
export class Enum { export class Enum implements flatbuffers.IUnpackableObject<EnumT> {
bb: flatbuffers.ByteBuffer|null = null; bb: flatbuffers.ByteBuffer|null = null;
bb_pos = 0; bb_pos = 0;
__init(i:number, bb:flatbuffers.ByteBuffer):Enum { __init(i:number, bb:flatbuffers.ByteBuffer):Enum {
@@ -179,11 +179,11 @@ static endEnum(builder:flatbuffers.Builder):flatbuffers.Offset {
unpack(): EnumT { unpack(): EnumT {
return new EnumT( return new EnumT(
this.name(), this.name(),
this.bb!.createObjList(this.values.bind(this), this.valuesLength()), this.bb!.createObjList<EnumVal, EnumValT>(this.values.bind(this), this.valuesLength()),
this.isUnion(), this.isUnion(),
(this.underlyingType() !== null ? this.underlyingType()!.unpack() : null), (this.underlyingType() !== null ? this.underlyingType()!.unpack() : null),
this.bb!.createObjList(this.attributes.bind(this), this.attributesLength()), this.bb!.createObjList<KeyValue, KeyValueT>(this.attributes.bind(this), this.attributesLength()),
this.bb!.createScalarList(this.documentation.bind(this), this.documentationLength()), this.bb!.createScalarList<string>(this.documentation.bind(this), this.documentationLength()),
this.declarationFile() this.declarationFile()
); );
} }
@@ -191,16 +191,16 @@ unpack(): EnumT {
unpackTo(_o: EnumT): void { unpackTo(_o: EnumT): void {
_o.name = this.name(); _o.name = this.name();
_o.values = this.bb!.createObjList(this.values.bind(this), this.valuesLength()); _o.values = this.bb!.createObjList<EnumVal, EnumValT>(this.values.bind(this), this.valuesLength());
_o.isUnion = this.isUnion(); _o.isUnion = this.isUnion();
_o.underlyingType = (this.underlyingType() !== null ? this.underlyingType()!.unpack() : null); _o.underlyingType = (this.underlyingType() !== null ? this.underlyingType()!.unpack() : null);
_o.attributes = this.bb!.createObjList(this.attributes.bind(this), this.attributesLength()); _o.attributes = this.bb!.createObjList<KeyValue, KeyValueT>(this.attributes.bind(this), this.attributesLength());
_o.documentation = this.bb!.createScalarList(this.documentation.bind(this), this.documentationLength()); _o.documentation = this.bb!.createScalarList<string>(this.documentation.bind(this), this.documentationLength());
_o.declarationFile = this.declarationFile(); _o.declarationFile = this.declarationFile();
} }
} }
export class EnumT { export class EnumT implements flatbuffers.IGeneratedObject {
constructor( constructor(
public name: string|Uint8Array|null = null, public name: string|Uint8Array|null = null,
public values: (EnumValT)[] = [], public values: (EnumValT)[] = [],

View File

@@ -6,7 +6,7 @@ import { KeyValue, KeyValueT } from '../reflection/key-value.js';
import { Type, TypeT } from '../reflection/type.js'; import { Type, TypeT } from '../reflection/type.js';
export class Field { export class Field implements flatbuffers.IUnpackableObject<FieldT> {
bb: flatbuffers.ByteBuffer|null = null; bb: flatbuffers.ByteBuffer|null = null;
bb_pos = 0; bb_pos = 0;
__init(i:number, bb:flatbuffers.ByteBuffer):Field { __init(i:number, bb:flatbuffers.ByteBuffer):Field {
@@ -308,8 +308,8 @@ unpack(): FieldT {
this.deprecated(), this.deprecated(),
this.required(), this.required(),
this.key(), this.key(),
this.bb!.createObjList(this.attributes.bind(this), this.attributesLength()), this.bb!.createObjList<KeyValue, KeyValueT>(this.attributes.bind(this), this.attributesLength()),
this.bb!.createScalarList(this.documentation.bind(this), this.documentationLength()), this.bb!.createScalarList<string>(this.documentation.bind(this), this.documentationLength()),
this.optional(), this.optional(),
this.padding() this.padding()
); );
@@ -326,14 +326,14 @@ unpackTo(_o: FieldT): void {
_o.deprecated = this.deprecated(); _o.deprecated = this.deprecated();
_o.required = this.required(); _o.required = this.required();
_o.key = this.key(); _o.key = this.key();
_o.attributes = this.bb!.createObjList(this.attributes.bind(this), this.attributesLength()); _o.attributes = this.bb!.createObjList<KeyValue, KeyValueT>(this.attributes.bind(this), this.attributesLength());
_o.documentation = this.bb!.createScalarList(this.documentation.bind(this), this.documentationLength()); _o.documentation = this.bb!.createScalarList<string>(this.documentation.bind(this), this.documentationLength());
_o.optional = this.optional(); _o.optional = this.optional();
_o.padding = this.padding(); _o.padding = this.padding();
} }
} }
export class FieldT { export class FieldT implements flatbuffers.IGeneratedObject {
constructor( constructor(
public name: string|Uint8Array|null = null, public name: string|Uint8Array|null = null,
public type: TypeT|null = null, public type: TypeT|null = null,

View File

@@ -4,7 +4,7 @@ import * as flatbuffers from 'flatbuffers';
export class KeyValue { export class KeyValue implements flatbuffers.IUnpackableObject<KeyValueT> {
bb: flatbuffers.ByteBuffer|null = null; bb: flatbuffers.ByteBuffer|null = null;
bb_pos = 0; bb_pos = 0;
__init(i:number, bb:flatbuffers.ByteBuffer):KeyValue { __init(i:number, bb:flatbuffers.ByteBuffer):KeyValue {
@@ -79,7 +79,7 @@ unpackTo(_o: KeyValueT): void {
} }
} }
export class KeyValueT { export class KeyValueT implements flatbuffers.IGeneratedObject {
constructor( constructor(
public key: string|Uint8Array|null = null, public key: string|Uint8Array|null = null,
public value: string|Uint8Array|null = null public value: string|Uint8Array|null = null

View File

@@ -6,7 +6,7 @@ import { Field, FieldT } from '../reflection/field.js';
import { KeyValue, KeyValueT } from '../reflection/key-value.js'; import { KeyValue, KeyValueT } from '../reflection/key-value.js';
export class Object_ { export class Object_ implements flatbuffers.IUnpackableObject<Object_T> {
bb: flatbuffers.ByteBuffer|null = null; bb: flatbuffers.ByteBuffer|null = null;
bb_pos = 0; bb_pos = 0;
__init(i:number, bb:flatbuffers.ByteBuffer):Object_ { __init(i:number, bb:flatbuffers.ByteBuffer):Object_ {
@@ -220,12 +220,12 @@ static createObject(builder:flatbuffers.Builder, nameOffset:flatbuffers.Offset,
unpack(): Object_T { unpack(): Object_T {
return new Object_T( return new Object_T(
this.name(), this.name(),
this.bb!.createObjList(this.fields.bind(this), this.fieldsLength()), this.bb!.createObjList<Field, FieldT>(this.fields.bind(this), this.fieldsLength()),
this.isStruct(), this.isStruct(),
this.minalign(), this.minalign(),
this.bytesize(), this.bytesize(),
this.bb!.createObjList(this.attributes.bind(this), this.attributesLength()), this.bb!.createObjList<KeyValue, KeyValueT>(this.attributes.bind(this), this.attributesLength()),
this.bb!.createScalarList(this.documentation.bind(this), this.documentationLength()), this.bb!.createScalarList<string>(this.documentation.bind(this), this.documentationLength()),
this.declarationFile() this.declarationFile()
); );
} }
@@ -233,17 +233,17 @@ unpack(): Object_T {
unpackTo(_o: Object_T): void { unpackTo(_o: Object_T): void {
_o.name = this.name(); _o.name = this.name();
_o.fields = this.bb!.createObjList(this.fields.bind(this), this.fieldsLength()); _o.fields = this.bb!.createObjList<Field, FieldT>(this.fields.bind(this), this.fieldsLength());
_o.isStruct = this.isStruct(); _o.isStruct = this.isStruct();
_o.minalign = this.minalign(); _o.minalign = this.minalign();
_o.bytesize = this.bytesize(); _o.bytesize = this.bytesize();
_o.attributes = this.bb!.createObjList(this.attributes.bind(this), this.attributesLength()); _o.attributes = this.bb!.createObjList<KeyValue, KeyValueT>(this.attributes.bind(this), this.attributesLength());
_o.documentation = this.bb!.createScalarList(this.documentation.bind(this), this.documentationLength()); _o.documentation = this.bb!.createScalarList<string>(this.documentation.bind(this), this.documentationLength());
_o.declarationFile = this.declarationFile(); _o.declarationFile = this.declarationFile();
} }
} }
export class Object_T { export class Object_T implements flatbuffers.IGeneratedObject {
constructor( constructor(
public name: string|Uint8Array|null = null, public name: string|Uint8Array|null = null,
public fields: (FieldT)[] = [], public fields: (FieldT)[] = [],

View File

@@ -6,7 +6,7 @@ import { KeyValue, KeyValueT } from '../reflection/key-value.js';
import { Object_, Object_T } from '../reflection/object.js'; import { Object_, Object_T } from '../reflection/object.js';
export class RPCCall { export class RPCCall implements flatbuffers.IUnpackableObject<RPCCallT> {
bb: flatbuffers.ByteBuffer|null = null; bb: flatbuffers.ByteBuffer|null = null;
bb_pos = 0; bb_pos = 0;
__init(i:number, bb:flatbuffers.ByteBuffer):RPCCall { __init(i:number, bb:flatbuffers.ByteBuffer):RPCCall {
@@ -129,8 +129,8 @@ unpack(): RPCCallT {
this.name(), this.name(),
(this.request() !== null ? this.request()!.unpack() : null), (this.request() !== null ? this.request()!.unpack() : null),
(this.response() !== null ? this.response()!.unpack() : null), (this.response() !== null ? this.response()!.unpack() : null),
this.bb!.createObjList(this.attributes.bind(this), this.attributesLength()), this.bb!.createObjList<KeyValue, KeyValueT>(this.attributes.bind(this), this.attributesLength()),
this.bb!.createScalarList(this.documentation.bind(this), this.documentationLength()) this.bb!.createScalarList<string>(this.documentation.bind(this), this.documentationLength())
); );
} }
@@ -139,12 +139,12 @@ unpackTo(_o: RPCCallT): void {
_o.name = this.name(); _o.name = this.name();
_o.request = (this.request() !== null ? this.request()!.unpack() : null); _o.request = (this.request() !== null ? this.request()!.unpack() : null);
_o.response = (this.response() !== null ? this.response()!.unpack() : null); _o.response = (this.response() !== null ? this.response()!.unpack() : null);
_o.attributes = this.bb!.createObjList(this.attributes.bind(this), this.attributesLength()); _o.attributes = this.bb!.createObjList<KeyValue, KeyValueT>(this.attributes.bind(this), this.attributesLength());
_o.documentation = this.bb!.createScalarList(this.documentation.bind(this), this.documentationLength()); _o.documentation = this.bb!.createScalarList<string>(this.documentation.bind(this), this.documentationLength());
} }
} }
export class RPCCallT { export class RPCCallT implements flatbuffers.IGeneratedObject {
constructor( constructor(
public name: string|Uint8Array|null = null, public name: string|Uint8Array|null = null,
public request: Object_T|null = null, public request: Object_T|null = null,

View File

@@ -9,7 +9,7 @@ import * as flatbuffers from 'flatbuffers';
* Symbols declared within a file may be recovered by iterating over all * Symbols declared within a file may be recovered by iterating over all
* symbols and examining the `declaration_file` field. * symbols and examining the `declaration_file` field.
*/ */
export class SchemaFile { export class SchemaFile implements flatbuffers.IUnpackableObject<SchemaFileT> {
bb: flatbuffers.ByteBuffer|null = null; bb: flatbuffers.ByteBuffer|null = null;
bb_pos = 0; bb_pos = 0;
__init(i:number, bb:flatbuffers.ByteBuffer):SchemaFile { __init(i:number, bb:flatbuffers.ByteBuffer):SchemaFile {
@@ -96,18 +96,18 @@ static createSchemaFile(builder:flatbuffers.Builder, filenameOffset:flatbuffers.
unpack(): SchemaFileT { unpack(): SchemaFileT {
return new SchemaFileT( return new SchemaFileT(
this.filename(), this.filename(),
this.bb!.createScalarList(this.includedFilenames.bind(this), this.includedFilenamesLength()) this.bb!.createScalarList<string>(this.includedFilenames.bind(this), this.includedFilenamesLength())
); );
} }
unpackTo(_o: SchemaFileT): void { unpackTo(_o: SchemaFileT): void {
_o.filename = this.filename(); _o.filename = this.filename();
_o.includedFilenames = this.bb!.createScalarList(this.includedFilenames.bind(this), this.includedFilenamesLength()); _o.includedFilenames = this.bb!.createScalarList<string>(this.includedFilenames.bind(this), this.includedFilenamesLength());
} }
} }
export class SchemaFileT { export class SchemaFileT implements flatbuffers.IGeneratedObject {
constructor( constructor(
public filename: string|Uint8Array|null = null, public filename: string|Uint8Array|null = null,
public includedFilenames: (string)[] = [] public includedFilenames: (string)[] = []

View File

@@ -8,7 +8,7 @@ import { SchemaFile, SchemaFileT } from '../reflection/schema-file.js';
import { Service, ServiceT } from '../reflection/service.js'; import { Service, ServiceT } from '../reflection/service.js';
export class Schema { export class Schema implements flatbuffers.IUnpackableObject<SchemaT> {
bb: flatbuffers.ByteBuffer|null = null; bb: flatbuffers.ByteBuffer|null = null;
bb_pos = 0; bb_pos = 0;
__init(i:number, bb:flatbuffers.ByteBuffer):Schema { __init(i:number, bb:flatbuffers.ByteBuffer):Schema {
@@ -215,31 +215,31 @@ static finishSizePrefixedSchemaBuffer(builder:flatbuffers.Builder, offset:flatbu
unpack(): SchemaT { unpack(): SchemaT {
return new SchemaT( return new SchemaT(
this.bb!.createObjList(this.objects.bind(this), this.objectsLength()), this.bb!.createObjList<Object_, Object_T>(this.objects.bind(this), this.objectsLength()),
this.bb!.createObjList(this.enums.bind(this), this.enumsLength()), this.bb!.createObjList<Enum, EnumT>(this.enums.bind(this), this.enumsLength()),
this.fileIdent(), this.fileIdent(),
this.fileExt(), this.fileExt(),
(this.rootTable() !== null ? this.rootTable()!.unpack() : null), (this.rootTable() !== null ? this.rootTable()!.unpack() : null),
this.bb!.createObjList(this.services.bind(this), this.servicesLength()), this.bb!.createObjList<Service, ServiceT>(this.services.bind(this), this.servicesLength()),
this.advancedFeatures(), this.advancedFeatures(),
this.bb!.createObjList(this.fbsFiles.bind(this), this.fbsFilesLength()) this.bb!.createObjList<SchemaFile, SchemaFileT>(this.fbsFiles.bind(this), this.fbsFilesLength())
); );
} }
unpackTo(_o: SchemaT): void { unpackTo(_o: SchemaT): void {
_o.objects = this.bb!.createObjList(this.objects.bind(this), this.objectsLength()); _o.objects = this.bb!.createObjList<Object_, Object_T>(this.objects.bind(this), this.objectsLength());
_o.enums = this.bb!.createObjList(this.enums.bind(this), this.enumsLength()); _o.enums = this.bb!.createObjList<Enum, EnumT>(this.enums.bind(this), this.enumsLength());
_o.fileIdent = this.fileIdent(); _o.fileIdent = this.fileIdent();
_o.fileExt = this.fileExt(); _o.fileExt = this.fileExt();
_o.rootTable = (this.rootTable() !== null ? this.rootTable()!.unpack() : null); _o.rootTable = (this.rootTable() !== null ? this.rootTable()!.unpack() : null);
_o.services = this.bb!.createObjList(this.services.bind(this), this.servicesLength()); _o.services = this.bb!.createObjList<Service, ServiceT>(this.services.bind(this), this.servicesLength());
_o.advancedFeatures = this.advancedFeatures(); _o.advancedFeatures = this.advancedFeatures();
_o.fbsFiles = this.bb!.createObjList(this.fbsFiles.bind(this), this.fbsFilesLength()); _o.fbsFiles = this.bb!.createObjList<SchemaFile, SchemaFileT>(this.fbsFiles.bind(this), this.fbsFilesLength());
} }
} }
export class SchemaT { export class SchemaT implements flatbuffers.IGeneratedObject {
constructor( constructor(
public objects: (Object_T)[] = [], public objects: (Object_T)[] = [],
public enums: (EnumT)[] = [], public enums: (EnumT)[] = [],

View File

@@ -6,7 +6,7 @@ import { KeyValue, KeyValueT } from '../reflection/key-value.js';
import { RPCCall, RPCCallT } from '../reflection/rpccall.js'; import { RPCCall, RPCCallT } from '../reflection/rpccall.js';
export class Service { export class Service implements flatbuffers.IUnpackableObject<ServiceT> {
bb: flatbuffers.ByteBuffer|null = null; bb: flatbuffers.ByteBuffer|null = null;
bb_pos = 0; bb_pos = 0;
__init(i:number, bb:flatbuffers.ByteBuffer):Service { __init(i:number, bb:flatbuffers.ByteBuffer):Service {
@@ -156,9 +156,9 @@ static createService(builder:flatbuffers.Builder, nameOffset:flatbuffers.Offset,
unpack(): ServiceT { unpack(): ServiceT {
return new ServiceT( return new ServiceT(
this.name(), this.name(),
this.bb!.createObjList(this.calls.bind(this), this.callsLength()), this.bb!.createObjList<RPCCall, RPCCallT>(this.calls.bind(this), this.callsLength()),
this.bb!.createObjList(this.attributes.bind(this), this.attributesLength()), this.bb!.createObjList<KeyValue, KeyValueT>(this.attributes.bind(this), this.attributesLength()),
this.bb!.createScalarList(this.documentation.bind(this), this.documentationLength()), this.bb!.createScalarList<string>(this.documentation.bind(this), this.documentationLength()),
this.declarationFile() this.declarationFile()
); );
} }
@@ -166,14 +166,14 @@ unpack(): ServiceT {
unpackTo(_o: ServiceT): void { unpackTo(_o: ServiceT): void {
_o.name = this.name(); _o.name = this.name();
_o.calls = this.bb!.createObjList(this.calls.bind(this), this.callsLength()); _o.calls = this.bb!.createObjList<RPCCall, RPCCallT>(this.calls.bind(this), this.callsLength());
_o.attributes = this.bb!.createObjList(this.attributes.bind(this), this.attributesLength()); _o.attributes = this.bb!.createObjList<KeyValue, KeyValueT>(this.attributes.bind(this), this.attributesLength());
_o.documentation = this.bb!.createScalarList(this.documentation.bind(this), this.documentationLength()); _o.documentation = this.bb!.createScalarList<string>(this.documentation.bind(this), this.documentationLength());
_o.declarationFile = this.declarationFile(); _o.declarationFile = this.declarationFile();
} }
} }
export class ServiceT { export class ServiceT implements flatbuffers.IGeneratedObject {
constructor( constructor(
public name: string|Uint8Array|null = null, public name: string|Uint8Array|null = null,
public calls: (RPCCallT)[] = [], public calls: (RPCCallT)[] = [],

View File

@@ -5,7 +5,7 @@ import * as flatbuffers from 'flatbuffers';
import { BaseType } from '../reflection/base-type.js'; import { BaseType } from '../reflection/base-type.js';
export class Type { export class Type implements flatbuffers.IUnpackableObject<TypeT> {
bb: flatbuffers.ByteBuffer|null = null; bb: flatbuffers.ByteBuffer|null = null;
bb_pos = 0; bb_pos = 0;
__init(i:number, bb:flatbuffers.ByteBuffer):Type { __init(i:number, bb:flatbuffers.ByteBuffer):Type {
@@ -195,7 +195,7 @@ unpackTo(_o: TypeT): void {
} }
} }
export class TypeT { export class TypeT implements flatbuffers.IGeneratedObject {
constructor( constructor(
public baseType: BaseType = BaseType.None, public baseType: BaseType = BaseType.None,
public element: BaseType = BaseType.None, public element: BaseType = BaseType.None,

View File

@@ -35,7 +35,7 @@ export enum AdvancedFeatures {
DefaultVectorsAndStrings = '8' DefaultVectorsAndStrings = '8'
} }
export class Type { export class Type implements flatbuffers.IUnpackableObject<TypeT> {
bb: flatbuffers.ByteBuffer|null = null; bb: flatbuffers.ByteBuffer|null = null;
bb_pos = 0; bb_pos = 0;
__init(i:number, bb:flatbuffers.ByteBuffer):Type { __init(i:number, bb:flatbuffers.ByteBuffer):Type {
@@ -225,7 +225,7 @@ unpackTo(_o: TypeT): void {
} }
} }
export class TypeT { export class TypeT implements flatbuffers.IGeneratedObject {
constructor( constructor(
public baseType: BaseType = BaseType.None, public baseType: BaseType = BaseType.None,
public element: BaseType = BaseType.None, public element: BaseType = BaseType.None,
@@ -248,7 +248,7 @@ pack(builder:flatbuffers.Builder): flatbuffers.Offset {
} }
} }
export class KeyValue { export class KeyValue implements flatbuffers.IUnpackableObject<KeyValueT> {
bb: flatbuffers.ByteBuffer|null = null; bb: flatbuffers.ByteBuffer|null = null;
bb_pos = 0; bb_pos = 0;
__init(i:number, bb:flatbuffers.ByteBuffer):KeyValue { __init(i:number, bb:flatbuffers.ByteBuffer):KeyValue {
@@ -323,7 +323,7 @@ unpackTo(_o: KeyValueT): void {
} }
} }
export class KeyValueT { export class KeyValueT implements flatbuffers.IGeneratedObject {
constructor( constructor(
public key: string|Uint8Array|null = null, public key: string|Uint8Array|null = null,
public value: string|Uint8Array|null = null public value: string|Uint8Array|null = null
@@ -341,7 +341,7 @@ pack(builder:flatbuffers.Builder): flatbuffers.Offset {
} }
} }
export class EnumVal { export class EnumVal implements flatbuffers.IUnpackableObject<EnumValT> {
bb: flatbuffers.ByteBuffer|null = null; bb: flatbuffers.ByteBuffer|null = null;
bb_pos = 0; bb_pos = 0;
__init(i:number, bb:flatbuffers.ByteBuffer):EnumVal { __init(i:number, bb:flatbuffers.ByteBuffer):EnumVal {
@@ -447,7 +447,7 @@ unpack(): EnumValT {
this.name(), this.name(),
this.value(), this.value(),
(this.unionType() !== null ? this.unionType()!.unpack() : null), (this.unionType() !== null ? this.unionType()!.unpack() : null),
this.bb!.createScalarList(this.documentation.bind(this), this.documentationLength()) this.bb!.createScalarList<string>(this.documentation.bind(this), this.documentationLength())
); );
} }
@@ -456,11 +456,11 @@ unpackTo(_o: EnumValT): void {
_o.name = this.name(); _o.name = this.name();
_o.value = this.value(); _o.value = this.value();
_o.unionType = (this.unionType() !== null ? this.unionType()!.unpack() : null); _o.unionType = (this.unionType() !== null ? this.unionType()!.unpack() : null);
_o.documentation = this.bb!.createScalarList(this.documentation.bind(this), this.documentationLength()); _o.documentation = this.bb!.createScalarList<string>(this.documentation.bind(this), this.documentationLength());
} }
} }
export class EnumValT { export class EnumValT implements flatbuffers.IGeneratedObject {
constructor( constructor(
public name: string|Uint8Array|null = null, public name: string|Uint8Array|null = null,
public value: bigint = BigInt('0'), public value: bigint = BigInt('0'),
@@ -484,7 +484,7 @@ pack(builder:flatbuffers.Builder): flatbuffers.Offset {
} }
} }
export class Enum { export class Enum implements flatbuffers.IUnpackableObject<EnumT> {
bb: flatbuffers.ByteBuffer|null = null; bb: flatbuffers.ByteBuffer|null = null;
bb_pos = 0; bb_pos = 0;
__init(i:number, bb:flatbuffers.ByteBuffer):Enum { __init(i:number, bb:flatbuffers.ByteBuffer):Enum {
@@ -656,11 +656,11 @@ static endEnum(builder:flatbuffers.Builder):flatbuffers.Offset {
unpack(): EnumT { unpack(): EnumT {
return new EnumT( return new EnumT(
this.name(), this.name(),
this.bb!.createObjList(this.values.bind(this), this.valuesLength()), this.bb!.createObjList<EnumVal, EnumValT>(this.values.bind(this), this.valuesLength()),
this.isUnion(), this.isUnion(),
(this.underlyingType() !== null ? this.underlyingType()!.unpack() : null), (this.underlyingType() !== null ? this.underlyingType()!.unpack() : null),
this.bb!.createObjList(this.attributes.bind(this), this.attributesLength()), this.bb!.createObjList<KeyValue, KeyValueT>(this.attributes.bind(this), this.attributesLength()),
this.bb!.createScalarList(this.documentation.bind(this), this.documentationLength()), this.bb!.createScalarList<string>(this.documentation.bind(this), this.documentationLength()),
this.declarationFile() this.declarationFile()
); );
} }
@@ -668,16 +668,16 @@ unpack(): EnumT {
unpackTo(_o: EnumT): void { unpackTo(_o: EnumT): void {
_o.name = this.name(); _o.name = this.name();
_o.values = this.bb!.createObjList(this.values.bind(this), this.valuesLength()); _o.values = this.bb!.createObjList<EnumVal, EnumValT>(this.values.bind(this), this.valuesLength());
_o.isUnion = this.isUnion(); _o.isUnion = this.isUnion();
_o.underlyingType = (this.underlyingType() !== null ? this.underlyingType()!.unpack() : null); _o.underlyingType = (this.underlyingType() !== null ? this.underlyingType()!.unpack() : null);
_o.attributes = this.bb!.createObjList(this.attributes.bind(this), this.attributesLength()); _o.attributes = this.bb!.createObjList<KeyValue, KeyValueT>(this.attributes.bind(this), this.attributesLength());
_o.documentation = this.bb!.createScalarList(this.documentation.bind(this), this.documentationLength()); _o.documentation = this.bb!.createScalarList<string>(this.documentation.bind(this), this.documentationLength());
_o.declarationFile = this.declarationFile(); _o.declarationFile = this.declarationFile();
} }
} }
export class EnumT { export class EnumT implements flatbuffers.IGeneratedObject {
constructor( constructor(
public name: string|Uint8Array|null = null, public name: string|Uint8Array|null = null,
public values: (EnumValT)[] = [], public values: (EnumValT)[] = [],
@@ -710,7 +710,7 @@ pack(builder:flatbuffers.Builder): flatbuffers.Offset {
} }
} }
export class Field { export class Field implements flatbuffers.IUnpackableObject<FieldT> {
bb: flatbuffers.ByteBuffer|null = null; bb: flatbuffers.ByteBuffer|null = null;
bb_pos = 0; bb_pos = 0;
__init(i:number, bb:flatbuffers.ByteBuffer):Field { __init(i:number, bb:flatbuffers.ByteBuffer):Field {
@@ -1012,8 +1012,8 @@ unpack(): FieldT {
this.deprecated(), this.deprecated(),
this.required(), this.required(),
this.key(), this.key(),
this.bb!.createObjList(this.attributes.bind(this), this.attributesLength()), this.bb!.createObjList<KeyValue, KeyValueT>(this.attributes.bind(this), this.attributesLength()),
this.bb!.createScalarList(this.documentation.bind(this), this.documentationLength()), this.bb!.createScalarList<string>(this.documentation.bind(this), this.documentationLength()),
this.optional(), this.optional(),
this.padding() this.padding()
); );
@@ -1030,14 +1030,14 @@ unpackTo(_o: FieldT): void {
_o.deprecated = this.deprecated(); _o.deprecated = this.deprecated();
_o.required = this.required(); _o.required = this.required();
_o.key = this.key(); _o.key = this.key();
_o.attributes = this.bb!.createObjList(this.attributes.bind(this), this.attributesLength()); _o.attributes = this.bb!.createObjList<KeyValue, KeyValueT>(this.attributes.bind(this), this.attributesLength());
_o.documentation = this.bb!.createScalarList(this.documentation.bind(this), this.documentationLength()); _o.documentation = this.bb!.createScalarList<string>(this.documentation.bind(this), this.documentationLength());
_o.optional = this.optional(); _o.optional = this.optional();
_o.padding = this.padding(); _o.padding = this.padding();
} }
} }
export class FieldT { export class FieldT implements flatbuffers.IGeneratedObject {
constructor( constructor(
public name: string|Uint8Array|null = null, public name: string|Uint8Array|null = null,
public type: TypeT|null = null, public type: TypeT|null = null,
@@ -1080,7 +1080,7 @@ pack(builder:flatbuffers.Builder): flatbuffers.Offset {
} }
} }
export class Object_ { export class Object_ implements flatbuffers.IUnpackableObject<Object_T> {
bb: flatbuffers.ByteBuffer|null = null; bb: flatbuffers.ByteBuffer|null = null;
bb_pos = 0; bb_pos = 0;
__init(i:number, bb:flatbuffers.ByteBuffer):Object_ { __init(i:number, bb:flatbuffers.ByteBuffer):Object_ {
@@ -1294,12 +1294,12 @@ static createObject(builder:flatbuffers.Builder, nameOffset:flatbuffers.Offset,
unpack(): Object_T { unpack(): Object_T {
return new Object_T( return new Object_T(
this.name(), this.name(),
this.bb!.createObjList(this.fields.bind(this), this.fieldsLength()), this.bb!.createObjList<Field, FieldT>(this.fields.bind(this), this.fieldsLength()),
this.isStruct(), this.isStruct(),
this.minalign(), this.minalign(),
this.bytesize(), this.bytesize(),
this.bb!.createObjList(this.attributes.bind(this), this.attributesLength()), this.bb!.createObjList<KeyValue, KeyValueT>(this.attributes.bind(this), this.attributesLength()),
this.bb!.createScalarList(this.documentation.bind(this), this.documentationLength()), this.bb!.createScalarList<string>(this.documentation.bind(this), this.documentationLength()),
this.declarationFile() this.declarationFile()
); );
} }
@@ -1307,17 +1307,17 @@ unpack(): Object_T {
unpackTo(_o: Object_T): void { unpackTo(_o: Object_T): void {
_o.name = this.name(); _o.name = this.name();
_o.fields = this.bb!.createObjList(this.fields.bind(this), this.fieldsLength()); _o.fields = this.bb!.createObjList<Field, FieldT>(this.fields.bind(this), this.fieldsLength());
_o.isStruct = this.isStruct(); _o.isStruct = this.isStruct();
_o.minalign = this.minalign(); _o.minalign = this.minalign();
_o.bytesize = this.bytesize(); _o.bytesize = this.bytesize();
_o.attributes = this.bb!.createObjList(this.attributes.bind(this), this.attributesLength()); _o.attributes = this.bb!.createObjList<KeyValue, KeyValueT>(this.attributes.bind(this), this.attributesLength());
_o.documentation = this.bb!.createScalarList(this.documentation.bind(this), this.documentationLength()); _o.documentation = this.bb!.createScalarList<string>(this.documentation.bind(this), this.documentationLength());
_o.declarationFile = this.declarationFile(); _o.declarationFile = this.declarationFile();
} }
} }
export class Object_T { export class Object_T implements flatbuffers.IGeneratedObject {
constructor( constructor(
public name: string|Uint8Array|null = null, public name: string|Uint8Array|null = null,
public fields: (FieldT)[] = [], public fields: (FieldT)[] = [],
@@ -1350,7 +1350,7 @@ pack(builder:flatbuffers.Builder): flatbuffers.Offset {
} }
} }
export class RPCCall { export class RPCCall implements flatbuffers.IUnpackableObject<RPCCallT> {
bb: flatbuffers.ByteBuffer|null = null; bb: flatbuffers.ByteBuffer|null = null;
bb_pos = 0; bb_pos = 0;
__init(i:number, bb:flatbuffers.ByteBuffer):RPCCall { __init(i:number, bb:flatbuffers.ByteBuffer):RPCCall {
@@ -1473,8 +1473,8 @@ unpack(): RPCCallT {
this.name(), this.name(),
(this.request() !== null ? this.request()!.unpack() : null), (this.request() !== null ? this.request()!.unpack() : null),
(this.response() !== null ? this.response()!.unpack() : null), (this.response() !== null ? this.response()!.unpack() : null),
this.bb!.createObjList(this.attributes.bind(this), this.attributesLength()), this.bb!.createObjList<KeyValue, KeyValueT>(this.attributes.bind(this), this.attributesLength()),
this.bb!.createScalarList(this.documentation.bind(this), this.documentationLength()) this.bb!.createScalarList<string>(this.documentation.bind(this), this.documentationLength())
); );
} }
@@ -1483,12 +1483,12 @@ unpackTo(_o: RPCCallT): void {
_o.name = this.name(); _o.name = this.name();
_o.request = (this.request() !== null ? this.request()!.unpack() : null); _o.request = (this.request() !== null ? this.request()!.unpack() : null);
_o.response = (this.response() !== null ? this.response()!.unpack() : null); _o.response = (this.response() !== null ? this.response()!.unpack() : null);
_o.attributes = this.bb!.createObjList(this.attributes.bind(this), this.attributesLength()); _o.attributes = this.bb!.createObjList<KeyValue, KeyValueT>(this.attributes.bind(this), this.attributesLength());
_o.documentation = this.bb!.createScalarList(this.documentation.bind(this), this.documentationLength()); _o.documentation = this.bb!.createScalarList<string>(this.documentation.bind(this), this.documentationLength());
} }
} }
export class RPCCallT { export class RPCCallT implements flatbuffers.IGeneratedObject {
constructor( constructor(
public name: string|Uint8Array|null = null, public name: string|Uint8Array|null = null,
public request: Object_T|null = null, public request: Object_T|null = null,
@@ -1516,7 +1516,7 @@ pack(builder:flatbuffers.Builder): flatbuffers.Offset {
} }
} }
export class Service { export class Service implements flatbuffers.IUnpackableObject<ServiceT> {
bb: flatbuffers.ByteBuffer|null = null; bb: flatbuffers.ByteBuffer|null = null;
bb_pos = 0; bb_pos = 0;
__init(i:number, bb:flatbuffers.ByteBuffer):Service { __init(i:number, bb:flatbuffers.ByteBuffer):Service {
@@ -1666,9 +1666,9 @@ static createService(builder:flatbuffers.Builder, nameOffset:flatbuffers.Offset,
unpack(): ServiceT { unpack(): ServiceT {
return new ServiceT( return new ServiceT(
this.name(), this.name(),
this.bb!.createObjList(this.calls.bind(this), this.callsLength()), this.bb!.createObjList<RPCCall, RPCCallT>(this.calls.bind(this), this.callsLength()),
this.bb!.createObjList(this.attributes.bind(this), this.attributesLength()), this.bb!.createObjList<KeyValue, KeyValueT>(this.attributes.bind(this), this.attributesLength()),
this.bb!.createScalarList(this.documentation.bind(this), this.documentationLength()), this.bb!.createScalarList<string>(this.documentation.bind(this), this.documentationLength()),
this.declarationFile() this.declarationFile()
); );
} }
@@ -1676,14 +1676,14 @@ unpack(): ServiceT {
unpackTo(_o: ServiceT): void { unpackTo(_o: ServiceT): void {
_o.name = this.name(); _o.name = this.name();
_o.calls = this.bb!.createObjList(this.calls.bind(this), this.callsLength()); _o.calls = this.bb!.createObjList<RPCCall, RPCCallT>(this.calls.bind(this), this.callsLength());
_o.attributes = this.bb!.createObjList(this.attributes.bind(this), this.attributesLength()); _o.attributes = this.bb!.createObjList<KeyValue, KeyValueT>(this.attributes.bind(this), this.attributesLength());
_o.documentation = this.bb!.createScalarList(this.documentation.bind(this), this.documentationLength()); _o.documentation = this.bb!.createScalarList<string>(this.documentation.bind(this), this.documentationLength());
_o.declarationFile = this.declarationFile(); _o.declarationFile = this.declarationFile();
} }
} }
export class ServiceT { export class ServiceT implements flatbuffers.IGeneratedObject {
constructor( constructor(
public name: string|Uint8Array|null = null, public name: string|Uint8Array|null = null,
public calls: (RPCCallT)[] = [], public calls: (RPCCallT)[] = [],
@@ -1715,7 +1715,7 @@ pack(builder:flatbuffers.Builder): flatbuffers.Offset {
* Symbols declared within a file may be recovered by iterating over all * Symbols declared within a file may be recovered by iterating over all
* symbols and examining the `declaration_file` field. * symbols and examining the `declaration_file` field.
*/ */
export class SchemaFile { export class SchemaFile implements flatbuffers.IUnpackableObject<SchemaFileT> {
bb: flatbuffers.ByteBuffer|null = null; bb: flatbuffers.ByteBuffer|null = null;
bb_pos = 0; bb_pos = 0;
__init(i:number, bb:flatbuffers.ByteBuffer):SchemaFile { __init(i:number, bb:flatbuffers.ByteBuffer):SchemaFile {
@@ -1802,18 +1802,18 @@ static createSchemaFile(builder:flatbuffers.Builder, filenameOffset:flatbuffers.
unpack(): SchemaFileT { unpack(): SchemaFileT {
return new SchemaFileT( return new SchemaFileT(
this.filename(), this.filename(),
this.bb!.createScalarList(this.includedFilenames.bind(this), this.includedFilenamesLength()) this.bb!.createScalarList<string>(this.includedFilenames.bind(this), this.includedFilenamesLength())
); );
} }
unpackTo(_o: SchemaFileT): void { unpackTo(_o: SchemaFileT): void {
_o.filename = this.filename(); _o.filename = this.filename();
_o.includedFilenames = this.bb!.createScalarList(this.includedFilenames.bind(this), this.includedFilenamesLength()); _o.includedFilenames = this.bb!.createScalarList<string>(this.includedFilenames.bind(this), this.includedFilenamesLength());
} }
} }
export class SchemaFileT { export class SchemaFileT implements flatbuffers.IGeneratedObject {
constructor( constructor(
public filename: string|Uint8Array|null = null, public filename: string|Uint8Array|null = null,
public includedFilenames: (string)[] = [] public includedFilenames: (string)[] = []
@@ -1831,7 +1831,7 @@ pack(builder:flatbuffers.Builder): flatbuffers.Offset {
} }
} }
export class Schema { export class Schema implements flatbuffers.IUnpackableObject<SchemaT> {
bb: flatbuffers.ByteBuffer|null = null; bb: flatbuffers.ByteBuffer|null = null;
bb_pos = 0; bb_pos = 0;
__init(i:number, bb:flatbuffers.ByteBuffer):Schema { __init(i:number, bb:flatbuffers.ByteBuffer):Schema {
@@ -2038,31 +2038,31 @@ static finishSizePrefixedSchemaBuffer(builder:flatbuffers.Builder, offset:flatbu
unpack(): SchemaT { unpack(): SchemaT {
return new SchemaT( return new SchemaT(
this.bb!.createObjList(this.objects.bind(this), this.objectsLength()), this.bb!.createObjList<Object_, Object_T>(this.objects.bind(this), this.objectsLength()),
this.bb!.createObjList(this.enums.bind(this), this.enumsLength()), this.bb!.createObjList<Enum, EnumT>(this.enums.bind(this), this.enumsLength()),
this.fileIdent(), this.fileIdent(),
this.fileExt(), this.fileExt(),
(this.rootTable() !== null ? this.rootTable()!.unpack() : null), (this.rootTable() !== null ? this.rootTable()!.unpack() : null),
this.bb!.createObjList(this.services.bind(this), this.servicesLength()), this.bb!.createObjList<Service, ServiceT>(this.services.bind(this), this.servicesLength()),
this.advancedFeatures(), this.advancedFeatures(),
this.bb!.createObjList(this.fbsFiles.bind(this), this.fbsFilesLength()) this.bb!.createObjList<SchemaFile, SchemaFileT>(this.fbsFiles.bind(this), this.fbsFilesLength())
); );
} }
unpackTo(_o: SchemaT): void { unpackTo(_o: SchemaT): void {
_o.objects = this.bb!.createObjList(this.objects.bind(this), this.objectsLength()); _o.objects = this.bb!.createObjList<Object_, Object_T>(this.objects.bind(this), this.objectsLength());
_o.enums = this.bb!.createObjList(this.enums.bind(this), this.enumsLength()); _o.enums = this.bb!.createObjList<Enum, EnumT>(this.enums.bind(this), this.enumsLength());
_o.fileIdent = this.fileIdent(); _o.fileIdent = this.fileIdent();
_o.fileExt = this.fileExt(); _o.fileExt = this.fileExt();
_o.rootTable = (this.rootTable() !== null ? this.rootTable()!.unpack() : null); _o.rootTable = (this.rootTable() !== null ? this.rootTable()!.unpack() : null);
_o.services = this.bb!.createObjList(this.services.bind(this), this.servicesLength()); _o.services = this.bb!.createObjList<Service, ServiceT>(this.services.bind(this), this.servicesLength());
_o.advancedFeatures = this.advancedFeatures(); _o.advancedFeatures = this.advancedFeatures();
_o.fbsFiles = this.bb!.createObjList(this.fbsFiles.bind(this), this.fbsFilesLength()); _o.fbsFiles = this.bb!.createObjList<SchemaFile, SchemaFileT>(this.fbsFiles.bind(this), this.fbsFilesLength());
} }
} }
export class SchemaT { export class SchemaT implements flatbuffers.IGeneratedObject {
constructor( constructor(
public objects: (Object_T)[] = [], public objects: (Object_T)[] = [],
public enums: (EnumT)[] = [], public enums: (EnumT)[] = [],

View File

@@ -8,7 +8,7 @@ import { Schema, SchemaT } from '../reflection/schema.js';
import { class_ } from '../typescript/class.js'; import { class_ } from '../typescript/class.js';
export class Object_ { export class Object_ implements flatbuffers.IUnpackableObject<Object_T> {
bb: flatbuffers.ByteBuffer|null = null; bb: flatbuffers.ByteBuffer|null = null;
bb_pos = 0; bb_pos = 0;
__init(i:number, bb:flatbuffers.ByteBuffer):Object_ { __init(i:number, bb:flatbuffers.ByteBuffer):Object_ {
@@ -193,7 +193,7 @@ unpackTo(_o: Object_T): void {
} }
} }
export class Object_T { export class Object_T implements flatbuffers.IGeneratedObject {
constructor( constructor(
public return_: number = 0, public return_: number = 0,
public if_: number = 0, public if_: number = 0,

View File

@@ -11,7 +11,7 @@ export enum class_ {
instanceof_ = 1 instanceof_ = 1
} }
export class Object_ { export class Object_ implements flatbuffers.IUnpackableObject<Object_T> {
bb: flatbuffers.ByteBuffer|null = null; bb: flatbuffers.ByteBuffer|null = null;
bb_pos = 0; bb_pos = 0;
__init(i:number, bb:flatbuffers.ByteBuffer):Object_ { __init(i:number, bb:flatbuffers.ByteBuffer):Object_ {
@@ -196,7 +196,7 @@ unpackTo(_o: Object_T): void {
} }
} }
export class Object_T { export class Object_T implements flatbuffers.IGeneratedObject {
constructor( constructor(
public return_: number = 0, public return_: number = 0,
public if_: number = 0, public if_: number = 0,

View File

@@ -4,7 +4,7 @@ import * as flatbuffers from 'flatbuffers';
export class Attacker { export class Attacker implements flatbuffers.IUnpackableObject<AttackerT> {
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 {
@@ -73,7 +73,7 @@ unpackTo(_o: AttackerT): void {
} }
} }
export class AttackerT { export class AttackerT implements flatbuffers.IGeneratedObject {
constructor( constructor(
public swordAttackDamage: number = 0 public swordAttackDamage: number = 0
){} ){}

View File

@@ -4,7 +4,7 @@ import * as flatbuffers from 'flatbuffers';
export class BookReader { export class BookReader implements flatbuffers.IUnpackableObject<BookReaderT> {
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 {
@@ -49,7 +49,7 @@ unpackTo(_o: BookReaderT): void {
} }
} }
export class BookReaderT { export class BookReaderT implements flatbuffers.IGeneratedObject {
constructor( constructor(
public booksRead: number = 0 public booksRead: number = 0
){} ){}

View File

@@ -4,7 +4,7 @@ import * as flatbuffers from 'flatbuffers';
export class FallingTub { export class FallingTub implements flatbuffers.IUnpackableObject<FallingTubT> {
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 {
@@ -49,7 +49,7 @@ unpackTo(_o: FallingTubT): void {
} }
} }
export class FallingTubT { export class FallingTubT implements flatbuffers.IGeneratedObject {
constructor( constructor(
public weight: number = 0 public weight: number = 0
){} ){}

View File

@@ -4,7 +4,7 @@ import * as flatbuffers from 'flatbuffers';
export class HandFan { export class HandFan implements flatbuffers.IUnpackableObject<HandFanT> {
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 {
@@ -73,7 +73,7 @@ unpackTo(_o: HandFanT): void {
} }
} }
export class HandFanT { export class HandFanT implements flatbuffers.IGeneratedObject {
constructor( constructor(
public length: number = 0 public length: number = 0
){} ){}

View File

@@ -107,7 +107,7 @@ export class Movie {
} }
unpack() { unpack() {
return new MovieT(this.mainCharacterType(), (() => { return new MovieT(this.mainCharacterType(), (() => {
let temp = unionToCharacter(this.mainCharacterType(), this.mainCharacter.bind(this)); const temp = unionToCharacter(this.mainCharacterType(), this.mainCharacter.bind(this));
if (temp === null) { if (temp === null) {
return null; return null;
} }
@@ -116,13 +116,13 @@ export class Movie {
} }
return temp.unpack(); return temp.unpack();
})(), this.bb.createScalarList(this.charactersType.bind(this), this.charactersTypeLength()), (() => { })(), this.bb.createScalarList(this.charactersType.bind(this), this.charactersTypeLength()), (() => {
let ret = []; const ret = [];
for (let targetEnumIndex = 0; targetEnumIndex < this.charactersTypeLength(); ++targetEnumIndex) { for (let targetEnumIndex = 0; targetEnumIndex < this.charactersTypeLength(); ++targetEnumIndex) {
let targetEnum = this.charactersType(targetEnumIndex); const targetEnum = this.charactersType(targetEnumIndex);
if (targetEnum === null || Character[targetEnum] === 'NONE') { if (targetEnum === null || Character[targetEnum] === 'NONE') {
continue; continue;
} }
let temp = unionListToCharacter(targetEnum, this.characters.bind(this), targetEnumIndex); const temp = unionListToCharacter(targetEnum, this.characters.bind(this), targetEnumIndex);
if (temp === null) { if (temp === null) {
continue; continue;
} }
@@ -138,7 +138,7 @@ export class Movie {
unpackTo(_o) { unpackTo(_o) {
_o.mainCharacterType = this.mainCharacterType(); _o.mainCharacterType = this.mainCharacterType();
_o.mainCharacter = (() => { _o.mainCharacter = (() => {
let temp = unionToCharacter(this.mainCharacterType(), this.mainCharacter.bind(this)); const temp = unionToCharacter(this.mainCharacterType(), this.mainCharacter.bind(this));
if (temp === null) { if (temp === null) {
return null; return null;
} }
@@ -149,13 +149,13 @@ export class Movie {
})(); })();
_o.charactersType = this.bb.createScalarList(this.charactersType.bind(this), this.charactersTypeLength()); _o.charactersType = this.bb.createScalarList(this.charactersType.bind(this), this.charactersTypeLength());
_o.characters = (() => { _o.characters = (() => {
let ret = []; const ret = [];
for (let targetEnumIndex = 0; targetEnumIndex < this.charactersTypeLength(); ++targetEnumIndex) { for (let targetEnumIndex = 0; targetEnumIndex < this.charactersTypeLength(); ++targetEnumIndex) {
let targetEnum = this.charactersType(targetEnumIndex); const targetEnum = this.charactersType(targetEnumIndex);
if (targetEnum === null || Character[targetEnum] === 'NONE') { if (targetEnum === null || Character[targetEnum] === 'NONE') {
continue; continue;
} }
let temp = unionListToCharacter(targetEnum, this.characters.bind(this), targetEnumIndex); const temp = unionListToCharacter(targetEnum, this.characters.bind(this), targetEnumIndex);
if (temp === null) { if (temp === null) {
continue; continue;
} }

View File

@@ -8,7 +8,7 @@ import { Character, unionToCharacter, unionListToCharacter } from './character.j
import { Rapunzel, RapunzelT } from './rapunzel.js'; import { Rapunzel, RapunzelT } from './rapunzel.js';
export class Movie { export class Movie implements flatbuffers.IUnpackableObject<MovieT> {
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 {
@@ -139,19 +139,19 @@ unpack(): MovieT {
return new MovieT( return new MovieT(
this.mainCharacterType(), this.mainCharacterType(),
(() => { (() => {
let temp = unionToCharacter(this.mainCharacterType(), this.mainCharacter.bind(this)); const temp = unionToCharacter(this.mainCharacterType(), this.mainCharacter.bind(this));
if(temp === null) { return null; } if(temp === null) { return null; }
if(typeof temp === 'string') { return temp; } if(typeof temp === 'string') { return temp; }
return temp.unpack() return temp.unpack()
})(), })(),
this.bb!.createScalarList(this.charactersType.bind(this), this.charactersTypeLength()), this.bb!.createScalarList<Character>(this.charactersType.bind(this), this.charactersTypeLength()),
(() => { (() => {
let ret = []; const ret = [];
for(let targetEnumIndex = 0; targetEnumIndex < this.charactersTypeLength(); ++targetEnumIndex) { for(let targetEnumIndex = 0; targetEnumIndex < this.charactersTypeLength(); ++targetEnumIndex) {
let targetEnum = this.charactersType(targetEnumIndex); const targetEnum = this.charactersType(targetEnumIndex);
if(targetEnum === null || Character[targetEnum!] === 'NONE') { continue; } if(targetEnum === null || Character[targetEnum!] === 'NONE') { continue; }
let temp = unionListToCharacter(targetEnum, this.characters.bind(this), targetEnumIndex); const temp = unionListToCharacter(targetEnum, this.characters.bind(this), targetEnumIndex);
if(temp === null) { continue; } if(temp === null) { continue; }
if(typeof temp === 'string') { ret.push(temp); continue; } if(typeof temp === 'string') { ret.push(temp); continue; }
ret.push(temp.unpack()); ret.push(temp.unpack());
@@ -165,19 +165,19 @@ unpack(): MovieT {
unpackTo(_o: MovieT): void { unpackTo(_o: MovieT): void {
_o.mainCharacterType = this.mainCharacterType(); _o.mainCharacterType = this.mainCharacterType();
_o.mainCharacter = (() => { _o.mainCharacter = (() => {
let temp = unionToCharacter(this.mainCharacterType(), this.mainCharacter.bind(this)); const temp = unionToCharacter(this.mainCharacterType(), this.mainCharacter.bind(this));
if(temp === null) { return null; } if(temp === null) { return null; }
if(typeof temp === 'string') { return temp; } if(typeof temp === 'string') { return temp; }
return temp.unpack() return temp.unpack()
})(); })();
_o.charactersType = this.bb!.createScalarList(this.charactersType.bind(this), this.charactersTypeLength()); _o.charactersType = this.bb!.createScalarList<Character>(this.charactersType.bind(this), this.charactersTypeLength());
_o.characters = (() => { _o.characters = (() => {
let ret = []; const ret = [];
for(let targetEnumIndex = 0; targetEnumIndex < this.charactersTypeLength(); ++targetEnumIndex) { for(let targetEnumIndex = 0; targetEnumIndex < this.charactersTypeLength(); ++targetEnumIndex) {
let targetEnum = this.charactersType(targetEnumIndex); const targetEnum = this.charactersType(targetEnumIndex);
if(targetEnum === null || Character[targetEnum!] === 'NONE') { continue; } if(targetEnum === null || Character[targetEnum!] === 'NONE') { continue; }
let temp = unionListToCharacter(targetEnum, this.characters.bind(this), targetEnumIndex); const temp = unionListToCharacter(targetEnum, this.characters.bind(this), targetEnumIndex);
if(temp === null) { continue; } if(temp === null) { continue; }
if(typeof temp === 'string') { ret.push(temp); continue; } if(typeof temp === 'string') { ret.push(temp); continue; }
ret.push(temp.unpack()); ret.push(temp.unpack());
@@ -187,7 +187,7 @@ unpackTo(_o: MovieT): void {
} }
} }
export class MovieT { export class MovieT implements flatbuffers.IGeneratedObject {
constructor( constructor(
public mainCharacterType: Character = Character.NONE, public mainCharacterType: Character = Character.NONE,
public mainCharacter: AttackerT|BookReaderT|RapunzelT|string|null = null, public mainCharacter: AttackerT|BookReaderT|RapunzelT|string|null = null,

View File

@@ -4,7 +4,7 @@ import * as flatbuffers from 'flatbuffers';
export class Rapunzel { export class Rapunzel implements flatbuffers.IUnpackableObject<RapunzelT> {
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 {
@@ -49,7 +49,7 @@ unpackTo(_o: RapunzelT): void {
} }
} }
export class RapunzelT { export class RapunzelT implements flatbuffers.IGeneratedObject {
constructor( constructor(
public hairLength: number = 0 public hairLength: number = 0
){} ){}

View File

@@ -549,7 +549,7 @@ export class Builder {
* *
* @returns offset of obj * @returns offset of obj
*/ */
createObjectOffset(obj: string | any): Offset { createObjectOffset(obj: string | IGeneratedObject | null): Offset {
if(obj === null) { if(obj === null) {
return 0 return 0
} }
@@ -566,7 +566,7 @@ export class Builder {
* *
* @returns list of offsets of each non null object * @returns list of offsets of each non null object
*/ */
createObjectOffsetList(list: string[] | any[]): Offset[] { createObjectOffsetList(list: (string | IGeneratedObject)[]): Offset[] {
const ret: number[] = []; const ret: number[] = [];
for(let i = 0; i < list.length; ++i) { for(let i = 0; i < list.length; ++i) {
@@ -583,7 +583,7 @@ export class Builder {
return ret; return ret;
} }
createStructOffsetList(list: string[] | any[], startFunc: (builder: Builder, length: number) => void): Offset { createStructOffsetList(list: (string | IGeneratedObject)[], startFunc: (builder: Builder, length: number) => void): Offset {
startFunc(this, list.length); startFunc(this, list.length);
this.createObjectOffsetList(list.slice().reverse()); this.createObjectOffsetList(list.slice().reverse());
return this.endVector(); return this.endVector();

View File

@@ -1,6 +1,6 @@
import { FILE_IDENTIFIER_LENGTH, SIZEOF_INT } from "./constants.js"; import { FILE_IDENTIFIER_LENGTH, SIZEOF_INT } from "./constants.js";
import { int32, isLittleEndian, float32, float64 } from "./utils.js"; import { int32, isLittleEndian, float32, float64 } from "./utils.js";
import { Offset, Table, IGeneratedObject } from "./types.js"; import { Offset, Table, IGeneratedObject, IUnpackableObject } from "./types.js";
import { Encoding } from "./encoding.js"; import { Encoding } from "./encoding.js";
export class ByteBuffer { export class ByteBuffer {
@@ -257,14 +257,14 @@ export class ByteBuffer {
/** /**
* A helper function for generating list for obj api * A helper function for generating list for obj api
*/ */
createScalarList(listAccessor: (i: number) => unknown, listLength: number): any[] { createScalarList<T>(listAccessor: (i: number) => T | null, listLength: number): T[] {
const ret: any[] = []; const ret: T[] = [];
for(let i = 0; i < listLength; ++i) { for(let i = 0; i < listLength; ++i) {
if(listAccessor(i) !== null) { const val = listAccessor(i);
ret.push(listAccessor(i)); if(val !== null) {
ret.push(val);
} }
} }
return ret; return ret;
} }
@@ -274,16 +274,14 @@ export class ByteBuffer {
* @param listLength listLength * @param listLength listLength
* @param res result list * @param res result list
*/ */
createObjList(listAccessor: (i: number) => unknown, listLength: number): any[] { createObjList<T1 extends IUnpackableObject<T2>, T2 extends IGeneratedObject>(listAccessor: (i: number) => T1 | null, listLength: number): T2[] {
const ret: any[] = []; const ret: T2[] = [];
for(let i = 0; i < listLength; ++i) { for(let i = 0; i < listLength; ++i) {
const val = listAccessor(i); const val = listAccessor(i);
if(val !== null) { if(val !== null) {
ret.push((val as IGeneratedObject).unpack()); ret.push(val.unpack());
} }
} }
return ret; return ret;
} }
} }

1
ts/flatbuffers.ts Normal file
View File

@@ -0,0 +1 @@
export * as flatbuffers from './index.js'

View File

@@ -3,7 +3,7 @@ export { SIZEOF_INT } from './constants.js'
export { FILE_IDENTIFIER_LENGTH } from './constants.js' export { FILE_IDENTIFIER_LENGTH } from './constants.js'
export { SIZE_PREFIX_LENGTH } from './constants.js' export { SIZE_PREFIX_LENGTH } from './constants.js'
export { Table, Offset } from './types.js' export { Table, Offset, IGeneratedObject, IUnpackableObject } from './types.js'
export { int32, float32, float64, isLittleEndian } from './utils.js' export { int32, float32, float64, isLittleEndian } from './utils.js'

View File

@@ -10,5 +10,8 @@ export type Table = {
export interface IGeneratedObject { export interface IGeneratedObject {
pack(builder:Builder): Offset pack(builder:Builder): Offset
unpack(): IGeneratedObject }
export interface IUnpackableObject<T> {
unpack(): T
} }