This commit is contained in:
Björn Harrtell
2026-04-08 05:42:25 +02:00
parent 496f10525b
commit 43e1505f61
23 changed files with 163 additions and 127 deletions

View File

@@ -296,11 +296,11 @@ class TsGenerator : public BaseGenerator {
auto fully_qualified_type_name = auto fully_qualified_type_name =
it.second.ns->GetFullyQualifiedName(type_name); it.second.ns->GetFullyQualifiedName(type_name);
auto is_struct = parser_.structs_.Lookup(fully_qualified_type_name); auto is_struct = parser_.structs_.Lookup(fully_qualified_type_name);
code += "export { " + type_name; code += "export {" + type_name;
if (parser_.opts.generate_object_based_api && is_struct) { if (parser_.opts.generate_object_based_api && is_struct) {
code += ", " + type_name + parser_.opts.object_suffix; code += ", " + type_name + parser_.opts.object_suffix;
} }
code += " } from '"; code += "} from '";
std::string import_extension = std::string import_extension =
parser_.opts.ts_no_import_ext ? "" : ".js"; parser_.opts.ts_no_import_ext ? "" : ".js";
code += base_name_rel + import_extension + "';\n"; code += base_name_rel + import_extension + "';\n";
@@ -1040,7 +1040,7 @@ class TsGenerator : public BaseGenerator {
std::string import_extension = parser_.opts.ts_no_import_ext ? "" : ".js"; std::string import_extension = parser_.opts.ts_no_import_ext ? "" : ".js";
import.import_statement = "import { " + symbols_expression + " } from '" + import.import_statement = "import { " + symbols_expression + " } from '" +
rel_file_path + import_extension + "';"; rel_file_path + import_extension + "';";
import.export_statement = "export { " + symbols_expression + " } from '." + import.export_statement = "export {" + symbols_expression + "} from '." +
bare_file_path + import_extension + "';"; bare_file_path + import_extension + "';";
import.dependency = &dependency; import.dependency = &dependency;
import.dependent = &dependent; import.dependent = &dependent;

View File

@@ -2,9 +2,9 @@
/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ /* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */
export { ArrayStruct, ArrayStructT } from './example/array-struct.js'; export {ArrayStruct, ArrayStructT} from './example/array-struct.js';
export { ArrayTable, ArrayTableT } from './example/array-table.js'; export {ArrayTable, ArrayTableT} from './example/array-table.js';
export { InnerStruct, InnerStructT } from './example/inner-struct.js'; export {InnerStruct, InnerStructT} from './example/inner-struct.js';
export { NestedStruct, NestedStructT } from './example/nested-struct.js'; export {NestedStruct, NestedStructT} from './example/nested-struct.js';
export { OuterStruct, OuterStructT } from './example/outer-struct.js'; export {OuterStruct, OuterStructT} from './example/outer-struct.js';
export { TestEnum } from './example/test-enum.js'; export {TestEnum} from './example/test-enum.js';

View File

@@ -2,4 +2,4 @@
/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ /* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */
export { Person } from './test/person.js'; export {Person} from './test/person.js';

View File

@@ -2,6 +2,6 @@
/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ /* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */
export { ABC } from './abc.js'; export {ABC} from './abc.js';
export { EvenMoreDefaults, EvenMoreDefaultsT } from './even-more-defaults.js'; export {EvenMoreDefaults, EvenMoreDefaultsT} from './even-more-defaults.js';
export { EvenMoreStruct, EvenMoreStructT } from './even-more-struct.js'; export {EvenMoreStruct, EvenMoreStructT} from './even-more-struct.js';

View File

@@ -2,4 +2,4 @@
/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ /* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */
export { Abc } from './foobar/abc.js'; export {Abc} from './foobar/abc.js';

View File

@@ -2,4 +2,4 @@
/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ /* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */
export { Person } from './c/person.js'; export {Person} from './c/person.js';

View File

@@ -2,5 +2,5 @@
/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ /* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */
export { TableA, TableAT } from './table-a.js'; export {TableA, TableAT} from './table-a.js';
export * as MyGame from './my-game.js'; export * as MyGame from './my-game.js';

View File

@@ -2,7 +2,7 @@
/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ /* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */
export { InParentNamespace, InParentNamespaceT } from './my-game/in-parent-namespace.js'; export {InParentNamespace, InParentNamespaceT} from './my-game/in-parent-namespace.js';
export * as Example from './my-game/example.js'; export * as Example from './my-game/example.js';
export * as Example2 from './my-game/example2.js'; export * as Example2 from './my-game/example2.js';
export * as OtherNameSpace from './my-game/other-name-space.js'; export * as OtherNameSpace from './my-game/other-name-space.js';

View File

@@ -2,19 +2,19 @@
/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ /* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */
export { Ability, AbilityT } from './example/ability.js'; export {Ability, AbilityT} from './example/ability.js';
export { Any } from './example/any.js'; export {Any} from './example/any.js';
export { AnyAmbiguousAliases } from './example/any-ambiguous-aliases.js'; export {AnyAmbiguousAliases} from './example/any-ambiguous-aliases.js';
export { AnyUniqueAliases } from './example/any-unique-aliases.js'; export {AnyUniqueAliases} from './example/any-unique-aliases.js';
export { Color } from './example/color.js'; export {Color} from './example/color.js';
export { LongEnum } from './example/long-enum.js'; export {LongEnum} from './example/long-enum.js';
export { Monster, MonsterT } from './example/monster.js'; export {Monster, MonsterT} from './example/monster.js';
export { Race } from './example/race.js'; export {Race} from './example/race.js';
export { Referrable, ReferrableT } from './example/referrable.js'; export {Referrable, ReferrableT} from './example/referrable.js';
export { Stat, StatT } from './example/stat.js'; export {Stat, StatT} from './example/stat.js';
export { StructOfStructs, StructOfStructsT } from './example/struct-of-structs.js'; export {StructOfStructs, StructOfStructsT} from './example/struct-of-structs.js';
export { StructOfStructsOfStructs, StructOfStructsOfStructsT } from './example/struct-of-structs-of-structs.js'; export {StructOfStructsOfStructs, StructOfStructsOfStructsT} from './example/struct-of-structs-of-structs.js';
export { Test, TestT } from './example/test.js'; export {Test, TestT} from './example/test.js';
export { TestSimpleTableWithEnum, TestSimpleTableWithEnumT } from './example/test-simple-table-with-enum.js'; export {TestSimpleTableWithEnum, TestSimpleTableWithEnumT} from './example/test-simple-table-with-enum.js';
export { TypeAliases, TypeAliasesT } from './example/type-aliases.js'; export {TypeAliases, TypeAliasesT} from './example/type-aliases.js';
export { Vec3, Vec3T } from './example/vec3.js'; export {Vec3, Vec3T} from './example/vec3.js';

View File

@@ -2,4 +2,4 @@
/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ /* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */
export { Monster, MonsterT } from './example2/monster.js'; export {Monster, MonsterT} from './example2/monster.js';

View File

@@ -2,6 +2,6 @@
/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ /* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */
export { FromInclude } from './other-name-space/from-include.js'; export {FromInclude} from './other-name-space/from-include.js';
export { TableB, TableBT } from './other-name-space/table-b.js'; export {TableB, TableBT} from './other-name-space/table-b.js';
export { Unused, UnusedT } from './other-name-space/unused.js'; export {Unused, UnusedT} from './other-name-space/unused.js';

View File

@@ -2,5 +2,5 @@
/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ /* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */
export { OptionalByte } from './optional-scalars/optional-byte'; export {OptionalByte} from './optional-scalars/optional-byte';
export { ScalarStuff } from './optional-scalars/scalar-stuff'; export {ScalarStuff} from './optional-scalars/scalar-stuff';

View File

@@ -2,5 +2,5 @@
/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ /* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */
export { NonZero } from './non-zero.js'; export {NonZero} from './non-zero.js';
export { NonZeroVectorTable, NonZeroVectorTableT } from './non-zero-vector-table.js'; export {NonZeroVectorTable, NonZeroVectorTableT} from './non-zero-vector-table.js';

View File

@@ -2,5 +2,5 @@
/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ /* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */
export { OptionalByte } from './optional-scalars/optional-byte.js'; export {OptionalByte} from './optional-scalars/optional-byte.js';
export { ScalarStuff } from './optional-scalars/scalar-stuff.js'; export {ScalarStuff} from './optional-scalars/scalar-stuff.js';

View File

@@ -2,15 +2,15 @@
/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ /* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */
export { AdvancedFeatures } from './reflection/advanced-features.js'; export {AdvancedFeatures} from './reflection/advanced-features.js';
export { BaseType } from './reflection/base-type.js'; export {BaseType} from './reflection/base-type.js';
export { Enum, EnumT } from './reflection/enum.js'; export {Enum, EnumT} from './reflection/enum.js';
export { EnumVal, EnumValT } from './reflection/enum-val.js'; export {EnumVal, EnumValT} from './reflection/enum-val.js';
export { Field, FieldT } from './reflection/field.js'; export {Field, FieldT} from './reflection/field.js';
export { KeyValue, KeyValueT } from './reflection/key-value.js'; export {KeyValue, KeyValueT} from './reflection/key-value.js';
export { Object_ } from './reflection/object.js'; export {Object_} from './reflection/object.js';
export { RPCCall, RPCCallT } from './reflection/rpccall.js'; export {RPCCall, RPCCallT} from './reflection/rpccall.js';
export { Schema, SchemaT } from './reflection/schema.js'; export {Schema, SchemaT} from './reflection/schema.js';
export { SchemaFile, SchemaFileT } from './reflection/schema-file.js'; export {SchemaFile, SchemaFileT} from './reflection/schema-file.js';
export { Service, ServiceT } from './reflection/service.js'; export {Service, ServiceT} from './reflection/service.js';
export { Type, TypeT } from './reflection/type.js'; export {Type, TypeT} from './reflection/type.js';

View File

@@ -2,4 +2,4 @@
/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ /* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */
export { Info, InfoT } from './one/info.js'; export {Info, InfoT} from './one/info.js';

View File

@@ -2,4 +2,4 @@
/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ /* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */
export { Header, HeaderT } from './three/header.js'; export {Header, HeaderT} from './three/header.js';

View File

@@ -2,4 +2,4 @@
/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ /* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */
export { Identity, IdentityT } from './two/identity.js'; export {Identity, IdentityT} from './two/identity.js';

View File

@@ -2,5 +2,5 @@
/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ /* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */
export { OptionalByte } from './optional-scalars/optional-byte.js'; export {OptionalByte} from './optional-scalars/optional-byte.js';
export { ScalarStuff, ScalarStuffT } from './optional-scalars/scalar-stuff.js'; export {ScalarStuff, ScalarStuffT} from './optional-scalars/scalar-stuff.js';

View File

@@ -2,5 +2,5 @@
/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ /* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */
export { Object_ } from './typescript/object.js'; export {Object_} from './typescript/object.js';
export { class_ } from './typescript/class.js'; export {class_} from './typescript/class.js';

View File

@@ -2,8 +2,8 @@
/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ /* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */
export { A, AT } from './union-underlying-type/a.js'; export {A, AT} from './union-underlying-type/a.js';
export { ABC } from './union-underlying-type/abc.js'; export {ABC} from './union-underlying-type/abc.js';
export { B, BT } from './union-underlying-type/b.js'; export {B, BT} from './union-underlying-type/b.js';
export { C, CT } from './union-underlying-type/c.js'; export {C, CT} from './union-underlying-type/c.js';
export { D, DT } from './union-underlying-type/d.js'; export {D, DT} from './union-underlying-type/d.js';

View File

@@ -2,11 +2,11 @@
/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ /* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */
export { Attacker, AttackerT } from './attacker.js'; export {Attacker, AttackerT} from './attacker.js';
export { BookReader, BookReaderT } from './book-reader.js'; export {BookReader, BookReaderT} from './book-reader.js';
export { Character } from './character.js'; export {Character} from './character.js';
export { FallingTub, FallingTubT } from './falling-tub.js'; export {FallingTub, FallingTubT} from './falling-tub.js';
export { Gadget } from './gadget.js'; export {Gadget} from './gadget.js';
export { HandFan, HandFanT } from './hand-fan.js'; export {HandFan, HandFanT} from './hand-fan.js';
export { Movie, MovieT } from './movie.js'; export {Movie, MovieT} from './movie.js';
export { Rapunzel, RapunzelT } from './rapunzel.js'; export {Rapunzel, RapunzelT} from './rapunzel.js';

View File

@@ -47,7 +47,7 @@ __export(union_vector_exports, {
}); });
module.exports = __toCommonJS(union_vector_exports); module.exports = __toCommonJS(union_vector_exports);
// union_vector/attacker.js // union_vector/attacker.ts
var flatbuffers = __toESM(require("flatbuffers"), 1); var flatbuffers = __toESM(require("flatbuffers"), 1);
var Attacker = class _Attacker { var Attacker = class _Attacker {
constructor() { constructor() {
@@ -97,7 +97,9 @@ var Attacker = class _Attacker {
return _Attacker.endAttacker(builder); return _Attacker.endAttacker(builder);
} }
unpack() { unpack() {
return new AttackerT(this.swordAttackDamage()); return new AttackerT(
this.swordAttackDamage()
);
} }
unpackTo(_o) { unpackTo(_o) {
_o.swordAttackDamage = this.swordAttackDamage(); _o.swordAttackDamage = this.swordAttackDamage();
@@ -108,11 +110,14 @@ var AttackerT = class {
this.swordAttackDamage = swordAttackDamage; this.swordAttackDamage = swordAttackDamage;
} }
pack(builder) { pack(builder) {
return Attacker.createAttacker(builder, this.swordAttackDamage); return Attacker.createAttacker(
builder,
this.swordAttackDamage
);
} }
}; };
// union_vector/book-reader.js // union_vector/book-reader.ts
var BookReader = class { var BookReader = class {
constructor() { constructor() {
this.bb = null; this.bb = null;
@@ -142,7 +147,9 @@ var BookReader = class {
return builder.offset(); return builder.offset();
} }
unpack() { unpack() {
return new BookReaderT(this.booksRead()); return new BookReaderT(
this.booksRead()
);
} }
unpackTo(_o) { unpackTo(_o) {
_o.booksRead = this.booksRead(); _o.booksRead = this.booksRead();
@@ -153,11 +160,14 @@ var BookReaderT = class {
this.booksRead = booksRead; this.booksRead = booksRead;
} }
pack(builder) { pack(builder) {
return BookReader.createBookReader(builder, this.booksRead); return BookReader.createBookReader(
builder,
this.booksRead
);
} }
}; };
// union_vector/rapunzel.js // union_vector/rapunzel.ts
var Rapunzel = class { var Rapunzel = class {
constructor() { constructor() {
this.bb = null; this.bb = null;
@@ -187,7 +197,9 @@ var Rapunzel = class {
return builder.offset(); return builder.offset();
} }
unpack() { unpack() {
return new RapunzelT(this.hairLength()); return new RapunzelT(
this.hairLength()
);
} }
unpackTo(_o) { unpackTo(_o) {
_o.hairLength = this.hairLength(); _o.hairLength = this.hairLength();
@@ -198,13 +210,15 @@ var RapunzelT = class {
this.hairLength = hairLength; this.hairLength = hairLength;
} }
pack(builder) { pack(builder) {
return Rapunzel.createRapunzel(builder, this.hairLength); return Rapunzel.createRapunzel(
builder,
this.hairLength
);
} }
}; };
// union_vector/character.js // union_vector/character.ts
var Character; var Character = /* @__PURE__ */ ((Character2) => {
(function(Character2) {
Character2[Character2["NONE"] = 0] = "NONE"; Character2[Character2["NONE"] = 0] = "NONE";
Character2[Character2["MuLan"] = 1] = "MuLan"; Character2[Character2["MuLan"] = 1] = "MuLan";
Character2[Character2["Rapunzel"] = 2] = "Rapunzel"; Character2[Character2["Rapunzel"] = 2] = "Rapunzel";
@@ -212,7 +226,8 @@ var Character;
Character2[Character2["BookFan"] = 4] = "BookFan"; Character2[Character2["BookFan"] = 4] = "BookFan";
Character2[Character2["Other"] = 5] = "Other"; Character2[Character2["Other"] = 5] = "Other";
Character2[Character2["Unused"] = 6] = "Unused"; Character2[Character2["Unused"] = 6] = "Unused";
})(Character || (Character = {})); return Character2;
})(Character || {});
function unionToCharacter(type, accessor) { function unionToCharacter(type, accessor) {
switch (Character[type]) { switch (Character[type]) {
case "NONE": case "NONE":
@@ -254,7 +269,7 @@ function unionListToCharacter(type, accessor, index) {
} }
} }
// union_vector/falling-tub.js // union_vector/falling-tub.ts
var FallingTub = class { var FallingTub = class {
constructor() { constructor() {
this.bb = null; this.bb = null;
@@ -284,7 +299,9 @@ var FallingTub = class {
return builder.offset(); return builder.offset();
} }
unpack() { unpack() {
return new FallingTubT(this.weight()); return new FallingTubT(
this.weight()
);
} }
unpackTo(_o) { unpackTo(_o) {
_o.weight = this.weight(); _o.weight = this.weight();
@@ -295,11 +312,14 @@ var FallingTubT = class {
this.weight = weight; this.weight = weight;
} }
pack(builder) { pack(builder) {
return FallingTub.createFallingTub(builder, this.weight); return FallingTub.createFallingTub(
builder,
this.weight
);
} }
}; };
// union_vector/hand-fan.js // union_vector/hand-fan.ts
var flatbuffers2 = __toESM(require("flatbuffers"), 1); var flatbuffers2 = __toESM(require("flatbuffers"), 1);
var HandFan = class _HandFan { var HandFan = class _HandFan {
constructor() { constructor() {
@@ -349,7 +369,9 @@ var HandFan = class _HandFan {
return _HandFan.endHandFan(builder); return _HandFan.endHandFan(builder);
} }
unpack() { unpack() {
return new HandFanT(this.length()); return new HandFanT(
this.length()
);
} }
unpackTo(_o) { unpackTo(_o) {
_o.length = this.length(); _o.length = this.length();
@@ -360,19 +382,22 @@ var HandFanT = class {
this.length = length; this.length = length;
} }
pack(builder) { pack(builder) {
return HandFan.createHandFan(builder, this.length); return HandFan.createHandFan(
builder,
this.length
);
} }
}; };
// union_vector/gadget.js // union_vector/gadget.ts
var Gadget; var Gadget = /* @__PURE__ */ ((Gadget2) => {
(function(Gadget2) {
Gadget2[Gadget2["NONE"] = 0] = "NONE"; Gadget2[Gadget2["NONE"] = 0] = "NONE";
Gadget2[Gadget2["FallingTub"] = 1] = "FallingTub"; Gadget2[Gadget2["FallingTub"] = 1] = "FallingTub";
Gadget2[Gadget2["HandFan"] = 2] = "HandFan"; Gadget2[Gadget2["HandFan"] = 2] = "HandFan";
})(Gadget || (Gadget = {})); return Gadget2;
})(Gadget || {});
// union_vector/movie.js // union_vector/movie.ts
var flatbuffers3 = __toESM(require("flatbuffers"), 1); var flatbuffers3 = __toESM(require("flatbuffers"), 1);
var Movie = class _Movie { var Movie = class _Movie {
constructor() { constructor() {
@@ -396,7 +421,7 @@ var Movie = class _Movie {
} }
mainCharacterType() { mainCharacterType() {
const offset = this.bb.__offset(this.bb_pos, 4); const offset = this.bb.__offset(this.bb_pos, 4);
return offset ? this.bb.readUint8(this.bb_pos + offset) : Character.NONE; return offset ? this.bb.readUint8(this.bb_pos + offset) : 0 /* NONE */;
} }
mainCharacter(obj) { mainCharacter(obj) {
const offset = this.bb.__offset(this.bb_pos, 6); const offset = this.bb.__offset(this.bb_pos, 6);
@@ -429,7 +454,7 @@ var Movie = class _Movie {
builder.startObject(4); builder.startObject(4);
} }
static addMainCharacterType(builder, mainCharacterType) { static addMainCharacterType(builder, mainCharacterType) {
builder.addFieldInt8(0, mainCharacterType, Character.NONE); builder.addFieldInt8(0, mainCharacterType, 0 /* NONE */);
} }
static addMainCharacter(builder, mainCharacterOffset) { static addMainCharacter(builder, mainCharacterOffset) {
builder.addFieldOffset(1, mainCharacterOffset, 0); builder.addFieldOffset(1, mainCharacterOffset, 0);
@@ -479,34 +504,39 @@ var Movie = class _Movie {
return _Movie.endMovie(builder); return _Movie.endMovie(builder);
} }
unpack() { unpack() {
return new MovieT(this.mainCharacterType(), (() => { return new MovieT(
const temp = unionToCharacter(this.mainCharacterType(), this.mainCharacter.bind(this)); this.mainCharacterType(),
if (temp === null) { (() => {
return null; const temp = unionToCharacter(this.mainCharacterType(), this.mainCharacter.bind(this));
}
if (typeof temp === "string") {
return temp;
}
return temp.unpack();
})(), this.bb.createScalarList(this.charactersType.bind(this), this.charactersTypeLength()), (() => {
const ret = [];
for (let targetEnumIndex = 0; targetEnumIndex < this.charactersTypeLength(); ++targetEnumIndex) {
const targetEnum = this.charactersType(targetEnumIndex);
if (targetEnum === null || Character[targetEnum] === "NONE") {
continue;
}
const temp = unionListToCharacter(targetEnum, this.characters.bind(this), targetEnumIndex);
if (temp === null) { if (temp === null) {
continue; return null;
} }
if (typeof temp === "string") { if (typeof temp === "string") {
ret.push(temp); return temp;
continue;
} }
ret.push(temp.unpack()); return temp.unpack();
} })(),
return ret; this.bb.createScalarList(this.charactersType.bind(this), this.charactersTypeLength()),
})()); (() => {
const ret = [];
for (let targetEnumIndex = 0; targetEnumIndex < this.charactersTypeLength(); ++targetEnumIndex) {
const targetEnum = this.charactersType(targetEnumIndex);
if (targetEnum === null || Character[targetEnum] === "NONE") {
continue;
}
const temp = unionListToCharacter(targetEnum, this.characters.bind(this), targetEnumIndex);
if (temp === null) {
continue;
}
if (typeof temp === "string") {
ret.push(temp);
continue;
}
ret.push(temp.unpack());
}
return ret;
})()
);
} }
unpackTo(_o) { unpackTo(_o) {
_o.mainCharacterType = this.mainCharacterType(); _o.mainCharacterType = this.mainCharacterType();
@@ -543,7 +573,7 @@ var Movie = class _Movie {
} }
}; };
var MovieT = class { var MovieT = class {
constructor(mainCharacterType = Character.NONE, mainCharacter = null, charactersType = [], characters = []) { constructor(mainCharacterType = 0 /* NONE */, mainCharacter = null, charactersType = [], characters = []) {
this.mainCharacterType = mainCharacterType; this.mainCharacterType = mainCharacterType;
this.mainCharacter = mainCharacter; this.mainCharacter = mainCharacter;
this.charactersType = charactersType; this.charactersType = charactersType;
@@ -553,6 +583,12 @@ var MovieT = class {
const mainCharacter = builder.createObjectOffset(this.mainCharacter); const mainCharacter = builder.createObjectOffset(this.mainCharacter);
const charactersType = Movie.createCharactersTypeVector(builder, this.charactersType); const charactersType = Movie.createCharactersTypeVector(builder, this.charactersType);
const characters = Movie.createCharactersVector(builder, builder.createObjectOffsetList(this.characters)); const characters = Movie.createCharactersVector(builder, builder.createObjectOffsetList(this.characters));
return Movie.createMovie(builder, this.mainCharacterType, mainCharacter, charactersType, characters); return Movie.createMovie(
builder,
this.mainCharacterType,
mainCharacter,
charactersType,
characters
);
} }
}; };