mirror of
https://github.com/google/flatbuffers.git
synced 2025-04-08 09:12:14 +08:00
* Wrap types in namespace for --ts-flat-files and --gen-all * Fixes for escaping object types * Added to generate_code
51 lines
1.4 KiB
JavaScript
51 lines
1.4 KiB
JavaScript
// automatically generated by the FlatBuffers compiler, do not modify
|
|
import * as flatbuffers from 'flatbuffers';
|
|
export class Monster {
|
|
constructor() {
|
|
this.bb = null;
|
|
this.bb_pos = 0;
|
|
}
|
|
__init(i, bb) {
|
|
this.bb_pos = i;
|
|
this.bb = bb;
|
|
return this;
|
|
}
|
|
static getRootAsMonster(bb, obj) {
|
|
return (obj || new Monster()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
|
|
}
|
|
static getSizePrefixedRootAsMonster(bb, obj) {
|
|
bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
|
|
return (obj || new Monster()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
|
|
}
|
|
static getFullyQualifiedName() {
|
|
return 'MyGame_Example2_Monster';
|
|
}
|
|
static startMonster(builder) {
|
|
builder.startObject(0);
|
|
}
|
|
static endMonster(builder) {
|
|
const offset = builder.endObject();
|
|
return offset;
|
|
}
|
|
static createMonster(builder) {
|
|
Monster.startMonster(builder);
|
|
return Monster.endMonster(builder);
|
|
}
|
|
serialize() {
|
|
return this.bb.bytes();
|
|
}
|
|
static deserialize(buffer) {
|
|
return Monster.getRootAsMonster(new flatbuffers.ByteBuffer(buffer));
|
|
}
|
|
unpack() {
|
|
return new MonsterT();
|
|
}
|
|
unpackTo(_o) { }
|
|
}
|
|
export class MonsterT {
|
|
constructor() { }
|
|
pack(builder) {
|
|
return Monster.createMonster(builder);
|
|
}
|
|
}
|