From fad9afbc9a909dcf9393c4f7ecbbf76e59a538f3 Mon Sep 17 00:00:00 2001 From: halx99 Date: Thu, 15 Sep 2022 20:15:28 +0800 Subject: [PATCH] Update thirdparty libs fmt: 9.0.0 --> 9.1.0 llhttp: 6.0.7 --> 6.0.9 astc-encoder: 4.0.0 --> 4.1.0 webp: 1.2.2 --> 1.2.4 flatbuffers: 2.0.0 --> 2.0.8 --- .github/workflows/clang-format.yml | 4 +- core/base/astc.cpp | 2 +- .../CSLanguageDataBinary_generated.h | 236 +- .../cocostudio/CSParse3DBinary_generated.h | 1189 +- .../cocostudio/CSParseBinary_generated.h | 9934 +++++++++-------- .../CSArmatureNode_generated.h | 391 +- .../SkeletonReader/CSBoneBinary_generated.h | 149 +- .../TabControlReader/CSTabControl_generated.h | 654 +- thirdparty/README.md | 10 +- thirdparty/astc/astcenc_compress_symbolic.cpp | 2 +- thirdparty/astc/astcenc_compute_variance.cpp | 65 +- thirdparty/astc/astcenc_entry.cpp | 138 +- thirdparty/astc/astcenc_internal.h | 258 +- thirdparty/astc/astcenc_internal_entry.h | 273 + .../astcenc_pick_best_endpoint_format.cpp | 4 +- thirdparty/astc/astcenc_vecmathlib_neon_4.h | 36 +- thirdparty/astc/astcenc_vecmathlib_sse_4.h | 30 +- thirdparty/flatbuffers/allocator.h | 68 + thirdparty/flatbuffers/array.h | 243 + thirdparty/flatbuffers/base.h | 87 +- thirdparty/flatbuffers/buffer.h | 142 + thirdparty/flatbuffers/buffer_ref.h | 53 + thirdparty/flatbuffers/default_allocator.h | 64 + thirdparty/flatbuffers/detached_buffer.h | 114 + thirdparty/flatbuffers/flatbuffer_builder.h | 1214 ++ thirdparty/flatbuffers/flatbuffers.h | 2730 +---- thirdparty/flatbuffers/stl_emulation.h | 439 +- thirdparty/flatbuffers/string.h | 64 + thirdparty/flatbuffers/struct.h | 53 + thirdparty/flatbuffers/table.h | 168 + thirdparty/flatbuffers/vector.h | 389 + thirdparty/flatbuffers/vector_downward.h | 271 + thirdparty/flatbuffers/verifier.h | 317 + thirdparty/fmt/CMakeLists.txt | 6 - thirdparty/fmt/ChangeLog.rst | 128 +- thirdparty/fmt/README.rst | 3 - thirdparty/fmt/include/fmt/chrono.h | 45 +- thirdparty/fmt/include/fmt/color.h | 2 +- thirdparty/fmt/include/fmt/compile.h | 26 +- thirdparty/fmt/include/fmt/core.h | 79 +- thirdparty/fmt/include/fmt/format-inl.h | 50 +- thirdparty/fmt/include/fmt/format.h | 105 +- thirdparty/fmt/include/fmt/ostream.h | 102 +- thirdparty/fmt/include/fmt/ranges.h | 261 +- thirdparty/fmt/include/fmt/std.h | 5 - thirdparty/fmt/include/fmt/xchar.h | 13 +- thirdparty/fmt/support/appveyor-build.py | 43 - thirdparty/fmt/support/appveyor.yml | 31 - thirdparty/fmt/support/manage.py | 6 + thirdparty/llhttp/include/llhttp.h | 5 +- thirdparty/llhttp/src/llhttp.c | 1080 +- thirdparty/webp/sharpyuv/sharpyuv.c | 498 + thirdparty/webp/sharpyuv/sharpyuv.h | 81 + thirdparty/webp/sharpyuv/sharpyuv_csp.c | 110 + thirdparty/webp/sharpyuv/sharpyuv_csp.h | 59 + thirdparty/webp/sharpyuv/sharpyuv_dsp.c | 102 + thirdparty/webp/sharpyuv/sharpyuv_dsp.h | 29 + thirdparty/webp/sharpyuv/sharpyuv_gamma.c | 114 + thirdparty/webp/sharpyuv/sharpyuv_gamma.h | 35 + thirdparty/webp/sharpyuv/sharpyuv_neon.c | 182 + thirdparty/webp/sharpyuv/sharpyuv_sse2.c | 204 + thirdparty/webp/src/dec/vp8i_dec.h | 2 +- thirdparty/webp/src/dec/vp8l_dec.c | 6 +- thirdparty/webp/src/demux/demux.c | 5 +- .../webp/src/dsp/alpha_processing_neon.c | 6 +- thirdparty/webp/src/dsp/cpu.c | 2 +- thirdparty/webp/src/dsp/cpu.h | 254 + thirdparty/webp/src/dsp/dsp.h | 229 +- thirdparty/webp/src/dsp/lossless.h | 8 +- thirdparty/webp/src/dsp/lossless_enc.c | 12 +- thirdparty/webp/src/dsp/lossless_enc_mips32.c | 22 +- thirdparty/webp/src/dsp/lossless_enc_sse2.c | 4 +- thirdparty/webp/src/dsp/yuv.c | 64 - thirdparty/webp/src/dsp/yuv_neon.c | 108 - thirdparty/webp/src/dsp/yuv_sse2.c | 119 - thirdparty/webp/src/enc/alpha_enc.c | 2 +- .../src/enc/backward_references_cost_enc.c | 77 +- .../webp/src/enc/backward_references_enc.c | 86 +- .../webp/src/enc/backward_references_enc.h | 12 +- thirdparty/webp/src/enc/histogram_enc.c | 208 +- thirdparty/webp/src/enc/histogram_enc.h | 24 +- thirdparty/webp/src/enc/picture_csp_enc.c | 498 +- thirdparty/webp/src/enc/picture_enc.c | 44 +- thirdparty/webp/src/enc/picture_rescale_enc.c | 72 +- thirdparty/webp/src/enc/picture_tools_enc.c | 45 +- thirdparty/webp/src/enc/predictor_enc.c | 50 +- thirdparty/webp/src/enc/quant_enc.c | 62 +- thirdparty/webp/src/enc/vp8i_enc.h | 24 +- thirdparty/webp/src/enc/vp8l_enc.c | 529 +- thirdparty/webp/src/enc/vp8li_enc.h | 24 +- thirdparty/webp/src/enc/webp_enc.c | 4 +- thirdparty/webp/src/mux/muxedit.c | 1 + thirdparty/webp/src/mux/muxi.h | 2 +- thirdparty/webp/src/mux/muxinternal.c | 9 +- thirdparty/webp/src/webp/encode.h | 6 +- 95 files changed, 14618 insertions(+), 11197 deletions(-) create mode 100644 thirdparty/astc/astcenc_internal_entry.h create mode 100644 thirdparty/flatbuffers/allocator.h create mode 100644 thirdparty/flatbuffers/array.h create mode 100644 thirdparty/flatbuffers/buffer.h create mode 100644 thirdparty/flatbuffers/buffer_ref.h create mode 100644 thirdparty/flatbuffers/default_allocator.h create mode 100644 thirdparty/flatbuffers/detached_buffer.h create mode 100644 thirdparty/flatbuffers/flatbuffer_builder.h create mode 100644 thirdparty/flatbuffers/string.h create mode 100644 thirdparty/flatbuffers/struct.h create mode 100644 thirdparty/flatbuffers/table.h create mode 100644 thirdparty/flatbuffers/vector.h create mode 100644 thirdparty/flatbuffers/vector_downward.h create mode 100644 thirdparty/flatbuffers/verifier.h delete mode 100644 thirdparty/fmt/support/appveyor-build.py delete mode 100644 thirdparty/fmt/support/appveyor.yml create mode 100644 thirdparty/webp/sharpyuv/sharpyuv.c create mode 100644 thirdparty/webp/sharpyuv/sharpyuv.h create mode 100644 thirdparty/webp/sharpyuv/sharpyuv_csp.c create mode 100644 thirdparty/webp/sharpyuv/sharpyuv_csp.h create mode 100644 thirdparty/webp/sharpyuv/sharpyuv_dsp.c create mode 100644 thirdparty/webp/sharpyuv/sharpyuv_dsp.h create mode 100644 thirdparty/webp/sharpyuv/sharpyuv_gamma.c create mode 100644 thirdparty/webp/sharpyuv/sharpyuv_gamma.h create mode 100644 thirdparty/webp/sharpyuv/sharpyuv_neon.c create mode 100644 thirdparty/webp/sharpyuv/sharpyuv_sse2.c create mode 100644 thirdparty/webp/src/dsp/cpu.h diff --git a/.github/workflows/clang-format.yml b/.github/workflows/clang-format.yml index d1f519846a..d47c453d19 100644 --- a/.github/workflows/clang-format.yml +++ b/.github/workflows/clang-format.yml @@ -19,10 +19,10 @@ jobs: - uses: actions/checkout@v2 - name: Run clang-format lint - uses: DoozyX/clang-format-lint-action@v0.13 + uses: DoozyX/clang-format-lint-action@v0.14 with: source: './core ./extensions ./tests ./templates' - exclude: './thidrparty ./extensions/fairygui ./extensions/scripting/lua-bindings/auto ./extensions/spine ./tests/fairygui-tests' + exclude: './thidrparty ./extensions/fairygui ./extensions/scripting/lua-bindings/auto ./extensions/spine ./tests/fairygui-tests' ./extensions/**/*_generated.h extensions: 'h,cpp,c,mm' clangFormatVersion: 13 inplace: True diff --git a/core/base/astc.cpp b/core/base/astc.cpp index ae56f65bf6..0c5e19af24 100644 --- a/core/base/astc.cpp +++ b/core/base/astc.cpp @@ -19,7 +19,7 @@ #include #include #include "astc/astcenc.h" -#include "astc/astcenc_internal.h" +#include "astc/astcenc_internal_entry.h" #include "yasio/detail/utils.hpp" #define ASTCDEC_NO_CONTEXT 1 diff --git a/extensions/cocostudio/CSLanguageDataBinary_generated.h b/extensions/cocostudio/CSLanguageDataBinary_generated.h index 6830ffb1c6..4465fa3e1b 100644 --- a/extensions/cocostudio/CSLanguageDataBinary_generated.h +++ b/extensions/cocostudio/CSLanguageDataBinary_generated.h @@ -1,151 +1,171 @@ // automatically generated by the FlatBuffers compiler, do not modify + #ifndef FLATBUFFERS_GENERATED_CSLANGUAGEDATABINARY_FLATBUFFERS_H_ #define FLATBUFFERS_GENERATED_CSLANGUAGEDATABINARY_FLATBUFFERS_H_ #include "flatbuffers/flatbuffers.h" -namespace flatbuffers -{ +// Ensure the included flatbuffers.h is the same version as when this file was +// generated, otherwise it may not be compatible. +static_assert(FLATBUFFERS_VERSION_MAJOR == 2 && + FLATBUFFERS_VERSION_MINOR == 0 && + FLATBUFFERS_VERSION_REVISION == 8, + "Non-compatible flatbuffers version included"); + +namespace flatbuffers { struct LanguageItem; +struct LanguageItemBuilder; struct LanguageSet; +struct LanguageSetBuilder; -struct LanguageItem FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table -{ - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE - { - VT_KEY = 4, - VT_VALUE = 6 - }; - const flatbuffers::String* key() const { return GetPointer(VT_KEY); } - const flatbuffers::String* value() const { return GetPointer(VT_VALUE); } - bool Verify(flatbuffers::Verifier& verifier) const - { - return VerifyTableStart(verifier) && VerifyOffset(verifier, VT_KEY) && verifier.VerifyString(key()) && - VerifyOffset(verifier, VT_VALUE) && verifier.VerifyString(value()) && verifier.EndTable(); - } +struct LanguageItem FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { + typedef LanguageItemBuilder Builder; + enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { + VT_KEY = 4, + VT_VALUE = 6 + }; + const flatbuffers::String *key() const { + return GetPointer(VT_KEY); + } + const flatbuffers::String *value() const { + return GetPointer(VT_VALUE); + } + bool Verify(flatbuffers::Verifier &verifier) const { + return VerifyTableStart(verifier) && + VerifyOffset(verifier, VT_KEY) && + verifier.VerifyString(key()) && + VerifyOffset(verifier, VT_VALUE) && + verifier.VerifyString(value()) && + verifier.EndTable(); + } }; -struct LanguageItemBuilder -{ - flatbuffers::FlatBufferBuilder& fbb_; - flatbuffers::uoffset_t start_; - void add_key(flatbuffers::Offset key) { fbb_.AddOffset(LanguageItem::VT_KEY, key); } - void add_value(flatbuffers::Offset value) { fbb_.AddOffset(LanguageItem::VT_VALUE, value); } - explicit LanguageItemBuilder(flatbuffers::FlatBufferBuilder& _fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } - LanguageItemBuilder& operator=(const LanguageItemBuilder&); - flatbuffers::Offset Finish() - { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset(end); - return o; - } +struct LanguageItemBuilder { + typedef LanguageItem Table; + flatbuffers::FlatBufferBuilder &fbb_; + flatbuffers::uoffset_t start_; + void add_key(flatbuffers::Offset key) { + fbb_.AddOffset(LanguageItem::VT_KEY, key); + } + void add_value(flatbuffers::Offset value) { + fbb_.AddOffset(LanguageItem::VT_VALUE, value); + } + explicit LanguageItemBuilder(flatbuffers::FlatBufferBuilder &_fbb) + : fbb_(_fbb) { + start_ = fbb_.StartTable(); + } + flatbuffers::Offset Finish() { + const auto end = fbb_.EndTable(start_); + auto o = flatbuffers::Offset(end); + return o; + } }; -inline flatbuffers::Offset CreateLanguageItem(flatbuffers::FlatBufferBuilder& _fbb, - flatbuffers::Offset key = 0, - flatbuffers::Offset value = 0) -{ - LanguageItemBuilder builder_(_fbb); - builder_.add_value(value); - builder_.add_key(key); - return builder_.Finish(); +inline flatbuffers::Offset CreateLanguageItem( + flatbuffers::FlatBufferBuilder &_fbb, + flatbuffers::Offset key = 0, + flatbuffers::Offset value = 0) { + LanguageItemBuilder builder_(_fbb); + builder_.add_value(value); + builder_.add_key(key); + return builder_.Finish(); } -inline flatbuffers::Offset CreateLanguageItemDirect(flatbuffers::FlatBufferBuilder& _fbb, - const char* key = nullptr, - const char* value = nullptr) -{ - auto key__ = key ? _fbb.CreateString(key) : 0; - auto value__ = value ? _fbb.CreateString(value) : 0; - return flatbuffers::CreateLanguageItem(_fbb, key__, value__); +inline flatbuffers::Offset CreateLanguageItemDirect( + flatbuffers::FlatBufferBuilder &_fbb, + const char *key = nullptr, + const char *value = nullptr) { + auto key__ = key ? _fbb.CreateString(key) : 0; + auto value__ = value ? _fbb.CreateString(value) : 0; + return flatbuffers::CreateLanguageItem( + _fbb, + key__, + value__); } -struct LanguageSet FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table -{ - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE - { - VT_LANGUAGEITEMS = 4 - }; - const flatbuffers::Vector>* languageItems() const - { - return GetPointer>*>(VT_LANGUAGEITEMS); - } - bool Verify(flatbuffers::Verifier& verifier) const - { - return VerifyTableStart(verifier) && VerifyOffset(verifier, VT_LANGUAGEITEMS) && - verifier.VerifyVector(languageItems()) && verifier.VerifyVectorOfTables(languageItems()) && - verifier.EndTable(); - } +struct LanguageSet FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { + typedef LanguageSetBuilder Builder; + enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { + VT_LANGUAGEITEMS = 4 + }; + const flatbuffers::Vector> *languageItems() const { + return GetPointer> *>(VT_LANGUAGEITEMS); + } + bool Verify(flatbuffers::Verifier &verifier) const { + return VerifyTableStart(verifier) && + VerifyOffset(verifier, VT_LANGUAGEITEMS) && + verifier.VerifyVector(languageItems()) && + verifier.VerifyVectorOfTables(languageItems()) && + verifier.EndTable(); + } }; -struct LanguageSetBuilder -{ - flatbuffers::FlatBufferBuilder& fbb_; - flatbuffers::uoffset_t start_; - void add_languageItems(flatbuffers::Offset>> languageItems) - { - fbb_.AddOffset(LanguageSet::VT_LANGUAGEITEMS, languageItems); - } - explicit LanguageSetBuilder(flatbuffers::FlatBufferBuilder& _fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } - LanguageSetBuilder& operator=(const LanguageSetBuilder&); - flatbuffers::Offset Finish() - { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset(end); - return o; - } +struct LanguageSetBuilder { + typedef LanguageSet Table; + flatbuffers::FlatBufferBuilder &fbb_; + flatbuffers::uoffset_t start_; + void add_languageItems(flatbuffers::Offset>> languageItems) { + fbb_.AddOffset(LanguageSet::VT_LANGUAGEITEMS, languageItems); + } + explicit LanguageSetBuilder(flatbuffers::FlatBufferBuilder &_fbb) + : fbb_(_fbb) { + start_ = fbb_.StartTable(); + } + flatbuffers::Offset Finish() { + const auto end = fbb_.EndTable(start_); + auto o = flatbuffers::Offset(end); + return o; + } }; inline flatbuffers::Offset CreateLanguageSet( - flatbuffers::FlatBufferBuilder& _fbb, - flatbuffers::Offset>> languageItems = 0) -{ - LanguageSetBuilder builder_(_fbb); - builder_.add_languageItems(languageItems); - return builder_.Finish(); + flatbuffers::FlatBufferBuilder &_fbb, + flatbuffers::Offset>> languageItems = 0) { + LanguageSetBuilder builder_(_fbb); + builder_.add_languageItems(languageItems); + return builder_.Finish(); } inline flatbuffers::Offset CreateLanguageSetDirect( - flatbuffers::FlatBufferBuilder& _fbb, - const std::vector>* languageItems = nullptr) -{ - auto languageItems__ = languageItems ? _fbb.CreateVector>(*languageItems) : 0; - return flatbuffers::CreateLanguageSet(_fbb, languageItems__); + flatbuffers::FlatBufferBuilder &_fbb, + const std::vector> *languageItems = nullptr) { + auto languageItems__ = languageItems ? _fbb.CreateVector>(*languageItems) : 0; + return flatbuffers::CreateLanguageSet( + _fbb, + languageItems__); } -inline const flatbuffers::LanguageSet* GetLanguageSet(const void* buf) -{ - return flatbuffers::GetRoot(buf); +inline const flatbuffers::LanguageSet *GetLanguageSet(const void *buf) { + return flatbuffers::GetRoot(buf); } -inline const flatbuffers::LanguageSet* GetSizePrefixedLanguageSet(const void* buf) -{ - return flatbuffers::GetSizePrefixedRoot(buf); +inline const flatbuffers::LanguageSet *GetSizePrefixedLanguageSet(const void *buf) { + return flatbuffers::GetSizePrefixedRoot(buf); } -inline bool VerifyLanguageSetBuffer(flatbuffers::Verifier& verifier) -{ - return verifier.VerifyBuffer(nullptr); +inline bool VerifyLanguageSetBuffer( + flatbuffers::Verifier &verifier) { + return verifier.VerifyBuffer(nullptr); } -inline bool VerifySizePrefixedLanguageSetBuffer(flatbuffers::Verifier& verifier) -{ - return verifier.VerifySizePrefixedBuffer(nullptr); +inline bool VerifySizePrefixedLanguageSetBuffer( + flatbuffers::Verifier &verifier) { + return verifier.VerifySizePrefixedBuffer(nullptr); } -inline void FinishLanguageSetBuffer(flatbuffers::FlatBufferBuilder& fbb, - flatbuffers::Offset root) -{ - fbb.Finish(root); +inline void FinishLanguageSetBuffer( + flatbuffers::FlatBufferBuilder &fbb, + flatbuffers::Offset root) { + fbb.Finish(root); } -inline void FinishSizePrefixedLanguageSetBuffer(flatbuffers::FlatBufferBuilder& fbb, - flatbuffers::Offset root) -{ - fbb.FinishSizePrefixed(root); +inline void FinishSizePrefixedLanguageSetBuffer( + flatbuffers::FlatBufferBuilder &fbb, + flatbuffers::Offset root) { + fbb.FinishSizePrefixed(root); } } // namespace flatbuffers diff --git a/extensions/cocostudio/CSParse3DBinary_generated.h b/extensions/cocostudio/CSParse3DBinary_generated.h index 5b875ac671..41fe85b28d 100644 --- a/extensions/cocostudio/CSParse3DBinary_generated.h +++ b/extensions/cocostudio/CSParse3DBinary_generated.h @@ -1,606 +1,739 @@ // automatically generated by the FlatBuffers compiler, do not modify + #ifndef FLATBUFFERS_GENERATED_CSPARSE3DBINARY_FLATBUFFERS_H_ #define FLATBUFFERS_GENERATED_CSPARSE3DBINARY_FLATBUFFERS_H_ #include "flatbuffers/flatbuffers.h" +// Ensure the included flatbuffers.h is the same version as when this file was +// generated, otherwise it may not be compatible. +static_assert(FLATBUFFERS_VERSION_MAJOR == 2 && + FLATBUFFERS_VERSION_MINOR == 0 && + FLATBUFFERS_VERSION_REVISION == 8, + "Non-compatible flatbuffers version included"); + #include "CSParseBinary_generated.h" -namespace flatbuffers -{ +namespace flatbuffers { struct Node3DOption; +struct Node3DOptionBuilder; struct Sprite3DOptions; +struct Sprite3DOptionsBuilder; struct Particle3DOptions; +struct Particle3DOptionsBuilder; struct UserCameraOptions; +struct UserCameraOptionsBuilder; struct GameNode3DOption; +struct GameNode3DOptionBuilder; struct Light3DOption; +struct Light3DOptionBuilder; -struct Node3DOption FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table -{ - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE - { - VT_NODEOPTIONS = 4, - VT_POSITION3D = 6, - VT_ROTATION3D = 8, - VT_SCALE3D = 10, - VT_CAMERAMASK = 12 - }; - const WidgetOptions* nodeOptions() const { return GetPointer(VT_NODEOPTIONS); } - const FVec3* position3D() const { return GetStruct(VT_POSITION3D); } - const FVec3* rotation3D() const { return GetStruct(VT_ROTATION3D); } - const FVec3* scale3D() const { return GetStruct(VT_SCALE3D); } - int32_t cameramask() const { return GetField(VT_CAMERAMASK, 0); } - bool Verify(flatbuffers::Verifier& verifier) const - { - return VerifyTableStart(verifier) && VerifyOffset(verifier, VT_NODEOPTIONS) && - verifier.VerifyTable(nodeOptions()) && VerifyField(verifier, VT_POSITION3D) && - VerifyField(verifier, VT_ROTATION3D) && VerifyField(verifier, VT_SCALE3D) && - VerifyField(verifier, VT_CAMERAMASK) && verifier.EndTable(); - } +struct Node3DOption FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { + typedef Node3DOptionBuilder Builder; + enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { + VT_NODEOPTIONS = 4, + VT_POSITION3D = 6, + VT_ROTATION3D = 8, + VT_SCALE3D = 10, + VT_CAMERAMASK = 12 + }; + const flatbuffers::WidgetOptions *nodeOptions() const { + return GetPointer(VT_NODEOPTIONS); + } + const flatbuffers::FVec3 *position3D() const { + return GetStruct(VT_POSITION3D); + } + const flatbuffers::FVec3 *rotation3D() const { + return GetStruct(VT_ROTATION3D); + } + const flatbuffers::FVec3 *scale3D() const { + return GetStruct(VT_SCALE3D); + } + int32_t cameramask() const { + return GetField(VT_CAMERAMASK, 0); + } + bool Verify(flatbuffers::Verifier &verifier) const { + return VerifyTableStart(verifier) && + VerifyOffset(verifier, VT_NODEOPTIONS) && + verifier.VerifyTable(nodeOptions()) && + VerifyField(verifier, VT_POSITION3D, 4) && + VerifyField(verifier, VT_ROTATION3D, 4) && + VerifyField(verifier, VT_SCALE3D, 4) && + VerifyField(verifier, VT_CAMERAMASK, 4) && + verifier.EndTable(); + } }; -struct Node3DOptionBuilder -{ - flatbuffers::FlatBufferBuilder& fbb_; - flatbuffers::uoffset_t start_; - void add_nodeOptions(flatbuffers::Offset nodeOptions) - { - fbb_.AddOffset(Node3DOption::VT_NODEOPTIONS, nodeOptions); - } - void add_position3D(const FVec3* position3D) { fbb_.AddStruct(Node3DOption::VT_POSITION3D, position3D); } - void add_rotation3D(const FVec3* rotation3D) { fbb_.AddStruct(Node3DOption::VT_ROTATION3D, rotation3D); } - void add_scale3D(const FVec3* scale3D) { fbb_.AddStruct(Node3DOption::VT_SCALE3D, scale3D); } - void add_cameramask(int32_t cameramask) { fbb_.AddElement(Node3DOption::VT_CAMERAMASK, cameramask, 0); } - explicit Node3DOptionBuilder(flatbuffers::FlatBufferBuilder& _fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } - Node3DOptionBuilder& operator=(const Node3DOptionBuilder&); - flatbuffers::Offset Finish() - { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset(end); - return o; - } +struct Node3DOptionBuilder { + typedef Node3DOption Table; + flatbuffers::FlatBufferBuilder &fbb_; + flatbuffers::uoffset_t start_; + void add_nodeOptions(flatbuffers::Offset nodeOptions) { + fbb_.AddOffset(Node3DOption::VT_NODEOPTIONS, nodeOptions); + } + void add_position3D(const flatbuffers::FVec3 *position3D) { + fbb_.AddStruct(Node3DOption::VT_POSITION3D, position3D); + } + void add_rotation3D(const flatbuffers::FVec3 *rotation3D) { + fbb_.AddStruct(Node3DOption::VT_ROTATION3D, rotation3D); + } + void add_scale3D(const flatbuffers::FVec3 *scale3D) { + fbb_.AddStruct(Node3DOption::VT_SCALE3D, scale3D); + } + void add_cameramask(int32_t cameramask) { + fbb_.AddElement(Node3DOption::VT_CAMERAMASK, cameramask, 0); + } + explicit Node3DOptionBuilder(flatbuffers::FlatBufferBuilder &_fbb) + : fbb_(_fbb) { + start_ = fbb_.StartTable(); + } + flatbuffers::Offset Finish() { + const auto end = fbb_.EndTable(start_); + auto o = flatbuffers::Offset(end); + return o; + } }; -inline flatbuffers::Offset CreateNode3DOption(flatbuffers::FlatBufferBuilder& _fbb, - flatbuffers::Offset nodeOptions = 0, - const FVec3* position3D = 0, - const FVec3* rotation3D = 0, - const FVec3* scale3D = 0, - int32_t cameramask = 0) -{ - Node3DOptionBuilder builder_(_fbb); - builder_.add_cameramask(cameramask); - builder_.add_scale3D(scale3D); - builder_.add_rotation3D(rotation3D); - builder_.add_position3D(position3D); - builder_.add_nodeOptions(nodeOptions); - return builder_.Finish(); +inline flatbuffers::Offset CreateNode3DOption( + flatbuffers::FlatBufferBuilder &_fbb, + flatbuffers::Offset nodeOptions = 0, + const flatbuffers::FVec3 *position3D = nullptr, + const flatbuffers::FVec3 *rotation3D = nullptr, + const flatbuffers::FVec3 *scale3D = nullptr, + int32_t cameramask = 0) { + Node3DOptionBuilder builder_(_fbb); + builder_.add_cameramask(cameramask); + builder_.add_scale3D(scale3D); + builder_.add_rotation3D(rotation3D); + builder_.add_position3D(position3D); + builder_.add_nodeOptions(nodeOptions); + return builder_.Finish(); } -struct Sprite3DOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table -{ - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE - { - VT_NODE3DOPTION = 4, - VT_FILEDATA = 6, - VT_RUNACTION = 8, - VT_ISFLIPPED = 10, - VT_LIGHTFLAG = 12 - }; - const Node3DOption* node3DOption() const { return GetPointer(VT_NODE3DOPTION); } - const ResourceData* fileData() const { return GetPointer(VT_FILEDATA); } - bool runAction() const { return GetField(VT_RUNACTION, 0) != 0; } - bool isFlipped() const { return GetField(VT_ISFLIPPED, 0) != 0; } - int32_t lightFlag() const { return GetField(VT_LIGHTFLAG, 0); } - bool Verify(flatbuffers::Verifier& verifier) const - { - return VerifyTableStart(verifier) && VerifyOffset(verifier, VT_NODE3DOPTION) && - verifier.VerifyTable(node3DOption()) && VerifyOffset(verifier, VT_FILEDATA) && - verifier.VerifyTable(fileData()) && VerifyField(verifier, VT_RUNACTION) && - VerifyField(verifier, VT_ISFLIPPED) && VerifyField(verifier, VT_LIGHTFLAG) && - verifier.EndTable(); - } +struct Sprite3DOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { + typedef Sprite3DOptionsBuilder Builder; + enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { + VT_NODE3DOPTION = 4, + VT_FILEDATA = 6, + VT_RUNACTION = 8, + VT_ISFLIPPED = 10, + VT_LIGHTFLAG = 12 + }; + const flatbuffers::Node3DOption *node3DOption() const { + return GetPointer(VT_NODE3DOPTION); + } + const flatbuffers::ResourceData *fileData() const { + return GetPointer(VT_FILEDATA); + } + bool runAction() const { + return GetField(VT_RUNACTION, 0) != 0; + } + bool isFlipped() const { + return GetField(VT_ISFLIPPED, 0) != 0; + } + int32_t lightFlag() const { + return GetField(VT_LIGHTFLAG, 0); + } + bool Verify(flatbuffers::Verifier &verifier) const { + return VerifyTableStart(verifier) && + VerifyOffset(verifier, VT_NODE3DOPTION) && + verifier.VerifyTable(node3DOption()) && + VerifyOffset(verifier, VT_FILEDATA) && + verifier.VerifyTable(fileData()) && + VerifyField(verifier, VT_RUNACTION, 1) && + VerifyField(verifier, VT_ISFLIPPED, 1) && + VerifyField(verifier, VT_LIGHTFLAG, 4) && + verifier.EndTable(); + } }; -struct Sprite3DOptionsBuilder -{ - flatbuffers::FlatBufferBuilder& fbb_; - flatbuffers::uoffset_t start_; - void add_node3DOption(flatbuffers::Offset node3DOption) - { - fbb_.AddOffset(Sprite3DOptions::VT_NODE3DOPTION, node3DOption); - } - void add_fileData(flatbuffers::Offset fileData) - { - fbb_.AddOffset(Sprite3DOptions::VT_FILEDATA, fileData); - } - void add_runAction(bool runAction) - { - fbb_.AddElement(Sprite3DOptions::VT_RUNACTION, static_cast(runAction), 0); - } - void add_isFlipped(bool isFlipped) - { - fbb_.AddElement(Sprite3DOptions::VT_ISFLIPPED, static_cast(isFlipped), 0); - } - void add_lightFlag(int32_t lightFlag) { fbb_.AddElement(Sprite3DOptions::VT_LIGHTFLAG, lightFlag, 0); } - explicit Sprite3DOptionsBuilder(flatbuffers::FlatBufferBuilder& _fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } - Sprite3DOptionsBuilder& operator=(const Sprite3DOptionsBuilder&); - flatbuffers::Offset Finish() - { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset(end); - return o; - } +struct Sprite3DOptionsBuilder { + typedef Sprite3DOptions Table; + flatbuffers::FlatBufferBuilder &fbb_; + flatbuffers::uoffset_t start_; + void add_node3DOption(flatbuffers::Offset node3DOption) { + fbb_.AddOffset(Sprite3DOptions::VT_NODE3DOPTION, node3DOption); + } + void add_fileData(flatbuffers::Offset fileData) { + fbb_.AddOffset(Sprite3DOptions::VT_FILEDATA, fileData); + } + void add_runAction(bool runAction) { + fbb_.AddElement(Sprite3DOptions::VT_RUNACTION, static_cast(runAction), 0); + } + void add_isFlipped(bool isFlipped) { + fbb_.AddElement(Sprite3DOptions::VT_ISFLIPPED, static_cast(isFlipped), 0); + } + void add_lightFlag(int32_t lightFlag) { + fbb_.AddElement(Sprite3DOptions::VT_LIGHTFLAG, lightFlag, 0); + } + explicit Sprite3DOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) + : fbb_(_fbb) { + start_ = fbb_.StartTable(); + } + flatbuffers::Offset Finish() { + const auto end = fbb_.EndTable(start_); + auto o = flatbuffers::Offset(end); + return o; + } }; -inline flatbuffers::Offset CreateSprite3DOptions(flatbuffers::FlatBufferBuilder& _fbb, - flatbuffers::Offset node3DOption = 0, - flatbuffers::Offset fileData = 0, - bool runAction = false, - bool isFlipped = false, - int32_t lightFlag = 0) -{ - Sprite3DOptionsBuilder builder_(_fbb); - builder_.add_lightFlag(lightFlag); - builder_.add_fileData(fileData); - builder_.add_node3DOption(node3DOption); - builder_.add_isFlipped(isFlipped); - builder_.add_runAction(runAction); - return builder_.Finish(); +inline flatbuffers::Offset CreateSprite3DOptions( + flatbuffers::FlatBufferBuilder &_fbb, + flatbuffers::Offset node3DOption = 0, + flatbuffers::Offset fileData = 0, + bool runAction = false, + bool isFlipped = false, + int32_t lightFlag = 0) { + Sprite3DOptionsBuilder builder_(_fbb); + builder_.add_lightFlag(lightFlag); + builder_.add_fileData(fileData); + builder_.add_node3DOption(node3DOption); + builder_.add_isFlipped(isFlipped); + builder_.add_runAction(runAction); + return builder_.Finish(); } -struct Particle3DOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table -{ - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE - { - VT_NODE3DOPTION = 4, - VT_FILEDATA = 6 - }; - const Node3DOption* node3DOption() const { return GetPointer(VT_NODE3DOPTION); } - const ResourceData* fileData() const { return GetPointer(VT_FILEDATA); } - bool Verify(flatbuffers::Verifier& verifier) const - { - return VerifyTableStart(verifier) && VerifyOffset(verifier, VT_NODE3DOPTION) && - verifier.VerifyTable(node3DOption()) && VerifyOffset(verifier, VT_FILEDATA) && - verifier.VerifyTable(fileData()) && verifier.EndTable(); - } +struct Particle3DOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { + typedef Particle3DOptionsBuilder Builder; + enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { + VT_NODE3DOPTION = 4, + VT_FILEDATA = 6 + }; + const flatbuffers::Node3DOption *node3DOption() const { + return GetPointer(VT_NODE3DOPTION); + } + const flatbuffers::ResourceData *fileData() const { + return GetPointer(VT_FILEDATA); + } + bool Verify(flatbuffers::Verifier &verifier) const { + return VerifyTableStart(verifier) && + VerifyOffset(verifier, VT_NODE3DOPTION) && + verifier.VerifyTable(node3DOption()) && + VerifyOffset(verifier, VT_FILEDATA) && + verifier.VerifyTable(fileData()) && + verifier.EndTable(); + } }; -struct Particle3DOptionsBuilder -{ - flatbuffers::FlatBufferBuilder& fbb_; - flatbuffers::uoffset_t start_; - void add_node3DOption(flatbuffers::Offset node3DOption) - { - fbb_.AddOffset(Particle3DOptions::VT_NODE3DOPTION, node3DOption); - } - void add_fileData(flatbuffers::Offset fileData) - { - fbb_.AddOffset(Particle3DOptions::VT_FILEDATA, fileData); - } - explicit Particle3DOptionsBuilder(flatbuffers::FlatBufferBuilder& _fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } - Particle3DOptionsBuilder& operator=(const Particle3DOptionsBuilder&); - flatbuffers::Offset Finish() - { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset(end); - return o; - } +struct Particle3DOptionsBuilder { + typedef Particle3DOptions Table; + flatbuffers::FlatBufferBuilder &fbb_; + flatbuffers::uoffset_t start_; + void add_node3DOption(flatbuffers::Offset node3DOption) { + fbb_.AddOffset(Particle3DOptions::VT_NODE3DOPTION, node3DOption); + } + void add_fileData(flatbuffers::Offset fileData) { + fbb_.AddOffset(Particle3DOptions::VT_FILEDATA, fileData); + } + explicit Particle3DOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) + : fbb_(_fbb) { + start_ = fbb_.StartTable(); + } + flatbuffers::Offset Finish() { + const auto end = fbb_.EndTable(start_); + auto o = flatbuffers::Offset(end); + return o; + } }; inline flatbuffers::Offset CreateParticle3DOptions( - flatbuffers::FlatBufferBuilder& _fbb, - flatbuffers::Offset node3DOption = 0, - flatbuffers::Offset fileData = 0) -{ - Particle3DOptionsBuilder builder_(_fbb); - builder_.add_fileData(fileData); - builder_.add_node3DOption(node3DOption); - return builder_.Finish(); + flatbuffers::FlatBufferBuilder &_fbb, + flatbuffers::Offset node3DOption = 0, + flatbuffers::Offset fileData = 0) { + Particle3DOptionsBuilder builder_(_fbb); + builder_.add_fileData(fileData); + builder_.add_node3DOption(node3DOption); + return builder_.Finish(); } -struct UserCameraOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table -{ - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE - { - VT_NODE3DOPTION = 4, - VT_FOV = 6, - VT_NEARCLIP = 8, - VT_FARCLIP = 10, - VT_CAMERAFLAG = 12, - VT_SKYBOXENABLED = 14, - VT_LEFTFILEDATA = 16, - VT_RIGHTFILEDATA = 18, - VT_UPFILEDATA = 20, - VT_DOWNFILEDATA = 22, - VT_FORWARDFILEDATA = 24, - VT_BACKFILEDATA = 26 - }; - const Node3DOption* node3DOption() const { return GetPointer(VT_NODE3DOPTION); } - float fov() const { return GetField(VT_FOV, 60.0f); } - float nearClip() const { return GetField(VT_NEARCLIP, 1.0f); } - float farClip() const { return GetField(VT_FARCLIP, 1000.0f); } - int32_t cameraFlag() const { return GetField(VT_CAMERAFLAG, 0); } - bool skyBoxEnabled() const { return GetField(VT_SKYBOXENABLED, 0) != 0; } - const ResourceData* leftFileData() const { return GetPointer(VT_LEFTFILEDATA); } - const ResourceData* rightFileData() const { return GetPointer(VT_RIGHTFILEDATA); } - const ResourceData* upFileData() const { return GetPointer(VT_UPFILEDATA); } - const ResourceData* downFileData() const { return GetPointer(VT_DOWNFILEDATA); } - const ResourceData* forwardFileData() const { return GetPointer(VT_FORWARDFILEDATA); } - const ResourceData* backFileData() const { return GetPointer(VT_BACKFILEDATA); } - bool Verify(flatbuffers::Verifier& verifier) const - { - return VerifyTableStart(verifier) && VerifyOffset(verifier, VT_NODE3DOPTION) && - verifier.VerifyTable(node3DOption()) && VerifyField(verifier, VT_FOV) && - VerifyField(verifier, VT_NEARCLIP) && VerifyField(verifier, VT_FARCLIP) && - VerifyField(verifier, VT_CAMERAFLAG) && VerifyField(verifier, VT_SKYBOXENABLED) && - VerifyOffset(verifier, VT_LEFTFILEDATA) && verifier.VerifyTable(leftFileData()) && - VerifyOffset(verifier, VT_RIGHTFILEDATA) && verifier.VerifyTable(rightFileData()) && - VerifyOffset(verifier, VT_UPFILEDATA) && verifier.VerifyTable(upFileData()) && - VerifyOffset(verifier, VT_DOWNFILEDATA) && verifier.VerifyTable(downFileData()) && - VerifyOffset(verifier, VT_FORWARDFILEDATA) && verifier.VerifyTable(forwardFileData()) && - VerifyOffset(verifier, VT_BACKFILEDATA) && verifier.VerifyTable(backFileData()) && verifier.EndTable(); - } +struct UserCameraOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { + typedef UserCameraOptionsBuilder Builder; + enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { + VT_NODE3DOPTION = 4, + VT_FOV = 6, + VT_NEARCLIP = 8, + VT_FARCLIP = 10, + VT_CAMERAFLAG = 12, + VT_SKYBOXENABLED = 14, + VT_LEFTFILEDATA = 16, + VT_RIGHTFILEDATA = 18, + VT_UPFILEDATA = 20, + VT_DOWNFILEDATA = 22, + VT_FORWARDFILEDATA = 24, + VT_BACKFILEDATA = 26 + }; + const flatbuffers::Node3DOption *node3DOption() const { + return GetPointer(VT_NODE3DOPTION); + } + float fov() const { + return GetField(VT_FOV, 60.0f); + } + float nearClip() const { + return GetField(VT_NEARCLIP, 1.0f); + } + float farClip() const { + return GetField(VT_FARCLIP, 1000.0f); + } + int32_t cameraFlag() const { + return GetField(VT_CAMERAFLAG, 0); + } + bool skyBoxEnabled() const { + return GetField(VT_SKYBOXENABLED, 0) != 0; + } + const flatbuffers::ResourceData *leftFileData() const { + return GetPointer(VT_LEFTFILEDATA); + } + const flatbuffers::ResourceData *rightFileData() const { + return GetPointer(VT_RIGHTFILEDATA); + } + const flatbuffers::ResourceData *upFileData() const { + return GetPointer(VT_UPFILEDATA); + } + const flatbuffers::ResourceData *downFileData() const { + return GetPointer(VT_DOWNFILEDATA); + } + const flatbuffers::ResourceData *forwardFileData() const { + return GetPointer(VT_FORWARDFILEDATA); + } + const flatbuffers::ResourceData *backFileData() const { + return GetPointer(VT_BACKFILEDATA); + } + bool Verify(flatbuffers::Verifier &verifier) const { + return VerifyTableStart(verifier) && + VerifyOffset(verifier, VT_NODE3DOPTION) && + verifier.VerifyTable(node3DOption()) && + VerifyField(verifier, VT_FOV, 4) && + VerifyField(verifier, VT_NEARCLIP, 4) && + VerifyField(verifier, VT_FARCLIP, 4) && + VerifyField(verifier, VT_CAMERAFLAG, 4) && + VerifyField(verifier, VT_SKYBOXENABLED, 1) && + VerifyOffset(verifier, VT_LEFTFILEDATA) && + verifier.VerifyTable(leftFileData()) && + VerifyOffset(verifier, VT_RIGHTFILEDATA) && + verifier.VerifyTable(rightFileData()) && + VerifyOffset(verifier, VT_UPFILEDATA) && + verifier.VerifyTable(upFileData()) && + VerifyOffset(verifier, VT_DOWNFILEDATA) && + verifier.VerifyTable(downFileData()) && + VerifyOffset(verifier, VT_FORWARDFILEDATA) && + verifier.VerifyTable(forwardFileData()) && + VerifyOffset(verifier, VT_BACKFILEDATA) && + verifier.VerifyTable(backFileData()) && + verifier.EndTable(); + } }; -struct UserCameraOptionsBuilder -{ - flatbuffers::FlatBufferBuilder& fbb_; - flatbuffers::uoffset_t start_; - void add_node3DOption(flatbuffers::Offset node3DOption) - { - fbb_.AddOffset(UserCameraOptions::VT_NODE3DOPTION, node3DOption); - } - void add_fov(float fov) { fbb_.AddElement(UserCameraOptions::VT_FOV, fov, 60.0f); } - void add_nearClip(float nearClip) { fbb_.AddElement(UserCameraOptions::VT_NEARCLIP, nearClip, 1.0f); } - void add_farClip(float farClip) { fbb_.AddElement(UserCameraOptions::VT_FARCLIP, farClip, 1000.0f); } - void add_cameraFlag(int32_t cameraFlag) - { - fbb_.AddElement(UserCameraOptions::VT_CAMERAFLAG, cameraFlag, 0); - } - void add_skyBoxEnabled(bool skyBoxEnabled) - { - fbb_.AddElement(UserCameraOptions::VT_SKYBOXENABLED, static_cast(skyBoxEnabled), 0); - } - void add_leftFileData(flatbuffers::Offset leftFileData) - { - fbb_.AddOffset(UserCameraOptions::VT_LEFTFILEDATA, leftFileData); - } - void add_rightFileData(flatbuffers::Offset rightFileData) - { - fbb_.AddOffset(UserCameraOptions::VT_RIGHTFILEDATA, rightFileData); - } - void add_upFileData(flatbuffers::Offset upFileData) - { - fbb_.AddOffset(UserCameraOptions::VT_UPFILEDATA, upFileData); - } - void add_downFileData(flatbuffers::Offset downFileData) - { - fbb_.AddOffset(UserCameraOptions::VT_DOWNFILEDATA, downFileData); - } - void add_forwardFileData(flatbuffers::Offset forwardFileData) - { - fbb_.AddOffset(UserCameraOptions::VT_FORWARDFILEDATA, forwardFileData); - } - void add_backFileData(flatbuffers::Offset backFileData) - { - fbb_.AddOffset(UserCameraOptions::VT_BACKFILEDATA, backFileData); - } - explicit UserCameraOptionsBuilder(flatbuffers::FlatBufferBuilder& _fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } - UserCameraOptionsBuilder& operator=(const UserCameraOptionsBuilder&); - flatbuffers::Offset Finish() - { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset(end); - return o; - } +struct UserCameraOptionsBuilder { + typedef UserCameraOptions Table; + flatbuffers::FlatBufferBuilder &fbb_; + flatbuffers::uoffset_t start_; + void add_node3DOption(flatbuffers::Offset node3DOption) { + fbb_.AddOffset(UserCameraOptions::VT_NODE3DOPTION, node3DOption); + } + void add_fov(float fov) { + fbb_.AddElement(UserCameraOptions::VT_FOV, fov, 60.0f); + } + void add_nearClip(float nearClip) { + fbb_.AddElement(UserCameraOptions::VT_NEARCLIP, nearClip, 1.0f); + } + void add_farClip(float farClip) { + fbb_.AddElement(UserCameraOptions::VT_FARCLIP, farClip, 1000.0f); + } + void add_cameraFlag(int32_t cameraFlag) { + fbb_.AddElement(UserCameraOptions::VT_CAMERAFLAG, cameraFlag, 0); + } + void add_skyBoxEnabled(bool skyBoxEnabled) { + fbb_.AddElement(UserCameraOptions::VT_SKYBOXENABLED, static_cast(skyBoxEnabled), 0); + } + void add_leftFileData(flatbuffers::Offset leftFileData) { + fbb_.AddOffset(UserCameraOptions::VT_LEFTFILEDATA, leftFileData); + } + void add_rightFileData(flatbuffers::Offset rightFileData) { + fbb_.AddOffset(UserCameraOptions::VT_RIGHTFILEDATA, rightFileData); + } + void add_upFileData(flatbuffers::Offset upFileData) { + fbb_.AddOffset(UserCameraOptions::VT_UPFILEDATA, upFileData); + } + void add_downFileData(flatbuffers::Offset downFileData) { + fbb_.AddOffset(UserCameraOptions::VT_DOWNFILEDATA, downFileData); + } + void add_forwardFileData(flatbuffers::Offset forwardFileData) { + fbb_.AddOffset(UserCameraOptions::VT_FORWARDFILEDATA, forwardFileData); + } + void add_backFileData(flatbuffers::Offset backFileData) { + fbb_.AddOffset(UserCameraOptions::VT_BACKFILEDATA, backFileData); + } + explicit UserCameraOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) + : fbb_(_fbb) { + start_ = fbb_.StartTable(); + } + flatbuffers::Offset Finish() { + const auto end = fbb_.EndTable(start_); + auto o = flatbuffers::Offset(end); + return o; + } }; inline flatbuffers::Offset CreateUserCameraOptions( - flatbuffers::FlatBufferBuilder& _fbb, - flatbuffers::Offset node3DOption = 0, - float fov = 60.0f, - float nearClip = 1.0f, - float farClip = 1000.0f, - int32_t cameraFlag = 0, - bool skyBoxEnabled = false, - flatbuffers::Offset leftFileData = 0, - flatbuffers::Offset rightFileData = 0, - flatbuffers::Offset upFileData = 0, - flatbuffers::Offset downFileData = 0, - flatbuffers::Offset forwardFileData = 0, - flatbuffers::Offset backFileData = 0) -{ - UserCameraOptionsBuilder builder_(_fbb); - builder_.add_backFileData(backFileData); - builder_.add_forwardFileData(forwardFileData); - builder_.add_downFileData(downFileData); - builder_.add_upFileData(upFileData); - builder_.add_rightFileData(rightFileData); - builder_.add_leftFileData(leftFileData); - builder_.add_cameraFlag(cameraFlag); - builder_.add_farClip(farClip); - builder_.add_nearClip(nearClip); - builder_.add_fov(fov); - builder_.add_node3DOption(node3DOption); - builder_.add_skyBoxEnabled(skyBoxEnabled); - return builder_.Finish(); + flatbuffers::FlatBufferBuilder &_fbb, + flatbuffers::Offset node3DOption = 0, + float fov = 60.0f, + float nearClip = 1.0f, + float farClip = 1000.0f, + int32_t cameraFlag = 0, + bool skyBoxEnabled = false, + flatbuffers::Offset leftFileData = 0, + flatbuffers::Offset rightFileData = 0, + flatbuffers::Offset upFileData = 0, + flatbuffers::Offset downFileData = 0, + flatbuffers::Offset forwardFileData = 0, + flatbuffers::Offset backFileData = 0) { + UserCameraOptionsBuilder builder_(_fbb); + builder_.add_backFileData(backFileData); + builder_.add_forwardFileData(forwardFileData); + builder_.add_downFileData(downFileData); + builder_.add_upFileData(upFileData); + builder_.add_rightFileData(rightFileData); + builder_.add_leftFileData(leftFileData); + builder_.add_cameraFlag(cameraFlag); + builder_.add_farClip(farClip); + builder_.add_nearClip(nearClip); + builder_.add_fov(fov); + builder_.add_node3DOption(node3DOption); + builder_.add_skyBoxEnabled(skyBoxEnabled); + return builder_.Finish(); } -struct GameNode3DOption FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table -{ - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE - { - VT_NAME = 4, - VT_SKYBOXMASK = 6, - VT_SKYBOXENABLED = 8, - VT_LEFTFILEDATA = 10, - VT_RIGHTFILEDATA = 12, - VT_UPFILEDATA = 14, - VT_DOWNFILEDATA = 16, - VT_FORWARDFILEDATA = 18, - VT_BACKFILEDATA = 20, - VT_FRAMEEVENT = 22, - VT_CUSTOMPROPERTY = 24, - VT_USEDEFAULTLIGHT = 26 - }; - const flatbuffers::String* name() const { return GetPointer(VT_NAME); } - int32_t skyBoxMask() const { return GetField(VT_SKYBOXMASK, 0); } - bool skyBoxEnabled() const { return GetField(VT_SKYBOXENABLED, 0) != 0; } - const ResourceData* leftFileData() const { return GetPointer(VT_LEFTFILEDATA); } - const ResourceData* rightFileData() const { return GetPointer(VT_RIGHTFILEDATA); } - const ResourceData* upFileData() const { return GetPointer(VT_UPFILEDATA); } - const ResourceData* downFileData() const { return GetPointer(VT_DOWNFILEDATA); } - const ResourceData* forwardFileData() const { return GetPointer(VT_FORWARDFILEDATA); } - const ResourceData* backFileData() const { return GetPointer(VT_BACKFILEDATA); } - const flatbuffers::String* frameEvent() const { return GetPointer(VT_FRAMEEVENT); } - const flatbuffers::String* customProperty() const - { - return GetPointer(VT_CUSTOMPROPERTY); - } - bool useDefaultLight() const { return GetField(VT_USEDEFAULTLIGHT, 0) != 0; } - bool Verify(flatbuffers::Verifier& verifier) const - { - return VerifyTableStart(verifier) && VerifyOffset(verifier, VT_NAME) && verifier.VerifyString(name()) && - VerifyField(verifier, VT_SKYBOXMASK) && VerifyField(verifier, VT_SKYBOXENABLED) && - VerifyOffset(verifier, VT_LEFTFILEDATA) && verifier.VerifyTable(leftFileData()) && - VerifyOffset(verifier, VT_RIGHTFILEDATA) && verifier.VerifyTable(rightFileData()) && - VerifyOffset(verifier, VT_UPFILEDATA) && verifier.VerifyTable(upFileData()) && - VerifyOffset(verifier, VT_DOWNFILEDATA) && verifier.VerifyTable(downFileData()) && - VerifyOffset(verifier, VT_FORWARDFILEDATA) && verifier.VerifyTable(forwardFileData()) && - VerifyOffset(verifier, VT_BACKFILEDATA) && verifier.VerifyTable(backFileData()) && - VerifyOffset(verifier, VT_FRAMEEVENT) && verifier.VerifyString(frameEvent()) && - VerifyOffset(verifier, VT_CUSTOMPROPERTY) && verifier.VerifyString(customProperty()) && - VerifyField(verifier, VT_USEDEFAULTLIGHT) && verifier.EndTable(); - } +struct GameNode3DOption FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { + typedef GameNode3DOptionBuilder Builder; + enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { + VT_NAME = 4, + VT_SKYBOXMASK = 6, + VT_SKYBOXENABLED = 8, + VT_LEFTFILEDATA = 10, + VT_RIGHTFILEDATA = 12, + VT_UPFILEDATA = 14, + VT_DOWNFILEDATA = 16, + VT_FORWARDFILEDATA = 18, + VT_BACKFILEDATA = 20, + VT_FRAMEEVENT = 22, + VT_CUSTOMPROPERTY = 24, + VT_USEDEFAULTLIGHT = 26 + }; + const flatbuffers::String *name() const { + return GetPointer(VT_NAME); + } + int32_t skyBoxMask() const { + return GetField(VT_SKYBOXMASK, 0); + } + bool skyBoxEnabled() const { + return GetField(VT_SKYBOXENABLED, 0) != 0; + } + const flatbuffers::ResourceData *leftFileData() const { + return GetPointer(VT_LEFTFILEDATA); + } + const flatbuffers::ResourceData *rightFileData() const { + return GetPointer(VT_RIGHTFILEDATA); + } + const flatbuffers::ResourceData *upFileData() const { + return GetPointer(VT_UPFILEDATA); + } + const flatbuffers::ResourceData *downFileData() const { + return GetPointer(VT_DOWNFILEDATA); + } + const flatbuffers::ResourceData *forwardFileData() const { + return GetPointer(VT_FORWARDFILEDATA); + } + const flatbuffers::ResourceData *backFileData() const { + return GetPointer(VT_BACKFILEDATA); + } + const flatbuffers::String *frameEvent() const { + return GetPointer(VT_FRAMEEVENT); + } + const flatbuffers::String *customProperty() const { + return GetPointer(VT_CUSTOMPROPERTY); + } + bool useDefaultLight() const { + return GetField(VT_USEDEFAULTLIGHT, 0) != 0; + } + bool Verify(flatbuffers::Verifier &verifier) const { + return VerifyTableStart(verifier) && + VerifyOffset(verifier, VT_NAME) && + verifier.VerifyString(name()) && + VerifyField(verifier, VT_SKYBOXMASK, 4) && + VerifyField(verifier, VT_SKYBOXENABLED, 1) && + VerifyOffset(verifier, VT_LEFTFILEDATA) && + verifier.VerifyTable(leftFileData()) && + VerifyOffset(verifier, VT_RIGHTFILEDATA) && + verifier.VerifyTable(rightFileData()) && + VerifyOffset(verifier, VT_UPFILEDATA) && + verifier.VerifyTable(upFileData()) && + VerifyOffset(verifier, VT_DOWNFILEDATA) && + verifier.VerifyTable(downFileData()) && + VerifyOffset(verifier, VT_FORWARDFILEDATA) && + verifier.VerifyTable(forwardFileData()) && + VerifyOffset(verifier, VT_BACKFILEDATA) && + verifier.VerifyTable(backFileData()) && + VerifyOffset(verifier, VT_FRAMEEVENT) && + verifier.VerifyString(frameEvent()) && + VerifyOffset(verifier, VT_CUSTOMPROPERTY) && + verifier.VerifyString(customProperty()) && + VerifyField(verifier, VT_USEDEFAULTLIGHT, 1) && + verifier.EndTable(); + } }; -struct GameNode3DOptionBuilder -{ - flatbuffers::FlatBufferBuilder& fbb_; - flatbuffers::uoffset_t start_; - void add_name(flatbuffers::Offset name) { fbb_.AddOffset(GameNode3DOption::VT_NAME, name); } - void add_skyBoxMask(int32_t skyBoxMask) - { - fbb_.AddElement(GameNode3DOption::VT_SKYBOXMASK, skyBoxMask, 0); - } - void add_skyBoxEnabled(bool skyBoxEnabled) - { - fbb_.AddElement(GameNode3DOption::VT_SKYBOXENABLED, static_cast(skyBoxEnabled), 0); - } - void add_leftFileData(flatbuffers::Offset leftFileData) - { - fbb_.AddOffset(GameNode3DOption::VT_LEFTFILEDATA, leftFileData); - } - void add_rightFileData(flatbuffers::Offset rightFileData) - { - fbb_.AddOffset(GameNode3DOption::VT_RIGHTFILEDATA, rightFileData); - } - void add_upFileData(flatbuffers::Offset upFileData) - { - fbb_.AddOffset(GameNode3DOption::VT_UPFILEDATA, upFileData); - } - void add_downFileData(flatbuffers::Offset downFileData) - { - fbb_.AddOffset(GameNode3DOption::VT_DOWNFILEDATA, downFileData); - } - void add_forwardFileData(flatbuffers::Offset forwardFileData) - { - fbb_.AddOffset(GameNode3DOption::VT_FORWARDFILEDATA, forwardFileData); - } - void add_backFileData(flatbuffers::Offset backFileData) - { - fbb_.AddOffset(GameNode3DOption::VT_BACKFILEDATA, backFileData); - } - void add_frameEvent(flatbuffers::Offset frameEvent) - { - fbb_.AddOffset(GameNode3DOption::VT_FRAMEEVENT, frameEvent); - } - void add_customProperty(flatbuffers::Offset customProperty) - { - fbb_.AddOffset(GameNode3DOption::VT_CUSTOMPROPERTY, customProperty); - } - void add_useDefaultLight(bool useDefaultLight) - { - fbb_.AddElement(GameNode3DOption::VT_USEDEFAULTLIGHT, static_cast(useDefaultLight), 0); - } - explicit GameNode3DOptionBuilder(flatbuffers::FlatBufferBuilder& _fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } - GameNode3DOptionBuilder& operator=(const GameNode3DOptionBuilder&); - flatbuffers::Offset Finish() - { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset(end); - return o; - } +struct GameNode3DOptionBuilder { + typedef GameNode3DOption Table; + flatbuffers::FlatBufferBuilder &fbb_; + flatbuffers::uoffset_t start_; + void add_name(flatbuffers::Offset name) { + fbb_.AddOffset(GameNode3DOption::VT_NAME, name); + } + void add_skyBoxMask(int32_t skyBoxMask) { + fbb_.AddElement(GameNode3DOption::VT_SKYBOXMASK, skyBoxMask, 0); + } + void add_skyBoxEnabled(bool skyBoxEnabled) { + fbb_.AddElement(GameNode3DOption::VT_SKYBOXENABLED, static_cast(skyBoxEnabled), 0); + } + void add_leftFileData(flatbuffers::Offset leftFileData) { + fbb_.AddOffset(GameNode3DOption::VT_LEFTFILEDATA, leftFileData); + } + void add_rightFileData(flatbuffers::Offset rightFileData) { + fbb_.AddOffset(GameNode3DOption::VT_RIGHTFILEDATA, rightFileData); + } + void add_upFileData(flatbuffers::Offset upFileData) { + fbb_.AddOffset(GameNode3DOption::VT_UPFILEDATA, upFileData); + } + void add_downFileData(flatbuffers::Offset downFileData) { + fbb_.AddOffset(GameNode3DOption::VT_DOWNFILEDATA, downFileData); + } + void add_forwardFileData(flatbuffers::Offset forwardFileData) { + fbb_.AddOffset(GameNode3DOption::VT_FORWARDFILEDATA, forwardFileData); + } + void add_backFileData(flatbuffers::Offset backFileData) { + fbb_.AddOffset(GameNode3DOption::VT_BACKFILEDATA, backFileData); + } + void add_frameEvent(flatbuffers::Offset frameEvent) { + fbb_.AddOffset(GameNode3DOption::VT_FRAMEEVENT, frameEvent); + } + void add_customProperty(flatbuffers::Offset customProperty) { + fbb_.AddOffset(GameNode3DOption::VT_CUSTOMPROPERTY, customProperty); + } + void add_useDefaultLight(bool useDefaultLight) { + fbb_.AddElement(GameNode3DOption::VT_USEDEFAULTLIGHT, static_cast(useDefaultLight), 0); + } + explicit GameNode3DOptionBuilder(flatbuffers::FlatBufferBuilder &_fbb) + : fbb_(_fbb) { + start_ = fbb_.StartTable(); + } + flatbuffers::Offset Finish() { + const auto end = fbb_.EndTable(start_); + auto o = flatbuffers::Offset(end); + return o; + } }; inline flatbuffers::Offset CreateGameNode3DOption( - flatbuffers::FlatBufferBuilder& _fbb, - flatbuffers::Offset name = 0, - int32_t skyBoxMask = 0, - bool skyBoxEnabled = false, - flatbuffers::Offset leftFileData = 0, - flatbuffers::Offset rightFileData = 0, - flatbuffers::Offset upFileData = 0, - flatbuffers::Offset downFileData = 0, - flatbuffers::Offset forwardFileData = 0, - flatbuffers::Offset backFileData = 0, - flatbuffers::Offset frameEvent = 0, + flatbuffers::FlatBufferBuilder &_fbb, + flatbuffers::Offset name = 0, + int32_t skyBoxMask = 0, + bool skyBoxEnabled = false, + flatbuffers::Offset leftFileData = 0, + flatbuffers::Offset rightFileData = 0, + flatbuffers::Offset upFileData = 0, + flatbuffers::Offset downFileData = 0, + flatbuffers::Offset forwardFileData = 0, + flatbuffers::Offset backFileData = 0, + flatbuffers::Offset frameEvent = 0, flatbuffers::Offset customProperty = 0, - bool useDefaultLight = false) -{ - GameNode3DOptionBuilder builder_(_fbb); - builder_.add_customProperty(customProperty); - builder_.add_frameEvent(frameEvent); - builder_.add_backFileData(backFileData); - builder_.add_forwardFileData(forwardFileData); - builder_.add_downFileData(downFileData); - builder_.add_upFileData(upFileData); - builder_.add_rightFileData(rightFileData); - builder_.add_leftFileData(leftFileData); - builder_.add_skyBoxMask(skyBoxMask); - builder_.add_name(name); - builder_.add_useDefaultLight(useDefaultLight); - builder_.add_skyBoxEnabled(skyBoxEnabled); - return builder_.Finish(); + bool useDefaultLight = false) { + GameNode3DOptionBuilder builder_(_fbb); + builder_.add_customProperty(customProperty); + builder_.add_frameEvent(frameEvent); + builder_.add_backFileData(backFileData); + builder_.add_forwardFileData(forwardFileData); + builder_.add_downFileData(downFileData); + builder_.add_upFileData(upFileData); + builder_.add_rightFileData(rightFileData); + builder_.add_leftFileData(leftFileData); + builder_.add_skyBoxMask(skyBoxMask); + builder_.add_name(name); + builder_.add_useDefaultLight(useDefaultLight); + builder_.add_skyBoxEnabled(skyBoxEnabled); + return builder_.Finish(); } inline flatbuffers::Offset CreateGameNode3DOptionDirect( - flatbuffers::FlatBufferBuilder& _fbb, - const char* name = nullptr, - int32_t skyBoxMask = 0, - bool skyBoxEnabled = false, - flatbuffers::Offset leftFileData = 0, - flatbuffers::Offset rightFileData = 0, - flatbuffers::Offset upFileData = 0, - flatbuffers::Offset downFileData = 0, - flatbuffers::Offset forwardFileData = 0, - flatbuffers::Offset backFileData = 0, - const char* frameEvent = nullptr, - const char* customProperty = nullptr, - bool useDefaultLight = false) -{ - auto name__ = name ? _fbb.CreateString(name) : 0; - auto frameEvent__ = frameEvent ? _fbb.CreateString(frameEvent) : 0; - auto customProperty__ = customProperty ? _fbb.CreateString(customProperty) : 0; - return flatbuffers::CreateGameNode3DOption(_fbb, name__, skyBoxMask, skyBoxEnabled, leftFileData, rightFileData, - upFileData, downFileData, forwardFileData, backFileData, frameEvent__, - customProperty__, useDefaultLight); + flatbuffers::FlatBufferBuilder &_fbb, + const char *name = nullptr, + int32_t skyBoxMask = 0, + bool skyBoxEnabled = false, + flatbuffers::Offset leftFileData = 0, + flatbuffers::Offset rightFileData = 0, + flatbuffers::Offset upFileData = 0, + flatbuffers::Offset downFileData = 0, + flatbuffers::Offset forwardFileData = 0, + flatbuffers::Offset backFileData = 0, + const char *frameEvent = nullptr, + const char *customProperty = nullptr, + bool useDefaultLight = false) { + auto name__ = name ? _fbb.CreateString(name) : 0; + auto frameEvent__ = frameEvent ? _fbb.CreateString(frameEvent) : 0; + auto customProperty__ = customProperty ? _fbb.CreateString(customProperty) : 0; + return flatbuffers::CreateGameNode3DOption( + _fbb, + name__, + skyBoxMask, + skyBoxEnabled, + leftFileData, + rightFileData, + upFileData, + downFileData, + forwardFileData, + backFileData, + frameEvent__, + customProperty__, + useDefaultLight); } -struct Light3DOption FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table -{ - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE - { - VT_NODE3DOPTION = 4, - VT_ENABLED = 6, - VT_TYPE = 8, - VT_FLAG = 10, - VT_INTENSITY = 12, - VT_RANGE = 14, - VT_OUTERANGLE = 16 - }; - const Node3DOption* node3DOption() const { return GetPointer(VT_NODE3DOPTION); } - bool enabled() const { return GetField(VT_ENABLED, 0) != 0; } - int32_t type() const { return GetField(VT_TYPE, 0); } - int32_t flag() const { return GetField(VT_FLAG, 0); } - float intensity() const { return GetField(VT_INTENSITY, 0.0f); } - float range() const { return GetField(VT_RANGE, 0.0f); } - float outerAngle() const { return GetField(VT_OUTERANGLE, 0.0f); } - bool Verify(flatbuffers::Verifier& verifier) const - { - return VerifyTableStart(verifier) && VerifyOffset(verifier, VT_NODE3DOPTION) && - verifier.VerifyTable(node3DOption()) && VerifyField(verifier, VT_ENABLED) && - VerifyField(verifier, VT_TYPE) && VerifyField(verifier, VT_FLAG) && - VerifyField(verifier, VT_INTENSITY) && VerifyField(verifier, VT_RANGE) && - VerifyField(verifier, VT_OUTERANGLE) && verifier.EndTable(); - } +struct Light3DOption FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { + typedef Light3DOptionBuilder Builder; + enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { + VT_NODE3DOPTION = 4, + VT_ENABLED = 6, + VT_TYPE = 8, + VT_FLAG = 10, + VT_INTENSITY = 12, + VT_RANGE = 14, + VT_OUTERANGLE = 16 + }; + const flatbuffers::Node3DOption *node3DOption() const { + return GetPointer(VT_NODE3DOPTION); + } + bool enabled() const { + return GetField(VT_ENABLED, 0) != 0; + } + int32_t type() const { + return GetField(VT_TYPE, 0); + } + int32_t flag() const { + return GetField(VT_FLAG, 0); + } + float intensity() const { + return GetField(VT_INTENSITY, 0.0f); + } + float range() const { + return GetField(VT_RANGE, 0.0f); + } + float outerAngle() const { + return GetField(VT_OUTERANGLE, 0.0f); + } + bool Verify(flatbuffers::Verifier &verifier) const { + return VerifyTableStart(verifier) && + VerifyOffset(verifier, VT_NODE3DOPTION) && + verifier.VerifyTable(node3DOption()) && + VerifyField(verifier, VT_ENABLED, 1) && + VerifyField(verifier, VT_TYPE, 4) && + VerifyField(verifier, VT_FLAG, 4) && + VerifyField(verifier, VT_INTENSITY, 4) && + VerifyField(verifier, VT_RANGE, 4) && + VerifyField(verifier, VT_OUTERANGLE, 4) && + verifier.EndTable(); + } }; -struct Light3DOptionBuilder -{ - flatbuffers::FlatBufferBuilder& fbb_; - flatbuffers::uoffset_t start_; - void add_node3DOption(flatbuffers::Offset node3DOption) - { - fbb_.AddOffset(Light3DOption::VT_NODE3DOPTION, node3DOption); - } - void add_enabled(bool enabled) - { - fbb_.AddElement(Light3DOption::VT_ENABLED, static_cast(enabled), 0); - } - void add_type(int32_t type) { fbb_.AddElement(Light3DOption::VT_TYPE, type, 0); } - void add_flag(int32_t flag) { fbb_.AddElement(Light3DOption::VT_FLAG, flag, 0); } - void add_intensity(float intensity) { fbb_.AddElement(Light3DOption::VT_INTENSITY, intensity, 0.0f); } - void add_range(float range) { fbb_.AddElement(Light3DOption::VT_RANGE, range, 0.0f); } - void add_outerAngle(float outerAngle) { fbb_.AddElement(Light3DOption::VT_OUTERANGLE, outerAngle, 0.0f); } - explicit Light3DOptionBuilder(flatbuffers::FlatBufferBuilder& _fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } - Light3DOptionBuilder& operator=(const Light3DOptionBuilder&); - flatbuffers::Offset Finish() - { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset(end); - return o; - } +struct Light3DOptionBuilder { + typedef Light3DOption Table; + flatbuffers::FlatBufferBuilder &fbb_; + flatbuffers::uoffset_t start_; + void add_node3DOption(flatbuffers::Offset node3DOption) { + fbb_.AddOffset(Light3DOption::VT_NODE3DOPTION, node3DOption); + } + void add_enabled(bool enabled) { + fbb_.AddElement(Light3DOption::VT_ENABLED, static_cast(enabled), 0); + } + void add_type(int32_t type) { + fbb_.AddElement(Light3DOption::VT_TYPE, type, 0); + } + void add_flag(int32_t flag) { + fbb_.AddElement(Light3DOption::VT_FLAG, flag, 0); + } + void add_intensity(float intensity) { + fbb_.AddElement(Light3DOption::VT_INTENSITY, intensity, 0.0f); + } + void add_range(float range) { + fbb_.AddElement(Light3DOption::VT_RANGE, range, 0.0f); + } + void add_outerAngle(float outerAngle) { + fbb_.AddElement(Light3DOption::VT_OUTERANGLE, outerAngle, 0.0f); + } + explicit Light3DOptionBuilder(flatbuffers::FlatBufferBuilder &_fbb) + : fbb_(_fbb) { + start_ = fbb_.StartTable(); + } + flatbuffers::Offset Finish() { + const auto end = fbb_.EndTable(start_); + auto o = flatbuffers::Offset(end); + return o; + } }; -inline flatbuffers::Offset CreateLight3DOption(flatbuffers::FlatBufferBuilder& _fbb, - flatbuffers::Offset node3DOption = 0, - bool enabled = false, - int32_t type = 0, - int32_t flag = 0, - float intensity = 0.0f, - float range = 0.0f, - float outerAngle = 0.0f) -{ - Light3DOptionBuilder builder_(_fbb); - builder_.add_outerAngle(outerAngle); - builder_.add_range(range); - builder_.add_intensity(intensity); - builder_.add_flag(flag); - builder_.add_type(type); - builder_.add_node3DOption(node3DOption); - builder_.add_enabled(enabled); - return builder_.Finish(); +inline flatbuffers::Offset CreateLight3DOption( + flatbuffers::FlatBufferBuilder &_fbb, + flatbuffers::Offset node3DOption = 0, + bool enabled = false, + int32_t type = 0, + int32_t flag = 0, + float intensity = 0.0f, + float range = 0.0f, + float outerAngle = 0.0f) { + Light3DOptionBuilder builder_(_fbb); + builder_.add_outerAngle(outerAngle); + builder_.add_range(range); + builder_.add_intensity(intensity); + builder_.add_flag(flag); + builder_.add_type(type); + builder_.add_node3DOption(node3DOption); + builder_.add_enabled(enabled); + return builder_.Finish(); } -inline const flatbuffers::Node3DOption* GetNode3DOption(const void* buf) -{ - return flatbuffers::GetRoot(buf); +inline const flatbuffers::Node3DOption *GetNode3DOption(const void *buf) { + return flatbuffers::GetRoot(buf); } -inline const flatbuffers::Node3DOption* GetSizePrefixedNode3DOption(const void* buf) -{ - return flatbuffers::GetSizePrefixedRoot(buf); +inline const flatbuffers::Node3DOption *GetSizePrefixedNode3DOption(const void *buf) { + return flatbuffers::GetSizePrefixedRoot(buf); } -inline bool VerifyNode3DOptionBuffer(flatbuffers::Verifier& verifier) -{ - return verifier.VerifyBuffer(nullptr); +inline bool VerifyNode3DOptionBuffer( + flatbuffers::Verifier &verifier) { + return verifier.VerifyBuffer(nullptr); } -inline bool VerifySizePrefixedNode3DOptionBuffer(flatbuffers::Verifier& verifier) -{ - return verifier.VerifySizePrefixedBuffer(nullptr); +inline bool VerifySizePrefixedNode3DOptionBuffer( + flatbuffers::Verifier &verifier) { + return verifier.VerifySizePrefixedBuffer(nullptr); } -inline void FinishNode3DOptionBuffer(flatbuffers::FlatBufferBuilder& fbb, - flatbuffers::Offset root) -{ - fbb.Finish(root); +inline void FinishNode3DOptionBuffer( + flatbuffers::FlatBufferBuilder &fbb, + flatbuffers::Offset root) { + fbb.Finish(root); } -inline void FinishSizePrefixedNode3DOptionBuffer(flatbuffers::FlatBufferBuilder& fbb, - flatbuffers::Offset root) -{ - fbb.FinishSizePrefixed(root); +inline void FinishSizePrefixedNode3DOptionBuffer( + flatbuffers::FlatBufferBuilder &fbb, + flatbuffers::Offset root) { + fbb.FinishSizePrefixed(root); } } // namespace flatbuffers diff --git a/extensions/cocostudio/CSParseBinary_generated.h b/extensions/cocostudio/CSParseBinary_generated.h index 8ff90654f6..b8adcff6b0 100644 --- a/extensions/cocostudio/CSParseBinary_generated.h +++ b/extensions/cocostudio/CSParseBinary_generated.h @@ -1,102 +1,154 @@ // automatically generated by the FlatBuffers compiler, do not modify + #ifndef FLATBUFFERS_GENERATED_CSPARSEBINARY_FLATBUFFERS_H_ #define FLATBUFFERS_GENERATED_CSPARSEBINARY_FLATBUFFERS_H_ #include "flatbuffers/flatbuffers.h" -namespace flatbuffers -{ +// Ensure the included flatbuffers.h is the same version as when this file was +// generated, otherwise it may not be compatible. +static_assert(FLATBUFFERS_VERSION_MAJOR == 2 && + FLATBUFFERS_VERSION_MINOR == 0 && + FLATBUFFERS_VERSION_REVISION == 8, + "Non-compatible flatbuffers version included"); + +namespace flatbuffers { struct CSParseBinary; +struct CSParseBinaryBuilder; struct NodeTree; +struct NodeTreeBuilder; struct Options; +struct OptionsBuilder; struct WidgetOptions; +struct WidgetOptionsBuilder; struct LayoutComponentTable; +struct LayoutComponentTableBuilder; struct SingleNodeOptions; +struct SingleNodeOptionsBuilder; struct SpriteOptions; +struct SpriteOptionsBuilder; struct ParticleSystemOptions; +struct ParticleSystemOptionsBuilder; struct SpineSkeletonOptions; +struct SpineSkeletonOptionsBuilder; struct ControlSwitchOptions; +struct ControlSwitchOptionsBuilder; struct LayerColorOptions; +struct LayerColorOptionsBuilder; struct GameMapOptions; +struct GameMapOptionsBuilder; struct ButtonOptions; +struct ButtonOptionsBuilder; struct CheckBoxOptions; +struct CheckBoxOptionsBuilder; struct RadioButtonOptions; +struct RadioButtonOptionsBuilder; struct RadioButtonGroupOptions; +struct RadioButtonGroupOptionsBuilder; struct ImageViewOptions; +struct ImageViewOptionsBuilder; struct TextAtlasOptions; +struct TextAtlasOptionsBuilder; struct TextBMFontOptions; +struct TextBMFontOptionsBuilder; struct TextOptions; +struct TextOptionsBuilder; struct RichTextOptions; +struct RichTextOptionsBuilder; struct TextFieldOptions; +struct TextFieldOptionsBuilder; struct LoadingBarOptions; +struct LoadingBarOptionsBuilder; struct SliderOptions; +struct SliderOptionsBuilder; struct PanelOptions; +struct PanelOptionsBuilder; struct ScrollViewOptions; +struct ScrollViewOptionsBuilder; struct PageViewOptions; +struct PageViewOptionsBuilder; struct ListViewOptions; +struct ListViewOptionsBuilder; struct TextFieldExOptions; +struct TextFieldExOptionsBuilder; struct ProjectNodeOptions; +struct ProjectNodeOptionsBuilder; struct ComponentOptions; +struct ComponentOptionsBuilder; struct ComAudioOptions; +struct ComAudioOptionsBuilder; struct AnimationInfo; +struct AnimationInfoBuilder; struct NodeAction; +struct NodeActionBuilder; struct TimeLine; +struct TimeLineBuilder; struct Frame; +struct FrameBuilder; struct PointFrame; +struct PointFrameBuilder; struct ScaleFrame; +struct ScaleFrameBuilder; struct ColorFrame; +struct ColorFrameBuilder; struct TextureFrame; +struct TextureFrameBuilder; struct EventFrame; +struct EventFrameBuilder; struct IntFrame; +struct IntFrameBuilder; struct BoolFrame; +struct BoolFrameBuilder; struct InnerActionFrame; +struct InnerActionFrameBuilder; struct EasingData; +struct EasingDataBuilder; struct RotationSkew; @@ -119,4838 +171,5924 @@ struct CapInsets; struct BlendFunc; struct ResourceData; +struct ResourceDataBuilder; struct BlendFrame; +struct BlendFrameBuilder; -FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(4) RotationSkew FLATBUFFERS_FINAL_CLASS -{ -private: - float rotationSkewX_; - float rotationSkewY_; +FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(4) RotationSkew FLATBUFFERS_FINAL_CLASS { + private: + float rotationSkewX_; + float rotationSkewY_; -public: - RotationSkew() { memset(static_cast(this), 0, sizeof(RotationSkew)); } - RotationSkew(float _rotationSkewX, float _rotationSkewY) - : rotationSkewX_(flatbuffers::EndianScalar(_rotationSkewX)) - , rotationSkewY_(flatbuffers::EndianScalar(_rotationSkewY)) - {} - float rotationSkewX() const { return flatbuffers::EndianScalar(rotationSkewX_); } - float rotationSkewY() const { return flatbuffers::EndianScalar(rotationSkewY_); } + public: + RotationSkew() + : rotationSkewX_(0), + rotationSkewY_(0) { + } + RotationSkew(float _rotationSkewX, float _rotationSkewY) + : rotationSkewX_(flatbuffers::EndianScalar(_rotationSkewX)), + rotationSkewY_(flatbuffers::EndianScalar(_rotationSkewY)) { + } + float rotationSkewX() const { + return flatbuffers::EndianScalar(rotationSkewX_); + } + float rotationSkewY() const { + return flatbuffers::EndianScalar(rotationSkewY_); + } }; FLATBUFFERS_STRUCT_END(RotationSkew, 8); -FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(4) FVec2 FLATBUFFERS_FINAL_CLASS -{ -private: - float x_; - float y_; +FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(4) FVec2 FLATBUFFERS_FINAL_CLASS { + private: + float x_; + float y_; -public: - FVec2() { memset(static_cast(this), 0, sizeof(FVec2)); } - FVec2(float _x, float _y) : x_(flatbuffers::EndianScalar(_x)), y_(flatbuffers::EndianScalar(_y)) {} - float x() const { return flatbuffers::EndianScalar(x_); } - float y() const { return flatbuffers::EndianScalar(y_); } + public: + FVec2() + : x_(0), + y_(0) { + } + FVec2(float _x, float _y) + : x_(flatbuffers::EndianScalar(_x)), + y_(flatbuffers::EndianScalar(_y)) { + } + float x() const { + return flatbuffers::EndianScalar(x_); + } + float y() const { + return flatbuffers::EndianScalar(y_); + } }; FLATBUFFERS_STRUCT_END(FVec2, 8); -FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(4) FVec3 FLATBUFFERS_FINAL_CLASS -{ -private: - float x_; - float y_; - float z_; +FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(4) FVec3 FLATBUFFERS_FINAL_CLASS { + private: + float x_; + float y_; + float z_; -public: - FVec3() { memset(static_cast(this), 0, sizeof(FVec3)); } - FVec3(float _x, float _y, float _z) - : x_(flatbuffers::EndianScalar(_x)), y_(flatbuffers::EndianScalar(_y)), z_(flatbuffers::EndianScalar(_z)) - {} - float x() const { return flatbuffers::EndianScalar(x_); } - float y() const { return flatbuffers::EndianScalar(y_); } - float z() const { return flatbuffers::EndianScalar(z_); } + public: + FVec3() + : x_(0), + y_(0), + z_(0) { + } + FVec3(float _x, float _y, float _z) + : x_(flatbuffers::EndianScalar(_x)), + y_(flatbuffers::EndianScalar(_y)), + z_(flatbuffers::EndianScalar(_z)) { + } + float x() const { + return flatbuffers::EndianScalar(x_); + } + float y() const { + return flatbuffers::EndianScalar(y_); + } + float z() const { + return flatbuffers::EndianScalar(z_); + } }; FLATBUFFERS_STRUCT_END(FVec3, 12); -FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(4) Scale FLATBUFFERS_FINAL_CLASS -{ -private: - float scaleX_; - float scaleY_; +FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(4) Scale FLATBUFFERS_FINAL_CLASS { + private: + float scaleX_; + float scaleY_; -public: - Scale() { memset(static_cast(this), 0, sizeof(Scale)); } - Scale(float _scaleX, float _scaleY) - : scaleX_(flatbuffers::EndianScalar(_scaleX)), scaleY_(flatbuffers::EndianScalar(_scaleY)) - {} - float scaleX() const { return flatbuffers::EndianScalar(scaleX_); } - float scaleY() const { return flatbuffers::EndianScalar(scaleY_); } + public: + Scale() + : scaleX_(0), + scaleY_(0) { + } + Scale(float _scaleX, float _scaleY) + : scaleX_(flatbuffers::EndianScalar(_scaleX)), + scaleY_(flatbuffers::EndianScalar(_scaleY)) { + } + float scaleX() const { + return flatbuffers::EndianScalar(scaleX_); + } + float scaleY() const { + return flatbuffers::EndianScalar(scaleY_); + } }; FLATBUFFERS_STRUCT_END(Scale, 8); -FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(4) AnchorPoint FLATBUFFERS_FINAL_CLASS -{ -private: - float scaleX_; - float scaleY_; +FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(4) AnchorPoint FLATBUFFERS_FINAL_CLASS { + private: + float scaleX_; + float scaleY_; -public: - AnchorPoint() { memset(static_cast(this), 0, sizeof(AnchorPoint)); } - AnchorPoint(float _scaleX, float _scaleY) - : scaleX_(flatbuffers::EndianScalar(_scaleX)), scaleY_(flatbuffers::EndianScalar(_scaleY)) - {} - float scaleX() const { return flatbuffers::EndianScalar(scaleX_); } - float scaleY() const { return flatbuffers::EndianScalar(scaleY_); } + public: + AnchorPoint() + : scaleX_(0), + scaleY_(0) { + } + AnchorPoint(float _scaleX, float _scaleY) + : scaleX_(flatbuffers::EndianScalar(_scaleX)), + scaleY_(flatbuffers::EndianScalar(_scaleY)) { + } + float scaleX() const { + return flatbuffers::EndianScalar(scaleX_); + } + float scaleY() const { + return flatbuffers::EndianScalar(scaleY_); + } }; FLATBUFFERS_STRUCT_END(AnchorPoint, 8); -FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(1) Color FLATBUFFERS_FINAL_CLASS -{ -private: - uint8_t a_; - uint8_t r_; - uint8_t g_; - uint8_t b_; +FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(1) Color FLATBUFFERS_FINAL_CLASS { + private: + uint8_t a_; + uint8_t r_; + uint8_t g_; + uint8_t b_; -public: - Color() { memset(static_cast(this), 0, sizeof(Color)); } - Color(uint8_t _a, uint8_t _r, uint8_t _g, uint8_t _b) - : a_(flatbuffers::EndianScalar(_a)) - , r_(flatbuffers::EndianScalar(_r)) - , g_(flatbuffers::EndianScalar(_g)) - , b_(flatbuffers::EndianScalar(_b)) - {} - uint8_t a() const { return flatbuffers::EndianScalar(a_); } - uint8_t r() const { return flatbuffers::EndianScalar(r_); } - uint8_t g() const { return flatbuffers::EndianScalar(g_); } - uint8_t b() const { return flatbuffers::EndianScalar(b_); } + public: + Color() + : a_(0), + r_(0), + g_(0), + b_(0) { + } + Color(uint8_t _a, uint8_t _r, uint8_t _g, uint8_t _b) + : a_(flatbuffers::EndianScalar(_a)), + r_(flatbuffers::EndianScalar(_r)), + g_(flatbuffers::EndianScalar(_g)), + b_(flatbuffers::EndianScalar(_b)) { + } + uint8_t a() const { + return flatbuffers::EndianScalar(a_); + } + uint8_t r() const { + return flatbuffers::EndianScalar(r_); + } + uint8_t g() const { + return flatbuffers::EndianScalar(g_); + } + uint8_t b() const { + return flatbuffers::EndianScalar(b_); + } }; FLATBUFFERS_STRUCT_END(Color, 4); -FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(4) ColorVector FLATBUFFERS_FINAL_CLASS -{ -private: - float vectorX_; - float vectorY_; +FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(4) ColorVector FLATBUFFERS_FINAL_CLASS { + private: + float vectorX_; + float vectorY_; -public: - ColorVector() { memset(static_cast(this), 0, sizeof(ColorVector)); } - ColorVector(float _vectorX, float _vectorY) - : vectorX_(flatbuffers::EndianScalar(_vectorX)), vectorY_(flatbuffers::EndianScalar(_vectorY)) - {} - float vectorX() const { return flatbuffers::EndianScalar(vectorX_); } - float vectorY() const { return flatbuffers::EndianScalar(vectorY_); } + public: + ColorVector() + : vectorX_(0), + vectorY_(0) { + } + ColorVector(float _vectorX, float _vectorY) + : vectorX_(flatbuffers::EndianScalar(_vectorX)), + vectorY_(flatbuffers::EndianScalar(_vectorY)) { + } + float vectorX() const { + return flatbuffers::EndianScalar(vectorX_); + } + float vectorY() const { + return flatbuffers::EndianScalar(vectorY_); + } }; FLATBUFFERS_STRUCT_END(ColorVector, 8); -FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(4) FlatSize FLATBUFFERS_FINAL_CLASS -{ -private: - float width_; - float height_; +FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(4) FlatSize FLATBUFFERS_FINAL_CLASS { + private: + float width_; + float height_; -public: - FlatSize() { memset(static_cast(this), 0, sizeof(FlatSize)); } - FlatSize(float _width, float _height) - : width_(flatbuffers::EndianScalar(_width)), height_(flatbuffers::EndianScalar(_height)) - {} - float width() const { return flatbuffers::EndianScalar(width_); } - float height() const { return flatbuffers::EndianScalar(height_); } + public: + FlatSize() + : width_(0), + height_(0) { + } + FlatSize(float _width, float _height) + : width_(flatbuffers::EndianScalar(_width)), + height_(flatbuffers::EndianScalar(_height)) { + } + float width() const { + return flatbuffers::EndianScalar(width_); + } + float height() const { + return flatbuffers::EndianScalar(height_); + } }; FLATBUFFERS_STRUCT_END(FlatSize, 8); -FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(4) CapInsets FLATBUFFERS_FINAL_CLASS -{ -private: - float x_; - float y_; - float width_; - float height_; +FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(4) CapInsets FLATBUFFERS_FINAL_CLASS { + private: + float x_; + float y_; + float width_; + float height_; -public: - CapInsets() { memset(static_cast(this), 0, sizeof(CapInsets)); } - CapInsets(float _x, float _y, float _width, float _height) - : x_(flatbuffers::EndianScalar(_x)) - , y_(flatbuffers::EndianScalar(_y)) - , width_(flatbuffers::EndianScalar(_width)) - , height_(flatbuffers::EndianScalar(_height)) - {} - float x() const { return flatbuffers::EndianScalar(x_); } - float y() const { return flatbuffers::EndianScalar(y_); } - float width() const { return flatbuffers::EndianScalar(width_); } - float height() const { return flatbuffers::EndianScalar(height_); } + public: + CapInsets() + : x_(0), + y_(0), + width_(0), + height_(0) { + } + CapInsets(float _x, float _y, float _width, float _height) + : x_(flatbuffers::EndianScalar(_x)), + y_(flatbuffers::EndianScalar(_y)), + width_(flatbuffers::EndianScalar(_width)), + height_(flatbuffers::EndianScalar(_height)) { + } + float x() const { + return flatbuffers::EndianScalar(x_); + } + float y() const { + return flatbuffers::EndianScalar(y_); + } + float width() const { + return flatbuffers::EndianScalar(width_); + } + float height() const { + return flatbuffers::EndianScalar(height_); + } }; FLATBUFFERS_STRUCT_END(CapInsets, 16); -FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(4) BlendFunc FLATBUFFERS_FINAL_CLASS -{ -private: - int32_t src_; - int32_t dst_; +FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(4) BlendFunc FLATBUFFERS_FINAL_CLASS { + private: + int32_t src_; + int32_t dst_; -public: - BlendFunc() { memset(static_cast(this), 0, sizeof(BlendFunc)); } - BlendFunc(int32_t _src, int32_t _dst) : src_(flatbuffers::EndianScalar(_src)), dst_(flatbuffers::EndianScalar(_dst)) - {} - int32_t src() const { return flatbuffers::EndianScalar(src_); } - int32_t dst() const { return flatbuffers::EndianScalar(dst_); } + public: + BlendFunc() + : src_(0), + dst_(0) { + } + BlendFunc(int32_t _src, int32_t _dst) + : src_(flatbuffers::EndianScalar(_src)), + dst_(flatbuffers::EndianScalar(_dst)) { + } + int32_t src() const { + return flatbuffers::EndianScalar(src_); + } + int32_t dst() const { + return flatbuffers::EndianScalar(dst_); + } }; FLATBUFFERS_STRUCT_END(BlendFunc, 8); -struct CSParseBinary FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table -{ - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE - { - VT_VERSION = 4, - VT_TEXTURES = 6, - VT_TEXTUREPNGS = 8, - VT_NODETREE = 10, - VT_ACTION = 12, - VT_ANIMATIONLIST = 14 - }; - const flatbuffers::String* version() const { return GetPointer(VT_VERSION); } - const flatbuffers::Vector>* textures() const - { - return GetPointer>*>(VT_TEXTURES); - } - const flatbuffers::Vector>* texturePngs() const - { - return GetPointer>*>(VT_TEXTUREPNGS); - } - const NodeTree* nodeTree() const { return GetPointer(VT_NODETREE); } - const NodeAction* action() const { return GetPointer(VT_ACTION); } - const flatbuffers::Vector>* animationList() const - { - return GetPointer>*>(VT_ANIMATIONLIST); - } - bool Verify(flatbuffers::Verifier& verifier) const - { - return VerifyTableStart(verifier) && VerifyOffset(verifier, VT_VERSION) && verifier.VerifyString(version()) && - VerifyOffset(verifier, VT_TEXTURES) && verifier.VerifyVector(textures()) && - verifier.VerifyVectorOfStrings(textures()) && VerifyOffset(verifier, VT_TEXTUREPNGS) && - verifier.VerifyVector(texturePngs()) && verifier.VerifyVectorOfStrings(texturePngs()) && - VerifyOffset(verifier, VT_NODETREE) && verifier.VerifyTable(nodeTree()) && - VerifyOffset(verifier, VT_ACTION) && verifier.VerifyTable(action()) && - VerifyOffset(verifier, VT_ANIMATIONLIST) && verifier.VerifyVector(animationList()) && - verifier.VerifyVectorOfTables(animationList()) && verifier.EndTable(); - } +struct CSParseBinary FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { + typedef CSParseBinaryBuilder Builder; + enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { + VT_VERSION = 4, + VT_TEXTURES = 6, + VT_TEXTUREPNGS = 8, + VT_NODETREE = 10, + VT_ACTION = 12, + VT_ANIMATIONLIST = 14 + }; + const flatbuffers::String *version() const { + return GetPointer(VT_VERSION); + } + const flatbuffers::Vector> *textures() const { + return GetPointer> *>(VT_TEXTURES); + } + const flatbuffers::Vector> *texturePngs() const { + return GetPointer> *>(VT_TEXTUREPNGS); + } + const flatbuffers::NodeTree *nodeTree() const { + return GetPointer(VT_NODETREE); + } + const flatbuffers::NodeAction *action() const { + return GetPointer(VT_ACTION); + } + const flatbuffers::Vector> *animationList() const { + return GetPointer> *>(VT_ANIMATIONLIST); + } + bool Verify(flatbuffers::Verifier &verifier) const { + return VerifyTableStart(verifier) && + VerifyOffset(verifier, VT_VERSION) && + verifier.VerifyString(version()) && + VerifyOffset(verifier, VT_TEXTURES) && + verifier.VerifyVector(textures()) && + verifier.VerifyVectorOfStrings(textures()) && + VerifyOffset(verifier, VT_TEXTUREPNGS) && + verifier.VerifyVector(texturePngs()) && + verifier.VerifyVectorOfStrings(texturePngs()) && + VerifyOffset(verifier, VT_NODETREE) && + verifier.VerifyTable(nodeTree()) && + VerifyOffset(verifier, VT_ACTION) && + verifier.VerifyTable(action()) && + VerifyOffset(verifier, VT_ANIMATIONLIST) && + verifier.VerifyVector(animationList()) && + verifier.VerifyVectorOfTables(animationList()) && + verifier.EndTable(); + } }; -struct CSParseBinaryBuilder -{ - flatbuffers::FlatBufferBuilder& fbb_; - flatbuffers::uoffset_t start_; - void add_version(flatbuffers::Offset version) - { - fbb_.AddOffset(CSParseBinary::VT_VERSION, version); - } - void add_textures(flatbuffers::Offset>> textures) - { - fbb_.AddOffset(CSParseBinary::VT_TEXTURES, textures); - } - void add_texturePngs(flatbuffers::Offset>> texturePngs) - { - fbb_.AddOffset(CSParseBinary::VT_TEXTUREPNGS, texturePngs); - } - void add_nodeTree(flatbuffers::Offset nodeTree) { fbb_.AddOffset(CSParseBinary::VT_NODETREE, nodeTree); } - void add_action(flatbuffers::Offset action) { fbb_.AddOffset(CSParseBinary::VT_ACTION, action); } - void add_animationList(flatbuffers::Offset>> animationList) - { - fbb_.AddOffset(CSParseBinary::VT_ANIMATIONLIST, animationList); - } - explicit CSParseBinaryBuilder(flatbuffers::FlatBufferBuilder& _fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } - CSParseBinaryBuilder& operator=(const CSParseBinaryBuilder&); - flatbuffers::Offset Finish() - { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset(end); - return o; - } +struct CSParseBinaryBuilder { + typedef CSParseBinary Table; + flatbuffers::FlatBufferBuilder &fbb_; + flatbuffers::uoffset_t start_; + void add_version(flatbuffers::Offset version) { + fbb_.AddOffset(CSParseBinary::VT_VERSION, version); + } + void add_textures(flatbuffers::Offset>> textures) { + fbb_.AddOffset(CSParseBinary::VT_TEXTURES, textures); + } + void add_texturePngs(flatbuffers::Offset>> texturePngs) { + fbb_.AddOffset(CSParseBinary::VT_TEXTUREPNGS, texturePngs); + } + void add_nodeTree(flatbuffers::Offset nodeTree) { + fbb_.AddOffset(CSParseBinary::VT_NODETREE, nodeTree); + } + void add_action(flatbuffers::Offset action) { + fbb_.AddOffset(CSParseBinary::VT_ACTION, action); + } + void add_animationList(flatbuffers::Offset>> animationList) { + fbb_.AddOffset(CSParseBinary::VT_ANIMATIONLIST, animationList); + } + explicit CSParseBinaryBuilder(flatbuffers::FlatBufferBuilder &_fbb) + : fbb_(_fbb) { + start_ = fbb_.StartTable(); + } + flatbuffers::Offset Finish() { + const auto end = fbb_.EndTable(start_); + auto o = flatbuffers::Offset(end); + return o; + } }; inline flatbuffers::Offset CreateCSParseBinary( - flatbuffers::FlatBufferBuilder& _fbb, - flatbuffers::Offset version = 0, - flatbuffers::Offset>> textures = 0, + flatbuffers::FlatBufferBuilder &_fbb, + flatbuffers::Offset version = 0, + flatbuffers::Offset>> textures = 0, flatbuffers::Offset>> texturePngs = 0, - flatbuffers::Offset nodeTree = 0, - flatbuffers::Offset action = 0, - flatbuffers::Offset>> animationList = 0) -{ - CSParseBinaryBuilder builder_(_fbb); - builder_.add_animationList(animationList); - builder_.add_action(action); - builder_.add_nodeTree(nodeTree); - builder_.add_texturePngs(texturePngs); - builder_.add_textures(textures); - builder_.add_version(version); - return builder_.Finish(); + flatbuffers::Offset nodeTree = 0, + flatbuffers::Offset action = 0, + flatbuffers::Offset>> animationList = 0) { + CSParseBinaryBuilder builder_(_fbb); + builder_.add_animationList(animationList); + builder_.add_action(action); + builder_.add_nodeTree(nodeTree); + builder_.add_texturePngs(texturePngs); + builder_.add_textures(textures); + builder_.add_version(version); + return builder_.Finish(); } inline flatbuffers::Offset CreateCSParseBinaryDirect( - flatbuffers::FlatBufferBuilder& _fbb, - const char* version = nullptr, - const std::vector>* textures = nullptr, - const std::vector>* texturePngs = nullptr, - flatbuffers::Offset nodeTree = 0, - flatbuffers::Offset action = 0, - const std::vector>* animationList = nullptr) -{ - auto version__ = version ? _fbb.CreateString(version) : 0; - auto textures__ = textures ? _fbb.CreateVector>(*textures) : 0; - auto texturePngs__ = texturePngs ? _fbb.CreateVector>(*texturePngs) : 0; - auto animationList__ = animationList ? _fbb.CreateVector>(*animationList) : 0; - return flatbuffers::CreateCSParseBinary(_fbb, version__, textures__, texturePngs__, nodeTree, action, - animationList__); + flatbuffers::FlatBufferBuilder &_fbb, + const char *version = nullptr, + const std::vector> *textures = nullptr, + const std::vector> *texturePngs = nullptr, + flatbuffers::Offset nodeTree = 0, + flatbuffers::Offset action = 0, + const std::vector> *animationList = nullptr) { + auto version__ = version ? _fbb.CreateString(version) : 0; + auto textures__ = textures ? _fbb.CreateVector>(*textures) : 0; + auto texturePngs__ = texturePngs ? _fbb.CreateVector>(*texturePngs) : 0; + auto animationList__ = animationList ? _fbb.CreateVector>(*animationList) : 0; + return flatbuffers::CreateCSParseBinary( + _fbb, + version__, + textures__, + texturePngs__, + nodeTree, + action, + animationList__); } -struct NodeTree FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table -{ - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE - { - VT_CLASSNAME = 4, - VT_CHILDREN = 6, - VT_OPTIONS = 8, - VT_CUSTOMCLASSNAME = 10 - }; - const flatbuffers::String* classname() const { return GetPointer(VT_CLASSNAME); } - const flatbuffers::Vector>* children() const - { - return GetPointer>*>(VT_CHILDREN); - } - const Options* options() const { return GetPointer(VT_OPTIONS); } - const flatbuffers::String* customClassName() const - { - return GetPointer(VT_CUSTOMCLASSNAME); - } - bool Verify(flatbuffers::Verifier& verifier) const - { - return VerifyTableStart(verifier) && VerifyOffset(verifier, VT_CLASSNAME) && - verifier.VerifyString(classname()) && VerifyOffset(verifier, VT_CHILDREN) && - verifier.VerifyVector(children()) && verifier.VerifyVectorOfTables(children()) && - VerifyOffset(verifier, VT_OPTIONS) && verifier.VerifyTable(options()) && - VerifyOffset(verifier, VT_CUSTOMCLASSNAME) && verifier.VerifyString(customClassName()) && - verifier.EndTable(); - } +struct NodeTree FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { + typedef NodeTreeBuilder Builder; + enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { + VT_CLASSNAME = 4, + VT_CHILDREN = 6, + VT_OPTIONS = 8, + VT_CUSTOMCLASSNAME = 10 + }; + const flatbuffers::String *classname() const { + return GetPointer(VT_CLASSNAME); + } + const flatbuffers::Vector> *children() const { + return GetPointer> *>(VT_CHILDREN); + } + const flatbuffers::Options *options() const { + return GetPointer(VT_OPTIONS); + } + const flatbuffers::String *customClassName() const { + return GetPointer(VT_CUSTOMCLASSNAME); + } + bool Verify(flatbuffers::Verifier &verifier) const { + return VerifyTableStart(verifier) && + VerifyOffset(verifier, VT_CLASSNAME) && + verifier.VerifyString(classname()) && + VerifyOffset(verifier, VT_CHILDREN) && + verifier.VerifyVector(children()) && + verifier.VerifyVectorOfTables(children()) && + VerifyOffset(verifier, VT_OPTIONS) && + verifier.VerifyTable(options()) && + VerifyOffset(verifier, VT_CUSTOMCLASSNAME) && + verifier.VerifyString(customClassName()) && + verifier.EndTable(); + } }; -struct NodeTreeBuilder -{ - flatbuffers::FlatBufferBuilder& fbb_; - flatbuffers::uoffset_t start_; - void add_classname(flatbuffers::Offset classname) - { - fbb_.AddOffset(NodeTree::VT_CLASSNAME, classname); - } - void add_children(flatbuffers::Offset>> children) - { - fbb_.AddOffset(NodeTree::VT_CHILDREN, children); - } - void add_options(flatbuffers::Offset options) { fbb_.AddOffset(NodeTree::VT_OPTIONS, options); } - void add_customClassName(flatbuffers::Offset customClassName) - { - fbb_.AddOffset(NodeTree::VT_CUSTOMCLASSNAME, customClassName); - } - explicit NodeTreeBuilder(flatbuffers::FlatBufferBuilder& _fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } - NodeTreeBuilder& operator=(const NodeTreeBuilder&); - flatbuffers::Offset Finish() - { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset(end); - return o; - } +struct NodeTreeBuilder { + typedef NodeTree Table; + flatbuffers::FlatBufferBuilder &fbb_; + flatbuffers::uoffset_t start_; + void add_classname(flatbuffers::Offset classname) { + fbb_.AddOffset(NodeTree::VT_CLASSNAME, classname); + } + void add_children(flatbuffers::Offset>> children) { + fbb_.AddOffset(NodeTree::VT_CHILDREN, children); + } + void add_options(flatbuffers::Offset options) { + fbb_.AddOffset(NodeTree::VT_OPTIONS, options); + } + void add_customClassName(flatbuffers::Offset customClassName) { + fbb_.AddOffset(NodeTree::VT_CUSTOMCLASSNAME, customClassName); + } + explicit NodeTreeBuilder(flatbuffers::FlatBufferBuilder &_fbb) + : fbb_(_fbb) { + start_ = fbb_.StartTable(); + } + flatbuffers::Offset Finish() { + const auto end = fbb_.EndTable(start_); + auto o = flatbuffers::Offset(end); + return o; + } }; inline flatbuffers::Offset CreateNodeTree( - flatbuffers::FlatBufferBuilder& _fbb, - flatbuffers::Offset classname = 0, - flatbuffers::Offset>> children = 0, - flatbuffers::Offset options = 0, - flatbuffers::Offset customClassName = 0) -{ - NodeTreeBuilder builder_(_fbb); - builder_.add_customClassName(customClassName); - builder_.add_options(options); - builder_.add_children(children); - builder_.add_classname(classname); - return builder_.Finish(); + flatbuffers::FlatBufferBuilder &_fbb, + flatbuffers::Offset classname = 0, + flatbuffers::Offset>> children = 0, + flatbuffers::Offset options = 0, + flatbuffers::Offset customClassName = 0) { + NodeTreeBuilder builder_(_fbb); + builder_.add_customClassName(customClassName); + builder_.add_options(options); + builder_.add_children(children); + builder_.add_classname(classname); + return builder_.Finish(); } inline flatbuffers::Offset CreateNodeTreeDirect( - flatbuffers::FlatBufferBuilder& _fbb, - const char* classname = nullptr, - const std::vector>* children = nullptr, - flatbuffers::Offset options = 0, - const char* customClassName = nullptr) -{ - auto classname__ = classname ? _fbb.CreateString(classname) : 0; - auto children__ = children ? _fbb.CreateVector>(*children) : 0; - auto customClassName__ = customClassName ? _fbb.CreateString(customClassName) : 0; - return flatbuffers::CreateNodeTree(_fbb, classname__, children__, options, customClassName__); + flatbuffers::FlatBufferBuilder &_fbb, + const char *classname = nullptr, + const std::vector> *children = nullptr, + flatbuffers::Offset options = 0, + const char *customClassName = nullptr) { + auto classname__ = classname ? _fbb.CreateString(classname) : 0; + auto children__ = children ? _fbb.CreateVector>(*children) : 0; + auto customClassName__ = customClassName ? _fbb.CreateString(customClassName) : 0; + return flatbuffers::CreateNodeTree( + _fbb, + classname__, + children__, + options, + customClassName__); } -struct Options FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table -{ - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE - { - VT_DATA = 4 - }; - const WidgetOptions* data() const { return GetPointer(VT_DATA); } - bool Verify(flatbuffers::Verifier& verifier) const - { - return VerifyTableStart(verifier) && VerifyOffset(verifier, VT_DATA) && verifier.VerifyTable(data()) && - verifier.EndTable(); - } +struct Options FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { + typedef OptionsBuilder Builder; + enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { + VT_DATA = 4 + }; + const flatbuffers::WidgetOptions *data() const { + return GetPointer(VT_DATA); + } + bool Verify(flatbuffers::Verifier &verifier) const { + return VerifyTableStart(verifier) && + VerifyOffset(verifier, VT_DATA) && + verifier.VerifyTable(data()) && + verifier.EndTable(); + } }; -struct OptionsBuilder -{ - flatbuffers::FlatBufferBuilder& fbb_; - flatbuffers::uoffset_t start_; - void add_data(flatbuffers::Offset data) { fbb_.AddOffset(Options::VT_DATA, data); } - explicit OptionsBuilder(flatbuffers::FlatBufferBuilder& _fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } - OptionsBuilder& operator=(const OptionsBuilder&); - flatbuffers::Offset Finish() - { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset(end); - return o; - } +struct OptionsBuilder { + typedef Options Table; + flatbuffers::FlatBufferBuilder &fbb_; + flatbuffers::uoffset_t start_; + void add_data(flatbuffers::Offset data) { + fbb_.AddOffset(Options::VT_DATA, data); + } + explicit OptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) + : fbb_(_fbb) { + start_ = fbb_.StartTable(); + } + flatbuffers::Offset Finish() { + const auto end = fbb_.EndTable(start_); + auto o = flatbuffers::Offset(end); + return o; + } }; -inline flatbuffers::Offset CreateOptions(flatbuffers::FlatBufferBuilder& _fbb, - flatbuffers::Offset data = 0) -{ - OptionsBuilder builder_(_fbb); - builder_.add_data(data); - return builder_.Finish(); +inline flatbuffers::Offset CreateOptions( + flatbuffers::FlatBufferBuilder &_fbb, + flatbuffers::Offset data = 0) { + OptionsBuilder builder_(_fbb); + builder_.add_data(data); + return builder_.Finish(); } -struct WidgetOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table -{ - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE - { - VT_NAME = 4, - VT_ACTIONTAG = 6, - VT_ROTATIONSKEW = 8, - VT_ZORDER = 10, - VT_VISIBLE = 12, - VT_ALPHA = 14, - VT_TAG = 16, - VT_POSITION = 18, - VT_SCALE = 20, - VT_ANCHORPOINT = 22, - VT_COLOR = 24, - VT_SIZE = 26, - VT_FLIPX = 28, - VT_FLIPY = 30, - VT_IGNORESIZE = 32, - VT_TOUCHENABLED = 34, - VT_FRAMEEVENT = 36, - VT_CUSTOMPROPERTY = 38, - VT_CALLBACKTYPE = 40, - VT_CALLBACKNAME = 42, - VT_LAYOUTCOMPONENT = 44, - VT_CASCADECOLORENABLED = 46, - VT_CASCADEOPACITYENABLED = 48 - }; - const flatbuffers::String* name() const { return GetPointer(VT_NAME); } - int32_t actionTag() const { return GetField(VT_ACTIONTAG, 0); } - const RotationSkew* rotationSkew() const { return GetStruct(VT_ROTATIONSKEW); } - int32_t zOrder() const { return GetField(VT_ZORDER, 0); } - bool visible() const { return GetField(VT_VISIBLE, 1) != 0; } - uint8_t alpha() const { return GetField(VT_ALPHA, 255); } - int32_t tag() const { return GetField(VT_TAG, 0); } - const FVec2* position() const { return GetStruct(VT_POSITION); } - const Scale* scale() const { return GetStruct(VT_SCALE); } - const AnchorPoint* anchorPoint() const { return GetStruct(VT_ANCHORPOINT); } - const Color* color() const { return GetStruct(VT_COLOR); } - const FlatSize* size() const { return GetStruct(VT_SIZE); } - bool flipX() const { return GetField(VT_FLIPX, 0) != 0; } - bool flipY() const { return GetField(VT_FLIPY, 0) != 0; } - bool ignoreSize() const { return GetField(VT_IGNORESIZE, 0) != 0; } - bool touchEnabled() const { return GetField(VT_TOUCHENABLED, 0) != 0; } - const flatbuffers::String* frameEvent() const { return GetPointer(VT_FRAMEEVENT); } - const flatbuffers::String* customProperty() const - { - return GetPointer(VT_CUSTOMPROPERTY); - } - const flatbuffers::String* callBackType() const { return GetPointer(VT_CALLBACKTYPE); } - const flatbuffers::String* callBackName() const { return GetPointer(VT_CALLBACKNAME); } - const LayoutComponentTable* layoutComponent() const - { - return GetPointer(VT_LAYOUTCOMPONENT); - } - bool cascadeColorEnabled() const { return GetField(VT_CASCADECOLORENABLED, 0) != 0; } - bool cascadeOpacityEnabled() const { return GetField(VT_CASCADEOPACITYENABLED, 0) != 0; } - bool Verify(flatbuffers::Verifier& verifier) const - { - return VerifyTableStart(verifier) && VerifyOffset(verifier, VT_NAME) && verifier.VerifyString(name()) && - VerifyField(verifier, VT_ACTIONTAG) && VerifyField(verifier, VT_ROTATIONSKEW) && - VerifyField(verifier, VT_ZORDER) && VerifyField(verifier, VT_VISIBLE) && - VerifyField(verifier, VT_ALPHA) && VerifyField(verifier, VT_TAG) && - VerifyField(verifier, VT_POSITION) && VerifyField(verifier, VT_SCALE) && - VerifyField(verifier, VT_ANCHORPOINT) && VerifyField(verifier, VT_COLOR) && - VerifyField(verifier, VT_SIZE) && VerifyField(verifier, VT_FLIPX) && - VerifyField(verifier, VT_FLIPY) && VerifyField(verifier, VT_IGNORESIZE) && - VerifyField(verifier, VT_TOUCHENABLED) && VerifyOffset(verifier, VT_FRAMEEVENT) && - verifier.VerifyString(frameEvent()) && VerifyOffset(verifier, VT_CUSTOMPROPERTY) && - verifier.VerifyString(customProperty()) && VerifyOffset(verifier, VT_CALLBACKTYPE) && - verifier.VerifyString(callBackType()) && VerifyOffset(verifier, VT_CALLBACKNAME) && - verifier.VerifyString(callBackName()) && VerifyOffset(verifier, VT_LAYOUTCOMPONENT) && - verifier.VerifyTable(layoutComponent()) && VerifyField(verifier, VT_CASCADECOLORENABLED) && - VerifyField(verifier, VT_CASCADEOPACITYENABLED) && verifier.EndTable(); - } +struct WidgetOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { + typedef WidgetOptionsBuilder Builder; + enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { + VT_NAME = 4, + VT_ACTIONTAG = 6, + VT_ROTATIONSKEW = 8, + VT_ZORDER = 10, + VT_VISIBLE = 12, + VT_ALPHA = 14, + VT_TAG = 16, + VT_POSITION = 18, + VT_SCALE = 20, + VT_ANCHORPOINT = 22, + VT_COLOR = 24, + VT_SIZE = 26, + VT_FLIPX = 28, + VT_FLIPY = 30, + VT_IGNORESIZE = 32, + VT_TOUCHENABLED = 34, + VT_FRAMEEVENT = 36, + VT_CUSTOMPROPERTY = 38, + VT_CALLBACKTYPE = 40, + VT_CALLBACKNAME = 42, + VT_LAYOUTCOMPONENT = 44, + VT_CASCADECOLORENABLED = 46, + VT_CASCADEOPACITYENABLED = 48 + }; + const flatbuffers::String *name() const { + return GetPointer(VT_NAME); + } + int32_t actionTag() const { + return GetField(VT_ACTIONTAG, 0); + } + const flatbuffers::RotationSkew *rotationSkew() const { + return GetStruct(VT_ROTATIONSKEW); + } + int32_t zOrder() const { + return GetField(VT_ZORDER, 0); + } + bool visible() const { + return GetField(VT_VISIBLE, 1) != 0; + } + uint8_t alpha() const { + return GetField(VT_ALPHA, 255); + } + int32_t tag() const { + return GetField(VT_TAG, 0); + } + const flatbuffers::FVec2 *position() const { + return GetStruct(VT_POSITION); + } + const flatbuffers::Scale *scale() const { + return GetStruct(VT_SCALE); + } + const flatbuffers::AnchorPoint *anchorPoint() const { + return GetStruct(VT_ANCHORPOINT); + } + const flatbuffers::Color *color() const { + return GetStruct(VT_COLOR); + } + const flatbuffers::FlatSize *size() const { + return GetStruct(VT_SIZE); + } + bool flipX() const { + return GetField(VT_FLIPX, 0) != 0; + } + bool flipY() const { + return GetField(VT_FLIPY, 0) != 0; + } + bool ignoreSize() const { + return GetField(VT_IGNORESIZE, 0) != 0; + } + bool touchEnabled() const { + return GetField(VT_TOUCHENABLED, 0) != 0; + } + const flatbuffers::String *frameEvent() const { + return GetPointer(VT_FRAMEEVENT); + } + const flatbuffers::String *customProperty() const { + return GetPointer(VT_CUSTOMPROPERTY); + } + const flatbuffers::String *callBackType() const { + return GetPointer(VT_CALLBACKTYPE); + } + const flatbuffers::String *callBackName() const { + return GetPointer(VT_CALLBACKNAME); + } + const flatbuffers::LayoutComponentTable *layoutComponent() const { + return GetPointer(VT_LAYOUTCOMPONENT); + } + bool cascadeColorEnabled() const { + return GetField(VT_CASCADECOLORENABLED, 0) != 0; + } + bool cascadeOpacityEnabled() const { + return GetField(VT_CASCADEOPACITYENABLED, 0) != 0; + } + bool Verify(flatbuffers::Verifier &verifier) const { + return VerifyTableStart(verifier) && + VerifyOffset(verifier, VT_NAME) && + verifier.VerifyString(name()) && + VerifyField(verifier, VT_ACTIONTAG, 4) && + VerifyField(verifier, VT_ROTATIONSKEW, 4) && + VerifyField(verifier, VT_ZORDER, 4) && + VerifyField(verifier, VT_VISIBLE, 1) && + VerifyField(verifier, VT_ALPHA, 1) && + VerifyField(verifier, VT_TAG, 4) && + VerifyField(verifier, VT_POSITION, 4) && + VerifyField(verifier, VT_SCALE, 4) && + VerifyField(verifier, VT_ANCHORPOINT, 4) && + VerifyField(verifier, VT_COLOR, 1) && + VerifyField(verifier, VT_SIZE, 4) && + VerifyField(verifier, VT_FLIPX, 1) && + VerifyField(verifier, VT_FLIPY, 1) && + VerifyField(verifier, VT_IGNORESIZE, 1) && + VerifyField(verifier, VT_TOUCHENABLED, 1) && + VerifyOffset(verifier, VT_FRAMEEVENT) && + verifier.VerifyString(frameEvent()) && + VerifyOffset(verifier, VT_CUSTOMPROPERTY) && + verifier.VerifyString(customProperty()) && + VerifyOffset(verifier, VT_CALLBACKTYPE) && + verifier.VerifyString(callBackType()) && + VerifyOffset(verifier, VT_CALLBACKNAME) && + verifier.VerifyString(callBackName()) && + VerifyOffset(verifier, VT_LAYOUTCOMPONENT) && + verifier.VerifyTable(layoutComponent()) && + VerifyField(verifier, VT_CASCADECOLORENABLED, 1) && + VerifyField(verifier, VT_CASCADEOPACITYENABLED, 1) && + verifier.EndTable(); + } }; -struct WidgetOptionsBuilder -{ - flatbuffers::FlatBufferBuilder& fbb_; - flatbuffers::uoffset_t start_; - void add_name(flatbuffers::Offset name) { fbb_.AddOffset(WidgetOptions::VT_NAME, name); } - void add_actionTag(int32_t actionTag) { fbb_.AddElement(WidgetOptions::VT_ACTIONTAG, actionTag, 0); } - void add_rotationSkew(const RotationSkew* rotationSkew) - { - fbb_.AddStruct(WidgetOptions::VT_ROTATIONSKEW, rotationSkew); - } - void add_zOrder(int32_t zOrder) { fbb_.AddElement(WidgetOptions::VT_ZORDER, zOrder, 0); } - void add_visible(bool visible) - { - fbb_.AddElement(WidgetOptions::VT_VISIBLE, static_cast(visible), 1); - } - void add_alpha(uint8_t alpha) { fbb_.AddElement(WidgetOptions::VT_ALPHA, alpha, 255); } - void add_tag(int32_t tag) { fbb_.AddElement(WidgetOptions::VT_TAG, tag, 0); } - void add_position(const FVec2* position) { fbb_.AddStruct(WidgetOptions::VT_POSITION, position); } - void add_scale(const Scale* scale) { fbb_.AddStruct(WidgetOptions::VT_SCALE, scale); } - void add_anchorPoint(const AnchorPoint* anchorPoint) { fbb_.AddStruct(WidgetOptions::VT_ANCHORPOINT, anchorPoint); } - void add_color(const Color* color) { fbb_.AddStruct(WidgetOptions::VT_COLOR, color); } - void add_size(const FlatSize* size) { fbb_.AddStruct(WidgetOptions::VT_SIZE, size); } - void add_flipX(bool flipX) { fbb_.AddElement(WidgetOptions::VT_FLIPX, static_cast(flipX), 0); } - void add_flipY(bool flipY) { fbb_.AddElement(WidgetOptions::VT_FLIPY, static_cast(flipY), 0); } - void add_ignoreSize(bool ignoreSize) - { - fbb_.AddElement(WidgetOptions::VT_IGNORESIZE, static_cast(ignoreSize), 0); - } - void add_touchEnabled(bool touchEnabled) - { - fbb_.AddElement(WidgetOptions::VT_TOUCHENABLED, static_cast(touchEnabled), 0); - } - void add_frameEvent(flatbuffers::Offset frameEvent) - { - fbb_.AddOffset(WidgetOptions::VT_FRAMEEVENT, frameEvent); - } - void add_customProperty(flatbuffers::Offset customProperty) - { - fbb_.AddOffset(WidgetOptions::VT_CUSTOMPROPERTY, customProperty); - } - void add_callBackType(flatbuffers::Offset callBackType) - { - fbb_.AddOffset(WidgetOptions::VT_CALLBACKTYPE, callBackType); - } - void add_callBackName(flatbuffers::Offset callBackName) - { - fbb_.AddOffset(WidgetOptions::VT_CALLBACKNAME, callBackName); - } - void add_layoutComponent(flatbuffers::Offset layoutComponent) - { - fbb_.AddOffset(WidgetOptions::VT_LAYOUTCOMPONENT, layoutComponent); - } - void add_cascadeColorEnabled(bool cascadeColorEnabled) - { - fbb_.AddElement(WidgetOptions::VT_CASCADECOLORENABLED, static_cast(cascadeColorEnabled), 0); - } - void add_cascadeOpacityEnabled(bool cascadeOpacityEnabled) - { - fbb_.AddElement(WidgetOptions::VT_CASCADEOPACITYENABLED, static_cast(cascadeOpacityEnabled), - 0); - } - explicit WidgetOptionsBuilder(flatbuffers::FlatBufferBuilder& _fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } - WidgetOptionsBuilder& operator=(const WidgetOptionsBuilder&); - flatbuffers::Offset Finish() - { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset(end); - return o; - } +struct WidgetOptionsBuilder { + typedef WidgetOptions Table; + flatbuffers::FlatBufferBuilder &fbb_; + flatbuffers::uoffset_t start_; + void add_name(flatbuffers::Offset name) { + fbb_.AddOffset(WidgetOptions::VT_NAME, name); + } + void add_actionTag(int32_t actionTag) { + fbb_.AddElement(WidgetOptions::VT_ACTIONTAG, actionTag, 0); + } + void add_rotationSkew(const flatbuffers::RotationSkew *rotationSkew) { + fbb_.AddStruct(WidgetOptions::VT_ROTATIONSKEW, rotationSkew); + } + void add_zOrder(int32_t zOrder) { + fbb_.AddElement(WidgetOptions::VT_ZORDER, zOrder, 0); + } + void add_visible(bool visible) { + fbb_.AddElement(WidgetOptions::VT_VISIBLE, static_cast(visible), 1); + } + void add_alpha(uint8_t alpha) { + fbb_.AddElement(WidgetOptions::VT_ALPHA, alpha, 255); + } + void add_tag(int32_t tag) { + fbb_.AddElement(WidgetOptions::VT_TAG, tag, 0); + } + void add_position(const flatbuffers::FVec2 *position) { + fbb_.AddStruct(WidgetOptions::VT_POSITION, position); + } + void add_scale(const flatbuffers::Scale *scale) { + fbb_.AddStruct(WidgetOptions::VT_SCALE, scale); + } + void add_anchorPoint(const flatbuffers::AnchorPoint *anchorPoint) { + fbb_.AddStruct(WidgetOptions::VT_ANCHORPOINT, anchorPoint); + } + void add_color(const flatbuffers::Color *color) { + fbb_.AddStruct(WidgetOptions::VT_COLOR, color); + } + void add_size(const flatbuffers::FlatSize *size) { + fbb_.AddStruct(WidgetOptions::VT_SIZE, size); + } + void add_flipX(bool flipX) { + fbb_.AddElement(WidgetOptions::VT_FLIPX, static_cast(flipX), 0); + } + void add_flipY(bool flipY) { + fbb_.AddElement(WidgetOptions::VT_FLIPY, static_cast(flipY), 0); + } + void add_ignoreSize(bool ignoreSize) { + fbb_.AddElement(WidgetOptions::VT_IGNORESIZE, static_cast(ignoreSize), 0); + } + void add_touchEnabled(bool touchEnabled) { + fbb_.AddElement(WidgetOptions::VT_TOUCHENABLED, static_cast(touchEnabled), 0); + } + void add_frameEvent(flatbuffers::Offset frameEvent) { + fbb_.AddOffset(WidgetOptions::VT_FRAMEEVENT, frameEvent); + } + void add_customProperty(flatbuffers::Offset customProperty) { + fbb_.AddOffset(WidgetOptions::VT_CUSTOMPROPERTY, customProperty); + } + void add_callBackType(flatbuffers::Offset callBackType) { + fbb_.AddOffset(WidgetOptions::VT_CALLBACKTYPE, callBackType); + } + void add_callBackName(flatbuffers::Offset callBackName) { + fbb_.AddOffset(WidgetOptions::VT_CALLBACKNAME, callBackName); + } + void add_layoutComponent(flatbuffers::Offset layoutComponent) { + fbb_.AddOffset(WidgetOptions::VT_LAYOUTCOMPONENT, layoutComponent); + } + void add_cascadeColorEnabled(bool cascadeColorEnabled) { + fbb_.AddElement(WidgetOptions::VT_CASCADECOLORENABLED, static_cast(cascadeColorEnabled), 0); + } + void add_cascadeOpacityEnabled(bool cascadeOpacityEnabled) { + fbb_.AddElement(WidgetOptions::VT_CASCADEOPACITYENABLED, static_cast(cascadeOpacityEnabled), 0); + } + explicit WidgetOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) + : fbb_(_fbb) { + start_ = fbb_.StartTable(); + } + flatbuffers::Offset Finish() { + const auto end = fbb_.EndTable(start_); + auto o = flatbuffers::Offset(end); + return o; + } }; inline flatbuffers::Offset CreateWidgetOptions( - flatbuffers::FlatBufferBuilder& _fbb, - flatbuffers::Offset name = 0, - int32_t actionTag = 0, - const RotationSkew* rotationSkew = 0, - int32_t zOrder = 0, - bool visible = true, - uint8_t alpha = 255, - int32_t tag = 0, - const FVec2* position = 0, - const Scale* scale = 0, - const AnchorPoint* anchorPoint = 0, - const Color* color = 0, - const FlatSize* size = 0, - bool flipX = false, - bool flipY = false, - bool ignoreSize = false, - bool touchEnabled = false, - flatbuffers::Offset frameEvent = 0, - flatbuffers::Offset customProperty = 0, - flatbuffers::Offset callBackType = 0, - flatbuffers::Offset callBackName = 0, - flatbuffers::Offset layoutComponent = 0, - bool cascadeColorEnabled = false, - bool cascadeOpacityEnabled = false) -{ - WidgetOptionsBuilder builder_(_fbb); - builder_.add_layoutComponent(layoutComponent); - builder_.add_callBackName(callBackName); - builder_.add_callBackType(callBackType); - builder_.add_customProperty(customProperty); - builder_.add_frameEvent(frameEvent); - builder_.add_size(size); - builder_.add_color(color); - builder_.add_anchorPoint(anchorPoint); - builder_.add_scale(scale); - builder_.add_position(position); - builder_.add_tag(tag); - builder_.add_zOrder(zOrder); - builder_.add_rotationSkew(rotationSkew); - builder_.add_actionTag(actionTag); - builder_.add_name(name); - builder_.add_cascadeOpacityEnabled(cascadeOpacityEnabled); - builder_.add_cascadeColorEnabled(cascadeColorEnabled); - builder_.add_touchEnabled(touchEnabled); - builder_.add_ignoreSize(ignoreSize); - builder_.add_flipY(flipY); - builder_.add_flipX(flipX); - builder_.add_alpha(alpha); - builder_.add_visible(visible); - return builder_.Finish(); + flatbuffers::FlatBufferBuilder &_fbb, + flatbuffers::Offset name = 0, + int32_t actionTag = 0, + const flatbuffers::RotationSkew *rotationSkew = nullptr, + int32_t zOrder = 0, + bool visible = true, + uint8_t alpha = 255, + int32_t tag = 0, + const flatbuffers::FVec2 *position = nullptr, + const flatbuffers::Scale *scale = nullptr, + const flatbuffers::AnchorPoint *anchorPoint = nullptr, + const flatbuffers::Color *color = nullptr, + const flatbuffers::FlatSize *size = nullptr, + bool flipX = false, + bool flipY = false, + bool ignoreSize = false, + bool touchEnabled = false, + flatbuffers::Offset frameEvent = 0, + flatbuffers::Offset customProperty = 0, + flatbuffers::Offset callBackType = 0, + flatbuffers::Offset callBackName = 0, + flatbuffers::Offset layoutComponent = 0, + bool cascadeColorEnabled = false, + bool cascadeOpacityEnabled = false) { + WidgetOptionsBuilder builder_(_fbb); + builder_.add_layoutComponent(layoutComponent); + builder_.add_callBackName(callBackName); + builder_.add_callBackType(callBackType); + builder_.add_customProperty(customProperty); + builder_.add_frameEvent(frameEvent); + builder_.add_size(size); + builder_.add_color(color); + builder_.add_anchorPoint(anchorPoint); + builder_.add_scale(scale); + builder_.add_position(position); + builder_.add_tag(tag); + builder_.add_zOrder(zOrder); + builder_.add_rotationSkew(rotationSkew); + builder_.add_actionTag(actionTag); + builder_.add_name(name); + builder_.add_cascadeOpacityEnabled(cascadeOpacityEnabled); + builder_.add_cascadeColorEnabled(cascadeColorEnabled); + builder_.add_touchEnabled(touchEnabled); + builder_.add_ignoreSize(ignoreSize); + builder_.add_flipY(flipY); + builder_.add_flipX(flipX); + builder_.add_alpha(alpha); + builder_.add_visible(visible); + return builder_.Finish(); } inline flatbuffers::Offset CreateWidgetOptionsDirect( - flatbuffers::FlatBufferBuilder& _fbb, - const char* name = nullptr, - int32_t actionTag = 0, - const RotationSkew* rotationSkew = 0, - int32_t zOrder = 0, - bool visible = true, - uint8_t alpha = 255, - int32_t tag = 0, - const FVec2* position = 0, - const Scale* scale = 0, - const AnchorPoint* anchorPoint = 0, - const Color* color = 0, - const FlatSize* size = 0, - bool flipX = false, - bool flipY = false, - bool ignoreSize = false, - bool touchEnabled = false, - const char* frameEvent = nullptr, - const char* customProperty = nullptr, - const char* callBackType = nullptr, - const char* callBackName = nullptr, - flatbuffers::Offset layoutComponent = 0, - bool cascadeColorEnabled = false, - bool cascadeOpacityEnabled = false) -{ - auto name__ = name ? _fbb.CreateString(name) : 0; - auto frameEvent__ = frameEvent ? _fbb.CreateString(frameEvent) : 0; - auto customProperty__ = customProperty ? _fbb.CreateString(customProperty) : 0; - auto callBackType__ = callBackType ? _fbb.CreateString(callBackType) : 0; - auto callBackName__ = callBackName ? _fbb.CreateString(callBackName) : 0; - return flatbuffers::CreateWidgetOptions( - _fbb, name__, actionTag, rotationSkew, zOrder, visible, alpha, tag, position, scale, anchorPoint, color, size, - flipX, flipY, ignoreSize, touchEnabled, frameEvent__, customProperty__, callBackType__, callBackName__, - layoutComponent, cascadeColorEnabled, cascadeOpacityEnabled); + flatbuffers::FlatBufferBuilder &_fbb, + const char *name = nullptr, + int32_t actionTag = 0, + const flatbuffers::RotationSkew *rotationSkew = nullptr, + int32_t zOrder = 0, + bool visible = true, + uint8_t alpha = 255, + int32_t tag = 0, + const flatbuffers::FVec2 *position = nullptr, + const flatbuffers::Scale *scale = nullptr, + const flatbuffers::AnchorPoint *anchorPoint = nullptr, + const flatbuffers::Color *color = nullptr, + const flatbuffers::FlatSize *size = nullptr, + bool flipX = false, + bool flipY = false, + bool ignoreSize = false, + bool touchEnabled = false, + const char *frameEvent = nullptr, + const char *customProperty = nullptr, + const char *callBackType = nullptr, + const char *callBackName = nullptr, + flatbuffers::Offset layoutComponent = 0, + bool cascadeColorEnabled = false, + bool cascadeOpacityEnabled = false) { + auto name__ = name ? _fbb.CreateString(name) : 0; + auto frameEvent__ = frameEvent ? _fbb.CreateString(frameEvent) : 0; + auto customProperty__ = customProperty ? _fbb.CreateString(customProperty) : 0; + auto callBackType__ = callBackType ? _fbb.CreateString(callBackType) : 0; + auto callBackName__ = callBackName ? _fbb.CreateString(callBackName) : 0; + return flatbuffers::CreateWidgetOptions( + _fbb, + name__, + actionTag, + rotationSkew, + zOrder, + visible, + alpha, + tag, + position, + scale, + anchorPoint, + color, + size, + flipX, + flipY, + ignoreSize, + touchEnabled, + frameEvent__, + customProperty__, + callBackType__, + callBackName__, + layoutComponent, + cascadeColorEnabled, + cascadeOpacityEnabled); } -struct LayoutComponentTable FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table -{ - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE - { - VT_POSITIONXPERCENTENABLED = 4, - VT_POSITIONYPERCENTENABLED = 6, - VT_POSITIONXPERCENT = 8, - VT_POSITIONYPERCENT = 10, - VT_SIZEXPERCENTENABLE = 12, - VT_SIZEYPERCENTENABLE = 14, - VT_SIZEXPERCENT = 16, - VT_SIZEYPERCENT = 18, - VT_STRETCHHORIZONTALENABLED = 20, - VT_STRETCHVERTICALENABLED = 22, - VT_HORIZONTALEDGE = 24, - VT_VERTICALEDGE = 26, - VT_LEFTMARGIN = 28, - VT_RIGHTMARGIN = 30, - VT_TOPMARGIN = 32, - VT_BOTTOMMARGIN = 34 - }; - bool positionXPercentEnabled() const { return GetField(VT_POSITIONXPERCENTENABLED, 0) != 0; } - bool positionYPercentEnabled() const { return GetField(VT_POSITIONYPERCENTENABLED, 0) != 0; } - float positionXPercent() const { return GetField(VT_POSITIONXPERCENT, 0.0f); } - float positionYPercent() const { return GetField(VT_POSITIONYPERCENT, 0.0f); } - bool sizeXPercentEnable() const { return GetField(VT_SIZEXPERCENTENABLE, 0) != 0; } - bool sizeYPercentEnable() const { return GetField(VT_SIZEYPERCENTENABLE, 0) != 0; } - float sizeXPercent() const { return GetField(VT_SIZEXPERCENT, 0.0f); } - float sizeYPercent() const { return GetField(VT_SIZEYPERCENT, 0.0f); } - bool stretchHorizontalEnabled() const { return GetField(VT_STRETCHHORIZONTALENABLED, 0) != 0; } - bool stretchVerticalEnabled() const { return GetField(VT_STRETCHVERTICALENABLED, 0) != 0; } - const flatbuffers::String* horizontalEdge() const - { - return GetPointer(VT_HORIZONTALEDGE); - } - const flatbuffers::String* verticalEdge() const { return GetPointer(VT_VERTICALEDGE); } - float leftMargin() const { return GetField(VT_LEFTMARGIN, 0.0f); } - float rightMargin() const { return GetField(VT_RIGHTMARGIN, 0.0f); } - float topMargin() const { return GetField(VT_TOPMARGIN, 0.0f); } - float bottomMargin() const { return GetField(VT_BOTTOMMARGIN, 0.0f); } - bool Verify(flatbuffers::Verifier& verifier) const - { - return VerifyTableStart(verifier) && VerifyField(verifier, VT_POSITIONXPERCENTENABLED) && - VerifyField(verifier, VT_POSITIONYPERCENTENABLED) && - VerifyField(verifier, VT_POSITIONXPERCENT) && VerifyField(verifier, VT_POSITIONYPERCENT) && - VerifyField(verifier, VT_SIZEXPERCENTENABLE) && - VerifyField(verifier, VT_SIZEYPERCENTENABLE) && VerifyField(verifier, VT_SIZEXPERCENT) && - VerifyField(verifier, VT_SIZEYPERCENT) && - VerifyField(verifier, VT_STRETCHHORIZONTALENABLED) && - VerifyField(verifier, VT_STRETCHVERTICALENABLED) && VerifyOffset(verifier, VT_HORIZONTALEDGE) && - verifier.VerifyString(horizontalEdge()) && VerifyOffset(verifier, VT_VERTICALEDGE) && - verifier.VerifyString(verticalEdge()) && VerifyField(verifier, VT_LEFTMARGIN) && - VerifyField(verifier, VT_RIGHTMARGIN) && VerifyField(verifier, VT_TOPMARGIN) && - VerifyField(verifier, VT_BOTTOMMARGIN) && verifier.EndTable(); - } +struct LayoutComponentTable FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { + typedef LayoutComponentTableBuilder Builder; + enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { + VT_POSITIONXPERCENTENABLED = 4, + VT_POSITIONYPERCENTENABLED = 6, + VT_POSITIONXPERCENT = 8, + VT_POSITIONYPERCENT = 10, + VT_SIZEXPERCENTENABLE = 12, + VT_SIZEYPERCENTENABLE = 14, + VT_SIZEXPERCENT = 16, + VT_SIZEYPERCENT = 18, + VT_STRETCHHORIZONTALENABLED = 20, + VT_STRETCHVERTICALENABLED = 22, + VT_HORIZONTALEDGE = 24, + VT_VERTICALEDGE = 26, + VT_LEFTMARGIN = 28, + VT_RIGHTMARGIN = 30, + VT_TOPMARGIN = 32, + VT_BOTTOMMARGIN = 34 + }; + bool positionXPercentEnabled() const { + return GetField(VT_POSITIONXPERCENTENABLED, 0) != 0; + } + bool positionYPercentEnabled() const { + return GetField(VT_POSITIONYPERCENTENABLED, 0) != 0; + } + float positionXPercent() const { + return GetField(VT_POSITIONXPERCENT, 0.0f); + } + float positionYPercent() const { + return GetField(VT_POSITIONYPERCENT, 0.0f); + } + bool sizeXPercentEnable() const { + return GetField(VT_SIZEXPERCENTENABLE, 0) != 0; + } + bool sizeYPercentEnable() const { + return GetField(VT_SIZEYPERCENTENABLE, 0) != 0; + } + float sizeXPercent() const { + return GetField(VT_SIZEXPERCENT, 0.0f); + } + float sizeYPercent() const { + return GetField(VT_SIZEYPERCENT, 0.0f); + } + bool stretchHorizontalEnabled() const { + return GetField(VT_STRETCHHORIZONTALENABLED, 0) != 0; + } + bool stretchVerticalEnabled() const { + return GetField(VT_STRETCHVERTICALENABLED, 0) != 0; + } + const flatbuffers::String *horizontalEdge() const { + return GetPointer(VT_HORIZONTALEDGE); + } + const flatbuffers::String *verticalEdge() const { + return GetPointer(VT_VERTICALEDGE); + } + float leftMargin() const { + return GetField(VT_LEFTMARGIN, 0.0f); + } + float rightMargin() const { + return GetField(VT_RIGHTMARGIN, 0.0f); + } + float topMargin() const { + return GetField(VT_TOPMARGIN, 0.0f); + } + float bottomMargin() const { + return GetField(VT_BOTTOMMARGIN, 0.0f); + } + bool Verify(flatbuffers::Verifier &verifier) const { + return VerifyTableStart(verifier) && + VerifyField(verifier, VT_POSITIONXPERCENTENABLED, 1) && + VerifyField(verifier, VT_POSITIONYPERCENTENABLED, 1) && + VerifyField(verifier, VT_POSITIONXPERCENT, 4) && + VerifyField(verifier, VT_POSITIONYPERCENT, 4) && + VerifyField(verifier, VT_SIZEXPERCENTENABLE, 1) && + VerifyField(verifier, VT_SIZEYPERCENTENABLE, 1) && + VerifyField(verifier, VT_SIZEXPERCENT, 4) && + VerifyField(verifier, VT_SIZEYPERCENT, 4) && + VerifyField(verifier, VT_STRETCHHORIZONTALENABLED, 1) && + VerifyField(verifier, VT_STRETCHVERTICALENABLED, 1) && + VerifyOffset(verifier, VT_HORIZONTALEDGE) && + verifier.VerifyString(horizontalEdge()) && + VerifyOffset(verifier, VT_VERTICALEDGE) && + verifier.VerifyString(verticalEdge()) && + VerifyField(verifier, VT_LEFTMARGIN, 4) && + VerifyField(verifier, VT_RIGHTMARGIN, 4) && + VerifyField(verifier, VT_TOPMARGIN, 4) && + VerifyField(verifier, VT_BOTTOMMARGIN, 4) && + verifier.EndTable(); + } }; -struct LayoutComponentTableBuilder -{ - flatbuffers::FlatBufferBuilder& fbb_; - flatbuffers::uoffset_t start_; - void add_positionXPercentEnabled(bool positionXPercentEnabled) - { - fbb_.AddElement(LayoutComponentTable::VT_POSITIONXPERCENTENABLED, - static_cast(positionXPercentEnabled), 0); - } - void add_positionYPercentEnabled(bool positionYPercentEnabled) - { - fbb_.AddElement(LayoutComponentTable::VT_POSITIONYPERCENTENABLED, - static_cast(positionYPercentEnabled), 0); - } - void add_positionXPercent(float positionXPercent) - { - fbb_.AddElement(LayoutComponentTable::VT_POSITIONXPERCENT, positionXPercent, 0.0f); - } - void add_positionYPercent(float positionYPercent) - { - fbb_.AddElement(LayoutComponentTable::VT_POSITIONYPERCENT, positionYPercent, 0.0f); - } - void add_sizeXPercentEnable(bool sizeXPercentEnable) - { - fbb_.AddElement(LayoutComponentTable::VT_SIZEXPERCENTENABLE, static_cast(sizeXPercentEnable), - 0); - } - void add_sizeYPercentEnable(bool sizeYPercentEnable) - { - fbb_.AddElement(LayoutComponentTable::VT_SIZEYPERCENTENABLE, static_cast(sizeYPercentEnable), - 0); - } - void add_sizeXPercent(float sizeXPercent) - { - fbb_.AddElement(LayoutComponentTable::VT_SIZEXPERCENT, sizeXPercent, 0.0f); - } - void add_sizeYPercent(float sizeYPercent) - { - fbb_.AddElement(LayoutComponentTable::VT_SIZEYPERCENT, sizeYPercent, 0.0f); - } - void add_stretchHorizontalEnabled(bool stretchHorizontalEnabled) - { - fbb_.AddElement(LayoutComponentTable::VT_STRETCHHORIZONTALENABLED, - static_cast(stretchHorizontalEnabled), 0); - } - void add_stretchVerticalEnabled(bool stretchVerticalEnabled) - { - fbb_.AddElement(LayoutComponentTable::VT_STRETCHVERTICALENABLED, - static_cast(stretchVerticalEnabled), 0); - } - void add_horizontalEdge(flatbuffers::Offset horizontalEdge) - { - fbb_.AddOffset(LayoutComponentTable::VT_HORIZONTALEDGE, horizontalEdge); - } - void add_verticalEdge(flatbuffers::Offset verticalEdge) - { - fbb_.AddOffset(LayoutComponentTable::VT_VERTICALEDGE, verticalEdge); - } - void add_leftMargin(float leftMargin) - { - fbb_.AddElement(LayoutComponentTable::VT_LEFTMARGIN, leftMargin, 0.0f); - } - void add_rightMargin(float rightMargin) - { - fbb_.AddElement(LayoutComponentTable::VT_RIGHTMARGIN, rightMargin, 0.0f); - } - void add_topMargin(float topMargin) { fbb_.AddElement(LayoutComponentTable::VT_TOPMARGIN, topMargin, 0.0f); } - void add_bottomMargin(float bottomMargin) - { - fbb_.AddElement(LayoutComponentTable::VT_BOTTOMMARGIN, bottomMargin, 0.0f); - } - explicit LayoutComponentTableBuilder(flatbuffers::FlatBufferBuilder& _fbb) : fbb_(_fbb) - { - start_ = fbb_.StartTable(); - } - LayoutComponentTableBuilder& operator=(const LayoutComponentTableBuilder&); - flatbuffers::Offset Finish() - { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset(end); - return o; - } +struct LayoutComponentTableBuilder { + typedef LayoutComponentTable Table; + flatbuffers::FlatBufferBuilder &fbb_; + flatbuffers::uoffset_t start_; + void add_positionXPercentEnabled(bool positionXPercentEnabled) { + fbb_.AddElement(LayoutComponentTable::VT_POSITIONXPERCENTENABLED, static_cast(positionXPercentEnabled), 0); + } + void add_positionYPercentEnabled(bool positionYPercentEnabled) { + fbb_.AddElement(LayoutComponentTable::VT_POSITIONYPERCENTENABLED, static_cast(positionYPercentEnabled), 0); + } + void add_positionXPercent(float positionXPercent) { + fbb_.AddElement(LayoutComponentTable::VT_POSITIONXPERCENT, positionXPercent, 0.0f); + } + void add_positionYPercent(float positionYPercent) { + fbb_.AddElement(LayoutComponentTable::VT_POSITIONYPERCENT, positionYPercent, 0.0f); + } + void add_sizeXPercentEnable(bool sizeXPercentEnable) { + fbb_.AddElement(LayoutComponentTable::VT_SIZEXPERCENTENABLE, static_cast(sizeXPercentEnable), 0); + } + void add_sizeYPercentEnable(bool sizeYPercentEnable) { + fbb_.AddElement(LayoutComponentTable::VT_SIZEYPERCENTENABLE, static_cast(sizeYPercentEnable), 0); + } + void add_sizeXPercent(float sizeXPercent) { + fbb_.AddElement(LayoutComponentTable::VT_SIZEXPERCENT, sizeXPercent, 0.0f); + } + void add_sizeYPercent(float sizeYPercent) { + fbb_.AddElement(LayoutComponentTable::VT_SIZEYPERCENT, sizeYPercent, 0.0f); + } + void add_stretchHorizontalEnabled(bool stretchHorizontalEnabled) { + fbb_.AddElement(LayoutComponentTable::VT_STRETCHHORIZONTALENABLED, static_cast(stretchHorizontalEnabled), 0); + } + void add_stretchVerticalEnabled(bool stretchVerticalEnabled) { + fbb_.AddElement(LayoutComponentTable::VT_STRETCHVERTICALENABLED, static_cast(stretchVerticalEnabled), 0); + } + void add_horizontalEdge(flatbuffers::Offset horizontalEdge) { + fbb_.AddOffset(LayoutComponentTable::VT_HORIZONTALEDGE, horizontalEdge); + } + void add_verticalEdge(flatbuffers::Offset verticalEdge) { + fbb_.AddOffset(LayoutComponentTable::VT_VERTICALEDGE, verticalEdge); + } + void add_leftMargin(float leftMargin) { + fbb_.AddElement(LayoutComponentTable::VT_LEFTMARGIN, leftMargin, 0.0f); + } + void add_rightMargin(float rightMargin) { + fbb_.AddElement(LayoutComponentTable::VT_RIGHTMARGIN, rightMargin, 0.0f); + } + void add_topMargin(float topMargin) { + fbb_.AddElement(LayoutComponentTable::VT_TOPMARGIN, topMargin, 0.0f); + } + void add_bottomMargin(float bottomMargin) { + fbb_.AddElement(LayoutComponentTable::VT_BOTTOMMARGIN, bottomMargin, 0.0f); + } + explicit LayoutComponentTableBuilder(flatbuffers::FlatBufferBuilder &_fbb) + : fbb_(_fbb) { + start_ = fbb_.StartTable(); + } + flatbuffers::Offset Finish() { + const auto end = fbb_.EndTable(start_); + auto o = flatbuffers::Offset(end); + return o; + } }; inline flatbuffers::Offset CreateLayoutComponentTable( - flatbuffers::FlatBufferBuilder& _fbb, - bool positionXPercentEnabled = false, - bool positionYPercentEnabled = false, - float positionXPercent = 0.0f, - float positionYPercent = 0.0f, - bool sizeXPercentEnable = false, - bool sizeYPercentEnable = false, - float sizeXPercent = 0.0f, - float sizeYPercent = 0.0f, - bool stretchHorizontalEnabled = false, - bool stretchVerticalEnabled = false, + flatbuffers::FlatBufferBuilder &_fbb, + bool positionXPercentEnabled = false, + bool positionYPercentEnabled = false, + float positionXPercent = 0.0f, + float positionYPercent = 0.0f, + bool sizeXPercentEnable = false, + bool sizeYPercentEnable = false, + float sizeXPercent = 0.0f, + float sizeYPercent = 0.0f, + bool stretchHorizontalEnabled = false, + bool stretchVerticalEnabled = false, flatbuffers::Offset horizontalEdge = 0, - flatbuffers::Offset verticalEdge = 0, - float leftMargin = 0.0f, - float rightMargin = 0.0f, - float topMargin = 0.0f, - float bottomMargin = 0.0f) -{ - LayoutComponentTableBuilder builder_(_fbb); - builder_.add_bottomMargin(bottomMargin); - builder_.add_topMargin(topMargin); - builder_.add_rightMargin(rightMargin); - builder_.add_leftMargin(leftMargin); - builder_.add_verticalEdge(verticalEdge); - builder_.add_horizontalEdge(horizontalEdge); - builder_.add_sizeYPercent(sizeYPercent); - builder_.add_sizeXPercent(sizeXPercent); - builder_.add_positionYPercent(positionYPercent); - builder_.add_positionXPercent(positionXPercent); - builder_.add_stretchVerticalEnabled(stretchVerticalEnabled); - builder_.add_stretchHorizontalEnabled(stretchHorizontalEnabled); - builder_.add_sizeYPercentEnable(sizeYPercentEnable); - builder_.add_sizeXPercentEnable(sizeXPercentEnable); - builder_.add_positionYPercentEnabled(positionYPercentEnabled); - builder_.add_positionXPercentEnabled(positionXPercentEnabled); - return builder_.Finish(); + flatbuffers::Offset verticalEdge = 0, + float leftMargin = 0.0f, + float rightMargin = 0.0f, + float topMargin = 0.0f, + float bottomMargin = 0.0f) { + LayoutComponentTableBuilder builder_(_fbb); + builder_.add_bottomMargin(bottomMargin); + builder_.add_topMargin(topMargin); + builder_.add_rightMargin(rightMargin); + builder_.add_leftMargin(leftMargin); + builder_.add_verticalEdge(verticalEdge); + builder_.add_horizontalEdge(horizontalEdge); + builder_.add_sizeYPercent(sizeYPercent); + builder_.add_sizeXPercent(sizeXPercent); + builder_.add_positionYPercent(positionYPercent); + builder_.add_positionXPercent(positionXPercent); + builder_.add_stretchVerticalEnabled(stretchVerticalEnabled); + builder_.add_stretchHorizontalEnabled(stretchHorizontalEnabled); + builder_.add_sizeYPercentEnable(sizeYPercentEnable); + builder_.add_sizeXPercentEnable(sizeXPercentEnable); + builder_.add_positionYPercentEnabled(positionYPercentEnabled); + builder_.add_positionXPercentEnabled(positionXPercentEnabled); + return builder_.Finish(); } -inline flatbuffers::Offset CreateLayoutComponentTableDirect(flatbuffers::FlatBufferBuilder& _fbb, - bool positionXPercentEnabled = false, - bool positionYPercentEnabled = false, - float positionXPercent = 0.0f, - float positionYPercent = 0.0f, - bool sizeXPercentEnable = false, - bool sizeYPercentEnable = false, - float sizeXPercent = 0.0f, - float sizeYPercent = 0.0f, - bool stretchHorizontalEnabled = false, - bool stretchVerticalEnabled = false, - const char* horizontalEdge = nullptr, - const char* verticalEdge = nullptr, - float leftMargin = 0.0f, - float rightMargin = 0.0f, - float topMargin = 0.0f, - float bottomMargin = 0.0f) -{ - auto horizontalEdge__ = horizontalEdge ? _fbb.CreateString(horizontalEdge) : 0; - auto verticalEdge__ = verticalEdge ? _fbb.CreateString(verticalEdge) : 0; - return flatbuffers::CreateLayoutComponentTable( - _fbb, positionXPercentEnabled, positionYPercentEnabled, positionXPercent, positionYPercent, sizeXPercentEnable, - sizeYPercentEnable, sizeXPercent, sizeYPercent, stretchHorizontalEnabled, stretchVerticalEnabled, - horizontalEdge__, verticalEdge__, leftMargin, rightMargin, topMargin, bottomMargin); +inline flatbuffers::Offset CreateLayoutComponentTableDirect( + flatbuffers::FlatBufferBuilder &_fbb, + bool positionXPercentEnabled = false, + bool positionYPercentEnabled = false, + float positionXPercent = 0.0f, + float positionYPercent = 0.0f, + bool sizeXPercentEnable = false, + bool sizeYPercentEnable = false, + float sizeXPercent = 0.0f, + float sizeYPercent = 0.0f, + bool stretchHorizontalEnabled = false, + bool stretchVerticalEnabled = false, + const char *horizontalEdge = nullptr, + const char *verticalEdge = nullptr, + float leftMargin = 0.0f, + float rightMargin = 0.0f, + float topMargin = 0.0f, + float bottomMargin = 0.0f) { + auto horizontalEdge__ = horizontalEdge ? _fbb.CreateString(horizontalEdge) : 0; + auto verticalEdge__ = verticalEdge ? _fbb.CreateString(verticalEdge) : 0; + return flatbuffers::CreateLayoutComponentTable( + _fbb, + positionXPercentEnabled, + positionYPercentEnabled, + positionXPercent, + positionYPercent, + sizeXPercentEnable, + sizeYPercentEnable, + sizeXPercent, + sizeYPercent, + stretchHorizontalEnabled, + stretchVerticalEnabled, + horizontalEdge__, + verticalEdge__, + leftMargin, + rightMargin, + topMargin, + bottomMargin); } -struct SingleNodeOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table -{ - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE - { - VT_NODEOPTIONS = 4 - }; - const WidgetOptions* nodeOptions() const { return GetPointer(VT_NODEOPTIONS); } - bool Verify(flatbuffers::Verifier& verifier) const - { - return VerifyTableStart(verifier) && VerifyOffset(verifier, VT_NODEOPTIONS) && - verifier.VerifyTable(nodeOptions()) && verifier.EndTable(); - } +struct SingleNodeOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { + typedef SingleNodeOptionsBuilder Builder; + enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { + VT_NODEOPTIONS = 4 + }; + const flatbuffers::WidgetOptions *nodeOptions() const { + return GetPointer(VT_NODEOPTIONS); + } + bool Verify(flatbuffers::Verifier &verifier) const { + return VerifyTableStart(verifier) && + VerifyOffset(verifier, VT_NODEOPTIONS) && + verifier.VerifyTable(nodeOptions()) && + verifier.EndTable(); + } }; -struct SingleNodeOptionsBuilder -{ - flatbuffers::FlatBufferBuilder& fbb_; - flatbuffers::uoffset_t start_; - void add_nodeOptions(flatbuffers::Offset nodeOptions) - { - fbb_.AddOffset(SingleNodeOptions::VT_NODEOPTIONS, nodeOptions); - } - explicit SingleNodeOptionsBuilder(flatbuffers::FlatBufferBuilder& _fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } - SingleNodeOptionsBuilder& operator=(const SingleNodeOptionsBuilder&); - flatbuffers::Offset Finish() - { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset(end); - return o; - } +struct SingleNodeOptionsBuilder { + typedef SingleNodeOptions Table; + flatbuffers::FlatBufferBuilder &fbb_; + flatbuffers::uoffset_t start_; + void add_nodeOptions(flatbuffers::Offset nodeOptions) { + fbb_.AddOffset(SingleNodeOptions::VT_NODEOPTIONS, nodeOptions); + } + explicit SingleNodeOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) + : fbb_(_fbb) { + start_ = fbb_.StartTable(); + } + flatbuffers::Offset Finish() { + const auto end = fbb_.EndTable(start_); + auto o = flatbuffers::Offset(end); + return o; + } }; inline flatbuffers::Offset CreateSingleNodeOptions( - flatbuffers::FlatBufferBuilder& _fbb, - flatbuffers::Offset nodeOptions = 0) -{ - SingleNodeOptionsBuilder builder_(_fbb); - builder_.add_nodeOptions(nodeOptions); - return builder_.Finish(); + flatbuffers::FlatBufferBuilder &_fbb, + flatbuffers::Offset nodeOptions = 0) { + SingleNodeOptionsBuilder builder_(_fbb); + builder_.add_nodeOptions(nodeOptions); + return builder_.Finish(); } -struct SpriteOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table -{ - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE - { - VT_NODEOPTIONS = 4, - VT_FILENAMEDATA = 6, - VT_BLENDFUNC = 8, - VT_INTELLISHADINGENABLED = 10, - VT_HSV = 12, - VT_FILTER = 14 - }; - const WidgetOptions* nodeOptions() const { return GetPointer(VT_NODEOPTIONS); } - const ResourceData* fileNameData() const { return GetPointer(VT_FILENAMEDATA); } - const BlendFunc* blendFunc() const { return GetStruct(VT_BLENDFUNC); } - bool intelliShadingEnabled() const { return GetField(VT_INTELLISHADINGENABLED, 0) != 0; } - const FVec3* hsv() const { return GetStruct(VT_HSV); } - const FVec3* filter() const { return GetStruct(VT_FILTER); } - bool Verify(flatbuffers::Verifier& verifier) const - { - return VerifyTableStart(verifier) && VerifyOffset(verifier, VT_NODEOPTIONS) && - verifier.VerifyTable(nodeOptions()) && VerifyOffset(verifier, VT_FILENAMEDATA) && - verifier.VerifyTable(fileNameData()) && VerifyField(verifier, VT_BLENDFUNC) && - VerifyField(verifier, VT_INTELLISHADINGENABLED) && VerifyField(verifier, VT_HSV) && - VerifyField(verifier, VT_FILTER) && verifier.EndTable(); - } +struct SpriteOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { + typedef SpriteOptionsBuilder Builder; + enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { + VT_NODEOPTIONS = 4, + VT_FILENAMEDATA = 6, + VT_BLENDFUNC = 8, + VT_INTELLISHADINGENABLED = 10, + VT_HSV = 12, + VT_FILTER = 14 + }; + const flatbuffers::WidgetOptions *nodeOptions() const { + return GetPointer(VT_NODEOPTIONS); + } + const flatbuffers::ResourceData *fileNameData() const { + return GetPointer(VT_FILENAMEDATA); + } + const flatbuffers::BlendFunc *blendFunc() const { + return GetStruct(VT_BLENDFUNC); + } + bool intelliShadingEnabled() const { + return GetField(VT_INTELLISHADINGENABLED, 0) != 0; + } + const flatbuffers::FVec3 *hsv() const { + return GetStruct(VT_HSV); + } + const flatbuffers::FVec3 *filter() const { + return GetStruct(VT_FILTER); + } + bool Verify(flatbuffers::Verifier &verifier) const { + return VerifyTableStart(verifier) && + VerifyOffset(verifier, VT_NODEOPTIONS) && + verifier.VerifyTable(nodeOptions()) && + VerifyOffset(verifier, VT_FILENAMEDATA) && + verifier.VerifyTable(fileNameData()) && + VerifyField(verifier, VT_BLENDFUNC, 4) && + VerifyField(verifier, VT_INTELLISHADINGENABLED, 1) && + VerifyField(verifier, VT_HSV, 4) && + VerifyField(verifier, VT_FILTER, 4) && + verifier.EndTable(); + } }; -struct SpriteOptionsBuilder -{ - flatbuffers::FlatBufferBuilder& fbb_; - flatbuffers::uoffset_t start_; - void add_nodeOptions(flatbuffers::Offset nodeOptions) - { - fbb_.AddOffset(SpriteOptions::VT_NODEOPTIONS, nodeOptions); - } - void add_fileNameData(flatbuffers::Offset fileNameData) - { - fbb_.AddOffset(SpriteOptions::VT_FILENAMEDATA, fileNameData); - } - void add_blendFunc(const BlendFunc* blendFunc) { fbb_.AddStruct(SpriteOptions::VT_BLENDFUNC, blendFunc); } - void add_intelliShadingEnabled(bool intelliShadingEnabled) - { - fbb_.AddElement(SpriteOptions::VT_INTELLISHADINGENABLED, static_cast(intelliShadingEnabled), - 0); - } - void add_hsv(const FVec3* hsv) { fbb_.AddStruct(SpriteOptions::VT_HSV, hsv); } - void add_filter(const FVec3* filter) { fbb_.AddStruct(SpriteOptions::VT_FILTER, filter); } - explicit SpriteOptionsBuilder(flatbuffers::FlatBufferBuilder& _fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } - SpriteOptionsBuilder& operator=(const SpriteOptionsBuilder&); - flatbuffers::Offset Finish() - { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset(end); - return o; - } +struct SpriteOptionsBuilder { + typedef SpriteOptions Table; + flatbuffers::FlatBufferBuilder &fbb_; + flatbuffers::uoffset_t start_; + void add_nodeOptions(flatbuffers::Offset nodeOptions) { + fbb_.AddOffset(SpriteOptions::VT_NODEOPTIONS, nodeOptions); + } + void add_fileNameData(flatbuffers::Offset fileNameData) { + fbb_.AddOffset(SpriteOptions::VT_FILENAMEDATA, fileNameData); + } + void add_blendFunc(const flatbuffers::BlendFunc *blendFunc) { + fbb_.AddStruct(SpriteOptions::VT_BLENDFUNC, blendFunc); + } + void add_intelliShadingEnabled(bool intelliShadingEnabled) { + fbb_.AddElement(SpriteOptions::VT_INTELLISHADINGENABLED, static_cast(intelliShadingEnabled), 0); + } + void add_hsv(const flatbuffers::FVec3 *hsv) { + fbb_.AddStruct(SpriteOptions::VT_HSV, hsv); + } + void add_filter(const flatbuffers::FVec3 *filter) { + fbb_.AddStruct(SpriteOptions::VT_FILTER, filter); + } + explicit SpriteOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) + : fbb_(_fbb) { + start_ = fbb_.StartTable(); + } + flatbuffers::Offset Finish() { + const auto end = fbb_.EndTable(start_); + auto o = flatbuffers::Offset(end); + return o; + } }; -inline flatbuffers::Offset CreateSpriteOptions(flatbuffers::FlatBufferBuilder& _fbb, - flatbuffers::Offset nodeOptions = 0, - flatbuffers::Offset fileNameData = 0, - const BlendFunc* blendFunc = 0, - bool intelliShadingEnabled = false, - const FVec3* hsv = 0, - const FVec3* filter = 0) -{ - SpriteOptionsBuilder builder_(_fbb); - builder_.add_filter(filter); - builder_.add_hsv(hsv); - builder_.add_blendFunc(blendFunc); - builder_.add_fileNameData(fileNameData); - builder_.add_nodeOptions(nodeOptions); - builder_.add_intelliShadingEnabled(intelliShadingEnabled); - return builder_.Finish(); +inline flatbuffers::Offset CreateSpriteOptions( + flatbuffers::FlatBufferBuilder &_fbb, + flatbuffers::Offset nodeOptions = 0, + flatbuffers::Offset fileNameData = 0, + const flatbuffers::BlendFunc *blendFunc = nullptr, + bool intelliShadingEnabled = false, + const flatbuffers::FVec3 *hsv = nullptr, + const flatbuffers::FVec3 *filter = nullptr) { + SpriteOptionsBuilder builder_(_fbb); + builder_.add_filter(filter); + builder_.add_hsv(hsv); + builder_.add_blendFunc(blendFunc); + builder_.add_fileNameData(fileNameData); + builder_.add_nodeOptions(nodeOptions); + builder_.add_intelliShadingEnabled(intelliShadingEnabled); + return builder_.Finish(); } -struct ParticleSystemOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table -{ - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE - { - VT_NODEOPTIONS = 4, - VT_FILENAMEDATA = 6, - VT_BLENDFUNC = 8 - }; - const WidgetOptions* nodeOptions() const { return GetPointer(VT_NODEOPTIONS); } - const ResourceData* fileNameData() const { return GetPointer(VT_FILENAMEDATA); } - const BlendFunc* blendFunc() const { return GetStruct(VT_BLENDFUNC); } - bool Verify(flatbuffers::Verifier& verifier) const - { - return VerifyTableStart(verifier) && VerifyOffset(verifier, VT_NODEOPTIONS) && - verifier.VerifyTable(nodeOptions()) && VerifyOffset(verifier, VT_FILENAMEDATA) && - verifier.VerifyTable(fileNameData()) && VerifyField(verifier, VT_BLENDFUNC) && - verifier.EndTable(); - } +struct ParticleSystemOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { + typedef ParticleSystemOptionsBuilder Builder; + enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { + VT_NODEOPTIONS = 4, + VT_FILENAMEDATA = 6, + VT_BLENDFUNC = 8 + }; + const flatbuffers::WidgetOptions *nodeOptions() const { + return GetPointer(VT_NODEOPTIONS); + } + const flatbuffers::ResourceData *fileNameData() const { + return GetPointer(VT_FILENAMEDATA); + } + const flatbuffers::BlendFunc *blendFunc() const { + return GetStruct(VT_BLENDFUNC); + } + bool Verify(flatbuffers::Verifier &verifier) const { + return VerifyTableStart(verifier) && + VerifyOffset(verifier, VT_NODEOPTIONS) && + verifier.VerifyTable(nodeOptions()) && + VerifyOffset(verifier, VT_FILENAMEDATA) && + verifier.VerifyTable(fileNameData()) && + VerifyField(verifier, VT_BLENDFUNC, 4) && + verifier.EndTable(); + } }; -struct ParticleSystemOptionsBuilder -{ - flatbuffers::FlatBufferBuilder& fbb_; - flatbuffers::uoffset_t start_; - void add_nodeOptions(flatbuffers::Offset nodeOptions) - { - fbb_.AddOffset(ParticleSystemOptions::VT_NODEOPTIONS, nodeOptions); - } - void add_fileNameData(flatbuffers::Offset fileNameData) - { - fbb_.AddOffset(ParticleSystemOptions::VT_FILENAMEDATA, fileNameData); - } - void add_blendFunc(const BlendFunc* blendFunc) { fbb_.AddStruct(ParticleSystemOptions::VT_BLENDFUNC, blendFunc); } - explicit ParticleSystemOptionsBuilder(flatbuffers::FlatBufferBuilder& _fbb) : fbb_(_fbb) - { - start_ = fbb_.StartTable(); - } - ParticleSystemOptionsBuilder& operator=(const ParticleSystemOptionsBuilder&); - flatbuffers::Offset Finish() - { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset(end); - return o; - } +struct ParticleSystemOptionsBuilder { + typedef ParticleSystemOptions Table; + flatbuffers::FlatBufferBuilder &fbb_; + flatbuffers::uoffset_t start_; + void add_nodeOptions(flatbuffers::Offset nodeOptions) { + fbb_.AddOffset(ParticleSystemOptions::VT_NODEOPTIONS, nodeOptions); + } + void add_fileNameData(flatbuffers::Offset fileNameData) { + fbb_.AddOffset(ParticleSystemOptions::VT_FILENAMEDATA, fileNameData); + } + void add_blendFunc(const flatbuffers::BlendFunc *blendFunc) { + fbb_.AddStruct(ParticleSystemOptions::VT_BLENDFUNC, blendFunc); + } + explicit ParticleSystemOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) + : fbb_(_fbb) { + start_ = fbb_.StartTable(); + } + flatbuffers::Offset Finish() { + const auto end = fbb_.EndTable(start_); + auto o = flatbuffers::Offset(end); + return o; + } }; inline flatbuffers::Offset CreateParticleSystemOptions( - flatbuffers::FlatBufferBuilder& _fbb, - flatbuffers::Offset nodeOptions = 0, - flatbuffers::Offset fileNameData = 0, - const BlendFunc* blendFunc = 0) -{ - ParticleSystemOptionsBuilder builder_(_fbb); - builder_.add_blendFunc(blendFunc); - builder_.add_fileNameData(fileNameData); - builder_.add_nodeOptions(nodeOptions); - return builder_.Finish(); + flatbuffers::FlatBufferBuilder &_fbb, + flatbuffers::Offset nodeOptions = 0, + flatbuffers::Offset fileNameData = 0, + const flatbuffers::BlendFunc *blendFunc = nullptr) { + ParticleSystemOptionsBuilder builder_(_fbb); + builder_.add_blendFunc(blendFunc); + builder_.add_fileNameData(fileNameData); + builder_.add_nodeOptions(nodeOptions); + return builder_.Finish(); } -struct SpineSkeletonOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table -{ - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE - { - VT_NODEOPTIONS = 4, - VT_DATAFILE = 6, - VT_ATLASFILE = 8, - VT_ANIMATION = 10, - VT_SKIN = 12, - VT_LOOP = 14, - VT_TIMESCALE = 16 - }; - const WidgetOptions* nodeOptions() const { return GetPointer(VT_NODEOPTIONS); } - const flatbuffers::String* dataFile() const { return GetPointer(VT_DATAFILE); } - const flatbuffers::String* atlasFile() const { return GetPointer(VT_ATLASFILE); } - const flatbuffers::String* animation() const { return GetPointer(VT_ANIMATION); } - const flatbuffers::String* skin() const { return GetPointer(VT_SKIN); } - bool loop() const { return GetField(VT_LOOP, 0) != 0; } - float timeScale() const { return GetField(VT_TIMESCALE, 0.0f); } - bool Verify(flatbuffers::Verifier& verifier) const - { - return VerifyTableStart(verifier) && VerifyOffset(verifier, VT_NODEOPTIONS) && - verifier.VerifyTable(nodeOptions()) && VerifyOffset(verifier, VT_DATAFILE) && - verifier.VerifyString(dataFile()) && VerifyOffset(verifier, VT_ATLASFILE) && - verifier.VerifyString(atlasFile()) && VerifyOffset(verifier, VT_ANIMATION) && - verifier.VerifyString(animation()) && VerifyOffset(verifier, VT_SKIN) && verifier.VerifyString(skin()) && - VerifyField(verifier, VT_LOOP) && VerifyField(verifier, VT_TIMESCALE) && - verifier.EndTable(); - } +struct SpineSkeletonOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { + typedef SpineSkeletonOptionsBuilder Builder; + enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { + VT_NODEOPTIONS = 4, + VT_DATAFILE = 6, + VT_ATLASFILE = 8, + VT_ANIMATION = 10, + VT_SKIN = 12, + VT_LOOP = 14, + VT_TIMESCALE = 16 + }; + const flatbuffers::WidgetOptions *nodeOptions() const { + return GetPointer(VT_NODEOPTIONS); + } + const flatbuffers::String *dataFile() const { + return GetPointer(VT_DATAFILE); + } + const flatbuffers::String *atlasFile() const { + return GetPointer(VT_ATLASFILE); + } + const flatbuffers::String *animation() const { + return GetPointer(VT_ANIMATION); + } + const flatbuffers::String *skin() const { + return GetPointer(VT_SKIN); + } + bool loop() const { + return GetField(VT_LOOP, 0) != 0; + } + float timeScale() const { + return GetField(VT_TIMESCALE, 0.0f); + } + bool Verify(flatbuffers::Verifier &verifier) const { + return VerifyTableStart(verifier) && + VerifyOffset(verifier, VT_NODEOPTIONS) && + verifier.VerifyTable(nodeOptions()) && + VerifyOffset(verifier, VT_DATAFILE) && + verifier.VerifyString(dataFile()) && + VerifyOffset(verifier, VT_ATLASFILE) && + verifier.VerifyString(atlasFile()) && + VerifyOffset(verifier, VT_ANIMATION) && + verifier.VerifyString(animation()) && + VerifyOffset(verifier, VT_SKIN) && + verifier.VerifyString(skin()) && + VerifyField(verifier, VT_LOOP, 1) && + VerifyField(verifier, VT_TIMESCALE, 4) && + verifier.EndTable(); + } }; -struct SpineSkeletonOptionsBuilder -{ - flatbuffers::FlatBufferBuilder& fbb_; - flatbuffers::uoffset_t start_; - void add_nodeOptions(flatbuffers::Offset nodeOptions) - { - fbb_.AddOffset(SpineSkeletonOptions::VT_NODEOPTIONS, nodeOptions); - } - void add_dataFile(flatbuffers::Offset dataFile) - { - fbb_.AddOffset(SpineSkeletonOptions::VT_DATAFILE, dataFile); - } - void add_atlasFile(flatbuffers::Offset atlasFile) - { - fbb_.AddOffset(SpineSkeletonOptions::VT_ATLASFILE, atlasFile); - } - void add_animation(flatbuffers::Offset animation) - { - fbb_.AddOffset(SpineSkeletonOptions::VT_ANIMATION, animation); - } - void add_skin(flatbuffers::Offset skin) - { - fbb_.AddOffset(SpineSkeletonOptions::VT_SKIN, skin); - } - void add_loop(bool loop) { fbb_.AddElement(SpineSkeletonOptions::VT_LOOP, static_cast(loop), 0); } - void add_timeScale(float timeScale) { fbb_.AddElement(SpineSkeletonOptions::VT_TIMESCALE, timeScale, 0.0f); } - explicit SpineSkeletonOptionsBuilder(flatbuffers::FlatBufferBuilder& _fbb) : fbb_(_fbb) - { - start_ = fbb_.StartTable(); - } - SpineSkeletonOptionsBuilder& operator=(const SpineSkeletonOptionsBuilder&); - flatbuffers::Offset Finish() - { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset(end); - return o; - } +struct SpineSkeletonOptionsBuilder { + typedef SpineSkeletonOptions Table; + flatbuffers::FlatBufferBuilder &fbb_; + flatbuffers::uoffset_t start_; + void add_nodeOptions(flatbuffers::Offset nodeOptions) { + fbb_.AddOffset(SpineSkeletonOptions::VT_NODEOPTIONS, nodeOptions); + } + void add_dataFile(flatbuffers::Offset dataFile) { + fbb_.AddOffset(SpineSkeletonOptions::VT_DATAFILE, dataFile); + } + void add_atlasFile(flatbuffers::Offset atlasFile) { + fbb_.AddOffset(SpineSkeletonOptions::VT_ATLASFILE, atlasFile); + } + void add_animation(flatbuffers::Offset animation) { + fbb_.AddOffset(SpineSkeletonOptions::VT_ANIMATION, animation); + } + void add_skin(flatbuffers::Offset skin) { + fbb_.AddOffset(SpineSkeletonOptions::VT_SKIN, skin); + } + void add_loop(bool loop) { + fbb_.AddElement(SpineSkeletonOptions::VT_LOOP, static_cast(loop), 0); + } + void add_timeScale(float timeScale) { + fbb_.AddElement(SpineSkeletonOptions::VT_TIMESCALE, timeScale, 0.0f); + } + explicit SpineSkeletonOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) + : fbb_(_fbb) { + start_ = fbb_.StartTable(); + } + flatbuffers::Offset Finish() { + const auto end = fbb_.EndTable(start_); + auto o = flatbuffers::Offset(end); + return o; + } }; inline flatbuffers::Offset CreateSpineSkeletonOptions( - flatbuffers::FlatBufferBuilder& _fbb, - flatbuffers::Offset nodeOptions = 0, - flatbuffers::Offset dataFile = 0, + flatbuffers::FlatBufferBuilder &_fbb, + flatbuffers::Offset nodeOptions = 0, + flatbuffers::Offset dataFile = 0, flatbuffers::Offset atlasFile = 0, flatbuffers::Offset animation = 0, - flatbuffers::Offset skin = 0, - bool loop = false, - float timeScale = 0.0f) -{ - SpineSkeletonOptionsBuilder builder_(_fbb); - builder_.add_timeScale(timeScale); - builder_.add_skin(skin); - builder_.add_animation(animation); - builder_.add_atlasFile(atlasFile); - builder_.add_dataFile(dataFile); - builder_.add_nodeOptions(nodeOptions); - builder_.add_loop(loop); - return builder_.Finish(); + flatbuffers::Offset skin = 0, + bool loop = false, + float timeScale = 0.0f) { + SpineSkeletonOptionsBuilder builder_(_fbb); + builder_.add_timeScale(timeScale); + builder_.add_skin(skin); + builder_.add_animation(animation); + builder_.add_atlasFile(atlasFile); + builder_.add_dataFile(dataFile); + builder_.add_nodeOptions(nodeOptions); + builder_.add_loop(loop); + return builder_.Finish(); } inline flatbuffers::Offset CreateSpineSkeletonOptionsDirect( - flatbuffers::FlatBufferBuilder& _fbb, - flatbuffers::Offset nodeOptions = 0, - const char* dataFile = nullptr, - const char* atlasFile = nullptr, - const char* animation = nullptr, - const char* skin = nullptr, - bool loop = false, - float timeScale = 0.0f) -{ - auto dataFile__ = dataFile ? _fbb.CreateString(dataFile) : 0; - auto atlasFile__ = atlasFile ? _fbb.CreateString(atlasFile) : 0; - auto animation__ = animation ? _fbb.CreateString(animation) : 0; - auto skin__ = skin ? _fbb.CreateString(skin) : 0; - return flatbuffers::CreateSpineSkeletonOptions(_fbb, nodeOptions, dataFile__, atlasFile__, animation__, skin__, - loop, timeScale); + flatbuffers::FlatBufferBuilder &_fbb, + flatbuffers::Offset nodeOptions = 0, + const char *dataFile = nullptr, + const char *atlasFile = nullptr, + const char *animation = nullptr, + const char *skin = nullptr, + bool loop = false, + float timeScale = 0.0f) { + auto dataFile__ = dataFile ? _fbb.CreateString(dataFile) : 0; + auto atlasFile__ = atlasFile ? _fbb.CreateString(atlasFile) : 0; + auto animation__ = animation ? _fbb.CreateString(animation) : 0; + auto skin__ = skin ? _fbb.CreateString(skin) : 0; + return flatbuffers::CreateSpineSkeletonOptions( + _fbb, + nodeOptions, + dataFile__, + atlasFile__, + animation__, + skin__, + loop, + timeScale); } -struct ControlSwitchOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table -{ - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE - { - VT_NODEOPTIONS = 4, - VT_MASKIMAGE = 6, - VT_ONIMAGE = 8, - VT_OFFIMAGE = 10, - VT_THUMBIMAGE = 12, - VT_ON = 14, - VT_ENABLED = 16 - }; - const WidgetOptions* nodeOptions() const { return GetPointer(VT_NODEOPTIONS); } - const ResourceData* maskImage() const { return GetPointer(VT_MASKIMAGE); } - const ResourceData* onImage() const { return GetPointer(VT_ONIMAGE); } - const ResourceData* offImage() const { return GetPointer(VT_OFFIMAGE); } - const ResourceData* thumbImage() const { return GetPointer(VT_THUMBIMAGE); } - bool on() const { return GetField(VT_ON, 0) != 0; } - bool enabled() const { return GetField(VT_ENABLED, 0) != 0; } - bool Verify(flatbuffers::Verifier& verifier) const - { - return VerifyTableStart(verifier) && VerifyOffset(verifier, VT_NODEOPTIONS) && - verifier.VerifyTable(nodeOptions()) && VerifyOffset(verifier, VT_MASKIMAGE) && - verifier.VerifyTable(maskImage()) && VerifyOffset(verifier, VT_ONIMAGE) && - verifier.VerifyTable(onImage()) && VerifyOffset(verifier, VT_OFFIMAGE) && - verifier.VerifyTable(offImage()) && VerifyOffset(verifier, VT_THUMBIMAGE) && - verifier.VerifyTable(thumbImage()) && VerifyField(verifier, VT_ON) && - VerifyField(verifier, VT_ENABLED) && verifier.EndTable(); - } +struct ControlSwitchOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { + typedef ControlSwitchOptionsBuilder Builder; + enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { + VT_NODEOPTIONS = 4, + VT_MASKIMAGE = 6, + VT_ONIMAGE = 8, + VT_OFFIMAGE = 10, + VT_THUMBIMAGE = 12, + VT_ON = 14, + VT_ENABLED = 16 + }; + const flatbuffers::WidgetOptions *nodeOptions() const { + return GetPointer(VT_NODEOPTIONS); + } + const flatbuffers::ResourceData *maskImage() const { + return GetPointer(VT_MASKIMAGE); + } + const flatbuffers::ResourceData *onImage() const { + return GetPointer(VT_ONIMAGE); + } + const flatbuffers::ResourceData *offImage() const { + return GetPointer(VT_OFFIMAGE); + } + const flatbuffers::ResourceData *thumbImage() const { + return GetPointer(VT_THUMBIMAGE); + } + bool on() const { + return GetField(VT_ON, 0) != 0; + } + bool enabled() const { + return GetField(VT_ENABLED, 0) != 0; + } + bool Verify(flatbuffers::Verifier &verifier) const { + return VerifyTableStart(verifier) && + VerifyOffset(verifier, VT_NODEOPTIONS) && + verifier.VerifyTable(nodeOptions()) && + VerifyOffset(verifier, VT_MASKIMAGE) && + verifier.VerifyTable(maskImage()) && + VerifyOffset(verifier, VT_ONIMAGE) && + verifier.VerifyTable(onImage()) && + VerifyOffset(verifier, VT_OFFIMAGE) && + verifier.VerifyTable(offImage()) && + VerifyOffset(verifier, VT_THUMBIMAGE) && + verifier.VerifyTable(thumbImage()) && + VerifyField(verifier, VT_ON, 1) && + VerifyField(verifier, VT_ENABLED, 1) && + verifier.EndTable(); + } }; -struct ControlSwitchOptionsBuilder -{ - flatbuffers::FlatBufferBuilder& fbb_; - flatbuffers::uoffset_t start_; - void add_nodeOptions(flatbuffers::Offset nodeOptions) - { - fbb_.AddOffset(ControlSwitchOptions::VT_NODEOPTIONS, nodeOptions); - } - void add_maskImage(flatbuffers::Offset maskImage) - { - fbb_.AddOffset(ControlSwitchOptions::VT_MASKIMAGE, maskImage); - } - void add_onImage(flatbuffers::Offset onImage) - { - fbb_.AddOffset(ControlSwitchOptions::VT_ONIMAGE, onImage); - } - void add_offImage(flatbuffers::Offset offImage) - { - fbb_.AddOffset(ControlSwitchOptions::VT_OFFIMAGE, offImage); - } - void add_thumbImage(flatbuffers::Offset thumbImage) - { - fbb_.AddOffset(ControlSwitchOptions::VT_THUMBIMAGE, thumbImage); - } - void add_on(bool on) { fbb_.AddElement(ControlSwitchOptions::VT_ON, static_cast(on), 0); } - void add_enabled(bool enabled) - { - fbb_.AddElement(ControlSwitchOptions::VT_ENABLED, static_cast(enabled), 0); - } - explicit ControlSwitchOptionsBuilder(flatbuffers::FlatBufferBuilder& _fbb) : fbb_(_fbb) - { - start_ = fbb_.StartTable(); - } - ControlSwitchOptionsBuilder& operator=(const ControlSwitchOptionsBuilder&); - flatbuffers::Offset Finish() - { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset(end); - return o; - } +struct ControlSwitchOptionsBuilder { + typedef ControlSwitchOptions Table; + flatbuffers::FlatBufferBuilder &fbb_; + flatbuffers::uoffset_t start_; + void add_nodeOptions(flatbuffers::Offset nodeOptions) { + fbb_.AddOffset(ControlSwitchOptions::VT_NODEOPTIONS, nodeOptions); + } + void add_maskImage(flatbuffers::Offset maskImage) { + fbb_.AddOffset(ControlSwitchOptions::VT_MASKIMAGE, maskImage); + } + void add_onImage(flatbuffers::Offset onImage) { + fbb_.AddOffset(ControlSwitchOptions::VT_ONIMAGE, onImage); + } + void add_offImage(flatbuffers::Offset offImage) { + fbb_.AddOffset(ControlSwitchOptions::VT_OFFIMAGE, offImage); + } + void add_thumbImage(flatbuffers::Offset thumbImage) { + fbb_.AddOffset(ControlSwitchOptions::VT_THUMBIMAGE, thumbImage); + } + void add_on(bool on) { + fbb_.AddElement(ControlSwitchOptions::VT_ON, static_cast(on), 0); + } + void add_enabled(bool enabled) { + fbb_.AddElement(ControlSwitchOptions::VT_ENABLED, static_cast(enabled), 0); + } + explicit ControlSwitchOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) + : fbb_(_fbb) { + start_ = fbb_.StartTable(); + } + flatbuffers::Offset Finish() { + const auto end = fbb_.EndTable(start_); + auto o = flatbuffers::Offset(end); + return o; + } }; inline flatbuffers::Offset CreateControlSwitchOptions( - flatbuffers::FlatBufferBuilder& _fbb, - flatbuffers::Offset nodeOptions = 0, - flatbuffers::Offset maskImage = 0, - flatbuffers::Offset onImage = 0, - flatbuffers::Offset offImage = 0, - flatbuffers::Offset thumbImage = 0, - bool on = false, - bool enabled = false) -{ - ControlSwitchOptionsBuilder builder_(_fbb); - builder_.add_thumbImage(thumbImage); - builder_.add_offImage(offImage); - builder_.add_onImage(onImage); - builder_.add_maskImage(maskImage); - builder_.add_nodeOptions(nodeOptions); - builder_.add_enabled(enabled); - builder_.add_on(on); - return builder_.Finish(); + flatbuffers::FlatBufferBuilder &_fbb, + flatbuffers::Offset nodeOptions = 0, + flatbuffers::Offset maskImage = 0, + flatbuffers::Offset onImage = 0, + flatbuffers::Offset offImage = 0, + flatbuffers::Offset thumbImage = 0, + bool on = false, + bool enabled = false) { + ControlSwitchOptionsBuilder builder_(_fbb); + builder_.add_thumbImage(thumbImage); + builder_.add_offImage(offImage); + builder_.add_onImage(onImage); + builder_.add_maskImage(maskImage); + builder_.add_nodeOptions(nodeOptions); + builder_.add_enabled(enabled); + builder_.add_on(on); + return builder_.Finish(); } -struct LayerColorOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table -{ - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE - { - VT_NODEOPTIONS = 4 - }; - const WidgetOptions* nodeOptions() const { return GetPointer(VT_NODEOPTIONS); } - bool Verify(flatbuffers::Verifier& verifier) const - { - return VerifyTableStart(verifier) && VerifyOffset(verifier, VT_NODEOPTIONS) && - verifier.VerifyTable(nodeOptions()) && verifier.EndTable(); - } +struct LayerColorOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { + typedef LayerColorOptionsBuilder Builder; + enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { + VT_NODEOPTIONS = 4 + }; + const flatbuffers::WidgetOptions *nodeOptions() const { + return GetPointer(VT_NODEOPTIONS); + } + bool Verify(flatbuffers::Verifier &verifier) const { + return VerifyTableStart(verifier) && + VerifyOffset(verifier, VT_NODEOPTIONS) && + verifier.VerifyTable(nodeOptions()) && + verifier.EndTable(); + } }; -struct LayerColorOptionsBuilder -{ - flatbuffers::FlatBufferBuilder& fbb_; - flatbuffers::uoffset_t start_; - void add_nodeOptions(flatbuffers::Offset nodeOptions) - { - fbb_.AddOffset(LayerColorOptions::VT_NODEOPTIONS, nodeOptions); - } - explicit LayerColorOptionsBuilder(flatbuffers::FlatBufferBuilder& _fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } - LayerColorOptionsBuilder& operator=(const LayerColorOptionsBuilder&); - flatbuffers::Offset Finish() - { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset(end); - return o; - } +struct LayerColorOptionsBuilder { + typedef LayerColorOptions Table; + flatbuffers::FlatBufferBuilder &fbb_; + flatbuffers::uoffset_t start_; + void add_nodeOptions(flatbuffers::Offset nodeOptions) { + fbb_.AddOffset(LayerColorOptions::VT_NODEOPTIONS, nodeOptions); + } + explicit LayerColorOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) + : fbb_(_fbb) { + start_ = fbb_.StartTable(); + } + flatbuffers::Offset Finish() { + const auto end = fbb_.EndTable(start_); + auto o = flatbuffers::Offset(end); + return o; + } }; inline flatbuffers::Offset CreateLayerColorOptions( - flatbuffers::FlatBufferBuilder& _fbb, - flatbuffers::Offset nodeOptions = 0) -{ - LayerColorOptionsBuilder builder_(_fbb); - builder_.add_nodeOptions(nodeOptions); - return builder_.Finish(); + flatbuffers::FlatBufferBuilder &_fbb, + flatbuffers::Offset nodeOptions = 0) { + LayerColorOptionsBuilder builder_(_fbb); + builder_.add_nodeOptions(nodeOptions); + return builder_.Finish(); } -struct GameMapOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table -{ - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE - { - VT_NODEOPTIONS = 4, - VT_FILENAMEDATA = 6 - }; - const WidgetOptions* nodeOptions() const { return GetPointer(VT_NODEOPTIONS); } - const ResourceData* fileNameData() const { return GetPointer(VT_FILENAMEDATA); } - bool Verify(flatbuffers::Verifier& verifier) const - { - return VerifyTableStart(verifier) && VerifyOffset(verifier, VT_NODEOPTIONS) && - verifier.VerifyTable(nodeOptions()) && VerifyOffset(verifier, VT_FILENAMEDATA) && - verifier.VerifyTable(fileNameData()) && verifier.EndTable(); - } +struct GameMapOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { + typedef GameMapOptionsBuilder Builder; + enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { + VT_NODEOPTIONS = 4, + VT_FILENAMEDATA = 6 + }; + const flatbuffers::WidgetOptions *nodeOptions() const { + return GetPointer(VT_NODEOPTIONS); + } + const flatbuffers::ResourceData *fileNameData() const { + return GetPointer(VT_FILENAMEDATA); + } + bool Verify(flatbuffers::Verifier &verifier) const { + return VerifyTableStart(verifier) && + VerifyOffset(verifier, VT_NODEOPTIONS) && + verifier.VerifyTable(nodeOptions()) && + VerifyOffset(verifier, VT_FILENAMEDATA) && + verifier.VerifyTable(fileNameData()) && + verifier.EndTable(); + } }; -struct GameMapOptionsBuilder -{ - flatbuffers::FlatBufferBuilder& fbb_; - flatbuffers::uoffset_t start_; - void add_nodeOptions(flatbuffers::Offset nodeOptions) - { - fbb_.AddOffset(GameMapOptions::VT_NODEOPTIONS, nodeOptions); - } - void add_fileNameData(flatbuffers::Offset fileNameData) - { - fbb_.AddOffset(GameMapOptions::VT_FILENAMEDATA, fileNameData); - } - explicit GameMapOptionsBuilder(flatbuffers::FlatBufferBuilder& _fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } - GameMapOptionsBuilder& operator=(const GameMapOptionsBuilder&); - flatbuffers::Offset Finish() - { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset(end); - return o; - } +struct GameMapOptionsBuilder { + typedef GameMapOptions Table; + flatbuffers::FlatBufferBuilder &fbb_; + flatbuffers::uoffset_t start_; + void add_nodeOptions(flatbuffers::Offset nodeOptions) { + fbb_.AddOffset(GameMapOptions::VT_NODEOPTIONS, nodeOptions); + } + void add_fileNameData(flatbuffers::Offset fileNameData) { + fbb_.AddOffset(GameMapOptions::VT_FILENAMEDATA, fileNameData); + } + explicit GameMapOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) + : fbb_(_fbb) { + start_ = fbb_.StartTable(); + } + flatbuffers::Offset Finish() { + const auto end = fbb_.EndTable(start_); + auto o = flatbuffers::Offset(end); + return o; + } }; -inline flatbuffers::Offset CreateGameMapOptions(flatbuffers::FlatBufferBuilder& _fbb, - flatbuffers::Offset nodeOptions = 0, - flatbuffers::Offset fileNameData = 0) -{ - GameMapOptionsBuilder builder_(_fbb); - builder_.add_fileNameData(fileNameData); - builder_.add_nodeOptions(nodeOptions); - return builder_.Finish(); +inline flatbuffers::Offset CreateGameMapOptions( + flatbuffers::FlatBufferBuilder &_fbb, + flatbuffers::Offset nodeOptions = 0, + flatbuffers::Offset fileNameData = 0) { + GameMapOptionsBuilder builder_(_fbb); + builder_.add_fileNameData(fileNameData); + builder_.add_nodeOptions(nodeOptions); + return builder_.Finish(); } -struct ButtonOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table -{ - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE - { - VT_WIDGETOPTIONS = 4, - VT_NORMALDATA = 6, - VT_PRESSEDDATA = 8, - VT_DISABLEDDATA = 10, - VT_FONTRESOURCE = 12, - VT_TEXT = 14, - VT_FONTNAME = 16, - VT_FONTSIZE = 18, - VT_TEXTCOLOR = 20, - VT_CAPINSETS = 22, - VT_SCALE9SIZE = 24, - VT_SCALE9ENABLED = 26, - VT_DISPLAYSTATE = 28, - VT_OUTLINEENABLED = 30, - VT_OUTLINECOLOR = 32, - VT_OUTLINESIZE = 34, - VT_SHADOWENABLED = 36, - VT_SHADOWCOLOR = 38, - VT_SHADOWOFFSETX = 40, - VT_SHADOWOFFSETY = 42, - VT_SHADOWBLURRADIUS = 44, - VT_ISLOCALIZED = 46, - VT_GLOWENABLED = 48, - VT_GLOWCOLOR = 50, - VT_BOLDENABLED = 52, - VT_UNDERLINEENABLED = 54, - VT_ITALICSENABLED = 56, - VT_STRIKETHROUGHENABLED = 58 - }; - const WidgetOptions* widgetOptions() const { return GetPointer(VT_WIDGETOPTIONS); } - const ResourceData* normalData() const { return GetPointer(VT_NORMALDATA); } - const ResourceData* pressedData() const { return GetPointer(VT_PRESSEDDATA); } - const ResourceData* disabledData() const { return GetPointer(VT_DISABLEDDATA); } - const ResourceData* fontResource() const { return GetPointer(VT_FONTRESOURCE); } - const flatbuffers::String* text() const { return GetPointer(VT_TEXT); } - const flatbuffers::String* fontName() const { return GetPointer(VT_FONTNAME); } - int32_t fontSize() const { return GetField(VT_FONTSIZE, 0); } - const Color* textColor() const { return GetStruct(VT_TEXTCOLOR); } - const CapInsets* capInsets() const { return GetStruct(VT_CAPINSETS); } - const FlatSize* scale9Size() const { return GetStruct(VT_SCALE9SIZE); } - bool scale9Enabled() const { return GetField(VT_SCALE9ENABLED, 0) != 0; } - bool displaystate() const { return GetField(VT_DISPLAYSTATE, 1) != 0; } - bool outlineEnabled() const { return GetField(VT_OUTLINEENABLED, 0) != 0; } - const Color* outlineColor() const { return GetStruct(VT_OUTLINECOLOR); } - int32_t outlineSize() const { return GetField(VT_OUTLINESIZE, 1); } - bool shadowEnabled() const { return GetField(VT_SHADOWENABLED, 0) != 0; } - const Color* shadowColor() const { return GetStruct(VT_SHADOWCOLOR); } - float shadowOffsetX() const { return GetField(VT_SHADOWOFFSETX, 2.0f); } - float shadowOffsetY() const { return GetField(VT_SHADOWOFFSETY, -2.0f); } - int32_t shadowBlurRadius() const { return GetField(VT_SHADOWBLURRADIUS, 0); } - bool isLocalized() const { return GetField(VT_ISLOCALIZED, 0) != 0; } - bool glowEnabled() const { return GetField(VT_GLOWENABLED, 0) != 0; } - const Color* glowColor() const { return GetStruct(VT_GLOWCOLOR); } - bool boldEnabled() const { return GetField(VT_BOLDENABLED, 0) != 0; } - bool underlineEnabled() const { return GetField(VT_UNDERLINEENABLED, 0) != 0; } - bool italicsEnabled() const { return GetField(VT_ITALICSENABLED, 0) != 0; } - bool strikethroughEnabled() const { return GetField(VT_STRIKETHROUGHENABLED, 0) != 0; } - bool Verify(flatbuffers::Verifier& verifier) const - { - return VerifyTableStart(verifier) && VerifyOffset(verifier, VT_WIDGETOPTIONS) && - verifier.VerifyTable(widgetOptions()) && VerifyOffset(verifier, VT_NORMALDATA) && - verifier.VerifyTable(normalData()) && VerifyOffset(verifier, VT_PRESSEDDATA) && - verifier.VerifyTable(pressedData()) && VerifyOffset(verifier, VT_DISABLEDDATA) && - verifier.VerifyTable(disabledData()) && VerifyOffset(verifier, VT_FONTRESOURCE) && - verifier.VerifyTable(fontResource()) && VerifyOffset(verifier, VT_TEXT) && - verifier.VerifyString(text()) && VerifyOffset(verifier, VT_FONTNAME) && - verifier.VerifyString(fontName()) && VerifyField(verifier, VT_FONTSIZE) && - VerifyField(verifier, VT_TEXTCOLOR) && VerifyField(verifier, VT_CAPINSETS) && - VerifyField(verifier, VT_SCALE9SIZE) && VerifyField(verifier, VT_SCALE9ENABLED) && - VerifyField(verifier, VT_DISPLAYSTATE) && VerifyField(verifier, VT_OUTLINEENABLED) && - VerifyField(verifier, VT_OUTLINECOLOR) && VerifyField(verifier, VT_OUTLINESIZE) && - VerifyField(verifier, VT_SHADOWENABLED) && VerifyField(verifier, VT_SHADOWCOLOR) && - VerifyField(verifier, VT_SHADOWOFFSETX) && VerifyField(verifier, VT_SHADOWOFFSETY) && - VerifyField(verifier, VT_SHADOWBLURRADIUS) && VerifyField(verifier, VT_ISLOCALIZED) && - VerifyField(verifier, VT_GLOWENABLED) && VerifyField(verifier, VT_GLOWCOLOR) && - VerifyField(verifier, VT_BOLDENABLED) && VerifyField(verifier, VT_UNDERLINEENABLED) && - VerifyField(verifier, VT_ITALICSENABLED) && - VerifyField(verifier, VT_STRIKETHROUGHENABLED) && verifier.EndTable(); - } +struct ButtonOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { + typedef ButtonOptionsBuilder Builder; + enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { + VT_WIDGETOPTIONS = 4, + VT_NORMALDATA = 6, + VT_PRESSEDDATA = 8, + VT_DISABLEDDATA = 10, + VT_FONTRESOURCE = 12, + VT_TEXT = 14, + VT_FONTNAME = 16, + VT_FONTSIZE = 18, + VT_TEXTCOLOR = 20, + VT_CAPINSETS = 22, + VT_SCALE9SIZE = 24, + VT_SCALE9ENABLED = 26, + VT_DISPLAYSTATE = 28, + VT_OUTLINEENABLED = 30, + VT_OUTLINECOLOR = 32, + VT_OUTLINESIZE = 34, + VT_SHADOWENABLED = 36, + VT_SHADOWCOLOR = 38, + VT_SHADOWOFFSETX = 40, + VT_SHADOWOFFSETY = 42, + VT_SHADOWBLURRADIUS = 44, + VT_ISLOCALIZED = 46, + VT_GLOWENABLED = 48, + VT_GLOWCOLOR = 50, + VT_BOLDENABLED = 52, + VT_UNDERLINEENABLED = 54, + VT_ITALICSENABLED = 56, + VT_STRIKETHROUGHENABLED = 58 + }; + const flatbuffers::WidgetOptions *widgetOptions() const { + return GetPointer(VT_WIDGETOPTIONS); + } + const flatbuffers::ResourceData *normalData() const { + return GetPointer(VT_NORMALDATA); + } + const flatbuffers::ResourceData *pressedData() const { + return GetPointer(VT_PRESSEDDATA); + } + const flatbuffers::ResourceData *disabledData() const { + return GetPointer(VT_DISABLEDDATA); + } + const flatbuffers::ResourceData *fontResource() const { + return GetPointer(VT_FONTRESOURCE); + } + const flatbuffers::String *text() const { + return GetPointer(VT_TEXT); + } + const flatbuffers::String *fontName() const { + return GetPointer(VT_FONTNAME); + } + int32_t fontSize() const { + return GetField(VT_FONTSIZE, 0); + } + const flatbuffers::Color *textColor() const { + return GetStruct(VT_TEXTCOLOR); + } + const flatbuffers::CapInsets *capInsets() const { + return GetStruct(VT_CAPINSETS); + } + const flatbuffers::FlatSize *scale9Size() const { + return GetStruct(VT_SCALE9SIZE); + } + bool scale9Enabled() const { + return GetField(VT_SCALE9ENABLED, 0) != 0; + } + bool displaystate() const { + return GetField(VT_DISPLAYSTATE, 1) != 0; + } + bool outlineEnabled() const { + return GetField(VT_OUTLINEENABLED, 0) != 0; + } + const flatbuffers::Color *outlineColor() const { + return GetStruct(VT_OUTLINECOLOR); + } + int32_t outlineSize() const { + return GetField(VT_OUTLINESIZE, 1); + } + bool shadowEnabled() const { + return GetField(VT_SHADOWENABLED, 0) != 0; + } + const flatbuffers::Color *shadowColor() const { + return GetStruct(VT_SHADOWCOLOR); + } + float shadowOffsetX() const { + return GetField(VT_SHADOWOFFSETX, 2.0f); + } + float shadowOffsetY() const { + return GetField(VT_SHADOWOFFSETY, -2.0f); + } + int32_t shadowBlurRadius() const { + return GetField(VT_SHADOWBLURRADIUS, 0); + } + bool isLocalized() const { + return GetField(VT_ISLOCALIZED, 0) != 0; + } + bool glowEnabled() const { + return GetField(VT_GLOWENABLED, 0) != 0; + } + const flatbuffers::Color *glowColor() const { + return GetStruct(VT_GLOWCOLOR); + } + bool boldEnabled() const { + return GetField(VT_BOLDENABLED, 0) != 0; + } + bool underlineEnabled() const { + return GetField(VT_UNDERLINEENABLED, 0) != 0; + } + bool italicsEnabled() const { + return GetField(VT_ITALICSENABLED, 0) != 0; + } + bool strikethroughEnabled() const { + return GetField(VT_STRIKETHROUGHENABLED, 0) != 0; + } + bool Verify(flatbuffers::Verifier &verifier) const { + return VerifyTableStart(verifier) && + VerifyOffset(verifier, VT_WIDGETOPTIONS) && + verifier.VerifyTable(widgetOptions()) && + VerifyOffset(verifier, VT_NORMALDATA) && + verifier.VerifyTable(normalData()) && + VerifyOffset(verifier, VT_PRESSEDDATA) && + verifier.VerifyTable(pressedData()) && + VerifyOffset(verifier, VT_DISABLEDDATA) && + verifier.VerifyTable(disabledData()) && + VerifyOffset(verifier, VT_FONTRESOURCE) && + verifier.VerifyTable(fontResource()) && + VerifyOffset(verifier, VT_TEXT) && + verifier.VerifyString(text()) && + VerifyOffset(verifier, VT_FONTNAME) && + verifier.VerifyString(fontName()) && + VerifyField(verifier, VT_FONTSIZE, 4) && + VerifyField(verifier, VT_TEXTCOLOR, 1) && + VerifyField(verifier, VT_CAPINSETS, 4) && + VerifyField(verifier, VT_SCALE9SIZE, 4) && + VerifyField(verifier, VT_SCALE9ENABLED, 1) && + VerifyField(verifier, VT_DISPLAYSTATE, 1) && + VerifyField(verifier, VT_OUTLINEENABLED, 1) && + VerifyField(verifier, VT_OUTLINECOLOR, 1) && + VerifyField(verifier, VT_OUTLINESIZE, 4) && + VerifyField(verifier, VT_SHADOWENABLED, 1) && + VerifyField(verifier, VT_SHADOWCOLOR, 1) && + VerifyField(verifier, VT_SHADOWOFFSETX, 4) && + VerifyField(verifier, VT_SHADOWOFFSETY, 4) && + VerifyField(verifier, VT_SHADOWBLURRADIUS, 4) && + VerifyField(verifier, VT_ISLOCALIZED, 1) && + VerifyField(verifier, VT_GLOWENABLED, 1) && + VerifyField(verifier, VT_GLOWCOLOR, 1) && + VerifyField(verifier, VT_BOLDENABLED, 1) && + VerifyField(verifier, VT_UNDERLINEENABLED, 1) && + VerifyField(verifier, VT_ITALICSENABLED, 1) && + VerifyField(verifier, VT_STRIKETHROUGHENABLED, 1) && + verifier.EndTable(); + } }; -struct ButtonOptionsBuilder -{ - flatbuffers::FlatBufferBuilder& fbb_; - flatbuffers::uoffset_t start_; - void add_widgetOptions(flatbuffers::Offset widgetOptions) - { - fbb_.AddOffset(ButtonOptions::VT_WIDGETOPTIONS, widgetOptions); - } - void add_normalData(flatbuffers::Offset normalData) - { - fbb_.AddOffset(ButtonOptions::VT_NORMALDATA, normalData); - } - void add_pressedData(flatbuffers::Offset pressedData) - { - fbb_.AddOffset(ButtonOptions::VT_PRESSEDDATA, pressedData); - } - void add_disabledData(flatbuffers::Offset disabledData) - { - fbb_.AddOffset(ButtonOptions::VT_DISABLEDDATA, disabledData); - } - void add_fontResource(flatbuffers::Offset fontResource) - { - fbb_.AddOffset(ButtonOptions::VT_FONTRESOURCE, fontResource); - } - void add_text(flatbuffers::Offset text) { fbb_.AddOffset(ButtonOptions::VT_TEXT, text); } - void add_fontName(flatbuffers::Offset fontName) - { - fbb_.AddOffset(ButtonOptions::VT_FONTNAME, fontName); - } - void add_fontSize(int32_t fontSize) { fbb_.AddElement(ButtonOptions::VT_FONTSIZE, fontSize, 0); } - void add_textColor(const Color* textColor) { fbb_.AddStruct(ButtonOptions::VT_TEXTCOLOR, textColor); } - void add_capInsets(const CapInsets* capInsets) { fbb_.AddStruct(ButtonOptions::VT_CAPINSETS, capInsets); } - void add_scale9Size(const FlatSize* scale9Size) { fbb_.AddStruct(ButtonOptions::VT_SCALE9SIZE, scale9Size); } - void add_scale9Enabled(bool scale9Enabled) - { - fbb_.AddElement(ButtonOptions::VT_SCALE9ENABLED, static_cast(scale9Enabled), 0); - } - void add_displaystate(bool displaystate) - { - fbb_.AddElement(ButtonOptions::VT_DISPLAYSTATE, static_cast(displaystate), 1); - } - void add_outlineEnabled(bool outlineEnabled) - { - fbb_.AddElement(ButtonOptions::VT_OUTLINEENABLED, static_cast(outlineEnabled), 0); - } - void add_outlineColor(const Color* outlineColor) { fbb_.AddStruct(ButtonOptions::VT_OUTLINECOLOR, outlineColor); } - void add_outlineSize(int32_t outlineSize) - { - fbb_.AddElement(ButtonOptions::VT_OUTLINESIZE, outlineSize, 1); - } - void add_shadowEnabled(bool shadowEnabled) - { - fbb_.AddElement(ButtonOptions::VT_SHADOWENABLED, static_cast(shadowEnabled), 0); - } - void add_shadowColor(const Color* shadowColor) { fbb_.AddStruct(ButtonOptions::VT_SHADOWCOLOR, shadowColor); } - void add_shadowOffsetX(float shadowOffsetX) - { - fbb_.AddElement(ButtonOptions::VT_SHADOWOFFSETX, shadowOffsetX, 2.0f); - } - void add_shadowOffsetY(float shadowOffsetY) - { - fbb_.AddElement(ButtonOptions::VT_SHADOWOFFSETY, shadowOffsetY, -2.0f); - } - void add_shadowBlurRadius(int32_t shadowBlurRadius) - { - fbb_.AddElement(ButtonOptions::VT_SHADOWBLURRADIUS, shadowBlurRadius, 0); - } - void add_isLocalized(bool isLocalized) - { - fbb_.AddElement(ButtonOptions::VT_ISLOCALIZED, static_cast(isLocalized), 0); - } - void add_glowEnabled(bool glowEnabled) - { - fbb_.AddElement(ButtonOptions::VT_GLOWENABLED, static_cast(glowEnabled), 0); - } - void add_glowColor(const Color* glowColor) { fbb_.AddStruct(ButtonOptions::VT_GLOWCOLOR, glowColor); } - void add_boldEnabled(bool boldEnabled) - { - fbb_.AddElement(ButtonOptions::VT_BOLDENABLED, static_cast(boldEnabled), 0); - } - void add_underlineEnabled(bool underlineEnabled) - { - fbb_.AddElement(ButtonOptions::VT_UNDERLINEENABLED, static_cast(underlineEnabled), 0); - } - void add_italicsEnabled(bool italicsEnabled) - { - fbb_.AddElement(ButtonOptions::VT_ITALICSENABLED, static_cast(italicsEnabled), 0); - } - void add_strikethroughEnabled(bool strikethroughEnabled) - { - fbb_.AddElement(ButtonOptions::VT_STRIKETHROUGHENABLED, static_cast(strikethroughEnabled), 0); - } - explicit ButtonOptionsBuilder(flatbuffers::FlatBufferBuilder& _fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } - ButtonOptionsBuilder& operator=(const ButtonOptionsBuilder&); - flatbuffers::Offset Finish() - { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset(end); - return o; - } +struct ButtonOptionsBuilder { + typedef ButtonOptions Table; + flatbuffers::FlatBufferBuilder &fbb_; + flatbuffers::uoffset_t start_; + void add_widgetOptions(flatbuffers::Offset widgetOptions) { + fbb_.AddOffset(ButtonOptions::VT_WIDGETOPTIONS, widgetOptions); + } + void add_normalData(flatbuffers::Offset normalData) { + fbb_.AddOffset(ButtonOptions::VT_NORMALDATA, normalData); + } + void add_pressedData(flatbuffers::Offset pressedData) { + fbb_.AddOffset(ButtonOptions::VT_PRESSEDDATA, pressedData); + } + void add_disabledData(flatbuffers::Offset disabledData) { + fbb_.AddOffset(ButtonOptions::VT_DISABLEDDATA, disabledData); + } + void add_fontResource(flatbuffers::Offset fontResource) { + fbb_.AddOffset(ButtonOptions::VT_FONTRESOURCE, fontResource); + } + void add_text(flatbuffers::Offset text) { + fbb_.AddOffset(ButtonOptions::VT_TEXT, text); + } + void add_fontName(flatbuffers::Offset fontName) { + fbb_.AddOffset(ButtonOptions::VT_FONTNAME, fontName); + } + void add_fontSize(int32_t fontSize) { + fbb_.AddElement(ButtonOptions::VT_FONTSIZE, fontSize, 0); + } + void add_textColor(const flatbuffers::Color *textColor) { + fbb_.AddStruct(ButtonOptions::VT_TEXTCOLOR, textColor); + } + void add_capInsets(const flatbuffers::CapInsets *capInsets) { + fbb_.AddStruct(ButtonOptions::VT_CAPINSETS, capInsets); + } + void add_scale9Size(const flatbuffers::FlatSize *scale9Size) { + fbb_.AddStruct(ButtonOptions::VT_SCALE9SIZE, scale9Size); + } + void add_scale9Enabled(bool scale9Enabled) { + fbb_.AddElement(ButtonOptions::VT_SCALE9ENABLED, static_cast(scale9Enabled), 0); + } + void add_displaystate(bool displaystate) { + fbb_.AddElement(ButtonOptions::VT_DISPLAYSTATE, static_cast(displaystate), 1); + } + void add_outlineEnabled(bool outlineEnabled) { + fbb_.AddElement(ButtonOptions::VT_OUTLINEENABLED, static_cast(outlineEnabled), 0); + } + void add_outlineColor(const flatbuffers::Color *outlineColor) { + fbb_.AddStruct(ButtonOptions::VT_OUTLINECOLOR, outlineColor); + } + void add_outlineSize(int32_t outlineSize) { + fbb_.AddElement(ButtonOptions::VT_OUTLINESIZE, outlineSize, 1); + } + void add_shadowEnabled(bool shadowEnabled) { + fbb_.AddElement(ButtonOptions::VT_SHADOWENABLED, static_cast(shadowEnabled), 0); + } + void add_shadowColor(const flatbuffers::Color *shadowColor) { + fbb_.AddStruct(ButtonOptions::VT_SHADOWCOLOR, shadowColor); + } + void add_shadowOffsetX(float shadowOffsetX) { + fbb_.AddElement(ButtonOptions::VT_SHADOWOFFSETX, shadowOffsetX, 2.0f); + } + void add_shadowOffsetY(float shadowOffsetY) { + fbb_.AddElement(ButtonOptions::VT_SHADOWOFFSETY, shadowOffsetY, -2.0f); + } + void add_shadowBlurRadius(int32_t shadowBlurRadius) { + fbb_.AddElement(ButtonOptions::VT_SHADOWBLURRADIUS, shadowBlurRadius, 0); + } + void add_isLocalized(bool isLocalized) { + fbb_.AddElement(ButtonOptions::VT_ISLOCALIZED, static_cast(isLocalized), 0); + } + void add_glowEnabled(bool glowEnabled) { + fbb_.AddElement(ButtonOptions::VT_GLOWENABLED, static_cast(glowEnabled), 0); + } + void add_glowColor(const flatbuffers::Color *glowColor) { + fbb_.AddStruct(ButtonOptions::VT_GLOWCOLOR, glowColor); + } + void add_boldEnabled(bool boldEnabled) { + fbb_.AddElement(ButtonOptions::VT_BOLDENABLED, static_cast(boldEnabled), 0); + } + void add_underlineEnabled(bool underlineEnabled) { + fbb_.AddElement(ButtonOptions::VT_UNDERLINEENABLED, static_cast(underlineEnabled), 0); + } + void add_italicsEnabled(bool italicsEnabled) { + fbb_.AddElement(ButtonOptions::VT_ITALICSENABLED, static_cast(italicsEnabled), 0); + } + void add_strikethroughEnabled(bool strikethroughEnabled) { + fbb_.AddElement(ButtonOptions::VT_STRIKETHROUGHENABLED, static_cast(strikethroughEnabled), 0); + } + explicit ButtonOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) + : fbb_(_fbb) { + start_ = fbb_.StartTable(); + } + flatbuffers::Offset Finish() { + const auto end = fbb_.EndTable(start_); + auto o = flatbuffers::Offset(end); + return o; + } }; -inline flatbuffers::Offset CreateButtonOptions(flatbuffers::FlatBufferBuilder& _fbb, - flatbuffers::Offset widgetOptions = 0, - flatbuffers::Offset normalData = 0, - flatbuffers::Offset pressedData = 0, - flatbuffers::Offset disabledData = 0, - flatbuffers::Offset fontResource = 0, - flatbuffers::Offset text = 0, - flatbuffers::Offset fontName = 0, - int32_t fontSize = 0, - const Color* textColor = 0, - const CapInsets* capInsets = 0, - const FlatSize* scale9Size = 0, - bool scale9Enabled = false, - bool displaystate = true, - bool outlineEnabled = false, - const Color* outlineColor = 0, - int32_t outlineSize = 1, - bool shadowEnabled = false, - const Color* shadowColor = 0, - float shadowOffsetX = 2.0f, - float shadowOffsetY = -2.0f, - int32_t shadowBlurRadius = 0, - bool isLocalized = false, - bool glowEnabled = false, - const Color* glowColor = 0, - bool boldEnabled = false, - bool underlineEnabled = false, - bool italicsEnabled = false, - bool strikethroughEnabled = false) -{ - ButtonOptionsBuilder builder_(_fbb); - builder_.add_glowColor(glowColor); - builder_.add_shadowBlurRadius(shadowBlurRadius); - builder_.add_shadowOffsetY(shadowOffsetY); - builder_.add_shadowOffsetX(shadowOffsetX); - builder_.add_shadowColor(shadowColor); - builder_.add_outlineSize(outlineSize); - builder_.add_outlineColor(outlineColor); - builder_.add_scale9Size(scale9Size); - builder_.add_capInsets(capInsets); - builder_.add_textColor(textColor); - builder_.add_fontSize(fontSize); - builder_.add_fontName(fontName); - builder_.add_text(text); - builder_.add_fontResource(fontResource); - builder_.add_disabledData(disabledData); - builder_.add_pressedData(pressedData); - builder_.add_normalData(normalData); - builder_.add_widgetOptions(widgetOptions); - builder_.add_strikethroughEnabled(strikethroughEnabled); - builder_.add_italicsEnabled(italicsEnabled); - builder_.add_underlineEnabled(underlineEnabled); - builder_.add_boldEnabled(boldEnabled); - builder_.add_glowEnabled(glowEnabled); - builder_.add_isLocalized(isLocalized); - builder_.add_shadowEnabled(shadowEnabled); - builder_.add_outlineEnabled(outlineEnabled); - builder_.add_displaystate(displaystate); - builder_.add_scale9Enabled(scale9Enabled); - return builder_.Finish(); +inline flatbuffers::Offset CreateButtonOptions( + flatbuffers::FlatBufferBuilder &_fbb, + flatbuffers::Offset widgetOptions = 0, + flatbuffers::Offset normalData = 0, + flatbuffers::Offset pressedData = 0, + flatbuffers::Offset disabledData = 0, + flatbuffers::Offset fontResource = 0, + flatbuffers::Offset text = 0, + flatbuffers::Offset fontName = 0, + int32_t fontSize = 0, + const flatbuffers::Color *textColor = nullptr, + const flatbuffers::CapInsets *capInsets = nullptr, + const flatbuffers::FlatSize *scale9Size = nullptr, + bool scale9Enabled = false, + bool displaystate = true, + bool outlineEnabled = false, + const flatbuffers::Color *outlineColor = nullptr, + int32_t outlineSize = 1, + bool shadowEnabled = false, + const flatbuffers::Color *shadowColor = nullptr, + float shadowOffsetX = 2.0f, + float shadowOffsetY = -2.0f, + int32_t shadowBlurRadius = 0, + bool isLocalized = false, + bool glowEnabled = false, + const flatbuffers::Color *glowColor = nullptr, + bool boldEnabled = false, + bool underlineEnabled = false, + bool italicsEnabled = false, + bool strikethroughEnabled = false) { + ButtonOptionsBuilder builder_(_fbb); + builder_.add_glowColor(glowColor); + builder_.add_shadowBlurRadius(shadowBlurRadius); + builder_.add_shadowOffsetY(shadowOffsetY); + builder_.add_shadowOffsetX(shadowOffsetX); + builder_.add_shadowColor(shadowColor); + builder_.add_outlineSize(outlineSize); + builder_.add_outlineColor(outlineColor); + builder_.add_scale9Size(scale9Size); + builder_.add_capInsets(capInsets); + builder_.add_textColor(textColor); + builder_.add_fontSize(fontSize); + builder_.add_fontName(fontName); + builder_.add_text(text); + builder_.add_fontResource(fontResource); + builder_.add_disabledData(disabledData); + builder_.add_pressedData(pressedData); + builder_.add_normalData(normalData); + builder_.add_widgetOptions(widgetOptions); + builder_.add_strikethroughEnabled(strikethroughEnabled); + builder_.add_italicsEnabled(italicsEnabled); + builder_.add_underlineEnabled(underlineEnabled); + builder_.add_boldEnabled(boldEnabled); + builder_.add_glowEnabled(glowEnabled); + builder_.add_isLocalized(isLocalized); + builder_.add_shadowEnabled(shadowEnabled); + builder_.add_outlineEnabled(outlineEnabled); + builder_.add_displaystate(displaystate); + builder_.add_scale9Enabled(scale9Enabled); + return builder_.Finish(); } inline flatbuffers::Offset CreateButtonOptionsDirect( - flatbuffers::FlatBufferBuilder& _fbb, - flatbuffers::Offset widgetOptions = 0, - flatbuffers::Offset normalData = 0, - flatbuffers::Offset pressedData = 0, - flatbuffers::Offset disabledData = 0, - flatbuffers::Offset fontResource = 0, - const char* text = nullptr, - const char* fontName = nullptr, - int32_t fontSize = 0, - const Color* textColor = 0, - const CapInsets* capInsets = 0, - const FlatSize* scale9Size = 0, - bool scale9Enabled = false, - bool displaystate = true, - bool outlineEnabled = false, - const Color* outlineColor = 0, - int32_t outlineSize = 1, - bool shadowEnabled = false, - const Color* shadowColor = 0, - float shadowOffsetX = 2.0f, - float shadowOffsetY = -2.0f, - int32_t shadowBlurRadius = 0, - bool isLocalized = false, - bool glowEnabled = false, - const Color* glowColor = 0, - bool boldEnabled = false, - bool underlineEnabled = false, - bool italicsEnabled = false, - bool strikethroughEnabled = false) -{ - auto text__ = text ? _fbb.CreateString(text) : 0; - auto fontName__ = fontName ? _fbb.CreateString(fontName) : 0; - return flatbuffers::CreateButtonOptions( - _fbb, widgetOptions, normalData, pressedData, disabledData, fontResource, text__, fontName__, fontSize, - textColor, capInsets, scale9Size, scale9Enabled, displaystate, outlineEnabled, outlineColor, outlineSize, - shadowEnabled, shadowColor, shadowOffsetX, shadowOffsetY, shadowBlurRadius, isLocalized, glowEnabled, glowColor, - boldEnabled, underlineEnabled, italicsEnabled, strikethroughEnabled); + flatbuffers::FlatBufferBuilder &_fbb, + flatbuffers::Offset widgetOptions = 0, + flatbuffers::Offset normalData = 0, + flatbuffers::Offset pressedData = 0, + flatbuffers::Offset disabledData = 0, + flatbuffers::Offset fontResource = 0, + const char *text = nullptr, + const char *fontName = nullptr, + int32_t fontSize = 0, + const flatbuffers::Color *textColor = nullptr, + const flatbuffers::CapInsets *capInsets = nullptr, + const flatbuffers::FlatSize *scale9Size = nullptr, + bool scale9Enabled = false, + bool displaystate = true, + bool outlineEnabled = false, + const flatbuffers::Color *outlineColor = nullptr, + int32_t outlineSize = 1, + bool shadowEnabled = false, + const flatbuffers::Color *shadowColor = nullptr, + float shadowOffsetX = 2.0f, + float shadowOffsetY = -2.0f, + int32_t shadowBlurRadius = 0, + bool isLocalized = false, + bool glowEnabled = false, + const flatbuffers::Color *glowColor = nullptr, + bool boldEnabled = false, + bool underlineEnabled = false, + bool italicsEnabled = false, + bool strikethroughEnabled = false) { + auto text__ = text ? _fbb.CreateString(text) : 0; + auto fontName__ = fontName ? _fbb.CreateString(fontName) : 0; + return flatbuffers::CreateButtonOptions( + _fbb, + widgetOptions, + normalData, + pressedData, + disabledData, + fontResource, + text__, + fontName__, + fontSize, + textColor, + capInsets, + scale9Size, + scale9Enabled, + displaystate, + outlineEnabled, + outlineColor, + outlineSize, + shadowEnabled, + shadowColor, + shadowOffsetX, + shadowOffsetY, + shadowBlurRadius, + isLocalized, + glowEnabled, + glowColor, + boldEnabled, + underlineEnabled, + italicsEnabled, + strikethroughEnabled); } -struct CheckBoxOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table -{ - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE - { - VT_WIDGETOPTIONS = 4, - VT_BACKGROUNDBOXDATA = 6, - VT_BACKGROUNDBOXSELECTEDDATA = 8, - VT_FRONTCROSSDATA = 10, - VT_BACKGROUNDBOXDISABLEDDATA = 12, - VT_FRONTCROSSDISABLEDDATA = 14, - VT_SELECTEDSTATE = 16, - VT_DISPLAYSTATE = 18 - }; - const WidgetOptions* widgetOptions() const { return GetPointer(VT_WIDGETOPTIONS); } - const ResourceData* backGroundBoxData() const { return GetPointer(VT_BACKGROUNDBOXDATA); } - const ResourceData* backGroundBoxSelectedData() const - { - return GetPointer(VT_BACKGROUNDBOXSELECTEDDATA); - } - const ResourceData* frontCrossData() const { return GetPointer(VT_FRONTCROSSDATA); } - const ResourceData* backGroundBoxDisabledData() const - { - return GetPointer(VT_BACKGROUNDBOXDISABLEDDATA); - } - const ResourceData* frontCrossDisabledData() const - { - return GetPointer(VT_FRONTCROSSDISABLEDDATA); - } - bool selectedState() const { return GetField(VT_SELECTEDSTATE, 1) != 0; } - bool displaystate() const { return GetField(VT_DISPLAYSTATE, 1) != 0; } - bool Verify(flatbuffers::Verifier& verifier) const - { - return VerifyTableStart(verifier) && VerifyOffset(verifier, VT_WIDGETOPTIONS) && - verifier.VerifyTable(widgetOptions()) && VerifyOffset(verifier, VT_BACKGROUNDBOXDATA) && - verifier.VerifyTable(backGroundBoxData()) && VerifyOffset(verifier, VT_BACKGROUNDBOXSELECTEDDATA) && - verifier.VerifyTable(backGroundBoxSelectedData()) && VerifyOffset(verifier, VT_FRONTCROSSDATA) && - verifier.VerifyTable(frontCrossData()) && VerifyOffset(verifier, VT_BACKGROUNDBOXDISABLEDDATA) && - verifier.VerifyTable(backGroundBoxDisabledData()) && VerifyOffset(verifier, VT_FRONTCROSSDISABLEDDATA) && - verifier.VerifyTable(frontCrossDisabledData()) && VerifyField(verifier, VT_SELECTEDSTATE) && - VerifyField(verifier, VT_DISPLAYSTATE) && verifier.EndTable(); - } +struct CheckBoxOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { + typedef CheckBoxOptionsBuilder Builder; + enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { + VT_WIDGETOPTIONS = 4, + VT_BACKGROUNDBOXDATA = 6, + VT_BACKGROUNDBOXSELECTEDDATA = 8, + VT_FRONTCROSSDATA = 10, + VT_BACKGROUNDBOXDISABLEDDATA = 12, + VT_FRONTCROSSDISABLEDDATA = 14, + VT_SELECTEDSTATE = 16, + VT_DISPLAYSTATE = 18 + }; + const flatbuffers::WidgetOptions *widgetOptions() const { + return GetPointer(VT_WIDGETOPTIONS); + } + const flatbuffers::ResourceData *backGroundBoxData() const { + return GetPointer(VT_BACKGROUNDBOXDATA); + } + const flatbuffers::ResourceData *backGroundBoxSelectedData() const { + return GetPointer(VT_BACKGROUNDBOXSELECTEDDATA); + } + const flatbuffers::ResourceData *frontCrossData() const { + return GetPointer(VT_FRONTCROSSDATA); + } + const flatbuffers::ResourceData *backGroundBoxDisabledData() const { + return GetPointer(VT_BACKGROUNDBOXDISABLEDDATA); + } + const flatbuffers::ResourceData *frontCrossDisabledData() const { + return GetPointer(VT_FRONTCROSSDISABLEDDATA); + } + bool selectedState() const { + return GetField(VT_SELECTEDSTATE, 1) != 0; + } + bool displaystate() const { + return GetField(VT_DISPLAYSTATE, 1) != 0; + } + bool Verify(flatbuffers::Verifier &verifier) const { + return VerifyTableStart(verifier) && + VerifyOffset(verifier, VT_WIDGETOPTIONS) && + verifier.VerifyTable(widgetOptions()) && + VerifyOffset(verifier, VT_BACKGROUNDBOXDATA) && + verifier.VerifyTable(backGroundBoxData()) && + VerifyOffset(verifier, VT_BACKGROUNDBOXSELECTEDDATA) && + verifier.VerifyTable(backGroundBoxSelectedData()) && + VerifyOffset(verifier, VT_FRONTCROSSDATA) && + verifier.VerifyTable(frontCrossData()) && + VerifyOffset(verifier, VT_BACKGROUNDBOXDISABLEDDATA) && + verifier.VerifyTable(backGroundBoxDisabledData()) && + VerifyOffset(verifier, VT_FRONTCROSSDISABLEDDATA) && + verifier.VerifyTable(frontCrossDisabledData()) && + VerifyField(verifier, VT_SELECTEDSTATE, 1) && + VerifyField(verifier, VT_DISPLAYSTATE, 1) && + verifier.EndTable(); + } }; -struct CheckBoxOptionsBuilder -{ - flatbuffers::FlatBufferBuilder& fbb_; - flatbuffers::uoffset_t start_; - void add_widgetOptions(flatbuffers::Offset widgetOptions) - { - fbb_.AddOffset(CheckBoxOptions::VT_WIDGETOPTIONS, widgetOptions); - } - void add_backGroundBoxData(flatbuffers::Offset backGroundBoxData) - { - fbb_.AddOffset(CheckBoxOptions::VT_BACKGROUNDBOXDATA, backGroundBoxData); - } - void add_backGroundBoxSelectedData(flatbuffers::Offset backGroundBoxSelectedData) - { - fbb_.AddOffset(CheckBoxOptions::VT_BACKGROUNDBOXSELECTEDDATA, backGroundBoxSelectedData); - } - void add_frontCrossData(flatbuffers::Offset frontCrossData) - { - fbb_.AddOffset(CheckBoxOptions::VT_FRONTCROSSDATA, frontCrossData); - } - void add_backGroundBoxDisabledData(flatbuffers::Offset backGroundBoxDisabledData) - { - fbb_.AddOffset(CheckBoxOptions::VT_BACKGROUNDBOXDISABLEDDATA, backGroundBoxDisabledData); - } - void add_frontCrossDisabledData(flatbuffers::Offset frontCrossDisabledData) - { - fbb_.AddOffset(CheckBoxOptions::VT_FRONTCROSSDISABLEDDATA, frontCrossDisabledData); - } - void add_selectedState(bool selectedState) - { - fbb_.AddElement(CheckBoxOptions::VT_SELECTEDSTATE, static_cast(selectedState), 1); - } - void add_displaystate(bool displaystate) - { - fbb_.AddElement(CheckBoxOptions::VT_DISPLAYSTATE, static_cast(displaystate), 1); - } - explicit CheckBoxOptionsBuilder(flatbuffers::FlatBufferBuilder& _fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } - CheckBoxOptionsBuilder& operator=(const CheckBoxOptionsBuilder&); - flatbuffers::Offset Finish() - { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset(end); - return o; - } +struct CheckBoxOptionsBuilder { + typedef CheckBoxOptions Table; + flatbuffers::FlatBufferBuilder &fbb_; + flatbuffers::uoffset_t start_; + void add_widgetOptions(flatbuffers::Offset widgetOptions) { + fbb_.AddOffset(CheckBoxOptions::VT_WIDGETOPTIONS, widgetOptions); + } + void add_backGroundBoxData(flatbuffers::Offset backGroundBoxData) { + fbb_.AddOffset(CheckBoxOptions::VT_BACKGROUNDBOXDATA, backGroundBoxData); + } + void add_backGroundBoxSelectedData(flatbuffers::Offset backGroundBoxSelectedData) { + fbb_.AddOffset(CheckBoxOptions::VT_BACKGROUNDBOXSELECTEDDATA, backGroundBoxSelectedData); + } + void add_frontCrossData(flatbuffers::Offset frontCrossData) { + fbb_.AddOffset(CheckBoxOptions::VT_FRONTCROSSDATA, frontCrossData); + } + void add_backGroundBoxDisabledData(flatbuffers::Offset backGroundBoxDisabledData) { + fbb_.AddOffset(CheckBoxOptions::VT_BACKGROUNDBOXDISABLEDDATA, backGroundBoxDisabledData); + } + void add_frontCrossDisabledData(flatbuffers::Offset frontCrossDisabledData) { + fbb_.AddOffset(CheckBoxOptions::VT_FRONTCROSSDISABLEDDATA, frontCrossDisabledData); + } + void add_selectedState(bool selectedState) { + fbb_.AddElement(CheckBoxOptions::VT_SELECTEDSTATE, static_cast(selectedState), 1); + } + void add_displaystate(bool displaystate) { + fbb_.AddElement(CheckBoxOptions::VT_DISPLAYSTATE, static_cast(displaystate), 1); + } + explicit CheckBoxOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) + : fbb_(_fbb) { + start_ = fbb_.StartTable(); + } + flatbuffers::Offset Finish() { + const auto end = fbb_.EndTable(start_); + auto o = flatbuffers::Offset(end); + return o; + } }; inline flatbuffers::Offset CreateCheckBoxOptions( - flatbuffers::FlatBufferBuilder& _fbb, - flatbuffers::Offset widgetOptions = 0, - flatbuffers::Offset backGroundBoxData = 0, - flatbuffers::Offset backGroundBoxSelectedData = 0, - flatbuffers::Offset frontCrossData = 0, - flatbuffers::Offset backGroundBoxDisabledData = 0, - flatbuffers::Offset frontCrossDisabledData = 0, - bool selectedState = true, - bool displaystate = true) -{ - CheckBoxOptionsBuilder builder_(_fbb); - builder_.add_frontCrossDisabledData(frontCrossDisabledData); - builder_.add_backGroundBoxDisabledData(backGroundBoxDisabledData); - builder_.add_frontCrossData(frontCrossData); - builder_.add_backGroundBoxSelectedData(backGroundBoxSelectedData); - builder_.add_backGroundBoxData(backGroundBoxData); - builder_.add_widgetOptions(widgetOptions); - builder_.add_displaystate(displaystate); - builder_.add_selectedState(selectedState); - return builder_.Finish(); + flatbuffers::FlatBufferBuilder &_fbb, + flatbuffers::Offset widgetOptions = 0, + flatbuffers::Offset backGroundBoxData = 0, + flatbuffers::Offset backGroundBoxSelectedData = 0, + flatbuffers::Offset frontCrossData = 0, + flatbuffers::Offset backGroundBoxDisabledData = 0, + flatbuffers::Offset frontCrossDisabledData = 0, + bool selectedState = true, + bool displaystate = true) { + CheckBoxOptionsBuilder builder_(_fbb); + builder_.add_frontCrossDisabledData(frontCrossDisabledData); + builder_.add_backGroundBoxDisabledData(backGroundBoxDisabledData); + builder_.add_frontCrossData(frontCrossData); + builder_.add_backGroundBoxSelectedData(backGroundBoxSelectedData); + builder_.add_backGroundBoxData(backGroundBoxData); + builder_.add_widgetOptions(widgetOptions); + builder_.add_displaystate(displaystate); + builder_.add_selectedState(selectedState); + return builder_.Finish(); } -struct RadioButtonOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table -{ - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE - { - VT_WIDGETOPTIONS = 4, - VT_BACKGROUNDBOXDATA = 6, - VT_BACKGROUNDBOXSELECTEDDATA = 8, - VT_FRONTCROSSDATA = 10, - VT_BACKGROUNDBOXDISABLEDDATA = 12, - VT_FRONTCROSSDISABLEDDATA = 14, - VT_SELECTEDSTATE = 16, - VT_DISPLAYSTATE = 18 - }; - const WidgetOptions* widgetOptions() const { return GetPointer(VT_WIDGETOPTIONS); } - const ResourceData* backGroundBoxData() const { return GetPointer(VT_BACKGROUNDBOXDATA); } - const ResourceData* backGroundBoxSelectedData() const - { - return GetPointer(VT_BACKGROUNDBOXSELECTEDDATA); - } - const ResourceData* frontCrossData() const { return GetPointer(VT_FRONTCROSSDATA); } - const ResourceData* backGroundBoxDisabledData() const - { - return GetPointer(VT_BACKGROUNDBOXDISABLEDDATA); - } - const ResourceData* frontCrossDisabledData() const - { - return GetPointer(VT_FRONTCROSSDISABLEDDATA); - } - bool selectedState() const { return GetField(VT_SELECTEDSTATE, 0) != 0; } - bool displaystate() const { return GetField(VT_DISPLAYSTATE, 0) != 0; } - bool Verify(flatbuffers::Verifier& verifier) const - { - return VerifyTableStart(verifier) && VerifyOffset(verifier, VT_WIDGETOPTIONS) && - verifier.VerifyTable(widgetOptions()) && VerifyOffset(verifier, VT_BACKGROUNDBOXDATA) && - verifier.VerifyTable(backGroundBoxData()) && VerifyOffset(verifier, VT_BACKGROUNDBOXSELECTEDDATA) && - verifier.VerifyTable(backGroundBoxSelectedData()) && VerifyOffset(verifier, VT_FRONTCROSSDATA) && - verifier.VerifyTable(frontCrossData()) && VerifyOffset(verifier, VT_BACKGROUNDBOXDISABLEDDATA) && - verifier.VerifyTable(backGroundBoxDisabledData()) && VerifyOffset(verifier, VT_FRONTCROSSDISABLEDDATA) && - verifier.VerifyTable(frontCrossDisabledData()) && VerifyField(verifier, VT_SELECTEDSTATE) && - VerifyField(verifier, VT_DISPLAYSTATE) && verifier.EndTable(); - } +struct RadioButtonOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { + typedef RadioButtonOptionsBuilder Builder; + enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { + VT_WIDGETOPTIONS = 4, + VT_BACKGROUNDBOXDATA = 6, + VT_BACKGROUNDBOXSELECTEDDATA = 8, + VT_FRONTCROSSDATA = 10, + VT_BACKGROUNDBOXDISABLEDDATA = 12, + VT_FRONTCROSSDISABLEDDATA = 14, + VT_SELECTEDSTATE = 16, + VT_DISPLAYSTATE = 18 + }; + const flatbuffers::WidgetOptions *widgetOptions() const { + return GetPointer(VT_WIDGETOPTIONS); + } + const flatbuffers::ResourceData *backGroundBoxData() const { + return GetPointer(VT_BACKGROUNDBOXDATA); + } + const flatbuffers::ResourceData *backGroundBoxSelectedData() const { + return GetPointer(VT_BACKGROUNDBOXSELECTEDDATA); + } + const flatbuffers::ResourceData *frontCrossData() const { + return GetPointer(VT_FRONTCROSSDATA); + } + const flatbuffers::ResourceData *backGroundBoxDisabledData() const { + return GetPointer(VT_BACKGROUNDBOXDISABLEDDATA); + } + const flatbuffers::ResourceData *frontCrossDisabledData() const { + return GetPointer(VT_FRONTCROSSDISABLEDDATA); + } + bool selectedState() const { + return GetField(VT_SELECTEDSTATE, 0) != 0; + } + bool displaystate() const { + return GetField(VT_DISPLAYSTATE, 0) != 0; + } + bool Verify(flatbuffers::Verifier &verifier) const { + return VerifyTableStart(verifier) && + VerifyOffset(verifier, VT_WIDGETOPTIONS) && + verifier.VerifyTable(widgetOptions()) && + VerifyOffset(verifier, VT_BACKGROUNDBOXDATA) && + verifier.VerifyTable(backGroundBoxData()) && + VerifyOffset(verifier, VT_BACKGROUNDBOXSELECTEDDATA) && + verifier.VerifyTable(backGroundBoxSelectedData()) && + VerifyOffset(verifier, VT_FRONTCROSSDATA) && + verifier.VerifyTable(frontCrossData()) && + VerifyOffset(verifier, VT_BACKGROUNDBOXDISABLEDDATA) && + verifier.VerifyTable(backGroundBoxDisabledData()) && + VerifyOffset(verifier, VT_FRONTCROSSDISABLEDDATA) && + verifier.VerifyTable(frontCrossDisabledData()) && + VerifyField(verifier, VT_SELECTEDSTATE, 1) && + VerifyField(verifier, VT_DISPLAYSTATE, 1) && + verifier.EndTable(); + } }; -struct RadioButtonOptionsBuilder -{ - flatbuffers::FlatBufferBuilder& fbb_; - flatbuffers::uoffset_t start_; - void add_widgetOptions(flatbuffers::Offset widgetOptions) - { - fbb_.AddOffset(RadioButtonOptions::VT_WIDGETOPTIONS, widgetOptions); - } - void add_backGroundBoxData(flatbuffers::Offset backGroundBoxData) - { - fbb_.AddOffset(RadioButtonOptions::VT_BACKGROUNDBOXDATA, backGroundBoxData); - } - void add_backGroundBoxSelectedData(flatbuffers::Offset backGroundBoxSelectedData) - { - fbb_.AddOffset(RadioButtonOptions::VT_BACKGROUNDBOXSELECTEDDATA, backGroundBoxSelectedData); - } - void add_frontCrossData(flatbuffers::Offset frontCrossData) - { - fbb_.AddOffset(RadioButtonOptions::VT_FRONTCROSSDATA, frontCrossData); - } - void add_backGroundBoxDisabledData(flatbuffers::Offset backGroundBoxDisabledData) - { - fbb_.AddOffset(RadioButtonOptions::VT_BACKGROUNDBOXDISABLEDDATA, backGroundBoxDisabledData); - } - void add_frontCrossDisabledData(flatbuffers::Offset frontCrossDisabledData) - { - fbb_.AddOffset(RadioButtonOptions::VT_FRONTCROSSDISABLEDDATA, frontCrossDisabledData); - } - void add_selectedState(bool selectedState) - { - fbb_.AddElement(RadioButtonOptions::VT_SELECTEDSTATE, static_cast(selectedState), 0); - } - void add_displaystate(bool displaystate) - { - fbb_.AddElement(RadioButtonOptions::VT_DISPLAYSTATE, static_cast(displaystate), 0); - } - explicit RadioButtonOptionsBuilder(flatbuffers::FlatBufferBuilder& _fbb) : fbb_(_fbb) - { - start_ = fbb_.StartTable(); - } - RadioButtonOptionsBuilder& operator=(const RadioButtonOptionsBuilder&); - flatbuffers::Offset Finish() - { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset(end); - return o; - } +struct RadioButtonOptionsBuilder { + typedef RadioButtonOptions Table; + flatbuffers::FlatBufferBuilder &fbb_; + flatbuffers::uoffset_t start_; + void add_widgetOptions(flatbuffers::Offset widgetOptions) { + fbb_.AddOffset(RadioButtonOptions::VT_WIDGETOPTIONS, widgetOptions); + } + void add_backGroundBoxData(flatbuffers::Offset backGroundBoxData) { + fbb_.AddOffset(RadioButtonOptions::VT_BACKGROUNDBOXDATA, backGroundBoxData); + } + void add_backGroundBoxSelectedData(flatbuffers::Offset backGroundBoxSelectedData) { + fbb_.AddOffset(RadioButtonOptions::VT_BACKGROUNDBOXSELECTEDDATA, backGroundBoxSelectedData); + } + void add_frontCrossData(flatbuffers::Offset frontCrossData) { + fbb_.AddOffset(RadioButtonOptions::VT_FRONTCROSSDATA, frontCrossData); + } + void add_backGroundBoxDisabledData(flatbuffers::Offset backGroundBoxDisabledData) { + fbb_.AddOffset(RadioButtonOptions::VT_BACKGROUNDBOXDISABLEDDATA, backGroundBoxDisabledData); + } + void add_frontCrossDisabledData(flatbuffers::Offset frontCrossDisabledData) { + fbb_.AddOffset(RadioButtonOptions::VT_FRONTCROSSDISABLEDDATA, frontCrossDisabledData); + } + void add_selectedState(bool selectedState) { + fbb_.AddElement(RadioButtonOptions::VT_SELECTEDSTATE, static_cast(selectedState), 0); + } + void add_displaystate(bool displaystate) { + fbb_.AddElement(RadioButtonOptions::VT_DISPLAYSTATE, static_cast(displaystate), 0); + } + explicit RadioButtonOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) + : fbb_(_fbb) { + start_ = fbb_.StartTable(); + } + flatbuffers::Offset Finish() { + const auto end = fbb_.EndTable(start_); + auto o = flatbuffers::Offset(end); + return o; + } }; inline flatbuffers::Offset CreateRadioButtonOptions( - flatbuffers::FlatBufferBuilder& _fbb, - flatbuffers::Offset widgetOptions = 0, - flatbuffers::Offset backGroundBoxData = 0, - flatbuffers::Offset backGroundBoxSelectedData = 0, - flatbuffers::Offset frontCrossData = 0, - flatbuffers::Offset backGroundBoxDisabledData = 0, - flatbuffers::Offset frontCrossDisabledData = 0, - bool selectedState = false, - bool displaystate = false) -{ - RadioButtonOptionsBuilder builder_(_fbb); - builder_.add_frontCrossDisabledData(frontCrossDisabledData); - builder_.add_backGroundBoxDisabledData(backGroundBoxDisabledData); - builder_.add_frontCrossData(frontCrossData); - builder_.add_backGroundBoxSelectedData(backGroundBoxSelectedData); - builder_.add_backGroundBoxData(backGroundBoxData); - builder_.add_widgetOptions(widgetOptions); - builder_.add_displaystate(displaystate); - builder_.add_selectedState(selectedState); - return builder_.Finish(); + flatbuffers::FlatBufferBuilder &_fbb, + flatbuffers::Offset widgetOptions = 0, + flatbuffers::Offset backGroundBoxData = 0, + flatbuffers::Offset backGroundBoxSelectedData = 0, + flatbuffers::Offset frontCrossData = 0, + flatbuffers::Offset backGroundBoxDisabledData = 0, + flatbuffers::Offset frontCrossDisabledData = 0, + bool selectedState = false, + bool displaystate = false) { + RadioButtonOptionsBuilder builder_(_fbb); + builder_.add_frontCrossDisabledData(frontCrossDisabledData); + builder_.add_backGroundBoxDisabledData(backGroundBoxDisabledData); + builder_.add_frontCrossData(frontCrossData); + builder_.add_backGroundBoxSelectedData(backGroundBoxSelectedData); + builder_.add_backGroundBoxData(backGroundBoxData); + builder_.add_widgetOptions(widgetOptions); + builder_.add_displaystate(displaystate); + builder_.add_selectedState(selectedState); + return builder_.Finish(); } -struct RadioButtonGroupOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table -{ - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE - { - VT_WIDGETOPTIONS = 4, - VT_ALLOWEDNOSELECTION = 6 - }; - const WidgetOptions* widgetOptions() const { return GetPointer(VT_WIDGETOPTIONS); } - bool allowedNoSelection() const { return GetField(VT_ALLOWEDNOSELECTION, 0) != 0; } - bool Verify(flatbuffers::Verifier& verifier) const - { - return VerifyTableStart(verifier) && VerifyOffset(verifier, VT_WIDGETOPTIONS) && - verifier.VerifyTable(widgetOptions()) && VerifyField(verifier, VT_ALLOWEDNOSELECTION) && - verifier.EndTable(); - } +struct RadioButtonGroupOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { + typedef RadioButtonGroupOptionsBuilder Builder; + enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { + VT_WIDGETOPTIONS = 4, + VT_ALLOWEDNOSELECTION = 6 + }; + const flatbuffers::WidgetOptions *widgetOptions() const { + return GetPointer(VT_WIDGETOPTIONS); + } + bool allowedNoSelection() const { + return GetField(VT_ALLOWEDNOSELECTION, 0) != 0; + } + bool Verify(flatbuffers::Verifier &verifier) const { + return VerifyTableStart(verifier) && + VerifyOffset(verifier, VT_WIDGETOPTIONS) && + verifier.VerifyTable(widgetOptions()) && + VerifyField(verifier, VT_ALLOWEDNOSELECTION, 1) && + verifier.EndTable(); + } }; -struct RadioButtonGroupOptionsBuilder -{ - flatbuffers::FlatBufferBuilder& fbb_; - flatbuffers::uoffset_t start_; - void add_widgetOptions(flatbuffers::Offset widgetOptions) - { - fbb_.AddOffset(RadioButtonGroupOptions::VT_WIDGETOPTIONS, widgetOptions); - } - void add_allowedNoSelection(bool allowedNoSelection) - { - fbb_.AddElement(RadioButtonGroupOptions::VT_ALLOWEDNOSELECTION, - static_cast(allowedNoSelection), 0); - } - explicit RadioButtonGroupOptionsBuilder(flatbuffers::FlatBufferBuilder& _fbb) : fbb_(_fbb) - { - start_ = fbb_.StartTable(); - } - RadioButtonGroupOptionsBuilder& operator=(const RadioButtonGroupOptionsBuilder&); - flatbuffers::Offset Finish() - { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset(end); - return o; - } +struct RadioButtonGroupOptionsBuilder { + typedef RadioButtonGroupOptions Table; + flatbuffers::FlatBufferBuilder &fbb_; + flatbuffers::uoffset_t start_; + void add_widgetOptions(flatbuffers::Offset widgetOptions) { + fbb_.AddOffset(RadioButtonGroupOptions::VT_WIDGETOPTIONS, widgetOptions); + } + void add_allowedNoSelection(bool allowedNoSelection) { + fbb_.AddElement(RadioButtonGroupOptions::VT_ALLOWEDNOSELECTION, static_cast(allowedNoSelection), 0); + } + explicit RadioButtonGroupOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) + : fbb_(_fbb) { + start_ = fbb_.StartTable(); + } + flatbuffers::Offset Finish() { + const auto end = fbb_.EndTable(start_); + auto o = flatbuffers::Offset(end); + return o; + } }; inline flatbuffers::Offset CreateRadioButtonGroupOptions( - flatbuffers::FlatBufferBuilder& _fbb, - flatbuffers::Offset widgetOptions = 0, - bool allowedNoSelection = false) -{ - RadioButtonGroupOptionsBuilder builder_(_fbb); - builder_.add_widgetOptions(widgetOptions); - builder_.add_allowedNoSelection(allowedNoSelection); - return builder_.Finish(); + flatbuffers::FlatBufferBuilder &_fbb, + flatbuffers::Offset widgetOptions = 0, + bool allowedNoSelection = false) { + RadioButtonGroupOptionsBuilder builder_(_fbb); + builder_.add_widgetOptions(widgetOptions); + builder_.add_allowedNoSelection(allowedNoSelection); + return builder_.Finish(); } -struct ImageViewOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table -{ - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE - { - VT_WIDGETOPTIONS = 4, - VT_FILENAMEDATA = 6, - VT_CAPINSETS = 8, - VT_SCALE9SIZE = 10, - VT_SCALE9ENABLED = 12 - }; - const WidgetOptions* widgetOptions() const { return GetPointer(VT_WIDGETOPTIONS); } - const ResourceData* fileNameData() const { return GetPointer(VT_FILENAMEDATA); } - const CapInsets* capInsets() const { return GetStruct(VT_CAPINSETS); } - const FlatSize* scale9Size() const { return GetStruct(VT_SCALE9SIZE); } - bool scale9Enabled() const { return GetField(VT_SCALE9ENABLED, 0) != 0; } - bool Verify(flatbuffers::Verifier& verifier) const - { - return VerifyTableStart(verifier) && VerifyOffset(verifier, VT_WIDGETOPTIONS) && - verifier.VerifyTable(widgetOptions()) && VerifyOffset(verifier, VT_FILENAMEDATA) && - verifier.VerifyTable(fileNameData()) && VerifyField(verifier, VT_CAPINSETS) && - VerifyField(verifier, VT_SCALE9SIZE) && VerifyField(verifier, VT_SCALE9ENABLED) && - verifier.EndTable(); - } +struct ImageViewOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { + typedef ImageViewOptionsBuilder Builder; + enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { + VT_WIDGETOPTIONS = 4, + VT_FILENAMEDATA = 6, + VT_CAPINSETS = 8, + VT_SCALE9SIZE = 10, + VT_SCALE9ENABLED = 12 + }; + const flatbuffers::WidgetOptions *widgetOptions() const { + return GetPointer(VT_WIDGETOPTIONS); + } + const flatbuffers::ResourceData *fileNameData() const { + return GetPointer(VT_FILENAMEDATA); + } + const flatbuffers::CapInsets *capInsets() const { + return GetStruct(VT_CAPINSETS); + } + const flatbuffers::FlatSize *scale9Size() const { + return GetStruct(VT_SCALE9SIZE); + } + bool scale9Enabled() const { + return GetField(VT_SCALE9ENABLED, 0) != 0; + } + bool Verify(flatbuffers::Verifier &verifier) const { + return VerifyTableStart(verifier) && + VerifyOffset(verifier, VT_WIDGETOPTIONS) && + verifier.VerifyTable(widgetOptions()) && + VerifyOffset(verifier, VT_FILENAMEDATA) && + verifier.VerifyTable(fileNameData()) && + VerifyField(verifier, VT_CAPINSETS, 4) && + VerifyField(verifier, VT_SCALE9SIZE, 4) && + VerifyField(verifier, VT_SCALE9ENABLED, 1) && + verifier.EndTable(); + } }; -struct ImageViewOptionsBuilder -{ - flatbuffers::FlatBufferBuilder& fbb_; - flatbuffers::uoffset_t start_; - void add_widgetOptions(flatbuffers::Offset widgetOptions) - { - fbb_.AddOffset(ImageViewOptions::VT_WIDGETOPTIONS, widgetOptions); - } - void add_fileNameData(flatbuffers::Offset fileNameData) - { - fbb_.AddOffset(ImageViewOptions::VT_FILENAMEDATA, fileNameData); - } - void add_capInsets(const CapInsets* capInsets) { fbb_.AddStruct(ImageViewOptions::VT_CAPINSETS, capInsets); } - void add_scale9Size(const FlatSize* scale9Size) { fbb_.AddStruct(ImageViewOptions::VT_SCALE9SIZE, scale9Size); } - void add_scale9Enabled(bool scale9Enabled) - { - fbb_.AddElement(ImageViewOptions::VT_SCALE9ENABLED, static_cast(scale9Enabled), 0); - } - explicit ImageViewOptionsBuilder(flatbuffers::FlatBufferBuilder& _fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } - ImageViewOptionsBuilder& operator=(const ImageViewOptionsBuilder&); - flatbuffers::Offset Finish() - { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset(end); - return o; - } +struct ImageViewOptionsBuilder { + typedef ImageViewOptions Table; + flatbuffers::FlatBufferBuilder &fbb_; + flatbuffers::uoffset_t start_; + void add_widgetOptions(flatbuffers::Offset widgetOptions) { + fbb_.AddOffset(ImageViewOptions::VT_WIDGETOPTIONS, widgetOptions); + } + void add_fileNameData(flatbuffers::Offset fileNameData) { + fbb_.AddOffset(ImageViewOptions::VT_FILENAMEDATA, fileNameData); + } + void add_capInsets(const flatbuffers::CapInsets *capInsets) { + fbb_.AddStruct(ImageViewOptions::VT_CAPINSETS, capInsets); + } + void add_scale9Size(const flatbuffers::FlatSize *scale9Size) { + fbb_.AddStruct(ImageViewOptions::VT_SCALE9SIZE, scale9Size); + } + void add_scale9Enabled(bool scale9Enabled) { + fbb_.AddElement(ImageViewOptions::VT_SCALE9ENABLED, static_cast(scale9Enabled), 0); + } + explicit ImageViewOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) + : fbb_(_fbb) { + start_ = fbb_.StartTable(); + } + flatbuffers::Offset Finish() { + const auto end = fbb_.EndTable(start_); + auto o = flatbuffers::Offset(end); + return o; + } }; inline flatbuffers::Offset CreateImageViewOptions( - flatbuffers::FlatBufferBuilder& _fbb, - flatbuffers::Offset widgetOptions = 0, - flatbuffers::Offset fileNameData = 0, - const CapInsets* capInsets = 0, - const FlatSize* scale9Size = 0, - bool scale9Enabled = false) -{ - ImageViewOptionsBuilder builder_(_fbb); - builder_.add_scale9Size(scale9Size); - builder_.add_capInsets(capInsets); - builder_.add_fileNameData(fileNameData); - builder_.add_widgetOptions(widgetOptions); - builder_.add_scale9Enabled(scale9Enabled); - return builder_.Finish(); + flatbuffers::FlatBufferBuilder &_fbb, + flatbuffers::Offset widgetOptions = 0, + flatbuffers::Offset fileNameData = 0, + const flatbuffers::CapInsets *capInsets = nullptr, + const flatbuffers::FlatSize *scale9Size = nullptr, + bool scale9Enabled = false) { + ImageViewOptionsBuilder builder_(_fbb); + builder_.add_scale9Size(scale9Size); + builder_.add_capInsets(capInsets); + builder_.add_fileNameData(fileNameData); + builder_.add_widgetOptions(widgetOptions); + builder_.add_scale9Enabled(scale9Enabled); + return builder_.Finish(); } -struct TextAtlasOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table -{ - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE - { - VT_WIDGETOPTIONS = 4, - VT_CHARMAPFILEDATA = 6, - VT_STRINGVALUE = 8, - VT_STARTCHARMAP = 10, - VT_ITEMWIDTH = 12, - VT_ITEMHEIGHT = 14 - }; - const WidgetOptions* widgetOptions() const { return GetPointer(VT_WIDGETOPTIONS); } - const ResourceData* charMapFileData() const { return GetPointer(VT_CHARMAPFILEDATA); } - const flatbuffers::String* stringValue() const { return GetPointer(VT_STRINGVALUE); } - const flatbuffers::String* startCharMap() const { return GetPointer(VT_STARTCHARMAP); } - int32_t itemWidth() const { return GetField(VT_ITEMWIDTH, 0); } - int32_t itemHeight() const { return GetField(VT_ITEMHEIGHT, 0); } - bool Verify(flatbuffers::Verifier& verifier) const - { - return VerifyTableStart(verifier) && VerifyOffset(verifier, VT_WIDGETOPTIONS) && - verifier.VerifyTable(widgetOptions()) && VerifyOffset(verifier, VT_CHARMAPFILEDATA) && - verifier.VerifyTable(charMapFileData()) && VerifyOffset(verifier, VT_STRINGVALUE) && - verifier.VerifyString(stringValue()) && VerifyOffset(verifier, VT_STARTCHARMAP) && - verifier.VerifyString(startCharMap()) && VerifyField(verifier, VT_ITEMWIDTH) && - VerifyField(verifier, VT_ITEMHEIGHT) && verifier.EndTable(); - } +struct TextAtlasOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { + typedef TextAtlasOptionsBuilder Builder; + enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { + VT_WIDGETOPTIONS = 4, + VT_CHARMAPFILEDATA = 6, + VT_STRINGVALUE = 8, + VT_STARTCHARMAP = 10, + VT_ITEMWIDTH = 12, + VT_ITEMHEIGHT = 14 + }; + const flatbuffers::WidgetOptions *widgetOptions() const { + return GetPointer(VT_WIDGETOPTIONS); + } + const flatbuffers::ResourceData *charMapFileData() const { + return GetPointer(VT_CHARMAPFILEDATA); + } + const flatbuffers::String *stringValue() const { + return GetPointer(VT_STRINGVALUE); + } + const flatbuffers::String *startCharMap() const { + return GetPointer(VT_STARTCHARMAP); + } + int32_t itemWidth() const { + return GetField(VT_ITEMWIDTH, 0); + } + int32_t itemHeight() const { + return GetField(VT_ITEMHEIGHT, 0); + } + bool Verify(flatbuffers::Verifier &verifier) const { + return VerifyTableStart(verifier) && + VerifyOffset(verifier, VT_WIDGETOPTIONS) && + verifier.VerifyTable(widgetOptions()) && + VerifyOffset(verifier, VT_CHARMAPFILEDATA) && + verifier.VerifyTable(charMapFileData()) && + VerifyOffset(verifier, VT_STRINGVALUE) && + verifier.VerifyString(stringValue()) && + VerifyOffset(verifier, VT_STARTCHARMAP) && + verifier.VerifyString(startCharMap()) && + VerifyField(verifier, VT_ITEMWIDTH, 4) && + VerifyField(verifier, VT_ITEMHEIGHT, 4) && + verifier.EndTable(); + } }; -struct TextAtlasOptionsBuilder -{ - flatbuffers::FlatBufferBuilder& fbb_; - flatbuffers::uoffset_t start_; - void add_widgetOptions(flatbuffers::Offset widgetOptions) - { - fbb_.AddOffset(TextAtlasOptions::VT_WIDGETOPTIONS, widgetOptions); - } - void add_charMapFileData(flatbuffers::Offset charMapFileData) - { - fbb_.AddOffset(TextAtlasOptions::VT_CHARMAPFILEDATA, charMapFileData); - } - void add_stringValue(flatbuffers::Offset stringValue) - { - fbb_.AddOffset(TextAtlasOptions::VT_STRINGVALUE, stringValue); - } - void add_startCharMap(flatbuffers::Offset startCharMap) - { - fbb_.AddOffset(TextAtlasOptions::VT_STARTCHARMAP, startCharMap); - } - void add_itemWidth(int32_t itemWidth) { fbb_.AddElement(TextAtlasOptions::VT_ITEMWIDTH, itemWidth, 0); } - void add_itemHeight(int32_t itemHeight) - { - fbb_.AddElement(TextAtlasOptions::VT_ITEMHEIGHT, itemHeight, 0); - } - explicit TextAtlasOptionsBuilder(flatbuffers::FlatBufferBuilder& _fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } - TextAtlasOptionsBuilder& operator=(const TextAtlasOptionsBuilder&); - flatbuffers::Offset Finish() - { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset(end); - return o; - } +struct TextAtlasOptionsBuilder { + typedef TextAtlasOptions Table; + flatbuffers::FlatBufferBuilder &fbb_; + flatbuffers::uoffset_t start_; + void add_widgetOptions(flatbuffers::Offset widgetOptions) { + fbb_.AddOffset(TextAtlasOptions::VT_WIDGETOPTIONS, widgetOptions); + } + void add_charMapFileData(flatbuffers::Offset charMapFileData) { + fbb_.AddOffset(TextAtlasOptions::VT_CHARMAPFILEDATA, charMapFileData); + } + void add_stringValue(flatbuffers::Offset stringValue) { + fbb_.AddOffset(TextAtlasOptions::VT_STRINGVALUE, stringValue); + } + void add_startCharMap(flatbuffers::Offset startCharMap) { + fbb_.AddOffset(TextAtlasOptions::VT_STARTCHARMAP, startCharMap); + } + void add_itemWidth(int32_t itemWidth) { + fbb_.AddElement(TextAtlasOptions::VT_ITEMWIDTH, itemWidth, 0); + } + void add_itemHeight(int32_t itemHeight) { + fbb_.AddElement(TextAtlasOptions::VT_ITEMHEIGHT, itemHeight, 0); + } + explicit TextAtlasOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) + : fbb_(_fbb) { + start_ = fbb_.StartTable(); + } + flatbuffers::Offset Finish() { + const auto end = fbb_.EndTable(start_); + auto o = flatbuffers::Offset(end); + return o; + } }; inline flatbuffers::Offset CreateTextAtlasOptions( - flatbuffers::FlatBufferBuilder& _fbb, - flatbuffers::Offset widgetOptions = 0, - flatbuffers::Offset charMapFileData = 0, - flatbuffers::Offset stringValue = 0, + flatbuffers::FlatBufferBuilder &_fbb, + flatbuffers::Offset widgetOptions = 0, + flatbuffers::Offset charMapFileData = 0, + flatbuffers::Offset stringValue = 0, flatbuffers::Offset startCharMap = 0, - int32_t itemWidth = 0, - int32_t itemHeight = 0) -{ - TextAtlasOptionsBuilder builder_(_fbb); - builder_.add_itemHeight(itemHeight); - builder_.add_itemWidth(itemWidth); - builder_.add_startCharMap(startCharMap); - builder_.add_stringValue(stringValue); - builder_.add_charMapFileData(charMapFileData); - builder_.add_widgetOptions(widgetOptions); - return builder_.Finish(); + int32_t itemWidth = 0, + int32_t itemHeight = 0) { + TextAtlasOptionsBuilder builder_(_fbb); + builder_.add_itemHeight(itemHeight); + builder_.add_itemWidth(itemWidth); + builder_.add_startCharMap(startCharMap); + builder_.add_stringValue(stringValue); + builder_.add_charMapFileData(charMapFileData); + builder_.add_widgetOptions(widgetOptions); + return builder_.Finish(); } inline flatbuffers::Offset CreateTextAtlasOptionsDirect( - flatbuffers::FlatBufferBuilder& _fbb, - flatbuffers::Offset widgetOptions = 0, - flatbuffers::Offset charMapFileData = 0, - const char* stringValue = nullptr, - const char* startCharMap = nullptr, - int32_t itemWidth = 0, - int32_t itemHeight = 0) -{ - auto stringValue__ = stringValue ? _fbb.CreateString(stringValue) : 0; - auto startCharMap__ = startCharMap ? _fbb.CreateString(startCharMap) : 0; - return flatbuffers::CreateTextAtlasOptions(_fbb, widgetOptions, charMapFileData, stringValue__, startCharMap__, - itemWidth, itemHeight); + flatbuffers::FlatBufferBuilder &_fbb, + flatbuffers::Offset widgetOptions = 0, + flatbuffers::Offset charMapFileData = 0, + const char *stringValue = nullptr, + const char *startCharMap = nullptr, + int32_t itemWidth = 0, + int32_t itemHeight = 0) { + auto stringValue__ = stringValue ? _fbb.CreateString(stringValue) : 0; + auto startCharMap__ = startCharMap ? _fbb.CreateString(startCharMap) : 0; + return flatbuffers::CreateTextAtlasOptions( + _fbb, + widgetOptions, + charMapFileData, + stringValue__, + startCharMap__, + itemWidth, + itemHeight); } -struct TextBMFontOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table -{ - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE - { - VT_WIDGETOPTIONS = 4, - VT_FILENAMEDATA = 6, - VT_TEXT = 8, - VT_ISLOCALIZED = 10 - }; - const WidgetOptions* widgetOptions() const { return GetPointer(VT_WIDGETOPTIONS); } - const ResourceData* fileNameData() const { return GetPointer(VT_FILENAMEDATA); } - const flatbuffers::String* text() const { return GetPointer(VT_TEXT); } - bool isLocalized() const { return GetField(VT_ISLOCALIZED, 0) != 0; } - bool Verify(flatbuffers::Verifier& verifier) const - { - return VerifyTableStart(verifier) && VerifyOffset(verifier, VT_WIDGETOPTIONS) && - verifier.VerifyTable(widgetOptions()) && VerifyOffset(verifier, VT_FILENAMEDATA) && - verifier.VerifyTable(fileNameData()) && VerifyOffset(verifier, VT_TEXT) && - verifier.VerifyString(text()) && VerifyField(verifier, VT_ISLOCALIZED) && verifier.EndTable(); - } +struct TextBMFontOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { + typedef TextBMFontOptionsBuilder Builder; + enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { + VT_WIDGETOPTIONS = 4, + VT_FILENAMEDATA = 6, + VT_TEXT = 8, + VT_ISLOCALIZED = 10 + }; + const flatbuffers::WidgetOptions *widgetOptions() const { + return GetPointer(VT_WIDGETOPTIONS); + } + const flatbuffers::ResourceData *fileNameData() const { + return GetPointer(VT_FILENAMEDATA); + } + const flatbuffers::String *text() const { + return GetPointer(VT_TEXT); + } + bool isLocalized() const { + return GetField(VT_ISLOCALIZED, 0) != 0; + } + bool Verify(flatbuffers::Verifier &verifier) const { + return VerifyTableStart(verifier) && + VerifyOffset(verifier, VT_WIDGETOPTIONS) && + verifier.VerifyTable(widgetOptions()) && + VerifyOffset(verifier, VT_FILENAMEDATA) && + verifier.VerifyTable(fileNameData()) && + VerifyOffset(verifier, VT_TEXT) && + verifier.VerifyString(text()) && + VerifyField(verifier, VT_ISLOCALIZED, 1) && + verifier.EndTable(); + } }; -struct TextBMFontOptionsBuilder -{ - flatbuffers::FlatBufferBuilder& fbb_; - flatbuffers::uoffset_t start_; - void add_widgetOptions(flatbuffers::Offset widgetOptions) - { - fbb_.AddOffset(TextBMFontOptions::VT_WIDGETOPTIONS, widgetOptions); - } - void add_fileNameData(flatbuffers::Offset fileNameData) - { - fbb_.AddOffset(TextBMFontOptions::VT_FILENAMEDATA, fileNameData); - } - void add_text(flatbuffers::Offset text) { fbb_.AddOffset(TextBMFontOptions::VT_TEXT, text); } - void add_isLocalized(bool isLocalized) - { - fbb_.AddElement(TextBMFontOptions::VT_ISLOCALIZED, static_cast(isLocalized), 0); - } - explicit TextBMFontOptionsBuilder(flatbuffers::FlatBufferBuilder& _fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } - TextBMFontOptionsBuilder& operator=(const TextBMFontOptionsBuilder&); - flatbuffers::Offset Finish() - { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset(end); - return o; - } +struct TextBMFontOptionsBuilder { + typedef TextBMFontOptions Table; + flatbuffers::FlatBufferBuilder &fbb_; + flatbuffers::uoffset_t start_; + void add_widgetOptions(flatbuffers::Offset widgetOptions) { + fbb_.AddOffset(TextBMFontOptions::VT_WIDGETOPTIONS, widgetOptions); + } + void add_fileNameData(flatbuffers::Offset fileNameData) { + fbb_.AddOffset(TextBMFontOptions::VT_FILENAMEDATA, fileNameData); + } + void add_text(flatbuffers::Offset text) { + fbb_.AddOffset(TextBMFontOptions::VT_TEXT, text); + } + void add_isLocalized(bool isLocalized) { + fbb_.AddElement(TextBMFontOptions::VT_ISLOCALIZED, static_cast(isLocalized), 0); + } + explicit TextBMFontOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) + : fbb_(_fbb) { + start_ = fbb_.StartTable(); + } + flatbuffers::Offset Finish() { + const auto end = fbb_.EndTable(start_); + auto o = flatbuffers::Offset(end); + return o; + } }; inline flatbuffers::Offset CreateTextBMFontOptions( - flatbuffers::FlatBufferBuilder& _fbb, - flatbuffers::Offset widgetOptions = 0, - flatbuffers::Offset fileNameData = 0, - flatbuffers::Offset text = 0, - bool isLocalized = false) -{ - TextBMFontOptionsBuilder builder_(_fbb); - builder_.add_text(text); - builder_.add_fileNameData(fileNameData); - builder_.add_widgetOptions(widgetOptions); - builder_.add_isLocalized(isLocalized); - return builder_.Finish(); + flatbuffers::FlatBufferBuilder &_fbb, + flatbuffers::Offset widgetOptions = 0, + flatbuffers::Offset fileNameData = 0, + flatbuffers::Offset text = 0, + bool isLocalized = false) { + TextBMFontOptionsBuilder builder_(_fbb); + builder_.add_text(text); + builder_.add_fileNameData(fileNameData); + builder_.add_widgetOptions(widgetOptions); + builder_.add_isLocalized(isLocalized); + return builder_.Finish(); } inline flatbuffers::Offset CreateTextBMFontOptionsDirect( - flatbuffers::FlatBufferBuilder& _fbb, - flatbuffers::Offset widgetOptions = 0, - flatbuffers::Offset fileNameData = 0, - const char* text = nullptr, - bool isLocalized = false) -{ - auto text__ = text ? _fbb.CreateString(text) : 0; - return flatbuffers::CreateTextBMFontOptions(_fbb, widgetOptions, fileNameData, text__, isLocalized); + flatbuffers::FlatBufferBuilder &_fbb, + flatbuffers::Offset widgetOptions = 0, + flatbuffers::Offset fileNameData = 0, + const char *text = nullptr, + bool isLocalized = false) { + auto text__ = text ? _fbb.CreateString(text) : 0; + return flatbuffers::CreateTextBMFontOptions( + _fbb, + widgetOptions, + fileNameData, + text__, + isLocalized); } -struct TextOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table -{ - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE - { - VT_WIDGETOPTIONS = 4, - VT_FONTRESOURCE = 6, - VT_FONTNAME = 8, - VT_FONTSIZE = 10, - VT_TEXT = 12, - VT_AREAWIDTH = 14, - VT_AREAHEIGHT = 16, - VT_HALIGNMENT = 18, - VT_VALIGNMENT = 20, - VT_TOUCHSCALEENABLE = 22, - VT_ISCUSTOMSIZE = 24, - VT_OUTLINEENABLED = 26, - VT_OUTLINECOLOR = 28, - VT_OUTLINESIZE = 30, - VT_SHADOWENABLED = 32, - VT_SHADOWCOLOR = 34, - VT_SHADOWOFFSETX = 36, - VT_SHADOWOFFSETY = 38, - VT_SHADOWBLURRADIUS = 40, - VT_ISLOCALIZED = 42, - VT_GLOWENABLED = 44, - VT_GLOWCOLOR = 46, - VT_BOLDENABLED = 48, - VT_UNDERLINEENABLED = 50, - VT_ITALICSENABLED = 52, - VT_STRIKETHROUGHENABLED = 54 - }; - const WidgetOptions* widgetOptions() const { return GetPointer(VT_WIDGETOPTIONS); } - const ResourceData* fontResource() const { return GetPointer(VT_FONTRESOURCE); } - const flatbuffers::String* fontName() const { return GetPointer(VT_FONTNAME); } - int32_t fontSize() const { return GetField(VT_FONTSIZE, 0); } - const flatbuffers::String* text() const { return GetPointer(VT_TEXT); } - int32_t areaWidth() const { return GetField(VT_AREAWIDTH, 0); } - int32_t areaHeight() const { return GetField(VT_AREAHEIGHT, 0); } - int32_t hAlignment() const { return GetField(VT_HALIGNMENT, 0); } - int32_t vAlignment() const { return GetField(VT_VALIGNMENT, 0); } - bool touchScaleEnable() const { return GetField(VT_TOUCHSCALEENABLE, 0) != 0; } - bool isCustomSize() const { return GetField(VT_ISCUSTOMSIZE, 0) != 0; } - bool outlineEnabled() const { return GetField(VT_OUTLINEENABLED, 0) != 0; } - const Color* outlineColor() const { return GetStruct(VT_OUTLINECOLOR); } - int32_t outlineSize() const { return GetField(VT_OUTLINESIZE, 1); } - bool shadowEnabled() const { return GetField(VT_SHADOWENABLED, 0) != 0; } - const Color* shadowColor() const { return GetStruct(VT_SHADOWCOLOR); } - float shadowOffsetX() const { return GetField(VT_SHADOWOFFSETX, 2.0f); } - float shadowOffsetY() const { return GetField(VT_SHADOWOFFSETY, -2.0f); } - int32_t shadowBlurRadius() const { return GetField(VT_SHADOWBLURRADIUS, 0); } - bool isLocalized() const { return GetField(VT_ISLOCALIZED, 0) != 0; } - bool glowEnabled() const { return GetField(VT_GLOWENABLED, 0) != 0; } - const Color* glowColor() const { return GetStruct(VT_GLOWCOLOR); } - bool boldEnabled() const { return GetField(VT_BOLDENABLED, 0) != 0; } - bool underlineEnabled() const { return GetField(VT_UNDERLINEENABLED, 0) != 0; } - bool italicsEnabled() const { return GetField(VT_ITALICSENABLED, 0) != 0; } - bool strikethroughEnabled() const { return GetField(VT_STRIKETHROUGHENABLED, 0) != 0; } - bool Verify(flatbuffers::Verifier& verifier) const - { - return VerifyTableStart(verifier) && VerifyOffset(verifier, VT_WIDGETOPTIONS) && - verifier.VerifyTable(widgetOptions()) && VerifyOffset(verifier, VT_FONTRESOURCE) && - verifier.VerifyTable(fontResource()) && VerifyOffset(verifier, VT_FONTNAME) && - verifier.VerifyString(fontName()) && VerifyField(verifier, VT_FONTSIZE) && - VerifyOffset(verifier, VT_TEXT) && verifier.VerifyString(text()) && - VerifyField(verifier, VT_AREAWIDTH) && VerifyField(verifier, VT_AREAHEIGHT) && - VerifyField(verifier, VT_HALIGNMENT) && VerifyField(verifier, VT_VALIGNMENT) && - VerifyField(verifier, VT_TOUCHSCALEENABLE) && VerifyField(verifier, VT_ISCUSTOMSIZE) && - VerifyField(verifier, VT_OUTLINEENABLED) && VerifyField(verifier, VT_OUTLINECOLOR) && - VerifyField(verifier, VT_OUTLINESIZE) && VerifyField(verifier, VT_SHADOWENABLED) && - VerifyField(verifier, VT_SHADOWCOLOR) && VerifyField(verifier, VT_SHADOWOFFSETX) && - VerifyField(verifier, VT_SHADOWOFFSETY) && VerifyField(verifier, VT_SHADOWBLURRADIUS) && - VerifyField(verifier, VT_ISLOCALIZED) && VerifyField(verifier, VT_GLOWENABLED) && - VerifyField(verifier, VT_GLOWCOLOR) && VerifyField(verifier, VT_BOLDENABLED) && - VerifyField(verifier, VT_UNDERLINEENABLED) && - VerifyField(verifier, VT_ITALICSENABLED) && - VerifyField(verifier, VT_STRIKETHROUGHENABLED) && verifier.EndTable(); - } +struct TextOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { + typedef TextOptionsBuilder Builder; + enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { + VT_WIDGETOPTIONS = 4, + VT_FONTRESOURCE = 6, + VT_FONTNAME = 8, + VT_FONTSIZE = 10, + VT_TEXT = 12, + VT_AREAWIDTH = 14, + VT_AREAHEIGHT = 16, + VT_HALIGNMENT = 18, + VT_VALIGNMENT = 20, + VT_TOUCHSCALEENABLE = 22, + VT_ISCUSTOMSIZE = 24, + VT_OUTLINEENABLED = 26, + VT_OUTLINECOLOR = 28, + VT_OUTLINESIZE = 30, + VT_SHADOWENABLED = 32, + VT_SHADOWCOLOR = 34, + VT_SHADOWOFFSETX = 36, + VT_SHADOWOFFSETY = 38, + VT_SHADOWBLURRADIUS = 40, + VT_ISLOCALIZED = 42, + VT_GLOWENABLED = 44, + VT_GLOWCOLOR = 46, + VT_BOLDENABLED = 48, + VT_UNDERLINEENABLED = 50, + VT_ITALICSENABLED = 52, + VT_STRIKETHROUGHENABLED = 54 + }; + const flatbuffers::WidgetOptions *widgetOptions() const { + return GetPointer(VT_WIDGETOPTIONS); + } + const flatbuffers::ResourceData *fontResource() const { + return GetPointer(VT_FONTRESOURCE); + } + const flatbuffers::String *fontName() const { + return GetPointer(VT_FONTNAME); + } + int32_t fontSize() const { + return GetField(VT_FONTSIZE, 0); + } + const flatbuffers::String *text() const { + return GetPointer(VT_TEXT); + } + int32_t areaWidth() const { + return GetField(VT_AREAWIDTH, 0); + } + int32_t areaHeight() const { + return GetField(VT_AREAHEIGHT, 0); + } + int32_t hAlignment() const { + return GetField(VT_HALIGNMENT, 0); + } + int32_t vAlignment() const { + return GetField(VT_VALIGNMENT, 0); + } + bool touchScaleEnable() const { + return GetField(VT_TOUCHSCALEENABLE, 0) != 0; + } + bool isCustomSize() const { + return GetField(VT_ISCUSTOMSIZE, 0) != 0; + } + bool outlineEnabled() const { + return GetField(VT_OUTLINEENABLED, 0) != 0; + } + const flatbuffers::Color *outlineColor() const { + return GetStruct(VT_OUTLINECOLOR); + } + int32_t outlineSize() const { + return GetField(VT_OUTLINESIZE, 1); + } + bool shadowEnabled() const { + return GetField(VT_SHADOWENABLED, 0) != 0; + } + const flatbuffers::Color *shadowColor() const { + return GetStruct(VT_SHADOWCOLOR); + } + float shadowOffsetX() const { + return GetField(VT_SHADOWOFFSETX, 2.0f); + } + float shadowOffsetY() const { + return GetField(VT_SHADOWOFFSETY, -2.0f); + } + int32_t shadowBlurRadius() const { + return GetField(VT_SHADOWBLURRADIUS, 0); + } + bool isLocalized() const { + return GetField(VT_ISLOCALIZED, 0) != 0; + } + bool glowEnabled() const { + return GetField(VT_GLOWENABLED, 0) != 0; + } + const flatbuffers::Color *glowColor() const { + return GetStruct(VT_GLOWCOLOR); + } + bool boldEnabled() const { + return GetField(VT_BOLDENABLED, 0) != 0; + } + bool underlineEnabled() const { + return GetField(VT_UNDERLINEENABLED, 0) != 0; + } + bool italicsEnabled() const { + return GetField(VT_ITALICSENABLED, 0) != 0; + } + bool strikethroughEnabled() const { + return GetField(VT_STRIKETHROUGHENABLED, 0) != 0; + } + bool Verify(flatbuffers::Verifier &verifier) const { + return VerifyTableStart(verifier) && + VerifyOffset(verifier, VT_WIDGETOPTIONS) && + verifier.VerifyTable(widgetOptions()) && + VerifyOffset(verifier, VT_FONTRESOURCE) && + verifier.VerifyTable(fontResource()) && + VerifyOffset(verifier, VT_FONTNAME) && + verifier.VerifyString(fontName()) && + VerifyField(verifier, VT_FONTSIZE, 4) && + VerifyOffset(verifier, VT_TEXT) && + verifier.VerifyString(text()) && + VerifyField(verifier, VT_AREAWIDTH, 4) && + VerifyField(verifier, VT_AREAHEIGHT, 4) && + VerifyField(verifier, VT_HALIGNMENT, 4) && + VerifyField(verifier, VT_VALIGNMENT, 4) && + VerifyField(verifier, VT_TOUCHSCALEENABLE, 1) && + VerifyField(verifier, VT_ISCUSTOMSIZE, 1) && + VerifyField(verifier, VT_OUTLINEENABLED, 1) && + VerifyField(verifier, VT_OUTLINECOLOR, 1) && + VerifyField(verifier, VT_OUTLINESIZE, 4) && + VerifyField(verifier, VT_SHADOWENABLED, 1) && + VerifyField(verifier, VT_SHADOWCOLOR, 1) && + VerifyField(verifier, VT_SHADOWOFFSETX, 4) && + VerifyField(verifier, VT_SHADOWOFFSETY, 4) && + VerifyField(verifier, VT_SHADOWBLURRADIUS, 4) && + VerifyField(verifier, VT_ISLOCALIZED, 1) && + VerifyField(verifier, VT_GLOWENABLED, 1) && + VerifyField(verifier, VT_GLOWCOLOR, 1) && + VerifyField(verifier, VT_BOLDENABLED, 1) && + VerifyField(verifier, VT_UNDERLINEENABLED, 1) && + VerifyField(verifier, VT_ITALICSENABLED, 1) && + VerifyField(verifier, VT_STRIKETHROUGHENABLED, 1) && + verifier.EndTable(); + } }; -struct TextOptionsBuilder -{ - flatbuffers::FlatBufferBuilder& fbb_; - flatbuffers::uoffset_t start_; - void add_widgetOptions(flatbuffers::Offset widgetOptions) - { - fbb_.AddOffset(TextOptions::VT_WIDGETOPTIONS, widgetOptions); - } - void add_fontResource(flatbuffers::Offset fontResource) - { - fbb_.AddOffset(TextOptions::VT_FONTRESOURCE, fontResource); - } - void add_fontName(flatbuffers::Offset fontName) - { - fbb_.AddOffset(TextOptions::VT_FONTNAME, fontName); - } - void add_fontSize(int32_t fontSize) { fbb_.AddElement(TextOptions::VT_FONTSIZE, fontSize, 0); } - void add_text(flatbuffers::Offset text) { fbb_.AddOffset(TextOptions::VT_TEXT, text); } - void add_areaWidth(int32_t areaWidth) { fbb_.AddElement(TextOptions::VT_AREAWIDTH, areaWidth, 0); } - void add_areaHeight(int32_t areaHeight) { fbb_.AddElement(TextOptions::VT_AREAHEIGHT, areaHeight, 0); } - void add_hAlignment(int32_t hAlignment) { fbb_.AddElement(TextOptions::VT_HALIGNMENT, hAlignment, 0); } - void add_vAlignment(int32_t vAlignment) { fbb_.AddElement(TextOptions::VT_VALIGNMENT, vAlignment, 0); } - void add_touchScaleEnable(bool touchScaleEnable) - { - fbb_.AddElement(TextOptions::VT_TOUCHSCALEENABLE, static_cast(touchScaleEnable), 0); - } - void add_isCustomSize(bool isCustomSize) - { - fbb_.AddElement(TextOptions::VT_ISCUSTOMSIZE, static_cast(isCustomSize), 0); - } - void add_outlineEnabled(bool outlineEnabled) - { - fbb_.AddElement(TextOptions::VT_OUTLINEENABLED, static_cast(outlineEnabled), 0); - } - void add_outlineColor(const Color* outlineColor) { fbb_.AddStruct(TextOptions::VT_OUTLINECOLOR, outlineColor); } - void add_outlineSize(int32_t outlineSize) { fbb_.AddElement(TextOptions::VT_OUTLINESIZE, outlineSize, 1); } - void add_shadowEnabled(bool shadowEnabled) - { - fbb_.AddElement(TextOptions::VT_SHADOWENABLED, static_cast(shadowEnabled), 0); - } - void add_shadowColor(const Color* shadowColor) { fbb_.AddStruct(TextOptions::VT_SHADOWCOLOR, shadowColor); } - void add_shadowOffsetX(float shadowOffsetX) - { - fbb_.AddElement(TextOptions::VT_SHADOWOFFSETX, shadowOffsetX, 2.0f); - } - void add_shadowOffsetY(float shadowOffsetY) - { - fbb_.AddElement(TextOptions::VT_SHADOWOFFSETY, shadowOffsetY, -2.0f); - } - void add_shadowBlurRadius(int32_t shadowBlurRadius) - { - fbb_.AddElement(TextOptions::VT_SHADOWBLURRADIUS, shadowBlurRadius, 0); - } - void add_isLocalized(bool isLocalized) - { - fbb_.AddElement(TextOptions::VT_ISLOCALIZED, static_cast(isLocalized), 0); - } - void add_glowEnabled(bool glowEnabled) - { - fbb_.AddElement(TextOptions::VT_GLOWENABLED, static_cast(glowEnabled), 0); - } - void add_glowColor(const Color* glowColor) { fbb_.AddStruct(TextOptions::VT_GLOWCOLOR, glowColor); } - void add_boldEnabled(bool boldEnabled) - { - fbb_.AddElement(TextOptions::VT_BOLDENABLED, static_cast(boldEnabled), 0); - } - void add_underlineEnabled(bool underlineEnabled) - { - fbb_.AddElement(TextOptions::VT_UNDERLINEENABLED, static_cast(underlineEnabled), 0); - } - void add_italicsEnabled(bool italicsEnabled) - { - fbb_.AddElement(TextOptions::VT_ITALICSENABLED, static_cast(italicsEnabled), 0); - } - void add_strikethroughEnabled(bool strikethroughEnabled) - { - fbb_.AddElement(TextOptions::VT_STRIKETHROUGHENABLED, static_cast(strikethroughEnabled), 0); - } - explicit TextOptionsBuilder(flatbuffers::FlatBufferBuilder& _fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } - TextOptionsBuilder& operator=(const TextOptionsBuilder&); - flatbuffers::Offset Finish() - { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset(end); - return o; - } +struct TextOptionsBuilder { + typedef TextOptions Table; + flatbuffers::FlatBufferBuilder &fbb_; + flatbuffers::uoffset_t start_; + void add_widgetOptions(flatbuffers::Offset widgetOptions) { + fbb_.AddOffset(TextOptions::VT_WIDGETOPTIONS, widgetOptions); + } + void add_fontResource(flatbuffers::Offset fontResource) { + fbb_.AddOffset(TextOptions::VT_FONTRESOURCE, fontResource); + } + void add_fontName(flatbuffers::Offset fontName) { + fbb_.AddOffset(TextOptions::VT_FONTNAME, fontName); + } + void add_fontSize(int32_t fontSize) { + fbb_.AddElement(TextOptions::VT_FONTSIZE, fontSize, 0); + } + void add_text(flatbuffers::Offset text) { + fbb_.AddOffset(TextOptions::VT_TEXT, text); + } + void add_areaWidth(int32_t areaWidth) { + fbb_.AddElement(TextOptions::VT_AREAWIDTH, areaWidth, 0); + } + void add_areaHeight(int32_t areaHeight) { + fbb_.AddElement(TextOptions::VT_AREAHEIGHT, areaHeight, 0); + } + void add_hAlignment(int32_t hAlignment) { + fbb_.AddElement(TextOptions::VT_HALIGNMENT, hAlignment, 0); + } + void add_vAlignment(int32_t vAlignment) { + fbb_.AddElement(TextOptions::VT_VALIGNMENT, vAlignment, 0); + } + void add_touchScaleEnable(bool touchScaleEnable) { + fbb_.AddElement(TextOptions::VT_TOUCHSCALEENABLE, static_cast(touchScaleEnable), 0); + } + void add_isCustomSize(bool isCustomSize) { + fbb_.AddElement(TextOptions::VT_ISCUSTOMSIZE, static_cast(isCustomSize), 0); + } + void add_outlineEnabled(bool outlineEnabled) { + fbb_.AddElement(TextOptions::VT_OUTLINEENABLED, static_cast(outlineEnabled), 0); + } + void add_outlineColor(const flatbuffers::Color *outlineColor) { + fbb_.AddStruct(TextOptions::VT_OUTLINECOLOR, outlineColor); + } + void add_outlineSize(int32_t outlineSize) { + fbb_.AddElement(TextOptions::VT_OUTLINESIZE, outlineSize, 1); + } + void add_shadowEnabled(bool shadowEnabled) { + fbb_.AddElement(TextOptions::VT_SHADOWENABLED, static_cast(shadowEnabled), 0); + } + void add_shadowColor(const flatbuffers::Color *shadowColor) { + fbb_.AddStruct(TextOptions::VT_SHADOWCOLOR, shadowColor); + } + void add_shadowOffsetX(float shadowOffsetX) { + fbb_.AddElement(TextOptions::VT_SHADOWOFFSETX, shadowOffsetX, 2.0f); + } + void add_shadowOffsetY(float shadowOffsetY) { + fbb_.AddElement(TextOptions::VT_SHADOWOFFSETY, shadowOffsetY, -2.0f); + } + void add_shadowBlurRadius(int32_t shadowBlurRadius) { + fbb_.AddElement(TextOptions::VT_SHADOWBLURRADIUS, shadowBlurRadius, 0); + } + void add_isLocalized(bool isLocalized) { + fbb_.AddElement(TextOptions::VT_ISLOCALIZED, static_cast(isLocalized), 0); + } + void add_glowEnabled(bool glowEnabled) { + fbb_.AddElement(TextOptions::VT_GLOWENABLED, static_cast(glowEnabled), 0); + } + void add_glowColor(const flatbuffers::Color *glowColor) { + fbb_.AddStruct(TextOptions::VT_GLOWCOLOR, glowColor); + } + void add_boldEnabled(bool boldEnabled) { + fbb_.AddElement(TextOptions::VT_BOLDENABLED, static_cast(boldEnabled), 0); + } + void add_underlineEnabled(bool underlineEnabled) { + fbb_.AddElement(TextOptions::VT_UNDERLINEENABLED, static_cast(underlineEnabled), 0); + } + void add_italicsEnabled(bool italicsEnabled) { + fbb_.AddElement(TextOptions::VT_ITALICSENABLED, static_cast(italicsEnabled), 0); + } + void add_strikethroughEnabled(bool strikethroughEnabled) { + fbb_.AddElement(TextOptions::VT_STRIKETHROUGHENABLED, static_cast(strikethroughEnabled), 0); + } + explicit TextOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) + : fbb_(_fbb) { + start_ = fbb_.StartTable(); + } + flatbuffers::Offset Finish() { + const auto end = fbb_.EndTable(start_); + auto o = flatbuffers::Offset(end); + return o; + } }; -inline flatbuffers::Offset CreateTextOptions(flatbuffers::FlatBufferBuilder& _fbb, - flatbuffers::Offset widgetOptions = 0, - flatbuffers::Offset fontResource = 0, - flatbuffers::Offset fontName = 0, - int32_t fontSize = 0, - flatbuffers::Offset text = 0, - int32_t areaWidth = 0, - int32_t areaHeight = 0, - int32_t hAlignment = 0, - int32_t vAlignment = 0, - bool touchScaleEnable = false, - bool isCustomSize = false, - bool outlineEnabled = false, - const Color* outlineColor = 0, - int32_t outlineSize = 1, - bool shadowEnabled = false, - const Color* shadowColor = 0, - float shadowOffsetX = 2.0f, - float shadowOffsetY = -2.0f, - int32_t shadowBlurRadius = 0, - bool isLocalized = false, - bool glowEnabled = false, - const Color* glowColor = 0, - bool boldEnabled = false, - bool underlineEnabled = false, - bool italicsEnabled = false, - bool strikethroughEnabled = false) -{ - TextOptionsBuilder builder_(_fbb); - builder_.add_glowColor(glowColor); - builder_.add_shadowBlurRadius(shadowBlurRadius); - builder_.add_shadowOffsetY(shadowOffsetY); - builder_.add_shadowOffsetX(shadowOffsetX); - builder_.add_shadowColor(shadowColor); - builder_.add_outlineSize(outlineSize); - builder_.add_outlineColor(outlineColor); - builder_.add_vAlignment(vAlignment); - builder_.add_hAlignment(hAlignment); - builder_.add_areaHeight(areaHeight); - builder_.add_areaWidth(areaWidth); - builder_.add_text(text); - builder_.add_fontSize(fontSize); - builder_.add_fontName(fontName); - builder_.add_fontResource(fontResource); - builder_.add_widgetOptions(widgetOptions); - builder_.add_strikethroughEnabled(strikethroughEnabled); - builder_.add_italicsEnabled(italicsEnabled); - builder_.add_underlineEnabled(underlineEnabled); - builder_.add_boldEnabled(boldEnabled); - builder_.add_glowEnabled(glowEnabled); - builder_.add_isLocalized(isLocalized); - builder_.add_shadowEnabled(shadowEnabled); - builder_.add_outlineEnabled(outlineEnabled); - builder_.add_isCustomSize(isCustomSize); - builder_.add_touchScaleEnable(touchScaleEnable); - return builder_.Finish(); +inline flatbuffers::Offset CreateTextOptions( + flatbuffers::FlatBufferBuilder &_fbb, + flatbuffers::Offset widgetOptions = 0, + flatbuffers::Offset fontResource = 0, + flatbuffers::Offset fontName = 0, + int32_t fontSize = 0, + flatbuffers::Offset text = 0, + int32_t areaWidth = 0, + int32_t areaHeight = 0, + int32_t hAlignment = 0, + int32_t vAlignment = 0, + bool touchScaleEnable = false, + bool isCustomSize = false, + bool outlineEnabled = false, + const flatbuffers::Color *outlineColor = nullptr, + int32_t outlineSize = 1, + bool shadowEnabled = false, + const flatbuffers::Color *shadowColor = nullptr, + float shadowOffsetX = 2.0f, + float shadowOffsetY = -2.0f, + int32_t shadowBlurRadius = 0, + bool isLocalized = false, + bool glowEnabled = false, + const flatbuffers::Color *glowColor = nullptr, + bool boldEnabled = false, + bool underlineEnabled = false, + bool italicsEnabled = false, + bool strikethroughEnabled = false) { + TextOptionsBuilder builder_(_fbb); + builder_.add_glowColor(glowColor); + builder_.add_shadowBlurRadius(shadowBlurRadius); + builder_.add_shadowOffsetY(shadowOffsetY); + builder_.add_shadowOffsetX(shadowOffsetX); + builder_.add_shadowColor(shadowColor); + builder_.add_outlineSize(outlineSize); + builder_.add_outlineColor(outlineColor); + builder_.add_vAlignment(vAlignment); + builder_.add_hAlignment(hAlignment); + builder_.add_areaHeight(areaHeight); + builder_.add_areaWidth(areaWidth); + builder_.add_text(text); + builder_.add_fontSize(fontSize); + builder_.add_fontName(fontName); + builder_.add_fontResource(fontResource); + builder_.add_widgetOptions(widgetOptions); + builder_.add_strikethroughEnabled(strikethroughEnabled); + builder_.add_italicsEnabled(italicsEnabled); + builder_.add_underlineEnabled(underlineEnabled); + builder_.add_boldEnabled(boldEnabled); + builder_.add_glowEnabled(glowEnabled); + builder_.add_isLocalized(isLocalized); + builder_.add_shadowEnabled(shadowEnabled); + builder_.add_outlineEnabled(outlineEnabled); + builder_.add_isCustomSize(isCustomSize); + builder_.add_touchScaleEnable(touchScaleEnable); + return builder_.Finish(); } -inline flatbuffers::Offset CreateTextOptionsDirect(flatbuffers::FlatBufferBuilder& _fbb, - flatbuffers::Offset widgetOptions = 0, - flatbuffers::Offset fontResource = 0, - const char* fontName = nullptr, - int32_t fontSize = 0, - const char* text = nullptr, - int32_t areaWidth = 0, - int32_t areaHeight = 0, - int32_t hAlignment = 0, - int32_t vAlignment = 0, - bool touchScaleEnable = false, - bool isCustomSize = false, - bool outlineEnabled = false, - const Color* outlineColor = 0, - int32_t outlineSize = 1, - bool shadowEnabled = false, - const Color* shadowColor = 0, - float shadowOffsetX = 2.0f, - float shadowOffsetY = -2.0f, - int32_t shadowBlurRadius = 0, - bool isLocalized = false, - bool glowEnabled = false, - const Color* glowColor = 0, - bool boldEnabled = false, - bool underlineEnabled = false, - bool italicsEnabled = false, - bool strikethroughEnabled = false) -{ - auto fontName__ = fontName ? _fbb.CreateString(fontName) : 0; - auto text__ = text ? _fbb.CreateString(text) : 0; - return flatbuffers::CreateTextOptions( - _fbb, widgetOptions, fontResource, fontName__, fontSize, text__, areaWidth, areaHeight, hAlignment, vAlignment, - touchScaleEnable, isCustomSize, outlineEnabled, outlineColor, outlineSize, shadowEnabled, shadowColor, - shadowOffsetX, shadowOffsetY, shadowBlurRadius, isLocalized, glowEnabled, glowColor, boldEnabled, - underlineEnabled, italicsEnabled, strikethroughEnabled); +inline flatbuffers::Offset CreateTextOptionsDirect( + flatbuffers::FlatBufferBuilder &_fbb, + flatbuffers::Offset widgetOptions = 0, + flatbuffers::Offset fontResource = 0, + const char *fontName = nullptr, + int32_t fontSize = 0, + const char *text = nullptr, + int32_t areaWidth = 0, + int32_t areaHeight = 0, + int32_t hAlignment = 0, + int32_t vAlignment = 0, + bool touchScaleEnable = false, + bool isCustomSize = false, + bool outlineEnabled = false, + const flatbuffers::Color *outlineColor = nullptr, + int32_t outlineSize = 1, + bool shadowEnabled = false, + const flatbuffers::Color *shadowColor = nullptr, + float shadowOffsetX = 2.0f, + float shadowOffsetY = -2.0f, + int32_t shadowBlurRadius = 0, + bool isLocalized = false, + bool glowEnabled = false, + const flatbuffers::Color *glowColor = nullptr, + bool boldEnabled = false, + bool underlineEnabled = false, + bool italicsEnabled = false, + bool strikethroughEnabled = false) { + auto fontName__ = fontName ? _fbb.CreateString(fontName) : 0; + auto text__ = text ? _fbb.CreateString(text) : 0; + return flatbuffers::CreateTextOptions( + _fbb, + widgetOptions, + fontResource, + fontName__, + fontSize, + text__, + areaWidth, + areaHeight, + hAlignment, + vAlignment, + touchScaleEnable, + isCustomSize, + outlineEnabled, + outlineColor, + outlineSize, + shadowEnabled, + shadowColor, + shadowOffsetX, + shadowOffsetY, + shadowBlurRadius, + isLocalized, + glowEnabled, + glowColor, + boldEnabled, + underlineEnabled, + italicsEnabled, + strikethroughEnabled); } -struct RichTextOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table -{ - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE - { - VT_WIDGETOPTIONS = 4, - VT_XMLDEFINITION = 6 - }; - const WidgetOptions* widgetOptions() const { return GetPointer(VT_WIDGETOPTIONS); } - const flatbuffers::String* xmlDefinition() const - { - return GetPointer(VT_XMLDEFINITION); - } - bool Verify(flatbuffers::Verifier& verifier) const - { - return VerifyTableStart(verifier) && VerifyOffset(verifier, VT_WIDGETOPTIONS) && - verifier.VerifyTable(widgetOptions()) && VerifyOffset(verifier, VT_XMLDEFINITION) && - verifier.VerifyString(xmlDefinition()) && verifier.EndTable(); - } +struct RichTextOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { + typedef RichTextOptionsBuilder Builder; + enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { + VT_WIDGETOPTIONS = 4, + VT_XMLDEFINITION = 6 + }; + const flatbuffers::WidgetOptions *widgetOptions() const { + return GetPointer(VT_WIDGETOPTIONS); + } + const flatbuffers::String *xmlDefinition() const { + return GetPointer(VT_XMLDEFINITION); + } + bool Verify(flatbuffers::Verifier &verifier) const { + return VerifyTableStart(verifier) && + VerifyOffset(verifier, VT_WIDGETOPTIONS) && + verifier.VerifyTable(widgetOptions()) && + VerifyOffset(verifier, VT_XMLDEFINITION) && + verifier.VerifyString(xmlDefinition()) && + verifier.EndTable(); + } }; -struct RichTextOptionsBuilder -{ - flatbuffers::FlatBufferBuilder& fbb_; - flatbuffers::uoffset_t start_; - void add_widgetOptions(flatbuffers::Offset widgetOptions) - { - fbb_.AddOffset(RichTextOptions::VT_WIDGETOPTIONS, widgetOptions); - } - void add_xmlDefinition(flatbuffers::Offset xmlDefinition) - { - fbb_.AddOffset(RichTextOptions::VT_XMLDEFINITION, xmlDefinition); - } - explicit RichTextOptionsBuilder(flatbuffers::FlatBufferBuilder& _fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } - RichTextOptionsBuilder& operator=(const RichTextOptionsBuilder&); - flatbuffers::Offset Finish() - { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset(end); - return o; - } +struct RichTextOptionsBuilder { + typedef RichTextOptions Table; + flatbuffers::FlatBufferBuilder &fbb_; + flatbuffers::uoffset_t start_; + void add_widgetOptions(flatbuffers::Offset widgetOptions) { + fbb_.AddOffset(RichTextOptions::VT_WIDGETOPTIONS, widgetOptions); + } + void add_xmlDefinition(flatbuffers::Offset xmlDefinition) { + fbb_.AddOffset(RichTextOptions::VT_XMLDEFINITION, xmlDefinition); + } + explicit RichTextOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) + : fbb_(_fbb) { + start_ = fbb_.StartTable(); + } + flatbuffers::Offset Finish() { + const auto end = fbb_.EndTable(start_); + auto o = flatbuffers::Offset(end); + return o; + } }; inline flatbuffers::Offset CreateRichTextOptions( - flatbuffers::FlatBufferBuilder& _fbb, - flatbuffers::Offset widgetOptions = 0, - flatbuffers::Offset xmlDefinition = 0) -{ - RichTextOptionsBuilder builder_(_fbb); - builder_.add_xmlDefinition(xmlDefinition); - builder_.add_widgetOptions(widgetOptions); - return builder_.Finish(); + flatbuffers::FlatBufferBuilder &_fbb, + flatbuffers::Offset widgetOptions = 0, + flatbuffers::Offset xmlDefinition = 0) { + RichTextOptionsBuilder builder_(_fbb); + builder_.add_xmlDefinition(xmlDefinition); + builder_.add_widgetOptions(widgetOptions); + return builder_.Finish(); } inline flatbuffers::Offset CreateRichTextOptionsDirect( - flatbuffers::FlatBufferBuilder& _fbb, - flatbuffers::Offset widgetOptions = 0, - const char* xmlDefinition = nullptr) -{ - auto xmlDefinition__ = xmlDefinition ? _fbb.CreateString(xmlDefinition) : 0; - return flatbuffers::CreateRichTextOptions(_fbb, widgetOptions, xmlDefinition__); + flatbuffers::FlatBufferBuilder &_fbb, + flatbuffers::Offset widgetOptions = 0, + const char *xmlDefinition = nullptr) { + auto xmlDefinition__ = xmlDefinition ? _fbb.CreateString(xmlDefinition) : 0; + return flatbuffers::CreateRichTextOptions( + _fbb, + widgetOptions, + xmlDefinition__); } -struct TextFieldOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table -{ - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE - { - VT_WIDGETOPTIONS = 4, - VT_FONTRESOURCE = 6, - VT_FONTNAME = 8, - VT_FONTSIZE = 10, - VT_TEXT = 12, - VT_PLACEHOLDER = 14, - VT_PASSWORDENABLED = 16, - VT_PASSWORDSTYLETEXT = 18, - VT_MAXLENGTHENABLED = 20, - VT_MAXLENGTH = 22, - VT_AREAWIDTH = 24, - VT_AREAHEIGHT = 26, - VT_ISCUSTOMSIZE = 28, - VT_ISLOCALIZED = 30 - }; - const WidgetOptions* widgetOptions() const { return GetPointer(VT_WIDGETOPTIONS); } - const ResourceData* fontResource() const { return GetPointer(VT_FONTRESOURCE); } - const flatbuffers::String* fontName() const { return GetPointer(VT_FONTNAME); } - int32_t fontSize() const { return GetField(VT_FONTSIZE, 0); } - const flatbuffers::String* text() const { return GetPointer(VT_TEXT); } - const flatbuffers::String* placeHolder() const { return GetPointer(VT_PLACEHOLDER); } - bool passwordEnabled() const { return GetField(VT_PASSWORDENABLED, 0) != 0; } - const flatbuffers::String* passwordStyleText() const - { - return GetPointer(VT_PASSWORDSTYLETEXT); - } - bool maxLengthEnabled() const { return GetField(VT_MAXLENGTHENABLED, 0) != 0; } - int32_t maxLength() const { return GetField(VT_MAXLENGTH, 0); } - int32_t areaWidth() const { return GetField(VT_AREAWIDTH, 0); } - int32_t areaHeight() const { return GetField(VT_AREAHEIGHT, 0); } - bool isCustomSize() const { return GetField(VT_ISCUSTOMSIZE, 0) != 0; } - bool isLocalized() const { return GetField(VT_ISLOCALIZED, 0) != 0; } - bool Verify(flatbuffers::Verifier& verifier) const - { - return VerifyTableStart(verifier) && VerifyOffset(verifier, VT_WIDGETOPTIONS) && - verifier.VerifyTable(widgetOptions()) && VerifyOffset(verifier, VT_FONTRESOURCE) && - verifier.VerifyTable(fontResource()) && VerifyOffset(verifier, VT_FONTNAME) && - verifier.VerifyString(fontName()) && VerifyField(verifier, VT_FONTSIZE) && - VerifyOffset(verifier, VT_TEXT) && verifier.VerifyString(text()) && - VerifyOffset(verifier, VT_PLACEHOLDER) && verifier.VerifyString(placeHolder()) && - VerifyField(verifier, VT_PASSWORDENABLED) && VerifyOffset(verifier, VT_PASSWORDSTYLETEXT) && - verifier.VerifyString(passwordStyleText()) && VerifyField(verifier, VT_MAXLENGTHENABLED) && - VerifyField(verifier, VT_MAXLENGTH) && VerifyField(verifier, VT_AREAWIDTH) && - VerifyField(verifier, VT_AREAHEIGHT) && VerifyField(verifier, VT_ISCUSTOMSIZE) && - VerifyField(verifier, VT_ISLOCALIZED) && verifier.EndTable(); - } +struct TextFieldOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { + typedef TextFieldOptionsBuilder Builder; + enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { + VT_WIDGETOPTIONS = 4, + VT_FONTRESOURCE = 6, + VT_FONTNAME = 8, + VT_FONTSIZE = 10, + VT_TEXT = 12, + VT_PLACEHOLDER = 14, + VT_PASSWORDENABLED = 16, + VT_PASSWORDSTYLETEXT = 18, + VT_MAXLENGTHENABLED = 20, + VT_MAXLENGTH = 22, + VT_AREAWIDTH = 24, + VT_AREAHEIGHT = 26, + VT_ISCUSTOMSIZE = 28, + VT_ISLOCALIZED = 30 + }; + const flatbuffers::WidgetOptions *widgetOptions() const { + return GetPointer(VT_WIDGETOPTIONS); + } + const flatbuffers::ResourceData *fontResource() const { + return GetPointer(VT_FONTRESOURCE); + } + const flatbuffers::String *fontName() const { + return GetPointer(VT_FONTNAME); + } + int32_t fontSize() const { + return GetField(VT_FONTSIZE, 0); + } + const flatbuffers::String *text() const { + return GetPointer(VT_TEXT); + } + const flatbuffers::String *placeHolder() const { + return GetPointer(VT_PLACEHOLDER); + } + bool passwordEnabled() const { + return GetField(VT_PASSWORDENABLED, 0) != 0; + } + const flatbuffers::String *passwordStyleText() const { + return GetPointer(VT_PASSWORDSTYLETEXT); + } + bool maxLengthEnabled() const { + return GetField(VT_MAXLENGTHENABLED, 0) != 0; + } + int32_t maxLength() const { + return GetField(VT_MAXLENGTH, 0); + } + int32_t areaWidth() const { + return GetField(VT_AREAWIDTH, 0); + } + int32_t areaHeight() const { + return GetField(VT_AREAHEIGHT, 0); + } + bool isCustomSize() const { + return GetField(VT_ISCUSTOMSIZE, 0) != 0; + } + bool isLocalized() const { + return GetField(VT_ISLOCALIZED, 0) != 0; + } + bool Verify(flatbuffers::Verifier &verifier) const { + return VerifyTableStart(verifier) && + VerifyOffset(verifier, VT_WIDGETOPTIONS) && + verifier.VerifyTable(widgetOptions()) && + VerifyOffset(verifier, VT_FONTRESOURCE) && + verifier.VerifyTable(fontResource()) && + VerifyOffset(verifier, VT_FONTNAME) && + verifier.VerifyString(fontName()) && + VerifyField(verifier, VT_FONTSIZE, 4) && + VerifyOffset(verifier, VT_TEXT) && + verifier.VerifyString(text()) && + VerifyOffset(verifier, VT_PLACEHOLDER) && + verifier.VerifyString(placeHolder()) && + VerifyField(verifier, VT_PASSWORDENABLED, 1) && + VerifyOffset(verifier, VT_PASSWORDSTYLETEXT) && + verifier.VerifyString(passwordStyleText()) && + VerifyField(verifier, VT_MAXLENGTHENABLED, 1) && + VerifyField(verifier, VT_MAXLENGTH, 4) && + VerifyField(verifier, VT_AREAWIDTH, 4) && + VerifyField(verifier, VT_AREAHEIGHT, 4) && + VerifyField(verifier, VT_ISCUSTOMSIZE, 1) && + VerifyField(verifier, VT_ISLOCALIZED, 1) && + verifier.EndTable(); + } }; -struct TextFieldOptionsBuilder -{ - flatbuffers::FlatBufferBuilder& fbb_; - flatbuffers::uoffset_t start_; - void add_widgetOptions(flatbuffers::Offset widgetOptions) - { - fbb_.AddOffset(TextFieldOptions::VT_WIDGETOPTIONS, widgetOptions); - } - void add_fontResource(flatbuffers::Offset fontResource) - { - fbb_.AddOffset(TextFieldOptions::VT_FONTRESOURCE, fontResource); - } - void add_fontName(flatbuffers::Offset fontName) - { - fbb_.AddOffset(TextFieldOptions::VT_FONTNAME, fontName); - } - void add_fontSize(int32_t fontSize) { fbb_.AddElement(TextFieldOptions::VT_FONTSIZE, fontSize, 0); } - void add_text(flatbuffers::Offset text) { fbb_.AddOffset(TextFieldOptions::VT_TEXT, text); } - void add_placeHolder(flatbuffers::Offset placeHolder) - { - fbb_.AddOffset(TextFieldOptions::VT_PLACEHOLDER, placeHolder); - } - void add_passwordEnabled(bool passwordEnabled) - { - fbb_.AddElement(TextFieldOptions::VT_PASSWORDENABLED, static_cast(passwordEnabled), 0); - } - void add_passwordStyleText(flatbuffers::Offset passwordStyleText) - { - fbb_.AddOffset(TextFieldOptions::VT_PASSWORDSTYLETEXT, passwordStyleText); - } - void add_maxLengthEnabled(bool maxLengthEnabled) - { - fbb_.AddElement(TextFieldOptions::VT_MAXLENGTHENABLED, static_cast(maxLengthEnabled), 0); - } - void add_maxLength(int32_t maxLength) { fbb_.AddElement(TextFieldOptions::VT_MAXLENGTH, maxLength, 0); } - void add_areaWidth(int32_t areaWidth) { fbb_.AddElement(TextFieldOptions::VT_AREAWIDTH, areaWidth, 0); } - void add_areaHeight(int32_t areaHeight) - { - fbb_.AddElement(TextFieldOptions::VT_AREAHEIGHT, areaHeight, 0); - } - void add_isCustomSize(bool isCustomSize) - { - fbb_.AddElement(TextFieldOptions::VT_ISCUSTOMSIZE, static_cast(isCustomSize), 0); - } - void add_isLocalized(bool isLocalized) - { - fbb_.AddElement(TextFieldOptions::VT_ISLOCALIZED, static_cast(isLocalized), 0); - } - explicit TextFieldOptionsBuilder(flatbuffers::FlatBufferBuilder& _fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } - TextFieldOptionsBuilder& operator=(const TextFieldOptionsBuilder&); - flatbuffers::Offset Finish() - { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset(end); - return o; - } +struct TextFieldOptionsBuilder { + typedef TextFieldOptions Table; + flatbuffers::FlatBufferBuilder &fbb_; + flatbuffers::uoffset_t start_; + void add_widgetOptions(flatbuffers::Offset widgetOptions) { + fbb_.AddOffset(TextFieldOptions::VT_WIDGETOPTIONS, widgetOptions); + } + void add_fontResource(flatbuffers::Offset fontResource) { + fbb_.AddOffset(TextFieldOptions::VT_FONTRESOURCE, fontResource); + } + void add_fontName(flatbuffers::Offset fontName) { + fbb_.AddOffset(TextFieldOptions::VT_FONTNAME, fontName); + } + void add_fontSize(int32_t fontSize) { + fbb_.AddElement(TextFieldOptions::VT_FONTSIZE, fontSize, 0); + } + void add_text(flatbuffers::Offset text) { + fbb_.AddOffset(TextFieldOptions::VT_TEXT, text); + } + void add_placeHolder(flatbuffers::Offset placeHolder) { + fbb_.AddOffset(TextFieldOptions::VT_PLACEHOLDER, placeHolder); + } + void add_passwordEnabled(bool passwordEnabled) { + fbb_.AddElement(TextFieldOptions::VT_PASSWORDENABLED, static_cast(passwordEnabled), 0); + } + void add_passwordStyleText(flatbuffers::Offset passwordStyleText) { + fbb_.AddOffset(TextFieldOptions::VT_PASSWORDSTYLETEXT, passwordStyleText); + } + void add_maxLengthEnabled(bool maxLengthEnabled) { + fbb_.AddElement(TextFieldOptions::VT_MAXLENGTHENABLED, static_cast(maxLengthEnabled), 0); + } + void add_maxLength(int32_t maxLength) { + fbb_.AddElement(TextFieldOptions::VT_MAXLENGTH, maxLength, 0); + } + void add_areaWidth(int32_t areaWidth) { + fbb_.AddElement(TextFieldOptions::VT_AREAWIDTH, areaWidth, 0); + } + void add_areaHeight(int32_t areaHeight) { + fbb_.AddElement(TextFieldOptions::VT_AREAHEIGHT, areaHeight, 0); + } + void add_isCustomSize(bool isCustomSize) { + fbb_.AddElement(TextFieldOptions::VT_ISCUSTOMSIZE, static_cast(isCustomSize), 0); + } + void add_isLocalized(bool isLocalized) { + fbb_.AddElement(TextFieldOptions::VT_ISLOCALIZED, static_cast(isLocalized), 0); + } + explicit TextFieldOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) + : fbb_(_fbb) { + start_ = fbb_.StartTable(); + } + flatbuffers::Offset Finish() { + const auto end = fbb_.EndTable(start_); + auto o = flatbuffers::Offset(end); + return o; + } }; inline flatbuffers::Offset CreateTextFieldOptions( - flatbuffers::FlatBufferBuilder& _fbb, - flatbuffers::Offset widgetOptions = 0, - flatbuffers::Offset fontResource = 0, - flatbuffers::Offset fontName = 0, - int32_t fontSize = 0, - flatbuffers::Offset text = 0, - flatbuffers::Offset placeHolder = 0, - bool passwordEnabled = false, + flatbuffers::FlatBufferBuilder &_fbb, + flatbuffers::Offset widgetOptions = 0, + flatbuffers::Offset fontResource = 0, + flatbuffers::Offset fontName = 0, + int32_t fontSize = 0, + flatbuffers::Offset text = 0, + flatbuffers::Offset placeHolder = 0, + bool passwordEnabled = false, flatbuffers::Offset passwordStyleText = 0, - bool maxLengthEnabled = false, - int32_t maxLength = 0, - int32_t areaWidth = 0, - int32_t areaHeight = 0, - bool isCustomSize = false, - bool isLocalized = false) -{ - TextFieldOptionsBuilder builder_(_fbb); - builder_.add_areaHeight(areaHeight); - builder_.add_areaWidth(areaWidth); - builder_.add_maxLength(maxLength); - builder_.add_passwordStyleText(passwordStyleText); - builder_.add_placeHolder(placeHolder); - builder_.add_text(text); - builder_.add_fontSize(fontSize); - builder_.add_fontName(fontName); - builder_.add_fontResource(fontResource); - builder_.add_widgetOptions(widgetOptions); - builder_.add_isLocalized(isLocalized); - builder_.add_isCustomSize(isCustomSize); - builder_.add_maxLengthEnabled(maxLengthEnabled); - builder_.add_passwordEnabled(passwordEnabled); - return builder_.Finish(); + bool maxLengthEnabled = false, + int32_t maxLength = 0, + int32_t areaWidth = 0, + int32_t areaHeight = 0, + bool isCustomSize = false, + bool isLocalized = false) { + TextFieldOptionsBuilder builder_(_fbb); + builder_.add_areaHeight(areaHeight); + builder_.add_areaWidth(areaWidth); + builder_.add_maxLength(maxLength); + builder_.add_passwordStyleText(passwordStyleText); + builder_.add_placeHolder(placeHolder); + builder_.add_text(text); + builder_.add_fontSize(fontSize); + builder_.add_fontName(fontName); + builder_.add_fontResource(fontResource); + builder_.add_widgetOptions(widgetOptions); + builder_.add_isLocalized(isLocalized); + builder_.add_isCustomSize(isCustomSize); + builder_.add_maxLengthEnabled(maxLengthEnabled); + builder_.add_passwordEnabled(passwordEnabled); + return builder_.Finish(); } inline flatbuffers::Offset CreateTextFieldOptionsDirect( - flatbuffers::FlatBufferBuilder& _fbb, - flatbuffers::Offset widgetOptions = 0, - flatbuffers::Offset fontResource = 0, - const char* fontName = nullptr, - int32_t fontSize = 0, - const char* text = nullptr, - const char* placeHolder = nullptr, - bool passwordEnabled = false, - const char* passwordStyleText = nullptr, - bool maxLengthEnabled = false, - int32_t maxLength = 0, - int32_t areaWidth = 0, - int32_t areaHeight = 0, - bool isCustomSize = false, - bool isLocalized = false) -{ - auto fontName__ = fontName ? _fbb.CreateString(fontName) : 0; - auto text__ = text ? _fbb.CreateString(text) : 0; - auto placeHolder__ = placeHolder ? _fbb.CreateString(placeHolder) : 0; - auto passwordStyleText__ = passwordStyleText ? _fbb.CreateString(passwordStyleText) : 0; - return flatbuffers::CreateTextFieldOptions(_fbb, widgetOptions, fontResource, fontName__, fontSize, text__, - placeHolder__, passwordEnabled, passwordStyleText__, maxLengthEnabled, - maxLength, areaWidth, areaHeight, isCustomSize, isLocalized); + flatbuffers::FlatBufferBuilder &_fbb, + flatbuffers::Offset widgetOptions = 0, + flatbuffers::Offset fontResource = 0, + const char *fontName = nullptr, + int32_t fontSize = 0, + const char *text = nullptr, + const char *placeHolder = nullptr, + bool passwordEnabled = false, + const char *passwordStyleText = nullptr, + bool maxLengthEnabled = false, + int32_t maxLength = 0, + int32_t areaWidth = 0, + int32_t areaHeight = 0, + bool isCustomSize = false, + bool isLocalized = false) { + auto fontName__ = fontName ? _fbb.CreateString(fontName) : 0; + auto text__ = text ? _fbb.CreateString(text) : 0; + auto placeHolder__ = placeHolder ? _fbb.CreateString(placeHolder) : 0; + auto passwordStyleText__ = passwordStyleText ? _fbb.CreateString(passwordStyleText) : 0; + return flatbuffers::CreateTextFieldOptions( + _fbb, + widgetOptions, + fontResource, + fontName__, + fontSize, + text__, + placeHolder__, + passwordEnabled, + passwordStyleText__, + maxLengthEnabled, + maxLength, + areaWidth, + areaHeight, + isCustomSize, + isLocalized); } -struct LoadingBarOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table -{ - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE - { - VT_WIDGETOPTIONS = 4, - VT_TEXTUREDATA = 6, - VT_PERCENT = 8, - VT_DIRECTION = 10 - }; - const WidgetOptions* widgetOptions() const { return GetPointer(VT_WIDGETOPTIONS); } - const ResourceData* textureData() const { return GetPointer(VT_TEXTUREDATA); } - int32_t percent() const { return GetField(VT_PERCENT, 80); } - int32_t direction() const { return GetField(VT_DIRECTION, 0); } - bool Verify(flatbuffers::Verifier& verifier) const - { - return VerifyTableStart(verifier) && VerifyOffset(verifier, VT_WIDGETOPTIONS) && - verifier.VerifyTable(widgetOptions()) && VerifyOffset(verifier, VT_TEXTUREDATA) && - verifier.VerifyTable(textureData()) && VerifyField(verifier, VT_PERCENT) && - VerifyField(verifier, VT_DIRECTION) && verifier.EndTable(); - } +struct LoadingBarOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { + typedef LoadingBarOptionsBuilder Builder; + enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { + VT_WIDGETOPTIONS = 4, + VT_TEXTUREDATA = 6, + VT_PERCENT = 8, + VT_DIRECTION = 10 + }; + const flatbuffers::WidgetOptions *widgetOptions() const { + return GetPointer(VT_WIDGETOPTIONS); + } + const flatbuffers::ResourceData *textureData() const { + return GetPointer(VT_TEXTUREDATA); + } + int32_t percent() const { + return GetField(VT_PERCENT, 80); + } + int32_t direction() const { + return GetField(VT_DIRECTION, 0); + } + bool Verify(flatbuffers::Verifier &verifier) const { + return VerifyTableStart(verifier) && + VerifyOffset(verifier, VT_WIDGETOPTIONS) && + verifier.VerifyTable(widgetOptions()) && + VerifyOffset(verifier, VT_TEXTUREDATA) && + verifier.VerifyTable(textureData()) && + VerifyField(verifier, VT_PERCENT, 4) && + VerifyField(verifier, VT_DIRECTION, 4) && + verifier.EndTable(); + } }; -struct LoadingBarOptionsBuilder -{ - flatbuffers::FlatBufferBuilder& fbb_; - flatbuffers::uoffset_t start_; - void add_widgetOptions(flatbuffers::Offset widgetOptions) - { - fbb_.AddOffset(LoadingBarOptions::VT_WIDGETOPTIONS, widgetOptions); - } - void add_textureData(flatbuffers::Offset textureData) - { - fbb_.AddOffset(LoadingBarOptions::VT_TEXTUREDATA, textureData); - } - void add_percent(int32_t percent) { fbb_.AddElement(LoadingBarOptions::VT_PERCENT, percent, 80); } - void add_direction(int32_t direction) { fbb_.AddElement(LoadingBarOptions::VT_DIRECTION, direction, 0); } - explicit LoadingBarOptionsBuilder(flatbuffers::FlatBufferBuilder& _fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } - LoadingBarOptionsBuilder& operator=(const LoadingBarOptionsBuilder&); - flatbuffers::Offset Finish() - { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset(end); - return o; - } +struct LoadingBarOptionsBuilder { + typedef LoadingBarOptions Table; + flatbuffers::FlatBufferBuilder &fbb_; + flatbuffers::uoffset_t start_; + void add_widgetOptions(flatbuffers::Offset widgetOptions) { + fbb_.AddOffset(LoadingBarOptions::VT_WIDGETOPTIONS, widgetOptions); + } + void add_textureData(flatbuffers::Offset textureData) { + fbb_.AddOffset(LoadingBarOptions::VT_TEXTUREDATA, textureData); + } + void add_percent(int32_t percent) { + fbb_.AddElement(LoadingBarOptions::VT_PERCENT, percent, 80); + } + void add_direction(int32_t direction) { + fbb_.AddElement(LoadingBarOptions::VT_DIRECTION, direction, 0); + } + explicit LoadingBarOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) + : fbb_(_fbb) { + start_ = fbb_.StartTable(); + } + flatbuffers::Offset Finish() { + const auto end = fbb_.EndTable(start_); + auto o = flatbuffers::Offset(end); + return o; + } }; inline flatbuffers::Offset CreateLoadingBarOptions( - flatbuffers::FlatBufferBuilder& _fbb, - flatbuffers::Offset widgetOptions = 0, - flatbuffers::Offset textureData = 0, - int32_t percent = 80, - int32_t direction = 0) -{ - LoadingBarOptionsBuilder builder_(_fbb); - builder_.add_direction(direction); - builder_.add_percent(percent); - builder_.add_textureData(textureData); - builder_.add_widgetOptions(widgetOptions); - return builder_.Finish(); + flatbuffers::FlatBufferBuilder &_fbb, + flatbuffers::Offset widgetOptions = 0, + flatbuffers::Offset textureData = 0, + int32_t percent = 80, + int32_t direction = 0) { + LoadingBarOptionsBuilder builder_(_fbb); + builder_.add_direction(direction); + builder_.add_percent(percent); + builder_.add_textureData(textureData); + builder_.add_widgetOptions(widgetOptions); + return builder_.Finish(); } -struct SliderOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table -{ - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE - { - VT_WIDGETOPTIONS = 4, - VT_BARFILENAMEDATA = 6, - VT_BALLNORMALDATA = 8, - VT_BALLPRESSEDDATA = 10, - VT_BALLDISABLEDDATA = 12, - VT_PROGRESSBARDATA = 14, - VT_PERCENT = 16, - VT_DISPLAYSTATE = 18 - }; - const WidgetOptions* widgetOptions() const { return GetPointer(VT_WIDGETOPTIONS); } - const ResourceData* barFileNameData() const { return GetPointer(VT_BARFILENAMEDATA); } - const ResourceData* ballNormalData() const { return GetPointer(VT_BALLNORMALDATA); } - const ResourceData* ballPressedData() const { return GetPointer(VT_BALLPRESSEDDATA); } - const ResourceData* ballDisabledData() const { return GetPointer(VT_BALLDISABLEDDATA); } - const ResourceData* progressBarData() const { return GetPointer(VT_PROGRESSBARDATA); } - int32_t percent() const { return GetField(VT_PERCENT, 50); } - bool displaystate() const { return GetField(VT_DISPLAYSTATE, 1) != 0; } - bool Verify(flatbuffers::Verifier& verifier) const - { - return VerifyTableStart(verifier) && VerifyOffset(verifier, VT_WIDGETOPTIONS) && - verifier.VerifyTable(widgetOptions()) && VerifyOffset(verifier, VT_BARFILENAMEDATA) && - verifier.VerifyTable(barFileNameData()) && VerifyOffset(verifier, VT_BALLNORMALDATA) && - verifier.VerifyTable(ballNormalData()) && VerifyOffset(verifier, VT_BALLPRESSEDDATA) && - verifier.VerifyTable(ballPressedData()) && VerifyOffset(verifier, VT_BALLDISABLEDDATA) && - verifier.VerifyTable(ballDisabledData()) && VerifyOffset(verifier, VT_PROGRESSBARDATA) && - verifier.VerifyTable(progressBarData()) && VerifyField(verifier, VT_PERCENT) && - VerifyField(verifier, VT_DISPLAYSTATE) && verifier.EndTable(); - } +struct SliderOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { + typedef SliderOptionsBuilder Builder; + enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { + VT_WIDGETOPTIONS = 4, + VT_BARFILENAMEDATA = 6, + VT_BALLNORMALDATA = 8, + VT_BALLPRESSEDDATA = 10, + VT_BALLDISABLEDDATA = 12, + VT_PROGRESSBARDATA = 14, + VT_PERCENT = 16, + VT_DISPLAYSTATE = 18 + }; + const flatbuffers::WidgetOptions *widgetOptions() const { + return GetPointer(VT_WIDGETOPTIONS); + } + const flatbuffers::ResourceData *barFileNameData() const { + return GetPointer(VT_BARFILENAMEDATA); + } + const flatbuffers::ResourceData *ballNormalData() const { + return GetPointer(VT_BALLNORMALDATA); + } + const flatbuffers::ResourceData *ballPressedData() const { + return GetPointer(VT_BALLPRESSEDDATA); + } + const flatbuffers::ResourceData *ballDisabledData() const { + return GetPointer(VT_BALLDISABLEDDATA); + } + const flatbuffers::ResourceData *progressBarData() const { + return GetPointer(VT_PROGRESSBARDATA); + } + int32_t percent() const { + return GetField(VT_PERCENT, 50); + } + bool displaystate() const { + return GetField(VT_DISPLAYSTATE, 1) != 0; + } + bool Verify(flatbuffers::Verifier &verifier) const { + return VerifyTableStart(verifier) && + VerifyOffset(verifier, VT_WIDGETOPTIONS) && + verifier.VerifyTable(widgetOptions()) && + VerifyOffset(verifier, VT_BARFILENAMEDATA) && + verifier.VerifyTable(barFileNameData()) && + VerifyOffset(verifier, VT_BALLNORMALDATA) && + verifier.VerifyTable(ballNormalData()) && + VerifyOffset(verifier, VT_BALLPRESSEDDATA) && + verifier.VerifyTable(ballPressedData()) && + VerifyOffset(verifier, VT_BALLDISABLEDDATA) && + verifier.VerifyTable(ballDisabledData()) && + VerifyOffset(verifier, VT_PROGRESSBARDATA) && + verifier.VerifyTable(progressBarData()) && + VerifyField(verifier, VT_PERCENT, 4) && + VerifyField(verifier, VT_DISPLAYSTATE, 1) && + verifier.EndTable(); + } }; -struct SliderOptionsBuilder -{ - flatbuffers::FlatBufferBuilder& fbb_; - flatbuffers::uoffset_t start_; - void add_widgetOptions(flatbuffers::Offset widgetOptions) - { - fbb_.AddOffset(SliderOptions::VT_WIDGETOPTIONS, widgetOptions); - } - void add_barFileNameData(flatbuffers::Offset barFileNameData) - { - fbb_.AddOffset(SliderOptions::VT_BARFILENAMEDATA, barFileNameData); - } - void add_ballNormalData(flatbuffers::Offset ballNormalData) - { - fbb_.AddOffset(SliderOptions::VT_BALLNORMALDATA, ballNormalData); - } - void add_ballPressedData(flatbuffers::Offset ballPressedData) - { - fbb_.AddOffset(SliderOptions::VT_BALLPRESSEDDATA, ballPressedData); - } - void add_ballDisabledData(flatbuffers::Offset ballDisabledData) - { - fbb_.AddOffset(SliderOptions::VT_BALLDISABLEDDATA, ballDisabledData); - } - void add_progressBarData(flatbuffers::Offset progressBarData) - { - fbb_.AddOffset(SliderOptions::VT_PROGRESSBARDATA, progressBarData); - } - void add_percent(int32_t percent) { fbb_.AddElement(SliderOptions::VT_PERCENT, percent, 50); } - void add_displaystate(bool displaystate) - { - fbb_.AddElement(SliderOptions::VT_DISPLAYSTATE, static_cast(displaystate), 1); - } - explicit SliderOptionsBuilder(flatbuffers::FlatBufferBuilder& _fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } - SliderOptionsBuilder& operator=(const SliderOptionsBuilder&); - flatbuffers::Offset Finish() - { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset(end); - return o; - } +struct SliderOptionsBuilder { + typedef SliderOptions Table; + flatbuffers::FlatBufferBuilder &fbb_; + flatbuffers::uoffset_t start_; + void add_widgetOptions(flatbuffers::Offset widgetOptions) { + fbb_.AddOffset(SliderOptions::VT_WIDGETOPTIONS, widgetOptions); + } + void add_barFileNameData(flatbuffers::Offset barFileNameData) { + fbb_.AddOffset(SliderOptions::VT_BARFILENAMEDATA, barFileNameData); + } + void add_ballNormalData(flatbuffers::Offset ballNormalData) { + fbb_.AddOffset(SliderOptions::VT_BALLNORMALDATA, ballNormalData); + } + void add_ballPressedData(flatbuffers::Offset ballPressedData) { + fbb_.AddOffset(SliderOptions::VT_BALLPRESSEDDATA, ballPressedData); + } + void add_ballDisabledData(flatbuffers::Offset ballDisabledData) { + fbb_.AddOffset(SliderOptions::VT_BALLDISABLEDDATA, ballDisabledData); + } + void add_progressBarData(flatbuffers::Offset progressBarData) { + fbb_.AddOffset(SliderOptions::VT_PROGRESSBARDATA, progressBarData); + } + void add_percent(int32_t percent) { + fbb_.AddElement(SliderOptions::VT_PERCENT, percent, 50); + } + void add_displaystate(bool displaystate) { + fbb_.AddElement(SliderOptions::VT_DISPLAYSTATE, static_cast(displaystate), 1); + } + explicit SliderOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) + : fbb_(_fbb) { + start_ = fbb_.StartTable(); + } + flatbuffers::Offset Finish() { + const auto end = fbb_.EndTable(start_); + auto o = flatbuffers::Offset(end); + return o; + } }; -inline flatbuffers::Offset CreateSliderOptions(flatbuffers::FlatBufferBuilder& _fbb, - flatbuffers::Offset widgetOptions = 0, - flatbuffers::Offset barFileNameData = 0, - flatbuffers::Offset ballNormalData = 0, - flatbuffers::Offset ballPressedData = 0, - flatbuffers::Offset ballDisabledData = 0, - flatbuffers::Offset progressBarData = 0, - int32_t percent = 50, - bool displaystate = true) -{ - SliderOptionsBuilder builder_(_fbb); - builder_.add_percent(percent); - builder_.add_progressBarData(progressBarData); - builder_.add_ballDisabledData(ballDisabledData); - builder_.add_ballPressedData(ballPressedData); - builder_.add_ballNormalData(ballNormalData); - builder_.add_barFileNameData(barFileNameData); - builder_.add_widgetOptions(widgetOptions); - builder_.add_displaystate(displaystate); - return builder_.Finish(); +inline flatbuffers::Offset CreateSliderOptions( + flatbuffers::FlatBufferBuilder &_fbb, + flatbuffers::Offset widgetOptions = 0, + flatbuffers::Offset barFileNameData = 0, + flatbuffers::Offset ballNormalData = 0, + flatbuffers::Offset ballPressedData = 0, + flatbuffers::Offset ballDisabledData = 0, + flatbuffers::Offset progressBarData = 0, + int32_t percent = 50, + bool displaystate = true) { + SliderOptionsBuilder builder_(_fbb); + builder_.add_percent(percent); + builder_.add_progressBarData(progressBarData); + builder_.add_ballDisabledData(ballDisabledData); + builder_.add_ballPressedData(ballPressedData); + builder_.add_ballNormalData(ballNormalData); + builder_.add_barFileNameData(barFileNameData); + builder_.add_widgetOptions(widgetOptions); + builder_.add_displaystate(displaystate); + return builder_.Finish(); } -struct PanelOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table -{ - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE - { - VT_WIDGETOPTIONS = 4, - VT_BACKGROUNDIMAGEDATA = 6, - VT_CLIPENABLED = 8, - VT_BGCOLOR = 10, - VT_BGSTARTCOLOR = 12, - VT_BGENDCOLOR = 14, - VT_COLORTYPE = 16, - VT_BGCOLOROPACITY = 18, - VT_COLORVECTOR = 20, - VT_CAPINSETS = 22, - VT_SCALE9SIZE = 24, - VT_BACKGROUNDSCALE9ENABLED = 26 - }; - const WidgetOptions* widgetOptions() const { return GetPointer(VT_WIDGETOPTIONS); } - const ResourceData* backGroundImageData() const { return GetPointer(VT_BACKGROUNDIMAGEDATA); } - bool clipEnabled() const { return GetField(VT_CLIPENABLED, 0) != 0; } - const Color* bgColor() const { return GetStruct(VT_BGCOLOR); } - const Color* bgStartColor() const { return GetStruct(VT_BGSTARTCOLOR); } - const Color* bgEndColor() const { return GetStruct(VT_BGENDCOLOR); } - int32_t colorType() const { return GetField(VT_COLORTYPE, 0); } - uint8_t bgColorOpacity() const { return GetField(VT_BGCOLOROPACITY, 255); } - const ColorVector* colorVector() const { return GetStruct(VT_COLORVECTOR); } - const CapInsets* capInsets() const { return GetStruct(VT_CAPINSETS); } - const FlatSize* scale9Size() const { return GetStruct(VT_SCALE9SIZE); } - bool backGroundScale9Enabled() const { return GetField(VT_BACKGROUNDSCALE9ENABLED, 0) != 0; } - bool Verify(flatbuffers::Verifier& verifier) const - { - return VerifyTableStart(verifier) && VerifyOffset(verifier, VT_WIDGETOPTIONS) && - verifier.VerifyTable(widgetOptions()) && VerifyOffset(verifier, VT_BACKGROUNDIMAGEDATA) && - verifier.VerifyTable(backGroundImageData()) && VerifyField(verifier, VT_CLIPENABLED) && - VerifyField(verifier, VT_BGCOLOR) && VerifyField(verifier, VT_BGSTARTCOLOR) && - VerifyField(verifier, VT_BGENDCOLOR) && VerifyField(verifier, VT_COLORTYPE) && - VerifyField(verifier, VT_BGCOLOROPACITY) && - VerifyField(verifier, VT_COLORVECTOR) && VerifyField(verifier, VT_CAPINSETS) && - VerifyField(verifier, VT_SCALE9SIZE) && - VerifyField(verifier, VT_BACKGROUNDSCALE9ENABLED) && verifier.EndTable(); - } +struct PanelOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { + typedef PanelOptionsBuilder Builder; + enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { + VT_WIDGETOPTIONS = 4, + VT_BACKGROUNDIMAGEDATA = 6, + VT_CLIPENABLED = 8, + VT_BGCOLOR = 10, + VT_BGSTARTCOLOR = 12, + VT_BGENDCOLOR = 14, + VT_COLORTYPE = 16, + VT_BGCOLOROPACITY = 18, + VT_COLORVECTOR = 20, + VT_CAPINSETS = 22, + VT_SCALE9SIZE = 24, + VT_BACKGROUNDSCALE9ENABLED = 26 + }; + const flatbuffers::WidgetOptions *widgetOptions() const { + return GetPointer(VT_WIDGETOPTIONS); + } + const flatbuffers::ResourceData *backGroundImageData() const { + return GetPointer(VT_BACKGROUNDIMAGEDATA); + } + bool clipEnabled() const { + return GetField(VT_CLIPENABLED, 0) != 0; + } + const flatbuffers::Color *bgColor() const { + return GetStruct(VT_BGCOLOR); + } + const flatbuffers::Color *bgStartColor() const { + return GetStruct(VT_BGSTARTCOLOR); + } + const flatbuffers::Color *bgEndColor() const { + return GetStruct(VT_BGENDCOLOR); + } + int32_t colorType() const { + return GetField(VT_COLORTYPE, 0); + } + uint8_t bgColorOpacity() const { + return GetField(VT_BGCOLOROPACITY, 255); + } + const flatbuffers::ColorVector *colorVector() const { + return GetStruct(VT_COLORVECTOR); + } + const flatbuffers::CapInsets *capInsets() const { + return GetStruct(VT_CAPINSETS); + } + const flatbuffers::FlatSize *scale9Size() const { + return GetStruct(VT_SCALE9SIZE); + } + bool backGroundScale9Enabled() const { + return GetField(VT_BACKGROUNDSCALE9ENABLED, 0) != 0; + } + bool Verify(flatbuffers::Verifier &verifier) const { + return VerifyTableStart(verifier) && + VerifyOffset(verifier, VT_WIDGETOPTIONS) && + verifier.VerifyTable(widgetOptions()) && + VerifyOffset(verifier, VT_BACKGROUNDIMAGEDATA) && + verifier.VerifyTable(backGroundImageData()) && + VerifyField(verifier, VT_CLIPENABLED, 1) && + VerifyField(verifier, VT_BGCOLOR, 1) && + VerifyField(verifier, VT_BGSTARTCOLOR, 1) && + VerifyField(verifier, VT_BGENDCOLOR, 1) && + VerifyField(verifier, VT_COLORTYPE, 4) && + VerifyField(verifier, VT_BGCOLOROPACITY, 1) && + VerifyField(verifier, VT_COLORVECTOR, 4) && + VerifyField(verifier, VT_CAPINSETS, 4) && + VerifyField(verifier, VT_SCALE9SIZE, 4) && + VerifyField(verifier, VT_BACKGROUNDSCALE9ENABLED, 1) && + verifier.EndTable(); + } }; -struct PanelOptionsBuilder -{ - flatbuffers::FlatBufferBuilder& fbb_; - flatbuffers::uoffset_t start_; - void add_widgetOptions(flatbuffers::Offset widgetOptions) - { - fbb_.AddOffset(PanelOptions::VT_WIDGETOPTIONS, widgetOptions); - } - void add_backGroundImageData(flatbuffers::Offset backGroundImageData) - { - fbb_.AddOffset(PanelOptions::VT_BACKGROUNDIMAGEDATA, backGroundImageData); - } - void add_clipEnabled(bool clipEnabled) - { - fbb_.AddElement(PanelOptions::VT_CLIPENABLED, static_cast(clipEnabled), 0); - } - void add_bgColor(const Color* bgColor) { fbb_.AddStruct(PanelOptions::VT_BGCOLOR, bgColor); } - void add_bgStartColor(const Color* bgStartColor) { fbb_.AddStruct(PanelOptions::VT_BGSTARTCOLOR, bgStartColor); } - void add_bgEndColor(const Color* bgEndColor) { fbb_.AddStruct(PanelOptions::VT_BGENDCOLOR, bgEndColor); } - void add_colorType(int32_t colorType) { fbb_.AddElement(PanelOptions::VT_COLORTYPE, colorType, 0); } - void add_bgColorOpacity(uint8_t bgColorOpacity) - { - fbb_.AddElement(PanelOptions::VT_BGCOLOROPACITY, bgColorOpacity, 255); - } - void add_colorVector(const ColorVector* colorVector) { fbb_.AddStruct(PanelOptions::VT_COLORVECTOR, colorVector); } - void add_capInsets(const CapInsets* capInsets) { fbb_.AddStruct(PanelOptions::VT_CAPINSETS, capInsets); } - void add_scale9Size(const FlatSize* scale9Size) { fbb_.AddStruct(PanelOptions::VT_SCALE9SIZE, scale9Size); } - void add_backGroundScale9Enabled(bool backGroundScale9Enabled) - { - fbb_.AddElement(PanelOptions::VT_BACKGROUNDSCALE9ENABLED, - static_cast(backGroundScale9Enabled), 0); - } - explicit PanelOptionsBuilder(flatbuffers::FlatBufferBuilder& _fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } - PanelOptionsBuilder& operator=(const PanelOptionsBuilder&); - flatbuffers::Offset Finish() - { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset(end); - return o; - } +struct PanelOptionsBuilder { + typedef PanelOptions Table; + flatbuffers::FlatBufferBuilder &fbb_; + flatbuffers::uoffset_t start_; + void add_widgetOptions(flatbuffers::Offset widgetOptions) { + fbb_.AddOffset(PanelOptions::VT_WIDGETOPTIONS, widgetOptions); + } + void add_backGroundImageData(flatbuffers::Offset backGroundImageData) { + fbb_.AddOffset(PanelOptions::VT_BACKGROUNDIMAGEDATA, backGroundImageData); + } + void add_clipEnabled(bool clipEnabled) { + fbb_.AddElement(PanelOptions::VT_CLIPENABLED, static_cast(clipEnabled), 0); + } + void add_bgColor(const flatbuffers::Color *bgColor) { + fbb_.AddStruct(PanelOptions::VT_BGCOLOR, bgColor); + } + void add_bgStartColor(const flatbuffers::Color *bgStartColor) { + fbb_.AddStruct(PanelOptions::VT_BGSTARTCOLOR, bgStartColor); + } + void add_bgEndColor(const flatbuffers::Color *bgEndColor) { + fbb_.AddStruct(PanelOptions::VT_BGENDCOLOR, bgEndColor); + } + void add_colorType(int32_t colorType) { + fbb_.AddElement(PanelOptions::VT_COLORTYPE, colorType, 0); + } + void add_bgColorOpacity(uint8_t bgColorOpacity) { + fbb_.AddElement(PanelOptions::VT_BGCOLOROPACITY, bgColorOpacity, 255); + } + void add_colorVector(const flatbuffers::ColorVector *colorVector) { + fbb_.AddStruct(PanelOptions::VT_COLORVECTOR, colorVector); + } + void add_capInsets(const flatbuffers::CapInsets *capInsets) { + fbb_.AddStruct(PanelOptions::VT_CAPINSETS, capInsets); + } + void add_scale9Size(const flatbuffers::FlatSize *scale9Size) { + fbb_.AddStruct(PanelOptions::VT_SCALE9SIZE, scale9Size); + } + void add_backGroundScale9Enabled(bool backGroundScale9Enabled) { + fbb_.AddElement(PanelOptions::VT_BACKGROUNDSCALE9ENABLED, static_cast(backGroundScale9Enabled), 0); + } + explicit PanelOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) + : fbb_(_fbb) { + start_ = fbb_.StartTable(); + } + flatbuffers::Offset Finish() { + const auto end = fbb_.EndTable(start_); + auto o = flatbuffers::Offset(end); + return o; + } }; -inline flatbuffers::Offset CreatePanelOptions(flatbuffers::FlatBufferBuilder& _fbb, - flatbuffers::Offset widgetOptions = 0, - flatbuffers::Offset backGroundImageData = 0, - bool clipEnabled = false, - const Color* bgColor = 0, - const Color* bgStartColor = 0, - const Color* bgEndColor = 0, - int32_t colorType = 0, - uint8_t bgColorOpacity = 255, - const ColorVector* colorVector = 0, - const CapInsets* capInsets = 0, - const FlatSize* scale9Size = 0, - bool backGroundScale9Enabled = false) -{ - PanelOptionsBuilder builder_(_fbb); - builder_.add_scale9Size(scale9Size); - builder_.add_capInsets(capInsets); - builder_.add_colorVector(colorVector); - builder_.add_colorType(colorType); - builder_.add_bgEndColor(bgEndColor); - builder_.add_bgStartColor(bgStartColor); - builder_.add_bgColor(bgColor); - builder_.add_backGroundImageData(backGroundImageData); - builder_.add_widgetOptions(widgetOptions); - builder_.add_backGroundScale9Enabled(backGroundScale9Enabled); - builder_.add_bgColorOpacity(bgColorOpacity); - builder_.add_clipEnabled(clipEnabled); - return builder_.Finish(); +inline flatbuffers::Offset CreatePanelOptions( + flatbuffers::FlatBufferBuilder &_fbb, + flatbuffers::Offset widgetOptions = 0, + flatbuffers::Offset backGroundImageData = 0, + bool clipEnabled = false, + const flatbuffers::Color *bgColor = nullptr, + const flatbuffers::Color *bgStartColor = nullptr, + const flatbuffers::Color *bgEndColor = nullptr, + int32_t colorType = 0, + uint8_t bgColorOpacity = 255, + const flatbuffers::ColorVector *colorVector = nullptr, + const flatbuffers::CapInsets *capInsets = nullptr, + const flatbuffers::FlatSize *scale9Size = nullptr, + bool backGroundScale9Enabled = false) { + PanelOptionsBuilder builder_(_fbb); + builder_.add_scale9Size(scale9Size); + builder_.add_capInsets(capInsets); + builder_.add_colorVector(colorVector); + builder_.add_colorType(colorType); + builder_.add_bgEndColor(bgEndColor); + builder_.add_bgStartColor(bgStartColor); + builder_.add_bgColor(bgColor); + builder_.add_backGroundImageData(backGroundImageData); + builder_.add_widgetOptions(widgetOptions); + builder_.add_backGroundScale9Enabled(backGroundScale9Enabled); + builder_.add_bgColorOpacity(bgColorOpacity); + builder_.add_clipEnabled(clipEnabled); + return builder_.Finish(); } -struct ScrollViewOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table -{ - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE - { - VT_WIDGETOPTIONS = 4, - VT_BACKGROUNDIMAGEDATA = 6, - VT_CLIPENABLED = 8, - VT_BGCOLOR = 10, - VT_BGSTARTCOLOR = 12, - VT_BGENDCOLOR = 14, - VT_COLORTYPE = 16, - VT_BGCOLOROPACITY = 18, - VT_COLORVECTOR = 20, - VT_CAPINSETS = 22, - VT_SCALE9SIZE = 24, - VT_BACKGROUNDSCALE9ENABLED = 26, - VT_INNERSIZE = 28, - VT_DIRECTION = 30, - VT_BOUNCEENABLED = 32, - VT_SCROLLBARENABELD = 34, - VT_SCROLLBARAUTOHIDE = 36, - VT_SCROLLBARAUTOHIDETIME = 38 - }; - const WidgetOptions* widgetOptions() const { return GetPointer(VT_WIDGETOPTIONS); } - const ResourceData* backGroundImageData() const { return GetPointer(VT_BACKGROUNDIMAGEDATA); } - bool clipEnabled() const { return GetField(VT_CLIPENABLED, 0) != 0; } - const Color* bgColor() const { return GetStruct(VT_BGCOLOR); } - const Color* bgStartColor() const { return GetStruct(VT_BGSTARTCOLOR); } - const Color* bgEndColor() const { return GetStruct(VT_BGENDCOLOR); } - int32_t colorType() const { return GetField(VT_COLORTYPE, 0); } - uint8_t bgColorOpacity() const { return GetField(VT_BGCOLOROPACITY, 255); } - const ColorVector* colorVector() const { return GetStruct(VT_COLORVECTOR); } - const CapInsets* capInsets() const { return GetStruct(VT_CAPINSETS); } - const FlatSize* scale9Size() const { return GetStruct(VT_SCALE9SIZE); } - bool backGroundScale9Enabled() const { return GetField(VT_BACKGROUNDSCALE9ENABLED, 0) != 0; } - const FlatSize* innerSize() const { return GetStruct(VT_INNERSIZE); } - int32_t direction() const { return GetField(VT_DIRECTION, 0); } - bool bounceEnabled() const { return GetField(VT_BOUNCEENABLED, 0) != 0; } - bool scrollbarEnabeld() const { return GetField(VT_SCROLLBARENABELD, 1) != 0; } - bool scrollbarAutoHide() const { return GetField(VT_SCROLLBARAUTOHIDE, 1) != 0; } - float scrollbarAutoHideTime() const { return GetField(VT_SCROLLBARAUTOHIDETIME, 0.2f); } - bool Verify(flatbuffers::Verifier& verifier) const - { - return VerifyTableStart(verifier) && VerifyOffset(verifier, VT_WIDGETOPTIONS) && - verifier.VerifyTable(widgetOptions()) && VerifyOffset(verifier, VT_BACKGROUNDIMAGEDATA) && - verifier.VerifyTable(backGroundImageData()) && VerifyField(verifier, VT_CLIPENABLED) && - VerifyField(verifier, VT_BGCOLOR) && VerifyField(verifier, VT_BGSTARTCOLOR) && - VerifyField(verifier, VT_BGENDCOLOR) && VerifyField(verifier, VT_COLORTYPE) && - VerifyField(verifier, VT_BGCOLOROPACITY) && - VerifyField(verifier, VT_COLORVECTOR) && VerifyField(verifier, VT_CAPINSETS) && - VerifyField(verifier, VT_SCALE9SIZE) && - VerifyField(verifier, VT_BACKGROUNDSCALE9ENABLED) && - VerifyField(verifier, VT_INNERSIZE) && VerifyField(verifier, VT_DIRECTION) && - VerifyField(verifier, VT_BOUNCEENABLED) && - VerifyField(verifier, VT_SCROLLBARENABELD) && - VerifyField(verifier, VT_SCROLLBARAUTOHIDE) && - VerifyField(verifier, VT_SCROLLBARAUTOHIDETIME) && verifier.EndTable(); - } +struct ScrollViewOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { + typedef ScrollViewOptionsBuilder Builder; + enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { + VT_WIDGETOPTIONS = 4, + VT_BACKGROUNDIMAGEDATA = 6, + VT_CLIPENABLED = 8, + VT_BGCOLOR = 10, + VT_BGSTARTCOLOR = 12, + VT_BGENDCOLOR = 14, + VT_COLORTYPE = 16, + VT_BGCOLOROPACITY = 18, + VT_COLORVECTOR = 20, + VT_CAPINSETS = 22, + VT_SCALE9SIZE = 24, + VT_BACKGROUNDSCALE9ENABLED = 26, + VT_INNERSIZE = 28, + VT_DIRECTION = 30, + VT_BOUNCEENABLED = 32, + VT_SCROLLBARENABELD = 34, + VT_SCROLLBARAUTOHIDE = 36, + VT_SCROLLBARAUTOHIDETIME = 38 + }; + const flatbuffers::WidgetOptions *widgetOptions() const { + return GetPointer(VT_WIDGETOPTIONS); + } + const flatbuffers::ResourceData *backGroundImageData() const { + return GetPointer(VT_BACKGROUNDIMAGEDATA); + } + bool clipEnabled() const { + return GetField(VT_CLIPENABLED, 0) != 0; + } + const flatbuffers::Color *bgColor() const { + return GetStruct(VT_BGCOLOR); + } + const flatbuffers::Color *bgStartColor() const { + return GetStruct(VT_BGSTARTCOLOR); + } + const flatbuffers::Color *bgEndColor() const { + return GetStruct(VT_BGENDCOLOR); + } + int32_t colorType() const { + return GetField(VT_COLORTYPE, 0); + } + uint8_t bgColorOpacity() const { + return GetField(VT_BGCOLOROPACITY, 255); + } + const flatbuffers::ColorVector *colorVector() const { + return GetStruct(VT_COLORVECTOR); + } + const flatbuffers::CapInsets *capInsets() const { + return GetStruct(VT_CAPINSETS); + } + const flatbuffers::FlatSize *scale9Size() const { + return GetStruct(VT_SCALE9SIZE); + } + bool backGroundScale9Enabled() const { + return GetField(VT_BACKGROUNDSCALE9ENABLED, 0) != 0; + } + const flatbuffers::FlatSize *innerSize() const { + return GetStruct(VT_INNERSIZE); + } + int32_t direction() const { + return GetField(VT_DIRECTION, 0); + } + bool bounceEnabled() const { + return GetField(VT_BOUNCEENABLED, 0) != 0; + } + bool scrollbarEnabeld() const { + return GetField(VT_SCROLLBARENABELD, 1) != 0; + } + bool scrollbarAutoHide() const { + return GetField(VT_SCROLLBARAUTOHIDE, 1) != 0; + } + float scrollbarAutoHideTime() const { + return GetField(VT_SCROLLBARAUTOHIDETIME, 0.2f); + } + bool Verify(flatbuffers::Verifier &verifier) const { + return VerifyTableStart(verifier) && + VerifyOffset(verifier, VT_WIDGETOPTIONS) && + verifier.VerifyTable(widgetOptions()) && + VerifyOffset(verifier, VT_BACKGROUNDIMAGEDATA) && + verifier.VerifyTable(backGroundImageData()) && + VerifyField(verifier, VT_CLIPENABLED, 1) && + VerifyField(verifier, VT_BGCOLOR, 1) && + VerifyField(verifier, VT_BGSTARTCOLOR, 1) && + VerifyField(verifier, VT_BGENDCOLOR, 1) && + VerifyField(verifier, VT_COLORTYPE, 4) && + VerifyField(verifier, VT_BGCOLOROPACITY, 1) && + VerifyField(verifier, VT_COLORVECTOR, 4) && + VerifyField(verifier, VT_CAPINSETS, 4) && + VerifyField(verifier, VT_SCALE9SIZE, 4) && + VerifyField(verifier, VT_BACKGROUNDSCALE9ENABLED, 1) && + VerifyField(verifier, VT_INNERSIZE, 4) && + VerifyField(verifier, VT_DIRECTION, 4) && + VerifyField(verifier, VT_BOUNCEENABLED, 1) && + VerifyField(verifier, VT_SCROLLBARENABELD, 1) && + VerifyField(verifier, VT_SCROLLBARAUTOHIDE, 1) && + VerifyField(verifier, VT_SCROLLBARAUTOHIDETIME, 4) && + verifier.EndTable(); + } }; -struct ScrollViewOptionsBuilder -{ - flatbuffers::FlatBufferBuilder& fbb_; - flatbuffers::uoffset_t start_; - void add_widgetOptions(flatbuffers::Offset widgetOptions) - { - fbb_.AddOffset(ScrollViewOptions::VT_WIDGETOPTIONS, widgetOptions); - } - void add_backGroundImageData(flatbuffers::Offset backGroundImageData) - { - fbb_.AddOffset(ScrollViewOptions::VT_BACKGROUNDIMAGEDATA, backGroundImageData); - } - void add_clipEnabled(bool clipEnabled) - { - fbb_.AddElement(ScrollViewOptions::VT_CLIPENABLED, static_cast(clipEnabled), 0); - } - void add_bgColor(const Color* bgColor) { fbb_.AddStruct(ScrollViewOptions::VT_BGCOLOR, bgColor); } - void add_bgStartColor(const Color* bgStartColor) - { - fbb_.AddStruct(ScrollViewOptions::VT_BGSTARTCOLOR, bgStartColor); - } - void add_bgEndColor(const Color* bgEndColor) { fbb_.AddStruct(ScrollViewOptions::VT_BGENDCOLOR, bgEndColor); } - void add_colorType(int32_t colorType) { fbb_.AddElement(ScrollViewOptions::VT_COLORTYPE, colorType, 0); } - void add_bgColorOpacity(uint8_t bgColorOpacity) - { - fbb_.AddElement(ScrollViewOptions::VT_BGCOLOROPACITY, bgColorOpacity, 255); - } - void add_colorVector(const ColorVector* colorVector) - { - fbb_.AddStruct(ScrollViewOptions::VT_COLORVECTOR, colorVector); - } - void add_capInsets(const CapInsets* capInsets) { fbb_.AddStruct(ScrollViewOptions::VT_CAPINSETS, capInsets); } - void add_scale9Size(const FlatSize* scale9Size) { fbb_.AddStruct(ScrollViewOptions::VT_SCALE9SIZE, scale9Size); } - void add_backGroundScale9Enabled(bool backGroundScale9Enabled) - { - fbb_.AddElement(ScrollViewOptions::VT_BACKGROUNDSCALE9ENABLED, - static_cast(backGroundScale9Enabled), 0); - } - void add_innerSize(const FlatSize* innerSize) { fbb_.AddStruct(ScrollViewOptions::VT_INNERSIZE, innerSize); } - void add_direction(int32_t direction) { fbb_.AddElement(ScrollViewOptions::VT_DIRECTION, direction, 0); } - void add_bounceEnabled(bool bounceEnabled) - { - fbb_.AddElement(ScrollViewOptions::VT_BOUNCEENABLED, static_cast(bounceEnabled), 0); - } - void add_scrollbarEnabeld(bool scrollbarEnabeld) - { - fbb_.AddElement(ScrollViewOptions::VT_SCROLLBARENABELD, static_cast(scrollbarEnabeld), 1); - } - void add_scrollbarAutoHide(bool scrollbarAutoHide) - { - fbb_.AddElement(ScrollViewOptions::VT_SCROLLBARAUTOHIDE, static_cast(scrollbarAutoHide), 1); - } - void add_scrollbarAutoHideTime(float scrollbarAutoHideTime) - { - fbb_.AddElement(ScrollViewOptions::VT_SCROLLBARAUTOHIDETIME, scrollbarAutoHideTime, 0.2f); - } - explicit ScrollViewOptionsBuilder(flatbuffers::FlatBufferBuilder& _fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } - ScrollViewOptionsBuilder& operator=(const ScrollViewOptionsBuilder&); - flatbuffers::Offset Finish() - { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset(end); - return o; - } +struct ScrollViewOptionsBuilder { + typedef ScrollViewOptions Table; + flatbuffers::FlatBufferBuilder &fbb_; + flatbuffers::uoffset_t start_; + void add_widgetOptions(flatbuffers::Offset widgetOptions) { + fbb_.AddOffset(ScrollViewOptions::VT_WIDGETOPTIONS, widgetOptions); + } + void add_backGroundImageData(flatbuffers::Offset backGroundImageData) { + fbb_.AddOffset(ScrollViewOptions::VT_BACKGROUNDIMAGEDATA, backGroundImageData); + } + void add_clipEnabled(bool clipEnabled) { + fbb_.AddElement(ScrollViewOptions::VT_CLIPENABLED, static_cast(clipEnabled), 0); + } + void add_bgColor(const flatbuffers::Color *bgColor) { + fbb_.AddStruct(ScrollViewOptions::VT_BGCOLOR, bgColor); + } + void add_bgStartColor(const flatbuffers::Color *bgStartColor) { + fbb_.AddStruct(ScrollViewOptions::VT_BGSTARTCOLOR, bgStartColor); + } + void add_bgEndColor(const flatbuffers::Color *bgEndColor) { + fbb_.AddStruct(ScrollViewOptions::VT_BGENDCOLOR, bgEndColor); + } + void add_colorType(int32_t colorType) { + fbb_.AddElement(ScrollViewOptions::VT_COLORTYPE, colorType, 0); + } + void add_bgColorOpacity(uint8_t bgColorOpacity) { + fbb_.AddElement(ScrollViewOptions::VT_BGCOLOROPACITY, bgColorOpacity, 255); + } + void add_colorVector(const flatbuffers::ColorVector *colorVector) { + fbb_.AddStruct(ScrollViewOptions::VT_COLORVECTOR, colorVector); + } + void add_capInsets(const flatbuffers::CapInsets *capInsets) { + fbb_.AddStruct(ScrollViewOptions::VT_CAPINSETS, capInsets); + } + void add_scale9Size(const flatbuffers::FlatSize *scale9Size) { + fbb_.AddStruct(ScrollViewOptions::VT_SCALE9SIZE, scale9Size); + } + void add_backGroundScale9Enabled(bool backGroundScale9Enabled) { + fbb_.AddElement(ScrollViewOptions::VT_BACKGROUNDSCALE9ENABLED, static_cast(backGroundScale9Enabled), 0); + } + void add_innerSize(const flatbuffers::FlatSize *innerSize) { + fbb_.AddStruct(ScrollViewOptions::VT_INNERSIZE, innerSize); + } + void add_direction(int32_t direction) { + fbb_.AddElement(ScrollViewOptions::VT_DIRECTION, direction, 0); + } + void add_bounceEnabled(bool bounceEnabled) { + fbb_.AddElement(ScrollViewOptions::VT_BOUNCEENABLED, static_cast(bounceEnabled), 0); + } + void add_scrollbarEnabeld(bool scrollbarEnabeld) { + fbb_.AddElement(ScrollViewOptions::VT_SCROLLBARENABELD, static_cast(scrollbarEnabeld), 1); + } + void add_scrollbarAutoHide(bool scrollbarAutoHide) { + fbb_.AddElement(ScrollViewOptions::VT_SCROLLBARAUTOHIDE, static_cast(scrollbarAutoHide), 1); + } + void add_scrollbarAutoHideTime(float scrollbarAutoHideTime) { + fbb_.AddElement(ScrollViewOptions::VT_SCROLLBARAUTOHIDETIME, scrollbarAutoHideTime, 0.2f); + } + explicit ScrollViewOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) + : fbb_(_fbb) { + start_ = fbb_.StartTable(); + } + flatbuffers::Offset Finish() { + const auto end = fbb_.EndTable(start_); + auto o = flatbuffers::Offset(end); + return o; + } }; inline flatbuffers::Offset CreateScrollViewOptions( - flatbuffers::FlatBufferBuilder& _fbb, - flatbuffers::Offset widgetOptions = 0, - flatbuffers::Offset backGroundImageData = 0, - bool clipEnabled = false, - const Color* bgColor = 0, - const Color* bgStartColor = 0, - const Color* bgEndColor = 0, - int32_t colorType = 0, - uint8_t bgColorOpacity = 255, - const ColorVector* colorVector = 0, - const CapInsets* capInsets = 0, - const FlatSize* scale9Size = 0, - bool backGroundScale9Enabled = false, - const FlatSize* innerSize = 0, - int32_t direction = 0, - bool bounceEnabled = false, - bool scrollbarEnabeld = true, - bool scrollbarAutoHide = true, - float scrollbarAutoHideTime = 0.2f) -{ - ScrollViewOptionsBuilder builder_(_fbb); - builder_.add_scrollbarAutoHideTime(scrollbarAutoHideTime); - builder_.add_direction(direction); - builder_.add_innerSize(innerSize); - builder_.add_scale9Size(scale9Size); - builder_.add_capInsets(capInsets); - builder_.add_colorVector(colorVector); - builder_.add_colorType(colorType); - builder_.add_bgEndColor(bgEndColor); - builder_.add_bgStartColor(bgStartColor); - builder_.add_bgColor(bgColor); - builder_.add_backGroundImageData(backGroundImageData); - builder_.add_widgetOptions(widgetOptions); - builder_.add_scrollbarAutoHide(scrollbarAutoHide); - builder_.add_scrollbarEnabeld(scrollbarEnabeld); - builder_.add_bounceEnabled(bounceEnabled); - builder_.add_backGroundScale9Enabled(backGroundScale9Enabled); - builder_.add_bgColorOpacity(bgColorOpacity); - builder_.add_clipEnabled(clipEnabled); - return builder_.Finish(); + flatbuffers::FlatBufferBuilder &_fbb, + flatbuffers::Offset widgetOptions = 0, + flatbuffers::Offset backGroundImageData = 0, + bool clipEnabled = false, + const flatbuffers::Color *bgColor = nullptr, + const flatbuffers::Color *bgStartColor = nullptr, + const flatbuffers::Color *bgEndColor = nullptr, + int32_t colorType = 0, + uint8_t bgColorOpacity = 255, + const flatbuffers::ColorVector *colorVector = nullptr, + const flatbuffers::CapInsets *capInsets = nullptr, + const flatbuffers::FlatSize *scale9Size = nullptr, + bool backGroundScale9Enabled = false, + const flatbuffers::FlatSize *innerSize = nullptr, + int32_t direction = 0, + bool bounceEnabled = false, + bool scrollbarEnabeld = true, + bool scrollbarAutoHide = true, + float scrollbarAutoHideTime = 0.2f) { + ScrollViewOptionsBuilder builder_(_fbb); + builder_.add_scrollbarAutoHideTime(scrollbarAutoHideTime); + builder_.add_direction(direction); + builder_.add_innerSize(innerSize); + builder_.add_scale9Size(scale9Size); + builder_.add_capInsets(capInsets); + builder_.add_colorVector(colorVector); + builder_.add_colorType(colorType); + builder_.add_bgEndColor(bgEndColor); + builder_.add_bgStartColor(bgStartColor); + builder_.add_bgColor(bgColor); + builder_.add_backGroundImageData(backGroundImageData); + builder_.add_widgetOptions(widgetOptions); + builder_.add_scrollbarAutoHide(scrollbarAutoHide); + builder_.add_scrollbarEnabeld(scrollbarEnabeld); + builder_.add_bounceEnabled(bounceEnabled); + builder_.add_backGroundScale9Enabled(backGroundScale9Enabled); + builder_.add_bgColorOpacity(bgColorOpacity); + builder_.add_clipEnabled(clipEnabled); + return builder_.Finish(); } -struct PageViewOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table -{ - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE - { - VT_WIDGETOPTIONS = 4, - VT_BACKGROUNDIMAGEDATA = 6, - VT_CLIPENABLED = 8, - VT_BGCOLOR = 10, - VT_BGSTARTCOLOR = 12, - VT_BGENDCOLOR = 14, - VT_COLORTYPE = 16, - VT_BGCOLOROPACITY = 18, - VT_COLORVECTOR = 20, - VT_CAPINSETS = 22, - VT_SCALE9SIZE = 24, - VT_BACKGROUNDSCALE9ENABLED = 26 - }; - const WidgetOptions* widgetOptions() const { return GetPointer(VT_WIDGETOPTIONS); } - const ResourceData* backGroundImageData() const { return GetPointer(VT_BACKGROUNDIMAGEDATA); } - bool clipEnabled() const { return GetField(VT_CLIPENABLED, 0) != 0; } - const Color* bgColor() const { return GetStruct(VT_BGCOLOR); } - const Color* bgStartColor() const { return GetStruct(VT_BGSTARTCOLOR); } - const Color* bgEndColor() const { return GetStruct(VT_BGENDCOLOR); } - int32_t colorType() const { return GetField(VT_COLORTYPE, 0); } - uint8_t bgColorOpacity() const { return GetField(VT_BGCOLOROPACITY, 255); } - const ColorVector* colorVector() const { return GetStruct(VT_COLORVECTOR); } - const CapInsets* capInsets() const { return GetStruct(VT_CAPINSETS); } - const FlatSize* scale9Size() const { return GetStruct(VT_SCALE9SIZE); } - bool backGroundScale9Enabled() const { return GetField(VT_BACKGROUNDSCALE9ENABLED, 0) != 0; } - bool Verify(flatbuffers::Verifier& verifier) const - { - return VerifyTableStart(verifier) && VerifyOffset(verifier, VT_WIDGETOPTIONS) && - verifier.VerifyTable(widgetOptions()) && VerifyOffset(verifier, VT_BACKGROUNDIMAGEDATA) && - verifier.VerifyTable(backGroundImageData()) && VerifyField(verifier, VT_CLIPENABLED) && - VerifyField(verifier, VT_BGCOLOR) && VerifyField(verifier, VT_BGSTARTCOLOR) && - VerifyField(verifier, VT_BGENDCOLOR) && VerifyField(verifier, VT_COLORTYPE) && - VerifyField(verifier, VT_BGCOLOROPACITY) && - VerifyField(verifier, VT_COLORVECTOR) && VerifyField(verifier, VT_CAPINSETS) && - VerifyField(verifier, VT_SCALE9SIZE) && - VerifyField(verifier, VT_BACKGROUNDSCALE9ENABLED) && verifier.EndTable(); - } +struct PageViewOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { + typedef PageViewOptionsBuilder Builder; + enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { + VT_WIDGETOPTIONS = 4, + VT_BACKGROUNDIMAGEDATA = 6, + VT_CLIPENABLED = 8, + VT_BGCOLOR = 10, + VT_BGSTARTCOLOR = 12, + VT_BGENDCOLOR = 14, + VT_COLORTYPE = 16, + VT_BGCOLOROPACITY = 18, + VT_COLORVECTOR = 20, + VT_CAPINSETS = 22, + VT_SCALE9SIZE = 24, + VT_BACKGROUNDSCALE9ENABLED = 26 + }; + const flatbuffers::WidgetOptions *widgetOptions() const { + return GetPointer(VT_WIDGETOPTIONS); + } + const flatbuffers::ResourceData *backGroundImageData() const { + return GetPointer(VT_BACKGROUNDIMAGEDATA); + } + bool clipEnabled() const { + return GetField(VT_CLIPENABLED, 0) != 0; + } + const flatbuffers::Color *bgColor() const { + return GetStruct(VT_BGCOLOR); + } + const flatbuffers::Color *bgStartColor() const { + return GetStruct(VT_BGSTARTCOLOR); + } + const flatbuffers::Color *bgEndColor() const { + return GetStruct(VT_BGENDCOLOR); + } + int32_t colorType() const { + return GetField(VT_COLORTYPE, 0); + } + uint8_t bgColorOpacity() const { + return GetField(VT_BGCOLOROPACITY, 255); + } + const flatbuffers::ColorVector *colorVector() const { + return GetStruct(VT_COLORVECTOR); + } + const flatbuffers::CapInsets *capInsets() const { + return GetStruct(VT_CAPINSETS); + } + const flatbuffers::FlatSize *scale9Size() const { + return GetStruct(VT_SCALE9SIZE); + } + bool backGroundScale9Enabled() const { + return GetField(VT_BACKGROUNDSCALE9ENABLED, 0) != 0; + } + bool Verify(flatbuffers::Verifier &verifier) const { + return VerifyTableStart(verifier) && + VerifyOffset(verifier, VT_WIDGETOPTIONS) && + verifier.VerifyTable(widgetOptions()) && + VerifyOffset(verifier, VT_BACKGROUNDIMAGEDATA) && + verifier.VerifyTable(backGroundImageData()) && + VerifyField(verifier, VT_CLIPENABLED, 1) && + VerifyField(verifier, VT_BGCOLOR, 1) && + VerifyField(verifier, VT_BGSTARTCOLOR, 1) && + VerifyField(verifier, VT_BGENDCOLOR, 1) && + VerifyField(verifier, VT_COLORTYPE, 4) && + VerifyField(verifier, VT_BGCOLOROPACITY, 1) && + VerifyField(verifier, VT_COLORVECTOR, 4) && + VerifyField(verifier, VT_CAPINSETS, 4) && + VerifyField(verifier, VT_SCALE9SIZE, 4) && + VerifyField(verifier, VT_BACKGROUNDSCALE9ENABLED, 1) && + verifier.EndTable(); + } }; -struct PageViewOptionsBuilder -{ - flatbuffers::FlatBufferBuilder& fbb_; - flatbuffers::uoffset_t start_; - void add_widgetOptions(flatbuffers::Offset widgetOptions) - { - fbb_.AddOffset(PageViewOptions::VT_WIDGETOPTIONS, widgetOptions); - } - void add_backGroundImageData(flatbuffers::Offset backGroundImageData) - { - fbb_.AddOffset(PageViewOptions::VT_BACKGROUNDIMAGEDATA, backGroundImageData); - } - void add_clipEnabled(bool clipEnabled) - { - fbb_.AddElement(PageViewOptions::VT_CLIPENABLED, static_cast(clipEnabled), 0); - } - void add_bgColor(const Color* bgColor) { fbb_.AddStruct(PageViewOptions::VT_BGCOLOR, bgColor); } - void add_bgStartColor(const Color* bgStartColor) { fbb_.AddStruct(PageViewOptions::VT_BGSTARTCOLOR, bgStartColor); } - void add_bgEndColor(const Color* bgEndColor) { fbb_.AddStruct(PageViewOptions::VT_BGENDCOLOR, bgEndColor); } - void add_colorType(int32_t colorType) { fbb_.AddElement(PageViewOptions::VT_COLORTYPE, colorType, 0); } - void add_bgColorOpacity(uint8_t bgColorOpacity) - { - fbb_.AddElement(PageViewOptions::VT_BGCOLOROPACITY, bgColorOpacity, 255); - } - void add_colorVector(const ColorVector* colorVector) - { - fbb_.AddStruct(PageViewOptions::VT_COLORVECTOR, colorVector); - } - void add_capInsets(const CapInsets* capInsets) { fbb_.AddStruct(PageViewOptions::VT_CAPINSETS, capInsets); } - void add_scale9Size(const FlatSize* scale9Size) { fbb_.AddStruct(PageViewOptions::VT_SCALE9SIZE, scale9Size); } - void add_backGroundScale9Enabled(bool backGroundScale9Enabled) - { - fbb_.AddElement(PageViewOptions::VT_BACKGROUNDSCALE9ENABLED, - static_cast(backGroundScale9Enabled), 0); - } - explicit PageViewOptionsBuilder(flatbuffers::FlatBufferBuilder& _fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } - PageViewOptionsBuilder& operator=(const PageViewOptionsBuilder&); - flatbuffers::Offset Finish() - { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset(end); - return o; - } +struct PageViewOptionsBuilder { + typedef PageViewOptions Table; + flatbuffers::FlatBufferBuilder &fbb_; + flatbuffers::uoffset_t start_; + void add_widgetOptions(flatbuffers::Offset widgetOptions) { + fbb_.AddOffset(PageViewOptions::VT_WIDGETOPTIONS, widgetOptions); + } + void add_backGroundImageData(flatbuffers::Offset backGroundImageData) { + fbb_.AddOffset(PageViewOptions::VT_BACKGROUNDIMAGEDATA, backGroundImageData); + } + void add_clipEnabled(bool clipEnabled) { + fbb_.AddElement(PageViewOptions::VT_CLIPENABLED, static_cast(clipEnabled), 0); + } + void add_bgColor(const flatbuffers::Color *bgColor) { + fbb_.AddStruct(PageViewOptions::VT_BGCOLOR, bgColor); + } + void add_bgStartColor(const flatbuffers::Color *bgStartColor) { + fbb_.AddStruct(PageViewOptions::VT_BGSTARTCOLOR, bgStartColor); + } + void add_bgEndColor(const flatbuffers::Color *bgEndColor) { + fbb_.AddStruct(PageViewOptions::VT_BGENDCOLOR, bgEndColor); + } + void add_colorType(int32_t colorType) { + fbb_.AddElement(PageViewOptions::VT_COLORTYPE, colorType, 0); + } + void add_bgColorOpacity(uint8_t bgColorOpacity) { + fbb_.AddElement(PageViewOptions::VT_BGCOLOROPACITY, bgColorOpacity, 255); + } + void add_colorVector(const flatbuffers::ColorVector *colorVector) { + fbb_.AddStruct(PageViewOptions::VT_COLORVECTOR, colorVector); + } + void add_capInsets(const flatbuffers::CapInsets *capInsets) { + fbb_.AddStruct(PageViewOptions::VT_CAPINSETS, capInsets); + } + void add_scale9Size(const flatbuffers::FlatSize *scale9Size) { + fbb_.AddStruct(PageViewOptions::VT_SCALE9SIZE, scale9Size); + } + void add_backGroundScale9Enabled(bool backGroundScale9Enabled) { + fbb_.AddElement(PageViewOptions::VT_BACKGROUNDSCALE9ENABLED, static_cast(backGroundScale9Enabled), 0); + } + explicit PageViewOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) + : fbb_(_fbb) { + start_ = fbb_.StartTable(); + } + flatbuffers::Offset Finish() { + const auto end = fbb_.EndTable(start_); + auto o = flatbuffers::Offset(end); + return o; + } }; inline flatbuffers::Offset CreatePageViewOptions( - flatbuffers::FlatBufferBuilder& _fbb, - flatbuffers::Offset widgetOptions = 0, - flatbuffers::Offset backGroundImageData = 0, - bool clipEnabled = false, - const Color* bgColor = 0, - const Color* bgStartColor = 0, - const Color* bgEndColor = 0, - int32_t colorType = 0, - uint8_t bgColorOpacity = 255, - const ColorVector* colorVector = 0, - const CapInsets* capInsets = 0, - const FlatSize* scale9Size = 0, - bool backGroundScale9Enabled = false) -{ - PageViewOptionsBuilder builder_(_fbb); - builder_.add_scale9Size(scale9Size); - builder_.add_capInsets(capInsets); - builder_.add_colorVector(colorVector); - builder_.add_colorType(colorType); - builder_.add_bgEndColor(bgEndColor); - builder_.add_bgStartColor(bgStartColor); - builder_.add_bgColor(bgColor); - builder_.add_backGroundImageData(backGroundImageData); - builder_.add_widgetOptions(widgetOptions); - builder_.add_backGroundScale9Enabled(backGroundScale9Enabled); - builder_.add_bgColorOpacity(bgColorOpacity); - builder_.add_clipEnabled(clipEnabled); - return builder_.Finish(); + flatbuffers::FlatBufferBuilder &_fbb, + flatbuffers::Offset widgetOptions = 0, + flatbuffers::Offset backGroundImageData = 0, + bool clipEnabled = false, + const flatbuffers::Color *bgColor = nullptr, + const flatbuffers::Color *bgStartColor = nullptr, + const flatbuffers::Color *bgEndColor = nullptr, + int32_t colorType = 0, + uint8_t bgColorOpacity = 255, + const flatbuffers::ColorVector *colorVector = nullptr, + const flatbuffers::CapInsets *capInsets = nullptr, + const flatbuffers::FlatSize *scale9Size = nullptr, + bool backGroundScale9Enabled = false) { + PageViewOptionsBuilder builder_(_fbb); + builder_.add_scale9Size(scale9Size); + builder_.add_capInsets(capInsets); + builder_.add_colorVector(colorVector); + builder_.add_colorType(colorType); + builder_.add_bgEndColor(bgEndColor); + builder_.add_bgStartColor(bgStartColor); + builder_.add_bgColor(bgColor); + builder_.add_backGroundImageData(backGroundImageData); + builder_.add_widgetOptions(widgetOptions); + builder_.add_backGroundScale9Enabled(backGroundScale9Enabled); + builder_.add_bgColorOpacity(bgColorOpacity); + builder_.add_clipEnabled(clipEnabled); + return builder_.Finish(); } -struct ListViewOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table -{ - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE - { - VT_WIDGETOPTIONS = 4, - VT_BACKGROUNDIMAGEDATA = 6, - VT_CLIPENABLED = 8, - VT_BGCOLOR = 10, - VT_BGSTARTCOLOR = 12, - VT_BGENDCOLOR = 14, - VT_COLORTYPE = 16, - VT_BGCOLOROPACITY = 18, - VT_COLORVECTOR = 20, - VT_CAPINSETS = 22, - VT_SCALE9SIZE = 24, - VT_BACKGROUNDSCALE9ENABLED = 26, - VT_INNERSIZE = 28, - VT_DIRECTION = 30, - VT_BOUNCEENABLED = 32, - VT_ITEMMARGIN = 34, - VT_DIRECTIONTYPE = 36, - VT_HORIZONTALTYPE = 38, - VT_VERTICALTYPE = 40 - }; - const WidgetOptions* widgetOptions() const { return GetPointer(VT_WIDGETOPTIONS); } - const ResourceData* backGroundImageData() const { return GetPointer(VT_BACKGROUNDIMAGEDATA); } - bool clipEnabled() const { return GetField(VT_CLIPENABLED, 0) != 0; } - const Color* bgColor() const { return GetStruct(VT_BGCOLOR); } - const Color* bgStartColor() const { return GetStruct(VT_BGSTARTCOLOR); } - const Color* bgEndColor() const { return GetStruct(VT_BGENDCOLOR); } - int32_t colorType() const { return GetField(VT_COLORTYPE, 0); } - uint8_t bgColorOpacity() const { return GetField(VT_BGCOLOROPACITY, 255); } - const ColorVector* colorVector() const { return GetStruct(VT_COLORVECTOR); } - const CapInsets* capInsets() const { return GetStruct(VT_CAPINSETS); } - const FlatSize* scale9Size() const { return GetStruct(VT_SCALE9SIZE); } - bool backGroundScale9Enabled() const { return GetField(VT_BACKGROUNDSCALE9ENABLED, 0) != 0; } - const FlatSize* innerSize() const { return GetStruct(VT_INNERSIZE); } - int32_t direction() const { return GetField(VT_DIRECTION, 0); } - bool bounceEnabled() const { return GetField(VT_BOUNCEENABLED, 0) != 0; } - int32_t itemMargin() const { return GetField(VT_ITEMMARGIN, 0); } - const flatbuffers::String* directionType() const - { - return GetPointer(VT_DIRECTIONTYPE); - } - const flatbuffers::String* horizontalType() const - { - return GetPointer(VT_HORIZONTALTYPE); - } - const flatbuffers::String* verticalType() const { return GetPointer(VT_VERTICALTYPE); } - bool Verify(flatbuffers::Verifier& verifier) const - { - return VerifyTableStart(verifier) && VerifyOffset(verifier, VT_WIDGETOPTIONS) && - verifier.VerifyTable(widgetOptions()) && VerifyOffset(verifier, VT_BACKGROUNDIMAGEDATA) && - verifier.VerifyTable(backGroundImageData()) && VerifyField(verifier, VT_CLIPENABLED) && - VerifyField(verifier, VT_BGCOLOR) && VerifyField(verifier, VT_BGSTARTCOLOR) && - VerifyField(verifier, VT_BGENDCOLOR) && VerifyField(verifier, VT_COLORTYPE) && - VerifyField(verifier, VT_BGCOLOROPACITY) && - VerifyField(verifier, VT_COLORVECTOR) && VerifyField(verifier, VT_CAPINSETS) && - VerifyField(verifier, VT_SCALE9SIZE) && - VerifyField(verifier, VT_BACKGROUNDSCALE9ENABLED) && - VerifyField(verifier, VT_INNERSIZE) && VerifyField(verifier, VT_DIRECTION) && - VerifyField(verifier, VT_BOUNCEENABLED) && VerifyField(verifier, VT_ITEMMARGIN) && - VerifyOffset(verifier, VT_DIRECTIONTYPE) && verifier.VerifyString(directionType()) && - VerifyOffset(verifier, VT_HORIZONTALTYPE) && verifier.VerifyString(horizontalType()) && - VerifyOffset(verifier, VT_VERTICALTYPE) && verifier.VerifyString(verticalType()) && verifier.EndTable(); - } +struct ListViewOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { + typedef ListViewOptionsBuilder Builder; + enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { + VT_WIDGETOPTIONS = 4, + VT_BACKGROUNDIMAGEDATA = 6, + VT_CLIPENABLED = 8, + VT_BGCOLOR = 10, + VT_BGSTARTCOLOR = 12, + VT_BGENDCOLOR = 14, + VT_COLORTYPE = 16, + VT_BGCOLOROPACITY = 18, + VT_COLORVECTOR = 20, + VT_CAPINSETS = 22, + VT_SCALE9SIZE = 24, + VT_BACKGROUNDSCALE9ENABLED = 26, + VT_INNERSIZE = 28, + VT_DIRECTION = 30, + VT_BOUNCEENABLED = 32, + VT_ITEMMARGIN = 34, + VT_DIRECTIONTYPE = 36, + VT_HORIZONTALTYPE = 38, + VT_VERTICALTYPE = 40 + }; + const flatbuffers::WidgetOptions *widgetOptions() const { + return GetPointer(VT_WIDGETOPTIONS); + } + const flatbuffers::ResourceData *backGroundImageData() const { + return GetPointer(VT_BACKGROUNDIMAGEDATA); + } + bool clipEnabled() const { + return GetField(VT_CLIPENABLED, 0) != 0; + } + const flatbuffers::Color *bgColor() const { + return GetStruct(VT_BGCOLOR); + } + const flatbuffers::Color *bgStartColor() const { + return GetStruct(VT_BGSTARTCOLOR); + } + const flatbuffers::Color *bgEndColor() const { + return GetStruct(VT_BGENDCOLOR); + } + int32_t colorType() const { + return GetField(VT_COLORTYPE, 0); + } + uint8_t bgColorOpacity() const { + return GetField(VT_BGCOLOROPACITY, 255); + } + const flatbuffers::ColorVector *colorVector() const { + return GetStruct(VT_COLORVECTOR); + } + const flatbuffers::CapInsets *capInsets() const { + return GetStruct(VT_CAPINSETS); + } + const flatbuffers::FlatSize *scale9Size() const { + return GetStruct(VT_SCALE9SIZE); + } + bool backGroundScale9Enabled() const { + return GetField(VT_BACKGROUNDSCALE9ENABLED, 0) != 0; + } + const flatbuffers::FlatSize *innerSize() const { + return GetStruct(VT_INNERSIZE); + } + int32_t direction() const { + return GetField(VT_DIRECTION, 0); + } + bool bounceEnabled() const { + return GetField(VT_BOUNCEENABLED, 0) != 0; + } + int32_t itemMargin() const { + return GetField(VT_ITEMMARGIN, 0); + } + const flatbuffers::String *directionType() const { + return GetPointer(VT_DIRECTIONTYPE); + } + const flatbuffers::String *horizontalType() const { + return GetPointer(VT_HORIZONTALTYPE); + } + const flatbuffers::String *verticalType() const { + return GetPointer(VT_VERTICALTYPE); + } + bool Verify(flatbuffers::Verifier &verifier) const { + return VerifyTableStart(verifier) && + VerifyOffset(verifier, VT_WIDGETOPTIONS) && + verifier.VerifyTable(widgetOptions()) && + VerifyOffset(verifier, VT_BACKGROUNDIMAGEDATA) && + verifier.VerifyTable(backGroundImageData()) && + VerifyField(verifier, VT_CLIPENABLED, 1) && + VerifyField(verifier, VT_BGCOLOR, 1) && + VerifyField(verifier, VT_BGSTARTCOLOR, 1) && + VerifyField(verifier, VT_BGENDCOLOR, 1) && + VerifyField(verifier, VT_COLORTYPE, 4) && + VerifyField(verifier, VT_BGCOLOROPACITY, 1) && + VerifyField(verifier, VT_COLORVECTOR, 4) && + VerifyField(verifier, VT_CAPINSETS, 4) && + VerifyField(verifier, VT_SCALE9SIZE, 4) && + VerifyField(verifier, VT_BACKGROUNDSCALE9ENABLED, 1) && + VerifyField(verifier, VT_INNERSIZE, 4) && + VerifyField(verifier, VT_DIRECTION, 4) && + VerifyField(verifier, VT_BOUNCEENABLED, 1) && + VerifyField(verifier, VT_ITEMMARGIN, 4) && + VerifyOffset(verifier, VT_DIRECTIONTYPE) && + verifier.VerifyString(directionType()) && + VerifyOffset(verifier, VT_HORIZONTALTYPE) && + verifier.VerifyString(horizontalType()) && + VerifyOffset(verifier, VT_VERTICALTYPE) && + verifier.VerifyString(verticalType()) && + verifier.EndTable(); + } }; -struct ListViewOptionsBuilder -{ - flatbuffers::FlatBufferBuilder& fbb_; - flatbuffers::uoffset_t start_; - void add_widgetOptions(flatbuffers::Offset widgetOptions) - { - fbb_.AddOffset(ListViewOptions::VT_WIDGETOPTIONS, widgetOptions); - } - void add_backGroundImageData(flatbuffers::Offset backGroundImageData) - { - fbb_.AddOffset(ListViewOptions::VT_BACKGROUNDIMAGEDATA, backGroundImageData); - } - void add_clipEnabled(bool clipEnabled) - { - fbb_.AddElement(ListViewOptions::VT_CLIPENABLED, static_cast(clipEnabled), 0); - } - void add_bgColor(const Color* bgColor) { fbb_.AddStruct(ListViewOptions::VT_BGCOLOR, bgColor); } - void add_bgStartColor(const Color* bgStartColor) { fbb_.AddStruct(ListViewOptions::VT_BGSTARTCOLOR, bgStartColor); } - void add_bgEndColor(const Color* bgEndColor) { fbb_.AddStruct(ListViewOptions::VT_BGENDCOLOR, bgEndColor); } - void add_colorType(int32_t colorType) { fbb_.AddElement(ListViewOptions::VT_COLORTYPE, colorType, 0); } - void add_bgColorOpacity(uint8_t bgColorOpacity) - { - fbb_.AddElement(ListViewOptions::VT_BGCOLOROPACITY, bgColorOpacity, 255); - } - void add_colorVector(const ColorVector* colorVector) - { - fbb_.AddStruct(ListViewOptions::VT_COLORVECTOR, colorVector); - } - void add_capInsets(const CapInsets* capInsets) { fbb_.AddStruct(ListViewOptions::VT_CAPINSETS, capInsets); } - void add_scale9Size(const FlatSize* scale9Size) { fbb_.AddStruct(ListViewOptions::VT_SCALE9SIZE, scale9Size); } - void add_backGroundScale9Enabled(bool backGroundScale9Enabled) - { - fbb_.AddElement(ListViewOptions::VT_BACKGROUNDSCALE9ENABLED, - static_cast(backGroundScale9Enabled), 0); - } - void add_innerSize(const FlatSize* innerSize) { fbb_.AddStruct(ListViewOptions::VT_INNERSIZE, innerSize); } - void add_direction(int32_t direction) { fbb_.AddElement(ListViewOptions::VT_DIRECTION, direction, 0); } - void add_bounceEnabled(bool bounceEnabled) - { - fbb_.AddElement(ListViewOptions::VT_BOUNCEENABLED, static_cast(bounceEnabled), 0); - } - void add_itemMargin(int32_t itemMargin) { fbb_.AddElement(ListViewOptions::VT_ITEMMARGIN, itemMargin, 0); } - void add_directionType(flatbuffers::Offset directionType) - { - fbb_.AddOffset(ListViewOptions::VT_DIRECTIONTYPE, directionType); - } - void add_horizontalType(flatbuffers::Offset horizontalType) - { - fbb_.AddOffset(ListViewOptions::VT_HORIZONTALTYPE, horizontalType); - } - void add_verticalType(flatbuffers::Offset verticalType) - { - fbb_.AddOffset(ListViewOptions::VT_VERTICALTYPE, verticalType); - } - explicit ListViewOptionsBuilder(flatbuffers::FlatBufferBuilder& _fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } - ListViewOptionsBuilder& operator=(const ListViewOptionsBuilder&); - flatbuffers::Offset Finish() - { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset(end); - return o; - } +struct ListViewOptionsBuilder { + typedef ListViewOptions Table; + flatbuffers::FlatBufferBuilder &fbb_; + flatbuffers::uoffset_t start_; + void add_widgetOptions(flatbuffers::Offset widgetOptions) { + fbb_.AddOffset(ListViewOptions::VT_WIDGETOPTIONS, widgetOptions); + } + void add_backGroundImageData(flatbuffers::Offset backGroundImageData) { + fbb_.AddOffset(ListViewOptions::VT_BACKGROUNDIMAGEDATA, backGroundImageData); + } + void add_clipEnabled(bool clipEnabled) { + fbb_.AddElement(ListViewOptions::VT_CLIPENABLED, static_cast(clipEnabled), 0); + } + void add_bgColor(const flatbuffers::Color *bgColor) { + fbb_.AddStruct(ListViewOptions::VT_BGCOLOR, bgColor); + } + void add_bgStartColor(const flatbuffers::Color *bgStartColor) { + fbb_.AddStruct(ListViewOptions::VT_BGSTARTCOLOR, bgStartColor); + } + void add_bgEndColor(const flatbuffers::Color *bgEndColor) { + fbb_.AddStruct(ListViewOptions::VT_BGENDCOLOR, bgEndColor); + } + void add_colorType(int32_t colorType) { + fbb_.AddElement(ListViewOptions::VT_COLORTYPE, colorType, 0); + } + void add_bgColorOpacity(uint8_t bgColorOpacity) { + fbb_.AddElement(ListViewOptions::VT_BGCOLOROPACITY, bgColorOpacity, 255); + } + void add_colorVector(const flatbuffers::ColorVector *colorVector) { + fbb_.AddStruct(ListViewOptions::VT_COLORVECTOR, colorVector); + } + void add_capInsets(const flatbuffers::CapInsets *capInsets) { + fbb_.AddStruct(ListViewOptions::VT_CAPINSETS, capInsets); + } + void add_scale9Size(const flatbuffers::FlatSize *scale9Size) { + fbb_.AddStruct(ListViewOptions::VT_SCALE9SIZE, scale9Size); + } + void add_backGroundScale9Enabled(bool backGroundScale9Enabled) { + fbb_.AddElement(ListViewOptions::VT_BACKGROUNDSCALE9ENABLED, static_cast(backGroundScale9Enabled), 0); + } + void add_innerSize(const flatbuffers::FlatSize *innerSize) { + fbb_.AddStruct(ListViewOptions::VT_INNERSIZE, innerSize); + } + void add_direction(int32_t direction) { + fbb_.AddElement(ListViewOptions::VT_DIRECTION, direction, 0); + } + void add_bounceEnabled(bool bounceEnabled) { + fbb_.AddElement(ListViewOptions::VT_BOUNCEENABLED, static_cast(bounceEnabled), 0); + } + void add_itemMargin(int32_t itemMargin) { + fbb_.AddElement(ListViewOptions::VT_ITEMMARGIN, itemMargin, 0); + } + void add_directionType(flatbuffers::Offset directionType) { + fbb_.AddOffset(ListViewOptions::VT_DIRECTIONTYPE, directionType); + } + void add_horizontalType(flatbuffers::Offset horizontalType) { + fbb_.AddOffset(ListViewOptions::VT_HORIZONTALTYPE, horizontalType); + } + void add_verticalType(flatbuffers::Offset verticalType) { + fbb_.AddOffset(ListViewOptions::VT_VERTICALTYPE, verticalType); + } + explicit ListViewOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) + : fbb_(_fbb) { + start_ = fbb_.StartTable(); + } + flatbuffers::Offset Finish() { + const auto end = fbb_.EndTable(start_); + auto o = flatbuffers::Offset(end); + return o; + } }; inline flatbuffers::Offset CreateListViewOptions( - flatbuffers::FlatBufferBuilder& _fbb, - flatbuffers::Offset widgetOptions = 0, - flatbuffers::Offset backGroundImageData = 0, - bool clipEnabled = false, - const Color* bgColor = 0, - const Color* bgStartColor = 0, - const Color* bgEndColor = 0, - int32_t colorType = 0, - uint8_t bgColorOpacity = 255, - const ColorVector* colorVector = 0, - const CapInsets* capInsets = 0, - const FlatSize* scale9Size = 0, - bool backGroundScale9Enabled = false, - const FlatSize* innerSize = 0, - int32_t direction = 0, - bool bounceEnabled = false, - int32_t itemMargin = 0, - flatbuffers::Offset directionType = 0, + flatbuffers::FlatBufferBuilder &_fbb, + flatbuffers::Offset widgetOptions = 0, + flatbuffers::Offset backGroundImageData = 0, + bool clipEnabled = false, + const flatbuffers::Color *bgColor = nullptr, + const flatbuffers::Color *bgStartColor = nullptr, + const flatbuffers::Color *bgEndColor = nullptr, + int32_t colorType = 0, + uint8_t bgColorOpacity = 255, + const flatbuffers::ColorVector *colorVector = nullptr, + const flatbuffers::CapInsets *capInsets = nullptr, + const flatbuffers::FlatSize *scale9Size = nullptr, + bool backGroundScale9Enabled = false, + const flatbuffers::FlatSize *innerSize = nullptr, + int32_t direction = 0, + bool bounceEnabled = false, + int32_t itemMargin = 0, + flatbuffers::Offset directionType = 0, flatbuffers::Offset horizontalType = 0, - flatbuffers::Offset verticalType = 0) -{ - ListViewOptionsBuilder builder_(_fbb); - builder_.add_verticalType(verticalType); - builder_.add_horizontalType(horizontalType); - builder_.add_directionType(directionType); - builder_.add_itemMargin(itemMargin); - builder_.add_direction(direction); - builder_.add_innerSize(innerSize); - builder_.add_scale9Size(scale9Size); - builder_.add_capInsets(capInsets); - builder_.add_colorVector(colorVector); - builder_.add_colorType(colorType); - builder_.add_bgEndColor(bgEndColor); - builder_.add_bgStartColor(bgStartColor); - builder_.add_bgColor(bgColor); - builder_.add_backGroundImageData(backGroundImageData); - builder_.add_widgetOptions(widgetOptions); - builder_.add_bounceEnabled(bounceEnabled); - builder_.add_backGroundScale9Enabled(backGroundScale9Enabled); - builder_.add_bgColorOpacity(bgColorOpacity); - builder_.add_clipEnabled(clipEnabled); - return builder_.Finish(); + flatbuffers::Offset verticalType = 0) { + ListViewOptionsBuilder builder_(_fbb); + builder_.add_verticalType(verticalType); + builder_.add_horizontalType(horizontalType); + builder_.add_directionType(directionType); + builder_.add_itemMargin(itemMargin); + builder_.add_direction(direction); + builder_.add_innerSize(innerSize); + builder_.add_scale9Size(scale9Size); + builder_.add_capInsets(capInsets); + builder_.add_colorVector(colorVector); + builder_.add_colorType(colorType); + builder_.add_bgEndColor(bgEndColor); + builder_.add_bgStartColor(bgStartColor); + builder_.add_bgColor(bgColor); + builder_.add_backGroundImageData(backGroundImageData); + builder_.add_widgetOptions(widgetOptions); + builder_.add_bounceEnabled(bounceEnabled); + builder_.add_backGroundScale9Enabled(backGroundScale9Enabled); + builder_.add_bgColorOpacity(bgColorOpacity); + builder_.add_clipEnabled(clipEnabled); + return builder_.Finish(); } inline flatbuffers::Offset CreateListViewOptionsDirect( - flatbuffers::FlatBufferBuilder& _fbb, - flatbuffers::Offset widgetOptions = 0, - flatbuffers::Offset backGroundImageData = 0, - bool clipEnabled = false, - const Color* bgColor = 0, - const Color* bgStartColor = 0, - const Color* bgEndColor = 0, - int32_t colorType = 0, - uint8_t bgColorOpacity = 255, - const ColorVector* colorVector = 0, - const CapInsets* capInsets = 0, - const FlatSize* scale9Size = 0, - bool backGroundScale9Enabled = false, - const FlatSize* innerSize = 0, - int32_t direction = 0, - bool bounceEnabled = false, - int32_t itemMargin = 0, - const char* directionType = nullptr, - const char* horizontalType = nullptr, - const char* verticalType = nullptr) -{ - auto directionType__ = directionType ? _fbb.CreateString(directionType) : 0; - auto horizontalType__ = horizontalType ? _fbb.CreateString(horizontalType) : 0; - auto verticalType__ = verticalType ? _fbb.CreateString(verticalType) : 0; - return flatbuffers::CreateListViewOptions( - _fbb, widgetOptions, backGroundImageData, clipEnabled, bgColor, bgStartColor, bgEndColor, colorType, - bgColorOpacity, colorVector, capInsets, scale9Size, backGroundScale9Enabled, innerSize, direction, - bounceEnabled, itemMargin, directionType__, horizontalType__, verticalType__); + flatbuffers::FlatBufferBuilder &_fbb, + flatbuffers::Offset widgetOptions = 0, + flatbuffers::Offset backGroundImageData = 0, + bool clipEnabled = false, + const flatbuffers::Color *bgColor = nullptr, + const flatbuffers::Color *bgStartColor = nullptr, + const flatbuffers::Color *bgEndColor = nullptr, + int32_t colorType = 0, + uint8_t bgColorOpacity = 255, + const flatbuffers::ColorVector *colorVector = nullptr, + const flatbuffers::CapInsets *capInsets = nullptr, + const flatbuffers::FlatSize *scale9Size = nullptr, + bool backGroundScale9Enabled = false, + const flatbuffers::FlatSize *innerSize = nullptr, + int32_t direction = 0, + bool bounceEnabled = false, + int32_t itemMargin = 0, + const char *directionType = nullptr, + const char *horizontalType = nullptr, + const char *verticalType = nullptr) { + auto directionType__ = directionType ? _fbb.CreateString(directionType) : 0; + auto horizontalType__ = horizontalType ? _fbb.CreateString(horizontalType) : 0; + auto verticalType__ = verticalType ? _fbb.CreateString(verticalType) : 0; + return flatbuffers::CreateListViewOptions( + _fbb, + widgetOptions, + backGroundImageData, + clipEnabled, + bgColor, + bgStartColor, + bgEndColor, + colorType, + bgColorOpacity, + colorVector, + capInsets, + scale9Size, + backGroundScale9Enabled, + innerSize, + direction, + bounceEnabled, + itemMargin, + directionType__, + horizontalType__, + verticalType__); } -struct TextFieldExOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table -{ - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE - { - VT_NODEOPTIONS = 4, - VT_FONTRESOURCE = 6, - VT_FONTNAME = 8, - VT_FONTSIZE = 10, - VT_TEXT = 12, - VT_PLACEHOLDERTEXT = 14, - VT_PASSWORDENABLED = 16, - VT_PASSWORDSTYLETEXT = 18, - VT_MAXLENGTH = 20, - VT_TEXTCOLOR = 22, - VT_PLACEHOLDERCOLOR = 24, - VT_CURSORCOLOR = 26, - VT_ENABLED = 28, - VT_EDITABLE = 30, - VT_ISLOCALIZED = 32 - }; - const WidgetOptions* nodeOptions() const { return GetPointer(VT_NODEOPTIONS); } - const ResourceData* fontResource() const { return GetPointer(VT_FONTRESOURCE); } - const flatbuffers::String* fontName() const { return GetPointer(VT_FONTNAME); } - int32_t fontSize() const { return GetField(VT_FONTSIZE, 0); } - const flatbuffers::String* text() const { return GetPointer(VT_TEXT); } - const flatbuffers::String* placeholderText() const - { - return GetPointer(VT_PLACEHOLDERTEXT); - } - bool passwordEnabled() const { return GetField(VT_PASSWORDENABLED, 0) != 0; } - const flatbuffers::String* passwordStyleText() const - { - return GetPointer(VT_PASSWORDSTYLETEXT); - } - int32_t maxLength() const { return GetField(VT_MAXLENGTH, 0); } - const Color* textColor() const { return GetStruct(VT_TEXTCOLOR); } - const Color* placeholderColor() const { return GetStruct(VT_PLACEHOLDERCOLOR); } - const Color* cursorColor() const { return GetStruct(VT_CURSORCOLOR); } - bool enabled() const { return GetField(VT_ENABLED, 1) != 0; } - bool editable() const { return GetField(VT_EDITABLE, 1) != 0; } - bool isLocalized() const { return GetField(VT_ISLOCALIZED, 0) != 0; } - bool Verify(flatbuffers::Verifier& verifier) const - { - return VerifyTableStart(verifier) && VerifyOffset(verifier, VT_NODEOPTIONS) && - verifier.VerifyTable(nodeOptions()) && VerifyOffset(verifier, VT_FONTRESOURCE) && - verifier.VerifyTable(fontResource()) && VerifyOffset(verifier, VT_FONTNAME) && - verifier.VerifyString(fontName()) && VerifyField(verifier, VT_FONTSIZE) && - VerifyOffset(verifier, VT_TEXT) && verifier.VerifyString(text()) && - VerifyOffset(verifier, VT_PLACEHOLDERTEXT) && verifier.VerifyString(placeholderText()) && - VerifyField(verifier, VT_PASSWORDENABLED) && VerifyOffset(verifier, VT_PASSWORDSTYLETEXT) && - verifier.VerifyString(passwordStyleText()) && VerifyField(verifier, VT_MAXLENGTH) && - VerifyField(verifier, VT_TEXTCOLOR) && VerifyField(verifier, VT_PLACEHOLDERCOLOR) && - VerifyField(verifier, VT_CURSORCOLOR) && VerifyField(verifier, VT_ENABLED) && - VerifyField(verifier, VT_EDITABLE) && VerifyField(verifier, VT_ISLOCALIZED) && - verifier.EndTable(); - } +struct TextFieldExOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { + typedef TextFieldExOptionsBuilder Builder; + enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { + VT_NODEOPTIONS = 4, + VT_FONTRESOURCE = 6, + VT_FONTNAME = 8, + VT_FONTSIZE = 10, + VT_TEXT = 12, + VT_PLACEHOLDERTEXT = 14, + VT_PASSWORDENABLED = 16, + VT_PASSWORDSTYLETEXT = 18, + VT_MAXLENGTH = 20, + VT_TEXTCOLOR = 22, + VT_PLACEHOLDERCOLOR = 24, + VT_CURSORCOLOR = 26, + VT_ENABLED = 28, + VT_EDITABLE = 30, + VT_ISLOCALIZED = 32 + }; + const flatbuffers::WidgetOptions *nodeOptions() const { + return GetPointer(VT_NODEOPTIONS); + } + const flatbuffers::ResourceData *fontResource() const { + return GetPointer(VT_FONTRESOURCE); + } + const flatbuffers::String *fontName() const { + return GetPointer(VT_FONTNAME); + } + int32_t fontSize() const { + return GetField(VT_FONTSIZE, 0); + } + const flatbuffers::String *text() const { + return GetPointer(VT_TEXT); + } + const flatbuffers::String *placeholderText() const { + return GetPointer(VT_PLACEHOLDERTEXT); + } + bool passwordEnabled() const { + return GetField(VT_PASSWORDENABLED, 0) != 0; + } + const flatbuffers::String *passwordStyleText() const { + return GetPointer(VT_PASSWORDSTYLETEXT); + } + int32_t maxLength() const { + return GetField(VT_MAXLENGTH, 0); + } + const flatbuffers::Color *textColor() const { + return GetStruct(VT_TEXTCOLOR); + } + const flatbuffers::Color *placeholderColor() const { + return GetStruct(VT_PLACEHOLDERCOLOR); + } + const flatbuffers::Color *cursorColor() const { + return GetStruct(VT_CURSORCOLOR); + } + bool enabled() const { + return GetField(VT_ENABLED, 1) != 0; + } + bool editable() const { + return GetField(VT_EDITABLE, 1) != 0; + } + bool isLocalized() const { + return GetField(VT_ISLOCALIZED, 0) != 0; + } + bool Verify(flatbuffers::Verifier &verifier) const { + return VerifyTableStart(verifier) && + VerifyOffset(verifier, VT_NODEOPTIONS) && + verifier.VerifyTable(nodeOptions()) && + VerifyOffset(verifier, VT_FONTRESOURCE) && + verifier.VerifyTable(fontResource()) && + VerifyOffset(verifier, VT_FONTNAME) && + verifier.VerifyString(fontName()) && + VerifyField(verifier, VT_FONTSIZE, 4) && + VerifyOffset(verifier, VT_TEXT) && + verifier.VerifyString(text()) && + VerifyOffset(verifier, VT_PLACEHOLDERTEXT) && + verifier.VerifyString(placeholderText()) && + VerifyField(verifier, VT_PASSWORDENABLED, 1) && + VerifyOffset(verifier, VT_PASSWORDSTYLETEXT) && + verifier.VerifyString(passwordStyleText()) && + VerifyField(verifier, VT_MAXLENGTH, 4) && + VerifyField(verifier, VT_TEXTCOLOR, 1) && + VerifyField(verifier, VT_PLACEHOLDERCOLOR, 1) && + VerifyField(verifier, VT_CURSORCOLOR, 1) && + VerifyField(verifier, VT_ENABLED, 1) && + VerifyField(verifier, VT_EDITABLE, 1) && + VerifyField(verifier, VT_ISLOCALIZED, 1) && + verifier.EndTable(); + } }; -struct TextFieldExOptionsBuilder -{ - flatbuffers::FlatBufferBuilder& fbb_; - flatbuffers::uoffset_t start_; - void add_nodeOptions(flatbuffers::Offset nodeOptions) - { - fbb_.AddOffset(TextFieldExOptions::VT_NODEOPTIONS, nodeOptions); - } - void add_fontResource(flatbuffers::Offset fontResource) - { - fbb_.AddOffset(TextFieldExOptions::VT_FONTRESOURCE, fontResource); - } - void add_fontName(flatbuffers::Offset fontName) - { - fbb_.AddOffset(TextFieldExOptions::VT_FONTNAME, fontName); - } - void add_fontSize(int32_t fontSize) { fbb_.AddElement(TextFieldExOptions::VT_FONTSIZE, fontSize, 0); } - void add_text(flatbuffers::Offset text) { fbb_.AddOffset(TextFieldExOptions::VT_TEXT, text); } - void add_placeholderText(flatbuffers::Offset placeholderText) - { - fbb_.AddOffset(TextFieldExOptions::VT_PLACEHOLDERTEXT, placeholderText); - } - void add_passwordEnabled(bool passwordEnabled) - { - fbb_.AddElement(TextFieldExOptions::VT_PASSWORDENABLED, static_cast(passwordEnabled), 0); - } - void add_passwordStyleText(flatbuffers::Offset passwordStyleText) - { - fbb_.AddOffset(TextFieldExOptions::VT_PASSWORDSTYLETEXT, passwordStyleText); - } - void add_maxLength(int32_t maxLength) { fbb_.AddElement(TextFieldExOptions::VT_MAXLENGTH, maxLength, 0); } - void add_textColor(const Color* textColor) { fbb_.AddStruct(TextFieldExOptions::VT_TEXTCOLOR, textColor); } - void add_placeholderColor(const Color* placeholderColor) - { - fbb_.AddStruct(TextFieldExOptions::VT_PLACEHOLDERCOLOR, placeholderColor); - } - void add_cursorColor(const Color* cursorColor) { fbb_.AddStruct(TextFieldExOptions::VT_CURSORCOLOR, cursorColor); } - void add_enabled(bool enabled) - { - fbb_.AddElement(TextFieldExOptions::VT_ENABLED, static_cast(enabled), 1); - } - void add_editable(bool editable) - { - fbb_.AddElement(TextFieldExOptions::VT_EDITABLE, static_cast(editable), 1); - } - void add_isLocalized(bool isLocalized) - { - fbb_.AddElement(TextFieldExOptions::VT_ISLOCALIZED, static_cast(isLocalized), 0); - } - explicit TextFieldExOptionsBuilder(flatbuffers::FlatBufferBuilder& _fbb) : fbb_(_fbb) - { - start_ = fbb_.StartTable(); - } - TextFieldExOptionsBuilder& operator=(const TextFieldExOptionsBuilder&); - flatbuffers::Offset Finish() - { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset(end); - return o; - } +struct TextFieldExOptionsBuilder { + typedef TextFieldExOptions Table; + flatbuffers::FlatBufferBuilder &fbb_; + flatbuffers::uoffset_t start_; + void add_nodeOptions(flatbuffers::Offset nodeOptions) { + fbb_.AddOffset(TextFieldExOptions::VT_NODEOPTIONS, nodeOptions); + } + void add_fontResource(flatbuffers::Offset fontResource) { + fbb_.AddOffset(TextFieldExOptions::VT_FONTRESOURCE, fontResource); + } + void add_fontName(flatbuffers::Offset fontName) { + fbb_.AddOffset(TextFieldExOptions::VT_FONTNAME, fontName); + } + void add_fontSize(int32_t fontSize) { + fbb_.AddElement(TextFieldExOptions::VT_FONTSIZE, fontSize, 0); + } + void add_text(flatbuffers::Offset text) { + fbb_.AddOffset(TextFieldExOptions::VT_TEXT, text); + } + void add_placeholderText(flatbuffers::Offset placeholderText) { + fbb_.AddOffset(TextFieldExOptions::VT_PLACEHOLDERTEXT, placeholderText); + } + void add_passwordEnabled(bool passwordEnabled) { + fbb_.AddElement(TextFieldExOptions::VT_PASSWORDENABLED, static_cast(passwordEnabled), 0); + } + void add_passwordStyleText(flatbuffers::Offset passwordStyleText) { + fbb_.AddOffset(TextFieldExOptions::VT_PASSWORDSTYLETEXT, passwordStyleText); + } + void add_maxLength(int32_t maxLength) { + fbb_.AddElement(TextFieldExOptions::VT_MAXLENGTH, maxLength, 0); + } + void add_textColor(const flatbuffers::Color *textColor) { + fbb_.AddStruct(TextFieldExOptions::VT_TEXTCOLOR, textColor); + } + void add_placeholderColor(const flatbuffers::Color *placeholderColor) { + fbb_.AddStruct(TextFieldExOptions::VT_PLACEHOLDERCOLOR, placeholderColor); + } + void add_cursorColor(const flatbuffers::Color *cursorColor) { + fbb_.AddStruct(TextFieldExOptions::VT_CURSORCOLOR, cursorColor); + } + void add_enabled(bool enabled) { + fbb_.AddElement(TextFieldExOptions::VT_ENABLED, static_cast(enabled), 1); + } + void add_editable(bool editable) { + fbb_.AddElement(TextFieldExOptions::VT_EDITABLE, static_cast(editable), 1); + } + void add_isLocalized(bool isLocalized) { + fbb_.AddElement(TextFieldExOptions::VT_ISLOCALIZED, static_cast(isLocalized), 0); + } + explicit TextFieldExOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) + : fbb_(_fbb) { + start_ = fbb_.StartTable(); + } + flatbuffers::Offset Finish() { + const auto end = fbb_.EndTable(start_); + auto o = flatbuffers::Offset(end); + return o; + } }; inline flatbuffers::Offset CreateTextFieldExOptions( - flatbuffers::FlatBufferBuilder& _fbb, - flatbuffers::Offset nodeOptions = 0, - flatbuffers::Offset fontResource = 0, - flatbuffers::Offset fontName = 0, - int32_t fontSize = 0, - flatbuffers::Offset text = 0, - flatbuffers::Offset placeholderText = 0, - bool passwordEnabled = false, + flatbuffers::FlatBufferBuilder &_fbb, + flatbuffers::Offset nodeOptions = 0, + flatbuffers::Offset fontResource = 0, + flatbuffers::Offset fontName = 0, + int32_t fontSize = 0, + flatbuffers::Offset text = 0, + flatbuffers::Offset placeholderText = 0, + bool passwordEnabled = false, flatbuffers::Offset passwordStyleText = 0, - int32_t maxLength = 0, - const Color* textColor = 0, - const Color* placeholderColor = 0, - const Color* cursorColor = 0, - bool enabled = true, - bool editable = true, - bool isLocalized = false) -{ - TextFieldExOptionsBuilder builder_(_fbb); - builder_.add_cursorColor(cursorColor); - builder_.add_placeholderColor(placeholderColor); - builder_.add_textColor(textColor); - builder_.add_maxLength(maxLength); - builder_.add_passwordStyleText(passwordStyleText); - builder_.add_placeholderText(placeholderText); - builder_.add_text(text); - builder_.add_fontSize(fontSize); - builder_.add_fontName(fontName); - builder_.add_fontResource(fontResource); - builder_.add_nodeOptions(nodeOptions); - builder_.add_isLocalized(isLocalized); - builder_.add_editable(editable); - builder_.add_enabled(enabled); - builder_.add_passwordEnabled(passwordEnabled); - return builder_.Finish(); + int32_t maxLength = 0, + const flatbuffers::Color *textColor = nullptr, + const flatbuffers::Color *placeholderColor = nullptr, + const flatbuffers::Color *cursorColor = nullptr, + bool enabled = true, + bool editable = true, + bool isLocalized = false) { + TextFieldExOptionsBuilder builder_(_fbb); + builder_.add_cursorColor(cursorColor); + builder_.add_placeholderColor(placeholderColor); + builder_.add_textColor(textColor); + builder_.add_maxLength(maxLength); + builder_.add_passwordStyleText(passwordStyleText); + builder_.add_placeholderText(placeholderText); + builder_.add_text(text); + builder_.add_fontSize(fontSize); + builder_.add_fontName(fontName); + builder_.add_fontResource(fontResource); + builder_.add_nodeOptions(nodeOptions); + builder_.add_isLocalized(isLocalized); + builder_.add_editable(editable); + builder_.add_enabled(enabled); + builder_.add_passwordEnabled(passwordEnabled); + return builder_.Finish(); } inline flatbuffers::Offset CreateTextFieldExOptionsDirect( - flatbuffers::FlatBufferBuilder& _fbb, - flatbuffers::Offset nodeOptions = 0, - flatbuffers::Offset fontResource = 0, - const char* fontName = nullptr, - int32_t fontSize = 0, - const char* text = nullptr, - const char* placeholderText = nullptr, - bool passwordEnabled = false, - const char* passwordStyleText = nullptr, - int32_t maxLength = 0, - const Color* textColor = 0, - const Color* placeholderColor = 0, - const Color* cursorColor = 0, - bool enabled = true, - bool editable = true, - bool isLocalized = false) -{ - auto fontName__ = fontName ? _fbb.CreateString(fontName) : 0; - auto text__ = text ? _fbb.CreateString(text) : 0; - auto placeholderText__ = placeholderText ? _fbb.CreateString(placeholderText) : 0; - auto passwordStyleText__ = passwordStyleText ? _fbb.CreateString(passwordStyleText) : 0; - return flatbuffers::CreateTextFieldExOptions( - _fbb, nodeOptions, fontResource, fontName__, fontSize, text__, placeholderText__, passwordEnabled, - passwordStyleText__, maxLength, textColor, placeholderColor, cursorColor, enabled, editable, isLocalized); + flatbuffers::FlatBufferBuilder &_fbb, + flatbuffers::Offset nodeOptions = 0, + flatbuffers::Offset fontResource = 0, + const char *fontName = nullptr, + int32_t fontSize = 0, + const char *text = nullptr, + const char *placeholderText = nullptr, + bool passwordEnabled = false, + const char *passwordStyleText = nullptr, + int32_t maxLength = 0, + const flatbuffers::Color *textColor = nullptr, + const flatbuffers::Color *placeholderColor = nullptr, + const flatbuffers::Color *cursorColor = nullptr, + bool enabled = true, + bool editable = true, + bool isLocalized = false) { + auto fontName__ = fontName ? _fbb.CreateString(fontName) : 0; + auto text__ = text ? _fbb.CreateString(text) : 0; + auto placeholderText__ = placeholderText ? _fbb.CreateString(placeholderText) : 0; + auto passwordStyleText__ = passwordStyleText ? _fbb.CreateString(passwordStyleText) : 0; + return flatbuffers::CreateTextFieldExOptions( + _fbb, + nodeOptions, + fontResource, + fontName__, + fontSize, + text__, + placeholderText__, + passwordEnabled, + passwordStyleText__, + maxLength, + textColor, + placeholderColor, + cursorColor, + enabled, + editable, + isLocalized); } -struct ProjectNodeOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table -{ - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE - { - VT_NODEOPTIONS = 4, - VT_FILENAME = 6, - VT_INNERACTIONSPEED = 8 - }; - const WidgetOptions* nodeOptions() const { return GetPointer(VT_NODEOPTIONS); } - const flatbuffers::String* fileName() const { return GetPointer(VT_FILENAME); } - float innerActionSpeed() const { return GetField(VT_INNERACTIONSPEED, 0.0f); } - bool Verify(flatbuffers::Verifier& verifier) const - { - return VerifyTableStart(verifier) && VerifyOffset(verifier, VT_NODEOPTIONS) && - verifier.VerifyTable(nodeOptions()) && VerifyOffset(verifier, VT_FILENAME) && - verifier.VerifyString(fileName()) && VerifyField(verifier, VT_INNERACTIONSPEED) && - verifier.EndTable(); - } +struct ProjectNodeOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { + typedef ProjectNodeOptionsBuilder Builder; + enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { + VT_NODEOPTIONS = 4, + VT_FILENAME = 6, + VT_INNERACTIONSPEED = 8 + }; + const flatbuffers::WidgetOptions *nodeOptions() const { + return GetPointer(VT_NODEOPTIONS); + } + const flatbuffers::String *fileName() const { + return GetPointer(VT_FILENAME); + } + float innerActionSpeed() const { + return GetField(VT_INNERACTIONSPEED, 0.0f); + } + bool Verify(flatbuffers::Verifier &verifier) const { + return VerifyTableStart(verifier) && + VerifyOffset(verifier, VT_NODEOPTIONS) && + verifier.VerifyTable(nodeOptions()) && + VerifyOffset(verifier, VT_FILENAME) && + verifier.VerifyString(fileName()) && + VerifyField(verifier, VT_INNERACTIONSPEED, 4) && + verifier.EndTable(); + } }; -struct ProjectNodeOptionsBuilder -{ - flatbuffers::FlatBufferBuilder& fbb_; - flatbuffers::uoffset_t start_; - void add_nodeOptions(flatbuffers::Offset nodeOptions) - { - fbb_.AddOffset(ProjectNodeOptions::VT_NODEOPTIONS, nodeOptions); - } - void add_fileName(flatbuffers::Offset fileName) - { - fbb_.AddOffset(ProjectNodeOptions::VT_FILENAME, fileName); - } - void add_innerActionSpeed(float innerActionSpeed) - { - fbb_.AddElement(ProjectNodeOptions::VT_INNERACTIONSPEED, innerActionSpeed, 0.0f); - } - explicit ProjectNodeOptionsBuilder(flatbuffers::FlatBufferBuilder& _fbb) : fbb_(_fbb) - { - start_ = fbb_.StartTable(); - } - ProjectNodeOptionsBuilder& operator=(const ProjectNodeOptionsBuilder&); - flatbuffers::Offset Finish() - { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset(end); - return o; - } +struct ProjectNodeOptionsBuilder { + typedef ProjectNodeOptions Table; + flatbuffers::FlatBufferBuilder &fbb_; + flatbuffers::uoffset_t start_; + void add_nodeOptions(flatbuffers::Offset nodeOptions) { + fbb_.AddOffset(ProjectNodeOptions::VT_NODEOPTIONS, nodeOptions); + } + void add_fileName(flatbuffers::Offset fileName) { + fbb_.AddOffset(ProjectNodeOptions::VT_FILENAME, fileName); + } + void add_innerActionSpeed(float innerActionSpeed) { + fbb_.AddElement(ProjectNodeOptions::VT_INNERACTIONSPEED, innerActionSpeed, 0.0f); + } + explicit ProjectNodeOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) + : fbb_(_fbb) { + start_ = fbb_.StartTable(); + } + flatbuffers::Offset Finish() { + const auto end = fbb_.EndTable(start_); + auto o = flatbuffers::Offset(end); + return o; + } }; inline flatbuffers::Offset CreateProjectNodeOptions( - flatbuffers::FlatBufferBuilder& _fbb, - flatbuffers::Offset nodeOptions = 0, + flatbuffers::FlatBufferBuilder &_fbb, + flatbuffers::Offset nodeOptions = 0, flatbuffers::Offset fileName = 0, - float innerActionSpeed = 0.0f) -{ - ProjectNodeOptionsBuilder builder_(_fbb); - builder_.add_innerActionSpeed(innerActionSpeed); - builder_.add_fileName(fileName); - builder_.add_nodeOptions(nodeOptions); - return builder_.Finish(); + float innerActionSpeed = 0.0f) { + ProjectNodeOptionsBuilder builder_(_fbb); + builder_.add_innerActionSpeed(innerActionSpeed); + builder_.add_fileName(fileName); + builder_.add_nodeOptions(nodeOptions); + return builder_.Finish(); } inline flatbuffers::Offset CreateProjectNodeOptionsDirect( - flatbuffers::FlatBufferBuilder& _fbb, - flatbuffers::Offset nodeOptions = 0, - const char* fileName = nullptr, - float innerActionSpeed = 0.0f) -{ - auto fileName__ = fileName ? _fbb.CreateString(fileName) : 0; - return flatbuffers::CreateProjectNodeOptions(_fbb, nodeOptions, fileName__, innerActionSpeed); + flatbuffers::FlatBufferBuilder &_fbb, + flatbuffers::Offset nodeOptions = 0, + const char *fileName = nullptr, + float innerActionSpeed = 0.0f) { + auto fileName__ = fileName ? _fbb.CreateString(fileName) : 0; + return flatbuffers::CreateProjectNodeOptions( + _fbb, + nodeOptions, + fileName__, + innerActionSpeed); } -struct ComponentOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table -{ - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE - { - VT_NODEOPTIONS = 4, - VT_TYPE = 6, - VT_COMAUDIOOPTIONS = 8 - }; - const WidgetOptions* nodeOptions() const { return GetPointer(VT_NODEOPTIONS); } - const flatbuffers::String* type() const { return GetPointer(VT_TYPE); } - const ComAudioOptions* comAudioOptions() const { return GetPointer(VT_COMAUDIOOPTIONS); } - bool Verify(flatbuffers::Verifier& verifier) const - { - return VerifyTableStart(verifier) && VerifyOffset(verifier, VT_NODEOPTIONS) && - verifier.VerifyTable(nodeOptions()) && VerifyOffset(verifier, VT_TYPE) && - verifier.VerifyString(type()) && VerifyOffset(verifier, VT_COMAUDIOOPTIONS) && - verifier.VerifyTable(comAudioOptions()) && verifier.EndTable(); - } +struct ComponentOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { + typedef ComponentOptionsBuilder Builder; + enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { + VT_NODEOPTIONS = 4, + VT_TYPE = 6, + VT_COMAUDIOOPTIONS = 8 + }; + const flatbuffers::WidgetOptions *nodeOptions() const { + return GetPointer(VT_NODEOPTIONS); + } + const flatbuffers::String *type() const { + return GetPointer(VT_TYPE); + } + const flatbuffers::ComAudioOptions *comAudioOptions() const { + return GetPointer(VT_COMAUDIOOPTIONS); + } + bool Verify(flatbuffers::Verifier &verifier) const { + return VerifyTableStart(verifier) && + VerifyOffset(verifier, VT_NODEOPTIONS) && + verifier.VerifyTable(nodeOptions()) && + VerifyOffset(verifier, VT_TYPE) && + verifier.VerifyString(type()) && + VerifyOffset(verifier, VT_COMAUDIOOPTIONS) && + verifier.VerifyTable(comAudioOptions()) && + verifier.EndTable(); + } }; -struct ComponentOptionsBuilder -{ - flatbuffers::FlatBufferBuilder& fbb_; - flatbuffers::uoffset_t start_; - void add_nodeOptions(flatbuffers::Offset nodeOptions) - { - fbb_.AddOffset(ComponentOptions::VT_NODEOPTIONS, nodeOptions); - } - void add_type(flatbuffers::Offset type) { fbb_.AddOffset(ComponentOptions::VT_TYPE, type); } - void add_comAudioOptions(flatbuffers::Offset comAudioOptions) - { - fbb_.AddOffset(ComponentOptions::VT_COMAUDIOOPTIONS, comAudioOptions); - } - explicit ComponentOptionsBuilder(flatbuffers::FlatBufferBuilder& _fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } - ComponentOptionsBuilder& operator=(const ComponentOptionsBuilder&); - flatbuffers::Offset Finish() - { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset(end); - return o; - } +struct ComponentOptionsBuilder { + typedef ComponentOptions Table; + flatbuffers::FlatBufferBuilder &fbb_; + flatbuffers::uoffset_t start_; + void add_nodeOptions(flatbuffers::Offset nodeOptions) { + fbb_.AddOffset(ComponentOptions::VT_NODEOPTIONS, nodeOptions); + } + void add_type(flatbuffers::Offset type) { + fbb_.AddOffset(ComponentOptions::VT_TYPE, type); + } + void add_comAudioOptions(flatbuffers::Offset comAudioOptions) { + fbb_.AddOffset(ComponentOptions::VT_COMAUDIOOPTIONS, comAudioOptions); + } + explicit ComponentOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) + : fbb_(_fbb) { + start_ = fbb_.StartTable(); + } + flatbuffers::Offset Finish() { + const auto end = fbb_.EndTable(start_); + auto o = flatbuffers::Offset(end); + return o; + } }; inline flatbuffers::Offset CreateComponentOptions( - flatbuffers::FlatBufferBuilder& _fbb, - flatbuffers::Offset nodeOptions = 0, - flatbuffers::Offset type = 0, - flatbuffers::Offset comAudioOptions = 0) -{ - ComponentOptionsBuilder builder_(_fbb); - builder_.add_comAudioOptions(comAudioOptions); - builder_.add_type(type); - builder_.add_nodeOptions(nodeOptions); - return builder_.Finish(); + flatbuffers::FlatBufferBuilder &_fbb, + flatbuffers::Offset nodeOptions = 0, + flatbuffers::Offset type = 0, + flatbuffers::Offset comAudioOptions = 0) { + ComponentOptionsBuilder builder_(_fbb); + builder_.add_comAudioOptions(comAudioOptions); + builder_.add_type(type); + builder_.add_nodeOptions(nodeOptions); + return builder_.Finish(); } inline flatbuffers::Offset CreateComponentOptionsDirect( - flatbuffers::FlatBufferBuilder& _fbb, - flatbuffers::Offset nodeOptions = 0, - const char* type = nullptr, - flatbuffers::Offset comAudioOptions = 0) -{ - auto type__ = type ? _fbb.CreateString(type) : 0; - return flatbuffers::CreateComponentOptions(_fbb, nodeOptions, type__, comAudioOptions); + flatbuffers::FlatBufferBuilder &_fbb, + flatbuffers::Offset nodeOptions = 0, + const char *type = nullptr, + flatbuffers::Offset comAudioOptions = 0) { + auto type__ = type ? _fbb.CreateString(type) : 0; + return flatbuffers::CreateComponentOptions( + _fbb, + nodeOptions, + type__, + comAudioOptions); } -struct ComAudioOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table -{ - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE - { - VT_NODEOPTIONS = 4, - VT_NAME = 6, - VT_ENABLED = 8, - VT_LOOP = 10, - VT_VOLUME = 12, - VT_FILENAMEDATA = 14 - }; - const WidgetOptions* nodeOptions() const { return GetPointer(VT_NODEOPTIONS); } - const flatbuffers::String* name() const { return GetPointer(VT_NAME); } - bool enabled() const { return GetField(VT_ENABLED, 0) != 0; } - bool loop() const { return GetField(VT_LOOP, 0) != 0; } - int32_t volume() const { return GetField(VT_VOLUME, 0); } - const ResourceData* fileNameData() const { return GetPointer(VT_FILENAMEDATA); } - bool Verify(flatbuffers::Verifier& verifier) const - { - return VerifyTableStart(verifier) && VerifyOffset(verifier, VT_NODEOPTIONS) && - verifier.VerifyTable(nodeOptions()) && VerifyOffset(verifier, VT_NAME) && - verifier.VerifyString(name()) && VerifyField(verifier, VT_ENABLED) && - VerifyField(verifier, VT_LOOP) && VerifyField(verifier, VT_VOLUME) && - VerifyOffset(verifier, VT_FILENAMEDATA) && verifier.VerifyTable(fileNameData()) && verifier.EndTable(); - } +struct ComAudioOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { + typedef ComAudioOptionsBuilder Builder; + enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { + VT_NODEOPTIONS = 4, + VT_NAME = 6, + VT_ENABLED = 8, + VT_LOOP = 10, + VT_VOLUME = 12, + VT_FILENAMEDATA = 14 + }; + const flatbuffers::WidgetOptions *nodeOptions() const { + return GetPointer(VT_NODEOPTIONS); + } + const flatbuffers::String *name() const { + return GetPointer(VT_NAME); + } + bool enabled() const { + return GetField(VT_ENABLED, 0) != 0; + } + bool loop() const { + return GetField(VT_LOOP, 0) != 0; + } + int32_t volume() const { + return GetField(VT_VOLUME, 0); + } + const flatbuffers::ResourceData *fileNameData() const { + return GetPointer(VT_FILENAMEDATA); + } + bool Verify(flatbuffers::Verifier &verifier) const { + return VerifyTableStart(verifier) && + VerifyOffset(verifier, VT_NODEOPTIONS) && + verifier.VerifyTable(nodeOptions()) && + VerifyOffset(verifier, VT_NAME) && + verifier.VerifyString(name()) && + VerifyField(verifier, VT_ENABLED, 1) && + VerifyField(verifier, VT_LOOP, 1) && + VerifyField(verifier, VT_VOLUME, 4) && + VerifyOffset(verifier, VT_FILENAMEDATA) && + verifier.VerifyTable(fileNameData()) && + verifier.EndTable(); + } }; -struct ComAudioOptionsBuilder -{ - flatbuffers::FlatBufferBuilder& fbb_; - flatbuffers::uoffset_t start_; - void add_nodeOptions(flatbuffers::Offset nodeOptions) - { - fbb_.AddOffset(ComAudioOptions::VT_NODEOPTIONS, nodeOptions); - } - void add_name(flatbuffers::Offset name) { fbb_.AddOffset(ComAudioOptions::VT_NAME, name); } - void add_enabled(bool enabled) - { - fbb_.AddElement(ComAudioOptions::VT_ENABLED, static_cast(enabled), 0); - } - void add_loop(bool loop) { fbb_.AddElement(ComAudioOptions::VT_LOOP, static_cast(loop), 0); } - void add_volume(int32_t volume) { fbb_.AddElement(ComAudioOptions::VT_VOLUME, volume, 0); } - void add_fileNameData(flatbuffers::Offset fileNameData) - { - fbb_.AddOffset(ComAudioOptions::VT_FILENAMEDATA, fileNameData); - } - explicit ComAudioOptionsBuilder(flatbuffers::FlatBufferBuilder& _fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } - ComAudioOptionsBuilder& operator=(const ComAudioOptionsBuilder&); - flatbuffers::Offset Finish() - { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset(end); - return o; - } +struct ComAudioOptionsBuilder { + typedef ComAudioOptions Table; + flatbuffers::FlatBufferBuilder &fbb_; + flatbuffers::uoffset_t start_; + void add_nodeOptions(flatbuffers::Offset nodeOptions) { + fbb_.AddOffset(ComAudioOptions::VT_NODEOPTIONS, nodeOptions); + } + void add_name(flatbuffers::Offset name) { + fbb_.AddOffset(ComAudioOptions::VT_NAME, name); + } + void add_enabled(bool enabled) { + fbb_.AddElement(ComAudioOptions::VT_ENABLED, static_cast(enabled), 0); + } + void add_loop(bool loop) { + fbb_.AddElement(ComAudioOptions::VT_LOOP, static_cast(loop), 0); + } + void add_volume(int32_t volume) { + fbb_.AddElement(ComAudioOptions::VT_VOLUME, volume, 0); + } + void add_fileNameData(flatbuffers::Offset fileNameData) { + fbb_.AddOffset(ComAudioOptions::VT_FILENAMEDATA, fileNameData); + } + explicit ComAudioOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) + : fbb_(_fbb) { + start_ = fbb_.StartTable(); + } + flatbuffers::Offset Finish() { + const auto end = fbb_.EndTable(start_); + auto o = flatbuffers::Offset(end); + return o; + } }; -inline flatbuffers::Offset CreateComAudioOptions(flatbuffers::FlatBufferBuilder& _fbb, - flatbuffers::Offset nodeOptions = 0, - flatbuffers::Offset name = 0, - bool enabled = false, - bool loop = false, - int32_t volume = 0, - flatbuffers::Offset fileNameData = 0) -{ - ComAudioOptionsBuilder builder_(_fbb); - builder_.add_fileNameData(fileNameData); - builder_.add_volume(volume); - builder_.add_name(name); - builder_.add_nodeOptions(nodeOptions); - builder_.add_loop(loop); - builder_.add_enabled(enabled); - return builder_.Finish(); +inline flatbuffers::Offset CreateComAudioOptions( + flatbuffers::FlatBufferBuilder &_fbb, + flatbuffers::Offset nodeOptions = 0, + flatbuffers::Offset name = 0, + bool enabled = false, + bool loop = false, + int32_t volume = 0, + flatbuffers::Offset fileNameData = 0) { + ComAudioOptionsBuilder builder_(_fbb); + builder_.add_fileNameData(fileNameData); + builder_.add_volume(volume); + builder_.add_name(name); + builder_.add_nodeOptions(nodeOptions); + builder_.add_loop(loop); + builder_.add_enabled(enabled); + return builder_.Finish(); } inline flatbuffers::Offset CreateComAudioOptionsDirect( - flatbuffers::FlatBufferBuilder& _fbb, - flatbuffers::Offset nodeOptions = 0, - const char* name = nullptr, - bool enabled = false, - bool loop = false, - int32_t volume = 0, - flatbuffers::Offset fileNameData = 0) -{ - auto name__ = name ? _fbb.CreateString(name) : 0; - return flatbuffers::CreateComAudioOptions(_fbb, nodeOptions, name__, enabled, loop, volume, fileNameData); + flatbuffers::FlatBufferBuilder &_fbb, + flatbuffers::Offset nodeOptions = 0, + const char *name = nullptr, + bool enabled = false, + bool loop = false, + int32_t volume = 0, + flatbuffers::Offset fileNameData = 0) { + auto name__ = name ? _fbb.CreateString(name) : 0; + return flatbuffers::CreateComAudioOptions( + _fbb, + nodeOptions, + name__, + enabled, + loop, + volume, + fileNameData); } -struct AnimationInfo FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table -{ - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE - { - VT_NAME = 4, - VT_STARTINDEX = 6, - VT_ENDINDEX = 8 - }; - const flatbuffers::String* name() const { return GetPointer(VT_NAME); } - int32_t startIndex() const { return GetField(VT_STARTINDEX, 0); } - int32_t endIndex() const { return GetField(VT_ENDINDEX, 0); } - bool Verify(flatbuffers::Verifier& verifier) const - { - return VerifyTableStart(verifier) && VerifyOffset(verifier, VT_NAME) && verifier.VerifyString(name()) && - VerifyField(verifier, VT_STARTINDEX) && VerifyField(verifier, VT_ENDINDEX) && - verifier.EndTable(); - } +struct AnimationInfo FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { + typedef AnimationInfoBuilder Builder; + enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { + VT_NAME = 4, + VT_STARTINDEX = 6, + VT_ENDINDEX = 8 + }; + const flatbuffers::String *name() const { + return GetPointer(VT_NAME); + } + int32_t startIndex() const { + return GetField(VT_STARTINDEX, 0); + } + int32_t endIndex() const { + return GetField(VT_ENDINDEX, 0); + } + bool Verify(flatbuffers::Verifier &verifier) const { + return VerifyTableStart(verifier) && + VerifyOffset(verifier, VT_NAME) && + verifier.VerifyString(name()) && + VerifyField(verifier, VT_STARTINDEX, 4) && + VerifyField(verifier, VT_ENDINDEX, 4) && + verifier.EndTable(); + } }; -struct AnimationInfoBuilder -{ - flatbuffers::FlatBufferBuilder& fbb_; - flatbuffers::uoffset_t start_; - void add_name(flatbuffers::Offset name) { fbb_.AddOffset(AnimationInfo::VT_NAME, name); } - void add_startIndex(int32_t startIndex) { fbb_.AddElement(AnimationInfo::VT_STARTINDEX, startIndex, 0); } - void add_endIndex(int32_t endIndex) { fbb_.AddElement(AnimationInfo::VT_ENDINDEX, endIndex, 0); } - explicit AnimationInfoBuilder(flatbuffers::FlatBufferBuilder& _fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } - AnimationInfoBuilder& operator=(const AnimationInfoBuilder&); - flatbuffers::Offset Finish() - { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset(end); - return o; - } +struct AnimationInfoBuilder { + typedef AnimationInfo Table; + flatbuffers::FlatBufferBuilder &fbb_; + flatbuffers::uoffset_t start_; + void add_name(flatbuffers::Offset name) { + fbb_.AddOffset(AnimationInfo::VT_NAME, name); + } + void add_startIndex(int32_t startIndex) { + fbb_.AddElement(AnimationInfo::VT_STARTINDEX, startIndex, 0); + } + void add_endIndex(int32_t endIndex) { + fbb_.AddElement(AnimationInfo::VT_ENDINDEX, endIndex, 0); + } + explicit AnimationInfoBuilder(flatbuffers::FlatBufferBuilder &_fbb) + : fbb_(_fbb) { + start_ = fbb_.StartTable(); + } + flatbuffers::Offset Finish() { + const auto end = fbb_.EndTable(start_); + auto o = flatbuffers::Offset(end); + return o; + } }; -inline flatbuffers::Offset CreateAnimationInfo(flatbuffers::FlatBufferBuilder& _fbb, - flatbuffers::Offset name = 0, - int32_t startIndex = 0, - int32_t endIndex = 0) -{ - AnimationInfoBuilder builder_(_fbb); - builder_.add_endIndex(endIndex); - builder_.add_startIndex(startIndex); - builder_.add_name(name); - return builder_.Finish(); +inline flatbuffers::Offset CreateAnimationInfo( + flatbuffers::FlatBufferBuilder &_fbb, + flatbuffers::Offset name = 0, + int32_t startIndex = 0, + int32_t endIndex = 0) { + AnimationInfoBuilder builder_(_fbb); + builder_.add_endIndex(endIndex); + builder_.add_startIndex(startIndex); + builder_.add_name(name); + return builder_.Finish(); } -inline flatbuffers::Offset CreateAnimationInfoDirect(flatbuffers::FlatBufferBuilder& _fbb, - const char* name = nullptr, - int32_t startIndex = 0, - int32_t endIndex = 0) -{ - auto name__ = name ? _fbb.CreateString(name) : 0; - return flatbuffers::CreateAnimationInfo(_fbb, name__, startIndex, endIndex); +inline flatbuffers::Offset CreateAnimationInfoDirect( + flatbuffers::FlatBufferBuilder &_fbb, + const char *name = nullptr, + int32_t startIndex = 0, + int32_t endIndex = 0) { + auto name__ = name ? _fbb.CreateString(name) : 0; + return flatbuffers::CreateAnimationInfo( + _fbb, + name__, + startIndex, + endIndex); } -struct NodeAction FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table -{ - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE - { - VT_DURATION = 4, - VT_SPEED = 6, - VT_TIMELINES = 8, - VT_CURRENTANIMATIONNAME = 10 - }; - int32_t duration() const { return GetField(VT_DURATION, 0); } - float speed() const { return GetField(VT_SPEED, 0.0f); } - const flatbuffers::Vector>* timeLines() const - { - return GetPointer>*>(VT_TIMELINES); - } - const flatbuffers::String* currentAnimationName() const - { - return GetPointer(VT_CURRENTANIMATIONNAME); - } - bool Verify(flatbuffers::Verifier& verifier) const - { - return VerifyTableStart(verifier) && VerifyField(verifier, VT_DURATION) && - VerifyField(verifier, VT_SPEED) && VerifyOffset(verifier, VT_TIMELINES) && - verifier.VerifyVector(timeLines()) && verifier.VerifyVectorOfTables(timeLines()) && - VerifyOffset(verifier, VT_CURRENTANIMATIONNAME) && verifier.VerifyString(currentAnimationName()) && - verifier.EndTable(); - } +struct NodeAction FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { + typedef NodeActionBuilder Builder; + enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { + VT_DURATION = 4, + VT_SPEED = 6, + VT_TIMELINES = 8, + VT_CURRENTANIMATIONNAME = 10 + }; + int32_t duration() const { + return GetField(VT_DURATION, 0); + } + float speed() const { + return GetField(VT_SPEED, 0.0f); + } + const flatbuffers::Vector> *timeLines() const { + return GetPointer> *>(VT_TIMELINES); + } + const flatbuffers::String *currentAnimationName() const { + return GetPointer(VT_CURRENTANIMATIONNAME); + } + bool Verify(flatbuffers::Verifier &verifier) const { + return VerifyTableStart(verifier) && + VerifyField(verifier, VT_DURATION, 4) && + VerifyField(verifier, VT_SPEED, 4) && + VerifyOffset(verifier, VT_TIMELINES) && + verifier.VerifyVector(timeLines()) && + verifier.VerifyVectorOfTables(timeLines()) && + VerifyOffset(verifier, VT_CURRENTANIMATIONNAME) && + verifier.VerifyString(currentAnimationName()) && + verifier.EndTable(); + } }; -struct NodeActionBuilder -{ - flatbuffers::FlatBufferBuilder& fbb_; - flatbuffers::uoffset_t start_; - void add_duration(int32_t duration) { fbb_.AddElement(NodeAction::VT_DURATION, duration, 0); } - void add_speed(float speed) { fbb_.AddElement(NodeAction::VT_SPEED, speed, 0.0f); } - void add_timeLines(flatbuffers::Offset>> timeLines) - { - fbb_.AddOffset(NodeAction::VT_TIMELINES, timeLines); - } - void add_currentAnimationName(flatbuffers::Offset currentAnimationName) - { - fbb_.AddOffset(NodeAction::VT_CURRENTANIMATIONNAME, currentAnimationName); - } - explicit NodeActionBuilder(flatbuffers::FlatBufferBuilder& _fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } - NodeActionBuilder& operator=(const NodeActionBuilder&); - flatbuffers::Offset Finish() - { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset(end); - return o; - } +struct NodeActionBuilder { + typedef NodeAction Table; + flatbuffers::FlatBufferBuilder &fbb_; + flatbuffers::uoffset_t start_; + void add_duration(int32_t duration) { + fbb_.AddElement(NodeAction::VT_DURATION, duration, 0); + } + void add_speed(float speed) { + fbb_.AddElement(NodeAction::VT_SPEED, speed, 0.0f); + } + void add_timeLines(flatbuffers::Offset>> timeLines) { + fbb_.AddOffset(NodeAction::VT_TIMELINES, timeLines); + } + void add_currentAnimationName(flatbuffers::Offset currentAnimationName) { + fbb_.AddOffset(NodeAction::VT_CURRENTANIMATIONNAME, currentAnimationName); + } + explicit NodeActionBuilder(flatbuffers::FlatBufferBuilder &_fbb) + : fbb_(_fbb) { + start_ = fbb_.StartTable(); + } + flatbuffers::Offset Finish() { + const auto end = fbb_.EndTable(start_); + auto o = flatbuffers::Offset(end); + return o; + } }; inline flatbuffers::Offset CreateNodeAction( - flatbuffers::FlatBufferBuilder& _fbb, - int32_t duration = 0, - float speed = 0.0f, - flatbuffers::Offset>> timeLines = 0, - flatbuffers::Offset currentAnimationName = 0) -{ - NodeActionBuilder builder_(_fbb); - builder_.add_currentAnimationName(currentAnimationName); - builder_.add_timeLines(timeLines); - builder_.add_speed(speed); - builder_.add_duration(duration); - return builder_.Finish(); + flatbuffers::FlatBufferBuilder &_fbb, + int32_t duration = 0, + float speed = 0.0f, + flatbuffers::Offset>> timeLines = 0, + flatbuffers::Offset currentAnimationName = 0) { + NodeActionBuilder builder_(_fbb); + builder_.add_currentAnimationName(currentAnimationName); + builder_.add_timeLines(timeLines); + builder_.add_speed(speed); + builder_.add_duration(duration); + return builder_.Finish(); } inline flatbuffers::Offset CreateNodeActionDirect( - flatbuffers::FlatBufferBuilder& _fbb, - int32_t duration = 0, - float speed = 0.0f, - const std::vector>* timeLines = nullptr, - const char* currentAnimationName = nullptr) -{ - auto timeLines__ = timeLines ? _fbb.CreateVector>(*timeLines) : 0; - auto currentAnimationName__ = currentAnimationName ? _fbb.CreateString(currentAnimationName) : 0; - return flatbuffers::CreateNodeAction(_fbb, duration, speed, timeLines__, currentAnimationName__); + flatbuffers::FlatBufferBuilder &_fbb, + int32_t duration = 0, + float speed = 0.0f, + const std::vector> *timeLines = nullptr, + const char *currentAnimationName = nullptr) { + auto timeLines__ = timeLines ? _fbb.CreateVector>(*timeLines) : 0; + auto currentAnimationName__ = currentAnimationName ? _fbb.CreateString(currentAnimationName) : 0; + return flatbuffers::CreateNodeAction( + _fbb, + duration, + speed, + timeLines__, + currentAnimationName__); } -struct TimeLine FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table -{ - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE - { - VT_PROPERTY = 4, - VT_ACTIONTAG = 6, - VT_FRAMES = 8 - }; - const flatbuffers::String* property() const { return GetPointer(VT_PROPERTY); } - int32_t actionTag() const { return GetField(VT_ACTIONTAG, 0); } - const flatbuffers::Vector>* frames() const - { - return GetPointer>*>(VT_FRAMES); - } - bool Verify(flatbuffers::Verifier& verifier) const - { - return VerifyTableStart(verifier) && VerifyOffset(verifier, VT_PROPERTY) && verifier.VerifyString(property()) && - VerifyField(verifier, VT_ACTIONTAG) && VerifyOffset(verifier, VT_FRAMES) && - verifier.VerifyVector(frames()) && verifier.VerifyVectorOfTables(frames()) && verifier.EndTable(); - } +struct TimeLine FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { + typedef TimeLineBuilder Builder; + enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { + VT_PROPERTY = 4, + VT_ACTIONTAG = 6, + VT_FRAMES = 8 + }; + const flatbuffers::String *property() const { + return GetPointer(VT_PROPERTY); + } + int32_t actionTag() const { + return GetField(VT_ACTIONTAG, 0); + } + const flatbuffers::Vector> *frames() const { + return GetPointer> *>(VT_FRAMES); + } + bool Verify(flatbuffers::Verifier &verifier) const { + return VerifyTableStart(verifier) && + VerifyOffset(verifier, VT_PROPERTY) && + verifier.VerifyString(property()) && + VerifyField(verifier, VT_ACTIONTAG, 4) && + VerifyOffset(verifier, VT_FRAMES) && + verifier.VerifyVector(frames()) && + verifier.VerifyVectorOfTables(frames()) && + verifier.EndTable(); + } }; -struct TimeLineBuilder -{ - flatbuffers::FlatBufferBuilder& fbb_; - flatbuffers::uoffset_t start_; - void add_property(flatbuffers::Offset property) - { - fbb_.AddOffset(TimeLine::VT_PROPERTY, property); - } - void add_actionTag(int32_t actionTag) { fbb_.AddElement(TimeLine::VT_ACTIONTAG, actionTag, 0); } - void add_frames(flatbuffers::Offset>> frames) - { - fbb_.AddOffset(TimeLine::VT_FRAMES, frames); - } - explicit TimeLineBuilder(flatbuffers::FlatBufferBuilder& _fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } - TimeLineBuilder& operator=(const TimeLineBuilder&); - flatbuffers::Offset Finish() - { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset(end); - return o; - } +struct TimeLineBuilder { + typedef TimeLine Table; + flatbuffers::FlatBufferBuilder &fbb_; + flatbuffers::uoffset_t start_; + void add_property(flatbuffers::Offset property) { + fbb_.AddOffset(TimeLine::VT_PROPERTY, property); + } + void add_actionTag(int32_t actionTag) { + fbb_.AddElement(TimeLine::VT_ACTIONTAG, actionTag, 0); + } + void add_frames(flatbuffers::Offset>> frames) { + fbb_.AddOffset(TimeLine::VT_FRAMES, frames); + } + explicit TimeLineBuilder(flatbuffers::FlatBufferBuilder &_fbb) + : fbb_(_fbb) { + start_ = fbb_.StartTable(); + } + flatbuffers::Offset Finish() { + const auto end = fbb_.EndTable(start_); + auto o = flatbuffers::Offset(end); + return o; + } }; inline flatbuffers::Offset CreateTimeLine( - flatbuffers::FlatBufferBuilder& _fbb, - flatbuffers::Offset property = 0, - int32_t actionTag = 0, - flatbuffers::Offset>> frames = 0) -{ - TimeLineBuilder builder_(_fbb); - builder_.add_frames(frames); - builder_.add_actionTag(actionTag); - builder_.add_property(property); - return builder_.Finish(); + flatbuffers::FlatBufferBuilder &_fbb, + flatbuffers::Offset property = 0, + int32_t actionTag = 0, + flatbuffers::Offset>> frames = 0) { + TimeLineBuilder builder_(_fbb); + builder_.add_frames(frames); + builder_.add_actionTag(actionTag); + builder_.add_property(property); + return builder_.Finish(); } inline flatbuffers::Offset CreateTimeLineDirect( - flatbuffers::FlatBufferBuilder& _fbb, - const char* property = nullptr, - int32_t actionTag = 0, - const std::vector>* frames = nullptr) -{ - auto property__ = property ? _fbb.CreateString(property) : 0; - auto frames__ = frames ? _fbb.CreateVector>(*frames) : 0; - return flatbuffers::CreateTimeLine(_fbb, property__, actionTag, frames__); + flatbuffers::FlatBufferBuilder &_fbb, + const char *property = nullptr, + int32_t actionTag = 0, + const std::vector> *frames = nullptr) { + auto property__ = property ? _fbb.CreateString(property) : 0; + auto frames__ = frames ? _fbb.CreateVector>(*frames) : 0; + return flatbuffers::CreateTimeLine( + _fbb, + property__, + actionTag, + frames__); } -struct Frame FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table -{ - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE - { - VT_POINTFRAME = 4, - VT_SCALEFRAME = 6, - VT_COLORFRAME = 8, - VT_TEXTUREFRAME = 10, - VT_EVENTFRAME = 12, - VT_INTFRAME = 14, - VT_BOOLFRAME = 16, - VT_INNERACTIONFRAME = 18, - VT_BLENDFRAME = 20 - }; - const PointFrame* pointFrame() const { return GetPointer(VT_POINTFRAME); } - const ScaleFrame* scaleFrame() const { return GetPointer(VT_SCALEFRAME); } - const ColorFrame* colorFrame() const { return GetPointer(VT_COLORFRAME); } - const TextureFrame* textureFrame() const { return GetPointer(VT_TEXTUREFRAME); } - const EventFrame* eventFrame() const { return GetPointer(VT_EVENTFRAME); } - const IntFrame* intFrame() const { return GetPointer(VT_INTFRAME); } - const BoolFrame* boolFrame() const { return GetPointer(VT_BOOLFRAME); } - const InnerActionFrame* innerActionFrame() const - { - return GetPointer(VT_INNERACTIONFRAME); - } - const BlendFrame* blendFrame() const { return GetPointer(VT_BLENDFRAME); } - bool Verify(flatbuffers::Verifier& verifier) const - { - return VerifyTableStart(verifier) && VerifyOffset(verifier, VT_POINTFRAME) && - verifier.VerifyTable(pointFrame()) && VerifyOffset(verifier, VT_SCALEFRAME) && - verifier.VerifyTable(scaleFrame()) && VerifyOffset(verifier, VT_COLORFRAME) && - verifier.VerifyTable(colorFrame()) && VerifyOffset(verifier, VT_TEXTUREFRAME) && - verifier.VerifyTable(textureFrame()) && VerifyOffset(verifier, VT_EVENTFRAME) && - verifier.VerifyTable(eventFrame()) && VerifyOffset(verifier, VT_INTFRAME) && - verifier.VerifyTable(intFrame()) && VerifyOffset(verifier, VT_BOOLFRAME) && - verifier.VerifyTable(boolFrame()) && VerifyOffset(verifier, VT_INNERACTIONFRAME) && - verifier.VerifyTable(innerActionFrame()) && VerifyOffset(verifier, VT_BLENDFRAME) && - verifier.VerifyTable(blendFrame()) && verifier.EndTable(); - } +struct Frame FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { + typedef FrameBuilder Builder; + enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { + VT_POINTFRAME = 4, + VT_SCALEFRAME = 6, + VT_COLORFRAME = 8, + VT_TEXTUREFRAME = 10, + VT_EVENTFRAME = 12, + VT_INTFRAME = 14, + VT_BOOLFRAME = 16, + VT_INNERACTIONFRAME = 18, + VT_BLENDFRAME = 20 + }; + const flatbuffers::PointFrame *pointFrame() const { + return GetPointer(VT_POINTFRAME); + } + const flatbuffers::ScaleFrame *scaleFrame() const { + return GetPointer(VT_SCALEFRAME); + } + const flatbuffers::ColorFrame *colorFrame() const { + return GetPointer(VT_COLORFRAME); + } + const flatbuffers::TextureFrame *textureFrame() const { + return GetPointer(VT_TEXTUREFRAME); + } + const flatbuffers::EventFrame *eventFrame() const { + return GetPointer(VT_EVENTFRAME); + } + const flatbuffers::IntFrame *intFrame() const { + return GetPointer(VT_INTFRAME); + } + const flatbuffers::BoolFrame *boolFrame() const { + return GetPointer(VT_BOOLFRAME); + } + const flatbuffers::InnerActionFrame *innerActionFrame() const { + return GetPointer(VT_INNERACTIONFRAME); + } + const flatbuffers::BlendFrame *blendFrame() const { + return GetPointer(VT_BLENDFRAME); + } + bool Verify(flatbuffers::Verifier &verifier) const { + return VerifyTableStart(verifier) && + VerifyOffset(verifier, VT_POINTFRAME) && + verifier.VerifyTable(pointFrame()) && + VerifyOffset(verifier, VT_SCALEFRAME) && + verifier.VerifyTable(scaleFrame()) && + VerifyOffset(verifier, VT_COLORFRAME) && + verifier.VerifyTable(colorFrame()) && + VerifyOffset(verifier, VT_TEXTUREFRAME) && + verifier.VerifyTable(textureFrame()) && + VerifyOffset(verifier, VT_EVENTFRAME) && + verifier.VerifyTable(eventFrame()) && + VerifyOffset(verifier, VT_INTFRAME) && + verifier.VerifyTable(intFrame()) && + VerifyOffset(verifier, VT_BOOLFRAME) && + verifier.VerifyTable(boolFrame()) && + VerifyOffset(verifier, VT_INNERACTIONFRAME) && + verifier.VerifyTable(innerActionFrame()) && + VerifyOffset(verifier, VT_BLENDFRAME) && + verifier.VerifyTable(blendFrame()) && + verifier.EndTable(); + } }; -struct FrameBuilder -{ - flatbuffers::FlatBufferBuilder& fbb_; - flatbuffers::uoffset_t start_; - void add_pointFrame(flatbuffers::Offset pointFrame) - { - fbb_.AddOffset(Frame::VT_POINTFRAME, pointFrame); - } - void add_scaleFrame(flatbuffers::Offset scaleFrame) - { - fbb_.AddOffset(Frame::VT_SCALEFRAME, scaleFrame); - } - void add_colorFrame(flatbuffers::Offset colorFrame) - { - fbb_.AddOffset(Frame::VT_COLORFRAME, colorFrame); - } - void add_textureFrame(flatbuffers::Offset textureFrame) - { - fbb_.AddOffset(Frame::VT_TEXTUREFRAME, textureFrame); - } - void add_eventFrame(flatbuffers::Offset eventFrame) - { - fbb_.AddOffset(Frame::VT_EVENTFRAME, eventFrame); - } - void add_intFrame(flatbuffers::Offset intFrame) { fbb_.AddOffset(Frame::VT_INTFRAME, intFrame); } - void add_boolFrame(flatbuffers::Offset boolFrame) { fbb_.AddOffset(Frame::VT_BOOLFRAME, boolFrame); } - void add_innerActionFrame(flatbuffers::Offset innerActionFrame) - { - fbb_.AddOffset(Frame::VT_INNERACTIONFRAME, innerActionFrame); - } - void add_blendFrame(flatbuffers::Offset blendFrame) - { - fbb_.AddOffset(Frame::VT_BLENDFRAME, blendFrame); - } - explicit FrameBuilder(flatbuffers::FlatBufferBuilder& _fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } - FrameBuilder& operator=(const FrameBuilder&); - flatbuffers::Offset Finish() - { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset(end); - return o; - } +struct FrameBuilder { + typedef Frame Table; + flatbuffers::FlatBufferBuilder &fbb_; + flatbuffers::uoffset_t start_; + void add_pointFrame(flatbuffers::Offset pointFrame) { + fbb_.AddOffset(Frame::VT_POINTFRAME, pointFrame); + } + void add_scaleFrame(flatbuffers::Offset scaleFrame) { + fbb_.AddOffset(Frame::VT_SCALEFRAME, scaleFrame); + } + void add_colorFrame(flatbuffers::Offset colorFrame) { + fbb_.AddOffset(Frame::VT_COLORFRAME, colorFrame); + } + void add_textureFrame(flatbuffers::Offset textureFrame) { + fbb_.AddOffset(Frame::VT_TEXTUREFRAME, textureFrame); + } + void add_eventFrame(flatbuffers::Offset eventFrame) { + fbb_.AddOffset(Frame::VT_EVENTFRAME, eventFrame); + } + void add_intFrame(flatbuffers::Offset intFrame) { + fbb_.AddOffset(Frame::VT_INTFRAME, intFrame); + } + void add_boolFrame(flatbuffers::Offset boolFrame) { + fbb_.AddOffset(Frame::VT_BOOLFRAME, boolFrame); + } + void add_innerActionFrame(flatbuffers::Offset innerActionFrame) { + fbb_.AddOffset(Frame::VT_INNERACTIONFRAME, innerActionFrame); + } + void add_blendFrame(flatbuffers::Offset blendFrame) { + fbb_.AddOffset(Frame::VT_BLENDFRAME, blendFrame); + } + explicit FrameBuilder(flatbuffers::FlatBufferBuilder &_fbb) + : fbb_(_fbb) { + start_ = fbb_.StartTable(); + } + flatbuffers::Offset Finish() { + const auto end = fbb_.EndTable(start_); + auto o = flatbuffers::Offset(end); + return o; + } }; -inline flatbuffers::Offset CreateFrame(flatbuffers::FlatBufferBuilder& _fbb, - flatbuffers::Offset pointFrame = 0, - flatbuffers::Offset scaleFrame = 0, - flatbuffers::Offset colorFrame = 0, - flatbuffers::Offset textureFrame = 0, - flatbuffers::Offset eventFrame = 0, - flatbuffers::Offset intFrame = 0, - flatbuffers::Offset boolFrame = 0, - flatbuffers::Offset innerActionFrame = 0, - flatbuffers::Offset blendFrame = 0) -{ - FrameBuilder builder_(_fbb); - builder_.add_blendFrame(blendFrame); - builder_.add_innerActionFrame(innerActionFrame); - builder_.add_boolFrame(boolFrame); - builder_.add_intFrame(intFrame); - builder_.add_eventFrame(eventFrame); - builder_.add_textureFrame(textureFrame); - builder_.add_colorFrame(colorFrame); - builder_.add_scaleFrame(scaleFrame); - builder_.add_pointFrame(pointFrame); - return builder_.Finish(); +inline flatbuffers::Offset CreateFrame( + flatbuffers::FlatBufferBuilder &_fbb, + flatbuffers::Offset pointFrame = 0, + flatbuffers::Offset scaleFrame = 0, + flatbuffers::Offset colorFrame = 0, + flatbuffers::Offset textureFrame = 0, + flatbuffers::Offset eventFrame = 0, + flatbuffers::Offset intFrame = 0, + flatbuffers::Offset boolFrame = 0, + flatbuffers::Offset innerActionFrame = 0, + flatbuffers::Offset blendFrame = 0) { + FrameBuilder builder_(_fbb); + builder_.add_blendFrame(blendFrame); + builder_.add_innerActionFrame(innerActionFrame); + builder_.add_boolFrame(boolFrame); + builder_.add_intFrame(intFrame); + builder_.add_eventFrame(eventFrame); + builder_.add_textureFrame(textureFrame); + builder_.add_colorFrame(colorFrame); + builder_.add_scaleFrame(scaleFrame); + builder_.add_pointFrame(pointFrame); + return builder_.Finish(); } -struct PointFrame FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table -{ - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE - { - VT_FRAMEINDEX = 4, - VT_TWEEN = 6, - VT_POSITION = 8, - VT_EASINGDATA = 10 - }; - int32_t frameIndex() const { return GetField(VT_FRAMEINDEX, 0); } - bool tween() const { return GetField(VT_TWEEN, 1) != 0; } - const FVec2* position() const { return GetStruct(VT_POSITION); } - const EasingData* easingData() const { return GetPointer(VT_EASINGDATA); } - bool Verify(flatbuffers::Verifier& verifier) const - { - return VerifyTableStart(verifier) && VerifyField(verifier, VT_FRAMEINDEX) && - VerifyField(verifier, VT_TWEEN) && VerifyField(verifier, VT_POSITION) && - VerifyOffset(verifier, VT_EASINGDATA) && verifier.VerifyTable(easingData()) && verifier.EndTable(); - } +struct PointFrame FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { + typedef PointFrameBuilder Builder; + enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { + VT_FRAMEINDEX = 4, + VT_TWEEN = 6, + VT_POSITION = 8, + VT_EASINGDATA = 10 + }; + int32_t frameIndex() const { + return GetField(VT_FRAMEINDEX, 0); + } + bool tween() const { + return GetField(VT_TWEEN, 1) != 0; + } + const flatbuffers::FVec2 *position() const { + return GetStruct(VT_POSITION); + } + const flatbuffers::EasingData *easingData() const { + return GetPointer(VT_EASINGDATA); + } + bool Verify(flatbuffers::Verifier &verifier) const { + return VerifyTableStart(verifier) && + VerifyField(verifier, VT_FRAMEINDEX, 4) && + VerifyField(verifier, VT_TWEEN, 1) && + VerifyField(verifier, VT_POSITION, 4) && + VerifyOffset(verifier, VT_EASINGDATA) && + verifier.VerifyTable(easingData()) && + verifier.EndTable(); + } }; -struct PointFrameBuilder -{ - flatbuffers::FlatBufferBuilder& fbb_; - flatbuffers::uoffset_t start_; - void add_frameIndex(int32_t frameIndex) { fbb_.AddElement(PointFrame::VT_FRAMEINDEX, frameIndex, 0); } - void add_tween(bool tween) { fbb_.AddElement(PointFrame::VT_TWEEN, static_cast(tween), 1); } - void add_position(const FVec2* position) { fbb_.AddStruct(PointFrame::VT_POSITION, position); } - void add_easingData(flatbuffers::Offset easingData) - { - fbb_.AddOffset(PointFrame::VT_EASINGDATA, easingData); - } - explicit PointFrameBuilder(flatbuffers::FlatBufferBuilder& _fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } - PointFrameBuilder& operator=(const PointFrameBuilder&); - flatbuffers::Offset Finish() - { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset(end); - return o; - } +struct PointFrameBuilder { + typedef PointFrame Table; + flatbuffers::FlatBufferBuilder &fbb_; + flatbuffers::uoffset_t start_; + void add_frameIndex(int32_t frameIndex) { + fbb_.AddElement(PointFrame::VT_FRAMEINDEX, frameIndex, 0); + } + void add_tween(bool tween) { + fbb_.AddElement(PointFrame::VT_TWEEN, static_cast(tween), 1); + } + void add_position(const flatbuffers::FVec2 *position) { + fbb_.AddStruct(PointFrame::VT_POSITION, position); + } + void add_easingData(flatbuffers::Offset easingData) { + fbb_.AddOffset(PointFrame::VT_EASINGDATA, easingData); + } + explicit PointFrameBuilder(flatbuffers::FlatBufferBuilder &_fbb) + : fbb_(_fbb) { + start_ = fbb_.StartTable(); + } + flatbuffers::Offset Finish() { + const auto end = fbb_.EndTable(start_); + auto o = flatbuffers::Offset(end); + return o; + } }; -inline flatbuffers::Offset CreatePointFrame(flatbuffers::FlatBufferBuilder& _fbb, - int32_t frameIndex = 0, - bool tween = true, - const FVec2* position = 0, - flatbuffers::Offset easingData = 0) -{ - PointFrameBuilder builder_(_fbb); - builder_.add_easingData(easingData); - builder_.add_position(position); - builder_.add_frameIndex(frameIndex); - builder_.add_tween(tween); - return builder_.Finish(); +inline flatbuffers::Offset CreatePointFrame( + flatbuffers::FlatBufferBuilder &_fbb, + int32_t frameIndex = 0, + bool tween = true, + const flatbuffers::FVec2 *position = nullptr, + flatbuffers::Offset easingData = 0) { + PointFrameBuilder builder_(_fbb); + builder_.add_easingData(easingData); + builder_.add_position(position); + builder_.add_frameIndex(frameIndex); + builder_.add_tween(tween); + return builder_.Finish(); } -struct ScaleFrame FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table -{ - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE - { - VT_FRAMEINDEX = 4, - VT_TWEEN = 6, - VT_SCALE = 8, - VT_EASINGDATA = 10 - }; - int32_t frameIndex() const { return GetField(VT_FRAMEINDEX, 0); } - bool tween() const { return GetField(VT_TWEEN, 1) != 0; } - const Scale* scale() const { return GetStruct(VT_SCALE); } - const EasingData* easingData() const { return GetPointer(VT_EASINGDATA); } - bool Verify(flatbuffers::Verifier& verifier) const - { - return VerifyTableStart(verifier) && VerifyField(verifier, VT_FRAMEINDEX) && - VerifyField(verifier, VT_TWEEN) && VerifyField(verifier, VT_SCALE) && - VerifyOffset(verifier, VT_EASINGDATA) && verifier.VerifyTable(easingData()) && verifier.EndTable(); - } +struct ScaleFrame FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { + typedef ScaleFrameBuilder Builder; + enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { + VT_FRAMEINDEX = 4, + VT_TWEEN = 6, + VT_SCALE = 8, + VT_EASINGDATA = 10 + }; + int32_t frameIndex() const { + return GetField(VT_FRAMEINDEX, 0); + } + bool tween() const { + return GetField(VT_TWEEN, 1) != 0; + } + const flatbuffers::Scale *scale() const { + return GetStruct(VT_SCALE); + } + const flatbuffers::EasingData *easingData() const { + return GetPointer(VT_EASINGDATA); + } + bool Verify(flatbuffers::Verifier &verifier) const { + return VerifyTableStart(verifier) && + VerifyField(verifier, VT_FRAMEINDEX, 4) && + VerifyField(verifier, VT_TWEEN, 1) && + VerifyField(verifier, VT_SCALE, 4) && + VerifyOffset(verifier, VT_EASINGDATA) && + verifier.VerifyTable(easingData()) && + verifier.EndTable(); + } }; -struct ScaleFrameBuilder -{ - flatbuffers::FlatBufferBuilder& fbb_; - flatbuffers::uoffset_t start_; - void add_frameIndex(int32_t frameIndex) { fbb_.AddElement(ScaleFrame::VT_FRAMEINDEX, frameIndex, 0); } - void add_tween(bool tween) { fbb_.AddElement(ScaleFrame::VT_TWEEN, static_cast(tween), 1); } - void add_scale(const Scale* scale) { fbb_.AddStruct(ScaleFrame::VT_SCALE, scale); } - void add_easingData(flatbuffers::Offset easingData) - { - fbb_.AddOffset(ScaleFrame::VT_EASINGDATA, easingData); - } - explicit ScaleFrameBuilder(flatbuffers::FlatBufferBuilder& _fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } - ScaleFrameBuilder& operator=(const ScaleFrameBuilder&); - flatbuffers::Offset Finish() - { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset(end); - return o; - } +struct ScaleFrameBuilder { + typedef ScaleFrame Table; + flatbuffers::FlatBufferBuilder &fbb_; + flatbuffers::uoffset_t start_; + void add_frameIndex(int32_t frameIndex) { + fbb_.AddElement(ScaleFrame::VT_FRAMEINDEX, frameIndex, 0); + } + void add_tween(bool tween) { + fbb_.AddElement(ScaleFrame::VT_TWEEN, static_cast(tween), 1); + } + void add_scale(const flatbuffers::Scale *scale) { + fbb_.AddStruct(ScaleFrame::VT_SCALE, scale); + } + void add_easingData(flatbuffers::Offset easingData) { + fbb_.AddOffset(ScaleFrame::VT_EASINGDATA, easingData); + } + explicit ScaleFrameBuilder(flatbuffers::FlatBufferBuilder &_fbb) + : fbb_(_fbb) { + start_ = fbb_.StartTable(); + } + flatbuffers::Offset Finish() { + const auto end = fbb_.EndTable(start_); + auto o = flatbuffers::Offset(end); + return o; + } }; -inline flatbuffers::Offset CreateScaleFrame(flatbuffers::FlatBufferBuilder& _fbb, - int32_t frameIndex = 0, - bool tween = true, - const Scale* scale = 0, - flatbuffers::Offset easingData = 0) -{ - ScaleFrameBuilder builder_(_fbb); - builder_.add_easingData(easingData); - builder_.add_scale(scale); - builder_.add_frameIndex(frameIndex); - builder_.add_tween(tween); - return builder_.Finish(); +inline flatbuffers::Offset CreateScaleFrame( + flatbuffers::FlatBufferBuilder &_fbb, + int32_t frameIndex = 0, + bool tween = true, + const flatbuffers::Scale *scale = nullptr, + flatbuffers::Offset easingData = 0) { + ScaleFrameBuilder builder_(_fbb); + builder_.add_easingData(easingData); + builder_.add_scale(scale); + builder_.add_frameIndex(frameIndex); + builder_.add_tween(tween); + return builder_.Finish(); } -struct ColorFrame FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table -{ - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE - { - VT_FRAMEINDEX = 4, - VT_TWEEN = 6, - VT_COLOR = 8, - VT_EASINGDATA = 10 - }; - int32_t frameIndex() const { return GetField(VT_FRAMEINDEX, 0); } - bool tween() const { return GetField(VT_TWEEN, 1) != 0; } - const Color* color() const { return GetStruct(VT_COLOR); } - const EasingData* easingData() const { return GetPointer(VT_EASINGDATA); } - bool Verify(flatbuffers::Verifier& verifier) const - { - return VerifyTableStart(verifier) && VerifyField(verifier, VT_FRAMEINDEX) && - VerifyField(verifier, VT_TWEEN) && VerifyField(verifier, VT_COLOR) && - VerifyOffset(verifier, VT_EASINGDATA) && verifier.VerifyTable(easingData()) && verifier.EndTable(); - } +struct ColorFrame FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { + typedef ColorFrameBuilder Builder; + enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { + VT_FRAMEINDEX = 4, + VT_TWEEN = 6, + VT_COLOR = 8, + VT_EASINGDATA = 10 + }; + int32_t frameIndex() const { + return GetField(VT_FRAMEINDEX, 0); + } + bool tween() const { + return GetField(VT_TWEEN, 1) != 0; + } + const flatbuffers::Color *color() const { + return GetStruct(VT_COLOR); + } + const flatbuffers::EasingData *easingData() const { + return GetPointer(VT_EASINGDATA); + } + bool Verify(flatbuffers::Verifier &verifier) const { + return VerifyTableStart(verifier) && + VerifyField(verifier, VT_FRAMEINDEX, 4) && + VerifyField(verifier, VT_TWEEN, 1) && + VerifyField(verifier, VT_COLOR, 1) && + VerifyOffset(verifier, VT_EASINGDATA) && + verifier.VerifyTable(easingData()) && + verifier.EndTable(); + } }; -struct ColorFrameBuilder -{ - flatbuffers::FlatBufferBuilder& fbb_; - flatbuffers::uoffset_t start_; - void add_frameIndex(int32_t frameIndex) { fbb_.AddElement(ColorFrame::VT_FRAMEINDEX, frameIndex, 0); } - void add_tween(bool tween) { fbb_.AddElement(ColorFrame::VT_TWEEN, static_cast(tween), 1); } - void add_color(const Color* color) { fbb_.AddStruct(ColorFrame::VT_COLOR, color); } - void add_easingData(flatbuffers::Offset easingData) - { - fbb_.AddOffset(ColorFrame::VT_EASINGDATA, easingData); - } - explicit ColorFrameBuilder(flatbuffers::FlatBufferBuilder& _fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } - ColorFrameBuilder& operator=(const ColorFrameBuilder&); - flatbuffers::Offset Finish() - { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset(end); - return o; - } +struct ColorFrameBuilder { + typedef ColorFrame Table; + flatbuffers::FlatBufferBuilder &fbb_; + flatbuffers::uoffset_t start_; + void add_frameIndex(int32_t frameIndex) { + fbb_.AddElement(ColorFrame::VT_FRAMEINDEX, frameIndex, 0); + } + void add_tween(bool tween) { + fbb_.AddElement(ColorFrame::VT_TWEEN, static_cast(tween), 1); + } + void add_color(const flatbuffers::Color *color) { + fbb_.AddStruct(ColorFrame::VT_COLOR, color); + } + void add_easingData(flatbuffers::Offset easingData) { + fbb_.AddOffset(ColorFrame::VT_EASINGDATA, easingData); + } + explicit ColorFrameBuilder(flatbuffers::FlatBufferBuilder &_fbb) + : fbb_(_fbb) { + start_ = fbb_.StartTable(); + } + flatbuffers::Offset Finish() { + const auto end = fbb_.EndTable(start_); + auto o = flatbuffers::Offset(end); + return o; + } }; -inline flatbuffers::Offset CreateColorFrame(flatbuffers::FlatBufferBuilder& _fbb, - int32_t frameIndex = 0, - bool tween = true, - const Color* color = 0, - flatbuffers::Offset easingData = 0) -{ - ColorFrameBuilder builder_(_fbb); - builder_.add_easingData(easingData); - builder_.add_color(color); - builder_.add_frameIndex(frameIndex); - builder_.add_tween(tween); - return builder_.Finish(); +inline flatbuffers::Offset CreateColorFrame( + flatbuffers::FlatBufferBuilder &_fbb, + int32_t frameIndex = 0, + bool tween = true, + const flatbuffers::Color *color = nullptr, + flatbuffers::Offset easingData = 0) { + ColorFrameBuilder builder_(_fbb); + builder_.add_easingData(easingData); + builder_.add_color(color); + builder_.add_frameIndex(frameIndex); + builder_.add_tween(tween); + return builder_.Finish(); } -struct TextureFrame FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table -{ - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE - { - VT_FRAMEINDEX = 4, - VT_TWEEN = 6, - VT_TEXTUREFILE = 8, - VT_EASINGDATA = 10 - }; - int32_t frameIndex() const { return GetField(VT_FRAMEINDEX, 0); } - bool tween() const { return GetField(VT_TWEEN, 1) != 0; } - const ResourceData* textureFile() const { return GetPointer(VT_TEXTUREFILE); } - const EasingData* easingData() const { return GetPointer(VT_EASINGDATA); } - bool Verify(flatbuffers::Verifier& verifier) const - { - return VerifyTableStart(verifier) && VerifyField(verifier, VT_FRAMEINDEX) && - VerifyField(verifier, VT_TWEEN) && VerifyOffset(verifier, VT_TEXTUREFILE) && - verifier.VerifyTable(textureFile()) && VerifyOffset(verifier, VT_EASINGDATA) && - verifier.VerifyTable(easingData()) && verifier.EndTable(); - } +struct TextureFrame FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { + typedef TextureFrameBuilder Builder; + enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { + VT_FRAMEINDEX = 4, + VT_TWEEN = 6, + VT_TEXTUREFILE = 8, + VT_EASINGDATA = 10 + }; + int32_t frameIndex() const { + return GetField(VT_FRAMEINDEX, 0); + } + bool tween() const { + return GetField(VT_TWEEN, 1) != 0; + } + const flatbuffers::ResourceData *textureFile() const { + return GetPointer(VT_TEXTUREFILE); + } + const flatbuffers::EasingData *easingData() const { + return GetPointer(VT_EASINGDATA); + } + bool Verify(flatbuffers::Verifier &verifier) const { + return VerifyTableStart(verifier) && + VerifyField(verifier, VT_FRAMEINDEX, 4) && + VerifyField(verifier, VT_TWEEN, 1) && + VerifyOffset(verifier, VT_TEXTUREFILE) && + verifier.VerifyTable(textureFile()) && + VerifyOffset(verifier, VT_EASINGDATA) && + verifier.VerifyTable(easingData()) && + verifier.EndTable(); + } }; -struct TextureFrameBuilder -{ - flatbuffers::FlatBufferBuilder& fbb_; - flatbuffers::uoffset_t start_; - void add_frameIndex(int32_t frameIndex) { fbb_.AddElement(TextureFrame::VT_FRAMEINDEX, frameIndex, 0); } - void add_tween(bool tween) { fbb_.AddElement(TextureFrame::VT_TWEEN, static_cast(tween), 1); } - void add_textureFile(flatbuffers::Offset textureFile) - { - fbb_.AddOffset(TextureFrame::VT_TEXTUREFILE, textureFile); - } - void add_easingData(flatbuffers::Offset easingData) - { - fbb_.AddOffset(TextureFrame::VT_EASINGDATA, easingData); - } - explicit TextureFrameBuilder(flatbuffers::FlatBufferBuilder& _fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } - TextureFrameBuilder& operator=(const TextureFrameBuilder&); - flatbuffers::Offset Finish() - { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset(end); - return o; - } +struct TextureFrameBuilder { + typedef TextureFrame Table; + flatbuffers::FlatBufferBuilder &fbb_; + flatbuffers::uoffset_t start_; + void add_frameIndex(int32_t frameIndex) { + fbb_.AddElement(TextureFrame::VT_FRAMEINDEX, frameIndex, 0); + } + void add_tween(bool tween) { + fbb_.AddElement(TextureFrame::VT_TWEEN, static_cast(tween), 1); + } + void add_textureFile(flatbuffers::Offset textureFile) { + fbb_.AddOffset(TextureFrame::VT_TEXTUREFILE, textureFile); + } + void add_easingData(flatbuffers::Offset easingData) { + fbb_.AddOffset(TextureFrame::VT_EASINGDATA, easingData); + } + explicit TextureFrameBuilder(flatbuffers::FlatBufferBuilder &_fbb) + : fbb_(_fbb) { + start_ = fbb_.StartTable(); + } + flatbuffers::Offset Finish() { + const auto end = fbb_.EndTable(start_); + auto o = flatbuffers::Offset(end); + return o; + } }; -inline flatbuffers::Offset CreateTextureFrame(flatbuffers::FlatBufferBuilder& _fbb, - int32_t frameIndex = 0, - bool tween = true, - flatbuffers::Offset textureFile = 0, - flatbuffers::Offset easingData = 0) -{ - TextureFrameBuilder builder_(_fbb); - builder_.add_easingData(easingData); - builder_.add_textureFile(textureFile); - builder_.add_frameIndex(frameIndex); - builder_.add_tween(tween); - return builder_.Finish(); +inline flatbuffers::Offset CreateTextureFrame( + flatbuffers::FlatBufferBuilder &_fbb, + int32_t frameIndex = 0, + bool tween = true, + flatbuffers::Offset textureFile = 0, + flatbuffers::Offset easingData = 0) { + TextureFrameBuilder builder_(_fbb); + builder_.add_easingData(easingData); + builder_.add_textureFile(textureFile); + builder_.add_frameIndex(frameIndex); + builder_.add_tween(tween); + return builder_.Finish(); } -struct EventFrame FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table -{ - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE - { - VT_FRAMEINDEX = 4, - VT_TWEEN = 6, - VT_VALUE = 8, - VT_EASINGDATA = 10 - }; - int32_t frameIndex() const { return GetField(VT_FRAMEINDEX, 0); } - bool tween() const { return GetField(VT_TWEEN, 1) != 0; } - const flatbuffers::String* value() const { return GetPointer(VT_VALUE); } - const EasingData* easingData() const { return GetPointer(VT_EASINGDATA); } - bool Verify(flatbuffers::Verifier& verifier) const - { - return VerifyTableStart(verifier) && VerifyField(verifier, VT_FRAMEINDEX) && - VerifyField(verifier, VT_TWEEN) && VerifyOffset(verifier, VT_VALUE) && - verifier.VerifyString(value()) && VerifyOffset(verifier, VT_EASINGDATA) && - verifier.VerifyTable(easingData()) && verifier.EndTable(); - } +struct EventFrame FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { + typedef EventFrameBuilder Builder; + enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { + VT_FRAMEINDEX = 4, + VT_TWEEN = 6, + VT_VALUE = 8, + VT_EASINGDATA = 10 + }; + int32_t frameIndex() const { + return GetField(VT_FRAMEINDEX, 0); + } + bool tween() const { + return GetField(VT_TWEEN, 1) != 0; + } + const flatbuffers::String *value() const { + return GetPointer(VT_VALUE); + } + const flatbuffers::EasingData *easingData() const { + return GetPointer(VT_EASINGDATA); + } + bool Verify(flatbuffers::Verifier &verifier) const { + return VerifyTableStart(verifier) && + VerifyField(verifier, VT_FRAMEINDEX, 4) && + VerifyField(verifier, VT_TWEEN, 1) && + VerifyOffset(verifier, VT_VALUE) && + verifier.VerifyString(value()) && + VerifyOffset(verifier, VT_EASINGDATA) && + verifier.VerifyTable(easingData()) && + verifier.EndTable(); + } }; -struct EventFrameBuilder -{ - flatbuffers::FlatBufferBuilder& fbb_; - flatbuffers::uoffset_t start_; - void add_frameIndex(int32_t frameIndex) { fbb_.AddElement(EventFrame::VT_FRAMEINDEX, frameIndex, 0); } - void add_tween(bool tween) { fbb_.AddElement(EventFrame::VT_TWEEN, static_cast(tween), 1); } - void add_value(flatbuffers::Offset value) { fbb_.AddOffset(EventFrame::VT_VALUE, value); } - void add_easingData(flatbuffers::Offset easingData) - { - fbb_.AddOffset(EventFrame::VT_EASINGDATA, easingData); - } - explicit EventFrameBuilder(flatbuffers::FlatBufferBuilder& _fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } - EventFrameBuilder& operator=(const EventFrameBuilder&); - flatbuffers::Offset Finish() - { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset(end); - return o; - } +struct EventFrameBuilder { + typedef EventFrame Table; + flatbuffers::FlatBufferBuilder &fbb_; + flatbuffers::uoffset_t start_; + void add_frameIndex(int32_t frameIndex) { + fbb_.AddElement(EventFrame::VT_FRAMEINDEX, frameIndex, 0); + } + void add_tween(bool tween) { + fbb_.AddElement(EventFrame::VT_TWEEN, static_cast(tween), 1); + } + void add_value(flatbuffers::Offset value) { + fbb_.AddOffset(EventFrame::VT_VALUE, value); + } + void add_easingData(flatbuffers::Offset easingData) { + fbb_.AddOffset(EventFrame::VT_EASINGDATA, easingData); + } + explicit EventFrameBuilder(flatbuffers::FlatBufferBuilder &_fbb) + : fbb_(_fbb) { + start_ = fbb_.StartTable(); + } + flatbuffers::Offset Finish() { + const auto end = fbb_.EndTable(start_); + auto o = flatbuffers::Offset(end); + return o; + } }; -inline flatbuffers::Offset CreateEventFrame(flatbuffers::FlatBufferBuilder& _fbb, - int32_t frameIndex = 0, - bool tween = true, - flatbuffers::Offset value = 0, - flatbuffers::Offset easingData = 0) -{ - EventFrameBuilder builder_(_fbb); - builder_.add_easingData(easingData); - builder_.add_value(value); - builder_.add_frameIndex(frameIndex); - builder_.add_tween(tween); - return builder_.Finish(); +inline flatbuffers::Offset CreateEventFrame( + flatbuffers::FlatBufferBuilder &_fbb, + int32_t frameIndex = 0, + bool tween = true, + flatbuffers::Offset value = 0, + flatbuffers::Offset easingData = 0) { + EventFrameBuilder builder_(_fbb); + builder_.add_easingData(easingData); + builder_.add_value(value); + builder_.add_frameIndex(frameIndex); + builder_.add_tween(tween); + return builder_.Finish(); } -inline flatbuffers::Offset CreateEventFrameDirect(flatbuffers::FlatBufferBuilder& _fbb, - int32_t frameIndex = 0, - bool tween = true, - const char* value = nullptr, - flatbuffers::Offset easingData = 0) -{ - auto value__ = value ? _fbb.CreateString(value) : 0; - return flatbuffers::CreateEventFrame(_fbb, frameIndex, tween, value__, easingData); +inline flatbuffers::Offset CreateEventFrameDirect( + flatbuffers::FlatBufferBuilder &_fbb, + int32_t frameIndex = 0, + bool tween = true, + const char *value = nullptr, + flatbuffers::Offset easingData = 0) { + auto value__ = value ? _fbb.CreateString(value) : 0; + return flatbuffers::CreateEventFrame( + _fbb, + frameIndex, + tween, + value__, + easingData); } -struct IntFrame FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table -{ - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE - { - VT_FRAMEINDEX = 4, - VT_TWEEN = 6, - VT_VALUE = 8, - VT_EASINGDATA = 10 - }; - int32_t frameIndex() const { return GetField(VT_FRAMEINDEX, 0); } - bool tween() const { return GetField(VT_TWEEN, 1) != 0; } - int32_t value() const { return GetField(VT_VALUE, 0); } - const EasingData* easingData() const { return GetPointer(VT_EASINGDATA); } - bool Verify(flatbuffers::Verifier& verifier) const - { - return VerifyTableStart(verifier) && VerifyField(verifier, VT_FRAMEINDEX) && - VerifyField(verifier, VT_TWEEN) && VerifyField(verifier, VT_VALUE) && - VerifyOffset(verifier, VT_EASINGDATA) && verifier.VerifyTable(easingData()) && verifier.EndTable(); - } +struct IntFrame FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { + typedef IntFrameBuilder Builder; + enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { + VT_FRAMEINDEX = 4, + VT_TWEEN = 6, + VT_VALUE = 8, + VT_EASINGDATA = 10 + }; + int32_t frameIndex() const { + return GetField(VT_FRAMEINDEX, 0); + } + bool tween() const { + return GetField(VT_TWEEN, 1) != 0; + } + int32_t value() const { + return GetField(VT_VALUE, 0); + } + const flatbuffers::EasingData *easingData() const { + return GetPointer(VT_EASINGDATA); + } + bool Verify(flatbuffers::Verifier &verifier) const { + return VerifyTableStart(verifier) && + VerifyField(verifier, VT_FRAMEINDEX, 4) && + VerifyField(verifier, VT_TWEEN, 1) && + VerifyField(verifier, VT_VALUE, 4) && + VerifyOffset(verifier, VT_EASINGDATA) && + verifier.VerifyTable(easingData()) && + verifier.EndTable(); + } }; -struct IntFrameBuilder -{ - flatbuffers::FlatBufferBuilder& fbb_; - flatbuffers::uoffset_t start_; - void add_frameIndex(int32_t frameIndex) { fbb_.AddElement(IntFrame::VT_FRAMEINDEX, frameIndex, 0); } - void add_tween(bool tween) { fbb_.AddElement(IntFrame::VT_TWEEN, static_cast(tween), 1); } - void add_value(int32_t value) { fbb_.AddElement(IntFrame::VT_VALUE, value, 0); } - void add_easingData(flatbuffers::Offset easingData) - { - fbb_.AddOffset(IntFrame::VT_EASINGDATA, easingData); - } - explicit IntFrameBuilder(flatbuffers::FlatBufferBuilder& _fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } - IntFrameBuilder& operator=(const IntFrameBuilder&); - flatbuffers::Offset Finish() - { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset(end); - return o; - } +struct IntFrameBuilder { + typedef IntFrame Table; + flatbuffers::FlatBufferBuilder &fbb_; + flatbuffers::uoffset_t start_; + void add_frameIndex(int32_t frameIndex) { + fbb_.AddElement(IntFrame::VT_FRAMEINDEX, frameIndex, 0); + } + void add_tween(bool tween) { + fbb_.AddElement(IntFrame::VT_TWEEN, static_cast(tween), 1); + } + void add_value(int32_t value) { + fbb_.AddElement(IntFrame::VT_VALUE, value, 0); + } + void add_easingData(flatbuffers::Offset easingData) { + fbb_.AddOffset(IntFrame::VT_EASINGDATA, easingData); + } + explicit IntFrameBuilder(flatbuffers::FlatBufferBuilder &_fbb) + : fbb_(_fbb) { + start_ = fbb_.StartTable(); + } + flatbuffers::Offset Finish() { + const auto end = fbb_.EndTable(start_); + auto o = flatbuffers::Offset(end); + return o; + } }; -inline flatbuffers::Offset CreateIntFrame(flatbuffers::FlatBufferBuilder& _fbb, - int32_t frameIndex = 0, - bool tween = true, - int32_t value = 0, - flatbuffers::Offset easingData = 0) -{ - IntFrameBuilder builder_(_fbb); - builder_.add_easingData(easingData); - builder_.add_value(value); - builder_.add_frameIndex(frameIndex); - builder_.add_tween(tween); - return builder_.Finish(); +inline flatbuffers::Offset CreateIntFrame( + flatbuffers::FlatBufferBuilder &_fbb, + int32_t frameIndex = 0, + bool tween = true, + int32_t value = 0, + flatbuffers::Offset easingData = 0) { + IntFrameBuilder builder_(_fbb); + builder_.add_easingData(easingData); + builder_.add_value(value); + builder_.add_frameIndex(frameIndex); + builder_.add_tween(tween); + return builder_.Finish(); } -struct BoolFrame FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table -{ - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE - { - VT_FRAMEINDEX = 4, - VT_TWEEN = 6, - VT_VALUE = 8, - VT_EASINGDATA = 10 - }; - int32_t frameIndex() const { return GetField(VT_FRAMEINDEX, 0); } - bool tween() const { return GetField(VT_TWEEN, 1) != 0; } - bool value() const { return GetField(VT_VALUE, 1) != 0; } - const EasingData* easingData() const { return GetPointer(VT_EASINGDATA); } - bool Verify(flatbuffers::Verifier& verifier) const - { - return VerifyTableStart(verifier) && VerifyField(verifier, VT_FRAMEINDEX) && - VerifyField(verifier, VT_TWEEN) && VerifyField(verifier, VT_VALUE) && - VerifyOffset(verifier, VT_EASINGDATA) && verifier.VerifyTable(easingData()) && verifier.EndTable(); - } +struct BoolFrame FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { + typedef BoolFrameBuilder Builder; + enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { + VT_FRAMEINDEX = 4, + VT_TWEEN = 6, + VT_VALUE = 8, + VT_EASINGDATA = 10 + }; + int32_t frameIndex() const { + return GetField(VT_FRAMEINDEX, 0); + } + bool tween() const { + return GetField(VT_TWEEN, 1) != 0; + } + bool value() const { + return GetField(VT_VALUE, 1) != 0; + } + const flatbuffers::EasingData *easingData() const { + return GetPointer(VT_EASINGDATA); + } + bool Verify(flatbuffers::Verifier &verifier) const { + return VerifyTableStart(verifier) && + VerifyField(verifier, VT_FRAMEINDEX, 4) && + VerifyField(verifier, VT_TWEEN, 1) && + VerifyField(verifier, VT_VALUE, 1) && + VerifyOffset(verifier, VT_EASINGDATA) && + verifier.VerifyTable(easingData()) && + verifier.EndTable(); + } }; -struct BoolFrameBuilder -{ - flatbuffers::FlatBufferBuilder& fbb_; - flatbuffers::uoffset_t start_; - void add_frameIndex(int32_t frameIndex) { fbb_.AddElement(BoolFrame::VT_FRAMEINDEX, frameIndex, 0); } - void add_tween(bool tween) { fbb_.AddElement(BoolFrame::VT_TWEEN, static_cast(tween), 1); } - void add_value(bool value) { fbb_.AddElement(BoolFrame::VT_VALUE, static_cast(value), 1); } - void add_easingData(flatbuffers::Offset easingData) - { - fbb_.AddOffset(BoolFrame::VT_EASINGDATA, easingData); - } - explicit BoolFrameBuilder(flatbuffers::FlatBufferBuilder& _fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } - BoolFrameBuilder& operator=(const BoolFrameBuilder&); - flatbuffers::Offset Finish() - { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset(end); - return o; - } +struct BoolFrameBuilder { + typedef BoolFrame Table; + flatbuffers::FlatBufferBuilder &fbb_; + flatbuffers::uoffset_t start_; + void add_frameIndex(int32_t frameIndex) { + fbb_.AddElement(BoolFrame::VT_FRAMEINDEX, frameIndex, 0); + } + void add_tween(bool tween) { + fbb_.AddElement(BoolFrame::VT_TWEEN, static_cast(tween), 1); + } + void add_value(bool value) { + fbb_.AddElement(BoolFrame::VT_VALUE, static_cast(value), 1); + } + void add_easingData(flatbuffers::Offset easingData) { + fbb_.AddOffset(BoolFrame::VT_EASINGDATA, easingData); + } + explicit BoolFrameBuilder(flatbuffers::FlatBufferBuilder &_fbb) + : fbb_(_fbb) { + start_ = fbb_.StartTable(); + } + flatbuffers::Offset Finish() { + const auto end = fbb_.EndTable(start_); + auto o = flatbuffers::Offset(end); + return o; + } }; -inline flatbuffers::Offset CreateBoolFrame(flatbuffers::FlatBufferBuilder& _fbb, - int32_t frameIndex = 0, - bool tween = true, - bool value = true, - flatbuffers::Offset easingData = 0) -{ - BoolFrameBuilder builder_(_fbb); - builder_.add_easingData(easingData); - builder_.add_frameIndex(frameIndex); - builder_.add_value(value); - builder_.add_tween(tween); - return builder_.Finish(); +inline flatbuffers::Offset CreateBoolFrame( + flatbuffers::FlatBufferBuilder &_fbb, + int32_t frameIndex = 0, + bool tween = true, + bool value = true, + flatbuffers::Offset easingData = 0) { + BoolFrameBuilder builder_(_fbb); + builder_.add_easingData(easingData); + builder_.add_frameIndex(frameIndex); + builder_.add_value(value); + builder_.add_tween(tween); + return builder_.Finish(); } -struct InnerActionFrame FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table -{ - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE - { - VT_FRAMEINDEX = 4, - VT_TWEEN = 6, - VT_INNERACTIONTYPE = 8, - VT_CURRENTANIAMTIONNAME = 10, - VT_SINGLEFRAMEINDEX = 12, - VT_EASINGDATA = 14 - }; - int32_t frameIndex() const { return GetField(VT_FRAMEINDEX, 0); } - bool tween() const { return GetField(VT_TWEEN, 1) != 0; } - int32_t innerActionType() const { return GetField(VT_INNERACTIONTYPE, 0); } - const flatbuffers::String* currentAniamtionName() const - { - return GetPointer(VT_CURRENTANIAMTIONNAME); - } - int32_t singleFrameIndex() const { return GetField(VT_SINGLEFRAMEINDEX, 0); } - const EasingData* easingData() const { return GetPointer(VT_EASINGDATA); } - bool Verify(flatbuffers::Verifier& verifier) const - { - return VerifyTableStart(verifier) && VerifyField(verifier, VT_FRAMEINDEX) && - VerifyField(verifier, VT_TWEEN) && VerifyField(verifier, VT_INNERACTIONTYPE) && - VerifyOffset(verifier, VT_CURRENTANIAMTIONNAME) && verifier.VerifyString(currentAniamtionName()) && - VerifyField(verifier, VT_SINGLEFRAMEINDEX) && VerifyOffset(verifier, VT_EASINGDATA) && - verifier.VerifyTable(easingData()) && verifier.EndTable(); - } +struct InnerActionFrame FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { + typedef InnerActionFrameBuilder Builder; + enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { + VT_FRAMEINDEX = 4, + VT_TWEEN = 6, + VT_INNERACTIONTYPE = 8, + VT_CURRENTANIAMTIONNAME = 10, + VT_SINGLEFRAMEINDEX = 12, + VT_EASINGDATA = 14 + }; + int32_t frameIndex() const { + return GetField(VT_FRAMEINDEX, 0); + } + bool tween() const { + return GetField(VT_TWEEN, 1) != 0; + } + int32_t innerActionType() const { + return GetField(VT_INNERACTIONTYPE, 0); + } + const flatbuffers::String *currentAniamtionName() const { + return GetPointer(VT_CURRENTANIAMTIONNAME); + } + int32_t singleFrameIndex() const { + return GetField(VT_SINGLEFRAMEINDEX, 0); + } + const flatbuffers::EasingData *easingData() const { + return GetPointer(VT_EASINGDATA); + } + bool Verify(flatbuffers::Verifier &verifier) const { + return VerifyTableStart(verifier) && + VerifyField(verifier, VT_FRAMEINDEX, 4) && + VerifyField(verifier, VT_TWEEN, 1) && + VerifyField(verifier, VT_INNERACTIONTYPE, 4) && + VerifyOffset(verifier, VT_CURRENTANIAMTIONNAME) && + verifier.VerifyString(currentAniamtionName()) && + VerifyField(verifier, VT_SINGLEFRAMEINDEX, 4) && + VerifyOffset(verifier, VT_EASINGDATA) && + verifier.VerifyTable(easingData()) && + verifier.EndTable(); + } }; -struct InnerActionFrameBuilder -{ - flatbuffers::FlatBufferBuilder& fbb_; - flatbuffers::uoffset_t start_; - void add_frameIndex(int32_t frameIndex) - { - fbb_.AddElement(InnerActionFrame::VT_FRAMEINDEX, frameIndex, 0); - } - void add_tween(bool tween) { fbb_.AddElement(InnerActionFrame::VT_TWEEN, static_cast(tween), 1); } - void add_innerActionType(int32_t innerActionType) - { - fbb_.AddElement(InnerActionFrame::VT_INNERACTIONTYPE, innerActionType, 0); - } - void add_currentAniamtionName(flatbuffers::Offset currentAniamtionName) - { - fbb_.AddOffset(InnerActionFrame::VT_CURRENTANIAMTIONNAME, currentAniamtionName); - } - void add_singleFrameIndex(int32_t singleFrameIndex) - { - fbb_.AddElement(InnerActionFrame::VT_SINGLEFRAMEINDEX, singleFrameIndex, 0); - } - void add_easingData(flatbuffers::Offset easingData) - { - fbb_.AddOffset(InnerActionFrame::VT_EASINGDATA, easingData); - } - explicit InnerActionFrameBuilder(flatbuffers::FlatBufferBuilder& _fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } - InnerActionFrameBuilder& operator=(const InnerActionFrameBuilder&); - flatbuffers::Offset Finish() - { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset(end); - return o; - } +struct InnerActionFrameBuilder { + typedef InnerActionFrame Table; + flatbuffers::FlatBufferBuilder &fbb_; + flatbuffers::uoffset_t start_; + void add_frameIndex(int32_t frameIndex) { + fbb_.AddElement(InnerActionFrame::VT_FRAMEINDEX, frameIndex, 0); + } + void add_tween(bool tween) { + fbb_.AddElement(InnerActionFrame::VT_TWEEN, static_cast(tween), 1); + } + void add_innerActionType(int32_t innerActionType) { + fbb_.AddElement(InnerActionFrame::VT_INNERACTIONTYPE, innerActionType, 0); + } + void add_currentAniamtionName(flatbuffers::Offset currentAniamtionName) { + fbb_.AddOffset(InnerActionFrame::VT_CURRENTANIAMTIONNAME, currentAniamtionName); + } + void add_singleFrameIndex(int32_t singleFrameIndex) { + fbb_.AddElement(InnerActionFrame::VT_SINGLEFRAMEINDEX, singleFrameIndex, 0); + } + void add_easingData(flatbuffers::Offset easingData) { + fbb_.AddOffset(InnerActionFrame::VT_EASINGDATA, easingData); + } + explicit InnerActionFrameBuilder(flatbuffers::FlatBufferBuilder &_fbb) + : fbb_(_fbb) { + start_ = fbb_.StartTable(); + } + flatbuffers::Offset Finish() { + const auto end = fbb_.EndTable(start_); + auto o = flatbuffers::Offset(end); + return o; + } }; inline flatbuffers::Offset CreateInnerActionFrame( - flatbuffers::FlatBufferBuilder& _fbb, - int32_t frameIndex = 0, - bool tween = true, - int32_t innerActionType = 0, + flatbuffers::FlatBufferBuilder &_fbb, + int32_t frameIndex = 0, + bool tween = true, + int32_t innerActionType = 0, flatbuffers::Offset currentAniamtionName = 0, - int32_t singleFrameIndex = 0, - flatbuffers::Offset easingData = 0) -{ - InnerActionFrameBuilder builder_(_fbb); - builder_.add_easingData(easingData); - builder_.add_singleFrameIndex(singleFrameIndex); - builder_.add_currentAniamtionName(currentAniamtionName); - builder_.add_innerActionType(innerActionType); - builder_.add_frameIndex(frameIndex); - builder_.add_tween(tween); - return builder_.Finish(); + int32_t singleFrameIndex = 0, + flatbuffers::Offset easingData = 0) { + InnerActionFrameBuilder builder_(_fbb); + builder_.add_easingData(easingData); + builder_.add_singleFrameIndex(singleFrameIndex); + builder_.add_currentAniamtionName(currentAniamtionName); + builder_.add_innerActionType(innerActionType); + builder_.add_frameIndex(frameIndex); + builder_.add_tween(tween); + return builder_.Finish(); } inline flatbuffers::Offset CreateInnerActionFrameDirect( - flatbuffers::FlatBufferBuilder& _fbb, - int32_t frameIndex = 0, - bool tween = true, - int32_t innerActionType = 0, - const char* currentAniamtionName = nullptr, - int32_t singleFrameIndex = 0, - flatbuffers::Offset easingData = 0) -{ - auto currentAniamtionName__ = currentAniamtionName ? _fbb.CreateString(currentAniamtionName) : 0; - return flatbuffers::CreateInnerActionFrame(_fbb, frameIndex, tween, innerActionType, currentAniamtionName__, - singleFrameIndex, easingData); + flatbuffers::FlatBufferBuilder &_fbb, + int32_t frameIndex = 0, + bool tween = true, + int32_t innerActionType = 0, + const char *currentAniamtionName = nullptr, + int32_t singleFrameIndex = 0, + flatbuffers::Offset easingData = 0) { + auto currentAniamtionName__ = currentAniamtionName ? _fbb.CreateString(currentAniamtionName) : 0; + return flatbuffers::CreateInnerActionFrame( + _fbb, + frameIndex, + tween, + innerActionType, + currentAniamtionName__, + singleFrameIndex, + easingData); } -struct EasingData FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table -{ - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE - { - VT_TYPE = 4, - VT_POINTS = 6 - }; - int32_t type() const { return GetField(VT_TYPE, -1); } - const flatbuffers::Vector* points() const - { - return GetPointer*>(VT_POINTS); - } - bool Verify(flatbuffers::Verifier& verifier) const - { - return VerifyTableStart(verifier) && VerifyField(verifier, VT_TYPE) && - VerifyOffset(verifier, VT_POINTS) && verifier.VerifyVector(points()) && verifier.EndTable(); - } +struct EasingData FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { + typedef EasingDataBuilder Builder; + enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { + VT_TYPE = 4, + VT_POINTS = 6 + }; + int32_t type() const { + return GetField(VT_TYPE, -1); + } + const flatbuffers::Vector *points() const { + return GetPointer *>(VT_POINTS); + } + bool Verify(flatbuffers::Verifier &verifier) const { + return VerifyTableStart(verifier) && + VerifyField(verifier, VT_TYPE, 4) && + VerifyOffset(verifier, VT_POINTS) && + verifier.VerifyVector(points()) && + verifier.EndTable(); + } }; -struct EasingDataBuilder -{ - flatbuffers::FlatBufferBuilder& fbb_; - flatbuffers::uoffset_t start_; - void add_type(int32_t type) { fbb_.AddElement(EasingData::VT_TYPE, type, -1); } - void add_points(flatbuffers::Offset> points) - { - fbb_.AddOffset(EasingData::VT_POINTS, points); - } - explicit EasingDataBuilder(flatbuffers::FlatBufferBuilder& _fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } - EasingDataBuilder& operator=(const EasingDataBuilder&); - flatbuffers::Offset Finish() - { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset(end); - return o; - } +struct EasingDataBuilder { + typedef EasingData Table; + flatbuffers::FlatBufferBuilder &fbb_; + flatbuffers::uoffset_t start_; + void add_type(int32_t type) { + fbb_.AddElement(EasingData::VT_TYPE, type, -1); + } + void add_points(flatbuffers::Offset> points) { + fbb_.AddOffset(EasingData::VT_POINTS, points); + } + explicit EasingDataBuilder(flatbuffers::FlatBufferBuilder &_fbb) + : fbb_(_fbb) { + start_ = fbb_.StartTable(); + } + flatbuffers::Offset Finish() { + const auto end = fbb_.EndTable(start_); + auto o = flatbuffers::Offset(end); + return o; + } }; inline flatbuffers::Offset CreateEasingData( - flatbuffers::FlatBufferBuilder& _fbb, - int32_t type = -1, - flatbuffers::Offset> points = 0) -{ - EasingDataBuilder builder_(_fbb); - builder_.add_points(points); - builder_.add_type(type); - return builder_.Finish(); + flatbuffers::FlatBufferBuilder &_fbb, + int32_t type = -1, + flatbuffers::Offset> points = 0) { + EasingDataBuilder builder_(_fbb); + builder_.add_points(points); + builder_.add_type(type); + return builder_.Finish(); } -inline flatbuffers::Offset CreateEasingDataDirect(flatbuffers::FlatBufferBuilder& _fbb, - int32_t type = -1, - const std::vector* points = nullptr) -{ - auto points__ = points ? _fbb.CreateVectorOfStructs(*points) : 0; - return flatbuffers::CreateEasingData(_fbb, type, points__); +inline flatbuffers::Offset CreateEasingDataDirect( + flatbuffers::FlatBufferBuilder &_fbb, + int32_t type = -1, + const std::vector *points = nullptr) { + auto points__ = points ? _fbb.CreateVectorOfStructs(*points) : 0; + return flatbuffers::CreateEasingData( + _fbb, + type, + points__); } -struct ResourceData FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table -{ - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE - { - VT_PATH = 4, - VT_PLISTFILE = 6, - VT_RESOURCETYPE = 8 - }; - const flatbuffers::String* path() const { return GetPointer(VT_PATH); } - const flatbuffers::String* plistFile() const { return GetPointer(VT_PLISTFILE); } - int32_t resourceType() const { return GetField(VT_RESOURCETYPE, 0); } - bool Verify(flatbuffers::Verifier& verifier) const - { - return VerifyTableStart(verifier) && VerifyOffset(verifier, VT_PATH) && verifier.VerifyString(path()) && - VerifyOffset(verifier, VT_PLISTFILE) && verifier.VerifyString(plistFile()) && - VerifyField(verifier, VT_RESOURCETYPE) && verifier.EndTable(); - } +struct ResourceData FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { + typedef ResourceDataBuilder Builder; + enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { + VT_PATH = 4, + VT_PLISTFILE = 6, + VT_RESOURCETYPE = 8 + }; + const flatbuffers::String *path() const { + return GetPointer(VT_PATH); + } + const flatbuffers::String *plistFile() const { + return GetPointer(VT_PLISTFILE); + } + int32_t resourceType() const { + return GetField(VT_RESOURCETYPE, 0); + } + bool Verify(flatbuffers::Verifier &verifier) const { + return VerifyTableStart(verifier) && + VerifyOffset(verifier, VT_PATH) && + verifier.VerifyString(path()) && + VerifyOffset(verifier, VT_PLISTFILE) && + verifier.VerifyString(plistFile()) && + VerifyField(verifier, VT_RESOURCETYPE, 4) && + verifier.EndTable(); + } }; -struct ResourceDataBuilder -{ - flatbuffers::FlatBufferBuilder& fbb_; - flatbuffers::uoffset_t start_; - void add_path(flatbuffers::Offset path) { fbb_.AddOffset(ResourceData::VT_PATH, path); } - void add_plistFile(flatbuffers::Offset plistFile) - { - fbb_.AddOffset(ResourceData::VT_PLISTFILE, plistFile); - } - void add_resourceType(int32_t resourceType) - { - fbb_.AddElement(ResourceData::VT_RESOURCETYPE, resourceType, 0); - } - explicit ResourceDataBuilder(flatbuffers::FlatBufferBuilder& _fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } - ResourceDataBuilder& operator=(const ResourceDataBuilder&); - flatbuffers::Offset Finish() - { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset(end); - return o; - } +struct ResourceDataBuilder { + typedef ResourceData Table; + flatbuffers::FlatBufferBuilder &fbb_; + flatbuffers::uoffset_t start_; + void add_path(flatbuffers::Offset path) { + fbb_.AddOffset(ResourceData::VT_PATH, path); + } + void add_plistFile(flatbuffers::Offset plistFile) { + fbb_.AddOffset(ResourceData::VT_PLISTFILE, plistFile); + } + void add_resourceType(int32_t resourceType) { + fbb_.AddElement(ResourceData::VT_RESOURCETYPE, resourceType, 0); + } + explicit ResourceDataBuilder(flatbuffers::FlatBufferBuilder &_fbb) + : fbb_(_fbb) { + start_ = fbb_.StartTable(); + } + flatbuffers::Offset Finish() { + const auto end = fbb_.EndTable(start_); + auto o = flatbuffers::Offset(end); + return o; + } }; -inline flatbuffers::Offset CreateResourceData(flatbuffers::FlatBufferBuilder& _fbb, - flatbuffers::Offset path = 0, - flatbuffers::Offset plistFile = 0, - int32_t resourceType = 0) -{ - ResourceDataBuilder builder_(_fbb); - builder_.add_resourceType(resourceType); - builder_.add_plistFile(plistFile); - builder_.add_path(path); - return builder_.Finish(); +inline flatbuffers::Offset CreateResourceData( + flatbuffers::FlatBufferBuilder &_fbb, + flatbuffers::Offset path = 0, + flatbuffers::Offset plistFile = 0, + int32_t resourceType = 0) { + ResourceDataBuilder builder_(_fbb); + builder_.add_resourceType(resourceType); + builder_.add_plistFile(plistFile); + builder_.add_path(path); + return builder_.Finish(); } -inline flatbuffers::Offset CreateResourceDataDirect(flatbuffers::FlatBufferBuilder& _fbb, - const char* path = nullptr, - const char* plistFile = nullptr, - int32_t resourceType = 0) -{ - auto path__ = path ? _fbb.CreateString(path) : 0; - auto plistFile__ = plistFile ? _fbb.CreateString(plistFile) : 0; - return flatbuffers::CreateResourceData(_fbb, path__, plistFile__, resourceType); +inline flatbuffers::Offset CreateResourceDataDirect( + flatbuffers::FlatBufferBuilder &_fbb, + const char *path = nullptr, + const char *plistFile = nullptr, + int32_t resourceType = 0) { + auto path__ = path ? _fbb.CreateString(path) : 0; + auto plistFile__ = plistFile ? _fbb.CreateString(plistFile) : 0; + return flatbuffers::CreateResourceData( + _fbb, + path__, + plistFile__, + resourceType); } -struct BlendFrame FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table -{ - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE - { - VT_FRAMEINDEX = 4, - VT_TWEEN = 6, - VT_BLENDFUNC = 8, - VT_EASINGDATA = 10 - }; - int32_t frameIndex() const { return GetField(VT_FRAMEINDEX, 0); } - bool tween() const { return GetField(VT_TWEEN, 1) != 0; } - const BlendFunc* blendFunc() const { return GetStruct(VT_BLENDFUNC); } - const EasingData* easingData() const { return GetPointer(VT_EASINGDATA); } - bool Verify(flatbuffers::Verifier& verifier) const - { - return VerifyTableStart(verifier) && VerifyField(verifier, VT_FRAMEINDEX) && - VerifyField(verifier, VT_TWEEN) && VerifyField(verifier, VT_BLENDFUNC) && - VerifyOffset(verifier, VT_EASINGDATA) && verifier.VerifyTable(easingData()) && verifier.EndTable(); - } +struct BlendFrame FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { + typedef BlendFrameBuilder Builder; + enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { + VT_FRAMEINDEX = 4, + VT_TWEEN = 6, + VT_BLENDFUNC = 8, + VT_EASINGDATA = 10 + }; + int32_t frameIndex() const { + return GetField(VT_FRAMEINDEX, 0); + } + bool tween() const { + return GetField(VT_TWEEN, 1) != 0; + } + const flatbuffers::BlendFunc *blendFunc() const { + return GetStruct(VT_BLENDFUNC); + } + const flatbuffers::EasingData *easingData() const { + return GetPointer(VT_EASINGDATA); + } + bool Verify(flatbuffers::Verifier &verifier) const { + return VerifyTableStart(verifier) && + VerifyField(verifier, VT_FRAMEINDEX, 4) && + VerifyField(verifier, VT_TWEEN, 1) && + VerifyField(verifier, VT_BLENDFUNC, 4) && + VerifyOffset(verifier, VT_EASINGDATA) && + verifier.VerifyTable(easingData()) && + verifier.EndTable(); + } }; -struct BlendFrameBuilder -{ - flatbuffers::FlatBufferBuilder& fbb_; - flatbuffers::uoffset_t start_; - void add_frameIndex(int32_t frameIndex) { fbb_.AddElement(BlendFrame::VT_FRAMEINDEX, frameIndex, 0); } - void add_tween(bool tween) { fbb_.AddElement(BlendFrame::VT_TWEEN, static_cast(tween), 1); } - void add_blendFunc(const BlendFunc* blendFunc) { fbb_.AddStruct(BlendFrame::VT_BLENDFUNC, blendFunc); } - void add_easingData(flatbuffers::Offset easingData) - { - fbb_.AddOffset(BlendFrame::VT_EASINGDATA, easingData); - } - explicit BlendFrameBuilder(flatbuffers::FlatBufferBuilder& _fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } - BlendFrameBuilder& operator=(const BlendFrameBuilder&); - flatbuffers::Offset Finish() - { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset(end); - return o; - } +struct BlendFrameBuilder { + typedef BlendFrame Table; + flatbuffers::FlatBufferBuilder &fbb_; + flatbuffers::uoffset_t start_; + void add_frameIndex(int32_t frameIndex) { + fbb_.AddElement(BlendFrame::VT_FRAMEINDEX, frameIndex, 0); + } + void add_tween(bool tween) { + fbb_.AddElement(BlendFrame::VT_TWEEN, static_cast(tween), 1); + } + void add_blendFunc(const flatbuffers::BlendFunc *blendFunc) { + fbb_.AddStruct(BlendFrame::VT_BLENDFUNC, blendFunc); + } + void add_easingData(flatbuffers::Offset easingData) { + fbb_.AddOffset(BlendFrame::VT_EASINGDATA, easingData); + } + explicit BlendFrameBuilder(flatbuffers::FlatBufferBuilder &_fbb) + : fbb_(_fbb) { + start_ = fbb_.StartTable(); + } + flatbuffers::Offset Finish() { + const auto end = fbb_.EndTable(start_); + auto o = flatbuffers::Offset(end); + return o; + } }; -inline flatbuffers::Offset CreateBlendFrame(flatbuffers::FlatBufferBuilder& _fbb, - int32_t frameIndex = 0, - bool tween = true, - const BlendFunc* blendFunc = 0, - flatbuffers::Offset easingData = 0) -{ - BlendFrameBuilder builder_(_fbb); - builder_.add_easingData(easingData); - builder_.add_blendFunc(blendFunc); - builder_.add_frameIndex(frameIndex); - builder_.add_tween(tween); - return builder_.Finish(); +inline flatbuffers::Offset CreateBlendFrame( + flatbuffers::FlatBufferBuilder &_fbb, + int32_t frameIndex = 0, + bool tween = true, + const flatbuffers::BlendFunc *blendFunc = nullptr, + flatbuffers::Offset easingData = 0) { + BlendFrameBuilder builder_(_fbb); + builder_.add_easingData(easingData); + builder_.add_blendFunc(blendFunc); + builder_.add_frameIndex(frameIndex); + builder_.add_tween(tween); + return builder_.Finish(); } -inline const flatbuffers::CSParseBinary* GetCSParseBinary(const void* buf) -{ - return flatbuffers::GetRoot(buf); +inline const flatbuffers::CSParseBinary *GetCSParseBinary(const void *buf) { + return flatbuffers::GetRoot(buf); } -inline const flatbuffers::CSParseBinary* GetSizePrefixedCSParseBinary(const void* buf) -{ - return flatbuffers::GetSizePrefixedRoot(buf); +inline const flatbuffers::CSParseBinary *GetSizePrefixedCSParseBinary(const void *buf) { + return flatbuffers::GetSizePrefixedRoot(buf); } -inline bool VerifyCSParseBinaryBuffer(flatbuffers::Verifier& verifier) -{ - return verifier.VerifyBuffer(nullptr); +inline bool VerifyCSParseBinaryBuffer( + flatbuffers::Verifier &verifier) { + return verifier.VerifyBuffer(nullptr); } -inline bool VerifySizePrefixedCSParseBinaryBuffer(flatbuffers::Verifier& verifier) -{ - return verifier.VerifySizePrefixedBuffer(nullptr); +inline bool VerifySizePrefixedCSParseBinaryBuffer( + flatbuffers::Verifier &verifier) { + return verifier.VerifySizePrefixedBuffer(nullptr); } -inline void FinishCSParseBinaryBuffer(flatbuffers::FlatBufferBuilder& fbb, - flatbuffers::Offset root) -{ - fbb.Finish(root); +inline void FinishCSParseBinaryBuffer( + flatbuffers::FlatBufferBuilder &fbb, + flatbuffers::Offset root) { + fbb.Finish(root); } -inline void FinishSizePrefixedCSParseBinaryBuffer(flatbuffers::FlatBufferBuilder& fbb, - flatbuffers::Offset root) -{ - fbb.FinishSizePrefixed(root); +inline void FinishSizePrefixedCSParseBinaryBuffer( + flatbuffers::FlatBufferBuilder &fbb, + flatbuffers::Offset root) { + fbb.FinishSizePrefixed(root); } } // namespace flatbuffers diff --git a/extensions/cocostudio/WidgetReader/ArmatureNodeReader/CSArmatureNode_generated.h b/extensions/cocostudio/WidgetReader/ArmatureNodeReader/CSArmatureNode_generated.h index 595d616bd5..e8ba650bab 100644 --- a/extensions/cocostudio/WidgetReader/ArmatureNodeReader/CSArmatureNode_generated.h +++ b/extensions/cocostudio/WidgetReader/ArmatureNodeReader/CSArmatureNode_generated.h @@ -1,225 +1,258 @@ // automatically generated by the FlatBuffers compiler, do not modify + #ifndef FLATBUFFERS_GENERATED_CSARMATURENODE_FLATBUFFERS_H_ #define FLATBUFFERS_GENERATED_CSARMATURENODE_FLATBUFFERS_H_ #include "flatbuffers/flatbuffers.h" +// Ensure the included flatbuffers.h is the same version as when this file was +// generated, otherwise it may not be compatible. +static_assert(FLATBUFFERS_VERSION_MAJOR == 2 && + FLATBUFFERS_VERSION_MINOR == 0 && + FLATBUFFERS_VERSION_REVISION == 8, + "Non-compatible flatbuffers version included"); + #include "CSParseBinary_generated.h" -namespace flatbuffers -{ +namespace flatbuffers { struct CSArmatureNodeOption; +struct CSArmatureNodeOptionBuilder; struct ResourceItemData; +struct ResourceItemDataBuilder; -struct CSArmatureNodeOption FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table -{ - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE - { - VT_NODEOPTIONS = 4, - VT_FILEDATA = 6, - VT_ISLOOP = 8, - VT_ISAUTOPLAY = 10, - VT_CURRENTANIMATIONNAME = 12, - VT_CURRENTARMATURENAME = 14, - VT_TIMESCALE = 16, - VT_ARMATURESCALE = 18 - }; - const WidgetOptions* nodeOptions() const { return GetPointer(VT_NODEOPTIONS); } - const ResourceItemData* fileData() const { return GetPointer(VT_FILEDATA); } - bool isLoop() const { return GetField(VT_ISLOOP, 1) != 0; } - bool isAutoPlay() const { return GetField(VT_ISAUTOPLAY, 1) != 0; } - const flatbuffers::String* currentAnimationName() const - { - return GetPointer(VT_CURRENTANIMATIONNAME); - } - const flatbuffers::String* currentArmatureName() const - { - return GetPointer(VT_CURRENTARMATURENAME); - } - float timeScale() const { return GetField(VT_TIMESCALE, 0.0f); } - float armatureScale() const { return GetField(VT_ARMATURESCALE, 0.0f); } - bool Verify(flatbuffers::Verifier& verifier) const - { - return VerifyTableStart(verifier) && VerifyOffset(verifier, VT_NODEOPTIONS) && - verifier.VerifyTable(nodeOptions()) && VerifyOffset(verifier, VT_FILEDATA) && - verifier.VerifyTable(fileData()) && VerifyField(verifier, VT_ISLOOP) && - VerifyField(verifier, VT_ISAUTOPLAY) && VerifyOffset(verifier, VT_CURRENTANIMATIONNAME) && - verifier.VerifyString(currentAnimationName()) && VerifyOffset(verifier, VT_CURRENTARMATURENAME) && - verifier.VerifyString(currentArmatureName()) && VerifyField(verifier, VT_TIMESCALE) && - VerifyField(verifier, VT_ARMATURESCALE) && verifier.EndTable(); - } +struct CSArmatureNodeOption FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { + typedef CSArmatureNodeOptionBuilder Builder; + enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { + VT_NODEOPTIONS = 4, + VT_FILEDATA = 6, + VT_ISLOOP = 8, + VT_ISAUTOPLAY = 10, + VT_CURRENTANIMATIONNAME = 12, + VT_CURRENTARMATURENAME = 14, + VT_TIMESCALE = 16, + VT_ARMATURESCALE = 18 + }; + const flatbuffers::WidgetOptions *nodeOptions() const { + return GetPointer(VT_NODEOPTIONS); + } + const flatbuffers::ResourceItemData *fileData() const { + return GetPointer(VT_FILEDATA); + } + bool isLoop() const { + return GetField(VT_ISLOOP, 1) != 0; + } + bool isAutoPlay() const { + return GetField(VT_ISAUTOPLAY, 1) != 0; + } + const flatbuffers::String *currentAnimationName() const { + return GetPointer(VT_CURRENTANIMATIONNAME); + } + const flatbuffers::String *currentArmatureName() const { + return GetPointer(VT_CURRENTARMATURENAME); + } + float timeScale() const { + return GetField(VT_TIMESCALE, 0.0f); + } + float armatureScale() const { + return GetField(VT_ARMATURESCALE, 0.0f); + } + bool Verify(flatbuffers::Verifier &verifier) const { + return VerifyTableStart(verifier) && + VerifyOffset(verifier, VT_NODEOPTIONS) && + verifier.VerifyTable(nodeOptions()) && + VerifyOffset(verifier, VT_FILEDATA) && + verifier.VerifyTable(fileData()) && + VerifyField(verifier, VT_ISLOOP, 1) && + VerifyField(verifier, VT_ISAUTOPLAY, 1) && + VerifyOffset(verifier, VT_CURRENTANIMATIONNAME) && + verifier.VerifyString(currentAnimationName()) && + VerifyOffset(verifier, VT_CURRENTARMATURENAME) && + verifier.VerifyString(currentArmatureName()) && + VerifyField(verifier, VT_TIMESCALE, 4) && + VerifyField(verifier, VT_ARMATURESCALE, 4) && + verifier.EndTable(); + } }; -struct CSArmatureNodeOptionBuilder -{ - flatbuffers::FlatBufferBuilder& fbb_; - flatbuffers::uoffset_t start_; - void add_nodeOptions(flatbuffers::Offset nodeOptions) - { - fbb_.AddOffset(CSArmatureNodeOption::VT_NODEOPTIONS, nodeOptions); - } - void add_fileData(flatbuffers::Offset fileData) - { - fbb_.AddOffset(CSArmatureNodeOption::VT_FILEDATA, fileData); - } - void add_isLoop(bool isLoop) - { - fbb_.AddElement(CSArmatureNodeOption::VT_ISLOOP, static_cast(isLoop), 1); - } - void add_isAutoPlay(bool isAutoPlay) - { - fbb_.AddElement(CSArmatureNodeOption::VT_ISAUTOPLAY, static_cast(isAutoPlay), 1); - } - void add_currentAnimationName(flatbuffers::Offset currentAnimationName) - { - fbb_.AddOffset(CSArmatureNodeOption::VT_CURRENTANIMATIONNAME, currentAnimationName); - } - void add_currentArmatureName(flatbuffers::Offset currentArmatureName) - { - fbb_.AddOffset(CSArmatureNodeOption::VT_CURRENTARMATURENAME, currentArmatureName); - } - void add_timeScale(float timeScale) { fbb_.AddElement(CSArmatureNodeOption::VT_TIMESCALE, timeScale, 0.0f); } - void add_armatureScale(float armatureScale) - { - fbb_.AddElement(CSArmatureNodeOption::VT_ARMATURESCALE, armatureScale, 0.0f); - } - explicit CSArmatureNodeOptionBuilder(flatbuffers::FlatBufferBuilder& _fbb) : fbb_(_fbb) - { - start_ = fbb_.StartTable(); - } - CSArmatureNodeOptionBuilder& operator=(const CSArmatureNodeOptionBuilder&); - flatbuffers::Offset Finish() - { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset(end); - return o; - } +struct CSArmatureNodeOptionBuilder { + typedef CSArmatureNodeOption Table; + flatbuffers::FlatBufferBuilder &fbb_; + flatbuffers::uoffset_t start_; + void add_nodeOptions(flatbuffers::Offset nodeOptions) { + fbb_.AddOffset(CSArmatureNodeOption::VT_NODEOPTIONS, nodeOptions); + } + void add_fileData(flatbuffers::Offset fileData) { + fbb_.AddOffset(CSArmatureNodeOption::VT_FILEDATA, fileData); + } + void add_isLoop(bool isLoop) { + fbb_.AddElement(CSArmatureNodeOption::VT_ISLOOP, static_cast(isLoop), 1); + } + void add_isAutoPlay(bool isAutoPlay) { + fbb_.AddElement(CSArmatureNodeOption::VT_ISAUTOPLAY, static_cast(isAutoPlay), 1); + } + void add_currentAnimationName(flatbuffers::Offset currentAnimationName) { + fbb_.AddOffset(CSArmatureNodeOption::VT_CURRENTANIMATIONNAME, currentAnimationName); + } + void add_currentArmatureName(flatbuffers::Offset currentArmatureName) { + fbb_.AddOffset(CSArmatureNodeOption::VT_CURRENTARMATURENAME, currentArmatureName); + } + void add_timeScale(float timeScale) { + fbb_.AddElement(CSArmatureNodeOption::VT_TIMESCALE, timeScale, 0.0f); + } + void add_armatureScale(float armatureScale) { + fbb_.AddElement(CSArmatureNodeOption::VT_ARMATURESCALE, armatureScale, 0.0f); + } + explicit CSArmatureNodeOptionBuilder(flatbuffers::FlatBufferBuilder &_fbb) + : fbb_(_fbb) { + start_ = fbb_.StartTable(); + } + flatbuffers::Offset Finish() { + const auto end = fbb_.EndTable(start_); + auto o = flatbuffers::Offset(end); + return o; + } }; inline flatbuffers::Offset CreateCSArmatureNodeOption( - flatbuffers::FlatBufferBuilder& _fbb, - flatbuffers::Offset nodeOptions = 0, - flatbuffers::Offset fileData = 0, - bool isLoop = true, - bool isAutoPlay = true, + flatbuffers::FlatBufferBuilder &_fbb, + flatbuffers::Offset nodeOptions = 0, + flatbuffers::Offset fileData = 0, + bool isLoop = true, + bool isAutoPlay = true, flatbuffers::Offset currentAnimationName = 0, - flatbuffers::Offset currentArmatureName = 0, - float timeScale = 0.0f, - float armatureScale = 0.0f) -{ - CSArmatureNodeOptionBuilder builder_(_fbb); - builder_.add_armatureScale(armatureScale); - builder_.add_timeScale(timeScale); - builder_.add_currentArmatureName(currentArmatureName); - builder_.add_currentAnimationName(currentAnimationName); - builder_.add_fileData(fileData); - builder_.add_nodeOptions(nodeOptions); - builder_.add_isAutoPlay(isAutoPlay); - builder_.add_isLoop(isLoop); - return builder_.Finish(); + flatbuffers::Offset currentArmatureName = 0, + float timeScale = 0.0f, + float armatureScale = 0.0f) { + CSArmatureNodeOptionBuilder builder_(_fbb); + builder_.add_armatureScale(armatureScale); + builder_.add_timeScale(timeScale); + builder_.add_currentArmatureName(currentArmatureName); + builder_.add_currentAnimationName(currentAnimationName); + builder_.add_fileData(fileData); + builder_.add_nodeOptions(nodeOptions); + builder_.add_isAutoPlay(isAutoPlay); + builder_.add_isLoop(isLoop); + return builder_.Finish(); } inline flatbuffers::Offset CreateCSArmatureNodeOptionDirect( - flatbuffers::FlatBufferBuilder& _fbb, - flatbuffers::Offset nodeOptions = 0, - flatbuffers::Offset fileData = 0, - bool isLoop = true, - bool isAutoPlay = true, - const char* currentAnimationName = nullptr, - const char* currentArmatureName = nullptr, - float timeScale = 0.0f, - float armatureScale = 0.0f) -{ - auto currentAnimationName__ = currentAnimationName ? _fbb.CreateString(currentAnimationName) : 0; - auto currentArmatureName__ = currentArmatureName ? _fbb.CreateString(currentArmatureName) : 0; - return flatbuffers::CreateCSArmatureNodeOption(_fbb, nodeOptions, fileData, isLoop, isAutoPlay, - currentAnimationName__, currentArmatureName__, timeScale, - armatureScale); + flatbuffers::FlatBufferBuilder &_fbb, + flatbuffers::Offset nodeOptions = 0, + flatbuffers::Offset fileData = 0, + bool isLoop = true, + bool isAutoPlay = true, + const char *currentAnimationName = nullptr, + const char *currentArmatureName = nullptr, + float timeScale = 0.0f, + float armatureScale = 0.0f) { + auto currentAnimationName__ = currentAnimationName ? _fbb.CreateString(currentAnimationName) : 0; + auto currentArmatureName__ = currentArmatureName ? _fbb.CreateString(currentArmatureName) : 0; + return flatbuffers::CreateCSArmatureNodeOption( + _fbb, + nodeOptions, + fileData, + isLoop, + isAutoPlay, + currentAnimationName__, + currentArmatureName__, + timeScale, + armatureScale); } -struct ResourceItemData FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table -{ - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE - { - VT_TYPE = 4, - VT_PATH = 6 - }; - int32_t type() const { return GetField(VT_TYPE, 0); } - const flatbuffers::String* path() const { return GetPointer(VT_PATH); } - bool Verify(flatbuffers::Verifier& verifier) const - { - return VerifyTableStart(verifier) && VerifyField(verifier, VT_TYPE) && - VerifyOffset(verifier, VT_PATH) && verifier.VerifyString(path()) && verifier.EndTable(); - } +struct ResourceItemData FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { + typedef ResourceItemDataBuilder Builder; + enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { + VT_TYPE = 4, + VT_PATH = 6 + }; + int32_t type() const { + return GetField(VT_TYPE, 0); + } + const flatbuffers::String *path() const { + return GetPointer(VT_PATH); + } + bool Verify(flatbuffers::Verifier &verifier) const { + return VerifyTableStart(verifier) && + VerifyField(verifier, VT_TYPE, 4) && + VerifyOffset(verifier, VT_PATH) && + verifier.VerifyString(path()) && + verifier.EndTable(); + } }; -struct ResourceItemDataBuilder -{ - flatbuffers::FlatBufferBuilder& fbb_; - flatbuffers::uoffset_t start_; - void add_type(int32_t type) { fbb_.AddElement(ResourceItemData::VT_TYPE, type, 0); } - void add_path(flatbuffers::Offset path) { fbb_.AddOffset(ResourceItemData::VT_PATH, path); } - explicit ResourceItemDataBuilder(flatbuffers::FlatBufferBuilder& _fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } - ResourceItemDataBuilder& operator=(const ResourceItemDataBuilder&); - flatbuffers::Offset Finish() - { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset(end); - return o; - } +struct ResourceItemDataBuilder { + typedef ResourceItemData Table; + flatbuffers::FlatBufferBuilder &fbb_; + flatbuffers::uoffset_t start_; + void add_type(int32_t type) { + fbb_.AddElement(ResourceItemData::VT_TYPE, type, 0); + } + void add_path(flatbuffers::Offset path) { + fbb_.AddOffset(ResourceItemData::VT_PATH, path); + } + explicit ResourceItemDataBuilder(flatbuffers::FlatBufferBuilder &_fbb) + : fbb_(_fbb) { + start_ = fbb_.StartTable(); + } + flatbuffers::Offset Finish() { + const auto end = fbb_.EndTable(start_); + auto o = flatbuffers::Offset(end); + return o; + } }; -inline flatbuffers::Offset CreateResourceItemData(flatbuffers::FlatBufferBuilder& _fbb, - int32_t type = 0, - flatbuffers::Offset path = 0) -{ - ResourceItemDataBuilder builder_(_fbb); - builder_.add_path(path); - builder_.add_type(type); - return builder_.Finish(); +inline flatbuffers::Offset CreateResourceItemData( + flatbuffers::FlatBufferBuilder &_fbb, + int32_t type = 0, + flatbuffers::Offset path = 0) { + ResourceItemDataBuilder builder_(_fbb); + builder_.add_path(path); + builder_.add_type(type); + return builder_.Finish(); } -inline flatbuffers::Offset CreateResourceItemDataDirect(flatbuffers::FlatBufferBuilder& _fbb, - int32_t type = 0, - const char* path = nullptr) -{ - auto path__ = path ? _fbb.CreateString(path) : 0; - return flatbuffers::CreateResourceItemData(_fbb, type, path__); +inline flatbuffers::Offset CreateResourceItemDataDirect( + flatbuffers::FlatBufferBuilder &_fbb, + int32_t type = 0, + const char *path = nullptr) { + auto path__ = path ? _fbb.CreateString(path) : 0; + return flatbuffers::CreateResourceItemData( + _fbb, + type, + path__); } -inline const flatbuffers::CSArmatureNodeOption* GetCSArmatureNodeOption(const void* buf) -{ - return flatbuffers::GetRoot(buf); +inline const flatbuffers::CSArmatureNodeOption *GetCSArmatureNodeOption(const void *buf) { + return flatbuffers::GetRoot(buf); } -inline const flatbuffers::CSArmatureNodeOption* GetSizePrefixedCSArmatureNodeOption(const void* buf) -{ - return flatbuffers::GetSizePrefixedRoot(buf); +inline const flatbuffers::CSArmatureNodeOption *GetSizePrefixedCSArmatureNodeOption(const void *buf) { + return flatbuffers::GetSizePrefixedRoot(buf); } -inline bool VerifyCSArmatureNodeOptionBuffer(flatbuffers::Verifier& verifier) -{ - return verifier.VerifyBuffer(nullptr); +inline bool VerifyCSArmatureNodeOptionBuffer( + flatbuffers::Verifier &verifier) { + return verifier.VerifyBuffer(nullptr); } -inline bool VerifySizePrefixedCSArmatureNodeOptionBuffer(flatbuffers::Verifier& verifier) -{ - return verifier.VerifySizePrefixedBuffer(nullptr); +inline bool VerifySizePrefixedCSArmatureNodeOptionBuffer( + flatbuffers::Verifier &verifier) { + return verifier.VerifySizePrefixedBuffer(nullptr); } -inline void FinishCSArmatureNodeOptionBuffer(flatbuffers::FlatBufferBuilder& fbb, - flatbuffers::Offset root) -{ - fbb.Finish(root); +inline void FinishCSArmatureNodeOptionBuffer( + flatbuffers::FlatBufferBuilder &fbb, + flatbuffers::Offset root) { + fbb.Finish(root); } -inline void FinishSizePrefixedCSArmatureNodeOptionBuffer(flatbuffers::FlatBufferBuilder& fbb, - flatbuffers::Offset root) -{ - fbb.FinishSizePrefixed(root); +inline void FinishSizePrefixedCSArmatureNodeOptionBuffer( + flatbuffers::FlatBufferBuilder &fbb, + flatbuffers::Offset root) { + fbb.FinishSizePrefixed(root); } } // namespace flatbuffers diff --git a/extensions/cocostudio/WidgetReader/SkeletonReader/CSBoneBinary_generated.h b/extensions/cocostudio/WidgetReader/SkeletonReader/CSBoneBinary_generated.h index 3f8c99f216..7b1a2b2786 100644 --- a/extensions/cocostudio/WidgetReader/SkeletonReader/CSBoneBinary_generated.h +++ b/extensions/cocostudio/WidgetReader/SkeletonReader/CSBoneBinary_generated.h @@ -1,88 +1,115 @@ // automatically generated by the FlatBuffers compiler, do not modify + #ifndef FLATBUFFERS_GENERATED_CSBONEBINARY_FLATBUFFERS_H_ #define FLATBUFFERS_GENERATED_CSBONEBINARY_FLATBUFFERS_H_ #include "flatbuffers/flatbuffers.h" +// Ensure the included flatbuffers.h is the same version as when this file was +// generated, otherwise it may not be compatible. +static_assert(FLATBUFFERS_VERSION_MAJOR == 2 && + FLATBUFFERS_VERSION_MINOR == 0 && + FLATBUFFERS_VERSION_REVISION == 8, + "Non-compatible flatbuffers version included"); + #include "CSParseBinary_generated.h" -namespace flatbuffers -{ +namespace flatbuffers { struct BoneOptions; +struct BoneOptionsBuilder; -struct BoneOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table -{ - enum - { - VT_NODEOPTIONS = 4, - VT_LENGTH = 6, - VT_BLENDFUNC = 8 - }; - const flatbuffers::WidgetOptions* nodeOptions() const - { - return GetPointer(VT_NODEOPTIONS); - } - float length() const { return GetField(VT_LENGTH, 0.0f); } - const flatbuffers::BlendFunc* blendFunc() const { return GetStruct(VT_BLENDFUNC); } - bool Verify(flatbuffers::Verifier& verifier) const - { - return VerifyTableStart(verifier) && VerifyField(verifier, VT_NODEOPTIONS) && - verifier.VerifyTable(nodeOptions()) && VerifyField(verifier, VT_LENGTH) && - VerifyField(verifier, VT_BLENDFUNC) && verifier.EndTable(); - } +struct BoneOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { + typedef BoneOptionsBuilder Builder; + enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { + VT_NODEOPTIONS = 4, + VT_LENGTH = 6, + VT_BLENDFUNC = 8 + }; + const flatbuffers::WidgetOptions *nodeOptions() const { + return GetPointer(VT_NODEOPTIONS); + } + float length() const { + return GetField(VT_LENGTH, 0.0f); + } + const flatbuffers::BlendFunc *blendFunc() const { + return GetStruct(VT_BLENDFUNC); + } + bool Verify(flatbuffers::Verifier &verifier) const { + return VerifyTableStart(verifier) && + VerifyOffset(verifier, VT_NODEOPTIONS) && + verifier.VerifyTable(nodeOptions()) && + VerifyField(verifier, VT_LENGTH, 4) && + VerifyField(verifier, VT_BLENDFUNC, 4) && + verifier.EndTable(); + } }; -struct BoneOptionsBuilder -{ - flatbuffers::FlatBufferBuilder& fbb_; - flatbuffers::uoffset_t start_; - void add_nodeOptions(flatbuffers::Offset nodeOptions) - { - fbb_.AddOffset(BoneOptions::VT_NODEOPTIONS, nodeOptions); - } - void add_length(float length) { fbb_.AddElement(BoneOptions::VT_LENGTH, length, 0.0f); } - void add_blendFunc(const flatbuffers::BlendFunc* blendFunc) - { - fbb_.AddStruct(BoneOptions::VT_BLENDFUNC, blendFunc); - } - BoneOptionsBuilder(flatbuffers::FlatBufferBuilder& _fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } - BoneOptionsBuilder& operator=(const BoneOptionsBuilder&); - flatbuffers::Offset Finish() - { - auto o = flatbuffers::Offset(fbb_.EndTable(start_, 3)); - return o; - } +struct BoneOptionsBuilder { + typedef BoneOptions Table; + flatbuffers::FlatBufferBuilder &fbb_; + flatbuffers::uoffset_t start_; + void add_nodeOptions(flatbuffers::Offset nodeOptions) { + fbb_.AddOffset(BoneOptions::VT_NODEOPTIONS, nodeOptions); + } + void add_length(float length) { + fbb_.AddElement(BoneOptions::VT_LENGTH, length, 0.0f); + } + void add_blendFunc(const flatbuffers::BlendFunc *blendFunc) { + fbb_.AddStruct(BoneOptions::VT_BLENDFUNC, blendFunc); + } + explicit BoneOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) + : fbb_(_fbb) { + start_ = fbb_.StartTable(); + } + flatbuffers::Offset Finish() { + const auto end = fbb_.EndTable(start_); + auto o = flatbuffers::Offset(end); + return o; + } }; inline flatbuffers::Offset CreateBoneOptions( - flatbuffers::FlatBufferBuilder& _fbb, + flatbuffers::FlatBufferBuilder &_fbb, flatbuffers::Offset nodeOptions = 0, - float length = 0.0f, - const flatbuffers::BlendFunc* blendFunc = 0) -{ - BoneOptionsBuilder builder_(_fbb); - builder_.add_blendFunc(blendFunc); - builder_.add_length(length); - builder_.add_nodeOptions(nodeOptions); - return builder_.Finish(); + float length = 0.0f, + const flatbuffers::BlendFunc *blendFunc = nullptr) { + BoneOptionsBuilder builder_(_fbb); + builder_.add_blendFunc(blendFunc); + builder_.add_length(length); + builder_.add_nodeOptions(nodeOptions); + return builder_.Finish(); } -inline const flatbuffers::BoneOptions* GetBoneOptions(const void* buf) -{ - return flatbuffers::GetRoot(buf); +inline const flatbuffers::BoneOptions *GetBoneOptions(const void *buf) { + return flatbuffers::GetRoot(buf); } -inline bool VerifyBoneOptionsBuffer(flatbuffers::Verifier& verifier) -{ - return verifier.VerifyBuffer(nullptr); +inline const flatbuffers::BoneOptions *GetSizePrefixedBoneOptions(const void *buf) { + return flatbuffers::GetSizePrefixedRoot(buf); } -inline void FinishBoneOptionsBuffer(flatbuffers::FlatBufferBuilder& fbb, - flatbuffers::Offset root) -{ - fbb.Finish(root); +inline bool VerifyBoneOptionsBuffer( + flatbuffers::Verifier &verifier) { + return verifier.VerifyBuffer(nullptr); +} + +inline bool VerifySizePrefixedBoneOptionsBuffer( + flatbuffers::Verifier &verifier) { + return verifier.VerifySizePrefixedBuffer(nullptr); +} + +inline void FinishBoneOptionsBuffer( + flatbuffers::FlatBufferBuilder &fbb, + flatbuffers::Offset root) { + fbb.Finish(root); +} + +inline void FinishSizePrefixedBoneOptionsBuffer( + flatbuffers::FlatBufferBuilder &fbb, + flatbuffers::Offset root) { + fbb.FinishSizePrefixed(root); } } // namespace flatbuffers diff --git a/extensions/cocostudio/WidgetReader/TabControlReader/CSTabControl_generated.h b/extensions/cocostudio/WidgetReader/TabControlReader/CSTabControl_generated.h index e3bc529eb9..46bb2cacb3 100644 --- a/extensions/cocostudio/WidgetReader/TabControlReader/CSTabControl_generated.h +++ b/extensions/cocostudio/WidgetReader/TabControlReader/CSTabControl_generated.h @@ -1,351 +1,415 @@ // automatically generated by the FlatBuffers compiler, do not modify + #ifndef FLATBUFFERS_GENERATED_CSTABCONTROL_FLATBUFFERS_H_ #define FLATBUFFERS_GENERATED_CSTABCONTROL_FLATBUFFERS_H_ #include "flatbuffers/flatbuffers.h" +// Ensure the included flatbuffers.h is the same version as when this file was +// generated, otherwise it may not be compatible. +static_assert(FLATBUFFERS_VERSION_MAJOR == 2 && + FLATBUFFERS_VERSION_MINOR == 0 && + FLATBUFFERS_VERSION_REVISION == 8, + "Non-compatible flatbuffers version included"); + #include "CSParseBinary_generated.h" -namespace flatbuffers -{ +namespace flatbuffers { struct TabControlOption; +struct TabControlOptionBuilder; struct TabHeaderOption; +struct TabHeaderOptionBuilder; struct TabItemOption; +struct TabItemOptionBuilder; -struct TabControlOption FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table -{ - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE - { - VT_NODEOPTIONS = 4, - VT_HEADERPLACE = 6, - VT_HEADERWIDTH = 8, - VT_HEADERHEIGHT = 10, - VT_SELECTEDTABZOOM = 12, - VT_SELECTEDTABINDEX = 14, - VT_IGNOREHEADERTEXTURESIZE = 16, - VT_TABITEMS = 18 - }; - const WidgetOptions* nodeOptions() const { return GetPointer(VT_NODEOPTIONS); } - int32_t headerPlace() const { return GetField(VT_HEADERPLACE, 0); } - int32_t headerWidth() const { return GetField(VT_HEADERWIDTH, 0); } - int32_t headerHeight() const { return GetField(VT_HEADERHEIGHT, 0); } - float selectedTabZoom() const { return GetField(VT_SELECTEDTABZOOM, 0.0f); } - int32_t selectedTabIndex() const { return GetField(VT_SELECTEDTABINDEX, 0); } - uint8_t ignoreHeaderTextureSize() const { return GetField(VT_IGNOREHEADERTEXTURESIZE, 0); } - const flatbuffers::Vector>* tabItems() const - { - return GetPointer>*>(VT_TABITEMS); - } - bool Verify(flatbuffers::Verifier& verifier) const - { - return VerifyTableStart(verifier) && VerifyOffset(verifier, VT_NODEOPTIONS) && - verifier.VerifyTable(nodeOptions()) && VerifyField(verifier, VT_HEADERPLACE) && - VerifyField(verifier, VT_HEADERWIDTH) && VerifyField(verifier, VT_HEADERHEIGHT) && - VerifyField(verifier, VT_SELECTEDTABZOOM) && - VerifyField(verifier, VT_SELECTEDTABINDEX) && - VerifyField(verifier, VT_IGNOREHEADERTEXTURESIZE) && VerifyOffset(verifier, VT_TABITEMS) && - verifier.VerifyVector(tabItems()) && verifier.VerifyVectorOfTables(tabItems()) && verifier.EndTable(); - } +struct TabControlOption FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { + typedef TabControlOptionBuilder Builder; + enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { + VT_NODEOPTIONS = 4, + VT_HEADERPLACE = 6, + VT_HEADERWIDTH = 8, + VT_HEADERHEIGHT = 10, + VT_SELECTEDTABZOOM = 12, + VT_SELECTEDTABINDEX = 14, + VT_IGNOREHEADERTEXTURESIZE = 16, + VT_TABITEMS = 18 + }; + const flatbuffers::WidgetOptions *nodeOptions() const { + return GetPointer(VT_NODEOPTIONS); + } + int32_t headerPlace() const { + return GetField(VT_HEADERPLACE, 0); + } + int32_t headerWidth() const { + return GetField(VT_HEADERWIDTH, 0); + } + int32_t headerHeight() const { + return GetField(VT_HEADERHEIGHT, 0); + } + float selectedTabZoom() const { + return GetField(VT_SELECTEDTABZOOM, 0.0f); + } + int32_t selectedTabIndex() const { + return GetField(VT_SELECTEDTABINDEX, 0); + } + uint8_t ignoreHeaderTextureSize() const { + return GetField(VT_IGNOREHEADERTEXTURESIZE, 0); + } + const flatbuffers::Vector> *tabItems() const { + return GetPointer> *>(VT_TABITEMS); + } + bool Verify(flatbuffers::Verifier &verifier) const { + return VerifyTableStart(verifier) && + VerifyOffset(verifier, VT_NODEOPTIONS) && + verifier.VerifyTable(nodeOptions()) && + VerifyField(verifier, VT_HEADERPLACE, 4) && + VerifyField(verifier, VT_HEADERWIDTH, 4) && + VerifyField(verifier, VT_HEADERHEIGHT, 4) && + VerifyField(verifier, VT_SELECTEDTABZOOM, 4) && + VerifyField(verifier, VT_SELECTEDTABINDEX, 4) && + VerifyField(verifier, VT_IGNOREHEADERTEXTURESIZE, 1) && + VerifyOffset(verifier, VT_TABITEMS) && + verifier.VerifyVector(tabItems()) && + verifier.VerifyVectorOfTables(tabItems()) && + verifier.EndTable(); + } }; -struct TabControlOptionBuilder -{ - flatbuffers::FlatBufferBuilder& fbb_; - flatbuffers::uoffset_t start_; - void add_nodeOptions(flatbuffers::Offset nodeOptions) - { - fbb_.AddOffset(TabControlOption::VT_NODEOPTIONS, nodeOptions); - } - void add_headerPlace(int32_t headerPlace) - { - fbb_.AddElement(TabControlOption::VT_HEADERPLACE, headerPlace, 0); - } - void add_headerWidth(int32_t headerWidth) - { - fbb_.AddElement(TabControlOption::VT_HEADERWIDTH, headerWidth, 0); - } - void add_headerHeight(int32_t headerHeight) - { - fbb_.AddElement(TabControlOption::VT_HEADERHEIGHT, headerHeight, 0); - } - void add_selectedTabZoom(float selectedTabZoom) - { - fbb_.AddElement(TabControlOption::VT_SELECTEDTABZOOM, selectedTabZoom, 0.0f); - } - void add_selectedTabIndex(int32_t selectedTabIndex) - { - fbb_.AddElement(TabControlOption::VT_SELECTEDTABINDEX, selectedTabIndex, 0); - } - void add_ignoreHeaderTextureSize(uint8_t ignoreHeaderTextureSize) - { - fbb_.AddElement(TabControlOption::VT_IGNOREHEADERTEXTURESIZE, ignoreHeaderTextureSize, 0); - } - void add_tabItems(flatbuffers::Offset>> tabItems) - { - fbb_.AddOffset(TabControlOption::VT_TABITEMS, tabItems); - } - explicit TabControlOptionBuilder(flatbuffers::FlatBufferBuilder& _fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } - TabControlOptionBuilder& operator=(const TabControlOptionBuilder&); - flatbuffers::Offset Finish() - { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset(end); - return o; - } +struct TabControlOptionBuilder { + typedef TabControlOption Table; + flatbuffers::FlatBufferBuilder &fbb_; + flatbuffers::uoffset_t start_; + void add_nodeOptions(flatbuffers::Offset nodeOptions) { + fbb_.AddOffset(TabControlOption::VT_NODEOPTIONS, nodeOptions); + } + void add_headerPlace(int32_t headerPlace) { + fbb_.AddElement(TabControlOption::VT_HEADERPLACE, headerPlace, 0); + } + void add_headerWidth(int32_t headerWidth) { + fbb_.AddElement(TabControlOption::VT_HEADERWIDTH, headerWidth, 0); + } + void add_headerHeight(int32_t headerHeight) { + fbb_.AddElement(TabControlOption::VT_HEADERHEIGHT, headerHeight, 0); + } + void add_selectedTabZoom(float selectedTabZoom) { + fbb_.AddElement(TabControlOption::VT_SELECTEDTABZOOM, selectedTabZoom, 0.0f); + } + void add_selectedTabIndex(int32_t selectedTabIndex) { + fbb_.AddElement(TabControlOption::VT_SELECTEDTABINDEX, selectedTabIndex, 0); + } + void add_ignoreHeaderTextureSize(uint8_t ignoreHeaderTextureSize) { + fbb_.AddElement(TabControlOption::VT_IGNOREHEADERTEXTURESIZE, ignoreHeaderTextureSize, 0); + } + void add_tabItems(flatbuffers::Offset>> tabItems) { + fbb_.AddOffset(TabControlOption::VT_TABITEMS, tabItems); + } + explicit TabControlOptionBuilder(flatbuffers::FlatBufferBuilder &_fbb) + : fbb_(_fbb) { + start_ = fbb_.StartTable(); + } + flatbuffers::Offset Finish() { + const auto end = fbb_.EndTable(start_); + auto o = flatbuffers::Offset(end); + return o; + } }; inline flatbuffers::Offset CreateTabControlOption( - flatbuffers::FlatBufferBuilder& _fbb, - flatbuffers::Offset nodeOptions = 0, - int32_t headerPlace = 0, - int32_t headerWidth = 0, - int32_t headerHeight = 0, - float selectedTabZoom = 0.0f, - int32_t selectedTabIndex = 0, - uint8_t ignoreHeaderTextureSize = 0, - flatbuffers::Offset>> tabItems = 0) -{ - TabControlOptionBuilder builder_(_fbb); - builder_.add_tabItems(tabItems); - builder_.add_selectedTabIndex(selectedTabIndex); - builder_.add_selectedTabZoom(selectedTabZoom); - builder_.add_headerHeight(headerHeight); - builder_.add_headerWidth(headerWidth); - builder_.add_headerPlace(headerPlace); - builder_.add_nodeOptions(nodeOptions); - builder_.add_ignoreHeaderTextureSize(ignoreHeaderTextureSize); - return builder_.Finish(); + flatbuffers::FlatBufferBuilder &_fbb, + flatbuffers::Offset nodeOptions = 0, + int32_t headerPlace = 0, + int32_t headerWidth = 0, + int32_t headerHeight = 0, + float selectedTabZoom = 0.0f, + int32_t selectedTabIndex = 0, + uint8_t ignoreHeaderTextureSize = 0, + flatbuffers::Offset>> tabItems = 0) { + TabControlOptionBuilder builder_(_fbb); + builder_.add_tabItems(tabItems); + builder_.add_selectedTabIndex(selectedTabIndex); + builder_.add_selectedTabZoom(selectedTabZoom); + builder_.add_headerHeight(headerHeight); + builder_.add_headerWidth(headerWidth); + builder_.add_headerPlace(headerPlace); + builder_.add_nodeOptions(nodeOptions); + builder_.add_ignoreHeaderTextureSize(ignoreHeaderTextureSize); + return builder_.Finish(); } inline flatbuffers::Offset CreateTabControlOptionDirect( - flatbuffers::FlatBufferBuilder& _fbb, - flatbuffers::Offset nodeOptions = 0, - int32_t headerPlace = 0, - int32_t headerWidth = 0, - int32_t headerHeight = 0, - float selectedTabZoom = 0.0f, - int32_t selectedTabIndex = 0, - uint8_t ignoreHeaderTextureSize = 0, - const std::vector>* tabItems = nullptr) -{ - auto tabItems__ = tabItems ? _fbb.CreateVector>(*tabItems) : 0; - return flatbuffers::CreateTabControlOption(_fbb, nodeOptions, headerPlace, headerWidth, headerHeight, - selectedTabZoom, selectedTabIndex, ignoreHeaderTextureSize, tabItems__); + flatbuffers::FlatBufferBuilder &_fbb, + flatbuffers::Offset nodeOptions = 0, + int32_t headerPlace = 0, + int32_t headerWidth = 0, + int32_t headerHeight = 0, + float selectedTabZoom = 0.0f, + int32_t selectedTabIndex = 0, + uint8_t ignoreHeaderTextureSize = 0, + const std::vector> *tabItems = nullptr) { + auto tabItems__ = tabItems ? _fbb.CreateVector>(*tabItems) : 0; + return flatbuffers::CreateTabControlOption( + _fbb, + nodeOptions, + headerPlace, + headerWidth, + headerHeight, + selectedTabZoom, + selectedTabIndex, + ignoreHeaderTextureSize, + tabItems__); } -struct TabHeaderOption FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table -{ - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE - { - VT_NODEOPTIONS = 4, - VT_FONTRES = 6, - VT_FONTSIZE = 8, - VT_TITLETEXT = 10, - VT_TEXTCOLOR = 12, - VT_NORMALBACKFILE = 14, - VT_PRESSBACKFILE = 16, - VT_DISABLEBACKFILE = 18, - VT_CROSSNORMALFILE = 20, - VT_CROSSDISABLEFILE = 22 - }; - const WidgetOptions* nodeOptions() const { return GetPointer(VT_NODEOPTIONS); } - const ResourceData* fontRes() const { return GetPointer(VT_FONTRES); } - int32_t fontSize() const { return GetField(VT_FONTSIZE, 0); } - const flatbuffers::String* titleText() const { return GetPointer(VT_TITLETEXT); } - const Color* textColor() const { return GetStruct(VT_TEXTCOLOR); } - const ResourceData* normalBackFile() const { return GetPointer(VT_NORMALBACKFILE); } - const ResourceData* pressBackFile() const { return GetPointer(VT_PRESSBACKFILE); } - const ResourceData* disableBackFile() const { return GetPointer(VT_DISABLEBACKFILE); } - const ResourceData* crossNormalFile() const { return GetPointer(VT_CROSSNORMALFILE); } - const ResourceData* crossDisableFile() const { return GetPointer(VT_CROSSDISABLEFILE); } - bool Verify(flatbuffers::Verifier& verifier) const - { - return VerifyTableStart(verifier) && VerifyOffset(verifier, VT_NODEOPTIONS) && - verifier.VerifyTable(nodeOptions()) && VerifyOffset(verifier, VT_FONTRES) && - verifier.VerifyTable(fontRes()) && VerifyField(verifier, VT_FONTSIZE) && - VerifyOffset(verifier, VT_TITLETEXT) && verifier.VerifyString(titleText()) && - VerifyField(verifier, VT_TEXTCOLOR) && VerifyOffset(verifier, VT_NORMALBACKFILE) && - verifier.VerifyTable(normalBackFile()) && VerifyOffset(verifier, VT_PRESSBACKFILE) && - verifier.VerifyTable(pressBackFile()) && VerifyOffset(verifier, VT_DISABLEBACKFILE) && - verifier.VerifyTable(disableBackFile()) && VerifyOffset(verifier, VT_CROSSNORMALFILE) && - verifier.VerifyTable(crossNormalFile()) && VerifyOffset(verifier, VT_CROSSDISABLEFILE) && - verifier.VerifyTable(crossDisableFile()) && verifier.EndTable(); - } +struct TabHeaderOption FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { + typedef TabHeaderOptionBuilder Builder; + enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { + VT_NODEOPTIONS = 4, + VT_FONTRES = 6, + VT_FONTSIZE = 8, + VT_TITLETEXT = 10, + VT_TEXTCOLOR = 12, + VT_NORMALBACKFILE = 14, + VT_PRESSBACKFILE = 16, + VT_DISABLEBACKFILE = 18, + VT_CROSSNORMALFILE = 20, + VT_CROSSDISABLEFILE = 22 + }; + const flatbuffers::WidgetOptions *nodeOptions() const { + return GetPointer(VT_NODEOPTIONS); + } + const flatbuffers::ResourceData *fontRes() const { + return GetPointer(VT_FONTRES); + } + int32_t fontSize() const { + return GetField(VT_FONTSIZE, 0); + } + const flatbuffers::String *titleText() const { + return GetPointer(VT_TITLETEXT); + } + const flatbuffers::Color *textColor() const { + return GetStruct(VT_TEXTCOLOR); + } + const flatbuffers::ResourceData *normalBackFile() const { + return GetPointer(VT_NORMALBACKFILE); + } + const flatbuffers::ResourceData *pressBackFile() const { + return GetPointer(VT_PRESSBACKFILE); + } + const flatbuffers::ResourceData *disableBackFile() const { + return GetPointer(VT_DISABLEBACKFILE); + } + const flatbuffers::ResourceData *crossNormalFile() const { + return GetPointer(VT_CROSSNORMALFILE); + } + const flatbuffers::ResourceData *crossDisableFile() const { + return GetPointer(VT_CROSSDISABLEFILE); + } + bool Verify(flatbuffers::Verifier &verifier) const { + return VerifyTableStart(verifier) && + VerifyOffset(verifier, VT_NODEOPTIONS) && + verifier.VerifyTable(nodeOptions()) && + VerifyOffset(verifier, VT_FONTRES) && + verifier.VerifyTable(fontRes()) && + VerifyField(verifier, VT_FONTSIZE, 4) && + VerifyOffset(verifier, VT_TITLETEXT) && + verifier.VerifyString(titleText()) && + VerifyField(verifier, VT_TEXTCOLOR, 1) && + VerifyOffset(verifier, VT_NORMALBACKFILE) && + verifier.VerifyTable(normalBackFile()) && + VerifyOffset(verifier, VT_PRESSBACKFILE) && + verifier.VerifyTable(pressBackFile()) && + VerifyOffset(verifier, VT_DISABLEBACKFILE) && + verifier.VerifyTable(disableBackFile()) && + VerifyOffset(verifier, VT_CROSSNORMALFILE) && + verifier.VerifyTable(crossNormalFile()) && + VerifyOffset(verifier, VT_CROSSDISABLEFILE) && + verifier.VerifyTable(crossDisableFile()) && + verifier.EndTable(); + } }; -struct TabHeaderOptionBuilder -{ - flatbuffers::FlatBufferBuilder& fbb_; - flatbuffers::uoffset_t start_; - void add_nodeOptions(flatbuffers::Offset nodeOptions) - { - fbb_.AddOffset(TabHeaderOption::VT_NODEOPTIONS, nodeOptions); - } - void add_fontRes(flatbuffers::Offset fontRes) - { - fbb_.AddOffset(TabHeaderOption::VT_FONTRES, fontRes); - } - void add_fontSize(int32_t fontSize) { fbb_.AddElement(TabHeaderOption::VT_FONTSIZE, fontSize, 0); } - void add_titleText(flatbuffers::Offset titleText) - { - fbb_.AddOffset(TabHeaderOption::VT_TITLETEXT, titleText); - } - void add_textColor(const Color* textColor) { fbb_.AddStruct(TabHeaderOption::VT_TEXTCOLOR, textColor); } - void add_normalBackFile(flatbuffers::Offset normalBackFile) - { - fbb_.AddOffset(TabHeaderOption::VT_NORMALBACKFILE, normalBackFile); - } - void add_pressBackFile(flatbuffers::Offset pressBackFile) - { - fbb_.AddOffset(TabHeaderOption::VT_PRESSBACKFILE, pressBackFile); - } - void add_disableBackFile(flatbuffers::Offset disableBackFile) - { - fbb_.AddOffset(TabHeaderOption::VT_DISABLEBACKFILE, disableBackFile); - } - void add_crossNormalFile(flatbuffers::Offset crossNormalFile) - { - fbb_.AddOffset(TabHeaderOption::VT_CROSSNORMALFILE, crossNormalFile); - } - void add_crossDisableFile(flatbuffers::Offset crossDisableFile) - { - fbb_.AddOffset(TabHeaderOption::VT_CROSSDISABLEFILE, crossDisableFile); - } - explicit TabHeaderOptionBuilder(flatbuffers::FlatBufferBuilder& _fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } - TabHeaderOptionBuilder& operator=(const TabHeaderOptionBuilder&); - flatbuffers::Offset Finish() - { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset(end); - return o; - } +struct TabHeaderOptionBuilder { + typedef TabHeaderOption Table; + flatbuffers::FlatBufferBuilder &fbb_; + flatbuffers::uoffset_t start_; + void add_nodeOptions(flatbuffers::Offset nodeOptions) { + fbb_.AddOffset(TabHeaderOption::VT_NODEOPTIONS, nodeOptions); + } + void add_fontRes(flatbuffers::Offset fontRes) { + fbb_.AddOffset(TabHeaderOption::VT_FONTRES, fontRes); + } + void add_fontSize(int32_t fontSize) { + fbb_.AddElement(TabHeaderOption::VT_FONTSIZE, fontSize, 0); + } + void add_titleText(flatbuffers::Offset titleText) { + fbb_.AddOffset(TabHeaderOption::VT_TITLETEXT, titleText); + } + void add_textColor(const flatbuffers::Color *textColor) { + fbb_.AddStruct(TabHeaderOption::VT_TEXTCOLOR, textColor); + } + void add_normalBackFile(flatbuffers::Offset normalBackFile) { + fbb_.AddOffset(TabHeaderOption::VT_NORMALBACKFILE, normalBackFile); + } + void add_pressBackFile(flatbuffers::Offset pressBackFile) { + fbb_.AddOffset(TabHeaderOption::VT_PRESSBACKFILE, pressBackFile); + } + void add_disableBackFile(flatbuffers::Offset disableBackFile) { + fbb_.AddOffset(TabHeaderOption::VT_DISABLEBACKFILE, disableBackFile); + } + void add_crossNormalFile(flatbuffers::Offset crossNormalFile) { + fbb_.AddOffset(TabHeaderOption::VT_CROSSNORMALFILE, crossNormalFile); + } + void add_crossDisableFile(flatbuffers::Offset crossDisableFile) { + fbb_.AddOffset(TabHeaderOption::VT_CROSSDISABLEFILE, crossDisableFile); + } + explicit TabHeaderOptionBuilder(flatbuffers::FlatBufferBuilder &_fbb) + : fbb_(_fbb) { + start_ = fbb_.StartTable(); + } + flatbuffers::Offset Finish() { + const auto end = fbb_.EndTable(start_); + auto o = flatbuffers::Offset(end); + return o; + } }; inline flatbuffers::Offset CreateTabHeaderOption( - flatbuffers::FlatBufferBuilder& _fbb, - flatbuffers::Offset nodeOptions = 0, - flatbuffers::Offset fontRes = 0, - int32_t fontSize = 0, + flatbuffers::FlatBufferBuilder &_fbb, + flatbuffers::Offset nodeOptions = 0, + flatbuffers::Offset fontRes = 0, + int32_t fontSize = 0, flatbuffers::Offset titleText = 0, - const Color* textColor = 0, - flatbuffers::Offset normalBackFile = 0, - flatbuffers::Offset pressBackFile = 0, - flatbuffers::Offset disableBackFile = 0, - flatbuffers::Offset crossNormalFile = 0, - flatbuffers::Offset crossDisableFile = 0) -{ - TabHeaderOptionBuilder builder_(_fbb); - builder_.add_crossDisableFile(crossDisableFile); - builder_.add_crossNormalFile(crossNormalFile); - builder_.add_disableBackFile(disableBackFile); - builder_.add_pressBackFile(pressBackFile); - builder_.add_normalBackFile(normalBackFile); - builder_.add_textColor(textColor); - builder_.add_titleText(titleText); - builder_.add_fontSize(fontSize); - builder_.add_fontRes(fontRes); - builder_.add_nodeOptions(nodeOptions); - return builder_.Finish(); + const flatbuffers::Color *textColor = nullptr, + flatbuffers::Offset normalBackFile = 0, + flatbuffers::Offset pressBackFile = 0, + flatbuffers::Offset disableBackFile = 0, + flatbuffers::Offset crossNormalFile = 0, + flatbuffers::Offset crossDisableFile = 0) { + TabHeaderOptionBuilder builder_(_fbb); + builder_.add_crossDisableFile(crossDisableFile); + builder_.add_crossNormalFile(crossNormalFile); + builder_.add_disableBackFile(disableBackFile); + builder_.add_pressBackFile(pressBackFile); + builder_.add_normalBackFile(normalBackFile); + builder_.add_textColor(textColor); + builder_.add_titleText(titleText); + builder_.add_fontSize(fontSize); + builder_.add_fontRes(fontRes); + builder_.add_nodeOptions(nodeOptions); + return builder_.Finish(); } inline flatbuffers::Offset CreateTabHeaderOptionDirect( - flatbuffers::FlatBufferBuilder& _fbb, - flatbuffers::Offset nodeOptions = 0, - flatbuffers::Offset fontRes = 0, - int32_t fontSize = 0, - const char* titleText = nullptr, - const Color* textColor = 0, - flatbuffers::Offset normalBackFile = 0, - flatbuffers::Offset pressBackFile = 0, - flatbuffers::Offset disableBackFile = 0, - flatbuffers::Offset crossNormalFile = 0, - flatbuffers::Offset crossDisableFile = 0) -{ - auto titleText__ = titleText ? _fbb.CreateString(titleText) : 0; - return flatbuffers::CreateTabHeaderOption(_fbb, nodeOptions, fontRes, fontSize, titleText__, textColor, - normalBackFile, pressBackFile, disableBackFile, crossNormalFile, - crossDisableFile); + flatbuffers::FlatBufferBuilder &_fbb, + flatbuffers::Offset nodeOptions = 0, + flatbuffers::Offset fontRes = 0, + int32_t fontSize = 0, + const char *titleText = nullptr, + const flatbuffers::Color *textColor = nullptr, + flatbuffers::Offset normalBackFile = 0, + flatbuffers::Offset pressBackFile = 0, + flatbuffers::Offset disableBackFile = 0, + flatbuffers::Offset crossNormalFile = 0, + flatbuffers::Offset crossDisableFile = 0) { + auto titleText__ = titleText ? _fbb.CreateString(titleText) : 0; + return flatbuffers::CreateTabHeaderOption( + _fbb, + nodeOptions, + fontRes, + fontSize, + titleText__, + textColor, + normalBackFile, + pressBackFile, + disableBackFile, + crossNormalFile, + crossDisableFile); } -struct TabItemOption FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table -{ - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE - { - VT_HEADER = 4, - VT_CONTAINER = 6 - }; - const TabHeaderOption* header() const { return GetPointer(VT_HEADER); } - const NodeTree* container() const { return GetPointer(VT_CONTAINER); } - bool Verify(flatbuffers::Verifier& verifier) const - { - return VerifyTableStart(verifier) && VerifyOffset(verifier, VT_HEADER) && verifier.VerifyTable(header()) && - VerifyOffset(verifier, VT_CONTAINER) && verifier.VerifyTable(container()) && verifier.EndTable(); - } +struct TabItemOption FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { + typedef TabItemOptionBuilder Builder; + enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { + VT_HEADER = 4, + VT_CONTAINER = 6 + }; + const flatbuffers::TabHeaderOption *header() const { + return GetPointer(VT_HEADER); + } + const flatbuffers::NodeTree *container() const { + return GetPointer(VT_CONTAINER); + } + bool Verify(flatbuffers::Verifier &verifier) const { + return VerifyTableStart(verifier) && + VerifyOffset(verifier, VT_HEADER) && + verifier.VerifyTable(header()) && + VerifyOffset(verifier, VT_CONTAINER) && + verifier.VerifyTable(container()) && + verifier.EndTable(); + } }; -struct TabItemOptionBuilder -{ - flatbuffers::FlatBufferBuilder& fbb_; - flatbuffers::uoffset_t start_; - void add_header(flatbuffers::Offset header) { fbb_.AddOffset(TabItemOption::VT_HEADER, header); } - void add_container(flatbuffers::Offset container) - { - fbb_.AddOffset(TabItemOption::VT_CONTAINER, container); - } - explicit TabItemOptionBuilder(flatbuffers::FlatBufferBuilder& _fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } - TabItemOptionBuilder& operator=(const TabItemOptionBuilder&); - flatbuffers::Offset Finish() - { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset(end); - return o; - } +struct TabItemOptionBuilder { + typedef TabItemOption Table; + flatbuffers::FlatBufferBuilder &fbb_; + flatbuffers::uoffset_t start_; + void add_header(flatbuffers::Offset header) { + fbb_.AddOffset(TabItemOption::VT_HEADER, header); + } + void add_container(flatbuffers::Offset container) { + fbb_.AddOffset(TabItemOption::VT_CONTAINER, container); + } + explicit TabItemOptionBuilder(flatbuffers::FlatBufferBuilder &_fbb) + : fbb_(_fbb) { + start_ = fbb_.StartTable(); + } + flatbuffers::Offset Finish() { + const auto end = fbb_.EndTable(start_); + auto o = flatbuffers::Offset(end); + return o; + } }; -inline flatbuffers::Offset CreateTabItemOption(flatbuffers::FlatBufferBuilder& _fbb, - flatbuffers::Offset header = 0, - flatbuffers::Offset container = 0) -{ - TabItemOptionBuilder builder_(_fbb); - builder_.add_container(container); - builder_.add_header(header); - return builder_.Finish(); +inline flatbuffers::Offset CreateTabItemOption( + flatbuffers::FlatBufferBuilder &_fbb, + flatbuffers::Offset header = 0, + flatbuffers::Offset container = 0) { + TabItemOptionBuilder builder_(_fbb); + builder_.add_container(container); + builder_.add_header(header); + return builder_.Finish(); } -inline const flatbuffers::TabControlOption* GetTabControlOption(const void* buf) -{ - return flatbuffers::GetRoot(buf); +inline const flatbuffers::TabControlOption *GetTabControlOption(const void *buf) { + return flatbuffers::GetRoot(buf); } -inline const flatbuffers::TabControlOption* GetSizePrefixedTabControlOption(const void* buf) -{ - return flatbuffers::GetSizePrefixedRoot(buf); +inline const flatbuffers::TabControlOption *GetSizePrefixedTabControlOption(const void *buf) { + return flatbuffers::GetSizePrefixedRoot(buf); } -inline bool VerifyTabControlOptionBuffer(flatbuffers::Verifier& verifier) -{ - return verifier.VerifyBuffer(nullptr); +inline bool VerifyTabControlOptionBuffer( + flatbuffers::Verifier &verifier) { + return verifier.VerifyBuffer(nullptr); } -inline bool VerifySizePrefixedTabControlOptionBuffer(flatbuffers::Verifier& verifier) -{ - return verifier.VerifySizePrefixedBuffer(nullptr); +inline bool VerifySizePrefixedTabControlOptionBuffer( + flatbuffers::Verifier &verifier) { + return verifier.VerifySizePrefixedBuffer(nullptr); } -inline void FinishTabControlOptionBuffer(flatbuffers::FlatBufferBuilder& fbb, - flatbuffers::Offset root) -{ - fbb.Finish(root); +inline void FinishTabControlOptionBuffer( + flatbuffers::FlatBufferBuilder &fbb, + flatbuffers::Offset root) { + fbb.Finish(root); } -inline void FinishSizePrefixedTabControlOptionBuffer(flatbuffers::FlatBufferBuilder& fbb, - flatbuffers::Offset root) -{ - fbb.FinishSizePrefixed(root); +inline void FinishSizePrefixedTabControlOptionBuffer( + flatbuffers::FlatBufferBuilder &fbb, + flatbuffers::Offset root) { + fbb.FinishSizePrefixed(root); } } // namespace flatbuffers diff --git a/thirdparty/README.md b/thirdparty/README.md index 2181da6c01..bb1106dfa1 100644 --- a/thirdparty/README.md +++ b/thirdparty/README.md @@ -6,7 +6,7 @@ ## astc - [![Upstream](https://img.shields.io/github/v/release/ARM-software/astc-encoder?label=Upstream)](https://github.com/ARM-software/astc-encoder) -- Version: 4.0.0 +- Version: 4.1.0 - License: Apache-2.0 ## Box2D @@ -52,12 +52,12 @@ ## flatbuffers - [![Upstream](https://img.shields.io/github/v/release/google/flatbuffers?label=Upstream)](https://github.com/google/flatbuffers) -- Version: 2.0.0 +- Version: 2.0.8 - License: Apache-2.0 ## {fmt} - [![Upstream](https://img.shields.io/github/v/release/fmtlib/fmt?label=Upstream)](https://github.com/fmtlib/fmt) -- Version: 9.0.0 +- Version: 9.1.0 - License: MIT ## FreeType @@ -102,7 +102,7 @@ ## llhttp - [![Upstream](https://img.shields.io/github/v/release/nodejs/llhttp?label=Upstream)](https://github.com/nodejs/llhttp) -- Version: 6.0.7 +- Version: 6.0.9 - License: MIT ## lua @@ -216,7 +216,7 @@ ## webp - [![Upstream](https://img.shields.io/github/v/tag/webmproject/libwebp?label=Upstream)](https://github.com/webmproject/libwebp) -- Version: 1.2.2 +- Version: 1.2.4 - License: Google Inc ## xsbase diff --git a/thirdparty/astc/astcenc_compress_symbolic.cpp b/thirdparty/astc/astcenc_compress_symbolic.cpp index e38d8a61c8..9c701b8675 100644 --- a/thirdparty/astc/astcenc_compress_symbolic.cpp +++ b/thirdparty/astc/astcenc_compress_symbolic.cpp @@ -1171,7 +1171,7 @@ static float prepare_block_statistics( /* See header for documentation. */ void compress_block( - const astcenc_context& ctx, + const astcenc_contexti& ctx, const image_block& blk, physical_compressed_block& pcb, compression_working_buffers& tmpbuf) diff --git a/thirdparty/astc/astcenc_compute_variance.cpp b/thirdparty/astc/astcenc_compute_variance.cpp index 02281a19fd..48a4af8cef 100644 --- a/thirdparty/astc/astcenc_compute_variance.cpp +++ b/thirdparty/astc/astcenc_compute_variance.cpp @@ -99,17 +99,9 @@ static void brent_kung_prefix_sum( } while (lc_stride > 2); } -/** - * @brief Compute averages for a pixel region. - * - * The routine computes both in a single pass, using a summed-area table to decouple the running - * time from the averaging/variance kernel size. - * - * @param[out] ctx The compressor context storing the output data. - * @param arg The input parameter structure. - */ -static void compute_pixel_region_variance( - astcenc_context& ctx, +/* See header for documentation. */ +void compute_pixel_region_variance( + astcenc_contexti& ctx, const pixel_region_args& arg ) { // Unpack the memory structure into local variables @@ -427,57 +419,6 @@ static void compute_pixel_region_variance( } } -void compute_averages( - astcenc_context& ctx, - const avg_args &ag -) { - pixel_region_args arg = ag.arg; - arg.work_memory = new vfloat4[ag.work_memory_size]; - - int size_x = ag.img_size_x; - int size_y = ag.img_size_y; - int size_z = ag.img_size_z; - - int step_xy = ag.blk_size_xy; - int step_z = ag.blk_size_z; - - int y_tasks = (size_y + step_xy - 1) / step_xy; - - // All threads run this processing loop until there is no work remaining - while (true) - { - unsigned int count; - unsigned int base = ctx.manage_avg.get_task_assignment(16, count); - if (!count) - { - break; - } - - for (unsigned int i = base; i < base + count; i++) - { - int z = (i / (y_tasks)) * step_z; - int y = (i - (z * y_tasks)) * step_xy; - - arg.size_z = astc::min(step_z, size_z - z); - arg.offset_z = z; - - arg.size_y = astc::min(step_xy, size_y - y); - arg.offset_y = y; - - for (int x = 0; x < size_x; x += step_xy) - { - arg.size_x = astc::min(step_xy, size_x - x); - arg.offset_x = x; - compute_pixel_region_variance(ctx, arg); - } - } - - ctx.manage_avg.complete_task_assignment(count); - } - - delete[] arg.work_memory; -} - /* See header for documentation. */ unsigned int init_compute_averages( const astcenc_image& img, diff --git a/thirdparty/astc/astcenc_entry.cpp b/thirdparty/astc/astcenc_entry.cpp index 5f6bd28ab3..32403c7bb4 100644 --- a/thirdparty/astc/astcenc_entry.cpp +++ b/thirdparty/astc/astcenc_entry.cpp @@ -24,7 +24,7 @@ #include #include "astcenc.h" -#include "astcenc_internal.h" +#include "astcenc_internal_entry.h" #include "astcenc_diagnostic_trace.h" /** @@ -701,7 +701,8 @@ astcenc_error astcenc_context_alloc( } #endif - astcenc_context* ctx = new astcenc_context; + astcenc_context* ctxo = new astcenc_context; + astcenc_contexti* ctx = &ctxo->context; ctx->thread_count = thread_count; ctx->config = config; ctx->working_buffers = nullptr; @@ -746,7 +747,7 @@ astcenc_error astcenc_context_alloc( if (!ctx->working_buffers) { aligned_free(ctx->bsd); - delete ctx; + delete ctxo; *context = nullptr; return ASTCENC_ERR_OUT_OF_MEM; } @@ -765,7 +766,7 @@ astcenc_error astcenc_context_alloc( trace_add_data("block_z", config.block_z); #endif - *context = ctx; + *context = ctxo; #if !defined(ASTCENC_DECOMPRESS_ONLY) prepare_angular_tables(); @@ -776,16 +777,17 @@ astcenc_error astcenc_context_alloc( /* See header dor documentation. */ void astcenc_context_free( - astcenc_context* ctx + astcenc_context* ctxo ) { - if (ctx) + if (ctxo) { + astcenc_contexti* ctx = &ctxo->context; aligned_free(ctx->working_buffers); aligned_free(ctx->bsd); #if defined(ASTCENC_DIAGNOSTICS) delete ctx->trace_log; #endif - delete ctx; + delete ctxo; } } @@ -794,19 +796,20 @@ void astcenc_context_free( /** * @brief Compress an image, after any preflight has completed. * - * @param[out] ctx The compressor context. + * @param[out] ctxo The compressor context. * @param thread_index The thread index. * @param image The intput image. * @param swizzle The input swizzle. * @param[out] buffer The output array for the compressed data. */ static void compress_image( - astcenc_context& ctx, + astcenc_context& ctxo, unsigned int thread_index, const astcenc_image& image, const astcenc_swizzle& swizzle, uint8_t* buffer ) { + astcenc_contexti& ctx = ctxo.context; const block_size_descriptor& bsd = *ctx.bsd; astcenc_profile decode_mode = ctx.config.profile; @@ -839,7 +842,7 @@ static void compress_image( auto& temp_buffers = ctx.working_buffers[thread_index]; // Only the first thread actually runs the initializer - ctx.manage_compress.init(block_count); + ctxo.manage_compress.init(block_count); // Determine if we can use an optimized load function bool needs_swz = (swizzle.r != ASTCENC_SWZ_R) || (swizzle.g != ASTCENC_SWZ_G) || @@ -861,7 +864,7 @@ static void compress_image( while (true) { unsigned int count; - unsigned int base = ctx.manage_compress.get_task_assignment(16, count); + unsigned int base = ctxo.manage_compress.get_task_assignment(16, count); if (!count) { break; @@ -945,15 +948,77 @@ static void compress_image( compress_block(ctx, blk, *pcb, temp_buffers); } - ctx.manage_compress.complete_task_assignment(count); + ctxo.manage_compress.complete_task_assignment(count); } } +/** + * @brief Compute regional averages in an image. + * + * This function can be called by multiple threads, but only after a single + * thread calls the setup function @c init_compute_averages(). + * + * Results are written back into @c img->input_alpha_averages. + * + * @param[out] ctx The context. + * @param ag The average and variance arguments created during setup. + */ +static void compute_averages( + astcenc_context& ctx, + const avg_args &ag +) { + pixel_region_args arg = ag.arg; + arg.work_memory = new vfloat4[ag.work_memory_size]; + + int size_x = ag.img_size_x; + int size_y = ag.img_size_y; + int size_z = ag.img_size_z; + + int step_xy = ag.blk_size_xy; + int step_z = ag.blk_size_z; + + int y_tasks = (size_y + step_xy - 1) / step_xy; + + // All threads run this processing loop until there is no work remaining + while (true) + { + unsigned int count; + unsigned int base = ctx.manage_avg.get_task_assignment(16, count); + if (!count) + { + break; + } + + for (unsigned int i = base; i < base + count; i++) + { + int z = (i / (y_tasks)) * step_z; + int y = (i - (z * y_tasks)) * step_xy; + + arg.size_z = astc::min(step_z, size_z - z); + arg.offset_z = z; + + arg.size_y = astc::min(step_xy, size_y - y); + arg.offset_y = y; + + for (int x = 0; x < size_x; x += step_xy) + { + arg.size_x = astc::min(step_xy, size_x - x); + arg.offset_x = x; + compute_pixel_region_variance(ctx.context, arg); + } + } + + ctx.manage_avg.complete_task_assignment(count); + } + + delete[] arg.work_memory; +} + #endif /* See header for documentation. */ astcenc_error astcenc_compress_image( - astcenc_context* ctx, + astcenc_context* ctxo, astcenc_image* imagep, const astcenc_swizzle* swizzle, uint8_t* data_out, @@ -961,7 +1026,7 @@ astcenc_error astcenc_compress_image( unsigned int thread_index ) { #if defined(ASTCENC_DECOMPRESS_ONLY) - (void)ctx; + (void)ctxo; (void)imagep; (void)swizzle; (void)data_out; @@ -969,6 +1034,7 @@ astcenc_error astcenc_compress_image( (void)thread_index; return ASTCENC_ERR_BAD_CONTEXT; #else + astcenc_contexti* ctx = &ctxo->context; astcenc_error status; astcenc_image& image = *imagep; @@ -1006,7 +1072,7 @@ astcenc_error astcenc_compress_image( // If context thread count is one then implicitly reset if (ctx->thread_count == 1) { - astcenc_compress_reset(ctx); + astcenc_compress_reset(ctxo); } if (ctx->config.a_scale_radius != 0) @@ -1024,19 +1090,19 @@ astcenc_error astcenc_compress_image( }; // Only the first thread actually runs the initializer - ctx->manage_avg.init(init_avg); + ctxo->manage_avg.init(init_avg); // All threads will enter this function and dynamically grab work - compute_averages(*ctx, ctx->avg_preprocess_args); + compute_averages(*ctxo, ctx->avg_preprocess_args); } // Wait for compute_averages to complete before compressing - ctx->manage_avg.wait(); + ctxo->manage_avg.wait(); - compress_image(*ctx, thread_index, image, *swizzle, data_out); + compress_image(*ctxo, thread_index, image, *swizzle, data_out); // Wait for compress to complete before freeing memory - ctx->manage_compress.wait(); + ctxo->manage_compress.wait(); auto term_compress = [ctx]() { delete[] ctx->input_alpha_averages; @@ -1044,7 +1110,7 @@ astcenc_error astcenc_compress_image( }; // Only the first thread to arrive actually runs the term - ctx->manage_compress.term(term_compress); + ctxo->manage_compress.term(term_compress); return ASTCENC_SUCCESS; #endif @@ -1052,26 +1118,27 @@ astcenc_error astcenc_compress_image( /* See header for documentation. */ astcenc_error astcenc_compress_reset( - astcenc_context* ctx + astcenc_context* ctxo ) { #if defined(ASTCENC_DECOMPRESS_ONLY) - (void)ctx; + (void)ctxo; return ASTCENC_ERR_BAD_CONTEXT; #else + astcenc_contexti* ctx = &ctxo->context; if (ctx->config.flags & ASTCENC_FLG_DECOMPRESS_ONLY) { return ASTCENC_ERR_BAD_CONTEXT; } - ctx->manage_avg.reset(); - ctx->manage_compress.reset(); + ctxo->manage_avg.reset(); + ctxo->manage_compress.reset(); return ASTCENC_SUCCESS; #endif } /* See header for documentation. */ astcenc_error astcenc_decompress_image( - astcenc_context* ctx, + astcenc_context* ctxo, const uint8_t* data, size_t data_len, astcenc_image* image_outp, @@ -1080,6 +1147,7 @@ astcenc_error astcenc_decompress_image( ) { astcenc_error status; astcenc_image& image_out = *image_outp; + astcenc_contexti* ctx = &ctxo->context; // Today this doesn't matter (working set on stack) but might in future ... if (thread_index >= ctx->thread_count) @@ -1117,17 +1185,17 @@ astcenc_error astcenc_decompress_image( // If context thread count is one then implicitly reset if (ctx->thread_count == 1) { - astcenc_decompress_reset(ctx); + astcenc_decompress_reset(ctxo); } // Only the first thread actually runs the initializer - ctx->manage_decompress.init(zblocks * yblocks * xblocks); + ctxo->manage_decompress.init(zblocks * yblocks * xblocks); // All threads run this processing loop until there is no work remaining while (true) { unsigned int count; - unsigned int base = ctx->manage_decompress.get_task_assignment(128, count); + unsigned int base = ctxo->manage_decompress.get_task_assignment(128, count); if (!count) { break; @@ -1157,7 +1225,7 @@ astcenc_error astcenc_decompress_image( x * block_x, y * block_y, z * block_z, *swizzle); } - ctx->manage_decompress.complete_task_assignment(count); + ctxo->manage_decompress.complete_task_assignment(count); } return ASTCENC_SUCCESS; @@ -1165,24 +1233,26 @@ astcenc_error astcenc_decompress_image( /* See header for documentation. */ astcenc_error astcenc_decompress_reset( - astcenc_context* ctx + astcenc_context* ctxo ) { - ctx->manage_decompress.reset(); + ctxo->manage_decompress.reset(); return ASTCENC_SUCCESS; } /* See header for documentation. */ astcenc_error astcenc_get_block_info( - astcenc_context* ctx, + astcenc_context* ctxo, const uint8_t data[16], astcenc_block_info* info ) { #if defined(ASTCENC_DECOMPRESS_ONLY) - (void)ctx; + (void)ctxo; (void)data; (void)info; return ASTCENC_ERR_BAD_CONTEXT; #else + astcenc_contexti* ctx = &ctxo->context; + // Decode the compressed data into a symbolic form const physical_compressed_block&pcb = *reinterpret_cast(data); symbolic_compressed_block scb; diff --git a/thirdparty/astc/astcenc_internal.h b/thirdparty/astc/astcenc_internal.h index 63c3b85915..5eb17a1e1a 100644 --- a/thirdparty/astc/astcenc_internal.h +++ b/thirdparty/astc/astcenc_internal.h @@ -23,15 +23,12 @@ #define ASTCENC_INTERNAL_INCLUDED #include -#include #include #include -#include +#if defined(ASTCENC_DIAGNOSTICS) + #include +#endif #include -#include -#include -#include -#include #include "astcenc.h" #include "astcenc_mathlib.h" @@ -161,223 +158,6 @@ static_assert((WEIGHTS_MAX_BLOCK_MODES % ASTCENC_SIMD_WIDTH) == 0, "WEIGHTS_MAX_BLOCK_MODES must be multiple of ASTCENC_SIMD_WIDTH"); -/* ============================================================================ - Parallel execution control -============================================================================ */ - -/** - * @brief A simple counter-based manager for parallel task execution. - * - * The task processing execution consists of: - * - * * A single-threaded init stage. - * * A multi-threaded processing stage. - * * A condition variable so threads can wait for processing completion. - * - * The init stage will be executed by the first thread to arrive in the critical section, there is - * no main thread in the thread pool. - * - * The processing stage uses dynamic dispatch to assign task tickets to threads on an on-demand - * basis. Threads may each therefore executed different numbers of tasks, depending on their - * processing complexity. The task queue and the task tickets are just counters; the caller must map - * these integers to an actual processing partition in a specific problem domain. - * - * The exit wait condition is needed to ensure processing has finished before a worker thread can - * progress to the next stage of the pipeline. Specifically a worker may exit the processing stage - * because there are no new tasks to assign to it while other worker threads are still processing. - * Calling @c wait() will ensure that all other worker have finished before the thread can proceed. - * - * The basic usage model: - * - * // --------- From single-threaded code --------- - * - * // Reset the tracker state - * manager->reset() - * - * // --------- From multi-threaded code --------- - * - * // Run the stage init; only first thread actually runs the lambda - * manager->init() - * - * do - * { - * // Request a task assignment - * uint task_count; - * uint base_index = manager->get_tasks(, task_count); - * - * // Process any tasks we were given (task_count <= granule size) - * if (task_count) - * { - * // Run the user task processing code for N tasks here - * ... - * - * // Flag these tasks as complete - * manager->complete_tasks(task_count); - * } - * } while (task_count); - * - * // Wait for all threads to complete tasks before progressing - * manager->wait() - * - * // Run the stage term; only first thread actually runs the lambda - * manager->term() - */ -class ParallelManager -{ -private: - /** @brief Lock used for critical section and condition synchronization. */ - std::mutex m_lock; - - /** @brief True if the stage init() step has been executed. */ - bool m_init_done; - - /** @brief True if the stage term() step has been executed. */ - bool m_term_done; - - /** @brief Condition variable for tracking stage processing completion. */ - std::condition_variable m_complete; - - /** @brief Number of tasks started, but not necessarily finished. */ - std::atomic m_start_count; - - /** @brief Number of tasks finished. */ - unsigned int m_done_count; - - /** @brief Number of tasks that need to be processed. */ - unsigned int m_task_count; - -public: - /** @brief Create a new ParallelManager. */ - ParallelManager() - { - reset(); - } - - /** - * @brief Reset the tracker for a new processing batch. - * - * This must be called from single-threaded code before starting the multi-threaded processing - * operations. - */ - void reset() - { - m_init_done = false; - m_term_done = false; - m_start_count = 0; - m_done_count = 0; - m_task_count = 0; - } - - /** - * @brief Trigger the pipeline stage init step. - * - * This can be called from multi-threaded code. The first thread to hit this will process the - * initialization. Other threads will block and wait for it to complete. - * - * @param init_func Callable which executes the stage initialization. It must return the - * total number of tasks in the stage. - */ - void init(std::function init_func) - { - std::lock_guard lck(m_lock); - if (!m_init_done) - { - m_task_count = init_func(); - m_init_done = true; - } - } - - /** - * @brief Trigger the pipeline stage init step. - * - * This can be called from multi-threaded code. The first thread to hit this will process the - * initialization. Other threads will block and wait for it to complete. - * - * @param task_count Total number of tasks needing processing. - */ - void init(unsigned int task_count) - { - std::lock_guard lck(m_lock); - if (!m_init_done) - { - m_task_count = task_count; - m_init_done = true; - } - } - - /** - * @brief Request a task assignment. - * - * Assign up to @c granule tasks to the caller for processing. - * - * @param granule Maximum number of tasks that can be assigned. - * @param[out] count Actual number of tasks assigned, or zero if no tasks were assigned. - * - * @return Task index of the first assigned task; assigned tasks increment from this. - */ - unsigned int get_task_assignment(unsigned int granule, unsigned int& count) - { - unsigned int base = m_start_count.fetch_add(granule, std::memory_order_relaxed); - if (base >= m_task_count) - { - count = 0; - return 0; - } - - count = astc::min(m_task_count - base, granule); - return base; - } - - /** - * @brief Complete a task assignment. - * - * Mark @c count tasks as complete. This will notify all threads blocked on @c wait() if this - * completes the processing of the stage. - * - * @param count The number of completed tasks. - */ - void complete_task_assignment(unsigned int count) - { - // Note: m_done_count cannot use an atomic without the mutex; this has a race between the - // update here and the wait() for other threads - std::unique_lock lck(m_lock); - this->m_done_count += count; - if (m_done_count == m_task_count) - { - lck.unlock(); - m_complete.notify_all(); - } - } - - /** - * @brief Wait for stage processing to complete. - */ - void wait() - { - std::unique_lock lck(m_lock); - m_complete.wait(lck, [this]{ return m_done_count == m_task_count; }); - } - - /** - * @brief Trigger the pipeline stage term step. - * - * This can be called from multi-threaded code. The first thread to hit this will process the - * work pool termination. Caller must have called @c wait() prior to calling this function to - * ensure that processing is complete. - * - * @param term_func Callable which executes the stage termination. - */ - void term(std::function term_func) - { - std::lock_guard lck(m_lock); - if (!m_term_done) - { - term_func(); - m_term_done = true; - } - } -}; - /* ============================================================================ Commonly used data structures ============================================================================ */ @@ -1432,7 +1212,7 @@ class TraceLog; /** * @brief The astcenc compression context. */ -struct astcenc_context +struct astcenc_contexti { /** @brief The configuration this context was created with. */ astcenc_config config; @@ -1458,17 +1238,8 @@ struct astcenc_context #if !defined(ASTCENC_DECOMPRESS_ONLY) /** @brief The pixel region and variance worker arguments. */ avg_args avg_preprocess_args; - - /** @brief The parallel manager for averages computation. */ - ParallelManager manage_avg; - - /** @brief The parallel manager for compression. */ - ParallelManager manage_compress; #endif - /** @brief The parallel manager for decompression. */ - ParallelManager manage_decompress; - #if defined(ASTCENC_DIAGNOSTICS) /** * @brief The diagnostic trace logger. @@ -1809,20 +1580,17 @@ unsigned int init_compute_averages( avg_args& ag); /** - * @brief Compute regional averages in an image. + * @brief Compute averages for a pixel region. * - * This function can be called by multiple threads, but only after a single - * thread calls the setup function @c init_compute_averages(). + * The routine computes both in a single pass, using a summed-area table to decouple the running + * time from the averaging/variance kernel size. * - * Results are written back into @c img->input_alpha_averages. - * - * @param[out] ctx The context. - * @param ag The average and variance arguments created during setup. + * @param[out] ctx The compressor context storing the output data. + * @param arg The input parameter structure. */ -void compute_averages( - astcenc_context& ctx, - const avg_args& ag); - +void compute_pixel_region_variance( + astcenc_contexti& ctx, + const pixel_region_args& arg); /** * @brief Load a single image block from the input image. * @@ -2222,7 +1990,7 @@ void compute_angular_endpoints_2planes( * @param[out] tmpbuf Preallocated scratch buffers for the compressor. */ void compress_block( - const astcenc_context& ctx, + const astcenc_contexti& ctx, const image_block& blk, physical_compressed_block& pcb, compression_working_buffers& tmpbuf); diff --git a/thirdparty/astc/astcenc_internal_entry.h b/thirdparty/astc/astcenc_internal_entry.h new file mode 100644 index 0000000000..4e8794547a --- /dev/null +++ b/thirdparty/astc/astcenc_internal_entry.h @@ -0,0 +1,273 @@ +// SPDX-License-Identifier: Apache-2.0 +// ---------------------------------------------------------------------------- +// Copyright 2011-2022 Arm Limited +// +// 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. +// ---------------------------------------------------------------------------- + +/** + * @brief Functions and data declarations for the outer context. + * + * The outer context includes thread-pool management, which is slower to + * compile due to increased use of C++ stdlib. The inner context used in the + * majority of the codec library does not include this. + */ + +#ifndef ASTCENC_INTERNAL_ENTRY_INCLUDED +#define ASTCENC_INTERNAL_ENTRY_INCLUDED + +#include +#include +#include +#include + +#include "astcenc_internal.h" + +/* ============================================================================ + Parallel execution control +============================================================================ */ + +/** + * @brief A simple counter-based manager for parallel task execution. + * + * The task processing execution consists of: + * + * * A single-threaded init stage. + * * A multi-threaded processing stage. + * * A condition variable so threads can wait for processing completion. + * + * The init stage will be executed by the first thread to arrive in the critical section, there is + * no main thread in the thread pool. + * + * The processing stage uses dynamic dispatch to assign task tickets to threads on an on-demand + * basis. Threads may each therefore executed different numbers of tasks, depending on their + * processing complexity. The task queue and the task tickets are just counters; the caller must map + * these integers to an actual processing partition in a specific problem domain. + * + * The exit wait condition is needed to ensure processing has finished before a worker thread can + * progress to the next stage of the pipeline. Specifically a worker may exit the processing stage + * because there are no new tasks to assign to it while other worker threads are still processing. + * Calling @c wait() will ensure that all other worker have finished before the thread can proceed. + * + * The basic usage model: + * + * // --------- From single-threaded code --------- + * + * // Reset the tracker state + * manager->reset() + * + * // --------- From multi-threaded code --------- + * + * // Run the stage init; only first thread actually runs the lambda + * manager->init() + * + * do + * { + * // Request a task assignment + * uint task_count; + * uint base_index = manager->get_tasks(, task_count); + * + * // Process any tasks we were given (task_count <= granule size) + * if (task_count) + * { + * // Run the user task processing code for N tasks here + * ... + * + * // Flag these tasks as complete + * manager->complete_tasks(task_count); + * } + * } while (task_count); + * + * // Wait for all threads to complete tasks before progressing + * manager->wait() + * + * // Run the stage term; only first thread actually runs the lambda + * manager->term() + */ +class ParallelManager +{ +private: + /** @brief Lock used for critical section and condition synchronization. */ + std::mutex m_lock; + + /** @brief True if the stage init() step has been executed. */ + bool m_init_done; + + /** @brief True if the stage term() step has been executed. */ + bool m_term_done; + + /** @brief Condition variable for tracking stage processing completion. */ + std::condition_variable m_complete; + + /** @brief Number of tasks started, but not necessarily finished. */ + std::atomic m_start_count; + + /** @brief Number of tasks finished. */ + unsigned int m_done_count; + + /** @brief Number of tasks that need to be processed. */ + unsigned int m_task_count; + +public: + /** @brief Create a new ParallelManager. */ + ParallelManager() + { + reset(); + } + + /** + * @brief Reset the tracker for a new processing batch. + * + * This must be called from single-threaded code before starting the multi-threaded processing + * operations. + */ + void reset() + { + m_init_done = false; + m_term_done = false; + m_start_count = 0; + m_done_count = 0; + m_task_count = 0; + } + + /** + * @brief Trigger the pipeline stage init step. + * + * This can be called from multi-threaded code. The first thread to hit this will process the + * initialization. Other threads will block and wait for it to complete. + * + * @param init_func Callable which executes the stage initialization. It must return the + * total number of tasks in the stage. + */ + void init(std::function init_func) + { + std::lock_guard lck(m_lock); + if (!m_init_done) + { + m_task_count = init_func(); + m_init_done = true; + } + } + + /** + * @brief Trigger the pipeline stage init step. + * + * This can be called from multi-threaded code. The first thread to hit this will process the + * initialization. Other threads will block and wait for it to complete. + * + * @param task_count Total number of tasks needing processing. + */ + void init(unsigned int task_count) + { + std::lock_guard lck(m_lock); + if (!m_init_done) + { + m_task_count = task_count; + m_init_done = true; + } + } + + /** + * @brief Request a task assignment. + * + * Assign up to @c granule tasks to the caller for processing. + * + * @param granule Maximum number of tasks that can be assigned. + * @param[out] count Actual number of tasks assigned, or zero if no tasks were assigned. + * + * @return Task index of the first assigned task; assigned tasks increment from this. + */ + unsigned int get_task_assignment(unsigned int granule, unsigned int& count) + { + unsigned int base = m_start_count.fetch_add(granule, std::memory_order_relaxed); + if (base >= m_task_count) + { + count = 0; + return 0; + } + + count = astc::min(m_task_count - base, granule); + return base; + } + + /** + * @brief Complete a task assignment. + * + * Mark @c count tasks as complete. This will notify all threads blocked on @c wait() if this + * completes the processing of the stage. + * + * @param count The number of completed tasks. + */ + void complete_task_assignment(unsigned int count) + { + // Note: m_done_count cannot use an atomic without the mutex; this has a race between the + // update here and the wait() for other threads + std::unique_lock lck(m_lock); + this->m_done_count += count; + if (m_done_count == m_task_count) + { + lck.unlock(); + m_complete.notify_all(); + } + } + + /** + * @brief Wait for stage processing to complete. + */ + void wait() + { + std::unique_lock lck(m_lock); + m_complete.wait(lck, [this]{ return m_done_count == m_task_count; }); + } + + /** + * @brief Trigger the pipeline stage term step. + * + * This can be called from multi-threaded code. The first thread to hit this will process the + * work pool termination. Caller must have called @c wait() prior to calling this function to + * ensure that processing is complete. + * + * @param term_func Callable which executes the stage termination. + */ + void term(std::function term_func) + { + std::lock_guard lck(m_lock); + if (!m_term_done) + { + term_func(); + m_term_done = true; + } + } +}; + +/** + * @brief The astcenc compression context. + */ +struct astcenc_context +{ + /** @brief The context internal state. */ + astcenc_contexti context; + +#if !defined(ASTCENC_DECOMPRESS_ONLY) + /** @brief The parallel manager for averages computation. */ + ParallelManager manage_avg; + + /** @brief The parallel manager for compression. */ + ParallelManager manage_compress; +#endif + + /** @brief The parallel manager for decompression. */ + ParallelManager manage_decompress; +}; + +#endif diff --git a/thirdparty/astc/astcenc_pick_best_endpoint_format.cpp b/thirdparty/astc/astcenc_pick_best_endpoint_format.cpp index eba5f62657..c140b6ba31 100644 --- a/thirdparty/astc/astcenc_pick_best_endpoint_format.cpp +++ b/thirdparty/astc/astcenc_pick_best_endpoint_format.cpp @@ -517,7 +517,7 @@ static void compute_color_error_for_every_integer_count_and_quant_level( best_error[i][1] = ERROR_CALC_DEFAULT; best_error[i][0] = ERROR_CALC_DEFAULT; - format_of_choice[i][3] = encode_hdr_alpha ? FMT_HDR_RGBA : FMT_HDR_RGB_LDR_ALPHA; + format_of_choice[i][3] = static_cast(encode_hdr_alpha ? FMT_HDR_RGBA : FMT_HDR_RGB_LDR_ALPHA); format_of_choice[i][2] = FMT_HDR_RGB; format_of_choice[i][1] = FMT_HDR_RGB_SCALE; format_of_choice[i][0] = FMT_HDR_LUMINANCE_LARGE_RANGE; @@ -537,7 +537,7 @@ static void compute_color_error_for_every_integer_count_and_quant_level( float full_hdr_rgba_error = rgba_quantization_error + rgb_range_error + alpha_range_error; best_error[i][3] = full_hdr_rgba_error; - format_of_choice[i][3] = encode_hdr_alpha ? FMT_HDR_RGBA : FMT_HDR_RGB_LDR_ALPHA; + format_of_choice[i][3] = static_cast(encode_hdr_alpha ? FMT_HDR_RGBA : FMT_HDR_RGB_LDR_ALPHA); // For 6 integers, we have one HDR-RGB encoding float full_hdr_rgb_error = (rgb_quantization_error * mode11mult) + rgb_range_error + eci.alpha_drop_error; diff --git a/thirdparty/astc/astcenc_vecmathlib_neon_4.h b/thirdparty/astc/astcenc_vecmathlib_neon_4.h index df1ea17515..554bb37d22 100644 --- a/thirdparty/astc/astcenc_vecmathlib_neon_4.h +++ b/thirdparty/astc/astcenc_vecmathlib_neon_4.h @@ -351,7 +351,7 @@ struct vmask4 */ template ASTCENC_SIMD_INLINE uint32_t lane() const { - return vgetq_lane_s32(m, l); + return vgetq_lane_u32(m, l); } /** @@ -968,13 +968,15 @@ ASTCENC_SIMD_INLINE void vtable_prepare( */ ASTCENC_SIMD_INLINE vint4 vtable_8bt_32bi(vint4 t0, vint4 idx) { - int8x16_t table { t0.m }; + int8x16_t table { + vreinterpretq_s8_s32(t0.m) + }; - // Set index byte MSB to 1 for unused bytes so shuffle returns zero + // Set index byte above max index for unused bytes so table lookup returns zero int32x4_t idx_masked = vorrq_s32(idx.m, vdupq_n_s32(0xFFFFFF00)); - int8x16_t idx_bytes = vreinterpretq_u8_s32(idx_masked); + uint8x16_t idx_bytes = vreinterpretq_u8_s32(idx_masked); - return vint4(vqtbl1q_s8(table, idx_bytes)); + return vint4(vreinterpretq_s32_s8(vqtbl1q_s8(table, idx_bytes))); } /** @@ -982,13 +984,16 @@ ASTCENC_SIMD_INLINE vint4 vtable_8bt_32bi(vint4 t0, vint4 idx) */ ASTCENC_SIMD_INLINE vint4 vtable_8bt_32bi(vint4 t0, vint4 t1, vint4 idx) { - int8x16x2_t table { t0.m, t1.m }; + int8x16x2_t table { + vreinterpretq_s8_s32(t0.m), + vreinterpretq_s8_s32(t1.m) + }; - // Set index byte MSB to 1 for unused bytes so shuffle returns zero + // Set index byte above max index for unused bytes so table lookup returns zero int32x4_t idx_masked = vorrq_s32(idx.m, vdupq_n_s32(0xFFFFFF00)); - int8x16_t idx_bytes = vreinterpretq_u8_s32(idx_masked); + uint8x16_t idx_bytes = vreinterpretq_u8_s32(idx_masked); - return vint4(vqtbl2q_s8(table, idx_bytes)); + return vint4(vreinterpretq_s32_s8(vqtbl2q_s8(table, idx_bytes))); } /** @@ -996,13 +1001,18 @@ ASTCENC_SIMD_INLINE vint4 vtable_8bt_32bi(vint4 t0, vint4 t1, vint4 idx) */ ASTCENC_SIMD_INLINE vint4 vtable_8bt_32bi(vint4 t0, vint4 t1, vint4 t2, vint4 t3, vint4 idx) { - int8x16x4_t table { t0.m, t1.m, t2.m, t3.m }; + int8x16x4_t table { + vreinterpretq_s8_s32(t0.m), + vreinterpretq_s8_s32(t1.m), + vreinterpretq_s8_s32(t2.m), + vreinterpretq_s8_s32(t3.m) + }; - // Set index byte MSB to 1 for unused bytes so shuffle returns zero + // Set index byte above max index for unused bytes so table lookup returns zero int32x4_t idx_masked = vorrq_s32(idx.m, vdupq_n_s32(0xFFFFFF00)); - int8x16_t idx_bytes = vreinterpretq_u8_s32(idx_masked); + uint8x16_t idx_bytes = vreinterpretq_u8_s32(idx_masked); - return vint4(vqtbl4q_s8(table, idx_bytes)); + return vint4(vreinterpretq_s32_s8(vqtbl4q_s8(table, idx_bytes))); } /** diff --git a/thirdparty/astc/astcenc_vecmathlib_sse_4.h b/thirdparty/astc/astcenc_vecmathlib_sse_4.h index 4ffe39a441..2ec26435e1 100644 --- a/thirdparty/astc/astcenc_vecmathlib_sse_4.h +++ b/thirdparty/astc/astcenc_vecmathlib_sse_4.h @@ -363,6 +363,14 @@ struct vmask4 m = _mm_castsi128_ps(mask.m); } + /** + * @brief Get the scalar value of a single lane. + */ + template ASTCENC_SIMD_INLINE float lane() const + { + return _mm_cvtss_f32(_mm_shuffle_ps(m, m, l)); + } + /** * @brief The vector ... */ @@ -1192,7 +1200,27 @@ ASTCENC_SIMD_INLINE void store_lanes_masked(int* base, vint4 data, vmask4 mask) #if ASTCENC_AVX >= 2 _mm_maskstore_epi32(base, _mm_castps_si128(mask.m), data.m); #else - _mm_maskmoveu_si128(data.m, _mm_castps_si128(mask.m), reinterpret_cast(base)); + // Note - we cannot use _mm_maskmoveu_si128 as the underlying hardware doesn't guarantee + // fault suppression on masked lanes so we can get page faults at the end of an image. + if (mask.lane<3>() != 0.0f) + { + store(data, base); + } + else if(mask.lane<2>() != 0.0f) + { + base[0] = data.lane<0>(); + base[1] = data.lane<1>(); + base[2] = data.lane<2>(); + } + else if(mask.lane<1>() != 0.0f) + { + base[0] = data.lane<0>(); + base[1] = data.lane<1>(); + } + else if(mask.lane<0>() != 0.0f) + { + base[0] = data.lane<0>(); + } #endif } diff --git a/thirdparty/flatbuffers/allocator.h b/thirdparty/flatbuffers/allocator.h new file mode 100644 index 0000000000..f4ef22db45 --- /dev/null +++ b/thirdparty/flatbuffers/allocator.h @@ -0,0 +1,68 @@ +/* + * Copyright 2021 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. + */ + +#ifndef FLATBUFFERS_ALLOCATOR_H_ +#define FLATBUFFERS_ALLOCATOR_H_ + +#include "flatbuffers/base.h" + +namespace flatbuffers { + +// Allocator interface. This is flatbuffers-specific and meant only for +// `vector_downward` usage. +class Allocator { + public: + virtual ~Allocator() {} + + // Allocate `size` bytes of memory. + virtual uint8_t *allocate(size_t size) = 0; + + // Deallocate `size` bytes of memory at `p` allocated by this allocator. + virtual void deallocate(uint8_t *p, size_t size) = 0; + + // Reallocate `new_size` bytes of memory, replacing the old region of size + // `old_size` at `p`. In contrast to a normal realloc, this grows downwards, + // and is intended specifcally for `vector_downward` use. + // `in_use_back` and `in_use_front` indicate how much of `old_size` is + // actually in use at each end, and needs to be copied. + virtual uint8_t *reallocate_downward(uint8_t *old_p, size_t old_size, + size_t new_size, size_t in_use_back, + size_t in_use_front) { + FLATBUFFERS_ASSERT(new_size > old_size); // vector_downward only grows + uint8_t *new_p = allocate(new_size); + memcpy_downward(old_p, old_size, new_p, new_size, in_use_back, + in_use_front); + deallocate(old_p, old_size); + return new_p; + } + + protected: + // Called by `reallocate_downward` to copy memory from `old_p` of `old_size` + // to `new_p` of `new_size`. Only memory of size `in_use_front` and + // `in_use_back` will be copied from the front and back of the old memory + // allocation. + void memcpy_downward(uint8_t *old_p, size_t old_size, uint8_t *new_p, + size_t new_size, size_t in_use_back, + size_t in_use_front) { + memcpy(new_p + new_size - in_use_back, old_p + old_size - in_use_back, + in_use_back); + memcpy(new_p, old_p, in_use_front); + } +}; + +} // namespace flatbuffers + +#endif // FLATBUFFERS_ALLOCATOR_H_ \ No newline at end of file diff --git a/thirdparty/flatbuffers/array.h b/thirdparty/flatbuffers/array.h new file mode 100644 index 0000000000..d4b73fc9e1 --- /dev/null +++ b/thirdparty/flatbuffers/array.h @@ -0,0 +1,243 @@ +/* + * Copyright 2021 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. + */ + +#ifndef FLATBUFFERS_ARRAY_H_ +#define FLATBUFFERS_ARRAY_H_ + +#include "flatbuffers/base.h" +#include "flatbuffers/stl_emulation.h" +#include "flatbuffers/vector.h" + +namespace flatbuffers { + +// This is used as a helper type for accessing arrays. +template class Array { + // Array can carry only POD data types (scalars or structs). + typedef typename flatbuffers::bool_constant::value> + scalar_tag; + typedef + typename flatbuffers::conditional::type + IndirectHelperType; + + public: + typedef uint16_t size_type; + typedef typename IndirectHelper::return_type return_type; + typedef VectorIterator const_iterator; + typedef VectorReverseIterator const_reverse_iterator; + + // If T is a LE-scalar or a struct (!scalar_tag::value). + static FLATBUFFERS_CONSTEXPR bool is_span_observable = + (scalar_tag::value && (FLATBUFFERS_LITTLEENDIAN || sizeof(T) == 1)) || + !scalar_tag::value; + + FLATBUFFERS_CONSTEXPR uint16_t size() const { return length; } + + return_type Get(uoffset_t i) const { + FLATBUFFERS_ASSERT(i < size()); + return IndirectHelper::Read(Data(), i); + } + + return_type operator[](uoffset_t i) const { return Get(i); } + + // If this is a Vector of enums, T will be its storage type, not the enum + // type. This function makes it convenient to retrieve value with enum + // type E. + template E GetEnum(uoffset_t i) const { + return static_cast(Get(i)); + } + + const_iterator begin() const { return const_iterator(Data(), 0); } + const_iterator end() const { return const_iterator(Data(), size()); } + + const_reverse_iterator rbegin() const { + return const_reverse_iterator(end()); + } + const_reverse_iterator rend() const { + return const_reverse_iterator(begin()); + } + + const_iterator cbegin() const { return begin(); } + const_iterator cend() const { return end(); } + + const_reverse_iterator crbegin() const { return rbegin(); } + const_reverse_iterator crend() const { return rend(); } + + // Get a mutable pointer to elements inside this array. + // This method used to mutate arrays of structs followed by a @p Mutate + // operation. For primitive types use @p Mutate directly. + // @warning Assignments and reads to/from the dereferenced pointer are not + // automatically converted to the correct endianness. + typename flatbuffers::conditional::type + GetMutablePointer(uoffset_t i) const { + FLATBUFFERS_ASSERT(i < size()); + return const_cast(&data()[i]); + } + + // Change elements if you have a non-const pointer to this object. + void Mutate(uoffset_t i, const T &val) { MutateImpl(scalar_tag(), i, val); } + + // The raw data in little endian format. Use with care. + const uint8_t *Data() const { return data_; } + + uint8_t *Data() { return data_; } + + // Similarly, but typed, much like std::vector::data + const T *data() const { return reinterpret_cast(Data()); } + T *data() { return reinterpret_cast(Data()); } + + // Copy data from a span with endian conversion. + // If this Array and the span overlap, the behavior is undefined. + void CopyFromSpan(flatbuffers::span src) { + const auto p1 = reinterpret_cast(src.data()); + const auto p2 = Data(); + FLATBUFFERS_ASSERT(!(p1 >= p2 && p1 < (p2 + length)) && + !(p2 >= p1 && p2 < (p1 + length))); + (void)p1; + (void)p2; + CopyFromSpanImpl(flatbuffers::bool_constant(), src); + } + + protected: + void MutateImpl(flatbuffers::true_type, uoffset_t i, const T &val) { + FLATBUFFERS_ASSERT(i < size()); + WriteScalar(data() + i, val); + } + + void MutateImpl(flatbuffers::false_type, uoffset_t i, const T &val) { + *(GetMutablePointer(i)) = val; + } + + void CopyFromSpanImpl(flatbuffers::true_type, + flatbuffers::span src) { + // Use std::memcpy() instead of std::copy() to avoid performance degradation + // due to aliasing if T is char or unsigned char. + // The size is known at compile time, so memcpy would be inlined. + std::memcpy(data(), src.data(), length * sizeof(T)); + } + + // Copy data from flatbuffers::span with endian conversion. + void CopyFromSpanImpl(flatbuffers::false_type, + flatbuffers::span src) { + for (size_type k = 0; k < length; k++) { Mutate(k, src[k]); } + } + + // This class is only used to access pre-existing data. Don't ever + // try to construct these manually. + // 'constexpr' allows us to use 'size()' at compile time. + // @note Must not use 'FLATBUFFERS_CONSTEXPR' here, as const is not allowed on + // a constructor. +#if defined(__cpp_constexpr) + constexpr Array(); +#else + Array(); +#endif + + uint8_t data_[length * sizeof(T)]; + + private: + // This class is a pointer. Copying will therefore create an invalid object. + // Private and unimplemented copy constructor. + Array(const Array &); + Array &operator=(const Array &); +}; + +// Specialization for Array[struct] with access using Offset pointer. +// This specialization used by idl_gen_text.cpp. +template class Array, length> { + static_assert(flatbuffers::is_same::value, "unexpected type T"); + + public: + typedef const void *return_type; + + const uint8_t *Data() const { return data_; } + + // Make idl_gen_text.cpp::PrintContainer happy. + return_type operator[](uoffset_t) const { + FLATBUFFERS_ASSERT(false); + return nullptr; + } + + private: + // This class is only used to access pre-existing data. + Array(); + Array(const Array &); + Array &operator=(const Array &); + + uint8_t data_[1]; +}; + +template +FLATBUFFERS_CONSTEXPR_CPP11 flatbuffers::span make_span(Array &arr) + FLATBUFFERS_NOEXCEPT { + static_assert( + Array::is_span_observable, + "wrong type U, only plain struct, LE-scalar, or byte types are allowed"); + return span(arr.data(), N); +} + +template +FLATBUFFERS_CONSTEXPR_CPP11 flatbuffers::span make_span( + const Array &arr) FLATBUFFERS_NOEXCEPT { + static_assert( + Array::is_span_observable, + "wrong type U, only plain struct, LE-scalar, or byte types are allowed"); + return span(arr.data(), N); +} + +template +FLATBUFFERS_CONSTEXPR_CPP11 flatbuffers::span +make_bytes_span(Array &arr) FLATBUFFERS_NOEXCEPT { + static_assert(Array::is_span_observable, + "internal error, Array might hold only scalars or structs"); + return span(arr.Data(), sizeof(U) * N); +} + +template +FLATBUFFERS_CONSTEXPR_CPP11 flatbuffers::span +make_bytes_span(const Array &arr) FLATBUFFERS_NOEXCEPT { + static_assert(Array::is_span_observable, + "internal error, Array might hold only scalars or structs"); + return span(arr.Data(), sizeof(U) * N); +} + +// Cast a raw T[length] to a raw flatbuffers::Array +// without endian conversion. Use with care. +// TODO: move these Cast-methods to `internal` namespace. +template +Array &CastToArray(T (&arr)[length]) { + return *reinterpret_cast *>(arr); +} + +template +const Array &CastToArray(const T (&arr)[length]) { + return *reinterpret_cast *>(arr); +} + +template +Array &CastToArrayOfEnum(T (&arr)[length]) { + static_assert(sizeof(E) == sizeof(T), "invalid enum type E"); + return *reinterpret_cast *>(arr); +} + +template +const Array &CastToArrayOfEnum(const T (&arr)[length]) { + static_assert(sizeof(E) == sizeof(T), "invalid enum type E"); + return *reinterpret_cast *>(arr); +} + +} // namespace flatbuffers + +#endif // FLATBUFFERS_ARRAY_H_ diff --git a/thirdparty/flatbuffers/base.h b/thirdparty/flatbuffers/base.h index cc9e22dccc..870a811c17 100644 --- a/thirdparty/flatbuffers/base.h +++ b/thirdparty/flatbuffers/base.h @@ -50,10 +50,6 @@ #include #endif -#ifdef _STLPORT_VERSION - #define FLATBUFFERS_CPP98_STL -#endif - #ifdef __ANDROID__ #include #endif @@ -144,7 +140,7 @@ #define FLATBUFFERS_VERSION_MAJOR 2 #define FLATBUFFERS_VERSION_MINOR 0 -#define FLATBUFFERS_VERSION_REVISION 0 +#define FLATBUFFERS_VERSION_REVISION 8 #define FLATBUFFERS_STRING_EXPAND(X) #X #define FLATBUFFERS_STRING(X) FLATBUFFERS_STRING_EXPAND(X) namespace flatbuffers { @@ -247,6 +243,11 @@ namespace flatbuffers { #endif // __has_include #endif // !FLATBUFFERS_HAS_STRING_VIEW +#ifndef FLATBUFFERS_GENERAL_HEAP_ALLOC_OK + // Allow heap allocations to be used + #define FLATBUFFERS_GENERAL_HEAP_ALLOC_OK 1 +#endif // !FLATBUFFERS_GENERAL_HEAP_ALLOC_OK + #ifndef FLATBUFFERS_HAS_NEW_STRTOD // Modern (C++11) strtod and strtof functions are available for use. // 1) nan/inf strings as argument of strtod; @@ -259,9 +260,12 @@ namespace flatbuffers { #endif // !FLATBUFFERS_HAS_NEW_STRTOD #ifndef FLATBUFFERS_LOCALE_INDEPENDENT - // Enable locale independent functions {strtof_l, strtod_l,strtoll_l, strtoull_l}. - #if ((defined(_MSC_VER) && _MSC_VER >= 1800) || \ - (defined(_XOPEN_VERSION) && (_XOPEN_VERSION>=700)) && (!defined(__ANDROID_API__) || (defined(__ANDROID_API__) && (__ANDROID_API__>=21)))) + // Enable locale independent functions {strtof_l, strtod_l,strtoll_l, + // strtoull_l}. + #if (defined(_MSC_VER) && _MSC_VER >= 1800) || \ + (defined(__ANDROID_API__) && __ANDROID_API__>= 21) || \ + (defined(_XOPEN_VERSION) && (_XOPEN_VERSION >= 700)) && \ + (!defined(__Fuchsia__) && !defined(__ANDROID_API__)) #define FLATBUFFERS_LOCALE_INDEPENDENT 1 #else #define FLATBUFFERS_LOCALE_INDEPENDENT 0 @@ -269,14 +273,14 @@ namespace flatbuffers { #endif // !FLATBUFFERS_LOCALE_INDEPENDENT // Suppress Undefined Behavior Sanitizer (recoverable only). Usage: -// - __supress_ubsan__("undefined") -// - __supress_ubsan__("signed-integer-overflow") +// - __suppress_ubsan__("undefined") +// - __suppress_ubsan__("signed-integer-overflow") #if defined(__clang__) && (__clang_major__ > 3 || (__clang_major__ == 3 && __clang_minor__ >=7)) - #define __supress_ubsan__(type) __attribute__((no_sanitize(type))) + #define __suppress_ubsan__(type) __attribute__((no_sanitize(type))) #elif defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ >= 409) - #define __supress_ubsan__(type) __attribute__((no_sanitize_undefined)) + #define __suppress_ubsan__(type) __attribute__((no_sanitize_undefined)) #else - #define __supress_ubsan__(type) + #define __suppress_ubsan__(type) #endif // This is constexpr function used for checking compile-time constants. @@ -289,7 +293,7 @@ template FLATBUFFERS_CONSTEXPR inline bool IsConstTrue(T t) { #if ((__cplusplus >= 201703L) \ || (defined(_MSVC_LANG) && (_MSVC_LANG >= 201703L))) // All attributes unknown to an implementation are ignored without causing an error. - #define FLATBUFFERS_ATTRIBUTE(attr) [[attr]] + #define FLATBUFFERS_ATTRIBUTE(attr) attr #define FLATBUFFERS_FALLTHROUGH() [[fallthrough]] #else @@ -327,8 +331,20 @@ typedef uintmax_t largest_scalar_t; // In 32bits, this evaluates to 2GB - 1 #define FLATBUFFERS_MAX_BUFFER_SIZE ((1ULL << (sizeof(::flatbuffers::soffset_t) * 8 - 1)) - 1) +// The minimum size buffer that can be a valid flatbuffer. +// Includes the offset to the root table (uoffset_t), the offset to the vtable +// of the root table (soffset_t), the size of the vtable (uint16_t), and the +// size of the referring table (uint16_t). +#define FLATBUFFERS_MIN_BUFFER_SIZE sizeof(uoffset_t) + sizeof(soffset_t) + \ + sizeof(uint16_t) + sizeof(uint16_t) + // We support aligning the contents of buffers up to this size. -#define FLATBUFFERS_MAX_ALIGNMENT 16 +#ifndef FLATBUFFERS_MAX_ALIGNMENT + #define FLATBUFFERS_MAX_ALIGNMENT 32 +#endif + +/// @brief The length of a FlatBuffer file header. +static const size_t kFileIdentifierLength = 4; inline bool VerifyAlignmentRequirements(size_t align, size_t min_align = 1) { return (min_align <= align) && (align <= (FLATBUFFERS_MAX_ALIGNMENT)) && @@ -397,7 +413,7 @@ template T EndianScalar(T t) { template // UBSAN: C++ aliasing type rules, see std::bit_cast<> for details. -__supress_ubsan__("alignment") +__suppress_ubsan__("alignment") T ReadScalar(const void *p) { return EndianScalar(*reinterpret_cast(p)); } @@ -411,13 +427,13 @@ T ReadScalar(const void *p) { template // UBSAN: C++ aliasing type rules, see std::bit_cast<> for details. -__supress_ubsan__("alignment") +__suppress_ubsan__("alignment") void WriteScalar(void *p, T t) { *reinterpret_cast(p) = EndianScalar(t); } template struct Offset; -template __supress_ubsan__("alignment") void WriteScalar(void *p, Offset t) { +template __suppress_ubsan__("alignment") void WriteScalar(void *p, Offset t) { *reinterpret_cast(p) = EndianScalar(t.o); } @@ -428,10 +444,43 @@ template __supress_ubsan__("alignment") void WriteScalar(void *p, Of // Computes how many bytes you'd have to pad to be able to write an // "scalar_size" scalar if the buffer had grown to "buf_size" (downwards in // memory). -__supress_ubsan__("unsigned-integer-overflow") +__suppress_ubsan__("unsigned-integer-overflow") inline size_t PaddingBytes(size_t buf_size, size_t scalar_size) { return ((~buf_size) + 1) & (scalar_size - 1); } +// Generic 'operator==' with conditional specialisations. +// T e - new value of a scalar field. +// T def - default of scalar (is known at compile-time). +template inline bool IsTheSameAs(T e, T def) { return e == def; } + +#if defined(FLATBUFFERS_NAN_DEFAULTS) && \ + defined(FLATBUFFERS_HAS_NEW_STRTOD) && (FLATBUFFERS_HAS_NEW_STRTOD > 0) +// Like `operator==(e, def)` with weak NaN if T=(float|double). +template inline bool IsFloatTheSameAs(T e, T def) { + return (e == def) || ((def != def) && (e != e)); +} +template<> inline bool IsTheSameAs(float e, float def) { + return IsFloatTheSameAs(e, def); +} +template<> inline bool IsTheSameAs(double e, double def) { + return IsFloatTheSameAs(e, def); +} +#endif + +// Check 'v' is out of closed range [low; high]. +// Workaround for GCC warning [-Werror=type-limits]: +// comparison is always true due to limited range of data type. +template +inline bool IsOutRange(const T &v, const T &low, const T &high) { + return (v < low) || (high < v); +} + +// Check 'v' is in closed range [low; high]. +template +inline bool IsInRange(const T &v, const T &low, const T &high) { + return !IsOutRange(v, low, high); +} + } // namespace flatbuffers #endif // FLATBUFFERS_BASE_H_ diff --git a/thirdparty/flatbuffers/buffer.h b/thirdparty/flatbuffers/buffer.h new file mode 100644 index 0000000000..ca005f7157 --- /dev/null +++ b/thirdparty/flatbuffers/buffer.h @@ -0,0 +1,142 @@ +/* + * Copyright 2021 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. + */ + +#ifndef FLATBUFFERS_BUFFER_H_ +#define FLATBUFFERS_BUFFER_H_ + +#include "flatbuffers/base.h" + +namespace flatbuffers { + +// Wrapper for uoffset_t to allow safe template specialization. +// Value is allowed to be 0 to indicate a null object (see e.g. AddOffset). +template struct Offset { + uoffset_t o; + Offset() : o(0) {} + Offset(uoffset_t _o) : o(_o) {} + Offset Union() const { return Offset(o); } + bool IsNull() const { return !o; } +}; + +inline void EndianCheck() { + int endiantest = 1; + // If this fails, see FLATBUFFERS_LITTLEENDIAN above. + FLATBUFFERS_ASSERT(*reinterpret_cast(&endiantest) == + FLATBUFFERS_LITTLEENDIAN); + (void)endiantest; +} + +template FLATBUFFERS_CONSTEXPR size_t AlignOf() { + // clang-format off + #ifdef _MSC_VER + return __alignof(T); + #else + #ifndef alignof + return __alignof__(T); + #else + return alignof(T); + #endif + #endif + // clang-format on +} + +// Lexicographically compare two strings (possibly containing nulls), and +// return true if the first is less than the second. +static inline bool StringLessThan(const char *a_data, uoffset_t a_size, + const char *b_data, uoffset_t b_size) { + const auto cmp = memcmp(a_data, b_data, (std::min)(a_size, b_size)); + return cmp == 0 ? a_size < b_size : cmp < 0; +} + +// When we read serialized data from memory, in the case of most scalars, +// we want to just read T, but in the case of Offset, we want to actually +// perform the indirection and return a pointer. +// The template specialization below does just that. +// It is wrapped in a struct since function templates can't overload on the +// return type like this. +// The typedef is for the convenience of callers of this function +// (avoiding the need for a trailing return decltype) +template struct IndirectHelper { + typedef T return_type; + typedef T mutable_return_type; + static const size_t element_stride = sizeof(T); + static return_type Read(const uint8_t *p, uoffset_t i) { + return EndianScalar((reinterpret_cast(p))[i]); + } +}; +template struct IndirectHelper> { + typedef const T *return_type; + typedef T *mutable_return_type; + static const size_t element_stride = sizeof(uoffset_t); + static return_type Read(const uint8_t *p, uoffset_t i) { + p += i * sizeof(uoffset_t); + return reinterpret_cast(p + ReadScalar(p)); + } +}; +template struct IndirectHelper { + typedef const T *return_type; + typedef T *mutable_return_type; + static const size_t element_stride = sizeof(T); + static return_type Read(const uint8_t *p, uoffset_t i) { + return reinterpret_cast(p + i * sizeof(T)); + } +}; + +/// @brief Get a pointer to the file_identifier section of the buffer. +/// @return Returns a const char pointer to the start of the file_identifier +/// characters in the buffer. The returned char * has length +/// 'flatbuffers::FlatBufferBuilder::kFileIdentifierLength'. +/// This function is UNDEFINED for FlatBuffers whose schema does not include +/// a file_identifier (likely points at padding or the start of a the root +/// vtable). +inline const char *GetBufferIdentifier(const void *buf, + bool size_prefixed = false) { + return reinterpret_cast(buf) + + ((size_prefixed) ? 2 * sizeof(uoffset_t) : sizeof(uoffset_t)); +} + +// Helper to see if the identifier in a buffer has the expected value. +inline bool BufferHasIdentifier(const void *buf, const char *identifier, + bool size_prefixed = false) { + return strncmp(GetBufferIdentifier(buf, size_prefixed), identifier, + flatbuffers::kFileIdentifierLength) == 0; +} + +/// @cond FLATBUFFERS_INTERNAL +// Helpers to get a typed pointer to the root object contained in the buffer. +template T *GetMutableRoot(void *buf) { + EndianCheck(); + return reinterpret_cast( + reinterpret_cast(buf) + + EndianScalar(*reinterpret_cast(buf))); +} + +template T *GetMutableSizePrefixedRoot(void *buf) { + return GetMutableRoot(reinterpret_cast(buf) + + sizeof(uoffset_t)); +} + +template const T *GetRoot(const void *buf) { + return GetMutableRoot(const_cast(buf)); +} + +template const T *GetSizePrefixedRoot(const void *buf) { + return GetRoot(reinterpret_cast(buf) + sizeof(uoffset_t)); +} + +} // namespace flatbuffers + +#endif // FLATBUFFERS_BUFFER_H_ \ No newline at end of file diff --git a/thirdparty/flatbuffers/buffer_ref.h b/thirdparty/flatbuffers/buffer_ref.h new file mode 100644 index 0000000000..ce30207330 --- /dev/null +++ b/thirdparty/flatbuffers/buffer_ref.h @@ -0,0 +1,53 @@ +/* + * Copyright 2021 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. + */ + +#ifndef FLATBUFFERS_BUFFER_REF_H_ +#define FLATBUFFERS_BUFFER_REF_H_ + +#include "flatbuffers/base.h" +#include "flatbuffers/verifier.h" + +namespace flatbuffers { + +// Convenient way to bundle a buffer and its length, to pass it around +// typed by its root. +// A BufferRef does not own its buffer. +struct BufferRefBase {}; // for std::is_base_of + +template struct BufferRef : BufferRefBase { + BufferRef() : buf(nullptr), len(0), must_free(false) {} + BufferRef(uint8_t *_buf, uoffset_t _len) + : buf(_buf), len(_len), must_free(false) {} + + ~BufferRef() { + if (must_free) free(buf); + } + + const T *GetRoot() const { return flatbuffers::GetRoot(buf); } + + bool Verify() { + Verifier verifier(buf, len); + return verifier.VerifyBuffer(nullptr); + } + + uint8_t *buf; + uoffset_t len; + bool must_free; +}; + +} // namespace flatbuffers + +#endif // FLATBUFFERS_BUFFER_REF_H_ \ No newline at end of file diff --git a/thirdparty/flatbuffers/default_allocator.h b/thirdparty/flatbuffers/default_allocator.h new file mode 100644 index 0000000000..8b173af11b --- /dev/null +++ b/thirdparty/flatbuffers/default_allocator.h @@ -0,0 +1,64 @@ +/* + * Copyright 2021 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. + */ + +#ifndef FLATBUFFERS_DEFAULT_ALLOCATOR_H_ +#define FLATBUFFERS_DEFAULT_ALLOCATOR_H_ + +#include "flatbuffers/allocator.h" +#include "flatbuffers/base.h" + +namespace flatbuffers { + +// DefaultAllocator uses new/delete to allocate memory regions +class DefaultAllocator : public Allocator { + public: + uint8_t *allocate(size_t size) FLATBUFFERS_OVERRIDE { + return new uint8_t[size]; + } + + void deallocate(uint8_t *p, size_t) FLATBUFFERS_OVERRIDE { delete[] p; } + + static void dealloc(void *p, size_t) { delete[] static_cast(p); } +}; + +// These functions allow for a null allocator to mean use the default allocator, +// as used by DetachedBuffer and vector_downward below. +// This is to avoid having a statically or dynamically allocated default +// allocator, or having to move it between the classes that may own it. +inline uint8_t *Allocate(Allocator *allocator, size_t size) { + return allocator ? allocator->allocate(size) + : DefaultAllocator().allocate(size); +} + +inline void Deallocate(Allocator *allocator, uint8_t *p, size_t size) { + if (allocator) + allocator->deallocate(p, size); + else + DefaultAllocator().deallocate(p, size); +} + +inline uint8_t *ReallocateDownward(Allocator *allocator, uint8_t *old_p, + size_t old_size, size_t new_size, + size_t in_use_back, size_t in_use_front) { + return allocator ? allocator->reallocate_downward(old_p, old_size, new_size, + in_use_back, in_use_front) + : DefaultAllocator().reallocate_downward( + old_p, old_size, new_size, in_use_back, in_use_front); +} + +} // namespace flatbuffers + +#endif // FLATBUFFERS_DEFAULT_ALLOCATOR_H_ \ No newline at end of file diff --git a/thirdparty/flatbuffers/detached_buffer.h b/thirdparty/flatbuffers/detached_buffer.h new file mode 100644 index 0000000000..760a088453 --- /dev/null +++ b/thirdparty/flatbuffers/detached_buffer.h @@ -0,0 +1,114 @@ +/* + * Copyright 2021 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. + */ + +#ifndef FLATBUFFERS_DETACHED_BUFFER_H_ +#define FLATBUFFERS_DETACHED_BUFFER_H_ + +#include "flatbuffers/allocator.h" +#include "flatbuffers/base.h" +#include "flatbuffers/default_allocator.h" + +namespace flatbuffers { + +// DetachedBuffer is a finished flatbuffer memory region, detached from its +// builder. The original memory region and allocator are also stored so that +// the DetachedBuffer can manage the memory lifetime. +class DetachedBuffer { + public: + DetachedBuffer() + : allocator_(nullptr), + own_allocator_(false), + buf_(nullptr), + reserved_(0), + cur_(nullptr), + size_(0) {} + + DetachedBuffer(Allocator *allocator, bool own_allocator, uint8_t *buf, + size_t reserved, uint8_t *cur, size_t sz) + : allocator_(allocator), + own_allocator_(own_allocator), + buf_(buf), + reserved_(reserved), + cur_(cur), + size_(sz) {} + + DetachedBuffer(DetachedBuffer &&other) + : allocator_(other.allocator_), + own_allocator_(other.own_allocator_), + buf_(other.buf_), + reserved_(other.reserved_), + cur_(other.cur_), + size_(other.size_) { + other.reset(); + } + + DetachedBuffer &operator=(DetachedBuffer &&other) { + if (this == &other) return *this; + + destroy(); + + allocator_ = other.allocator_; + own_allocator_ = other.own_allocator_; + buf_ = other.buf_; + reserved_ = other.reserved_; + cur_ = other.cur_; + size_ = other.size_; + + other.reset(); + + return *this; + } + + ~DetachedBuffer() { destroy(); } + + const uint8_t *data() const { return cur_; } + + uint8_t *data() { return cur_; } + + size_t size() const { return size_; } + + // These may change access mode, leave these at end of public section + FLATBUFFERS_DELETE_FUNC(DetachedBuffer(const DetachedBuffer &other)); + FLATBUFFERS_DELETE_FUNC( + DetachedBuffer &operator=(const DetachedBuffer &other)); + + protected: + Allocator *allocator_; + bool own_allocator_; + uint8_t *buf_; + size_t reserved_; + uint8_t *cur_; + size_t size_; + + inline void destroy() { + if (buf_) Deallocate(allocator_, buf_, reserved_); + if (own_allocator_ && allocator_) { delete allocator_; } + reset(); + } + + inline void reset() { + allocator_ = nullptr; + own_allocator_ = false; + buf_ = nullptr; + reserved_ = 0; + cur_ = nullptr; + size_ = 0; + } +}; + +} // namespace flatbuffers + +#endif // FLATBUFFERS_DETACHED_BUFFER_H_ diff --git a/thirdparty/flatbuffers/flatbuffer_builder.h b/thirdparty/flatbuffers/flatbuffer_builder.h new file mode 100644 index 0000000000..f9432338f0 --- /dev/null +++ b/thirdparty/flatbuffers/flatbuffer_builder.h @@ -0,0 +1,1214 @@ +/* + * Copyright 2021 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. + */ + +#ifndef FLATBUFFERS_FLATBUFFER_BUILDER_H_ +#define FLATBUFFERS_FLATBUFFER_BUILDER_H_ + +#include +#include + +#include "flatbuffers/allocator.h" +#include "flatbuffers/array.h" +#include "flatbuffers/base.h" +#include "flatbuffers/buffer_ref.h" +#include "flatbuffers/default_allocator.h" +#include "flatbuffers/detached_buffer.h" +#include "flatbuffers/stl_emulation.h" +#include "flatbuffers/string.h" +#include "flatbuffers/struct.h" +#include "flatbuffers/table.h" +#include "flatbuffers/vector.h" +#include "flatbuffers/vector_downward.h" +#include "flatbuffers/verifier.h" + +namespace flatbuffers { + +// Converts a Field ID to a virtual table offset. +inline voffset_t FieldIndexToOffset(voffset_t field_id) { + // Should correspond to what EndTable() below builds up. + const int fixed_fields = 2; // Vtable size and Object Size. + return static_cast((field_id + fixed_fields) * sizeof(voffset_t)); +} + +template> +const T *data(const std::vector &v) { + // Eventually the returned pointer gets passed down to memcpy, so + // we need it to be non-null to avoid undefined behavior. + static uint8_t t; + return v.empty() ? reinterpret_cast(&t) : &v.front(); +} +template> +T *data(std::vector &v) { + // Eventually the returned pointer gets passed down to memcpy, so + // we need it to be non-null to avoid undefined behavior. + static uint8_t t; + return v.empty() ? reinterpret_cast(&t) : &v.front(); +} + +/// @addtogroup flatbuffers_cpp_api +/// @{ +/// @class FlatBufferBuilder +/// @brief Helper class to hold data needed in creation of a FlatBuffer. +/// To serialize data, you typically call one of the `Create*()` functions in +/// the generated code, which in turn call a sequence of `StartTable`/ +/// `PushElement`/`AddElement`/`EndTable`, or the builtin `CreateString`/ +/// `CreateVector` functions. Do this is depth-first order to build up a tree to +/// the root. `Finish()` wraps up the buffer ready for transport. +class FlatBufferBuilder { + public: + /// @brief Default constructor for FlatBufferBuilder. + /// @param[in] initial_size The initial size of the buffer, in bytes. Defaults + /// to `1024`. + /// @param[in] allocator An `Allocator` to use. If null will use + /// `DefaultAllocator`. + /// @param[in] own_allocator Whether the builder/vector should own the + /// allocator. Defaults to / `false`. + /// @param[in] buffer_minalign Force the buffer to be aligned to the given + /// minimum alignment upon reallocation. Only needed if you intend to store + /// types with custom alignment AND you wish to read the buffer in-place + /// directly after creation. + explicit FlatBufferBuilder( + size_t initial_size = 1024, Allocator *allocator = nullptr, + bool own_allocator = false, + size_t buffer_minalign = AlignOf()) + : buf_(initial_size, allocator, own_allocator, buffer_minalign), + num_field_loc(0), + max_voffset_(0), + nested(false), + finished(false), + minalign_(1), + force_defaults_(false), + dedup_vtables_(true), + string_pool(nullptr) { + EndianCheck(); + } + + /// @brief Move constructor for FlatBufferBuilder. + FlatBufferBuilder(FlatBufferBuilder &&other) + : buf_(1024, nullptr, false, AlignOf()), + num_field_loc(0), + max_voffset_(0), + nested(false), + finished(false), + minalign_(1), + force_defaults_(false), + dedup_vtables_(true), + string_pool(nullptr) { + EndianCheck(); + // Default construct and swap idiom. + // Lack of delegating constructors in vs2010 makes it more verbose than + // needed. + Swap(other); + } + + /// @brief Move assignment operator for FlatBufferBuilder. + FlatBufferBuilder &operator=(FlatBufferBuilder &&other) { + // Move construct a temporary and swap idiom + FlatBufferBuilder temp(std::move(other)); + Swap(temp); + return *this; + } + + void Swap(FlatBufferBuilder &other) { + using std::swap; + buf_.swap(other.buf_); + swap(num_field_loc, other.num_field_loc); + swap(max_voffset_, other.max_voffset_); + swap(nested, other.nested); + swap(finished, other.finished); + swap(minalign_, other.minalign_); + swap(force_defaults_, other.force_defaults_); + swap(dedup_vtables_, other.dedup_vtables_); + swap(string_pool, other.string_pool); + } + + ~FlatBufferBuilder() { + if (string_pool) delete string_pool; + } + + void Reset() { + Clear(); // clear builder state + buf_.reset(); // deallocate buffer + } + + /// @brief Reset all the state in this FlatBufferBuilder so it can be reused + /// to construct another buffer. + void Clear() { + ClearOffsets(); + buf_.clear(); + nested = false; + finished = false; + minalign_ = 1; + if (string_pool) string_pool->clear(); + } + + /// @brief The current size of the serialized buffer, counting from the end. + /// @return Returns an `uoffset_t` with the current size of the buffer. + uoffset_t GetSize() const { return buf_.size(); } + + /// @brief Get the serialized buffer (after you call `Finish()`). + /// @return Returns an `uint8_t` pointer to the FlatBuffer data inside the + /// buffer. + uint8_t *GetBufferPointer() const { + Finished(); + return buf_.data(); + } + + /// @brief Get the serialized buffer (after you call `Finish()`) as a span. + /// @return Returns a constructed flatbuffers::span that is a view over the + /// FlatBuffer data inside the buffer. + flatbuffers::span GetBufferSpan() const { + Finished(); + return flatbuffers::span(buf_.data(), buf_.size()); + } + + /// @brief Get a pointer to an unfinished buffer. + /// @return Returns a `uint8_t` pointer to the unfinished buffer. + uint8_t *GetCurrentBufferPointer() const { return buf_.data(); } + + /// @brief Get the released pointer to the serialized buffer. + /// @warning Do NOT attempt to use this FlatBufferBuilder afterwards! + /// @return A `FlatBuffer` that owns the buffer and its allocator and + /// behaves similar to a `unique_ptr` with a deleter. + FLATBUFFERS_ATTRIBUTE([[deprecated("use Release() instead")]]) + DetachedBuffer ReleaseBufferPointer() { + Finished(); + return buf_.release(); + } + + /// @brief Get the released DetachedBuffer. + /// @return A `DetachedBuffer` that owns the buffer and its allocator. + DetachedBuffer Release() { + Finished(); + return buf_.release(); + } + + /// @brief Get the released pointer to the serialized buffer. + /// @param size The size of the memory block containing + /// the serialized `FlatBuffer`. + /// @param offset The offset from the released pointer where the finished + /// `FlatBuffer` starts. + /// @return A raw pointer to the start of the memory block containing + /// the serialized `FlatBuffer`. + /// @remark If the allocator is owned, it gets deleted when the destructor is + /// called.. + uint8_t *ReleaseRaw(size_t &size, size_t &offset) { + Finished(); + return buf_.release_raw(size, offset); + } + + /// @brief get the minimum alignment this buffer needs to be accessed + /// properly. This is only known once all elements have been written (after + /// you call Finish()). You can use this information if you need to embed + /// a FlatBuffer in some other buffer, such that you can later read it + /// without first having to copy it into its own buffer. + size_t GetBufferMinAlignment() const { + Finished(); + return minalign_; + } + + /// @cond FLATBUFFERS_INTERNAL + void Finished() const { + // If you get this assert, you're attempting to get access a buffer + // which hasn't been finished yet. Be sure to call + // FlatBufferBuilder::Finish with your root table. + // If you really need to access an unfinished buffer, call + // GetCurrentBufferPointer instead. + FLATBUFFERS_ASSERT(finished); + } + /// @endcond + + /// @brief In order to save space, fields that are set to their default value + /// don't get serialized into the buffer. + /// @param[in] fd When set to `true`, always serializes default values that + /// are set. Optional fields which are not set explicitly, will still not be + /// serialized. + void ForceDefaults(bool fd) { force_defaults_ = fd; } + + /// @brief By default vtables are deduped in order to save space. + /// @param[in] dedup When set to `true`, dedup vtables. + void DedupVtables(bool dedup) { dedup_vtables_ = dedup; } + + /// @cond FLATBUFFERS_INTERNAL + void Pad(size_t num_bytes) { buf_.fill(num_bytes); } + + void TrackMinAlign(size_t elem_size) { + if (elem_size > minalign_) minalign_ = elem_size; + } + + void Align(size_t elem_size) { + TrackMinAlign(elem_size); + buf_.fill(PaddingBytes(buf_.size(), elem_size)); + } + + void PushFlatBuffer(const uint8_t *bytes, size_t size) { + PushBytes(bytes, size); + finished = true; + } + + void PushBytes(const uint8_t *bytes, size_t size) { buf_.push(bytes, size); } + + void PopBytes(size_t amount) { buf_.pop(amount); } + + template void AssertScalarT() { + // The code assumes power of 2 sizes and endian-swap-ability. + static_assert(flatbuffers::is_scalar::value, "T must be a scalar type"); + } + + // Write a single aligned scalar to the buffer + template uoffset_t PushElement(T element) { + AssertScalarT(); + Align(sizeof(T)); + buf_.push_small(EndianScalar(element)); + return GetSize(); + } + + template uoffset_t PushElement(Offset off) { + // Special case for offsets: see ReferTo below. + return PushElement(ReferTo(off.o)); + } + + // When writing fields, we track where they are, so we can create correct + // vtables later. + void TrackField(voffset_t field, uoffset_t off) { + FieldLoc fl = { off, field }; + buf_.scratch_push_small(fl); + num_field_loc++; + if (field > max_voffset_) { max_voffset_ = field; } + } + + // Like PushElement, but additionally tracks the field this represents. + template void AddElement(voffset_t field, T e, T def) { + // We don't serialize values equal to the default. + if (IsTheSameAs(e, def) && !force_defaults_) return; + TrackField(field, PushElement(e)); + } + + template void AddElement(voffset_t field, T e) { + TrackField(field, PushElement(e)); + } + + template void AddOffset(voffset_t field, Offset off) { + if (off.IsNull()) return; // Don't store. + AddElement(field, ReferTo(off.o), static_cast(0)); + } + + template void AddStruct(voffset_t field, const T *structptr) { + if (!structptr) return; // Default, don't store. + Align(AlignOf()); + buf_.push_small(*structptr); + TrackField(field, GetSize()); + } + + void AddStructOffset(voffset_t field, uoffset_t off) { + TrackField(field, off); + } + + // Offsets initially are relative to the end of the buffer (downwards). + // This function converts them to be relative to the current location + // in the buffer (when stored here), pointing upwards. + uoffset_t ReferTo(uoffset_t off) { + // Align to ensure GetSize() below is correct. + Align(sizeof(uoffset_t)); + // Offset must refer to something already in buffer. + const uoffset_t size = GetSize(); + FLATBUFFERS_ASSERT(off && off <= size); + return size - off + static_cast(sizeof(uoffset_t)); + } + + void NotNested() { + // If you hit this, you're trying to construct a Table/Vector/String + // during the construction of its parent table (between the MyTableBuilder + // and table.Finish(). + // Move the creation of these sub-objects to above the MyTableBuilder to + // not get this assert. + // Ignoring this assert may appear to work in simple cases, but the reason + // it is here is that storing objects in-line may cause vtable offsets + // to not fit anymore. It also leads to vtable duplication. + FLATBUFFERS_ASSERT(!nested); + // If you hit this, fields were added outside the scope of a table. + FLATBUFFERS_ASSERT(!num_field_loc); + } + + // From generated code (or from the parser), we call StartTable/EndTable + // with a sequence of AddElement calls in between. + uoffset_t StartTable() { + NotNested(); + nested = true; + return GetSize(); + } + + // This finishes one serialized object by generating the vtable if it's a + // table, comparing it against existing vtables, and writing the + // resulting vtable offset. + uoffset_t EndTable(uoffset_t start) { + // If you get this assert, a corresponding StartTable wasn't called. + FLATBUFFERS_ASSERT(nested); + // Write the vtable offset, which is the start of any Table. + // We fill its value later. + auto vtableoffsetloc = PushElement(0); + // Write a vtable, which consists entirely of voffset_t elements. + // It starts with the number of offsets, followed by a type id, followed + // by the offsets themselves. In reverse: + // Include space for the last offset and ensure empty tables have a + // minimum size. + max_voffset_ = + (std::max)(static_cast(max_voffset_ + sizeof(voffset_t)), + FieldIndexToOffset(0)); + buf_.fill_big(max_voffset_); + auto table_object_size = vtableoffsetloc - start; + // Vtable use 16bit offsets. + FLATBUFFERS_ASSERT(table_object_size < 0x10000); + WriteScalar(buf_.data() + sizeof(voffset_t), + static_cast(table_object_size)); + WriteScalar(buf_.data(), max_voffset_); + // Write the offsets into the table + for (auto it = buf_.scratch_end() - num_field_loc * sizeof(FieldLoc); + it < buf_.scratch_end(); it += sizeof(FieldLoc)) { + auto field_location = reinterpret_cast(it); + auto pos = static_cast(vtableoffsetloc - field_location->off); + // If this asserts, it means you've set a field twice. + FLATBUFFERS_ASSERT( + !ReadScalar(buf_.data() + field_location->id)); + WriteScalar(buf_.data() + field_location->id, pos); + } + ClearOffsets(); + auto vt1 = reinterpret_cast(buf_.data()); + auto vt1_size = ReadScalar(vt1); + auto vt_use = GetSize(); + // See if we already have generated a vtable with this exact same + // layout before. If so, make it point to the old one, remove this one. + if (dedup_vtables_) { + for (auto it = buf_.scratch_data(); it < buf_.scratch_end(); + it += sizeof(uoffset_t)) { + auto vt_offset_ptr = reinterpret_cast(it); + auto vt2 = reinterpret_cast(buf_.data_at(*vt_offset_ptr)); + auto vt2_size = ReadScalar(vt2); + if (vt1_size != vt2_size || 0 != memcmp(vt2, vt1, vt1_size)) continue; + vt_use = *vt_offset_ptr; + buf_.pop(GetSize() - vtableoffsetloc); + break; + } + } + // If this is a new vtable, remember it. + if (vt_use == GetSize()) { buf_.scratch_push_small(vt_use); } + // Fill the vtable offset we created above. + // The offset points from the beginning of the object to where the + // vtable is stored. + // Offsets default direction is downward in memory for future format + // flexibility (storing all vtables at the start of the file). + WriteScalar(buf_.data_at(vtableoffsetloc), + static_cast(vt_use) - + static_cast(vtableoffsetloc)); + + nested = false; + return vtableoffsetloc; + } + + FLATBUFFERS_ATTRIBUTE([[deprecated("call the version above instead")]]) + uoffset_t EndTable(uoffset_t start, voffset_t /*numfields*/) { + return EndTable(start); + } + + // This checks a required field has been set in a given table that has + // just been constructed. + template void Required(Offset table, voffset_t field); + + uoffset_t StartStruct(size_t alignment) { + Align(alignment); + return GetSize(); + } + + uoffset_t EndStruct() { return GetSize(); } + + void ClearOffsets() { + buf_.scratch_pop(num_field_loc * sizeof(FieldLoc)); + num_field_loc = 0; + max_voffset_ = 0; + } + + // Aligns such that when "len" bytes are written, an object can be written + // after it with "alignment" without padding. + void PreAlign(size_t len, size_t alignment) { + if (len == 0) return; + TrackMinAlign(alignment); + buf_.fill(PaddingBytes(GetSize() + len, alignment)); + } + template void PreAlign(size_t len) { + AssertScalarT(); + PreAlign(len, sizeof(T)); + } + /// @endcond + + /// @brief Store a string in the buffer, which can contain any binary data. + /// @param[in] str A const char pointer to the data to be stored as a string. + /// @param[in] len The number of bytes that should be stored from `str`. + /// @return Returns the offset in the buffer where the string starts. + Offset CreateString(const char *str, size_t len) { + NotNested(); + PreAlign(len + 1); // Always 0-terminated. + buf_.fill(1); + PushBytes(reinterpret_cast(str), len); + PushElement(static_cast(len)); + return Offset(GetSize()); + } + + /// @brief Store a string in the buffer, which is null-terminated. + /// @param[in] str A const char pointer to a C-string to add to the buffer. + /// @return Returns the offset in the buffer where the string starts. + Offset CreateString(const char *str) { + return CreateString(str, strlen(str)); + } + + /// @brief Store a string in the buffer, which is null-terminated. + /// @param[in] str A char pointer to a C-string to add to the buffer. + /// @return Returns the offset in the buffer where the string starts. + Offset CreateString(char *str) { + return CreateString(str, strlen(str)); + } + + /// @brief Store a string in the buffer, which can contain any binary data. + /// @param[in] str A const reference to a std::string to store in the buffer. + /// @return Returns the offset in the buffer where the string starts. + Offset CreateString(const std::string &str) { + return CreateString(str.c_str(), str.length()); + } + + // clang-format off + #ifdef FLATBUFFERS_HAS_STRING_VIEW + /// @brief Store a string in the buffer, which can contain any binary data. + /// @param[in] str A const string_view to copy in to the buffer. + /// @return Returns the offset in the buffer where the string starts. + Offset CreateString(flatbuffers::string_view str) { + return CreateString(str.data(), str.size()); + } + #endif // FLATBUFFERS_HAS_STRING_VIEW + // clang-format on + + /// @brief Store a string in the buffer, which can contain any binary data. + /// @param[in] str A const pointer to a `String` struct to add to the buffer. + /// @return Returns the offset in the buffer where the string starts + Offset CreateString(const String *str) { + return str ? CreateString(str->c_str(), str->size()) : 0; + } + + /// @brief Store a string in the buffer, which can contain any binary data. + /// @param[in] str A const reference to a std::string like type with support + /// of T::c_str() and T::length() to store in the buffer. + /// @return Returns the offset in the buffer where the string starts. + template Offset CreateString(const T &str) { + return CreateString(str.c_str(), str.length()); + } + + /// @brief Store a string in the buffer, which can contain any binary data. + /// If a string with this exact contents has already been serialized before, + /// instead simply returns the offset of the existing string. This uses a map + /// stored on the heap, but only stores the numerical offsets. + /// @param[in] str A const char pointer to the data to be stored as a string. + /// @param[in] len The number of bytes that should be stored from `str`. + /// @return Returns the offset in the buffer where the string starts. + Offset CreateSharedString(const char *str, size_t len) { + FLATBUFFERS_ASSERT(FLATBUFFERS_GENERAL_HEAP_ALLOC_OK); + if (!string_pool) + string_pool = new StringOffsetMap(StringOffsetCompare(buf_)); + auto size_before_string = buf_.size(); + // Must first serialize the string, since the set is all offsets into + // buffer. + auto off = CreateString(str, len); + auto it = string_pool->find(off); + // If it exists we reuse existing serialized data! + if (it != string_pool->end()) { + // We can remove the string we serialized. + buf_.pop(buf_.size() - size_before_string); + return *it; + } + // Record this string for future use. + string_pool->insert(off); + return off; + } + +#ifdef FLATBUFFERS_HAS_STRING_VIEW + /// @brief Store a string in the buffer, which can contain any binary data. + /// If a string with this exact contents has already been serialized before, + /// instead simply returns the offset of the existing string. This uses a map + /// stored on the heap, but only stores the numerical offsets. + /// @param[in] str A const std::string_view to store in the buffer. + /// @return Returns the offset in the buffer where the string starts + Offset CreateSharedString(const flatbuffers::string_view str) { + return CreateSharedString(str.data(), str.size()); + } +#else + /// @brief Store a string in the buffer, which null-terminated. + /// If a string with this exact contents has already been serialized before, + /// instead simply returns the offset of the existing string. This uses a map + /// stored on the heap, but only stores the numerical offsets. + /// @param[in] str A const char pointer to a C-string to add to the buffer. + /// @return Returns the offset in the buffer where the string starts. + Offset CreateSharedString(const char *str) { + return CreateSharedString(str, strlen(str)); + } + + /// @brief Store a string in the buffer, which can contain any binary data. + /// If a string with this exact contents has already been serialized before, + /// instead simply returns the offset of the existing string. This uses a map + /// stored on the heap, but only stores the numerical offsets. + /// @param[in] str A const reference to a std::string to store in the buffer. + /// @return Returns the offset in the buffer where the string starts. + Offset CreateSharedString(const std::string &str) { + return CreateSharedString(str.c_str(), str.length()); + } +#endif + + /// @brief Store a string in the buffer, which can contain any binary data. + /// If a string with this exact contents has already been serialized before, + /// instead simply returns the offset of the existing string. This uses a map + /// stored on the heap, but only stores the numerical offsets. + /// @param[in] str A const pointer to a `String` struct to add to the buffer. + /// @return Returns the offset in the buffer where the string starts + Offset CreateSharedString(const String *str) { + return str ? CreateSharedString(str->c_str(), str->size()) : 0; + } + + /// @cond FLATBUFFERS_INTERNAL + uoffset_t EndVector(size_t len) { + FLATBUFFERS_ASSERT(nested); // Hit if no corresponding StartVector. + nested = false; + return PushElement(static_cast(len)); + } + + void StartVector(size_t len, size_t elemsize) { + NotNested(); + nested = true; + PreAlign(len * elemsize); + PreAlign(len * elemsize, elemsize); // Just in case elemsize > uoffset_t. + } + + // Call this right before StartVector/CreateVector if you want to force the + // alignment to be something different than what the element size would + // normally dictate. + // This is useful when storing a nested_flatbuffer in a vector of bytes, + // or when storing SIMD floats, etc. + void ForceVectorAlignment(size_t len, size_t elemsize, size_t alignment) { + if (len == 0) return; + FLATBUFFERS_ASSERT(VerifyAlignmentRequirements(alignment)); + PreAlign(len * elemsize, alignment); + } + + // Similar to ForceVectorAlignment but for String fields. + void ForceStringAlignment(size_t len, size_t alignment) { + if (len == 0) return; + FLATBUFFERS_ASSERT(VerifyAlignmentRequirements(alignment)); + PreAlign((len + 1) * sizeof(char), alignment); + } + + /// @endcond + + /// @brief Serialize an array into a FlatBuffer `vector`. + /// @tparam T The data type of the array elements. + /// @param[in] v A pointer to the array of type `T` to serialize into the + /// buffer as a `vector`. + /// @param[in] len The number of elements to serialize. + /// @return Returns a typed `Offset` into the serialized data indicating + /// where the vector is stored. + template Offset> CreateVector(const T *v, size_t len) { + // If this assert hits, you're specifying a template argument that is + // causing the wrong overload to be selected, remove it. + AssertScalarT(); + StartVector(len, sizeof(T)); + if (len == 0) { return Offset>(EndVector(len)); } + // clang-format off + #if FLATBUFFERS_LITTLEENDIAN + PushBytes(reinterpret_cast(v), len * sizeof(T)); + #else + if (sizeof(T) == 1) { + PushBytes(reinterpret_cast(v), len); + } else { + for (auto i = len; i > 0; ) { + PushElement(v[--i]); + } + } + #endif + // clang-format on + return Offset>(EndVector(len)); + } + + /// @brief Serialize an array like object into a FlatBuffer `vector`. + /// @tparam T The data type of the array elements. + /// @tparam C The type of the array. + /// @param[in] array A reference to an array like object of type `T` to + /// serialize into the buffer as a `vector`. + /// @return Returns a typed `Offset` into the serialized data indicating + /// where the vector is stored. + template Offset> CreateVector(const C &array) { + return CreateVector(array.data(), array.size()); + } + + /// @brief Serialize an initializer list into a FlatBuffer `vector`. + /// @tparam T The data type of the initializer list elements. + /// @param[in] v The value of the initializer list. + /// @return Returns a typed `Offset` into the serialized data indicating + /// where the vector is stored. + template + Offset> CreateVector(std::initializer_list v) { + return CreateVector(v.begin(), v.size()); + } + + template + Offset>> CreateVector(const Offset *v, size_t len) { + StartVector(len, sizeof(Offset)); + for (auto i = len; i > 0;) { PushElement(v[--i]); } + return Offset>>(EndVector(len)); + } + + /// @brief Serialize a `std::vector` into a FlatBuffer `vector`. + /// @tparam T The data type of the `std::vector` elements. + /// @param v A const reference to the `std::vector` to serialize into the + /// buffer as a `vector`. + /// @return Returns a typed `Offset` into the serialized data indicating + /// where the vector is stored. + template> + Offset> CreateVector(const std::vector &v) { + return CreateVector(data(v), v.size()); + } + + // vector may be implemented using a bit-set, so we can't access it as + // an array. Instead, read elements manually. + // Background: https://isocpp.org/blog/2012/11/on-vectorbool + Offset> CreateVector(const std::vector &v) { + StartVector(v.size(), sizeof(uint8_t)); + for (auto i = v.size(); i > 0;) { + PushElement(static_cast(v[--i])); + } + return Offset>(EndVector(v.size())); + } + + /// @brief Serialize values returned by a function into a FlatBuffer `vector`. + /// This is a convenience function that takes care of iteration for you. + /// @tparam T The data type of the `std::vector` elements. + /// @param f A function that takes the current iteration 0..vector_size-1 and + /// returns any type that you can construct a FlatBuffers vector out of. + /// @return Returns a typed `Offset` into the serialized data indicating + /// where the vector is stored. + template + Offset> CreateVector(size_t vector_size, + const std::function &f) { + FLATBUFFERS_ASSERT(FLATBUFFERS_GENERAL_HEAP_ALLOC_OK); + std::vector elems(vector_size); + for (size_t i = 0; i < vector_size; i++) elems[i] = f(i); + return CreateVector(elems); + } + + /// @brief Serialize values returned by a function into a FlatBuffer `vector`. + /// This is a convenience function that takes care of iteration for you. This + /// uses a vector stored on the heap to store the intermediate results of the + /// iteration. + /// @tparam T The data type of the `std::vector` elements. + /// @param f A function that takes the current iteration 0..vector_size-1, + /// and the state parameter returning any type that you can construct a + /// FlatBuffers vector out of. + /// @param state State passed to f. + /// @return Returns a typed `Offset` into the serialized data indicating + /// where the vector is stored. + template + Offset> CreateVector(size_t vector_size, F f, S *state) { + FLATBUFFERS_ASSERT(FLATBUFFERS_GENERAL_HEAP_ALLOC_OK); + std::vector elems(vector_size); + for (size_t i = 0; i < vector_size; i++) elems[i] = f(i, state); + return CreateVector(elems); + } + + /// @brief Serialize a `std::vector` into a FlatBuffer `vector`. + /// whereas StringType is any type that is accepted by the CreateString() + /// overloads. + /// This is a convenience function for a common case. + /// @param v A const reference to the `std::vector` to serialize into the + /// buffer as a `vector`. + /// @return Returns a typed `Offset` into the serialized data indicating + /// where the vector is stored. + template> + Offset>> CreateVectorOfStrings( + const std::vector &v) { + return CreateVectorOfStrings(v.cbegin(), v.cend()); + } + + /// @brief Serialize a collection of Strings into a FlatBuffer `vector`. + /// This is a convenience function for a common case. + /// @param begin The beginning iterator of the collection + /// @param end The ending iterator of the collection + /// @return Returns a typed `Offset` into the serialized data indicating + /// where the vector is stored. + template + Offset>> CreateVectorOfStrings(It begin, It end) { + auto size = std::distance(begin, end); + auto scratch_buffer_usage = size * sizeof(Offset); + // If there is not enough space to store the offsets, there definitely won't + // be enough space to store all the strings. So ensuring space for the + // scratch region is OK, for if it fails, it would have failed later. + buf_.ensure_space(scratch_buffer_usage); + for (auto it = begin; it != end; ++it) { + buf_.scratch_push_small(CreateString(*it)); + } + StartVector(size, sizeof(Offset)); + for (auto i = 1; i <= size; i++) { + // Note we re-evaluate the buf location each iteration to account for any + // underlying buffer resizing that may occur. + PushElement(*reinterpret_cast *>( + buf_.scratch_end() - i * sizeof(Offset))); + } + buf_.scratch_pop(scratch_buffer_usage); + return Offset>>(EndVector(size)); + } + + /// @brief Serialize an array of structs into a FlatBuffer `vector`. + /// @tparam T The data type of the struct array elements. + /// @param[in] v A pointer to the array of type `T` to serialize into the + /// buffer as a `vector`. + /// @param[in] len The number of elements to serialize. + /// @return Returns a typed `Offset` into the serialized data indicating + /// where the vector is stored. + template + Offset> CreateVectorOfStructs(const T *v, size_t len) { + StartVector(len * sizeof(T) / AlignOf(), AlignOf()); + if (len > 0) { + PushBytes(reinterpret_cast(v), sizeof(T) * len); + } + return Offset>(EndVector(len)); + } + + /// @brief Serialize an array of native structs into a FlatBuffer `vector`. + /// @tparam T The data type of the struct array elements. + /// @tparam S The data type of the native struct array elements. + /// @param[in] v A pointer to the array of type `S` to serialize into the + /// buffer as a `vector`. + /// @param[in] len The number of elements to serialize. + /// @param[in] pack_func Pointer to a function to convert the native struct + /// to the FlatBuffer struct. + /// @return Returns a typed `Offset` into the serialized data indicating + /// where the vector is stored. + template + Offset> CreateVectorOfNativeStructs( + const S *v, size_t len, T (*const pack_func)(const S &)) { + FLATBUFFERS_ASSERT(pack_func); + auto structs = StartVectorOfStructs(len); + for (size_t i = 0; i < len; i++) { structs[i] = pack_func(v[i]); } + return EndVectorOfStructs(len); + } + + /// @brief Serialize an array of native structs into a FlatBuffer `vector`. + /// @tparam T The data type of the struct array elements. + /// @tparam S The data type of the native struct array elements. + /// @param[in] v A pointer to the array of type `S` to serialize into the + /// buffer as a `vector`. + /// @param[in] len The number of elements to serialize. + /// @return Returns a typed `Offset` into the serialized data indicating + /// where the vector is stored. + template + Offset> CreateVectorOfNativeStructs(const S *v, + size_t len) { + extern T Pack(const S &); + return CreateVectorOfNativeStructs(v, len, Pack); + } + + /// @brief Serialize an array of structs into a FlatBuffer `vector`. + /// @tparam T The data type of the struct array elements. + /// @param[in] filler A function that takes the current iteration + /// 0..vector_size-1 and a pointer to the struct that must be filled. + /// @return Returns a typed `Offset` into the serialized data indicating + /// where the vector is stored. + /// This is mostly useful when flatbuffers are generated with mutation + /// accessors. + template + Offset> CreateVectorOfStructs( + size_t vector_size, const std::function &filler) { + T *structs = StartVectorOfStructs(vector_size); + for (size_t i = 0; i < vector_size; i++) { + filler(i, structs); + structs++; + } + return EndVectorOfStructs(vector_size); + } + + /// @brief Serialize an array of structs into a FlatBuffer `vector`. + /// @tparam T The data type of the struct array elements. + /// @param[in] f A function that takes the current iteration 0..vector_size-1, + /// a pointer to the struct that must be filled and the state argument. + /// @param[in] state Arbitrary state to pass to f. + /// @return Returns a typed `Offset` into the serialized data indicating + /// where the vector is stored. + /// This is mostly useful when flatbuffers are generated with mutation + /// accessors. + template + Offset> CreateVectorOfStructs(size_t vector_size, F f, + S *state) { + T *structs = StartVectorOfStructs(vector_size); + for (size_t i = 0; i < vector_size; i++) { + f(i, structs, state); + structs++; + } + return EndVectorOfStructs(vector_size); + } + + /// @brief Serialize a `std::vector` of structs into a FlatBuffer `vector`. + /// @tparam T The data type of the `std::vector` struct elements. + /// @param[in] v A const reference to the `std::vector` of structs to + /// serialize into the buffer as a `vector`. + /// @return Returns a typed `Offset` into the serialized data indicating + /// where the vector is stored. + template> + Offset> CreateVectorOfStructs( + const std::vector &v) { + return CreateVectorOfStructs(data(v), v.size()); + } + + /// @brief Serialize a `std::vector` of native structs into a FlatBuffer + /// `vector`. + /// @tparam T The data type of the `std::vector` struct elements. + /// @tparam S The data type of the `std::vector` native struct elements. + /// @param[in] v A const reference to the `std::vector` of structs to + /// serialize into the buffer as a `vector`. + /// @param[in] pack_func Pointer to a function to convert the native struct + /// to the FlatBuffer struct. + /// @return Returns a typed `Offset` into the serialized data indicating + /// where the vector is stored. + template> + Offset> CreateVectorOfNativeStructs( + const std::vector &v, T (*const pack_func)(const S &)) { + return CreateVectorOfNativeStructs(data(v), v.size(), pack_func); + } + + /// @brief Serialize a `std::vector` of native structs into a FlatBuffer + /// `vector`. + /// @tparam T The data type of the `std::vector` struct elements. + /// @tparam S The data type of the `std::vector` native struct elements. + /// @param[in] v A const reference to the `std::vector` of structs to + /// serialize into the buffer as a `vector`. + /// @return Returns a typed `Offset` into the serialized data indicating + /// where the vector is stored. + template> + Offset> CreateVectorOfNativeStructs( + const std::vector &v) { + return CreateVectorOfNativeStructs(data(v), v.size()); + } + + /// @cond FLATBUFFERS_INTERNAL + template struct StructKeyComparator { + bool operator()(const T &a, const T &b) const { + return a.KeyCompareLessThan(&b); + } + }; + /// @endcond + + /// @brief Serialize a `std::vector` of structs into a FlatBuffer `vector` + /// in sorted order. + /// @tparam T The data type of the `std::vector` struct elements. + /// @param[in] v A const reference to the `std::vector` of structs to + /// serialize into the buffer as a `vector`. + /// @return Returns a typed `Offset` into the serialized data indicating + /// where the vector is stored. + template> + Offset> CreateVectorOfSortedStructs( + std::vector *v) { + return CreateVectorOfSortedStructs(data(*v), v->size()); + } + + /// @brief Serialize a `std::vector` of native structs into a FlatBuffer + /// `vector` in sorted order. + /// @tparam T The data type of the `std::vector` struct elements. + /// @tparam S The data type of the `std::vector` native struct elements. + /// @param[in] v A const reference to the `std::vector` of structs to + /// serialize into the buffer as a `vector`. + /// @return Returns a typed `Offset` into the serialized data indicating + /// where the vector is stored. + template> + Offset> CreateVectorOfSortedNativeStructs( + std::vector *v) { + return CreateVectorOfSortedNativeStructs(data(*v), v->size()); + } + + /// @brief Serialize an array of structs into a FlatBuffer `vector` in sorted + /// order. + /// @tparam T The data type of the struct array elements. + /// @param[in] v A pointer to the array of type `T` to serialize into the + /// buffer as a `vector`. + /// @param[in] len The number of elements to serialize. + /// @return Returns a typed `Offset` into the serialized data indicating + /// where the vector is stored. + template + Offset> CreateVectorOfSortedStructs(T *v, size_t len) { + std::stable_sort(v, v + len, StructKeyComparator()); + return CreateVectorOfStructs(v, len); + } + + /// @brief Serialize an array of native structs into a FlatBuffer `vector` in + /// sorted order. + /// @tparam T The data type of the struct array elements. + /// @tparam S The data type of the native struct array elements. + /// @param[in] v A pointer to the array of type `S` to serialize into the + /// buffer as a `vector`. + /// @param[in] len The number of elements to serialize. + /// @return Returns a typed `Offset` into the serialized data indicating + /// where the vector is stored. + template + Offset> CreateVectorOfSortedNativeStructs(S *v, + size_t len) { + extern T Pack(const S &); + auto structs = StartVectorOfStructs(len); + for (size_t i = 0; i < len; i++) { structs[i] = Pack(v[i]); } + std::stable_sort(structs, structs + len, StructKeyComparator()); + return EndVectorOfStructs(len); + } + + /// @cond FLATBUFFERS_INTERNAL + template struct TableKeyComparator { + TableKeyComparator(vector_downward &buf) : buf_(buf) {} + TableKeyComparator(const TableKeyComparator &other) : buf_(other.buf_) {} + bool operator()(const Offset &a, const Offset &b) const { + auto table_a = reinterpret_cast(buf_.data_at(a.o)); + auto table_b = reinterpret_cast(buf_.data_at(b.o)); + return table_a->KeyCompareLessThan(table_b); + } + vector_downward &buf_; + + private: + FLATBUFFERS_DELETE_FUNC( + TableKeyComparator &operator=(const TableKeyComparator &other)); + }; + /// @endcond + + /// @brief Serialize an array of `table` offsets as a `vector` in the buffer + /// in sorted order. + /// @tparam T The data type that the offset refers to. + /// @param[in] v An array of type `Offset` that contains the `table` + /// offsets to store in the buffer in sorted order. + /// @param[in] len The number of elements to store in the `vector`. + /// @return Returns a typed `Offset` into the serialized data indicating + /// where the vector is stored. + template + Offset>> CreateVectorOfSortedTables(Offset *v, + size_t len) { + std::stable_sort(v, v + len, TableKeyComparator(buf_)); + return CreateVector(v, len); + } + + /// @brief Serialize an array of `table` offsets as a `vector` in the buffer + /// in sorted order. + /// @tparam T The data type that the offset refers to. + /// @param[in] v An array of type `Offset` that contains the `table` + /// offsets to store in the buffer in sorted order. + /// @return Returns a typed `Offset` into the serialized data indicating + /// where the vector is stored. + template> + Offset>> CreateVectorOfSortedTables( + std::vector, Alloc> *v) { + return CreateVectorOfSortedTables(data(*v), v->size()); + } + + /// @brief Specialized version of `CreateVector` for non-copying use cases. + /// Write the data any time later to the returned buffer pointer `buf`. + /// @param[in] len The number of elements to store in the `vector`. + /// @param[in] elemsize The size of each element in the `vector`. + /// @param[out] buf A pointer to a `uint8_t` pointer that can be + /// written to at a later time to serialize the data into a `vector` + /// in the buffer. + uoffset_t CreateUninitializedVector(size_t len, size_t elemsize, + uint8_t **buf) { + NotNested(); + StartVector(len, elemsize); + buf_.make_space(len * elemsize); + auto vec_start = GetSize(); + auto vec_end = EndVector(len); + *buf = buf_.data_at(vec_start); + return vec_end; + } + + /// @brief Specialized version of `CreateVector` for non-copying use cases. + /// Write the data any time later to the returned buffer pointer `buf`. + /// @tparam T The data type of the data that will be stored in the buffer + /// as a `vector`. + /// @param[in] len The number of elements to store in the `vector`. + /// @param[out] buf A pointer to a pointer of type `T` that can be + /// written to at a later time to serialize the data into a `vector` + /// in the buffer. + template + Offset> CreateUninitializedVector(size_t len, T **buf) { + AssertScalarT(); + return CreateUninitializedVector(len, sizeof(T), + reinterpret_cast(buf)); + } + + template + Offset> CreateUninitializedVectorOfStructs(size_t len, + T **buf) { + return CreateUninitializedVector(len, sizeof(T), + reinterpret_cast(buf)); + } + + // @brief Create a vector of scalar type T given as input a vector of scalar + // type U, useful with e.g. pre "enum class" enums, or any existing scalar + // data of the wrong type. + template + Offset> CreateVectorScalarCast(const U *v, size_t len) { + AssertScalarT(); + AssertScalarT(); + StartVector(len, sizeof(T)); + for (auto i = len; i > 0;) { PushElement(static_cast(v[--i])); } + return Offset>(EndVector(len)); + } + + /// @brief Write a struct by itself, typically to be part of a union. + template Offset CreateStruct(const T &structobj) { + NotNested(); + Align(AlignOf()); + buf_.push_small(structobj); + return Offset(GetSize()); + } + + /// @brief Finish serializing a buffer by writing the root offset. + /// @param[in] file_identifier If a `file_identifier` is given, the buffer + /// will be prefixed with a standard FlatBuffers file header. + template + void Finish(Offset root, const char *file_identifier = nullptr) { + Finish(root.o, file_identifier, false); + } + + /// @brief Finish a buffer with a 32 bit size field pre-fixed (size of the + /// buffer following the size field). These buffers are NOT compatible + /// with standard buffers created by Finish, i.e. you can't call GetRoot + /// on them, you have to use GetSizePrefixedRoot instead. + /// All >32 bit quantities in this buffer will be aligned when the whole + /// size pre-fixed buffer is aligned. + /// These kinds of buffers are useful for creating a stream of FlatBuffers. + template + void FinishSizePrefixed(Offset root, + const char *file_identifier = nullptr) { + Finish(root.o, file_identifier, true); + } + + void SwapBufAllocator(FlatBufferBuilder &other) { + buf_.swap_allocator(other.buf_); + } + + /// @brief The length of a FlatBuffer file header. + static const size_t kFileIdentifierLength = + ::flatbuffers::kFileIdentifierLength; + + protected: + // You shouldn't really be copying instances of this class. + FlatBufferBuilder(const FlatBufferBuilder &); + FlatBufferBuilder &operator=(const FlatBufferBuilder &); + + void Finish(uoffset_t root, const char *file_identifier, bool size_prefix) { + NotNested(); + buf_.clear_scratch(); + // This will cause the whole buffer to be aligned. + PreAlign((size_prefix ? sizeof(uoffset_t) : 0) + sizeof(uoffset_t) + + (file_identifier ? kFileIdentifierLength : 0), + minalign_); + if (file_identifier) { + FLATBUFFERS_ASSERT(strlen(file_identifier) == kFileIdentifierLength); + PushBytes(reinterpret_cast(file_identifier), + kFileIdentifierLength); + } + PushElement(ReferTo(root)); // Location of root. + if (size_prefix) { PushElement(GetSize()); } + finished = true; + } + + struct FieldLoc { + uoffset_t off; + voffset_t id; + }; + + vector_downward buf_; + + // Accumulating offsets of table members while it is being built. + // We store these in the scratch pad of buf_, after the vtable offsets. + uoffset_t num_field_loc; + // Track how much of the vtable is in use, so we can output the most compact + // possible vtable. + voffset_t max_voffset_; + + // Ensure objects are not nested. + bool nested; + + // Ensure the buffer is finished before it is being accessed. + bool finished; + + size_t minalign_; + + bool force_defaults_; // Serialize values equal to their defaults anyway. + + bool dedup_vtables_; + + struct StringOffsetCompare { + StringOffsetCompare(const vector_downward &buf) : buf_(&buf) {} + bool operator()(const Offset &a, const Offset &b) const { + auto stra = reinterpret_cast(buf_->data_at(a.o)); + auto strb = reinterpret_cast(buf_->data_at(b.o)); + return StringLessThan(stra->data(), stra->size(), strb->data(), + strb->size()); + } + const vector_downward *buf_; + }; + + // For use with CreateSharedString. Instantiated on first use only. + typedef std::set, StringOffsetCompare> StringOffsetMap; + StringOffsetMap *string_pool; + + private: + // Allocates space for a vector of structures. + // Must be completed with EndVectorOfStructs(). + template T *StartVectorOfStructs(size_t vector_size) { + StartVector(vector_size * sizeof(T) / AlignOf(), AlignOf()); + return reinterpret_cast(buf_.make_space(vector_size * sizeof(T))); + } + + // End the vector of structures in the flatbuffers. + // Vector should have previously be started with StartVectorOfStructs(). + template + Offset> EndVectorOfStructs(size_t vector_size) { + return Offset>(EndVector(vector_size)); + } +}; +/// @} + +/// Helpers to get a typed pointer to objects that are currently being built. +/// @warning Creating new objects will lead to reallocations and invalidates +/// the pointer! +template +T *GetMutableTemporaryPointer(FlatBufferBuilder &fbb, Offset offset) { + return reinterpret_cast(fbb.GetCurrentBufferPointer() + fbb.GetSize() - + offset.o); +} + +template +const T *GetTemporaryPointer(FlatBufferBuilder &fbb, Offset offset) { + return GetMutableTemporaryPointer(fbb, offset); +} + +template +void FlatBufferBuilder::Required(Offset table, voffset_t field) { + auto table_ptr = reinterpret_cast(buf_.data_at(table.o)); + bool ok = table_ptr->GetOptionalFieldOffset(field) != 0; + // If this fails, the caller will show what field needs to be set. + FLATBUFFERS_ASSERT(ok); + (void)ok; +} + +} // namespace flatbuffers + +#endif // FLATBUFFERS_VECTOR_DOWNWARD_H_ diff --git a/thirdparty/flatbuffers/flatbuffers.h b/thirdparty/flatbuffers/flatbuffers.h index ee34d54ed4..642178897b 100644 --- a/thirdparty/flatbuffers/flatbuffers.h +++ b/thirdparty/flatbuffers/flatbuffers.h @@ -17,2686 +17,23 @@ #ifndef FLATBUFFERS_H_ #define FLATBUFFERS_H_ +// TODO: These includes are for mitigating the pains of users editing their +// source because they relied on flatbuffers.h to include everything for them. +#include "flatbuffers/array.h" #include "flatbuffers/base.h" +#include "flatbuffers/buffer.h" +#include "flatbuffers/buffer_ref.h" +#include "flatbuffers/detached_buffer.h" +#include "flatbuffers/flatbuffer_builder.h" #include "flatbuffers/stl_emulation.h" - -#ifndef FLATBUFFERS_CPP98_STL -# include -#endif - -#if defined(FLATBUFFERS_NAN_DEFAULTS) -# include -#endif +#include "flatbuffers/string.h" +#include "flatbuffers/struct.h" +#include "flatbuffers/table.h" +#include "flatbuffers/vector.h" +#include "flatbuffers/vector_downward.h" +#include "flatbuffers/verifier.h" namespace flatbuffers { -// Generic 'operator==' with conditional specialisations. -// T e - new value of a scalar field. -// T def - default of scalar (is known at compile-time). -template inline bool IsTheSameAs(T e, T def) { return e == def; } - -#if defined(FLATBUFFERS_NAN_DEFAULTS) && \ - defined(FLATBUFFERS_HAS_NEW_STRTOD) && (FLATBUFFERS_HAS_NEW_STRTOD > 0) -// Like `operator==(e, def)` with weak NaN if T=(float|double). -template inline bool IsFloatTheSameAs(T e, T def) { - return (e == def) || ((def != def) && (e != e)); -} -template<> inline bool IsTheSameAs(float e, float def) { - return IsFloatTheSameAs(e, def); -} -template<> inline bool IsTheSameAs(double e, double def) { - return IsFloatTheSameAs(e, def); -} -#endif - -// Check 'v' is out of closed range [low; high]. -// Workaround for GCC warning [-Werror=type-limits]: -// comparison is always true due to limited range of data type. -template -inline bool IsOutRange(const T &v, const T &low, const T &high) { - return (v < low) || (high < v); -} - -// Check 'v' is in closed range [low; high]. -template -inline bool IsInRange(const T &v, const T &low, const T &high) { - return !IsOutRange(v, low, high); -} - -// Wrapper for uoffset_t to allow safe template specialization. -// Value is allowed to be 0 to indicate a null object (see e.g. AddOffset). -template struct Offset { - uoffset_t o; - Offset() : o(0) {} - Offset(uoffset_t _o) : o(_o) {} - Offset Union() const { return Offset(o); } - bool IsNull() const { return !o; } -}; - -inline void EndianCheck() { - int endiantest = 1; - // If this fails, see FLATBUFFERS_LITTLEENDIAN above. - FLATBUFFERS_ASSERT(*reinterpret_cast(&endiantest) == - FLATBUFFERS_LITTLEENDIAN); - (void)endiantest; -} - -template FLATBUFFERS_CONSTEXPR size_t AlignOf() { - // clang-format off - #ifdef _MSC_VER - return __alignof(T); - #else - #ifndef alignof - return __alignof__(T); - #else - return alignof(T); - #endif - #endif - // clang-format on -} - -// When we read serialized data from memory, in the case of most scalars, -// we want to just read T, but in the case of Offset, we want to actually -// perform the indirection and return a pointer. -// The template specialization below does just that. -// It is wrapped in a struct since function templates can't overload on the -// return type like this. -// The typedef is for the convenience of callers of this function -// (avoiding the need for a trailing return decltype) -template struct IndirectHelper { - typedef T return_type; - typedef T mutable_return_type; - static const size_t element_stride = sizeof(T); - static return_type Read(const uint8_t *p, uoffset_t i) { - return EndianScalar((reinterpret_cast(p))[i]); - } -}; -template struct IndirectHelper> { - typedef const T *return_type; - typedef T *mutable_return_type; - static const size_t element_stride = sizeof(uoffset_t); - static return_type Read(const uint8_t *p, uoffset_t i) { - p += i * sizeof(uoffset_t); - return reinterpret_cast(p + ReadScalar(p)); - } -}; -template struct IndirectHelper { - typedef const T *return_type; - typedef T *mutable_return_type; - static const size_t element_stride = sizeof(T); - static return_type Read(const uint8_t *p, uoffset_t i) { - return reinterpret_cast(p + i * sizeof(T)); - } -}; - -// An STL compatible iterator implementation for Vector below, effectively -// calling Get() for every element. -template struct VectorIterator { - typedef std::random_access_iterator_tag iterator_category; - typedef IT value_type; - typedef ptrdiff_t difference_type; - typedef IT *pointer; - typedef IT &reference; - - VectorIterator(const uint8_t *data, uoffset_t i) - : data_(data + IndirectHelper::element_stride * i) {} - VectorIterator(const VectorIterator &other) : data_(other.data_) {} - VectorIterator() : data_(nullptr) {} - - VectorIterator &operator=(const VectorIterator &other) { - data_ = other.data_; - return *this; - } - - // clang-format off - #if !defined(FLATBUFFERS_CPP98_STL) - VectorIterator &operator=(VectorIterator &&other) { - data_ = other.data_; - return *this; - } - #endif // !defined(FLATBUFFERS_CPP98_STL) - // clang-format on - - bool operator==(const VectorIterator &other) const { - return data_ == other.data_; - } - - bool operator<(const VectorIterator &other) const { - return data_ < other.data_; - } - - bool operator!=(const VectorIterator &other) const { - return data_ != other.data_; - } - - difference_type operator-(const VectorIterator &other) const { - return (data_ - other.data_) / IndirectHelper::element_stride; - } - - // Note: return type is incompatible with the standard - // `reference operator*()`. - IT operator*() const { return IndirectHelper::Read(data_, 0); } - - // Note: return type is incompatible with the standard - // `pointer operator->()`. - IT operator->() const { return IndirectHelper::Read(data_, 0); } - - VectorIterator &operator++() { - data_ += IndirectHelper::element_stride; - return *this; - } - - VectorIterator operator++(int) { - VectorIterator temp(data_, 0); - data_ += IndirectHelper::element_stride; - return temp; - } - - VectorIterator operator+(const uoffset_t &offset) const { - return VectorIterator(data_ + offset * IndirectHelper::element_stride, - 0); - } - - VectorIterator &operator+=(const uoffset_t &offset) { - data_ += offset * IndirectHelper::element_stride; - return *this; - } - - VectorIterator &operator--() { - data_ -= IndirectHelper::element_stride; - return *this; - } - - VectorIterator operator--(int) { - VectorIterator temp(data_, 0); - data_ -= IndirectHelper::element_stride; - return temp; - } - - VectorIterator operator-(const uoffset_t &offset) const { - return VectorIterator(data_ - offset * IndirectHelper::element_stride, - 0); - } - - VectorIterator &operator-=(const uoffset_t &offset) { - data_ -= offset * IndirectHelper::element_stride; - return *this; - } - - private: - const uint8_t *data_; -}; - -template -struct VectorReverseIterator : public std::reverse_iterator { - explicit VectorReverseIterator(Iterator iter) - : std::reverse_iterator(iter) {} - - // Note: return type is incompatible with the standard - // `reference operator*()`. - typename Iterator::value_type operator*() const { - auto tmp = std::reverse_iterator::current; - return *--tmp; - } - - // Note: return type is incompatible with the standard - // `pointer operator->()`. - typename Iterator::value_type operator->() const { - auto tmp = std::reverse_iterator::current; - return *--tmp; - } -}; - -struct String; - -// This is used as a helper type for accessing vectors. -// Vector::data() assumes the vector elements start after the length field. -template class Vector { - public: - typedef VectorIterator::mutable_return_type> - iterator; - typedef VectorIterator::return_type> - const_iterator; - typedef VectorReverseIterator reverse_iterator; - typedef VectorReverseIterator const_reverse_iterator; - - uoffset_t size() const { return EndianScalar(length_); } - - // Deprecated: use size(). Here for backwards compatibility. - FLATBUFFERS_ATTRIBUTE(deprecated("use size() instead")) - uoffset_t Length() const { return size(); } - - typedef typename IndirectHelper::return_type return_type; - typedef typename IndirectHelper::mutable_return_type mutable_return_type; - typedef return_type value_type; - - return_type Get(uoffset_t i) const { - FLATBUFFERS_ASSERT(i < size()); - return IndirectHelper::Read(Data(), i); - } - - return_type operator[](uoffset_t i) const { return Get(i); } - - // If this is a Vector of enums, T will be its storage type, not the enum - // type. This function makes it convenient to retrieve value with enum - // type E. - template E GetEnum(uoffset_t i) const { - return static_cast(Get(i)); - } - - // If this a vector of unions, this does the cast for you. There's no check - // to make sure this is the right type! - template const U *GetAs(uoffset_t i) const { - return reinterpret_cast(Get(i)); - } - - // If this a vector of unions, this does the cast for you. There's no check - // to make sure this is actually a string! - const String *GetAsString(uoffset_t i) const { - return reinterpret_cast(Get(i)); - } - - const void *GetStructFromOffset(size_t o) const { - return reinterpret_cast(Data() + o); - } - - iterator begin() { return iterator(Data(), 0); } - const_iterator begin() const { return const_iterator(Data(), 0); } - - iterator end() { return iterator(Data(), size()); } - const_iterator end() const { return const_iterator(Data(), size()); } - - reverse_iterator rbegin() { return reverse_iterator(end()); } - const_reverse_iterator rbegin() const { - return const_reverse_iterator(end()); - } - - reverse_iterator rend() { return reverse_iterator(begin()); } - const_reverse_iterator rend() const { - return const_reverse_iterator(begin()); - } - - const_iterator cbegin() const { return begin(); } - - const_iterator cend() const { return end(); } - - const_reverse_iterator crbegin() const { return rbegin(); } - - const_reverse_iterator crend() const { return rend(); } - - // Change elements if you have a non-const pointer to this object. - // Scalars only. See reflection.h, and the documentation. - void Mutate(uoffset_t i, const T &val) { - FLATBUFFERS_ASSERT(i < size()); - WriteScalar(data() + i, val); - } - - // Change an element of a vector of tables (or strings). - // "val" points to the new table/string, as you can obtain from - // e.g. reflection::AddFlatBuffer(). - void MutateOffset(uoffset_t i, const uint8_t *val) { - FLATBUFFERS_ASSERT(i < size()); - static_assert(sizeof(T) == sizeof(uoffset_t), "Unrelated types"); - WriteScalar(data() + i, - static_cast(val - (Data() + i * sizeof(uoffset_t)))); - } - - // Get a mutable pointer to tables/strings inside this vector. - mutable_return_type GetMutableObject(uoffset_t i) const { - FLATBUFFERS_ASSERT(i < size()); - return const_cast(IndirectHelper::Read(Data(), i)); - } - - // The raw data in little endian format. Use with care. - const uint8_t *Data() const { - return reinterpret_cast(&length_ + 1); - } - - uint8_t *Data() { return reinterpret_cast(&length_ + 1); } - - // Similarly, but typed, much like std::vector::data - const T *data() const { return reinterpret_cast(Data()); } - T *data() { return reinterpret_cast(Data()); } - - template return_type LookupByKey(K key) const { - void *search_result = std::bsearch( - &key, Data(), size(), IndirectHelper::element_stride, KeyCompare); - - if (!search_result) { - return nullptr; // Key not found. - } - - const uint8_t *element = reinterpret_cast(search_result); - - return IndirectHelper::Read(element, 0); - } - - protected: - // This class is only used to access pre-existing data. Don't ever - // try to construct these manually. - Vector(); - - uoffset_t length_; - - private: - // This class is a pointer. Copying will therefore create an invalid object. - // Private and unimplemented copy constructor. - Vector(const Vector &); - Vector &operator=(const Vector &); - - template static int KeyCompare(const void *ap, const void *bp) { - const K *key = reinterpret_cast(ap); - const uint8_t *data = reinterpret_cast(bp); - auto table = IndirectHelper::Read(data, 0); - - // std::bsearch compares with the operands transposed, so we negate the - // result here. - return -table->KeyCompareWithValue(*key); - } -}; - -// Represent a vector much like the template above, but in this case we -// don't know what the element types are (used with reflection.h). -class VectorOfAny { - public: - uoffset_t size() const { return EndianScalar(length_); } - - const uint8_t *Data() const { - return reinterpret_cast(&length_ + 1); - } - uint8_t *Data() { return reinterpret_cast(&length_ + 1); } - - protected: - VectorOfAny(); - - uoffset_t length_; - - private: - VectorOfAny(const VectorOfAny &); - VectorOfAny &operator=(const VectorOfAny &); -}; - -#ifndef FLATBUFFERS_CPP98_STL -template -Vector> *VectorCast(Vector> *ptr) { - static_assert(std::is_base_of::value, "Unrelated types"); - return reinterpret_cast> *>(ptr); -} - -template -const Vector> *VectorCast(const Vector> *ptr) { - static_assert(std::is_base_of::value, "Unrelated types"); - return reinterpret_cast> *>(ptr); -} -#endif - -// Convenient helper function to get the length of any vector, regardless -// of whether it is null or not (the field is not set). -template static inline size_t VectorLength(const Vector *v) { - return v ? v->size() : 0; -} - -// This is used as a helper type for accessing arrays. -template class Array { - typedef - typename flatbuffers::integral_constant::value> - scalar_tag; - typedef - typename flatbuffers::conditional::type - IndirectHelperType; - - public: - typedef uint16_t size_type; - typedef typename IndirectHelper::return_type return_type; - typedef VectorIterator const_iterator; - typedef VectorReverseIterator const_reverse_iterator; - - FLATBUFFERS_CONSTEXPR uint16_t size() const { return length; } - - return_type Get(uoffset_t i) const { - FLATBUFFERS_ASSERT(i < size()); - return IndirectHelper::Read(Data(), i); - } - - return_type operator[](uoffset_t i) const { return Get(i); } - - // If this is a Vector of enums, T will be its storage type, not the enum - // type. This function makes it convenient to retrieve value with enum - // type E. - template E GetEnum(uoffset_t i) const { - return static_cast(Get(i)); - } - - const_iterator begin() const { return const_iterator(Data(), 0); } - const_iterator end() const { return const_iterator(Data(), size()); } - - const_reverse_iterator rbegin() const { - return const_reverse_iterator(end()); - } - const_reverse_iterator rend() const { - return const_reverse_iterator(begin()); - } - - const_iterator cbegin() const { return begin(); } - const_iterator cend() const { return end(); } - - const_reverse_iterator crbegin() const { return rbegin(); } - const_reverse_iterator crend() const { return rend(); } - - // Get a mutable pointer to elements inside this array. - // This method used to mutate arrays of structs followed by a @p Mutate - // operation. For primitive types use @p Mutate directly. - // @warning Assignments and reads to/from the dereferenced pointer are not - // automatically converted to the correct endianness. - typename flatbuffers::conditional::type - GetMutablePointer(uoffset_t i) const { - FLATBUFFERS_ASSERT(i < size()); - return const_cast(&data()[i]); - } - - // Change elements if you have a non-const pointer to this object. - void Mutate(uoffset_t i, const T &val) { MutateImpl(scalar_tag(), i, val); } - - // The raw data in little endian format. Use with care. - const uint8_t *Data() const { return data_; } - - uint8_t *Data() { return data_; } - - // Similarly, but typed, much like std::vector::data - const T *data() const { return reinterpret_cast(Data()); } - T *data() { return reinterpret_cast(Data()); } - - // Copy data from a span with endian conversion. - // If this Array and the span overlap, the behavior is undefined. - void CopyFromSpan(flatbuffers::span src) { - const auto p1 = reinterpret_cast(src.data()); - const auto p2 = Data(); - FLATBUFFERS_ASSERT(!(p1 >= p2 && p1 < (p2 + length)) && - !(p2 >= p1 && p2 < (p1 + length))); - (void)p1; - (void)p2; - - CopyFromSpanImpl( - flatbuffers::integral_constant < bool, - !scalar_tag::value || sizeof(T) == 1 || FLATBUFFERS_LITTLEENDIAN > (), - src); - } - - protected: - void MutateImpl(flatbuffers::integral_constant, uoffset_t i, - const T &val) { - FLATBUFFERS_ASSERT(i < size()); - WriteScalar(data() + i, val); - } - - void MutateImpl(flatbuffers::integral_constant, uoffset_t i, - const T &val) { - *(GetMutablePointer(i)) = val; - } - - void CopyFromSpanImpl(flatbuffers::integral_constant, - flatbuffers::span src) { - // Use std::memcpy() instead of std::copy() to avoid preformance degradation - // due to aliasing if T is char or unsigned char. - // The size is known at compile time, so memcpy would be inlined. - std::memcpy(data(), src.data(), length * sizeof(T)); - } - - // Copy data from flatbuffers::span with endian conversion. - void CopyFromSpanImpl(flatbuffers::integral_constant, - flatbuffers::span src) { - for (size_type k = 0; k < length; k++) { Mutate(k, src[k]); } - } - - // This class is only used to access pre-existing data. Don't ever - // try to construct these manually. - // 'constexpr' allows us to use 'size()' at compile time. - // @note Must not use 'FLATBUFFERS_CONSTEXPR' here, as const is not allowed on - // a constructor. -#if defined(__cpp_constexpr) - constexpr Array(); -#else - Array(); -#endif - - uint8_t data_[length * sizeof(T)]; - - private: - // This class is a pointer. Copying will therefore create an invalid object. - // Private and unimplemented copy constructor. - Array(const Array &); - Array &operator=(const Array &); -}; - -// Specialization for Array[struct] with access using Offset pointer. -// This specialization used by idl_gen_text.cpp. -template class Array, length> { - static_assert(flatbuffers::is_same::value, "unexpected type T"); - - public: - typedef const void *return_type; - - const uint8_t *Data() const { return data_; } - - // Make idl_gen_text.cpp::PrintContainer happy. - return_type operator[](uoffset_t) const { - FLATBUFFERS_ASSERT(false); - return nullptr; - } - - private: - // This class is only used to access pre-existing data. - Array(); - Array(const Array &); - Array &operator=(const Array &); - - uint8_t data_[1]; -}; - -// Cast a raw T[length] to a raw flatbuffers::Array -// without endian conversion. Use with care. -template -Array &CastToArray(T (&arr)[length]) { - return *reinterpret_cast *>(arr); -} - -template -const Array &CastToArray(const T (&arr)[length]) { - return *reinterpret_cast *>(arr); -} - -template -Array &CastToArrayOfEnum(T (&arr)[length]) { - static_assert(sizeof(E) == sizeof(T), "invalid enum type E"); - return *reinterpret_cast *>(arr); -} - -template -const Array &CastToArrayOfEnum(const T (&arr)[length]) { - static_assert(sizeof(E) == sizeof(T), "invalid enum type E"); - return *reinterpret_cast *>(arr); -} - -// Lexicographically compare two strings (possibly containing nulls), and -// return true if the first is less than the second. -static inline bool StringLessThan(const char *a_data, uoffset_t a_size, - const char *b_data, uoffset_t b_size) { - const auto cmp = memcmp(a_data, b_data, (std::min)(a_size, b_size)); - return cmp == 0 ? a_size < b_size : cmp < 0; -} - -struct String : public Vector { - const char *c_str() const { return reinterpret_cast(Data()); } - std::string str() const { return std::string(c_str(), size()); } - - // clang-format off - #ifdef FLATBUFFERS_HAS_STRING_VIEW - flatbuffers::string_view string_view() const { - return flatbuffers::string_view(c_str(), size()); - } - #endif // FLATBUFFERS_HAS_STRING_VIEW - // clang-format on - - bool operator<(const String &o) const { - return StringLessThan(this->data(), this->size(), o.data(), o.size()); - } -}; - -// Convenience function to get std::string from a String returning an empty -// string on null pointer. -static inline std::string GetString(const String *str) { - return str ? str->str() : ""; -} - -// Convenience function to get char* from a String returning an empty string on -// null pointer. -static inline const char *GetCstring(const String *str) { - return str ? str->c_str() : ""; -} - -#ifdef FLATBUFFERS_HAS_STRING_VIEW -// Convenience function to get string_view from a String returning an empty -// string_view on null pointer. -static inline flatbuffers::string_view GetStringView(const String *str) { - return str ? str->string_view() : flatbuffers::string_view(); -} -#endif // FLATBUFFERS_HAS_STRING_VIEW - -// Allocator interface. This is flatbuffers-specific and meant only for -// `vector_downward` usage. -class Allocator { - public: - virtual ~Allocator() {} - - // Allocate `size` bytes of memory. - virtual uint8_t *allocate(size_t size) = 0; - - // Deallocate `size` bytes of memory at `p` allocated by this allocator. - virtual void deallocate(uint8_t *p, size_t size) = 0; - - // Reallocate `new_size` bytes of memory, replacing the old region of size - // `old_size` at `p`. In contrast to a normal realloc, this grows downwards, - // and is intended specifcally for `vector_downward` use. - // `in_use_back` and `in_use_front` indicate how much of `old_size` is - // actually in use at each end, and needs to be copied. - virtual uint8_t *reallocate_downward(uint8_t *old_p, size_t old_size, - size_t new_size, size_t in_use_back, - size_t in_use_front) { - FLATBUFFERS_ASSERT(new_size > old_size); // vector_downward only grows - uint8_t *new_p = allocate(new_size); - memcpy_downward(old_p, old_size, new_p, new_size, in_use_back, - in_use_front); - deallocate(old_p, old_size); - return new_p; - } - - protected: - // Called by `reallocate_downward` to copy memory from `old_p` of `old_size` - // to `new_p` of `new_size`. Only memory of size `in_use_front` and - // `in_use_back` will be copied from the front and back of the old memory - // allocation. - void memcpy_downward(uint8_t *old_p, size_t old_size, uint8_t *new_p, - size_t new_size, size_t in_use_back, - size_t in_use_front) { - memcpy(new_p + new_size - in_use_back, old_p + old_size - in_use_back, - in_use_back); - memcpy(new_p, old_p, in_use_front); - } -}; - -// DefaultAllocator uses new/delete to allocate memory regions -class DefaultAllocator : public Allocator { - public: - uint8_t *allocate(size_t size) FLATBUFFERS_OVERRIDE { - return new uint8_t[size]; - } - - void deallocate(uint8_t *p, size_t) FLATBUFFERS_OVERRIDE { delete[] p; } - - static void dealloc(void *p, size_t) { delete[] static_cast(p); } -}; - -// These functions allow for a null allocator to mean use the default allocator, -// as used by DetachedBuffer and vector_downward below. -// This is to avoid having a statically or dynamically allocated default -// allocator, or having to move it between the classes that may own it. -inline uint8_t *Allocate(Allocator *allocator, size_t size) { - return allocator ? allocator->allocate(size) - : DefaultAllocator().allocate(size); -} - -inline void Deallocate(Allocator *allocator, uint8_t *p, size_t size) { - if (allocator) - allocator->deallocate(p, size); - else - DefaultAllocator().deallocate(p, size); -} - -inline uint8_t *ReallocateDownward(Allocator *allocator, uint8_t *old_p, - size_t old_size, size_t new_size, - size_t in_use_back, size_t in_use_front) { - return allocator ? allocator->reallocate_downward(old_p, old_size, new_size, - in_use_back, in_use_front) - : DefaultAllocator().reallocate_downward( - old_p, old_size, new_size, in_use_back, in_use_front); -} - -// DetachedBuffer is a finished flatbuffer memory region, detached from its -// builder. The original memory region and allocator are also stored so that -// the DetachedBuffer can manage the memory lifetime. -class DetachedBuffer { - public: - DetachedBuffer() - : allocator_(nullptr), - own_allocator_(false), - buf_(nullptr), - reserved_(0), - cur_(nullptr), - size_(0) {} - - DetachedBuffer(Allocator *allocator, bool own_allocator, uint8_t *buf, - size_t reserved, uint8_t *cur, size_t sz) - : allocator_(allocator), - own_allocator_(own_allocator), - buf_(buf), - reserved_(reserved), - cur_(cur), - size_(sz) {} - - // clang-format off - #if !defined(FLATBUFFERS_CPP98_STL) - // clang-format on - DetachedBuffer(DetachedBuffer &&other) - : allocator_(other.allocator_), - own_allocator_(other.own_allocator_), - buf_(other.buf_), - reserved_(other.reserved_), - cur_(other.cur_), - size_(other.size_) { - other.reset(); - } - // clang-format off - #endif // !defined(FLATBUFFERS_CPP98_STL) - // clang-format on - - // clang-format off - #if !defined(FLATBUFFERS_CPP98_STL) - // clang-format on - DetachedBuffer &operator=(DetachedBuffer &&other) { - if (this == &other) return *this; - - destroy(); - - allocator_ = other.allocator_; - own_allocator_ = other.own_allocator_; - buf_ = other.buf_; - reserved_ = other.reserved_; - cur_ = other.cur_; - size_ = other.size_; - - other.reset(); - - return *this; - } - // clang-format off - #endif // !defined(FLATBUFFERS_CPP98_STL) - // clang-format on - - ~DetachedBuffer() { destroy(); } - - const uint8_t *data() const { return cur_; } - - uint8_t *data() { return cur_; } - - size_t size() const { return size_; } - - // clang-format off - #if 0 // disabled for now due to the ordering of classes in this header - template - bool Verify() const { - Verifier verifier(data(), size()); - return verifier.Verify(nullptr); - } - - template - const T* GetRoot() const { - return flatbuffers::GetRoot(data()); - } - - template - T* GetRoot() { - return flatbuffers::GetRoot(data()); - } - #endif - // clang-format on - - // clang-format off - #if !defined(FLATBUFFERS_CPP98_STL) - // clang-format on - // These may change access mode, leave these at end of public section - FLATBUFFERS_DELETE_FUNC(DetachedBuffer(const DetachedBuffer &other)); - FLATBUFFERS_DELETE_FUNC( - DetachedBuffer &operator=(const DetachedBuffer &other)); - // clang-format off - #endif // !defined(FLATBUFFERS_CPP98_STL) - // clang-format on - - protected: - Allocator *allocator_; - bool own_allocator_; - uint8_t *buf_; - size_t reserved_; - uint8_t *cur_; - size_t size_; - - inline void destroy() { - if (buf_) Deallocate(allocator_, buf_, reserved_); - if (own_allocator_ && allocator_) { delete allocator_; } - reset(); - } - - inline void reset() { - allocator_ = nullptr; - own_allocator_ = false; - buf_ = nullptr; - reserved_ = 0; - cur_ = nullptr; - size_ = 0; - } -}; - -// This is a minimal replication of std::vector functionality, -// except growing from higher to lower addresses. i.e push_back() inserts data -// in the lowest address in the vector. -// Since this vector leaves the lower part unused, we support a "scratch-pad" -// that can be stored there for temporary data, to share the allocated space. -// Essentially, this supports 2 std::vectors in a single buffer. -class vector_downward { - public: - explicit vector_downward(size_t initial_size, Allocator *allocator, - bool own_allocator, size_t buffer_minalign) - : allocator_(allocator), - own_allocator_(own_allocator), - initial_size_(initial_size), - buffer_minalign_(buffer_minalign), - reserved_(0), - buf_(nullptr), - cur_(nullptr), - scratch_(nullptr) {} - - // clang-format off - #if !defined(FLATBUFFERS_CPP98_STL) - vector_downward(vector_downward &&other) - #else - vector_downward(vector_downward &other) - #endif // defined(FLATBUFFERS_CPP98_STL) - // clang-format on - : allocator_(other.allocator_), - own_allocator_(other.own_allocator_), - initial_size_(other.initial_size_), - buffer_minalign_(other.buffer_minalign_), - reserved_(other.reserved_), - buf_(other.buf_), - cur_(other.cur_), - scratch_(other.scratch_) { - // No change in other.allocator_ - // No change in other.initial_size_ - // No change in other.buffer_minalign_ - other.own_allocator_ = false; - other.reserved_ = 0; - other.buf_ = nullptr; - other.cur_ = nullptr; - other.scratch_ = nullptr; - } - - // clang-format off - #if !defined(FLATBUFFERS_CPP98_STL) - // clang-format on - vector_downward &operator=(vector_downward &&other) { - // Move construct a temporary and swap idiom - vector_downward temp(std::move(other)); - swap(temp); - return *this; - } - // clang-format off - #endif // defined(FLATBUFFERS_CPP98_STL) - // clang-format on - - ~vector_downward() { - clear_buffer(); - clear_allocator(); - } - - void reset() { - clear_buffer(); - clear(); - } - - void clear() { - if (buf_) { - cur_ = buf_ + reserved_; - } else { - reserved_ = 0; - cur_ = nullptr; - } - clear_scratch(); - } - - void clear_scratch() { scratch_ = buf_; } - - void clear_allocator() { - if (own_allocator_ && allocator_) { delete allocator_; } - allocator_ = nullptr; - own_allocator_ = false; - } - - void clear_buffer() { - if (buf_) Deallocate(allocator_, buf_, reserved_); - buf_ = nullptr; - } - - // Relinquish the pointer to the caller. - uint8_t *release_raw(size_t &allocated_bytes, size_t &offset) { - auto *buf = buf_; - allocated_bytes = reserved_; - offset = static_cast(cur_ - buf_); - - // release_raw only relinquishes the buffer ownership. - // Does not deallocate or reset the allocator. Destructor will do that. - buf_ = nullptr; - clear(); - return buf; - } - - // Relinquish the pointer to the caller. - DetachedBuffer release() { - // allocator ownership (if any) is transferred to DetachedBuffer. - DetachedBuffer fb(allocator_, own_allocator_, buf_, reserved_, cur_, - size()); - if (own_allocator_) { - allocator_ = nullptr; - own_allocator_ = false; - } - buf_ = nullptr; - clear(); - return fb; - } - - size_t ensure_space(size_t len) { - FLATBUFFERS_ASSERT(cur_ >= scratch_ && scratch_ >= buf_); - if (len > static_cast(cur_ - scratch_)) { reallocate(len); } - // Beyond this, signed offsets may not have enough range: - // (FlatBuffers > 2GB not supported). - FLATBUFFERS_ASSERT(size() < FLATBUFFERS_MAX_BUFFER_SIZE); - return len; - } - - inline uint8_t *make_space(size_t len) { - size_t space = ensure_space(len); - cur_ -= space; - return cur_; - } - - // Returns nullptr if using the DefaultAllocator. - Allocator *get_custom_allocator() { return allocator_; } - - uoffset_t size() const { - return static_cast(reserved_ - static_cast(cur_ - buf_)); - } - - uoffset_t scratch_size() const { - return static_cast(scratch_ - buf_); - } - - size_t capacity() const { return reserved_; } - - uint8_t *data() const { - FLATBUFFERS_ASSERT(cur_); - return cur_; - } - - uint8_t *scratch_data() const { - FLATBUFFERS_ASSERT(buf_); - return buf_; - } - - uint8_t *scratch_end() const { - FLATBUFFERS_ASSERT(scratch_); - return scratch_; - } - - uint8_t *data_at(size_t offset) const { return buf_ + reserved_ - offset; } - - void push(const uint8_t *bytes, size_t num) { - if (num > 0) { memcpy(make_space(num), bytes, num); } - } - - // Specialized version of push() that avoids memcpy call for small data. - template void push_small(const T &little_endian_t) { - make_space(sizeof(T)); - *reinterpret_cast(cur_) = little_endian_t; - } - - template void scratch_push_small(const T &t) { - ensure_space(sizeof(T)); - *reinterpret_cast(scratch_) = t; - scratch_ += sizeof(T); - } - - // fill() is most frequently called with small byte counts (<= 4), - // which is why we're using loops rather than calling memset. - void fill(size_t zero_pad_bytes) { - make_space(zero_pad_bytes); - for (size_t i = 0; i < zero_pad_bytes; i++) cur_[i] = 0; - } - - // Version for when we know the size is larger. - // Precondition: zero_pad_bytes > 0 - void fill_big(size_t zero_pad_bytes) { - memset(make_space(zero_pad_bytes), 0, zero_pad_bytes); - } - - void pop(size_t bytes_to_remove) { cur_ += bytes_to_remove; } - void scratch_pop(size_t bytes_to_remove) { scratch_ -= bytes_to_remove; } - - void swap(vector_downward &other) { - using std::swap; - swap(allocator_, other.allocator_); - swap(own_allocator_, other.own_allocator_); - swap(initial_size_, other.initial_size_); - swap(buffer_minalign_, other.buffer_minalign_); - swap(reserved_, other.reserved_); - swap(buf_, other.buf_); - swap(cur_, other.cur_); - swap(scratch_, other.scratch_); - } - - void swap_allocator(vector_downward &other) { - using std::swap; - swap(allocator_, other.allocator_); - swap(own_allocator_, other.own_allocator_); - } - - private: - // You shouldn't really be copying instances of this class. - FLATBUFFERS_DELETE_FUNC(vector_downward(const vector_downward &)); - FLATBUFFERS_DELETE_FUNC(vector_downward &operator=(const vector_downward &)); - - Allocator *allocator_; - bool own_allocator_; - size_t initial_size_; - size_t buffer_minalign_; - size_t reserved_; - uint8_t *buf_; - uint8_t *cur_; // Points at location between empty (below) and used (above). - uint8_t *scratch_; // Points to the end of the scratchpad in use. - - void reallocate(size_t len) { - auto old_reserved = reserved_; - auto old_size = size(); - auto old_scratch_size = scratch_size(); - reserved_ += - (std::max)(len, old_reserved ? old_reserved / 2 : initial_size_); - reserved_ = (reserved_ + buffer_minalign_ - 1) & ~(buffer_minalign_ - 1); - if (buf_) { - buf_ = ReallocateDownward(allocator_, buf_, old_reserved, reserved_, - old_size, old_scratch_size); - } else { - buf_ = Allocate(allocator_, reserved_); - } - cur_ = buf_ + reserved_ - old_size; - scratch_ = buf_ + old_scratch_size; - } -}; - -// Converts a Field ID to a virtual table offset. -inline voffset_t FieldIndexToOffset(voffset_t field_id) { - // Should correspond to what EndTable() below builds up. - const int fixed_fields = 2; // Vtable size and Object Size. - return static_cast((field_id + fixed_fields) * sizeof(voffset_t)); -} - -template -const T *data(const std::vector &v) { - // Eventually the returned pointer gets passed down to memcpy, so - // we need it to be non-null to avoid undefined behavior. - static uint8_t t; - return v.empty() ? reinterpret_cast(&t) : &v.front(); -} -template T *data(std::vector &v) { - // Eventually the returned pointer gets passed down to memcpy, so - // we need it to be non-null to avoid undefined behavior. - static uint8_t t; - return v.empty() ? reinterpret_cast(&t) : &v.front(); -} - -/// @endcond - -/// @addtogroup flatbuffers_cpp_api -/// @{ -/// @class FlatBufferBuilder -/// @brief Helper class to hold data needed in creation of a FlatBuffer. -/// To serialize data, you typically call one of the `Create*()` functions in -/// the generated code, which in turn call a sequence of `StartTable`/ -/// `PushElement`/`AddElement`/`EndTable`, or the builtin `CreateString`/ -/// `CreateVector` functions. Do this is depth-first order to build up a tree to -/// the root. `Finish()` wraps up the buffer ready for transport. -class FlatBufferBuilder { - public: - /// @brief Default constructor for FlatBufferBuilder. - /// @param[in] initial_size The initial size of the buffer, in bytes. Defaults - /// to `1024`. - /// @param[in] allocator An `Allocator` to use. If null will use - /// `DefaultAllocator`. - /// @param[in] own_allocator Whether the builder/vector should own the - /// allocator. Defaults to / `false`. - /// @param[in] buffer_minalign Force the buffer to be aligned to the given - /// minimum alignment upon reallocation. Only needed if you intend to store - /// types with custom alignment AND you wish to read the buffer in-place - /// directly after creation. - explicit FlatBufferBuilder( - size_t initial_size = 1024, Allocator *allocator = nullptr, - bool own_allocator = false, - size_t buffer_minalign = AlignOf()) - : buf_(initial_size, allocator, own_allocator, buffer_minalign), - num_field_loc(0), - max_voffset_(0), - nested(false), - finished(false), - minalign_(1), - force_defaults_(false), - dedup_vtables_(true), - string_pool(nullptr) { - EndianCheck(); - } - - // clang-format off - /// @brief Move constructor for FlatBufferBuilder. - #if !defined(FLATBUFFERS_CPP98_STL) - FlatBufferBuilder(FlatBufferBuilder &&other) - #else - FlatBufferBuilder(FlatBufferBuilder &other) - #endif // #if !defined(FLATBUFFERS_CPP98_STL) - : buf_(1024, nullptr, false, AlignOf()), - num_field_loc(0), - max_voffset_(0), - nested(false), - finished(false), - minalign_(1), - force_defaults_(false), - dedup_vtables_(true), - string_pool(nullptr) { - EndianCheck(); - // Default construct and swap idiom. - // Lack of delegating constructors in vs2010 makes it more verbose than needed. - Swap(other); - } - // clang-format on - - // clang-format off - #if !defined(FLATBUFFERS_CPP98_STL) - // clang-format on - /// @brief Move assignment operator for FlatBufferBuilder. - FlatBufferBuilder &operator=(FlatBufferBuilder &&other) { - // Move construct a temporary and swap idiom - FlatBufferBuilder temp(std::move(other)); - Swap(temp); - return *this; - } - // clang-format off - #endif // defined(FLATBUFFERS_CPP98_STL) - // clang-format on - - void Swap(FlatBufferBuilder &other) { - using std::swap; - buf_.swap(other.buf_); - swap(num_field_loc, other.num_field_loc); - swap(max_voffset_, other.max_voffset_); - swap(nested, other.nested); - swap(finished, other.finished); - swap(minalign_, other.minalign_); - swap(force_defaults_, other.force_defaults_); - swap(dedup_vtables_, other.dedup_vtables_); - swap(string_pool, other.string_pool); - } - - ~FlatBufferBuilder() { - if (string_pool) delete string_pool; - } - - void Reset() { - Clear(); // clear builder state - buf_.reset(); // deallocate buffer - } - - /// @brief Reset all the state in this FlatBufferBuilder so it can be reused - /// to construct another buffer. - void Clear() { - ClearOffsets(); - buf_.clear(); - nested = false; - finished = false; - minalign_ = 1; - if (string_pool) string_pool->clear(); - } - - /// @brief The current size of the serialized buffer, counting from the end. - /// @return Returns an `uoffset_t` with the current size of the buffer. - uoffset_t GetSize() const { return buf_.size(); } - - /// @brief Get the serialized buffer (after you call `Finish()`). - /// @return Returns an `uint8_t` pointer to the FlatBuffer data inside the - /// buffer. - uint8_t *GetBufferPointer() const { - Finished(); - return buf_.data(); - } - - /// @brief Get the serialized buffer (after you call `Finish()`) as a span. - /// @return Returns a constructed flatbuffers::span that is a view over the - /// FlatBuffer data inside the buffer. - flatbuffers::span GetBufferSpan() const { - Finished(); - return flatbuffers::span(buf_.data(), buf_.size()); - } - - /// @brief Get a pointer to an unfinished buffer. - /// @return Returns a `uint8_t` pointer to the unfinished buffer. - uint8_t *GetCurrentBufferPointer() const { return buf_.data(); } - - /// @brief Get the released pointer to the serialized buffer. - /// @warning Do NOT attempt to use this FlatBufferBuilder afterwards! - /// @return A `FlatBuffer` that owns the buffer and its allocator and - /// behaves similar to a `unique_ptr` with a deleter. - FLATBUFFERS_ATTRIBUTE(deprecated("use Release() instead")) - DetachedBuffer ReleaseBufferPointer() { - Finished(); - return buf_.release(); - } - - /// @brief Get the released DetachedBuffer. - /// @return A `DetachedBuffer` that owns the buffer and its allocator. - DetachedBuffer Release() { - Finished(); - return buf_.release(); - } - - /// @brief Get the released pointer to the serialized buffer. - /// @param size The size of the memory block containing - /// the serialized `FlatBuffer`. - /// @param offset The offset from the released pointer where the finished - /// `FlatBuffer` starts. - /// @return A raw pointer to the start of the memory block containing - /// the serialized `FlatBuffer`. - /// @remark If the allocator is owned, it gets deleted when the destructor is - /// called.. - uint8_t *ReleaseRaw(size_t &size, size_t &offset) { - Finished(); - return buf_.release_raw(size, offset); - } - - /// @brief get the minimum alignment this buffer needs to be accessed - /// properly. This is only known once all elements have been written (after - /// you call Finish()). You can use this information if you need to embed - /// a FlatBuffer in some other buffer, such that you can later read it - /// without first having to copy it into its own buffer. - size_t GetBufferMinAlignment() const { - Finished(); - return minalign_; - } - - /// @cond FLATBUFFERS_INTERNAL - void Finished() const { - // If you get this assert, you're attempting to get access a buffer - // which hasn't been finished yet. Be sure to call - // FlatBufferBuilder::Finish with your root table. - // If you really need to access an unfinished buffer, call - // GetCurrentBufferPointer instead. - FLATBUFFERS_ASSERT(finished); - } - /// @endcond - - /// @brief In order to save space, fields that are set to their default value - /// don't get serialized into the buffer. - /// @param[in] fd When set to `true`, always serializes default values that - /// are set. Optional fields which are not set explicitly, will still not be - /// serialized. - void ForceDefaults(bool fd) { force_defaults_ = fd; } - - /// @brief By default vtables are deduped in order to save space. - /// @param[in] dedup When set to `true`, dedup vtables. - void DedupVtables(bool dedup) { dedup_vtables_ = dedup; } - - /// @cond FLATBUFFERS_INTERNAL - void Pad(size_t num_bytes) { buf_.fill(num_bytes); } - - void TrackMinAlign(size_t elem_size) { - if (elem_size > minalign_) minalign_ = elem_size; - } - - void Align(size_t elem_size) { - TrackMinAlign(elem_size); - buf_.fill(PaddingBytes(buf_.size(), elem_size)); - } - - void PushFlatBuffer(const uint8_t *bytes, size_t size) { - PushBytes(bytes, size); - finished = true; - } - - void PushBytes(const uint8_t *bytes, size_t size) { buf_.push(bytes, size); } - - void PopBytes(size_t amount) { buf_.pop(amount); } - - template void AssertScalarT() { - // The code assumes power of 2 sizes and endian-swap-ability. - static_assert(flatbuffers::is_scalar::value, "T must be a scalar type"); - } - - // Write a single aligned scalar to the buffer - template uoffset_t PushElement(T element) { - AssertScalarT(); - T litle_endian_element = EndianScalar(element); - Align(sizeof(T)); - buf_.push_small(litle_endian_element); - return GetSize(); - } - - template uoffset_t PushElement(Offset off) { - // Special case for offsets: see ReferTo below. - return PushElement(ReferTo(off.o)); - } - - // When writing fields, we track where they are, so we can create correct - // vtables later. - void TrackField(voffset_t field, uoffset_t off) { - FieldLoc fl = { off, field }; - buf_.scratch_push_small(fl); - num_field_loc++; - max_voffset_ = (std::max)(max_voffset_, field); - } - - // Like PushElement, but additionally tracks the field this represents. - template void AddElement(voffset_t field, T e, T def) { - // We don't serialize values equal to the default. - if (IsTheSameAs(e, def) && !force_defaults_) return; - auto off = PushElement(e); - TrackField(field, off); - } - - template void AddElement(voffset_t field, T e) { - auto off = PushElement(e); - TrackField(field, off); - } - - template void AddOffset(voffset_t field, Offset off) { - if (off.IsNull()) return; // Don't store. - AddElement(field, ReferTo(off.o), static_cast(0)); - } - - template void AddStruct(voffset_t field, const T *structptr) { - if (!structptr) return; // Default, don't store. - Align(AlignOf()); - buf_.push_small(*structptr); - TrackField(field, GetSize()); - } - - void AddStructOffset(voffset_t field, uoffset_t off) { - TrackField(field, off); - } - - // Offsets initially are relative to the end of the buffer (downwards). - // This function converts them to be relative to the current location - // in the buffer (when stored here), pointing upwards. - uoffset_t ReferTo(uoffset_t off) { - // Align to ensure GetSize() below is correct. - Align(sizeof(uoffset_t)); - // Offset must refer to something already in buffer. - FLATBUFFERS_ASSERT(off && off <= GetSize()); - return GetSize() - off + static_cast(sizeof(uoffset_t)); - } - - void NotNested() { - // If you hit this, you're trying to construct a Table/Vector/String - // during the construction of its parent table (between the MyTableBuilder - // and table.Finish(). - // Move the creation of these sub-objects to above the MyTableBuilder to - // not get this assert. - // Ignoring this assert may appear to work in simple cases, but the reason - // it is here is that storing objects in-line may cause vtable offsets - // to not fit anymore. It also leads to vtable duplication. - FLATBUFFERS_ASSERT(!nested); - // If you hit this, fields were added outside the scope of a table. - FLATBUFFERS_ASSERT(!num_field_loc); - } - - // From generated code (or from the parser), we call StartTable/EndTable - // with a sequence of AddElement calls in between. - uoffset_t StartTable() { - NotNested(); - nested = true; - return GetSize(); - } - - // This finishes one serialized object by generating the vtable if it's a - // table, comparing it against existing vtables, and writing the - // resulting vtable offset. - uoffset_t EndTable(uoffset_t start) { - // If you get this assert, a corresponding StartTable wasn't called. - FLATBUFFERS_ASSERT(nested); - // Write the vtable offset, which is the start of any Table. - // We fill it's value later. - auto vtableoffsetloc = PushElement(0); - // Write a vtable, which consists entirely of voffset_t elements. - // It starts with the number of offsets, followed by a type id, followed - // by the offsets themselves. In reverse: - // Include space for the last offset and ensure empty tables have a - // minimum size. - max_voffset_ = - (std::max)(static_cast(max_voffset_ + sizeof(voffset_t)), - FieldIndexToOffset(0)); - buf_.fill_big(max_voffset_); - auto table_object_size = vtableoffsetloc - start; - // Vtable use 16bit offsets. - FLATBUFFERS_ASSERT(table_object_size < 0x10000); - WriteScalar(buf_.data() + sizeof(voffset_t), - static_cast(table_object_size)); - WriteScalar(buf_.data(), max_voffset_); - // Write the offsets into the table - for (auto it = buf_.scratch_end() - num_field_loc * sizeof(FieldLoc); - it < buf_.scratch_end(); it += sizeof(FieldLoc)) { - auto field_location = reinterpret_cast(it); - auto pos = static_cast(vtableoffsetloc - field_location->off); - // If this asserts, it means you've set a field twice. - FLATBUFFERS_ASSERT( - !ReadScalar(buf_.data() + field_location->id)); - WriteScalar(buf_.data() + field_location->id, pos); - } - ClearOffsets(); - auto vt1 = reinterpret_cast(buf_.data()); - auto vt1_size = ReadScalar(vt1); - auto vt_use = GetSize(); - // See if we already have generated a vtable with this exact same - // layout before. If so, make it point to the old one, remove this one. - if (dedup_vtables_) { - for (auto it = buf_.scratch_data(); it < buf_.scratch_end(); - it += sizeof(uoffset_t)) { - auto vt_offset_ptr = reinterpret_cast(it); - auto vt2 = reinterpret_cast(buf_.data_at(*vt_offset_ptr)); - auto vt2_size = ReadScalar(vt2); - if (vt1_size != vt2_size || 0 != memcmp(vt2, vt1, vt1_size)) continue; - vt_use = *vt_offset_ptr; - buf_.pop(GetSize() - vtableoffsetloc); - break; - } - } - // If this is a new vtable, remember it. - if (vt_use == GetSize()) { buf_.scratch_push_small(vt_use); } - // Fill the vtable offset we created above. - // The offset points from the beginning of the object to where the - // vtable is stored. - // Offsets default direction is downward in memory for future format - // flexibility (storing all vtables at the start of the file). - WriteScalar(buf_.data_at(vtableoffsetloc), - static_cast(vt_use) - - static_cast(vtableoffsetloc)); - - nested = false; - return vtableoffsetloc; - } - - FLATBUFFERS_ATTRIBUTE(deprecated("call the version above instead")) - uoffset_t EndTable(uoffset_t start, voffset_t /*numfields*/) { - return EndTable(start); - } - - // This checks a required field has been set in a given table that has - // just been constructed. - template void Required(Offset table, voffset_t field); - - uoffset_t StartStruct(size_t alignment) { - Align(alignment); - return GetSize(); - } - - uoffset_t EndStruct() { return GetSize(); } - - void ClearOffsets() { - buf_.scratch_pop(num_field_loc * sizeof(FieldLoc)); - num_field_loc = 0; - max_voffset_ = 0; - } - - // Aligns such that when "len" bytes are written, an object can be written - // after it with "alignment" without padding. - void PreAlign(size_t len, size_t alignment) { - TrackMinAlign(alignment); - buf_.fill(PaddingBytes(GetSize() + len, alignment)); - } - template void PreAlign(size_t len) { - AssertScalarT(); - PreAlign(len, sizeof(T)); - } - /// @endcond - - /// @brief Store a string in the buffer, which can contain any binary data. - /// @param[in] str A const char pointer to the data to be stored as a string. - /// @param[in] len The number of bytes that should be stored from `str`. - /// @return Returns the offset in the buffer where the string starts. - Offset CreateString(const char *str, size_t len) { - NotNested(); - PreAlign(len + 1); // Always 0-terminated. - buf_.fill(1); - PushBytes(reinterpret_cast(str), len); - PushElement(static_cast(len)); - return Offset(GetSize()); - } - - /// @brief Store a string in the buffer, which is null-terminated. - /// @param[in] str A const char pointer to a C-string to add to the buffer. - /// @return Returns the offset in the buffer where the string starts. - Offset CreateString(const char *str) { - return CreateString(str, strlen(str)); - } - - /// @brief Store a string in the buffer, which is null-terminated. - /// @param[in] str A char pointer to a C-string to add to the buffer. - /// @return Returns the offset in the buffer where the string starts. - Offset CreateString(char *str) { - return CreateString(str, strlen(str)); - } - - /// @brief Store a string in the buffer, which can contain any binary data. - /// @param[in] str A const reference to a std::string to store in the buffer. - /// @return Returns the offset in the buffer where the string starts. - Offset CreateString(const std::string &str) { - return CreateString(str.c_str(), str.length()); - } - - // clang-format off - #ifdef FLATBUFFERS_HAS_STRING_VIEW - /// @brief Store a string in the buffer, which can contain any binary data. - /// @param[in] str A const string_view to copy in to the buffer. - /// @return Returns the offset in the buffer where the string starts. - Offset CreateString(flatbuffers::string_view str) { - return CreateString(str.data(), str.size()); - } - #endif // FLATBUFFERS_HAS_STRING_VIEW - // clang-format on - - /// @brief Store a string in the buffer, which can contain any binary data. - /// @param[in] str A const pointer to a `String` struct to add to the buffer. - /// @return Returns the offset in the buffer where the string starts - Offset CreateString(const String *str) { - return str ? CreateString(str->c_str(), str->size()) : 0; - } - - /// @brief Store a string in the buffer, which can contain any binary data. - /// @param[in] str A const reference to a std::string like type with support - /// of T::c_str() and T::length() to store in the buffer. - /// @return Returns the offset in the buffer where the string starts. - template Offset CreateString(const T &str) { - return CreateString(str.c_str(), str.length()); - } - - /// @brief Store a string in the buffer, which can contain any binary data. - /// If a string with this exact contents has already been serialized before, - /// instead simply returns the offset of the existing string. - /// @param[in] str A const char pointer to the data to be stored as a string. - /// @param[in] len The number of bytes that should be stored from `str`. - /// @return Returns the offset in the buffer where the string starts. - Offset CreateSharedString(const char *str, size_t len) { - if (!string_pool) - string_pool = new StringOffsetMap(StringOffsetCompare(buf_)); - auto size_before_string = buf_.size(); - // Must first serialize the string, since the set is all offsets into - // buffer. - auto off = CreateString(str, len); - auto it = string_pool->find(off); - // If it exists we reuse existing serialized data! - if (it != string_pool->end()) { - // We can remove the string we serialized. - buf_.pop(buf_.size() - size_before_string); - return *it; - } - // Record this string for future use. - string_pool->insert(off); - return off; - } - -#ifdef FLATBUFFERS_HAS_STRING_VIEW - /// @brief Store a string in the buffer, which can contain any binary data. - /// If a string with this exact contents has already been serialized before, - /// instead simply returns the offset of the existing string. - /// @param[in] str A const std::string_view to store in the buffer. - /// @return Returns the offset in the buffer where the string starts - Offset CreateSharedString(const flatbuffers::string_view str) { - return CreateSharedString(str.data(), str.size()); - } -#else - /// @brief Store a string in the buffer, which null-terminated. - /// If a string with this exact contents has already been serialized before, - /// instead simply returns the offset of the existing string. - /// @param[in] str A const char pointer to a C-string to add to the buffer. - /// @return Returns the offset in the buffer where the string starts. - Offset CreateSharedString(const char *str) { - return CreateSharedString(str, strlen(str)); - } - - /// @brief Store a string in the buffer, which can contain any binary data. - /// If a string with this exact contents has already been serialized before, - /// instead simply returns the offset of the existing string. - /// @param[in] str A const reference to a std::string to store in the buffer. - /// @return Returns the offset in the buffer where the string starts. - Offset CreateSharedString(const std::string &str) { - return CreateSharedString(str.c_str(), str.length()); - } -#endif - - /// @brief Store a string in the buffer, which can contain any binary data. - /// If a string with this exact contents has already been serialized before, - /// instead simply returns the offset of the existing string. - /// @param[in] str A const pointer to a `String` struct to add to the buffer. - /// @return Returns the offset in the buffer where the string starts - Offset CreateSharedString(const String *str) { - return CreateSharedString(str->c_str(), str->size()); - } - - /// @cond FLATBUFFERS_INTERNAL - uoffset_t EndVector(size_t len) { - FLATBUFFERS_ASSERT(nested); // Hit if no corresponding StartVector. - nested = false; - return PushElement(static_cast(len)); - } - - void StartVector(size_t len, size_t elemsize) { - NotNested(); - nested = true; - PreAlign(len * elemsize); - PreAlign(len * elemsize, elemsize); // Just in case elemsize > uoffset_t. - } - - // Call this right before StartVector/CreateVector if you want to force the - // alignment to be something different than what the element size would - // normally dictate. - // This is useful when storing a nested_flatbuffer in a vector of bytes, - // or when storing SIMD floats, etc. - void ForceVectorAlignment(size_t len, size_t elemsize, size_t alignment) { - FLATBUFFERS_ASSERT(VerifyAlignmentRequirements(alignment)); - PreAlign(len * elemsize, alignment); - } - - // Similar to ForceVectorAlignment but for String fields. - void ForceStringAlignment(size_t len, size_t alignment) { - FLATBUFFERS_ASSERT(VerifyAlignmentRequirements(alignment)); - PreAlign((len + 1) * sizeof(char), alignment); - } - - /// @endcond - - /// @brief Serialize an array into a FlatBuffer `vector`. - /// @tparam T The data type of the array elements. - /// @param[in] v A pointer to the array of type `T` to serialize into the - /// buffer as a `vector`. - /// @param[in] len The number of elements to serialize. - /// @return Returns a typed `Offset` into the serialized data indicating - /// where the vector is stored. - template Offset> CreateVector(const T *v, size_t len) { - // If this assert hits, you're specifying a template argument that is - // causing the wrong overload to be selected, remove it. - AssertScalarT(); - StartVector(len, sizeof(T)); - if (len == 0) { return Offset>(EndVector(len)); } - // clang-format off - #if FLATBUFFERS_LITTLEENDIAN - PushBytes(reinterpret_cast(v), len * sizeof(T)); - #else - if (sizeof(T) == 1) { - PushBytes(reinterpret_cast(v), len); - } else { - for (auto i = len; i > 0; ) { - PushElement(v[--i]); - } - } - #endif - // clang-format on - return Offset>(EndVector(len)); - } - - template - Offset>> CreateVector(const Offset *v, size_t len) { - StartVector(len, sizeof(Offset)); - for (auto i = len; i > 0;) { PushElement(v[--i]); } - return Offset>>(EndVector(len)); - } - - /// @brief Serialize a `std::vector` into a FlatBuffer `vector`. - /// @tparam T The data type of the `std::vector` elements. - /// @param v A const reference to the `std::vector` to serialize into the - /// buffer as a `vector`. - /// @return Returns a typed `Offset` into the serialized data indicating - /// where the vector is stored. - template Offset> CreateVector(const std::vector &v) { - return CreateVector(data(v), v.size()); - } - - // vector may be implemented using a bit-set, so we can't access it as - // an array. Instead, read elements manually. - // Background: https://isocpp.org/blog/2012/11/on-vectorbool - Offset> CreateVector(const std::vector &v) { - StartVector(v.size(), sizeof(uint8_t)); - for (auto i = v.size(); i > 0;) { - PushElement(static_cast(v[--i])); - } - return Offset>(EndVector(v.size())); - } - - // clang-format off - #ifndef FLATBUFFERS_CPP98_STL - /// @brief Serialize values returned by a function into a FlatBuffer `vector`. - /// This is a convenience function that takes care of iteration for you. - /// @tparam T The data type of the `std::vector` elements. - /// @param f A function that takes the current iteration 0..vector_size-1 and - /// returns any type that you can construct a FlatBuffers vector out of. - /// @return Returns a typed `Offset` into the serialized data indicating - /// where the vector is stored. - template Offset> CreateVector(size_t vector_size, - const std::function &f) { - std::vector elems(vector_size); - for (size_t i = 0; i < vector_size; i++) elems[i] = f(i); - return CreateVector(elems); - } - #endif - // clang-format on - - /// @brief Serialize values returned by a function into a FlatBuffer `vector`. - /// This is a convenience function that takes care of iteration for you. - /// @tparam T The data type of the `std::vector` elements. - /// @param f A function that takes the current iteration 0..vector_size-1, - /// and the state parameter returning any type that you can construct a - /// FlatBuffers vector out of. - /// @param state State passed to f. - /// @return Returns a typed `Offset` into the serialized data indicating - /// where the vector is stored. - template - Offset> CreateVector(size_t vector_size, F f, S *state) { - std::vector elems(vector_size); - for (size_t i = 0; i < vector_size; i++) elems[i] = f(i, state); - return CreateVector(elems); - } - - /// @brief Serialize a `std::vector` into a FlatBuffer `vector`. - /// This is a convenience function for a common case. - /// @param v A const reference to the `std::vector` to serialize into the - /// buffer as a `vector`. - /// @return Returns a typed `Offset` into the serialized data indicating - /// where the vector is stored. - Offset>> CreateVectorOfStrings( - const std::vector &v) { - std::vector> offsets(v.size()); - for (size_t i = 0; i < v.size(); i++) offsets[i] = CreateString(v[i]); - return CreateVector(offsets); - } - - /// @brief Serialize an array of structs into a FlatBuffer `vector`. - /// @tparam T The data type of the struct array elements. - /// @param[in] v A pointer to the array of type `T` to serialize into the - /// buffer as a `vector`. - /// @param[in] len The number of elements to serialize. - /// @return Returns a typed `Offset` into the serialized data indicating - /// where the vector is stored. - template - Offset> CreateVectorOfStructs(const T *v, size_t len) { - StartVector(len * sizeof(T) / AlignOf(), AlignOf()); - PushBytes(reinterpret_cast(v), sizeof(T) * len); - return Offset>(EndVector(len)); - } - - /// @brief Serialize an array of native structs into a FlatBuffer `vector`. - /// @tparam T The data type of the struct array elements. - /// @tparam S The data type of the native struct array elements. - /// @param[in] v A pointer to the array of type `S` to serialize into the - /// buffer as a `vector`. - /// @param[in] len The number of elements to serialize. - /// @param[in] pack_func Pointer to a function to convert the native struct - /// to the FlatBuffer struct. - /// @return Returns a typed `Offset` into the serialized data indicating - /// where the vector is stored. - template - Offset> CreateVectorOfNativeStructs( - const S *v, size_t len, T((*const pack_func)(const S &))) { - FLATBUFFERS_ASSERT(pack_func); - std::vector vv(len); - std::transform(v, v + len, vv.begin(), pack_func); - return CreateVectorOfStructs(data(vv), vv.size()); - } - - /// @brief Serialize an array of native structs into a FlatBuffer `vector`. - /// @tparam T The data type of the struct array elements. - /// @tparam S The data type of the native struct array elements. - /// @param[in] v A pointer to the array of type `S` to serialize into the - /// buffer as a `vector`. - /// @param[in] len The number of elements to serialize. - /// @return Returns a typed `Offset` into the serialized data indicating - /// where the vector is stored. - template - Offset> CreateVectorOfNativeStructs(const S *v, - size_t len) { - extern T Pack(const S &); - return CreateVectorOfNativeStructs(v, len, Pack); - } - - // clang-format off - #ifndef FLATBUFFERS_CPP98_STL - /// @brief Serialize an array of structs into a FlatBuffer `vector`. - /// @tparam T The data type of the struct array elements. - /// @param[in] filler A function that takes the current iteration 0..vector_size-1 - /// and a pointer to the struct that must be filled. - /// @return Returns a typed `Offset` into the serialized data indicating - /// where the vector is stored. - /// This is mostly useful when flatbuffers are generated with mutation - /// accessors. - template Offset> CreateVectorOfStructs( - size_t vector_size, const std::function &filler) { - T* structs = StartVectorOfStructs(vector_size); - for (size_t i = 0; i < vector_size; i++) { - filler(i, structs); - structs++; - } - return EndVectorOfStructs(vector_size); - } - #endif - // clang-format on - - /// @brief Serialize an array of structs into a FlatBuffer `vector`. - /// @tparam T The data type of the struct array elements. - /// @param[in] f A function that takes the current iteration 0..vector_size-1, - /// a pointer to the struct that must be filled and the state argument. - /// @param[in] state Arbitrary state to pass to f. - /// @return Returns a typed `Offset` into the serialized data indicating - /// where the vector is stored. - /// This is mostly useful when flatbuffers are generated with mutation - /// accessors. - template - Offset> CreateVectorOfStructs(size_t vector_size, F f, - S *state) { - T *structs = StartVectorOfStructs(vector_size); - for (size_t i = 0; i < vector_size; i++) { - f(i, structs, state); - structs++; - } - return EndVectorOfStructs(vector_size); - } - - /// @brief Serialize a `std::vector` of structs into a FlatBuffer `vector`. - /// @tparam T The data type of the `std::vector` struct elements. - /// @param[in] v A const reference to the `std::vector` of structs to - /// serialize into the buffer as a `vector`. - /// @return Returns a typed `Offset` into the serialized data indicating - /// where the vector is stored. - template - Offset> CreateVectorOfStructs( - const std::vector &v) { - return CreateVectorOfStructs(data(v), v.size()); - } - - /// @brief Serialize a `std::vector` of native structs into a FlatBuffer - /// `vector`. - /// @tparam T The data type of the `std::vector` struct elements. - /// @tparam S The data type of the `std::vector` native struct elements. - /// @param[in] v A const reference to the `std::vector` of structs to - /// serialize into the buffer as a `vector`. - /// @param[in] pack_func Pointer to a function to convert the native struct - /// to the FlatBuffer struct. - /// @return Returns a typed `Offset` into the serialized data indicating - /// where the vector is stored. - template - Offset> CreateVectorOfNativeStructs( - const std::vector &v, T((*const pack_func)(const S &))) { - return CreateVectorOfNativeStructs(data(v), v.size(), pack_func); - } - - /// @brief Serialize a `std::vector` of native structs into a FlatBuffer - /// `vector`. - /// @tparam T The data type of the `std::vector` struct elements. - /// @tparam S The data type of the `std::vector` native struct elements. - /// @param[in] v A const reference to the `std::vector` of structs to - /// serialize into the buffer as a `vector`. - /// @return Returns a typed `Offset` into the serialized data indicating - /// where the vector is stored. - template - Offset> CreateVectorOfNativeStructs( - const std::vector &v) { - return CreateVectorOfNativeStructs(data(v), v.size()); - } - - /// @cond FLATBUFFERS_INTERNAL - template struct StructKeyComparator { - bool operator()(const T &a, const T &b) const { - return a.KeyCompareLessThan(&b); - } - - FLATBUFFERS_DELETE_FUNC( - StructKeyComparator &operator=(const StructKeyComparator &)); - }; - /// @endcond - - /// @brief Serialize a `std::vector` of structs into a FlatBuffer `vector` - /// in sorted order. - /// @tparam T The data type of the `std::vector` struct elements. - /// @param[in] v A const reference to the `std::vector` of structs to - /// serialize into the buffer as a `vector`. - /// @return Returns a typed `Offset` into the serialized data indicating - /// where the vector is stored. - template - Offset> CreateVectorOfSortedStructs(std::vector *v) { - return CreateVectorOfSortedStructs(data(*v), v->size()); - } - - /// @brief Serialize a `std::vector` of native structs into a FlatBuffer - /// `vector` in sorted order. - /// @tparam T The data type of the `std::vector` struct elements. - /// @tparam S The data type of the `std::vector` native struct elements. - /// @param[in] v A const reference to the `std::vector` of structs to - /// serialize into the buffer as a `vector`. - /// @return Returns a typed `Offset` into the serialized data indicating - /// where the vector is stored. - template - Offset> CreateVectorOfSortedNativeStructs( - std::vector *v) { - return CreateVectorOfSortedNativeStructs(data(*v), v->size()); - } - - /// @brief Serialize an array of structs into a FlatBuffer `vector` in sorted - /// order. - /// @tparam T The data type of the struct array elements. - /// @param[in] v A pointer to the array of type `T` to serialize into the - /// buffer as a `vector`. - /// @param[in] len The number of elements to serialize. - /// @return Returns a typed `Offset` into the serialized data indicating - /// where the vector is stored. - template - Offset> CreateVectorOfSortedStructs(T *v, size_t len) { - std::sort(v, v + len, StructKeyComparator()); - return CreateVectorOfStructs(v, len); - } - - /// @brief Serialize an array of native structs into a FlatBuffer `vector` in - /// sorted order. - /// @tparam T The data type of the struct array elements. - /// @tparam S The data type of the native struct array elements. - /// @param[in] v A pointer to the array of type `S` to serialize into the - /// buffer as a `vector`. - /// @param[in] len The number of elements to serialize. - /// @return Returns a typed `Offset` into the serialized data indicating - /// where the vector is stored. - template - Offset> CreateVectorOfSortedNativeStructs(S *v, - size_t len) { - extern T Pack(const S &); - typedef T (*Pack_t)(const S &); - std::vector vv(len); - std::transform(v, v + len, vv.begin(), static_cast(Pack)); - return CreateVectorOfSortedStructs(vv, len); - } - - /// @cond FLATBUFFERS_INTERNAL - template struct TableKeyComparator { - TableKeyComparator(vector_downward &buf) : buf_(buf) {} - TableKeyComparator(const TableKeyComparator &other) : buf_(other.buf_) {} - bool operator()(const Offset &a, const Offset &b) const { - auto table_a = reinterpret_cast(buf_.data_at(a.o)); - auto table_b = reinterpret_cast(buf_.data_at(b.o)); - return table_a->KeyCompareLessThan(table_b); - } - vector_downward &buf_; - - private: - FLATBUFFERS_DELETE_FUNC( - TableKeyComparator &operator=(const TableKeyComparator &other)); - }; - /// @endcond - - /// @brief Serialize an array of `table` offsets as a `vector` in the buffer - /// in sorted order. - /// @tparam T The data type that the offset refers to. - /// @param[in] v An array of type `Offset` that contains the `table` - /// offsets to store in the buffer in sorted order. - /// @param[in] len The number of elements to store in the `vector`. - /// @return Returns a typed `Offset` into the serialized data indicating - /// where the vector is stored. - template - Offset>> CreateVectorOfSortedTables(Offset *v, - size_t len) { - std::sort(v, v + len, TableKeyComparator(buf_)); - return CreateVector(v, len); - } - - /// @brief Serialize an array of `table` offsets as a `vector` in the buffer - /// in sorted order. - /// @tparam T The data type that the offset refers to. - /// @param[in] v An array of type `Offset` that contains the `table` - /// offsets to store in the buffer in sorted order. - /// @return Returns a typed `Offset` into the serialized data indicating - /// where the vector is stored. - template - Offset>> CreateVectorOfSortedTables( - std::vector> *v) { - return CreateVectorOfSortedTables(data(*v), v->size()); - } - - /// @brief Specialized version of `CreateVector` for non-copying use cases. - /// Write the data any time later to the returned buffer pointer `buf`. - /// @param[in] len The number of elements to store in the `vector`. - /// @param[in] elemsize The size of each element in the `vector`. - /// @param[out] buf A pointer to a `uint8_t` pointer that can be - /// written to at a later time to serialize the data into a `vector` - /// in the buffer. - uoffset_t CreateUninitializedVector(size_t len, size_t elemsize, - uint8_t **buf) { - NotNested(); - StartVector(len, elemsize); - buf_.make_space(len * elemsize); - auto vec_start = GetSize(); - auto vec_end = EndVector(len); - *buf = buf_.data_at(vec_start); - return vec_end; - } - - /// @brief Specialized version of `CreateVector` for non-copying use cases. - /// Write the data any time later to the returned buffer pointer `buf`. - /// @tparam T The data type of the data that will be stored in the buffer - /// as a `vector`. - /// @param[in] len The number of elements to store in the `vector`. - /// @param[out] buf A pointer to a pointer of type `T` that can be - /// written to at a later time to serialize the data into a `vector` - /// in the buffer. - template - Offset> CreateUninitializedVector(size_t len, T **buf) { - AssertScalarT(); - return CreateUninitializedVector(len, sizeof(T), - reinterpret_cast(buf)); - } - - template - Offset> CreateUninitializedVectorOfStructs(size_t len, - T **buf) { - return CreateUninitializedVector(len, sizeof(T), - reinterpret_cast(buf)); - } - - // @brief Create a vector of scalar type T given as input a vector of scalar - // type U, useful with e.g. pre "enum class" enums, or any existing scalar - // data of the wrong type. - template - Offset> CreateVectorScalarCast(const U *v, size_t len) { - AssertScalarT(); - AssertScalarT(); - StartVector(len, sizeof(T)); - for (auto i = len; i > 0;) { PushElement(static_cast(v[--i])); } - return Offset>(EndVector(len)); - } - - /// @brief Write a struct by itself, typically to be part of a union. - template Offset CreateStruct(const T &structobj) { - NotNested(); - Align(AlignOf()); - buf_.push_small(structobj); - return Offset(GetSize()); - } - - /// @brief The length of a FlatBuffer file header. - static const size_t kFileIdentifierLength = 4; - - /// @brief Finish serializing a buffer by writing the root offset. - /// @param[in] file_identifier If a `file_identifier` is given, the buffer - /// will be prefixed with a standard FlatBuffers file header. - template - void Finish(Offset root, const char *file_identifier = nullptr) { - Finish(root.o, file_identifier, false); - } - - /// @brief Finish a buffer with a 32 bit size field pre-fixed (size of the - /// buffer following the size field). These buffers are NOT compatible - /// with standard buffers created by Finish, i.e. you can't call GetRoot - /// on them, you have to use GetSizePrefixedRoot instead. - /// All >32 bit quantities in this buffer will be aligned when the whole - /// size pre-fixed buffer is aligned. - /// These kinds of buffers are useful for creating a stream of FlatBuffers. - template - void FinishSizePrefixed(Offset root, - const char *file_identifier = nullptr) { - Finish(root.o, file_identifier, true); - } - - void SwapBufAllocator(FlatBufferBuilder &other) { - buf_.swap_allocator(other.buf_); - } - - protected: - // You shouldn't really be copying instances of this class. - FlatBufferBuilder(const FlatBufferBuilder &); - FlatBufferBuilder &operator=(const FlatBufferBuilder &); - - void Finish(uoffset_t root, const char *file_identifier, bool size_prefix) { - NotNested(); - buf_.clear_scratch(); - // This will cause the whole buffer to be aligned. - PreAlign((size_prefix ? sizeof(uoffset_t) : 0) + sizeof(uoffset_t) + - (file_identifier ? kFileIdentifierLength : 0), - minalign_); - if (file_identifier) { - FLATBUFFERS_ASSERT(strlen(file_identifier) == kFileIdentifierLength); - PushBytes(reinterpret_cast(file_identifier), - kFileIdentifierLength); - } - PushElement(ReferTo(root)); // Location of root. - if (size_prefix) { PushElement(GetSize()); } - finished = true; - } - - struct FieldLoc { - uoffset_t off; - voffset_t id; - }; - - vector_downward buf_; - - // Accumulating offsets of table members while it is being built. - // We store these in the scratch pad of buf_, after the vtable offsets. - uoffset_t num_field_loc; - // Track how much of the vtable is in use, so we can output the most compact - // possible vtable. - voffset_t max_voffset_; - - // Ensure objects are not nested. - bool nested; - - // Ensure the buffer is finished before it is being accessed. - bool finished; - - size_t minalign_; - - bool force_defaults_; // Serialize values equal to their defaults anyway. - - bool dedup_vtables_; - - struct StringOffsetCompare { - StringOffsetCompare(const vector_downward &buf) : buf_(&buf) {} - bool operator()(const Offset &a, const Offset &b) const { - auto stra = reinterpret_cast(buf_->data_at(a.o)); - auto strb = reinterpret_cast(buf_->data_at(b.o)); - return StringLessThan(stra->data(), stra->size(), strb->data(), - strb->size()); - } - const vector_downward *buf_; - }; - - // For use with CreateSharedString. Instantiated on first use only. - typedef std::set, StringOffsetCompare> StringOffsetMap; - StringOffsetMap *string_pool; - - private: - // Allocates space for a vector of structures. - // Must be completed with EndVectorOfStructs(). - template T *StartVectorOfStructs(size_t vector_size) { - StartVector(vector_size * sizeof(T) / AlignOf(), AlignOf()); - return reinterpret_cast(buf_.make_space(vector_size * sizeof(T))); - } - - // End the vector of structues in the flatbuffers. - // Vector should have previously be started with StartVectorOfStructs(). - template - Offset> EndVectorOfStructs(size_t vector_size) { - return Offset>(EndVector(vector_size)); - } -}; -/// @} - -/// @cond FLATBUFFERS_INTERNAL -// Helpers to get a typed pointer to the root object contained in the buffer. -template T *GetMutableRoot(void *buf) { - EndianCheck(); - return reinterpret_cast( - reinterpret_cast(buf) + - EndianScalar(*reinterpret_cast(buf))); -} - -template const T *GetRoot(const void *buf) { - return GetMutableRoot(const_cast(buf)); -} - -template const T *GetSizePrefixedRoot(const void *buf) { - return GetRoot(reinterpret_cast(buf) + sizeof(uoffset_t)); -} - -/// Helpers to get a typed pointer to objects that are currently being built. -/// @warning Creating new objects will lead to reallocations and invalidates -/// the pointer! -template -T *GetMutableTemporaryPointer(FlatBufferBuilder &fbb, Offset offset) { - return reinterpret_cast(fbb.GetCurrentBufferPointer() + fbb.GetSize() - - offset.o); -} - -template -const T *GetTemporaryPointer(FlatBufferBuilder &fbb, Offset offset) { - return GetMutableTemporaryPointer(fbb, offset); -} - -/// @brief Get a pointer to the the file_identifier section of the buffer. -/// @return Returns a const char pointer to the start of the file_identifier -/// characters in the buffer. The returned char * has length -/// 'flatbuffers::FlatBufferBuilder::kFileIdentifierLength'. -/// This function is UNDEFINED for FlatBuffers whose schema does not include -/// a file_identifier (likely points at padding or the start of a the root -/// vtable). -inline const char *GetBufferIdentifier(const void *buf, - bool size_prefixed = false) { - return reinterpret_cast(buf) + - ((size_prefixed) ? 2 * sizeof(uoffset_t) : sizeof(uoffset_t)); -} - -// Helper to see if the identifier in a buffer has the expected value. -inline bool BufferHasIdentifier(const void *buf, const char *identifier, - bool size_prefixed = false) { - return strncmp(GetBufferIdentifier(buf, size_prefixed), identifier, - FlatBufferBuilder::kFileIdentifierLength) == 0; -} - -// Helper class to verify the integrity of a FlatBuffer -class Verifier FLATBUFFERS_FINAL_CLASS { - public: - Verifier(const uint8_t *buf, size_t buf_len, uoffset_t _max_depth = 64, - uoffset_t _max_tables = 1000000, bool _check_alignment = true) - : buf_(buf), - size_(buf_len), - depth_(0), - max_depth_(_max_depth), - num_tables_(0), - max_tables_(_max_tables), - upper_bound_(0), - check_alignment_(_check_alignment) { - FLATBUFFERS_ASSERT(size_ < FLATBUFFERS_MAX_BUFFER_SIZE); - } - - // Central location where any verification failures register. - bool Check(bool ok) const { - // clang-format off - #ifdef FLATBUFFERS_DEBUG_VERIFICATION_FAILURE - FLATBUFFERS_ASSERT(ok); - #endif - #ifdef FLATBUFFERS_TRACK_VERIFIER_BUFFER_SIZE - if (!ok) - upper_bound_ = 0; - #endif - // clang-format on - return ok; - } - - // Verify any range within the buffer. - bool Verify(size_t elem, size_t elem_len) const { - // clang-format off - #ifdef FLATBUFFERS_TRACK_VERIFIER_BUFFER_SIZE - auto upper_bound = elem + elem_len; - if (upper_bound_ < upper_bound) - upper_bound_ = upper_bound; - #endif - // clang-format on - return Check(elem_len < size_ && elem <= size_ - elem_len); - } - - template bool VerifyAlignment(size_t elem) const { - return Check((elem & (sizeof(T) - 1)) == 0 || !check_alignment_); - } - - // Verify a range indicated by sizeof(T). - template bool Verify(size_t elem) const { - return VerifyAlignment(elem) && Verify(elem, sizeof(T)); - } - - bool VerifyFromPointer(const uint8_t *p, size_t len) { - auto o = static_cast(p - buf_); - return Verify(o, len); - } - - // Verify relative to a known-good base pointer. - bool Verify(const uint8_t *base, voffset_t elem_off, size_t elem_len) const { - return Verify(static_cast(base - buf_) + elem_off, elem_len); - } - - template - bool Verify(const uint8_t *base, voffset_t elem_off) const { - return Verify(static_cast(base - buf_) + elem_off, sizeof(T)); - } - - // Verify a pointer (may be NULL) of a table type. - template bool VerifyTable(const T *table) { - return !table || table->Verify(*this); - } - - // Verify a pointer (may be NULL) of any vector type. - template bool VerifyVector(const Vector *vec) const { - return !vec || VerifyVectorOrString(reinterpret_cast(vec), - sizeof(T)); - } - - // Verify a pointer (may be NULL) of a vector to struct. - template bool VerifyVector(const Vector *vec) const { - return VerifyVector(reinterpret_cast *>(vec)); - } - - // Verify a pointer (may be NULL) to string. - bool VerifyString(const String *str) const { - size_t end; - return !str || (VerifyVectorOrString(reinterpret_cast(str), - 1, &end) && - Verify(end, 1) && // Must have terminator - Check(buf_[end] == '\0')); // Terminating byte must be 0. - } - - // Common code between vectors and strings. - bool VerifyVectorOrString(const uint8_t *vec, size_t elem_size, - size_t *end = nullptr) const { - auto veco = static_cast(vec - buf_); - // Check we can read the size field. - if (!Verify(veco)) return false; - // Check the whole array. If this is a string, the byte past the array - // must be 0. - auto size = ReadScalar(vec); - auto max_elems = FLATBUFFERS_MAX_BUFFER_SIZE / elem_size; - if (!Check(size < max_elems)) - return false; // Protect against byte_size overflowing. - auto byte_size = sizeof(size) + elem_size * size; - if (end) *end = veco + byte_size; - return Verify(veco, byte_size); - } - - // Special case for string contents, after the above has been called. - bool VerifyVectorOfStrings(const Vector> *vec) const { - if (vec) { - for (uoffset_t i = 0; i < vec->size(); i++) { - if (!VerifyString(vec->Get(i))) return false; - } - } - return true; - } - - // Special case for table contents, after the above has been called. - template bool VerifyVectorOfTables(const Vector> *vec) { - if (vec) { - for (uoffset_t i = 0; i < vec->size(); i++) { - if (!vec->Get(i)->Verify(*this)) return false; - } - } - return true; - } - - __supress_ubsan__("unsigned-integer-overflow") bool VerifyTableStart( - const uint8_t *table) { - // Check the vtable offset. - auto tableo = static_cast(table - buf_); - if (!Verify(tableo)) return false; - // This offset may be signed, but doing the subtraction unsigned always - // gives the result we want. - auto vtableo = tableo - static_cast(ReadScalar(table)); - // Check the vtable size field, then check vtable fits in its entirety. - return VerifyComplexity() && Verify(vtableo) && - VerifyAlignment(ReadScalar(buf_ + vtableo)) && - Verify(vtableo, ReadScalar(buf_ + vtableo)); - } - - template - bool VerifyBufferFromStart(const char *identifier, size_t start) { - if (identifier && !Check((size_ >= 2 * sizeof(flatbuffers::uoffset_t) && - BufferHasIdentifier(buf_ + start, identifier)))) { - return false; - } - - // Call T::Verify, which must be in the generated code for this type. - auto o = VerifyOffset(start); - return o && reinterpret_cast(buf_ + start + o)->Verify(*this) - // clang-format off - #ifdef FLATBUFFERS_TRACK_VERIFIER_BUFFER_SIZE - && GetComputedSize() - #endif - ; - // clang-format on - } - - // Verify this whole buffer, starting with root type T. - template bool VerifyBuffer() { return VerifyBuffer(nullptr); } - - template bool VerifyBuffer(const char *identifier) { - return VerifyBufferFromStart(identifier, 0); - } - - template bool VerifySizePrefixedBuffer(const char *identifier) { - return Verify(0U) && - ReadScalar(buf_) == size_ - sizeof(uoffset_t) && - VerifyBufferFromStart(identifier, sizeof(uoffset_t)); - } - - uoffset_t VerifyOffset(size_t start) const { - if (!Verify(start)) return 0; - auto o = ReadScalar(buf_ + start); - // May not point to itself. - if (!Check(o != 0)) return 0; - // Can't wrap around / buffers are max 2GB. - if (!Check(static_cast(o) >= 0)) return 0; - // Must be inside the buffer to create a pointer from it (pointer outside - // buffer is UB). - if (!Verify(start + o, 1)) return 0; - return o; - } - - uoffset_t VerifyOffset(const uint8_t *base, voffset_t start) const { - return VerifyOffset(static_cast(base - buf_) + start); - } - - // Called at the start of a table to increase counters measuring data - // structure depth and amount, and possibly bails out with false if - // limits set by the constructor have been hit. Needs to be balanced - // with EndTable(). - bool VerifyComplexity() { - depth_++; - num_tables_++; - return Check(depth_ <= max_depth_ && num_tables_ <= max_tables_); - } - - // Called at the end of a table to pop the depth count. - bool EndTable() { - depth_--; - return true; - } - - // Returns the message size in bytes - size_t GetComputedSize() const { - // clang-format off - #ifdef FLATBUFFERS_TRACK_VERIFIER_BUFFER_SIZE - uintptr_t size = upper_bound_; - // Align the size to uoffset_t - size = (size - 1 + sizeof(uoffset_t)) & ~(sizeof(uoffset_t) - 1); - return (size > size_) ? 0 : size; - #else - // Must turn on FLATBUFFERS_TRACK_VERIFIER_BUFFER_SIZE for this to work. - (void)upper_bound_; - FLATBUFFERS_ASSERT(false); - return 0; - #endif - // clang-format on - } - - private: - const uint8_t *buf_; - size_t size_; - uoffset_t depth_; - uoffset_t max_depth_; - uoffset_t num_tables_; - uoffset_t max_tables_; - mutable size_t upper_bound_; - bool check_alignment_; -}; - -// Convenient way to bundle a buffer and its length, to pass it around -// typed by its root. -// A BufferRef does not own its buffer. -struct BufferRefBase {}; // for std::is_base_of -template struct BufferRef : BufferRefBase { - BufferRef() : buf(nullptr), len(0), must_free(false) {} - BufferRef(uint8_t *_buf, uoffset_t _len) - : buf(_buf), len(_len), must_free(false) {} - - ~BufferRef() { - if (must_free) free(buf); - } - - const T *GetRoot() const { return flatbuffers::GetRoot(buf); } - - bool Verify() { - Verifier verifier(buf, len); - return verifier.VerifyBuffer(nullptr); - } - - uint8_t *buf; - uoffset_t len; - bool must_free; -}; - -// "structs" are flat structures that do not have an offset table, thus -// always have all members present and do not support forwards/backwards -// compatible extensions. - -class Struct FLATBUFFERS_FINAL_CLASS { - public: - template T GetField(uoffset_t o) const { - return ReadScalar(&data_[o]); - } - - template T GetStruct(uoffset_t o) const { - return reinterpret_cast(&data_[o]); - } - - const uint8_t *GetAddressOf(uoffset_t o) const { return &data_[o]; } - uint8_t *GetAddressOf(uoffset_t o) { return &data_[o]; } - - private: - // private constructor & copy constructor: you obtain instances of this - // class by pointing to existing data only - Struct(); - Struct(const Struct &); - Struct &operator=(const Struct &); - - uint8_t data_[1]; -}; - -// "tables" use an offset table (possibly shared) that allows fields to be -// omitted and added at will, but uses an extra indirection to read. -class Table { - public: - const uint8_t *GetVTable() const { - return data_ - ReadScalar(data_); - } - - // This gets the field offset for any of the functions below it, or 0 - // if the field was not present. - voffset_t GetOptionalFieldOffset(voffset_t field) const { - // The vtable offset is always at the start. - auto vtable = GetVTable(); - // The first element is the size of the vtable (fields + type id + itself). - auto vtsize = ReadScalar(vtable); - // If the field we're accessing is outside the vtable, we're reading older - // data, so it's the same as if the offset was 0 (not present). - return field < vtsize ? ReadScalar(vtable + field) : 0; - } - - template T GetField(voffset_t field, T defaultval) const { - auto field_offset = GetOptionalFieldOffset(field); - return field_offset ? ReadScalar(data_ + field_offset) : defaultval; - } - - template P GetPointer(voffset_t field) { - auto field_offset = GetOptionalFieldOffset(field); - auto p = data_ + field_offset; - return field_offset ? reinterpret_cast

(p + ReadScalar(p)) - : nullptr; - } - template P GetPointer(voffset_t field) const { - return const_cast(this)->GetPointer

(field); - } - - template P GetStruct(voffset_t field) const { - auto field_offset = GetOptionalFieldOffset(field); - auto p = const_cast(data_ + field_offset); - return field_offset ? reinterpret_cast

(p) : nullptr; - } - - template - flatbuffers::Optional GetOptional(voffset_t field) const { - auto field_offset = GetOptionalFieldOffset(field); - auto p = data_ + field_offset; - return field_offset ? Optional(static_cast(ReadScalar(p))) - : Optional(); - } - - template bool SetField(voffset_t field, T val, T def) { - auto field_offset = GetOptionalFieldOffset(field); - if (!field_offset) return IsTheSameAs(val, def); - WriteScalar(data_ + field_offset, val); - return true; - } - template bool SetField(voffset_t field, T val) { - auto field_offset = GetOptionalFieldOffset(field); - if (!field_offset) return false; - WriteScalar(data_ + field_offset, val); - return true; - } - - bool SetPointer(voffset_t field, const uint8_t *val) { - auto field_offset = GetOptionalFieldOffset(field); - if (!field_offset) return false; - WriteScalar(data_ + field_offset, - static_cast(val - (data_ + field_offset))); - return true; - } - - uint8_t *GetAddressOf(voffset_t field) { - auto field_offset = GetOptionalFieldOffset(field); - return field_offset ? data_ + field_offset : nullptr; - } - const uint8_t *GetAddressOf(voffset_t field) const { - return const_cast

(this)->GetAddressOf(field); - } - - bool CheckField(voffset_t field) const { - return GetOptionalFieldOffset(field) != 0; - } - - // Verify the vtable of this table. - // Call this once per table, followed by VerifyField once per field. - bool VerifyTableStart(Verifier &verifier) const { - return verifier.VerifyTableStart(data_); - } - - // Verify a particular field. - template - bool VerifyField(const Verifier &verifier, voffset_t field) const { - // Calling GetOptionalFieldOffset should be safe now thanks to - // VerifyTable(). - auto field_offset = GetOptionalFieldOffset(field); - // Check the actual field. - return !field_offset || verifier.Verify(data_, field_offset); - } - - // VerifyField for required fields. - template - bool VerifyFieldRequired(const Verifier &verifier, voffset_t field) const { - auto field_offset = GetOptionalFieldOffset(field); - return verifier.Check(field_offset != 0) && - verifier.Verify(data_, field_offset); - } - - // Versions for offsets. - bool VerifyOffset(const Verifier &verifier, voffset_t field) const { - auto field_offset = GetOptionalFieldOffset(field); - return !field_offset || verifier.VerifyOffset(data_, field_offset); - } - - bool VerifyOffsetRequired(const Verifier &verifier, voffset_t field) const { - auto field_offset = GetOptionalFieldOffset(field); - return verifier.Check(field_offset != 0) && - verifier.VerifyOffset(data_, field_offset); - } - - private: - // private constructor & copy constructor: you obtain instances of this - // class by pointing to existing data only - Table(); - Table(const Table &other); - Table &operator=(const Table &); - - uint8_t data_[1]; -}; - -// This specialization allows avoiding warnings like: -// MSVC C4800: type: forcing value to bool 'true' or 'false'. -template<> -inline flatbuffers::Optional Table::GetOptional( - voffset_t field) const { - auto field_offset = GetOptionalFieldOffset(field); - auto p = data_ + field_offset; - return field_offset ? Optional(ReadScalar(p) != 0) - : Optional(); -} - -template -void FlatBufferBuilder::Required(Offset table, voffset_t field) { - auto table_ptr = reinterpret_cast(buf_.data_at(table.o)); - bool ok = table_ptr->GetOptionalFieldOffset(field) != 0; - // If this fails, the caller will show what field needs to be set. - FLATBUFFERS_ASSERT(ok); - (void)ok; -} /// @brief This can compute the start of a FlatBuffer from a root pointer, i.e. /// it is the opposite transformation of GetRoot(). @@ -2719,7 +56,7 @@ inline const uint8_t *GetBufferStartFromRootPointer(const void *root) { // file_identifier, and alignment padding) to see which points to the root. // None of the other values can "impersonate" the root since they will either // be 0 or four ASCII characters. - static_assert(FlatBufferBuilder::kFileIdentifierLength == sizeof(uoffset_t), + static_assert(flatbuffers::kFileIdentifierLength == sizeof(uoffset_t), "file_identifier is assumed to be the same size as uoffset_t"); for (auto possible_roots = FLATBUFFERS_MAX_ALIGNMENT / sizeof(uoffset_t) + 1; possible_roots; possible_roots--) { @@ -2755,16 +92,9 @@ struct NativeTable {}; /// if you wish. The resolver does the opposite lookup, for when the object /// is being serialized again. typedef uint64_t hash_value_t; -// clang-format off -#ifdef FLATBUFFERS_CPP98_STL - typedef void (*resolver_function_t)(void **pointer_adr, hash_value_t hash); - typedef hash_value_t (*rehasher_function_t)(void *pointer); -#else - typedef std::function - resolver_function_t; - typedef std::function rehasher_function_t; -#endif -// clang-format on +typedef std::function + resolver_function_t; +typedef std::function rehasher_function_t; // Helper function to test if a field is present, using any of the field // enums in the generated code. @@ -2821,7 +151,7 @@ inline int LookupEnum(const char **names, const char *name) { // Minimal reflection via code generation. // Besides full-fat reflection (see reflection.h) and parsing/printing by -// loading schemas (see idl.h), we can also have code generation for mimimal +// loading schemas (see idl.h), we can also have code generation for minimal // reflection data which allows pretty-printing and other uses without needing // a schema or a parser. // Generate code with --reflect-types (types only) or --reflect-names (names @@ -2896,27 +226,13 @@ struct TypeTable { }; // String which identifies the current version of FlatBuffers. -// flatbuffer_version_string is used by Google developers to identify which -// applications uploaded to Google Play are using this library. This allows -// the development team at Google to determine the popularity of the library. -// How it works: Applications that are uploaded to the Google Play Store are -// scanned for this version string. We track which applications are using it -// to measure popularity. You are free to remove it (of course) but we would -// appreciate if you left it in. +inline const char *flatbuffers_version_string() { + return "FlatBuffers " FLATBUFFERS_STRING(FLATBUFFERS_VERSION_MAJOR) "." + FLATBUFFERS_STRING(FLATBUFFERS_VERSION_MINOR) "." + FLATBUFFERS_STRING(FLATBUFFERS_VERSION_REVISION); +} -// Weak linkage is culled by VS & doesn't work on cygwin. // clang-format off -#if !defined(_WIN32) && !defined(__CYGWIN__) - -extern volatile __attribute__((weak)) const char *flatbuffer_version_string; -volatile __attribute__((weak)) const char *flatbuffer_version_string = - "FlatBuffers " - FLATBUFFERS_STRING(FLATBUFFERS_VERSION_MAJOR) "." - FLATBUFFERS_STRING(FLATBUFFERS_VERSION_MINOR) "." - FLATBUFFERS_STRING(FLATBUFFERS_VERSION_REVISION); - -#endif // !defined(_WIN32) && !defined(__CYGWIN__) - #define FLATBUFFERS_DEFINE_BITMASK_OPERATORS(E, T)\ inline E operator | (E lhs, E rhs){\ return E(T(lhs) | T(rhs));\ diff --git a/thirdparty/flatbuffers/stl_emulation.h b/thirdparty/flatbuffers/stl_emulation.h index 70e5dc944e..452ddb832f 100644 --- a/thirdparty/flatbuffers/stl_emulation.h +++ b/thirdparty/flatbuffers/stl_emulation.h @@ -26,36 +26,33 @@ #include #include -#if defined(_STLPORT_VERSION) && !defined(FLATBUFFERS_CPP98_STL) - #define FLATBUFFERS_CPP98_STL -#endif // defined(_STLPORT_VERSION) && !defined(FLATBUFFERS_CPP98_STL) +#ifndef FLATBUFFERS_USE_STD_OPTIONAL + // Detect C++17 compatible compiler. + // __cplusplus >= 201703L - a compiler has support of 'static inline' variables. + #if (defined(__cplusplus) && __cplusplus >= 201703L) \ + || (defined(_MSVC_LANG) && _MSVC_LANG >= 201703L) + #define FLATBUFFERS_USE_STD_OPTIONAL 1 + #else + #define FLATBUFFERS_USE_STD_OPTIONAL 0 + #endif // (defined(__cplusplus) && __cplusplus >= 201703L) ... +#endif // FLATBUFFERS_USE_STD_OPTIONAL -#if defined(FLATBUFFERS_CPP98_STL) - #include -#endif // defined(FLATBUFFERS_CPP98_STL) - -// Detect C++17 compatible compiler. -// __cplusplus >= 201703L - a compiler has support of 'static inline' variables. -#if defined(FLATBUFFERS_USE_STD_OPTIONAL) \ - || (defined(__cplusplus) && __cplusplus >= 201703L) \ - || (defined(_MSVC_LANG) && (_MSVC_LANG >= 201703L)) +#if FLATBUFFERS_USE_STD_OPTIONAL #include - #ifndef FLATBUFFERS_USE_STD_OPTIONAL - #define FLATBUFFERS_USE_STD_OPTIONAL - #endif -#endif // defined(FLATBUFFERS_USE_STD_OPTIONAL) ... +#endif // The __cpp_lib_span is the predefined feature macro. #if defined(FLATBUFFERS_USE_STD_SPAN) #include #elif defined(__cpp_lib_span) && defined(__has_include) #if __has_include() + #include #include #define FLATBUFFERS_USE_STD_SPAN #endif #else // Disable non-trivial ctors if FLATBUFFERS_SPAN_MINIMAL defined. - #if !defined(FLATBUFFERS_TEMPLATES_ALIASES) || defined(FLATBUFFERS_CPP98_STL) + #if !defined(FLATBUFFERS_TEMPLATES_ALIASES) #define FLATBUFFERS_SPAN_MINIMAL #else // Enable implicit construction of a span from a std::array. @@ -63,135 +60,32 @@ #endif #endif // defined(FLATBUFFERS_USE_STD_SPAN) -// This header provides backwards compatibility for C++98 STLs like stlport. +// This header provides backwards compatibility for older versions of the STL. namespace flatbuffers { -// Retrieve ::back() from a string in a way that is compatible with pre C++11 -// STLs (e.g stlport). -inline char& string_back(std::string &value) { - return value[value.length() - 1]; -} - -inline char string_back(const std::string &value) { - return value[value.length() - 1]; -} - -// Helper method that retrieves ::data() from a vector in a way that is -// compatible with pre C++11 STLs (e.g stlport). -template inline T *vector_data(std::vector &vector) { - // In some debug environments, operator[] does bounds checking, so &vector[0] - // can't be used. - return vector.empty() ? nullptr : &vector[0]; -} - -template inline const T *vector_data( - const std::vector &vector) { - return vector.empty() ? nullptr : &vector[0]; -} - -template -inline void vector_emplace_back(std::vector *vector, V &&data) { - #if defined(FLATBUFFERS_CPP98_STL) - vector->push_back(data); - #else - vector->emplace_back(std::forward(data)); - #endif // defined(FLATBUFFERS_CPP98_STL) -} - -#ifndef FLATBUFFERS_CPP98_STL - #if defined(FLATBUFFERS_TEMPLATES_ALIASES) - template - using numeric_limits = std::numeric_limits; - #else - template class numeric_limits : - public std::numeric_limits {}; - #endif // defined(FLATBUFFERS_TEMPLATES_ALIASES) +#if defined(FLATBUFFERS_TEMPLATES_ALIASES) + template + using numeric_limits = std::numeric_limits; #else template class numeric_limits : - public std::numeric_limits { - public: - // Android NDK fix. - static T lowest() { - return std::numeric_limits::min(); - } - }; - - template <> class numeric_limits : - public std::numeric_limits { - public: - static float lowest() { return -FLT_MAX; } - }; - - template <> class numeric_limits : - public std::numeric_limits { - public: - static double lowest() { return -DBL_MAX; } - }; - - template <> class numeric_limits { - public: - static unsigned long long min() { return 0ULL; } - static unsigned long long max() { return ~0ULL; } - static unsigned long long lowest() { - return numeric_limits::min(); - } - }; - - template <> class numeric_limits { - public: - static long long min() { - return static_cast(1ULL << ((sizeof(long long) << 3) - 1)); - } - static long long max() { - return static_cast( - (1ULL << ((sizeof(long long) << 3) - 1)) - 1); - } - static long long lowest() { - return numeric_limits::min(); - } - }; -#endif // FLATBUFFERS_CPP98_STL + public std::numeric_limits {}; +#endif // defined(FLATBUFFERS_TEMPLATES_ALIASES) #if defined(FLATBUFFERS_TEMPLATES_ALIASES) - #ifndef FLATBUFFERS_CPP98_STL - template using is_scalar = std::is_scalar; - template using is_same = std::is_same; - template using is_floating_point = std::is_floating_point; - template using is_unsigned = std::is_unsigned; - template using is_enum = std::is_enum; - template using make_unsigned = std::make_unsigned; - template - using conditional = std::conditional; - template - using integral_constant = std::integral_constant; - template - using bool_constant = integral_constant; - #else - // Map C++ TR1 templates defined by stlport. - template using is_scalar = std::tr1::is_scalar; - template using is_same = std::tr1::is_same; - template using is_floating_point = - std::tr1::is_floating_point; - template using is_unsigned = std::tr1::is_unsigned; - template using is_enum = std::tr1::is_enum; - // Android NDK doesn't have std::make_unsigned or std::tr1::make_unsigned. - template struct make_unsigned { - static_assert(is_unsigned::value, "Specialization not implemented!"); - using type = T; - }; - template<> struct make_unsigned { using type = unsigned char; }; - template<> struct make_unsigned { using type = unsigned short; }; - template<> struct make_unsigned { using type = unsigned int; }; - template<> struct make_unsigned { using type = unsigned long; }; - template<> - struct make_unsigned { using type = unsigned long long; }; - template - using conditional = std::tr1::conditional; - template - using integral_constant = std::tr1::integral_constant; - template - using bool_constant = integral_constant; - #endif // !FLATBUFFERS_CPP98_STL + template using is_scalar = std::is_scalar; + template using is_same = std::is_same; + template using is_floating_point = std::is_floating_point; + template using is_unsigned = std::is_unsigned; + template using is_enum = std::is_enum; + template using make_unsigned = std::make_unsigned; + template + using conditional = std::conditional; + template + using integral_constant = std::integral_constant; + template + using bool_constant = integral_constant; + using true_type = std::true_type; + using false_type = std::false_type; #else // MSVC 2010 doesn't support C++11 aliases. template struct is_scalar : public std::is_scalar {}; @@ -207,128 +101,39 @@ inline void vector_emplace_back(std::vector *vector, V &&data) { struct integral_constant : public std::integral_constant {}; template struct bool_constant : public integral_constant {}; + typedef bool_constant true_type; + typedef bool_constant false_type; #endif // defined(FLATBUFFERS_TEMPLATES_ALIASES) -#ifndef FLATBUFFERS_CPP98_STL - #if defined(FLATBUFFERS_TEMPLATES_ALIASES) - template using unique_ptr = std::unique_ptr; - #else - // MSVC 2010 doesn't support C++11 aliases. - // We're manually "aliasing" the class here as we want to bring unique_ptr - // into the flatbuffers namespace. We have unique_ptr in the flatbuffers - // namespace we have a completely independent implementation (see below) - // for C++98 STL implementations. - template class unique_ptr : public std::unique_ptr { - public: - unique_ptr() {} - explicit unique_ptr(T* p) : std::unique_ptr(p) {} - unique_ptr(std::unique_ptr&& u) { *this = std::move(u); } - unique_ptr(unique_ptr&& u) { *this = std::move(u); } - unique_ptr& operator=(std::unique_ptr&& u) { - std::unique_ptr::reset(u.release()); - return *this; - } - unique_ptr& operator=(unique_ptr&& u) { - std::unique_ptr::reset(u.release()); - return *this; - } - unique_ptr& operator=(T* p) { - return std::unique_ptr::operator=(p); - } - }; - #endif // defined(FLATBUFFERS_TEMPLATES_ALIASES) +#if defined(FLATBUFFERS_TEMPLATES_ALIASES) + template using unique_ptr = std::unique_ptr; #else - // Very limited implementation of unique_ptr. - // This is provided simply to allow the C++ code generated from the default - // settings to function in C++98 environments with no modifications. - template class unique_ptr { - public: - typedef T element_type; - - unique_ptr() : ptr_(nullptr) {} - explicit unique_ptr(T* p) : ptr_(p) {} - unique_ptr(unique_ptr&& u) : ptr_(nullptr) { reset(u.release()); } - unique_ptr(const unique_ptr& u) : ptr_(nullptr) { - reset(const_cast(&u)->release()); - } - ~unique_ptr() { reset(); } - - unique_ptr& operator=(const unique_ptr& u) { - reset(const_cast(&u)->release()); + // MSVC 2010 doesn't support C++11 aliases. + // We're manually "aliasing" the class here as we want to bring unique_ptr + // into the flatbuffers namespace. We have unique_ptr in the flatbuffers + // namespace we have a completely independent implementation (see below) + // for C++98 STL implementations. + template class unique_ptr : public std::unique_ptr { + public: + unique_ptr() {} + explicit unique_ptr(T* p) : std::unique_ptr(p) {} + unique_ptr(std::unique_ptr&& u) { *this = std::move(u); } + unique_ptr(unique_ptr&& u) { *this = std::move(u); } + unique_ptr& operator=(std::unique_ptr&& u) { + std::unique_ptr::reset(u.release()); return *this; } - unique_ptr& operator=(unique_ptr&& u) { - reset(u.release()); + std::unique_ptr::reset(u.release()); return *this; } - unique_ptr& operator=(T* p) { - reset(p); - return *this; + return std::unique_ptr::operator=(p); } - - const T& operator*() const { return *ptr_; } - T* operator->() const { return ptr_; } - T* get() const noexcept { return ptr_; } - explicit operator bool() const { return ptr_ != nullptr; } - - // modifiers - T* release() { - T* value = ptr_; - ptr_ = nullptr; - return value; - } - - void reset(T* p = nullptr) { - T* value = ptr_; - ptr_ = p; - if (value) delete value; - } - - void swap(unique_ptr& u) { - T* temp_ptr = ptr_; - ptr_ = u.ptr_; - u.ptr_ = temp_ptr; - } - - private: - T* ptr_; }; +#endif // defined(FLATBUFFERS_TEMPLATES_ALIASES) - template bool operator==(const unique_ptr& x, - const unique_ptr& y) { - return x.get() == y.get(); - } - - template bool operator==(const unique_ptr& x, - const D* y) { - return static_cast(x.get()) == y; - } - - template bool operator==(const unique_ptr& x, intptr_t y) { - return reinterpret_cast(x.get()) == y; - } - - template bool operator!=(const unique_ptr& x, decltype(nullptr)) { - return !!x; - } - - template bool operator!=(decltype(nullptr), const unique_ptr& x) { - return !!x; - } - - template bool operator==(const unique_ptr& x, decltype(nullptr)) { - return !x; - } - - template bool operator==(decltype(nullptr), const unique_ptr& x) { - return !x; - } - -#endif // !FLATBUFFERS_CPP98_STL - -#ifdef FLATBUFFERS_USE_STD_OPTIONAL +#if FLATBUFFERS_USE_STD_OPTIONAL template using Optional = std::optional; using nullopt_t = std::nullopt_t; @@ -484,17 +289,43 @@ FLATBUFFERS_CONSTEXPR std::size_t dynamic_extent = static_cast(-1); namespace internal { // This is SFINAE helper class for checking of a common condition: // > This overload only participates in overload resolution - // > Check whether a pointer to an array of U can be converted - // > to a pointer to an array of E. - // This helper is used for checking of 'U -> const U'. - template - struct is_span_convertable { + // > Check whether a pointer to an array of From can be converted + // > to a pointer to an array of To. + // This helper is used for checking of 'From -> const From'. + template + struct is_span_convertible { using type = - typename std::conditional::value + typename std::conditional::value && (Extent == dynamic_extent || N == Extent), int, void>::type; }; + template + struct SpanIterator { + // TODO: upgrade to std::random_access_iterator_tag. + using iterator_category = std::forward_iterator_tag; + using difference_type = std::ptrdiff_t; + using value_type = typename std::remove_cv::type; + using reference = T&; + using pointer = T*; + + // Convince MSVC compiler that this iterator is trusted (it is verified). + #ifdef _MSC_VER + using _Unchecked_type = pointer; + #endif // _MSC_VER + + SpanIterator(pointer ptr) : ptr_(ptr) {} + reference operator*() const { return *ptr_; } + pointer operator->() { return ptr_; } + SpanIterator& operator++() { ptr_++; return *this; } + SpanIterator operator++(int) { auto tmp = *this; ++(*this); return tmp; } + + friend bool operator== (const SpanIterator& lhs, const SpanIterator& rhs) { return lhs.ptr_ == rhs.ptr_; } + friend bool operator!= (const SpanIterator& lhs, const SpanIterator& rhs) { return lhs.ptr_ != rhs.ptr_; } + + private: + pointer ptr_; + }; } // namespace internal #endif // !defined(FLATBUFFERS_SPAN_MINIMAL) @@ -534,6 +365,13 @@ class span FLATBUFFERS_FINAL_CLASS { return data_; } + #if !defined(FLATBUFFERS_SPAN_MINIMAL) + using Iterator = internal::SpanIterator; + + Iterator begin() const { return Iterator(data()); } + Iterator end() const { return Iterator(data() + size()); } + #endif + // Returns a reference to the idx-th element of the sequence. // The behavior is undefined if the idx is greater than or equal to size(). FLATBUFFERS_CONSTEXPR_CPP11 reference operator[](size_type idx) const { @@ -577,7 +415,7 @@ class span FLATBUFFERS_FINAL_CLASS { // extent == 0 || extent == flatbuffers::dynamic_extent. // A dummy template argument N is need dependency for SFINAE. template::type = 0> + typename internal::is_span_convertible::type = 0> FLATBUFFERS_CONSTEXPR_CPP11 span() FLATBUFFERS_NOEXCEPT : data_(nullptr), count_(0) { static_assert(extent == 0 || extent == dynamic_extent, "invalid span"); @@ -590,12 +428,12 @@ class span FLATBUFFERS_FINAL_CLASS { // std::remove_pointer_t(*)[] // is convertible to element_type (*)[]. template::type = 0> + typename internal::is_span_convertible::type = 0> FLATBUFFERS_CONSTEXPR_CPP11 span(element_type (&arr)[N]) FLATBUFFERS_NOEXCEPT : data_(arr), count_(N) {} template::type = 0> + typename internal::is_span_convertible::type = 0> FLATBUFFERS_CONSTEXPR_CPP11 span(std::array &arr) FLATBUFFERS_NOEXCEPT : data_(arr.data()), count_(N) {} @@ -605,7 +443,7 @@ class span FLATBUFFERS_FINAL_CLASS { // : data_(arr.data()), count_(N) {} template::type = 0> + typename internal::is_span_convertible::type = 0> FLATBUFFERS_CONSTEXPR_CPP11 span(const std::array &arr) FLATBUFFERS_NOEXCEPT : data_(arr.data()), count_(N) {} @@ -615,7 +453,7 @@ class span FLATBUFFERS_FINAL_CLASS { // if extent == std::dynamic_extent || N == extent is true and U (*)[] // is convertible to element_type (*)[]. template::type = 0> + typename internal::is_span_convertible::type = 0> FLATBUFFERS_CONSTEXPR_CPP11 span(const flatbuffers::span &s) FLATBUFFERS_NOEXCEPT : span(s.data(), s.size()) { } @@ -625,49 +463,48 @@ class span FLATBUFFERS_FINAL_CLASS { private: // This is a naive implementation with 'count_' member even if (Extent != dynamic_extent). pointer const data_; - const size_type count_; + size_type count_; }; - - #if !defined(FLATBUFFERS_SPAN_MINIMAL) - template - FLATBUFFERS_CONSTEXPR_CPP11 - flatbuffers::span make_span(U(&arr)[N]) FLATBUFFERS_NOEXCEPT { - return span(arr); - } - - template - FLATBUFFERS_CONSTEXPR_CPP11 - flatbuffers::span make_span(const U(&arr)[N]) FLATBUFFERS_NOEXCEPT { - return span(arr); - } - - template - FLATBUFFERS_CONSTEXPR_CPP11 - flatbuffers::span make_span(std::array &arr) FLATBUFFERS_NOEXCEPT { - return span(arr); - } - - template - FLATBUFFERS_CONSTEXPR_CPP11 - flatbuffers::span make_span(const std::array &arr) FLATBUFFERS_NOEXCEPT { - return span(arr); - } - - template - FLATBUFFERS_CONSTEXPR_CPP11 - flatbuffers::span make_span(U *first, std::size_t count) FLATBUFFERS_NOEXCEPT { - return span(first, count); - } - - template - FLATBUFFERS_CONSTEXPR_CPP11 - flatbuffers::span make_span(const U *first, std::size_t count) FLATBUFFERS_NOEXCEPT { - return span(first, count); - } -#endif - #endif // defined(FLATBUFFERS_USE_STD_SPAN) +#if !defined(FLATBUFFERS_SPAN_MINIMAL) +template +FLATBUFFERS_CONSTEXPR_CPP11 +flatbuffers::span make_span(ElementType(&arr)[Extent]) FLATBUFFERS_NOEXCEPT { + return span(arr); +} + +template +FLATBUFFERS_CONSTEXPR_CPP11 +flatbuffers::span make_span(const ElementType(&arr)[Extent]) FLATBUFFERS_NOEXCEPT { + return span(arr); +} + +template +FLATBUFFERS_CONSTEXPR_CPP11 +flatbuffers::span make_span(std::array &arr) FLATBUFFERS_NOEXCEPT { + return span(arr); +} + +template +FLATBUFFERS_CONSTEXPR_CPP11 +flatbuffers::span make_span(const std::array &arr) FLATBUFFERS_NOEXCEPT { + return span(arr); +} + +template +FLATBUFFERS_CONSTEXPR_CPP11 +flatbuffers::span make_span(ElementType *first, std::size_t count) FLATBUFFERS_NOEXCEPT { + return span(first, count); +} + +template +FLATBUFFERS_CONSTEXPR_CPP11 +flatbuffers::span make_span(const ElementType *first, std::size_t count) FLATBUFFERS_NOEXCEPT { + return span(first, count); +} +#endif // !defined(FLATBUFFERS_SPAN_MINIMAL) + } // namespace flatbuffers #endif // FLATBUFFERS_STL_EMULATION_H_ diff --git a/thirdparty/flatbuffers/string.h b/thirdparty/flatbuffers/string.h new file mode 100644 index 0000000000..3db95fce1b --- /dev/null +++ b/thirdparty/flatbuffers/string.h @@ -0,0 +1,64 @@ +/* + * Copyright 2021 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. + */ + +#ifndef FLATBUFFERS_STRING_H_ +#define FLATBUFFERS_STRING_H_ + +#include "flatbuffers/base.h" +#include "flatbuffers/vector.h" + +namespace flatbuffers { + +struct String : public Vector { + const char *c_str() const { return reinterpret_cast(Data()); } + std::string str() const { return std::string(c_str(), size()); } + + // clang-format off + #ifdef FLATBUFFERS_HAS_STRING_VIEW + flatbuffers::string_view string_view() const { + return flatbuffers::string_view(c_str(), size()); + } + #endif // FLATBUFFERS_HAS_STRING_VIEW + // clang-format on + + bool operator<(const String &o) const { + return StringLessThan(this->data(), this->size(), o.data(), o.size()); + } +}; + +// Convenience function to get std::string from a String returning an empty +// string on null pointer. +static inline std::string GetString(const String *str) { + return str ? str->str() : ""; +} + +// Convenience function to get char* from a String returning an empty string on +// null pointer. +static inline const char *GetCstring(const String *str) { + return str ? str->c_str() : ""; +} + +#ifdef FLATBUFFERS_HAS_STRING_VIEW +// Convenience function to get string_view from a String returning an empty +// string_view on null pointer. +static inline flatbuffers::string_view GetStringView(const String *str) { + return str ? str->string_view() : flatbuffers::string_view(); +} +#endif // FLATBUFFERS_HAS_STRING_VIEW + +} // namespace flatbuffers + +#endif // FLATBUFFERS_STRING_H_ \ No newline at end of file diff --git a/thirdparty/flatbuffers/struct.h b/thirdparty/flatbuffers/struct.h new file mode 100644 index 0000000000..d8753c84f0 --- /dev/null +++ b/thirdparty/flatbuffers/struct.h @@ -0,0 +1,53 @@ +/* + * Copyright 2021 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. + */ + +#ifndef FLATBUFFERS_STRUCT_H_ +#define FLATBUFFERS_STRUCT_H_ + +#include "flatbuffers/base.h" + +namespace flatbuffers { + +// "structs" are flat structures that do not have an offset table, thus +// always have all members present and do not support forwards/backwards +// compatible extensions. + +class Struct FLATBUFFERS_FINAL_CLASS { + public: + template T GetField(uoffset_t o) const { + return ReadScalar(&data_[o]); + } + + template T GetStruct(uoffset_t o) const { + return reinterpret_cast(&data_[o]); + } + + const uint8_t *GetAddressOf(uoffset_t o) const { return &data_[o]; } + uint8_t *GetAddressOf(uoffset_t o) { return &data_[o]; } + + private: + // private constructor & copy constructor: you obtain instances of this + // class by pointing to existing data only + Struct(); + Struct(const Struct &); + Struct &operator=(const Struct &); + + uint8_t data_[1]; +}; + +} // namespace flatbuffers + +#endif // FLATBUFFERS_STRUCT_H_ \ No newline at end of file diff --git a/thirdparty/flatbuffers/table.h b/thirdparty/flatbuffers/table.h new file mode 100644 index 0000000000..11b292476b --- /dev/null +++ b/thirdparty/flatbuffers/table.h @@ -0,0 +1,168 @@ +/* + * Copyright 2021 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. + */ + +#ifndef FLATBUFFERS_TABLE_H_ +#define FLATBUFFERS_TABLE_H_ + +#include "flatbuffers/base.h" +#include "flatbuffers/verifier.h" + +namespace flatbuffers { + +// "tables" use an offset table (possibly shared) that allows fields to be +// omitted and added at will, but uses an extra indirection to read. +class Table { + public: + const uint8_t *GetVTable() const { + return data_ - ReadScalar(data_); + } + + // This gets the field offset for any of the functions below it, or 0 + // if the field was not present. + voffset_t GetOptionalFieldOffset(voffset_t field) const { + // The vtable offset is always at the start. + auto vtable = GetVTable(); + // The first element is the size of the vtable (fields + type id + itself). + auto vtsize = ReadScalar(vtable); + // If the field we're accessing is outside the vtable, we're reading older + // data, so it's the same as if the offset was 0 (not present). + return field < vtsize ? ReadScalar(vtable + field) : 0; + } + + template T GetField(voffset_t field, T defaultval) const { + auto field_offset = GetOptionalFieldOffset(field); + return field_offset ? ReadScalar(data_ + field_offset) : defaultval; + } + + template P GetPointer(voffset_t field) { + auto field_offset = GetOptionalFieldOffset(field); + auto p = data_ + field_offset; + return field_offset ? reinterpret_cast

(p + ReadScalar(p)) + : nullptr; + } + template P GetPointer(voffset_t field) const { + return const_cast

(this)->GetPointer

(field); + } + + template P GetStruct(voffset_t field) const { + auto field_offset = GetOptionalFieldOffset(field); + auto p = const_cast(data_ + field_offset); + return field_offset ? reinterpret_cast

(p) : nullptr; + } + + template + flatbuffers::Optional GetOptional(voffset_t field) const { + auto field_offset = GetOptionalFieldOffset(field); + auto p = data_ + field_offset; + return field_offset ? Optional(static_cast(ReadScalar(p))) + : Optional(); + } + + template bool SetField(voffset_t field, T val, T def) { + auto field_offset = GetOptionalFieldOffset(field); + if (!field_offset) return IsTheSameAs(val, def); + WriteScalar(data_ + field_offset, val); + return true; + } + template bool SetField(voffset_t field, T val) { + auto field_offset = GetOptionalFieldOffset(field); + if (!field_offset) return false; + WriteScalar(data_ + field_offset, val); + return true; + } + + bool SetPointer(voffset_t field, const uint8_t *val) { + auto field_offset = GetOptionalFieldOffset(field); + if (!field_offset) return false; + WriteScalar(data_ + field_offset, + static_cast(val - (data_ + field_offset))); + return true; + } + + uint8_t *GetAddressOf(voffset_t field) { + auto field_offset = GetOptionalFieldOffset(field); + return field_offset ? data_ + field_offset : nullptr; + } + const uint8_t *GetAddressOf(voffset_t field) const { + return const_cast

(this)->GetAddressOf(field); + } + + bool CheckField(voffset_t field) const { + return GetOptionalFieldOffset(field) != 0; + } + + // Verify the vtable of this table. + // Call this once per table, followed by VerifyField once per field. + bool VerifyTableStart(Verifier &verifier) const { + return verifier.VerifyTableStart(data_); + } + + // Verify a particular field. + template + bool VerifyField(const Verifier &verifier, voffset_t field, + size_t align) const { + // Calling GetOptionalFieldOffset should be safe now thanks to + // VerifyTable(). + auto field_offset = GetOptionalFieldOffset(field); + // Check the actual field. + return !field_offset || verifier.VerifyField(data_, field_offset, align); + } + + // VerifyField for required fields. + template + bool VerifyFieldRequired(const Verifier &verifier, voffset_t field, + size_t align) const { + auto field_offset = GetOptionalFieldOffset(field); + return verifier.Check(field_offset != 0) && + verifier.VerifyField(data_, field_offset, align); + } + + // Versions for offsets. + bool VerifyOffset(const Verifier &verifier, voffset_t field) const { + auto field_offset = GetOptionalFieldOffset(field); + return !field_offset || verifier.VerifyOffset(data_, field_offset); + } + + bool VerifyOffsetRequired(const Verifier &verifier, voffset_t field) const { + auto field_offset = GetOptionalFieldOffset(field); + return verifier.Check(field_offset != 0) && + verifier.VerifyOffset(data_, field_offset); + } + + private: + // private constructor & copy constructor: you obtain instances of this + // class by pointing to existing data only + Table(); + Table(const Table &other); + Table &operator=(const Table &); + + uint8_t data_[1]; +}; + +// This specialization allows avoiding warnings like: +// MSVC C4800: type: forcing value to bool 'true' or 'false'. +template<> +inline flatbuffers::Optional Table::GetOptional( + voffset_t field) const { + auto field_offset = GetOptionalFieldOffset(field); + auto p = data_ + field_offset; + return field_offset ? Optional(ReadScalar(p) != 0) + : Optional(); +} + +} // namespace flatbuffers + +#endif // FLATBUFFERS_TABLE_H_ diff --git a/thirdparty/flatbuffers/vector.h b/thirdparty/flatbuffers/vector.h new file mode 100644 index 0000000000..6bcdfe263a --- /dev/null +++ b/thirdparty/flatbuffers/vector.h @@ -0,0 +1,389 @@ +/* + * Copyright 2021 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. + */ + +#ifndef FLATBUFFERS_VECTOR_H_ +#define FLATBUFFERS_VECTOR_H_ + +#include "flatbuffers/base.h" +#include "flatbuffers/buffer.h" +#include "flatbuffers/stl_emulation.h" + +namespace flatbuffers { + +struct String; + +// An STL compatible iterator implementation for Vector below, effectively +// calling Get() for every element. +template struct VectorIterator { + typedef std::random_access_iterator_tag iterator_category; + typedef IT value_type; + typedef ptrdiff_t difference_type; + typedef IT *pointer; + typedef IT &reference; + + VectorIterator(const uint8_t *data, uoffset_t i) + : data_(data + IndirectHelper::element_stride * i) {} + VectorIterator(const VectorIterator &other) : data_(other.data_) {} + VectorIterator() : data_(nullptr) {} + + VectorIterator &operator=(const VectorIterator &other) { + data_ = other.data_; + return *this; + } + + VectorIterator &operator=(VectorIterator &&other) { + data_ = other.data_; + return *this; + } + + bool operator==(const VectorIterator &other) const { + return data_ == other.data_; + } + + bool operator<(const VectorIterator &other) const { + return data_ < other.data_; + } + + bool operator!=(const VectorIterator &other) const { + return data_ != other.data_; + } + + difference_type operator-(const VectorIterator &other) const { + return (data_ - other.data_) / IndirectHelper::element_stride; + } + + // Note: return type is incompatible with the standard + // `reference operator*()`. + IT operator*() const { return IndirectHelper::Read(data_, 0); } + + // Note: return type is incompatible with the standard + // `pointer operator->()`. + IT operator->() const { return IndirectHelper::Read(data_, 0); } + + VectorIterator &operator++() { + data_ += IndirectHelper::element_stride; + return *this; + } + + VectorIterator operator++(int) { + VectorIterator temp(data_, 0); + data_ += IndirectHelper::element_stride; + return temp; + } + + VectorIterator operator+(const uoffset_t &offset) const { + return VectorIterator(data_ + offset * IndirectHelper::element_stride, + 0); + } + + VectorIterator &operator+=(const uoffset_t &offset) { + data_ += offset * IndirectHelper::element_stride; + return *this; + } + + VectorIterator &operator--() { + data_ -= IndirectHelper::element_stride; + return *this; + } + + VectorIterator operator--(int) { + VectorIterator temp(data_, 0); + data_ -= IndirectHelper::element_stride; + return temp; + } + + VectorIterator operator-(const uoffset_t &offset) const { + return VectorIterator(data_ - offset * IndirectHelper::element_stride, + 0); + } + + VectorIterator &operator-=(const uoffset_t &offset) { + data_ -= offset * IndirectHelper::element_stride; + return *this; + } + + private: + const uint8_t *data_; +}; + +template +struct VectorReverseIterator : public std::reverse_iterator { + explicit VectorReverseIterator(Iterator iter) + : std::reverse_iterator(iter) {} + + // Note: return type is incompatible with the standard + // `reference operator*()`. + typename Iterator::value_type operator*() const { + auto tmp = std::reverse_iterator::current; + return *--tmp; + } + + // Note: return type is incompatible with the standard + // `pointer operator->()`. + typename Iterator::value_type operator->() const { + auto tmp = std::reverse_iterator::current; + return *--tmp; + } +}; + +// This is used as a helper type for accessing vectors. +// Vector::data() assumes the vector elements start after the length field. +template class Vector { + public: + typedef VectorIterator::mutable_return_type> + iterator; + typedef VectorIterator::return_type> + const_iterator; + typedef VectorReverseIterator reverse_iterator; + typedef VectorReverseIterator const_reverse_iterator; + + typedef typename flatbuffers::bool_constant::value> + scalar_tag; + + static FLATBUFFERS_CONSTEXPR bool is_span_observable = + scalar_tag::value && (FLATBUFFERS_LITTLEENDIAN || sizeof(T) == 1); + + uoffset_t size() const { return EndianScalar(length_); } + + // Deprecated: use size(). Here for backwards compatibility. + FLATBUFFERS_ATTRIBUTE([[deprecated("use size() instead")]]) + uoffset_t Length() const { return size(); } + + typedef typename IndirectHelper::return_type return_type; + typedef typename IndirectHelper::mutable_return_type mutable_return_type; + typedef return_type value_type; + + return_type Get(uoffset_t i) const { + FLATBUFFERS_ASSERT(i < size()); + return IndirectHelper::Read(Data(), i); + } + + return_type operator[](uoffset_t i) const { return Get(i); } + + // If this is a Vector of enums, T will be its storage type, not the enum + // type. This function makes it convenient to retrieve value with enum + // type E. + template E GetEnum(uoffset_t i) const { + return static_cast(Get(i)); + } + + // If this a vector of unions, this does the cast for you. There's no check + // to make sure this is the right type! + template const U *GetAs(uoffset_t i) const { + return reinterpret_cast(Get(i)); + } + + // If this a vector of unions, this does the cast for you. There's no check + // to make sure this is actually a string! + const String *GetAsString(uoffset_t i) const { + return reinterpret_cast(Get(i)); + } + + const void *GetStructFromOffset(size_t o) const { + return reinterpret_cast(Data() + o); + } + + iterator begin() { return iterator(Data(), 0); } + const_iterator begin() const { return const_iterator(Data(), 0); } + + iterator end() { return iterator(Data(), size()); } + const_iterator end() const { return const_iterator(Data(), size()); } + + reverse_iterator rbegin() { return reverse_iterator(end()); } + const_reverse_iterator rbegin() const { + return const_reverse_iterator(end()); + } + + reverse_iterator rend() { return reverse_iterator(begin()); } + const_reverse_iterator rend() const { + return const_reverse_iterator(begin()); + } + + const_iterator cbegin() const { return begin(); } + + const_iterator cend() const { return end(); } + + const_reverse_iterator crbegin() const { return rbegin(); } + + const_reverse_iterator crend() const { return rend(); } + + // Change elements if you have a non-const pointer to this object. + // Scalars only. See reflection.h, and the documentation. + void Mutate(uoffset_t i, const T &val) { + FLATBUFFERS_ASSERT(i < size()); + WriteScalar(data() + i, val); + } + + // Change an element of a vector of tables (or strings). + // "val" points to the new table/string, as you can obtain from + // e.g. reflection::AddFlatBuffer(). + void MutateOffset(uoffset_t i, const uint8_t *val) { + FLATBUFFERS_ASSERT(i < size()); + static_assert(sizeof(T) == sizeof(uoffset_t), "Unrelated types"); + WriteScalar(data() + i, + static_cast(val - (Data() + i * sizeof(uoffset_t)))); + } + + // Get a mutable pointer to tables/strings inside this vector. + mutable_return_type GetMutableObject(uoffset_t i) const { + FLATBUFFERS_ASSERT(i < size()); + return const_cast(IndirectHelper::Read(Data(), i)); + } + + // The raw data in little endian format. Use with care. + const uint8_t *Data() const { + return reinterpret_cast(&length_ + 1); + } + + uint8_t *Data() { return reinterpret_cast(&length_ + 1); } + + // Similarly, but typed, much like std::vector::data + const T *data() const { return reinterpret_cast(Data()); } + T *data() { return reinterpret_cast(Data()); } + + template return_type LookupByKey(K key) const { + void *search_result = std::bsearch( + &key, Data(), size(), IndirectHelper::element_stride, KeyCompare); + + if (!search_result) { + return nullptr; // Key not found. + } + + const uint8_t *element = reinterpret_cast(search_result); + + return IndirectHelper::Read(element, 0); + } + + template mutable_return_type MutableLookupByKey(K key) { + return const_cast(LookupByKey(key)); + } + + protected: + // This class is only used to access pre-existing data. Don't ever + // try to construct these manually. + Vector(); + + uoffset_t length_; + + private: + // This class is a pointer. Copying will therefore create an invalid object. + // Private and unimplemented copy constructor. + Vector(const Vector &); + Vector &operator=(const Vector &); + + template static int KeyCompare(const void *ap, const void *bp) { + const K *key = reinterpret_cast(ap); + const uint8_t *data = reinterpret_cast(bp); + auto table = IndirectHelper::Read(data, 0); + + // std::bsearch compares with the operands transposed, so we negate the + // result here. + return -table->KeyCompareWithValue(*key); + } +}; + +template +FLATBUFFERS_CONSTEXPR_CPP11 flatbuffers::span make_span(Vector &vec) + FLATBUFFERS_NOEXCEPT { + static_assert(Vector::is_span_observable, + "wrong type U, only LE-scalar, or byte types are allowed"); + return span(vec.data(), vec.size()); +} + +template +FLATBUFFERS_CONSTEXPR_CPP11 flatbuffers::span make_span( + const Vector &vec) FLATBUFFERS_NOEXCEPT { + static_assert(Vector::is_span_observable, + "wrong type U, only LE-scalar, or byte types are allowed"); + return span(vec.data(), vec.size()); +} + +template +FLATBUFFERS_CONSTEXPR_CPP11 flatbuffers::span make_bytes_span( + Vector &vec) FLATBUFFERS_NOEXCEPT { + static_assert(Vector::scalar_tag::value, + "wrong type U, only LE-scalar, or byte types are allowed"); + return span(vec.Data(), vec.size() * sizeof(U)); +} + +template +FLATBUFFERS_CONSTEXPR_CPP11 flatbuffers::span make_bytes_span( + const Vector &vec) FLATBUFFERS_NOEXCEPT { + static_assert(Vector::scalar_tag::value, + "wrong type U, only LE-scalar, or byte types are allowed"); + return span(vec.Data(), vec.size() * sizeof(U)); +} + +// Convenient helper functions to get a span of any vector, regardless +// of whether it is null or not (the field is not set). +template +FLATBUFFERS_CONSTEXPR_CPP11 flatbuffers::span make_span(Vector *ptr) + FLATBUFFERS_NOEXCEPT { + static_assert(Vector::is_span_observable, + "wrong type U, only LE-scalar, or byte types are allowed"); + return ptr ? make_span(*ptr) : span(); +} + +template +FLATBUFFERS_CONSTEXPR_CPP11 flatbuffers::span make_span( + const Vector *ptr) FLATBUFFERS_NOEXCEPT { + static_assert(Vector::is_span_observable, + "wrong type U, only LE-scalar, or byte types are allowed"); + return ptr ? make_span(*ptr) : span(); +} + +// Represent a vector much like the template above, but in this case we +// don't know what the element types are (used with reflection.h). +class VectorOfAny { + public: + uoffset_t size() const { return EndianScalar(length_); } + + const uint8_t *Data() const { + return reinterpret_cast(&length_ + 1); + } + uint8_t *Data() { return reinterpret_cast(&length_ + 1); } + + protected: + VectorOfAny(); + + uoffset_t length_; + + private: + VectorOfAny(const VectorOfAny &); + VectorOfAny &operator=(const VectorOfAny &); +}; + +template +Vector> *VectorCast(Vector> *ptr) { + static_assert(std::is_base_of::value, "Unrelated types"); + return reinterpret_cast> *>(ptr); +} + +template +const Vector> *VectorCast(const Vector> *ptr) { + static_assert(std::is_base_of::value, "Unrelated types"); + return reinterpret_cast> *>(ptr); +} + +// Convenient helper function to get the length of any vector, regardless +// of whether it is null or not (the field is not set). +template static inline size_t VectorLength(const Vector *v) { + return v ? v->size() : 0; +} + +} // namespace flatbuffers + +#endif // FLATBUFFERS_VERIFIER_H_ diff --git a/thirdparty/flatbuffers/vector_downward.h b/thirdparty/flatbuffers/vector_downward.h new file mode 100644 index 0000000000..d25e544970 --- /dev/null +++ b/thirdparty/flatbuffers/vector_downward.h @@ -0,0 +1,271 @@ +/* + * Copyright 2021 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. + */ + +#ifndef FLATBUFFERS_VECTOR_DOWNWARD_H_ +#define FLATBUFFERS_VECTOR_DOWNWARD_H_ + +#include "flatbuffers/base.h" +#include "flatbuffers/default_allocator.h" +#include "flatbuffers/detached_buffer.h" + +namespace flatbuffers { + +// This is a minimal replication of std::vector functionality, +// except growing from higher to lower addresses. i.e. push_back() inserts data +// in the lowest address in the vector. +// Since this vector leaves the lower part unused, we support a "scratch-pad" +// that can be stored there for temporary data, to share the allocated space. +// Essentially, this supports 2 std::vectors in a single buffer. +class vector_downward { + public: + explicit vector_downward(size_t initial_size, Allocator *allocator, + bool own_allocator, size_t buffer_minalign) + : allocator_(allocator), + own_allocator_(own_allocator), + initial_size_(initial_size), + buffer_minalign_(buffer_minalign), + reserved_(0), + size_(0), + buf_(nullptr), + cur_(nullptr), + scratch_(nullptr) {} + + vector_downward(vector_downward &&other) + // clang-format on + : allocator_(other.allocator_), + own_allocator_(other.own_allocator_), + initial_size_(other.initial_size_), + buffer_minalign_(other.buffer_minalign_), + reserved_(other.reserved_), + size_(other.size_), + buf_(other.buf_), + cur_(other.cur_), + scratch_(other.scratch_) { + // No change in other.allocator_ + // No change in other.initial_size_ + // No change in other.buffer_minalign_ + other.own_allocator_ = false; + other.reserved_ = 0; + other.buf_ = nullptr; + other.cur_ = nullptr; + other.scratch_ = nullptr; + } + + vector_downward &operator=(vector_downward &&other) { + // Move construct a temporary and swap idiom + vector_downward temp(std::move(other)); + swap(temp); + return *this; + } + + ~vector_downward() { + clear_buffer(); + clear_allocator(); + } + + void reset() { + clear_buffer(); + clear(); + } + + void clear() { + if (buf_) { + cur_ = buf_ + reserved_; + } else { + reserved_ = 0; + cur_ = nullptr; + } + size_ = 0; + clear_scratch(); + } + + void clear_scratch() { scratch_ = buf_; } + + void clear_allocator() { + if (own_allocator_ && allocator_) { delete allocator_; } + allocator_ = nullptr; + own_allocator_ = false; + } + + void clear_buffer() { + if (buf_) Deallocate(allocator_, buf_, reserved_); + buf_ = nullptr; + } + + // Relinquish the pointer to the caller. + uint8_t *release_raw(size_t &allocated_bytes, size_t &offset) { + auto *buf = buf_; + allocated_bytes = reserved_; + offset = static_cast(cur_ - buf_); + + // release_raw only relinquishes the buffer ownership. + // Does not deallocate or reset the allocator. Destructor will do that. + buf_ = nullptr; + clear(); + return buf; + } + + // Relinquish the pointer to the caller. + DetachedBuffer release() { + // allocator ownership (if any) is transferred to DetachedBuffer. + DetachedBuffer fb(allocator_, own_allocator_, buf_, reserved_, cur_, + size()); + if (own_allocator_) { + allocator_ = nullptr; + own_allocator_ = false; + } + buf_ = nullptr; + clear(); + return fb; + } + + size_t ensure_space(size_t len) { + FLATBUFFERS_ASSERT(cur_ >= scratch_ && scratch_ >= buf_); + if (len > static_cast(cur_ - scratch_)) { reallocate(len); } + // Beyond this, signed offsets may not have enough range: + // (FlatBuffers > 2GB not supported). + FLATBUFFERS_ASSERT(size() < FLATBUFFERS_MAX_BUFFER_SIZE); + return len; + } + + inline uint8_t *make_space(size_t len) { + if (len) { + ensure_space(len); + cur_ -= len; + size_ += static_cast(len); + } + return cur_; + } + + // Returns nullptr if using the DefaultAllocator. + Allocator *get_custom_allocator() { return allocator_; } + + inline uoffset_t size() const { return size_; } + + uoffset_t scratch_size() const { + return static_cast(scratch_ - buf_); + } + + size_t capacity() const { return reserved_; } + + uint8_t *data() const { + FLATBUFFERS_ASSERT(cur_); + return cur_; + } + + uint8_t *scratch_data() const { + FLATBUFFERS_ASSERT(buf_); + return buf_; + } + + uint8_t *scratch_end() const { + FLATBUFFERS_ASSERT(scratch_); + return scratch_; + } + + uint8_t *data_at(size_t offset) const { return buf_ + reserved_ - offset; } + + void push(const uint8_t *bytes, size_t num) { + if (num > 0) { memcpy(make_space(num), bytes, num); } + } + + // Specialized version of push() that avoids memcpy call for small data. + template void push_small(const T &little_endian_t) { + make_space(sizeof(T)); + *reinterpret_cast(cur_) = little_endian_t; + } + + template void scratch_push_small(const T &t) { + ensure_space(sizeof(T)); + *reinterpret_cast(scratch_) = t; + scratch_ += sizeof(T); + } + + // fill() is most frequently called with small byte counts (<= 4), + // which is why we're using loops rather than calling memset. + void fill(size_t zero_pad_bytes) { + make_space(zero_pad_bytes); + for (size_t i = 0; i < zero_pad_bytes; i++) cur_[i] = 0; + } + + // Version for when we know the size is larger. + // Precondition: zero_pad_bytes > 0 + void fill_big(size_t zero_pad_bytes) { + memset(make_space(zero_pad_bytes), 0, zero_pad_bytes); + } + + void pop(size_t bytes_to_remove) { + cur_ += bytes_to_remove; + size_ -= static_cast(bytes_to_remove); + } + + void scratch_pop(size_t bytes_to_remove) { scratch_ -= bytes_to_remove; } + + void swap(vector_downward &other) { + using std::swap; + swap(allocator_, other.allocator_); + swap(own_allocator_, other.own_allocator_); + swap(initial_size_, other.initial_size_); + swap(buffer_minalign_, other.buffer_minalign_); + swap(reserved_, other.reserved_); + swap(size_, other.size_); + swap(buf_, other.buf_); + swap(cur_, other.cur_); + swap(scratch_, other.scratch_); + } + + void swap_allocator(vector_downward &other) { + using std::swap; + swap(allocator_, other.allocator_); + swap(own_allocator_, other.own_allocator_); + } + + private: + // You shouldn't really be copying instances of this class. + FLATBUFFERS_DELETE_FUNC(vector_downward(const vector_downward &)); + FLATBUFFERS_DELETE_FUNC(vector_downward &operator=(const vector_downward &)); + + Allocator *allocator_; + bool own_allocator_; + size_t initial_size_; + size_t buffer_minalign_; + size_t reserved_; + uoffset_t size_; + uint8_t *buf_; + uint8_t *cur_; // Points at location between empty (below) and used (above). + uint8_t *scratch_; // Points to the end of the scratchpad in use. + + void reallocate(size_t len) { + auto old_reserved = reserved_; + auto old_size = size(); + auto old_scratch_size = scratch_size(); + reserved_ += + (std::max)(len, old_reserved ? old_reserved / 2 : initial_size_); + reserved_ = (reserved_ + buffer_minalign_ - 1) & ~(buffer_minalign_ - 1); + if (buf_) { + buf_ = ReallocateDownward(allocator_, buf_, old_reserved, reserved_, + old_size, old_scratch_size); + } else { + buf_ = Allocate(allocator_, reserved_); + } + cur_ = buf_ + reserved_ - old_size; + scratch_ = buf_ + old_scratch_size; + } +}; + +} // namespace flatbuffers + +#endif // FLATBUFFERS_VECTOR_DOWNWARD_H_ diff --git a/thirdparty/flatbuffers/verifier.h b/thirdparty/flatbuffers/verifier.h new file mode 100644 index 0000000000..87d3f54a5d --- /dev/null +++ b/thirdparty/flatbuffers/verifier.h @@ -0,0 +1,317 @@ +/* + * Copyright 2021 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. + */ + +#ifndef FLATBUFFERS_VERIFIER_H_ +#define FLATBUFFERS_VERIFIER_H_ + +#include "flatbuffers/base.h" +#include "flatbuffers/vector.h" + +namespace flatbuffers { + +// Helper class to verify the integrity of a FlatBuffer +class Verifier FLATBUFFERS_FINAL_CLASS { + public: + struct Options { + // The maximum nesting of tables and vectors before we call it invalid. + uoffset_t max_depth = 64; + // The maximum number of tables we will verify before we call it invalid. + uoffset_t max_tables = 1000000; + // If true, verify all data is aligned. + bool check_alignment = true; + // If true, run verifier on nested flatbuffers + bool check_nested_flatbuffers = true; + }; + + explicit Verifier(const uint8_t *const buf, const size_t buf_len, + const Options &opts) + : buf_(buf), size_(buf_len), opts_(opts) { + FLATBUFFERS_ASSERT(size_ < FLATBUFFERS_MAX_BUFFER_SIZE); + } + + // Deprecated API, please construct with Verifier::Options. + Verifier(const uint8_t *const buf, const size_t buf_len, + const uoffset_t max_depth = 64, const uoffset_t max_tables = 1000000, + const bool check_alignment = true) + : Verifier(buf, buf_len, [&] { + Options opts; + opts.max_depth = max_depth; + opts.max_tables = max_tables; + opts.check_alignment = check_alignment; + return opts; + }()) {} + + // Central location where any verification failures register. + bool Check(const bool ok) const { + // clang-format off + #ifdef FLATBUFFERS_DEBUG_VERIFICATION_FAILURE + FLATBUFFERS_ASSERT(ok); + #endif + #ifdef FLATBUFFERS_TRACK_VERIFIER_BUFFER_SIZE + if (!ok) + upper_bound_ = 0; + #endif + // clang-format on + return ok; + } + + // Verify any range within the buffer. + bool Verify(const size_t elem, const size_t elem_len) const { + // clang-format off + #ifdef FLATBUFFERS_TRACK_VERIFIER_BUFFER_SIZE + auto upper_bound = elem + elem_len; + if (upper_bound_ < upper_bound) + upper_bound_ = upper_bound; + #endif + // clang-format on + return Check(elem_len < size_ && elem <= size_ - elem_len); + } + + bool VerifyAlignment(const size_t elem, const size_t align) const { + return Check((elem & (align - 1)) == 0 || !opts_.check_alignment); + } + + // Verify a range indicated by sizeof(T). + template bool Verify(const size_t elem) const { + return VerifyAlignment(elem, sizeof(T)) && Verify(elem, sizeof(T)); + } + + bool VerifyFromPointer(const uint8_t *const p, const size_t len) { + return Verify(static_cast(p - buf_), len); + } + + // Verify relative to a known-good base pointer. + bool VerifyFieldStruct(const uint8_t *const base, const voffset_t elem_off, + const size_t elem_len, const size_t align) const { + const auto f = static_cast(base - buf_) + elem_off; + return VerifyAlignment(f, align) && Verify(f, elem_len); + } + + template + bool VerifyField(const uint8_t *const base, const voffset_t elem_off, + const size_t align) const { + const auto f = static_cast(base - buf_) + elem_off; + return VerifyAlignment(f, align) && Verify(f, sizeof(T)); + } + + // Verify a pointer (may be NULL) of a table type. + template bool VerifyTable(const T *const table) { + return !table || table->Verify(*this); + } + + // Verify a pointer (may be NULL) of any vector type. + template bool VerifyVector(const Vector *const vec) const { + return !vec || VerifyVectorOrString(reinterpret_cast(vec), + sizeof(T)); + } + + // Verify a pointer (may be NULL) of a vector to struct. + template + bool VerifyVector(const Vector *const vec) const { + return VerifyVector(reinterpret_cast *>(vec)); + } + + // Verify a pointer (may be NULL) to string. + bool VerifyString(const String *const str) const { + size_t end; + return !str || (VerifyVectorOrString(reinterpret_cast(str), + 1, &end) && + Verify(end, 1) && // Must have terminator + Check(buf_[end] == '\0')); // Terminating byte must be 0. + } + + // Common code between vectors and strings. + bool VerifyVectorOrString(const uint8_t *const vec, const size_t elem_size, + size_t *const end = nullptr) const { + const auto veco = static_cast(vec - buf_); + // Check we can read the size field. + if (!Verify(veco)) return false; + // Check the whole array. If this is a string, the byte past the array must + // be 0. + const auto size = ReadScalar(vec); + const auto max_elems = FLATBUFFERS_MAX_BUFFER_SIZE / elem_size; + if (!Check(size < max_elems)) + return false; // Protect against byte_size overflowing. + const auto byte_size = sizeof(size) + elem_size * size; + if (end) *end = veco + byte_size; + return Verify(veco, byte_size); + } + + // Special case for string contents, after the above has been called. + bool VerifyVectorOfStrings(const Vector> *const vec) const { + if (vec) { + for (uoffset_t i = 0; i < vec->size(); i++) { + if (!VerifyString(vec->Get(i))) return false; + } + } + return true; + } + + // Special case for table contents, after the above has been called. + template + bool VerifyVectorOfTables(const Vector> *const vec) { + if (vec) { + for (uoffset_t i = 0; i < vec->size(); i++) { + if (!vec->Get(i)->Verify(*this)) return false; + } + } + return true; + } + + __suppress_ubsan__("unsigned-integer-overflow") bool VerifyTableStart( + const uint8_t *const table) { + // Check the vtable offset. + const auto tableo = static_cast(table - buf_); + if (!Verify(tableo)) return false; + // This offset may be signed, but doing the subtraction unsigned always + // gives the result we want. + const auto vtableo = + tableo - static_cast(ReadScalar(table)); + // Check the vtable size field, then check vtable fits in its entirety. + if (!(VerifyComplexity() && Verify(vtableo) && + VerifyAlignment(ReadScalar(buf_ + vtableo), + sizeof(voffset_t)))) + return false; + const auto vsize = ReadScalar(buf_ + vtableo); + return Check((vsize & 1) == 0) && Verify(vtableo, vsize); + } + + template + bool VerifyBufferFromStart(const char *const identifier, const size_t start) { + // Buffers have to be of some size to be valid. The reason it is a runtime + // check instead of static_assert, is that nested flatbuffers go through + // this call and their size is determined at runtime. + if (!Check(size_ >= FLATBUFFERS_MIN_BUFFER_SIZE)) return false; + + // If an identifier is provided, check that we have a buffer + if (identifier && !Check((size_ >= 2 * sizeof(flatbuffers::uoffset_t) && + BufferHasIdentifier(buf_ + start, identifier)))) { + return false; + } + + // Call T::Verify, which must be in the generated code for this type. + const auto o = VerifyOffset(start); + return Check(o != 0) && + reinterpret_cast(buf_ + start + o)->Verify(*this) + // clang-format off + #ifdef FLATBUFFERS_TRACK_VERIFIER_BUFFER_SIZE + && GetComputedSize() + #endif + ; + // clang-format on + } + + template + bool VerifyNestedFlatBuffer(const Vector *const buf, + const char *const identifier) { + // Caller opted out of this. + if (!opts_.check_nested_flatbuffers) return true; + + // An empty buffer is OK as it indicates not present. + if (!buf) return true; + + // If there is a nested buffer, it must be greater than the min size. + if (!Check(buf->size() >= FLATBUFFERS_MIN_BUFFER_SIZE)) return false; + + Verifier nested_verifier(buf->data(), buf->size()); + return nested_verifier.VerifyBuffer(identifier); + } + + // Verify this whole buffer, starting with root type T. + template bool VerifyBuffer() { return VerifyBuffer(nullptr); } + + template bool VerifyBuffer(const char *const identifier) { + return VerifyBufferFromStart(identifier, 0); + } + + template + bool VerifySizePrefixedBuffer(const char *const identifier) { + return Verify(0U) && + Check(ReadScalar(buf_) == size_ - sizeof(uoffset_t)) && + VerifyBufferFromStart(identifier, sizeof(uoffset_t)); + } + + uoffset_t VerifyOffset(const size_t start) const { + if (!Verify(start)) return 0; + const auto o = ReadScalar(buf_ + start); + // May not point to itself. + if (!Check(o != 0)) return 0; + // Can't wrap around / buffers are max 2GB. + if (!Check(static_cast(o) >= 0)) return 0; + // Must be inside the buffer to create a pointer from it (pointer outside + // buffer is UB). + if (!Verify(start + o, 1)) return 0; + return o; + } + + uoffset_t VerifyOffset(const uint8_t *const base, + const voffset_t start) const { + return VerifyOffset(static_cast(base - buf_) + start); + } + + // Called at the start of a table to increase counters measuring data + // structure depth and amount, and possibly bails out with false if limits set + // by the constructor have been hit. Needs to be balanced with EndTable(). + bool VerifyComplexity() { + depth_++; + num_tables_++; + return Check(depth_ <= opts_.max_depth && num_tables_ <= opts_.max_tables); + } + + // Called at the end of a table to pop the depth count. + bool EndTable() { + depth_--; + return true; + } + + // Returns the message size in bytes + size_t GetComputedSize() const { + // clang-format off + #ifdef FLATBUFFERS_TRACK_VERIFIER_BUFFER_SIZE + uintptr_t size = upper_bound_; + // Align the size to uoffset_t + size = (size - 1 + sizeof(uoffset_t)) & ~(sizeof(uoffset_t) - 1); + return (size > size_) ? 0 : size; + #else + // Must turn on FLATBUFFERS_TRACK_VERIFIER_BUFFER_SIZE for this to work. + (void)upper_bound_; + FLATBUFFERS_ASSERT(false); + return 0; + #endif + // clang-format on + } + + std::vector *GetFlexReuseTracker() { return flex_reuse_tracker_; } + + void SetFlexReuseTracker(std::vector *const rt) { + flex_reuse_tracker_ = rt; + } + + private: + const uint8_t *buf_; + const size_t size_; + const Options opts_; + + mutable size_t upper_bound_ = 0; + + uoffset_t depth_ = 0; + uoffset_t num_tables_ = 0; + std::vector *flex_reuse_tracker_ = nullptr; +}; + +} // namespace flatbuffers + +#endif // FLATBUFFERS_VERIFIER_H_ diff --git a/thirdparty/fmt/CMakeLists.txt b/thirdparty/fmt/CMakeLists.txt index 4033ddfc03..088a2a9c56 100644 --- a/thirdparty/fmt/CMakeLists.txt +++ b/thirdparty/fmt/CMakeLists.txt @@ -262,12 +262,6 @@ if (CMAKE_BUILD_TYPE STREQUAL "Debug") endif () if (BUILD_SHARED_LIBS) - if (UNIX AND NOT APPLE AND NOT ${CMAKE_SYSTEM_NAME} MATCHES "SunOS" AND - NOT EMSCRIPTEN) - # Fix rpmlint warning: - # unused-direct-shlib-dependency /usr/lib/libformat.so.1.1.0 /lib/libm.so.6. - target_link_libraries(fmt -Wl,--as-needed) - endif () target_compile_definitions(fmt PRIVATE FMT_EXPORT INTERFACE FMT_SHARED) endif () if (FMT_SAFE_DURATION_CAST) diff --git a/thirdparty/fmt/ChangeLog.rst b/thirdparty/fmt/ChangeLog.rst index 966d039f81..4ebc5c7330 100644 --- a/thirdparty/fmt/ChangeLog.rst +++ b/thirdparty/fmt/ChangeLog.rst @@ -1,3 +1,129 @@ +9.1.0 - 2022-08-27 +------------------ + +* ``fmt::formatted_size`` now works at compile time + (`#3026 `_). For example + (`godbolt `__): + + .. code:: c++ + + #include + + int main() { + using namespace fmt::literals; + constexpr size_t n = fmt::formatted_size("{}"_cf, 42); + fmt::print("{}\n", n); // prints 2 + } + + Thanks `@marksantaniello (Mark Santaniello) + `_. + +* Fixed handling of invalid UTF-8 + (`#3038 `_, + `#3044 `_, + `#3056 `_). + Thanks `@phprus (Vladislav Shchapov) `_ and + `@skeeto (Christopher Wellons) `_. + +* Improved Unicode support in ``ostream`` overloads of ``print`` + (`#2994 `_, + `#3001 `_, + `#3025 `_). + Thanks `@dimztimz (Dimitrij Mijoski) `_. + +* Fixed handling of the sign specifier in localized formatting on systems with + 32-bit ``wchar_t`` (`#3041 `_). + +* Added support for wide streams to ``fmt::streamed`` + (`#2994 `_). + Thanks `@phprus (Vladislav Shchapov) `_. + +* Added the ``n`` specifier that disables the output of delimiters when + formatting ranges (`#2981 `_, + `#2983 `_). + For example (`godbolt `__): + + .. code:: c++ + + #include + #include + + int main() { + auto v = std::vector{1, 2, 3}; + fmt::print("{:n}\n", v); // prints 1, 2, 3 + } + + Thanks `@BRevzin (Barry Revzin) `_. + +* Worked around problematic ``std::string_view`` constructors introduced in + C++23 (`#3030 `_, + `#3050 `_). + Thanks `@strega-nil-ms (nicole mazzuca) `_. + +* Improve handling (exclusion) of recursive ranges + (`#2968 `_, + `#2974 `_). + Thanks `@Dani-Hub (Daniel Krügler) `_. + +* Improved error reporting in format string compilation + (`#3055 `_). + +* Improved the implementation of + `Dragonbox `_, the algorithm used for + the default floating-point formatting + (`#2984 `_). + Thanks `@jk-jeon (Junekey Jeon) `_. + +* Fixed issues with floating-point formatting on exotic platforms. + +* Improved the implementation of chrono formatting + (`#3010 `_). + Thanks `@phprus (Vladislav Shchapov) `_. + +* Improved documentation + (`#2966 `_, + `#3009 `_, + `#3020 `_, + `#3037 `_). + Thanks `@mwinterb `_, + `@jcelerier (Jean-Michaël Celerier) `_ + and `@remiburtin (Rémi Burtin) `_. + +* Improved build configuration + (`#2991 `_, + `#2995 `_, + `#3004 `_, + `#3007 `_, + `#3040 `_). + Thanks `@dimztimz (Dimitrij Mijoski) `_ and + `@hwhsu1231 (Haowei Hsu) `_. + +* Fixed various warnings and compilation issues + (`#2969 `_, + `#2971 `_, + `#2975 `_, + `#2982 `_, + `#2985 `_, + `#2988 `_, + `#3000 `_, + `#3006 `_, + `#3014 `_, + `#3015 `_, + `#3021 `_, + `#3023 `_, + `#3024 `_, + `#3029 `_, + `#3043 `_, + `#3052 `_, + `#3053 `_, + `#3054 `_). + Thanks `@h-friederich (Hannes Friederich) `_, + `@dimztimz (Dimitrij Mijoski) `_, + `@olupton (Olli Lupton) `_, + `@bernhardmgruber (Bernhard Manfred Gruber) + `_, + `@phprus (Vladislav Shchapov) `_. + 9.0.0 - 2022-07-04 ------------------ @@ -19,7 +145,7 @@ return result; } - constexpr auto answer = compile_time_itoa(0.42); + constexpr auto answer = compile_time_dtoa(0.42); works with the default settings. diff --git a/thirdparty/fmt/README.rst b/thirdparty/fmt/README.rst index 4a3addf08f..cc6d7c41ad 100644 --- a/thirdparty/fmt/README.rst +++ b/thirdparty/fmt/README.rst @@ -12,9 +12,6 @@ .. image:: https://github.com/fmtlib/fmt/workflows/windows/badge.svg :target: https://github.com/fmtlib/fmt/actions?query=workflow%3Awindows -.. image:: https://ci.appveyor.com/api/projects/status/ehjkiefde6gucy1v?svg=true - :target: https://ci.appveyor.com/project/vitaut/fmt - .. image:: https://oss-fuzz-build-logs.storage.googleapis.com/badges/fmt.svg :alt: fmt is continuously fuzzed at oss-fuzz :target: https://bugs.chromium.org/p/oss-fuzz/issues/list?\ diff --git a/thirdparty/fmt/include/fmt/chrono.h b/thirdparty/fmt/include/fmt/chrono.h index c3c52bf592..b112f76e99 100644 --- a/thirdparty/fmt/include/fmt/chrono.h +++ b/thirdparty/fmt/include/fmt/chrono.h @@ -203,7 +203,7 @@ To safe_duration_cast(std::chrono::duration from, } const auto min1 = (std::numeric_limits::min)() / Factor::num; - if (count < min1) { + if (!std::is_unsigned::value && count < min1) { ec = 1; return {}; } @@ -1396,7 +1396,8 @@ inline bool isfinite(T) { // Converts value to Int and checks that it's in the range [0, upper). template ::value)> inline Int to_nonnegative_int(T value, Int upper) { - FMT_ASSERT(value >= 0 && to_unsigned(value) <= to_unsigned(upper), + FMT_ASSERT(std::is_unsigned::value || + (value >= 0 && to_unsigned(value) <= to_unsigned(upper)), "invalid value"); (void)upper; return static_cast(value); @@ -1776,7 +1777,7 @@ struct chrono_formatter { format_to(std::back_inserter(buf), runtime("{:.{}f}"), std::fmod(val * static_cast(Period::num) / static_cast(Period::den), - 60), + static_cast(60)), num_fractional_digits); if (negative) *out++ = '-'; if (buf.size() < 2 || buf[1] == '.') *out++ = '0'; @@ -2001,13 +2002,9 @@ template struct formatter, Char> : formatter { FMT_CONSTEXPR formatter() { - this->do_parse(default_specs, - default_specs + sizeof(default_specs) / sizeof(Char)); - } - - template - FMT_CONSTEXPR auto parse(ParseContext& ctx) -> decltype(ctx.begin()) { - return this->do_parse(ctx.begin(), ctx.end(), true); + basic_string_view default_specs = + detail::string_literal{}; + this->do_parse(default_specs.begin(), default_specs.end()); } template @@ -2015,15 +2012,8 @@ struct formatter, FormatContext& ctx) const -> decltype(ctx.out()) { return formatter::format(localtime(val), ctx); } - - static constexpr const Char default_specs[] = {'%', 'F', ' ', '%', 'T'}; }; -template -constexpr const Char - formatter, - Char>::default_specs[]; - template struct formatter { private: enum class spec { @@ -2035,13 +2025,18 @@ template struct formatter { basic_string_view specs; protected: - template - FMT_CONSTEXPR auto do_parse(It begin, It end, bool with_default = false) - -> It { + template FMT_CONSTEXPR auto do_parse(It begin, It end) -> It { if (begin != end && *begin == ':') ++begin; end = detail::parse_chrono_format(begin, end, detail::tm_format_checker()); - if (!with_default || end != begin) - specs = {begin, detail::to_unsigned(end - begin)}; + // Replace default spec only if the new spec is not empty. + if (end != begin) specs = {begin, detail::to_unsigned(end - begin)}; + return end; + } + + public: + FMT_CONSTEXPR auto parse(basic_format_parse_context& ctx) + -> decltype(ctx.begin()) { + auto end = this->do_parse(ctx.begin(), ctx.end()); // basic_string_view<>::compare isn't constexpr before C++17. if (specs.size() == 2 && specs[0] == Char('%')) { if (specs[1] == Char('F')) @@ -2052,12 +2047,6 @@ template struct formatter { return end; } - public: - template - FMT_CONSTEXPR auto parse(ParseContext& ctx) -> decltype(ctx.begin()) { - return this->do_parse(ctx.begin(), ctx.end()); - } - template auto format(const std::tm& tm, FormatContext& ctx) const -> decltype(ctx.out()) { diff --git a/thirdparty/fmt/include/fmt/color.h b/thirdparty/fmt/include/fmt/color.h index e6212d249e..4c163277ef 100644 --- a/thirdparty/fmt/include/fmt/color.h +++ b/thirdparty/fmt/include/fmt/color.h @@ -634,7 +634,7 @@ struct formatter, Char> : formatter { **Example**:: - fmt::print("Elapsed time: {s:.2f} seconds", + fmt::print("Elapsed time: {0:.2f} seconds", fmt::styled(1.23, fmt::fg(fmt::color::green) | fmt::bg(fmt::color::blue))); \endrst diff --git a/thirdparty/fmt/include/fmt/compile.h b/thirdparty/fmt/include/fmt/compile.h index c09dd6f2a1..933668c41c 100644 --- a/thirdparty/fmt/include/fmt/compile.h +++ b/thirdparty/fmt/include/fmt/compile.h @@ -14,8 +14,8 @@ FMT_BEGIN_NAMESPACE namespace detail { template -inline counting_iterator copy_str(InputIt begin, InputIt end, - counting_iterator it) { +FMT_CONSTEXPR inline counting_iterator copy_str(InputIt begin, InputIt end, + counting_iterator it) { return it + (end - begin); } @@ -341,7 +341,7 @@ constexpr parse_specs_result parse_specs(basic_string_view str, next_arg_id); auto f = formatter(); auto end = f.parse(ctx); - return {f, pos + fmt::detail::to_unsigned(end - str.data()) + 1, + return {f, pos + fmt::detail::to_unsigned(end - str.data()), next_arg_id == 0 ? manual_indexing_id : ctx.next_arg_id()}; } @@ -397,13 +397,20 @@ constexpr auto parse_replacement_field_then_tail(S format_str) { return parse_tail( field::type, ARG_INDEX>(), format_str); - } else if constexpr (c == ':') { + } else if constexpr (c != ':') { + FMT_THROW(format_error("expected ':'")); + } else { constexpr auto result = parse_specs::type>( str, END_POS + 1, NEXT_ID == manual_indexing_id ? 0 : NEXT_ID); - return parse_tail( - spec_field::type, ARG_INDEX>{ - result.fmt}, - format_str); + if constexpr (result.end >= str.size() || str[result.end] != '}') { + FMT_THROW(format_error("expected '}'")); + return 0; + } else { + return parse_tail( + spec_field::type, ARG_INDEX>{ + result.fmt}, + format_str); + } } } @@ -568,7 +575,8 @@ format_to_n_result format_to_n(OutputIt out, size_t n, template ::value)> -size_t formatted_size(const S& format_str, const Args&... args) { +FMT_CONSTEXPR20 size_t formatted_size(const S& format_str, + const Args&... args) { return fmt::format_to(detail::counting_iterator(), format_str, args...) .count(); } diff --git a/thirdparty/fmt/include/fmt/core.h b/thirdparty/fmt/include/fmt/core.h index 0e7843b85f..f6a37af9e3 100644 --- a/thirdparty/fmt/include/fmt/core.h +++ b/thirdparty/fmt/include/fmt/core.h @@ -17,7 +17,7 @@ #include // The fmt library version in the form major * 10000 + minor * 100 + patch. -#define FMT_VERSION 90000 +#define FMT_VERSION 90100 #if defined(__clang__) && !defined(__ibmxl__) # define FMT_CLANG_VERSION (__clang_major__ * 100 + __clang_minor__) @@ -200,6 +200,9 @@ # endif #endif +// An inline std::forward replacement. +#define FMT_FORWARD(...) static_cast(__VA_ARGS__) + #ifdef _MSC_VER # define FMT_UNCHECKED_ITERATOR(It) \ using _Unchecked_type = It // Mark iterator as checked. @@ -273,7 +276,8 @@ #ifndef FMT_USE_NONTYPE_TEMPLATE_ARGS # if defined(__cpp_nontype_template_args) && \ ((FMT_GCC_VERSION >= 903 && FMT_CPLUSPLUS >= 201709L) || \ - __cpp_nontype_template_args >= 201911L) + __cpp_nontype_template_args >= 201911L) && \ + !defined(__NVCOMPILER) # define FMT_USE_NONTYPE_TEMPLATE_ARGS 1 # else # define FMT_USE_NONTYPE_TEMPLATE_ARGS 0 @@ -402,7 +406,7 @@ template auto convert_for_visit(T) -> monostate { return {}; } template FMT_CONSTEXPR auto to_unsigned(Int value) -> typename std::make_unsigned::type { - FMT_ASSERT(value >= 0, "negative value"); + FMT_ASSERT(std::is_unsigned::value || value >= 0, "negative value"); return static_cast::type>(value); } @@ -707,8 +711,8 @@ class basic_format_parse_context : private ErrorHandler { next_arg_id_ = -1; do_check_arg_id(id); } - FMT_CONSTEXPR void check_arg_id(basic_string_view) {} + FMT_CONSTEXPR void check_dynamic_spec(int arg_id); FMT_CONSTEXPR void on_error(const char* message) { ErrorHandler::on_error(message); @@ -735,7 +739,8 @@ class compile_parse_context ErrorHandler eh = {}, int next_arg_id = 0) : base(format_str, eh, next_arg_id), num_args_(num_args), types_(types) {} - constexpr int num_args() const { return num_args_; } + constexpr auto num_args() const -> int { return num_args_; } + constexpr auto arg_type(int id) const -> type { return types_[id]; } FMT_CONSTEXPR auto next_arg_id() -> int { int id = base::next_arg_id(); @@ -748,6 +753,11 @@ class compile_parse_context if (id >= num_args_) this->on_error("argument not found"); } using base::check_arg_id; + + FMT_CONSTEXPR void check_dynamic_spec(int arg_id) { + if (arg_id < num_args_ && types_ && !is_integral_type(types_[arg_id])) + this->on_error("width/precision is not integer"); + } }; FMT_END_DETAIL_NAMESPACE @@ -763,6 +773,15 @@ basic_format_parse_context::do_check_arg_id(int id) { } } +template +FMT_CONSTEXPR void +basic_format_parse_context::check_dynamic_spec(int arg_id) { + if (detail::is_constant_evaluated()) { + using context = detail::compile_parse_context; + static_cast(this)->check_dynamic_spec(arg_id); + } +} + template class basic_format_arg; template class basic_format_args; template class dynamic_format_arg_store; @@ -917,11 +936,11 @@ template class buffer { /** Appends data to the end of the buffer. */ template void append(const U* begin, const U* end); - template FMT_CONSTEXPR auto operator[](I index) -> T& { + template FMT_CONSTEXPR auto operator[](Idx index) -> T& { return ptr_[index]; } - template - FMT_CONSTEXPR auto operator[](I index) const -> const T& { + template + FMT_CONSTEXPR auto operator[](Idx index) const -> const T& { return ptr_[index]; } }; @@ -1649,6 +1668,11 @@ auto copy_str(InputIt begin, InputIt end, appender out) -> appender { return out; } +template +FMT_CONSTEXPR auto copy_str(R&& rng, OutputIt out) -> OutputIt { + return detail::copy_str(rng.begin(), rng.end(), out); +} + #if FMT_GCC_VERSION && FMT_GCC_VERSION < 500 // A workaround for gcc 4.8 to make void_t work in a SFINAE context. template struct void_t_impl { using type = void; }; @@ -1708,7 +1732,7 @@ constexpr auto encode_types() -> unsigned long long { template FMT_CONSTEXPR FMT_INLINE auto make_value(T&& val) -> value { - const auto& arg = arg_mapper().map(std::forward(val)); + const auto& arg = arg_mapper().map(FMT_FORWARD(val)); constexpr bool formattable_char = !std::is_same::value; @@ -1875,7 +1899,7 @@ class format_arg_store data_{detail::make_arg< is_packed, Context, detail::mapped_type_constant, Context>::value>( - std::forward(args))...} { + FMT_FORWARD(args))...} { detail::init_named_args(data_.named_args(), 0, 0, args...); } }; @@ -1891,7 +1915,7 @@ class format_arg_store template constexpr auto make_format_args(Args&&... args) -> format_arg_store...> { - return {std::forward(args)...}; + return {FMT_FORWARD(args)...}; } /** @@ -2240,11 +2264,14 @@ class dynamic_specs_handler FMT_CONSTEXPR auto make_arg_ref(int arg_id) -> arg_ref_type { context_.check_arg_id(arg_id); + context_.check_dynamic_spec(arg_id); return arg_ref_type(arg_id); } FMT_CONSTEXPR auto make_arg_ref(auto_id) -> arg_ref_type { - return arg_ref_type(context_.next_arg_id()); + int arg_id = context_.next_arg_id(); + context_.check_dynamic_spec(arg_id); + return arg_ref_type(arg_id); } FMT_CONSTEXPR auto make_arg_ref(basic_string_view arg_id) @@ -2270,12 +2297,15 @@ constexpr auto to_ascii(Char c) -> underlying_t { return c; } +FMT_CONSTEXPR inline auto code_point_length_impl(char c) -> int { + return "\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\0\0\0\0\0\0\0\0\2\2\2\2\3\3\4" + [static_cast(c) >> 3]; +} + template FMT_CONSTEXPR auto code_point_length(const Char* begin) -> int { if (const_check(sizeof(Char) != 1)) return 1; - auto lengths = - "\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\0\0\0\0\0\0\0\0\2\2\2\2\3\3\4"; - int len = lengths[static_cast(*begin) >> 3]; + int len = code_point_length_impl(static_cast(*begin)); // Compute the pointer to the next character early so that the next // iteration can start working on the next character. Neither Clang @@ -2803,7 +2833,8 @@ FMT_CONSTEXPR auto parse_float_type_spec(const basic_format_specs& specs, template FMT_CONSTEXPR auto check_cstring_type_spec(presentation_type type, ErrorHandler&& eh = {}) -> bool { - if (type == presentation_type::none || type == presentation_type::string) + if (type == presentation_type::none || type == presentation_type::string || + type == presentation_type::debug) return true; if (type != presentation_type::pointer) eh.on_error("invalid type specifier"); return false; @@ -2921,7 +2952,10 @@ class format_string_checker { basic_string_view format_str, ErrorHandler eh) : context_(format_str, num_args, types_, eh), parse_funcs_{&parse_format_specs...}, - types_{type_constant::value...} {} + types_{ + mapped_type_constant>::value...} { + } FMT_CONSTEXPR void on_text(const Char*, const Char*) {} @@ -3065,6 +3099,15 @@ struct formatter::value, + enable_if_t<(U == detail::type::string_type || + U == detail::type::cstring_type || + U == detail::type::char_type), + int> = 0> + FMT_CONSTEXPR void set_debug_format() { + specs_.type = presentation_type::debug; + } + template FMT_CONSTEXPR auto format(const T& val, FormatContext& ctx) const -> decltype(ctx.out()); @@ -3127,7 +3170,7 @@ template class basic_format_string { #if FMT_GCC_VERSION && FMT_GCC_VERSION < 409 // Workaround broken conversion on older gcc. template using format_string = string_view; -inline auto runtime(string_view s) -> basic_string_view { return s; } +inline auto runtime(string_view s) -> string_view { return s; } #else template using format_string = basic_format_string...>; diff --git a/thirdparty/fmt/include/fmt/format-inl.h b/thirdparty/fmt/include/fmt/format-inl.h index f44df01c5d..22b1ec8df0 100644 --- a/thirdparty/fmt/include/fmt/format-inl.h +++ b/thirdparty/fmt/include/fmt/format-inl.h @@ -1337,7 +1337,7 @@ template decimal_fp to_decimal(T x) noexcept { if (r < deltai) { // Exclude the right endpoint if necessary. - if (r == 0 && z_mul.is_integer && !include_right_endpoint) { + if (r == 0 && (z_mul.is_integer & !include_right_endpoint)) { --ret_value.significand; r = float_info::big_divisor; goto small_divisor_case_label; @@ -1346,26 +1346,11 @@ template decimal_fp to_decimal(T x) noexcept { goto small_divisor_case_label; } else { // r == deltai; compare fractional parts. - const carrier_uint two_fl = two_fc - 1; + const typename cache_accessor::compute_mul_parity_result x_mul = + cache_accessor::compute_mul_parity(two_fc - 1, cache, beta); - if (!include_left_endpoint || - exponent < float_info::case_fc_pm_half_lower_threshold || - exponent > float_info::divisibility_check_by_5_threshold) { - // If the left endpoint is not included, the condition for - // success is z^(f) < delta^(f) (odd parity). - // Otherwise, the inequalities on exponent ensure that - // x is not an integer, so if z^(f) >= delta^(f) (even parity), we in fact - // have strict inequality. - if (!cache_accessor::compute_mul_parity(two_fl, cache, beta).parity) { - goto small_divisor_case_label; - } - } else { - const typename cache_accessor::compute_mul_parity_result x_mul = - cache_accessor::compute_mul_parity(two_fl, cache, beta); - if (!x_mul.parity && !x_mul.is_integer) { - goto small_divisor_case_label; - } - } + if (!(x_mul.parity | (x_mul.is_integer & include_left_endpoint))) + goto small_divisor_case_label; } ret_value.exponent = minus_k + float_info::kappa + 1; @@ -1404,7 +1389,7 @@ small_divisor_case_label: // or equivalently, when y is an integer. if (y_mul.parity != approx_y_parity) --ret_value.significand; - else if (y_mul.is_integer && ret_value.significand % 2 != 0) + else if (y_mul.is_integer & (ret_value.significand % 2 != 0)) --ret_value.significand; return ret_value; } @@ -1488,17 +1473,13 @@ FMT_FUNC std::string vformat(string_view fmt, format_args args) { return to_string(buffer); } -#ifdef _WIN32 namespace detail { +#ifdef _WIN32 using dword = conditional_t; extern "C" __declspec(dllimport) int __stdcall WriteConsoleW( // void*, const void*, dword, dword*, void*); -} // namespace detail -#endif -namespace detail { -FMT_FUNC void print(std::FILE* f, string_view text) { -#ifdef _WIN32 +FMT_FUNC bool write_console(std::FILE* f, string_view text) { auto fd = _fileno(f); if (_isatty(fd)) { detail::utf8_to_utf16 u16(string_view(text.data(), text.size())); @@ -1506,11 +1487,20 @@ FMT_FUNC void print(std::FILE* f, string_view text) { if (detail::WriteConsoleW(reinterpret_cast(_get_osfhandle(fd)), u16.c_str(), static_cast(u16.size()), &written, nullptr)) { - return; + return true; } - // Fallback to fwrite on failure. It can happen if the output has been - // redirected to NUL. } + // We return false if the file descriptor was not TTY, or it was but + // SetConsoleW failed which can happen if the output has been redirected to + // NUL. In both cases when we return false, we should attempt to do regular + // write via fwrite or std::ostream::write. + return false; +} +#endif + +FMT_FUNC void print(std::FILE* f, string_view text) { +#ifdef _WIN32 + if (write_console(f, text)) return; #endif detail::fwrite_fully(text.data(), 1, text.size(), f); } diff --git a/thirdparty/fmt/include/fmt/format.h b/thirdparty/fmt/include/fmt/format.h index 0bd2fdb182..7c607dbd30 100644 --- a/thirdparty/fmt/include/fmt/format.h +++ b/thirdparty/fmt/include/fmt/format.h @@ -249,6 +249,18 @@ FMT_CONSTEXPR inline void abort_fuzzing_if(bool condition) { #endif } +template struct string_literal { + static constexpr CharT value[sizeof...(C)] = {C...}; + constexpr operator basic_string_view() const { + return {value, sizeof...(C)}; + } +}; + +#if FMT_CPLUSPLUS < 201703L +template +constexpr CharT string_literal::value[sizeof...(C)]; +#endif + template class formatbuf : public Streambuf { private: using char_type = typename Streambuf::char_type; @@ -287,7 +299,8 @@ FMT_CONSTEXPR20 auto bit_cast(const From& from) -> To { if (is_constant_evaluated()) return std::bit_cast(from); #endif auto to = To(); - std::memcpy(&to, &from, sizeof(to)); + // The cast suppresses a bogus -Wclass-memaccess on GCC. + std::memcpy(static_cast(&to), &from, sizeof(to)); return to; } @@ -366,10 +379,12 @@ class uint128_fallback { } FMT_CONSTEXPR auto operator>>(int shift) const -> uint128_fallback { if (shift == 64) return {0, hi_}; + if (shift > 64) return uint128_fallback(0, hi_) >> (shift - 64); return {hi_ >> shift, (hi_ << (64 - shift)) | (lo_ >> shift)}; } FMT_CONSTEXPR auto operator<<(int shift) const -> uint128_fallback { if (shift == 64) return {lo_, 0}; + if (shift > 64) return uint128_fallback(lo_, 0) << (shift - 64); return {hi_ << shift | (lo_ >> (64 - shift)), (lo_ << shift)}; } FMT_CONSTEXPR auto operator>>=(int shift) -> uint128_fallback& { @@ -389,11 +404,11 @@ class uint128_fallback { hi_ += (lo_ < n ? 1 : 0); return *this; } -#if FMT_HAS_BUILTIN(__builtin_addcll) +#if FMT_HAS_BUILTIN(__builtin_addcll) && !defined(__ibmxl__) unsigned long long carry; lo_ = __builtin_addcll(lo_, n, 0, &carry); hi_ += carry; -#elif FMT_HAS_BUILTIN(__builtin_ia32_addcarryx_u64) +#elif FMT_HAS_BUILTIN(__builtin_ia32_addcarryx_u64) && !defined(__ibmxl__) unsigned long long result; auto carry = __builtin_ia32_addcarryx_u64(0, lo_, n, &result); lo_ = result; @@ -592,19 +607,23 @@ FMT_CONSTEXPR inline auto utf8_decode(const char* s, uint32_t* c, int* e) constexpr const int shiftc[] = {0, 18, 12, 6, 0}; constexpr const int shifte[] = {0, 6, 4, 2, 0}; - int len = code_point_length(s); - const char* next = s + len; + int len = code_point_length_impl(*s); + // Compute the pointer to the next character early so that the next + // iteration can start working on the next character. Neither Clang + // nor GCC figure out this reordering on their own. + const char* next = s + len + !len; + + using uchar = unsigned char; // Assume a four-byte character and load four bytes. Unused bits are // shifted out. - *c = uint32_t(s[0] & masks[len]) << 18; - *c |= uint32_t(s[1] & 0x3f) << 12; - *c |= uint32_t(s[2] & 0x3f) << 6; - *c |= uint32_t(s[3] & 0x3f) << 0; + *c = uint32_t(uchar(s[0]) & masks[len]) << 18; + *c |= uint32_t(uchar(s[1]) & 0x3f) << 12; + *c |= uint32_t(uchar(s[2]) & 0x3f) << 6; + *c |= uint32_t(uchar(s[3]) & 0x3f) << 0; *c >>= shiftc[len]; // Accumulate the various error conditions. - using uchar = unsigned char; *e = (*c < mins[len]) << 6; // non-canonical encoding *e |= ((*c >> 11) == 0x1b) << 7; // surrogate half? *e |= (*c > 0x10FFFF) << 8; // out of range? @@ -628,8 +647,8 @@ FMT_CONSTEXPR void for_each_codepoint(string_view s, F f) { auto error = 0; auto end = utf8_decode(buf_ptr, &cp, &error); bool result = f(error ? invalid_code_point : cp, - string_view(ptr, to_unsigned(end - buf_ptr))); - return result ? end : nullptr; + string_view(ptr, error ? 1 : to_unsigned(end - buf_ptr))); + return result ? (error ? buf_ptr + 1 : end) : nullptr; }; auto p = s.data(); const size_t block_size = 4; // utf8_decode always reads blocks of 4 chars. @@ -919,8 +938,11 @@ struct is_contiguous> : std::true_type { }; namespace detail { +#ifdef _WIN32 +FMT_API bool write_console(std::FILE* f, string_view text); +#endif FMT_API void print(std::FILE*, string_view); -} +} // namespace detail /** A formatting error such as invalid format string. */ FMT_CLASS_API @@ -1213,7 +1235,7 @@ FMT_CONSTEXPR20 auto format_decimal(Char* out, UInt value, int size) template >::value)> -inline auto format_decimal(Iterator out, UInt value, int size) +FMT_CONSTEXPR inline auto format_decimal(Iterator out, UInt value, int size) -> format_decimal_result { // Buffer is large enough to hold all digits (digits10 + 1). Char buffer[digits10() + 1]; @@ -1274,8 +1296,6 @@ template <> struct float_info { static const int small_divisor = 10; static const int min_k = -31; static const int max_k = 46; - static const int divisibility_check_by_5_threshold = 39; - static const int case_fc_pm_half_lower_threshold = -1; static const int shorter_interval_tie_lower_threshold = -35; static const int shorter_interval_tie_upper_threshold = -35; }; @@ -1288,8 +1308,6 @@ template <> struct float_info { static const int small_divisor = 100; static const int min_k = -292; static const int max_k = 326; - static const int divisibility_check_by_5_threshold = 86; - static const int case_fc_pm_half_lower_threshold = -2; static const int shorter_interval_tie_lower_threshold = -77; static const int shorter_interval_tie_upper_threshold = -77; }; @@ -1543,7 +1561,10 @@ FMT_CONSTEXPR inline fp get_cached_power(int min_exponent, const int dec_exp_step = 8; index = (index - first_dec_exp - 1) / dec_exp_step + 1; pow10_exponent = first_dec_exp + index * dec_exp_step; - return {data::pow10_significands[index], data::pow10_exponents[index]}; + // Using *(x + index) instead of x[index] avoids an issue with some compilers + // using the EDG frontend (e.g. nvhpc/22.3 in C++17 mode). + return {*(data::pow10_significands + index), + *(data::pow10_exponents + index)}; } #ifndef _MSC_VER @@ -1724,18 +1745,18 @@ inline auto find_escape(const char* begin, const char* end) return result; } -#define FMT_STRING_IMPL(s, base, explicit) \ - [] { \ - /* Use the hidden visibility as a workaround for a GCC bug (#1973). */ \ - /* Use a macro-like name to avoid shadowing warnings. */ \ - struct FMT_GCC_VISIBILITY_HIDDEN FMT_COMPILE_STRING : base { \ - using char_type = fmt::remove_cvref_t; \ - FMT_MAYBE_UNUSED FMT_CONSTEXPR explicit \ - operator fmt::basic_string_view() const { \ - return fmt::detail_exported::compile_string_to_view(s); \ - } \ - }; \ - return FMT_COMPILE_STRING(); \ +#define FMT_STRING_IMPL(s, base, explicit) \ + [] { \ + /* Use the hidden visibility as a workaround for a GCC bug (#1973). */ \ + /* Use a macro-like name to avoid shadowing warnings. */ \ + struct FMT_GCC_VISIBILITY_HIDDEN FMT_COMPILE_STRING : base { \ + using char_type FMT_MAYBE_UNUSED = fmt::remove_cvref_t; \ + FMT_MAYBE_UNUSED FMT_CONSTEXPR explicit \ + operator fmt::basic_string_view() const { \ + return fmt::detail_exported::compile_string_to_view(s); \ + } \ + }; \ + return FMT_COMPILE_STRING(); \ }() /** @@ -1981,7 +2002,10 @@ auto write_int_localized(OutputIt out, UInt value, unsigned prefix, grouping.count_separators(num_digits)); return write_padded( out, specs, size, size, [&](reserve_iterator it) { - if (prefix != 0) *it++ = static_cast(prefix); + if (prefix != 0) { + char sign = static_cast(prefix); + *it++ = static_cast(sign); + } return grouping.apply(it, string_view(digits, to_unsigned(num_digits))); }); } @@ -2123,29 +2147,30 @@ class counting_iterator { FMT_UNCHECKED_ITERATOR(counting_iterator); struct value_type { - template void operator=(const T&) {} + template FMT_CONSTEXPR void operator=(const T&) {} }; - counting_iterator() : count_(0) {} + FMT_CONSTEXPR counting_iterator() : count_(0) {} - size_t count() const { return count_; } + FMT_CONSTEXPR size_t count() const { return count_; } - counting_iterator& operator++() { + FMT_CONSTEXPR counting_iterator& operator++() { ++count_; return *this; } - counting_iterator operator++(int) { + FMT_CONSTEXPR counting_iterator operator++(int) { auto it = *this; ++*this; return it; } - friend counting_iterator operator+(counting_iterator it, difference_type n) { + FMT_CONSTEXPR friend counting_iterator operator+(counting_iterator it, + difference_type n) { it.count_ += static_cast(n); return it; } - value_type operator*() const { return {}; } + FMT_CONSTEXPR value_type operator*() const { return {}; } }; template @@ -2991,7 +3016,7 @@ FMT_CONSTEXPR20 inline void format_dragon(basic_fp value, upper = &upper_store; } } - bool even = (value.f & 1) == 0; + int even = static_cast((value.f & 1) == 0); if (!upper) upper = &lower; if ((flags & dragon::fixup) != 0) { if (add_compare(numerator, *upper, denominator) + even <= 0) { diff --git a/thirdparty/fmt/include/fmt/ostream.h b/thirdparty/fmt/include/fmt/ostream.h index 394d947c56..c3cdd4a61b 100644 --- a/thirdparty/fmt/include/fmt/ostream.h +++ b/thirdparty/fmt/include/fmt/ostream.h @@ -10,6 +10,12 @@ #include #include +#if defined(_WIN32) && defined(__GLIBCXX__) +# include +# include +#elif defined(_WIN32) && defined(_LIBCPP_VERSION) +# include <__std_stream> +#endif #include "format.h" @@ -51,43 +57,50 @@ struct is_streamable< (std::is_convertible::value && !std::is_enum::value)>> : std::false_type {}; -template FILE* get_file(std::basic_filebuf&) { - return nullptr; -} - -struct dummy_filebuf { - FILE* _Myfile; -}; -template struct ms_filebuf { - using type = dummy_filebuf; -}; -template struct ms_filebuf { - using type = T; -}; -using filebuf_type = ms_filebuf::type; - -FILE* get_file(filebuf_type& buf); - // Generate a unique explicit instantion in every translation unit using a tag // type in an anonymous namespace. namespace { -struct filebuf_access_tag {}; +struct file_access_tag {}; } // namespace -template -class filebuf_access { - friend FILE* get_file(filebuf_type& buf) { return buf.*file; } +template +class file_access { + friend auto get_file(BufType& obj) -> FILE* { return obj.*FileMemberPtr; } }; -template class filebuf_access; -inline bool write(std::filebuf& buf, fmt::string_view data) { - FILE* f = get_file(buf); - if (!f) return false; - print(f, data); - return true; +#if FMT_MSC_VERSION +template class file_access; +auto get_file(std::filebuf&) -> FILE*; +#elif defined(_WIN32) && defined(_LIBCPP_VERSION) +template class file_access, + &std::__stdoutbuf::__file_>; +auto get_file(std::__stdoutbuf&) -> FILE*; +#endif + +inline bool write_ostream_unicode(std::ostream& os, fmt::string_view data) { +#if FMT_MSC_VERSION + if (auto* buf = dynamic_cast(os.rdbuf())) + if (FILE* f = get_file(*buf)) return write_console(f, data); +#elif defined(_WIN32) && defined(__GLIBCXX__) + auto* rdbuf = os.rdbuf(); + FILE* c_file; + if (auto* fbuf = dynamic_cast<__gnu_cxx::stdio_sync_filebuf*>(rdbuf)) + c_file = fbuf->file(); + else if (auto* fbuf = dynamic_cast<__gnu_cxx::stdio_filebuf*>(rdbuf)) + c_file = fbuf->file(); + else + return false; + if (c_file) return write_console(c_file, data); +#elif defined(_WIN32) && defined(_LIBCPP_VERSION) + if (auto* buf = dynamic_cast*>(os.rdbuf())) + if (FILE* f = get_file(*buf)) return write_console(f, data); +#else + ignore_unused(os, data); +#endif + return false; } -inline bool write(std::wfilebuf&, fmt::basic_string_view) { +inline bool write_ostream_unicode(std::wostream&, + fmt::basic_string_view) { return false; } @@ -95,10 +108,6 @@ inline bool write(std::wfilebuf&, fmt::basic_string_view) { // It is a separate function rather than a part of vprint to simplify testing. template void write_buffer(std::basic_ostream& os, buffer& buf) { - if (const_check(FMT_MSC_VERSION)) { - auto filebuf = dynamic_cast*>(os.rdbuf()); - if (filebuf && write(*filebuf, {buf.data(), buf.size()})) return; - } const Char* buf_data = buf.data(); using unsigned_streamsize = std::make_unsigned::type; unsigned_streamsize size = buf.size(); @@ -130,6 +139,8 @@ template struct streamed_view { const T& value; }; // Formats an object of type T that has an overloaded ostream operator<<. template struct basic_ostream_formatter : formatter, Char> { + void set_debug_format() = delete; + template auto format(const T& value, basic_format_context& ctx) const -> OutputIt { @@ -142,12 +153,13 @@ struct basic_ostream_formatter : formatter, Char> { using ostream_formatter = basic_ostream_formatter; -template -struct formatter> : ostream_formatter { +template +struct formatter, Char> + : basic_ostream_formatter { template auto format(detail::streamed_view view, - basic_format_context& ctx) const -> OutputIt { - return ostream_formatter::format(view.value, ctx); + basic_format_context& ctx) const -> OutputIt { + return basic_ostream_formatter::format(view.value, ctx); } }; @@ -175,6 +187,13 @@ struct fallback_formatter::value>> using basic_ostream_formatter::format; }; +inline void vprint_directly(std::ostream& os, string_view format_str, + format_args args) { + auto buffer = memory_buffer(); + detail::vformat_to(buffer, format_str, args); + detail::write_buffer(os, buffer); +} + } // namespace detail FMT_MODULE_EXPORT template @@ -183,6 +202,7 @@ void vprint(std::basic_ostream& os, basic_format_args>> args) { auto buffer = basic_memory_buffer(); detail::vformat_to(buffer, format_str, args); + if (detail::write_ostream_unicode(os, {buffer.data(), buffer.size()})) return; detail::write_buffer(os, buffer); } @@ -197,7 +217,11 @@ void vprint(std::basic_ostream& os, */ FMT_MODULE_EXPORT template void print(std::ostream& os, format_string fmt, T&&... args) { - vprint(os, fmt, fmt::make_format_args(args...)); + const auto& vargs = fmt::make_format_args(args...); + if (detail::is_utf8()) + vprint(os, fmt, vargs); + else + detail::vprint_directly(os, fmt, vargs); } FMT_MODULE_EXPORT diff --git a/thirdparty/fmt/include/fmt/ranges.h b/thirdparty/fmt/include/fmt/ranges.h index 10429fc8ed..dea7d60dd6 100644 --- a/thirdparty/fmt/include/fmt/ranges.h +++ b/thirdparty/fmt/include/fmt/ranges.h @@ -270,8 +270,8 @@ template using uncvref_type = remove_cvref_t>; template -using uncvref_first_type = remove_cvref_t< - decltype(std::declval>().first)>; +using uncvref_first_type = + remove_cvref_t>().first)>; template using uncvref_second_type = remove_cvref_t< @@ -326,18 +326,37 @@ struct formatter::value && fmt::is_tuple_formattable::value>> { private: + basic_string_view separator_ = detail::string_literal{}; + basic_string_view opening_bracket_ = + detail::string_literal{}; + basic_string_view closing_bracket_ = + detail::string_literal{}; + // C++11 generic lambda for format(). template struct format_each { template void operator()(const T& v) { - if (i > 0) out = detail::write_delimiter(out); + if (i > 0) out = detail::copy_str(separator, out); out = detail::write_range_entry(out, v); ++i; } int i; typename FormatContext::iterator& out; + basic_string_view separator; }; public: + FMT_CONSTEXPR formatter() {} + + FMT_CONSTEXPR void set_separator(basic_string_view sep) { + separator_ = sep; + } + + FMT_CONSTEXPR void set_brackets(basic_string_view open, + basic_string_view close) { + opening_bracket_ = open; + closing_bracket_ = close; + } + template FMT_CONSTEXPR auto parse(ParseContext& ctx) -> decltype(ctx.begin()) { return ctx.begin(); @@ -347,9 +366,9 @@ struct formatter decltype(ctx.out()) { auto out = ctx.out(); - *out++ = '('; - detail::for_each(values, format_each{0, out}); - *out++ = ')'; + out = detail::copy_str(opening_bracket_, out); + detail::for_each(values, format_each{0, out, separator_}); + out = detail::copy_str(closing_bracket_, out); return out; } }; @@ -357,9 +376,8 @@ struct formatter struct is_range { static constexpr const bool value = detail::is_range_::value && !detail::is_std_string_like::value && - !detail::is_map::value && !std::is_convertible>::value && - !std::is_constructible, T>::value; + !std::is_convertible>::value; }; namespace detail { @@ -390,40 +408,88 @@ using range_formatter_type = conditional_t< template using maybe_const_range = conditional_t::value, const R, R>; + +// Workaround a bug in MSVC 2015 and earlier. +#if !FMT_MSC_VERSION || FMT_MSC_VERSION >= 1910 +template +struct is_formattable_delayed + : disjunction< + is_formattable>, Char>, + has_fallback_formatter>, Char>> {}; +#endif + } // namespace detail -template -struct formatter< - R, Char, - enable_if_t< - conjunction -// Workaround a bug in MSVC 2017 and earlier. -#if !FMT_MSC_VERSION || FMT_MSC_VERSION >= 1920 - , - disjunction< - is_formattable>, - Char>, - detail::has_fallback_formatter< - detail::uncvref_type>, Char> - > -#endif - >::value - >> { +template +struct range_formatter; - using range_type = detail::maybe_const_range; - using formatter_type = - detail::range_formatter_type>; - formatter_type underlying_; +template +struct range_formatter< + T, Char, + enable_if_t>, + disjunction, + detail::has_fallback_formatter>>::value>> { + private: + detail::range_formatter_type underlying_; bool custom_specs_ = false; + basic_string_view separator_ = detail::string_literal{}; + basic_string_view opening_bracket_ = + detail::string_literal{}; + basic_string_view closing_bracket_ = + detail::string_literal{}; + + template + FMT_CONSTEXPR static auto maybe_set_debug_format(U& u, int) + -> decltype(u.set_debug_format()) { + u.set_debug_format(); + } + + template + FMT_CONSTEXPR static void maybe_set_debug_format(U&, ...) {} + + FMT_CONSTEXPR void maybe_set_debug_format() { + maybe_set_debug_format(underlying_, 0); + } + + public: + FMT_CONSTEXPR range_formatter() {} + + FMT_CONSTEXPR auto underlying() -> detail::range_formatter_type& { + return underlying_; + } + + FMT_CONSTEXPR void set_separator(basic_string_view sep) { + separator_ = sep; + } + + FMT_CONSTEXPR void set_brackets(basic_string_view open, + basic_string_view close) { + opening_bracket_ = open; + closing_bracket_ = close; + } template FMT_CONSTEXPR auto parse(ParseContext& ctx) -> decltype(ctx.begin()) { auto it = ctx.begin(); auto end = ctx.end(); - if (it == end || *it == '}') return it; + if (it == end || *it == '}') { + maybe_set_debug_format(); + return it; + } + + if (*it == 'n') { + set_brackets({}, {}); + ++it; + } + + if (*it == '}') { + maybe_set_debug_format(); + return it; + } if (*it != ':') - FMT_THROW(format_error("no top-level range formatters supported")); + FMT_THROW(format_error("no other top-level range formatters supported")); custom_specs_ = true; ++it; @@ -431,75 +497,100 @@ struct formatter< return underlying_.parse(ctx); } - template - auto format(range_type& range, FormatContext& ctx) const - -> decltype(ctx.out()) { - Char prefix = detail::is_set::value ? '{' : '['; - Char postfix = detail::is_set::value ? '}' : ']'; + template + auto format(R&& range, FormatContext& ctx) const -> decltype(ctx.out()) { detail::range_mapper> mapper; auto out = ctx.out(); - *out++ = prefix; + out = detail::copy_str(opening_bracket_, out); int i = 0; auto it = detail::range_begin(range); auto end = detail::range_end(range); for (; it != end; ++it) { - if (i > 0) out = detail::write_delimiter(out); - if (custom_specs_) { - ctx.advance_to(out); - out = underlying_.format(mapper.map(*it), ctx); - } else { - out = detail::write_range_entry(out, *it); - } + if (i > 0) out = detail::copy_str(separator_, out); + ; + ctx.advance_to(out); + out = underlying_.format(mapper.map(*it), ctx); ++i; } - *out++ = postfix; + out = detail::copy_str(closing_bracket_, out); return out; } }; -template -struct formatter< - T, Char, - enable_if_t -// Workaround a bug in MSVC 2017 and earlier. -#if !FMT_MSC_VERSION || FMT_MSC_VERSION >= 1920 - , - disjunction< - is_formattable, Char>, - detail::has_fallback_formatter, Char> - >, - disjunction< - is_formattable, Char>, - detail::has_fallback_formatter, Char> - > -#endif - >::value - >> { - template - FMT_CONSTEXPR auto parse(ParseContext& ctx) -> decltype(ctx.begin()) { - return ctx.begin(); +enum class range_format { disabled, map, set, sequence, string, debug_string }; + +namespace detail { +template struct range_format_kind_ { + static constexpr auto value = std::is_same, T>::value + ? range_format::disabled + : is_map::value ? range_format::map + : is_set::value ? range_format::set + : range_format::sequence; +}; + +template +struct range_default_formatter; + +template +using range_format_constant = std::integral_constant; + +template +struct range_default_formatter< + K, R, Char, + enable_if_t<(K == range_format::sequence || K == range_format::map || + K == range_format::set)>> { + using range_type = detail::maybe_const_range; + range_formatter, Char> underlying_; + + FMT_CONSTEXPR range_default_formatter() { init(range_format_constant()); } + + FMT_CONSTEXPR void init(range_format_constant) { + underlying_.set_brackets(detail::string_literal{}, + detail::string_literal{}); } - template < - typename FormatContext, typename U, - FMT_ENABLE_IF( - std::is_same::value, - const T, T>>::value)> - auto format(U& map, FormatContext& ctx) const -> decltype(ctx.out()) { - auto out = ctx.out(); - *out++ = '{'; - int i = 0; - for (const auto& item : map) { - if (i > 0) out = detail::write_delimiter(out); - out = detail::write_range_entry(out, item.first); - *out++ = ':'; - *out++ = ' '; - out = detail::write_range_entry(out, item.second); - ++i; - } - *out++ = '}'; - return out; + FMT_CONSTEXPR void init(range_format_constant) { + underlying_.set_brackets(detail::string_literal{}, + detail::string_literal{}); + underlying_.underlying().set_brackets({}, {}); + underlying_.underlying().set_separator( + detail::string_literal{}); } + + FMT_CONSTEXPR void init(range_format_constant) {} + + template + FMT_CONSTEXPR auto parse(ParseContext& ctx) -> decltype(ctx.begin()) { + return underlying_.parse(ctx); + } + + template + auto format(range_type& range, FormatContext& ctx) const + -> decltype(ctx.out()) { + return underlying_.format(range, ctx); + } +}; +} // namespace detail + +template +struct range_format_kind + : conditional_t< + is_range::value, detail::range_format_kind_, + std::integral_constant> {}; + +template +struct formatter< + R, Char, + enable_if_t::value != + range_format::disabled> +// Workaround a bug in MSVC 2015 and earlier. +#if !FMT_MSC_VERSION || FMT_MSC_VERSION >= 1910 + , + detail::is_formattable_delayed +#endif + >::value>> + : detail::range_default_formatter::value, R, + Char> { }; template struct tuple_join_view : detail::view { diff --git a/thirdparty/fmt/include/fmt/std.h b/thirdparty/fmt/include/fmt/std.h index 227f484112..41d2b2838b 100644 --- a/thirdparty/fmt/include/fmt/std.h +++ b/thirdparty/fmt/include/fmt/std.h @@ -57,10 +57,6 @@ inline void write_escaped_path( } // namespace detail -#if !FMT_MSC_VERSION || FMT_MSC_VERSION >= 1920 -// For MSVC 2017 and earlier using the partial specialization -// would cause an ambiguity error, therefore we provide it only -// conditionally. template struct formatter : formatter> { @@ -73,7 +69,6 @@ struct formatter basic_string_view(quoted.data(), quoted.size()), ctx); } }; -#endif FMT_END_NAMESPACE #endif diff --git a/thirdparty/fmt/include/fmt/xchar.h b/thirdparty/fmt/include/fmt/xchar.h index 2865b76efc..3b5bc15ca0 100644 --- a/thirdparty/fmt/include/fmt/xchar.h +++ b/thirdparty/fmt/include/fmt/xchar.h @@ -9,7 +9,6 @@ #define FMT_XCHAR_H_ #include -#include #include "format.h" @@ -30,9 +29,11 @@ using wmemory_buffer = basic_memory_buffer; #if FMT_GCC_VERSION && FMT_GCC_VERSION < 409 // Workaround broken conversion on older gcc. template using wformat_string = wstring_view; +inline auto runtime(wstring_view s) -> wstring_view { return s; } #else template using wformat_string = basic_format_string...>; +inline auto runtime(wstring_view s) -> basic_runtime { return {{s}}; } #endif template <> struct is_char : std::true_type {}; @@ -82,20 +83,16 @@ auto vformat(basic_string_view format_str, return to_string(buffer); } -#if !FMT_GCC_VERSION || FMT_GCC_VERSION >= 409 -template -using wformat_string = basic_format_string...>; -#endif - template auto format(wformat_string fmt, T&&... args) -> std::wstring { - return vformat(fmt, fmt::make_wformat_args(args...)); + return vformat(fmt::wstring_view(fmt), fmt::make_wformat_args(args...)); } // Pass char_t as a default template parameter instead of using // std::basic_string> to reduce the symbol size. template , - FMT_ENABLE_IF(!std::is_same::value)> + FMT_ENABLE_IF(!std::is_same::value && + !std::is_same::value)> auto format(const S& format_str, Args&&... args) -> std::basic_string { return vformat(detail::to_string_view(format_str), fmt::make_format_args>(args...)); diff --git a/thirdparty/fmt/support/appveyor-build.py b/thirdparty/fmt/support/appveyor-build.py deleted file mode 100644 index 6544610326..0000000000 --- a/thirdparty/fmt/support/appveyor-build.py +++ /dev/null @@ -1,43 +0,0 @@ -#!/usr/bin/env python -# Build the project on AppVeyor. - -import os -from subprocess import check_call - -build = os.environ['BUILD'] -config = os.environ['CONFIGURATION'] -platform = os.environ['PLATFORM'] -path = os.environ['PATH'] -image = os.environ['APPVEYOR_BUILD_WORKER_IMAGE'] -jobid = os.environ['APPVEYOR_JOB_ID'] -cmake_command = ['cmake', '-DFMT_PEDANTIC=ON', '-DCMAKE_BUILD_TYPE=' + config, '..'] -if build == 'mingw': - cmake_command.append('-GMinGW Makefiles') - build_command = ['mingw32-make', '-j4'] - test_command = ['mingw32-make', 'test'] - # Remove the path to Git bin directory from $PATH because it breaks - # MinGW config. - path = path.replace(r'C:\Program Files (x86)\Git\bin', '') - os.environ['PATH'] = r'C:\MinGW\bin;' + path -else: - # Add MSBuild 14.0 to PATH as described in - # http://help.appveyor.com/discussions/problems/2229-v140-not-found-on-vs2105rc. - os.environ['PATH'] = r'C:\Program Files (x86)\MSBuild\15.0\Bin;' + path - if image == 'Visual Studio 2019': - generator = 'Visual Studio 16 2019' - if platform == 'x64': - cmake_command.extend(['-A', 'x64']) - else: - if image == 'Visual Studio 2015': - generator = 'Visual Studio 14 2015' - elif image == 'Visual Studio 2017': - generator = 'Visual Studio 15 2017' - if platform == 'x64': - generator += ' Win64' - cmake_command.append('-G' + generator) - build_command = ['cmake', '--build', '.', '--config', config, '--', '/m:4'] - test_command = ['ctest', '-C', config] - -check_call(cmake_command) -check_call(build_command) -check_call(test_command) diff --git a/thirdparty/fmt/support/appveyor.yml b/thirdparty/fmt/support/appveyor.yml deleted file mode 100644 index 64ca58a949..0000000000 --- a/thirdparty/fmt/support/appveyor.yml +++ /dev/null @@ -1,31 +0,0 @@ -configuration: - - Debug - - Release - -clone_depth: 1 - -image: - - Visual Studio 2015 - -platform: - - x64 - -environment: - CTEST_OUTPUT_ON_FAILURE: 1 - MSVC_DEFAULT_OPTIONS: ON - BUILD: msvc - -before_build: - - mkdir build - - cd build - -build_script: - - python ../support/appveyor-build.py - -on_failure: - - appveyor PushArtifact Testing/Temporary/LastTest.log - - appveyor AddTest test - -# Uncomment this to debug AppVeyor failures. -#on_finish: -# - ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1')) diff --git a/thirdparty/fmt/support/manage.py b/thirdparty/fmt/support/manage.py index bece4566f5..d2afcee92d 100644 --- a/thirdparty/fmt/support/manage.py +++ b/thirdparty/fmt/support/manage.py @@ -183,6 +183,12 @@ def update_site(env): with rewrite(index) as b: b.data = b.data.replace( 'doc/latest/index.html#format-string-syntax', 'syntax.html') + # Fix issues in syntax.rst. + index = os.path.join(target_doc_dir, 'syntax.rst') + with rewrite(index) as b: + b.data = b.data.replace( + '..productionlist:: sf\n', '.. productionlist:: sf\n ') + b.data = b.data.replace('Examples:\n', 'Examples::\n') # Build the docs. html_dir = os.path.join(env.build_dir, 'html') if os.path.exists(html_dir): diff --git a/thirdparty/llhttp/include/llhttp.h b/thirdparty/llhttp/include/llhttp.h index c9f1251ca4..4d5312e7aa 100644 --- a/thirdparty/llhttp/include/llhttp.h +++ b/thirdparty/llhttp/include/llhttp.h @@ -3,7 +3,7 @@ #define LLHTTP_VERSION_MAJOR 6 #define LLHTTP_VERSION_MINOR 0 -#define LLHTTP_VERSION_PATCH 7 +#define LLHTTP_VERSION_PATCH 9 #ifndef LLHTTP_STRICT_MODE # define LLHTTP_STRICT_MODE 0 @@ -102,7 +102,8 @@ enum llhttp_lenient_flags { LENIENT_HEADERS = 0x1, LENIENT_CHUNKED_LENGTH = 0x2, LENIENT_KEEP_ALIVE = 0x4, - LENIENT_TRANSFER_ENCODING = 0x8 + LENIENT_TRANSFER_ENCODING = 0x8, + LENIENT_VERSION = 0x10 }; typedef enum llhttp_lenient_flags llhttp_lenient_flags_t; diff --git a/thirdparty/llhttp/src/llhttp.c b/thirdparty/llhttp/src/llhttp.c index 296a1a75ac..9a0a35bd33 100644 --- a/thirdparty/llhttp/src/llhttp.c +++ b/thirdparty/llhttp/src/llhttp.c @@ -958,6 +958,27 @@ int llhttp__internal__c_store_http_minor( return 0; } +int llhttp__internal__c_test_lenient_flags_6( + llhttp__internal_t* state, + const unsigned char* p, + const unsigned char* endp) { + return (state->lenient_flags & 16) == 16; +} + +int llhttp__internal__c_load_http_major( + llhttp__internal_t* state, + const unsigned char* p, + const unsigned char* endp) { + return state->http_major; +} + +int llhttp__internal__c_load_http_minor( + llhttp__internal_t* state, + const unsigned char* p, + const unsigned char* endp) { + return state->http_minor; +} + int llhttp__internal__c_update_status_code( llhttp__internal_t* state, const unsigned char* p, @@ -2713,13 +2734,13 @@ static llparse_state_t llhttp__internal__run( switch (match_seq.status) { case kMatchComplete: { p++; - goto s_n_llhttp__internal__n_error_34; + goto s_n_llhttp__internal__n_error_36; } case kMatchPause: { return s_n_llhttp__internal__n_req_pri_upgrade; } case kMatchMismatch: { - goto s_n_llhttp__internal__n_error_35; + goto s_n_llhttp__internal__n_error_37; } } /* UNREACHABLE */; @@ -2736,7 +2757,7 @@ static llparse_state_t llhttp__internal__run( goto s_n_llhttp__internal__n_header_field_start; } default: { - goto s_n_llhttp__internal__n_error_33; + goto s_n_llhttp__internal__n_error_35; } } /* UNREACHABLE */; @@ -2757,7 +2778,7 @@ static llparse_state_t llhttp__internal__run( goto s_n_llhttp__internal__n_req_http_complete_1; } default: { - goto s_n_llhttp__internal__n_error_33; + goto s_n_llhttp__internal__n_error_35; } } /* UNREACHABLE */; @@ -2820,7 +2841,7 @@ static llparse_state_t llhttp__internal__run( goto s_n_llhttp__internal__n_invoke_store_http_minor; } default: { - goto s_n_llhttp__internal__n_error_36; + goto s_n_llhttp__internal__n_error_40; } } /* UNREACHABLE */; @@ -2837,7 +2858,7 @@ static llparse_state_t llhttp__internal__run( goto s_n_llhttp__internal__n_req_http_minor; } default: { - goto s_n_llhttp__internal__n_error_37; + goto s_n_llhttp__internal__n_error_41; } } /* UNREACHABLE */; @@ -2900,7 +2921,7 @@ static llparse_state_t llhttp__internal__run( goto s_n_llhttp__internal__n_invoke_store_http_major; } default: { - goto s_n_llhttp__internal__n_error_38; + goto s_n_llhttp__internal__n_error_42; } } /* UNREACHABLE */; @@ -2924,7 +2945,7 @@ static llparse_state_t llhttp__internal__run( return s_n_llhttp__internal__n_req_http_start_1; } case kMatchMismatch: { - goto s_n_llhttp__internal__n_error_41; + goto s_n_llhttp__internal__n_error_45; } } /* UNREACHABLE */; @@ -2948,7 +2969,7 @@ static llparse_state_t llhttp__internal__run( return s_n_llhttp__internal__n_req_http_start_2; } case kMatchMismatch: { - goto s_n_llhttp__internal__n_error_41; + goto s_n_llhttp__internal__n_error_45; } } /* UNREACHABLE */; @@ -2972,7 +2993,7 @@ static llparse_state_t llhttp__internal__run( return s_n_llhttp__internal__n_req_http_start_3; } case kMatchMismatch: { - goto s_n_llhttp__internal__n_error_41; + goto s_n_llhttp__internal__n_error_45; } } /* UNREACHABLE */; @@ -3001,7 +3022,7 @@ static llparse_state_t llhttp__internal__run( goto s_n_llhttp__internal__n_req_http_start_3; } default: { - goto s_n_llhttp__internal__n_error_41; + goto s_n_llhttp__internal__n_error_45; } } /* UNREACHABLE */; @@ -3092,7 +3113,7 @@ static llparse_state_t llhttp__internal__run( goto s_n_llhttp__internal__n_url_fragment; } default: { - goto s_n_llhttp__internal__n_error_42; + goto s_n_llhttp__internal__n_error_46; } } /* UNREACHABLE */; @@ -3153,7 +3174,7 @@ static llparse_state_t llhttp__internal__run( goto s_n_llhttp__internal__n_span_end_stub_query_3; } default: { - goto s_n_llhttp__internal__n_error_43; + goto s_n_llhttp__internal__n_error_47; } } /* UNREACHABLE */; @@ -3191,7 +3212,7 @@ static llparse_state_t llhttp__internal__run( goto s_n_llhttp__internal__n_url_query; } default: { - goto s_n_llhttp__internal__n_error_44; + goto s_n_llhttp__internal__n_error_48; } } /* UNREACHABLE */; @@ -3316,10 +3337,10 @@ static llparse_state_t llhttp__internal__run( } case 8: { p++; - goto s_n_llhttp__internal__n_error_45; + goto s_n_llhttp__internal__n_error_49; } default: { - goto s_n_llhttp__internal__n_error_46; + goto s_n_llhttp__internal__n_error_50; } } /* UNREACHABLE */; @@ -3378,7 +3399,7 @@ static llparse_state_t llhttp__internal__run( goto s_n_llhttp__internal__n_url_server_with_at; } default: { - goto s_n_llhttp__internal__n_error_47; + goto s_n_llhttp__internal__n_error_51; } } /* UNREACHABLE */; @@ -3395,7 +3416,7 @@ static llparse_state_t llhttp__internal__run( goto s_n_llhttp__internal__n_url_server; } default: { - goto s_n_llhttp__internal__n_error_49; + goto s_n_llhttp__internal__n_error_53; } } /* UNREACHABLE */; @@ -3413,7 +3434,7 @@ static llparse_state_t llhttp__internal__run( } case 10: { p++; - goto s_n_llhttp__internal__n_error_48; + goto s_n_llhttp__internal__n_error_52; } case 12: { p++; @@ -3421,18 +3442,18 @@ static llparse_state_t llhttp__internal__run( } case 13: { p++; - goto s_n_llhttp__internal__n_error_48; + goto s_n_llhttp__internal__n_error_52; } case ' ': { p++; - goto s_n_llhttp__internal__n_error_48; + goto s_n_llhttp__internal__n_error_52; } case '/': { p++; goto s_n_llhttp__internal__n_url_schema_delim_1; } default: { - goto s_n_llhttp__internal__n_error_49; + goto s_n_llhttp__internal__n_error_53; } } /* UNREACHABLE */; @@ -3478,7 +3499,7 @@ static llparse_state_t llhttp__internal__run( } case 2: { p++; - goto s_n_llhttp__internal__n_error_48; + goto s_n_llhttp__internal__n_error_52; } case 3: { goto s_n_llhttp__internal__n_span_end_stub_schema; @@ -3488,7 +3509,7 @@ static llparse_state_t llhttp__internal__run( goto s_n_llhttp__internal__n_url_schema; } default: { - goto s_n_llhttp__internal__n_error_50; + goto s_n_llhttp__internal__n_error_54; } } /* UNREACHABLE */; @@ -3524,7 +3545,7 @@ static llparse_state_t llhttp__internal__run( } case 2: { p++; - goto s_n_llhttp__internal__n_error_48; + goto s_n_llhttp__internal__n_error_52; } case 3: { goto s_n_llhttp__internal__n_span_start_stub_path_2; @@ -3533,7 +3554,7 @@ static llparse_state_t llhttp__internal__run( goto s_n_llhttp__internal__n_url_schema; } default: { - goto s_n_llhttp__internal__n_error_51; + goto s_n_llhttp__internal__n_error_55; } } /* UNREACHABLE */; @@ -3631,7 +3652,7 @@ static llparse_state_t llhttp__internal__run( goto s_n_llhttp__internal__n_req_spaces_before_url; } default: { - goto s_n_llhttp__internal__n_error_52; + goto s_n_llhttp__internal__n_error_56; } } /* UNREACHABLE */; @@ -3649,7 +3670,7 @@ static llparse_state_t llhttp__internal__run( goto s_n_llhttp__internal__n_invoke_store_method_1; } default: { - goto s_n_llhttp__internal__n_error_61; + goto s_n_llhttp__internal__n_error_69; } } /* UNREACHABLE */; @@ -3674,7 +3695,7 @@ static llparse_state_t llhttp__internal__run( return s_n_llhttp__internal__n_start_req_3; } case kMatchMismatch: { - goto s_n_llhttp__internal__n_error_61; + goto s_n_llhttp__internal__n_error_69; } } /* UNREACHABLE */; @@ -3695,7 +3716,7 @@ static llparse_state_t llhttp__internal__run( goto s_n_llhttp__internal__n_start_req_3; } default: { - goto s_n_llhttp__internal__n_error_61; + goto s_n_llhttp__internal__n_error_69; } } /* UNREACHABLE */; @@ -3720,7 +3741,7 @@ static llparse_state_t llhttp__internal__run( return s_n_llhttp__internal__n_start_req_4; } case kMatchMismatch: { - goto s_n_llhttp__internal__n_error_61; + goto s_n_llhttp__internal__n_error_69; } } /* UNREACHABLE */; @@ -3745,7 +3766,7 @@ static llparse_state_t llhttp__internal__run( return s_n_llhttp__internal__n_start_req_6; } case kMatchMismatch: { - goto s_n_llhttp__internal__n_error_61; + goto s_n_llhttp__internal__n_error_69; } } /* UNREACHABLE */; @@ -3770,7 +3791,7 @@ static llparse_state_t llhttp__internal__run( return s_n_llhttp__internal__n_start_req_8; } case kMatchMismatch: { - goto s_n_llhttp__internal__n_error_61; + goto s_n_llhttp__internal__n_error_69; } } /* UNREACHABLE */; @@ -3788,7 +3809,7 @@ static llparse_state_t llhttp__internal__run( goto s_n_llhttp__internal__n_invoke_store_method_1; } default: { - goto s_n_llhttp__internal__n_error_61; + goto s_n_llhttp__internal__n_error_69; } } /* UNREACHABLE */; @@ -3809,7 +3830,7 @@ static llparse_state_t llhttp__internal__run( goto s_n_llhttp__internal__n_start_req_9; } default: { - goto s_n_llhttp__internal__n_error_61; + goto s_n_llhttp__internal__n_error_69; } } /* UNREACHABLE */; @@ -3830,7 +3851,7 @@ static llparse_state_t llhttp__internal__run( goto s_n_llhttp__internal__n_start_req_7; } default: { - goto s_n_llhttp__internal__n_error_61; + goto s_n_llhttp__internal__n_error_69; } } /* UNREACHABLE */; @@ -3855,7 +3876,7 @@ static llparse_state_t llhttp__internal__run( return s_n_llhttp__internal__n_start_req_12; } case kMatchMismatch: { - goto s_n_llhttp__internal__n_error_61; + goto s_n_llhttp__internal__n_error_69; } } /* UNREACHABLE */; @@ -3880,7 +3901,7 @@ static llparse_state_t llhttp__internal__run( return s_n_llhttp__internal__n_start_req_13; } case kMatchMismatch: { - goto s_n_llhttp__internal__n_error_61; + goto s_n_llhttp__internal__n_error_69; } } /* UNREACHABLE */; @@ -3901,7 +3922,7 @@ static llparse_state_t llhttp__internal__run( goto s_n_llhttp__internal__n_start_req_13; } default: { - goto s_n_llhttp__internal__n_error_61; + goto s_n_llhttp__internal__n_error_69; } } /* UNREACHABLE */; @@ -3918,7 +3939,7 @@ static llparse_state_t llhttp__internal__run( goto s_n_llhttp__internal__n_start_req_11; } default: { - goto s_n_llhttp__internal__n_error_61; + goto s_n_llhttp__internal__n_error_69; } } /* UNREACHABLE */; @@ -3943,7 +3964,7 @@ static llparse_state_t llhttp__internal__run( return s_n_llhttp__internal__n_start_req_14; } case kMatchMismatch: { - goto s_n_llhttp__internal__n_error_61; + goto s_n_llhttp__internal__n_error_69; } } /* UNREACHABLE */; @@ -3968,7 +3989,7 @@ static llparse_state_t llhttp__internal__run( return s_n_llhttp__internal__n_start_req_17; } case kMatchMismatch: { - goto s_n_llhttp__internal__n_error_61; + goto s_n_llhttp__internal__n_error_69; } } /* UNREACHABLE */; @@ -4010,7 +4031,7 @@ static llparse_state_t llhttp__internal__run( return s_n_llhttp__internal__n_start_req_15; } case kMatchMismatch: { - goto s_n_llhttp__internal__n_error_61; + goto s_n_llhttp__internal__n_error_69; } } /* UNREACHABLE */; @@ -4035,7 +4056,7 @@ static llparse_state_t llhttp__internal__run( return s_n_llhttp__internal__n_start_req_18; } case kMatchMismatch: { - goto s_n_llhttp__internal__n_error_61; + goto s_n_llhttp__internal__n_error_69; } } /* UNREACHABLE */; @@ -4060,7 +4081,7 @@ static llparse_state_t llhttp__internal__run( return s_n_llhttp__internal__n_start_req_20; } case kMatchMismatch: { - goto s_n_llhttp__internal__n_error_61; + goto s_n_llhttp__internal__n_error_69; } } /* UNREACHABLE */; @@ -4085,7 +4106,7 @@ static llparse_state_t llhttp__internal__run( return s_n_llhttp__internal__n_start_req_21; } case kMatchMismatch: { - goto s_n_llhttp__internal__n_error_61; + goto s_n_llhttp__internal__n_error_69; } } /* UNREACHABLE */; @@ -4106,7 +4127,7 @@ static llparse_state_t llhttp__internal__run( goto s_n_llhttp__internal__n_start_req_21; } default: { - goto s_n_llhttp__internal__n_error_61; + goto s_n_llhttp__internal__n_error_69; } } /* UNREACHABLE */; @@ -4131,7 +4152,7 @@ static llparse_state_t llhttp__internal__run( return s_n_llhttp__internal__n_start_req_23; } case kMatchMismatch: { - goto s_n_llhttp__internal__n_error_61; + goto s_n_llhttp__internal__n_error_69; } } /* UNREACHABLE */; @@ -4156,7 +4177,7 @@ static llparse_state_t llhttp__internal__run( return s_n_llhttp__internal__n_start_req_24; } case kMatchMismatch: { - goto s_n_llhttp__internal__n_error_61; + goto s_n_llhttp__internal__n_error_69; } } /* UNREACHABLE */; @@ -4181,7 +4202,7 @@ static llparse_state_t llhttp__internal__run( return s_n_llhttp__internal__n_start_req_26; } case kMatchMismatch: { - goto s_n_llhttp__internal__n_error_61; + goto s_n_llhttp__internal__n_error_69; } } /* UNREACHABLE */; @@ -4206,7 +4227,7 @@ static llparse_state_t llhttp__internal__run( return s_n_llhttp__internal__n_start_req_28; } case kMatchMismatch: { - goto s_n_llhttp__internal__n_error_61; + goto s_n_llhttp__internal__n_error_69; } } /* UNREACHABLE */; @@ -4224,7 +4245,7 @@ static llparse_state_t llhttp__internal__run( goto s_n_llhttp__internal__n_invoke_store_method_1; } default: { - goto s_n_llhttp__internal__n_error_61; + goto s_n_llhttp__internal__n_error_69; } } /* UNREACHABLE */; @@ -4245,7 +4266,7 @@ static llparse_state_t llhttp__internal__run( goto s_n_llhttp__internal__n_start_req_29; } default: { - goto s_n_llhttp__internal__n_error_61; + goto s_n_llhttp__internal__n_error_69; } } /* UNREACHABLE */; @@ -4266,7 +4287,7 @@ static llparse_state_t llhttp__internal__run( goto s_n_llhttp__internal__n_start_req_27; } default: { - goto s_n_llhttp__internal__n_error_61; + goto s_n_llhttp__internal__n_error_69; } } /* UNREACHABLE */; @@ -4291,7 +4312,7 @@ static llparse_state_t llhttp__internal__run( return s_n_llhttp__internal__n_start_req_30; } case kMatchMismatch: { - goto s_n_llhttp__internal__n_error_61; + goto s_n_llhttp__internal__n_error_69; } } /* UNREACHABLE */; @@ -4320,7 +4341,7 @@ static llparse_state_t llhttp__internal__run( goto s_n_llhttp__internal__n_start_req_30; } default: { - goto s_n_llhttp__internal__n_error_61; + goto s_n_llhttp__internal__n_error_69; } } /* UNREACHABLE */; @@ -4345,7 +4366,7 @@ static llparse_state_t llhttp__internal__run( return s_n_llhttp__internal__n_start_req_31; } case kMatchMismatch: { - goto s_n_llhttp__internal__n_error_61; + goto s_n_llhttp__internal__n_error_69; } } /* UNREACHABLE */; @@ -4370,7 +4391,7 @@ static llparse_state_t llhttp__internal__run( return s_n_llhttp__internal__n_start_req_32; } case kMatchMismatch: { - goto s_n_llhttp__internal__n_error_61; + goto s_n_llhttp__internal__n_error_69; } } /* UNREACHABLE */; @@ -4395,7 +4416,7 @@ static llparse_state_t llhttp__internal__run( return s_n_llhttp__internal__n_start_req_35; } case kMatchMismatch: { - goto s_n_llhttp__internal__n_error_61; + goto s_n_llhttp__internal__n_error_69; } } /* UNREACHABLE */; @@ -4420,7 +4441,7 @@ static llparse_state_t llhttp__internal__run( return s_n_llhttp__internal__n_start_req_36; } case kMatchMismatch: { - goto s_n_llhttp__internal__n_error_61; + goto s_n_llhttp__internal__n_error_69; } } /* UNREACHABLE */; @@ -4441,7 +4462,7 @@ static llparse_state_t llhttp__internal__run( goto s_n_llhttp__internal__n_start_req_36; } default: { - goto s_n_llhttp__internal__n_error_61; + goto s_n_llhttp__internal__n_error_69; } } /* UNREACHABLE */; @@ -4466,7 +4487,7 @@ static llparse_state_t llhttp__internal__run( return s_n_llhttp__internal__n_start_req_37; } case kMatchMismatch: { - goto s_n_llhttp__internal__n_error_61; + goto s_n_llhttp__internal__n_error_69; } } /* UNREACHABLE */; @@ -4491,7 +4512,7 @@ static llparse_state_t llhttp__internal__run( return s_n_llhttp__internal__n_start_req_38; } case kMatchMismatch: { - goto s_n_llhttp__internal__n_error_61; + goto s_n_llhttp__internal__n_error_69; } } /* UNREACHABLE */; @@ -4516,7 +4537,7 @@ static llparse_state_t llhttp__internal__run( return s_n_llhttp__internal__n_start_req_42; } case kMatchMismatch: { - goto s_n_llhttp__internal__n_error_61; + goto s_n_llhttp__internal__n_error_69; } } /* UNREACHABLE */; @@ -4541,7 +4562,7 @@ static llparse_state_t llhttp__internal__run( return s_n_llhttp__internal__n_start_req_43; } case kMatchMismatch: { - goto s_n_llhttp__internal__n_error_61; + goto s_n_llhttp__internal__n_error_69; } } /* UNREACHABLE */; @@ -4562,7 +4583,7 @@ static llparse_state_t llhttp__internal__run( goto s_n_llhttp__internal__n_start_req_43; } default: { - goto s_n_llhttp__internal__n_error_61; + goto s_n_llhttp__internal__n_error_69; } } /* UNREACHABLE */; @@ -4579,7 +4600,7 @@ static llparse_state_t llhttp__internal__run( goto s_n_llhttp__internal__n_start_req_41; } default: { - goto s_n_llhttp__internal__n_error_61; + goto s_n_llhttp__internal__n_error_69; } } /* UNREACHABLE */; @@ -4601,7 +4622,7 @@ static llparse_state_t llhttp__internal__run( goto s_n_llhttp__internal__n_start_req_40; } default: { - goto s_n_llhttp__internal__n_error_61; + goto s_n_llhttp__internal__n_error_69; } } /* UNREACHABLE */; @@ -4626,7 +4647,7 @@ static llparse_state_t llhttp__internal__run( return s_n_llhttp__internal__n_start_req_45; } case kMatchMismatch: { - goto s_n_llhttp__internal__n_error_61; + goto s_n_llhttp__internal__n_error_69; } } /* UNREACHABLE */; @@ -4648,7 +4669,7 @@ static llparse_state_t llhttp__internal__run( goto s_n_llhttp__internal__n_invoke_store_method_1; } default: { - goto s_n_llhttp__internal__n_error_61; + goto s_n_llhttp__internal__n_error_69; } } /* UNREACHABLE */; @@ -4681,7 +4702,7 @@ static llparse_state_t llhttp__internal__run( goto s_n_llhttp__internal__n_start_req_44; } default: { - goto s_n_llhttp__internal__n_error_61; + goto s_n_llhttp__internal__n_error_69; } } /* UNREACHABLE */; @@ -4706,7 +4727,7 @@ static llparse_state_t llhttp__internal__run( return s_n_llhttp__internal__n_start_req_48; } case kMatchMismatch: { - goto s_n_llhttp__internal__n_error_61; + goto s_n_llhttp__internal__n_error_69; } } /* UNREACHABLE */; @@ -4731,7 +4752,7 @@ static llparse_state_t llhttp__internal__run( return s_n_llhttp__internal__n_start_req_49; } case kMatchMismatch: { - goto s_n_llhttp__internal__n_error_61; + goto s_n_llhttp__internal__n_error_69; } } /* UNREACHABLE */; @@ -4756,7 +4777,7 @@ static llparse_state_t llhttp__internal__run( return s_n_llhttp__internal__n_start_req_50; } case kMatchMismatch: { - goto s_n_llhttp__internal__n_error_61; + goto s_n_llhttp__internal__n_error_69; } } /* UNREACHABLE */; @@ -4781,7 +4802,7 @@ static llparse_state_t llhttp__internal__run( return s_n_llhttp__internal__n_start_req_51; } case kMatchMismatch: { - goto s_n_llhttp__internal__n_error_61; + goto s_n_llhttp__internal__n_error_69; } } /* UNREACHABLE */; @@ -4810,7 +4831,7 @@ static llparse_state_t llhttp__internal__run( goto s_n_llhttp__internal__n_start_req_51; } default: { - goto s_n_llhttp__internal__n_error_61; + goto s_n_llhttp__internal__n_error_69; } } /* UNREACHABLE */; @@ -4827,7 +4848,7 @@ static llparse_state_t llhttp__internal__run( goto s_n_llhttp__internal__n_start_req_47; } default: { - goto s_n_llhttp__internal__n_error_61; + goto s_n_llhttp__internal__n_error_69; } } /* UNREACHABLE */; @@ -4852,7 +4873,7 @@ static llparse_state_t llhttp__internal__run( return s_n_llhttp__internal__n_start_req_54; } case kMatchMismatch: { - goto s_n_llhttp__internal__n_error_61; + goto s_n_llhttp__internal__n_error_69; } } /* UNREACHABLE */; @@ -4870,7 +4891,7 @@ static llparse_state_t llhttp__internal__run( goto s_n_llhttp__internal__n_invoke_store_method_1; } default: { - goto s_n_llhttp__internal__n_error_61; + goto s_n_llhttp__internal__n_error_69; } } /* UNREACHABLE */; @@ -4895,7 +4916,7 @@ static llparse_state_t llhttp__internal__run( return s_n_llhttp__internal__n_start_req_57; } case kMatchMismatch: { - goto s_n_llhttp__internal__n_error_61; + goto s_n_llhttp__internal__n_error_69; } } /* UNREACHABLE */; @@ -4916,7 +4937,7 @@ static llparse_state_t llhttp__internal__run( goto s_n_llhttp__internal__n_start_req_57; } default: { - goto s_n_llhttp__internal__n_error_61; + goto s_n_llhttp__internal__n_error_69; } } /* UNREACHABLE */; @@ -4937,7 +4958,7 @@ static llparse_state_t llhttp__internal__run( goto s_n_llhttp__internal__n_start_req_55; } default: { - goto s_n_llhttp__internal__n_error_61; + goto s_n_llhttp__internal__n_error_69; } } /* UNREACHABLE */; @@ -4962,7 +4983,7 @@ static llparse_state_t llhttp__internal__run( return s_n_llhttp__internal__n_start_req_58; } case kMatchMismatch: { - goto s_n_llhttp__internal__n_error_61; + goto s_n_llhttp__internal__n_error_69; } } /* UNREACHABLE */; @@ -4987,7 +5008,7 @@ static llparse_state_t llhttp__internal__run( return s_n_llhttp__internal__n_start_req_59; } case kMatchMismatch: { - goto s_n_llhttp__internal__n_error_61; + goto s_n_llhttp__internal__n_error_69; } } /* UNREACHABLE */; @@ -5012,7 +5033,7 @@ static llparse_state_t llhttp__internal__run( goto s_n_llhttp__internal__n_start_req_59; } default: { - goto s_n_llhttp__internal__n_error_61; + goto s_n_llhttp__internal__n_error_69; } } /* UNREACHABLE */; @@ -5037,7 +5058,7 @@ static llparse_state_t llhttp__internal__run( return s_n_llhttp__internal__n_start_req_61; } case kMatchMismatch: { - goto s_n_llhttp__internal__n_error_61; + goto s_n_llhttp__internal__n_error_69; } } /* UNREACHABLE */; @@ -5062,7 +5083,7 @@ static llparse_state_t llhttp__internal__run( return s_n_llhttp__internal__n_start_req_62; } case kMatchMismatch: { - goto s_n_llhttp__internal__n_error_61; + goto s_n_llhttp__internal__n_error_69; } } /* UNREACHABLE */; @@ -5083,7 +5104,7 @@ static llparse_state_t llhttp__internal__run( goto s_n_llhttp__internal__n_start_req_62; } default: { - goto s_n_llhttp__internal__n_error_61; + goto s_n_llhttp__internal__n_error_69; } } /* UNREACHABLE */; @@ -5108,7 +5129,7 @@ static llparse_state_t llhttp__internal__run( return s_n_llhttp__internal__n_start_req_65; } case kMatchMismatch: { - goto s_n_llhttp__internal__n_error_61; + goto s_n_llhttp__internal__n_error_69; } } /* UNREACHABLE */; @@ -5133,7 +5154,7 @@ static llparse_state_t llhttp__internal__run( return s_n_llhttp__internal__n_start_req_67; } case kMatchMismatch: { - goto s_n_llhttp__internal__n_error_61; + goto s_n_llhttp__internal__n_error_69; } } /* UNREACHABLE */; @@ -5158,7 +5179,7 @@ static llparse_state_t llhttp__internal__run( return s_n_llhttp__internal__n_start_req_68; } case kMatchMismatch: { - goto s_n_llhttp__internal__n_error_61; + goto s_n_llhttp__internal__n_error_69; } } /* UNREACHABLE */; @@ -5179,7 +5200,7 @@ static llparse_state_t llhttp__internal__run( goto s_n_llhttp__internal__n_start_req_68; } default: { - goto s_n_llhttp__internal__n_error_61; + goto s_n_llhttp__internal__n_error_69; } } /* UNREACHABLE */; @@ -5204,7 +5225,7 @@ static llparse_state_t llhttp__internal__run( return s_n_llhttp__internal__n_start_req_69; } case kMatchMismatch: { - goto s_n_llhttp__internal__n_error_61; + goto s_n_llhttp__internal__n_error_69; } } /* UNREACHABLE */; @@ -5229,7 +5250,7 @@ static llparse_state_t llhttp__internal__run( goto s_n_llhttp__internal__n_start_req_69; } default: { - goto s_n_llhttp__internal__n_error_61; + goto s_n_llhttp__internal__n_error_69; } } /* UNREACHABLE */; @@ -5246,7 +5267,7 @@ static llparse_state_t llhttp__internal__run( goto s_n_llhttp__internal__n_start_req_64; } default: { - goto s_n_llhttp__internal__n_error_61; + goto s_n_llhttp__internal__n_error_69; } } /* UNREACHABLE */; @@ -5323,7 +5344,7 @@ static llparse_state_t llhttp__internal__run( goto s_n_llhttp__internal__n_start_req_63; } default: { - goto s_n_llhttp__internal__n_error_61; + goto s_n_llhttp__internal__n_error_69; } } /* UNREACHABLE */; @@ -5349,7 +5370,7 @@ static llparse_state_t llhttp__internal__run( goto s_n_llhttp__internal__n_invoke_llhttp__on_status_complete; } default: { - goto s_n_llhttp__internal__n_error_54; + goto s_n_llhttp__internal__n_error_60; } } /* UNREACHABLE */; @@ -5424,7 +5445,7 @@ static llparse_state_t llhttp__internal__run( goto s_n_llhttp__internal__n_res_status_start; } default: { - goto s_n_llhttp__internal__n_error_55; + goto s_n_llhttp__internal__n_error_61; } } /* UNREACHABLE */; @@ -5504,7 +5525,7 @@ static llparse_state_t llhttp__internal__run( goto s_n_llhttp__internal__n_invoke_update_status_code; } default: { - goto s_n_llhttp__internal__n_error_56; + goto s_n_llhttp__internal__n_error_62; } } /* UNREACHABLE */; @@ -5567,7 +5588,7 @@ static llparse_state_t llhttp__internal__run( goto s_n_llhttp__internal__n_invoke_store_http_minor_1; } default: { - goto s_n_llhttp__internal__n_error_57; + goto s_n_llhttp__internal__n_error_65; } } /* UNREACHABLE */; @@ -5584,7 +5605,7 @@ static llparse_state_t llhttp__internal__run( goto s_n_llhttp__internal__n_res_http_minor; } default: { - goto s_n_llhttp__internal__n_error_58; + goto s_n_llhttp__internal__n_error_66; } } /* UNREACHABLE */; @@ -5647,7 +5668,7 @@ static llparse_state_t llhttp__internal__run( goto s_n_llhttp__internal__n_invoke_store_http_major_1; } default: { - goto s_n_llhttp__internal__n_error_59; + goto s_n_llhttp__internal__n_error_67; } } /* UNREACHABLE */; @@ -5671,7 +5692,7 @@ static llparse_state_t llhttp__internal__run( return s_n_llhttp__internal__n_start_res; } case kMatchMismatch: { - goto s_n_llhttp__internal__n_error_62; + goto s_n_llhttp__internal__n_error_70; } } /* UNREACHABLE */; @@ -5696,7 +5717,7 @@ static llparse_state_t llhttp__internal__run( return s_n_llhttp__internal__n_req_or_res_method_2; } case kMatchMismatch: { - goto s_n_llhttp__internal__n_error_60; + goto s_n_llhttp__internal__n_error_68; } } /* UNREACHABLE */; @@ -5720,7 +5741,7 @@ static llparse_state_t llhttp__internal__run( return s_n_llhttp__internal__n_req_or_res_method_3; } case kMatchMismatch: { - goto s_n_llhttp__internal__n_error_60; + goto s_n_llhttp__internal__n_error_68; } } /* UNREACHABLE */; @@ -5741,7 +5762,7 @@ static llparse_state_t llhttp__internal__run( goto s_n_llhttp__internal__n_req_or_res_method_3; } default: { - goto s_n_llhttp__internal__n_error_60; + goto s_n_llhttp__internal__n_error_68; } } /* UNREACHABLE */; @@ -5758,7 +5779,7 @@ static llparse_state_t llhttp__internal__run( goto s_n_llhttp__internal__n_req_or_res_method_1; } default: { - goto s_n_llhttp__internal__n_error_60; + goto s_n_llhttp__internal__n_error_68; } } /* UNREACHABLE */; @@ -5827,7 +5848,7 @@ static llparse_state_t llhttp__internal__run( /* UNREACHABLE */; abort(); } - s_n_llhttp__internal__n_error_48: { + s_n_llhttp__internal__n_error_52: { state->error = 0x7; state->reason = "Invalid characters in url"; state->error_pos = (const char*) p; @@ -7005,7 +7026,7 @@ static llparse_state_t llhttp__internal__run( /* UNREACHABLE */; abort(); } - s_n_llhttp__internal__n_error_34: { + s_n_llhttp__internal__n_error_36: { state->error = 0x17; state->reason = "Pause on PRI/Upgrade"; state->error_pos = (const char*) p; @@ -7014,7 +7035,7 @@ static llparse_state_t llhttp__internal__run( /* UNREACHABLE */; abort(); } - s_n_llhttp__internal__n_error_35: { + s_n_llhttp__internal__n_error_37: { state->error = 0x9; state->reason = "Expected HTTP/2 Connection Preface"; state->error_pos = (const char*) p; @@ -7023,7 +7044,7 @@ static llparse_state_t llhttp__internal__run( /* UNREACHABLE */; abort(); } - s_n_llhttp__internal__n_error_33: { + s_n_llhttp__internal__n_error_35: { state->error = 0x9; state->reason = "Expected CRLF after version"; state->error_pos = (const char*) p; @@ -7042,15 +7063,107 @@ static llparse_state_t llhttp__internal__run( /* UNREACHABLE */; abort(); } - s_n_llhttp__internal__n_invoke_store_http_minor: { - switch (llhttp__internal__c_store_http_minor(state, p, endp, match)) { - default: + s_n_llhttp__internal__n_error_34: { + state->error = 0x9; + state->reason = "Invalid HTTP version"; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_error; + return s_error; + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_invoke_load_http_minor: { + switch (llhttp__internal__c_load_http_minor(state, p, endp)) { + case 9: goto s_n_llhttp__internal__n_invoke_load_method_1; + default: + goto s_n_llhttp__internal__n_error_34; } /* UNREACHABLE */; abort(); } - s_n_llhttp__internal__n_error_36: { + s_n_llhttp__internal__n_error_38: { + state->error = 0x9; + state->reason = "Invalid HTTP version"; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_error; + return s_error; + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_invoke_load_http_minor_1: { + switch (llhttp__internal__c_load_http_minor(state, p, endp)) { + case 0: + goto s_n_llhttp__internal__n_invoke_load_method_1; + case 1: + goto s_n_llhttp__internal__n_invoke_load_method_1; + default: + goto s_n_llhttp__internal__n_error_38; + } + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_error_39: { + state->error = 0x9; + state->reason = "Invalid HTTP version"; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_error; + return s_error; + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_invoke_load_http_minor_2: { + switch (llhttp__internal__c_load_http_minor(state, p, endp)) { + case 0: + goto s_n_llhttp__internal__n_invoke_load_method_1; + default: + goto s_n_llhttp__internal__n_error_39; + } + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_error_33: { + state->error = 0x9; + state->reason = "Invalid HTTP version"; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_error; + return s_error; + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_invoke_load_http_major: { + switch (llhttp__internal__c_load_http_major(state, p, endp)) { + case 0: + goto s_n_llhttp__internal__n_invoke_load_http_minor; + case 1: + goto s_n_llhttp__internal__n_invoke_load_http_minor_1; + case 2: + goto s_n_llhttp__internal__n_invoke_load_http_minor_2; + default: + goto s_n_llhttp__internal__n_error_33; + } + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_invoke_test_lenient_flags_6: { + switch (llhttp__internal__c_test_lenient_flags_6(state, p, endp)) { + case 1: + goto s_n_llhttp__internal__n_invoke_load_method_1; + default: + goto s_n_llhttp__internal__n_invoke_load_http_major; + } + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_invoke_store_http_minor: { + switch (llhttp__internal__c_store_http_minor(state, p, endp, match)) { + default: + goto s_n_llhttp__internal__n_invoke_test_lenient_flags_6; + } + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_error_40: { state->error = 0x9; state->reason = "Invalid minor version"; state->error_pos = (const char*) p; @@ -7059,7 +7172,7 @@ static llparse_state_t llhttp__internal__run( /* UNREACHABLE */; abort(); } - s_n_llhttp__internal__n_error_37: { + s_n_llhttp__internal__n_error_41: { state->error = 0x9; state->reason = "Expected dot"; state->error_pos = (const char*) p; @@ -7076,7 +7189,7 @@ static llparse_state_t llhttp__internal__run( /* UNREACHABLE */; abort(); } - s_n_llhttp__internal__n_error_38: { + s_n_llhttp__internal__n_error_42: { state->error = 0x9; state->reason = "Invalid major version"; state->error_pos = (const char*) p; @@ -7172,7 +7285,7 @@ static llparse_state_t llhttp__internal__run( /* UNREACHABLE */; abort(); } - s_n_llhttp__internal__n_error_41: { + s_n_llhttp__internal__n_error_45: { state->error = 0x8; state->reason = "Expected HTTP/"; state->error_pos = (const char*) p; @@ -7181,7 +7294,7 @@ static llparse_state_t llhttp__internal__run( /* UNREACHABLE */; abort(); } - s_n_llhttp__internal__n_error_39: { + s_n_llhttp__internal__n_error_43: { state->error = 0x8; state->reason = "Expected SOURCE method for ICE/x.x request"; state->error_pos = (const char*) p; @@ -7195,12 +7308,12 @@ static llparse_state_t llhttp__internal__run( case 33: goto s_n_llhttp__internal__n_req_http_major; default: - goto s_n_llhttp__internal__n_error_39; + goto s_n_llhttp__internal__n_error_43; } /* UNREACHABLE */; abort(); } - s_n_llhttp__internal__n_error_40: { + s_n_llhttp__internal__n_error_44: { state->error = 0x8; state->reason = "Invalid method for RTSP/x.x request"; state->error_pos = (const char*) p; @@ -7240,7 +7353,7 @@ static llparse_state_t llhttp__internal__run( case 45: goto s_n_llhttp__internal__n_req_http_major; default: - goto s_n_llhttp__internal__n_error_40; + goto s_n_llhttp__internal__n_error_44; } /* UNREACHABLE */; abort(); @@ -7321,7 +7434,7 @@ static llparse_state_t llhttp__internal__run( /* UNREACHABLE */; abort(); } - s_n_llhttp__internal__n_error_42: { + s_n_llhttp__internal__n_error_46: { state->error = 0x7; state->reason = "Invalid char in url fragment start"; state->error_pos = (const char*) p; @@ -7381,7 +7494,7 @@ static llparse_state_t llhttp__internal__run( /* UNREACHABLE */; abort(); } - s_n_llhttp__internal__n_error_43: { + s_n_llhttp__internal__n_error_47: { state->error = 0x7; state->reason = "Invalid char in url query"; state->error_pos = (const char*) p; @@ -7390,7 +7503,7 @@ static llparse_state_t llhttp__internal__run( /* UNREACHABLE */; abort(); } - s_n_llhttp__internal__n_error_44: { + s_n_llhttp__internal__n_error_48: { state->error = 0x7; state->reason = "Invalid char in url path"; state->error_pos = (const char*) p; @@ -7501,7 +7614,7 @@ static llparse_state_t llhttp__internal__run( /* UNREACHABLE */; abort(); } - s_n_llhttp__internal__n_error_45: { + s_n_llhttp__internal__n_error_49: { state->error = 0x7; state->reason = "Double @ in url"; state->error_pos = (const char*) p; @@ -7510,36 +7623,9 @@ static llparse_state_t llhttp__internal__run( /* UNREACHABLE */; abort(); } - s_n_llhttp__internal__n_error_46: { - state->error = 0x7; - state->reason = "Unexpected char in url server"; - state->error_pos = (const char*) p; - state->_current = (void*) (intptr_t) s_error; - return s_error; - /* UNREACHABLE */; - abort(); - } - s_n_llhttp__internal__n_error_47: { - state->error = 0x7; - state->reason = "Unexpected char in url server"; - state->error_pos = (const char*) p; - state->_current = (void*) (intptr_t) s_error; - return s_error; - /* UNREACHABLE */; - abort(); - } - s_n_llhttp__internal__n_error_49: { - state->error = 0x7; - state->reason = "Unexpected char in url schema"; - state->error_pos = (const char*) p; - state->_current = (void*) (intptr_t) s_error; - return s_error; - /* UNREACHABLE */; - abort(); - } s_n_llhttp__internal__n_error_50: { state->error = 0x7; - state->reason = "Unexpected char in url schema"; + state->reason = "Unexpected char in url server"; state->error_pos = (const char*) p; state->_current = (void*) (intptr_t) s_error; return s_error; @@ -7547,6 +7633,33 @@ static llparse_state_t llhttp__internal__run( abort(); } s_n_llhttp__internal__n_error_51: { + state->error = 0x7; + state->reason = "Unexpected char in url server"; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_error; + return s_error; + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_error_53: { + state->error = 0x7; + state->reason = "Unexpected char in url schema"; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_error; + return s_error; + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_error_54: { + state->error = 0x7; + state->reason = "Unexpected char in url schema"; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_error; + return s_error; + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_error_55: { state->error = 0x7; state->reason = "Unexpected start char in url"; state->error_pos = (const char*) p; @@ -7565,7 +7678,7 @@ static llparse_state_t llhttp__internal__run( /* UNREACHABLE */; abort(); } - s_n_llhttp__internal__n_error_52: { + s_n_llhttp__internal__n_error_56: { state->error = 0x6; state->reason = "Expected space after method"; state->error_pos = (const char*) p; @@ -7582,7 +7695,7 @@ static llparse_state_t llhttp__internal__run( /* UNREACHABLE */; abort(); } - s_n_llhttp__internal__n_error_61: { + s_n_llhttp__internal__n_error_69: { state->error = 0x6; state->reason = "Invalid method encountered"; state->error_pos = (const char*) p; @@ -7591,7 +7704,7 @@ static llparse_state_t llhttp__internal__run( /* UNREACHABLE */; abort(); } - s_n_llhttp__internal__n_error_53: { + s_n_llhttp__internal__n_error_59: { state->error = 0xd; state->reason = "Response overflow"; state->error_pos = (const char*) p; @@ -7603,14 +7716,14 @@ static llparse_state_t llhttp__internal__run( s_n_llhttp__internal__n_invoke_mul_add_status_code: { switch (llhttp__internal__c_mul_add_status_code(state, p, endp, match)) { case 1: - goto s_n_llhttp__internal__n_error_53; + goto s_n_llhttp__internal__n_error_59; default: goto s_n_llhttp__internal__n_res_status_code; } /* UNREACHABLE */; abort(); } - s_n_llhttp__internal__n_error_54: { + s_n_llhttp__internal__n_error_60: { state->error = 0x2; state->reason = "Expected LF after CR"; state->error_pos = (const char*) p; @@ -7655,7 +7768,7 @@ static llparse_state_t llhttp__internal__run( /* UNREACHABLE */; abort(); } - s_n_llhttp__internal__n_error_55: { + s_n_llhttp__internal__n_error_61: { state->error = 0xd; state->reason = "Invalid response status"; state->error_pos = (const char*) p; @@ -7672,7 +7785,7 @@ static llparse_state_t llhttp__internal__run( /* UNREACHABLE */; abort(); } - s_n_llhttp__internal__n_error_56: { + s_n_llhttp__internal__n_error_62: { state->error = 0x9; state->reason = "Expected space after version"; state->error_pos = (const char*) p; @@ -7681,15 +7794,107 @@ static llparse_state_t llhttp__internal__run( /* UNREACHABLE */; abort(); } - s_n_llhttp__internal__n_invoke_store_http_minor_1: { - switch (llhttp__internal__c_store_http_minor(state, p, endp, match)) { - default: + s_n_llhttp__internal__n_error_58: { + state->error = 0x9; + state->reason = "Invalid HTTP version"; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_error; + return s_error; + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_invoke_load_http_minor_3: { + switch (llhttp__internal__c_load_http_minor(state, p, endp)) { + case 9: goto s_n_llhttp__internal__n_res_http_end; + default: + goto s_n_llhttp__internal__n_error_58; + } + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_error_63: { + state->error = 0x9; + state->reason = "Invalid HTTP version"; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_error; + return s_error; + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_invoke_load_http_minor_4: { + switch (llhttp__internal__c_load_http_minor(state, p, endp)) { + case 0: + goto s_n_llhttp__internal__n_res_http_end; + case 1: + goto s_n_llhttp__internal__n_res_http_end; + default: + goto s_n_llhttp__internal__n_error_63; + } + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_error_64: { + state->error = 0x9; + state->reason = "Invalid HTTP version"; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_error; + return s_error; + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_invoke_load_http_minor_5: { + switch (llhttp__internal__c_load_http_minor(state, p, endp)) { + case 0: + goto s_n_llhttp__internal__n_res_http_end; + default: + goto s_n_llhttp__internal__n_error_64; } /* UNREACHABLE */; abort(); } s_n_llhttp__internal__n_error_57: { + state->error = 0x9; + state->reason = "Invalid HTTP version"; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_error; + return s_error; + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_invoke_load_http_major_1: { + switch (llhttp__internal__c_load_http_major(state, p, endp)) { + case 0: + goto s_n_llhttp__internal__n_invoke_load_http_minor_3; + case 1: + goto s_n_llhttp__internal__n_invoke_load_http_minor_4; + case 2: + goto s_n_llhttp__internal__n_invoke_load_http_minor_5; + default: + goto s_n_llhttp__internal__n_error_57; + } + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_invoke_test_lenient_flags_7: { + switch (llhttp__internal__c_test_lenient_flags_6(state, p, endp)) { + case 1: + goto s_n_llhttp__internal__n_res_http_end; + default: + goto s_n_llhttp__internal__n_invoke_load_http_major_1; + } + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_invoke_store_http_minor_1: { + switch (llhttp__internal__c_store_http_minor(state, p, endp, match)) { + default: + goto s_n_llhttp__internal__n_invoke_test_lenient_flags_7; + } + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_error_65: { state->error = 0x9; state->reason = "Invalid minor version"; state->error_pos = (const char*) p; @@ -7698,7 +7903,7 @@ static llparse_state_t llhttp__internal__run( /* UNREACHABLE */; abort(); } - s_n_llhttp__internal__n_error_58: { + s_n_llhttp__internal__n_error_66: { state->error = 0x9; state->reason = "Expected dot"; state->error_pos = (const char*) p; @@ -7715,7 +7920,7 @@ static llparse_state_t llhttp__internal__run( /* UNREACHABLE */; abort(); } - s_n_llhttp__internal__n_error_59: { + s_n_llhttp__internal__n_error_67: { state->error = 0x9; state->reason = "Invalid major version"; state->error_pos = (const char*) p; @@ -7724,7 +7929,7 @@ static llparse_state_t llhttp__internal__run( /* UNREACHABLE */; abort(); } - s_n_llhttp__internal__n_error_62: { + s_n_llhttp__internal__n_error_70: { state->error = 0x8; state->reason = "Expected HTTP/"; state->error_pos = (const char*) p; @@ -7749,7 +7954,7 @@ static llparse_state_t llhttp__internal__run( /* UNREACHABLE */; abort(); } - s_n_llhttp__internal__n_error_60: { + s_n_llhttp__internal__n_error_68: { state->error = 0x8; state->reason = "Invalid word encountered"; state->error_pos = (const char*) p; @@ -8810,6 +9015,27 @@ int llhttp__internal__c_store_http_minor( return 0; } +int llhttp__internal__c_test_lenient_flags_6( + llhttp__internal_t* state, + const unsigned char* p, + const unsigned char* endp) { + return (state->lenient_flags & 16) == 16; +} + +int llhttp__internal__c_load_http_major( + llhttp__internal_t* state, + const unsigned char* p, + const unsigned char* endp) { + return state->http_major; +} + +int llhttp__internal__c_load_http_minor( + llhttp__internal_t* state, + const unsigned char* p, + const unsigned char* endp) { + return state->http_minor; +} + int llhttp__internal__c_update_status_code( llhttp__internal_t* state, const unsigned char* p, @@ -10477,13 +10703,13 @@ static llparse_state_t llhttp__internal__run( switch (match_seq.status) { case kMatchComplete: { p++; - goto s_n_llhttp__internal__n_error_28; + goto s_n_llhttp__internal__n_error_30; } case kMatchPause: { return s_n_llhttp__internal__n_req_pri_upgrade; } case kMatchMismatch: { - goto s_n_llhttp__internal__n_error_29; + goto s_n_llhttp__internal__n_error_31; } } /* UNREACHABLE */; @@ -10500,7 +10726,7 @@ static llparse_state_t llhttp__internal__run( goto s_n_llhttp__internal__n_header_field_start; } default: { - goto s_n_llhttp__internal__n_error_27; + goto s_n_llhttp__internal__n_error_29; } } /* UNREACHABLE */; @@ -10521,7 +10747,7 @@ static llparse_state_t llhttp__internal__run( goto s_n_llhttp__internal__n_req_http_complete_1; } default: { - goto s_n_llhttp__internal__n_error_27; + goto s_n_llhttp__internal__n_error_29; } } /* UNREACHABLE */; @@ -10584,7 +10810,7 @@ static llparse_state_t llhttp__internal__run( goto s_n_llhttp__internal__n_invoke_store_http_minor; } default: { - goto s_n_llhttp__internal__n_error_30; + goto s_n_llhttp__internal__n_error_34; } } /* UNREACHABLE */; @@ -10601,7 +10827,7 @@ static llparse_state_t llhttp__internal__run( goto s_n_llhttp__internal__n_req_http_minor; } default: { - goto s_n_llhttp__internal__n_error_31; + goto s_n_llhttp__internal__n_error_35; } } /* UNREACHABLE */; @@ -10664,7 +10890,7 @@ static llparse_state_t llhttp__internal__run( goto s_n_llhttp__internal__n_invoke_store_http_major; } default: { - goto s_n_llhttp__internal__n_error_32; + goto s_n_llhttp__internal__n_error_36; } } /* UNREACHABLE */; @@ -10688,7 +10914,7 @@ static llparse_state_t llhttp__internal__run( return s_n_llhttp__internal__n_req_http_start_1; } case kMatchMismatch: { - goto s_n_llhttp__internal__n_error_35; + goto s_n_llhttp__internal__n_error_39; } } /* UNREACHABLE */; @@ -10712,7 +10938,7 @@ static llparse_state_t llhttp__internal__run( return s_n_llhttp__internal__n_req_http_start_2; } case kMatchMismatch: { - goto s_n_llhttp__internal__n_error_35; + goto s_n_llhttp__internal__n_error_39; } } /* UNREACHABLE */; @@ -10736,7 +10962,7 @@ static llparse_state_t llhttp__internal__run( return s_n_llhttp__internal__n_req_http_start_3; } case kMatchMismatch: { - goto s_n_llhttp__internal__n_error_35; + goto s_n_llhttp__internal__n_error_39; } } /* UNREACHABLE */; @@ -10765,7 +10991,7 @@ static llparse_state_t llhttp__internal__run( goto s_n_llhttp__internal__n_req_http_start_3; } default: { - goto s_n_llhttp__internal__n_error_35; + goto s_n_llhttp__internal__n_error_39; } } /* UNREACHABLE */; @@ -10819,7 +11045,7 @@ static llparse_state_t llhttp__internal__run( goto s_n_llhttp__internal__n_span_end_llhttp__on_url_8; } default: { - goto s_n_llhttp__internal__n_error_36; + goto s_n_llhttp__internal__n_error_40; } } /* UNREACHABLE */; @@ -10876,7 +11102,7 @@ static llparse_state_t llhttp__internal__run( goto s_n_llhttp__internal__n_span_end_stub_query_3; } default: { - goto s_n_llhttp__internal__n_error_37; + goto s_n_llhttp__internal__n_error_41; } } /* UNREACHABLE */; @@ -10906,7 +11132,7 @@ static llparse_state_t llhttp__internal__run( goto s_n_llhttp__internal__n_url_query; } default: { - goto s_n_llhttp__internal__n_error_38; + goto s_n_llhttp__internal__n_error_42; } } /* UNREACHABLE */; @@ -11047,10 +11273,10 @@ static llparse_state_t llhttp__internal__run( } case 7: { p++; - goto s_n_llhttp__internal__n_error_39; + goto s_n_llhttp__internal__n_error_43; } default: { - goto s_n_llhttp__internal__n_error_40; + goto s_n_llhttp__internal__n_error_44; } } /* UNREACHABLE */; @@ -11105,7 +11331,7 @@ static llparse_state_t llhttp__internal__run( goto s_n_llhttp__internal__n_url_server_with_at; } default: { - goto s_n_llhttp__internal__n_error_41; + goto s_n_llhttp__internal__n_error_45; } } /* UNREACHABLE */; @@ -11122,7 +11348,7 @@ static llparse_state_t llhttp__internal__run( goto s_n_llhttp__internal__n_url_server; } default: { - goto s_n_llhttp__internal__n_error_43; + goto s_n_llhttp__internal__n_error_47; } } /* UNREACHABLE */; @@ -11136,22 +11362,22 @@ static llparse_state_t llhttp__internal__run( switch (*p) { case 10: { p++; - goto s_n_llhttp__internal__n_error_42; + goto s_n_llhttp__internal__n_error_46; } case 13: { p++; - goto s_n_llhttp__internal__n_error_42; + goto s_n_llhttp__internal__n_error_46; } case ' ': { p++; - goto s_n_llhttp__internal__n_error_42; + goto s_n_llhttp__internal__n_error_46; } case '/': { p++; goto s_n_llhttp__internal__n_url_schema_delim_1; } default: { - goto s_n_llhttp__internal__n_error_43; + goto s_n_llhttp__internal__n_error_47; } } /* UNREACHABLE */; @@ -11193,7 +11419,7 @@ static llparse_state_t llhttp__internal__run( switch (lookup_table[(uint8_t) *p]) { case 1: { p++; - goto s_n_llhttp__internal__n_error_42; + goto s_n_llhttp__internal__n_error_46; } case 2: { goto s_n_llhttp__internal__n_span_end_stub_schema; @@ -11203,7 +11429,7 @@ static llparse_state_t llhttp__internal__run( goto s_n_llhttp__internal__n_url_schema; } default: { - goto s_n_llhttp__internal__n_error_44; + goto s_n_llhttp__internal__n_error_48; } } /* UNREACHABLE */; @@ -11235,7 +11461,7 @@ static llparse_state_t llhttp__internal__run( switch (lookup_table[(uint8_t) *p]) { case 1: { p++; - goto s_n_llhttp__internal__n_error_42; + goto s_n_llhttp__internal__n_error_46; } case 2: { goto s_n_llhttp__internal__n_span_start_stub_path_2; @@ -11244,7 +11470,7 @@ static llparse_state_t llhttp__internal__run( goto s_n_llhttp__internal__n_url_schema; } default: { - goto s_n_llhttp__internal__n_error_45; + goto s_n_llhttp__internal__n_error_49; } } /* UNREACHABLE */; @@ -11300,7 +11526,7 @@ static llparse_state_t llhttp__internal__run( goto s_n_llhttp__internal__n_req_spaces_before_url; } default: { - goto s_n_llhttp__internal__n_error_46; + goto s_n_llhttp__internal__n_error_50; } } /* UNREACHABLE */; @@ -11318,7 +11544,7 @@ static llparse_state_t llhttp__internal__run( goto s_n_llhttp__internal__n_invoke_store_method_1; } default: { - goto s_n_llhttp__internal__n_error_54; + goto s_n_llhttp__internal__n_error_62; } } /* UNREACHABLE */; @@ -11343,7 +11569,7 @@ static llparse_state_t llhttp__internal__run( return s_n_llhttp__internal__n_start_req_3; } case kMatchMismatch: { - goto s_n_llhttp__internal__n_error_54; + goto s_n_llhttp__internal__n_error_62; } } /* UNREACHABLE */; @@ -11364,7 +11590,7 @@ static llparse_state_t llhttp__internal__run( goto s_n_llhttp__internal__n_start_req_3; } default: { - goto s_n_llhttp__internal__n_error_54; + goto s_n_llhttp__internal__n_error_62; } } /* UNREACHABLE */; @@ -11389,7 +11615,7 @@ static llparse_state_t llhttp__internal__run( return s_n_llhttp__internal__n_start_req_4; } case kMatchMismatch: { - goto s_n_llhttp__internal__n_error_54; + goto s_n_llhttp__internal__n_error_62; } } /* UNREACHABLE */; @@ -11414,7 +11640,7 @@ static llparse_state_t llhttp__internal__run( return s_n_llhttp__internal__n_start_req_6; } case kMatchMismatch: { - goto s_n_llhttp__internal__n_error_54; + goto s_n_llhttp__internal__n_error_62; } } /* UNREACHABLE */; @@ -11439,7 +11665,7 @@ static llparse_state_t llhttp__internal__run( return s_n_llhttp__internal__n_start_req_8; } case kMatchMismatch: { - goto s_n_llhttp__internal__n_error_54; + goto s_n_llhttp__internal__n_error_62; } } /* UNREACHABLE */; @@ -11457,7 +11683,7 @@ static llparse_state_t llhttp__internal__run( goto s_n_llhttp__internal__n_invoke_store_method_1; } default: { - goto s_n_llhttp__internal__n_error_54; + goto s_n_llhttp__internal__n_error_62; } } /* UNREACHABLE */; @@ -11478,7 +11704,7 @@ static llparse_state_t llhttp__internal__run( goto s_n_llhttp__internal__n_start_req_9; } default: { - goto s_n_llhttp__internal__n_error_54; + goto s_n_llhttp__internal__n_error_62; } } /* UNREACHABLE */; @@ -11499,7 +11725,7 @@ static llparse_state_t llhttp__internal__run( goto s_n_llhttp__internal__n_start_req_7; } default: { - goto s_n_llhttp__internal__n_error_54; + goto s_n_llhttp__internal__n_error_62; } } /* UNREACHABLE */; @@ -11524,7 +11750,7 @@ static llparse_state_t llhttp__internal__run( return s_n_llhttp__internal__n_start_req_12; } case kMatchMismatch: { - goto s_n_llhttp__internal__n_error_54; + goto s_n_llhttp__internal__n_error_62; } } /* UNREACHABLE */; @@ -11549,7 +11775,7 @@ static llparse_state_t llhttp__internal__run( return s_n_llhttp__internal__n_start_req_13; } case kMatchMismatch: { - goto s_n_llhttp__internal__n_error_54; + goto s_n_llhttp__internal__n_error_62; } } /* UNREACHABLE */; @@ -11570,7 +11796,7 @@ static llparse_state_t llhttp__internal__run( goto s_n_llhttp__internal__n_start_req_13; } default: { - goto s_n_llhttp__internal__n_error_54; + goto s_n_llhttp__internal__n_error_62; } } /* UNREACHABLE */; @@ -11587,7 +11813,7 @@ static llparse_state_t llhttp__internal__run( goto s_n_llhttp__internal__n_start_req_11; } default: { - goto s_n_llhttp__internal__n_error_54; + goto s_n_llhttp__internal__n_error_62; } } /* UNREACHABLE */; @@ -11612,7 +11838,7 @@ static llparse_state_t llhttp__internal__run( return s_n_llhttp__internal__n_start_req_14; } case kMatchMismatch: { - goto s_n_llhttp__internal__n_error_54; + goto s_n_llhttp__internal__n_error_62; } } /* UNREACHABLE */; @@ -11637,7 +11863,7 @@ static llparse_state_t llhttp__internal__run( return s_n_llhttp__internal__n_start_req_17; } case kMatchMismatch: { - goto s_n_llhttp__internal__n_error_54; + goto s_n_llhttp__internal__n_error_62; } } /* UNREACHABLE */; @@ -11679,7 +11905,7 @@ static llparse_state_t llhttp__internal__run( return s_n_llhttp__internal__n_start_req_15; } case kMatchMismatch: { - goto s_n_llhttp__internal__n_error_54; + goto s_n_llhttp__internal__n_error_62; } } /* UNREACHABLE */; @@ -11704,7 +11930,7 @@ static llparse_state_t llhttp__internal__run( return s_n_llhttp__internal__n_start_req_18; } case kMatchMismatch: { - goto s_n_llhttp__internal__n_error_54; + goto s_n_llhttp__internal__n_error_62; } } /* UNREACHABLE */; @@ -11729,7 +11955,7 @@ static llparse_state_t llhttp__internal__run( return s_n_llhttp__internal__n_start_req_20; } case kMatchMismatch: { - goto s_n_llhttp__internal__n_error_54; + goto s_n_llhttp__internal__n_error_62; } } /* UNREACHABLE */; @@ -11754,7 +11980,7 @@ static llparse_state_t llhttp__internal__run( return s_n_llhttp__internal__n_start_req_21; } case kMatchMismatch: { - goto s_n_llhttp__internal__n_error_54; + goto s_n_llhttp__internal__n_error_62; } } /* UNREACHABLE */; @@ -11775,7 +12001,7 @@ static llparse_state_t llhttp__internal__run( goto s_n_llhttp__internal__n_start_req_21; } default: { - goto s_n_llhttp__internal__n_error_54; + goto s_n_llhttp__internal__n_error_62; } } /* UNREACHABLE */; @@ -11800,7 +12026,7 @@ static llparse_state_t llhttp__internal__run( return s_n_llhttp__internal__n_start_req_23; } case kMatchMismatch: { - goto s_n_llhttp__internal__n_error_54; + goto s_n_llhttp__internal__n_error_62; } } /* UNREACHABLE */; @@ -11825,7 +12051,7 @@ static llparse_state_t llhttp__internal__run( return s_n_llhttp__internal__n_start_req_24; } case kMatchMismatch: { - goto s_n_llhttp__internal__n_error_54; + goto s_n_llhttp__internal__n_error_62; } } /* UNREACHABLE */; @@ -11850,7 +12076,7 @@ static llparse_state_t llhttp__internal__run( return s_n_llhttp__internal__n_start_req_26; } case kMatchMismatch: { - goto s_n_llhttp__internal__n_error_54; + goto s_n_llhttp__internal__n_error_62; } } /* UNREACHABLE */; @@ -11875,7 +12101,7 @@ static llparse_state_t llhttp__internal__run( return s_n_llhttp__internal__n_start_req_28; } case kMatchMismatch: { - goto s_n_llhttp__internal__n_error_54; + goto s_n_llhttp__internal__n_error_62; } } /* UNREACHABLE */; @@ -11893,7 +12119,7 @@ static llparse_state_t llhttp__internal__run( goto s_n_llhttp__internal__n_invoke_store_method_1; } default: { - goto s_n_llhttp__internal__n_error_54; + goto s_n_llhttp__internal__n_error_62; } } /* UNREACHABLE */; @@ -11914,7 +12140,7 @@ static llparse_state_t llhttp__internal__run( goto s_n_llhttp__internal__n_start_req_29; } default: { - goto s_n_llhttp__internal__n_error_54; + goto s_n_llhttp__internal__n_error_62; } } /* UNREACHABLE */; @@ -11935,7 +12161,7 @@ static llparse_state_t llhttp__internal__run( goto s_n_llhttp__internal__n_start_req_27; } default: { - goto s_n_llhttp__internal__n_error_54; + goto s_n_llhttp__internal__n_error_62; } } /* UNREACHABLE */; @@ -11960,7 +12186,7 @@ static llparse_state_t llhttp__internal__run( return s_n_llhttp__internal__n_start_req_30; } case kMatchMismatch: { - goto s_n_llhttp__internal__n_error_54; + goto s_n_llhttp__internal__n_error_62; } } /* UNREACHABLE */; @@ -11989,7 +12215,7 @@ static llparse_state_t llhttp__internal__run( goto s_n_llhttp__internal__n_start_req_30; } default: { - goto s_n_llhttp__internal__n_error_54; + goto s_n_llhttp__internal__n_error_62; } } /* UNREACHABLE */; @@ -12014,7 +12240,7 @@ static llparse_state_t llhttp__internal__run( return s_n_llhttp__internal__n_start_req_31; } case kMatchMismatch: { - goto s_n_llhttp__internal__n_error_54; + goto s_n_llhttp__internal__n_error_62; } } /* UNREACHABLE */; @@ -12039,7 +12265,7 @@ static llparse_state_t llhttp__internal__run( return s_n_llhttp__internal__n_start_req_32; } case kMatchMismatch: { - goto s_n_llhttp__internal__n_error_54; + goto s_n_llhttp__internal__n_error_62; } } /* UNREACHABLE */; @@ -12064,7 +12290,7 @@ static llparse_state_t llhttp__internal__run( return s_n_llhttp__internal__n_start_req_35; } case kMatchMismatch: { - goto s_n_llhttp__internal__n_error_54; + goto s_n_llhttp__internal__n_error_62; } } /* UNREACHABLE */; @@ -12089,7 +12315,7 @@ static llparse_state_t llhttp__internal__run( return s_n_llhttp__internal__n_start_req_36; } case kMatchMismatch: { - goto s_n_llhttp__internal__n_error_54; + goto s_n_llhttp__internal__n_error_62; } } /* UNREACHABLE */; @@ -12110,7 +12336,7 @@ static llparse_state_t llhttp__internal__run( goto s_n_llhttp__internal__n_start_req_36; } default: { - goto s_n_llhttp__internal__n_error_54; + goto s_n_llhttp__internal__n_error_62; } } /* UNREACHABLE */; @@ -12135,7 +12361,7 @@ static llparse_state_t llhttp__internal__run( return s_n_llhttp__internal__n_start_req_37; } case kMatchMismatch: { - goto s_n_llhttp__internal__n_error_54; + goto s_n_llhttp__internal__n_error_62; } } /* UNREACHABLE */; @@ -12160,7 +12386,7 @@ static llparse_state_t llhttp__internal__run( return s_n_llhttp__internal__n_start_req_38; } case kMatchMismatch: { - goto s_n_llhttp__internal__n_error_54; + goto s_n_llhttp__internal__n_error_62; } } /* UNREACHABLE */; @@ -12185,7 +12411,7 @@ static llparse_state_t llhttp__internal__run( return s_n_llhttp__internal__n_start_req_42; } case kMatchMismatch: { - goto s_n_llhttp__internal__n_error_54; + goto s_n_llhttp__internal__n_error_62; } } /* UNREACHABLE */; @@ -12210,7 +12436,7 @@ static llparse_state_t llhttp__internal__run( return s_n_llhttp__internal__n_start_req_43; } case kMatchMismatch: { - goto s_n_llhttp__internal__n_error_54; + goto s_n_llhttp__internal__n_error_62; } } /* UNREACHABLE */; @@ -12231,7 +12457,7 @@ static llparse_state_t llhttp__internal__run( goto s_n_llhttp__internal__n_start_req_43; } default: { - goto s_n_llhttp__internal__n_error_54; + goto s_n_llhttp__internal__n_error_62; } } /* UNREACHABLE */; @@ -12248,7 +12474,7 @@ static llparse_state_t llhttp__internal__run( goto s_n_llhttp__internal__n_start_req_41; } default: { - goto s_n_llhttp__internal__n_error_54; + goto s_n_llhttp__internal__n_error_62; } } /* UNREACHABLE */; @@ -12270,7 +12496,7 @@ static llparse_state_t llhttp__internal__run( goto s_n_llhttp__internal__n_start_req_40; } default: { - goto s_n_llhttp__internal__n_error_54; + goto s_n_llhttp__internal__n_error_62; } } /* UNREACHABLE */; @@ -12295,7 +12521,7 @@ static llparse_state_t llhttp__internal__run( return s_n_llhttp__internal__n_start_req_45; } case kMatchMismatch: { - goto s_n_llhttp__internal__n_error_54; + goto s_n_llhttp__internal__n_error_62; } } /* UNREACHABLE */; @@ -12317,7 +12543,7 @@ static llparse_state_t llhttp__internal__run( goto s_n_llhttp__internal__n_invoke_store_method_1; } default: { - goto s_n_llhttp__internal__n_error_54; + goto s_n_llhttp__internal__n_error_62; } } /* UNREACHABLE */; @@ -12350,7 +12576,7 @@ static llparse_state_t llhttp__internal__run( goto s_n_llhttp__internal__n_start_req_44; } default: { - goto s_n_llhttp__internal__n_error_54; + goto s_n_llhttp__internal__n_error_62; } } /* UNREACHABLE */; @@ -12375,7 +12601,7 @@ static llparse_state_t llhttp__internal__run( return s_n_llhttp__internal__n_start_req_48; } case kMatchMismatch: { - goto s_n_llhttp__internal__n_error_54; + goto s_n_llhttp__internal__n_error_62; } } /* UNREACHABLE */; @@ -12400,7 +12626,7 @@ static llparse_state_t llhttp__internal__run( return s_n_llhttp__internal__n_start_req_49; } case kMatchMismatch: { - goto s_n_llhttp__internal__n_error_54; + goto s_n_llhttp__internal__n_error_62; } } /* UNREACHABLE */; @@ -12425,7 +12651,7 @@ static llparse_state_t llhttp__internal__run( return s_n_llhttp__internal__n_start_req_50; } case kMatchMismatch: { - goto s_n_llhttp__internal__n_error_54; + goto s_n_llhttp__internal__n_error_62; } } /* UNREACHABLE */; @@ -12450,7 +12676,7 @@ static llparse_state_t llhttp__internal__run( return s_n_llhttp__internal__n_start_req_51; } case kMatchMismatch: { - goto s_n_llhttp__internal__n_error_54; + goto s_n_llhttp__internal__n_error_62; } } /* UNREACHABLE */; @@ -12479,7 +12705,7 @@ static llparse_state_t llhttp__internal__run( goto s_n_llhttp__internal__n_start_req_51; } default: { - goto s_n_llhttp__internal__n_error_54; + goto s_n_llhttp__internal__n_error_62; } } /* UNREACHABLE */; @@ -12496,7 +12722,7 @@ static llparse_state_t llhttp__internal__run( goto s_n_llhttp__internal__n_start_req_47; } default: { - goto s_n_llhttp__internal__n_error_54; + goto s_n_llhttp__internal__n_error_62; } } /* UNREACHABLE */; @@ -12521,7 +12747,7 @@ static llparse_state_t llhttp__internal__run( return s_n_llhttp__internal__n_start_req_54; } case kMatchMismatch: { - goto s_n_llhttp__internal__n_error_54; + goto s_n_llhttp__internal__n_error_62; } } /* UNREACHABLE */; @@ -12539,7 +12765,7 @@ static llparse_state_t llhttp__internal__run( goto s_n_llhttp__internal__n_invoke_store_method_1; } default: { - goto s_n_llhttp__internal__n_error_54; + goto s_n_llhttp__internal__n_error_62; } } /* UNREACHABLE */; @@ -12564,7 +12790,7 @@ static llparse_state_t llhttp__internal__run( return s_n_llhttp__internal__n_start_req_57; } case kMatchMismatch: { - goto s_n_llhttp__internal__n_error_54; + goto s_n_llhttp__internal__n_error_62; } } /* UNREACHABLE */; @@ -12585,7 +12811,7 @@ static llparse_state_t llhttp__internal__run( goto s_n_llhttp__internal__n_start_req_57; } default: { - goto s_n_llhttp__internal__n_error_54; + goto s_n_llhttp__internal__n_error_62; } } /* UNREACHABLE */; @@ -12606,7 +12832,7 @@ static llparse_state_t llhttp__internal__run( goto s_n_llhttp__internal__n_start_req_55; } default: { - goto s_n_llhttp__internal__n_error_54; + goto s_n_llhttp__internal__n_error_62; } } /* UNREACHABLE */; @@ -12631,7 +12857,7 @@ static llparse_state_t llhttp__internal__run( return s_n_llhttp__internal__n_start_req_58; } case kMatchMismatch: { - goto s_n_llhttp__internal__n_error_54; + goto s_n_llhttp__internal__n_error_62; } } /* UNREACHABLE */; @@ -12656,7 +12882,7 @@ static llparse_state_t llhttp__internal__run( return s_n_llhttp__internal__n_start_req_59; } case kMatchMismatch: { - goto s_n_llhttp__internal__n_error_54; + goto s_n_llhttp__internal__n_error_62; } } /* UNREACHABLE */; @@ -12681,7 +12907,7 @@ static llparse_state_t llhttp__internal__run( goto s_n_llhttp__internal__n_start_req_59; } default: { - goto s_n_llhttp__internal__n_error_54; + goto s_n_llhttp__internal__n_error_62; } } /* UNREACHABLE */; @@ -12706,7 +12932,7 @@ static llparse_state_t llhttp__internal__run( return s_n_llhttp__internal__n_start_req_61; } case kMatchMismatch: { - goto s_n_llhttp__internal__n_error_54; + goto s_n_llhttp__internal__n_error_62; } } /* UNREACHABLE */; @@ -12731,7 +12957,7 @@ static llparse_state_t llhttp__internal__run( return s_n_llhttp__internal__n_start_req_62; } case kMatchMismatch: { - goto s_n_llhttp__internal__n_error_54; + goto s_n_llhttp__internal__n_error_62; } } /* UNREACHABLE */; @@ -12752,7 +12978,7 @@ static llparse_state_t llhttp__internal__run( goto s_n_llhttp__internal__n_start_req_62; } default: { - goto s_n_llhttp__internal__n_error_54; + goto s_n_llhttp__internal__n_error_62; } } /* UNREACHABLE */; @@ -12777,7 +13003,7 @@ static llparse_state_t llhttp__internal__run( return s_n_llhttp__internal__n_start_req_65; } case kMatchMismatch: { - goto s_n_llhttp__internal__n_error_54; + goto s_n_llhttp__internal__n_error_62; } } /* UNREACHABLE */; @@ -12802,7 +13028,7 @@ static llparse_state_t llhttp__internal__run( return s_n_llhttp__internal__n_start_req_67; } case kMatchMismatch: { - goto s_n_llhttp__internal__n_error_54; + goto s_n_llhttp__internal__n_error_62; } } /* UNREACHABLE */; @@ -12827,7 +13053,7 @@ static llparse_state_t llhttp__internal__run( return s_n_llhttp__internal__n_start_req_68; } case kMatchMismatch: { - goto s_n_llhttp__internal__n_error_54; + goto s_n_llhttp__internal__n_error_62; } } /* UNREACHABLE */; @@ -12848,7 +13074,7 @@ static llparse_state_t llhttp__internal__run( goto s_n_llhttp__internal__n_start_req_68; } default: { - goto s_n_llhttp__internal__n_error_54; + goto s_n_llhttp__internal__n_error_62; } } /* UNREACHABLE */; @@ -12873,7 +13099,7 @@ static llparse_state_t llhttp__internal__run( return s_n_llhttp__internal__n_start_req_69; } case kMatchMismatch: { - goto s_n_llhttp__internal__n_error_54; + goto s_n_llhttp__internal__n_error_62; } } /* UNREACHABLE */; @@ -12898,7 +13124,7 @@ static llparse_state_t llhttp__internal__run( goto s_n_llhttp__internal__n_start_req_69; } default: { - goto s_n_llhttp__internal__n_error_54; + goto s_n_llhttp__internal__n_error_62; } } /* UNREACHABLE */; @@ -12915,7 +13141,7 @@ static llparse_state_t llhttp__internal__run( goto s_n_llhttp__internal__n_start_req_64; } default: { - goto s_n_llhttp__internal__n_error_54; + goto s_n_llhttp__internal__n_error_62; } } /* UNREACHABLE */; @@ -12992,7 +13218,7 @@ static llparse_state_t llhttp__internal__run( goto s_n_llhttp__internal__n_start_req_63; } default: { - goto s_n_llhttp__internal__n_error_54; + goto s_n_llhttp__internal__n_error_62; } } /* UNREACHABLE */; @@ -13086,7 +13312,7 @@ static llparse_state_t llhttp__internal__run( goto s_n_llhttp__internal__n_res_status_start; } default: { - goto s_n_llhttp__internal__n_error_48; + goto s_n_llhttp__internal__n_error_54; } } /* UNREACHABLE */; @@ -13166,7 +13392,7 @@ static llparse_state_t llhttp__internal__run( goto s_n_llhttp__internal__n_invoke_update_status_code; } default: { - goto s_n_llhttp__internal__n_error_49; + goto s_n_llhttp__internal__n_error_55; } } /* UNREACHABLE */; @@ -13229,7 +13455,7 @@ static llparse_state_t llhttp__internal__run( goto s_n_llhttp__internal__n_invoke_store_http_minor_1; } default: { - goto s_n_llhttp__internal__n_error_50; + goto s_n_llhttp__internal__n_error_58; } } /* UNREACHABLE */; @@ -13246,7 +13472,7 @@ static llparse_state_t llhttp__internal__run( goto s_n_llhttp__internal__n_res_http_minor; } default: { - goto s_n_llhttp__internal__n_error_51; + goto s_n_llhttp__internal__n_error_59; } } /* UNREACHABLE */; @@ -13309,7 +13535,7 @@ static llparse_state_t llhttp__internal__run( goto s_n_llhttp__internal__n_invoke_store_http_major_1; } default: { - goto s_n_llhttp__internal__n_error_52; + goto s_n_llhttp__internal__n_error_60; } } /* UNREACHABLE */; @@ -13333,7 +13559,7 @@ static llparse_state_t llhttp__internal__run( return s_n_llhttp__internal__n_start_res; } case kMatchMismatch: { - goto s_n_llhttp__internal__n_error_55; + goto s_n_llhttp__internal__n_error_63; } } /* UNREACHABLE */; @@ -13358,7 +13584,7 @@ static llparse_state_t llhttp__internal__run( return s_n_llhttp__internal__n_req_or_res_method_2; } case kMatchMismatch: { - goto s_n_llhttp__internal__n_error_53; + goto s_n_llhttp__internal__n_error_61; } } /* UNREACHABLE */; @@ -13382,7 +13608,7 @@ static llparse_state_t llhttp__internal__run( return s_n_llhttp__internal__n_req_or_res_method_3; } case kMatchMismatch: { - goto s_n_llhttp__internal__n_error_53; + goto s_n_llhttp__internal__n_error_61; } } /* UNREACHABLE */; @@ -13403,7 +13629,7 @@ static llparse_state_t llhttp__internal__run( goto s_n_llhttp__internal__n_req_or_res_method_3; } default: { - goto s_n_llhttp__internal__n_error_53; + goto s_n_llhttp__internal__n_error_61; } } /* UNREACHABLE */; @@ -13420,7 +13646,7 @@ static llparse_state_t llhttp__internal__run( goto s_n_llhttp__internal__n_req_or_res_method_1; } default: { - goto s_n_llhttp__internal__n_error_53; + goto s_n_llhttp__internal__n_error_61; } } /* UNREACHABLE */; @@ -13480,7 +13706,7 @@ static llparse_state_t llhttp__internal__run( /* UNREACHABLE */ abort(); } - s_n_llhttp__internal__n_error_42: { + s_n_llhttp__internal__n_error_46: { state->error = 0x7; state->reason = "Invalid characters in url"; state->error_pos = (const char*) p; @@ -14613,7 +14839,7 @@ static llparse_state_t llhttp__internal__run( /* UNREACHABLE */; abort(); } - s_n_llhttp__internal__n_error_28: { + s_n_llhttp__internal__n_error_30: { state->error = 0x17; state->reason = "Pause on PRI/Upgrade"; state->error_pos = (const char*) p; @@ -14622,7 +14848,7 @@ static llparse_state_t llhttp__internal__run( /* UNREACHABLE */; abort(); } - s_n_llhttp__internal__n_error_29: { + s_n_llhttp__internal__n_error_31: { state->error = 0x9; state->reason = "Expected HTTP/2 Connection Preface"; state->error_pos = (const char*) p; @@ -14631,7 +14857,7 @@ static llparse_state_t llhttp__internal__run( /* UNREACHABLE */; abort(); } - s_n_llhttp__internal__n_error_27: { + s_n_llhttp__internal__n_error_29: { state->error = 0x9; state->reason = "Expected CRLF after version"; state->error_pos = (const char*) p; @@ -14650,15 +14876,107 @@ static llparse_state_t llhttp__internal__run( /* UNREACHABLE */; abort(); } - s_n_llhttp__internal__n_invoke_store_http_minor: { - switch (llhttp__internal__c_store_http_minor(state, p, endp, match)) { - default: + s_n_llhttp__internal__n_error_28: { + state->error = 0x9; + state->reason = "Invalid HTTP version"; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_error; + return s_error; + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_invoke_load_http_minor: { + switch (llhttp__internal__c_load_http_minor(state, p, endp)) { + case 9: goto s_n_llhttp__internal__n_invoke_load_method_1; + default: + goto s_n_llhttp__internal__n_error_28; } /* UNREACHABLE */; abort(); } - s_n_llhttp__internal__n_error_30: { + s_n_llhttp__internal__n_error_32: { + state->error = 0x9; + state->reason = "Invalid HTTP version"; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_error; + return s_error; + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_invoke_load_http_minor_1: { + switch (llhttp__internal__c_load_http_minor(state, p, endp)) { + case 0: + goto s_n_llhttp__internal__n_invoke_load_method_1; + case 1: + goto s_n_llhttp__internal__n_invoke_load_method_1; + default: + goto s_n_llhttp__internal__n_error_32; + } + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_error_33: { + state->error = 0x9; + state->reason = "Invalid HTTP version"; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_error; + return s_error; + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_invoke_load_http_minor_2: { + switch (llhttp__internal__c_load_http_minor(state, p, endp)) { + case 0: + goto s_n_llhttp__internal__n_invoke_load_method_1; + default: + goto s_n_llhttp__internal__n_error_33; + } + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_error_27: { + state->error = 0x9; + state->reason = "Invalid HTTP version"; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_error; + return s_error; + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_invoke_load_http_major: { + switch (llhttp__internal__c_load_http_major(state, p, endp)) { + case 0: + goto s_n_llhttp__internal__n_invoke_load_http_minor; + case 1: + goto s_n_llhttp__internal__n_invoke_load_http_minor_1; + case 2: + goto s_n_llhttp__internal__n_invoke_load_http_minor_2; + default: + goto s_n_llhttp__internal__n_error_27; + } + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_invoke_test_lenient_flags_6: { + switch (llhttp__internal__c_test_lenient_flags_6(state, p, endp)) { + case 1: + goto s_n_llhttp__internal__n_invoke_load_method_1; + default: + goto s_n_llhttp__internal__n_invoke_load_http_major; + } + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_invoke_store_http_minor: { + switch (llhttp__internal__c_store_http_minor(state, p, endp, match)) { + default: + goto s_n_llhttp__internal__n_invoke_test_lenient_flags_6; + } + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_error_34: { state->error = 0x9; state->reason = "Invalid minor version"; state->error_pos = (const char*) p; @@ -14667,7 +14985,7 @@ static llparse_state_t llhttp__internal__run( /* UNREACHABLE */; abort(); } - s_n_llhttp__internal__n_error_31: { + s_n_llhttp__internal__n_error_35: { state->error = 0x9; state->reason = "Expected dot"; state->error_pos = (const char*) p; @@ -14684,7 +15002,7 @@ static llparse_state_t llhttp__internal__run( /* UNREACHABLE */; abort(); } - s_n_llhttp__internal__n_error_32: { + s_n_llhttp__internal__n_error_36: { state->error = 0x9; state->reason = "Invalid major version"; state->error_pos = (const char*) p; @@ -14780,7 +15098,7 @@ static llparse_state_t llhttp__internal__run( /* UNREACHABLE */; abort(); } - s_n_llhttp__internal__n_error_35: { + s_n_llhttp__internal__n_error_39: { state->error = 0x8; state->reason = "Expected HTTP/"; state->error_pos = (const char*) p; @@ -14789,7 +15107,7 @@ static llparse_state_t llhttp__internal__run( /* UNREACHABLE */; abort(); } - s_n_llhttp__internal__n_error_33: { + s_n_llhttp__internal__n_error_37: { state->error = 0x8; state->reason = "Expected SOURCE method for ICE/x.x request"; state->error_pos = (const char*) p; @@ -14803,12 +15121,12 @@ static llparse_state_t llhttp__internal__run( case 33: goto s_n_llhttp__internal__n_req_http_major; default: - goto s_n_llhttp__internal__n_error_33; + goto s_n_llhttp__internal__n_error_37; } /* UNREACHABLE */; abort(); } - s_n_llhttp__internal__n_error_34: { + s_n_llhttp__internal__n_error_38: { state->error = 0x8; state->reason = "Invalid method for RTSP/x.x request"; state->error_pos = (const char*) p; @@ -14848,7 +15166,7 @@ static llparse_state_t llhttp__internal__run( case 45: goto s_n_llhttp__internal__n_req_http_major; default: - goto s_n_llhttp__internal__n_error_34; + goto s_n_llhttp__internal__n_error_38; } /* UNREACHABLE */; abort(); @@ -14929,7 +15247,7 @@ static llparse_state_t llhttp__internal__run( /* UNREACHABLE */; abort(); } - s_n_llhttp__internal__n_error_36: { + s_n_llhttp__internal__n_error_40: { state->error = 0x7; state->reason = "Invalid char in url fragment start"; state->error_pos = (const char*) p; @@ -14989,7 +15307,7 @@ static llparse_state_t llhttp__internal__run( /* UNREACHABLE */; abort(); } - s_n_llhttp__internal__n_error_37: { + s_n_llhttp__internal__n_error_41: { state->error = 0x7; state->reason = "Invalid char in url query"; state->error_pos = (const char*) p; @@ -14998,7 +15316,7 @@ static llparse_state_t llhttp__internal__run( /* UNREACHABLE */; abort(); } - s_n_llhttp__internal__n_error_38: { + s_n_llhttp__internal__n_error_42: { state->error = 0x7; state->reason = "Invalid char in url path"; state->error_pos = (const char*) p; @@ -15109,7 +15427,7 @@ static llparse_state_t llhttp__internal__run( /* UNREACHABLE */; abort(); } - s_n_llhttp__internal__n_error_39: { + s_n_llhttp__internal__n_error_43: { state->error = 0x7; state->reason = "Double @ in url"; state->error_pos = (const char*) p; @@ -15118,36 +15436,9 @@ static llparse_state_t llhttp__internal__run( /* UNREACHABLE */; abort(); } - s_n_llhttp__internal__n_error_40: { - state->error = 0x7; - state->reason = "Unexpected char in url server"; - state->error_pos = (const char*) p; - state->_current = (void*) (intptr_t) s_error; - return s_error; - /* UNREACHABLE */; - abort(); - } - s_n_llhttp__internal__n_error_41: { - state->error = 0x7; - state->reason = "Unexpected char in url server"; - state->error_pos = (const char*) p; - state->_current = (void*) (intptr_t) s_error; - return s_error; - /* UNREACHABLE */; - abort(); - } - s_n_llhttp__internal__n_error_43: { - state->error = 0x7; - state->reason = "Unexpected char in url schema"; - state->error_pos = (const char*) p; - state->_current = (void*) (intptr_t) s_error; - return s_error; - /* UNREACHABLE */; - abort(); - } s_n_llhttp__internal__n_error_44: { state->error = 0x7; - state->reason = "Unexpected char in url schema"; + state->reason = "Unexpected char in url server"; state->error_pos = (const char*) p; state->_current = (void*) (intptr_t) s_error; return s_error; @@ -15155,6 +15446,33 @@ static llparse_state_t llhttp__internal__run( abort(); } s_n_llhttp__internal__n_error_45: { + state->error = 0x7; + state->reason = "Unexpected char in url server"; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_error; + return s_error; + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_error_47: { + state->error = 0x7; + state->reason = "Unexpected char in url schema"; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_error; + return s_error; + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_error_48: { + state->error = 0x7; + state->reason = "Unexpected char in url schema"; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_error; + return s_error; + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_error_49: { state->error = 0x7; state->reason = "Unexpected start char in url"; state->error_pos = (const char*) p; @@ -15173,7 +15491,7 @@ static llparse_state_t llhttp__internal__run( /* UNREACHABLE */; abort(); } - s_n_llhttp__internal__n_error_46: { + s_n_llhttp__internal__n_error_50: { state->error = 0x6; state->reason = "Expected space after method"; state->error_pos = (const char*) p; @@ -15190,7 +15508,7 @@ static llparse_state_t llhttp__internal__run( /* UNREACHABLE */; abort(); } - s_n_llhttp__internal__n_error_54: { + s_n_llhttp__internal__n_error_62: { state->error = 0x6; state->reason = "Invalid method encountered"; state->error_pos = (const char*) p; @@ -15199,7 +15517,7 @@ static llparse_state_t llhttp__internal__run( /* UNREACHABLE */; abort(); } - s_n_llhttp__internal__n_error_47: { + s_n_llhttp__internal__n_error_53: { state->error = 0xd; state->reason = "Response overflow"; state->error_pos = (const char*) p; @@ -15211,7 +15529,7 @@ static llparse_state_t llhttp__internal__run( s_n_llhttp__internal__n_invoke_mul_add_status_code: { switch (llhttp__internal__c_mul_add_status_code(state, p, endp, match)) { case 1: - goto s_n_llhttp__internal__n_error_47; + goto s_n_llhttp__internal__n_error_53; default: goto s_n_llhttp__internal__n_res_status_code; } @@ -15254,7 +15572,7 @@ static llparse_state_t llhttp__internal__run( /* UNREACHABLE */; abort(); } - s_n_llhttp__internal__n_error_48: { + s_n_llhttp__internal__n_error_54: { state->error = 0xd; state->reason = "Invalid response status"; state->error_pos = (const char*) p; @@ -15271,7 +15589,7 @@ static llparse_state_t llhttp__internal__run( /* UNREACHABLE */; abort(); } - s_n_llhttp__internal__n_error_49: { + s_n_llhttp__internal__n_error_55: { state->error = 0x9; state->reason = "Expected space after version"; state->error_pos = (const char*) p; @@ -15280,15 +15598,107 @@ static llparse_state_t llhttp__internal__run( /* UNREACHABLE */; abort(); } - s_n_llhttp__internal__n_invoke_store_http_minor_1: { - switch (llhttp__internal__c_store_http_minor(state, p, endp, match)) { - default: + s_n_llhttp__internal__n_error_52: { + state->error = 0x9; + state->reason = "Invalid HTTP version"; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_error; + return s_error; + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_invoke_load_http_minor_3: { + switch (llhttp__internal__c_load_http_minor(state, p, endp)) { + case 9: goto s_n_llhttp__internal__n_res_http_end; + default: + goto s_n_llhttp__internal__n_error_52; } /* UNREACHABLE */; abort(); } - s_n_llhttp__internal__n_error_50: { + s_n_llhttp__internal__n_error_56: { + state->error = 0x9; + state->reason = "Invalid HTTP version"; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_error; + return s_error; + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_invoke_load_http_minor_4: { + switch (llhttp__internal__c_load_http_minor(state, p, endp)) { + case 0: + goto s_n_llhttp__internal__n_res_http_end; + case 1: + goto s_n_llhttp__internal__n_res_http_end; + default: + goto s_n_llhttp__internal__n_error_56; + } + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_error_57: { + state->error = 0x9; + state->reason = "Invalid HTTP version"; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_error; + return s_error; + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_invoke_load_http_minor_5: { + switch (llhttp__internal__c_load_http_minor(state, p, endp)) { + case 0: + goto s_n_llhttp__internal__n_res_http_end; + default: + goto s_n_llhttp__internal__n_error_57; + } + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_error_51: { + state->error = 0x9; + state->reason = "Invalid HTTP version"; + state->error_pos = (const char*) p; + state->_current = (void*) (intptr_t) s_error; + return s_error; + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_invoke_load_http_major_1: { + switch (llhttp__internal__c_load_http_major(state, p, endp)) { + case 0: + goto s_n_llhttp__internal__n_invoke_load_http_minor_3; + case 1: + goto s_n_llhttp__internal__n_invoke_load_http_minor_4; + case 2: + goto s_n_llhttp__internal__n_invoke_load_http_minor_5; + default: + goto s_n_llhttp__internal__n_error_51; + } + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_invoke_test_lenient_flags_7: { + switch (llhttp__internal__c_test_lenient_flags_6(state, p, endp)) { + case 1: + goto s_n_llhttp__internal__n_res_http_end; + default: + goto s_n_llhttp__internal__n_invoke_load_http_major_1; + } + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_invoke_store_http_minor_1: { + switch (llhttp__internal__c_store_http_minor(state, p, endp, match)) { + default: + goto s_n_llhttp__internal__n_invoke_test_lenient_flags_7; + } + /* UNREACHABLE */; + abort(); + } + s_n_llhttp__internal__n_error_58: { state->error = 0x9; state->reason = "Invalid minor version"; state->error_pos = (const char*) p; @@ -15297,7 +15707,7 @@ static llparse_state_t llhttp__internal__run( /* UNREACHABLE */; abort(); } - s_n_llhttp__internal__n_error_51: { + s_n_llhttp__internal__n_error_59: { state->error = 0x9; state->reason = "Expected dot"; state->error_pos = (const char*) p; @@ -15314,7 +15724,7 @@ static llparse_state_t llhttp__internal__run( /* UNREACHABLE */; abort(); } - s_n_llhttp__internal__n_error_52: { + s_n_llhttp__internal__n_error_60: { state->error = 0x9; state->reason = "Invalid major version"; state->error_pos = (const char*) p; @@ -15323,7 +15733,7 @@ static llparse_state_t llhttp__internal__run( /* UNREACHABLE */; abort(); } - s_n_llhttp__internal__n_error_55: { + s_n_llhttp__internal__n_error_63: { state->error = 0x8; state->reason = "Expected HTTP/"; state->error_pos = (const char*) p; @@ -15348,7 +15758,7 @@ static llparse_state_t llhttp__internal__run( /* UNREACHABLE */; abort(); } - s_n_llhttp__internal__n_error_53: { + s_n_llhttp__internal__n_error_61: { state->error = 0x8; state->reason = "Invalid word encountered"; state->error_pos = (const char*) p; diff --git a/thirdparty/webp/sharpyuv/sharpyuv.c b/thirdparty/webp/sharpyuv/sharpyuv.c new file mode 100644 index 0000000000..8b3ab7216b --- /dev/null +++ b/thirdparty/webp/sharpyuv/sharpyuv.c @@ -0,0 +1,498 @@ +// Copyright 2022 Google Inc. All Rights Reserved. +// +// Use of this source code is governed by a BSD-style license +// that can be found in the COPYING file in the root of the source +// tree. An additional intellectual property rights grant can be found +// in the file PATENTS. All contributing project authors may +// be found in the AUTHORS file in the root of the source tree. +// ----------------------------------------------------------------------------- +// +// Sharp RGB to YUV conversion. +// +// Author: Skal (pascal.massimino@gmail.com) + +#include "sharpyuv/sharpyuv.h" + +#include +#include +#include +#include +#include + +#include "src/webp/types.h" +#include "src/dsp/cpu.h" +#include "sharpyuv/sharpyuv_dsp.h" +#include "sharpyuv/sharpyuv_gamma.h" + +//------------------------------------------------------------------------------ +// Sharp RGB->YUV conversion + +static const int kNumIterations = 4; + +#define YUV_FIX 16 // fixed-point precision for RGB->YUV +static const int kYuvHalf = 1 << (YUV_FIX - 1); + +// Max bit depth so that intermediate calculations fit in 16 bits. +static const int kMaxBitDepth = 14; + +// Returns the precision shift to use based on the input rgb_bit_depth. +static int GetPrecisionShift(int rgb_bit_depth) { + // Try to add 2 bits of precision if it fits in kMaxBitDepth. Otherwise remove + // bits if needed. + return ((rgb_bit_depth + 2) <= kMaxBitDepth) ? 2 + : (kMaxBitDepth - rgb_bit_depth); +} + +typedef int16_t fixed_t; // signed type with extra precision for UV +typedef uint16_t fixed_y_t; // unsigned type with extra precision for W + +//------------------------------------------------------------------------------ + +static uint8_t clip_8b(fixed_t v) { + return (!(v & ~0xff)) ? (uint8_t)v : (v < 0) ? 0u : 255u; +} + +static uint16_t clip(fixed_t v, int max) { + return (v < 0) ? 0 : (v > max) ? max : (uint16_t)v; +} + +static fixed_y_t clip_bit_depth(int y, int bit_depth) { + const int max = (1 << bit_depth) - 1; + return (!(y & ~max)) ? (fixed_y_t)y : (y < 0) ? 0 : max; +} + +//------------------------------------------------------------------------------ + +static int RGBToGray(int64_t r, int64_t g, int64_t b) { + const int64_t luma = 13933 * r + 46871 * g + 4732 * b + kYuvHalf; + return (int)(luma >> YUV_FIX); +} + +static uint32_t ScaleDown(uint16_t a, uint16_t b, uint16_t c, uint16_t d, + int rgb_bit_depth) { + const int bit_depth = rgb_bit_depth + GetPrecisionShift(rgb_bit_depth); + const uint32_t A = SharpYuvGammaToLinear(a, bit_depth); + const uint32_t B = SharpYuvGammaToLinear(b, bit_depth); + const uint32_t C = SharpYuvGammaToLinear(c, bit_depth); + const uint32_t D = SharpYuvGammaToLinear(d, bit_depth); + return SharpYuvLinearToGamma((A + B + C + D + 2) >> 2, bit_depth); +} + +static WEBP_INLINE void UpdateW(const fixed_y_t* src, fixed_y_t* dst, int w, + int rgb_bit_depth) { + const int bit_depth = rgb_bit_depth + GetPrecisionShift(rgb_bit_depth); + int i; + for (i = 0; i < w; ++i) { + const uint32_t R = SharpYuvGammaToLinear(src[0 * w + i], bit_depth); + const uint32_t G = SharpYuvGammaToLinear(src[1 * w + i], bit_depth); + const uint32_t B = SharpYuvGammaToLinear(src[2 * w + i], bit_depth); + const uint32_t Y = RGBToGray(R, G, B); + dst[i] = (fixed_y_t)SharpYuvLinearToGamma(Y, bit_depth); + } +} + +static void UpdateChroma(const fixed_y_t* src1, const fixed_y_t* src2, + fixed_t* dst, int uv_w, int rgb_bit_depth) { + int i; + for (i = 0; i < uv_w; ++i) { + const int r = + ScaleDown(src1[0 * uv_w + 0], src1[0 * uv_w + 1], src2[0 * uv_w + 0], + src2[0 * uv_w + 1], rgb_bit_depth); + const int g = + ScaleDown(src1[2 * uv_w + 0], src1[2 * uv_w + 1], src2[2 * uv_w + 0], + src2[2 * uv_w + 1], rgb_bit_depth); + const int b = + ScaleDown(src1[4 * uv_w + 0], src1[4 * uv_w + 1], src2[4 * uv_w + 0], + src2[4 * uv_w + 1], rgb_bit_depth); + const int W = RGBToGray(r, g, b); + dst[0 * uv_w] = (fixed_t)(r - W); + dst[1 * uv_w] = (fixed_t)(g - W); + dst[2 * uv_w] = (fixed_t)(b - W); + dst += 1; + src1 += 2; + src2 += 2; + } +} + +static void StoreGray(const fixed_y_t* rgb, fixed_y_t* y, int w) { + int i; + assert(w > 0); + for (i = 0; i < w; ++i) { + y[i] = RGBToGray(rgb[0 * w + i], rgb[1 * w + i], rgb[2 * w + i]); + } +} + +//------------------------------------------------------------------------------ + +static WEBP_INLINE fixed_y_t Filter2(int A, int B, int W0, int bit_depth) { + const int v0 = (A * 3 + B + 2) >> 2; + return clip_bit_depth(v0 + W0, bit_depth); +} + +//------------------------------------------------------------------------------ + +static WEBP_INLINE int Shift(int v, int shift) { + return (shift >= 0) ? (v << shift) : (v >> -shift); +} + +static void ImportOneRow(const uint8_t* const r_ptr, + const uint8_t* const g_ptr, + const uint8_t* const b_ptr, + int rgb_step, + int rgb_bit_depth, + int pic_width, + fixed_y_t* const dst) { + // Convert the rgb_step from a number of bytes to a number of uint8_t or + // uint16_t values depending the bit depth. + const int step = (rgb_bit_depth > 8) ? rgb_step / 2 : rgb_step; + int i; + const int w = (pic_width + 1) & ~1; + for (i = 0; i < pic_width; ++i) { + const int off = i * step; + const int shift = GetPrecisionShift(rgb_bit_depth); + if (rgb_bit_depth == 8) { + dst[i + 0 * w] = Shift(r_ptr[off], shift); + dst[i + 1 * w] = Shift(g_ptr[off], shift); + dst[i + 2 * w] = Shift(b_ptr[off], shift); + } else { + dst[i + 0 * w] = Shift(((uint16_t*)r_ptr)[off], shift); + dst[i + 1 * w] = Shift(((uint16_t*)g_ptr)[off], shift); + dst[i + 2 * w] = Shift(((uint16_t*)b_ptr)[off], shift); + } + } + if (pic_width & 1) { // replicate rightmost pixel + dst[pic_width + 0 * w] = dst[pic_width + 0 * w - 1]; + dst[pic_width + 1 * w] = dst[pic_width + 1 * w - 1]; + dst[pic_width + 2 * w] = dst[pic_width + 2 * w - 1]; + } +} + +static void InterpolateTwoRows(const fixed_y_t* const best_y, + const fixed_t* prev_uv, + const fixed_t* cur_uv, + const fixed_t* next_uv, + int w, + fixed_y_t* out1, + fixed_y_t* out2, + int rgb_bit_depth) { + const int uv_w = w >> 1; + const int len = (w - 1) >> 1; // length to filter + int k = 3; + const int bit_depth = rgb_bit_depth + GetPrecisionShift(rgb_bit_depth); + while (k-- > 0) { // process each R/G/B segments in turn + // special boundary case for i==0 + out1[0] = Filter2(cur_uv[0], prev_uv[0], best_y[0], bit_depth); + out2[0] = Filter2(cur_uv[0], next_uv[0], best_y[w], bit_depth); + + SharpYuvFilterRow(cur_uv, prev_uv, len, best_y + 0 + 1, out1 + 1, + bit_depth); + SharpYuvFilterRow(cur_uv, next_uv, len, best_y + w + 1, out2 + 1, + bit_depth); + + // special boundary case for i == w - 1 when w is even + if (!(w & 1)) { + out1[w - 1] = Filter2(cur_uv[uv_w - 1], prev_uv[uv_w - 1], + best_y[w - 1 + 0], bit_depth); + out2[w - 1] = Filter2(cur_uv[uv_w - 1], next_uv[uv_w - 1], + best_y[w - 1 + w], bit_depth); + } + out1 += w; + out2 += w; + prev_uv += uv_w; + cur_uv += uv_w; + next_uv += uv_w; + } +} + +static WEBP_INLINE int RGBToYUVComponent(int r, int g, int b, + const int coeffs[4], int sfix) { + const int srounder = 1 << (YUV_FIX + sfix - 1); + const int luma = coeffs[0] * r + coeffs[1] * g + coeffs[2] * b + + coeffs[3] + srounder; + return (luma >> (YUV_FIX + sfix)); +} + +static int ConvertWRGBToYUV(const fixed_y_t* best_y, const fixed_t* best_uv, + uint8_t* y_ptr, int y_stride, uint8_t* u_ptr, + int u_stride, uint8_t* v_ptr, int v_stride, + int rgb_bit_depth, + int yuv_bit_depth, int width, int height, + const SharpYuvConversionMatrix* yuv_matrix) { + int i, j; + const fixed_t* const best_uv_base = best_uv; + const int w = (width + 1) & ~1; + const int h = (height + 1) & ~1; + const int uv_w = w >> 1; + const int uv_h = h >> 1; + const int sfix = GetPrecisionShift(rgb_bit_depth); + const int yuv_max = (1 << yuv_bit_depth) - 1; + + for (best_uv = best_uv_base, j = 0; j < height; ++j) { + for (i = 0; i < width; ++i) { + const int off = (i >> 1); + const int W = best_y[i]; + const int r = best_uv[off + 0 * uv_w] + W; + const int g = best_uv[off + 1 * uv_w] + W; + const int b = best_uv[off + 2 * uv_w] + W; + const int y = RGBToYUVComponent(r, g, b, yuv_matrix->rgb_to_y, sfix); + if (yuv_bit_depth <= 8) { + y_ptr[i] = clip_8b(y); + } else { + ((uint16_t*)y_ptr)[i] = clip(y, yuv_max); + } + } + best_y += w; + best_uv += (j & 1) * 3 * uv_w; + y_ptr += y_stride; + } + for (best_uv = best_uv_base, j = 0; j < uv_h; ++j) { + for (i = 0; i < uv_w; ++i) { + const int off = i; + // Note r, g and b values here are off by W, but a constant offset on all + // 3 components doesn't change the value of u and v with a YCbCr matrix. + const int r = best_uv[off + 0 * uv_w]; + const int g = best_uv[off + 1 * uv_w]; + const int b = best_uv[off + 2 * uv_w]; + const int u = RGBToYUVComponent(r, g, b, yuv_matrix->rgb_to_u, sfix); + const int v = RGBToYUVComponent(r, g, b, yuv_matrix->rgb_to_v, sfix); + if (yuv_bit_depth <= 8) { + u_ptr[i] = clip_8b(u); + v_ptr[i] = clip_8b(v); + } else { + ((uint16_t*)u_ptr)[i] = clip(u, yuv_max); + ((uint16_t*)v_ptr)[i] = clip(v, yuv_max); + } + } + best_uv += 3 * uv_w; + u_ptr += u_stride; + v_ptr += v_stride; + } + return 1; +} + +//------------------------------------------------------------------------------ +// Main function + +static void* SafeMalloc(uint64_t nmemb, size_t size) { + const uint64_t total_size = nmemb * (uint64_t)size; + if (total_size != (size_t)total_size) return NULL; + return malloc((size_t)total_size); +} + +#define SAFE_ALLOC(W, H, T) ((T*)SafeMalloc((W) * (H), sizeof(T))) + +static int DoSharpArgbToYuv(const uint8_t* r_ptr, const uint8_t* g_ptr, + const uint8_t* b_ptr, int rgb_step, int rgb_stride, + int rgb_bit_depth, uint8_t* y_ptr, int y_stride, + uint8_t* u_ptr, int u_stride, uint8_t* v_ptr, + int v_stride, int yuv_bit_depth, int width, + int height, + const SharpYuvConversionMatrix* yuv_matrix) { + // we expand the right/bottom border if needed + const int w = (width + 1) & ~1; + const int h = (height + 1) & ~1; + const int uv_w = w >> 1; + const int uv_h = h >> 1; + uint64_t prev_diff_y_sum = ~0; + int j, iter; + + // TODO(skal): allocate one big memory chunk. But for now, it's easier + // for valgrind debugging to have several chunks. + fixed_y_t* const tmp_buffer = SAFE_ALLOC(w * 3, 2, fixed_y_t); // scratch + fixed_y_t* const best_y_base = SAFE_ALLOC(w, h, fixed_y_t); + fixed_y_t* const target_y_base = SAFE_ALLOC(w, h, fixed_y_t); + fixed_y_t* const best_rgb_y = SAFE_ALLOC(w, 2, fixed_y_t); + fixed_t* const best_uv_base = SAFE_ALLOC(uv_w * 3, uv_h, fixed_t); + fixed_t* const target_uv_base = SAFE_ALLOC(uv_w * 3, uv_h, fixed_t); + fixed_t* const best_rgb_uv = SAFE_ALLOC(uv_w * 3, 1, fixed_t); + fixed_y_t* best_y = best_y_base; + fixed_y_t* target_y = target_y_base; + fixed_t* best_uv = best_uv_base; + fixed_t* target_uv = target_uv_base; + const uint64_t diff_y_threshold = (uint64_t)(3.0 * w * h); + int ok; + assert(w > 0); + assert(h > 0); + + if (best_y_base == NULL || best_uv_base == NULL || + target_y_base == NULL || target_uv_base == NULL || + best_rgb_y == NULL || best_rgb_uv == NULL || + tmp_buffer == NULL) { + ok = 0; + goto End; + } + + // Import RGB samples to W/RGB representation. + for (j = 0; j < height; j += 2) { + const int is_last_row = (j == height - 1); + fixed_y_t* const src1 = tmp_buffer + 0 * w; + fixed_y_t* const src2 = tmp_buffer + 3 * w; + + // prepare two rows of input + ImportOneRow(r_ptr, g_ptr, b_ptr, rgb_step, rgb_bit_depth, width, + src1); + if (!is_last_row) { + ImportOneRow(r_ptr + rgb_stride, g_ptr + rgb_stride, b_ptr + rgb_stride, + rgb_step, rgb_bit_depth, width, src2); + } else { + memcpy(src2, src1, 3 * w * sizeof(*src2)); + } + StoreGray(src1, best_y + 0, w); + StoreGray(src2, best_y + w, w); + + UpdateW(src1, target_y, w, rgb_bit_depth); + UpdateW(src2, target_y + w, w, rgb_bit_depth); + UpdateChroma(src1, src2, target_uv, uv_w, rgb_bit_depth); + memcpy(best_uv, target_uv, 3 * uv_w * sizeof(*best_uv)); + best_y += 2 * w; + best_uv += 3 * uv_w; + target_y += 2 * w; + target_uv += 3 * uv_w; + r_ptr += 2 * rgb_stride; + g_ptr += 2 * rgb_stride; + b_ptr += 2 * rgb_stride; + } + + // Iterate and resolve clipping conflicts. + for (iter = 0; iter < kNumIterations; ++iter) { + const fixed_t* cur_uv = best_uv_base; + const fixed_t* prev_uv = best_uv_base; + uint64_t diff_y_sum = 0; + + best_y = best_y_base; + best_uv = best_uv_base; + target_y = target_y_base; + target_uv = target_uv_base; + for (j = 0; j < h; j += 2) { + fixed_y_t* const src1 = tmp_buffer + 0 * w; + fixed_y_t* const src2 = tmp_buffer + 3 * w; + { + const fixed_t* const next_uv = cur_uv + ((j < h - 2) ? 3 * uv_w : 0); + InterpolateTwoRows(best_y, prev_uv, cur_uv, next_uv, w, + src1, src2, rgb_bit_depth); + prev_uv = cur_uv; + cur_uv = next_uv; + } + + UpdateW(src1, best_rgb_y + 0 * w, w, rgb_bit_depth); + UpdateW(src2, best_rgb_y + 1 * w, w, rgb_bit_depth); + UpdateChroma(src1, src2, best_rgb_uv, uv_w, rgb_bit_depth); + + // update two rows of Y and one row of RGB + diff_y_sum += + SharpYuvUpdateY(target_y, best_rgb_y, best_y, 2 * w, + rgb_bit_depth + GetPrecisionShift(rgb_bit_depth)); + SharpYuvUpdateRGB(target_uv, best_rgb_uv, best_uv, 3 * uv_w); + + best_y += 2 * w; + best_uv += 3 * uv_w; + target_y += 2 * w; + target_uv += 3 * uv_w; + } + // test exit condition + if (iter > 0) { + if (diff_y_sum < diff_y_threshold) break; + if (diff_y_sum > prev_diff_y_sum) break; + } + prev_diff_y_sum = diff_y_sum; + } + + // final reconstruction + ok = ConvertWRGBToYUV(best_y_base, best_uv_base, y_ptr, y_stride, u_ptr, + u_stride, v_ptr, v_stride, rgb_bit_depth, yuv_bit_depth, + width, height, yuv_matrix); + + End: + free(best_y_base); + free(best_uv_base); + free(target_y_base); + free(target_uv_base); + free(best_rgb_y); + free(best_rgb_uv); + free(tmp_buffer); + return ok; +} +#undef SAFE_ALLOC + +// Hidden exported init function. +// By default SharpYuvConvert calls it with NULL. If needed, users can declare +// it as extern and call it with a VP8CPUInfo function. +extern void SharpYuvInit(VP8CPUInfo cpu_info_func); +void SharpYuvInit(VP8CPUInfo cpu_info_func) { + static volatile VP8CPUInfo sharpyuv_last_cpuinfo_used = + (VP8CPUInfo)&sharpyuv_last_cpuinfo_used; + const int initialized = + (sharpyuv_last_cpuinfo_used != (VP8CPUInfo)&sharpyuv_last_cpuinfo_used); + if (cpu_info_func == NULL && initialized) return; + if (sharpyuv_last_cpuinfo_used == cpu_info_func) return; + + SharpYuvInitDsp(cpu_info_func); + if (!initialized) { + SharpYuvInitGammaTables(); + } + + sharpyuv_last_cpuinfo_used = cpu_info_func; +} + +int SharpYuvConvert(const void* r_ptr, const void* g_ptr, + const void* b_ptr, int rgb_step, int rgb_stride, + int rgb_bit_depth, void* y_ptr, int y_stride, + void* u_ptr, int u_stride, void* v_ptr, + int v_stride, int yuv_bit_depth, int width, + int height, const SharpYuvConversionMatrix* yuv_matrix) { + SharpYuvConversionMatrix scaled_matrix; + const int rgb_max = (1 << rgb_bit_depth) - 1; + const int rgb_round = 1 << (rgb_bit_depth - 1); + const int yuv_max = (1 << yuv_bit_depth) - 1; + const int sfix = GetPrecisionShift(rgb_bit_depth); + + if (width < 1 || height < 1 || width == INT_MAX || height == INT_MAX || + r_ptr == NULL || g_ptr == NULL || b_ptr == NULL || y_ptr == NULL || + u_ptr == NULL || v_ptr == NULL) { + return 0; + } + if (rgb_bit_depth != 8 && rgb_bit_depth != 10 && rgb_bit_depth != 12 && + rgb_bit_depth != 16) { + return 0; + } + if (yuv_bit_depth != 8 && yuv_bit_depth != 10 && yuv_bit_depth != 12) { + return 0; + } + if (rgb_bit_depth > 8 && (rgb_step % 2 != 0 || rgb_stride %2 != 0)) { + // Step/stride should be even for uint16_t buffers. + return 0; + } + if (yuv_bit_depth > 8 && + (y_stride % 2 != 0 || u_stride % 2 != 0 || v_stride % 2 != 0)) { + // Stride should be even for uint16_t buffers. + return 0; + } + SharpYuvInit(NULL); + + // Add scaling factor to go from rgb_bit_depth to yuv_bit_depth, to the + // rgb->yuv conversion matrix. + if (rgb_bit_depth == yuv_bit_depth) { + memcpy(&scaled_matrix, yuv_matrix, sizeof(scaled_matrix)); + } else { + int i; + for (i = 0; i < 3; ++i) { + scaled_matrix.rgb_to_y[i] = + (yuv_matrix->rgb_to_y[i] * yuv_max + rgb_round) / rgb_max; + scaled_matrix.rgb_to_u[i] = + (yuv_matrix->rgb_to_u[i] * yuv_max + rgb_round) / rgb_max; + scaled_matrix.rgb_to_v[i] = + (yuv_matrix->rgb_to_v[i] * yuv_max + rgb_round) / rgb_max; + } + } + // Also incorporate precision change scaling. + scaled_matrix.rgb_to_y[3] = Shift(yuv_matrix->rgb_to_y[3], sfix); + scaled_matrix.rgb_to_u[3] = Shift(yuv_matrix->rgb_to_u[3], sfix); + scaled_matrix.rgb_to_v[3] = Shift(yuv_matrix->rgb_to_v[3], sfix); + + return DoSharpArgbToYuv(r_ptr, g_ptr, b_ptr, rgb_step, rgb_stride, + rgb_bit_depth, y_ptr, y_stride, u_ptr, u_stride, + v_ptr, v_stride, yuv_bit_depth, width, height, + &scaled_matrix); +} + +//------------------------------------------------------------------------------ diff --git a/thirdparty/webp/sharpyuv/sharpyuv.h b/thirdparty/webp/sharpyuv/sharpyuv.h new file mode 100644 index 0000000000..9386ea2185 --- /dev/null +++ b/thirdparty/webp/sharpyuv/sharpyuv.h @@ -0,0 +1,81 @@ +// Copyright 2022 Google Inc. All Rights Reserved. +// +// Use of this source code is governed by a BSD-style license +// that can be found in the COPYING file in the root of the source +// tree. An additional intellectual property rights grant can be found +// in the file PATENTS. All contributing project authors may +// be found in the AUTHORS file in the root of the source tree. +// ----------------------------------------------------------------------------- +// +// Sharp RGB to YUV conversion. + +#ifndef WEBP_SHARPYUV_SHARPYUV_H_ +#define WEBP_SHARPYUV_SHARPYUV_H_ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +// SharpYUV API version following the convention from semver.org +#define SHARPYUV_VERSION_MAJOR 0 +#define SHARPYUV_VERSION_MINOR 1 +#define SHARPYUV_VERSION_PATCH 0 +// Version as a uint32_t. The major number is the high 8 bits. +// The minor number is the middle 8 bits. The patch number is the low 16 bits. +#define SHARPYUV_MAKE_VERSION(MAJOR, MINOR, PATCH) \ + (((MAJOR) << 24) | ((MINOR) << 16) | (PATCH)) +#define SHARPYUV_VERSION \ + SHARPYUV_MAKE_VERSION(SHARPYUV_VERSION_MAJOR, SHARPYUV_VERSION_MINOR, \ + SHARPYUV_VERSION_PATCH) + +// RGB to YUV conversion matrix, in 16 bit fixed point. +// y = rgb_to_y[0] * r + rgb_to_y[1] * g + rgb_to_y[2] * b + rgb_to_y[3] +// u = rgb_to_u[0] * r + rgb_to_u[1] * g + rgb_to_u[2] * b + rgb_to_u[3] +// v = rgb_to_v[0] * r + rgb_to_v[1] * g + rgb_to_v[2] * b + rgb_to_v[3] +// Then y, u and v values are divided by 1<<16 and rounded. +typedef struct { + int rgb_to_y[4]; + int rgb_to_u[4]; + int rgb_to_v[4]; +} SharpYuvConversionMatrix; + +// Converts RGB to YUV420 using a downsampling algorithm that minimizes +// artefacts caused by chroma subsampling. +// This is slower than standard downsampling (averaging of 4 UV values). +// Assumes that the image will be upsampled using a bilinear filter. If nearest +// neighbor is used instead, the upsampled image might look worse than with +// standard downsampling. +// r_ptr, g_ptr, b_ptr: pointers to the source r, g and b channels. Should point +// to uint8_t buffers if rgb_bit_depth is 8, or uint16_t buffers otherwise. +// rgb_step: distance in bytes between two horizontally adjacent pixels on the +// r, g and b channels. If rgb_bit_depth is > 8, it should be a +// multiple of 2. +// rgb_stride: distance in bytes between two vertically adjacent pixels on the +// r, g, and b channels. If rgb_bit_depth is > 8, it should be a +// multiple of 2. +// rgb_bit_depth: number of bits for each r/g/b value. One of: 8, 10, 12, 16. +// Note: 16 bit input is truncated to 14 bits before conversion to yuv. +// yuv_bit_depth: number of bits for each y/u/v value. One of: 8, 10, 12. +// y_ptr, u_ptr, v_ptr: pointers to the destination y, u and v channels. Should +// point to uint8_t buffers if yuv_bit_depth is 8, or uint16_t buffers +// otherwise. +// y_stride, u_stride, v_stride: distance in bytes between two vertically +// adjacent pixels on the y, u and v channels. If yuv_bit_depth > 8, they +// should be multiples of 2. +// width, height: width and height of the image in pixels +int SharpYuvConvert(const void* r_ptr, const void* g_ptr, const void* b_ptr, + int rgb_step, int rgb_stride, int rgb_bit_depth, + void* y_ptr, int y_stride, void* u_ptr, int u_stride, + void* v_ptr, int v_stride, int yuv_bit_depth, int width, + int height, const SharpYuvConversionMatrix* yuv_matrix); + +// TODO(b/194336375): Add YUV444 to YUV420 conversion. Maybe also add 422 +// support (it's rarely used in practice, especially for images). + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // WEBP_SHARPYUV_SHARPYUV_H_ diff --git a/thirdparty/webp/sharpyuv/sharpyuv_csp.c b/thirdparty/webp/sharpyuv/sharpyuv_csp.c new file mode 100644 index 0000000000..5334fa64fa --- /dev/null +++ b/thirdparty/webp/sharpyuv/sharpyuv_csp.c @@ -0,0 +1,110 @@ +// Copyright 2022 Google Inc. All Rights Reserved. +// +// Use of this source code is governed by a BSD-style license +// that can be found in the COPYING file in the root of the source +// tree. An additional intellectual property rights grant can be found +// in the file PATENTS. All contributing project authors may +// be found in the AUTHORS file in the root of the source tree. +// ----------------------------------------------------------------------------- +// +// Colorspace utilities. + +#include "sharpyuv/sharpyuv_csp.h" + +#include +#include +#include + +static int ToFixed16(float f) { return (int)floor(f * (1 << 16) + 0.5f); } + +void SharpYuvComputeConversionMatrix(const SharpYuvColorSpace* yuv_color_space, + SharpYuvConversionMatrix* matrix) { + const float kr = yuv_color_space->kr; + const float kb = yuv_color_space->kb; + const float kg = 1.0f - kr - kb; + const float cr = 0.5f / (1.0f - kb); + const float cb = 0.5f / (1.0f - kr); + + const int shift = yuv_color_space->bit_depth - 8; + + const float denom = (float)((1 << yuv_color_space->bit_depth) - 1); + float scale_y = 1.0f; + float add_y = 0.0f; + float scale_u = cr; + float scale_v = cb; + float add_uv = (float)(128 << shift); + assert(yuv_color_space->bit_depth >= 8); + + if (yuv_color_space->range == kSharpYuvRangeLimited) { + scale_y *= (219 << shift) / denom; + scale_u *= (224 << shift) / denom; + scale_v *= (224 << shift) / denom; + add_y = (float)(16 << shift); + } + + matrix->rgb_to_y[0] = ToFixed16(kr * scale_y); + matrix->rgb_to_y[1] = ToFixed16(kg * scale_y); + matrix->rgb_to_y[2] = ToFixed16(kb * scale_y); + matrix->rgb_to_y[3] = ToFixed16(add_y); + + matrix->rgb_to_u[0] = ToFixed16(-kr * scale_u); + matrix->rgb_to_u[1] = ToFixed16(-kg * scale_u); + matrix->rgb_to_u[2] = ToFixed16((1 - kb) * scale_u); + matrix->rgb_to_u[3] = ToFixed16(add_uv); + + matrix->rgb_to_v[0] = ToFixed16((1 - kr) * scale_v); + matrix->rgb_to_v[1] = ToFixed16(-kg * scale_v); + matrix->rgb_to_v[2] = ToFixed16(-kb * scale_v); + matrix->rgb_to_v[3] = ToFixed16(add_uv); +} + +// Matrices are in YUV_FIX fixed point precision. +// WebP's matrix, similar but not identical to kRec601LimitedMatrix. +static const SharpYuvConversionMatrix kWebpMatrix = { + {16839, 33059, 6420, 16 << 16}, + {-9719, -19081, 28800, 128 << 16}, + {28800, -24116, -4684, 128 << 16}, +}; +// Kr=0.2990f Kb=0.1140f bits=8 range=kSharpYuvRangeLimited +static const SharpYuvConversionMatrix kRec601LimitedMatrix = { + {16829, 33039, 6416, 16 << 16}, + {-9714, -19071, 28784, 128 << 16}, + {28784, -24103, -4681, 128 << 16}, +}; +// Kr=0.2990f Kb=0.1140f bits=8 range=kSharpYuvRangeFull +static const SharpYuvConversionMatrix kRec601FullMatrix = { + {19595, 38470, 7471, 0}, + {-11058, -21710, 32768, 128 << 16}, + {32768, -27439, -5329, 128 << 16}, +}; +// Kr=0.2126f Kb=0.0722f bits=8 range=kSharpYuvRangeLimited +static const SharpYuvConversionMatrix kRec709LimitedMatrix = { + {11966, 40254, 4064, 16 << 16}, + {-6596, -22189, 28784, 128 << 16}, + {28784, -26145, -2639, 128 << 16}, +}; +// Kr=0.2126f Kb=0.0722f bits=8 range=kSharpYuvRangeFull +static const SharpYuvConversionMatrix kRec709FullMatrix = { + {13933, 46871, 4732, 0}, + {-7509, -25259, 32768, 128 << 16}, + {32768, -29763, -3005, 128 << 16}, +}; + +const SharpYuvConversionMatrix* SharpYuvGetConversionMatrix( + SharpYuvMatrixType matrix_type) { + switch (matrix_type) { + case kSharpYuvMatrixWebp: + return &kWebpMatrix; + case kSharpYuvMatrixRec601Limited: + return &kRec601LimitedMatrix; + case kSharpYuvMatrixRec601Full: + return &kRec601FullMatrix; + case kSharpYuvMatrixRec709Limited: + return &kRec709LimitedMatrix; + case kSharpYuvMatrixRec709Full: + return &kRec709FullMatrix; + case kSharpYuvMatrixNum: + return NULL; + } + return NULL; +} diff --git a/thirdparty/webp/sharpyuv/sharpyuv_csp.h b/thirdparty/webp/sharpyuv/sharpyuv_csp.h new file mode 100644 index 0000000000..63c99ef5cd --- /dev/null +++ b/thirdparty/webp/sharpyuv/sharpyuv_csp.h @@ -0,0 +1,59 @@ +// Copyright 2022 Google Inc. All Rights Reserved. +// +// Use of this source code is governed by a BSD-style license +// that can be found in the COPYING file in the root of the source +// tree. An additional intellectual property rights grant can be found +// in the file PATENTS. All contributing project authors may +// be found in the AUTHORS file in the root of the source tree. +// ----------------------------------------------------------------------------- +// +// Colorspace utilities. + +#ifndef WEBP_SHARPYUV_SHARPYUV_CSP_H_ +#define WEBP_SHARPYUV_SHARPYUV_CSP_H_ + +#include "sharpyuv/sharpyuv.h" + +#ifdef __cplusplus +extern "C" { +#endif + +// Range of YUV values. +typedef enum { + kSharpYuvRangeFull, // YUV values between [0;255] (for 8 bit) + kSharpYuvRangeLimited // Y in [16;235], YUV in [16;240] (for 8 bit) +} SharpYuvRange; + +// Constants that define a YUV color space. +typedef struct { + // Kr and Kb are defined such that: + // Y = Kr * r + Kg * g + Kb * b where Kg = 1 - Kr - Kb. + float kr; + float kb; + int bit_depth; // 8, 10 or 12 + SharpYuvRange range; +} SharpYuvColorSpace; + +// Fills in 'matrix' for the given YUVColorSpace. +void SharpYuvComputeConversionMatrix(const SharpYuvColorSpace* yuv_color_space, + SharpYuvConversionMatrix* matrix); + +// Enums for precomputed conversion matrices. +typedef enum { + kSharpYuvMatrixWebp = 0, + kSharpYuvMatrixRec601Limited, + kSharpYuvMatrixRec601Full, + kSharpYuvMatrixRec709Limited, + kSharpYuvMatrixRec709Full, + kSharpYuvMatrixNum +} SharpYuvMatrixType; + +// Returns a pointer to a matrix for one of the predefined colorspaces. +const SharpYuvConversionMatrix* SharpYuvGetConversionMatrix( + SharpYuvMatrixType matrix_type); + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // WEBP_SHARPYUV_SHARPYUV_CSP_H_ diff --git a/thirdparty/webp/sharpyuv/sharpyuv_dsp.c b/thirdparty/webp/sharpyuv/sharpyuv_dsp.c new file mode 100644 index 0000000000..956fa7ce55 --- /dev/null +++ b/thirdparty/webp/sharpyuv/sharpyuv_dsp.c @@ -0,0 +1,102 @@ +// Copyright 2022 Google Inc. All Rights Reserved. +// +// Use of this source code is governed by a BSD-style license +// that can be found in the COPYING file in the root of the source +// tree. An additional intellectual property rights grant can be found +// in the file PATENTS. All contributing project authors may +// be found in the AUTHORS file in the root of the source tree. +// ----------------------------------------------------------------------------- +// +// Speed-critical functions for Sharp YUV. +// +// Author: Skal (pascal.massimino@gmail.com) + +#include "sharpyuv/sharpyuv_dsp.h" + +#include +#include + +#include "src/dsp/cpu.h" + +//----------------------------------------------------------------------------- + +#if !WEBP_NEON_OMIT_C_CODE +static uint16_t clip(int v, int max) { + return (v < 0) ? 0 : (v > max) ? max : (uint16_t)v; +} + +static uint64_t SharpYuvUpdateY_C(const uint16_t* ref, const uint16_t* src, + uint16_t* dst, int len, int bit_depth) { + uint64_t diff = 0; + int i; + const int max_y = (1 << bit_depth) - 1; + for (i = 0; i < len; ++i) { + const int diff_y = ref[i] - src[i]; + const int new_y = (int)dst[i] + diff_y; + dst[i] = clip(new_y, max_y); + diff += (uint64_t)abs(diff_y); + } + return diff; +} + +static void SharpYuvUpdateRGB_C(const int16_t* ref, const int16_t* src, + int16_t* dst, int len) { + int i; + for (i = 0; i < len; ++i) { + const int diff_uv = ref[i] - src[i]; + dst[i] += diff_uv; + } +} + +static void SharpYuvFilterRow_C(const int16_t* A, const int16_t* B, int len, + const uint16_t* best_y, uint16_t* out, + int bit_depth) { + int i; + const int max_y = (1 << bit_depth) - 1; + for (i = 0; i < len; ++i, ++A, ++B) { + const int v0 = (A[0] * 9 + A[1] * 3 + B[0] * 3 + B[1] + 8) >> 4; + const int v1 = (A[1] * 9 + A[0] * 3 + B[1] * 3 + B[0] + 8) >> 4; + out[2 * i + 0] = clip(best_y[2 * i + 0] + v0, max_y); + out[2 * i + 1] = clip(best_y[2 * i + 1] + v1, max_y); + } +} +#endif // !WEBP_NEON_OMIT_C_CODE + +//----------------------------------------------------------------------------- + +uint64_t (*SharpYuvUpdateY)(const uint16_t* src, const uint16_t* ref, + uint16_t* dst, int len, int bit_depth); +void (*SharpYuvUpdateRGB)(const int16_t* src, const int16_t* ref, int16_t* dst, + int len); +void (*SharpYuvFilterRow)(const int16_t* A, const int16_t* B, int len, + const uint16_t* best_y, uint16_t* out, + int bit_depth); + +extern void InitSharpYuvSSE2(void); +extern void InitSharpYuvNEON(void); + +void SharpYuvInitDsp(VP8CPUInfo cpu_info_func) { + (void)cpu_info_func; + +#if !WEBP_NEON_OMIT_C_CODE + SharpYuvUpdateY = SharpYuvUpdateY_C; + SharpYuvUpdateRGB = SharpYuvUpdateRGB_C; + SharpYuvFilterRow = SharpYuvFilterRow_C; +#endif + +#if defined(WEBP_HAVE_SSE2) + if (cpu_info_func == NULL || cpu_info_func(kSSE2)) { + InitSharpYuvSSE2(); + } +#endif // WEBP_HAVE_SSE2 + +#if defined(WEBP_HAVE_NEON) + if (WEBP_NEON_OMIT_C_CODE || cpu_info_func == NULL || cpu_info_func(kNEON)) { + InitSharpYuvNEON(); + } +#endif // WEBP_HAVE_NEON + + assert(SharpYuvUpdateY != NULL); + assert(SharpYuvUpdateRGB != NULL); + assert(SharpYuvFilterRow != NULL); +} diff --git a/thirdparty/webp/sharpyuv/sharpyuv_dsp.h b/thirdparty/webp/sharpyuv/sharpyuv_dsp.h new file mode 100644 index 0000000000..e561d8d3d0 --- /dev/null +++ b/thirdparty/webp/sharpyuv/sharpyuv_dsp.h @@ -0,0 +1,29 @@ +// Copyright 2022 Google Inc. All Rights Reserved. +// +// Use of this source code is governed by a BSD-style license +// that can be found in the COPYING file in the root of the source +// tree. An additional intellectual property rights grant can be found +// in the file PATENTS. All contributing project authors may +// be found in the AUTHORS file in the root of the source tree. +// ----------------------------------------------------------------------------- +// +// Speed-critical functions for Sharp YUV. + +#ifndef WEBP_SHARPYUV_SHARPYUV_DSP_H_ +#define WEBP_SHARPYUV_SHARPYUV_DSP_H_ + +#include + +#include "src/dsp/cpu.h" + +extern uint64_t (*SharpYuvUpdateY)(const uint16_t* src, const uint16_t* ref, + uint16_t* dst, int len, int bit_depth); +extern void (*SharpYuvUpdateRGB)(const int16_t* src, const int16_t* ref, + int16_t* dst, int len); +extern void (*SharpYuvFilterRow)(const int16_t* A, const int16_t* B, int len, + const uint16_t* best_y, uint16_t* out, + int bit_depth); + +void SharpYuvInitDsp(VP8CPUInfo cpu_info_func); + +#endif // WEBP_SHARPYUV_SHARPYUV_DSP_H_ diff --git a/thirdparty/webp/sharpyuv/sharpyuv_gamma.c b/thirdparty/webp/sharpyuv/sharpyuv_gamma.c new file mode 100644 index 0000000000..05b5436f83 --- /dev/null +++ b/thirdparty/webp/sharpyuv/sharpyuv_gamma.c @@ -0,0 +1,114 @@ +// Copyright 2022 Google Inc. All Rights Reserved. +// +// Use of this source code is governed by a BSD-style license +// that can be found in the COPYING file in the root of the source +// tree. An additional intellectual property rights grant can be found +// in the file PATENTS. All contributing project authors may +// be found in the AUTHORS file in the root of the source tree. +// ----------------------------------------------------------------------------- +// +// Gamma correction utilities. + +#include "sharpyuv/sharpyuv_gamma.h" + +#include +#include +#include + +#include "src/webp/types.h" + +// Gamma correction compensates loss of resolution during chroma subsampling. +// Size of pre-computed table for converting from gamma to linear. +#define GAMMA_TO_LINEAR_TAB_BITS 10 +#define GAMMA_TO_LINEAR_TAB_SIZE (1 << GAMMA_TO_LINEAR_TAB_BITS) +static uint32_t kGammaToLinearTabS[GAMMA_TO_LINEAR_TAB_SIZE + 2]; +#define LINEAR_TO_GAMMA_TAB_BITS 9 +#define LINEAR_TO_GAMMA_TAB_SIZE (1 << LINEAR_TO_GAMMA_TAB_BITS) +static uint32_t kLinearToGammaTabS[LINEAR_TO_GAMMA_TAB_SIZE + 2]; + +static const double kGammaF = 1. / 0.45; +#define GAMMA_TO_LINEAR_BITS 16 + +static volatile int kGammaTablesSOk = 0; +void SharpYuvInitGammaTables(void) { + assert(GAMMA_TO_LINEAR_BITS <= 16); + if (!kGammaTablesSOk) { + int v; + const double a = 0.09929682680944; + const double thresh = 0.018053968510807; + const double final_scale = 1 << GAMMA_TO_LINEAR_BITS; + // Precompute gamma to linear table. + { + const double norm = 1. / GAMMA_TO_LINEAR_TAB_SIZE; + const double a_rec = 1. / (1. + a); + for (v = 0; v <= GAMMA_TO_LINEAR_TAB_SIZE; ++v) { + const double g = norm * v; + double value; + if (g <= thresh * 4.5) { + value = g / 4.5; + } else { + value = pow(a_rec * (g + a), kGammaF); + } + kGammaToLinearTabS[v] = (uint32_t)(value * final_scale + .5); + } + // to prevent small rounding errors to cause read-overflow: + kGammaToLinearTabS[GAMMA_TO_LINEAR_TAB_SIZE + 1] = + kGammaToLinearTabS[GAMMA_TO_LINEAR_TAB_SIZE]; + } + // Precompute linear to gamma table. + { + const double scale = 1. / LINEAR_TO_GAMMA_TAB_SIZE; + for (v = 0; v <= LINEAR_TO_GAMMA_TAB_SIZE; ++v) { + const double g = scale * v; + double value; + if (g <= thresh) { + value = 4.5 * g; + } else { + value = (1. + a) * pow(g, 1. / kGammaF) - a; + } + kLinearToGammaTabS[v] = + (uint32_t)(final_scale * value + 0.5); + } + // to prevent small rounding errors to cause read-overflow: + kLinearToGammaTabS[LINEAR_TO_GAMMA_TAB_SIZE + 1] = + kLinearToGammaTabS[LINEAR_TO_GAMMA_TAB_SIZE]; + } + kGammaTablesSOk = 1; + } +} + +static WEBP_INLINE int Shift(int v, int shift) { + return (shift >= 0) ? (v << shift) : (v >> -shift); +} + +static WEBP_INLINE uint32_t FixedPointInterpolation(int v, uint32_t* tab, + int tab_pos_shift_right, + int tab_value_shift) { + const uint32_t tab_pos = Shift(v, -tab_pos_shift_right); + // fractional part, in 'tab_pos_shift' fixed-point precision + const uint32_t x = v - (tab_pos << tab_pos_shift_right); // fractional part + // v0 / v1 are in kGammaToLinearBits fixed-point precision (range [0..1]) + const uint32_t v0 = Shift(tab[tab_pos + 0], tab_value_shift); + const uint32_t v1 = Shift(tab[tab_pos + 1], tab_value_shift); + // Final interpolation. + const uint32_t v2 = (v1 - v0) * x; // note: v1 >= v0. + const int half = + (tab_pos_shift_right > 0) ? 1 << (tab_pos_shift_right - 1) : 0; + const uint32_t result = v0 + ((v2 + half) >> tab_pos_shift_right); + return result; +} + +uint32_t SharpYuvGammaToLinear(uint16_t v, int bit_depth) { + const int shift = GAMMA_TO_LINEAR_TAB_BITS - bit_depth; + if (shift > 0) { + return kGammaToLinearTabS[v << shift]; + } + return FixedPointInterpolation(v, kGammaToLinearTabS, -shift, 0); +} + +uint16_t SharpYuvLinearToGamma(uint32_t value, int bit_depth) { + return FixedPointInterpolation( + value, kLinearToGammaTabS, + (GAMMA_TO_LINEAR_BITS - LINEAR_TO_GAMMA_TAB_BITS), + bit_depth - GAMMA_TO_LINEAR_BITS); +} diff --git a/thirdparty/webp/sharpyuv/sharpyuv_gamma.h b/thirdparty/webp/sharpyuv/sharpyuv_gamma.h new file mode 100644 index 0000000000..2f1a3ff4a0 --- /dev/null +++ b/thirdparty/webp/sharpyuv/sharpyuv_gamma.h @@ -0,0 +1,35 @@ +// Copyright 2022 Google Inc. All Rights Reserved. +// +// Use of this source code is governed by a BSD-style license +// that can be found in the COPYING file in the root of the source +// tree. An additional intellectual property rights grant can be found +// in the file PATENTS. All contributing project authors may +// be found in the AUTHORS file in the root of the source tree. +// ----------------------------------------------------------------------------- +// +// Gamma correction utilities. + +#ifndef WEBP_SHARPYUV_SHARPYUV_GAMMA_H_ +#define WEBP_SHARPYUV_SHARPYUV_GAMMA_H_ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +// Initializes precomputed tables. Must be called once before calling +// SharpYuvGammaToLinear or SharpYuvLinearToGamma. +void SharpYuvInitGammaTables(void); + +// Converts a gamma color value on 'bit_depth' bits to a 16 bit linear value. +uint32_t SharpYuvGammaToLinear(uint16_t v, int bit_depth); + +// Converts a 16 bit linear color value to a gamma value on 'bit_depth' bits. +uint16_t SharpYuvLinearToGamma(uint32_t value, int bit_depth); + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // WEBP_SHARPYUV_SHARPYUV_GAMMA_H_ diff --git a/thirdparty/webp/sharpyuv/sharpyuv_neon.c b/thirdparty/webp/sharpyuv/sharpyuv_neon.c new file mode 100644 index 0000000000..5cf6aaffb0 --- /dev/null +++ b/thirdparty/webp/sharpyuv/sharpyuv_neon.c @@ -0,0 +1,182 @@ +// Copyright 2022 Google Inc. All Rights Reserved. +// +// Use of this source code is governed by a BSD-style license +// that can be found in the COPYING file in the root of the source +// tree. An additional intellectual property rights grant can be found +// in the file PATENTS. All contributing project authors may +// be found in the AUTHORS file in the root of the source tree. +// ----------------------------------------------------------------------------- +// +// Speed-critical functions for Sharp YUV. +// +// Author: Skal (pascal.massimino@gmail.com) + +#include "sharpyuv/sharpyuv_dsp.h" + +#if defined(WEBP_USE_NEON) +#include +#include +#include +#endif + +extern void InitSharpYuvNEON(void); + +#if defined(WEBP_USE_NEON) + +static uint16_t clip_NEON(int v, int max) { + return (v < 0) ? 0 : (v > max) ? max : (uint16_t)v; +} + +static uint64_t SharpYuvUpdateY_NEON(const uint16_t* ref, const uint16_t* src, + uint16_t* dst, int len, int bit_depth) { + const int max_y = (1 << bit_depth) - 1; + int i; + const int16x8_t zero = vdupq_n_s16(0); + const int16x8_t max = vdupq_n_s16(max_y); + uint64x2_t sum = vdupq_n_u64(0); + uint64_t diff; + + for (i = 0; i + 8 <= len; i += 8) { + const int16x8_t A = vreinterpretq_s16_u16(vld1q_u16(ref + i)); + const int16x8_t B = vreinterpretq_s16_u16(vld1q_u16(src + i)); + const int16x8_t C = vreinterpretq_s16_u16(vld1q_u16(dst + i)); + const int16x8_t D = vsubq_s16(A, B); // diff_y + const int16x8_t F = vaddq_s16(C, D); // new_y + const uint16x8_t H = + vreinterpretq_u16_s16(vmaxq_s16(vminq_s16(F, max), zero)); + const int16x8_t I = vabsq_s16(D); // abs(diff_y) + vst1q_u16(dst + i, H); + sum = vpadalq_u32(sum, vpaddlq_u16(vreinterpretq_u16_s16(I))); + } + diff = vgetq_lane_u64(sum, 0) + vgetq_lane_u64(sum, 1); + for (; i < len; ++i) { + const int diff_y = ref[i] - src[i]; + const int new_y = (int)(dst[i]) + diff_y; + dst[i] = clip_NEON(new_y, max_y); + diff += (uint64_t)(abs(diff_y)); + } + return diff; +} + +static void SharpYuvUpdateRGB_NEON(const int16_t* ref, const int16_t* src, + int16_t* dst, int len) { + int i; + for (i = 0; i + 8 <= len; i += 8) { + const int16x8_t A = vld1q_s16(ref + i); + const int16x8_t B = vld1q_s16(src + i); + const int16x8_t C = vld1q_s16(dst + i); + const int16x8_t D = vsubq_s16(A, B); // diff_uv + const int16x8_t E = vaddq_s16(C, D); // new_uv + vst1q_s16(dst + i, E); + } + for (; i < len; ++i) { + const int diff_uv = ref[i] - src[i]; + dst[i] += diff_uv; + } +} + +static void SharpYuvFilterRow16_NEON(const int16_t* A, const int16_t* B, + int len, const uint16_t* best_y, + uint16_t* out, int bit_depth) { + const int max_y = (1 << bit_depth) - 1; + int i; + const int16x8_t max = vdupq_n_s16(max_y); + const int16x8_t zero = vdupq_n_s16(0); + for (i = 0; i + 8 <= len; i += 8) { + const int16x8_t a0 = vld1q_s16(A + i + 0); + const int16x8_t a1 = vld1q_s16(A + i + 1); + const int16x8_t b0 = vld1q_s16(B + i + 0); + const int16x8_t b1 = vld1q_s16(B + i + 1); + const int16x8_t a0b1 = vaddq_s16(a0, b1); + const int16x8_t a1b0 = vaddq_s16(a1, b0); + const int16x8_t a0a1b0b1 = vaddq_s16(a0b1, a1b0); // A0+A1+B0+B1 + const int16x8_t a0b1_2 = vaddq_s16(a0b1, a0b1); // 2*(A0+B1) + const int16x8_t a1b0_2 = vaddq_s16(a1b0, a1b0); // 2*(A1+B0) + const int16x8_t c0 = vshrq_n_s16(vaddq_s16(a0b1_2, a0a1b0b1), 3); + const int16x8_t c1 = vshrq_n_s16(vaddq_s16(a1b0_2, a0a1b0b1), 3); + const int16x8_t e0 = vrhaddq_s16(c1, a0); + const int16x8_t e1 = vrhaddq_s16(c0, a1); + const int16x8x2_t f = vzipq_s16(e0, e1); + const int16x8_t g0 = vreinterpretq_s16_u16(vld1q_u16(best_y + 2 * i + 0)); + const int16x8_t g1 = vreinterpretq_s16_u16(vld1q_u16(best_y + 2 * i + 8)); + const int16x8_t h0 = vaddq_s16(g0, f.val[0]); + const int16x8_t h1 = vaddq_s16(g1, f.val[1]); + const int16x8_t i0 = vmaxq_s16(vminq_s16(h0, max), zero); + const int16x8_t i1 = vmaxq_s16(vminq_s16(h1, max), zero); + vst1q_u16(out + 2 * i + 0, vreinterpretq_u16_s16(i0)); + vst1q_u16(out + 2 * i + 8, vreinterpretq_u16_s16(i1)); + } + for (; i < len; ++i) { + const int a0b1 = A[i + 0] + B[i + 1]; + const int a1b0 = A[i + 1] + B[i + 0]; + const int a0a1b0b1 = a0b1 + a1b0 + 8; + const int v0 = (8 * A[i + 0] + 2 * a1b0 + a0a1b0b1) >> 4; + const int v1 = (8 * A[i + 1] + 2 * a0b1 + a0a1b0b1) >> 4; + out[2 * i + 0] = clip_NEON(best_y[2 * i + 0] + v0, max_y); + out[2 * i + 1] = clip_NEON(best_y[2 * i + 1] + v1, max_y); + } +} + +static void SharpYuvFilterRow32_NEON(const int16_t* A, const int16_t* B, + int len, const uint16_t* best_y, + uint16_t* out, int bit_depth) { + const int max_y = (1 << bit_depth) - 1; + int i; + const uint16x8_t max = vdupq_n_u16(max_y); + for (i = 0; i + 4 <= len; i += 4) { + const int16x4_t a0 = vld1_s16(A + i + 0); + const int16x4_t a1 = vld1_s16(A + i + 1); + const int16x4_t b0 = vld1_s16(B + i + 0); + const int16x4_t b1 = vld1_s16(B + i + 1); + const int32x4_t a0b1 = vaddl_s16(a0, b1); + const int32x4_t a1b0 = vaddl_s16(a1, b0); + const int32x4_t a0a1b0b1 = vaddq_s32(a0b1, a1b0); // A0+A1+B0+B1 + const int32x4_t a0b1_2 = vaddq_s32(a0b1, a0b1); // 2*(A0+B1) + const int32x4_t a1b0_2 = vaddq_s32(a1b0, a1b0); // 2*(A1+B0) + const int32x4_t c0 = vshrq_n_s32(vaddq_s32(a0b1_2, a0a1b0b1), 3); + const int32x4_t c1 = vshrq_n_s32(vaddq_s32(a1b0_2, a0a1b0b1), 3); + const int32x4_t e0 = vrhaddq_s32(c1, vmovl_s16(a0)); + const int32x4_t e1 = vrhaddq_s32(c0, vmovl_s16(a1)); + const int32x4x2_t f = vzipq_s32(e0, e1); + + const int16x8_t g = vreinterpretq_s16_u16(vld1q_u16(best_y + 2 * i)); + const int32x4_t h0 = vaddw_s16(f.val[0], vget_low_s16(g)); + const int32x4_t h1 = vaddw_s16(f.val[1], vget_high_s16(g)); + const uint16x8_t i_16 = vcombine_u16(vqmovun_s32(h0), vqmovun_s32(h1)); + const uint16x8_t i_clamped = vminq_u16(i_16, max); + vst1q_u16(out + 2 * i + 0, i_clamped); + } + for (; i < len; ++i) { + const int a0b1 = A[i + 0] + B[i + 1]; + const int a1b0 = A[i + 1] + B[i + 0]; + const int a0a1b0b1 = a0b1 + a1b0 + 8; + const int v0 = (8 * A[i + 0] + 2 * a1b0 + a0a1b0b1) >> 4; + const int v1 = (8 * A[i + 1] + 2 * a0b1 + a0a1b0b1) >> 4; + out[2 * i + 0] = clip_NEON(best_y[2 * i + 0] + v0, max_y); + out[2 * i + 1] = clip_NEON(best_y[2 * i + 1] + v1, max_y); + } +} + +static void SharpYuvFilterRow_NEON(const int16_t* A, const int16_t* B, int len, + const uint16_t* best_y, uint16_t* out, + int bit_depth) { + if (bit_depth <= 10) { + SharpYuvFilterRow16_NEON(A, B, len, best_y, out, bit_depth); + } else { + SharpYuvFilterRow32_NEON(A, B, len, best_y, out, bit_depth); + } +} + +//------------------------------------------------------------------------------ + +WEBP_TSAN_IGNORE_FUNCTION void InitSharpYuvNEON(void) { + SharpYuvUpdateY = SharpYuvUpdateY_NEON; + SharpYuvUpdateRGB = SharpYuvUpdateRGB_NEON; + SharpYuvFilterRow = SharpYuvFilterRow_NEON; +} + +#else // !WEBP_USE_NEON + +void InitSharpYuvNEON(void) {} + +#endif // WEBP_USE_NEON diff --git a/thirdparty/webp/sharpyuv/sharpyuv_sse2.c b/thirdparty/webp/sharpyuv/sharpyuv_sse2.c new file mode 100644 index 0000000000..1943873748 --- /dev/null +++ b/thirdparty/webp/sharpyuv/sharpyuv_sse2.c @@ -0,0 +1,204 @@ +// Copyright 2022 Google Inc. All Rights Reserved. +// +// Use of this source code is governed by a BSD-style license +// that can be found in the COPYING file in the root of the source +// tree. An additional intellectual property rights grant can be found +// in the file PATENTS. All contributing project authors may +// be found in the AUTHORS file in the root of the source tree. +// ----------------------------------------------------------------------------- +// +// Speed-critical functions for Sharp YUV. +// +// Author: Skal (pascal.massimino@gmail.com) + +#include "sharpyuv/sharpyuv_dsp.h" + +#if defined(WEBP_USE_SSE2) +#include +#include +#endif + +extern void InitSharpYuvSSE2(void); + +#if defined(WEBP_USE_SSE2) + +static uint16_t clip_SSE2(int v, int max) { + return (v < 0) ? 0 : (v > max) ? max : (uint16_t)v; +} + +static uint64_t SharpYuvUpdateY_SSE2(const uint16_t* ref, const uint16_t* src, + uint16_t* dst, int len, int bit_depth) { + const int max_y = (1 << bit_depth) - 1; + uint64_t diff = 0; + uint32_t tmp[4]; + int i; + const __m128i zero = _mm_setzero_si128(); + const __m128i max = _mm_set1_epi16(max_y); + const __m128i one = _mm_set1_epi16(1); + __m128i sum = zero; + + for (i = 0; i + 8 <= len; i += 8) { + const __m128i A = _mm_loadu_si128((const __m128i*)(ref + i)); + const __m128i B = _mm_loadu_si128((const __m128i*)(src + i)); + const __m128i C = _mm_loadu_si128((const __m128i*)(dst + i)); + const __m128i D = _mm_sub_epi16(A, B); // diff_y + const __m128i E = _mm_cmpgt_epi16(zero, D); // sign (-1 or 0) + const __m128i F = _mm_add_epi16(C, D); // new_y + const __m128i G = _mm_or_si128(E, one); // -1 or 1 + const __m128i H = _mm_max_epi16(_mm_min_epi16(F, max), zero); + const __m128i I = _mm_madd_epi16(D, G); // sum(abs(...)) + _mm_storeu_si128((__m128i*)(dst + i), H); + sum = _mm_add_epi32(sum, I); + } + _mm_storeu_si128((__m128i*)tmp, sum); + diff = tmp[3] + tmp[2] + tmp[1] + tmp[0]; + for (; i < len; ++i) { + const int diff_y = ref[i] - src[i]; + const int new_y = (int)dst[i] + diff_y; + dst[i] = clip_SSE2(new_y, max_y); + diff += (uint64_t)abs(diff_y); + } + return diff; +} + +static void SharpYuvUpdateRGB_SSE2(const int16_t* ref, const int16_t* src, + int16_t* dst, int len) { + int i = 0; + for (i = 0; i + 8 <= len; i += 8) { + const __m128i A = _mm_loadu_si128((const __m128i*)(ref + i)); + const __m128i B = _mm_loadu_si128((const __m128i*)(src + i)); + const __m128i C = _mm_loadu_si128((const __m128i*)(dst + i)); + const __m128i D = _mm_sub_epi16(A, B); // diff_uv + const __m128i E = _mm_add_epi16(C, D); // new_uv + _mm_storeu_si128((__m128i*)(dst + i), E); + } + for (; i < len; ++i) { + const int diff_uv = ref[i] - src[i]; + dst[i] += diff_uv; + } +} + +static void SharpYuvFilterRow16_SSE2(const int16_t* A, const int16_t* B, + int len, const uint16_t* best_y, + uint16_t* out, int bit_depth) { + const int max_y = (1 << bit_depth) - 1; + int i; + const __m128i kCst8 = _mm_set1_epi16(8); + const __m128i max = _mm_set1_epi16(max_y); + const __m128i zero = _mm_setzero_si128(); + for (i = 0; i + 8 <= len; i += 8) { + const __m128i a0 = _mm_loadu_si128((const __m128i*)(A + i + 0)); + const __m128i a1 = _mm_loadu_si128((const __m128i*)(A + i + 1)); + const __m128i b0 = _mm_loadu_si128((const __m128i*)(B + i + 0)); + const __m128i b1 = _mm_loadu_si128((const __m128i*)(B + i + 1)); + const __m128i a0b1 = _mm_add_epi16(a0, b1); + const __m128i a1b0 = _mm_add_epi16(a1, b0); + const __m128i a0a1b0b1 = _mm_add_epi16(a0b1, a1b0); // A0+A1+B0+B1 + const __m128i a0a1b0b1_8 = _mm_add_epi16(a0a1b0b1, kCst8); + const __m128i a0b1_2 = _mm_add_epi16(a0b1, a0b1); // 2*(A0+B1) + const __m128i a1b0_2 = _mm_add_epi16(a1b0, a1b0); // 2*(A1+B0) + const __m128i c0 = _mm_srai_epi16(_mm_add_epi16(a0b1_2, a0a1b0b1_8), 3); + const __m128i c1 = _mm_srai_epi16(_mm_add_epi16(a1b0_2, a0a1b0b1_8), 3); + const __m128i d0 = _mm_add_epi16(c1, a0); + const __m128i d1 = _mm_add_epi16(c0, a1); + const __m128i e0 = _mm_srai_epi16(d0, 1); + const __m128i e1 = _mm_srai_epi16(d1, 1); + const __m128i f0 = _mm_unpacklo_epi16(e0, e1); + const __m128i f1 = _mm_unpackhi_epi16(e0, e1); + const __m128i g0 = _mm_loadu_si128((const __m128i*)(best_y + 2 * i + 0)); + const __m128i g1 = _mm_loadu_si128((const __m128i*)(best_y + 2 * i + 8)); + const __m128i h0 = _mm_add_epi16(g0, f0); + const __m128i h1 = _mm_add_epi16(g1, f1); + const __m128i i0 = _mm_max_epi16(_mm_min_epi16(h0, max), zero); + const __m128i i1 = _mm_max_epi16(_mm_min_epi16(h1, max), zero); + _mm_storeu_si128((__m128i*)(out + 2 * i + 0), i0); + _mm_storeu_si128((__m128i*)(out + 2 * i + 8), i1); + } + for (; i < len; ++i) { + // (9 * A0 + 3 * A1 + 3 * B0 + B1 + 8) >> 4 = + // = (8 * A0 + 2 * (A1 + B0) + (A0 + A1 + B0 + B1 + 8)) >> 4 + // We reuse the common sub-expressions. + const int a0b1 = A[i + 0] + B[i + 1]; + const int a1b0 = A[i + 1] + B[i + 0]; + const int a0a1b0b1 = a0b1 + a1b0 + 8; + const int v0 = (8 * A[i + 0] + 2 * a1b0 + a0a1b0b1) >> 4; + const int v1 = (8 * A[i + 1] + 2 * a0b1 + a0a1b0b1) >> 4; + out[2 * i + 0] = clip_SSE2(best_y[2 * i + 0] + v0, max_y); + out[2 * i + 1] = clip_SSE2(best_y[2 * i + 1] + v1, max_y); + } +} + +static WEBP_INLINE __m128i s16_to_s32(__m128i in) { + return _mm_srai_epi32(_mm_unpacklo_epi16(in, in), 16); +} + +static void SharpYuvFilterRow32_SSE2(const int16_t* A, const int16_t* B, + int len, const uint16_t* best_y, + uint16_t* out, int bit_depth) { + const int max_y = (1 << bit_depth) - 1; + int i; + const __m128i kCst8 = _mm_set1_epi32(8); + const __m128i max = _mm_set1_epi16(max_y); + const __m128i zero = _mm_setzero_si128(); + for (i = 0; i + 4 <= len; i += 4) { + const __m128i a0 = s16_to_s32(_mm_loadl_epi64((const __m128i*)(A + i + 0))); + const __m128i a1 = s16_to_s32(_mm_loadl_epi64((const __m128i*)(A + i + 1))); + const __m128i b0 = s16_to_s32(_mm_loadl_epi64((const __m128i*)(B + i + 0))); + const __m128i b1 = s16_to_s32(_mm_loadl_epi64((const __m128i*)(B + i + 1))); + const __m128i a0b1 = _mm_add_epi32(a0, b1); + const __m128i a1b0 = _mm_add_epi32(a1, b0); + const __m128i a0a1b0b1 = _mm_add_epi32(a0b1, a1b0); // A0+A1+B0+B1 + const __m128i a0a1b0b1_8 = _mm_add_epi32(a0a1b0b1, kCst8); + const __m128i a0b1_2 = _mm_add_epi32(a0b1, a0b1); // 2*(A0+B1) + const __m128i a1b0_2 = _mm_add_epi32(a1b0, a1b0); // 2*(A1+B0) + const __m128i c0 = _mm_srai_epi32(_mm_add_epi32(a0b1_2, a0a1b0b1_8), 3); + const __m128i c1 = _mm_srai_epi32(_mm_add_epi32(a1b0_2, a0a1b0b1_8), 3); + const __m128i d0 = _mm_add_epi32(c1, a0); + const __m128i d1 = _mm_add_epi32(c0, a1); + const __m128i e0 = _mm_srai_epi32(d0, 1); + const __m128i e1 = _mm_srai_epi32(d1, 1); + const __m128i f0 = _mm_unpacklo_epi32(e0, e1); + const __m128i f1 = _mm_unpackhi_epi32(e0, e1); + const __m128i g = _mm_loadu_si128((const __m128i*)(best_y + 2 * i + 0)); + const __m128i h_16 = _mm_add_epi16(g, _mm_packs_epi32(f0, f1)); + const __m128i final = _mm_max_epi16(_mm_min_epi16(h_16, max), zero); + _mm_storeu_si128((__m128i*)(out + 2 * i + 0), final); + } + for (; i < len; ++i) { + // (9 * A0 + 3 * A1 + 3 * B0 + B1 + 8) >> 4 = + // = (8 * A0 + 2 * (A1 + B0) + (A0 + A1 + B0 + B1 + 8)) >> 4 + // We reuse the common sub-expressions. + const int a0b1 = A[i + 0] + B[i + 1]; + const int a1b0 = A[i + 1] + B[i + 0]; + const int a0a1b0b1 = a0b1 + a1b0 + 8; + const int v0 = (8 * A[i + 0] + 2 * a1b0 + a0a1b0b1) >> 4; + const int v1 = (8 * A[i + 1] + 2 * a0b1 + a0a1b0b1) >> 4; + out[2 * i + 0] = clip_SSE2(best_y[2 * i + 0] + v0, max_y); + out[2 * i + 1] = clip_SSE2(best_y[2 * i + 1] + v1, max_y); + } +} + +static void SharpYuvFilterRow_SSE2(const int16_t* A, const int16_t* B, int len, + const uint16_t* best_y, uint16_t* out, + int bit_depth) { + if (bit_depth <= 10) { + SharpYuvFilterRow16_SSE2(A, B, len, best_y, out, bit_depth); + } else { + SharpYuvFilterRow32_SSE2(A, B, len, best_y, out, bit_depth); + } +} + +//------------------------------------------------------------------------------ + +extern void InitSharpYuvSSE2(void); + +WEBP_TSAN_IGNORE_FUNCTION void InitSharpYuvSSE2(void) { + SharpYuvUpdateY = SharpYuvUpdateY_SSE2; + SharpYuvUpdateRGB = SharpYuvUpdateRGB_SSE2; + SharpYuvFilterRow = SharpYuvFilterRow_SSE2; +} +#else // !WEBP_USE_SSE2 + +void InitSharpYuvSSE2(void) {} + +#endif // WEBP_USE_SSE2 diff --git a/thirdparty/webp/src/dec/vp8i_dec.h b/thirdparty/webp/src/dec/vp8i_dec.h index 9af22f8cc6..30c1bd3ef9 100644 --- a/thirdparty/webp/src/dec/vp8i_dec.h +++ b/thirdparty/webp/src/dec/vp8i_dec.h @@ -32,7 +32,7 @@ extern "C" { // version numbers #define DEC_MAJ_VERSION 1 #define DEC_MIN_VERSION 2 -#define DEC_REV_VERSION 2 +#define DEC_REV_VERSION 4 // YUV-cache parameters. Cache is 32-bytes wide (= one cacheline). // Constraints are: We need to store one 16x16 block of luma samples (y), diff --git a/thirdparty/webp/src/dec/vp8l_dec.c b/thirdparty/webp/src/dec/vp8l_dec.c index 78db014030..1348055128 100644 --- a/thirdparty/webp/src/dec/vp8l_dec.c +++ b/thirdparty/webp/src/dec/vp8l_dec.c @@ -178,7 +178,7 @@ static WEBP_INLINE int PlaneCodeToDistance(int xsize, int plane_code) { //------------------------------------------------------------------------------ // Decodes the next Huffman code from bit-stream. -// FillBitWindow(br) needs to be called at minimum every second call +// VP8LFillBitWindow(br) needs to be called at minimum every second call // to ReadSymbol, in order to pre-fetch enough bits. static WEBP_INLINE int ReadSymbol(const HuffmanCode* table, VP8LBitReader* const br) { @@ -321,7 +321,7 @@ static int ReadHuffmanCode(int alphabet_size, VP8LDecoder* const dec, // The first code is either 1 bit or 8 bit code. int symbol = VP8LReadBits(br, (first_symbol_len_code == 0) ? 1 : 8); code_lengths[symbol] = 1; - // The second code (if present), is always 8 bit long. + // The second code (if present), is always 8 bits long. if (num_symbols == 2) { symbol = VP8LReadBits(br, 8); code_lengths[symbol] = 1; @@ -1281,7 +1281,7 @@ static int ExpandColorMap(int num_colors, VP8LTransform* const transform) { uint8_t* const new_data = (uint8_t*)new_color_map; new_color_map[0] = transform->data_[0]; for (i = 4; i < 4 * num_colors; ++i) { - // Equivalent to AddPixelEq(), on a byte-basis. + // Equivalent to VP8LAddPixels(), on a byte-basis. new_data[i] = (data[i] + new_data[i - 4]) & 0xff; } for (; i < 4 * final_num_colors; ++i) { diff --git a/thirdparty/webp/src/demux/demux.c b/thirdparty/webp/src/demux/demux.c index f04a2b8450..41387ec2d6 100644 --- a/thirdparty/webp/src/demux/demux.c +++ b/thirdparty/webp/src/demux/demux.c @@ -25,7 +25,7 @@ #define DMUX_MAJ_VERSION 1 #define DMUX_MIN_VERSION 2 -#define DMUX_REV_VERSION 2 +#define DMUX_REV_VERSION 4 typedef struct { size_t start_; // start location of the data @@ -614,7 +614,6 @@ static int IsValidExtendedFormat(const WebPDemuxer* const dmux) { while (f != NULL) { const int cur_frame_set = f->frame_num_; - int frame_count = 0; // Check frame properties. for (; f != NULL && f->frame_num_ == cur_frame_set; f = f->next_) { @@ -649,8 +648,6 @@ static int IsValidExtendedFormat(const WebPDemuxer* const dmux) { dmux->canvas_width_, dmux->canvas_height_)) { return 0; } - - ++frame_count; } } return 1; diff --git a/thirdparty/webp/src/dsp/alpha_processing_neon.c b/thirdparty/webp/src/dsp/alpha_processing_neon.c index 9e0ace9421..6716fb77f0 100644 --- a/thirdparty/webp/src/dsp/alpha_processing_neon.c +++ b/thirdparty/webp/src/dsp/alpha_processing_neon.c @@ -83,7 +83,7 @@ static void ApplyAlphaMultiply_NEON(uint8_t* rgba, int alpha_first, static int DispatchAlpha_NEON(const uint8_t* WEBP_RESTRICT alpha, int alpha_stride, int width, int height, uint8_t* WEBP_RESTRICT dst, int dst_stride) { - uint32_t alpha_mask = 0xffffffffu; + uint32_t alpha_mask = 0xffu; uint8x8_t mask8 = vdup_n_u8(0xff); uint32_t tmp[2]; int i, j; @@ -107,6 +107,7 @@ static int DispatchAlpha_NEON(const uint8_t* WEBP_RESTRICT alpha, dst += dst_stride; } vst1_u8((uint8_t*)tmp, mask8); + alpha_mask *= 0x01010101; alpha_mask &= tmp[0]; alpha_mask &= tmp[1]; return (alpha_mask != 0xffffffffu); @@ -135,7 +136,7 @@ static void DispatchAlphaToGreen_NEON(const uint8_t* WEBP_RESTRICT alpha, static int ExtractAlpha_NEON(const uint8_t* WEBP_RESTRICT argb, int argb_stride, int width, int height, uint8_t* WEBP_RESTRICT alpha, int alpha_stride) { - uint32_t alpha_mask = 0xffffffffu; + uint32_t alpha_mask = 0xffu; uint8x8_t mask8 = vdup_n_u8(0xff); uint32_t tmp[2]; int i, j; @@ -157,6 +158,7 @@ static int ExtractAlpha_NEON(const uint8_t* WEBP_RESTRICT argb, int argb_stride, alpha += alpha_stride; } vst1_u8((uint8_t*)tmp, mask8); + alpha_mask *= 0x01010101; alpha_mask &= tmp[0]; alpha_mask &= tmp[1]; return (alpha_mask == 0xffffffffu); diff --git a/thirdparty/webp/src/dsp/cpu.c b/thirdparty/webp/src/dsp/cpu.c index 3145e190a4..a4ba7f2cb7 100644 --- a/thirdparty/webp/src/dsp/cpu.c +++ b/thirdparty/webp/src/dsp/cpu.c @@ -11,7 +11,7 @@ // // Author: Christian Duvivier (cduvivier@google.com) -#include "src/dsp/dsp.h" +#include "src/dsp/cpu.h" #if defined(WEBP_HAVE_NEON_RTCD) #include diff --git a/thirdparty/webp/src/dsp/cpu.h b/thirdparty/webp/src/dsp/cpu.h new file mode 100644 index 0000000000..57a40d87d4 --- /dev/null +++ b/thirdparty/webp/src/dsp/cpu.h @@ -0,0 +1,254 @@ +// Copyright 2022 Google Inc. All Rights Reserved. +// +// Use of this source code is governed by a BSD-style license +// that can be found in the COPYING file in the root of the source +// tree. An additional intellectual property rights grant can be found +// in the file PATENTS. All contributing project authors may +// be found in the AUTHORS file in the root of the source tree. +// ----------------------------------------------------------------------------- +// +// CPU detection functions and macros. +// +// Author: Skal (pascal.massimino@gmail.com) + +#ifndef WEBP_DSP_CPU_H_ +#define WEBP_DSP_CPU_H_ + +#ifdef HAVE_CONFIG_H +#include "src/webp/config.h" +#endif + +#include "src/webp/types.h" + +#if defined(__GNUC__) +#define LOCAL_GCC_VERSION ((__GNUC__ << 8) | __GNUC_MINOR__) +#define LOCAL_GCC_PREREQ(maj, min) (LOCAL_GCC_VERSION >= (((maj) << 8) | (min))) +#else +#define LOCAL_GCC_VERSION 0 +#define LOCAL_GCC_PREREQ(maj, min) 0 +#endif + +#if defined(__clang__) +#define LOCAL_CLANG_VERSION ((__clang_major__ << 8) | __clang_minor__) +#define LOCAL_CLANG_PREREQ(maj, min) \ + (LOCAL_CLANG_VERSION >= (((maj) << 8) | (min))) +#else +#define LOCAL_CLANG_VERSION 0 +#define LOCAL_CLANG_PREREQ(maj, min) 0 +#endif + +#ifndef __has_builtin +#define __has_builtin(x) 0 +#endif + +#if !defined(HAVE_CONFIG_H) +#if defined(_MSC_VER) && _MSC_VER > 1310 && \ + (defined(_M_X64) || defined(_M_IX86)) +#define WEBP_MSC_SSE2 // Visual C++ SSE2 targets +#endif + +#if defined(_MSC_VER) && _MSC_VER >= 1500 && \ + (defined(_M_X64) || defined(_M_IX86)) +#define WEBP_MSC_SSE41 // Visual C++ SSE4.1 targets +#endif +#endif + +// WEBP_HAVE_* are used to indicate the presence of the instruction set in dsp +// files without intrinsics, allowing the corresponding Init() to be called. +// Files containing intrinsics will need to be built targeting the instruction +// set so should succeed on one of the earlier tests. +#if (defined(__SSE2__) || defined(WEBP_MSC_SSE2)) && \ + (!defined(HAVE_CONFIG_H) || defined(WEBP_HAVE_SSE2)) +#define WEBP_USE_SSE2 +#endif + +#if defined(WEBP_USE_SSE2) && !defined(WEBP_HAVE_SSE2) +#define WEBP_HAVE_SSE2 +#endif + +#if (defined(__SSE4_1__) || defined(WEBP_MSC_SSE41)) && \ + (!defined(HAVE_CONFIG_H) || defined(WEBP_HAVE_SSE41)) +#define WEBP_USE_SSE41 +#endif + +#if defined(WEBP_USE_SSE41) && !defined(WEBP_HAVE_SSE41) +#define WEBP_HAVE_SSE41 +#endif + +#undef WEBP_MSC_SSE41 +#undef WEBP_MSC_SSE2 + +// The intrinsics currently cause compiler errors with arm-nacl-gcc and the +// inline assembly would need to be modified for use with Native Client. +#if ((defined(__ARM_NEON__) || defined(__aarch64__)) && \ + (!defined(HAVE_CONFIG_H) || defined(WEBP_HAVE_NEON))) && \ + !defined(__native_client__) +#define WEBP_USE_NEON +#endif + +#if !defined(WEBP_USE_NEON) && defined(__ANDROID__) && \ + defined(__ARM_ARCH_7A__) && defined(HAVE_CPU_FEATURES_H) +#define WEBP_ANDROID_NEON // Android targets that may have NEON +#define WEBP_USE_NEON +#endif + +// Note: ARM64 is supported in Visual Studio 2017, but requires the direct +// inclusion of arm64_neon.h; Visual Studio 2019 includes this file in +// arm_neon.h. Compile errors were seen with Visual Studio 2019 16.4 with +// vtbl4_u8(); a fix was made in 16.6. +#if defined(_MSC_VER) && ((_MSC_VER >= 1700 && defined(_M_ARM)) || \ + (_MSC_VER >= 1926 && defined(_M_ARM64))) +#define WEBP_USE_NEON +#define WEBP_USE_INTRINSICS +#endif + +#if defined(WEBP_USE_NEON) && !defined(WEBP_HAVE_NEON) +#define WEBP_HAVE_NEON +#endif + +#if defined(__mips__) && !defined(__mips64) && defined(__mips_isa_rev) && \ + (__mips_isa_rev >= 1) && (__mips_isa_rev < 6) +#define WEBP_USE_MIPS32 +#if (__mips_isa_rev >= 2) +#define WEBP_USE_MIPS32_R2 +#if defined(__mips_dspr2) || (defined(__mips_dsp_rev) && __mips_dsp_rev >= 2) +#define WEBP_USE_MIPS_DSP_R2 +#endif +#endif +#endif + +#if defined(__mips_msa) && defined(__mips_isa_rev) && (__mips_isa_rev >= 5) +#define WEBP_USE_MSA +#endif + +#ifndef WEBP_DSP_OMIT_C_CODE +#define WEBP_DSP_OMIT_C_CODE 1 +#endif + +#if defined(WEBP_USE_NEON) && WEBP_DSP_OMIT_C_CODE +#define WEBP_NEON_OMIT_C_CODE 1 +#else +#define WEBP_NEON_OMIT_C_CODE 0 +#endif + +#if !(LOCAL_CLANG_PREREQ(3, 8) || LOCAL_GCC_PREREQ(4, 8) || \ + defined(__aarch64__)) +#define WEBP_NEON_WORK_AROUND_GCC 1 +#else +#define WEBP_NEON_WORK_AROUND_GCC 0 +#endif + +// This macro prevents thread_sanitizer from reporting known concurrent writes. +#define WEBP_TSAN_IGNORE_FUNCTION +#if defined(__has_feature) +#if __has_feature(thread_sanitizer) +#undef WEBP_TSAN_IGNORE_FUNCTION +#define WEBP_TSAN_IGNORE_FUNCTION __attribute__((no_sanitize_thread)) +#endif +#endif + +#if defined(__has_feature) +#if __has_feature(memory_sanitizer) +#define WEBP_MSAN +#endif +#endif + +#if defined(WEBP_USE_THREAD) && !defined(_WIN32) +#include // NOLINT + +#define WEBP_DSP_INIT(func) \ + do { \ + static volatile VP8CPUInfo func##_last_cpuinfo_used = \ + (VP8CPUInfo)&func##_last_cpuinfo_used; \ + static pthread_mutex_t func##_lock = PTHREAD_MUTEX_INITIALIZER; \ + if (pthread_mutex_lock(&func##_lock)) break; \ + if (func##_last_cpuinfo_used != VP8GetCPUInfo) func(); \ + func##_last_cpuinfo_used = VP8GetCPUInfo; \ + (void)pthread_mutex_unlock(&func##_lock); \ + } while (0) +#else // !(defined(WEBP_USE_THREAD) && !defined(_WIN32)) +#define WEBP_DSP_INIT(func) \ + do { \ + static volatile VP8CPUInfo func##_last_cpuinfo_used = \ + (VP8CPUInfo)&func##_last_cpuinfo_used; \ + if (func##_last_cpuinfo_used == VP8GetCPUInfo) break; \ + func(); \ + func##_last_cpuinfo_used = VP8GetCPUInfo; \ + } while (0) +#endif // defined(WEBP_USE_THREAD) && !defined(_WIN32) + +// Defines an Init + helper function that control multiple initialization of +// function pointers / tables. +/* Usage: + WEBP_DSP_INIT_FUNC(InitFunc) { + ...function body + } +*/ +#define WEBP_DSP_INIT_FUNC(name) \ + static WEBP_TSAN_IGNORE_FUNCTION void name##_body(void); \ + WEBP_TSAN_IGNORE_FUNCTION void name(void) { WEBP_DSP_INIT(name##_body); } \ + static WEBP_TSAN_IGNORE_FUNCTION void name##_body(void) + +#define WEBP_UBSAN_IGNORE_UNDEF +#define WEBP_UBSAN_IGNORE_UNSIGNED_OVERFLOW +#if defined(__clang__) && defined(__has_attribute) +#if __has_attribute(no_sanitize) +// This macro prevents the undefined behavior sanitizer from reporting +// failures. This is only meant to silence unaligned loads on platforms that +// are known to support them. +#undef WEBP_UBSAN_IGNORE_UNDEF +#define WEBP_UBSAN_IGNORE_UNDEF __attribute__((no_sanitize("undefined"))) + +// This macro prevents the undefined behavior sanitizer from reporting +// failures related to unsigned integer overflows. This is only meant to +// silence cases where this well defined behavior is expected. +#undef WEBP_UBSAN_IGNORE_UNSIGNED_OVERFLOW +#define WEBP_UBSAN_IGNORE_UNSIGNED_OVERFLOW \ + __attribute__((no_sanitize("unsigned-integer-overflow"))) +#endif +#endif + +// If 'ptr' is NULL, returns NULL. Otherwise returns 'ptr + off'. +// Prevents undefined behavior sanitizer nullptr-with-nonzero-offset warning. +#if !defined(WEBP_OFFSET_PTR) +#define WEBP_OFFSET_PTR(ptr, off) (((ptr) == NULL) ? NULL : ((ptr) + (off))) +#endif + +// Regularize the definition of WEBP_SWAP_16BIT_CSP (backward compatibility) +#if !defined(WEBP_SWAP_16BIT_CSP) +#define WEBP_SWAP_16BIT_CSP 0 +#endif + +// some endian fix (e.g.: mips-gcc doesn't define __BIG_ENDIAN__) +#if !defined(WORDS_BIGENDIAN) && \ + (defined(__BIG_ENDIAN__) || defined(_M_PPC) || \ + (defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__))) +#define WORDS_BIGENDIAN +#endif + +typedef enum { + kSSE2, + kSSE3, + kSlowSSSE3, // special feature for slow SSSE3 architectures + kSSE4_1, + kAVX, + kAVX2, + kNEON, + kMIPS32, + kMIPSdspR2, + kMSA +} CPUFeature; + +#ifdef __cplusplus +extern "C" { +#endif + +// returns true if the CPU supports the feature. +typedef int (*VP8CPUInfo)(CPUFeature feature); +WEBP_EXTERN VP8CPUInfo VP8GetCPUInfo; + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // WEBP_DSP_CPU_H_ diff --git a/thirdparty/webp/src/dsp/dsp.h b/thirdparty/webp/src/dsp/dsp.h index c4f57e4d5b..d2000b8efc 100644 --- a/thirdparty/webp/src/dsp/dsp.h +++ b/thirdparty/webp/src/dsp/dsp.h @@ -18,6 +18,7 @@ #include "src/webp/config.h" #endif +#include "src/dsp/cpu.h" #include "src/webp/types.h" #ifdef __cplusplus @@ -43,225 +44,6 @@ extern "C" { #define WEBP_RESTRICT #endif -//------------------------------------------------------------------------------ -// CPU detection - -#if defined(__GNUC__) -# define LOCAL_GCC_VERSION ((__GNUC__ << 8) | __GNUC_MINOR__) -# define LOCAL_GCC_PREREQ(maj, min) \ - (LOCAL_GCC_VERSION >= (((maj) << 8) | (min))) -#else -# define LOCAL_GCC_VERSION 0 -# define LOCAL_GCC_PREREQ(maj, min) 0 -#endif - -#if defined(__clang__) -# define LOCAL_CLANG_VERSION ((__clang_major__ << 8) | __clang_minor__) -# define LOCAL_CLANG_PREREQ(maj, min) \ - (LOCAL_CLANG_VERSION >= (((maj) << 8) | (min))) -#else -# define LOCAL_CLANG_VERSION 0 -# define LOCAL_CLANG_PREREQ(maj, min) 0 -#endif - -#ifndef __has_builtin -# define __has_builtin(x) 0 -#endif - -#if !defined(HAVE_CONFIG_H) -#if defined(_MSC_VER) && _MSC_VER > 1310 && \ - (defined(_M_X64) || defined(_M_IX86)) -#define WEBP_MSC_SSE2 // Visual C++ SSE2 targets -#endif - -#if defined(_MSC_VER) && _MSC_VER >= 1500 && \ - (defined(_M_X64) || defined(_M_IX86)) -#define WEBP_MSC_SSE41 // Visual C++ SSE4.1 targets -#endif -#endif - -// WEBP_HAVE_* are used to indicate the presence of the instruction set in dsp -// files without intrinsics, allowing the corresponding Init() to be called. -// Files containing intrinsics will need to be built targeting the instruction -// set so should succeed on one of the earlier tests. -#if (defined(__SSE2__) || defined(WEBP_MSC_SSE2)) && \ - (!defined(HAVE_CONFIG_H) || defined(WEBP_HAVE_SSE2)) -#define WEBP_USE_SSE2 -#endif - -#if defined(WEBP_USE_SSE2) && !defined(WEBP_HAVE_SSE2) -#define WEBP_HAVE_SSE2 -#endif - -#if (defined(__SSE4_1__) || defined(WEBP_MSC_SSE41)) && \ - (!defined(HAVE_CONFIG_H) || defined(WEBP_HAVE_SSE41)) -#define WEBP_USE_SSE41 -#endif - -#if defined(WEBP_USE_SSE41) && !defined(WEBP_HAVE_SSE41) -#define WEBP_HAVE_SSE41 -#endif - -#undef WEBP_MSC_SSE41 -#undef WEBP_MSC_SSE2 - -// The intrinsics currently cause compiler errors with arm-nacl-gcc and the -// inline assembly would need to be modified for use with Native Client. -#if ((defined(__ARM_NEON__) || defined(__aarch64__)) && \ - (!defined(HAVE_CONFIG_H) || defined(WEBP_HAVE_NEON))) && \ - !defined(__native_client__) -#define WEBP_USE_NEON -#endif - -#if !defined(WEBP_USE_NEON) && defined(__ANDROID__) && \ - defined(__ARM_ARCH_7A__) && defined(HAVE_CPU_FEATURES_H) -#define WEBP_ANDROID_NEON // Android targets that may have NEON -#define WEBP_USE_NEON -#endif - -// Note: ARM64 is supported in Visual Studio 2017, but requires the direct -// inclusion of arm64_neon.h; Visual Studio 2019 includes this file in -// arm_neon.h. -#if defined(_MSC_VER) && \ - ((_MSC_VER >= 1700 && defined(_M_ARM)) || \ - (_MSC_VER >= 1920 && defined(_M_ARM64))) -#define WEBP_USE_NEON -#define WEBP_USE_INTRINSICS -#endif - -#if defined(WEBP_USE_NEON) && !defined(WEBP_HAVE_NEON) -#define WEBP_HAVE_NEON -#endif - -#if defined(__mips__) && !defined(__mips64) && \ - defined(__mips_isa_rev) && (__mips_isa_rev >= 1) && (__mips_isa_rev < 6) -#define WEBP_USE_MIPS32 -#if (__mips_isa_rev >= 2) -#define WEBP_USE_MIPS32_R2 -#if defined(__mips_dspr2) || (defined(__mips_dsp_rev) && __mips_dsp_rev >= 2) -#define WEBP_USE_MIPS_DSP_R2 -#endif -#endif -#endif - -#if defined(__mips_msa) && defined(__mips_isa_rev) && (__mips_isa_rev >= 5) -#define WEBP_USE_MSA -#endif - -#ifndef WEBP_DSP_OMIT_C_CODE -#define WEBP_DSP_OMIT_C_CODE 1 -#endif - -#if defined(WEBP_USE_NEON) && WEBP_DSP_OMIT_C_CODE -#define WEBP_NEON_OMIT_C_CODE 1 -#else -#define WEBP_NEON_OMIT_C_CODE 0 -#endif - -#if !(LOCAL_CLANG_PREREQ(3,8) || LOCAL_GCC_PREREQ(4,8) || defined(__aarch64__)) -#define WEBP_NEON_WORK_AROUND_GCC 1 -#else -#define WEBP_NEON_WORK_AROUND_GCC 0 -#endif - -// This macro prevents thread_sanitizer from reporting known concurrent writes. -#define WEBP_TSAN_IGNORE_FUNCTION -#if defined(__has_feature) -#if __has_feature(thread_sanitizer) -#undef WEBP_TSAN_IGNORE_FUNCTION -#define WEBP_TSAN_IGNORE_FUNCTION __attribute__((no_sanitize_thread)) -#endif -#endif - -#if defined(WEBP_USE_THREAD) && !defined(_WIN32) -#include // NOLINT - -#define WEBP_DSP_INIT(func) do { \ - static volatile VP8CPUInfo func ## _last_cpuinfo_used = \ - (VP8CPUInfo)&func ## _last_cpuinfo_used; \ - static pthread_mutex_t func ## _lock = PTHREAD_MUTEX_INITIALIZER; \ - if (pthread_mutex_lock(&func ## _lock)) break; \ - if (func ## _last_cpuinfo_used != VP8GetCPUInfo) func(); \ - func ## _last_cpuinfo_used = VP8GetCPUInfo; \ - (void)pthread_mutex_unlock(&func ## _lock); \ -} while (0) -#else // !(defined(WEBP_USE_THREAD) && !defined(_WIN32)) -#define WEBP_DSP_INIT(func) do { \ - static volatile VP8CPUInfo func ## _last_cpuinfo_used = \ - (VP8CPUInfo)&func ## _last_cpuinfo_used; \ - if (func ## _last_cpuinfo_used == VP8GetCPUInfo) break; \ - func(); \ - func ## _last_cpuinfo_used = VP8GetCPUInfo; \ -} while (0) -#endif // defined(WEBP_USE_THREAD) && !defined(_WIN32) - -// Defines an Init + helper function that control multiple initialization of -// function pointers / tables. -/* Usage: - WEBP_DSP_INIT_FUNC(InitFunc) { - ...function body - } -*/ -#define WEBP_DSP_INIT_FUNC(name) \ - static WEBP_TSAN_IGNORE_FUNCTION void name ## _body(void); \ - WEBP_TSAN_IGNORE_FUNCTION void name(void) { \ - WEBP_DSP_INIT(name ## _body); \ - } \ - static WEBP_TSAN_IGNORE_FUNCTION void name ## _body(void) - -#define WEBP_UBSAN_IGNORE_UNDEF -#define WEBP_UBSAN_IGNORE_UNSIGNED_OVERFLOW -#if defined(__clang__) && defined(__has_attribute) -#if __has_attribute(no_sanitize) -// This macro prevents the undefined behavior sanitizer from reporting -// failures. This is only meant to silence unaligned loads on platforms that -// are known to support them. -#undef WEBP_UBSAN_IGNORE_UNDEF -#define WEBP_UBSAN_IGNORE_UNDEF \ - __attribute__((no_sanitize("undefined"))) - -// This macro prevents the undefined behavior sanitizer from reporting -// failures related to unsigned integer overflows. This is only meant to -// silence cases where this well defined behavior is expected. -#undef WEBP_UBSAN_IGNORE_UNSIGNED_OVERFLOW -#define WEBP_UBSAN_IGNORE_UNSIGNED_OVERFLOW \ - __attribute__((no_sanitize("unsigned-integer-overflow"))) -#endif -#endif - -// If 'ptr' is NULL, returns NULL. Otherwise returns 'ptr + off'. -// Prevents undefined behavior sanitizer nullptr-with-nonzero-offset warning. -#if !defined(WEBP_OFFSET_PTR) -#define WEBP_OFFSET_PTR(ptr, off) (((ptr) == NULL) ? NULL : ((ptr) + (off))) -#endif - -// Regularize the definition of WEBP_SWAP_16BIT_CSP (backward compatibility) -#if !defined(WEBP_SWAP_16BIT_CSP) -#define WEBP_SWAP_16BIT_CSP 0 -#endif - -// some endian fix (e.g.: mips-gcc doesn't define __BIG_ENDIAN__) -#if !defined(WORDS_BIGENDIAN) && \ - (defined(__BIG_ENDIAN__) || defined(_M_PPC) || \ - (defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__))) -#define WORDS_BIGENDIAN -#endif - -typedef enum { - kSSE2, - kSSE3, - kSlowSSSE3, // special feature for slow SSSE3 architectures - kSSE4_1, - kAVX, - kAVX2, - kNEON, - kMIPS32, - kMIPSdspR2, - kMSA -} CPUFeature; -// returns true if the CPU supports the feature. -typedef int (*VP8CPUInfo)(CPUFeature feature); -WEBP_EXTERN VP8CPUInfo VP8GetCPUInfo; //------------------------------------------------------------------------------ // Init stub generator @@ -550,15 +332,6 @@ extern void WebPConvertARGBToUV_C(const uint32_t* argb, uint8_t* u, uint8_t* v, extern void WebPConvertRGBA32ToUV_C(const uint16_t* rgb, uint8_t* u, uint8_t* v, int width); -// utilities for accurate RGB->YUV conversion -extern uint64_t (*WebPSharpYUVUpdateY)(const uint16_t* src, const uint16_t* ref, - uint16_t* dst, int len); -extern void (*WebPSharpYUVUpdateRGB)(const int16_t* src, const int16_t* ref, - int16_t* dst, int len); -extern void (*WebPSharpYUVFilterRow)(const int16_t* A, const int16_t* B, - int len, - const uint16_t* best_y, uint16_t* out); - // Must be called before using the above. void WebPInitConvertARGBToYUV(void); diff --git a/thirdparty/webp/src/dsp/lossless.h b/thirdparty/webp/src/dsp/lossless.h index c26c6bca07..de60d95d0b 100644 --- a/thirdparty/webp/src/dsp/lossless.h +++ b/thirdparty/webp/src/dsp/lossless.h @@ -182,9 +182,9 @@ extern VP8LPredictorAddSubFunc VP8LPredictorsSub_C[16]; // ----------------------------------------------------------------------------- // Huffman-cost related functions. -typedef double (*VP8LCostFunc)(const uint32_t* population, int length); -typedef double (*VP8LCostCombinedFunc)(const uint32_t* X, const uint32_t* Y, - int length); +typedef float (*VP8LCostFunc)(const uint32_t* population, int length); +typedef float (*VP8LCostCombinedFunc)(const uint32_t* X, const uint32_t* Y, + int length); typedef float (*VP8LCombinedShannonEntropyFunc)(const int X[256], const int Y[256]); @@ -198,7 +198,7 @@ typedef struct { // small struct to hold counters } VP8LStreaks; typedef struct { // small struct to hold bit entropy results - double entropy; // entropy + float entropy; // entropy uint32_t sum; // sum of the population int nonzeros; // number of non-zero elements in the population uint32_t max_val; // maximum value in the population diff --git a/thirdparty/webp/src/dsp/lossless_enc.c b/thirdparty/webp/src/dsp/lossless_enc.c index 1580631e38..de6c4ace5f 100644 --- a/thirdparty/webp/src/dsp/lossless_enc.c +++ b/thirdparty/webp/src/dsp/lossless_enc.c @@ -402,7 +402,7 @@ static float FastLog2Slow_C(uint32_t v) { // Compute the combined Shanon's entropy for distribution {X} and {X+Y} static float CombinedShannonEntropy_C(const int X[256], const int Y[256]) { int i; - double retval = 0.; + float retval = 0.f; int sumX = 0, sumXY = 0; for (i = 0; i < 256; ++i) { const int x = X[i]; @@ -418,7 +418,7 @@ static float CombinedShannonEntropy_C(const int X[256], const int Y[256]) { } } retval += VP8LFastSLog2(sumX) + VP8LFastSLog2(sumXY); - return (float)retval; + return retval; } void VP8LBitEntropyInit(VP8LBitEntropy* const entropy) { @@ -636,17 +636,17 @@ void VP8LBundleColorMap_C(const uint8_t* const row, int width, int xbits, //------------------------------------------------------------------------------ -static double ExtraCost_C(const uint32_t* population, int length) { +static float ExtraCost_C(const uint32_t* population, int length) { int i; - double cost = 0.; + float cost = 0.f; for (i = 2; i < length - 2; ++i) cost += (i >> 1) * population[i + 2]; return cost; } -static double ExtraCostCombined_C(const uint32_t* X, const uint32_t* Y, +static float ExtraCostCombined_C(const uint32_t* X, const uint32_t* Y, int length) { int i; - double cost = 0.; + float cost = 0.f; for (i = 2; i < length - 2; ++i) { const int xy = X[i + 2] + Y[i + 2]; cost += (i >> 1) * xy; diff --git a/thirdparty/webp/src/dsp/lossless_enc_mips32.c b/thirdparty/webp/src/dsp/lossless_enc_mips32.c index 0412a093cf..639f786631 100644 --- a/thirdparty/webp/src/dsp/lossless_enc_mips32.c +++ b/thirdparty/webp/src/dsp/lossless_enc_mips32.c @@ -103,8 +103,8 @@ static float FastLog2Slow_MIPS32(uint32_t v) { // cost += i * *(pop + 1); // pop += 2; // } -// return (double)cost; -static double ExtraCost_MIPS32(const uint32_t* const population, int length) { +// return (float)cost; +static float ExtraCost_MIPS32(const uint32_t* const population, int length) { int i, temp0, temp1; const uint32_t* pop = &population[4]; const uint32_t* const LoopEnd = &population[length]; @@ -130,7 +130,7 @@ static double ExtraCost_MIPS32(const uint32_t* const population, int length) { : "memory", "hi", "lo" ); - return (double)((int64_t)temp0 << 32 | temp1); + return (float)((int64_t)temp0 << 32 | temp1); } // C version of this function: @@ -148,9 +148,9 @@ static double ExtraCost_MIPS32(const uint32_t* const population, int length) { // pX += 2; // pY += 2; // } -// return (double)cost; -static double ExtraCostCombined_MIPS32(const uint32_t* const X, - const uint32_t* const Y, int length) { +// return (float)cost; +static float ExtraCostCombined_MIPS32(const uint32_t* const X, + const uint32_t* const Y, int length) { int i, temp0, temp1, temp2, temp3; const uint32_t* pX = &X[4]; const uint32_t* pY = &Y[4]; @@ -183,7 +183,7 @@ static double ExtraCostCombined_MIPS32(const uint32_t* const X, : "memory", "hi", "lo" ); - return (double)((int64_t)temp0 << 32 | temp1); + return (float)((int64_t)temp0 << 32 | temp1); } #define HUFFMAN_COST_PASS \ @@ -347,24 +347,24 @@ static void GetCombinedEntropyUnrefined_MIPS32(const uint32_t X[], static void AddVector_MIPS32(const uint32_t* pa, const uint32_t* pb, uint32_t* pout, int size) { uint32_t temp0, temp1, temp2, temp3, temp4, temp5, temp6, temp7; - const uint32_t end = ((size) / 4) * 4; + const int end = ((size) / 4) * 4; const uint32_t* const LoopEnd = pa + end; int i; ASM_START ADD_TO_OUT(0, 4, 8, 12, 1, pa, pb, pout) ASM_END_0 - for (i = end; i < size; ++i) pout[i] = pa[i] + pb[i]; + for (i = 0; i < size - end; ++i) pout[i] = pa[i] + pb[i]; } static void AddVectorEq_MIPS32(const uint32_t* pa, uint32_t* pout, int size) { uint32_t temp0, temp1, temp2, temp3, temp4, temp5, temp6, temp7; - const uint32_t end = ((size) / 4) * 4; + const int end = ((size) / 4) * 4; const uint32_t* const LoopEnd = pa + end; int i; ASM_START ADD_TO_OUT(0, 4, 8, 12, 0, pa, pout, pout) ASM_END_1 - for (i = end; i < size; ++i) pout[i] += pa[i]; + for (i = 0; i < size - end; ++i) pout[i] += pa[i]; } #undef ASM_END_1 diff --git a/thirdparty/webp/src/dsp/lossless_enc_sse2.c b/thirdparty/webp/src/dsp/lossless_enc_sse2.c index b2f83b871c..948001a3d5 100644 --- a/thirdparty/webp/src/dsp/lossless_enc_sse2.c +++ b/thirdparty/webp/src/dsp/lossless_enc_sse2.c @@ -239,7 +239,7 @@ static void AddVectorEq_SSE2(const uint32_t* a, uint32_t* out, int size) { static float CombinedShannonEntropy_SSE2(const int X[256], const int Y[256]) { int i; - double retval = 0.; + float retval = 0.f; int sumX = 0, sumXY = 0; const __m128i zero = _mm_setzero_si128(); @@ -273,7 +273,7 @@ static float CombinedShannonEntropy_SSE2(const int X[256], const int Y[256]) { } } retval += VP8LFastSLog2(sumX) + VP8LFastSLog2(sumXY); - return (float)retval; + return retval; } #else diff --git a/thirdparty/webp/src/dsp/yuv.c b/thirdparty/webp/src/dsp/yuv.c index 48466f8b11..d16c13d3ca 100644 --- a/thirdparty/webp/src/dsp/yuv.c +++ b/thirdparty/webp/src/dsp/yuv.c @@ -194,50 +194,6 @@ void WebPConvertRGBA32ToUV_C(const uint16_t* rgb, //----------------------------------------------------------------------------- -#if !WEBP_NEON_OMIT_C_CODE -#define MAX_Y ((1 << 10) - 1) // 10b precision over 16b-arithmetic -static uint16_t clip_y(int v) { - return (v < 0) ? 0 : (v > MAX_Y) ? MAX_Y : (uint16_t)v; -} - -static uint64_t SharpYUVUpdateY_C(const uint16_t* ref, const uint16_t* src, - uint16_t* dst, int len) { - uint64_t diff = 0; - int i; - for (i = 0; i < len; ++i) { - const int diff_y = ref[i] - src[i]; - const int new_y = (int)dst[i] + diff_y; - dst[i] = clip_y(new_y); - diff += (uint64_t)abs(diff_y); - } - return diff; -} - -static void SharpYUVUpdateRGB_C(const int16_t* ref, const int16_t* src, - int16_t* dst, int len) { - int i; - for (i = 0; i < len; ++i) { - const int diff_uv = ref[i] - src[i]; - dst[i] += diff_uv; - } -} - -static void SharpYUVFilterRow_C(const int16_t* A, const int16_t* B, int len, - const uint16_t* best_y, uint16_t* out) { - int i; - for (i = 0; i < len; ++i, ++A, ++B) { - const int v0 = (A[0] * 9 + A[1] * 3 + B[0] * 3 + B[1] + 8) >> 4; - const int v1 = (A[1] * 9 + A[0] * 3 + B[1] * 3 + B[0] + 8) >> 4; - out[2 * i + 0] = clip_y(best_y[2 * i + 0] + v0); - out[2 * i + 1] = clip_y(best_y[2 * i + 1] + v1); - } -} -#endif // !WEBP_NEON_OMIT_C_CODE - -#undef MAX_Y - -//----------------------------------------------------------------------------- - void (*WebPConvertRGB24ToY)(const uint8_t* rgb, uint8_t* y, int width); void (*WebPConvertBGR24ToY)(const uint8_t* bgr, uint8_t* y, int width); void (*WebPConvertRGBA32ToUV)(const uint16_t* rgb, @@ -247,18 +203,9 @@ void (*WebPConvertARGBToY)(const uint32_t* argb, uint8_t* y, int width); void (*WebPConvertARGBToUV)(const uint32_t* argb, uint8_t* u, uint8_t* v, int src_width, int do_store); -uint64_t (*WebPSharpYUVUpdateY)(const uint16_t* ref, const uint16_t* src, - uint16_t* dst, int len); -void (*WebPSharpYUVUpdateRGB)(const int16_t* ref, const int16_t* src, - int16_t* dst, int len); -void (*WebPSharpYUVFilterRow)(const int16_t* A, const int16_t* B, int len, - const uint16_t* best_y, uint16_t* out); - extern void WebPInitConvertARGBToYUVSSE2(void); extern void WebPInitConvertARGBToYUVSSE41(void); extern void WebPInitConvertARGBToYUVNEON(void); -extern void WebPInitSharpYUVSSE2(void); -extern void WebPInitSharpYUVNEON(void); WEBP_DSP_INIT_FUNC(WebPInitConvertARGBToYUV) { WebPConvertARGBToY = ConvertARGBToY_C; @@ -269,17 +216,10 @@ WEBP_DSP_INIT_FUNC(WebPInitConvertARGBToYUV) { WebPConvertRGBA32ToUV = WebPConvertRGBA32ToUV_C; -#if !WEBP_NEON_OMIT_C_CODE - WebPSharpYUVUpdateY = SharpYUVUpdateY_C; - WebPSharpYUVUpdateRGB = SharpYUVUpdateRGB_C; - WebPSharpYUVFilterRow = SharpYUVFilterRow_C; -#endif - if (VP8GetCPUInfo != NULL) { #if defined(WEBP_HAVE_SSE2) if (VP8GetCPUInfo(kSSE2)) { WebPInitConvertARGBToYUVSSE2(); - WebPInitSharpYUVSSE2(); } #endif // WEBP_HAVE_SSE2 #if defined(WEBP_HAVE_SSE41) @@ -293,7 +233,6 @@ WEBP_DSP_INIT_FUNC(WebPInitConvertARGBToYUV) { if (WEBP_NEON_OMIT_C_CODE || (VP8GetCPUInfo != NULL && VP8GetCPUInfo(kNEON))) { WebPInitConvertARGBToYUVNEON(); - WebPInitSharpYUVNEON(); } #endif // WEBP_HAVE_NEON @@ -302,7 +241,4 @@ WEBP_DSP_INIT_FUNC(WebPInitConvertARGBToYUV) { assert(WebPConvertRGB24ToY != NULL); assert(WebPConvertBGR24ToY != NULL); assert(WebPConvertRGBA32ToUV != NULL); - assert(WebPSharpYUVUpdateY != NULL); - assert(WebPSharpYUVUpdateRGB != NULL); - assert(WebPSharpYUVFilterRow != NULL); } diff --git a/thirdparty/webp/src/dsp/yuv_neon.c b/thirdparty/webp/src/dsp/yuv_neon.c index a34d60248f..ff77b00980 100644 --- a/thirdparty/webp/src/dsp/yuv_neon.c +++ b/thirdparty/webp/src/dsp/yuv_neon.c @@ -173,116 +173,8 @@ WEBP_TSAN_IGNORE_FUNCTION void WebPInitConvertARGBToYUVNEON(void) { WebPConvertRGBA32ToUV = ConvertRGBA32ToUV_NEON; } -//------------------------------------------------------------------------------ - -#define MAX_Y ((1 << 10) - 1) // 10b precision over 16b-arithmetic -static uint16_t clip_y_NEON(int v) { - return (v < 0) ? 0 : (v > MAX_Y) ? MAX_Y : (uint16_t)v; -} - -static uint64_t SharpYUVUpdateY_NEON(const uint16_t* ref, const uint16_t* src, - uint16_t* dst, int len) { - int i; - const int16x8_t zero = vdupq_n_s16(0); - const int16x8_t max = vdupq_n_s16(MAX_Y); - uint64x2_t sum = vdupq_n_u64(0); - uint64_t diff; - - for (i = 0; i + 8 <= len; i += 8) { - const int16x8_t A = vreinterpretq_s16_u16(vld1q_u16(ref + i)); - const int16x8_t B = vreinterpretq_s16_u16(vld1q_u16(src + i)); - const int16x8_t C = vreinterpretq_s16_u16(vld1q_u16(dst + i)); - const int16x8_t D = vsubq_s16(A, B); // diff_y - const int16x8_t F = vaddq_s16(C, D); // new_y - const uint16x8_t H = - vreinterpretq_u16_s16(vmaxq_s16(vminq_s16(F, max), zero)); - const int16x8_t I = vabsq_s16(D); // abs(diff_y) - vst1q_u16(dst + i, H); - sum = vpadalq_u32(sum, vpaddlq_u16(vreinterpretq_u16_s16(I))); - } - diff = vgetq_lane_u64(sum, 0) + vgetq_lane_u64(sum, 1); - for (; i < len; ++i) { - const int diff_y = ref[i] - src[i]; - const int new_y = (int)(dst[i]) + diff_y; - dst[i] = clip_y_NEON(new_y); - diff += (uint64_t)(abs(diff_y)); - } - return diff; -} - -static void SharpYUVUpdateRGB_NEON(const int16_t* ref, const int16_t* src, - int16_t* dst, int len) { - int i; - for (i = 0; i + 8 <= len; i += 8) { - const int16x8_t A = vld1q_s16(ref + i); - const int16x8_t B = vld1q_s16(src + i); - const int16x8_t C = vld1q_s16(dst + i); - const int16x8_t D = vsubq_s16(A, B); // diff_uv - const int16x8_t E = vaddq_s16(C, D); // new_uv - vst1q_s16(dst + i, E); - } - for (; i < len; ++i) { - const int diff_uv = ref[i] - src[i]; - dst[i] += diff_uv; - } -} - -static void SharpYUVFilterRow_NEON(const int16_t* A, const int16_t* B, int len, - const uint16_t* best_y, uint16_t* out) { - int i; - const int16x8_t max = vdupq_n_s16(MAX_Y); - const int16x8_t zero = vdupq_n_s16(0); - for (i = 0; i + 8 <= len; i += 8) { - const int16x8_t a0 = vld1q_s16(A + i + 0); - const int16x8_t a1 = vld1q_s16(A + i + 1); - const int16x8_t b0 = vld1q_s16(B + i + 0); - const int16x8_t b1 = vld1q_s16(B + i + 1); - const int16x8_t a0b1 = vaddq_s16(a0, b1); - const int16x8_t a1b0 = vaddq_s16(a1, b0); - const int16x8_t a0a1b0b1 = vaddq_s16(a0b1, a1b0); // A0+A1+B0+B1 - const int16x8_t a0b1_2 = vaddq_s16(a0b1, a0b1); // 2*(A0+B1) - const int16x8_t a1b0_2 = vaddq_s16(a1b0, a1b0); // 2*(A1+B0) - const int16x8_t c0 = vshrq_n_s16(vaddq_s16(a0b1_2, a0a1b0b1), 3); - const int16x8_t c1 = vshrq_n_s16(vaddq_s16(a1b0_2, a0a1b0b1), 3); - const int16x8_t d0 = vaddq_s16(c1, a0); - const int16x8_t d1 = vaddq_s16(c0, a1); - const int16x8_t e0 = vrshrq_n_s16(d0, 1); - const int16x8_t e1 = vrshrq_n_s16(d1, 1); - const int16x8x2_t f = vzipq_s16(e0, e1); - const int16x8_t g0 = vreinterpretq_s16_u16(vld1q_u16(best_y + 2 * i + 0)); - const int16x8_t g1 = vreinterpretq_s16_u16(vld1q_u16(best_y + 2 * i + 8)); - const int16x8_t h0 = vaddq_s16(g0, f.val[0]); - const int16x8_t h1 = vaddq_s16(g1, f.val[1]); - const int16x8_t i0 = vmaxq_s16(vminq_s16(h0, max), zero); - const int16x8_t i1 = vmaxq_s16(vminq_s16(h1, max), zero); - vst1q_u16(out + 2 * i + 0, vreinterpretq_u16_s16(i0)); - vst1q_u16(out + 2 * i + 8, vreinterpretq_u16_s16(i1)); - } - for (; i < len; ++i) { - const int a0b1 = A[i + 0] + B[i + 1]; - const int a1b0 = A[i + 1] + B[i + 0]; - const int a0a1b0b1 = a0b1 + a1b0 + 8; - const int v0 = (8 * A[i + 0] + 2 * a1b0 + a0a1b0b1) >> 4; - const int v1 = (8 * A[i + 1] + 2 * a0b1 + a0a1b0b1) >> 4; - out[2 * i + 0] = clip_y_NEON(best_y[2 * i + 0] + v0); - out[2 * i + 1] = clip_y_NEON(best_y[2 * i + 1] + v1); - } -} -#undef MAX_Y - -//------------------------------------------------------------------------------ - -extern void WebPInitSharpYUVNEON(void); - -WEBP_TSAN_IGNORE_FUNCTION void WebPInitSharpYUVNEON(void) { - WebPSharpYUVUpdateY = SharpYUVUpdateY_NEON; - WebPSharpYUVUpdateRGB = SharpYUVUpdateRGB_NEON; - WebPSharpYUVFilterRow = SharpYUVFilterRow_NEON; -} - #else // !WEBP_USE_NEON WEBP_DSP_INIT_STUB(WebPInitConvertARGBToYUVNEON) -WEBP_DSP_INIT_STUB(WebPInitSharpYUVNEON) #endif // WEBP_USE_NEON diff --git a/thirdparty/webp/src/dsp/yuv_sse2.c b/thirdparty/webp/src/dsp/yuv_sse2.c index baa48d5371..970bbb7884 100644 --- a/thirdparty/webp/src/dsp/yuv_sse2.c +++ b/thirdparty/webp/src/dsp/yuv_sse2.c @@ -747,128 +747,9 @@ WEBP_TSAN_IGNORE_FUNCTION void WebPInitConvertARGBToYUVSSE2(void) { WebPConvertRGBA32ToUV = ConvertRGBA32ToUV_SSE2; } -//------------------------------------------------------------------------------ - -#define MAX_Y ((1 << 10) - 1) // 10b precision over 16b-arithmetic -static uint16_t clip_y(int v) { - return (v < 0) ? 0 : (v > MAX_Y) ? MAX_Y : (uint16_t)v; -} - -static uint64_t SharpYUVUpdateY_SSE2(const uint16_t* ref, const uint16_t* src, - uint16_t* dst, int len) { - uint64_t diff = 0; - uint32_t tmp[4]; - int i; - const __m128i zero = _mm_setzero_si128(); - const __m128i max = _mm_set1_epi16(MAX_Y); - const __m128i one = _mm_set1_epi16(1); - __m128i sum = zero; - - for (i = 0; i + 8 <= len; i += 8) { - const __m128i A = _mm_loadu_si128((const __m128i*)(ref + i)); - const __m128i B = _mm_loadu_si128((const __m128i*)(src + i)); - const __m128i C = _mm_loadu_si128((const __m128i*)(dst + i)); - const __m128i D = _mm_sub_epi16(A, B); // diff_y - const __m128i E = _mm_cmpgt_epi16(zero, D); // sign (-1 or 0) - const __m128i F = _mm_add_epi16(C, D); // new_y - const __m128i G = _mm_or_si128(E, one); // -1 or 1 - const __m128i H = _mm_max_epi16(_mm_min_epi16(F, max), zero); - const __m128i I = _mm_madd_epi16(D, G); // sum(abs(...)) - _mm_storeu_si128((__m128i*)(dst + i), H); - sum = _mm_add_epi32(sum, I); - } - _mm_storeu_si128((__m128i*)tmp, sum); - diff = tmp[3] + tmp[2] + tmp[1] + tmp[0]; - for (; i < len; ++i) { - const int diff_y = ref[i] - src[i]; - const int new_y = (int)dst[i] + diff_y; - dst[i] = clip_y(new_y); - diff += (uint64_t)abs(diff_y); - } - return diff; -} - -static void SharpYUVUpdateRGB_SSE2(const int16_t* ref, const int16_t* src, - int16_t* dst, int len) { - int i = 0; - for (i = 0; i + 8 <= len; i += 8) { - const __m128i A = _mm_loadu_si128((const __m128i*)(ref + i)); - const __m128i B = _mm_loadu_si128((const __m128i*)(src + i)); - const __m128i C = _mm_loadu_si128((const __m128i*)(dst + i)); - const __m128i D = _mm_sub_epi16(A, B); // diff_uv - const __m128i E = _mm_add_epi16(C, D); // new_uv - _mm_storeu_si128((__m128i*)(dst + i), E); - } - for (; i < len; ++i) { - const int diff_uv = ref[i] - src[i]; - dst[i] += diff_uv; - } -} - -static void SharpYUVFilterRow_SSE2(const int16_t* A, const int16_t* B, int len, - const uint16_t* best_y, uint16_t* out) { - int i; - const __m128i kCst8 = _mm_set1_epi16(8); - const __m128i max = _mm_set1_epi16(MAX_Y); - const __m128i zero = _mm_setzero_si128(); - for (i = 0; i + 8 <= len; i += 8) { - const __m128i a0 = _mm_loadu_si128((const __m128i*)(A + i + 0)); - const __m128i a1 = _mm_loadu_si128((const __m128i*)(A + i + 1)); - const __m128i b0 = _mm_loadu_si128((const __m128i*)(B + i + 0)); - const __m128i b1 = _mm_loadu_si128((const __m128i*)(B + i + 1)); - const __m128i a0b1 = _mm_add_epi16(a0, b1); - const __m128i a1b0 = _mm_add_epi16(a1, b0); - const __m128i a0a1b0b1 = _mm_add_epi16(a0b1, a1b0); // A0+A1+B0+B1 - const __m128i a0a1b0b1_8 = _mm_add_epi16(a0a1b0b1, kCst8); - const __m128i a0b1_2 = _mm_add_epi16(a0b1, a0b1); // 2*(A0+B1) - const __m128i a1b0_2 = _mm_add_epi16(a1b0, a1b0); // 2*(A1+B0) - const __m128i c0 = _mm_srai_epi16(_mm_add_epi16(a0b1_2, a0a1b0b1_8), 3); - const __m128i c1 = _mm_srai_epi16(_mm_add_epi16(a1b0_2, a0a1b0b1_8), 3); - const __m128i d0 = _mm_add_epi16(c1, a0); - const __m128i d1 = _mm_add_epi16(c0, a1); - const __m128i e0 = _mm_srai_epi16(d0, 1); - const __m128i e1 = _mm_srai_epi16(d1, 1); - const __m128i f0 = _mm_unpacklo_epi16(e0, e1); - const __m128i f1 = _mm_unpackhi_epi16(e0, e1); - const __m128i g0 = _mm_loadu_si128((const __m128i*)(best_y + 2 * i + 0)); - const __m128i g1 = _mm_loadu_si128((const __m128i*)(best_y + 2 * i + 8)); - const __m128i h0 = _mm_add_epi16(g0, f0); - const __m128i h1 = _mm_add_epi16(g1, f1); - const __m128i i0 = _mm_max_epi16(_mm_min_epi16(h0, max), zero); - const __m128i i1 = _mm_max_epi16(_mm_min_epi16(h1, max), zero); - _mm_storeu_si128((__m128i*)(out + 2 * i + 0), i0); - _mm_storeu_si128((__m128i*)(out + 2 * i + 8), i1); - } - for (; i < len; ++i) { - // (9 * A0 + 3 * A1 + 3 * B0 + B1 + 8) >> 4 = - // = (8 * A0 + 2 * (A1 + B0) + (A0 + A1 + B0 + B1 + 8)) >> 4 - // We reuse the common sub-expressions. - const int a0b1 = A[i + 0] + B[i + 1]; - const int a1b0 = A[i + 1] + B[i + 0]; - const int a0a1b0b1 = a0b1 + a1b0 + 8; - const int v0 = (8 * A[i + 0] + 2 * a1b0 + a0a1b0b1) >> 4; - const int v1 = (8 * A[i + 1] + 2 * a0b1 + a0a1b0b1) >> 4; - out[2 * i + 0] = clip_y(best_y[2 * i + 0] + v0); - out[2 * i + 1] = clip_y(best_y[2 * i + 1] + v1); - } -} - -#undef MAX_Y - -//------------------------------------------------------------------------------ - -extern void WebPInitSharpYUVSSE2(void); - -WEBP_TSAN_IGNORE_FUNCTION void WebPInitSharpYUVSSE2(void) { - WebPSharpYUVUpdateY = SharpYUVUpdateY_SSE2; - WebPSharpYUVUpdateRGB = SharpYUVUpdateRGB_SSE2; - WebPSharpYUVFilterRow = SharpYUVFilterRow_SSE2; -} - #else // !WEBP_USE_SSE2 WEBP_DSP_INIT_STUB(WebPInitSamplersSSE2) WEBP_DSP_INIT_STUB(WebPInitConvertARGBToYUVSSE2) -WEBP_DSP_INIT_STUB(WebPInitSharpYUVSSE2) #endif // WEBP_USE_SSE2 diff --git a/thirdparty/webp/src/enc/alpha_enc.c b/thirdparty/webp/src/enc/alpha_enc.c index 0b54f3e6ec..f7c02690e3 100644 --- a/thirdparty/webp/src/enc/alpha_enc.c +++ b/thirdparty/webp/src/enc/alpha_enc.c @@ -86,7 +86,7 @@ static int EncodeLossless(const uint8_t* const data, int width, int height, // a decoder bug related to alpha with color cache. // See: https://code.google.com/p/webp/issues/detail?id=239 // Need to re-enable this later. - ok = (VP8LEncodeStream(&config, &picture, bw, 0 /*use_cache*/) == VP8_ENC_OK); + ok = VP8LEncodeStream(&config, &picture, bw, /*use_cache=*/0); WebPPictureFree(&picture); ok = ok && !bw->error_; if (!ok) { diff --git a/thirdparty/webp/src/enc/backward_references_cost_enc.c b/thirdparty/webp/src/enc/backward_references_cost_enc.c index 516abd73eb..6968ef3c9f 100644 --- a/thirdparty/webp/src/enc/backward_references_cost_enc.c +++ b/thirdparty/webp/src/enc/backward_references_cost_enc.c @@ -15,10 +15,11 @@ // #include +#include +#include "src/dsp/lossless_common.h" #include "src/enc/backward_references_enc.h" #include "src/enc/histogram_enc.h" -#include "src/dsp/lossless_common.h" #include "src/utils/color_cache_utils.h" #include "src/utils/utils.h" @@ -30,15 +31,15 @@ extern void VP8LBackwardRefsCursorAdd(VP8LBackwardRefs* const refs, const PixOrCopy v); typedef struct { - double alpha_[VALUES_IN_BYTE]; - double red_[VALUES_IN_BYTE]; - double blue_[VALUES_IN_BYTE]; - double distance_[NUM_DISTANCE_CODES]; - double* literal_; + float alpha_[VALUES_IN_BYTE]; + float red_[VALUES_IN_BYTE]; + float blue_[VALUES_IN_BYTE]; + float distance_[NUM_DISTANCE_CODES]; + float* literal_; } CostModel; static void ConvertPopulationCountTableToBitEstimates( - int num_symbols, const uint32_t population_counts[], double output[]) { + int num_symbols, const uint32_t population_counts[], float output[]) { uint32_t sum = 0; int nonzeros = 0; int i; @@ -51,7 +52,7 @@ static void ConvertPopulationCountTableToBitEstimates( if (nonzeros <= 1) { memset(output, 0, num_symbols * sizeof(*output)); } else { - const double logsum = VP8LFastLog2(sum); + const float logsum = VP8LFastLog2(sum); for (i = 0; i < num_symbols; ++i) { output[i] = logsum - VP8LFastLog2(population_counts[i]); } @@ -75,8 +76,8 @@ static int CostModelBuild(CostModel* const m, int xsize, int cache_bits, } ConvertPopulationCountTableToBitEstimates( - VP8LHistogramNumCodes(histo->palette_code_bits_), - histo->literal_, m->literal_); + VP8LHistogramNumCodes(histo->palette_code_bits_), histo->literal_, + m->literal_); ConvertPopulationCountTableToBitEstimates( VALUES_IN_BYTE, histo->red_, m->red_); ConvertPopulationCountTableToBitEstimates( @@ -92,27 +93,27 @@ static int CostModelBuild(CostModel* const m, int xsize, int cache_bits, return ok; } -static WEBP_INLINE double GetLiteralCost(const CostModel* const m, uint32_t v) { +static WEBP_INLINE float GetLiteralCost(const CostModel* const m, uint32_t v) { return m->alpha_[v >> 24] + m->red_[(v >> 16) & 0xff] + m->literal_[(v >> 8) & 0xff] + m->blue_[v & 0xff]; } -static WEBP_INLINE double GetCacheCost(const CostModel* const m, uint32_t idx) { +static WEBP_INLINE float GetCacheCost(const CostModel* const m, uint32_t idx) { const int literal_idx = VALUES_IN_BYTE + NUM_LENGTH_CODES + idx; return m->literal_[literal_idx]; } -static WEBP_INLINE double GetLengthCost(const CostModel* const m, - uint32_t length) { +static WEBP_INLINE float GetLengthCost(const CostModel* const m, + uint32_t length) { int code, extra_bits; VP8LPrefixEncodeBits(length, &code, &extra_bits); return m->literal_[VALUES_IN_BYTE + code] + extra_bits; } -static WEBP_INLINE double GetDistanceCost(const CostModel* const m, - uint32_t distance) { +static WEBP_INLINE float GetDistanceCost(const CostModel* const m, + uint32_t distance) { int code, extra_bits; VP8LPrefixEncodeBits(distance, &code, &extra_bits); return m->distance_[code] + extra_bits; @@ -122,20 +123,20 @@ static WEBP_INLINE void AddSingleLiteralWithCostModel( const uint32_t* const argb, VP8LColorCache* const hashers, const CostModel* const cost_model, int idx, int use_color_cache, float prev_cost, float* const cost, uint16_t* const dist_array) { - double cost_val = prev_cost; + float cost_val = prev_cost; const uint32_t color = argb[idx]; const int ix = use_color_cache ? VP8LColorCacheContains(hashers, color) : -1; if (ix >= 0) { // use_color_cache is true and hashers contains color - const double mul0 = 0.68; + const float mul0 = 0.68f; cost_val += GetCacheCost(cost_model, ix) * mul0; } else { - const double mul1 = 0.82; + const float mul1 = 0.82f; if (use_color_cache) VP8LColorCacheInsert(hashers, color); cost_val += GetLiteralCost(cost_model, color) * mul1; } if (cost[idx] > cost_val) { - cost[idx] = (float)cost_val; + cost[idx] = cost_val; dist_array[idx] = 1; // only one is inserted. } } @@ -172,7 +173,7 @@ struct CostInterval { // The GetLengthCost(cost_model, k) are cached in a CostCacheInterval. typedef struct { - double cost_; + float cost_; int start_; int end_; // Exclusive. } CostCacheInterval; @@ -187,7 +188,7 @@ typedef struct { int count_; // The number of stored intervals. CostCacheInterval* cache_intervals_; size_t cache_intervals_size_; - double cost_cache_[MAX_LENGTH]; // Contains the GetLengthCost(cost_model, k). + float cost_cache_[MAX_LENGTH]; // Contains the GetLengthCost(cost_model, k). float* costs_; uint16_t* dist_array_; // Most of the time, we only need few intervals -> use a free-list, to avoid @@ -262,10 +263,13 @@ static int CostManagerInit(CostManager* const manager, CostManagerInitFreeList(manager); // Fill in the cost_cache_. - manager->cache_intervals_size_ = 1; - manager->cost_cache_[0] = GetLengthCost(cost_model, 0); - for (i = 1; i < cost_cache_size; ++i) { + // Has to be done in two passes due to a GCC bug on i686 + // related to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=323 + for (i = 0; i < cost_cache_size; ++i) { manager->cost_cache_[i] = GetLengthCost(cost_model, i); + } + manager->cache_intervals_size_ = 1; + for (i = 1; i < cost_cache_size; ++i) { // Get the number of bound intervals. if (manager->cost_cache_[i] != manager->cost_cache_[i - 1]) { ++manager->cache_intervals_size_; @@ -294,7 +298,7 @@ static int CostManagerInit(CostManager* const manager, cur->end_ = 1; cur->cost_ = manager->cost_cache_[0]; for (i = 1; i < cost_cache_size; ++i) { - const double cost_val = manager->cost_cache_[i]; + const float cost_val = manager->cost_cache_[i]; if (cost_val != cur->cost_) { ++cur; // Initialize an interval. @@ -303,6 +307,8 @@ static int CostManagerInit(CostManager* const manager, } cur->end_ = i + 1; } + assert((size_t)(cur - manager->cache_intervals_) + 1 == + manager->cache_intervals_size_); } manager->costs_ = (float*)WebPSafeMalloc(pix_count, sizeof(*manager->costs_)); @@ -311,7 +317,7 @@ static int CostManagerInit(CostManager* const manager, return 0; } // Set the initial costs_ high for every pixel as we will keep the minimum. - for (i = 0; i < pix_count; ++i) manager->costs_[i] = 1e38f; + for (i = 0; i < pix_count; ++i) manager->costs_[i] = FLT_MAX; return 1; } @@ -457,7 +463,7 @@ static WEBP_INLINE void InsertInterval(CostManager* const manager, // If handling the interval or one of its subintervals becomes to heavy, its // contribution is added to the costs right away. static WEBP_INLINE void PushInterval(CostManager* const manager, - double distance_cost, int position, + float distance_cost, int position, int len) { size_t i; CostInterval* interval = manager->head_; @@ -474,7 +480,7 @@ static WEBP_INLINE void PushInterval(CostManager* const manager, const int k = j - position; float cost_tmp; assert(k >= 0 && k < MAX_LENGTH); - cost_tmp = (float)(distance_cost + manager->cost_cache_[k]); + cost_tmp = distance_cost + manager->cost_cache_[k]; if (manager->costs_[j] > cost_tmp) { manager->costs_[j] = cost_tmp; @@ -492,7 +498,7 @@ static WEBP_INLINE void PushInterval(CostManager* const manager, const int end = position + (cost_cache_intervals[i].end_ > len ? len : cost_cache_intervals[i].end_); - const float cost = (float)(distance_cost + cost_cache_intervals[i].cost_); + const float cost = distance_cost + cost_cache_intervals[i].cost_; for (; interval != NULL && interval->start_ < end; interval = interval_next) { @@ -570,22 +576,21 @@ static int BackwardReferencesHashChainDistanceOnly( const int pix_count = xsize * ysize; const int use_color_cache = (cache_bits > 0); const size_t literal_array_size = - sizeof(double) * (NUM_LITERAL_CODES + NUM_LENGTH_CODES + - ((cache_bits > 0) ? (1 << cache_bits) : 0)); + sizeof(float) * (VP8LHistogramNumCodes(cache_bits)); const size_t cost_model_size = sizeof(CostModel) + literal_array_size; CostModel* const cost_model = (CostModel*)WebPSafeCalloc(1ULL, cost_model_size); VP8LColorCache hashers; CostManager* cost_manager = - (CostManager*)WebPSafeMalloc(1ULL, sizeof(*cost_manager)); + (CostManager*)WebPSafeCalloc(1ULL, sizeof(*cost_manager)); int offset_prev = -1, len_prev = -1; - double offset_cost = -1; + float offset_cost = -1.f; int first_offset_is_constant = -1; // initialized with 'impossible' value int reach = 0; if (cost_model == NULL || cost_manager == NULL) goto Error; - cost_model->literal_ = (double*)(cost_model + 1); + cost_model->literal_ = (float*)(cost_model + 1); if (use_color_cache) { cc_init = VP8LColorCacheInit(&hashers, cache_bits); if (!cc_init) goto Error; @@ -675,7 +680,7 @@ static int BackwardReferencesHashChainDistanceOnly( } ok = !refs->error_; -Error: + Error: if (cc_init) VP8LColorCacheClear(&hashers); CostManagerClear(cost_manager); WebPSafeFree(cost_model); diff --git a/thirdparty/webp/src/enc/backward_references_enc.c b/thirdparty/webp/src/enc/backward_references_enc.c index 519b36a091..49a0fac034 100644 --- a/thirdparty/webp/src/enc/backward_references_enc.c +++ b/thirdparty/webp/src/enc/backward_references_enc.c @@ -10,6 +10,8 @@ // Author: Jyrki Alakuijala (jyrki@google.com) // +#include "src/enc/backward_references_enc.h" + #include #include #include @@ -17,10 +19,11 @@ #include "src/dsp/dsp.h" #include "src/dsp/lossless.h" #include "src/dsp/lossless_common.h" -#include "src/enc/backward_references_enc.h" #include "src/enc/histogram_enc.h" +#include "src/enc/vp8i_enc.h" #include "src/utils/color_cache_utils.h" #include "src/utils/utils.h" +#include "src/webp/encode.h" #define MIN_BLOCK_SIZE 256 // minimum block size for backward references @@ -255,10 +258,13 @@ static WEBP_INLINE int MaxFindCopyLength(int len) { int VP8LHashChainFill(VP8LHashChain* const p, int quality, const uint32_t* const argb, int xsize, int ysize, - int low_effort) { + int low_effort, const WebPPicture* const pic, + int percent_range, int* const percent) { const int size = xsize * ysize; const int iter_max = GetMaxItersForQuality(quality); const uint32_t window_size = GetWindowSizeForHashChain(quality, xsize); + int remaining_percent = percent_range; + int percent_start = *percent; int pos; int argb_comp; uint32_t base_position; @@ -276,7 +282,13 @@ int VP8LHashChainFill(VP8LHashChain* const p, int quality, hash_to_first_index = (int32_t*)WebPSafeMalloc(HASH_SIZE, sizeof(*hash_to_first_index)); - if (hash_to_first_index == NULL) return 0; + if (hash_to_first_index == NULL) { + WebPEncodingSetError(pic, VP8_ENC_ERROR_OUT_OF_MEMORY); + return 0; + } + + percent_range = remaining_percent / 2; + remaining_percent -= percent_range; // Set the int32_t array to -1. memset(hash_to_first_index, 0xff, HASH_SIZE * sizeof(*hash_to_first_index)); @@ -323,12 +335,22 @@ int VP8LHashChainFill(VP8LHashChain* const p, int quality, hash_to_first_index[hash_code] = pos++; argb_comp = argb_comp_next; } + + if (!WebPReportProgress( + pic, percent_start + percent_range * pos / (size - 2), percent)) { + WebPSafeFree(hash_to_first_index); + return 0; + } } // Process the penultimate pixel. chain[pos] = hash_to_first_index[GetPixPairHash64(argb + pos)]; WebPSafeFree(hash_to_first_index); + percent_start += percent_range; + if (!WebPReportProgress(pic, percent_start, percent)) return 0; + percent_range = remaining_percent; + // Find the best match interval at each pixel, defined by an offset to the // pixel and a length. The right-most pixel cannot match anything to the right // (hence a best length of 0) and the left-most pixel nothing to the left @@ -417,8 +439,17 @@ int VP8LHashChainFill(VP8LHashChain* const p, int quality, max_base_position = base_position; } } + + if (!WebPReportProgress(pic, + percent_start + percent_range * + (size - 2 - base_position) / + (size - 2), + percent)) { + return 0; + } } - return 1; + + return WebPReportProgress(pic, percent_start + percent_range, percent); } static WEBP_INLINE void AddSingleLiteral(uint32_t pixel, int use_color_cache, @@ -728,7 +759,7 @@ static int CalculateBestCacheSize(const uint32_t* argb, int quality, int* const best_cache_bits) { int i; const int cache_bits_max = (quality <= 25) ? 0 : *best_cache_bits; - double entropy_min = MAX_ENTROPY; + float entropy_min = MAX_ENTROPY; int cc_init[MAX_COLOR_CACHE_BITS + 1] = { 0 }; VP8LColorCache hashers[MAX_COLOR_CACHE_BITS + 1]; VP8LRefsCursor c = VP8LRefsCursorInit(refs); @@ -813,14 +844,14 @@ static int CalculateBestCacheSize(const uint32_t* argb, int quality, } for (i = 0; i <= cache_bits_max; ++i) { - const double entropy = VP8LHistogramEstimateBits(histos[i]); + const float entropy = VP8LHistogramEstimateBits(histos[i]); if (i == 0 || entropy < entropy_min) { entropy_min = entropy; *best_cache_bits = i; } } ok = 1; -Error: + Error: for (i = 0; i <= cache_bits_max; ++i) { if (cc_init[i]) VP8LColorCacheClear(&hashers[i]); VP8LFreeHistogram(histos[i]); @@ -890,7 +921,7 @@ static int GetBackwardReferences(int width, int height, int i, lz77_type; // Index 0 is for a color cache, index 1 for no cache (if needed). int lz77_types_best[2] = {0, 0}; - double bit_costs_best[2] = {DBL_MAX, DBL_MAX}; + float bit_costs_best[2] = {FLT_MAX, FLT_MAX}; VP8LHashChain hash_chain_box; VP8LBackwardRefs* const refs_tmp = &refs[do_no_cache ? 2 : 1]; int status = 0; @@ -902,7 +933,7 @@ static int GetBackwardReferences(int width, int height, for (lz77_type = 1; lz77_types_to_try; lz77_types_to_try &= ~lz77_type, lz77_type <<= 1) { int res = 0; - double bit_cost = 0.; + float bit_cost = 0.f; if ((lz77_types_to_try & lz77_type) == 0) continue; switch (lz77_type) { case kLZ77RLE: @@ -976,15 +1007,16 @@ static int GetBackwardReferences(int width, int height, const VP8LHashChain* const hash_chain_tmp = (lz77_types_best[i] == kLZ77Standard) ? hash_chain : &hash_chain_box; const int cache_bits = (i == 1) ? 0 : *cache_bits_best; - if (VP8LBackwardReferencesTraceBackwards(width, height, argb, cache_bits, - hash_chain_tmp, &refs[i], - refs_tmp)) { - double bit_cost_trace; - VP8LHistogramCreate(histo, refs_tmp, cache_bits); - bit_cost_trace = VP8LHistogramEstimateBits(histo); - if (bit_cost_trace < bit_costs_best[i]) { - BackwardRefsSwap(refs_tmp, &refs[i]); - } + float bit_cost_trace; + if (!VP8LBackwardReferencesTraceBackwards(width, height, argb, cache_bits, + hash_chain_tmp, &refs[i], + refs_tmp)) { + goto Error; + } + VP8LHistogramCreate(histo, refs_tmp, cache_bits); + bit_cost_trace = VP8LHistogramEstimateBits(histo); + if (bit_cost_trace < bit_costs_best[i]) { + BackwardRefsSwap(refs_tmp, &refs[i]); } } @@ -1000,31 +1032,37 @@ static int GetBackwardReferences(int width, int height, } status = 1; -Error: + Error: VP8LHashChainClear(&hash_chain_box); VP8LFreeHistogram(histo); return status; } -WebPEncodingError VP8LGetBackwardReferences( +int VP8LGetBackwardReferences( int width, int height, const uint32_t* const argb, int quality, int low_effort, int lz77_types_to_try, int cache_bits_max, int do_no_cache, const VP8LHashChain* const hash_chain, VP8LBackwardRefs* const refs, - int* const cache_bits_best) { + int* const cache_bits_best, const WebPPicture* const pic, int percent_range, + int* const percent) { if (low_effort) { VP8LBackwardRefs* refs_best; *cache_bits_best = cache_bits_max; refs_best = GetBackwardReferencesLowEffort( width, height, argb, cache_bits_best, hash_chain, refs); - if (refs_best == NULL) return VP8_ENC_ERROR_OUT_OF_MEMORY; + if (refs_best == NULL) { + WebPEncodingSetError(pic, VP8_ENC_ERROR_OUT_OF_MEMORY); + return 0; + } // Set it in first position. BackwardRefsSwap(refs_best, &refs[0]); } else { if (!GetBackwardReferences(width, height, argb, quality, lz77_types_to_try, cache_bits_max, do_no_cache, hash_chain, refs, cache_bits_best)) { - return VP8_ENC_ERROR_OUT_OF_MEMORY; + WebPEncodingSetError(pic, VP8_ENC_ERROR_OUT_OF_MEMORY); + return 0; } } - return VP8_ENC_OK; + + return WebPReportProgress(pic, *percent + percent_range, percent); } diff --git a/thirdparty/webp/src/enc/backward_references_enc.h b/thirdparty/webp/src/enc/backward_references_enc.h index 4c0267b41e..4dff1c27b5 100644 --- a/thirdparty/webp/src/enc/backward_references_enc.h +++ b/thirdparty/webp/src/enc/backward_references_enc.h @@ -134,10 +134,11 @@ struct VP8LHashChain { // Must be called first, to set size. int VP8LHashChainInit(VP8LHashChain* const p, int size); -// Pre-compute the best matches for argb. +// Pre-compute the best matches for argb. pic and percent are for progress. int VP8LHashChainFill(VP8LHashChain* const p, int quality, const uint32_t* const argb, int xsize, int ysize, - int low_effort); + int low_effort, const WebPPicture* const pic, + int percent_range, int* const percent); void VP8LHashChainClear(VP8LHashChain* const p); // release memory static WEBP_INLINE int VP8LHashChainFindOffset(const VP8LHashChain* const p, @@ -227,11 +228,14 @@ enum VP8LLZ77Type { // VP8LBackwardRefs is put in the first element, the best value with no-cache in // the second element. // In both cases, the last element is used as temporary internally. -WebPEncodingError VP8LGetBackwardReferences( +// pic and percent are for progress. +// Returns false in case of error (stored in pic->error_code). +int VP8LGetBackwardReferences( int width, int height, const uint32_t* const argb, int quality, int low_effort, int lz77_types_to_try, int cache_bits_max, int do_no_cache, const VP8LHashChain* const hash_chain, VP8LBackwardRefs* const refs, - int* const cache_bits_best); + int* const cache_bits_best, const WebPPicture* const pic, int percent_range, + int* const percent); #ifdef __cplusplus } diff --git a/thirdparty/webp/src/enc/histogram_enc.c b/thirdparty/webp/src/enc/histogram_enc.c index 38a0cebcab..8418def2e1 100644 --- a/thirdparty/webp/src/enc/histogram_enc.c +++ b/thirdparty/webp/src/enc/histogram_enc.c @@ -13,15 +13,17 @@ #include "src/webp/config.h" #endif +#include #include -#include "src/enc/backward_references_enc.h" -#include "src/enc/histogram_enc.h" #include "src/dsp/lossless.h" #include "src/dsp/lossless_common.h" +#include "src/enc/backward_references_enc.h" +#include "src/enc/histogram_enc.h" +#include "src/enc/vp8i_enc.h" #include "src/utils/utils.h" -#define MAX_COST 1.e38 +#define MAX_BIT_COST FLT_MAX // Number of partitions for the three dominant (literal, red and blue) symbol // costs. @@ -228,8 +230,8 @@ void VP8LHistogramAddSinglePixOrCopy(VP8LHistogram* const histo, // ----------------------------------------------------------------------------- // Entropy-related functions. -static WEBP_INLINE double BitsEntropyRefine(const VP8LBitEntropy* entropy) { - double mix; +static WEBP_INLINE float BitsEntropyRefine(const VP8LBitEntropy* entropy) { + float mix; if (entropy->nonzeros < 5) { if (entropy->nonzeros <= 1) { return 0; @@ -238,67 +240,67 @@ static WEBP_INLINE double BitsEntropyRefine(const VP8LBitEntropy* entropy) { // Let's mix in a bit of entropy to favor good clustering when // distributions of these are combined. if (entropy->nonzeros == 2) { - return 0.99 * entropy->sum + 0.01 * entropy->entropy; + return 0.99f * entropy->sum + 0.01f * entropy->entropy; } // No matter what the entropy says, we cannot be better than min_limit // with Huffman coding. I am mixing a bit of entropy into the // min_limit since it produces much better (~0.5 %) compression results // perhaps because of better entropy clustering. if (entropy->nonzeros == 3) { - mix = 0.95; + mix = 0.95f; } else { - mix = 0.7; // nonzeros == 4. + mix = 0.7f; // nonzeros == 4. } } else { - mix = 0.627; + mix = 0.627f; } { - double min_limit = 2 * entropy->sum - entropy->max_val; - min_limit = mix * min_limit + (1.0 - mix) * entropy->entropy; + float min_limit = 2.f * entropy->sum - entropy->max_val; + min_limit = mix * min_limit + (1.f - mix) * entropy->entropy; return (entropy->entropy < min_limit) ? min_limit : entropy->entropy; } } -double VP8LBitsEntropy(const uint32_t* const array, int n) { +float VP8LBitsEntropy(const uint32_t* const array, int n) { VP8LBitEntropy entropy; VP8LBitsEntropyUnrefined(array, n, &entropy); return BitsEntropyRefine(&entropy); } -static double InitialHuffmanCost(void) { +static float InitialHuffmanCost(void) { // Small bias because Huffman code length is typically not stored in // full length. static const int kHuffmanCodeOfHuffmanCodeSize = CODE_LENGTH_CODES * 3; - static const double kSmallBias = 9.1; + static const float kSmallBias = 9.1f; return kHuffmanCodeOfHuffmanCodeSize - kSmallBias; } // Finalize the Huffman cost based on streak numbers and length type (<3 or >=3) -static double FinalHuffmanCost(const VP8LStreaks* const stats) { +static float FinalHuffmanCost(const VP8LStreaks* const stats) { // The constants in this function are experimental and got rounded from // their original values in 1/8 when switched to 1/1024. - double retval = InitialHuffmanCost(); + float retval = InitialHuffmanCost(); // Second coefficient: Many zeros in the histogram are covered efficiently // by a run-length encode. Originally 2/8. - retval += stats->counts[0] * 1.5625 + 0.234375 * stats->streaks[0][1]; + retval += stats->counts[0] * 1.5625f + 0.234375f * stats->streaks[0][1]; // Second coefficient: Constant values are encoded less efficiently, but still // RLE'ed. Originally 6/8. - retval += stats->counts[1] * 2.578125 + 0.703125 * stats->streaks[1][1]; + retval += stats->counts[1] * 2.578125f + 0.703125f * stats->streaks[1][1]; // 0s are usually encoded more efficiently than non-0s. // Originally 15/8. - retval += 1.796875 * stats->streaks[0][0]; + retval += 1.796875f * stats->streaks[0][0]; // Originally 26/8. - retval += 3.28125 * stats->streaks[1][0]; + retval += 3.28125f * stats->streaks[1][0]; return retval; } // Get the symbol entropy for the distribution 'population'. // Set 'trivial_sym', if there's only one symbol present in the distribution. -static double PopulationCost(const uint32_t* const population, int length, - uint32_t* const trivial_sym, - uint8_t* const is_used) { +static float PopulationCost(const uint32_t* const population, int length, + uint32_t* const trivial_sym, + uint8_t* const is_used) { VP8LBitEntropy bit_entropy; VP8LStreaks stats; VP8LGetEntropyUnrefined(population, length, &bit_entropy, &stats); @@ -314,11 +316,10 @@ static double PopulationCost(const uint32_t* const population, int length, // trivial_at_end is 1 if the two histograms only have one element that is // non-zero: both the zero-th one, or both the last one. -static WEBP_INLINE double GetCombinedEntropy(const uint32_t* const X, - const uint32_t* const Y, - int length, int is_X_used, - int is_Y_used, - int trivial_at_end) { +static WEBP_INLINE float GetCombinedEntropy(const uint32_t* const X, + const uint32_t* const Y, int length, + int is_X_used, int is_Y_used, + int trivial_at_end) { VP8LStreaks stats; if (trivial_at_end) { // This configuration is due to palettization that transforms an indexed @@ -356,7 +357,7 @@ static WEBP_INLINE double GetCombinedEntropy(const uint32_t* const X, } // Estimates the Entropy + Huffman + other block overhead size cost. -double VP8LHistogramEstimateBits(VP8LHistogram* const p) { +float VP8LHistogramEstimateBits(VP8LHistogram* const p) { return PopulationCost(p->literal_, VP8LHistogramNumCodes(p->palette_code_bits_), NULL, &p->is_used_[0]) @@ -373,8 +374,7 @@ double VP8LHistogramEstimateBits(VP8LHistogram* const p) { static int GetCombinedHistogramEntropy(const VP8LHistogram* const a, const VP8LHistogram* const b, - double cost_threshold, - double* cost) { + float cost_threshold, float* cost) { const int palette_code_bits = a->palette_code_bits_; int trivial_at_end = 0; assert(a->palette_code_bits_ == b->palette_code_bits_); @@ -439,12 +439,11 @@ static WEBP_INLINE void HistogramAdd(const VP8LHistogram* const a, // Since the previous score passed is 'cost_threshold', we only need to compare // the partial cost against 'cost_threshold + C(a) + C(b)' to possibly bail-out // early. -static double HistogramAddEval(const VP8LHistogram* const a, - const VP8LHistogram* const b, - VP8LHistogram* const out, - double cost_threshold) { - double cost = 0; - const double sum_cost = a->bit_cost_ + b->bit_cost_; +static float HistogramAddEval(const VP8LHistogram* const a, + const VP8LHistogram* const b, + VP8LHistogram* const out, float cost_threshold) { + float cost = 0; + const float sum_cost = a->bit_cost_ + b->bit_cost_; cost_threshold += sum_cost; if (GetCombinedHistogramEntropy(a, b, cost_threshold, &cost)) { @@ -459,10 +458,10 @@ static double HistogramAddEval(const VP8LHistogram* const a, // Same as HistogramAddEval(), except that the resulting histogram // is not stored. Only the cost C(a+b) - C(a) is evaluated. We omit // the term C(b) which is constant over all the evaluations. -static double HistogramAddThresh(const VP8LHistogram* const a, - const VP8LHistogram* const b, - double cost_threshold) { - double cost; +static float HistogramAddThresh(const VP8LHistogram* const a, + const VP8LHistogram* const b, + float cost_threshold) { + float cost; assert(a != NULL && b != NULL); cost = -a->bit_cost_; GetCombinedHistogramEntropy(a, b, cost_threshold, &cost); @@ -473,24 +472,22 @@ static double HistogramAddThresh(const VP8LHistogram* const a, // The structure to keep track of cost range for the three dominant entropy // symbols. -// TODO(skal): Evaluate if float can be used here instead of double for -// representing the entropy costs. typedef struct { - double literal_max_; - double literal_min_; - double red_max_; - double red_min_; - double blue_max_; - double blue_min_; + float literal_max_; + float literal_min_; + float red_max_; + float red_min_; + float blue_max_; + float blue_min_; } DominantCostRange; static void DominantCostRangeInit(DominantCostRange* const c) { c->literal_max_ = 0.; - c->literal_min_ = MAX_COST; + c->literal_min_ = MAX_BIT_COST; c->red_max_ = 0.; - c->red_min_ = MAX_COST; + c->red_min_ = MAX_BIT_COST; c->blue_max_ = 0.; - c->blue_min_ = MAX_COST; + c->blue_min_ = MAX_BIT_COST; } static void UpdateDominantCostRange( @@ -505,10 +502,9 @@ static void UpdateDominantCostRange( static void UpdateHistogramCost(VP8LHistogram* const h) { uint32_t alpha_sym, red_sym, blue_sym; - const double alpha_cost = - PopulationCost(h->alpha_, NUM_LITERAL_CODES, &alpha_sym, - &h->is_used_[3]); - const double distance_cost = + const float alpha_cost = + PopulationCost(h->alpha_, NUM_LITERAL_CODES, &alpha_sym, &h->is_used_[3]); + const float distance_cost = PopulationCost(h->distance_, NUM_DISTANCE_CODES, NULL, &h->is_used_[4]) + VP8LExtraCost(h->distance_, NUM_DISTANCE_CODES); const int num_codes = VP8LHistogramNumCodes(h->palette_code_bits_); @@ -529,10 +525,10 @@ static void UpdateHistogramCost(VP8LHistogram* const h) { } } -static int GetBinIdForEntropy(double min, double max, double val) { - const double range = max - min; +static int GetBinIdForEntropy(float min, float max, float val) { + const float range = max - min; if (range > 0.) { - const double delta = val - min; + const float delta = val - min; return (int)((NUM_PARTITIONS - 1e-6) * delta / range); } else { return 0; @@ -641,15 +637,11 @@ static void HistogramAnalyzeEntropyBin(VP8LHistogramSet* const image_histo, // Merges some histograms with same bin_id together if it's advantageous. // Sets the remaining histograms to NULL. -static void HistogramCombineEntropyBin(VP8LHistogramSet* const image_histo, - int* num_used, - const uint16_t* const clusters, - uint16_t* const cluster_mappings, - VP8LHistogram* cur_combo, - const uint16_t* const bin_map, - int num_bins, - double combine_cost_factor, - int low_effort) { +static void HistogramCombineEntropyBin( + VP8LHistogramSet* const image_histo, int* num_used, + const uint16_t* const clusters, uint16_t* const cluster_mappings, + VP8LHistogram* cur_combo, const uint16_t* const bin_map, int num_bins, + float combine_cost_factor, int low_effort) { VP8LHistogram** const histograms = image_histo->histograms; int idx; struct { @@ -679,11 +671,10 @@ static void HistogramCombineEntropyBin(VP8LHistogramSet* const image_histo, cluster_mappings[clusters[idx]] = clusters[first]; } else { // try to merge #idx into #first (both share the same bin_id) - const double bit_cost = histograms[idx]->bit_cost_; - const double bit_cost_thresh = -bit_cost * combine_cost_factor; - const double curr_cost_diff = - HistogramAddEval(histograms[first], histograms[idx], - cur_combo, bit_cost_thresh); + const float bit_cost = histograms[idx]->bit_cost_; + const float bit_cost_thresh = -bit_cost * combine_cost_factor; + const float curr_cost_diff = HistogramAddEval( + histograms[first], histograms[idx], cur_combo, bit_cost_thresh); if (curr_cost_diff < bit_cost_thresh) { // Try to merge two histograms only if the combo is a trivial one or // the two candidate histograms are already non-trivial. @@ -731,8 +722,8 @@ static uint32_t MyRand(uint32_t* const seed) { typedef struct { int idx1; int idx2; - double cost_diff; - double cost_combo; + float cost_diff; + float cost_combo; } HistogramPair; typedef struct { @@ -787,10 +778,9 @@ static void HistoQueueUpdateHead(HistoQueue* const histo_queue, // Update the cost diff and combo of a pair of histograms. This needs to be // called when the the histograms have been merged with a third one. static void HistoQueueUpdatePair(const VP8LHistogram* const h1, - const VP8LHistogram* const h2, - double threshold, + const VP8LHistogram* const h2, float threshold, HistogramPair* const pair) { - const double sum_cost = h1->bit_cost_ + h2->bit_cost_; + const float sum_cost = h1->bit_cost_ + h2->bit_cost_; pair->cost_combo = 0.; GetCombinedHistogramEntropy(h1, h2, sum_cost + threshold, &pair->cost_combo); pair->cost_diff = pair->cost_combo - sum_cost; @@ -799,9 +789,9 @@ static void HistoQueueUpdatePair(const VP8LHistogram* const h1, // Create a pair from indices "idx1" and "idx2" provided its cost // is inferior to "threshold", a negative entropy. // It returns the cost of the pair, or 0. if it superior to threshold. -static double HistoQueuePush(HistoQueue* const histo_queue, - VP8LHistogram** const histograms, int idx1, - int idx2, double threshold) { +static float HistoQueuePush(HistoQueue* const histo_queue, + VP8LHistogram** const histograms, int idx1, + int idx2, float threshold) { const VP8LHistogram* h1; const VP8LHistogram* h2; HistogramPair pair; @@ -945,8 +935,8 @@ static int HistogramCombineStochastic(VP8LHistogramSet* const image_histo, ++tries_with_no_success < num_tries_no_success; ++iter) { int* mapping_index; - double best_cost = - (histo_queue.size == 0) ? 0. : histo_queue.queue[0].cost_diff; + float best_cost = + (histo_queue.size == 0) ? 0.f : histo_queue.queue[0].cost_diff; int best_idx1 = -1, best_idx2 = 1; const uint32_t rand_range = (*num_used - 1) * (*num_used); // (*num_used) / 2 was chosen empirically. Less means faster but worse @@ -955,7 +945,7 @@ static int HistogramCombineStochastic(VP8LHistogramSet* const image_histo, // Pick random samples. for (j = 0; *num_used >= 2 && j < num_tries; ++j) { - double curr_cost; + float curr_cost; // Choose two different histograms at random and try to combine them. const uint32_t tmp = MyRand(&seed) % rand_range; uint32_t idx1 = tmp / (*num_used - 1); @@ -1034,7 +1024,7 @@ static int HistogramCombineStochastic(VP8LHistogramSet* const image_histo, *do_greedy = (*num_used <= min_cluster_size); ok = 1; -End: + End: HistoQueueClear(&histo_queue); WebPSafeFree(mappings); return ok; @@ -1057,7 +1047,7 @@ static void HistogramRemap(const VP8LHistogramSet* const in, if (out_size > 1) { for (i = 0; i < in_size; ++i) { int best_out = 0; - double best_bits = MAX_COST; + float best_bits = MAX_BIT_COST; int k; if (in_histo[i] == NULL) { // Arbitrarily set to the previous value if unused to help future LZ77. @@ -1065,7 +1055,7 @@ static void HistogramRemap(const VP8LHistogramSet* const in, continue; } for (k = 0; k < out_size; ++k) { - double cur_bits; + float cur_bits; cur_bits = HistogramAddThresh(out_histo[k], in_histo[i], best_bits); if (k == 0 || cur_bits < best_bits) { best_bits = cur_bits; @@ -1093,13 +1083,13 @@ static void HistogramRemap(const VP8LHistogramSet* const in, } } -static double GetCombineCostFactor(int histo_size, int quality) { - double combine_cost_factor = 0.16; +static float GetCombineCostFactor(int histo_size, int quality) { + float combine_cost_factor = 0.16f; if (quality < 90) { - if (histo_size > 256) combine_cost_factor /= 2.; - if (histo_size > 512) combine_cost_factor /= 2.; - if (histo_size > 1024) combine_cost_factor /= 2.; - if (quality <= 50) combine_cost_factor /= 2.; + if (histo_size > 256) combine_cost_factor /= 2.f; + if (histo_size > 512) combine_cost_factor /= 2.f; + if (histo_size > 1024) combine_cost_factor /= 2.f; + if (quality <= 50) combine_cost_factor /= 2.f; } return combine_cost_factor; } @@ -1169,13 +1159,13 @@ static void RemoveEmptyHistograms(VP8LHistogramSet* const image_histo) { } int VP8LGetHistoImageSymbols(int xsize, int ysize, - const VP8LBackwardRefs* const refs, - int quality, int low_effort, - int histogram_bits, int cache_bits, + const VP8LBackwardRefs* const refs, int quality, + int low_effort, int histogram_bits, int cache_bits, VP8LHistogramSet* const image_histo, VP8LHistogram* const tmp_histo, - uint16_t* const histogram_symbols) { - int ok = 0; + uint16_t* const histogram_symbols, + const WebPPicture* const pic, int percent_range, + int* const percent) { const int histo_xsize = histogram_bits ? VP8LSubSampleSize(xsize, histogram_bits) : 1; const int histo_ysize = @@ -1192,7 +1182,10 @@ int VP8LGetHistoImageSymbols(int xsize, int ysize, WebPSafeMalloc(2 * image_histo_raw_size, sizeof(map_tmp)); uint16_t* const cluster_mappings = map_tmp + image_histo_raw_size; int num_used = image_histo_raw_size; - if (orig_histo == NULL || map_tmp == NULL) goto Error; + if (orig_histo == NULL || map_tmp == NULL) { + WebPEncodingSetError(pic, VP8_ENC_ERROR_OUT_OF_MEMORY); + goto Error; + } // Construct the histograms from backward references. HistogramBuild(xsize, histogram_bits, refs, orig_histo); @@ -1206,16 +1199,15 @@ int VP8LGetHistoImageSymbols(int xsize, int ysize, if (entropy_combine) { uint16_t* const bin_map = map_tmp; - const double combine_cost_factor = + const float combine_cost_factor = GetCombineCostFactor(image_histo_raw_size, quality); const uint32_t num_clusters = num_used; HistogramAnalyzeEntropyBin(image_histo, bin_map, low_effort); // Collapse histograms with similar entropy. - HistogramCombineEntropyBin(image_histo, &num_used, histogram_symbols, - cluster_mappings, tmp_histo, bin_map, - entropy_combine_num_bins, combine_cost_factor, - low_effort); + HistogramCombineEntropyBin( + image_histo, &num_used, histogram_symbols, cluster_mappings, tmp_histo, + bin_map, entropy_combine_num_bins, combine_cost_factor, low_effort); OptimizeHistogramSymbols(image_histo, cluster_mappings, num_clusters, map_tmp, histogram_symbols); } @@ -1229,11 +1221,13 @@ int VP8LGetHistoImageSymbols(int xsize, int ysize, int do_greedy; if (!HistogramCombineStochastic(image_histo, &num_used, threshold_size, &do_greedy)) { + WebPEncodingSetError(pic, VP8_ENC_ERROR_OUT_OF_MEMORY); goto Error; } if (do_greedy) { RemoveEmptyHistograms(image_histo); if (!HistogramCombineGreedy(image_histo, &num_used)) { + WebPEncodingSetError(pic, VP8_ENC_ERROR_OUT_OF_MEMORY); goto Error; } } @@ -1243,10 +1237,12 @@ int VP8LGetHistoImageSymbols(int xsize, int ysize, RemoveEmptyHistograms(image_histo); HistogramRemap(orig_histo, image_histo, histogram_symbols); - ok = 1; + if (!WebPReportProgress(pic, *percent + percent_range, percent)) { + goto Error; + } Error: VP8LFreeHistogramSet(orig_histo); WebPSafeFree(map_tmp); - return ok; + return (pic->error_code == VP8_ENC_OK); } diff --git a/thirdparty/webp/src/enc/histogram_enc.h b/thirdparty/webp/src/enc/histogram_enc.h index c3428b5d55..4c0bb97464 100644 --- a/thirdparty/webp/src/enc/histogram_enc.h +++ b/thirdparty/webp/src/enc/histogram_enc.h @@ -40,10 +40,10 @@ typedef struct { int palette_code_bits_; uint32_t trivial_symbol_; // True, if histograms for Red, Blue & Alpha // literal symbols are single valued. - double bit_cost_; // cached value of bit cost. - double literal_cost_; // Cached values of dominant entropy costs: - double red_cost_; // literal, red & blue. - double blue_cost_; + float bit_cost_; // cached value of bit cost. + float literal_cost_; // Cached values of dominant entropy costs: + float red_cost_; // literal, red & blue. + float blue_cost_; uint8_t is_used_[5]; // 5 for literal, red, blue, alpha, distance } VP8LHistogram; @@ -105,21 +105,23 @@ static WEBP_INLINE int VP8LHistogramNumCodes(int palette_code_bits) { ((palette_code_bits > 0) ? (1 << palette_code_bits) : 0); } -// Builds the histogram image. +// Builds the histogram image. pic and percent are for progress. +// Returns false in case of error (stored in pic->error_code). int VP8LGetHistoImageSymbols(int xsize, int ysize, - const VP8LBackwardRefs* const refs, - int quality, int low_effort, - int histogram_bits, int cache_bits, + const VP8LBackwardRefs* const refs, int quality, + int low_effort, int histogram_bits, int cache_bits, VP8LHistogramSet* const image_histo, VP8LHistogram* const tmp_histo, - uint16_t* const histogram_symbols); + uint16_t* const histogram_symbols, + const WebPPicture* const pic, int percent_range, + int* const percent); // Returns the entropy for the symbols in the input array. -double VP8LBitsEntropy(const uint32_t* const array, int n); +float VP8LBitsEntropy(const uint32_t* const array, int n); // Estimate how many bits the combined entropy of literals and distance // approximately maps to. -double VP8LHistogramEstimateBits(VP8LHistogram* const p); +float VP8LHistogramEstimateBits(VP8LHistogram* const p); #ifdef __cplusplus } diff --git a/thirdparty/webp/src/enc/picture_csp_enc.c b/thirdparty/webp/src/enc/picture_csp_enc.c index 35eede9635..fabebcf202 100644 --- a/thirdparty/webp/src/enc/picture_csp_enc.c +++ b/thirdparty/webp/src/enc/picture_csp_enc.c @@ -15,12 +15,19 @@ #include #include +#include "sharpyuv/sharpyuv.h" +#include "sharpyuv/sharpyuv_csp.h" #include "src/enc/vp8i_enc.h" #include "src/utils/random_utils.h" #include "src/utils/utils.h" #include "src/dsp/dsp.h" #include "src/dsp/lossless.h" #include "src/dsp/yuv.h" +#include "src/dsp/cpu.h" + +#if defined(WEBP_USE_THREAD) && !defined(_WIN32) +#include +#endif // Uncomment to disable gamma-compression during RGB->U/V averaging #define USE_GAMMA_COMPRESSION @@ -76,16 +83,16 @@ int WebPPictureHasTransparency(const WebPPicture* picture) { #if defined(USE_GAMMA_COMPRESSION) -// gamma-compensates loss of resolution during chroma subsampling -#define kGamma 0.80 // for now we use a different gamma value than kGammaF -#define kGammaFix 12 // fixed-point precision for linear values -#define kGammaScale ((1 << kGammaFix) - 1) -#define kGammaTabFix 7 // fixed-point fractional bits precision -#define kGammaTabScale (1 << kGammaTabFix) -#define kGammaTabRounder (kGammaTabScale >> 1) -#define kGammaTabSize (1 << (kGammaFix - kGammaTabFix)) +// Gamma correction compensates loss of resolution during chroma subsampling. +#define GAMMA_FIX 12 // fixed-point precision for linear values +#define GAMMA_TAB_FIX 7 // fixed-point fractional bits precision +#define GAMMA_TAB_SIZE (1 << (GAMMA_FIX - GAMMA_TAB_FIX)) +static const double kGamma = 0.80; +static const int kGammaScale = ((1 << GAMMA_FIX) - 1); +static const int kGammaTabScale = (1 << GAMMA_TAB_FIX); +static const int kGammaTabRounder = (1 << GAMMA_TAB_FIX >> 1); -static int kLinearToGammaTab[kGammaTabSize + 1]; +static int kLinearToGammaTab[GAMMA_TAB_SIZE + 1]; static uint16_t kGammaToLinearTab[256]; static volatile int kGammaTablesOk = 0; static void InitGammaTables(void); @@ -93,13 +100,13 @@ static void InitGammaTables(void); WEBP_DSP_INIT_FUNC(InitGammaTables) { if (!kGammaTablesOk) { int v; - const double scale = (double)(1 << kGammaTabFix) / kGammaScale; + const double scale = (double)(1 << GAMMA_TAB_FIX) / kGammaScale; const double norm = 1. / 255.; for (v = 0; v <= 255; ++v) { kGammaToLinearTab[v] = (uint16_t)(pow(norm * v, kGamma) * kGammaScale + .5); } - for (v = 0; v <= kGammaTabSize; ++v) { + for (v = 0; v <= GAMMA_TAB_SIZE; ++v) { kLinearToGammaTab[v] = (int)(255. * pow(scale * v, 1. / kGamma) + .5); } kGammaTablesOk = 1; @@ -111,12 +118,12 @@ static WEBP_INLINE uint32_t GammaToLinear(uint8_t v) { } static WEBP_INLINE int Interpolate(int v) { - const int tab_pos = v >> (kGammaTabFix + 2); // integer part + const int tab_pos = v >> (GAMMA_TAB_FIX + 2); // integer part const int x = v & ((kGammaTabScale << 2) - 1); // fractional part const int v0 = kLinearToGammaTab[tab_pos]; const int v1 = kLinearToGammaTab[tab_pos + 1]; const int y = v1 * x + v0 * ((kGammaTabScale << 2) - x); // interpolate - assert(tab_pos + 1 < kGammaTabSize + 1); + assert(tab_pos + 1 < GAMMA_TAB_SIZE + 1); return y; } @@ -124,7 +131,7 @@ static WEBP_INLINE int Interpolate(int v) { // U/V value, suitable for RGBToU/V calls. static WEBP_INLINE int LinearToGamma(uint32_t base_value, int shift) { const int y = Interpolate(base_value << shift); // final uplifted value - return (y + kGammaTabRounder) >> kGammaTabFix; // descale + return (y + kGammaTabRounder) >> GAMMA_TAB_FIX; // descale } #else @@ -158,415 +165,41 @@ static int RGBToV(int r, int g, int b, VP8Random* const rg) { //------------------------------------------------------------------------------ // Sharp RGB->YUV conversion -static const int kNumIterations = 4; static const int kMinDimensionIterativeConversion = 4; -// We could use SFIX=0 and only uint8_t for fixed_y_t, but it produces some -// banding sometimes. Better use extra precision. -#define SFIX 2 // fixed-point precision of RGB and Y/W -typedef int16_t fixed_t; // signed type with extra SFIX precision for UV -typedef uint16_t fixed_y_t; // unsigned type with extra SFIX precision for W - -#define SHALF (1 << SFIX >> 1) -#define MAX_Y_T ((256 << SFIX) - 1) -#define SROUNDER (1 << (YUV_FIX + SFIX - 1)) - -#if defined(USE_GAMMA_COMPRESSION) - -// We use tables of different size and precision for the Rec709 / BT2020 -// transfer function. -#define kGammaF (1./0.45) -static uint32_t kLinearToGammaTabS[kGammaTabSize + 2]; -#define GAMMA_TO_LINEAR_BITS 14 -static uint32_t kGammaToLinearTabS[MAX_Y_T + 1]; // size scales with Y_FIX -static volatile int kGammaTablesSOk = 0; -static void InitGammaTablesS(void); - -WEBP_DSP_INIT_FUNC(InitGammaTablesS) { - assert(2 * GAMMA_TO_LINEAR_BITS < 32); // we use uint32_t intermediate values - if (!kGammaTablesSOk) { - int v; - const double norm = 1. / MAX_Y_T; - const double scale = 1. / kGammaTabSize; - const double a = 0.09929682680944; - const double thresh = 0.018053968510807; - const double final_scale = 1 << GAMMA_TO_LINEAR_BITS; - for (v = 0; v <= MAX_Y_T; ++v) { - const double g = norm * v; - double value; - if (g <= thresh * 4.5) { - value = g / 4.5; - } else { - const double a_rec = 1. / (1. + a); - value = pow(a_rec * (g + a), kGammaF); - } - kGammaToLinearTabS[v] = (uint32_t)(value * final_scale + .5); - } - for (v = 0; v <= kGammaTabSize; ++v) { - const double g = scale * v; - double value; - if (g <= thresh) { - value = 4.5 * g; - } else { - value = (1. + a) * pow(g, 1. / kGammaF) - a; - } - // we already incorporate the 1/2 rounding constant here - kLinearToGammaTabS[v] = - (uint32_t)(MAX_Y_T * value) + (1 << GAMMA_TO_LINEAR_BITS >> 1); - } - // to prevent small rounding errors to cause read-overflow: - kLinearToGammaTabS[kGammaTabSize + 1] = kLinearToGammaTabS[kGammaTabSize]; - kGammaTablesSOk = 1; - } -} - -// return value has a fixed-point precision of GAMMA_TO_LINEAR_BITS -static WEBP_INLINE uint32_t GammaToLinearS(int v) { - return kGammaToLinearTabS[v]; -} - -static WEBP_INLINE uint32_t LinearToGammaS(uint32_t value) { - // 'value' is in GAMMA_TO_LINEAR_BITS fractional precision - const uint32_t v = value * kGammaTabSize; - const uint32_t tab_pos = v >> GAMMA_TO_LINEAR_BITS; - // fractional part, in GAMMA_TO_LINEAR_BITS fixed-point precision - const uint32_t x = v - (tab_pos << GAMMA_TO_LINEAR_BITS); // fractional part - // v0 / v1 are in GAMMA_TO_LINEAR_BITS fixed-point precision (range [0..1]) - const uint32_t v0 = kLinearToGammaTabS[tab_pos + 0]; - const uint32_t v1 = kLinearToGammaTabS[tab_pos + 1]; - // Final interpolation. Note that rounding is already included. - const uint32_t v2 = (v1 - v0) * x; // note: v1 >= v0. - const uint32_t result = v0 + (v2 >> GAMMA_TO_LINEAR_BITS); - return result; -} - -#else - -static void InitGammaTablesS(void) {} -static WEBP_INLINE uint32_t GammaToLinearS(int v) { - return (v << GAMMA_TO_LINEAR_BITS) / MAX_Y_T; -} -static WEBP_INLINE uint32_t LinearToGammaS(uint32_t value) { - return (MAX_Y_T * value) >> GAMMA_TO_LINEAR_BITS; -} - -#endif // USE_GAMMA_COMPRESSION - -//------------------------------------------------------------------------------ - -static uint8_t clip_8b(fixed_t v) { - return (!(v & ~0xff)) ? (uint8_t)v : (v < 0) ? 0u : 255u; -} - -static fixed_y_t clip_y(int y) { - return (!(y & ~MAX_Y_T)) ? (fixed_y_t)y : (y < 0) ? 0 : MAX_Y_T; -} - -//------------------------------------------------------------------------------ - -static int RGBToGray(int r, int g, int b) { - const int luma = 13933 * r + 46871 * g + 4732 * b + YUV_HALF; - return (luma >> YUV_FIX); -} - -static uint32_t ScaleDown(int a, int b, int c, int d) { - const uint32_t A = GammaToLinearS(a); - const uint32_t B = GammaToLinearS(b); - const uint32_t C = GammaToLinearS(c); - const uint32_t D = GammaToLinearS(d); - return LinearToGammaS((A + B + C + D + 2) >> 2); -} - -static WEBP_INLINE void UpdateW(const fixed_y_t* src, fixed_y_t* dst, int w) { - int i; - for (i = 0; i < w; ++i) { - const uint32_t R = GammaToLinearS(src[0 * w + i]); - const uint32_t G = GammaToLinearS(src[1 * w + i]); - const uint32_t B = GammaToLinearS(src[2 * w + i]); - const uint32_t Y = RGBToGray(R, G, B); - dst[i] = (fixed_y_t)LinearToGammaS(Y); - } -} - -static void UpdateChroma(const fixed_y_t* src1, const fixed_y_t* src2, - fixed_t* dst, int uv_w) { - int i; - for (i = 0; i < uv_w; ++i) { - const int r = ScaleDown(src1[0 * uv_w + 0], src1[0 * uv_w + 1], - src2[0 * uv_w + 0], src2[0 * uv_w + 1]); - const int g = ScaleDown(src1[2 * uv_w + 0], src1[2 * uv_w + 1], - src2[2 * uv_w + 0], src2[2 * uv_w + 1]); - const int b = ScaleDown(src1[4 * uv_w + 0], src1[4 * uv_w + 1], - src2[4 * uv_w + 0], src2[4 * uv_w + 1]); - const int W = RGBToGray(r, g, b); - dst[0 * uv_w] = (fixed_t)(r - W); - dst[1 * uv_w] = (fixed_t)(g - W); - dst[2 * uv_w] = (fixed_t)(b - W); - dst += 1; - src1 += 2; - src2 += 2; - } -} - -static void StoreGray(const fixed_y_t* rgb, fixed_y_t* y, int w) { - int i; - for (i = 0; i < w; ++i) { - y[i] = RGBToGray(rgb[0 * w + i], rgb[1 * w + i], rgb[2 * w + i]); - } -} - -//------------------------------------------------------------------------------ - -static WEBP_INLINE fixed_y_t Filter2(int A, int B, int W0) { - const int v0 = (A * 3 + B + 2) >> 2; - return clip_y(v0 + W0); -} - -//------------------------------------------------------------------------------ - -static WEBP_INLINE fixed_y_t UpLift(uint8_t a) { // 8bit -> SFIX - return ((fixed_y_t)a << SFIX) | SHALF; -} - -static void ImportOneRow(const uint8_t* const r_ptr, - const uint8_t* const g_ptr, - const uint8_t* const b_ptr, - int step, - int pic_width, - fixed_y_t* const dst) { - int i; - const int w = (pic_width + 1) & ~1; - for (i = 0; i < pic_width; ++i) { - const int off = i * step; - dst[i + 0 * w] = UpLift(r_ptr[off]); - dst[i + 1 * w] = UpLift(g_ptr[off]); - dst[i + 2 * w] = UpLift(b_ptr[off]); - } - if (pic_width & 1) { // replicate rightmost pixel - dst[pic_width + 0 * w] = dst[pic_width + 0 * w - 1]; - dst[pic_width + 1 * w] = dst[pic_width + 1 * w - 1]; - dst[pic_width + 2 * w] = dst[pic_width + 2 * w - 1]; - } -} - -static void InterpolateTwoRows(const fixed_y_t* const best_y, - const fixed_t* prev_uv, - const fixed_t* cur_uv, - const fixed_t* next_uv, - int w, - fixed_y_t* out1, - fixed_y_t* out2) { - const int uv_w = w >> 1; - const int len = (w - 1) >> 1; // length to filter - int k = 3; - while (k-- > 0) { // process each R/G/B segments in turn - // special boundary case for i==0 - out1[0] = Filter2(cur_uv[0], prev_uv[0], best_y[0]); - out2[0] = Filter2(cur_uv[0], next_uv[0], best_y[w]); - - WebPSharpYUVFilterRow(cur_uv, prev_uv, len, best_y + 0 + 1, out1 + 1); - WebPSharpYUVFilterRow(cur_uv, next_uv, len, best_y + w + 1, out2 + 1); - - // special boundary case for i == w - 1 when w is even - if (!(w & 1)) { - out1[w - 1] = Filter2(cur_uv[uv_w - 1], prev_uv[uv_w - 1], - best_y[w - 1 + 0]); - out2[w - 1] = Filter2(cur_uv[uv_w - 1], next_uv[uv_w - 1], - best_y[w - 1 + w]); - } - out1 += w; - out2 += w; - prev_uv += uv_w; - cur_uv += uv_w; - next_uv += uv_w; - } -} - -static WEBP_INLINE uint8_t ConvertRGBToY(int r, int g, int b) { - const int luma = 16839 * r + 33059 * g + 6420 * b + SROUNDER; - return clip_8b(16 + (luma >> (YUV_FIX + SFIX))); -} - -static WEBP_INLINE uint8_t ConvertRGBToU(int r, int g, int b) { - const int u = -9719 * r - 19081 * g + 28800 * b + SROUNDER; - return clip_8b(128 + (u >> (YUV_FIX + SFIX))); -} - -static WEBP_INLINE uint8_t ConvertRGBToV(int r, int g, int b) { - const int v = +28800 * r - 24116 * g - 4684 * b + SROUNDER; - return clip_8b(128 + (v >> (YUV_FIX + SFIX))); -} - -static int ConvertWRGBToYUV(const fixed_y_t* best_y, const fixed_t* best_uv, - WebPPicture* const picture) { - int i, j; - uint8_t* dst_y = picture->y; - uint8_t* dst_u = picture->u; - uint8_t* dst_v = picture->v; - const fixed_t* const best_uv_base = best_uv; - const int w = (picture->width + 1) & ~1; - const int h = (picture->height + 1) & ~1; - const int uv_w = w >> 1; - const int uv_h = h >> 1; - for (best_uv = best_uv_base, j = 0; j < picture->height; ++j) { - for (i = 0; i < picture->width; ++i) { - const int off = (i >> 1); - const int W = best_y[i]; - const int r = best_uv[off + 0 * uv_w] + W; - const int g = best_uv[off + 1 * uv_w] + W; - const int b = best_uv[off + 2 * uv_w] + W; - dst_y[i] = ConvertRGBToY(r, g, b); - } - best_y += w; - best_uv += (j & 1) * 3 * uv_w; - dst_y += picture->y_stride; - } - for (best_uv = best_uv_base, j = 0; j < uv_h; ++j) { - for (i = 0; i < uv_w; ++i) { - const int off = i; - const int r = best_uv[off + 0 * uv_w]; - const int g = best_uv[off + 1 * uv_w]; - const int b = best_uv[off + 2 * uv_w]; - dst_u[i] = ConvertRGBToU(r, g, b); - dst_v[i] = ConvertRGBToV(r, g, b); - } - best_uv += 3 * uv_w; - dst_u += picture->uv_stride; - dst_v += picture->uv_stride; - } - return 1; -} - //------------------------------------------------------------------------------ // Main function -#define SAFE_ALLOC(W, H, T) ((T*)WebPSafeMalloc((W) * (H), sizeof(T))) +extern void SharpYuvInit(VP8CPUInfo cpu_info_func); + +static void SafeInitSharpYuv(void) { +#if defined(WEBP_USE_THREAD) && !defined(_WIN32) + static pthread_mutex_t initsharpyuv_lock = PTHREAD_MUTEX_INITIALIZER; + if (pthread_mutex_lock(&initsharpyuv_lock)) return; +#endif + + SharpYuvInit(VP8GetCPUInfo); + +#if defined(WEBP_USE_THREAD) && !defined(_WIN32) + (void)pthread_mutex_unlock(&initsharpyuv_lock); +#endif +} static int PreprocessARGB(const uint8_t* r_ptr, const uint8_t* g_ptr, const uint8_t* b_ptr, int step, int rgb_stride, WebPPicture* const picture) { - // we expand the right/bottom border if needed - const int w = (picture->width + 1) & ~1; - const int h = (picture->height + 1) & ~1; - const int uv_w = w >> 1; - const int uv_h = h >> 1; - uint64_t prev_diff_y_sum = ~0; - int j, iter; - - // TODO(skal): allocate one big memory chunk. But for now, it's easier - // for valgrind debugging to have several chunks. - fixed_y_t* const tmp_buffer = SAFE_ALLOC(w * 3, 2, fixed_y_t); // scratch - fixed_y_t* const best_y_base = SAFE_ALLOC(w, h, fixed_y_t); - fixed_y_t* const target_y_base = SAFE_ALLOC(w, h, fixed_y_t); - fixed_y_t* const best_rgb_y = SAFE_ALLOC(w, 2, fixed_y_t); - fixed_t* const best_uv_base = SAFE_ALLOC(uv_w * 3, uv_h, fixed_t); - fixed_t* const target_uv_base = SAFE_ALLOC(uv_w * 3, uv_h, fixed_t); - fixed_t* const best_rgb_uv = SAFE_ALLOC(uv_w * 3, 1, fixed_t); - fixed_y_t* best_y = best_y_base; - fixed_y_t* target_y = target_y_base; - fixed_t* best_uv = best_uv_base; - fixed_t* target_uv = target_uv_base; - const uint64_t diff_y_threshold = (uint64_t)(3.0 * w * h); - int ok; - - if (best_y_base == NULL || best_uv_base == NULL || - target_y_base == NULL || target_uv_base == NULL || - best_rgb_y == NULL || best_rgb_uv == NULL || - tmp_buffer == NULL) { - ok = WebPEncodingSetError(picture, VP8_ENC_ERROR_OUT_OF_MEMORY); - goto End; + const int ok = SharpYuvConvert( + r_ptr, g_ptr, b_ptr, step, rgb_stride, /*rgb_bit_depth=*/8, + picture->y, picture->y_stride, picture->u, picture->uv_stride, picture->v, + picture->uv_stride, /*yuv_bit_depth=*/8, picture->width, + picture->height, SharpYuvGetConversionMatrix(kSharpYuvMatrixWebp)); + if (!ok) { + return WebPEncodingSetError(picture, VP8_ENC_ERROR_OUT_OF_MEMORY); } - assert(picture->width >= kMinDimensionIterativeConversion); - assert(picture->height >= kMinDimensionIterativeConversion); - - WebPInitConvertARGBToYUV(); - - // Import RGB samples to W/RGB representation. - for (j = 0; j < picture->height; j += 2) { - const int is_last_row = (j == picture->height - 1); - fixed_y_t* const src1 = tmp_buffer + 0 * w; - fixed_y_t* const src2 = tmp_buffer + 3 * w; - - // prepare two rows of input - ImportOneRow(r_ptr, g_ptr, b_ptr, step, picture->width, src1); - if (!is_last_row) { - ImportOneRow(r_ptr + rgb_stride, g_ptr + rgb_stride, b_ptr + rgb_stride, - step, picture->width, src2); - } else { - memcpy(src2, src1, 3 * w * sizeof(*src2)); - } - StoreGray(src1, best_y + 0, w); - StoreGray(src2, best_y + w, w); - - UpdateW(src1, target_y, w); - UpdateW(src2, target_y + w, w); - UpdateChroma(src1, src2, target_uv, uv_w); - memcpy(best_uv, target_uv, 3 * uv_w * sizeof(*best_uv)); - best_y += 2 * w; - best_uv += 3 * uv_w; - target_y += 2 * w; - target_uv += 3 * uv_w; - r_ptr += 2 * rgb_stride; - g_ptr += 2 * rgb_stride; - b_ptr += 2 * rgb_stride; - } - - // Iterate and resolve clipping conflicts. - for (iter = 0; iter < kNumIterations; ++iter) { - const fixed_t* cur_uv = best_uv_base; - const fixed_t* prev_uv = best_uv_base; - uint64_t diff_y_sum = 0; - - best_y = best_y_base; - best_uv = best_uv_base; - target_y = target_y_base; - target_uv = target_uv_base; - for (j = 0; j < h; j += 2) { - fixed_y_t* const src1 = tmp_buffer + 0 * w; - fixed_y_t* const src2 = tmp_buffer + 3 * w; - { - const fixed_t* const next_uv = cur_uv + ((j < h - 2) ? 3 * uv_w : 0); - InterpolateTwoRows(best_y, prev_uv, cur_uv, next_uv, w, src1, src2); - prev_uv = cur_uv; - cur_uv = next_uv; - } - - UpdateW(src1, best_rgb_y + 0 * w, w); - UpdateW(src2, best_rgb_y + 1 * w, w); - UpdateChroma(src1, src2, best_rgb_uv, uv_w); - - // update two rows of Y and one row of RGB - diff_y_sum += WebPSharpYUVUpdateY(target_y, best_rgb_y, best_y, 2 * w); - WebPSharpYUVUpdateRGB(target_uv, best_rgb_uv, best_uv, 3 * uv_w); - - best_y += 2 * w; - best_uv += 3 * uv_w; - target_y += 2 * w; - target_uv += 3 * uv_w; - } - // test exit condition - if (iter > 0) { - if (diff_y_sum < diff_y_threshold) break; - if (diff_y_sum > prev_diff_y_sum) break; - } - prev_diff_y_sum = diff_y_sum; - } - // final reconstruction - ok = ConvertWRGBToYUV(best_y_base, best_uv_base, picture); - - End: - WebPSafeFree(best_y_base); - WebPSafeFree(best_uv_base); - WebPSafeFree(target_y_base); - WebPSafeFree(target_uv_base); - WebPSafeFree(best_rgb_y); - WebPSafeFree(best_rgb_uv); - WebPSafeFree(tmp_buffer); return ok; } -#undef SAFE_ALLOC //------------------------------------------------------------------------------ // "Fast" regular RGB->YUV @@ -591,8 +224,8 @@ static const int kAlphaFix = 19; // and constant are adjusted very tightly to fit 32b arithmetic. // In particular, they use the fact that the operands for 'v / a' are actually // derived as v = (a0.p0 + a1.p1 + a2.p2 + a3.p3) and a = a0 + a1 + a2 + a3 -// with ai in [0..255] and pi in [0..1<width, picture->height)) return 0; + if (!WebPPictureAllocARGB(picture)) return 0; picture->use_argb = 1; // Convert @@ -1106,6 +748,8 @@ static int Import(WebPPicture* const picture, const int width = picture->width; const int height = picture->height; + if (abs(rgb_stride) < (import_alpha ? 4 : 3) * width) return 0; + if (!picture->use_argb) { const uint8_t* a_ptr = import_alpha ? rgb + 3 : NULL; return ImportYUVAFromRGBA(r_ptr, g_ptr, b_ptr, a_ptr, step, rgb_stride, @@ -1163,24 +807,24 @@ static int Import(WebPPicture* const picture, #if !defined(WEBP_REDUCE_CSP) int WebPPictureImportBGR(WebPPicture* picture, - const uint8_t* rgb, int rgb_stride) { - return (picture != NULL && rgb != NULL) - ? Import(picture, rgb, rgb_stride, 3, 1, 0) + const uint8_t* bgr, int bgr_stride) { + return (picture != NULL && bgr != NULL) + ? Import(picture, bgr, bgr_stride, 3, 1, 0) : 0; } int WebPPictureImportBGRA(WebPPicture* picture, - const uint8_t* rgba, int rgba_stride) { - return (picture != NULL && rgba != NULL) - ? Import(picture, rgba, rgba_stride, 4, 1, 1) + const uint8_t* bgra, int bgra_stride) { + return (picture != NULL && bgra != NULL) + ? Import(picture, bgra, bgra_stride, 4, 1, 1) : 0; } int WebPPictureImportBGRX(WebPPicture* picture, - const uint8_t* rgba, int rgba_stride) { - return (picture != NULL && rgba != NULL) - ? Import(picture, rgba, rgba_stride, 4, 1, 0) + const uint8_t* bgrx, int bgrx_stride) { + return (picture != NULL && bgrx != NULL) + ? Import(picture, bgrx, bgrx_stride, 4, 1, 0) : 0; } @@ -1201,9 +845,9 @@ int WebPPictureImportRGBA(WebPPicture* picture, } int WebPPictureImportRGBX(WebPPicture* picture, - const uint8_t* rgba, int rgba_stride) { - return (picture != NULL && rgba != NULL) - ? Import(picture, rgba, rgba_stride, 4, 0, 0) + const uint8_t* rgbx, int rgbx_stride) { + return (picture != NULL && rgbx != NULL) + ? Import(picture, rgbx, rgbx_stride, 4, 0, 0) : 0; } diff --git a/thirdparty/webp/src/enc/picture_enc.c b/thirdparty/webp/src/enc/picture_enc.c index c691622d03..3af6383d38 100644 --- a/thirdparty/webp/src/enc/picture_enc.c +++ b/thirdparty/webp/src/enc/picture_enc.c @@ -45,6 +45,22 @@ int WebPPictureInitInternal(WebPPicture* picture, int version) { //------------------------------------------------------------------------------ +int WebPValidatePicture(const WebPPicture* const picture) { + if (picture == NULL) return 0; + if (picture->width <= 0 || picture->height <= 0) { + return WebPEncodingSetError(picture, VP8_ENC_ERROR_BAD_DIMENSION); + } + if (picture->width <= 0 || picture->width / 4 > INT_MAX / 4 || + picture->height <= 0 || picture->height / 4 > INT_MAX / 4) { + return WebPEncodingSetError(picture, VP8_ENC_ERROR_BAD_DIMENSION); + } + if (picture->colorspace != WEBP_YUV420 && + picture->colorspace != WEBP_YUV420A) { + return WebPEncodingSetError(picture, VP8_ENC_ERROR_INVALID_CONFIGURATION); + } + return 1; +} + static void WebPPictureResetBufferARGB(WebPPicture* const picture) { picture->memory_argb_ = NULL; picture->argb = NULL; @@ -63,18 +79,17 @@ void WebPPictureResetBuffers(WebPPicture* const picture) { WebPPictureResetBufferYUVA(picture); } -int WebPPictureAllocARGB(WebPPicture* const picture, int width, int height) { +int WebPPictureAllocARGB(WebPPicture* const picture) { void* memory; + const int width = picture->width; + const int height = picture->height; const uint64_t argb_size = (uint64_t)width * height; - assert(picture != NULL); + if (!WebPValidatePicture(picture)) return 0; WebPSafeFree(picture->memory_argb_); WebPPictureResetBufferARGB(picture); - if (width <= 0 || height <= 0) { - return WebPEncodingSetError(picture, VP8_ENC_ERROR_BAD_DIMENSION); - } // allocate a new buffer. memory = WebPSafeMalloc(argb_size + WEBP_ALIGN_CST, sizeof(*picture->argb)); if (memory == NULL) { @@ -86,10 +101,10 @@ int WebPPictureAllocARGB(WebPPicture* const picture, int width, int height) { return 1; } -int WebPPictureAllocYUVA(WebPPicture* const picture, int width, int height) { - const WebPEncCSP uv_csp = - (WebPEncCSP)((int)picture->colorspace & WEBP_CSP_UV_MASK); +int WebPPictureAllocYUVA(WebPPicture* const picture) { const int has_alpha = (int)picture->colorspace & WEBP_CSP_ALPHA_BIT; + const int width = picture->width; + const int height = picture->height; const int y_stride = width; const int uv_width = (int)(((int64_t)width + 1) >> 1); const int uv_height = (int)(((int64_t)height + 1) >> 1); @@ -98,15 +113,11 @@ int WebPPictureAllocYUVA(WebPPicture* const picture, int width, int height) { uint64_t y_size, uv_size, a_size, total_size; uint8_t* mem; - assert(picture != NULL); + if (!WebPValidatePicture(picture)) return 0; WebPSafeFree(picture->memory_); WebPPictureResetBufferYUVA(picture); - if (uv_csp != WEBP_YUV420) { - return WebPEncodingSetError(picture, VP8_ENC_ERROR_INVALID_CONFIGURATION); - } - // alpha a_width = has_alpha ? width : 0; a_stride = a_width; @@ -152,15 +163,12 @@ int WebPPictureAllocYUVA(WebPPicture* const picture, int width, int height) { int WebPPictureAlloc(WebPPicture* picture) { if (picture != NULL) { - const int width = picture->width; - const int height = picture->height; - WebPPictureFree(picture); // erase previous buffer if (!picture->use_argb) { - return WebPPictureAllocYUVA(picture, width, height); + return WebPPictureAllocYUVA(picture); } else { - return WebPPictureAllocARGB(picture, width, height); + return WebPPictureAllocARGB(picture); } } return 1; diff --git a/thirdparty/webp/src/enc/picture_rescale_enc.c b/thirdparty/webp/src/enc/picture_rescale_enc.c index a75f5d9c06..839f91cacc 100644 --- a/thirdparty/webp/src/enc/picture_rescale_enc.c +++ b/thirdparty/webp/src/enc/picture_rescale_enc.c @@ -13,14 +13,15 @@ #include "src/webp/encode.h" -#if !defined(WEBP_REDUCE_SIZE) - #include #include #include "src/enc/vp8i_enc.h" + +#if !defined(WEBP_REDUCE_SIZE) #include "src/utils/rescaler_utils.h" #include "src/utils/utils.h" +#endif // !defined(WEBP_REDUCE_SIZE) #define HALVE(x) (((x) + 1) >> 1) @@ -56,6 +57,7 @@ static int AdjustAndCheckRectangle(const WebPPicture* const pic, return 1; } +#if !defined(WEBP_REDUCE_SIZE) int WebPPictureCopy(const WebPPicture* src, WebPPicture* dst) { if (src == NULL || dst == NULL) return 0; if (src == dst) return 1; @@ -81,6 +83,7 @@ int WebPPictureCopy(const WebPPicture* src, WebPPicture* dst) { } return 1; } +#endif // !defined(WEBP_REDUCE_SIZE) int WebPPictureIsView(const WebPPicture* picture) { if (picture == NULL) return 0; @@ -120,6 +123,7 @@ int WebPPictureView(const WebPPicture* src, return 1; } +#if !defined(WEBP_REDUCE_SIZE) //------------------------------------------------------------------------------ // Picture cropping @@ -198,34 +202,34 @@ static void AlphaMultiplyY(WebPPicture* const pic, int inverse) { } } -int WebPPictureRescale(WebPPicture* pic, int width, int height) { +int WebPPictureRescale(WebPPicture* picture, int width, int height) { WebPPicture tmp; int prev_width, prev_height; rescaler_t* work; - if (pic == NULL) return 0; - prev_width = pic->width; - prev_height = pic->height; + if (picture == NULL) return 0; + prev_width = picture->width; + prev_height = picture->height; if (!WebPRescalerGetScaledDimensions( prev_width, prev_height, &width, &height)) { return 0; } - PictureGrabSpecs(pic, &tmp); + PictureGrabSpecs(picture, &tmp); tmp.width = width; tmp.height = height; if (!WebPPictureAlloc(&tmp)) return 0; - if (!pic->use_argb) { + if (!picture->use_argb) { work = (rescaler_t*)WebPSafeMalloc(2ULL * width, sizeof(*work)); if (work == NULL) { WebPPictureFree(&tmp); return 0; } // If present, we need to rescale alpha first (for AlphaMultiplyY). - if (pic->a != NULL) { + if (picture->a != NULL) { WebPInitAlphaProcessing(); - if (!RescalePlane(pic->a, prev_width, prev_height, pic->a_stride, + if (!RescalePlane(picture->a, prev_width, prev_height, picture->a_stride, tmp.a, width, height, tmp.a_stride, work, 1)) { return 0; } @@ -233,17 +237,15 @@ int WebPPictureRescale(WebPPicture* pic, int width, int height) { // We take transparency into account on the luma plane only. That's not // totally exact blending, but still is a good approximation. - AlphaMultiplyY(pic, 0); - if (!RescalePlane(pic->y, prev_width, prev_height, pic->y_stride, + AlphaMultiplyY(picture, 0); + if (!RescalePlane(picture->y, prev_width, prev_height, picture->y_stride, tmp.y, width, height, tmp.y_stride, work, 1) || - !RescalePlane(pic->u, - HALVE(prev_width), HALVE(prev_height), pic->uv_stride, - tmp.u, - HALVE(width), HALVE(height), tmp.uv_stride, work, 1) || - !RescalePlane(pic->v, - HALVE(prev_width), HALVE(prev_height), pic->uv_stride, - tmp.v, - HALVE(width), HALVE(height), tmp.uv_stride, work, 1)) { + !RescalePlane(picture->u, HALVE(prev_width), HALVE(prev_height), + picture->uv_stride, tmp.u, HALVE(width), HALVE(height), + tmp.uv_stride, work, 1) || + !RescalePlane(picture->v, HALVE(prev_width), HALVE(prev_height), + picture->uv_stride, tmp.v, HALVE(width), HALVE(height), + tmp.uv_stride, work, 1)) { return 0; } AlphaMultiplyY(&tmp, 1); @@ -257,18 +259,17 @@ int WebPPictureRescale(WebPPicture* pic, int width, int height) { // weighting first (black-matting), scale the RGB values, and remove // the premultiplication afterward (while preserving the alpha channel). WebPInitAlphaProcessing(); - AlphaMultiplyARGB(pic, 0); - if (!RescalePlane((const uint8_t*)pic->argb, prev_width, prev_height, - pic->argb_stride * 4, - (uint8_t*)tmp.argb, width, height, - tmp.argb_stride * 4, work, 4)) { + AlphaMultiplyARGB(picture, 0); + if (!RescalePlane((const uint8_t*)picture->argb, prev_width, prev_height, + picture->argb_stride * 4, (uint8_t*)tmp.argb, width, + height, tmp.argb_stride * 4, work, 4)) { return 0; } AlphaMultiplyARGB(&tmp, 1); } - WebPPictureFree(pic); + WebPPictureFree(picture); WebPSafeFree(work); - *pic = tmp; + *picture = tmp; return 1; } @@ -280,23 +281,6 @@ int WebPPictureCopy(const WebPPicture* src, WebPPicture* dst) { return 0; } -int WebPPictureIsView(const WebPPicture* picture) { - (void)picture; - return 0; -} - -int WebPPictureView(const WebPPicture* src, - int left, int top, int width, int height, - WebPPicture* dst) { - (void)src; - (void)left; - (void)top; - (void)width; - (void)height; - (void)dst; - return 0; -} - int WebPPictureCrop(WebPPicture* pic, int left, int top, int width, int height) { (void)pic; diff --git a/thirdparty/webp/src/enc/picture_tools_enc.c b/thirdparty/webp/src/enc/picture_tools_enc.c index 38cb01534a..147cc18608 100644 --- a/thirdparty/webp/src/enc/picture_tools_enc.c +++ b/thirdparty/webp/src/enc/picture_tools_enc.c @@ -190,27 +190,28 @@ static WEBP_INLINE uint32_t MakeARGB32(int r, int g, int b) { return (0xff000000u | (r << 16) | (g << 8) | b); } -void WebPBlendAlpha(WebPPicture* pic, uint32_t background_rgb) { +void WebPBlendAlpha(WebPPicture* picture, uint32_t background_rgb) { const int red = (background_rgb >> 16) & 0xff; const int green = (background_rgb >> 8) & 0xff; const int blue = (background_rgb >> 0) & 0xff; int x, y; - if (pic == NULL) return; - if (!pic->use_argb) { - const int uv_width = (pic->width >> 1); // omit last pixel during u/v loop + if (picture == NULL) return; + if (!picture->use_argb) { + // omit last pixel during u/v loop + const int uv_width = (picture->width >> 1); const int Y0 = VP8RGBToY(red, green, blue, YUV_HALF); // VP8RGBToU/V expects the u/v values summed over four pixels const int U0 = VP8RGBToU(4 * red, 4 * green, 4 * blue, 4 * YUV_HALF); const int V0 = VP8RGBToV(4 * red, 4 * green, 4 * blue, 4 * YUV_HALF); - const int has_alpha = pic->colorspace & WEBP_CSP_ALPHA_BIT; - uint8_t* y_ptr = pic->y; - uint8_t* u_ptr = pic->u; - uint8_t* v_ptr = pic->v; - uint8_t* a_ptr = pic->a; + const int has_alpha = picture->colorspace & WEBP_CSP_ALPHA_BIT; + uint8_t* y_ptr = picture->y; + uint8_t* u_ptr = picture->u; + uint8_t* v_ptr = picture->v; + uint8_t* a_ptr = picture->a; if (!has_alpha || a_ptr == NULL) return; // nothing to do - for (y = 0; y < pic->height; ++y) { + for (y = 0; y < picture->height; ++y) { // Luma blending - for (x = 0; x < pic->width; ++x) { + for (x = 0; x < picture->width; ++x) { const uint8_t alpha = a_ptr[x]; if (alpha < 0xff) { y_ptr[x] = BLEND(Y0, y_ptr[x], alpha); @@ -219,7 +220,7 @@ void WebPBlendAlpha(WebPPicture* pic, uint32_t background_rgb) { // Chroma blending every even line if ((y & 1) == 0) { uint8_t* const a_ptr2 = - (y + 1 == pic->height) ? a_ptr : a_ptr + pic->a_stride; + (y + 1 == picture->height) ? a_ptr : a_ptr + picture->a_stride; for (x = 0; x < uv_width; ++x) { // Average four alpha values into a single blending weight. // TODO(skal): might lead to visible contouring. Can we do better? @@ -229,24 +230,24 @@ void WebPBlendAlpha(WebPPicture* pic, uint32_t background_rgb) { u_ptr[x] = BLEND_10BIT(U0, u_ptr[x], alpha); v_ptr[x] = BLEND_10BIT(V0, v_ptr[x], alpha); } - if (pic->width & 1) { // rightmost pixel + if (picture->width & 1) { // rightmost pixel const uint32_t alpha = 2 * (a_ptr[2 * x + 0] + a_ptr2[2 * x + 0]); u_ptr[x] = BLEND_10BIT(U0, u_ptr[x], alpha); v_ptr[x] = BLEND_10BIT(V0, v_ptr[x], alpha); } } else { - u_ptr += pic->uv_stride; - v_ptr += pic->uv_stride; + u_ptr += picture->uv_stride; + v_ptr += picture->uv_stride; } - memset(a_ptr, 0xff, pic->width); // reset alpha value to opaque - a_ptr += pic->a_stride; - y_ptr += pic->y_stride; + memset(a_ptr, 0xff, picture->width); // reset alpha value to opaque + a_ptr += picture->a_stride; + y_ptr += picture->y_stride; } } else { - uint32_t* argb = pic->argb; + uint32_t* argb = picture->argb; const uint32_t background = MakeARGB32(red, green, blue); - for (y = 0; y < pic->height; ++y) { - for (x = 0; x < pic->width; ++x) { + for (y = 0; y < picture->height; ++y) { + for (x = 0; x < picture->width; ++x) { const int alpha = (argb[x] >> 24) & 0xff; if (alpha != 0xff) { if (alpha > 0) { @@ -262,7 +263,7 @@ void WebPBlendAlpha(WebPPicture* pic, uint32_t background_rgb) { } } } - argb += pic->argb_stride; + argb += picture->argb_stride; } } } diff --git a/thirdparty/webp/src/enc/predictor_enc.c b/thirdparty/webp/src/enc/predictor_enc.c index 2b5c767280..b3d44b59d5 100644 --- a/thirdparty/webp/src/enc/predictor_enc.c +++ b/thirdparty/webp/src/enc/predictor_enc.c @@ -16,6 +16,7 @@ #include "src/dsp/lossless.h" #include "src/dsp/lossless_common.h" +#include "src/enc/vp8i_enc.h" #include "src/enc/vp8li_enc.h" #define MAX_DIFF_COST (1e30f) @@ -31,10 +32,10 @@ static WEBP_INLINE int GetMin(int a, int b) { return (a > b) ? b : a; } // Methods to calculate Entropy (Shannon). static float PredictionCostSpatial(const int counts[256], int weight_0, - double exp_val) { + float exp_val) { const int significant_symbols = 256 >> 4; - const double exp_decay_factor = 0.6; - double bits = weight_0 * counts[0]; + const float exp_decay_factor = 0.6f; + float bits = (float)weight_0 * counts[0]; int i; for (i = 1; i < significant_symbols; ++i) { bits += exp_val * (counts[i] + counts[256 - i]); @@ -46,9 +47,9 @@ static float PredictionCostSpatial(const int counts[256], int weight_0, static float PredictionCostSpatialHistogram(const int accumulated[4][256], const int tile[4][256]) { int i; - double retval = 0; + float retval = 0.f; for (i = 0; i < 4; ++i) { - const double kExpValue = 0.94; + const float kExpValue = 0.94f; retval += PredictionCostSpatial(tile[i], 1, kExpValue); retval += VP8LCombinedShannonEntropy(tile[i], accumulated[i]); } @@ -472,12 +473,15 @@ static void CopyImageWithPrediction(int width, int height, // with respect to predictions. If near_lossless_quality < 100, applies // near lossless processing, shaving off more bits of residuals for lower // qualities. -void VP8LResidualImage(int width, int height, int bits, int low_effort, - uint32_t* const argb, uint32_t* const argb_scratch, - uint32_t* const image, int near_lossless_quality, - int exact, int used_subtract_green) { +int VP8LResidualImage(int width, int height, int bits, int low_effort, + uint32_t* const argb, uint32_t* const argb_scratch, + uint32_t* const image, int near_lossless_quality, + int exact, int used_subtract_green, + const WebPPicture* const pic, int percent_range, + int* const percent) { const int tiles_per_row = VP8LSubSampleSize(width, bits); const int tiles_per_col = VP8LSubSampleSize(height, bits); + int percent_start = *percent; int tile_y; int histo[4][256]; const int max_quantization = 1 << VP8LNearLosslessBits(near_lossless_quality); @@ -491,17 +495,24 @@ void VP8LResidualImage(int width, int height, int bits, int low_effort, for (tile_y = 0; tile_y < tiles_per_col; ++tile_y) { int tile_x; for (tile_x = 0; tile_x < tiles_per_row; ++tile_x) { - const int pred = GetBestPredictorForTile(width, height, tile_x, tile_y, - bits, histo, argb_scratch, argb, max_quantization, exact, - used_subtract_green, image); + const int pred = GetBestPredictorForTile( + width, height, tile_x, tile_y, bits, histo, argb_scratch, argb, + max_quantization, exact, used_subtract_green, image); image[tile_y * tiles_per_row + tile_x] = ARGB_BLACK | (pred << 8); } + + if (!WebPReportProgress( + pic, percent_start + percent_range * tile_y / tiles_per_col, + percent)) { + return 0; + } } } CopyImageWithPrediction(width, height, bits, image, argb_scratch, argb, low_effort, max_quantization, exact, used_subtract_green); + return WebPReportProgress(pic, percent_start + percent_range, percent); } //------------------------------------------------------------------------------ @@ -532,7 +543,7 @@ static float PredictionCostCrossColor(const int accumulated[256], const int counts[256]) { // Favor low entropy, locally and globally. // Favor small absolute values for PredictionCostSpatial - static const double kExpValue = 2.4; + static const float kExpValue = 2.4f; return VP8LCombinedShannonEntropy(counts, accumulated) + PredictionCostSpatial(counts, 3, kExpValue); } @@ -714,11 +725,14 @@ static void CopyTileWithColorTransform(int xsize, int ysize, } } -void VP8LColorSpaceTransform(int width, int height, int bits, int quality, - uint32_t* const argb, uint32_t* image) { +int VP8LColorSpaceTransform(int width, int height, int bits, int quality, + uint32_t* const argb, uint32_t* image, + const WebPPicture* const pic, int percent_range, + int* const percent) { const int max_tile_size = 1 << bits; const int tile_xsize = VP8LSubSampleSize(width, bits); const int tile_ysize = VP8LSubSampleSize(height, bits); + int percent_start = *percent; int accumulated_red_histo[256] = { 0 }; int accumulated_blue_histo[256] = { 0 }; int tile_x, tile_y; @@ -768,5 +782,11 @@ void VP8LColorSpaceTransform(int width, int height, int bits, int quality, } } } + if (!WebPReportProgress( + pic, percent_start + percent_range * tile_y / tile_ysize, + percent)) { + return 0; + } } + return 1; } diff --git a/thirdparty/webp/src/enc/quant_enc.c b/thirdparty/webp/src/enc/quant_enc.c index 6cede28ab4..6d8202d277 100644 --- a/thirdparty/webp/src/enc/quant_enc.c +++ b/thirdparty/webp/src/enc/quant_enc.c @@ -533,7 +533,8 @@ static void InitScore(VP8ModeScore* const rd) { rd->score = MAX_COST; } -static void CopyScore(VP8ModeScore* const dst, const VP8ModeScore* const src) { +static void CopyScore(VP8ModeScore* WEBP_RESTRICT const dst, + const VP8ModeScore* WEBP_RESTRICT const src) { dst->D = src->D; dst->SD = src->SD; dst->R = src->R; @@ -542,7 +543,8 @@ static void CopyScore(VP8ModeScore* const dst, const VP8ModeScore* const src) { dst->score = src->score; } -static void AddScore(VP8ModeScore* const dst, const VP8ModeScore* const src) { +static void AddScore(VP8ModeScore* WEBP_RESTRICT const dst, + const VP8ModeScore* WEBP_RESTRICT const src) { dst->D += src->D; dst->SD += src->SD; dst->R += src->R; @@ -588,10 +590,10 @@ static WEBP_INLINE score_t RDScoreTrellis(int lambda, score_t rate, // Coefficient type. enum { TYPE_I16_AC = 0, TYPE_I16_DC = 1, TYPE_CHROMA_A = 2, TYPE_I4_AC = 3 }; -static int TrellisQuantizeBlock(const VP8Encoder* const enc, +static int TrellisQuantizeBlock(const VP8Encoder* WEBP_RESTRICT const enc, int16_t in[16], int16_t out[16], int ctx0, int coeff_type, - const VP8Matrix* const mtx, + const VP8Matrix* WEBP_RESTRICT const mtx, int lambda) { const ProbaArray* const probas = enc->proba_.coeffs_[coeff_type]; CostArrayPtr const costs = @@ -767,9 +769,9 @@ static int TrellisQuantizeBlock(const VP8Encoder* const enc, // all at once. Output is the reconstructed block in *yuv_out, and the // quantized levels in *levels. -static int ReconstructIntra16(VP8EncIterator* const it, - VP8ModeScore* const rd, - uint8_t* const yuv_out, +static int ReconstructIntra16(VP8EncIterator* WEBP_RESTRICT const it, + VP8ModeScore* WEBP_RESTRICT const rd, + uint8_t* WEBP_RESTRICT const yuv_out, int mode) { const VP8Encoder* const enc = it->enc_; const uint8_t* const ref = it->yuv_p_ + VP8I16ModeOffsets[mode]; @@ -819,10 +821,10 @@ static int ReconstructIntra16(VP8EncIterator* const it, return nz; } -static int ReconstructIntra4(VP8EncIterator* const it, +static int ReconstructIntra4(VP8EncIterator* WEBP_RESTRICT const it, int16_t levels[16], - const uint8_t* const src, - uint8_t* const yuv_out, + const uint8_t* WEBP_RESTRICT const src, + uint8_t* WEBP_RESTRICT const yuv_out, int mode) { const VP8Encoder* const enc = it->enc_; const uint8_t* const ref = it->yuv_p_ + VP8I4ModeOffsets[mode]; @@ -855,7 +857,8 @@ static int ReconstructIntra4(VP8EncIterator* const it, // Quantize as usual, but also compute and return the quantization error. // Error is already divided by DSHIFT. -static int QuantizeSingle(int16_t* const v, const VP8Matrix* const mtx) { +static int QuantizeSingle(int16_t* WEBP_RESTRICT const v, + const VP8Matrix* WEBP_RESTRICT const mtx) { int V = *v; const int sign = (V < 0); if (sign) V = -V; @@ -869,9 +872,10 @@ static int QuantizeSingle(int16_t* const v, const VP8Matrix* const mtx) { return (sign ? -V : V) >> DSCALE; } -static void CorrectDCValues(const VP8EncIterator* const it, - const VP8Matrix* const mtx, - int16_t tmp[][16], VP8ModeScore* const rd) { +static void CorrectDCValues(const VP8EncIterator* WEBP_RESTRICT const it, + const VP8Matrix* WEBP_RESTRICT const mtx, + int16_t tmp[][16], + VP8ModeScore* WEBP_RESTRICT const rd) { // | top[0] | top[1] // --------+--------+--------- // left[0] | tmp[0] tmp[1] <-> err0 err1 @@ -902,8 +906,8 @@ static void CorrectDCValues(const VP8EncIterator* const it, } } -static void StoreDiffusionErrors(VP8EncIterator* const it, - const VP8ModeScore* const rd) { +static void StoreDiffusionErrors(VP8EncIterator* WEBP_RESTRICT const it, + const VP8ModeScore* WEBP_RESTRICT const rd) { int ch; for (ch = 0; ch <= 1; ++ch) { int8_t* const top = it->top_derr_[it->x_][ch]; @@ -922,8 +926,9 @@ static void StoreDiffusionErrors(VP8EncIterator* const it, //------------------------------------------------------------------------------ -static int ReconstructUV(VP8EncIterator* const it, VP8ModeScore* const rd, - uint8_t* const yuv_out, int mode) { +static int ReconstructUV(VP8EncIterator* WEBP_RESTRICT const it, + VP8ModeScore* WEBP_RESTRICT const rd, + uint8_t* WEBP_RESTRICT const yuv_out, int mode) { const VP8Encoder* const enc = it->enc_; const uint8_t* const ref = it->yuv_p_ + VP8UVModeOffsets[mode]; const uint8_t* const src = it->yuv_in_ + U_OFF_ENC; @@ -994,7 +999,8 @@ static void SwapOut(VP8EncIterator* const it) { SwapPtr(&it->yuv_out_, &it->yuv_out2_); } -static void PickBestIntra16(VP8EncIterator* const it, VP8ModeScore* rd) { +static void PickBestIntra16(VP8EncIterator* WEBP_RESTRICT const it, + VP8ModeScore* WEBP_RESTRICT rd) { const int kNumBlocks = 16; VP8SegmentInfo* const dqm = &it->enc_->dqm_[it->mb_->segment_]; const int lambda = dqm->lambda_i16_; @@ -1054,7 +1060,7 @@ static void PickBestIntra16(VP8EncIterator* const it, VP8ModeScore* rd) { //------------------------------------------------------------------------------ // return the cost array corresponding to the surrounding prediction modes. -static const uint16_t* GetCostModeI4(VP8EncIterator* const it, +static const uint16_t* GetCostModeI4(VP8EncIterator* WEBP_RESTRICT const it, const uint8_t modes[16]) { const int preds_w = it->enc_->preds_w_; const int x = (it->i4_ & 3), y = it->i4_ >> 2; @@ -1063,7 +1069,8 @@ static const uint16_t* GetCostModeI4(VP8EncIterator* const it, return VP8FixedCostsI4[top][left]; } -static int PickBestIntra4(VP8EncIterator* const it, VP8ModeScore* const rd) { +static int PickBestIntra4(VP8EncIterator* WEBP_RESTRICT const it, + VP8ModeScore* WEBP_RESTRICT const rd) { const VP8Encoder* const enc = it->enc_; const VP8SegmentInfo* const dqm = &enc->dqm_[it->mb_->segment_]; const int lambda = dqm->lambda_i4_; @@ -1159,7 +1166,8 @@ static int PickBestIntra4(VP8EncIterator* const it, VP8ModeScore* const rd) { //------------------------------------------------------------------------------ -static void PickBestUV(VP8EncIterator* const it, VP8ModeScore* const rd) { +static void PickBestUV(VP8EncIterator* WEBP_RESTRICT const it, + VP8ModeScore* WEBP_RESTRICT const rd) { const int kNumBlocks = 8; const VP8SegmentInfo* const dqm = &it->enc_->dqm_[it->mb_->segment_]; const int lambda = dqm->lambda_uv_; @@ -1211,7 +1219,8 @@ static void PickBestUV(VP8EncIterator* const it, VP8ModeScore* const rd) { //------------------------------------------------------------------------------ // Final reconstruction and quantization. -static void SimpleQuantize(VP8EncIterator* const it, VP8ModeScore* const rd) { +static void SimpleQuantize(VP8EncIterator* WEBP_RESTRICT const it, + VP8ModeScore* WEBP_RESTRICT const rd) { const VP8Encoder* const enc = it->enc_; const int is_i16 = (it->mb_->type_ == 1); int nz = 0; @@ -1236,9 +1245,9 @@ static void SimpleQuantize(VP8EncIterator* const it, VP8ModeScore* const rd) { } // Refine intra16/intra4 sub-modes based on distortion only (not rate). -static void RefineUsingDistortion(VP8EncIterator* const it, +static void RefineUsingDistortion(VP8EncIterator* WEBP_RESTRICT const it, int try_both_modes, int refine_uv_mode, - VP8ModeScore* const rd) { + VP8ModeScore* WEBP_RESTRICT const rd) { score_t best_score = MAX_COST; int nz = 0; int mode; @@ -1352,7 +1361,8 @@ static void RefineUsingDistortion(VP8EncIterator* const it, //------------------------------------------------------------------------------ // Entry point -int VP8Decimate(VP8EncIterator* const it, VP8ModeScore* const rd, +int VP8Decimate(VP8EncIterator* WEBP_RESTRICT const it, + VP8ModeScore* WEBP_RESTRICT const rd, VP8RDLevel rd_opt) { int is_skipped; const int method = it->enc_->method_; diff --git a/thirdparty/webp/src/enc/vp8i_enc.h b/thirdparty/webp/src/enc/vp8i_enc.h index b4bba08f27..71f76702ae 100644 --- a/thirdparty/webp/src/enc/vp8i_enc.h +++ b/thirdparty/webp/src/enc/vp8i_enc.h @@ -32,7 +32,7 @@ extern "C" { // version numbers #define ENC_MAJ_VERSION 1 #define ENC_MIN_VERSION 2 -#define ENC_REV_VERSION 2 +#define ENC_REV_VERSION 4 enum { MAX_LF_LEVELS = 64, // Maximum loop filter level MAX_VARIABLE_LEVEL = 67, // last (inclusive) level with variable cost @@ -470,7 +470,8 @@ int VP8EncAnalyze(VP8Encoder* const enc); // Sets up segment's quantization values, base_quant_ and filter strengths. void VP8SetSegmentParams(VP8Encoder* const enc, float quality); // Pick best modes and fills the levels. Returns true if skipped. -int VP8Decimate(VP8EncIterator* const it, VP8ModeScore* const rd, +int VP8Decimate(VP8EncIterator* WEBP_RESTRICT const it, + VP8ModeScore* WEBP_RESTRICT const rd, VP8RDLevel rd_opt); // in alpha.c @@ -490,19 +491,24 @@ int VP8FilterStrengthFromDelta(int sharpness, int delta); // misc utils for picture_*.c: +// Returns true if 'picture' is non-NULL and dimensions/colorspace are within +// their valid ranges. If returning false, the 'error_code' in 'picture' is +// updated. +int WebPValidatePicture(const WebPPicture* const picture); + // Remove reference to the ARGB/YUVA buffer (doesn't free anything). void WebPPictureResetBuffers(WebPPicture* const picture); -// Allocates ARGB buffer of given dimension (previous one is always free'd). -// Preserves the YUV(A) buffer. Returns false in case of error (invalid param, -// out-of-memory). -int WebPPictureAllocARGB(WebPPicture* const picture, int width, int height); +// Allocates ARGB buffer according to set width/height (previous one is +// always free'd). Preserves the YUV(A) buffer. Returns false in case of error +// (invalid param, out-of-memory). +int WebPPictureAllocARGB(WebPPicture* const picture); -// Allocates YUVA buffer of given dimension (previous one is always free'd). -// Uses picture->csp to determine whether an alpha buffer is needed. +// Allocates YUVA buffer according to set width/height (previous one is always +// free'd). Uses picture->csp to determine whether an alpha buffer is needed. // Preserves the ARGB buffer. // Returns false in case of error (invalid param, out-of-memory). -int WebPPictureAllocYUVA(WebPPicture* const picture, int width, int height); +int WebPPictureAllocYUVA(WebPPicture* const picture); // Replace samples that are fully transparent by 'color' to help compressibility // (no guarantee, though). Assumes pic->use_argb is true. diff --git a/thirdparty/webp/src/enc/vp8l_enc.c b/thirdparty/webp/src/enc/vp8l_enc.c index e330e716f1..2b345df610 100644 --- a/thirdparty/webp/src/enc/vp8l_enc.c +++ b/thirdparty/webp/src/enc/vp8l_enc.c @@ -15,15 +15,16 @@ #include #include +#include "src/dsp/lossless.h" +#include "src/dsp/lossless_common.h" #include "src/enc/backward_references_enc.h" #include "src/enc/histogram_enc.h" #include "src/enc/vp8i_enc.h" #include "src/enc/vp8li_enc.h" -#include "src/dsp/lossless.h" -#include "src/dsp/lossless_common.h" #include "src/utils/bit_writer_utils.h" #include "src/utils/huffman_encode_utils.h" #include "src/utils/utils.h" +#include "src/webp/encode.h" #include "src/webp/format_constants.h" // Maximum number of histogram images (sub-blocks). @@ -183,10 +184,9 @@ static void CoOccurrenceFindMax(const uint32_t* const cooccurrence, } // Builds the cooccurrence matrix -static WebPEncodingError CoOccurrenceBuild(const WebPPicture* const pic, - const uint32_t* const palette, - uint32_t num_colors, - uint32_t* cooccurrence) { +static int CoOccurrenceBuild(const WebPPicture* const pic, + const uint32_t* const palette, uint32_t num_colors, + uint32_t* cooccurrence) { uint32_t *lines, *line_top, *line_current, *line_tmp; int x, y; const uint32_t* src = pic->argb; @@ -195,7 +195,10 @@ static WebPEncodingError CoOccurrenceBuild(const WebPPicture* const pic, uint32_t idx_map[MAX_PALETTE_SIZE] = {0}; uint32_t palette_sorted[MAX_PALETTE_SIZE]; lines = (uint32_t*)WebPSafeMalloc(2 * pic->width, sizeof(*lines)); - if (lines == NULL) return VP8_ENC_ERROR_OUT_OF_MEMORY; + if (lines == NULL) { + WebPEncodingSetError(pic, VP8_ENC_ERROR_OUT_OF_MEMORY); + return 0; + } line_top = &lines[0]; line_current = &lines[pic->width]; PrepareMapToPalette(palette, num_colors, palette_sorted, idx_map); @@ -226,7 +229,7 @@ static WebPEncodingError CoOccurrenceBuild(const WebPPicture* const pic, src += pic->argb_stride; } WebPSafeFree(lines); - return VP8_ENC_OK; + return 1; } struct Sum { @@ -237,7 +240,7 @@ struct Sum { // Implements the modified Zeng method from "A Survey on Palette Reordering // Methods for Improving the Compression of Color-Indexed Images" by Armando J. // Pinho and Antonio J. R. Neves. -static WebPEncodingError PaletteSortModifiedZeng( +static int PaletteSortModifiedZeng( const WebPPicture* const pic, const uint32_t* const palette_sorted, uint32_t num_colors, uint32_t* const palette) { uint32_t i, j, ind; @@ -247,15 +250,16 @@ static WebPEncodingError PaletteSortModifiedZeng( uint32_t first, last; uint32_t num_sums; // TODO(vrabaud) check whether one color images should use palette or not. - if (num_colors <= 1) return VP8_ENC_OK; + if (num_colors <= 1) return 1; // Build the co-occurrence matrix. cooccurrence = (uint32_t*)WebPSafeCalloc(num_colors * num_colors, sizeof(*cooccurrence)); - if (cooccurrence == NULL) return VP8_ENC_ERROR_OUT_OF_MEMORY; - if (CoOccurrenceBuild(pic, palette_sorted, num_colors, cooccurrence) != - VP8_ENC_OK) { - WebPSafeFree(cooccurrence); - return VP8_ENC_ERROR_OUT_OF_MEMORY; + if (cooccurrence == NULL) { + WebPEncodingSetError(pic, VP8_ENC_ERROR_OUT_OF_MEMORY); + return 0; + } + if (!CoOccurrenceBuild(pic, palette_sorted, num_colors, cooccurrence)) { + return 0; } // Initialize the mapping list with the two best indices. @@ -316,7 +320,7 @@ static WebPEncodingError PaletteSortModifiedZeng( for (i = 0; i < num_colors; ++i) { palette[i] = palette_sorted[remapping[(first + i) % num_colors]]; } - return VP8_ENC_OK; + return 1; } // ----------------------------------------------------------------------------- @@ -434,8 +438,8 @@ static int AnalyzeEntropy(const uint32_t* argb, curr_row += argb_stride; } { - double entropy_comp[kHistoTotal]; - double entropy[kNumEntropyIx]; + float entropy_comp[kHistoTotal]; + float entropy[kNumEntropyIx]; int k; int last_mode_to_analyze = use_palette ? kPalette : kSpatialSubGreen; int j; @@ -949,11 +953,11 @@ static WEBP_INLINE void WriteHuffmanCodeWithExtraBits( VP8LPutBits(bw, (bits << depth) | symbol, depth + n_bits); } -static WebPEncodingError StoreImageToBitMask( +static int StoreImageToBitMask( VP8LBitWriter* const bw, int width, int histo_bits, const VP8LBackwardRefs* const refs, const uint16_t* histogram_symbols, - const HuffmanTreeCode* const huffman_codes) { + const HuffmanTreeCode* const huffman_codes, const WebPPicture* const pic) { const int histo_xsize = histo_bits ? VP8LSubSampleSize(width, histo_bits) : 1; const int tile_mask = (histo_bits == 0) ? 0 : -(1 << histo_bits); // x and y trace the position in the image. @@ -1006,44 +1010,53 @@ static WebPEncodingError StoreImageToBitMask( } VP8LRefsCursorNext(&c); } - return bw->error_ ? VP8_ENC_ERROR_OUT_OF_MEMORY : VP8_ENC_OK; + if (bw->error_) { + WebPEncodingSetError(pic, VP8_ENC_ERROR_OUT_OF_MEMORY); + return 0; + } + return 1; } -// Special case of EncodeImageInternal() for cache-bits=0, histo_bits=31 -static WebPEncodingError EncodeImageNoHuffman( - VP8LBitWriter* const bw, const uint32_t* const argb, - VP8LHashChain* const hash_chain, VP8LBackwardRefs* const refs_array, - int width, int height, int quality, int low_effort) { +// Special case of EncodeImageInternal() for cache-bits=0, histo_bits=31. +// pic and percent are for progress. +static int EncodeImageNoHuffman(VP8LBitWriter* const bw, + const uint32_t* const argb, + VP8LHashChain* const hash_chain, + VP8LBackwardRefs* const refs_array, int width, + int height, int quality, int low_effort, + const WebPPicture* const pic, int percent_range, + int* const percent) { int i; int max_tokens = 0; - WebPEncodingError err = VP8_ENC_OK; VP8LBackwardRefs* refs; HuffmanTreeToken* tokens = NULL; - HuffmanTreeCode huffman_codes[5] = { { 0, NULL, NULL } }; - const uint16_t histogram_symbols[1] = { 0 }; // only one tree, one symbol + HuffmanTreeCode huffman_codes[5] = {{0, NULL, NULL}}; + const uint16_t histogram_symbols[1] = {0}; // only one tree, one symbol int cache_bits = 0; VP8LHistogramSet* histogram_image = NULL; HuffmanTree* const huff_tree = (HuffmanTree*)WebPSafeMalloc( - 3ULL * CODE_LENGTH_CODES, sizeof(*huff_tree)); + 3ULL * CODE_LENGTH_CODES, sizeof(*huff_tree)); if (huff_tree == NULL) { - err = VP8_ENC_ERROR_OUT_OF_MEMORY; + WebPEncodingSetError(pic, VP8_ENC_ERROR_OUT_OF_MEMORY); goto Error; } // Calculate backward references from ARGB image. - if (!VP8LHashChainFill(hash_chain, quality, argb, width, height, - low_effort)) { - err = VP8_ENC_ERROR_OUT_OF_MEMORY; + if (!VP8LHashChainFill(hash_chain, quality, argb, width, height, low_effort, + pic, percent_range / 2, percent)) { + goto Error; + } + if (!VP8LGetBackwardReferences(width, height, argb, quality, /*low_effort=*/0, + kLZ77Standard | kLZ77RLE, cache_bits, + /*do_no_cache=*/0, hash_chain, refs_array, + &cache_bits, pic, + percent_range - percent_range / 2, percent)) { goto Error; } - err = VP8LGetBackwardReferences( - width, height, argb, quality, /*low_effort=*/0, kLZ77Standard | kLZ77RLE, - cache_bits, /*do_no_cache=*/0, hash_chain, refs_array, &cache_bits); - if (err != VP8_ENC_OK) goto Error; refs = &refs_array[0]; histogram_image = VP8LAllocateHistogramSet(1, cache_bits); if (histogram_image == NULL) { - err = VP8_ENC_ERROR_OUT_OF_MEMORY; + WebPEncodingSetError(pic, VP8_ENC_ERROR_OUT_OF_MEMORY); goto Error; } VP8LHistogramSetClear(histogram_image); @@ -1054,7 +1067,7 @@ static WebPEncodingError EncodeImageNoHuffman( // Create Huffman bit lengths and codes for each histogram image. assert(histogram_image->size == 1); if (!GetHuffBitLengthsAndCodes(histogram_image, huffman_codes)) { - err = VP8_ENC_ERROR_OUT_OF_MEMORY; + WebPEncodingSetError(pic, VP8_ENC_ERROR_OUT_OF_MEMORY); goto Error; } @@ -1071,7 +1084,7 @@ static WebPEncodingError EncodeImageNoHuffman( tokens = (HuffmanTreeToken*)WebPSafeMalloc(max_tokens, sizeof(*tokens)); if (tokens == NULL) { - err = VP8_ENC_ERROR_OUT_OF_MEMORY; + WebPEncodingSetError(pic, VP8_ENC_ERROR_OUT_OF_MEMORY); goto Error; } @@ -1083,27 +1096,32 @@ static WebPEncodingError EncodeImageNoHuffman( } // Store actual literals. - err = StoreImageToBitMask(bw, width, 0, refs, histogram_symbols, - huffman_codes); + if (!StoreImageToBitMask(bw, width, 0, refs, histogram_symbols, huffman_codes, + pic)) { + goto Error; + } Error: WebPSafeFree(tokens); WebPSafeFree(huff_tree); VP8LFreeHistogramSet(histogram_image); WebPSafeFree(huffman_codes[0].codes); - return err; + return (pic->error_code == VP8_ENC_OK); } -static WebPEncodingError EncodeImageInternal( +// pic and percent are for progress. +static int EncodeImageInternal( VP8LBitWriter* const bw, const uint32_t* const argb, VP8LHashChain* const hash_chain, VP8LBackwardRefs refs_array[4], int width, int height, int quality, int low_effort, int use_cache, const CrunchConfig* const config, int* cache_bits, int histogram_bits, - size_t init_byte_position, int* const hdr_size, int* const data_size) { - WebPEncodingError err = VP8_ENC_ERROR_OUT_OF_MEMORY; + size_t init_byte_position, int* const hdr_size, int* const data_size, + const WebPPicture* const pic, int percent_range, int* const percent) { const uint32_t histogram_image_xysize = VP8LSubSampleSize(width, histogram_bits) * VP8LSubSampleSize(height, histogram_bits); + int remaining_percent = percent_range; + int percent_start = *percent; VP8LHistogramSet* histogram_image = NULL; VP8LHistogram* tmp_histo = NULL; int histogram_image_size = 0; @@ -1112,9 +1130,8 @@ static WebPEncodingError EncodeImageInternal( 3ULL * CODE_LENGTH_CODES, sizeof(*huff_tree)); HuffmanTreeToken* tokens = NULL; HuffmanTreeCode* huffman_codes = NULL; - uint16_t* const histogram_symbols = - (uint16_t*)WebPSafeMalloc(histogram_image_xysize, - sizeof(*histogram_symbols)); + uint16_t* const histogram_symbols = (uint16_t*)WebPSafeMalloc( + histogram_image_xysize, sizeof(*histogram_symbols)); int sub_configs_idx; int cache_bits_init, write_histogram_image; VP8LBitWriter bw_init = *bw, bw_best; @@ -1126,14 +1143,27 @@ static WebPEncodingError EncodeImageInternal( assert(hdr_size != NULL); assert(data_size != NULL); - // Make sure we can allocate the different objects. memset(&hash_chain_histogram, 0, sizeof(hash_chain_histogram)); - if (huff_tree == NULL || histogram_symbols == NULL || - !VP8LHashChainInit(&hash_chain_histogram, histogram_image_xysize) || - !VP8LHashChainFill(hash_chain, quality, argb, width, height, - low_effort)) { + if (!VP8LBitWriterInit(&bw_best, 0)) { + WebPEncodingSetError(pic, VP8_ENC_ERROR_OUT_OF_MEMORY); goto Error; } + + // Make sure we can allocate the different objects. + if (huff_tree == NULL || histogram_symbols == NULL || + !VP8LHashChainInit(&hash_chain_histogram, histogram_image_xysize)) { + WebPEncodingSetError(pic, VP8_ENC_ERROR_OUT_OF_MEMORY); + goto Error; + } + + percent_range = remaining_percent / 5; + if (!VP8LHashChainFill(hash_chain, quality, argb, width, height, + low_effort, pic, percent_range, percent)) { + goto Error; + } + percent_start += percent_range; + remaining_percent -= percent_range; + if (use_cache) { // If the value is different from zero, it has been set during the // palette analysis. @@ -1142,22 +1172,27 @@ static WebPEncodingError EncodeImageInternal( cache_bits_init = 0; } // If several iterations will happen, clone into bw_best. - if (!VP8LBitWriterInit(&bw_best, 0) || - ((config->sub_configs_size_ > 1 || - config->sub_configs_[0].do_no_cache_) && - !VP8LBitWriterClone(bw, &bw_best))) { + if ((config->sub_configs_size_ > 1 || config->sub_configs_[0].do_no_cache_) && + !VP8LBitWriterClone(bw, &bw_best)) { + WebPEncodingSetError(pic, VP8_ENC_ERROR_OUT_OF_MEMORY); goto Error; } + for (sub_configs_idx = 0; sub_configs_idx < config->sub_configs_size_; ++sub_configs_idx) { const CrunchSubConfig* const sub_config = &config->sub_configs_[sub_configs_idx]; int cache_bits_best, i_cache; - err = VP8LGetBackwardReferences(width, height, argb, quality, low_effort, - sub_config->lz77_, cache_bits_init, - sub_config->do_no_cache_, hash_chain, - &refs_array[0], &cache_bits_best); - if (err != VP8_ENC_OK) goto Error; + int i_remaining_percent = remaining_percent / config->sub_configs_size_; + int i_percent_range = i_remaining_percent / 4; + i_remaining_percent -= i_percent_range; + + if (!VP8LGetBackwardReferences( + width, height, argb, quality, low_effort, sub_config->lz77_, + cache_bits_init, sub_config->do_no_cache_, hash_chain, + &refs_array[0], &cache_bits_best, pic, i_percent_range, percent)) { + goto Error; + } for (i_cache = 0; i_cache < (sub_config->do_no_cache_ ? 2 : 1); ++i_cache) { const int cache_bits_tmp = (i_cache == 0) ? cache_bits_best : 0; @@ -1172,11 +1207,17 @@ static WebPEncodingError EncodeImageInternal( histogram_image = VP8LAllocateHistogramSet(histogram_image_xysize, cache_bits_tmp); tmp_histo = VP8LAllocateHistogram(cache_bits_tmp); - if (histogram_image == NULL || tmp_histo == NULL || - !VP8LGetHistoImageSymbols(width, height, &refs_array[i_cache], - quality, low_effort, histogram_bits, - cache_bits_tmp, histogram_image, tmp_histo, - histogram_symbols)) { + if (histogram_image == NULL || tmp_histo == NULL) { + WebPEncodingSetError(pic, VP8_ENC_ERROR_OUT_OF_MEMORY); + goto Error; + } + + i_percent_range = i_remaining_percent / 3; + i_remaining_percent -= i_percent_range; + if (!VP8LGetHistoImageSymbols( + width, height, &refs_array[i_cache], quality, low_effort, + histogram_bits, cache_bits_tmp, histogram_image, tmp_histo, + histogram_symbols, pic, i_percent_range, percent)) { goto Error; } // Create Huffman bit lengths and codes for each histogram image. @@ -1189,6 +1230,7 @@ static WebPEncodingError EncodeImageInternal( // GetHuffBitLengthsAndCodes(). if (huffman_codes == NULL || !GetHuffBitLengthsAndCodes(histogram_image, huffman_codes)) { + WebPEncodingSetError(pic, VP8_ENC_ERROR_OUT_OF_MEMORY); goto Error; } // Free combined histograms. @@ -1211,12 +1253,14 @@ static WebPEncodingError EncodeImageInternal( write_histogram_image = (histogram_image_size > 1); VP8LPutBits(bw, write_histogram_image, 1); if (write_histogram_image) { - uint32_t* const histogram_argb = - (uint32_t*)WebPSafeMalloc(histogram_image_xysize, - sizeof(*histogram_argb)); + uint32_t* const histogram_argb = (uint32_t*)WebPSafeMalloc( + histogram_image_xysize, sizeof(*histogram_argb)); int max_index = 0; uint32_t i; - if (histogram_argb == NULL) goto Error; + if (histogram_argb == NULL) { + WebPEncodingSetError(pic, VP8_ENC_ERROR_OUT_OF_MEMORY); + goto Error; + } for (i = 0; i < histogram_image_xysize; ++i) { const int symbol_index = histogram_symbols[i] & 0xffff; histogram_argb[i] = (symbol_index << 8); @@ -1227,12 +1271,17 @@ static WebPEncodingError EncodeImageInternal( histogram_image_size = max_index; VP8LPutBits(bw, histogram_bits - 2, 3); - err = EncodeImageNoHuffman( - bw, histogram_argb, &hash_chain_histogram, &refs_array[2], - VP8LSubSampleSize(width, histogram_bits), - VP8LSubSampleSize(height, histogram_bits), quality, low_effort); + i_percent_range = i_remaining_percent / 2; + i_remaining_percent -= i_percent_range; + if (!EncodeImageNoHuffman( + bw, histogram_argb, &hash_chain_histogram, &refs_array[2], + VP8LSubSampleSize(width, histogram_bits), + VP8LSubSampleSize(height, histogram_bits), quality, low_effort, + pic, i_percent_range, percent)) { + WebPSafeFree(histogram_argb); + goto Error; + } WebPSafeFree(histogram_argb); - if (err != VP8_ENC_OK) goto Error; } // Store Huffman codes. @@ -1256,9 +1305,10 @@ static WebPEncodingError EncodeImageInternal( } // Store actual literals. hdr_size_tmp = (int)(VP8LBitWriterNumBytes(bw) - init_byte_position); - err = StoreImageToBitMask(bw, width, histogram_bits, &refs_array[i_cache], - histogram_symbols, huffman_codes); - if (err != VP8_ENC_OK) goto Error; + if (!StoreImageToBitMask(bw, width, histogram_bits, &refs_array[i_cache], + histogram_symbols, huffman_codes, pic)) { + goto Error; + } // Keep track of the smallest image so far. if (VP8LBitWriterNumBytes(bw) < bw_size_best) { bw_size_best = VP8LBitWriterNumBytes(bw); @@ -1278,7 +1328,10 @@ static WebPEncodingError EncodeImageInternal( } } VP8LBitWriterSwap(bw, &bw_best); - err = VP8_ENC_OK; + + if (!WebPReportProgress(pic, percent_start + remaining_percent, percent)) { + goto Error; + } Error: WebPSafeFree(tokens); @@ -1292,7 +1345,7 @@ static WebPEncodingError EncodeImageInternal( } WebPSafeFree(histogram_symbols); VP8LBitWriterWipeOut(&bw_best); - return err; + return (pic->error_code == VP8_ENC_OK); } // ----------------------------------------------------------------------------- @@ -1305,22 +1358,23 @@ static void ApplySubtractGreen(VP8LEncoder* const enc, int width, int height, VP8LSubtractGreenFromBlueAndRed(enc->argb_, width * height); } -static WebPEncodingError ApplyPredictFilter(const VP8LEncoder* const enc, - int width, int height, - int quality, int low_effort, - int used_subtract_green, - VP8LBitWriter* const bw) { +static int ApplyPredictFilter(const VP8LEncoder* const enc, int width, + int height, int quality, int low_effort, + int used_subtract_green, VP8LBitWriter* const bw, + int percent_range, int* const percent) { const int pred_bits = enc->transform_bits_; const int transform_width = VP8LSubSampleSize(width, pred_bits); const int transform_height = VP8LSubSampleSize(height, pred_bits); // we disable near-lossless quantization if palette is used. - const int near_lossless_strength = enc->use_palette_ ? 100 - : enc->config_->near_lossless; + const int near_lossless_strength = + enc->use_palette_ ? 100 : enc->config_->near_lossless; - VP8LResidualImage(width, height, pred_bits, low_effort, enc->argb_, - enc->argb_scratch_, enc->transform_data_, - near_lossless_strength, enc->config_->exact, - used_subtract_green); + if (!VP8LResidualImage( + width, height, pred_bits, low_effort, enc->argb_, enc->argb_scratch_, + enc->transform_data_, near_lossless_strength, enc->config_->exact, + used_subtract_green, enc->pic_, percent_range / 2, percent)) { + return 0; + } VP8LPutBits(bw, TRANSFORM_PRESENT, 1); VP8LPutBits(bw, PREDICTOR_TRANSFORM, 2); assert(pred_bits >= 2); @@ -1328,19 +1382,23 @@ static WebPEncodingError ApplyPredictFilter(const VP8LEncoder* const enc, return EncodeImageNoHuffman( bw, enc->transform_data_, (VP8LHashChain*)&enc->hash_chain_, (VP8LBackwardRefs*)&enc->refs_[0], transform_width, transform_height, - quality, low_effort); + quality, low_effort, enc->pic_, percent_range - percent_range / 2, + percent); } -static WebPEncodingError ApplyCrossColorFilter(const VP8LEncoder* const enc, - int width, int height, - int quality, int low_effort, - VP8LBitWriter* const bw) { +static int ApplyCrossColorFilter(const VP8LEncoder* const enc, int width, + int height, int quality, int low_effort, + VP8LBitWriter* const bw, int percent_range, + int* const percent) { const int ccolor_transform_bits = enc->transform_bits_; const int transform_width = VP8LSubSampleSize(width, ccolor_transform_bits); const int transform_height = VP8LSubSampleSize(height, ccolor_transform_bits); - VP8LColorSpaceTransform(width, height, ccolor_transform_bits, quality, - enc->argb_, enc->transform_data_); + if (!VP8LColorSpaceTransform(width, height, ccolor_transform_bits, quality, + enc->argb_, enc->transform_data_, enc->pic_, + percent_range / 2, percent)) { + return 0; + } VP8LPutBits(bw, TRANSFORM_PRESENT, 1); VP8LPutBits(bw, CROSS_COLOR_TRANSFORM, 2); assert(ccolor_transform_bits >= 2); @@ -1348,23 +1406,21 @@ static WebPEncodingError ApplyCrossColorFilter(const VP8LEncoder* const enc, return EncodeImageNoHuffman( bw, enc->transform_data_, (VP8LHashChain*)&enc->hash_chain_, (VP8LBackwardRefs*)&enc->refs_[0], transform_width, transform_height, - quality, low_effort); + quality, low_effort, enc->pic_, percent_range - percent_range / 2, + percent); } // ----------------------------------------------------------------------------- -static WebPEncodingError WriteRiffHeader(const WebPPicture* const pic, - size_t riff_size, size_t vp8l_size) { +static int WriteRiffHeader(const WebPPicture* const pic, size_t riff_size, + size_t vp8l_size) { uint8_t riff[RIFF_HEADER_SIZE + CHUNK_HEADER_SIZE + VP8L_SIGNATURE_SIZE] = { 'R', 'I', 'F', 'F', 0, 0, 0, 0, 'W', 'E', 'B', 'P', 'V', 'P', '8', 'L', 0, 0, 0, 0, VP8L_MAGIC_BYTE, }; PutLE32(riff + TAG_SIZE, (uint32_t)riff_size); PutLE32(riff + RIFF_HEADER_SIZE + TAG_SIZE, (uint32_t)vp8l_size); - if (!pic->writer(riff, sizeof(riff), pic)) { - return VP8_ENC_ERROR_BAD_WRITE; - } - return VP8_ENC_OK; + return pic->writer(riff, sizeof(riff), pic); } static int WriteImageSize(const WebPPicture* const pic, @@ -1384,36 +1440,29 @@ static int WriteRealAlphaAndVersion(VP8LBitWriter* const bw, int has_alpha) { return !bw->error_; } -static WebPEncodingError WriteImage(const WebPPicture* const pic, - VP8LBitWriter* const bw, - size_t* const coded_size) { - WebPEncodingError err = VP8_ENC_OK; +static int WriteImage(const WebPPicture* const pic, VP8LBitWriter* const bw, + size_t* const coded_size) { const uint8_t* const webpll_data = VP8LBitWriterFinish(bw); const size_t webpll_size = VP8LBitWriterNumBytes(bw); const size_t vp8l_size = VP8L_SIGNATURE_SIZE + webpll_size; const size_t pad = vp8l_size & 1; const size_t riff_size = TAG_SIZE + CHUNK_HEADER_SIZE + vp8l_size + pad; - err = WriteRiffHeader(pic, riff_size, vp8l_size); - if (err != VP8_ENC_OK) goto Error; - - if (!pic->writer(webpll_data, webpll_size, pic)) { - err = VP8_ENC_ERROR_BAD_WRITE; - goto Error; + if (!WriteRiffHeader(pic, riff_size, vp8l_size) || + !pic->writer(webpll_data, webpll_size, pic)) { + WebPEncodingSetError(pic, VP8_ENC_ERROR_BAD_WRITE); + return 0; } if (pad) { const uint8_t pad_byte[1] = { 0 }; if (!pic->writer(pad_byte, 1, pic)) { - err = VP8_ENC_ERROR_BAD_WRITE; - goto Error; + WebPEncodingSetError(pic, VP8_ENC_ERROR_BAD_WRITE); + return 0; } } *coded_size = CHUNK_HEADER_SIZE + riff_size; - return VP8_ENC_OK; - - Error: - return err; + return 1; } // ----------------------------------------------------------------------------- @@ -1429,18 +1478,16 @@ static void ClearTransformBuffer(VP8LEncoder* const enc) { // Flags influencing the memory allocated: // enc->transform_bits_ // enc->use_predict_, enc->use_cross_color_ -static WebPEncodingError AllocateTransformBuffer(VP8LEncoder* const enc, - int width, int height) { - WebPEncodingError err = VP8_ENC_OK; +static int AllocateTransformBuffer(VP8LEncoder* const enc, int width, + int height) { const uint64_t image_size = width * height; // VP8LResidualImage needs room for 2 scanlines of uint32 pixels with an extra // pixel in each, plus 2 regular scanlines of bytes. // TODO(skal): Clean up by using arithmetic in bytes instead of words. const uint64_t argb_scratch_size = - enc->use_predict_ - ? (width + 1) * 2 + - (width * 2 + sizeof(uint32_t) - 1) / sizeof(uint32_t) - : 0; + enc->use_predict_ ? (width + 1) * 2 + (width * 2 + sizeof(uint32_t) - 1) / + sizeof(uint32_t) + : 0; const uint64_t transform_data_size = (enc->use_predict_ || enc->use_cross_color_) ? VP8LSubSampleSize(width, enc->transform_bits_) * @@ -1448,17 +1495,16 @@ static WebPEncodingError AllocateTransformBuffer(VP8LEncoder* const enc, : 0; const uint64_t max_alignment_in_words = (WEBP_ALIGN_CST + sizeof(uint32_t) - 1) / sizeof(uint32_t); - const uint64_t mem_size = - image_size + max_alignment_in_words + - argb_scratch_size + max_alignment_in_words + - transform_data_size; + const uint64_t mem_size = image_size + max_alignment_in_words + + argb_scratch_size + max_alignment_in_words + + transform_data_size; uint32_t* mem = enc->transform_mem_; if (mem == NULL || mem_size > enc->transform_mem_size_) { ClearTransformBuffer(enc); mem = (uint32_t*)WebPSafeMalloc(mem_size, sizeof(*mem)); if (mem == NULL) { - err = VP8_ENC_ERROR_OUT_OF_MEMORY; - goto Error; + WebPEncodingSetError(enc->pic_, VP8_ENC_ERROR_OUT_OF_MEMORY); + return 0; } enc->transform_mem_ = mem; enc->transform_mem_size_ = (size_t)mem_size; @@ -1471,19 +1517,16 @@ static WebPEncodingError AllocateTransformBuffer(VP8LEncoder* const enc, enc->transform_data_ = mem; enc->current_width_ = width; - Error: - return err; + return 1; } -static WebPEncodingError MakeInputImageCopy(VP8LEncoder* const enc) { - WebPEncodingError err = VP8_ENC_OK; +static int MakeInputImageCopy(VP8LEncoder* const enc) { const WebPPicture* const picture = enc->pic_; const int width = picture->width; const int height = picture->height; - err = AllocateTransformBuffer(enc, width, height); - if (err != VP8_ENC_OK) return err; - if (enc->argb_content_ == kEncoderARGB) return VP8_ENC_OK; + if (!AllocateTransformBuffer(enc, width, height)) return 0; + if (enc->argb_content_ == kEncoderARGB) return 1; { uint32_t* dst = enc->argb_; @@ -1497,7 +1540,7 @@ static WebPEncodingError MakeInputImageCopy(VP8LEncoder* const enc) { } enc->argb_content_ = kEncoderARGB; assert(enc->current_width_ == width); - return VP8_ENC_OK; + return 1; } // ----------------------------------------------------------------------------- @@ -1559,16 +1602,19 @@ static WEBP_INLINE uint32_t ApplyPaletteHash2(uint32_t color) { // using 'row' as a temporary buffer of size 'width'. // We assume that all src[] values have a corresponding entry in the palette. // Note: src[] can be the same as dst[] -static WebPEncodingError ApplyPalette(const uint32_t* src, uint32_t src_stride, - uint32_t* dst, uint32_t dst_stride, - const uint32_t* palette, int palette_size, - int width, int height, int xbits) { +static int ApplyPalette(const uint32_t* src, uint32_t src_stride, uint32_t* dst, + uint32_t dst_stride, const uint32_t* palette, + int palette_size, int width, int height, int xbits, + const WebPPicture* const pic) { // TODO(skal): this tmp buffer is not needed if VP8LBundleColorMap() can be // made to work in-place. uint8_t* const tmp_row = (uint8_t*)WebPSafeMalloc(width, sizeof(*tmp_row)); int x, y; - if (tmp_row == NULL) return VP8_ENC_ERROR_OUT_OF_MEMORY; + if (tmp_row == NULL) { + WebPEncodingSetError(pic, VP8_ENC_ERROR_OUT_OF_MEMORY); + return 0; + } if (palette_size < APPLY_PALETTE_GREEDY_MAX) { APPLY_PALETTE_FOR(SearchColorGreedy(palette, palette_size, pix)); @@ -1613,7 +1659,7 @@ static WebPEncodingError ApplyPalette(const uint32_t* src, uint32_t src_stride, } } WebPSafeFree(tmp_row); - return VP8_ENC_OK; + return 1; } #undef APPLY_PALETTE_FOR #undef PALETTE_INV_SIZE_BITS @@ -1621,9 +1667,7 @@ static WebPEncodingError ApplyPalette(const uint32_t* src, uint32_t src_stride, #undef APPLY_PALETTE_GREEDY_MAX // Note: Expects "enc->palette_" to be set properly. -static WebPEncodingError MapImageFromPalette(VP8LEncoder* const enc, - int in_place) { - WebPEncodingError err = VP8_ENC_OK; +static int MapImageFromPalette(VP8LEncoder* const enc, int in_place) { const WebPPicture* const pic = enc->pic_; const int width = pic->width; const int height = pic->height; @@ -1641,19 +1685,22 @@ static WebPEncodingError MapImageFromPalette(VP8LEncoder* const enc, xbits = (palette_size <= 16) ? 1 : 0; } - err = AllocateTransformBuffer(enc, VP8LSubSampleSize(width, xbits), height); - if (err != VP8_ENC_OK) return err; - - err = ApplyPalette(src, src_stride, + if (!AllocateTransformBuffer(enc, VP8LSubSampleSize(width, xbits), height)) { + return 0; + } + if (!ApplyPalette(src, src_stride, enc->argb_, enc->current_width_, - palette, palette_size, width, height, xbits); + palette, palette_size, width, height, xbits, pic)) { + return 0; + } enc->argb_content_ = kEncoderPalette; - return err; + return 1; } // Save palette_[] to bitstream. static WebPEncodingError EncodePalette(VP8LBitWriter* const bw, int low_effort, - VP8LEncoder* const enc) { + VP8LEncoder* const enc, + int percent_range, int* const percent) { int i; uint32_t tmp_palette[MAX_PALETTE_SIZE]; const int palette_size = enc->palette_size_; @@ -1668,7 +1715,7 @@ static WebPEncodingError EncodePalette(VP8LBitWriter* const bw, int low_effort, tmp_palette[0] = palette[0]; return EncodeImageNoHuffman(bw, tmp_palette, &enc->hash_chain_, &enc->refs_[0], palette_size, 1, /*quality=*/20, - low_effort); + low_effort, enc->pic_, percent_range, percent); } // ----------------------------------------------------------------------------- @@ -1712,7 +1759,6 @@ typedef struct { CrunchConfig crunch_configs_[CRUNCH_CONFIGS_MAX]; int num_crunch_configs_; int red_and_blue_always_zero_; - WebPEncodingError err_; WebPAuxStats* stats_; } StreamEncodeContext; @@ -1729,7 +1775,6 @@ static int EncodeStreamHook(void* input, void* data2) { #if !defined(WEBP_DISABLE_STATS) WebPAuxStats* const stats = params->stats_; #endif - WebPEncodingError err = VP8_ENC_OK; const int quality = (int)config->quality; const int low_effort = (config->method == 0); #if (WEBP_NEAR_LOSSLESS == 1) @@ -1737,6 +1782,7 @@ static int EncodeStreamHook(void* input, void* data2) { #endif const int height = picture->height; const size_t byte_position = VP8LBitWriterNumBytes(bw); + int percent = 2; // for WebPProgressHook #if (WEBP_NEAR_LOSSLESS == 1) int use_near_lossless = 0; #endif @@ -1750,12 +1796,13 @@ static int EncodeStreamHook(void* input, void* data2) { if (!VP8LBitWriterInit(&bw_best, 0) || (num_crunch_configs > 1 && !VP8LBitWriterClone(bw, &bw_best))) { - err = VP8_ENC_ERROR_OUT_OF_MEMORY; + WebPEncodingSetError(picture, VP8_ENC_ERROR_OUT_OF_MEMORY); goto Error; } for (idx = 0; idx < num_crunch_configs; ++idx) { const int entropy_idx = crunch_configs[idx].entropy_idx_; + int remaining_percent = 97 / num_crunch_configs, percent_range; enc->use_palette_ = (entropy_idx == kPalette) || (entropy_idx == kPaletteAndSpatial); enc->use_subtract_green_ = @@ -1779,11 +1826,10 @@ static int EncodeStreamHook(void* input, void* data2) { use_near_lossless = (config->near_lossless < 100) && !enc->use_palette_ && !enc->use_predict_; if (use_near_lossless) { - err = AllocateTransformBuffer(enc, width, height); - if (err != VP8_ENC_OK) goto Error; + if (!AllocateTransformBuffer(enc, width, height)) goto Error; if ((enc->argb_content_ != kEncoderNearLossless) && !VP8ApplyNearLossless(picture, config->near_lossless, enc->argb_)) { - err = VP8_ENC_ERROR_OUT_OF_MEMORY; + WebPEncodingSetError(picture, VP8_ENC_ERROR_OUT_OF_MEMORY); goto Error; } enc->argb_content_ = kEncoderNearLossless; @@ -1805,14 +1851,17 @@ static int EncodeStreamHook(void* input, void* data2) { enc->palette_); } else { assert(crunch_configs[idx].palette_sorting_type_ == kModifiedZeng); - err = PaletteSortModifiedZeng(enc->pic_, enc->palette_sorted_, - enc->palette_size_, enc->palette_); - if (err != VP8_ENC_OK) goto Error; + if (!PaletteSortModifiedZeng(enc->pic_, enc->palette_sorted_, + enc->palette_size_, enc->palette_)) { + goto Error; + } } - err = EncodePalette(bw, low_effort, enc); - if (err != VP8_ENC_OK) goto Error; - err = MapImageFromPalette(enc, use_delta_palette); - if (err != VP8_ENC_OK) goto Error; + percent_range = remaining_percent / 4; + if (!EncodePalette(bw, low_effort, enc, percent_range, &percent)) { + goto Error; + } + remaining_percent -= percent_range; + if (!MapImageFromPalette(enc, use_delta_palette)) goto Error; // If using a color cache, do not have it bigger than the number of // colors. if (use_cache && enc->palette_size_ < (1 << MAX_COLOR_CACHE_BITS)) { @@ -1823,8 +1872,7 @@ static int EncodeStreamHook(void* input, void* data2) { // In case image is not packed. if (enc->argb_content_ != kEncoderNearLossless && enc->argb_content_ != kEncoderPalette) { - err = MakeInputImageCopy(enc); - if (err != VP8_ENC_OK) goto Error; + if (!MakeInputImageCopy(enc)) goto Error; } // ----------------------------------------------------------------------- @@ -1835,15 +1883,22 @@ static int EncodeStreamHook(void* input, void* data2) { } if (enc->use_predict_) { - err = ApplyPredictFilter(enc, enc->current_width_, height, quality, - low_effort, enc->use_subtract_green_, bw); - if (err != VP8_ENC_OK) goto Error; + percent_range = remaining_percent / 3; + if (!ApplyPredictFilter(enc, enc->current_width_, height, quality, + low_effort, enc->use_subtract_green_, bw, + percent_range, &percent)) { + goto Error; + } + remaining_percent -= percent_range; } if (enc->use_cross_color_) { - err = ApplyCrossColorFilter(enc, enc->current_width_, height, quality, - low_effort, bw); - if (err != VP8_ENC_OK) goto Error; + percent_range = remaining_percent / 2; + if (!ApplyCrossColorFilter(enc, enc->current_width_, height, quality, + low_effort, bw, percent_range, &percent)) { + goto Error; + } + remaining_percent -= percent_range; } } @@ -1851,12 +1906,13 @@ static int EncodeStreamHook(void* input, void* data2) { // ------------------------------------------------------------------------- // Encode and write the transformed image. - err = EncodeImageInternal(bw, enc->argb_, &enc->hash_chain_, enc->refs_, - enc->current_width_, height, quality, low_effort, - use_cache, &crunch_configs[idx], - &enc->cache_bits_, enc->histo_bits_, - byte_position, &hdr_size, &data_size); - if (err != VP8_ENC_OK) goto Error; + if (!EncodeImageInternal( + bw, enc->argb_, &enc->hash_chain_, enc->refs_, enc->current_width_, + height, quality, low_effort, use_cache, &crunch_configs[idx], + &enc->cache_bits_, enc->histo_bits_, byte_position, &hdr_size, + &data_size, picture, remaining_percent, &percent)) { + goto Error; + } // If we are better than what we already have. if (VP8LBitWriterNumBytes(bw) < best_size) { @@ -1886,18 +1942,15 @@ static int EncodeStreamHook(void* input, void* data2) { } VP8LBitWriterSwap(&bw_best, bw); -Error: + Error: VP8LBitWriterWipeOut(&bw_best); - params->err_ = err; // The hook should return false in case of error. - return (err == VP8_ENC_OK); + return (params->picture_->error_code == VP8_ENC_OK); } -WebPEncodingError VP8LEncodeStream(const WebPConfig* const config, - const WebPPicture* const picture, - VP8LBitWriter* const bw_main, - int use_cache) { - WebPEncodingError err = VP8_ENC_OK; +int VP8LEncodeStream(const WebPConfig* const config, + const WebPPicture* const picture, + VP8LBitWriter* const bw_main, int use_cache) { VP8LEncoder* const enc_main = VP8LEncoderNew(config, picture); VP8LEncoder* enc_side = NULL; CrunchConfig crunch_configs[CRUNCH_CONFIGS_MAX]; @@ -1909,15 +1962,24 @@ WebPEncodingError VP8LEncodeStream(const WebPConfig* const config, // The main thread uses picture->stats, the side thread uses stats_side. WebPAuxStats stats_side; VP8LBitWriter bw_side; + WebPPicture picture_side; const WebPWorkerInterface* const worker_interface = WebPGetWorkerInterface(); int ok_main; + if (enc_main == NULL || !VP8LBitWriterInit(&bw_side, 0)) { + WebPEncodingSetError(picture, VP8_ENC_ERROR_OUT_OF_MEMORY); + VP8LEncoderDelete(enc_main); + return 0; + } + + // Avoid "garbage value" error from Clang's static analysis tool. + WebPPictureInit(&picture_side); + // Analyze image (entropy, num_palettes etc) - if (enc_main == NULL || - !EncoderAnalyze(enc_main, crunch_configs, &num_crunch_configs_main, + if (!EncoderAnalyze(enc_main, crunch_configs, &num_crunch_configs_main, &red_and_blue_always_zero) || - !EncoderInit(enc_main) || !VP8LBitWriterInit(&bw_side, 0)) { - err = VP8_ENC_ERROR_OUT_OF_MEMORY; + !EncoderInit(enc_main)) { + WebPEncodingSetError(picture, VP8_ENC_ERROR_OUT_OF_MEMORY); goto Error; } @@ -1946,25 +2008,32 @@ WebPEncodingError VP8LEncodeStream(const WebPConfig* const config, StreamEncodeContext* const param = (idx == 0) ? ¶ms_main : ¶ms_side; param->config_ = config; - param->picture_ = picture; param->use_cache_ = use_cache; param->red_and_blue_always_zero_ = red_and_blue_always_zero; if (idx == 0) { + param->picture_ = picture; param->stats_ = picture->stats; param->bw_ = bw_main; param->enc_ = enc_main; } else { + // Create a side picture (error_code is not thread-safe). + if (!WebPPictureView(picture, /*left=*/0, /*top=*/0, picture->width, + picture->height, &picture_side)) { + assert(0); + } + picture_side.progress_hook = NULL; // Progress hook is not thread-safe. + param->picture_ = &picture_side; // No need to free a view afterwards. param->stats_ = (picture->stats == NULL) ? NULL : &stats_side; // Create a side bit writer. if (!VP8LBitWriterClone(bw_main, &bw_side)) { - err = VP8_ENC_ERROR_OUT_OF_MEMORY; + WebPEncodingSetError(picture, VP8_ENC_ERROR_OUT_OF_MEMORY); goto Error; } param->bw_ = &bw_side; // Create a side encoder. - enc_side = VP8LEncoderNew(config, picture); + enc_side = VP8LEncoderNew(config, &picture_side); if (enc_side == NULL || !EncoderInit(enc_side)) { - err = VP8_ENC_ERROR_OUT_OF_MEMORY; + WebPEncodingSetError(picture, VP8_ENC_ERROR_OUT_OF_MEMORY); goto Error; } // Copy the values that were computed for the main encoder. @@ -1988,7 +2057,7 @@ WebPEncodingError VP8LEncodeStream(const WebPConfig* const config, // Start the second thread if needed. if (num_crunch_configs_side != 0) { if (!worker_interface->Reset(&worker_side)) { - err = VP8_ENC_ERROR_OUT_OF_MEMORY; + WebPEncodingSetError(picture, VP8_ENC_ERROR_OUT_OF_MEMORY); goto Error; } #if !defined(WEBP_DISABLE_STATS) @@ -1998,8 +2067,6 @@ WebPEncodingError VP8LEncodeStream(const WebPConfig* const config, memcpy(&stats_side, picture->stats, sizeof(stats_side)); } #endif - // This line is only useful to remove a Clang static analyzer warning. - params_side.err_ = VP8_ENC_OK; worker_interface->Launch(&worker_side); } // Execute the main thread. @@ -2011,7 +2078,10 @@ WebPEncodingError VP8LEncodeStream(const WebPConfig* const config, const int ok_side = worker_interface->Sync(&worker_side); worker_interface->End(&worker_side); if (!ok_main || !ok_side) { - err = ok_main ? params_side.err_ : params_main.err_; + if (picture->error_code == VP8_ENC_OK) { + assert(picture_side.error_code != VP8_ENC_OK); + WebPEncodingSetError(picture, picture_side.error_code); + } goto Error; } if (VP8LBitWriterNumBytes(&bw_side) < VP8LBitWriterNumBytes(bw_main)) { @@ -2022,18 +2092,13 @@ WebPEncodingError VP8LEncodeStream(const WebPConfig* const config, } #endif } - } else { - if (!ok_main) { - err = params_main.err_; - goto Error; - } } -Error: + Error: VP8LBitWriterWipeOut(&bw_side); VP8LEncoderDelete(enc_main); VP8LEncoderDelete(enc_side); - return err; + return (picture->error_code == VP8_ENC_OK); } #undef CRUNCH_CONFIGS_MAX @@ -2046,14 +2111,12 @@ int VP8LEncodeImage(const WebPConfig* const config, size_t coded_size; int percent = 0; int initial_size; - WebPEncodingError err = VP8_ENC_OK; VP8LBitWriter bw; if (picture == NULL) return 0; if (config == NULL || picture->argb == NULL) { - err = VP8_ENC_ERROR_NULL_PARAMETER; - WebPEncodingSetError(picture, err); + WebPEncodingSetError(picture, VP8_ENC_ERROR_NULL_PARAMETER); return 0; } @@ -2064,13 +2127,13 @@ int VP8LEncodeImage(const WebPConfig* const config, initial_size = (config->image_hint == WEBP_HINT_GRAPH) ? width * height : width * height * 2; if (!VP8LBitWriterInit(&bw, initial_size)) { - err = VP8_ENC_ERROR_OUT_OF_MEMORY; + WebPEncodingSetError(picture, VP8_ENC_ERROR_OUT_OF_MEMORY); goto Error; } if (!WebPReportProgress(picture, 1, &percent)) { UserAbort: - err = VP8_ENC_ERROR_USER_ABORT; + WebPEncodingSetError(picture, VP8_ENC_ERROR_USER_ABORT); goto Error; } // Reset stats (for pure lossless coding) @@ -2086,28 +2149,26 @@ int VP8LEncodeImage(const WebPConfig* const config, // Write image size. if (!WriteImageSize(picture, &bw)) { - err = VP8_ENC_ERROR_OUT_OF_MEMORY; + WebPEncodingSetError(picture, VP8_ENC_ERROR_OUT_OF_MEMORY); goto Error; } has_alpha = WebPPictureHasTransparency(picture); // Write the non-trivial Alpha flag and lossless version. if (!WriteRealAlphaAndVersion(&bw, has_alpha)) { - err = VP8_ENC_ERROR_OUT_OF_MEMORY; + WebPEncodingSetError(picture, VP8_ENC_ERROR_OUT_OF_MEMORY); goto Error; } - if (!WebPReportProgress(picture, 5, &percent)) goto UserAbort; + if (!WebPReportProgress(picture, 2, &percent)) goto UserAbort; // Encode main image stream. - err = VP8LEncodeStream(config, picture, &bw, 1 /*use_cache*/); - if (err != VP8_ENC_OK) goto Error; + if (!VP8LEncodeStream(config, picture, &bw, 1 /*use_cache*/)) goto Error; - if (!WebPReportProgress(picture, 90, &percent)) goto UserAbort; + if (!WebPReportProgress(picture, 99, &percent)) goto UserAbort; // Finish the RIFF chunk. - err = WriteImage(picture, &bw, &coded_size); - if (err != VP8_ENC_OK) goto Error; + if (!WriteImage(picture, &bw, &coded_size)) goto Error; if (!WebPReportProgress(picture, 100, &percent)) goto UserAbort; @@ -2126,13 +2187,11 @@ int VP8LEncodeImage(const WebPConfig* const config, } Error: - if (bw.error_) err = VP8_ENC_ERROR_OUT_OF_MEMORY; - VP8LBitWriterWipeOut(&bw); - if (err != VP8_ENC_OK) { - WebPEncodingSetError(picture, err); - return 0; + if (bw.error_) { + WebPEncodingSetError(picture, VP8_ENC_ERROR_OUT_OF_MEMORY); } - return 1; + VP8LBitWriterWipeOut(&bw); + return (picture->error_code == VP8_ENC_OK); } //------------------------------------------------------------------------------ diff --git a/thirdparty/webp/src/enc/vp8li_enc.h b/thirdparty/webp/src/enc/vp8li_enc.h index 00de48946c..3d35e1612d 100644 --- a/thirdparty/webp/src/enc/vp8li_enc.h +++ b/thirdparty/webp/src/enc/vp8li_enc.h @@ -89,9 +89,10 @@ int VP8LEncodeImage(const WebPConfig* const config, // Encodes the main image stream using the supplied bit writer. // If 'use_cache' is false, disables the use of color cache. -WebPEncodingError VP8LEncodeStream(const WebPConfig* const config, - const WebPPicture* const picture, - VP8LBitWriter* const bw, int use_cache); +// Returns false in case of error (stored in picture->error_code). +int VP8LEncodeStream(const WebPConfig* const config, + const WebPPicture* const picture, VP8LBitWriter* const bw, + int use_cache); #if (WEBP_NEAR_LOSSLESS == 1) // in near_lossless.c @@ -103,13 +104,18 @@ int VP8ApplyNearLossless(const WebPPicture* const picture, int quality, //------------------------------------------------------------------------------ // Image transforms in predictor.c. -void VP8LResidualImage(int width, int height, int bits, int low_effort, - uint32_t* const argb, uint32_t* const argb_scratch, - uint32_t* const image, int near_lossless, int exact, - int used_subtract_green); +// pic and percent are for progress. +// Returns false in case of error (stored in pic->error_code). +int VP8LResidualImage(int width, int height, int bits, int low_effort, + uint32_t* const argb, uint32_t* const argb_scratch, + uint32_t* const image, int near_lossless, int exact, + int used_subtract_green, const WebPPicture* const pic, + int percent_range, int* const percent); -void VP8LColorSpaceTransform(int width, int height, int bits, int quality, - uint32_t* const argb, uint32_t* image); +int VP8LColorSpaceTransform(int width, int height, int bits, int quality, + uint32_t* const argb, uint32_t* image, + const WebPPicture* const pic, int percent_range, + int* const percent); //------------------------------------------------------------------------------ diff --git a/thirdparty/webp/src/enc/webp_enc.c b/thirdparty/webp/src/enc/webp_enc.c index ce2db2e94b..9620e05070 100644 --- a/thirdparty/webp/src/enc/webp_enc.c +++ b/thirdparty/webp/src/enc/webp_enc.c @@ -336,9 +336,7 @@ int WebPEncode(const WebPConfig* config, WebPPicture* pic) { if (!WebPValidateConfig(config)) { return WebPEncodingSetError(pic, VP8_ENC_ERROR_INVALID_CONFIGURATION); } - if (pic->width <= 0 || pic->height <= 0) { - return WebPEncodingSetError(pic, VP8_ENC_ERROR_BAD_DIMENSION); - } + if (!WebPValidatePicture(pic)) return 0; if (pic->width > WEBP_MAX_DIMENSION || pic->height > WEBP_MAX_DIMENSION) { return WebPEncodingSetError(pic, VP8_ENC_ERROR_BAD_DIMENSION); } diff --git a/thirdparty/webp/src/mux/muxedit.c b/thirdparty/webp/src/mux/muxedit.c index 02c3edecd7..63e71a0aba 100644 --- a/thirdparty/webp/src/mux/muxedit.c +++ b/thirdparty/webp/src/mux/muxedit.c @@ -70,6 +70,7 @@ void WebPMuxDelete(WebPMux* mux) { err = ChunkAssignData(&chunk, data, copy_data, tag); \ if (err == WEBP_MUX_OK) { \ err = ChunkSetHead(&chunk, (LIST)); \ + if (err != WEBP_MUX_OK) ChunkRelease(&chunk); \ } \ return err; \ } diff --git a/thirdparty/webp/src/mux/muxi.h b/thirdparty/webp/src/mux/muxi.h index d9bf9b3770..0f4af1784d 100644 --- a/thirdparty/webp/src/mux/muxi.h +++ b/thirdparty/webp/src/mux/muxi.h @@ -29,7 +29,7 @@ extern "C" { #define MUX_MAJ_VERSION 1 #define MUX_MIN_VERSION 2 -#define MUX_REV_VERSION 2 +#define MUX_REV_VERSION 4 // Chunk object. typedef struct WebPChunk WebPChunk; diff --git a/thirdparty/webp/src/mux/muxinternal.c b/thirdparty/webp/src/mux/muxinternal.c index b9ee6717d3..75b6b416b9 100644 --- a/thirdparty/webp/src/mux/muxinternal.c +++ b/thirdparty/webp/src/mux/muxinternal.c @@ -155,17 +155,18 @@ WebPMuxError ChunkSetHead(WebPChunk* const chunk, WebPMuxError ChunkAppend(WebPChunk* const chunk, WebPChunk*** const chunk_list) { + WebPMuxError err; assert(chunk_list != NULL && *chunk_list != NULL); if (**chunk_list == NULL) { - ChunkSetHead(chunk, *chunk_list); + err = ChunkSetHead(chunk, *chunk_list); } else { WebPChunk* last_chunk = **chunk_list; while (last_chunk->next_ != NULL) last_chunk = last_chunk->next_; - ChunkSetHead(chunk, &last_chunk->next_); - *chunk_list = &last_chunk->next_; + err = ChunkSetHead(chunk, &last_chunk->next_); + if (err == WEBP_MUX_OK) *chunk_list = &last_chunk->next_; } - return WEBP_MUX_OK; + return err; } //------------------------------------------------------------------------------ diff --git a/thirdparty/webp/src/webp/encode.h b/thirdparty/webp/src/webp/encode.h index b4c599df87..56b68e2f10 100644 --- a/thirdparty/webp/src/webp/encode.h +++ b/thirdparty/webp/src/webp/encode.h @@ -441,7 +441,7 @@ WEBP_EXTERN int WebPPictureCrop(WebPPicture* picture, // the original dimension will be lost). Picture 'dst' need not be initialized // with WebPPictureInit() if it is different from 'src', since its content will // be overwritten. -// Returns false in case of memory allocation error or invalid parameters. +// Returns false in case of invalid parameters. WEBP_EXTERN int WebPPictureView(const WebPPicture* src, int left, int top, int width, int height, WebPPicture* dst); @@ -455,7 +455,7 @@ WEBP_EXTERN int WebPPictureIsView(const WebPPicture* picture); // dimension will be calculated preserving the aspect ratio. // No gamma correction is applied. // Returns false in case of error (invalid parameter or insufficient memory). -WEBP_EXTERN int WebPPictureRescale(WebPPicture* pic, int width, int height); +WEBP_EXTERN int WebPPictureRescale(WebPPicture* picture, int width, int height); // Colorspace conversion function to import RGB samples. // Previous buffer will be free'd, if any. @@ -526,7 +526,7 @@ WEBP_EXTERN int WebPPictureHasTransparency(const WebPPicture* picture); // Remove the transparency information (if present) by blending the color with // the background color 'background_rgb' (specified as 24bit RGB triplet). // After this call, all alpha values are reset to 0xff. -WEBP_EXTERN void WebPBlendAlpha(WebPPicture* pic, uint32_t background_rgb); +WEBP_EXTERN void WebPBlendAlpha(WebPPicture* picture, uint32_t background_rgb); //------------------------------------------------------------------------------ // Main call