1// 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, 27 Array 28} 29 30table Type { 31 base_type:BaseType; 32 element:BaseType = None; // Only if base_type == Vector 33 // or base_type == Array. 34 index:int = -1; // If base_type == Object, index into "objects" below. 35 // If base_type == Union, UnionType, or integral derived 36 // from an enum, index into "enums" below. 37 fixed_length:uint16 = 0; // Only if base_type == Array. 38} 39 40table KeyValue { 41 key:string (required, key); 42 value:string; 43} 44 45table EnumVal { 46 name:string (required); 47 value:long (key); 48 object:Object; // Will be deprecated in favor of union_type in the future. 49 union_type:Type; 50 documentation:[string]; 51} 52 53table Enum { 54 name:string (required, key); 55 values:[EnumVal] (required); // In order of their values. 56 is_union:bool = false; 57 underlying_type:Type (required); 58 attributes:[KeyValue]; 59 documentation:[string]; 60} 61 62table Field { 63 name:string (required, key); 64 type:Type (required); 65 id:ushort; 66 offset:ushort; // Offset into the vtable for tables, or into the struct. 67 default_integer:long = 0; 68 default_real:double = 0.0; 69 deprecated:bool = false; 70 required:bool = false; 71 key:bool = false; 72 attributes:[KeyValue]; 73 documentation:[string]; 74} 75 76table Object { // Used for both tables and structs. 77 name:string (required, key); 78 fields:[Field] (required); // Sorted. 79 is_struct:bool = false; 80 minalign:int; 81 bytesize:int; // For structs. 82 attributes:[KeyValue]; 83 documentation:[string]; 84} 85 86table RPCCall { 87 name:string (required, key); 88 request:Object (required); // must be a table (not a struct) 89 response:Object (required); // must be a table (not a struct) 90 attributes:[KeyValue]; 91 documentation:[string]; 92} 93 94table Service { 95 name:string (required, key); 96 calls:[RPCCall]; 97 attributes:[KeyValue]; 98 documentation:[string]; 99} 100 101table Schema { 102 objects:[Object] (required); // Sorted. 103 enums:[Enum] (required); // Sorted. 104 file_ident:string; 105 file_ext:string; 106 root_table:Object; 107 services:[Service]; // Sorted. 108} 109 110root_type Schema; 111 112file_identifier "BFBS"; 113file_extension "bfbs"; 114