blob: 61d2f0c90691b38d2ac37d1e39cd4b25c1f89582 [file] [log] [blame]
// 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,
// Add any new type above this value.
MaxBaseType
}
table Type {
base_type:BaseType (id: 0);
element:BaseType = None (id: 1); // Only if base_type == Vector
// or base_type == Array.
index:int = -1 (id: 2); // If base_type == Object, index into "objects" below.
// If base_type == Union, UnionType, or integral derived
// from an enum, index into "enums" below.
fixed_length:uint16 = 0 (id: 3); // Only if base_type == Array.
}
table KeyValue {
key:string (required, key, id: 0);
value:string (id: 1);
}
table EnumVal {
name:string (required, id: 0);
value:long (key, id: 1);
object:Object (id: 2); // Will be deprecated in favor of union_type in the future.
union_type:Type (id: 3);
documentation:[string] (id: 4);
}
table Enum {
name:string (required, key, id: 0);
values:[EnumVal] (required, id: 1); // In order of their values.
is_union:bool = false (id: 2);
underlying_type:Type (required, id: 3);
attributes:[KeyValue] (id: 4);
documentation:[string] (id: 5);
}
table Field {
name:string (required, key, id: 0);
type:Type (required, id: 1);
id:ushort (id: 2);
offset:ushort (id: 3); // Offset into the vtable for tables, or into the struct.
default_integer:long = 0 (id: 4);
default_real:double = 0.0 (id: 5);
deprecated:bool = false (id: 6);
required:bool = false (id: 7);
key:bool = false (id: 8);
attributes:[KeyValue] (id: 9);
documentation:[string] (id: 10);
optional:bool = false (id: 11);
}
table Object { // Used for both tables and structs.
name:string (required, key, id: 0);
fields:[Field] (required, id: 1); // Sorted.
is_struct:bool = false (id: 2);
minalign:int (id: 3);
bytesize:int (id: 4); // For structs.
attributes:[KeyValue] (id: 5);
documentation:[string] (id: 6);
}
table RPCCall {
name:string (required, key, id: 0);
request:Object (required, id: 1); // must be a table (not a struct)
response:Object (required, id: 2); // must be a table (not a struct)
attributes:[KeyValue] (id: 3);
documentation:[string] (id: 4);
}
table Service {
name:string (required, key, id: 0);
calls:[RPCCall] (id: 1);
attributes:[KeyValue] (id: 2);
documentation:[string] (id: 3);
}
table Schema {
objects:[Object] (required, id: 0); // Sorted.
enums:[Enum] (required, id: 1); // Sorted.
file_ident:string (id: 2);
file_ext:string (id: 3);
root_table:Object (id: 4);
services:[Service] (id: 5); // Sorted.
}
root_type Schema;
file_identifier "BFBS";
file_extension "bfbs";