mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-18 09:54:26 +00:00
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)
This commit is contained in:
committed by
Wouter van Oortmerssen
parent
3e8f15df90
commit
44bf719883
@@ -57,7 +57,7 @@ inline const char * const *EnumNamesTestEnum() {
|
||||
}
|
||||
|
||||
inline const char *EnumNameTestEnum(TestEnum e) {
|
||||
if (e < TestEnum::A || e > TestEnum::C) return "";
|
||||
if (flatbuffers::IsOutRange(e, TestEnum::A, TestEnum::C)) return "";
|
||||
const size_t index = static_cast<size_t>(e);
|
||||
return EnumNamesTestEnum()[index];
|
||||
}
|
||||
|
||||
3296
tests/cpp17/generated_cpp17/monster_test_generated.h
Normal file
3296
tests/cpp17/generated_cpp17/monster_test_generated.h
Normal file
File diff suppressed because it is too large
Load Diff
55
tests/cpp17/test_cpp17.cpp
Normal file
55
tests/cpp17/test_cpp17.cpp
Normal file
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright 2014 Google Inc. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
// This is a sandbox for modeling C++17 code generator.
|
||||
// C++17 code generator: "flatc --cpp_std c++17".
|
||||
// Warning:
|
||||
// This is an experimental feature and could change at any time.
|
||||
|
||||
#include "flatbuffers/flatbuffers.h"
|
||||
#include "flatbuffers/flexbuffers.h"
|
||||
#include "flatbuffers/idl.h"
|
||||
#include "flatbuffers/minireflect.h"
|
||||
#include "flatbuffers/registry.h"
|
||||
#include "flatbuffers/util.h"
|
||||
#include "test_assert.h"
|
||||
|
||||
// Embed generated code into an isolated namespace.
|
||||
namespace cpp17 {
|
||||
#include "generated_cpp17/monster_test_generated.h"
|
||||
} // namespace cpp17
|
||||
|
||||
namespace cpp11 {
|
||||
#include "../monster_test_generated.h"
|
||||
} // namespace cpp11
|
||||
|
||||
int FlatBufferCpp17Tests() {
|
||||
TEST_ASSERT(true);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main(int /*argc*/, const char * /*argv*/[]) {
|
||||
InitTestEngine();
|
||||
|
||||
FlatBufferCpp17Tests();
|
||||
|
||||
if (!testing_fails) {
|
||||
TEST_OUTPUT_LINE("C++17: ALL TESTS PASSED");
|
||||
} else {
|
||||
TEST_OUTPUT_LINE("C++17: %d FAILED TESTS", testing_fails);
|
||||
}
|
||||
return CloseTestEngine();
|
||||
}
|
||||
@@ -12,32 +12,61 @@
|
||||
:: See the License for the specific language governing permissions and
|
||||
:: limitations under the License.
|
||||
|
||||
@SETLOCAL
|
||||
|
||||
set buildtype=Release
|
||||
if "%1"=="-b" set buildtype=%2
|
||||
|
||||
..\%buildtype%\flatc.exe --cpp --java --csharp --dart --go --binary --lobster --lua --js --ts --php --rust --grpc --gen-mutable --reflect-names --gen-object-api --gen-compare --no-includes --cpp-ptr-type flatbuffers::unique_ptr --no-fb-import -I include_test monster_test.fbs monsterdata_test.json || goto FAIL
|
||||
..\%buildtype%\flatc.exe --python --gen-mutable --reflect-names --gen-object-api --gen-compare --cpp-ptr-type flatbuffers::unique_ptr --no-fb-import -I include_test monster_test.fbs monsterdata_test.json || goto FAIL
|
||||
..\%buildtype%\flatc.exe --cpp --java --csharp --dart --go --binary --lobster --lua --python --js --ts --php --rust --gen-mutable --reflect-names --no-fb-import --cpp-ptr-type flatbuffers::unique_ptr -o namespace_test namespace_test/namespace_test1.fbs namespace_test/namespace_test2.fbs || goto FAIL
|
||||
..\%buildtype%\flatc.exe --cpp --java --csharp --js --ts --php --gen-mutable --reflect-names --gen-object-api --gen-compare --cpp-ptr-type flatbuffers::unique_ptr -o union_vector ./union_vector/union_vector.fbs || goto FAIL
|
||||
..\%buildtype%\flatc.exe --cpp --scoped-enums -o evolution_test ./evolution_test/evolution_v1.fbs ./evolution_test/evolution_v2.fbs|| goto FAIL
|
||||
set commandline=%*
|
||||
|
||||
|
||||
if NOT "%commandline%"=="%commandline:--cpp-std c++0x=%" (
|
||||
set TEST_CPP_FLAGS=--cpp-std c++0x
|
||||
) else (
|
||||
@rem --cpp-std is defined by flatc default settings.
|
||||
set TEST_CPP_FLAGS=
|
||||
)
|
||||
|
||||
set TEST_CPP_FLAGS=--gen-compare --cpp-ptr-type flatbuffers::unique_ptr %TEST_CPP_FLAGS%
|
||||
set TEST_BASE_FLAGS=--reflect-names --gen-mutable --gen-object-api
|
||||
set TEST_NOINCL_FLAGS=%TEST_BASE_FLAGS% --no-includes --no-fb-import
|
||||
|
||||
..\%buildtype%\flatc.exe --binary --cpp --java --kotlin --csharp --dart --go --lobster --lua --js --ts --php --rust --grpc ^
|
||||
%TEST_NOINCL_FLAGS% %TEST_CPP_FLAGS% -I include_test monster_test.fbs monsterdata_test.json || goto FAIL
|
||||
|
||||
..\%buildtype%\flatc.exe --python %TEST_BASE_FLAGS% --no-fb-import -I include_test monster_test.fbs monsterdata_test.json || goto FAIL
|
||||
|
||||
..\%buildtype%\flatc.exe --binary --cpp --java --csharp --dart --go --lobster --lua --js --ts --php --python --rust ^
|
||||
%TEST_NOINCL_FLAGS% %TEST_CPP_FLAGS% -o namespace_test namespace_test/namespace_test1.fbs namespace_test/namespace_test2.fbs || goto FAIL
|
||||
|
||||
..\%buildtype%\flatc.exe --cpp --java --csharp --js --ts --php %TEST_BASE_FLAGS% %TEST_CPP_FLAGS% -o union_vector ./union_vector/union_vector.fbs || goto FAIL
|
||||
..\%buildtype%\flatc.exe -b --schema --bfbs-comments --bfbs-builtins -I include_test monster_test.fbs || goto FAIL
|
||||
..\%buildtype%\flatc.exe -b --schema --bfbs-comments --bfbs-builtins -I include_test arrays_test.fbs || goto FAIL
|
||||
..\%buildtype%\flatc.exe --jsonschema --schema -I include_test monster_test.fbs || goto FAIL
|
||||
..\%buildtype%\flatc.exe --cpp --java --csharp --gen-mutable --reflect-names --gen-object-api --gen-compare --no-includes --scoped-enums --jsonschema --cpp-ptr-type flatbuffers::unique_ptr arrays_test.fbs || goto FAIL
|
||||
..\%buildtype%\flatc.exe --python --gen-mutable --reflect-names --gen-object-api --gen-compare --scoped-enums --jsonschema --cpp-ptr-type flatbuffers::unique_ptr arrays_test.fbs || goto FAIL
|
||||
..\%buildtype%\flatc.exe --cpp --gen-mutable --gen-object-api --reflect-names --cpp-ptr-type flatbuffers::unique_ptr native_type_test.fbs || goto FAIL
|
||||
..\%buildtype%\flatc.exe --cpp --java --csharp --jsonschema %TEST_NOINCL_FLAGS% %TEST_CPP_FLAGS% --scoped-enums arrays_test.fbs || goto FAIL
|
||||
..\%buildtype%\flatc.exe --python %TEST_BASE_FLAGS% arrays_test.fbs || goto FAIL
|
||||
..\%buildtype%\flatc.exe --cpp %TEST_BASE_FLAGS% --cpp-ptr-type flatbuffers::unique_ptr native_type_test.fbs || goto FAIL
|
||||
|
||||
IF NOT "%MONSTER_EXTRA%"=="skip" (
|
||||
if NOT "%MONSTER_EXTRA%"=="skip" (
|
||||
@echo Generate MosterExtra
|
||||
..\%buildtype%\flatc.exe --cpp --java --csharp --gen-mutable --reflect-names --gen-object-api --gen-compare --no-includes --cpp-ptr-type flatbuffers::unique_ptr monster_extra.fbs monsterdata_extra.json || goto FAIL
|
||||
..\%buildtype%\flatc.exe --python --gen-mutable --reflect-names --gen-object-api --gen-compare --cpp-ptr-type flatbuffers::unique_ptr monster_extra.fbs monsterdata_extra.json || goto FAIL
|
||||
|
||||
..\%buildtype%\flatc.exe --cpp --java --csharp %TEST_NOINCL_FLAGS% %TEST_CPP_FLAGS% monster_extra.fbs monsterdata_extra.json || goto FAIL
|
||||
..\%buildtype%\flatc.exe --python %TEST_BASE_FLAGS% monster_extra.fbs monsterdata_extra.json || goto FAIL
|
||||
) else (
|
||||
@echo monster_extra.fbs skipped (the strtod function from MSVC2013 or older doesn't support NaN/Inf arguments)
|
||||
)
|
||||
|
||||
set TEST_CPP17_FLAGS=--cpp --cpp-std c++17 -o ./cpp17/generated_cpp17 %TEST_NOINCL_FLAGS%
|
||||
if NOT "%MONSTER_EXTRA%"=="skip" (
|
||||
@rem Flag c++17 requires Clang6, GCC7, MSVC2017 (_MSC_VER >= 1914) or higher.
|
||||
..\%buildtype%\flatc.exe %TEST_CPP17_FLAGS% -I include_test monster_test.fbs || goto FAIL
|
||||
@rem..\%buildtype%\flatc.exe %TEST_CPP17_FLAGS% arrays_test.fbs || goto FAIL
|
||||
@rem..\%buildtype%\flatc.exe %TEST_CPP17_FLAGS% native_type_test.fbs || goto FAIL
|
||||
@rem..\%buildtype%\flatc.exe %TEST_CPP17_FLAGS% monster_extra.fbs || goto FAIL
|
||||
@rem..\%buildtype%\flatc.exe %TEST_CPP17_FLAGS% ./union_vector/union_vector.fbs || goto FAIL
|
||||
)
|
||||
|
||||
cd ../samples
|
||||
..\%buildtype%\flatc.exe --cpp --lobster --gen-mutable --reflect-names --gen-object-api --gen-compare --cpp-ptr-type flatbuffers::unique_ptr monster.fbs || goto FAIL
|
||||
..\%buildtype%\flatc.exe --cpp --lobster %TEST_BASE_FLAGS% %TEST_CPP_FLAGS% monster.fbs || goto FAIL
|
||||
..\%buildtype%\flatc.exe -b --schema --bfbs-comments --bfbs-builtins monster.fbs || goto FAIL
|
||||
cd ../reflection
|
||||
call generate_code.bat %1 %2 || goto FAIL
|
||||
|
||||
@@ -15,19 +15,41 @@
|
||||
# limitations under the License.
|
||||
set -e
|
||||
|
||||
../flatc --cpp --java --kotlin --csharp --dart --go --binary --lobster --lua --js --ts --php --rust --grpc --gen-mutable --reflect-names --gen-object-api --gen-compare --no-includes --cpp-ptr-type flatbuffers::unique_ptr --no-fb-import -I include_test monster_test.fbs monsterdata_test.json
|
||||
../flatc --python --gen-mutable --reflect-names --gen-object-api --gen-compare --cpp-ptr-type flatbuffers::unique_ptr --no-fb-import -I include_test monster_test.fbs monsterdata_test.json
|
||||
../flatc --cpp --java --kotlin --csharp --dart --go --binary --lobster --lua --python --js --ts --php --rust --gen-mutable --reflect-names --no-fb-import --cpp-ptr-type flatbuffers::unique_ptr -o namespace_test namespace_test/namespace_test1.fbs namespace_test/namespace_test2.fbs
|
||||
../flatc --cpp --java --kotlin --csharp --js --ts --php --gen-mutable --reflect-names --gen-object-api --gen-compare --cpp-ptr-type flatbuffers::unique_ptr -o union_vector ./union_vector/union_vector.fbs
|
||||
../flatc --cpp --scoped-enums -o evolution_test ./evolution_test/evolution_v*.fbs
|
||||
commandline="'$*'"
|
||||
|
||||
if [[ $commandline == *"--cpp-std c++0x"* ]]; then
|
||||
TEST_CPP_FLAGS="--cpp-std c++0x"
|
||||
else
|
||||
# --cpp-std is defined by flatc default settings.
|
||||
TEST_CPP_FLAGS=
|
||||
fi
|
||||
|
||||
TEST_CPP_FLAGS="--gen-compare --cpp-ptr-type flatbuffers::unique_ptr $TEST_CPP_FLAGS"
|
||||
TEST_BASE_FLAGS="--reflect-names --gen-mutable --gen-object-api"
|
||||
TEST_NOINCL_FLAGS="$TEST_BASE_FLAGS --no-includes --no-fb-import"
|
||||
|
||||
../flatc --binary --cpp --java --kotlin --csharp --dart --go --lobster --lua --js --ts --php --rust --grpc \
|
||||
$TEST_NOINCL_FLAGS $TEST_CPP_FLAGS -I include_test monster_test.fbs monsterdata_test.json
|
||||
|
||||
../flatc --python $TEST_BASE_FLAGS -I include_test monster_test.fbs monsterdata_test.json
|
||||
|
||||
../flatc --cpp --java --kotlin --csharp --dart --go --binary --lobster --lua --js --ts --php --python --rust \
|
||||
$TEST_NOINCL_FLAGS $TEST_CPP_FLAGS -o namespace_test namespace_test/namespace_test1.fbs namespace_test/namespace_test2.fbs
|
||||
|
||||
../flatc --cpp --java --kotlin --csharp --js --ts --php $TEST_BASE_FLAGS $TEST_CPP_FLAGS -o union_vector ./union_vector/union_vector.fbs
|
||||
../flatc -b --schema --bfbs-comments --bfbs-builtins -I include_test monster_test.fbs
|
||||
../flatc -b --schema --bfbs-comments --bfbs-builtins -I include_test arrays_test.fbs
|
||||
../flatc --jsonschema --schema -I include_test monster_test.fbs
|
||||
../flatc --cpp --java --kotlin --csharp --python --gen-mutable --reflect-names --gen-object-api --gen-compare --no-includes --cpp-ptr-type flatbuffers::unique_ptr monster_extra.fbs monsterdata_extra.json
|
||||
../flatc --cpp --java --csharp --gen-mutable --reflect-names --gen-object-api --gen-compare --no-includes --scoped-enums --jsonschema --cpp-ptr-type flatbuffers::unique_ptr arrays_test.fbs
|
||||
../flatc --python --gen-mutable --reflect-names --gen-object-api --gen-compare --scoped-enums --jsonschema --cpp-ptr-type flatbuffers::unique_ptr arrays_test.fbs
|
||||
../flatc --cpp --java --kotlin --csharp --python $TEST_NOINCL_FLAGS $TEST_CPP_FLAGS monster_extra.fbs monsterdata_extra.json
|
||||
../flatc --cpp --java --csharp --jsonschema $TEST_NOINCL_FLAGS $TEST_CPP_FLAGS --scoped-enums arrays_test.fbs
|
||||
../flatc --python $TEST_BASE_FLAGS arrays_test.fbs
|
||||
|
||||
# Flag c++17 requires Clang6, GCC7, MSVC2017 (_MSC_VER >= 1914) or higher.
|
||||
TEST_CPP17_FLAGS="--cpp --cpp-std c++17 -o ./cpp17/generated_cpp17 $TEST_NOINCL_FLAGS"
|
||||
../flatc $TEST_CPP17_FLAGS -I include_test monster_test.fbs
|
||||
|
||||
cd ../samples
|
||||
../flatc --cpp --lobster --gen-mutable --reflect-names --gen-object-api --gen-compare --cpp-ptr-type flatbuffers::unique_ptr monster.fbs
|
||||
../flatc --cpp --lobster $TEST_BASE_FLAGS $TEST_CPP_FLAGS monster.fbs
|
||||
../flatc -b --schema --bfbs-comments --bfbs-builtins monster.fbs
|
||||
cd ../reflection
|
||||
./generate_code.sh
|
||||
./generate_code.sh --cpp-std c++0x
|
||||
|
||||
@@ -136,7 +136,7 @@ inline const char * const *EnumNamesColor() {
|
||||
}
|
||||
|
||||
inline const char *EnumNameColor(Color e) {
|
||||
if (e < Color_Red || e > Color_Blue) return "";
|
||||
if (flatbuffers::IsOutRange(e, Color_Red, Color_Blue)) return "";
|
||||
const size_t index = static_cast<size_t>(e) - static_cast<size_t>(Color_Red);
|
||||
return EnumNamesColor()[index];
|
||||
}
|
||||
@@ -172,7 +172,7 @@ inline const char * const *EnumNamesRace() {
|
||||
}
|
||||
|
||||
inline const char *EnumNameRace(Race e) {
|
||||
if (e < Race_None || e > Race_Elf) return "";
|
||||
if (flatbuffers::IsOutRange(e, Race_None, Race_Elf)) return "";
|
||||
const size_t index = static_cast<size_t>(e) - static_cast<size_t>(Race_None);
|
||||
return EnumNamesRace()[index];
|
||||
}
|
||||
@@ -208,7 +208,7 @@ inline const char * const *EnumNamesAny() {
|
||||
}
|
||||
|
||||
inline const char *EnumNameAny(Any e) {
|
||||
if (e < Any_NONE || e > Any_MyGame_Example2_Monster) return "";
|
||||
if (flatbuffers::IsOutRange(e, Any_NONE, Any_MyGame_Example2_Monster)) return "";
|
||||
const size_t index = static_cast<size_t>(e);
|
||||
return EnumNamesAny()[index];
|
||||
}
|
||||
@@ -350,7 +350,7 @@ inline const char * const *EnumNamesAnyUniqueAliases() {
|
||||
}
|
||||
|
||||
inline const char *EnumNameAnyUniqueAliases(AnyUniqueAliases e) {
|
||||
if (e < AnyUniqueAliases_NONE || e > AnyUniqueAliases_M2) return "";
|
||||
if (flatbuffers::IsOutRange(e, AnyUniqueAliases_NONE, AnyUniqueAliases_M2)) return "";
|
||||
const size_t index = static_cast<size_t>(e);
|
||||
return EnumNamesAnyUniqueAliases()[index];
|
||||
}
|
||||
@@ -492,7 +492,7 @@ inline const char * const *EnumNamesAnyAmbiguousAliases() {
|
||||
}
|
||||
|
||||
inline const char *EnumNameAnyAmbiguousAliases(AnyAmbiguousAliases e) {
|
||||
if (e < AnyAmbiguousAliases_NONE || e > AnyAmbiguousAliases_M3) return "";
|
||||
if (flatbuffers::IsOutRange(e, AnyAmbiguousAliases_NONE, AnyAmbiguousAliases_M3)) return "";
|
||||
const size_t index = static_cast<size_t>(e);
|
||||
return EnumNamesAnyAmbiguousAliases()[index];
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -8,6 +8,29 @@ import (
|
||||
NamespaceC "NamespaceC"
|
||||
)
|
||||
|
||||
type SecondTableInAT struct {
|
||||
ReferToC *NamespaceC.TableInCT
|
||||
}
|
||||
|
||||
func SecondTableInAPack(builder *flatbuffers.Builder, t *SecondTableInAT) flatbuffers.UOffsetT {
|
||||
if t == nil { return 0 }
|
||||
referToCOffset := NamespaceC.TableInCPack(builder, t.ReferToC)
|
||||
SecondTableInAStart(builder)
|
||||
SecondTableInAAddReferToC(builder, referToCOffset)
|
||||
return SecondTableInAEnd(builder)
|
||||
}
|
||||
|
||||
func (rcv *SecondTableInA) UnPackTo(t *SecondTableInAT) {
|
||||
t.ReferToC = rcv.ReferToC(nil).UnPack()
|
||||
}
|
||||
|
||||
func (rcv *SecondTableInA) UnPack() *SecondTableInAT {
|
||||
if rcv == nil { return nil }
|
||||
t := &SecondTableInAT{}
|
||||
rcv.UnPackTo(t)
|
||||
return t
|
||||
}
|
||||
|
||||
type SecondTableInA struct {
|
||||
_tab flatbuffers.Table
|
||||
}
|
||||
|
||||
@@ -25,7 +25,6 @@ class SecondTableInA(object):
|
||||
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
|
||||
if o != 0:
|
||||
x = self._tab.Indirect(o + self._tab.Pos)
|
||||
from NamespaceC.TableInC import TableInC
|
||||
obj = TableInC()
|
||||
obj.Init(self._tab.Bytes, x)
|
||||
return obj
|
||||
@@ -34,3 +33,43 @@ class SecondTableInA(object):
|
||||
def SecondTableInAStart(builder): builder.StartObject(1)
|
||||
def SecondTableInAAddReferToC(builder, referToC): builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(referToC), 0)
|
||||
def SecondTableInAEnd(builder): return builder.EndObject()
|
||||
|
||||
try:
|
||||
from typing import Optional
|
||||
except:
|
||||
pass
|
||||
|
||||
class SecondTableInAT(object):
|
||||
|
||||
# SecondTableInAT
|
||||
def __init__(self):
|
||||
self.referToC = None # type: Optional[TableInCT]
|
||||
|
||||
@classmethod
|
||||
def InitFromBuf(cls, buf, pos):
|
||||
secondTableInA = SecondTableInA()
|
||||
secondTableInA.Init(buf, pos)
|
||||
return cls.InitFromObj(secondTableInA)
|
||||
|
||||
@classmethod
|
||||
def InitFromObj(cls, secondTableInA):
|
||||
x = SecondTableInAT()
|
||||
x._UnPack(secondTableInA)
|
||||
return x
|
||||
|
||||
# SecondTableInAT
|
||||
def _UnPack(self, secondTableInA):
|
||||
if secondTableInA is None:
|
||||
return
|
||||
if secondTableInA.ReferToC() is not None:
|
||||
self.referToC = TableInCT.InitFromObj(secondTableInA.ReferToC())
|
||||
|
||||
# SecondTableInAT
|
||||
def Pack(self, builder):
|
||||
if self.referToC is not None:
|
||||
referToC = self.referToC.Pack(builder)
|
||||
SecondTableInAStart(builder)
|
||||
if self.referToC is not None:
|
||||
SecondTableInAAddReferToC(builder, referToC)
|
||||
secondTableInA = SecondTableInAEnd(builder)
|
||||
return secondTableInA
|
||||
|
||||
@@ -8,6 +8,36 @@ import (
|
||||
NamespaceA__NamespaceB "NamespaceA/NamespaceB"
|
||||
)
|
||||
|
||||
type TableInFirstNST struct {
|
||||
FooTable *NamespaceA__NamespaceB.TableInNestedNST
|
||||
FooEnum NamespaceA__NamespaceB.EnumInNestedNS
|
||||
FooStruct *NamespaceA__NamespaceB.StructInNestedNST
|
||||
}
|
||||
|
||||
func TableInFirstNSPack(builder *flatbuffers.Builder, t *TableInFirstNST) flatbuffers.UOffsetT {
|
||||
if t == nil { return 0 }
|
||||
fooTableOffset := NamespaceA__NamespaceB.TableInNestedNSPack(builder, t.FooTable)
|
||||
TableInFirstNSStart(builder)
|
||||
TableInFirstNSAddFooTable(builder, fooTableOffset)
|
||||
TableInFirstNSAddFooEnum(builder, t.FooEnum)
|
||||
fooStructOffset := NamespaceA__NamespaceB.StructInNestedNSPack(builder, t.FooStruct)
|
||||
TableInFirstNSAddFooStruct(builder, fooStructOffset)
|
||||
return TableInFirstNSEnd(builder)
|
||||
}
|
||||
|
||||
func (rcv *TableInFirstNS) UnPackTo(t *TableInFirstNST) {
|
||||
t.FooTable = rcv.FooTable(nil).UnPack()
|
||||
t.FooEnum = rcv.FooEnum()
|
||||
t.FooStruct = rcv.FooStruct(nil).UnPack()
|
||||
}
|
||||
|
||||
func (rcv *TableInFirstNS) UnPack() *TableInFirstNST {
|
||||
if rcv == nil { return nil }
|
||||
t := &TableInFirstNST{}
|
||||
rcv.UnPackTo(t)
|
||||
return t
|
||||
}
|
||||
|
||||
type TableInFirstNS struct {
|
||||
_tab flatbuffers.Table
|
||||
}
|
||||
|
||||
@@ -25,7 +25,6 @@ class TableInFirstNS(object):
|
||||
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
|
||||
if o != 0:
|
||||
x = self._tab.Indirect(o + self._tab.Pos)
|
||||
from NamespaceA.NamespaceB.TableInNestedNS import TableInNestedNS
|
||||
obj = TableInNestedNS()
|
||||
obj.Init(self._tab.Bytes, x)
|
||||
return obj
|
||||
@@ -43,7 +42,6 @@ class TableInFirstNS(object):
|
||||
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
|
||||
if o != 0:
|
||||
x = o + self._tab.Pos
|
||||
from NamespaceA.NamespaceB.StructInNestedNS import StructInNestedNS
|
||||
obj = StructInNestedNS()
|
||||
obj.Init(self._tab.Bytes, x)
|
||||
return obj
|
||||
@@ -54,3 +52,52 @@ def TableInFirstNSAddFooTable(builder, fooTable): builder.PrependUOffsetTRelativ
|
||||
def TableInFirstNSAddFooEnum(builder, fooEnum): builder.PrependInt8Slot(1, fooEnum, 0)
|
||||
def TableInFirstNSAddFooStruct(builder, fooStruct): builder.PrependStructSlot(2, flatbuffers.number_types.UOffsetTFlags.py_type(fooStruct), 0)
|
||||
def TableInFirstNSEnd(builder): return builder.EndObject()
|
||||
|
||||
try:
|
||||
from typing import Optional
|
||||
except:
|
||||
pass
|
||||
|
||||
class TableInFirstNST(object):
|
||||
|
||||
# TableInFirstNST
|
||||
def __init__(self):
|
||||
self.fooTable = None # type: Optional[TableInNestedNST]
|
||||
self.fooEnum = 0 # type: int
|
||||
self.fooStruct = None # type: Optional[StructInNestedNST]
|
||||
|
||||
@classmethod
|
||||
def InitFromBuf(cls, buf, pos):
|
||||
tableInFirstNS = TableInFirstNS()
|
||||
tableInFirstNS.Init(buf, pos)
|
||||
return cls.InitFromObj(tableInFirstNS)
|
||||
|
||||
@classmethod
|
||||
def InitFromObj(cls, tableInFirstNS):
|
||||
x = TableInFirstNST()
|
||||
x._UnPack(tableInFirstNS)
|
||||
return x
|
||||
|
||||
# TableInFirstNST
|
||||
def _UnPack(self, tableInFirstNS):
|
||||
if tableInFirstNS is None:
|
||||
return
|
||||
if tableInFirstNS.FooTable() is not None:
|
||||
self.fooTable = TableInNestedNST.InitFromObj(tableInFirstNS.FooTable())
|
||||
self.fooEnum = tableInFirstNS.FooEnum()
|
||||
if tableInFirstNS.FooStruct() is not None:
|
||||
self.fooStruct = StructInNestedNST.InitFromObj(tableInFirstNS.FooStruct())
|
||||
|
||||
# TableInFirstNST
|
||||
def Pack(self, builder):
|
||||
if self.fooTable is not None:
|
||||
fooTable = self.fooTable.Pack(builder)
|
||||
TableInFirstNSStart(builder)
|
||||
if self.fooTable is not None:
|
||||
TableInFirstNSAddFooTable(builder, fooTable)
|
||||
TableInFirstNSAddFooEnum(builder, self.fooEnum)
|
||||
if self.fooStruct is not None:
|
||||
fooStruct = self.fooStruct.Pack(builder)
|
||||
TableInFirstNSAddFooStruct(builder, fooStruct)
|
||||
tableInFirstNS = TableInFirstNSEnd(builder)
|
||||
return tableInFirstNS
|
||||
|
||||
@@ -8,6 +8,33 @@ import (
|
||||
NamespaceA "NamespaceA"
|
||||
)
|
||||
|
||||
type TableInCT struct {
|
||||
ReferToA1 *NamespaceA.TableInFirstNST
|
||||
ReferToA2 *NamespaceA.SecondTableInAT
|
||||
}
|
||||
|
||||
func TableInCPack(builder *flatbuffers.Builder, t *TableInCT) flatbuffers.UOffsetT {
|
||||
if t == nil { return 0 }
|
||||
referToA1Offset := NamespaceA.TableInFirstNSPack(builder, t.ReferToA1)
|
||||
referToA2Offset := NamespaceA.SecondTableInAPack(builder, t.ReferToA2)
|
||||
TableInCStart(builder)
|
||||
TableInCAddReferToA1(builder, referToA1Offset)
|
||||
TableInCAddReferToA2(builder, referToA2Offset)
|
||||
return TableInCEnd(builder)
|
||||
}
|
||||
|
||||
func (rcv *TableInC) UnPackTo(t *TableInCT) {
|
||||
t.ReferToA1 = rcv.ReferToA1(nil).UnPack()
|
||||
t.ReferToA2 = rcv.ReferToA2(nil).UnPack()
|
||||
}
|
||||
|
||||
func (rcv *TableInC) UnPack() *TableInCT {
|
||||
if rcv == nil { return nil }
|
||||
t := &TableInCT{}
|
||||
rcv.UnPackTo(t)
|
||||
return t
|
||||
}
|
||||
|
||||
type TableInC struct {
|
||||
_tab flatbuffers.Table
|
||||
}
|
||||
|
||||
@@ -25,7 +25,6 @@ class TableInC(object):
|
||||
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
|
||||
if o != 0:
|
||||
x = self._tab.Indirect(o + self._tab.Pos)
|
||||
from NamespaceA.TableInFirstNS import TableInFirstNS
|
||||
obj = TableInFirstNS()
|
||||
obj.Init(self._tab.Bytes, x)
|
||||
return obj
|
||||
@@ -36,7 +35,6 @@ class TableInC(object):
|
||||
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
|
||||
if o != 0:
|
||||
x = self._tab.Indirect(o + self._tab.Pos)
|
||||
from NamespaceA.SecondTableInA import SecondTableInA
|
||||
obj = SecondTableInA()
|
||||
obj.Init(self._tab.Bytes, x)
|
||||
return obj
|
||||
@@ -46,3 +44,50 @@ def TableInCStart(builder): builder.StartObject(2)
|
||||
def TableInCAddReferToA1(builder, referToA1): builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(referToA1), 0)
|
||||
def TableInCAddReferToA2(builder, referToA2): builder.PrependUOffsetTRelativeSlot(1, flatbuffers.number_types.UOffsetTFlags.py_type(referToA2), 0)
|
||||
def TableInCEnd(builder): return builder.EndObject()
|
||||
|
||||
try:
|
||||
from typing import Optional
|
||||
except:
|
||||
pass
|
||||
|
||||
class TableInCT(object):
|
||||
|
||||
# TableInCT
|
||||
def __init__(self):
|
||||
self.referToA1 = None # type: Optional[TableInFirstNST]
|
||||
self.referToA2 = None # type: Optional[SecondTableInAT]
|
||||
|
||||
@classmethod
|
||||
def InitFromBuf(cls, buf, pos):
|
||||
tableInC = TableInC()
|
||||
tableInC.Init(buf, pos)
|
||||
return cls.InitFromObj(tableInC)
|
||||
|
||||
@classmethod
|
||||
def InitFromObj(cls, tableInC):
|
||||
x = TableInCT()
|
||||
x._UnPack(tableInC)
|
||||
return x
|
||||
|
||||
# TableInCT
|
||||
def _UnPack(self, tableInC):
|
||||
if tableInC is None:
|
||||
return
|
||||
if tableInC.ReferToA1() is not None:
|
||||
self.referToA1 = TableInFirstNST.InitFromObj(tableInC.ReferToA1())
|
||||
if tableInC.ReferToA2() is not None:
|
||||
self.referToA2 = SecondTableInAT.InitFromObj(tableInC.ReferToA2())
|
||||
|
||||
# TableInCT
|
||||
def Pack(self, builder):
|
||||
if self.referToA1 is not None:
|
||||
referToA1 = self.referToA1.Pack(builder)
|
||||
if self.referToA2 is not None:
|
||||
referToA2 = self.referToA2.Pack(builder)
|
||||
TableInCStart(builder)
|
||||
if self.referToA1 is not None:
|
||||
TableInCAddReferToA1(builder, referToA1)
|
||||
if self.referToA2 is not None:
|
||||
TableInCAddReferToA2(builder, referToA2)
|
||||
tableInC = TableInCEnd(builder)
|
||||
return tableInC
|
||||
|
||||
@@ -10,9 +10,15 @@ namespace NamespaceA {
|
||||
namespace NamespaceB {
|
||||
|
||||
struct TableInNestedNS;
|
||||
struct TableInNestedNST;
|
||||
|
||||
struct StructInNestedNS;
|
||||
|
||||
bool operator==(const TableInNestedNST &lhs, const TableInNestedNST &rhs);
|
||||
bool operator!=(const TableInNestedNST &lhs, const TableInNestedNST &rhs);
|
||||
bool operator==(const StructInNestedNS &lhs, const StructInNestedNS &rhs);
|
||||
bool operator!=(const StructInNestedNS &lhs, const StructInNestedNS &rhs);
|
||||
|
||||
inline const flatbuffers::TypeTable *TableInNestedNSTypeTable();
|
||||
|
||||
inline const flatbuffers::TypeTable *StructInNestedNSTypeTable();
|
||||
@@ -45,7 +51,7 @@ inline const char * const *EnumNamesEnumInNestedNS() {
|
||||
}
|
||||
|
||||
inline const char *EnumNameEnumInNestedNS(EnumInNestedNS e) {
|
||||
if (e < EnumInNestedNS_A || e > EnumInNestedNS_C) return "";
|
||||
if (flatbuffers::IsOutRange(e, EnumInNestedNS_A, EnumInNestedNS_C)) return "";
|
||||
const size_t index = static_cast<size_t>(e);
|
||||
return EnumNamesEnumInNestedNS()[index];
|
||||
}
|
||||
@@ -81,7 +87,37 @@ FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(4) StructInNestedNS FLATBUFFERS_FINAL_CLASS
|
||||
};
|
||||
FLATBUFFERS_STRUCT_END(StructInNestedNS, 8);
|
||||
|
||||
inline bool operator==(const StructInNestedNS &lhs, const StructInNestedNS &rhs) {
|
||||
return
|
||||
(lhs.a() == rhs.a()) &&
|
||||
(lhs.b() == rhs.b());
|
||||
}
|
||||
|
||||
inline bool operator!=(const StructInNestedNS &lhs, const StructInNestedNS &rhs) {
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
|
||||
struct TableInNestedNST : public flatbuffers::NativeTable {
|
||||
typedef TableInNestedNS TableType;
|
||||
int32_t foo;
|
||||
TableInNestedNST()
|
||||
: foo(0) {
|
||||
}
|
||||
};
|
||||
|
||||
inline bool operator==(const TableInNestedNST &lhs, const TableInNestedNST &rhs) {
|
||||
return
|
||||
(lhs.foo == rhs.foo);
|
||||
}
|
||||
|
||||
inline bool operator!=(const TableInNestedNST &lhs, const TableInNestedNST &rhs) {
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
|
||||
struct TableInNestedNS FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
|
||||
typedef TableInNestedNST NativeTableType;
|
||||
static const flatbuffers::TypeTable *MiniReflectTypeTable() {
|
||||
return TableInNestedNSTypeTable();
|
||||
}
|
||||
@@ -99,6 +135,9 @@ struct TableInNestedNS FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
|
||||
VerifyField<int32_t>(verifier, VT_FOO) &&
|
||||
verifier.EndTable();
|
||||
}
|
||||
TableInNestedNST *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const;
|
||||
void UnPackTo(TableInNestedNST *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const;
|
||||
static flatbuffers::Offset<TableInNestedNS> Pack(flatbuffers::FlatBufferBuilder &_fbb, const TableInNestedNST* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr);
|
||||
};
|
||||
|
||||
struct TableInNestedNSBuilder {
|
||||
@@ -127,6 +166,34 @@ inline flatbuffers::Offset<TableInNestedNS> CreateTableInNestedNS(
|
||||
return builder_.Finish();
|
||||
}
|
||||
|
||||
flatbuffers::Offset<TableInNestedNS> CreateTableInNestedNS(flatbuffers::FlatBufferBuilder &_fbb, const TableInNestedNST *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr);
|
||||
|
||||
inline TableInNestedNST *TableInNestedNS::UnPack(const flatbuffers::resolver_function_t *_resolver) const {
|
||||
auto _o = new TableInNestedNST();
|
||||
UnPackTo(_o, _resolver);
|
||||
return _o;
|
||||
}
|
||||
|
||||
inline void TableInNestedNS::UnPackTo(TableInNestedNST *_o, const flatbuffers::resolver_function_t *_resolver) const {
|
||||
(void)_o;
|
||||
(void)_resolver;
|
||||
{ auto _e = foo(); _o->foo = _e; }
|
||||
}
|
||||
|
||||
inline flatbuffers::Offset<TableInNestedNS> TableInNestedNS::Pack(flatbuffers::FlatBufferBuilder &_fbb, const TableInNestedNST* _o, const flatbuffers::rehasher_function_t *_rehasher) {
|
||||
return CreateTableInNestedNS(_fbb, _o, _rehasher);
|
||||
}
|
||||
|
||||
inline flatbuffers::Offset<TableInNestedNS> CreateTableInNestedNS(flatbuffers::FlatBufferBuilder &_fbb, const TableInNestedNST *_o, const flatbuffers::rehasher_function_t *_rehasher) {
|
||||
(void)_rehasher;
|
||||
(void)_o;
|
||||
struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const TableInNestedNST* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va;
|
||||
auto _foo = _o->foo;
|
||||
return NamespaceA::NamespaceB::CreateTableInNestedNS(
|
||||
_fbb,
|
||||
_foo);
|
||||
}
|
||||
|
||||
inline const flatbuffers::TypeTable *EnumInNestedNSTypeTable() {
|
||||
static const flatbuffers::TypeCode type_codes[] = {
|
||||
{ flatbuffers::ET_CHAR, 0, 0 },
|
||||
|
||||
@@ -6,23 +6,39 @@
|
||||
|
||||
#include "flatbuffers/flatbuffers.h"
|
||||
|
||||
#include "namespace_test1_generated.h"
|
||||
|
||||
namespace NamespaceA {
|
||||
|
||||
struct TableInFirstNS;
|
||||
struct TableInFirstNST;
|
||||
|
||||
} // namespace NamespaceA
|
||||
|
||||
namespace NamespaceC {
|
||||
|
||||
struct TableInC;
|
||||
struct TableInCT;
|
||||
|
||||
} // namespace NamespaceC
|
||||
|
||||
namespace NamespaceA {
|
||||
|
||||
struct SecondTableInA;
|
||||
struct SecondTableInAT;
|
||||
|
||||
bool operator==(const TableInFirstNST &lhs, const TableInFirstNST &rhs);
|
||||
bool operator!=(const TableInFirstNST &lhs, const TableInFirstNST &rhs);
|
||||
} // namespace NamespaceA
|
||||
|
||||
namespace NamespaceC {
|
||||
|
||||
bool operator==(const TableInCT &lhs, const TableInCT &rhs);
|
||||
bool operator!=(const TableInCT &lhs, const TableInCT &rhs);
|
||||
} // namespace NamespaceC
|
||||
|
||||
namespace NamespaceA {
|
||||
|
||||
bool operator==(const SecondTableInAT &lhs, const SecondTableInAT &rhs);
|
||||
bool operator!=(const SecondTableInAT &lhs, const SecondTableInAT &rhs);
|
||||
|
||||
inline const flatbuffers::TypeTable *TableInFirstNSTypeTable();
|
||||
|
||||
@@ -38,7 +54,30 @@ namespace NamespaceA {
|
||||
|
||||
inline const flatbuffers::TypeTable *SecondTableInATypeTable();
|
||||
|
||||
struct TableInFirstNST : public flatbuffers::NativeTable {
|
||||
typedef TableInFirstNS TableType;
|
||||
flatbuffers::unique_ptr<NamespaceA::NamespaceB::TableInNestedNST> foo_table;
|
||||
NamespaceA::NamespaceB::EnumInNestedNS foo_enum;
|
||||
flatbuffers::unique_ptr<NamespaceA::NamespaceB::StructInNestedNS> foo_struct;
|
||||
TableInFirstNST()
|
||||
: foo_enum(NamespaceA::NamespaceB::EnumInNestedNS_A) {
|
||||
}
|
||||
};
|
||||
|
||||
inline bool operator==(const TableInFirstNST &lhs, const TableInFirstNST &rhs) {
|
||||
return
|
||||
(lhs.foo_table == rhs.foo_table) &&
|
||||
(lhs.foo_enum == rhs.foo_enum) &&
|
||||
(lhs.foo_struct == rhs.foo_struct);
|
||||
}
|
||||
|
||||
inline bool operator!=(const TableInFirstNST &lhs, const TableInFirstNST &rhs) {
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
|
||||
struct TableInFirstNS FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
|
||||
typedef TableInFirstNST NativeTableType;
|
||||
static const flatbuffers::TypeTable *MiniReflectTypeTable() {
|
||||
return TableInFirstNSTypeTable();
|
||||
}
|
||||
@@ -73,6 +112,9 @@ struct TableInFirstNS FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
|
||||
VerifyField<NamespaceA::NamespaceB::StructInNestedNS>(verifier, VT_FOO_STRUCT) &&
|
||||
verifier.EndTable();
|
||||
}
|
||||
TableInFirstNST *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const;
|
||||
void UnPackTo(TableInFirstNST *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const;
|
||||
static flatbuffers::Offset<TableInFirstNS> Pack(flatbuffers::FlatBufferBuilder &_fbb, const TableInFirstNST* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr);
|
||||
};
|
||||
|
||||
struct TableInFirstNSBuilder {
|
||||
@@ -111,11 +153,33 @@ inline flatbuffers::Offset<TableInFirstNS> CreateTableInFirstNS(
|
||||
return builder_.Finish();
|
||||
}
|
||||
|
||||
flatbuffers::Offset<TableInFirstNS> CreateTableInFirstNS(flatbuffers::FlatBufferBuilder &_fbb, const TableInFirstNST *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr);
|
||||
|
||||
} // namespace NamespaceA
|
||||
|
||||
namespace NamespaceC {
|
||||
|
||||
struct TableInCT : public flatbuffers::NativeTable {
|
||||
typedef TableInC TableType;
|
||||
flatbuffers::unique_ptr<NamespaceA::TableInFirstNST> refer_to_a1;
|
||||
flatbuffers::unique_ptr<NamespaceA::SecondTableInAT> refer_to_a2;
|
||||
TableInCT() {
|
||||
}
|
||||
};
|
||||
|
||||
inline bool operator==(const TableInCT &lhs, const TableInCT &rhs) {
|
||||
return
|
||||
(lhs.refer_to_a1 == rhs.refer_to_a1) &&
|
||||
(lhs.refer_to_a2 == rhs.refer_to_a2);
|
||||
}
|
||||
|
||||
inline bool operator!=(const TableInCT &lhs, const TableInCT &rhs) {
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
|
||||
struct TableInC FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
|
||||
typedef TableInCT NativeTableType;
|
||||
static const flatbuffers::TypeTable *MiniReflectTypeTable() {
|
||||
return TableInCTypeTable();
|
||||
}
|
||||
@@ -143,6 +207,9 @@ struct TableInC FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
|
||||
verifier.VerifyTable(refer_to_a2()) &&
|
||||
verifier.EndTable();
|
||||
}
|
||||
TableInCT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const;
|
||||
void UnPackTo(TableInCT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const;
|
||||
static flatbuffers::Offset<TableInC> Pack(flatbuffers::FlatBufferBuilder &_fbb, const TableInCT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr);
|
||||
};
|
||||
|
||||
struct TableInCBuilder {
|
||||
@@ -176,11 +243,31 @@ inline flatbuffers::Offset<TableInC> CreateTableInC(
|
||||
return builder_.Finish();
|
||||
}
|
||||
|
||||
flatbuffers::Offset<TableInC> CreateTableInC(flatbuffers::FlatBufferBuilder &_fbb, const TableInCT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr);
|
||||
|
||||
} // namespace NamespaceC
|
||||
|
||||
namespace NamespaceA {
|
||||
|
||||
struct SecondTableInAT : public flatbuffers::NativeTable {
|
||||
typedef SecondTableInA TableType;
|
||||
flatbuffers::unique_ptr<NamespaceC::TableInCT> refer_to_c;
|
||||
SecondTableInAT() {
|
||||
}
|
||||
};
|
||||
|
||||
inline bool operator==(const SecondTableInAT &lhs, const SecondTableInAT &rhs) {
|
||||
return
|
||||
(lhs.refer_to_c == rhs.refer_to_c);
|
||||
}
|
||||
|
||||
inline bool operator!=(const SecondTableInAT &lhs, const SecondTableInAT &rhs) {
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
|
||||
struct SecondTableInA FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
|
||||
typedef SecondTableInAT NativeTableType;
|
||||
static const flatbuffers::TypeTable *MiniReflectTypeTable() {
|
||||
return SecondTableInATypeTable();
|
||||
}
|
||||
@@ -199,6 +286,9 @@ struct SecondTableInA FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
|
||||
verifier.VerifyTable(refer_to_c()) &&
|
||||
verifier.EndTable();
|
||||
}
|
||||
SecondTableInAT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const;
|
||||
void UnPackTo(SecondTableInAT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const;
|
||||
static flatbuffers::Offset<SecondTableInA> Pack(flatbuffers::FlatBufferBuilder &_fbb, const SecondTableInAT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr);
|
||||
};
|
||||
|
||||
struct SecondTableInABuilder {
|
||||
@@ -227,14 +317,103 @@ inline flatbuffers::Offset<SecondTableInA> CreateSecondTableInA(
|
||||
return builder_.Finish();
|
||||
}
|
||||
|
||||
flatbuffers::Offset<SecondTableInA> CreateSecondTableInA(flatbuffers::FlatBufferBuilder &_fbb, const SecondTableInAT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr);
|
||||
|
||||
inline TableInFirstNST *TableInFirstNS::UnPack(const flatbuffers::resolver_function_t *_resolver) const {
|
||||
auto _o = new TableInFirstNST();
|
||||
UnPackTo(_o, _resolver);
|
||||
return _o;
|
||||
}
|
||||
|
||||
inline void TableInFirstNS::UnPackTo(TableInFirstNST *_o, const flatbuffers::resolver_function_t *_resolver) const {
|
||||
(void)_o;
|
||||
(void)_resolver;
|
||||
{ auto _e = foo_table(); if (_e) _o->foo_table = flatbuffers::unique_ptr<NamespaceA::NamespaceB::TableInNestedNST>(_e->UnPack(_resolver)); }
|
||||
{ auto _e = foo_enum(); _o->foo_enum = _e; }
|
||||
{ auto _e = foo_struct(); if (_e) _o->foo_struct = flatbuffers::unique_ptr<NamespaceA::NamespaceB::StructInNestedNS>(new NamespaceA::NamespaceB::StructInNestedNS(*_e)); }
|
||||
}
|
||||
|
||||
inline flatbuffers::Offset<TableInFirstNS> TableInFirstNS::Pack(flatbuffers::FlatBufferBuilder &_fbb, const TableInFirstNST* _o, const flatbuffers::rehasher_function_t *_rehasher) {
|
||||
return CreateTableInFirstNS(_fbb, _o, _rehasher);
|
||||
}
|
||||
|
||||
inline flatbuffers::Offset<TableInFirstNS> CreateTableInFirstNS(flatbuffers::FlatBufferBuilder &_fbb, const TableInFirstNST *_o, const flatbuffers::rehasher_function_t *_rehasher) {
|
||||
(void)_rehasher;
|
||||
(void)_o;
|
||||
struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const TableInFirstNST* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va;
|
||||
auto _foo_table = _o->foo_table ? CreateTableInNestedNS(_fbb, _o->foo_table.get(), _rehasher) : 0;
|
||||
auto _foo_enum = _o->foo_enum;
|
||||
auto _foo_struct = _o->foo_struct ? _o->foo_struct.get() : 0;
|
||||
return NamespaceA::CreateTableInFirstNS(
|
||||
_fbb,
|
||||
_foo_table,
|
||||
_foo_enum,
|
||||
_foo_struct);
|
||||
}
|
||||
|
||||
} // namespace NamespaceA
|
||||
|
||||
namespace NamespaceC {
|
||||
|
||||
inline TableInCT *TableInC::UnPack(const flatbuffers::resolver_function_t *_resolver) const {
|
||||
auto _o = new TableInCT();
|
||||
UnPackTo(_o, _resolver);
|
||||
return _o;
|
||||
}
|
||||
|
||||
inline void TableInC::UnPackTo(TableInCT *_o, const flatbuffers::resolver_function_t *_resolver) const {
|
||||
(void)_o;
|
||||
(void)_resolver;
|
||||
{ auto _e = refer_to_a1(); if (_e) _o->refer_to_a1 = flatbuffers::unique_ptr<NamespaceA::TableInFirstNST>(_e->UnPack(_resolver)); }
|
||||
{ auto _e = refer_to_a2(); if (_e) _o->refer_to_a2 = flatbuffers::unique_ptr<NamespaceA::SecondTableInAT>(_e->UnPack(_resolver)); }
|
||||
}
|
||||
|
||||
inline flatbuffers::Offset<TableInC> TableInC::Pack(flatbuffers::FlatBufferBuilder &_fbb, const TableInCT* _o, const flatbuffers::rehasher_function_t *_rehasher) {
|
||||
return CreateTableInC(_fbb, _o, _rehasher);
|
||||
}
|
||||
|
||||
inline flatbuffers::Offset<TableInC> CreateTableInC(flatbuffers::FlatBufferBuilder &_fbb, const TableInCT *_o, const flatbuffers::rehasher_function_t *_rehasher) {
|
||||
(void)_rehasher;
|
||||
(void)_o;
|
||||
struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const TableInCT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va;
|
||||
auto _refer_to_a1 = _o->refer_to_a1 ? CreateTableInFirstNS(_fbb, _o->refer_to_a1.get(), _rehasher) : 0;
|
||||
auto _refer_to_a2 = _o->refer_to_a2 ? CreateSecondTableInA(_fbb, _o->refer_to_a2.get(), _rehasher) : 0;
|
||||
return NamespaceC::CreateTableInC(
|
||||
_fbb,
|
||||
_refer_to_a1,
|
||||
_refer_to_a2);
|
||||
}
|
||||
|
||||
} // namespace NamespaceC
|
||||
|
||||
namespace NamespaceA {
|
||||
|
||||
inline SecondTableInAT *SecondTableInA::UnPack(const flatbuffers::resolver_function_t *_resolver) const {
|
||||
auto _o = new SecondTableInAT();
|
||||
UnPackTo(_o, _resolver);
|
||||
return _o;
|
||||
}
|
||||
|
||||
inline void SecondTableInA::UnPackTo(SecondTableInAT *_o, const flatbuffers::resolver_function_t *_resolver) const {
|
||||
(void)_o;
|
||||
(void)_resolver;
|
||||
{ auto _e = refer_to_c(); if (_e) _o->refer_to_c = flatbuffers::unique_ptr<NamespaceC::TableInCT>(_e->UnPack(_resolver)); }
|
||||
}
|
||||
|
||||
inline flatbuffers::Offset<SecondTableInA> SecondTableInA::Pack(flatbuffers::FlatBufferBuilder &_fbb, const SecondTableInAT* _o, const flatbuffers::rehasher_function_t *_rehasher) {
|
||||
return CreateSecondTableInA(_fbb, _o, _rehasher);
|
||||
}
|
||||
|
||||
inline flatbuffers::Offset<SecondTableInA> CreateSecondTableInA(flatbuffers::FlatBufferBuilder &_fbb, const SecondTableInAT *_o, const flatbuffers::rehasher_function_t *_rehasher) {
|
||||
(void)_rehasher;
|
||||
(void)_o;
|
||||
struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const SecondTableInAT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va;
|
||||
auto _refer_to_c = _o->refer_to_c ? CreateTableInC(_fbb, _o->refer_to_c.get(), _rehasher) : 0;
|
||||
return NamespaceA::CreateSecondTableInA(
|
||||
_fbb,
|
||||
_refer_to_c);
|
||||
}
|
||||
|
||||
inline const flatbuffers::TypeTable *TableInFirstNSTypeTable() {
|
||||
static const flatbuffers::TypeCode type_codes[] = {
|
||||
{ flatbuffers::ET_SEQUENCE, 0, 0 },
|
||||
|
||||
@@ -6,7 +6,6 @@ library namespace_a;
|
||||
import 'dart:typed_data' show Uint8List;
|
||||
import 'package:flat_buffers/flat_buffers.dart' as fb;
|
||||
|
||||
import 'namespace_test1_namespace_a_generated.dart';
|
||||
import './namespace_test2_namespace_c_generated.dart' as namespace_c;
|
||||
|
||||
class TableInFirstNS {
|
||||
|
||||
@@ -6,7 +6,6 @@ library namespace_c;
|
||||
import 'dart:typed_data' show Uint8List;
|
||||
import 'package:flat_buffers/flat_buffers.dart' as fb;
|
||||
|
||||
import 'namespace_test1_namespace_c_generated.dart';
|
||||
import './namespace_test2_namespace_a_generated.dart' as namespace_a;
|
||||
|
||||
class TableInC {
|
||||
|
||||
@@ -1459,7 +1459,7 @@ void FuzzTest2() {
|
||||
break;
|
||||
}
|
||||
}
|
||||
TEST_NOTNULL(nullptr);
|
||||
TEST_NOTNULL(nullptr); //-V501 (this comment supresses CWE-570 warning)
|
||||
}
|
||||
|
||||
// clang-format off
|
||||
|
||||
@@ -5,11 +5,6 @@
|
||||
|
||||
using namespace MyGame::Example;
|
||||
|
||||
const std::string m1_name = "Cyberdemon";
|
||||
const Color m1_color = Color_Red;
|
||||
const std::string m2_name = "Imp";
|
||||
const Color m2_color = Color_Green;
|
||||
|
||||
struct OwnedAllocator : public flatbuffers::DefaultAllocator {};
|
||||
|
||||
class TestHeapBuilder : public flatbuffers::FlatBufferBuilder {
|
||||
@@ -88,14 +83,14 @@ struct GrpcLikeMessageBuilder : private AllocatorMember,
|
||||
|
||||
flatbuffers::Offset<Monster> populate1(
|
||||
flatbuffers::FlatBufferBuilder &builder) {
|
||||
auto name_offset = builder.CreateString(m1_name);
|
||||
return CreateMonster(builder, nullptr, 0, 0, name_offset, 0, m1_color);
|
||||
auto name_offset = builder.CreateString(m1_name());
|
||||
return CreateMonster(builder, nullptr, 0, 0, name_offset, 0, m1_color());
|
||||
}
|
||||
|
||||
flatbuffers::Offset<Monster> populate2(
|
||||
flatbuffers::FlatBufferBuilder &builder) {
|
||||
auto name_offset = builder.CreateString(m2_name);
|
||||
return CreateMonster(builder, nullptr, 0, 0, name_offset, 0, m2_color);
|
||||
auto name_offset = builder.CreateString(m2_name());
|
||||
return CreateMonster(builder, nullptr, 0, 0, name_offset, 0, m2_color());
|
||||
}
|
||||
|
||||
uint8_t *release_raw_base(flatbuffers::FlatBufferBuilder &fbb, size_t &size,
|
||||
@@ -158,3 +153,7 @@ void FlatBufferBuilderTest() {
|
||||
BuilderReuseTests<GrpcLikeMessageBuilder, GrpcLikeMessageBuilder>::run_tests(
|
||||
TestSelector(tests, tests + 4));
|
||||
}
|
||||
|
||||
// Link-time check using pointer type.
|
||||
void CheckTestGeneratedIsValid(const MyGame::Example::Color&)
|
||||
{}
|
||||
@@ -21,10 +21,19 @@ template<class T, class U> struct is_same { static const bool value = false; };
|
||||
|
||||
template<class T> struct is_same<T, T> { static const bool value = true; };
|
||||
|
||||
extern const std::string m1_name;
|
||||
extern const Color m1_color;
|
||||
extern const std::string m2_name;
|
||||
extern const Color m2_color;
|
||||
inline std::string m1_name() { return "Cyberdemon"; }
|
||||
inline std::string m2_name() { return "Imp"; }
|
||||
inline MyGame::Example::Color m1_color() {
|
||||
return MyGame::Example::Color_Red;
|
||||
}
|
||||
inline MyGame::Example::Color m2_color() {
|
||||
return MyGame::Example::Color_Green;
|
||||
}
|
||||
inline void m1_color_check() {
|
||||
// Ensure that all compilation units see the same monster_test_generated.h.
|
||||
extern void CheckTestGeneratedIsValid(const MyGame::Example::Color&);
|
||||
CheckTestGeneratedIsValid(m1_color());
|
||||
}
|
||||
|
||||
flatbuffers::Offset<Monster> populate1(flatbuffers::FlatBufferBuilder &builder);
|
||||
flatbuffers::Offset<Monster> populate2(flatbuffers::FlatBufferBuilder &builder);
|
||||
@@ -66,7 +75,7 @@ void builder_move_assign_after_releaseraw_test(Builder b1) {
|
||||
// Move into a released builder.
|
||||
b1 = std::move(src);
|
||||
TEST_EQ_FUNC(b1.GetSize(), src_size);
|
||||
TEST_ASSERT_FUNC(release_n_verify(b1, m2_name, m2_color));
|
||||
TEST_ASSERT_FUNC(release_n_verify(b1, m2_name(), m2_color()));
|
||||
TEST_EQ_FUNC(src.GetSize(), 0);
|
||||
}
|
||||
// clang-format off
|
||||
@@ -104,7 +113,7 @@ struct BuilderTests {
|
||||
auto root_offset1 = populate1(src);
|
||||
DestBuilder dst(std::move(src));
|
||||
dst.Finish(root_offset1);
|
||||
TEST_ASSERT_FUNC(release_n_verify(dst, m1_name, m1_color));
|
||||
TEST_ASSERT_FUNC(release_n_verify(dst, m1_name(), m1_color()));
|
||||
TEST_EQ_FUNC(src.GetSize(), 0);
|
||||
}
|
||||
|
||||
@@ -115,7 +124,7 @@ struct BuilderTests {
|
||||
auto src_size = src.GetSize();
|
||||
DestBuilder dst(std::move(src));
|
||||
TEST_EQ_FUNC(dst.GetSize(), src_size);
|
||||
TEST_ASSERT_FUNC(release_n_verify(dst, m1_name, m1_color));
|
||||
TEST_ASSERT_FUNC(release_n_verify(dst, m1_name(), m1_color()));
|
||||
TEST_EQ_FUNC(src.GetSize(), 0);
|
||||
}
|
||||
|
||||
@@ -126,7 +135,7 @@ struct BuilderTests {
|
||||
populate2(dst);
|
||||
dst = std::move(src);
|
||||
dst.Finish(root_offset1);
|
||||
TEST_ASSERT_FUNC(release_n_verify(dst, m1_name, m1_color));
|
||||
TEST_ASSERT_FUNC(release_n_verify(dst, m1_name(), m1_color()));
|
||||
TEST_EQ_FUNC(src.GetSize(), 0);
|
||||
}
|
||||
|
||||
@@ -140,7 +149,7 @@ struct BuilderTests {
|
||||
dst.Finish(root_offset2);
|
||||
dst = std::move(src);
|
||||
TEST_EQ_FUNC(dst.GetSize(), src_size);
|
||||
TEST_ASSERT_FUNC(release_n_verify(dst, m1_name, m1_color));
|
||||
TEST_ASSERT_FUNC(release_n_verify(dst, m1_name(), m1_color()));
|
||||
TEST_EQ_FUNC(src.GetSize(), 0);
|
||||
}
|
||||
|
||||
@@ -159,7 +168,7 @@ struct BuilderTests {
|
||||
// Move into a released builder.
|
||||
dst = std::move(src);
|
||||
TEST_EQ_FUNC(dst.GetSize(), src_size);
|
||||
TEST_ASSERT_FUNC(release_n_verify(dst, m2_name, m2_color));
|
||||
TEST_ASSERT_FUNC(release_n_verify(dst, m2_name(), m2_color()));
|
||||
TEST_EQ_FUNC(src.GetSize(), 0);
|
||||
}
|
||||
// clang-format off
|
||||
@@ -181,8 +190,8 @@ struct BuilderTests {
|
||||
dst.Finish(root_offset1);
|
||||
TEST_EQ_FUNC(src.GetSize() > size2, true);
|
||||
TEST_EQ_FUNC(dst.GetSize() > size1, true);
|
||||
TEST_ASSERT_FUNC(release_n_verify(src, m2_name, m2_color));
|
||||
TEST_ASSERT_FUNC(release_n_verify(dst, m1_name, m1_color));
|
||||
TEST_ASSERT_FUNC(release_n_verify(src, m2_name(), m2_color()));
|
||||
TEST_ASSERT_FUNC(release_n_verify(dst, m1_name(), m1_color()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -201,8 +210,8 @@ struct BuilderTests {
|
||||
src.Swap(dst);
|
||||
TEST_EQ_FUNC(src.GetSize(), size2);
|
||||
TEST_EQ_FUNC(dst.GetSize(), size1);
|
||||
TEST_ASSERT_FUNC(release_n_verify(src, m2_name, m2_color));
|
||||
TEST_ASSERT_FUNC(release_n_verify(dst, m1_name, m1_color));
|
||||
TEST_ASSERT_FUNC(release_n_verify(src, m2_name(), m2_color()));
|
||||
TEST_ASSERT_FUNC(release_n_verify(dst, m1_name(), m1_color()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -247,7 +256,7 @@ template<class DestBuilder, class SrcBuilder> struct BuilderReuseTests {
|
||||
auto root_offset1 = populate1(fbb);
|
||||
fbb.Finish(root_offset1);
|
||||
buffers.push_back(fbb.Release());
|
||||
TEST_ASSERT_FUNC(verify(buffers[i], m1_name, m1_color));
|
||||
TEST_ASSERT_FUNC(verify(buffers[i], m1_name(), m1_color()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -260,7 +269,7 @@ template<class DestBuilder, class SrcBuilder> struct BuilderReuseTests {
|
||||
fbb.Finish(root_offset1);
|
||||
size_t size, offset;
|
||||
uint8_t *buf = release_raw_base(fbb, size, offset);
|
||||
TEST_ASSERT_FUNC(verify(buf, offset, m1_name, m1_color));
|
||||
TEST_ASSERT_FUNC(verify(buf, offset, m1_name(), m1_color()));
|
||||
free_raw(fbb, buf);
|
||||
}
|
||||
}
|
||||
@@ -278,7 +287,7 @@ template<class DestBuilder, class SrcBuilder> struct BuilderReuseTests {
|
||||
auto root_offset1 = populate1(dst);
|
||||
dst.Finish(root_offset1);
|
||||
buffers.push_back(dst.Release());
|
||||
TEST_ASSERT_FUNC(verify(buffers[i], m1_name, m1_color));
|
||||
TEST_ASSERT_FUNC(verify(buffers[i], m1_name(), m1_color()));
|
||||
SrcBuilder src;
|
||||
dst = std::move(src);
|
||||
TEST_EQ_FUNC(src.GetSize(), 0);
|
||||
@@ -295,7 +304,7 @@ template<class DestBuilder, class SrcBuilder> struct BuilderReuseTests {
|
||||
dst.Finish(root_offset1);
|
||||
size_t size, offset;
|
||||
uint8_t *buf = release_raw_base(dst, size, offset);
|
||||
TEST_ASSERT_FUNC(verify(buf, offset, m1_name, m1_color));
|
||||
TEST_ASSERT_FUNC(verify(buf, offset, m1_name(), m1_color()));
|
||||
free_raw(dst, buf);
|
||||
SrcBuilder src;
|
||||
dst = std::move(src);
|
||||
|
||||
@@ -73,7 +73,7 @@ inline const char * const *EnumNamesCharacter() {
|
||||
}
|
||||
|
||||
inline const char *EnumNameCharacter(Character e) {
|
||||
if (e < Character_NONE || e > Character_Unused) return "";
|
||||
if (flatbuffers::IsOutRange(e, Character_NONE, Character_Unused)) return "";
|
||||
const size_t index = static_cast<size_t>(e);
|
||||
return EnumNamesCharacter()[index];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user