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