xref: /aosp_15_r20/external/flatbuffers/tests/my-game/example/any.js (revision 890232f25432b36107d06881e0a25aaa6b473652)
1// automatically generated by the FlatBuffers compiler, do not modify
2import { Monster as MyGame_Example2_Monster } from '../../my-game/example2/monster';
3import { Monster } from '../../my-game/example/monster';
4import { TestSimpleTableWithEnum } from '../../my-game/example/test-simple-table-with-enum';
5export var Any;
6(function (Any) {
7    Any[Any["NONE"] = 0] = "NONE";
8    Any[Any["Monster"] = 1] = "Monster";
9    Any[Any["TestSimpleTableWithEnum"] = 2] = "TestSimpleTableWithEnum";
10    Any[Any["MyGame_Example2_Monster"] = 3] = "MyGame_Example2_Monster";
11})(Any || (Any = {}));
12export function unionToAny(type, accessor) {
13    switch (Any[type]) {
14        case 'NONE': return null;
15        case 'Monster': return accessor(new Monster());
16        case 'TestSimpleTableWithEnum': return accessor(new TestSimpleTableWithEnum());
17        case 'MyGame_Example2_Monster': return accessor(new MyGame_Example2_Monster());
18        default: return null;
19    }
20}
21export function unionListToAny(type, accessor, index) {
22    switch (Any[type]) {
23        case 'NONE': return null;
24        case 'Monster': return accessor(index, new Monster());
25        case 'TestSimpleTableWithEnum': return accessor(index, new TestSimpleTableWithEnum());
26        case 'MyGame_Example2_Monster': return accessor(index, new MyGame_Example2_Monster());
27        default: return null;
28    }
29}
30