diff options
author | Anass Al <anassinator@fb.com> | 2020-09-28 08:54:50 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-28 08:54:50 -0700 |
commit | 689bfafa7e8061dc25f0f4b5e7017a1fecb3ceac (patch) | |
tree | a8e4f5afc32430ba147de9c7dd7aba6517bf3523 /tests/MyGame/Example | |
parent | 641309a5bf8370206d5fffea7521270952bb655f (diff) | |
download | flatbuffers-689bfafa7e8061dc25f0f4b5e7017a1fecb3ceac.tar.gz flatbuffers-689bfafa7e8061dc25f0f4b5e7017a1fecb3ceac.tar.bz2 flatbuffers-689bfafa7e8061dc25f0f4b5e7017a1fecb3ceac.zip |
[Python/JS/TS] Codegen SizeOf method for structs (#6136)
* [Python] Codegen SizeOf classmethod for structs
This codegens a `SizeOf()` classmethod for all structs since we can't
determine the size of a FlatBuffer generated struct from Python otherwise.
* [JS/TS] Codegen sizeOf static method for structs
This codegens a `sizeOf()` static method for all structs since we can't
determine the size of a FlatBuffer generated struct from JavaScript or
TypeScript otherwise.
Diffstat (limited to 'tests/MyGame/Example')
-rw-r--r-- | tests/MyGame/Example/Ability.py | 4 | ||||
-rw-r--r-- | tests/MyGame/Example/ArrayStruct.py | 4 | ||||
-rw-r--r-- | tests/MyGame/Example/NestedStruct.py | 4 | ||||
-rw-r--r-- | tests/MyGame/Example/Test.py | 4 | ||||
-rw-r--r-- | tests/MyGame/Example/Vec3.py | 4 |
5 files changed, 20 insertions, 0 deletions
diff --git a/tests/MyGame/Example/Ability.py b/tests/MyGame/Example/Ability.py index 2cc916bd..e57dfd74 100644 --- a/tests/MyGame/Example/Ability.py +++ b/tests/MyGame/Example/Ability.py @@ -9,6 +9,10 @@ np = import_numpy() class Ability(object): __slots__ = ['_tab'] + @classmethod + def SizeOf(cls): + return 8 + # Ability def Init(self, buf, pos): self._tab = flatbuffers.table.Table(buf, pos) diff --git a/tests/MyGame/Example/ArrayStruct.py b/tests/MyGame/Example/ArrayStruct.py index 50f136df..c80bf688 100644 --- a/tests/MyGame/Example/ArrayStruct.py +++ b/tests/MyGame/Example/ArrayStruct.py @@ -9,6 +9,10 @@ np = import_numpy() class ArrayStruct(object): __slots__ = ['_tab'] + @classmethod + def SizeOf(cls): + return 160 + # ArrayStruct def Init(self, buf, pos): self._tab = flatbuffers.table.Table(buf, pos) diff --git a/tests/MyGame/Example/NestedStruct.py b/tests/MyGame/Example/NestedStruct.py index a66cee01..a9db014f 100644 --- a/tests/MyGame/Example/NestedStruct.py +++ b/tests/MyGame/Example/NestedStruct.py @@ -9,6 +9,10 @@ np = import_numpy() class NestedStruct(object): __slots__ = ['_tab'] + @classmethod + def SizeOf(cls): + return 32 + # NestedStruct def Init(self, buf, pos): self._tab = flatbuffers.table.Table(buf, pos) diff --git a/tests/MyGame/Example/Test.py b/tests/MyGame/Example/Test.py index 576a656e..8357ec20 100644 --- a/tests/MyGame/Example/Test.py +++ b/tests/MyGame/Example/Test.py @@ -9,6 +9,10 @@ np = import_numpy() class Test(object): __slots__ = ['_tab'] + @classmethod + def SizeOf(cls): + return 4 + # Test def Init(self, buf, pos): self._tab = flatbuffers.table.Table(buf, pos) diff --git a/tests/MyGame/Example/Vec3.py b/tests/MyGame/Example/Vec3.py index 5c91a7d3..69cd511f 100644 --- a/tests/MyGame/Example/Vec3.py +++ b/tests/MyGame/Example/Vec3.py @@ -9,6 +9,10 @@ np = import_numpy() class Vec3(object): __slots__ = ['_tab'] + @classmethod + def SizeOf(cls): + return 32 + # Vec3 def Init(self, buf, pos): self._tab = flatbuffers.table.Table(buf, pos) |