MCPcopy Create free account
hub / github.com/apache/thrift / compare_services

Function compare_services

compiler/cpp/src/thrift/audit/t_audit.cpp:373–423  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

371}
372
373void compare_services(const std::vector<t_service*>& newServices, const std::vector<t_service*>& oldServices)
374{
375 std::vector<t_service*>::const_iterator oldServiceIt;
376
377 std::map<std::string, t_service*> newServiceMap;
378 for(auto newService : newServices)
379 {
380 newServiceMap[newService->get_name()] = newService;
381 }
382
383
384 for(oldServiceIt = oldServices.begin(); oldServiceIt != oldServices.end(); oldServiceIt++)
385 {
386 const std::string oldServiceName = (*oldServiceIt)->get_name();
387 auto newServiceMapIt = newServiceMap.find(oldServiceName);
388
389 if(newServiceMapIt == newServiceMap.end())
390 {
391 thrift_audit_failure("New Thrift file is missing a service %s\n", oldServiceName.c_str());
392 }
393 else
394 {
395 t_service* oldServiceExtends = (*oldServiceIt)->get_extends();
396 t_service* newServiceExtends = (newServiceMapIt->second)->get_extends();
397
398 if(oldServiceExtends == nullptr)
399 {
400 // It is fine to add extends. So if service in older thrift did not have any extends, we are fine.
401 // DO Nothing
402 }
403 else if(oldServiceExtends != nullptr && newServiceExtends == nullptr)
404 {
405 thrift_audit_failure("Change in Service inheritance for %s\n", oldServiceName.c_str());
406 }
407 else
408 {
409 std::string oldExtendsName = oldServiceExtends->get_name();
410 std::string newExtendsName = newServiceExtends->get_name();
411
412 if( newExtendsName != oldExtendsName)
413 {
414 thrift_audit_failure("Change in Service inheritance for %s\n", oldServiceName.c_str());
415 }
416 }
417
418 compare_functions((newServiceMapIt->second)->get_functions(), (*oldServiceIt)->get_functions());
419 }
420
421 }
422
423}
424
425void compare_consts(const std::vector<t_const*>& newConst, const std::vector<t_const*>& oldConst)
426{

Callers 1

auditFunction · 0.85

Calls 7

thrift_audit_failureFunction · 0.85
compare_functionsFunction · 0.85
findMethod · 0.80
get_extendsMethod · 0.80
get_nameMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected