Added stream & idempotent annotations for RPCs.

Change-Id: Ia8651c1051808fdda0dc0ba52ec991777f868e88
Tested: on Linux.
parent 1a63eb46
...@@ -308,6 +308,7 @@ struct EnumDef : public Definition { ...@@ -308,6 +308,7 @@ struct EnumDef : public Definition {
struct RPCCall { struct RPCCall {
std::string name; std::string name;
SymbolTable<Value> attributes;
StructDef *request, *response; StructDef *request, *response;
}; };
...@@ -413,6 +414,8 @@ class Parser { ...@@ -413,6 +414,8 @@ class Parser {
known_attributes_.insert("original_order"); known_attributes_.insert("original_order");
known_attributes_.insert("nested_flatbuffer"); known_attributes_.insert("nested_flatbuffer");
known_attributes_.insert("csharp_partial"); known_attributes_.insert("csharp_partial");
known_attributes_.insert("stream");
known_attributes_.insert("idempotent");
} }
~Parser() { ~Parser() {
...@@ -474,7 +477,7 @@ private: ...@@ -474,7 +477,7 @@ private:
void SerializeStruct(const StructDef &struct_def, const Value &val); void SerializeStruct(const StructDef &struct_def, const Value &val);
void AddVector(bool sortbysize, int count); void AddVector(bool sortbysize, int count);
FLATBUFFERS_CHECKED_ERROR ParseVector(const Type &type, uoffset_t *ovalue); FLATBUFFERS_CHECKED_ERROR ParseVector(const Type &type, uoffset_t *ovalue);
FLATBUFFERS_CHECKED_ERROR ParseMetaData(Definition &def); FLATBUFFERS_CHECKED_ERROR ParseMetaData(SymbolTable<Value> *attributes);
FLATBUFFERS_CHECKED_ERROR TryTypedValue(int dtoken, bool check, Value &e, FLATBUFFERS_CHECKED_ERROR TryTypedValue(int dtoken, bool check, Value &e,
BaseType req, bool *destmatch); BaseType req, bool *destmatch);
FLATBUFFERS_CHECKED_ERROR ParseHash(Value &e, FieldDef* field); FLATBUFFERS_CHECKED_ERROR ParseHash(Value &e, FieldDef* field);
......
...@@ -556,7 +556,7 @@ CheckedError Parser::ParseField(StructDef &struct_def) { ...@@ -556,7 +556,7 @@ CheckedError Parser::ParseField(StructDef &struct_def) {
field->value.constant); field->value.constant);
field->doc_comment = dc; field->doc_comment = dc;
ECHECK(ParseMetaData(*field)); ECHECK(ParseMetaData(&field->attributes));
field->deprecated = field->attributes.Lookup("deprecated") != nullptr; field->deprecated = field->attributes.Lookup("deprecated") != nullptr;
auto hash_name = field->attributes.Lookup("hash"); auto hash_name = field->attributes.Lookup("hash");
if (hash_name) { if (hash_name) {
...@@ -846,7 +846,7 @@ CheckedError Parser::ParseVector(const Type &type, uoffset_t *ovalue) { ...@@ -846,7 +846,7 @@ CheckedError Parser::ParseVector(const Type &type, uoffset_t *ovalue) {
return NoError(); return NoError();
} }
CheckedError Parser::ParseMetaData(Definition &def) { CheckedError Parser::ParseMetaData(SymbolTable<Value> *attributes) {
if (Is('(')) { if (Is('(')) {
NEXT(); NEXT();
for (;;) { for (;;) {
...@@ -856,7 +856,7 @@ CheckedError Parser::ParseMetaData(Definition &def) { ...@@ -856,7 +856,7 @@ CheckedError Parser::ParseMetaData(Definition &def) {
return Error("user define attributes must be declared before use: " + return Error("user define attributes must be declared before use: " +
name); name);
auto e = new Value(); auto e = new Value();
def.attributes.Add(name, e); attributes->Add(name, e);
if (Is(':')) { if (Is(':')) {
NEXT(); NEXT();
ECHECK(ParseSingleValue(*e)); ECHECK(ParseSingleValue(*e));
...@@ -1089,7 +1089,7 @@ CheckedError Parser::ParseEnum(bool is_union, EnumDef **dest) { ...@@ -1089,7 +1089,7 @@ CheckedError Parser::ParseEnum(bool is_union, EnumDef **dest) {
// Make this type refer back to the enum it was derived from. // Make this type refer back to the enum it was derived from.
enum_def.underlying_type.enum_def = &enum_def; enum_def.underlying_type.enum_def = &enum_def;
} }
ECHECK(ParseMetaData(enum_def)); ECHECK(ParseMetaData(&enum_def.attributes));
EXPECT('{'); EXPECT('{');
if (is_union) enum_def.vals.Add("NONE", new EnumVal("NONE", 0)); if (is_union) enum_def.vals.Add("NONE", new EnumVal("NONE", 0));
for (;;) { for (;;) {
...@@ -1195,7 +1195,7 @@ CheckedError Parser::ParseDecl() { ...@@ -1195,7 +1195,7 @@ CheckedError Parser::ParseDecl() {
ECHECK(StartStruct(name, &struct_def)); ECHECK(StartStruct(name, &struct_def));
struct_def->doc_comment = dc; struct_def->doc_comment = dc;
struct_def->fixed = fixed; struct_def->fixed = fixed;
ECHECK(ParseMetaData(*struct_def)); ECHECK(ParseMetaData(&struct_def->attributes));
struct_def->sortbysize = struct_def->sortbysize =
struct_def->attributes.Lookup("original_order") == nullptr && !fixed; struct_def->attributes.Lookup("original_order") == nullptr && !fixed;
EXPECT('{'); EXPECT('{');
...@@ -1261,7 +1261,7 @@ CheckedError Parser::ParseService() { ...@@ -1261,7 +1261,7 @@ CheckedError Parser::ParseService() {
if (services_.Add(namespaces_.back()->GetFullyQualifiedName(service_name), if (services_.Add(namespaces_.back()->GetFullyQualifiedName(service_name),
&service_def)) &service_def))
return Error("service already exists: " + service_name); return Error("service already exists: " + service_name);
ECHECK(ParseMetaData(service_def)); ECHECK(ParseMetaData(&service_def.attributes));
EXPECT('{'); EXPECT('{');
do { do {
auto rpc_name = attribute_; auto rpc_name = attribute_;
...@@ -1281,6 +1281,7 @@ CheckedError Parser::ParseService() { ...@@ -1281,6 +1281,7 @@ CheckedError Parser::ParseService() {
rpc.response = resptype.struct_def; rpc.response = resptype.struct_def;
if (service_def.calls.Add(rpc_name, &rpc)) if (service_def.calls.Add(rpc_name, &rpc))
return Error("rpc already exists: " + rpc_name); return Error("rpc already exists: " + rpc_name);
ECHECK(ParseMetaData(&rpc.attributes));
EXPECT(';'); EXPECT(';');
} while (token_ != '}'); } while (token_ != '}');
NEXT(); NEXT();
......
...@@ -62,8 +62,8 @@ table Monster { ...@@ -62,8 +62,8 @@ table Monster {
} }
rpc_service MonsterStorage { rpc_service MonsterStorage {
Store(Monster):Stat; Store(Monster):Stat (stream);
Retrieve(Stat):Monster; Retrieve(Stat):Monster (idempotent);
} }
root_type Monster; root_type Monster;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment