├── bazel └── BUILD.bazel ├── grpc ├── BUILD.bazel ├── examples │ ├── python │ │ └── greeter │ │ │ ├── models │ │ │ └── __init__.py │ │ │ └── README.md │ ├── go │ │ ├── greeter │ │ │ ├── .gitignore │ │ │ ├── models │ │ │ │ └── go.mod │ │ │ ├── client │ │ │ │ └── go.mod │ │ │ ├── server │ │ │ │ └── go.mod │ │ │ └── README.md │ │ └── format.sh │ ├── ts │ │ └── greeter │ │ │ ├── src │ │ │ ├── greeter.ts │ │ │ └── greeter_generated.ts │ │ │ ├── README.md │ │ │ ├── package.json │ │ │ └── tsconfig.json │ ├── swift │ │ └── Greeter │ │ │ └── README.md │ └── greeter.fbs ├── tests │ ├── java-grpc-test.sh │ └── BUILD ├── boringssl.patch ├── samples │ └── greeter │ │ ├── greeter.fbs │ │ └── Makefile ├── src │ └── compiler │ │ └── ts_generator.h └── build_grpc.sh ├── python ├── __init__.py ├── flatbuffers │ ├── reflection │ │ ├── __init__.py │ │ ├── AdvancedFeatures.py │ │ └── BaseType.py │ ├── _version.py │ └── __init__.py ├── .gitignore └── setup.cfg ├── tests ├── MyGame │ ├── __init__.py │ ├── Example │ │ ├── __init__.py │ │ ├── TestEnum.py │ │ ├── LongEnum.py │ │ ├── Race.py │ │ ├── Color.py │ │ ├── LongEnum.kt │ │ ├── LongEnum.java │ │ ├── TestEnum.cs │ │ ├── Race.cs │ │ ├── Race.lua │ │ ├── LongEnum.cs │ │ ├── TestEnum.kt │ │ ├── LongEnum.lua │ │ ├── Any.lua │ │ ├── AnyUniqueAliases.lua │ │ ├── TestEnum.java │ │ ├── AnyAmbiguousAliases.lua │ │ ├── ReferrableT.java │ │ ├── AnyUniqueAliases.kt │ │ ├── Race.kt │ │ ├── AnyAmbiguousAliases.kt │ │ ├── TestSimpleTableWithEnumT.java │ │ ├── Race.java │ │ ├── AnyUniqueAliases.java │ │ ├── AnyAmbiguousAliases.java │ │ ├── Color.cs │ │ ├── Color.lua │ │ ├── Any.kt │ │ ├── TestT.java │ │ ├── Any.java │ │ ├── StructOfStructsOfStructsT.java │ │ ├── LongEnum.php │ │ ├── Race.php │ │ ├── AbilityT.java │ │ ├── AnyUniqueAliases.php │ │ ├── AnyAmbiguousAliases.php │ │ ├── Color.java │ │ ├── Race.go │ │ ├── Color.kt │ │ ├── Any.php │ │ ├── Color.php │ │ ├── LongEnum.go │ │ ├── StatT.java │ │ ├── Color.go │ │ ├── AnyAmbiguousAliases.py │ │ ├── ArrayTableT.java │ │ └── AnyUniqueAliases.py │ ├── Example2 │ │ ├── __init__.py │ │ ├── MonsterT.java │ │ └── Monster.lua │ ├── InParentNamespaceT.java │ ├── OtherNameSpace │ │ ├── FromInclude.lua │ │ ├── UnusedT.java │ │ ├── TableBT.java │ │ └── Unused.lua │ └── InParentNamespace.lua ├── optional_scalars │ ├── __init__.py │ ├── optional-byte.ts │ ├── OptionalByte.py │ ├── OptionalByte.cs │ ├── mod.rs │ ├── optional-byte.js │ ├── OptionalByte.kt │ ├── OptionalByte.java │ └── OptionalByte.go ├── namespace_test │ ├── NamespaceA │ │ ├── __init__.py │ │ ├── NamespaceB │ │ │ ├── __init__.py │ │ │ ├── EnumInNestedNS.py │ │ │ ├── EnumInNestedNS.lua │ │ │ ├── UnionInNestedNS.lua │ │ │ ├── EnumInNestedNS.cs │ │ │ ├── EnumInNestedNS.kt │ │ │ ├── UnionInNestedNS.java │ │ │ ├── UnionInNestedNS.kt │ │ │ ├── EnumInNestedNS.java │ │ │ ├── TableInNestedNST.java │ │ │ ├── UnionInNestedNS.py │ │ │ ├── UnionInNestedNS.php │ │ │ ├── EnumInNestedNS.php │ │ │ ├── StructInNestedNST.java │ │ │ └── EnumInNestedNS.go │ │ └── SecondTableInAT.java │ ├── NamespaceC │ │ ├── __init__.py │ │ └── TableInCT.java │ ├── namespace-a │ │ └── namespace-b │ │ │ ├── enum-in-nested-n-s.ts │ │ │ └── enum-in-nested-n-s.js │ ├── namespace_test1.fbs │ ├── namespace_test1.ts │ ├── namespace_test2.fbs │ ├── namespace_test2.ts │ └── mod.rs ├── rust_usage_test │ ├── outdir │ │ ├── .gitignore │ │ ├── Cargo.toml │ │ └── src │ │ │ └── main.rs │ ├── tests │ │ └── flexbuffers_tests │ │ │ └── mod.rs │ └── bin │ │ └── monster_example.rs ├── docker │ ├── TODO.Dockerfile.testing.python.cpython_with_conda │ ├── TODO.Dockerfile.testing.python.cpython_with_numpy │ ├── languages │ │ ├── Dockerfile.testing.node.12_20_1 │ │ ├── Dockerfile.testing.node.14_15_4 │ │ ├── Dockerfile.testing.golang.1_11 │ │ ├── Dockerfile.testing.rust.1_51_0 │ │ ├── Dockerfile.testing.java.openjdk_10_0_2 │ │ ├── Dockerfile.testing.java.openjdk_11_0_1 │ │ ├── Dockerfile.testing.swift_5_2 │ │ ├── Dockerfile.testing.csharp.mono_5_18 │ │ ├── Dockerfile.testing.php.zend_7_3 │ │ ├── Dockerfile.testing.python.cpython_2_7_15 │ │ ├── Dockerfile.testing.python.cpython_3_7_1 │ │ ├── Dockerfile.testing.rust.nightly │ │ ├── Dockerfile.testing.python.numpy.cpython_3_7_1 │ │ ├── Dockerfile.testing.python.numpy.cpython_2_7_15 │ │ └── Dockerfile.testing.rust.big_endian.1_51_0 │ ├── TODO.Dockerfile.testing.python.pypy_6_0_0_py2 │ ├── TODO.Dockerfile.testing.python.pypy_6_0_0_py3 │ ├── Dockerfile.testing.build_flatc_debian_stretch │ ├── Dockerfile.testing.cpp.debian_buster │ ├── build_flatc.run.sh │ ├── cpp_test.run.sh │ └── TODO.Dockerfile.testing.php.hhvm_2019_01_16 ├── included_test.fbs ├── FlatBuffers.Test.Swift.Wasm │ └── Sources │ │ └── Wasm │ │ └── Wasm.swift ├── include_build_test.cc ├── name_clash_test │ ├── invalid_test2.fbs │ ├── valid_test2.fbs │ ├── valid_test1.fbs │ └── invalid_test1.fbs ├── flatc │ ├── bar │ │ ├── bar.fbs │ │ ├── baz │ │ │ ├── baz.fbs │ │ │ └── baz_with_ns.fbs │ │ ├── bar_with_foo.fbs │ │ └── bar_with_ns.fbs │ ├── foo_with_ns.fbs │ └── foo.fbs ├── FlatBuffers.Test │ ├── .gitignore │ ├── packages.config │ ├── clean.sh │ ├── NetTest.bat │ ├── FlatBuffersTestMethodAttribute.cs │ └── README.md ├── javatest.bin ├── optional_scalars.ts ├── arrays_test.bfbs ├── monster_test.afb ├── unicode_test.mon ├── monster_test.bfbs ├── includer_test.fbs ├── monsterdata_test.mon ├── test_dir │ ├── typescript_transitive_include.fbs │ ├── typescript_include.fbs │ └── BUILD.bazel ├── FlatBuffers.Test.Swift │ ├── CodeGenerationTests │ │ ├── test_import.fbs │ │ └── test_no_include.fbs │ ├── monsterdata_test.mon │ ├── Sources │ │ └── SwiftFlatBuffers │ │ │ └── fuzzer.fbs │ └── Tests │ │ └── LinuxMain.swift ├── monsterdata_go_wire.mon.sp ├── gold_flexbuffer_example.bin ├── monsterdata_python_wire.mon ├── nested_namespace_test │ ├── nested_namespace_test1.fbs │ ├── nested_namespace_test2.fbs │ ├── nested_namespace_test3.fbs │ ├── nested_namespace_test2_generated.cs │ └── nested_namespace_test1_generated.cs ├── prototest │ └── imported.proto ├── MutatingBool.fbs ├── annotated_binary │ ├── tests │ │ ├── invalid_root_table_too_short.bin │ │ ├── invalid_root_offset.bin │ │ ├── invalid_vtable_size.bin │ │ ├── invalid_string_length.bin │ │ ├── invalid_table_field_size.bin │ │ ├── invalid_union_type_value.bin │ │ ├── invalid_table_field_offset.bin │ │ ├── invalid_vtable_field_offset.bin │ │ ├── invalid_vtable_size_short.bin │ │ ├── invalid_vtable_ref_table_size.bin │ │ ├── invalid_root_table_vtable_offset.bin │ │ ├── invalid_string_length_cut_short.bin │ │ ├── invalid_struct_field_cut_short.bin │ │ ├── invalid_vector_length_cut_short.bin │ │ ├── invalid_vector_scalars_cut_short.bin │ │ ├── invalid_vector_strings_cut_short.bin │ │ ├── invalid_vector_structs_cut_short.bin │ │ ├── invalid_vector_tables_cut_short.bin │ │ ├── invalid_vector_union_type_value.bin │ │ ├── invalid_vector_unions_cut_short.bin │ │ ├── invalid_struct_array_field_cut_short.bin │ │ └── invalid_vtable_ref_table_size_short.bin │ ├── annotated_binary.bfbs │ └── annotated_binary.bin ├── package.json ├── LuaTest.bat ├── vector_has_test.fbs ├── phpUnionVectorTest.sh ├── my-game │ └── example │ │ ├── race.ts │ │ ├── long-enum.ts │ │ ├── race.js │ │ ├── color.ts │ │ └── color.js ├── optional-scalars │ └── optional-byte.ts ├── type_field_collsion.fbs ├── dictionary_lookup.fbs ├── optional_scalars_generated.ts ├── include_test │ ├── include_test1.fbs │ └── sub │ │ └── include_test2.fbs ├── more_defaults │ └── mod.rs ├── more_defaults.fbs ├── private_annotation_test.fbs ├── KeywordTest │ ├── public.cs │ └── ABC.cs ├── keyword_test.fbs ├── rust_serialize_test │ └── Cargo.toml ├── fuzzer │ ├── .gitignore │ ├── scalar_fuzzer.dict │ ├── fuzzer_assert.h │ ├── flatbuffers_verifier_fuzzer.cc │ ├── monster_fuzzer.dict │ └── flexbuffers_verifier_fuzzer.cc ├── private_annotation_test │ └── mod.rs ├── optional_scalars.json ├── evolution_test │ ├── evolution_v1.json │ ├── evolution_v2.json │ └── evolution_v1.fbs ├── union_vector │ ├── Gadget.kt │ ├── HandFanT.java │ ├── FallingTubT.java │ ├── Gadget.java │ ├── union_vector.json │ ├── union_vector.js │ ├── union_vector.ts │ ├── BookReaderT.java │ ├── RapunzelT.java │ ├── AttackerT.java │ ├── union_vector_generated.ts │ ├── Gadget.php │ ├── Character.kt │ ├── Character.java │ ├── FallingTub.kt │ ├── Character.php │ ├── BookReader.kt │ ├── Rapunzel.kt │ └── union_vector.fbs ├── arrays_test.fbs ├── keyword_test │ └── mod.rs ├── native_type_test.fbs ├── TableAT.java ├── monsterdata_extra.json ├── typescript_keywords.fbs ├── arrays_test.golden ├── unicode_test.json ├── include_test1 │ └── mod.rs ├── include_test2 │ └── mod.rs ├── arrays_test │ └── mod.rs ├── monster_extra.fbs ├── tsconfig.json ├── native_type_test_impl.cpp ├── optional_scalars_defaults.json ├── FlatBuffers.Benchmarks │ └── FlatBuffers.Benchmarks.csproj ├── native_type_test_impl.h ├── LuaTest.sh └── RustTest.bat ├── android ├── app │ ├── .gitignore │ ├── src │ │ └── main │ │ │ ├── res │ │ │ ├── values │ │ │ │ ├── strings.xml │ │ │ │ ├── colors.xml │ │ │ │ └── styles.xml │ │ │ ├── mipmap-hdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-mdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xxhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xxxhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-anydpi-v26 │ │ │ │ ├── ic_launcher.xml │ │ │ │ └── ic_launcher_round.xml │ │ │ └── layout │ │ │ │ └── activity_main.xml │ │ │ ├── AndroidManifest.xml │ │ │ └── fbs │ │ │ └── animal.fbs │ └── proguard-rules.pro ├── settings.gradle ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties └── build.gradle ├── docs ├── source │ ├── CONTRIBUTING.md │ ├── groups │ └── gRPC │ │ └── CppUsage.md ├── images │ ├── ftv2mnode.png │ ├── ftv2pnode.png │ └── fpl_logo_small.png └── footer.html ├── kotlin ├── benchmark │ └── src │ │ └── jvmMain │ │ └── java ├── settings.gradle.kts ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── gradle.properties └── spotless │ └── spotless.kt ├── dart ├── analysis_options.yaml ├── lib │ └── flex_buffers.dart ├── test │ ├── monsterdata_test.mon │ ├── list_of_enums.fbs │ └── bool_structs.fbs └── pubspec.yaml ├── rust ├── flexbuffers │ └── .gitignore └── flatbuffers │ └── README.md ├── swift ├── Sources │ └── FlatBuffers │ │ └── Documentation.docc │ │ ├── Resources │ │ ├── code │ │ │ ├── fbs │ │ │ │ ├── monster_step_1.fbs │ │ │ │ ├── monster_step_2.fbs │ │ │ │ ├── monster_step_3.fbs │ │ │ │ ├── monster_step_4.fbs │ │ │ │ ├── monster_step_5.fbs │ │ │ │ ├── monster_step_6.fbs │ │ │ │ └── monster_step_7.fbs │ │ │ └── swift │ │ │ │ ├── swift_code_1.swift │ │ │ │ ├── swift_code_2.swift │ │ │ │ ├── swift_code_3.swift │ │ │ │ ├── swift_code_4.swift │ │ │ │ ├── swift_code_11.swift │ │ │ │ ├── swift_code_12.swift │ │ │ │ ├── swift_code_5.swift │ │ │ │ └── swift_code_13.swift │ │ └── images │ │ │ └── tutorial_cover_image_1.png │ │ └── Tutorials │ │ └── Tutorial_Table_of_Contents.tutorial ├── BUILD.bazel ├── README.md └── FlatBuffers.podspec ├── ts ├── encoding.ts ├── flexbuffers │ ├── bit-width.ts │ ├── flexbuffers-util.ts │ └── value-type.ts ├── constants.ts ├── utils.ts ├── types.ts ├── index.ts └── flexbuffers.ts ├── samples ├── monster.bfbs ├── lua │ └── MyGame │ │ └── Sample │ │ ├── Equipment.lua │ │ └── Color.lua ├── monsterdata.json ├── rust_generated │ └── mod.rs └── monster.fbs ├── .gitattributes ├── go ├── doc.go ├── struct.go ├── BUILD.bazel └── lib.go ├── js └── README.md ├── mjs └── README.md ├── reflection ├── BUILD.bazel └── ts │ └── BUILD.bazel ├── lua ├── flatbuffers.lua └── flatbuffers │ ├── compat_5_3.lua │ ├── compat_5_1.lua │ └── compat.lua ├── conan ├── appveyor │ ├── build.py │ └── install.py ├── travis │ ├── build.sh │ └── install.sh ├── test_package │ ├── CMakeLists.txt │ └── conanfile.py └── CMakeLists.txt ├── CMake ├── FlatBuffersConfig.cmake ├── DESCRIPTION.txt ├── flatbuffers.pc.in └── FlatBuffersConfigVersion.cmake.in ├── .editorconfig ├── benchmarks └── cpp │ ├── raw │ └── raw_bench.h │ ├── bench.h │ └── flatbuffers │ └── fb_bench.h ├── scripts ├── clang-format-all.sh └── clang-format-git.sh ├── .eslintrc.js ├── .clang-format ├── tsconfig.json ├── tsconfig.mjs.json ├── composer.json ├── SECURITY.md ├── .github ├── ISSUE_TEMPLATE.md ├── workflows │ ├── label.yml │ ├── stale.yml │ └── main.yml └── PULL_REQUEST_TEMPLATE.md ├── php └── Constants.php ├── CHANGELOG.md └── net └── FlatBuffers └── IFlatbufferObject.cs /bazel/BUILD.bazel: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /grpc/BUILD.bazel: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /python/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/MyGame/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /android/app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /tests/MyGame/Example/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/MyGame/Example2/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/optional_scalars/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /python/flatbuffers/reflection/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/namespace_test/NamespaceA/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/namespace_test/NamespaceC/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/source/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | ../../CONTRIBUTING.md -------------------------------------------------------------------------------- /grpc/examples/python/greeter/models/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /python/.gitignore: -------------------------------------------------------------------------------- 1 | /dist/ 2 | /*.egg-info/ 3 | -------------------------------------------------------------------------------- /kotlin/benchmark/src/jvmMain/java: -------------------------------------------------------------------------------- 1 | ../../../../java/ -------------------------------------------------------------------------------- /python/setup.cfg: -------------------------------------------------------------------------------- 1 | [bdist_wheel] 2 | universal=1 3 | -------------------------------------------------------------------------------- /grpc/examples/go/greeter/.gitignore: -------------------------------------------------------------------------------- 1 | **/server 2 | **/client -------------------------------------------------------------------------------- /tests/namespace_test/NamespaceA/NamespaceB/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/rust_usage_test/outdir/.gitignore: -------------------------------------------------------------------------------- 1 | src/generated 2 | -------------------------------------------------------------------------------- /tests/docker/TODO.Dockerfile.testing.python.cpython_with_conda: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/docker/TODO.Dockerfile.testing.python.cpython_with_numpy: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/included_test.fbs: -------------------------------------------------------------------------------- 1 | table Wrapped { 2 | a:double; 3 | } 4 | -------------------------------------------------------------------------------- /dart/analysis_options.yaml: -------------------------------------------------------------------------------- 1 | include: package:lints/recommended.yaml 2 | -------------------------------------------------------------------------------- /rust/flexbuffers/.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | **/*.rs.bk 3 | Cargo.lock 4 | -------------------------------------------------------------------------------- /tests/FlatBuffers.Test.Swift.Wasm/Sources/Wasm/Wasm.swift: -------------------------------------------------------------------------------- 1 | public struct Wasm {} -------------------------------------------------------------------------------- /tests/include_build_test.cc: -------------------------------------------------------------------------------- 1 | #include "tests/includer_test_generated.h" 2 | -------------------------------------------------------------------------------- /tests/name_clash_test/invalid_test2.fbs: -------------------------------------------------------------------------------- 1 | namespace A; 2 | 3 | union X {} 4 | -------------------------------------------------------------------------------- /tests/name_clash_test/valid_test2.fbs: -------------------------------------------------------------------------------- 1 | namespace B; 2 | 3 | union X {} 4 | -------------------------------------------------------------------------------- /android/settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | rootProject.name = "FlatbuffersTest" 3 | -------------------------------------------------------------------------------- /swift/Sources/FlatBuffers/Documentation.docc/Resources/code/fbs/monster_step_1.fbs: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /tests/flatc/bar/bar.fbs: -------------------------------------------------------------------------------- 1 | include "baz/baz.fbs"; 2 | 3 | table Bar { 4 | baz:Baz; 5 | } -------------------------------------------------------------------------------- /dart/lib/flex_buffers.dart: -------------------------------------------------------------------------------- 1 | export 'src/builder.dart'; 2 | export 'src/reference.dart'; 3 | -------------------------------------------------------------------------------- /tests/FlatBuffers.Test/.gitignore: -------------------------------------------------------------------------------- 1 | dotnet-install.sh 2 | .dotnet_tmp/ 3 | .tmp/ 4 | packages/ -------------------------------------------------------------------------------- /ts/encoding.ts: -------------------------------------------------------------------------------- 1 | export enum Encoding { 2 | UTF8_BYTES = 1, 3 | UTF16_STRING = 2 4 | } -------------------------------------------------------------------------------- /samples/monster.bfbs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/englercj/flatbuffers/master/samples/monster.bfbs -------------------------------------------------------------------------------- /tests/javatest.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/englercj/flatbuffers/master/tests/javatest.bin -------------------------------------------------------------------------------- /tests/optional_scalars.ts: -------------------------------------------------------------------------------- 1 | export { OptionalByte } from './optional-scalars/optional-byte'; 2 | -------------------------------------------------------------------------------- /tests/arrays_test.bfbs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/englercj/flatbuffers/master/tests/arrays_test.bfbs -------------------------------------------------------------------------------- /tests/flatc/bar/baz/baz.fbs: -------------------------------------------------------------------------------- 1 | enum Baz : short { 2 | None = 0, 3 | Red, 4 | Green, 5 | Blue, 6 | } -------------------------------------------------------------------------------- /tests/monster_test.afb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/englercj/flatbuffers/master/tests/monster_test.afb -------------------------------------------------------------------------------- /tests/unicode_test.mon: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/englercj/flatbuffers/master/tests/unicode_test.mon -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Set the default behavior, in case people don't have core.autocrlf set. 2 | * text=auto 3 | -------------------------------------------------------------------------------- /docs/images/ftv2mnode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/englercj/flatbuffers/master/docs/images/ftv2mnode.png -------------------------------------------------------------------------------- /docs/images/ftv2pnode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/englercj/flatbuffers/master/docs/images/ftv2pnode.png -------------------------------------------------------------------------------- /swift/Sources/FlatBuffers/Documentation.docc/Resources/code/swift/swift_code_1.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | -------------------------------------------------------------------------------- /tests/monster_test.bfbs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/englercj/flatbuffers/master/tests/monster_test.bfbs -------------------------------------------------------------------------------- /tests/includer_test.fbs: -------------------------------------------------------------------------------- 1 | include "tests/included_test.fbs"; 2 | 3 | table Wrapper { 4 | a:Wrapped; 5 | } 6 | -------------------------------------------------------------------------------- /tests/monsterdata_test.mon: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/englercj/flatbuffers/master/tests/monsterdata_test.mon -------------------------------------------------------------------------------- /tests/name_clash_test/valid_test1.fbs: -------------------------------------------------------------------------------- 1 | include "valid_test2.fbs"; 2 | 3 | namespace A; 4 | 5 | table X {} 6 | -------------------------------------------------------------------------------- /tests/test_dir/typescript_transitive_include.fbs: -------------------------------------------------------------------------------- 1 | namespace foobar; 2 | 3 | enum Abc: int { 4 | a, 5 | } 6 | -------------------------------------------------------------------------------- /dart/test/monsterdata_test.mon: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/englercj/flatbuffers/master/dart/test/monsterdata_test.mon -------------------------------------------------------------------------------- /docs/images/fpl_logo_small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/englercj/flatbuffers/master/docs/images/fpl_logo_small.png -------------------------------------------------------------------------------- /tests/FlatBuffers.Test.Swift/CodeGenerationTests/test_import.fbs: -------------------------------------------------------------------------------- 1 | table Message { 2 | internal_message: string; 3 | } -------------------------------------------------------------------------------- /tests/name_clash_test/invalid_test1.fbs: -------------------------------------------------------------------------------- 1 | include "invalid_test2.fbs"; 2 | 3 | namespace A; 4 | 5 | table X {} 6 | -------------------------------------------------------------------------------- /swift/Sources/FlatBuffers/Documentation.docc/Resources/code/fbs/monster_step_2.fbs: -------------------------------------------------------------------------------- 1 | enum Color:byte { red, green, blue } 2 | -------------------------------------------------------------------------------- /tests/monsterdata_go_wire.mon.sp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/englercj/flatbuffers/master/tests/monsterdata_go_wire.mon.sp -------------------------------------------------------------------------------- /go/doc.go: -------------------------------------------------------------------------------- 1 | // Package flatbuffers provides facilities to read and write flatbuffers 2 | // objects. 3 | package flatbuffers 4 | -------------------------------------------------------------------------------- /tests/flatc/bar/bar_with_foo.fbs: -------------------------------------------------------------------------------- 1 | include "foo.fbs"; 2 | include "baz/baz.fbs"; 3 | 4 | table BarWithFoo { 5 | foo:Foo; 6 | } -------------------------------------------------------------------------------- /tests/gold_flexbuffer_example.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/englercj/flatbuffers/master/tests/gold_flexbuffer_example.bin -------------------------------------------------------------------------------- /tests/monsterdata_python_wire.mon: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/englercj/flatbuffers/master/tests/monsterdata_python_wire.mon -------------------------------------------------------------------------------- /tests/nested_namespace_test/nested_namespace_test1.fbs: -------------------------------------------------------------------------------- 1 | namespace NamespaceB; 2 | 3 | enum Color:byte { Red, Green, Blue } 4 | -------------------------------------------------------------------------------- /tests/nested_namespace_test/nested_namespace_test2.fbs: -------------------------------------------------------------------------------- 1 | namespace NamespaceA.NamespaceB; 2 | 3 | enum Color:byte { Purple } 4 | -------------------------------------------------------------------------------- /tests/prototest/imported.proto: -------------------------------------------------------------------------------- 1 | package proto.test; 2 | 3 | message ImportedMessage { 4 | optional int32 a = 26; 5 | } 6 | -------------------------------------------------------------------------------- /js/README.md: -------------------------------------------------------------------------------- 1 | This folder is intentionally empty and will contain transpiled js modules in Common JS format after compiling with tsc. -------------------------------------------------------------------------------- /kotlin/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | rootProject.name = "flatbuffers-kotlin" 2 | include("flatbuffers-kotlin") 3 | include("benchmark") 4 | -------------------------------------------------------------------------------- /mjs/README.md: -------------------------------------------------------------------------------- 1 | This folder is intentionally empty and will contain transpiled js modules in ES modules format after compiling with tsc. -------------------------------------------------------------------------------- /swift/Sources/FlatBuffers/Documentation.docc/Resources/code/swift/swift_code_2.swift: -------------------------------------------------------------------------------- 1 | import FlatBuffers 2 | import Foundation 3 | -------------------------------------------------------------------------------- /ts/flexbuffers/bit-width.ts: -------------------------------------------------------------------------------- 1 | export enum BitWidth { 2 | WIDTH8 = 0, 3 | WIDTH16 = 1, 4 | WIDTH32 = 2, 5 | WIDTH64 = 3, 6 | } -------------------------------------------------------------------------------- /android/app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | FlatbuffersTestApp 3 | 4 | -------------------------------------------------------------------------------- /kotlin/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/englercj/flatbuffers/master/kotlin/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /tests/MutatingBool.fbs: -------------------------------------------------------------------------------- 1 | 2 | struct Property { 3 | property: bool; 4 | } 5 | 6 | table TestMutatingBool { 7 | b: Property; 8 | } 9 | -------------------------------------------------------------------------------- /tests/annotated_binary/tests/invalid_root_table_too_short.bin: -------------------------------------------------------------------------------- 1 | DANNO:h 04 8<@DHLPTX 2 | \ `d: -------------------------------------------------------------------------------- /tests/flatc/bar/baz/baz_with_ns.fbs: -------------------------------------------------------------------------------- 1 | namespace baz; 2 | 3 | enum Baz : short { 4 | None = 0, 5 | Red, 6 | Green, 7 | Blue, 8 | } -------------------------------------------------------------------------------- /android/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/englercj/flatbuffers/master/android/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /grpc/tests/java-grpc-test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # NOTE: make sure `mvn install` in /gprc is executed before running this test 4 | mvn test 5 | -------------------------------------------------------------------------------- /tests/annotated_binary/annotated_binary.bfbs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/englercj/flatbuffers/master/tests/annotated_binary/annotated_binary.bfbs -------------------------------------------------------------------------------- /tests/annotated_binary/annotated_binary.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/englercj/flatbuffers/master/tests/annotated_binary/annotated_binary.bin -------------------------------------------------------------------------------- /grpc/examples/ts/greeter/src/greeter.ts: -------------------------------------------------------------------------------- 1 | export { HelloReply } from './models/hello-reply'; 2 | export { HelloRequest } from './models/hello-request'; 3 | -------------------------------------------------------------------------------- /tests/FlatBuffers.Test.Swift/monsterdata_test.mon: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/englercj/flatbuffers/master/tests/FlatBuffers.Test.Swift/monsterdata_test.mon -------------------------------------------------------------------------------- /tests/flatc/foo_with_ns.fbs: -------------------------------------------------------------------------------- 1 | include "bar/bar_with_ns.fbs"; 2 | 3 | namespace something; 4 | 5 | table Foo { 6 | bar:bar.Bar; 7 | } 8 | 9 | root_type Foo; -------------------------------------------------------------------------------- /tests/test_dir/typescript_include.fbs: -------------------------------------------------------------------------------- 1 | include 'typescript_transitive_include.fbs'; 2 | namespace foobar; 3 | 4 | enum class: int { 5 | arguments, 6 | } 7 | -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/englercj/flatbuffers/master/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/englercj/flatbuffers/master/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /tests/annotated_binary/tests/invalid_root_offset.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/englercj/flatbuffers/master/tests/annotated_binary/tests/invalid_root_offset.bin -------------------------------------------------------------------------------- /tests/annotated_binary/tests/invalid_vtable_size.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/englercj/flatbuffers/master/tests/annotated_binary/tests/invalid_vtable_size.bin -------------------------------------------------------------------------------- /tests/flatc/foo.fbs: -------------------------------------------------------------------------------- 1 | include "bar/bar.fbs"; 2 | include "bar/bar_with_ns.fbs"; 3 | 4 | table Foo { 5 | bar:Bar; 6 | bar2:bar.Bar; 7 | } 8 | 9 | root_type Foo; -------------------------------------------------------------------------------- /tests/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "esm": "^3.2.25", 4 | "flatbuffers": "../", 5 | "grpc": "^1.24.6" 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/englercj/flatbuffers/master/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/englercj/flatbuffers/master/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/englercj/flatbuffers/master/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /reflection/BUILD.bazel: -------------------------------------------------------------------------------- 1 | filegroup( 2 | name = "reflection_fbs_schema", 3 | srcs = ["reflection.fbs"], 4 | visibility = ["//visibility:public"], 5 | ) 6 | -------------------------------------------------------------------------------- /tests/annotated_binary/tests/invalid_string_length.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/englercj/flatbuffers/master/tests/annotated_binary/tests/invalid_string_length.bin -------------------------------------------------------------------------------- /ts/constants.ts: -------------------------------------------------------------------------------- 1 | export const SIZEOF_SHORT = 2; 2 | export const SIZEOF_INT = 4; 3 | export const FILE_IDENTIFIER_LENGTH = 4; 4 | export const SIZE_PREFIX_LENGTH = 4; -------------------------------------------------------------------------------- /tests/annotated_binary/tests/invalid_table_field_size.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/englercj/flatbuffers/master/tests/annotated_binary/tests/invalid_table_field_size.bin -------------------------------------------------------------------------------- /tests/annotated_binary/tests/invalid_union_type_value.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/englercj/flatbuffers/master/tests/annotated_binary/tests/invalid_union_type_value.bin -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/englercj/flatbuffers/master/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/englercj/flatbuffers/master/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/englercj/flatbuffers/master/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/englercj/flatbuffers/master/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /tests/annotated_binary/tests/invalid_table_field_offset.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/englercj/flatbuffers/master/tests/annotated_binary/tests/invalid_table_field_offset.bin -------------------------------------------------------------------------------- /tests/annotated_binary/tests/invalid_vtable_field_offset.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/englercj/flatbuffers/master/tests/annotated_binary/tests/invalid_vtable_field_offset.bin -------------------------------------------------------------------------------- /tests/annotated_binary/tests/invalid_vtable_size_short.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/englercj/flatbuffers/master/tests/annotated_binary/tests/invalid_vtable_size_short.bin -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/englercj/flatbuffers/master/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /swift/Sources/FlatBuffers/Documentation.docc/Resources/code/fbs/monster_step_3.fbs: -------------------------------------------------------------------------------- 1 | enum Color:byte { red, green, blue } 2 | 3 | struct Vec3 { 4 | x:float; 5 | y:float; 6 | } 7 | -------------------------------------------------------------------------------- /tests/annotated_binary/tests/invalid_vtable_ref_table_size.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/englercj/flatbuffers/master/tests/annotated_binary/tests/invalid_vtable_ref_table_size.bin -------------------------------------------------------------------------------- /dart/test/list_of_enums.fbs: -------------------------------------------------------------------------------- 1 | enum OptionsEnum : uint32 2 | { 3 | A = 1, 4 | B = 2, 5 | C = 3 6 | } 7 | 8 | table MyTable { 9 | options : [OptionsEnum]; 10 | } 11 | -------------------------------------------------------------------------------- /tests/FlatBuffers.Test/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /tests/LuaTest.bat: -------------------------------------------------------------------------------- 1 | set buildtype=Release 2 | if "%1"=="-b" set buildtype=%2 3 | 4 | echo Run with LuaJIT: 5 | luajit.exe luatest.lua 6 | echo Run with Lua 5.3: 7 | lua53.exe luatest.lua -------------------------------------------------------------------------------- /tests/annotated_binary/tests/invalid_root_table_vtable_offset.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/englercj/flatbuffers/master/tests/annotated_binary/tests/invalid_root_table_vtable_offset.bin -------------------------------------------------------------------------------- /tests/annotated_binary/tests/invalid_string_length_cut_short.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/englercj/flatbuffers/master/tests/annotated_binary/tests/invalid_string_length_cut_short.bin -------------------------------------------------------------------------------- /tests/annotated_binary/tests/invalid_struct_field_cut_short.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/englercj/flatbuffers/master/tests/annotated_binary/tests/invalid_struct_field_cut_short.bin -------------------------------------------------------------------------------- /tests/annotated_binary/tests/invalid_vector_length_cut_short.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/englercj/flatbuffers/master/tests/annotated_binary/tests/invalid_vector_length_cut_short.bin -------------------------------------------------------------------------------- /tests/annotated_binary/tests/invalid_vector_scalars_cut_short.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/englercj/flatbuffers/master/tests/annotated_binary/tests/invalid_vector_scalars_cut_short.bin -------------------------------------------------------------------------------- /tests/annotated_binary/tests/invalid_vector_strings_cut_short.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/englercj/flatbuffers/master/tests/annotated_binary/tests/invalid_vector_strings_cut_short.bin -------------------------------------------------------------------------------- /tests/annotated_binary/tests/invalid_vector_structs_cut_short.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/englercj/flatbuffers/master/tests/annotated_binary/tests/invalid_vector_structs_cut_short.bin -------------------------------------------------------------------------------- /tests/annotated_binary/tests/invalid_vector_tables_cut_short.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/englercj/flatbuffers/master/tests/annotated_binary/tests/invalid_vector_tables_cut_short.bin -------------------------------------------------------------------------------- /tests/annotated_binary/tests/invalid_vector_union_type_value.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/englercj/flatbuffers/master/tests/annotated_binary/tests/invalid_vector_union_type_value.bin -------------------------------------------------------------------------------- /tests/annotated_binary/tests/invalid_vector_unions_cut_short.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/englercj/flatbuffers/master/tests/annotated_binary/tests/invalid_vector_unions_cut_short.bin -------------------------------------------------------------------------------- /tests/vector_has_test.fbs: -------------------------------------------------------------------------------- 1 | namespace Swift.Tests; 2 | 3 | table Vectors 4 | { 5 | none:[ulong]; 6 | empty:[ulong]; 7 | array:[ulong]; 8 | } 9 | 10 | root_type Vectors; 11 | -------------------------------------------------------------------------------- /dart/test/bool_structs.fbs: -------------------------------------------------------------------------------- 1 | // Test for #7355 2 | table Foo { 3 | my_foo : foo_properties; 4 | } 5 | 6 | struct foo_properties 7 | { 8 | a : bool; 9 | b : bool; 10 | } 11 | -------------------------------------------------------------------------------- /go/struct.go: -------------------------------------------------------------------------------- 1 | package flatbuffers 2 | 3 | // Struct wraps a byte slice and provides read access to its data. 4 | // 5 | // Structs do not have a vtable. 6 | type Struct struct { 7 | Table 8 | } 9 | -------------------------------------------------------------------------------- /tests/annotated_binary/tests/invalid_struct_array_field_cut_short.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/englercj/flatbuffers/master/tests/annotated_binary/tests/invalid_struct_array_field_cut_short.bin -------------------------------------------------------------------------------- /tests/annotated_binary/tests/invalid_vtable_ref_table_size_short.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/englercj/flatbuffers/master/tests/annotated_binary/tests/invalid_vtable_ref_table_size_short.bin -------------------------------------------------------------------------------- /tests/docker/languages/Dockerfile.testing.node.12_20_1: -------------------------------------------------------------------------------- 1 | FROM node:12.20.1-stretch as base 2 | WORKDIR /code 3 | ADD . . 4 | RUN cp flatc_debian_stretch flatc 5 | RUN npm install 6 | RUN npm test 7 | -------------------------------------------------------------------------------- /tests/docker/languages/Dockerfile.testing.node.14_15_4: -------------------------------------------------------------------------------- 1 | FROM node:14.15.4-stretch as base 2 | WORKDIR /code 3 | ADD . . 4 | RUN cp flatc_debian_stretch flatc 5 | RUN npm install 6 | RUN npm test 7 | -------------------------------------------------------------------------------- /tests/phpUnionVectorTest.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | ../flatc --php -o php union_vector/union_vector.fbs 6 | php phpUnionVectorTest.php 7 | 8 | echo 'PHP union vector test passed' 9 | -------------------------------------------------------------------------------- /tests/my-game/example/race.ts: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | 3 | export enum Race { 4 | None = -1, 5 | Human = 0, 6 | Dwarf = 1, 7 | Elf = 2 8 | } 9 | -------------------------------------------------------------------------------- /tests/optional-scalars/optional-byte.ts: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | 3 | export enum OptionalByte { 4 | None = 0, 5 | One = 1, 6 | Two = 2 7 | } 8 | -------------------------------------------------------------------------------- /tests/type_field_collsion.fbs: -------------------------------------------------------------------------------- 1 | namespace type_field_collsion; 2 | 3 | // This table tests collsions of identifiers. 4 | table Collision { 5 | collision : int; 6 | } 7 | 8 | root_type Collision; 9 | -------------------------------------------------------------------------------- /tests/optional_scalars/optional-byte.ts: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | 3 | export enum OptionalByte{ 4 | None = 0, 5 | One = 1, 6 | Two = 2 7 | } 8 | 9 | -------------------------------------------------------------------------------- /tests/MyGame/Example/TestEnum.py: -------------------------------------------------------------------------------- 1 | # automatically generated by the FlatBuffers compiler, do not modify 2 | 3 | # namespace: Example 4 | 5 | class TestEnum(object): 6 | A = 0 7 | B = 1 8 | C = 2 9 | -------------------------------------------------------------------------------- /tests/nested_namespace_test/nested_namespace_test3.fbs: -------------------------------------------------------------------------------- 1 | include "nested_namespace_test1.fbs"; 2 | 3 | namespace NamespaceA.NamespaceB; 4 | 5 | table ColorTestTable { 6 | color:NamespaceB.Color = Blue; 7 | } 8 | -------------------------------------------------------------------------------- /tests/docker/languages/Dockerfile.testing.golang.1_11: -------------------------------------------------------------------------------- 1 | FROM golang:1.11-stretch as base 2 | WORKDIR /code 3 | ADD . . 4 | RUN cp flatc_debian_stretch flatc 5 | WORKDIR /code/tests 6 | RUN go version 7 | RUN ./GoTest.sh 8 | -------------------------------------------------------------------------------- /tests/my-game/example/long-enum.ts: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | 3 | export enum LongEnum { 4 | LongOne = '2', 5 | LongTwo = '4', 6 | LongBig = '1099511627776' 7 | } 8 | -------------------------------------------------------------------------------- /tests/docker/languages/Dockerfile.testing.rust.1_51_0: -------------------------------------------------------------------------------- 1 | FROM rust:1.51.0-slim as base 2 | WORKDIR /code 3 | ADD . . 4 | RUN cp flatc_debian_stretch flatc 5 | WORKDIR /code/tests 6 | RUN rustc --version 7 | RUN ./RustTest.sh 8 | -------------------------------------------------------------------------------- /tests/namespace_test/namespace-a/namespace-b/enum-in-nested-n-s.ts: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | 3 | export enum EnumInNestedNS{ 4 | A = 0, 5 | B = 1, 6 | C = 2 7 | } 8 | 9 | -------------------------------------------------------------------------------- /grpc/examples/go/greeter/models/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/google/flatbuffers/grpc/examples/go/greeter/models 2 | 3 | go 1.15 4 | 5 | require ( 6 | github.com/google/flatbuffers v1.12.0 7 | google.golang.org/grpc v1.35.0 8 | ) 9 | -------------------------------------------------------------------------------- /tests/docker/TODO.Dockerfile.testing.python.pypy_6_0_0_py2: -------------------------------------------------------------------------------- 1 | FROM pypy:2-6.0.0-slim as base 2 | WORKDIR /code 3 | ADD . . 4 | RUN cp flatc_debian_stretch flatc 5 | WORKDIR /code/tests 6 | RUN pypy --version 7 | RUN ./PythonTest.sh 8 | -------------------------------------------------------------------------------- /tests/docker/TODO.Dockerfile.testing.python.pypy_6_0_0_py3: -------------------------------------------------------------------------------- 1 | FROM pypy:3-6.0.0-slim as base 2 | WORKDIR /code 3 | ADD . . 4 | RUN cp flatc_debian_stretch flatc 5 | WORKDIR /code/tests 6 | RUN pypy --version 7 | RUN ./PythonTest.sh 8 | -------------------------------------------------------------------------------- /swift/Sources/FlatBuffers/Documentation.docc/Resources/images/tutorial_cover_image_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/englercj/flatbuffers/master/swift/Sources/FlatBuffers/Documentation.docc/Resources/images/tutorial_cover_image_1.png -------------------------------------------------------------------------------- /tests/optional_scalars/OptionalByte.py: -------------------------------------------------------------------------------- 1 | # automatically generated by the FlatBuffers compiler, do not modify 2 | 3 | # namespace: optional_scalars 4 | 5 | class OptionalByte(object): 6 | None_ = 0 7 | One = 1 8 | Two = 2 9 | -------------------------------------------------------------------------------- /grpc/examples/ts/greeter/src/greeter_generated.ts: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | 3 | export { HelloReply } from './models/hello-reply'; 4 | export { HelloRequest } from './models/hello-request'; 5 | -------------------------------------------------------------------------------- /lua/flatbuffers.lua: -------------------------------------------------------------------------------- 1 | local m = {} 2 | 3 | m.Builder = require("flatbuffers.builder").New 4 | m.N = require("flatbuffers.numTypes") 5 | m.view = require("flatbuffers.view") 6 | m.binaryArray = require("flatbuffers.binaryarray") 7 | 8 | return m -------------------------------------------------------------------------------- /tests/MyGame/Example/LongEnum.py: -------------------------------------------------------------------------------- 1 | # automatically generated by the FlatBuffers compiler, do not modify 2 | 3 | # namespace: Example 4 | 5 | class LongEnum(object): 6 | LongOne = 2 7 | LongTwo = 4 8 | LongBig = 1099511627776 9 | -------------------------------------------------------------------------------- /tests/MyGame/Example/Race.py: -------------------------------------------------------------------------------- 1 | # automatically generated by the FlatBuffers compiler, do not modify 2 | 3 | # namespace: Example 4 | 5 | class Race(object): 6 | None_ = -1 7 | Human = 0 8 | Dwarf = 1 9 | Elf = 2 10 | -------------------------------------------------------------------------------- /tests/docker/languages/Dockerfile.testing.java.openjdk_10_0_2: -------------------------------------------------------------------------------- 1 | FROM openjdk:10.0.2-jdk-slim-sid as base 2 | WORKDIR /code 3 | ADD . . 4 | RUN cp flatc_debian_stretch flatc 5 | WORKDIR /code/tests 6 | RUN java -version 7 | RUN ./JavaTest.sh 8 | -------------------------------------------------------------------------------- /tests/docker/languages/Dockerfile.testing.java.openjdk_11_0_1: -------------------------------------------------------------------------------- 1 | FROM openjdk:11.0.1-jdk-slim-sid as base 2 | WORKDIR /code 3 | ADD . . 4 | RUN cp flatc_debian_stretch flatc 5 | WORKDIR /code/tests 6 | RUN java -version 7 | RUN ./JavaTest.sh 8 | -------------------------------------------------------------------------------- /tests/flatc/bar/bar_with_ns.fbs: -------------------------------------------------------------------------------- 1 | include "baz/baz_with_ns.fbs"; 2 | include "baz/baz.fbs"; 3 | 4 | namespace bar; 5 | 6 | table Bar { 7 | baz:baz.Baz; 8 | baz2:Baz; 9 | foo:Foo; 10 | } 11 | 12 | table Foo { 13 | a:int; 14 | } -------------------------------------------------------------------------------- /conan/appveyor/build.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | import os 4 | 5 | if os.getenv("APPVEYOR_REPO_TAG") != "true": 6 | print("Skip build step. It's not TAG") 7 | else: 8 | os.system("python conan/build.py") 9 | -------------------------------------------------------------------------------- /tests/namespace_test/NamespaceA/NamespaceB/EnumInNestedNS.py: -------------------------------------------------------------------------------- 1 | # automatically generated by the FlatBuffers compiler, do not modify 2 | 3 | # namespace: NamespaceB 4 | 5 | class EnumInNestedNS(object): 6 | A = 0 7 | B = 1 8 | C = 2 9 | -------------------------------------------------------------------------------- /tests/dictionary_lookup.fbs: -------------------------------------------------------------------------------- 1 | namespace DictionaryLookup; 2 | 3 | table LongFloatEntry { 4 | key: long (key); 5 | value: float; 6 | } 7 | 8 | table LongFloatMap { 9 | entries: [LongFloatEntry]; 10 | } 11 | root_type LongFloatMap; 12 | -------------------------------------------------------------------------------- /tests/optional_scalars_generated.ts: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | 3 | export { OptionalByte } from './optional-scalars/optional-byte'; 4 | export { ScalarStuff } from './optional-scalars/scalar-stuff'; 5 | -------------------------------------------------------------------------------- /CMake/FlatBuffersConfig.cmake: -------------------------------------------------------------------------------- 1 | include("${CMAKE_CURRENT_LIST_DIR}/FlatBuffersTargets.cmake" OPTIONAL) 2 | include("${CMAKE_CURRENT_LIST_DIR}/FlatcTargets.cmake" OPTIONAL) 3 | include("${CMAKE_CURRENT_LIST_DIR}/FlatBuffersSharedTargets.cmake" OPTIONAL) 4 | -------------------------------------------------------------------------------- /conan/appveyor/install.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | import os 4 | 5 | if os.getenv("APPVEYOR_REPO_TAG") != "true": 6 | print("Skip step. It's not TAG") 7 | else: 8 | os.system("pip install conan conan-package-tools") 9 | -------------------------------------------------------------------------------- /tests/docker/languages/Dockerfile.testing.swift_5_2: -------------------------------------------------------------------------------- 1 | FROM swift:5.2 2 | WORKDIR /code 3 | ADD . . 4 | RUN cp flatc_debian_stretch flatc 5 | WORKDIR /code/tests 6 | RUN swift --version 7 | WORKDIR /code/tests/FlatBuffers.Test.Swift 8 | RUN sh SwiftTest.sh 9 | -------------------------------------------------------------------------------- /tests/include_test/include_test1.fbs: -------------------------------------------------------------------------------- 1 | include "sub/include_test2.fbs"; 2 | include "sub/include_test2.fbs"; // should be skipped 3 | include "include_test1.fbs"; // should be skipped 4 | 5 | table TableA { 6 | b:MyGame.OtherNameSpace.TableB; 7 | } 8 | -------------------------------------------------------------------------------- /tests/more_defaults/mod.rs: -------------------------------------------------------------------------------- 1 | // Automatically generated by the Flatbuffers compiler. Do not modify. 2 | // @generated 3 | mod abc_generated; 4 | pub use self::abc_generated::*; 5 | mod more_defaults_generated; 6 | pub use self::more_defaults_generated::*; 7 | -------------------------------------------------------------------------------- /tests/docker/languages/Dockerfile.testing.csharp.mono_5_18: -------------------------------------------------------------------------------- 1 | FROM mono:5.18 as base 2 | WORKDIR /code 3 | ADD . . 4 | RUN cp flatc_debian_stretch flatc 5 | WORKDIR /code/tests 6 | RUN mono --version 7 | WORKDIR /code/tests/FlatBuffers.Test 8 | RUN sh NetTest.sh 9 | -------------------------------------------------------------------------------- /tests/docker/languages/Dockerfile.testing.php.zend_7_3: -------------------------------------------------------------------------------- 1 | FROM php:7.3-cli-stretch as base 2 | WORKDIR /code 3 | ADD . . 4 | RUN cp flatc_debian_stretch flatc 5 | WORKDIR /code/tests 6 | RUN php --version 7 | RUN php phpTest.php 8 | RUN sh phpUnionVectorTest.sh 9 | -------------------------------------------------------------------------------- /ts/utils.ts: -------------------------------------------------------------------------------- 1 | export const int32 = new Int32Array(2); 2 | export const float32 = new Float32Array(int32.buffer); 3 | export const float64 = new Float64Array(int32.buffer); 4 | export const isLittleEndian = new Uint16Array(new Uint8Array([1, 0]).buffer)[0] === 1; -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | # Don't set line endings to avoid conflict with core.autocrlf flag. 3 | # Line endings on checkout/checkin are controlled by .gitattributes file. 4 | [*] 5 | indent_style = space 6 | indent_size = 2 7 | insert_final_newline = true 8 | -------------------------------------------------------------------------------- /grpc/examples/swift/Greeter/README.md: -------------------------------------------------------------------------------- 1 | # FlatBuffers.GRPC.Swift 2 | 3 | The following is Swift example on how GRPC would be with Swift Flatbuffers, you can simply run the following commands: 4 | 5 | `swift run Server` 6 | 7 | `swift run Client {port} {name}` 8 | -------------------------------------------------------------------------------- /samples/lua/MyGame/Sample/Equipment.lua: -------------------------------------------------------------------------------- 1 | -- automatically generated by the FlatBuffers compiler, do not modify 2 | 3 | -- namespace: Sample 4 | 5 | local Equipment = { 6 | NONE = 0, 7 | Weapon = 1, 8 | } 9 | 10 | return Equipment -- return the module -------------------------------------------------------------------------------- /android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /kotlin/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /samples/lua/MyGame/Sample/Color.lua: -------------------------------------------------------------------------------- 1 | -- automatically generated by the FlatBuffers compiler, do not modify 2 | 3 | -- namespace: Sample 4 | 5 | local Color = { 6 | Red = 0, 7 | Green = 1, 8 | Blue = 2, 9 | } 10 | 11 | return Color -- return the module -------------------------------------------------------------------------------- /swift/Sources/FlatBuffers/Documentation.docc/Resources/code/fbs/monster_step_4.fbs: -------------------------------------------------------------------------------- 1 | enum Color:byte { red, green, blue } 2 | 3 | struct Vec3 { 4 | x:float; 5 | y:float; 6 | } 7 | 8 | table Monster { 9 | pos:Vec3; 10 | color:Color = Blue; 11 | } 12 | 13 | -------------------------------------------------------------------------------- /android/app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #6200EE 4 | #3700B3 5 | #03DAC5 6 | 7 | -------------------------------------------------------------------------------- /tests/docker/languages/Dockerfile.testing.python.cpython_2_7_15: -------------------------------------------------------------------------------- 1 | FROM python:2.7.15-slim-stretch as base 2 | WORKDIR /code 3 | ADD . . 4 | RUN cp flatc_debian_stretch flatc 5 | WORKDIR /code/tests 6 | RUN python --version 7 | RUN pip install coverage 8 | RUN ./PythonTest.sh 9 | -------------------------------------------------------------------------------- /tests/docker/languages/Dockerfile.testing.python.cpython_3_7_1: -------------------------------------------------------------------------------- 1 | FROM python:3.7.1-slim-stretch as base 2 | WORKDIR /code 3 | ADD . . 4 | RUN cp flatc_debian_stretch flatc 5 | WORKDIR /code/tests 6 | RUN python --version 7 | RUN pip install coverage 8 | RUN ./PythonTest.sh 9 | -------------------------------------------------------------------------------- /tests/docker/languages/Dockerfile.testing.rust.nightly: -------------------------------------------------------------------------------- 1 | FROM rustlang/rust:nightly-stretch-slim as base 2 | WORKDIR /code 3 | ADD . . 4 | RUN cp flatc_debian_stretch flatc 5 | WORKDIR /code/tests 6 | RUN rustc --version 7 | RUN export RUST_NIGHTLY=1 8 | RUN ./RustTest.sh 9 | -------------------------------------------------------------------------------- /CMake/DESCRIPTION.txt: -------------------------------------------------------------------------------- 1 | FlatBuffers is a cross platform serialization library architected for 2 | maximum memory efficiency. It allows you to directly access serialized 3 | data without parsing/unpacking it first, while still having great 4 | forwards/backwards compatibility. 5 | -------------------------------------------------------------------------------- /swift/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@build_bazel_rules_swift//swift:swift.bzl", "swift_library") 2 | 3 | swift_library( 4 | name = "swift", 5 | srcs = glob(["Sources/FlatBuffers/*.swift"]), 6 | module_name = "FlatBuffers", 7 | visibility = ["//visibility:public"], 8 | ) 9 | -------------------------------------------------------------------------------- /tests/more_defaults.fbs: -------------------------------------------------------------------------------- 1 | 2 | enum ABC: int { A, B, C } 3 | 4 | 5 | table MoreDefaults { 6 | ints: [int] = []; 7 | floats: [float] = [ ]; 8 | empty_string: string = ""; 9 | some_string: string = "some"; 10 | abcs: [ABC] = []; 11 | bools: [bool] = []; 12 | } 13 | -------------------------------------------------------------------------------- /benchmarks/cpp/raw/raw_bench.h: -------------------------------------------------------------------------------- 1 | #ifndef BENCHMARKS_CPP_RAW_RAW_BENCH_H_ 2 | #define BENCHMARKS_CPP_RAW_RAW_BENCH_H_ 3 | 4 | #include 5 | 6 | #include "benchmarks/cpp/bench.h" 7 | 8 | std::unique_ptr NewRawBench(); 9 | 10 | #endif // BENCHMARKS_CPP_RAW_RAW_BENCH_H_ -------------------------------------------------------------------------------- /swift/Sources/FlatBuffers/Documentation.docc/Resources/code/swift/swift_code_3.swift: -------------------------------------------------------------------------------- 1 | import FlatBuffers 2 | import Foundation 3 | 4 | func run() { 5 | // create a `FlatBufferBuilder`, which will be used to serialize objects 6 | let builder = FlatBufferBuilder(initialSize: 1024) 7 | } 8 | -------------------------------------------------------------------------------- /conan/travis/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | set -x 5 | 6 | if [[ "$(uname -s)" == 'Darwin' ]]; then 7 | if which pyenv > /dev/null; then 8 | eval "$(pyenv init -)" 9 | fi 10 | pyenv activate conan 11 | fi 12 | 13 | conan user 14 | python conan/build.py 15 | -------------------------------------------------------------------------------- /tests/FlatBuffers.Test.Swift/CodeGenerationTests/test_no_include.fbs: -------------------------------------------------------------------------------- 1 | struct BytesCount { 2 | x: int64; 3 | } 4 | 5 | table InternalMessage { 6 | str: string; 7 | } 8 | 9 | table Message { 10 | id: int64; 11 | position: BytesCount (required); 12 | pointer: InternalMessage (required); 13 | } -------------------------------------------------------------------------------- /tests/namespace_test/NamespaceA/NamespaceB/EnumInNestedNS.lua: -------------------------------------------------------------------------------- 1 | -- automatically generated by the FlatBuffers compiler, do not modify 2 | 3 | -- namespace: NamespaceB 4 | 5 | local EnumInNestedNS = { 6 | A = 0, 7 | B = 1, 8 | C = 2, 9 | } 10 | 11 | return EnumInNestedNS -- return the module -------------------------------------------------------------------------------- /scripts/clang-format-all.sh: -------------------------------------------------------------------------------- 1 | # Running it twice corrects some bugs in clang-format. 2 | for run in {1..2} 3 | do 4 | clang-format -i include/flatbuffers/* src/*.cpp tests/*.cpp samples/*.cpp grpc/src/compiler/schema_interface.h grpc/tests/*.cpp 5 | done 6 | git checkout include/flatbuffers/reflection_generated.h 7 | -------------------------------------------------------------------------------- /tests/docker/Dockerfile.testing.build_flatc_debian_stretch: -------------------------------------------------------------------------------- 1 | FROM debian:9.6-slim as base 2 | RUN apt -qq update >/dev/null 3 | RUN apt -qq install -y cmake make build-essential >/dev/null 4 | FROM base 5 | WORKDIR /code 6 | ADD . . 7 | RUN cmake -G "Unix Makefiles" 8 | RUN make flatc 9 | RUN ls flatc 10 | -------------------------------------------------------------------------------- /tests/docker/languages/Dockerfile.testing.python.numpy.cpython_3_7_1: -------------------------------------------------------------------------------- 1 | FROM python:3.7.1-slim-stretch as base 2 | WORKDIR /code 3 | ADD . . 4 | RUN cp flatc_debian_stretch flatc 5 | WORKDIR /code/tests 6 | RUN python --version 7 | RUN pip install numpy 8 | RUN pip install coverage 9 | RUN ./PythonTest.sh 10 | -------------------------------------------------------------------------------- /tests/include_test/sub/include_test2.fbs: -------------------------------------------------------------------------------- 1 | include "include_test1.fbs"; 2 | include "sub/include_test2.fbs"; // should be skipped 3 | 4 | namespace MyGame.OtherNameSpace; 5 | 6 | enum FromInclude:long { IncludeVal } 7 | 8 | struct Unused { a:int; } 9 | 10 | table TableB { 11 | a:TableA; 12 | } 13 | -------------------------------------------------------------------------------- /tests/namespace_test/NamespaceA/NamespaceB/UnionInNestedNS.lua: -------------------------------------------------------------------------------- 1 | -- automatically generated by the FlatBuffers compiler, do not modify 2 | 3 | -- namespace: NamespaceB 4 | 5 | local UnionInNestedNS = { 6 | NONE = 0, 7 | TableInNestedNS = 1, 8 | } 9 | 10 | return UnionInNestedNS -- return the module -------------------------------------------------------------------------------- /grpc/examples/greeter.fbs: -------------------------------------------------------------------------------- 1 | namespace models; 2 | 3 | table HelloReply { 4 | message:string; 5 | } 6 | 7 | table HelloRequest { 8 | name:string; 9 | } 10 | 11 | rpc_service Greeter { 12 | SayHello(HelloRequest):HelloReply; 13 | SayManyHellos(HelloRequest):HelloReply (streaming: "server"); 14 | } 15 | -------------------------------------------------------------------------------- /tests/docker/languages/Dockerfile.testing.python.numpy.cpython_2_7_15: -------------------------------------------------------------------------------- 1 | FROM python:2.7.15-slim-stretch as base 2 | WORKDIR /code 3 | ADD . . 4 | RUN cp flatc_debian_stretch flatc 5 | WORKDIR /code/tests 6 | RUN python --version 7 | RUN pip install numpy 8 | RUN pip install coverage 9 | RUN ./PythonTest.sh 10 | -------------------------------------------------------------------------------- /ts/flexbuffers/flexbuffers-util.ts: -------------------------------------------------------------------------------- 1 | export function fromUTF8Array(data: BufferSource): string { 2 | const decoder = new TextDecoder(); 3 | return decoder.decode(data); 4 | } 5 | 6 | export function toUTF8Array(str: string) : Uint8Array { 7 | const encoder = new TextEncoder(); 8 | return encoder.encode(str); 9 | } -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | /* eslint-env node */ 2 | 3 | module.exports = { 4 | root: true, 5 | parser: '@typescript-eslint/parser', 6 | plugins: [ 7 | '@typescript-eslint', 8 | ], 9 | extends: [ 10 | 'eslint:recommended', 11 | 'plugin:@typescript-eslint/recommended', 12 | ] 13 | }; -------------------------------------------------------------------------------- /grpc/examples/python/greeter/README.md: -------------------------------------------------------------------------------- 1 | # Python Greeter example 2 | 3 | ## Prerequisite 4 | 5 | - You need to have grpc python installed on your device `pip install grpcio` 6 | ## How to run Server: 7 | 8 | - `python server.py ${PORT}` 9 | 10 | ## How to run Client: 11 | 12 | - `python client.py ${PORT} ${NAME}` -------------------------------------------------------------------------------- /CMake/flatbuffers.pc.in: -------------------------------------------------------------------------------- 1 | libdir=@CMAKE_INSTALL_FULL_LIBDIR@ 2 | includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@ 3 | 4 | Name: FlatBuffers 5 | Description: Memory Efficient Serialization Library 6 | Version: @VERSION_MAJOR@.@VERSION_MINOR@.@VERSION_PATCH@ 7 | 8 | Libs: -L${libdir} -lflatbuffers 9 | Cflags: -I${includedir} 10 | -------------------------------------------------------------------------------- /scripts/clang-format-git.sh: -------------------------------------------------------------------------------- 1 | # Running it twice corrects some bugs in clang-format. 2 | for run in {1..2} 3 | do 4 | git clang-format HEAD^ -- include/flatbuffers/* src/*.cpp tests/*.cpp samples/*.cpp grpc/src/compiler/schema_interface.h grpc/tests/*.cpp -f 5 | done 6 | git checkout include/flatbuffers/reflection_generated.h 7 | -------------------------------------------------------------------------------- /grpc/boringssl.patch: -------------------------------------------------------------------------------- 1 | diff --git a/CMakeLists.txt b/CMakeLists.txt 2 | index 1645a264a..12f8ca999 100644 3 | --- a/CMakeLists.txt 4 | +++ b/CMakeLists.txt 5 | @@ -635,6 +635,8 @@ add_library( 6 | src/ssl/tls_record.cc 7 | ) 8 | 9 | +target_link_libraries(ssl crypto) 10 | + 11 | add_executable( 12 | bssl 13 | 14 | -------------------------------------------------------------------------------- /tests/optional_scalars/OptionalByte.cs: -------------------------------------------------------------------------------- 1 | // 2 | // automatically generated by the FlatBuffers compiler, do not modify 3 | // 4 | 5 | namespace optional_scalars 6 | { 7 | 8 | public enum OptionalByte : sbyte 9 | { 10 | None = 0, 11 | One = 1, 12 | Two = 2, 13 | }; 14 | 15 | 16 | } 17 | -------------------------------------------------------------------------------- /tests/private_annotation_test.fbs: -------------------------------------------------------------------------------- 1 | enum AB:byte (private) { 2 | A, 3 | B, 4 | } 5 | 6 | struct Object (private) { 7 | value: int; 8 | } 9 | 10 | union Any (private) { Game, Annotations } 11 | 12 | table Game (private) { 13 | value: int; 14 | } 15 | 16 | table Annotations (private) { 17 | value: int; 18 | } -------------------------------------------------------------------------------- /tests/my-game/example/race.js: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | export var Race; 3 | (function (Race) { 4 | Race[Race["None"] = -1] = "None"; 5 | Race[Race["Human"] = 0] = "Human"; 6 | Race[Race["Dwarf"] = 1] = "Dwarf"; 7 | Race[Race["Elf"] = 2] = "Elf"; 8 | })(Race || (Race = {})); 9 | -------------------------------------------------------------------------------- /tests/namespace_test/namespace_test1.fbs: -------------------------------------------------------------------------------- 1 | namespace NamespaceA.NamespaceB; 2 | 3 | table TableInNestedNS 4 | { 5 | foo:int; 6 | } 7 | 8 | union UnionInNestedNS { 9 | TableInNestedNS, 10 | } 11 | 12 | enum EnumInNestedNS:byte 13 | { 14 | A, B, C 15 | } 16 | 17 | struct StructInNestedNS 18 | { 19 | a:int; 20 | b:int; 21 | } -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /ts/types.ts: -------------------------------------------------------------------------------- 1 | import { ByteBuffer } from './byte-buffer.js' 2 | import { Builder } from './builder.js' 3 | 4 | export type Offset = number; 5 | 6 | export type Table = { 7 | bb: ByteBuffer 8 | bb_pos: number 9 | }; 10 | 11 | export interface IGeneratedObject { 12 | pack(builder:Builder): Offset 13 | unpack(): IGeneratedObject 14 | } -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /lua/flatbuffers/compat_5_3.lua: -------------------------------------------------------------------------------- 1 | -- We need to put it into a separate file to avoid syntax error like `unexpected symbol near '~'` 2 | local m = {} 3 | 4 | 5 | m.GetAlignSize = function(k, size) 6 | return ((~k) + 1) & (size - 1) 7 | end 8 | 9 | 10 | m.string_pack = string.pack 11 | m.string_unpack = string.unpack 12 | 13 | 14 | return m 15 | -------------------------------------------------------------------------------- /tests/MyGame/Example2/MonsterT.java: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | 3 | package MyGame.Example2; 4 | 5 | import java.nio.*; 6 | import java.lang.*; 7 | import java.util.*; 8 | import com.google.flatbuffers.*; 9 | 10 | public class MonsterT { 11 | 12 | 13 | public MonsterT() { 14 | } 15 | } 16 | 17 | -------------------------------------------------------------------------------- /tests/MyGame/InParentNamespaceT.java: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | 3 | package MyGame; 4 | 5 | import java.nio.*; 6 | import java.lang.*; 7 | import java.util.*; 8 | import com.google.flatbuffers.*; 9 | 10 | public class InParentNamespaceT { 11 | 12 | 13 | public InParentNamespaceT() { 14 | } 15 | } 16 | 17 | -------------------------------------------------------------------------------- /tests/optional_scalars/mod.rs: -------------------------------------------------------------------------------- 1 | // Automatically generated by the Flatbuffers compiler. Do not modify. 2 | // @generated 3 | pub mod optional_scalars { 4 | use super::*; 5 | mod optional_byte_generated; 6 | pub use self::optional_byte_generated::*; 7 | mod scalar_stuff_generated; 8 | pub use self::scalar_stuff_generated::*; 9 | } // optional_scalars 10 | -------------------------------------------------------------------------------- /tests/KeywordTest/public.cs: -------------------------------------------------------------------------------- 1 | // 2 | // automatically generated by the FlatBuffers compiler, do not modify 3 | // 4 | 5 | namespace KeywordTest 6 | { 7 | 8 | [Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))] 9 | public enum @public : int 10 | { 11 | NONE = 0, 12 | }; 13 | 14 | 15 | } 16 | -------------------------------------------------------------------------------- /.clang-format: -------------------------------------------------------------------------------- 1 | --- 2 | Language: Cpp 3 | BasedOnStyle: Google 4 | DerivePointerAlignment: false 5 | PointerAlignment: Right 6 | IndentPPDirectives: AfterHash 7 | Cpp11BracedListStyle: false 8 | AlwaysBreakTemplateDeclarations: false 9 | AllowShortCaseLabelsOnASingleLine: true 10 | SpaceAfterTemplateKeyword: false 11 | AllowShortBlocksOnASingleLine: true 12 | ... 13 | 14 | -------------------------------------------------------------------------------- /conan/test_package/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | project(test_package CXX) 2 | cmake_minimum_required(VERSION 2.8.11) 3 | 4 | include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) 5 | conan_basic_setup() 6 | 7 | add_executable(${PROJECT_NAME} test_package.cpp) 8 | target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) 9 | set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) 10 | -------------------------------------------------------------------------------- /tests/keyword_test.fbs: -------------------------------------------------------------------------------- 1 | namespace KeywordTest; 2 | 3 | enum ABC: int { void, where, stackalloc } 4 | 5 | enum public: int { } 6 | 7 | table KeywordsInTable { 8 | is: ABC = void; 9 | private: public; 10 | type: int; 11 | default: bool = false; 12 | } 13 | 14 | union KeywordsInUnion { 15 | static: KeywordsInTable, 16 | internal: KeywordsInTable, 17 | } 18 | -------------------------------------------------------------------------------- /tests/rust_usage_test/outdir/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "outdir" 3 | version = "0.1.0" 4 | authors = ["Casper Neo "] 5 | edition = "2018" 6 | 7 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 8 | 9 | [dependencies] 10 | flatbuffers = { path = "../../../rust/flatbuffers" } 11 | serde = "1.0" 12 | -------------------------------------------------------------------------------- /tests/MyGame/Example/Color.py: -------------------------------------------------------------------------------- 1 | # automatically generated by the FlatBuffers compiler, do not modify 2 | 3 | # namespace: Example 4 | 5 | # Composite components of Monster color. 6 | class Color(object): 7 | Red = 1 8 | # \brief color Green 9 | # Green is bit_flag with value (1u << 1) 10 | Green = 2 11 | # \brief color Blue (1u << 3) 12 | Blue = 8 13 | -------------------------------------------------------------------------------- /tests/namespace_test/namespace_test1.ts: -------------------------------------------------------------------------------- 1 | export { StructInNestedNS, StructInNestedNST } from './namespace-a/namespace-b/struct-in-nested-n-s'; 2 | export { TableInNestedNS, TableInNestedNST } from './namespace-a/namespace-b/table-in-nested-n-s'; 3 | export { UnionInNestedNS, unionToUnionInNestedNS, unionListToUnionInNestedNS } from './namespace-a/namespace-b/union-in-nested-n-s'; 4 | -------------------------------------------------------------------------------- /tests/optional_scalars/optional-byte.js: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | export var OptionalByte; 3 | (function (OptionalByte) { 4 | OptionalByte[OptionalByte["None"] = 0] = "None"; 5 | OptionalByte[OptionalByte["One"] = 1] = "One"; 6 | OptionalByte[OptionalByte["Two"] = 2] = "Two"; 7 | })(OptionalByte || (OptionalByte = {})); 8 | -------------------------------------------------------------------------------- /grpc/examples/ts/greeter/README.md: -------------------------------------------------------------------------------- 1 | # TS Greeter example 2 | 3 | The following is an example on how to run the TS grpc server. Make sure that you have `Typescript` installed 4 | 5 | you would need to run `npm run build` or simply use `npm install && tsc` 6 | 7 | ## How to run Server: 8 | 9 | - `npm run server` 10 | 11 | ## How to run Client: 12 | 13 | - `npm run client 3000` -------------------------------------------------------------------------------- /grpc/samples/greeter/greeter.fbs: -------------------------------------------------------------------------------- 1 | table HelloReply { 2 | message:string; 3 | } 4 | 5 | table HelloRequest { 6 | name:string; 7 | } 8 | 9 | table ManyHellosRequest { 10 | name:string; 11 | num_greetings:int; 12 | } 13 | 14 | rpc_service Greeter { 15 | SayHello(HelloRequest):HelloReply; 16 | SayManyHellos(ManyHellosRequest):HelloReply (streaming: "server"); 17 | } 18 | -------------------------------------------------------------------------------- /tests/rust_serialize_test/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "rust_serialize_test" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 7 | 8 | [dependencies] 9 | flatbuffers = { path = "../../rust/flatbuffers", features=["serialize"] } 10 | serde = "1.0" 11 | serde_json = "1.0" 12 | 13 | -------------------------------------------------------------------------------- /tests/fuzzer/.gitignore: -------------------------------------------------------------------------------- 1 | # The generated fuzzers 2 | *_fuzzer 3 | 4 | # Findings from the fuzzers 5 | oom-* 6 | slow-unit-* 7 | crash-* 8 | 9 | # Individual fuzzer logs if job=N 10 | fuzz-*.log 11 | 12 | .clangd/ 13 | 14 | # These are copied from tests/annotated_binary/ and should use the latest ones. 15 | annotated_binary.bfbs 16 | annotated_binary.bin 17 | 18 | monster_test.bfbs -------------------------------------------------------------------------------- /grpc/examples/ts/greeter/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "flatbuffers-js-grpc", 3 | "version": "1.0.0", 4 | "author": "mustii@mmk.one", 5 | "scripts": { 6 | "build": "npm install && tsc", 7 | "client": "node dist/client.js", 8 | "server": "node dist/server.js" 9 | }, 10 | "dependencies": { 11 | "@grpc/grpc-js": "^1.3.2", 12 | "flatbuffers": "^2.0.0" 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /tests/FlatBuffers.Test/clean.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Remove files and directory that are needed to build and run the .NET tests. 4 | # The script NetTest.sh installs these as needed. 5 | 6 | [ -d .dotnet_tmp ] && rm -rf .dotnet_tmp 7 | [ -d packages ] && rm -rf packages 8 | [ -d .tmp ] && rm -rf .tmp 9 | [ -f nuget.exe ] && rm nuget.exe 10 | [ -f dotnet-intall.sh ] && rm dotnet-install.sh 11 | -------------------------------------------------------------------------------- /tests/MyGame/Example/LongEnum.kt: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | 3 | package MyGame.Example 4 | 5 | @Suppress("unused") 6 | class LongEnum private constructor() { 7 | companion object { 8 | const val LongOne: ULong = 2UL 9 | const val LongTwo: ULong = 4UL 10 | const val LongBig: ULong = 1099511627776UL 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /swift/Sources/FlatBuffers/Documentation.docc/Resources/code/fbs/monster_step_5.fbs: -------------------------------------------------------------------------------- 1 | enum Color:byte { red, green, blue } 2 | 3 | struct Vec3 { 4 | x:float; 5 | y:float; 6 | } 7 | 8 | table Monster { 9 | pos:Vec3; 10 | color:Color = Blue; 11 | 12 | mana:short = 150; 13 | hp:short = 100; 14 | name:string; 15 | equipped:Equipment; 16 | weapons:[Weapon]; 17 | path:[Vec3]; 18 | } 19 | -------------------------------------------------------------------------------- /tests/KeywordTest/ABC.cs: -------------------------------------------------------------------------------- 1 | // 2 | // automatically generated by the FlatBuffers compiler, do not modify 3 | // 4 | 5 | namespace KeywordTest 6 | { 7 | 8 | [Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))] 9 | public enum ABC : int 10 | { 11 | @void = 0, 12 | where = 1, 13 | @stackalloc = 2, 14 | }; 15 | 16 | 17 | } 18 | -------------------------------------------------------------------------------- /tests/MyGame/Example/LongEnum.java: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | 3 | package MyGame.Example; 4 | 5 | @SuppressWarnings("unused") 6 | public final class LongEnum { 7 | private LongEnum() { } 8 | public static final long LongOne = 2; 9 | public static final long LongTwo = 4; 10 | public static final long LongBig = 1099511627776; 11 | } 12 | 13 | -------------------------------------------------------------------------------- /tests/MyGame/Example/TestEnum.cs: -------------------------------------------------------------------------------- 1 | // 2 | // automatically generated by the FlatBuffers compiler, do not modify 3 | // 4 | 5 | namespace MyGame.Example 6 | { 7 | 8 | [Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))] 9 | public enum TestEnum : sbyte 10 | { 11 | A = 0, 12 | B = 1, 13 | C = 2, 14 | }; 15 | 16 | 17 | } 18 | -------------------------------------------------------------------------------- /tests/fuzzer/scalar_fuzzer.dict: -------------------------------------------------------------------------------- 1 | "-" 2 | "+" 3 | "." 4 | "e" 5 | "e+" 6 | "e-" 7 | "E" 8 | "E+" 9 | "E-" 10 | "0x" 11 | "-0x" 12 | "p" 13 | "0" 14 | "1" 15 | "2" 16 | "3" 17 | "4" 18 | "5" 19 | "6" 20 | "7" 21 | "8" 22 | "9" 23 | "a" 24 | "b" 25 | "c" 26 | "d" 27 | "e" 28 | "f" 29 | "nan" 30 | "-nan" 31 | "+nan" 32 | "inf" 33 | "+inf" 34 | "-inf" 35 | "infinity" 36 | "+infinity" 37 | "-infinity" 38 | -------------------------------------------------------------------------------- /grpc/examples/go/greeter/client/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/google/flatbuffers/grpc/examples/go/greeter/client 2 | 3 | go 1.15 4 | 5 | replace github.com/google/flatbuffers/grpc/examples/go/greeter/models v0.0.0 => ../models 6 | 7 | require ( 8 | github.com/google/flatbuffers v1.12.0 9 | github.com/google/flatbuffers/grpc/examples/go/greeter/models v0.0.0 10 | google.golang.org/grpc v1.35.0 11 | ) 12 | -------------------------------------------------------------------------------- /kotlin/gradle.properties: -------------------------------------------------------------------------------- 1 | #Gradle 2 | 3 | org.gradle.parallel=true 4 | org.gradle.caching=true 5 | 6 | #Kotlin 7 | kotlin.code.style=official 8 | 9 | #MPP 10 | kotlin.mpp.enableGranularSourceSetsMetadata=true 11 | kotlin.native.enableDependencyPropagation=false 12 | kotlin.mpp.enableCompatibilityMetadataVariant=true 13 | kotlin.mpp.stability.nowarn=true 14 | kotlin.incremental.multiplatform=true 15 | -------------------------------------------------------------------------------- /tests/namespace_test/namespace-a/namespace-b/enum-in-nested-n-s.js: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | export var EnumInNestedNS; 3 | (function (EnumInNestedNS) { 4 | EnumInNestedNS[EnumInNestedNS["A"] = 0] = "A"; 5 | EnumInNestedNS[EnumInNestedNS["B"] = 1] = "B"; 6 | EnumInNestedNS[EnumInNestedNS["C"] = 2] = "C"; 7 | })(EnumInNestedNS || (EnumInNestedNS = {})); 8 | -------------------------------------------------------------------------------- /grpc/examples/go/greeter/server/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/google/flatbuffers/grpc/examples/go/greeter/server 2 | 3 | go 1.15 4 | 5 | replace github.com/google/flatbuffers/grpc/examples/go/greeter/models v0.0.0 => ../models 6 | 7 | require ( 8 | github.com/google/flatbuffers v1.12.0 9 | github.com/google/flatbuffers/grpc/examples/go/greeter/models v0.0.0 10 | google.golang.org/grpc v1.39.0-dev 11 | ) 12 | -------------------------------------------------------------------------------- /python/flatbuffers/reflection/AdvancedFeatures.py: -------------------------------------------------------------------------------- 1 | # automatically generated by the FlatBuffers compiler, do not modify 2 | 3 | # namespace: reflection 4 | 5 | # New schema language features that are not supported by old code generators. 6 | class AdvancedFeatures(object): 7 | AdvancedArrayFeatures = 1 8 | AdvancedUnionFeatures = 2 9 | OptionalScalars = 4 10 | DefaultVectorsAndStrings = 8 11 | -------------------------------------------------------------------------------- /swift/Sources/FlatBuffers/Documentation.docc/Resources/code/swift/swift_code_4.swift: -------------------------------------------------------------------------------- 1 | import FlatBuffers 2 | import Foundation 3 | 4 | func run() { 5 | // create a `FlatBufferBuilder`, which will be used to serialize objects 6 | let builder = FlatBufferBuilder(initialSize: 1024) 7 | 8 | let weapon1Name = builder.create(string: "Sword") 9 | let weapon2Name = builder.create(string: "Axe") 10 | } 11 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ES5", 4 | "module": "commonjs", 5 | "lib": ["ES2015", "ES2020.BigInt", "DOM"], 6 | "declaration": true, 7 | "outDir": "./js", 8 | "strict": true, 9 | "esModuleInterop": true, 10 | "skipLibCheck": true, 11 | "forceConsistentCasingInFileNames": true 12 | }, 13 | "include": [ 14 | "ts/**/*.ts" 15 | ] 16 | } 17 | -------------------------------------------------------------------------------- /tsconfig.mjs.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ES2017", 4 | "module": "ES2015", 5 | "lib": ["ES2017", "ES2020.BigInt", "DOM"], 6 | "declaration": true, 7 | "outDir": "./mjs", 8 | "strict": true, 9 | "esModuleInterop": true, 10 | "skipLibCheck": true, 11 | "forceConsistentCasingInFileNames": true 12 | }, 13 | "include": [ 14 | "ts/**/*.ts" 15 | ] 16 | } -------------------------------------------------------------------------------- /swift/README.md: -------------------------------------------------------------------------------- 1 | FlatBuffers swift can be found in both SPM 2 | 3 | `.package(url: "https://github.com/mustiikhalil/flatbuffers.git", from: "X.Y.Z"),` 4 | 5 | and Cocoapods 6 | 7 | `pod 'FlatBuffers'` 8 | 9 | ### Notes 10 | 11 | 1- To report any error please use the main repository. 12 | 13 | ### Contribute 14 | 15 | 1- Always run `swift test --generate-linuxmain` whenever new test functions are added or removed -------------------------------------------------------------------------------- /tests/MyGame/Example/Race.cs: -------------------------------------------------------------------------------- 1 | // 2 | // automatically generated by the FlatBuffers compiler, do not modify 3 | // 4 | 5 | namespace MyGame.Example 6 | { 7 | 8 | [Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))] 9 | public enum Race : sbyte 10 | { 11 | None = -1, 12 | Human = 0, 13 | Dwarf = 1, 14 | Elf = 2, 15 | }; 16 | 17 | 18 | } 19 | -------------------------------------------------------------------------------- /tests/my-game/example/color.ts: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | 3 | /** 4 | * Composite components of Monster color. 5 | */ 6 | export enum Color { 7 | Red = 1, 8 | 9 | /** 10 | * \brief color Green 11 | * Green is bit_flag with value (1u << 1) 12 | */ 13 | Green = 2, 14 | 15 | /** 16 | * \brief color Blue (1u << 3) 17 | */ 18 | Blue = 8 19 | } 20 | -------------------------------------------------------------------------------- /conan/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8) 2 | 3 | message(STATUS "Conan FlatBuffers Wrapper") 4 | 5 | include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) 6 | conan_basic_setup() 7 | 8 | if (WIN32 AND MSVC_LIKE AND FLATBUFFERS_BUILD_SHAREDLIB) 9 | set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) 10 | endif(WIN32 AND MSVC_LIKE AND FLATBUFFERS_BUILD_SHAREDLIB) 11 | 12 | include(${CMAKE_SOURCE_DIR}/CMakeListsOriginal.txt) 13 | -------------------------------------------------------------------------------- /samples/monsterdata.json: -------------------------------------------------------------------------------- 1 | { 2 | "pos": { 3 | "x": 1.0, 4 | "y": 2.0, 5 | "z": 3.0 6 | }, 7 | "hp": 300, 8 | "name": "Orc", 9 | "weapons": [ 10 | { 11 | "name": "axe", 12 | "damage": 100 13 | }, 14 | { 15 | "name": "bow", 16 | "damage": 90 17 | } 18 | ], 19 | "equipped_type": "Weapon", 20 | "equipped": { 21 | "name": "bow", 22 | "damage": 90 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /tests/docker/Dockerfile.testing.cpp.debian_buster: -------------------------------------------------------------------------------- 1 | FROM debian:10.1-slim as base 2 | RUN apt -qq update >/dev/null 3 | RUN apt -qq install -y cmake make build-essential >/dev/null 4 | RUN apt -qq install -y autoconf git libtool >/dev/null 5 | RUN apt -qq install -y clang >/dev/null 6 | FROM base 7 | # Travis machines have 2 cores. Can be redefined with 'run --env PAR_JOBS=N'. 8 | ENV JOBS=2 9 | WORKDIR /flatbuffers 10 | ADD . . 11 | -------------------------------------------------------------------------------- /tests/namespace_test/NamespaceA/NamespaceB/EnumInNestedNS.cs: -------------------------------------------------------------------------------- 1 | // 2 | // automatically generated by the FlatBuffers compiler, do not modify 3 | // 4 | 5 | namespace NamespaceA.NamespaceB 6 | { 7 | 8 | [Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))] 9 | public enum EnumInNestedNS : sbyte 10 | { 11 | A = 0, 12 | B = 1, 13 | C = 2, 14 | }; 15 | 16 | 17 | } 18 | -------------------------------------------------------------------------------- /tests/private_annotation_test/mod.rs: -------------------------------------------------------------------------------- 1 | // Automatically generated by the Flatbuffers compiler. Do not modify. 2 | // @generated 3 | mod ab_generated; 4 | pub use self::ab_generated::*; 5 | mod any_generated; 6 | pub use self::any_generated::*; 7 | mod object_generated; 8 | pub use self::object_generated::*; 9 | mod game_generated; 10 | pub use self::game_generated::*; 11 | mod annotations_generated; 12 | pub use self::annotations_generated::*; 13 | -------------------------------------------------------------------------------- /tests/MyGame/Example/Race.lua: -------------------------------------------------------------------------------- 1 | --[[ MyGame.Example.Race 2 | 3 | Automatically generated by the FlatBuffers compiler, do not modify. 4 | Or modify. I'm a message, not a cop. 5 | 6 | flatc version: 2.0.7 7 | 8 | Declared by : //monster_test.fbs 9 | Rooting type : MyGame.Example.Monster (//monster_test.fbs) 10 | 11 | --]] 12 | 13 | local Race = { 14 | None = -1, 15 | Human = 0, 16 | Dwarf = 1, 17 | Elf = 2, 18 | } 19 | 20 | return Race -------------------------------------------------------------------------------- /tests/MyGame/Example/LongEnum.cs: -------------------------------------------------------------------------------- 1 | // 2 | // automatically generated by the FlatBuffers compiler, do not modify 3 | // 4 | 5 | namespace MyGame.Example 6 | { 7 | 8 | [Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))] 9 | [System.FlagsAttribute] 10 | public enum LongEnum : ulong 11 | { 12 | LongOne = 2, 13 | LongTwo = 4, 14 | LongBig = 1099511627776, 15 | }; 16 | 17 | 18 | } 19 | -------------------------------------------------------------------------------- /tests/optional_scalars.json: -------------------------------------------------------------------------------- 1 | { 2 | just_i8: 4, 3 | maybe_u8: 0, 4 | default_u8: 0, 5 | just_i16: 4, 6 | maybe_u16: 0, 7 | default_u16: 0, 8 | just_i32: 4, 9 | maybe_u32: 0, 10 | default_u32: 0, 11 | just_i64: 4, 12 | maybe_u64: 0, 13 | default_u64: 0, 14 | just_f32: 4.0, 15 | maybe_f64: 0.0, 16 | default_f64: 0.0, 17 | just_bool: true, 18 | default_bool: false, 19 | maybe_enum: "One", 20 | default_enum: "Two" 21 | } 22 | -------------------------------------------------------------------------------- /android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "google/flatbuffers", 3 | "type": "library", 4 | "description": "FlatBuffers for PHP", 5 | "keywords": ["google", "flatbuffers", "serialization"], 6 | "homepage": "https://github.com/google/flatbuffers", 7 | "license": "Apache-2.0", 8 | "require": { 9 | "php": ">=5.4" 10 | }, 11 | "require-dev": { 12 | }, 13 | "autoload": { 14 | "psr-4": { 15 | "Google\\FlatBuffers\\": "php" 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /tests/docker/build_flatc.run.sh: -------------------------------------------------------------------------------- 1 | set -e 2 | 3 | JOBS=${JOBS:-1} 4 | config=$1 5 | echo "" 6 | echo "Build 'flatc' compiler for '$config'" 7 | 8 | cmake . -DCMAKE_BUILD_TYPE=$config \ 9 | -DFLATBUFFERS_BUILD_FLATC=1 -DFLATBUFFERS_STATIC_FLATC=1 \ 10 | -DFLATBUFFERS_BUILD_TESTS=0 -DFLATBUFFERS_INSTALL=0 11 | cmake --build . --target flatc --clean-first -- -j$JOBS 12 | 13 | echo "Checking generated code" 14 | scripts/check_generate_code.py 15 | echo "Done" 16 | -------------------------------------------------------------------------------- /tests/fuzzer/fuzzer_assert.h: -------------------------------------------------------------------------------- 1 | #ifndef FUZZER_ASSERT_IMPL_H_ 2 | #define FUZZER_ASSERT_IMPL_H_ 3 | 4 | #if defined(_MSC_VER) 5 | extern "C" void __debugbreak(); 6 | #define __builtin_trap __debugbreak 7 | #else // Clang 8 | extern "C" void __builtin_trap(void); 9 | #endif 10 | 11 | // Declare Debug/Release independed assert macro. 12 | #define fuzzer_assert_impl(x) (!!(x) ? static_cast(0) : __builtin_trap()) 13 | 14 | #endif // !FUZZER_ASSERT_IMPL_H_ 15 | -------------------------------------------------------------------------------- /tests/MyGame/Example/TestEnum.kt: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | 3 | package MyGame.Example 4 | 5 | @Suppress("unused") 6 | class TestEnum private constructor() { 7 | companion object { 8 | const val A: Byte = 0 9 | const val B: Byte = 1 10 | const val C: Byte = 2 11 | val names : Array = arrayOf("A", "B", "C") 12 | fun name(e: Int) : String = names[e] 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /tests/MyGame/OtherNameSpace/FromInclude.lua: -------------------------------------------------------------------------------- 1 | --[[ MyGame.OtherNameSpace.FromInclude 2 | 3 | Automatically generated by the FlatBuffers compiler, do not modify. 4 | Or modify. I'm a message, not a cop. 5 | 6 | flatc version: 2.0.7 7 | 8 | Declared by : //include_test/sub/include_test2.fbs 9 | Rooting type : MyGame.Example.Monster (//monster_test.fbs) 10 | 11 | --]] 12 | 13 | local FromInclude = { 14 | IncludeVal = 0, 15 | } 16 | 17 | return FromInclude -------------------------------------------------------------------------------- /tests/evolution_test/evolution_v1.json: -------------------------------------------------------------------------------- 1 | { 2 | "a": 42, 3 | "b": true, 4 | "c_type": "TableB", 5 | "c": { 6 | "a": 15 7 | }, 8 | "d": "King", 9 | "e": { 10 | "a": 3.1452, 11 | "b": 325 12 | }, 13 | "f":{ 14 | "a": 16, 15 | "b": 243.980943 16 | }, 17 | "g": [ 7, 8, 9], 18 | "h": [ 19 | { 20 | "a": 212 21 | }, 22 | { 23 | "a": 459 24 | } 25 | ], 26 | "j": { 27 | "a": 984 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /grpc/tests/BUILD: -------------------------------------------------------------------------------- 1 | cc_test( 2 | name = "grpc_test", 3 | srcs = [ 4 | "grpctest.cpp", 5 | "message_builder_test.cpp", 6 | ], 7 | copts = ["-Itests"], 8 | # This is required. 9 | linkstatic = 1, 10 | deps = [ 11 | "//tests:monster_test_cc_fbs", 12 | "//tests:monster_test_grpc", 13 | "//tests:test_assert", 14 | "//tests:test_builder", 15 | "@com_github_grpc_grpc//:grpc++", 16 | ], 17 | ) 18 | -------------------------------------------------------------------------------- /tests/MyGame/Example/LongEnum.lua: -------------------------------------------------------------------------------- 1 | --[[ MyGame.Example.LongEnum 2 | 3 | Automatically generated by the FlatBuffers compiler, do not modify. 4 | Or modify. I'm a message, not a cop. 5 | 6 | flatc version: 2.0.7 7 | 8 | Declared by : //monster_test.fbs 9 | Rooting type : MyGame.Example.Monster (//monster_test.fbs) 10 | 11 | --]] 12 | 13 | local LongEnum = { 14 | LongOne = 2, 15 | LongTwo = 4, 16 | LongBig = 1099511627776, 17 | } 18 | 19 | return LongEnum -------------------------------------------------------------------------------- /tests/union_vector/Gadget.kt: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | 3 | @Suppress("unused") 4 | class Gadget private constructor() { 5 | companion object { 6 | const val NONE: UByte = 0u 7 | const val FallingTub: UByte = 1u 8 | const val HandFan: UByte = 2u 9 | val names : Array = arrayOf("NONE", "FallingTub", "HandFan") 10 | fun name(e: Int) : String = names[e] 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /swift/Sources/FlatBuffers/Documentation.docc/Resources/code/swift/swift_code_11.swift: -------------------------------------------------------------------------------- 1 | import FlatBuffers 2 | import Foundation 3 | 4 | func run() { 5 | // create a ByteBuffer(:) from an [UInt8] or Data() 6 | let buf = [] // Get your data 7 | 8 | // Get an accessor to the root object inside the buffer. 9 | let monster: Monster = try! getCheckedRoot(byteBuffer: ByteBuffer(bytes: buf)) 10 | // let monster: Monster = getRoot(byteBuffer: ByteBuffer(bytes: buf)) 11 | } 12 | -------------------------------------------------------------------------------- /tests/test_dir/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("//:typescript.bzl", "flatbuffer_ts_library") 2 | 3 | flatbuffer_ts_library( 4 | name = "typescript_transitive_ts_fbs", 5 | srcs = ["typescript_transitive_include.fbs"], 6 | visibility = ["//visibility:public"], 7 | ) 8 | 9 | flatbuffer_ts_library( 10 | name = "include_ts_fbs", 11 | srcs = ["typescript_include.fbs"], 12 | visibility = ["//visibility:public"], 13 | deps = [":typescript_transitive_ts_fbs"], 14 | ) 15 | -------------------------------------------------------------------------------- /tests/MyGame/Example/Any.lua: -------------------------------------------------------------------------------- 1 | --[[ MyGame.Example.Any 2 | 3 | Automatically generated by the FlatBuffers compiler, do not modify. 4 | Or modify. I'm a message, not a cop. 5 | 6 | flatc version: 2.0.7 7 | 8 | Declared by : //monster_test.fbs 9 | Rooting type : MyGame.Example.Monster (//monster_test.fbs) 10 | 11 | --]] 12 | 13 | local Any = { 14 | NONE = 0, 15 | Monster = 1, 16 | TestSimpleTableWithEnum = 2, 17 | MyGame_Example2_Monster = 3, 18 | } 19 | 20 | return Any -------------------------------------------------------------------------------- /tests/union_vector/HandFanT.java: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | 3 | import java.nio.*; 4 | import java.lang.*; 5 | import java.util.*; 6 | import com.google.flatbuffers.*; 7 | 8 | public class HandFanT { 9 | private int length; 10 | 11 | public int getLength() { return length; } 12 | 13 | public void setLength(int length) { this.length = length; } 14 | 15 | 16 | public HandFanT() { 17 | this.length = 0; 18 | } 19 | } 20 | 21 | -------------------------------------------------------------------------------- /CMake/FlatBuffersConfigVersion.cmake.in: -------------------------------------------------------------------------------- 1 | set(PACKAGE_VERSION "@VERSION_MAJOR@.@VERSION_MINOR@.@VERSION_PATCH@") 2 | 3 | # Check whether the requested PACKAGE_FIND_VERSION is compatible 4 | if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}") 5 | set(PACKAGE_VERSION_COMPATIBLE FALSE) 6 | else() 7 | set(PACKAGE_VERSION_COMPATIBLE TRUE) 8 | if ("${PACKAGE_VERSION}" VERSION_EQUAL "${PACKAGE_FIND_VERSION}") 9 | set(PACKAGE_VERSION_EXACT TRUE) 10 | endif() 11 | endif() 12 | -------------------------------------------------------------------------------- /tests/MyGame/Example/AnyUniqueAliases.lua: -------------------------------------------------------------------------------- 1 | --[[ MyGame.Example.AnyUniqueAliases 2 | 3 | Automatically generated by the FlatBuffers compiler, do not modify. 4 | Or modify. I'm a message, not a cop. 5 | 6 | flatc version: 2.0.7 7 | 8 | Declared by : //monster_test.fbs 9 | Rooting type : MyGame.Example.Monster (//monster_test.fbs) 10 | 11 | --]] 12 | 13 | local AnyUniqueAliases = { 14 | NONE = 0, 15 | M = 1, 16 | TS = 2, 17 | M2 = 3, 18 | } 19 | 20 | return AnyUniqueAliases -------------------------------------------------------------------------------- /tests/docker/languages/Dockerfile.testing.rust.big_endian.1_51_0: -------------------------------------------------------------------------------- 1 | FROM rust:1.51.0-slim as base 2 | RUN apt -qq update -y && apt -qq install -y \ 3 | gcc-mips-linux-gnu \ 4 | libexpat1 \ 5 | libmagic1 \ 6 | libmpdec2 \ 7 | libreadline7 \ 8 | qemu-user 9 | RUN rustup target add mips-unknown-linux-gnu 10 | WORKDIR /code 11 | ADD . . 12 | RUN cp flatc_debian_stretch flatc 13 | WORKDIR /code/tests 14 | RUN rustc --version 15 | RUN ./RustTest.sh mips-unknown-linux-gnu 16 | -------------------------------------------------------------------------------- /tests/optional_scalars/OptionalByte.kt: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | 3 | package optional_scalars 4 | 5 | @Suppress("unused") 6 | class OptionalByte private constructor() { 7 | companion object { 8 | const val None: Byte = 0 9 | const val One: Byte = 1 10 | const val Two: Byte = 2 11 | val names : Array = arrayOf("None", "One", "Two") 12 | fun name(e: Int) : String = names[e] 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /tests/MyGame/OtherNameSpace/UnusedT.java: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | 3 | package MyGame.OtherNameSpace; 4 | 5 | import java.nio.*; 6 | import java.lang.*; 7 | import java.util.*; 8 | import com.google.flatbuffers.*; 9 | 10 | public class UnusedT { 11 | private int a; 12 | 13 | public int getA() { return a; } 14 | 15 | public void setA(int a) { this.a = a; } 16 | 17 | 18 | public UnusedT() { 19 | this.a = 0; 20 | } 21 | } 22 | 23 | -------------------------------------------------------------------------------- /tests/union_vector/FallingTubT.java: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | 3 | import java.nio.*; 4 | import java.lang.*; 5 | import java.util.*; 6 | import com.google.flatbuffers.*; 7 | 8 | public class FallingTubT { 9 | private int weight; 10 | 11 | public int getWeight() { return weight; } 12 | 13 | public void setWeight(int weight) { this.weight = weight; } 14 | 15 | 16 | public FallingTubT() { 17 | this.weight = 0; 18 | } 19 | } 20 | 21 | -------------------------------------------------------------------------------- /tests/union_vector/Gadget.java: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | 3 | @SuppressWarnings("unused") 4 | public final class Gadget { 5 | private Gadget() { } 6 | public static final byte NONE = 0; 7 | public static final byte FallingTub = 1; 8 | public static final byte HandFan = 2; 9 | 10 | public static final String[] names = { "NONE", "FallingTub", "HandFan", }; 11 | 12 | public static String name(int e) { return names[e]; } 13 | } 14 | 15 | -------------------------------------------------------------------------------- /tests/union_vector/union_vector.json: -------------------------------------------------------------------------------- 1 | { 2 | "main_character_type": "Rapunzel", 3 | "main_character": { 4 | "hair_length": 6 5 | }, 6 | "characters_type": [ 7 | "Belle", 8 | "MuLan", 9 | "BookFan", 10 | "Other", 11 | "Unused" 12 | ], 13 | "characters": [ 14 | { 15 | "books_read": 7 16 | }, 17 | { 18 | "sword_attack_damage": 5 19 | }, 20 | { 21 | "books_read": 2 22 | }, 23 | "Other", 24 | "Unused" 25 | ] 26 | } 27 | -------------------------------------------------------------------------------- /ts/index.ts: -------------------------------------------------------------------------------- 1 | export { SIZEOF_SHORT } from './constants.js' 2 | export { SIZEOF_INT } from './constants.js' 3 | export { FILE_IDENTIFIER_LENGTH } from './constants.js' 4 | export { SIZE_PREFIX_LENGTH } from './constants.js' 5 | 6 | export { Table, Offset } from './types.js' 7 | 8 | export { int32, float32, float64, isLittleEndian } from './utils.js' 9 | 10 | export { Encoding } from './encoding.js' 11 | export { Builder } from './builder.js' 12 | export { ByteBuffer } from './byte-buffer.js' 13 | -------------------------------------------------------------------------------- /reflection/ts/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("//:typescript.bzl", "flatbuffer_ts_library") 2 | 3 | genrule( 4 | name = "copy_schema_to_folder", 5 | srcs = ["//reflection:reflection_fbs_schema"], 6 | outs = ["reflection.fbs"], 7 | cmd = "cp $< $@", 8 | ) 9 | 10 | flatbuffer_ts_library( 11 | name = "reflection_ts_fbs", 12 | package_name = "flatbuffers_reflection", 13 | srcs = [":reflection.fbs"], 14 | include_reflection = False, 15 | visibility = ["//visibility:public"], 16 | ) 17 | -------------------------------------------------------------------------------- /tests/MyGame/Example/TestEnum.java: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | 3 | package MyGame.Example; 4 | 5 | @SuppressWarnings("unused") 6 | public final class TestEnum { 7 | private TestEnum() { } 8 | public static final byte A = 0; 9 | public static final byte B = 1; 10 | public static final byte C = 2; 11 | 12 | public static final String[] names = { "A", "B", "C", }; 13 | 14 | public static String name(int e) { return names[e]; } 15 | } 16 | 17 | -------------------------------------------------------------------------------- /tests/arrays_test.fbs: -------------------------------------------------------------------------------- 1 | namespace MyGame.Example; 2 | 3 | enum TestEnum : byte { A, B, C } 4 | 5 | struct NestedStruct{ 6 | a:[int:2]; 7 | b:TestEnum; 8 | c:[TestEnum:2]; 9 | d:[int64:2]; 10 | } 11 | 12 | struct ArrayStruct{ 13 | a:float; 14 | b:[int:0xF]; 15 | c:byte; 16 | d:[NestedStruct:2]; 17 | e:int32; 18 | f:[int64:2]; 19 | } 20 | 21 | table ArrayTable{ 22 | a:ArrayStruct; 23 | } 24 | 25 | root_type ArrayTable; 26 | file_identifier "ARRT"; 27 | file_extension "mon"; 28 | -------------------------------------------------------------------------------- /tests/keyword_test/mod.rs: -------------------------------------------------------------------------------- 1 | // Automatically generated by the Flatbuffers compiler. Do not modify. 2 | // @generated 3 | pub mod keyword_test { 4 | use super::*; 5 | mod abc_generated; 6 | pub use self::abc_generated::*; 7 | mod public_generated; 8 | pub use self::public_generated::*; 9 | mod keywords_in_union_generated; 10 | pub use self::keywords_in_union_generated::*; 11 | mod keywords_in_table_generated; 12 | pub use self::keywords_in_table_generated::*; 13 | } // keyword_test 14 | -------------------------------------------------------------------------------- /dart/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: flat_buffers 2 | version: 2.0.5 3 | description: FlatBuffers reading and writing library for Dart. Based on original work by Konstantin Scheglov and Paul Berry of the Dart SDK team. 4 | homepage: https://github.com/google/flatbuffers 5 | documentation: https://google.github.io/flatbuffers/index.html 6 | 7 | environment: 8 | sdk: '>=2.12.0 <3.0.0' 9 | 10 | dev_dependencies: 11 | test: ^1.17.7 12 | test_reflective_loader: ^0.2.0 13 | path: ^1.8.0 14 | lints: ^1.0.1 15 | 16 | -------------------------------------------------------------------------------- /tests/MyGame/Example/AnyAmbiguousAliases.lua: -------------------------------------------------------------------------------- 1 | --[[ MyGame.Example.AnyAmbiguousAliases 2 | 3 | Automatically generated by the FlatBuffers compiler, do not modify. 4 | Or modify. I'm a message, not a cop. 5 | 6 | flatc version: 2.0.7 7 | 8 | Declared by : //monster_test.fbs 9 | Rooting type : MyGame.Example.Monster (//monster_test.fbs) 10 | 11 | --]] 12 | 13 | local AnyAmbiguousAliases = { 14 | NONE = 0, 15 | M1 = 1, 16 | M2 = 2, 17 | M3 = 3, 18 | } 19 | 20 | return AnyAmbiguousAliases -------------------------------------------------------------------------------- /tests/MyGame/Example/ReferrableT.java: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | 3 | package MyGame.Example; 4 | 5 | import java.nio.*; 6 | import java.lang.*; 7 | import java.util.*; 8 | import com.google.flatbuffers.*; 9 | 10 | public class ReferrableT { 11 | private long id; 12 | 13 | public long getId() { return id; } 14 | 15 | public void setId(long id) { this.id = id; } 16 | 17 | 18 | public ReferrableT() { 19 | this.id = 0L; 20 | } 21 | } 22 | 23 | -------------------------------------------------------------------------------- /tests/native_type_test.fbs: -------------------------------------------------------------------------------- 1 | native_include "native_type_test_impl.h"; 2 | 3 | namespace Geometry; 4 | 5 | struct Vector3D (native_type:"Native::Vector3D") { 6 | x:float; 7 | y:float; 8 | z:float; 9 | } 10 | 11 | struct Vector3DAlt (native_type:"Native::Vector3D", native_type_pack_name:"Vector3DAlt") { 12 | a:float; 13 | b:float; 14 | c:float; 15 | } 16 | 17 | table ApplicationData { 18 | vectors:[Vector3D]; 19 | vectors_alt:[Vector3DAlt]; 20 | } 21 | 22 | root_type ApplicationData; 23 | -------------------------------------------------------------------------------- /tests/union_vector/union_vector.js: -------------------------------------------------------------------------------- 1 | export { Attacker, AttackerT } from './attacker'; 2 | export { BookReader, BookReaderT } from './book-reader'; 3 | export { Character, unionToCharacter, unionListToCharacter } from './character'; 4 | export { FallingTub, FallingTubT } from './falling-tub'; 5 | export { Gadget, unionToGadget, unionListToGadget } from './gadget'; 6 | export { HandFan, HandFanT } from './hand-fan'; 7 | export { Movie, MovieT } from './movie'; 8 | export { Rapunzel, RapunzelT } from './rapunzel'; 9 | -------------------------------------------------------------------------------- /tests/union_vector/union_vector.ts: -------------------------------------------------------------------------------- 1 | export { Attacker, AttackerT } from './attacker'; 2 | export { BookReader, BookReaderT } from './book-reader'; 3 | export { Character, unionToCharacter, unionListToCharacter } from './character'; 4 | export { FallingTub, FallingTubT } from './falling-tub'; 5 | export { Gadget, unionToGadget, unionListToGadget } from './gadget'; 6 | export { HandFan, HandFanT } from './hand-fan'; 7 | export { Movie, MovieT } from './movie'; 8 | export { Rapunzel, RapunzelT } from './rapunzel'; 9 | -------------------------------------------------------------------------------- /tests/MyGame/OtherNameSpace/TableBT.java: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | 3 | package MyGame.OtherNameSpace; 4 | 5 | import java.nio.*; 6 | import java.lang.*; 7 | import java.util.*; 8 | import com.google.flatbuffers.*; 9 | 10 | public class TableBT { 11 | private TableAT a; 12 | 13 | public TableAT getA() { return a; } 14 | 15 | public void setA(TableAT a) { this.a = a; } 16 | 17 | 18 | public TableBT() { 19 | this.a = null; 20 | } 21 | } 22 | 23 | -------------------------------------------------------------------------------- /tests/TableAT.java: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | 3 | import java.nio.*; 4 | import java.lang.*; 5 | import java.util.*; 6 | import com.google.flatbuffers.*; 7 | 8 | public class TableAT { 9 | private MyGame.OtherNameSpace.TableBT b; 10 | 11 | public MyGame.OtherNameSpace.TableBT getB() { return b; } 12 | 13 | public void setB(MyGame.OtherNameSpace.TableBT b) { this.b = b; } 14 | 15 | 16 | public TableAT() { 17 | this.b = null; 18 | } 19 | } 20 | 21 | -------------------------------------------------------------------------------- /tests/monsterdata_extra.json: -------------------------------------------------------------------------------- 1 | { 2 | // Initialize with non-default values. 3 | d0 : -nan, // match with default 4 | d1 : +inf, 5 | d2 : -inf, 6 | d3: nan, 7 | f0 : +nan, // match with default 8 | f1 : -nan, // match with default 9 | f2 : +inf, // match with default 10 | f3 : -inf, // match with default 11 | // Values should have exact binary representation 12 | // to avoid rounding effects in tests. 13 | dvec : [2.0, +inf, -inf, nan,], 14 | fvec : [1.0, -inf, +inf, nan], 15 | } 16 | -------------------------------------------------------------------------------- /tests/typescript_keywords.fbs: -------------------------------------------------------------------------------- 1 | include 'test_dir/typescript_include.fbs'; 2 | include 'reflection/reflection.fbs'; 3 | 4 | // This file includes a variety of keywords meant to deliberately interfere 5 | // with typescript keywords. 6 | namespace typescript; 7 | 8 | enum class: int { 9 | new, 10 | instanceof, 11 | } 12 | 13 | table Object { 14 | return:int; 15 | if:int; 16 | switch:int; 17 | enum:class; 18 | enum2:foobar.class; 19 | enum3:foobar.Abc; 20 | reflect:reflection.Schema; 21 | } 22 | -------------------------------------------------------------------------------- /benchmarks/cpp/bench.h: -------------------------------------------------------------------------------- 1 | #ifndef BENCHMARKS_CPP_BENCH_H_ 2 | #define BENCHMARKS_CPP_BENCH_H_ 3 | 4 | #include 5 | 6 | struct Bench { 7 | virtual ~Bench() {} 8 | 9 | inline void Add(int64_t value) { sum += value; } 10 | 11 | virtual uint8_t *Encode(void *buf, int64_t &len) = 0; 12 | virtual void *Decode(void *buf, int64_t len) = 0; 13 | virtual int64_t Use(void *decoded) = 0; 14 | virtual void Dealloc(void *decoded) = 0; 15 | 16 | int64_t sum = 0; 17 | }; 18 | 19 | #endif // BENCHMARKS_CPP_BENCH_H_ -------------------------------------------------------------------------------- /tests/nested_namespace_test/nested_namespace_test2_generated.cs: -------------------------------------------------------------------------------- 1 | // 2 | // automatically generated by the FlatBuffers compiler, do not modify 3 | // 4 | 5 | namespace NamespaceA.NamespaceB 6 | { 7 | 8 | using global::System; 9 | using global::System.Collections.Generic; 10 | using global::FlatBuffers; 11 | 12 | [Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))] 13 | public enum Color : sbyte 14 | { 15 | Purple = 0, 16 | }; 17 | 18 | 19 | } 20 | -------------------------------------------------------------------------------- /tests/union_vector/BookReaderT.java: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | 3 | import java.nio.*; 4 | import java.lang.*; 5 | import java.util.*; 6 | import com.google.flatbuffers.*; 7 | 8 | public class BookReaderT { 9 | private int booksRead; 10 | 11 | public int getBooksRead() { return booksRead; } 12 | 13 | public void setBooksRead(int booksRead) { this.booksRead = booksRead; } 14 | 15 | 16 | public BookReaderT() { 17 | this.booksRead = 0; 18 | } 19 | } 20 | 21 | -------------------------------------------------------------------------------- /tests/union_vector/RapunzelT.java: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | 3 | import java.nio.*; 4 | import java.lang.*; 5 | import java.util.*; 6 | import com.google.flatbuffers.*; 7 | 8 | public class RapunzelT { 9 | private int hairLength; 10 | 11 | public int getHairLength() { return hairLength; } 12 | 13 | public void setHairLength(int hairLength) { this.hairLength = hairLength; } 14 | 15 | 16 | public RapunzelT() { 17 | this.hairLength = 0; 18 | } 19 | } 20 | 21 | -------------------------------------------------------------------------------- /docs/footer.html: -------------------------------------------------------------------------------- 1 | 2 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /grpc/examples/ts/greeter/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es5", 4 | "module": "commonjs", 5 | "outDir": "./dist", 6 | "allowJs": true, 7 | "sourceMap": true, 8 | "strict": true, 9 | "noImplicitAny": false, 10 | "strictNullChecks": false, 11 | "esModuleInterop": true, 12 | "baseUrl": "./", 13 | "typeRoots": ["node_modules/@types"], 14 | "skipLibCheck": true, 15 | "forceConsistentCasingInFileNames": true 16 | } 17 | } -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | # Security Policy 2 | 3 | ## Reporting a Vulnerability 4 | 5 | To report a security issue, please use http://g.co/vulnz. We use 6 | http://g.co/vulnz for our intake, and do coordination and disclosure here on 7 | GitHub (including using GitHub Security Advisory). The Google Security Team will 8 | respond within 5 working days of your report on g.co/vulnz. 9 | 10 | Select the `I want to report a technical security or an abuse risk related bug 11 | in a Google product (SQLi, XSS, etc.)` option and complete the form. 12 | -------------------------------------------------------------------------------- /grpc/examples/go/greeter/README.md: -------------------------------------------------------------------------------- 1 | # Go Greeter example 2 | 3 | ## Project Structure 4 | 5 | . 6 | ├── server # Server module 7 | ├── client # Client module 8 | ├── models # Flatbuffers models & main grpc code. 9 | └── README.md 10 | 11 | ## How to run Server: 12 | 13 | - `cd server` 14 | 15 | - `go clean` 16 | 17 | - `go run main.go` 18 | 19 | ## How to run Client: 20 | 21 | - `cd client` 22 | 23 | - `go clean` 24 | 25 | - `go run main.go --name NAME` -------------------------------------------------------------------------------- /tests/optional_scalars/OptionalByte.java: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | 3 | package optional_scalars; 4 | 5 | @SuppressWarnings("unused") 6 | public final class OptionalByte { 7 | private OptionalByte() { } 8 | public static final byte None = 0; 9 | public static final byte One = 1; 10 | public static final byte Two = 2; 11 | 12 | public static final String[] names = { "None", "One", "Two", }; 13 | 14 | public static String name(int e) { return names[e]; } 15 | } 16 | 17 | -------------------------------------------------------------------------------- /python/flatbuffers/reflection/BaseType.py: -------------------------------------------------------------------------------- 1 | # automatically generated by the FlatBuffers compiler, do not modify 2 | 3 | # namespace: reflection 4 | 5 | class BaseType(object): 6 | None_ = 0 7 | UType = 1 8 | Bool = 2 9 | Byte = 3 10 | UByte = 4 11 | Short = 5 12 | UShort = 6 13 | Int = 7 14 | UInt = 8 15 | Long = 9 16 | ULong = 10 17 | Float = 11 18 | Double = 12 19 | String = 13 20 | Vector = 14 21 | Obj = 15 22 | Union = 16 23 | Array = 17 24 | MaxBaseType = 18 25 | -------------------------------------------------------------------------------- /swift/Sources/FlatBuffers/Documentation.docc/Resources/code/fbs/monster_step_6.fbs: -------------------------------------------------------------------------------- 1 | enum Color:byte { red, green, blue } 2 | 3 | union Equipment { Weapon } // Optionally add more tables. 4 | 5 | struct Vec3 { 6 | x:float; 7 | y:float; 8 | } 9 | 10 | table Monster { 11 | pos:Vec3; 12 | color:Color = Blue; 13 | 14 | mana:short = 150; 15 | hp:short = 100; 16 | name:string; 17 | equipped:Equipment; 18 | weapons:[Weapon]; 19 | path:[Vec3]; 20 | } 21 | 22 | table Weapon { 23 | name:string; 24 | damage:short; 25 | } 26 | -------------------------------------------------------------------------------- /tests/MyGame/Example/AnyUniqueAliases.kt: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | 3 | package MyGame.Example 4 | 5 | @Suppress("unused") 6 | class AnyUniqueAliases private constructor() { 7 | companion object { 8 | const val NONE: UByte = 0u 9 | const val M: UByte = 1u 10 | const val TS: UByte = 2u 11 | const val M2: UByte = 3u 12 | val names : Array = arrayOf("NONE", "M", "TS", "M2") 13 | fun name(e: Int) : String = names[e] 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /tests/MyGame/Example/Race.kt: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | 3 | package MyGame.Example 4 | 5 | @Suppress("unused") 6 | class Race private constructor() { 7 | companion object { 8 | const val None: Byte = -1 9 | const val Human: Byte = 0 10 | const val Dwarf: Byte = 1 11 | const val Elf: Byte = 2 12 | val names : Array = arrayOf("None", "Human", "Dwarf", "Elf") 13 | fun name(e: Int) : String = names[e - None.toInt()] 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /tests/arrays_test.golden: -------------------------------------------------------------------------------- 1 | { 2 | a : { 3 | a: 12.34, 4 | b: [1,2,3,4,5,6,7,8,9,0xA,0xB,0xC,0xD,0xE,0xF], 5 | c: -127, 6 | d: [ 7 | { 8 | a : [-1,2], 9 | b : A, 10 | c : [C, B], 11 | d : [0x1122334455667788, -0x1122334455667788] 12 | }, 13 | { 14 | a : [3,-4], 15 | b : B, 16 | c : [B, A], 17 | d : [-0x1122334455667788, 0x1122334455667788] 18 | } 19 | ], 20 | e: 1, 21 | f: [-0x8000000000000000, 0x7FFFFFFFFFFFFFFF] 22 | } 23 | } -------------------------------------------------------------------------------- /tests/my-game/example/color.js: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | /** 3 | * Composite components of Monster color. 4 | */ 5 | export var Color; 6 | (function (Color) { 7 | Color[Color["Red"] = 1] = "Red"; 8 | /** 9 | * \brief color Green 10 | * Green is bit_flag with value (1u << 1) 11 | */ 12 | Color[Color["Green"] = 2] = "Green"; 13 | /** 14 | * \brief color Blue (1u << 3) 15 | */ 16 | Color[Color["Blue"] = 8] = "Blue"; 17 | })(Color || (Color = {})); 18 | -------------------------------------------------------------------------------- /tests/namespace_test/NamespaceA/NamespaceB/EnumInNestedNS.kt: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | 3 | package NamespaceA.NamespaceB 4 | 5 | @Suppress("unused") 6 | @ExperimentalUnsignedTypes 7 | class EnumInNestedNS private constructor() { 8 | companion object { 9 | const val A: Byte = 0 10 | const val B: Byte = 1 11 | const val C: Byte = 2 12 | val names : Array = arrayOf("A", "B", "C") 13 | fun name(e: Int) : String = names[e] 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /tests/namespace_test/NamespaceA/NamespaceB/UnionInNestedNS.java: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | 3 | package NamespaceA.NamespaceB; 4 | 5 | @SuppressWarnings("unused") 6 | public final class UnionInNestedNS { 7 | private UnionInNestedNS() { } 8 | public static final byte NONE = 0; 9 | public static final byte TableInNestedNS = 1; 10 | 11 | public static final String[] names = { "NONE", "TableInNestedNS", }; 12 | 13 | public static String name(int e) { return names[e]; } 14 | } 15 | 16 | -------------------------------------------------------------------------------- /tests/namespace_test/NamespaceA/NamespaceB/UnionInNestedNS.kt: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | 3 | package NamespaceA.NamespaceB 4 | 5 | @Suppress("unused") 6 | @ExperimentalUnsignedTypes 7 | class UnionInNestedNS private constructor() { 8 | companion object { 9 | const val NONE: UByte = 0u 10 | const val TableInNestedNS: UByte = 1u 11 | val names : Array = arrayOf("NONE", "TableInNestedNS") 12 | fun name(e: Int) : String = names[e] 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /tests/nested_namespace_test/nested_namespace_test1_generated.cs: -------------------------------------------------------------------------------- 1 | // 2 | // automatically generated by the FlatBuffers compiler, do not modify 3 | // 4 | 5 | namespace NamespaceB 6 | { 7 | 8 | using global::System; 9 | using global::System.Collections.Generic; 10 | using global::FlatBuffers; 11 | 12 | [Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))] 13 | public enum Color : sbyte 14 | { 15 | Red = 0, 16 | Green = 1, 17 | Blue = 2, 18 | }; 19 | 20 | 21 | } 22 | -------------------------------------------------------------------------------- /tests/namespace_test/NamespaceA/NamespaceB/EnumInNestedNS.java: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | 3 | package NamespaceA.NamespaceB; 4 | 5 | @SuppressWarnings("unused") 6 | public final class EnumInNestedNS { 7 | private EnumInNestedNS() { } 8 | public static final byte A = 0; 9 | public static final byte B = 1; 10 | public static final byte C = 2; 11 | 12 | public static final String[] names = { "A", "B", "C", }; 13 | 14 | public static String name(int e) { return names[e]; } 15 | } 16 | 17 | -------------------------------------------------------------------------------- /conan/travis/install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | set -x 5 | 6 | if [[ "$(uname -s)" == 'Darwin' ]]; then 7 | brew update || brew update 8 | brew outdated pyenv || brew upgrade pyenv 9 | brew install pyenv-virtualenv 10 | brew install cmake || true 11 | 12 | if which pyenv > /dev/null; then 13 | eval "$(pyenv init -)" 14 | fi 15 | 16 | pyenv install 2.7.10 17 | pyenv virtualenv 2.7.10 conan 18 | pyenv rehash 19 | pyenv activate conan 20 | fi 21 | 22 | pip install -U conan_package_tools conan 23 | -------------------------------------------------------------------------------- /tests/MyGame/Example/AnyAmbiguousAliases.kt: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | 3 | package MyGame.Example 4 | 5 | @Suppress("unused") 6 | class AnyAmbiguousAliases private constructor() { 7 | companion object { 8 | const val NONE: UByte = 0u 9 | const val M1: UByte = 1u 10 | const val M2: UByte = 2u 11 | const val M3: UByte = 3u 12 | val names : Array = arrayOf("NONE", "M1", "M2", "M3") 13 | fun name(e: Int) : String = names[e] 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /tests/unicode_test.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "unicode_test", 3 | "testarrayofstring": [ 4 | "Цлїςσδε", 5 | "フムアムカモケモ", 6 | "フムヤムカモケモ", 7 | "㊀㊁㊂㊃㊄", 8 | "☳☶☲", 9 | "𡇙𝌆" 10 | ], 11 | "testarrayoftables": [ 12 | { 13 | "name": "Цлїςσδε" 14 | }, 15 | { 16 | "name": "☳☶☲" 17 | }, 18 | { 19 | "name": "フムヤムカモケモ" 20 | }, 21 | { 22 | "name": "㊀㊁㊂㊃㊄" 23 | }, 24 | { 25 | "name": "フムアムカモケモ" 26 | }, 27 | { 28 | "name": "𡇙𝌆" 29 | } 30 | ] 31 | } 32 | -------------------------------------------------------------------------------- /tests/MyGame/Example/TestSimpleTableWithEnumT.java: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | 3 | package MyGame.Example; 4 | 5 | import java.nio.*; 6 | import java.lang.*; 7 | import java.util.*; 8 | import com.google.flatbuffers.*; 9 | 10 | class TestSimpleTableWithEnumT { 11 | private int color; 12 | 13 | public int getColor() { return color; } 14 | 15 | public void setColor(int color) { this.color = color; } 16 | 17 | 18 | public TestSimpleTableWithEnumT() { 19 | this.color = 2; 20 | } 21 | } 22 | 23 | -------------------------------------------------------------------------------- /tests/namespace_test/NamespaceA/NamespaceB/TableInNestedNST.java: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | 3 | package NamespaceA.NamespaceB; 4 | 5 | import java.nio.*; 6 | import java.lang.*; 7 | import java.util.*; 8 | import com.google.flatbuffers.*; 9 | 10 | public class TableInNestedNST { 11 | private int foo; 12 | 13 | public int getFoo() { return foo; } 14 | 15 | public void setFoo(int foo) { this.foo = foo; } 16 | 17 | 18 | public TableInNestedNST() { 19 | this.foo = 0; 20 | } 21 | } 22 | 23 | -------------------------------------------------------------------------------- /tests/include_test1/mod.rs: -------------------------------------------------------------------------------- 1 | // Automatically generated by the Flatbuffers compiler. Do not modify. 2 | // @generated 3 | pub mod my_game { 4 | use super::*; 5 | pub mod other_name_space { 6 | use super::*; 7 | mod from_include_generated; 8 | pub use self::from_include_generated::*; 9 | mod unused_generated; 10 | pub use self::unused_generated::*; 11 | mod table_b_generated; 12 | pub use self::table_b_generated::*; 13 | } // other_name_space 14 | } // my_game 15 | mod table_a_generated; 16 | pub use self::table_a_generated::*; 17 | -------------------------------------------------------------------------------- /tests/include_test2/mod.rs: -------------------------------------------------------------------------------- 1 | // Automatically generated by the Flatbuffers compiler. Do not modify. 2 | // @generated 3 | pub mod my_game { 4 | use super::*; 5 | pub mod other_name_space { 6 | use super::*; 7 | mod from_include_generated; 8 | pub use self::from_include_generated::*; 9 | mod unused_generated; 10 | pub use self::unused_generated::*; 11 | mod table_b_generated; 12 | pub use self::table_b_generated::*; 13 | } // other_name_space 14 | } // my_game 15 | mod table_a_generated; 16 | pub use self::table_a_generated::*; 17 | -------------------------------------------------------------------------------- /grpc/samples/greeter/Makefile: -------------------------------------------------------------------------------- 1 | CXXFLAGS ?= -I../../../include 2 | LDFLAGS ?= 3 | 4 | .PHONY: all 5 | all: server client 6 | 7 | greeter_generated: greeter.fbs 8 | flatc --grpc --cpp $< 9 | 10 | server: greeter_generated server.cpp greeter.grpc.fb.cc greeter.grpc.fb.h 11 | g++ -std=c++11 -O2 $(CXXFLAGS) $(LDFLAGS) -lgpr -lgrpc -lgrpc++ server.cpp greeter.grpc.fb.cc -o $@ 12 | 13 | client: greeter_generated client.cpp greeter.grpc.fb.cc greeter.grpc.fb.h 14 | g++ -std=c++11 -O2 $(CXXFLAGS) $(LDFLAGS) -lgpr -lgrpc -lgrpc++ client.cpp greeter.grpc.fb.cc -o $@ 15 | -------------------------------------------------------------------------------- /lua/flatbuffers/compat_5_1.lua: -------------------------------------------------------------------------------- 1 | local m = {} 2 | local ok, bit = pcall(require, "bit32") 3 | assert(ok, "The Bit32 library must be installed") 4 | assert(pcall(require, "compat53"), "The Compat 5.3 library must be installed") 5 | 6 | m.GetAlignSize = function(k, size) 7 | return bit.band(bit.bnot(k) + 1,(size - 1)) 8 | end 9 | 10 | if not table.unpack then 11 | table.unpack = unpack 12 | end 13 | 14 | if not table.pack then 15 | table.pack = pack 16 | end 17 | 18 | m.string_pack = string.pack 19 | m.string_unpack = string.unpack 20 | 21 | return m 22 | -------------------------------------------------------------------------------- /tests/MyGame/Example/Race.java: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | 3 | package MyGame.Example; 4 | 5 | @SuppressWarnings("unused") 6 | public final class Race { 7 | private Race() { } 8 | public static final byte None = -1; 9 | public static final byte Human = 0; 10 | public static final byte Dwarf = 1; 11 | public static final byte Elf = 2; 12 | 13 | public static final String[] names = { "None", "Human", "Dwarf", "Elf", }; 14 | 15 | public static String name(int e) { return names[e - None]; } 16 | } 17 | 18 | -------------------------------------------------------------------------------- /tests/fuzzer/flatbuffers_verifier_fuzzer.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Chromium Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | #include 5 | #include 6 | #include 7 | 8 | #include "cpp17/generated_cpp17/monster_test_generated.h" 9 | 10 | extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { 11 | flatbuffers::Verifier verifier(data, size); 12 | MyGame::Example::VerifyMonsterBuffer(verifier); 13 | return 0; 14 | } 15 | -------------------------------------------------------------------------------- /tests/namespace_test/NamespaceA/NamespaceB/UnionInNestedNS.py: -------------------------------------------------------------------------------- 1 | # automatically generated by the FlatBuffers compiler, do not modify 2 | 3 | # namespace: NamespaceB 4 | 5 | class UnionInNestedNS(object): 6 | NONE = 0 7 | TableInNestedNS = 1 8 | 9 | def UnionInNestedNSCreator(unionType, table): 10 | from flatbuffers.table import Table 11 | if not isinstance(table, Table): 12 | return None 13 | if unionType == UnionInNestedNS().TableInNestedNS: 14 | return TableInNestedNST.InitFromBuf(table.Bytes, table.Pos) 15 | return None 16 | -------------------------------------------------------------------------------- /tests/arrays_test/mod.rs: -------------------------------------------------------------------------------- 1 | // Automatically generated by the Flatbuffers compiler. Do not modify. 2 | // @generated 3 | pub mod my_game { 4 | use super::*; 5 | pub mod example { 6 | use super::*; 7 | mod test_enum_generated; 8 | pub use self::test_enum_generated::*; 9 | mod nested_struct_generated; 10 | pub use self::nested_struct_generated::*; 11 | mod array_struct_generated; 12 | pub use self::array_struct_generated::*; 13 | mod array_table_generated; 14 | pub use self::array_table_generated::*; 15 | } // example 16 | } // my_game 17 | -------------------------------------------------------------------------------- /go/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library") 2 | 3 | alias( 4 | name = "go_default_library", 5 | actual = ":go", 6 | visibility = ["//visibility:public"], 7 | ) 8 | 9 | go_library( 10 | name = "go", 11 | srcs = [ 12 | "builder.go", 13 | "doc.go", 14 | "encode.go", 15 | "grpc.go", 16 | "lib.go", 17 | "sizes.go", 18 | "struct.go", 19 | "table.go", 20 | ], 21 | importpath = "github.com/google/flatbuffers/go", 22 | visibility = ["//visibility:public"], 23 | ) 24 | -------------------------------------------------------------------------------- /tests/MyGame/Example/AnyUniqueAliases.java: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | 3 | package MyGame.Example; 4 | 5 | @SuppressWarnings("unused") 6 | public final class AnyUniqueAliases { 7 | private AnyUniqueAliases() { } 8 | public static final byte NONE = 0; 9 | public static final byte M = 1; 10 | public static final byte TS = 2; 11 | public static final byte M2 = 3; 12 | 13 | public static final String[] names = { "NONE", "M", "TS", "M2", }; 14 | 15 | public static String name(int e) { return names[e]; } 16 | } 17 | 18 | -------------------------------------------------------------------------------- /tests/union_vector/AttackerT.java: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | 3 | import java.nio.*; 4 | import java.lang.*; 5 | import java.util.*; 6 | import com.google.flatbuffers.*; 7 | 8 | public class AttackerT { 9 | private int swordAttackDamage; 10 | 11 | public int getSwordAttackDamage() { return swordAttackDamage; } 12 | 13 | public void setSwordAttackDamage(int swordAttackDamage) { this.swordAttackDamage = swordAttackDamage; } 14 | 15 | 16 | public AttackerT() { 17 | this.swordAttackDamage = 0; 18 | } 19 | } 20 | 21 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | Thank you for submitting an issue! 2 | 3 | Please make sure you include the names of the affected language(s), compiler version(s), operating system version(s), and FlatBuffers version(s) in your issue title. 4 | 5 | This helps us get the correct maintainers to look at your issue. Here are examples of good titles: 6 | 7 | - Crash when accessing FlatBuffer [C++, gcc 4.8, OS X, master] 8 | - Flatc converts a protobuf 'bytes' field to 'string' in fbs schema file [all languages, FlatBuffers 1.4] 9 | 10 | Include other details as appropriate. 11 | 12 | Thanks! 13 | -------------------------------------------------------------------------------- /tests/MyGame/Example/AnyAmbiguousAliases.java: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | 3 | package MyGame.Example; 4 | 5 | @SuppressWarnings("unused") 6 | public final class AnyAmbiguousAliases { 7 | private AnyAmbiguousAliases() { } 8 | public static final byte NONE = 0; 9 | public static final byte M1 = 1; 10 | public static final byte M2 = 2; 11 | public static final byte M3 = 3; 12 | 13 | public static final String[] names = { "NONE", "M1", "M2", "M3", }; 14 | 15 | public static String name(int e) { return names[e]; } 16 | } 17 | 18 | -------------------------------------------------------------------------------- /tests/MyGame/Example/Color.cs: -------------------------------------------------------------------------------- 1 | // 2 | // automatically generated by the FlatBuffers compiler, do not modify 3 | // 4 | 5 | namespace MyGame.Example 6 | { 7 | 8 | /// Composite components of Monster color. 9 | [Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))] 10 | [System.FlagsAttribute] 11 | public enum Color : byte 12 | { 13 | Red = 1, 14 | /// \brief color Green 15 | /// Green is bit_flag with value (1u << 1) 16 | Green = 2, 17 | /// \brief color Blue (1u << 3) 18 | Blue = 8, 19 | }; 20 | 21 | 22 | } 23 | -------------------------------------------------------------------------------- /tests/evolution_test/evolution_v2.json: -------------------------------------------------------------------------------- 1 | { 2 | "b": false, 3 | "c_type": "TableC", 4 | "c": { 5 | "a": 984.2494 6 | }, 7 | "d": "Bishop", 8 | "e": { 9 | "a": 3.1452, 10 | "b": 435, 11 | "c": "yummy yummy fig bar bar" 12 | }, 13 | "ff":{ 14 | "a": 35, 15 | "b": 243.980943 16 | }, 17 | "g": [ 7, 8, 10], 18 | "h": [ 19 | { 20 | "a": 212 21 | }, 22 | { 23 | "a": 459 24 | }, 25 | { 26 | "a": 333 27 | } 28 | ], 29 | "i": 4321, 30 | "k": { 31 | "a": 9874.342, 32 | "b": "more please" 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /swift/Sources/FlatBuffers/Documentation.docc/Resources/code/fbs/monster_step_7.fbs: -------------------------------------------------------------------------------- 1 | enum Color:byte { red, green, blue } 2 | 3 | union Equipment { Weapon } // Optionally add more tables. 4 | 5 | struct Vec3 { 6 | x:float; 7 | y:float; 8 | } 9 | 10 | table Monster { 11 | pos:Vec3; 12 | color:Color = Blue; 13 | 14 | mana:short = 150; 15 | hp:short = 100; 16 | name:string; 17 | equipped:Equipment; 18 | weapons:[Weapon]; 19 | path:[Vec3]; 20 | } 21 | 22 | table Weapon { 23 | name:string; 24 | damage:short; 25 | } 26 | 27 | root_type Monster; // flatc --swift monster.fbs 28 | -------------------------------------------------------------------------------- /tests/MyGame/Example/Color.lua: -------------------------------------------------------------------------------- 1 | --[[ MyGame.Example.Color 2 | 3 | Automatically generated by the FlatBuffers compiler, do not modify. 4 | Or modify. I'm a message, not a cop. 5 | 6 | flatc version: 2.0.7 7 | 8 | Declared by : //monster_test.fbs 9 | Rooting type : MyGame.Example.Monster (//monster_test.fbs) 10 | 11 | --]] 12 | 13 | -- Composite components of Monster color. 14 | local Color = { 15 | Red = 1, 16 | -- \brief color Green 17 | -- Green is bit_flag with value (1u << 1) 18 | Green = 2, 19 | -- \brief color Blue (1u << 3) 20 | Blue = 8, 21 | } 22 | 23 | return Color -------------------------------------------------------------------------------- /tests/union_vector/union_vector_generated.ts: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | 3 | export { Attacker, AttackerT } from './attacker'; 4 | export { BookReader, BookReaderT } from './book-reader'; 5 | export { Character, unionToCharacter, unionListToCharacter } from './character'; 6 | export { FallingTub, FallingTubT } from './falling-tub'; 7 | export { Gadget, unionToGadget, unionListToGadget } from './gadget'; 8 | export { HandFan, HandFanT } from './hand-fan'; 9 | export { Movie, MovieT } from './movie'; 10 | export { Rapunzel, RapunzelT } from './rapunzel'; 11 | -------------------------------------------------------------------------------- /tests/MyGame/Example/Any.kt: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | 3 | package MyGame.Example 4 | 5 | @Suppress("unused") 6 | class Any_ private constructor() { 7 | companion object { 8 | const val NONE: UByte = 0u 9 | const val Monster: UByte = 1u 10 | const val TestSimpleTableWithEnum: UByte = 2u 11 | const val MyGameExample2Monster: UByte = 3u 12 | val names : Array = arrayOf("NONE", "Monster", "TestSimpleTableWithEnum", "MyGame_Example2_Monster") 13 | fun name(e: Int) : String = names[e] 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /tests/docker/cpp_test.run.sh: -------------------------------------------------------------------------------- 1 | set -e 2 | 3 | JOBS=${JOBS:-1} 4 | export UBSAN_OPTIONS=halt_on_error=1 5 | export ASAN_OPTIONS=halt_on_error=1 6 | export MAKEFLAGS="-j$JOBS" 7 | 8 | config=$1 9 | echo "" 10 | echo "Build Flatbuffers project for '$config' with jobs=$JOBS" 11 | 12 | cmake . -DCMAKE_BUILD_TYPE=$config \ 13 | -DFLATBUFFERS_BUILD_TESTS=ON -DFLATBUFFERS_CODE_SANITIZE=ON 14 | cmake --build . --target all --clean-first -- -j$JOBS 15 | ctest --extra-verbose --output-on-failure -j$JOBS 16 | 17 | echo "Checking generated code" 18 | scripts/check_generate_code.py 19 | 20 | echo "C++ tests done" 21 | -------------------------------------------------------------------------------- /tests/evolution_test/evolution_v1.fbs: -------------------------------------------------------------------------------- 1 | namespace Evolution.V1; 2 | 3 | table TableA { 4 | a:float; 5 | b:int; 6 | } 7 | 8 | table TableB { 9 | a:int; 10 | } 11 | 12 | enum Enum : byte { 13 | King, 14 | Queen 15 | } 16 | 17 | union Union { 18 | TableA, 19 | TableB 20 | } 21 | 22 | struct Struct { 23 | a:int; 24 | b:double; 25 | } 26 | 27 | table Root { 28 | a:int; 29 | b:bool; 30 | c:Union; 31 | d:Enum; 32 | e:TableA; 33 | f:Struct; 34 | g:[int]; 35 | h:[TableB]; 36 | i:int = 1234; 37 | j:Union; 38 | } 39 | 40 | root_type Root; 41 | -------------------------------------------------------------------------------- /tests/union_vector/Gadget.php: -------------------------------------------------------------------------------- 1 | "NONE", 12 | Gadget::FallingTub=>"FallingTub", 13 | Gadget::HandFan=>"HandFan", 14 | ); 15 | 16 | public static function Name($e) 17 | { 18 | if (!isset(self::$names[$e])) { 19 | throw new \Exception(); 20 | } 21 | return self::$names[$e]; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /samples/rust_generated/mod.rs: -------------------------------------------------------------------------------- 1 | // Automatically generated by the Flatbuffers compiler. Do not modify. 2 | // @generated 3 | pub mod my_game { 4 | use super::*; 5 | pub mod sample { 6 | use super::*; 7 | mod color_generated; 8 | pub use self::color_generated::*; 9 | mod equipment_generated; 10 | pub use self::equipment_generated::*; 11 | mod vec_3_generated; 12 | pub use self::vec_3_generated::*; 13 | mod monster_generated; 14 | pub use self::monster_generated::*; 15 | mod weapon_generated; 16 | pub use self::weapon_generated::*; 17 | } // sample 18 | } // my_game 19 | -------------------------------------------------------------------------------- /tests/namespace_test/NamespaceA/SecondTableInAT.java: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | 3 | package NamespaceA; 4 | 5 | import java.nio.*; 6 | import java.lang.*; 7 | import java.util.*; 8 | import com.google.flatbuffers.*; 9 | 10 | public class SecondTableInAT { 11 | private NamespaceC.TableInCT referToC; 12 | 13 | public NamespaceC.TableInCT getReferToC() { return referToC; } 14 | 15 | public void setReferToC(NamespaceC.TableInCT referToC) { this.referToC = referToC; } 16 | 17 | 18 | public SecondTableInAT() { 19 | this.referToC = null; 20 | } 21 | } 22 | 23 | -------------------------------------------------------------------------------- /tests/MyGame/Example/TestT.java: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | 3 | package MyGame.Example; 4 | 5 | import java.nio.*; 6 | import java.lang.*; 7 | import java.util.*; 8 | import com.google.flatbuffers.*; 9 | 10 | public class TestT { 11 | private short a; 12 | private byte b; 13 | 14 | public short getA() { return a; } 15 | 16 | public void setA(short a) { this.a = a; } 17 | 18 | public byte getB() { return b; } 19 | 20 | public void setB(byte b) { this.b = b; } 21 | 22 | 23 | public TestT() { 24 | this.a = 0; 25 | this.b = 0; 26 | } 27 | } 28 | 29 | -------------------------------------------------------------------------------- /tests/monster_extra.fbs: -------------------------------------------------------------------------------- 1 | namespace MyGame; 2 | 3 | // Not all programming languages support this extra table. 4 | table MonsterExtra { 5 | // Float-point values with NaN and Inf defaults. 6 | d0:double = nan; 7 | d1:double = -nan; // parser must ignore sign of NaN 8 | d2:double = +inf; 9 | d3:double = -inf; 10 | f0:float = -nan; // parser must ignore sign of NaN 11 | f1:float = +nan; 12 | f2:float = +inf; 13 | f3:float = -inf; 14 | dvec : [double]; 15 | fvec : [float]; 16 | deprec:int (deprecated); 17 | } 18 | 19 | root_type MonsterExtra; 20 | 21 | file_identifier "MONE"; 22 | file_extension "mon"; 23 | -------------------------------------------------------------------------------- /tests/MyGame/Example/Any.java: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | 3 | package MyGame.Example; 4 | 5 | @SuppressWarnings("unused") 6 | public final class Any { 7 | private Any() { } 8 | public static final byte NONE = 0; 9 | public static final byte Monster = 1; 10 | public static final byte TestSimpleTableWithEnum = 2; 11 | public static final byte MyGame_Example2_Monster = 3; 12 | 13 | public static final String[] names = { "NONE", "Monster", "TestSimpleTableWithEnum", "MyGame_Example2_Monster", }; 14 | 15 | public static String name(int e) { return names[e]; } 16 | } 17 | 18 | -------------------------------------------------------------------------------- /tests/namespace_test/namespace_test2.fbs: -------------------------------------------------------------------------------- 1 | include "namespace_test1.fbs"; 2 | 3 | namespace NamespaceA; 4 | 5 | table TableInFirstNS 6 | { 7 | foo_table:NamespaceB.TableInNestedNS; 8 | foo_enum:NamespaceB.EnumInNestedNS; 9 | foo_union:NamespaceB.UnionInNestedNS; 10 | foo_struct:NamespaceB.StructInNestedNS; 11 | } 12 | 13 | // Test switching namespaces inside a file. 14 | namespace NamespaceC; 15 | 16 | table TableInC { 17 | refer_to_a1:NamespaceA.TableInFirstNS; 18 | refer_to_a2:NamespaceA.SecondTableInA; 19 | } 20 | 21 | namespace NamespaceA; 22 | 23 | table SecondTableInA { 24 | refer_to_c:NamespaceC.TableInC; 25 | } 26 | -------------------------------------------------------------------------------- /tests/MyGame/Example/StructOfStructsOfStructsT.java: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | 3 | package MyGame.Example; 4 | 5 | import java.nio.*; 6 | import java.lang.*; 7 | import java.util.*; 8 | import com.google.flatbuffers.*; 9 | 10 | public class StructOfStructsOfStructsT { 11 | private MyGame.Example.StructOfStructsT a; 12 | 13 | public MyGame.Example.StructOfStructsT getA() { return a; } 14 | 15 | public void setA(MyGame.Example.StructOfStructsT a) { this.a = a; } 16 | 17 | 18 | public StructOfStructsOfStructsT() { 19 | this.a = new MyGame.Example.StructOfStructsT(); 20 | } 21 | } 22 | 23 | -------------------------------------------------------------------------------- /tests/namespace_test/NamespaceA/NamespaceB/UnionInNestedNS.php: -------------------------------------------------------------------------------- 1 | "NONE", 13 | UnionInNestedNS::TableInNestedNS=>"TableInNestedNS", 14 | ); 15 | 16 | public static function Name($e) 17 | { 18 | if (!isset(self::$names[$e])) { 19 | throw new \Exception(); 20 | } 21 | return self::$names[$e]; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /tests/namespace_test/NamespaceA/NamespaceB/EnumInNestedNS.php: -------------------------------------------------------------------------------- 1 | "A", 14 | EnumInNestedNS::B=>"B", 15 | EnumInNestedNS::C=>"C", 16 | ); 17 | 18 | public static function Name($e) 19 | { 20 | if (!isset(self::$names[$e])) { 21 | throw new \Exception(); 22 | } 23 | return self::$names[$e]; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /tests/MyGame/Example/LongEnum.php: -------------------------------------------------------------------------------- 1 | "LongOne", 14 | LongEnum::LongTwo=>"LongTwo", 15 | LongEnum::LongBig=>"LongBig", 16 | ); 17 | 18 | public static function Name($e) 19 | { 20 | if (!isset(self::$names[$e])) { 21 | throw new \Exception(); 22 | } 23 | return self::$names[$e]; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /conan/test_package/conanfile.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | from conans import ConanFile, CMake 5 | import os 6 | 7 | 8 | class TestPackageConan(ConanFile): 9 | settings = "os", "compiler", "build_type", "arch" 10 | generators = "cmake" 11 | 12 | def build(self): 13 | cmake = CMake(self) 14 | cmake.configure() 15 | cmake.build() 16 | 17 | def test(self): 18 | bin_path = os.path.join("bin", "test_package") 19 | self.run(bin_path, run_environment=True) 20 | self.run("flatc --version", run_environment=True) 21 | self.run("flathash fnv1_16 conan", run_environment=True) 22 | -------------------------------------------------------------------------------- /tests/MyGame/Example/Race.php: -------------------------------------------------------------------------------- 1 | "None", 15 | Race::Human=>"Human", 16 | Race::Dwarf=>"Dwarf", 17 | Race::Elf=>"Elf", 18 | ); 19 | 20 | public static function Name($e) 21 | { 22 | if (!isset(self::$names[$e])) { 23 | throw new \Exception(); 24 | } 25 | return self::$names[$e]; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /tests/union_vector/Character.kt: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | 3 | @Suppress("unused") 4 | class Character_ private constructor() { 5 | companion object { 6 | const val NONE: UByte = 0u 7 | const val MuLan: UByte = 1u 8 | const val Rapunzel: UByte = 2u 9 | const val Belle: UByte = 3u 10 | const val BookFan: UByte = 4u 11 | const val Other: UByte = 5u 12 | const val Unused: UByte = 6u 13 | val names : Array = arrayOf("NONE", "MuLan", "Rapunzel", "Belle", "BookFan", "Other", "Unused") 14 | fun name(e: Int) : String = names[e] 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /swift/Sources/FlatBuffers/Documentation.docc/Resources/code/swift/swift_code_12.swift: -------------------------------------------------------------------------------- 1 | import FlatBuffers 2 | import Foundation 3 | 4 | func run() { 5 | // create a ByteBuffer(:) from an [UInt8] or Data() 6 | let buf = [] // Get your data 7 | 8 | // Get an accessor to the root object inside the buffer. 9 | let monster: Monster = try! getCheckedRoot(byteBuffer: ByteBuffer(bytes: buf)) 10 | // let monster: Monster = getRoot(byteBuffer: ByteBuffer(bytes: buf)) 11 | 12 | let hp = monster.hp 13 | let mana = monster.mana 14 | let name = monster.name // returns an optional string 15 | 16 | let pos = monster.pos 17 | let x = pos.x 18 | let y = pos.y 19 | } 20 | -------------------------------------------------------------------------------- /tests/namespace_test/NamespaceA/NamespaceB/StructInNestedNST.java: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | 3 | package NamespaceA.NamespaceB; 4 | 5 | import java.nio.*; 6 | import java.lang.*; 7 | import java.util.*; 8 | import com.google.flatbuffers.*; 9 | 10 | public class StructInNestedNST { 11 | private int a; 12 | private int b; 13 | 14 | public int getA() { return a; } 15 | 16 | public void setA(int a) { this.a = a; } 17 | 18 | public int getB() { return b; } 19 | 20 | public void setB(int b) { this.b = b; } 21 | 22 | 23 | public StructInNestedNST() { 24 | this.a = 0; 25 | this.b = 0; 26 | } 27 | } 28 | 29 | -------------------------------------------------------------------------------- /lua/flatbuffers/compat.lua: -------------------------------------------------------------------------------- 1 | local compats = { 2 | ["Lua 5.1"] = function() 3 | -- Check if Lua JIT is installed first 4 | local ok = pcall(require, "jit") 5 | if not ok then 6 | return require("flatbuffers.compat_5_1") 7 | else 8 | return require("flatbuffers.compat_luajit") 9 | end 10 | end, 11 | ["Lua 5.2"] = function() return require("flatbuffers.compat_5_1") end, 12 | ["Lua 5.3"] = function() return require("flatbuffers.compat_5_3") end, 13 | ["Lua 5.4"] = function() return require("flatbuffers.compat_5_3") end, 14 | } 15 | return assert(compats[_VERSION], "Unsupported Lua Version: ".._VERSION)() -------------------------------------------------------------------------------- /samples/monster.fbs: -------------------------------------------------------------------------------- 1 | // Example IDL file for our monster's schema. 2 | 3 | namespace MyGame.Sample; 4 | 5 | enum Color:byte { Red = 0, Green, Blue = 2 } 6 | 7 | union Equipment { Weapon } // Optionally add more tables. 8 | 9 | struct Vec3 { 10 | x:float; 11 | y:float; 12 | z:float; 13 | } 14 | 15 | table Monster { 16 | pos:Vec3; 17 | mana:short = 150; 18 | hp:short = 100; 19 | name:string; 20 | friendly:bool = false (deprecated); 21 | inventory:[ubyte]; 22 | color:Color = Blue; 23 | weapons:[Weapon]; 24 | equipped:Equipment; 25 | path:[Vec3]; 26 | } 27 | 28 | table Weapon { 29 | name:string; 30 | damage:short; 31 | } 32 | 33 | root_type Monster; 34 | -------------------------------------------------------------------------------- /ts/flexbuffers/value-type.ts: -------------------------------------------------------------------------------- 1 | export enum ValueType { 2 | NULL = 0, 3 | INT = 1, 4 | UINT = 2, 5 | FLOAT = 3, 6 | KEY = 4, 7 | STRING = 5, 8 | INDIRECT_INT = 6, 9 | INDIRECT_UINT = 7, 10 | INDIRECT_FLOAT = 8, 11 | MAP = 9, 12 | VECTOR = 10, 13 | VECTOR_INT = 11, 14 | VECTOR_UINT = 12, 15 | VECTOR_FLOAT = 13, 16 | VECTOR_KEY = 14, 17 | VECTOR_STRING_DEPRECATED = 15, 18 | VECTOR_INT2 = 16, 19 | VECTOR_UINT2 = 17, 20 | VECTOR_FLOAT2 = 18, 21 | VECTOR_INT3 = 19, 22 | VECTOR_UINT3 = 20, 23 | VECTOR_FLOAT3 = 21, 24 | VECTOR_INT4 = 22, 25 | VECTOR_UINT4 = 23, 26 | VECTOR_FLOAT4 = 24, 27 | BLOB = 25, 28 | BOOL = 26, 29 | VECTOR_BOOL = 36, 30 | } -------------------------------------------------------------------------------- /.github/workflows/label.yml: -------------------------------------------------------------------------------- 1 | # This workflow will triage pull requests and apply a label based on the 2 | # paths that are modified in the pull request. 3 | # 4 | # To use this workflow, you will need to set up a .github/labeler.yml 5 | # file with configuration. For more information, see: 6 | # https://github.com/actions/labeler 7 | 8 | name: Labeler 9 | permissions: read-all 10 | 11 | on: [pull_request_target] 12 | 13 | jobs: 14 | label: 15 | permissions: 16 | contents: read 17 | pull-requests: write 18 | 19 | runs-on: ubuntu-latest 20 | 21 | steps: 22 | - uses: actions/labeler@main 23 | with: 24 | repo-token: "${{ secrets.GITHUB_TOKEN }}" -------------------------------------------------------------------------------- /tests/MyGame/Example/AbilityT.java: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | 3 | package MyGame.Example; 4 | 5 | import java.nio.*; 6 | import java.lang.*; 7 | import java.util.*; 8 | import com.google.flatbuffers.*; 9 | 10 | public class AbilityT { 11 | private long id; 12 | private long distance; 13 | 14 | public long getId() { return id; } 15 | 16 | public void setId(long id) { this.id = id; } 17 | 18 | public long getDistance() { return distance; } 19 | 20 | public void setDistance(long distance) { this.distance = distance; } 21 | 22 | 23 | public AbilityT() { 24 | this.id = 0L; 25 | this.distance = 0L; 26 | } 27 | } 28 | 29 | -------------------------------------------------------------------------------- /tests/namespace_test/namespace_test2.ts: -------------------------------------------------------------------------------- 1 | export { EnumInNestedNS } from './namespace-a/namespace-b/enum-in-nested-n-s'; 2 | export { StructInNestedNS, StructInNestedNST } from './namespace-a/namespace-b/struct-in-nested-n-s'; 3 | export { TableInNestedNS, TableInNestedNST } from './namespace-a/namespace-b/table-in-nested-n-s'; 4 | export { UnionInNestedNS, unionToUnionInNestedNS, unionListToUnionInNestedNS } from './namespace-a/namespace-b/union-in-nested-n-s'; 5 | export { SecondTableInA, SecondTableInAT } from './namespace-a/second-table-in-a'; 6 | export { TableInFirstNS, TableInFirstNST } from './namespace-a/table-in-first-n-s'; 7 | export { TableInC, TableInCT } from './namespace-c/table-in-c'; 8 | -------------------------------------------------------------------------------- /kotlin/spotless/spotless.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright $YEAR Google Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | -------------------------------------------------------------------------------- /tests/union_vector/Character.java: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | 3 | @SuppressWarnings("unused") 4 | public final class Character { 5 | private Character() { } 6 | public static final byte NONE = 0; 7 | public static final byte MuLan = 1; 8 | public static final byte Rapunzel = 2; 9 | public static final byte Belle = 3; 10 | public static final byte BookFan = 4; 11 | public static final byte Other = 5; 12 | public static final byte Unused = 6; 13 | 14 | public static final String[] names = { "NONE", "MuLan", "Rapunzel", "Belle", "BookFan", "Other", "Unused", }; 15 | 16 | public static String name(int e) { return names[e]; } 17 | } 18 | 19 | -------------------------------------------------------------------------------- /tests/MyGame/Example/AnyUniqueAliases.php: -------------------------------------------------------------------------------- 1 | "NONE", 15 | AnyUniqueAliases::M=>"M", 16 | AnyUniqueAliases::TS=>"TS", 17 | AnyUniqueAliases::M2=>"M2", 18 | ); 19 | 20 | public static function Name($e) 21 | { 22 | if (!isset(self::$names[$e])) { 23 | throw new \Exception(); 24 | } 25 | return self::$names[$e]; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /tests/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ES6", 4 | "lib": ["ES2015", "ES2020.BigInt", "DOM"], 5 | "moduleResolution": "Node", 6 | "noImplicitAny": true, 7 | "strict": true, 8 | "noUnusedParameters": false, 9 | "noUnusedLocals": false, 10 | "noImplicitReturns": true, 11 | "strictNullChecks": true, 12 | "baseUrl": ".", 13 | "noEmit": false 14 | }, 15 | "include": [ 16 | "monster_test.ts", 17 | "typescript_keywords.ts", 18 | "typescript_keywords_generated.ts", 19 | "my-game/**/*.ts", 20 | "typescript/**/*.ts", 21 | "optional_scalars/**/*.ts", 22 | "namespace_test/**/*.ts", 23 | "union_vector/**/*.ts" 24 | ] 25 | } 26 | -------------------------------------------------------------------------------- /tests/native_type_test_impl.cpp: -------------------------------------------------------------------------------- 1 | #include "native_type_test_impl.h" 2 | 3 | #include "native_type_test_generated.h" 4 | 5 | namespace flatbuffers { 6 | Geometry::Vector3D Pack(const Native::Vector3D &obj) { 7 | return Geometry::Vector3D(obj.x, obj.y, obj.z); 8 | } 9 | 10 | const Native::Vector3D UnPack(const Geometry::Vector3D &obj) { 11 | return Native::Vector3D(obj.x(), obj.y(), obj.z()); 12 | } 13 | 14 | Geometry::Vector3DAlt PackVector3DAlt(const Native::Vector3D &obj) { 15 | return Geometry::Vector3DAlt(obj.x, obj.y, obj.z); 16 | } 17 | 18 | const Native::Vector3D UnPackVector3DAlt(const Geometry::Vector3DAlt &obj) { 19 | return Native::Vector3D(obj.a(), obj.b(), obj.c()); 20 | } 21 | } // namespace flatbuffers 22 | -------------------------------------------------------------------------------- /tests/MyGame/Example/AnyAmbiguousAliases.php: -------------------------------------------------------------------------------- 1 | "NONE", 15 | AnyAmbiguousAliases::M1=>"M1", 16 | AnyAmbiguousAliases::M2=>"M2", 17 | AnyAmbiguousAliases::M3=>"M3", 18 | ); 19 | 20 | public static function Name($e) 21 | { 22 | if (!isset(self::$names[$e])) { 23 | throw new \Exception(); 24 | } 25 | return self::$names[$e]; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /tests/MyGame/Example/Color.java: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | 3 | package MyGame.Example; 4 | 5 | /** 6 | * Composite components of Monster color. 7 | */ 8 | @SuppressWarnings("unused") 9 | public final class Color { 10 | private Color() { } 11 | public static final int Red = 1; 12 | /** 13 | * \brief color Green 14 | * Green is bit_flag with value (1u << 1) 15 | */ 16 | public static final int Green = 2; 17 | /** 18 | * \brief color Blue (1u << 3) 19 | */ 20 | public static final int Blue = 8; 21 | 22 | public static final String[] names = { "Red", "Green", "", "", "", "", "", "Blue", }; 23 | 24 | public static String name(int e) { return names[e - Red]; } 25 | } 26 | 27 | -------------------------------------------------------------------------------- /tests/fuzzer/monster_fuzzer.dict: -------------------------------------------------------------------------------- 1 | "{" 2 | "}" 3 | "[" 4 | "]" 5 | "\"" 6 | "'" 7 | "\\" 8 | "//" 9 | ":" 10 | "," 11 | " " 12 | "\\n" 13 | "\\r" 14 | "/*" 15 | "*/" 16 | "true" 17 | "false" 18 | "null" 19 | "\\u" 20 | "\\b" 21 | "\\f" 22 | "\\t" 23 | "." 24 | "e" 25 | "e+" 26 | "e-" 27 | "E" 28 | "E+" 29 | "E-" 30 | "0x" 31 | "p" 32 | "a" 33 | "b" 34 | "Monster" 35 | "pos" 36 | "hp" 37 | "name" 38 | "weapons" 39 | "damage" 40 | "equipped_type" 41 | "equipped" 42 | "inventory" 43 | "vector_of_longs" 44 | "vector_of_doubles" 45 | "test_type" 46 | "test" 47 | "test1" 48 | "test2" 49 | "test4" 50 | "test3" 51 | "test5" 52 | "enemy" 53 | "Weapon" 54 | "Green" 55 | "Red" 56 | "Blue" 57 | "testarrayofstring" 58 | "testarrayofbools" 59 | "testbool" 60 | "flex" 61 | -------------------------------------------------------------------------------- /benchmarks/cpp/flatbuffers/fb_bench.h: -------------------------------------------------------------------------------- 1 | #ifndef BENCHMARKS_CPP_FLATBUFFERS_FB_BENCH_H_ 2 | #define BENCHMARKS_CPP_FLATBUFFERS_FB_BENCH_H_ 3 | 4 | #include 5 | #include 6 | 7 | #include "benchmarks/cpp/bench.h" 8 | #include "include/flatbuffers/flatbuffers.h" 9 | 10 | struct StaticAllocator : public flatbuffers::Allocator { 11 | explicit StaticAllocator(uint8_t *buffer) : buffer_(buffer) {} 12 | 13 | uint8_t *allocate(size_t) override { return buffer_; } 14 | 15 | void deallocate(uint8_t *, size_t) override {} 16 | 17 | uint8_t *buffer_; 18 | }; 19 | 20 | std::unique_ptr NewFlatBuffersBench( 21 | int64_t initial_size = 1024, flatbuffers::Allocator *allocator = nullptr); 22 | 23 | #endif // BENCHMARKS_CPP_FLATBUFFERS_FB_BENCH_H_ -------------------------------------------------------------------------------- /tests/MyGame/Example/Race.go: -------------------------------------------------------------------------------- 1 | // Code generated by the FlatBuffers compiler. DO NOT EDIT. 2 | 3 | package Example 4 | 5 | import "strconv" 6 | 7 | type Race int8 8 | 9 | const ( 10 | RaceNone Race = -1 11 | RaceHuman Race = 0 12 | RaceDwarf Race = 1 13 | RaceElf Race = 2 14 | ) 15 | 16 | var EnumNamesRace = map[Race]string{ 17 | RaceNone: "None", 18 | RaceHuman: "Human", 19 | RaceDwarf: "Dwarf", 20 | RaceElf: "Elf", 21 | } 22 | 23 | var EnumValuesRace = map[string]Race{ 24 | "None": RaceNone, 25 | "Human": RaceHuman, 26 | "Dwarf": RaceDwarf, 27 | "Elf": RaceElf, 28 | } 29 | 30 | func (v Race) String() string { 31 | if s, ok := EnumNamesRace[v]; ok { 32 | return s 33 | } 34 | return "Race(" + strconv.FormatInt(int64(v), 10) + ")" 35 | } 36 | -------------------------------------------------------------------------------- /android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /tests/FlatBuffers.Test/NetTest.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | @REM Builds a .NET solution file, adds the project, builds it 3 | @REM and executes it. Cleans up all generated files and directories. 4 | 5 | set TEMP_BIN=.tmp 6 | 7 | @REM Run the .NET Core tests 8 | set CORE_FILE=FlatBuffers.Core.Test 9 | set CORE_PROJ_FILE=%CORE_FILE%.csproj 10 | set CORE_SLN_FILE=%CORE_FILE%.sln 11 | dotnet new sln --force --name %CORE_FILE% 12 | dotnet sln %CORE_SLN_FILE% add %CORE_PROJ_FILE% 13 | dotnet build -c Release -o %TEMP_BIN% -v quiet %CORE_PROJ_FILE% 14 | %TEMP_BIN%\%CORE_FILE%.exe 15 | del /f %CORE_SLN_FILE% 16 | 17 | @REM TODO(dbaileychess): Support the other configurations in NetTest.sh 18 | 19 | @REM remove the temp bin directory, with files (/S) and quietly (/Q) 20 | RD /S /Q %TEMP_BIN% 21 | -------------------------------------------------------------------------------- /tests/MyGame/Example/Color.kt: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | 3 | package MyGame.Example 4 | 5 | /** 6 | * Composite components of Monster color. 7 | */ 8 | @Suppress("unused") 9 | class Color private constructor() { 10 | companion object { 11 | const val Red: UByte = 1u 12 | /** 13 | * \brief color Green 14 | * Green is bit_flag with value (1u << 1) 15 | */ 16 | const val Green: UByte = 2u 17 | /** 18 | * \brief color Blue (1u << 3) 19 | */ 20 | const val Blue: UByte = 8u 21 | val names : Array = arrayOf("Red", "Green", "", "", "", "", "", "Blue") 22 | fun name(e: Int) : String = names[e - Red.toInt()] 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /tests/MyGame/Example/Any.php: -------------------------------------------------------------------------------- 1 | "NONE", 15 | Any::Monster=>"Monster", 16 | Any::TestSimpleTableWithEnum=>"TestSimpleTableWithEnum", 17 | Any::MyGame_Example2_Monster=>"MyGame_Example2_Monster", 18 | ); 19 | 20 | public static function Name($e) 21 | { 22 | if (!isset(self::$names[$e])) { 23 | throw new \Exception(); 24 | } 25 | return self::$names[$e]; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /tests/MyGame/Example/Color.php: -------------------------------------------------------------------------------- 1 | "Red", 18 | Color::Green=>"Green", 19 | Color::Blue=>"Blue", 20 | ); 21 | 22 | public static function Name($e) 23 | { 24 | if (!isset(self::$names[$e])) { 25 | throw new \Exception(); 26 | } 27 | return self::$names[$e]; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /docs/source/groups: -------------------------------------------------------------------------------- 1 | /// @defgroup flatbuffers_cpp_api C++ API 2 | /// @brief FlatBuffers API for C++ 3 | 4 | /// @defgroup flatbuffers_csharp_api C# API 5 | /// @brief FlatBuffers API for C# 6 | 7 | /// @defgroup flatbuffers_go_api Go API 8 | /// @brief FlatBuffers API for Go 9 | 10 | /// @defgroup flatbuffers_java_api Java API 11 | /// @brief FlatBuffers API for Java 12 | 13 | /// @defgroup flatbuffers_javascript_api JavaScript API 14 | /// @brief FlatBuffers API for JavaScript 15 | 16 | /// @defgroup flatbuffers_typescript_api TypeScript API 17 | /// @brief FlatBuffers API for TypeScript 18 | 19 | /// @defgroup flatbuffers_php_api PHP API 20 | /// @brief FlatBuffers API for PHP 21 | 22 | /// @defgroup flatbuffers_python_api Python API 23 | /// @brief FlatBuffers API for Python 24 | -------------------------------------------------------------------------------- /python/flatbuffers/_version.py: -------------------------------------------------------------------------------- 1 | # Copyright 2019 Google Inc. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # Placeholder, to be updated during the release process 16 | # by the setup.py 17 | __version__ = u"latest" 18 | -------------------------------------------------------------------------------- /ts/flexbuffers.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable @typescript-eslint/no-namespace */ 2 | import { Builder } from './flexbuffers/builder.js' 3 | import { toReference } from './flexbuffers/reference.js' 4 | export { toReference } from './flexbuffers/reference.js' 5 | 6 | export function builder(): Builder { 7 | return new Builder(); 8 | } 9 | 10 | export function toObject(buffer: ArrayBuffer): unknown { 11 | return toReference(buffer).toObject(); 12 | } 13 | 14 | export function encode(object: unknown, size = 2048, deduplicateStrings = true, deduplicateKeys = true, deduplicateKeyVectors = true): Uint8Array { 15 | const builder = new Builder(size > 0 ? size : 2048, deduplicateStrings, deduplicateKeys, deduplicateKeyVectors); 16 | builder.add(object); 17 | return builder.finish(); 18 | } 19 | -------------------------------------------------------------------------------- /rust/flatbuffers/README.md: -------------------------------------------------------------------------------- 1 | # Flatbuffers 2 | 3 | FlatBuffers is a cross platform serialization library architected for maximum 4 | memory efficiency. It allows you to directly access serialized data without 5 | parsing/unpacking it first, while still having great forwards/backwards 6 | compatibility. It was originally created at Google for game development and 7 | other performance-critical applications. 8 | 9 | ## See our 10 | * [Tutorial](https://google.github.io/flatbuffers/flatbuffers_guide_tutorial.html) 11 | * [Landing Page](https://google.github.io/flatbuffers/) 12 | * [Rust sample binary](https://github.com/google/flatbuffers/blob/master/samples/sample_binary.rs) 13 | * [Schema**less** format, Flexbuffers](https://crates.io/crates/flexbuffers) 14 | * [Github](https://github.com/google/flatbuffers) 15 | 16 | -------------------------------------------------------------------------------- /tests/MyGame/Example/LongEnum.go: -------------------------------------------------------------------------------- 1 | // Code generated by the FlatBuffers compiler. DO NOT EDIT. 2 | 3 | package Example 4 | 5 | import "strconv" 6 | 7 | type LongEnum uint64 8 | 9 | const ( 10 | LongEnumLongOne LongEnum = 2 11 | LongEnumLongTwo LongEnum = 4 12 | LongEnumLongBig LongEnum = 1099511627776 13 | ) 14 | 15 | var EnumNamesLongEnum = map[LongEnum]string{ 16 | LongEnumLongOne: "LongOne", 17 | LongEnumLongTwo: "LongTwo", 18 | LongEnumLongBig: "LongBig", 19 | } 20 | 21 | var EnumValuesLongEnum = map[string]LongEnum{ 22 | "LongOne": LongEnumLongOne, 23 | "LongTwo": LongEnumLongTwo, 24 | "LongBig": LongEnumLongBig, 25 | } 26 | 27 | func (v LongEnum) String() string { 28 | if s, ok := EnumNamesLongEnum[v]; ok { 29 | return s 30 | } 31 | return "LongEnum(" + strconv.FormatInt(int64(v), 10) + ")" 32 | } 33 | -------------------------------------------------------------------------------- /tests/MyGame/Example/StatT.java: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | 3 | package MyGame.Example; 4 | 5 | import java.nio.*; 6 | import java.lang.*; 7 | import java.util.*; 8 | import com.google.flatbuffers.*; 9 | 10 | public class StatT { 11 | private String id; 12 | private long val; 13 | private int count; 14 | 15 | public String getId() { return id; } 16 | 17 | public void setId(String id) { this.id = id; } 18 | 19 | public long getVal() { return val; } 20 | 21 | public void setVal(long val) { this.val = val; } 22 | 23 | public int getCount() { return count; } 24 | 25 | public void setCount(int count) { this.count = count; } 26 | 27 | 28 | public StatT() { 29 | this.id = null; 30 | this.val = 0L; 31 | this.count = 0; 32 | } 33 | } 34 | 35 | -------------------------------------------------------------------------------- /grpc/src/compiler/ts_generator.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "src/compiler/schema_interface.h" 6 | 7 | #ifndef GRPC_CUSTOM_STRING 8 | # include 9 | # define GRPC_CUSTOM_STRING std::string 10 | #endif 11 | 12 | namespace grpc { 13 | 14 | typedef GRPC_CUSTOM_STRING string; 15 | 16 | } // namespace grpc 17 | 18 | namespace grpc_ts_generator { 19 | grpc::string Generate(grpc_generator::File *file, 20 | const grpc_generator::Service *service, 21 | const grpc::string &filename); 22 | 23 | grpc::string GenerateInterface(grpc_generator::File *file, 24 | const grpc_generator::Service *service, 25 | const grpc::string &filename); 26 | } // namespace grpc_ts_generator 27 | -------------------------------------------------------------------------------- /tests/FlatBuffers.Test.Swift/Sources/SwiftFlatBuffers/fuzzer.fbs: -------------------------------------------------------------------------------- 1 | enum Color:ubyte (bit_flags) { 2 | Red = 0, // color Red = (1u << 0) 3 | /// \brief color Green 4 | /// Green is bit_flag with value (1u << 1) 5 | Green, 6 | /// \brief color Blue (1u << 3) 7 | Blue = 3, 8 | } 9 | 10 | struct Test { a:short; b:byte; } 11 | 12 | struct Vec3 (force_align: 8) { 13 | x:float; 14 | y:float; 15 | z:float; 16 | test1:double; 17 | test2:Color; 18 | test3:Test; 19 | } 20 | 21 | /// an example documentation comment: "monster object" 22 | table Monster { 23 | pos:Vec3 (id: 0); 24 | hp:short = 100 (id: 2); 25 | mana:short = 150 (id: 1); 26 | name:string (id: 3, key); 27 | color:Color = Blue (id: 6); 28 | inventory:[ubyte] (id: 5); 29 | testarrayoftables:[Monster] (id: 4); 30 | } 31 | 32 | root_type Monster; 33 | -------------------------------------------------------------------------------- /tests/MyGame/Example2/Monster.lua: -------------------------------------------------------------------------------- 1 | --[[ MyGame.Example2.Monster 2 | 3 | Automatically generated by the FlatBuffers compiler, do not modify. 4 | Or modify. I'm a message, not a cop. 5 | 6 | flatc version: 2.0.7 7 | 8 | Declared by : //monster_test.fbs 9 | Rooting type : MyGame.Example.Monster (//monster_test.fbs) 10 | 11 | --]] 12 | 13 | local flatbuffers = require('flatbuffers') 14 | 15 | local Monster = {} 16 | local mt = {} 17 | 18 | function Monster.New() 19 | local o = {} 20 | setmetatable(o, {__index = mt}) 21 | return o 22 | end 23 | 24 | function mt:Init(buf, pos) 25 | self.view = flatbuffers.view.New(buf, pos) 26 | end 27 | 28 | function Monster.Start(builder) 29 | builder:StartObject(0) 30 | end 31 | 32 | function Monster.End(builder) 33 | return builder:EndObject() 34 | end 35 | 36 | return Monster -------------------------------------------------------------------------------- /android/app/src/main/fbs/animal.fbs: -------------------------------------------------------------------------------- 1 | // Copyright 2015 Google Inc. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | namespace com.fbs.app; 16 | 17 | table Animal { 18 | name:string; 19 | sound:string; 20 | weight: uint16; 21 | } 22 | 23 | root_type Animal; 24 | -------------------------------------------------------------------------------- /tests/optional_scalars_defaults.json: -------------------------------------------------------------------------------- 1 | { 2 | just_i8: 4, 3 | maybe_i8: null, 4 | default_i8: 42, 5 | just_u8: 0, 6 | maybe_u8: 0, 7 | default_u8: 0, 8 | just_i16: 4, 9 | maybe_i16: null, 10 | default_i16: 42, 11 | just_u16: 0, 12 | maybe_u16: 0, 13 | default_u16: 0, 14 | just_i32: 4, 15 | maybe_i32: null, 16 | default_i32: 42, 17 | just_u32: 0, 18 | maybe_u32: 0, 19 | default_u32: 0, 20 | just_i64: 4, 21 | maybe_i64: null, 22 | default_i64: 42, 23 | just_u64: 0, 24 | maybe_u64: 0, 25 | default_u64: 0, 26 | just_f32: 4.0, 27 | maybe_f32: null, 28 | default_f32: 42.0, 29 | just_f64: 0.0, 30 | maybe_f64: 0.0, 31 | default_f64: 0.0, 32 | just_bool: true, 33 | maybe_bool: null, 34 | default_bool: false, 35 | just_enum: "None", 36 | maybe_enum: "One", 37 | default_enum: "Two" 38 | } 39 | -------------------------------------------------------------------------------- /python/flatbuffers/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright 2014 Google Inc. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from .builder import Builder 16 | from .table import Table 17 | from .compat import range_func as compat_range 18 | from ._version import __version__ 19 | from . import util 20 | -------------------------------------------------------------------------------- /tests/fuzzer/flexbuffers_verifier_fuzzer.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Chromium Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | #include 5 | #include 6 | #include 7 | 8 | #include "flatbuffers/flexbuffers.h" 9 | 10 | extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { 11 | std::vector reuse_tracker; 12 | // Check both with and without reuse tracker paths. 13 | flexbuffers::VerifyBuffer(data, size, &reuse_tracker); 14 | // FIXME: we can't really verify this path, because the fuzzer will 15 | // construct buffers that time out. 16 | // Add a simple #define to bound the number of steps just for the fuzzer? 17 | //flexbuffers::VerifyBuffer(data, size, nullptr); 18 | return 0; 19 | } 20 | -------------------------------------------------------------------------------- /grpc/build_grpc.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | grpc_1_39_0_githash=58602e20a3f3e48f24a4114c757099b25b947f7b 4 | 5 | function build_grpc () { 6 | git clone https://github.com/grpc/grpc.git google/grpc 7 | cd google/grpc 8 | git checkout ${grpc_1_39_0_githash} 9 | git submodule update --init 10 | # Apply boringssl build patch 11 | cd third_party/boringssl-with-bazel 12 | git apply ../../../../grpc/boringssl.patch 13 | cd ../.. 14 | mkdir ../grpc_build 15 | cd ../grpc_build 16 | cmake ../grpc -DgRPC_INSTALL=ON -DgRPC_BUILD_TESTS=OFF -DABSL_ENABLE_INSTALL=ON -DBUILD_SHARED_LIBS=ON -DCMAKE_INSTALL_PREFIX=`pwd`/../grpc/install 17 | cmake --build . --target install ${JOBS:+-j$JOBS} 18 | cd ../.. 19 | } 20 | 21 | GRPC_INSTALL_PATH=`pwd`/google/grpc/install 22 | PROTOBUF_DOWNLOAD_PATH=`pwd`/google/grpc/third_party/protobuf 23 | 24 | build_grpc 25 | -------------------------------------------------------------------------------- /tests/optional_scalars/OptionalByte.go: -------------------------------------------------------------------------------- 1 | // Code generated by the FlatBuffers compiler. DO NOT EDIT. 2 | 3 | package optional_scalars 4 | 5 | import "strconv" 6 | 7 | type OptionalByte int8 8 | 9 | const ( 10 | OptionalByteNone OptionalByte = 0 11 | OptionalByteOne OptionalByte = 1 12 | OptionalByteTwo OptionalByte = 2 13 | ) 14 | 15 | var EnumNamesOptionalByte = map[OptionalByte]string{ 16 | OptionalByteNone: "None", 17 | OptionalByteOne: "One", 18 | OptionalByteTwo: "Two", 19 | } 20 | 21 | var EnumValuesOptionalByte = map[string]OptionalByte{ 22 | "None": OptionalByteNone, 23 | "One": OptionalByteOne, 24 | "Two": OptionalByteTwo, 25 | } 26 | 27 | func (v OptionalByte) String() string { 28 | if s, ok := EnumNamesOptionalByte[v]; ok { 29 | return s 30 | } 31 | return "OptionalByte(" + strconv.FormatInt(int64(v), 10) + ")" 32 | } 33 | -------------------------------------------------------------------------------- /android/app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /php/Constants.php: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 16 | 17 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /tests/MyGame/Example/Color.go: -------------------------------------------------------------------------------- 1 | // Code generated by the FlatBuffers compiler. DO NOT EDIT. 2 | 3 | package Example 4 | 5 | import "strconv" 6 | 7 | /// Composite components of Monster color. 8 | type Color byte 9 | 10 | const ( 11 | ColorRed Color = 1 12 | /// \brief color Green 13 | /// Green is bit_flag with value (1u << 1) 14 | ColorGreen Color = 2 15 | /// \brief color Blue (1u << 3) 16 | ColorBlue Color = 8 17 | ) 18 | 19 | var EnumNamesColor = map[Color]string{ 20 | ColorRed: "Red", 21 | ColorGreen: "Green", 22 | ColorBlue: "Blue", 23 | } 24 | 25 | var EnumValuesColor = map[string]Color{ 26 | "Red": ColorRed, 27 | "Green": ColorGreen, 28 | "Blue": ColorBlue, 29 | } 30 | 31 | func (v Color) String() string { 32 | if s, ok := EnumNamesColor[v]; ok { 33 | return s 34 | } 35 | return "Color(" + strconv.FormatInt(int64(v), 10) + ")" 36 | } 37 | -------------------------------------------------------------------------------- /tests/namespace_test/NamespaceA/NamespaceB/EnumInNestedNS.go: -------------------------------------------------------------------------------- 1 | // Code generated by the FlatBuffers compiler. DO NOT EDIT. 2 | 3 | package NamespaceB 4 | 5 | import "strconv" 6 | 7 | type EnumInNestedNS int8 8 | 9 | const ( 10 | EnumInNestedNSA EnumInNestedNS = 0 11 | EnumInNestedNSB EnumInNestedNS = 1 12 | EnumInNestedNSC EnumInNestedNS = 2 13 | ) 14 | 15 | var EnumNamesEnumInNestedNS = map[EnumInNestedNS]string{ 16 | EnumInNestedNSA: "A", 17 | EnumInNestedNSB: "B", 18 | EnumInNestedNSC: "C", 19 | } 20 | 21 | var EnumValuesEnumInNestedNS = map[string]EnumInNestedNS{ 22 | "A": EnumInNestedNSA, 23 | "B": EnumInNestedNSB, 24 | "C": EnumInNestedNSC, 25 | } 26 | 27 | func (v EnumInNestedNS) String() string { 28 | if s, ok := EnumNamesEnumInNestedNS[v]; ok { 29 | return s 30 | } 31 | return "EnumInNestedNS(" + strconv.FormatInt(int64(v), 10) + ")" 32 | } 33 | -------------------------------------------------------------------------------- /tests/rust_usage_test/tests/flexbuffers_tests/mod.rs: -------------------------------------------------------------------------------- 1 | // Copyright 2020 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | mod binary_format; 16 | #[cfg(not(feature = "no_std"))] // uses file I/O 17 | mod interop; 18 | mod other_api; 19 | #[cfg(not(miri))] // slow. 20 | mod qc_serious; 21 | mod rwyw; 22 | -------------------------------------------------------------------------------- /tests/union_vector/FallingTub.kt: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | 3 | import java.nio.* 4 | import kotlin.math.sign 5 | import com.google.flatbuffers.* 6 | 7 | @Suppress("unused") 8 | class FallingTub : Struct() { 9 | 10 | fun __init(_i: Int, _bb: ByteBuffer) { 11 | __reset(_i, _bb) 12 | } 13 | fun __assign(_i: Int, _bb: ByteBuffer) : FallingTub { 14 | __init(_i, _bb) 15 | return this 16 | } 17 | val weight : Int get() = bb.getInt(bb_pos + 0) 18 | fun mutateWeight(weight: Int) : ByteBuffer = bb.putInt(bb_pos + 0, weight) 19 | companion object { 20 | fun createFallingTub(builder: FlatBufferBuilder, weight: Int) : Int { 21 | builder.prep(4, 4) 22 | builder.putInt(weight) 23 | return builder.offset() 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /tests/union_vector/Character.php: -------------------------------------------------------------------------------- 1 | "NONE", 16 | Character::MuLan=>"MuLan", 17 | Character::Rapunzel=>"Rapunzel", 18 | Character::Belle=>"Belle", 19 | Character::BookFan=>"BookFan", 20 | Character::Other=>"Other", 21 | Character::Unused=>"Unused", 22 | ); 23 | 24 | public static function Name($e) 25 | { 26 | if (!isset(self::$names[$e])) { 27 | throw new \Exception(); 28 | } 29 | return self::$names[$e]; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /tests/MyGame/InParentNamespace.lua: -------------------------------------------------------------------------------- 1 | --[[ MyGame.InParentNamespace 2 | 3 | Automatically generated by the FlatBuffers compiler, do not modify. 4 | Or modify. I'm a message, not a cop. 5 | 6 | flatc version: 2.0.7 7 | 8 | Declared by : //monster_test.fbs 9 | Rooting type : MyGame.Example.Monster (//monster_test.fbs) 10 | 11 | --]] 12 | 13 | local flatbuffers = require('flatbuffers') 14 | 15 | local InParentNamespace = {} 16 | local mt = {} 17 | 18 | function InParentNamespace.New() 19 | local o = {} 20 | setmetatable(o, {__index = mt}) 21 | return o 22 | end 23 | 24 | function mt:Init(buf, pos) 25 | self.view = flatbuffers.view.New(buf, pos) 26 | end 27 | 28 | function InParentNamespace.Start(builder) 29 | builder:StartObject(0) 30 | end 31 | 32 | function InParentNamespace.End(builder) 33 | return builder:EndObject() 34 | end 35 | 36 | return InParentNamespace -------------------------------------------------------------------------------- /tests/union_vector/BookReader.kt: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | 3 | import java.nio.* 4 | import kotlin.math.sign 5 | import com.google.flatbuffers.* 6 | 7 | @Suppress("unused") 8 | class BookReader : Struct() { 9 | 10 | fun __init(_i: Int, _bb: ByteBuffer) { 11 | __reset(_i, _bb) 12 | } 13 | fun __assign(_i: Int, _bb: ByteBuffer) : BookReader { 14 | __init(_i, _bb) 15 | return this 16 | } 17 | val booksRead : Int get() = bb.getInt(bb_pos + 0) 18 | fun mutateBooksRead(booksRead: Int) : ByteBuffer = bb.putInt(bb_pos + 0, booksRead) 19 | companion object { 20 | fun createBookReader(builder: FlatBufferBuilder, booksRead: Int) : Int { 21 | builder.prep(4, 4) 22 | builder.putInt(booksRead) 23 | return builder.offset() 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /tests/union_vector/Rapunzel.kt: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | 3 | import java.nio.* 4 | import kotlin.math.sign 5 | import com.google.flatbuffers.* 6 | 7 | @Suppress("unused") 8 | class Rapunzel : Struct() { 9 | 10 | fun __init(_i: Int, _bb: ByteBuffer) { 11 | __reset(_i, _bb) 12 | } 13 | fun __assign(_i: Int, _bb: ByteBuffer) : Rapunzel { 14 | __init(_i, _bb) 15 | return this 16 | } 17 | val hairLength : Int get() = bb.getInt(bb_pos + 0) 18 | fun mutateHairLength(hairLength: Int) : ByteBuffer = bb.putInt(bb_pos + 0, hairLength) 19 | companion object { 20 | fun createRapunzel(builder: FlatBufferBuilder, hairLength: Int) : Int { 21 | builder.prep(4, 4) 22 | builder.putInt(hairLength) 23 | return builder.offset() 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | Thank you for submitting a PR! 2 | 3 | Please delete this standard text once you've created your own description. 4 | 5 | If you make changes to any of the code generators (`src/idl_gen*`) be sure to 6 | build your project, as it will generate code based on the changes. If necessary 7 | the code generation script can be directly run (`scripts/generate_code.py`), 8 | requires Python3. This allows us to better see the effect of the PR. 9 | 10 | If your PR includes C++ code, please adhere to the 11 | [Google C++ Style Guide](https://google.github.io/styleguide/cppguide.html), 12 | and don't forget we try to support older compilers (e.g. VS2010, GCC 4.6.3), 13 | so only some C++11 support is available. 14 | 15 | For any C++ changes, please make sure to run `sh scripts/clang-format-git.sh` 16 | 17 | Include other details as appropriate. 18 | 19 | Thanks! 20 | -------------------------------------------------------------------------------- /tests/FlatBuffers.Benchmarks/FlatBuffers.Benchmarks.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.1 6 | latest 7 | true 8 | $(DefineConstants);UNSAFE_BYTEBUFFER;BYTEBUFFER_NO_BOUNDS_CHECK;ENABLE_SPAN_T 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /tests/namespace_test/NamespaceC/TableInCT.java: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | 3 | package NamespaceC; 4 | 5 | import java.nio.*; 6 | import java.lang.*; 7 | import java.util.*; 8 | import com.google.flatbuffers.*; 9 | 10 | public class TableInCT { 11 | private NamespaceA.TableInFirstNST referToA1; 12 | private NamespaceA.SecondTableInAT referToA2; 13 | 14 | public NamespaceA.TableInFirstNST getReferToA1() { return referToA1; } 15 | 16 | public void setReferToA1(NamespaceA.TableInFirstNST referToA1) { this.referToA1 = referToA1; } 17 | 18 | public NamespaceA.SecondTableInAT getReferToA2() { return referToA2; } 19 | 20 | public void setReferToA2(NamespaceA.SecondTableInAT referToA2) { this.referToA2 = referToA2; } 21 | 22 | 23 | public TableInCT() { 24 | this.referToA1 = null; 25 | this.referToA2 = null; 26 | } 27 | } 28 | 29 | -------------------------------------------------------------------------------- /.github/workflows/stale.yml: -------------------------------------------------------------------------------- 1 | name: Mark stale issues and pull requests 2 | permissions: read-all 3 | 4 | on: 5 | schedule: 6 | - cron: "30 20 * * *" 7 | 8 | jobs: 9 | stale: 10 | 11 | runs-on: ubuntu-latest 12 | 13 | steps: 14 | - uses: actions/stale@v4.0.0 15 | with: 16 | repo-token: ${{ secrets.GITHUB_TOKEN }} 17 | stale-pr-message: 'This pull request is stale because it has been open 6 months with no activity. Please comment or this will be closed in 14 days.' 18 | stale-issue-message: 'This issue is stale because it has been open 6 months with no activity. Please comment or this will be closed in 14 days.' 19 | days-before-stale: 182 # 6 months 20 | days-before-close: 14 21 | operations-per-run: 1500 22 | exempt-issue-labels: not-stale 23 | exempt-pr-labels: not-stale 24 | exempt-all-milestones: true 25 | -------------------------------------------------------------------------------- /tests/docker/TODO.Dockerfile.testing.php.hhvm_2019_01_16: -------------------------------------------------------------------------------- 1 | # This does not pass tests due to the following error: 2 | # 3 | # Fatal error: Uncaught exception 'InvalidArgumentException' with message 'Google\FlatBuffers\ByteBuffer::getX() expects parameter 1 by reference, but the call was not annotated with '&'. in /code/php/FlatbufferBuilder.php:971 4 | # Stack trace: 5 | # #0 /code/tests/phpTest.php(277): Google\FlatBuffers\FlatbufferBuilder->sizedByteArray() 6 | # #1 /code/tests/phpTest.php(79): fuzzTest1() 7 | # #2 /code/tests/phpTest.php(86): main() 8 | # #3 {main} 9 | # thrown in in /code/php/FlatbufferBuilder.php:971 10 | FROM hhvm/hhvm:2019.01.16 as base 11 | WORKDIR /code 12 | ADD . . 13 | RUN cp flatc_debian_stretch flatc 14 | WORKDIR /code/tests 15 | RUN hhvm --version 16 | RUN hhvm phpTest.php 17 | RUN ../flatc --php -o php union_vector/union_vector.fbs 18 | RUN hhvm phpUnionVectorTest.php 19 | -------------------------------------------------------------------------------- /tests/FlatBuffers.Test.Swift/Tests/LinuxMain.swift: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 Google Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import XCTest 18 | 19 | import FlatBuffers_Test_SwiftTests 20 | 21 | var tests = [XCTestCaseEntry]() 22 | tests += FlatBuffers_Test_SwiftTests.__allTests() 23 | 24 | XCTMain(tests) 25 | -------------------------------------------------------------------------------- /tests/union_vector/union_vector.fbs: -------------------------------------------------------------------------------- 1 | // Demonstrates the ability to have vectors of unions, and also to 2 | // store structs and strings in unions. 3 | 4 | table Attacker { 5 | sword_attack_damage: int; 6 | } 7 | 8 | struct Rapunzel { 9 | hair_length: int; 10 | } 11 | 12 | struct BookReader { 13 | books_read: int; 14 | } 15 | 16 | union Character { 17 | MuLan: Attacker, // Can have name be different from type. 18 | Rapunzel, // Or just both the same, as before. 19 | Belle: BookReader, 20 | BookFan: BookReader, 21 | Other: string, 22 | Unused: string 23 | } 24 | 25 | struct FallingTub { 26 | weight: int; 27 | } 28 | 29 | table HandFan { 30 | length: int; 31 | } 32 | 33 | union Gadget { 34 | FallingTub, 35 | HandFan, 36 | } 37 | 38 | table Movie { 39 | main_character: Character; 40 | characters: [Character]; 41 | } 42 | 43 | root_type Movie; 44 | file_identifier "MOVI"; 45 | -------------------------------------------------------------------------------- /tests/native_type_test_impl.h: -------------------------------------------------------------------------------- 1 | #ifndef NATIVE_TYPE_TEST_IMPL_H 2 | #define NATIVE_TYPE_TEST_IMPL_H 3 | 4 | namespace Native { 5 | struct Vector3D { 6 | float x; 7 | float y; 8 | float z; 9 | 10 | Vector3D() { 11 | x = 0; 12 | y = 0; 13 | z = 0; 14 | } 15 | Vector3D(float _x, float _y, float _z) { 16 | this->x = _x; 17 | this->y = _y; 18 | this->z = _z; 19 | } 20 | }; 21 | } // namespace Native 22 | 23 | namespace Geometry { 24 | struct Vector3D; 25 | struct Vector3DAlt; 26 | } // namespace Geometry 27 | 28 | namespace flatbuffers { 29 | Geometry::Vector3D Pack(const Native::Vector3D &obj); 30 | const Native::Vector3D UnPack(const Geometry::Vector3D &obj); 31 | Geometry::Vector3DAlt PackVector3DAlt(const Native::Vector3D &obj); 32 | const Native::Vector3D UnPackVector3DAlt(const Geometry::Vector3DAlt &obj); 33 | } // namespace flatbuffers 34 | 35 | #endif // VECTOR3D_PACK_H 36 | -------------------------------------------------------------------------------- /docs/source/gRPC/CppUsage.md: -------------------------------------------------------------------------------- 1 | Use in C++ {#flatbuffers_grpc_guide_use_cpp} 2 | ========== 3 | 4 | ## Before you get started 5 | 6 | Before diving into the FlatBuffers gRPC usage in C++, you should already be 7 | familiar with the following: 8 | 9 | - FlatBuffers as a serialization format 10 | - [gRPC](http://www.grpc.io/docs/) usage 11 | 12 | ## Using the FlatBuffers gRPC C++ library 13 | 14 | NOTE: The examples below are also in the `grpc/samples/greeter` directory. 15 | 16 | We will illustrate usage with the following schema: 17 | 18 | @include grpc/samples/greeter/greeter.fbs 19 | 20 | When we run `flatc`, we pass in the `--grpc` option and generage an additional 21 | `greeter.grpc.fb.h` and `greeter.grpc.fb.cc`. 22 | 23 | Example server code looks like this: 24 | 25 | @include grpc/samples/greeter/server.cpp 26 | 27 | Example client code looks like this: 28 | 29 | @include grpc/samples/greeter/client.cpp 30 | -------------------------------------------------------------------------------- /tests/rust_usage_test/outdir/src/main.rs: -------------------------------------------------------------------------------- 1 | // In this example, a build.rs file generates the code and then copies it into generated/ 2 | extern crate flatbuffers; 3 | #[allow(unused_imports, dead_code)] 4 | mod generated; 5 | use generated::my_game::sample::{Monster, MonsterArgs}; 6 | 7 | fn main() { 8 | let mut fbb = flatbuffers::FlatBufferBuilder::new(); 9 | let name = Some(fbb.create_string("bob")); 10 | let m = Monster::create( 11 | &mut fbb, 12 | &MonsterArgs { 13 | hp: 1, 14 | mana: 2, 15 | name, 16 | ..Default::default() 17 | }, 18 | ); 19 | fbb.finish(m, None); 20 | let mon = flatbuffers::root::(fbb.finished_data()).unwrap(); 21 | assert_eq!(mon.hp(), 1); 22 | assert_eq!(mon.mana(), 2); 23 | assert_eq!(mon.name().unwrap(), "bob"); 24 | } 25 | 26 | #[test] 27 | fn test_main() { 28 | main() 29 | } 30 | -------------------------------------------------------------------------------- /tests/FlatBuffers.Test/FlatBuffersTestMethodAttribute.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | using System; 18 | 19 | namespace FlatBuffers.Test 20 | { 21 | [AttributeUsage(AttributeTargets.Method)] 22 | public class FlatBuffersTestMethodAttribute : Attribute 23 | { 24 | } 25 | } -------------------------------------------------------------------------------- /swift/Sources/FlatBuffers/Documentation.docc/Resources/code/swift/swift_code_5.swift: -------------------------------------------------------------------------------- 1 | import FlatBuffers 2 | import Foundation 3 | 4 | func run() { 5 | // create a `FlatBufferBuilder`, which will be used to serialize objects 6 | let builder = FlatBufferBuilder(initialSize: 1024) 7 | 8 | let weapon1Name = builder.create(string: "Sword") 9 | let weapon2Name = builder.create(string: "Axe") 10 | 11 | // start creating the weapon by calling startWeapon 12 | let weapon1Start = Weapon.startWeapon(&builder) 13 | Weapon.add(name: weapon1Name, &builder) 14 | Weapon.add(damage: 3, &builder) 15 | // end the object by passing the start point for the weapon 1 16 | let sword = Weapon.endWeapon(&builder, start: weapon1Start) 17 | 18 | let weapon2Start = Weapon.startWeapon(&builder) 19 | Weapon.add(name: weapon2Name, &builder) 20 | Weapon.add(damage: 5, &builder) 21 | let axe = Weapon.endWeapon(&builder, start: weapon2Start) 22 | } 23 | -------------------------------------------------------------------------------- /tests/MyGame/OtherNameSpace/Unused.lua: -------------------------------------------------------------------------------- 1 | --[[ MyGame.OtherNameSpace.Unused 2 | 3 | Automatically generated by the FlatBuffers compiler, do not modify. 4 | Or modify. I'm a message, not a cop. 5 | 6 | flatc version: 2.0.7 7 | 8 | Declared by : //include_test/sub/include_test2.fbs 9 | Rooting type : MyGame.Example.Monster (//monster_test.fbs) 10 | 11 | --]] 12 | 13 | local flatbuffers = require('flatbuffers') 14 | 15 | local Unused = {} 16 | local mt = {} 17 | 18 | function Unused.New() 19 | local o = {} 20 | setmetatable(o, {__index = mt}) 21 | return o 22 | end 23 | 24 | function mt:Init(buf, pos) 25 | self.view = flatbuffers.view.New(buf, pos) 26 | end 27 | 28 | function mt:A() 29 | return self.view:Get(flatbuffers.N.Int32, self.view.pos + 0) 30 | end 31 | 32 | function Unused.CreateUnused(builder, a) 33 | builder:Prep(4, 4) 34 | builder:PrependInt32(a) 35 | return builder:Offset() 36 | end 37 | 38 | return Unused -------------------------------------------------------------------------------- /.github/workflows/main.yml: -------------------------------------------------------------------------------- 1 | name: OSS-Fuzz 2 | permissions: read-all 3 | 4 | on: 5 | pull_request: 6 | branches: 7 | - master 8 | paths: 9 | - include/** 10 | - src/** 11 | - tests/**.cpp 12 | - tests/**.h 13 | jobs: 14 | Fuzzing: 15 | runs-on: ubuntu-latest 16 | steps: 17 | - name: Build Fuzzers 18 | id: build 19 | uses: google/oss-fuzz/infra/cifuzz/actions/build_fuzzers@master 20 | with: 21 | oss-fuzz-project-name: 'flatbuffers' 22 | language: c++ 23 | - name: Run Fuzzers 24 | uses: google/oss-fuzz/infra/cifuzz/actions/run_fuzzers@master 25 | with: 26 | oss-fuzz-project-name: 'flatbuffers' 27 | language: c++ 28 | fuzz-seconds: 60 29 | - name: Upload Crash 30 | uses: actions/upload-artifact@v1 31 | if: failure() && steps.build.outcome == 'success' 32 | with: 33 | name: artifacts 34 | path: ./out/artifacts 35 | -------------------------------------------------------------------------------- /swift/Sources/FlatBuffers/Documentation.docc/Tutorials/Tutorial_Table_of_Contents.tutorial: -------------------------------------------------------------------------------- 1 | @Tutorials(name: "Starting with FlatBuffers") { 2 | @Intro(title: "Starting with FlatBuffers") { 3 | FlatBuffers is an efficient cross platform serialization library for C++, 4 | C#, C, Go, Java, Kotlin, JavaScript, Lobster, Lua, TypeScript, PHP, Python, Rust and Swift. 5 | It was originally created at Google for game development and other performance-critical applications. 6 | } 7 | @Chapter(name: "Generating your code") { 8 | Start by generating your first FlatBuffers objects. 9 | @Image(source: tutorial_cover_image_1.png, alt: "A code structure for a base struct in flatbuffers") 10 | @TutorialReference(tutorial: "doc:creating_flatbuffer_schema") 11 | @TutorialReference(tutorial: "doc:create_your_first_buffer") 12 | @TutorialReference(tutorial: "doc:reading_bytebuffer") 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /swift/Sources/FlatBuffers/Documentation.docc/Resources/code/swift/swift_code_13.swift: -------------------------------------------------------------------------------- 1 | import FlatBuffers 2 | import Foundation 3 | 4 | func run() { 5 | // create a ByteBuffer(:) from an [UInt8] or Data() 6 | let buf = [] // Get your data 7 | 8 | // Get an accessor to the root object inside the buffer. 9 | let monster: Monster = try! getCheckedRoot(byteBuffer: ByteBuffer(bytes: buf)) 10 | // let monster: Monster = getRoot(byteBuffer: ByteBuffer(bytes: buf)) 11 | 12 | let hp = monster.hp 13 | let mana = monster.mana 14 | let name = monster.name // returns an optional string 15 | 16 | let pos = monster.pos 17 | let x = pos.x 18 | let y = pos.y 19 | 20 | // Get and check if the monster has an equipped item 21 | if monster.equippedType == .weapon { 22 | let _weapon = monster.equipped(type: Weapon.self) 23 | let name = _weapon.name // should return "Axe" 24 | let dmg = _weapon.damage // should return 5 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /go/lib.go: -------------------------------------------------------------------------------- 1 | package flatbuffers 2 | 3 | // FlatBuffer is the interface that represents a flatbuffer. 4 | type FlatBuffer interface { 5 | Table() Table 6 | Init(buf []byte, i UOffsetT) 7 | } 8 | 9 | // GetRootAs is a generic helper to initialize a FlatBuffer with the provided buffer bytes and its data offset. 10 | func GetRootAs(buf []byte, offset UOffsetT, fb FlatBuffer) { 11 | n := GetUOffsetT(buf[offset:]) 12 | fb.Init(buf, n+offset) 13 | } 14 | 15 | // GetSizePrefixedRootAs is a generic helper to initialize a FlatBuffer with the provided size-prefixed buffer 16 | // bytes and its data offset 17 | func GetSizePrefixedRootAs(buf []byte, offset UOffsetT, fb FlatBuffer) { 18 | n := GetUOffsetT(buf[offset+sizePrefixLength:]) 19 | fb.Init(buf, n+offset+sizePrefixLength) 20 | } 21 | 22 | // GetSizePrefix reads the size from a size-prefixed flatbuffer 23 | func GetSizePrefix(buf []byte, offset UOffsetT) uint32 { 24 | return GetUint32(buf[offset:]) 25 | } 26 | -------------------------------------------------------------------------------- /grpc/examples/go/format.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Copyright 2021 Google Inc. All rights reserved. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | set -e 18 | 19 | 20 | format_greeter() { 21 | cd greeter 22 | 23 | # Format client 24 | cd client 25 | gofmt -w . 26 | cd .. 27 | 28 | # Format server 29 | cd server 30 | gofmt -w . 31 | cd .. 32 | 33 | cd .. 34 | } 35 | 36 | format_greeter -------------------------------------------------------------------------------- /tests/MyGame/Example/AnyAmbiguousAliases.py: -------------------------------------------------------------------------------- 1 | # automatically generated by the FlatBuffers compiler, do not modify 2 | 3 | # namespace: Example 4 | 5 | class AnyAmbiguousAliases(object): 6 | NONE = 0 7 | M1 = 1 8 | M2 = 2 9 | M3 = 3 10 | 11 | def AnyAmbiguousAliasesCreator(unionType, table): 12 | from flatbuffers.table import Table 13 | if not isinstance(table, Table): 14 | return None 15 | if unionType == AnyAmbiguousAliases().M1: 16 | import MyGame.Example.Monster 17 | return MyGame.Example.Monster.MonsterT.InitFromBuf(table.Bytes, table.Pos) 18 | if unionType == AnyAmbiguousAliases().M2: 19 | import MyGame.Example.Monster 20 | return MyGame.Example.Monster.MonsterT.InitFromBuf(table.Bytes, table.Pos) 21 | if unionType == AnyAmbiguousAliases().M3: 22 | import MyGame.Example.Monster 23 | return MyGame.Example.Monster.MonsterT.InitFromBuf(table.Bytes, table.Pos) 24 | return None 25 | -------------------------------------------------------------------------------- /tests/namespace_test/mod.rs: -------------------------------------------------------------------------------- 1 | // Automatically generated by the Flatbuffers compiler. Do not modify. 2 | // @generated 3 | pub mod namespace_a { 4 | use super::*; 5 | pub mod namespace_b { 6 | use super::*; 7 | mod union_in_nested_ns_generated; 8 | pub use self::union_in_nested_ns_generated::*; 9 | mod enum_in_nested_ns_generated; 10 | pub use self::enum_in_nested_ns_generated::*; 11 | mod table_in_nested_ns_generated; 12 | pub use self::table_in_nested_ns_generated::*; 13 | mod struct_in_nested_ns_generated; 14 | pub use self::struct_in_nested_ns_generated::*; 15 | } // namespace_b 16 | mod table_in_first_ns_generated; 17 | pub use self::table_in_first_ns_generated::*; 18 | mod second_table_in_a_generated; 19 | pub use self::second_table_in_a_generated::*; 20 | } // namespace_a 21 | pub mod namespace_c { 22 | use super::*; 23 | mod table_in_c_generated; 24 | pub use self::table_in_c_generated::*; 25 | } // namespace_c 26 | -------------------------------------------------------------------------------- /android/build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | buildscript { 3 | ext.kotlin_version = "1.4.10" 4 | repositories { 5 | google() 6 | jcenter() 7 | } 8 | dependencies { 9 | classpath 'com.android.tools.build:gradle:4.1.0' 10 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 11 | 12 | // NOTE: Do not place your application dependencies here; they belong 13 | // in the individual module build.gradle files 14 | } 15 | } 16 | 17 | allprojects { 18 | repositories { 19 | google() 20 | jcenter() 21 | } 22 | } 23 | 24 | tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all { 25 | sourceCompatibility = JavaVersion.VERSION_1_8 26 | targetCompatibility = JavaVersion.VERSION_1_8 27 | 28 | compileKotlin { 29 | dependsOn flatbuffer 30 | } 31 | } 32 | 33 | task clean(type: Delete) { 34 | delete rootProject.buildDir 35 | } 36 | -------------------------------------------------------------------------------- /tests/MyGame/Example/ArrayTableT.java: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | 3 | package MyGame.Example; 4 | 5 | import java.nio.*; 6 | import java.lang.*; 7 | import java.util.*; 8 | import com.google.flatbuffers.*; 9 | 10 | public class ArrayTableT { 11 | private MyGame.Example.ArrayStructT a; 12 | 13 | public MyGame.Example.ArrayStructT getA() { return a; } 14 | 15 | public void setA(MyGame.Example.ArrayStructT a) { this.a = a; } 16 | 17 | 18 | public ArrayTableT() { 19 | this.a = new MyGame.Example.ArrayStructT(); 20 | } 21 | public static ArrayTableT deserializeFromBinary(byte[] fbBuffer) { 22 | return ArrayTable.getRootAsArrayTable(ByteBuffer.wrap(fbBuffer)).unpack(); 23 | } 24 | public byte[] serializeToBinary() { 25 | FlatBufferBuilder fbb = new FlatBufferBuilder(); 26 | ArrayTable.finishArrayTableBuffer(fbb, ArrayTable.pack(fbb, this)); 27 | return fbb.sizedByteArray(); 28 | } 29 | } 30 | 31 | -------------------------------------------------------------------------------- /tests/LuaTest.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -eu 2 | # 3 | # Copyright 2019 Google Inc. All rights reserved. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | pushd "$(dirname $0)" >/dev/null 18 | test_dir="$(pwd)" 19 | 20 | declare -a versions=(luajit lua5.1 lua5.2 lua5.3 lua5.4) 21 | 22 | for i in "${versions[@]}" 23 | do 24 | if command -v $i &> /dev/null 25 | then 26 | echo "[$i]" 27 | $i luatest.lua 28 | fi 29 | done 30 | -------------------------------------------------------------------------------- /tests/RustTest.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | rem Copyright 2018 Google Inc. All rights reserved. 3 | rem 4 | rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | rem you may not use this file except in compliance with the License. 6 | rem You may obtain a copy of the License at 7 | rem 8 | rem http://www.apache.org/licenses/LICENSE-2.0 9 | rem 10 | rem Unless required by applicable law or agreed to in writing, software 11 | rem distributed under the License is distributed on an "AS IS" BASIS, 12 | rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | rem See the License for the specific language governing permissions and 14 | rem limitations under the License. 15 | 16 | rem Compile then run the Rust test. 17 | 18 | cd rust_usage_test 19 | cargo test -- --quiet || exit /b 1 20 | cargo run --bin=flatbuffers_alloc_check || exit /b 1 21 | cargo run --bin=flexbuffers_alloc_check || exit /b 1 22 | cargo run --bin=monster_example || exit /b 1 23 | cd .. 24 | -------------------------------------------------------------------------------- /swift/FlatBuffers.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | s.name = 'FlatBuffers' 3 | s.version = '2.0.0' 4 | s.summary = 'FlatBuffers: Memory Efficient Serialization Library' 5 | 6 | s.description = "FlatBuffers is a cross platform serialization library architected for 7 | maximum memory efficiency. It allows you to directly access serialized 8 | data without parsing/unpacking it first, while still having great 9 | forwards/backwards compatibility." 10 | 11 | s.homepage = 'https://github.com/google/flatbuffers' 12 | s.license = { :type => 'Apache2.0', :file => 'LICENSE' } 13 | s.author = { 'mustii' => 'mustii@mmk.one' } 14 | s.source = { :git => 'https://github.com/mustiikhalil/flatbuffers.git', :tag => s.version.to_s, :submodules => true } 15 | 16 | s.ios.deployment_target = '11.0' 17 | s.osx.deployment_target = '10.14' 18 | 19 | s.swift_version = '5.0' 20 | s.source_files = 'Sources/**/*' 21 | end 22 | -------------------------------------------------------------------------------- /tests/rust_usage_test/bin/monster_example.rs: -------------------------------------------------------------------------------- 1 | extern crate flatbuffers; 2 | 3 | #[allow(dead_code, unused_imports)] 4 | #[path = "../../include_test1/mod.rs"] 5 | pub mod include_test1_generated; 6 | 7 | #[allow(dead_code, unused_imports)] 8 | #[path = "../../include_test2/mod.rs"] 9 | pub mod include_test2_generated; 10 | 11 | #[allow(dead_code, unused_imports, clippy::approx_constant)] 12 | #[path = "../../monster_test/mod.rs"] 13 | mod monster_test_generated; 14 | pub use monster_test_generated::my_game; 15 | 16 | use std::io::Read; 17 | 18 | fn main() { 19 | let mut f = std::fs::File::open("../monsterdata_test.mon").unwrap(); 20 | let mut buf = Vec::new(); 21 | f.read_to_end(&mut buf).expect("file reading failed"); 22 | 23 | let monster = my_game::example::root_as_monster(&buf[..]).unwrap(); 24 | println!("{}", monster.hp()); // `80` 25 | println!("{}", monster.mana()); // default value of `150` 26 | println!("{:?}", monster.name()); // Some("MyMonster") 27 | } 28 | -------------------------------------------------------------------------------- /tests/MyGame/Example/AnyUniqueAliases.py: -------------------------------------------------------------------------------- 1 | # automatically generated by the FlatBuffers compiler, do not modify 2 | 3 | # namespace: Example 4 | 5 | class AnyUniqueAliases(object): 6 | NONE = 0 7 | M = 1 8 | TS = 2 9 | M2 = 3 10 | 11 | def AnyUniqueAliasesCreator(unionType, table): 12 | from flatbuffers.table import Table 13 | if not isinstance(table, Table): 14 | return None 15 | if unionType == AnyUniqueAliases().M: 16 | import MyGame.Example.Monster 17 | return MyGame.Example.Monster.MonsterT.InitFromBuf(table.Bytes, table.Pos) 18 | if unionType == AnyUniqueAliases().TS: 19 | import MyGame.Example.TestSimpleTableWithEnum 20 | return MyGame.Example.TestSimpleTableWithEnum.TestSimpleTableWithEnumT.InitFromBuf(table.Bytes, table.Pos) 21 | if unionType == AnyUniqueAliases().M2: 22 | import MyGame.Example2.Monster 23 | return MyGame.Example2.Monster.MonsterT.InitFromBuf(table.Bytes, table.Pos) 24 | return None 25 | -------------------------------------------------------------------------------- /tests/FlatBuffers.Test/README.md: -------------------------------------------------------------------------------- 1 | # .NET Tests 2 | 3 | ## Running on Linux 4 | 5 | ### Prerequisites 6 | To run the tests on a Linux a few prerequisites are needed: 7 | 8 | 1) mono 9 | 2) msbuild 10 | 11 | ### Running 12 | 13 | To run the tests: 14 | 15 | ``` 16 | ./NetTest.sh 17 | ``` 18 | 19 | This will download the .NET installer and core SDK if those are not already 20 | installed. Then it will build the tests using `msbuild` and run the resulting 21 | test binary with `mono`. 22 | 23 | After running the tests, the downloaded .NET installer and SDK are *not* removed 24 | as they can be reused in subsequent invocations. The files are ignored by git by 25 | default, and can remain in the working directory. 26 | 27 | ### Cleaning 28 | 29 | If you want to clean up the downloaded .NET installer and SDK, run: 30 | 31 | ``` 32 | ./clean.sh 33 | ``` 34 | 35 | This will wipe away the downloaded files and directories. Those will be 36 | automatically re-downloaded when running `NetTest.sh`. 37 | 38 | 39 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Flatbuffers Change Log 2 | 3 | All major or breaking changes will be documented in this file, as well as any 4 | new features that should be highlighted. Minor fixes or improvements are not 5 | necessarily listed. 6 | 7 | ## 2.0.7 (Aug 22 2022) 8 | 9 | * This is the first version with an explicit change log, so all the previous 10 | features will not be listed. 11 | 12 | * Verifier now checks that buffers are at least the minimum size required to be 13 | a flatbuffers (12 bytes). This includes nested flatbuffers, which previously 14 | could be declared valid at size 0. 15 | 16 | * Annotated binaries. Given a flatbuffer binary and a schema (or binary schema) 17 | one can generate an annotated flatbuffer (.afb) to describe each byte in the 18 | binary with schema metadata and value. 19 | 20 | * First binary schema generator (Lua) to generate Lua code via a .bfbs file. 21 | This is mostly an implementation detail of flatc internals, but will be slowly 22 | applied to the other language generators. -------------------------------------------------------------------------------- /net/FlatBuffers/IFlatbufferObject.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014 Google Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | namespace FlatBuffers 18 | { 19 | /// 20 | /// This is the base for both structs and tables. 21 | /// 22 | public interface IFlatbufferObject 23 | { 24 | void __init(int _i, ByteBuffer _bb); 25 | 26 | ByteBuffer ByteBuffer { get; } 27 | } 28 | } 29 | --------------------------------------------------------------------------------