// automatically generated by the FlatBuffers compiler, do not modify
import * as flatbuffers from 'flatbuffers';
import { BaseType } from '../reflection/base-type.js';
export class Type {
    constructor() {
        this.bb = null;
        this.bb_pos = 0;
    }
    __init(i, bb) {
        this.bb_pos = i;
        this.bb = bb;
        return this;
    }
    static getRootAsType(bb, obj) {
        return (obj || new Type()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
    }
    static getSizePrefixedRootAsType(bb, obj) {
        bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
        return (obj || new Type()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
    }
    baseType() {
        const offset = this.bb.__offset(this.bb_pos, 4);
        return offset ? this.bb.readInt8(this.bb_pos + offset) : BaseType.None;
    }
    mutate_base_type(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;
    }
    element() {
        const offset = this.bb.__offset(this.bb_pos, 6);
        return offset ? this.bb.readInt8(this.bb_pos + offset) : BaseType.None;
    }
    mutate_element(value) {
        const offset = this.bb.__offset(this.bb_pos, 6);
        if (offset === 0) {
            return false;
        }
        this.bb.writeInt8(this.bb_pos + offset, value);
        return true;
    }
    index() {
        const offset = this.bb.__offset(this.bb_pos, 8);
        return offset ? this.bb.readInt32(this.bb_pos + offset) : -1;
    }
    mutate_index(value) {
        const offset = this.bb.__offset(this.bb_pos, 8);
        if (offset === 0) {
            return false;
        }
        this.bb.writeInt32(this.bb_pos + offset, value);
        return true;
    }
    fixedLength() {
        const offset = this.bb.__offset(this.bb_pos, 10);
        return offset ? this.bb.readUint16(this.bb_pos + offset) : 0;
    }
    mutate_fixed_length(value) {
        const offset = this.bb.__offset(this.bb_pos, 10);
        if (offset === 0) {
            return false;
        }
        this.bb.writeUint16(this.bb_pos + offset, value);
        return true;
    }
    /**
     * The size (octets) of the `base_type` field.
     */
    baseSize() {
        const offset = this.bb.__offset(this.bb_pos, 12);
        return offset ? this.bb.readUint32(this.bb_pos + offset) : 4;
    }
    mutate_base_size(value) {
        const offset = this.bb.__offset(this.bb_pos, 12);
        if (offset === 0) {
            return false;
        }
        this.bb.writeUint32(this.bb_pos + offset, value);
        return true;
    }
    /**
     * The size (octets) of the `element` field, if present.
     */
    elementSize() {
        const offset = this.bb.__offset(this.bb_pos, 14);
        return offset ? this.bb.readUint32(this.bb_pos + offset) : 0;
    }
    mutate_element_size(value) {
        const offset = this.bb.__offset(this.bb_pos, 14);
        if (offset === 0) {
            return false;
        }
        this.bb.writeUint32(this.bb_pos + offset, value);
        return true;
    }
    static getFullyQualifiedName() {
        return 'reflection.Type';
    }
    static startType(builder) {
        builder.startObject(6);
    }
    static addBaseType(builder, baseType) {
        builder.addFieldInt8(0, baseType, BaseType.None);
    }
    static addElement(builder, element) {
        builder.addFieldInt8(1, element, BaseType.None);
    }
    static addIndex(builder, index) {
        builder.addFieldInt32(2, index, -1);
    }
    static addFixedLength(builder, fixedLength) {
        builder.addFieldInt16(3, fixedLength, 0);
    }
    static addBaseSize(builder, baseSize) {
        builder.addFieldInt32(4, baseSize, 4);
    }
    static addElementSize(builder, elementSize) {
        builder.addFieldInt32(5, elementSize, 0);
    }
    static endType(builder) {
        const offset = builder.endObject();
        return offset;
    }
    static createType(builder, baseType, element, index, fixedLength, baseSize, elementSize) {
        Type.startType(builder);
        Type.addBaseType(builder, baseType);
        Type.addElement(builder, element);
        Type.addIndex(builder, index);
        Type.addFixedLength(builder, fixedLength);
        Type.addBaseSize(builder, baseSize);
        Type.addElementSize(builder, elementSize);
        return Type.endType(builder);
    }
    unpack() {
        return new TypeT(this.baseType(), this.element(), this.index(), this.fixedLength(), this.baseSize(), this.elementSize());
    }
    unpackTo(_o) {
        _o.baseType = this.baseType();
        _o.element = this.element();
        _o.index = this.index();
        _o.fixedLength = this.fixedLength();
        _o.baseSize = this.baseSize();
        _o.elementSize = this.elementSize();
    }
}
export class TypeT {
    constructor(baseType = BaseType.None, element = BaseType.None, index = -1, fixedLength = 0, baseSize = 4, elementSize = 0) {
        this.baseType = baseType;
        this.element = element;
        this.index = index;
        this.fixedLength = fixedLength;
        this.baseSize = baseSize;
        this.elementSize = elementSize;
    }
    pack(builder) {
        return Type.createType(builder, this.baseType, this.element, this.index, this.fixedLength, this.baseSize, this.elementSize);
    }
}
