typeinfo.h revision 227983
1#include <stddef.h>
2#include "abi_namespace.h"
3#include "typeinfo"
4
5namespace ABI_NAMESPACE
6{
7	/**
8	 * Primitive type info, for intrinsic types.
9	 */
10	struct __fundamental_type_info : public std::type_info
11	{
12		virtual ~__fundamental_type_info();
13	};
14	/**
15	 * Type info for arrays.
16	 */
17	struct __array_type_info : public std::type_info
18	{
19		virtual ~__array_type_info();
20	};
21	/**
22	 * Type info for functions.
23	 */
24	struct __function_type_info : public std::type_info
25	{
26		virtual ~__function_type_info();
27	};
28	/**
29	 * Type info for enums.
30	 */
31	struct __enum_type_info : public std::type_info
32	{
33		virtual ~__enum_type_info();
34	};
35
36	/**
37	 * Base class for class type info.  Used only for tentative definitions.
38	 */
39	struct __class_type_info : public std::type_info
40	{
41		virtual ~__class_type_info();
42		/**
43		 * Function implementing dynamic casts.
44		 */
45		virtual void *cast_to(void *obj,
46		                      const struct __class_type_info *other) const;
47		/**
48		 * Function returning whether a cast from this type to another type is
49		 * possible.
50		 */
51		virtual bool can_cast_to(const struct __class_type_info *other) const;
52	};
53
54	/**
55	 * Single-inheritance class type info.  This is used for classes containing
56	 * a single non-virtual base class at offset 0.
57	 */
58	struct __si_class_type_info : public __class_type_info
59	{
60		virtual ~__si_class_type_info();
61		const __class_type_info *__base_type;
62		virtual void *cast_to(void *obj, const struct __class_type_info *other) const;
63        virtual bool can_cast_to(const struct __class_type_info *other) const;
64	};
65
66	/**
67	 * Type info for base classes.  Classes with multiple bases store an array
68	 * of these, one for each superclass.
69	 */
70	struct __base_class_type_info
71	{
72		const __class_type_info *__base_type;
73		private:
74			/**
75			 * The high __offset_shift bits of this store the (signed) offset
76			 * of the base class.  The low bits store flags from
77			 * __offset_flags_masks.
78			 */
79			long __offset_flags;
80			/**
81			 * Flags used in the low bits of __offset_flags.
82			 */
83			enum __offset_flags_masks
84			{
85				/** This base class is virtual. */
86				__virtual_mask = 0x1,
87				/** This base class is public. */
88				__public_mask = 0x2,
89				/** The number of bits reserved for flags. */
90				__offset_shift = 8
91			};
92		public:
93			/**
94			 * Returns the offset of the base class.
95			 */
96			long offset() const
97			{
98				return __offset_flags >> __offset_shift;
99			}
100			/**
101			 * Returns the flags.
102			 */
103			long flags() const
104			{
105				return __offset_flags & ((1 << __offset_shift) - 1);
106			}
107			/**
108			 * Returns whether this is a public base class.
109			 */
110			bool isPublic() const { return flags() & __public_mask; }
111			/**
112			 * Returns whether this is a virtual base class.
113			 */
114			bool isVirtual() const { return flags() & __virtual_mask; }
115	};
116
117	/**
118	 * Type info for classes with virtual bases or multiple superclasses.
119	 */
120	struct __vmi_class_type_info : public __class_type_info
121	{
122		virtual ~__vmi_class_type_info();
123		/** Flags describing this class.  Contains values from __flags_masks. */
124		unsigned int __flags;
125		/** The number of base classes. */
126		unsigned int __base_count;
127		/**
128		 * Array of base classes - this actually has __base_count elements, not
129		 * 1.
130		 */
131		__base_class_type_info __base_info[1];
132
133		/**
134		 * Flags used in the __flags field.
135		 */
136		enum __flags_masks
137		{
138			/** The class has non-diamond repeated inheritance. */
139			__non_diamond_repeat_mask = 0x1,
140			/** The class is diamond shaped. */
141			__diamond_shaped_mask = 0x2
142		};
143		virtual void *cast_to(void *obj, const struct __class_type_info *other) const;
144        virtual bool can_cast_to(const struct __class_type_info *other) const;
145	};
146
147	/**
148	 * Base class used for both pointer and pointer-to-member type info.
149	 */
150	struct __pbase_type_info : public std::type_info
151	{
152		virtual ~__pbase_type_info();
153		/**
154		 * Flags.  Values from __masks.
155		 */
156		unsigned int __flags;
157		/**
158		 * The type info for the pointee.
159		 */
160		const std::type_info *__pointee;
161
162		/**
163		 * Masks used for qualifiers on the pointer.
164		 */
165		enum __masks
166		{
167			/** Pointer has const qualifier. */
168			__const_mask = 0x1,
169			/** Pointer has volatile qualifier. */
170			__volatile_mask = 0x2,
171			/** Pointer has restrict qualifier. */
172			__restrict_mask = 0x4,
173			/** Pointer points to an incomplete type. */
174			__incomplete_mask = 0x8,
175			/** Pointer is a pointer to a member of an incomplete class. */
176			__incomplete_class_mask = 0x10
177		};
178	};
179
180	/**
181	 * Pointer type info.
182	 */
183	struct __pointer_type_info : public __pbase_type_info
184	{
185		virtual ~__pointer_type_info();
186	};
187
188	/**
189	 * Pointer to member type info.
190	 */
191	struct __pointer_to_member_type_info : public __pbase_type_info
192	{
193		virtual ~__pointer_to_member_type_info();
194		/**
195		 * Pointer to the class containing this member.
196		 */
197		const __class_type_info *__context;
198	};
199
200}
201