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