mirror of
https://github.com/google/flatbuffers.git
synced 2025-04-08 09:12:14 +08:00
* TS/ES6 modules spike iteration 1 * Initial modularized dasherized output * Remove obsoleted parts and namespace wrapping * Use _flatbuffers_ prefix * First part of imports logic * Second part of imports logic * Fix TS/JS code removal mixup * Alias imported symbols if same name from different namespaces and some fixes * Use star import for bare imports * Fix messed up string concat * var to const and remove not needed semi * Remove some cases of ns prefixing * Add missing space * Cleanups * Completed initial import tracking logic * Compilable output * Adjust TypeScriptTest and dependents to work * Use local flatbuffers package for tests * Refactor away use of any * Remove obsolete imported_fileset and reexport_map * Still need any and fix JavaScriptTest.sh * Fix test runs out of the box * Temp add generated files * TypeScriptTest replaces JavaScriptTest and cleanups * Also remove reference to JavaScriptTest in TestAll.sh * Remove old generated ts/js files * Remove use of --js in generate_code scripts * idl_gen_js_ts to idl_gen_ts and removal of js gen * Remove obsoleted options * Fix obsolete ts test detection * Tweak ts compilation be as strict as possible * Remove jsdoc type annotation generation * Generated test ts files * Fix search and replace messup * Regenerated ts test output * Use CharToLower * Use normal for loop * Rework namespacedir * Revert "Rework namespacedir" This reverts commit 6f4eb0104ceeb86011bb076ebca901138c48e068. * Revert "Use normal for loop" This reverts commit 676b2135bfaa1853dfbb06c92b5c16a0d81bb13a. * Revert "Use CharToLower" This reverts commit 2d08648d0d72d0af201fad80d54cdc76412b35e9. * Again do rework but correct * Avoid runtime cast * Fix test runs * Also add npm install to get tsc * Bump node test versions * for range to std for loop * Clang format * Missed one clang format * Move accessor to later * Attempt to make windows version of TypeScriptTest * Want to see the output * Try to get newer node at appveyor * Style changes
139 lines
3.3 KiB
TypeScript
139 lines
3.3 KiB
TypeScript
// automatically generated by the FlatBuffers compiler, do not modify
|
|
|
|
import * as flatbuffers from 'flatbuffers';
|
|
|
|
|
|
|
|
export class Stat {
|
|
bb: flatbuffers.ByteBuffer|null = null;
|
|
bb_pos = 0;
|
|
__init(i:number, bb:flatbuffers.ByteBuffer):Stat {
|
|
this.bb_pos = i;
|
|
this.bb = bb;
|
|
return this;
|
|
}
|
|
|
|
static getRootAsStat(bb:flatbuffers.ByteBuffer, obj?:Stat):Stat {
|
|
return (obj || new Stat()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
|
|
}
|
|
|
|
static getSizePrefixedRootAsStat(bb:flatbuffers.ByteBuffer, obj?:Stat):Stat {
|
|
bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
|
|
return (obj || new Stat()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
|
|
}
|
|
|
|
id():string|null
|
|
id(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
|
|
id(optionalEncoding?:any):string|Uint8Array|null {
|
|
const offset = this.bb!.__offset(this.bb_pos, 4);
|
|
return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
|
|
}
|
|
|
|
val():flatbuffers.Long {
|
|
const offset = this.bb!.__offset(this.bb_pos, 6);
|
|
return offset ? this.bb!.readInt64(this.bb_pos + offset) : this.bb!.createLong(0, 0);
|
|
}
|
|
|
|
mutate_val(value:flatbuffers.Long):boolean {
|
|
const offset = this.bb!.__offset(this.bb_pos, 6);
|
|
|
|
if (offset === 0) {
|
|
return false;
|
|
}
|
|
|
|
this.bb!.writeInt64(this.bb_pos + offset, value);
|
|
return true;
|
|
}
|
|
|
|
count():number {
|
|
const offset = this.bb!.__offset(this.bb_pos, 8);
|
|
return offset ? this.bb!.readUint16(this.bb_pos + offset) : 0;
|
|
}
|
|
|
|
mutate_count(value:number):boolean {
|
|
const offset = this.bb!.__offset(this.bb_pos, 8);
|
|
|
|
if (offset === 0) {
|
|
return false;
|
|
}
|
|
|
|
this.bb!.writeUint16(this.bb_pos + offset, value);
|
|
return true;
|
|
}
|
|
|
|
static getFullyQualifiedName():string {
|
|
return 'MyGame.Example.Stat';
|
|
}
|
|
|
|
static startStat(builder:flatbuffers.Builder) {
|
|
builder.startObject(3);
|
|
}
|
|
|
|
static addId(builder:flatbuffers.Builder, idOffset:flatbuffers.Offset) {
|
|
builder.addFieldOffset(0, idOffset, 0);
|
|
}
|
|
|
|
static addVal(builder:flatbuffers.Builder, val:flatbuffers.Long) {
|
|
builder.addFieldInt64(1, val, builder.createLong(0, 0));
|
|
}
|
|
|
|
static addCount(builder:flatbuffers.Builder, count:number) {
|
|
builder.addFieldInt16(2, count, 0);
|
|
}
|
|
|
|
static endStat(builder:flatbuffers.Builder):flatbuffers.Offset {
|
|
const offset = builder.endObject();
|
|
return offset;
|
|
}
|
|
|
|
static createStat(builder:flatbuffers.Builder, idOffset:flatbuffers.Offset, val:flatbuffers.Long, count:number):flatbuffers.Offset {
|
|
Stat.startStat(builder);
|
|
Stat.addId(builder, idOffset);
|
|
Stat.addVal(builder, val);
|
|
Stat.addCount(builder, count);
|
|
return Stat.endStat(builder);
|
|
}
|
|
|
|
serialize():Uint8Array {
|
|
return this.bb!.bytes();
|
|
}
|
|
|
|
static deserialize(buffer: Uint8Array):Stat {
|
|
return Stat.getRootAsStat(new flatbuffers.ByteBuffer(buffer))
|
|
}
|
|
|
|
unpack(): StatT {
|
|
return new StatT(
|
|
this.id(),
|
|
this.val(),
|
|
this.count()
|
|
);
|
|
}
|
|
|
|
|
|
unpackTo(_o: StatT): void {
|
|
_o.id = this.id();
|
|
_o.val = this.val();
|
|
_o.count = this.count();
|
|
}
|
|
}
|
|
|
|
export class StatT {
|
|
constructor(
|
|
public id: string|Uint8Array|null = null,
|
|
public val: flatbuffers.Long = flatbuffers.createLong(0, 0),
|
|
public count: number = 0
|
|
){}
|
|
|
|
|
|
pack(builder:flatbuffers.Builder): flatbuffers.Offset {
|
|
const id = (this.id !== null ? builder.createString(this.id!) : 0);
|
|
|
|
return Stat.createStat(builder,
|
|
id,
|
|
this.val,
|
|
this.count
|
|
);
|
|
}
|
|
}
|