Added stream & idempotent annotations for RPCs.

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