210 lines
5.3 KiB
C++
210 lines
5.3 KiB
C++
/*
|
|
* Generated by erpcgen 1.14.0 on Wed Dec 31 16:10:10 2025.
|
|
*
|
|
* AUTOGENERATED - DO NOT EDIT
|
|
*/
|
|
|
|
|
|
#include "head_service_server.hpp"
|
|
#if ERPC_ALLOCATION_POLICY == ERPC_ALLOCATION_POLICY_DYNAMIC
|
|
#include <new>
|
|
#include "erpc_port.h"
|
|
#endif
|
|
#include "erpc_manually_constructed.hpp"
|
|
|
|
#if 11400 != ERPC_VERSION_NUMBER
|
|
#error "The generated shim code version is different to the rest of eRPC code."
|
|
#endif
|
|
|
|
using namespace erpc;
|
|
using namespace std;
|
|
using namespace erpcShim;
|
|
|
|
#if ERPC_NESTED_CALLS_DETECTION
|
|
extern bool nestingDetection;
|
|
#endif
|
|
|
|
|
|
//! @brief Function to read struct list_int32_1_t
|
|
static void read_list_int32_1_t_struct(erpc::Codec * codec, list_int32_1_t * data);
|
|
|
|
|
|
// Read struct list_int32_1_t function implementation
|
|
static void read_list_int32_1_t_struct(erpc::Codec * codec, list_int32_1_t * data)
|
|
{
|
|
if(NULL == data)
|
|
{
|
|
return;
|
|
}
|
|
|
|
codec->startReadList(data->elementsCount);
|
|
data->elements = (int32_t *) erpc_malloc(data->elementsCount * sizeof(int32_t));
|
|
if ((data->elements == NULL) && (data->elementsCount > 0))
|
|
{
|
|
codec->updateStatus(kErpcStatus_MemoryError);
|
|
}
|
|
for (uint32_t listCount = 0U; listCount < data->elementsCount; ++listCount)
|
|
{
|
|
codec->read(data->elements[listCount]);
|
|
}
|
|
}
|
|
|
|
|
|
//! @brief Function to free space allocated inside struct list_int32_1_t
|
|
static void free_list_int32_1_t_struct(list_int32_1_t * data);
|
|
|
|
|
|
// Free space allocated inside struct list_int32_1_t function implementation
|
|
static void free_list_int32_1_t_struct(list_int32_1_t * data)
|
|
{
|
|
erpc_free(data->elements);
|
|
}
|
|
|
|
|
|
|
|
demo_service::demo_service(demo_interface *_demo_interface)
|
|
: erpc::Service(demo_interface::m_serviceId)
|
|
, m_handler(_demo_interface)
|
|
{
|
|
}
|
|
|
|
demo_service::~demo_service()
|
|
{
|
|
}
|
|
|
|
// return service interface handler.
|
|
demo_interface* demo_service::getHandler(void)
|
|
{
|
|
return m_handler;
|
|
}
|
|
|
|
// Call the correct server shim based on method unique ID.
|
|
erpc_status_t demo_service::handleInvocation(uint32_t methodId, uint32_t sequence, Codec * codec, MessageBufferFactory *messageFactory, Transport * transport)
|
|
{
|
|
erpc_status_t erpcStatus;
|
|
switch (methodId)
|
|
{
|
|
case demo_interface::m_addId:
|
|
{
|
|
erpcStatus = add_shim(codec, messageFactory, transport, sequence);
|
|
break;
|
|
}
|
|
|
|
case demo_interface::m_sum_i32Id:
|
|
{
|
|
erpcStatus = sum_i32_shim(codec, messageFactory, transport, sequence);
|
|
break;
|
|
}
|
|
|
|
default:
|
|
{
|
|
erpcStatus = kErpcStatus_InvalidArgument;
|
|
break;
|
|
}
|
|
}
|
|
|
|
return erpcStatus;
|
|
}
|
|
|
|
// Server shim for add of demo interface.
|
|
erpc_status_t demo_service::add_shim(Codec * codec, MessageBufferFactory *messageFactory, Transport * transport, uint32_t sequence)
|
|
{
|
|
erpc_status_t err = kErpcStatus_Success;
|
|
|
|
int32_t a;
|
|
int32_t b;
|
|
int32_t result;
|
|
|
|
// startReadMessage() was already called before this shim was invoked.
|
|
|
|
codec->read(a);
|
|
|
|
codec->read(b);
|
|
|
|
err = codec->getStatus();
|
|
if (err == kErpcStatus_Success)
|
|
{
|
|
// Invoke the actual served function.
|
|
#if ERPC_NESTED_CALLS_DETECTION
|
|
nestingDetection = true;
|
|
#endif
|
|
result = m_handler->add(a, b);
|
|
#if ERPC_NESTED_CALLS_DETECTION
|
|
nestingDetection = false;
|
|
#endif
|
|
|
|
// preparing MessageBuffer for serializing data
|
|
err = messageFactory->prepareServerBufferForSend(codec->getBufferRef(), transport->reserveHeaderSize());
|
|
}
|
|
|
|
if (err == kErpcStatus_Success)
|
|
{
|
|
// preparing codec for serializing data
|
|
codec->reset(transport->reserveHeaderSize());
|
|
|
|
// Build response message.
|
|
codec->startWriteMessage(message_type_t::kReplyMessage, demo_interface::m_serviceId, demo_interface::m_addId, sequence);
|
|
|
|
codec->write(result);
|
|
|
|
err = codec->getStatus();
|
|
}
|
|
|
|
return err;
|
|
}
|
|
|
|
// Server shim for sum_i32 of demo interface.
|
|
erpc_status_t demo_service::sum_i32_shim(Codec * codec, MessageBufferFactory *messageFactory, Transport * transport, uint32_t sequence)
|
|
{
|
|
erpc_status_t err = kErpcStatus_Success;
|
|
|
|
list_int32_1_t *arr = NULL;
|
|
arr = (list_int32_1_t *) erpc_malloc(sizeof(list_int32_1_t));
|
|
if (arr == NULL)
|
|
{
|
|
codec->updateStatus(kErpcStatus_MemoryError);
|
|
}
|
|
int64_t result;
|
|
|
|
// startReadMessage() was already called before this shim was invoked.
|
|
|
|
read_list_int32_1_t_struct(codec, arr);
|
|
|
|
err = codec->getStatus();
|
|
if (err == kErpcStatus_Success)
|
|
{
|
|
// Invoke the actual served function.
|
|
#if ERPC_NESTED_CALLS_DETECTION
|
|
nestingDetection = true;
|
|
#endif
|
|
result = m_handler->sum_i32(arr);
|
|
#if ERPC_NESTED_CALLS_DETECTION
|
|
nestingDetection = false;
|
|
#endif
|
|
|
|
// preparing MessageBuffer for serializing data
|
|
err = messageFactory->prepareServerBufferForSend(codec->getBufferRef(), transport->reserveHeaderSize());
|
|
}
|
|
|
|
if (err == kErpcStatus_Success)
|
|
{
|
|
// preparing codec for serializing data
|
|
codec->reset(transport->reserveHeaderSize());
|
|
|
|
// Build response message.
|
|
codec->startWriteMessage(message_type_t::kReplyMessage, demo_interface::m_serviceId, demo_interface::m_sum_i32Id, sequence);
|
|
|
|
codec->write(result);
|
|
|
|
err = codec->getStatus();
|
|
}
|
|
|
|
if (arr)
|
|
{
|
|
free_list_int32_1_t_struct(arr);
|
|
}
|
|
erpc_free(arr);
|
|
|
|
return err;
|
|
}
|