mt-lang 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (189) hide show
  1. checksums.yaml +4 -4
  2. data/docs/index.html +4 -3
  3. data/lib/milk_tea/base.rb +1 -1
  4. data/std/asset_pack.mt +267 -0
  5. data/std/async/libuv_runtime.mt +539 -0
  6. data/std/async/mailbox.mt +191 -0
  7. data/std/async/runtime.mt +87 -0
  8. data/std/async.mt +87 -0
  9. data/std/base64.mt +185 -0
  10. data/std/behavior_tree.mt +396 -0
  11. data/std/binary.mt +314 -0
  12. data/std/binary_heap.mt +157 -0
  13. data/std/bitset.mt +239 -0
  14. data/std/box2d.mt +535 -0
  15. data/std/bytes.mt +46 -0
  16. data/std/c/box2d.mt +1254 -0
  17. data/std/c/cgltf.mt +647 -0
  18. data/std/c/cjson.mt +106 -0
  19. data/std/c/crypto.mt +11 -0
  20. data/std/c/crypto_support.h +51 -0
  21. data/std/c/ctype.mt +19 -0
  22. data/std/c/ctype_bindgen.h +29 -0
  23. data/std/c/curl.mt +1223 -0
  24. data/std/c/enet.mt +473 -0
  25. data/std/c/errno.mt +41 -0
  26. data/std/c/errno_bindgen.h +53 -0
  27. data/std/c/flecs.mt +2945 -0
  28. data/std/c/fs.linux.mt +43 -0
  29. data/std/c/fs.windows.mt +43 -0
  30. data/std/c/fs_support.h +954 -0
  31. data/std/c/gl.mt +2065 -0
  32. data/std/c/gl_registry_helpers.h +10748 -0
  33. data/std/c/glfw.mt +499 -0
  34. data/std/c/libc.mt +167 -0
  35. data/std/c/libuv.mt +1491 -0
  36. data/std/c/math.mt +22 -0
  37. data/std/c/math_bindgen.h +31 -0
  38. data/std/c/miniaudio.mt +3420 -0
  39. data/std/c/pcre2.mt +735 -0
  40. data/std/c/process.mt +58 -0
  41. data/std/c/process_support.h +1147 -0
  42. data/std/c/raygui.mt +1602 -0
  43. data/std/c/raylib.mt +1245 -0
  44. data/std/c/raymath.mt +163 -0
  45. data/std/c/rlgl.mt +434 -0
  46. data/std/c/rpng.mt +60 -0
  47. data/std/c/rres.mt +187 -0
  48. data/std/c/sdl3.mt +4132 -0
  49. data/std/c/sqlite3.mt +951 -0
  50. data/std/c/stb_image.mt +52 -0
  51. data/std/c/stb_image_resize2.mt +128 -0
  52. data/std/c/stb_image_write.mt +19 -0
  53. data/std/c/stb_rect_pack.mt +38 -0
  54. data/std/c/stb_truetype.mt +175 -0
  55. data/std/c/stb_vorbis.mt +31 -0
  56. data/std/c/stdio.mt +90 -0
  57. data/std/c/steamworks.h +5769 -0
  58. data/std/c/steamworks.mt +4771 -0
  59. data/std/c/string.mt +16 -0
  60. data/std/c/string_bindgen.h +36 -0
  61. data/std/c/sync.mt +33 -0
  62. data/std/c/sync_support.h +219 -0
  63. data/std/c/terminal.mt +24 -0
  64. data/std/c/terminal_support.h +408 -0
  65. data/std/c/time.mt +26 -0
  66. data/std/c/tls.mt +24 -0
  67. data/std/c/tls_support.h +626 -0
  68. data/std/c/tracy.mt +53 -0
  69. data/std/c/zlib.mt +20 -0
  70. data/std/c/zlib_support.h +239 -0
  71. data/std/c/zstd.mt +231 -0
  72. data/std/cell.mt +60 -0
  73. data/std/cgltf.mt +115 -0
  74. data/std/cjson.mt +90 -0
  75. data/std/cli.mt +768 -0
  76. data/std/cookie.mt +198 -0
  77. data/std/counter.mt +160 -0
  78. data/std/crypto.mt +74 -0
  79. data/std/cstring.mt +13 -0
  80. data/std/ctype.mt +52 -0
  81. data/std/curl/runtime.mt +261 -0
  82. data/std/curl.mt +38 -0
  83. data/std/deque.mt +348 -0
  84. data/std/encoding.mt +93 -0
  85. data/std/enet.mt +133 -0
  86. data/std/env.mt +41 -0
  87. data/std/errno.mt +47 -0
  88. data/std/flecs.mt +978 -0
  89. data/std/fmt.mt +271 -0
  90. data/std/fs.linux.mt +696 -0
  91. data/std/fs.windows.mt +711 -0
  92. data/std/fsm.mt +267 -0
  93. data/std/gl.mt +2062 -0
  94. data/std/glfw.mt +471 -0
  95. data/std/goap.mt +342 -0
  96. data/std/graph.mt +521 -0
  97. data/std/gzip.mt +77 -0
  98. data/std/hash.mt +429 -0
  99. data/std/http/server.mt +810 -0
  100. data/std/http.mt +1227 -0
  101. data/std/intern.mt +53 -0
  102. data/std/jobs.mt +288 -0
  103. data/std/json.mt +627 -0
  104. data/std/libc.mt +34 -0
  105. data/std/libuv.mt +554 -0
  106. data/std/linear_algebra.mt +243 -0
  107. data/std/linked_map.mt +372 -0
  108. data/std/linked_map_view.mt +49 -0
  109. data/std/linked_set.mt +117 -0
  110. data/std/log.mt +69 -0
  111. data/std/map.mt +418 -0
  112. data/std/math.mt +24 -0
  113. data/std/mem/arena.mt +137 -0
  114. data/std/mem/endian.mt +51 -0
  115. data/std/mem/heap.mt +298 -0
  116. data/std/mem/pool.mt +164 -0
  117. data/std/mem/stack.mt +47 -0
  118. data/std/mem/tracking.mt +119 -0
  119. data/std/miniaudio.mt +1299 -0
  120. data/std/multiset.mt +191 -0
  121. data/std/net/channel.mt +727 -0
  122. data/std/net/clock.mt +237 -0
  123. data/std/net/discovery.mt +277 -0
  124. data/std/net/lobby.mt +813 -0
  125. data/std/net/manager.mt +539 -0
  126. data/std/net/mux.mt +839 -0
  127. data/std/net/nat.mt +122 -0
  128. data/std/net/packet.mt +219 -0
  129. data/std/net/punch.mt +162 -0
  130. data/std/net/rpc.mt +119 -0
  131. data/std/net/session.mt +1157 -0
  132. data/std/net/stun.mt +252 -0
  133. data/std/net/sync.mt +183 -0
  134. data/std/net/turn.mt +459 -0
  135. data/std/net.mt +2944 -0
  136. data/std/oauth2.mt +408 -0
  137. data/std/option.mt +51 -0
  138. data/std/ordered_map.mt +497 -0
  139. data/std/ordered_set.mt +348 -0
  140. data/std/path.mt +368 -0
  141. data/std/pcre2/runtime.mt +35 -0
  142. data/std/pcre2.mt +78 -0
  143. data/std/priority_queue.mt +55 -0
  144. data/std/process.mt +837 -0
  145. data/std/queue.mt +55 -0
  146. data/std/random.mt +146 -0
  147. data/std/raygui.mt +99 -0
  148. data/std/raylib/debug_console.mt +71 -0
  149. data/std/raylib/easing.mt +388 -0
  150. data/std/raylib/packed_assets.mt +255 -0
  151. data/std/raylib/runtime.mt +30 -0
  152. data/std/raylib/tracy_gpu.mt +37 -0
  153. data/std/raylib.mt +1510 -0
  154. data/std/raymath.mt +153 -0
  155. data/std/result.mt +89 -0
  156. data/std/rlgl.mt +268 -0
  157. data/std/rpng.mt +46 -0
  158. data/std/rres.mt +36 -0
  159. data/std/sdl3/runtime.mt +54 -0
  160. data/std/sdl3.mt +1731 -0
  161. data/std/serialize.mt +68 -0
  162. data/std/set.mt +124 -0
  163. data/std/spatial.mt +176 -0
  164. data/std/sqlite3.mt +151 -0
  165. data/std/stack.mt +55 -0
  166. data/std/stb_image.mt +47 -0
  167. data/std/stb_image_resize2.mt +41 -0
  168. data/std/stb_image_write.mt +17 -0
  169. data/std/stb_rect_pack.mt +15 -0
  170. data/std/stb_truetype.mt +77 -0
  171. data/std/stb_vorbis.mt +16 -0
  172. data/std/stdio.mt +88 -0
  173. data/std/steamworks.mt +1542 -0
  174. data/std/str.mt +293 -0
  175. data/std/string.mt +234 -0
  176. data/std/sync.mt +194 -0
  177. data/std/tar.mt +704 -0
  178. data/std/terminal.mt +1002 -0
  179. data/std/testing.mt +266 -0
  180. data/std/thread.mt +120 -0
  181. data/std/time.mt +105 -0
  182. data/std/tls.mt +616 -0
  183. data/std/toml.mt +1310 -0
  184. data/std/tracy.mt +42 -0
  185. data/std/uri.mt +118 -0
  186. data/std/url.mt +372 -0
  187. data/std/vec.mt +433 -0
  188. data/std/zstd.mt +94 -0
  189. metadata +187 -2
