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