mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-03 04:21:13 +00:00
Size verifier fix 2 (#8740)
* Fixes to make SizeVerifier work. In particular change all the places in the Flatbuffers library and generated code that were using `Verifier` to instead use `VerifierTemplate<TrackBufferSize>` and wrap them all inside `template <bool TrackBufferSize = false>`. Also add unit tests for SizeVerifier. * Format using `sh scripts/clang-format-git.sh` * Use `B` rather than `TrackBufferSize` for the name of the template parameter. * Update generated files.
This commit is contained in:
@@ -395,7 +395,8 @@ struct ScalarStuff FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
||||
else if constexpr (Index == 35) return default_enum();
|
||||
else static_assert(Index != -1, "Invalid Field Index");
|
||||
}
|
||||
bool Verify(::flatbuffers::Verifier &verifier) const {
|
||||
template <bool B = false>
|
||||
bool Verify(::flatbuffers::VerifierTemplate<B> &verifier) const {
|
||||
return VerifyTableStart(verifier) &&
|
||||
VerifyField<int8_t>(verifier, VT_JUST_I8, 1) &&
|
||||
VerifyField<int8_t>(verifier, VT_MAYBE_I8, 1) &&
|
||||
@@ -958,14 +959,16 @@ inline bool SizePrefixedScalarStuffBufferHasIdentifier(const void *buf) {
|
||||
buf, ScalarStuffIdentifier(), true);
|
||||
}
|
||||
|
||||
template <bool B = false>
|
||||
inline bool VerifyScalarStuffBuffer(
|
||||
::flatbuffers::Verifier &verifier) {
|
||||
return verifier.VerifyBuffer<optional_scalars::ScalarStuff>(ScalarStuffIdentifier());
|
||||
::flatbuffers::VerifierTemplate<B> &verifier) {
|
||||
return verifier.template VerifyBuffer<optional_scalars::ScalarStuff>(ScalarStuffIdentifier());
|
||||
}
|
||||
|
||||
template <bool B = false>
|
||||
inline bool VerifySizePrefixedScalarStuffBuffer(
|
||||
::flatbuffers::Verifier &verifier) {
|
||||
return verifier.VerifySizePrefixedBuffer<optional_scalars::ScalarStuff>(ScalarStuffIdentifier());
|
||||
::flatbuffers::VerifierTemplate<B> &verifier) {
|
||||
return verifier.template VerifySizePrefixedBuffer<optional_scalars::ScalarStuff>(ScalarStuffIdentifier());
|
||||
}
|
||||
|
||||
inline const char *ScalarStuffExtension() {
|
||||
|
||||
Reference in New Issue
Block a user