@@ -0,0 +1,239 @@
1
+ #ifndef MT_ZLIB_SUPPORT_H
2
+ #define MT_ZLIB_SUPPORT_H
3
+
4
+ #include <limits.h>
5
+ #include <stdint.h>
6
+ #include <stdlib.h>
7
+ #include <string.h>
8
+ #include <zlib.h>
9
+
10
+ typedef struct mt_zlib_bytes {
11
+ uint8_t* data;
12
+ uintptr_t len;
13
+ } mt_zlib_bytes;
14
+
15
+ typedef struct mt_zlib_error {
16
+ int code;
17
+ char* message_data;
18
+ uintptr_t message_len;
19
+ } mt_zlib_error;
20
+
21
+ static inline void mt_zlib_reset_bytes(mt_zlib_bytes* value) {
22
+ if (value == NULL) {
23
+ return;
24
+ }
25
+
26
+ value->data = NULL;
27
+ value->len = 0;
28
+ }
29
+
30
+ static inline void mt_zlib_reset_error(mt_zlib_error* error) {
31
+ if (error == NULL) {
32
+ return;
33
+ }
34
+
35
+ error->code = 0;
36
+ error->message_data = NULL;
37
+ error->message_len = 0;
38
+ }
39
+
40
+ static inline int mt_zlib_set_message(mt_zlib_error* error, int code, const char* prefix, const char* detail) {
41
+ if (error == NULL) {
42
+ return code == 0 ? -1 : code;
43
+ }
44
+
45
+ size_t prefix_len = prefix == NULL ? 0 : strlen(prefix);
46
+ size_t detail_len = detail == NULL ? 0 : strlen(detail);
47
+ size_t separator_len = prefix_len != 0 && detail_len != 0 ? 2 : 0;
48
+ size_t total_len = prefix_len + separator_len + detail_len;
49
+
50
+ char* message = NULL;
51
+ if (total_len != 0) {
52
+ message = (char*) malloc(total_len);
53
+ if (message != NULL) {
54
+ size_t offset = 0;
55
+ if (prefix_len != 0) {
56
+ memcpy(message + offset, prefix, prefix_len);
57
+ offset += prefix_len;
58
+ }
59
+ if (separator_len != 0) {
60
+ memcpy(message + offset, ": ", separator_len);
61
+ offset += separator_len;
62
+ }
63
+ if (detail_len != 0) {
64
+ memcpy(message + offset, detail, detail_len);
65
+ }
66
+ }
67
+ }
68
+
69
+ error->code = code;
70
+ error->message_data = message;
71
+ error->message_len = (uintptr_t) total_len;
72
+ return code == 0 ? -1 : code;
73
+ }
74
+
75
+ static inline int mt_zlib_set_zlib_error(mt_zlib_error* error, int code, const char* prefix, const char* detail) {
76
+ return mt_zlib_set_message(error, code, prefix, detail == NULL ? zError(code) : detail);
77
+ }
78
+
79
+ static inline int mt_gzip_compress(const uint8_t* data, uintptr_t len, int level, mt_zlib_bytes* out_bytes, mt_zlib_error* out_error) {
80
+ mt_zlib_reset_bytes(out_bytes);
81
+ mt_zlib_reset_error(out_error);
82
+
83
+ if (len != 0 && data == NULL) {
84
+ return mt_zlib_set_message(out_error, -1, "gzip compress failed", "missing input data");
85
+ }
86
+ if (level < -1 || level > 9) {
87
+ return mt_zlib_set_message(out_error, -1, "gzip compress failed", "compression level must be between -1 and 9");
88
+ }
89
+ if (len > UINT_MAX || len > ULONG_MAX) {
90
+ return mt_zlib_set_message(out_error, -1, "gzip compress failed", "input exceeds zlib range limits");
91
+ }
92
+
93
+ z_stream stream;
94
+ memset(&stream, 0, sizeof(stream));
95
+
96
+ int rc = deflateInit2(&stream, level, Z_DEFLATED, MAX_WBITS + 16, 8, Z_DEFAULT_STRATEGY);
97
+ if (rc != Z_OK) {
98
+ return mt_zlib_set_zlib_error(out_error, rc, "gzip compress failed", stream.msg);
99
+ }
100
+
101
+ uLong bound = deflateBound(&stream, (uLong) len);
102
+ if (bound > UINT_MAX) {
103
+ deflateEnd(&stream);
104
+ return mt_zlib_set_message(out_error, -1, "gzip compress failed", "compressed output exceeds zlib range limits");
105
+ }
106
+
107
+ size_t capacity = (size_t) bound;
108
+ if (capacity < 64) {
109
+ capacity = 64;
110
+ }
111
+
112
+ uint8_t* output = (uint8_t*) malloc(capacity);
113
+ if (output == NULL) {
114
+ deflateEnd(&stream);
115
+ return mt_zlib_set_message(out_error, Z_MEM_ERROR, "gzip compress failed", "out of memory");
116
+ }
117
+
118
+ stream.next_in = len == 0 ? Z_NULL : (Bytef*) data;
119
+ stream.avail_in = (uInt) len;
120
+ stream.next_out = output;
121
+ stream.avail_out = (uInt) capacity;
122
+
123
+ rc = deflate(&stream, Z_FINISH);
124
+ if (rc != Z_STREAM_END) {
125
+ const char* detail = stream.msg;
126
+ if (rc == Z_OK || rc == Z_BUF_ERROR) {
127
+ detail = "compressed output buffer too small";
128
+ }
129
+
130
+ free(output);
131
+ deflateEnd(&stream);
132
+ return mt_zlib_set_zlib_error(out_error, rc == Z_OK ? Z_BUF_ERROR : rc, "gzip compress failed", detail);
133
+ }
134
+
135
+ size_t produced = (size_t) stream.total_out;
136
+ rc = deflateEnd(&stream);
137
+ if (rc != Z_OK) {
138
+ free(output);
139
+ return mt_zlib_set_zlib_error(out_error, rc, "gzip compress failed", NULL);
140
+ }
141
+
142
+ out_bytes->data = output;
143
+ out_bytes->len = (uintptr_t) produced;
144
+ return 0;
145
+ }
146
+
147
+ static inline int mt_gzip_decompress(const uint8_t* data, uintptr_t len, mt_zlib_bytes* out_bytes, mt_zlib_error* out_error) {
148
+ mt_zlib_reset_bytes(out_bytes);
149
+ mt_zlib_reset_error(out_error);
150
+
151
+ if (len != 0 && data == NULL) {
152
+ return mt_zlib_set_message(out_error, -1, "gzip decompress failed", "missing input data");
153
+ }
154
+ if (len > UINT_MAX) {
155
+ return mt_zlib_set_message(out_error, -1, "gzip decompress failed", "input exceeds zlib range limits");
156
+ }
157
+
158
+ z_stream stream;
159
+ memset(&stream, 0, sizeof(stream));
160
+
161
+ int rc = inflateInit2(&stream, MAX_WBITS + 16);
162
+ if (rc != Z_OK) {
163
+ return mt_zlib_set_zlib_error(out_error, rc, "gzip decompress failed", stream.msg);
164
+ }
165
+
166
+ size_t capacity = (size_t) len;
167
+ if (capacity < 64) {
168
+ capacity = 64;
169
+ }
170
+
171
+ uint8_t* output = (uint8_t*) malloc(capacity);
172
+ if (output == NULL) {
173
+ inflateEnd(&stream);
174
+ return mt_zlib_set_message(out_error, Z_MEM_ERROR, "gzip decompress failed", "out of memory");
175
+ }
176
+
177
+ stream.next_in = len == 0 ? Z_NULL : (Bytef*) data;
178
+ stream.avail_in = (uInt) len;
179
+ stream.next_out = output;
180
+ stream.avail_out = (uInt) capacity;
181
+
182
+ while (true) {
183
+ rc = inflate(&stream, Z_NO_FLUSH);
184
+ if (rc == Z_STREAM_END) {
185
+ break;
186
+ }
187
+
188
+ if (rc == Z_OK) {
189
+ if (stream.avail_out == 0) {
190
+ size_t next_capacity = capacity > (size_t) (UINT_MAX / 2) ? (size_t) UINT_MAX : capacity * 2;
191
+ if (next_capacity <= capacity) {
192
+ free(output);
193
+ inflateEnd(&stream);
194
+ return mt_zlib_set_message(out_error, -1, "gzip decompress failed", "decompressed output exceeds zlib range limits");
195
+ }
196
+
197
+ uint8_t* resized = (uint8_t*) realloc(output, next_capacity);
198
+ if (resized == NULL) {
199
+ free(output);
200
+ inflateEnd(&stream);
201
+ return mt_zlib_set_message(out_error, Z_MEM_ERROR, "gzip decompress failed", "out of memory");
202
+ }
203
+
204
+ output = resized;
205
+ stream.next_out = output + capacity;
206
+ stream.avail_out = (uInt) (next_capacity - capacity);
207
+ capacity = next_capacity;
208
+ }
209
+
210
+ continue;
211
+ }
212
+
213
+ free(output);
214
+ inflateEnd(&stream);
215
+ if (rc == Z_BUF_ERROR && stream.avail_in == 0) {
216
+ return mt_zlib_set_message(out_error, rc, "gzip decompress failed", "truncated gzip stream");
217
+ }
218
+
219
+ return mt_zlib_set_zlib_error(out_error, rc, "gzip decompress failed", stream.msg);
220
+ }
221
+
222
+ size_t produced = (size_t) stream.total_out;
223
+ rc = inflateEnd(&stream);
224
+ if (rc != Z_OK) {
225
+ free(output);
226
+ return mt_zlib_set_zlib_error(out_error, rc, "gzip decompress failed", NULL);
227
+ }
228
+
229
+ if (produced == 0) {
230
+ free(output);
231
+ output = NULL;
232
+ }
233
+
234
+ out_bytes->data = output;
235
+ out_bytes->len = (uintptr_t) produced;
236
+ return 0;
237
+ }
238
+
239
+ #endif
data/std/c/zstd.mt ADDED
@@ -0,0 +1,231 @@
1
+ # generated by mtc bindgen from /usr/include/zstd.h
2
+ external
3
+
4
+ link "zstd"
5
+ include "zstd.h"
6
+
7
+ enum ZSTD_ErrorCode: int
8
+ ZSTD_error_no_error = 0
9
+ ZSTD_error_GENERIC = 1
10
+ ZSTD_error_prefix_unknown = 10
11
+ ZSTD_error_version_unsupported = 12
12
+ ZSTD_error_frameParameter_unsupported = 14
13
+ ZSTD_error_frameParameter_windowTooLarge = 16
14
+ ZSTD_error_corruption_detected = 20
15
+ ZSTD_error_checksum_wrong = 22
16
+ ZSTD_error_literals_headerWrong = 24
17
+ ZSTD_error_dictionary_corrupted = 30
18
+ ZSTD_error_dictionary_wrong = 32
19
+ ZSTD_error_dictionaryCreation_failed = 34
20
+ ZSTD_error_parameter_unsupported = 40
21
+ ZSTD_error_parameter_combination_unsupported = 41
22
+ ZSTD_error_parameter_outOfBound = 42
23
+ ZSTD_error_tableLog_tooLarge = 44
24
+ ZSTD_error_maxSymbolValue_tooLarge = 46
25
+ ZSTD_error_maxSymbolValue_tooSmall = 48
26
+ ZSTD_error_cannotProduce_uncompressedBlock = 49
27
+ ZSTD_error_stabilityCondition_notRespected = 50
28
+ ZSTD_error_stage_wrong = 60
29
+ ZSTD_error_init_missing = 62
30
+ ZSTD_error_memory_allocation = 64
31
+ ZSTD_error_workSpace_tooSmall = 66
32
+ ZSTD_error_dstSize_tooSmall = 70
33
+ ZSTD_error_srcSize_wrong = 72
34
+ ZSTD_error_dstBuffer_null = 74
35
+ ZSTD_error_noForwardProgress_destFull = 80
36
+ ZSTD_error_noForwardProgress_inputEmpty = 82
37
+ ZSTD_error_frameIndex_tooLarge = 100
38
+ ZSTD_error_seekableIO = 102
39
+ ZSTD_error_dstBuffer_wrong = 104
40
+ ZSTD_error_srcBuffer_wrong = 105
41
+ ZSTD_error_sequenceProducer_failed = 106
42
+ ZSTD_error_externalSequences_invalid = 107
43
+ ZSTD_error_maxCode = 120
44
+
45
+ external function ZSTD_getErrorString(code: ZSTD_ErrorCode) -> cstr
46
+ external function ZSTD_versionNumber() -> uint
47
+ external function ZSTD_versionString() -> cstr
48
+ external function ZSTD_compress(dst: ptr[void], dstCapacity: ptr_uint, src: const_ptr[void], srcSize: ptr_uint, compressionLevel: int) -> ptr_uint
49
+ external function ZSTD_decompress(dst: ptr[void], dstCapacity: ptr_uint, src: const_ptr[void], compressedSize: ptr_uint) -> ptr_uint
50
+ external function ZSTD_getFrameContentSize(src: const_ptr[void], srcSize: ptr_uint) -> ulong
51
+ external function ZSTD_getDecompressedSize(src: const_ptr[void], srcSize: ptr_uint) -> ulong
52
+ external function ZSTD_findFrameCompressedSize(src: const_ptr[void], srcSize: ptr_uint) -> ptr_uint
53
+ external function ZSTD_compressBound(srcSize: ptr_uint) -> ptr_uint
54
+ external function ZSTD_isError(result: ptr_uint) -> uint
55
+ external function ZSTD_getErrorCode(functionResult: ptr_uint) -> ZSTD_ErrorCode
56
+ external function ZSTD_getErrorName(result: ptr_uint) -> cstr
57
+ external function ZSTD_minCLevel() -> int
58
+ external function ZSTD_maxCLevel() -> int
59
+ external function ZSTD_defaultCLevel() -> int
60
+
61
+ opaque ZSTD_CCtx = c"ZSTD_CCtx"
62
+
63
+ external function ZSTD_createCCtx() -> ptr[ZSTD_CCtx]
64
+ external function ZSTD_freeCCtx(cctx: ptr[ZSTD_CCtx]) -> ptr_uint
65
+ external function ZSTD_compressCCtx(cctx: ptr[ZSTD_CCtx], dst: ptr[void], dstCapacity: ptr_uint, src: const_ptr[void], srcSize: ptr_uint, compressionLevel: int) -> ptr_uint
66
+
67
+ opaque ZSTD_DCtx = c"ZSTD_DCtx"
68
+
69
+ external function ZSTD_createDCtx() -> ptr[ZSTD_DCtx]
70
+ external function ZSTD_freeDCtx(dctx: ptr[ZSTD_DCtx]) -> ptr_uint
71
+ external function ZSTD_decompressDCtx(dctx: ptr[ZSTD_DCtx], dst: ptr[void], dstCapacity: ptr_uint, src: const_ptr[void], srcSize: ptr_uint) -> ptr_uint
72
+
73
+ enum ZSTD_strategy: int
74
+ ZSTD_fast = 1
75
+ ZSTD_dfast = 2
76
+ ZSTD_greedy = 3
77
+ ZSTD_lazy = 4
78
+ ZSTD_lazy2 = 5
79
+ ZSTD_btlazy2 = 6
80
+ ZSTD_btopt = 7
81
+ ZSTD_btultra = 8
82
+ ZSTD_btultra2 = 9
83
+
84
+ enum ZSTD_cParameter: int
85
+ ZSTD_c_compressionLevel = 100
86
+ ZSTD_c_windowLog = 101
87
+ ZSTD_c_hashLog = 102
88
+ ZSTD_c_chainLog = 103
89
+ ZSTD_c_searchLog = 104
90
+ ZSTD_c_minMatch = 105
91
+ ZSTD_c_targetLength = 106
92
+ ZSTD_c_strategy = 107
93
+ ZSTD_c_targetCBlockSize = 130
94
+ ZSTD_c_enableLongDistanceMatching = 160
95
+ ZSTD_c_ldmHashLog = 161
96
+ ZSTD_c_ldmMinMatch = 162
97
+ ZSTD_c_ldmBucketSizeLog = 163
98
+ ZSTD_c_ldmHashRateLog = 164
99
+ ZSTD_c_contentSizeFlag = 200
100
+ ZSTD_c_checksumFlag = 201
101
+ ZSTD_c_dictIDFlag = 202
102
+ ZSTD_c_nbWorkers = 400
103
+ ZSTD_c_jobSize = 401
104
+ ZSTD_c_overlapLog = 402
105
+ ZSTD_c_experimentalParam1 = 500
106
+ ZSTD_c_experimentalParam2 = 10
107
+ ZSTD_c_experimentalParam3 = 1000
108
+ ZSTD_c_experimentalParam4 = 1001
109
+ ZSTD_c_experimentalParam5 = 1002
110
+ ZSTD_c_experimentalParam7 = 1004
111
+ ZSTD_c_experimentalParam8 = 1005
112
+ ZSTD_c_experimentalParam9 = 1006
113
+ ZSTD_c_experimentalParam10 = 1007
114
+ ZSTD_c_experimentalParam11 = 1008
115
+ ZSTD_c_experimentalParam12 = 1009
116
+ ZSTD_c_experimentalParam13 = 1010
117
+ ZSTD_c_experimentalParam14 = 1011
118
+ ZSTD_c_experimentalParam15 = 1012
119
+ ZSTD_c_experimentalParam16 = 1013
120
+ ZSTD_c_experimentalParam17 = 1014
121
+ ZSTD_c_experimentalParam18 = 1015
122
+ ZSTD_c_experimentalParam19 = 1016
123
+ ZSTD_c_experimentalParam20 = 1017
124
+
125
+ struct ZSTD_bounds:
126
+ error: ptr_uint
127
+ lowerBound: int
128
+ upperBound: int
129
+
130
+ external function ZSTD_cParam_getBounds(cParam: ZSTD_cParameter) -> ZSTD_bounds
131
+ external function ZSTD_CCtx_setParameter(cctx: ptr[ZSTD_CCtx], param: ZSTD_cParameter, value: int) -> ptr_uint
132
+ external function ZSTD_CCtx_setPledgedSrcSize(cctx: ptr[ZSTD_CCtx], pledgedSrcSize: ulong) -> ptr_uint
133
+
134
+ enum ZSTD_ResetDirective: int
135
+ ZSTD_reset_session_only = 1
136
+ ZSTD_reset_parameters = 2
137
+ ZSTD_reset_session_and_parameters = 3
138
+
139
+ external function ZSTD_CCtx_reset(cctx: ptr[ZSTD_CCtx], reset: ZSTD_ResetDirective) -> ptr_uint
140
+ external function ZSTD_compress2(cctx: ptr[ZSTD_CCtx], dst: ptr[void], dstCapacity: ptr_uint, src: const_ptr[void], srcSize: ptr_uint) -> ptr_uint
141
+
142
+ enum ZSTD_dParameter: int
143
+ ZSTD_d_windowLogMax = 100
144
+ ZSTD_d_experimentalParam1 = 1000
145
+ ZSTD_d_experimentalParam2 = 1001
146
+ ZSTD_d_experimentalParam3 = 1002
147
+ ZSTD_d_experimentalParam4 = 1003
148
+ ZSTD_d_experimentalParam5 = 1004
149
+ ZSTD_d_experimentalParam6 = 1005
150
+
151
+ external function ZSTD_dParam_getBounds(dParam: ZSTD_dParameter) -> ZSTD_bounds
152
+ external function ZSTD_DCtx_setParameter(dctx: ptr[ZSTD_DCtx], param: ZSTD_dParameter, value: int) -> ptr_uint
153
+ external function ZSTD_DCtx_reset(dctx: ptr[ZSTD_DCtx], reset: ZSTD_ResetDirective) -> ptr_uint
154
+
155
+ struct ZSTD_inBuffer:
156
+ src: const_ptr[void]
157
+ size: ptr_uint
158
+ pos: ptr_uint
159
+
160
+ struct ZSTD_outBuffer:
161
+ dst: ptr[void]
162
+ size: ptr_uint
163
+ pos: ptr_uint
164
+
165
+ type ZSTD_CStream = ZSTD_CCtx
166
+
167
+ external function ZSTD_createCStream() -> ptr[ZSTD_CStream]
168
+ external function ZSTD_freeCStream(zcs: ptr[ZSTD_CStream]) -> ptr_uint
169
+
170
+ flags ZSTD_EndDirective: int
171
+ ZSTD_e_continue = 0
172
+ ZSTD_e_flush = 1
173
+ ZSTD_e_end = 2
174
+
175
+ external function ZSTD_compressStream2(cctx: ptr[ZSTD_CCtx], output: ptr[ZSTD_outBuffer], input: ptr[ZSTD_inBuffer], endOp: ZSTD_EndDirective) -> ptr_uint
176
+ external function ZSTD_CStreamInSize() -> ptr_uint
177
+ external function ZSTD_CStreamOutSize() -> ptr_uint
178
+ external function ZSTD_initCStream(zcs: ptr[ZSTD_CStream], compressionLevel: int) -> ptr_uint
179
+ external function ZSTD_compressStream(zcs: ptr[ZSTD_CStream], output: ptr[ZSTD_outBuffer], input: ptr[ZSTD_inBuffer]) -> ptr_uint
180
+ external function ZSTD_flushStream(zcs: ptr[ZSTD_CStream], output: ptr[ZSTD_outBuffer]) -> ptr_uint
181
+ external function ZSTD_endStream(zcs: ptr[ZSTD_CStream], output: ptr[ZSTD_outBuffer]) -> ptr_uint
182
+
183
+ type ZSTD_DStream = ZSTD_DCtx
184
+
185
+ external function ZSTD_createDStream() -> ptr[ZSTD_DStream]
186
+ external function ZSTD_freeDStream(zds: ptr[ZSTD_DStream]) -> ptr_uint
187
+ external function ZSTD_initDStream(zds: ptr[ZSTD_DStream]) -> ptr_uint
188
+ external function ZSTD_decompressStream(zds: ptr[ZSTD_DStream], output: ptr[ZSTD_outBuffer], input: ptr[ZSTD_inBuffer]) -> ptr_uint
189
+ external function ZSTD_DStreamInSize() -> ptr_uint
190
+ external function ZSTD_DStreamOutSize() -> ptr_uint
191
+ external function ZSTD_compress_usingDict(ctx: ptr[ZSTD_CCtx], dst: ptr[void], dstCapacity: ptr_uint, src: const_ptr[void], srcSize: ptr_uint, dict: const_ptr[void], dictSize: ptr_uint, compressionLevel: int) -> ptr_uint
192
+ external function ZSTD_decompress_usingDict(dctx: ptr[ZSTD_DCtx], dst: ptr[void], dstCapacity: ptr_uint, src: const_ptr[void], srcSize: ptr_uint, dict: const_ptr[void], dictSize: ptr_uint) -> ptr_uint
193
+
194
+ opaque ZSTD_CDict = c"ZSTD_CDict"
195
+
196
+ external function ZSTD_createCDict(dictBuffer: const_ptr[void], dictSize: ptr_uint, compressionLevel: int) -> ptr[ZSTD_CDict]
197
+ external function ZSTD_freeCDict(CDict: ptr[ZSTD_CDict]) -> ptr_uint
198
+ external function ZSTD_compress_usingCDict(cctx: ptr[ZSTD_CCtx], dst: ptr[void], dstCapacity: ptr_uint, src: const_ptr[void], srcSize: ptr_uint, cdict: const_ptr[ZSTD_CDict]) -> ptr_uint
199
+
200
+ opaque ZSTD_DDict = c"ZSTD_DDict"
201
+
202
+ external function ZSTD_createDDict(dictBuffer: const_ptr[void], dictSize: ptr_uint) -> ptr[ZSTD_DDict]
203
+ external function ZSTD_freeDDict(ddict: ptr[ZSTD_DDict]) -> ptr_uint
204
+ external function ZSTD_decompress_usingDDict(dctx: ptr[ZSTD_DCtx], dst: ptr[void], dstCapacity: ptr_uint, src: const_ptr[void], srcSize: ptr_uint, ddict: const_ptr[ZSTD_DDict]) -> ptr_uint
205
+ external function ZSTD_getDictID_fromDict(dict: const_ptr[void], dictSize: ptr_uint) -> uint
206
+ external function ZSTD_getDictID_fromCDict(cdict: const_ptr[ZSTD_CDict]) -> uint
207
+ external function ZSTD_getDictID_fromDDict(ddict: const_ptr[ZSTD_DDict]) -> uint
208
+ external function ZSTD_getDictID_fromFrame(src: const_ptr[void], srcSize: ptr_uint) -> uint
209
+ external function ZSTD_CCtx_loadDictionary(cctx: ptr[ZSTD_CCtx], dict: const_ptr[void], dictSize: ptr_uint) -> ptr_uint
210
+ external function ZSTD_CCtx_refCDict(cctx: ptr[ZSTD_CCtx], cdict: const_ptr[ZSTD_CDict]) -> ptr_uint
211
+ external function ZSTD_CCtx_refPrefix(cctx: ptr[ZSTD_CCtx], prefix: const_ptr[void], prefixSize: ptr_uint) -> ptr_uint
212
+ external function ZSTD_DCtx_loadDictionary(dctx: ptr[ZSTD_DCtx], dict: const_ptr[void], dictSize: ptr_uint) -> ptr_uint
213
+ external function ZSTD_DCtx_refDDict(dctx: ptr[ZSTD_DCtx], ddict: const_ptr[ZSTD_DDict]) -> ptr_uint
214
+ external function ZSTD_DCtx_refPrefix(dctx: ptr[ZSTD_DCtx], prefix: const_ptr[void], prefixSize: ptr_uint) -> ptr_uint
215
+ external function ZSTD_sizeof_CCtx(cctx: const_ptr[ZSTD_CCtx]) -> ptr_uint
216
+ external function ZSTD_sizeof_DCtx(dctx: const_ptr[ZSTD_DCtx]) -> ptr_uint
217
+ external function ZSTD_sizeof_CStream(zcs: const_ptr[ZSTD_CStream]) -> ptr_uint
218
+ external function ZSTD_sizeof_DStream(zds: const_ptr[ZSTD_DStream]) -> ptr_uint
219
+ external function ZSTD_sizeof_CDict(cdict: const_ptr[ZSTD_CDict]) -> ptr_uint
220
+ external function ZSTD_sizeof_DDict(ddict: const_ptr[ZSTD_DDict]) -> ptr_uint
221
+
222
+ const ZSTD_VERSION_MAJOR: int = 1
223
+ const ZSTD_VERSION_MINOR: int = 5
224
+ const ZSTD_VERSION_RELEASE: int = 7
225
+ const ZSTD_VERSION_STRING: cstr = c"1.5.7"
226
+ const ZSTD_CLEVEL_DEFAULT: int = 3
227
+ const ZSTD_MAGICNUMBER: uint = 4247762216
228
+ const ZSTD_MAGIC_DICTIONARY: uint = 3962610743
229
+ const ZSTD_MAGIC_SKIPPABLE_START: int = 407710288
230
+ const ZSTD_MAGIC_SKIPPABLE_MASK: uint = 4294967280
231
+ const ZSTD_BLOCKSIZELOG_MAX: int = 17
data/std/cell.mt ADDED
@@ -0,0 +1,60 @@
1
+ import std.mem.heap as heap
2
+
3
+ ## Explicit single-value heap storage.
4
+ ##
5
+ ## This is the intended escape hatch for shared mutable proc state.
6
+ ## Allocation stays visible at the call site via `cell.alloc(...)`.
7
+ public struct Cell[T]:
8
+ storage: own[T]?
9
+
10
+
11
+ public function alloc[T](value: T) -> Cell[T]:
12
+ let storage = heap.must_alloc[T](1)
13
+ read(storage) = value
14
+ return Cell[T](storage = storage)
15
+
16
+
17
+ extending Cell[T]:
18
+ public function as_ptr() -> ptr[T]:
19
+ let storage = this.storage else:
20
+ fatal(c"cell.Cell.as_ptr released cell")
21
+
22
+ return storage
23
+
24
+
25
+ public function get() -> T:
26
+ let storage = this.storage else:
27
+ fatal(c"cell.Cell.get released cell")
28
+
29
+ return read(storage)
30
+
31
+
32
+ public function set(value: T) -> void:
33
+ let storage = this.storage else:
34
+ fatal(c"cell.Cell.set released cell")
35
+
36
+ read(storage) = value
37
+
38
+
39
+ public function replace(value: T) -> T:
40
+ let storage = this.storage else:
41
+ fatal(c"cell.Cell.replace released cell")
42
+
43
+ let previous = read(storage)
44
+ read(storage) = value
45
+ return previous
46
+
47
+
48
+ public function update(body: proc(value: T) -> T) -> T:
49
+ let next = body(this.get())
50
+ this.set(next)
51
+ return next
52
+
53
+
54
+ public function is_released() -> bool:
55
+ return this.storage == null
56
+
57
+
58
+ public editable function release() -> void:
59
+ heap.release(this.storage)
60
+ this.storage = null
data/std/cgltf.mt ADDED
@@ -0,0 +1,115 @@
1
+ # generated by mtc imported-bindings from std.c.cgltf using bindings/imported/cgltf.binding.json
2
+
3
+ import std.c.cgltf as c
4
+
5
+ public type camera_data = c.cgltf_camera_data
6
+ public type size = c.cgltf_size
7
+ public type ssize = c.cgltf_ssize
8
+ public type float_ = c.cgltf_float
9
+ public type int_ = c.cgltf_int
10
+ public type uint_ = c.cgltf_uint
11
+ public type bool_ = c.cgltf_bool
12
+ public type file_type = c.cgltf_file_type
13
+ public type result = c.cgltf_result
14
+ public type memory_options = c.cgltf_memory_options
15
+ public type file_options = c.cgltf_file_options
16
+ public type options = c.cgltf_options
17
+ public type buffer_view_type = c.cgltf_buffer_view_type
18
+ public type attribute_type = c.cgltf_attribute_type
19
+ public type component_type = c.cgltf_component_type
20
+ public type type_ = c.cgltf_type
21
+ public type primitive_type = c.cgltf_primitive_type
22
+ public type alpha_mode = c.cgltf_alpha_mode
23
+ public type animation_path_type = c.cgltf_animation_path_type
24
+ public type interpolation_type = c.cgltf_interpolation_type
25
+ public type camera_type = c.cgltf_camera_type
26
+ public type light_type = c.cgltf_light_type
27
+ public type data_free_method = c.cgltf_data_free_method
28
+ public type extras = c.cgltf_extras
29
+ public type extension = c.cgltf_extension
30
+ public type buffer = c.cgltf_buffer
31
+ public type meshopt_compression_mode = c.cgltf_meshopt_compression_mode
32
+ public type meshopt_compression_filter = c.cgltf_meshopt_compression_filter
33
+ public type meshopt_compression = c.cgltf_meshopt_compression
34
+ public type buffer_view = c.cgltf_buffer_view
35
+ public type accessor_sparse = c.cgltf_accessor_sparse
36
+ public type accessor = c.cgltf_accessor
37
+ public type attribute_ = c.cgltf_attribute
38
+ public type image = c.cgltf_image
39
+ public type filter_type = c.cgltf_filter_type
40
+ public type wrap_mode = c.cgltf_wrap_mode
41
+ public type sampler = c.cgltf_sampler
42
+ public type texture = c.cgltf_texture
43
+ public type texture_transform = c.cgltf_texture_transform
44
+ public type texture_view = c.cgltf_texture_view
45
+ public type pbr_metallic_roughness = c.cgltf_pbr_metallic_roughness
46
+ public type pbr_specular_glossiness = c.cgltf_pbr_specular_glossiness
47
+ public type clearcoat = c.cgltf_clearcoat
48
+ public type transmission = c.cgltf_transmission
49
+ public type ior = c.cgltf_ior
50
+ public type specular = c.cgltf_specular
51
+ public type volume = c.cgltf_volume
52
+ public type sheen = c.cgltf_sheen
53
+ public type emissive_strength = c.cgltf_emissive_strength
54
+ public type iridescence = c.cgltf_iridescence
55
+ public type diffuse_transmission = c.cgltf_diffuse_transmission
56
+ public type anisotropy = c.cgltf_anisotropy
57
+ public type dispersion = c.cgltf_dispersion
58
+ public type material = c.cgltf_material
59
+ public type material_mapping = c.cgltf_material_mapping
60
+ public type morph_target = c.cgltf_morph_target
61
+ public type draco_mesh_compression = c.cgltf_draco_mesh_compression
62
+ public type mesh_gpu_instancing = c.cgltf_mesh_gpu_instancing
63
+ public type primitive = c.cgltf_primitive
64
+ public type mesh = c.cgltf_mesh
65
+ public type skin = c.cgltf_skin
66
+ public type camera_perspective = c.cgltf_camera_perspective
67
+ public type camera_orthographic = c.cgltf_camera_orthographic
68
+ public type camera = c.cgltf_camera
69
+ public type light = c.cgltf_light
70
+ public type node = c.cgltf_node
71
+ public type scene = c.cgltf_scene
72
+ public type animation_sampler = c.cgltf_animation_sampler
73
+ public type animation_channel = c.cgltf_animation_channel
74
+ public type animation = c.cgltf_animation
75
+ public type material_variant = c.cgltf_material_variant
76
+ public type asset = c.cgltf_asset
77
+ public type data = c.cgltf_data
78
+
79
+ public foreign function parse(options: const_ptr[options], data: const_ptr[void], size: ptr_uint, out_data: ptr[ptr[data]]) -> result = c.cgltf_parse
80
+ public foreign function parse_file(options: const_ptr[options], path: str as cstr, out_data: ptr[ptr[data]]) -> result = c.cgltf_parse_file
81
+ public foreign function load_buffers(options: const_ptr[options], data: ptr[data], gltf_path: str as cstr) -> result = c.cgltf_load_buffers
82
+ public foreign function load_buffer_base64(options: const_ptr[options], size: ptr_uint, base64: str as cstr, out_data: ptr[ptr[void]]) -> result = c.cgltf_load_buffer_base64
83
+ public foreign function decode_string(string: ptr[char]) -> size = c.cgltf_decode_string
84
+ public foreign function decode_uri(uri: ptr[char]) -> size = c.cgltf_decode_uri
85
+ public foreign function validate(data: ptr[data]) -> result = c.cgltf_validate
86
+ public foreign function free(data: ptr[data]) -> void = c.cgltf_free
87
+ public foreign function node_transform_local(node: const_ptr[node], out_matrix: ptr[float_]) -> void = c.cgltf_node_transform_local
88
+ public foreign function node_transform_world(node: const_ptr[node], out_matrix: ptr[float_]) -> void = c.cgltf_node_transform_world
89
+ public foreign function buffer_view_data(view: const_ptr[buffer_view]) -> const_ptr[ubyte] = c.cgltf_buffer_view_data
90
+ public foreign function find_accessor(prim: const_ptr[primitive], type_: attribute_type, index: int) -> const_ptr[accessor] = c.cgltf_find_accessor
91
+ public foreign function accessor_read_float(accessor: const_ptr[accessor], index: ptr_uint, out_: ptr[float_], element_size: ptr_uint) -> bool_ = c.cgltf_accessor_read_float
92
+ public foreign function accessor_read_uint(accessor: const_ptr[accessor], index: ptr_uint, out_: ptr[uint_], element_size: ptr_uint) -> bool_ = c.cgltf_accessor_read_uint
93
+ public foreign function accessor_read_index(accessor: const_ptr[accessor], index: ptr_uint) -> size = c.cgltf_accessor_read_index
94
+ public foreign function num_components(type_: type_) -> size = c.cgltf_num_components
95
+ public foreign function component_size(component_type: component_type) -> size = c.cgltf_component_size
96
+ public foreign function calc_size(type_: type_, component_type: component_type) -> size = c.cgltf_calc_size
97
+ public foreign function accessor_unpack_floats(accessor: const_ptr[accessor], out_: ptr[float_], float_count: ptr_uint) -> size = c.cgltf_accessor_unpack_floats
98
+ public foreign function accessor_unpack_indices(accessor: const_ptr[accessor], out_: ptr[void], out_component_size: ptr_uint, index_count: ptr_uint) -> size = c.cgltf_accessor_unpack_indices
99
+ public foreign function copy_extras_json(data: const_ptr[data], extras: const_ptr[extras], dest: ptr[char], dest_size: ptr[size]) -> result = c.cgltf_copy_extras_json
100
+ public foreign function mesh_index(data: const_ptr[data], object: const_ptr[mesh]) -> size = c.cgltf_mesh_index
101
+ public foreign function material_index(data: const_ptr[data], object: const_ptr[material]) -> size = c.cgltf_material_index
102
+ public foreign function accessor_index(data: const_ptr[data], object: const_ptr[accessor]) -> size = c.cgltf_accessor_index
103
+ public foreign function buffer_view_index(data: const_ptr[data], object: const_ptr[buffer_view]) -> size = c.cgltf_buffer_view_index
104
+ public foreign function buffer_index(data: const_ptr[data], object: const_ptr[buffer]) -> size = c.cgltf_buffer_index
105
+ public foreign function image_index(data: const_ptr[data], object: const_ptr[image]) -> size = c.cgltf_image_index
106
+ public foreign function texture_index(data: const_ptr[data], object: const_ptr[texture]) -> size = c.cgltf_texture_index
107
+ public foreign function sampler_index(data: const_ptr[data], object: const_ptr[sampler]) -> size = c.cgltf_sampler_index
108
+ public foreign function skin_index(data: const_ptr[data], object: const_ptr[skin]) -> size = c.cgltf_skin_index
109
+ public foreign function camera_index(data: const_ptr[data], object: const_ptr[camera]) -> size = c.cgltf_camera_index
110
+ public foreign function light_index(data: const_ptr[data], object: const_ptr[light]) -> size = c.cgltf_light_index
111
+ public foreign function node_index(data: const_ptr[data], object: const_ptr[node]) -> size = c.cgltf_node_index
112
+ public foreign function scene_index(data: const_ptr[data], object: const_ptr[scene]) -> size = c.cgltf_scene_index
113
+ public foreign function animation_index(data: const_ptr[data], object: const_ptr[animation]) -> size = c.cgltf_animation_index
114
+ public foreign function animation_sampler_index(animation: const_ptr[animation], object: const_ptr[animation_sampler]) -> size = c.cgltf_animation_sampler_index
115
+ public foreign function animation_channel_index(animation: const_ptr[animation], object: const_ptr[animation_channel]) -> size = c.cgltf_animation_channel_index