Skip to content

Commit

Permalink
Merge pull request #1459 from dgelessus/console_parsing
Browse files Browse the repository at this point in the history
Refactor and add tests for console command parsing
  • Loading branch information
Hoikas authored Sep 18, 2023
2 parents dedae35 + 1ccefa3 commit 7ebef73
Show file tree
Hide file tree
Showing 11 changed files with 1,151 additions and 246 deletions.
2 changes: 2 additions & 0 deletions Sources/Plasma/FeatureLib/pfConsoleCore/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@ set(pfConsoleCore_SOURCES
pfConsoleCommandsCore.cpp
pfConsoleContext.cpp
pfConsoleEngine.cpp
pfConsoleParser.cpp
)

set(pfConsoleCore_HEADERS
pfConsoleCmd.h
pfConsoleContext.h
pfConsoleEngine.h
pfConsoleParser.h
)

plasma_library(pfConsoleCore SOURCES ${pfConsoleCore_SOURCES} ${pfConsoleCore_HEADERS})
Expand Down
19 changes: 19 additions & 0 deletions Sources/Plasma/FeatureLib/pfConsoleCore/pfConsoleCmd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ You can contact Cyan Worlds, Inc. by email [email protected]

#include "pfConsoleCmd.h"

#include <string_theory/format>
#include <string_theory/string_stream>

//////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -134,6 +135,15 @@ void pfConsoleCmdGroup::AddSubGroup( pfConsoleCmdGroup *group )
fBaseCmdGroupRef++;
}

ST::string pfConsoleCmdGroup::GetFullName()
{
if (fParentGroup == nullptr || fParentGroup == GetBaseGroup()) {
return fName;
} else {
return ST::format("{}.{}", fParentGroup->GetFullName(), fName);
}
}

//// FindCommand /////////////////////////////////////////////////////////////
// No longer recursive.

Expand Down Expand Up @@ -446,6 +456,15 @@ void pfConsoleCmd::Unlink()
*fPrevPtr = fNext;
}

ST::string pfConsoleCmd::GetFullName()
{
if (fParentGroup == pfConsoleCmdGroup::GetBaseGroup()) {
return fName;
} else {
return ST::format("{}.{}", fParentGroup->GetFullName(), fName);
}
}

//// GetSigEntry /////////////////////////////////////////////////////////////

uint8_t pfConsoleCmd::GetSigEntry(size_t i)
Expand Down
2 changes: 2 additions & 0 deletions Sources/Plasma/FeatureLib/pfConsoleCore/pfConsoleCmd.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ class pfConsoleCmdGroup

pfConsoleCmdGroup *GetNext() { return fNext; }
ST::string GetName() { return fName; }
ST::string GetFullName();
pfConsoleCmdGroup *GetParent() { return fParentGroup; }

static pfConsoleCmdGroup *GetBaseGroup();
Expand Down Expand Up @@ -262,6 +263,7 @@ class pfConsoleCmd

pfConsoleCmd *GetNext() { return fNext; }
ST::string GetName() { return fName; }
ST::string GetFullName();
ST::string GetHelp() { return fHelpString; }
ST::string GetSignature();

Expand Down
Loading

0 comments on commit 7ebef73

Please sign in to comment.