diff options
author | David Crocker <dcrocker@eschertech.com> | 2020-01-27 16:39:24 +0300 |
---|---|---|
committer | David Crocker <dcrocker@eschertech.com> | 2020-01-27 16:39:24 +0300 |
commit | fe079c21c242e2c3831651c58710c114c0848a22 (patch) | |
tree | 91e8cb69acce9cb959143aac1a4bc76ef5a3e9eb /src/ObjectModel/ObjectModel.h | |
parent | 79df4b88ed68875cd58ef4e1ec5ea22f9ab9d55e (diff) |
Bug fix to expressions using OM variables
Fixed bug: if an expression in a GCode command used an object model
varoiable starting with g, m or t and the name was preceded by a space
or tab, then the firmware tried to interpret it as another command
Diffstat (limited to 'src/ObjectModel/ObjectModel.h')
-rw-r--r-- | src/ObjectModel/ObjectModel.h | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/ObjectModel/ObjectModel.h b/src/ObjectModel/ObjectModel.h index 54d007b6..b076026b 100644 --- a/src/ObjectModel/ObjectModel.h +++ b/src/ObjectModel/ObjectModel.h @@ -62,7 +62,6 @@ template<> constexpr TypeCode TypeOf<MacAddress> () noexcept { return 16; } // Forward declarations class ObjectModelTableEntry; class ObjectModel; -class StringParser; // Struct used to hold the expressions with polymorphic types struct ExpressionValue @@ -131,7 +130,7 @@ enum class ObjectModelEntryFlags : uint8_t class ObjectExplorationContext { public: - ObjectExplorationContext(const char *reportFlags, unsigned int initialMaxDepth, bool wal) noexcept; + ObjectExplorationContext(const char *reportFlags, bool wal, unsigned int initialMaxDepth, int p_line = -1, int p_col = -1) noexcept; void SetMaxDepth(unsigned int d) noexcept { maxDepth = d; } bool IncreaseDepth() noexcept { if (currentDepth < maxDepth) { ++currentDepth; return true; } return false; } @@ -148,6 +147,8 @@ public: bool WantArrayLength() const noexcept { return wantArrayLength; } bool ShouldIncludeNulls() const noexcept { return includeNulls; } + GCodeException ConstructParseException(const char *msg) const noexcept; + private: static constexpr size_t MaxIndices = 4; // max depth of array nesting @@ -156,6 +157,8 @@ private: size_t numIndicesProvided; // the number of indices provided, when we are doing a value lookup size_t numIndicesCounted; // the number of indices passed in the search string int32_t indices[MaxIndices]; + int line; + int column; bool shortForm; bool onlyLive; bool includeVerbose; @@ -183,7 +186,7 @@ public: void ReportAsJson(OutputBuffer *buf, const char *filter, const char *reportFlags, bool wantArrayLength) const THROWS_GCODE_EXCEPTION; // Get the value of an object via the table - ExpressionValue GetObjectValue(const StringParser& sp, ObjectExplorationContext& context, const char *idString, uint8_t tableNumber = 0) const THROWS_GCODE_EXCEPTION; + ExpressionValue GetObjectValue(ObjectExplorationContext& context, const char *idString, uint8_t tableNumber = 0) const THROWS_GCODE_EXCEPTION; // Function to report a value or object as JSON void ReportItemAsJson(OutputBuffer *buf, ObjectExplorationContext& context, ExpressionValue val, const char *filter) const THROWS_GCODE_EXCEPTION; @@ -199,7 +202,7 @@ protected: void ReportArrayAsJson(OutputBuffer *buf, ObjectExplorationContext& context, const ObjectModelArrayDescriptor *omad, const char *filter) const THROWS_GCODE_EXCEPTION; // Get the value of an object that we hold - ExpressionValue GetObjectValue(const StringParser& sp, ObjectExplorationContext& context, ExpressionValue val, const char *idString) const THROWS_GCODE_EXCEPTION; + ExpressionValue GetObjectValue(ObjectExplorationContext& context, ExpressionValue val, const char *idString) const THROWS_GCODE_EXCEPTION; // Get the object model table entry for the current level object in the query const ObjectModelTableEntry *FindObjectModelTableEntry(uint8_t tableNumber, const char *idString) const noexcept; |