Files
flatbuffers/tests/monster_test.fbs
Wouter van Oortmerssen 3639032d1e Allow unions of table types with the same name but from different namespaces.
Also fixed most codegenerators using the wrong namespace when multiple
namespace were used in a file, with some files not being generated.

Change-Id: Ib42969221239d7244e431cbd667ef69200fc415f
Tested: on Linux.
Bug: 29338474
2016-06-20 11:47:04 -07:00

81 lines
2.0 KiB
Plaintext
Executable File

// test schema file
include "include_test1.fbs";
namespace MyGame.Example2;
table Monster {} // Test having same name as below, but in different namespace.
namespace MyGame.Example;
attribute "priority";
enum Color:byte (bit_flags) { Red = 0, Green, Blue = 3, }
union Any { Monster, TestSimpleTableWithEnum, MyGame.Example2.Monster }
struct Test { a:short; b:byte; }
table TestSimpleTableWithEnum (csharp_partial) {
color: Color = Green;
}
struct Vec3 (force_align: 16) {
x:float;
y:float;
z:float;
test1:double;
test2:Color;
test3:Test;
}
table Stat {
id:string;
val:long;
count:ushort;
}
/// an example documentation comment: monster object
table Monster {
pos:Vec3 (id: 0);
hp:short = 100 (id: 2);
mana:short = 150 (id: 1);
name:string (id: 3, required, key);
color:Color = Blue (id: 6);
inventory:[ubyte] (id: 5);
friendly:bool = false (deprecated, priority: 1, id: 4);
/// an example documentation comment: this will end up in the generated code
/// multiline too
testarrayoftables:[Monster] (id: 11);
testarrayofstring:[string] (id: 10);
testarrayofstring2:[string] (id: 28);
testarrayofbools:[bool] (id: 24);
enemy:MyGame.Example.Monster (id:12); // Test referring by full namespace.
test:Any (id: 8);
test4:[Test] (id: 9);
testnestedflatbuffer:[ubyte] (id:13, nested_flatbuffer: "Monster");
testempty:Stat (id:14);
testbool:bool (id:15);
testhashs32_fnv1:int (id:16, hash:"fnv1_32");
testhashu32_fnv1:uint (id:17, hash:"fnv1_32");
testhashs64_fnv1:long (id:18, hash:"fnv1_64");
testhashu64_fnv1:ulong (id:19, hash:"fnv1_64");
testhashs32_fnv1a:int (id:20, hash:"fnv1a_32");
testhashu32_fnv1a:uint (id:21, hash:"fnv1a_32");
testhashs64_fnv1a:long (id:22, hash:"fnv1a_64");
testhashu64_fnv1a:ulong (id:23, hash:"fnv1a_64");
testf:float = 3.14159 (id:25);
testf2:float = 3 (id:26);
testf3:float (id:27);
}
rpc_service MonsterStorage {
Store(Monster):Stat (stream);
Retrieve(Stat):Monster (idempotent);
}
root_type Monster;
file_identifier "MONS";
file_extension "mon";