typeinfo.h (232950) | typeinfo.h (233235) |
---|---|
1/* 2 * Copyright 2010-2011 PathScale, Inc. All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions are met: 6 * 7 * 1. Redistributions of source code must retain the above copyright notice, 8 * this list of conditions and the following disclaimer. --- 12 unchanged lines hidden (view full) --- 21 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 22 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 23 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 24 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 */ 26 27#include <stddef.h> 28#include "abi_namespace.h" | 1/* 2 * Copyright 2010-2011 PathScale, Inc. All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions are met: 6 * 7 * 1. Redistributions of source code must retain the above copyright notice, 8 * this list of conditions and the following disclaimer. --- 12 unchanged lines hidden (view full) --- 21 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 22 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 23 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 24 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 */ 26 27#include <stddef.h> 28#include "abi_namespace.h" |
29#include "typeinfo" | |
30 31namespace ABI_NAMESPACE 32{ | 29 30namespace ABI_NAMESPACE 31{ |
32 struct __class_type_info; 33} 34namespace std 35{ |
|
33 /** | 36 /** |
37 * Standard type info class. The layout of this class is specified by the 38 * ABI. The layout of the vtable is not, but is intended to be 39 * compatible with the GNU ABI. 40 * 41 * Unlike the GNU version, the vtable layout is considered semi-private. 42 */ 43 class type_info 44 { 45 public: 46 /** 47 * Virtual destructor. This class must have one virtual function to 48 * ensure that it has a vtable. 49 */ 50 virtual ~type_info(); 51 bool operator==(const type_info &) const; 52 bool operator!=(const type_info &) const; 53 bool before(const type_info &) const; 54 const char* name() const; 55 type_info(); 56 private: 57 type_info(const type_info& rhs); 58 type_info& operator= (const type_info& rhs); 59 const char *__type_name; 60 /* 61 * The following functions are in this order to match the 62 * vtable layout of libsupc++. This allows libcxxrt to be used 63 * with libraries that depend on this. 64 * 65 * These functions are in the public headers for libstdc++, so 66 * we have to assume that someone will probably call them and 67 * expect them to work. Their names must also match the names used in 68 * libsupc++, so that code linking against this library can subclass 69 * type_info and correctly fill in the values in the vtables. 70 */ 71 public: 72 /** 73 * Catch function. Allows external libraries to implement 74 * their own basic types. This is used, for example, in the 75 * GNUstep Objective-C runtime to allow Objective-C types to be 76 * caught in G++ catch blocks. 77 * 78 * The outer parameter indicates the number of outer pointers 79 * in the high bits. The low bit indicates whether the 80 * pointers are const qualified. 81 */ 82 virtual bool __do_catch(const type_info *thrown_type, 83 void **thrown_object, 84 unsigned outer) const; 85 /** 86 * Performs an upcast. This is used in exception handling to 87 * cast from subclasses to superclasses. If the upcast is 88 * possible, it returns true and adjusts the pointer. If the 89 * upcast is not possible, it returns false and does not adjust 90 * the pointer. 91 */ 92 virtual bool __do_upcast( 93 const ABI_NAMESPACE::__class_type_info *target, 94 void **thrown_object) const 95 { 96 return false; 97 } 98 /** 99 * Returns true if this is some pointer type, false otherwise. 100 */ 101 virtual bool __is_pointer_p() const { return false; } 102 /** 103 * Returns true if this is some function type, false otherwise. 104 */ 105 virtual bool __is_function_p() const { return false; } 106 }; 107} 108 109 110namespace ABI_NAMESPACE 111{ 112 /** |
|
34 * Primitive type info, for intrinsic types. 35 */ 36 struct __fundamental_type_info : public std::type_info 37 { 38 virtual ~__fundamental_type_info(); 39 }; 40 /** 41 * Type info for arrays. 42 */ 43 struct __array_type_info : public std::type_info 44 { 45 virtual ~__array_type_info(); 46 }; 47 /** 48 * Type info for functions. 49 */ 50 struct __function_type_info : public std::type_info 51 { 52 virtual ~__function_type_info(); | 113 * Primitive type info, for intrinsic types. 114 */ 115 struct __fundamental_type_info : public std::type_info 116 { 117 virtual ~__fundamental_type_info(); 118 }; 119 /** 120 * Type info for arrays. 121 */ 122 struct __array_type_info : public std::type_info 123 { 124 virtual ~__array_type_info(); 125 }; 126 /** 127 * Type info for functions. 128 */ 129 struct __function_type_info : public std::type_info 130 { 131 virtual ~__function_type_info(); |
132 virtual bool __is_function_p() const { return true; } |
|
53 }; 54 /** 55 * Type info for enums. 56 */ 57 struct __enum_type_info : public std::type_info 58 { 59 virtual ~__enum_type_info(); 60 }; 61 62 /** 63 * Base class for class type info. Used only for tentative definitions. 64 */ 65 struct __class_type_info : public std::type_info 66 { 67 virtual ~__class_type_info(); 68 /** 69 * Function implementing dynamic casts. 70 */ | 133 }; 134 /** 135 * Type info for enums. 136 */ 137 struct __enum_type_info : public std::type_info 138 { 139 virtual ~__enum_type_info(); 140 }; 141 142 /** 143 * Base class for class type info. Used only for tentative definitions. 144 */ 145 struct __class_type_info : public std::type_info 146 { 147 virtual ~__class_type_info(); 148 /** 149 * Function implementing dynamic casts. 150 */ |
71 virtual void *cast_to(void *obj, 72 const struct __class_type_info *other) const; 73 /** 74 * Function returning whether a cast from this type to another type is 75 * possible. 76 */ 77 virtual bool can_cast_to(const struct __class_type_info *other) const; | 151 virtual void *cast_to(void *obj, const struct __class_type_info *other) const; 152 virtual bool __do_upcast(const __class_type_info *target, 153 void **thrown_object) const 154 { 155 return this == target; 156 } |
78 }; 79 80 /** 81 * Single-inheritance class type info. This is used for classes containing 82 * a single non-virtual base class at offset 0. 83 */ 84 struct __si_class_type_info : public __class_type_info 85 { 86 virtual ~__si_class_type_info(); 87 const __class_type_info *__base_type; | 157 }; 158 159 /** 160 * Single-inheritance class type info. This is used for classes containing 161 * a single non-virtual base class at offset 0. 162 */ 163 struct __si_class_type_info : public __class_type_info 164 { 165 virtual ~__si_class_type_info(); 166 const __class_type_info *__base_type; |
167 virtual bool __do_upcast( 168 const ABI_NAMESPACE::__class_type_info *target, 169 void **thrown_object) const; |
|
88 virtual void *cast_to(void *obj, const struct __class_type_info *other) const; | 170 virtual void *cast_to(void *obj, const struct __class_type_info *other) const; |
89 virtual bool can_cast_to(const struct __class_type_info *other) const; | |
90 }; 91 92 /** 93 * Type info for base classes. Classes with multiple bases store an array 94 * of these, one for each superclass. 95 */ 96 struct __base_class_type_info 97 { --- 63 unchanged lines hidden (view full) --- 161 */ 162 enum __flags_masks 163 { 164 /** The class has non-diamond repeated inheritance. */ 165 __non_diamond_repeat_mask = 0x1, 166 /** The class is diamond shaped. */ 167 __diamond_shaped_mask = 0x2 168 }; | 171 }; 172 173 /** 174 * Type info for base classes. Classes with multiple bases store an array 175 * of these, one for each superclass. 176 */ 177 struct __base_class_type_info 178 { --- 63 unchanged lines hidden (view full) --- 242 */ 243 enum __flags_masks 244 { 245 /** The class has non-diamond repeated inheritance. */ 246 __non_diamond_repeat_mask = 0x1, 247 /** The class is diamond shaped. */ 248 __diamond_shaped_mask = 0x2 249 }; |
250 virtual bool __do_upcast( 251 const ABI_NAMESPACE::__class_type_info *target, 252 void **thrown_object) const; |
|
169 virtual void *cast_to(void *obj, const struct __class_type_info *other) const; | 253 virtual void *cast_to(void *obj, const struct __class_type_info *other) const; |
170 virtual bool can_cast_to(const struct __class_type_info *other) const; | |
171 }; 172 173 /** 174 * Base class used for both pointer and pointer-to-member type info. 175 */ 176 struct __pbase_type_info : public std::type_info 177 { 178 virtual ~__pbase_type_info(); --- 17 unchanged lines hidden (view full) --- 196 __volatile_mask = 0x2, 197 /** Pointer has restrict qualifier. */ 198 __restrict_mask = 0x4, 199 /** Pointer points to an incomplete type. */ 200 __incomplete_mask = 0x8, 201 /** Pointer is a pointer to a member of an incomplete class. */ 202 __incomplete_class_mask = 0x10 203 }; | 254 }; 255 256 /** 257 * Base class used for both pointer and pointer-to-member type info. 258 */ 259 struct __pbase_type_info : public std::type_info 260 { 261 virtual ~__pbase_type_info(); --- 17 unchanged lines hidden (view full) --- 279 __volatile_mask = 0x2, 280 /** Pointer has restrict qualifier. */ 281 __restrict_mask = 0x4, 282 /** Pointer points to an incomplete type. */ 283 __incomplete_mask = 0x8, 284 /** Pointer is a pointer to a member of an incomplete class. */ 285 __incomplete_class_mask = 0x10 286 }; |
287 virtual bool __is_pointer_p() const { return true; } 288 virtual bool __do_catch(const type_info *thrown_type, 289 void **thrown_object, 290 unsigned outer) const; |
|
204 }; 205 206 /** 207 * Pointer type info. 208 */ 209 struct __pointer_type_info : public __pbase_type_info 210 { 211 virtual ~__pointer_type_info(); --- 15 unchanged lines hidden --- | 291 }; 292 293 /** 294 * Pointer type info. 295 */ 296 struct __pointer_type_info : public __pbase_type_info 297 { 298 virtual ~__pointer_type_info(); --- 15 unchanged lines hidden --- |