Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/Duet3D/RepRapFirmware.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Crocker <dcrocker@eschertech.com>2020-01-04 21:15:22 +0300
committerDavid Crocker <dcrocker@eschertech.com>2020-01-04 21:15:22 +0300
commit5bd28a1aea25e83e6e1d7a0ca50cd000e7baf1a7 (patch)
tree059d11bfc384d80c7ff07d3457e994ac50a0c07e /src/GCodes/GCodeMachineState.cpp
parent8ded9143fa9d07dcddd525683403980c42881f1a (diff)
Conditional GCode fixes and exception specifiers
Loops are now working Added noexcept specifiers to omst of the remaining C++ source files
Diffstat (limited to 'src/GCodes/GCodeMachineState.cpp')
-rw-r--r--src/GCodes/GCodeMachineState.cpp38
1 files changed, 24 insertions, 14 deletions
diff --git a/src/GCodes/GCodeMachineState.cpp b/src/GCodes/GCodeMachineState.cpp
index bb9ab7e7..36aa4e14 100644
--- a/src/GCodes/GCodeMachineState.cpp
+++ b/src/GCodes/GCodeMachineState.cpp
@@ -18,7 +18,7 @@ static unsigned int LastFileId = 1;
#endif
// Create a default initialised GCodeMachineState
-GCodeMachineState::GCodeMachineState()
+GCodeMachineState::GCodeMachineState() noexcept
: previous(nullptr), feedRate(DefaultFeedRate * SecondsToMinutes), lockedResources(0), errorMessage(nullptr),
lineNumber(0), compatibility(Compatibility::reprapFirmware), drivesRelative(false), axesRelative(false), doingFileMacro(false), runningM501(false),
runningM502(false), volumetricExtrusion(false), g53Active(false), runningSystemMacro(false), usingInches(false),
@@ -28,19 +28,20 @@ GCodeMachineState::GCodeMachineState()
fileId = 0;
isFileFinished = fileError = false;
#endif
+ blockStates[0].SetPlainBlock();
}
#if HAS_LINUX_INTERFACE
// Set the state to indicate a file is being processed
-void GCodeMachineState::SetFileExecuting()
+void GCodeMachineState::SetFileExecuting() noexcept
{
fileId = LastFileId++;
isFileFinished = fileError = false;
}
// Mark the currently executing file as finished
-void GCodeMachineState::SetFileFinished(bool error)
+void GCodeMachineState::SetFileFinished(bool error) noexcept
{
isFileFinished = true;
fileError = error;
@@ -48,7 +49,7 @@ void GCodeMachineState::SetFileFinished(bool error)
#endif
-bool GCodeMachineState::DoingFile() const
+bool GCodeMachineState::DoingFile() const noexcept
{
#if HAS_LINUX_INTERFACE
if (reprap.UsingLinuxInterface())
@@ -64,7 +65,7 @@ bool GCodeMachineState::DoingFile() const
}
// Close the currently executing file
-void GCodeMachineState::CloseFile()
+void GCodeMachineState::CloseFile() noexcept
{
#if HAS_LINUX_INTERFACE
if (reprap.UsingLinuxInterface())
@@ -87,8 +88,17 @@ void GCodeMachineState::CloseFile()
}
}
+void GCodeMachineState::CopyStateFrom(const GCodeMachineState& other) noexcept
+{
+ drivesRelative = other.drivesRelative;
+ axesRelative = other.axesRelative;
+ feedRate = other.feedRate;
+ volumetricExtrusion = other.volumetricExtrusion;
+ usingInches = other.usingInches;
+}
+
// Allocate a new GCodeMachineState
-/*static*/ GCodeMachineState *GCodeMachineState::Allocate()
+/*static*/ GCodeMachineState *GCodeMachineState::Allocate() noexcept
{
GCodeMachineState *ms = freeList;
if (ms != nullptr)
@@ -106,7 +116,7 @@ void GCodeMachineState::CloseFile()
return ms;
}
-/*static*/ void GCodeMachineState::Release(GCodeMachineState *ms)
+/*static*/ void GCodeMachineState::Release(GCodeMachineState *ms) noexcept
{
#if HAS_LINUX_INTERFACE
if (reprap.UsingLinuxInterface())
@@ -125,7 +135,7 @@ void GCodeMachineState::CloseFile()
freeList = ms;
}
-/*static*/ unsigned int GCodeMachineState::GetNumInUse()
+/*static*/ unsigned int GCodeMachineState::GetNumInUse() noexcept
{
unsigned int inUse = numAllocated;
for (GCodeMachineState *ms = freeList; ms != nullptr; ms = ms->previous)
@@ -135,18 +145,18 @@ void GCodeMachineState::CloseFile()
return inUse;
}
-GCodeMachineState::BlockState& GCodeMachineState::CurrentBlockState()
+GCodeMachineState::BlockState& GCodeMachineState::CurrentBlockState() noexcept
{
return blockStates[indentLevel];
}
-// Get the number of iterations of the closest enclosing loop i the current file, or -1 if there is on enclosing loop
-int32_t GCodeMachineState::GetIterations() const
+// Get the number of iterations of the closest enclosing loop in the current file, or -1 if there is on enclosing loop
+int32_t GCodeMachineState::GetIterations() const noexcept
{
uint8_t i = indentLevel;
while (true)
{
- if (blockStates[i].GetType() != BlockType::loop)
+ if (blockStates[i].GetType() == BlockType::loop)
{
return blockStates[i].GetIterations();
}
@@ -159,7 +169,7 @@ int32_t GCodeMachineState::GetIterations() const
}
// Create a new block returning true if successful, false if maximum indent level exceeded
-bool GCodeMachineState::CreateBlock()
+bool GCodeMachineState::CreateBlock() noexcept
{
if (indentLevel + 1 == ARRAY_SIZE(blockStates))
{
@@ -171,7 +181,7 @@ bool GCodeMachineState::CreateBlock()
return true;
}
-void GCodeMachineState::EndBlock()
+void GCodeMachineState::EndBlock() noexcept
{
if (indentLevel != 0)
{