Java/C#/Python prefixed size support (#4445)

* initial changes to support size prefixed buffers in Java

* add slice equivalent to CSharp ByteBuffer

* resolve TODO for slicing in CSharp code generation

* add newly generated Java and CSharp test sources

* fix typo in comment

* add FinishSizePrefixed methods to CSharp FlatBufferBuilder as well

* add option to allow writing the prefix as well

* generate size-prefixed monster binary as well

* extend JavaTest to test the size prefixed binary as well

* use constants for size prefix length

* fuse common code for getRootAs and getSizePrefixedRootAs

* pulled file identifier out of if

* add FinishSizePrefixed, GetSizePrefixedRootAs support for Python

* Revert "extend JavaTest to test the size prefixed binary as well"

This reverts commit 68be4420dda47e8d0600bb19691f03be71503a68.

* Revert "generate size-prefixed monster binary as well"

This reverts commit 2939516fdf78df4f061c627221e232b312301417.

* fix ByteBuffer.cs Slice() method; add proper CSharp and Java tests

* fix unused parameter

* increment version number

* pulled out generated methods into separate utility class

* pulled out generated methods into separate utility class for Python

* fix indentation

* remove unnecessary comment

* fix newline and copyright

* add ByteBufferUtil to csproj compilation

* hide ByteBuffer's internal data; track offset into parent's array

* test unsafe versions as well; compile and run in debug mode

* clarify help text for size prefix

* move ByteBuffer slicing behavior to subclass

* fix protection levels

* add size prefix support for text generation

* add ByteBufferSlice to csproj compilation

* revert size prefix handling for nested buffers

* use duplicate instead of slice for removing size prefix

* remove slice subclass and use duplicate for removing size prefix

* remove slice specific tests

* remove superfluous command line option
24 files changed
tree: 26431684eab70b726f4e5ee6ca2bf2b67f53766f
  1. .github/
  2. .travis/
  3. android/
  4. biicode/
  5. CMake/
  6. docs/
  7. go/
  8. grpc/
  9. include/
  10. java/
  11. js/
  12. net/
  13. php/
  14. python/
  15. reflection/
  16. samples/
  17. src/
  18. tests/
  19. .clang-format
  20. .editorconfig
  21. .gitattributes
  22. .gitignore
  23. .travis.yml
  24. appveyor.yml
  25. biicode.conf
  26. BUILD
  27. CMakeLists.txt
  28. composer.json
  29. conanfile.py
  30. CONTRIBUTING.md
  31. LICENSE.txt
  32. package.json
  33. pom.xml
  34. readme.md
  35. WORKSPACE
readme.md

logo FlatBuffers

Join the chat at https://gitter.im/google/flatbuffers Build Status Build status

FlatBuffers is an efficient cross platform serialization library for games and other memory constrained apps. It allows you to directly access serialized data without unpacking/parsing it first, while still having great forwards/backwards compatibility.

Go to our landing page to browse our documentation.

Supported operating systems

  • Android
  • Windows
  • MacOS X
  • Linux

Supported programming languages

  • C++
  • C#
  • C
  • Go
  • Java
  • JavaScript
  • PHP
  • Python

and many more in progress...

Contribution

To contribute to this project, see CONTRIBUTING.

Integration

For applications on Google Play that integrate this tool, usage is tracked. This tracking is done automatically using the embedded version string (flatbuffer_version_string), and helps us continue to optimize it. Aside from consuming a few extra bytes in your application binary, it shouldn't affect your application at all. We use this information to let us know if FlatBuffers is useful and if we should continue to invest in it. Since this is open source, you are free to remove the version string but we would appreciate if you would leave it in.

Licensing

Flatbuffers is licensed under the Apache License, Version 2.0. See LICENSE for the full license text.