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