Zen API

- Home
- Help Topics
- Types by Category
- All Types
- Files

All Classes Files Functions Variables Typedefs Macros Groups Pages
kType.h
Go to the documentation of this file.
1 /**
2 * @file kType.h
3 * @brief Declarations related to the kType system.
4 *
5 * @internal
6 * Copyright (C) 2005-2014 by LMI Technologies Inc.
7 * Licensed under the MIT License.
8 * Redistributed files must retain the above copyright notice.
9 */
10 #include <kApi/kApiDef.h> //--inclusion order controlled by kApiDef
11
12 #ifndef K_API_TYPE_H
13 #define K_API_TYPE_H
14
15 kBeginHeader()
16
17 #define kTypeName kText64 ///< Alias for type used to store a kType text name.
18
19 /**
20 * @struct kTypeFlag
21 * @extends kValue
22 * @ingroup kApi
23 * @brief Represents an enumeration of type flags.
24 *
25 * The following enumerators are defined:
26 * - #kTYPE_FLAGS_CLASS
27 * - #kTYPE_FLAGS_INTERFACE
28 * - #kTYPE_FLAGS_VALUE
29 * - #kTYPE_FLAGS_VALUE
30 * - #kTYPE_FLAGS_ENUM
31 * - #kTYPE_FLAGS_BIT_ENUM
32 * - #kTYPE_FLAGS_ABSTRACT
33 */
34 typedef k32u kTypeFlags;
35
36 #define kTYPE_FLAGS_CLASS (0x01) ///< Type is a class.
37 #define kTYPE_FLAGS_INTERFACE (0x02) ///< Type is an interface.
38 #define kTYPE_FLAGS_VALUE (0x04) ///< Type is a value.
39 #define kTYPE_FLAGS_ENUM (0x08) ///< Type is an enumeration.
40 #define kTYPE_FLAGS_BIT_ENUM (0x10) ///< Type is a bitset enumeration.
41 #define kTYPE_FLAGS_ABSTRACT (0x20) ///< Type is an abstract class.
42 #define kTYPE_FLAGS_ARRAY_VALUE (0x40) ///< Type is an array-based value (e.g. kText32).
43
44 /**
45 * @struct kTypeVersion
46 * @ingroup kApi
47 * @brief Represents an opaque reference to type version information (used in object serialization).
48 */
49 typedef kPointer kTypeVersion;
50
51 /**
52 * @class kType
53 * @extends kObject
54 * @ingroup kApi
55 * @brief Represents metadata about a type (class, interface, or value).
56 *
57 * When an assembly is constructed, one kType instance is created for every type defined in the assmebly.
58 * kAssembly methods can be used to discover the types in the assembly, and kType methods can be used to
59 * learn about individual types (e.g., type name, base class).
60 *
61 * The kObject_Type method can be used to obtain type information for any object derived from kObject.
62 * The kTypeOf macro can be used to obtain type information for any class, interface, or value by
63 * compile-time type symbol.
64 *
65 * @code
66 *
67 * kBool IsImageType(kObject object)
68 * {
69 * kType objectType = kObject_Type(object);
70 * kType imageType = kTypeOf(kImage);
71 *
72 * return objectType == imageType;
73 * }
74 *
75 * @endcode
76 *
77 */
78 //typedef kObject kType; --forward-declared in kApiDef.x.h
79
80 /**
81 * Gets the assembly to which the type belongs.
82 *
83 * @public @memberof kType
84 * @param type Type.
85 * @return Assembly.
86 */
87 kFx(kAssembly) kType_Assembly(kType type);
88
89 /**
90 * Gets the name of the type.
91 *
92 * @public @memberof kType
93 * @param type Type.
94 * @return Type name.
95 */
96 kFx(const kChar*) kType_Name(kType type);
97
98 /**
99 * Determines whether a type is equivalent to another type.
100 *
101 * Checks type equality, inheritance, and interfaces.
102 *
103 * @public @memberof kType
104 * @param type Type to be compared.
105 * @param other Type to which type is compared.
106 * @return kTRUE if type is equivalent.
107 */
108 kFx(kBool) kType_Is(kType type, kType other);
109
110 /**
111 * Determines whether a type represents a value (primitive, struct, enum).
112 *
113 * @public @memberof kType
114 * @param type Type.
115 * @return kTRUE if type represents a value.
116 */
117 kFx(kBool) kType_IsValue(kType type);
118
119 /**
120 * Determines whether a type represents a class.
121 *
122 * @public @memberof kType
123 * @param type Type.
124 * @return kTRUE if type represents a class.
125 */
126 kFx(kBool) kType_IsClass(kType type);
127
128 /**
129 * Determines whether a type represents an interface.
130 *
131 * @public @memberof kType
132 * @param type Type.
133 * @return kTRUE if type represents an interface.
134 */
135 kFx(kBool) kType_IsInterface(kType type);
136
137 /**
138 * Determines whether a type represents a class or interface.
139 *
140 * @public @memberof kType
141 * @param type Type.
142 * @return kTRUE if type represents a reference.
143 */
144 kFx(kBool) kType_IsReference(kType type);
145
146 /**
147 * Determines whether a type represents an abstract class.
148 *
149 * @public @memberof kType
150 * @param type Class type.
151 * @return kTRUE if type is abstract.
152 */
153 kFx(kBool) kType_IsAbstract(kType type);
154
155 /**
156 * Reports whether the type is an enumeration.
157 *
158 * @public @memberof kType
159 * @return kTRUE if the type is an enumeration; otherwise, kFALSE.
160 */
161 kFx(kBool) kType_IsEnum(kType type);
162
163 /**
164 * Reports whether the type is an enumeration bitset.
165 *
166 * @public @memberof kType
167 * @return kTRUE if the type is an enumeration bitset; otherwise, kFALSE.
168 */
169 kFx(kBool) kType_IsBitEnum(kType type);
170
171 /**
172 * Reports whether the type is an 'array-value' type (e.g., kText32)
173 *
174 * @public @memberof kType
175 * @return kTRUE if the type is an 'array-value' type; otherwise, kFALSE.
176 */
177 kFx(kBool) kType_IsArrayValue(kType type);
178
179 /**
180 * Determines whether a type implements a specific interface.
181 *
182 * @public @memberof kType
183 * @param type Type.
184 * @param interfaceType Interface type.
185 * @return kTRUE if type implements interface.
186 */
187 kFx(kBool) kType_Implements(kType type, kType interfaceType);
188
189 /**
190 * Determines whether a type extends another type.
191 *
192 * @public @memberof kType
193 * @param type Type.
194 * @param baseType Base type.
195 * @return kTRUE if type extends base type.
196 */
197 kFx(kBool) kType_Extends(kType type, kType baseType);
198
199 /**
200 * Gets the base of a class or interface.
201 *
202 * @public @memberof kType
203 * @param type Type.
204 * @return Base type (or kNULL if none).
205 */
206 kFx(kType) kType_Base(kType type);
207
208 /**
209 * Gets the external size of a type.
210 *
211 * The external size of a value type reflects the size of the struct, value or enum. The external size of a reference
212 * type is equal to the size of a pointer.
213 *
214 * @public @memberof kType
215 * @return Type size.
216 */
217 kFx(kSize) kType_Size(kType type);
218
219 /**
220 * Gets the internal size of a type.
221 *
222 * The internal size of a value type reflects the size of the struct, value or enum. The internal size of a reference
223 * type is equal to the size of its class structure.
224 *
225 * @public @memberof kType
226 * @return Type size.
227 */
228 kFx(kSize) kType_InnerSize(kType type);
229
230 /**
231 * Gets a pointer to the type's primary virtual method table.
232 *
233 * @public @memberof kType
234 * @return Virtual table pointer.
235 */
236 kFx(kFunction*) kType_VTable(kType type);
237
238 /**
239 * Gets a pointer to the type's virtual method table corresponding to the specified interface type.
240 *
241 * @public @memberof kType
242 * @return Interface virtual table pointer.
243 */
244 kFx(kFunction*) kType_IVTable(kType type, kType interfaceType);
245
246 /**
247 * Gets a pointer to the type's static data structure.
248 *
249 * @public @memberof kType
250 * @return Pointer to static data.
251 */
252 kFx(void*) kType_Static(kType type);
253
254 /**
255 * Reports whether the type's static data structure has been successfully initialized.
256 *
257 * This function can be helpful during startup, to determine whether the static data for a particular type
258 * has been initialized. This function is not thread-safe.
259 *
260 * @public @memberof kType
261 * @return kTRUE if static data has been initialized; otherwise, kFALSE.
262 */
263 kFx(kBool) kType_StaticInitialized(kType type);
264
265 #define kType_Assembly_(TYPE) kxType_Assembly_(TYPE) ///< Macro version of kType_Assembly.
266 #define kType_Is_(TYPE, OTHER) kxType_Is_(TYPE, OTHER) ///< Macro version of kType_Is.
267 #define kType_IsValue_(TYPE) kxType_IsValue_(TYPE) ///< Macro version of kType_IsValue.
268 #define kType_IsClass_(TYPE) kxType_IsClass_(TYPE) ///< Macro version of kType_IsClass.
269 #define kType_IsInterface_(TYPE) kxType_IsInterface_(TYPE) ///< Macro version of kType_IsInterface.
270 #define kType_IsAbstract_(TYPE) kxType_IsAbstract_(TYPE) ///< Macro version of kType_IsAbstract.
271 #define kType_IsReference_(TYPE) kxType_IsReference_(TYPE) ///< Macro version of kType_IsReference.
272 #define kType_IsEnum_(TYPE) kxType_IsEnum_(TYPE) ///< Macro version of kType_IsEnum.
273 #define kType_IsBitEnum_(TYPE) kxType_IsBitEnum_(TYPE) ///< Macro version of kType_IsBitEnum.
274 #define kType_IsArrayValue_(TYPE) kxType_IsArrayValue_(TYPE) ///< Macro version of kType_IsArrayValue.
275 #define kType_Implements_(TYPE, IFACE) kxType_Implements_(TYPE, IFACE) ///< Macro version of kType_Implements.
276 #define kType_Extends_(TYPE, BASE) kxType_Extends_(TYPE, BASE) ///< Macro version of kType_Extends.
277 #define kType_Base_(TYPE) kxType_Base_(TYPE) ///< Macro version of kType_Base.
278 #define kType_Size_(TYPE) kxType_Size_(TYPE) ///< Macro version of kType_Size.
279 #define kType_InnerSize_(TYPE) kxType_InnerSize_(TYPE) ///< Macro version of kType_InnerSize.
280 #define kType_VTable_(TYPE) kxType_VTable_(TYPE) ///< Macro version of kType_VTable.
281 #define kType_Static_(TYPE) kxType_Static_(TYPE) ///< Macro version of kType_Static.
282
283 kEndHeader()
284
285 #include <kApi/kType.x.h>
286
287 #endif
kType::kType_IsInterface
kBool kType_IsInterface(kType type)
Determines whether a type represents an interface.
kType::kType_IsEnum
kBool kType_IsEnum(kType type)
Reports whether the type is an enumeration.
k32u
Represents a 32-bit unsigned integer.
kType::kType_StaticInitialized
kBool kType_StaticInitialized(kType type)
Reports whether the type's static data structure has been successfully initialized.
kAssembly
Represents a library of types.
kPointer
Represents a void pointer.
kType::kType_Is
kBool kType_Is(kType type, kType other)
Determines whether a type is equivalent to another type.
kSize
Represents an unsigned integer that can store a pointer address.
kType::kType_IsArrayValue
kBool kType_IsArrayValue(kType type)
Reports whether the type is an 'array-value' type (e.g., kText32)
kType::kType_IsBitEnum
kBool kType_IsBitEnum(kType type)
Reports whether the type is an enumeration bitset.
kType::kType_Extends
kBool kType_Extends(kType type, kType baseType)
Determines whether a type extends another type.
kType::kType_IsClass
kBool kType_IsClass(kType type)
Determines whether a type represents a class.
kType::kType_Assembly
kAssembly kType_Assembly(kType type)
Gets the assembly to which the type belongs.
kChar
Represents a single unit (byte) in a UTF-8 character.
kType::kType_IsAbstract
kBool kType_IsAbstract(kType type)
Determines whether a type represents an abstract class.
kType::kType_InnerSize
kSize kType_InnerSize(kType type)
Gets the internal size of a type.
kType::kType_IsValue
kBool kType_IsValue(kType type)
Determines whether a type represents a value (primitive, struct, enum).
kType::kType_IsReference
kBool kType_IsReference(kType type)
Determines whether a type represents a class or interface.
kTypeVersion
Represents an opaque reference to type version information (used in object serialization).
kType::kType_Base
kType kType_Base(kType type)
Gets the base of a class or interface.
kType::kType_Size
kSize kType_Size(kType type)
Gets the external size of a type.
kApiDef.h
Essential API declarations.
kFunction
void(kCall * kFunction)()
Generic pointer to function.
Definition: kApiDef.h:28
kType::kType_Implements
kBool kType_Implements(kType type, kType interfaceType)
Determines whether a type implements a specific interface.
kType
Represents metadata about a type (class, interface, or value).
kType::kType_IVTable
kFunction * kType_IVTable(kType type, kType interfaceType)
Gets a pointer to the type's virtual method table corresponding to the specified interface type...
kType::kType_Name
const kChar * kType_Name(kType type)
Gets the name of the type.
kType::kType_VTable
kFunction * kType_VTable(kType type)
Gets a pointer to the type's primary virtual method table.
kBool
Represents a boolean value.
kType::kType_Static
void * kType_Static(kType type)
Gets a pointer to the type's static data structure.