diff options
author | David Crocker <dcrocker@eschertech.com> | 2021-03-07 17:14:27 +0300 |
---|---|---|
committer | David Crocker <dcrocker@eschertech.com> | 2021-03-07 17:14:27 +0300 |
commit | f333a1c88e8c533a3c2ba5564967ea167fe78407 (patch) | |
tree | b962be01f2af4080870a7619e709640a1a236430 | |
parent | f91ad24934aca0c14279a5ed86020e802ad3e8de (diff) |
Tided up SetParameters
-rw-r--r-- | src/GCodes/GCodeBuffer/BinaryParser.cpp | 4 | ||||
-rw-r--r-- | src/GCodes/GCodeBuffer/BinaryParser.h | 2 | ||||
-rw-r--r-- | src/GCodes/GCodeBuffer/GCodeBuffer.cpp | 2 | ||||
-rw-r--r-- | src/GCodes/GCodeBuffer/StringParser.cpp | 6 | ||||
-rw-r--r-- | src/GCodes/GCodeBuffer/StringParser.h | 3 |
5 files changed, 9 insertions, 8 deletions
diff --git a/src/GCodes/GCodeBuffer/BinaryParser.cpp b/src/GCodes/GCodeBuffer/BinaryParser.cpp index 8babdea9..d863e151 100644 --- a/src/GCodes/GCodeBuffer/BinaryParser.cpp +++ b/src/GCodes/GCodeBuffer/BinaryParser.cpp @@ -754,7 +754,7 @@ void BinaryParser::WriteParameters(const StringRef& s, bool quoteStrings) const } } -void BinaryParser::SetParameters(GCodeMachineState *mc, int codeRunning) noexcept +void BinaryParser::SetParameters(VariableSet& vs, int codeRunning) noexcept { if (bufferLength != 0 && header->numParameters != 0) { @@ -806,7 +806,7 @@ void BinaryParser::SetParameters(GCodeMachineState *mc, int codeRunning) noexcep if (ev.GetType() != TypeCode::None) { char paramName[2] = { param->letter, 0 }; - mc->variables.Insert(new Variable(paramName, ev, -1)); + vs.Insert(new Variable(paramName, ev, -1)); } } diff --git a/src/GCodes/GCodeBuffer/BinaryParser.h b/src/GCodes/GCodeBuffer/BinaryParser.h index 35d6f800..d2e81c06 100644 --- a/src/GCodes/GCodeBuffer/BinaryParser.h +++ b/src/GCodes/GCodeBuffer/BinaryParser.h @@ -60,7 +60,7 @@ public: void PrintCommand(const StringRef& s) const noexcept; void AppendFullCommand(const StringRef &s) const noexcept; - void SetParameters(GCodeMachineState *mc, int codeRunning) noexcept; + void SetParameters(VariableSet& vs, int codeRunning) noexcept; private: GCodeBuffer& gb; diff --git a/src/GCodes/GCodeBuffer/GCodeBuffer.cpp b/src/GCodes/GCodeBuffer/GCodeBuffer.cpp index 1feac192..75f6cac2 100644 --- a/src/GCodes/GCodeBuffer/GCodeBuffer.cpp +++ b/src/GCodes/GCodeBuffer/GCodeBuffer.cpp @@ -1013,7 +1013,7 @@ void GCodeBuffer::AppendFullCommand(const StringRef &s) const noexcept void GCodeBuffer::SetParameters(int codeRunning) noexcept { - PARSER_OPERATION(SetParameters(machineState, codeRunning)); + PARSER_OPERATION(SetParameters(GetVariables(), codeRunning)); } VariableSet& GCodeBuffer::GetVariables() const noexcept diff --git a/src/GCodes/GCodeBuffer/StringParser.cpp b/src/GCodes/GCodeBuffer/StringParser.cpp index 85da823e..e4abb59e 100644 --- a/src/GCodes/GCodeBuffer/StringParser.cpp +++ b/src/GCodes/GCodeBuffer/StringParser.cpp @@ -1671,9 +1671,9 @@ void StringParser::SkipWhiteSpace() noexcept } } -void StringParser::SetParameters(GCodeMachineState *mc, int codeRunning) noexcept +void StringParser::SetParameters(VariableSet& vs, int codeRunning) noexcept { - parametersPresent.Iterate([this, mc, codeRunning](unsigned int bit, unsigned int count) + parametersPresent.Iterate([this, &vs, codeRunning](unsigned int bit, unsigned int count) { const char letter = 'A' + bit; if ((letter != 'P' || codeRunning != 98) && Seen(letter)) @@ -1683,7 +1683,7 @@ void StringParser::SetParameters(GCodeMachineState *mc, int codeRunning) noexcep { ExpressionValue ev = parser.Parse(); char paramName[2] = { letter, 0 }; - mc->variables.Insert(new Variable(paramName, ev, -1)); + vs.Insert(new Variable(paramName, ev, -1)); } catch (const GCodeException&) { } } diff --git a/src/GCodes/GCodeBuffer/StringParser.h b/src/GCodes/GCodeBuffer/StringParser.h index a8752675..fa090b70 100644 --- a/src/GCodes/GCodeBuffer/StringParser.h +++ b/src/GCodes/GCodeBuffer/StringParser.h @@ -20,6 +20,7 @@ class GCodeBuffer; class IPAddress; class MacAddress; class StringBuffer; +class VariableSet; class StringParser { @@ -82,7 +83,7 @@ public: void PrintCommand(const StringRef& s) const noexcept; void AppendFullCommand(const StringRef &s) const noexcept; - void SetParameters(GCodeMachineState *mc, int codeRunning) noexcept; + void SetParameters(VariableSet& vs, int codeRunning) noexcept; GCodeException ConstructParseException(const char *str) const noexcept; GCodeException ConstructParseException(const char *str, const char *param) const noexcept; |