// brintos_monster.fbs -- the schema the flatbuffers port is exercised against. // // It is deliberately the canonical "monster" shape from upstream's own tutorial // rather than something invented here: every FlatBuffers feature this port has // to get right on wasm32 appears in it exactly once, and a reader who knows // FlatBuffers already knows what the generated code is supposed to look like. // // Vec3 -- an inline STRUCT, stored in the parent's own memory, no offset // Color -- an ENUM over a byte, so the underlying type is not int // Weapon -- a TABLE reached through a vector of offsets // Monster -- the root, carrying a struct, scalars WITH DEFAULTS, a string, // a vector of ubyte, a vector of tables, and a vector of structs // // The defaults matter to the port more than they look: FlatBuffers does not // write a field whose value equals its default, so `mana` at 150 occupies no // bytes in the buffer and is reconstructed by the generated accessor from the // vtable's absence entry. That is a read path a round-trip of explicitly-set // fields never touches. namespace BrintosProbe; enum Color : byte { Red = 0, Green = 1, Blue = 2 } struct Vec3 { x:float; y:float; z:float; } table Weapon { name:string; damage:short; } table Monster { pos:Vec3; mana:short = 150; hp:short = 100; name:string; inventory:[ubyte]; color:Color = Blue; weapons:[Weapon]; path:[Vec3]; } root_type Monster; // Stamped into the buffer by FinishMonsterBuffer and checked by the verifier. // Without it flatc emits no BufferHasIdentifier, and the verifier has one // less thing it is able to disagree with. file_identifier "MONS";