Zen API

- Home
- Topics
- Types
- Files

All Classes Files Functions Variables Typedefs Friends Macros Modules Pages
kType.h
Go to the documentation of this file.
1
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 #include <kApi/kType.x.h>
16
50 //typedef kObject kType; --forward-declared in kApiDef.x.h
51
59 kInlineFx(kAssembly) kType_Assembly(kType type)
60 {
61 xkTypeObj(type);
62
63 return obj->assembly;
64 }
72 kInlineFx(const kChar*) kType_Name(kType type)
73 {
74 xkTypeObj(type);
75
76 return obj->name;
77 }
78
89 kInlineFx(kBool) kType_Is(kType type, kType other)
90 {
91 return (type == other) ||
92 kType_Extends(type, other) ||
93 kType_Implements(type, other);
94 }
95
103 kInlineFx(kBool) kType_IsValue(kType type)
104 {
105 xkTypeObj(type);
106
107 return (obj->flags & kTYPE_FLAGS_VALUE) != 0;
108 }
109
117 kInlineFx(kBool) kType_IsClass(kType type)
118 {
119 xkTypeObj(type);
120
121 return (obj->flags & kTYPE_FLAGS_CLASS) != 0;
122 }
123
131 kInlineFx(kBool) kType_IsInterface(kType type)
132 {
133 xkTypeObj(type);
134
135 return (obj->flags & kTYPE_FLAGS_INTERFACE) != 0;
136 }
137
145 kInlineFx(kBool) kType_IsReference(kType type)
146 {
147 xkTypeObj(type);
148
149 return (obj->flags & (kTYPE_FLAGS_INTERFACE | kTYPE_FLAGS_CLASS)) != 0;
150 }
151
159 kInlineFx(kBool) kType_IsAbstract(kType type)
160 {
161 xkTypeObj(type);
162
163 return (obj->flags & kTYPE_FLAGS_ABSTRACT) != 0;
164 }
165
172 kInlineFx(kBool) kType_IsEnum(kType type)
173 {
174 xkTypeObj(type);
175
176 return (obj->flags & kTYPE_FLAGS_ENUM) != 0;
177 }
178
185 kInlineFx(kBool) kType_IsArrayValue(kType type)
186 {
187 xkTypeObj(type);
188
189 return (obj->flags & kTYPE_FLAGS_ARRAY_VALUE) != 0;
190 }
191
198 kInlineFx(kBool) kType_IsPrimitive(kType type)
199 {
200 xkTypeObj(type);
201
202 return (obj->flags & kTYPE_FLAGS_PRIMITIVE) != 0;
203 }
204
211 kInlineFx(kBool) kType_IsPacked(kType type)
212 {
213 xkTypeObj(type);
214
215 return (obj->flags & xkTYPE_FLAGS_PACKED) != 0;
216 }
217
226 kInlineFx(kBool) kType_Implements(kType type, kType interfaceType)
227 {
228 return kType_IVTable(type, interfaceType) != kNULL;
229 }
230
239 kInlineFx(kBool) kType_Extends(kType type, kType baseType)
240 {
241 xkTypeObj(type);
242
243 return obj->bases[0] == baseType ||
244 obj->bases[1] == baseType ||
245 obj->bases[2] == baseType ||
246 obj->bases[3] == baseType;
247 }
248
256 kInlineFx(kType) kType_Base(kType type)
257 {
258 xkTypeObj(type);
259
260 return obj->bases[0];
261 }
262
270 kInlineFx(kSize) kType_InterfaceCount(kType type)
271 {
272 xkTypeObj(type);
273
274 return obj->interfaceCount;
275 }
276
285 kInlineFx(kType) kType_InterfaceAt(kType type, kSize index)
286 {
287 xkTypeObj(type);
288
289 kAssert(index < obj->interfaceCount);
290
291 return obj->interfaces[index].type;
292 }
293
304 kInlineFx(kSize) kType_Size(kType type)
305 {
306 xkTypeObj(type);
307
308 return obj->size;
309 }
310
321 kInlineFx(kSize) kType_InnerSize(kType type)
322 {
323 xkTypeObj(type);
324
325 return obj->innerSize;
326 }
327
335 kInlineFx(kSize) kType_StaticSize(kType type)
336 {
337 xkTypeObj(type);
338
339 return obj->staticSize;
340 }
341
349 kInlineFx(kFunction*) kType_VTable(kType type)
350 {
351 xkTypeObj(type);
352
353 return obj->vTable;
354 }
355
367 #define kType_VTableT(kType_type, T) \
368 kCast(T##VTable*, xkType_VTableT(kType_type, kTypeOf(T)))
369
378 kInlineFx(kFunction*) kType_IVTable(kType type, kType interfaceType)
379 {
380 xkTypeObj(type);
381
382 if (obj->interfaces[0].type == interfaceType) return obj->interfaces[0].iTable;
383 else if (obj->interfaces[1].type == interfaceType) return obj->interfaces[1].iTable;
384 else if (obj->interfaces[2].type == interfaceType) return obj->interfaces[2].iTable;
385 else if (obj->interfaces[3].type == interfaceType) return obj->interfaces[3].iTable;
386 else return kNULL;
387 }
388
396 kInlineFx(void*) kType_Static(kType type)
397 {
398 xkTypeObj(type);
399
400 return obj->staticData;
401 }
402
413 kInlineFx(kBool) kType_StaticInitialized(kType type)
414 {
415 kObjR(kType, type);
416
417 return !kIsNull(obj->staticInitialized) && *obj->staticInitialized;
418 }
419
430 kInlineFx(kSize) kType_MethodCount(kType type)
431 {
432 xkTypeObj(type);
433
434 return obj->cMethodCount;
435 }
436
445 kInlineFx(const kMethodInfo*) kType_MethodInfoAt(kType type, kSize index)
446 {
447 xkTypeObj(type);
448
449 kAssert(index < obj->cMethodCount);
450
451 return &obj->cMethodInfo[index];
452 }
453
463 kFx(kStatus) kType_FindMethodInfo(kType type, const kChar* name, const kMethodInfo** info);
464
472 kInlineFx(kSize) kType_VMethodCount(kType type)
473 {
474 xkTypeObj(type);
475
476 return obj->vMethodCount;
477 }
478
487 kInlineFx(const kMethodInfo*) kType_VMethodInfoAt(kType type, kSize index)
488 {
489 xkTypeObj(type);
490
491 kAssert(index < obj->vMethodCount);
492
493 return &obj->vMethodInfo[index];
494 }
495
504 kInlineFx(kSize) kType_IMethodCount(kType type, kType interfaceType)
505 {
506 xkTypeObj(type);
507 xkInterfaceInfo* info = xkType_InterfaceInfo(obj, interfaceType);
508
509 return kIsNull(info) ? 0 : info->iMethodCount;
510 }
511
521 kInlineFx(const kMethodInfo*) kType_IMethodInfoAt(kType type, kType interfaceType, kSize index)
522 {
523 xkTypeObj(type);
524 xkInterfaceInfo* info = xkType_InterfaceInfo(obj, interfaceType);
525
526 kAssert(index < info->iMethodCount);
527
528 return kIsNull(info) ? kNULL : &info->iMethodInfo[index];
529 }
530
540 kInlineFx(kSize) kType_FieldCount(kType type)
541 {
542 xkTypeObj(type);
543
544 return obj->fieldCount;
545 }
546
555 kInlineFx(const kFieldInfo*) kType_FieldInfoAt(kType type, kSize index)
556 {
557 xkTypeObj(type);
558
559 kAssert(index < obj->fieldCount);
560
561 return &obj->fieldInfo[index];
562 }
563
573 kInlineFx(kSize) kType_EnumeratorCount(kType type)
574 {
575 xkTypeObj(type);
576
577 return obj->enumeratorCount;
578 }
579
588 kInlineFx(const kEnumeratorInfo*) kType_EnumeratorInfoAt(kType type, kSize index)
589 {
590 xkTypeObj(type);
591
592 kAssert(index < obj->enumeratorCount);
593
594 return &obj->enumeratorInfo[index];
595 }
596
606 kFx(kStatus) kType_FindEnumeratorInfo(kType type, k32s value, const kEnumeratorInfo** info);
607
625 kFx(kStatus) kType_FormatEnumerator(kType type, k32s value, kChar* displayName, kSize capacity);
626
639 kFx(kStatus) kType_ParseEnumerator(kType type, k32s* value, const kChar* displayName);
640
651 kInlineFx(kSize) kType_VersionCount(kType type)
652 {
653 xkTypeObj(type);
654
655 return obj->versionCount;
656 }
657
666 kInlineFx(kTypeVersion) kType_VersionAt(kType type, kSize index)
667 {
668 xkTypeObj(type);
669
670 kAssert(index < obj->versionCount);
671
672 return &obj->versionInfo[index];
673 }
674
683 kInlineFx(const kChar*) kType_VersionGuid(kType type, kPointer version)
684 {
685 return kCast(kTypeVersionInfo*, version)->guid;
686 }
687
696 kInlineFx(kFunction) kType_VersionSerializeFx(kType type, kTypeVersion version)
697 {
698 return kCast(kTypeVersionInfo*, version)->serialize;
699 }
700
709 kInlineFx(kFunction) kType_VersionDeserializeFx(kType type, kTypeVersion version)
710 {
711 return kCast(kTypeVersionInfo*, version)->deserialize;
712 }
713
722 kInlineFx(const kChar*) kType_VersionFormat(kType type, kTypeVersion version)
723 {
724 return kCast(kTypeVersionInfo*, version)->format;
725 }
726
735 kInlineFx(kVersion) kType_VersionFormatVersion(kType type, kTypeVersion version)
736 {
737 return kCast(kTypeVersionInfo*, version)->formatVersion;
738 }
739
740 #endif
kType::kType_VersionDeserializeFx
kFunction kType_VersionDeserializeFx(kType type, kTypeVersion version)
Gets the deserialization method for the specified type version.
Definition: kType.h:709
kType::kType_IsValue
kBool kType_IsValue(kType type)
Determines whether a type represents a value (primitive, struct, enum).
Definition: kType.h:103
kType::kType_Extends
kBool kType_Extends(kType type, kType baseType)
Determines whether a type extends another type.
Definition: kType.h:239
kType::kType_Implements
kBool kType_Implements(kType type, kType interfaceType)
Determines whether a type implements a specific interface.
Definition: kType.h:226
kType::kType_VersionFormat
const kChar * kType_VersionFormat(kType type, kTypeVersion version)
Gets the serialization format name associated with the type version.
Definition: kType.h:722
kType::kType_FindEnumeratorInfo
kStatus kType_FindEnumeratorInfo(kType type, k32s value, const kEnumeratorInfo **info)
Finds enumerator metadata for the enumerator with the specified value.
kType::kType_VersionGuid
const kChar * kType_VersionGuid(kType type, kPointer version)
Gets the GUID associated with the specified type version.
Definition: kType.h:683
kType::kType_IsClass
kBool kType_IsClass(kType type)
Determines whether a type represents a class.
Definition: kType.h:117
kType::kType_IsArrayValue
kBool kType_IsArrayValue(kType type)
Reports whether the type is an 'array-value' type (e.g., kText32)
Definition: kType.h:185
kAssembly
Represents a library of types.
kPointer
Represents a void pointer.
kPointer::kIsNull
#define kIsNull(POINTER)
Tests for equality with null pointer.
Definition: kApiDef.h:339
kTypeFlags::kTYPE_FLAGS_CLASS
#define kTYPE_FLAGS_CLASS
Type is a class.
Definition: kApiDef.h:1931
kType::kType_Static
void * kType_Static(kType type)
Gets a pointer to the type's static data structure.
Definition: kType.h:396
kType::kType_FieldInfoAt
const kFieldInfo * kType_FieldInfoAt(kType type, kSize index)
Gets metadata for the field at the specified index.
Definition: kType.h:555
kSize
Represents an unsigned integer that can store a pointer address.
kTypeFlags::kTYPE_FLAGS_ABSTRACT
#define kTYPE_FLAGS_ABSTRACT
Type is an abstract class.
Definition: kApiDef.h:1935
kType::kType_VersionFormatVersion
kVersion kType_VersionFormatVersion(kType type, kTypeVersion version)
Gets the serialization format version associated with the type version.
Definition: kType.h:735
kType::kType_IsInterface
kBool kType_IsInterface(kType type)
Determines whether a type represents an interface.
Definition: kType.h:131
kType::kType_EnumeratorInfoAt
const kEnumeratorInfo * kType_EnumeratorInfoAt(kType type, kSize index)
Gets metadata for the enumerator at the specified index.
Definition: kType.h:588
kType::kType_EnumeratorCount
kSize kType_EnumeratorCount(kType type)
Reports count of registered enumerators for the given enumeration type.
Definition: kType.h:573
kType::kType_IsPacked
kBool kType_IsPacked(kType type)
Reports whether the fields of a value type are tightly packed (free from structure padding)...
Definition: kType.h:211
kType::kType_StaticInitialized
kBool kType_StaticInitialized(kType type)
Reports whether the type's static data structure has been successfully initialized.
Definition: kType.h:413
kFieldInfo
Represents type field information.
Definition: kApiDef.h:1965
kType::kType_MethodCount
kSize kType_MethodCount(kType type)
Reports count of non-virtual methods.
Definition: kType.h:430
kTypeFlags::kTYPE_FLAGS_ENUM
#define kTYPE_FLAGS_ENUM
Type is an enumeration.
Definition: kApiDef.h:1934
kInlineFx
#define kInlineFx(TYPE)
Inline method declaration helper.
Definition: kApiDef.h:26
kType::kType_InterfaceAt
kType kType_InterfaceAt(kType type, kSize index)
Gets the implemented interface at the specified index.
Definition: kType.h:285
kType::kType_VMethodCount
kSize kType_VMethodCount(kType type)
Reports count of virtual methods.
Definition: kType.h:472
kEnumeratorInfo
Represents enumerator information.
Definition: kApiDef.h:1978
kChar
Represents a single unit (byte) in a UTF-8 character.
kType::kType_FormatEnumerator
kStatus kType_FormatEnumerator(kType type, k32s value, kChar *displayName, kSize capacity)
Formats an enumerator value to a text buffer using the enumerator display name.
kType::kType_VTable
kFunction * kType_VTable(kType type)
Gets a pointer to the type's primary virtual method table.
Definition: kType.h:349
kType::kType_Base
kType kType_Base(kType type)
Gets the base of a class or interface.
Definition: kType.h:256
kTypeFlags::kTYPE_FLAGS_VALUE
#define kTYPE_FLAGS_VALUE
Type is a value.
Definition: kApiDef.h:1933
kType::kType_Name
const kChar * kType_Name(kType type)
Gets the name of the type.
Definition: kType.h:72
kType::kType_FindMethodInfo
kStatus kType_FindMethodInfo(kType type, const kChar *name, const kMethodInfo **info)
Finds metadata for the non-virtual method with the specified name.
kType::kType_IsPrimitive
kBool kType_IsPrimitive(kType type)
Reports whether the type is a primitive value (single-valued; lacks fields).
Definition: kType.h:198
kMethodInfo
Represents type method information.
Definition: kApiDef.h:1953
kType::kType_FieldCount
kSize kType_FieldCount(kType type)
Reports count of registered fields for the given type.
Definition: kType.h:540
kType::kType_VersionSerializeFx
kFunction kType_VersionSerializeFx(kType type, kTypeVersion version)
Gets the serialization method for the specified type version.
Definition: kType.h:696
kType::kTypeVersion
kPointer kTypeVersion
Represents an opaque reference to type version information (used in object serialization).
kObjR
#define kObjR(TypeName_T, T_object)
Declares a local "obj" (this-pointer) variable and initializes it from an object handle, without type-checking.
Definition: kApiDef.h:2870
kType::kType_VersionCount
kSize kType_VersionCount(kType type)
Reports count of registered type versions.
Definition: kType.h:651
kApiDef.h
Core Zen type declarations.
kType::kType_IsReference
kBool kType_IsReference(kType type)
Determines whether a type represents a class or interface.
Definition: kType.h:145
k32s
Represents a 32-bit signed integer.
kType::kType_Size
kSize kType_Size(kType type)
Gets the external size of a type.
Definition: kType.h:304
kType::kType_IMethodCount
kSize kType_IMethodCount(kType type, kType interfaceType)
Reports count of interface methods for the given interface.
Definition: kType.h:504
kFunction
void(kCall * kFunction)()
Generic pointer to function.
Definition: kApiDef.h:28
kType::kType_InterfaceCount
kSize kType_InterfaceCount(kType type)
Reports count of implemented interfaces.
Definition: kType.h:270
kType::kType_IsEnum
kBool kType_IsEnum(kType type)
Reports whether the type is an enumeration.
Definition: kType.h:172
kType::kType_IsAbstract
kBool kType_IsAbstract(kType type)
Determines whether a type represents an abstract class.
Definition: kType.h:159
kType::kType_MethodInfoAt
const kMethodInfo * kType_MethodInfoAt(kType type, kSize index)
Gets metadata for the non-virtual method at the specified index.
Definition: kType.h:445
kType::kType_Assembly
kAssembly kType_Assembly(kType type)
Gets the assembly to which the type belongs.
Definition: kType.h:59
kType::kType_IMethodInfoAt
const kMethodInfo * kType_IMethodInfoAt(kType type, kType interfaceType, kSize index)
Gets metadata for the interface method at the specified index.
Definition: kType.h:521
kType
Represents metadata about a type (class, interface, or value).
kTypeFlags::kTYPE_FLAGS_ARRAY_VALUE
#define kTYPE_FLAGS_ARRAY_VALUE
Type is an array-based value (e.g. kText32).
Definition: kApiDef.h:1936
kType::kType_ParseEnumerator
kStatus kType_ParseEnumerator(kType type, k32s *value, const kChar *displayName)
Parses an enumerator value from a text buffer using the enumerator display name.
kType::kType_InnerSize
kSize kType_InnerSize(kType type)
Gets the internal size of a type.
Definition: kType.h:321
kAssert
#define kAssert(EXPRESSION)
Aborts execution if EXPRESSION is kFALSE.
Definition: kApiDef.h:749
kTypeFlags::kTYPE_FLAGS_INTERFACE
#define kTYPE_FLAGS_INTERFACE
Type is an interface.
Definition: kApiDef.h:1932
kVersion
Represents a version number.
kStatus
Represents an error code.
kTypeFlags::kTYPE_FLAGS_PRIMITIVE
#define kTYPE_FLAGS_PRIMITIVE
Type is a primitive value (i.e., has no fields).
Definition: kApiDef.h:1937
kNULL
#define kNULL
Null pointer.
Definition: kApiDef.h:267
kType::kType_VersionAt
kTypeVersion kType_VersionAt(kType type, kSize index)
Gets the type version handle at the specified index.
Definition: kType.h:666
kType::kType_Is
kBool kType_Is(kType type, kType other)
Determines whether a type is equivalent to another type.
Definition: kType.h:89
kType::kType_StaticSize
kSize kType_StaticSize(kType type)
Gets the size of a type's static data.
Definition: kType.h:335
kBool
Represents a boolean value.
kCast
#define kCast(TYPE, ITEM)
Casts the ITEM argument to the specified TYPE.
Definition: kApiDef.h:1767
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...
Definition: kType.h:378
kType::kType_VMethodInfoAt
const kMethodInfo * kType_VMethodInfoAt(kType type, kSize index)
Gets metadata for the virtual method at the specified index.
Definition: kType.h:487