Austin Schuh | e89fa2d | 2019-08-14 20:24:23 -0700 | [diff] [blame^] | 1 | // test schema file |
| 2 | |
| 3 | include "include_test1.fbs"; |
| 4 | |
| 5 | namespace MyGame; |
| 6 | |
| 7 | table InParentNamespace {} |
| 8 | |
| 9 | namespace MyGame.Example2; |
| 10 | |
| 11 | table Monster {} // Test having same name as below, but in different namespace. |
| 12 | |
| 13 | namespace MyGame.Example; |
| 14 | |
| 15 | attribute "priority"; |
| 16 | |
| 17 | /// Composite components of Monster color. |
| 18 | enum Color:ubyte (bit_flags) { |
| 19 | Red = 0, // color Red = (1u << 0) |
| 20 | /// \brief color Green |
| 21 | /// Green is bit_flag with value (1u << 1) |
| 22 | Green, |
| 23 | /// \brief color Blue (1u << 3) |
| 24 | Blue = 3, |
| 25 | } |
| 26 | |
| 27 | union Any { Monster, TestSimpleTableWithEnum, MyGame.Example2.Monster } |
| 28 | |
| 29 | union AnyUniqueAliases { M: Monster, TS: TestSimpleTableWithEnum, M2: MyGame.Example2.Monster } |
| 30 | union AnyAmbiguousAliases { M1: Monster, M2: Monster, M3: Monster } |
| 31 | |
| 32 | struct Test { a:short; b:byte; } |
| 33 | |
| 34 | table TestSimpleTableWithEnum (csharp_partial, private) { |
| 35 | color: Color = Green; |
| 36 | } |
| 37 | |
| 38 | struct Vec3 (force_align: 8) { |
| 39 | x:float; |
| 40 | y:float; |
| 41 | z:float; |
| 42 | test1:double; |
| 43 | test2:Color; |
| 44 | test3:Test; |
| 45 | } |
| 46 | |
| 47 | struct Ability { |
| 48 | id:uint(key); |
| 49 | distance:uint; |
| 50 | } |
| 51 | |
| 52 | table Stat { |
| 53 | id:string; |
| 54 | val:long; |
| 55 | count:ushort; |
| 56 | } |
| 57 | |
| 58 | table Referrable { |
| 59 | id:ulong(key, hash:"fnv1a_64"); |
| 60 | } |
| 61 | |
| 62 | /// an example documentation comment: monster object |
| 63 | table Monster { |
| 64 | pos:Vec3 (id: 0); |
| 65 | hp:short = 100 (id: 2); |
| 66 | mana:short = 150 (id: 1); |
| 67 | name:string (id: 3, required, key); |
| 68 | color:Color = Blue (id: 6); |
| 69 | inventory:[ubyte] (id: 5); |
| 70 | friendly:bool = false (deprecated, priority: 1, id: 4); |
| 71 | /// an example documentation comment: this will end up in the generated code |
| 72 | /// multiline too |
| 73 | testarrayoftables:[Monster] (id: 11); |
| 74 | testarrayofstring:[string] (id: 10); |
| 75 | testarrayofstring2:[string] (id: 28); |
| 76 | testarrayofbools:[bool] (id: 24); |
| 77 | testarrayofsortedstruct:[Ability] (id: 29); |
| 78 | enemy:MyGame.Example.Monster (id:12); // Test referring by full namespace. |
| 79 | test:Any (id: 8); |
| 80 | test4:[Test] (id: 9); |
| 81 | test5:[Test] (id: 31); |
| 82 | testnestedflatbuffer:[ubyte] (id:13, nested_flatbuffer: "Monster"); |
| 83 | testempty:Stat (id:14); |
| 84 | testbool:bool (id:15); |
| 85 | testhashs32_fnv1:int (id:16, hash:"fnv1_32"); |
| 86 | testhashu32_fnv1:uint (id:17, hash:"fnv1_32"); |
| 87 | testhashs64_fnv1:long (id:18, hash:"fnv1_64"); |
| 88 | testhashu64_fnv1:ulong (id:19, hash:"fnv1_64"); |
| 89 | testhashs32_fnv1a:int (id:20, hash:"fnv1a_32"); |
| 90 | testhashu32_fnv1a:uint (id:21, hash:"fnv1a_32", cpp_type:"Stat"); |
| 91 | testhashs64_fnv1a:long (id:22, hash:"fnv1a_64"); |
| 92 | testhashu64_fnv1a:ulong (id:23, hash:"fnv1a_64"); |
| 93 | testf:float = 3.14159 (id:25); |
| 94 | testf2:float = 3 (id:26); |
| 95 | testf3:float (id:27); |
| 96 | flex:[ubyte] (id:30, flexbuffer); |
| 97 | vector_of_longs:[long] (id:32); |
| 98 | vector_of_doubles:[double] (id:33); |
| 99 | parent_namespace_test:InParentNamespace (id:34); |
| 100 | vector_of_referrables:[Referrable](id:35); |
| 101 | single_weak_reference:ulong(id:36, hash:"fnv1a_64", cpp_type:"ReferrableT"); |
| 102 | vector_of_weak_references:[ulong](id:37, hash:"fnv1a_64", cpp_type:"ReferrableT"); |
| 103 | vector_of_strong_referrables:[Referrable](id:38, cpp_ptr_type:"default_ptr_type"); //was shared_ptr |
| 104 | co_owning_reference:ulong(id:39, hash:"fnv1a_64", cpp_type:"ReferrableT", cpp_ptr_type:"naked"); //was shared_ptr as well |
| 105 | vector_of_co_owning_references:[ulong](id:40, hash:"fnv1a_64", cpp_type:"ReferrableT", cpp_ptr_type:"default_ptr_type", cpp_ptr_type_get:".get()"); //was shared_ptr |
| 106 | non_owning_reference:ulong(id:41, hash:"fnv1a_64", cpp_type:"ReferrableT", cpp_ptr_type:"naked", cpp_ptr_type_get:""); //was weak_ptr |
| 107 | vector_of_non_owning_references:[ulong](id:42, hash:"fnv1a_64", cpp_type:"ReferrableT", cpp_ptr_type:"naked", cpp_ptr_type_get:""); //was weak_ptr |
| 108 | any_unique:AnyUniqueAliases(id:44); |
| 109 | any_ambiguous:AnyAmbiguousAliases (id:46); |
| 110 | vector_of_enums:[Color] (id:47); |
| 111 | } |
| 112 | |
| 113 | table TypeAliases { |
| 114 | i8:int8; |
| 115 | u8:uint8; |
| 116 | i16:int16; |
| 117 | u16:uint16; |
| 118 | i32:int32; |
| 119 | u32:uint32; |
| 120 | i64:int64; |
| 121 | u64:uint64; |
| 122 | f32:float32; |
| 123 | f64:float64; |
| 124 | v8:[int8]; |
| 125 | vf64:[float64]; |
| 126 | } |
| 127 | |
| 128 | rpc_service MonsterStorage { |
| 129 | Store(Monster):Stat (streaming: "none"); |
| 130 | Retrieve(Stat):Monster (streaming: "server", idempotent); |
| 131 | GetMaxHitPoint(Monster):Stat (streaming: "client"); |
| 132 | GetMinMaxHitPoints(Monster):Stat (streaming: "bidi"); |
| 133 | } |
| 134 | |
| 135 | root_type Monster; |
| 136 | |
| 137 | file_identifier "MONS"; |
| 138 | file_extension "mon"; |