...

Text file src/github.com/google/flatbuffers/dart/test/monster_test.fbs

Documentation: github.com/google/flatbuffers/dart/test

     1// 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.
    18enum 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
    27enum Race:byte {
    28  None = -1,
    29  Human = 0,
    30  Dwarf,
    31  Elf,
    32}
    33
    34enum LongEnum:ulong (bit_flags) {
    35  LongOne = 1,
    36  LongTwo = 2,
    37  // Because this is a bitflag, 40 will be out of range of a 32-bit integer,
    38  // allowing us to exercise any logic special to big numbers.
    39  LongBig = 40,
    40}
    41
    42union Any { Monster, TestSimpleTableWithEnum, MyGame.Example2.Monster }
    43
    44union AnyUniqueAliases { M: Monster, TS: TestSimpleTableWithEnum, M2: MyGame.Example2.Monster }
    45union AnyAmbiguousAliases { M1: Monster, M2: Monster, M3: Monster }
    46
    47struct Test { a:short; b:byte; }
    48
    49table TestSimpleTableWithEnum (csharp_partial, private) {
    50  color: Color = Green;
    51}
    52
    53struct Vec3 (force_align: 8) {
    54  x:float;
    55  y:float;
    56  z:float;
    57  test1:double;
    58  test2:Color;
    59  test3:Test;
    60}
    61
    62// Stats for monster
    63
    64struct Ability {
    65  id:uint(key);
    66  distance:uint;
    67}
    68
    69struct StructOfStructs {
    70  a: Ability;
    71  b: Test;
    72  c: Ability;
    73}
    74
    75struct StructOfStructsOfStructs {
    76 a: StructOfStructs;
    77}
    78
    79table Stat {
    80  id:string;
    81  val:long;
    82  count:ushort (key);
    83}
    84
    85table Referrable {
    86  id:ulong(key, hash:"fnv1a_64");
    87}
    88
    89/// an example documentation comment: "monster object"
    90table Monster {
    91  pos:Vec3 (id: 0);
    92  hp:short = 100 (id: 2);
    93  mana:short = 150 (id: 1);
    94  name:string (id: 3, key);
    95  color:Color = Blue (id: 6);
    96  inventory:[ubyte] (id: 5);
    97  friendly:bool = false (deprecated, priority: 1, id: 4);
    98  /// an example documentation comment: this will end up in the generated code
    99  /// multiline too
   100  testarrayoftables:[Monster] (id: 11);
   101  testarrayofstring:[string] (id: 10);
   102  testarrayofstring2:[string] (id: 28);
   103  testarrayofbools:[bool] (id: 24);
   104  testarrayofsortedstruct:[Ability] (id: 29);
   105  enemy:MyGame.Example.Monster (id:12);  // Test referring by full namespace.
   106  test:Any (id: 8);
   107  test4:[Test] (id: 9);
   108  test5:[Test] (id: 31);
   109  testnestedflatbuffer:[ubyte] (id:13, nested_flatbuffer: "Monster");
   110  testempty:Stat (id:14);
   111  testbool:bool (id:15);
   112  testhashs32_fnv1:int (id:16, hash:"fnv1_32");
   113  testhashu32_fnv1:uint (id:17, hash:"fnv1_32");
   114  testhashs64_fnv1:long (id:18, hash:"fnv1_64");
   115  testhashu64_fnv1:ulong (id:19, hash:"fnv1_64");
   116  testhashs32_fnv1a:int (id:20, hash:"fnv1a_32");
   117  testhashu32_fnv1a:uint (id:21, hash:"fnv1a_32", cpp_type:"Stat");
   118  testhashs64_fnv1a:long (id:22, hash:"fnv1a_64");
   119  testhashu64_fnv1a:ulong (id:23, hash:"fnv1a_64");
   120  testf:float = 3.14159 (id:25);
   121  testf2:float = 3 (id:26);
   122  testf3:float (id:27);
   123  flex:[ubyte] (id:30, flexbuffer);
   124  vector_of_longs:[long] (id:32);
   125  vector_of_doubles:[double] (id:33);
   126  parent_namespace_test:InParentNamespace (id:34);
   127  vector_of_referrables:[Referrable](id:35);
   128  single_weak_reference:ulong(id:36, hash:"fnv1a_64", cpp_type:"ReferrableT");
   129  vector_of_weak_references:[ulong](id:37, hash:"fnv1a_64", cpp_type:"ReferrableT");
   130  vector_of_strong_referrables:[Referrable](id:38, cpp_ptr_type:"default_ptr_type");                 //was shared_ptr
   131  co_owning_reference:ulong(id:39, hash:"fnv1a_64", cpp_type:"ReferrableT", cpp_ptr_type:"naked");  //was shared_ptr as well
   132  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
   133  non_owning_reference:ulong(id:41, hash:"fnv1a_64", cpp_type:"ReferrableT", cpp_ptr_type:"naked", cpp_ptr_type_get:"");                              //was weak_ptr
   134  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
   135  any_unique:AnyUniqueAliases(id:44);
   136  any_ambiguous:AnyAmbiguousAliases (id:46);
   137  vector_of_enums:[Color] (id:47);
   138  signed_enum:Race = None (id:48);
   139  testrequirednestedflatbuffer:[ubyte] (id:49, nested_flatbuffer: "Monster");
   140  scalar_key_sorted_tables:[Stat] (id: 50);
   141  native_inline:Test (id: 51, native_inline);
   142  // The default value of this enum will be a numeric zero, which isn't a valid
   143  // enum value.
   144  long_enum_non_enum_default:LongEnum (id: 52);
   145  long_enum_normal_default:LongEnum = LongOne (id: 53);
   146  // Test that default values nan and +/-inf work.
   147  nan_default:float = nan (id: 54);
   148  inf_default:float = inf (id: 55);
   149  positive_inf_default:float = +inf (id: 56);
   150  infinity_default:float = infinity (id: 57);
   151  positive_infinity_default:float = +infinity (id: 58);
   152  negative_inf_default:float = -inf (id: 59);
   153  negative_infinity_default:float = -infinity (id: 60);
   154  double_inf_default:double = inf (id: 61);
   155}
   156
   157table TypeAliases {
   158    i8:int8;
   159    u8:uint8;
   160    i16:int16;
   161    u16:uint16;
   162    i32:int32;
   163    u32:uint32;
   164    i64:int64;
   165    u64:uint64;
   166    f32:float32;
   167    f64:float64;
   168    v8:[int8];
   169    vf64:[float64];
   170}
   171
   172rpc_service MonsterStorage {
   173  Store(Monster):Stat (streaming: "none");
   174  Retrieve(Stat):Monster (streaming: "server", idempotent);
   175  GetMaxHitPoint(Monster):Stat (streaming: "client");
   176  GetMinMaxHitPoints(Monster):Stat (streaming: "bidi");
   177}
   178
   179root_type Monster;
   180
   181file_identifier "MONS";
   182file_extension "mon";

View as plain text