1 // RTTI support for -*- C++ -*-
2 // Copyright (C) 1994, 1995, 1996, 1997, 1998, 2000 Free Software Foundation
4 // This file is part of GNU CC.
6 // GNU CC is free software; you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation; either version 2, or (at your option)
11 // GNU CC is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with GNU CC; see the file COPYING. If not, write to
18 // the Free Software Foundation, 59 Temple Place - Suite 330,
19 // Boston, MA 02111-1307, USA.
21 // As a special exception, you may use this file as part of a free software
22 // library without restriction. Specifically, if other files instantiate
23 // templates or use macros or inline functions from this file, or you compile
24 // this file and link it with other files to produce an executable, this
25 // file does not by itself cause the resulting executable to be covered by
26 // the GNU General Public License. This exception does not however
27 // invalidate any other reasons why the executable file might be covered by
28 // the GNU General Public License.
30 // __GXX_ABI_VERSION distinguishes the ABI that is being used. Values <100
31 // indicate the `old' abi, which grew as C++ was defined. Values >=100
32 // indicate the `new' abi, which is a cross vendor C++ abi, documented at
33 // `http://reality.sgi.com/dehnert_engr/cxx/'.
38 #pragma interface "typeinfo"
44 #if defined(__GXX_ABI_VERSION) && __GXX_ABI_VERSION >= 100
47 class __class_type_info;
48 } // namespace __cxxabiv1
55 // Destructor. Being the first non-inline virtual function, this controls in
56 // which translation unit the vtable is emitted. The compiler makes use of
57 // that information to know where to emit the runtime-mandated type_info
58 // structures in the new-abi.
59 virtual ~type_info ();
62 // Assigning type_info is not supported. made private.
63 type_info& operator= (const type_info&);
64 type_info (const type_info&);
70 explicit type_info (const char *__n): __name (__n) { }
73 // the public interface
74 #if !defined(__GXX_ABI_VERSION) || __GXX_ABI_VERSION < 100
75 // In old abi, there can be multiple instances of a type_info object for one
76 // type. Uniqueness must use the _name value, not object address.
77 bool before (const type_info& arg) const;
78 const char* name () const
80 bool operator== (const type_info& __arg) const;
81 bool operator!= (const type_info& __arg) const
82 { return !operator== (__arg); }
85 // In new abi we can rely on type_info's NTBS being unique,
86 // and therefore address comparisons are sufficient.
87 bool before (const type_info& __arg) const
88 { return __name < __arg.__name; }
89 const char* name () const
91 bool operator== (const type_info& __arg) const
92 { return __name == __arg.__name; }
93 bool operator!= (const type_info& __arg) const
94 { return !operator== (__arg); }
97 // the internal interface
98 #if defined(__GXX_ABI_VERSION) && __GXX_ABI_VERSION >= 100
100 // return true if this is a pointer type of some kind
101 virtual bool __is_pointer_p () const;
102 // return true if this is a function type
103 virtual bool __is_function_p () const;
105 // Try and catch a thrown type. Store an adjusted pointer to the caught type
106 // in THR_OBJ. If THR_TYPE is not a pointer type, then THR_OBJ points to the
107 // thrown object. If THR_TYPE is a pointer type, then THR_OBJ is the pointer
108 // itself. OUTER indicates the number of outer pointers, and whether they
109 // were const qualified.
110 virtual bool __do_catch (const type_info *__thr_type, void **__thr_obj,
111 unsigned __outer) const;
113 // internally used during catch matching
114 virtual bool __do_upcast (const __cxxabiv1::__class_type_info *__target,
115 void **__obj_ptr) const;
119 class bad_cast : public exception {
122 virtual ~bad_cast() { }
125 class bad_typeid : public exception {
128 virtual ~bad_typeid () { }