LibreOffice Module bridges (master) 1
rtti.h
Go to the documentation of this file.
1// Copyright (C) 2000, 2002, 2003, 2004, 2006 Free Software Foundation, Inc.
2//
3// This file is part of GCC.
4//
5// GCC is free software; you can redistribute it and/or modify
6// it under the terms of the GNU General Public License as published by
7// the Free Software Foundation; either version 2, or (at your option)
8// any later version.
9// GCC is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.
13// You should have received a copy of the GNU General Public License
14// along with GCC; see the file COPYING. If not, write to
15// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
16// Boston, MA 02110-1301, USA.
17//
18// As a special exception, you may use this file as part of a free software
19// library without restriction. Specifically, if other files instantiate
20// templates or use macros or inline functions from this file, or you compile
21// this file and link it with other files to produce an executable, this
22// file does not by itself cause the resulting executable to be covered by
23// the GNU General Public License. This exception does not however
24// invalidate any other reasons why the executable file might be covered by
25// the GNU General Public License.
26//
27// Written by Nathan Sidwell, Codesourcery LLC, <nathan@codesourcery.com>
28
29#pragma once
30
31#include <typeinfo>
32
33namespace __cxxabiv1
34{
35 // Type information for int, float etc.
36 class __fundamental_type_info : public std::type_info
37 {
38 public:
39 explicit
40 __fundamental_type_info(const char* __n) : std::type_info(__n) { }
41
42 virtual
44 };
45
46 // Type information for array objects.
47 class __array_type_info : public std::type_info
48 {
49 public:
50 explicit
51 __array_type_info(const char* __n) : std::type_info(__n) { }
52
53 virtual
55 };
56
57 // Type information for functions (both member and non-member).
58 class __function_type_info : public std::type_info
59 {
60 public:
61 explicit
62 __function_type_info(const char* __n) : std::type_info(__n) { }
63
64 virtual
66
67 protected:
68 // Implementation defined member function.
69 virtual bool
71 };
72
73 // Type information for enumerations.
74 class __enum_type_info : public std::type_info
75 {
76 public:
77 explicit
78 __enum_type_info(const char* __n) : std::type_info(__n) { }
79
80 virtual
82 };
83
84 // Common type information for simple pointers and pointers to member.
85 class __pbase_type_info : public std::type_info
86 {
87 public:
88 unsigned int __flags; // Qualification of the target object.
89 const std::type_info* __pointee; // Type of pointed to object.
90
91 explicit
92 __pbase_type_info(const char* __n, int __quals,
93 const std::type_info* __type)
94 : std::type_info(__n), __flags(__quals), __pointee(__type)
95 { }
96
97 virtual
99
100 // Implementation defined type.
102 {
108 };
109
110 protected:
112
115
116 // Implementation defined member functions.
117 virtual bool
118 __do_catch(const std::type_info* __thr_type, void** __thr_obj,
119 unsigned int __outer) const;
120
121 inline virtual bool
122 __pointer_catch(const __pbase_type_info* __thr_type, void** __thr_obj,
123 unsigned __outer) const;
124 };
125
126 // Type information for simple pointers.
128 {
129 public:
130 explicit
131 __pointer_type_info(const char* __n, int __quals,
132 const std::type_info* __type)
133 : __pbase_type_info (__n, __quals, __type) { }
134
135
136 virtual
138
139 protected:
140 // Implementation defined member functions.
141 virtual bool
143
144 virtual bool
145 __pointer_catch(const __pbase_type_info* __thr_type, void** __thr_obj,
146 unsigned __outer) const;
147 };
148
149 class __class_type_info;
150
151 // Type information for a pointer to member variable.
153 {
154 public:
155 __class_type_info* __context; // Class of the member.
156
157 explicit
158 __pointer_to_member_type_info(const char* __n, int __quals,
159 const std::type_info* __type,
160 __class_type_info* __klass)
161 : __pbase_type_info(__n, __quals, __type), __context(__klass) { }
162
163 virtual
165
166 protected:
168
171
172 // Implementation defined member function.
173 virtual bool
174 __pointer_catch(const __pbase_type_info* __thr_type, void** __thr_obj,
175 unsigned __outer) const;
176 };
177
178 // Helper class for __vmi_class_type.
180 {
181 public:
182 const __class_type_info* __base_type; // Base class type.
183 long __offset_flags; // Offset and info.
184
186 {
190 __offset_shift = 8 // Bits to shift offset.
191 };
192
193 // Implementation defined member functions.
194 bool
196 { return __offset_flags & __virtual_mask; }
197
198 bool
200 { return __offset_flags & __public_mask; }
201
202 ptrdiff_t
203 __offset() const
204 {
205 // This shift, being of a signed type, is implementation
206 // defined. GCC implements such shifts as arithmetic, which is
207 // what we want.
208 return static_cast<ptrdiff_t>(__offset_flags) >> __offset_shift;
209 }
210 };
211
212 // Type information for a class.
213 class __class_type_info : public std::type_info
214 {
215 public:
216 explicit
217 __class_type_info (const char *__n) : type_info(__n) { }
218
219 virtual
221
222 // Implementation defined types.
223 // The type sub_kind tells us about how a base object is contained
224 // within a derived object. We often do this lazily, hence the
225 // UNKNOWN value. At other times we may use NOT_CONTAINED to mean
226 // not publicly contained.
228 {
229 // We have no idea.
231
232 // Not contained within us (in some circumstances this might
233 // mean not contained publicly)
235
236 // Contained ambiguously.
238
239 // Via a virtual path.
241
242 // Via a public path.
244
245 // Contained within us.
247
250 };
251
252 struct __upcast_result;
253 struct __dyncast_result;
254
255 protected:
256 // Implementation defined member functions.
257 virtual bool
258 __do_upcast(const __class_type_info* __dst_type, void**__obj_ptr) const;
259
260 virtual bool
261 __do_catch(const type_info* __thr_type, void** __thr_obj,
262 unsigned __outer) const;
263
264 public:
265 // Helper for upcast. See if DST is us, or one of our bases.
266 // Return false if not found, true if found.
267 virtual bool
268 __do_upcast(const __class_type_info* __dst, const void* __obj,
269 __upcast_result& __restrict __result) const;
270
271 // Indicate whether SRC_PTR of type SRC_TYPE is contained publicly
272 // within OBJ_PTR. OBJ_PTR points to a base object of our type,
273 // which is the destination type. SRC2DST indicates how SRC
274 // objects might be contained within this type. If SRC_PTR is one
275 // of our SRC_TYPE bases, indicate the virtuality. Returns
276 // not_contained for non containment or private containment.
277 inline __sub_kind
278 __find_public_src(ptrdiff_t __src2dst, const void* __obj_ptr,
279 const __class_type_info* __src_type,
280 const void* __src_ptr) const;
281
282 // Helper for dynamic cast. ACCESS_PATH gives the access from the
283 // most derived object to this base. DST_TYPE indicates the
284 // desired type we want. OBJ_PTR points to a base of our type
285 // within the complete object. SRC_TYPE indicates the static type
286 // started from and SRC_PTR points to that base within the most
287 // derived object. Fill in RESULT with what we find. Return true
288 // if we have located an ambiguous match.
289 virtual bool
290 __do_dyncast(ptrdiff_t __src2dst, __sub_kind __access_path,
291 const __class_type_info* __dst_type, const void* __obj_ptr,
292 const __class_type_info* __src_type, const void* __src_ptr,
293 __dyncast_result& __result) const;
294
295 // Helper for find_public_subobj. SRC2DST indicates how SRC_TYPE
296 // bases are inherited by the type started from -- which is not
297 // necessarily the current type. The current type will be a base
298 // of the destination type. OBJ_PTR points to the current base.
299 virtual __sub_kind
300 __do_find_public_src(ptrdiff_t __src2dst, const void* __obj_ptr,
301 const __class_type_info* __src_type,
302 const void* __src_ptr) const;
303 };
304
305 // Type information for a class with a single non-virtual base.
307 {
308 public:
310
311 explicit
312 __si_class_type_info(const char *__n, const __class_type_info *__base)
313 : __class_type_info(__n), __base_type(__base) { }
314
315 virtual
317
318 protected:
320
323
324 // Implementation defined member functions.
325 virtual bool
326 __do_dyncast(ptrdiff_t __src2dst, __sub_kind __access_path,
327 const __class_type_info* __dst_type, const void* __obj_ptr,
328 const __class_type_info* __src_type, const void* __src_ptr,
329 __dyncast_result& __result) const;
330
331 virtual __sub_kind
332 __do_find_public_src(ptrdiff_t __src2dst, const void* __obj_ptr,
333 const __class_type_info* __src_type,
334 const void* __sub_ptr) const;
335
336 virtual bool
337 __do_upcast(const __class_type_info*__dst, const void*__obj,
338 __upcast_result& __restrict __result) const;
339 };
340
341 // Type information for a class with multiple and/or virtual bases.
343 {
344 public:
345 unsigned int __flags; // Details about the class hierarchy.
346 unsigned int __base_count; // Number of direct bases.
347
348 // The array of bases uses the trailing array struct hack so this
349 // class is not constructable with a normal constructor. It is
350 // internally generated by the compiler.
351 __base_class_type_info __base_info[1]; // Array of bases.
352
353 explicit
354 __vmi_class_type_info(const char* __n, int ___flags)
355 : __class_type_info(__n), __flags(___flags), __base_count(0) { }
356
357 virtual
359
360 // Implementation defined types.
362 {
363 __non_diamond_repeat_mask = 0x1, // Distinct instance of repeated base.
364 __diamond_shaped_mask = 0x2, // Diamond shaped multiple inheritance.
366 };
367
368 protected:
369 // Implementation defined member functions.
370 virtual bool
371 __do_dyncast(ptrdiff_t __src2dst, __sub_kind __access_path,
372 const __class_type_info* __dst_type, const void* __obj_ptr,
373 const __class_type_info* __src_type, const void* __src_ptr,
374 __dyncast_result& __result) const;
375
376 virtual __sub_kind
377 __do_find_public_src(ptrdiff_t __src2dst, const void* __obj_ptr,
378 const __class_type_info* __src_type,
379 const void* __src_ptr) const;
380
381 virtual bool
382 __do_upcast(const __class_type_info* __dst, const void* __obj,
383 __upcast_result& __restrict __result) const;
384 };
385
386 // Dynamic cast runtime.
387 // src2dst has the following possible values
388 // >-1: src_type is a unique public non-virtual base of dst_type
389 // dst_ptr + src2dst == src_ptr
390 // -1: unspecified relationship
391 // -2: src_type is not a public base of dst_type
392 // -3: src_type is a multiple public non-virtual base of dst_type
393 extern "C" void*
394 __dynamic_cast(const void* __src_ptr, // Starting object.
395 const __class_type_info* __src_type, // Static type of object.
396 const __class_type_info* __dst_type, // Desired target type.
397 ptrdiff_t __src2dst); // How src and dst are related.
398
399
400 // Returns the type_info for the currently handled exception [15.3/8], or
401 // null if there is none.
402 extern "C" std::type_info*
404} // namespace __cxxabiv1
405
406// User programs should use the alias `abi'.
407namespace abi = __cxxabiv1;
__array_type_info(const char *__n)
Definition: rtti.h:51
ptrdiff_t __offset() const
Definition: rtti.h:203
const __class_type_info * __base_type
Definition: rtti.h:182
virtual bool __do_upcast(const __class_type_info *__dst_type, void **__obj_ptr) const
virtual bool __do_upcast(const __class_type_info *__dst, const void *__obj, __upcast_result &__restrict __result) const
virtual __sub_kind __do_find_public_src(ptrdiff_t __src2dst, const void *__obj_ptr, const __class_type_info *__src_type, const void *__src_ptr) const
__class_type_info(const char *__n)
Definition: rtti.h:217
virtual bool __do_catch(const type_info *__thr_type, void **__thr_obj, unsigned __outer) const
__sub_kind __find_public_src(ptrdiff_t __src2dst, const void *__obj_ptr, const __class_type_info *__src_type, const void *__src_ptr) const
virtual bool __do_dyncast(ptrdiff_t __src2dst, __sub_kind __access_path, const __class_type_info *__dst_type, const void *__obj_ptr, const __class_type_info *__src_type, const void *__src_ptr, __dyncast_result &__result) const
__enum_type_info(const char *__n)
Definition: rtti.h:78
__function_type_info(const char *__n)
Definition: rtti.h:62
virtual bool __is_function_p() const
__fundamental_type_info(const char *__n)
Definition: rtti.h:40
const std::type_info * __pointee
Definition: rtti.h:89
__pbase_type_info(const __pbase_type_info &)
virtual bool __do_catch(const std::type_info *__thr_type, void **__thr_obj, unsigned int __outer) const
virtual bool __pointer_catch(const __pbase_type_info *__thr_type, void **__thr_obj, unsigned __outer) const
__pbase_type_info & operator=(const __pbase_type_info &)
unsigned int __flags
Definition: rtti.h:88
__pbase_type_info(const char *__n, int __quals, const std::type_info *__type)
Definition: rtti.h:92
__pointer_to_member_type_info(const char *__n, int __quals, const std::type_info *__type, __class_type_info *__klass)
Definition: rtti.h:158
virtual bool __pointer_catch(const __pbase_type_info *__thr_type, void **__thr_obj, unsigned __outer) const
__pointer_to_member_type_info & operator=(const __pointer_to_member_type_info &)
__pointer_to_member_type_info(const __pointer_to_member_type_info &)
virtual bool __is_pointer_p() const
virtual bool __pointer_catch(const __pbase_type_info *__thr_type, void **__thr_obj, unsigned __outer) const
__pointer_type_info(const char *__n, int __quals, const std::type_info *__type)
Definition: rtti.h:131
virtual __sub_kind __do_find_public_src(ptrdiff_t __src2dst, const void *__obj_ptr, const __class_type_info *__src_type, const void *__sub_ptr) const
__si_class_type_info(const char *__n, const __class_type_info *__base)
Definition: rtti.h:312
__si_class_type_info(const __si_class_type_info &)
virtual bool __do_dyncast(ptrdiff_t __src2dst, __sub_kind __access_path, const __class_type_info *__dst_type, const void *__obj_ptr, const __class_type_info *__src_type, const void *__src_ptr, __dyncast_result &__result) const
__si_class_type_info & operator=(const __si_class_type_info &)
const __class_type_info * __base_type
Definition: rtti.h:309
virtual bool __do_upcast(const __class_type_info *__dst, const void *__obj, __upcast_result &__restrict __result) const
virtual __sub_kind __do_find_public_src(ptrdiff_t __src2dst, const void *__obj_ptr, const __class_type_info *__src_type, const void *__src_ptr) const
virtual bool __do_upcast(const __class_type_info *__dst, const void *__obj, __upcast_result &__restrict __result) const
virtual bool __do_dyncast(ptrdiff_t __src2dst, __sub_kind __access_path, const __class_type_info *__dst_type, const void *__obj_ptr, const __class_type_info *__src_type, const void *__src_ptr, __dyncast_result &__result) const
__vmi_class_type_info(const char *__n, int ___flags)
Definition: rtti.h:354
__base_class_type_info __base_info[1]
Definition: rtti.h:351
std::type_info * __cxa_current_exception_type()
void * __dynamic_cast(const void *__src_ptr, const __class_type_info *__src_type, const __class_type_info *__dst_type, ptrdiff_t __src2dst)