...
1# Flatbuffers Intermediate Representation {#intermediate_representation}
2
3We use [reflection.fbs](https://github.com/google/flatbuffers/blob/master/reflection/reflection.fbs)
4as our intermediate representation. `flatc` parses `.fbs` files, checks them for
5errors and stores the resulting data in this IR, outputting `.bfbs` files.
6Since this IR is a Flatbuffer, you can load and use it at runtime for runtime
7reflection purposes.
8
9There are some quirks:
10- Tables and Structs are serialized as `Object`s.
11- Unions and Enums are serialized as `Enum`s.
12- It is the responsibility of the code generator to check the `advanced_features`
13 field of `Schema`. These mark the presence of new, backwards incompatible,
14 schema features. Code generators must error if generating a schema with
15 unrecognized advanced features.
16- Filenames are relative to a "project root" denoted by "//" in the path. This
17 may be specified in flatc with `--bfbs-filenames=$PROJECT_ROOT`, or it will be
18 inferred to be the directory containing the first provided schema file.
19
20
21## Invocation
22You can invoke it like so
23```{.sh}
24flatc -b --schema ${your_fbs_files}
25```
26This generates `.bfbs` (binary flatbuffer schema) files.
27
28Some information is not included by default. See the `--bfbs-filenames` and
29`--bfbs-comments` flags. These may be necessary for code-generators, so they can
30add documentation and maybe name generated files (depending on the generator).
31
32
33TODO(cneo): Flags to output bfbs as flexbuffers or json.
34
35TODO(cneo): Tutorial for building a flatc plugin.
View as plain text