blob: d9e2dc4790bbb0aa0e46f67884498b7d33430bad [file] [log] [blame]
Austin Schuhe89fa2d2019-08-14 20:24:23 -07001// This schema defines objects that represent a parsed schema, like
2// the binary version of a .fbs file.
3// This could be used to operate on unknown FlatBuffers at runtime.
4// It can even ... represent itself (!)
5
6namespace reflection;
7
8// These must correspond to the enum in idl.h.
9enum BaseType : byte {
10 None,
11 UType,
12 Bool,
13 Byte,
14 UByte,
15 Short,
16 UShort,
17 Int,
18 UInt,
19 Long,
20 ULong,
21 Float,
22 Double,
23 String,
24 Vector,
25 Obj, // Used for tables & structs.
26 Union,
Austin Schuh272c6132020-11-14 16:37:52 -080027 Array,
28
29 // Add any new type above this value.
30 MaxBaseType
Austin Schuhe89fa2d2019-08-14 20:24:23 -070031}
32
33table Type {
34 base_type:BaseType;
Austin Schuh272c6132020-11-14 16:37:52 -080035 element:BaseType = None; // Only if base_type == Vector
Austin Schuhe89fa2d2019-08-14 20:24:23 -070036 // or base_type == Array.
37 index:int = -1; // If base_type == Object, index into "objects" below.
38 // If base_type == Union, UnionType, or integral derived
39 // from an enum, index into "enums" below.
40 fixed_length:uint16 = 0; // Only if base_type == Array.
41}
42
43table KeyValue {
44 key:string (required, key);
45 value:string;
46}
47
48table EnumVal {
49 name:string (required);
50 value:long (key);
51 object:Object; // Will be deprecated in favor of union_type in the future.
52 union_type:Type;
53 documentation:[string];
54}
55
56table Enum {
57 name:string (required, key);
58 values:[EnumVal] (required); // In order of their values.
59 is_union:bool = false;
60 underlying_type:Type (required);
61 attributes:[KeyValue];
62 documentation:[string];
63}
64
65table Field {
66 name:string (required, key);
67 type:Type (required);
68 id:ushort;
69 offset:ushort; // Offset into the vtable for tables, or into the struct.
70 default_integer:long = 0;
71 default_real:double = 0.0;
72 deprecated:bool = false;
73 required:bool = false;
74 key:bool = false;
75 attributes:[KeyValue];
76 documentation:[string];
Austin Schuh272c6132020-11-14 16:37:52 -080077 optional:bool = false;
Austin Schuhe89fa2d2019-08-14 20:24:23 -070078}
79
80table Object { // Used for both tables and structs.
81 name:string (required, key);
82 fields:[Field] (required); // Sorted.
83 is_struct:bool = false;
84 minalign:int;
85 bytesize:int; // For structs.
86 attributes:[KeyValue];
87 documentation:[string];
88}
89
90table RPCCall {
91 name:string (required, key);
92 request:Object (required); // must be a table (not a struct)
93 response:Object (required); // must be a table (not a struct)
94 attributes:[KeyValue];
95 documentation:[string];
96}
97
98table Service {
99 name:string (required, key);
100 calls:[RPCCall];
101 attributes:[KeyValue];
102 documentation:[string];
103}
104
105table Schema {
106 objects:[Object] (required); // Sorted.
107 enums:[Enum] (required); // Sorted.
108 file_ident:string;
109 file_ext:string;
110 root_table:Object;
111 services:[Service]; // Sorted.
112}
113
114root_type Schema;
115
116file_identifier "BFBS";
117file_extension "bfbs";