Zen API
 All Classes Files Functions Variables Typedefs Friends Macros Modules Pages
kApiDef.h
Go to the documentation of this file.
1 
10 #ifndef K_API_API_DEF_H
11 #define K_API_API_DEF_H
12 
13 #include <kApi/kApiCfg.h>
14 
15 #define kCall xkCall
16 #define kDlCall xkDlCall
17 
18 #if defined(K_EMIT)
19 # define kFx(TYPE) kExportFx(TYPE)
20 # define kDx(TYPE) kExportDx(TYPE)
21 #else
22 # define kFx(TYPE) kImportFx(TYPE)
23 # define kDx(TYPE) kImportDx(TYPE)
24 #endif
25 
26 #define kInlineFx(TYPE) xkInlineFx(TYPE)
27 
28 typedef void (kCall* kFunction)();
29 
38 typedef xk8u k8u;
39 
41 #define k8U_MIN (0)
42 #define k8U_MAX (255U)
43 #define k8U_NULL (k8U_MAX)
44 
54 typedef xk16u k16u;
55 
57 #define k16U_MIN (0)
58 #define k16U_MAX (65535U)
59 #define k16U_NULL (k16U_MAX)
60 
70 typedef xk32u k32u;
71 
73 #define k32U_MIN (0)
74 #define k32U_MAX (4294967295U)
75 #define k32U_NULL (k32U_MAX)
76 
86 typedef xk64u k64u;
87 
89 #define k64U(CONST) xk64U(CONST)
90 #define k64U_MIN k64U(0)
91 #define k64U_MAX k64U(18446744073709551615)
92 #define k64U_NULL (k64U_MAX)
93 
95 #define kINFINITE k64U_MAX
96 
97 
105 typedef xk8s k8s;
106 
108 #define k8S_MAX (127)
109 #define k8S_MIN (-k8S_MAX -1)
110 #define k8S_NULL (k8S_MIN)
111 
121 typedef xk16s k16s;
122 
124 #define k16S_MAX (32767)
125 #define k16S_MIN (-k16S_MAX -1)
126 #define k16S_NULL (k16S_MIN)
127 
137 typedef xk32s k32s;
138 
140 #define k32S_MAX (2147483647)
141 #define k32S_MIN (-k32S_MAX -1)
142 #define k32S_NULL (k32S_MIN)
143 
153 typedef xk64s k64s;
154 
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)
160 
170 typedef k32s kBool;
171 
173 #define kFALSE (0)
174 #define kTRUE (1)
175 
185 typedef xk32f k32f;
186 
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)
192 
201 kInlineFx(kBool) k32f_IsNull(k32f value)
202 {
203  return (value == k32F_NULL);
204 }
205 
214 typedef xk64f k64f;
215 
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)
221 
231 kFx(k32s) k64f_IsNanOrInf(k64f value);
232 
241 {
242  return (value == k64F_NULL);
243 }
244 
253 typedef xkByte kByte;
254 
263 typedef xkSize kSize;
264 
266 #define kSIZE_MAX xkSIZE_MAX
267 #define kSIZE_NULL kSIZE_MAX
268 
280 kInlineFx(kSize) kSize_Align(kSize value, kSize to)
281 {
282  return ((value >> to) + !!(value & ((1 << to) - 1))) << to;
283 }
284 
291 typedef xkSSize kSSize;
292 
294 #define kSSIZE_MIN xkSSIZE_MIN
295 #define kSSIZE_MAX xkSSIZE_MAX
296 #define kSSIZE_NULL kSSIZE_MIN
297 
306 typedef void* kPointer;
307 
308 #define kNULL (0)
309 
310 
319 kInlineFx(void*) kPointer_ByteOffset(const void* pointer, kSSize offset)
320 {
321  return (kByte*)pointer + offset;
322 }
323 
333 kInlineFx(void*) kPointer_ItemOffset(const void* pointer, kSSize itemIndex, kSize itemSize)
334 {
335  return kPointer_ByteOffset(pointer, itemIndex*(kSSize)itemSize);
336 }
337 
346 kInlineFx(kSSize) kPointer_Diff(void* a, void* b)
347 {
348  return (kSSize)a - (kSSize)b;
349 }
350 
359 #define kPointer_ReadAs(POINTER, TYPE) \
360  (*(TYPE*)(POINTER))
361 
370 #define kPointer_WriteAs(POINTER, VALUE, TYPE) \
371  (*(TYPE*)(POINTER) = (TYPE)(VALUE))
372 
380 #define kIsNull(POINTER) \
381  ((POINTER) == kNULL)
382 
391 typedef xkChar kChar;
392 
401 {
402  return (ch >= 'A' && ch <= 'Z') ? (ch - 'A' + 'a') : ch;
403 }
404 
413 {
414  return (ch >= 'a' && ch <= 'z') ? (ch - 'a' + 'A') : ch;
415 }
416 
425 {
426  return ch == ' ';
427 }
428 
437 {
438  return ((ch >= 'a') && (ch <= 'z') ) || ((ch >= 'A') && (ch <= 'Z'));
439 }
440 
449 {
450  return ch >= '0' && ch <= '9';
451 }
452 
461 typedef kChar kText16[16];
462 
471 typedef kChar kText32[32];
472 
481 typedef kChar kText64[64];
482 
491 typedef kChar kText128[128];
492 
501 typedef kChar kText256[256];
502 
511 typedef k32s kStatus;
512 
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)
538 #define kERROR (0)
539 #define kOK (1)
540 
551 kFx(const kChar*) kStatus_Name(kStatus status);
552 
561 {
562  return status != kOK;
563 }
564 
573 {
574  return status == kOK;
575 }
576 
585 #define kCheck(EXPRESSION) \
586  xkCheck(EXPRESSION)
587 
597 #define kCheckTrue(EXPRESSION, STATUS) \
598  xkCheckTrue(EXPRESSION, STATUS)
599 
608 #define kCheckArgs(EXPRESSION) \
609  xkCheckArgs(EXPRESSION)
610 
619 #define kCheckState(EXPRESSION) \
620  xkCheckState(EXPRESSION)
621 
627 #define kTry \
628  xkTry
629 
636 #define kThrow(EXPRESSION) \
637  xkThrow(EXPRESSION)
638 
648 #define kTest(EXPRESSION) \
649  xkTest(EXPRESSION)
650 
661 #define kTestTrue(EXPRESSION, STATUS) \
662  xkTestTrue(EXPRESSION, STATUS)
663 
673 #define kTestArgs(EXPRESSION) \
674  xkTestArgs(EXPRESSION)
675 
685 #define kTestState(EXPRESSION) \
686  xkTestState(EXPRESSION)
687 
694 #define kCatch(STATUS_POINTER) \
695  xkCatch(STATUS_POINTER)
696 
705 #define kEndCatch(STATUS) \
706  xkEndCatch(STATUS)
707 
713 #define kFinally \
714  xkFinally
715 
724 #define kEndFinally() \
725  xkEndFinally()
726 
733 #define kCatchEx(STATUS_POINTER) \
734  xkCatchEx(STATUS_POINTER)
735 
746 #define kEndCatchEx(STATUS) \
747  xkEndCatchEx(STATUS)
748 
754 #define kFinallyEx \
755  xkFinallyEx
756 
765 #define kEndFinallyEx() \
766  xkEndFinallyEx()
767 
775 #define kAssert(EXPRESSION) \
776  xkAssert(EXPRESSION)
777 
788 #define kAssertType(OBJECT, SYMBOL) \
789  xkAssertType(OBJECT, SYMBOL)
790 
799 typedef k32u kVersion;
800 
801 #define kVERSION_NULL (k32U_NULL) // kVersion invalid value.
802 
813 kInlineFx(kVersion) kVersion_Create(k32u major, k32u minor, k32u release, k32u build)
814 {
815  return (major & 0xFF) << 24 |
816  (minor & 0xFF) << 16 |
817  (release & 0xFF) << 8 |
818  (build & 0xFF);
819 }
820 
831 #define kVersion_Stringify_(MAJOR, MINOR, RELEASE, BUILD) \
832  xkStringize(MAJOR) "." xkStringize(MINOR) "." xkStringize(RELEASE) "." xkStringize(BUILD)
833 
842 kFx(kStatus) kVersion_Parse(kVersion* version, const kChar* buffer);
843 
853 kFx(kStatus) kVersion_Format(kVersion version, kChar* buffer, kSize capacity);
854 
867 {
868  return (k32s)version1 - (k32s)version2;
869 }
870 
879 {
880  return (version >> 24) & 0xFF;
881 }
882 
891 {
892  return (version >> 16) & 0xFF;
893 }
894 
903 {
904  return (version >> 8) & 0xFF;
905 }
906 
915 {
916  return (version) & 0xFF;
917 }
918 
925 typedef k32s kEndianness;
926 
928 #define kENDIANNESS_LITTLE (1)
929 #define kENDIANNESS_BIG (2)
930 
937 kInlineFx(kEndianness) kEndianness_Host()
938 {
939  return K_ENDIANNESS;
940 }
941 
949 {
950  return endianness != kEndianness_Host();
951 }
952 
967 kFx(kStatus) k8u_Format(k8u value, kChar* buffer, kSize capacity);
968 
977 kFx(kStatus) k8u_Parse(k8u* value, const kChar* str);
978 
993 kFx(kStatus) k8s_Format(k8s value, kChar* buffer, kSize capacity);
994 
1003 kFx(kStatus) k8s_Parse(k8s* value, const kChar* str);
1004 
1019 kFx(kStatus) k16u_Format(k16u value, kChar* buffer, kSize capacity);
1020 
1029 kFx(kStatus) k16u_Parse(k16u* value, const kChar* str);
1030 
1045 kFx(kStatus) k16s_Format(k16s value, kChar* buffer, kSize capacity);
1046 
1055 kFx(kStatus) k16s_Parse(k16s* value, const kChar* str);
1056 
1071 kFx(kStatus) k32u_Format(k32u value, kChar* buffer, kSize capacity);
1072 
1081 kFx(kStatus) k32u_Parse(k32u* value, const kChar* str);
1082 
1097 kFx(kStatus) k32s_Format(k32s value, kChar* buffer, kSize capacity);
1098 
1107 kFx(kStatus) k32s_Parse(k32s* value, const kChar* str);
1108 
1123 kFx(kStatus) k64u_Format(k64u value, kChar* buffer, kSize capacity);
1124 
1133 kFx(kStatus) k64u_Parse(k64u* value, const kChar* str);
1134 
1149 kFx(kStatus) k64s_Format(k64s value, kChar* buffer, kSize capacity);
1150 
1159 kFx(kStatus) k64s_Parse(k64s* value, const kChar* str);
1160 
1175 kFx(kStatus) kBool_Format(kBool value, kChar* buffer, kSize capacity);
1176 
1185 kFx(kStatus) kBool_Parse(kBool* value, const kChar* str);
1186 
1201 kFx(kStatus) kSize_Format(kSize value, kChar* buffer, kSize capacity);
1202 
1211 kFx(kStatus) kSize_Parse(kSize* value, const kChar* str);
1212 
1227 kFx(kStatus) kSSize_Format(kSSize value, kChar* buffer, kSize capacity);
1228 
1237 kFx(kStatus) kSSize_Parse(kSSize* value, const kChar* str);
1238 
1253 kFx(kStatus) k32f_Format(k32f value, kChar* buffer, kSize capacity);
1254 
1263 kFx(kStatus) k32f_Parse(k32f* value, const kChar* str);
1264 
1279 kFx(kStatus) k64f_Format(k64f value, kChar* buffer, kSize capacity);
1280 
1289 kFx(kStatus) k64f_Parse(k64f* value, const kChar* str);
1290 
1299 typedef struct kPoint16s
1300 {
1303 } kPoint16s;
1304 
1313 typedef struct kPoint32s
1314 {
1317 } kPoint32s;
1318 
1327 typedef struct kPoint32f
1328 {
1331 } kPoint32f;
1332 
1341 typedef struct kPoint64f
1342 {
1345 } kPoint64f;
1346 
1356 #define kPoint_Init_(POINT, X, Y) xkPoint_Init_(POINT, X, Y)
1357 
1366 typedef struct kPoint3d16s
1367 {
1371 } kPoint3d16s;
1372 
1381 typedef struct kPoint3d32s
1382 {
1386 } kPoint3d32s;
1387 
1396 typedef struct kPoint3d32f
1397 {
1401 } kPoint3d32f;
1402 
1411 typedef struct kPoint3d64f
1412 {
1416 } kPoint3d64f;
1417 
1428 #define kPoint3d_Init_(POINT, X, Y, Z) xkPoint3d_Init_(POINT, X, Y, Z)
1429 
1438 typedef struct kPoint4d16s
1439 {
1444 } kPoint4d16s;
1445 
1457 #define kPoint4d_Init_(POINT, X, Y, Z, W) xkPoint4d_Init_(POINT, X, Y, Z, W)
1458 
1467 typedef struct kRect16s
1468 {
1473 } kRect16s;
1474 
1483 typedef struct kRect32s
1484 {
1489 } kRect32s;
1490 
1499 typedef struct kRect32f
1500 {
1505 } kRect32f;
1506 
1515 typedef struct kRect64f
1516 {
1521 } kRect64f;
1522 
1534 #define kRect_Init_(RECT, X, Y, W, H) \
1535  xkRect_Init_(RECT, X, Y, W, H)
1536 
1545 typedef struct kRect3d64f
1546 {
1553 } kRect3d64f;
1554 
1566 #define kRect3d_Init_(RECT, X, Y, Z, W, H, D) \
1567  xkRect3d_Init_(RECT, X, Y, Z, W, H, D)
1568 
1577 typedef struct kRotatedRect32s
1578 {
1584 } kRotatedRect32s;
1585 
1594 typedef struct kRotatedRect32f
1595 {
1601 } kRotatedRect32f;
1602 
1615 #define kRotatedRect_Init_(RECT, XC, YC, W, H, A) \
1616  xkRotatedRect_Init_(RECT, XC, YC, W, H, A)
1617 
1626 typedef k32s kPixelFormat;
1627 
1629 #define kPIXEL_FORMAT_NULL (0)
1630 #define kPIXEL_FORMAT_8BPP_GREYSCALE (1)
1631 #define kPIXEL_FORMAT_8BPP_CFA (2)
1632 #define kPIXEL_FORMAT_8BPC_BGRX (3)
1633 #define kPIXEL_FORMAT_1BPP_GREYSCALE (4)
1634 #define kPIXEL_FORMAT_16BPP_GREYSCALE (5)
1635 #define kPIXEL_FORMAT_8BPC_BGR (6)
1636 
1646 typedef k32s kCfa;
1647 
1649 #define kCFA_NONE (0)
1650 #define kCFA_BAYER_BGGR (1)
1651 #define kCFA_BAYER_GBRG (2)
1652 #define kCFA_BAYER_RGGB (3)
1653 #define kCFA_BAYER_GRBG (4)
1654 
1664 typedef struct kRgb
1665 {
1666  k8u b;
1667  k8u g;
1668  k8u r;
1669  k8u x;
1670 } kRgb;
1671 
1681 #define kRgb_Init_(RGB, R, G, B) \
1682  xkRgb_Init_(RGB, R, G, B)
1683 
1692 typedef struct kArgb
1693 {
1694  k8u b;
1695  k8u g;
1696  k8u r;
1697  k8u a;
1698 } kArgb;
1699 
1710 #define kArgb_Init_(ARGB, A, R, G, B) \
1711  xkArgb_Init_(ARGB, A, R, G, B)
1712 
1721 typedef struct kRgb24
1722 {
1723  k8u b;
1724  k8u g;
1725  k8u r;
1726 } kRgb24;
1727 
1737 #define kRgb24_Init_(RGB24, R, G, B) \
1738  xkRgb24_Init_(RGB24, R, G, B)
1739 
1746 typedef struct kMacAddress
1747 {
1749 } kMacAddress;
1750 
1757 typedef k32s kMemoryAlignment;
1758 
1760 #define kMEMORY_ALIGNMENT_8 (3)
1761 #define kMEMORY_ALIGNMENT_16 (4)
1762 #define kMEMORY_ALIGNMENT_32 (5)
1763 #define kMEMORY_ALIGNMENT_64 (6)
1764 #define kMEMORY_ALIGNMENT_128 (7)
1765 #define kMEMORY_ALIGNMENT_256 (8)
1766 #define kMEMORY_ALIGNMENT_512 (9)
1767 #define kMEMORY_ALIGNMENT_1024 (10)
1768 #define kMEMORY_ALIGNMENT_2048 (11)
1769 #define kMEMORY_ALIGNMENT_4096 (12)
1770 
1778 kInlineFx(kSize) kMemoryAlignment_Size(kMemoryAlignment alignment)
1779 {
1780  return ((kSize)1 << (kSize)alignment);
1781 }
1782 
1793 kFx(kStatus) kMacAddress_Parse(kMacAddress* address, const kChar* text);
1794 
1806 kFx(kStatus) kMacAddress_Format(kMacAddress address, kChar* text, kSize capacity);
1807 
1814 typedef k32s kComparison;
1815 
1816 #define kCOMPARISON_EQ (0)
1817 #define kCOMPARISON_NEQ (1)
1818 #define kCOMPARISON_LT (2)
1819 #define kCOMPARISON_LTE (3)
1820 #define kCOMPARISON_GT (4)
1821 #define kCOMPARISON_GTE (5)
1822 
1823 
1830 typedef kBool (kCall* kEqualsFx)(const void* item1, const void* item2);
1831 
1838 typedef kSize (kCall* kHashFx)(const void* item);
1839 
1848 typedef kStatus (kCall* kCallbackFx)(kPointer receiver, kPointer sender, void* args);
1849 
1856 typedef struct kCallback
1857 {
1858  kCallbackFx function;
1860 } kCallback;
1861 
1868 typedef k32s kFileMode;
1869 
1871 #define kFILE_MODE_READ (0x1)
1872 #define kFILE_MODE_WRITE (0x2)
1873 #define kFILE_MODE_UPDATE (0x4)
1874 
1882 typedef k32s kSeekOrigin;
1883 
1885 #define kSEEK_ORIGIN_BEGIN (0)
1886 #define kSEEK_ORIGIN_CURRENT (1)
1887 #define kSEEK_ORIGIN_END (2)
1888 
1896 typedef k32s kCompressionType;
1897 
1899 #define kCOMPRESSION_TYPE_NULL (0)
1900 #define kCOMPRESSION_TYPE_ZSTD (1)
1901 
1902 
1910 typedef k32s kCompressionPreset;
1911 
1913 #define kCOMPRESSION_PRESET_MIN (-1)
1914 #define kCOMPRESSION_PRESET_FAST (-2)
1915 #define kCOMPRESSION_PRESET_DEFAULT (-3)
1916 #define kCOMPRESSION_PRESET_DENSE (-4)
1917 #define kCOMPRESSION_PRESET_MAX (-5)
1918 
1929 typedef k64u kLogOption;
1930 
1932 #define kLOG_OPTION_WARNING (0x1)
1933 #define kLOG_OPTION_ERROR (0x2)
1934 #define kLOG_OPTION_PLATFORM (0x10)
1935 
1945 #define kCountOf(CARRAY) \
1946  (sizeof(CARRAY)/sizeof(CARRAY[0]))
1947 
1957 #define kCast(TYPE, ITEM) \
1958  ((TYPE)(ITEM))
1959 
1960 #if (K_CPP_VERSION >= K_CPP_VERSION_2011)
1961 
1971 template <typename T>
1972 static kInline typename std::enable_if<std::is_unsigned<T>::value, T>::type kAbs(const T& v)
1973 {
1974  return v;
1975 }
1976 
1986 template <typename T>
1987 static kInline typename std::enable_if<!std::is_unsigned<T>::value, T>::type kAbs(const T& v)
1988 {
1989  return (v >= T()) ? v : -v;
1990 }
1991 
2001 template <typename T>
2002 static kInline typename std::enable_if<std::is_unsigned<T>::value, T>::type kSign(const T& v)
2003 {
2004  return v > T();
2005 }
2006 
2016 template <typename T>
2017 static kInline typename std::enable_if<!std::is_unsigned<T>::value, T>::type kSign(const T& v)
2018 {
2019  return (v > T()) - (v < T());
2020 }
2021 
2032 template <typename T>
2033 kInlineFx(T) kMin(const T& a, const T& b)
2034 {
2035  return (a < b) ? a : b;
2036 }
2037 
2048 template <typename T>
2049 kInlineFx(T) kMax(const T& a, const T& b)
2050 {
2051  return (a > b) ? a : b;
2052 }
2053 
2065 template <typename T>
2066 kInlineFx(T) kClamp(const T& v, const T& min, const T& max)
2067 {
2068  return kMin(kMax(v, min), max);
2069 }
2070 
2081 template <typename T>
2082 static kInline typename std::enable_if<std::is_unsigned<T>::value, T>::type kDivideFloor(const T& a, const T& b)
2083 {
2084  return a / b;
2085 }
2086 
2097 template <typename T>
2098 static kInline typename std::enable_if<!std::is_unsigned<T>::value, T>::type kDivideFloor(const T& a, const T& b)
2099 {
2100  return ((kSign(a) * kSign(b)) >= T()) ? a / b : ((a / b) - ((a % b) != T()));
2101 }
2102 
2113 template <typename T>
2114 static kInline typename std::enable_if<std::is_unsigned<T>::value, T>::type kDivideCeil(const T& a, const T& b)
2115 {
2116  return (a / b) + ((a % b) != T());
2117 }
2118 
2129 template <typename T>
2130 static kInline typename std::enable_if<!std::is_unsigned<T>::value, T>::type kDivideCeil(const T& a, const T& b)
2131 {
2132  return ((kSign(a) * kSign(b)) <= T()) ? a / b : ((a / b) + ((a % b) != T()));
2133 }
2134 
2145 template <typename T>
2146 kInlineFx(T) kQuantizeFloor(const T& value, const T& granularity)
2147 {
2148  return kDivideFloor(value, granularity) * granularity;
2149 }
2150 
2161 template <typename T>
2162 kInlineFx(T) kQuantizeCeil(const T& value, const T& granularity)
2163 {
2164  return kDivideCeil(value, granularity) * granularity;
2165 }
2166 
2183 template <typename T>
2184 kInlineFx(T) kAdjustFloor(const T& value, const T& min, const T& max, const T& granularity)
2185 {
2186  typedef typename std::make_unsigned<T>::type U;
2187  U relativeValue = (value >= min) ? (U) (value - min) : U();
2188  U relativeMax = (max >= min) ? (U) (max - min) : U();
2189  U quantizedRelativeMax = kQuantizeFloor<U>(relativeMax, granularity);
2190  U limitedRelativeValue = kMin<U>(relativeValue, quantizedRelativeMax);
2191 
2192  return (T) kQuantizeFloor<U>(limitedRelativeValue, granularity) + min;
2193 }
2194 
2211 template <typename T>
2212 kInlineFx(T) kAdjustCeil(const T& value, const T& min, const T& max, const T& granularity)
2213 {
2214  typedef typename std::make_unsigned<T>::type U;
2215  U relativeValue = (value >= min) ? (U) (value - min) : U();
2216  U relativeMax = (max >= min) ? (U) (max - min) : U();
2217  U quantizedRelativeMax = kQuantizeFloor<U>(relativeMax, granularity);
2218  U limitedRelativeValue = kMin<U>(relativeValue, quantizedRelativeMax);
2219 
2220  return (T) kQuantizeCeil<U>(limitedRelativeValue, granularity) + min;
2221 }
2222 
2223 #endif
2224 
2230 #define kZero(VALUE) \
2231  memset(&VALUE, 0, sizeof(VALUE))
2232 
2247 kInlineFx(void) kItemCopy(void* dest, const void* src, kSize size)
2248 {
2249  memcpy(dest, src, size);
2250 }
2251 
2265 kInlineFx(void) kItemZero(void* dest, kSize size)
2266 {
2267  memset(dest, 0, size);
2268 }
2269 
2275 typedef k32s kAllocTrait;
2276 
2278 #define kALLOC_TRAIT_FOREIGN (0x00000001)
2279 #define kALLOC_TRAIT_SERIAL (0x00000002)
2280 #define kALLOC_TRAIT_NON_ATOMIC (0x00000004)
2281 #define kALLOC_TRAIT_CONTEXT (0x00000008)
2282 #define kALLOC_TRAIT_CUDA_PINNED (0x00010000)
2283 #define kALLOC_TRAIT_CUDA_MANAGED (0x00020000)
2284 #define kALLOC_TRAIT_CUDA_DEVICE (0x01000000)
2285 
2294 kInlineFx(kBool) kAllocTrait_IsForeign(kAllocTrait traits)
2295 {
2296  return (traits & kALLOC_TRAIT_FOREIGN) != 0;
2297 }
2298 
2307 {
2308  return (traits & kALLOC_TRAIT_SERIAL) != 0;
2309 }
2310 
2319 {
2320  return (traits & kALLOC_TRAIT_NON_ATOMIC) != 0;
2321 }
2322 
2331 {
2332  return (traits & kALLOC_TRAIT_CONTEXT) != 0;
2333 }
2334 
2343 {
2344  return (traits & kALLOC_TRAIT_CUDA_PINNED) != 0;
2345 }
2346 
2355 {
2356  return (traits & kALLOC_TRAIT_CUDA_MANAGED) != 0;
2357 }
2358 
2367 {
2368  return (traits & kALLOC_TRAIT_CUDA_DEVICE) != 0;
2369 }
2370 
2379 {
2381 }
2382 
2390 typedef kSize kThreadId;
2391 
2400 kFx(kBool) kThreadId_Compare(kThreadId a, kThreadId b);
2401 
2409 typedef k32s kThreadPriorityClass;
2410 
2412 #define kTHREAD_PRIORITY_CLASS_LOW (-1)
2413 #define kTHREAD_PRIORITY_CLASS_NORMAL (0)
2414 #define kTHREAD_PRIORITY_CLASS_HIGH (1)
2415 
2417 /*
2418  * Forward declarations
2419  */
2420 
2421 typedef void* kObject;
2422 typedef kObject kType;
2423 typedef kObject kAlloc;
2424 
2426 #define kTypeName kText64
2427 
2435 typedef k32u kTypeFlags;
2436 
2438 #define kTYPE_FLAGS_CLASS (0x01)
2439 #define kTYPE_FLAGS_INTERFACE (0x02)
2440 #define kTYPE_FLAGS_VALUE (0x04)
2441 #define kTYPE_FLAGS_ENUM (0x08)
2442 #define kTYPE_FLAGS_ABSTRACT (0x20)
2443 #define kTYPE_FLAGS_ARRAY_VALUE (0x40)
2444 #define kTYPE_FLAGS_PRIMITIVE (0x80)
2445 
2453 typedef kPointer kTypeVersion;
2454 
2456 typedef kStatus (kCall* kFrameworkConstructorFx)(kObject* object, kAlloc allocator);
2457 
2463 typedef struct kMethodInfo
2464 {
2465  kTypeName methodName;
2466  kTypeName functionName;
2467  kFunction function;
2468 } kMethodInfo;
2469 
2475 typedef struct kFieldInfo
2476 {
2477  kTypeName name;
2478  kType type;
2481 } kFieldInfo;
2482 
2488 typedef struct kEnumeratorInfo
2489 {
2491  kTypeName name;
2492  kTypeName displayName;
2493 } kEnumeratorInfo;
2494 
2520 #define kTypeOf(SYMBOL) \
2521  xkTypeOf(SYMBOL)
2522 
2548 #define kAssemblyOf(SYMBOL) \
2549  xkAssemblyOf(SYMBOL)
2550 
2559 #define kStaticOf(SYMBOL) \
2560  xkStaticOf(SYMBOL)
2561 
2569 #define kDeprecate(SYMBOL) \
2570  xkDeprecate(#SYMBOL)
2571 
2580 #define kWarn(MESSAGE) \
2581  xkWarn(MESSAGE)
2582 
2583 /*
2584 *
2585 * Type Declaration/Definition Macros, Generation 1.
2586 *
2587 * These type declaration/definition macros continue to be supported. However, consider using the Generation 2
2588 * macros (defined below) in new code.
2589 *
2590 */
2591 
2599 #define kDeclareAssembly(PREFIX, SYMBOL) \
2600  xkDeclareAssembly(PREFIX, SYMBOL)
2601 
2611 #define kBeginAssembly(PREFIX, SYMBOL, VERSION, PLATFORM_VERSION) \
2612  xkBeginAssembly(PREFIX, SYMBOL, VERSION, PLATFORM_VERSION)
2613 
2619 #define kEndAssembly() \
2620  xkEndAssembly()
2621 
2630 #define kDeclareValue(PREFIX, SYMBOL, BASE) \
2631  xkDeclareValue(PREFIX, SYMBOL, BASE)
2632 
2641 #define kBeginValue(PREFIX, SYMBOL, BASE) \
2642  xkBeginValue(PREFIX, SYMBOL, BASE)
2643 
2649 #define kEndValue() \
2650  xkEndValue()
2651 
2660 #define kDeclareEnum(PREFIX, SYMBOL, BASE) \
2661  xkDeclareEnum(PREFIX, SYMBOL, BASE)
2662 
2671 #define kBeginEnum(PREFIX, SYMBOL, BASE) \
2672  xkBeginEnum(PREFIX, SYMBOL, BASE)
2673 
2679 #define kEndEnum() \
2680  xkEndEnum()
2681 
2690 #define kDeclareArrayValue(PREFIX, SYMBOL, BASE) \
2691  xkDeclareArrayValue(PREFIX, SYMBOL, BASE)
2692 
2702 #define kBeginArrayValue(PREFIX, SYMBOL, TYPE, BASE) \
2703  xkBeginArrayValue(PREFIX, SYMBOL, TYPE, BASE)
2704 
2710 #define kEndArrayValue() \
2711  xkEndArrayValue()
2712 
2721 #define kDeclareInterface(PREFIX, SYMBOL, BASE) \
2722  xkDeclareInterface(PREFIX, SYMBOL, BASE)
2723 
2732 #define kBeginInterface(PREFIX, SYMBOL, BASE) \
2733  xkBeginInterface(PREFIX, SYMBOL, BASE)
2734 
2740 #define kEndInterface() \
2741  xkEndInterface()
2742 
2751 #define kDeclareFullClass(PREFIX, SYMBOL, BASE) \
2752  xkDeclareFullClass(PREFIX, SYMBOL, BASE)
2753 
2762 #define kBeginFullClass(PREFIX, SYMBOL, BASE) \
2763  xkBeginFullClass(PREFIX, SYMBOL, BASE)
2764 
2770 #define kEndFullClass() \
2771  xkEndFullClass()
2772 
2781 #define kDeclareVirtualClass(PREFIX, SYMBOL, BASE) \
2782  xkDeclareVirtualClass(PREFIX, SYMBOL, BASE)
2783 
2792 #define kBeginVirtualClass(PREFIX, SYMBOL, BASE) \
2793  xkBeginVirtualClass(PREFIX, SYMBOL, BASE)
2794 
2800 #define kEndVirtualClass() \
2801  xkEndVirtualClass()
2802 
2810 #define kDeclareStaticClass(PREFIX, SYMBOL) \
2811  xkDeclareStaticClass(PREFIX, SYMBOL)
2812 
2820 #define kBeginStaticClass(PREFIX, SYMBOL) \
2821  xkBeginStaticClass(PREFIX, SYMBOL)
2822 
2828 #define kEndStaticClass() \
2829  xkEndStaticClass()
2830 
2839 #define kDeclareClass(PREFIX, SYMBOL, BASE) \
2840  xkDeclareClass(PREFIX, SYMBOL, BASE)
2841 
2850 #define kBeginClass(PREFIX, SYMBOL, BASE) \
2851  xkBeginClass(PREFIX, SYMBOL, BASE)
2852 
2858 #define kEndClass() \
2859  xkEndClass()
2860 
2861 /*
2862 *
2863 * Type Declaration/Definition Macros, Generation 2.
2864 *
2865 * These macros are used to declare and define elements of the type system, such
2866 * as assemblies, classes and values. These macros supersede the Generation 1 macros,
2867 * defined above.
2868 *
2869 */
2870 
2878 #define kDeclareAssemblyEx(PREFIX, SYMBOL) \
2879  xkDeclareAssemblyEx(PREFIX, SYMBOL)
2880 
2890 #define kBeginAssemblyEx(PREFIX, SYMBOL, VERSION, PLATFORM_VERSION) \
2891  xkBeginAssemblyEx(PREFIX, SYMBOL, VERSION, PLATFORM_VERSION)
2892 
2898 #define kEndAssemblyEx() \
2899  xkEndAssemblyEx()
2900 
2909 #define kDeclareValueEx(PREFIX, SYMBOL, BASE) \
2910  xkDeclareValueEx(PREFIX, SYMBOL, BASE)
2911 
2919 #define kBeginValueEx(PREFIX, SYMBOL) \
2920  xkBeginValueEx(PREFIX, SYMBOL)
2921 
2927 #define kEndValueEx() \
2928  xkEndValueEx()
2929 
2938 #define kDeclareEnumEx(PREFIX, SYMBOL, BASE) \
2939  xkDeclareEnumEx(PREFIX, SYMBOL, BASE)
2940 
2948 #define kBeginEnumEx(PREFIX, SYMBOL) \
2949  xkBeginEnumEx(PREFIX, SYMBOL)
2950 
2956 #define kEndEnumEx() \
2957  xkEndEnumEx()
2958 
2967 #define kDeclareArrayValueEx(PREFIX, SYMBOL, BASE) \
2968  xkDeclareArrayValueEx(PREFIX, SYMBOL, BASE)
2969 
2978 #define kBeginArrayValueEx(PREFIX, SYMBOL, TYPE) \
2979  xkBeginArrayValueEx(PREFIX, SYMBOL, TYPE)
2980 
2986 #define kEndArrayValueEx() \
2987  xkEndArrayValueEx()
2988 
2997 #define kDeclareInterfaceEx(PREFIX, SYMBOL, BASE) \
2998  xkDeclareInterfaceEx(PREFIX, SYMBOL, BASE)
2999 
3007 #define kBeginInterfaceEx(PREFIX, SYMBOL) \
3008  xkBeginInterfaceEx(PREFIX, SYMBOL)
3009 
3015 #define kEndInterfaceEx() \
3016  xkEndInterfaceEx()
3017 
3026 #define kDeclareFullClassEx(PREFIX, SYMBOL, BASE) \
3027  xkDeclareFullClassEx(PREFIX, SYMBOL, BASE)
3028 
3036 #define kBeginFullClassEx(PREFIX, SYMBOL) \
3037  xkBeginFullClassEx(PREFIX, SYMBOL)
3038 
3044 #define kEndFullClassEx() \
3045  xkEndFullClassEx()
3046 
3055 #define kDeclareVirtualClassEx(PREFIX, SYMBOL, BASE) \
3056  xkDeclareVirtualClassEx(PREFIX, SYMBOL, BASE)
3057 
3065 #define kBeginVirtualClassEx(PREFIX, SYMBOL) \
3066  xkBeginVirtualClassEx(PREFIX, SYMBOL)
3067 
3073 #define kEndVirtualClassEx() \
3074  xkEndVirtualClassEx()
3075 
3083 #define kDeclareStaticClassEx(PREFIX, SYMBOL) \
3084  xkDeclareStaticClassEx(PREFIX, SYMBOL)
3085 
3093 #define kBeginStaticClassEx(PREFIX, SYMBOL) \
3094  xkBeginStaticClassEx(PREFIX, SYMBOL)
3095 
3101 #define kEndStaticClassEx() \
3102  xkEndStaticClassEx()
3103 
3112 #define kDeclareClassEx(PREFIX, SYMBOL, BASE) \
3113  xkDeclareClassEx(PREFIX, SYMBOL, BASE)
3114 
3122 #define kBeginClassEx(PREFIX, SYMBOL) \
3123  xkBeginClassEx(PREFIX, SYMBOL)
3124 
3130 #define kEndClassEx() \
3131  xkEndClassEx()
3132 
3133 /*
3134 *
3135 * Type Implementation Macros
3136 *
3137 * These macros are used to provide type-specific details. They are typically used between
3138 * type definition begin/end macros (e.g., kBeginClass/kEndClass).
3139 *
3140 */
3141 
3148 #define kAddDependency(SYMBOL) \
3149  xkAddDependency(SYMBOL)
3150 
3157 #define kAddType(SYMBOL) \
3158  xkAddType(SYMBOL)
3159 
3170 #define kAddPriority(SYMBOL) \
3171  xkAddPriority(SYMBOL)
3172 
3181 #define kAddStatic(SYMBOL) \
3182  xkAddStatic(SYMBOL)
3183 
3191 #define kAddInterface(SYMBOL, IFACE) \
3192  xkAddInterface(SYMBOL, IFACE)
3193 
3212 #define kAddFrameworkConstructor(SYMBOL, CTOR) \
3213  xkAddFrameworkConstructor(SYMBOL, CTOR)
3214 
3233 #define kAddPrivateFrameworkConstructor(SYMBOL, CTOR) \
3234  xkAddPrivateFrameworkConstructor(SYMBOL, CTOR)
3235 
3243 #define kAddMethod(SYMBOL, METHOD) \
3244  xkAddMethod(SYMBOL, METHOD)
3245 
3254 #define kAddVMethod(IN_TYPE, FROM_TYPE, METHOD) \
3255  xkAddVMethod(IN_TYPE, FROM_TYPE, METHOD)
3256 
3267 #define kAddPrivateVMethod(IN_TYPE, FROM_TYPE, METHOD) \
3268  xkAddPrivateVMethod(IN_TYPE, FROM_TYPE, METHOD)
3269 
3279 #define kAddIVMethod(IN_TYPE, FROM_IFACE, IMETHOD, CMETHOD) \
3280  xkAddIVMethod(IN_TYPE, FROM_IFACE, IMETHOD, CMETHOD)
3281 
3293 #define kAddPrivateIVMethod(IN_TYPE, FROM_IFACE, IMETHOD, CMETHOD) \
3294  xkAddPrivateIVMethod(IN_TYPE, FROM_IFACE, IMETHOD, CMETHOD)
3295 
3304 #define kAddField(VALUE, FIELD_TYPE, FIELD) \
3305  xkAddField(VALUE, FIELD_TYPE, FIELD)
3306 
3314 #define kAddEnumerator \
3315  xkAddEnumerator
3316 
3335 #define kAddVersionEx(TYPE, FORMAT, FORMAT_VER, GUID, WRITE_METHOD, READ_METHOD) \
3336  xkAddVersionEx(TYPE, FORMAT, FORMAT_VER, GUID, WRITE_METHOD, READ_METHOD)
3337 
3358 #define kAddPrivateVersionEx(TYPE, FORMAT, FORMAT_VER, GUID, WRITE_METHOD, READ_METHOD) \
3359  xkAddPrivateVersionEx(TYPE, FORMAT, FORMAT_VER, GUID, WRITE_METHOD, READ_METHOD)
3360 
3374 #define kAddAbstractVersionEx(TYPE, FORMAT, FORMAT_VER, GUID) \
3375  xkAddAbstractVersion(TYPE, FORMAT, FORMAT_VER, GUID)
3376 
3384 #define kAddFlags(TYPE, FLAGS) \
3385  xkAddFlags(TYPE, FLAGS)
3386 
3408 #define kDefineDebugHints() \
3409  xkDefineDebugHints()
3410 
3411 /*
3412 *
3413 * Method Implementation Macros
3414 *
3415 * These macros are used in the implementation of class methods.
3416 *
3417 */
3418 
3425 #define kObj(TypeName_T, T_object) \
3426  TypeName_T##Class* obj K_ATTRIBUTE_UNUSED = xx##TypeName_T##_Cast(T_object, __FILE__, __LINE__)
3427 
3437 #define kObjR(TypeName_T, T_object) \
3438  TypeName_T##Class* obj K_ATTRIBUTE_UNUSED = x##TypeName_T##_CastRaw(T_object)
3439 
3451 #define kObjN(TypeName_T, VarName_obj, T_object) \
3452  TypeName_T##Class* VarName_obj = xx##TypeName_T##_Cast(T_object, __FILE__, __LINE__)
3453 
3464 #define kObjNR(TypeName_T, VarName_obj, T_object) \
3465  TypeName_T##Class* VarName_obj = x##TypeName_T##_CastRaw(T_object)
3466 
3472 #define kStaticObj(TypeName_T) \
3473  TypeName_T##Static* sobj = kStaticOf(TypeName_T)
3474 
3485 #define kCastClass_(TYPE, OBJECT) \
3486  xkCastClass_(TYPE, OBJECT)
3487 
3498 #define kCastVTable_(TYPE, OBJECT) \
3499  xkCastVTable_(TYPE, OBJECT)
3500 
3511 #define kCastIVTable_(IFACE, OBJECT) \
3512  xkCastIVTable_(IFACE, OBJECT)
3513 
3519 #define kDebugBreak() \
3520  xkDebugBreak()
3521 
3522 #include <kApi/kApiDef.x.h>
3523 
3524 #endif
k32f y
Y-coordinate value.
Definition: kApiDef.h:1330
kStatus k32s_Parse(k32s *value, const kChar *str)
Converts string to k32s value.
k64f height
Height of the rectangular cuboid.
Definition: kApiDef.h:1551
Represents a 64-unit, null-terminated, kChar sequence.
#define kALLOC_TRAIT_NON_ATOMIC
Allocates memory that cannot support atomic operations.
Definition: kApiDef.h:2280
Represents a 32-bit unsigned integer.
k32s y
Y-coordinate of the origin.
Definition: kApiDef.h:1486
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:1520
k32f x
X-coordinate of the origin.
Definition: kApiDef.h:1501
Rectangle structure with 32-bit signed integer fields.
Definition: kApiDef.h:1483
3D point structure with 32-bit floating-point fields.
Definition: kApiDef.h:1396
k64f x
X-coordinate of the origin.
Definition: kApiDef.h:1517
k32s width
Width of the rectangle.
Definition: kApiDef.h:1581
k8u b
Blue component value.
Definition: kApiDef.h:1666
k32s y
Y-coordinate value.
Definition: kApiDef.h:1384
#define kALLOC_TRAIT_SERIAL
Allocates memory suitable for single-threaded use only.
Definition: kApiDef.h:2279
k16s width
Width of the rectangle.
Definition: kApiDef.h:1471
32-bit color pixel structure (B/G/R/A).
Definition: kApiDef.h:1692
k16s y
Y-coordinate of the origin.
Definition: kApiDef.h:1470
k8u b
Blue component value.
Definition: kApiDef.h:1723
Represents a unique thread identifier.
2D point structure with 16-bit signed integer fields.
Definition: kApiDef.h:1299
kStatus(kCall * kFrameworkConstructorFx)(kObject *object, kAlloc allocator)
Required signature for kObject framework constructors.
Definition: kApiDef.h:2456
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:2354
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:2465
kPointer receiver
Callback receiver context pointer.
Definition: kApiDef.h:1859
kTypeName name
Enumerator name (e.g. "kPIXEL_FORMAT_8BPP_GREYSCALE").
Definition: kApiDef.h:2491
#define kALLOC_TRAIT_CUDA_PINNED
Allocates Cuda pinned memory (host or device).
Definition: kApiDef.h:2282
Rotated rectangle structure with 32-bit floating-point fields.
Definition: kApiDef.h:1594
k64f y
Y-coordinate of the origin.
Definition: kApiDef.h:1518
k32s z
Z-coordinate value.
Definition: kApiDef.h:1385
Represents a void pointer.
32-bit color pixel structure (B/G/R/X).
Definition: kApiDef.h:1664
kStatus kSize_Parse(kSize *value, const kChar *str)
Converts string to kSize value.
k32f x
X-coordinate value.
Definition: kApiDef.h:1329
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:1748
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:2330
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:2114
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:2146
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:2066
k16s z
Z-coordinate value.
Definition: kApiDef.h:1370
T kMax(const T &a, const T &b)
Returns the maximum of two numbers.
Definition: kApiDef.h:2049
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:1579
Rotated rectangle structure with 32-bit signed integer fields.
Definition: kApiDef.h:1577
kBool kAllocTrait_IsSerial(kAllocTrait traits)
Reports whether the kALLOC_TRAIT_SERIAL trait is present in an allocator trait bitset.
Definition: kApiDef.h:2306
k32f yc
Y-coordinate of the rectangle center.
Definition: kApiDef.h:1597
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:1583
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:2492
Represents type field information.
Definition: kApiDef.h:2475
k64f width
Width of the rectangular cuboid.
Definition: kApiDef.h:1550
Represents an 8-bit unsigned integer.
k64f x
X-coordinate of the origin.
Definition: kApiDef.h:1547
k64f depth
Depth of the rectangular cuboid.
Definition: kApiDef.h:1552
#define kInlineFx(TYPE)
Inline method declaration helper.
Definition: kApiDef.h:26
k64f y
Y-coordinate value.
Definition: kApiDef.h:1414
#define k64F_NULL
k64f invalid value.
Definition: kApiDef.h:219
k64f x
X-coordinate value.
Definition: kApiDef.h:1413
kBool kAllocTrait_IsNonAtomic(kAllocTrait traits)
Reports whether the kALLOC_TRAIT_NON_ATOMIC trait is present in an allocator trait bitset...
Definition: kApiDef.h:2318
Represents enumerator information.
Definition: kApiDef.h:2488
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:2281
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:2212
kStatus k16u_Parse(k16u *value, const kChar *str)
Converts string to k16u value.
k16s x
X-coordinate value.
Definition: kApiDef.h:1301
k16s y
Y-coordinate value.
Definition: kApiDef.h:1369
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:1838
kStatus k64f_Parse(k64f *value, const kChar *str)
Converts string to k64f value.
k32f angle
Rotation angle of the rectangle.
Definition: kApiDef.h:1600
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:1488
Rectangle structure with 32-bit floating-point fields.
Definition: kApiDef.h:1499
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:866
kBool kAllocTrait_IsCudaPinned(kAllocTrait traits)
Reports whether the kALLOC_TRAIT_CUDA_PINNED trait is present in an allocator trait bitset...
Definition: kApiDef.h:2342
k32s width
Width of the rectangle.
Definition: kApiDef.h:1487
#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:1315
Pixel format descriptor.
k32s height
Height of the rectangle.
Definition: kApiDef.h:1582
Rectangle structure with 64-bit floating-point fields.
Definition: kApiDef.h:1515
Represents a 128-unit, null-terminated, kChar sequence.
k32f x
X-coordinate value.
Definition: kApiDef.h:1398
k8u kVersion_Minor(kVersion version)
Returns the minor part of a version number.
Definition: kApiDef.h:890
#define kALLOC_TRAIT_CUDA_MANAGED
Allocates Cuda managed memory (host or device).
Definition: kApiDef.h:2283
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:1830
k8u kVersion_Major(kVersion version)
Returns the major part of a version number.
Definition: kApiDef.h:878
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:2162
k16s y
Y-coordinate value.
Definition: kApiDef.h:1302
Represents type method information.
Definition: kApiDef.h:2463
k16s x
X-coordinate value.
Definition: kApiDef.h:1368
k32f z
Z-coordinate value.
Definition: kApiDef.h:1400
kTypeName name
Field name.
Definition: kApiDef.h:2477
kStatus k32f_Parse(k32f *value, const kChar *str)
Converts string to k32f value.
k64f width
Width of the rectangle.
Definition: kApiDef.h:1519
k64f z
Z-coordinate value.
Definition: kApiDef.h:1415
Represents a callback function and context pointer.
Definition: kApiDef.h:1856
void kItemCopy(void *dest, const void *src, kSize size)
Performs a small copy with minimal overhead.
Definition: kApiDef.h:2247
k8u kVersion_Build(kVersion version)
Returns the build part of a version number.
Definition: kApiDef.h:914
k8u r
Red component value.
Definition: kApiDef.h:1696
2D point structure with 32-bit floating-point fields.
Definition: kApiDef.h:1327
k64f y
Y-coordinate of the origin.
Definition: kApiDef.h:1548
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:1443
k32s yc
Y-coordinate of the rectangle center.
Definition: kApiDef.h:1580
k8u r
Red component value.
Definition: kApiDef.h:1725
Represents a 32-bit signed integer.
Represents an Ethernet address.
Definition: kApiDef.h:1746
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:1668
k32f height
Height of the rectangle.
Definition: kApiDef.h:1599
kBool kChar_IsDigit(kChar ch)
Checks whether ASCII character is a digit.
Definition: kApiDef.h:448
k64f x
X-coordinate value.
Definition: kApiDef.h:1343
void kItemZero(void *dest, kSize size)
Zero-initializes a small amount of memory with minimal overhead.
Definition: kApiDef.h:2265
kVersion kVersion_Create(k32u major, k32u minor, k32u release, k32u build)
Creates a version value from its constituent parts.
Definition: kApiDef.h:813
kType type
Field type.
Definition: kApiDef.h:2478
k8u kVersion_Release(kVersion version)
Returns the release part of a version number.
Definition: kApiDef.h:902
kEndianness kEndianness_Host()
Reports the endianness of the current platform.
Definition: kApiDef.h:937
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:1341
kBool kEndianness_ShouldReverse(kEndianness endianness)
Reports whether byte ordering must be reversed to be consistent with the current platform.
Definition: kApiDef.h:948
kStatus(kCall * kCallbackFx)(kPointer receiver, kPointer sender, void *args)
Callback signature for a generic event handler.
Definition: kApiDef.h:1848
#define kALLOC_TRAIT_CUDA_DEVICE
Allocates Cuda device memory (device only).
Definition: kApiDef.h:2284
k8u g
Green component value.
Definition: kApiDef.h:1667
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:2378
T kMin(const T &a, const T &b)
Returns the minimum of two numbers.
Definition: kApiDef.h:2033
#define kALLOC_TRAIT_FOREIGN
Allocates memory in a foreign memory domain (non-host address space).
Definition: kApiDef.h:2278
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:1598
k8u b
Blue component value.
Definition: kApiDef.h:1694
k16s height
Height of the rectangle.
Definition: kApiDef.h:1472
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:1695
kStatus k64s_Parse(k64s *value, const kChar *str)
Converts string to k64s value.
k16s x
X-coordinate value.
Definition: kApiDef.h:1440
k32s x
X-coordinate value.
Definition: kApiDef.h:1383
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:1366
k32s value
Enumerator numeric value.
Definition: kApiDef.h:2490
kTypeName functionName
Full function name (e.g. "kObject_Clone").
Definition: kApiDef.h:2466
Represents a 16-bit signed integer.
k32f y
Y-coordinate of the origin.
Definition: kApiDef.h:1502
Represents a 32-bit floating-point number.
k64f y
Y-coordinate value.
Definition: kApiDef.h:1344
Root of all Zen classes.
Represents a version number.
k8u a
Alpha component value.
Definition: kApiDef.h:1697
#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:2082
Represents an error code.
k64f z
Z-coordinate of the origin.
Definition: kApiDef.h:1549
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:1669
k32s y
Y-coordinate value.
Definition: kApiDef.h:1316
kSize offset
Offset of field within structure (bytes).
Definition: kApiDef.h:2479
k16s y
Y-coordinate value.
Definition: kApiDef.h:1441
#define kCall
kApi standard function calling convention.
Definition: kApiDef.h:15
k32f width
Width of the rectangle.
Definition: kApiDef.h:1503
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:1545
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:1467
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:1721
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:1485
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:1972
Represents a memory allocator trait.
k32f xc
X-coordinate of the rectangle center.
Definition: kApiDef.h:1596
2D point structure with 32-bit signed integer fields.
Definition: kApiDef.h:1313
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:1469
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:2480
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:2184
k32f height
Height of the rectangle.
Definition: kApiDef.h:1504
k8u g
Green component value.
Definition: kApiDef.h:1724
3D point structure with 64-bit floating-point fields.
Definition: kApiDef.h:1411
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:2002
kBool kAllocTrait_IsCudaDevice(kAllocTrait traits)
Reports whether the kALLOC_TRAIT_CUDA_DEVICE trait is present in an allocator trait bitset...
Definition: kApiDef.h:2366
3D point structure with 32-bit signed integer fields.
Definition: kApiDef.h:1381
k16s z
Z-coordinate value.
Definition: kApiDef.h:1442
kStatus k8u_Parse(k8u *value, const kChar *str)
Converts string to k8u value.
k32f y
Y-coordinate value.
Definition: kApiDef.h:1399
4D point structure with 16-bit signed integer fields.
Definition: kApiDef.h:1438
kStatus k8s_Parse(k8s *value, const kChar *str)
Converts string to k8s value.