mirror of https://github.com/vee1e/flatbuffers - FlatBuffers: Memory Efficient Serialization Library
Find a file
Max Burke 355dfd48d1 [rust] Make enum names public (#5690)
* Bugfix for Rust generation of union fields named with language keywords

Looking at ParseField, it appears that in the case of unions, an extra field with a `UnionTypeFieldSuffix` is added to the type definition, however, if the name of this field is a keyword in the target language, it isn't escaped.

For example, if generating code for rust for a union field named `type`, flatc will generate a (non-keyword escaped) field named `type_type` for this hidden union field, and one (keyword escaped) called `type_` for the actual union contents.

When the union accessors are generated, they refer to this `type_type` field, but they will escape it mistakenly, generating code like this:

```
  #[inline]
  #[allow(non_snake_case)]
  pub fn type__as_int(&self) -> Option<Int<'a>> {
    if self.type__type() == Type::Int {
      self.type_().map(|u| Int::init_from_table(u))
    } else {
      None
    }
  }
```

Which will fail to build because the field is called `self.type_type()`, not `self.type__type()`.

* [Rust] Add crate-relative use statements for FBS includes.

At present if a flatbuffer description includes a reference to a type in
another file, the generated Rust code needs to be hand-modified to add
the appropriate `use` statements.

This assumes that the dependencies are built into the same crate, which
I think is a reasonable assumption?

* Revert "[Rust] Add crate-relative use statements for FBS includes."

This reverts commit d554d79fecf5afd6da6fb993b30b4cd523a5889a.

* Address comments raised in PR

* Update documentation comments per feedback

* Fix typo

* [rust] Make enum variant names public.

* Update generated test files

* Add test for public enum names
2019-12-31 10:28:58 -08:00
.appveyor
.bazelci
.github
.travis Add testing of C++ with sanitizers (CI-Docker) (#5631) 2019-11-18 12:16:41 -08:00
android Removed idl_gen_general.cpp and move contents to code_generators.cpp (#5625) 2019-11-14 15:47:58 -08:00
CMake
conan
dart [Dart] Fix prepare space for writeListInt64 and writeListUint64 (#5654) 2019-12-18 11:23:54 -08:00
docs Minor doc updates: FlexBuffers C#, Discord, CppUsage. 2019-12-26 12:36:41 -08:00
go
grpc Fix --incompatible_load_cc_rules_from_bzl (#5683) 2019-12-26 10:03:22 -08:00
include/flatbuffers [C++] Add Builder and Table typedefs (#5685) 2019-12-26 14:56:46 -08:00
java/com/google/flatbuffers Fixed warnings in FlexBuffers.java 2019-12-23 17:11:57 -08:00
js
lobster
lua Lua cleanup (#5624) 2019-11-14 15:46:46 -08:00
net/FlatBuffers Fixed struct initialization error on older versions of C# 2019-12-23 17:35:54 -08:00
php
python
reflection Add flatc '--cpp_std' switch (#5656) 2019-12-23 12:13:48 -08:00
rust/flatbuffers [Rust] Bump smallvec version to 1.0 (#5621) 2019-11-11 09:52:26 -08:00
samples [C++] Add Builder and Table typedefs (#5685) 2019-12-26 14:56:46 -08:00
snap
src [rust] Make enum names public (#5690) 2019-12-31 10:28:58 -08:00
tests [rust] Make enum names public (#5690) 2019-12-31 10:28:58 -08:00
.clang-format
.editorconfig
.gitattributes
.gitignore Add flatc '--cpp_std' switch (#5656) 2019-12-23 12:13:48 -08:00
.travis.yml
appveyor.yml Add flatc '--cpp_std' switch (#5656) 2019-12-23 12:13:48 -08:00
BUILD Split Bazel targets into multiple packages (#5640) 2019-12-02 14:14:48 -08:00
build_defs.bzl [Bazel] Add support for compatible_with and restricted_to (#5681) 2019-12-26 09:58:48 -08:00
CMakeLists.txt Add flatc '--cpp_std' switch (#5656) 2019-12-23 12:13:48 -08:00
composer.json
conanfile.py
CONTRIBUTING.md
LICENSE.txt
package.json
pom.xml
readme.md Minor doc updates: FlexBuffers C#, Discord, CppUsage. 2019-12-26 12:36:41 -08:00
WORKSPACE Upgrade rules_go (#5684) 2019-12-26 10:07:15 -08:00

logo FlatBuffers

Build Status Build status Join the chat at https://gitter.im/google/flatbuffers Discord Chat Twitter Follow

FlatBuffers is a cross platform serialization library architected for maximum memory efficiency. It allows you to directly access serialized data without parsing/unpacking it first, while still having great forwards/backwards compatibility.

Go to our landing page to browse our documentation.

Supported operating systems

  • Windows
  • MacOS X
  • Linux
  • Android
  • And any others with a recent C++ compiler.

Supported programming languages

  • C++
  • C#
  • C
  • Dart
  • Go
  • Java
  • JavaScript
  • Lobster
  • Lua
  • PHP
  • Python
  • Rust
  • TypeScript

and more in progress...

Contribution

To contribute to this project, see CONTRIBUTING.

Licensing

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