-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Fw::ExternalString and revise string implementations #2679
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CppCheck found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CodeQL found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.
Fw/Types/PolyType.cpp
Outdated
} else { | ||
dest = valString; | ||
} | ||
#if FW_SERIALIZABLE_TO_STRING || BUILD_UT |
Check notice
Code scanning / CodeQL
Conditional compilation Note
Fw/Types/PolyType.cpp
Outdated
case TYPE_I8: | ||
(void)snprintf(valString, sizeof(valString), "%" PRId8 " ", this->m_val.i8Val); | ||
break; | ||
#if FW_HAS_16_BIT |
Check notice
Code scanning / CodeQL
Conditional compilation Note
Fw/Types/PolyType.cpp
Outdated
(void)snprintf(valString, sizeof(valString), "%" PRId16 " ", this->m_val.i16Val); | ||
break; | ||
#endif | ||
#if FW_HAS_32_BIT |
Check notice
Code scanning / CodeQL
Conditional compilation Note
Fw/Types/PolyType.cpp
Outdated
(void)snprintf(valString, sizeof(valString), "%" PRId32 " ", this->m_val.i32Val); | ||
break; | ||
#endif | ||
#if FW_HAS_64_BIT |
Check notice
Code scanning / CodeQL
Conditional compilation Note
Fw/Types/PolyType.cpp
Outdated
#endif | ||
#if FW_HAS_F64 |
Check notice
Code scanning / CodeQL
Conditional compilation Note
Fw/Types/Serializable.cpp
Outdated
|
||
#ifdef BUILD_UT |
Check notice
Code scanning / CodeQL
Conditional compilation Note
Converting this PR to draft because I need to do some refactoring. |
Fw/Types/MemAllocator.hpp
Outdated
|
||
private: | ||
MemAllocator(MemAllocator&); //!< disable | ||
MemAllocator(MemAllocator*); //!< disable |
Check warning
Code scanning / CppCheck
Single-parameter constructors should be marked explicit. Warning
Fw/Types/PolyType.hpp
Outdated
PolyType& operator=(U8 val); //!< U8 operator= | ||
class PolyType : public Serializable { | ||
public: | ||
PolyType(U8 val); //!< U8 constructor |
Check warning
Code scanning / CppCheck
Single-parameter constructors should be marked explicit. Warning
Fw/Types/PolyType.hpp
Outdated
void get(I8& val); //!< I8 accessor | ||
bool isI8(); //!< I8 checker | ||
PolyType& operator=(I8 val); //!< I8 operator= | ||
PolyType(I8 val); //!< I8 constructor |
Check warning
Code scanning / CppCheck
Single-parameter constructors should be marked explicit. Warning
Fw/Types/PolyType.hpp
Outdated
void get(I16& val); //!< I16 accessor | ||
bool isI16(); //!< I16 checker | ||
PolyType& operator=(I16 val); //!< I16 operator= | ||
PolyType(U16 val); //!< U16 constructor |
Check warning
Code scanning / CppCheck
Single-parameter constructors should be marked explicit. Warning
Fw/Types/PolyType.hpp
Outdated
bool isU16(); //!< U16 checker | ||
PolyType& operator=(U16 val); //!< I8 operator= | ||
|
||
PolyType(I16 val); //!< I16 constructor |
Check warning
Code scanning / CppCheck
Single-parameter constructors should be marked explicit. Warning
Fw/Types/PolyType.hpp
Outdated
bool isBool(); //!< bool checker | ||
PolyType& operator=(bool val); //!< bool operator= | ||
|
||
PolyType(void* val); //!< void* constructor. |
Check warning
Code scanning / CppCheck
Single-parameter constructors should be marked explicit. Warning
|
||
const char* toChar() const; | ||
NATIVE_UINT_TYPE getCapacity() const; | ||
ParamString(const StringBase& src) : StringBase() { *this = src; } |
Check warning
Code scanning / CppCheck
Single-parameter constructors should be marked explicit. Warning
|
||
private: | ||
ParamString(const char* src) : StringBase() { *this = src; } |
Check warning
Code scanning / CppCheck
Single-parameter constructors should be marked explicit. Warning
|
||
const char* toChar() const; //!< gets char buffer | ||
NATIVE_UINT_TYPE getCapacity() const ; //!< return buffer size | ||
String(const StringBase& src) : StringBase() { *this = src; } |
Check warning
Code scanning / CppCheck
Single-parameter constructors should be marked explicit. Warning
|
||
private: | ||
String(const char* src) : StringBase() { *this = src; } |
Check warning
Code scanning / CppCheck
Single-parameter constructors should be marked explicit. Warning
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did not see what I expected from this PR. Awaiting more input.
This PR does the following:
Fw::ExternalString
. This class is derived fromFw::StringBase
. It uses an externally supplied character buffer to implement a string. I added tests forFw::ExternalString
to theFw/Types
unit tests.Rationale:
Fw::ExternalString
is needed to improve the C++ code generation strategy for strings. See Minimize use of auto-generated string types in C++ code gen fpp#406.Notes:
explicit
. When I tried this, I saw compilation errors in the generated C++. I think this issue will have to be addressed separately.