1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/kernelhwsrv/kerneltest/e32test/cppexceptions/second_excp.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,79 @@
1.4 +/*
1.5 +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
1.6 +* All rights reserved.
1.7 +* This component and the accompanying materials are made available
1.8 +* under the terms of the License "Eclipse Public License v1.0"
1.9 +* which accompanies this distribution, and is available
1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.11 +*
1.12 +* Initial Contributors:
1.13 +* Nokia Corporation - initial contribution.
1.14 +*
1.15 +* Contributors:
1.16 +*
1.17 +* Description:
1.18 +*
1.19 +*/
1.20 +#include "second_excp.h"
1.21 +
1.22 +EXPORT_C int thrower2 (int x) {
1.23 +#ifdef __SUPPORT_CPP_EXCEPTIONS__
1.24 + if (x != 0) throw MySecondException(x);
1.25 +#else //!__SUPPORT_CPP_EXCEPTIONS__
1.26 + if (x != 0)
1.27 + return x;
1.28 + else
1.29 +#endif //__SUPPORT_CPP_EXCEPTIONS__
1.30 + return -1;
1.31 +}
1.32 +
1.33 +EXPORT_C int thrower3 (int x) {
1.34 +#ifdef __SUPPORT_CPP_EXCEPTIONS__
1.35 + if (x != 0) throw MyThirdException(x);
1.36 +#else //!__SUPPORT_CPP_EXCEPTIONS__
1.37 + if (x != 0)
1.38 + return x;
1.39 + else
1.40 +#endif //__SUPPORT_CPP_EXCEPTIONS__
1.41 + return -1;
1.42 +}
1.43 +
1.44 +#pragma warning( disable : 4673 ) /* throwing 'class MyFourthException' the following types will not be considered at the catch site */
1.45 +
1.46 +EXPORT_C int thrower4 (int x) {
1.47 +#ifdef __SUPPORT_CPP_EXCEPTIONS__
1.48 + if (x != 0) throw MyFourthException(x);
1.49 +#else //!__SUPPORT_CPP_EXCEPTIONS__
1.50 + if (x != 0)
1.51 + return x;
1.52 + else
1.53 +#endif //__SUPPORT_CPP_EXCEPTIONS__
1.54 + return -1;
1.55 +}
1.56 +
1.57 +EXPORT_C int thrower5 (int x) {
1.58 +#ifdef __SUPPORT_CPP_EXCEPTIONS__
1.59 + if (x != 0) throw MyFifthException(x);
1.60 +#else //!__SUPPORT_CPP_EXCEPTIONS__
1.61 + if (x != 0)
1.62 + return x;
1.63 + else
1.64 +#endif //__SUPPORT_CPP_EXCEPTIONS__
1.65 + return -1;
1.66 +}
1.67 +
1.68 +
1.69 +EXPORT_C UncaughtTester::UncaughtTester(TInt & x) : aInt(x){}
1.70 +
1.71 +EXPORT_C UncaughtTester::~UncaughtTester(){
1.72 +#ifdef __SUPPORT_CPP_EXCEPTIONS__
1.73 + if (std::uncaught_exception()) {
1.74 + aInt = 2;
1.75 + } else {
1.76 +#endif //__SUPPORT_CPP_EXCEPTIONS__
1.77 + aInt = 1;
1.78 +#ifdef __SUPPORT_CPP_EXCEPTIONS__
1.79 + }
1.80 +#endif //__SUPPORT_CPP_EXCEPTIONS__
1.81 +}
1.82 +