• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// automatically generated by the FlatBuffers compiler, do not modify
2/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */
3import * as flatbuffers from 'flatbuffers';
4import { Character, unionToCharacter, unionListToCharacter } from './character.js';
5export class Movie {
6    constructor() {
7        this.bb = null;
8        this.bb_pos = 0;
9    }
10    __init(i, bb) {
11        this.bb_pos = i;
12        this.bb = bb;
13        return this;
14    }
15    static getRootAsMovie(bb, obj) {
16        return (obj || new Movie()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
17    }
18    static getSizePrefixedRootAsMovie(bb, obj) {
19        bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
20        return (obj || new Movie()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
21    }
22    static bufferHasIdentifier(bb) {
23        return bb.__has_identifier('MOVI');
24    }
25    mainCharacterType() {
26        const offset = this.bb.__offset(this.bb_pos, 4);
27        return offset ? this.bb.readUint8(this.bb_pos + offset) : Character.NONE;
28    }
29    mainCharacter(obj) {
30        const offset = this.bb.__offset(this.bb_pos, 6);
31        return offset ? this.bb.__union_with_string(obj, this.bb_pos + offset) : null;
32    }
33    charactersType(index) {
34        const offset = this.bb.__offset(this.bb_pos, 8);
35        return offset ? this.bb.readUint8(this.bb.__vector(this.bb_pos + offset) + index) : 0;
36    }
37    charactersTypeLength() {
38        const offset = this.bb.__offset(this.bb_pos, 8);
39        return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0;
40    }
41    charactersTypeArray() {
42        const offset = this.bb.__offset(this.bb_pos, 8);
43        return offset ? new Uint8Array(this.bb.bytes().buffer, this.bb.bytes().byteOffset + this.bb.__vector(this.bb_pos + offset), this.bb.__vector_len(this.bb_pos + offset)) : null;
44    }
45    characters(index, obj) {
46        const offset = this.bb.__offset(this.bb_pos, 10);
47        return offset ? this.bb.__union_with_string(obj, this.bb.__vector(this.bb_pos + offset) + index * 4) : null;
48    }
49    charactersLength() {
50        const offset = this.bb.__offset(this.bb_pos, 10);
51        return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0;
52    }
53    static getFullyQualifiedName() {
54        return 'Movie';
55    }
56    static startMovie(builder) {
57        builder.startObject(4);
58    }
59    static addMainCharacterType(builder, mainCharacterType) {
60        builder.addFieldInt8(0, mainCharacterType, Character.NONE);
61    }
62    static addMainCharacter(builder, mainCharacterOffset) {
63        builder.addFieldOffset(1, mainCharacterOffset, 0);
64    }
65    static addCharactersType(builder, charactersTypeOffset) {
66        builder.addFieldOffset(2, charactersTypeOffset, 0);
67    }
68    static createCharactersTypeVector(builder, data) {
69        builder.startVector(1, data.length, 1);
70        for (let i = data.length - 1; i >= 0; i--) {
71            builder.addInt8(data[i]);
72        }
73        return builder.endVector();
74    }
75    static startCharactersTypeVector(builder, numElems) {
76        builder.startVector(1, numElems, 1);
77    }
78    static addCharacters(builder, charactersOffset) {
79        builder.addFieldOffset(3, charactersOffset, 0);
80    }
81    static createCharactersVector(builder, data) {
82        builder.startVector(4, data.length, 4);
83        for (let i = data.length - 1; i >= 0; i--) {
84            builder.addOffset(data[i]);
85        }
86        return builder.endVector();
87    }
88    static startCharactersVector(builder, numElems) {
89        builder.startVector(4, numElems, 4);
90    }
91    static endMovie(builder) {
92        const offset = builder.endObject();
93        return offset;
94    }
95    static finishMovieBuffer(builder, offset) {
96        builder.finish(offset, 'MOVI');
97    }
98    static finishSizePrefixedMovieBuffer(builder, offset) {
99        builder.finish(offset, 'MOVI', true);
100    }
101    static createMovie(builder, mainCharacterType, mainCharacterOffset, charactersTypeOffset, charactersOffset) {
102        Movie.startMovie(builder);
103        Movie.addMainCharacterType(builder, mainCharacterType);
104        Movie.addMainCharacter(builder, mainCharacterOffset);
105        Movie.addCharactersType(builder, charactersTypeOffset);
106        Movie.addCharacters(builder, charactersOffset);
107        return Movie.endMovie(builder);
108    }
109    unpack() {
110        return new MovieT(this.mainCharacterType(), (() => {
111            const temp = unionToCharacter(this.mainCharacterType(), this.mainCharacter.bind(this));
112            if (temp === null) {
113                return null;
114            }
115            if (typeof temp === 'string') {
116                return temp;
117            }
118            return temp.unpack();
119        })(), this.bb.createScalarList(this.charactersType.bind(this), this.charactersTypeLength()), (() => {
120            const ret = [];
121            for (let targetEnumIndex = 0; targetEnumIndex < this.charactersTypeLength(); ++targetEnumIndex) {
122                const targetEnum = this.charactersType(targetEnumIndex);
123                if (targetEnum === null || Character[targetEnum] === 'NONE') {
124                    continue;
125                }
126                const temp = unionListToCharacter(targetEnum, this.characters.bind(this), targetEnumIndex);
127                if (temp === null) {
128                    continue;
129                }
130                if (typeof temp === 'string') {
131                    ret.push(temp);
132                    continue;
133                }
134                ret.push(temp.unpack());
135            }
136            return ret;
137        })());
138    }
139    unpackTo(_o) {
140        _o.mainCharacterType = this.mainCharacterType();
141        _o.mainCharacter = (() => {
142            const temp = unionToCharacter(this.mainCharacterType(), this.mainCharacter.bind(this));
143            if (temp === null) {
144                return null;
145            }
146            if (typeof temp === 'string') {
147                return temp;
148            }
149            return temp.unpack();
150        })();
151        _o.charactersType = this.bb.createScalarList(this.charactersType.bind(this), this.charactersTypeLength());
152        _o.characters = (() => {
153            const ret = [];
154            for (let targetEnumIndex = 0; targetEnumIndex < this.charactersTypeLength(); ++targetEnumIndex) {
155                const targetEnum = this.charactersType(targetEnumIndex);
156                if (targetEnum === null || Character[targetEnum] === 'NONE') {
157                    continue;
158                }
159                const temp = unionListToCharacter(targetEnum, this.characters.bind(this), targetEnumIndex);
160                if (temp === null) {
161                    continue;
162                }
163                if (typeof temp === 'string') {
164                    ret.push(temp);
165                    continue;
166                }
167                ret.push(temp.unpack());
168            }
169            return ret;
170        })();
171    }
172}
173export class MovieT {
174    constructor(mainCharacterType = Character.NONE, mainCharacter = null, charactersType = [], characters = []) {
175        this.mainCharacterType = mainCharacterType;
176        this.mainCharacter = mainCharacter;
177        this.charactersType = charactersType;
178        this.characters = characters;
179    }
180    pack(builder) {
181        const mainCharacter = builder.createObjectOffset(this.mainCharacter);
182        const charactersType = Movie.createCharactersTypeVector(builder, this.charactersType);
183        const characters = Movie.createCharactersVector(builder, builder.createObjectOffsetList(this.characters));
184        return Movie.createMovie(builder, this.mainCharacterType, mainCharacter, charactersType, characters);
185    }
186}
187