summaryrefslogtreecommitdiff
path: root/tests/namespace_test/NamespaceA/NamespaceB
diff options
context:
space:
mode:
authorVladimir Glavnyy <31897320+vglavnyy@users.noreply.github.com>2019-12-24 03:13:48 +0700
committerWouter van Oortmerssen <aardappel@gmail.com>2019-12-23 12:13:48 -0800
commit44bf719883248a392e04d9cebecdedb00cdd393c (patch)
tree6f62a383ee5612c3755811b62dd3270c3cb6e481 /tests/namespace_test/NamespaceA/NamespaceB
parent3e8f15df908c31b4c52308b621fed490cbac2ccc (diff)
downloadflatbuffers-44bf719883248a392e04d9cebecdedb00cdd393c.tar.gz
flatbuffers-44bf719883248a392e04d9cebecdedb00cdd393c.tar.bz2
flatbuffers-44bf719883248a392e04d9cebecdedb00cdd393c.zip
Add flatc '--cpp_std' switch (#5656)
* Add flatc '--cpp_std' switch and sandbox for C++17 code generator - Added 'flac --cpp_std legacy' for compatibility with old compilers (VS2010); - Added experimental switch 'flac --cpp_std c++17' for future development; - Added C++17 sandbox test_cpp17.cpp; - C++ code generator generates enums with explicit underlying type to avoid problems with the forward and backward schema compatibility; - Adjusted CMakeLists.txt, CI and generate code scripts to support of introduced '--cpp_std'; * Fix --cpp_std values: c++0x, c++11, c++17 * Add 'cpp::CppStandard' enum * Add testing engine into test_cpp17 * Rebase to upstream/master * Set default '--cpp-std C++0x' * Fix code generation (--cpp_std C++11) in CMakeLists.txt - Fix dependency declaration of grpctest target * Revert --cpp-std for the tests from explicit C++11 to flatc default value (C++0x)
Diffstat (limited to 'tests/namespace_test/NamespaceA/NamespaceB')
-rw-r--r--tests/namespace_test/NamespaceA/NamespaceB/StructInNestedNS.go21
-rw-r--r--tests/namespace_test/NamespaceA/NamespaceB/StructInNestedNS.py31
-rw-r--r--tests/namespace_test/NamespaceA/NamespaceB/TableInNestedNS.go22
-rw-r--r--tests/namespace_test/NamespaceA/NamespaceB/TableInNestedNS.py32
4 files changed, 106 insertions, 0 deletions
diff --git a/tests/namespace_test/NamespaceA/NamespaceB/StructInNestedNS.go b/tests/namespace_test/NamespaceA/NamespaceB/StructInNestedNS.go
index e985fbf7..fe9255e3 100644
--- a/tests/namespace_test/NamespaceA/NamespaceB/StructInNestedNS.go
+++ b/tests/namespace_test/NamespaceA/NamespaceB/StructInNestedNS.go
@@ -6,6 +6,27 @@ import (
flatbuffers "github.com/google/flatbuffers/go"
)
+type StructInNestedNST struct {
+ A int32
+ B int32
+}
+
+func StructInNestedNSPack(builder *flatbuffers.Builder, t *StructInNestedNST) flatbuffers.UOffsetT {
+ if t == nil { return 0 }
+ return CreateStructInNestedNS(builder, t.A, t.B)
+}
+func (rcv *StructInNestedNS) UnPackTo(t *StructInNestedNST) {
+ t.A = rcv.A()
+ t.B = rcv.B()
+}
+
+func (rcv *StructInNestedNS) UnPack() *StructInNestedNST {
+ if rcv == nil { return nil }
+ t := &StructInNestedNST{}
+ rcv.UnPackTo(t)
+ return t
+}
+
type StructInNestedNS struct {
_tab flatbuffers.Struct
}
diff --git a/tests/namespace_test/NamespaceA/NamespaceB/StructInNestedNS.py b/tests/namespace_test/NamespaceA/NamespaceB/StructInNestedNS.py
index db9dcc41..9df52bde 100644
--- a/tests/namespace_test/NamespaceA/NamespaceB/StructInNestedNS.py
+++ b/tests/namespace_test/NamespaceA/NamespaceB/StructInNestedNS.py
@@ -23,3 +23,34 @@ def CreateStructInNestedNS(builder, a, b):
builder.PrependInt32(b)
builder.PrependInt32(a)
return builder.Offset()
+
+
+class StructInNestedNST(object):
+
+ # StructInNestedNST
+ def __init__(self):
+ self.a = 0 # type: int
+ self.b = 0 # type: int
+
+ @classmethod
+ def InitFromBuf(cls, buf, pos):
+ structInNestedNS = StructInNestedNS()
+ structInNestedNS.Init(buf, pos)
+ return cls.InitFromObj(structInNestedNS)
+
+ @classmethod
+ def InitFromObj(cls, structInNestedNS):
+ x = StructInNestedNST()
+ x._UnPack(structInNestedNS)
+ return x
+
+ # StructInNestedNST
+ def _UnPack(self, structInNestedNS):
+ if structInNestedNS is None:
+ return
+ self.a = structInNestedNS.A()
+ self.b = structInNestedNS.B()
+
+ # StructInNestedNST
+ def Pack(self, builder):
+ return CreateStructInNestedNS(builder, self.a, self.b)
diff --git a/tests/namespace_test/NamespaceA/NamespaceB/TableInNestedNS.go b/tests/namespace_test/NamespaceA/NamespaceB/TableInNestedNS.go
index 75f7a554..fb0d39b0 100644
--- a/tests/namespace_test/NamespaceA/NamespaceB/TableInNestedNS.go
+++ b/tests/namespace_test/NamespaceA/NamespaceB/TableInNestedNS.go
@@ -6,6 +6,28 @@ import (
flatbuffers "github.com/google/flatbuffers/go"
)
+type TableInNestedNST struct {
+ Foo int32
+}
+
+func TableInNestedNSPack(builder *flatbuffers.Builder, t *TableInNestedNST) flatbuffers.UOffsetT {
+ if t == nil { return 0 }
+ TableInNestedNSStart(builder)
+ TableInNestedNSAddFoo(builder, t.Foo)
+ return TableInNestedNSEnd(builder)
+}
+
+func (rcv *TableInNestedNS) UnPackTo(t *TableInNestedNST) {
+ t.Foo = rcv.Foo()
+}
+
+func (rcv *TableInNestedNS) UnPack() *TableInNestedNST {
+ if rcv == nil { return nil }
+ t := &TableInNestedNST{}
+ rcv.UnPackTo(t)
+ return t
+}
+
type TableInNestedNS struct {
_tab flatbuffers.Table
}
diff --git a/tests/namespace_test/NamespaceA/NamespaceB/TableInNestedNS.py b/tests/namespace_test/NamespaceA/NamespaceB/TableInNestedNS.py
index 020e1899..e86ba633 100644
--- a/tests/namespace_test/NamespaceA/NamespaceB/TableInNestedNS.py
+++ b/tests/namespace_test/NamespaceA/NamespaceB/TableInNestedNS.py
@@ -30,3 +30,35 @@ class TableInNestedNS(object):
def TableInNestedNSStart(builder): builder.StartObject(1)
def TableInNestedNSAddFoo(builder, foo): builder.PrependInt32Slot(0, foo, 0)
def TableInNestedNSEnd(builder): return builder.EndObject()
+
+
+class TableInNestedNST(object):
+
+ # TableInNestedNST
+ def __init__(self):
+ self.foo = 0 # type: int
+
+ @classmethod
+ def InitFromBuf(cls, buf, pos):
+ tableInNestedNS = TableInNestedNS()
+ tableInNestedNS.Init(buf, pos)
+ return cls.InitFromObj(tableInNestedNS)
+
+ @classmethod
+ def InitFromObj(cls, tableInNestedNS):
+ x = TableInNestedNST()
+ x._UnPack(tableInNestedNS)
+ return x
+
+ # TableInNestedNST
+ def _UnPack(self, tableInNestedNS):
+ if tableInNestedNS is None:
+ return
+ self.foo = tableInNestedNS.Foo()
+
+ # TableInNestedNST
+ def Pack(self, builder):
+ TableInNestedNSStart(builder)
+ TableInNestedNSAddFoo(builder, self.foo)
+ tableInNestedNS = TableInNestedNSEnd(builder)
+ return tableInNestedNS