From c74a4b2f09b5ccc2418999aea3ca90f0dfe42043 Mon Sep 17 00:00:00 2001 From: Joshua Anderson Date: Tue, 15 Jun 2021 18:33:09 -0700 Subject: [PATCH 1/2] Mark Fw::Time addition and subtraction as const --- Fw/Time/Time.cpp | 10 +++++----- Fw/Time/Time.hpp | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Fw/Time/Time.cpp b/Fw/Time/Time.cpp index 155a95f468..a8879b336b 100644 --- a/Fw/Time/Time.cpp +++ b/Fw/Time/Time.cpp @@ -186,9 +186,9 @@ namespace Fw { Time Time :: add( - Time& a, - Time& b - ) + const Time& a, + const Time& b + ) { #if FW_USE_TIME_BASE FW_ASSERT(a.getTimeBase() == b.getTimeBase(), a.getTimeBase(), b.getTimeBase() ); @@ -209,8 +209,8 @@ namespace Fw { Time Time :: sub( - Time& minuend, //!< Time minuend - Time& subtrahend //!< Time subtrahend + const Time& minuend, //!< Time minuend + const Time& subtrahend //!< Time subtrahend ) { #if FW_USE_TIME_BASE diff --git a/Fw/Time/Time.hpp b/Fw/Time/Time.hpp index ce003f57e8..dcc58be8a6 100644 --- a/Fw/Time/Time.hpp +++ b/Fw/Time/Time.hpp @@ -62,15 +62,15 @@ namespace Fw { //! Add two times //! \return The result static Time add( - Time& a, //!< Time a - Time& b //!< Time b + const Time& a, //!< Time a + const Time& b //!< Time b ); //! Subtract subtrahend from minuend //! \return The result static Time sub( - Time& minuend, //!< Value being subtracted from - Time& subtrahend //!< Value being subtracted + const Time& minuend, //!< Value being subtracted from + const Time& subtrahend //!< Value being subtracted ); // add seconds and microseconds to existing time From f63e685428b687728116a26e61d36a834e56e118 Mon Sep 17 00:00:00 2001 From: Joshua Anderson Date: Wed, 16 Jun 2021 13:49:07 -0700 Subject: [PATCH 2/2] Make serializable type getters as const functions --- .../generators/templates/serialize/publicSerialCpp.tmpl | 6 +++--- .../generators/templates/serialize/publicSerialH.tmpl | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Autocoders/Python/src/fprime_ac/generators/templates/serialize/publicSerialCpp.tmpl b/Autocoders/Python/src/fprime_ac/generators/templates/serialize/publicSerialCpp.tmpl index c48cf9f5b9..27e6331219 100644 --- a/Autocoders/Python/src/fprime_ac/generators/templates/serialize/publicSerialCpp.tmpl +++ b/Autocoders/Python/src/fprime_ac/generators/templates/serialize/publicSerialCpp.tmpl @@ -44,13 +44,13 @@ void ${name}::set(${args_proto_string}) { #for ($member,$type,$size,$format,$comment,$typeinfo) in $members: #if $size == None: -${type} ${name}::get${member}(void) { +${type} ${name}::get${member}(void) const { return this->m_${member}; #else if $typeinfo == 'string' or $typeinfo == 'extern': -const ${type}& ${name}::get${member}(void) { +const ${type}& ${name}::get${member}(void) const { return this->m_${member}; #else -const ${type}* ${name}::get${member}(NATIVE_INT_TYPE& size) { +const ${type}* ${name}::get${member}(NATIVE_INT_TYPE& size) const { size = ${size}; return this->m_${member}; #end if diff --git a/Autocoders/Python/src/fprime_ac/generators/templates/serialize/publicSerialH.tmpl b/Autocoders/Python/src/fprime_ac/generators/templates/serialize/publicSerialH.tmpl index 69e81c8c3d..9892426f82 100644 --- a/Autocoders/Python/src/fprime_ac/generators/templates/serialize/publicSerialH.tmpl +++ b/Autocoders/Python/src/fprime_ac/generators/templates/serialize/publicSerialH.tmpl @@ -40,11 +40,11 @@ public: #for name,type,size,format,comment,typeinfo in $members: #if $size == None: - ${type} get${name}(void); //!< get member $name + ${type} get${name}(void) const; //!< get member $name #else if $typeinfo == 'string' or $typeinfo == 'extern': - const ${type}& get${name}(void); //!< get member $name + const ${type}& get${name}(void) const; //!< get member $name #else - const ${type}* get${name}(NATIVE_INT_TYPE& size); //!< get member $name + const ${type}* get${name}(NATIVE_INT_TYPE& size) const; //!< get member $name #end if #end for