Debian Codegraph @

tests/ts/my-game/example/vec3.ts

raw symbols SCIP
1 // automatically generated by the FlatBuffers compiler, do not modify
2
3 import * as flatbuffers from 'flatbuffers';
4
5 import { Color } from '../../my-game/example/color.js';
6 import { Test, TestT } from '../../my-game/example/test.js';
7
8
9 export class Vec3 implements flatbuffers.IUnpackableObject<Vec3T> {
10 bb: flatbuffers.ByteBuffer|null = null;
11 bb_pos = 0;
12 __init(i:number, bb:flatbuffers.ByteBuffer):Vec3 {
13 this.bb_pos = i;
14 this.bb = bb;
15 return this;
16 }
17
18 x():number {
19 return this.bb!.readFloat32(this.bb_pos);
20 }
21
22 mutate_x(value:number):boolean {
23 this.bb!.writeFloat32(this.bb_pos + 0, value);
24 return true;
25 }
26
27 y():number {
28 return this.bb!.readFloat32(this.bb_pos + 4);
29 }
30
31 mutate_y(value:number):boolean {
32 this.bb!.writeFloat32(this.bb_pos + 4, value);
33 return true;
34 }
35
36 z():number {
37 return this.bb!.readFloat32(this.bb_pos + 8);
38 }
39
40 mutate_z(value:number):boolean {
41 this.bb!.writeFloat32(this.bb_pos + 8, value);
42 return true;
43 }
44
45 test1():number {
46 return this.bb!.readFloat64(this.bb_pos + 16);
47 }
48
49 mutate_test1(value:number):boolean {
50 this.bb!.writeFloat64(this.bb_pos + 16, value);
51 return true;
52 }
53
54 test2():Color {
55 return this.bb!.readUint8(this.bb_pos + 24);
56 }
57
58 mutate_test2(value:Color):boolean {
59 this.bb!.writeUint8(this.bb_pos + 24, value);
60 return true;
61 }
62
63 test3(obj?:Test):Test|null {
64 return (obj || new Test()).__init(this.bb_pos + 26, this.bb!);
65 }
66
67 static getFullyQualifiedName():string {
68 return 'MyGame.Example.Vec3';
69 }
70
71 static sizeOf():number {
72 return 32;
73 }
74
75 static createVec3(builder:flatbuffers.Builder, x: number, y: number, z: number, test1: number, test2: Color, test3_a: number, test3_b: number):flatbuffers.Offset {
76 builder.prep(8, 32);
77 builder.pad(2);
78 builder.prep(2, 4);
79 builder.pad(1);
80 builder.writeInt8(test3_b);
81 builder.writeInt16(test3_a);
82 builder.pad(1);
83 builder.writeInt8(test2);
84 builder.writeFloat64(test1);
85 builder.pad(4);
86 builder.writeFloat32(z);
87 builder.writeFloat32(y);
88 builder.writeFloat32(x);
89 return builder.offset();
90 }
91
92
93 unpack(): Vec3T {
94 return new Vec3T(
95 this.x(),
96 this.y(),
97 this.z(),
98 this.test1(),
99 this.test2(),
100 (this.test3() !== null ? this.test3()!.unpack() : null)
101 );
102 }
103
104
105 unpackTo(_o: Vec3T): void {
106 _o.x = this.x();
107 _o.y = this.y();
108 _o.z = this.z();
109 _o.test1 = this.test1();
110 _o.test2 = this.test2();
111 _o.test3 = (this.test3() !== null ? this.test3()!.unpack() : null);
112 }
113 }
114
115 export class Vec3T implements flatbuffers.IGeneratedObject {
116 constructor(
117 public x: number = 0.0,
118 public y: number = 0.0,
119 public z: number = 0.0,
120 public test1: number = 0.0,
121 public test2: Color = Color.Red,
122 public test3: TestT|null = null
123 ){}
124
125
126 pack(builder:flatbuffers.Builder): flatbuffers.Offset {
127 return Vec3.createVec3(builder,
128 this.x,
129 this.y,
130 this.z,
131 this.test1,
132 this.test2,
133 (this.test3?.a ?? 0),
134 (this.test3?.b ?? 0)
135 );
136 }
137 }