10 #ifndef K_API_API_DEF_H
11 #define K_API_API_DEF_H
16 #define kDlCall xkDlCall
19 # define kFx(TYPE) kExportFx(TYPE)
20 # define kDx(TYPE) kExportDx(TYPE)
22 # define kFx(TYPE) kImportFx(TYPE)
23 # define kDx(TYPE) kImportDx(TYPE)
26 #define kInlineFx(TYPE) xkInlineFx(TYPE)
42 #define k8U_MAX (255U)
43 #define k8U_NULL (k8U_MAX)
58 #define k16U_MAX (65535U)
59 #define k16U_NULL (k16U_MAX)
74 #define k32U_MAX (4294967295U)
75 #define k32U_NULL (k32U_MAX)
89 #define k64U(CONST) xk64U(CONST)
90 #define k64U_MIN k64U(0)
91 #define k64U_MAX k64U(18446744073709551615)
92 #define k64U_NULL (k64U_MAX)
95 #define kINFINITE k64U_MAX
108 #define k8S_MAX (127)
109 #define k8S_MIN (-k8S_MAX -1)
110 #define k8S_NULL (k8S_MIN)
124 #define k16S_MAX (32767)
125 #define k16S_MIN (-k16S_MAX -1)
126 #define k16S_NULL (k16S_MIN)
140 #define k32S_MAX (2147483647)
141 #define k32S_MIN (-k32S_MAX -1)
142 #define k32S_NULL (k32S_MIN)
156 #define k64S(CONST) xk64S(CONST)
157 #define k64S_MAX k64S(9223372036854775807)
158 #define k64S_MIN (-k64S_MAX -1)
159 #define k64S_NULL (k64S_MIN)
173 #define k32F_MIN (1.175494351e-38F)
174 #define k32F_MAX (3.402823466e+38F)
175 #define k32F_NULL (-k32F_MAX)
176 #define k32F_DIGITS (9)
190 #define k64F_MIN (2.2250738585072014e-308)
191 #define k64F_MAX (1.7976931348623157e+308)
192 #define k64F_NULL (-k64F_MAX)
193 #define k64F_DIGITS (17)
204 kFx(k32s) k64f_IsNanOrInf(k64f value);
214 typedef xkByte
kByte;
224 typedef xkSize
kSize;
227 #define kSIZE_MAX xkSIZE_MAX
228 #define kSIZE_NULL kSIZE_MAX
241 kInlineFx(kSize) kSize_Align(kSize value, kSize to)
243 return ((value >> to) + !!(value & ((1 << to) - 1))) << to;
255 #define kSSIZE_MIN xkSSIZE_MIN
256 #define kSSIZE_MAX xkSSIZE_MAX
257 #define kSSIZE_NULL kSSIZE_MIN
267 typedef void* kPointer;
282 return (
kByte*)pointer + offset;
320 #define kPointer_ReadAs(POINTER, TYPE) \
331 #define kPointer_WriteAs(POINTER, VALUE, TYPE) \
332 (*(TYPE*)(POINTER) = (TYPE)(VALUE))
341 #define kIsNull(POINTER) \
367 typedef xkChar kChar;
378 return (ch >=
'A' && ch <=
'Z') ? (ch -
'A' +
'a') : ch;
390 return (ch >=
'a' && ch <=
'z') ? (ch -
'a' +
'A') : ch;
414 return ((ch >=
'a') && (ch <=
'z') ) || ((ch >=
'A') && (ch <=
'Z'));
426 return ch >=
'0' && ch <=
'9';
490 #define kERROR_STATE (-1000)
491 #define kERROR_NOT_FOUND (-999)
492 #define kERROR_COMMAND (-998)
493 #define kERROR_PARAMETER (-997)
494 #define kERROR_UNIMPLEMENTED (-996)
495 #define kERROR_MEMORY (-994)
496 #define kERROR_TIMEOUT (-993)
497 #define kERROR_INCOMPLETE (-992)
498 #define kERROR_STREAM (-991)
499 #define kERROR_CLOSED (-990)
500 #define kERROR_VERSION (-989)
501 #define kERROR_ABORT (-988)
502 #define kERROR_ALREADY_EXISTS (-987)
503 #define kERROR_NETWORK (-986)
504 #define kERROR_HEAP (-985)
505 #define kERROR_FORMAT (-984)
506 #define kERROR_READ_ONLY (-983)
507 #define kERROR_WRITE_ONLY (-982)
508 #define kERROR_BUSY (-981)
509 #define kERROR_CONFLICT (-980)
510 #define kERROR_OS (-979)
511 #define kERROR_DEVICE (-978)
512 #define kERROR_FULL (-977)
513 #define kERROR_IN_PROGRESS (-976)
527 kFx(const kChar*) kStatus_Name(kStatus status);
538 return status !=
kOK;
550 return status ==
kOK;
561 #define kCheck(EXPRESSION) \
573 #define kCheckTrue(EXPRESSION, STATUS) \
574 xkCheckTrue(EXPRESSION, STATUS)
584 #define kCheckArgs(EXPRESSION) \
585 xkCheckArgs(EXPRESSION)
595 #define kCheckState(EXPRESSION) \
596 xkCheckState(EXPRESSION)
612 #define kThrow(EXPRESSION) \
624 #define kTest(EXPRESSION) \
637 #define kTestTrue(EXPRESSION, STATUS) \
638 xkTestTrue(EXPRESSION, STATUS)
649 #define kTestArgs(EXPRESSION) \
650 xkTestArgs(EXPRESSION)
661 #define kTestState(EXPRESSION) \
662 xkTestState(EXPRESSION)
670 #define kCatch(STATUS_POINTER) \
671 xkCatch(STATUS_POINTER)
681 #define kEndCatch(STATUS) \
700 #define kEndFinally() \
709 #define kCatchEx(STATUS_POINTER) \
710 xkCatchEx(STATUS_POINTER)
722 #define kEndCatchEx(STATUS) \
741 #define kEndFinallyEx() \
751 #define kAssert(EXPRESSION) \
764 #define kAssertType(OBJECT, SYMBOL) \
765 xkAssertType(OBJECT, SYMBOL)
774 #define kTrace(TAG) \
787 #define kVERSION_NULL (k32U_NULL) // kVersion invalid value.
801 return (major & 0xFF) << 24 |
802 (minor & 0xFF) << 16 |
803 (release & 0xFF) << 8 |
817 #define kVersion_Stringify_(MAJOR, MINOR, RELEASE, BUILD) \
818 xkStringize(MAJOR) "." xkStringize(MINOR) "." xkStringize(RELEASE) "." xkStringize(BUILD)
854 return (
k32s)version1 - (
k32s)version2;
866 return (version >> 24) & 0xFF;
878 return (version >> 16) & 0xFF;
890 return (version >> 8) & 0xFF;
902 return (version) & 0xFF;
914 #define kENDIANNESS_LITTLE (1)
915 #define kENDIANNESS_BIG (2)
923 kInlineFx(kEndianness) kEndianness_Host()
1342 #define kPoint_Init_(POINT, X, Y) xkPoint_Init_(POINT, X, Y)
1414 #define kPoint3d_Init_(POINT, X, Y, Z) xkPoint3d_Init_(POINT, X, Y, Z)
1443 #define kPoint4d_Init_(POINT, X, Y, Z, W) xkPoint4d_Init_(POINT, X, Y, Z, W)
1520 #define kRect_Init_(RECT, X, Y, W, H) \
1521 xkRect_Init_(RECT, X, Y, W, H)
1552 #define kRect3d_Init_(RECT, X, Y, Z, W, H, D) \
1553 xkRect3d_Init_(RECT, X, Y, Z, W, H, D)
1601 #define kRotatedRect_Init_(RECT, XC, YC, W, H, A) \
1602 xkRotatedRect_Init_(RECT, XC, YC, W, H, A)
1615 #define kPIXEL_FORMAT_NULL (0)
1616 #define kPIXEL_FORMAT_8BPP_GREYSCALE (1)
1617 #define kPIXEL_FORMAT_8BPP_CFA (2)
1618 #define kPIXEL_FORMAT_8BPC_BGRX (3)
1619 #define kPIXEL_FORMAT_1BPP_GREYSCALE (4)
1620 #define kPIXEL_FORMAT_16BPP_GREYSCALE (5)
1634 #define kCFA_NONE (0)
1635 #define kCFA_BAYER_BGGR (1)
1636 #define kCFA_BAYER_GBRG (2)
1637 #define kCFA_BAYER_RGGB (3)
1638 #define kCFA_BAYER_GRBG (4)
1666 #define kRgb_Init_(RGB, R, G, B) \
1667 xkRgb_Init_(RGB, R, G, B)
1695 #define kArgb_Init_(ARGB, A, R, G, B) \
1696 xkArgb_Init_(ARGB, A, R, G, B)
1718 #define kMEMORY_ALIGNMENT_8 (3)
1719 #define kMEMORY_ALIGNMENT_16 (4)
1720 #define kMEMORY_ALIGNMENT_32 (5)
1721 #define kMEMORY_ALIGNMENT_64 (6)
1722 #define kMEMORY_ALIGNMENT_128 (7)
1723 #define kMEMORY_ALIGNMENT_256 (8)
1724 #define kMEMORY_ALIGNMENT_512 (9)
1725 #define kMEMORY_ALIGNMENT_1024 (10)
1726 #define kMEMORY_ALIGNMENT_2048 (11)
1727 #define kMEMORY_ALIGNMENT_4096 (12)
1736 kInlineFx(kSize) kMemoryAlignment_Size(kMemoryAlignment alignment)
1774 #define kCOMPARISON_EQ (0)
1775 #define kCOMPARISON_NEQ (1)
1776 #define kCOMPARISON_LT (2)
1777 #define kCOMPARISON_LTE (3)
1778 #define kCOMPARISON_GT (4)
1779 #define kCOMPARISON_GTE (5)
1829 #define kFILE_MODE_READ (0x1)
1830 #define kFILE_MODE_WRITE (0x2)
1831 #define kFILE_MODE_UPDATE (0x4)
1840 typedef k32s kSeekOrigin;
1843 #define kSEEK_ORIGIN_BEGIN (0)
1844 #define kSEEK_ORIGIN_CURRENT (1)
1845 #define kSEEK_ORIGIN_END (2)
1854 typedef k32s kCompressionType;
1857 #define kCOMPRESSION_TYPE_NULL (0)
1858 #define kCOMPRESSION_TYPE_ZSTD (1)
1871 #define kCOMPRESSION_PRESET_MIN (-1)
1872 #define kCOMPRESSION_PRESET_FAST (-2)
1873 #define kCOMPRESSION_PRESET_DEFAULT (-3)
1874 #define kCOMPRESSION_PRESET_DENSE (-4)
1875 #define kCOMPRESSION_PRESET_MAX (-5)
1887 typedef k64u kLogOption;
1890 #define kLOG_OPTION_WARNING (0x1)
1891 #define kLOG_OPTION_ERROR (0x2)
1892 #define kLOG_OPTION_PLATFORM (0x10)
1903 #define kCountOf(CARRAY) \
1904 (sizeof(CARRAY)/sizeof(CARRAY[0]))
1915 #define kCast(TYPE, ITEM) \
1918 #if (K_CPP_VERSION >= K_CPP_VERSION_2011)
1929 template <
typename T>
1930 static kInline
typename std::enable_if<std::is_unsigned<T>::value, T>::type
kAbs(
const T& v)
1944 template <
typename T>
1945 static kInline
typename std::enable_if<!std::is_unsigned<T>::value, T>::type
kAbs(
const T& v)
1947 return (v >= T()) ? v : -v;
1959 template <
typename T>
1960 static kInline
typename std::enable_if<std::is_unsigned<T>::value, T>::type
kSign(
const T& v)
1974 template <
typename T>
1975 static kInline
typename std::enable_if<!std::is_unsigned<T>::value, T>::type
kSign(
const T& v)
1977 return (v > T()) - (v < T());
1990 template <
typename T>
1993 return (a < b) ? a : b;
2006 template <
typename T>
2009 return (a > b) ? a : b;
2023 template <
typename T>
2039 template <
typename T>
2040 static kInline
typename std::enable_if<std::is_unsigned<T>::value, T>::type
kDivideFloor(
const T& a,
const T& b)
2055 template <
typename T>
2056 static kInline
typename std::enable_if<!std::is_unsigned<T>::value, T>::type
kDivideFloor(
const T& a,
const T& b)
2058 return ((
kSign(a) *
kSign(b)) >= T()) ? a / b : ((a / b) - ((a % b) != T()));
2071 template <
typename T>
2072 static kInline
typename std::enable_if<std::is_unsigned<T>::value, T>::type
kDivideCeil(
const T& a,
const T& b)
2074 return (a / b) + ((a % b) != T());
2087 template <
typename T>
2088 static kInline
typename std::enable_if<!std::is_unsigned<T>::value, T>::type
kDivideCeil(
const T& a,
const T& b)
2090 return ((
kSign(a) *
kSign(b)) <= T()) ? a / b : ((a / b) + ((a % b) != T()));
2103 template <
typename T>
2119 template <
typename T>
2122 return kDivideCeil(value, granularity) * granularity;
2141 template <
typename T>
2144 typedef typename std::make_unsigned<T>::type U;
2145 U relativeValue = (value >= min) ? (U) (value - min) : U();
2146 U relativeMax = (max >= min) ? (U) (max - min) : U();
2147 U quantizedRelativeMax = kQuantizeFloor<U>(relativeMax, granularity);
2148 U limitedRelativeValue = kMin<U>(relativeValue, quantizedRelativeMax);
2150 return (T) kQuantizeFloor<U>(limitedRelativeValue, granularity) + min;
2169 template <
typename T>
2172 typedef typename std::make_unsigned<T>::type U;
2173 U relativeValue = (value >= min) ? (U) (value - min) : U();
2174 U relativeMax = (max >= min) ? (U) (max - min) : U();
2175 U quantizedRelativeMax = kQuantizeFloor<U>(relativeMax, granularity);
2176 U limitedRelativeValue = kMin<U>(relativeValue, quantizedRelativeMax);
2178 return (T) kQuantizeCeil<U>(limitedRelativeValue, granularity) + min;
2188 #define kZero(VALUE) \
2189 memset(&VALUE, 0, sizeof(VALUE))
2207 memcpy(dest, src, size);
2225 memset(dest, 0, size);
2236 #define kALLOC_TRAIT_FOREIGN (0x00000001)
2237 #define kALLOC_TRAIT_SERIAL (0x00000002)
2238 #define kALLOC_TRAIT_NON_ATOMIC (0x00000004)
2239 #define kALLOC_TRAIT_CONTEXT (0x00000008)
2240 #define kALLOC_TRAIT_CUDA_PINNED (0x00010000)
2241 #define kALLOC_TRAIT_CUDA_MANAGED (0x00020000)
2242 #define kALLOC_TRAIT_CUDA_DEVICE (0x01000000)
2252 kInlineFx(kBool) kAllocTrait_IsForeign(kAllocTrait traits)
2370 #define kTHREAD_PRIORITY_CLASS_LOW (-1)
2371 #define kTHREAD_PRIORITY_CLASS_NORMAL (0)
2372 #define kTHREAD_PRIORITY_CLASS_HIGH (1)
2380 typedef kObject
kType;
2384 #define kTypeName kText64
2393 typedef k32u kTypeFlags;
2396 #define kTYPE_FLAGS_CLASS (0x01)
2397 #define kTYPE_FLAGS_INTERFACE (0x02)
2398 #define kTYPE_FLAGS_VALUE (0x04)
2399 #define kTYPE_FLAGS_ENUM (0x08)
2400 #define kTYPE_FLAGS_ABSTRACT (0x20)
2401 #define kTYPE_FLAGS_ARRAY_VALUE (0x40)
2402 #define kTYPE_FLAGS_PRIMITIVE (0x80)
2411 typedef kPointer kTypeVersion;
2478 #define kTypeOf(SYMBOL) \
2506 #define kAssemblyOf(SYMBOL) \
2507 xkAssemblyOf(SYMBOL)
2517 #define kStaticOf(SYMBOL) \
2527 #define kDeprecate(SYMBOL) \
2528 xkDeprecate(#SYMBOL)
2538 #define kWarn(MESSAGE) \
2557 #define kDeclareAssembly(PREFIX, SYMBOL) \
2558 xkDeclareAssembly(PREFIX, SYMBOL)
2569 #define kBeginAssembly(PREFIX, SYMBOL, VERSION, PLATFORM_VERSION) \
2570 xkBeginAssembly(PREFIX, SYMBOL, VERSION, PLATFORM_VERSION)
2577 #define kEndAssembly() \
2588 #define kDeclareValue(PREFIX, SYMBOL, BASE) \
2589 xkDeclareValue(PREFIX, SYMBOL, BASE)
2599 #define kBeginValue(PREFIX, SYMBOL, BASE) \
2600 xkBeginValue(PREFIX, SYMBOL, BASE)
2607 #define kEndValue() \
2618 #define kDeclareEnum(PREFIX, SYMBOL, BASE) \
2619 xkDeclareEnum(PREFIX, SYMBOL, BASE)
2629 #define kBeginEnum(PREFIX, SYMBOL, BASE) \
2630 xkBeginEnum(PREFIX, SYMBOL, BASE)
2637 #define kEndEnum() \
2648 #define kDeclareArrayValue(PREFIX, SYMBOL, BASE) \
2649 xkDeclareArrayValue(PREFIX, SYMBOL, BASE)
2660 #define kBeginArrayValue(PREFIX, SYMBOL, TYPE, BASE) \
2661 xkBeginArrayValue(PREFIX, SYMBOL, TYPE, BASE)
2668 #define kEndArrayValue() \
2679 #define kDeclareInterface(PREFIX, SYMBOL, BASE) \
2680 xkDeclareInterface(PREFIX, SYMBOL, BASE)
2690 #define kBeginInterface(PREFIX, SYMBOL, BASE) \
2691 xkBeginInterface(PREFIX, SYMBOL, BASE)
2698 #define kEndInterface() \
2709 #define kDeclareFullClass(PREFIX, SYMBOL, BASE) \
2710 xkDeclareFullClass(PREFIX, SYMBOL, BASE)
2720 #define kBeginFullClass(PREFIX, SYMBOL, BASE) \
2721 xkBeginFullClass(PREFIX, SYMBOL, BASE)
2728 #define kEndFullClass() \
2739 #define kDeclareVirtualClass(PREFIX, SYMBOL, BASE) \
2740 xkDeclareVirtualClass(PREFIX, SYMBOL, BASE)
2750 #define kBeginVirtualClass(PREFIX, SYMBOL, BASE) \
2751 xkBeginVirtualClass(PREFIX, SYMBOL, BASE)
2758 #define kEndVirtualClass() \
2768 #define kDeclareStaticClass(PREFIX, SYMBOL) \
2769 xkDeclareStaticClass(PREFIX, SYMBOL)
2778 #define kBeginStaticClass(PREFIX, SYMBOL) \
2779 xkBeginStaticClass(PREFIX, SYMBOL)
2786 #define kEndStaticClass() \
2797 #define kDeclareClass(PREFIX, SYMBOL, BASE) \
2798 xkDeclareClass(PREFIX, SYMBOL, BASE)
2808 #define kBeginClass(PREFIX, SYMBOL, BASE) \
2809 xkBeginClass(PREFIX, SYMBOL, BASE)
2816 #define kEndClass() \
2836 #define kDeclareAssemblyEx(PREFIX, SYMBOL) \
2837 xkDeclareAssemblyEx(PREFIX, SYMBOL)
2848 #define kBeginAssemblyEx(PREFIX, SYMBOL, VERSION, PLATFORM_VERSION) \
2849 xkBeginAssemblyEx(PREFIX, SYMBOL, VERSION, PLATFORM_VERSION)
2856 #define kEndAssemblyEx() \
2867 #define kDeclareValueEx(PREFIX, SYMBOL, BASE) \
2868 xkDeclareValueEx(PREFIX, SYMBOL, BASE)
2877 #define kBeginValueEx(PREFIX, SYMBOL) \
2878 xkBeginValueEx(PREFIX, SYMBOL)
2885 #define kEndValueEx() \
2896 #define kDeclareEnumEx(PREFIX, SYMBOL, BASE) \
2897 xkDeclareEnumEx(PREFIX, SYMBOL, BASE)
2906 #define kBeginEnumEx(PREFIX, SYMBOL) \
2907 xkBeginEnumEx(PREFIX, SYMBOL)
2914 #define kEndEnumEx() \
2925 #define kDeclareArrayValueEx(PREFIX, SYMBOL, BASE) \
2926 xkDeclareArrayValueEx(PREFIX, SYMBOL, BASE)
2936 #define kBeginArrayValueEx(PREFIX, SYMBOL, TYPE) \
2937 xkBeginArrayValueEx(PREFIX, SYMBOL, TYPE)
2944 #define kEndArrayValueEx() \
2955 #define kDeclareInterfaceEx(PREFIX, SYMBOL, BASE) \
2956 xkDeclareInterfaceEx(PREFIX, SYMBOL, BASE)
2965 #define kBeginInterfaceEx(PREFIX, SYMBOL) \
2966 xkBeginInterfaceEx(PREFIX, SYMBOL)
2973 #define kEndInterfaceEx() \
2984 #define kDeclareFullClassEx(PREFIX, SYMBOL, BASE) \
2985 xkDeclareFullClassEx(PREFIX, SYMBOL, BASE)
2994 #define kBeginFullClassEx(PREFIX, SYMBOL) \
2995 xkBeginFullClassEx(PREFIX, SYMBOL)
3002 #define kEndFullClassEx() \
3013 #define kDeclareVirtualClassEx(PREFIX, SYMBOL, BASE) \
3014 xkDeclareVirtualClassEx(PREFIX, SYMBOL, BASE)
3023 #define kBeginVirtualClassEx(PREFIX, SYMBOL) \
3024 xkBeginVirtualClassEx(PREFIX, SYMBOL)
3031 #define kEndVirtualClassEx() \
3032 xkEndVirtualClassEx()
3041 #define kDeclareStaticClassEx(PREFIX, SYMBOL) \
3042 xkDeclareStaticClassEx(PREFIX, SYMBOL)
3051 #define kBeginStaticClassEx(PREFIX, SYMBOL) \
3052 xkBeginStaticClassEx(PREFIX, SYMBOL)
3059 #define kEndStaticClassEx() \
3060 xkEndStaticClassEx()
3070 #define kDeclareClassEx(PREFIX, SYMBOL, BASE) \
3071 xkDeclareClassEx(PREFIX, SYMBOL, BASE)
3080 #define kBeginClassEx(PREFIX, SYMBOL) \
3081 xkBeginClassEx(PREFIX, SYMBOL)
3088 #define kEndClassEx() \
3106 #define kAddDependency(SYMBOL) \
3107 xkAddDependency(SYMBOL)
3115 #define kAddType(SYMBOL) \
3128 #define kAddPriority(SYMBOL) \
3129 xkAddPriority(SYMBOL)
3139 #define kAddStatic(SYMBOL) \
3149 #define kAddInterface(SYMBOL, IFACE) \
3150 xkAddInterface(SYMBOL, IFACE)
3170 #define kAddFrameworkConstructor(SYMBOL, CTOR) \
3171 xkAddFrameworkConstructor(SYMBOL, CTOR)
3191 #define kAddPrivateFrameworkConstructor(SYMBOL, CTOR) \
3192 xkAddPrivateFrameworkConstructor(SYMBOL, CTOR)
3201 #define kAddMethod(SYMBOL, METHOD) \
3202 xkAddMethod(SYMBOL, METHOD)
3212 #define kAddVMethod(IN_TYPE, FROM_TYPE, METHOD) \
3213 xkAddVMethod(IN_TYPE, FROM_TYPE, METHOD)
3225 #define kAddPrivateVMethod(IN_TYPE, FROM_TYPE, METHOD) \
3226 xkAddPrivateVMethod(IN_TYPE, FROM_TYPE, METHOD)
3237 #define kAddIVMethod(IN_TYPE, FROM_IFACE, IMETHOD, CMETHOD) \
3238 xkAddIVMethod(IN_TYPE, FROM_IFACE, IMETHOD, CMETHOD)
3251 #define kAddPrivateIVMethod(IN_TYPE, FROM_IFACE, IMETHOD, CMETHOD) \
3252 xkAddPrivateIVMethod(IN_TYPE, FROM_IFACE, IMETHOD, CMETHOD)
3262 #define kAddField(VALUE, FIELD_TYPE, FIELD) \
3263 xkAddField(VALUE, FIELD_TYPE, FIELD)
3272 #define kAddEnumerator \
3293 #define kAddVersionEx(TYPE, FORMAT, FORMAT_VER, GUID, WRITE_METHOD, READ_METHOD) \
3294 xkAddVersionEx(TYPE, FORMAT, FORMAT_VER, GUID, WRITE_METHOD, READ_METHOD)
3316 #define kAddPrivateVersionEx(TYPE, FORMAT, FORMAT_VER, GUID, WRITE_METHOD, READ_METHOD) \
3317 xkAddPrivateVersionEx(TYPE, FORMAT, FORMAT_VER, GUID, WRITE_METHOD, READ_METHOD)
3332 #define kAddAbstractVersionEx(TYPE, FORMAT, FORMAT_VER, GUID) \
3333 xkAddAbstractVersion(TYPE, FORMAT, FORMAT_VER, GUID)
3342 #define kAddFlags(TYPE, FLAGS) \
3343 xkAddFlags(TYPE, FLAGS)
3366 #define kDefineDebugHints() \
3367 xkDefineDebugHints()
3383 #define kObj(TypeName_T, T_object) \
3384 TypeName_T##Class* obj K_ATTRIBUTE_UNUSED = xx##TypeName_T##_Cast(T_object, __FILE__, __LINE__)
3395 #define kObjR(TypeName_T, T_object) \
3396 TypeName_T##Class* obj K_ATTRIBUTE_UNUSED = x##TypeName_T##_CastRaw(T_object)
3409 #define kObjN(TypeName_T, VarName_obj, T_object) \
3410 TypeName_T##Class* VarName_obj = xx##TypeName_T##_Cast(T_object, __FILE__, __LINE__)
3422 #define kObjNR(TypeName_T, VarName_obj, T_object) \
3423 TypeName_T##Class* VarName_obj = x##TypeName_T##_CastRaw(T_object)
3430 #define kStaticObj(TypeName_T) \
3431 TypeName_T##Static* sobj = kStaticOf(TypeName_T)
3443 #define kCastClass_(TYPE, OBJECT) \
3444 xkCastClass_(TYPE, OBJECT)
3456 #define kCastVTable_(TYPE, OBJECT) \
3457 xkCastVTable_(TYPE, OBJECT)
3469 #define kCastIVTable_(IFACE, OBJECT) \
3470 xkCastIVTable_(IFACE, OBJECT)
3477 #define kDebugBreak() \
3480 #include <kApi/kApiDef.x.h>
k32f y
Y-coordinate value.
Definition: kApiDef.h:1316
kStatus k32s_Parse(k32s *value, const kChar *str)
Converts string to k32s value.
k64f height
Height of the rectangular cuboid.
Definition: kApiDef.h:1537
Represents a 64-unit, null-terminated, kChar sequence.
#define kALLOC_TRAIT_NON_ATOMIC
Allocates memory that cannot support atomic operations.
Definition: kApiDef.h:2238
Represents a 32-bit unsigned integer.
k32s y
Y-coordinate of the origin.
Definition: kApiDef.h:1472
kBool kChar_IsSpace(kChar ch)
Checks whether ASCII character is a some kind of white space character type.
Definition: kApiDef.h:400
kStatus kBool_Parse(kBool *value, const kChar *str)
Converts string to kBool value.
k64f height
Height of the rectangle.
Definition: kApiDef.h:1506
k32f x
X-coordinate of the origin.
Definition: kApiDef.h:1487
Rectangle structure with 32-bit signed integer fields.
Definition: kApiDef.h:1469
3D point structure with 32-bit floating-point fields.
Definition: kApiDef.h:1382
k64f x
X-coordinate of the origin.
Definition: kApiDef.h:1503
k32s width
Width of the rectangle.
Definition: kApiDef.h:1567
k8u b
Blue component value.
Definition: kApiDef.h:1651
k32s y
Y-coordinate value.
Definition: kApiDef.h:1370
#define kALLOC_TRAIT_SERIAL
Allocates memory suitable for single-threaded use only.
Definition: kApiDef.h:2237
k16s width
Width of the rectangle.
Definition: kApiDef.h:1457
32-bit color pixel structure (B/G/R/A).
Definition: kApiDef.h:1677
k16s y
Y-coordinate of the origin.
Definition: kApiDef.h:1456
Represents a unique thread identifier.
2D point structure with 16-bit signed integer fields.
Definition: kApiDef.h:1285
kStatus(kCall * kFrameworkConstructorFx)(kObject *object, kAlloc allocator)
Required signature for kObject framework constructors.
Definition: kApiDef.h:2414
kChar kChar_ToLower(kChar ch)
Convert ASCII character to lower case.
Definition: kApiDef.h:376
kBool kAllocTrait_IsCudaManaged(kAllocTrait traits)
Reports whether the kALLOC_TRAIT_CUDA_MANAGED trait is present in an allocator trait bitset...
Definition: kApiDef.h:2312
Represents a 64-bit unsigned integer.
Architecture/compiler-specific definitions.
kBool kSuccess(kStatus status)
Returns kTRUE if the given expression value is kOK.
Definition: kApiDef.h:548
Represents a 256-unit, null-terminated, kChar sequence.
kTypeName methodName
Method name (e.g. "Clone").
Definition: kApiDef.h:2423
kPointer receiver
Callback receiver context pointer.
Definition: kApiDef.h:1817
kTypeName name
Enumerator name (e.g. "kPIXEL_FORMAT_8BPP_GREYSCALE").
Definition: kApiDef.h:2449
#define kALLOC_TRAIT_CUDA_PINNED
Allocates Cuda pinned memory (host or device).
Definition: kApiDef.h:2240
Rotated rectangle structure with 32-bit floating-point fields.
Definition: kApiDef.h:1580
k64f y
Y-coordinate of the origin.
Definition: kApiDef.h:1504
k32s z
Z-coordinate value.
Definition: kApiDef.h:1371
Represents a void pointer.
32-bit color pixel structure (B/G/R/X).
Definition: kApiDef.h:1649
kStatus kSize_Parse(kSize *value, const kChar *str)
Converts string to kSize value.
k32f x
X-coordinate value.
Definition: kApiDef.h:1315
kBool kThreadId_Compare(kThreadId a, kThreadId b)
Compares two thread identifiers for equality.
kByte address[6]
Address bytes (most significant byte first).
Definition: kApiDef.h:1706
kStatus kSSize_Parse(kSSize *value, const kChar *str)
Converts string to kSSize value.
kBool kAllocTrait_SupportsContext(kAllocTrait traits)
Reports whether the kALLOC_TRAIT_CONTEXT trait is present in an allocator trait bitset.
Definition: kApiDef.h:2288
static kInline std::enable_if< std::is_unsigned< T >::value, T >::type kDivideCeil(const T &a, const T &b)
Calculates the quotient of two unsigned integers, rounding up.
Definition: kApiDef.h:2072
T kQuantizeFloor(const T &value, const T &granularity)
Rounds the specified input value down to the nearest multiple of the specified granularity.
Definition: kApiDef.h:2104
kBool kChar_IsLetter(kChar ch)
Checks whether ASCII character is a letter.
Definition: kApiDef.h:412
T kClamp(const T &v, const T &min, const T &max)
Returns a value limited to the specified range.
Definition: kApiDef.h:2024
k16s z
Z-coordinate value.
Definition: kApiDef.h:1356
T kMax(const T &a, const T &b)
Returns the maximum of two numbers.
Definition: kApiDef.h:2007
kStatus k32f_Format(k32f value, kChar *buffer, kSize capacity)
Converts k32f value to string.
Represents a 16-bit unsigned integer.
kStatus k32u_Format(k32u value, kChar *buffer, kSize capacity)
Converts k32u value to string.
k32s xc
X-coordinate of the rectangle center.
Definition: kApiDef.h:1565
Rotated rectangle structure with 32-bit signed integer fields.
Definition: kApiDef.h:1563
kBool kAllocTrait_IsSerial(kAllocTrait traits)
Reports whether the kALLOC_TRAIT_SERIAL trait is present in an allocator trait bitset.
Definition: kApiDef.h:2264
k32f yc
Y-coordinate of the rectangle center.
Definition: kApiDef.h:1583
kStatus kBool_Format(kBool value, kChar *buffer, kSize capacity)
Converts kBool value to string.
Represents an unsigned integer that can store a pointer address.
Abstract base class for memory allocator types.
k32s angle
Rotation angle of the rectangle.
Definition: kApiDef.h:1569
void * kPointer_ItemOffset(const void *pointer, kSSize itemIndex, kSize itemSize)
Gets a pointer to the Nth element of an array.
Definition: kApiDef.h:294
kTypeName displayName
Formatted display name (e.g. "8bpp Greyscale");.
Definition: kApiDef.h:2450
Represents type field information.
Definition: kApiDef.h:2433
k64f width
Width of the rectangular cuboid.
Definition: kApiDef.h:1536
Represents an 8-bit unsigned integer.
k64f x
X-coordinate of the origin.
Definition: kApiDef.h:1533
k64f depth
Depth of the rectangular cuboid.
Definition: kApiDef.h:1538
#define kInlineFx(TYPE)
Inline method declaration helper.
Definition: kApiDef.h:26
k64f y
Y-coordinate value.
Definition: kApiDef.h:1400
k64f x
X-coordinate value.
Definition: kApiDef.h:1399
kBool kAllocTrait_IsNonAtomic(kAllocTrait traits)
Reports whether the kALLOC_TRAIT_NON_ATOMIC trait is present in an allocator trait bitset...
Definition: kApiDef.h:2276
Represents enumerator information.
Definition: kApiDef.h:2446
Represents a single unit (byte) in a UTF-8 character.
#define kALLOC_TRAIT_CONTEXT
Allocator supports use of a context object during copy operations.
Definition: kApiDef.h:2239
Represents a byte on the current platform.
kStatus k64s_Format(k64s value, kChar *buffer, kSize capacity)
Converts k64s value to string.
T kAdjustCeil(const T &value, const T &min, const T &max, const T &granularity)
Rounds the specified input up, conforming to minimum, maximum, and granularity constraints.
Definition: kApiDef.h:2170
kStatus k16u_Parse(k16u *value, const kChar *str)
Converts string to k16u value.
k16s x
X-coordinate value.
Definition: kApiDef.h:1287
k16s y
Y-coordinate value.
Definition: kApiDef.h:1355
kStatus kSSize_Format(kSSize value, kChar *buffer, kSize capacity)
Converts kSSize value to string.
kSize(kCall * kHashFx)(const void *item)
Callback signature to determine hash code of an item.
Definition: kApiDef.h:1796
kStatus k64f_Parse(k64f *value, const kChar *str)
Converts string to k64f value.
k32f angle
Rotation angle of the rectangle.
Definition: kApiDef.h:1586
Represents a signed integer that can store a pointer address.
typedef kStatus(kCall *kMsgQueueDropFx)(kPointer receiver
Defines the signature of a callback function to handle dropped items.
k32s height
Height of the rectangle.
Definition: kApiDef.h:1474
Rectangle structure with 32-bit floating-point fields.
Definition: kApiDef.h:1485
kBool kIsError(kStatus status)
Returns kTRUE if the given status value is not kOK.
Definition: kApiDef.h:536
k32s kVersion_Compare(kVersion version1, kVersion version2)
Returns an integral value indicating the relationship between the versions.
Definition: kApiDef.h:852
kBool kAllocTrait_IsCudaPinned(kAllocTrait traits)
Reports whether the kALLOC_TRAIT_CUDA_PINNED trait is present in an allocator trait bitset...
Definition: kApiDef.h:2300
k32s width
Width of the rectangle.
Definition: kApiDef.h:1473
kStatus k32u_Parse(k32u *value, const kChar *str)
Converts string to k32u value.
k32s x
X-coordinate value.
Definition: kApiDef.h:1301
k32s height
Height of the rectangle.
Definition: kApiDef.h:1568
Rectangle structure with 64-bit floating-point fields.
Definition: kApiDef.h:1501
Represents a 128-unit, null-terminated, kChar sequence.
k32f x
X-coordinate value.
Definition: kApiDef.h:1384
k8u kVersion_Minor(kVersion version)
Returns the minor part of a version number.
Definition: kApiDef.h:876
#define kALLOC_TRAIT_CUDA_MANAGED
Allocates Cuda managed memory (host or device).
Definition: kApiDef.h:2241
kChar kChar_ToUpper(kChar ch)
Convert ASCII character to upper case.
Definition: kApiDef.h:388
kStatus k16s_Format(k16s value, kChar *buffer, kSize capacity)
Converts k16s value to string.
kBool(kCall * kEqualsFx)(const void *item1, const void *item2)
Callback signature to determine equality of two items.
Definition: kApiDef.h:1788
k8u kVersion_Major(kVersion version)
Returns the major part of a version number.
Definition: kApiDef.h:864
T kQuantizeCeil(const T &value, const T &granularity)
Rounds the specified input value up to the nearest multiple of the specified granularity.
Definition: kApiDef.h:2120
k16s y
Y-coordinate value.
Definition: kApiDef.h:1288
Represents type method information.
Definition: kApiDef.h:2421
k16s x
X-coordinate value.
Definition: kApiDef.h:1354
k32f z
Z-coordinate value.
Definition: kApiDef.h:1386
kTypeName name
Field name.
Definition: kApiDef.h:2435
kStatus k32f_Parse(k32f *value, const kChar *str)
Converts string to k32f value.
k64f width
Width of the rectangle.
Definition: kApiDef.h:1505
k64f z
Z-coordinate value.
Definition: kApiDef.h:1401
Represents a callback function and context pointer.
Definition: kApiDef.h:1814
void kItemCopy(void *dest, const void *src, kSize size)
Performs a small copy with minimal overhead.
Definition: kApiDef.h:2205
k8u kVersion_Build(kVersion version)
Returns the build part of a version number.
Definition: kApiDef.h:900
k8u r
Red component value.
Definition: kApiDef.h:1681
2D point structure with 32-bit floating-point fields.
Definition: kApiDef.h:1313
k64f y
Y-coordinate of the origin.
Definition: kApiDef.h:1534
kStatus k32s_Format(k32s value, kChar *buffer, kSize capacity)
Converts k32s value to string.
Preset compression levels.
k16s w
W-coordinate value.
Definition: kApiDef.h:1429
k32s yc
Y-coordinate of the rectangle center.
Definition: kApiDef.h:1566
Represents a 32-bit signed integer.
Represents an Ethernet address.
Definition: kApiDef.h:1704
void * kPointer_ByteOffset(const void *pointer, kSSize offset)
Calculates a pointer address from a base address and a byte offset.
Definition: kApiDef.h:280
void(kCall * kFunction)()
Generic pointer to function.
Definition: kApiDef.h:28
k8u r
Red component value.
Definition: kApiDef.h:1653
k32f height
Height of the rectangle.
Definition: kApiDef.h:1585
kBool kChar_IsDigit(kChar ch)
Checks whether ASCII character is a digit.
Definition: kApiDef.h:424
k64f x
X-coordinate value.
Definition: kApiDef.h:1329
void kItemZero(void *dest, kSize size)
Zero-initializes a small amount of memory with minimal overhead.
Definition: kApiDef.h:2223
kVersion kVersion_Create(k32u major, k32u minor, k32u release, k32u build)
Creates a version value from its constituent parts.
Definition: kApiDef.h:799
kType type
Field type.
Definition: kApiDef.h:2436
k8u kVersion_Release(kVersion version)
Returns the release part of a version number.
Definition: kApiDef.h:888
kEndianness kEndianness_Host()
Reports the endianness of the current platform.
Definition: kApiDef.h:923
kStatus k16s_Parse(k16s *value, const kChar *str)
Converts string to k16s value.
2D point structure with 64-bit floating-point fields.
Definition: kApiDef.h:1327
kBool kEndianness_ShouldReverse(kEndianness endianness)
Reports whether byte ordering must be reversed to be consistent with the current platform.
Definition: kApiDef.h:934
kStatus(kCall * kCallbackFx)(kPointer receiver, kPointer sender, void *args)
Callback signature for a generic event handler.
Definition: kApiDef.h:1806
#define kALLOC_TRAIT_CUDA_DEVICE
Allocates Cuda device memory (device only).
Definition: kApiDef.h:2242
k8u g
Green component value.
Definition: kApiDef.h:1652
Represents a 64-bit signed integer.
kStatus kSize_Format(kSize value, kChar *buffer, kSize capacity)
Converts kSize value to string.
kBool kAllocTrait_IsCudaDeviceAccessible(kAllocTrait traits)
Reports whether the memory is Cuda device-accessible.
Definition: kApiDef.h:2336
T kMin(const T &a, const T &b)
Returns the minimum of two numbers.
Definition: kApiDef.h:1991
#define kALLOC_TRAIT_FOREIGN
Allocates memory in a foreign memory domain (non-host address space).
Definition: kApiDef.h:2236
kStatus kVersion_Format(kVersion version, kChar *buffer, kSize capacity)
Formats a version to a string buffer.
Represents a 16-unit, null-terminated, kChar sequence.
Flags that control how a file is opened.
Represents an 8-bit signed integer.
Represents the byte-ordering of primitive data types.
k32f width
Width of the rectangle.
Definition: kApiDef.h:1584
k8u b
Blue component value.
Definition: kApiDef.h:1679
k16s height
Height of the rectangle.
Definition: kApiDef.h:1458
kStatus k8s_Format(k8s value, kChar *buffer, kSize capacity)
Converts k8s value to string.
Represents metadata about a type (class, interface, or value).
k8u g
Green component value.
Definition: kApiDef.h:1680
kStatus k64s_Parse(k64s *value, const kChar *str)
Converts string to k64s value.
k16s x
X-coordinate value.
Definition: kApiDef.h:1426
k32s x
X-coordinate value.
Definition: kApiDef.h:1369
kStatus kVersion_Parse(kVersion *version, const kChar *buffer)
Parses a version from a formatted string.
Represents a 32-unit, null-terminated, kChar sequence.
kStatus kMacAddress_Format(kMacAddress address, kChar *text, kSize capacity)
Formats an Ethernet MAC address as a string.
3D point structure with 16-bit signed integer fields.
Definition: kApiDef.h:1352
k32s value
Enumerator numeric value.
Definition: kApiDef.h:2448
kTypeName functionName
Full function name (e.g. "kObject_Clone").
Definition: kApiDef.h:2424
Represents a 16-bit signed integer.
k32f y
Y-coordinate of the origin.
Definition: kApiDef.h:1488
Represents a 32-bit floating-point number.
k64f y
Y-coordinate value.
Definition: kApiDef.h:1330
Represents a version number.
k8u a
Alpha component value.
Definition: kApiDef.h:1682
#define kOK
Operation successful.
Definition: kApiDef.h:515
static kInline std::enable_if< std::is_unsigned< T >::value, T >::type kDivideFloor(const T &a, const T &b)
Calculates the quotient of two unsigned integers, rounding down.
Definition: kApiDef.h:2040
Represents an error code.
k64f z
Z-coordinate of the origin.
Definition: kApiDef.h:1535
Represents a thread priority class.
kStatus k64u_Format(k64u value, kChar *buffer, kSize capacity)
Converts k64u value to string.
k8u x
Undefined.
Definition: kApiDef.h:1654
k32s y
Y-coordinate value.
Definition: kApiDef.h:1302
kSize offset
Offset of field within structure (bytes).
Definition: kApiDef.h:2437
k16s y
Y-coordinate value.
Definition: kApiDef.h:1427
#define kCall
kApi standard function calling convention.
Definition: kApiDef.h:15
k32f width
Width of the rectangle.
Definition: kApiDef.h:1489
kStatus k16u_Format(k16u value, kChar *buffer, kSize capacity)
Converts k16u value to string.
Rectangular cuboid structure with 64-bit floating-point fields.
Definition: kApiDef.h:1531
kStatus k64f_Format(k64f value, kChar *buffer, kSize capacity)
Converts k64f value to string.
Rectangle structure with 16-bit signed integer fields.
Definition: kApiDef.h:1453
kStatus k8u_Format(k8u value, kChar *buffer, kSize capacity)
Converts k8u value to string.
Represents a 64-bit floating-point number.
Represents a comparison type.
kSSize kPointer_Diff(void *a, void *b)
Calculates the signed difference between two pointers.
Definition: kApiDef.h:307
k32s x
X-coordinate of the origin.
Definition: kApiDef.h:1471
static kInline std::enable_if< std::is_unsigned< T >::value, T >::type kAbs(const T &v)
Returns the absolute value of an unsigned number.
Definition: kApiDef.h:1930
Represents a memory allocator trait.
k32f xc
X-coordinate of the rectangle center.
Definition: kApiDef.h:1582
2D point structure with 32-bit signed integer fields.
Definition: kApiDef.h:1299
Represents a boolean value.
kStatus k64u_Parse(k64u *value, const kChar *str)
Converts string to k64u value.
k16s x
X-coordinate of the origin.
Definition: kApiDef.h:1455
Represents alignment options for allocations.
kStatus kMacAddress_Parse(kMacAddress *address, const kChar *text)
Parses a text-formatted Ethernet MAC address.
kSize count
Count of values in this field (typically 1; can be higher for "array value" fields, e.g. kText32).
Definition: kApiDef.h:2438
T kAdjustFloor(const T &value, const T &min, const T &max, const T &granularity)
Rounds the specified input down, conforming to minimum, maximum, and granularity constraints.
Definition: kApiDef.h:2142
k32f height
Height of the rectangle.
Definition: kApiDef.h:1490
3D point structure with 64-bit floating-point fields.
Definition: kApiDef.h:1397
static kInline std::enable_if< std::is_unsigned< T >::value, T >::type kSign(const T &v)
Returns the sign of an unsigned number.
Definition: kApiDef.h:1960
kBool kAllocTrait_IsCudaDevice(kAllocTrait traits)
Reports whether the kALLOC_TRAIT_CUDA_DEVICE trait is present in an allocator trait bitset...
Definition: kApiDef.h:2324
3D point structure with 32-bit signed integer fields.
Definition: kApiDef.h:1367
k16s z
Z-coordinate value.
Definition: kApiDef.h:1428
kStatus k8u_Parse(k8u *value, const kChar *str)
Converts string to k8u value.
k32f y
Y-coordinate value.
Definition: kApiDef.h:1385
4D point structure with 16-bit signed integer fields.
Definition: kApiDef.h:1424
kStatus k8s_Parse(k8s *value, const kChar *str)
Converts string to k8s value.