@shd101wyy/yo 0.1.25 → 0.1.27

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 (194) hide show
  1. package/.github/skills/yo-async-effects/SKILL.md +4 -4
  2. package/.github/skills/yo-async-effects/async-effects-recipes.md +40 -40
  3. package/.github/skills/yo-core-patterns/SKILL.md +1 -1
  4. package/.github/skills/yo-core-patterns/core-patterns-cheatsheet.md +30 -26
  5. package/.github/skills/yo-project-workflow/SKILL.md +6 -3
  6. package/.github/skills/yo-project-workflow/workflow-cheatsheet.md +34 -11
  7. package/.github/skills/yo-syntax/SKILL.md +7 -6
  8. package/.github/skills/yo-syntax/syntax-cheatsheet.md +78 -60
  9. package/.github/skills/yo-wasm-integration/wasm-integration-cheatsheet.md +3 -3
  10. package/README.md +10 -8
  11. package/out/cjs/index.cjs +583 -567
  12. package/out/cjs/yo-cli.cjs +664 -632
  13. package/out/cjs/yo-lsp.cjs +510 -485
  14. package/out/esm/index.mjs +538 -522
  15. package/out/types/src/codegen/codegen-c.d.ts +2 -2
  16. package/out/types/src/codegen/functions/collection.d.ts +2 -2
  17. package/out/types/src/codegen/functions/context.d.ts +3 -2
  18. package/out/types/src/codegen/types/collection.d.ts +2 -2
  19. package/out/types/src/codegen/utils/index.d.ts +3 -1
  20. package/out/types/src/doc/builder.d.ts +2 -2
  21. package/out/types/src/evaluator/calls/closure-type.d.ts +2 -2
  22. package/out/types/src/evaluator/calls/record-type.d.ts +11 -0
  23. package/out/types/src/evaluator/context.d.ts +8 -9
  24. package/out/types/src/evaluator/index.d.ts +3 -3
  25. package/out/types/src/evaluator/types/record.d.ts +14 -0
  26. package/out/types/src/evaluator/types/validation.d.ts +2 -2
  27. package/out/types/src/evaluator/values/anonymous-module.d.ts +5 -5
  28. package/out/types/src/evaluator/values/impl.d.ts +1 -1
  29. package/out/types/src/expr.d.ts +1 -4
  30. package/out/types/src/formatter.d.ts +11 -0
  31. package/out/types/src/function-value.d.ts +1 -1
  32. package/out/types/src/lsp/document-manager.d.ts +1 -1
  33. package/out/types/src/lsp/formatting.d.ts +2 -0
  34. package/out/types/src/module-manager.d.ts +3 -3
  35. package/out/types/src/tests/formatter.test.d.ts +1 -0
  36. package/out/types/src/types/creators.d.ts +3 -4
  37. package/out/types/src/types/definitions.d.ts +8 -19
  38. package/out/types/src/types/guards.d.ts +3 -3
  39. package/out/types/src/types/tags.d.ts +0 -1
  40. package/out/types/src/types/utils.d.ts +1 -1
  41. package/out/types/src/value-tag.d.ts +0 -1
  42. package/out/types/src/value.d.ts +6 -13
  43. package/out/types/tsconfig.tsbuildinfo +1 -1
  44. package/package.json +1 -1
  45. package/std/alg/hash.yo +13 -21
  46. package/std/allocator.yo +25 -40
  47. package/std/async.yo +3 -7
  48. package/std/build.yo +105 -151
  49. package/std/cli/arg_parser.yo +184 -169
  50. package/std/collections/array_list.yo +350 -314
  51. package/std/collections/btree_map.yo +142 -131
  52. package/std/collections/deque.yo +132 -128
  53. package/std/collections/hash_map.yo +542 -566
  54. package/std/collections/hash_set.yo +623 -687
  55. package/std/collections/linked_list.yo +275 -293
  56. package/std/collections/ordered_map.yo +113 -85
  57. package/std/collections/priority_queue.yo +73 -73
  58. package/std/crypto/md5.yo +191 -95
  59. package/std/crypto/random.yo +56 -64
  60. package/std/crypto/sha256.yo +151 -107
  61. package/std/encoding/base64.yo +87 -81
  62. package/std/encoding/hex.yo +43 -50
  63. package/std/encoding/html.yo +56 -81
  64. package/std/encoding/html_char_utils.yo +7 -13
  65. package/std/encoding/html_entities.yo +2248 -2253
  66. package/std/encoding/json.yo +316 -224
  67. package/std/encoding/punycode.yo +86 -116
  68. package/std/encoding/toml.yo +67 -66
  69. package/std/encoding/utf16.yo +37 -44
  70. package/std/env.yo +62 -91
  71. package/std/error.yo +12 -20
  72. package/std/fmt/display.yo +5 -9
  73. package/std/fmt/index.yo +8 -14
  74. package/std/fmt/to_string.yo +330 -315
  75. package/std/fmt/writer.yo +58 -87
  76. package/std/fs/dir.yo +83 -102
  77. package/std/fs/file.yo +147 -180
  78. package/std/fs/metadata.yo +45 -78
  79. package/std/fs/temp.yo +55 -65
  80. package/std/fs/types.yo +27 -40
  81. package/std/fs/walker.yo +53 -68
  82. package/std/gc.yo +5 -8
  83. package/std/glob.yo +30 -43
  84. package/std/http/client.yo +107 -120
  85. package/std/http/http.yo +106 -96
  86. package/std/http/index.yo +4 -6
  87. package/std/imm/list.yo +88 -93
  88. package/std/imm/map.yo +528 -464
  89. package/std/imm/set.yo +52 -57
  90. package/std/imm/sorted_map.yo +340 -286
  91. package/std/imm/sorted_set.yo +57 -63
  92. package/std/imm/string.yo +404 -345
  93. package/std/imm/vec.yo +173 -181
  94. package/std/io/reader.yo +3 -6
  95. package/std/io/writer.yo +4 -8
  96. package/std/libc/assert.yo +5 -9
  97. package/std/libc/ctype.yo +32 -22
  98. package/std/libc/dirent.yo +26 -25
  99. package/std/libc/errno.yo +164 -90
  100. package/std/libc/fcntl.yo +52 -45
  101. package/std/libc/float.yo +66 -44
  102. package/std/libc/limits.yo +42 -33
  103. package/std/libc/math.yo +53 -82
  104. package/std/libc/signal.yo +72 -47
  105. package/std/libc/stdatomic.yo +217 -188
  106. package/std/libc/stdint.yo +5 -29
  107. package/std/libc/stdio.yo +5 -29
  108. package/std/libc/stdlib.yo +32 -39
  109. package/std/libc/string.yo +5 -23
  110. package/std/libc/sys/stat.yo +58 -56
  111. package/std/libc/time.yo +5 -19
  112. package/std/libc/unistd.yo +5 -20
  113. package/std/libc/wctype.yo +6 -9
  114. package/std/libc/windows.yo +26 -30
  115. package/std/log.yo +41 -55
  116. package/std/net/addr.yo +102 -97
  117. package/std/net/dns.yo +27 -28
  118. package/std/net/errors.yo +50 -49
  119. package/std/net/tcp.yo +113 -124
  120. package/std/net/udp.yo +55 -66
  121. package/std/os/env.yo +35 -33
  122. package/std/os/signal.yo +15 -25
  123. package/std/path.yo +276 -311
  124. package/std/prelude.yo +6316 -4333
  125. package/std/process/command.yo +87 -103
  126. package/std/process/index.yo +12 -31
  127. package/std/regex/compiler.yo +196 -95
  128. package/std/regex/flags.yo +58 -39
  129. package/std/regex/index.yo +157 -173
  130. package/std/regex/match.yo +20 -31
  131. package/std/regex/node.yo +134 -152
  132. package/std/regex/parser.yo +283 -259
  133. package/std/regex/unicode.yo +172 -202
  134. package/std/regex/vm.yo +155 -171
  135. package/std/string/index.yo +5 -7
  136. package/std/string/rune.yo +45 -55
  137. package/std/string/string.yo +937 -964
  138. package/std/string/string_builder.yo +94 -104
  139. package/std/string/unicode.yo +46 -64
  140. package/std/sync/channel.yo +72 -73
  141. package/std/sync/cond.yo +31 -36
  142. package/std/sync/mutex.yo +30 -32
  143. package/std/sync/once.yo +13 -16
  144. package/std/sync/rwlock.yo +26 -31
  145. package/std/sync/waitgroup.yo +20 -25
  146. package/std/sys/advise.yo +16 -24
  147. package/std/sys/bufio/buf_reader.yo +77 -93
  148. package/std/sys/bufio/buf_writer.yo +52 -65
  149. package/std/sys/clock.yo +4 -9
  150. package/std/sys/constants.yo +77 -61
  151. package/std/sys/copy.yo +4 -10
  152. package/std/sys/dir.yo +26 -43
  153. package/std/sys/dns.yo +41 -61
  154. package/std/sys/errors.yo +95 -103
  155. package/std/sys/events.yo +45 -57
  156. package/std/sys/externs.yo +319 -267
  157. package/std/sys/fallocate.yo +7 -11
  158. package/std/sys/fcntl.yo +14 -22
  159. package/std/sys/file.yo +26 -40
  160. package/std/sys/future.yo +5 -8
  161. package/std/sys/iov.yo +12 -25
  162. package/std/sys/lock.yo +12 -13
  163. package/std/sys/mmap.yo +38 -43
  164. package/std/sys/path.yo +3 -8
  165. package/std/sys/perm.yo +7 -21
  166. package/std/sys/pipe.yo +5 -12
  167. package/std/sys/process.yo +23 -29
  168. package/std/sys/seek.yo +10 -12
  169. package/std/sys/signal.yo +7 -13
  170. package/std/sys/signals.yo +52 -35
  171. package/std/sys/socket.yo +63 -58
  172. package/std/sys/socketpair.yo +3 -6
  173. package/std/sys/sockinfo.yo +11 -20
  174. package/std/sys/statfs.yo +11 -34
  175. package/std/sys/statx.yo +25 -52
  176. package/std/sys/sysinfo.yo +15 -20
  177. package/std/sys/tcp.yo +62 -92
  178. package/std/sys/temp.yo +5 -9
  179. package/std/sys/time.yo +5 -15
  180. package/std/sys/timer.yo +6 -11
  181. package/std/sys/tty.yo +10 -18
  182. package/std/sys/udp.yo +22 -39
  183. package/std/sys/umask.yo +3 -6
  184. package/std/sys/unix.yo +33 -52
  185. package/std/testing/bench.yo +49 -52
  186. package/std/thread.yo +10 -15
  187. package/std/time/datetime.yo +105 -89
  188. package/std/time/duration.yo +43 -56
  189. package/std/time/instant.yo +13 -18
  190. package/std/time/sleep.yo +5 -9
  191. package/std/url/index.yo +184 -209
  192. package/std/worker.yo +6 -10
  193. package/out/types/src/evaluator/calls/module-type.d.ts +0 -11
  194. package/out/types/src/evaluator/types/module.d.ts +0 -19
