File: object.ts

package info (click to toggle)
golang-github-google-flatbuffers 24.12.23-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 17,704 kB
  • sloc: cpp: 53,217; python: 6,900; cs: 5,566; java: 4,370; php: 1,460; javascript: 1,061; xml: 1,016; sh: 886; makefile: 13
file content (224 lines) | stat: -rw-r--r-- 5,804 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
// automatically generated by the FlatBuffers compiler, do not modify

/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */

import * as flatbuffers from 'flatbuffers';

import { Abc } from '../foobar/abc.js';
import { class_ as foobar_class_ } from '../foobar/class.js';
import { Schema, SchemaT } from '../reflection/schema.js';
import { class_ } from '../typescript/class.js';


export class Object_ implements flatbuffers.IUnpackableObject<Object_T> {
  bb: flatbuffers.ByteBuffer|null = null;
  bb_pos = 0;
  __init(i:number, bb:flatbuffers.ByteBuffer):Object_ {
  this.bb_pos = i;
  this.bb = bb;
  return this;
}

static getRootAsObject(bb:flatbuffers.ByteBuffer, obj?:Object_):Object_ {
  return (obj || new Object_()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}

static getSizePrefixedRootAsObject(bb:flatbuffers.ByteBuffer, obj?:Object_):Object_ {
  bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
  return (obj || new Object_()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}

return_():number {
  const offset = this.bb!.__offset(this.bb_pos, 4);
  return offset ? this.bb!.readInt32(this.bb_pos + offset) : 0;
}

mutate_return(value:number):boolean {
  const offset = this.bb!.__offset(this.bb_pos, 4);

  if (offset === 0) {
    return false;
  }

  this.bb!.writeInt32(this.bb_pos + offset, value);
  return true;
}

if_():number {
  const offset = this.bb!.__offset(this.bb_pos, 6);
  return offset ? this.bb!.readInt32(this.bb_pos + offset) : 0;
}

mutate_if(value:number):boolean {
  const offset = this.bb!.__offset(this.bb_pos, 6);

  if (offset === 0) {
    return false;
  }

  this.bb!.writeInt32(this.bb_pos + offset, value);
  return true;
}

switch_():number {
  const offset = this.bb!.__offset(this.bb_pos, 8);
  return offset ? this.bb!.readInt32(this.bb_pos + offset) : 0;
}

mutate_switch(value:number):boolean {
  const offset = this.bb!.__offset(this.bb_pos, 8);

  if (offset === 0) {
    return false;
  }

  this.bb!.writeInt32(this.bb_pos + offset, value);
  return true;
}

enum_():class_ {
  const offset = this.bb!.__offset(this.bb_pos, 10);
  return offset ? this.bb!.readInt32(this.bb_pos + offset) : class_.new_;
}

mutate_enum(value:class_):boolean {
  const offset = this.bb!.__offset(this.bb_pos, 10);

  if (offset === 0) {
    return false;
  }

  this.bb!.writeInt32(this.bb_pos + offset, value);
  return true;
}

enum2():foobar_class_ {
  const offset = this.bb!.__offset(this.bb_pos, 12);
  return offset ? this.bb!.readInt32(this.bb_pos + offset) : foobar_class_.arguments_;
}

mutate_enum2(value:foobar_class_):boolean {
  const offset = this.bb!.__offset(this.bb_pos, 12);

  if (offset === 0) {
    return false;
  }

  this.bb!.writeInt32(this.bb_pos + offset, value);
  return true;
}

enum3():Abc {
  const offset = this.bb!.__offset(this.bb_pos, 14);
  return offset ? this.bb!.readInt32(this.bb_pos + offset) : Abc.a;
}

mutate_enum3(value:Abc):boolean {
  const offset = this.bb!.__offset(this.bb_pos, 14);

  if (offset === 0) {
    return false;
  }

  this.bb!.writeInt32(this.bb_pos + offset, value);
  return true;
}

reflect(obj?:Schema):Schema|null {
  const offset = this.bb!.__offset(this.bb_pos, 16);
  return offset ? (obj || new Schema()).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null;
}

static getFullyQualifiedName():string {
  return 'typescript.Object';
}

static startObject(builder:flatbuffers.Builder) {
  builder.startObject(7);
}

static addReturn(builder:flatbuffers.Builder, return_:number) {
  builder.addFieldInt32(0, return_, 0);
}

static addIf(builder:flatbuffers.Builder, if_:number) {
  builder.addFieldInt32(1, if_, 0);
}

static addSwitch(builder:flatbuffers.Builder, switch_:number) {
  builder.addFieldInt32(2, switch_, 0);
}

static addEnum(builder:flatbuffers.Builder, enum_:class_) {
  builder.addFieldInt32(3, enum_, class_.new_);
}

static addEnum2(builder:flatbuffers.Builder, enum2:foobar_class_) {
  builder.addFieldInt32(4, enum2, foobar_class_.arguments_);
}

static addEnum3(builder:flatbuffers.Builder, enum3:Abc) {
  builder.addFieldInt32(5, enum3, Abc.a);
}

static addReflect(builder:flatbuffers.Builder, reflectOffset:flatbuffers.Offset) {
  builder.addFieldOffset(6, reflectOffset, 0);
}

static endObject(builder:flatbuffers.Builder):flatbuffers.Offset {
  const offset = builder.endObject();
  return offset;
}


unpack(): Object_T {
  return new Object_T(
    this.return_(),
    this.if_(),
    this.switch_(),
    this.enum_(),
    this.enum2(),
    this.enum3(),
    (this.reflect() !== null ? this.reflect()!.unpack() : null)
  );
}


unpackTo(_o: Object_T): void {
  _o.return_ = this.return_();
  _o.if_ = this.if_();
  _o.switch_ = this.switch_();
  _o.enum_ = this.enum_();
  _o.enum2 = this.enum2();
  _o.enum3 = this.enum3();
  _o.reflect = (this.reflect() !== null ? this.reflect()!.unpack() : null);
}
}

export class Object_T implements flatbuffers.IGeneratedObject {
constructor(
  public return_: number = 0,
  public if_: number = 0,
  public switch_: number = 0,
  public enum_: class_ = class_.new_,
  public enum2: foobar_class_ = foobar_class_.arguments_,
  public enum3: Abc = Abc.a,
  public reflect: SchemaT|null = null
){}


pack(builder:flatbuffers.Builder): flatbuffers.Offset {
  const reflect = (this.reflect !== null ? this.reflect!.pack(builder) : 0);

  Object_.startObject(builder);
  Object_.addReturn(builder, this.return_);
  Object_.addIf(builder, this.if_);
  Object_.addSwitch(builder, this.switch_);
  Object_.addEnum(builder, this.enum_);
  Object_.addEnum2(builder, this.enum2);
  Object_.addEnum3(builder, this.enum3);
  Object_.addReflect(builder, reflect);

  return Object_.endObject(builder);
}
}