Home | History | Annotate | Download | only in tests
      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 enum Color:byte (bit_flags) { Red = 0, Green, Blue = 3, }
     18 
     19 union Any { Monster, TestSimpleTableWithEnum, MyGame.Example2.Monster }
     20 
     21 struct Test { a:short; b:byte; }
     22 
     23 table TestSimpleTableWithEnum (csharp_partial) {
     24   color: Color = Green;
     25 }
     26 
     27 struct Vec3 (force_align: 16) {
     28   x:float;
     29   y:float;
     30   z:float;
     31   test1:double;
     32   test2:Color;
     33   test3:Test;
     34 }
     35 
     36 struct Ability {
     37   id:uint(key);
     38   distance:uint;
     39 }
     40 
     41 table Stat {
     42   id:string;
     43   val:long;
     44   count:ushort;
     45 }
     46 
     47 /// an example documentation comment: monster object
     48 table Monster {
     49   pos:Vec3 (id: 0);
     50   hp:short = 100 (id: 2);
     51   mana:short = 150 (id: 1);
     52   name:string (id: 3, required, key);
     53   color:Color = Blue (id: 6);
     54   inventory:[ubyte] (id: 5);
     55   friendly:bool = false (deprecated, priority: 1, id: 4);
     56   /// an example documentation comment: this will end up in the generated code
     57   /// multiline too
     58   testarrayoftables:[Monster] (id: 11);
     59   testarrayofstring:[string] (id: 10);
     60   testarrayofstring2:[string] (id: 28);
     61   testarrayofbools:[bool] (id: 24);
     62   testarrayofsortedstruct:[Ability] (id: 29);
     63   enemy:MyGame.Example.Monster (id:12);  // Test referring by full namespace.
     64   test:Any (id: 8);
     65   test4:[Test] (id: 9);
     66   test5:[Test] (id: 31);
     67   testnestedflatbuffer:[ubyte] (id:13, nested_flatbuffer: "Monster");
     68   testempty:Stat (id:14);
     69   testbool:bool (id:15);
     70   testhashs32_fnv1:int (id:16, hash:"fnv1_32");
     71   testhashu32_fnv1:uint (id:17, hash:"fnv1_32");
     72   testhashs64_fnv1:long (id:18, hash:"fnv1_64");
     73   testhashu64_fnv1:ulong (id:19, hash:"fnv1_64");
     74   testhashs32_fnv1a:int (id:20, hash:"fnv1a_32");
     75   testhashu32_fnv1a:uint (id:21, hash:"fnv1a_32", cpp_type:"Stat");
     76   testhashs64_fnv1a:long (id:22, hash:"fnv1a_64");
     77   testhashu64_fnv1a:ulong (id:23, hash:"fnv1a_64");
     78   testf:float = 3.14159 (id:25);
     79   testf2:float = 3 (id:26);
     80   testf3:float (id:27);
     81   flex:[ubyte] (id:30, flexbuffer);
     82   vector_of_longs:[long] (id:32);
     83   vector_of_doubles:[double] (id:33);
     84   parent_namespace_test:InParentNamespace (id:34);
     85 }
     86 
     87 table TypeAliases {
     88     i8:int8;
     89     u8:uint8;
     90     i16:int16;
     91     u16:uint16;
     92     i32:int32;
     93     u32:uint32;
     94     i64:int64;
     95     u64:uint64;
     96     f32:float32;
     97     f64:float64;
     98     v8:[int8];
     99     vf64:[float64];
    100 }
    101 
    102 rpc_service MonsterStorage {
    103   Store(Monster):Stat (streaming: "none");
    104   Retrieve(Stat):Monster (streaming: "server", idempotent);
    105 }
    106 
    107 root_type Monster;
    108 
    109 file_identifier "MONS";
    110 file_extension "mon";
    111