Skip to content

Commit f6d9011

Browse files
authored
Move enums to enum classes (#379)
* Move enums to enum classes Signed-off-by: Cervenka Dusan <cervenka@acrios.com> * Fixed python typo Signed-off-by: Cervenka Dusan <cervenka@acrios.com> --------- Signed-off-by: Cervenka Dusan <cervenka@acrios.com>
1 parent f335f87 commit f6d9011

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+652
-628
lines changed

erpc_c/infra/erpc_basic_codec.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ void BasicCodec::startWriteUnion(int32_t discriminator)
158158

159159
void BasicCodec::writeNullFlag(bool isNull)
160160
{
161-
write(static_cast<uint8_t>(isNull ? kIsNull : kNotNull));
161+
write(static_cast<uint8_t>(isNull ? null_flag_t::kIsNull : null_flag_t::kNotNull));
162162
}
163163

164164
void BasicCodec::writeCallback(arrayOfFunPtr callbacks, uint8_t callbacksCount, funPtr callback)
@@ -392,7 +392,7 @@ void BasicCodec::readNullFlag(bool &isNull)
392392
read(flag);
393393
if (isStatusOk())
394394
{
395-
isNull = (flag == (uint8_t)kIsNull);
395+
isNull = (flag == static_cast<uint8_t>(null_flag_t::kIsNull));
396396
}
397397
}
398398

erpc_c/infra/erpc_basic_codec.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ namespace erpc {
2727
/*!
2828
* @brief Values of the uint8 flag prefixing nullable values.
2929
*/
30-
enum _null_flag
30+
enum class null_flag_t
3131
{
3232
kNotNull = 0,
3333
kIsNull

erpc_c/infra/erpc_client_manager.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ void ClientManager::verifyReply(RequestContext &request)
175175
if (request.getCodec()->isStatusOk() == true)
176176
{
177177
// Verify that this is a reply to the request we just sent.
178-
if ((msgType != kReplyMessage) || (sequence != request.getSequence()))
178+
if ((msgType != message_type_t::kReplyMessage) || (sequence != request.getSequence()))
179179
{
180180
request.getCodec()->updateStatus(kErpcStatus_ExpectedReply);
181181
}

erpc_c/infra/erpc_client_manager.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,8 @@ class ClientManager : public ClientServerCommon
130130
#endif
131131

132132
protected:
133-
uint32_t m_sequence; //!< Sequence number.
134-
client_error_handler_t m_errorHandler; //!< Pointer to function error handler.
133+
uint32_t m_sequence; //!< Sequence number.
134+
client_error_handler_t m_errorHandler; //!< Pointer to function error handler.
135135
#if ERPC_NESTED_CALLS
136136
Server *m_server; //!< Server used for nested calls.
137137
Thread::thread_id_t m_serverThreadId; //!< Thread in which server run function is called.

erpc_c/infra/erpc_codec.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,13 @@ namespace erpc {
3232
/*!
3333
* @brief Types of messages that can be encoded.
3434
*/
35-
typedef enum _message_type
35+
enum class message_type_t
3636
{
3737
kInvocationMessage = 0,
3838
kOnewayMessage,
3939
kReplyMessage,
4040
kNotificationMessage
41-
} message_type_t;
41+
};
4242

4343
typedef void *funPtr; // Pointer to functions
4444
typedef funPtr *arrayOfFunPtr; // Pointer to array of functions

erpc_c/infra/erpc_server.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ erpc_status_t Server::processMessage(Codec *codec, message_type_t msgType, uint3
7575
erpc_status_t err = kErpcStatus_Success;
7676
Service *service;
7777

78-
if ((msgType != kInvocationMessage) && (msgType != kOnewayMessage))
78+
if ((msgType != message_type_t::kInvocationMessage) && (msgType != message_type_t::kOnewayMessage))
7979
{
8080
err = kErpcStatus_InvalidArgument;
8181
}

erpc_c/infra/erpc_simple_server.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ erpc_status_t SimpleServer::runInternalEnd(Codec *codec, message_type_t msgType,
123123

124124
if (err == kErpcStatus_Success)
125125
{
126-
if (msgType != kOnewayMessage)
126+
if (msgType != message_type_t::kOnewayMessage)
127127
{
128128
#if ERPC_MESSAGE_LOGGING
129129
err = logMessage(codec->getBuffer());
@@ -183,7 +183,7 @@ erpc_status_t SimpleServer::run(RequestContext &request)
183183
break;
184184
}
185185

186-
if (msgType == kReplyMessage)
186+
if (msgType == message_type_t::kReplyMessage)
187187
{
188188
if (sequence == request.getSequence())
189189
{

erpc_c/infra/erpc_transport_arbitrator.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,13 +107,13 @@ erpc_status_t TransportArbitrator::receive(MessageBuffer *message)
107107
}
108108

109109
// If this message is an invocation, return it to the calling server.
110-
if ((msgType == kInvocationMessage) || (msgType == kOnewayMessage))
110+
if ((msgType == message_type_t::kInvocationMessage) || (msgType == message_type_t::kOnewayMessage))
111111
{
112112
break;
113113
}
114114

115115
// Just ignore messages we don't know what to do with.
116-
if (msgType != kReplyMessage)
116+
if (msgType != message_type_t::kReplyMessage)
117117
{
118118
continue;
119119
}

erpc_c/setup/erpc_arbitrated_client_setup.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ extern "C" {
6666
*
6767
* @return erpc_client_t Pointer to client structure.
6868
*/
69-
erpc_client_t erpc_arbitrated_client_init(erpc_transport_t transport, erpc_mbf_t message_buffer_factory, erpc_transport_t *arbitrator);
69+
erpc_client_t erpc_arbitrated_client_init(erpc_transport_t transport, erpc_mbf_t message_buffer_factory,
70+
erpc_transport_t *arbitrator);
7071

7172
/*!
7273
* @brief This function sets error handler function.

erpc_c/transports/erpc_rpmsg_lite_transport.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ class RPMsgTransport : public RPMsgBaseTransport
132132
*
133133
* @return True if exist received message, else false.
134134
*/
135-
virtual bool hasMessage(void) { return ((0UL < m_messageQueue.size()) ? true: false); }
135+
virtual bool hasMessage(void) { return ((0UL < m_messageQueue.size()) ? true : false); }
136136

137137
protected:
138138
/*!

0 commit comments

Comments
 (0)