# automatically generated by the FlatBuffers compiler, do not modify

# namespace: MNN

import flatbuffers
from flatbuffers.compat import import_numpy
np = import_numpy()

class Region(object):
    __slots__ = ['_tab']

    @classmethod
    def GetRootAs(cls, buf, offset=0):
        n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
        x = Region()
        x.Init(buf, n + offset)
        return x

    @classmethod
    def GetRootAsRegion(cls, buf, offset=0):
        """This method is deprecated. Please switch to GetRootAs."""
        return cls.GetRootAs(buf, offset)
    # Region
    def Init(self, buf, pos):
        self._tab = flatbuffers.table.Table(buf, pos)

    # Region
    def Src(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
        if o != 0:
            x = self._tab.Indirect(o + self._tab.Pos)
            obj = View()
            obj.Init(self._tab.Bytes, x)
            return obj
        return None

    # Region
    def Dst(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
        if o != 0:
            x = self._tab.Indirect(o + self._tab.Pos)
            obj = View()
            obj.Init(self._tab.Bytes, x)
            return obj
        return None

    # Region
    def Size(self, j):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
        if o != 0:
            a = self._tab.Vector(o)
            return self._tab.Get(flatbuffers.number_types.Int32Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 4))
        return 0

    # Region
    def SizeAsNumpy(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
        if o != 0:
            return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Int32Flags, o)
        return 0

    # Region
    def SizeLength(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
        if o != 0:
            return self._tab.VectorLen(o)
        return 0

    # Region
    def SizeIsNone(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
        return o == 0

    # Region
    def Origin(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10))
        if o != 0:
            return self._tab.Get(flatbuffers.number_types.Int32Flags, o + self._tab.Pos)
        return 0

def RegionStart(builder): builder.StartObject(4)
def Start(builder):
    return RegionStart(builder)
def RegionAddSrc(builder, src): builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(src), 0)
def AddSrc(builder, src):
    return RegionAddSrc(builder, src)
def RegionAddDst(builder, dst): builder.PrependUOffsetTRelativeSlot(1, flatbuffers.number_types.UOffsetTFlags.py_type(dst), 0)
def AddDst(builder, dst):
    return RegionAddDst(builder, dst)
def RegionAddSize(builder, size): builder.PrependUOffsetTRelativeSlot(2, flatbuffers.number_types.UOffsetTFlags.py_type(size), 0)
def AddSize(builder, size):
    return RegionAddSize(builder, size)
def RegionStartSizeVector(builder, numElems): return builder.StartVector(4, numElems, 4)
def StartSizeVector(builder, numElems):
    return RegionStartSizeVector(builder, numElems)
def RegionAddOrigin(builder, origin): builder.PrependInt32Slot(3, origin, 0)
def AddOrigin(builder, origin):
    return RegionAddOrigin(builder, origin)
def RegionEnd(builder): return builder.EndObject()
def End(builder):
    return RegionEnd(builder)