MCPcopy Create free account
hub / github.com/Tencent/phxrpc / GenerateURIFuncMap

Method GenerateURIFuncMap

codegen/service_code_render.cpp:412–436  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

410}
411
412void ServiceCodeRender::GenerateURIFuncMap(SyntaxTree *stree, FILE *write) {
413 char dispatcher_name[128]{'\0'};
414 name_render_.GetDispatcherClassName(stree->GetName(), dispatcher_name, sizeof(dispatcher_name));
415
416 fprintf(write, "const phxrpc::HttpDispatcher<%s>::URIFuncMap &%s::GetURIFuncMap() {\n",
417 dispatcher_name, dispatcher_name);
418
419 fprintf(write, " static phxrpc::HttpDispatcher<%s>::URIFuncMap uri_func_map = {\n",
420 dispatcher_name);
421
422 SyntaxFuncVector *flist{stree->GetFuncList()};
423 auto fit(flist->cbegin());
424 for (; flist->cend() != fit; ++fit) {
425 if (fit != flist->cbegin()) {
426 fprintf(write, ",\n");
427 }
428 fprintf(write, " {\"/%s/%s\", &%s::%s}",
429 stree->GetPackageName(), fit->GetName(), dispatcher_name, fit->GetName());
430 }
431 fprintf(write, "};\n");
432
433 fprintf(write, " return uri_func_map;\n");
434
435 fprintf(write, "}\n");
436}
437
438void ServiceCodeRender::GenerateDispatcherFunc(const SyntaxTree *const stree,
439 const SyntaxFunc *const func, FILE *write) {

Callers

nothing calls this directly

Calls 4

GetNameMethod · 0.80
GetFuncListMethod · 0.80
GetPackageNameMethod · 0.45

Tested by

no test coverage detected