diff options
Diffstat (limited to 'tests/ts/my-game/example/any-unique-aliases.ts')
-rw-r--r-- | tests/ts/my-game/example/any-unique-aliases.ts | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/tests/ts/my-game/example/any-unique-aliases.ts b/tests/ts/my-game/example/any-unique-aliases.ts new file mode 100644 index 00000000..51061488 --- /dev/null +++ b/tests/ts/my-game/example/any-unique-aliases.ts @@ -0,0 +1,41 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +import { Monster as MyGameExample2Monster, MonsterT as MyGameExample2MonsterT } from '../../my-game/example2/monster'; +import { Monster, MonsterT } from '../../my-game/example/monster'; +import { TestSimpleTableWithEnum, TestSimpleTableWithEnumT } from '../../my-game/example/test-simple-table-with-enum'; + + +export enum AnyUniqueAliases{ + NONE = 0, + M = 1, + TS = 2, + M2 = 3 +} + +export function unionToAnyUniqueAliases( + type: AnyUniqueAliases, + accessor: (obj:Monster|MyGameExample2Monster|TestSimpleTableWithEnum) => Monster|MyGameExample2Monster|TestSimpleTableWithEnum|null +): Monster|MyGameExample2Monster|TestSimpleTableWithEnum|null { + switch(AnyUniqueAliases[type]) { + case 'NONE': return null; + case 'M': return accessor(new Monster())! as Monster; + case 'TS': return accessor(new TestSimpleTableWithEnum())! as TestSimpleTableWithEnum; + case 'M2': return accessor(new MyGameExample2Monster())! as MyGameExample2Monster; + default: return null; + } +} + +export function unionListToAnyUniqueAliases( + type: AnyUniqueAliases, + accessor: (index: number, obj:Monster|MyGameExample2Monster|TestSimpleTableWithEnum) => Monster|MyGameExample2Monster|TestSimpleTableWithEnum|null, + index: number +): Monster|MyGameExample2Monster|TestSimpleTableWithEnum|null { + switch(AnyUniqueAliases[type]) { + case 'NONE': return null; + case 'M': return accessor(index, new Monster())! as Monster; + case 'TS': return accessor(index, new TestSimpleTableWithEnum())! as TestSimpleTableWithEnum; + case 'M2': return accessor(index, new MyGameExample2Monster())! as MyGameExample2Monster; + default: return null; + } +} + |