MCPcopy Create free account
hub / github.com/bytedance/Fastbot_Android / ParseService

Method ParseService

native/thirdpart/flatbuffers/idl_parser.cpp:2602–2642  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2600}
2601
2602CheckedError Parser::ParseService() {
2603 std::vector<std::string> service_comment = doc_comment_;
2604 NEXT();
2605 auto service_name = attribute_;
2606 EXPECT(kTokenIdentifier);
2607 auto &service_def = *new ServiceDef();
2608 service_def.name = service_name;
2609 service_def.file = file_being_parsed_;
2610 service_def.doc_comment = service_comment;
2611 service_def.defined_namespace = current_namespace_;
2612 if (services_.Add(current_namespace_->GetFullyQualifiedName(service_name),
2613 &service_def))
2614 return Error("service already exists: " + service_name);
2615 ECHECK(ParseMetaData(&service_def.attributes));
2616 EXPECT('{');
2617 do {
2618 std::vector<std::string> doc_comment = doc_comment_;
2619 auto rpc_name = attribute_;
2620 EXPECT(kTokenIdentifier);
2621 EXPECT('(');
2622 Type reqtype, resptype;
2623 ECHECK(ParseTypeIdent(reqtype));
2624 EXPECT(')');
2625 EXPECT(':');
2626 ECHECK(ParseTypeIdent(resptype));
2627 if (reqtype.base_type != BASE_TYPE_STRUCT || reqtype.struct_def->fixed ||
2628 resptype.base_type != BASE_TYPE_STRUCT || resptype.struct_def->fixed)
2629 return Error("rpc request and response types must be tables");
2630 auto &rpc = *new RPCCall();
2631 rpc.name = rpc_name;
2632 rpc.request = reqtype.struct_def;
2633 rpc.response = resptype.struct_def;
2634 rpc.doc_comment = doc_comment;
2635 if (service_def.calls.Add(rpc_name, &rpc))
2636 return Error("rpc already exists: " + rpc_name);
2637 ECHECK(ParseMetaData(&rpc.attributes));
2638 EXPECT(';');
2639 } while (token_ != '}');
2640 NEXT();
2641 return NoError();
2642}
2643
2644bool Parser::SetRootType(const char *name) {
2645 root_struct_def_ = LookupStruct(name);

Callers

nothing calls this directly

Calls 4

ErrorFunction · 0.85
NoErrorFunction · 0.85
AddMethod · 0.80
GetFullyQualifiedNameMethod · 0.80

Tested by

no test coverage detected