2000-10-11 01:43:26 +02:00
|
|
|
// RTTI support for -*- C++ -*-
|
2001-02-16 02:26:14 +01:00
|
|
|
// Copyright (C) 1994, 1995, 1996, 1997, 1998, 2000, 2001 Free Software Foundation
|
2001-02-16 01:44:44 +01:00
|
|
|
//
|
2000-10-11 01:43:26 +02:00
|
|
|
// This file is part of GNU CC.
|
|
|
|
//
|
|
|
|
// GNU CC is free software; you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation; either version 2, or (at your option)
|
|
|
|
// any later version.
|
|
|
|
//
|
|
|
|
// GNU CC is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with GNU CC; see the file COPYING. If not, write to
|
|
|
|
// the Free Software Foundation, 59 Temple Place - Suite 330,
|
|
|
|
// Boston, MA 02111-1307, USA.
|
|
|
|
|
|
|
|
// As a special exception, you may use this file as part of a free software
|
|
|
|
// library without restriction. Specifically, if other files instantiate
|
|
|
|
// templates or use macros or inline functions from this file, or you compile
|
|
|
|
// this file and link it with other files to produce an executable, this
|
|
|
|
// file does not by itself cause the resulting executable to be covered by
|
|
|
|
// the GNU General Public License. This exception does not however
|
|
|
|
// invalidate any other reasons why the executable file might be covered by
|
|
|
|
// the GNU General Public License.
|
|
|
|
|
2001-07-11 21:35:49 +02:00
|
|
|
/** @file typeinfo
|
|
|
|
* This header provides RTTI support.
|
|
|
|
*/
|
|
|
|
|
2000-10-11 01:43:26 +02:00
|
|
|
#ifndef __TYPEINFO__
|
|
|
|
#define __TYPEINFO__
|
|
|
|
|
|
|
|
#include <exception>
|
|
|
|
|
|
|
|
extern "C++" {
|
|
|
|
|
|
|
|
namespace __cxxabiv1
|
|
|
|
{
|
|
|
|
class __class_type_info;
|
|
|
|
} // namespace __cxxabiv1
|
|
|
|
|
2001-02-16 02:26:14 +01:00
|
|
|
#if !__GXX_WEAK__
|
|
|
|
// If weak symbols are not supported, typeinfo names are not merged.
|
2001-02-04 09:37:50 +01:00
|
|
|
#define __GXX_MERGED_TYPEINFO_NAMES 0
|
|
|
|
#else
|
2001-02-16 02:26:14 +01:00
|
|
|
// On platforms that support weak symbols, typeinfo names are merged.
|
2001-02-04 09:37:50 +01:00
|
|
|
#define __GXX_MERGED_TYPEINFO_NAMES 1
|
|
|
|
#endif
|
|
|
|
|
2001-01-17 08:44:57 +01:00
|
|
|
namespace std
|
|
|
|
{
|
2001-07-11 21:35:49 +02:00
|
|
|
/** The @c type_info class describes type information generated by
|
|
|
|
* an implementation.
|
|
|
|
* @brief Used in RTTI. */
|
2001-01-17 08:44:57 +01:00
|
|
|
class type_info
|
|
|
|
{
|
|
|
|
public:
|
2001-07-11 21:35:49 +02:00
|
|
|
/** Destructor. Being the first non-inline virtual function, this
|
|
|
|
* controls in which translation unit the vtable is emitted. The
|
|
|
|
* compiler makes use of that information to know where to emit
|
|
|
|
* the runtime-mandated type_info structures in the new-abi. */
|
2001-01-17 08:44:57 +01:00
|
|
|
virtual ~type_info();
|
|
|
|
|
|
|
|
private:
|
2001-07-11 21:35:49 +02:00
|
|
|
/// Assigning type_info is not supported. Made private.
|
2001-01-17 08:44:57 +01:00
|
|
|
type_info& operator=(const type_info&);
|
|
|
|
type_info(const type_info&);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
const char *__name;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
explicit type_info(const char *__n): __name(__n) { }
|
|
|
|
|
|
|
|
public:
|
|
|
|
// the public interface
|
2001-09-26 01:51:17 +02:00
|
|
|
/** Returns an @e implementation-defined byte string; this is not
|
2001-07-11 21:35:49 +02:00
|
|
|
* portable between compilers! */
|
2001-01-17 08:44:57 +01:00
|
|
|
const char* name() const
|
2000-10-11 01:43:26 +02:00
|
|
|
{ return __name; }
|
|
|
|
|
2001-02-04 09:37:50 +01:00
|
|
|
#if !__GXX_MERGED_TYPEINFO_NAMES
|
|
|
|
bool before(const type_info& arg) const;
|
|
|
|
// In old abi, or when weak symbols are not supported, there can
|
|
|
|
// be multiple instances of a type_info object for one
|
|
|
|
// type. Uniqueness must use the _name value, not object address.
|
|
|
|
bool operator==(const type_info& __arg) const;
|
2000-10-11 01:43:26 +02:00
|
|
|
#else
|
ChangeLog, [...]: Fix spelling errors.
* ChangeLog, docs/doxygen/maint.cfg.in, docs/doxygen/user.cfg.in,
docs/doxygen/doxygroups.cc, docs/doxygen/Intro.3,
docs/html/17_intro/BUGS, docs/html/17_intro/C++STYLE,
docs/html/17_intro/CHECKLIST, docs/html/17_intro/DESIGN,
docs/html/17_intro/howto.html, docs/html/17_intro/porting.html,
docs/html/17_intro/porting.texi, docs/html/18_support/howto.html,
docs/html/19_diagnostics/howto.html, docs/html/20_util/howto.html,
docs/html/21_strings/howto.html,
docs/html/23_containers/howto.html,
docs/html/26_numerics/howto.html, docs/html/27_io/howto.html,
docs/html/27_io/binary_iostreams_kuehl.txt,
docs/html/ext/sgiexts.html, docs/html/faq/index.html,
docs/html/faq/index.txt, testsuite/24_iterators/iterator.cc,
include/bits/basic_file.h, include/bits/locale_facets.h,
include/bits/locale_facets.tcc, include/bits/std_sstream.h,
include/ext/ropeimpl.h, include/ext/stl_rope.h,
libsupc++/tinfo.cc, libsupc++/cxxabi.h, libsupc++/typeinfo,
libsupc++/eh_throw.cc, acinclude.m4, aclocal.m4, configure,
configure.target, ChangeLog-2000: Fix spelling errors.
From-SVN: r47291
2001-11-23 17:29:02 +01:00
|
|
|
/** Returns true if @c *this precedes @c __arg in the implementation's
|
2001-07-11 21:35:49 +02:00
|
|
|
* collation order. */
|
2001-01-17 08:44:57 +01:00
|
|
|
// In new abi we can rely on type_info's NTBS being unique,
|
|
|
|
// and therefore address comparisons are sufficient.
|
|
|
|
bool before(const type_info& __arg) const
|
2000-10-11 01:43:26 +02:00
|
|
|
{ return __name < __arg.__name; }
|
2001-01-17 08:44:57 +01:00
|
|
|
bool operator==(const type_info& __arg) const
|
2000-10-11 01:43:26 +02:00
|
|
|
{ return __name == __arg.__name; }
|
2001-02-04 09:37:50 +01:00
|
|
|
#endif
|
2001-01-17 08:44:57 +01:00
|
|
|
bool operator!=(const type_info& __arg) const
|
|
|
|
{ return !operator==(__arg); }
|
|
|
|
|
|
|
|
// the internal interface
|
|
|
|
public:
|
|
|
|
// return true if this is a pointer type of some kind
|
|
|
|
virtual bool __is_pointer_p() const;
|
|
|
|
// return true if this is a function type
|
|
|
|
virtual bool __is_function_p() const;
|
|
|
|
|
|
|
|
// Try and catch a thrown type. Store an adjusted pointer to the
|
|
|
|
// caught type in THR_OBJ. If THR_TYPE is not a pointer type, then
|
|
|
|
// THR_OBJ points to the thrown object. If THR_TYPE is a pointer
|
|
|
|
// type, then THR_OBJ is the pointer itself. OUTER indicates the
|
|
|
|
// number of outer pointers, and whether they were const
|
|
|
|
// qualified.
|
|
|
|
virtual bool __do_catch(const type_info *__thr_type, void **__thr_obj,
|
|
|
|
unsigned __outer) const;
|
|
|
|
|
|
|
|
// internally used during catch matching
|
|
|
|
virtual bool __do_upcast(const __cxxabiv1::__class_type_info *__target,
|
|
|
|
void **__obj_ptr) const;
|
|
|
|
};
|
|
|
|
|
2001-07-11 21:35:49 +02:00
|
|
|
/** If you attempt an invalid @c dynamic_cast expression, an instance of
|
|
|
|
* this class (or something derived from this class) is thrown. */
|
2001-01-17 08:44:57 +01:00
|
|
|
class bad_cast : public exception
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
bad_cast() throw() { }
|
|
|
|
};
|
|
|
|
|
2001-07-11 21:35:49 +02:00
|
|
|
/** If you use a NULL pointer in a @c typeid expression, this is thrown. */
|
2001-01-17 08:44:57 +01:00
|
|
|
class bad_typeid : public exception
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
bad_typeid () throw() { }
|
|
|
|
};
|
2000-10-11 01:43:26 +02:00
|
|
|
} // namespace std
|
|
|
|
|
|
|
|
} // extern "C++"
|
|
|
|
#endif
|