package/std/sys/tcp.yo CHANGED
@@ -33,224 +33,194 @@
33
33
  // client_fd := await tcp.accept(sockfd);
34
34
  // // ...
35
35
  // };
36
-
37
- { GlobalAllocator } :: import "../allocator.yo";
36
+ { GlobalAllocator } :: import("../allocator.yo");
38
37
  { malloc, free } :: GlobalAllocator;
39
- { IOFuture } :: import "./future.yo";
40
- {
41
- __yo_async_socket_start, __yo_async_bind_start,
42
- __yo_async_listen_start, __yo_async_accept_start,
43
- __yo_async_connect_start, __yo_async_send_start,
44
- __yo_async_recv_start, __yo_async_shutdown_start,
45
- __yo_async_setsockopt_start, __yo_async_getsockopt_start,
46
- __yo_async_close_start,
47
- __yo_sockaddr_set_family, __yo_sockaddr_get_family,
48
- __yo_sockaddr_in_set_port, __yo_sockaddr_in_get_port,
49
- __yo_sockaddr_in_set_addr, __yo_sockaddr_in_get_addr,
50
- __yo_sockaddr_in6_set_port, __yo_sockaddr_in6_get_port,
51
- __yo_sockaddr_in6_set_addr, __yo_sockaddr_in6_get_addr,
52
- __yo_inet_pton, __yo_inet_ntop,
53
- __yo_htons, __yo_ntohs, __yo_htonl, __yo_ntohl
54
- } :: import "./externs.yo";
55
- {
56
- AF_INET, AF_INET6, SOCK_STREAM,
57
- sockaddr_in_size, sockaddr_in6_size
58
- } :: import "./socket.yo";
59
-
38
+ { IOFuture } :: import("./future.yo");
39
+ { __yo_async_socket_start, __yo_async_bind_start, __yo_async_listen_start, __yo_async_accept_start, __yo_async_connect_start, __yo_async_send_start, __yo_async_recv_start, __yo_async_shutdown_start, __yo_async_setsockopt_start, __yo_async_getsockopt_start, __yo_async_close_start, __yo_sockaddr_set_family, __yo_sockaddr_get_family, __yo_sockaddr_in_set_port, __yo_sockaddr_in_get_port, __yo_sockaddr_in_set_addr, __yo_sockaddr_in_get_addr, __yo_sockaddr_in6_set_port, __yo_sockaddr_in6_get_port, __yo_sockaddr_in6_set_addr, __yo_sockaddr_in6_get_addr, __yo_inet_pton, __yo_inet_ntop, __yo_htons, __yo_ntohs, __yo_htonl, __yo_ntohl } :: import("./externs.yo");
40
+ { AF_INET, AF_INET6, SOCK_STREAM, sockaddr_in_size, sockaddr_in6_size } :: import("./socket.yo");
60
41
  // ============================================================================
