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 #elif defined (K_STATIC)
22 # define kFx(TYPE) kInFx(TYPE)
23 # define kDx(TYPE) kInDx(TYPE)
24 #else
25 # define kFx(TYPE) kImportFx(TYPE)
26 # define kDx(TYPE) kImportDx(TYPE)
27 #endif
28 
29 #define kInlineFx(TYPE) xkInlineFx(TYPE)
30 
31 typedef void (kCall* kFunction)();
32 
41 typedef xk8u k8u;
42 
44 #define k8U_MIN (0)
45 #define k8U_MAX (255U)
46 #define k8U_NULL (k8U_MAX)
47 
57 typedef xk16u k16u;
58 
60 #define k16U_MIN (0)
61 #define k16U_MAX (65535U)
62 #define k16U_NULL (k16U_MAX)
63 
73 typedef xk32u k32u;
74 
76 #define k32U_MIN (0)
77 #define k32U_MAX (4294967295U)
78 #define k32U_NULL (k32U_MAX)
79 
89 typedef xk64u k64u;
90 
92 #define k64U(CONST) xk64U(CONST)
93 #define k64U_MIN k64U(0)
94 #define k64U_MAX k64U(18446744073709551615)
95 #define k64U_NULL (k64U_MAX)
96 
98 #define kINFINITE k64U_MAX
99 
100 
108 typedef xk8s k8s;
109 
111 #define k8S_MAX (127)
112 #define k8S_MIN (-k8S_MAX -1)
113 #define k8S_NULL (k8S_MIN)
114 
124 typedef xk16s k16s;
125 
127 #define k16S_MAX (32767)
128 #define k16S_MIN (-k16S_MAX -1)
129 #define k16S_NULL (k16S_MIN)
130 
140 typedef xk32s k32s;
141 
143 #define k32S_MAX (2147483647)
144 #define k32S_MIN (-k32S_MAX -1)
145 #define k32S_NULL (k32S_MIN)
146 
156 typedef xk64s k64s;
157 
159 #define k64S(CONST) xk64S(CONST)
160 #define k64S_MAX k64S(9223372036854775807)
161 #define k64S_MIN (-k64S_MAX -1)
162 #define k64S_NULL (k64S_MIN)
163 
173 typedef k32s kBool;
174 
176 #define kFALSE (0)
177 #define kTRUE (1)
178 
188 typedef xk32f k32f;
189 
191 #define k32F_MIN (1.175494351e-38F)
192 #define k32F_MAX (3.402823466e+38F)
193 #define k32F_NULL (-k32F_MAX)
194 #define k32F_DIGITS (9)
195 
204 kInlineFx(kBool) k32f_IsNull(k32f value)
205 {
206  return (value == k32F_NULL);
207 }
208 
217 typedef xk64f k64f;
218 
220 #define k64F_MIN (2.2250738585072014e-308)
221 #define k64F_MAX (1.7976931348623157e+308)
222 #define k64F_NULL (-k64F_MAX)
223 #define k64F_DIGITS (17)
224 
234 kFx(k32s) k64f_IsNanOrInf(k64f value);
235 
244 {
245  return (value == k64F_NULL);
246 }
247 
256 typedef xkByte kByte;
257 
266 typedef xkSize kSize;
267 
269 #define kSIZE_MAX xkSIZE_MAX
270 #define kSIZE_NULL kSIZE_MAX
271 
283 kInlineFx(kSize) kSize_Align(kSize value, kSize to)
284 {
285  return ((value >> to) + !!(value & ((1 << to) - 1))) << to;
286 }
287 
294 typedef xkSSize kSSize;
295 
297 #define kSSIZE_MIN xkSSIZE_MIN
298 #define kSSIZE_MAX xkSSIZE_MAX
299 #define kSSIZE_NULL kSSIZE_MIN
300 
309 typedef void* kPointer;
310 
311 #define kNULL (0)
312 
313 
322 kInlineFx(void*) kPointer_ByteOffset(const void* pointer, kSSize offset)
323 {
324  return (kByte*)pointer + offset;
325 }
326 
336 kInlineFx(void*) kPointer_ItemOffset(const void* pointer, kSSize itemIndex, kSize itemSize)
337 {
338  return kPointer_ByteOffset(pointer, itemIndex*(kSSize)itemSize);
339 }
340 
349 kInlineFx(kSSize) kPointer_Diff(void* a, void* b)
350 {
351  return (kSSize)a - (kSSize)b;
352 }
353 
362 #define kPointer_ReadAs(POINTER, TYPE) \
363  (*(TYPE*)(POINTER))
364 
373 #define kPointer_WriteAs(POINTER, VALUE, TYPE) \
374  (*(TYPE*)(POINTER) = (TYPE)(VALUE))
375 
383 #define kIsNull(POINTER) \
384  ((POINTER) == kNULL)
385 
394 typedef xkChar kChar;
395 
404 {
405  return (ch >= 'A' && ch <= 'Z') ? (ch - 'A' + 'a') : ch;
406 }
407 
416 {
417  return (ch >= 'a' && ch <= 'z') ? (ch - 'a' + 'A') : ch;
418 }
419 
428 {
429  return ch == ' ';
430 }
431 
440 {
441  return ((ch >= 'a') && (ch <= 'z') ) || ((ch >= 'A') && (ch <= 'Z'));
442 }
443 
452 {
453  return ch >= '0' && ch <= '9';
454 }
455 
464 typedef kChar kText16[16];
465 
474 typedef kChar kText32[32];
475 
484 typedef kChar kText64[64];
485 
494 typedef kChar kText128[128];
495 
504 typedef kChar kText256[256];
505 
514 typedef k32s kStatus;
515 
517 #define kERROR_STATE (-1000)
518 #define kERROR_NOT_FOUND (-999)
519 #define kERROR_COMMAND (-998)
520 #define kERROR_PARAMETER (-997)
521 #define kERROR_UNIMPLEMENTED (-996)
522 #define kERROR_MEMORY (-994)
523 #define kERROR_TIMEOUT (-993)
524 #define kERROR_INCOMPLETE (-992)
525 #define kERROR_STREAM (-991)
526 #define kERROR_CLOSED (-990)
527 #define kERROR_VERSION (-989)
528 #define kERROR_ABORT (-988)
529 #define kERROR_ALREADY_EXISTS (-987)
530 #define kERROR_NETWORK (-986)
531 #define kERROR_HEAP (-985)
532 #define kERROR_FORMAT (-984)
533 #define kERROR_READ_ONLY (-983)
534 #define kERROR_WRITE_ONLY (-982)
535 #define kERROR_BUSY (-981)
536 #define kERROR_CONFLICT (-980)
537 #define kERROR_OS (-979)
538 #define kERROR_DEVICE (-978)
539 #define kERROR_FULL (-977)
540 #define kERROR_IN_PROGRESS (-976)
541 #define kERROR_OVERHEAT (-975)
542 #define kERROR (0)
543 #define kOK (1)
544 
555 kFx(const kChar*) kStatus_Name(kStatus status);
556 
565 {
566  return status != kOK;
567 }
568 
577 {
578  return status == kOK;
579 }
580 
589 #define kCheck(EXPRESSION) \
590  xkCheck(EXPRESSION)
591 
601 #define kCheckTrue(EXPRESSION, STATUS) \
602  xkCheckTrue(EXPRESSION, STATUS)
603 
612 #define kCheckArgs(EXPRESSION) \
613  xkCheckArgs(EXPRESSION)
614 
623 #define kCheckState(EXPRESSION) \
624  xkCheckState(EXPRESSION)
625 
631 #define kTry \
632  xkTry
633 
640 #define kThrow(EXPRESSION) \
641  xkThrow(EXPRESSION)
642 
652 #define kTest(EXPRESSION) \
653  xkTest(EXPRESSION)
654 
665 #define kTestTrue(EXPRESSION, STATUS) \
666  xkTestTrue(EXPRESSION, STATUS)
667 
677 #define kTestArgs(EXPRESSION) \
678  xkTestArgs(EXPRESSION)
679 
689 #define kTestState(EXPRESSION) \
690  xkTestState(EXPRESSION)
691 
698 #define kCatch(STATUS_POINTER) \
699  xkCatch(STATUS_POINTER)
700 
709 #define kEndCatch(STATUS) \
710  xkEndCatch(STATUS)
711 
717 #define kFinally \
718  xkFinally
719 
728 #define kEndFinally() \
729  xkEndFinally()
730 
737 #define kCatchEx(STATUS_POINTER) \
738  xkCatchEx(STATUS_POINTER)
739 
750 #define kEndCatchEx(STATUS) \
751  xkEndCatchEx(STATUS)
752 
758 #define kFinallyEx \
759  xkFinallyEx
760 
769 #define kEndFinallyEx() \
770  xkEndFinallyEx()
771 
779 #define kAssert(EXPRESSION) \
780  xkAssert(EXPRESSION)
781 
792 #define kAssertType(OBJECT, SYMBOL) \
793  xkAssertType(OBJECT, SYMBOL)
794 
803 typedef k32u kVersion;
804 
805 #define kVERSION_NULL (k32U_NULL) // kVersion invalid value.
806 
817 kInlineFx(kVersion) kVersion_Create(k32u major, k32u minor, k32u release, k32u build)
818 {
819  return (major & 0xFF) << 24 |
820  (minor & 0xFF) << 16 |
821  (release & 0xFF) << 8 |
822  (build & 0xFF);
823 }
824 
835 #define kVersion_Stringify_(MAJOR, MINOR, RELEASE, BUILD) \
836  xkStringize(MAJOR) "." xkStringize(MINOR) "." xkStringize(RELEASE) "." xkStringize(BUILD)
837 
846 kFx(kStatus) kVersion_Parse(kVersion* version, const kChar* buffer);
847 
857 kFx(kStatus) kVersion_Format(kVersion version, kChar* buffer, kSize capacity);
858 
871 {
872  return (k32s)version1 - (k32s)version2;
873 }
874 
883 {
884  return (version >> 24) & 0xFF;
885 }
886 
895 {
896  return (version >> 16) & 0xFF;
897 }
898 
907 {
908  return (version >> 8) & 0xFF;
909 }
910 
919 {
920  return (version) & 0xFF;
921 }
922 
929 typedef k32s kEndianness;
930 
932 #define kENDIANNESS_LITTLE (1)
933 #define kENDIANNESS_BIG (2)
934 
941 kInlineFx(kEndianness) kEndianness_Host()
942 {
943  return K_ENDIANNESS;
944 }
945 
953 {
954  return endianness != kEndianness_Host();
955 }
956 
971 kFx(kStatus) k8u_Format(k8u value, kChar* buffer, kSize capacity);
972 
981 kFx(kStatus) k8u_Parse(k8u* value, const kChar* str);
982 
997 kFx(kStatus) k8s_Format(k8s value, kChar* buffer, kSize capacity);
998 
1007 kFx(kStatus) k8s_Parse(k8s* value, const kChar* str);
1008 
1023 kFx(kStatus) k16u_Format(k16u value, kChar* buffer, kSize capacity);
1024 
1033 kFx(kStatus) k16u_Parse(k16u* value, const kChar* str);
1034 
1049 kFx(kStatus) k16s_Format(k16s value, kChar* buffer, kSize capacity);
1050 
1059 kFx(kStatus) k16s_Parse(k16s* value, const kChar* str);
1060 
1075 kFx(kStatus) k32u_Format(k32u value, kChar* buffer, kSize capacity);
1076 
1085 kFx(kStatus) k32u_Parse(k32u* value, const kChar* str);
1086 
1101 kFx(kStatus) k32s_Format(k32s value, kChar* buffer, kSize capacity);
1102 
1111 kFx(kStatus) k32s_Parse(k32s* value, const kChar* str);
1112 
1127 kFx(kStatus) k64u_Format(k64u value, kChar* buffer, kSize capacity);
1128 
1137 kFx(kStatus) k64u_Parse(k64u* value, const kChar* str);
1138 
1153 kFx(kStatus) k64s_Format(k64s value, kChar* buffer, kSize capacity);
1154 
1163 kFx(kStatus) k64s_Parse(k64s* value, const kChar* str);
1164 
1179 kFx(kStatus) kBool_Format(kBool value, kChar* buffer, kSize capacity);
1180 
1189 kFx(kStatus) kBool_Parse(kBool* value, const kChar* str);
1190 
1205 kFx(kStatus) kSize_Format(kSize value, kChar* buffer, kSize capacity);
1206 
1215 kFx(kStatus) kSize_Parse(kSize* value, const kChar* str);
1216 
1231 kFx(kStatus) kSSize_Format(kSSize value, kChar* buffer, kSize capacity);
1232 
1241 kFx(kStatus) kSSize_Parse(kSSize* value, const kChar* str);
1242 
1257 kFx(kStatus) k32f_Format(k32f value, kChar* buffer, kSize capacity);
1258 
1267 kFx(kStatus) k32f_Parse(k32f* value, const kChar* str);
1268 
1283 kFx(kStatus) k64f_Format(k64f value, kChar* buffer, kSize capacity);
1284 
1293 kFx(kStatus) k64f_Parse(k64f* value, const kChar* str);
1294 
1303 typedef struct kPoint16s
1304 {
1307 } kPoint16s;
1308 
1317 typedef struct kPoint32s
1318 {
1321 } kPoint32s;
1322 
1331 typedef struct kPoint32f
1332 {
1335 } kPoint32f;
1336 
1345 typedef struct kPoint64f
1346 {
1349 } kPoint64f;
1350 
1360 #define kPoint_Init_(POINT, X, Y) xkPoint_Init_(POINT, X, Y)
1361 
1370 typedef struct kPoint3d16s
1371 {
1375 } kPoint3d16s;
1376 
1385 typedef struct kPoint3d32s
1386 {
1390 } kPoint3d32s;
1391 
1400 typedef struct kPoint3d32f
1401 {
1405 } kPoint3d32f;
1406 
1415 typedef struct kPoint3d64f
1416 {
1420 } kPoint3d64f;
1421 
1432 #define kPoint3d_Init_(POINT, X, Y, Z) xkPoint3d_Init_(POINT, X, Y, Z)
1433 
1442 typedef struct kPoint4d16s
1443 {
1448 } kPoint4d16s;
1449 
1461 #define kPoint4d_Init_(POINT, X, Y, Z, W) xkPoint4d_Init_(POINT, X, Y, Z, W)
1462 
1471 typedef struct kRect16s
1472 {
1477 } kRect16s;
1478 
1487 typedef struct kWindow32u
1488 {
1493 } kWindow32u;
1494 
1503 typedef struct kRect32s
1504 {
1509 } kRect32s;
1510 
1519 typedef struct kRect32f
1520 {
1525 } kRect32f;
1526 
1535 typedef struct kRect64f
1536 {
1541 } kRect64f;
1542 
1554 #define kRect_Init_(RECT, X, Y, W, H) \
1555  xkRect_Init_(RECT, X, Y, W, H)
1556 
1565 typedef struct kRect3d64f
1566 {
1573 } kRect3d64f;
1574 
1586 #define kRect3d_Init_(RECT, X, Y, Z, W, H, D) \
1587  xkRect3d_Init_(RECT, X, Y, Z, W, H, D)
1588 
1597 typedef struct kRotatedRect32s
1598 {
1604 } kRotatedRect32s;
1605 
1614 typedef struct kRotatedRect32f
1615 {
1621 } kRotatedRect32f;
1622 
1635 #define kRotatedRect_Init_(RECT, XC, YC, W, H, A) \
1636  xkRotatedRect_Init_(RECT, XC, YC, W, H, A)
1637 
1646 typedef k32s kPixelFormat;
1647 
1649 #define kPIXEL_FORMAT_NULL (0)
1650 #define kPIXEL_FORMAT_8BPP_GREYSCALE (1)
1651 #define kPIXEL_FORMAT_8BPP_CFA (2)
1652 #define kPIXEL_FORMAT_8BPC_BGRX (3)
1653 #define kPIXEL_FORMAT_1BPP_GREYSCALE (4)
1654 #define kPIXEL_FORMAT_16BPP_GREYSCALE (5)
1655 #define kPIXEL_FORMAT_8BPC_BGR (6)
1656 #define kPIXEL_FORMAT_VOID_TYPE_START kPIXEL_FORMAT_MONO8
1657 #define kPIXEL_FORMAT_MONO8 (0x01080001)
1658 #define kPIXEL_FORMAT_MONO12_PACKED (0x010C0047)
1659 
1669 typedef k32s kCfa;
1670 
1672 #define kCFA_NONE (0)
1673 #define kCFA_BAYER_BGGR (1)
1674 #define kCFA_BAYER_GBRG (2)
1675 #define kCFA_BAYER_RGGB (3)
1676 #define kCFA_BAYER_GRBG (4)
1677 
1687 typedef struct kRgb
1688 {
1689  k8u b;
1690  k8u g;
1691  k8u r;
1692  k8u x;
1693 } kRgb;
1694 
1704 #define kRgb_Init_(RGB, R, G, B) \
1705  xkRgb_Init_(RGB, R, G, B)
1706 
1715 typedef struct kArgb
1716 {
1717  k8u b;
1718  k8u g;
1719  k8u r;
1720  k8u a;
1721 } kArgb;
1722 
1733 #define kArgb_Init_(ARGB, A, R, G, B) \
1734  xkArgb_Init_(ARGB, A, R, G, B)
1735 
1744 typedef struct kRgb24
1745 {
1746  k8u b;
1747  k8u g;
1748  k8u r;
1749 } kRgb24;
1750 
1760 #define kRgb24_Init_(RGB24, R, G, B) \
1761  xkRgb24_Init_(RGB24, R, G, B)
1762 
1769 typedef struct kMacAddress
1770 {
1772 } kMacAddress;
1773 
1780 typedef k32s kMemoryAlignment;
1781 
1783 #define kMEMORY_ALIGNMENT_8 (3)
1784 #define kMEMORY_ALIGNMENT_16 (4)
1785 #define kMEMORY_ALIGNMENT_32 (5)
1786 #define kMEMORY_ALIGNMENT_64 (6)
1787 #define kMEMORY_ALIGNMENT_128 (7)
1788 #define kMEMORY_ALIGNMENT_256 (8)
1789 #define kMEMORY_ALIGNMENT_512 (9)
1790 #define kMEMORY_ALIGNMENT_1024 (10)
1791 #define kMEMORY_ALIGNMENT_2048 (11)
1792 #define kMEMORY_ALIGNMENT_4096 (12)
1793 
1801 kInlineFx(kSize) kMemoryAlignment_Size(kMemoryAlignment alignment)
1802 {
1803  return ((kSize)1 << (kSize)alignment);
1804 }
1805 
1816 kFx(kStatus) kMacAddress_Parse(kMacAddress* address, const kChar* text);
1817 
1829 kFx(kStatus) kMacAddress_Format(kMacAddress address, kChar* text, kSize capacity);
1830 
1837 typedef k32s kComparison;
1838 
1839 #define kCOMPARISON_EQ (0)
1840 #define kCOMPARISON_NEQ (1)
1841 #define kCOMPARISON_LT (2)
1842 #define kCOMPARISON_LTE (3)
1843 #define kCOMPARISON_GT (4)
1844 #define kCOMPARISON_GTE (5)
1845 
1846 
1853 typedef kBool (kCall* kEqualsFx)(const void* item1, const void* item2);
1854 
1861 typedef kSize (kCall* kHashFx)(const void* item);
1862 
1871 typedef kStatus (kCall* kCallbackFx)(kPointer receiver, kPointer sender, void* args);
1872 
1879 typedef struct kCallback
1880 {
1881  kCallbackFx function;
1883 } kCallback;
1884 
1891 typedef k32s kFileMode;
1892 
1894 #define kFILE_MODE_READ (0x1)
1895 #define kFILE_MODE_WRITE (0x2)
1896 #define kFILE_MODE_UPDATE (0x4)
1897 
1905 typedef k32s kSeekOrigin;
1906 
1908 #define kSEEK_ORIGIN_BEGIN (0)
1909 #define kSEEK_ORIGIN_CURRENT (1)
1910 #define kSEEK_ORIGIN_END (2)
1911 
1919 typedef k32s kCompressionType;
1920 
1922 #define kCOMPRESSION_TYPE_NULL (0)
1923 #define kCOMPRESSION_TYPE_ZSTD (1)
1924 
1925 
1933 typedef k32s kCompressionPreset;
1934 
1936 #define kCOMPRESSION_PRESET_MIN (-1)
1937 #define kCOMPRESSION_PRESET_FAST (-2)
1938 #define kCOMPRESSION_PRESET_DEFAULT (-3)
1939 #define kCOMPRESSION_PRESET_DENSE (-4)
1940 #define kCOMPRESSION_PRESET_MAX (-5)
1941 
1952 typedef k64u kLogOption;
1953 
1955 #define kLOG_OPTION_WARNING (0x1)
1956 #define kLOG_OPTION_ERROR (0x2)
1957 #define kLOG_OPTION_TRACE (0x4)
1958 #define kLOG_OPTION_DEBUG (0x8)
1959 #define kLOG_OPTION_PLATFORM (0x10)
1960 
1970 #define kCountOf(CARRAY) \
1971  (sizeof(CARRAY)/sizeof(CARRAY[0]))
1972 
1982 #define kCast(TYPE, ITEM) \
1983  ((TYPE)(ITEM))
1984 
1985 #if (K_CPP_VERSION >= K_CPP_VERSION_2011)
1986 
1996 template <typename T>
1997 static kInline typename std::enable_if<std::is_unsigned<T>::value, T>::type kAbs(const T& v)
1998 {
1999  return v;
2000 }
2001 
2011 template <typename T>
2012 static kInline typename std::enable_if<!std::is_unsigned<T>::value, T>::type kAbs(const T& v)
2013 {
2014  return (v >= T()) ? v : -v;
2015 }
2016 
2026 template <typename T>
2027 static kInline typename std::enable_if<std::is_unsigned<T>::value, T>::type kSign(const T& v)
2028 {
2029  return v > T();
2030 }
2031 
2041 template <typename T>
2042 static kInline typename std::enable_if<!std::is_unsigned<T>::value, T>::type kSign(const T& v)
2043 {
2044  return (v > T()) - (v < T());
2045 }
2046 
2057 template <typename T>
2058 kInlineFx(T) kMin(const T& a, const T& b)
2059 {
2060  return (a < b) ? a : b;
2061 }
2062 
2073 template <typename T>
2074 kInlineFx(T) kMax(const T& a, const T& b)
2075 {
2076  return (a > b) ? a : b;
2077 }
2078 
2090 template <typename T>
2091 kInlineFx(T) kClamp(const T& v, const T& min, const T& max)
2092 {
2093  return kMin(kMax(v, min), max);
2094 }
2095 
2106 template <typename T>
2107 static kInline typename std::enable_if<std::is_unsigned<T>::value, T>::type kDivideFloor(const T& a, const T& b)
2108 {
2109  return a / b;
2110 }
2111 
2122 template <typename T>
2123 static kInline typename std::enable_if<!std::is_unsigned<T>::value, T>::type kDivideFloor(const T& a, const T& b)
2124 {
2125  return ((kSign(a) * kSign(b)) >= T()) ? a / b : ((a / b) - ((a % b) != T()));
2126 }
2127 
2138 template <typename T>
2139 static kInline typename std::enable_if<std::is_unsigned<T>::value, T>::type kDivideCeil(const T& a, const T& b)
2140 {
2141  return (a / b) + ((a % b) != T());
2142 }
2143 
2154 template <typename T>
2155 static kInline typename std::enable_if<!std::is_unsigned<T>::value, T>::type kDivideCeil(const T& a, const T& b)
2156 {
2157  return ((kSign(a) * kSign(b)) <= T()) ? a / b : ((a / b) + ((a % b) != T()));
2158 }
2159 
2170 template <typename T>
2171 kInlineFx(T) kQuantizeFloor(const T& value, const T& granularity)
2172 {
2173  return kDivideFloor(value, granularity) * granularity;
2174 }
2175 
2186 template <typename T>
2187 kInlineFx(T) kQuantizeCeil(const T& value, const T& granularity)
2188 {
2189  return kDivideCeil(value, granularity) * granularity;
2190 }
2191 
2208 template <typename T>
2209 kInlineFx(T) kAdjustFloor(const T& value, const T& min, const T& max, const T& granularity)
2210 {
2211  typedef typename std::make_unsigned<T>::type U;
2212  U relativeValue = (value >= min) ? (U) (value - min) : U();
2213  U relativeMax = (max >= min) ? (U) (max - min) : U();
2214  U quantizedRelativeMax = kQuantizeFloor<U>(relativeMax, granularity);
2215  U limitedRelativeValue = kMin<U>(relativeValue, quantizedRelativeMax);
2216 
2217  return (T) kQuantizeFloor<U>(limitedRelativeValue, granularity) + min;
2218 }
2219 
2236 template <typename T>
2237 kInlineFx(T) kAdjustCeil(const T& value, const T& min, const T& max, const T& granularity)
2238 {
2239  typedef typename std::make_unsigned<T>::type U;
2240  U relativeValue = (value >= min) ? (U) (value - min) : U();
2241  U relativeMax = (max >= min) ? (U) (max - min) : U();
2242  U quantizedRelativeMax = kQuantizeFloor<U>(relativeMax, granularity);
2243  U limitedRelativeValue = kMin<U>(relativeValue, quantizedRelativeMax);
2244 
2245  return (T) kQuantizeCeil<U>(limitedRelativeValue, granularity) + min;
2246 }
2247 
2248 #endif
2249 
2255 #define kZero(VALUE) \
2256  memset(&VALUE, 0, sizeof(VALUE))
2257 
2272 kInlineFx(void) kItemCopy(void* dest, const void* src, kSize size)
2273 {
2274  memcpy(dest, src, size);
2275 }
2276 
2290 kInlineFx(void) kItemZero(void* dest, kSize size)
2291 {
2292  memset(dest, 0, size);
2293 }
2294 
2300 typedef k32s kAllocTrait;
2301 
2303 #define kALLOC_TRAIT_FOREIGN (0x00000001)
2304 #define kALLOC_TRAIT_SERIAL (0x00000002)
2305 #define kALLOC_TRAIT_NON_ATOMIC (0x00000004)
2306 #define kALLOC_TRAIT_CONTEXT (0x00000008)
2307 #define kALLOC_TRAIT_CUDA_PINNED (0x00010000)
2308 #define kALLOC_TRAIT_CUDA_MANAGED (0x00020000)
2309 #define kALLOC_TRAIT_CUDA_DEVICE (0x01000000)
2310 
2319 kInlineFx(kBool) kAllocTrait_IsForeign(kAllocTrait traits)
2320 {
2321  return (traits & kALLOC_TRAIT_FOREIGN) != 0;
2322 }
2323 
2332 {
2333  return (traits & kALLOC_TRAIT_SERIAL) != 0;
2334 }
2335 
2344 {
2345  return (traits & kALLOC_TRAIT_NON_ATOMIC) != 0;
2346 }
2347 
2356 {
2357  return (traits & kALLOC_TRAIT_CONTEXT) != 0;
2358 }
2359 
2368 {
2369  return (traits & kALLOC_TRAIT_CUDA_PINNED) != 0;
2370 }
2371 
2380 {
2381  return (traits & kALLOC_TRAIT_CUDA_MANAGED) != 0;
2382 }
2383 
2392 {
2393  return (traits & kALLOC_TRAIT_CUDA_DEVICE) != 0;
2394 }
2395 
2404 {
2406 }
2407 
2415 typedef kSize kThreadId;
2416 
2425 kFx(kBool) kThreadId_Compare(kThreadId a, kThreadId b);
2426 
2434 typedef k32s kThreadPriorityClass;
2435 
2437 #define kTHREAD_PRIORITY_CLASS_LOW (-1)
2438 #define kTHREAD_PRIORITY_CLASS_NORMAL (0)
2439 #define kTHREAD_PRIORITY_CLASS_HIGH (1)
2440 
2442 /*
2443  * Forward declarations
2444  */
2445 
2446 typedef void* kObject;
2447 typedef kObject kType;
2448 typedef kObject kAlloc;
2449 
2451 #define kTypeName kText64
2452 
2460 typedef k32u kTypeFlags;
2461 
2463 #define kTYPE_FLAGS_CLASS (0x01)
2464 #define kTYPE_FLAGS_INTERFACE (0x02)
2465 #define kTYPE_FLAGS_VALUE (0x04)
2466 #define kTYPE_FLAGS_ENUM (0x08)
2467 #define kTYPE_FLAGS_ABSTRACT (0x20)
2468 #define kTYPE_FLAGS_ARRAY_VALUE (0x40)
2469 #define kTYPE_FLAGS_PRIMITIVE (0x80)
2470 
2478 typedef kPointer kTypeVersion;
2479 
2481 typedef kStatus (kCall* kFrameworkConstructorFx)(kObject* object, kAlloc allocator);
2482 
2488 typedef struct kMethodInfo
2489 {
2490  kTypeName methodName;
2491  kTypeName functionName;
2492  kFunction function;
2493 } kMethodInfo;
2494 
2500 typedef struct kFieldInfo
2501 {
2502  kTypeName name;
2503  kType type;
2506 } kFieldInfo;
2507 
2513 typedef struct kEnumeratorInfo
2514 {
2516  kTypeName name;
2517  kTypeName displayName;
2518 } kEnumeratorInfo;
2519 
2545 #define kTypeOf(SYMBOL) \
2546  xkTypeOf(SYMBOL)
2547 
2573 #define kAssemblyOf(SYMBOL) \
2574  xkAssemblyOf(SYMBOL)
2575 
2584 #define kStaticOf(SYMBOL) \
2585  xkStaticOf(SYMBOL)
2586 
2594 #define kDeprecate(SYMBOL) \
2595  xkDeprecate(#SYMBOL)
2596 
2605 #define kWarn(MESSAGE) \
2606  xkWarn(MESSAGE)
2607 
2608 /*
2609 *
2610 * Type Declaration/Definition Macros, Generation 1.
2611 *
2612 * These type declaration/definition macros continue to be supported. However, consider using the Generation 2
2613 * macros (defined below) in new code.
2614 *
2615 */
2616 
2624 #define kDeclareAssembly(PREFIX, SYMBOL) \
2625  xkDeclareAssembly(PREFIX, SYMBOL)
2626 
2636 #define kBeginAssembly(PREFIX, SYMBOL, VERSION, PLATFORM_VERSION) \
2637  xkBeginAssembly(PREFIX, SYMBOL, VERSION, PLATFORM_VERSION)
2638 
2644 #define kEndAssembly() \
2645  xkEndAssembly()
2646 
2655 #define kDeclareValue(PREFIX, SYMBOL, BASE) \
2656  xkDeclareValue(PREFIX, SYMBOL, BASE)
2657 
2666 #define kBeginValue(PREFIX, SYMBOL, BASE) \
2667  xkBeginValue(PREFIX, SYMBOL, BASE)
2668 
2674 #define kEndValue() \
2675  xkEndValue()
2676 
2685 #define kDeclareEnum(PREFIX, SYMBOL, BASE) \
2686  xkDeclareEnum(PREFIX, SYMBOL, BASE)
2687 
2696 #define kBeginEnum(PREFIX, SYMBOL, BASE) \
2697  xkBeginEnum(PREFIX, SYMBOL, BASE)
2698 
2704 #define kEndEnum() \
2705  xkEndEnum()
2706 
2715 #define kDeclareArrayValue(PREFIX, SYMBOL, BASE) \
2716  xkDeclareArrayValue(PREFIX, SYMBOL, BASE)
2717 
2727 #define kBeginArrayValue(PREFIX, SYMBOL, TYPE, BASE) \
2728  xkBeginArrayValue(PREFIX, SYMBOL, TYPE, BASE)
2729 
2735 #define kEndArrayValue() \
2736  xkEndArrayValue()
2737 
2746 #define kDeclareInterface(PREFIX, SYMBOL, BASE) \
2747  xkDeclareInterface(PREFIX, SYMBOL, BASE)
2748 
2757 #define kBeginInterface(PREFIX, SYMBOL, BASE) \
2758  xkBeginInterface(PREFIX, SYMBOL, BASE)
2759 
2765 #define kEndInterface() \
2766  xkEndInterface()
2767 
2776 #define kDeclareFullClass(PREFIX, SYMBOL, BASE) \
2777  xkDeclareFullClass(PREFIX, SYMBOL, BASE)
2778 
2787 #define kBeginFullClass(PREFIX, SYMBOL, BASE) \
2788  xkBeginFullClass(PREFIX, SYMBOL, BASE)
2789 
2795 #define kEndFullClass() \
2796  xkEndFullClass()
2797 
2806 #define kDeclareVirtualClass(PREFIX, SYMBOL, BASE) \
2807  xkDeclareVirtualClass(PREFIX, SYMBOL, BASE)
2808 
2817 #define kBeginVirtualClass(PREFIX, SYMBOL, BASE) \
2818  xkBeginVirtualClass(PREFIX, SYMBOL, BASE)
2819 
2825 #define kEndVirtualClass() \
2826  xkEndVirtualClass()
2827 
2835 #define kDeclareStaticClass(PREFIX, SYMBOL) \
2836  xkDeclareStaticClass(PREFIX, SYMBOL)
2837 
2845 #define kBeginStaticClass(PREFIX, SYMBOL) \
2846  xkBeginStaticClass(PREFIX, SYMBOL)
2847 
2853 #define kEndStaticClass() \
2854  xkEndStaticClass()
2855 
2864 #define kDeclareClass(PREFIX, SYMBOL, BASE) \
2865  xkDeclareClass(PREFIX, SYMBOL, BASE)
2866 
2875 #define kBeginClass(PREFIX, SYMBOL, BASE) \
2876  xkBeginClass(PREFIX, SYMBOL, BASE)
2877 
2883 #define kEndClass() \
2884  xkEndClass()
2885 
2886 /*
2887 *
2888 * Type Declaration/Definition Macros, Generation 2.
2889 *
2890 * These macros are used to declare and define elements of the type system, such
2891 * as assemblies, classes and values. These macros supersede the Generation 1 macros,
2892 * defined above.
2893 *
2894 */
2895 
2903 #define kDeclareAssemblyEx(PREFIX, SYMBOL) \
2904  xkDeclareAssemblyEx(PREFIX, SYMBOL)
2905 
2915 #define kBeginAssemblyEx(PREFIX, SYMBOL, VERSION, PLATFORM_VERSION) \
2916  xkBeginAssemblyEx(PREFIX, SYMBOL, VERSION, PLATFORM_VERSION)
2917 
2923 #define kEndAssemblyEx() \
2924  xkEndAssemblyEx()
2925 
2934 #define kDeclareValueEx(PREFIX, SYMBOL, BASE) \
2935  xkDeclareValueEx(PREFIX, SYMBOL, BASE)
2936 
2944 #define kBeginValueEx(PREFIX, SYMBOL) \
2945  xkBeginValueEx(PREFIX, SYMBOL)
2946 
2952 #define kEndValueEx() \
2953  xkEndValueEx()
2954 
2963 #define kDeclareEnumEx(PREFIX, SYMBOL, BASE) \
2964  xkDeclareEnumEx(PREFIX, SYMBOL, BASE)
2965 
2973 #define kBeginEnumEx(PREFIX, SYMBOL) \
2974  xkBeginEnumEx(PREFIX, SYMBOL)
2975 
2981 #define kEndEnumEx() \
2982  xkEndEnumEx()
2983 
2992 #define kDeclareArrayValueEx(PREFIX, SYMBOL, BASE) \
2993  xkDeclareArrayValueEx(PREFIX, SYMBOL, BASE)
2994 
3003 #define kBeginArrayValueEx(PREFIX, SYMBOL, TYPE) \
3004  xkBeginArrayValueEx(PREFIX, SYMBOL, TYPE)
3005 
3011 #define kEndArrayValueEx() \
3012  xkEndArrayValueEx()
3013 
3022 #define kDeclareInterfaceEx(PREFIX, SYMBOL, BASE) \
3023  xkDeclareInterfaceEx(PREFIX, SYMBOL, BASE)
3024 
3032 #define kBeginInterfaceEx(PREFIX, SYMBOL) \
3033  xkBeginInterfaceEx(PREFIX, SYMBOL)
3034 
3040 #define kEndInterfaceEx() \
3041  xkEndInterfaceEx()
3042 
3051 #define kDeclareFullClassEx(PREFIX, SYMBOL, BASE) \
3052  xkDeclareFullClassEx(PREFIX, SYMBOL, BASE)
3053 
3061 #define kBeginFullClassEx(PREFIX, SYMBOL) \
3062  xkBeginFullClassEx(PREFIX, SYMBOL)
3063 
3069 #define kEndFullClassEx() \
3070  xkEndFullClassEx()
3071 
3080 #define kDeclareVirtualClassEx(PREFIX, SYMBOL, BASE) \
3081  xkDeclareVirtualClassEx(PREFIX, SYMBOL, BASE)
3082 
3090 #define kBeginVirtualClassEx(PREFIX, SYMBOL) \
3091  xkBeginVirtualClassEx(PREFIX, SYMBOL)
3092 
3098 #define kEndVirtualClassEx() \
3099  xkEndVirtualClassEx()
3100 
3108 #define kDeclareStaticClassEx(PREFIX, SYMBOL) \
3109  xkDeclareStaticClassEx(PREFIX, SYMBOL)
3110 
3118 #define kBeginStaticClassEx(PREFIX, SYMBOL) \
3119  xkBeginStaticClassEx(PREFIX, SYMBOL)
3120 
3126 #define kEndStaticClassEx() \
3127  xkEndStaticClassEx()
3128 
3137 #define kDeclareClassEx(PREFIX, SYMBOL, BASE) \
3138  xkDeclareClassEx(PREFIX, SYMBOL, BASE)
3139 
3147 #define kBeginClassEx(PREFIX, SYMBOL) \
3148  xkBeginClassEx(PREFIX, SYMBOL)
3149 
3155 #define kEndClassEx() \
3156  xkEndClassEx()
3157 
3158 /*
3159 *
3160 * Type Implementation Macros
3161 *
3162 * These macros are used to provide type-specific details. They are typically used between
3163 * type definition begin/end macros (e.g., kBeginClass/kEndClass).
3164 *
3165 */
3166 
3173 #define kAddDependency(SYMBOL) \
3174  xkAddDependency(SYMBOL)
3175 
3182 #define kAddType(SYMBOL) \
3183  xkAddType(SYMBOL)
3184 
3195 #define kAddPriority(SYMBOL) \
3196  xkAddPriority(SYMBOL)
3197 
3206 #define kAddStatic(SYMBOL) \
3207  xkAddStatic(SYMBOL)
3208 
3216 #define kAddInterface(SYMBOL, IFACE) \
3217  xkAddInterface(SYMBOL, IFACE)
3218 
3237 #define kAddFrameworkConstructor(SYMBOL, CTOR) \
3238  xkAddFrameworkConstructor(SYMBOL, CTOR)
3239 
3258 #define kAddPrivateFrameworkConstructor(SYMBOL, CTOR) \
3259  xkAddPrivateFrameworkConstructor(SYMBOL, CTOR)
3260 
3268 #define kAddMethod(SYMBOL, METHOD) \
3269  xkAddMethod(SYMBOL, METHOD)
3270 
3279 #define kAddVMethod(IN_TYPE, FROM_TYPE, METHOD) \
3280  xkAddVMethod(IN_TYPE, FROM_TYPE, METHOD)
3281 
3292 #define kAddPrivateVMethod(IN_TYPE, FROM_TYPE, METHOD) \
3293  xkAddPrivateVMethod(IN_TYPE, FROM_TYPE, METHOD)
3294 
3304 #define kAddIVMethod(IN_TYPE, FROM_IFACE, IMETHOD, CMETHOD) \
3305  xkAddIVMethod(IN_TYPE, FROM_IFACE, IMETHOD, CMETHOD)
3306 
3318 #define kAddPrivateIVMethod(IN_TYPE, FROM_IFACE, IMETHOD, CMETHOD) \
3319  xkAddPrivateIVMethod(IN_TYPE, FROM_IFACE, IMETHOD, CMETHOD)
3320 
3329 #define kAddField(VALUE, FIELD_TYPE, FIELD) \
3330  xkAddField(VALUE, FIELD_TYPE, FIELD)
3331 
3339 #define kAddEnumerator \
3340  xkAddEnumerator
3341 
3360 #define kAddVersionEx(TYPE, FORMAT, FORMAT_VER, GUID, WRITE_METHOD, READ_METHOD) \
3361  xkAddVersionEx(TYPE, FORMAT, FORMAT_VER, GUID, WRITE_METHOD, READ_METHOD)
3362 
3383 #define kAddPrivateVersionEx(TYPE, FORMAT, FORMAT_VER, GUID, WRITE_METHOD, READ_METHOD) \
3384  xkAddPrivateVersionEx(TYPE, FORMAT, FORMAT_VER, GUID, WRITE_METHOD, READ_METHOD)
3385 
3399 #define kAddAbstractVersionEx(TYPE, FORMAT, FORMAT_VER, GUID) \
3400  xkAddAbstractVersion(TYPE, FORMAT, FORMAT_VER, GUID)
3401 
3409 #define kAddFlags(TYPE, FLAGS) \
3410  xkAddFlags(TYPE, FLAGS)
3411 
3433 #define kDefineDebugHints() \
3434  xkDefineDebugHints()
3435 
3436 /*
3437 *
3438 * Method Implementation Macros
3439 *
3440 * These macros are used in the implementation of class methods.
3441 *
3442 */
3443 
3450 #define kObj(TypeName_T, T_object) \
3451  TypeName_T##Class* obj K_ATTRIBUTE_UNUSED = xx##TypeName_T##_Cast(T_object, __FILE__, __LINE__)
3452 
3462 #define kObjR(TypeName_T, T_object) \
3463  TypeName_T##Class* obj K_ATTRIBUTE_UNUSED = x##TypeName_T##_CastRaw(T_object)
3464 
3476 #define kObjN(TypeName_T, VarName_obj, T_object) \
3477  TypeName_T##Class* VarName_obj = xx##TypeName_T##_Cast(T_object, __FILE__, __LINE__)
3478 
3489 #define kObjNR(TypeName_T, VarName_obj, T_object) \
3490  TypeName_T##Class* VarName_obj = x##TypeName_T##_CastRaw(T_object)
3491 
3497 #define kStaticObj(TypeName_T) \
3498  TypeName_T##Static* sobj = kStaticOf(TypeName_T)
3499 
3510 #define kCastClass_(TYPE, OBJECT) \
3511  xkCastClass_(TYPE, OBJECT)
3512 
3523 #define kCastVTable_(TYPE, OBJECT) \
3524  xkCastVTable_(TYPE, OBJECT)
3525 
3536 #define kCastIVTable_(IFACE, OBJECT) \
3537  xkCastIVTable_(IFACE, OBJECT)
3538 
3544 #define kDebugBreak() \
3545  xkDebugBreak()
3546 
3547 #include <kApi/kApiDef.x.h>
3548 
3549 #endif
k32f y
Y-coordinate value.
Definition: kApiDef.h:1334
kStatus k32s_Parse(k32s *value, const kChar *str)
Converts string to k32s value.
k64f height
Height of the rectangular cuboid.
Definition: kApiDef.h:1571
Represents a 64-unit, null-terminated, kChar sequence.
#define kALLOC_TRAIT_NON_ATOMIC
Allocates memory that cannot support atomic operations.
Definition: kApiDef.h:2305
Represents a 32-bit unsigned integer.
k32s y
Y-coordinate of the origin.
Definition: kApiDef.h:1506
kBool kChar_IsSpace(kChar ch)
Checks whether ASCII character is a some kind of white space character type.
Definition: kApiDef.h:427
kStatus kBool_Parse(kBool *value, const kChar *str)
Converts string to kBool value.
k32u left
Horizontal origin.
Definition: kApiDef.h:1489
k64f height
Height of the rectangle.
Definition: kApiDef.h:1540
k32f x
X-coordinate of the origin.
Definition: kApiDef.h:1521
Rectangle structure with 32-bit signed integer fields.
Definition: kApiDef.h:1503
3D point structure with 32-bit floating-point fields.
Definition: kApiDef.h:1400
k64f x
X-coordinate of the origin.
Definition: kApiDef.h:1537
k32s width
Width of the rectangle.
Definition: kApiDef.h:1601
k8u b
Blue component value.
Definition: kApiDef.h:1689
k32s y
Y-coordinate value.
Definition: kApiDef.h:1388
#define kALLOC_TRAIT_SERIAL
Allocates memory suitable for single-threaded use only.
Definition: kApiDef.h:2304
k16s width
Width of the rectangle.
Definition: kApiDef.h:1475
32-bit color pixel structure (B/G/R/A).
Definition: kApiDef.h:1715
k16s y
Y-coordinate of the origin.
Definition: kApiDef.h:1474
k8u b
Blue component value.
Definition: kApiDef.h:1746
Represents a unique thread identifier.
2D point structure with 16-bit signed integer fields.
Definition: kApiDef.h:1303
kStatus(kCall * kFrameworkConstructorFx)(kObject *object, kAlloc allocator)
Required signature for kObject framework constructors.
Definition: kApiDef.h:2481
kChar kChar_ToLower(kChar ch)
Convert ASCII character to lower case.
Definition: kApiDef.h:403
kBool kAllocTrait_IsCudaManaged(kAllocTrait traits)
Reports whether the kALLOC_TRAIT_CUDA_MANAGED trait is present in an allocator trait bitset...
Definition: kApiDef.h:2379
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:576
Represents a 256-unit, null-terminated, kChar sequence.
kTypeName methodName
Method name (e.g. "Clone").
Definition: kApiDef.h:2490
kPointer receiver
Callback receiver context pointer.
Definition: kApiDef.h:1882
kTypeName name
Enumerator name (e.g. "kPIXEL_FORMAT_8BPP_GREYSCALE").
Definition: kApiDef.h:2516
#define kALLOC_TRAIT_CUDA_PINNED
Allocates Cuda pinned memory (host or device).
Definition: kApiDef.h:2307
Rotated rectangle structure with 32-bit floating-point fields.
Definition: kApiDef.h:1614
k64f y
Y-coordinate of the origin.
Definition: kApiDef.h:1538
k32s z
Z-coordinate value.
Definition: kApiDef.h:1389
Represents a void pointer.
32-bit color pixel structure (B/G/R/X).
Definition: kApiDef.h:1687
kStatus kSize_Parse(kSize *value, const kChar *str)
Converts string to kSize value.
k32f x
X-coordinate value.
Definition: kApiDef.h:1333
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:1771
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:2355
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:2139
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:2171
kBool kChar_IsLetter(kChar ch)
Checks whether ASCII character is a letter.
Definition: kApiDef.h:439
T kClamp(const T &v, const T &min, const T &max)
Returns a value limited to the specified range.
Definition: kApiDef.h:2091
k16s z
Z-coordinate value.
Definition: kApiDef.h:1374
T kMax(const T &a, const T &b)
Returns the maximum of two numbers.
Definition: kApiDef.h:2074
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:1599
Rotated rectangle structure with 32-bit signed integer fields.
Definition: kApiDef.h:1597
kBool kAllocTrait_IsSerial(kAllocTrait traits)
Reports whether the kALLOC_TRAIT_SERIAL trait is present in an allocator trait bitset.
Definition: kApiDef.h:2331
k32f yc
Y-coordinate of the rectangle center.
Definition: kApiDef.h:1617
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:1603
void * kPointer_ItemOffset(const void *pointer, kSSize itemIndex, kSize itemSize)
Gets a pointer to the Nth element of an array.
Definition: kApiDef.h:336
kTypeName displayName
Formatted display name (e.g. "8bpp Greyscale");.
Definition: kApiDef.h:2517
Represents type field information.
Definition: kApiDef.h:2500
k64f width
Width of the rectangular cuboid.
Definition: kApiDef.h:1570
Represents an 8-bit unsigned integer.
k64f x
X-coordinate of the origin.
Definition: kApiDef.h:1567
k64f depth
Depth of the rectangular cuboid.
Definition: kApiDef.h:1572
#define kInlineFx(TYPE)
Inline method declaration helper.
Definition: kApiDef.h:29
k64f y
Y-coordinate value.
Definition: kApiDef.h:1418
#define k64F_NULL
k64f invalid value.
Definition: kApiDef.h:222
k64f x
X-coordinate value.
Definition: kApiDef.h:1417
kBool kAllocTrait_IsNonAtomic(kAllocTrait traits)
Reports whether the kALLOC_TRAIT_NON_ATOMIC trait is present in an allocator trait bitset...
Definition: kApiDef.h:2343
Represents enumerator information.
Definition: kApiDef.h:2513
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:2306
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:2237
kStatus k16u_Parse(k16u *value, const kChar *str)
Converts string to k16u value.
k16s x
X-coordinate value.
Definition: kApiDef.h:1305
k16s y
Y-coordinate value.
Definition: kApiDef.h:1373
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:1861
kStatus k64f_Parse(k64f *value, const kChar *str)
Converts string to k64f value.
k32f angle
Rotation angle of the rectangle.
Definition: kApiDef.h:1620
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:1508
Rectangle structure with 32-bit floating-point fields.
Definition: kApiDef.h:1519
kBool kIsError(kStatus status)
Returns kTRUE if the given status value is not kOK.
Definition: kApiDef.h:564
k32s kVersion_Compare(kVersion version1, kVersion version2)
Returns an integral value indicating the relationship between the versions.
Definition: kApiDef.h:870
kBool kAllocTrait_IsCudaPinned(kAllocTrait traits)
Reports whether the kALLOC_TRAIT_CUDA_PINNED trait is present in an allocator trait bitset...
Definition: kApiDef.h:2367
k32s width
Width of the rectangle.
Definition: kApiDef.h:1507
#define k32F_NULL
k32f invalid value.
Definition: kApiDef.h:193
kStatus k32u_Parse(k32u *value, const kChar *str)
Converts string to k32u value.
k32s x
X-coordinate value.
Definition: kApiDef.h:1319
Pixel format descriptor.
k32u width
Width of the ROI.
Definition: kApiDef.h:1491
k32s height
Height of the rectangle.
Definition: kApiDef.h:1602
Rectangle structure with 64-bit floating-point fields.
Definition: kApiDef.h:1535
Represents a 128-unit, null-terminated, kChar sequence.
k32f x
X-coordinate value.
Definition: kApiDef.h:1402
k8u kVersion_Minor(kVersion version)
Returns the minor part of a version number.
Definition: kApiDef.h:894
#define kALLOC_TRAIT_CUDA_MANAGED
Allocates Cuda managed memory (host or device).
Definition: kApiDef.h:2308
kChar kChar_ToUpper(kChar ch)
Convert ASCII character to upper case.
Definition: kApiDef.h:415
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:1853
k8u kVersion_Major(kVersion version)
Returns the major part of a version number.
Definition: kApiDef.h:882
kBool k64f_IsNull(k64f value)
Tests for null k64f.
Definition: kApiDef.h:243
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:2187
k16s y
Y-coordinate value.
Definition: kApiDef.h:1306
Represents type method information.
Definition: kApiDef.h:2488
k16s x
X-coordinate value.
Definition: kApiDef.h:1372
k32f z
Z-coordinate value.
Definition: kApiDef.h:1404
kTypeName name
Field name.
Definition: kApiDef.h:2502
kStatus k32f_Parse(k32f *value, const kChar *str)
Converts string to k32f value.
k64f width
Width of the rectangle.
Definition: kApiDef.h:1539
k64f z
Z-coordinate value.
Definition: kApiDef.h:1419
Represents a callback function and context pointer.
Definition: kApiDef.h:1879
void kItemCopy(void *dest, const void *src, kSize size)
Performs a small copy with minimal overhead.
Definition: kApiDef.h:2272
k8u kVersion_Build(kVersion version)
Returns the build part of a version number.
Definition: kApiDef.h:918
k8u r
Red component value.
Definition: kApiDef.h:1719
2D point structure with 32-bit floating-point fields.
Definition: kApiDef.h:1331
k64f y
Y-coordinate of the origin.
Definition: kApiDef.h:1568
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:1447
k32s yc
Y-coordinate of the rectangle center.
Definition: kApiDef.h:1600
k8u r
Red component value.
Definition: kApiDef.h:1748
Represents a 32-bit signed integer.
Represents an Ethernet address.
Definition: kApiDef.h:1769
void * kPointer_ByteOffset(const void *pointer, kSSize offset)
Calculates a pointer address from a base address and a byte offset.
Definition: kApiDef.h:322
void(kCall * kFunction)()
Generic pointer to function.
Definition: kApiDef.h:31
k8u r
Red component value.
Definition: kApiDef.h:1691
k32f height
Height of the rectangle.
Definition: kApiDef.h:1619
kBool kChar_IsDigit(kChar ch)
Checks whether ASCII character is a digit.
Definition: kApiDef.h:451
k64f x
X-coordinate value.
Definition: kApiDef.h:1347
void kItemZero(void *dest, kSize size)
Zero-initializes a small amount of memory with minimal overhead.
Definition: kApiDef.h:2290
kVersion kVersion_Create(k32u major, k32u minor, k32u release, k32u build)
Creates a version value from its constituent parts.
Definition: kApiDef.h:817
kType type
Field type.
Definition: kApiDef.h:2503
k8u kVersion_Release(kVersion version)
Returns the release part of a version number.
Definition: kApiDef.h:906
kEndianness kEndianness_Host()
Reports the endianness of the current platform.
Definition: kApiDef.h:941
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:1345
kBool kEndianness_ShouldReverse(kEndianness endianness)
Reports whether byte ordering must be reversed to be consistent with the current platform.
Definition: kApiDef.h:952
kStatus(kCall * kCallbackFx)(kPointer receiver, kPointer sender, void *args)
Callback signature for a generic event handler.
Definition: kApiDef.h:1871
#define kALLOC_TRAIT_CUDA_DEVICE
Allocates Cuda device memory (device only).
Definition: kApiDef.h:2309
k8u g
Green component value.
Definition: kApiDef.h:1690
Represents a 64-bit signed integer.
Window structure with 32-bit unsigned integer fields.
Definition: kApiDef.h:1487
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:2403
T kMin(const T &a, const T &b)
Returns the minimum of two numbers.
Definition: kApiDef.h:2058
#define kALLOC_TRAIT_FOREIGN
Allocates memory in a foreign memory domain (non-host address space).
Definition: kApiDef.h:2303
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:1618
k8u b
Blue component value.
Definition: kApiDef.h:1717
k16s height
Height of the rectangle.
Definition: kApiDef.h:1476
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:1718
kStatus k64s_Parse(k64s *value, const kChar *str)
Converts string to k64s value.
k16s x
X-coordinate value.
Definition: kApiDef.h:1444
k32s x
X-coordinate value.
Definition: kApiDef.h:1387
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.
k32u top
Vertical origin.
Definition: kApiDef.h:1490
3D point structure with 16-bit signed integer fields.
Definition: kApiDef.h:1370
k32s value
Enumerator numeric value.
Definition: kApiDef.h:2515
kTypeName functionName
Full function name (e.g. "kObject_Clone").
Definition: kApiDef.h:2491
Represents a 16-bit signed integer.
k32f y
Y-coordinate of the origin.
Definition: kApiDef.h:1522
Represents a 32-bit floating-point number.
k64f y
Y-coordinate value.
Definition: kApiDef.h:1348
Root of all Zen classes.
Represents a version number.
k8u a
Alpha component value.
Definition: kApiDef.h:1720
#define kOK
Operation successful.
Definition: kApiDef.h:543
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:2107
Represents an error code.
k64f z
Z-coordinate of the origin.
Definition: kApiDef.h:1569
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:1692
k32u height
Height of the ROI.
Definition: kApiDef.h:1492
k32s y
Y-coordinate value.
Definition: kApiDef.h:1320
kSize offset
Offset of field within structure (bytes).
Definition: kApiDef.h:2504
k16s y
Y-coordinate value.
Definition: kApiDef.h:1445
#define kCall
kApi standard function calling convention.
Definition: kApiDef.h:15
k32f width
Width of the rectangle.
Definition: kApiDef.h:1523
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:1565
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:1471
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:1744
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:349
k32s x
X-coordinate of the origin.
Definition: kApiDef.h:1505
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:1997
Represents a memory allocator trait.
k32f xc
X-coordinate of the rectangle center.
Definition: kApiDef.h:1616
2D point structure with 32-bit signed integer fields.
Definition: kApiDef.h:1317
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:1473
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:2505
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:2209
k32f height
Height of the rectangle.
Definition: kApiDef.h:1524
k8u g
Green component value.
Definition: kApiDef.h:1747
3D point structure with 64-bit floating-point fields.
Definition: kApiDef.h:1415
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:2027
kBool kAllocTrait_IsCudaDevice(kAllocTrait traits)
Reports whether the kALLOC_TRAIT_CUDA_DEVICE trait is present in an allocator trait bitset...
Definition: kApiDef.h:2391
3D point structure with 32-bit signed integer fields.
Definition: kApiDef.h:1385
k16s z
Z-coordinate value.
Definition: kApiDef.h:1446
kStatus k8u_Parse(k8u *value, const kChar *str)
Converts string to k8u value.
k32f y
Y-coordinate value.
Definition: kApiDef.h:1403
4D point structure with 16-bit signed integer fields.
Definition: kApiDef.h:1442
kStatus k8s_Parse(k8s *value, const kChar *str)
Converts string to k8s value.