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 xk32f k32f;
171 
173 #define k32F_MIN (1.175494351e-38F)
174 #define k32F_MAX (3.402823466e+38F)
175 #define k32F_NULL (-k32F_MAX)
176 #define k32F_DIGITS (9)
177 
187 typedef xk64f k64f;
188 
190 #define k64F_MIN (2.2250738585072014e-308)
191 #define k64F_MAX (1.7976931348623157e+308)
192 #define k64F_NULL (-k64F_MAX)
193 #define k64F_DIGITS (17)
194 
204 kFx(k32s) k64f_IsNanOrInf(k64f value);
205 
214 typedef xkByte kByte;
215 
224 typedef xkSize kSize;
225 
227 #define kSIZE_MAX xkSIZE_MAX
228 #define kSIZE_NULL kSIZE_MAX
229 
241 kInlineFx(kSize) kSize_Align(kSize value, kSize to)
242 {
243  return ((value >> to) + !!(value & ((1 << to) - 1))) << to;
244 }
245 
252 typedef xkSSize kSSize;
253 
255 #define kSSIZE_MIN xkSSIZE_MIN
256 #define kSSIZE_MAX xkSSIZE_MAX
257 #define kSSIZE_NULL kSSIZE_MIN
258 
267 typedef void* kPointer;
268 
269 #define kNULL (0)
270 
271 
280 kInlineFx(void*) kPointer_ByteOffset(const void* pointer, kSSize offset)
281 {
282  return (kByte*)pointer + offset;
283 }
284 
294 kInlineFx(void*) kPointer_ItemOffset(const void* pointer, kSSize itemIndex, kSize itemSize)
295 {
296  return kPointer_ByteOffset(pointer, itemIndex*(kSSize)itemSize);
297 }
298 
307 kInlineFx(kSSize) kPointer_Diff(void* a, void* b)
308 {
309  return (kSSize)a - (kSSize)b;
310 }
311 
320 #define kPointer_ReadAs(POINTER, TYPE) \
321  (*(TYPE*)(POINTER))
322 
331 #define kPointer_WriteAs(POINTER, VALUE, TYPE) \
332  (*(TYPE*)(POINTER) = (TYPE)(VALUE))
333 
341 #define kIsNull(POINTER) \
342  ((POINTER) == kNULL)
343 
352 typedef k32s kBool;
353 
355 #define kFALSE (0)
356 #define kTRUE (1)
357 
367 typedef xkChar kChar;
368 
377 {
378  return (ch >= 'A' && ch <= 'Z') ? (ch - 'A' + 'a') : ch;
379 }
380 
389 {
390  return (ch >= 'a' && ch <= 'z') ? (ch - 'a' + 'A') : ch;
391 }
392 
401 {
402  return ch == ' ';
403 }
404 
413 {
414  return ((ch >= 'a') && (ch <= 'z') ) || ((ch >= 'A') && (ch <= 'Z'));
415 }
416 
425 {
426  return ch >= '0' && ch <= '9';
427 }
428 
437 typedef kChar kText16[16];
438 
447 typedef kChar kText32[32];
448 
457 typedef kChar kText64[64];
458 
467 typedef kChar kText128[128];
468 
477 typedef kChar kText256[256];
478 
487 typedef k32s kStatus;
488 
490 #define kERROR_STATE (-1000)
491 #define kERROR_NOT_FOUND (-999)
492 #define kERROR_COMMAND (-998)
493 #define kERROR_PARAMETER (-997)
494 #define kERROR_UNIMPLEMENTED (-996)
495 #define kERROR_MEMORY (-994)
496 #define kERROR_TIMEOUT (-993)
497 #define kERROR_INCOMPLETE (-992)
498 #define kERROR_STREAM (-991)
499 #define kERROR_CLOSED (-990)
500 #define kERROR_VERSION (-989)
501 #define kERROR_ABORT (-988)
502 #define kERROR_ALREADY_EXISTS (-987)
503 #define kERROR_NETWORK (-986)
504 #define kERROR_HEAP (-985)
505 #define kERROR_FORMAT (-984)
506 #define kERROR_READ_ONLY (-983)
507 #define kERROR_WRITE_ONLY (-982)
508 #define kERROR_BUSY (-981)
509 #define kERROR_CONFLICT (-980)
510 #define kERROR_OS (-979)
511 #define kERROR_DEVICE (-978)
512 #define kERROR_FULL (-977)
513 #define kERROR_IN_PROGRESS (-976)
514 #define kERROR (0)
515 #define kOK (1)
516 
527 kFx(const kChar*) kStatus_Name(kStatus status);
528 
537 {
538  return status != kOK;
539 }
540 
549 {
550  return status == kOK;
551 }
552 
561 #define kCheck(EXPRESSION) \
562  xkCheck(EXPRESSION)
563 
573 #define kCheckTrue(EXPRESSION, STATUS) \
574  xkCheckTrue(EXPRESSION, STATUS)
575 
584 #define kCheckArgs(EXPRESSION) \
585  xkCheckArgs(EXPRESSION)
586 
595 #define kCheckState(EXPRESSION) \
596  xkCheckState(EXPRESSION)
597 
603 #define kTry \
604  xkTry
605 
612 #define kThrow(EXPRESSION) \
613  xkThrow(EXPRESSION)
614 
624 #define kTest(EXPRESSION) \
625  xkTest(EXPRESSION)
626 
637 #define kTestTrue(EXPRESSION, STATUS) \
638  xkTestTrue(EXPRESSION, STATUS)
639 
649 #define kTestArgs(EXPRESSION) \
650  xkTestArgs(EXPRESSION)
651 
661 #define kTestState(EXPRESSION) \
662  xkTestState(EXPRESSION)
663 
670 #define kCatch(STATUS_POINTER) \
671  xkCatch(STATUS_POINTER)
672 
681 #define kEndCatch(STATUS) \
682  xkEndCatch(STATUS)
683 
689 #define kFinally \
690  xkFinally
691 
700 #define kEndFinally() \
701  xkEndFinally()
702 
709 #define kCatchEx(STATUS_POINTER) \
710  xkCatchEx(STATUS_POINTER)
711 
722 #define kEndCatchEx(STATUS) \
723  xkEndCatchEx(STATUS)
724 
730 #define kFinallyEx \
731  xkFinallyEx
732 
741 #define kEndFinallyEx() \
742  xkEndFinallyEx()
743 
751 #define kAssert(EXPRESSION) \
752  xkAssert(EXPRESSION)
753 
764 #define kAssertType(OBJECT, SYMBOL) \
765  xkAssertType(OBJECT, SYMBOL)
766 
774 #define kTrace(TAG) \
775  xkTrace(TAG)
776 
785 typedef k32u kVersion;
786 
787 #define kVERSION_NULL (k32U_NULL) // kVersion invalid value.
788 
799 kInlineFx(kVersion) kVersion_Create(k32u major, k32u minor, k32u release, k32u build)
800 {
801  return (major & 0xFF) << 24 |
802  (minor & 0xFF) << 16 |
803  (release & 0xFF) << 8 |
804  (build & 0xFF);
805 }
806 
817 #define kVersion_Stringify_(MAJOR, MINOR, RELEASE, BUILD) \
818  xkStringize(MAJOR) "." xkStringize(MINOR) "." xkStringize(RELEASE) "." xkStringize(BUILD)
819 
828 kFx(kStatus) kVersion_Parse(kVersion* version, const kChar* buffer);
829 
839 kFx(kStatus) kVersion_Format(kVersion version, kChar* buffer, kSize capacity);
840 
853 {
854  return (k32s)version1 - (k32s)version2;
855 }
856 
865 {
866  return (version >> 24) & 0xFF;
867 }
868 
877 {
878  return (version >> 16) & 0xFF;
879 }
880 
889 {
890  return (version >> 8) & 0xFF;
891 }
892 
901 {
902  return (version) & 0xFF;
903 }
904 
911 typedef k32s kEndianness;
912 
914 #define kENDIANNESS_LITTLE (1)
915 #define kENDIANNESS_BIG (2)
916 
923 kInlineFx(kEndianness) kEndianness_Host()
924 {
925  return K_ENDIANNESS;
926 }
927 
935 {
936  return endianness != kEndianness_Host();
937 }
938 
953 kFx(kStatus) k8u_Format(k8u value, kChar* buffer, kSize capacity);
954 
963 kFx(kStatus) k8u_Parse(k8u* value, const kChar* str);
964 
979 kFx(kStatus) k8s_Format(k8s value, kChar* buffer, kSize capacity);
980 
989 kFx(kStatus) k8s_Parse(k8s* value, const kChar* str);
990 
1005 kFx(kStatus) k16u_Format(k16u value, kChar* buffer, kSize capacity);
1006 
1015 kFx(kStatus) k16u_Parse(k16u* value, const kChar* str);
1016 
1031 kFx(kStatus) k16s_Format(k16s value, kChar* buffer, kSize capacity);
1032 
1041 kFx(kStatus) k16s_Parse(k16s* value, const kChar* str);
1042 
1057 kFx(kStatus) k32u_Format(k32u value, kChar* buffer, kSize capacity);
1058 
1067 kFx(kStatus) k32u_Parse(k32u* value, const kChar* str);
1068 
1083 kFx(kStatus) k32s_Format(k32s value, kChar* buffer, kSize capacity);
1084 
1093 kFx(kStatus) k32s_Parse(k32s* value, const kChar* str);
1094 
1109 kFx(kStatus) k64u_Format(k64u value, kChar* buffer, kSize capacity);
1110 
1119 kFx(kStatus) k64u_Parse(k64u* value, const kChar* str);
1120 
1135 kFx(kStatus) k64s_Format(k64s value, kChar* buffer, kSize capacity);
1136 
1145 kFx(kStatus) k64s_Parse(k64s* value, const kChar* str);
1146 
1161 kFx(kStatus) kBool_Format(kBool value, kChar* buffer, kSize capacity);
1162 
1171 kFx(kStatus) kBool_Parse(kBool* value, const kChar* str);
1172 
1187 kFx(kStatus) kSize_Format(kSize value, kChar* buffer, kSize capacity);
1188 
1197 kFx(kStatus) kSize_Parse(kSize* value, const kChar* str);
1198 
1213 kFx(kStatus) kSSize_Format(kSSize value, kChar* buffer, kSize capacity);
1214 
1223 kFx(kStatus) kSSize_Parse(kSSize* value, const kChar* str);
1224 
1239 kFx(kStatus) k32f_Format(k32f value, kChar* buffer, kSize capacity);
1240 
1249 kFx(kStatus) k32f_Parse(k32f* value, const kChar* str);
1250 
1265 kFx(kStatus) k64f_Format(k64f value, kChar* buffer, kSize capacity);
1266 
1275 kFx(kStatus) k64f_Parse(k64f* value, const kChar* str);
1276 
1285 typedef struct kPoint16s
1286 {
1289 } kPoint16s;
1290 
1299 typedef struct kPoint32s
1300 {
1303 } kPoint32s;
1304 
1313 typedef struct kPoint32f
1314 {
1317 } kPoint32f;
1318 
1327 typedef struct kPoint64f
1328 {
1331 } kPoint64f;
1332 
1342 #define kPoint_Init_(POINT, X, Y) xkPoint_Init_(POINT, X, Y)
1343 
1352 typedef struct kPoint3d16s
1353 {
1357 } kPoint3d16s;
1358 
1367 typedef struct kPoint3d32s
1368 {
1372 } kPoint3d32s;
1373 
1382 typedef struct kPoint3d32f
1383 {
1387 } kPoint3d32f;
1388 
1397 typedef struct kPoint3d64f
1398 {
1402 } kPoint3d64f;
1403 
1414 #define kPoint3d_Init_(POINT, X, Y, Z) xkPoint3d_Init_(POINT, X, Y, Z)
1415 
1424 typedef struct kPoint4d16s
1425 {
1430 } kPoint4d16s;
1431 
1443 #define kPoint4d_Init_(POINT, X, Y, Z, W) xkPoint4d_Init_(POINT, X, Y, Z, W)
1444 
1453 typedef struct kRect16s
1454 {
1459 } kRect16s;
1460 
1469 typedef struct kRect32s
1470 {
1475 } kRect32s;
1476 
1485 typedef struct kRect32f
1486 {
1491 } kRect32f;
1492 
1501 typedef struct kRect64f
1502 {
1507 } kRect64f;
1508 
1520 #define kRect_Init_(RECT, X, Y, W, H) \
1521  xkRect_Init_(RECT, X, Y, W, H)
1522 
1531 typedef struct kRect3d64f
1532 {
1539 } kRect3d64f;
1540 
1552 #define kRect3d_Init_(RECT, X, Y, Z, W, H, D) \
1553  xkRect3d_Init_(RECT, X, Y, Z, W, H, D)
1554 
1563 typedef struct kRotatedRect32s
1564 {
1570 } kRotatedRect32s;
1571 
1580 typedef struct kRotatedRect32f
1581 {
1587 } kRotatedRect32f;
1588 
1601 #define kRotatedRect_Init_(RECT, XC, YC, W, H, A) \
1602  xkRotatedRect_Init_(RECT, XC, YC, W, H, A)
1603 
1612 typedef k32s kPixelFormat;
1613 
1615 #define kPIXEL_FORMAT_NULL (0)
1616 #define kPIXEL_FORMAT_8BPP_GREYSCALE (1)
1617 #define kPIXEL_FORMAT_8BPP_CFA (2)
1618 #define kPIXEL_FORMAT_8BPC_BGRX (3)
1619 #define kPIXEL_FORMAT_1BPP_GREYSCALE (4)
1620 #define kPIXEL_FORMAT_16BPP_GREYSCALE (5)
1621 
1631 typedef k32s kCfa;
1632 
1634 #define kCFA_NONE (0)
1635 #define kCFA_BAYER_BGGR (1)
1636 #define kCFA_BAYER_GBRG (2)
1637 #define kCFA_BAYER_RGGB (3)
1638 #define kCFA_BAYER_GRBG (4)
1639 
1649 typedef struct kRgb
1650 {
1651  k8u b;
1652  k8u g;
1653  k8u r;
1654  k8u x;
1655 } kRgb;
1656 
1666 #define kRgb_Init_(RGB, R, G, B) \
1667  xkRgb_Init_(RGB, R, G, B)
1668 
1677 typedef struct kArgb
1678 {
1679  k8u b;
1680  k8u g;
1681  k8u r;
1682  k8u a;
1683 } kArgb;
1684 
1695 #define kArgb_Init_(ARGB, A, R, G, B) \
1696  xkArgb_Init_(ARGB, A, R, G, B)
1697 
1704 typedef struct kMacAddress
1705 {
1707 } kMacAddress;
1708 
1715 typedef k32s kMemoryAlignment;
1716 
1718 #define kMEMORY_ALIGNMENT_8 (3)
1719 #define kMEMORY_ALIGNMENT_16 (4)
1720 #define kMEMORY_ALIGNMENT_32 (5)
1721 #define kMEMORY_ALIGNMENT_64 (6)
1722 #define kMEMORY_ALIGNMENT_128 (7)
1723 #define kMEMORY_ALIGNMENT_256 (8)
1724 #define kMEMORY_ALIGNMENT_512 (9)
1725 #define kMEMORY_ALIGNMENT_1024 (10)
1726 #define kMEMORY_ALIGNMENT_2048 (11)
1727 #define kMEMORY_ALIGNMENT_4096 (12)
1728 
1736 kInlineFx(kSize) kMemoryAlignment_Size(kMemoryAlignment alignment)
1737 {
1738  return ((kSize)1 << (kSize)alignment);
1739 }
1740 
1751 kFx(kStatus) kMacAddress_Parse(kMacAddress* address, const kChar* text);
1752 
1764 kFx(kStatus) kMacAddress_Format(kMacAddress address, kChar* text, kSize capacity);
1765 
1772 typedef k32s kComparison;
1773 
1774 #define kCOMPARISON_EQ (0)
1775 #define kCOMPARISON_NEQ (1)
1776 #define kCOMPARISON_LT (2)
1777 #define kCOMPARISON_LTE (3)
1778 #define kCOMPARISON_GT (4)
1779 #define kCOMPARISON_GTE (5)
1780 
1781 
1788 typedef kBool (kCall* kEqualsFx)(const void* item1, const void* item2);
1789 
1796 typedef kSize (kCall* kHashFx)(const void* item);
1797 
1806 typedef kStatus (kCall* kCallbackFx)(kPointer receiver, kPointer sender, void* args);
1807 
1814 typedef struct kCallback
1815 {
1816  kCallbackFx function;
1818 } kCallback;
1819 
1826 typedef k32s kFileMode;
1827 
1829 #define kFILE_MODE_READ (0x1)
1830 #define kFILE_MODE_WRITE (0x2)
1831 #define kFILE_MODE_UPDATE (0x4)
1832 
1840 typedef k32s kSeekOrigin;
1841 
1843 #define kSEEK_ORIGIN_BEGIN (0)
1844 #define kSEEK_ORIGIN_CURRENT (1)
1845 #define kSEEK_ORIGIN_END (2)
1846 
1854 typedef k32s kCompressionType;
1855 
1857 #define kCOMPRESSION_TYPE_NULL (0)
1858 #define kCOMPRESSION_TYPE_ZSTD (1)
1859 
1860 
1868 typedef k32s kCompressionPreset;
1869 
1871 #define kCOMPRESSION_PRESET_MIN (-1)
1872 #define kCOMPRESSION_PRESET_FAST (-2)
1873 #define kCOMPRESSION_PRESET_DEFAULT (-3)
1874 #define kCOMPRESSION_PRESET_DENSE (-4)
1875 #define kCOMPRESSION_PRESET_MAX (-5)
1876 
1887 typedef k64u kLogOption;
1888 
1890 #define kLOG_OPTION_WARNING (0x1)
1891 #define kLOG_OPTION_ERROR (0x2)
1892 #define kLOG_OPTION_PLATFORM (0x10)
1893 
1903 #define kCountOf(CARRAY) \
1904  (sizeof(CARRAY)/sizeof(CARRAY[0]))
1905 
1915 #define kCast(TYPE, ITEM) \
1916  ((TYPE)(ITEM))
1917 
1918 #if (K_CPP_VERSION >= K_CPP_VERSION_2011)
1919 
1929 template <typename T>
1930 static kInline typename std::enable_if<std::is_unsigned<T>::value, T>::type kAbs(const T& v)
1931 {
1932  return v;
1933 }
1934 
1944 template <typename T>
1945 static kInline typename std::enable_if<!std::is_unsigned<T>::value, T>::type kAbs(const T& v)
1946 {
1947  return (v >= T()) ? v : -v;
1948 }
1949 
1959 template <typename T>
1960 static kInline typename std::enable_if<std::is_unsigned<T>::value, T>::type kSign(const T& v)
1961 {
1962  return v > T();
1963 }
1964 
1974 template <typename T>
1975 static kInline typename std::enable_if<!std::is_unsigned<T>::value, T>::type kSign(const T& v)
1976 {
1977  return (v > T()) - (v < T());
1978 }
1979 
1990 template <typename T>
1991 kInlineFx(T) kMin(const T& a, const T& b)
1992 {
1993  return (a < b) ? a : b;
1994 }
1995 
2006 template <typename T>
2007 kInlineFx(T) kMax(const T& a, const T& b)
2008 {
2009  return (a > b) ? a : b;
2010 }
2011 
2023 template <typename T>
2024 kInlineFx(T) kClamp(const T& v, const T& min, const T& max)
2025 {
2026  return kMin(kMax(v, min), max);
2027 }
2028 
2039 template <typename T>
2040 static kInline typename std::enable_if<std::is_unsigned<T>::value, T>::type kDivideFloor(const T& a, const T& b)
2041 {
2042  return a / b;
2043 }
2044 
2055 template <typename T>
2056 static kInline typename std::enable_if<!std::is_unsigned<T>::value, T>::type kDivideFloor(const T& a, const T& b)
2057 {
2058  return ((kSign(a) * kSign(b)) >= T()) ? a / b : ((a / b) - ((a % b) != T()));
2059 }
2060 
2071 template <typename T>
2072 static kInline typename std::enable_if<std::is_unsigned<T>::value, T>::type kDivideCeil(const T& a, const T& b)
2073 {
2074  return (a / b) + ((a % b) != T());
2075 }
2076 
2087 template <typename T>
2088 static kInline typename std::enable_if<!std::is_unsigned<T>::value, T>::type kDivideCeil(const T& a, const T& b)
2089 {
2090  return ((kSign(a) * kSign(b)) <= T()) ? a / b : ((a / b) + ((a % b) != T()));
2091 }
2092 
2103 template <typename T>
2104 kInlineFx(T) kQuantizeFloor(const T& value, const T& granularity)
2105 {
2106  return kDivideFloor(value, granularity) * granularity;
2107 }
2108 
2119 template <typename T>
2120 kInlineFx(T) kQuantizeCeil(const T& value, const T& granularity)
2121 {
2122  return kDivideCeil(value, granularity) * granularity;
2123 }
2124 
2141 template <typename T>
2142 kInlineFx(T) kAdjustFloor(const T& value, const T& min, const T& max, const T& granularity)
2143 {
2144  typedef typename std::make_unsigned<T>::type U;
2145  U relativeValue = (value >= min) ? (U) (value - min) : U();
2146  U relativeMax = (max >= min) ? (U) (max - min) : U();
2147  U quantizedRelativeMax = kQuantizeFloor<U>(relativeMax, granularity);
2148  U limitedRelativeValue = kMin<U>(relativeValue, quantizedRelativeMax);
2149 
2150  return (T) kQuantizeFloor<U>(limitedRelativeValue, granularity) + min;
2151 }
2152 
2169 template <typename T>
2170 kInlineFx(T) kAdjustCeil(const T& value, const T& min, const T& max, const T& granularity)
2171 {
2172  typedef typename std::make_unsigned<T>::type U;
2173  U relativeValue = (value >= min) ? (U) (value - min) : U();
2174  U relativeMax = (max >= min) ? (U) (max - min) : U();
2175  U quantizedRelativeMax = kQuantizeFloor<U>(relativeMax, granularity);
2176  U limitedRelativeValue = kMin<U>(relativeValue, quantizedRelativeMax);
2177 
2178  return (T) kQuantizeCeil<U>(limitedRelativeValue, granularity) + min;
2179 }
2180 
2181 #endif
2182 
2188 #define kZero(VALUE) \
2189  memset(&VALUE, 0, sizeof(VALUE))
2190 
2205 kInlineFx(void) kItemCopy(void* dest, const void* src, kSize size)
2206 {
2207  memcpy(dest, src, size);
2208 }
2209 
2223 kInlineFx(void) kItemZero(void* dest, kSize size)
2224 {
2225  memset(dest, 0, size);
2226 }
2227 
2233 typedef k32s kAllocTrait;
2234 
2236 #define kALLOC_TRAIT_FOREIGN (0x00000001)
2237 #define kALLOC_TRAIT_SERIAL (0x00000002)
2238 #define kALLOC_TRAIT_NON_ATOMIC (0x00000004)
2239 #define kALLOC_TRAIT_CONTEXT (0x00000008)
2240 #define kALLOC_TRAIT_CUDA_PINNED (0x00010000)
2241 #define kALLOC_TRAIT_CUDA_MANAGED (0x00020000)
2242 #define kALLOC_TRAIT_CUDA_DEVICE (0x01000000)
2243 
2252 kInlineFx(kBool) kAllocTrait_IsForeign(kAllocTrait traits)
2253 {
2254  return (traits & kALLOC_TRAIT_FOREIGN) != 0;
2255 }
2256 
2265 {
2266  return (traits & kALLOC_TRAIT_SERIAL) != 0;
2267 }
2268 
2277 {
2278  return (traits & kALLOC_TRAIT_NON_ATOMIC) != 0;
2279 }
2280 
2289 {
2290  return (traits & kALLOC_TRAIT_CONTEXT) != 0;
2291 }
2292 
2301 {
2302  return (traits & kALLOC_TRAIT_CUDA_PINNED) != 0;
2303 }
2304 
2313 {
2314  return (traits & kALLOC_TRAIT_CUDA_MANAGED) != 0;
2315 }
2316 
2325 {
2326  return (traits & kALLOC_TRAIT_CUDA_DEVICE) != 0;
2327 }
2328 
2337 {
2339 }
2340 
2348 typedef kSize kThreadId;
2349 
2358 kFx(kBool) kThreadId_Compare(kThreadId a, kThreadId b);
2359 
2367 typedef k32s kThreadPriorityClass;
2368 
2370 #define kTHREAD_PRIORITY_CLASS_LOW (-1)
2371 #define kTHREAD_PRIORITY_CLASS_NORMAL (0)
2372 #define kTHREAD_PRIORITY_CLASS_HIGH (1)
2373 
2375 /*
2376  * Forward declarations
2377  */
2378 
2379 typedef void* kObject;
2380 typedef kObject kType;
2381 typedef kObject kAlloc;
2382 
2384 #define kTypeName kText64
2385 
2393 typedef k32u kTypeFlags;
2394 
2396 #define kTYPE_FLAGS_CLASS (0x01)
2397 #define kTYPE_FLAGS_INTERFACE (0x02)
2398 #define kTYPE_FLAGS_VALUE (0x04)
2399 #define kTYPE_FLAGS_ENUM (0x08)
2400 #define kTYPE_FLAGS_ABSTRACT (0x20)
2401 #define kTYPE_FLAGS_ARRAY_VALUE (0x40)
2402 #define kTYPE_FLAGS_PRIMITIVE (0x80)
2403 
2411 typedef kPointer kTypeVersion;
2412 
2414 typedef kStatus (kCall* kFrameworkConstructorFx)(kObject* object, kAlloc allocator);
2415 
2421 typedef struct kMethodInfo
2422 {
2423  kTypeName methodName;
2424  kTypeName functionName;
2425  kFunction function;
2426 } kMethodInfo;
2427 
2433 typedef struct kFieldInfo
2434 {
2435  kTypeName name;
2436  kType type;
2439 } kFieldInfo;
2440 
2446 typedef struct kEnumeratorInfo
2447 {
2449  kTypeName name;
2450  kTypeName displayName;
2451 } kEnumeratorInfo;
2452 
2478 #define kTypeOf(SYMBOL) \
2479  xkTypeOf(SYMBOL)
2480 
2506 #define kAssemblyOf(SYMBOL) \
2507  xkAssemblyOf(SYMBOL)
2508 
2517 #define kStaticOf(SYMBOL) \
2518  xkStaticOf(SYMBOL)
2519 
2527 #define kDeprecate(SYMBOL) \
2528  xkDeprecate(#SYMBOL)
2529 
2538 #define kWarn(MESSAGE) \
2539  xkWarn(MESSAGE)
2540 
2541 /*
2542 *
2543 * Type Declaration/Definition Macros, Generation 1.
2544 *
2545 * These type declaration/definition macros continue to be supported. However, consider using the Generation 2
2546 * macros (defined below) in new code.
2547 *
2548 */
2549 
2557 #define kDeclareAssembly(PREFIX, SYMBOL) \
2558  xkDeclareAssembly(PREFIX, SYMBOL)
2559 
2569 #define kBeginAssembly(PREFIX, SYMBOL, VERSION, PLATFORM_VERSION) \
2570  xkBeginAssembly(PREFIX, SYMBOL, VERSION, PLATFORM_VERSION)
2571 
2577 #define kEndAssembly() \
2578  xkEndAssembly()
2579 
2588 #define kDeclareValue(PREFIX, SYMBOL, BASE) \
2589  xkDeclareValue(PREFIX, SYMBOL, BASE)
2590 
2599 #define kBeginValue(PREFIX, SYMBOL, BASE) \
2600  xkBeginValue(PREFIX, SYMBOL, BASE)
2601 
2607 #define kEndValue() \
2608  xkEndValue()
2609 
2618 #define kDeclareEnum(PREFIX, SYMBOL, BASE) \
2619  xkDeclareEnum(PREFIX, SYMBOL, BASE)
2620 
2629 #define kBeginEnum(PREFIX, SYMBOL, BASE) \
2630  xkBeginEnum(PREFIX, SYMBOL, BASE)
2631 
2637 #define kEndEnum() \
2638  xkEndEnum()
2639 
2648 #define kDeclareArrayValue(PREFIX, SYMBOL, BASE) \
2649  xkDeclareArrayValue(PREFIX, SYMBOL, BASE)
2650 
2660 #define kBeginArrayValue(PREFIX, SYMBOL, TYPE, BASE) \
2661  xkBeginArrayValue(PREFIX, SYMBOL, TYPE, BASE)
2662 
2668 #define kEndArrayValue() \
2669  xkEndArrayValue()
2670 
2679 #define kDeclareInterface(PREFIX, SYMBOL, BASE) \
2680  xkDeclareInterface(PREFIX, SYMBOL, BASE)
2681 
2690 #define kBeginInterface(PREFIX, SYMBOL, BASE) \
2691  xkBeginInterface(PREFIX, SYMBOL, BASE)
2692 
2698 #define kEndInterface() \
2699  xkEndInterface()
2700 
2709 #define kDeclareFullClass(PREFIX, SYMBOL, BASE) \
2710  xkDeclareFullClass(PREFIX, SYMBOL, BASE)
2711 
2720 #define kBeginFullClass(PREFIX, SYMBOL, BASE) \
2721  xkBeginFullClass(PREFIX, SYMBOL, BASE)
2722 
2728 #define kEndFullClass() \
2729  xkEndFullClass()
2730 
2739 #define kDeclareVirtualClass(PREFIX, SYMBOL, BASE) \
2740  xkDeclareVirtualClass(PREFIX, SYMBOL, BASE)
2741 
2750 #define kBeginVirtualClass(PREFIX, SYMBOL, BASE) \
2751  xkBeginVirtualClass(PREFIX, SYMBOL, BASE)
2752 
2758 #define kEndVirtualClass() \
2759  xkEndVirtualClass()
2760 
2768 #define kDeclareStaticClass(PREFIX, SYMBOL) \
2769  xkDeclareStaticClass(PREFIX, SYMBOL)
2770 
2778 #define kBeginStaticClass(PREFIX, SYMBOL) \
2779  xkBeginStaticClass(PREFIX, SYMBOL)
2780 
2786 #define kEndStaticClass() \
2787  xkEndStaticClass()
2788 
2797 #define kDeclareClass(PREFIX, SYMBOL, BASE) \
2798  xkDeclareClass(PREFIX, SYMBOL, BASE)
2799 
2808 #define kBeginClass(PREFIX, SYMBOL, BASE) \
2809  xkBeginClass(PREFIX, SYMBOL, BASE)
2810 
2816 #define kEndClass() \
2817  xkEndClass()
2818 
2819 /*
2820 *
2821 * Type Declaration/Definition Macros, Generation 2.
2822 *
2823 * These macros are used to declare and define elements of the type system, such
2824 * as assemblies, classes and values. These macros supersede the Generation 1 macros,
2825 * defined above.
2826 *
2827 */
2828 
2836 #define kDeclareAssemblyEx(PREFIX, SYMBOL) \
2837  xkDeclareAssemblyEx(PREFIX, SYMBOL)
2838 
2848 #define kBeginAssemblyEx(PREFIX, SYMBOL, VERSION, PLATFORM_VERSION) \
2849  xkBeginAssemblyEx(PREFIX, SYMBOL, VERSION, PLATFORM_VERSION)
2850 
2856 #define kEndAssemblyEx() \
2857  xkEndAssemblyEx()
2858 
2867 #define kDeclareValueEx(PREFIX, SYMBOL, BASE) \
2868  xkDeclareValueEx(PREFIX, SYMBOL, BASE)
2869 
2877 #define kBeginValueEx(PREFIX, SYMBOL) \
2878  xkBeginValueEx(PREFIX, SYMBOL)
2879 
2885 #define kEndValueEx() \
2886  xkEndValueEx()
2887 
2896 #define kDeclareEnumEx(PREFIX, SYMBOL, BASE) \
2897  xkDeclareEnumEx(PREFIX, SYMBOL, BASE)
2898 
2906 #define kBeginEnumEx(PREFIX, SYMBOL) \
2907  xkBeginEnumEx(PREFIX, SYMBOL)
2908 
2914 #define kEndEnumEx() \
2915  xkEndEnumEx()
2916 
2925 #define kDeclareArrayValueEx(PREFIX, SYMBOL, BASE) \
2926  xkDeclareArrayValueEx(PREFIX, SYMBOL, BASE)
2927 
2936 #define kBeginArrayValueEx(PREFIX, SYMBOL, TYPE) \
2937  xkBeginArrayValueEx(PREFIX, SYMBOL, TYPE)
2938 
2944 #define kEndArrayValueEx() \
2945  xkEndArrayValueEx()
2946 
2955 #define kDeclareInterfaceEx(PREFIX, SYMBOL, BASE) \
2956  xkDeclareInterfaceEx(PREFIX, SYMBOL, BASE)
2957 
2965 #define kBeginInterfaceEx(PREFIX, SYMBOL) \
2966  xkBeginInterfaceEx(PREFIX, SYMBOL)
2967 
2973 #define kEndInterfaceEx() \
2974  xkEndInterfaceEx()
2975 
2984 #define kDeclareFullClassEx(PREFIX, SYMBOL, BASE) \
2985  xkDeclareFullClassEx(PREFIX, SYMBOL, BASE)
2986 
2994 #define kBeginFullClassEx(PREFIX, SYMBOL) \
2995  xkBeginFullClassEx(PREFIX, SYMBOL)
2996 
3002 #define kEndFullClassEx() \
3003  xkEndFullClassEx()
3004 
3013 #define kDeclareVirtualClassEx(PREFIX, SYMBOL, BASE) \
3014  xkDeclareVirtualClassEx(PREFIX, SYMBOL, BASE)
3015 
3023 #define kBeginVirtualClassEx(PREFIX, SYMBOL) \
3024  xkBeginVirtualClassEx(PREFIX, SYMBOL)
3025 
3031 #define kEndVirtualClassEx() \
3032  xkEndVirtualClassEx()
3033 
3041 #define kDeclareStaticClassEx(PREFIX, SYMBOL) \
3042  xkDeclareStaticClassEx(PREFIX, SYMBOL)
3043 
3051 #define kBeginStaticClassEx(PREFIX, SYMBOL) \
3052  xkBeginStaticClassEx(PREFIX, SYMBOL)
3053 
3059 #define kEndStaticClassEx() \
3060  xkEndStaticClassEx()
3061 
3070 #define kDeclareClassEx(PREFIX, SYMBOL, BASE) \
3071  xkDeclareClassEx(PREFIX, SYMBOL, BASE)
3072 
3080 #define kBeginClassEx(PREFIX, SYMBOL) \
3081  xkBeginClassEx(PREFIX, SYMBOL)
3082 
3088 #define kEndClassEx() \
3089  xkEndClassEx()
3090 
3091 /*
3092 *
3093 * Type Implementation Macros
3094 *
3095 * These macros are used to provide type-specific details. They are typically used between
3096 * type definition begin/end macros (e.g., kBeginClass/kEndClass).
3097 *
3098 */
3099 
3106 #define kAddDependency(SYMBOL) \
3107  xkAddDependency(SYMBOL)
3108 
3115 #define kAddType(SYMBOL) \
3116  xkAddType(SYMBOL)
3117 
3128 #define kAddPriority(SYMBOL) \
3129  xkAddPriority(SYMBOL)
3130 
3139 #define kAddStatic(SYMBOL) \
3140  xkAddStatic(SYMBOL)
3141 
3149 #define kAddInterface(SYMBOL, IFACE) \
3150  xkAddInterface(SYMBOL, IFACE)
3151 
3170 #define kAddFrameworkConstructor(SYMBOL, CTOR) \
3171  xkAddFrameworkConstructor(SYMBOL, CTOR)
3172 
3191 #define kAddPrivateFrameworkConstructor(SYMBOL, CTOR) \
3192  xkAddPrivateFrameworkConstructor(SYMBOL, CTOR)
3193 
3201 #define kAddMethod(SYMBOL, METHOD) \
3202  xkAddMethod(SYMBOL, METHOD)
3203 
3212 #define kAddVMethod(IN_TYPE, FROM_TYPE, METHOD) \
3213  xkAddVMethod(IN_TYPE, FROM_TYPE, METHOD)
3214 
3225 #define kAddPrivateVMethod(IN_TYPE, FROM_TYPE, METHOD) \
3226  xkAddPrivateVMethod(IN_TYPE, FROM_TYPE, METHOD)
3227 
3237 #define kAddIVMethod(IN_TYPE, FROM_IFACE, IMETHOD, CMETHOD) \
3238  xkAddIVMethod(IN_TYPE, FROM_IFACE, IMETHOD, CMETHOD)
3239 
3251 #define kAddPrivateIVMethod(IN_TYPE, FROM_IFACE, IMETHOD, CMETHOD) \
3252  xkAddPrivateIVMethod(IN_TYPE, FROM_IFACE, IMETHOD, CMETHOD)
3253 
3262 #define kAddField(VALUE, FIELD_TYPE, FIELD) \
3263  xkAddField(VALUE, FIELD_TYPE, FIELD)
3264 
3272 #define kAddEnumerator \
3273  xkAddEnumerator
3274 
3293 #define kAddVersionEx(TYPE, FORMAT, FORMAT_VER, GUID, WRITE_METHOD, READ_METHOD) \
3294  xkAddVersionEx(TYPE, FORMAT, FORMAT_VER, GUID, WRITE_METHOD, READ_METHOD)
3295 
3316 #define kAddPrivateVersionEx(TYPE, FORMAT, FORMAT_VER, GUID, WRITE_METHOD, READ_METHOD) \
3317  xkAddPrivateVersionEx(TYPE, FORMAT, FORMAT_VER, GUID, WRITE_METHOD, READ_METHOD)
3318 
3332 #define kAddAbstractVersionEx(TYPE, FORMAT, FORMAT_VER, GUID) \
3333  xkAddAbstractVersion(TYPE, FORMAT, FORMAT_VER, GUID)
3334 
3342 #define kAddFlags(TYPE, FLAGS) \
3343  xkAddFlags(TYPE, FLAGS)
3344 
3366 #define kDefineDebugHints() \
3367  xkDefineDebugHints()
3368 
3369 /*
3370 *
3371 * Method Implementation Macros
3372 *
3373 * These macros are used in the implementation of class methods.
3374 *
3375 */
3376 
3383 #define kObj(TypeName_T, T_object) \
3384  TypeName_T##Class* obj K_ATTRIBUTE_UNUSED = xx##TypeName_T##_Cast(T_object, __FILE__, __LINE__)
3385 
3395 #define kObjR(TypeName_T, T_object) \
3396  TypeName_T##Class* obj K_ATTRIBUTE_UNUSED = x##TypeName_T##_CastRaw(T_object)
3397 
3409 #define kObjN(TypeName_T, VarName_obj, T_object) \
3410  TypeName_T##Class* VarName_obj = xx##TypeName_T##_Cast(T_object, __FILE__, __LINE__)
3411 
3422 #define kObjNR(TypeName_T, VarName_obj, T_object) \
3423  TypeName_T##Class* VarName_obj = x##TypeName_T##_CastRaw(T_object)
3424 
3430 #define kStaticObj(TypeName_T) \
3431  TypeName_T##Static* sobj = kStaticOf(TypeName_T)
3432 
3443 #define kCastClass_(TYPE, OBJECT) \
3444  xkCastClass_(TYPE, OBJECT)
3445 
3456 #define kCastVTable_(TYPE, OBJECT) \
3457  xkCastVTable_(TYPE, OBJECT)
3458 
3469 #define kCastIVTable_(IFACE, OBJECT) \
3470  xkCastIVTable_(IFACE, OBJECT)
3471 
3477 #define kDebugBreak() \
3478  xkDebugBreak()
3479 
3480 #include <kApi/kApiDef.x.h>
3481 
3482 #endif
k32f y
Y-coordinate value.
Definition: kApiDef.h:1316
kStatus k32s_Parse(k32s *value, const kChar *str)
Converts string to k32s value.
k64f height
Height of the rectangular cuboid.
Definition: kApiDef.h:1537
Represents a 64-unit, null-terminated, kChar sequence.
#define kALLOC_TRAIT_NON_ATOMIC
Allocates memory that cannot support atomic operations.
Definition: kApiDef.h:2238
Represents a 32-bit unsigned integer.
k32s y
Y-coordinate of the origin.
Definition: kApiDef.h:1472
kBool kChar_IsSpace(kChar ch)
Checks whether ASCII character is a some kind of white space character type.
Definition: kApiDef.h:400
kStatus kBool_Parse(kBool *value, const kChar *str)
Converts string to kBool value.
k64f height
Height of the rectangle.
Definition: kApiDef.h:1506
k32f x
X-coordinate of the origin.
Definition: kApiDef.h:1487
Rectangle structure with 32-bit signed integer fields.
Definition: kApiDef.h:1469
3D point structure with 32-bit floating-point fields.
Definition: kApiDef.h:1382
k64f x
X-coordinate of the origin.
Definition: kApiDef.h:1503
k32s width
Width of the rectangle.
Definition: kApiDef.h:1567
k8u b
Blue component value.
Definition: kApiDef.h:1651
k32s y
Y-coordinate value.
Definition: kApiDef.h:1370
#define kALLOC_TRAIT_SERIAL
Allocates memory suitable for single-threaded use only.
Definition: kApiDef.h:2237
k16s width
Width of the rectangle.
Definition: kApiDef.h:1457
32-bit color pixel structure (B/G/R/A).
Definition: kApiDef.h:1677
k16s y
Y-coordinate of the origin.
Definition: kApiDef.h:1456
Represents a unique thread identifier.
2D point structure with 16-bit signed integer fields.
Definition: kApiDef.h:1285
kStatus(kCall * kFrameworkConstructorFx)(kObject *object, kAlloc allocator)
Required signature for kObject framework constructors.
Definition: kApiDef.h:2414
kChar kChar_ToLower(kChar ch)
Convert ASCII character to lower case.
Definition: kApiDef.h:376
kBool kAllocTrait_IsCudaManaged(kAllocTrait traits)
Reports whether the kALLOC_TRAIT_CUDA_MANAGED trait is present in an allocator trait bitset...
Definition: kApiDef.h:2312
Represents a 64-bit unsigned integer.
Architecture/compiler-specific definitions.
kBool kSuccess(kStatus status)
Returns kTRUE if the given expression value is kOK.
Definition: kApiDef.h:548
Represents a 256-unit, null-terminated, kChar sequence.
kTypeName methodName
Method name (e.g. "Clone").
Definition: kApiDef.h:2423
kPointer receiver
Callback receiver context pointer.
Definition: kApiDef.h:1817
kTypeName name
Enumerator name (e.g. "kPIXEL_FORMAT_8BPP_GREYSCALE").
Definition: kApiDef.h:2449
#define kALLOC_TRAIT_CUDA_PINNED
Allocates Cuda pinned memory (host or device).
Definition: kApiDef.h:2240
Rotated rectangle structure with 32-bit floating-point fields.
Definition: kApiDef.h:1580
k64f y
Y-coordinate of the origin.
Definition: kApiDef.h:1504
k32s z
Z-coordinate value.
Definition: kApiDef.h:1371
Represents a void pointer.
32-bit color pixel structure (B/G/R/X).
Definition: kApiDef.h:1649
kStatus kSize_Parse(kSize *value, const kChar *str)
Converts string to kSize value.
k32f x
X-coordinate value.
Definition: kApiDef.h:1315
kBool kThreadId_Compare(kThreadId a, kThreadId b)
Compares two thread identifiers for equality.
kByte address[6]
Address bytes (most significant byte first).
Definition: kApiDef.h:1706
kStatus kSSize_Parse(kSSize *value, const kChar *str)
Converts string to kSSize value.
kBool kAllocTrait_SupportsContext(kAllocTrait traits)
Reports whether the kALLOC_TRAIT_CONTEXT trait is present in an allocator trait bitset.
Definition: kApiDef.h:2288
static kInline std::enable_if< std::is_unsigned< T >::value, T >::type kDivideCeil(const T &a, const T &b)
Calculates the quotient of two unsigned integers, rounding up.
Definition: kApiDef.h:2072
T kQuantizeFloor(const T &value, const T &granularity)
Rounds the specified input value down to the nearest multiple of the specified granularity.
Definition: kApiDef.h:2104
kBool kChar_IsLetter(kChar ch)
Checks whether ASCII character is a letter.
Definition: kApiDef.h:412
T kClamp(const T &v, const T &min, const T &max)
Returns a value limited to the specified range.
Definition: kApiDef.h:2024
k16s z
Z-coordinate value.
Definition: kApiDef.h:1356
T kMax(const T &a, const T &b)
Returns the maximum of two numbers.
Definition: kApiDef.h:2007
kStatus k32f_Format(k32f value, kChar *buffer, kSize capacity)
Converts k32f value to string.
Represents a 16-bit unsigned integer.
kStatus k32u_Format(k32u value, kChar *buffer, kSize capacity)
Converts k32u value to string.
k32s xc
X-coordinate of the rectangle center.
Definition: kApiDef.h:1565
Rotated rectangle structure with 32-bit signed integer fields.
Definition: kApiDef.h:1563
kBool kAllocTrait_IsSerial(kAllocTrait traits)
Reports whether the kALLOC_TRAIT_SERIAL trait is present in an allocator trait bitset.
Definition: kApiDef.h:2264
k32f yc
Y-coordinate of the rectangle center.
Definition: kApiDef.h:1583
kStatus kBool_Format(kBool value, kChar *buffer, kSize capacity)
Converts kBool value to string.
Represents an unsigned integer that can store a pointer address.
Abstract base class for memory allocator types.
k32s angle
Rotation angle of the rectangle.
Definition: kApiDef.h:1569
void * kPointer_ItemOffset(const void *pointer, kSSize itemIndex, kSize itemSize)
Gets a pointer to the Nth element of an array.
Definition: kApiDef.h:294
kTypeName displayName
Formatted display name (e.g. "8bpp Greyscale");.
Definition: kApiDef.h:2450
Represents type field information.
Definition: kApiDef.h:2433
k64f width
Width of the rectangular cuboid.
Definition: kApiDef.h:1536
Represents an 8-bit unsigned integer.
k64f x
X-coordinate of the origin.
Definition: kApiDef.h:1533
k64f depth
Depth of the rectangular cuboid.
Definition: kApiDef.h:1538
#define kInlineFx(TYPE)
Inline method declaration helper.
Definition: kApiDef.h:26
k64f y
Y-coordinate value.
Definition: kApiDef.h:1400
k64f x
X-coordinate value.
Definition: kApiDef.h:1399
kBool kAllocTrait_IsNonAtomic(kAllocTrait traits)
Reports whether the kALLOC_TRAIT_NON_ATOMIC trait is present in an allocator trait bitset...
Definition: kApiDef.h:2276
Represents enumerator information.
Definition: kApiDef.h:2446
Represents a single unit (byte) in a UTF-8 character.
#define kALLOC_TRAIT_CONTEXT
Allocator supports use of a context object during copy operations.
Definition: kApiDef.h:2239
Represents a byte on the current platform.
kStatus k64s_Format(k64s value, kChar *buffer, kSize capacity)
Converts k64s value to string.
T kAdjustCeil(const T &value, const T &min, const T &max, const T &granularity)
Rounds the specified input up, conforming to minimum, maximum, and granularity constraints.
Definition: kApiDef.h:2170
kStatus k16u_Parse(k16u *value, const kChar *str)
Converts string to k16u value.
k16s x
X-coordinate value.
Definition: kApiDef.h:1287
k16s y
Y-coordinate value.
Definition: kApiDef.h:1355
kStatus kSSize_Format(kSSize value, kChar *buffer, kSize capacity)
Converts kSSize value to string.
kSize(kCall * kHashFx)(const void *item)
Callback signature to determine hash code of an item.
Definition: kApiDef.h:1796
kStatus k64f_Parse(k64f *value, const kChar *str)
Converts string to k64f value.
k32f angle
Rotation angle of the rectangle.
Definition: kApiDef.h:1586
Represents a signed integer that can store a pointer address.
typedef kStatus(kCall *kMsgQueueDropFx)(kPointer receiver
Defines the signature of a callback function to handle dropped items.
k32s height
Height of the rectangle.
Definition: kApiDef.h:1474
Rectangle structure with 32-bit floating-point fields.
Definition: kApiDef.h:1485
kBool kIsError(kStatus status)
Returns kTRUE if the given status value is not kOK.
Definition: kApiDef.h:536
k32s kVersion_Compare(kVersion version1, kVersion version2)
Returns an integral value indicating the relationship between the versions.
Definition: kApiDef.h:852
kBool kAllocTrait_IsCudaPinned(kAllocTrait traits)
Reports whether the kALLOC_TRAIT_CUDA_PINNED trait is present in an allocator trait bitset...
Definition: kApiDef.h:2300
k32s width
Width of the rectangle.
Definition: kApiDef.h:1473
kStatus k32u_Parse(k32u *value, const kChar *str)
Converts string to k32u value.
k32s x
X-coordinate value.
Definition: kApiDef.h:1301
Pixel format descriptor.
k32s height
Height of the rectangle.
Definition: kApiDef.h:1568
Rectangle structure with 64-bit floating-point fields.
Definition: kApiDef.h:1501
Represents a 128-unit, null-terminated, kChar sequence.
k32f x
X-coordinate value.
Definition: kApiDef.h:1384
k8u kVersion_Minor(kVersion version)
Returns the minor part of a version number.
Definition: kApiDef.h:876
#define kALLOC_TRAIT_CUDA_MANAGED
Allocates Cuda managed memory (host or device).
Definition: kApiDef.h:2241
kChar kChar_ToUpper(kChar ch)
Convert ASCII character to upper case.
Definition: kApiDef.h:388
kStatus k16s_Format(k16s value, kChar *buffer, kSize capacity)
Converts k16s value to string.
kBool(kCall * kEqualsFx)(const void *item1, const void *item2)
Callback signature to determine equality of two items.
Definition: kApiDef.h:1788
k8u kVersion_Major(kVersion version)
Returns the major part of a version number.
Definition: kApiDef.h:864
T kQuantizeCeil(const T &value, const T &granularity)
Rounds the specified input value up to the nearest multiple of the specified granularity.
Definition: kApiDef.h:2120
k16s y
Y-coordinate value.
Definition: kApiDef.h:1288
Represents type method information.
Definition: kApiDef.h:2421
k16s x
X-coordinate value.
Definition: kApiDef.h:1354
k32f z
Z-coordinate value.
Definition: kApiDef.h:1386
kTypeName name
Field name.
Definition: kApiDef.h:2435
kStatus k32f_Parse(k32f *value, const kChar *str)
Converts string to k32f value.
k64f width
Width of the rectangle.
Definition: kApiDef.h:1505
k64f z
Z-coordinate value.
Definition: kApiDef.h:1401
Represents a callback function and context pointer.
Definition: kApiDef.h:1814
void kItemCopy(void *dest, const void *src, kSize size)
Performs a small copy with minimal overhead.
Definition: kApiDef.h:2205
k8u kVersion_Build(kVersion version)
Returns the build part of a version number.
Definition: kApiDef.h:900
k8u r
Red component value.
Definition: kApiDef.h:1681
2D point structure with 32-bit floating-point fields.
Definition: kApiDef.h:1313
k64f y
Y-coordinate of the origin.
Definition: kApiDef.h:1534
kStatus k32s_Format(k32s value, kChar *buffer, kSize capacity)
Converts k32s value to string.
Preset compression levels.
k16s w
W-coordinate value.
Definition: kApiDef.h:1429
k32s yc
Y-coordinate of the rectangle center.
Definition: kApiDef.h:1566
Represents a 32-bit signed integer.
Represents an Ethernet address.
Definition: kApiDef.h:1704
void * kPointer_ByteOffset(const void *pointer, kSSize offset)
Calculates a pointer address from a base address and a byte offset.
Definition: kApiDef.h:280
void(kCall * kFunction)()
Generic pointer to function.
Definition: kApiDef.h:28
k8u r
Red component value.
Definition: kApiDef.h:1653
k32f height
Height of the rectangle.
Definition: kApiDef.h:1585
kBool kChar_IsDigit(kChar ch)
Checks whether ASCII character is a digit.
Definition: kApiDef.h:424
k64f x
X-coordinate value.
Definition: kApiDef.h:1329
void kItemZero(void *dest, kSize size)
Zero-initializes a small amount of memory with minimal overhead.
Definition: kApiDef.h:2223
kVersion kVersion_Create(k32u major, k32u minor, k32u release, k32u build)
Creates a version value from its constituent parts.
Definition: kApiDef.h:799
kType type
Field type.
Definition: kApiDef.h:2436
k8u kVersion_Release(kVersion version)
Returns the release part of a version number.
Definition: kApiDef.h:888
kEndianness kEndianness_Host()
Reports the endianness of the current platform.
Definition: kApiDef.h:923
kStatus k16s_Parse(k16s *value, const kChar *str)
Converts string to k16s value.
2D point structure with 64-bit floating-point fields.
Definition: kApiDef.h:1327
kBool kEndianness_ShouldReverse(kEndianness endianness)
Reports whether byte ordering must be reversed to be consistent with the current platform.
Definition: kApiDef.h:934
kStatus(kCall * kCallbackFx)(kPointer receiver, kPointer sender, void *args)
Callback signature for a generic event handler.
Definition: kApiDef.h:1806
#define kALLOC_TRAIT_CUDA_DEVICE
Allocates Cuda device memory (device only).
Definition: kApiDef.h:2242
k8u g
Green component value.
Definition: kApiDef.h:1652
Represents a 64-bit signed integer.
kStatus kSize_Format(kSize value, kChar *buffer, kSize capacity)
Converts kSize value to string.
kBool kAllocTrait_IsCudaDeviceAccessible(kAllocTrait traits)
Reports whether the memory is Cuda device-accessible.
Definition: kApiDef.h:2336
T kMin(const T &a, const T &b)
Returns the minimum of two numbers.
Definition: kApiDef.h:1991
#define kALLOC_TRAIT_FOREIGN
Allocates memory in a foreign memory domain (non-host address space).
Definition: kApiDef.h:2236
kStatus kVersion_Format(kVersion version, kChar *buffer, kSize capacity)
Formats a version to a string buffer.
Represents a 16-unit, null-terminated, kChar sequence.
Flags that control how a file is opened.
Represents an 8-bit signed integer.
Represents the byte-ordering of primitive data types.
k32f width
Width of the rectangle.
Definition: kApiDef.h:1584
k8u b
Blue component value.
Definition: kApiDef.h:1679
k16s height
Height of the rectangle.
Definition: kApiDef.h:1458
kStatus k8s_Format(k8s value, kChar *buffer, kSize capacity)
Converts k8s value to string.
Represents metadata about a type (class, interface, or value).
k8u g
Green component value.
Definition: kApiDef.h:1680
kStatus k64s_Parse(k64s *value, const kChar *str)
Converts string to k64s value.
k16s x
X-coordinate value.
Definition: kApiDef.h:1426
k32s x
X-coordinate value.
Definition: kApiDef.h:1369
kStatus kVersion_Parse(kVersion *version, const kChar *buffer)
Parses a version from a formatted string.
Represents a 32-unit, null-terminated, kChar sequence.
kStatus kMacAddress_Format(kMacAddress address, kChar *text, kSize capacity)
Formats an Ethernet MAC address as a string.
3D point structure with 16-bit signed integer fields.
Definition: kApiDef.h:1352
k32s value
Enumerator numeric value.
Definition: kApiDef.h:2448
kTypeName functionName
Full function name (e.g. "kObject_Clone").
Definition: kApiDef.h:2424
Represents a 16-bit signed integer.
k32f y
Y-coordinate of the origin.
Definition: kApiDef.h:1488
Represents a 32-bit floating-point number.
k64f y
Y-coordinate value.
Definition: kApiDef.h:1330
Root of all Zen classes.
Represents a version number.
k8u a
Alpha component value.
Definition: kApiDef.h:1682
#define kOK
Operation successful.
Definition: kApiDef.h:515
static kInline std::enable_if< std::is_unsigned< T >::value, T >::type kDivideFloor(const T &a, const T &b)
Calculates the quotient of two unsigned integers, rounding down.
Definition: kApiDef.h:2040
Represents an error code.
k64f z
Z-coordinate of the origin.
Definition: kApiDef.h:1535
Represents a thread priority class.
kStatus k64u_Format(k64u value, kChar *buffer, kSize capacity)
Converts k64u value to string.
k8u x
Undefined.
Definition: kApiDef.h:1654
k32s y
Y-coordinate value.
Definition: kApiDef.h:1302
kSize offset
Offset of field within structure (bytes).
Definition: kApiDef.h:2437
k16s y
Y-coordinate value.
Definition: kApiDef.h:1427
#define kCall
kApi standard function calling convention.
Definition: kApiDef.h:15
k32f width
Width of the rectangle.
Definition: kApiDef.h:1489
kStatus k16u_Format(k16u value, kChar *buffer, kSize capacity)
Converts k16u value to string.
Rectangular cuboid structure with 64-bit floating-point fields.
Definition: kApiDef.h:1531
kStatus k64f_Format(k64f value, kChar *buffer, kSize capacity)
Converts k64f value to string.
Rectangle structure with 16-bit signed integer fields.
Definition: kApiDef.h:1453
kStatus k8u_Format(k8u value, kChar *buffer, kSize capacity)
Converts k8u value to string.
Represents a 64-bit floating-point number.
Represents a comparison type.
kSSize kPointer_Diff(void *a, void *b)
Calculates the signed difference between two pointers.
Definition: kApiDef.h:307
k32s x
X-coordinate of the origin.
Definition: kApiDef.h:1471
static kInline std::enable_if< std::is_unsigned< T >::value, T >::type kAbs(const T &v)
Returns the absolute value of an unsigned number.
Definition: kApiDef.h:1930
Represents a memory allocator trait.
k32f xc
X-coordinate of the rectangle center.
Definition: kApiDef.h:1582
2D point structure with 32-bit signed integer fields.
Definition: kApiDef.h:1299
Represents a boolean value.
kStatus k64u_Parse(k64u *value, const kChar *str)
Converts string to k64u value.
k16s x
X-coordinate of the origin.
Definition: kApiDef.h:1455
Represents alignment options for allocations.
kStatus kMacAddress_Parse(kMacAddress *address, const kChar *text)
Parses a text-formatted Ethernet MAC address.
kSize count
Count of values in this field (typically 1; can be higher for "array value" fields, e.g. kText32).
Definition: kApiDef.h:2438
T kAdjustFloor(const T &value, const T &min, const T &max, const T &granularity)
Rounds the specified input down, conforming to minimum, maximum, and granularity constraints.
Definition: kApiDef.h:2142
k32f height
Height of the rectangle.
Definition: kApiDef.h:1490
3D point structure with 64-bit floating-point fields.
Definition: kApiDef.h:1397
static kInline std::enable_if< std::is_unsigned< T >::value, T >::type kSign(const T &v)
Returns the sign of an unsigned number.
Definition: kApiDef.h:1960
kBool kAllocTrait_IsCudaDevice(kAllocTrait traits)
Reports whether the kALLOC_TRAIT_CUDA_DEVICE trait is present in an allocator trait bitset...
Definition: kApiDef.h:2324
3D point structure with 32-bit signed integer fields.
Definition: kApiDef.h:1367
k16s z
Z-coordinate value.
Definition: kApiDef.h:1428
kStatus k8u_Parse(k8u *value, const kChar *str)
Converts string to k8u value.
k32f y
Y-coordinate value.
Definition: kApiDef.h:1385
4D point structure with 16-bit signed integer fields.
Definition: kApiDef.h:1424
kStatus k8s_Parse(k8s *value, const kChar *str)
Converts string to k8s value.