Skip to content

Commit

Permalink
fix: enable service scoping of method invocations in services.echo_co…
Browse files Browse the repository at this point in the history
…nsole (#325)
  • Loading branch information
richardapeters authored Jun 16, 2023
1 parent 8cb1636 commit 7090a40
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions services/echo_console/Console.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -751,9 +751,12 @@ namespace application
std::pair<std::shared_ptr<const EchoService>, const EchoMethod&> Console::SearchMethod(MethodInvocation& methodInvocation) const
{
for (auto service : root.services)
for (auto& method : service->methods)
if (method.name == methodInvocation.method.back())
return std::pair<std::shared_ptr<const EchoService>, const EchoMethod&>(service, method);
{
if (methodInvocation.method.size() == 1 || methodInvocation.method.front() == service->name)
for (auto& method : service->methods)
if (method.name == methodInvocation.method.back())
return std::pair<std::shared_ptr<const EchoService>, const EchoMethod&>(service, method);
}

throw ConsoleExceptions::MethodNotFound{ methodInvocation.method };
}
Expand All @@ -780,7 +783,11 @@ namespace application
{
if (!currentToken.Is<ConsoleToken::String>())
break;
method.push_back(currentToken.Get<ConsoleToken::String>().value);
auto stringToken = currentToken.Get<ConsoleToken::String>();
method.push_back(stringToken.value);

if (method.size() > 2)
throw ConsoleExceptions::SyntaxError{ stringToken.index };

currentToken = tokenizer.Token();

Expand Down

0 comments on commit 7090a40

Please sign in to comment.