cmvr_head/packages/erpc-1.14.0/test/test_unions/test_unions.erpc
2025-12-30 15:44:41 +08:00

150 lines
3.2 KiB
Plaintext

/*!
* Copyright (c) 2016, Freescale Semiconductor, Inc.
* Copyright 2016-2017 NXP
* All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
@c:include("myAlloc.hpp")
@output_dir("erpc_outputs")
@separateInterfaceOutput(true)
program test;
import "../common/unit_test_common.erpc"
enum caseValues { bar, baz }
enum fruit { apple, orange, banana, coconut, grape, papaya, kiwi, returnVal }
//const int32 returnVal = 10;
type floatList = list<float>
struct foobar
{
float a
binary rawString
}
union unionType
{
case apple:
foobar myFoobar
case banana:
case papaya:
int32 x;
float y;
case orange:
list<int32> a
case coconut:
uint32 cx;
list<int32> cc @length(cx)
case returnVal:
int32 ret
default:
bool c
int32 blah
}
struct foo
{
int32 discriminator
union(discriminator)
{
case apple:
foobar myFoobar
case banana:
case papaya:
int32 x;
float y;
case orange:
list<int32> a
case coconut:
uint32 cx;
list<int32> cc @length(cx)
case returnVal:
int32 ret
default:
bool c
int32 blah
} bing
}
struct InnerList {
list<int32> myList
}
const uint8 gcBleDeviceAddressSize_c = 6
type bleDeviceAddress_t = uint8[gcBleDeviceAddressSize_c]
type bool_t = uint8
enum bleResult_t { gBleStatusBase_c, gBleSuccess_c, gBleOsError_c }
enum gapGenericEventType_t
{
gInternalError_c,
gWhiteListSizeReady_c,
gRandomAddressReady_c,
gPublicAddressRead_c,
gAdvertisingSetupFailed_c,
gAdvTxPowerLevelRead_c,
gPrivateResolvableAddressVerified_c
gTestCaseReturn_c
}
enum gapInternalErrorSource_t
{
gHciCommandStatus_c,
gCheckPrivateResolvableAddress_c,
gVerifySignature_c,
gConnect_c
}
struct gapInternalError_t
{
bleResult_t errorCode
gapInternalErrorSource_t errorSource
uint16 hciCommandOpcode
}
struct gapGenericEvent_t
{
gapGenericEventType_t eventType;
union(eventType)
{
case gInternalError_c:
gapInternalError_t internalError /*!<comment test*/
case gWhiteListSizeReady_c:
uint8 whiteListSize; /*!<another comment test */
case gRandomAddressReady_c, gPublicAddressRead_c:
bleDeviceAddress_t aAddress /*!< testing more comments */
case gAdvertisingSetupFailed_c:
bleResult_t setupFailError;
case gAdvTxPowerLevelRead_c:
int8 advTxPowerLevel_dBm
case gPrivateResolvableAddressVerified_c:
bool_t verified;
case gTestCaseReturn_c:
int32 returnCode;
default:
int8 defaultValue
} eventData
}
/*struct Foop {
gapGenericEventType_t eventType;
union(eventType){
default:
void
} value
}*/
interface ArithmeticService {
testGenericCallback(gapGenericEvent_t event) -> gapGenericEvent_t
sendMyFoo(foo f @retain) -> foo
sendMyUnion(fruit discriminator, unionType unionVariable @discriminator(discriminator)) -> foo
testInnerList(InnerList il) -> InnerList
}