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
data/std/encoding.mt ADDED
@@ -0,0 +1,93 @@
1
+ ## std.encoding — UTF-8 validation, codepoint iteration, and character encoding helpers.
2
+
3
+ import std.str as text_ops
4
+
5
+ public function is_valid_utf8(text: str) -> bool:
6
+ return text.is_valid_utf8()
7
+
8
+
9
+ public function utf8_codepoint_length(first_byte: ubyte) -> ptr_uint:
10
+ if first_byte < 0x80:
11
+ return 1
12
+ if first_byte < 0xC2:
13
+ return 0 # invalid continuation byte at start
14
+ if first_byte <= 0xDF:
15
+ return 2
16
+ if first_byte <= 0xEF:
17
+ return 3
18
+ if first_byte <= 0xF4:
19
+ return 4
20
+ return 0 # invalid byte value
21
+
22
+
23
+ public function utf8_codepoint_count(text: str) -> ptr_uint:
24
+ var count: ptr_uint = 0
25
+ var index: ptr_uint = 0
26
+ while index < text.len:
27
+ let b = text.byte_at(index)
28
+ let len = utf8_codepoint_length(b)
29
+ if len == 0:
30
+ index += 1
31
+ else:
32
+ index += len
33
+ count += 1
34
+
35
+ if index != text.len:
36
+ return count
37
+ return count
38
+
39
+
40
+ public function decode_utf8_codepoint(text: str, byte_offset: ptr_uint) -> Option[uint]:
41
+ if byte_offset >= text.len:
42
+ return Option[uint].none
43
+
44
+ let b0 = text.byte_at(byte_offset)
45
+ let len = utf8_codepoint_length(b0)
46
+ if len == 0 or byte_offset + len > text.len:
47
+ return Option[uint].none
48
+
49
+ if len == 1:
50
+ return Option[uint].some(value = uint<-(b0))
51
+
52
+ var codepoint: uint = (b0)
53
+ if len == 2:
54
+ codepoint = codepoint & uint<-(0x1F)
55
+ else if len == 3:
56
+ codepoint = codepoint & uint<-(0x0F)
57
+ else if len == 4:
58
+ codepoint = codepoint & uint<-(0x07)
59
+ var i: ptr_uint = 1
60
+ while i < len:
61
+ codepoint = (codepoint << 6) | uint<-(text.byte_at(byte_offset + i) & 0x3F)
62
+ i += 1
63
+
64
+ return Option[uint].some(value = codepoint)
65
+
66
+
67
+ public function utf8_overlong_check(text: str) -> bool:
68
+ if not is_valid_utf8(text):
69
+ return false
70
+
71
+ var index: ptr_uint = 0
72
+ while index < text.len:
73
+ let b0 = text.byte_at(index)
74
+ let len = utf8_codepoint_length(b0)
75
+ if len == 0:
76
+ index += 1
77
+ continue
78
+
79
+ if len > (text.len - index):
80
+ return false
81
+
82
+ if len == 3:
83
+ let b1 = text.byte_at(index + 1)
84
+ if b0 == 0xE0 and b1 < 0xA0:
85
+ return false # overlong 3-byte
86
+ else if len == 4:
87
+ let b1 = text.byte_at(index + 1)
88
+ if b0 == 0xF0 and b1 < 0x90:
89
+ return false # overlong 4-byte
90
+
91
+ index += len
92
+
93
+ return true
data/std/enet.mt ADDED
@@ -0,0 +1,133 @@
1
+ # generated by mtc imported-bindings from std.c.enet using bindings/imported/enet.binding.json
2
+
3
+ import std.c.enet as c
4
+
5
+ public type Socket = c.ENetSocket
6
+ public type Buffer = c.ENetBuffer
7
+ public type SocketSet = c.ENetSocketSet
8
+ public type ProtocolCommand = c.ENetProtocolCommand
9
+ public type ProtocolFlag = c.ENetProtocolFlag
10
+ public type ProtocolHeader = c.ENetProtocolHeader
11
+ public type ProtocolCommandHeader = c.ENetProtocolCommandHeader
12
+ public type ProtocolAcknowledge = c.ENetProtocolAcknowledge
13
+ public type ProtocolConnect = c.ENetProtocolConnect
14
+ public type ProtocolVerifyConnect = c.ENetProtocolVerifyConnect
15
+ public type ProtocolBandwidthLimit = c.ENetProtocolBandwidthLimit
16
+ public type ProtocolThrottleConfigure = c.ENetProtocolThrottleConfigure
17
+ public type ProtocolDisconnect = c.ENetProtocolDisconnect
18
+ public type ProtocolPing = c.ENetProtocolPing
19
+ public type ProtocolSendReliable = c.ENetProtocolSendReliable
20
+ public type ProtocolSendUnreliable = c.ENetProtocolSendUnreliable
21
+ public type ProtocolSendUnsequenced = c.ENetProtocolSendUnsequenced
22
+ public type ProtocolSendFragment = c.ENetProtocolSendFragment
23
+ public type Protocol = c.ENetProtocol
24
+ public type ListNode = c.ENetListNode
25
+ public type ListIterator = c.ENetListIterator
26
+ public type List = c.ENetList
27
+ public type Callbacks = c.ENetCallbacks
28
+ public type Version = c.ENetVersion
29
+ public type SocketType = c.ENetSocketType
30
+ public type SocketWait = c.ENetSocketWait
31
+ public type SocketOption = c.ENetSocketOption
32
+ public type SocketShutdown = c.ENetSocketShutdown
33
+ public type Address = c.ENetAddress
34
+ public type PacketFlag = c.ENetPacketFlag
35
+ public type PacketFreeCallback = c.ENetPacketFreeCallback
36
+ public type Packet = c.ENetPacket
37
+ public type Acknowledgement = c.ENetAcknowledgement
38
+ public type OutgoingCommand = c.ENetOutgoingCommand
39
+ public type IncomingCommand = c.ENetIncomingCommand
40
+ public type PeerState = c.ENetPeerState
41
+ public type Channel = c.ENetChannel
42
+ public type PeerFlag = c.ENetPeerFlag
43
+ public type Peer = c.ENetPeer
44
+ public type Compressor = c.ENetCompressor
45
+ public type ChecksumCallback = c.ENetChecksumCallback
46
+ public type InterceptCallback = c.ENetInterceptCallback
47
+ public type Host = c.ENetHost
48
+ public type EventType = c.ENetEventType
49
+ public type Event = c.ENetEvent
50
+
51
+ public const SOCKET_NULL: int = c.ENET_SOCKET_NULL
52
+ public const VERSION_MAJOR: int = c.ENET_VERSION_MAJOR
53
+ public const VERSION_MINOR: int = c.ENET_VERSION_MINOR
54
+ public const VERSION_PATCH: int = c.ENET_VERSION_PATCH
55
+ public const HOST_ANY: int = c.ENET_HOST_ANY
56
+ public const HOST_BROADCAST: uint = c.ENET_HOST_BROADCAST
57
+ public const PORT_ANY: int = c.ENET_PORT_ANY
58
+
59
+ public foreign function list_clear(arg0: ptr[List]) -> void = c.enet_list_clear
60
+ public foreign function list_insert(arg0: ptr[ListNode], arg1: ptr[void]) -> ListIterator = c.enet_list_insert
61
+ public foreign function list_remove(arg0: ptr[ListNode]) -> ptr[void] = c.enet_list_remove
62
+ public foreign function list_move(arg0: ptr[ListNode], arg1: ptr[void], arg2: ptr[void]) -> ListIterator = c.enet_list_move
63
+ public foreign function list_size(arg0: ptr[List]) -> ptr_uint = c.enet_list_size
64
+ public foreign function malloc(arg0: ptr_uint) -> ptr[void] = c.enet_malloc
65
+ public foreign function free(arg0: ptr[void]) -> void = c.enet_free
66
+ public foreign function initialize() -> int = c.enet_initialize
67
+ public foreign function initialize_with_callbacks(version: uint, inits: const_ptr[Callbacks]) -> int = c.enet_initialize_with_callbacks
68
+ public foreign function deinitialize() -> void = c.enet_deinitialize
69
+ public foreign function linked_version() -> Version = c.enet_linked_version
70
+ public foreign function time_get() -> uint = c.enet_time_get
71
+ public foreign function time_set(arg0: uint) -> void = c.enet_time_set
72
+ public foreign function socket_create(arg0: SocketType) -> Socket = c.enet_socket_create
73
+ public foreign function socket_bind(arg0: int, arg1: const_ptr[Address]) -> int = c.enet_socket_bind
74
+ public foreign function socket_get_address(arg0: int, arg1: ptr[Address]) -> int = c.enet_socket_get_address
75
+ public foreign function socket_listen(arg0: int, arg1: int) -> int = c.enet_socket_listen
76
+ public foreign function socket_accept(arg0: int, arg1: ptr[Address]) -> Socket = c.enet_socket_accept
77
+ public foreign function socket_connect(arg0: int, arg1: const_ptr[Address]) -> int = c.enet_socket_connect
78
+ public foreign function socket_send(arg0: int, arg1: const_ptr[Address], arg2: const_ptr[Buffer], arg3: ptr_uint) -> int = c.enet_socket_send
79
+ public foreign function socket_receive(arg0: int, arg1: ptr[Address], arg2: ptr[Buffer], arg3: ptr_uint) -> int = c.enet_socket_receive
80
+ public foreign function socket_wait(arg0: int, arg1: ptr[uint], arg2: uint) -> int = c.enet_socket_wait
81
+ public foreign function socket_set_option(arg0: int, arg1: SocketOption, arg2: int) -> int = c.enet_socket_set_option
82
+ public foreign function socket_get_option(arg0: int, arg1: SocketOption, arg2: ptr[int]) -> int = c.enet_socket_get_option
83
+ public foreign function socket_shutdown(arg0: int, arg1: SocketShutdown) -> int = c.enet_socket_shutdown
84
+ public foreign function socket_destroy(arg0: int) -> void = c.enet_socket_destroy
85
+ public foreign function socketset_select(arg0: int, arg1: ptr[SocketSet], arg2: ptr[SocketSet], arg3: uint) -> int = c.enet_socketset_select
86
+ public foreign function address_set_host_ip(address: ptr[Address], host_name: str as cstr) -> int = c.enet_address_set_host_ip
87
+ public foreign function address_set_host(address: ptr[Address], host_name: str as cstr) -> int = c.enet_address_set_host
88
+ public foreign function address_get_host_ip(address: const_ptr[Address], host_name: ptr[char], name_length: ptr_uint) -> int = c.enet_address_get_host_ip
89
+ public foreign function address_get_host(address: const_ptr[Address], host_name: ptr[char], name_length: ptr_uint) -> int = c.enet_address_get_host
90
+ public foreign function packet_create(data: const_ptr[void], data_length: ptr_uint, flag_bits: PacketFlag) -> ptr[Packet]? = c.enet_packet_create
91
+ public foreign function packet_destroy(arg0: ptr[Packet]) -> void = c.enet_packet_destroy
92
+ public foreign function packet_resize(arg0: ptr[Packet], arg1: ptr_uint) -> int = c.enet_packet_resize
93
+ public foreign function crc32(arg0: const_ptr[Buffer], arg1: ptr_uint) -> uint = c.enet_crc32
94
+ public foreign function host_create(address: const_ptr[Address], peer_count: ptr_uint, channel_limit: ptr_uint, incoming_bandwidth: uint, outgoing_bandwidth: uint) -> ptr[Host]? = c.enet_host_create
95
+ public foreign function host_destroy(arg0: ptr[Host]) -> void = c.enet_host_destroy
96
+ public foreign function host_connect(host: ptr[Host], address: const_ptr[Address], channel_count: ptr_uint, data: uint) -> ptr[Peer]? = c.enet_host_connect
97
+ public foreign function host_check_events(arg0: ptr[Host], arg1: ptr[Event]) -> int = c.enet_host_check_events
98
+ public foreign function host_service(arg0: ptr[Host], arg1: ptr[Event], arg2: uint) -> int = c.enet_host_service
99
+ public foreign function host_flush(arg0: ptr[Host]) -> void = c.enet_host_flush
100
+ public foreign function host_broadcast(arg0: ptr[Host], arg1: ubyte, arg2: ptr[Packet]) -> void = c.enet_host_broadcast
101
+ public foreign function host_compress(arg0: ptr[Host], arg1: const_ptr[Compressor]) -> void = c.enet_host_compress
102
+ public foreign function host_compress_with_range_coder(host: ptr[Host]) -> int = c.enet_host_compress_with_range_coder
103
+ public foreign function host_channel_limit(arg0: ptr[Host], arg1: ptr_uint) -> void = c.enet_host_channel_limit
104
+ public foreign function host_bandwidth_limit(arg0: ptr[Host], arg1: uint, arg2: uint) -> void = c.enet_host_bandwidth_limit
105
+ public foreign function host_bandwidth_throttle(arg0: ptr[Host]) -> void = c.enet_host_bandwidth_throttle
106
+ public foreign function host_random_seed() -> uint = c.enet_host_random_seed
107
+ public foreign function host_random(arg0: ptr[Host]) -> uint = c.enet_host_random
108
+ public foreign function peer_send(arg0: ptr[Peer], arg1: ubyte, arg2: ptr[Packet]) -> int = c.enet_peer_send
109
+ public foreign function peer_receive(peer: ptr[Peer], channel_id: ptr[ubyte]) -> ptr[Packet]? = c.enet_peer_receive
110
+ public foreign function peer_ping(arg0: ptr[Peer]) -> void = c.enet_peer_ping
111
+ public foreign function peer_ping_interval(arg0: ptr[Peer], arg1: uint) -> void = c.enet_peer_ping_interval
112
+ public foreign function peer_timeout(arg0: ptr[Peer], arg1: uint, arg2: uint, arg3: uint) -> void = c.enet_peer_timeout
113
+ public foreign function peer_reset(arg0: ptr[Peer]) -> void = c.enet_peer_reset
114
+ public foreign function peer_disconnect(arg0: ptr[Peer], arg1: uint) -> void = c.enet_peer_disconnect
115
+ public foreign function peer_disconnect_now(arg0: ptr[Peer], arg1: uint) -> void = c.enet_peer_disconnect_now
116
+ public foreign function peer_disconnect_later(arg0: ptr[Peer], arg1: uint) -> void = c.enet_peer_disconnect_later
117
+ public foreign function peer_throttle_configure(arg0: ptr[Peer], arg1: uint, arg2: uint, arg3: uint) -> void = c.enet_peer_throttle_configure
118
+ public foreign function peer_throttle(arg0: ptr[Peer], arg1: uint) -> int = c.enet_peer_throttle
119
+ public foreign function peer_reset_queues(arg0: ptr[Peer]) -> void = c.enet_peer_reset_queues
120
+ public foreign function peer_has_outgoing_commands(arg0: ptr[Peer]) -> int = c.enet_peer_has_outgoing_commands
121
+ public foreign function peer_setup_outgoing_command(arg0: ptr[Peer], arg1: ptr[OutgoingCommand]) -> void = c.enet_peer_setup_outgoing_command
122
+ public foreign function peer_queue_outgoing_command(arg0: ptr[Peer], arg1: const_ptr[Protocol], arg2: ptr[Packet], arg3: uint, arg4: ushort) -> ptr[OutgoingCommand] = c.enet_peer_queue_outgoing_command
123
+ public foreign function peer_queue_incoming_command(arg0: ptr[Peer], arg1: const_ptr[Protocol], arg2: const_ptr[void], arg3: ptr_uint, arg4: uint, arg5: uint) -> ptr[IncomingCommand] = c.enet_peer_queue_incoming_command
124
+ public foreign function peer_queue_acknowledgement(arg0: ptr[Peer], arg1: const_ptr[Protocol], arg2: ushort) -> ptr[Acknowledgement] = c.enet_peer_queue_acknowledgement
125
+ public foreign function peer_dispatch_incoming_unreliable_commands(arg0: ptr[Peer], arg1: ptr[Channel], arg2: ptr[IncomingCommand]) -> void = c.enet_peer_dispatch_incoming_unreliable_commands
126
+ public foreign function peer_dispatch_incoming_reliable_commands(arg0: ptr[Peer], arg1: ptr[Channel], arg2: ptr[IncomingCommand]) -> void = c.enet_peer_dispatch_incoming_reliable_commands
127
+ public foreign function peer_on_connect(arg0: ptr[Peer]) -> void = c.enet_peer_on_connect
128
+ public foreign function peer_on_disconnect(arg0: ptr[Peer]) -> void = c.enet_peer_on_disconnect
129
+ public foreign function range_coder_create() -> ptr[void] = c.enet_range_coder_create
130
+ public foreign function range_coder_destroy(arg0: ptr[void]) -> void = c.enet_range_coder_destroy
131
+ public foreign function range_coder_compress(arg0: ptr[void], arg1: const_ptr[Buffer], arg2: ptr_uint, arg3: ptr_uint, arg4: ptr[ubyte], arg5: ptr_uint) -> ptr_uint = c.enet_range_coder_compress
132
+ public foreign function range_coder_decompress(arg0: ptr[void], arg1: const_ptr[ubyte], arg2: ptr_uint, arg3: ptr[ubyte], arg4: ptr_uint) -> ptr_uint = c.enet_range_coder_decompress
133
+ public foreign function protocol_command_size(arg0: ubyte) -> ptr_uint = c.enet_protocol_command_size
data/std/env.mt ADDED
@@ -0,0 +1,41 @@
1
+ import std.libc as libc
2
+ import std.str as text
3
+
4
+
5
+ public function get(name: str) -> Option[str]:
6
+ let raw = libc.get_environment_variable(name) else:
7
+ return Option[str].none
8
+ return Option[str].some(value = text.cstr_as_str(raw))
9
+
10
+
11
+ public function set(name: str, value: str, overwrite: int) -> bool:
12
+ let result = libc.set_environment_variable(name, value, overwrite)
13
+ return result == 0
14
+
15
+
16
+ public function remove(name: str) -> bool:
17
+ let result = libc.unset_environment_variable(name)
18
+ return result == 0
19
+
20
+
21
+ public function home() -> Option[str]:
22
+ return get("HOME")
23
+
24
+
25
+ public function temp_directory() -> Option[str]:
26
+ match get("TMPDIR"):
27
+ Option.some as payload:
28
+ return Option[str].some(value = payload.value)
29
+ Option.none:
30
+ pass
31
+ match get("TMP"):
32
+ Option.some as payload:
33
+ return Option[str].some(value = payload.value)
34
+ Option.none:
35
+ pass
36
+ match get("TEMP"):
37
+ Option.some as payload:
38
+ return Option[str].some(value = payload.value)
39
+ Option.none:
40
+ pass
41
+ return Option[str].none
data/std/errno.mt ADDED
@@ -0,0 +1,47 @@
1
+ import std.c.errno as c
2
+
3
+ public type Code = int
4
+
5
+ public const NONE: Code = int<-c.MT_ERRNO_CODES.MT_ERRNO_NONE
6
+ public const E2BIG: Code = int<-c.MT_ERRNO_CODES.MT_ERRNO_E2BIG
7
+ public const EACCES: Code = int<-c.MT_ERRNO_CODES.MT_ERRNO_EACCES
8
+ public const EAGAIN: Code = int<-c.MT_ERRNO_CODES.MT_ERRNO_EAGAIN
9
+ public const EBADF: Code = int<-c.MT_ERRNO_CODES.MT_ERRNO_EBADF
10
+ public const EBUSY: Code = int<-c.MT_ERRNO_CODES.MT_ERRNO_EBUSY
11
+ public const ECONNREFUSED: Code = int<-c.MT_ERRNO_CODES.MT_ERRNO_ECONNREFUSED
12
+ public const ECONNRESET: Code = int<-c.MT_ERRNO_CODES.MT_ERRNO_ECONNRESET
13
+ public const EEXIST: Code = int<-c.MT_ERRNO_CODES.MT_ERRNO_EEXIST
14
+ public const EFAULT: Code = int<-c.MT_ERRNO_CODES.MT_ERRNO_EFAULT
15
+ public const EHOSTUNREACH: Code = int<-c.MT_ERRNO_CODES.MT_ERRNO_EHOSTUNREACH
16
+ public const EINPROGRESS: Code = int<-c.MT_ERRNO_CODES.MT_ERRNO_EINPROGRESS
17
+ public const EINTR: Code = int<-c.MT_ERRNO_CODES.MT_ERRNO_EINTR
18
+ public const EINVAL: Code = int<-c.MT_ERRNO_CODES.MT_ERRNO_EINVAL
19
+ public const EIO: Code = int<-c.MT_ERRNO_CODES.MT_ERRNO_EIO
20
+ public const EISCONN: Code = int<-c.MT_ERRNO_CODES.MT_ERRNO_EISCONN
21
+ public const EISDIR: Code = int<-c.MT_ERRNO_CODES.MT_ERRNO_EISDIR
22
+ public const EMFILE: Code = int<-c.MT_ERRNO_CODES.MT_ERRNO_EMFILE
23
+ public const ENAMETOOLONG: Code = int<-c.MT_ERRNO_CODES.MT_ERRNO_ENAMETOOLONG
24
+ public const ENOENT: Code = int<-c.MT_ERRNO_CODES.MT_ERRNO_ENOENT
25
+ public const ENOMEM: Code = int<-c.MT_ERRNO_CODES.MT_ERRNO_ENOMEM
26
+ public const ENOSPC: Code = int<-c.MT_ERRNO_CODES.MT_ERRNO_ENOSPC
27
+ public const ENOTCONN: Code = int<-c.MT_ERRNO_CODES.MT_ERRNO_ENOTCONN
28
+ public const ENOTDIR: Code = int<-c.MT_ERRNO_CODES.MT_ERRNO_ENOTDIR
29
+ public const ENOTEMPTY: Code = int<-c.MT_ERRNO_CODES.MT_ERRNO_ENOTEMPTY
30
+ public const EPERM: Code = int<-c.MT_ERRNO_CODES.MT_ERRNO_EPERM
31
+ public const EPIPE: Code = int<-c.MT_ERRNO_CODES.MT_ERRNO_EPIPE
32
+ public const EROFS: Code = int<-c.MT_ERRNO_CODES.MT_ERRNO_EROFS
33
+ public const ESRCH: Code = int<-c.MT_ERRNO_CODES.MT_ERRNO_ESRCH
34
+ public const ETIMEDOUT: Code = int<-c.MT_ERRNO_CODES.MT_ERRNO_ETIMEDOUT
35
+ public const EXDEV: Code = int<-c.MT_ERRNO_CODES.MT_ERRNO_EXDEV
36
+
37
+ public foreign function current() -> Code = c.mt_errno_get
38
+ public foreign function set_current(value: Code) -> void = c.mt_errno_set
39
+ public foreign function message(error: Code) -> cstr? = c.mt_errno_strerror
40
+
41
+
42
+ public function clear() -> void:
43
+ set_current(NONE)
44
+
45
+
46
+ public function current_message() -> cstr?:
47
+ return message(current())