Austin Schuh | e89fa2d | 2019-08-14 20:24:23 -0700 | [diff] [blame] | 1 | # automatically generated by the FlatBuffers compiler, do not modify |
| 2 | |
| 3 | # namespace: Example |
| 4 | |
| 5 | import flatbuffers |
Austin Schuh | 272c613 | 2020-11-14 16:37:52 -0800 | [diff] [blame] | 6 | from flatbuffers.compat import import_numpy |
| 7 | np = import_numpy() |
Austin Schuh | e89fa2d | 2019-08-14 20:24:23 -0700 | [diff] [blame] | 8 | |
| 9 | class TestSimpleTableWithEnum(object): |
| 10 | __slots__ = ['_tab'] |
| 11 | |
| 12 | @classmethod |
James Kuszmaul | 8e62b02 | 2022-03-22 09:33:25 -0700 | [diff] [blame] | 13 | def GetRootAs(cls, buf, offset=0): |
Austin Schuh | e89fa2d | 2019-08-14 20:24:23 -0700 | [diff] [blame] | 14 | n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) |
| 15 | x = TestSimpleTableWithEnum() |
| 16 | x.Init(buf, n + offset) |
| 17 | return x |
| 18 | |
| 19 | @classmethod |
James Kuszmaul | 8e62b02 | 2022-03-22 09:33:25 -0700 | [diff] [blame] | 20 | def GetRootAsTestSimpleTableWithEnum(cls, buf, offset=0): |
| 21 | """This method is deprecated. Please switch to GetRootAs.""" |
| 22 | return cls.GetRootAs(buf, offset) |
| 23 | @classmethod |
Austin Schuh | e89fa2d | 2019-08-14 20:24:23 -0700 | [diff] [blame] | 24 | def TestSimpleTableWithEnumBufferHasIdentifier(cls, buf, offset, size_prefixed=False): |
| 25 | return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x4D\x4F\x4E\x53", size_prefixed=size_prefixed) |
| 26 | |
| 27 | # TestSimpleTableWithEnum |
| 28 | def Init(self, buf, pos): |
| 29 | self._tab = flatbuffers.table.Table(buf, pos) |
| 30 | |
| 31 | # TestSimpleTableWithEnum |
| 32 | def Color(self): |
| 33 | o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) |
| 34 | if o != 0: |
| 35 | return self._tab.Get(flatbuffers.number_types.Uint8Flags, o + self._tab.Pos) |
| 36 | return 2 |
| 37 | |
| 38 | def TestSimpleTableWithEnumStart(builder): builder.StartObject(1) |
James Kuszmaul | 8e62b02 | 2022-03-22 09:33:25 -0700 | [diff] [blame] | 39 | def Start(builder): |
| 40 | return TestSimpleTableWithEnumStart(builder) |
Austin Schuh | e89fa2d | 2019-08-14 20:24:23 -0700 | [diff] [blame] | 41 | def TestSimpleTableWithEnumAddColor(builder, color): builder.PrependUint8Slot(0, color, 2) |
James Kuszmaul | 8e62b02 | 2022-03-22 09:33:25 -0700 | [diff] [blame] | 42 | def AddColor(builder, color): |
| 43 | return TestSimpleTableWithEnumAddColor(builder, color) |
Austin Schuh | e89fa2d | 2019-08-14 20:24:23 -0700 | [diff] [blame] | 44 | def TestSimpleTableWithEnumEnd(builder): return builder.EndObject() |
James Kuszmaul | 8e62b02 | 2022-03-22 09:33:25 -0700 | [diff] [blame] | 45 | def End(builder): |
| 46 | return TestSimpleTableWithEnumEnd(builder) |
Austin Schuh | 272c613 | 2020-11-14 16:37:52 -0800 | [diff] [blame] | 47 | |
| 48 | class TestSimpleTableWithEnumT(object): |
| 49 | |
| 50 | # TestSimpleTableWithEnumT |
| 51 | def __init__(self): |
| 52 | self.color = 2 # type: int |
| 53 | |
| 54 | @classmethod |
| 55 | def InitFromBuf(cls, buf, pos): |
| 56 | testSimpleTableWithEnum = TestSimpleTableWithEnum() |
| 57 | testSimpleTableWithEnum.Init(buf, pos) |
| 58 | return cls.InitFromObj(testSimpleTableWithEnum) |
| 59 | |
| 60 | @classmethod |
James Kuszmaul | 3b15b0c | 2022-11-08 14:03:16 -0800 | [diff] [blame^] | 61 | def InitFromPackedBuf(cls, buf, pos=0): |
| 62 | n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos) |
| 63 | return cls.InitFromBuf(buf, pos+n) |
| 64 | |
| 65 | @classmethod |
Austin Schuh | 272c613 | 2020-11-14 16:37:52 -0800 | [diff] [blame] | 66 | def InitFromObj(cls, testSimpleTableWithEnum): |
| 67 | x = TestSimpleTableWithEnumT() |
| 68 | x._UnPack(testSimpleTableWithEnum) |
| 69 | return x |
| 70 | |
| 71 | # TestSimpleTableWithEnumT |
| 72 | def _UnPack(self, testSimpleTableWithEnum): |
| 73 | if testSimpleTableWithEnum is None: |
| 74 | return |
| 75 | self.color = testSimpleTableWithEnum.Color() |
| 76 | |
| 77 | # TestSimpleTableWithEnumT |
| 78 | def Pack(self, builder): |
| 79 | TestSimpleTableWithEnumStart(builder) |
| 80 | TestSimpleTableWithEnumAddColor(builder, self.color) |
| 81 | testSimpleTableWithEnum = TestSimpleTableWithEnumEnd(builder) |
| 82 | return testSimpleTableWithEnum |