61
42
  // SockAddr - Socket address buffer with pointer and length
62
43
  // ============================================================================
63
-
64
44
  SockAddr :: struct(
65
45
  buf : *(u8),
66
46
  len : u32
67
47
  );
68
- export SockAddr;
69
-
48
+ export(SockAddr);
70
49
  // ============================================================================
71
50
  // Core TCP Operations (return IOFuture, use with await)
72
51
  // ============================================================================
73
-
74
52
  // Create a TCP socket.
75
53
  // domain: AF_INET or AF_INET6
76
54
  // Returns fd on success, -errno on failure.
77
- socket :: (fn(domain: i32, sock_type: i32, protocol: i32) -> IOFuture)(
55
+ socket :: (fn(domain : i32, sock_type : i32, protocol : i32) -> IOFuture)(
78
56
  __yo_async_socket_start(domain, sock_type, protocol)
79
57
  );
80
-
81
58
  // Bind a socket to a local address.
82
59
  // Returns 0 on success, -errno on failure.
83
- bind :: (fn(sockfd: i32, addr: *(u8), addrlen: u32) -> IOFuture)(
60
+ bind :: (fn(sockfd : i32, addr : *(u8), addrlen : u32) -> IOFuture)(
84
61
  __yo_async_bind_start(sockfd, addr, addrlen)
85
62
  );
86
-
87
63
  // Listen for incoming connections on a socket.
88
64
  // backlog: maximum length of the pending connections queue.
89
65
  // Returns 0 on success, -errno on failure.
90
- listen :: (fn(sockfd: i32, backlog: i32) -> IOFuture)(
66
+ listen :: (fn(sockfd : i32, backlog : i32) -> IOFuture)(
91
67
  __yo_async_listen_start(sockfd, backlog)
92
68
  );
93
-
94
69
  // Accept an incoming connection on a listening socket.
95
70
  // Returns the new connection fd on success, -errno on failure.
96
71
  // addr/addrlen can be used to retrieve the peer address.
97
- accept :: (fn(sockfd: i32, addr: *(u8), addrlen: *(u32)) -> IOFuture)(
72
+ accept :: (fn(sockfd : i32, addr : *(u8), addrlen : *(u32)) -> IOFuture)(
98
73
  __yo_async_accept_start(sockfd, addr, addrlen)
99
74
  );
100
-
101
75
  // Connect to a remote address.
102
76
  // Returns 0 on success, -errno on failure.
103
- connect :: (fn(sockfd: i32, addr: *(u8), addrlen: u32) -> IOFuture)(
77
+ connect :: (fn(sockfd : i32, addr : *(u8), addrlen : u32) -> IOFuture)(
104
78
  __yo_async_connect_start(sockfd, addr, addrlen)
105
79
  );
106
-
107
80
  // Send data on a connected socket.
108
81
  // Returns number of bytes sent on success, -errno on failure.
109
- send :: (fn(sockfd: i32, buf: *(u8), len: usize, flags: i32) -> IOFuture)(
82
+ send :: (fn(sockfd : i32, buf : *(u8), len : usize, flags : i32) -> IOFuture)(
110
83
  __yo_async_send_start(sockfd, buf, len, flags)
111
84
  );
112
-
113
85
  // Receive data from a connected socket.
114
86
  // Returns number of bytes received on success (0 = peer closed), -errno on failure.
115
- recv :: (fn(sockfd: i32, buf: *(u8), len: usize, flags: i32) -> IOFuture)(
87
+ recv :: (fn(sockfd : i32, buf : *(u8), len : usize, flags : i32) -> IOFuture)(
116
88
  __yo_async_recv_start(sockfd, buf, len, flags)
117
89
  );
118
-
119
90
  // Shut down part of a full-duplex connection.
120
91
  // how: SHUT_RD (0), SHUT_WR (1), or SHUT_RDWR (2).
121
92
  // Returns 0 on success, -errno on failure.
122
- shutdown :: (fn(sockfd: i32, how: i32) -> IOFuture)(
93
+ shutdown :: (fn(sockfd : i32, how : i32) -> IOFuture)(
123
94
  __yo_async_shutdown_start(sockfd, how)
124
95
  );
125
-
126
96
  // Close a socket file descriptor.
127
97
  // Returns 0 on success, -errno on failure.
128
- close :: (fn(fd: i32) -> IOFuture)(
98
+ close :: (fn(fd : i32) -> IOFuture)(
129
99
  __yo_async_close_start(fd)
130
100
  );
131
-
132
101
  // ============================================================================
133
102
  // Socket Options
134
103
  // ============================================================================
135
-
136
104
  // Set a socket option (raw).
137
105
  // Returns 0 on success, -errno on failure.
138
- setsockopt :: (fn(sockfd: i32, level: i32, optname: i32, optval: *(u8), optlen: u32) -> IOFuture)(
106
+ setsockopt :: (fn(sockfd : i32, level : i32, optname : i32, optval : *(u8), optlen : u32) -> IOFuture)(
139
107
  __yo_async_setsockopt_start(sockfd, level, optname, optval, optlen)
140
108
  );
141
-
142
109
  // Get a socket option (raw).
143
110
  // Returns 0 on success, -errno on failure.
144
- getsockopt :: (fn(sockfd: i32, level: i32, optname: i32, optval: *(u8), optlen: *(u32)) -> IOFuture)(
111
+ getsockopt :: (fn(sockfd : i32, level : i32, optname : i32, optval : *(u8), optlen : *(u32)) -> IOFuture)(
145
112
  __yo_async_getsockopt_start(sockfd, level, optname, optval, optlen)
146
113
  );
147
-
148
114
  // ============================================================================
149
115
  // Socket Address Helpers
150
116
  // ============================================================================
151
-
152
117
  // Create an IPv4 socket address (sockaddr_in) from an IP string and port.
153
118
  // The IP string must be a null-terminated C string (e.g. "127.0.0.1").
154
119
  // Returns a SockAddr with an allocated buffer. Caller must free buf when done.
155
- make_sockaddr_in :: (fn(ip: *(u8), port: u16) -> SockAddr)({
120
+ make_sockaddr_in :: (fn(ip : *(u8), port : u16) -> SockAddr)({
156
121
  size := sockaddr_in_size();
157
122
  buf := *(u8)(malloc(size).unwrap());
158
123
  i := usize(0);
159
- while runtime((i < size)), {
124
+ while(runtime(i < size), {
160
125
  (buf &+ i).* = u8(0);
161
126
  i = (i + usize(1));
162
- };
127
+ });
163
128
  __yo_sockaddr_set_family(buf, u16(AF_INET));
164
129
  __yo_sockaddr_in_set_port(buf, port);
165
- __yo_inet_pton(AF_INET, ip, (buf &+ usize(4)));
130
+ __yo_inet_pton(AF_INET, ip, buf &+ usize(4));
166
131
  SockAddr(buf, u32(size))
167
132
  });
168
-
169
133
  // Create an IPv6 socket address (sockaddr_in6) from an IP string and port.
170
134
  // The IP string must be a null-terminated C string (e.g. "::1").
171
135
  // Returns a SockAddr with an allocated buffer. Caller must free buf when done.
172
- make_sockaddr_in6 :: (fn(ip: *(u8), port: u16) -> SockAddr)({
136
+ make_sockaddr_in6 :: (fn(ip : *(u8), port : u16) -> SockAddr)({
173
137
  size := sockaddr_in6_size();
174
138
  buf := *(u8)(malloc(size).unwrap());
175
139
  i := usize(0);
176
- while runtime((i < size)), {
140
+ while(runtime(i < size), {
177
141
  (buf &+ i).* = u8(0);
178
142
  i = (i + usize(1));
179
- };
143
+ });
180
144
  __yo_sockaddr_set_family(buf, u16(AF_INET6));
181
145
  __yo_sockaddr_in6_set_port(buf, port);
182
- __yo_inet_pton(AF_INET6, ip, (buf &+ usize(8)));
146
+ __yo_inet_pton(AF_INET6, ip, buf &+ usize(8));
183
147
  SockAddr(buf, u32(size))
184
148
  });
185
-
186
149
  // Create an IPv4 socket address for INADDR_ANY (0.0.0.0) with a given port.
187
150
  // Returns a SockAddr with an allocated buffer. Caller must free buf when done.
188
- make_sockaddr_in_any :: (fn(port: u16) -> SockAddr)({
151
+ make_sockaddr_in_any :: (fn(port : u16) -> SockAddr)({
189
152
  size := sockaddr_in_size();
190
153
  buf := *(u8)(malloc(size).unwrap());
191
154
  i := usize(0);
192
- while runtime((i < size)), {
155
+ while(runtime(i < size), {
193
156
  (buf &+ i).* = u8(0);
194
157
  i = (i + usize(1));
195
- };
158
+ });
196
159
  __yo_sockaddr_set_family(buf, u16(AF_INET));
197
160
  __yo_sockaddr_in_set_port(buf, port);
198
161
  __yo_sockaddr_in_set_addr(buf, u32(0));
199
162
  SockAddr(buf, u32(size))
200
163
  });
201
-
202
164
  // Create an IPv4 socket address for loopback (127.0.0.1) with a given port.
203
165
  // Returns a SockAddr with an allocated buffer. Caller must free buf when done.
204
- make_sockaddr_in_loopback :: (fn(port: u16) -> SockAddr)({
166
+ make_sockaddr_in_loopback :: (fn(port : u16) -> SockAddr)({
205
167
  size := sockaddr_in_size();
206
168
  buf := *(u8)(malloc(size).unwrap());
207
169
  i := usize(0);
208
- while runtime((i < size)), {
170
+ while(runtime(i < size), {
209
171
  (buf &+ i).* = u8(0);
210
172
  i = (i + usize(1));
211
- };
173
+ });
212
174
  __yo_sockaddr_set_family(buf, u16(AF_INET));
213
175
  __yo_sockaddr_in_set_port(buf, port);
214
176
  __yo_sockaddr_in_set_addr(buf, __yo_htonl(u32(0x7F000001)));
215
177
  SockAddr(buf, u32(size))
216
178
  });
217
-
218
179
  // Free a SockAddr buffer.
219
- free_sockaddr :: (fn(addr: SockAddr) -> unit)(
180
+ free_sockaddr :: (fn(addr : SockAddr) -> unit)(
220
181
  free(.Some(*(void)(addr.buf)))
221
182
  );
222
-
223
183
  // Get the port number from an IPv4 socket address buffer.
224
- get_port_in :: (fn(addr: *(u8)) -> u16)(
184
+ get_port_in :: (fn(addr : *(u8)) -> u16)(
225
185
  __yo_sockaddr_in_get_port(addr)
226
186
  );
227
-
228
187
  // Get the IPv4 address as a u32 from a socket address buffer.
229
- get_addr_in :: (fn(addr: *(u8)) -> u32)(
188
+ get_addr_in :: (fn(addr : *(u8)) -> u32)(
230
189
  __yo_sockaddr_in_get_addr(addr)
231
190
  );
232
-
233
191
  // Get the address family from a socket address buffer.
234
- get_family :: (fn(addr: *(u8)) -> u16)(
192
+ get_family :: (fn(addr : *(u8)) -> u16)(
235
193
  __yo_sockaddr_get_family(addr)
236
194
  );
237
-
238
195
  // ============================================================================
239
196
  // Byte Order Helpers
240
197
  // ============================================================================
241
-
242
- htons :: (fn(hostshort: u16) -> u16)(__yo_htons(hostshort));
243
- ntohs :: (fn(netshort: u16) -> u16)(__yo_ntohs(netshort));
244
- htonl :: (fn(hostlong: u32) -> u32)(__yo_htonl(hostlong));
245
- ntohl :: (fn(netlong: u32) -> u32)(__yo_ntohl(netlong));
246
-
247
- export
248
- socket, bind, listen, accept, connect,
249
- send, recv, shutdown, close,
250
- setsockopt, getsockopt,
251
- make_sockaddr_in, make_sockaddr_in6,
252
- make_sockaddr_in_any, make_sockaddr_in_loopback,
198
+ htons :: (fn(hostshort : u16) -> u16)(__yo_htons(hostshort));
199
+ ntohs :: (fn(netshort : u16) -> u16)(__yo_ntohs(netshort));
200
+ htonl :: (fn(hostlong : u32) -> u32)(__yo_htonl(hostlong));
201
+ ntohl :: (fn(netlong : u32) -> u32)(__yo_ntohl(netlong));
202
+ export(
203
+ socket,
204
+ bind,
205
+ listen,
206
+ accept,
207
+ connect,
208
+ send,
209
+ recv,
210
+ shutdown,
211
+ close,
212
+ setsockopt,
213
+ getsockopt,
214
+ make_sockaddr_in,
215
+ make_sockaddr_in6,
216
+ make_sockaddr_in_any,
217
+ make_sockaddr_in_loopback,
253
218
  free_sockaddr,
254
- get_port_in, get_addr_in, get_family,
255
- htons, ntohs, htonl, ntohl
256
- ;
219
+ get_port_in,
220
+ get_addr_in,
221
+ get_family,
222
+ htons,
223
+ ntohs,
224
+ htonl,
225
+ ntohl
226
+ );
package/std/sys/temp.yo CHANGED
@@ -7,24 +7,20 @@
7
7
  //!
8
8
  //! - `mkdtemp`: 0 on success, -errno on failure
9
9
  //! - `mkstemp`: fd on success, -errno on failure
10
-
11
- { __yo_sync_mkdtemp, __yo_sync_mkstemp } :: import "./externs.yo";
12
-
10
+ { __yo_sync_mkdtemp, __yo_sync_mkstemp } :: import("./externs.yo");
13
11
  // Create a temporary directory from template (e.g., "/tmp/myapp-XXXXXX").
14
12
  // The template is modified in-place with the actual path.
15
13
  // Returns 0 on success, -errno on failure.
16
- mkdtemp :: (fn(template: *(u8)) -> i32)(
14
+ mkdtemp :: (fn(template : *(u8)) -> i32)(
17
15
  __yo_sync_mkdtemp(template)
18
16
  );
19
-
20
17
  // Create a temporary file from template (e.g., "/tmp/myfile-XXXXXX").
21
18
  // The template is modified in-place with the actual path.
22
19
  // Returns fd on success, -errno on failure.
23
- mkstemp :: (fn(template: *(u8)) -> i32)(
20
+ mkstemp :: (fn(template : *(u8)) -> i32)(
24
21
  __yo_sync_mkstemp(template)
25
22
  );
26
-
27
- export
23
+ export(
28
24
  mkdtemp,
29
25
  mkstemp
30
- ;
26
+ );
package/std/sys/time.yo CHANGED
@@ -21,49 +21,39 @@
21
21
  // // Set timestamps on an open fd
22
22
  // ret2 := time.futime(fd, i64(1000000), i64(0), i64(2000000), i64(0));
23
23
  // assert(ret2 == i32(0));
24
-
25
- {
26
- __yo_sync_utime, __yo_sync_futime, __yo_sync_lutime
27
- } :: import "./externs.yo";
28
-
24
+ { __yo_sync_utime, __yo_sync_futime, __yo_sync_lutime } :: import("./externs.yo");
29
25
  // ============================================================================
30
26
  // utime — Change file timestamps by path
31
27
  // ============================================================================
32
-
33
28
  // Change file access and modification times by path.
34
29
  // path: file path (null-terminated)
35
30
  // atime_sec, atime_nsec: access time (seconds + nanoseconds)
36
31
  // mtime_sec, mtime_nsec: modification time (seconds + nanoseconds)
37
32
  // Returns 0 on success, -errno on failure.
38
- utime :: (fn(path: *(u8), atime_sec: i64, atime_nsec: i64, mtime_sec: i64, mtime_nsec: i64) -> i32)(
33
+ utime :: (fn(path : *(u8), atime_sec : i64, atime_nsec : i64, mtime_sec : i64, mtime_nsec : i64) -> i32)(
39
34
  __yo_sync_utime(path, atime_sec, atime_nsec, mtime_sec, mtime_nsec)
40
35
  );
41
-
42
36
  // ============================================================================
43
37
  // futime — Change file timestamps by fd
44
38
  // ============================================================================
45
-
46
39
  // Change file access and modification times by file descriptor.
47
40
  // fd: open file descriptor
48
41
  // atime_sec, atime_nsec: access time (seconds + nanoseconds)
49
42
  // mtime_sec, mtime_nsec: modification time (seconds + nanoseconds)
50
43
  // Returns 0 on success, -errno on failure.
51
- futime :: (fn(fd: i32, atime_sec: i64, atime_nsec: i64, mtime_sec: i64, mtime_nsec: i64) -> i32)(
44
+ futime :: (fn(fd : i32, atime_sec : i64, atime_nsec : i64, mtime_sec : i64, mtime_nsec : i64) -> i32)(
52
45
  __yo_sync_futime(fd, atime_sec, atime_nsec, mtime_sec, mtime_nsec)
53
46
  );
54
-
55
47
  // ============================================================================
56
48
  // lutime — Change symlink timestamps (does not follow symlinks)
57
49
  // ============================================================================
58
-
59
50
  // Change file access and modification times of a symlink itself.
60
51
  // Does not follow the symlink (uses AT_SYMLINK_NOFOLLOW).
61
52
  // path: symlink path (null-terminated)
62
53
  // atime_sec, atime_nsec: access time (seconds + nanoseconds)
63
54
  // mtime_sec, mtime_nsec: modification time (seconds + nanoseconds)
64
55
  // Returns 0 on success, -errno on failure.
65
- lutime :: (fn(path: *(u8), atime_sec: i64, atime_nsec: i64, mtime_sec: i64, mtime_nsec: i64) -> i32)(
56
+ lutime :: (fn(path : *(u8), atime_sec : i64, atime_nsec : i64, mtime_sec : i64, mtime_nsec : i64) -> i32)(
66
57
  __yo_sync_lutime(path, atime_sec, atime_nsec, mtime_sec, mtime_nsec)
67
58
  );
68
-
69
- export utime, futime, lutime;
59
+ export(utime, futime, lutime);
package/std/sys/timer.yo CHANGED
@@ -8,21 +8,16 @@
8
8
  //
9
9
  // Example:
10
10
  // IO :: import "std/io";
11
- //
11
+ //
12
12
  // task := async {
13
13
  // // Sleep for 100 milliseconds
14
14
  // result := await IO.sleep(u64(100));
15
15
  // printf("Woke up! result=%d\n", result);
16
16
  // };
17
-
18
- { IOFuture } :: import "./future.yo";
19
- { IOError } :: import "./errors.yo";
20
- { __yo_async_sleep_start } :: import "./externs.yo";
21
-
22
- sleep :: (fn(milliseconds: u64) -> IOFuture)(
17
+ { IOFuture } :: import("./future.yo");
18
+ { IOError } :: import("./errors.yo");
19
+ { __yo_async_sleep_start } :: import("./externs.yo");
20
+ sleep :: (fn(milliseconds : u64) -> IOFuture)(
23
21
  __yo_async_sleep_start(milliseconds)
24
22
  );
25
-
26
- export
27
- sleep
28
- ;
23
+ export(sleep);
package/std/sys/tty.yo CHANGED
@@ -1,8 +1,6 @@
1
1
  //! TTY operations.
2
-
3
- { __yo_tty_init, __yo_tty_set_mode, __yo_tty_reset_mode, __yo_tty_get_winsize, __yo_isatty } :: import "./externs.yo";
4
- { TTY_MODE_NORMAL, TTY_MODE_RAW, TTY_MODE_IO } :: import "./events.yo";
5
-
2
+ { __yo_tty_init, __yo_tty_set_mode, __yo_tty_reset_mode, __yo_tty_get_winsize, __yo_isatty } :: import("./externs.yo");
3
+ { TTY_MODE_NORMAL, TTY_MODE_RAW, TTY_MODE_IO } :: import("./events.yo");
6
4
  /// Terminal window size.
7
5
  WinSize :: struct(
8
6
  /// Width in columns.
@@ -10,31 +8,27 @@ WinSize :: struct(
10
8
  /// Height in rows.
11
9
  height : i32
12
10
  );
13
-
14
11
  /// Initialize TTY for a fd.
15
12
  /// Returns 0 on success, -errno on failure.
16
- tty_init :: (fn(fd: i32) -> i32)(
13
+ tty_init :: (fn(fd : i32) -> i32)(
17
14
  __yo_tty_init(fd)
18
15
  );
19
-
20
16
  /// Set TTY mode (normal, raw, IO).
21
17
  /// Returns 0 on success, -errno on failure.
22
- tty_set_mode :: (fn(fd: i32, mode: i32) -> i32)(
18
+ tty_set_mode :: (fn(fd : i32, mode : i32) -> i32)(
23
19
  __yo_tty_set_mode(fd, mode)
24
20
  );
25
-
26
21
  /// Reset TTY to original mode.
27
22
  /// Returns 0 on success, -errno on failure.
28
23
  tty_reset :: (fn() -> i32)(
29
24
  __yo_tty_reset_mode()
30
25
  );
31
-
32
26
  /// Get terminal window size.
33
27
  /// Returns width and height (0,0 on error).
34
- tty_winsize :: (fn(fd: i32) -> WinSize)({
28
+ tty_winsize :: (fn(fd : i32) -> WinSize)({
35
29
  buf_uninit := MaybeUninit(Array(i32, usize(2))).new();
36
30
  buf := *(i32)(buf_uninit.as_ptr());
37
- res := __yo_tty_get_winsize(fd, (buf &+ usize(0)), (buf &+ usize(1)));
31
+ res := __yo_tty_get_winsize(fd, buf &+ usize(0), buf &+ usize(1));
38
32
  width := cond(
39
33
  (res == i32(0)) => (buf &+ usize(0)).*,
40
34
  true => i32(0)
@@ -45,14 +39,12 @@ tty_winsize :: (fn(fd: i32) -> WinSize)({
45
39
  );
46
40
  WinSize(width, height)
47
41
  });
48
-
49
42
  /// Check if `fd` is a TTY.
50
- isatty :: (fn(fd: i32) -> bool)({
43
+ isatty :: (fn(fd : i32) -> bool)({
51
44
  res := __yo_isatty(fd);
52
- (res > i32(0))
45
+ res > i32(0)
53
46
  });
54
-
55
- export
47
+ export(
56
48
  WinSize,
57
49
  tty_init,
58
50
  tty_set_mode,
@@ -62,4 +54,4 @@ export
62
54
  TTY_MODE_NORMAL,
63
55
  TTY_MODE_RAW,
64
56
  TTY_MODE_IO
65
- ;
57
+ );
package/std/sys/udp.yo CHANGED
@@ -26,88 +26,71 @@
26
26
  // await udp.close(sockfd);
27
27
  // tcp.free_sockaddr(addr);
28
28
  // };
29
-
30
- { IOFuture } :: import "./future.yo";
31
- {
32
- __yo_async_socket_start, __yo_async_bind_start,
33
- __yo_async_send_start, __yo_async_recv_start,
34
- __yo_async_sendto_start, __yo_async_recvfrom_start,
35
- __yo_async_close_start,
36
- __yo_async_setsockopt_start, __yo_async_getsockopt_start
37
- } :: import "./externs.yo";
38
- {
39
- SOCK_DGRAM
40
- } :: import "./socket.yo";
41
-
29
+ { IOFuture } :: import("./future.yo");
30
+ { __yo_async_socket_start, __yo_async_bind_start, __yo_async_send_start, __yo_async_recv_start, __yo_async_sendto_start, __yo_async_recvfrom_start, __yo_async_close_start, __yo_async_setsockopt_start, __yo_async_getsockopt_start } :: import("./externs.yo");
31
+ { SOCK_DGRAM } :: import("./socket.yo");
42
32
  // ============================================================================
43
33
  // Core UDP Operations (return IOFuture, use with await)
44
34
  // ============================================================================
45
-
46
35
  // Create a UDP socket.
47
36
  // domain: AF_INET or AF_INET6
48
37
  // protocol: typically 0
49
38
  // Returns fd on success, -errno on failure.
50
- socket :: (fn(domain: i32, protocol: i32) -> IOFuture)(
39
+ socket :: (fn(domain : i32, protocol : i32) -> IOFuture)(
51
40
  __yo_async_socket_start(domain, SOCK_DGRAM, protocol)
52
41
  );
53
-
54
42
  // Bind a UDP socket to a local address.
55
43
  // Returns 0 on success, -errno on failure.
56
- bind :: (fn(sockfd: i32, addr: *(u8), addrlen: u32) -> IOFuture)(
44
+ bind :: (fn(sockfd : i32, addr : *(u8), addrlen : u32) -> IOFuture)(
57
45
  __yo_async_bind_start(sockfd, addr, addrlen)
58
46
  );
59
-
60
47
  // Send a datagram to a specific destination address.
61
48
  // Returns number of bytes sent on success, -errno on failure.
62
- sendto :: (fn(sockfd: i32, buf: *(u8), len: usize, flags: i32, dest_addr: *(u8), addrlen: u32) -> IOFuture)(
49
+ sendto :: (fn(sockfd : i32, buf : *(u8), len : usize, flags : i32, dest_addr : *(u8), addrlen : u32) -> IOFuture)(
63
50
  __yo_async_sendto_start(sockfd, buf, len, flags, dest_addr, addrlen)
64
51
  );
65
-
66
52
  // Receive a datagram and get the source address.
67
53
  // src_addr/addrlen are filled with the sender's address.
68
54
  // Returns number of bytes received on success, -errno on failure.
69
- recvfrom :: (fn(sockfd: i32, buf: *(u8), len: usize, flags: i32, src_addr: *(u8), addrlen: *(u32)) -> IOFuture)(
55
+ recvfrom :: (fn(sockfd : i32, buf : *(u8), len : usize, flags : i32, src_addr : *(u8), addrlen : *(u32)) -> IOFuture)(
70
56
  __yo_async_recvfrom_start(sockfd, buf, len, flags, src_addr, addrlen)
71
57
  );
72
-
73
58
  // Send data on a connected UDP socket (after connect()).
74
59
  // Returns number of bytes sent on success, -errno on failure.
75
- send :: (fn(sockfd: i32, buf: *(u8), len: usize, flags: i32) -> IOFuture)(
60
+ send :: (fn(sockfd : i32, buf : *(u8), len : usize, flags : i32) -> IOFuture)(
76
61
  __yo_async_send_start(sockfd, buf, len, flags)
77
62
  );
78
-
79
63
  // Receive data on a connected UDP socket (after connect()).
80
64
  // Returns number of bytes received on success, -errno on failure.
81
- recv :: (fn(sockfd: i32, buf: *(u8), len: usize, flags: i32) -> IOFuture)(
65
+ recv :: (fn(sockfd : i32, buf : *(u8), len : usize, flags : i32) -> IOFuture)(
82
66
  __yo_async_recv_start(sockfd, buf, len, flags)
83
67
  );
84
-
85
68
  // Close a UDP socket file descriptor.
86
69
  // Returns 0 on success, -errno on failure.
87
- close :: (fn(fd: i32) -> IOFuture)(
70
+ close :: (fn(fd : i32) -> IOFuture)(
88
71
  __yo_async_close_start(fd)
89
72
  );
90
-
91
73
  // ============================================================================
92
74
  // Socket Options
93
75
  // ============================================================================
94
-
95
76
  // Set a socket option (raw).
96
77
  // Returns 0 on success, -errno on failure.
97
- setsockopt :: (fn(sockfd: i32, level: i32, optname: i32, optval: *(u8), optlen: u32) -> IOFuture)(
78
+ setsockopt :: (fn(sockfd : i32, level : i32, optname : i32, optval : *(u8), optlen : u32) -> IOFuture)(
98
79
  __yo_async_setsockopt_start(sockfd, level, optname, optval, optlen)
99
80
  );
100
-
101
81
  // Get a socket option (raw).
102
82
  // Returns 0 on success, -errno on failure.
103
- getsockopt :: (fn(sockfd: i32, level: i32, optname: i32, optval: *(u8), optlen: *(u32)) -> IOFuture)(
83
+ getsockopt :: (fn(sockfd : i32, level : i32, optname : i32, optval : *(u8), optlen : *(u32)) -> IOFuture)(
104
84
  __yo_async_getsockopt_start(sockfd, level, optname, optval, optlen)
105
85
  );
106
-
107
- export
108
- socket, bind,
109
- sendto, recvfrom,
110
- send, recv,
86
+ export(
87
+ socket,
88
+ bind,
89
+ sendto,
90
+ recvfrom,
91
+ send,
92
+ recv,
111
93
  close,
112
- setsockopt, getsockopt
113
- ;
94
+ setsockopt,
95
+ getsockopt
96
+ );
package/std/sys/umask.yo CHANGED
@@ -2,11 +2,8 @@
2
2
  //!
3
3
  //! Synchronous wrapper for setting process `umask`.
4
4
  //! Returns previous mask value.
5
-
6
- { __yo_sync_umask } :: import "./externs.yo";
7
-
8
- umask :: (fn(mask: i32) -> i32)(
5
+ { __yo_sync_umask } :: import("./externs.yo");
6
+ umask :: (fn(mask : i32) -> i32)(
9
7
  __yo_sync_umask(mask)
10
8
  );
11
-
12
- export umask;
9
+ export(umask);