summaryrefslogtreecommitdiff
path: root/tests/MyGame/Example/Monster.py
diff options
context:
space:
mode:
authorJaemin Park <ppparkje@naver.com>2019-09-06 02:22:04 +0900
committerWouter van Oortmerssen <aardappel@gmail.com>2019-09-05 10:22:04 -0700
commit4b870aca98eca22c56faa3245ada7014752f7b2c (patch)
tree542fe3efaf96c12031f28011111c933b74a30fee /tests/MyGame/Example/Monster.py
parentd0e3870c0f74f85d545242d4e09921ee334b0982 (diff)
downloadflatbuffers-4b870aca98eca22c56faa3245ada7014752f7b2c.tar.gz
flatbuffers-4b870aca98eca22c56faa3245ada7014752f7b2c.tar.bz2
flatbuffers-4b870aca98eca22c56faa3245ada7014752f7b2c.zip
[Javascript] Fix syntax error for signed enum (#5503)
* wrap quotes to enum name map to prevent syntax errorn when enum value is negative * Add a test that covers signed enum case
Diffstat (limited to 'tests/MyGame/Example/Monster.py')
-rw-r--r--tests/MyGame/Example/Monster.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/tests/MyGame/Example/Monster.py b/tests/MyGame/Example/Monster.py
index 5baf64d4..fe5fb489 100644
--- a/tests/MyGame/Example/Monster.py
+++ b/tests/MyGame/Example/Monster.py
@@ -620,7 +620,14 @@ class Monster(object):
return self._tab.VectorLen(o)
return 0
-def MonsterStart(builder): builder.StartObject(48)
+ # Monster
+ def SignedEnum(self):
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(100))
+ if o != 0:
+ return self._tab.Get(flatbuffers.number_types.Int8Flags, o + self._tab.Pos)
+ return -1
+
+def MonsterStart(builder): builder.StartObject(49)
def MonsterAddPos(builder, pos): builder.PrependStructSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(pos), 0)
def MonsterAddMana(builder, mana): builder.PrependInt16Slot(1, mana, 150)
def MonsterAddHp(builder, hp): builder.PrependInt16Slot(2, hp, 100)
@@ -686,4 +693,5 @@ def MonsterAddAnyAmbiguousType(builder, anyAmbiguousType): builder.PrependUint8S
def MonsterAddAnyAmbiguous(builder, anyAmbiguous): builder.PrependUOffsetTRelativeSlot(46, flatbuffers.number_types.UOffsetTFlags.py_type(anyAmbiguous), 0)
def MonsterAddVectorOfEnums(builder, vectorOfEnums): builder.PrependUOffsetTRelativeSlot(47, flatbuffers.number_types.UOffsetTFlags.py_type(vectorOfEnums), 0)
def MonsterStartVectorOfEnumsVector(builder, numElems): return builder.StartVector(1, numElems, 1)
+def MonsterAddSignedEnum(builder, signedEnum): builder.PrependInt8Slot(48, signedEnum, -1)
def MonsterEnd(builder): return builder.EndObject()