mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-08 06:05:17 +00:00
Added user defined attribute declarations.
This is such that if you mis-spell an attribute, it doesn't get silently ignored. Bug: 18294628 Change-Id: I10013f5b2a21048b7daba2e9410678f528e09761 Tested: on Linux.
This commit is contained in:
@@ -1,12 +1,15 @@
|
||||
# Formal Grammar of the schema language
|
||||
|
||||
schema = include*
|
||||
( namespace\_decl | type\_decl | enum\_decl | root\_decl | object )*
|
||||
( namespace\_decl | type\_decl | enum\_decl | root\_decl |
|
||||
attribute\_decl | object )*
|
||||
|
||||
include = `include` string\_constant `;`
|
||||
|
||||
namespace\_decl = `namespace` ident ( `.` ident )* `;`
|
||||
|
||||
attribute\_decl = `attribute` string\_constant `;`
|
||||
|
||||
type\_decl = ( `table` | `struct` ) ident metadata `{` field\_decl+ `}`
|
||||
|
||||
enum\_decl = ( `enum` | `union` ) ident [ `:` type ] metadata `{` commasep(
|
||||
|
||||
@@ -9,6 +9,8 @@ first:
|
||||
|
||||
namespace MyGame;
|
||||
|
||||
attribute "priority";
|
||||
|
||||
enum Color : byte { Red = 1, Green, Blue }
|
||||
|
||||
union Any { Monster, Weapon, Pickup }
|
||||
@@ -211,7 +213,8 @@ in the corresponding C++ code. Multiple such lines per item are allowed.
|
||||
Attributes may be attached to a declaration, behind a field, or after
|
||||
the name of a table/struct/enum/union. These may either have a value or
|
||||
not. Some attributes like `deprecated` are understood by the compiler,
|
||||
others are simply ignored (like `priority` in the example above), but are
|
||||
user defined ones need to be declared with the attribute declaration
|
||||
(like `priority` in the example above), and are
|
||||
available to query if you parse the schema at runtime.
|
||||
This is useful if you write your own code generators/editors etc., and
|
||||
you wish to add additional information specific to your tool (such as a
|
||||
|
||||
Reference in New Issue
Block a user