mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-22 23:18:51 +00:00
bulk code format fix (#8707)
This commit is contained in:
34
tests/ts/union-underlying-type/a.d.ts
vendored
34
tests/ts/union-underlying-type/a.d.ts
vendored
@@ -1,22 +1,22 @@
|
||||
import * as flatbuffers from 'flatbuffers';
|
||||
export declare class A implements flatbuffers.IUnpackableObject<AT> {
|
||||
bb: flatbuffers.ByteBuffer | null;
|
||||
bb_pos: number;
|
||||
__init(i: number, bb: flatbuffers.ByteBuffer): A;
|
||||
static getRootAsA(bb: flatbuffers.ByteBuffer, obj?: A): A;
|
||||
static getSizePrefixedRootAsA(bb: flatbuffers.ByteBuffer, obj?: A): A;
|
||||
a(): number;
|
||||
mutate_a(value: number): boolean;
|
||||
static getFullyQualifiedName(): string;
|
||||
static startA(builder: flatbuffers.Builder): void;
|
||||
static addA(builder: flatbuffers.Builder, a: number): void;
|
||||
static endA(builder: flatbuffers.Builder): flatbuffers.Offset;
|
||||
static createA(builder: flatbuffers.Builder, a: number): flatbuffers.Offset;
|
||||
unpack(): AT;
|
||||
unpackTo(_o: AT): void;
|
||||
bb: flatbuffers.ByteBuffer | null;
|
||||
bb_pos: number;
|
||||
__init(i: number, bb: flatbuffers.ByteBuffer): A;
|
||||
static getRootAsA(bb: flatbuffers.ByteBuffer, obj?: A): A;
|
||||
static getSizePrefixedRootAsA(bb: flatbuffers.ByteBuffer, obj?: A): A;
|
||||
a(): number;
|
||||
mutate_a(value: number): boolean;
|
||||
static getFullyQualifiedName(): string;
|
||||
static startA(builder: flatbuffers.Builder): void;
|
||||
static addA(builder: flatbuffers.Builder, a: number): void;
|
||||
static endA(builder: flatbuffers.Builder): flatbuffers.Offset;
|
||||
static createA(builder: flatbuffers.Builder, a: number): flatbuffers.Offset;
|
||||
unpack(): AT;
|
||||
unpackTo(_o: AT): void;
|
||||
}
|
||||
export declare class AT implements flatbuffers.IGeneratedObject {
|
||||
a: number;
|
||||
constructor(a?: number);
|
||||
pack(builder: flatbuffers.Builder): flatbuffers.Offset;
|
||||
a: number;
|
||||
constructor(a?: number);
|
||||
pack(builder: flatbuffers.Builder): flatbuffers.Offset;
|
||||
}
|
||||
|
||||
@@ -1,65 +1,68 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */
|
||||
/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any,
|
||||
* @typescript-eslint/no-non-null-assertion */
|
||||
import * as flatbuffers from 'flatbuffers';
|
||||
export class A {
|
||||
constructor() {
|
||||
this.bb = null;
|
||||
this.bb_pos = 0;
|
||||
}
|
||||
__init(i, bb) {
|
||||
this.bb_pos = i;
|
||||
this.bb = bb;
|
||||
return this;
|
||||
}
|
||||
static getRootAsA(bb, obj) {
|
||||
return (obj || new A()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
|
||||
}
|
||||
static getSizePrefixedRootAsA(bb, obj) {
|
||||
bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
|
||||
return (obj || new A()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
|
||||
}
|
||||
a() {
|
||||
const offset = this.bb.__offset(this.bb_pos, 4);
|
||||
return offset ? this.bb.readInt32(this.bb_pos + offset) : 0;
|
||||
}
|
||||
mutate_a(value) {
|
||||
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() {
|
||||
return 'UnionUnderlyingType.A';
|
||||
}
|
||||
static startA(builder) {
|
||||
builder.startObject(1);
|
||||
}
|
||||
static addA(builder, a) {
|
||||
builder.addFieldInt32(0, a, 0);
|
||||
}
|
||||
static endA(builder) {
|
||||
const offset = builder.endObject();
|
||||
return offset;
|
||||
}
|
||||
static createA(builder, a) {
|
||||
A.startA(builder);
|
||||
A.addA(builder, a);
|
||||
return A.endA(builder);
|
||||
}
|
||||
unpack() {
|
||||
return new AT(this.a());
|
||||
}
|
||||
unpackTo(_o) {
|
||||
_o.a = this.a();
|
||||
constructor() {
|
||||
this.bb = null;
|
||||
this.bb_pos = 0;
|
||||
}
|
||||
__init(i, bb) {
|
||||
this.bb_pos = i;
|
||||
this.bb = bb;
|
||||
return this;
|
||||
}
|
||||
static getRootAsA(bb, obj) {
|
||||
return (obj || new A())
|
||||
.__init(bb.readInt32(bb.position()) + bb.position(), bb);
|
||||
}
|
||||
static getSizePrefixedRootAsA(bb, obj) {
|
||||
bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
|
||||
return (obj || new A())
|
||||
.__init(bb.readInt32(bb.position()) + bb.position(), bb);
|
||||
}
|
||||
a() {
|
||||
const offset = this.bb.__offset(this.bb_pos, 4);
|
||||
return offset ? this.bb.readInt32(this.bb_pos + offset) : 0;
|
||||
}
|
||||
mutate_a(value) {
|
||||
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() {
|
||||
return 'UnionUnderlyingType.A';
|
||||
}
|
||||
static startA(builder) {
|
||||
builder.startObject(1);
|
||||
}
|
||||
static addA(builder, a) {
|
||||
builder.addFieldInt32(0, a, 0);
|
||||
}
|
||||
static endA(builder) {
|
||||
const offset = builder.endObject();
|
||||
return offset;
|
||||
}
|
||||
static createA(builder, a) {
|
||||
A.startA(builder);
|
||||
A.addA(builder, a);
|
||||
return A.endA(builder);
|
||||
}
|
||||
unpack() {
|
||||
return new AT(this.a());
|
||||
}
|
||||
unpackTo(_o) {
|
||||
_o.a = this.a();
|
||||
}
|
||||
}
|
||||
export class AT {
|
||||
constructor(a = 0) {
|
||||
this.a = a;
|
||||
}
|
||||
pack(builder) {
|
||||
return A.createA(builder, this.a);
|
||||
}
|
||||
constructor(a = 0) {
|
||||
this.a = a;
|
||||
}
|
||||
pack(builder) {
|
||||
return A.createA(builder, this.a);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,86 +4,82 @@
|
||||
|
||||
import * as flatbuffers from 'flatbuffers';
|
||||
|
||||
|
||||
|
||||
export class A implements flatbuffers.IUnpackableObject<AT> {
|
||||
bb: flatbuffers.ByteBuffer|null = null;
|
||||
bb: flatbuffers.ByteBuffer | null = null;
|
||||
bb_pos = 0;
|
||||
__init(i:number, bb:flatbuffers.ByteBuffer):A {
|
||||
this.bb_pos = i;
|
||||
this.bb = bb;
|
||||
return this;
|
||||
}
|
||||
|
||||
static getRootAsA(bb:flatbuffers.ByteBuffer, obj?:A):A {
|
||||
return (obj || new A()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
|
||||
}
|
||||
|
||||
static getSizePrefixedRootAsA(bb:flatbuffers.ByteBuffer, obj?:A):A {
|
||||
bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
|
||||
return (obj || new A()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
|
||||
}
|
||||
|
||||
a():number {
|
||||
const offset = this.bb!.__offset(this.bb_pos, 4);
|
||||
return offset ? this.bb!.readInt32(this.bb_pos + offset) : 0;
|
||||
}
|
||||
|
||||
mutate_a(value:number):boolean {
|
||||
const offset = this.bb!.__offset(this.bb_pos, 4);
|
||||
|
||||
if (offset === 0) {
|
||||
return false;
|
||||
__init(i: number, bb: flatbuffers.ByteBuffer): A {
|
||||
this.bb_pos = i;
|
||||
this.bb = bb;
|
||||
return this;
|
||||
}
|
||||
|
||||
this.bb!.writeInt32(this.bb_pos + offset, value);
|
||||
return true;
|
||||
}
|
||||
static getRootAsA(bb: flatbuffers.ByteBuffer, obj?: A): A {
|
||||
return (obj || new A()).__init(
|
||||
bb.readInt32(bb.position()) + bb.position(),
|
||||
bb,
|
||||
);
|
||||
}
|
||||
|
||||
static getFullyQualifiedName():string {
|
||||
return 'UnionUnderlyingType.A';
|
||||
}
|
||||
static getSizePrefixedRootAsA(bb: flatbuffers.ByteBuffer, obj?: A): A {
|
||||
bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
|
||||
return (obj || new A()).__init(
|
||||
bb.readInt32(bb.position()) + bb.position(),
|
||||
bb,
|
||||
);
|
||||
}
|
||||
|
||||
static startA(builder:flatbuffers.Builder) {
|
||||
builder.startObject(1);
|
||||
}
|
||||
a(): number {
|
||||
const offset = this.bb!.__offset(this.bb_pos, 4);
|
||||
return offset ? this.bb!.readInt32(this.bb_pos + offset) : 0;
|
||||
}
|
||||
|
||||
static addA(builder:flatbuffers.Builder, a:number) {
|
||||
builder.addFieldInt32(0, a, 0);
|
||||
}
|
||||
mutate_a(value: number): boolean {
|
||||
const offset = this.bb!.__offset(this.bb_pos, 4);
|
||||
|
||||
static endA(builder:flatbuffers.Builder):flatbuffers.Offset {
|
||||
const offset = builder.endObject();
|
||||
return offset;
|
||||
}
|
||||
if (offset === 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
static createA(builder:flatbuffers.Builder, a:number):flatbuffers.Offset {
|
||||
A.startA(builder);
|
||||
A.addA(builder, a);
|
||||
return A.endA(builder);
|
||||
}
|
||||
this.bb!.writeInt32(this.bb_pos + offset, value);
|
||||
return true;
|
||||
}
|
||||
|
||||
unpack(): AT {
|
||||
return new AT(
|
||||
this.a()
|
||||
);
|
||||
}
|
||||
static getFullyQualifiedName(): string {
|
||||
return 'UnionUnderlyingType.A';
|
||||
}
|
||||
|
||||
static startA(builder: flatbuffers.Builder) {
|
||||
builder.startObject(1);
|
||||
}
|
||||
|
||||
unpackTo(_o: AT): void {
|
||||
_o.a = this.a();
|
||||
}
|
||||
static addA(builder: flatbuffers.Builder, a: number) {
|
||||
builder.addFieldInt32(0, a, 0);
|
||||
}
|
||||
|
||||
static endA(builder: flatbuffers.Builder): flatbuffers.Offset {
|
||||
const offset = builder.endObject();
|
||||
return offset;
|
||||
}
|
||||
|
||||
static createA(builder: flatbuffers.Builder, a: number): flatbuffers.Offset {
|
||||
A.startA(builder);
|
||||
A.addA(builder, a);
|
||||
return A.endA(builder);
|
||||
}
|
||||
|
||||
unpack(): AT {
|
||||
return new AT(this.a());
|
||||
}
|
||||
|
||||
unpackTo(_o: AT): void {
|
||||
_o.a = this.a();
|
||||
}
|
||||
}
|
||||
|
||||
export class AT implements flatbuffers.IGeneratedObject {
|
||||
constructor(
|
||||
public a: number = 0
|
||||
){}
|
||||
constructor(public a: number = 0) {}
|
||||
|
||||
|
||||
pack(builder:flatbuffers.Builder): flatbuffers.Offset {
|
||||
return A.createA(builder,
|
||||
this.a
|
||||
);
|
||||
}
|
||||
pack(builder: flatbuffers.Builder): flatbuffers.Offset {
|
||||
return A.createA(builder, this.a);
|
||||
}
|
||||
}
|
||||
|
||||
25
tests/ts/union-underlying-type/abc.d.ts
vendored
25
tests/ts/union-underlying-type/abc.d.ts
vendored
@@ -1,11 +1,18 @@
|
||||
import { A } from '../union-underlying-type/a.js';
|
||||
import { B } from '../union-underlying-type/b.js';
|
||||
import { C } from '../union-underlying-type/c.js';
|
||||
import {A} from '../union-underlying-type/a.js';
|
||||
import {B} from '../union-underlying-type/b.js';
|
||||
import {C} from '../union-underlying-type/c.js';
|
||||
export declare enum ABC {
|
||||
NONE = 0,
|
||||
A = 555,
|
||||
B = 666,
|
||||
C = 777
|
||||
NONE = 0,
|
||||
A = 555,
|
||||
B = 666,
|
||||
C = 777,
|
||||
}
|
||||
export declare function unionToAbc(type: ABC, accessor: (obj: A | B | C) => A | B | C | null): A | B | C | null;
|
||||
export declare function unionListToAbc(type: ABC, accessor: (index: number, obj: A | B | C) => A | B | C | null, index: number): A | B | C | null;
|
||||
export declare function unionToAbc(
|
||||
type: ABC,
|
||||
accessor: (obj: A | B | C) => A | B | C | null,
|
||||
): A | B | C | null;
|
||||
export declare function unionListToAbc(
|
||||
type: ABC,
|
||||
accessor: (index: number, obj: A | B | C) => A | B | C | null,
|
||||
index: number,
|
||||
): A | B | C | null;
|
||||
|
||||
@@ -1,30 +1,41 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */
|
||||
import { A } from '../union-underlying-type/a.js';
|
||||
import { B } from '../union-underlying-type/b.js';
|
||||
import { C } from '../union-underlying-type/c.js';
|
||||
/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any,
|
||||
* @typescript-eslint/no-non-null-assertion */
|
||||
import {A} from '../union-underlying-type/a.js';
|
||||
import {B} from '../union-underlying-type/b.js';
|
||||
import {C} from '../union-underlying-type/c.js';
|
||||
export var ABC;
|
||||
(function (ABC) {
|
||||
ABC[ABC["NONE"] = 0] = "NONE";
|
||||
ABC[ABC["A"] = 555] = "A";
|
||||
ABC[ABC["B"] = 666] = "B";
|
||||
ABC[ABC["C"] = 777] = "C";
|
||||
(function(ABC) {
|
||||
ABC[ABC['NONE'] = 0] = 'NONE';
|
||||
ABC[ABC['A'] = 555] = 'A';
|
||||
ABC[ABC['B'] = 666] = 'B';
|
||||
ABC[ABC['C'] = 777] = 'C';
|
||||
})(ABC || (ABC = {}));
|
||||
export function unionToAbc(type, accessor) {
|
||||
switch (ABC[type]) {
|
||||
case 'NONE': return null;
|
||||
case 'A': return accessor(new A());
|
||||
case 'B': return accessor(new B());
|
||||
case 'C': return accessor(new C());
|
||||
default: return null;
|
||||
}
|
||||
switch (ABC[type]) {
|
||||
case 'NONE':
|
||||
return null;
|
||||
case 'A':
|
||||
return accessor(new A());
|
||||
case 'B':
|
||||
return accessor(new B());
|
||||
case 'C':
|
||||
return accessor(new C());
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
export function unionListToAbc(type, accessor, index) {
|
||||
switch (ABC[type]) {
|
||||
case 'NONE': return null;
|
||||
case 'A': return accessor(index, new A());
|
||||
case 'B': return accessor(index, new B());
|
||||
case 'C': return accessor(index, new C());
|
||||
default: return null;
|
||||
}
|
||||
switch (ABC[type]) {
|
||||
case 'NONE':
|
||||
return null;
|
||||
case 'A':
|
||||
return accessor(index, new A());
|
||||
case 'B':
|
||||
return accessor(index, new B());
|
||||
case 'C':
|
||||
return accessor(index, new C());
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,41 +2,50 @@
|
||||
|
||||
/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */
|
||||
|
||||
import { A, AT } from '../union-underlying-type/a.js';
|
||||
import { B, BT } from '../union-underlying-type/b.js';
|
||||
import { C, CT } from '../union-underlying-type/c.js';
|
||||
|
||||
import {A, AT} from '../union-underlying-type/a.js';
|
||||
import {B, BT} from '../union-underlying-type/b.js';
|
||||
import {C, CT} from '../union-underlying-type/c.js';
|
||||
|
||||
export enum ABC {
|
||||
NONE = 0,
|
||||
A = 555,
|
||||
B = 666,
|
||||
C = 777
|
||||
C = 777,
|
||||
}
|
||||
|
||||
export function unionToAbc(
|
||||
type: ABC,
|
||||
accessor: (obj:A|B|C) => A|B|C|null
|
||||
): A|B|C|null {
|
||||
switch(ABC[type]) {
|
||||
case 'NONE': return null;
|
||||
case 'A': return accessor(new A())! as A;
|
||||
case 'B': return accessor(new B())! as B;
|
||||
case 'C': return accessor(new C())! as C;
|
||||
default: return null;
|
||||
accessor: (obj: A | B | C) => A | B | C | null,
|
||||
): A | B | C | null {
|
||||
switch (ABC[type]) {
|
||||
case 'NONE':
|
||||
return null;
|
||||
case 'A':
|
||||
return accessor(new A())! as A;
|
||||
case 'B':
|
||||
return accessor(new B())! as B;
|
||||
case 'C':
|
||||
return accessor(new C())! as C;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
export function unionListToAbc(
|
||||
type: ABC,
|
||||
accessor: (index: number, obj:A|B|C) => A|B|C|null,
|
||||
index: number
|
||||
): A|B|C|null {
|
||||
switch(ABC[type]) {
|
||||
case 'NONE': return null;
|
||||
case 'A': return accessor(index, new A())! as A;
|
||||
case 'B': return accessor(index, new B())! as B;
|
||||
case 'C': return accessor(index, new C())! as C;
|
||||
default: return null;
|
||||
type: ABC,
|
||||
accessor: (index: number, obj: A | B | C) => A | B | C | null,
|
||||
index: number,
|
||||
): A | B | C | null {
|
||||
switch (ABC[type]) {
|
||||
case 'NONE':
|
||||
return null;
|
||||
case 'A':
|
||||
return accessor(index, new A())! as A;
|
||||
case 'B':
|
||||
return accessor(index, new B())! as B;
|
||||
case 'C':
|
||||
return accessor(index, new C())! as C;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
37
tests/ts/union-underlying-type/b.d.ts
vendored
37
tests/ts/union-underlying-type/b.d.ts
vendored
@@ -1,22 +1,25 @@
|
||||
import * as flatbuffers from 'flatbuffers';
|
||||
export declare class B implements flatbuffers.IUnpackableObject<BT> {
|
||||
bb: flatbuffers.ByteBuffer | null;
|
||||
bb_pos: number;
|
||||
__init(i: number, bb: flatbuffers.ByteBuffer): B;
|
||||
static getRootAsB(bb: flatbuffers.ByteBuffer, obj?: B): B;
|
||||
static getSizePrefixedRootAsB(bb: flatbuffers.ByteBuffer, obj?: B): B;
|
||||
b(): string | null;
|
||||
b(optionalEncoding: flatbuffers.Encoding): string | Uint8Array | null;
|
||||
static getFullyQualifiedName(): string;
|
||||
static startB(builder: flatbuffers.Builder): void;
|
||||
static addB(builder: flatbuffers.Builder, bOffset: flatbuffers.Offset): void;
|
||||
static endB(builder: flatbuffers.Builder): flatbuffers.Offset;
|
||||
static createB(builder: flatbuffers.Builder, bOffset: flatbuffers.Offset): flatbuffers.Offset;
|
||||
unpack(): BT;
|
||||
unpackTo(_o: BT): void;
|
||||
bb: flatbuffers.ByteBuffer | null;
|
||||
bb_pos: number;
|
||||
__init(i: number, bb: flatbuffers.ByteBuffer): B;
|
||||
static getRootAsB(bb: flatbuffers.ByteBuffer, obj?: B): B;
|
||||
static getSizePrefixedRootAsB(bb: flatbuffers.ByteBuffer, obj?: B): B;
|
||||
b(): string | null;
|
||||
b(optionalEncoding: flatbuffers.Encoding): string | Uint8Array | null;
|
||||
static getFullyQualifiedName(): string;
|
||||
static startB(builder: flatbuffers.Builder): void;
|
||||
static addB(builder: flatbuffers.Builder, bOffset: flatbuffers.Offset): void;
|
||||
static endB(builder: flatbuffers.Builder): flatbuffers.Offset;
|
||||
static createB(
|
||||
builder: flatbuffers.Builder,
|
||||
bOffset: flatbuffers.Offset,
|
||||
): flatbuffers.Offset;
|
||||
unpack(): BT;
|
||||
unpackTo(_o: BT): void;
|
||||
}
|
||||
export declare class BT implements flatbuffers.IGeneratedObject {
|
||||
b: string | Uint8Array | null;
|
||||
constructor(b?: string | Uint8Array | null);
|
||||
pack(builder: flatbuffers.Builder): flatbuffers.Offset;
|
||||
b: string | Uint8Array | null;
|
||||
constructor(b?: string | Uint8Array | null);
|
||||
pack(builder: flatbuffers.Builder): flatbuffers.Offset;
|
||||
}
|
||||
|
||||
@@ -1,58 +1,62 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */
|
||||
/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any,
|
||||
* @typescript-eslint/no-non-null-assertion */
|
||||
import * as flatbuffers from 'flatbuffers';
|
||||
export class B {
|
||||
constructor() {
|
||||
this.bb = null;
|
||||
this.bb_pos = 0;
|
||||
}
|
||||
__init(i, bb) {
|
||||
this.bb_pos = i;
|
||||
this.bb = bb;
|
||||
return this;
|
||||
}
|
||||
static getRootAsB(bb, obj) {
|
||||
return (obj || new B()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
|
||||
}
|
||||
static getSizePrefixedRootAsB(bb, obj) {
|
||||
bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
|
||||
return (obj || new B()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
|
||||
}
|
||||
b(optionalEncoding) {
|
||||
const offset = this.bb.__offset(this.bb_pos, 4);
|
||||
return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null;
|
||||
}
|
||||
static getFullyQualifiedName() {
|
||||
return 'UnionUnderlyingType.B';
|
||||
}
|
||||
static startB(builder) {
|
||||
builder.startObject(1);
|
||||
}
|
||||
static addB(builder, bOffset) {
|
||||
builder.addFieldOffset(0, bOffset, 0);
|
||||
}
|
||||
static endB(builder) {
|
||||
const offset = builder.endObject();
|
||||
return offset;
|
||||
}
|
||||
static createB(builder, bOffset) {
|
||||
B.startB(builder);
|
||||
B.addB(builder, bOffset);
|
||||
return B.endB(builder);
|
||||
}
|
||||
unpack() {
|
||||
return new BT(this.b());
|
||||
}
|
||||
unpackTo(_o) {
|
||||
_o.b = this.b();
|
||||
}
|
||||
constructor() {
|
||||
this.bb = null;
|
||||
this.bb_pos = 0;
|
||||
}
|
||||
__init(i, bb) {
|
||||
this.bb_pos = i;
|
||||
this.bb = bb;
|
||||
return this;
|
||||
}
|
||||
static getRootAsB(bb, obj) {
|
||||
return (obj || new B())
|
||||
.__init(bb.readInt32(bb.position()) + bb.position(), bb);
|
||||
}
|
||||
static getSizePrefixedRootAsB(bb, obj) {
|
||||
bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
|
||||
return (obj || new B())
|
||||
.__init(bb.readInt32(bb.position()) + bb.position(), bb);
|
||||
}
|
||||
b(optionalEncoding) {
|
||||
const offset = this.bb.__offset(this.bb_pos, 4);
|
||||
return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) :
|
||||
null;
|
||||
}
|
||||
static getFullyQualifiedName() {
|
||||
return 'UnionUnderlyingType.B';
|
||||
}
|
||||
static startB(builder) {
|
||||
builder.startObject(1);
|
||||
}
|
||||
static addB(builder, bOffset) {
|
||||
builder.addFieldOffset(0, bOffset, 0);
|
||||
}
|
||||
static endB(builder) {
|
||||
const offset = builder.endObject();
|
||||
return offset;
|
||||
}
|
||||
static createB(builder, bOffset) {
|
||||
B.startB(builder);
|
||||
B.addB(builder, bOffset);
|
||||
return B.endB(builder);
|
||||
}
|
||||
unpack() {
|
||||
return new BT(this.b());
|
||||
}
|
||||
unpackTo(_o) {
|
||||
_o.b = this.b();
|
||||
}
|
||||
}
|
||||
export class BT {
|
||||
constructor(b = null) {
|
||||
this.b = b;
|
||||
}
|
||||
pack(builder) {
|
||||
const b = (this.b !== null ? builder.createString(this.b) : 0);
|
||||
return B.createB(builder, b);
|
||||
}
|
||||
constructor(b = null) {
|
||||
this.b = b;
|
||||
}
|
||||
pack(builder) {
|
||||
const b = (this.b !== null ? builder.createString(this.b) : 0);
|
||||
return B.createB(builder, b);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,79 +4,80 @@
|
||||
|
||||
import * as flatbuffers from 'flatbuffers';
|
||||
|
||||
|
||||
|
||||
export class B implements flatbuffers.IUnpackableObject<BT> {
|
||||
bb: flatbuffers.ByteBuffer|null = null;
|
||||
bb: flatbuffers.ByteBuffer | null = null;
|
||||
bb_pos = 0;
|
||||
__init(i:number, bb:flatbuffers.ByteBuffer):B {
|
||||
this.bb_pos = i;
|
||||
this.bb = bb;
|
||||
return this;
|
||||
}
|
||||
__init(i: number, bb: flatbuffers.ByteBuffer): B {
|
||||
this.bb_pos = i;
|
||||
this.bb = bb;
|
||||
return this;
|
||||
}
|
||||
|
||||
static getRootAsB(bb:flatbuffers.ByteBuffer, obj?:B):B {
|
||||
return (obj || new B()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
|
||||
}
|
||||
static getRootAsB(bb: flatbuffers.ByteBuffer, obj?: B): B {
|
||||
return (obj || new B()).__init(
|
||||
bb.readInt32(bb.position()) + bb.position(),
|
||||
bb,
|
||||
);
|
||||
}
|
||||
|
||||
static getSizePrefixedRootAsB(bb:flatbuffers.ByteBuffer, obj?:B):B {
|
||||
bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
|
||||
return (obj || new B()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
|
||||
}
|
||||
static getSizePrefixedRootAsB(bb: flatbuffers.ByteBuffer, obj?: B): B {
|
||||
bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
|
||||
return (obj || new B()).__init(
|
||||
bb.readInt32(bb.position()) + bb.position(),
|
||||
bb,
|
||||
);
|
||||
}
|
||||
|
||||
b():string|null
|
||||
b(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
|
||||
b(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;
|
||||
}
|
||||
b(): string | null;
|
||||
b(optionalEncoding: flatbuffers.Encoding): string | Uint8Array | null;
|
||||
b(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;
|
||||
}
|
||||
|
||||
static getFullyQualifiedName():string {
|
||||
return 'UnionUnderlyingType.B';
|
||||
}
|
||||
static getFullyQualifiedName(): string {
|
||||
return 'UnionUnderlyingType.B';
|
||||
}
|
||||
|
||||
static startB(builder:flatbuffers.Builder) {
|
||||
builder.startObject(1);
|
||||
}
|
||||
static startB(builder: flatbuffers.Builder) {
|
||||
builder.startObject(1);
|
||||
}
|
||||
|
||||
static addB(builder:flatbuffers.Builder, bOffset:flatbuffers.Offset) {
|
||||
builder.addFieldOffset(0, bOffset, 0);
|
||||
}
|
||||
static addB(builder: flatbuffers.Builder, bOffset: flatbuffers.Offset) {
|
||||
builder.addFieldOffset(0, bOffset, 0);
|
||||
}
|
||||
|
||||
static endB(builder:flatbuffers.Builder):flatbuffers.Offset {
|
||||
const offset = builder.endObject();
|
||||
return offset;
|
||||
}
|
||||
static endB(builder: flatbuffers.Builder): flatbuffers.Offset {
|
||||
const offset = builder.endObject();
|
||||
return offset;
|
||||
}
|
||||
|
||||
static createB(builder:flatbuffers.Builder, bOffset:flatbuffers.Offset):flatbuffers.Offset {
|
||||
B.startB(builder);
|
||||
B.addB(builder, bOffset);
|
||||
return B.endB(builder);
|
||||
}
|
||||
static createB(
|
||||
builder: flatbuffers.Builder,
|
||||
bOffset: flatbuffers.Offset,
|
||||
): flatbuffers.Offset {
|
||||
B.startB(builder);
|
||||
B.addB(builder, bOffset);
|
||||
return B.endB(builder);
|
||||
}
|
||||
|
||||
unpack(): BT {
|
||||
return new BT(
|
||||
this.b()
|
||||
);
|
||||
}
|
||||
unpack(): BT {
|
||||
return new BT(this.b());
|
||||
}
|
||||
|
||||
|
||||
unpackTo(_o: BT): void {
|
||||
_o.b = this.b();
|
||||
}
|
||||
unpackTo(_o: BT): void {
|
||||
_o.b = this.b();
|
||||
}
|
||||
}
|
||||
|
||||
export class BT implements flatbuffers.IGeneratedObject {
|
||||
constructor(
|
||||
public b: string|Uint8Array|null = null
|
||||
){}
|
||||
constructor(public b: string | Uint8Array | null = null) {}
|
||||
|
||||
pack(builder: flatbuffers.Builder): flatbuffers.Offset {
|
||||
const b = this.b !== null ? builder.createString(this.b!) : 0;
|
||||
|
||||
pack(builder:flatbuffers.Builder): flatbuffers.Offset {
|
||||
const b = (this.b !== null ? builder.createString(this.b!) : 0);
|
||||
|
||||
return B.createB(builder,
|
||||
b
|
||||
);
|
||||
}
|
||||
return B.createB(builder, b);
|
||||
}
|
||||
}
|
||||
|
||||
34
tests/ts/union-underlying-type/c.d.ts
vendored
34
tests/ts/union-underlying-type/c.d.ts
vendored
@@ -1,22 +1,22 @@
|
||||
import * as flatbuffers from 'flatbuffers';
|
||||
export declare class C implements flatbuffers.IUnpackableObject<CT> {
|
||||
bb: flatbuffers.ByteBuffer | null;
|
||||
bb_pos: number;
|
||||
__init(i: number, bb: flatbuffers.ByteBuffer): C;
|
||||
static getRootAsC(bb: flatbuffers.ByteBuffer, obj?: C): C;
|
||||
static getSizePrefixedRootAsC(bb: flatbuffers.ByteBuffer, obj?: C): C;
|
||||
c(): boolean;
|
||||
mutate_c(value: boolean): boolean;
|
||||
static getFullyQualifiedName(): string;
|
||||
static startC(builder: flatbuffers.Builder): void;
|
||||
static addC(builder: flatbuffers.Builder, c: boolean): void;
|
||||
static endC(builder: flatbuffers.Builder): flatbuffers.Offset;
|
||||
static createC(builder: flatbuffers.Builder, c: boolean): flatbuffers.Offset;
|
||||
unpack(): CT;
|
||||
unpackTo(_o: CT): void;
|
||||
bb: flatbuffers.ByteBuffer | null;
|
||||
bb_pos: number;
|
||||
__init(i: number, bb: flatbuffers.ByteBuffer): C;
|
||||
static getRootAsC(bb: flatbuffers.ByteBuffer, obj?: C): C;
|
||||
static getSizePrefixedRootAsC(bb: flatbuffers.ByteBuffer, obj?: C): C;
|
||||
c(): boolean;
|
||||
mutate_c(value: boolean): boolean;
|
||||
static getFullyQualifiedName(): string;
|
||||
static startC(builder: flatbuffers.Builder): void;
|
||||
static addC(builder: flatbuffers.Builder, c: boolean): void;
|
||||
static endC(builder: flatbuffers.Builder): flatbuffers.Offset;
|
||||
static createC(builder: flatbuffers.Builder, c: boolean): flatbuffers.Offset;
|
||||
unpack(): CT;
|
||||
unpackTo(_o: CT): void;
|
||||
}
|
||||
export declare class CT implements flatbuffers.IGeneratedObject {
|
||||
c: boolean;
|
||||
constructor(c?: boolean);
|
||||
pack(builder: flatbuffers.Builder): flatbuffers.Offset;
|
||||
c: boolean;
|
||||
constructor(c?: boolean);
|
||||
pack(builder: flatbuffers.Builder): flatbuffers.Offset;
|
||||
}
|
||||
|
||||
@@ -1,65 +1,68 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */
|
||||
/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any,
|
||||
* @typescript-eslint/no-non-null-assertion */
|
||||
import * as flatbuffers from 'flatbuffers';
|
||||
export class C {
|
||||
constructor() {
|
||||
this.bb = null;
|
||||
this.bb_pos = 0;
|
||||
}
|
||||
__init(i, bb) {
|
||||
this.bb_pos = i;
|
||||
this.bb = bb;
|
||||
return this;
|
||||
}
|
||||
static getRootAsC(bb, obj) {
|
||||
return (obj || new C()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
|
||||
}
|
||||
static getSizePrefixedRootAsC(bb, obj) {
|
||||
bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
|
||||
return (obj || new C()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
|
||||
}
|
||||
c() {
|
||||
const offset = this.bb.__offset(this.bb_pos, 4);
|
||||
return offset ? !!this.bb.readInt8(this.bb_pos + offset) : false;
|
||||
}
|
||||
mutate_c(value) {
|
||||
const offset = this.bb.__offset(this.bb_pos, 4);
|
||||
if (offset === 0) {
|
||||
return false;
|
||||
}
|
||||
this.bb.writeInt8(this.bb_pos + offset, +value);
|
||||
return true;
|
||||
}
|
||||
static getFullyQualifiedName() {
|
||||
return 'UnionUnderlyingType.C';
|
||||
}
|
||||
static startC(builder) {
|
||||
builder.startObject(1);
|
||||
}
|
||||
static addC(builder, c) {
|
||||
builder.addFieldInt8(0, +c, +false);
|
||||
}
|
||||
static endC(builder) {
|
||||
const offset = builder.endObject();
|
||||
return offset;
|
||||
}
|
||||
static createC(builder, c) {
|
||||
C.startC(builder);
|
||||
C.addC(builder, c);
|
||||
return C.endC(builder);
|
||||
}
|
||||
unpack() {
|
||||
return new CT(this.c());
|
||||
}
|
||||
unpackTo(_o) {
|
||||
_o.c = this.c();
|
||||
constructor() {
|
||||
this.bb = null;
|
||||
this.bb_pos = 0;
|
||||
}
|
||||
__init(i, bb) {
|
||||
this.bb_pos = i;
|
||||
this.bb = bb;
|
||||
return this;
|
||||
}
|
||||
static getRootAsC(bb, obj) {
|
||||
return (obj || new C())
|
||||
.__init(bb.readInt32(bb.position()) + bb.position(), bb);
|
||||
}
|
||||
static getSizePrefixedRootAsC(bb, obj) {
|
||||
bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
|
||||
return (obj || new C())
|
||||
.__init(bb.readInt32(bb.position()) + bb.position(), bb);
|
||||
}
|
||||
c() {
|
||||
const offset = this.bb.__offset(this.bb_pos, 4);
|
||||
return offset ? !!this.bb.readInt8(this.bb_pos + offset) : false;
|
||||
}
|
||||
mutate_c(value) {
|
||||
const offset = this.bb.__offset(this.bb_pos, 4);
|
||||
if (offset === 0) {
|
||||
return false;
|
||||
}
|
||||
this.bb.writeInt8(this.bb_pos + offset, +value);
|
||||
return true;
|
||||
}
|
||||
static getFullyQualifiedName() {
|
||||
return 'UnionUnderlyingType.C';
|
||||
}
|
||||
static startC(builder) {
|
||||
builder.startObject(1);
|
||||
}
|
||||
static addC(builder, c) {
|
||||
builder.addFieldInt8(0, +c, +false);
|
||||
}
|
||||
static endC(builder) {
|
||||
const offset = builder.endObject();
|
||||
return offset;
|
||||
}
|
||||
static createC(builder, c) {
|
||||
C.startC(builder);
|
||||
C.addC(builder, c);
|
||||
return C.endC(builder);
|
||||
}
|
||||
unpack() {
|
||||
return new CT(this.c());
|
||||
}
|
||||
unpackTo(_o) {
|
||||
_o.c = this.c();
|
||||
}
|
||||
}
|
||||
export class CT {
|
||||
constructor(c = false) {
|
||||
this.c = c;
|
||||
}
|
||||
pack(builder) {
|
||||
return C.createC(builder, this.c);
|
||||
}
|
||||
constructor(c = false) {
|
||||
this.c = c;
|
||||
}
|
||||
pack(builder) {
|
||||
return C.createC(builder, this.c);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,86 +4,82 @@
|
||||
|
||||
import * as flatbuffers from 'flatbuffers';
|
||||
|
||||
|
||||
|
||||
export class C implements flatbuffers.IUnpackableObject<CT> {
|
||||
bb: flatbuffers.ByteBuffer|null = null;
|
||||
bb: flatbuffers.ByteBuffer | null = null;
|
||||
bb_pos = 0;
|
||||
__init(i:number, bb:flatbuffers.ByteBuffer):C {
|
||||
this.bb_pos = i;
|
||||
this.bb = bb;
|
||||
return this;
|
||||
}
|
||||
|
||||
static getRootAsC(bb:flatbuffers.ByteBuffer, obj?:C):C {
|
||||
return (obj || new C()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
|
||||
}
|
||||
|
||||
static getSizePrefixedRootAsC(bb:flatbuffers.ByteBuffer, obj?:C):C {
|
||||
bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
|
||||
return (obj || new C()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
|
||||
}
|
||||
|
||||
c():boolean {
|
||||
const offset = this.bb!.__offset(this.bb_pos, 4);
|
||||
return offset ? !!this.bb!.readInt8(this.bb_pos + offset) : false;
|
||||
}
|
||||
|
||||
mutate_c(value:boolean):boolean {
|
||||
const offset = this.bb!.__offset(this.bb_pos, 4);
|
||||
|
||||
if (offset === 0) {
|
||||
return false;
|
||||
__init(i: number, bb: flatbuffers.ByteBuffer): C {
|
||||
this.bb_pos = i;
|
||||
this.bb = bb;
|
||||
return this;
|
||||
}
|
||||
|
||||
this.bb!.writeInt8(this.bb_pos + offset, +value);
|
||||
return true;
|
||||
}
|
||||
static getRootAsC(bb: flatbuffers.ByteBuffer, obj?: C): C {
|
||||
return (obj || new C()).__init(
|
||||
bb.readInt32(bb.position()) + bb.position(),
|
||||
bb,
|
||||
);
|
||||
}
|
||||
|
||||
static getFullyQualifiedName():string {
|
||||
return 'UnionUnderlyingType.C';
|
||||
}
|
||||
static getSizePrefixedRootAsC(bb: flatbuffers.ByteBuffer, obj?: C): C {
|
||||
bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
|
||||
return (obj || new C()).__init(
|
||||
bb.readInt32(bb.position()) + bb.position(),
|
||||
bb,
|
||||
);
|
||||
}
|
||||
|
||||
static startC(builder:flatbuffers.Builder) {
|
||||
builder.startObject(1);
|
||||
}
|
||||
c(): boolean {
|
||||
const offset = this.bb!.__offset(this.bb_pos, 4);
|
||||
return offset ? !!this.bb!.readInt8(this.bb_pos + offset) : false;
|
||||
}
|
||||
|
||||
static addC(builder:flatbuffers.Builder, c:boolean) {
|
||||
builder.addFieldInt8(0, +c, +false);
|
||||
}
|
||||
mutate_c(value: boolean): boolean {
|
||||
const offset = this.bb!.__offset(this.bb_pos, 4);
|
||||
|
||||
static endC(builder:flatbuffers.Builder):flatbuffers.Offset {
|
||||
const offset = builder.endObject();
|
||||
return offset;
|
||||
}
|
||||
if (offset === 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
static createC(builder:flatbuffers.Builder, c:boolean):flatbuffers.Offset {
|
||||
C.startC(builder);
|
||||
C.addC(builder, c);
|
||||
return C.endC(builder);
|
||||
}
|
||||
this.bb!.writeInt8(this.bb_pos + offset, +value);
|
||||
return true;
|
||||
}
|
||||
|
||||
unpack(): CT {
|
||||
return new CT(
|
||||
this.c()
|
||||
);
|
||||
}
|
||||
static getFullyQualifiedName(): string {
|
||||
return 'UnionUnderlyingType.C';
|
||||
}
|
||||
|
||||
static startC(builder: flatbuffers.Builder) {
|
||||
builder.startObject(1);
|
||||
}
|
||||
|
||||
unpackTo(_o: CT): void {
|
||||
_o.c = this.c();
|
||||
}
|
||||
static addC(builder: flatbuffers.Builder, c: boolean) {
|
||||
builder.addFieldInt8(0, +c, +false);
|
||||
}
|
||||
|
||||
static endC(builder: flatbuffers.Builder): flatbuffers.Offset {
|
||||
const offset = builder.endObject();
|
||||
return offset;
|
||||
}
|
||||
|
||||
static createC(builder: flatbuffers.Builder, c: boolean): flatbuffers.Offset {
|
||||
C.startC(builder);
|
||||
C.addC(builder, c);
|
||||
return C.endC(builder);
|
||||
}
|
||||
|
||||
unpack(): CT {
|
||||
return new CT(this.c());
|
||||
}
|
||||
|
||||
unpackTo(_o: CT): void {
|
||||
_o.c = this.c();
|
||||
}
|
||||
}
|
||||
|
||||
export class CT implements flatbuffers.IGeneratedObject {
|
||||
constructor(
|
||||
public c: boolean = false
|
||||
){}
|
||||
constructor(public c: boolean = false) {}
|
||||
|
||||
|
||||
pack(builder:flatbuffers.Builder): flatbuffers.Offset {
|
||||
return C.createC(builder,
|
||||
this.c
|
||||
);
|
||||
}
|
||||
pack(builder: flatbuffers.Builder): flatbuffers.Offset {
|
||||
return C.createC(builder, this.c);
|
||||
}
|
||||
}
|
||||
|
||||
107
tests/ts/union-underlying-type/d.d.ts
vendored
107
tests/ts/union-underlying-type/d.d.ts
vendored
@@ -1,41 +1,76 @@
|
||||
import * as flatbuffers from 'flatbuffers';
|
||||
import { AT } from '../union-underlying-type/a.js';
|
||||
import { ABC } from '../union-underlying-type/abc.js';
|
||||
import { BT } from '../union-underlying-type/b.js';
|
||||
import { CT } from '../union-underlying-type/c.js';
|
||||
import {AT} from '../union-underlying-type/a.js';
|
||||
import {ABC} from '../union-underlying-type/abc.js';
|
||||
import {BT} from '../union-underlying-type/b.js';
|
||||
import {CT} from '../union-underlying-type/c.js';
|
||||
export declare class D implements flatbuffers.IUnpackableObject<DT> {
|
||||
bb: flatbuffers.ByteBuffer | null;
|
||||
bb_pos: number;
|
||||
__init(i: number, bb: flatbuffers.ByteBuffer): D;
|
||||
static getRootAsD(bb: flatbuffers.ByteBuffer, obj?: D): D;
|
||||
static getSizePrefixedRootAsD(bb: flatbuffers.ByteBuffer, obj?: D): D;
|
||||
testUnionType(): ABC;
|
||||
testUnion<T extends flatbuffers.Table>(obj: any): any | null;
|
||||
testVectorOfUnionType(index: number): ABC | null;
|
||||
testVectorOfUnionTypeLength(): number;
|
||||
testVectorOfUnionTypeArray(): Int32Array | null;
|
||||
testVectorOfUnion(index: number, obj: any): any | null;
|
||||
testVectorOfUnionLength(): number;
|
||||
static getFullyQualifiedName(): string;
|
||||
static startD(builder: flatbuffers.Builder): void;
|
||||
static addTestUnionType(builder: flatbuffers.Builder, testUnionType: ABC): void;
|
||||
static addTestUnion(builder: flatbuffers.Builder, testUnionOffset: flatbuffers.Offset): void;
|
||||
static addTestVectorOfUnionType(builder: flatbuffers.Builder, testVectorOfUnionTypeOffset: flatbuffers.Offset): void;
|
||||
static createTestVectorOfUnionTypeVector(builder: flatbuffers.Builder, data: ABC[]): flatbuffers.Offset;
|
||||
static startTestVectorOfUnionTypeVector(builder: flatbuffers.Builder, numElems: number): void;
|
||||
static addTestVectorOfUnion(builder: flatbuffers.Builder, testVectorOfUnionOffset: flatbuffers.Offset): void;
|
||||
static createTestVectorOfUnionVector(builder: flatbuffers.Builder, data: flatbuffers.Offset[]): flatbuffers.Offset;
|
||||
static startTestVectorOfUnionVector(builder: flatbuffers.Builder, numElems: number): void;
|
||||
static endD(builder: flatbuffers.Builder): flatbuffers.Offset;
|
||||
static createD(builder: flatbuffers.Builder, testUnionType: ABC, testUnionOffset: flatbuffers.Offset, testVectorOfUnionTypeOffset: flatbuffers.Offset, testVectorOfUnionOffset: flatbuffers.Offset): flatbuffers.Offset;
|
||||
unpack(): DT;
|
||||
unpackTo(_o: DT): void;
|
||||
bb: flatbuffers.ByteBuffer | null;
|
||||
bb_pos: number;
|
||||
__init(i: number, bb: flatbuffers.ByteBuffer): D;
|
||||
static getRootAsD(bb: flatbuffers.ByteBuffer, obj?: D): D;
|
||||
static getSizePrefixedRootAsD(bb: flatbuffers.ByteBuffer, obj?: D): D;
|
||||
testUnionType(): ABC;
|
||||
testUnion<T extends flatbuffers.Table>(obj: any): any | null;
|
||||
testVectorOfUnionType(index: number): ABC | null;
|
||||
testVectorOfUnionTypeLength(): number;
|
||||
testVectorOfUnionTypeArray(): Int32Array | null;
|
||||
testVectorOfUnion(index: number, obj: any): any | null;
|
||||
testVectorOfUnionLength(): number;
|
||||
static getFullyQualifiedName(): string;
|
||||
static startD(builder: flatbuffers.Builder): void;
|
||||
static addTestUnionType(
|
||||
builder: flatbuffers.Builder,
|
||||
testUnionType: ABC,
|
||||
): void;
|
||||
static addTestUnion(
|
||||
builder: flatbuffers.Builder,
|
||||
testUnionOffset: flatbuffers.Offset,
|
||||
): void;
|
||||
static addTestVectorOfUnionType(
|
||||
builder: flatbuffers.Builder,
|
||||
testVectorOfUnionTypeOffset: flatbuffers.Offset,
|
||||
): void;
|
||||
static createTestVectorOfUnionTypeVector(
|
||||
builder: flatbuffers.Builder,
|
||||
data: ABC[],
|
||||
): flatbuffers.Offset;
|
||||
static startTestVectorOfUnionTypeVector(
|
||||
builder: flatbuffers.Builder,
|
||||
numElems: number,
|
||||
): void;
|
||||
static addTestVectorOfUnion(
|
||||
builder: flatbuffers.Builder,
|
||||
testVectorOfUnionOffset: flatbuffers.Offset,
|
||||
): void;
|
||||
static createTestVectorOfUnionVector(
|
||||
builder: flatbuffers.Builder,
|
||||
data: flatbuffers.Offset[],
|
||||
): flatbuffers.Offset;
|
||||
static startTestVectorOfUnionVector(
|
||||
builder: flatbuffers.Builder,
|
||||
numElems: number,
|
||||
): void;
|
||||
static endD(builder: flatbuffers.Builder): flatbuffers.Offset;
|
||||
static createD(
|
||||
builder: flatbuffers.Builder,
|
||||
testUnionType: ABC,
|
||||
testUnionOffset: flatbuffers.Offset,
|
||||
testVectorOfUnionTypeOffset: flatbuffers.Offset,
|
||||
testVectorOfUnionOffset: flatbuffers.Offset,
|
||||
): flatbuffers.Offset;
|
||||
unpack(): DT;
|
||||
unpackTo(_o: DT): void;
|
||||
}
|
||||
export declare class DT implements flatbuffers.IGeneratedObject {
|
||||
testUnionType: ABC;
|
||||
testUnion: AT | BT | CT | null;
|
||||
testVectorOfUnionType: (ABC)[];
|
||||
testVectorOfUnion: (AT | BT | CT)[];
|
||||
constructor(testUnionType?: ABC, testUnion?: AT | BT | CT | null, testVectorOfUnionType?: (ABC)[], testVectorOfUnion?: (AT | BT | CT)[]);
|
||||
pack(builder: flatbuffers.Builder): flatbuffers.Offset;
|
||||
testUnionType: ABC;
|
||||
testUnion: AT | BT | CT | null;
|
||||
testVectorOfUnionType: ABC[];
|
||||
testVectorOfUnion: (AT | BT | CT)[];
|
||||
constructor(
|
||||
testUnionType?: ABC,
|
||||
testUnion?: AT | BT | CT | null,
|
||||
testVectorOfUnionType?: ABC[],
|
||||
testVectorOfUnion?: (AT | BT | CT)[],
|
||||
);
|
||||
pack(builder: flatbuffers.Builder): flatbuffers.Offset;
|
||||
}
|
||||
|
||||
@@ -1,163 +1,200 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */
|
||||
/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any,
|
||||
* @typescript-eslint/no-non-null-assertion */
|
||||
import * as flatbuffers from 'flatbuffers';
|
||||
import { ABC, unionToAbc, unionListToAbc } from '../union-underlying-type/abc.js';
|
||||
|
||||
import {ABC, unionListToAbc, unionToAbc} from '../union-underlying-type/abc.js';
|
||||
|
||||
export class D {
|
||||
constructor() {
|
||||
this.bb = null;
|
||||
this.bb_pos = 0;
|
||||
constructor() {
|
||||
this.bb = null;
|
||||
this.bb_pos = 0;
|
||||
}
|
||||
__init(i, bb) {
|
||||
this.bb_pos = i;
|
||||
this.bb = bb;
|
||||
return this;
|
||||
}
|
||||
static getRootAsD(bb, obj) {
|
||||
return (obj || new D())
|
||||
.__init(bb.readInt32(bb.position()) + bb.position(), bb);
|
||||
}
|
||||
static getSizePrefixedRootAsD(bb, obj) {
|
||||
bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
|
||||
return (obj || new D())
|
||||
.__init(bb.readInt32(bb.position()) + bb.position(), bb);
|
||||
}
|
||||
testUnionType() {
|
||||
const offset = this.bb.__offset(this.bb_pos, 4);
|
||||
return offset ? this.bb.readInt32(this.bb_pos + offset) : ABC.NONE;
|
||||
}
|
||||
testUnion(obj) {
|
||||
const offset = this.bb.__offset(this.bb_pos, 6);
|
||||
return offset ? this.bb.__union(obj, this.bb_pos + offset) : null;
|
||||
}
|
||||
testVectorOfUnionType(index) {
|
||||
const offset = this.bb.__offset(this.bb_pos, 8);
|
||||
return offset ?
|
||||
this.bb.readInt32(this.bb.__vector(this.bb_pos + offset) + index * 4) :
|
||||
null;
|
||||
}
|
||||
testVectorOfUnionTypeLength() {
|
||||
const offset = this.bb.__offset(this.bb_pos, 8);
|
||||
return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0;
|
||||
}
|
||||
testVectorOfUnionTypeArray() {
|
||||
const offset = this.bb.__offset(this.bb_pos, 8);
|
||||
return offset ?
|
||||
new Int32Array(
|
||||
this.bb.bytes().buffer,
|
||||
this.bb.bytes().byteOffset + this.bb.__vector(this.bb_pos + offset),
|
||||
this.bb.__vector_len(this.bb_pos + offset)) :
|
||||
null;
|
||||
}
|
||||
testVectorOfUnion(index, obj) {
|
||||
const offset = this.bb.__offset(this.bb_pos, 10);
|
||||
return offset ?
|
||||
this.bb.__union(
|
||||
obj, this.bb.__vector(this.bb_pos + offset) + index * 4) :
|
||||
null;
|
||||
}
|
||||
testVectorOfUnionLength() {
|
||||
const offset = this.bb.__offset(this.bb_pos, 10);
|
||||
return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0;
|
||||
}
|
||||
static getFullyQualifiedName() {
|
||||
return 'UnionUnderlyingType.D';
|
||||
}
|
||||
static startD(builder) {
|
||||
builder.startObject(4);
|
||||
}
|
||||
static addTestUnionType(builder, testUnionType) {
|
||||
builder.addFieldInt32(0, testUnionType, ABC.NONE);
|
||||
}
|
||||
static addTestUnion(builder, testUnionOffset) {
|
||||
builder.addFieldOffset(1, testUnionOffset, 0);
|
||||
}
|
||||
static addTestVectorOfUnionType(builder, testVectorOfUnionTypeOffset) {
|
||||
builder.addFieldOffset(2, testVectorOfUnionTypeOffset, 0);
|
||||
}
|
||||
static createTestVectorOfUnionTypeVector(builder, data) {
|
||||
builder.startVector(4, data.length, 4);
|
||||
for (let i = data.length - 1; i >= 0; i--) {
|
||||
builder.addInt32(data[i]);
|
||||
}
|
||||
__init(i, bb) {
|
||||
this.bb_pos = i;
|
||||
this.bb = bb;
|
||||
return this;
|
||||
return builder.endVector();
|
||||
}
|
||||
static startTestVectorOfUnionTypeVector(builder, numElems) {
|
||||
builder.startVector(4, numElems, 4);
|
||||
}
|
||||
static addTestVectorOfUnion(builder, testVectorOfUnionOffset) {
|
||||
builder.addFieldOffset(3, testVectorOfUnionOffset, 0);
|
||||
}
|
||||
static createTestVectorOfUnionVector(builder, data) {
|
||||
builder.startVector(4, data.length, 4);
|
||||
for (let i = data.length - 1; i >= 0; i--) {
|
||||
builder.addOffset(data[i]);
|
||||
}
|
||||
static getRootAsD(bb, obj) {
|
||||
return (obj || new D()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
|
||||
}
|
||||
static getSizePrefixedRootAsD(bb, obj) {
|
||||
bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
|
||||
return (obj || new D()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
|
||||
}
|
||||
testUnionType() {
|
||||
const offset = this.bb.__offset(this.bb_pos, 4);
|
||||
return offset ? this.bb.readInt32(this.bb_pos + offset) : ABC.NONE;
|
||||
}
|
||||
testUnion(obj) {
|
||||
const offset = this.bb.__offset(this.bb_pos, 6);
|
||||
return offset ? this.bb.__union(obj, this.bb_pos + offset) : null;
|
||||
}
|
||||
testVectorOfUnionType(index) {
|
||||
const offset = this.bb.__offset(this.bb_pos, 8);
|
||||
return offset ? this.bb.readInt32(this.bb.__vector(this.bb_pos + offset) + index * 4) : null;
|
||||
}
|
||||
testVectorOfUnionTypeLength() {
|
||||
const offset = this.bb.__offset(this.bb_pos, 8);
|
||||
return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0;
|
||||
}
|
||||
testVectorOfUnionTypeArray() {
|
||||
const offset = this.bb.__offset(this.bb_pos, 8);
|
||||
return offset ? new Int32Array(this.bb.bytes().buffer, this.bb.bytes().byteOffset + this.bb.__vector(this.bb_pos + offset), this.bb.__vector_len(this.bb_pos + offset)) : null;
|
||||
}
|
||||
testVectorOfUnion(index, obj) {
|
||||
const offset = this.bb.__offset(this.bb_pos, 10);
|
||||
return offset ? this.bb.__union(obj, this.bb.__vector(this.bb_pos + offset) + index * 4) : null;
|
||||
}
|
||||
testVectorOfUnionLength() {
|
||||
const offset = this.bb.__offset(this.bb_pos, 10);
|
||||
return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0;
|
||||
}
|
||||
static getFullyQualifiedName() {
|
||||
return 'UnionUnderlyingType.D';
|
||||
}
|
||||
static startD(builder) {
|
||||
builder.startObject(4);
|
||||
}
|
||||
static addTestUnionType(builder, testUnionType) {
|
||||
builder.addFieldInt32(0, testUnionType, ABC.NONE);
|
||||
}
|
||||
static addTestUnion(builder, testUnionOffset) {
|
||||
builder.addFieldOffset(1, testUnionOffset, 0);
|
||||
}
|
||||
static addTestVectorOfUnionType(builder, testVectorOfUnionTypeOffset) {
|
||||
builder.addFieldOffset(2, testVectorOfUnionTypeOffset, 0);
|
||||
}
|
||||
static createTestVectorOfUnionTypeVector(builder, data) {
|
||||
builder.startVector(4, data.length, 4);
|
||||
for (let i = data.length - 1; i >= 0; i--) {
|
||||
builder.addInt32(data[i]);
|
||||
}
|
||||
return builder.endVector();
|
||||
}
|
||||
static startTestVectorOfUnionTypeVector(builder, numElems) {
|
||||
builder.startVector(4, numElems, 4);
|
||||
}
|
||||
static addTestVectorOfUnion(builder, testVectorOfUnionOffset) {
|
||||
builder.addFieldOffset(3, testVectorOfUnionOffset, 0);
|
||||
}
|
||||
static createTestVectorOfUnionVector(builder, data) {
|
||||
builder.startVector(4, data.length, 4);
|
||||
for (let i = data.length - 1; i >= 0; i--) {
|
||||
builder.addOffset(data[i]);
|
||||
}
|
||||
return builder.endVector();
|
||||
}
|
||||
static startTestVectorOfUnionVector(builder, numElems) {
|
||||
builder.startVector(4, numElems, 4);
|
||||
}
|
||||
static endD(builder) {
|
||||
const offset = builder.endObject();
|
||||
return offset;
|
||||
}
|
||||
static createD(builder, testUnionType, testUnionOffset, testVectorOfUnionTypeOffset, testVectorOfUnionOffset) {
|
||||
D.startD(builder);
|
||||
D.addTestUnionType(builder, testUnionType);
|
||||
D.addTestUnion(builder, testUnionOffset);
|
||||
D.addTestVectorOfUnionType(builder, testVectorOfUnionTypeOffset);
|
||||
D.addTestVectorOfUnion(builder, testVectorOfUnionOffset);
|
||||
return D.endD(builder);
|
||||
}
|
||||
unpack() {
|
||||
return new DT(this.testUnionType(), (() => {
|
||||
const temp = unionToAbc(this.testUnionType(), this.testUnion.bind(this));
|
||||
return builder.endVector();
|
||||
}
|
||||
static startTestVectorOfUnionVector(builder, numElems) {
|
||||
builder.startVector(4, numElems, 4);
|
||||
}
|
||||
static endD(builder) {
|
||||
const offset = builder.endObject();
|
||||
return offset;
|
||||
}
|
||||
static createD(
|
||||
builder, testUnionType, testUnionOffset, testVectorOfUnionTypeOffset,
|
||||
testVectorOfUnionOffset) {
|
||||
D.startD(builder);
|
||||
D.addTestUnionType(builder, testUnionType);
|
||||
D.addTestUnion(builder, testUnionOffset);
|
||||
D.addTestVectorOfUnionType(builder, testVectorOfUnionTypeOffset);
|
||||
D.addTestVectorOfUnion(builder, testVectorOfUnionOffset);
|
||||
return D.endD(builder);
|
||||
}
|
||||
unpack() {
|
||||
return new DT(
|
||||
this.testUnionType(), (() => {
|
||||
const temp =
|
||||
unionToAbc(this.testUnionType(), this.testUnion.bind(this));
|
||||
if (temp === null) {
|
||||
return null;
|
||||
}
|
||||
return temp.unpack();
|
||||
})(),
|
||||
this.bb.createScalarList(
|
||||
this.testVectorOfUnionType.bind(this),
|
||||
this.testVectorOfUnionTypeLength()),
|
||||
(() => {
|
||||
const ret = [];
|
||||
for (let targetEnumIndex = 0;
|
||||
targetEnumIndex < this.testVectorOfUnionTypeLength();
|
||||
++targetEnumIndex) {
|
||||
const targetEnum = this.testVectorOfUnionType(targetEnumIndex);
|
||||
if (targetEnum === null || ABC[targetEnum] === 'NONE') {
|
||||
continue;
|
||||
}
|
||||
const temp = unionListToAbc(
|
||||
targetEnum, this.testVectorOfUnion.bind(this), targetEnumIndex);
|
||||
if (temp === null) {
|
||||
return null;
|
||||
continue;
|
||||
}
|
||||
return temp.unpack();
|
||||
})(), this.bb.createScalarList(this.testVectorOfUnionType.bind(this), this.testVectorOfUnionTypeLength()), (() => {
|
||||
const ret = [];
|
||||
for (let targetEnumIndex = 0; targetEnumIndex < this.testVectorOfUnionTypeLength(); ++targetEnumIndex) {
|
||||
const targetEnum = this.testVectorOfUnionType(targetEnumIndex);
|
||||
if (targetEnum === null || ABC[targetEnum] === 'NONE') {
|
||||
continue;
|
||||
}
|
||||
const temp = unionListToAbc(targetEnum, this.testVectorOfUnion.bind(this), targetEnumIndex);
|
||||
if (temp === null) {
|
||||
continue;
|
||||
}
|
||||
ret.push(temp.unpack());
|
||||
}
|
||||
return ret;
|
||||
ret.push(temp.unpack());
|
||||
}
|
||||
return ret;
|
||||
})());
|
||||
}
|
||||
unpackTo(_o) {
|
||||
_o.testUnionType = this.testUnionType();
|
||||
_o.testUnion = (() => {
|
||||
const temp = unionToAbc(this.testUnionType(), this.testUnion.bind(this));
|
||||
if (temp === null) {
|
||||
return null;
|
||||
}
|
||||
return temp.unpack();
|
||||
})();
|
||||
_o.testVectorOfUnionType = this.bb.createScalarList(this.testVectorOfUnionType.bind(this), this.testVectorOfUnionTypeLength());
|
||||
_o.testVectorOfUnion = (() => {
|
||||
const ret = [];
|
||||
for (let targetEnumIndex = 0; targetEnumIndex < this.testVectorOfUnionTypeLength(); ++targetEnumIndex) {
|
||||
const targetEnum = this.testVectorOfUnionType(targetEnumIndex);
|
||||
if (targetEnum === null || ABC[targetEnum] === 'NONE') {
|
||||
continue;
|
||||
}
|
||||
const temp = unionListToAbc(targetEnum, this.testVectorOfUnion.bind(this), targetEnumIndex);
|
||||
if (temp === null) {
|
||||
continue;
|
||||
}
|
||||
ret.push(temp.unpack());
|
||||
}
|
||||
return ret;
|
||||
})();
|
||||
}
|
||||
}
|
||||
unpackTo(_o) {
|
||||
_o.testUnionType = this.testUnionType();
|
||||
_o.testUnion = (() => {
|
||||
const temp = unionToAbc(this.testUnionType(), this.testUnion.bind(this));
|
||||
if (temp === null) {
|
||||
return null;
|
||||
}
|
||||
return temp.unpack();
|
||||
})();
|
||||
_o.testVectorOfUnionType = this.bb.createScalarList(
|
||||
this.testVectorOfUnionType.bind(this),
|
||||
this.testVectorOfUnionTypeLength());
|
||||
_o.testVectorOfUnion = (() => {
|
||||
const ret = [];
|
||||
for (let targetEnumIndex = 0;
|
||||
targetEnumIndex < this.testVectorOfUnionTypeLength();
|
||||
++targetEnumIndex) {
|
||||
const targetEnum = this.testVectorOfUnionType(targetEnumIndex);
|
||||
if (targetEnum === null || ABC[targetEnum] === 'NONE') {
|
||||
continue;
|
||||
}
|
||||
const temp = unionListToAbc(
|
||||
targetEnum, this.testVectorOfUnion.bind(this), targetEnumIndex);
|
||||
if (temp === null) {
|
||||
continue;
|
||||
}
|
||||
ret.push(temp.unpack());
|
||||
}
|
||||
return ret;
|
||||
})();
|
||||
}
|
||||
}
|
||||
export class DT {
|
||||
constructor(testUnionType = ABC.NONE, testUnion = null, testVectorOfUnionType = [], testVectorOfUnion = []) {
|
||||
this.testUnionType = testUnionType;
|
||||
this.testUnion = testUnion;
|
||||
this.testVectorOfUnionType = testVectorOfUnionType;
|
||||
this.testVectorOfUnion = testVectorOfUnion;
|
||||
}
|
||||
pack(builder) {
|
||||
const testUnion = builder.createObjectOffset(this.testUnion);
|
||||
const testVectorOfUnionType = D.createTestVectorOfUnionTypeVector(builder, this.testVectorOfUnionType);
|
||||
const testVectorOfUnion = D.createTestVectorOfUnionVector(builder, builder.createObjectOffsetList(this.testVectorOfUnion));
|
||||
return D.createD(builder, this.testUnionType, testUnion, testVectorOfUnionType, testVectorOfUnion);
|
||||
}
|
||||
constructor(
|
||||
testUnionType = ABC.NONE, testUnion = null, testVectorOfUnionType = [],
|
||||
testVectorOfUnion = []) {
|
||||
this.testUnionType = testUnionType;
|
||||
this.testUnion = testUnion;
|
||||
this.testVectorOfUnionType = testVectorOfUnionType;
|
||||
this.testVectorOfUnion = testVectorOfUnion;
|
||||
}
|
||||
pack(builder) {
|
||||
const testUnion = builder.createObjectOffset(this.testUnion);
|
||||
const testVectorOfUnionType = D.createTestVectorOfUnionTypeVector(
|
||||
builder, this.testVectorOfUnionType);
|
||||
const testVectorOfUnion = D.createTestVectorOfUnionVector(
|
||||
builder, builder.createObjectOffsetList(this.testVectorOfUnion));
|
||||
return D.createD(
|
||||
builder, this.testUnionType, testUnion, testVectorOfUnionType,
|
||||
testVectorOfUnion);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,194 +4,281 @@
|
||||
|
||||
import * as flatbuffers from 'flatbuffers';
|
||||
|
||||
import { A, AT } from '../union-underlying-type/a.js';
|
||||
import { ABC, unionToAbc, unionListToAbc } from '../union-underlying-type/abc.js';
|
||||
import { B, BT } from '../union-underlying-type/b.js';
|
||||
import { C, CT } from '../union-underlying-type/c.js';
|
||||
|
||||
import {A, AT} from '../union-underlying-type/a.js';
|
||||
import {ABC, unionListToAbc, unionToAbc} from '../union-underlying-type/abc.js';
|
||||
import {B, BT} from '../union-underlying-type/b.js';
|
||||
import {C, CT} from '../union-underlying-type/c.js';
|
||||
|
||||
export class D implements flatbuffers.IUnpackableObject<DT> {
|
||||
bb: flatbuffers.ByteBuffer|null = null;
|
||||
bb: flatbuffers.ByteBuffer | null = null;
|
||||
bb_pos = 0;
|
||||
__init(i:number, bb:flatbuffers.ByteBuffer):D {
|
||||
this.bb_pos = i;
|
||||
this.bb = bb;
|
||||
return this;
|
||||
}
|
||||
|
||||
static getRootAsD(bb:flatbuffers.ByteBuffer, obj?:D):D {
|
||||
return (obj || new D()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
|
||||
}
|
||||
|
||||
static getSizePrefixedRootAsD(bb:flatbuffers.ByteBuffer, obj?:D):D {
|
||||
bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
|
||||
return (obj || new D()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
|
||||
}
|
||||
|
||||
testUnionType():ABC {
|
||||
const offset = this.bb!.__offset(this.bb_pos, 4);
|
||||
return offset ? this.bb!.readInt32(this.bb_pos + offset) : ABC.NONE;
|
||||
}
|
||||
|
||||
testUnion<T extends flatbuffers.Table>(obj:any):any|null {
|
||||
const offset = this.bb!.__offset(this.bb_pos, 6);
|
||||
return offset ? this.bb!.__union(obj, this.bb_pos + offset) : null;
|
||||
}
|
||||
|
||||
testVectorOfUnionType(index: number):ABC|null {
|
||||
const offset = this.bb!.__offset(this.bb_pos, 8);
|
||||
return offset ? this.bb!.readInt32(this.bb!.__vector(this.bb_pos + offset) + index * 4) : null;
|
||||
}
|
||||
|
||||
testVectorOfUnionTypeLength():number {
|
||||
const offset = this.bb!.__offset(this.bb_pos, 8);
|
||||
return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
|
||||
}
|
||||
|
||||
testVectorOfUnionTypeArray():Int32Array|null {
|
||||
const offset = this.bb!.__offset(this.bb_pos, 8);
|
||||
return offset ? new Int32Array(this.bb!.bytes().buffer, this.bb!.bytes().byteOffset + this.bb!.__vector(this.bb_pos + offset), this.bb!.__vector_len(this.bb_pos + offset)) : null;
|
||||
}
|
||||
|
||||
testVectorOfUnion(index: number, obj:any):any|null {
|
||||
const offset = this.bb!.__offset(this.bb_pos, 10);
|
||||
return offset ? this.bb!.__union(obj, this.bb!.__vector(this.bb_pos + offset) + index * 4) : null;
|
||||
}
|
||||
|
||||
testVectorOfUnionLength():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 'UnionUnderlyingType.D';
|
||||
}
|
||||
|
||||
static startD(builder:flatbuffers.Builder) {
|
||||
builder.startObject(4);
|
||||
}
|
||||
|
||||
static addTestUnionType(builder:flatbuffers.Builder, testUnionType:ABC) {
|
||||
builder.addFieldInt32(0, testUnionType, ABC.NONE);
|
||||
}
|
||||
|
||||
static addTestUnion(builder:flatbuffers.Builder, testUnionOffset:flatbuffers.Offset) {
|
||||
builder.addFieldOffset(1, testUnionOffset, 0);
|
||||
}
|
||||
|
||||
static addTestVectorOfUnionType(builder:flatbuffers.Builder, testVectorOfUnionTypeOffset:flatbuffers.Offset) {
|
||||
builder.addFieldOffset(2, testVectorOfUnionTypeOffset, 0);
|
||||
}
|
||||
|
||||
static createTestVectorOfUnionTypeVector(builder:flatbuffers.Builder, data:ABC[]):flatbuffers.Offset {
|
||||
builder.startVector(4, data.length, 4);
|
||||
for (let i = data.length - 1; i >= 0; i--) {
|
||||
builder.addInt32(data[i]!);
|
||||
__init(i: number, bb: flatbuffers.ByteBuffer): D {
|
||||
this.bb_pos = i;
|
||||
this.bb = bb;
|
||||
return this;
|
||||
}
|
||||
return builder.endVector();
|
||||
}
|
||||
|
||||
static startTestVectorOfUnionTypeVector(builder:flatbuffers.Builder, numElems:number) {
|
||||
builder.startVector(4, numElems, 4);
|
||||
}
|
||||
|
||||
static addTestVectorOfUnion(builder:flatbuffers.Builder, testVectorOfUnionOffset:flatbuffers.Offset) {
|
||||
builder.addFieldOffset(3, testVectorOfUnionOffset, 0);
|
||||
}
|
||||
|
||||
static createTestVectorOfUnionVector(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]!);
|
||||
static getRootAsD(bb: flatbuffers.ByteBuffer, obj?: D): D {
|
||||
return (obj || new D()).__init(
|
||||
bb.readInt32(bb.position()) + bb.position(),
|
||||
bb,
|
||||
);
|
||||
}
|
||||
return builder.endVector();
|
||||
}
|
||||
|
||||
static startTestVectorOfUnionVector(builder:flatbuffers.Builder, numElems:number) {
|
||||
builder.startVector(4, numElems, 4);
|
||||
}
|
||||
static getSizePrefixedRootAsD(bb: flatbuffers.ByteBuffer, obj?: D): D {
|
||||
bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
|
||||
return (obj || new D()).__init(
|
||||
bb.readInt32(bb.position()) + bb.position(),
|
||||
bb,
|
||||
);
|
||||
}
|
||||
|
||||
static endD(builder:flatbuffers.Builder):flatbuffers.Offset {
|
||||
const offset = builder.endObject();
|
||||
return offset;
|
||||
}
|
||||
testUnionType(): ABC {
|
||||
const offset = this.bb!.__offset(this.bb_pos, 4);
|
||||
return offset ? this.bb!.readInt32(this.bb_pos + offset) : ABC.NONE;
|
||||
}
|
||||
|
||||
static createD(builder:flatbuffers.Builder, testUnionType:ABC, testUnionOffset:flatbuffers.Offset, testVectorOfUnionTypeOffset:flatbuffers.Offset, testVectorOfUnionOffset:flatbuffers.Offset):flatbuffers.Offset {
|
||||
D.startD(builder);
|
||||
D.addTestUnionType(builder, testUnionType);
|
||||
D.addTestUnion(builder, testUnionOffset);
|
||||
D.addTestVectorOfUnionType(builder, testVectorOfUnionTypeOffset);
|
||||
D.addTestVectorOfUnion(builder, testVectorOfUnionOffset);
|
||||
return D.endD(builder);
|
||||
}
|
||||
testUnion<T extends flatbuffers.Table>(obj: any): any | null {
|
||||
const offset = this.bb!.__offset(this.bb_pos, 6);
|
||||
return offset ? this.bb!.__union(obj, this.bb_pos + offset) : null;
|
||||
}
|
||||
|
||||
unpack(): DT {
|
||||
return new DT(
|
||||
this.testUnionType(),
|
||||
(() => {
|
||||
const temp = unionToAbc(this.testUnionType(), this.testUnion.bind(this));
|
||||
if(temp === null) { return null; }
|
||||
return temp.unpack()
|
||||
})(),
|
||||
this.bb!.createScalarList<ABC>(this.testVectorOfUnionType.bind(this), this.testVectorOfUnionTypeLength()),
|
||||
(() => {
|
||||
const ret: (AT|BT|CT)[] = [];
|
||||
for(let targetEnumIndex = 0; targetEnumIndex < this.testVectorOfUnionTypeLength(); ++targetEnumIndex) {
|
||||
const targetEnum = this.testVectorOfUnionType(targetEnumIndex);
|
||||
if(targetEnum === null || ABC[targetEnum!] === 'NONE') { continue; }
|
||||
testVectorOfUnionType(index: number): ABC | null {
|
||||
const offset = this.bb!.__offset(this.bb_pos, 8);
|
||||
return offset
|
||||
? this.bb!.readInt32(this.bb!.__vector(this.bb_pos + offset) + index * 4)
|
||||
: null;
|
||||
}
|
||||
|
||||
const temp = unionListToAbc(targetEnum, this.testVectorOfUnion.bind(this), targetEnumIndex);
|
||||
if(temp === null) { continue; }
|
||||
ret.push(temp.unpack());
|
||||
testVectorOfUnionTypeLength(): number {
|
||||
const offset = this.bb!.__offset(this.bb_pos, 8);
|
||||
return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
|
||||
}
|
||||
|
||||
testVectorOfUnionTypeArray(): Int32Array | null {
|
||||
const offset = this.bb!.__offset(this.bb_pos, 8);
|
||||
return offset
|
||||
? new Int32Array(
|
||||
this.bb!.bytes().buffer,
|
||||
this.bb!.bytes().byteOffset + this.bb!.__vector(this.bb_pos + offset),
|
||||
this.bb!.__vector_len(this.bb_pos + offset),
|
||||
)
|
||||
: null;
|
||||
}
|
||||
|
||||
testVectorOfUnion(index: number, obj: any): any | null {
|
||||
const offset = this.bb!.__offset(this.bb_pos, 10);
|
||||
return offset
|
||||
? this.bb!.__union(
|
||||
obj,
|
||||
this.bb!.__vector(this.bb_pos + offset) + index * 4,
|
||||
)
|
||||
: null;
|
||||
}
|
||||
|
||||
testVectorOfUnionLength(): 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 'UnionUnderlyingType.D';
|
||||
}
|
||||
|
||||
static startD(builder: flatbuffers.Builder) {
|
||||
builder.startObject(4);
|
||||
}
|
||||
|
||||
static addTestUnionType(builder: flatbuffers.Builder, testUnionType: ABC) {
|
||||
builder.addFieldInt32(0, testUnionType, ABC.NONE);
|
||||
}
|
||||
|
||||
static addTestUnion(
|
||||
builder: flatbuffers.Builder,
|
||||
testUnionOffset: flatbuffers.Offset,
|
||||
) {
|
||||
builder.addFieldOffset(1, testUnionOffset, 0);
|
||||
}
|
||||
|
||||
static addTestVectorOfUnionType(
|
||||
builder: flatbuffers.Builder,
|
||||
testVectorOfUnionTypeOffset: flatbuffers.Offset,
|
||||
) {
|
||||
builder.addFieldOffset(2, testVectorOfUnionTypeOffset, 0);
|
||||
}
|
||||
|
||||
static createTestVectorOfUnionTypeVector(
|
||||
builder: flatbuffers.Builder,
|
||||
data: ABC[],
|
||||
): flatbuffers.Offset {
|
||||
builder.startVector(4, data.length, 4);
|
||||
for (let i = data.length - 1; i >= 0; i--) {
|
||||
builder.addInt32(data[i]!);
|
||||
}
|
||||
return ret;
|
||||
})()
|
||||
);
|
||||
}
|
||||
return builder.endVector();
|
||||
}
|
||||
|
||||
static startTestVectorOfUnionTypeVector(
|
||||
builder: flatbuffers.Builder,
|
||||
numElems: number,
|
||||
) {
|
||||
builder.startVector(4, numElems, 4);
|
||||
}
|
||||
|
||||
unpackTo(_o: DT): void {
|
||||
_o.testUnionType = this.testUnionType();
|
||||
_o.testUnion = (() => {
|
||||
const temp = unionToAbc(this.testUnionType(), this.testUnion.bind(this));
|
||||
if(temp === null) { return null; }
|
||||
return temp.unpack()
|
||||
})();
|
||||
_o.testVectorOfUnionType = this.bb!.createScalarList<ABC>(this.testVectorOfUnionType.bind(this), this.testVectorOfUnionTypeLength());
|
||||
_o.testVectorOfUnion = (() => {
|
||||
const ret: (AT|BT|CT)[] = [];
|
||||
for(let targetEnumIndex = 0; targetEnumIndex < this.testVectorOfUnionTypeLength(); ++targetEnumIndex) {
|
||||
const targetEnum = this.testVectorOfUnionType(targetEnumIndex);
|
||||
if(targetEnum === null || ABC[targetEnum!] === 'NONE') { continue; }
|
||||
static addTestVectorOfUnion(
|
||||
builder: flatbuffers.Builder,
|
||||
testVectorOfUnionOffset: flatbuffers.Offset,
|
||||
) {
|
||||
builder.addFieldOffset(3, testVectorOfUnionOffset, 0);
|
||||
}
|
||||
|
||||
const temp = unionListToAbc(targetEnum, this.testVectorOfUnion.bind(this), targetEnumIndex);
|
||||
if(temp === null) { continue; }
|
||||
ret.push(temp.unpack());
|
||||
static createTestVectorOfUnionVector(
|
||||
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 ret;
|
||||
})();
|
||||
}
|
||||
return builder.endVector();
|
||||
}
|
||||
|
||||
static startTestVectorOfUnionVector(
|
||||
builder: flatbuffers.Builder,
|
||||
numElems: number,
|
||||
) {
|
||||
builder.startVector(4, numElems, 4);
|
||||
}
|
||||
|
||||
static endD(builder: flatbuffers.Builder): flatbuffers.Offset {
|
||||
const offset = builder.endObject();
|
||||
return offset;
|
||||
}
|
||||
|
||||
static createD(
|
||||
builder: flatbuffers.Builder,
|
||||
testUnionType: ABC,
|
||||
testUnionOffset: flatbuffers.Offset,
|
||||
testVectorOfUnionTypeOffset: flatbuffers.Offset,
|
||||
testVectorOfUnionOffset: flatbuffers.Offset,
|
||||
): flatbuffers.Offset {
|
||||
D.startD(builder);
|
||||
D.addTestUnionType(builder, testUnionType);
|
||||
D.addTestUnion(builder, testUnionOffset);
|
||||
D.addTestVectorOfUnionType(builder, testVectorOfUnionTypeOffset);
|
||||
D.addTestVectorOfUnion(builder, testVectorOfUnionOffset);
|
||||
return D.endD(builder);
|
||||
}
|
||||
|
||||
unpack(): DT {
|
||||
return new DT(
|
||||
this.testUnionType(),
|
||||
(() => {
|
||||
const temp = unionToAbc(
|
||||
this.testUnionType(),
|
||||
this.testUnion.bind(this),
|
||||
);
|
||||
if (temp === null) {
|
||||
return null;
|
||||
}
|
||||
return temp.unpack();
|
||||
})(),
|
||||
this.bb!.createScalarList<ABC>(
|
||||
this.testVectorOfUnionType.bind(this),
|
||||
this.testVectorOfUnionTypeLength(),
|
||||
),
|
||||
(() => {
|
||||
const ret: (AT | BT | CT)[] = [];
|
||||
for (
|
||||
let targetEnumIndex = 0;
|
||||
targetEnumIndex < this.testVectorOfUnionTypeLength();
|
||||
++targetEnumIndex
|
||||
) {
|
||||
const targetEnum = this.testVectorOfUnionType(targetEnumIndex);
|
||||
if (targetEnum === null || ABC[targetEnum!] === 'NONE') {
|
||||
continue;
|
||||
}
|
||||
|
||||
const temp = unionListToAbc(
|
||||
targetEnum,
|
||||
this.testVectorOfUnion.bind(this),
|
||||
targetEnumIndex,
|
||||
);
|
||||
if (temp === null) {
|
||||
continue;
|
||||
}
|
||||
ret.push(temp.unpack());
|
||||
}
|
||||
return ret;
|
||||
})(),
|
||||
);
|
||||
}
|
||||
|
||||
unpackTo(_o: DT): void {
|
||||
_o.testUnionType = this.testUnionType();
|
||||
_o.testUnion = (() => {
|
||||
const temp = unionToAbc(this.testUnionType(), this.testUnion.bind(this));
|
||||
if (temp === null) {
|
||||
return null;
|
||||
}
|
||||
return temp.unpack();
|
||||
})();
|
||||
_o.testVectorOfUnionType = this.bb!.createScalarList<ABC>(
|
||||
this.testVectorOfUnionType.bind(this),
|
||||
this.testVectorOfUnionTypeLength(),
|
||||
);
|
||||
_o.testVectorOfUnion = (() => {
|
||||
const ret: (AT | BT | CT)[] = [];
|
||||
for (
|
||||
let targetEnumIndex = 0;
|
||||
targetEnumIndex < this.testVectorOfUnionTypeLength();
|
||||
++targetEnumIndex
|
||||
) {
|
||||
const targetEnum = this.testVectorOfUnionType(targetEnumIndex);
|
||||
if (targetEnum === null || ABC[targetEnum!] === 'NONE') {
|
||||
continue;
|
||||
}
|
||||
|
||||
const temp = unionListToAbc(
|
||||
targetEnum,
|
||||
this.testVectorOfUnion.bind(this),
|
||||
targetEnumIndex,
|
||||
);
|
||||
if (temp === null) {
|
||||
continue;
|
||||
}
|
||||
ret.push(temp.unpack());
|
||||
}
|
||||
return ret;
|
||||
})();
|
||||
}
|
||||
}
|
||||
|
||||
export class DT implements flatbuffers.IGeneratedObject {
|
||||
constructor(
|
||||
public testUnionType: ABC = ABC.NONE,
|
||||
public testUnion: AT|BT|CT|null = null,
|
||||
public testVectorOfUnionType: (ABC)[] = [],
|
||||
public testVectorOfUnion: (AT|BT|CT)[] = []
|
||||
){}
|
||||
constructor(
|
||||
public testUnionType: ABC = ABC.NONE,
|
||||
public testUnion: AT | BT | CT | null = null,
|
||||
public testVectorOfUnionType: ABC[] = [],
|
||||
public testVectorOfUnion: (AT | BT | CT)[] = [],
|
||||
) {}
|
||||
|
||||
pack(builder: flatbuffers.Builder): flatbuffers.Offset {
|
||||
const testUnion = builder.createObjectOffset(this.testUnion);
|
||||
const testVectorOfUnionType = D.createTestVectorOfUnionTypeVector(
|
||||
builder,
|
||||
this.testVectorOfUnionType,
|
||||
);
|
||||
const testVectorOfUnion = D.createTestVectorOfUnionVector(
|
||||
builder,
|
||||
builder.createObjectOffsetList(this.testVectorOfUnion),
|
||||
);
|
||||
|
||||
pack(builder:flatbuffers.Builder): flatbuffers.Offset {
|
||||
const testUnion = builder.createObjectOffset(this.testUnion);
|
||||
const testVectorOfUnionType = D.createTestVectorOfUnionTypeVector(builder, this.testVectorOfUnionType);
|
||||
const testVectorOfUnion = D.createTestVectorOfUnionVector(builder, builder.createObjectOffsetList(this.testVectorOfUnion));
|
||||
|
||||
return D.createD(builder,
|
||||
this.testUnionType,
|
||||
testUnion,
|
||||
testVectorOfUnionType,
|
||||
testVectorOfUnion
|
||||
);
|
||||
}
|
||||
return D.createD(
|
||||
builder,
|
||||
this.testUnionType,
|
||||
testUnion,
|
||||
testVectorOfUnionType,
|
||||
testVectorOfUnion,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user