blob: 91bcc8569fd441b482f85aec75b8da494e981224 [file] [log] [blame]
James Kuszmaul8e62b022022-03-22 09:33:25 -07001// automatically generated by the FlatBuffers compiler, do not modify
2import * as flatbuffers from 'flatbuffers';
3import { EnumInNestedNS } from '../namespace-a/namespace-b/enum-in-nested-n-s';
4import { StructInNestedNS } from '../namespace-a/namespace-b/struct-in-nested-n-s';
5import { TableInNestedNS } from '../namespace-a/namespace-b/table-in-nested-n-s';
6import { UnionInNestedNS, unionToUnionInNestedNS } from '../namespace-a/namespace-b/union-in-nested-n-s';
7export class TableInFirstNS {
8 constructor() {
9 this.bb = null;
10 this.bb_pos = 0;
11 }
12 __init(i, bb) {
13 this.bb_pos = i;
14 this.bb = bb;
15 return this;
16 }
17 static getRootAsTableInFirstNS(bb, obj) {
18 return (obj || new TableInFirstNS()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
19 }
20 static getSizePrefixedRootAsTableInFirstNS(bb, obj) {
21 bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
22 return (obj || new TableInFirstNS()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
23 }
24 fooTable(obj) {
25 const offset = this.bb.__offset(this.bb_pos, 4);
26 return offset ? (obj || new TableInNestedNS()).__init(this.bb.__indirect(this.bb_pos + offset), this.bb) : null;
27 }
28 fooEnum() {
29 const offset = this.bb.__offset(this.bb_pos, 6);
30 return offset ? this.bb.readInt8(this.bb_pos + offset) : EnumInNestedNS.A;
31 }
32 mutate_foo_enum(value) {
33 const offset = this.bb.__offset(this.bb_pos, 6);
34 if (offset === 0) {
35 return false;
36 }
37 this.bb.writeInt8(this.bb_pos + offset, value);
38 return true;
39 }
40 fooUnionType() {
41 const offset = this.bb.__offset(this.bb_pos, 8);
42 return offset ? this.bb.readUint8(this.bb_pos + offset) : UnionInNestedNS.NONE;
43 }
44 fooUnion(obj) {
45 const offset = this.bb.__offset(this.bb_pos, 10);
46 return offset ? this.bb.__union(obj, this.bb_pos + offset) : null;
47 }
48 fooStruct(obj) {
49 const offset = this.bb.__offset(this.bb_pos, 12);
50 return offset ? (obj || new StructInNestedNS()).__init(this.bb_pos + offset, this.bb) : null;
51 }
52 static getFullyQualifiedName() {
53 return 'NamespaceA.TableInFirstNS';
54 }
55 static startTableInFirstNS(builder) {
56 builder.startObject(5);
57 }
58 static addFooTable(builder, fooTableOffset) {
59 builder.addFieldOffset(0, fooTableOffset, 0);
60 }
61 static addFooEnum(builder, fooEnum) {
62 builder.addFieldInt8(1, fooEnum, EnumInNestedNS.A);
63 }
64 static addFooUnionType(builder, fooUnionType) {
65 builder.addFieldInt8(2, fooUnionType, UnionInNestedNS.NONE);
66 }
67 static addFooUnion(builder, fooUnionOffset) {
68 builder.addFieldOffset(3, fooUnionOffset, 0);
69 }
70 static addFooStruct(builder, fooStructOffset) {
71 builder.addFieldStruct(4, fooStructOffset, 0);
72 }
73 static endTableInFirstNS(builder) {
74 const offset = builder.endObject();
75 return offset;
76 }
77 unpack() {
78 return new TableInFirstNST((this.fooTable() !== null ? this.fooTable().unpack() : null), this.fooEnum(), this.fooUnionType(), (() => {
79 let temp = unionToUnionInNestedNS(this.fooUnionType(), this.fooUnion.bind(this));
80 if (temp === null) {
81 return null;
82 }
83 return temp.unpack();
84 })(), (this.fooStruct() !== null ? this.fooStruct().unpack() : null));
85 }
86 unpackTo(_o) {
87 _o.fooTable = (this.fooTable() !== null ? this.fooTable().unpack() : null);
88 _o.fooEnum = this.fooEnum();
89 _o.fooUnionType = this.fooUnionType();
90 _o.fooUnion = (() => {
91 let temp = unionToUnionInNestedNS(this.fooUnionType(), this.fooUnion.bind(this));
92 if (temp === null) {
93 return null;
94 }
95 return temp.unpack();
96 })();
97 _o.fooStruct = (this.fooStruct() !== null ? this.fooStruct().unpack() : null);
98 }
99}
100export class TableInFirstNST {
101 constructor(fooTable = null, fooEnum = EnumInNestedNS.A, fooUnionType = UnionInNestedNS.NONE, fooUnion = null, fooStruct = null) {
102 this.fooTable = fooTable;
103 this.fooEnum = fooEnum;
104 this.fooUnionType = fooUnionType;
105 this.fooUnion = fooUnion;
106 this.fooStruct = fooStruct;
107 }
108 pack(builder) {
109 const fooTable = (this.fooTable !== null ? this.fooTable.pack(builder) : 0);
110 const fooUnion = builder.createObjectOffset(this.fooUnion);
111 TableInFirstNS.startTableInFirstNS(builder);
112 TableInFirstNS.addFooTable(builder, fooTable);
113 TableInFirstNS.addFooEnum(builder, this.fooEnum);
114 TableInFirstNS.addFooUnionType(builder, this.fooUnionType);
115 TableInFirstNS.addFooUnion(builder, fooUnion);
116 TableInFirstNS.addFooStruct(builder, (this.fooStruct !== null ? this.fooStruct.pack(builder) : 0));
117 return TableInFirstNS.endTableInFirstNS(builder);
118 }
119}