Files
flatbuffers/reflection/reflection.fbs
Derek Bailey 63b7b25289 FlatBuffers 64 for C++ (#7935)
* First working hack of adding 64-bit. Don't judge :)

* Made vector_downward work on 64 bit types

* vector_downward uses size_t, added offset64 to reflection

* cleaned up adding offset64 in parser

* Add C++ testing skeleton for 64-bit

* working test for CreateVector64

* working >2 GiB buffers

* support for large strings

* simplified CreateString<> to just provide the offset type

* generalize CreateVector template

* update test_64.afb due to upstream format change

* Added Vector64 type, which is just an alias for vector ATM

* Switch to Offset64 for Vector64

* Update for reflection bfbs output change

* Starting to add support for vector64 type in C++

* made a generic CreateVector that can handle different offsets and vector types

* Support for 32-vector with 64-addressing

* Vector64 basic builder + tests working

* basic support for json vector64 support

* renamed fields in test_64bit.fbs to better reflect their use

* working C++ vector64 builder

* Apply --annotate-sparse-vector to 64-bit tests

* Enable Vector64 for --annotate-sparse-vectors

* Merged from upstream

* Add `near_string` field for testing 32-bit offsets alongside

* keep track of where the 32-bit and 64-bit regions are for flatbufferbuilder

* move template<> outside class body for GCC

* update run.sh to build and run tests

* basic assertion for adding 64-bit offset at the wrong time

* started to separate `FlatBufferBuilder` into two classes, 1 64-bit aware, the other not

* add test for nested flatbuffer vector64, fix bug in alignment of big vectors

* fixed CreateDirect method by iterating by Offset64 first

* internal refactoring of flatbufferbuilder

* block not supported languages in the parser from using 64-bit

* evolution tests for adding a vector64 field

* conformity tests for adding/removing offset64 attributes

* ensure test is for a big buffer

* add parser error tests for `offset64` and `vector64` attributes

* add missing static that GCC only complains about

* remove stdint-uintn.h header that gets automatically added

* move 64-bit CalculateOffset internal

* fixed return size of EndVector

* various fixes on windows

* add SizeT to vector_downward

* minimze range of size changes in vector and builder

* reworked how tracking if 64-offsets are added

* Add ReturnT to EndVector

* small cleanups

* remove need for second Array definition

* combine IndirectHelpers into one definition

* started support for vector of struct

* Support for 32/64-vectors of structs + Offset64

* small cleanups

* add verification for vector64

* add sized prefix for 64-bit buffers

* add fuzzer for 64-bit

* add example of adding many vectors using a wrapper table

* run the new -bfbs-gen-embed logic on the 64-bit tests

* remove run.sh and fix cmakelist issue

* fixed bazel rules

* fixed some PR comments

* add 64-bit tests to cmakelist
2023-05-09 09:16:30 -07:00

157 lines
4.2 KiB
Plaintext

// This schema defines objects that represent a parsed schema, like
// the binary version of a .fbs file.
// This could be used to operate on unknown FlatBuffers at runtime.
// It can even ... represent itself (!)
namespace reflection;
// These must correspond to the enum in idl.h.
enum BaseType : byte {
None,
UType,
Bool,
Byte,
UByte,
Short,
UShort,
Int,
UInt,
Long,
ULong,
Float,
Double,
String,
Vector,
Obj, // Used for tables & structs.
Union,
Array,
Vector64,
// Add any new type above this value.
MaxBaseType
}
table Type {
base_type:BaseType;
element:BaseType = None; // Only if base_type == Vector
// or base_type == Array.
index:int = -1; // If base_type == Object, index into "objects" below.
// If base_type == Union, UnionType, or integral derived
// from an enum, index into "enums" below.
// If base_type == Vector && element == Union or UnionType.
fixed_length:uint16 = 0; // Only if base_type == Array.
/// The size (octets) of the `base_type` field.
base_size:uint = 4; // 4 Is a common size due to offsets being that size.
/// The size (octets) of the `element` field, if present.
element_size:uint = 0;
}
table KeyValue {
key:string (required, key);
value:string;
}
table EnumVal {
name:string (required);
value:long (key);
object:Object (deprecated);
union_type:Type;
documentation:[string];
attributes:[KeyValue];
}
table Enum {
name:string (required, key);
values:[EnumVal] (required); // In order of their values.
is_union:bool = false;
underlying_type:Type (required);
attributes:[KeyValue];
documentation:[string];
/// File that this Enum is declared in.
declaration_file: string;
}
table Field {
name:string (required, key);
type:Type (required);
id:ushort;
offset:ushort; // Offset into the vtable for tables, or into the struct.
default_integer:long = 0;
default_real:double = 0.0;
deprecated:bool = false;
required:bool = false;
key:bool = false;
attributes:[KeyValue];
documentation:[string];
optional:bool = false;
/// Number of padding octets to always add after this field. Structs only.
padding:uint16 = 0;
/// If the field uses 64-bit offsets.
offset64:bool = false;
}
table Object { // Used for both tables and structs.
name:string (required, key);
fields:[Field] (required); // Sorted.
is_struct:bool = false;
minalign:int;
bytesize:int; // For structs.
attributes:[KeyValue];
documentation:[string];
/// File that this Object is declared in.
declaration_file: string;
}
table RPCCall {
name:string (required, key);
request:Object (required); // must be a table (not a struct)
response:Object (required); // must be a table (not a struct)
attributes:[KeyValue];
documentation:[string];
}
table Service {
name:string (required, key);
calls:[RPCCall];
attributes:[KeyValue];
documentation:[string];
/// File that this Service is declared in.
declaration_file: string;
}
/// New schema language features that are not supported by old code generators.
enum AdvancedFeatures : ulong (bit_flags) {
AdvancedArrayFeatures,
AdvancedUnionFeatures,
OptionalScalars,
DefaultVectorsAndStrings,
}
/// File specific information.
/// Symbols declared within a file may be recovered by iterating over all
/// symbols and examining the `declaration_file` field.
table SchemaFile {
/// Filename, relative to project root.
filename:string (required, key);
/// Names of included files, relative to project root.
included_filenames:[string];
}
table Schema {
objects:[Object] (required); // Sorted.
enums:[Enum] (required); // Sorted.
file_ident:string;
file_ext:string;
root_table:Object;
services:[Service]; // Sorted.
advanced_features:AdvancedFeatures;
/// All the files used in this compilation. Files are relative to where
/// flatc was invoked.
fbs_files:[SchemaFile]; // Sorted.
}
root_type Schema;
file_identifier "BFBS";
file_extension "bfbs";