Skip to content

Commit

Permalink
align switch brackets (#396)
Browse files Browse the repository at this point in the history
Signed-off-by: Cervenka Dusan <cervenka@acrios.com>
Co-authored-by: Michal Princ <michal.princ@nxp.com>
  • Loading branch information
Hadatko and MichalPrincNXP authored Feb 9, 2024
1 parent a8a7a0d commit 61b1b36
Show file tree
Hide file tree
Showing 15 changed files with 280 additions and 2 deletions.
10 changes: 10 additions & 0 deletions erpc_c/transports/erpc_i2c_slave_transport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,39 +108,49 @@ static void I2C_SlaveUserCallback(I2C_Type *base, volatile i2c_slave_transfer_t
{
/* Address match event */
case kI2C_SlaveAddressMatchEvent:
{
transfer->rxData = NULL;
transfer->rxSize = 0;
break;
}
/* Transmit request */
case kI2C_SlaveTransmitEvent:
{
/* Update information for transmit process */
transfer->txData = ((I2C_CLB_USER_DATA *)userData)->tx_buffer;
transfer->txSize = ((I2C_CLB_USER_DATA *)userData)->tx_size;
transfer->rxData = NULL;
transfer->rxSize = 0;
break;
}

/* Setup the slave receive buffer */
case kI2C_SlaveReceiveEvent:
{
/* Update information for received process */
transfer->rxData = ((I2C_CLB_USER_DATA *)userData)->rx_buffer;
transfer->rxSize = ((I2C_CLB_USER_DATA *)userData)->rx_size;
transfer->txData = NULL;
transfer->txSize = 0;
break;
}

/* The master has sent a stop transition on the bus */
case kI2C_SlaveCompletionEvent:
{
transport->transfer_cb();
transfer->rxData = NULL;
transfer->rxSize = 0;
transfer->txData = NULL;
transfer->txSize = 0;
break;
}

default:
{
s_isTransferCompleted = false;
break;
}
}
}

Expand Down
8 changes: 8 additions & 0 deletions erpc_c/transports/erpc_lpi2c_slave_transport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,20 +108,25 @@ static void LPI2C_SlaveUserCallback(LPI2C_Type *base, lpi2c_slave_transfer_t *tr
{
/* Transmit request */
case kLPI2C_SlaveTransmitEvent:
{
/* Update information for transmit process */
transfer->data = ((LPI2C_CLB_USER_DATA *)userData)->tx_buffer;
transfer->dataSize = ((LPI2C_CLB_USER_DATA *)userData)->tx_size;
break;
}

/* Setup the slave receive buffer */
case kLPI2C_SlaveReceiveEvent:
{
/* Update information for received process */
transfer->data = ((LPI2C_CLB_USER_DATA *)userData)->rx_buffer;
transfer->dataSize = ((LPI2C_CLB_USER_DATA *)userData)->rx_size;
break;
}

/* The master has sent a stop transition on the bus */
case kLPI2C_SlaveCompletionEvent:
{
/* Filter out dummy transaction completions (additional dummy recv./transmit) */
if (!(transfer->transferredCount == 0 && transfer->dataSize == 0) && transfer->data != NULL)
{
Expand All @@ -130,10 +135,13 @@ static void LPI2C_SlaveUserCallback(LPI2C_Type *base, lpi2c_slave_transfer_t *tr
transfer->dataSize = 0;
}
break;
}

default:
{
s_isTransferCompleted = false;
break;
}
}
}

Expand Down
2 changes: 2 additions & 0 deletions erpcgen/src/AstNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,9 @@ string AstNode::getDescription() const
case TOK_UNARY_NEGATE:
case TOK_ARRAY:
case TOK_UNION_CASE:
{
break;
}
default:
{
output += " " + valToString + " ";
Expand Down
34 changes: 34 additions & 0 deletions erpcgen/src/AstWalker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,49 +62,79 @@ void AstWalker::dispatch(AstNode *node)
switch (tok.getToken())
{
case TOK_PROGRAM:
{
rewrite = handleProgram(node, dir);
break;
}
case TOK_CHILDREN:
{
break;
}
case TOK_TYPE:
{
rewrite = handleType(node, dir);
break;
}
case TOK_ENUM:
{
rewrite = handleEnum(node, dir);
break;
}
case TOK_ENUM_MEMBER:
{
rewrite = handleEnumMember(node, dir);
break;
}
case TOK_STRUCT:
{
rewrite = handleStruct(node, dir);
break;
}
case TOK_STRUCT_MEMBER:
{
rewrite = handleStructMember(node, dir);
break;
}
case TOK_UNION:
{
rewrite = handleUnion(node, dir);
break;
}
case TOK_UNION_CASE:
{
rewrite = handleUnionCase(node, dir);
break;
}
case TOK_INTERFACE:
{
rewrite = handleInterface(node, dir);
break;
}
case TOK_FUNCTION:
{
rewrite = handleFunction(node, dir);
break;
}
case TOK_PARAM:
{
rewrite = handleParam(node, dir);
break;
}
case TOK_CONST:
{
rewrite = handleConst(node, dir);
break;
}
case TOK_EXPR:
{
rewrite = handleExpr(node, dir);
break;
}
case TOK_ANNOTATION:
{
rewrite = handleAnnotation(node, dir);
break;
}
case '+':
case '-':
case '*':
Expand All @@ -115,12 +145,16 @@ void AstWalker::dispatch(AstNode *node)
case '^':
case TOK_LSHIFT:
case TOK_RSHIFT:
{
rewrite = handleBinaryOp(node, dir);
break;
}
case TOK_UNARY_NEGATE:
case '~':
{
rewrite = handleUnaryOp(node, dir);
break;
}
}

if (rewrite)
Expand Down
47 changes: 47 additions & 0 deletions erpcgen/src/CGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -821,7 +821,9 @@ void CGenerator::makeAliasesTemplateData()
break;
}
default:
{
throw internal_error("Only structs or enums are allowed as unnamed types.");
}
}
}
aliases.push_back(aliasInfo);
Expand Down Expand Up @@ -2268,8 +2270,11 @@ string CGenerator::getTypenameName(DataType *t, const string &name)
break;
}
default:
{
throw internal_error(format_string("In getTypenameName: unknown data type: %s value:%d",
t->getName().c_str(), t->getDataType()));
break;
}
}
return returnName;
}
Expand All @@ -2279,35 +2284,65 @@ string CGenerator::getBuiltinTypename(const BuiltinType *t)
switch (t->getBuiltinType())
{
case BuiltinType::builtin_type_t::kBoolType:
{
return "bool";
}
case BuiltinType::builtin_type_t::kInt8Type:
{
return "int8_t";
}
case BuiltinType::builtin_type_t::kInt16Type:
{
return "int16_t";
}
case BuiltinType::builtin_type_t::kInt32Type:
{
return "int32_t";
}
case BuiltinType::builtin_type_t::kInt64Type:
{
return "int64_t";
}
case BuiltinType::builtin_type_t::kUInt8Type:
{
return "uint8_t";
}
case BuiltinType::builtin_type_t::kUInt16Type:
{
return "uint16_t";
}
case BuiltinType::builtin_type_t::kUInt32Type:
{
return "uint32_t";
}
case BuiltinType::builtin_type_t::kUInt64Type:
{
return "uint64_t";
}
case BuiltinType::builtin_type_t::kFloatType:
{
return "float";
}
case BuiltinType::builtin_type_t::kDoubleType:
{
return "double";
}
case BuiltinType::builtin_type_t::kStringType:
{
return "char *";
}
case BuiltinType::builtin_type_t::kUStringType:
{
return "unsigned char*";
}
case BuiltinType::builtin_type_t::kBinaryType:
{
return "uint8_t *";
}
default:
{
throw internal_error("unknown builtin type");
}
}
}

Expand Down Expand Up @@ -3039,7 +3074,9 @@ bool CGenerator::isNeedCallFree(DataType *dataType)
return false;
}
default:
{
return false;
}
}
}

Expand Down Expand Up @@ -3422,15 +3459,25 @@ string CGenerator::getDirection(param_direction_t direction)
switch (direction)
{
case param_direction_t::kInDirection:
{
return "kInDirection";
}
case param_direction_t::kOutDirection:
{
return "kOutDirection";
}
case param_direction_t::kInoutDirection:
{
return "kInoutDirection";
}
case param_direction_t::kReturn:
{
return "kReturn";
}
default:
{
throw semantic_error("Unsupported direction type");
}
}
}

Expand Down
Loading

0 comments on commit 61b1b36

Please sign in to comment.