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)
188 #define k32F_MIN (1.175494351e-38F)
189 #define k32F_MAX (3.402823466e+38F)
190 #define k32F_NULL (-k32F_MAX)
191 #define k32F_DIGITS (9)
201 kInlineFx(kBool) k32f_IsNull(k32f value)
217 #define k64F_MIN (2.2250738585072014e-308)
218 #define k64F_MAX (1.7976931348623157e+308)
219 #define k64F_NULL (-k64F_MAX)
220 #define k64F_DIGITS (17)
231 kFx(k32s) k64f_IsNanOrInf(k64f value);
253 typedef xkByte
kByte;
263 typedef xkSize
kSize;
266 #define kSIZE_MAX xkSIZE_MAX
267 #define kSIZE_NULL kSIZE_MAX
280 kInlineFx(kSize) kSize_Align(kSize value, kSize to)
282 return ((value >> to) + !!(value & ((1 << to) - 1))) << to;
294 #define kSSIZE_MIN xkSSIZE_MIN
295 #define kSSIZE_MAX xkSSIZE_MAX
296 #define kSSIZE_NULL kSSIZE_MIN
306 typedef void* kPointer;
321 return (
kByte*)pointer + offset;
359 #define kPointer_ReadAs(POINTER, TYPE) \
370 #define kPointer_WriteAs(POINTER, VALUE, TYPE) \
371 (*(TYPE*)(POINTER) = (TYPE)(VALUE))
380 #define kIsNull(POINTER) \
391 typedef xkChar
kChar;
402 return (ch >=
'A' && ch <=
'Z') ? (ch -
'A' +
'a') : ch;
414 return (ch >=
'a' && ch <=
'z') ? (ch -
'a' +
'A') : ch;
438 return ((ch >=
'a') && (ch <=
'z') ) || ((ch >=
'A') && (ch <=
'Z'));
450 return ch >=
'0' && ch <=
'9';
514 #define kERROR_STATE (-1000)
515 #define kERROR_NOT_FOUND (-999)
516 #define kERROR_COMMAND (-998)
517 #define kERROR_PARAMETER (-997)
518 #define kERROR_UNIMPLEMENTED (-996)
519 #define kERROR_MEMORY (-994)
520 #define kERROR_TIMEOUT (-993)
521 #define kERROR_INCOMPLETE (-992)
522 #define kERROR_STREAM (-991)
523 #define kERROR_CLOSED (-990)
524 #define kERROR_VERSION (-989)
525 #define kERROR_ABORT (-988)
526 #define kERROR_ALREADY_EXISTS (-987)
527 #define kERROR_NETWORK (-986)
528 #define kERROR_HEAP (-985)
529 #define kERROR_FORMAT (-984)
530 #define kERROR_READ_ONLY (-983)
531 #define kERROR_WRITE_ONLY (-982)
532 #define kERROR_BUSY (-981)
533 #define kERROR_CONFLICT (-980)
534 #define kERROR_OS (-979)
535 #define kERROR_DEVICE (-978)
536 #define kERROR_FULL (-977)
537 #define kERROR_IN_PROGRESS (-976)
551 kFx(const kChar*) kStatus_Name(kStatus status);
562 return status !=
kOK;
574 return status ==
kOK;
585 #define kCheck(EXPRESSION) \
597 #define kCheckTrue(EXPRESSION, STATUS) \
598 xkCheckTrue(EXPRESSION, STATUS)
608 #define kCheckArgs(EXPRESSION) \
609 xkCheckArgs(EXPRESSION)
619 #define kCheckState(EXPRESSION) \
620 xkCheckState(EXPRESSION)
636 #define kThrow(EXPRESSION) \
648 #define kTest(EXPRESSION) \
661 #define kTestTrue(EXPRESSION, STATUS) \
662 xkTestTrue(EXPRESSION, STATUS)
673 #define kTestArgs(EXPRESSION) \
674 xkTestArgs(EXPRESSION)
685 #define kTestState(EXPRESSION) \
686 xkTestState(EXPRESSION)
694 #define kCatch(STATUS_POINTER) \
695 xkCatch(STATUS_POINTER)
705 #define kEndCatch(STATUS) \
724 #define kEndFinally() \
733 #define kCatchEx(STATUS_POINTER) \
734 xkCatchEx(STATUS_POINTER)
746 #define kEndCatchEx(STATUS) \
765 #define kEndFinallyEx() \
775 #define kAssert(EXPRESSION) \
788 #define kAssertType(OBJECT, SYMBOL) \
789 xkAssertType(OBJECT, SYMBOL)
798 #define kTrace(TAG) \
811 #define kVERSION_NULL (k32U_NULL) // kVersion invalid value.
825 return (major & 0xFF) << 24 |
826 (minor & 0xFF) << 16 |
827 (release & 0xFF) << 8 |
841 #define kVersion_Stringify_(MAJOR, MINOR, RELEASE, BUILD) \
842 xkStringize(MAJOR) "." xkStringize(MINOR) "." xkStringize(RELEASE) "." xkStringize(BUILD)
878 return (
k32s)version1 - (
k32s)version2;
890 return (version >> 24) & 0xFF;
902 return (version >> 16) & 0xFF;
914 return (version >> 8) & 0xFF;
926 return (version) & 0xFF;
938 #define kENDIANNESS_LITTLE (1)
939 #define kENDIANNESS_BIG (2)
947 kInlineFx(kEndianness) kEndianness_Host()
1366 #define kPoint_Init_(POINT, X, Y) xkPoint_Init_(POINT, X, Y)
1438 #define kPoint3d_Init_(POINT, X, Y, Z) xkPoint3d_Init_(POINT, X, Y, Z)
1467 #define kPoint4d_Init_(POINT, X, Y, Z, W) xkPoint4d_Init_(POINT, X, Y, Z, W)
1544 #define kRect_Init_(RECT, X, Y, W, H) \
1545 xkRect_Init_(RECT, X, Y, W, H)
1576 #define kRect3d_Init_(RECT, X, Y, Z, W, H, D) \
1577 xkRect3d_Init_(RECT, X, Y, Z, W, H, D)
1625 #define kRotatedRect_Init_(RECT, XC, YC, W, H, A) \
1626 xkRotatedRect_Init_(RECT, XC, YC, W, H, A)
1639 #define kPIXEL_FORMAT_NULL (0)
1640 #define kPIXEL_FORMAT_8BPP_GREYSCALE (1)
1641 #define kPIXEL_FORMAT_8BPP_CFA (2)
1642 #define kPIXEL_FORMAT_8BPC_BGRX (3)
1643 #define kPIXEL_FORMAT_1BPP_GREYSCALE (4)
1644 #define kPIXEL_FORMAT_16BPP_GREYSCALE (5)
1645 #define kPIXEL_FORMAT_8BPC_BGR (6)
1659 #define kCFA_NONE (0)
1660 #define kCFA_BAYER_BGGR (1)
1661 #define kCFA_BAYER_GBRG (2)
1662 #define kCFA_BAYER_RGGB (3)
1663 #define kCFA_BAYER_GRBG (4)
1691 #define kRgb_Init_(RGB, R, G, B) \
1692 xkRgb_Init_(RGB, R, G, B)
1720 #define kArgb_Init_(ARGB, A, R, G, B) \
1721 xkArgb_Init_(ARGB, A, R, G, B)
1747 #define kRgb24_Init_(RGB24, R, G, B) \
1748 xkRgb24_Init_(RGB24, R, G, B)
1770 #define kMEMORY_ALIGNMENT_8 (3)
1771 #define kMEMORY_ALIGNMENT_16 (4)
1772 #define kMEMORY_ALIGNMENT_32 (5)
1773 #define kMEMORY_ALIGNMENT_64 (6)
1774 #define kMEMORY_ALIGNMENT_128 (7)
1775 #define kMEMORY_ALIGNMENT_256 (8)
1776 #define kMEMORY_ALIGNMENT_512 (9)
1777 #define kMEMORY_ALIGNMENT_1024 (10)
1778 #define kMEMORY_ALIGNMENT_2048 (11)
1779 #define kMEMORY_ALIGNMENT_4096 (12)
1788 kInlineFx(kSize) kMemoryAlignment_Size(kMemoryAlignment alignment)
1826 #define kCOMPARISON_EQ (0)
1827 #define kCOMPARISON_NEQ (1)
1828 #define kCOMPARISON_LT (2)
1829 #define kCOMPARISON_LTE (3)
1830 #define kCOMPARISON_GT (4)
1831 #define kCOMPARISON_GTE (5)
1881 #define kFILE_MODE_READ (0x1)
1882 #define kFILE_MODE_WRITE (0x2)
1883 #define kFILE_MODE_UPDATE (0x4)
1892 typedef k32s kSeekOrigin;
1895 #define kSEEK_ORIGIN_BEGIN (0)
1896 #define kSEEK_ORIGIN_CURRENT (1)
1897 #define kSEEK_ORIGIN_END (2)
1906 typedef k32s kCompressionType;
1909 #define kCOMPRESSION_TYPE_NULL (0)
1910 #define kCOMPRESSION_TYPE_ZSTD (1)
1923 #define kCOMPRESSION_PRESET_MIN (-1)
1924 #define kCOMPRESSION_PRESET_FAST (-2)
1925 #define kCOMPRESSION_PRESET_DEFAULT (-3)
1926 #define kCOMPRESSION_PRESET_DENSE (-4)
1927 #define kCOMPRESSION_PRESET_MAX (-5)
1939 typedef k64u kLogOption;
1942 #define kLOG_OPTION_WARNING (0x1)
1943 #define kLOG_OPTION_ERROR (0x2)
1944 #define kLOG_OPTION_PLATFORM (0x10)
1955 #define kCountOf(CARRAY) \
1956 (sizeof(CARRAY)/sizeof(CARRAY[0]))
1967 #define kCast(TYPE, ITEM) \
1970 #if (K_CPP_VERSION >= K_CPP_VERSION_2011)
1981 template <
typename T>
1982 static kInline
typename std::enable_if<std::is_unsigned<T>::value, T>::type
kAbs(
const T& v)
1996 template <
typename T>
1997 static kInline
typename std::enable_if<!std::is_unsigned<T>::value, T>::type
kAbs(
const T& v)
1999 return (v >= T()) ? v : -v;
2011 template <
typename T>
2012 static kInline
typename std::enable_if<std::is_unsigned<T>::value, T>::type
kSign(
const T& v)
2026 template <
typename T>
2027 static kInline
typename std::enable_if<!std::is_unsigned<T>::value, T>::type
kSign(
const T& v)
2029 return (v > T()) - (v < T());
2042 template <
typename T>
2045 return (a < b) ? a : b;
2058 template <
typename T>
2061 return (a > b) ? a : b;
2075 template <
typename T>
2091 template <
typename T>
2092 static kInline
typename std::enable_if<std::is_unsigned<T>::value, T>::type
kDivideFloor(
const T& a,
const T& b)
2107 template <
typename T>
2108 static kInline
typename std::enable_if<!std::is_unsigned<T>::value, T>::type
kDivideFloor(
const T& a,
const T& b)
2110 return ((
kSign(a) *
kSign(b)) >= T()) ? a / b : ((a / b) - ((a % b) != T()));
2123 template <
typename T>
2124 static kInline
typename std::enable_if<std::is_unsigned<T>::value, T>::type
kDivideCeil(
const T& a,
const T& b)
2126 return (a / b) + ((a % b) != T());
2139 template <
typename T>
2140 static kInline
typename std::enable_if<!std::is_unsigned<T>::value, T>::type
kDivideCeil(
const T& a,
const T& b)
2142 return ((
kSign(a) *
kSign(b)) <= T()) ? a / b : ((a / b) + ((a % b) != T()));
2155 template <
typename T>
2171 template <
typename T>
2174 return kDivideCeil(value, granularity) * granularity;
2193 template <
typename T>
2196 typedef typename std::make_unsigned<T>::type U;
2197 U relativeValue = (value >= min) ? (U) (value - min) : U();
2198 U relativeMax = (max >= min) ? (U) (max - min) : U();
2199 U quantizedRelativeMax = kQuantizeFloor<U>(relativeMax, granularity);
2200 U limitedRelativeValue = kMin<U>(relativeValue, quantizedRelativeMax);
2202 return (T) kQuantizeFloor<U>(limitedRelativeValue, granularity) + min;
2221 template <
typename T>
2224 typedef typename std::make_unsigned<T>::type U;
2225 U relativeValue = (value >= min) ? (U) (value - min) : U();
2226 U relativeMax = (max >= min) ? (U) (max - min) : U();
2227 U quantizedRelativeMax = kQuantizeFloor<U>(relativeMax, granularity);
2228 U limitedRelativeValue = kMin<U>(relativeValue, quantizedRelativeMax);
2230 return (T) kQuantizeCeil<U>(limitedRelativeValue, granularity) + min;
2240 #define kZero(VALUE) \
2241 memset(&VALUE, 0, sizeof(VALUE))
2259 memcpy(dest, src, size);
2277 memset(dest, 0, size);
2288 #define kALLOC_TRAIT_FOREIGN (0x00000001)
2289 #define kALLOC_TRAIT_SERIAL (0x00000002)
2290 #define kALLOC_TRAIT_NON_ATOMIC (0x00000004)
2291 #define kALLOC_TRAIT_CONTEXT (0x00000008)
2292 #define kALLOC_TRAIT_CUDA_PINNED (0x00010000)
2293 #define kALLOC_TRAIT_CUDA_MANAGED (0x00020000)
2294 #define kALLOC_TRAIT_CUDA_DEVICE (0x01000000)
2304 kInlineFx(kBool) kAllocTrait_IsForeign(kAllocTrait traits)
2422 #define kTHREAD_PRIORITY_CLASS_LOW (-1)
2423 #define kTHREAD_PRIORITY_CLASS_NORMAL (0)
2424 #define kTHREAD_PRIORITY_CLASS_HIGH (1)
2432 typedef kObject
kType;
2436 #define kTypeName kText64
2445 typedef k32u kTypeFlags;
2448 #define kTYPE_FLAGS_CLASS (0x01)
2449 #define kTYPE_FLAGS_INTERFACE (0x02)
2450 #define kTYPE_FLAGS_VALUE (0x04)
2451 #define kTYPE_FLAGS_ENUM (0x08)
2452 #define kTYPE_FLAGS_ABSTRACT (0x20)
2453 #define kTYPE_FLAGS_ARRAY_VALUE (0x40)
2454 #define kTYPE_FLAGS_PRIMITIVE (0x80)
2463 typedef kPointer kTypeVersion;
2530 #define kTypeOf(SYMBOL) \
2558 #define kAssemblyOf(SYMBOL) \
2559 xkAssemblyOf(SYMBOL)
2569 #define kStaticOf(SYMBOL) \
2579 #define kDeprecate(SYMBOL) \
2580 xkDeprecate(#SYMBOL)
2590 #define kWarn(MESSAGE) \
2609 #define kDeclareAssembly(PREFIX, SYMBOL) \
2610 xkDeclareAssembly(PREFIX, SYMBOL)
2621 #define kBeginAssembly(PREFIX, SYMBOL, VERSION, PLATFORM_VERSION) \
2622 xkBeginAssembly(PREFIX, SYMBOL, VERSION, PLATFORM_VERSION)
2629 #define kEndAssembly() \
2640 #define kDeclareValue(PREFIX, SYMBOL, BASE) \
2641 xkDeclareValue(PREFIX, SYMBOL, BASE)
2651 #define kBeginValue(PREFIX, SYMBOL, BASE) \
2652 xkBeginValue(PREFIX, SYMBOL, BASE)
2659 #define kEndValue() \
2670 #define kDeclareEnum(PREFIX, SYMBOL, BASE) \
2671 xkDeclareEnum(PREFIX, SYMBOL, BASE)
2681 #define kBeginEnum(PREFIX, SYMBOL, BASE) \
2682 xkBeginEnum(PREFIX, SYMBOL, BASE)
2689 #define kEndEnum() \
2700 #define kDeclareArrayValue(PREFIX, SYMBOL, BASE) \
2701 xkDeclareArrayValue(PREFIX, SYMBOL, BASE)
2712 #define kBeginArrayValue(PREFIX, SYMBOL, TYPE, BASE) \
2713 xkBeginArrayValue(PREFIX, SYMBOL, TYPE, BASE)
2720 #define kEndArrayValue() \
2731 #define kDeclareInterface(PREFIX, SYMBOL, BASE) \
2732 xkDeclareInterface(PREFIX, SYMBOL, BASE)
2742 #define kBeginInterface(PREFIX, SYMBOL, BASE) \
2743 xkBeginInterface(PREFIX, SYMBOL, BASE)
2750 #define kEndInterface() \
2761 #define kDeclareFullClass(PREFIX, SYMBOL, BASE) \
2762 xkDeclareFullClass(PREFIX, SYMBOL, BASE)
2772 #define kBeginFullClass(PREFIX, SYMBOL, BASE) \
2773 xkBeginFullClass(PREFIX, SYMBOL, BASE)
2780 #define kEndFullClass() \
2791 #define kDeclareVirtualClass(PREFIX, SYMBOL, BASE) \
2792 xkDeclareVirtualClass(PREFIX, SYMBOL, BASE)
2802 #define kBeginVirtualClass(PREFIX, SYMBOL, BASE) \
2803 xkBeginVirtualClass(PREFIX, SYMBOL, BASE)
2810 #define kEndVirtualClass() \
2820 #define kDeclareStaticClass(PREFIX, SYMBOL) \
2821 xkDeclareStaticClass(PREFIX, SYMBOL)
2830 #define kBeginStaticClass(PREFIX, SYMBOL) \
2831 xkBeginStaticClass(PREFIX, SYMBOL)
2838 #define kEndStaticClass() \
2849 #define kDeclareClass(PREFIX, SYMBOL, BASE) \
2850 xkDeclareClass(PREFIX, SYMBOL, BASE)
2860 #define kBeginClass(PREFIX, SYMBOL, BASE) \
2861 xkBeginClass(PREFIX, SYMBOL, BASE)
2868 #define kEndClass() \
2888 #define kDeclareAssemblyEx(PREFIX, SYMBOL) \
2889 xkDeclareAssemblyEx(PREFIX, SYMBOL)
2900 #define kBeginAssemblyEx(PREFIX, SYMBOL, VERSION, PLATFORM_VERSION) \
2901 xkBeginAssemblyEx(PREFIX, SYMBOL, VERSION, PLATFORM_VERSION)
2908 #define kEndAssemblyEx() \
2919 #define kDeclareValueEx(PREFIX, SYMBOL, BASE) \
2920 xkDeclareValueEx(PREFIX, SYMBOL, BASE)
2929 #define kBeginValueEx(PREFIX, SYMBOL) \
2930 xkBeginValueEx(PREFIX, SYMBOL)
2937 #define kEndValueEx() \
2948 #define kDeclareEnumEx(PREFIX, SYMBOL, BASE) \
2949 xkDeclareEnumEx(PREFIX, SYMBOL, BASE)
2958 #define kBeginEnumEx(PREFIX, SYMBOL) \
2959 xkBeginEnumEx(PREFIX, SYMBOL)
2966 #define kEndEnumEx() \
2977 #define kDeclareArrayValueEx(PREFIX, SYMBOL, BASE) \
2978 xkDeclareArrayValueEx(PREFIX, SYMBOL, BASE)
2988 #define kBeginArrayValueEx(PREFIX, SYMBOL, TYPE) \
2989 xkBeginArrayValueEx(PREFIX, SYMBOL, TYPE)
2996 #define kEndArrayValueEx() \
3007 #define kDeclareInterfaceEx(PREFIX, SYMBOL, BASE) \
3008 xkDeclareInterfaceEx(PREFIX, SYMBOL, BASE)
3017 #define kBeginInterfaceEx(PREFIX, SYMBOL) \
3018 xkBeginInterfaceEx(PREFIX, SYMBOL)
3025 #define kEndInterfaceEx() \
3036 #define kDeclareFullClassEx(PREFIX, SYMBOL, BASE) \
3037 xkDeclareFullClassEx(PREFIX, SYMBOL, BASE)
3046 #define kBeginFullClassEx(PREFIX, SYMBOL) \
3047 xkBeginFullClassEx(PREFIX, SYMBOL)
3054 #define kEndFullClassEx() \
3065 #define kDeclareVirtualClassEx(PREFIX, SYMBOL, BASE) \
3066 xkDeclareVirtualClassEx(PREFIX, SYMBOL, BASE)
3075 #define kBeginVirtualClassEx(PREFIX, SYMBOL) \
3076 xkBeginVirtualClassEx(PREFIX, SYMBOL)
3083 #define kEndVirtualClassEx() \
3084 xkEndVirtualClassEx()
3093 #define kDeclareStaticClassEx(PREFIX, SYMBOL) \
3094 xkDeclareStaticClassEx(PREFIX, SYMBOL)
3103 #define kBeginStaticClassEx(PREFIX, SYMBOL) \
3104 xkBeginStaticClassEx(PREFIX, SYMBOL)
3111 #define kEndStaticClassEx() \
3112 xkEndStaticClassEx()
3122 #define kDeclareClassEx(PREFIX, SYMBOL, BASE) \
3123 xkDeclareClassEx(PREFIX, SYMBOL, BASE)
3132 #define kBeginClassEx(PREFIX, SYMBOL) \
3133 xkBeginClassEx(PREFIX, SYMBOL)
3140 #define kEndClassEx() \
3158 #define kAddDependency(SYMBOL) \
3159 xkAddDependency(SYMBOL)
3167 #define kAddType(SYMBOL) \
3180 #define kAddPriority(SYMBOL) \
3181 xkAddPriority(SYMBOL)
3191 #define kAddStatic(SYMBOL) \
3201 #define kAddInterface(SYMBOL, IFACE) \
3202 xkAddInterface(SYMBOL, IFACE)
3222 #define kAddFrameworkConstructor(SYMBOL, CTOR) \
3223 xkAddFrameworkConstructor(SYMBOL, CTOR)
3243 #define kAddPrivateFrameworkConstructor(SYMBOL, CTOR) \
3244 xkAddPrivateFrameworkConstructor(SYMBOL, CTOR)
3253 #define kAddMethod(SYMBOL, METHOD) \
3254 xkAddMethod(SYMBOL, METHOD)
3264 #define kAddVMethod(IN_TYPE, FROM_TYPE, METHOD) \
3265 xkAddVMethod(IN_TYPE, FROM_TYPE, METHOD)
3277 #define kAddPrivateVMethod(IN_TYPE, FROM_TYPE, METHOD) \
3278 xkAddPrivateVMethod(IN_TYPE, FROM_TYPE, METHOD)
3289 #define kAddIVMethod(IN_TYPE, FROM_IFACE, IMETHOD, CMETHOD) \
3290 xkAddIVMethod(IN_TYPE, FROM_IFACE, IMETHOD, CMETHOD)
3303 #define kAddPrivateIVMethod(IN_TYPE, FROM_IFACE, IMETHOD, CMETHOD) \
3304 xkAddPrivateIVMethod(IN_TYPE, FROM_IFACE, IMETHOD, CMETHOD)
3314 #define kAddField(VALUE, FIELD_TYPE, FIELD) \
3315 xkAddField(VALUE, FIELD_TYPE, FIELD)
3324 #define kAddEnumerator \
3345 #define kAddVersionEx(TYPE, FORMAT, FORMAT_VER, GUID, WRITE_METHOD, READ_METHOD) \
3346 xkAddVersionEx(TYPE, FORMAT, FORMAT_VER, GUID, WRITE_METHOD, READ_METHOD)
3368 #define kAddPrivateVersionEx(TYPE, FORMAT, FORMAT_VER, GUID, WRITE_METHOD, READ_METHOD) \
3369 xkAddPrivateVersionEx(TYPE, FORMAT, FORMAT_VER, GUID, WRITE_METHOD, READ_METHOD)
3384 #define kAddAbstractVersionEx(TYPE, FORMAT, FORMAT_VER, GUID) \
3385 xkAddAbstractVersion(TYPE, FORMAT, FORMAT_VER, GUID)
3394 #define kAddFlags(TYPE, FLAGS) \
3395 xkAddFlags(TYPE, FLAGS)
3418 #define kDefineDebugHints() \
3419 xkDefineDebugHints()
3435 #define kObj(TypeName_T, T_object) \
3436 TypeName_T##Class* obj K_ATTRIBUTE_UNUSED = xx##TypeName_T##_Cast(T_object, __FILE__, __LINE__)
3447 #define kObjR(TypeName_T, T_object) \
3448 TypeName_T##Class* obj K_ATTRIBUTE_UNUSED = x##TypeName_T##_CastRaw(T_object)
3461 #define kObjN(TypeName_T, VarName_obj, T_object) \
3462 TypeName_T##Class* VarName_obj = xx##TypeName_T##_Cast(T_object, __FILE__, __LINE__)
3474 #define kObjNR(TypeName_T, VarName_obj, T_object) \
3475 TypeName_T##Class* VarName_obj = x##TypeName_T##_CastRaw(T_object)
3482 #define kStaticObj(TypeName_T) \
3483 TypeName_T##Static* sobj = kStaticOf(TypeName_T)
3495 #define kCastClass_(TYPE, OBJECT) \
3496 xkCastClass_(TYPE, OBJECT)
3508 #define kCastVTable_(TYPE, OBJECT) \
3509 xkCastVTable_(TYPE, OBJECT)
3521 #define kCastIVTable_(IFACE, OBJECT) \
3522 xkCastIVTable_(IFACE, OBJECT)
3529 #define kDebugBreak() \
3532 #include <kApi/kApiDef.x.h>
k32f y
Y-coordinate value.
Definition: kApiDef.h:1340
kStatus k32s_Parse(k32s *value, const kChar *str)
Converts string to k32s value.
k64f height
Height of the rectangular cuboid.
Definition: kApiDef.h:1561
Represents a 64-unit, null-terminated, kChar sequence.
#define kALLOC_TRAIT_NON_ATOMIC
Allocates memory that cannot support atomic operations.
Definition: kApiDef.h:2290
Represents a 32-bit unsigned integer.
k32s y
Y-coordinate of the origin.
Definition: kApiDef.h:1496
kBool kChar_IsSpace(kChar ch)
Checks whether ASCII character is a some kind of white space character type.
Definition: kApiDef.h:424
kStatus kBool_Parse(kBool *value, const kChar *str)
Converts string to kBool value.
k64f height
Height of the rectangle.
Definition: kApiDef.h:1530
k32f x
X-coordinate of the origin.
Definition: kApiDef.h:1511
Rectangle structure with 32-bit signed integer fields.
Definition: kApiDef.h:1493
3D point structure with 32-bit floating-point fields.
Definition: kApiDef.h:1406
k64f x
X-coordinate of the origin.
Definition: kApiDef.h:1527
k32s width
Width of the rectangle.
Definition: kApiDef.h:1591
k8u b
Blue component value.
Definition: kApiDef.h:1676
k32s y
Y-coordinate value.
Definition: kApiDef.h:1394
#define kALLOC_TRAIT_SERIAL
Allocates memory suitable for single-threaded use only.
Definition: kApiDef.h:2289
k16s width
Width of the rectangle.
Definition: kApiDef.h:1481
32-bit color pixel structure (B/G/R/A).
Definition: kApiDef.h:1702
k16s y
Y-coordinate of the origin.
Definition: kApiDef.h:1480
k8u b
Blue component value.
Definition: kApiDef.h:1733
Represents a unique thread identifier.
2D point structure with 16-bit signed integer fields.
Definition: kApiDef.h:1309
kStatus(kCall * kFrameworkConstructorFx)(kObject *object, kAlloc allocator)
Required signature for kObject framework constructors.
Definition: kApiDef.h:2466
kChar kChar_ToLower(kChar ch)
Convert ASCII character to lower case.
Definition: kApiDef.h:400
kBool kAllocTrait_IsCudaManaged(kAllocTrait traits)
Reports whether the kALLOC_TRAIT_CUDA_MANAGED trait is present in an allocator trait bitset...
Definition: kApiDef.h:2364
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:572
Represents a 256-unit, null-terminated, kChar sequence.
kTypeName methodName
Method name (e.g. "Clone").
Definition: kApiDef.h:2475
kPointer receiver
Callback receiver context pointer.
Definition: kApiDef.h:1869
kTypeName name
Enumerator name (e.g. "kPIXEL_FORMAT_8BPP_GREYSCALE").
Definition: kApiDef.h:2501
#define kALLOC_TRAIT_CUDA_PINNED
Allocates Cuda pinned memory (host or device).
Definition: kApiDef.h:2292
Rotated rectangle structure with 32-bit floating-point fields.
Definition: kApiDef.h:1604
k64f y
Y-coordinate of the origin.
Definition: kApiDef.h:1528
k32s z
Z-coordinate value.
Definition: kApiDef.h:1395
Represents a void pointer.
32-bit color pixel structure (B/G/R/X).
Definition: kApiDef.h:1674
kStatus kSize_Parse(kSize *value, const kChar *str)
Converts string to kSize value.
k32f x
X-coordinate value.
Definition: kApiDef.h:1339
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:1758
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:2340
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:2124
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:2156
kBool kChar_IsLetter(kChar ch)
Checks whether ASCII character is a letter.
Definition: kApiDef.h:436
T kClamp(const T &v, const T &min, const T &max)
Returns a value limited to the specified range.
Definition: kApiDef.h:2076
k16s z
Z-coordinate value.
Definition: kApiDef.h:1380
T kMax(const T &a, const T &b)
Returns the maximum of two numbers.
Definition: kApiDef.h:2059
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:1589
Rotated rectangle structure with 32-bit signed integer fields.
Definition: kApiDef.h:1587
kBool kAllocTrait_IsSerial(kAllocTrait traits)
Reports whether the kALLOC_TRAIT_SERIAL trait is present in an allocator trait bitset.
Definition: kApiDef.h:2316
k32f yc
Y-coordinate of the rectangle center.
Definition: kApiDef.h:1607
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:1593
void * kPointer_ItemOffset(const void *pointer, kSSize itemIndex, kSize itemSize)
Gets a pointer to the Nth element of an array.
Definition: kApiDef.h:333
kTypeName displayName
Formatted display name (e.g. "8bpp Greyscale");.
Definition: kApiDef.h:2502
Represents type field information.
Definition: kApiDef.h:2485
k64f width
Width of the rectangular cuboid.
Definition: kApiDef.h:1560
Represents an 8-bit unsigned integer.
k64f x
X-coordinate of the origin.
Definition: kApiDef.h:1557
k64f depth
Depth of the rectangular cuboid.
Definition: kApiDef.h:1562
#define kInlineFx(TYPE)
Inline method declaration helper.
Definition: kApiDef.h:26
k64f y
Y-coordinate value.
Definition: kApiDef.h:1424
#define k64F_NULL
k64f invalid value.
Definition: kApiDef.h:219
k64f x
X-coordinate value.
Definition: kApiDef.h:1423
kBool kAllocTrait_IsNonAtomic(kAllocTrait traits)
Reports whether the kALLOC_TRAIT_NON_ATOMIC trait is present in an allocator trait bitset...
Definition: kApiDef.h:2328
Represents enumerator information.
Definition: kApiDef.h:2498
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:2291
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:2222
kStatus k16u_Parse(k16u *value, const kChar *str)
Converts string to k16u value.
k16s x
X-coordinate value.
Definition: kApiDef.h:1311
k16s y
Y-coordinate value.
Definition: kApiDef.h:1379
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:1848
kStatus k64f_Parse(k64f *value, const kChar *str)
Converts string to k64f value.
k32f angle
Rotation angle of the rectangle.
Definition: kApiDef.h:1610
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:1498
Rectangle structure with 32-bit floating-point fields.
Definition: kApiDef.h:1509
kBool kIsError(kStatus status)
Returns kTRUE if the given status value is not kOK.
Definition: kApiDef.h:560
k32s kVersion_Compare(kVersion version1, kVersion version2)
Returns an integral value indicating the relationship between the versions.
Definition: kApiDef.h:876
kBool kAllocTrait_IsCudaPinned(kAllocTrait traits)
Reports whether the kALLOC_TRAIT_CUDA_PINNED trait is present in an allocator trait bitset...
Definition: kApiDef.h:2352
k32s width
Width of the rectangle.
Definition: kApiDef.h:1497
#define k32F_NULL
k32f invalid value.
Definition: kApiDef.h:190
kStatus k32u_Parse(k32u *value, const kChar *str)
Converts string to k32u value.
k32s x
X-coordinate value.
Definition: kApiDef.h:1325
k32s height
Height of the rectangle.
Definition: kApiDef.h:1592
Rectangle structure with 64-bit floating-point fields.
Definition: kApiDef.h:1525
Represents a 128-unit, null-terminated, kChar sequence.
k32f x
X-coordinate value.
Definition: kApiDef.h:1408
k8u kVersion_Minor(kVersion version)
Returns the minor part of a version number.
Definition: kApiDef.h:900
#define kALLOC_TRAIT_CUDA_MANAGED
Allocates Cuda managed memory (host or device).
Definition: kApiDef.h:2293
kChar kChar_ToUpper(kChar ch)
Convert ASCII character to upper case.
Definition: kApiDef.h:412
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:1840
k8u kVersion_Major(kVersion version)
Returns the major part of a version number.
Definition: kApiDef.h:888
kBool k64f_IsNull(k64f value)
Tests for null k64f.
Definition: kApiDef.h:240
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:2172
k16s y
Y-coordinate value.
Definition: kApiDef.h:1312
Represents type method information.
Definition: kApiDef.h:2473
k16s x
X-coordinate value.
Definition: kApiDef.h:1378
k32f z
Z-coordinate value.
Definition: kApiDef.h:1410
kTypeName name
Field name.
Definition: kApiDef.h:2487
kStatus k32f_Parse(k32f *value, const kChar *str)
Converts string to k32f value.
k64f width
Width of the rectangle.
Definition: kApiDef.h:1529
k64f z
Z-coordinate value.
Definition: kApiDef.h:1425
Represents a callback function and context pointer.
Definition: kApiDef.h:1866
void kItemCopy(void *dest, const void *src, kSize size)
Performs a small copy with minimal overhead.
Definition: kApiDef.h:2257
k8u kVersion_Build(kVersion version)
Returns the build part of a version number.
Definition: kApiDef.h:924
k8u r
Red component value.
Definition: kApiDef.h:1706
2D point structure with 32-bit floating-point fields.
Definition: kApiDef.h:1337
k64f y
Y-coordinate of the origin.
Definition: kApiDef.h:1558
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:1453
k32s yc
Y-coordinate of the rectangle center.
Definition: kApiDef.h:1590
k8u r
Red component value.
Definition: kApiDef.h:1735
Represents a 32-bit signed integer.
Represents an Ethernet address.
Definition: kApiDef.h:1756
void * kPointer_ByteOffset(const void *pointer, kSSize offset)
Calculates a pointer address from a base address and a byte offset.
Definition: kApiDef.h:319
void(kCall * kFunction)()
Generic pointer to function.
Definition: kApiDef.h:28
k8u r
Red component value.
Definition: kApiDef.h:1678
k32f height
Height of the rectangle.
Definition: kApiDef.h:1609
kBool kChar_IsDigit(kChar ch)
Checks whether ASCII character is a digit.
Definition: kApiDef.h:448
k64f x
X-coordinate value.
Definition: kApiDef.h:1353
void kItemZero(void *dest, kSize size)
Zero-initializes a small amount of memory with minimal overhead.
Definition: kApiDef.h:2275
kVersion kVersion_Create(k32u major, k32u minor, k32u release, k32u build)
Creates a version value from its constituent parts.
Definition: kApiDef.h:823
kType type
Field type.
Definition: kApiDef.h:2488
k8u kVersion_Release(kVersion version)
Returns the release part of a version number.
Definition: kApiDef.h:912
kEndianness kEndianness_Host()
Reports the endianness of the current platform.
Definition: kApiDef.h:947
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:1351
kBool kEndianness_ShouldReverse(kEndianness endianness)
Reports whether byte ordering must be reversed to be consistent with the current platform.
Definition: kApiDef.h:958
kStatus(kCall * kCallbackFx)(kPointer receiver, kPointer sender, void *args)
Callback signature for a generic event handler.
Definition: kApiDef.h:1858
#define kALLOC_TRAIT_CUDA_DEVICE
Allocates Cuda device memory (device only).
Definition: kApiDef.h:2294
k8u g
Green component value.
Definition: kApiDef.h:1677
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:2388
T kMin(const T &a, const T &b)
Returns the minimum of two numbers.
Definition: kApiDef.h:2043
#define kALLOC_TRAIT_FOREIGN
Allocates memory in a foreign memory domain (non-host address space).
Definition: kApiDef.h:2288
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:1608
k8u b
Blue component value.
Definition: kApiDef.h:1704
k16s height
Height of the rectangle.
Definition: kApiDef.h:1482
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:1705
kStatus k64s_Parse(k64s *value, const kChar *str)
Converts string to k64s value.
k16s x
X-coordinate value.
Definition: kApiDef.h:1450
k32s x
X-coordinate value.
Definition: kApiDef.h:1393
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:1376
k32s value
Enumerator numeric value.
Definition: kApiDef.h:2500
kTypeName functionName
Full function name (e.g. "kObject_Clone").
Definition: kApiDef.h:2476
Represents a 16-bit signed integer.
k32f y
Y-coordinate of the origin.
Definition: kApiDef.h:1512
Represents a 32-bit floating-point number.
k64f y
Y-coordinate value.
Definition: kApiDef.h:1354
Represents a version number.
k8u a
Alpha component value.
Definition: kApiDef.h:1707
#define kOK
Operation successful.
Definition: kApiDef.h:539
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:2092
Represents an error code.
k64f z
Z-coordinate of the origin.
Definition: kApiDef.h:1559
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:1679
k32s y
Y-coordinate value.
Definition: kApiDef.h:1326
kSize offset
Offset of field within structure (bytes).
Definition: kApiDef.h:2489
k16s y
Y-coordinate value.
Definition: kApiDef.h:1451
#define kCall
kApi standard function calling convention.
Definition: kApiDef.h:15
k32f width
Width of the rectangle.
Definition: kApiDef.h:1513
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:1555
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:1477
kStatus k8u_Format(k8u value, kChar *buffer, kSize capacity)
Converts k8u value to string.
24-bit color pixel structure (B/G/R).
Definition: kApiDef.h:1731
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:346
k32s x
X-coordinate of the origin.
Definition: kApiDef.h:1495
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:1982
Represents a memory allocator trait.
k32f xc
X-coordinate of the rectangle center.
Definition: kApiDef.h:1606
2D point structure with 32-bit signed integer fields.
Definition: kApiDef.h:1323
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:1479
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:2490
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:2194
k32f height
Height of the rectangle.
Definition: kApiDef.h:1514
k8u g
Green component value.
Definition: kApiDef.h:1734
3D point structure with 64-bit floating-point fields.
Definition: kApiDef.h:1421
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:2012
kBool kAllocTrait_IsCudaDevice(kAllocTrait traits)
Reports whether the kALLOC_TRAIT_CUDA_DEVICE trait is present in an allocator trait bitset...
Definition: kApiDef.h:2376
3D point structure with 32-bit signed integer fields.
Definition: kApiDef.h:1391
k16s z
Z-coordinate value.
Definition: kApiDef.h:1452
kStatus k8u_Parse(k8u *value, const kChar *str)
Converts string to k8u value.
k32f y
Y-coordinate value.
Definition: kApiDef.h:1409
4D point structure with 16-bit signed integer fields.
Definition: kApiDef.h:1448
kStatus k8s_Parse(k8s *value, const kChar *str)
Converts string to k8s value.