home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-11-08 | 3.3 KB | 102 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: FWTryBlo.cpp
- // Release Version: $ 1.0d11 $
- //
- // Copyright: (c) 1993, 1995 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #include "FWFound.hpp"
-
- #ifndef FW_NATIVE_EXCEPTIONS
-
- #ifndef FWTRYBLO_H
- #include "FWTryBlo.h"
- #endif
-
- #ifndef FWEXCRUN_H
- #include "FWExcRun.h"
- #endif
-
- #ifndef FWDELSTA_H
- #include "FWDelSta.h"
- #endif
-
- #if FW_LIB_EXPORT_PRAGMAS
- #pragma lib_export on
- #endif
-
- #ifdef FW_BUILD_MAC
- #pragma segment BEL
- #endif
-
- //========================================================================================
- // CLASS FW_CPrivTryBlockContext
- //========================================================================================
-
- //----------------------------------------------------------------------------------------
- // FW_CPrivTryBlockContext::~FW_CPrivTryBlockContext
- //----------------------------------------------------------------------------------------
- FW_CPrivTryBlockContext::~FW_CPrivTryBlockContext()
- {
- #ifdef FW_DEBUG
- CheckClassInvariants(fGlobals);
- fGlobals.gContextDepth--;
- FW_PRIV_ASSERT(fAutomaticsInMyScope == 0);
- #endif
-
- FW_CPrivTryBlockContext *priorContext = MakeCurrent(fGlobals, fPriorContext);
- FW_PRIV_ASSERT(priorContext == this);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPrivTryBlockContext::FW_CPrivTryBlockContext
- //----------------------------------------------------------------------------------------
- FW_CPrivTryBlockContext::FW_CPrivTryBlockContext(FW_SPrivExceptionGlobals& globals, jmp_buf buffer) :
- fGlobals(globals),
- fJumpBuffer((jmp_buf *) buffer)
- {
- fPriorContext = MakeCurrent(fGlobals, this);
- fDeleteStackLevel = FW_CPrivDeleteStack::RelativeTopOfStack(fGlobals);
-
- #ifdef FW_DEBUG
- fGlobals.gContextDepth++;
- fAutomaticsInMyScope = 0;
- CheckClassInvariants(fGlobals);
- #endif
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPrivTryBlockContext::MakeCurrent
- //----------------------------------------------------------------------------------------
- class FW_CPrivTryBlockContext *FW_CPrivTryBlockContext::MakeCurrent(
- FW_SPrivExceptionGlobals& globals,
- FW_CPrivTryBlockContext *context)
- {
- FW_CPrivTryBlockContext *tmpContext = globals.gCurrentContext;
- globals.gCurrentContext = context;
- return tmpContext;
- }
-
- #ifdef FW_DEBUG
- //----------------------------------------------------------------------------------------
- // FW_CPrivTryBlockContext::CheckClassInvariants
- //
- // Should only be called on current context.
- //----------------------------------------------------------------------------------------
- void FW_CPrivTryBlockContext::CheckClassInvariants(FW_SPrivExceptionGlobals& globals)
- {
- // Ensure class invariants
- FW_PRIV_ASSERT(&globals == &fGlobals);
- FW_PRIV_ASSERT(globals.gContextDepth>=1);
- FW_PRIV_ASSERT(globals.gContextDepth>1 || fPriorContext==NULL);
- FW_PRIV_ASSERT(globals.gContextDepth==1 || fPriorContext!=NULL);
- FW_PRIV_ASSERT(fAutomaticsInMyScope >= 0);
- FW_PRIV_ASSERT(fDeleteStackLevel >= 0);
- FW_PRIV_ASSERT(globals.gCurrentContext == this);
- }
- #endif
-
- #endif // FW_NATIVE_EXCEPTIONS
-