forked from BigfootDev/flatbuffers
Compare commits
78 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
01834de25e | ||
|
|
6f9ea7c23c | ||
|
|
de9791e0a9 | ||
|
|
3e778aca4d | ||
|
|
01f4138618 | ||
|
|
b90cc35a10 | ||
|
|
79d6abb42e | ||
|
|
d1e4daa178 | ||
|
|
4a34cd70dc | ||
|
|
6a9cd4411f | ||
|
|
f7a75173f1 | ||
|
|
a56f9ec50e | ||
|
|
4c71f87619 | ||
|
|
6af83a7d05 | ||
|
|
535ead8d8c | ||
|
|
85aee1f5c3 | ||
|
|
f3a3f45159 | ||
|
|
02d7859f8b | ||
|
|
5785784c8a | ||
|
|
0fb5519585 | ||
|
|
f838017860 | ||
|
|
08ebd202e2 | ||
|
|
a6f4194489 | ||
|
|
7fb785fd89 | ||
|
|
ca71fdfb9a | ||
|
|
a105c26eca | ||
|
|
5b7a02d037 | ||
|
|
f5121615d9 | ||
|
|
34c821f4ad | ||
|
|
802a3a056a | ||
|
|
ee848a02e1 | ||
|
|
ef76b5ece4 | ||
|
|
1703662285 | ||
|
|
991b39edbe | ||
|
|
81799203f1 | ||
|
|
62e4d2e5b2 | ||
|
|
40758674b1 | ||
|
|
4e75867bd2 | ||
|
|
b17d59b18c | ||
|
|
b23493a7d2 | ||
|
|
b50b6be60a | ||
|
|
7bf83f5ea0 | ||
|
|
ca6381bcc8 | ||
|
|
3b8644d32c | ||
|
|
641fbe4658 | ||
|
|
5638a6a900 | ||
|
|
c2668fc0e2 | ||
|
|
b5802b57f2 | ||
|
|
06f2a3dce9 | ||
|
|
75af533e95 | ||
|
|
c95cf661af | ||
|
|
920f3827a0 | ||
|
|
81724e5b20 | ||
|
|
4d6a7aa8b7 | ||
|
|
e61b00359b | ||
|
|
74b5195089 | ||
|
|
07d9485146 | ||
|
|
82da3da3f6 | ||
|
|
a809a2d3f7 | ||
|
|
af9ceabeef | ||
|
|
3b2eb77595 | ||
|
|
6420fa5c88 | ||
|
|
01589630ba | ||
|
|
e0d68bdda2 | ||
|
|
e43a80c322 | ||
|
|
449d5649d6 | ||
|
|
96d438df47 | ||
|
|
4e396d47bc | ||
|
|
b47ba1d5ff | ||
|
|
a078130c87 | ||
|
|
9ed76559df | ||
|
|
9927747d4e | ||
|
|
52d1b77941 | ||
|
|
40aa964057 | ||
|
|
e1a2f688e0 | ||
|
|
c0797b22ae | ||
|
|
97ee210826 | ||
|
|
3be296ec8a |
347
.clang-tidy
Normal file
347
.clang-tidy
Normal file
@@ -0,0 +1,347 @@
|
||||
---
|
||||
FormatStyle: "file"
|
||||
WarningsAsErrors: "*"
|
||||
HeaderFilterRegex: ".*"
|
||||
Checks: "google-build-explicit-make-pair,
|
||||
google-build-namespaces,
|
||||
google-build-using-namespace,
|
||||
google-default-arguments,
|
||||
google-explicit-constructor,
|
||||
google-global-names-in-headers,
|
||||
google-objc-avoid-nsobject-new,
|
||||
google-objc-avoid-throwing-exception,
|
||||
google-objc-function-naming,
|
||||
google-objc-global-variable-declaration,
|
||||
google-readability-avoid-underscore-in-googletest-name,
|
||||
google-readability-braces-around-statements,
|
||||
google-readability-casting,
|
||||
google-readability-function-size,
|
||||
google-readability-namespace-comments,
|
||||
google-runtime-int,
|
||||
google-runtime-operator,
|
||||
google-upgrade-googletest-case,
|
||||
clang-analyzer-apiModeling.StdCLibraryFunctions,
|
||||
clang-analyzer-apiModeling.TrustNonnull,
|
||||
clang-analyzer-apiModeling.google.GTest,
|
||||
clang-analyzer-apiModeling.llvm.CastValue,
|
||||
clang-analyzer-apiModeling.llvm.ReturnValue,
|
||||
clang-analyzer-core.CallAndMessage,
|
||||
clang-analyzer-core.CallAndMessageModeling,
|
||||
clang-analyzer-core.DivideZero,
|
||||
clang-analyzer-core.DynamicTypePropagation,
|
||||
clang-analyzer-core.NonNullParamChecker,
|
||||
clang-analyzer-core.NonnilStringConstants,
|
||||
clang-analyzer-core.NullDereference,
|
||||
clang-analyzer-core.StackAddrEscapeBase,
|
||||
clang-analyzer-core.StackAddressEscape,
|
||||
clang-analyzer-core.UndefinedBinaryOperatorResult,
|
||||
clang-analyzer-core.VLASize,
|
||||
clang-analyzer-core.builtin.BuiltinFunctions,
|
||||
clang-analyzer-core.builtin.NoReturnFunctions,
|
||||
clang-analyzer-core.uninitialized.ArraySubscript,
|
||||
clang-analyzer-core.uninitialized.Assign,
|
||||
clang-analyzer-core.uninitialized.Branch,
|
||||
clang-analyzer-core.uninitialized.CapturedBlockVariable,
|
||||
clang-analyzer-core.uninitialized.UndefReturn,
|
||||
clang-analyzer-cplusplus.InnerPointer,
|
||||
clang-analyzer-cplusplus.Move,
|
||||
clang-analyzer-cplusplus.NewDelete,
|
||||
clang-analyzer-cplusplus.NewDeleteLeaks,
|
||||
clang-analyzer-cplusplus.PlacementNew,
|
||||
clang-analyzer-cplusplus.PureVirtualCall,
|
||||
clang-analyzer-cplusplus.SelfAssignment,
|
||||
clang-analyzer-cplusplus.SmartPtrModeling,
|
||||
clang-analyzer-cplusplus.StringChecker,
|
||||
clang-analyzer-cplusplus.VirtualCallModeling,
|
||||
clang-analyzer-deadcode.DeadStores,
|
||||
clang-analyzer-fuchsia.HandleChecker,
|
||||
clang-analyzer-nullability.NullPassedToNonnull,
|
||||
clang-analyzer-nullability.NullReturnedFromNonnull,
|
||||
clang-analyzer-nullability.NullabilityBase,
|
||||
clang-analyzer-nullability.NullableDereferenced,
|
||||
clang-analyzer-nullability.NullablePassedToNonnull,
|
||||
clang-analyzer-nullability.NullableReturnedFromNonnull,
|
||||
clang-analyzer-optin.cplusplus.UninitializedObject,
|
||||
clang-analyzer-optin.cplusplus.VirtualCall,
|
||||
clang-analyzer-optin.mpi.MPI-Checker,
|
||||
clang-analyzer-optin.osx.OSObjectCStyleCast,
|
||||
clang-analyzer-optin.osx.cocoa.localizability.EmptyLocalizationContextChecker,
|
||||
clang-analyzer-optin.osx.cocoa.localizability.NonLocalizedStringChecker,
|
||||
clang-analyzer-optin.performance.GCDAntipattern,
|
||||
clang-analyzer-optin.performance.Padding,
|
||||
clang-analyzer-optin.portability.UnixAPI,
|
||||
clang-analyzer-osx.API,
|
||||
clang-analyzer-osx.MIG,
|
||||
clang-analyzer-osx.NSOrCFErrorDerefChecker,
|
||||
clang-analyzer-osx.NumberObjectConversion,
|
||||
clang-analyzer-osx.OSObjectRetainCount,
|
||||
clang-analyzer-osx.ObjCProperty,
|
||||
clang-analyzer-osx.SecKeychainAPI,
|
||||
clang-analyzer-osx.cocoa.AtSync,
|
||||
clang-analyzer-osx.cocoa.AutoreleaseWrite,
|
||||
clang-analyzer-osx.cocoa.ClassRelease,
|
||||
clang-analyzer-osx.cocoa.Dealloc,
|
||||
clang-analyzer-osx.cocoa.IncompatibleMethodTypes,
|
||||
clang-analyzer-osx.cocoa.Loops,
|
||||
clang-analyzer-osx.cocoa.MissingSuperCall,
|
||||
clang-analyzer-osx.cocoa.NSAutoreleasePool,
|
||||
clang-analyzer-osx.cocoa.NSError,
|
||||
clang-analyzer-osx.cocoa.NilArg,
|
||||
clang-analyzer-osx.cocoa.NonNilReturnValue,
|
||||
clang-analyzer-osx.cocoa.ObjCGenerics,
|
||||
clang-analyzer-osx.cocoa.RetainCount,
|
||||
clang-analyzer-osx.cocoa.RetainCountBase,
|
||||
clang-analyzer-osx.cocoa.RunLoopAutoreleaseLeak,
|
||||
clang-analyzer-osx.cocoa.SelfInit,
|
||||
clang-analyzer-osx.cocoa.SuperDealloc,
|
||||
clang-analyzer-osx.cocoa.UnusedIvars,
|
||||
clang-analyzer-osx.cocoa.VariadicMethodTypes,
|
||||
clang-analyzer-osx.coreFoundation.CFError,
|
||||
clang-analyzer-osx.coreFoundation.CFNumber,
|
||||
clang-analyzer-osx.coreFoundation.CFRetainRelease,
|
||||
clang-analyzer-osx.coreFoundation.containers.OutOfBounds,
|
||||
clang-analyzer-osx.coreFoundation.containers.PointerSizedValues,
|
||||
clang-analyzer-security.FloatLoopCounter,
|
||||
clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling,
|
||||
clang-analyzer-security.insecureAPI.SecuritySyntaxChecker,
|
||||
clang-analyzer-security.insecureAPI.UncheckedReturn,
|
||||
clang-analyzer-security.insecureAPI.bcmp,
|
||||
clang-analyzer-security.insecureAPI.bcopy,
|
||||
clang-analyzer-security.insecureAPI.bzero,
|
||||
clang-analyzer-security.insecureAPI.decodeValueOfObjCType,
|
||||
clang-analyzer-security.insecureAPI.getpw,
|
||||
clang-analyzer-security.insecureAPI.gets,
|
||||
clang-analyzer-security.insecureAPI.mkstemp,
|
||||
clang-analyzer-security.insecureAPI.mktemp,
|
||||
clang-analyzer-security.insecureAPI.rand,
|
||||
clang-analyzer-security.insecureAPI.strcpy,
|
||||
clang-analyzer-security.insecureAPI.vfork,
|
||||
clang-analyzer-unix.API,
|
||||
clang-analyzer-unix.DynamicMemoryModeling,
|
||||
clang-analyzer-unix.Malloc,
|
||||
clang-analyzer-unix.MallocSizeof,
|
||||
clang-analyzer-unix.MismatchedDeallocator,
|
||||
clang-analyzer-unix.Vfork,
|
||||
clang-analyzer-unix.cstring.BadSizeArg,
|
||||
clang-analyzer-unix.cstring.CStringModeling,
|
||||
clang-analyzer-unix.cstring.NullArg,
|
||||
clang-analyzer-valist.CopyToSelf,
|
||||
clang-analyzer-valist.Uninitialized,
|
||||
clang-analyzer-valist.Unterminated,
|
||||
clang-analyzer-valist.ValistBase,
|
||||
clang-analyzer-webkit.NoUncountedMemberChecker,
|
||||
clang-analyzer-webkit.RefCntblBaseVirtualDtor,
|
||||
clang-analyzer-webkit.UncountedLambdaCapturesChecker,
|
||||
|
||||
################################################ Optional checks ################################################
|
||||
|
||||
#google-readability-todo,
|
||||
#bugprone-argument-comment,
|
||||
#bugprone-assert-side-effect,
|
||||
#bugprone-bad-signal-to-kill-thread,
|
||||
#bugprone-bool-pointer-implicit-conversion,
|
||||
#bugprone-branch-clone,
|
||||
#bugprone-copy-constructor-init,
|
||||
#bugprone-dangling-handle,
|
||||
#bugprone-dynamic-static-initializers,
|
||||
#bugprone-easily-swappable-parameters,
|
||||
#bugprone-exception-escape,
|
||||
#bugprone-fold-init-type,
|
||||
#bugprone-forward-declaration-namespace,
|
||||
#bugprone-forwarding-reference-overload,
|
||||
#bugprone-implicit-widening-of-multiplication-result,
|
||||
#bugprone-inaccurate-erase,
|
||||
#bugprone-incorrect-roundings,
|
||||
#bugprone-infinite-loop,
|
||||
#bugprone-integer-division,
|
||||
#bugprone-lambda-function-name,
|
||||
#bugprone-macro-parentheses,
|
||||
#bugprone-macro-repeated-side-effects,
|
||||
#bugprone-misplaced-operator-in-strlen-in-alloc,
|
||||
#bugprone-misplaced-pointer-arithmetic-in-alloc,
|
||||
#bugprone-misplaced-widening-cast,
|
||||
#bugprone-move-forwarding-reference,
|
||||
#bugprone-multiple-statement-macro,
|
||||
#bugprone-narrowing-conversions,
|
||||
#bugprone-no-escape,
|
||||
#bugprone-not-null-terminated-result,
|
||||
#bugprone-parent-virtual-call,
|
||||
#bugprone-posix-return,
|
||||
#bugprone-redundant-branch-condition,
|
||||
#bugprone-reserved-identifier,
|
||||
#bugprone-signal-handler,
|
||||
#bugprone-signed-char-misuse,
|
||||
#bugprone-sizeof-container,
|
||||
#bugprone-sizeof-expression,
|
||||
#bugprone-spuriously-wake-up-functions,
|
||||
#bugprone-string-constructor,
|
||||
#bugprone-string-integer-assignment,
|
||||
#bugprone-string-literal-with-embedded-nul,
|
||||
#bugprone-stringview-nullptr,
|
||||
#bugprone-suspicious-enum-usage,
|
||||
#bugprone-suspicious-include,
|
||||
#bugprone-suspicious-memory-comparison,
|
||||
#bugprone-suspicious-memset-usage,
|
||||
#bugprone-suspicious-missing-comma,
|
||||
#bugprone-suspicious-semicolon,
|
||||
#bugprone-suspicious-string-compare,
|
||||
#bugprone-swapped-arguments,
|
||||
#bugprone-terminating-continue,
|
||||
#bugprone-throw-keyword-missing,
|
||||
#bugprone-too-small-loop-variable,
|
||||
#bugprone-undefined-memory-manipulation,
|
||||
#bugprone-undelegated-constructor,
|
||||
#bugprone-unhandled-exception-at-new,
|
||||
#bugprone-unhandled-self-assignment,
|
||||
#bugprone-unused-raii,
|
||||
#bugprone-unused-return-value,
|
||||
#bugprone-use-after-move,
|
||||
#bugprone-virtual-near-miss,
|
||||
#cppcoreguidelines-avoid-c-arrays,
|
||||
#cppcoreguidelines-avoid-goto,
|
||||
#cppcoreguidelines-avoid-magic-numbers,
|
||||
#cppcoreguidelines-avoid-non-const-global-variables,
|
||||
#cppcoreguidelines-c-copy-assignment-signature,
|
||||
#cppcoreguidelines-explicit-virtual-functions,
|
||||
#cppcoreguidelines-init-variables,
|
||||
#cppcoreguidelines-interfaces-global-init,
|
||||
#cppcoreguidelines-macro-usage,
|
||||
#cppcoreguidelines-narrowing-conversions,
|
||||
#cppcoreguidelines-no-malloc,
|
||||
#cppcoreguidelines-non-private-member-variables-in-classes,
|
||||
#cppcoreguidelines-owning-memory,
|
||||
#cppcoreguidelines-prefer-member-initializer,
|
||||
#cppcoreguidelines-pro-bounds-array-to-pointer-decay,
|
||||
#cppcoreguidelines-pro-bounds-constant-array-index,
|
||||
#cppcoreguidelines-pro-bounds-pointer-arithmetic,
|
||||
#cppcoreguidelines-pro-type-const-cast,
|
||||
#cppcoreguidelines-pro-type-cstyle-cast,
|
||||
#cppcoreguidelines-pro-type-member-init,
|
||||
#cppcoreguidelines-pro-type-reinterpret-cast,
|
||||
#cppcoreguidelines-pro-type-static-cast-downcast,
|
||||
#cppcoreguidelines-pro-type-union-access,
|
||||
#cppcoreguidelines-pro-type-vararg,
|
||||
#cppcoreguidelines-slicing,
|
||||
#cppcoreguidelines-special-member-functions,
|
||||
#cppcoreguidelines-virtual-class-destructor,
|
||||
#hicpp-avoid-c-arrays,
|
||||
#hicpp-avoid-goto,
|
||||
#hicpp-braces-around-statements,
|
||||
#hicpp-deprecated-headers,
|
||||
#hicpp-exception-baseclass,
|
||||
#hicpp-explicit-conversions,
|
||||
#hicpp-function-size,
|
||||
#hicpp-invalid-access-moved,
|
||||
#hicpp-member-init,
|
||||
#hicpp-move-const-arg,
|
||||
#hicpp-multiway-paths-covered,
|
||||
#hicpp-named-parameter,
|
||||
#hicpp-new-delete-operators,
|
||||
#hicpp-no-array-decay,
|
||||
#hicpp-no-assembler,
|
||||
#hicpp-no-malloc,
|
||||
#hicpp-noexcept-move,
|
||||
#hicpp-signed-bitwise,
|
||||
#hicpp-special-member-functions,
|
||||
#hicpp-static-assert,
|
||||
#hicpp-undelegated-constructor,
|
||||
#hicpp-uppercase-literal-suffix,
|
||||
#hicpp-use-auto,
|
||||
#hicpp-use-emplace,
|
||||
#hicpp-use-equals-default,
|
||||
#hicpp-use-equals-delete,
|
||||
#hicpp-use-noexcept,
|
||||
#hicpp-use-nullptr,
|
||||
#hicpp-use-override,
|
||||
#hicpp-vararg,
|
||||
#modernize-avoid-bind,
|
||||
#modernize-avoid-c-arrays,
|
||||
#modernize-concat-nested-namespaces,
|
||||
#modernize-deprecated-headers,
|
||||
#modernize-deprecated-ios-base-aliases,
|
||||
#modernize-loop-convert,
|
||||
#modernize-make-shared,
|
||||
#modernize-make-unique,
|
||||
#modernize-pass-by-value,
|
||||
#modernize-raw-string-literal,
|
||||
#modernize-redundant-void-arg,
|
||||
#modernize-replace-auto-ptr,
|
||||
#modernize-replace-disallow-copy-and-assign-macro,
|
||||
#modernize-replace-random-shuffle,
|
||||
#modernize-return-braced-init-list,
|
||||
#modernize-shrink-to-fit,
|
||||
#modernize-unary-static-assert,
|
||||
#modernize-use-auto,
|
||||
#modernize-use-bool-literals,
|
||||
#modernize-use-default-member-init,
|
||||
#modernize-use-emplace,
|
||||
#modernize-use-equals-default,
|
||||
#modernize-use-equals-delete,
|
||||
#modernize-use-nodiscard,
|
||||
#modernize-use-noexcept,
|
||||
#modernize-use-nullptr,
|
||||
#modernize-use-override,
|
||||
#modernize-use-trailing-return-type,
|
||||
#modernize-use-transparent-functors,
|
||||
#modernize-use-uncaught-exceptions,
|
||||
#modernize-use-using,
|
||||
#performance-faster-string-find,
|
||||
#performance-for-range-copy,
|
||||
#performance-implicit-conversion-in-loop,
|
||||
#performance-inefficient-algorithm,
|
||||
#performance-inefficient-string-concatenation,
|
||||
#performance-inefficient-vector-operation,
|
||||
#performance-move-const-arg,
|
||||
#performance-move-constructor-init,
|
||||
#performance-no-automatic-move,
|
||||
#performance-no-int-to-ptr,
|
||||
#performance-noexcept-move-constructor,
|
||||
#performance-trivially-destructible,
|
||||
#performance-type-promotion-in-math-fn,
|
||||
#performance-unnecessary-copy-initialization,
|
||||
#performance-unnecessary-value-param,
|
||||
#portability-restrict-system-includes,
|
||||
#portability-simd-intrinsics,
|
||||
#readability-avoid-const-params-in-decls,
|
||||
#readability-braces-around-statements,
|
||||
#readability-const-return-type,
|
||||
#readability-container-contains,
|
||||
#readability-container-data-pointer,
|
||||
#readability-container-size-empty,
|
||||
#readability-convert-member-functions-to-static,
|
||||
#readability-delete-null-pointer,
|
||||
#readability-duplicate-include,
|
||||
#readability-else-after-return,
|
||||
#readability-function-cognitive-complexity,
|
||||
#readability-function-size,
|
||||
#readability-identifier-length,
|
||||
#readability-identifier-naming,
|
||||
#readability-implicit-bool-conversion,
|
||||
#readability-inconsistent-declaration-parameter-name,
|
||||
#readability-isolate-declaration,
|
||||
#readability-magic-numbers,
|
||||
#readability-make-member-function-const,
|
||||
#readability-misleading-indentation,
|
||||
#readability-misplaced-array-index,
|
||||
#readability-named-parameter,
|
||||
#readability-non-const-parameter,
|
||||
#readability-qualified-auto,
|
||||
#readability-redundant-access-specifiers,
|
||||
#readability-redundant-control-flow,
|
||||
#readability-redundant-declaration,
|
||||
#readability-redundant-function-ptr-dereference,
|
||||
#readability-redundant-member-init,
|
||||
#readability-redundant-preprocessor,
|
||||
#readability-redundant-smartptr-get,
|
||||
#readability-redundant-string-cstr,
|
||||
#readability-redundant-string-init,
|
||||
#readability-simplify-boolean-expr,
|
||||
#readability-simplify-subscript-expr,
|
||||
#readability-static-accessed-through-instance,
|
||||
#readability-static-definition-in-anonymous-namespace,
|
||||
#readability-string-compare,
|
||||
#readability-suspicious-call-argument,
|
||||
#readability-uniqueptr-delete-release,
|
||||
#readability-uppercase-literal-suffix,
|
||||
#readability-use-anyofallof
|
||||
"
|
||||
@@ -5,3 +5,4 @@ root = true
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
insert_final_newline = true
|
||||
trim_trailing_whitespace = true
|
||||
|
||||
2
.github/PULL_REQUEST_TEMPLATE.md
vendored
2
.github/PULL_REQUEST_TEMPLATE.md
vendored
@@ -3,7 +3,7 @@ Thank you for submitting a PR!
|
||||
Please delete this standard text once you've created your own description.
|
||||
|
||||
If you make changes to any of the code generators (`src/idl_gen*`) be sure to
|
||||
build your project, as it will generate code based on the changes. If necessary
|
||||
[build](https://google.github.io/flatbuffers/flatbuffers_guide_building.html) your project, as it will generate code based on the changes. If necessary
|
||||
the code generation script can be directly run (`scripts/generate_code.py`),
|
||||
requires Python3. This allows us to better see the effect of the PR.
|
||||
|
||||
|
||||
44
.github/workflows/build.yml
vendored
44
.github/workflows/build.yml
vendored
@@ -38,8 +38,10 @@ jobs:
|
||||
run: |
|
||||
chmod +x flatc
|
||||
./flatc --version
|
||||
- name: flatc tests
|
||||
run: python3 tests/flatc/main.py
|
||||
# - name: flatc tests
|
||||
# run: |
|
||||
# yarn global add esbuild
|
||||
# python3 tests/flatc/main.py
|
||||
- name: upload build artifacts
|
||||
uses: actions/upload-artifact@v1
|
||||
with:
|
||||
@@ -62,6 +64,16 @@ jobs:
|
||||
if: matrix.cxx == 'g++-10' && startsWith(github.ref, 'refs/tags/')
|
||||
id: hash-gcc
|
||||
run: echo "::set-output name=hashes::$(sha256sum Linux.flatc.binary.${{ matrix.cxx }}.zip | base64 -w0)"
|
||||
|
||||
build-linux-no-file-tests:
|
||||
name: Build Linux with -DFLATBUFFERS_NO_FILE_TESTS
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: cmake
|
||||
run: CXX=clang++-12 cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_STRICT_MODE=ON -DFLATBUFFERS_CXX_FLAGS="-DFLATBUFFERS_NO_FILE_TESTS" .
|
||||
- name: build
|
||||
run: make -j
|
||||
|
||||
build-linux-cpp-std:
|
||||
name: Build Linux C++
|
||||
@@ -133,8 +145,8 @@ jobs:
|
||||
run: msbuild.exe FlatBuffers.sln /p:Configuration=Release /p:Platform=x64
|
||||
- name: test
|
||||
run: Release\flattests.exe
|
||||
- name: flatc tests
|
||||
run: python3 tests/flatc/main.py --flatc Release\flatc.exe
|
||||
# - name: flatc tests
|
||||
# run: python3 tests/flatc/main.py --flatc Release\flatc.exe
|
||||
- name: upload build artifacts
|
||||
uses: actions/upload-artifact@v1
|
||||
with:
|
||||
@@ -235,8 +247,8 @@ jobs:
|
||||
run: |
|
||||
chmod +x Release/flatc
|
||||
Release/flatc --version
|
||||
- name: flatc tests
|
||||
run: python3 tests/flatc/main.py --flatc Release/flatc
|
||||
# - name: flatc tests
|
||||
# run: python3 tests/flatc/main.py --flatc Release/flatc
|
||||
- name: upload build artifacts
|
||||
uses: actions/upload-artifact@v1
|
||||
with:
|
||||
@@ -333,6 +345,22 @@ jobs:
|
||||
- name: Generate gRPC
|
||||
run: scripts/check-grpc-generated-code.py
|
||||
|
||||
build-generator-windows:
|
||||
name: Check Generated Code on Windows
|
||||
runs-on: windows-2019
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Add msbuild to PATH
|
||||
uses: microsoft/setup-msbuild@v1.1
|
||||
- name: cmake
|
||||
run: cmake -G "Visual Studio 16 2019" -A x64 -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_BUILD_CPP17=ON -DFLATBUFFERS_STRICT_MODE=ON .
|
||||
- name: build
|
||||
run: msbuild.exe FlatBuffers.sln /p:Configuration=Release /p:Platform=x64
|
||||
- name: Generate
|
||||
run: python3 scripts/check_generate_code.py --flatc Release\flatc.exe
|
||||
- name: Generate gRPC
|
||||
run: python3 scripts/check-grpc-generated-code.py --flatc Release\flatc.exe
|
||||
|
||||
build-benchmarks:
|
||||
name: Build Benchmarks (on Linux)
|
||||
runs-on: ubuntu-latest
|
||||
@@ -475,7 +503,9 @@ jobs:
|
||||
run: yarn compile
|
||||
- name: test
|
||||
working-directory: tests/ts
|
||||
run: python3 TypeScriptTest.py
|
||||
run: |
|
||||
yarn global add esbuild
|
||||
python3 TypeScriptTest.py
|
||||
|
||||
build-dart:
|
||||
name: Build Dart
|
||||
|
||||
35
.github/workflows/extrabuild.yml
vendored
Normal file
35
.github/workflows/extrabuild.yml
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
name: Build and unit tests that are more time consuming
|
||||
permissions: read-all
|
||||
|
||||
on:
|
||||
# For manual tests.
|
||||
workflow_dispatch:
|
||||
pull_request:
|
||||
types:
|
||||
- closed
|
||||
schedule:
|
||||
- cron: "30 20 * * *"
|
||||
|
||||
jobs:
|
||||
build-linux-s390x:
|
||||
name: Build Linux on s390x arch and run unit tests
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: uraimo/run-on-arch-action@v2
|
||||
name: Run commands
|
||||
id: runcmd
|
||||
with:
|
||||
arch: s390x
|
||||
distro: ubuntu_latest
|
||||
install: |
|
||||
apt-get update -q -y
|
||||
apt-get -y install cmake
|
||||
apt-get -y install make
|
||||
apt-get -y install g++
|
||||
run: |
|
||||
lscpu | grep Endian
|
||||
cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release
|
||||
make -j
|
||||
./flattests
|
||||
|
||||
@@ -41,9 +41,9 @@ filegroup(
|
||||
"include/flatbuffers/allocator.h",
|
||||
"include/flatbuffers/array.h",
|
||||
"include/flatbuffers/base.h",
|
||||
"include/flatbuffers/bfbs_generator.h",
|
||||
"include/flatbuffers/buffer.h",
|
||||
"include/flatbuffers/buffer_ref.h",
|
||||
"include/flatbuffers/code_generator.h",
|
||||
"include/flatbuffers/code_generators.h",
|
||||
"include/flatbuffers/default_allocator.h",
|
||||
"include/flatbuffers/detached_buffer.h",
|
||||
|
||||
43
CHANGELOG.md
43
CHANGELOG.md
@@ -4,19 +4,52 @@ All major or breaking changes will be documented in this file, as well as any
|
||||
new features that should be highlighted. Minor fixes or improvements are not
|
||||
necessarily listed.
|
||||
|
||||
## 22.12.06 (Dec 06 2022)
|
||||
## [23.3.3 (Mar 3 2023)](https://github.com/google/flatbuffers/releases/tag/v23.3.3)
|
||||
|
||||
* Refactoring of `flatc` generators to use an interface (#7797).
|
||||
|
||||
* Removed legacy cmake support and set min to 3.8 (#7801).
|
||||
|
||||
## [23.1.21 (Jan 21 2023)](https://github.com/google/flatbuffers/releases/tag/v23.1.20)
|
||||
|
||||
* Reworked entry points for Typescript/Javascript and compatibility for single
|
||||
file build (#7510)
|
||||
|
||||
## [23.1.20 (Jan 20 2023)](https://github.com/google/flatbuffers/releases/tag/v23.1.20)
|
||||
|
||||
* Removed go.mod files after some versioning issues were being report (#7780).
|
||||
|
||||
## [23.1.4 (Jan 4 2023)](https://github.com/google/flatbuffers/releases/tag/v23.1.4)
|
||||
|
||||
* Major release! Just kidding, we are continuing the
|
||||
[versioning scheme](https://github.com/google/flatbuffers/wiki/Versioning) of
|
||||
using a date to signify releases. This results in the first release of the new
|
||||
year to bump the tradition major version field.
|
||||
|
||||
* Go minimum version is now 1.19 (#7720) with the addition of Go modules.
|
||||
|
||||
* Added CI support for Big Endian regression testing (#7707).
|
||||
|
||||
* Fixed `getFullyQualifiedName` in typescript to return name delimited by '.'
|
||||
instead of '_' (#7730).
|
||||
|
||||
* Fixed the versioning scheme to not include leading zeros which are not
|
||||
consistently handled by every package manager. Only the last release
|
||||
(12.12.06) should have suffered from this.
|
||||
|
||||
## [22.12.06 (Dec 06 2022)](https://github.com/google/flatbuffers/releases/tag/v22.12.06)
|
||||
|
||||
* Bug fixing release, no major changes.
|
||||
|
||||
## 22.10.25 (Oct 25 2022)
|
||||
## [22.10.25 (Oct 25 2022)](https://github.com/google/flatbuffers/releases/tag/v22.10.25)
|
||||
|
||||
* Added Nim language support with generator and runtime libraries (#7534).
|
||||
|
||||
## 22.9.29 (Sept 29 2022)
|
||||
## [22.9.29 (Sept 29 2022)](https://github.com/google/flatbuffers/releases/tag/v22.9.29)
|
||||
|
||||
* Rust soundness fixes to avoid the crate from bing labelled unsafe (#7518).
|
||||
|
||||
## 22.9.24 (Sept 24 2022)
|
||||
## [22.9.24 (Sept 24 2022)](https://github.com/google/flatbuffers/releases/tag/v22.9.24)
|
||||
|
||||
* 20 Major releases in a row? Nope, we switched to a new
|
||||
[versioning scheme](https://github.com/google/flatbuffers/wiki/Versioning)
|
||||
@@ -67,4 +100,4 @@ necessarily listed.
|
||||
|
||||
* First binary schema generator (Lua) to generate Lua code via a .bfbs file.
|
||||
This is mostly an implementation detail of flatc internals, but will be slowly
|
||||
applied to the other language generators.
|
||||
applied to the other language generators.
|
||||
|
||||
@@ -157,6 +157,10 @@ endfunction()
|
||||
# other flagc flags using the FLAGS option to change the behavior of the flatc
|
||||
# tool.
|
||||
#
|
||||
# When the target_link_libraries is done within a different directory than
|
||||
# flatbuffers_generate_headers is called, then the target should also be dependent
|
||||
# the custom generation target called GENERATE_<TARGET>.
|
||||
#
|
||||
# Arguments:
|
||||
# TARGET: The name of the target to generate.
|
||||
# SCHEMAS: The list of schema files to generate code for.
|
||||
@@ -182,6 +186,9 @@ endfunction()
|
||||
# target_link_libraries(MyExecutableTarget
|
||||
# PRIVATE my_generated_headers_target
|
||||
# )
|
||||
#
|
||||
# Optional (only needed within different directory):
|
||||
# add_dependencies(app GENERATE_my_generated_headers_target)
|
||||
function(flatbuffers_generate_headers)
|
||||
# Parse function arguments.
|
||||
set(options)
|
||||
@@ -226,6 +233,8 @@ function(flatbuffers_generate_headers)
|
||||
"--include-prefix" ${FLATBUFFERS_GENERATE_HEADERS_INCLUDE_PREFIX})
|
||||
endif()
|
||||
|
||||
set(generated_custom_commands)
|
||||
|
||||
# Create rules to generate the code for each schema.
|
||||
foreach(schema ${FLATBUFFERS_GENERATE_HEADERS_SCHEMAS})
|
||||
get_filename_component(filename ${schema} NAME_WE)
|
||||
@@ -254,6 +263,7 @@ function(flatbuffers_generate_headers)
|
||||
COMMENT "Building ${schema} flatbuffers...")
|
||||
list(APPEND all_generated_header_files ${generated_include})
|
||||
list(APPEND all_generated_source_files ${generated_source_file})
|
||||
list(APPEND generated_custom_commands "${generated_include}" "${generated_source_file}")
|
||||
|
||||
# Geneate the binary flatbuffers schemas if instructed to.
|
||||
if (NOT ${FLATBUFFERS_GENERATE_HEADERS_BINARY_SCHEMAS_DIR} STREQUAL "")
|
||||
@@ -267,10 +277,17 @@ function(flatbuffers_generate_headers)
|
||||
${schema}
|
||||
DEPENDS ${FLATC_TARGET} ${schema}
|
||||
WORKING_DIRECTORY "${working_dir}")
|
||||
list(APPEND generated_custom_commands "${binary_schema}")
|
||||
list(APPEND all_generated_binary_files ${binary_schema})
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
# Create an additional target as add_custom_command scope is only within same directory (CMakeFile.txt)
|
||||
set(generate_target GENERATE_${FLATBUFFERS_GENERATE_HEADERS_TARGET})
|
||||
add_custom_target(${generate_target} ALL
|
||||
DEPENDS ${generated_custom_commands}
|
||||
COMMENT "Generating flatbuffer target ${FLATBUFFERS_GENERATE_HEADERS_TARGET}")
|
||||
|
||||
# Set up interface library
|
||||
add_library(${FLATBUFFERS_GENERATE_HEADERS_TARGET} INTERFACE)
|
||||
target_sources(
|
||||
|
||||
@@ -1,780 +0,0 @@
|
||||
# This was the legacy <root>/CMakeLists.txt that supported cmake version 2.8.12.
|
||||
# It was originally copied on Jan 30 2022, and is conditionally included in the
|
||||
# current <root>/CMakeLists.txt if the cmake version used is older than the new
|
||||
# minimum version.
|
||||
#
|
||||
# Only add to this file to fix immediate issues or if a change cannot be made
|
||||
# <root>/CMakeList.txt in a compatible way.
|
||||
|
||||
if (POLICY CMP0048)
|
||||
cmake_policy(SET CMP0048 NEW)
|
||||
if(CMAKE_VERSION VERSION_LESS 3.9)
|
||||
project(FlatBuffers
|
||||
VERSION 2.0.0
|
||||
LANGUAGES CXX)
|
||||
else()
|
||||
project(FlatBuffers
|
||||
DESCRIPTION "Flatbuffers serialization library"
|
||||
VERSION 2.0.0
|
||||
LANGUAGES CXX)
|
||||
endif()
|
||||
else()
|
||||
project(FlatBuffers)
|
||||
endif (POLICY CMP0048)
|
||||
|
||||
include(CMake/Version.cmake)
|
||||
|
||||
# generate compile_commands.json
|
||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||
|
||||
# NOTE: Code coverage only works on Linux & OSX.
|
||||
option(FLATBUFFERS_CODE_COVERAGE "Enable the code coverage build option." OFF)
|
||||
option(FLATBUFFERS_BUILD_TESTS "Enable the build of tests and samples." ON)
|
||||
option(FLATBUFFERS_INSTALL "Enable the installation of targets." ON)
|
||||
option(FLATBUFFERS_BUILD_FLATLIB "Enable the build of the flatbuffers library"
|
||||
ON)
|
||||
option(FLATBUFFERS_BUILD_FLATC "Enable the build of the flatbuffers compiler"
|
||||
ON)
|
||||
option(FLATBUFFERS_STATIC_FLATC "Build flatbuffers compiler with -static flag"
|
||||
OFF)
|
||||
option(FLATBUFFERS_BUILD_FLATHASH "Enable the build of flathash" ON)
|
||||
option(FLATBUFFERS_BUILD_BENCHMARKS "Enable the build of flatbenchmark. \"
|
||||
Requires C++11."
|
||||
OFF)
|
||||
option(FLATBUFFERS_BUILD_GRPCTEST "Enable the build of grpctest" OFF)
|
||||
option(FLATBUFFERS_BUILD_SHAREDLIB
|
||||
"Enable the build of the flatbuffers shared library"
|
||||
OFF)
|
||||
option(FLATBUFFERS_LIBCXX_WITH_CLANG "Force libc++ when using Clang" ON)
|
||||
# NOTE: Sanitizer check only works on Linux & OSX (gcc & llvm).
|
||||
option(FLATBUFFERS_CODE_SANITIZE
|
||||
"Add '-fsanitize' flags to 'flattests' and 'flatc' targets."
|
||||
OFF)
|
||||
option(FLATBUFFERS_PACKAGE_REDHAT
|
||||
"Build an rpm using the 'package' target."
|
||||
OFF)
|
||||
option(FLATBUFFERS_PACKAGE_DEBIAN
|
||||
"Build an deb using the 'package' target."
|
||||
OFF)
|
||||
option(FLATBUFFERS_BUILD_CPP17
|
||||
"Enable the build of c++17 test target. \"
|
||||
Requirements: Clang6, GCC7, MSVC2017 (_MSC_VER >= 1914) or higher."
|
||||
OFF)
|
||||
option(FLATBUFFERS_BUILD_LEGACY
|
||||
"Run C++ code generator with '--cpp-std c++0x' switch."
|
||||
OFF)
|
||||
option(FLATBUFFERS_ENABLE_PCH
|
||||
"Enable precompile headers support for 'flatbuffers' and 'flatc'. \"
|
||||
Only work if CMake supports 'target_precompile_headers'. \"
|
||||
This can speed up compilation time."
|
||||
OFF)
|
||||
option(FLATBUFFERS_SKIP_MONSTER_EXTRA
|
||||
"Skip generating monster_extra.fbs that contains non-supported numerical\"
|
||||
types." OFF)
|
||||
option(FLATBUFFERS_OSX_BUILD_UNIVERSAL
|
||||
"Enable the build for multiple architectures on OS X (arm64, x86_64)."
|
||||
ON)
|
||||
|
||||
if(NOT FLATBUFFERS_BUILD_FLATC AND FLATBUFFERS_BUILD_TESTS)
|
||||
message(WARNING
|
||||
"Cannot build tests without building the compiler. Tests will be disabled.")
|
||||
set(FLATBUFFERS_BUILD_TESTS OFF)
|
||||
endif()
|
||||
|
||||
if(DEFINED FLATBUFFERS_MAX_PARSING_DEPTH)
|
||||
# Override the default recursion depth limit.
|
||||
add_definitions(-DFLATBUFFERS_MAX_PARSING_DEPTH=${FLATBUFFERS_MAX_PARSING_DEPTH})
|
||||
message(STATUS "FLATBUFFERS_MAX_PARSING_DEPTH: ${FLATBUFFERS_MAX_PARSING_DEPTH}")
|
||||
endif()
|
||||
|
||||
# Auto-detect locale-narrow 'strtod_l' and 'strtoull_l' functions.
|
||||
if(NOT DEFINED FLATBUFFERS_LOCALE_INDEPENDENT)
|
||||
include(CheckCXXSymbolExists)
|
||||
|
||||
set(FLATBUFFERS_LOCALE_INDEPENDENT 0)
|
||||
if(MSVC)
|
||||
check_cxx_symbol_exists(_strtof_l stdlib.h FLATBUFFERS_HAS_STRTOF_L)
|
||||
check_cxx_symbol_exists(_strtoui64_l stdlib.h FLATBUFFERS_HAS_STRTOULL_L)
|
||||
else()
|
||||
check_cxx_symbol_exists(strtof_l stdlib.h FLATBUFFERS_HAS_STRTOF_L)
|
||||
check_cxx_symbol_exists(strtoull_l stdlib.h FLATBUFFERS_HAS_STRTOULL_L)
|
||||
endif()
|
||||
if(FLATBUFFERS_HAS_STRTOF_L AND FLATBUFFERS_HAS_STRTOULL_L)
|
||||
set(FLATBUFFERS_LOCALE_INDEPENDENT 1)
|
||||
endif()
|
||||
endif()
|
||||
add_definitions(-DFLATBUFFERS_LOCALE_INDEPENDENT=$<BOOL:${FLATBUFFERS_LOCALE_INDEPENDENT}>)
|
||||
|
||||
set(FlatBuffers_Library_SRCS
|
||||
include/flatbuffers/allocator.h
|
||||
include/flatbuffers/array.h
|
||||
include/flatbuffers/base.h
|
||||
include/flatbuffers/bfbs_generator.h
|
||||
include/flatbuffers/buffer.h
|
||||
include/flatbuffers/buffer_ref.h
|
||||
include/flatbuffers/default_allocator.h
|
||||
include/flatbuffers/detached_buffer.h
|
||||
include/flatbuffers/flatbuffer_builder.h
|
||||
include/flatbuffers/flatbuffers.h
|
||||
include/flatbuffers/flexbuffers.h
|
||||
include/flatbuffers/hash.h
|
||||
include/flatbuffers/idl.h
|
||||
include/flatbuffers/minireflect.h
|
||||
include/flatbuffers/reflection.h
|
||||
include/flatbuffers/reflection_generated.h
|
||||
include/flatbuffers/registry.h
|
||||
include/flatbuffers/stl_emulation.h
|
||||
include/flatbuffers/string.h
|
||||
include/flatbuffers/struct.h
|
||||
include/flatbuffers/table.h
|
||||
include/flatbuffers/util.h
|
||||
include/flatbuffers/vector.h
|
||||
include/flatbuffers/vector_downward.h
|
||||
include/flatbuffers/verifier.h
|
||||
src/idl_parser.cpp
|
||||
src/idl_gen_text.cpp
|
||||
src/reflection.cpp
|
||||
src/util.cpp
|
||||
)
|
||||
|
||||
set(FlatBuffers_Compiler_SRCS
|
||||
${FlatBuffers_Library_SRCS}
|
||||
src/idl_gen_cpp.cpp
|
||||
src/idl_gen_csharp.cpp
|
||||
src/idl_gen_dart.cpp
|
||||
src/idl_gen_kotlin.cpp
|
||||
src/idl_gen_go.cpp
|
||||
src/idl_gen_java.cpp
|
||||
src/idl_gen_ts.cpp
|
||||
src/idl_gen_php.cpp
|
||||
src/idl_gen_python.cpp
|
||||
src/idl_gen_lobster.cpp
|
||||
src/idl_gen_lua.cpp
|
||||
src/idl_gen_rust.cpp
|
||||
src/idl_gen_fbs.cpp
|
||||
src/idl_gen_grpc.cpp
|
||||
src/idl_gen_json_schema.cpp
|
||||
src/idl_gen_swift.cpp
|
||||
src/flatc.cpp
|
||||
src/flatc_main.cpp
|
||||
src/bfbs_gen.h
|
||||
src/bfbs_gen_lua.h
|
||||
include/flatbuffers/code_generators.h
|
||||
src/bfbs_gen_lua.cpp
|
||||
src/code_generators.cpp
|
||||
grpc/src/compiler/schema_interface.h
|
||||
grpc/src/compiler/cpp_generator.h
|
||||
grpc/src/compiler/cpp_generator.cc
|
||||
grpc/src/compiler/go_generator.h
|
||||
grpc/src/compiler/go_generator.cc
|
||||
grpc/src/compiler/java_generator.h
|
||||
grpc/src/compiler/java_generator.cc
|
||||
grpc/src/compiler/python_generator.h
|
||||
grpc/src/compiler/python_generator.cc
|
||||
grpc/src/compiler/swift_generator.h
|
||||
grpc/src/compiler/swift_generator.cc
|
||||
grpc/src/compiler/ts_generator.h
|
||||
grpc/src/compiler/ts_generator.cc
|
||||
)
|
||||
|
||||
set(FlatHash_SRCS
|
||||
include/flatbuffers/hash.h
|
||||
src/flathash.cpp
|
||||
)
|
||||
|
||||
set(FlatBuffers_Tests_SRCS
|
||||
${FlatBuffers_Library_SRCS}
|
||||
src/idl_gen_fbs.cpp
|
||||
tests/test.cpp
|
||||
tests/test_assert.h
|
||||
tests/test_assert.cpp
|
||||
tests/test_builder.h
|
||||
tests/test_builder.cpp
|
||||
tests/native_type_test_impl.h
|
||||
tests/native_type_test_impl.cpp
|
||||
include/flatbuffers/code_generators.h
|
||||
src/code_generators.cpp
|
||||
# file generate by running compiler on tests/monster_test.fbs
|
||||
${CMAKE_CURRENT_BINARY_DIR}/tests/monster_test_generated.h
|
||||
# file generate by running compiler on namespace_test/namespace_test1.fbs
|
||||
${CMAKE_CURRENT_BINARY_DIR}/tests/namespace_test/namespace_test1_generated.h
|
||||
${CMAKE_CURRENT_BINARY_DIR}/tests/namespace_test/namespace_test2_generated.h
|
||||
# file generate by running compiler on union_vector/union_vector.fbs
|
||||
${CMAKE_CURRENT_BINARY_DIR}/tests/union_vector/union_vector_generated.h
|
||||
# file generate by running compiler on tests/arrays_test.fbs
|
||||
${CMAKE_CURRENT_BINARY_DIR}/tests/arrays_test_generated.h
|
||||
# file generate by running compiler on tests/native_type_test.fbs
|
||||
${CMAKE_CURRENT_BINARY_DIR}/tests/native_type_test_generated.h
|
||||
# file generate by running compiler on tests/monster_extra.fbs
|
||||
${CMAKE_CURRENT_BINARY_DIR}/tests/monster_extra_generated.h
|
||||
# file generate by running compiler on tests/monster_test.fbs
|
||||
${CMAKE_CURRENT_BINARY_DIR}/tests/monster_test_bfbs_generated.h
|
||||
# file generate by running compiler on tests/optional_scalars.fbs
|
||||
${CMAKE_CURRENT_BINARY_DIR}/tests/optional_scalars_generated.h
|
||||
)
|
||||
|
||||
set(FlatBuffers_Tests_CPP17_SRCS
|
||||
${FlatBuffers_Library_SRCS}
|
||||
tests/test_assert.h
|
||||
tests/test_assert.cpp
|
||||
tests/cpp17/test_cpp17.cpp
|
||||
# file generate by running compiler on tests/monster_test.fbs
|
||||
${CMAKE_CURRENT_BINARY_DIR}/tests/cpp17/generated_cpp17/monster_test_generated.h
|
||||
${CMAKE_CURRENT_BINARY_DIR}/tests/monster_test_generated.h
|
||||
${CMAKE_CURRENT_BINARY_DIR}/tests/cpp17/generated_cpp17/optional_scalars_generated.h
|
||||
${CMAKE_CURRENT_BINARY_DIR}/tests/optional_scalars_generated.h
|
||||
)
|
||||
|
||||
set(FlatBuffers_Sample_Binary_SRCS
|
||||
include/flatbuffers/flatbuffers.h
|
||||
samples/sample_binary.cpp
|
||||
# file generated by running compiler on samples/monster.fbs
|
||||
${CMAKE_CURRENT_BINARY_DIR}/samples/monster_generated.h
|
||||
)
|
||||
|
||||
set(FlatBuffers_Sample_Text_SRCS
|
||||
${FlatBuffers_Library_SRCS}
|
||||
samples/sample_text.cpp
|
||||
# file generated by running compiler on samples/monster.fbs
|
||||
${CMAKE_CURRENT_BINARY_DIR}/samples/monster_generated.h
|
||||
)
|
||||
|
||||
set(FlatBuffers_Sample_BFBS_SRCS
|
||||
${FlatBuffers_Library_SRCS}
|
||||
samples/sample_bfbs.cpp
|
||||
# file generated by running compiler on samples/monster.fbs
|
||||
${CMAKE_CURRENT_BINARY_DIR}/samples/monster_generated.h
|
||||
)
|
||||
|
||||
set(FlatBuffers_GRPCTest_SRCS
|
||||
include/flatbuffers/flatbuffers.h
|
||||
include/flatbuffers/grpc.h
|
||||
include/flatbuffers/util.h
|
||||
src/util.cpp
|
||||
tests/monster_test.grpc.fb.h
|
||||
tests/test_assert.h
|
||||
tests/test_builder.h
|
||||
tests/monster_test.grpc.fb.cc
|
||||
tests/test_assert.cpp
|
||||
tests/test_builder.cpp
|
||||
grpc/tests/grpctest.cpp
|
||||
grpc/tests/message_builder_test.cpp
|
||||
# file generate by running compiler on tests/monster_test.fbs
|
||||
${CMAKE_CURRENT_BINARY_DIR}/tests/monster_test_generated.h
|
||||
)
|
||||
|
||||
# source_group(Compiler FILES ${FlatBuffers_Compiler_SRCS})
|
||||
# source_group(Tests FILES ${FlatBuffers_Tests_SRCS})
|
||||
|
||||
if(EXISTS "${CMAKE_TOOLCHAIN_FILE}")
|
||||
# do not apply any global settings if the toolchain
|
||||
# is being configured externally
|
||||
message(STATUS "Using toolchain file: ${CMAKE_TOOLCHAIN_FILE}.")
|
||||
elseif(CMAKE_COMPILER_IS_GNUCXX)
|
||||
if(CYGWIN)
|
||||
set(CMAKE_CXX_FLAGS
|
||||
"${CMAKE_CXX_FLAGS} -std=gnu++11")
|
||||
else(CYGWIN)
|
||||
set(CMAKE_CXX_FLAGS
|
||||
"${CMAKE_CXX_FLAGS} -std=c++0x")
|
||||
endif(CYGWIN)
|
||||
set(CMAKE_CXX_FLAGS
|
||||
"${CMAKE_CXX_FLAGS} -Wall -pedantic -Werror -Wextra -Werror=shadow")
|
||||
set(FLATBUFFERS_PRIVATE_CXX_FLAGS "-Wold-style-cast")
|
||||
if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 4.4)
|
||||
if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 7.0)
|
||||
set(CMAKE_CXX_FLAGS
|
||||
"${CMAKE_CXX_FLAGS} -faligned-new -Werror=implicit-fallthrough=2")
|
||||
endif()
|
||||
set(CMAKE_CXX_FLAGS
|
||||
"${CMAKE_CXX_FLAGS} -Wunused-result -Werror=unused-result -Wunused-parameter -Werror=unused-parameter")
|
||||
endif()
|
||||
|
||||
# Certain platforms such as ARM do not use signed chars by default
|
||||
# which causes issues with certain bounds checks.
|
||||
set(CMAKE_CXX_FLAGS
|
||||
"${CMAKE_CXX_FLAGS} -fsigned-char")
|
||||
|
||||
# MSVC **MUST** come before the Clang check, as clang-cl is flagged by CMake as "MSVC", but it still textually
|
||||
# matches as Clang in its Compiler Id :)
|
||||
# Note: in CMake >= 3.14 we can check CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL "GNU" or "MSVC" to differentiate...
|
||||
elseif(MSVC)
|
||||
# Visual Studio pedantic build settings
|
||||
# warning C4512: assignment operator could not be generated
|
||||
# warning C4316: object allocated on the heap may not be aligned
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4 /WX /wd4512 /wd4316")
|
||||
|
||||
if(${CMAKE_CXX_COMPILER_ID} MATCHES "Clang")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D_CRT_SECURE_NO_WARNINGS")
|
||||
endif()
|
||||
|
||||
elseif(${CMAKE_CXX_COMPILER_ID} MATCHES "Clang")
|
||||
if(APPLE)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
|
||||
|
||||
if(FLATBUFFERS_OSX_BUILD_UNIVERSAL)
|
||||
set(CMAKE_OSX_ARCHITECTURES "arm64;x86_64")
|
||||
endif()
|
||||
else()
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
|
||||
endif()
|
||||
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -pedantic -Werror -Wextra -Wno-unused-parameter")
|
||||
set(FLATBUFFERS_PRIVATE_CXX_FLAGS "-Wold-style-cast")
|
||||
if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.8)
|
||||
list(APPEND FLATBUFFERS_PRIVATE_CXX_FLAGS "-Wimplicit-fallthrough" "-Wextra-semi" "-Werror=unused-private-field") # enable warning
|
||||
endif()
|
||||
if(FLATBUFFERS_LIBCXX_WITH_CLANG)
|
||||
if(NOT "${CMAKE_SYSTEM_NAME}" MATCHES "Linux")
|
||||
set(CMAKE_CXX_FLAGS
|
||||
"${CMAKE_CXX_FLAGS} -stdlib=libc++")
|
||||
endif()
|
||||
if(NOT ("${CMAKE_SYSTEM_NAME}" MATCHES "FreeBSD" OR
|
||||
"${CMAKE_SYSTEM_NAME}" MATCHES "Linux"))
|
||||
set(CMAKE_EXE_LINKER_FLAGS
|
||||
"${CMAKE_EXE_LINKER_FLAGS} -lc++abi")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Certain platforms such as ARM do not use signed chars by default
|
||||
# which causes issues with certain bounds checks.
|
||||
set(CMAKE_CXX_FLAGS
|
||||
"${CMAKE_CXX_FLAGS} -fsigned-char")
|
||||
|
||||
endif()
|
||||
|
||||
# Append FLATBUFFERS_CXX_FLAGS to CMAKE_CXX_FLAGS.
|
||||
if(DEFINED FLATBUFFERS_CXX_FLAGS AND NOT EXISTS "${CMAKE_TOOLCHAIN_FILE}")
|
||||
message(STATUS "extend CXX_FLAGS with ${FLATBUFFERS_CXX_FLAGS}")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${FLATBUFFERS_CXX_FLAGS}")
|
||||
endif()
|
||||
message(STATUS "CMAKE_CXX_FLAGS: ${CMAKE_CXX_FLAGS}")
|
||||
|
||||
if(FLATBUFFERS_CODE_COVERAGE)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -fprofile-arcs -ftest-coverage")
|
||||
set(CMAKE_EXE_LINKER_FLAGS
|
||||
"${CMAKE_EXE_LINKER_FLAGS} -fprofile-arcs -ftest-coverage")
|
||||
endif()
|
||||
|
||||
function(add_fsanitize_to_target _target _sanitizer)
|
||||
if(WIN32)
|
||||
target_compile_definitions(${_target} PRIVATE FLATBUFFERS_MEMORY_LEAK_TRACKING)
|
||||
message(STATUS "Sanitizer MSVC::_CrtDumpMemoryLeaks added to ${_target}")
|
||||
else()
|
||||
# FLATBUFFERS_CODE_SANITIZE: boolean {ON,OFF,YES,NO} or string with list of sanitizer.
|
||||
# List of sanitizer is string starts with '=': "=address,undefined,thread,memory".
|
||||
if((${CMAKE_CXX_COMPILER_ID} MATCHES "Clang") OR
|
||||
((${CMAKE_CXX_COMPILER_ID} MATCHES "GNU") AND NOT (CMAKE_CXX_COMPILER_VERSION VERSION_LESS "4.9"))
|
||||
)
|
||||
set(_sanitizer_flags "=address,undefined")
|
||||
if(_sanitizer MATCHES "=.*")
|
||||
# override default by user-defined sanitizer list
|
||||
set(_sanitizer_flags ${_sanitizer})
|
||||
endif()
|
||||
target_compile_options(${_target} PRIVATE
|
||||
-g -fsigned-char -fno-omit-frame-pointer
|
||||
"-fsanitize${_sanitizer_flags}")
|
||||
target_link_libraries(${_target} PRIVATE
|
||||
"-fsanitize${_sanitizer_flags}")
|
||||
set_property(TARGET ${_target} PROPERTY POSITION_INDEPENDENT_CODE ON)
|
||||
message(STATUS "Sanitizer ${_sanitizer_flags} added to ${_target}")
|
||||
endif()
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
function(add_pch_to_target _target _pch_header)
|
||||
if(COMMAND target_precompile_headers)
|
||||
target_precompile_headers(${_target} PRIVATE ${_pch_header})
|
||||
if(NOT MSVC)
|
||||
set_source_files_properties(src/util.cpp PROPERTIES SKIP_PRECOMPILE_HEADERS ON)
|
||||
endif()
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
if(BIICODE)
|
||||
include(biicode/cmake/biicode.cmake)
|
||||
return()
|
||||
endif()
|
||||
|
||||
include_directories(include)
|
||||
include_directories(grpc)
|
||||
|
||||
if(FLATBUFFERS_BUILD_FLATLIB)
|
||||
add_library(flatbuffers STATIC ${FlatBuffers_Library_SRCS})
|
||||
# Attach header directory for when build via add_subdirectory().
|
||||
target_include_directories(flatbuffers INTERFACE
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>)
|
||||
target_compile_options(flatbuffers PRIVATE "${FLATBUFFERS_PRIVATE_CXX_FLAGS}")
|
||||
if(FLATBUFFERS_ENABLE_PCH)
|
||||
add_pch_to_target(flatbuffers include/flatbuffers/pch/pch.h)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(FLATBUFFERS_BUILD_FLATC)
|
||||
add_executable(flatc ${FlatBuffers_Compiler_SRCS})
|
||||
if(FLATBUFFERS_ENABLE_PCH)
|
||||
add_pch_to_target(flatc include/flatbuffers/pch/flatc_pch.h)
|
||||
endif()
|
||||
target_compile_options(flatc PRIVATE "${FLATBUFFERS_PRIVATE_CXX_FLAGS}")
|
||||
if(FLATBUFFERS_CODE_SANITIZE AND NOT WIN32)
|
||||
add_fsanitize_to_target(flatc ${FLATBUFFERS_CODE_SANITIZE})
|
||||
endif()
|
||||
if(NOT FLATBUFFERS_FLATC_EXECUTABLE)
|
||||
set(FLATBUFFERS_FLATC_EXECUTABLE $<TARGET_FILE:flatc>)
|
||||
endif()
|
||||
if(MSVC)
|
||||
# Make flatc.exe not depend on runtime dlls for easy distribution.
|
||||
target_compile_options(flatc PUBLIC $<$<CONFIG:Release>:/MT>)
|
||||
endif()
|
||||
if(FLATBUFFERS_STATIC_FLATC AND NOT MSVC)
|
||||
target_link_libraries(flatc PRIVATE -static)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(FLATBUFFERS_BUILD_FLATHASH)
|
||||
add_executable(flathash ${FlatHash_SRCS})
|
||||
endif()
|
||||
|
||||
if(FLATBUFFERS_BUILD_SHAREDLIB)
|
||||
add_library(flatbuffers_shared SHARED ${FlatBuffers_Library_SRCS})
|
||||
|
||||
# Shared object version: "major.minor.micro"
|
||||
# - micro updated every release when there is no API/ABI changes
|
||||
# - minor updated when there are additions in API/ABI
|
||||
# - major (ABI number) updated when there are changes in ABI (or removals)
|
||||
set(FlatBuffers_Library_SONAME_MAJOR ${VERSION_MAJOR})
|
||||
set(FlatBuffers_Library_SONAME_FULL "${FlatBuffers_Library_SONAME_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}")
|
||||
set_target_properties(flatbuffers_shared PROPERTIES OUTPUT_NAME flatbuffers
|
||||
SOVERSION "${FlatBuffers_Library_SONAME_MAJOR}"
|
||||
VERSION "${FlatBuffers_Library_SONAME_FULL}")
|
||||
if(FLATBUFFERS_ENABLE_PCH)
|
||||
add_pch_to_target(flatbuffers_shared include/flatbuffers/pch/pch.h)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Global list of generated files.
|
||||
# Use the global property to be independent of PARENT_SCOPE.
|
||||
set_property(GLOBAL PROPERTY FBS_GENERATED_OUTPUTS)
|
||||
|
||||
function(get_generated_output generated_files)
|
||||
get_property(tmp GLOBAL PROPERTY FBS_GENERATED_OUTPUTS)
|
||||
set(${generated_files} ${tmp} PARENT_SCOPE)
|
||||
endfunction(get_generated_output)
|
||||
|
||||
function(register_generated_output file_name)
|
||||
get_property(tmp GLOBAL PROPERTY FBS_GENERATED_OUTPUTS)
|
||||
list(APPEND tmp ${file_name})
|
||||
set_property(GLOBAL PROPERTY FBS_GENERATED_OUTPUTS ${tmp})
|
||||
endfunction(register_generated_output)
|
||||
|
||||
function(compile_flatbuffers_schema_to_cpp_opt SRC_FBS OPT)
|
||||
if(FLATBUFFERS_BUILD_LEGACY)
|
||||
set(OPT ${OPT};--cpp-std c++0x)
|
||||
else()
|
||||
# --cpp-std is defined by flatc default settings.
|
||||
endif()
|
||||
message(STATUS "`${SRC_FBS}`: add generation of C++ code with '${OPT}'")
|
||||
get_filename_component(SRC_FBS_DIR ${SRC_FBS} PATH)
|
||||
string(REGEX REPLACE "\\.fbs$" "_generated.h" GEN_HEADER ${SRC_FBS})
|
||||
add_custom_command(
|
||||
OUTPUT ${GEN_HEADER}
|
||||
COMMAND "${FLATBUFFERS_FLATC_EXECUTABLE}"
|
||||
--cpp --gen-mutable --gen-object-api --reflect-names
|
||||
--cpp-ptr-type flatbuffers::unique_ptr # Used to test with C++98 STLs
|
||||
${OPT}
|
||||
-I "${CMAKE_CURRENT_SOURCE_DIR}/tests/include_test"
|
||||
-o "${SRC_FBS_DIR}"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/${SRC_FBS}"
|
||||
DEPENDS flatc
|
||||
COMMENT "Run generation: '${GEN_HEADER}'")
|
||||
register_generated_output(${GEN_HEADER})
|
||||
endfunction()
|
||||
|
||||
function(compile_flatbuffers_schema_to_cpp SRC_FBS)
|
||||
compile_flatbuffers_schema_to_cpp_opt(${SRC_FBS} "--no-includes;--gen-compare")
|
||||
endfunction()
|
||||
|
||||
function(compile_flatbuffers_schema_to_binary SRC_FBS)
|
||||
message(STATUS "`${SRC_FBS}`: add generation of binary (.bfbs) schema")
|
||||
get_filename_component(SRC_FBS_DIR ${SRC_FBS} PATH)
|
||||
string(REGEX REPLACE "\\.fbs$" ".bfbs" GEN_BINARY_SCHEMA ${SRC_FBS})
|
||||
# For details about flags see generate_code.py
|
||||
add_custom_command(
|
||||
OUTPUT ${GEN_BINARY_SCHEMA}
|
||||
COMMAND "${FLATBUFFERS_FLATC_EXECUTABLE}"
|
||||
-b --schema --bfbs-comments --bfbs-builtins
|
||||
--bfbs-filenames ${SRC_FBS_DIR}
|
||||
-I "${CMAKE_CURRENT_SOURCE_DIR}/tests/include_test"
|
||||
-o "${SRC_FBS_DIR}"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/${SRC_FBS}"
|
||||
DEPENDS flatc
|
||||
COMMENT "Run generation: '${GEN_BINARY_SCHEMA}'")
|
||||
register_generated_output(${GEN_BINARY_SCHEMA})
|
||||
endfunction()
|
||||
|
||||
function(compile_flatbuffers_schema_to_embedded_binary SRC_FBS OPT)
|
||||
if(FLATBUFFERS_BUILD_LEGACY)
|
||||
set(OPT ${OPT};--cpp-std c++0x)
|
||||
else()
|
||||
# --cpp-std is defined by flatc default settings.
|
||||
endif()
|
||||
message(STATUS "`${SRC_FBS}`: add generation of C++ embedded binary schema code with '${OPT}'")
|
||||
get_filename_component(SRC_FBS_DIR ${SRC_FBS} PATH)
|
||||
string(REGEX REPLACE "\\.fbs$" "_bfbs_generated.h" GEN_BFBS_HEADER ${SRC_FBS})
|
||||
# For details about flags see generate_code.py
|
||||
add_custom_command(
|
||||
OUTPUT ${GEN_BFBS_HEADER}
|
||||
COMMAND "${FLATBUFFERS_FLATC_EXECUTABLE}"
|
||||
--cpp --gen-mutable --gen-object-api --reflect-names
|
||||
--cpp-ptr-type flatbuffers::unique_ptr # Used to test with C++98 STLs
|
||||
${OPT}
|
||||
--bfbs-comments --bfbs-builtins --bfbs-gen-embed
|
||||
--bfbs-filenames ${SRC_FBS_DIR}
|
||||
-I "${CMAKE_CURRENT_SOURCE_DIR}/tests/include_test"
|
||||
-o "${SRC_FBS_DIR}"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/${SRC_FBS}"
|
||||
DEPENDS flatc
|
||||
COMMENT "Run generation: '${GEN_BFBS_HEADER}'")
|
||||
register_generated_output(${GEN_BFBS_HEADER})
|
||||
endfunction()
|
||||
|
||||
# Look if we have python 3.5 installed so that we can run the generate code
|
||||
# python script after flatc is built.
|
||||
find_package(PythonInterp 3.5)
|
||||
|
||||
if(PYTHONINTERP_FOUND AND
|
||||
# Skip doing this if the MSVC version is below VS 12.
|
||||
# https://cmake.org/cmake/help/latest/variable/MSVC_VERSION.html
|
||||
(NOT MSVC OR MSVC_VERSION GREATER 1800))
|
||||
set(GENERATION_SCRIPT ${PYTHON_EXECUTABLE} scripts/generate_code.py)
|
||||
if(FLATBUFFERS_BUILD_LEGACY)
|
||||
# Need to set --cpp-std c++-0x options
|
||||
set(GENERATION_SCRIPT ${GENERATION_SCRIPT} --cpp-0x)
|
||||
endif()
|
||||
if(FLATBUFFERS_SKIP_MONSTER_EXTRA)
|
||||
set(GENERATION_SCRIPT ${GENERATION_SCRIPT} --skip-monster-extra)
|
||||
endif()
|
||||
add_custom_command(
|
||||
TARGET flatc
|
||||
POST_BUILD
|
||||
COMMAND ${GENERATION_SCRIPT} --flatc "${FLATBUFFERS_FLATC_EXECUTABLE}"
|
||||
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
|
||||
COMMENT "Running ${GENERATION_SCRIPT}..."
|
||||
VERBATIM)
|
||||
else()
|
||||
message("No Python3 interpreter found! Unable to generate files automatically.")
|
||||
endif()
|
||||
|
||||
if(FLATBUFFERS_BUILD_TESTS)
|
||||
file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/tests" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}")
|
||||
file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/samples" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}")
|
||||
|
||||
# TODO Add (monster_test.fbs monsterdata_test.json)->monsterdata_test.mon
|
||||
compile_flatbuffers_schema_to_cpp(tests/monster_test.fbs)
|
||||
compile_flatbuffers_schema_to_binary(tests/monster_test.fbs)
|
||||
compile_flatbuffers_schema_to_cpp_opt(tests/namespace_test/namespace_test1.fbs "--no-includes;--gen-compare;--gen-name-strings")
|
||||
compile_flatbuffers_schema_to_cpp_opt(tests/namespace_test/namespace_test2.fbs "--no-includes;--gen-compare;--gen-name-strings")
|
||||
compile_flatbuffers_schema_to_cpp_opt(tests/union_vector/union_vector.fbs "--no-includes;--gen-compare;--gen-name-strings")
|
||||
compile_flatbuffers_schema_to_cpp(tests/optional_scalars.fbs)
|
||||
compile_flatbuffers_schema_to_cpp_opt(tests/native_type_test.fbs "")
|
||||
compile_flatbuffers_schema_to_cpp_opt(tests/arrays_test.fbs "--scoped-enums;--gen-compare")
|
||||
compile_flatbuffers_schema_to_binary(tests/arrays_test.fbs)
|
||||
compile_flatbuffers_schema_to_embedded_binary(tests/monster_test.fbs "--no-includes;--gen-compare")
|
||||
if(NOT (MSVC AND (MSVC_VERSION LESS 1900)))
|
||||
compile_flatbuffers_schema_to_cpp(tests/monster_extra.fbs) # Test floating-point NAN/INF.
|
||||
endif()
|
||||
include_directories(${CMAKE_CURRENT_BINARY_DIR}/tests)
|
||||
add_executable(flattests ${FlatBuffers_Tests_SRCS})
|
||||
add_dependencies(flattests generated_code)
|
||||
set_property(TARGET flattests
|
||||
PROPERTY COMPILE_DEFINITIONS FLATBUFFERS_TRACK_VERIFIER_BUFFER_SIZE
|
||||
FLATBUFFERS_DEBUG_VERIFICATION_FAILURE=1)
|
||||
if(FLATBUFFERS_CODE_SANITIZE)
|
||||
add_fsanitize_to_target(flattests ${FLATBUFFERS_CODE_SANITIZE})
|
||||
endif()
|
||||
|
||||
compile_flatbuffers_schema_to_cpp(samples/monster.fbs)
|
||||
compile_flatbuffers_schema_to_binary(samples/monster.fbs)
|
||||
include_directories(${CMAKE_CURRENT_BINARY_DIR}/samples)
|
||||
add_executable(flatsamplebinary ${FlatBuffers_Sample_Binary_SRCS})
|
||||
add_dependencies(flatsamplebinary generated_code)
|
||||
add_executable(flatsampletext ${FlatBuffers_Sample_Text_SRCS})
|
||||
add_dependencies(flatsampletext generated_code)
|
||||
add_executable(flatsamplebfbs ${FlatBuffers_Sample_BFBS_SRCS})
|
||||
add_dependencies(flatsamplebfbs generated_code)
|
||||
|
||||
if(FLATBUFFERS_BUILD_CPP17)
|
||||
# Don't generate header for flattests_cpp17 target.
|
||||
# This target uses "generated_cpp17/monster_test_generated.h"
|
||||
# produced by direct call of generate_code.py script.
|
||||
add_executable(flattests_cpp17 ${FlatBuffers_Tests_CPP17_SRCS})
|
||||
add_dependencies(flattests_cpp17 generated_code)
|
||||
target_compile_features(flattests_cpp17 PRIVATE cxx_std_17)
|
||||
target_compile_definitions(flattests_cpp17 PRIVATE
|
||||
FLATBUFFERS_TRACK_VERIFIER_BUFFER_SIZE
|
||||
FLATBUFFERS_DEBUG_VERIFICATION_FAILURE=1
|
||||
)
|
||||
if(FLATBUFFERS_CODE_SANITIZE)
|
||||
add_fsanitize_to_target(flattests_cpp17 ${FLATBUFFERS_CODE_SANITIZE})
|
||||
endif()
|
||||
endif(FLATBUFFERS_BUILD_CPP17)
|
||||
endif()
|
||||
|
||||
if(FLATBUFFERS_BUILD_GRPCTEST)
|
||||
if(CMAKE_COMPILER_IS_GNUCXX)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-parameter -Wno-shadow")
|
||||
endif()
|
||||
if(NOT GRPC_INSTALL_PATH)
|
||||
message(SEND_ERROR "GRPC_INSTALL_PATH variable is not defined. See grpc/README.md")
|
||||
endif()
|
||||
if(NOT PROTOBUF_DOWNLOAD_PATH)
|
||||
message(SEND_ERROR "PROTOBUF_DOWNLOAD_PATH variable is not defined. See grpc/README.md")
|
||||
endif()
|
||||
INCLUDE_DIRECTORIES(${GRPC_INSTALL_PATH}/include)
|
||||
INCLUDE_DIRECTORIES(${PROTOBUF_DOWNLOAD_PATH}/src)
|
||||
find_package(Threads REQUIRED)
|
||||
list(APPEND CMAKE_PREFIX_PATH ${GRPC_INSTALL_PATH})
|
||||
find_package(absl CONFIG REQUIRED)
|
||||
find_package(protobuf CONFIG REQUIRED)
|
||||
find_package(gRPC CONFIG REQUIRED)
|
||||
add_executable(grpctest ${FlatBuffers_GRPCTest_SRCS})
|
||||
add_dependencies(grpctest generated_code)
|
||||
target_link_libraries(grpctest PRIVATE gRPC::grpc++_unsecure gRPC::grpc_unsecure gRPC::gpr pthread dl)
|
||||
if(FLATBUFFERS_CODE_SANITIZE AND NOT WIN32)
|
||||
# GRPC test has problems with alignment and will fail under ASAN/UBSAN.
|
||||
# add_fsanitize_to_target(grpctest ${FLATBUFFERS_CODE_SANITIZE})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
||||
if(FLATBUFFERS_INSTALL)
|
||||
include(GNUInstallDirs)
|
||||
|
||||
install(DIRECTORY include/flatbuffers DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
|
||||
|
||||
set(FB_CMAKE_DIR "${CMAKE_INSTALL_LIBDIR}/cmake/flatbuffers")
|
||||
|
||||
configure_file(CMake/flatbuffers-config-version.cmake.in flatbuffers-config-version.cmake @ONLY)
|
||||
install(
|
||||
FILES "CMake/flatbuffers-config.cmake" "${CMAKE_CURRENT_BINARY_DIR}/flatbuffers-config-version.cmake"
|
||||
DESTINATION ${FB_CMAKE_DIR}
|
||||
)
|
||||
|
||||
if(FLATBUFFERS_BUILD_FLATLIB)
|
||||
if(CMAKE_VERSION VERSION_LESS 3.0)
|
||||
install(
|
||||
TARGETS flatbuffers EXPORT FlatBuffersTargets
|
||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
)
|
||||
else()
|
||||
install(
|
||||
TARGETS flatbuffers EXPORT FlatBuffersTargets
|
||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
|
||||
)
|
||||
endif()
|
||||
|
||||
install(EXPORT FlatBuffersTargets
|
||||
FILE FlatBuffersTargets.cmake
|
||||
NAMESPACE flatbuffers::
|
||||
DESTINATION ${FB_CMAKE_DIR}
|
||||
)
|
||||
endif()
|
||||
|
||||
if(FLATBUFFERS_BUILD_FLATC)
|
||||
install(
|
||||
TARGETS flatc EXPORT FlatcTargets
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
)
|
||||
|
||||
install(
|
||||
EXPORT FlatcTargets
|
||||
FILE FlatcTargets.cmake
|
||||
NAMESPACE flatbuffers::
|
||||
DESTINATION ${FB_CMAKE_DIR}
|
||||
)
|
||||
endif()
|
||||
|
||||
if(FLATBUFFERS_BUILD_SHAREDLIB)
|
||||
if(CMAKE_VERSION VERSION_LESS 3.0)
|
||||
install(
|
||||
TARGETS flatbuffers_shared EXPORT FlatBuffersSharedTargets
|
||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
)
|
||||
else()
|
||||
install(
|
||||
TARGETS flatbuffers_shared EXPORT FlatBuffersSharedTargets
|
||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
|
||||
)
|
||||
endif()
|
||||
|
||||
install(
|
||||
EXPORT FlatBuffersSharedTargets
|
||||
FILE FlatBuffersSharedTargets.cmake
|
||||
NAMESPACE flatbuffers::
|
||||
DESTINATION ${FB_CMAKE_DIR}
|
||||
)
|
||||
endif()
|
||||
|
||||
if(FLATBUFFERS_BUILD_SHAREDLIB OR FLATBUFFERS_BUILD_FLATLIB)
|
||||
configure_file(CMake/flatbuffers.pc.in flatbuffers.pc @ONLY)
|
||||
install(
|
||||
FILES "${CMAKE_CURRENT_BINARY_DIR}/flatbuffers.pc"
|
||||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(FLATBUFFERS_BUILD_TESTS)
|
||||
enable_testing()
|
||||
|
||||
add_test(NAME flattests COMMAND flattests)
|
||||
if(FLATBUFFERS_BUILD_CPP17)
|
||||
add_test(NAME flattests_cpp17 COMMAND flattests_cpp17)
|
||||
endif()
|
||||
if(FLATBUFFERS_BUILD_GRPCTEST)
|
||||
add_test(NAME grpctest COMMAND grpctest)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# This target is sync-barrier.
|
||||
# Other generate-dependent targets can depend on 'generated_code' only.
|
||||
get_generated_output(fbs_generated)
|
||||
if(fbs_generated)
|
||||
# message(STATUS "Add generated_code target with files:${fbs_generated}")
|
||||
add_custom_target(generated_code
|
||||
DEPENDS ${fbs_generated}
|
||||
COMMENT "All generated files were updated.")
|
||||
endif()
|
||||
|
||||
include(CMake/BuildFlatBuffers.cmake)
|
||||
|
||||
if(UNIX)
|
||||
# Use of CPack only supported on Linux systems.
|
||||
if(FLATBUFFERS_PACKAGE_DEBIAN)
|
||||
include(CMake/PackageDebian.cmake)
|
||||
include(CPack)
|
||||
endif()
|
||||
if (FLATBUFFERS_PACKAGE_REDHAT)
|
||||
include(CMake/PackageRedhat.cmake)
|
||||
include(CPack)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Include for running Google Benchmarks.
|
||||
if(FLATBUFFERS_BUILD_BENCHMARKS AND CMAKE_VERSION VERSION_GREATER 3.13)
|
||||
add_subdirectory(benchmarks)
|
||||
endif()
|
||||
|
||||
# Add FlatBuffers::FlatBuffers interface, needed for FetchContent_Declare
|
||||
add_library(FlatBuffers INTERFACE)
|
||||
add_library(FlatBuffers::FlatBuffers ALIAS FlatBuffers)
|
||||
target_include_directories(
|
||||
FlatBuffers
|
||||
INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
||||
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/include>)
|
||||
@@ -17,23 +17,9 @@ if (UNIX)
|
||||
SET(CPACK_PACKAGE_VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}-${VERSION_COMMIT}")
|
||||
SET(CPACK_DEBIAN_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION}")
|
||||
|
||||
# Derive architecture
|
||||
IF(NOT CPACK_DEBIAN_PACKAGE_ARCHITECTURE)
|
||||
FIND_PROGRAM(DPKG_CMD dpkg)
|
||||
IF(NOT DPKG_CMD)
|
||||
MESSAGE(STATUS "Can not find dpkg in your path, default to i386.")
|
||||
SET(CPACK_DEBIAN_PACKAGE_ARCHITECTURE i386)
|
||||
ENDIF(NOT DPKG_CMD)
|
||||
EXECUTE_PROCESS(COMMAND "${DPKG_CMD}" --print-architecture
|
||||
OUTPUT_VARIABLE CPACK_DEBIAN_PACKAGE_ARCHITECTURE
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
ENDIF(NOT CPACK_DEBIAN_PACKAGE_ARCHITECTURE)
|
||||
|
||||
# Package name
|
||||
SET(CPACK_DEBIAN_PACKAGE_NAME "flatbuffers")
|
||||
SET(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_SOURCE_DIR}/LICENSE.txt)
|
||||
SET(CPACK_PACKAGE_FILE_NAME
|
||||
"${CPACK_DEBIAN_PACKAGE_NAME}_${CPACK_DEBIAN_PACKAGE_VERSION}_${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}")
|
||||
SET(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_SOURCE_DIR}/LICENSE)
|
||||
set(CPACK_DEBIAN_FILE_NAME "DEB-DEFAULT")
|
||||
|
||||
endif(UNIX)
|
||||
|
||||
@@ -15,7 +15,7 @@ if (UNIX)
|
||||
|
||||
set(CPACK_RPM_PACKAGE_NAME "flatbuffers")
|
||||
|
||||
# Assume this is not a cross complation build.
|
||||
# Assume this is not a cross compilation build.
|
||||
if(NOT CPACK_RPM_PACKAGE_ARCHITECTURE)
|
||||
set(CPACK_RPM_PACKAGE_ARCHITECTURE "${CMAKE_SYSTEM_PROCESSOR}")
|
||||
endif(NOT CPACK_RPM_PACKAGE_ARCHITECTURE)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
set(VERSION_MAJOR 22)
|
||||
set(VERSION_MINOR 12)
|
||||
set(VERSION_PATCH 06)
|
||||
set(VERSION_MAJOR 23)
|
||||
set(VERSION_MINOR 3)
|
||||
set(VERSION_PATCH 3)
|
||||
set(VERSION_COMMIT 0)
|
||||
|
||||
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.git")
|
||||
|
||||
@@ -1,32 +1,12 @@
|
||||
# This is the legacy minimum version flatbuffers supported for a while.
|
||||
cmake_minimum_required(VERSION 2.8.12...3.22.1)
|
||||
|
||||
# CMake version 3.16 is the 'de-facto' minimum version for flatbuffers. If the
|
||||
# current cmake is older than this, warn the user and include the legacy file to
|
||||
# provide some level of support.
|
||||
if(CMAKE_VERSION VERSION_LESS 3.16)
|
||||
message(WARNING "Using cmake version ${CMAKE_VERSION} which is older than "
|
||||
"our target version of 3.16. This will use the legacy CMakeLists.txt that "
|
||||
"supports version 2.8.12 and higher, but not actively maintained. Consider "
|
||||
"upgrading cmake to a newer version, as this may become a fatal error in the "
|
||||
"future.")
|
||||
# Use the legacy version of CMakeLists.txt
|
||||
include(CMake/CMakeLists_legacy.cmake.in)
|
||||
return()
|
||||
endif()
|
||||
cmake_minimum_required(VERSION 3.8...3.25.2)
|
||||
|
||||
# Attempt to read the current version of flatbuffers by looking at the latest tag.
|
||||
include(CMake/Version.cmake)
|
||||
|
||||
if (POLICY CMP0048)
|
||||
cmake_policy(SET CMP0048 NEW)
|
||||
project(FlatBuffers
|
||||
DESCRIPTION "Flatbuffers serialization library"
|
||||
project(FlatBuffers
|
||||
VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}
|
||||
LANGUAGES CXX)
|
||||
else()
|
||||
project(FlatBuffers)
|
||||
endif (POLICY CMP0048)
|
||||
|
||||
# generate compile_commands.json
|
||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||
@@ -87,6 +67,12 @@ if(MSVC OR CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL "MSVC")
|
||||
set(MSVC_LIKE ON)
|
||||
endif()
|
||||
|
||||
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||
set(IS_CLANG ON)
|
||||
else()
|
||||
set(IS_CLANG OFF)
|
||||
endif()
|
||||
|
||||
if(DEFINED FLATBUFFERS_COMPILATION_TIMINGS)
|
||||
message("Recording Compilation Timings to ${FLATBUFFERS_COMPILATION_TIMINGS}")
|
||||
file(REMOVE ${FLATBUFFERS_COMPILATION_TIMINGS})
|
||||
@@ -136,11 +122,11 @@ set(FlatBuffers_Library_SRCS
|
||||
include/flatbuffers/allocator.h
|
||||
include/flatbuffers/array.h
|
||||
include/flatbuffers/base.h
|
||||
include/flatbuffers/bfbs_generator.h
|
||||
include/flatbuffers/buffer.h
|
||||
include/flatbuffers/buffer_ref.h
|
||||
include/flatbuffers/default_allocator.h
|
||||
include/flatbuffers/detached_buffer.h
|
||||
include/flatbuffers/code_generator.h
|
||||
include/flatbuffers/flatbuffer_builder.h
|
||||
include/flatbuffers/flatbuffers.h
|
||||
include/flatbuffers/flexbuffers.h
|
||||
@@ -167,6 +153,8 @@ set(FlatBuffers_Library_SRCS
|
||||
|
||||
set(FlatBuffers_Compiler_SRCS
|
||||
${FlatBuffers_Library_SRCS}
|
||||
src/idl_gen_binary.cpp
|
||||
src/idl_gen_text.cpp
|
||||
src/idl_gen_cpp.cpp
|
||||
src/idl_gen_csharp.cpp
|
||||
src/idl_gen_dart.cpp
|
||||
@@ -322,7 +310,7 @@ set(FlatBuffers_GRPCTest_SRCS
|
||||
# TODO(dbaileychess): Figure out how this would now work. I posted a question on
|
||||
# https://stackoverflow.com/questions/71772330/override-target-compile-options-via-cmake-command-line.
|
||||
# Append FLATBUFFERS_CXX_FLAGS to CMAKE_CXX_FLAGS.
|
||||
if(DEFINED FLATBUFFERS_CXX_FLAGS AND NOT EXISTS "${CMAKE_TOOLCHAIN_FILE}")
|
||||
if(DEFINED FLATBUFFERS_CXX_FLAGS)
|
||||
message(STATUS "extend CXX_FLAGS with ${FLATBUFFERS_CXX_FLAGS}")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${FLATBUFFERS_CXX_FLAGS}")
|
||||
endif()
|
||||
@@ -335,9 +323,7 @@ function(add_fsanitize_to_target _target _sanitizer)
|
||||
else()
|
||||
# FLATBUFFERS_CODE_SANITIZE: boolean {ON,OFF,YES,NO} or string with list of sanitizer.
|
||||
# List of sanitizer is string starts with '=': "=address,undefined,thread,memory".
|
||||
if((${CMAKE_CXX_COMPILER_ID} MATCHES "Clang") OR
|
||||
((${CMAKE_CXX_COMPILER_ID} MATCHES "GNU") AND NOT (CMAKE_CXX_COMPILER_VERSION VERSION_LESS "4.9"))
|
||||
)
|
||||
if(IS_CLANG OR (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 4.9))
|
||||
set(_sanitizer_flags "=address,undefined")
|
||||
if(_sanitizer MATCHES "=.*")
|
||||
# override default by user-defined sanitizer list
|
||||
@@ -348,13 +334,14 @@ function(add_fsanitize_to_target _target _sanitizer)
|
||||
"-fsanitize${_sanitizer_flags}")
|
||||
target_link_libraries(${_target} PRIVATE
|
||||
"-fsanitize${_sanitizer_flags}")
|
||||
set_property(TARGET ${_target} PROPERTY POSITION_INDEPENDENT_CODE ON)
|
||||
set_target_properties(${_target} PROPERTIES POSITION_INDEPENDENT_CODE ON)
|
||||
message(STATUS "Sanitizer ${_sanitizer_flags} added to ${_target}")
|
||||
endif()
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
function(add_pch_to_target _target _pch_header)
|
||||
# the command is available since cmake 3.16
|
||||
if(COMMAND target_precompile_headers)
|
||||
target_precompile_headers(${_target} PRIVATE ${_pch_header})
|
||||
if(NOT MSVC)
|
||||
@@ -398,11 +385,6 @@ if(MSVC_LIKE)
|
||||
>
|
||||
)
|
||||
else()
|
||||
if("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
|
||||
set(IS_CLANG ON)
|
||||
else()
|
||||
set(IS_CLANG OFF)
|
||||
endif()
|
||||
target_compile_options(ProjectConfig
|
||||
INTERFACE
|
||||
-Wall
|
||||
@@ -426,6 +408,7 @@ else()
|
||||
|
||||
# This isn't working for some reason: $<$<CXX_COMPILER_ID:CLANG>:
|
||||
$<$<BOOL:${IS_CLANG}>:
|
||||
-Wnewline-eof
|
||||
-Wno-unknown-warning-option
|
||||
-Wmissing-declarations
|
||||
-Wzero-as-null-pointer-constant
|
||||
@@ -498,7 +481,7 @@ if(FLATBUFFERS_BUILD_FLATC)
|
||||
|
||||
target_link_libraries(flatc PRIVATE $<BUILD_INTERFACE:ProjectConfig>)
|
||||
target_compile_options(flatc
|
||||
PUBLIC
|
||||
PRIVATE
|
||||
$<$<AND:$<BOOL:${MSVC_LIKE}>,$<CONFIG:Release>>:
|
||||
/MT
|
||||
>
|
||||
@@ -523,14 +506,13 @@ endif()
|
||||
if(FLATBUFFERS_BUILD_SHAREDLIB)
|
||||
add_library(flatbuffers_shared SHARED ${FlatBuffers_Library_SRCS})
|
||||
target_link_libraries(flatbuffers_shared PRIVATE $<BUILD_INTERFACE:ProjectConfig>)
|
||||
# Shared object version: "major.minor.micro"
|
||||
# - micro updated every release when there is no API/ABI changes
|
||||
# - minor updated when there are additions in API/ABI
|
||||
# - major (ABI number) updated when there are changes in ABI (or removals)
|
||||
set(FlatBuffers_Library_SONAME_MAJOR ${VERSION_MAJOR})
|
||||
set(FlatBuffers_Library_SONAME_FULL "${FlatBuffers_Library_SONAME_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}")
|
||||
set_target_properties(flatbuffers_shared PROPERTIES OUTPUT_NAME flatbuffers
|
||||
SOVERSION "${FlatBuffers_Library_SONAME_MAJOR}"
|
||||
# FlatBuffers use calendar-based versioning and do not provide any ABI
|
||||
# stability guarantees. Therefore, always use the full version as SOVERSION
|
||||
# in order to avoid breaking reverse dependencies on upgrades.
|
||||
set(FlatBuffers_Library_SONAME_FULL "${PROJECT_VERSION}")
|
||||
set_target_properties(flatbuffers_shared PROPERTIES
|
||||
OUTPUT_NAME flatbuffers
|
||||
SOVERSION "${FlatBuffers_Library_SONAME_FULL}"
|
||||
VERSION "${FlatBuffers_Library_SONAME_FULL}")
|
||||
if(FLATBUFFERS_ENABLE_PCH)
|
||||
add_pch_to_target(flatbuffers_shared include/flatbuffers/pch/pch.h)
|
||||
@@ -676,7 +658,7 @@ if(FLATBUFFERS_BUILD_TESTS)
|
||||
add_executable(flattests_cpp17 ${FlatBuffers_Tests_CPP17_SRCS})
|
||||
add_dependencies(flattests_cpp17 generated_code)
|
||||
target_link_libraries(flattests_cpp17 PRIVATE $<BUILD_INTERFACE:ProjectConfig>)
|
||||
target_compile_features(flattests_cpp17 PRIVATE cxx_std_17)
|
||||
target_compile_features(flattests_cpp17 PRIVATE cxx_std_17) # requires cmake 3.8
|
||||
|
||||
if(FLATBUFFERS_CODE_SANITIZE)
|
||||
add_fsanitize_to_target(flattests_cpp17 ${FLATBUFFERS_CODE_SANITIZE})
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
Pod::Spec.new do |s|
|
||||
s.name = 'FlatBuffers'
|
||||
s.version = '22.12.06'
|
||||
s.version = '23.3.3'
|
||||
s.summary = 'FlatBuffers: Memory Efficient Serialization Library'
|
||||
|
||||
s.description = "FlatBuffers is a cross platform serialization library architected for
|
||||
|
||||
@@ -32,6 +32,6 @@ let package = Package(
|
||||
.target(
|
||||
name: "FlatBuffers",
|
||||
dependencies: [],
|
||||
path: "swift/Sources")
|
||||
path: "swift/Sources"),
|
||||
])
|
||||
|
||||
|
||||
@@ -94,8 +94,12 @@ yarn_install(
|
||||
name = "npm",
|
||||
exports_directories_only = False,
|
||||
# Unfreeze to add/remove packages.
|
||||
frozen_lockfile = True,
|
||||
frozen_lockfile = False,
|
||||
package_json = "//:package.json",
|
||||
symlink_node_modules = False,
|
||||
yarn_lock = "//:yarn.lock",
|
||||
)
|
||||
|
||||
load("@build_bazel_rules_nodejs//toolchains/esbuild:esbuild_repositories.bzl", "esbuild_repositories")
|
||||
|
||||
esbuild_repositories(npm_repository = "npm")
|
||||
|
||||
@@ -1,20 +1,22 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- Copyright (c) 2014 Google, Inc.
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
-->
|
||||
<projectDescription>
|
||||
<name>FlatBufferTest</name>
|
||||
<name>FlatBufferTest</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
</natures>
|
||||
<filteredResources>
|
||||
<filter>
|
||||
<id>1677235311958</id>
|
||||
<name></name>
|
||||
<type>30</type>
|
||||
<matcher>
|
||||
<id>org.eclipse.core.resources.regexFilterMatcher</id>
|
||||
<arguments>node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
|
||||
</matcher>
|
||||
</filter>
|
||||
</filteredResources>
|
||||
</projectDescription>
|
||||
|
||||
@@ -1,15 +1,13 @@
|
||||
apply plugin: 'com.android.application'
|
||||
apply plugin: 'kotlin-android'
|
||||
apply plugin: 'kotlin-android-extensions'
|
||||
|
||||
android {
|
||||
compileSdkVersion 30
|
||||
buildToolsVersion "30.0.2"
|
||||
compileSdk 33
|
||||
|
||||
defaultConfig {
|
||||
applicationId "com.flatbuffers.app"
|
||||
minSdkVersion 26
|
||||
targetSdkVersion 30
|
||||
targetSdkVersion 33
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
|
||||
@@ -113,13 +111,13 @@ android {
|
||||
dependsOn(generateFbsCpp)
|
||||
}
|
||||
}
|
||||
namespace 'com.flatbuffers.app'
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation fileTree(dir: "libs", include: ["*.jar"])
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
||||
implementation 'androidx.core:core-ktx:1.3.2'
|
||||
implementation 'androidx.appcompat:appcompat:1.2.0'
|
||||
implementation 'androidx.appcompat:appcompat:1.6.1'
|
||||
|
||||
// If you using java runtime you can add its dependency as the example below
|
||||
// implementation 'com.google.flatbuffers:flatbuffers-java:$latest_version'
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.flatbuffers.app">
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
@@ -9,7 +8,8 @@
|
||||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/AppTheme">
|
||||
<activity android:name=".MainActivity">
|
||||
<activity android:name=".MainActivity"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
|
||||
@@ -18,7 +18,6 @@ set(FlatBuffers_Library_SRCS
|
||||
${FLATBUFFERS_SRC}/include/flatbuffers/allocator.h
|
||||
${FLATBUFFERS_SRC}/include/flatbuffers/array.h
|
||||
${FLATBUFFERS_SRC}/include/flatbuffers/base.h
|
||||
${FLATBUFFERS_SRC}/include/flatbuffers/bfbs_generator.h
|
||||
${FLATBUFFERS_SRC}/include/flatbuffers/buffer.h
|
||||
${FLATBUFFERS_SRC}/include/flatbuffers/buffer_ref.h
|
||||
${FLATBUFFERS_SRC}/include/flatbuffers/default_allocator.h
|
||||
|
||||
@@ -8,9 +8,9 @@
|
||||
|
||||
// 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,
|
||||
static_assert(FLATBUFFERS_VERSION_MAJOR == 23 &&
|
||||
FLATBUFFERS_VERSION_MINOR == 1 &&
|
||||
FLATBUFFERS_VERSION_REVISION == 21,
|
||||
"Non-compatible flatbuffers version included");
|
||||
|
||||
namespace com {
|
||||
@@ -20,23 +20,23 @@ namespace app {
|
||||
struct Animal;
|
||||
struct AnimalBuilder;
|
||||
|
||||
struct Animal FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
|
||||
struct Animal FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
||||
typedef AnimalBuilder Builder;
|
||||
enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
|
||||
VT_NAME = 4,
|
||||
VT_SOUND = 6,
|
||||
VT_WEIGHT = 8
|
||||
};
|
||||
const flatbuffers::String *name() const {
|
||||
return GetPointer<const flatbuffers::String *>(VT_NAME);
|
||||
const ::flatbuffers::String *name() const {
|
||||
return GetPointer<const ::flatbuffers::String *>(VT_NAME);
|
||||
}
|
||||
const flatbuffers::String *sound() const {
|
||||
return GetPointer<const flatbuffers::String *>(VT_SOUND);
|
||||
const ::flatbuffers::String *sound() const {
|
||||
return GetPointer<const ::flatbuffers::String *>(VT_SOUND);
|
||||
}
|
||||
uint16_t weight() const {
|
||||
return GetField<uint16_t>(VT_WEIGHT, 0);
|
||||
}
|
||||
bool Verify(flatbuffers::Verifier &verifier) const {
|
||||
bool Verify(::flatbuffers::Verifier &verifier) const {
|
||||
return VerifyTableStart(verifier) &&
|
||||
VerifyOffset(verifier, VT_NAME) &&
|
||||
verifier.VerifyString(name()) &&
|
||||
@@ -49,32 +49,32 @@ struct Animal FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
|
||||
|
||||
struct AnimalBuilder {
|
||||
typedef Animal Table;
|
||||
flatbuffers::FlatBufferBuilder &fbb_;
|
||||
flatbuffers::uoffset_t start_;
|
||||
void add_name(flatbuffers::Offset<flatbuffers::String> name) {
|
||||
::flatbuffers::FlatBufferBuilder &fbb_;
|
||||
::flatbuffers::uoffset_t start_;
|
||||
void add_name(::flatbuffers::Offset<::flatbuffers::String> name) {
|
||||
fbb_.AddOffset(Animal::VT_NAME, name);
|
||||
}
|
||||
void add_sound(flatbuffers::Offset<flatbuffers::String> sound) {
|
||||
void add_sound(::flatbuffers::Offset<::flatbuffers::String> sound) {
|
||||
fbb_.AddOffset(Animal::VT_SOUND, sound);
|
||||
}
|
||||
void add_weight(uint16_t weight) {
|
||||
fbb_.AddElement<uint16_t>(Animal::VT_WEIGHT, weight, 0);
|
||||
}
|
||||
explicit AnimalBuilder(flatbuffers::FlatBufferBuilder &_fbb)
|
||||
explicit AnimalBuilder(::flatbuffers::FlatBufferBuilder &_fbb)
|
||||
: fbb_(_fbb) {
|
||||
start_ = fbb_.StartTable();
|
||||
}
|
||||
flatbuffers::Offset<Animal> Finish() {
|
||||
::flatbuffers::Offset<Animal> Finish() {
|
||||
const auto end = fbb_.EndTable(start_);
|
||||
auto o = flatbuffers::Offset<Animal>(end);
|
||||
auto o = ::flatbuffers::Offset<Animal>(end);
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
||||
inline flatbuffers::Offset<Animal> CreateAnimal(
|
||||
flatbuffers::FlatBufferBuilder &_fbb,
|
||||
flatbuffers::Offset<flatbuffers::String> name = 0,
|
||||
flatbuffers::Offset<flatbuffers::String> sound = 0,
|
||||
inline ::flatbuffers::Offset<Animal> CreateAnimal(
|
||||
::flatbuffers::FlatBufferBuilder &_fbb,
|
||||
::flatbuffers::Offset<::flatbuffers::String> name = 0,
|
||||
::flatbuffers::Offset<::flatbuffers::String> sound = 0,
|
||||
uint16_t weight = 0) {
|
||||
AnimalBuilder builder_(_fbb);
|
||||
builder_.add_sound(sound);
|
||||
@@ -83,8 +83,8 @@ inline flatbuffers::Offset<Animal> CreateAnimal(
|
||||
return builder_.Finish();
|
||||
}
|
||||
|
||||
inline flatbuffers::Offset<Animal> CreateAnimalDirect(
|
||||
flatbuffers::FlatBufferBuilder &_fbb,
|
||||
inline ::flatbuffers::Offset<Animal> CreateAnimalDirect(
|
||||
::flatbuffers::FlatBufferBuilder &_fbb,
|
||||
const char *name = nullptr,
|
||||
const char *sound = nullptr,
|
||||
uint16_t weight = 0) {
|
||||
@@ -98,32 +98,32 @@ inline flatbuffers::Offset<Animal> CreateAnimalDirect(
|
||||
}
|
||||
|
||||
inline const com::fbs::app::Animal *GetAnimal(const void *buf) {
|
||||
return flatbuffers::GetRoot<com::fbs::app::Animal>(buf);
|
||||
return ::flatbuffers::GetRoot<com::fbs::app::Animal>(buf);
|
||||
}
|
||||
|
||||
inline const com::fbs::app::Animal *GetSizePrefixedAnimal(const void *buf) {
|
||||
return flatbuffers::GetSizePrefixedRoot<com::fbs::app::Animal>(buf);
|
||||
return ::flatbuffers::GetSizePrefixedRoot<com::fbs::app::Animal>(buf);
|
||||
}
|
||||
|
||||
inline bool VerifyAnimalBuffer(
|
||||
flatbuffers::Verifier &verifier) {
|
||||
::flatbuffers::Verifier &verifier) {
|
||||
return verifier.VerifyBuffer<com::fbs::app::Animal>(nullptr);
|
||||
}
|
||||
|
||||
inline bool VerifySizePrefixedAnimalBuffer(
|
||||
flatbuffers::Verifier &verifier) {
|
||||
::flatbuffers::Verifier &verifier) {
|
||||
return verifier.VerifySizePrefixedBuffer<com::fbs::app::Animal>(nullptr);
|
||||
}
|
||||
|
||||
inline void FinishAnimalBuffer(
|
||||
flatbuffers::FlatBufferBuilder &fbb,
|
||||
flatbuffers::Offset<com::fbs::app::Animal> root) {
|
||||
::flatbuffers::FlatBufferBuilder &fbb,
|
||||
::flatbuffers::Offset<com::fbs::app::Animal> root) {
|
||||
fbb.Finish(root);
|
||||
}
|
||||
|
||||
inline void FinishSizePrefixedAnimalBuffer(
|
||||
flatbuffers::FlatBufferBuilder &fbb,
|
||||
flatbuffers::Offset<com::fbs::app::Animal> root) {
|
||||
::flatbuffers::FlatBufferBuilder &fbb,
|
||||
::flatbuffers::Offset<com::fbs::app::Animal> root) {
|
||||
fbb.FinishSizePrefixed(root);
|
||||
}
|
||||
|
||||
|
||||
@@ -2,11 +2,24 @@
|
||||
|
||||
package com.fbs.app
|
||||
|
||||
import java.nio.*
|
||||
import com.google.flatbuffers.BaseVector
|
||||
import com.google.flatbuffers.BooleanVector
|
||||
import com.google.flatbuffers.ByteVector
|
||||
import com.google.flatbuffers.Constants
|
||||
import com.google.flatbuffers.DoubleVector
|
||||
import com.google.flatbuffers.FlatBufferBuilder
|
||||
import com.google.flatbuffers.FloatVector
|
||||
import com.google.flatbuffers.LongVector
|
||||
import com.google.flatbuffers.StringVector
|
||||
import com.google.flatbuffers.Struct
|
||||
import com.google.flatbuffers.Table
|
||||
import com.google.flatbuffers.UnionVector
|
||||
import java.nio.ByteBuffer
|
||||
import java.nio.ByteOrder
|
||||
import kotlin.math.sign
|
||||
import com.google.flatbuffers.*
|
||||
|
||||
@Suppress("unused")
|
||||
@kotlin.ExperimentalUnsignedTypes
|
||||
class Animal : Table() {
|
||||
|
||||
fun __init(_i: Int, _bb: ByteBuffer) {
|
||||
@@ -19,14 +32,22 @@ class Animal : Table() {
|
||||
val name : String?
|
||||
get() {
|
||||
val o = __offset(4)
|
||||
return if (o != 0) __string(o + bb_pos) else null
|
||||
return if (o != 0) {
|
||||
__string(o + bb_pos)
|
||||
} else {
|
||||
null
|
||||
}
|
||||
}
|
||||
val nameAsByteBuffer : ByteBuffer get() = __vector_as_bytebuffer(4, 1)
|
||||
fun nameInByteBuffer(_bb: ByteBuffer) : ByteBuffer = __vector_in_bytebuffer(_bb, 4, 1)
|
||||
val sound : String?
|
||||
get() {
|
||||
val o = __offset(6)
|
||||
return if (o != 0) __string(o + bb_pos) else null
|
||||
return if (o != 0) {
|
||||
__string(o + bb_pos)
|
||||
} else {
|
||||
null
|
||||
}
|
||||
}
|
||||
val soundAsByteBuffer : ByteBuffer get() = __vector_as_bytebuffer(6, 1)
|
||||
fun soundInByteBuffer(_bb: ByteBuffer) : ByteBuffer = __vector_in_bytebuffer(_bb, 6, 1)
|
||||
@@ -36,7 +57,7 @@ class Animal : Table() {
|
||||
return if(o != 0) bb.getShort(o + bb_pos).toUShort() else 0u
|
||||
}
|
||||
companion object {
|
||||
fun validateVersion() = Constants.FLATBUFFERS_22_12_06()
|
||||
fun validateVersion() = Constants.FLATBUFFERS_23_3_3()
|
||||
fun getRootAsAnimal(_bb: ByteBuffer): Animal = getRootAsAnimal(_bb, Animal())
|
||||
fun getRootAsAnimal(_bb: ByteBuffer, obj: Animal): Animal {
|
||||
_bb.order(ByteOrder.LITTLE_ENDIAN)
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||
buildscript {
|
||||
ext.kotlin_version = "1.4.10"
|
||||
ext.kotlin_version = "1.7.21"
|
||||
repositories {
|
||||
google()
|
||||
jcenter()
|
||||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:4.1.0'
|
||||
classpath 'com.android.tools.build:gradle:7.4.1'
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||
|
||||
// NOTE: Do not place your application dependencies here; they belong
|
||||
@@ -17,7 +17,7 @@ buildscript {
|
||||
allprojects {
|
||||
repositories {
|
||||
google()
|
||||
jcenter()
|
||||
mavenCentral()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.1-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
# Setup for running Google Benchmarks (https://github.com/google/benchmark) on
|
||||
# flatbuffers. This requires both that benchmark library and its depenency gtest
|
||||
# flatbuffers. This requires both that benchmark library and its dependency gtest
|
||||
# to build. Instead of including them here or doing a submodule, this uses
|
||||
# FetchContent (https://cmake.org/cmake/help/latest/module/FetchContent.html) to
|
||||
# grab the dependencies at config time. This requires CMake 3.14 or higher.
|
||||
|
||||
cmake_minimum_required(VERSION 3.14)
|
||||
include(FetchContent)
|
||||
|
||||
@@ -27,7 +28,7 @@ FetchContent_MakeAvailable(
|
||||
googlebenchmark
|
||||
)
|
||||
|
||||
set(CPP_BENCH_DIR cpp)
|
||||
set(CPP_BENCH_DIR ${CMAKE_CURRENT_SOURCE_DIR}/cpp)
|
||||
set(CPP_FB_BENCH_DIR ${CPP_BENCH_DIR}/flatbuffers)
|
||||
set(CPP_RAW_BENCH_DIR ${CPP_BENCH_DIR}/raw)
|
||||
set(CPP_BENCH_FBS ${CPP_FB_BENCH_DIR}/bench.fbs)
|
||||
@@ -62,8 +63,8 @@ add_custom_command(
|
||||
add_executable(flatbenchmark ${FlatBenchmark_SRCS})
|
||||
|
||||
# Benchmark requires C++11
|
||||
target_compile_features(flatbenchmark PUBLIC
|
||||
cxx_std_11
|
||||
target_compile_features(flatbenchmark PRIVATE
|
||||
cxx_std_11 # requires cmake 3.8
|
||||
)
|
||||
|
||||
target_compile_options(flatbenchmark
|
||||
@@ -81,7 +82,7 @@ set_target_properties(flatbenchmark
|
||||
# The includes of the benchmark files are fully qualified from flatbuffers root.
|
||||
target_include_directories(flatbenchmark PUBLIC ${CMAKE_SOURCE_DIR})
|
||||
|
||||
target_link_libraries(flatbenchmark
|
||||
target_link_libraries(flatbenchmark PRIVATE
|
||||
benchmark::benchmark_main # _main to use their entry point
|
||||
gtest # Link to gtest so we can also assert in the benchmarks
|
||||
)
|
||||
@@ -7,7 +7,7 @@ Rules for building C++ flatbuffers with Bazel.
|
||||
|
||||
load("@rules_cc//cc:defs.bzl", "cc_library")
|
||||
|
||||
flatc_path = "@com_github_google_flatbuffers//:flatc"
|
||||
TRUE_FLATC_PATH = "@com_github_google_flatbuffers//:flatc"
|
||||
|
||||
DEFAULT_INCLUDE_PATHS = [
|
||||
"./",
|
||||
@@ -16,6 +16,14 @@ DEFAULT_INCLUDE_PATHS = [
|
||||
"$(execpath @com_github_google_flatbuffers//:flatc).runfiles/com_github_google_flatbuffers",
|
||||
]
|
||||
|
||||
def default_include_paths(flatc_path):
|
||||
return [
|
||||
"./",
|
||||
"$(GENDIR)",
|
||||
"$(BINDIR)",
|
||||
"$(execpath %s).runfiles/com_github_google_flatbuffers" % (flatc_path),
|
||||
]
|
||||
|
||||
DEFAULT_FLATC_ARGS = [
|
||||
"--gen-object-api",
|
||||
"--gen-compare",
|
||||
@@ -32,13 +40,14 @@ def flatbuffer_library_public(
|
||||
language_flag,
|
||||
out_prefix = "",
|
||||
includes = [],
|
||||
include_paths = DEFAULT_INCLUDE_PATHS,
|
||||
include_paths = None,
|
||||
flatc_args = DEFAULT_FLATC_ARGS,
|
||||
reflection_name = "",
|
||||
reflection_visibility = None,
|
||||
compatible_with = None,
|
||||
restricted_to = None,
|
||||
target_compatible_with = None,
|
||||
flatc_path = "@com_github_google_flatbuffers//:flatc",
|
||||
output_to_bindir = False):
|
||||
"""Generates code files for reading/writing the given flatbuffers in the requested language using the public compiler.
|
||||
|
||||
@@ -62,6 +71,7 @@ def flatbuffer_library_public(
|
||||
for, instead of default-supported environments.
|
||||
target_compatible_with: Optional, The list of target platform constraints
|
||||
to use.
|
||||
flatc_path: Bazel target corresponding to the flatc compiler to use.
|
||||
output_to_bindir: Passed to genrule for output to bin directory.
|
||||
|
||||
|
||||
@@ -69,6 +79,8 @@ def flatbuffer_library_public(
|
||||
optionally a Fileset([reflection_name]) with all generated reflection
|
||||
binaries.
|
||||
"""
|
||||
if include_paths == None:
|
||||
include_paths = default_include_paths(flatc_path)
|
||||
include_paths_cmd = ["-I %s" % (s) for s in include_paths]
|
||||
|
||||
# '$(@D)' when given a single source target will give the appropriate
|
||||
@@ -80,7 +92,7 @@ def flatbuffer_library_public(
|
||||
genrule_cmd = " ".join([
|
||||
"SRCS=($(SRCS));",
|
||||
"for f in $${SRCS[@]:0:%s}; do" % len(srcs),
|
||||
"$(location %s)" % (flatc_path),
|
||||
"OUTPUT_FILE=\"$(OUTS)\" $(location %s)" % (flatc_path),
|
||||
" ".join(include_paths_cmd),
|
||||
" ".join(flatc_args),
|
||||
language_flag,
|
||||
@@ -104,7 +116,7 @@ def flatbuffer_library_public(
|
||||
reflection_genrule_cmd = " ".join([
|
||||
"SRCS=($(SRCS));",
|
||||
"for f in $${SRCS[@]:0:%s}; do" % len(srcs),
|
||||
"$(location %s)" % (flatc_path),
|
||||
"$(location %s)" % (TRUE_FLATC_PATH),
|
||||
"-b --schema",
|
||||
" ".join(flatc_args),
|
||||
" ".join(include_paths_cmd),
|
||||
@@ -122,7 +134,7 @@ def flatbuffer_library_public(
|
||||
srcs = srcs + includes,
|
||||
outs = reflection_outs,
|
||||
output_to_bindir = output_to_bindir,
|
||||
tools = [flatc_path],
|
||||
tools = [TRUE_FLATC_PATH],
|
||||
compatible_with = compatible_with,
|
||||
restricted_to = restricted_to,
|
||||
target_compatible_with = target_compatible_with,
|
||||
@@ -145,7 +157,7 @@ def flatbuffer_cc_library(
|
||||
out_prefix = "",
|
||||
deps = [],
|
||||
includes = [],
|
||||
include_paths = DEFAULT_INCLUDE_PATHS,
|
||||
include_paths = None,
|
||||
cc_include_paths = [],
|
||||
flatc_args = DEFAULT_FLATC_ARGS,
|
||||
visibility = None,
|
||||
|
||||
@@ -9,7 +9,7 @@ class BitWidthUtil {
|
||||
}
|
||||
|
||||
static BitWidth width(num value) {
|
||||
if (value.toInt() == value) {
|
||||
if (value is int) {
|
||||
var v = value.toInt().abs();
|
||||
if (v >> 7 == 0) return BitWidth.width8;
|
||||
if (v >> 15 == 0) return BitWidth.width16;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
name: flat_buffers
|
||||
version: 22.12.06
|
||||
version: 23.3.3
|
||||
description: FlatBuffers reading and writing library for Dart. Based on original work by Konstantin Scheglov and Paul Berry of the Dart SDK team.
|
||||
homepage: https://github.com/google/flatbuffers
|
||||
documentation: https://google.github.io/flatbuffers/index.html
|
||||
|
||||
@@ -40,6 +40,10 @@ void main() {
|
||||
flx.addInt(-1025);
|
||||
expect(flx.finish(), [255, 251, 5, 2]);
|
||||
}
|
||||
{
|
||||
var builder = Builder()..addDouble(1.0);
|
||||
expect(builder.finish(), [0, 0, 128, 63, 14, 4]);
|
||||
}
|
||||
{
|
||||
var flx = Builder();
|
||||
flx.addDouble(0.1);
|
||||
|
||||
@@ -37,6 +37,7 @@ void main() {
|
||||
// expect(FlxValue.fromBuffer(b([255, 255, 255, 255, 255, 255, 255, 255, 11, 8])).intValue, 18446744073709551615);
|
||||
});
|
||||
test('double value', () {
|
||||
expect(Reference.fromBuffer(b([0, 0, 128, 63, 14, 4])).doubleValue, 1.0);
|
||||
expect(Reference.fromBuffer(b([0, 0, 144, 64, 14, 4])).doubleValue, 4.5);
|
||||
expect(Reference.fromBuffer(b([205, 204, 204, 61, 14, 4])).doubleValue,
|
||||
closeTo(.1, .001));
|
||||
|
||||
@@ -278,3 +278,122 @@ class KeywordsInTableObjectBuilder extends fb.ObjectBuilder {
|
||||
return fbBuilder.buffer;
|
||||
}
|
||||
}
|
||||
class Table2 {
|
||||
Table2._(this._bc, this._bcOffset);
|
||||
factory Table2(List<int> bytes) {
|
||||
final rootRef = fb.BufferContext.fromBytes(bytes);
|
||||
return reader.read(rootRef, 0);
|
||||
}
|
||||
|
||||
static const fb.Reader<Table2> reader = _Table2Reader();
|
||||
|
||||
final fb.BufferContext _bc;
|
||||
final int _bcOffset;
|
||||
|
||||
KeywordsInUnionTypeId? get typeType => KeywordsInUnionTypeId._createOrNull(const fb.Uint8Reader().vTableGetNullable(_bc, _bcOffset, 4));
|
||||
dynamic get type {
|
||||
switch (typeType?.value) {
|
||||
case 1: return KeywordsInTable.reader.vTableGetNullable(_bc, _bcOffset, 6);
|
||||
case 2: return KeywordsInTable.reader.vTableGetNullable(_bc, _bcOffset, 6);
|
||||
default: return null;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'Table2{typeType: ${typeType}, type: ${type}}';
|
||||
}
|
||||
|
||||
Table2T unpack() => Table2T(
|
||||
typeType: typeType,
|
||||
type: type);
|
||||
|
||||
static int pack(fb.Builder fbBuilder, Table2T? object) {
|
||||
if (object == null) return 0;
|
||||
return object.pack(fbBuilder);
|
||||
}
|
||||
}
|
||||
|
||||
class Table2T implements fb.Packable {
|
||||
KeywordsInUnionTypeId? typeType;
|
||||
dynamic type;
|
||||
|
||||
Table2T({
|
||||
this.typeType,
|
||||
this.type});
|
||||
|
||||
@override
|
||||
int pack(fb.Builder fbBuilder) {
|
||||
final int? typeOffset = type?.pack(fbBuilder);
|
||||
fbBuilder.startTable(2);
|
||||
fbBuilder.addUint8(0, typeType?.value);
|
||||
fbBuilder.addOffset(1, typeOffset);
|
||||
return fbBuilder.endTable();
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'Table2T{typeType: ${typeType}, type: ${type}}';
|
||||
}
|
||||
}
|
||||
|
||||
class _Table2Reader extends fb.TableReader<Table2> {
|
||||
const _Table2Reader();
|
||||
|
||||
@override
|
||||
Table2 createObject(fb.BufferContext bc, int offset) =>
|
||||
Table2._(bc, offset);
|
||||
}
|
||||
|
||||
class Table2Builder {
|
||||
Table2Builder(this.fbBuilder);
|
||||
|
||||
final fb.Builder fbBuilder;
|
||||
|
||||
void begin() {
|
||||
fbBuilder.startTable(2);
|
||||
}
|
||||
|
||||
int addTypeType(KeywordsInUnionTypeId? typeType) {
|
||||
fbBuilder.addUint8(0, typeType?.value);
|
||||
return fbBuilder.offset;
|
||||
}
|
||||
int addTypeOffset(int? offset) {
|
||||
fbBuilder.addOffset(1, offset);
|
||||
return fbBuilder.offset;
|
||||
}
|
||||
|
||||
int finish() {
|
||||
return fbBuilder.endTable();
|
||||
}
|
||||
}
|
||||
|
||||
class Table2ObjectBuilder extends fb.ObjectBuilder {
|
||||
final KeywordsInUnionTypeId? _typeType;
|
||||
final dynamic _type;
|
||||
|
||||
Table2ObjectBuilder({
|
||||
KeywordsInUnionTypeId? typeType,
|
||||
dynamic type,
|
||||
})
|
||||
: _typeType = typeType,
|
||||
_type = type;
|
||||
|
||||
/// Finish building, and store into the [fbBuilder].
|
||||
@override
|
||||
int finish(fb.Builder fbBuilder) {
|
||||
final int? typeOffset = _type?.getOrCreateOffset(fbBuilder);
|
||||
fbBuilder.startTable(2);
|
||||
fbBuilder.addUint8(0, _typeType?.value);
|
||||
fbBuilder.addOffset(1, typeOffset);
|
||||
return fbBuilder.endTable();
|
||||
}
|
||||
|
||||
/// Convenience method to serialize to byte list.
|
||||
@override
|
||||
Uint8List toBytes([String? fileIdentifier]) {
|
||||
final fbBuilder = fb.Builder(deduplicateTables: false);
|
||||
fbBuilder.finish(finish(fbBuilder), fileIdentifier);
|
||||
return fbBuilder.buffer;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -90,7 +90,10 @@ Additional options:
|
||||
|
||||
- `--scoped-enums` : Use C++11 style scoped and strongly typed enums in
|
||||
generated C++. This also implies `--no-prefix`.
|
||||
|
||||
|
||||
- `--no-emit-min-max-enum-values` : Disable generation of MIN and MAX
|
||||
enumerated values for scoped enums and prefixed enums.
|
||||
|
||||
- `--gen-includes` : (deprecated), this is the default behavior.
|
||||
If the original behavior is required (no include
|
||||
statements) use `--no-includes.`
|
||||
|
||||
@@ -72,7 +72,10 @@ Now you can access values like this:
|
||||
In some cases it's necessary to modify values in an existing FlatBuffer in place (without creating a copy). For this reason, scalar fields of a Flatbuffer table or struct can be mutated.
|
||||
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.swift}
|
||||
let monster = Monster.getRootAsMonster(bb: ByteBuffer(data: data))
|
||||
var byteBuffer = ByteBuffer(bytes: data)
|
||||
// Get an accessor to the root object inside the buffer.
|
||||
let monster: Monster = try! getCheckedRoot(byteBuffer: &byteBuffer)
|
||||
// let monster: Monster = getRoot(byteBuffer: &byteBuffer)
|
||||
|
||||
if !monster.mutate(hp: 10) {
|
||||
fatalError("couldn't mutate")
|
||||
|
||||
@@ -321,9 +321,8 @@ Please be aware of the difference between `flatc` and `flatcc` tools.
|
||||
<div class="language-javascript">
|
||||
~~~{.sh}
|
||||
cd flatbuffers/samples
|
||||
./../flatc --ts monster.fbs
|
||||
# customize your TS -> JS transpilation
|
||||
tsc monster_generated.ts
|
||||
./../flatc --ts-flat-files --ts monster.fbs
|
||||
# produces ts/js modules and js bundle monster_generated.js
|
||||
~~~
|
||||
</div>
|
||||
<div class="language-typescript">
|
||||
@@ -2241,7 +2240,7 @@ before:
|
||||
~~~{.ts}
|
||||
// note: import flatbuffers with your desired import method
|
||||
|
||||
// note: the `./monster_generated.ts` file was previously generated by `flatc` above using the `monster.fbs` schema
|
||||
// note: the `./monster_generated.js` file was previously generated by `flatc` above using the `monster.fbs` schema
|
||||
import { MyGame } from './monster_generated';
|
||||
~~~
|
||||
</div>
|
||||
@@ -2472,10 +2471,10 @@ myGame.Monster monster = new myGame.Monster(data);
|
||||
<div class="language-swift">
|
||||
~~~{.swift}
|
||||
// create a ByteBuffer(:) from an [UInt8] or Data()
|
||||
let buf = // Get your data
|
||||
|
||||
var buf = // Get your data
|
||||
// Get an accessor to the root object inside the buffer.
|
||||
let monster = Monster.getRootAsMonster(bb: ByteBuffer(bytes: buf))
|
||||
let monster: Monster = try! getCheckedRoot(byteBuffer: &byteBuffer)
|
||||
// let monster: Monster = getRoot(byteBuffer: &byteBuffer)
|
||||
~~~
|
||||
</div>
|
||||
|
||||
|
||||
@@ -6,12 +6,10 @@ import FlatBuffers
|
||||
|
||||
public struct models_HelloReply: FlatBufferObject, Verifiable {
|
||||
|
||||
static func validateVersion() { FlatBuffersVersion_22_12_06() }
|
||||
static func validateVersion() { FlatBuffersVersion_23_3_3() }
|
||||
public var __buffer: ByteBuffer! { return _accessor.bb }
|
||||
private var _accessor: Table
|
||||
|
||||
public static func getRootAsHelloReply(bb: ByteBuffer) -> models_HelloReply { return models_HelloReply(Table(bb: bb, position: Int32(bb.read(def: UOffset.self, position: bb.reader)) + Int32(bb.reader))) }
|
||||
|
||||
private init(_ t: Table) { _accessor = t }
|
||||
public init(_ bb: ByteBuffer, o: Int32) { _accessor = Table(bb: bb, position: o) }
|
||||
|
||||
@@ -55,12 +53,10 @@ extension models_HelloReply: Encodable {
|
||||
|
||||
public struct models_HelloRequest: FlatBufferObject, Verifiable {
|
||||
|
||||
static func validateVersion() { FlatBuffersVersion_22_12_06() }
|
||||
static func validateVersion() { FlatBuffersVersion_23_3_3() }
|
||||
public var __buffer: ByteBuffer! { return _accessor.bb }
|
||||
private var _accessor: Table
|
||||
|
||||
public static func getRootAsHelloRequest(bb: ByteBuffer) -> models_HelloRequest { return models_HelloRequest(Table(bb: bb, position: Int32(bb.read(def: UOffset.self, position: bb.reader)) + Int32(bb.reader))) }
|
||||
|
||||
private init(_ t: Table) { _accessor = t }
|
||||
public init(_ bb: ByteBuffer, o: Int32) { _accessor = Table(bb: bb, position: o) }
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2021 Google Inc. All rights reserved.
|
||||
* Copyright 2023 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.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2021 Google Inc. All rights reserved.
|
||||
* Copyright 2023 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.
|
||||
|
||||
@@ -1,2 +1,3 @@
|
||||
export { HelloReply } from './models/hello-reply';
|
||||
export { HelloRequest } from './models/hello-request';
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
export * as models from './models.js';
|
||||
|
||||
4
grpc/examples/ts/greeter/src/models.ts
Normal file
4
grpc/examples/ts/greeter/src/models.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
export { HelloReply } from './models/hello-reply.js';
|
||||
export { HelloRequest } from './models/hello-request.js';
|
||||
@@ -65,4 +65,4 @@ class Allocator {
|
||||
|
||||
} // namespace flatbuffers
|
||||
|
||||
#endif // FLATBUFFERS_ALLOCATOR_H_
|
||||
#endif // FLATBUFFERS_ALLOCATOR_H_
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
#ifndef FLATBUFFERS_ARRAY_H_
|
||||
#define FLATBUFFERS_ARRAY_H_
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "flatbuffers/base.h"
|
||||
#include "flatbuffers/stl_emulation.h"
|
||||
#include "flatbuffers/vector.h"
|
||||
@@ -238,6 +240,14 @@ const Array<E, length> &CastToArrayOfEnum(const T (&arr)[length]) {
|
||||
return *reinterpret_cast<const Array<E, length> *>(arr);
|
||||
}
|
||||
|
||||
template<typename T, uint16_t length>
|
||||
bool operator==(const Array<T, length> &lhs,
|
||||
const Array<T, length> &rhs) noexcept {
|
||||
return std::addressof(lhs) == std::addressof(rhs) ||
|
||||
(lhs.size() == rhs.size() &&
|
||||
std::memcmp(lhs.Data(), rhs.Data(), rhs.size() * sizeof(T)) == 0);
|
||||
}
|
||||
|
||||
} // namespace flatbuffers
|
||||
|
||||
#endif // FLATBUFFERS_ARRAY_H_
|
||||
|
||||
@@ -138,9 +138,9 @@
|
||||
#endif
|
||||
#endif // !defined(FLATBUFFERS_LITTLEENDIAN)
|
||||
|
||||
#define FLATBUFFERS_VERSION_MAJOR 22
|
||||
#define FLATBUFFERS_VERSION_MINOR 12
|
||||
#define FLATBUFFERS_VERSION_REVISION 06
|
||||
#define FLATBUFFERS_VERSION_MAJOR 23
|
||||
#define FLATBUFFERS_VERSION_MINOR 3
|
||||
#define FLATBUFFERS_VERSION_REVISION 3
|
||||
#define FLATBUFFERS_STRING_EXPAND(X) #X
|
||||
#define FLATBUFFERS_STRING(X) FLATBUFFERS_STRING_EXPAND(X)
|
||||
namespace flatbuffers {
|
||||
@@ -233,7 +233,7 @@ namespace flatbuffers {
|
||||
}
|
||||
#define FLATBUFFERS_HAS_STRING_VIEW 1
|
||||
// Check for absl::string_view
|
||||
#elif __has_include("absl/strings/string_view.h")
|
||||
#elif __has_include("absl/strings/string_view.h") && (__cplusplus >= 201411)
|
||||
#include "absl/strings/string_view.h"
|
||||
namespace flatbuffers {
|
||||
typedef absl::string_view string_view;
|
||||
|
||||
@@ -50,4 +50,4 @@ template<typename T> struct BufferRef : BufferRefBase {
|
||||
|
||||
} // namespace flatbuffers
|
||||
|
||||
#endif // FLATBUFFERS_BUFFER_REF_H_
|
||||
#endif // FLATBUFFERS_BUFFER_REF_H_
|
||||
|
||||
80
include/flatbuffers/code_generator.h
Normal file
80
include/flatbuffers/code_generator.h
Normal file
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
* Copyright 2023 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_CODE_GENERATOR_H_
|
||||
#define FLATBUFFERS_CODE_GENERATOR_H_
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "flatbuffers/idl.h"
|
||||
|
||||
namespace flatbuffers {
|
||||
|
||||
// A code generator interface for producing converting flatbuffer schema into
|
||||
// code.
|
||||
class CodeGenerator {
|
||||
public:
|
||||
virtual ~CodeGenerator() = default;
|
||||
|
||||
enum Status {
|
||||
OK = 0,
|
||||
ERROR = 1,
|
||||
FAILED_VERIFICATION = 2,
|
||||
NOT_IMPLEMENTED = 3
|
||||
};
|
||||
|
||||
// Generate code from the provided `parser`.
|
||||
//
|
||||
// DEPRECATED: prefer using the other overload of GenerateCode for bfbs.
|
||||
virtual Status GenerateCode(const Parser &parser, const std::string &path,
|
||||
const std::string &filename) = 0;
|
||||
|
||||
// Generate code from the provided `buffer` of given `length`. The buffer is a
|
||||
// serialized reflection.fbs.
|
||||
virtual Status GenerateCode(const uint8_t *buffer, int64_t length) = 0;
|
||||
|
||||
virtual Status GenerateMakeRule(const Parser &parser, const std::string &path,
|
||||
const std::string &filename,
|
||||
std::string &output) = 0;
|
||||
|
||||
virtual Status GenerateGrpcCode(const Parser &parser, const std::string &path,
|
||||
const std::string &filename) = 0;
|
||||
|
||||
virtual Status GenerateRootFile(const Parser &parser,
|
||||
const std::string &path) = 0;
|
||||
|
||||
virtual bool IsSchemaOnly() const = 0;
|
||||
|
||||
virtual bool SupportsBfbsGeneration() const = 0;
|
||||
|
||||
virtual bool SupportsRootFileGeneration() const = 0;
|
||||
|
||||
virtual IDLOptions::Language Language() const = 0;
|
||||
|
||||
virtual std::string LanguageName() const = 0;
|
||||
|
||||
protected:
|
||||
CodeGenerator() = default;
|
||||
|
||||
private:
|
||||
// Copying is not supported.
|
||||
CodeGenerator(const CodeGenerator &) = delete;
|
||||
CodeGenerator &operator=(const CodeGenerator &) = delete;
|
||||
};
|
||||
|
||||
} // namespace flatbuffers
|
||||
|
||||
#endif // FLATBUFFERS_CODE_GENERATOR_H_
|
||||
@@ -61,4 +61,4 @@ inline uint8_t *ReallocateDownward(Allocator *allocator, uint8_t *old_p,
|
||||
|
||||
} // namespace flatbuffers
|
||||
|
||||
#endif // FLATBUFFERS_DEFAULT_ALLOCATOR_H_
|
||||
#endif // FLATBUFFERS_DEFAULT_ALLOCATOR_H_
|
||||
|
||||
@@ -45,7 +45,7 @@ class DetachedBuffer {
|
||||
cur_(cur),
|
||||
size_(sz) {}
|
||||
|
||||
DetachedBuffer(DetachedBuffer &&other)
|
||||
DetachedBuffer(DetachedBuffer &&other) noexcept
|
||||
: allocator_(other.allocator_),
|
||||
own_allocator_(other.own_allocator_),
|
||||
buf_(other.buf_),
|
||||
@@ -55,7 +55,7 @@ class DetachedBuffer {
|
||||
other.reset();
|
||||
}
|
||||
|
||||
DetachedBuffer &operator=(DetachedBuffer &&other) {
|
||||
DetachedBuffer &operator=(DetachedBuffer &&other) noexcept {
|
||||
if (this == &other) return *this;
|
||||
|
||||
destroy();
|
||||
|
||||
@@ -98,7 +98,7 @@ class FlatBufferBuilder {
|
||||
}
|
||||
|
||||
/// @brief Move constructor for FlatBufferBuilder.
|
||||
FlatBufferBuilder(FlatBufferBuilder &&other)
|
||||
FlatBufferBuilder(FlatBufferBuilder &&other) noexcept
|
||||
: buf_(1024, nullptr, false, AlignOf<largest_scalar_t>()),
|
||||
num_field_loc(0),
|
||||
max_voffset_(0),
|
||||
@@ -116,7 +116,7 @@ class FlatBufferBuilder {
|
||||
}
|
||||
|
||||
/// @brief Move assignment operator for FlatBufferBuilder.
|
||||
FlatBufferBuilder &operator=(FlatBufferBuilder &&other) {
|
||||
FlatBufferBuilder &operator=(FlatBufferBuilder &&other) noexcept {
|
||||
// Move construct a temporary and swap idiom
|
||||
FlatBufferBuilder temp(std::move(other));
|
||||
Swap(temp);
|
||||
|
||||
@@ -19,9 +19,11 @@
|
||||
|
||||
#include <functional>
|
||||
#include <limits>
|
||||
#include <list>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include "flatbuffers/bfbs_generator.h"
|
||||
#include "flatbuffers/code_generator.h"
|
||||
#include "flatbuffers/flatbuffers.h"
|
||||
#include "flatbuffers/idl.h"
|
||||
#include "flatbuffers/util.h"
|
||||
@@ -31,6 +33,33 @@ namespace flatbuffers {
|
||||
extern void LogCompilerWarn(const std::string &warn);
|
||||
extern void LogCompilerError(const std::string &err);
|
||||
|
||||
struct FlatCOptions {
|
||||
IDLOptions opts;
|
||||
|
||||
std::string program_name;
|
||||
|
||||
std::string output_path;
|
||||
|
||||
std::vector<std::string> filenames;
|
||||
|
||||
std::list<std::string> include_directories_storage;
|
||||
std::vector<const char *> include_directories;
|
||||
std::vector<const char *> conform_include_directories;
|
||||
std::vector<bool> generator_enabled;
|
||||
size_t binary_files_from = std::numeric_limits<size_t>::max();
|
||||
std::string conform_to_schema;
|
||||
std::string annotate_schema;
|
||||
bool annotate_include_vector_contents = true;
|
||||
bool any_generator = false;
|
||||
bool print_make_rules = false;
|
||||
bool raw_binary = false;
|
||||
bool schema_binary = false;
|
||||
bool grpc_enabled = false;
|
||||
bool requires_bfbs = false;
|
||||
|
||||
std::vector<std::shared_ptr<CodeGenerator>> generators;
|
||||
};
|
||||
|
||||
struct FlatCOption {
|
||||
std::string short_opt;
|
||||
std::string long_opt;
|
||||
@@ -40,29 +69,6 @@ struct FlatCOption {
|
||||
|
||||
class FlatCompiler {
|
||||
public:
|
||||
// Output generator for the various programming languages and formats we
|
||||
// support.
|
||||
struct Generator {
|
||||
typedef bool (*GenerateFn)(const flatbuffers::Parser &parser,
|
||||
const std::string &path,
|
||||
const std::string &file_name);
|
||||
typedef std::string (*MakeRuleFn)(const flatbuffers::Parser &parser,
|
||||
const std::string &path,
|
||||
const std::string &file_name);
|
||||
typedef bool (*ParsingCompletedFn)(const flatbuffers::Parser &parser,
|
||||
const std::string &output_path);
|
||||
|
||||
GenerateFn generate;
|
||||
const char *lang_name;
|
||||
bool schema_only;
|
||||
GenerateFn generateGRPC;
|
||||
flatbuffers::IDLOptions::Language lang;
|
||||
FlatCOption option;
|
||||
MakeRuleFn make_rule;
|
||||
BfbsGenerator *bfbs_generator;
|
||||
ParsingCompletedFn parsing_completed;
|
||||
};
|
||||
|
||||
typedef void (*WarnFn)(const FlatCompiler *flatc, const std::string &warn,
|
||||
bool show_exe_name);
|
||||
|
||||
@@ -71,29 +77,29 @@ class FlatCompiler {
|
||||
|
||||
// Parameters required to initialize the FlatCompiler.
|
||||
struct InitParams {
|
||||
InitParams()
|
||||
: generators(nullptr),
|
||||
num_generators(0),
|
||||
warn_fn(nullptr),
|
||||
error_fn(nullptr) {}
|
||||
InitParams() : warn_fn(nullptr), error_fn(nullptr) {}
|
||||
|
||||
const Generator *generators;
|
||||
size_t num_generators;
|
||||
WarnFn warn_fn;
|
||||
ErrorFn error_fn;
|
||||
};
|
||||
|
||||
explicit FlatCompiler(const InitParams ¶ms) : params_(params) {}
|
||||
|
||||
int Compile(int argc, const char **argv);
|
||||
bool RegisterCodeGenerator(const FlatCOption &option,
|
||||
std::shared_ptr<CodeGenerator> code_generator);
|
||||
|
||||
std::string GetShortUsageString(const char *program_name) const;
|
||||
std::string GetUsageString(const char *program_name) const;
|
||||
int Compile(const FlatCOptions &options);
|
||||
|
||||
std::string GetShortUsageString(const std::string &program_name) const;
|
||||
std::string GetUsageString(const std::string &program_name) const;
|
||||
|
||||
// Parse the FlatC options from command line arguments.
|
||||
FlatCOptions ParseFromCommandLineArguments(int argc, const char **argv);
|
||||
|
||||
private:
|
||||
void ParseFile(flatbuffers::Parser &parser, const std::string &filename,
|
||||
const std::string &contents,
|
||||
std::vector<const char *> &include_directories) const;
|
||||
const std::vector<const char *> &include_directories) const;
|
||||
|
||||
void LoadBinarySchema(Parser &parser, const std::string &filename,
|
||||
const std::string &contents);
|
||||
@@ -105,8 +111,16 @@ class FlatCompiler {
|
||||
|
||||
void AnnotateBinaries(const uint8_t *binary_schema,
|
||||
uint64_t binary_schema_size,
|
||||
const std::string & schema_filename,
|
||||
const std::vector<std::string> &binary_files);
|
||||
const FlatCOptions &options);
|
||||
|
||||
void ValidateOptions(const FlatCOptions &options);
|
||||
|
||||
Parser GetConformParser(const FlatCOptions &options);
|
||||
|
||||
std::unique_ptr<Parser> GenerateCode(const FlatCOptions &options,
|
||||
Parser &conform_parser);
|
||||
|
||||
std::map<std::string, std::shared_ptr<CodeGenerator>> code_generators_;
|
||||
|
||||
InitParams params_;
|
||||
};
|
||||
|
||||
@@ -385,9 +385,8 @@ class Reference {
|
||||
Reference(const uint8_t *data, uint8_t parent_width, uint8_t packed_type)
|
||||
: data_(data),
|
||||
parent_width_(parent_width),
|
||||
byte_width_(1 << (packed_type & 3)),
|
||||
type_(static_cast<Type>(packed_type >> 2)) {
|
||||
}
|
||||
byte_width_(static_cast<uint8_t>(1 << (packed_type & 3))),
|
||||
type_(static_cast<Type>(packed_type >> 2)) {}
|
||||
|
||||
Type GetType() const { return type_; }
|
||||
|
||||
@@ -1846,7 +1845,7 @@ class Verifier FLATBUFFERS_FINAL_CLASS {
|
||||
uint8_t len = 0;
|
||||
auto vtype = ToFixedTypedVectorElementType(r.type_, &len);
|
||||
if (!VerifyType(vtype)) return false;
|
||||
return VerifyFromPointer(p, r.byte_width_ * len);
|
||||
return VerifyFromPointer(p, static_cast<size_t>(r.byte_width_) * len);
|
||||
}
|
||||
default: return false;
|
||||
}
|
||||
|
||||
@@ -45,26 +45,26 @@ namespace flatbuffers {
|
||||
// of type tokens.
|
||||
// clang-format off
|
||||
#define FLATBUFFERS_GEN_TYPES_SCALAR(TD) \
|
||||
TD(NONE, "", uint8_t, byte, byte, byte, uint8, u8, UByte, UInt8) \
|
||||
TD(UTYPE, "", uint8_t, byte, byte, byte, uint8, u8, UByte, UInt8) /* begin scalar/int */ \
|
||||
TD(BOOL, "bool", uint8_t, boolean,bool, bool, bool, bool, Boolean, Bool) \
|
||||
TD(CHAR, "byte", int8_t, byte, int8, sbyte, int8, i8, Byte, Int8) \
|
||||
TD(UCHAR, "ubyte", uint8_t, byte, byte, byte, uint8, u8, UByte, UInt8) \
|
||||
TD(SHORT, "short", int16_t, short, int16, short, int16, i16, Short, Int16) \
|
||||
TD(USHORT, "ushort", uint16_t, short, uint16, ushort, uint16, u16, UShort, UInt16) \
|
||||
TD(INT, "int", int32_t, int, int32, int, int32, i32, Int, Int32) \
|
||||
TD(UINT, "uint", uint32_t, int, uint32, uint, uint32, u32, UInt, UInt32) \
|
||||
TD(LONG, "long", int64_t, long, int64, long, int64, i64, Long, Int64) \
|
||||
TD(ULONG, "ulong", uint64_t, long, uint64, ulong, uint64, u64, ULong, UInt64) /* end int */ \
|
||||
TD(FLOAT, "float", float, float, float32, float, float32, f32, Float, Float32) /* begin float */ \
|
||||
TD(DOUBLE, "double", double, double, float64, double, float64, f64, Double, Double) /* end float/scalar */
|
||||
TD(NONE, "", uint8_t, byte, byte, byte, uint8, u8, UByte, UInt8, 0) \
|
||||
TD(UTYPE, "", uint8_t, byte, byte, byte, uint8, u8, UByte, UInt8, 1) /* begin scalar/int */ \
|
||||
TD(BOOL, "bool", uint8_t, boolean,bool, bool, bool, bool, Boolean, Bool, 2) \
|
||||
TD(CHAR, "byte", int8_t, byte, int8, sbyte, int8, i8, Byte, Int8, 3) \
|
||||
TD(UCHAR, "ubyte", uint8_t, byte, byte, byte, uint8, u8, UByte, UInt8, 4) \
|
||||
TD(SHORT, "short", int16_t, short, int16, short, int16, i16, Short, Int16, 5) \
|
||||
TD(USHORT, "ushort", uint16_t, short, uint16, ushort, uint16, u16, UShort, UInt16, 6) \
|
||||
TD(INT, "int", int32_t, int, int32, int, int32, i32, Int, Int32, 7) \
|
||||
TD(UINT, "uint", uint32_t, int, uint32, uint, uint32, u32, UInt, UInt32, 8) \
|
||||
TD(LONG, "long", int64_t, long, int64, long, int64, i64, Long, Int64, 9) \
|
||||
TD(ULONG, "ulong", uint64_t, long, uint64, ulong, uint64, u64, ULong, UInt64, 10) /* end int */ \
|
||||
TD(FLOAT, "float", float, float, float32, float, float32, f32, Float, Float32, 11) /* begin float */ \
|
||||
TD(DOUBLE, "double", double, double, float64, double, float64, f64, Double, Double, 12) /* end float/scalar */
|
||||
#define FLATBUFFERS_GEN_TYPES_POINTER(TD) \
|
||||
TD(STRING, "string", Offset<void>, int, int, StringOffset, int, unused, Int, Offset<String>) \
|
||||
TD(VECTOR, "", Offset<void>, int, int, VectorOffset, int, unused, Int, Offset<UOffset>) \
|
||||
TD(STRUCT, "", Offset<void>, int, int, int, int, unused, Int, Offset<UOffset>) \
|
||||
TD(UNION, "", Offset<void>, int, int, int, int, unused, Int, Offset<UOffset>)
|
||||
TD(STRING, "string", Offset<void>, int, int, StringOffset, int, unused, Int, Offset<String>, 13) \
|
||||
TD(VECTOR, "", Offset<void>, int, int, VectorOffset, int, unused, Int, Offset<UOffset>, 14) \
|
||||
TD(STRUCT, "", Offset<void>, int, int, int, int, unused, Int, Offset<UOffset>, 15) \
|
||||
TD(UNION, "", Offset<void>, int, int, int, int, unused, Int, Offset<UOffset>, 16)
|
||||
#define FLATBUFFERS_GEN_TYPE_ARRAY(TD) \
|
||||
TD(ARRAY, "", int, int, int, int, int, unused, Int, Offset<UOffset>)
|
||||
TD(ARRAY, "", int, int, int, int, int, unused, Int, Offset<UOffset>, 17)
|
||||
// The fields are:
|
||||
// - enum
|
||||
// - FlatBuffers schema type.
|
||||
@@ -75,13 +75,15 @@ namespace flatbuffers {
|
||||
// - Python type.
|
||||
// - Kotlin type.
|
||||
// - Rust type.
|
||||
// - Swift type.
|
||||
// - enum value (matches the reflected values)
|
||||
|
||||
// using these macros, we can now write code dealing with types just once, e.g.
|
||||
|
||||
/*
|
||||
switch (type) {
|
||||
#define FLATBUFFERS_TD(ENUM, IDLTYPE, CTYPE, JTYPE, GTYPE, NTYPE, PTYPE, \
|
||||
RTYPE, KTYPE) \
|
||||
RTYPE, KTYPE, STYPE, ...) \
|
||||
case BASE_TYPE_ ## ENUM: \
|
||||
// do something specific to CTYPE here
|
||||
FLATBUFFERS_GEN_TYPES(FLATBUFFERS_TD)
|
||||
@@ -113,8 +115,9 @@ switch (type) {
|
||||
__extension__ // Stop GCC complaining about trailing comma with -Wpendantic.
|
||||
#endif
|
||||
enum BaseType {
|
||||
#define FLATBUFFERS_TD(ENUM, ...) \
|
||||
BASE_TYPE_ ## ENUM,
|
||||
#define FLATBUFFERS_TD(ENUM, IDLTYPE, \
|
||||
CTYPE, JTYPE, GTYPE, NTYPE, PTYPE, RTYPE, KTYPE, STYPE, ENUM_VALUE) \
|
||||
BASE_TYPE_ ## ENUM = ENUM_VALUE,
|
||||
FLATBUFFERS_GEN_TYPES(FLATBUFFERS_TD)
|
||||
#undef FLATBUFFERS_TD
|
||||
};
|
||||
@@ -143,13 +146,41 @@ inline bool IsUnsigned(BaseType t) {
|
||||
(t == BASE_TYPE_ULONG);
|
||||
}
|
||||
|
||||
inline size_t SizeOf(const BaseType t) {
|
||||
switch (t) {
|
||||
#define FLATBUFFERS_TD(ENUM, IDLTYPE, CTYPE, ...) \
|
||||
case BASE_TYPE_##ENUM: return sizeof(CTYPE);
|
||||
FLATBUFFERS_GEN_TYPES(FLATBUFFERS_TD)
|
||||
#undef FLATBUFFERS_TD
|
||||
default: FLATBUFFERS_ASSERT(0);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
inline const char* TypeName(const BaseType t) {
|
||||
switch (t) {
|
||||
#define FLATBUFFERS_TD(ENUM, IDLTYPE, ...) \
|
||||
case BASE_TYPE_##ENUM: return IDLTYPE;
|
||||
FLATBUFFERS_GEN_TYPES(FLATBUFFERS_TD)
|
||||
#undef FLATBUFFERS_TD
|
||||
default: FLATBUFFERS_ASSERT(0);
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
inline const char* StringOf(const BaseType t) {
|
||||
switch (t) {
|
||||
#define FLATBUFFERS_TD(ENUM, IDLTYPE, CTYPE, ...) \
|
||||
case BASE_TYPE_##ENUM: return #CTYPE;
|
||||
FLATBUFFERS_GEN_TYPES(FLATBUFFERS_TD)
|
||||
#undef FLATBUFFERS_TD
|
||||
default: FLATBUFFERS_ASSERT(0);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
// clang-format on
|
||||
|
||||
extern const char *const kTypeNames[];
|
||||
extern const char kTypeSizes[];
|
||||
|
||||
inline size_t SizeOf(BaseType t) { return kTypeSizes[t]; }
|
||||
|
||||
struct StructDef;
|
||||
struct EnumDef;
|
||||
class Parser;
|
||||
@@ -297,7 +328,8 @@ struct FieldDef : public Definition {
|
||||
flexbuffer(false),
|
||||
presence(kDefault),
|
||||
nested_flatbuffer(nullptr),
|
||||
padding(0) {}
|
||||
padding(0),
|
||||
sibling_union_field(nullptr) {}
|
||||
|
||||
Offset<reflection::Field> Serialize(FlatBufferBuilder *builder, uint16_t id,
|
||||
const Parser &parser) const;
|
||||
@@ -342,6 +374,12 @@ struct FieldDef : public Definition {
|
||||
|
||||
StructDef *nested_flatbuffer; // This field contains nested FlatBuffer data.
|
||||
size_t padding; // Bytes to always pad after this field.
|
||||
|
||||
// sibling_union_field is always set to nullptr. The only exception is
|
||||
// when FieldDef is a union field or an union type field. Therefore,
|
||||
// sibling_union_field on a union field points to the union type field
|
||||
// and vice-versa.
|
||||
FieldDef *sibling_union_field;
|
||||
};
|
||||
|
||||
struct StructDef : public Definition {
|
||||
@@ -374,6 +412,7 @@ struct StructDef : public Definition {
|
||||
size_t bytesize; // Size if fixed.
|
||||
|
||||
flatbuffers::unique_ptr<std::string> original_location;
|
||||
std::vector<voffset_t> reserved_ids;
|
||||
};
|
||||
|
||||
struct EnumDef;
|
||||
@@ -587,7 +626,7 @@ inline bool operator<(const IncludedFile &a, const IncludedFile &b) {
|
||||
struct IDLOptions {
|
||||
// field case style options for C++
|
||||
enum CaseStyle { CaseStyle_Unchanged = 0, CaseStyle_Upper, CaseStyle_Lower };
|
||||
|
||||
enum class ProtoIdGapAction { NO_OP, WARNING, ERROR };
|
||||
bool gen_jvmstatic;
|
||||
// Use flexbuffers instead for binary and text generation
|
||||
bool use_flexbuffers;
|
||||
@@ -598,6 +637,7 @@ struct IDLOptions {
|
||||
bool output_enum_identifiers;
|
||||
bool prefixed_enums;
|
||||
bool scoped_enums;
|
||||
bool emit_min_max_enum_values;
|
||||
bool swift_implementation_only;
|
||||
bool include_dependence_headers;
|
||||
bool mutable_buffer;
|
||||
@@ -615,6 +655,7 @@ struct IDLOptions {
|
||||
CaseStyle cpp_object_api_field_case_style;
|
||||
bool cpp_direct_copy;
|
||||
bool gen_nullable;
|
||||
std::string java_package_prefix;
|
||||
bool java_checkerframework;
|
||||
bool gen_generated;
|
||||
bool gen_json_coders;
|
||||
@@ -650,9 +691,13 @@ struct IDLOptions {
|
||||
bool json_nested_flatbuffers;
|
||||
bool json_nested_flexbuffers;
|
||||
bool json_nested_legacy_flatbuffers;
|
||||
bool ts_flat_file;
|
||||
bool ts_flat_files;
|
||||
bool ts_entry_points;
|
||||
bool ts_no_import_ext;
|
||||
bool no_leak_private_annotations;
|
||||
bool require_json_eof;
|
||||
bool keep_proto_id;
|
||||
ProtoIdGapAction proto_id_gap_action;
|
||||
|
||||
// Possible options for the more general generator below.
|
||||
enum Language {
|
||||
@@ -673,6 +718,7 @@ struct IDLOptions {
|
||||
kKotlin = 1 << 15,
|
||||
kSwift = 1 << 16,
|
||||
kNim = 1 << 17,
|
||||
kProto = 1 << 18,
|
||||
kMAX
|
||||
};
|
||||
|
||||
@@ -711,6 +757,7 @@ struct IDLOptions {
|
||||
output_enum_identifiers(true),
|
||||
prefixed_enums(true),
|
||||
scoped_enums(false),
|
||||
emit_min_max_enum_values(true),
|
||||
swift_implementation_only(false),
|
||||
include_dependence_headers(true),
|
||||
mutable_buffer(false),
|
||||
@@ -753,9 +800,13 @@ struct IDLOptions {
|
||||
json_nested_flatbuffers(true),
|
||||
json_nested_flexbuffers(true),
|
||||
json_nested_legacy_flatbuffers(false),
|
||||
ts_flat_file(false),
|
||||
ts_flat_files(false),
|
||||
ts_entry_points(false),
|
||||
ts_no_import_ext(false),
|
||||
no_leak_private_annotations(false),
|
||||
require_json_eof(true),
|
||||
keep_proto_id(false),
|
||||
proto_id_gap_action(ProtoIdGapAction::WARNING),
|
||||
mini_reflect(IDLOptions::kNone),
|
||||
require_explicit_ids(false),
|
||||
rust_serialize(false),
|
||||
@@ -792,7 +843,7 @@ struct ParserState {
|
||||
FLATBUFFERS_ASSERT(cursor_ && line_start_ && cursor_ >= line_start_);
|
||||
return static_cast<int64_t>(cursor_ - line_start_);
|
||||
}
|
||||
|
||||
|
||||
const char *prev_cursor_;
|
||||
const char *cursor_;
|
||||
const char *line_start_;
|
||||
@@ -899,6 +950,13 @@ class Parser : public ParserState {
|
||||
known_attributes_["private"] = true;
|
||||
}
|
||||
|
||||
// Copying is not allowed
|
||||
Parser(const Parser &) = delete;
|
||||
Parser &operator=(const Parser &) = delete;
|
||||
|
||||
Parser(Parser &&) = default;
|
||||
Parser &operator=(Parser &&) = default;
|
||||
|
||||
~Parser() {
|
||||
for (auto it = namespaces_.begin(); it != namespaces_.end(); ++it) {
|
||||
delete *it;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -41,15 +41,18 @@
|
||||
#include <optional>
|
||||
#endif
|
||||
|
||||
// The __cpp_lib_span is the predefined feature macro.
|
||||
#if defined(FLATBUFFERS_USE_STD_SPAN)
|
||||
#include <span>
|
||||
#elif defined(__cpp_lib_span) && defined(__has_include)
|
||||
#if __has_include(<span>)
|
||||
#include <array>
|
||||
#include <span>
|
||||
#define FLATBUFFERS_USE_STD_SPAN
|
||||
#ifndef FLATBUFFERS_USE_STD_SPAN
|
||||
// Testing __cpp_lib_span requires including either <version> or <span>,
|
||||
// both of which were added in C++20.
|
||||
// See: https://en.cppreference.com/w/cpp/utility/feature_test
|
||||
#if defined(__cplusplus) && __cplusplus >= 202002L
|
||||
#define FLATBUFFERS_USE_STD_SPAN 1
|
||||
#endif
|
||||
#endif // FLATBUFFERS_USE_STD_SPAN
|
||||
|
||||
#if defined(FLATBUFFERS_USE_STD_SPAN)
|
||||
#include <array>
|
||||
#include <span>
|
||||
#else
|
||||
// Disable non-trivial ctors if FLATBUFFERS_SPAN_MINIMAL defined.
|
||||
#if !defined(FLATBUFFERS_TEMPLATES_ALIASES)
|
||||
|
||||
@@ -61,4 +61,4 @@ static inline flatbuffers::string_view GetStringView(const String *str) {
|
||||
|
||||
} // namespace flatbuffers
|
||||
|
||||
#endif // FLATBUFFERS_STRING_H_
|
||||
#endif // FLATBUFFERS_STRING_H_
|
||||
|
||||
@@ -50,4 +50,4 @@ class Struct FLATBUFFERS_FINAL_CLASS {
|
||||
|
||||
} // namespace flatbuffers
|
||||
|
||||
#endif // FLATBUFFERS_STRUCT_H_
|
||||
#endif // FLATBUFFERS_STRUCT_H_
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
# include <stdio.h>
|
||||
#endif // FLATBUFFERS_PREFER_PRINTF
|
||||
|
||||
#include <cmath>
|
||||
#include <limits>
|
||||
#include <string>
|
||||
|
||||
@@ -313,6 +314,7 @@ inline bool StringToFloatImpl(T *val, const char *const str) {
|
||||
strtoval_impl(val, str, const_cast<char **>(&end));
|
||||
auto done = (end != str) && (*end == '\0');
|
||||
if (!done) *val = 0; // erase partial result
|
||||
if (done && std::isnan(*val)) { *val = std::numeric_limits<T>::quiet_NaN(); }
|
||||
return done;
|
||||
}
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ class vector_downward {
|
||||
cur_(nullptr),
|
||||
scratch_(nullptr) {}
|
||||
|
||||
vector_downward(vector_downward &&other)
|
||||
vector_downward(vector_downward &&other) noexcept
|
||||
// clang-format on
|
||||
: allocator_(other.allocator_),
|
||||
own_allocator_(other.own_allocator_),
|
||||
@@ -66,7 +66,7 @@ class vector_downward {
|
||||
other.scratch_ = nullptr;
|
||||
}
|
||||
|
||||
vector_downward &operator=(vector_downward &&other) {
|
||||
vector_downward &operator=(vector_downward &&other) noexcept {
|
||||
// Move construct a temporary and swap idiom
|
||||
vector_downward temp(std::move(other));
|
||||
swap(temp);
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.google.flatbuffers</groupId>
|
||||
<artifactId>flatbuffers-java</artifactId>
|
||||
<version>22.12.06</version>
|
||||
<version>23.3.3</version>
|
||||
<packaging>bundle</packaging>
|
||||
<name>FlatBuffers Java API</name>
|
||||
<description>
|
||||
@@ -25,7 +25,7 @@
|
||||
<licenses>
|
||||
<license>
|
||||
<name>Apache License V2.0</name>
|
||||
<url>https://raw.githubusercontent.com/google/flatbuffers/master/LICENSE.txt</url>
|
||||
<url>https://raw.githubusercontent.com/google/flatbuffers/master/LICENSE</url>
|
||||
<distribution>repo</distribution>
|
||||
</license>
|
||||
</licenses>
|
||||
|
||||
@@ -46,7 +46,7 @@ public class Constants {
|
||||
Changes to the Java implementation need to be sure to change
|
||||
the version here and in the code generator on every possible
|
||||
incompatible change */
|
||||
public static void FLATBUFFERS_22_12_06() {}
|
||||
public static void FLATBUFFERS_23_3_3() {}
|
||||
}
|
||||
|
||||
/// @endcond
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
package com.google.flatbuffers.reflection;
|
||||
|
||||
/**
|
||||
* New schema language features that are not supported by old code generators.
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public final class AdvancedFeatures {
|
||||
private AdvancedFeatures() { }
|
||||
public static final long AdvancedArrayFeatures = 1L;
|
||||
public static final long AdvancedUnionFeatures = 2L;
|
||||
public static final long OptionalScalars = 4L;
|
||||
public static final long DefaultVectorsAndStrings = 8L;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
package com.google.flatbuffers.reflection;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public final class BaseType {
|
||||
private BaseType() { }
|
||||
public static final byte None = 0;
|
||||
public static final byte UType = 1;
|
||||
public static final byte Bool = 2;
|
||||
public static final byte Byte = 3;
|
||||
public static final byte UByte = 4;
|
||||
public static final byte Short = 5;
|
||||
public static final byte UShort = 6;
|
||||
public static final byte Int = 7;
|
||||
public static final byte UInt = 8;
|
||||
public static final byte Long = 9;
|
||||
public static final byte ULong = 10;
|
||||
public static final byte Float = 11;
|
||||
public static final byte Double = 12;
|
||||
public static final byte String = 13;
|
||||
public static final byte Vector = 14;
|
||||
public static final byte Obj = 15;
|
||||
public static final byte Union = 16;
|
||||
public static final byte Array = 17;
|
||||
public static final byte MaxBaseType = 18;
|
||||
|
||||
public static final String[] names = { "None", "UType", "Bool", "Byte", "UByte", "Short", "UShort", "Int", "UInt", "Long", "ULong", "Float", "Double", "String", "Vector", "Obj", "Union", "Array", "MaxBaseType", };
|
||||
|
||||
public static String name(int e) { return names[e]; }
|
||||
}
|
||||
|
||||
135
java/src/main/java/com/google/flatbuffers/reflection/Enum.java
Normal file
135
java/src/main/java/com/google/flatbuffers/reflection/Enum.java
Normal file
@@ -0,0 +1,135 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
package com.google.flatbuffers.reflection;
|
||||
|
||||
import com.google.flatbuffers.BaseVector;
|
||||
import com.google.flatbuffers.BooleanVector;
|
||||
import com.google.flatbuffers.ByteVector;
|
||||
import com.google.flatbuffers.Constants;
|
||||
import com.google.flatbuffers.DoubleVector;
|
||||
import com.google.flatbuffers.FlatBufferBuilder;
|
||||
import com.google.flatbuffers.FloatVector;
|
||||
import com.google.flatbuffers.IntVector;
|
||||
import com.google.flatbuffers.LongVector;
|
||||
import com.google.flatbuffers.ShortVector;
|
||||
import com.google.flatbuffers.StringVector;
|
||||
import com.google.flatbuffers.Struct;
|
||||
import com.google.flatbuffers.Table;
|
||||
import com.google.flatbuffers.UnionVector;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public final class Enum extends Table {
|
||||
public static void ValidateVersion() { Constants.FLATBUFFERS_23_3_3(); }
|
||||
public static Enum getRootAsEnum(ByteBuffer _bb) { return getRootAsEnum(_bb, new Enum()); }
|
||||
public static Enum getRootAsEnum(ByteBuffer _bb, Enum obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
|
||||
public void __init(int _i, ByteBuffer _bb) { __reset(_i, _bb); }
|
||||
public Enum __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }
|
||||
|
||||
public String name() { int o = __offset(4); return o != 0 ? __string(o + bb_pos) : null; }
|
||||
public ByteBuffer nameAsByteBuffer() { return __vector_as_bytebuffer(4, 1); }
|
||||
public ByteBuffer nameInByteBuffer(ByteBuffer _bb) { return __vector_in_bytebuffer(_bb, 4, 1); }
|
||||
public com.google.flatbuffers.reflection.EnumVal values(int j) { return values(new com.google.flatbuffers.reflection.EnumVal(), j); }
|
||||
public com.google.flatbuffers.reflection.EnumVal values(com.google.flatbuffers.reflection.EnumVal obj, int j) { int o = __offset(6); return o != 0 ? obj.__assign(__indirect(__vector(o) + j * 4), bb) : null; }
|
||||
public int valuesLength() { int o = __offset(6); return o != 0 ? __vector_len(o) : 0; }
|
||||
public com.google.flatbuffers.reflection.EnumVal valuesByKey(long key) { int o = __offset(6); return o != 0 ? com.google.flatbuffers.reflection.EnumVal.__lookup_by_key(null, __vector(o), key, bb) : null; }
|
||||
public com.google.flatbuffers.reflection.EnumVal valuesByKey(com.google.flatbuffers.reflection.EnumVal obj, long key) { int o = __offset(6); return o != 0 ? com.google.flatbuffers.reflection.EnumVal.__lookup_by_key(obj, __vector(o), key, bb) : null; }
|
||||
public com.google.flatbuffers.reflection.EnumVal.Vector valuesVector() { return valuesVector(new com.google.flatbuffers.reflection.EnumVal.Vector()); }
|
||||
public com.google.flatbuffers.reflection.EnumVal.Vector valuesVector(com.google.flatbuffers.reflection.EnumVal.Vector obj) { int o = __offset(6); return o != 0 ? obj.__assign(__vector(o), 4, bb) : null; }
|
||||
public boolean isUnion() { int o = __offset(8); return o != 0 ? 0!=bb.get(o + bb_pos) : false; }
|
||||
public com.google.flatbuffers.reflection.Type underlyingType() { return underlyingType(new com.google.flatbuffers.reflection.Type()); }
|
||||
public com.google.flatbuffers.reflection.Type underlyingType(com.google.flatbuffers.reflection.Type obj) { int o = __offset(10); return o != 0 ? obj.__assign(__indirect(o + bb_pos), bb) : null; }
|
||||
public com.google.flatbuffers.reflection.KeyValue attributes(int j) { return attributes(new com.google.flatbuffers.reflection.KeyValue(), j); }
|
||||
public com.google.flatbuffers.reflection.KeyValue attributes(com.google.flatbuffers.reflection.KeyValue obj, int j) { int o = __offset(12); return o != 0 ? obj.__assign(__indirect(__vector(o) + j * 4), bb) : null; }
|
||||
public int attributesLength() { int o = __offset(12); return o != 0 ? __vector_len(o) : 0; }
|
||||
public com.google.flatbuffers.reflection.KeyValue attributesByKey(String key) { int o = __offset(12); return o != 0 ? com.google.flatbuffers.reflection.KeyValue.__lookup_by_key(null, __vector(o), key, bb) : null; }
|
||||
public com.google.flatbuffers.reflection.KeyValue attributesByKey(com.google.flatbuffers.reflection.KeyValue obj, String key) { int o = __offset(12); return o != 0 ? com.google.flatbuffers.reflection.KeyValue.__lookup_by_key(obj, __vector(o), key, bb) : null; }
|
||||
public com.google.flatbuffers.reflection.KeyValue.Vector attributesVector() { return attributesVector(new com.google.flatbuffers.reflection.KeyValue.Vector()); }
|
||||
public com.google.flatbuffers.reflection.KeyValue.Vector attributesVector(com.google.flatbuffers.reflection.KeyValue.Vector obj) { int o = __offset(12); return o != 0 ? obj.__assign(__vector(o), 4, bb) : null; }
|
||||
public String documentation(int j) { int o = __offset(14); return o != 0 ? __string(__vector(o) + j * 4) : null; }
|
||||
public int documentationLength() { int o = __offset(14); return o != 0 ? __vector_len(o) : 0; }
|
||||
public StringVector documentationVector() { return documentationVector(new StringVector()); }
|
||||
public StringVector documentationVector(StringVector obj) { int o = __offset(14); return o != 0 ? obj.__assign(__vector(o), 4, bb) : null; }
|
||||
/**
|
||||
* File that this Enum is declared in.
|
||||
*/
|
||||
public String declarationFile() { int o = __offset(16); return o != 0 ? __string(o + bb_pos) : null; }
|
||||
public ByteBuffer declarationFileAsByteBuffer() { return __vector_as_bytebuffer(16, 1); }
|
||||
public ByteBuffer declarationFileInByteBuffer(ByteBuffer _bb) { return __vector_in_bytebuffer(_bb, 16, 1); }
|
||||
|
||||
public static int createEnum(FlatBufferBuilder builder,
|
||||
int nameOffset,
|
||||
int valuesOffset,
|
||||
boolean isUnion,
|
||||
int underlyingTypeOffset,
|
||||
int attributesOffset,
|
||||
int documentationOffset,
|
||||
int declarationFileOffset) {
|
||||
builder.startTable(7);
|
||||
Enum.addDeclarationFile(builder, declarationFileOffset);
|
||||
Enum.addDocumentation(builder, documentationOffset);
|
||||
Enum.addAttributes(builder, attributesOffset);
|
||||
Enum.addUnderlyingType(builder, underlyingTypeOffset);
|
||||
Enum.addValues(builder, valuesOffset);
|
||||
Enum.addName(builder, nameOffset);
|
||||
Enum.addIsUnion(builder, isUnion);
|
||||
return Enum.endEnum(builder);
|
||||
}
|
||||
|
||||
public static void startEnum(FlatBufferBuilder builder) { builder.startTable(7); }
|
||||
public static void addName(FlatBufferBuilder builder, int nameOffset) { builder.addOffset(nameOffset); builder.slot(0); }
|
||||
public static void addValues(FlatBufferBuilder builder, int valuesOffset) { builder.addOffset(1, valuesOffset, 0); }
|
||||
public static int createValuesVector(FlatBufferBuilder builder, int[] data) { builder.startVector(4, data.length, 4); for (int i = data.length - 1; i >= 0; i--) builder.addOffset(data[i]); return builder.endVector(); }
|
||||
public static void startValuesVector(FlatBufferBuilder builder, int numElems) { builder.startVector(4, numElems, 4); }
|
||||
public static void addIsUnion(FlatBufferBuilder builder, boolean isUnion) { builder.addBoolean(2, isUnion, false); }
|
||||
public static void addUnderlyingType(FlatBufferBuilder builder, int underlyingTypeOffset) { builder.addOffset(3, underlyingTypeOffset, 0); }
|
||||
public static void addAttributes(FlatBufferBuilder builder, int attributesOffset) { builder.addOffset(4, attributesOffset, 0); }
|
||||
public static int createAttributesVector(FlatBufferBuilder builder, int[] data) { builder.startVector(4, data.length, 4); for (int i = data.length - 1; i >= 0; i--) builder.addOffset(data[i]); return builder.endVector(); }
|
||||
public static void startAttributesVector(FlatBufferBuilder builder, int numElems) { builder.startVector(4, numElems, 4); }
|
||||
public static void addDocumentation(FlatBufferBuilder builder, int documentationOffset) { builder.addOffset(5, documentationOffset, 0); }
|
||||
public static int createDocumentationVector(FlatBufferBuilder builder, int[] data) { builder.startVector(4, data.length, 4); for (int i = data.length - 1; i >= 0; i--) builder.addOffset(data[i]); return builder.endVector(); }
|
||||
public static void startDocumentationVector(FlatBufferBuilder builder, int numElems) { builder.startVector(4, numElems, 4); }
|
||||
public static void addDeclarationFile(FlatBufferBuilder builder, int declarationFileOffset) { builder.addOffset(6, declarationFileOffset, 0); }
|
||||
public static int endEnum(FlatBufferBuilder builder) {
|
||||
int o = builder.endTable();
|
||||
builder.required(o, 4); // name
|
||||
builder.required(o, 6); // values
|
||||
builder.required(o, 10); // underlying_type
|
||||
return o;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int keysCompare(Integer o1, Integer o2, ByteBuffer _bb) { return compareStrings(__offset(4, o1, _bb), __offset(4, o2, _bb), _bb); }
|
||||
|
||||
public static Enum __lookup_by_key(Enum obj, int vectorLocation, String key, ByteBuffer bb) {
|
||||
byte[] byteKey = key.getBytes(java.nio.charset.StandardCharsets.UTF_8);
|
||||
int span = bb.getInt(vectorLocation - 4);
|
||||
int start = 0;
|
||||
while (span != 0) {
|
||||
int middle = span / 2;
|
||||
int tableOffset = __indirect(vectorLocation + 4 * (start + middle), bb);
|
||||
int comp = compareStrings(__offset(4, bb.capacity() - tableOffset, bb), byteKey, bb);
|
||||
if (comp > 0) {
|
||||
span = middle;
|
||||
} else if (comp < 0) {
|
||||
middle++;
|
||||
start += middle;
|
||||
span -= middle;
|
||||
} else {
|
||||
return (obj == null ? new Enum() : obj).__assign(tableOffset, bb);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static final class Vector extends BaseVector {
|
||||
public Vector __assign(int _vector, int _element_size, ByteBuffer _bb) { __reset(_vector, _element_size, _bb); return this; }
|
||||
|
||||
public Enum get(int j) { return get(new Enum(), j); }
|
||||
public Enum get(Enum obj, int j) { return obj.__assign(__indirect(__element(j), bb), bb); }
|
||||
public Enum getByKey(String key) { return __lookup_by_key(null, __vector(), key, bb); }
|
||||
public Enum getByKey(Enum obj, String key) { return __lookup_by_key(obj, __vector(), key, bb); }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,116 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
package com.google.flatbuffers.reflection;
|
||||
|
||||
import com.google.flatbuffers.BaseVector;
|
||||
import com.google.flatbuffers.BooleanVector;
|
||||
import com.google.flatbuffers.ByteVector;
|
||||
import com.google.flatbuffers.Constants;
|
||||
import com.google.flatbuffers.DoubleVector;
|
||||
import com.google.flatbuffers.FlatBufferBuilder;
|
||||
import com.google.flatbuffers.FloatVector;
|
||||
import com.google.flatbuffers.IntVector;
|
||||
import com.google.flatbuffers.LongVector;
|
||||
import com.google.flatbuffers.ShortVector;
|
||||
import com.google.flatbuffers.StringVector;
|
||||
import com.google.flatbuffers.Struct;
|
||||
import com.google.flatbuffers.Table;
|
||||
import com.google.flatbuffers.UnionVector;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public final class EnumVal extends Table {
|
||||
public static void ValidateVersion() { Constants.FLATBUFFERS_23_3_3(); }
|
||||
public static EnumVal getRootAsEnumVal(ByteBuffer _bb) { return getRootAsEnumVal(_bb, new EnumVal()); }
|
||||
public static EnumVal getRootAsEnumVal(ByteBuffer _bb, EnumVal obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
|
||||
public void __init(int _i, ByteBuffer _bb) { __reset(_i, _bb); }
|
||||
public EnumVal __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }
|
||||
|
||||
public String name() { int o = __offset(4); return o != 0 ? __string(o + bb_pos) : null; }
|
||||
public ByteBuffer nameAsByteBuffer() { return __vector_as_bytebuffer(4, 1); }
|
||||
public ByteBuffer nameInByteBuffer(ByteBuffer _bb) { return __vector_in_bytebuffer(_bb, 4, 1); }
|
||||
public long value() { int o = __offset(6); return o != 0 ? bb.getLong(o + bb_pos) : 0L; }
|
||||
public com.google.flatbuffers.reflection.Type unionType() { return unionType(new com.google.flatbuffers.reflection.Type()); }
|
||||
public com.google.flatbuffers.reflection.Type unionType(com.google.flatbuffers.reflection.Type obj) { int o = __offset(10); return o != 0 ? obj.__assign(__indirect(o + bb_pos), bb) : null; }
|
||||
public String documentation(int j) { int o = __offset(12); return o != 0 ? __string(__vector(o) + j * 4) : null; }
|
||||
public int documentationLength() { int o = __offset(12); return o != 0 ? __vector_len(o) : 0; }
|
||||
public StringVector documentationVector() { return documentationVector(new StringVector()); }
|
||||
public StringVector documentationVector(StringVector obj) { int o = __offset(12); return o != 0 ? obj.__assign(__vector(o), 4, bb) : null; }
|
||||
public com.google.flatbuffers.reflection.KeyValue attributes(int j) { return attributes(new com.google.flatbuffers.reflection.KeyValue(), j); }
|
||||
public com.google.flatbuffers.reflection.KeyValue attributes(com.google.flatbuffers.reflection.KeyValue obj, int j) { int o = __offset(14); return o != 0 ? obj.__assign(__indirect(__vector(o) + j * 4), bb) : null; }
|
||||
public int attributesLength() { int o = __offset(14); return o != 0 ? __vector_len(o) : 0; }
|
||||
public com.google.flatbuffers.reflection.KeyValue attributesByKey(String key) { int o = __offset(14); return o != 0 ? com.google.flatbuffers.reflection.KeyValue.__lookup_by_key(null, __vector(o), key, bb) : null; }
|
||||
public com.google.flatbuffers.reflection.KeyValue attributesByKey(com.google.flatbuffers.reflection.KeyValue obj, String key) { int o = __offset(14); return o != 0 ? com.google.flatbuffers.reflection.KeyValue.__lookup_by_key(obj, __vector(o), key, bb) : null; }
|
||||
public com.google.flatbuffers.reflection.KeyValue.Vector attributesVector() { return attributesVector(new com.google.flatbuffers.reflection.KeyValue.Vector()); }
|
||||
public com.google.flatbuffers.reflection.KeyValue.Vector attributesVector(com.google.flatbuffers.reflection.KeyValue.Vector obj) { int o = __offset(14); return o != 0 ? obj.__assign(__vector(o), 4, bb) : null; }
|
||||
|
||||
public static int createEnumVal(FlatBufferBuilder builder,
|
||||
int nameOffset,
|
||||
long value,
|
||||
int unionTypeOffset,
|
||||
int documentationOffset,
|
||||
int attributesOffset) {
|
||||
builder.startTable(6);
|
||||
EnumVal.addValue(builder, value);
|
||||
EnumVal.addAttributes(builder, attributesOffset);
|
||||
EnumVal.addDocumentation(builder, documentationOffset);
|
||||
EnumVal.addUnionType(builder, unionTypeOffset);
|
||||
EnumVal.addName(builder, nameOffset);
|
||||
return EnumVal.endEnumVal(builder);
|
||||
}
|
||||
|
||||
public static void startEnumVal(FlatBufferBuilder builder) { builder.startTable(6); }
|
||||
public static void addName(FlatBufferBuilder builder, int nameOffset) { builder.addOffset(0, nameOffset, 0); }
|
||||
public static void addValue(FlatBufferBuilder builder, long value) { builder.addLong(value); builder.slot(1); }
|
||||
public static void addUnionType(FlatBufferBuilder builder, int unionTypeOffset) { builder.addOffset(3, unionTypeOffset, 0); }
|
||||
public static void addDocumentation(FlatBufferBuilder builder, int documentationOffset) { builder.addOffset(4, documentationOffset, 0); }
|
||||
public static int createDocumentationVector(FlatBufferBuilder builder, int[] data) { builder.startVector(4, data.length, 4); for (int i = data.length - 1; i >= 0; i--) builder.addOffset(data[i]); return builder.endVector(); }
|
||||
public static void startDocumentationVector(FlatBufferBuilder builder, int numElems) { builder.startVector(4, numElems, 4); }
|
||||
public static void addAttributes(FlatBufferBuilder builder, int attributesOffset) { builder.addOffset(5, attributesOffset, 0); }
|
||||
public static int createAttributesVector(FlatBufferBuilder builder, int[] data) { builder.startVector(4, data.length, 4); for (int i = data.length - 1; i >= 0; i--) builder.addOffset(data[i]); return builder.endVector(); }
|
||||
public static void startAttributesVector(FlatBufferBuilder builder, int numElems) { builder.startVector(4, numElems, 4); }
|
||||
public static int endEnumVal(FlatBufferBuilder builder) {
|
||||
int o = builder.endTable();
|
||||
builder.required(o, 4); // name
|
||||
return o;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int keysCompare(Integer o1, Integer o2, ByteBuffer _bb) {
|
||||
long val_1 = _bb.getLong(__offset(6, o1, _bb));
|
||||
long val_2 = _bb.getLong(__offset(6, o2, _bb));
|
||||
return val_1 > val_2 ? 1 : val_1 < val_2 ? -1 : 0;
|
||||
}
|
||||
|
||||
public static EnumVal __lookup_by_key(EnumVal obj, int vectorLocation, long key, ByteBuffer bb) {
|
||||
int span = bb.getInt(vectorLocation - 4);
|
||||
int start = 0;
|
||||
while (span != 0) {
|
||||
int middle = span / 2;
|
||||
int tableOffset = __indirect(vectorLocation + 4 * (start + middle), bb);
|
||||
long val = bb.getLong(__offset(6, bb.capacity() - tableOffset, bb));
|
||||
int comp = val > key ? 1 : val < key ? -1 : 0;
|
||||
if (comp > 0) {
|
||||
span = middle;
|
||||
} else if (comp < 0) {
|
||||
middle++;
|
||||
start += middle;
|
||||
span -= middle;
|
||||
} else {
|
||||
return (obj == null ? new EnumVal() : obj).__assign(tableOffset, bb);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static final class Vector extends BaseVector {
|
||||
public Vector __assign(int _vector, int _element_size, ByteBuffer _bb) { __reset(_vector, _element_size, _bb); return this; }
|
||||
|
||||
public EnumVal get(int j) { return get(new EnumVal(), j); }
|
||||
public EnumVal get(EnumVal obj, int j) { return obj.__assign(__indirect(__element(j), bb), bb); }
|
||||
public EnumVal getByKey(long key) { return __lookup_by_key(null, __vector(), key, bb); }
|
||||
public EnumVal getByKey(EnumVal obj, long key) { return __lookup_by_key(obj, __vector(), key, bb); }
|
||||
}
|
||||
}
|
||||
|
||||
148
java/src/main/java/com/google/flatbuffers/reflection/Field.java
Normal file
148
java/src/main/java/com/google/flatbuffers/reflection/Field.java
Normal file
@@ -0,0 +1,148 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
package com.google.flatbuffers.reflection;
|
||||
|
||||
import com.google.flatbuffers.BaseVector;
|
||||
import com.google.flatbuffers.BooleanVector;
|
||||
import com.google.flatbuffers.ByteVector;
|
||||
import com.google.flatbuffers.Constants;
|
||||
import com.google.flatbuffers.DoubleVector;
|
||||
import com.google.flatbuffers.FlatBufferBuilder;
|
||||
import com.google.flatbuffers.FloatVector;
|
||||
import com.google.flatbuffers.IntVector;
|
||||
import com.google.flatbuffers.LongVector;
|
||||
import com.google.flatbuffers.ShortVector;
|
||||
import com.google.flatbuffers.StringVector;
|
||||
import com.google.flatbuffers.Struct;
|
||||
import com.google.flatbuffers.Table;
|
||||
import com.google.flatbuffers.UnionVector;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public final class Field extends Table {
|
||||
public static void ValidateVersion() { Constants.FLATBUFFERS_23_3_3(); }
|
||||
public static Field getRootAsField(ByteBuffer _bb) { return getRootAsField(_bb, new Field()); }
|
||||
public static Field getRootAsField(ByteBuffer _bb, Field obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
|
||||
public void __init(int _i, ByteBuffer _bb) { __reset(_i, _bb); }
|
||||
public Field __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }
|
||||
|
||||
public String name() { int o = __offset(4); return o != 0 ? __string(o + bb_pos) : null; }
|
||||
public ByteBuffer nameAsByteBuffer() { return __vector_as_bytebuffer(4, 1); }
|
||||
public ByteBuffer nameInByteBuffer(ByteBuffer _bb) { return __vector_in_bytebuffer(_bb, 4, 1); }
|
||||
public com.google.flatbuffers.reflection.Type type() { return type(new com.google.flatbuffers.reflection.Type()); }
|
||||
public com.google.flatbuffers.reflection.Type type(com.google.flatbuffers.reflection.Type obj) { int o = __offset(6); return o != 0 ? obj.__assign(__indirect(o + bb_pos), bb) : null; }
|
||||
public int id() { int o = __offset(8); return o != 0 ? bb.getShort(o + bb_pos) & 0xFFFF : 0; }
|
||||
public int offset() { int o = __offset(10); return o != 0 ? bb.getShort(o + bb_pos) & 0xFFFF : 0; }
|
||||
public long defaultInteger() { int o = __offset(12); return o != 0 ? bb.getLong(o + bb_pos) : 0L; }
|
||||
public double defaultReal() { int o = __offset(14); return o != 0 ? bb.getDouble(o + bb_pos) : 0.0; }
|
||||
public boolean deprecated() { int o = __offset(16); return o != 0 ? 0!=bb.get(o + bb_pos) : false; }
|
||||
public boolean required() { int o = __offset(18); return o != 0 ? 0!=bb.get(o + bb_pos) : false; }
|
||||
public boolean key() { int o = __offset(20); return o != 0 ? 0!=bb.get(o + bb_pos) : false; }
|
||||
public com.google.flatbuffers.reflection.KeyValue attributes(int j) { return attributes(new com.google.flatbuffers.reflection.KeyValue(), j); }
|
||||
public com.google.flatbuffers.reflection.KeyValue attributes(com.google.flatbuffers.reflection.KeyValue obj, int j) { int o = __offset(22); return o != 0 ? obj.__assign(__indirect(__vector(o) + j * 4), bb) : null; }
|
||||
public int attributesLength() { int o = __offset(22); return o != 0 ? __vector_len(o) : 0; }
|
||||
public com.google.flatbuffers.reflection.KeyValue attributesByKey(String key) { int o = __offset(22); return o != 0 ? com.google.flatbuffers.reflection.KeyValue.__lookup_by_key(null, __vector(o), key, bb) : null; }
|
||||
public com.google.flatbuffers.reflection.KeyValue attributesByKey(com.google.flatbuffers.reflection.KeyValue obj, String key) { int o = __offset(22); return o != 0 ? com.google.flatbuffers.reflection.KeyValue.__lookup_by_key(obj, __vector(o), key, bb) : null; }
|
||||
public com.google.flatbuffers.reflection.KeyValue.Vector attributesVector() { return attributesVector(new com.google.flatbuffers.reflection.KeyValue.Vector()); }
|
||||
public com.google.flatbuffers.reflection.KeyValue.Vector attributesVector(com.google.flatbuffers.reflection.KeyValue.Vector obj) { int o = __offset(22); return o != 0 ? obj.__assign(__vector(o), 4, bb) : null; }
|
||||
public String documentation(int j) { int o = __offset(24); return o != 0 ? __string(__vector(o) + j * 4) : null; }
|
||||
public int documentationLength() { int o = __offset(24); return o != 0 ? __vector_len(o) : 0; }
|
||||
public StringVector documentationVector() { return documentationVector(new StringVector()); }
|
||||
public StringVector documentationVector(StringVector obj) { int o = __offset(24); return o != 0 ? obj.__assign(__vector(o), 4, bb) : null; }
|
||||
public boolean optional() { int o = __offset(26); return o != 0 ? 0!=bb.get(o + bb_pos) : false; }
|
||||
/**
|
||||
* Number of padding octets to always add after this field. Structs only.
|
||||
*/
|
||||
public int padding() { int o = __offset(28); return o != 0 ? bb.getShort(o + bb_pos) & 0xFFFF : 0; }
|
||||
|
||||
public static int createField(FlatBufferBuilder builder,
|
||||
int nameOffset,
|
||||
int typeOffset,
|
||||
int id,
|
||||
int offset,
|
||||
long defaultInteger,
|
||||
double defaultReal,
|
||||
boolean deprecated,
|
||||
boolean required,
|
||||
boolean key,
|
||||
int attributesOffset,
|
||||
int documentationOffset,
|
||||
boolean optional,
|
||||
int padding) {
|
||||
builder.startTable(13);
|
||||
Field.addDefaultReal(builder, defaultReal);
|
||||
Field.addDefaultInteger(builder, defaultInteger);
|
||||
Field.addDocumentation(builder, documentationOffset);
|
||||
Field.addAttributes(builder, attributesOffset);
|
||||
Field.addType(builder, typeOffset);
|
||||
Field.addName(builder, nameOffset);
|
||||
Field.addPadding(builder, padding);
|
||||
Field.addOffset(builder, offset);
|
||||
Field.addId(builder, id);
|
||||
Field.addOptional(builder, optional);
|
||||
Field.addKey(builder, key);
|
||||
Field.addRequired(builder, required);
|
||||
Field.addDeprecated(builder, deprecated);
|
||||
return Field.endField(builder);
|
||||
}
|
||||
|
||||
public static void startField(FlatBufferBuilder builder) { builder.startTable(13); }
|
||||
public static void addName(FlatBufferBuilder builder, int nameOffset) { builder.addOffset(nameOffset); builder.slot(0); }
|
||||
public static void addType(FlatBufferBuilder builder, int typeOffset) { builder.addOffset(1, typeOffset, 0); }
|
||||
public static void addId(FlatBufferBuilder builder, int id) { builder.addShort(2, (short) id, (short) 0); }
|
||||
public static void addOffset(FlatBufferBuilder builder, int offset) { builder.addShort(3, (short) offset, (short) 0); }
|
||||
public static void addDefaultInteger(FlatBufferBuilder builder, long defaultInteger) { builder.addLong(4, defaultInteger, 0L); }
|
||||
public static void addDefaultReal(FlatBufferBuilder builder, double defaultReal) { builder.addDouble(5, defaultReal, 0.0); }
|
||||
public static void addDeprecated(FlatBufferBuilder builder, boolean deprecated) { builder.addBoolean(6, deprecated, false); }
|
||||
public static void addRequired(FlatBufferBuilder builder, boolean required) { builder.addBoolean(7, required, false); }
|
||||
public static void addKey(FlatBufferBuilder builder, boolean key) { builder.addBoolean(8, key, false); }
|
||||
public static void addAttributes(FlatBufferBuilder builder, int attributesOffset) { builder.addOffset(9, attributesOffset, 0); }
|
||||
public static int createAttributesVector(FlatBufferBuilder builder, int[] data) { builder.startVector(4, data.length, 4); for (int i = data.length - 1; i >= 0; i--) builder.addOffset(data[i]); return builder.endVector(); }
|
||||
public static void startAttributesVector(FlatBufferBuilder builder, int numElems) { builder.startVector(4, numElems, 4); }
|
||||
public static void addDocumentation(FlatBufferBuilder builder, int documentationOffset) { builder.addOffset(10, documentationOffset, 0); }
|
||||
public static int createDocumentationVector(FlatBufferBuilder builder, int[] data) { builder.startVector(4, data.length, 4); for (int i = data.length - 1; i >= 0; i--) builder.addOffset(data[i]); return builder.endVector(); }
|
||||
public static void startDocumentationVector(FlatBufferBuilder builder, int numElems) { builder.startVector(4, numElems, 4); }
|
||||
public static void addOptional(FlatBufferBuilder builder, boolean optional) { builder.addBoolean(11, optional, false); }
|
||||
public static void addPadding(FlatBufferBuilder builder, int padding) { builder.addShort(12, (short) padding, (short) 0); }
|
||||
public static int endField(FlatBufferBuilder builder) {
|
||||
int o = builder.endTable();
|
||||
builder.required(o, 4); // name
|
||||
builder.required(o, 6); // type
|
||||
return o;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int keysCompare(Integer o1, Integer o2, ByteBuffer _bb) { return compareStrings(__offset(4, o1, _bb), __offset(4, o2, _bb), _bb); }
|
||||
|
||||
public static Field __lookup_by_key(Field obj, int vectorLocation, String key, ByteBuffer bb) {
|
||||
byte[] byteKey = key.getBytes(java.nio.charset.StandardCharsets.UTF_8);
|
||||
int span = bb.getInt(vectorLocation - 4);
|
||||
int start = 0;
|
||||
while (span != 0) {
|
||||
int middle = span / 2;
|
||||
int tableOffset = __indirect(vectorLocation + 4 * (start + middle), bb);
|
||||
int comp = compareStrings(__offset(4, bb.capacity() - tableOffset, bb), byteKey, bb);
|
||||
if (comp > 0) {
|
||||
span = middle;
|
||||
} else if (comp < 0) {
|
||||
middle++;
|
||||
start += middle;
|
||||
span -= middle;
|
||||
} else {
|
||||
return (obj == null ? new Field() : obj).__assign(tableOffset, bb);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static final class Vector extends BaseVector {
|
||||
public Vector __assign(int _vector, int _element_size, ByteBuffer _bb) { __reset(_vector, _element_size, _bb); return this; }
|
||||
|
||||
public Field get(int j) { return get(new Field(), j); }
|
||||
public Field get(Field obj, int j) { return obj.__assign(__indirect(__element(j), bb), bb); }
|
||||
public Field getByKey(String key) { return __lookup_by_key(null, __vector(), key, bb); }
|
||||
public Field getByKey(Field obj, String key) { return __lookup_by_key(obj, __vector(), key, bb); }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
package com.google.flatbuffers.reflection;
|
||||
|
||||
import com.google.flatbuffers.BaseVector;
|
||||
import com.google.flatbuffers.BooleanVector;
|
||||
import com.google.flatbuffers.ByteVector;
|
||||
import com.google.flatbuffers.Constants;
|
||||
import com.google.flatbuffers.DoubleVector;
|
||||
import com.google.flatbuffers.FlatBufferBuilder;
|
||||
import com.google.flatbuffers.FloatVector;
|
||||
import com.google.flatbuffers.IntVector;
|
||||
import com.google.flatbuffers.LongVector;
|
||||
import com.google.flatbuffers.ShortVector;
|
||||
import com.google.flatbuffers.StringVector;
|
||||
import com.google.flatbuffers.Struct;
|
||||
import com.google.flatbuffers.Table;
|
||||
import com.google.flatbuffers.UnionVector;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public final class KeyValue extends Table {
|
||||
public static void ValidateVersion() { Constants.FLATBUFFERS_23_3_3(); }
|
||||
public static KeyValue getRootAsKeyValue(ByteBuffer _bb) { return getRootAsKeyValue(_bb, new KeyValue()); }
|
||||
public static KeyValue getRootAsKeyValue(ByteBuffer _bb, KeyValue obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
|
||||
public void __init(int _i, ByteBuffer _bb) { __reset(_i, _bb); }
|
||||
public KeyValue __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }
|
||||
|
||||
public String key() { int o = __offset(4); return o != 0 ? __string(o + bb_pos) : null; }
|
||||
public ByteBuffer keyAsByteBuffer() { return __vector_as_bytebuffer(4, 1); }
|
||||
public ByteBuffer keyInByteBuffer(ByteBuffer _bb) { return __vector_in_bytebuffer(_bb, 4, 1); }
|
||||
public String value() { int o = __offset(6); return o != 0 ? __string(o + bb_pos) : null; }
|
||||
public ByteBuffer valueAsByteBuffer() { return __vector_as_bytebuffer(6, 1); }
|
||||
public ByteBuffer valueInByteBuffer(ByteBuffer _bb) { return __vector_in_bytebuffer(_bb, 6, 1); }
|
||||
|
||||
public static int createKeyValue(FlatBufferBuilder builder,
|
||||
int keyOffset,
|
||||
int valueOffset) {
|
||||
builder.startTable(2);
|
||||
KeyValue.addValue(builder, valueOffset);
|
||||
KeyValue.addKey(builder, keyOffset);
|
||||
return KeyValue.endKeyValue(builder);
|
||||
}
|
||||
|
||||
public static void startKeyValue(FlatBufferBuilder builder) { builder.startTable(2); }
|
||||
public static void addKey(FlatBufferBuilder builder, int keyOffset) { builder.addOffset(keyOffset); builder.slot(0); }
|
||||
public static void addValue(FlatBufferBuilder builder, int valueOffset) { builder.addOffset(1, valueOffset, 0); }
|
||||
public static int endKeyValue(FlatBufferBuilder builder) {
|
||||
int o = builder.endTable();
|
||||
builder.required(o, 4); // key
|
||||
return o;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int keysCompare(Integer o1, Integer o2, ByteBuffer _bb) { return compareStrings(__offset(4, o1, _bb), __offset(4, o2, _bb), _bb); }
|
||||
|
||||
public static KeyValue __lookup_by_key(KeyValue obj, int vectorLocation, String key, ByteBuffer bb) {
|
||||
byte[] byteKey = key.getBytes(java.nio.charset.StandardCharsets.UTF_8);
|
||||
int span = bb.getInt(vectorLocation - 4);
|
||||
int start = 0;
|
||||
while (span != 0) {
|
||||
int middle = span / 2;
|
||||
int tableOffset = __indirect(vectorLocation + 4 * (start + middle), bb);
|
||||
int comp = compareStrings(__offset(4, bb.capacity() - tableOffset, bb), byteKey, bb);
|
||||
if (comp > 0) {
|
||||
span = middle;
|
||||
} else if (comp < 0) {
|
||||
middle++;
|
||||
start += middle;
|
||||
span -= middle;
|
||||
} else {
|
||||
return (obj == null ? new KeyValue() : obj).__assign(tableOffset, bb);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static final class Vector extends BaseVector {
|
||||
public Vector __assign(int _vector, int _element_size, ByteBuffer _bb) { __reset(_vector, _element_size, _bb); return this; }
|
||||
|
||||
public KeyValue get(int j) { return get(new KeyValue(), j); }
|
||||
public KeyValue get(KeyValue obj, int j) { return obj.__assign(__indirect(__element(j), bb), bb); }
|
||||
public KeyValue getByKey(String key) { return __lookup_by_key(null, __vector(), key, bb); }
|
||||
public KeyValue getByKey(KeyValue obj, String key) { return __lookup_by_key(obj, __vector(), key, bb); }
|
||||
}
|
||||
}
|
||||
|
||||
137
java/src/main/java/com/google/flatbuffers/reflection/Object.java
Normal file
137
java/src/main/java/com/google/flatbuffers/reflection/Object.java
Normal file
@@ -0,0 +1,137 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
package com.google.flatbuffers.reflection;
|
||||
|
||||
import com.google.flatbuffers.BaseVector;
|
||||
import com.google.flatbuffers.BooleanVector;
|
||||
import com.google.flatbuffers.ByteVector;
|
||||
import com.google.flatbuffers.Constants;
|
||||
import com.google.flatbuffers.DoubleVector;
|
||||
import com.google.flatbuffers.FlatBufferBuilder;
|
||||
import com.google.flatbuffers.FloatVector;
|
||||
import com.google.flatbuffers.IntVector;
|
||||
import com.google.flatbuffers.LongVector;
|
||||
import com.google.flatbuffers.ShortVector;
|
||||
import com.google.flatbuffers.StringVector;
|
||||
import com.google.flatbuffers.Struct;
|
||||
import com.google.flatbuffers.Table;
|
||||
import com.google.flatbuffers.UnionVector;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public final class Object extends Table {
|
||||
public static void ValidateVersion() { Constants.FLATBUFFERS_23_3_3(); }
|
||||
public static Object getRootAsObject(ByteBuffer _bb) { return getRootAsObject(_bb, new Object()); }
|
||||
public static Object getRootAsObject(ByteBuffer _bb, Object obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
|
||||
public void __init(int _i, ByteBuffer _bb) { __reset(_i, _bb); }
|
||||
public Object __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }
|
||||
|
||||
public String name() { int o = __offset(4); return o != 0 ? __string(o + bb_pos) : null; }
|
||||
public ByteBuffer nameAsByteBuffer() { return __vector_as_bytebuffer(4, 1); }
|
||||
public ByteBuffer nameInByteBuffer(ByteBuffer _bb) { return __vector_in_bytebuffer(_bb, 4, 1); }
|
||||
public com.google.flatbuffers.reflection.Field fields(int j) { return fields(new com.google.flatbuffers.reflection.Field(), j); }
|
||||
public com.google.flatbuffers.reflection.Field fields(com.google.flatbuffers.reflection.Field obj, int j) { int o = __offset(6); return o != 0 ? obj.__assign(__indirect(__vector(o) + j * 4), bb) : null; }
|
||||
public int fieldsLength() { int o = __offset(6); return o != 0 ? __vector_len(o) : 0; }
|
||||
public com.google.flatbuffers.reflection.Field fieldsByKey(String key) { int o = __offset(6); return o != 0 ? com.google.flatbuffers.reflection.Field.__lookup_by_key(null, __vector(o), key, bb) : null; }
|
||||
public com.google.flatbuffers.reflection.Field fieldsByKey(com.google.flatbuffers.reflection.Field obj, String key) { int o = __offset(6); return o != 0 ? com.google.flatbuffers.reflection.Field.__lookup_by_key(obj, __vector(o), key, bb) : null; }
|
||||
public com.google.flatbuffers.reflection.Field.Vector fieldsVector() { return fieldsVector(new com.google.flatbuffers.reflection.Field.Vector()); }
|
||||
public com.google.flatbuffers.reflection.Field.Vector fieldsVector(com.google.flatbuffers.reflection.Field.Vector obj) { int o = __offset(6); return o != 0 ? obj.__assign(__vector(o), 4, bb) : null; }
|
||||
public boolean isStruct() { int o = __offset(8); return o != 0 ? 0!=bb.get(o + bb_pos) : false; }
|
||||
public int minalign() { int o = __offset(10); return o != 0 ? bb.getInt(o + bb_pos) : 0; }
|
||||
public int bytesize() { int o = __offset(12); return o != 0 ? bb.getInt(o + bb_pos) : 0; }
|
||||
public com.google.flatbuffers.reflection.KeyValue attributes(int j) { return attributes(new com.google.flatbuffers.reflection.KeyValue(), j); }
|
||||
public com.google.flatbuffers.reflection.KeyValue attributes(com.google.flatbuffers.reflection.KeyValue obj, int j) { int o = __offset(14); return o != 0 ? obj.__assign(__indirect(__vector(o) + j * 4), bb) : null; }
|
||||
public int attributesLength() { int o = __offset(14); return o != 0 ? __vector_len(o) : 0; }
|
||||
public com.google.flatbuffers.reflection.KeyValue attributesByKey(String key) { int o = __offset(14); return o != 0 ? com.google.flatbuffers.reflection.KeyValue.__lookup_by_key(null, __vector(o), key, bb) : null; }
|
||||
public com.google.flatbuffers.reflection.KeyValue attributesByKey(com.google.flatbuffers.reflection.KeyValue obj, String key) { int o = __offset(14); return o != 0 ? com.google.flatbuffers.reflection.KeyValue.__lookup_by_key(obj, __vector(o), key, bb) : null; }
|
||||
public com.google.flatbuffers.reflection.KeyValue.Vector attributesVector() { return attributesVector(new com.google.flatbuffers.reflection.KeyValue.Vector()); }
|
||||
public com.google.flatbuffers.reflection.KeyValue.Vector attributesVector(com.google.flatbuffers.reflection.KeyValue.Vector obj) { int o = __offset(14); return o != 0 ? obj.__assign(__vector(o), 4, bb) : null; }
|
||||
public String documentation(int j) { int o = __offset(16); return o != 0 ? __string(__vector(o) + j * 4) : null; }
|
||||
public int documentationLength() { int o = __offset(16); return o != 0 ? __vector_len(o) : 0; }
|
||||
public StringVector documentationVector() { return documentationVector(new StringVector()); }
|
||||
public StringVector documentationVector(StringVector obj) { int o = __offset(16); return o != 0 ? obj.__assign(__vector(o), 4, bb) : null; }
|
||||
/**
|
||||
* File that this Object is declared in.
|
||||
*/
|
||||
public String declarationFile() { int o = __offset(18); return o != 0 ? __string(o + bb_pos) : null; }
|
||||
public ByteBuffer declarationFileAsByteBuffer() { return __vector_as_bytebuffer(18, 1); }
|
||||
public ByteBuffer declarationFileInByteBuffer(ByteBuffer _bb) { return __vector_in_bytebuffer(_bb, 18, 1); }
|
||||
|
||||
public static int createObject(FlatBufferBuilder builder,
|
||||
int nameOffset,
|
||||
int fieldsOffset,
|
||||
boolean isStruct,
|
||||
int minalign,
|
||||
int bytesize,
|
||||
int attributesOffset,
|
||||
int documentationOffset,
|
||||
int declarationFileOffset) {
|
||||
builder.startTable(8);
|
||||
Object.addDeclarationFile(builder, declarationFileOffset);
|
||||
Object.addDocumentation(builder, documentationOffset);
|
||||
Object.addAttributes(builder, attributesOffset);
|
||||
Object.addBytesize(builder, bytesize);
|
||||
Object.addMinalign(builder, minalign);
|
||||
Object.addFields(builder, fieldsOffset);
|
||||
Object.addName(builder, nameOffset);
|
||||
Object.addIsStruct(builder, isStruct);
|
||||
return Object.endObject(builder);
|
||||
}
|
||||
|
||||
public static void startObject(FlatBufferBuilder builder) { builder.startTable(8); }
|
||||
public static void addName(FlatBufferBuilder builder, int nameOffset) { builder.addOffset(nameOffset); builder.slot(0); }
|
||||
public static void addFields(FlatBufferBuilder builder, int fieldsOffset) { builder.addOffset(1, fieldsOffset, 0); }
|
||||
public static int createFieldsVector(FlatBufferBuilder builder, int[] data) { builder.startVector(4, data.length, 4); for (int i = data.length - 1; i >= 0; i--) builder.addOffset(data[i]); return builder.endVector(); }
|
||||
public static void startFieldsVector(FlatBufferBuilder builder, int numElems) { builder.startVector(4, numElems, 4); }
|
||||
public static void addIsStruct(FlatBufferBuilder builder, boolean isStruct) { builder.addBoolean(2, isStruct, false); }
|
||||
public static void addMinalign(FlatBufferBuilder builder, int minalign) { builder.addInt(3, minalign, 0); }
|
||||
public static void addBytesize(FlatBufferBuilder builder, int bytesize) { builder.addInt(4, bytesize, 0); }
|
||||
public static void addAttributes(FlatBufferBuilder builder, int attributesOffset) { builder.addOffset(5, attributesOffset, 0); }
|
||||
public static int createAttributesVector(FlatBufferBuilder builder, int[] data) { builder.startVector(4, data.length, 4); for (int i = data.length - 1; i >= 0; i--) builder.addOffset(data[i]); return builder.endVector(); }
|
||||
public static void startAttributesVector(FlatBufferBuilder builder, int numElems) { builder.startVector(4, numElems, 4); }
|
||||
public static void addDocumentation(FlatBufferBuilder builder, int documentationOffset) { builder.addOffset(6, documentationOffset, 0); }
|
||||
public static int createDocumentationVector(FlatBufferBuilder builder, int[] data) { builder.startVector(4, data.length, 4); for (int i = data.length - 1; i >= 0; i--) builder.addOffset(data[i]); return builder.endVector(); }
|
||||
public static void startDocumentationVector(FlatBufferBuilder builder, int numElems) { builder.startVector(4, numElems, 4); }
|
||||
public static void addDeclarationFile(FlatBufferBuilder builder, int declarationFileOffset) { builder.addOffset(7, declarationFileOffset, 0); }
|
||||
public static int endObject(FlatBufferBuilder builder) {
|
||||
int o = builder.endTable();
|
||||
builder.required(o, 4); // name
|
||||
builder.required(o, 6); // fields
|
||||
return o;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int keysCompare(Integer o1, Integer o2, ByteBuffer _bb) { return compareStrings(__offset(4, o1, _bb), __offset(4, o2, _bb), _bb); }
|
||||
|
||||
public static Object __lookup_by_key(Object obj, int vectorLocation, String key, ByteBuffer bb) {
|
||||
byte[] byteKey = key.getBytes(java.nio.charset.StandardCharsets.UTF_8);
|
||||
int span = bb.getInt(vectorLocation - 4);
|
||||
int start = 0;
|
||||
while (span != 0) {
|
||||
int middle = span / 2;
|
||||
int tableOffset = __indirect(vectorLocation + 4 * (start + middle), bb);
|
||||
int comp = compareStrings(__offset(4, bb.capacity() - tableOffset, bb), byteKey, bb);
|
||||
if (comp > 0) {
|
||||
span = middle;
|
||||
} else if (comp < 0) {
|
||||
middle++;
|
||||
start += middle;
|
||||
span -= middle;
|
||||
} else {
|
||||
return (obj == null ? new Object() : obj).__assign(tableOffset, bb);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static final class Vector extends BaseVector {
|
||||
public Vector __assign(int _vector, int _element_size, ByteBuffer _bb) { __reset(_vector, _element_size, _bb); return this; }
|
||||
|
||||
public Object get(int j) { return get(new Object(), j); }
|
||||
public Object get(Object obj, int j) { return obj.__assign(__indirect(__element(j), bb), bb); }
|
||||
public Object getByKey(String key) { return __lookup_by_key(null, __vector(), key, bb); }
|
||||
public Object getByKey(Object obj, String key) { return __lookup_by_key(obj, __vector(), key, bb); }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,115 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
package com.google.flatbuffers.reflection;
|
||||
|
||||
import com.google.flatbuffers.BaseVector;
|
||||
import com.google.flatbuffers.BooleanVector;
|
||||
import com.google.flatbuffers.ByteVector;
|
||||
import com.google.flatbuffers.Constants;
|
||||
import com.google.flatbuffers.DoubleVector;
|
||||
import com.google.flatbuffers.FlatBufferBuilder;
|
||||
import com.google.flatbuffers.FloatVector;
|
||||
import com.google.flatbuffers.IntVector;
|
||||
import com.google.flatbuffers.LongVector;
|
||||
import com.google.flatbuffers.ShortVector;
|
||||
import com.google.flatbuffers.StringVector;
|
||||
import com.google.flatbuffers.Struct;
|
||||
import com.google.flatbuffers.Table;
|
||||
import com.google.flatbuffers.UnionVector;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public final class RPCCall extends Table {
|
||||
public static void ValidateVersion() { Constants.FLATBUFFERS_23_3_3(); }
|
||||
public static RPCCall getRootAsRPCCall(ByteBuffer _bb) { return getRootAsRPCCall(_bb, new RPCCall()); }
|
||||
public static RPCCall getRootAsRPCCall(ByteBuffer _bb, RPCCall obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
|
||||
public void __init(int _i, ByteBuffer _bb) { __reset(_i, _bb); }
|
||||
public RPCCall __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }
|
||||
|
||||
public String name() { int o = __offset(4); return o != 0 ? __string(o + bb_pos) : null; }
|
||||
public ByteBuffer nameAsByteBuffer() { return __vector_as_bytebuffer(4, 1); }
|
||||
public ByteBuffer nameInByteBuffer(ByteBuffer _bb) { return __vector_in_bytebuffer(_bb, 4, 1); }
|
||||
public com.google.flatbuffers.reflection.Object request() { return request(new com.google.flatbuffers.reflection.Object()); }
|
||||
public com.google.flatbuffers.reflection.Object request(com.google.flatbuffers.reflection.Object obj) { int o = __offset(6); return o != 0 ? obj.__assign(__indirect(o + bb_pos), bb) : null; }
|
||||
public com.google.flatbuffers.reflection.Object response() { return response(new com.google.flatbuffers.reflection.Object()); }
|
||||
public com.google.flatbuffers.reflection.Object response(com.google.flatbuffers.reflection.Object obj) { int o = __offset(8); return o != 0 ? obj.__assign(__indirect(o + bb_pos), bb) : null; }
|
||||
public com.google.flatbuffers.reflection.KeyValue attributes(int j) { return attributes(new com.google.flatbuffers.reflection.KeyValue(), j); }
|
||||
public com.google.flatbuffers.reflection.KeyValue attributes(com.google.flatbuffers.reflection.KeyValue obj, int j) { int o = __offset(10); return o != 0 ? obj.__assign(__indirect(__vector(o) + j * 4), bb) : null; }
|
||||
public int attributesLength() { int o = __offset(10); return o != 0 ? __vector_len(o) : 0; }
|
||||
public com.google.flatbuffers.reflection.KeyValue attributesByKey(String key) { int o = __offset(10); return o != 0 ? com.google.flatbuffers.reflection.KeyValue.__lookup_by_key(null, __vector(o), key, bb) : null; }
|
||||
public com.google.flatbuffers.reflection.KeyValue attributesByKey(com.google.flatbuffers.reflection.KeyValue obj, String key) { int o = __offset(10); return o != 0 ? com.google.flatbuffers.reflection.KeyValue.__lookup_by_key(obj, __vector(o), key, bb) : null; }
|
||||
public com.google.flatbuffers.reflection.KeyValue.Vector attributesVector() { return attributesVector(new com.google.flatbuffers.reflection.KeyValue.Vector()); }
|
||||
public com.google.flatbuffers.reflection.KeyValue.Vector attributesVector(com.google.flatbuffers.reflection.KeyValue.Vector obj) { int o = __offset(10); return o != 0 ? obj.__assign(__vector(o), 4, bb) : null; }
|
||||
public String documentation(int j) { int o = __offset(12); return o != 0 ? __string(__vector(o) + j * 4) : null; }
|
||||
public int documentationLength() { int o = __offset(12); return o != 0 ? __vector_len(o) : 0; }
|
||||
public StringVector documentationVector() { return documentationVector(new StringVector()); }
|
||||
public StringVector documentationVector(StringVector obj) { int o = __offset(12); return o != 0 ? obj.__assign(__vector(o), 4, bb) : null; }
|
||||
|
||||
public static int createRPCCall(FlatBufferBuilder builder,
|
||||
int nameOffset,
|
||||
int requestOffset,
|
||||
int responseOffset,
|
||||
int attributesOffset,
|
||||
int documentationOffset) {
|
||||
builder.startTable(5);
|
||||
RPCCall.addDocumentation(builder, documentationOffset);
|
||||
RPCCall.addAttributes(builder, attributesOffset);
|
||||
RPCCall.addResponse(builder, responseOffset);
|
||||
RPCCall.addRequest(builder, requestOffset);
|
||||
RPCCall.addName(builder, nameOffset);
|
||||
return RPCCall.endRPCCall(builder);
|
||||
}
|
||||
|
||||
public static void startRPCCall(FlatBufferBuilder builder) { builder.startTable(5); }
|
||||
public static void addName(FlatBufferBuilder builder, int nameOffset) { builder.addOffset(nameOffset); builder.slot(0); }
|
||||
public static void addRequest(FlatBufferBuilder builder, int requestOffset) { builder.addOffset(1, requestOffset, 0); }
|
||||
public static void addResponse(FlatBufferBuilder builder, int responseOffset) { builder.addOffset(2, responseOffset, 0); }
|
||||
public static void addAttributes(FlatBufferBuilder builder, int attributesOffset) { builder.addOffset(3, attributesOffset, 0); }
|
||||
public static int createAttributesVector(FlatBufferBuilder builder, int[] data) { builder.startVector(4, data.length, 4); for (int i = data.length - 1; i >= 0; i--) builder.addOffset(data[i]); return builder.endVector(); }
|
||||
public static void startAttributesVector(FlatBufferBuilder builder, int numElems) { builder.startVector(4, numElems, 4); }
|
||||
public static void addDocumentation(FlatBufferBuilder builder, int documentationOffset) { builder.addOffset(4, documentationOffset, 0); }
|
||||
public static int createDocumentationVector(FlatBufferBuilder builder, int[] data) { builder.startVector(4, data.length, 4); for (int i = data.length - 1; i >= 0; i--) builder.addOffset(data[i]); return builder.endVector(); }
|
||||
public static void startDocumentationVector(FlatBufferBuilder builder, int numElems) { builder.startVector(4, numElems, 4); }
|
||||
public static int endRPCCall(FlatBufferBuilder builder) {
|
||||
int o = builder.endTable();
|
||||
builder.required(o, 4); // name
|
||||
builder.required(o, 6); // request
|
||||
builder.required(o, 8); // response
|
||||
return o;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int keysCompare(Integer o1, Integer o2, ByteBuffer _bb) { return compareStrings(__offset(4, o1, _bb), __offset(4, o2, _bb), _bb); }
|
||||
|
||||
public static RPCCall __lookup_by_key(RPCCall obj, int vectorLocation, String key, ByteBuffer bb) {
|
||||
byte[] byteKey = key.getBytes(java.nio.charset.StandardCharsets.UTF_8);
|
||||
int span = bb.getInt(vectorLocation - 4);
|
||||
int start = 0;
|
||||
while (span != 0) {
|
||||
int middle = span / 2;
|
||||
int tableOffset = __indirect(vectorLocation + 4 * (start + middle), bb);
|
||||
int comp = compareStrings(__offset(4, bb.capacity() - tableOffset, bb), byteKey, bb);
|
||||
if (comp > 0) {
|
||||
span = middle;
|
||||
} else if (comp < 0) {
|
||||
middle++;
|
||||
start += middle;
|
||||
span -= middle;
|
||||
} else {
|
||||
return (obj == null ? new RPCCall() : obj).__assign(tableOffset, bb);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static final class Vector extends BaseVector {
|
||||
public Vector __assign(int _vector, int _element_size, ByteBuffer _bb) { __reset(_vector, _element_size, _bb); return this; }
|
||||
|
||||
public RPCCall get(int j) { return get(new RPCCall(), j); }
|
||||
public RPCCall get(RPCCall obj, int j) { return obj.__assign(__indirect(__element(j), bb), bb); }
|
||||
public RPCCall getByKey(String key) { return __lookup_by_key(null, __vector(), key, bb); }
|
||||
public RPCCall getByKey(RPCCall obj, String key) { return __lookup_by_key(obj, __vector(), key, bb); }
|
||||
}
|
||||
}
|
||||
|
||||
127
java/src/main/java/com/google/flatbuffers/reflection/Schema.java
Normal file
127
java/src/main/java/com/google/flatbuffers/reflection/Schema.java
Normal file
@@ -0,0 +1,127 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
package com.google.flatbuffers.reflection;
|
||||
|
||||
import com.google.flatbuffers.BaseVector;
|
||||
import com.google.flatbuffers.BooleanVector;
|
||||
import com.google.flatbuffers.ByteVector;
|
||||
import com.google.flatbuffers.Constants;
|
||||
import com.google.flatbuffers.DoubleVector;
|
||||
import com.google.flatbuffers.FlatBufferBuilder;
|
||||
import com.google.flatbuffers.FloatVector;
|
||||
import com.google.flatbuffers.IntVector;
|
||||
import com.google.flatbuffers.LongVector;
|
||||
import com.google.flatbuffers.ShortVector;
|
||||
import com.google.flatbuffers.StringVector;
|
||||
import com.google.flatbuffers.Struct;
|
||||
import com.google.flatbuffers.Table;
|
||||
import com.google.flatbuffers.UnionVector;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public final class Schema extends Table {
|
||||
public static void ValidateVersion() { Constants.FLATBUFFERS_23_3_3(); }
|
||||
public static Schema getRootAsSchema(ByteBuffer _bb) { return getRootAsSchema(_bb, new Schema()); }
|
||||
public static Schema getRootAsSchema(ByteBuffer _bb, Schema obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
|
||||
public static boolean SchemaBufferHasIdentifier(ByteBuffer _bb) { return __has_identifier(_bb, "BFBS"); }
|
||||
public void __init(int _i, ByteBuffer _bb) { __reset(_i, _bb); }
|
||||
public Schema __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }
|
||||
|
||||
public com.google.flatbuffers.reflection.Object objects(int j) { return objects(new com.google.flatbuffers.reflection.Object(), j); }
|
||||
public com.google.flatbuffers.reflection.Object objects(com.google.flatbuffers.reflection.Object obj, int j) { int o = __offset(4); return o != 0 ? obj.__assign(__indirect(__vector(o) + j * 4), bb) : null; }
|
||||
public int objectsLength() { int o = __offset(4); return o != 0 ? __vector_len(o) : 0; }
|
||||
public com.google.flatbuffers.reflection.Object objectsByKey(String key) { int o = __offset(4); return o != 0 ? com.google.flatbuffers.reflection.Object.__lookup_by_key(null, __vector(o), key, bb) : null; }
|
||||
public com.google.flatbuffers.reflection.Object objectsByKey(com.google.flatbuffers.reflection.Object obj, String key) { int o = __offset(4); return o != 0 ? com.google.flatbuffers.reflection.Object.__lookup_by_key(obj, __vector(o), key, bb) : null; }
|
||||
public com.google.flatbuffers.reflection.Object.Vector objectsVector() { return objectsVector(new com.google.flatbuffers.reflection.Object.Vector()); }
|
||||
public com.google.flatbuffers.reflection.Object.Vector objectsVector(com.google.flatbuffers.reflection.Object.Vector obj) { int o = __offset(4); return o != 0 ? obj.__assign(__vector(o), 4, bb) : null; }
|
||||
public com.google.flatbuffers.reflection.Enum enums(int j) { return enums(new com.google.flatbuffers.reflection.Enum(), j); }
|
||||
public com.google.flatbuffers.reflection.Enum enums(com.google.flatbuffers.reflection.Enum obj, int j) { int o = __offset(6); return o != 0 ? obj.__assign(__indirect(__vector(o) + j * 4), bb) : null; }
|
||||
public int enumsLength() { int o = __offset(6); return o != 0 ? __vector_len(o) : 0; }
|
||||
public com.google.flatbuffers.reflection.Enum enumsByKey(String key) { int o = __offset(6); return o != 0 ? com.google.flatbuffers.reflection.Enum.__lookup_by_key(null, __vector(o), key, bb) : null; }
|
||||
public com.google.flatbuffers.reflection.Enum enumsByKey(com.google.flatbuffers.reflection.Enum obj, String key) { int o = __offset(6); return o != 0 ? com.google.flatbuffers.reflection.Enum.__lookup_by_key(obj, __vector(o), key, bb) : null; }
|
||||
public com.google.flatbuffers.reflection.Enum.Vector enumsVector() { return enumsVector(new com.google.flatbuffers.reflection.Enum.Vector()); }
|
||||
public com.google.flatbuffers.reflection.Enum.Vector enumsVector(com.google.flatbuffers.reflection.Enum.Vector obj) { int o = __offset(6); return o != 0 ? obj.__assign(__vector(o), 4, bb) : null; }
|
||||
public String fileIdent() { int o = __offset(8); return o != 0 ? __string(o + bb_pos) : null; }
|
||||
public ByteBuffer fileIdentAsByteBuffer() { return __vector_as_bytebuffer(8, 1); }
|
||||
public ByteBuffer fileIdentInByteBuffer(ByteBuffer _bb) { return __vector_in_bytebuffer(_bb, 8, 1); }
|
||||
public String fileExt() { int o = __offset(10); return o != 0 ? __string(o + bb_pos) : null; }
|
||||
public ByteBuffer fileExtAsByteBuffer() { return __vector_as_bytebuffer(10, 1); }
|
||||
public ByteBuffer fileExtInByteBuffer(ByteBuffer _bb) { return __vector_in_bytebuffer(_bb, 10, 1); }
|
||||
public com.google.flatbuffers.reflection.Object rootTable() { return rootTable(new com.google.flatbuffers.reflection.Object()); }
|
||||
public com.google.flatbuffers.reflection.Object rootTable(com.google.flatbuffers.reflection.Object obj) { int o = __offset(12); return o != 0 ? obj.__assign(__indirect(o + bb_pos), bb) : null; }
|
||||
public com.google.flatbuffers.reflection.Service services(int j) { return services(new com.google.flatbuffers.reflection.Service(), j); }
|
||||
public com.google.flatbuffers.reflection.Service services(com.google.flatbuffers.reflection.Service obj, int j) { int o = __offset(14); return o != 0 ? obj.__assign(__indirect(__vector(o) + j * 4), bb) : null; }
|
||||
public int servicesLength() { int o = __offset(14); return o != 0 ? __vector_len(o) : 0; }
|
||||
public com.google.flatbuffers.reflection.Service servicesByKey(String key) { int o = __offset(14); return o != 0 ? com.google.flatbuffers.reflection.Service.__lookup_by_key(null, __vector(o), key, bb) : null; }
|
||||
public com.google.flatbuffers.reflection.Service servicesByKey(com.google.flatbuffers.reflection.Service obj, String key) { int o = __offset(14); return o != 0 ? com.google.flatbuffers.reflection.Service.__lookup_by_key(obj, __vector(o), key, bb) : null; }
|
||||
public com.google.flatbuffers.reflection.Service.Vector servicesVector() { return servicesVector(new com.google.flatbuffers.reflection.Service.Vector()); }
|
||||
public com.google.flatbuffers.reflection.Service.Vector servicesVector(com.google.flatbuffers.reflection.Service.Vector obj) { int o = __offset(14); return o != 0 ? obj.__assign(__vector(o), 4, bb) : null; }
|
||||
public long advancedFeatures() { int o = __offset(16); return o != 0 ? bb.getLong(o + bb_pos) : 0L; }
|
||||
/**
|
||||
* All the files used in this compilation. Files are relative to where
|
||||
* flatc was invoked.
|
||||
*/
|
||||
public com.google.flatbuffers.reflection.SchemaFile fbsFiles(int j) { return fbsFiles(new com.google.flatbuffers.reflection.SchemaFile(), j); }
|
||||
public com.google.flatbuffers.reflection.SchemaFile fbsFiles(com.google.flatbuffers.reflection.SchemaFile obj, int j) { int o = __offset(18); return o != 0 ? obj.__assign(__indirect(__vector(o) + j * 4), bb) : null; }
|
||||
public int fbsFilesLength() { int o = __offset(18); return o != 0 ? __vector_len(o) : 0; }
|
||||
public com.google.flatbuffers.reflection.SchemaFile fbsFilesByKey(String key) { int o = __offset(18); return o != 0 ? com.google.flatbuffers.reflection.SchemaFile.__lookup_by_key(null, __vector(o), key, bb) : null; }
|
||||
public com.google.flatbuffers.reflection.SchemaFile fbsFilesByKey(com.google.flatbuffers.reflection.SchemaFile obj, String key) { int o = __offset(18); return o != 0 ? com.google.flatbuffers.reflection.SchemaFile.__lookup_by_key(obj, __vector(o), key, bb) : null; }
|
||||
public com.google.flatbuffers.reflection.SchemaFile.Vector fbsFilesVector() { return fbsFilesVector(new com.google.flatbuffers.reflection.SchemaFile.Vector()); }
|
||||
public com.google.flatbuffers.reflection.SchemaFile.Vector fbsFilesVector(com.google.flatbuffers.reflection.SchemaFile.Vector obj) { int o = __offset(18); return o != 0 ? obj.__assign(__vector(o), 4, bb) : null; }
|
||||
|
||||
public static int createSchema(FlatBufferBuilder builder,
|
||||
int objectsOffset,
|
||||
int enumsOffset,
|
||||
int fileIdentOffset,
|
||||
int fileExtOffset,
|
||||
int rootTableOffset,
|
||||
int servicesOffset,
|
||||
long advancedFeatures,
|
||||
int fbsFilesOffset) {
|
||||
builder.startTable(8);
|
||||
Schema.addAdvancedFeatures(builder, advancedFeatures);
|
||||
Schema.addFbsFiles(builder, fbsFilesOffset);
|
||||
Schema.addServices(builder, servicesOffset);
|
||||
Schema.addRootTable(builder, rootTableOffset);
|
||||
Schema.addFileExt(builder, fileExtOffset);
|
||||
Schema.addFileIdent(builder, fileIdentOffset);
|
||||
Schema.addEnums(builder, enumsOffset);
|
||||
Schema.addObjects(builder, objectsOffset);
|
||||
return Schema.endSchema(builder);
|
||||
}
|
||||
|
||||
public static void startSchema(FlatBufferBuilder builder) { builder.startTable(8); }
|
||||
public static void addObjects(FlatBufferBuilder builder, int objectsOffset) { builder.addOffset(0, objectsOffset, 0); }
|
||||
public static int createObjectsVector(FlatBufferBuilder builder, int[] data) { builder.startVector(4, data.length, 4); for (int i = data.length - 1; i >= 0; i--) builder.addOffset(data[i]); return builder.endVector(); }
|
||||
public static void startObjectsVector(FlatBufferBuilder builder, int numElems) { builder.startVector(4, numElems, 4); }
|
||||
public static void addEnums(FlatBufferBuilder builder, int enumsOffset) { builder.addOffset(1, enumsOffset, 0); }
|
||||
public static int createEnumsVector(FlatBufferBuilder builder, int[] data) { builder.startVector(4, data.length, 4); for (int i = data.length - 1; i >= 0; i--) builder.addOffset(data[i]); return builder.endVector(); }
|
||||
public static void startEnumsVector(FlatBufferBuilder builder, int numElems) { builder.startVector(4, numElems, 4); }
|
||||
public static void addFileIdent(FlatBufferBuilder builder, int fileIdentOffset) { builder.addOffset(2, fileIdentOffset, 0); }
|
||||
public static void addFileExt(FlatBufferBuilder builder, int fileExtOffset) { builder.addOffset(3, fileExtOffset, 0); }
|
||||
public static void addRootTable(FlatBufferBuilder builder, int rootTableOffset) { builder.addOffset(4, rootTableOffset, 0); }
|
||||
public static void addServices(FlatBufferBuilder builder, int servicesOffset) { builder.addOffset(5, servicesOffset, 0); }
|
||||
public static int createServicesVector(FlatBufferBuilder builder, int[] data) { builder.startVector(4, data.length, 4); for (int i = data.length - 1; i >= 0; i--) builder.addOffset(data[i]); return builder.endVector(); }
|
||||
public static void startServicesVector(FlatBufferBuilder builder, int numElems) { builder.startVector(4, numElems, 4); }
|
||||
public static void addAdvancedFeatures(FlatBufferBuilder builder, long advancedFeatures) { builder.addLong(6, advancedFeatures, 0L); }
|
||||
public static void addFbsFiles(FlatBufferBuilder builder, int fbsFilesOffset) { builder.addOffset(7, fbsFilesOffset, 0); }
|
||||
public static int createFbsFilesVector(FlatBufferBuilder builder, int[] data) { builder.startVector(4, data.length, 4); for (int i = data.length - 1; i >= 0; i--) builder.addOffset(data[i]); return builder.endVector(); }
|
||||
public static void startFbsFilesVector(FlatBufferBuilder builder, int numElems) { builder.startVector(4, numElems, 4); }
|
||||
public static int endSchema(FlatBufferBuilder builder) {
|
||||
int o = builder.endTable();
|
||||
builder.required(o, 4); // objects
|
||||
builder.required(o, 6); // enums
|
||||
return o;
|
||||
}
|
||||
public static void finishSchemaBuffer(FlatBufferBuilder builder, int offset) { builder.finish(offset, "BFBS"); }
|
||||
public static void finishSizePrefixedSchemaBuffer(FlatBufferBuilder builder, int offset) { builder.finishSizePrefixed(offset, "BFBS"); }
|
||||
|
||||
public static final class Vector extends BaseVector {
|
||||
public Vector __assign(int _vector, int _element_size, ByteBuffer _bb) { __reset(_vector, _element_size, _bb); return this; }
|
||||
|
||||
public Schema get(int j) { return get(new Schema(), j); }
|
||||
public Schema get(Schema obj, int j) { return obj.__assign(__indirect(__element(j), bb), bb); }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,102 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
package com.google.flatbuffers.reflection;
|
||||
|
||||
import com.google.flatbuffers.BaseVector;
|
||||
import com.google.flatbuffers.BooleanVector;
|
||||
import com.google.flatbuffers.ByteVector;
|
||||
import com.google.flatbuffers.Constants;
|
||||
import com.google.flatbuffers.DoubleVector;
|
||||
import com.google.flatbuffers.FlatBufferBuilder;
|
||||
import com.google.flatbuffers.FloatVector;
|
||||
import com.google.flatbuffers.IntVector;
|
||||
import com.google.flatbuffers.LongVector;
|
||||
import com.google.flatbuffers.ShortVector;
|
||||
import com.google.flatbuffers.StringVector;
|
||||
import com.google.flatbuffers.Struct;
|
||||
import com.google.flatbuffers.Table;
|
||||
import com.google.flatbuffers.UnionVector;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
/**
|
||||
* File specific information.
|
||||
* Symbols declared within a file may be recovered by iterating over all
|
||||
* symbols and examining the `declaration_file` field.
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public final class SchemaFile extends Table {
|
||||
public static void ValidateVersion() { Constants.FLATBUFFERS_23_3_3(); }
|
||||
public static SchemaFile getRootAsSchemaFile(ByteBuffer _bb) { return getRootAsSchemaFile(_bb, new SchemaFile()); }
|
||||
public static SchemaFile getRootAsSchemaFile(ByteBuffer _bb, SchemaFile obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
|
||||
public void __init(int _i, ByteBuffer _bb) { __reset(_i, _bb); }
|
||||
public SchemaFile __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }
|
||||
|
||||
/**
|
||||
* Filename, relative to project root.
|
||||
*/
|
||||
public String filename() { int o = __offset(4); return o != 0 ? __string(o + bb_pos) : null; }
|
||||
public ByteBuffer filenameAsByteBuffer() { return __vector_as_bytebuffer(4, 1); }
|
||||
public ByteBuffer filenameInByteBuffer(ByteBuffer _bb) { return __vector_in_bytebuffer(_bb, 4, 1); }
|
||||
/**
|
||||
* Names of included files, relative to project root.
|
||||
*/
|
||||
public String includedFilenames(int j) { int o = __offset(6); return o != 0 ? __string(__vector(o) + j * 4) : null; }
|
||||
public int includedFilenamesLength() { int o = __offset(6); return o != 0 ? __vector_len(o) : 0; }
|
||||
public StringVector includedFilenamesVector() { return includedFilenamesVector(new StringVector()); }
|
||||
public StringVector includedFilenamesVector(StringVector obj) { int o = __offset(6); return o != 0 ? obj.__assign(__vector(o), 4, bb) : null; }
|
||||
|
||||
public static int createSchemaFile(FlatBufferBuilder builder,
|
||||
int filenameOffset,
|
||||
int includedFilenamesOffset) {
|
||||
builder.startTable(2);
|
||||
SchemaFile.addIncludedFilenames(builder, includedFilenamesOffset);
|
||||
SchemaFile.addFilename(builder, filenameOffset);
|
||||
return SchemaFile.endSchemaFile(builder);
|
||||
}
|
||||
|
||||
public static void startSchemaFile(FlatBufferBuilder builder) { builder.startTable(2); }
|
||||
public static void addFilename(FlatBufferBuilder builder, int filenameOffset) { builder.addOffset(filenameOffset); builder.slot(0); }
|
||||
public static void addIncludedFilenames(FlatBufferBuilder builder, int includedFilenamesOffset) { builder.addOffset(1, includedFilenamesOffset, 0); }
|
||||
public static int createIncludedFilenamesVector(FlatBufferBuilder builder, int[] data) { builder.startVector(4, data.length, 4); for (int i = data.length - 1; i >= 0; i--) builder.addOffset(data[i]); return builder.endVector(); }
|
||||
public static void startIncludedFilenamesVector(FlatBufferBuilder builder, int numElems) { builder.startVector(4, numElems, 4); }
|
||||
public static int endSchemaFile(FlatBufferBuilder builder) {
|
||||
int o = builder.endTable();
|
||||
builder.required(o, 4); // filename
|
||||
return o;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int keysCompare(Integer o1, Integer o2, ByteBuffer _bb) { return compareStrings(__offset(4, o1, _bb), __offset(4, o2, _bb), _bb); }
|
||||
|
||||
public static SchemaFile __lookup_by_key(SchemaFile obj, int vectorLocation, String key, ByteBuffer bb) {
|
||||
byte[] byteKey = key.getBytes(java.nio.charset.StandardCharsets.UTF_8);
|
||||
int span = bb.getInt(vectorLocation - 4);
|
||||
int start = 0;
|
||||
while (span != 0) {
|
||||
int middle = span / 2;
|
||||
int tableOffset = __indirect(vectorLocation + 4 * (start + middle), bb);
|
||||
int comp = compareStrings(__offset(4, bb.capacity() - tableOffset, bb), byteKey, bb);
|
||||
if (comp > 0) {
|
||||
span = middle;
|
||||
} else if (comp < 0) {
|
||||
middle++;
|
||||
start += middle;
|
||||
span -= middle;
|
||||
} else {
|
||||
return (obj == null ? new SchemaFile() : obj).__assign(tableOffset, bb);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static final class Vector extends BaseVector {
|
||||
public Vector __assign(int _vector, int _element_size, ByteBuffer _bb) { __reset(_vector, _element_size, _bb); return this; }
|
||||
|
||||
public SchemaFile get(int j) { return get(new SchemaFile(), j); }
|
||||
public SchemaFile get(SchemaFile obj, int j) { return obj.__assign(__indirect(__element(j), bb), bb); }
|
||||
public SchemaFile getByKey(String key) { return __lookup_by_key(null, __vector(), key, bb); }
|
||||
public SchemaFile getByKey(SchemaFile obj, String key) { return __lookup_by_key(obj, __vector(), key, bb); }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,124 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
package com.google.flatbuffers.reflection;
|
||||
|
||||
import com.google.flatbuffers.BaseVector;
|
||||
import com.google.flatbuffers.BooleanVector;
|
||||
import com.google.flatbuffers.ByteVector;
|
||||
import com.google.flatbuffers.Constants;
|
||||
import com.google.flatbuffers.DoubleVector;
|
||||
import com.google.flatbuffers.FlatBufferBuilder;
|
||||
import com.google.flatbuffers.FloatVector;
|
||||
import com.google.flatbuffers.IntVector;
|
||||
import com.google.flatbuffers.LongVector;
|
||||
import com.google.flatbuffers.ShortVector;
|
||||
import com.google.flatbuffers.StringVector;
|
||||
import com.google.flatbuffers.Struct;
|
||||
import com.google.flatbuffers.Table;
|
||||
import com.google.flatbuffers.UnionVector;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public final class Service extends Table {
|
||||
public static void ValidateVersion() { Constants.FLATBUFFERS_23_3_3(); }
|
||||
public static Service getRootAsService(ByteBuffer _bb) { return getRootAsService(_bb, new Service()); }
|
||||
public static Service getRootAsService(ByteBuffer _bb, Service obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
|
||||
public void __init(int _i, ByteBuffer _bb) { __reset(_i, _bb); }
|
||||
public Service __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }
|
||||
|
||||
public String name() { int o = __offset(4); return o != 0 ? __string(o + bb_pos) : null; }
|
||||
public ByteBuffer nameAsByteBuffer() { return __vector_as_bytebuffer(4, 1); }
|
||||
public ByteBuffer nameInByteBuffer(ByteBuffer _bb) { return __vector_in_bytebuffer(_bb, 4, 1); }
|
||||
public com.google.flatbuffers.reflection.RPCCall calls(int j) { return calls(new com.google.flatbuffers.reflection.RPCCall(), j); }
|
||||
public com.google.flatbuffers.reflection.RPCCall calls(com.google.flatbuffers.reflection.RPCCall obj, int j) { int o = __offset(6); return o != 0 ? obj.__assign(__indirect(__vector(o) + j * 4), bb) : null; }
|
||||
public int callsLength() { int o = __offset(6); return o != 0 ? __vector_len(o) : 0; }
|
||||
public com.google.flatbuffers.reflection.RPCCall callsByKey(String key) { int o = __offset(6); return o != 0 ? com.google.flatbuffers.reflection.RPCCall.__lookup_by_key(null, __vector(o), key, bb) : null; }
|
||||
public com.google.flatbuffers.reflection.RPCCall callsByKey(com.google.flatbuffers.reflection.RPCCall obj, String key) { int o = __offset(6); return o != 0 ? com.google.flatbuffers.reflection.RPCCall.__lookup_by_key(obj, __vector(o), key, bb) : null; }
|
||||
public com.google.flatbuffers.reflection.RPCCall.Vector callsVector() { return callsVector(new com.google.flatbuffers.reflection.RPCCall.Vector()); }
|
||||
public com.google.flatbuffers.reflection.RPCCall.Vector callsVector(com.google.flatbuffers.reflection.RPCCall.Vector obj) { int o = __offset(6); return o != 0 ? obj.__assign(__vector(o), 4, bb) : null; }
|
||||
public com.google.flatbuffers.reflection.KeyValue attributes(int j) { return attributes(new com.google.flatbuffers.reflection.KeyValue(), j); }
|
||||
public com.google.flatbuffers.reflection.KeyValue attributes(com.google.flatbuffers.reflection.KeyValue obj, int j) { int o = __offset(8); return o != 0 ? obj.__assign(__indirect(__vector(o) + j * 4), bb) : null; }
|
||||
public int attributesLength() { int o = __offset(8); return o != 0 ? __vector_len(o) : 0; }
|
||||
public com.google.flatbuffers.reflection.KeyValue attributesByKey(String key) { int o = __offset(8); return o != 0 ? com.google.flatbuffers.reflection.KeyValue.__lookup_by_key(null, __vector(o), key, bb) : null; }
|
||||
public com.google.flatbuffers.reflection.KeyValue attributesByKey(com.google.flatbuffers.reflection.KeyValue obj, String key) { int o = __offset(8); return o != 0 ? com.google.flatbuffers.reflection.KeyValue.__lookup_by_key(obj, __vector(o), key, bb) : null; }
|
||||
public com.google.flatbuffers.reflection.KeyValue.Vector attributesVector() { return attributesVector(new com.google.flatbuffers.reflection.KeyValue.Vector()); }
|
||||
public com.google.flatbuffers.reflection.KeyValue.Vector attributesVector(com.google.flatbuffers.reflection.KeyValue.Vector obj) { int o = __offset(8); return o != 0 ? obj.__assign(__vector(o), 4, bb) : null; }
|
||||
public String documentation(int j) { int o = __offset(10); return o != 0 ? __string(__vector(o) + j * 4) : null; }
|
||||
public int documentationLength() { int o = __offset(10); return o != 0 ? __vector_len(o) : 0; }
|
||||
public StringVector documentationVector() { return documentationVector(new StringVector()); }
|
||||
public StringVector documentationVector(StringVector obj) { int o = __offset(10); return o != 0 ? obj.__assign(__vector(o), 4, bb) : null; }
|
||||
/**
|
||||
* File that this Service is declared in.
|
||||
*/
|
||||
public String declarationFile() { int o = __offset(12); return o != 0 ? __string(o + bb_pos) : null; }
|
||||
public ByteBuffer declarationFileAsByteBuffer() { return __vector_as_bytebuffer(12, 1); }
|
||||
public ByteBuffer declarationFileInByteBuffer(ByteBuffer _bb) { return __vector_in_bytebuffer(_bb, 12, 1); }
|
||||
|
||||
public static int createService(FlatBufferBuilder builder,
|
||||
int nameOffset,
|
||||
int callsOffset,
|
||||
int attributesOffset,
|
||||
int documentationOffset,
|
||||
int declarationFileOffset) {
|
||||
builder.startTable(5);
|
||||
Service.addDeclarationFile(builder, declarationFileOffset);
|
||||
Service.addDocumentation(builder, documentationOffset);
|
||||
Service.addAttributes(builder, attributesOffset);
|
||||
Service.addCalls(builder, callsOffset);
|
||||
Service.addName(builder, nameOffset);
|
||||
return Service.endService(builder);
|
||||
}
|
||||
|
||||
public static void startService(FlatBufferBuilder builder) { builder.startTable(5); }
|
||||
public static void addName(FlatBufferBuilder builder, int nameOffset) { builder.addOffset(nameOffset); builder.slot(0); }
|
||||
public static void addCalls(FlatBufferBuilder builder, int callsOffset) { builder.addOffset(1, callsOffset, 0); }
|
||||
public static int createCallsVector(FlatBufferBuilder builder, int[] data) { builder.startVector(4, data.length, 4); for (int i = data.length - 1; i >= 0; i--) builder.addOffset(data[i]); return builder.endVector(); }
|
||||
public static void startCallsVector(FlatBufferBuilder builder, int numElems) { builder.startVector(4, numElems, 4); }
|
||||
public static void addAttributes(FlatBufferBuilder builder, int attributesOffset) { builder.addOffset(2, attributesOffset, 0); }
|
||||
public static int createAttributesVector(FlatBufferBuilder builder, int[] data) { builder.startVector(4, data.length, 4); for (int i = data.length - 1; i >= 0; i--) builder.addOffset(data[i]); return builder.endVector(); }
|
||||
public static void startAttributesVector(FlatBufferBuilder builder, int numElems) { builder.startVector(4, numElems, 4); }
|
||||
public static void addDocumentation(FlatBufferBuilder builder, int documentationOffset) { builder.addOffset(3, documentationOffset, 0); }
|
||||
public static int createDocumentationVector(FlatBufferBuilder builder, int[] data) { builder.startVector(4, data.length, 4); for (int i = data.length - 1; i >= 0; i--) builder.addOffset(data[i]); return builder.endVector(); }
|
||||
public static void startDocumentationVector(FlatBufferBuilder builder, int numElems) { builder.startVector(4, numElems, 4); }
|
||||
public static void addDeclarationFile(FlatBufferBuilder builder, int declarationFileOffset) { builder.addOffset(4, declarationFileOffset, 0); }
|
||||
public static int endService(FlatBufferBuilder builder) {
|
||||
int o = builder.endTable();
|
||||
builder.required(o, 4); // name
|
||||
return o;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int keysCompare(Integer o1, Integer o2, ByteBuffer _bb) { return compareStrings(__offset(4, o1, _bb), __offset(4, o2, _bb), _bb); }
|
||||
|
||||
public static Service __lookup_by_key(Service obj, int vectorLocation, String key, ByteBuffer bb) {
|
||||
byte[] byteKey = key.getBytes(java.nio.charset.StandardCharsets.UTF_8);
|
||||
int span = bb.getInt(vectorLocation - 4);
|
||||
int start = 0;
|
||||
while (span != 0) {
|
||||
int middle = span / 2;
|
||||
int tableOffset = __indirect(vectorLocation + 4 * (start + middle), bb);
|
||||
int comp = compareStrings(__offset(4, bb.capacity() - tableOffset, bb), byteKey, bb);
|
||||
if (comp > 0) {
|
||||
span = middle;
|
||||
} else if (comp < 0) {
|
||||
middle++;
|
||||
start += middle;
|
||||
span -= middle;
|
||||
} else {
|
||||
return (obj == null ? new Service() : obj).__assign(tableOffset, bb);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static final class Vector extends BaseVector {
|
||||
public Vector __assign(int _vector, int _element_size, ByteBuffer _bb) { __reset(_vector, _element_size, _bb); return this; }
|
||||
|
||||
public Service get(int j) { return get(new Service(), j); }
|
||||
public Service get(Service obj, int j) { return obj.__assign(__indirect(__element(j), bb), bb); }
|
||||
public Service getByKey(String key) { return __lookup_by_key(null, __vector(), key, bb); }
|
||||
public Service getByKey(Service obj, String key) { return __lookup_by_key(obj, __vector(), key, bb); }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
package com.google.flatbuffers.reflection;
|
||||
|
||||
import com.google.flatbuffers.BaseVector;
|
||||
import com.google.flatbuffers.BooleanVector;
|
||||
import com.google.flatbuffers.ByteVector;
|
||||
import com.google.flatbuffers.Constants;
|
||||
import com.google.flatbuffers.DoubleVector;
|
||||
import com.google.flatbuffers.FlatBufferBuilder;
|
||||
import com.google.flatbuffers.FloatVector;
|
||||
import com.google.flatbuffers.IntVector;
|
||||
import com.google.flatbuffers.LongVector;
|
||||
import com.google.flatbuffers.ShortVector;
|
||||
import com.google.flatbuffers.StringVector;
|
||||
import com.google.flatbuffers.Struct;
|
||||
import com.google.flatbuffers.Table;
|
||||
import com.google.flatbuffers.UnionVector;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public final class Type extends Table {
|
||||
public static void ValidateVersion() { Constants.FLATBUFFERS_23_3_3(); }
|
||||
public static Type getRootAsType(ByteBuffer _bb) { return getRootAsType(_bb, new Type()); }
|
||||
public static Type getRootAsType(ByteBuffer _bb, Type obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
|
||||
public void __init(int _i, ByteBuffer _bb) { __reset(_i, _bb); }
|
||||
public Type __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }
|
||||
|
||||
public byte baseType() { int o = __offset(4); return o != 0 ? bb.get(o + bb_pos) : 0; }
|
||||
public byte element() { int o = __offset(6); return o != 0 ? bb.get(o + bb_pos) : 0; }
|
||||
public int index() { int o = __offset(8); return o != 0 ? bb.getInt(o + bb_pos) : -1; }
|
||||
public int fixedLength() { int o = __offset(10); return o != 0 ? bb.getShort(o + bb_pos) & 0xFFFF : 0; }
|
||||
/**
|
||||
* The size (octets) of the `base_type` field.
|
||||
*/
|
||||
public long baseSize() { int o = __offset(12); return o != 0 ? (long)bb.getInt(o + bb_pos) & 0xFFFFFFFFL : 4L; }
|
||||
/**
|
||||
* The size (octets) of the `element` field, if present.
|
||||
*/
|
||||
public long elementSize() { int o = __offset(14); return o != 0 ? (long)bb.getInt(o + bb_pos) & 0xFFFFFFFFL : 0L; }
|
||||
|
||||
public static int createType(FlatBufferBuilder builder,
|
||||
byte baseType,
|
||||
byte element,
|
||||
int index,
|
||||
int fixedLength,
|
||||
long baseSize,
|
||||
long elementSize) {
|
||||
builder.startTable(6);
|
||||
Type.addElementSize(builder, elementSize);
|
||||
Type.addBaseSize(builder, baseSize);
|
||||
Type.addIndex(builder, index);
|
||||
Type.addFixedLength(builder, fixedLength);
|
||||
Type.addElement(builder, element);
|
||||
Type.addBaseType(builder, baseType);
|
||||
return Type.endType(builder);
|
||||
}
|
||||
|
||||
public static void startType(FlatBufferBuilder builder) { builder.startTable(6); }
|
||||
public static void addBaseType(FlatBufferBuilder builder, byte baseType) { builder.addByte(0, baseType, 0); }
|
||||
public static void addElement(FlatBufferBuilder builder, byte element) { builder.addByte(1, element, 0); }
|
||||
public static void addIndex(FlatBufferBuilder builder, int index) { builder.addInt(2, index, -1); }
|
||||
public static void addFixedLength(FlatBufferBuilder builder, int fixedLength) { builder.addShort(3, (short) fixedLength, (short) 0); }
|
||||
public static void addBaseSize(FlatBufferBuilder builder, long baseSize) { builder.addInt(4, (int) baseSize, (int) 4L); }
|
||||
public static void addElementSize(FlatBufferBuilder builder, long elementSize) { builder.addInt(5, (int) elementSize, (int) 0L); }
|
||||
public static int endType(FlatBufferBuilder builder) {
|
||||
int o = builder.endTable();
|
||||
return o;
|
||||
}
|
||||
|
||||
public static final class Vector extends BaseVector {
|
||||
public Vector __assign(int _vector, int _element_size, ByteBuffer _bb) { __reset(_vector, _element_size, _bb); return this; }
|
||||
|
||||
public Type get(int j) { return get(new Type(), j); }
|
||||
public Type get(Type obj, int j) { return obj.__assign(__indirect(__element(j), bb), bb); }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,18 +2,11 @@ import org.jetbrains.kotlin.ir.backend.js.compile
|
||||
|
||||
plugins {
|
||||
kotlin("multiplatform")
|
||||
id("org.jetbrains.kotlin.plugin.allopen") version "1.4.20"
|
||||
id("org.jetbrains.kotlinx.benchmark") version "0.4.2"
|
||||
id("io.morethan.jmhreport") version "0.9.0"
|
||||
id("org.jetbrains.kotlinx.benchmark")
|
||||
id("io.morethan.jmhreport")
|
||||
id("de.undercouch.download")
|
||||
}
|
||||
|
||||
// allOpen plugin is needed for the benchmark annotations.
|
||||
// for more information, see https://github.com/Kotlin/kotlinx-benchmark#gradle-plugin
|
||||
allOpen {
|
||||
annotation("org.openjdk.jmh.annotations.State")
|
||||
}
|
||||
|
||||
group = "com.google.flatbuffers.jmh"
|
||||
version = "2.0.0-SNAPSHOT"
|
||||
|
||||
@@ -34,7 +27,7 @@ benchmark {
|
||||
iterationTime = 300
|
||||
iterationTimeUnit = "ms"
|
||||
// uncomment for benchmarking JSON op only
|
||||
// include(".*JsonBenchmark.*")
|
||||
include(".*JsonBenchmark.*")
|
||||
}
|
||||
}
|
||||
targets {
|
||||
@@ -43,9 +36,7 @@ benchmark {
|
||||
}
|
||||
|
||||
kotlin {
|
||||
jvm {
|
||||
withJava()
|
||||
}
|
||||
jvm()
|
||||
|
||||
sourceSets {
|
||||
|
||||
@@ -58,7 +49,7 @@ kotlin {
|
||||
implementation(kotlin("stdlib-common"))
|
||||
implementation(project(":flatbuffers-kotlin"))
|
||||
implementation(libs.kotlinx.benchmark.runtime)
|
||||
|
||||
implementation("com.google.flatbuffers:flatbuffers-java:2.0.3")
|
||||
// json serializers
|
||||
implementation(libs.moshi.kotlin)
|
||||
implementation(libs.gson)
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.google.flatbuffers.kotlin.benchmark
|
||||
|
||||
import com.google.flatbuffers.ArrayReadWriteBuf
|
||||
import com.google.flatbuffers.FlexBuffers
|
||||
import com.google.flatbuffers.FlexBuffersBuilder.BUILDER_FLAG_SHARE_ALL
|
||||
@@ -35,7 +34,7 @@ import java.util.concurrent.TimeUnit
|
||||
@BenchmarkMode(Mode.AverageTime)
|
||||
@OutputTimeUnit(TimeUnit.NANOSECONDS)
|
||||
@Measurement(iterations = 20, time = 1, timeUnit = TimeUnit.NANOSECONDS)
|
||||
class FlexBuffersBenchmark {
|
||||
open class FlexBuffersBenchmark {
|
||||
|
||||
var initialCapacity = 1024
|
||||
var value: Double = 0.0
|
||||
@@ -49,7 +48,7 @@ class FlexBuffersBenchmark {
|
||||
}
|
||||
|
||||
@Benchmark
|
||||
fun mapKotlin(blackhole: Blackhole) {
|
||||
open fun mapKotlin(blackhole: Blackhole) {
|
||||
val kBuilder = FlexBuffersBuilder(initialCapacity, FlexBuffersBuilder.SHARE_KEYS_AND_STRINGS)
|
||||
kBuilder.putMap {
|
||||
this["hello"] = "world"
|
||||
@@ -72,7 +71,7 @@ class FlexBuffersBenchmark {
|
||||
}
|
||||
|
||||
@Benchmark
|
||||
fun mapJava(blackhole: Blackhole) {
|
||||
open fun mapJava(blackhole: Blackhole) {
|
||||
val jBuilder = com.google.flatbuffers.FlexBuffersBuilder(ArrayReadWriteBuf(initialCapacity), BUILDER_FLAG_SHARE_ALL)
|
||||
val startMap = jBuilder.startMap()
|
||||
jBuilder.putString("hello", "world")
|
||||
@@ -102,7 +101,7 @@ class FlexBuffersBenchmark {
|
||||
}
|
||||
|
||||
@Benchmark
|
||||
fun intArrayKotlin(blackhole: Blackhole) {
|
||||
open fun intArrayKotlin(blackhole: Blackhole) {
|
||||
val kBuilder = FlexBuffersBuilder(initialCapacity, FlexBuffersBuilder.SHARE_KEYS_AND_STRINGS)
|
||||
kBuilder.put(bigIntArray)
|
||||
val root = getRoot(kBuilder.finish())
|
||||
@@ -110,7 +109,7 @@ class FlexBuffersBenchmark {
|
||||
}
|
||||
|
||||
@Benchmark
|
||||
fun intArrayJava(blackhole: Blackhole) {
|
||||
open fun intArrayJava(blackhole: Blackhole) {
|
||||
val jBuilder = com.google.flatbuffers.FlexBuffersBuilder(ArrayReadWriteBuf(initialCapacity), BUILDER_FLAG_SHARE_ALL)
|
||||
val v = jBuilder.startVector()
|
||||
bigIntArray.forEach { jBuilder.putInt(it) }
|
||||
@@ -126,7 +125,7 @@ class FlexBuffersBenchmark {
|
||||
}
|
||||
|
||||
@Benchmark
|
||||
fun stringArrayKotlin(blackhole: Blackhole) {
|
||||
open fun stringArrayKotlin(blackhole: Blackhole) {
|
||||
val kBuilder = FlexBuffersBuilder(initialCapacity, FlexBuffersBuilder.SHARE_KEYS_AND_STRINGS)
|
||||
kBuilder.putVector { stringValue.forEach { kBuilder.put(it) } }
|
||||
kBuilder.finish()
|
||||
@@ -136,7 +135,7 @@ class FlexBuffersBenchmark {
|
||||
}
|
||||
|
||||
@Benchmark
|
||||
fun stringArrayJava(blackhole: Blackhole) {
|
||||
open fun stringArrayJava(blackhole: Blackhole) {
|
||||
val jBuilder = com.google.flatbuffers.FlexBuffersBuilder(ArrayReadWriteBuf(initialCapacity), BUILDER_FLAG_SHARE_ALL)
|
||||
val v = jBuilder.startVector()
|
||||
stringValue.forEach { jBuilder.putString(it) }
|
||||
@@ -148,7 +147,7 @@ class FlexBuffersBenchmark {
|
||||
}
|
||||
|
||||
@Benchmark
|
||||
fun stringMapKotlin(blackhole: Blackhole) {
|
||||
open fun stringMapKotlin(blackhole: Blackhole) {
|
||||
val kBuilder = FlexBuffersBuilder(initialCapacity, FlexBuffersBuilder.SHARE_KEYS_AND_STRINGS)
|
||||
val pos = kBuilder.startMap()
|
||||
for (i in stringKey.indices) {
|
||||
@@ -165,7 +164,7 @@ class FlexBuffersBenchmark {
|
||||
}
|
||||
|
||||
@Benchmark
|
||||
fun stringMapBytIndexKotlin(blackhole: Blackhole) {
|
||||
open fun stringMapBytIndexKotlin(blackhole: Blackhole) {
|
||||
val kBuilder = FlexBuffersBuilder(initialCapacity, FlexBuffersBuilder.SHARE_KEYS_AND_STRINGS)
|
||||
val pos = kBuilder.startMap()
|
||||
for (i in stringKey.indices) {
|
||||
@@ -180,7 +179,7 @@ class FlexBuffersBenchmark {
|
||||
}
|
||||
|
||||
@Benchmark
|
||||
fun stringMapJava(blackhole: Blackhole) {
|
||||
open fun stringMapJava(blackhole: Blackhole) {
|
||||
val jBuilder = com.google.flatbuffers.FlexBuffersBuilder(ArrayReadWriteBuf(initialCapacity), BUILDER_FLAG_SHARE_ALL)
|
||||
val v = jBuilder.startMap()
|
||||
for (i in stringKey.indices) {
|
||||
|
||||
@@ -41,7 +41,7 @@ import java.util.concurrent.TimeUnit
|
||||
@BenchmarkMode(Mode.AverageTime)
|
||||
@OutputTimeUnit(TimeUnit.MICROSECONDS)
|
||||
@Measurement(iterations = 100, time = 1, timeUnit = TimeUnit.MICROSECONDS)
|
||||
class JsonBenchmark {
|
||||
open class JsonBenchmark {
|
||||
|
||||
final val moshi = Moshi.Builder()
|
||||
.addLast(KotlinJsonAdapterFactory())
|
||||
@@ -76,46 +76,46 @@ class JsonBenchmark {
|
||||
|
||||
// TWITTER
|
||||
@Benchmark
|
||||
fun readTwitterFlexBuffers(hole: Blackhole? = null) = hole?.consume(readFlexBuffers(twitterData))
|
||||
open fun readTwitterFlexBuffers(hole: Blackhole? = null) = hole?.consume(readFlexBuffers(twitterData))
|
||||
@Benchmark
|
||||
fun readTwitterMoshi(hole: Blackhole?) = hole?.consume(readMoshi(twitterData))
|
||||
open fun readTwitterMoshi(hole: Blackhole?) = hole?.consume(readMoshi(twitterData))
|
||||
@Benchmark
|
||||
fun readTwitterGson(hole: Blackhole?) = hole?.consume(readGson(twitterData))
|
||||
open fun readTwitterGson(hole: Blackhole?) = hole?.consume(readGson(twitterData))
|
||||
|
||||
@Benchmark
|
||||
fun roundTripTwitterFlexBuffers(hole: Blackhole? = null) = hole?.consume(readFlexBuffers(twitterData).toJson())
|
||||
open fun roundTripTwitterFlexBuffers(hole: Blackhole? = null) = hole?.consume(readFlexBuffers(twitterData).toJson())
|
||||
@Benchmark
|
||||
fun roundTripTwitterMoshi(hole: Blackhole?) = hole?.consume(moshiAdapter.toJson(readMoshi(twitterData)))
|
||||
open fun roundTripTwitterMoshi(hole: Blackhole?) = hole?.consume(moshiAdapter.toJson(readMoshi(twitterData)))
|
||||
@Benchmark
|
||||
fun roundTripTwitterGson(hole: Blackhole?) = hole?.consume(gson.toJson(readGson(twitterData)))
|
||||
open fun roundTripTwitterGson(hole: Blackhole?) = hole?.consume(gson.toJson(readGson(twitterData)))
|
||||
|
||||
// CITM
|
||||
@Benchmark
|
||||
fun readCITMFlexBuffers(hole: Blackhole? = null) = hole?.consume(readFlexBuffers(citmData))
|
||||
open fun readCITMFlexBuffers(hole: Blackhole? = null) = hole?.consume(readFlexBuffers(citmData))
|
||||
@Benchmark
|
||||
fun readCITMMoshi(hole: Blackhole?) = hole?.consume(moshiAdapter.toJson(readMoshi(citmData)))
|
||||
open fun readCITMMoshi(hole: Blackhole?) = hole?.consume(moshiAdapter.toJson(readMoshi(citmData)))
|
||||
@Benchmark
|
||||
fun readCITMGson(hole: Blackhole?) = hole?.consume(gson.toJson(readGson(citmData)))
|
||||
open fun readCITMGson(hole: Blackhole?) = hole?.consume(gson.toJson(readGson(citmData)))
|
||||
|
||||
@Benchmark
|
||||
fun roundTripCITMFlexBuffers(hole: Blackhole? = null) = hole?.consume(readFlexBuffers(citmData).toJson())
|
||||
open fun roundTripCITMFlexBuffers(hole: Blackhole? = null) = hole?.consume(readFlexBuffers(citmData).toJson())
|
||||
@Benchmark
|
||||
fun roundTripCITMMoshi(hole: Blackhole?) = hole?.consume(moshiAdapter.toJson(readMoshi(citmData)))
|
||||
open fun roundTripCITMMoshi(hole: Blackhole?) = hole?.consume(moshiAdapter.toJson(readMoshi(citmData)))
|
||||
@Benchmark
|
||||
fun roundTripCITMGson(hole: Blackhole?) = hole?.consume(gson.toJson(readGson(citmData)))
|
||||
open fun roundTripCITMGson(hole: Blackhole?) = hole?.consume(gson.toJson(readGson(citmData)))
|
||||
|
||||
@Benchmark
|
||||
fun writeCITMFlexBuffers(hole: Blackhole? = null) = hole?.consume(fbCitmRef.toJson())
|
||||
open fun writeCITMFlexBuffers(hole: Blackhole? = null) = hole?.consume(fbCitmRef.toJson())
|
||||
@Benchmark
|
||||
fun writeCITMMoshi(hole: Blackhole?) = hole?.consume(moshiAdapter.toJson(moshiCitmRef))
|
||||
open fun writeCITMMoshi(hole: Blackhole?) = hole?.consume(moshiAdapter.toJson(moshiCitmRef))
|
||||
@Benchmark
|
||||
fun writeCITMGson(hole: Blackhole?) = hole?.consume(gson.toJson(gsonCitmRef))
|
||||
open fun writeCITMGson(hole: Blackhole?) = hole?.consume(gson.toJson(gsonCitmRef))
|
||||
|
||||
// CANADA
|
||||
@Benchmark
|
||||
fun readCanadaFlexBuffers(hole: Blackhole? = null) = hole?.consume(readFlexBuffers(canadaData))
|
||||
open fun readCanadaFlexBuffers(hole: Blackhole? = null) = hole?.consume(readFlexBuffers(canadaData))
|
||||
@Benchmark
|
||||
fun readCanadaMoshi(hole: Blackhole?) = hole?.consume(readMoshi(canadaData))
|
||||
open fun readCanadaMoshi(hole: Blackhole?) = hole?.consume(readMoshi(canadaData))
|
||||
@Benchmark
|
||||
fun readCanadaGson(hole: Blackhole?) = hole?.consume(readGson(canadaData))
|
||||
open fun readCanadaGson(hole: Blackhole?) = hole?.consume(readGson(canadaData))
|
||||
}
|
||||
|
||||
@@ -1,7 +1,3 @@
|
||||
plugins {
|
||||
id("com.diffplug.spotless") version "6.3.0"
|
||||
}
|
||||
|
||||
group = "com.google.flatbuffers"
|
||||
version = "2.0.0-SNAPSHOT"
|
||||
|
||||
@@ -12,7 +8,10 @@ buildscript {
|
||||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
classpath(libs.bundles.plugins)
|
||||
classpath(libs.plugin.kotlin.gradle)
|
||||
classpath(libs.plugin.kotlinx.benchmark)
|
||||
classpath(libs.plugin.jmhreport)
|
||||
classpath(libs.plugin.download)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,21 +21,3 @@ allprojects {
|
||||
mavenCentral()
|
||||
}
|
||||
}
|
||||
|
||||
// plugin used to enforce code style
|
||||
spotless {
|
||||
val klintConfig = mapOf("indent_size" to "2", "continuation_indent_size" to "2")
|
||||
kotlin {
|
||||
target("**/*.kt")
|
||||
ktlint("0.40.0").userData(klintConfig)
|
||||
trimTrailingWhitespace()
|
||||
indentWithSpaces()
|
||||
endWithNewline()
|
||||
licenseHeaderFile("$rootDir/spotless/spotless.kt").updateYearWithLatest(false)
|
||||
targetExclude("**/spotless.kt", "**/build/**")
|
||||
}
|
||||
kotlinGradle {
|
||||
target("*.gradle.kts")
|
||||
ktlint().userData(klintConfig)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,20 +1,19 @@
|
||||
[versions]
|
||||
plugin-kotlin = "1.6.10"
|
||||
kotlin = "1.7.21"
|
||||
plugin-gver = "0.42.0"
|
||||
kotlinx-benchmark-runtime = "0.4.2"
|
||||
kotlinx-benchmark = "0.4.6"
|
||||
junit = "4.12"
|
||||
gson = "2.8.5"
|
||||
moshi-kotlin = "1.11.0"
|
||||
|
||||
[libraries]
|
||||
kotlin-compiler = { module = "org.jetbrains.kotlin:kotlin-compiler", version.ref = "kotlin" }
|
||||
moshi-kotlin = { module = "com.squareup.moshi:moshi-kotlin", version.ref = "moshi-kotlin" }
|
||||
gson = { module = "com.google.code.gson:gson", version.ref = "gson" }
|
||||
kotlinx-benchmark-runtime = { module = "org.jetbrains.kotlinx:kotlinx-benchmark-runtime", version.ref = "kotlinx-benchmark-runtime" }
|
||||
plugin-kotlin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "plugin-kotlin" }
|
||||
plugin-kotlin-serialization = { module = "org.jetbrains.kotlin:kotlin-serialization", version.ref = "plugin-kotlin" }
|
||||
kotlinx-benchmark-runtime = { module = "org.jetbrains.kotlinx:kotlinx-benchmark-runtime", version.ref = "kotlinx-benchmark" }
|
||||
plugin-gver = { module = "com.github.ben-manes:gradle-versions-plugin", version.ref = "plugin-gver" }
|
||||
|
||||
plugin-kotlin-gradle = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" }
|
||||
plugin-kotlinx-benchmark = { module="org.jetbrains.kotlinx:kotlinx-benchmark-plugin", version.ref="kotlinx-benchmark"}
|
||||
plugin-jmhreport = { module = "gradle.plugin.io.morethan.jmhreport:gradle-jmh-report", version="0.9.0" }
|
||||
plugin-download = { module = "de.undercouch:gradle-download-task", version = "5.3.0"}
|
||||
junit = { module="junit:junit", version.ref="junit"}
|
||||
|
||||
[bundles]
|
||||
plugins = ["plugin-kotlin", "plugin-kotlin-serialization", "plugin-gver"]
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.1-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
||||
@@ -32,6 +32,6 @@ namespace Google.FlatBuffers
|
||||
Changes to the C# implementation need to be sure to change
|
||||
the version here and in the code generator on every possible
|
||||
incompatible change */
|
||||
public static void FLATBUFFERS_22_12_06() {}
|
||||
public static void FLATBUFFERS_23_3_3() {}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>netstandard2.1;netstandard2.0;net46</TargetFrameworks>
|
||||
<Description>A cross-platform memory efficient serialization library</Description>
|
||||
<PackageVersion>22.12.06</PackageVersion>
|
||||
<PackageVersion>23.3.3</PackageVersion>
|
||||
<Authors>Google LLC</Authors>
|
||||
<PackageProjectUrl>https://github.com/google/flatbuffers</PackageProjectUrl>
|
||||
<RepositoryUrl>https://github.com/google/flatbuffers</RepositoryUrl>
|
||||
|
||||
16
package.json
16
package.json
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "flatbuffers",
|
||||
"version": "22.12.06",
|
||||
"version": "23.3.3",
|
||||
"description": "Memory Efficient Serialization Library",
|
||||
"files": [
|
||||
"js/**/*.js",
|
||||
@@ -9,8 +9,8 @@
|
||||
"mjs/**/*.d.ts",
|
||||
"ts/**/*.ts"
|
||||
],
|
||||
"main": "js/index.js",
|
||||
"module": "mjs/index.js",
|
||||
"main": "js/flatbuffers.js",
|
||||
"module": "mjs/flatbuffers.js",
|
||||
"directories": {
|
||||
"doc": "docs",
|
||||
"test": "tests"
|
||||
@@ -18,7 +18,7 @@
|
||||
"scripts": {
|
||||
"test": "npm run compile && cd tests/ts && python3 ./TypeScriptTest.py",
|
||||
"lint": "eslint ts",
|
||||
"compile": "tsc && tsc -p tsconfig.mjs.json && rollup -c",
|
||||
"compile": "tsc && tsc -p tsconfig.mjs.json && esbuild js/flatbuffers.js --minify --global-name=flatbuffers --bundle --outfile=js/flatbuffers.min.js",
|
||||
"prepublishOnly": "npm install --only=dev && npm run compile"
|
||||
},
|
||||
"repository": {
|
||||
@@ -38,10 +38,10 @@
|
||||
"devDependencies": {
|
||||
"@bazel/typescript": "5.2.0",
|
||||
"@types/node": "18.7.16",
|
||||
"@typescript-eslint/eslint-plugin": "^5.36.2",
|
||||
"@typescript-eslint/parser": "^5.36.2",
|
||||
"eslint": "^8.23.1",
|
||||
"rollup": "^2.79.0",
|
||||
"@typescript-eslint/eslint-plugin": "^5.46.0",
|
||||
"@typescript-eslint/parser": "^5.46.0",
|
||||
"esbuild": "^0.16.4",
|
||||
"eslint": "^8.29.0",
|
||||
"typescript": "^4.8.3"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,4 +14,4 @@
|
||||
|
||||
# Placeholder, to be updated during the release process
|
||||
# by the setup.py
|
||||
__version__ = u"22.12.06"
|
||||
__version__ = u"23.3.3"
|
||||
|
||||
@@ -75,7 +75,7 @@ class BitWidth(enum.IntEnum):
|
||||
@staticmethod
|
||||
def F(value):
|
||||
"""Returns the `BitWidth` to encode floating point value."""
|
||||
if struct.unpack('f', struct.pack('f', value))[0] == value:
|
||||
if struct.unpack('<f', struct.pack('<f', value))[0] == value:
|
||||
return BitWidth.W32
|
||||
return BitWidth.W64
|
||||
|
||||
@@ -95,20 +95,20 @@ F = {4: 'f', 8: 'd'} # Floating point formats
|
||||
|
||||
|
||||
def _Unpack(fmt, buf):
|
||||
return struct.unpack(fmt[len(buf)], buf)[0]
|
||||
return struct.unpack('<%s' % fmt[len(buf)], buf)[0]
|
||||
|
||||
|
||||
def _UnpackVector(fmt, buf, length):
|
||||
byte_width = len(buf) // length
|
||||
return struct.unpack('%d%s' % (length, fmt[byte_width]), buf)
|
||||
return struct.unpack('<%d%s' % (length, fmt[byte_width]), buf)
|
||||
|
||||
|
||||
def _Pack(fmt, value, byte_width):
|
||||
return struct.pack(fmt[byte_width], value)
|
||||
return struct.pack('<%s' % fmt[byte_width], value)
|
||||
|
||||
|
||||
def _PackVector(fmt, values, byte_width):
|
||||
return struct.pack('%d%s' % (len(values), fmt[byte_width]), *values)
|
||||
return struct.pack('<%d%s' % (len(values), fmt[byte_width]), *values)
|
||||
|
||||
|
||||
def _Mutate(fmt, buf, value, byte_width, value_bit_width):
|
||||
@@ -727,6 +727,15 @@ class Ref:
|
||||
def IsString(self):
|
||||
return self._type is Type.STRING
|
||||
|
||||
@property
|
||||
def AsStringBytes(self):
|
||||
if self.IsString:
|
||||
return String(self._Indirect(), self._byte_width).Bytes
|
||||
elif self.IsKey:
|
||||
return self.AsKeyBytes
|
||||
else:
|
||||
raise self._ConvertError(Type.STRING)
|
||||
|
||||
@property
|
||||
def AsString(self):
|
||||
if self.IsString:
|
||||
|
||||
@@ -16,7 +16,7 @@ from setuptools import setup
|
||||
|
||||
setup(
|
||||
name='flatbuffers',
|
||||
version='22.12.06',
|
||||
version='23.3.3',
|
||||
license='Apache 2.0',
|
||||
license_files='../LICENSE.txt',
|
||||
author='Derek Bailey',
|
||||
|
||||
@@ -44,6 +44,10 @@ Code generation and runtime libraries for many popular languages.
|
||||
1. TypeScript - [NPM](https://www.npmjs.com/package/flatbuffers)
|
||||
1. Nim
|
||||
|
||||
## Versioning
|
||||
|
||||
FlatBuffers does not follow traditional Semver versioning (see [rationale](https://github.com/google/flatbuffers/wiki/Versioning)) but rather uses a format of the date of the release.
|
||||
|
||||
## Contribution
|
||||
|
||||
* [FlatBuffers Issues Tracker][] to submit an issue.
|
||||
@@ -73,4 +77,4 @@ Please see our [Security Policy](SECURITY.md) for reporting vulnerabilities.
|
||||
[FlatBuffers Issues Tracker]: http://github.com/google/flatbuffers/issues
|
||||
[stackoverflow.com]: http://stackoverflow.com/search?q=flatbuffers
|
||||
[landing page]: https://google.github.io/flatbuffers
|
||||
[LICENSE]: https://github.com/google/flatbuffers/blob/master/LICENSE.txt
|
||||
[LICENSE]: https://github.com/google/flatbuffers/blob/master/LICENSE
|
||||
|
||||
@@ -11,6 +11,5 @@ flatbuffer_ts_library(
|
||||
name = "reflection_ts_fbs",
|
||||
package_name = "flatbuffers_reflection",
|
||||
srcs = [":reflection.fbs"],
|
||||
include_reflection = False,
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
export default {
|
||||
input: 'mjs/index.js',
|
||||
output: {
|
||||
file: 'flatbuffers.js',
|
||||
format: 'iife',
|
||||
name: 'flatbuffers'
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "flatbuffers"
|
||||
version = "22.12.6"
|
||||
version = "23.3.3"
|
||||
edition = "2018"
|
||||
authors = ["Robert Winslow <hello@rwinslow.com>", "FlatBuffers Maintainers"]
|
||||
license = "Apache-2.0"
|
||||
|
||||
@@ -25,6 +25,16 @@ pub struct Table<'a> {
|
||||
}
|
||||
|
||||
impl<'a> Table<'a> {
|
||||
#[inline]
|
||||
pub fn buf(&self) -> &'a [u8] {
|
||||
self.buf
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn loc(&self) -> usize {
|
||||
self.loc
|
||||
}
|
||||
|
||||
/// # Safety
|
||||
///
|
||||
/// `buf` must contain a `soffset_t` at `loc`, which points to a valid vtable
|
||||
|
||||
@@ -24,6 +24,7 @@ import MyGame.Sample.Weapon
|
||||
|
||||
import com.google.flatbuffers.FlatBufferBuilder
|
||||
|
||||
@kotlin.ExperimentalUnsignedTypes
|
||||
class SampleBinary {
|
||||
|
||||
companion object {
|
||||
@@ -45,7 +46,7 @@ class SampleBinary {
|
||||
|
||||
// Serialize the FlatBuffer data.
|
||||
val name = builder.createString("Orc")
|
||||
val treasure = byteArrayOf(0, 1, 2, 3, 4, 5, 6, 7, 8, 9)
|
||||
val treasure = byteArrayOf(0, 1, 2, 3, 4, 5, 6, 7, 8, 9).asUByteArray()
|
||||
val inv = Monster.createInventoryVector(builder, treasure)
|
||||
val weapons = Monster.createWeaponsVector(builder, weaps)
|
||||
val pos = Vec3.createVec3(builder, 1.0f, 2.0f, 3.0f)
|
||||
@@ -85,7 +86,7 @@ class SampleBinary {
|
||||
|
||||
// Get and test the `inventory` FlatBuffer `vector`.
|
||||
for (i in 0 until monster.inventoryLength) {
|
||||
assert(monster.inventory(i) == i.toByte().toInt())
|
||||
assert(monster.inventory(i) == i.toUByte())
|
||||
}
|
||||
|
||||
// Get and test the `weapons` FlatBuffer `vector` of `table`s.
|
||||
|
||||
@@ -8,9 +8,9 @@
|
||||
|
||||
// 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 == 22 &&
|
||||
FLATBUFFERS_VERSION_MINOR == 12 &&
|
||||
FLATBUFFERS_VERSION_REVISION == 6,
|
||||
static_assert(FLATBUFFERS_VERSION_MAJOR == 23 &&
|
||||
FLATBUFFERS_VERSION_MINOR == 3 &&
|
||||
FLATBUFFERS_VERSION_REVISION == 3,
|
||||
"Non-compatible flatbuffers version included");
|
||||
|
||||
namespace MyGame {
|
||||
@@ -33,11 +33,11 @@ bool operator!=(const MonsterT &lhs, const MonsterT &rhs);
|
||||
bool operator==(const WeaponT &lhs, const WeaponT &rhs);
|
||||
bool operator!=(const WeaponT &lhs, const WeaponT &rhs);
|
||||
|
||||
inline const flatbuffers::TypeTable *Vec3TypeTable();
|
||||
inline const ::flatbuffers::TypeTable *Vec3TypeTable();
|
||||
|
||||
inline const flatbuffers::TypeTable *MonsterTypeTable();
|
||||
inline const ::flatbuffers::TypeTable *MonsterTypeTable();
|
||||
|
||||
inline const flatbuffers::TypeTable *WeaponTypeTable();
|
||||
inline const ::flatbuffers::TypeTable *WeaponTypeTable();
|
||||
|
||||
enum Color : int8_t {
|
||||
Color_Red = 0,
|
||||
@@ -67,7 +67,7 @@ inline const char * const *EnumNamesColor() {
|
||||
}
|
||||
|
||||
inline const char *EnumNameColor(Color e) {
|
||||
if (flatbuffers::IsOutRange(e, Color_Red, Color_Blue)) return "";
|
||||
if (::flatbuffers::IsOutRange(e, Color_Red, Color_Blue)) return "";
|
||||
const size_t index = static_cast<size_t>(e);
|
||||
return EnumNamesColor()[index];
|
||||
}
|
||||
@@ -97,7 +97,7 @@ inline const char * const *EnumNamesEquipment() {
|
||||
}
|
||||
|
||||
inline const char *EnumNameEquipment(Equipment e) {
|
||||
if (flatbuffers::IsOutRange(e, Equipment_NONE, Equipment_Weapon)) return "";
|
||||
if (::flatbuffers::IsOutRange(e, Equipment_NONE, Equipment_Weapon)) return "";
|
||||
const size_t index = static_cast<size_t>(e);
|
||||
return EnumNamesEquipment()[index];
|
||||
}
|
||||
@@ -145,8 +145,8 @@ struct EquipmentUnion {
|
||||
}
|
||||
}
|
||||
|
||||
static void *UnPack(const void *obj, Equipment type, const flatbuffers::resolver_function_t *resolver);
|
||||
flatbuffers::Offset<void> Pack(flatbuffers::FlatBufferBuilder &_fbb, const flatbuffers::rehasher_function_t *_rehasher = nullptr) const;
|
||||
static void *UnPack(const void *obj, Equipment type, const ::flatbuffers::resolver_function_t *resolver);
|
||||
::flatbuffers::Offset<void> Pack(::flatbuffers::FlatBufferBuilder &_fbb, const ::flatbuffers::rehasher_function_t *_rehasher = nullptr) const;
|
||||
|
||||
MyGame::Sample::WeaponT *AsWeapon() {
|
||||
return type == Equipment_Weapon ?
|
||||
@@ -179,8 +179,8 @@ inline bool operator!=(const EquipmentUnion &lhs, const EquipmentUnion &rhs) {
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
bool VerifyEquipment(flatbuffers::Verifier &verifier, const void *obj, Equipment type);
|
||||
bool VerifyEquipmentVector(flatbuffers::Verifier &verifier, const flatbuffers::Vector<flatbuffers::Offset<void>> *values, const flatbuffers::Vector<uint8_t> *types);
|
||||
bool VerifyEquipment(::flatbuffers::Verifier &verifier, const void *obj, Equipment type);
|
||||
bool VerifyEquipmentVector(::flatbuffers::Verifier &verifier, const ::flatbuffers::Vector<::flatbuffers::Offset<void>> *values, const ::flatbuffers::Vector<uint8_t> *types);
|
||||
|
||||
FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(4) Vec3 FLATBUFFERS_FINAL_CLASS {
|
||||
private:
|
||||
@@ -189,7 +189,7 @@ FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(4) Vec3 FLATBUFFERS_FINAL_CLASS {
|
||||
float z_;
|
||||
|
||||
public:
|
||||
static const flatbuffers::TypeTable *MiniReflectTypeTable() {
|
||||
static const ::flatbuffers::TypeTable *MiniReflectTypeTable() {
|
||||
return Vec3TypeTable();
|
||||
}
|
||||
Vec3()
|
||||
@@ -198,27 +198,27 @@ FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(4) Vec3 FLATBUFFERS_FINAL_CLASS {
|
||||
z_(0) {
|
||||
}
|
||||
Vec3(float _x, float _y, float _z)
|
||||
: x_(flatbuffers::EndianScalar(_x)),
|
||||
y_(flatbuffers::EndianScalar(_y)),
|
||||
z_(flatbuffers::EndianScalar(_z)) {
|
||||
: x_(::flatbuffers::EndianScalar(_x)),
|
||||
y_(::flatbuffers::EndianScalar(_y)),
|
||||
z_(::flatbuffers::EndianScalar(_z)) {
|
||||
}
|
||||
float x() const {
|
||||
return flatbuffers::EndianScalar(x_);
|
||||
return ::flatbuffers::EndianScalar(x_);
|
||||
}
|
||||
void mutate_x(float _x) {
|
||||
flatbuffers::WriteScalar(&x_, _x);
|
||||
::flatbuffers::WriteScalar(&x_, _x);
|
||||
}
|
||||
float y() const {
|
||||
return flatbuffers::EndianScalar(y_);
|
||||
return ::flatbuffers::EndianScalar(y_);
|
||||
}
|
||||
void mutate_y(float _y) {
|
||||
flatbuffers::WriteScalar(&y_, _y);
|
||||
::flatbuffers::WriteScalar(&y_, _y);
|
||||
}
|
||||
float z() const {
|
||||
return flatbuffers::EndianScalar(z_);
|
||||
return ::flatbuffers::EndianScalar(z_);
|
||||
}
|
||||
void mutate_z(float _z) {
|
||||
flatbuffers::WriteScalar(&z_, _z);
|
||||
::flatbuffers::WriteScalar(&z_, _z);
|
||||
}
|
||||
};
|
||||
FLATBUFFERS_STRUCT_END(Vec3, 12);
|
||||
@@ -235,7 +235,7 @@ inline bool operator!=(const Vec3 &lhs, const Vec3 &rhs) {
|
||||
}
|
||||
|
||||
|
||||
struct MonsterT : public flatbuffers::NativeTable {
|
||||
struct MonsterT : public ::flatbuffers::NativeTable {
|
||||
typedef Monster TableType;
|
||||
flatbuffers::unique_ptr<MyGame::Sample::Vec3> pos{};
|
||||
int16_t mana = 150;
|
||||
@@ -252,10 +252,10 @@ struct MonsterT : public flatbuffers::NativeTable {
|
||||
MonsterT &operator=(MonsterT o) FLATBUFFERS_NOEXCEPT;
|
||||
};
|
||||
|
||||
struct Monster FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
|
||||
struct Monster FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
||||
typedef MonsterT NativeTableType;
|
||||
typedef MonsterBuilder Builder;
|
||||
static const flatbuffers::TypeTable *MiniReflectTypeTable() {
|
||||
static const ::flatbuffers::TypeTable *MiniReflectTypeTable() {
|
||||
return MonsterTypeTable();
|
||||
}
|
||||
enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
|
||||
@@ -288,17 +288,17 @@ struct Monster FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
|
||||
bool mutate_hp(int16_t _hp = 100) {
|
||||
return SetField<int16_t>(VT_HP, _hp, 100);
|
||||
}
|
||||
const flatbuffers::String *name() const {
|
||||
return GetPointer<const flatbuffers::String *>(VT_NAME);
|
||||
const ::flatbuffers::String *name() const {
|
||||
return GetPointer<const ::flatbuffers::String *>(VT_NAME);
|
||||
}
|
||||
flatbuffers::String *mutable_name() {
|
||||
return GetPointer<flatbuffers::String *>(VT_NAME);
|
||||
::flatbuffers::String *mutable_name() {
|
||||
return GetPointer<::flatbuffers::String *>(VT_NAME);
|
||||
}
|
||||
const flatbuffers::Vector<uint8_t> *inventory() const {
|
||||
return GetPointer<const flatbuffers::Vector<uint8_t> *>(VT_INVENTORY);
|
||||
const ::flatbuffers::Vector<uint8_t> *inventory() const {
|
||||
return GetPointer<const ::flatbuffers::Vector<uint8_t> *>(VT_INVENTORY);
|
||||
}
|
||||
flatbuffers::Vector<uint8_t> *mutable_inventory() {
|
||||
return GetPointer<flatbuffers::Vector<uint8_t> *>(VT_INVENTORY);
|
||||
::flatbuffers::Vector<uint8_t> *mutable_inventory() {
|
||||
return GetPointer<::flatbuffers::Vector<uint8_t> *>(VT_INVENTORY);
|
||||
}
|
||||
MyGame::Sample::Color color() const {
|
||||
return static_cast<MyGame::Sample::Color>(GetField<int8_t>(VT_COLOR, 2));
|
||||
@@ -306,11 +306,11 @@ struct Monster FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
|
||||
bool mutate_color(MyGame::Sample::Color _color = static_cast<MyGame::Sample::Color>(2)) {
|
||||
return SetField<int8_t>(VT_COLOR, static_cast<int8_t>(_color), 2);
|
||||
}
|
||||
const flatbuffers::Vector<flatbuffers::Offset<MyGame::Sample::Weapon>> *weapons() const {
|
||||
return GetPointer<const flatbuffers::Vector<flatbuffers::Offset<MyGame::Sample::Weapon>> *>(VT_WEAPONS);
|
||||
const ::flatbuffers::Vector<::flatbuffers::Offset<MyGame::Sample::Weapon>> *weapons() const {
|
||||
return GetPointer<const ::flatbuffers::Vector<::flatbuffers::Offset<MyGame::Sample::Weapon>> *>(VT_WEAPONS);
|
||||
}
|
||||
flatbuffers::Vector<flatbuffers::Offset<MyGame::Sample::Weapon>> *mutable_weapons() {
|
||||
return GetPointer<flatbuffers::Vector<flatbuffers::Offset<MyGame::Sample::Weapon>> *>(VT_WEAPONS);
|
||||
::flatbuffers::Vector<::flatbuffers::Offset<MyGame::Sample::Weapon>> *mutable_weapons() {
|
||||
return GetPointer<::flatbuffers::Vector<::flatbuffers::Offset<MyGame::Sample::Weapon>> *>(VT_WEAPONS);
|
||||
}
|
||||
MyGame::Sample::Equipment equipped_type() const {
|
||||
return static_cast<MyGame::Sample::Equipment>(GetField<uint8_t>(VT_EQUIPPED_TYPE, 0));
|
||||
@@ -325,13 +325,13 @@ struct Monster FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
|
||||
void *mutable_equipped() {
|
||||
return GetPointer<void *>(VT_EQUIPPED);
|
||||
}
|
||||
const flatbuffers::Vector<const MyGame::Sample::Vec3 *> *path() const {
|
||||
return GetPointer<const flatbuffers::Vector<const MyGame::Sample::Vec3 *> *>(VT_PATH);
|
||||
const ::flatbuffers::Vector<const MyGame::Sample::Vec3 *> *path() const {
|
||||
return GetPointer<const ::flatbuffers::Vector<const MyGame::Sample::Vec3 *> *>(VT_PATH);
|
||||
}
|
||||
flatbuffers::Vector<const MyGame::Sample::Vec3 *> *mutable_path() {
|
||||
return GetPointer<flatbuffers::Vector<const MyGame::Sample::Vec3 *> *>(VT_PATH);
|
||||
::flatbuffers::Vector<const MyGame::Sample::Vec3 *> *mutable_path() {
|
||||
return GetPointer<::flatbuffers::Vector<const MyGame::Sample::Vec3 *> *>(VT_PATH);
|
||||
}
|
||||
bool Verify(flatbuffers::Verifier &verifier) const {
|
||||
bool Verify(::flatbuffers::Verifier &verifier) const {
|
||||
return VerifyTableStart(verifier) &&
|
||||
VerifyField<MyGame::Sample::Vec3>(verifier, VT_POS, 4) &&
|
||||
VerifyField<int16_t>(verifier, VT_MANA, 2) &&
|
||||
@@ -351,9 +351,9 @@ struct Monster FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
|
||||
verifier.VerifyVector(path()) &&
|
||||
verifier.EndTable();
|
||||
}
|
||||
MonsterT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const;
|
||||
void UnPackTo(MonsterT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const;
|
||||
static flatbuffers::Offset<Monster> Pack(flatbuffers::FlatBufferBuilder &_fbb, const MonsterT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr);
|
||||
MonsterT *UnPack(const ::flatbuffers::resolver_function_t *_resolver = nullptr) const;
|
||||
void UnPackTo(MonsterT *_o, const ::flatbuffers::resolver_function_t *_resolver = nullptr) const;
|
||||
static ::flatbuffers::Offset<Monster> Pack(::flatbuffers::FlatBufferBuilder &_fbb, const MonsterT* _o, const ::flatbuffers::rehasher_function_t *_rehasher = nullptr);
|
||||
};
|
||||
|
||||
template<> inline const MyGame::Sample::Weapon *Monster::equipped_as<MyGame::Sample::Weapon>() const {
|
||||
@@ -362,8 +362,8 @@ template<> inline const MyGame::Sample::Weapon *Monster::equipped_as<MyGame::Sam
|
||||
|
||||
struct MonsterBuilder {
|
||||
typedef Monster Table;
|
||||
flatbuffers::FlatBufferBuilder &fbb_;
|
||||
flatbuffers::uoffset_t start_;
|
||||
::flatbuffers::FlatBufferBuilder &fbb_;
|
||||
::flatbuffers::uoffset_t start_;
|
||||
void add_pos(const MyGame::Sample::Vec3 *pos) {
|
||||
fbb_.AddStruct(Monster::VT_POS, pos);
|
||||
}
|
||||
@@ -373,50 +373,50 @@ struct MonsterBuilder {
|
||||
void add_hp(int16_t hp) {
|
||||
fbb_.AddElement<int16_t>(Monster::VT_HP, hp, 100);
|
||||
}
|
||||
void add_name(flatbuffers::Offset<flatbuffers::String> name) {
|
||||
void add_name(::flatbuffers::Offset<::flatbuffers::String> name) {
|
||||
fbb_.AddOffset(Monster::VT_NAME, name);
|
||||
}
|
||||
void add_inventory(flatbuffers::Offset<flatbuffers::Vector<uint8_t>> inventory) {
|
||||
void add_inventory(::flatbuffers::Offset<::flatbuffers::Vector<uint8_t>> inventory) {
|
||||
fbb_.AddOffset(Monster::VT_INVENTORY, inventory);
|
||||
}
|
||||
void add_color(MyGame::Sample::Color color) {
|
||||
fbb_.AddElement<int8_t>(Monster::VT_COLOR, static_cast<int8_t>(color), 2);
|
||||
}
|
||||
void add_weapons(flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<MyGame::Sample::Weapon>>> weapons) {
|
||||
void add_weapons(::flatbuffers::Offset<::flatbuffers::Vector<::flatbuffers::Offset<MyGame::Sample::Weapon>>> weapons) {
|
||||
fbb_.AddOffset(Monster::VT_WEAPONS, weapons);
|
||||
}
|
||||
void add_equipped_type(MyGame::Sample::Equipment equipped_type) {
|
||||
fbb_.AddElement<uint8_t>(Monster::VT_EQUIPPED_TYPE, static_cast<uint8_t>(equipped_type), 0);
|
||||
}
|
||||
void add_equipped(flatbuffers::Offset<void> equipped) {
|
||||
void add_equipped(::flatbuffers::Offset<void> equipped) {
|
||||
fbb_.AddOffset(Monster::VT_EQUIPPED, equipped);
|
||||
}
|
||||
void add_path(flatbuffers::Offset<flatbuffers::Vector<const MyGame::Sample::Vec3 *>> path) {
|
||||
void add_path(::flatbuffers::Offset<::flatbuffers::Vector<const MyGame::Sample::Vec3 *>> path) {
|
||||
fbb_.AddOffset(Monster::VT_PATH, path);
|
||||
}
|
||||
explicit MonsterBuilder(flatbuffers::FlatBufferBuilder &_fbb)
|
||||
explicit MonsterBuilder(::flatbuffers::FlatBufferBuilder &_fbb)
|
||||
: fbb_(_fbb) {
|
||||
start_ = fbb_.StartTable();
|
||||
}
|
||||
flatbuffers::Offset<Monster> Finish() {
|
||||
::flatbuffers::Offset<Monster> Finish() {
|
||||
const auto end = fbb_.EndTable(start_);
|
||||
auto o = flatbuffers::Offset<Monster>(end);
|
||||
auto o = ::flatbuffers::Offset<Monster>(end);
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
||||
inline flatbuffers::Offset<Monster> CreateMonster(
|
||||
flatbuffers::FlatBufferBuilder &_fbb,
|
||||
inline ::flatbuffers::Offset<Monster> CreateMonster(
|
||||
::flatbuffers::FlatBufferBuilder &_fbb,
|
||||
const MyGame::Sample::Vec3 *pos = nullptr,
|
||||
int16_t mana = 150,
|
||||
int16_t hp = 100,
|
||||
flatbuffers::Offset<flatbuffers::String> name = 0,
|
||||
flatbuffers::Offset<flatbuffers::Vector<uint8_t>> inventory = 0,
|
||||
::flatbuffers::Offset<::flatbuffers::String> name = 0,
|
||||
::flatbuffers::Offset<::flatbuffers::Vector<uint8_t>> inventory = 0,
|
||||
MyGame::Sample::Color color = MyGame::Sample::Color_Blue,
|
||||
flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<MyGame::Sample::Weapon>>> weapons = 0,
|
||||
::flatbuffers::Offset<::flatbuffers::Vector<::flatbuffers::Offset<MyGame::Sample::Weapon>>> weapons = 0,
|
||||
MyGame::Sample::Equipment equipped_type = MyGame::Sample::Equipment_NONE,
|
||||
flatbuffers::Offset<void> equipped = 0,
|
||||
flatbuffers::Offset<flatbuffers::Vector<const MyGame::Sample::Vec3 *>> path = 0) {
|
||||
::flatbuffers::Offset<void> equipped = 0,
|
||||
::flatbuffers::Offset<::flatbuffers::Vector<const MyGame::Sample::Vec3 *>> path = 0) {
|
||||
MonsterBuilder builder_(_fbb);
|
||||
builder_.add_path(path);
|
||||
builder_.add_equipped(equipped);
|
||||
@@ -431,21 +431,21 @@ inline flatbuffers::Offset<Monster> CreateMonster(
|
||||
return builder_.Finish();
|
||||
}
|
||||
|
||||
inline flatbuffers::Offset<Monster> CreateMonsterDirect(
|
||||
flatbuffers::FlatBufferBuilder &_fbb,
|
||||
inline ::flatbuffers::Offset<Monster> CreateMonsterDirect(
|
||||
::flatbuffers::FlatBufferBuilder &_fbb,
|
||||
const MyGame::Sample::Vec3 *pos = nullptr,
|
||||
int16_t mana = 150,
|
||||
int16_t hp = 100,
|
||||
const char *name = nullptr,
|
||||
const std::vector<uint8_t> *inventory = nullptr,
|
||||
MyGame::Sample::Color color = MyGame::Sample::Color_Blue,
|
||||
const std::vector<flatbuffers::Offset<MyGame::Sample::Weapon>> *weapons = nullptr,
|
||||
const std::vector<::flatbuffers::Offset<MyGame::Sample::Weapon>> *weapons = nullptr,
|
||||
MyGame::Sample::Equipment equipped_type = MyGame::Sample::Equipment_NONE,
|
||||
flatbuffers::Offset<void> equipped = 0,
|
||||
::flatbuffers::Offset<void> equipped = 0,
|
||||
const std::vector<MyGame::Sample::Vec3> *path = nullptr) {
|
||||
auto name__ = name ? _fbb.CreateString(name) : 0;
|
||||
auto inventory__ = inventory ? _fbb.CreateVector<uint8_t>(*inventory) : 0;
|
||||
auto weapons__ = weapons ? _fbb.CreateVector<flatbuffers::Offset<MyGame::Sample::Weapon>>(*weapons) : 0;
|
||||
auto weapons__ = weapons ? _fbb.CreateVector<::flatbuffers::Offset<MyGame::Sample::Weapon>>(*weapons) : 0;
|
||||
auto path__ = path ? _fbb.CreateVectorOfStructs<MyGame::Sample::Vec3>(*path) : 0;
|
||||
return MyGame::Sample::CreateMonster(
|
||||
_fbb,
|
||||
@@ -461,29 +461,29 @@ inline flatbuffers::Offset<Monster> CreateMonsterDirect(
|
||||
path__);
|
||||
}
|
||||
|
||||
flatbuffers::Offset<Monster> CreateMonster(flatbuffers::FlatBufferBuilder &_fbb, const MonsterT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr);
|
||||
::flatbuffers::Offset<Monster> CreateMonster(::flatbuffers::FlatBufferBuilder &_fbb, const MonsterT *_o, const ::flatbuffers::rehasher_function_t *_rehasher = nullptr);
|
||||
|
||||
struct WeaponT : public flatbuffers::NativeTable {
|
||||
struct WeaponT : public ::flatbuffers::NativeTable {
|
||||
typedef Weapon TableType;
|
||||
std::string name{};
|
||||
int16_t damage = 0;
|
||||
};
|
||||
|
||||
struct Weapon FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
|
||||
struct Weapon FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
||||
typedef WeaponT NativeTableType;
|
||||
typedef WeaponBuilder Builder;
|
||||
static const flatbuffers::TypeTable *MiniReflectTypeTable() {
|
||||
static const ::flatbuffers::TypeTable *MiniReflectTypeTable() {
|
||||
return WeaponTypeTable();
|
||||
}
|
||||
enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
|
||||
VT_NAME = 4,
|
||||
VT_DAMAGE = 6
|
||||
};
|
||||
const flatbuffers::String *name() const {
|
||||
return GetPointer<const flatbuffers::String *>(VT_NAME);
|
||||
const ::flatbuffers::String *name() const {
|
||||
return GetPointer<const ::flatbuffers::String *>(VT_NAME);
|
||||
}
|
||||
flatbuffers::String *mutable_name() {
|
||||
return GetPointer<flatbuffers::String *>(VT_NAME);
|
||||
::flatbuffers::String *mutable_name() {
|
||||
return GetPointer<::flatbuffers::String *>(VT_NAME);
|
||||
}
|
||||
int16_t damage() const {
|
||||
return GetField<int16_t>(VT_DAMAGE, 0);
|
||||
@@ -491,42 +491,42 @@ struct Weapon FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
|
||||
bool mutate_damage(int16_t _damage = 0) {
|
||||
return SetField<int16_t>(VT_DAMAGE, _damage, 0);
|
||||
}
|
||||
bool Verify(flatbuffers::Verifier &verifier) const {
|
||||
bool Verify(::flatbuffers::Verifier &verifier) const {
|
||||
return VerifyTableStart(verifier) &&
|
||||
VerifyOffset(verifier, VT_NAME) &&
|
||||
verifier.VerifyString(name()) &&
|
||||
VerifyField<int16_t>(verifier, VT_DAMAGE, 2) &&
|
||||
verifier.EndTable();
|
||||
}
|
||||
WeaponT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const;
|
||||
void UnPackTo(WeaponT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const;
|
||||
static flatbuffers::Offset<Weapon> Pack(flatbuffers::FlatBufferBuilder &_fbb, const WeaponT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr);
|
||||
WeaponT *UnPack(const ::flatbuffers::resolver_function_t *_resolver = nullptr) const;
|
||||
void UnPackTo(WeaponT *_o, const ::flatbuffers::resolver_function_t *_resolver = nullptr) const;
|
||||
static ::flatbuffers::Offset<Weapon> Pack(::flatbuffers::FlatBufferBuilder &_fbb, const WeaponT* _o, const ::flatbuffers::rehasher_function_t *_rehasher = nullptr);
|
||||
};
|
||||
|
||||
struct WeaponBuilder {
|
||||
typedef Weapon Table;
|
||||
flatbuffers::FlatBufferBuilder &fbb_;
|
||||
flatbuffers::uoffset_t start_;
|
||||
void add_name(flatbuffers::Offset<flatbuffers::String> name) {
|
||||
::flatbuffers::FlatBufferBuilder &fbb_;
|
||||
::flatbuffers::uoffset_t start_;
|
||||
void add_name(::flatbuffers::Offset<::flatbuffers::String> name) {
|
||||
fbb_.AddOffset(Weapon::VT_NAME, name);
|
||||
}
|
||||
void add_damage(int16_t damage) {
|
||||
fbb_.AddElement<int16_t>(Weapon::VT_DAMAGE, damage, 0);
|
||||
}
|
||||
explicit WeaponBuilder(flatbuffers::FlatBufferBuilder &_fbb)
|
||||
explicit WeaponBuilder(::flatbuffers::FlatBufferBuilder &_fbb)
|
||||
: fbb_(_fbb) {
|
||||
start_ = fbb_.StartTable();
|
||||
}
|
||||
flatbuffers::Offset<Weapon> Finish() {
|
||||
::flatbuffers::Offset<Weapon> Finish() {
|
||||
const auto end = fbb_.EndTable(start_);
|
||||
auto o = flatbuffers::Offset<Weapon>(end);
|
||||
auto o = ::flatbuffers::Offset<Weapon>(end);
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
||||
inline flatbuffers::Offset<Weapon> CreateWeapon(
|
||||
flatbuffers::FlatBufferBuilder &_fbb,
|
||||
flatbuffers::Offset<flatbuffers::String> name = 0,
|
||||
inline ::flatbuffers::Offset<Weapon> CreateWeapon(
|
||||
::flatbuffers::FlatBufferBuilder &_fbb,
|
||||
::flatbuffers::Offset<::flatbuffers::String> name = 0,
|
||||
int16_t damage = 0) {
|
||||
WeaponBuilder builder_(_fbb);
|
||||
builder_.add_name(name);
|
||||
@@ -534,8 +534,8 @@ inline flatbuffers::Offset<Weapon> CreateWeapon(
|
||||
return builder_.Finish();
|
||||
}
|
||||
|
||||
inline flatbuffers::Offset<Weapon> CreateWeaponDirect(
|
||||
flatbuffers::FlatBufferBuilder &_fbb,
|
||||
inline ::flatbuffers::Offset<Weapon> CreateWeaponDirect(
|
||||
::flatbuffers::FlatBufferBuilder &_fbb,
|
||||
const char *name = nullptr,
|
||||
int16_t damage = 0) {
|
||||
auto name__ = name ? _fbb.CreateString(name) : 0;
|
||||
@@ -545,7 +545,7 @@ inline flatbuffers::Offset<Weapon> CreateWeaponDirect(
|
||||
damage);
|
||||
}
|
||||
|
||||
flatbuffers::Offset<Weapon> CreateWeapon(flatbuffers::FlatBufferBuilder &_fbb, const WeaponT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr);
|
||||
::flatbuffers::Offset<Weapon> CreateWeapon(::flatbuffers::FlatBufferBuilder &_fbb, const WeaponT *_o, const ::flatbuffers::rehasher_function_t *_rehasher = nullptr);
|
||||
|
||||
|
||||
inline bool operator==(const MonsterT &lhs, const MonsterT &rhs) {
|
||||
@@ -592,13 +592,13 @@ inline MonsterT &MonsterT::operator=(MonsterT o) FLATBUFFERS_NOEXCEPT {
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline MonsterT *Monster::UnPack(const flatbuffers::resolver_function_t *_resolver) const {
|
||||
inline MonsterT *Monster::UnPack(const ::flatbuffers::resolver_function_t *_resolver) const {
|
||||
auto _o = std::unique_ptr<MonsterT>(new MonsterT());
|
||||
UnPackTo(_o.get(), _resolver);
|
||||
return _o.release();
|
||||
}
|
||||
|
||||
inline void Monster::UnPackTo(MonsterT *_o, const flatbuffers::resolver_function_t *_resolver) const {
|
||||
inline void Monster::UnPackTo(MonsterT *_o, const ::flatbuffers::resolver_function_t *_resolver) const {
|
||||
(void)_o;
|
||||
(void)_resolver;
|
||||
{ auto _e = pos(); if (_e) _o->pos = flatbuffers::unique_ptr<MyGame::Sample::Vec3>(new MyGame::Sample::Vec3(*_e)); }
|
||||
@@ -607,27 +607,27 @@ inline void Monster::UnPackTo(MonsterT *_o, const flatbuffers::resolver_function
|
||||
{ auto _e = name(); if (_e) _o->name = _e->str(); }
|
||||
{ auto _e = inventory(); if (_e) { _o->inventory.resize(_e->size()); std::copy(_e->begin(), _e->end(), _o->inventory.begin()); } }
|
||||
{ auto _e = color(); _o->color = _e; }
|
||||
{ auto _e = weapons(); if (_e) { _o->weapons.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { if(_o->weapons[_i]) { _e->Get(_i)->UnPackTo(_o->weapons[_i].get(), _resolver); } else { _o->weapons[_i] = flatbuffers::unique_ptr<MyGame::Sample::WeaponT>(_e->Get(_i)->UnPack(_resolver)); }; } } else { _o->weapons.resize(0); } }
|
||||
{ auto _e = weapons(); if (_e) { _o->weapons.resize(_e->size()); for (::flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { if(_o->weapons[_i]) { _e->Get(_i)->UnPackTo(_o->weapons[_i].get(), _resolver); } else { _o->weapons[_i] = flatbuffers::unique_ptr<MyGame::Sample::WeaponT>(_e->Get(_i)->UnPack(_resolver)); }; } } else { _o->weapons.resize(0); } }
|
||||
{ auto _e = equipped_type(); _o->equipped.type = _e; }
|
||||
{ auto _e = equipped(); if (_e) _o->equipped.value = MyGame::Sample::EquipmentUnion::UnPack(_e, equipped_type(), _resolver); }
|
||||
{ auto _e = path(); if (_e) { _o->path.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->path[_i] = *_e->Get(_i); } } else { _o->path.resize(0); } }
|
||||
{ auto _e = path(); if (_e) { _o->path.resize(_e->size()); for (::flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->path[_i] = *_e->Get(_i); } } else { _o->path.resize(0); } }
|
||||
}
|
||||
|
||||
inline flatbuffers::Offset<Monster> Monster::Pack(flatbuffers::FlatBufferBuilder &_fbb, const MonsterT* _o, const flatbuffers::rehasher_function_t *_rehasher) {
|
||||
inline ::flatbuffers::Offset<Monster> Monster::Pack(::flatbuffers::FlatBufferBuilder &_fbb, const MonsterT* _o, const ::flatbuffers::rehasher_function_t *_rehasher) {
|
||||
return CreateMonster(_fbb, _o, _rehasher);
|
||||
}
|
||||
|
||||
inline flatbuffers::Offset<Monster> CreateMonster(flatbuffers::FlatBufferBuilder &_fbb, const MonsterT *_o, const flatbuffers::rehasher_function_t *_rehasher) {
|
||||
inline ::flatbuffers::Offset<Monster> CreateMonster(::flatbuffers::FlatBufferBuilder &_fbb, const MonsterT *_o, const ::flatbuffers::rehasher_function_t *_rehasher) {
|
||||
(void)_rehasher;
|
||||
(void)_o;
|
||||
struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const MonsterT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va;
|
||||
struct _VectorArgs { ::flatbuffers::FlatBufferBuilder *__fbb; const MonsterT* __o; const ::flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va;
|
||||
auto _pos = _o->pos ? _o->pos.get() : nullptr;
|
||||
auto _mana = _o->mana;
|
||||
auto _hp = _o->hp;
|
||||
auto _name = _o->name.empty() ? 0 : _fbb.CreateString(_o->name);
|
||||
auto _inventory = _o->inventory.size() ? _fbb.CreateVector(_o->inventory) : 0;
|
||||
auto _color = _o->color;
|
||||
auto _weapons = _o->weapons.size() ? _fbb.CreateVector<flatbuffers::Offset<MyGame::Sample::Weapon>> (_o->weapons.size(), [](size_t i, _VectorArgs *__va) { return CreateWeapon(*__va->__fbb, __va->__o->weapons[i].get(), __va->__rehasher); }, &_va ) : 0;
|
||||
auto _weapons = _o->weapons.size() ? _fbb.CreateVector<::flatbuffers::Offset<MyGame::Sample::Weapon>> (_o->weapons.size(), [](size_t i, _VectorArgs *__va) { return CreateWeapon(*__va->__fbb, __va->__o->weapons[i].get(), __va->__rehasher); }, &_va ) : 0;
|
||||
auto _equipped_type = _o->equipped.type;
|
||||
auto _equipped = _o->equipped.Pack(_fbb);
|
||||
auto _path = _o->path.size() ? _fbb.CreateVectorOfStructs(_o->path) : 0;
|
||||
@@ -657,27 +657,27 @@ inline bool operator!=(const WeaponT &lhs, const WeaponT &rhs) {
|
||||
}
|
||||
|
||||
|
||||
inline WeaponT *Weapon::UnPack(const flatbuffers::resolver_function_t *_resolver) const {
|
||||
inline WeaponT *Weapon::UnPack(const ::flatbuffers::resolver_function_t *_resolver) const {
|
||||
auto _o = std::unique_ptr<WeaponT>(new WeaponT());
|
||||
UnPackTo(_o.get(), _resolver);
|
||||
return _o.release();
|
||||
}
|
||||
|
||||
inline void Weapon::UnPackTo(WeaponT *_o, const flatbuffers::resolver_function_t *_resolver) const {
|
||||
inline void Weapon::UnPackTo(WeaponT *_o, const ::flatbuffers::resolver_function_t *_resolver) const {
|
||||
(void)_o;
|
||||
(void)_resolver;
|
||||
{ auto _e = name(); if (_e) _o->name = _e->str(); }
|
||||
{ auto _e = damage(); _o->damage = _e; }
|
||||
}
|
||||
|
||||
inline flatbuffers::Offset<Weapon> Weapon::Pack(flatbuffers::FlatBufferBuilder &_fbb, const WeaponT* _o, const flatbuffers::rehasher_function_t *_rehasher) {
|
||||
inline ::flatbuffers::Offset<Weapon> Weapon::Pack(::flatbuffers::FlatBufferBuilder &_fbb, const WeaponT* _o, const ::flatbuffers::rehasher_function_t *_rehasher) {
|
||||
return CreateWeapon(_fbb, _o, _rehasher);
|
||||
}
|
||||
|
||||
inline flatbuffers::Offset<Weapon> CreateWeapon(flatbuffers::FlatBufferBuilder &_fbb, const WeaponT *_o, const flatbuffers::rehasher_function_t *_rehasher) {
|
||||
inline ::flatbuffers::Offset<Weapon> CreateWeapon(::flatbuffers::FlatBufferBuilder &_fbb, const WeaponT *_o, const ::flatbuffers::rehasher_function_t *_rehasher) {
|
||||
(void)_rehasher;
|
||||
(void)_o;
|
||||
struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const WeaponT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va;
|
||||
struct _VectorArgs { ::flatbuffers::FlatBufferBuilder *__fbb; const WeaponT* __o; const ::flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va;
|
||||
auto _name = _o->name.empty() ? 0 : _fbb.CreateString(_o->name);
|
||||
auto _damage = _o->damage;
|
||||
return MyGame::Sample::CreateWeapon(
|
||||
@@ -686,7 +686,7 @@ inline flatbuffers::Offset<Weapon> CreateWeapon(flatbuffers::FlatBufferBuilder &
|
||||
_damage);
|
||||
}
|
||||
|
||||
inline bool VerifyEquipment(flatbuffers::Verifier &verifier, const void *obj, Equipment type) {
|
||||
inline bool VerifyEquipment(::flatbuffers::Verifier &verifier, const void *obj, Equipment type) {
|
||||
switch (type) {
|
||||
case Equipment_NONE: {
|
||||
return true;
|
||||
@@ -699,10 +699,10 @@ inline bool VerifyEquipment(flatbuffers::Verifier &verifier, const void *obj, Eq
|
||||
}
|
||||
}
|
||||
|
||||
inline bool VerifyEquipmentVector(flatbuffers::Verifier &verifier, const flatbuffers::Vector<flatbuffers::Offset<void>> *values, const flatbuffers::Vector<uint8_t> *types) {
|
||||
inline bool VerifyEquipmentVector(::flatbuffers::Verifier &verifier, const ::flatbuffers::Vector<::flatbuffers::Offset<void>> *values, const ::flatbuffers::Vector<uint8_t> *types) {
|
||||
if (!values || !types) return !values && !types;
|
||||
if (values->size() != types->size()) return false;
|
||||
for (flatbuffers::uoffset_t i = 0; i < values->size(); ++i) {
|
||||
for (::flatbuffers::uoffset_t i = 0; i < values->size(); ++i) {
|
||||
if (!VerifyEquipment(
|
||||
verifier, values->Get(i), types->GetEnum<Equipment>(i))) {
|
||||
return false;
|
||||
@@ -711,7 +711,7 @@ inline bool VerifyEquipmentVector(flatbuffers::Verifier &verifier, const flatbuf
|
||||
return true;
|
||||
}
|
||||
|
||||
inline void *EquipmentUnion::UnPack(const void *obj, Equipment type, const flatbuffers::resolver_function_t *resolver) {
|
||||
inline void *EquipmentUnion::UnPack(const void *obj, Equipment type, const ::flatbuffers::resolver_function_t *resolver) {
|
||||
(void)resolver;
|
||||
switch (type) {
|
||||
case Equipment_Weapon: {
|
||||
@@ -722,7 +722,7 @@ inline void *EquipmentUnion::UnPack(const void *obj, Equipment type, const flatb
|
||||
}
|
||||
}
|
||||
|
||||
inline flatbuffers::Offset<void> EquipmentUnion::Pack(flatbuffers::FlatBufferBuilder &_fbb, const flatbuffers::rehasher_function_t *_rehasher) const {
|
||||
inline ::flatbuffers::Offset<void> EquipmentUnion::Pack(::flatbuffers::FlatBufferBuilder &_fbb, const ::flatbuffers::rehasher_function_t *_rehasher) const {
|
||||
(void)_rehasher;
|
||||
switch (type) {
|
||||
case Equipment_Weapon: {
|
||||
@@ -757,13 +757,13 @@ inline void EquipmentUnion::Reset() {
|
||||
type = Equipment_NONE;
|
||||
}
|
||||
|
||||
inline const flatbuffers::TypeTable *ColorTypeTable() {
|
||||
static const flatbuffers::TypeCode type_codes[] = {
|
||||
{ flatbuffers::ET_CHAR, 0, 0 },
|
||||
{ flatbuffers::ET_CHAR, 0, 0 },
|
||||
{ flatbuffers::ET_CHAR, 0, 0 }
|
||||
inline const ::flatbuffers::TypeTable *ColorTypeTable() {
|
||||
static const ::flatbuffers::TypeCode type_codes[] = {
|
||||
{ ::flatbuffers::ET_CHAR, 0, 0 },
|
||||
{ ::flatbuffers::ET_CHAR, 0, 0 },
|
||||
{ ::flatbuffers::ET_CHAR, 0, 0 }
|
||||
};
|
||||
static const flatbuffers::TypeFunction type_refs[] = {
|
||||
static const ::flatbuffers::TypeFunction type_refs[] = {
|
||||
MyGame::Sample::ColorTypeTable
|
||||
};
|
||||
static const char * const names[] = {
|
||||
@@ -771,35 +771,35 @@ inline const flatbuffers::TypeTable *ColorTypeTable() {
|
||||
"Green",
|
||||
"Blue"
|
||||
};
|
||||
static const flatbuffers::TypeTable tt = {
|
||||
flatbuffers::ST_ENUM, 3, type_codes, type_refs, nullptr, nullptr, names
|
||||
static const ::flatbuffers::TypeTable tt = {
|
||||
::flatbuffers::ST_ENUM, 3, type_codes, type_refs, nullptr, nullptr, names
|
||||
};
|
||||
return &tt;
|
||||
}
|
||||
|
||||
inline const flatbuffers::TypeTable *EquipmentTypeTable() {
|
||||
static const flatbuffers::TypeCode type_codes[] = {
|
||||
{ flatbuffers::ET_SEQUENCE, 0, -1 },
|
||||
{ flatbuffers::ET_SEQUENCE, 0, 0 }
|
||||
inline const ::flatbuffers::TypeTable *EquipmentTypeTable() {
|
||||
static const ::flatbuffers::TypeCode type_codes[] = {
|
||||
{ ::flatbuffers::ET_SEQUENCE, 0, -1 },
|
||||
{ ::flatbuffers::ET_SEQUENCE, 0, 0 }
|
||||
};
|
||||
static const flatbuffers::TypeFunction type_refs[] = {
|
||||
static const ::flatbuffers::TypeFunction type_refs[] = {
|
||||
MyGame::Sample::WeaponTypeTable
|
||||
};
|
||||
static const char * const names[] = {
|
||||
"NONE",
|
||||
"Weapon"
|
||||
};
|
||||
static const flatbuffers::TypeTable tt = {
|
||||
flatbuffers::ST_UNION, 2, type_codes, type_refs, nullptr, nullptr, names
|
||||
static const ::flatbuffers::TypeTable tt = {
|
||||
::flatbuffers::ST_UNION, 2, type_codes, type_refs, nullptr, nullptr, names
|
||||
};
|
||||
return &tt;
|
||||
}
|
||||
|
||||
inline const flatbuffers::TypeTable *Vec3TypeTable() {
|
||||
static const flatbuffers::TypeCode type_codes[] = {
|
||||
{ flatbuffers::ET_FLOAT, 0, -1 },
|
||||
{ flatbuffers::ET_FLOAT, 0, -1 },
|
||||
{ flatbuffers::ET_FLOAT, 0, -1 }
|
||||
inline const ::flatbuffers::TypeTable *Vec3TypeTable() {
|
||||
static const ::flatbuffers::TypeCode type_codes[] = {
|
||||
{ ::flatbuffers::ET_FLOAT, 0, -1 },
|
||||
{ ::flatbuffers::ET_FLOAT, 0, -1 },
|
||||
{ ::flatbuffers::ET_FLOAT, 0, -1 }
|
||||
};
|
||||
static const int64_t values[] = { 0, 4, 8, 12 };
|
||||
static const char * const names[] = {
|
||||
@@ -807,27 +807,27 @@ inline const flatbuffers::TypeTable *Vec3TypeTable() {
|
||||
"y",
|
||||
"z"
|
||||
};
|
||||
static const flatbuffers::TypeTable tt = {
|
||||
flatbuffers::ST_STRUCT, 3, type_codes, nullptr, nullptr, values, names
|
||||
static const ::flatbuffers::TypeTable tt = {
|
||||
::flatbuffers::ST_STRUCT, 3, type_codes, nullptr, nullptr, values, names
|
||||
};
|
||||
return &tt;
|
||||
}
|
||||
|
||||
inline const flatbuffers::TypeTable *MonsterTypeTable() {
|
||||
static const flatbuffers::TypeCode type_codes[] = {
|
||||
{ flatbuffers::ET_SEQUENCE, 0, 0 },
|
||||
{ flatbuffers::ET_SHORT, 0, -1 },
|
||||
{ flatbuffers::ET_SHORT, 0, -1 },
|
||||
{ flatbuffers::ET_STRING, 0, -1 },
|
||||
{ flatbuffers::ET_BOOL, 0, -1 },
|
||||
{ flatbuffers::ET_UCHAR, 1, -1 },
|
||||
{ flatbuffers::ET_CHAR, 0, 1 },
|
||||
{ flatbuffers::ET_SEQUENCE, 1, 2 },
|
||||
{ flatbuffers::ET_UTYPE, 0, 3 },
|
||||
{ flatbuffers::ET_SEQUENCE, 0, 3 },
|
||||
{ flatbuffers::ET_SEQUENCE, 1, 0 }
|
||||
inline const ::flatbuffers::TypeTable *MonsterTypeTable() {
|
||||
static const ::flatbuffers::TypeCode type_codes[] = {
|
||||
{ ::flatbuffers::ET_SEQUENCE, 0, 0 },
|
||||
{ ::flatbuffers::ET_SHORT, 0, -1 },
|
||||
{ ::flatbuffers::ET_SHORT, 0, -1 },
|
||||
{ ::flatbuffers::ET_STRING, 0, -1 },
|
||||
{ ::flatbuffers::ET_BOOL, 0, -1 },
|
||||
{ ::flatbuffers::ET_UCHAR, 1, -1 },
|
||||
{ ::flatbuffers::ET_CHAR, 0, 1 },
|
||||
{ ::flatbuffers::ET_SEQUENCE, 1, 2 },
|
||||
{ ::flatbuffers::ET_UTYPE, 0, 3 },
|
||||
{ ::flatbuffers::ET_SEQUENCE, 0, 3 },
|
||||
{ ::flatbuffers::ET_SEQUENCE, 1, 0 }
|
||||
};
|
||||
static const flatbuffers::TypeFunction type_refs[] = {
|
||||
static const ::flatbuffers::TypeFunction type_refs[] = {
|
||||
MyGame::Sample::Vec3TypeTable,
|
||||
MyGame::Sample::ColorTypeTable,
|
||||
MyGame::Sample::WeaponTypeTable,
|
||||
@@ -846,74 +846,74 @@ inline const flatbuffers::TypeTable *MonsterTypeTable() {
|
||||
"equipped",
|
||||
"path"
|
||||
};
|
||||
static const flatbuffers::TypeTable tt = {
|
||||
flatbuffers::ST_TABLE, 11, type_codes, type_refs, nullptr, nullptr, names
|
||||
static const ::flatbuffers::TypeTable tt = {
|
||||
::flatbuffers::ST_TABLE, 11, type_codes, type_refs, nullptr, nullptr, names
|
||||
};
|
||||
return &tt;
|
||||
}
|
||||
|
||||
inline const flatbuffers::TypeTable *WeaponTypeTable() {
|
||||
static const flatbuffers::TypeCode type_codes[] = {
|
||||
{ flatbuffers::ET_STRING, 0, -1 },
|
||||
{ flatbuffers::ET_SHORT, 0, -1 }
|
||||
inline const ::flatbuffers::TypeTable *WeaponTypeTable() {
|
||||
static const ::flatbuffers::TypeCode type_codes[] = {
|
||||
{ ::flatbuffers::ET_STRING, 0, -1 },
|
||||
{ ::flatbuffers::ET_SHORT, 0, -1 }
|
||||
};
|
||||
static const char * const names[] = {
|
||||
"name",
|
||||
"damage"
|
||||
};
|
||||
static const flatbuffers::TypeTable tt = {
|
||||
flatbuffers::ST_TABLE, 2, type_codes, nullptr, nullptr, nullptr, names
|
||||
static const ::flatbuffers::TypeTable tt = {
|
||||
::flatbuffers::ST_TABLE, 2, type_codes, nullptr, nullptr, nullptr, names
|
||||
};
|
||||
return &tt;
|
||||
}
|
||||
|
||||
inline const MyGame::Sample::Monster *GetMonster(const void *buf) {
|
||||
return flatbuffers::GetRoot<MyGame::Sample::Monster>(buf);
|
||||
return ::flatbuffers::GetRoot<MyGame::Sample::Monster>(buf);
|
||||
}
|
||||
|
||||
inline const MyGame::Sample::Monster *GetSizePrefixedMonster(const void *buf) {
|
||||
return flatbuffers::GetSizePrefixedRoot<MyGame::Sample::Monster>(buf);
|
||||
return ::flatbuffers::GetSizePrefixedRoot<MyGame::Sample::Monster>(buf);
|
||||
}
|
||||
|
||||
inline Monster *GetMutableMonster(void *buf) {
|
||||
return flatbuffers::GetMutableRoot<Monster>(buf);
|
||||
return ::flatbuffers::GetMutableRoot<Monster>(buf);
|
||||
}
|
||||
|
||||
inline MyGame::Sample::Monster *GetMutableSizePrefixedMonster(void *buf) {
|
||||
return flatbuffers::GetMutableSizePrefixedRoot<MyGame::Sample::Monster>(buf);
|
||||
return ::flatbuffers::GetMutableSizePrefixedRoot<MyGame::Sample::Monster>(buf);
|
||||
}
|
||||
|
||||
inline bool VerifyMonsterBuffer(
|
||||
flatbuffers::Verifier &verifier) {
|
||||
::flatbuffers::Verifier &verifier) {
|
||||
return verifier.VerifyBuffer<MyGame::Sample::Monster>(nullptr);
|
||||
}
|
||||
|
||||
inline bool VerifySizePrefixedMonsterBuffer(
|
||||
flatbuffers::Verifier &verifier) {
|
||||
::flatbuffers::Verifier &verifier) {
|
||||
return verifier.VerifySizePrefixedBuffer<MyGame::Sample::Monster>(nullptr);
|
||||
}
|
||||
|
||||
inline void FinishMonsterBuffer(
|
||||
flatbuffers::FlatBufferBuilder &fbb,
|
||||
flatbuffers::Offset<MyGame::Sample::Monster> root) {
|
||||
::flatbuffers::FlatBufferBuilder &fbb,
|
||||
::flatbuffers::Offset<MyGame::Sample::Monster> root) {
|
||||
fbb.Finish(root);
|
||||
}
|
||||
|
||||
inline void FinishSizePrefixedMonsterBuffer(
|
||||
flatbuffers::FlatBufferBuilder &fbb,
|
||||
flatbuffers::Offset<MyGame::Sample::Monster> root) {
|
||||
::flatbuffers::FlatBufferBuilder &fbb,
|
||||
::flatbuffers::Offset<MyGame::Sample::Monster> root) {
|
||||
fbb.FinishSizePrefixed(root);
|
||||
}
|
||||
|
||||
inline flatbuffers::unique_ptr<MyGame::Sample::MonsterT> UnPackMonster(
|
||||
const void *buf,
|
||||
const flatbuffers::resolver_function_t *res = nullptr) {
|
||||
const ::flatbuffers::resolver_function_t *res = nullptr) {
|
||||
return flatbuffers::unique_ptr<MyGame::Sample::MonsterT>(GetMonster(buf)->UnPack(res));
|
||||
}
|
||||
|
||||
inline flatbuffers::unique_ptr<MyGame::Sample::MonsterT> UnPackSizePrefixedMonster(
|
||||
const void *buf,
|
||||
const flatbuffers::resolver_function_t *res = nullptr) {
|
||||
const ::flatbuffers::resolver_function_t *res = nullptr) {
|
||||
return flatbuffers::unique_ptr<MyGame::Sample::MonsterT>(GetSizePrefixedMonster(buf)->UnPack(res));
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
import FlatBuffers
|
||||
|
||||
public enum MyGame_Sample_Color: Int8, Enum {
|
||||
public enum MyGame_Sample_Color: Int8, Enum, Verifiable {
|
||||
public typealias T = Int8
|
||||
public static var byteSize: Int { return MemoryLayout<Int8>.size }
|
||||
public var value: Int8 { return self.rawValue }
|
||||
@@ -12,31 +12,43 @@ public enum MyGame_Sample_Color: Int8, Enum {
|
||||
case green = 1
|
||||
case blue = 2
|
||||
|
||||
|
||||
public static var max: MyGame_Sample_Color { return .blue }
|
||||
public static var min: MyGame_Sample_Color { return .red }
|
||||
}
|
||||
|
||||
public enum MyGame_Sample_Equipment: UInt8, Enum {
|
||||
|
||||
public enum MyGame_Sample_Equipment: UInt8, UnionEnum {
|
||||
public typealias T = UInt8
|
||||
|
||||
public init?(value: T) {
|
||||
self.init(rawValue: value)
|
||||
}
|
||||
|
||||
public static var byteSize: Int { return MemoryLayout<UInt8>.size }
|
||||
public var value: UInt8 { return self.rawValue }
|
||||
case none_ = 0
|
||||
case weapon = 1
|
||||
|
||||
|
||||
public static var max: MyGame_Sample_Equipment { return .weapon }
|
||||
public static var min: MyGame_Sample_Equipment { return .none_ }
|
||||
}
|
||||
|
||||
public struct MyGame_Sample_Vec3: NativeStruct {
|
||||
|
||||
static func validateVersion() { FlatBuffersVersion_22_12_06() }
|
||||
public struct MyGame_Sample_Vec3: NativeStruct, Verifiable, FlatbuffersInitializable {
|
||||
|
||||
static func validateVersion() { FlatBuffersVersion_23_3_3() }
|
||||
|
||||
private var _x: Float32
|
||||
private var _y: Float32
|
||||
private var _z: Float32
|
||||
|
||||
public init(_ bb: ByteBuffer, o: Int32) {
|
||||
let _accessor = Struct(bb: bb, position: o)
|
||||
_x = _accessor.readBuffer(of: Float32.self, at: 0)
|
||||
_y = _accessor.readBuffer(of: Float32.self, at: 4)
|
||||
_z = _accessor.readBuffer(of: Float32.self, at: 8)
|
||||
}
|
||||
|
||||
public init(x: Float32, y: Float32, z: Float32) {
|
||||
_x = x
|
||||
_y = y
|
||||
@@ -52,11 +64,15 @@ public struct MyGame_Sample_Vec3: NativeStruct {
|
||||
public var x: Float32 { _x }
|
||||
public var y: Float32 { _y }
|
||||
public var z: Float32 { _z }
|
||||
|
||||
public static func verify<T>(_ verifier: inout Verifier, at position: Int, of type: T.Type) throws where T: Verifiable {
|
||||
try verifier.inBuffer(position: position, of: MyGame_Sample_Vec3.self)
|
||||
}
|
||||
}
|
||||
|
||||
public struct MyGame_Sample_Vec3_Mutable: FlatBufferObject {
|
||||
|
||||
static func validateVersion() { FlatBuffersVersion_22_12_06() }
|
||||
static func validateVersion() { FlatBuffersVersion_23_3_3() }
|
||||
public var __buffer: ByteBuffer! { return _accessor.bb }
|
||||
private var _accessor: Struct
|
||||
|
||||
@@ -70,14 +86,12 @@ public struct MyGame_Sample_Vec3_Mutable: FlatBufferObject {
|
||||
@discardableResult public func mutate(z: Float32) -> Bool { return _accessor.mutate(z, index: 8) }
|
||||
}
|
||||
|
||||
public struct MyGame_Sample_Monster: FlatBufferObject {
|
||||
public struct MyGame_Sample_Monster: FlatBufferObject, Verifiable {
|
||||
|
||||
static func validateVersion() { FlatBuffersVersion_22_12_06() }
|
||||
static func validateVersion() { FlatBuffersVersion_23_3_3() }
|
||||
public var __buffer: ByteBuffer! { return _accessor.bb }
|
||||
private var _accessor: Table
|
||||
|
||||
public static func getRootAsMonster(bb: ByteBuffer) -> MyGame_Sample_Monster { return MyGame_Sample_Monster(Table(bb: bb, position: Int32(bb.read(def: UOffset.self, position: bb.reader)) + Int32(bb.reader))) }
|
||||
|
||||
private init(_ t: Table) { _accessor = t }
|
||||
public init(_ bb: ByteBuffer, o: Int32) { _accessor = Table(bb: bb, position: o) }
|
||||
|
||||
@@ -104,16 +118,19 @@ public struct MyGame_Sample_Monster: FlatBufferObject {
|
||||
@discardableResult public func mutate(hp: Int16) -> Bool {let o = _accessor.offset(VTOFFSET.hp.v); return _accessor.mutate(hp, index: o) }
|
||||
public var name: String? { let o = _accessor.offset(VTOFFSET.name.v); return o == 0 ? nil : _accessor.string(at: o) }
|
||||
public var nameSegmentArray: [UInt8]? { return _accessor.getVector(at: VTOFFSET.name.v) }
|
||||
public var hasInventory: Bool { let o = _accessor.offset(VTOFFSET.inventory.v); return o == 0 ? false : true }
|
||||
public var inventoryCount: Int32 { let o = _accessor.offset(VTOFFSET.inventory.v); return o == 0 ? 0 : _accessor.vector(count: o) }
|
||||
public func inventory(at index: Int32) -> UInt8 { let o = _accessor.offset(VTOFFSET.inventory.v); return o == 0 ? 0 : _accessor.directRead(of: UInt8.self, offset: _accessor.vector(at: o) + index * 1) }
|
||||
public var inventory: [UInt8] { return _accessor.getVector(at: VTOFFSET.inventory.v) ?? [] }
|
||||
public func mutate(inventory: UInt8, at index: Int32) -> Bool { let o = _accessor.offset(VTOFFSET.inventory.v); return _accessor.directMutate(inventory, index: _accessor.vector(at: o) + index * 1) }
|
||||
public var color: MyGame_Sample_Color { let o = _accessor.offset(VTOFFSET.color.v); return o == 0 ? .blue : MyGame_Sample_Color(rawValue: _accessor.readBuffer(of: Int8.self, at: o)) ?? .blue }
|
||||
@discardableResult public func mutate(color: MyGame_Sample_Color) -> Bool {let o = _accessor.offset(VTOFFSET.color.v); return _accessor.mutate(color.rawValue, index: o) }
|
||||
public var hasWeapons: Bool { let o = _accessor.offset(VTOFFSET.weapons.v); return o == 0 ? false : true }
|
||||
public var weaponsCount: Int32 { let o = _accessor.offset(VTOFFSET.weapons.v); return o == 0 ? 0 : _accessor.vector(count: o) }
|
||||
public func weapons(at index: Int32) -> MyGame_Sample_Weapon? { let o = _accessor.offset(VTOFFSET.weapons.v); return o == 0 ? nil : MyGame_Sample_Weapon(_accessor.bb, o: _accessor.indirect(_accessor.vector(at: o) + index * 4)) }
|
||||
public var equippedType: MyGame_Sample_Equipment { let o = _accessor.offset(VTOFFSET.equippedType.v); return o == 0 ? .none_ : MyGame_Sample_Equipment(rawValue: _accessor.readBuffer(of: UInt8.self, at: o)) ?? .none_ }
|
||||
public func equipped<T: FlatbuffersInitializable>(type: T.Type) -> T? { let o = _accessor.offset(VTOFFSET.equipped.v); return o == 0 ? nil : _accessor.union(o) }
|
||||
public var hasPath: Bool { let o = _accessor.offset(VTOFFSET.path.v); return o == 0 ? false : true }
|
||||
public var pathCount: Int32 { let o = _accessor.offset(VTOFFSET.path.v); return o == 0 ? 0 : _accessor.vector(count: o) }
|
||||
public func path(at index: Int32) -> MyGame_Sample_Vec3? { let o = _accessor.offset(VTOFFSET.path.v); return o == 0 ? nil : _accessor.directRead(of: MyGame_Sample_Vec3.self, offset: _accessor.vector(at: o) + index * 12) }
|
||||
public func mutablePath(at index: Int32) -> MyGame_Sample_Vec3_Mutable? { let o = _accessor.offset(VTOFFSET.path.v); return o == 0 ? nil : MyGame_Sample_Vec3_Mutable(_accessor.bb, o: _accessor.vector(at: o) + index * 12) }
|
||||
@@ -158,16 +175,35 @@ public struct MyGame_Sample_Monster: FlatBufferObject {
|
||||
MyGame_Sample_Monster.addVectorOf(path: path, &fbb)
|
||||
return MyGame_Sample_Monster.endMonster(&fbb, start: __start)
|
||||
}
|
||||
|
||||
public static func verify<T>(_ verifier: inout Verifier, at position: Int, of type: T.Type) throws where T: Verifiable {
|
||||
var _v = try verifier.visitTable(at: position)
|
||||
try _v.visit(field: VTOFFSET.pos.p, fieldName: "pos", required: false, type: MyGame_Sample_Vec3.self)
|
||||
try _v.visit(field: VTOFFSET.mana.p, fieldName: "mana", required: false, type: Int16.self)
|
||||
try _v.visit(field: VTOFFSET.hp.p, fieldName: "hp", required: false, type: Int16.self)
|
||||
try _v.visit(field: VTOFFSET.name.p, fieldName: "name", required: false, type: ForwardOffset<String>.self)
|
||||
try _v.visit(field: VTOFFSET.inventory.p, fieldName: "inventory", required: false, type: ForwardOffset<Vector<UInt8, UInt8>>.self)
|
||||
try _v.visit(field: VTOFFSET.color.p, fieldName: "color", required: false, type: MyGame_Sample_Color.self)
|
||||
try _v.visit(field: VTOFFSET.weapons.p, fieldName: "weapons", required: false, type: ForwardOffset<Vector<ForwardOffset<MyGame_Sample_Weapon>, MyGame_Sample_Weapon>>.self)
|
||||
try _v.visit(unionKey: VTOFFSET.equippedType.p, unionField: VTOFFSET.equipped.p, unionKeyName: "equippedType", fieldName: "equipped", required: false, completion: { (verifier, key: MyGame_Sample_Equipment, pos) in
|
||||
switch key {
|
||||
case .none_:
|
||||
break // NOTE - SWIFT doesnt support none
|
||||
case .weapon:
|
||||
try ForwardOffset<MyGame_Sample_Weapon>.verify(&verifier, at: pos, of: MyGame_Sample_Weapon.self)
|
||||
}
|
||||
})
|
||||
try _v.visit(field: VTOFFSET.path.p, fieldName: "path", required: false, type: ForwardOffset<Vector<MyGame_Sample_Vec3, MyGame_Sample_Vec3>>.self)
|
||||
_v.finish()
|
||||
}
|
||||
}
|
||||
|
||||
public struct MyGame_Sample_Weapon: FlatBufferObject {
|
||||
public struct MyGame_Sample_Weapon: FlatBufferObject, Verifiable {
|
||||
|
||||
static func validateVersion() { FlatBuffersVersion_22_12_06() }
|
||||
static func validateVersion() { FlatBuffersVersion_23_3_3() }
|
||||
public var __buffer: ByteBuffer! { return _accessor.bb }
|
||||
private var _accessor: Table
|
||||
|
||||
public static func getRootAsWeapon(bb: ByteBuffer) -> MyGame_Sample_Weapon { return MyGame_Sample_Weapon(Table(bb: bb, position: Int32(bb.read(def: UOffset.self, position: bb.reader)) + Int32(bb.reader))) }
|
||||
|
||||
private init(_ t: Table) { _accessor = t }
|
||||
public init(_ bb: ByteBuffer, o: Int32) { _accessor = Table(bb: bb, position: o) }
|
||||
|
||||
@@ -196,5 +232,12 @@ public struct MyGame_Sample_Weapon: FlatBufferObject {
|
||||
MyGame_Sample_Weapon.add(damage: damage, &fbb)
|
||||
return MyGame_Sample_Weapon.endWeapon(&fbb, start: __start)
|
||||
}
|
||||
|
||||
public static func verify<T>(_ verifier: inout Verifier, at position: Int, of type: T.Type) throws where T: Verifiable {
|
||||
var _v = try verifier.visitTable(at: position)
|
||||
try _v.visit(field: VTOFFSET.name.p, fieldName: "name", required: false, type: ForwardOffset<String>.self)
|
||||
try _v.visit(field: VTOFFSET.damage.p, fieldName: "damage", required: false, type: Int16.self)
|
||||
_v.finish()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -99,20 +99,20 @@ def main():
|
||||
# Note: We did not set the `Mana` field explicitly, so we get a default value.
|
||||
assert monster.Mana() == 150
|
||||
assert monster.Hp() == 300
|
||||
assert monster.Name() == 'Orc'
|
||||
assert monster.Name() == b'Orc'
|
||||
assert monster.Color() == MyGame.Sample.Color.Color().Red
|
||||
assert monster.Pos().X() == 1.0
|
||||
assert monster.Pos().Y() == 2.0
|
||||
assert monster.Pos().Z() == 3.0
|
||||
|
||||
# Get and test the `inventory` FlatBuffer `vector`.
|
||||
for i in xrange(monster.InventoryLength()):
|
||||
for i in range(monster.InventoryLength()):
|
||||
assert monster.Inventory(i) == i
|
||||
|
||||
# Get and test the `weapons` FlatBuffer `vector` of `table`s.
|
||||
expected_weapon_names = ['Sword', 'Axe']
|
||||
expected_weapon_names = [b'Sword', b'Axe']
|
||||
expected_weapon_damages = [3, 5]
|
||||
for i in xrange(monster.WeaponsLength()):
|
||||
for i in range(monster.WeaponsLength()):
|
||||
assert monster.Weapons(i).Name() == expected_weapon_names[i]
|
||||
assert monster.Weapons(i).Damage() == expected_weapon_damages[i]
|
||||
|
||||
@@ -128,10 +128,10 @@ def main():
|
||||
union_weapon = MyGame.Sample.Weapon.Weapon()
|
||||
union_weapon.Init(monster.Equipped().Bytes, monster.Equipped().Pos)
|
||||
|
||||
assert union_weapon.Name() == "Axe"
|
||||
assert union_weapon.Name() == b"Axe"
|
||||
assert union_weapon.Damage() == 5
|
||||
|
||||
print 'The FlatBuffer was successfully created and verified!'
|
||||
print('The FlatBuffer was successfully created and verified!')
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2021 Google Inc. All rights reserved.
|
||||
* Copyright 2023 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.
|
||||
@@ -56,8 +56,8 @@ func main() {
|
||||
equippedOffset: axe)
|
||||
builder.finish(offset: orc)
|
||||
|
||||
let buf = builder.sizedByteArray
|
||||
let monster = Monster.getRootAsMonster(bb: ByteBuffer(bytes: buf))
|
||||
var buf = ByteBuffer(bytes: builder.sizedByteArray)
|
||||
let monster: Monster = try! getCheckedRoot(byteBuffer: &buffer)
|
||||
|
||||
assert(monster.mana == 150)
|
||||
assert(monster.hp == 300)
|
||||
|
||||
@@ -29,7 +29,7 @@ root_path = script_path.parent.absolute()
|
||||
print("Generating GRPC code...")
|
||||
generate_grpc_examples.GenerateGRPCExamples()
|
||||
|
||||
result = subprocess.run(["git", "diff", "--quiet"], cwd=root_path)
|
||||
result = subprocess.run(["git", "diff", "--quiet", "--ignore-cr-at-eol"], cwd=root_path)
|
||||
|
||||
if result.returncode != 0:
|
||||
print(
|
||||
|
||||
@@ -26,7 +26,7 @@ script_path = Path(__file__).parent.resolve()
|
||||
# Get the root path as an absolute path, so all derived paths are absolute.
|
||||
root_path = script_path.parent.absolute()
|
||||
|
||||
result = subprocess.run(["git", "diff", "--quiet"], cwd=root_path)
|
||||
result = subprocess.run(["git", "diff", "--quiet", "--ignore-cr-at-eol"], cwd=root_path)
|
||||
|
||||
if result.returncode != 0:
|
||||
print(
|
||||
@@ -46,7 +46,7 @@ if platform.system() == "Windows":
|
||||
gen_cmd = ["py"] + gen_cmd
|
||||
subprocess.run(gen_cmd, cwd=root_path)
|
||||
|
||||
result = subprocess.run(["git", "diff", "--quiet"], cwd=root_path)
|
||||
result = subprocess.run(["git", "diff", "--quiet", "--ignore-cr-at-eol"], cwd=root_path)
|
||||
|
||||
if result.returncode != 0:
|
||||
print(
|
||||
|
||||
1
scripts/clang-tidy-git.sh
Executable file
1
scripts/clang-tidy-git.sh
Executable file
@@ -0,0 +1 @@
|
||||
run-clang-tidy -fix -extra-arg=-std=c++11 -extra-arg=-Wno-unknown-warning-option `git diff --name-only origin/HEAD`
|
||||
@@ -14,73 +14,20 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import argparse
|
||||
import filecmp
|
||||
import glob
|
||||
import platform
|
||||
import shutil
|
||||
import subprocess
|
||||
import generate_grpc_examples
|
||||
from pathlib import Path
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument(
|
||||
"--flatc",
|
||||
help="path of the Flat C compiler relative to the root directory",
|
||||
)
|
||||
parser.add_argument("--cpp-0x", action="store_true", help="use --cpp-std c++ox")
|
||||
parser.add_argument(
|
||||
"--skip-monster-extra",
|
||||
action="store_true",
|
||||
help="skip generating tests involving monster_extra.fbs",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--skip-gen-reflection",
|
||||
action="store_true",
|
||||
help="skip generating the reflection.fbs files",
|
||||
)
|
||||
args = parser.parse_args()
|
||||
|
||||
# Get the path where this script is located so we can invoke the script from
|
||||
# any directory and have the paths work correctly.
|
||||
script_path = Path(__file__).parent.resolve()
|
||||
|
||||
# Get the root path as an absolute path, so all derived paths are absolute.
|
||||
root_path = script_path.parent.absolute()
|
||||
|
||||
# Get the location of the flatc executable, reading from the first command line
|
||||
# argument or defaulting to default names.
|
||||
flatc_exe = Path(
|
||||
("flatc" if not platform.system() == "Windows" else "flatc.exe")
|
||||
if not args.flatc
|
||||
else args.flatc
|
||||
)
|
||||
|
||||
# Find and assert flatc compiler is present.
|
||||
if root_path in flatc_exe.parents:
|
||||
flatc_exe = flatc_exe.relative_to(root_path)
|
||||
flatc_path = Path(root_path, flatc_exe)
|
||||
assert flatc_path.exists(), "Cannot find the flatc compiler " + str(flatc_path)
|
||||
from util import flatc, root_path, tests_path, args, flatc_path
|
||||
|
||||
# Specify the other paths that will be referenced
|
||||
tests_path = Path(root_path, "tests")
|
||||
swift_code_gen = Path(root_path, "tests/swift/tests/CodeGenerationTests")
|
||||
ts_code_gen = Path(root_path, "tests/ts")
|
||||
samples_path = Path(root_path, "samples")
|
||||
reflection_path = Path(root_path, "reflection")
|
||||
|
||||
# Execute the flatc compiler with the specified parameters
|
||||
def flatc(options, schema, prefix=None, include=None, data=None, cwd=tests_path):
|
||||
cmd = [str(flatc_path)] + options
|
||||
if prefix:
|
||||
cmd += ["-o"] + [prefix]
|
||||
if include:
|
||||
cmd += ["-I"] + [include]
|
||||
cmd += [schema] if isinstance(schema, str) else schema
|
||||
if data:
|
||||
cmd += [data] if isinstance(data, str) else data
|
||||
result = subprocess.run(cmd, cwd=str(cwd), check=True)
|
||||
|
||||
|
||||
# Generate the code for flatbuffers reflection schema
|
||||
def flatc_reflection(options, location, target):
|
||||
full_options = ["--no-prefix"] + options
|
||||
@@ -150,7 +97,7 @@ SWIFT_OPTS_CODE_GEN = [
|
||||
"--swift",
|
||||
"--gen-json-emit",
|
||||
"--bfbs-filenames",
|
||||
swift_code_gen
|
||||
str(swift_code_gen)
|
||||
]
|
||||
JAVA_OPTS = ["--java"]
|
||||
KOTLIN_OPTS = ["--kotlin"]
|
||||
@@ -158,6 +105,7 @@ PHP_OPTS = ["--php"]
|
||||
DART_OPTS = ["--dart"]
|
||||
PYTHON_OPTS = ["--python"]
|
||||
BINARY_OPTS = ["-b", "--schema", "--bfbs-comments", "--bfbs-builtins"]
|
||||
PROTO_OPTS = ["--proto"]
|
||||
|
||||
# Basic Usage
|
||||
|
||||
@@ -196,10 +144,10 @@ flatc(
|
||||
flatc(
|
||||
NO_INCL_OPTS
|
||||
+ TS_OPTS,
|
||||
schema="monster_test.fbs",
|
||||
prefix="ts",
|
||||
include="include_test",
|
||||
data="monsterdata_test.json",
|
||||
cwd=ts_code_gen,
|
||||
schema="../monster_test.fbs",
|
||||
include="../include_test",
|
||||
data="../monsterdata_test.json",
|
||||
)
|
||||
|
||||
flatc(
|
||||
@@ -245,6 +193,11 @@ flatc(
|
||||
data="monsterdata_test.json",
|
||||
)
|
||||
|
||||
flatc(
|
||||
PROTO_OPTS,
|
||||
schema="prototest/test.proto",
|
||||
)
|
||||
|
||||
# For Rust we currently generate two independent schemas, with namespace_test2
|
||||
# duplicating the types in namespace_test1
|
||||
flatc(
|
||||
@@ -264,37 +217,31 @@ flatc(
|
||||
|
||||
flatc(
|
||||
BASE_OPTS + TS_OPTS,
|
||||
prefix="ts/union_vector",
|
||||
schema="union_vector/union_vector.fbs",
|
||||
cwd=ts_code_gen,
|
||||
prefix="union_vector",
|
||||
schema="../union_vector/union_vector.fbs",
|
||||
)
|
||||
|
||||
flatc(
|
||||
BASE_OPTS + TS_OPTS + ["--gen-name-strings", "--gen-mutable"],
|
||||
include="include_test",
|
||||
prefix="ts",
|
||||
schema="monster_test.fbs",
|
||||
)
|
||||
|
||||
# Generate the complete flat file TS of monster.
|
||||
flatc(
|
||||
["--ts", "--gen-all", "--ts-flat-files"],
|
||||
include="include_test",
|
||||
schema="monster_test.fbs",
|
||||
prefix="ts/ts-flat-files"
|
||||
cwd=ts_code_gen,
|
||||
include="../include_test",
|
||||
schema="../monster_test.fbs",
|
||||
)
|
||||
|
||||
flatc(
|
||||
BASE_OPTS + TS_OPTS + ["-b"],
|
||||
include="include_test",
|
||||
prefix="ts",
|
||||
schema="monster_test.fbs",
|
||||
data="unicode_test.json",
|
||||
cwd=ts_code_gen,
|
||||
include="../include_test",
|
||||
schema="../monster_test.fbs",
|
||||
data="../unicode_test.json",
|
||||
)
|
||||
|
||||
flatc(
|
||||
BASE_OPTS + TS_OPTS + ["--gen-name-strings"],
|
||||
prefix="ts/union_vector",
|
||||
schema="union_vector/union_vector.fbs",
|
||||
cwd=ts_code_gen,
|
||||
prefix="union_vector",
|
||||
schema="../union_vector/union_vector.fbs",
|
||||
)
|
||||
|
||||
flatc(
|
||||
@@ -394,7 +341,7 @@ flatc(
|
||||
# Optional Scalars
|
||||
optional_scalars_schema = "optional_scalars.fbs"
|
||||
flatc(["--java", "--kotlin", "--lobster"], schema=optional_scalars_schema)
|
||||
flatc(TS_OPTS, schema=optional_scalars_schema, prefix="ts")
|
||||
flatc(TS_OPTS, cwd=ts_code_gen, schema="../optional_scalars.fbs")
|
||||
|
||||
flatc(["--csharp", "--python", "--gen-object-api"], schema=optional_scalars_schema)
|
||||
|
||||
@@ -407,6 +354,13 @@ type_field_collsion_schema = "type_field_collsion.fbs"
|
||||
|
||||
flatc(["--csharp", "--gen-object-api"], schema=type_field_collsion_schema)
|
||||
|
||||
# Union / value collision
|
||||
flatc(
|
||||
CS_OPTS + ["--gen-object-api", "--gen-onefile"],
|
||||
prefix="union_value_collsion",
|
||||
schema="union_value_collision.fbs"
|
||||
)
|
||||
|
||||
# Generate string/vector default code for tests
|
||||
flatc(RUST_OPTS, prefix="more_defaults", schema="more_defaults.fbs")
|
||||
|
||||
@@ -470,6 +424,15 @@ flatc(
|
||||
cwd=swift_code_gen
|
||||
)
|
||||
|
||||
# Swift Wasm Tests
|
||||
swift_Wasm_prefix = "swift/Wasm.tests/Tests/FlatBuffers.Test.Swift.WasmTests"
|
||||
flatc(
|
||||
SWIFT_OPTS + BASE_OPTS,
|
||||
schema="monster_test.fbs",
|
||||
include="include_test",
|
||||
prefix=swift_Wasm_prefix,
|
||||
)
|
||||
|
||||
# Nim Tests
|
||||
NIM_OPTS = BASE_OPTS + ["--nim"]
|
||||
flatc(NIM_OPTS, schema="monster_test.fbs", include="include_test")
|
||||
@@ -544,6 +507,12 @@ if not args.skip_gen_reflection:
|
||||
# Python Reflection
|
||||
flatc_reflection(["-p"], "python/flatbuffers", "reflection")
|
||||
|
||||
# Java Reflection
|
||||
flatc_reflection(
|
||||
["-j", "--java-package-prefix", "com.google.flatbuffers"],
|
||||
"java/src/main/java", "com/google/flatbuffers/reflection"
|
||||
)
|
||||
|
||||
# Annotation
|
||||
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ from pathlib import Path
|
||||
|
||||
grpc_examples_path = Path(root_path, "grpc/examples")
|
||||
|
||||
greeter_schema = Path(grpc_examples_path, "greeter.fbs")
|
||||
greeter_schema = str(Path(grpc_examples_path, "greeter.fbs"))
|
||||
|
||||
COMMON_ARGS = [
|
||||
"--grpc",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
|
||||
printf -v year '%(%y)T' -1
|
||||
printf -v month '%(%m)T' -1
|
||||
printf -v day '%(%d)T' -1
|
||||
printf -v month '%(%-m)T' -1
|
||||
printf -v day '%(%-d)T' -1
|
||||
|
||||
version="$year.$month.$day"
|
||||
version_underscore="$year\_$month\_$day"
|
||||
|
||||
@@ -12,20 +12,44 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import argparse
|
||||
import platform
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument(
|
||||
"--flatc",
|
||||
help="path of the Flat C compiler relative to the root directory",
|
||||
)
|
||||
parser.add_argument("--cpp-0x", action="store_true", help="use --cpp-std c++ox")
|
||||
parser.add_argument(
|
||||
"--skip-monster-extra",
|
||||
action="store_true",
|
||||
help="skip generating tests involving monster_extra.fbs",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--skip-gen-reflection",
|
||||
action="store_true",
|
||||
help="skip generating the reflection.fbs files",
|
||||
)
|
||||
args = parser.parse_args()
|
||||
|
||||
# Get the path where this script is located so we can invoke the script from
|
||||
# any directory and have the paths work correctly.
|
||||
script_path = Path(__file__).parent.resolve()
|
||||
|
||||
# Get the root path as an absolute path, so all derived paths are absolute.
|
||||
root_path = script_path.parent.absolute()
|
||||
tests_path = Path(root_path, "tests")
|
||||
|
||||
# Get the location of the flatc executable, reading from the first command line
|
||||
# argument or defaulting to default names.
|
||||
flatc_exe = Path("flatc" if not platform.system() == "Windows" else "flatc.exe")
|
||||
flatc_exe = Path(
|
||||
("flatc" if not platform.system() == "Windows" else "flatc.exe")
|
||||
if not args.flatc
|
||||
else args.flatc
|
||||
)
|
||||
|
||||
# Find and assert flatc compiler is present.
|
||||
if root_path in flatc_exe.parents:
|
||||
@@ -34,18 +58,13 @@ flatc_path = Path(root_path, flatc_exe)
|
||||
assert flatc_path.exists(), "Cannot find the flatc compiler " + str(flatc_path)
|
||||
|
||||
# Execute the flatc compiler with the specified parameters
|
||||
def flatc(options, schema, prefix=None, include=None, data=None, cwd=root_path):
|
||||
def flatc(options, schema, prefix=None, include=None, data=None, cwd=tests_path):
|
||||
cmd = [str(flatc_path)] + options
|
||||
if prefix:
|
||||
cmd += ["-o"] + [prefix]
|
||||
if include:
|
||||
cmd += ["-I"] + [include]
|
||||
if isinstance(schema, Path):
|
||||
cmd += [str(schema)]
|
||||
elif isinstance(schema, str):
|
||||
cmd += [schema]
|
||||
else:
|
||||
cmd += schema
|
||||
cmd += [schema] if isinstance(schema, str) else schema
|
||||
if data:
|
||||
cmd += [data] if isinstance(data, str) else data
|
||||
return subprocess.check_call(cmd, cwd=str(cwd))
|
||||
result = subprocess.run(cmd, cwd=str(cwd), check=True)
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user