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
400 #define kType_IVTableT(kType_type, T) \
401 kCast(T##VTable*, xkType_IVTableT(kType_type, kTypeOf(T)))
402
410 kInlineFx(void*) kType_Static(kType type)
411 {
412 xkTypeObj(type);
413
414 return obj->staticData;
415 }
416
427 kInlineFx(kBool) kType_StaticInitialized(kType type)
428 {
429 kObjR(kType, type);
430
431 return obj->staticInitialized;
432 }
433
444 kInlineFx(kSize) kType_MethodCount(kType type)
445 {
446 xkTypeObj(type);
447
448 return obj->cMethodCount;
449 }
450
459 kInlineFx(const kMethodInfo*) kType_MethodInfoAt(kType type, kSize index)
460 {
461 xkTypeObj(type);
462
463 kAssert(index < obj->cMethodCount);
464
465 return &obj->cMethodInfo[index];
466 }
467
477 kFx(kStatus) kType_FindMethodInfo(kType type, const kChar* name, const kMethodInfo** info);
478
486 kInlineFx(kSize) kType_VMethodCount(kType type)
487 {
488 xkTypeObj(type);
489
490 return obj->vMethodCount;
491 }
492
501 kInlineFx(const kMethodInfo*) kType_VMethodInfoAt(kType type, kSize index)
502 {
503 xkTypeObj(type);
504
505 kAssert(index < obj->vMethodCount);
506
507 return &obj->vMethodInfo[index];
508 }
509
518 kInlineFx(kSize) kType_IMethodCount(kType type, kType interfaceType)
519 {
520 xkTypeObj(type);
521 xkInterfaceInfo* info = xkType_InterfaceInfo(obj, interfaceType);
522
523 return kIsNull(info) ? 0 : info->iMethodCount;
524 }
525
535 kInlineFx(const kMethodInfo*) kType_IMethodInfoAt(kType type, kType interfaceType, kSize index)
536 {
537 xkTypeObj(type);
538 xkInterfaceInfo* info = xkType_InterfaceInfo(obj, interfaceType);
539
540 kAssert(index < info->iMethodCount);
541
542 return kIsNull(info) ? kNULL : &info->iMethodInfo[index];
543 }
544
554 kInlineFx(kSize) kType_FieldCount(kType type)
555 {
556 xkTypeObj(type);
557
558 return obj->fieldCount;
559 }
560
569 kInlineFx(const kFieldInfo*) kType_FieldInfoAt(kType type, kSize index)
570 {
571 xkTypeObj(type);
572
573 kAssert(index < obj->fieldCount);
574
575 return &obj->fieldInfo[index];
576 }
577
587 kInlineFx(kSize) kType_EnumeratorCount(kType type)
588 {
589 xkTypeObj(type);
590
591 return obj->enumeratorCount;
592 }
593
602 kInlineFx(const kEnumeratorInfo*) kType_EnumeratorInfoAt(kType type, kSize index)
603 {
604 xkTypeObj(type);
605
606 kAssert(index < obj->enumeratorCount);
607
608 return &obj->enumeratorInfo[index];
609 }
610
620 kFx(kStatus) kType_FindEnumeratorInfo(kType type, k32s value, const kEnumeratorInfo** info);
621
639 kFx(kStatus) kType_FormatEnumerator(kType type, k32s value, kChar* displayName, kSize capacity);
640
653 kFx(kStatus) kType_ParseEnumerator(kType type, k32s* value, const kChar* displayName);
654
665 kInlineFx(kSize) kType_VersionCount(kType type)
666 {
667 xkTypeObj(type);
668
669 return obj->versionCount;
670 }
671
680 kInlineFx(kTypeVersion) kType_VersionAt(kType type, kSize index)
681 {
682 xkTypeObj(type);
683
684 kAssert(index < obj->versionCount);
685
686 return &obj->versionInfo[index];
687 }
688
697 kInlineFx(const kChar*) kType_VersionGuid(kType type, kPointer version)
698 {
699 return kCast(kTypeVersionInfo*, version)->guid;
700 }
701
710 kInlineFx(kFunction) kType_VersionSerializeFx(kType type, kTypeVersion version)
711 {
712 return kCast(kTypeVersionInfo*, version)->serialize;
713 }
714
723 kInlineFx(kFunction) kType_VersionDeserializeFx(kType type, kTypeVersion version)
724 {
725 return kCast(kTypeVersionInfo*, version)->deserialize;
726 }
727
736 kInlineFx(const kChar*) kType_VersionFormat(kType type, kTypeVersion version)
737 {
738 return kCast(kTypeVersionInfo*, version)->format;
739 }
740
749 kInlineFx(kVersion) kType_VersionFormatVersion(kType type, kTypeVersion version)
750 {
751 return kCast(kTypeVersionInfo*, version)->formatVersion;
752 }
753
754 #endif
kType::kType_VersionDeserializeFx
kFunction kType_VersionDeserializeFx(kType type, kTypeVersion version)
Gets the deserialization method for the specified type version.
Definition: kType.h:723
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:736
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:697
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:1963
kType::kType_Static
void * kType_Static(kType type)
Gets a pointer to the type's static data structure.
Definition: kType.h:410
kType::kType_FieldInfoAt
const kFieldInfo * kType_FieldInfoAt(kType type, kSize index)
Gets metadata for the field at the specified index.
Definition: kType.h:569
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:1967
kType::kType_VersionFormatVersion
kVersion kType_VersionFormatVersion(kType type, kTypeVersion version)
Gets the serialization format version associated with the type version.
Definition: kType.h:749
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:602
kType::kType_EnumeratorCount
kSize kType_EnumeratorCount(kType type)
Reports count of registered enumerators for the given enumeration type.
Definition: kType.h:587
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:427
kFieldInfo
Represents type field information.
Definition: kApiDef.h:1997
kType::kType_MethodCount
kSize kType_MethodCount(kType type)
Reports count of non-virtual methods.
Definition: kType.h:444
kTypeFlags::kTYPE_FLAGS_ENUM
#define kTYPE_FLAGS_ENUM
Type is an enumeration.
Definition: kApiDef.h:1966
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:486
kEnumeratorInfo
Represents enumerator information.
Definition: kApiDef.h:2010
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:1965
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:1985
kType::kType_FieldCount
kSize kType_FieldCount(kType type)
Reports count of registered fields for the given type.
Definition: kType.h:554
kType::kType_VersionSerializeFx
kFunction kType_VersionSerializeFx(kType type, kTypeVersion version)
Gets the serialization method for the specified type version.
Definition: kType.h:710
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:2904
kType::kType_VersionCount
kSize kType_VersionCount(kType type)
Reports count of registered type versions.
Definition: kType.h:665
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:518
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:459
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:535
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:1968
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:1964
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:1969
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:680
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:1799
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:501