1 /* ------------------------------------------------------------------ 2 * Copyright (C) 1998-2009 PacketVideo 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 13 * express or implied. 14 * See the License for the specific language governing permissions 15 * and limitations under the License. 16 * ------------------------------------------------------------------- 17 */ 18 // -*- c++ -*- 19 // = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = 20 21 // O S C L _ E R R O R _ I M P _ C P P E X C E P T I O N S 22 23 // = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = 24 25 /*! \addtogroup osclerror OSCL Error 26 * 27 * @{ 28 */ 29 30 31 /** \file oscl_error_imp_cppexceptions.h 32 \brief Implementation File for Leave using C++ exceptions. 33 */ 34 35 #ifndef OSCL_ERROR_IMP_CPPEXCEPTIONS_H_INCLUDED 36 #define OSCL_ERROR_IMP_CPPEXCEPTIONS_H_INCLUDED 37 38 #ifndef OSCL_ERROR_TRAPCLEANUP_H_INCLUDED 39 #include "oscl_error_trapcleanup.h" 40 #endif 41 42 //Implementation file for Leave using C++ exceptions. 43 44 //This is a full implementation of Leave. 45 46 class internalLeave 47 { 48 public: 49 int a; 50 }; 51 52 //Leave throws C++ exceptions. 53 #define PVError_DoLeave() internalLeave __ilv;__ilv.a=0;throw(__ilv) 54 55 56 //_PV_TRAP catches Leaves. 57 //_r is the leave code, _s are statements to execute 58 #define _PV_TRAP(__r,__s)\ 59 __r=OsclErrNone;\ 60 {\ 61 OsclErrorTrapImp* __tr=OsclErrorTrapImp::Trap();\ 62 if(!__tr){__s;}else{\ 63 try{__s;}\ 64 catch(internalLeave __lv)\ 65 {__lv.a=__r=__tr->iLeave;}\ 66 __tr->UnTrap();}\ 67 } 68 69 //_PV_TRAP_NO_TLS catches Leaves. 70 //_r is the leave code, _s are statements to execute 71 #define _PV_TRAP_NO_TLS(__trapimp,__r,__s)\ 72 __r=OsclErrNone;\ 73 {\ 74 OsclErrorTrapImp* __tr=OsclErrorTrapImp::TrapNoTls(__trapimp);\ 75 if(!__tr){__s;}else{\ 76 try{__s;}\ 77 catch(internalLeave __lv)\ 78 {__lv.a=__r=__tr->iLeave;}\ 79 __tr->UnTrap();}\ 80 } 81 82 83 #endif // OSCL_ERROR_IMP_CPPEXCEPTIONS_H_INCLUDED 84 85 /*! @} */ 86 87 88