exceptio.mh

来自「开放源码的编译器open watcom 1.6.0版的源代码」· MH 代码 · 共 104 行

MH
104
字号
///////////////////////////////////////////////////////////////////////////
// FILE: exception.h/exception (Basic exception classes)
//
:keep CPP_HDR
:include crwat.sp
//
// Description: This header is part of the C++ standard library. It
//              defines the base class of the exception classes as
//              well as a number of helper functions related to
//              exception handling.
///////////////////////////////////////////////////////////////////////////
:segment !CNAME
#ifndef _EXCEPTION_H_INCLUDED
#define _EXCEPTION_H_INCLUDED

:include readonly.sp

#ifndef _EXCEPTION_INCLUDED
  #include <exceptio>
#endif
using std::exception;
using std::bad_exception;
using std::unexpected_handler;
using std::set_unexpected;
using std::unexpected;
using std::terminate_handler;
using std::set_terminate;
using std::terminate;
// using std::uncaught_exception;

// Needed for compatibility with Watcom legacy code?
// #include <stdexcep.h>

#endif
:elsesegment
#ifndef _EXCEPTION_INCLUDED
#define _EXCEPTION_INCLUDED

:include readonly.sp

#ifndef __cplusplus
#error The header exception requires C++
#endif

#ifndef _COMDEF_H_INCLUDED
 #include <_comdef.h>
#endif

:include cpppfv.sp

:include watexc.sp

:include throws.sp

namespace std {

  class _WPRTLINK exception {
    const char *_what_val;
  public:
    exception( ) _WCTHROWS() { }

    exception( const exception &src ) _WCTHROWS()
        : _what_val( src._what_val ) { }

    exception( const char *what_val ) _WCTHROWS()
        : _what_val( what_val ) { }

    exception& operator=( const exception &src ) _WCTHROWS()
        { _what_val = src._what_val; return *this; }

    virtual ~exception( ) _WCTHROWS() { }

    virtual const char *what( ) const _WCTHROWS()
        { return _what_val; }
  };


  class _WPRTLINK bad_exception : public exception {
  public:
    bad_exception( ) _WCTHROWS()
        : exception( "exception missing from exception specification" ) { }

    bad_exception( const bad_exception & ) _WCTHROWS() { }

    bad_exception & operator=( bad_exception & ) _WCTHROWS()
        { return *this; }

    virtual ~bad_exception( ) _WCTHROWS() { }
  };


  typedef void (*unexpected_handler)( );
  typedef void (*terminate_handler)( );

  _WPRTLINK extern void terminate( );
  _WPRTLINK extern terminate_handler set_terminate( terminate_handler );
  _WPRTLINK extern void unexpected( );
  _WPRTLINK extern unexpected_handler set_unexpected( unexpected_handler );

} // namespace std

#endif
:endsegment

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?