mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-07 13:53:38 +00:00
fixed invalid TS call and added test files (#6495)
e581013e3d broke TS generation - please don't use "replace" to refactor function names :)
This commit is contained in:
9
flatbuffers.pc
Normal file
9
flatbuffers.pc
Normal file
@@ -0,0 +1,9 @@
|
||||
libdir=/usr/local/lib
|
||||
includedir=/usr/local/include
|
||||
|
||||
Name: FlatBuffers
|
||||
Description: Memory Efficient Serialization Library
|
||||
Version: 1.12.0
|
||||
|
||||
Libs: -L${libdir} -lflatbuffers
|
||||
Cflags: -I${includedir}
|
||||
@@ -1467,7 +1467,7 @@ class TsGenerator : public BaseGenerator {
|
||||
it != struct_def.fields.vec.end(); ++it) {
|
||||
auto &field = **it;
|
||||
if (!field.deprecated && field.IsRequired()) {
|
||||
code += " builder.IsRequired()Field(offset, ";
|
||||
code += " builder.requiredField(offset, ";
|
||||
code += NumToString(field.value.offset);
|
||||
code += ") // " + field.name + "\n";
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
93
tests/monster_test_grpc.d.ts
vendored
Normal file
93
tests/monster_test_grpc.d.ts
vendored
Normal file
@@ -0,0 +1,93 @@
|
||||
// Generated GRPC code for FlatBuffers TS *** DO NOT EDIT ***
|
||||
import { flatbuffers } from 'flatbuffers';
|
||||
import { Stat as MyGame_Example_Stat } from './my-game/example/stat';
|
||||
import { Monster as MyGame_Example_Monster } from './my-game/example/monster';
|
||||
|
||||
import * as grpc from 'grpc';
|
||||
|
||||
interface IMonsterStorageService extends grpc.ServiceDefinition<grpc.UntypedServiceImplementation> {
|
||||
Store: IMonsterStorageService_IStore;
|
||||
Retrieve: IMonsterStorageService_IRetrieve;
|
||||
GetMaxHitPoint: IMonsterStorageService_IGetMaxHitPoint;
|
||||
GetMinMaxHitPoints: IMonsterStorageService_IGetMinMaxHitPoints;
|
||||
}
|
||||
interface IMonsterStorageService_IStore extends grpc.MethodDefinition<MyGame_Example_Monster, MyGame_Example_Stat> {
|
||||
path: string; // /MyGame.Example.MonsterStorage/Store
|
||||
requestStream: boolean; // false
|
||||
responseStream: boolean; // false
|
||||
requestSerialize: grpc.serialize<MyGame_Example_Monster>;
|
||||
requestDeserialize: grpc.deserialize<MyGame_Example_Monster>;
|
||||
responseSerialize: grpc.serialize<MyGame_Example_Stat>;
|
||||
responseDeserialize: grpc.deserialize<MyGame_Example_Stat>;
|
||||
}
|
||||
|
||||
interface IMonsterStorageService_IRetrieve extends grpc.MethodDefinition<MyGame_Example_Stat, MyGame_Example_Monster> {
|
||||
path: string; // /MyGame.Example.MonsterStorage/Retrieve
|
||||
requestStream: boolean; // false
|
||||
responseStream: boolean; // true
|
||||
requestSerialize: grpc.serialize<MyGame_Example_Stat>;
|
||||
requestDeserialize: grpc.deserialize<MyGame_Example_Stat>;
|
||||
responseSerialize: grpc.serialize<MyGame_Example_Monster>;
|
||||
responseDeserialize: grpc.deserialize<MyGame_Example_Monster>;
|
||||
}
|
||||
|
||||
interface IMonsterStorageService_IGetMaxHitPoint extends grpc.MethodDefinition<MyGame_Example_Monster, MyGame_Example_Stat> {
|
||||
path: string; // /MyGame.Example.MonsterStorage/GetMaxHitPoint
|
||||
requestStream: boolean; // true
|
||||
responseStream: boolean; // false
|
||||
requestSerialize: grpc.serialize<MyGame_Example_Monster>;
|
||||
requestDeserialize: grpc.deserialize<MyGame_Example_Monster>;
|
||||
responseSerialize: grpc.serialize<MyGame_Example_Stat>;
|
||||
responseDeserialize: grpc.deserialize<MyGame_Example_Stat>;
|
||||
}
|
||||
|
||||
interface IMonsterStorageService_IGetMinMaxHitPoints extends grpc.MethodDefinition<MyGame_Example_Monster, MyGame_Example_Stat> {
|
||||
path: string; // /MyGame.Example.MonsterStorage/GetMinMaxHitPoints
|
||||
requestStream: boolean; // true
|
||||
responseStream: boolean; // true
|
||||
requestSerialize: grpc.serialize<MyGame_Example_Monster>;
|
||||
requestDeserialize: grpc.deserialize<MyGame_Example_Monster>;
|
||||
responseSerialize: grpc.serialize<MyGame_Example_Stat>;
|
||||
responseDeserialize: grpc.deserialize<MyGame_Example_Stat>;
|
||||
}
|
||||
|
||||
|
||||
export const MonsterStorageService: IMonsterStorageService;
|
||||
|
||||
export interface IMonsterStorageServer {
|
||||
Store: grpc.handleUnaryCall<MyGame_Example_Monster, MyGame_Example_Stat>;
|
||||
Retrieve: grpc.handleServerStreamingCall<MyGame_Example_Stat, MyGame_Example_Monster>;
|
||||
GetMaxHitPoint: grpc.handleClientStreamingCall<MyGame_Example_Monster, MyGame_Example_Stat>;
|
||||
GetMinMaxHitPoints: grpc.handleBidiStreamingCall<MyGame_Example_Monster, MyGame_Example_Stat>;
|
||||
}
|
||||
|
||||
export interface IMonsterStorageClient {
|
||||
Store(request: MyGame_Example_Monster, callback: (error: grpc.ServiceError | null, response: MyGame_Example_Stat) => void): grpc.ClientUnaryCall;
|
||||
Store(request: MyGame_Example_Monster, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: MyGame_Example_Stat) => void): grpc.ClientUnaryCall;
|
||||
Store(request: MyGame_Example_Monster, metadata: grpc.Metadata, options: Partial<grpc.CallOptions>, callback: (error: grpc.ServiceError | null, response: MyGame_Example_Stat) => void): grpc.ClientUnaryCall;
|
||||
Retrieve(request: MyGame_Example_Stat, metadata: grpc.Metadata): grpc.ClientReadableStream<MyGame_Example_Monster>;
|
||||
Retrieve(request: MyGame_Example_Stat, options: Partial<grpc.CallOptions>): grpc.ClientReadableStream<MyGame_Example_Monster>;
|
||||
GetMaxHitPoint(callback: (error: grpc.ServiceError | null, response: MyGame_Example_Monster) => void): grpc.ClientWritableStream<MyGame_Example_Stat>;
|
||||
GetMaxHitPoint(metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: MyGame_Example_Monster) => void): grpc.ClientWritableStream<MyGame_Example_Stat>;
|
||||
GetMaxHitPoint(options: Partial<grpc.CallOptions>, callback: (error: grpc.ServiceError | null, response: MyGame_Example_Monster) => void): grpc.ClientWritableStream<MyGame_Example_Stat>;
|
||||
GetMaxHitPoint(metadata: grpc.Metadata, options: Partial<grpc.CallOptions>, callback: (error: grpc.ServiceError | null, response: MyGame_Example_Monster) => void): grpc.ClientWritableStream<MyGame_Example_Stat>;
|
||||
GetMinMaxHitPoints(): grpc.ClientDuplexStream<MyGame_Example_Monster, MyGame_Example_Stat>;
|
||||
GetMinMaxHitPoints(options: Partial<grpc.CallOptions>): grpc.ClientDuplexStream<MyGame_Example_Monster, MyGame_Example_Stat>;
|
||||
GetMinMaxHitPoints(metadata: grpc.Metadata, options?: Partial<grpc.CallOptions>): grpc.ClientDuplexStream<MyGame_Example_Monster, MyGame_Example_Stat>;
|
||||
}
|
||||
|
||||
export class MonsterStorageClient extends grpc.Client implements IMonsterStorageClient {
|
||||
constructor(address: string, credentials: grpc.ChannelCredentials, options?: object); public Store(request: MyGame_Example_Monster, callback: (error: grpc.ServiceError | null, response: MyGame_Example_Stat) => void): grpc.ClientUnaryCall;
|
||||
public Store(request: MyGame_Example_Monster, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: MyGame_Example_Stat) => void): grpc.ClientUnaryCall;
|
||||
public Store(request: MyGame_Example_Monster, metadata: grpc.Metadata, options: Partial<grpc.CallOptions>, callback: (error: grpc.ServiceError | null, response: MyGame_Example_Stat) => void): grpc.ClientUnaryCall;
|
||||
public Retrieve(request: MyGame_Example_Stat, metadata: grpc.Metadata): grpc.ClientReadableStream<MyGame_Example_Monster>;
|
||||
public Retrieve(request: MyGame_Example_Stat, options: Partial<grpc.CallOptions>): grpc.ClientReadableStream<MyGame_Example_Monster>;
|
||||
public GetMaxHitPoint(callback: (error: grpc.ServiceError | null, response: MyGame_Example_Monster) => void): grpc.ClientWritableStream<MyGame_Example_Stat>;
|
||||
public GetMaxHitPoint(metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: MyGame_Example_Monster) => void): grpc.ClientWritableStream<MyGame_Example_Stat>;
|
||||
public GetMaxHitPoint(options: Partial<grpc.CallOptions>, callback: (error: grpc.ServiceError | null, response: MyGame_Example_Monster) => void): grpc.ClientWritableStream<MyGame_Example_Stat>;
|
||||
public GetMaxHitPoint(metadata: grpc.Metadata, options: Partial<grpc.CallOptions>, callback: (error: grpc.ServiceError | null, response: MyGame_Example_Monster) => void): grpc.ClientWritableStream<MyGame_Example_Stat>;
|
||||
public GetMinMaxHitPoints(): grpc.ClientDuplexStream<MyGame_Example_Monster, MyGame_Example_Stat>;
|
||||
public GetMinMaxHitPoints(options: Partial<grpc.CallOptions>): grpc.ClientDuplexStream<MyGame_Example_Monster, MyGame_Example_Stat>;
|
||||
public GetMinMaxHitPoints(metadata: grpc.Metadata, options?: Partial<grpc.CallOptions>): grpc.ClientDuplexStream<MyGame_Example_Monster, MyGame_Example_Stat>;
|
||||
}
|
||||
|
||||
73
tests/my-game/example/ability.ts
Normal file
73
tests/my-game/example/ability.ts
Normal file
@@ -0,0 +1,73 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
import * as flatbuffers from 'flatbuffers';
|
||||
|
||||
|
||||
|
||||
export class Ability {
|
||||
bb: flatbuffers.ByteBuffer|null = null;
|
||||
bb_pos = 0;
|
||||
__init(i:number, bb:flatbuffers.ByteBuffer):Ability {
|
||||
this.bb_pos = i;
|
||||
this.bb = bb;
|
||||
return this;
|
||||
}
|
||||
|
||||
id():number {
|
||||
return this.bb!.readUint32(this.bb_pos);
|
||||
}
|
||||
|
||||
mutate_id(value:number):boolean {
|
||||
this.bb!.writeUint32(this.bb_pos + 0, value);
|
||||
return true;
|
||||
}
|
||||
|
||||
distance():number {
|
||||
return this.bb!.readUint32(this.bb_pos + 4);
|
||||
}
|
||||
|
||||
mutate_distance(value:number):boolean {
|
||||
this.bb!.writeUint32(this.bb_pos + 4, value);
|
||||
return true;
|
||||
}
|
||||
|
||||
static sizeOf():number {
|
||||
return 8;
|
||||
}
|
||||
|
||||
static createAbility(builder:flatbuffers.Builder, id: number, distance: number):flatbuffers.Offset {
|
||||
builder.prep(4, 8);
|
||||
builder.writeInt32(distance);
|
||||
builder.writeInt32(id);
|
||||
return builder.offset();
|
||||
}
|
||||
|
||||
|
||||
unpack(): AbilityT {
|
||||
return new AbilityT(
|
||||
this.id(),
|
||||
this.distance()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
unpackTo(_o: AbilityT): void {
|
||||
_o.id = this.id();
|
||||
_o.distance = this.distance();
|
||||
}
|
||||
}
|
||||
|
||||
export class AbilityT {
|
||||
constructor(
|
||||
public id: number = 0,
|
||||
public distance: number = 0
|
||||
){}
|
||||
|
||||
|
||||
pack(builder:flatbuffers.Builder): flatbuffers.Offset {
|
||||
return Ability.createAbility(builder,
|
||||
this.id,
|
||||
this.distance
|
||||
);
|
||||
}
|
||||
}
|
||||
39
tests/my-game/example/any-ambiguous-aliases.ts
Normal file
39
tests/my-game/example/any-ambiguous-aliases.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
import { Monster, MonsterT } from '../../my-game/example/monster';
|
||||
|
||||
|
||||
export enum AnyAmbiguousAliases{
|
||||
NONE = 0,
|
||||
M1 = 1,
|
||||
M2 = 2,
|
||||
M3 = 3
|
||||
}
|
||||
|
||||
export function unionToAnyAmbiguousAliases(
|
||||
type: AnyAmbiguousAliases,
|
||||
accessor: (obj:Monster) => Monster|null
|
||||
): Monster|null {
|
||||
switch(AnyAmbiguousAliases[type]) {
|
||||
case 'NONE': return null;
|
||||
case 'M1': return accessor(new Monster())! as Monster;
|
||||
case 'M2': return accessor(new Monster())! as Monster;
|
||||
case 'M3': return accessor(new Monster())! as Monster;
|
||||
default: return null;
|
||||
}
|
||||
}
|
||||
|
||||
export function unionListToAnyAmbiguousAliases(
|
||||
type: AnyAmbiguousAliases,
|
||||
accessor: (index: number, obj:Monster) => Monster|null,
|
||||
index: number
|
||||
): Monster|null {
|
||||
switch(AnyAmbiguousAliases[type]) {
|
||||
case 'NONE': return null;
|
||||
case 'M1': return accessor(index, new Monster())! as Monster;
|
||||
case 'M2': return accessor(index, new Monster())! as Monster;
|
||||
case 'M3': return accessor(index, new Monster())! as Monster;
|
||||
default: return null;
|
||||
}
|
||||
}
|
||||
|
||||
41
tests/my-game/example/any-unique-aliases.ts
Normal file
41
tests/my-game/example/any-unique-aliases.ts
Normal file
@@ -0,0 +1,41 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
import { Monster as MyGameExample2Monster, MonsterT as MyGameExample2MonsterT } from '../../my-game/example2/monster';
|
||||
import { Monster, MonsterT } from '../../my-game/example/monster';
|
||||
import { TestSimpleTableWithEnum, TestSimpleTableWithEnumT } from '../../my-game/example/test-simple-table-with-enum';
|
||||
|
||||
|
||||
export enum AnyUniqueAliases{
|
||||
NONE = 0,
|
||||
M = 1,
|
||||
TS = 2,
|
||||
M2 = 3
|
||||
}
|
||||
|
||||
export function unionToAnyUniqueAliases(
|
||||
type: AnyUniqueAliases,
|
||||
accessor: (obj:Monster|MyGameExample2Monster|TestSimpleTableWithEnum) => Monster|MyGameExample2Monster|TestSimpleTableWithEnum|null
|
||||
): Monster|MyGameExample2Monster|TestSimpleTableWithEnum|null {
|
||||
switch(AnyUniqueAliases[type]) {
|
||||
case 'NONE': return null;
|
||||
case 'M': return accessor(new Monster())! as Monster;
|
||||
case 'TS': return accessor(new TestSimpleTableWithEnum())! as TestSimpleTableWithEnum;
|
||||
case 'M2': return accessor(new MyGameExample2Monster())! as MyGameExample2Monster;
|
||||
default: return null;
|
||||
}
|
||||
}
|
||||
|
||||
export function unionListToAnyUniqueAliases(
|
||||
type: AnyUniqueAliases,
|
||||
accessor: (index: number, obj:Monster|MyGameExample2Monster|TestSimpleTableWithEnum) => Monster|MyGameExample2Monster|TestSimpleTableWithEnum|null,
|
||||
index: number
|
||||
): Monster|MyGameExample2Monster|TestSimpleTableWithEnum|null {
|
||||
switch(AnyUniqueAliases[type]) {
|
||||
case 'NONE': return null;
|
||||
case 'M': return accessor(index, new Monster())! as Monster;
|
||||
case 'TS': return accessor(index, new TestSimpleTableWithEnum())! as TestSimpleTableWithEnum;
|
||||
case 'M2': return accessor(index, new MyGameExample2Monster())! as MyGameExample2Monster;
|
||||
default: return null;
|
||||
}
|
||||
}
|
||||
|
||||
41
tests/my-game/example/any.ts
Normal file
41
tests/my-game/example/any.ts
Normal file
@@ -0,0 +1,41 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
import { Monster as MyGameExample2Monster, MonsterT as MyGameExample2MonsterT } from '../../my-game/example2/monster';
|
||||
import { Monster, MonsterT } from '../../my-game/example/monster';
|
||||
import { TestSimpleTableWithEnum, TestSimpleTableWithEnumT } from '../../my-game/example/test-simple-table-with-enum';
|
||||
|
||||
|
||||
export enum Any{
|
||||
NONE = 0,
|
||||
Monster = 1,
|
||||
TestSimpleTableWithEnum = 2,
|
||||
MyGame_Example2_Monster = 3
|
||||
}
|
||||
|
||||
export function unionToAny(
|
||||
type: Any,
|
||||
accessor: (obj:Monster|MyGameExample2Monster|TestSimpleTableWithEnum) => Monster|MyGameExample2Monster|TestSimpleTableWithEnum|null
|
||||
): Monster|MyGameExample2Monster|TestSimpleTableWithEnum|null {
|
||||
switch(Any[type]) {
|
||||
case 'NONE': return null;
|
||||
case 'Monster': return accessor(new Monster())! as Monster;
|
||||
case 'TestSimpleTableWithEnum': return accessor(new TestSimpleTableWithEnum())! as TestSimpleTableWithEnum;
|
||||
case 'MyGame_Example2_Monster': return accessor(new MyGameExample2Monster())! as MyGameExample2Monster;
|
||||
default: return null;
|
||||
}
|
||||
}
|
||||
|
||||
export function unionListToAny(
|
||||
type: Any,
|
||||
accessor: (index: number, obj:Monster|MyGameExample2Monster|TestSimpleTableWithEnum) => Monster|MyGameExample2Monster|TestSimpleTableWithEnum|null,
|
||||
index: number
|
||||
): Monster|MyGameExample2Monster|TestSimpleTableWithEnum|null {
|
||||
switch(Any[type]) {
|
||||
case 'NONE': return null;
|
||||
case 'Monster': return accessor(index, new Monster())! as Monster;
|
||||
case 'TestSimpleTableWithEnum': return accessor(index, new TestSimpleTableWithEnum())! as TestSimpleTableWithEnum;
|
||||
case 'MyGame_Example2_Monster': return accessor(index, new MyGameExample2Monster())! as MyGameExample2Monster;
|
||||
default: return null;
|
||||
}
|
||||
}
|
||||
|
||||
20
tests/my-game/example/color.ts
Normal file
20
tests/my-game/example/color.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
/**
|
||||
* Composite components of Monster color.
|
||||
*/
|
||||
export enum Color{
|
||||
Red = 1,
|
||||
|
||||
/**
|
||||
* \brief color Green
|
||||
* Green is bit_flag with value (1u << 1)
|
||||
*/
|
||||
Green = 2,
|
||||
|
||||
/**
|
||||
* \brief color Blue (1u << 3)
|
||||
*/
|
||||
Blue = 8
|
||||
}
|
||||
|
||||
1366
tests/my-game/example/monster.ts
Normal file
1366
tests/my-game/example/monster.ts
Normal file
File diff suppressed because it is too large
Load Diff
9
tests/my-game/example/race.ts
Normal file
9
tests/my-game/example/race.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
export enum Race{
|
||||
None = -1,
|
||||
Human = 0,
|
||||
Dwarf = 1,
|
||||
Elf = 2
|
||||
}
|
||||
|
||||
91
tests/my-game/example/referrable.ts
Normal file
91
tests/my-game/example/referrable.ts
Normal file
@@ -0,0 +1,91 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
import * as flatbuffers from 'flatbuffers';
|
||||
|
||||
|
||||
|
||||
export class Referrable {
|
||||
bb: flatbuffers.ByteBuffer|null = null;
|
||||
bb_pos = 0;
|
||||
__init(i:number, bb:flatbuffers.ByteBuffer):Referrable {
|
||||
this.bb_pos = i;
|
||||
this.bb = bb;
|
||||
return this;
|
||||
}
|
||||
|
||||
static getRootAsReferrable(bb:flatbuffers.ByteBuffer, obj?:Referrable):Referrable {
|
||||
return (obj || new Referrable()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
|
||||
}
|
||||
|
||||
static getSizePrefixedRootAsReferrable(bb:flatbuffers.ByteBuffer, obj?:Referrable):Referrable {
|
||||
bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
|
||||
return (obj || new Referrable()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
|
||||
}
|
||||
|
||||
id():flatbuffers.Long {
|
||||
const offset = this.bb!.__offset(this.bb_pos, 4);
|
||||
return offset ? this.bb!.readUint64(this.bb_pos + offset) : this.bb!.createLong(0, 0);
|
||||
}
|
||||
|
||||
mutate_id(value:flatbuffers.Long):boolean {
|
||||
const offset = this.bb!.__offset(this.bb_pos, 4);
|
||||
|
||||
if (offset === 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
this.bb!.writeUint64(this.bb_pos + offset, value);
|
||||
return true;
|
||||
}
|
||||
|
||||
static startReferrable(builder:flatbuffers.Builder) {
|
||||
builder.startObject(1);
|
||||
}
|
||||
|
||||
static addId(builder:flatbuffers.Builder, id:flatbuffers.Long) {
|
||||
builder.addFieldInt64(0, id, builder.createLong(0, 0));
|
||||
}
|
||||
|
||||
static endReferrable(builder:flatbuffers.Builder):flatbuffers.Offset {
|
||||
const offset = builder.endObject();
|
||||
return offset;
|
||||
}
|
||||
|
||||
static createReferrable(builder:flatbuffers.Builder, id:flatbuffers.Long):flatbuffers.Offset {
|
||||
Referrable.startReferrable(builder);
|
||||
Referrable.addId(builder, id);
|
||||
return Referrable.endReferrable(builder);
|
||||
}
|
||||
|
||||
serialize():Uint8Array {
|
||||
return this.bb!.bytes();
|
||||
}
|
||||
|
||||
static deserialize(buffer: Uint8Array):Referrable {
|
||||
return Referrable.getRootAsReferrable(new flatbuffers.ByteBuffer(buffer))
|
||||
}
|
||||
|
||||
unpack(): ReferrableT {
|
||||
return new ReferrableT(
|
||||
this.id()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
unpackTo(_o: ReferrableT): void {
|
||||
_o.id = this.id();
|
||||
}
|
||||
}
|
||||
|
||||
export class ReferrableT {
|
||||
constructor(
|
||||
public id: flatbuffers.Long = flatbuffers.createLong(0, 0)
|
||||
){}
|
||||
|
||||
|
||||
pack(builder:flatbuffers.Builder): flatbuffers.Offset {
|
||||
return Referrable.createReferrable(builder,
|
||||
this.id
|
||||
);
|
||||
}
|
||||
}
|
||||
134
tests/my-game/example/stat.ts
Normal file
134
tests/my-game/example/stat.ts
Normal file
@@ -0,0 +1,134 @@
|
||||
// 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 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
|
||||
);
|
||||
}
|
||||
}
|
||||
92
tests/my-game/example/test-simple-table-with-enum.ts
Normal file
92
tests/my-game/example/test-simple-table-with-enum.ts
Normal file
@@ -0,0 +1,92 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
import * as flatbuffers from 'flatbuffers';
|
||||
|
||||
import { Color } from '../../my-game/example/color';
|
||||
|
||||
|
||||
export class TestSimpleTableWithEnum {
|
||||
bb: flatbuffers.ByteBuffer|null = null;
|
||||
bb_pos = 0;
|
||||
__init(i:number, bb:flatbuffers.ByteBuffer):TestSimpleTableWithEnum {
|
||||
this.bb_pos = i;
|
||||
this.bb = bb;
|
||||
return this;
|
||||
}
|
||||
|
||||
static getRootAsTestSimpleTableWithEnum(bb:flatbuffers.ByteBuffer, obj?:TestSimpleTableWithEnum):TestSimpleTableWithEnum {
|
||||
return (obj || new TestSimpleTableWithEnum()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
|
||||
}
|
||||
|
||||
static getSizePrefixedRootAsTestSimpleTableWithEnum(bb:flatbuffers.ByteBuffer, obj?:TestSimpleTableWithEnum):TestSimpleTableWithEnum {
|
||||
bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
|
||||
return (obj || new TestSimpleTableWithEnum()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
|
||||
}
|
||||
|
||||
color():Color {
|
||||
const offset = this.bb!.__offset(this.bb_pos, 4);
|
||||
return offset ? this.bb!.readUint8(this.bb_pos + offset) : Color.Green;
|
||||
}
|
||||
|
||||
mutate_color(value:Color):boolean {
|
||||
const offset = this.bb!.__offset(this.bb_pos, 4);
|
||||
|
||||
if (offset === 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
this.bb!.writeUint8(this.bb_pos + offset, value);
|
||||
return true;
|
||||
}
|
||||
|
||||
static startTestSimpleTableWithEnum(builder:flatbuffers.Builder) {
|
||||
builder.startObject(1);
|
||||
}
|
||||
|
||||
static addColor(builder:flatbuffers.Builder, color:Color) {
|
||||
builder.addFieldInt8(0, color, Color.Green);
|
||||
}
|
||||
|
||||
static endTestSimpleTableWithEnum(builder:flatbuffers.Builder):flatbuffers.Offset {
|
||||
const offset = builder.endObject();
|
||||
return offset;
|
||||
}
|
||||
|
||||
static createTestSimpleTableWithEnum(builder:flatbuffers.Builder, color:Color):flatbuffers.Offset {
|
||||
TestSimpleTableWithEnum.startTestSimpleTableWithEnum(builder);
|
||||
TestSimpleTableWithEnum.addColor(builder, color);
|
||||
return TestSimpleTableWithEnum.endTestSimpleTableWithEnum(builder);
|
||||
}
|
||||
|
||||
serialize():Uint8Array {
|
||||
return this.bb!.bytes();
|
||||
}
|
||||
|
||||
static deserialize(buffer: Uint8Array):TestSimpleTableWithEnum {
|
||||
return TestSimpleTableWithEnum.getRootAsTestSimpleTableWithEnum(new flatbuffers.ByteBuffer(buffer))
|
||||
}
|
||||
|
||||
unpack(): TestSimpleTableWithEnumT {
|
||||
return new TestSimpleTableWithEnumT(
|
||||
this.color()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
unpackTo(_o: TestSimpleTableWithEnumT): void {
|
||||
_o.color = this.color();
|
||||
}
|
||||
}
|
||||
|
||||
export class TestSimpleTableWithEnumT {
|
||||
constructor(
|
||||
public color: Color = Color.Green
|
||||
){}
|
||||
|
||||
|
||||
pack(builder:flatbuffers.Builder): flatbuffers.Offset {
|
||||
return TestSimpleTableWithEnum.createTestSimpleTableWithEnum(builder,
|
||||
this.color
|
||||
);
|
||||
}
|
||||
}
|
||||
74
tests/my-game/example/test.ts
Normal file
74
tests/my-game/example/test.ts
Normal file
@@ -0,0 +1,74 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
import * as flatbuffers from 'flatbuffers';
|
||||
|
||||
|
||||
|
||||
export class Test {
|
||||
bb: flatbuffers.ByteBuffer|null = null;
|
||||
bb_pos = 0;
|
||||
__init(i:number, bb:flatbuffers.ByteBuffer):Test {
|
||||
this.bb_pos = i;
|
||||
this.bb = bb;
|
||||
return this;
|
||||
}
|
||||
|
||||
a():number {
|
||||
return this.bb!.readInt16(this.bb_pos);
|
||||
}
|
||||
|
||||
mutate_a(value:number):boolean {
|
||||
this.bb!.writeInt16(this.bb_pos + 0, value);
|
||||
return true;
|
||||
}
|
||||
|
||||
b():number {
|
||||
return this.bb!.readInt8(this.bb_pos + 2);
|
||||
}
|
||||
|
||||
mutate_b(value:number):boolean {
|
||||
this.bb!.writeInt8(this.bb_pos + 2, value);
|
||||
return true;
|
||||
}
|
||||
|
||||
static sizeOf():number {
|
||||
return 4;
|
||||
}
|
||||
|
||||
static createTest(builder:flatbuffers.Builder, a: number, b: number):flatbuffers.Offset {
|
||||
builder.prep(2, 4);
|
||||
builder.pad(1);
|
||||
builder.writeInt8(b);
|
||||
builder.writeInt16(a);
|
||||
return builder.offset();
|
||||
}
|
||||
|
||||
|
||||
unpack(): TestT {
|
||||
return new TestT(
|
||||
this.a(),
|
||||
this.b()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
unpackTo(_o: TestT): void {
|
||||
_o.a = this.a();
|
||||
_o.b = this.b();
|
||||
}
|
||||
}
|
||||
|
||||
export class TestT {
|
||||
constructor(
|
||||
public a: number = 0,
|
||||
public b: number = 0
|
||||
){}
|
||||
|
||||
|
||||
pack(builder:flatbuffers.Builder): flatbuffers.Offset {
|
||||
return Test.createTest(builder,
|
||||
this.a,
|
||||
this.b
|
||||
);
|
||||
}
|
||||
}
|
||||
401
tests/my-game/example/type-aliases.ts
Normal file
401
tests/my-game/example/type-aliases.ts
Normal file
@@ -0,0 +1,401 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
import * as flatbuffers from 'flatbuffers';
|
||||
|
||||
|
||||
|
||||
export class TypeAliases {
|
||||
bb: flatbuffers.ByteBuffer|null = null;
|
||||
bb_pos = 0;
|
||||
__init(i:number, bb:flatbuffers.ByteBuffer):TypeAliases {
|
||||
this.bb_pos = i;
|
||||
this.bb = bb;
|
||||
return this;
|
||||
}
|
||||
|
||||
static getRootAsTypeAliases(bb:flatbuffers.ByteBuffer, obj?:TypeAliases):TypeAliases {
|
||||
return (obj || new TypeAliases()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
|
||||
}
|
||||
|
||||
static getSizePrefixedRootAsTypeAliases(bb:flatbuffers.ByteBuffer, obj?:TypeAliases):TypeAliases {
|
||||
bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
|
||||
return (obj || new TypeAliases()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
|
||||
}
|
||||
|
||||
i8():number {
|
||||
const offset = this.bb!.__offset(this.bb_pos, 4);
|
||||
return offset ? this.bb!.readInt8(this.bb_pos + offset) : 0;
|
||||
}
|
||||
|
||||
mutate_i8(value:number):boolean {
|
||||
const offset = this.bb!.__offset(this.bb_pos, 4);
|
||||
|
||||
if (offset === 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
this.bb!.writeInt8(this.bb_pos + offset, value);
|
||||
return true;
|
||||
}
|
||||
|
||||
u8():number {
|
||||
const offset = this.bb!.__offset(this.bb_pos, 6);
|
||||
return offset ? this.bb!.readUint8(this.bb_pos + offset) : 0;
|
||||
}
|
||||
|
||||
mutate_u8(value:number):boolean {
|
||||
const offset = this.bb!.__offset(this.bb_pos, 6);
|
||||
|
||||
if (offset === 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
this.bb!.writeUint8(this.bb_pos + offset, value);
|
||||
return true;
|
||||
}
|
||||
|
||||
i16():number {
|
||||
const offset = this.bb!.__offset(this.bb_pos, 8);
|
||||
return offset ? this.bb!.readInt16(this.bb_pos + offset) : 0;
|
||||
}
|
||||
|
||||
mutate_i16(value:number):boolean {
|
||||
const offset = this.bb!.__offset(this.bb_pos, 8);
|
||||
|
||||
if (offset === 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
this.bb!.writeInt16(this.bb_pos + offset, value);
|
||||
return true;
|
||||
}
|
||||
|
||||
u16():number {
|
||||
const offset = this.bb!.__offset(this.bb_pos, 10);
|
||||
return offset ? this.bb!.readUint16(this.bb_pos + offset) : 0;
|
||||
}
|
||||
|
||||
mutate_u16(value:number):boolean {
|
||||
const offset = this.bb!.__offset(this.bb_pos, 10);
|
||||
|
||||
if (offset === 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
this.bb!.writeUint16(this.bb_pos + offset, value);
|
||||
return true;
|
||||
}
|
||||
|
||||
i32():number {
|
||||
const offset = this.bb!.__offset(this.bb_pos, 12);
|
||||
return offset ? this.bb!.readInt32(this.bb_pos + offset) : 0;
|
||||
}
|
||||
|
||||
mutate_i32(value:number):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;
|
||||
}
|
||||
|
||||
u32():number {
|
||||
const offset = this.bb!.__offset(this.bb_pos, 14);
|
||||
return offset ? this.bb!.readUint32(this.bb_pos + offset) : 0;
|
||||
}
|
||||
|
||||
mutate_u32(value:number):boolean {
|
||||
const offset = this.bb!.__offset(this.bb_pos, 14);
|
||||
|
||||
if (offset === 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
this.bb!.writeUint32(this.bb_pos + offset, value);
|
||||
return true;
|
||||
}
|
||||
|
||||
i64():flatbuffers.Long {
|
||||
const offset = this.bb!.__offset(this.bb_pos, 16);
|
||||
return offset ? this.bb!.readInt64(this.bb_pos + offset) : this.bb!.createLong(0, 0);
|
||||
}
|
||||
|
||||
mutate_i64(value:flatbuffers.Long):boolean {
|
||||
const offset = this.bb!.__offset(this.bb_pos, 16);
|
||||
|
||||
if (offset === 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
this.bb!.writeInt64(this.bb_pos + offset, value);
|
||||
return true;
|
||||
}
|
||||
|
||||
u64():flatbuffers.Long {
|
||||
const offset = this.bb!.__offset(this.bb_pos, 18);
|
||||
return offset ? this.bb!.readUint64(this.bb_pos + offset) : this.bb!.createLong(0, 0);
|
||||
}
|
||||
|
||||
mutate_u64(value:flatbuffers.Long):boolean {
|
||||
const offset = this.bb!.__offset(this.bb_pos, 18);
|
||||
|
||||
if (offset === 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
this.bb!.writeUint64(this.bb_pos + offset, value);
|
||||
return true;
|
||||
}
|
||||
|
||||
f32():number {
|
||||
const offset = this.bb!.__offset(this.bb_pos, 20);
|
||||
return offset ? this.bb!.readFloat32(this.bb_pos + offset) : 0.0;
|
||||
}
|
||||
|
||||
mutate_f32(value:number):boolean {
|
||||
const offset = this.bb!.__offset(this.bb_pos, 20);
|
||||
|
||||
if (offset === 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
this.bb!.writeFloat32(this.bb_pos + offset, value);
|
||||
return true;
|
||||
}
|
||||
|
||||
f64():number {
|
||||
const offset = this.bb!.__offset(this.bb_pos, 22);
|
||||
return offset ? this.bb!.readFloat64(this.bb_pos + offset) : 0.0;
|
||||
}
|
||||
|
||||
mutate_f64(value:number):boolean {
|
||||
const offset = this.bb!.__offset(this.bb_pos, 22);
|
||||
|
||||
if (offset === 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
this.bb!.writeFloat64(this.bb_pos + offset, value);
|
||||
return true;
|
||||
}
|
||||
|
||||
v8(index: number):number|null {
|
||||
const offset = this.bb!.__offset(this.bb_pos, 24);
|
||||
return offset ? this.bb!.readInt8(this.bb!.__vector(this.bb_pos + offset) + index) : 0;
|
||||
}
|
||||
|
||||
v8Length():number {
|
||||
const offset = this.bb!.__offset(this.bb_pos, 24);
|
||||
return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
|
||||
}
|
||||
|
||||
v8Array():Int8Array|null {
|
||||
const offset = this.bb!.__offset(this.bb_pos, 24);
|
||||
return offset ? new Int8Array(this.bb!.bytes().buffer, this.bb!.bytes().byteOffset + this.bb!.__vector(this.bb_pos + offset), this.bb!.__vector_len(this.bb_pos + offset)) : null;
|
||||
}
|
||||
|
||||
vf64(index: number):number|null {
|
||||
const offset = this.bb!.__offset(this.bb_pos, 26);
|
||||
return offset ? this.bb!.readFloat64(this.bb!.__vector(this.bb_pos + offset) + index * 8) : 0;
|
||||
}
|
||||
|
||||
vf64Length():number {
|
||||
const offset = this.bb!.__offset(this.bb_pos, 26);
|
||||
return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
|
||||
}
|
||||
|
||||
vf64Array():Float64Array|null {
|
||||
const offset = this.bb!.__offset(this.bb_pos, 26);
|
||||
return offset ? new Float64Array(this.bb!.bytes().buffer, this.bb!.bytes().byteOffset + this.bb!.__vector(this.bb_pos + offset), this.bb!.__vector_len(this.bb_pos + offset)) : null;
|
||||
}
|
||||
|
||||
static startTypeAliases(builder:flatbuffers.Builder) {
|
||||
builder.startObject(12);
|
||||
}
|
||||
|
||||
static addI8(builder:flatbuffers.Builder, i8:number) {
|
||||
builder.addFieldInt8(0, i8, 0);
|
||||
}
|
||||
|
||||
static addU8(builder:flatbuffers.Builder, u8:number) {
|
||||
builder.addFieldInt8(1, u8, 0);
|
||||
}
|
||||
|
||||
static addI16(builder:flatbuffers.Builder, i16:number) {
|
||||
builder.addFieldInt16(2, i16, 0);
|
||||
}
|
||||
|
||||
static addU16(builder:flatbuffers.Builder, u16:number) {
|
||||
builder.addFieldInt16(3, u16, 0);
|
||||
}
|
||||
|
||||
static addI32(builder:flatbuffers.Builder, i32:number) {
|
||||
builder.addFieldInt32(4, i32, 0);
|
||||
}
|
||||
|
||||
static addU32(builder:flatbuffers.Builder, u32:number) {
|
||||
builder.addFieldInt32(5, u32, 0);
|
||||
}
|
||||
|
||||
static addI64(builder:flatbuffers.Builder, i64:flatbuffers.Long) {
|
||||
builder.addFieldInt64(6, i64, builder.createLong(0, 0));
|
||||
}
|
||||
|
||||
static addU64(builder:flatbuffers.Builder, u64:flatbuffers.Long) {
|
||||
builder.addFieldInt64(7, u64, builder.createLong(0, 0));
|
||||
}
|
||||
|
||||
static addF32(builder:flatbuffers.Builder, f32:number) {
|
||||
builder.addFieldFloat32(8, f32, 0.0);
|
||||
}
|
||||
|
||||
static addF64(builder:flatbuffers.Builder, f64:number) {
|
||||
builder.addFieldFloat64(9, f64, 0.0);
|
||||
}
|
||||
|
||||
static addV8(builder:flatbuffers.Builder, v8Offset:flatbuffers.Offset) {
|
||||
builder.addFieldOffset(10, v8Offset, 0);
|
||||
}
|
||||
|
||||
static createV8Vector(builder:flatbuffers.Builder, data:number[]|Int8Array):flatbuffers.Offset;
|
||||
/**
|
||||
* @deprecated This Uint8Array overload will be removed in the future.
|
||||
*/
|
||||
static createV8Vector(builder:flatbuffers.Builder, data:number[]|Uint8Array):flatbuffers.Offset;
|
||||
static createV8Vector(builder:flatbuffers.Builder, data:number[]|Int8Array|Uint8Array):flatbuffers.Offset {
|
||||
builder.startVector(1, data.length, 1);
|
||||
for (let i = data.length - 1; i >= 0; i--) {
|
||||
builder.addInt8(data[i]!);
|
||||
}
|
||||
return builder.endVector();
|
||||
}
|
||||
|
||||
static startV8Vector(builder:flatbuffers.Builder, numElems:number) {
|
||||
builder.startVector(1, numElems, 1);
|
||||
}
|
||||
|
||||
static addVf64(builder:flatbuffers.Builder, vf64Offset:flatbuffers.Offset) {
|
||||
builder.addFieldOffset(11, vf64Offset, 0);
|
||||
}
|
||||
|
||||
static createVf64Vector(builder:flatbuffers.Builder, data:number[]|Float64Array):flatbuffers.Offset;
|
||||
/**
|
||||
* @deprecated This Uint8Array overload will be removed in the future.
|
||||
*/
|
||||
static createVf64Vector(builder:flatbuffers.Builder, data:number[]|Uint8Array):flatbuffers.Offset;
|
||||
static createVf64Vector(builder:flatbuffers.Builder, data:number[]|Float64Array|Uint8Array):flatbuffers.Offset {
|
||||
builder.startVector(8, data.length, 8);
|
||||
for (let i = data.length - 1; i >= 0; i--) {
|
||||
builder.addFloat64(data[i]!);
|
||||
}
|
||||
return builder.endVector();
|
||||
}
|
||||
|
||||
static startVf64Vector(builder:flatbuffers.Builder, numElems:number) {
|
||||
builder.startVector(8, numElems, 8);
|
||||
}
|
||||
|
||||
static endTypeAliases(builder:flatbuffers.Builder):flatbuffers.Offset {
|
||||
const offset = builder.endObject();
|
||||
return offset;
|
||||
}
|
||||
|
||||
static createTypeAliases(builder:flatbuffers.Builder, i8:number, u8:number, i16:number, u16:number, i32:number, u32:number, i64:flatbuffers.Long, u64:flatbuffers.Long, f32:number, f64:number, v8Offset:flatbuffers.Offset, vf64Offset:flatbuffers.Offset):flatbuffers.Offset {
|
||||
TypeAliases.startTypeAliases(builder);
|
||||
TypeAliases.addI8(builder, i8);
|
||||
TypeAliases.addU8(builder, u8);
|
||||
TypeAliases.addI16(builder, i16);
|
||||
TypeAliases.addU16(builder, u16);
|
||||
TypeAliases.addI32(builder, i32);
|
||||
TypeAliases.addU32(builder, u32);
|
||||
TypeAliases.addI64(builder, i64);
|
||||
TypeAliases.addU64(builder, u64);
|
||||
TypeAliases.addF32(builder, f32);
|
||||
TypeAliases.addF64(builder, f64);
|
||||
TypeAliases.addV8(builder, v8Offset);
|
||||
TypeAliases.addVf64(builder, vf64Offset);
|
||||
return TypeAliases.endTypeAliases(builder);
|
||||
}
|
||||
|
||||
serialize():Uint8Array {
|
||||
return this.bb!.bytes();
|
||||
}
|
||||
|
||||
static deserialize(buffer: Uint8Array):TypeAliases {
|
||||
return TypeAliases.getRootAsTypeAliases(new flatbuffers.ByteBuffer(buffer))
|
||||
}
|
||||
|
||||
unpack(): TypeAliasesT {
|
||||
return new TypeAliasesT(
|
||||
this.i8(),
|
||||
this.u8(),
|
||||
this.i16(),
|
||||
this.u16(),
|
||||
this.i32(),
|
||||
this.u32(),
|
||||
this.i64(),
|
||||
this.u64(),
|
||||
this.f32(),
|
||||
this.f64(),
|
||||
this.bb!.createScalarList(this.v8.bind(this), this.v8Length()),
|
||||
this.bb!.createScalarList(this.vf64.bind(this), this.vf64Length())
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
unpackTo(_o: TypeAliasesT): void {
|
||||
_o.i8 = this.i8();
|
||||
_o.u8 = this.u8();
|
||||
_o.i16 = this.i16();
|
||||
_o.u16 = this.u16();
|
||||
_o.i32 = this.i32();
|
||||
_o.u32 = this.u32();
|
||||
_o.i64 = this.i64();
|
||||
_o.u64 = this.u64();
|
||||
_o.f32 = this.f32();
|
||||
_o.f64 = this.f64();
|
||||
_o.v8 = this.bb!.createScalarList(this.v8.bind(this), this.v8Length());
|
||||
_o.vf64 = this.bb!.createScalarList(this.vf64.bind(this), this.vf64Length());
|
||||
}
|
||||
}
|
||||
|
||||
export class TypeAliasesT {
|
||||
constructor(
|
||||
public i8: number = 0,
|
||||
public u8: number = 0,
|
||||
public i16: number = 0,
|
||||
public u16: number = 0,
|
||||
public i32: number = 0,
|
||||
public u32: number = 0,
|
||||
public i64: flatbuffers.Long = flatbuffers.createLong(0, 0),
|
||||
public u64: flatbuffers.Long = flatbuffers.createLong(0, 0),
|
||||
public f32: number = 0.0,
|
||||
public f64: number = 0.0,
|
||||
public v8: (number)[] = [],
|
||||
public vf64: (number)[] = []
|
||||
){}
|
||||
|
||||
|
||||
pack(builder:flatbuffers.Builder): flatbuffers.Offset {
|
||||
const v8 = TypeAliases.createV8Vector(builder, this.v8);
|
||||
const vf64 = TypeAliases.createVf64Vector(builder, this.vf64);
|
||||
|
||||
return TypeAliases.createTypeAliases(builder,
|
||||
this.i8,
|
||||
this.u8,
|
||||
this.i16,
|
||||
this.u16,
|
||||
this.i32,
|
||||
this.u32,
|
||||
this.i64,
|
||||
this.u64,
|
||||
this.f32,
|
||||
this.f64,
|
||||
v8,
|
||||
vf64
|
||||
);
|
||||
}
|
||||
}
|
||||
133
tests/my-game/example/vec3.ts
Normal file
133
tests/my-game/example/vec3.ts
Normal file
@@ -0,0 +1,133 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
import * as flatbuffers from 'flatbuffers';
|
||||
|
||||
import { Color } from '../../my-game/example/color';
|
||||
import { Test, TestT } from '../../my-game/example/test';
|
||||
|
||||
|
||||
export class Vec3 {
|
||||
bb: flatbuffers.ByteBuffer|null = null;
|
||||
bb_pos = 0;
|
||||
__init(i:number, bb:flatbuffers.ByteBuffer):Vec3 {
|
||||
this.bb_pos = i;
|
||||
this.bb = bb;
|
||||
return this;
|
||||
}
|
||||
|
||||
x():number {
|
||||
return this.bb!.readFloat32(this.bb_pos);
|
||||
}
|
||||
|
||||
mutate_x(value:number):boolean {
|
||||
this.bb!.writeFloat32(this.bb_pos + 0, value);
|
||||
return true;
|
||||
}
|
||||
|
||||
y():number {
|
||||
return this.bb!.readFloat32(this.bb_pos + 4);
|
||||
}
|
||||
|
||||
mutate_y(value:number):boolean {
|
||||
this.bb!.writeFloat32(this.bb_pos + 4, value);
|
||||
return true;
|
||||
}
|
||||
|
||||
z():number {
|
||||
return this.bb!.readFloat32(this.bb_pos + 8);
|
||||
}
|
||||
|
||||
mutate_z(value:number):boolean {
|
||||
this.bb!.writeFloat32(this.bb_pos + 8, value);
|
||||
return true;
|
||||
}
|
||||
|
||||
test1():number {
|
||||
return this.bb!.readFloat64(this.bb_pos + 16);
|
||||
}
|
||||
|
||||
mutate_test1(value:number):boolean {
|
||||
this.bb!.writeFloat64(this.bb_pos + 16, value);
|
||||
return true;
|
||||
}
|
||||
|
||||
test2():Color {
|
||||
return this.bb!.readUint8(this.bb_pos + 24);
|
||||
}
|
||||
|
||||
mutate_test2(value:Color):boolean {
|
||||
this.bb!.writeUint8(this.bb_pos + 24, value);
|
||||
return true;
|
||||
}
|
||||
|
||||
test3(obj?:Test):Test|null {
|
||||
return (obj || new Test()).__init(this.bb_pos + 26, this.bb!);
|
||||
}
|
||||
|
||||
static sizeOf():number {
|
||||
return 32;
|
||||
}
|
||||
|
||||
static createVec3(builder:flatbuffers.Builder, x: number, y: number, z: number, test1: number, test2: Color, test3_a: number, test3_b: number):flatbuffers.Offset {
|
||||
builder.prep(8, 32);
|
||||
builder.pad(2);
|
||||
builder.prep(2, 4);
|
||||
builder.pad(1);
|
||||
builder.writeInt8(test3_b);
|
||||
builder.writeInt16(test3_a);
|
||||
builder.pad(1);
|
||||
builder.writeInt8(test2);
|
||||
builder.writeFloat64(test1);
|
||||
builder.pad(4);
|
||||
builder.writeFloat32(z);
|
||||
builder.writeFloat32(y);
|
||||
builder.writeFloat32(x);
|
||||
return builder.offset();
|
||||
}
|
||||
|
||||
|
||||
unpack(): Vec3T {
|
||||
return new Vec3T(
|
||||
this.x(),
|
||||
this.y(),
|
||||
this.z(),
|
||||
this.test1(),
|
||||
this.test2(),
|
||||
(this.test3() !== null ? this.test3()!.unpack() : null)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
unpackTo(_o: Vec3T): void {
|
||||
_o.x = this.x();
|
||||
_o.y = this.y();
|
||||
_o.z = this.z();
|
||||
_o.test1 = this.test1();
|
||||
_o.test2 = this.test2();
|
||||
_o.test3 = (this.test3() !== null ? this.test3()!.unpack() : null);
|
||||
}
|
||||
}
|
||||
|
||||
export class Vec3T {
|
||||
constructor(
|
||||
public x: number = 0.0,
|
||||
public y: number = 0.0,
|
||||
public z: number = 0.0,
|
||||
public test1: number = 0.0,
|
||||
public test2: Color = 0,
|
||||
public test3: TestT|null = null
|
||||
){}
|
||||
|
||||
|
||||
pack(builder:flatbuffers.Builder): flatbuffers.Offset {
|
||||
return Vec3.createVec3(builder,
|
||||
this.x,
|
||||
this.y,
|
||||
this.z,
|
||||
this.test1,
|
||||
this.test2,
|
||||
(this.test3 === null ? 0 : this.test3.a!),
|
||||
(this.test3 === null ? 0 : this.test3.b!)
|
||||
);
|
||||
}
|
||||
}
|
||||
62
tests/my-game/example2/monster.ts
Normal file
62
tests/my-game/example2/monster.ts
Normal file
@@ -0,0 +1,62 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
import * as flatbuffers from 'flatbuffers';
|
||||
|
||||
|
||||
|
||||
export class Monster {
|
||||
bb: flatbuffers.ByteBuffer|null = null;
|
||||
bb_pos = 0;
|
||||
__init(i:number, bb:flatbuffers.ByteBuffer):Monster {
|
||||
this.bb_pos = i;
|
||||
this.bb = bb;
|
||||
return this;
|
||||
}
|
||||
|
||||
static getRootAsMonster(bb:flatbuffers.ByteBuffer, obj?:Monster):Monster {
|
||||
return (obj || new Monster()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
|
||||
}
|
||||
|
||||
static getSizePrefixedRootAsMonster(bb:flatbuffers.ByteBuffer, obj?:Monster):Monster {
|
||||
bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
|
||||
return (obj || new Monster()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
|
||||
}
|
||||
|
||||
static startMonster(builder:flatbuffers.Builder) {
|
||||
builder.startObject(0);
|
||||
}
|
||||
|
||||
static endMonster(builder:flatbuffers.Builder):flatbuffers.Offset {
|
||||
const offset = builder.endObject();
|
||||
return offset;
|
||||
}
|
||||
|
||||
static createMonster(builder:flatbuffers.Builder):flatbuffers.Offset {
|
||||
Monster.startMonster(builder);
|
||||
return Monster.endMonster(builder);
|
||||
}
|
||||
|
||||
serialize():Uint8Array {
|
||||
return this.bb!.bytes();
|
||||
}
|
||||
|
||||
static deserialize(buffer: Uint8Array):Monster {
|
||||
return Monster.getRootAsMonster(new flatbuffers.ByteBuffer(buffer))
|
||||
}
|
||||
|
||||
unpack(): MonsterT {
|
||||
return new MonsterT();
|
||||
}
|
||||
|
||||
|
||||
unpackTo(_o: MonsterT): void {}
|
||||
}
|
||||
|
||||
export class MonsterT {
|
||||
constructor(){}
|
||||
|
||||
|
||||
pack(builder:flatbuffers.Builder): flatbuffers.Offset {
|
||||
return Monster.createMonster(builder);
|
||||
}
|
||||
}
|
||||
62
tests/my-game/in-parent-namespace.ts
Normal file
62
tests/my-game/in-parent-namespace.ts
Normal file
@@ -0,0 +1,62 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
import * as flatbuffers from 'flatbuffers';
|
||||
|
||||
|
||||
|
||||
export class InParentNamespace {
|
||||
bb: flatbuffers.ByteBuffer|null = null;
|
||||
bb_pos = 0;
|
||||
__init(i:number, bb:flatbuffers.ByteBuffer):InParentNamespace {
|
||||
this.bb_pos = i;
|
||||
this.bb = bb;
|
||||
return this;
|
||||
}
|
||||
|
||||
static getRootAsInParentNamespace(bb:flatbuffers.ByteBuffer, obj?:InParentNamespace):InParentNamespace {
|
||||
return (obj || new InParentNamespace()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
|
||||
}
|
||||
|
||||
static getSizePrefixedRootAsInParentNamespace(bb:flatbuffers.ByteBuffer, obj?:InParentNamespace):InParentNamespace {
|
||||
bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
|
||||
return (obj || new InParentNamespace()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
|
||||
}
|
||||
|
||||
static startInParentNamespace(builder:flatbuffers.Builder) {
|
||||
builder.startObject(0);
|
||||
}
|
||||
|
||||
static endInParentNamespace(builder:flatbuffers.Builder):flatbuffers.Offset {
|
||||
const offset = builder.endObject();
|
||||
return offset;
|
||||
}
|
||||
|
||||
static createInParentNamespace(builder:flatbuffers.Builder):flatbuffers.Offset {
|
||||
InParentNamespace.startInParentNamespace(builder);
|
||||
return InParentNamespace.endInParentNamespace(builder);
|
||||
}
|
||||
|
||||
serialize():Uint8Array {
|
||||
return this.bb!.bytes();
|
||||
}
|
||||
|
||||
static deserialize(buffer: Uint8Array):InParentNamespace {
|
||||
return InParentNamespace.getRootAsInParentNamespace(new flatbuffers.ByteBuffer(buffer))
|
||||
}
|
||||
|
||||
unpack(): InParentNamespaceT {
|
||||
return new InParentNamespaceT();
|
||||
}
|
||||
|
||||
|
||||
unpackTo(_o: InParentNamespaceT): void {}
|
||||
}
|
||||
|
||||
export class InParentNamespaceT {
|
||||
constructor(){}
|
||||
|
||||
|
||||
pack(builder:flatbuffers.Builder): flatbuffers.Offset {
|
||||
return InParentNamespace.createInParentNamespace(builder);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
export enum EnumInNestedNS{
|
||||
A = 0,
|
||||
B = 1,
|
||||
C = 2
|
||||
}
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
import * as flatbuffers from 'flatbuffers';
|
||||
|
||||
|
||||
|
||||
export class StructInNestedNS {
|
||||
bb: flatbuffers.ByteBuffer|null = null;
|
||||
bb_pos = 0;
|
||||
__init(i:number, bb:flatbuffers.ByteBuffer):StructInNestedNS {
|
||||
this.bb_pos = i;
|
||||
this.bb = bb;
|
||||
return this;
|
||||
}
|
||||
|
||||
a():number {
|
||||
return this.bb!.readInt32(this.bb_pos);
|
||||
}
|
||||
|
||||
mutate_a(value:number):boolean {
|
||||
this.bb!.writeInt32(this.bb_pos + 0, value);
|
||||
return true;
|
||||
}
|
||||
|
||||
b():number {
|
||||
return this.bb!.readInt32(this.bb_pos + 4);
|
||||
}
|
||||
|
||||
mutate_b(value:number):boolean {
|
||||
this.bb!.writeInt32(this.bb_pos + 4, value);
|
||||
return true;
|
||||
}
|
||||
|
||||
static getFullyQualifiedName():string {
|
||||
return 'NamespaceA.NamespaceB.StructInNestedNS';
|
||||
}
|
||||
|
||||
static sizeOf():number {
|
||||
return 8;
|
||||
}
|
||||
|
||||
static createStructInNestedNS(builder:flatbuffers.Builder, a: number, b: number):flatbuffers.Offset {
|
||||
builder.prep(4, 8);
|
||||
builder.writeInt32(b);
|
||||
builder.writeInt32(a);
|
||||
return builder.offset();
|
||||
}
|
||||
|
||||
|
||||
unpack(): StructInNestedNST {
|
||||
return new StructInNestedNST(
|
||||
this.a(),
|
||||
this.b()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
unpackTo(_o: StructInNestedNST): void {
|
||||
_o.a = this.a();
|
||||
_o.b = this.b();
|
||||
}
|
||||
}
|
||||
|
||||
export class StructInNestedNST {
|
||||
constructor(
|
||||
public a: number = 0,
|
||||
public b: number = 0
|
||||
){}
|
||||
|
||||
|
||||
pack(builder:flatbuffers.Builder): flatbuffers.Offset {
|
||||
return StructInNestedNS.createStructInNestedNS(builder,
|
||||
this.a,
|
||||
this.b
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
import * as flatbuffers from 'flatbuffers';
|
||||
|
||||
|
||||
|
||||
export class TableInNestedNS {
|
||||
bb: flatbuffers.ByteBuffer|null = null;
|
||||
bb_pos = 0;
|
||||
__init(i:number, bb:flatbuffers.ByteBuffer):TableInNestedNS {
|
||||
this.bb_pos = i;
|
||||
this.bb = bb;
|
||||
return this;
|
||||
}
|
||||
|
||||
static getRootAsTableInNestedNS(bb:flatbuffers.ByteBuffer, obj?:TableInNestedNS):TableInNestedNS {
|
||||
return (obj || new TableInNestedNS()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
|
||||
}
|
||||
|
||||
static getSizePrefixedRootAsTableInNestedNS(bb:flatbuffers.ByteBuffer, obj?:TableInNestedNS):TableInNestedNS {
|
||||
bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
|
||||
return (obj || new TableInNestedNS()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
|
||||
}
|
||||
|
||||
foo():number {
|
||||
const offset = this.bb!.__offset(this.bb_pos, 4);
|
||||
return offset ? this.bb!.readInt32(this.bb_pos + offset) : 0;
|
||||
}
|
||||
|
||||
mutate_foo(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;
|
||||
}
|
||||
|
||||
static getFullyQualifiedName():string {
|
||||
return 'NamespaceA.NamespaceB.TableInNestedNS';
|
||||
}
|
||||
|
||||
static startTableInNestedNS(builder:flatbuffers.Builder) {
|
||||
builder.startObject(1);
|
||||
}
|
||||
|
||||
static addFoo(builder:flatbuffers.Builder, foo:number) {
|
||||
builder.addFieldInt32(0, foo, 0);
|
||||
}
|
||||
|
||||
static endTableInNestedNS(builder:flatbuffers.Builder):flatbuffers.Offset {
|
||||
const offset = builder.endObject();
|
||||
return offset;
|
||||
}
|
||||
|
||||
static createTableInNestedNS(builder:flatbuffers.Builder, foo:number):flatbuffers.Offset {
|
||||
TableInNestedNS.startTableInNestedNS(builder);
|
||||
TableInNestedNS.addFoo(builder, foo);
|
||||
return TableInNestedNS.endTableInNestedNS(builder);
|
||||
}
|
||||
|
||||
unpack(): TableInNestedNST {
|
||||
return new TableInNestedNST(
|
||||
this.foo()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
unpackTo(_o: TableInNestedNST): void {
|
||||
_o.foo = this.foo();
|
||||
}
|
||||
}
|
||||
|
||||
export class TableInNestedNST {
|
||||
constructor(
|
||||
public foo: number = 0
|
||||
){}
|
||||
|
||||
|
||||
pack(builder:flatbuffers.Builder): flatbuffers.Offset {
|
||||
return TableInNestedNS.createTableInNestedNS(builder,
|
||||
this.foo
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
import { TableInNestedNS, TableInNestedNST } from '../../namespace-a/namespace-b/table-in-nested-n-s';
|
||||
|
||||
|
||||
export enum UnionInNestedNS{
|
||||
NONE = 0,
|
||||
TableInNestedNS = 1
|
||||
}
|
||||
|
||||
export function unionToUnionInNestedNS(
|
||||
type: UnionInNestedNS,
|
||||
accessor: (obj:TableInNestedNS) => TableInNestedNS|null
|
||||
): TableInNestedNS|null {
|
||||
switch(UnionInNestedNS[type]) {
|
||||
case 'NONE': return null;
|
||||
case 'TableInNestedNS': return accessor(new TableInNestedNS())! as TableInNestedNS;
|
||||
default: return null;
|
||||
}
|
||||
}
|
||||
|
||||
export function unionListToUnionInNestedNS(
|
||||
type: UnionInNestedNS,
|
||||
accessor: (index: number, obj:TableInNestedNS) => TableInNestedNS|null,
|
||||
index: number
|
||||
): TableInNestedNS|null {
|
||||
switch(UnionInNestedNS[type]) {
|
||||
case 'NONE': return null;
|
||||
case 'TableInNestedNS': return accessor(index, new TableInNestedNS())! as TableInNestedNS;
|
||||
default: return null;
|
||||
}
|
||||
}
|
||||
|
||||
77
tests/namespace_test/namespace-a/second-table-in-a.ts
Normal file
77
tests/namespace_test/namespace-a/second-table-in-a.ts
Normal file
@@ -0,0 +1,77 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
import * as flatbuffers from 'flatbuffers';
|
||||
|
||||
import { TableInC, TableInCT } from '../namespace-c/table-in-c';
|
||||
|
||||
|
||||
export class SecondTableInA {
|
||||
bb: flatbuffers.ByteBuffer|null = null;
|
||||
bb_pos = 0;
|
||||
__init(i:number, bb:flatbuffers.ByteBuffer):SecondTableInA {
|
||||
this.bb_pos = i;
|
||||
this.bb = bb;
|
||||
return this;
|
||||
}
|
||||
|
||||
static getRootAsSecondTableInA(bb:flatbuffers.ByteBuffer, obj?:SecondTableInA):SecondTableInA {
|
||||
return (obj || new SecondTableInA()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
|
||||
}
|
||||
|
||||
static getSizePrefixedRootAsSecondTableInA(bb:flatbuffers.ByteBuffer, obj?:SecondTableInA):SecondTableInA {
|
||||
bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
|
||||
return (obj || new SecondTableInA()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
|
||||
}
|
||||
|
||||
referToC(obj?:TableInC):TableInC|null {
|
||||
const offset = this.bb!.__offset(this.bb_pos, 4);
|
||||
return offset ? (obj || new TableInC()).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null;
|
||||
}
|
||||
|
||||
static getFullyQualifiedName():string {
|
||||
return 'NamespaceA.SecondTableInA';
|
||||
}
|
||||
|
||||
static startSecondTableInA(builder:flatbuffers.Builder) {
|
||||
builder.startObject(1);
|
||||
}
|
||||
|
||||
static addReferToC(builder:flatbuffers.Builder, referToCOffset:flatbuffers.Offset) {
|
||||
builder.addFieldOffset(0, referToCOffset, 0);
|
||||
}
|
||||
|
||||
static endSecondTableInA(builder:flatbuffers.Builder):flatbuffers.Offset {
|
||||
const offset = builder.endObject();
|
||||
return offset;
|
||||
}
|
||||
|
||||
static createSecondTableInA(builder:flatbuffers.Builder, referToCOffset:flatbuffers.Offset):flatbuffers.Offset {
|
||||
SecondTableInA.startSecondTableInA(builder);
|
||||
SecondTableInA.addReferToC(builder, referToCOffset);
|
||||
return SecondTableInA.endSecondTableInA(builder);
|
||||
}
|
||||
|
||||
unpack(): SecondTableInAT {
|
||||
return new SecondTableInAT(
|
||||
(this.referToC() !== null ? this.referToC()!.unpack() : null)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
unpackTo(_o: SecondTableInAT): void {
|
||||
_o.referToC = (this.referToC() !== null ? this.referToC()!.unpack() : null);
|
||||
}
|
||||
}
|
||||
|
||||
export class SecondTableInAT {
|
||||
constructor(
|
||||
public referToC: TableInCT|null = null
|
||||
){}
|
||||
|
||||
|
||||
pack(builder:flatbuffers.Builder): flatbuffers.Offset {
|
||||
return SecondTableInA.createSecondTableInA(builder,
|
||||
(this.referToC !== null ? this.referToC!.pack(builder) : 0)
|
||||
);
|
||||
}
|
||||
}
|
||||
149
tests/namespace_test/namespace-a/table-in-first-n-s.ts
Normal file
149
tests/namespace_test/namespace-a/table-in-first-n-s.ts
Normal file
@@ -0,0 +1,149 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
import * as flatbuffers from 'flatbuffers';
|
||||
|
||||
import { EnumInNestedNS } from '../namespace-a/namespace-b/enum-in-nested-n-s';
|
||||
import { StructInNestedNS, StructInNestedNST } from '../namespace-a/namespace-b/struct-in-nested-n-s';
|
||||
import { TableInNestedNS, TableInNestedNST } from '../namespace-a/namespace-b/table-in-nested-n-s';
|
||||
import { UnionInNestedNS, unionToUnionInNestedNS, unionListToUnionInNestedNS } from '../namespace-a/namespace-b/union-in-nested-n-s';
|
||||
|
||||
|
||||
export class TableInFirstNS {
|
||||
bb: flatbuffers.ByteBuffer|null = null;
|
||||
bb_pos = 0;
|
||||
__init(i:number, bb:flatbuffers.ByteBuffer):TableInFirstNS {
|
||||
this.bb_pos = i;
|
||||
this.bb = bb;
|
||||
return this;
|
||||
}
|
||||
|
||||
static getRootAsTableInFirstNS(bb:flatbuffers.ByteBuffer, obj?:TableInFirstNS):TableInFirstNS {
|
||||
return (obj || new TableInFirstNS()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
|
||||
}
|
||||
|
||||
static getSizePrefixedRootAsTableInFirstNS(bb:flatbuffers.ByteBuffer, obj?:TableInFirstNS):TableInFirstNS {
|
||||
bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
|
||||
return (obj || new TableInFirstNS()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
|
||||
}
|
||||
|
||||
fooTable(obj?:NS8755221360535654258.TableInNestedNS):NS8755221360535654258.TableInNestedNS|null {
|
||||
const offset = this.bb!.__offset(this.bb_pos, 4);
|
||||
return offset ? (obj || new NS8755221360535654258.TableInNestedNS()).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null;
|
||||
}
|
||||
|
||||
fooEnum():EnumInNestedNS {
|
||||
const offset = this.bb!.__offset(this.bb_pos, 6);
|
||||
return offset ? this.bb!.readInt8(this.bb_pos + offset) : EnumInNestedNS.A;
|
||||
}
|
||||
|
||||
mutate_foo_enum(value:EnumInNestedNS):boolean {
|
||||
const offset = this.bb!.__offset(this.bb_pos, 6);
|
||||
|
||||
if (offset === 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
this.bb!.writeInt8(this.bb_pos + offset, value);
|
||||
return true;
|
||||
}
|
||||
|
||||
fooUnionType():UnionInNestedNS {
|
||||
const offset = this.bb!.__offset(this.bb_pos, 8);
|
||||
return offset ? this.bb!.readUint8(this.bb_pos + offset) : UnionInNestedNS.NONE;
|
||||
}
|
||||
|
||||
fooUnion<T extends flatbuffers.Table>(obj:any):any|null {
|
||||
const offset = this.bb!.__offset(this.bb_pos, 10);
|
||||
return offset ? this.bb!.__union(obj, this.bb_pos + offset) : null;
|
||||
}
|
||||
|
||||
fooStruct(obj?:NS8755221360535654258.StructInNestedNS):NS8755221360535654258.StructInNestedNS|null {
|
||||
const offset = this.bb!.__offset(this.bb_pos, 12);
|
||||
return offset ? (obj || new NS8755221360535654258.StructInNestedNS()).__init(this.bb_pos + offset, this.bb!) : null;
|
||||
}
|
||||
|
||||
static getFullyQualifiedName():string {
|
||||
return 'NamespaceA.TableInFirstNS';
|
||||
}
|
||||
|
||||
static startTableInFirstNS(builder:flatbuffers.Builder) {
|
||||
builder.startObject(5);
|
||||
}
|
||||
|
||||
static addFooTable(builder:flatbuffers.Builder, fooTableOffset:flatbuffers.Offset) {
|
||||
builder.addFieldOffset(0, fooTableOffset, 0);
|
||||
}
|
||||
|
||||
static addFooEnum(builder:flatbuffers.Builder, fooEnum:EnumInNestedNS) {
|
||||
builder.addFieldInt8(1, fooEnum, EnumInNestedNS.A);
|
||||
}
|
||||
|
||||
static addFooUnionType(builder:flatbuffers.Builder, fooUnionType:UnionInNestedNS) {
|
||||
builder.addFieldInt8(2, fooUnionType, UnionInNestedNS.NONE);
|
||||
}
|
||||
|
||||
static addFooUnion(builder:flatbuffers.Builder, fooUnionOffset:flatbuffers.Offset) {
|
||||
builder.addFieldOffset(3, fooUnionOffset, 0);
|
||||
}
|
||||
|
||||
static addFooStruct(builder:flatbuffers.Builder, fooStructOffset:flatbuffers.Offset) {
|
||||
builder.addFieldStruct(4, fooStructOffset, 0);
|
||||
}
|
||||
|
||||
static endTableInFirstNS(builder:flatbuffers.Builder):flatbuffers.Offset {
|
||||
const offset = builder.endObject();
|
||||
return offset;
|
||||
}
|
||||
|
||||
|
||||
unpack(): TableInFirstNST {
|
||||
return new TableInFirstNST(
|
||||
(this.fooTable() !== null ? this.fooTable()!.unpack() : null),
|
||||
this.fooEnum(),
|
||||
this.fooUnionType(),
|
||||
(() => {
|
||||
let temp = unionToUnionInNestedNS(this.fooUnionType(), this.fooUnion.bind(this));
|
||||
if(temp === null) { return null; }
|
||||
return temp.unpack()
|
||||
})(),
|
||||
(this.fooStruct() !== null ? this.fooStruct()!.unpack() : null)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
unpackTo(_o: TableInFirstNST): void {
|
||||
_o.fooTable = (this.fooTable() !== null ? this.fooTable()!.unpack() : null);
|
||||
_o.fooEnum = this.fooEnum();
|
||||
_o.fooUnionType = this.fooUnionType();
|
||||
_o.fooUnion = (() => {
|
||||
let temp = unionToUnionInNestedNS(this.fooUnionType(), this.fooUnion.bind(this));
|
||||
if(temp === null) { return null; }
|
||||
return temp.unpack()
|
||||
})();
|
||||
_o.fooStruct = (this.fooStruct() !== null ? this.fooStruct()!.unpack() : null);
|
||||
}
|
||||
}
|
||||
|
||||
export class TableInFirstNST {
|
||||
constructor(
|
||||
public fooTable: TableInNestedNST|null = null,
|
||||
public fooEnum: EnumInNestedNS = EnumInNestedNS.A,
|
||||
public fooUnionType: UnionInNestedNS = UnionInNestedNS.NONE,
|
||||
public fooUnion: TableInNestedNST|null = null,
|
||||
public fooStruct: StructInNestedNST|null = null
|
||||
){}
|
||||
|
||||
|
||||
pack(builder:flatbuffers.Builder): flatbuffers.Offset {
|
||||
const fooUnion = builder.createObjectOffset(this.fooUnion);
|
||||
|
||||
TableInFirstNS.startTableInFirstNS(builder);
|
||||
TableInFirstNS.addFooTable(builder, (this.fooTable !== null ? this.fooTable!.pack(builder) : 0));
|
||||
TableInFirstNS.addFooEnum(builder, this.fooEnum);
|
||||
TableInFirstNS.addFooUnionType(builder, this.fooUnionType);
|
||||
TableInFirstNS.addFooUnion(builder, fooUnion);
|
||||
TableInFirstNS.addFooStruct(builder, (this.fooStruct !== null ? this.fooStruct!.pack(builder) : 0));
|
||||
|
||||
return TableInFirstNS.endTableInFirstNS(builder);
|
||||
}
|
||||
}
|
||||
87
tests/namespace_test/namespace-c/table-in-c.ts
Normal file
87
tests/namespace_test/namespace-c/table-in-c.ts
Normal file
@@ -0,0 +1,87 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
import * as flatbuffers from 'flatbuffers';
|
||||
|
||||
import { SecondTableInA, SecondTableInAT } from '../namespace-a/second-table-in-a';
|
||||
import { TableInFirstNS, TableInFirstNST } from '../namespace-a/table-in-first-n-s';
|
||||
|
||||
|
||||
export class TableInC {
|
||||
bb: flatbuffers.ByteBuffer|null = null;
|
||||
bb_pos = 0;
|
||||
__init(i:number, bb:flatbuffers.ByteBuffer):TableInC {
|
||||
this.bb_pos = i;
|
||||
this.bb = bb;
|
||||
return this;
|
||||
}
|
||||
|
||||
static getRootAsTableInC(bb:flatbuffers.ByteBuffer, obj?:TableInC):TableInC {
|
||||
return (obj || new TableInC()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
|
||||
}
|
||||
|
||||
static getSizePrefixedRootAsTableInC(bb:flatbuffers.ByteBuffer, obj?:TableInC):TableInC {
|
||||
bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
|
||||
return (obj || new TableInC()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
|
||||
}
|
||||
|
||||
referToA1(obj?:TableInFirstNS):TableInFirstNS|null {
|
||||
const offset = this.bb!.__offset(this.bb_pos, 4);
|
||||
return offset ? (obj || new TableInFirstNS()).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null;
|
||||
}
|
||||
|
||||
referToA2(obj?:SecondTableInA):SecondTableInA|null {
|
||||
const offset = this.bb!.__offset(this.bb_pos, 6);
|
||||
return offset ? (obj || new SecondTableInA()).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null;
|
||||
}
|
||||
|
||||
static getFullyQualifiedName():string {
|
||||
return 'NamespaceC.TableInC';
|
||||
}
|
||||
|
||||
static startTableInC(builder:flatbuffers.Builder) {
|
||||
builder.startObject(2);
|
||||
}
|
||||
|
||||
static addReferToA1(builder:flatbuffers.Builder, referToA1Offset:flatbuffers.Offset) {
|
||||
builder.addFieldOffset(0, referToA1Offset, 0);
|
||||
}
|
||||
|
||||
static addReferToA2(builder:flatbuffers.Builder, referToA2Offset:flatbuffers.Offset) {
|
||||
builder.addFieldOffset(1, referToA2Offset, 0);
|
||||
}
|
||||
|
||||
static endTableInC(builder:flatbuffers.Builder):flatbuffers.Offset {
|
||||
const offset = builder.endObject();
|
||||
return offset;
|
||||
}
|
||||
|
||||
|
||||
unpack(): TableInCT {
|
||||
return new TableInCT(
|
||||
(this.referToA1() !== null ? this.referToA1()!.unpack() : null),
|
||||
(this.referToA2() !== null ? this.referToA2()!.unpack() : null)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
unpackTo(_o: TableInCT): void {
|
||||
_o.referToA1 = (this.referToA1() !== null ? this.referToA1()!.unpack() : null);
|
||||
_o.referToA2 = (this.referToA2() !== null ? this.referToA2()!.unpack() : null);
|
||||
}
|
||||
}
|
||||
|
||||
export class TableInCT {
|
||||
constructor(
|
||||
public referToA1: TableInFirstNST|null = null,
|
||||
public referToA2: SecondTableInAT|null = null
|
||||
){}
|
||||
|
||||
|
||||
pack(builder:flatbuffers.Builder): flatbuffers.Offset {
|
||||
TableInC.startTableInC(builder);
|
||||
TableInC.addReferToA1(builder, (this.referToA1 !== null ? this.referToA1!.pack(builder) : 0));
|
||||
TableInC.addReferToA2(builder, (this.referToA2 !== null ? this.referToA2!.pack(builder) : 0));
|
||||
|
||||
return TableInC.endTableInC(builder);
|
||||
}
|
||||
}
|
||||
8
tests/optional_scalars/optional-byte.ts
Normal file
8
tests/optional_scalars/optional-byte.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
export enum OptionalByte{
|
||||
None = 0,
|
||||
One = 1,
|
||||
Two = 2
|
||||
}
|
||||
|
||||
423
tests/optional_scalars/scalar-stuff.ts
Normal file
423
tests/optional_scalars/scalar-stuff.ts
Normal file
@@ -0,0 +1,423 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
import * as flatbuffers from 'flatbuffers';
|
||||
|
||||
import { OptionalByte } from '../optional_scalars/optional-byte';
|
||||
|
||||
|
||||
export class ScalarStuff {
|
||||
bb: flatbuffers.ByteBuffer|null = null;
|
||||
bb_pos = 0;
|
||||
__init(i:number, bb:flatbuffers.ByteBuffer):ScalarStuff {
|
||||
this.bb_pos = i;
|
||||
this.bb = bb;
|
||||
return this;
|
||||
}
|
||||
|
||||
static getRootAsScalarStuff(bb:flatbuffers.ByteBuffer, obj?:ScalarStuff):ScalarStuff {
|
||||
return (obj || new ScalarStuff()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
|
||||
}
|
||||
|
||||
static getSizePrefixedRootAsScalarStuff(bb:flatbuffers.ByteBuffer, obj?:ScalarStuff):ScalarStuff {
|
||||
bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
|
||||
return (obj || new ScalarStuff()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
|
||||
}
|
||||
|
||||
static bufferHasIdentifier(bb:flatbuffers.ByteBuffer):boolean {
|
||||
return bb.__has_identifier('NULL');
|
||||
}
|
||||
|
||||
justI8():number {
|
||||
const offset = this.bb!.__offset(this.bb_pos, 4);
|
||||
return offset ? this.bb!.readInt8(this.bb_pos + offset) : 0;
|
||||
}
|
||||
|
||||
maybeI8():number|null {
|
||||
const offset = this.bb!.__offset(this.bb_pos, 6);
|
||||
return offset ? this.bb!.readInt8(this.bb_pos + offset) : null;
|
||||
}
|
||||
|
||||
defaultI8():number {
|
||||
const offset = this.bb!.__offset(this.bb_pos, 8);
|
||||
return offset ? this.bb!.readInt8(this.bb_pos + offset) : 42;
|
||||
}
|
||||
|
||||
justU8():number {
|
||||
const offset = this.bb!.__offset(this.bb_pos, 10);
|
||||
return offset ? this.bb!.readUint8(this.bb_pos + offset) : 0;
|
||||
}
|
||||
|
||||
maybeU8():number|null {
|
||||
const offset = this.bb!.__offset(this.bb_pos, 12);
|
||||
return offset ? this.bb!.readUint8(this.bb_pos + offset) : null;
|
||||
}
|
||||
|
||||
defaultU8():number {
|
||||
const offset = this.bb!.__offset(this.bb_pos, 14);
|
||||
return offset ? this.bb!.readUint8(this.bb_pos + offset) : 42;
|
||||
}
|
||||
|
||||
justI16():number {
|
||||
const offset = this.bb!.__offset(this.bb_pos, 16);
|
||||
return offset ? this.bb!.readInt16(this.bb_pos + offset) : 0;
|
||||
}
|
||||
|
||||
maybeI16():number|null {
|
||||
const offset = this.bb!.__offset(this.bb_pos, 18);
|
||||
return offset ? this.bb!.readInt16(this.bb_pos + offset) : null;
|
||||
}
|
||||
|
||||
defaultI16():number {
|
||||
const offset = this.bb!.__offset(this.bb_pos, 20);
|
||||
return offset ? this.bb!.readInt16(this.bb_pos + offset) : 42;
|
||||
}
|
||||
|
||||
justU16():number {
|
||||
const offset = this.bb!.__offset(this.bb_pos, 22);
|
||||
return offset ? this.bb!.readUint16(this.bb_pos + offset) : 0;
|
||||
}
|
||||
|
||||
maybeU16():number|null {
|
||||
const offset = this.bb!.__offset(this.bb_pos, 24);
|
||||
return offset ? this.bb!.readUint16(this.bb_pos + offset) : null;
|
||||
}
|
||||
|
||||
defaultU16():number {
|
||||
const offset = this.bb!.__offset(this.bb_pos, 26);
|
||||
return offset ? this.bb!.readUint16(this.bb_pos + offset) : 42;
|
||||
}
|
||||
|
||||
justI32():number {
|
||||
const offset = this.bb!.__offset(this.bb_pos, 28);
|
||||
return offset ? this.bb!.readInt32(this.bb_pos + offset) : 0;
|
||||
}
|
||||
|
||||
maybeI32():number|null {
|
||||
const offset = this.bb!.__offset(this.bb_pos, 30);
|
||||
return offset ? this.bb!.readInt32(this.bb_pos + offset) : null;
|
||||
}
|
||||
|
||||
defaultI32():number {
|
||||
const offset = this.bb!.__offset(this.bb_pos, 32);
|
||||
return offset ? this.bb!.readInt32(this.bb_pos + offset) : 42;
|
||||
}
|
||||
|
||||
justU32():number {
|
||||
const offset = this.bb!.__offset(this.bb_pos, 34);
|
||||
return offset ? this.bb!.readUint32(this.bb_pos + offset) : 0;
|
||||
}
|
||||
|
||||
maybeU32():number|null {
|
||||
const offset = this.bb!.__offset(this.bb_pos, 36);
|
||||
return offset ? this.bb!.readUint32(this.bb_pos + offset) : null;
|
||||
}
|
||||
|
||||
defaultU32():number {
|
||||
const offset = this.bb!.__offset(this.bb_pos, 38);
|
||||
return offset ? this.bb!.readUint32(this.bb_pos + offset) : 42;
|
||||
}
|
||||
|
||||
justI64():flatbuffers.Long {
|
||||
const offset = this.bb!.__offset(this.bb_pos, 40);
|
||||
return offset ? this.bb!.readInt64(this.bb_pos + offset) : this.bb!.createLong(0, 0);
|
||||
}
|
||||
|
||||
maybeI64():flatbuffers.Long|null {
|
||||
const offset = this.bb!.__offset(this.bb_pos, 42);
|
||||
return offset ? this.bb!.readInt64(this.bb_pos + offset) : null;
|
||||
}
|
||||
|
||||
defaultI64():flatbuffers.Long {
|
||||
const offset = this.bb!.__offset(this.bb_pos, 44);
|
||||
return offset ? this.bb!.readInt64(this.bb_pos + offset) : this.bb!.createLong(42, 0);
|
||||
}
|
||||
|
||||
justU64():flatbuffers.Long {
|
||||
const offset = this.bb!.__offset(this.bb_pos, 46);
|
||||
return offset ? this.bb!.readUint64(this.bb_pos + offset) : this.bb!.createLong(0, 0);
|
||||
}
|
||||
|
||||
maybeU64():flatbuffers.Long|null {
|
||||
const offset = this.bb!.__offset(this.bb_pos, 48);
|
||||
return offset ? this.bb!.readUint64(this.bb_pos + offset) : null;
|
||||
}
|
||||
|
||||
defaultU64():flatbuffers.Long {
|
||||
const offset = this.bb!.__offset(this.bb_pos, 50);
|
||||
return offset ? this.bb!.readUint64(this.bb_pos + offset) : this.bb!.createLong(42, 0);
|
||||
}
|
||||
|
||||
justF32():number {
|
||||
const offset = this.bb!.__offset(this.bb_pos, 52);
|
||||
return offset ? this.bb!.readFloat32(this.bb_pos + offset) : 0.0;
|
||||
}
|
||||
|
||||
maybeF32():number|null {
|
||||
const offset = this.bb!.__offset(this.bb_pos, 54);
|
||||
return offset ? this.bb!.readFloat32(this.bb_pos + offset) : null;
|
||||
}
|
||||
|
||||
defaultF32():number {
|
||||
const offset = this.bb!.__offset(this.bb_pos, 56);
|
||||
return offset ? this.bb!.readFloat32(this.bb_pos + offset) : 42.0;
|
||||
}
|
||||
|
||||
justF64():number {
|
||||
const offset = this.bb!.__offset(this.bb_pos, 58);
|
||||
return offset ? this.bb!.readFloat64(this.bb_pos + offset) : 0.0;
|
||||
}
|
||||
|
||||
maybeF64():number|null {
|
||||
const offset = this.bb!.__offset(this.bb_pos, 60);
|
||||
return offset ? this.bb!.readFloat64(this.bb_pos + offset) : null;
|
||||
}
|
||||
|
||||
defaultF64():number {
|
||||
const offset = this.bb!.__offset(this.bb_pos, 62);
|
||||
return offset ? this.bb!.readFloat64(this.bb_pos + offset) : 42.0;
|
||||
}
|
||||
|
||||
justBool():boolean {
|
||||
const offset = this.bb!.__offset(this.bb_pos, 64);
|
||||
return offset ? !!this.bb!.readInt8(this.bb_pos + offset) : false;
|
||||
}
|
||||
|
||||
maybeBool():boolean|null {
|
||||
const offset = this.bb!.__offset(this.bb_pos, 66);
|
||||
return offset ? !!this.bb!.readInt8(this.bb_pos + offset) : null;
|
||||
}
|
||||
|
||||
defaultBool():boolean {
|
||||
const offset = this.bb!.__offset(this.bb_pos, 68);
|
||||
return offset ? !!this.bb!.readInt8(this.bb_pos + offset) : true;
|
||||
}
|
||||
|
||||
justEnum():OptionalByte {
|
||||
const offset = this.bb!.__offset(this.bb_pos, 70);
|
||||
return offset ? this.bb!.readInt8(this.bb_pos + offset) : OptionalByte.None;
|
||||
}
|
||||
|
||||
maybeEnum():OptionalByte|null {
|
||||
const offset = this.bb!.__offset(this.bb_pos, 72);
|
||||
return offset ? this.bb!.readInt8(this.bb_pos + offset) : null;
|
||||
}
|
||||
|
||||
defaultEnum():OptionalByte {
|
||||
const offset = this.bb!.__offset(this.bb_pos, 74);
|
||||
return offset ? this.bb!.readInt8(this.bb_pos + offset) : OptionalByte.One;
|
||||
}
|
||||
|
||||
static startScalarStuff(builder:flatbuffers.Builder) {
|
||||
builder.startObject(36);
|
||||
}
|
||||
|
||||
static addJustI8(builder:flatbuffers.Builder, justI8:number) {
|
||||
builder.addFieldInt8(0, justI8, 0);
|
||||
}
|
||||
|
||||
static addMaybeI8(builder:flatbuffers.Builder, maybeI8:number) {
|
||||
builder.addFieldInt8(1, maybeI8, 0);
|
||||
}
|
||||
|
||||
static addDefaultI8(builder:flatbuffers.Builder, defaultI8:number) {
|
||||
builder.addFieldInt8(2, defaultI8, 42);
|
||||
}
|
||||
|
||||
static addJustU8(builder:flatbuffers.Builder, justU8:number) {
|
||||
builder.addFieldInt8(3, justU8, 0);
|
||||
}
|
||||
|
||||
static addMaybeU8(builder:flatbuffers.Builder, maybeU8:number) {
|
||||
builder.addFieldInt8(4, maybeU8, 0);
|
||||
}
|
||||
|
||||
static addDefaultU8(builder:flatbuffers.Builder, defaultU8:number) {
|
||||
builder.addFieldInt8(5, defaultU8, 42);
|
||||
}
|
||||
|
||||
static addJustI16(builder:flatbuffers.Builder, justI16:number) {
|
||||
builder.addFieldInt16(6, justI16, 0);
|
||||
}
|
||||
|
||||
static addMaybeI16(builder:flatbuffers.Builder, maybeI16:number) {
|
||||
builder.addFieldInt16(7, maybeI16, 0);
|
||||
}
|
||||
|
||||
static addDefaultI16(builder:flatbuffers.Builder, defaultI16:number) {
|
||||
builder.addFieldInt16(8, defaultI16, 42);
|
||||
}
|
||||
|
||||
static addJustU16(builder:flatbuffers.Builder, justU16:number) {
|
||||
builder.addFieldInt16(9, justU16, 0);
|
||||
}
|
||||
|
||||
static addMaybeU16(builder:flatbuffers.Builder, maybeU16:number) {
|
||||
builder.addFieldInt16(10, maybeU16, 0);
|
||||
}
|
||||
|
||||
static addDefaultU16(builder:flatbuffers.Builder, defaultU16:number) {
|
||||
builder.addFieldInt16(11, defaultU16, 42);
|
||||
}
|
||||
|
||||
static addJustI32(builder:flatbuffers.Builder, justI32:number) {
|
||||
builder.addFieldInt32(12, justI32, 0);
|
||||
}
|
||||
|
||||
static addMaybeI32(builder:flatbuffers.Builder, maybeI32:number) {
|
||||
builder.addFieldInt32(13, maybeI32, 0);
|
||||
}
|
||||
|
||||
static addDefaultI32(builder:flatbuffers.Builder, defaultI32:number) {
|
||||
builder.addFieldInt32(14, defaultI32, 42);
|
||||
}
|
||||
|
||||
static addJustU32(builder:flatbuffers.Builder, justU32:number) {
|
||||
builder.addFieldInt32(15, justU32, 0);
|
||||
}
|
||||
|
||||
static addMaybeU32(builder:flatbuffers.Builder, maybeU32:number) {
|
||||
builder.addFieldInt32(16, maybeU32, 0);
|
||||
}
|
||||
|
||||
static addDefaultU32(builder:flatbuffers.Builder, defaultU32:number) {
|
||||
builder.addFieldInt32(17, defaultU32, 42);
|
||||
}
|
||||
|
||||
static addJustI64(builder:flatbuffers.Builder, justI64:flatbuffers.Long) {
|
||||
builder.addFieldInt64(18, justI64, builder.createLong(0, 0));
|
||||
}
|
||||
|
||||
static addMaybeI64(builder:flatbuffers.Builder, maybeI64:flatbuffers.Long) {
|
||||
builder.addFieldInt64(19, maybeI64, builder.createLong(0, 0));
|
||||
}
|
||||
|
||||
static addDefaultI64(builder:flatbuffers.Builder, defaultI64:flatbuffers.Long) {
|
||||
builder.addFieldInt64(20, defaultI64, builder.createLong(42, 0));
|
||||
}
|
||||
|
||||
static addJustU64(builder:flatbuffers.Builder, justU64:flatbuffers.Long) {
|
||||
builder.addFieldInt64(21, justU64, builder.createLong(0, 0));
|
||||
}
|
||||
|
||||
static addMaybeU64(builder:flatbuffers.Builder, maybeU64:flatbuffers.Long) {
|
||||
builder.addFieldInt64(22, maybeU64, builder.createLong(0, 0));
|
||||
}
|
||||
|
||||
static addDefaultU64(builder:flatbuffers.Builder, defaultU64:flatbuffers.Long) {
|
||||
builder.addFieldInt64(23, defaultU64, builder.createLong(42, 0));
|
||||
}
|
||||
|
||||
static addJustF32(builder:flatbuffers.Builder, justF32:number) {
|
||||
builder.addFieldFloat32(24, justF32, 0.0);
|
||||
}
|
||||
|
||||
static addMaybeF32(builder:flatbuffers.Builder, maybeF32:number) {
|
||||
builder.addFieldFloat32(25, maybeF32, 0);
|
||||
}
|
||||
|
||||
static addDefaultF32(builder:flatbuffers.Builder, defaultF32:number) {
|
||||
builder.addFieldFloat32(26, defaultF32, 42.0);
|
||||
}
|
||||
|
||||
static addJustF64(builder:flatbuffers.Builder, justF64:number) {
|
||||
builder.addFieldFloat64(27, justF64, 0.0);
|
||||
}
|
||||
|
||||
static addMaybeF64(builder:flatbuffers.Builder, maybeF64:number) {
|
||||
builder.addFieldFloat64(28, maybeF64, 0);
|
||||
}
|
||||
|
||||
static addDefaultF64(builder:flatbuffers.Builder, defaultF64:number) {
|
||||
builder.addFieldFloat64(29, defaultF64, 42.0);
|
||||
}
|
||||
|
||||
static addJustBool(builder:flatbuffers.Builder, justBool:boolean) {
|
||||
builder.addFieldInt8(30, +justBool, +false);
|
||||
}
|
||||
|
||||
static addMaybeBool(builder:flatbuffers.Builder, maybeBool:boolean) {
|
||||
builder.addFieldInt8(31, +maybeBool, 0);
|
||||
}
|
||||
|
||||
static addDefaultBool(builder:flatbuffers.Builder, defaultBool:boolean) {
|
||||
builder.addFieldInt8(32, +defaultBool, +true);
|
||||
}
|
||||
|
||||
static addJustEnum(builder:flatbuffers.Builder, justEnum:OptionalByte) {
|
||||
builder.addFieldInt8(33, justEnum, OptionalByte.None);
|
||||
}
|
||||
|
||||
static addMaybeEnum(builder:flatbuffers.Builder, maybeEnum:OptionalByte) {
|
||||
builder.addFieldInt8(34, maybeEnum, 0);
|
||||
}
|
||||
|
||||
static addDefaultEnum(builder:flatbuffers.Builder, defaultEnum:OptionalByte) {
|
||||
builder.addFieldInt8(35, defaultEnum, OptionalByte.One);
|
||||
}
|
||||
|
||||
static endScalarStuff(builder:flatbuffers.Builder):flatbuffers.Offset {
|
||||
const offset = builder.endObject();
|
||||
return offset;
|
||||
}
|
||||
|
||||
static finishScalarStuffBuffer(builder:flatbuffers.Builder, offset:flatbuffers.Offset) {
|
||||
builder.finish(offset, 'NULL');
|
||||
}
|
||||
|
||||
static finishSizePrefixedScalarStuffBuffer(builder:flatbuffers.Builder, offset:flatbuffers.Offset) {
|
||||
builder.finish(offset, 'NULL', true);
|
||||
}
|
||||
|
||||
static createScalarStuff(builder:flatbuffers.Builder, justI8:number, maybeI8:number|null, defaultI8:number, justU8:number, maybeU8:number|null, defaultU8:number, justI16:number, maybeI16:number|null, defaultI16:number, justU16:number, maybeU16:number|null, defaultU16:number, justI32:number, maybeI32:number|null, defaultI32:number, justU32:number, maybeU32:number|null, defaultU32:number, justI64:flatbuffers.Long, maybeI64:flatbuffers.Long|null, defaultI64:flatbuffers.Long, justU64:flatbuffers.Long, maybeU64:flatbuffers.Long|null, defaultU64:flatbuffers.Long, justF32:number, maybeF32:number|null, defaultF32:number, justF64:number, maybeF64:number|null, defaultF64:number, justBool:boolean, maybeBool:boolean|null, defaultBool:boolean, justEnum:OptionalByte, maybeEnum:OptionalByte|null, defaultEnum:OptionalByte):flatbuffers.Offset {
|
||||
ScalarStuff.startScalarStuff(builder);
|
||||
ScalarStuff.addJustI8(builder, justI8);
|
||||
if (maybeI8 !== null)
|
||||
ScalarStuff.addMaybeI8(builder, maybeI8);
|
||||
ScalarStuff.addDefaultI8(builder, defaultI8);
|
||||
ScalarStuff.addJustU8(builder, justU8);
|
||||
if (maybeU8 !== null)
|
||||
ScalarStuff.addMaybeU8(builder, maybeU8);
|
||||
ScalarStuff.addDefaultU8(builder, defaultU8);
|
||||
ScalarStuff.addJustI16(builder, justI16);
|
||||
if (maybeI16 !== null)
|
||||
ScalarStuff.addMaybeI16(builder, maybeI16);
|
||||
ScalarStuff.addDefaultI16(builder, defaultI16);
|
||||
ScalarStuff.addJustU16(builder, justU16);
|
||||
if (maybeU16 !== null)
|
||||
ScalarStuff.addMaybeU16(builder, maybeU16);
|
||||
ScalarStuff.addDefaultU16(builder, defaultU16);
|
||||
ScalarStuff.addJustI32(builder, justI32);
|
||||
if (maybeI32 !== null)
|
||||
ScalarStuff.addMaybeI32(builder, maybeI32);
|
||||
ScalarStuff.addDefaultI32(builder, defaultI32);
|
||||
ScalarStuff.addJustU32(builder, justU32);
|
||||
if (maybeU32 !== null)
|
||||
ScalarStuff.addMaybeU32(builder, maybeU32);
|
||||
ScalarStuff.addDefaultU32(builder, defaultU32);
|
||||
ScalarStuff.addJustI64(builder, justI64);
|
||||
if (maybeI64 !== null)
|
||||
ScalarStuff.addMaybeI64(builder, maybeI64);
|
||||
ScalarStuff.addDefaultI64(builder, defaultI64);
|
||||
ScalarStuff.addJustU64(builder, justU64);
|
||||
if (maybeU64 !== null)
|
||||
ScalarStuff.addMaybeU64(builder, maybeU64);
|
||||
ScalarStuff.addDefaultU64(builder, defaultU64);
|
||||
ScalarStuff.addJustF32(builder, justF32);
|
||||
if (maybeF32 !== null)
|
||||
ScalarStuff.addMaybeF32(builder, maybeF32);
|
||||
ScalarStuff.addDefaultF32(builder, defaultF32);
|
||||
ScalarStuff.addJustF64(builder, justF64);
|
||||
if (maybeF64 !== null)
|
||||
ScalarStuff.addMaybeF64(builder, maybeF64);
|
||||
ScalarStuff.addDefaultF64(builder, defaultF64);
|
||||
ScalarStuff.addJustBool(builder, justBool);
|
||||
if (maybeBool !== null)
|
||||
ScalarStuff.addMaybeBool(builder, maybeBool);
|
||||
ScalarStuff.addDefaultBool(builder, defaultBool);
|
||||
ScalarStuff.addJustEnum(builder, justEnum);
|
||||
if (maybeEnum !== null)
|
||||
ScalarStuff.addMaybeEnum(builder, maybeEnum);
|
||||
ScalarStuff.addDefaultEnum(builder, defaultEnum);
|
||||
return ScalarStuff.endScalarStuff(builder);
|
||||
}
|
||||
}
|
||||
@@ -88,7 +88,7 @@ static addCharactersType(builder:flatbuffers.Builder, charactersTypeOffset:flatb
|
||||
static createCharactersTypeVector(builder:flatbuffers.Builder, data:Character[]):flatbuffers.Offset {
|
||||
builder.startVector(1, data.length, 1);
|
||||
for (let i = data.length - 1; i >= 0; i--) {
|
||||
builder.addInt8(data[i]);
|
||||
builder.addInt8(data[i]!);
|
||||
}
|
||||
return builder.endVector();
|
||||
}
|
||||
@@ -104,7 +104,7 @@ static addCharacters(builder:flatbuffers.Builder, charactersOffset:flatbuffers.O
|
||||
static createCharactersVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset {
|
||||
builder.startVector(4, data.length, 4);
|
||||
for (let i = data.length - 1; i >= 0; i--) {
|
||||
builder.addOffset(data[i]);
|
||||
builder.addOffset(data[i]!);
|
||||
}
|
||||
return builder.endVector();
|
||||
}
|
||||
|
||||
@@ -677,7 +677,7 @@ static addInventory(builder:flatbuffers.Builder, inventoryOffset:flatbuffers.Off
|
||||
static createInventoryVector(builder:flatbuffers.Builder, data:number[]|Uint8Array):flatbuffers.Offset {
|
||||
builder.startVector(1, data.length, 1);
|
||||
for (let i = data.length - 1; i >= 0; i--) {
|
||||
builder.addInt8(data[i]);
|
||||
builder.addInt8(data[i]!);
|
||||
}
|
||||
return builder.endVector();
|
||||
}
|
||||
@@ -713,7 +713,7 @@ static addTestarrayofstring(builder:flatbuffers.Builder, testarrayofstringOffset
|
||||
static createTestarrayofstringVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset {
|
||||
builder.startVector(4, data.length, 4);
|
||||
for (let i = data.length - 1; i >= 0; i--) {
|
||||
builder.addOffset(data[i]);
|
||||
builder.addOffset(data[i]!);
|
||||
}
|
||||
return builder.endVector();
|
||||
}
|
||||
@@ -729,7 +729,7 @@ static addTestarrayoftables(builder:flatbuffers.Builder, testarrayoftablesOffset
|
||||
static createTestarrayoftablesVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset {
|
||||
builder.startVector(4, data.length, 4);
|
||||
for (let i = data.length - 1; i >= 0; i--) {
|
||||
builder.addOffset(data[i]);
|
||||
builder.addOffset(data[i]!);
|
||||
}
|
||||
return builder.endVector();
|
||||
}
|
||||
@@ -749,7 +749,7 @@ static addTestnestedflatbuffer(builder:flatbuffers.Builder, testnestedflatbuffer
|
||||
static createTestnestedflatbufferVector(builder:flatbuffers.Builder, data:number[]|Uint8Array):flatbuffers.Offset {
|
||||
builder.startVector(1, data.length, 1);
|
||||
for (let i = data.length - 1; i >= 0; i--) {
|
||||
builder.addInt8(data[i]);
|
||||
builder.addInt8(data[i]!);
|
||||
}
|
||||
return builder.endVector();
|
||||
}
|
||||
@@ -805,7 +805,7 @@ static addTestarrayofbools(builder:flatbuffers.Builder, testarrayofboolsOffset:f
|
||||
static createTestarrayofboolsVector(builder:flatbuffers.Builder, data:boolean[]):flatbuffers.Offset {
|
||||
builder.startVector(1, data.length, 1);
|
||||
for (let i = data.length - 1; i >= 0; i--) {
|
||||
builder.addInt8(+data[i]);
|
||||
builder.addInt8(+data[i]!);
|
||||
}
|
||||
return builder.endVector();
|
||||
}
|
||||
@@ -833,7 +833,7 @@ static addTestarrayofstring2(builder:flatbuffers.Builder, testarrayofstring2Offs
|
||||
static createTestarrayofstring2Vector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset {
|
||||
builder.startVector(4, data.length, 4);
|
||||
for (let i = data.length - 1; i >= 0; i--) {
|
||||
builder.addOffset(data[i]);
|
||||
builder.addOffset(data[i]!);
|
||||
}
|
||||
return builder.endVector();
|
||||
}
|
||||
@@ -857,7 +857,7 @@ static addFlex(builder:flatbuffers.Builder, flexOffset:flatbuffers.Offset) {
|
||||
static createFlexVector(builder:flatbuffers.Builder, data:number[]|Uint8Array):flatbuffers.Offset {
|
||||
builder.startVector(1, data.length, 1);
|
||||
for (let i = data.length - 1; i >= 0; i--) {
|
||||
builder.addInt8(data[i]);
|
||||
builder.addInt8(data[i]!);
|
||||
}
|
||||
return builder.endVector();
|
||||
}
|
||||
@@ -881,7 +881,7 @@ static addVectorOfLongs(builder:flatbuffers.Builder, vectorOfLongsOffset:flatbuf
|
||||
static createVectorOfLongsVector(builder:flatbuffers.Builder, data:flatbuffers.Long[]):flatbuffers.Offset {
|
||||
builder.startVector(8, data.length, 8);
|
||||
for (let i = data.length - 1; i >= 0; i--) {
|
||||
builder.addInt64(data[i]);
|
||||
builder.addInt64(data[i]!);
|
||||
}
|
||||
return builder.endVector();
|
||||
}
|
||||
@@ -902,7 +902,7 @@ static createVectorOfDoublesVector(builder:flatbuffers.Builder, data:number[]|Ui
|
||||
static createVectorOfDoublesVector(builder:flatbuffers.Builder, data:number[]|Float64Array|Uint8Array):flatbuffers.Offset {
|
||||
builder.startVector(8, data.length, 8);
|
||||
for (let i = data.length - 1; i >= 0; i--) {
|
||||
builder.addFloat64(data[i]);
|
||||
builder.addFloat64(data[i]!);
|
||||
}
|
||||
return builder.endVector();
|
||||
}
|
||||
@@ -922,7 +922,7 @@ static addVectorOfReferrables(builder:flatbuffers.Builder, vectorOfReferrablesOf
|
||||
static createVectorOfReferrablesVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset {
|
||||
builder.startVector(4, data.length, 4);
|
||||
for (let i = data.length - 1; i >= 0; i--) {
|
||||
builder.addOffset(data[i]);
|
||||
builder.addOffset(data[i]!);
|
||||
}
|
||||
return builder.endVector();
|
||||
}
|
||||
@@ -942,7 +942,7 @@ static addVectorOfWeakReferences(builder:flatbuffers.Builder, vectorOfWeakRefere
|
||||
static createVectorOfWeakReferencesVector(builder:flatbuffers.Builder, data:flatbuffers.Long[]):flatbuffers.Offset {
|
||||
builder.startVector(8, data.length, 8);
|
||||
for (let i = data.length - 1; i >= 0; i--) {
|
||||
builder.addInt64(data[i]);
|
||||
builder.addInt64(data[i]!);
|
||||
}
|
||||
return builder.endVector();
|
||||
}
|
||||
@@ -958,7 +958,7 @@ static addVectorOfStrongReferrables(builder:flatbuffers.Builder, vectorOfStrongR
|
||||
static createVectorOfStrongReferrablesVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset {
|
||||
builder.startVector(4, data.length, 4);
|
||||
for (let i = data.length - 1; i >= 0; i--) {
|
||||
builder.addOffset(data[i]);
|
||||
builder.addOffset(data[i]!);
|
||||
}
|
||||
return builder.endVector();
|
||||
}
|
||||
@@ -978,7 +978,7 @@ static addVectorOfCoOwningReferences(builder:flatbuffers.Builder, vectorOfCoOwni
|
||||
static createVectorOfCoOwningReferencesVector(builder:flatbuffers.Builder, data:flatbuffers.Long[]):flatbuffers.Offset {
|
||||
builder.startVector(8, data.length, 8);
|
||||
for (let i = data.length - 1; i >= 0; i--) {
|
||||
builder.addInt64(data[i]);
|
||||
builder.addInt64(data[i]!);
|
||||
}
|
||||
return builder.endVector();
|
||||
}
|
||||
@@ -998,7 +998,7 @@ static addVectorOfNonOwningReferences(builder:flatbuffers.Builder, vectorOfNonOw
|
||||
static createVectorOfNonOwningReferencesVector(builder:flatbuffers.Builder, data:flatbuffers.Long[]):flatbuffers.Offset {
|
||||
builder.startVector(8, data.length, 8);
|
||||
for (let i = data.length - 1; i >= 0; i--) {
|
||||
builder.addInt64(data[i]);
|
||||
builder.addInt64(data[i]!);
|
||||
}
|
||||
return builder.endVector();
|
||||
}
|
||||
@@ -1030,7 +1030,7 @@ static addVectorOfEnums(builder:flatbuffers.Builder, vectorOfEnumsOffset:flatbuf
|
||||
static createVectorOfEnumsVector(builder:flatbuffers.Builder, data:Color[]):flatbuffers.Offset {
|
||||
builder.startVector(1, data.length, 1);
|
||||
for (let i = data.length - 1; i >= 0; i--) {
|
||||
builder.addInt8(data[i]);
|
||||
builder.addInt8(data[i]!);
|
||||
}
|
||||
return builder.endVector();
|
||||
}
|
||||
@@ -1050,7 +1050,7 @@ static addTestrequirednestedflatbuffer(builder:flatbuffers.Builder, testrequired
|
||||
static createTestrequirednestedflatbufferVector(builder:flatbuffers.Builder, data:number[]|Uint8Array):flatbuffers.Offset {
|
||||
builder.startVector(1, data.length, 1);
|
||||
for (let i = data.length - 1; i >= 0; i--) {
|
||||
builder.addInt8(data[i]);
|
||||
builder.addInt8(data[i]!);
|
||||
}
|
||||
return builder.endVector();
|
||||
}
|
||||
@@ -1066,7 +1066,7 @@ static addScalarKeySortedTables(builder:flatbuffers.Builder, scalarKeySortedTabl
|
||||
static createScalarKeySortedTablesVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset {
|
||||
builder.startVector(4, data.length, 4);
|
||||
for (let i = data.length - 1; i >= 0; i--) {
|
||||
builder.addOffset(data[i]);
|
||||
builder.addOffset(data[i]!);
|
||||
}
|
||||
return builder.endVector();
|
||||
}
|
||||
|
||||
@@ -272,7 +272,7 @@ static createV8Vector(builder:flatbuffers.Builder, data:number[]|Uint8Array):fla
|
||||
static createV8Vector(builder:flatbuffers.Builder, data:number[]|Int8Array|Uint8Array):flatbuffers.Offset {
|
||||
builder.startVector(1, data.length, 1);
|
||||
for (let i = data.length - 1; i >= 0; i--) {
|
||||
builder.addInt8(data[i]);
|
||||
builder.addInt8(data[i]!);
|
||||
}
|
||||
return builder.endVector();
|
||||
}
|
||||
@@ -293,7 +293,7 @@ static createVf64Vector(builder:flatbuffers.Builder, data:number[]|Uint8Array):f
|
||||
static createVf64Vector(builder:flatbuffers.Builder, data:number[]|Float64Array|Uint8Array):flatbuffers.Offset {
|
||||
builder.startVector(8, data.length, 8);
|
||||
for (let i = data.length - 1; i >= 0; i--) {
|
||||
builder.addFloat64(data[i]);
|
||||
builder.addFloat64(data[i]!);
|
||||
}
|
||||
return builder.endVector();
|
||||
}
|
||||
|
||||
87
tests/union_vector/attacker.ts
Normal file
87
tests/union_vector/attacker.ts
Normal file
@@ -0,0 +1,87 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
import * as flatbuffers from 'flatbuffers';
|
||||
|
||||
|
||||
|
||||
export class Attacker {
|
||||
bb: flatbuffers.ByteBuffer|null = null;
|
||||
bb_pos = 0;
|
||||
__init(i:number, bb:flatbuffers.ByteBuffer):Attacker {
|
||||
this.bb_pos = i;
|
||||
this.bb = bb;
|
||||
return this;
|
||||
}
|
||||
|
||||
static getRootAsAttacker(bb:flatbuffers.ByteBuffer, obj?:Attacker):Attacker {
|
||||
return (obj || new Attacker()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
|
||||
}
|
||||
|
||||
static getSizePrefixedRootAsAttacker(bb:flatbuffers.ByteBuffer, obj?:Attacker):Attacker {
|
||||
bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
|
||||
return (obj || new Attacker()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
|
||||
}
|
||||
|
||||
swordAttackDamage():number {
|
||||
const offset = this.bb!.__offset(this.bb_pos, 4);
|
||||
return offset ? this.bb!.readInt32(this.bb_pos + offset) : 0;
|
||||
}
|
||||
|
||||
mutate_sword_attack_damage(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;
|
||||
}
|
||||
|
||||
static getFullyQualifiedName():string {
|
||||
return 'Attacker';
|
||||
}
|
||||
|
||||
static startAttacker(builder:flatbuffers.Builder) {
|
||||
builder.startObject(1);
|
||||
}
|
||||
|
||||
static addSwordAttackDamage(builder:flatbuffers.Builder, swordAttackDamage:number) {
|
||||
builder.addFieldInt32(0, swordAttackDamage, 0);
|
||||
}
|
||||
|
||||
static endAttacker(builder:flatbuffers.Builder):flatbuffers.Offset {
|
||||
const offset = builder.endObject();
|
||||
return offset;
|
||||
}
|
||||
|
||||
static createAttacker(builder:flatbuffers.Builder, swordAttackDamage:number):flatbuffers.Offset {
|
||||
Attacker.startAttacker(builder);
|
||||
Attacker.addSwordAttackDamage(builder, swordAttackDamage);
|
||||
return Attacker.endAttacker(builder);
|
||||
}
|
||||
|
||||
unpack(): AttackerT {
|
||||
return new AttackerT(
|
||||
this.swordAttackDamage()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
unpackTo(_o: AttackerT): void {
|
||||
_o.swordAttackDamage = this.swordAttackDamage();
|
||||
}
|
||||
}
|
||||
|
||||
export class AttackerT {
|
||||
constructor(
|
||||
public swordAttackDamage: number = 0
|
||||
){}
|
||||
|
||||
|
||||
pack(builder:flatbuffers.Builder): flatbuffers.Offset {
|
||||
return Attacker.createAttacker(builder,
|
||||
this.swordAttackDamage
|
||||
);
|
||||
}
|
||||
}
|
||||
63
tests/union_vector/book-reader.ts
Normal file
63
tests/union_vector/book-reader.ts
Normal file
@@ -0,0 +1,63 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
import * as flatbuffers from 'flatbuffers';
|
||||
|
||||
|
||||
|
||||
export class BookReader {
|
||||
bb: flatbuffers.ByteBuffer|null = null;
|
||||
bb_pos = 0;
|
||||
__init(i:number, bb:flatbuffers.ByteBuffer):BookReader {
|
||||
this.bb_pos = i;
|
||||
this.bb = bb;
|
||||
return this;
|
||||
}
|
||||
|
||||
booksRead():number {
|
||||
return this.bb!.readInt32(this.bb_pos);
|
||||
}
|
||||
|
||||
mutate_books_read(value:number):boolean {
|
||||
this.bb!.writeInt32(this.bb_pos + 0, value);
|
||||
return true;
|
||||
}
|
||||
|
||||
static getFullyQualifiedName():string {
|
||||
return 'BookReader';
|
||||
}
|
||||
|
||||
static sizeOf():number {
|
||||
return 4;
|
||||
}
|
||||
|
||||
static createBookReader(builder:flatbuffers.Builder, books_read: number):flatbuffers.Offset {
|
||||
builder.prep(4, 4);
|
||||
builder.writeInt32(books_read);
|
||||
return builder.offset();
|
||||
}
|
||||
|
||||
|
||||
unpack(): BookReaderT {
|
||||
return new BookReaderT(
|
||||
this.booksRead()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
unpackTo(_o: BookReaderT): void {
|
||||
_o.booksRead = this.booksRead();
|
||||
}
|
||||
}
|
||||
|
||||
export class BookReaderT {
|
||||
constructor(
|
||||
public booksRead: number = 0
|
||||
){}
|
||||
|
||||
|
||||
pack(builder:flatbuffers.Builder): flatbuffers.Offset {
|
||||
return BookReader.createBookReader(builder,
|
||||
this.booksRead
|
||||
);
|
||||
}
|
||||
}
|
||||
50
tests/union_vector/character.ts
Normal file
50
tests/union_vector/character.ts
Normal file
@@ -0,0 +1,50 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
import { Attacker, AttackerT } from './attacker';
|
||||
import { BookReader, BookReaderT } from './book-reader';
|
||||
import { Rapunzel, RapunzelT } from './rapunzel';
|
||||
|
||||
|
||||
export enum Character{
|
||||
NONE = 0,
|
||||
MuLan = 1,
|
||||
Rapunzel = 2,
|
||||
Belle = 3,
|
||||
BookFan = 4,
|
||||
Other = 5,
|
||||
Unused = 6
|
||||
}
|
||||
|
||||
export function unionToCharacter(
|
||||
type: Character,
|
||||
accessor: (obj:Attacker|BookReader|Rapunzel|string) => Attacker|BookReader|Rapunzel|string|null
|
||||
): Attacker|BookReader|Rapunzel|string|null {
|
||||
switch(Character[type]) {
|
||||
case 'NONE': return null;
|
||||
case 'MuLan': return accessor(new Attacker())! as Attacker;
|
||||
case 'Rapunzel': return accessor(new Rapunzel())! as Rapunzel;
|
||||
case 'Belle': return accessor(new BookReader())! as BookReader;
|
||||
case 'BookFan': return accessor(new BookReader())! as BookReader;
|
||||
case 'Other': return accessor('') as string;
|
||||
case 'Unused': return accessor('') as string;
|
||||
default: return null;
|
||||
}
|
||||
}
|
||||
|
||||
export function unionListToCharacter(
|
||||
type: Character,
|
||||
accessor: (index: number, obj:Attacker|BookReader|Rapunzel|string) => Attacker|BookReader|Rapunzel|string|null,
|
||||
index: number
|
||||
): Attacker|BookReader|Rapunzel|string|null {
|
||||
switch(Character[type]) {
|
||||
case 'NONE': return null;
|
||||
case 'MuLan': return accessor(index, new Attacker())! as Attacker;
|
||||
case 'Rapunzel': return accessor(index, new Rapunzel())! as Rapunzel;
|
||||
case 'Belle': return accessor(index, new BookReader())! as BookReader;
|
||||
case 'BookFan': return accessor(index, new BookReader())! as BookReader;
|
||||
case 'Other': return accessor(index, '') as string;
|
||||
case 'Unused': return accessor(index, '') as string;
|
||||
default: return null;
|
||||
}
|
||||
}
|
||||
|
||||
211
tests/union_vector/movie.ts
Normal file
211
tests/union_vector/movie.ts
Normal file
@@ -0,0 +1,211 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
import * as flatbuffers from 'flatbuffers';
|
||||
|
||||
import { Attacker, AttackerT } from './attacker';
|
||||
import { BookReader, BookReaderT } from './book-reader';
|
||||
import { Character, unionToCharacter, unionListToCharacter } from './character';
|
||||
import { Rapunzel, RapunzelT } from './rapunzel';
|
||||
|
||||
|
||||
export class Movie {
|
||||
bb: flatbuffers.ByteBuffer|null = null;
|
||||
bb_pos = 0;
|
||||
__init(i:number, bb:flatbuffers.ByteBuffer):Movie {
|
||||
this.bb_pos = i;
|
||||
this.bb = bb;
|
||||
return this;
|
||||
}
|
||||
|
||||
static getRootAsMovie(bb:flatbuffers.ByteBuffer, obj?:Movie):Movie {
|
||||
return (obj || new Movie()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
|
||||
}
|
||||
|
||||
static getSizePrefixedRootAsMovie(bb:flatbuffers.ByteBuffer, obj?:Movie):Movie {
|
||||
bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
|
||||
return (obj || new Movie()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
|
||||
}
|
||||
|
||||
static bufferHasIdentifier(bb:flatbuffers.ByteBuffer):boolean {
|
||||
return bb.__has_identifier('MOVI');
|
||||
}
|
||||
|
||||
mainCharacterType():Character {
|
||||
const offset = this.bb!.__offset(this.bb_pos, 4);
|
||||
return offset ? this.bb!.readUint8(this.bb_pos + offset) : Character.NONE;
|
||||
}
|
||||
|
||||
mainCharacter<T extends flatbuffers.Table>(obj:any|string):any|string|null {
|
||||
const offset = this.bb!.__offset(this.bb_pos, 6);
|
||||
return offset ? this.bb!.__union_with_string(obj, this.bb_pos + offset) : null;
|
||||
}
|
||||
|
||||
charactersType(index: number):Character|null {
|
||||
const offset = this.bb!.__offset(this.bb_pos, 8);
|
||||
return offset ? this.bb!.readUint8(this.bb!.__vector(this.bb_pos + offset) + index) : 0;
|
||||
}
|
||||
|
||||
charactersTypeLength():number {
|
||||
const offset = this.bb!.__offset(this.bb_pos, 8);
|
||||
return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
|
||||
}
|
||||
|
||||
charactersTypeArray():Uint8Array|null {
|
||||
const offset = this.bb!.__offset(this.bb_pos, 8);
|
||||
return offset ? new Uint8Array(this.bb!.bytes().buffer, this.bb!.bytes().byteOffset + this.bb!.__vector(this.bb_pos + offset), this.bb!.__vector_len(this.bb_pos + offset)) : null;
|
||||
}
|
||||
|
||||
characters(index: number, obj:any|string):any|string|null {
|
||||
const offset = this.bb!.__offset(this.bb_pos, 10);
|
||||
return offset ? this.bb!.__union_with_string(obj, this.bb!.__vector(this.bb_pos + offset) + index * 4) : null;
|
||||
}
|
||||
|
||||
charactersLength():number {
|
||||
const offset = this.bb!.__offset(this.bb_pos, 10);
|
||||
return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
|
||||
}
|
||||
|
||||
static getFullyQualifiedName():string {
|
||||
return 'Movie';
|
||||
}
|
||||
|
||||
static startMovie(builder:flatbuffers.Builder) {
|
||||
builder.startObject(4);
|
||||
}
|
||||
|
||||
static addMainCharacterType(builder:flatbuffers.Builder, mainCharacterType:Character) {
|
||||
builder.addFieldInt8(0, mainCharacterType, Character.NONE);
|
||||
}
|
||||
|
||||
static addMainCharacter(builder:flatbuffers.Builder, mainCharacterOffset:flatbuffers.Offset) {
|
||||
builder.addFieldOffset(1, mainCharacterOffset, 0);
|
||||
}
|
||||
|
||||
static addCharactersType(builder:flatbuffers.Builder, charactersTypeOffset:flatbuffers.Offset) {
|
||||
builder.addFieldOffset(2, charactersTypeOffset, 0);
|
||||
}
|
||||
|
||||
static createCharactersTypeVector(builder:flatbuffers.Builder, data:Character[]):flatbuffers.Offset {
|
||||
builder.startVector(1, data.length, 1);
|
||||
for (let i = data.length - 1; i >= 0; i--) {
|
||||
builder.addInt8(data[i]!);
|
||||
}
|
||||
return builder.endVector();
|
||||
}
|
||||
|
||||
static startCharactersTypeVector(builder:flatbuffers.Builder, numElems:number) {
|
||||
builder.startVector(1, numElems, 1);
|
||||
}
|
||||
|
||||
static addCharacters(builder:flatbuffers.Builder, charactersOffset:flatbuffers.Offset) {
|
||||
builder.addFieldOffset(3, charactersOffset, 0);
|
||||
}
|
||||
|
||||
static createCharactersVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset {
|
||||
builder.startVector(4, data.length, 4);
|
||||
for (let i = data.length - 1; i >= 0; i--) {
|
||||
builder.addOffset(data[i]!);
|
||||
}
|
||||
return builder.endVector();
|
||||
}
|
||||
|
||||
static startCharactersVector(builder:flatbuffers.Builder, numElems:number) {
|
||||
builder.startVector(4, numElems, 4);
|
||||
}
|
||||
|
||||
static endMovie(builder:flatbuffers.Builder):flatbuffers.Offset {
|
||||
const offset = builder.endObject();
|
||||
return offset;
|
||||
}
|
||||
|
||||
static finishMovieBuffer(builder:flatbuffers.Builder, offset:flatbuffers.Offset) {
|
||||
builder.finish(offset, 'MOVI');
|
||||
}
|
||||
|
||||
static finishSizePrefixedMovieBuffer(builder:flatbuffers.Builder, offset:flatbuffers.Offset) {
|
||||
builder.finish(offset, 'MOVI', true);
|
||||
}
|
||||
|
||||
static createMovie(builder:flatbuffers.Builder, mainCharacterType:Character, mainCharacterOffset:flatbuffers.Offset, charactersTypeOffset:flatbuffers.Offset, charactersOffset:flatbuffers.Offset):flatbuffers.Offset {
|
||||
Movie.startMovie(builder);
|
||||
Movie.addMainCharacterType(builder, mainCharacterType);
|
||||
Movie.addMainCharacter(builder, mainCharacterOffset);
|
||||
Movie.addCharactersType(builder, charactersTypeOffset);
|
||||
Movie.addCharacters(builder, charactersOffset);
|
||||
return Movie.endMovie(builder);
|
||||
}
|
||||
|
||||
unpack(): MovieT {
|
||||
return new MovieT(
|
||||
this.mainCharacterType(),
|
||||
(() => {
|
||||
let temp = unionToCharacter(this.mainCharacterType(), this.mainCharacter.bind(this));
|
||||
if(temp === null) { return null; }
|
||||
if(typeof temp === 'string') { return temp; }
|
||||
return temp.unpack()
|
||||
})(),
|
||||
this.bb!.createScalarList(this.charactersType.bind(this), this.charactersTypeLength()),
|
||||
(() => {
|
||||
let ret = [];
|
||||
for(let targetEnumIndex = 0; targetEnumIndex < this.charactersTypeLength(); ++targetEnumIndex) {
|
||||
let targetEnum = this.charactersType(targetEnumIndex);
|
||||
if(targetEnum === null || Character[targetEnum!] === 'NONE') { continue; }
|
||||
|
||||
let temp = unionListToCharacter(targetEnum, this.characters.bind(this), targetEnumIndex);
|
||||
if(temp === null) { continue; }
|
||||
if(typeof temp === 'string') { ret.push(temp); continue; }
|
||||
ret.push(temp.unpack());
|
||||
}
|
||||
return ret;
|
||||
})()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
unpackTo(_o: MovieT): void {
|
||||
_o.mainCharacterType = this.mainCharacterType();
|
||||
_o.mainCharacter = (() => {
|
||||
let temp = unionToCharacter(this.mainCharacterType(), this.mainCharacter.bind(this));
|
||||
if(temp === null) { return null; }
|
||||
if(typeof temp === 'string') { return temp; }
|
||||
return temp.unpack()
|
||||
})();
|
||||
_o.charactersType = this.bb!.createScalarList(this.charactersType.bind(this), this.charactersTypeLength());
|
||||
_o.characters = (() => {
|
||||
let ret = [];
|
||||
for(let targetEnumIndex = 0; targetEnumIndex < this.charactersTypeLength(); ++targetEnumIndex) {
|
||||
let targetEnum = this.charactersType(targetEnumIndex);
|
||||
if(targetEnum === null || Character[targetEnum!] === 'NONE') { continue; }
|
||||
|
||||
let temp = unionListToCharacter(targetEnum, this.characters.bind(this), targetEnumIndex);
|
||||
if(temp === null) { continue; }
|
||||
if(typeof temp === 'string') { ret.push(temp); continue; }
|
||||
ret.push(temp.unpack());
|
||||
}
|
||||
return ret;
|
||||
})();
|
||||
}
|
||||
}
|
||||
|
||||
export class MovieT {
|
||||
constructor(
|
||||
public mainCharacterType: Character = Character.NONE,
|
||||
public mainCharacter: AttackerT|BookReaderT|RapunzelT|string|null = null,
|
||||
public charactersType: (Character)[] = [],
|
||||
public characters: (AttackerT|BookReaderT|RapunzelT|string)[] = []
|
||||
){}
|
||||
|
||||
|
||||
pack(builder:flatbuffers.Builder): flatbuffers.Offset {
|
||||
const mainCharacter = builder.createObjectOffset(this.mainCharacter);
|
||||
const charactersType = Movie.createCharactersTypeVector(builder, this.charactersType);
|
||||
const characters = Movie.createCharactersVector(builder, builder.createObjectOffsetList(this.characters));
|
||||
|
||||
return Movie.createMovie(builder,
|
||||
this.mainCharacterType,
|
||||
mainCharacter,
|
||||
charactersType,
|
||||
characters
|
||||
);
|
||||
}
|
||||
}
|
||||
63
tests/union_vector/rapunzel.ts
Normal file
63
tests/union_vector/rapunzel.ts
Normal file
@@ -0,0 +1,63 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
import * as flatbuffers from 'flatbuffers';
|
||||
|
||||
|
||||
|
||||
export class Rapunzel {
|
||||
bb: flatbuffers.ByteBuffer|null = null;
|
||||
bb_pos = 0;
|
||||
__init(i:number, bb:flatbuffers.ByteBuffer):Rapunzel {
|
||||
this.bb_pos = i;
|
||||
this.bb = bb;
|
||||
return this;
|
||||
}
|
||||
|
||||
hairLength():number {
|
||||
return this.bb!.readInt32(this.bb_pos);
|
||||
}
|
||||
|
||||
mutate_hair_length(value:number):boolean {
|
||||
this.bb!.writeInt32(this.bb_pos + 0, value);
|
||||
return true;
|
||||
}
|
||||
|
||||
static getFullyQualifiedName():string {
|
||||
return 'Rapunzel';
|
||||
}
|
||||
|
||||
static sizeOf():number {
|
||||
return 4;
|
||||
}
|
||||
|
||||
static createRapunzel(builder:flatbuffers.Builder, hair_length: number):flatbuffers.Offset {
|
||||
builder.prep(4, 4);
|
||||
builder.writeInt32(hair_length);
|
||||
return builder.offset();
|
||||
}
|
||||
|
||||
|
||||
unpack(): RapunzelT {
|
||||
return new RapunzelT(
|
||||
this.hairLength()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
unpackTo(_o: RapunzelT): void {
|
||||
_o.hairLength = this.hairLength();
|
||||
}
|
||||
}
|
||||
|
||||
export class RapunzelT {
|
||||
constructor(
|
||||
public hairLength: number = 0
|
||||
){}
|
||||
|
||||
|
||||
pack(builder:flatbuffers.Builder): flatbuffers.Offset {
|
||||
return Rapunzel.createRapunzel(builder,
|
||||
this.hairLength
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user