@shd101wyy/yo 0.1.29 → 0.1.30

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 (174) hide show
  1. package/.github/skills/yo-async-effects/SKILL.md +3 -3
  2. package/.github/skills/yo-async-effects/async-effects-recipes.md +19 -11
  3. package/.github/skills/yo-core-patterns/core-patterns-cheatsheet.md +33 -13
  4. package/.github/skills/yo-project-workflow/workflow-cheatsheet.md +1 -1
  5. package/.github/skills/yo-syntax/syntax-cheatsheet.md +59 -21
  6. package/README.md +4 -3
  7. package/out/cjs/index.cjs +771 -676
  8. package/out/cjs/yo-cli.cjs +1003 -898
  9. package/out/cjs/yo-lsp.cjs +834 -739
  10. package/out/esm/index.mjs +716 -621
  11. package/out/types/src/codegen/exprs/async.d.ts +2 -0
  12. package/out/types/src/codegen/exprs/await.d.ts +1 -0
  13. package/out/types/src/codegen/exprs/closures.d.ts +4 -0
  14. package/out/types/src/codegen/functions/context.d.ts +6 -0
  15. package/out/types/src/env.d.ts +2 -0
  16. package/out/types/src/evaluator/builtins/pragma.d.ts +9 -0
  17. package/out/types/src/evaluator/builtins/unsafe.d.ts +8 -0
  18. package/out/types/src/evaluator/context.d.ts +2 -0
  19. package/out/types/src/evaluator/index.d.ts +1 -1
  20. package/out/types/src/evaluator/memory-safety.d.ts +14 -0
  21. package/out/types/src/evaluator/types/flowability.d.ts +6 -0
  22. package/out/types/src/expr-traversal.d.ts +1 -0
  23. package/out/types/src/expr.d.ts +4 -1
  24. package/out/types/src/public-safe-report.d.ts +19 -0
  25. package/out/types/src/tests/comptime-ref-gate.test.d.ts +1 -0
  26. package/out/types/src/tests/pragma-validation.test.d.ts +1 -0
  27. package/out/types/src/tests/public-safe-report.test.d.ts +1 -0
  28. package/out/types/src/tests/type-representation-pointer.test.d.ts +1 -0
  29. package/out/types/src/tests/unsafe-gate.test.d.ts +1 -0
  30. package/out/types/src/tests/unsafe-report-classify.test.d.ts +1 -0
  31. package/out/types/src/types/definitions.d.ts +2 -0
  32. package/out/types/src/types/utils.d.ts +4 -0
  33. package/out/types/src/unsafe-report.d.ts +29 -0
  34. package/out/types/src/value.d.ts +1 -0
  35. package/out/types/tsconfig.tsbuildinfo +1 -1
  36. package/package.json +1 -1
  37. package/scripts/add-pragma-for-pointer-decls.ts +134 -0
  38. package/scripts/add-pragma.ts +58 -0
  39. package/scripts/migrate-amp-method-calls.ts +186 -0
  40. package/scripts/migrate-clone-calls.ts +93 -0
  41. package/scripts/migrate-get-unwrap.ts +166 -0
  42. package/scripts/migrate-index-patterns.ts +210 -0
  43. package/scripts/migrate-index-trait.ts +142 -0
  44. package/scripts/migrate-iterator.ts +150 -0
  45. package/scripts/migrate-self-ptr.ts +220 -0
  46. package/scripts/migrate-skip-pragmas.ts +109 -0
  47. package/scripts/migrate-tostring.ts +134 -0
  48. package/scripts/trim-pragma.ts +130 -0
  49. package/scripts/wrap-extern-calls.ts +161 -0
  50. package/std/alg/hash.yo +3 -2
  51. package/std/allocator.yo +6 -5
  52. package/std/async.yo +2 -2
  53. package/std/collections/array_list.yo +59 -40
  54. package/std/collections/btree_map.yo +19 -18
  55. package/std/collections/deque.yo +9 -8
  56. package/std/collections/hash_map.yo +101 -13
  57. package/std/collections/hash_set.yo +5 -4
  58. package/std/collections/linked_list.yo +39 -4
  59. package/std/collections/ordered_map.yo +3 -3
  60. package/std/collections/priority_queue.yo +14 -13
  61. package/std/crypto/md5.yo +2 -1
  62. package/std/crypto/random.yo +16 -15
  63. package/std/crypto/sha256.yo +2 -1
  64. package/std/encoding/base64.yo +14 -14
  65. package/std/encoding/hex.yo +3 -3
  66. package/std/encoding/json.yo +59 -10
  67. package/std/encoding/punycode.yo +24 -23
  68. package/std/encoding/toml.yo +4 -3
  69. package/std/encoding/utf16.yo +2 -2
  70. package/std/env.yo +43 -28
  71. package/std/error.yo +6 -6
  72. package/std/fmt/display.yo +2 -2
  73. package/std/fmt/index.yo +6 -5
  74. package/std/fmt/to_string.yo +39 -38
  75. package/std/fmt/writer.yo +9 -8
  76. package/std/fs/dir.yo +34 -33
  77. package/std/fs/file.yo +52 -51
  78. package/std/fs/metadata.yo +10 -9
  79. package/std/fs/temp.yo +24 -13
  80. package/std/fs/walker.yo +10 -9
  81. package/std/gc.yo +1 -0
  82. package/std/glob.yo +7 -7
  83. package/std/http/client.yo +15 -14
  84. package/std/http/http.yo +6 -6
  85. package/std/http/index.yo +1 -1
  86. package/std/imm/list.yo +33 -0
  87. package/std/imm/map.yo +2 -1
  88. package/std/imm/set.yo +1 -0
  89. package/std/imm/sorted_map.yo +1 -0
  90. package/std/imm/sorted_set.yo +1 -0
  91. package/std/imm/string.yo +27 -23
  92. package/std/imm/vec.yo +18 -2
  93. package/std/io/reader.yo +2 -1
  94. package/std/io/writer.yo +3 -2
  95. package/std/libc/assert.yo +1 -0
  96. package/std/libc/ctype.yo +1 -0
  97. package/std/libc/dirent.yo +1 -0
  98. package/std/libc/errno.yo +1 -0
  99. package/std/libc/fcntl.yo +1 -0
  100. package/std/libc/float.yo +1 -0
  101. package/std/libc/limits.yo +1 -0
  102. package/std/libc/math.yo +1 -0
  103. package/std/libc/signal.yo +1 -0
  104. package/std/libc/stdatomic.yo +1 -0
  105. package/std/libc/stdint.yo +1 -0
  106. package/std/libc/stdio.yo +1 -0
  107. package/std/libc/stdlib.yo +1 -0
  108. package/std/libc/string.yo +1 -0
  109. package/std/libc/sys/stat.yo +1 -0
  110. package/std/libc/time.yo +1 -0
  111. package/std/libc/unistd.yo +1 -0
  112. package/std/libc/wctype.yo +1 -0
  113. package/std/libc/windows.yo +2 -0
  114. package/std/log.yo +7 -6
  115. package/std/net/addr.yo +5 -4
  116. package/std/net/dns.yo +7 -6
  117. package/std/net/errors.yo +8 -8
  118. package/std/net/tcp.yo +19 -18
  119. package/std/net/udp.yo +13 -12
  120. package/std/os/signal.yo +3 -3
  121. package/std/path.yo +1 -0
  122. package/std/prelude.yo +353 -182
  123. package/std/process/command.yo +40 -23
  124. package/std/process/index.yo +2 -1
  125. package/std/regex/compiler.yo +10 -9
  126. package/std/regex/index.yo +41 -41
  127. package/std/regex/match.yo +2 -2
  128. package/std/regex/parser.yo +21 -21
  129. package/std/regex/vm.yo +42 -41
  130. package/std/string/string.yo +95 -40
  131. package/std/string/string_builder.yo +9 -9
  132. package/std/string/unicode.yo +50 -49
  133. package/std/sync/channel.yo +2 -1
  134. package/std/sync/cond.yo +5 -4
  135. package/std/sync/mutex.yo +4 -3
  136. package/std/sys/advise.yo +1 -0
  137. package/std/sys/bufio/buf_reader.yo +17 -16
  138. package/std/sys/bufio/buf_writer.yo +10 -9
  139. package/std/sys/clock.yo +1 -0
  140. package/std/sys/copy.yo +1 -0
  141. package/std/sys/dir.yo +10 -9
  142. package/std/sys/dns.yo +6 -5
  143. package/std/sys/errors.yo +11 -11
  144. package/std/sys/events.yo +1 -0
  145. package/std/sys/externs.yo +38 -37
  146. package/std/sys/file.yo +17 -16
  147. package/std/sys/future.yo +4 -3
  148. package/std/sys/iov.yo +1 -0
  149. package/std/sys/mmap.yo +1 -0
  150. package/std/sys/path.yo +1 -0
  151. package/std/sys/perm.yo +2 -1
  152. package/std/sys/pipe.yo +1 -0
  153. package/std/sys/process.yo +5 -4
  154. package/std/sys/signal.yo +1 -0
  155. package/std/sys/socketpair.yo +1 -0
  156. package/std/sys/sockinfo.yo +1 -0
  157. package/std/sys/statfs.yo +2 -1
  158. package/std/sys/statx.yo +1 -0
  159. package/std/sys/sysinfo.yo +1 -0
  160. package/std/sys/tcp.yo +15 -14
  161. package/std/sys/temp.yo +1 -0
  162. package/std/sys/time.yo +2 -1
  163. package/std/sys/timer.yo +6 -6
  164. package/std/sys/tty.yo +2 -1
  165. package/std/sys/udp.yo +13 -12
  166. package/std/sys/unix.yo +12 -11
  167. package/std/testing/bench.yo +4 -3
  168. package/std/thread.yo +7 -6
  169. package/std/time/datetime.yo +18 -15
  170. package/std/time/duration.yo +11 -10
  171. package/std/time/instant.yo +4 -4
  172. package/std/time/sleep.yo +1 -0
  173. package/std/url/index.yo +3 -3
  174. package/std/worker.yo +4 -3
@@ -17,9 +17,10 @@
17
17
  //! .Err(e) => println(e.to_string())
18
18
  //! );
19
19
  //! ```
20
+ pragma(Pragma.AllowUnsafe);
20
21
  { ArrayList } :: import("../../collections/array_list");
21
22
  open(import("../../string"));
22
- { IOError } :: import("../errors");
23
+ { IoError } :: import("../errors");
23
24
  IO_file :: import("../file");
24
25
  { GlobalAllocator } :: import("../../allocator");
25
26
  { malloc, free } :: GlobalAllocator;
@@ -68,19 +69,19 @@ impl(
68
69
  // Read a line from the reader (up to and including '\n').
69
70
  // Returns .None on EOF when no data is available.
70
71
  // Returns .Some(line) with the line content (without the trailing '\n').
71
- read_line : (fn(self : Self, io : IO) -> Impl(Future(Result(Option(String), IOError), IO)))({
72
+ read_line : (fn(self : Self, io : Io) -> Impl(Future(Result(Option(String), IoError), Io)))({
72
73
  the_fd := self._fd;
73
74
  io.async((io) => {
74
75
  line_bytes := ArrayList(u8).new();
75
76
  found_newline := false;
76
77
  hit_eof := false;
77
- (read_err : Option(IOError)) =.None;
78
+ (read_err : Option(IoError)) =.None;
78
79
  while(runtime(((!(found_newline)) && (!(hit_eof))) && read_err.is_none()), {
79
80
  cond(
80
81
  (self._pos < self._filled) => {
81
82
  scan := self._pos;
82
83
  while(runtime((scan < self._filled) && (!(found_newline))), {
83
- b := self._buf.get(scan).unwrap();
84
+ b := self._buf(scan);
84
85
  cond(
85
86
  (b == _NEWLINE) => {
86
87
  found_newline = true;
@@ -99,7 +100,7 @@ impl(
99
100
  cond(
100
101
  (n < i32(0)) => {
101
102
  free(.Some(*(void)(raw_buf)));
102
- read_err =.Some(IOError.from_errno(i32(0) - n));
103
+ read_err =.Some(IoError.from_errno(i32(0) - n));
103
104
  },
104
105
  (n == i32(0)) => {
105
106
  free(.Some(*(void)(raw_buf)));
@@ -134,11 +135,11 @@ impl(
134
135
  }),
135
136
  // Read up to `size` bytes into a provided buffer.
136
137
  // Returns the number of bytes actually read.
137
- read : (fn(self : Self, buf : *(u8), size : u32, io : IO) -> Impl(Future(Result(i32, IOError), IO)))({
138
+ read : (fn(self : Self, buf : *(u8), size : u32, io : Io) -> Impl(Future(Result(i32, IoError), Io)))({
138
139
  the_fd := self._fd;
139
140
  io.async((io) => {
140
141
  available := (self._filled - self._pos);
141
- (read_err : Option(IOError)) =.None;
142
+ (read_err : Option(IoError)) =.None;
142
143
  (read_n : i32) = i32(0);
143
144
  done := false;
144
145
  // If there's data already buffered, serve from buffer
@@ -150,7 +151,7 @@ impl(
150
151
  );
151
152
  i := usize(0);
152
153
  while(runtime(i < to_copy), {
153
- b := self._buf.get(self._pos + i).unwrap();
154
+ b := self._buf(self._pos + i);
154
155
  (buf &+ i).* = b;
155
156
  i = (i + usize(1));
156
157
  });
@@ -166,7 +167,7 @@ impl(
166
167
  n := io.await(IO_file.read(the_fd, buf, size, self._offset), io);
167
168
  cond(
168
169
  (n < i32(0)) => {
169
- read_err =.Some(IOError.from_errno(i32(0) - n));
170
+ read_err =.Some(IoError.from_errno(i32(0) - n));
170
171
  },
171
172
  true => {
172
173
  self._offset = (self._offset + u64(n));
@@ -185,7 +186,7 @@ impl(
185
186
  cond(
186
187
  (n < i32(0)) => {
187
188
  free(.Some(*(void)(raw_buf)));
188
- read_err =.Some(IOError.from_errno(i32(0) - n));
189
+ read_err =.Some(IoError.from_errno(i32(0) - n));
189
190
  },
190
191
  (n == i32(0)) => {
191
192
  free(.Some(*(void)(raw_buf)));
@@ -208,7 +209,7 @@ impl(
208
209
  );
209
210
  j := usize(0);
210
211
  while(runtime(j < to_copy), {
211
- b := self._buf.get(j).unwrap();
212
+ b := self._buf(j);
212
213
  (buf &+ j).* = b;
213
214
  j = (j + usize(1));
214
215
  });
@@ -227,7 +228,7 @@ impl(
227
228
  })
228
229
  }),
229
230
  // Read all remaining data into an ArrayList of bytes.
230
- read_bytes : (fn(self : Self, io : IO) -> Impl(Future(Result(ArrayList(u8), IOError), IO)))({
231
+ read_bytes : (fn(self : Self, io : Io) -> Impl(Future(Result(ArrayList(u8), IoError), Io)))({
231
232
  the_fd := self._fd;
232
233
  io.async((io) => {
233
234
  result := ArrayList(u8).new();
@@ -236,7 +237,7 @@ impl(
236
237
  (self._pos < self._filled) => {
237
238
  i := self._pos;
238
239
  while(runtime(i < self._filled), {
239
- result.push(self._buf.get(i).unwrap());
240
+ result.push(self._buf(i));
240
241
  i = (i + usize(1));
241
242
  });
242
243
  self._pos = self._filled;
@@ -245,12 +246,12 @@ impl(
245
246
  );
246
247
  // Then read the rest from fd
247
248
  raw_buf := *(u8)(malloc(self._capacity).unwrap());
248
- (read_err : Option(IOError)) =.None;
249
+ (read_err : Option(IoError)) =.None;
249
250
  while(runtime(true), {
250
251
  n := io.await(IO_file.read(the_fd, raw_buf, u32(self._capacity), self._offset), io);
251
252
  cond(
252
253
  (n < i32(0)) => {
253
- read_err =.Some(IOError.from_errno(i32(0) - n));
254
+ read_err =.Some(IoError.from_errno(i32(0) - n));
254
255
  break;
255
256
  },
256
257
  (n == i32(0)) => break,
@@ -273,7 +274,7 @@ impl(
273
274
  })
274
275
  }),
275
276
  // Read all remaining data as a String.
276
- read_to_string : (fn(self : Self, io : IO) -> Impl(Future(Result(String, IOError), IO)))(
277
+ read_to_string : (fn(self : Self, io : Io) -> Impl(Future(Result(String, IoError), Io)))(
277
278
  io.async((io) => {
278
279
  bytes_result := io.await(self.read_bytes(io), io);
279
280
  match(
@@ -12,9 +12,10 @@
12
12
  //! io.await(writer.write_string(`hello\n`, io));
13
13
  //! io.await(writer.flush(io));
14
14
  //! ```
15
+ pragma(Pragma.AllowUnsafe);
15
16
  { ArrayList } :: import("../../collections/array_list");
16
17
  open(import("../../string"));
17
- { IOError } :: import("../errors");
18
+ { IoError } :: import("../errors");
18
19
  IO_file :: import("../file");
19
20
  { GlobalAllocator } :: import("../../allocator");
20
21
  { malloc, free } :: GlobalAllocator;
@@ -54,10 +55,10 @@ impl(
54
55
  self._buf.len()
55
56
  ),
56
57
  // Internal: flush the buffer contents to fd.
57
- _flush_inner : (fn(self : Self, io : IO) -> Impl(Future(Result(unit, IOError), IO)))({
58
+ _flush_inner : (fn(self : Self, io : Io) -> Impl(Future(Result(unit, IoError), Io)))({
58
59
  the_fd := self._fd;
59
60
  io.async((io) => {
60
- (write_err : Option(IOError)) =.None;
61
+ (write_err : Option(IoError)) =.None;
61
62
  cond(
62
63
  (self._buf.len() > usize(0)) => {
63
64
  written := usize(0);
@@ -68,7 +69,7 @@ impl(
68
69
  n := io.await(IO_file.write(the_fd, buf_ptr &+ written, remaining, self._offset), io);
69
70
  cond(
70
71
  (n < i32(0)) => {
71
- write_err =.Some(IOError.from_errno(i32(0) - n));
72
+ write_err =.Some(IoError.from_errno(i32(0) - n));
72
73
  },
73
74
  true => {
74
75
  written = (written + usize(n));
@@ -90,12 +91,12 @@ impl(
90
91
  // Write bytes from a pointer into the buffer.
91
92
  // Automatically flushes when the buffer is full.
92
93
  // Returns total number of bytes written.
93
- write : (fn(self : Self, data : *(u8), size : u32, io : IO) -> Impl(Future(Result(i32, IOError), IO)))({
94
+ write : (fn(self : Self, data : *(u8), size : u32, io : Io) -> Impl(Future(Result(i32, IoError), Io)))({
94
95
  the_fd := self._fd;
95
96
  io.async((io) => {
96
97
  remaining := usize(size);
97
98
  src_pos := usize(0);
98
- (write_err : Option(IOError)) =.None;
99
+ (write_err : Option(IoError)) =.None;
99
100
  while(runtime((remaining > usize(0)) && write_err.is_none()), {
100
101
  space := (self._capacity - self._buf.len());
101
102
  cond(
@@ -133,7 +134,7 @@ impl(
133
134
  })
134
135
  }),
135
136
  // Write a String to the buffer.
136
- write_string : (fn(self : Self, s : String, io : IO) -> Impl(Future(Result(i32, IOError), IO)))(
137
+ write_string : (fn(self : Self, s : String, io : Io) -> Impl(Future(Result(i32, IoError), Io)))(
137
138
  io.async((io) => {
138
139
  bytes := s.as_bytes();
139
140
  result := io.await(self.write(bytes.ptr().unwrap(), u32(bytes.len()), io), io);
@@ -141,14 +142,14 @@ impl(
141
142
  })
142
143
  ),
143
144
  // Write bytes from an ArrayList to the buffer.
144
- write_bytes : (fn(self : Self, data : ArrayList(u8), io : IO) -> Impl(Future(Result(i32, IOError), IO)))(
145
+ write_bytes : (fn(self : Self, data : ArrayList(u8), io : Io) -> Impl(Future(Result(i32, IoError), Io)))(
145
146
  io.async((io) => {
146
147
  result := io.await(self.write(data.ptr().unwrap(), u32(data.len()), io), io);
147
148
  result
148
149
  })
149
150
  ),
150
151
  // Flush all buffered data to the underlying file descriptor.
151
- flush : (fn(self : Self, io : IO) -> Impl(Future(Result(unit, IOError), IO)))(
152
+ flush : (fn(self : Self, io : Io) -> Impl(Future(Result(unit, IoError), Io)))(
152
153
  io.async((io) => {
153
154
  flush_result := io.await(self._flush_inner(io), io);
154
155
  flush_result
package/std/sys/clock.yo CHANGED
@@ -2,6 +2,7 @@
2
2
  //!
3
3
  //! Provides a synchronous wrapper for reading wall-clock and monotonic time.
4
4
  //! Returns 0 on success, -errno / negative platform error on failure.
5
+ pragma(Pragma.AllowUnsafe);
5
6
  { platform, Platform } :: import("../process");
6
7
  { __yo_sync_clock_gettime } :: import("./externs.yo");
7
8
  // Wall clock time (Unix epoch seconds + nanoseconds)
package/std/sys/copy.yo CHANGED
@@ -7,6 +7,7 @@
7
7
  //!
8
8
  //! - `copyfile`: 0 on success, -errno on failure
9
9
  //! - `sendfile`: bytes transferred on success, -errno on failure
10
+ pragma(Pragma.AllowUnsafe);
10
11
  { __yo_sync_copyfile, __yo_sync_sendfile } :: import("./externs.yo");
11
12
  // Copy a file using kernel-accelerated copy.
12
13
  // flags: 0 = default, 1 = COPYFILE_EXCL (fail if dst exists)
package/std/sys/dir.yo CHANGED
@@ -3,7 +3,7 @@
3
3
  //! Provides low-level directory manipulation wrappers around C runtime externs.
4
4
  //!
5
5
  //! Async operations (`mkdir`, `unlink`, `rename`, `symlink`, `link`, `getdents`)
6
- //! return `IOFuture` which resolves to:
6
+ //! return `IoFuture` which resolves to:
7
7
  //! - 0 on success (for mkdir, unlink, rename, symlink, link)
8
8
  //! - Bytes read for getdents
9
9
  //! - Negative value: -errno on failure
@@ -20,35 +20,36 @@
20
20
  // result := await mkdir(AT_FDCWD, *(u8)("/tmp/yo_test_dir"), i32(0o755));
21
21
  // assert(result == i32(0));
22
22
  // };
23
- { IOFuture } :: import("./future.yo");
23
+ pragma(Pragma.AllowUnsafe);
24
+ { IoFuture } :: import("./future.yo");
24
25
  { __yo_async_mkdirat_start, __yo_async_unlinkat_start, __yo_async_renameat_start, __yo_async_symlinkat_start, __yo_async_linkat_start, __yo_sync_readlinkat, __yo_async_getdents_start, __yo_dirent_size, __yo_dirent_reclen, __yo_dirent_type, __yo_dirent_name, __yo_dirent_ino } :: import("./externs.yo");
25
26
  // ============================================================================
26
- // Async Directory Operations (return IOFuture, use with await)
27
+ // Async Directory Operations (return IoFuture, use with await)
27
28
  // ============================================================================
28
29
  // Create a directory relative to dirfd. Use AT_FDCWD for current directory.
29
30
  // Returns 0 on success, -errno on failure.
30
- mkdir :: (fn(dirfd : i32, path : *(u8), mode : i32) -> IOFuture)(
31
+ mkdir :: (fn(dirfd : i32, path : *(u8), mode : i32) -> IoFuture)(
31
32
  __yo_async_mkdirat_start(dirfd, path, mode)
32
33
  );
33
34
  // Remove a file or directory relative to dirfd.
34
35
  // Use flags=0 for files, flags=AT_REMOVEDIR (0x200) for directories.
35
36
  // Returns 0 on success, -errno on failure.
36
- unlink :: (fn(dirfd : i32, path : *(u8), flags : i32) -> IOFuture)(
37
+ unlink :: (fn(dirfd : i32, path : *(u8), flags : i32) -> IoFuture)(
37
38
  __yo_async_unlinkat_start(dirfd, path, flags)
38
39
  );
39
40
  // Rename/move a file or directory.
40
41
  // Returns 0 on success, -errno on failure.
41
- rename :: (fn(olddirfd : i32, oldpath : *(u8), newdirfd : i32, newpath : *(u8)) -> IOFuture)(
42
+ rename :: (fn(olddirfd : i32, oldpath : *(u8), newdirfd : i32, newpath : *(u8)) -> IoFuture)(
42
43
  __yo_async_renameat_start(olddirfd, oldpath, newdirfd, newpath)
43
44
  );
44
45
  // Create a symbolic link at linkpath pointing to target.
45
46
  // Returns 0 on success, -errno on failure.
46
- symlink :: (fn(target : *(u8), newdirfd : i32, linkpath : *(u8)) -> IOFuture)(
47
+ symlink :: (fn(target : *(u8), newdirfd : i32, linkpath : *(u8)) -> IoFuture)(
47
48
  __yo_async_symlinkat_start(target, newdirfd, linkpath)
48
49
  );
49
50
  // Create a hard link from oldpath to newpath.
50
51
  // Returns 0 on success, -errno on failure.
51
- link :: (fn(olddirfd : i32, oldpath : *(u8), newdirfd : i32, newpath : *(u8), flags : i32) -> IOFuture)(
52
+ link :: (fn(olddirfd : i32, oldpath : *(u8), newdirfd : i32, newpath : *(u8), flags : i32) -> IoFuture)(
52
53
  __yo_async_linkat_start(olddirfd, oldpath, newdirfd, newpath, flags)
53
54
  );
54
55
  // Read the target of a symbolic link into buf.
@@ -93,7 +94,7 @@ readlink :: (fn(dirfd : i32, path : *(u8), buf : *(u8), bufsize : usize) -> i32)
93
94
  // free(.Some(*(void)(buf)));
94
95
  // await close(fd);
95
96
  // };
96
- getdents :: (fn(fd : i32, buf : *(u8), buf_size : u32) -> IOFuture)(
97
+ getdents :: (fn(fd : i32, buf : *(u8), buf_size : u32) -> IoFuture)(
97
98
  __yo_async_getdents_start(fd, buf, buf_size)
98
99
  );
99
100
  // ============================================================================
package/std/sys/dns.yo CHANGED
@@ -3,7 +3,7 @@
3
3
  //! Provides async DNS resolution wrapping `getaddrinfo`/`getnameinfo`, plus
4
4
  //! accessors for iterating the linked list of `addrinfo` results.
5
5
  //!
6
- //! All async operations return `IOFuture` which resolves to:
6
+ //! All async operations return `IoFuture` which resolves to:
7
7
  //! - 0: success
8
8
  //! - Non-zero: raw `gai_error` code (`EAI_NONAME`, `EAI_AGAIN`, etc.)
9
9
  //
@@ -36,12 +36,13 @@
36
36
  // );
37
37
  // dns.free_result(result_ptr);
38
38
  // };
39
+ pragma(Pragma.AllowUnsafe);
39
40
  { GlobalAllocator } :: import("../allocator");
40
41
  { malloc, free } :: GlobalAllocator;
41
- { IOFuture } :: import("./future.yo");
42
+ { IoFuture } :: import("./future.yo");
42
43
  { __yo_async_getaddrinfo_start, __yo_async_getnameinfo_start, __yo_freeaddrinfo, __yo_addrinfo_size, __yo_addrinfo_flags, __yo_addrinfo_family, __yo_addrinfo_socktype, __yo_addrinfo_protocol, __yo_addrinfo_addrlen, __yo_addrinfo_addr, __yo_addrinfo_canonname, __yo_addrinfo_next } :: import("./externs.yo");
43
44
  // ============================================================================
44
- // DNS Resolution (return IOFuture, use with await)
45
+ // DNS Resolution (return IoFuture, use with await)
45
46
  // ============================================================================
46
47
  // Resolve hostname to a linked list of addrinfo results.
47
48
  // node: hostname or IP string (e.g. "localhost", "example.com")
@@ -50,7 +51,7 @@
50
51
  // result: pointer to a ?*(u8) that will receive the head of the result list
51
52
  // Returns 0 on success, non-zero gai_error on failure.
52
53
  // Caller must call freeaddrinfo() on the result when done.
53
- getaddrinfo :: (fn(node : *(u8), service : ?*(u8), hints : ?*(u8), result : *(?*(u8))) -> IOFuture)(
54
+ getaddrinfo :: (fn(node : *(u8), service : ?*(u8), hints : ?*(u8), result : *(?*(u8))) -> IoFuture)(
54
55
  __yo_async_getaddrinfo_start(node, service, hints, result)
55
56
  );
56
57
  // Reverse lookup: convert a socket address to hostname and service strings.
@@ -62,7 +63,7 @@ getaddrinfo :: (fn(node : *(u8), service : ?*(u8), hints : ?*(u8), result : *(?*
62
63
  // servlen: size of service buffer
63
64
  // flags: NI_NUMERICHOST, NI_NUMERICSERV, etc.
64
65
  // Returns 0 on success, -gai_error on failure.
65
- getnameinfo :: (fn(addr : *(u8), addrlen : u32, host : *(u8), hostlen : usize, service : *(u8), servlen : usize, flags : i32) -> IOFuture)(
66
+ getnameinfo :: (fn(addr : *(u8), addrlen : u32, host : *(u8), hostlen : usize, service : *(u8), servlen : usize, flags : i32) -> IoFuture)(
66
67
  __yo_async_getnameinfo_start(addr, addrlen, host, hostlen, service, servlen, flags)
67
68
  );
68
69
  // Free an addrinfo result list returned by getaddrinfo.
package/std/sys/errors.yo CHANGED
@@ -1,13 +1,13 @@
1
- //! `IOError` type — comprehensive I/O error type with errno-to-error mapping.
1
+ //! `IoError` type — comprehensive I/O error type with errno-to-error mapping.
2
2
  { String } :: import("../string");
3
3
  { ToString } :: import("../fmt");
4
4
  { Error, Exception } :: import("../error");
5
5
  { ENOENT, EPERM, EACCES, EEXIST, ENOTDIR, EISDIR, ENOTEMPTY, EPIPE, EAGAIN, EWOULDBLOCK, EINVAL, EINTR, EMFILE, ENFILE, EFBIG, ENOSPC, EROFS, EXDEV, EMLINK, ENAMETOOLONG, ENOTSUP, EOPNOTSUPP, ETIMEDOUT, EBUSY, ECONNREFUSED, ECONNRESET, ECONNABORTED, ENOTCONN, EADDRINUSE, EADDRNOTAVAIL, ENETUNREACH, EHOSTUNREACH, ENETDOWN, EISCONN, EBADF, EIO } :: import("../libc/errno");
6
6
  // ============================================================================
7
- // IOError - I/O error type
7
+ // IoError - I/O error type
8
8
  // ============================================================================
9
9
  /// Comprehensive I/O error type with errno-to-error mapping.
10
- IOError :: enum(
10
+ IoError :: enum(
11
11
  /// File or directory not found (ENOENT).
12
12
  NotFound,
13
13
  /// Permission denied (EACCES, EPERM).
@@ -51,7 +51,7 @@ IOError :: enum(
51
51
  /// Bad file descriptor (EBADF).
52
52
  BadFileDescriptor,
53
53
  /// Generic I/O error (EIO).
54
- IOError,
54
+ IoError,
55
55
  /// Connection refused (ECONNREFUSED).
56
56
  ConnectionRefused,
57
57
  /// Connection reset by peer (ECONNRESET).
@@ -76,7 +76,7 @@ IOError :: enum(
76
76
  Other(code : i32)
77
77
  );
78
78
  impl(
79
- IOError,
79
+ IoError,
80
80
  from_errno : (fn(errno : i32) -> Self)(
81
81
  cond(
82
82
  (errno == i32(ENOENT)) =>.NotFound,
@@ -100,7 +100,7 @@ impl(
100
100
  (errno == i32(ETIMEDOUT)) =>.TimedOut,
101
101
  (errno == i32(EBUSY)) =>.Busy,
102
102
  (errno == i32(EBADF)) =>.BadFileDescriptor,
103
- (errno == i32(EIO)) =>.IOError,
103
+ (errno == i32(EIO)) =>.IoError,
104
104
  (errno == i32(ECONNREFUSED)) =>.ConnectionRefused,
105
105
  (errno == i32(ECONNRESET)) =>.ConnectionReset,
106
106
  (errno == i32(ECONNABORTED)) =>.ConnectionAborted,
@@ -122,7 +122,7 @@ impl(
122
122
  )
123
123
  );
124
124
  impl(
125
- IOError,
125
+ IoError,
126
126
  ToString(
127
127
  to_string : (
128
128
  self -> {
@@ -149,7 +149,7 @@ impl(
149
149
  .TimedOut => String.from("operation timed out"),
150
150
  .Busy => String.from("resource busy"),
151
151
  .BadFileDescriptor => String.from("bad file descriptor"),
152
- .IOError => String.from("I/O error"),
152
+ .IoError => String.from("I/O error"),
153
153
  .ConnectionRefused => String.from("connection refused"),
154
154
  .ConnectionReset => String.from("connection reset by peer"),
155
155
  .ConnectionAborted => String.from("connection aborted"),
@@ -167,9 +167,9 @@ impl(
167
167
  )
168
168
  )
169
169
  );
170
- impl(IOError, Error());
170
+ impl(IoError, Error());
171
171
  impl(
172
- IOError,
172
+ IoError,
173
173
  // Check a raw result code, throwing on error via Exception effect.
174
174
  check : (fn(result : i32, exn : Exception) -> i32)(
175
175
  cond(
@@ -178,4 +178,4 @@ impl(
178
178
  )
179
179
  )
180
180
  );
181
- export(IOError);
181
+ export(IoError);
package/std/sys/events.yo CHANGED
@@ -1,4 +1,5 @@
1
1
  //! TTY, Poll, and FS Event constants.
2
+ pragma(Pragma.AllowUnsafe);
2
3
  { __yo_fs_event_init, __yo_fs_event_start, __yo_fs_event_stop, __yo_fs_event_close, __yo_poll_init, __yo_poll_start, __yo_poll_stop, __yo_poll_close } :: import("./externs.yo");
3
4
  // ============================================================================
4
5
  // TTY Mode Constants (libuv uv_tty_mode_t equivalent)
@@ -1,7 +1,8 @@
1
1
  //! Extern C runtime function declarations.
2
2
  //!
3
3
  //! All low-level extern functions for async I/O operations.
4
- { IOFuture } :: import("./future.yo");
4
+ pragma(Pragma.AllowUnsafe);
5
+ { IoFuture } :: import("./future.yo");
5
6
  // ============================================================================
6
7
  // Extern C runtime functions
7
8
  // ============================================================================
@@ -10,23 +11,23 @@ extern(
10
11
  // ========================================================================
11
12
  // File Operations
12
13
  // ========================================================================
13
- __yo_async_read_start : (fn(fd : i32, buffer : *(u8), size : u32, offset : u64) -> IOFuture),
14
- __yo_async_write_start : (fn(fd : i32, buffer : *(u8), size : u32, offset : u64) -> IOFuture),
15
- __yo_async_openat_start : (fn(dirfd : i32, path : *(u8), flags : i32, mode : i32) -> IOFuture),
16
- __yo_async_close_start : (fn(fd : i32) -> IOFuture),
17
- __yo_async_statx_start : (fn(dirfd : i32, path : *(u8), flags : i32, mask : u32, statxbuf : *(u8)) -> IOFuture),
18
- __yo_async_mkdirat_start : (fn(dirfd : i32, path : *(u8), mode : i32) -> IOFuture),
19
- __yo_async_unlinkat_start : (fn(dirfd : i32, path : *(u8), flags : i32) -> IOFuture),
20
- __yo_async_renameat_start : (fn(olddirfd : i32, oldpath : *(u8), newdirfd : i32, newpath : *(u8)) -> IOFuture),
21
- __yo_async_symlinkat_start : (fn(target : *(u8), newdirfd : i32, linkpath : *(u8)) -> IOFuture),
22
- __yo_async_linkat_start : (fn(olddirfd : i32, oldpath : *(u8), newdirfd : i32, newpath : *(u8), flags : i32) -> IOFuture),
23
- __yo_async_fsync_start : (fn(fd : i32) -> IOFuture),
24
- __yo_async_fdatasync_start : (fn(fd : i32) -> IOFuture),
25
- __yo_async_ftruncate_start : (fn(fd : i32, length : i64) -> IOFuture),
14
+ __yo_async_read_start : (fn(fd : i32, buffer : *(u8), size : u32, offset : u64) -> IoFuture),
15
+ __yo_async_write_start : (fn(fd : i32, buffer : *(u8), size : u32, offset : u64) -> IoFuture),
16
+ __yo_async_openat_start : (fn(dirfd : i32, path : *(u8), flags : i32, mode : i32) -> IoFuture),
17
+ __yo_async_close_start : (fn(fd : i32) -> IoFuture),
18
+ __yo_async_statx_start : (fn(dirfd : i32, path : *(u8), flags : i32, mask : u32, statxbuf : *(u8)) -> IoFuture),
19
+ __yo_async_mkdirat_start : (fn(dirfd : i32, path : *(u8), mode : i32) -> IoFuture),
20
+ __yo_async_unlinkat_start : (fn(dirfd : i32, path : *(u8), flags : i32) -> IoFuture),
21
+ __yo_async_renameat_start : (fn(olddirfd : i32, oldpath : *(u8), newdirfd : i32, newpath : *(u8)) -> IoFuture),
22
+ __yo_async_symlinkat_start : (fn(target : *(u8), newdirfd : i32, linkpath : *(u8)) -> IoFuture),
23
+ __yo_async_linkat_start : (fn(olddirfd : i32, oldpath : *(u8), newdirfd : i32, newpath : *(u8), flags : i32) -> IoFuture),
24
+ __yo_async_fsync_start : (fn(fd : i32) -> IoFuture),
25
+ __yo_async_fdatasync_start : (fn(fd : i32) -> IoFuture),
26
+ __yo_async_ftruncate_start : (fn(fd : i32, length : i64) -> IoFuture),
26
27
  // ========================================================================
27
28
  // Directory Listing (for fs.readdir)
28
29
  // ========================================================================
29
- __yo_async_getdents_start : (fn(fd : i32, buf : *(u8), buf_size : u32) -> IOFuture),
30
+ __yo_async_getdents_start : (fn(fd : i32, buf : *(u8), buf_size : u32) -> IoFuture),
30
31
  __yo_dirent_size : (fn() -> usize),
31
32
  __yo_dirent_reclen : (fn(entry : *(u8)) -> u16),
32
33
  __yo_dirent_type : (fn(entry : *(u8)) -> u8),
@@ -41,18 +42,18 @@ extern(
41
42
  // ========================================================================
42
43
  // Socket Operations (for tcp, udp, unix sockets)
43
44
  // ========================================================================
44
- __yo_async_socket_start : (fn(domain : i32, sock_type : i32, protocol : i32) -> IOFuture),
45
- __yo_async_bind_start : (fn(sockfd : i32, addr : *(u8), addrlen : u32) -> IOFuture),
46
- __yo_async_listen_start : (fn(sockfd : i32, backlog : i32) -> IOFuture),
47
- __yo_async_accept_start : (fn(sockfd : i32, addr : *(u8), addrlen : *(u32)) -> IOFuture),
48
- __yo_async_connect_start : (fn(sockfd : i32, addr : *(u8), addrlen : u32) -> IOFuture),
49
- __yo_async_send_start : (fn(sockfd : i32, buf : *(u8), len : usize, flags : i32) -> IOFuture),
50
- __yo_async_recv_start : (fn(sockfd : i32, buf : *(u8), len : usize, flags : i32) -> IOFuture),
51
- __yo_async_sendto_start : (fn(sockfd : i32, buf : *(u8), len : usize, flags : i32, dest_addr : *(u8), addrlen : u32) -> IOFuture),
52
- __yo_async_recvfrom_start : (fn(sockfd : i32, buf : *(u8), len : usize, flags : i32, src_addr : *(u8), addrlen : *(u32)) -> IOFuture),
53
- __yo_async_shutdown_start : (fn(sockfd : i32, how : i32) -> IOFuture),
54
- __yo_async_setsockopt_start : (fn(sockfd : i32, level : i32, optname : i32, optval : *(u8), optlen : u32) -> IOFuture),
55
- __yo_async_getsockopt_start : (fn(sockfd : i32, level : i32, optname : i32, optval : *(u8), optlen : *(u32)) -> IOFuture),
45
+ __yo_async_socket_start : (fn(domain : i32, sock_type : i32, protocol : i32) -> IoFuture),
46
+ __yo_async_bind_start : (fn(sockfd : i32, addr : *(u8), addrlen : u32) -> IoFuture),
47
+ __yo_async_listen_start : (fn(sockfd : i32, backlog : i32) -> IoFuture),
48
+ __yo_async_accept_start : (fn(sockfd : i32, addr : *(u8), addrlen : *(u32)) -> IoFuture),
49
+ __yo_async_connect_start : (fn(sockfd : i32, addr : *(u8), addrlen : u32) -> IoFuture),
50
+ __yo_async_send_start : (fn(sockfd : i32, buf : *(u8), len : usize, flags : i32) -> IoFuture),
51
+ __yo_async_recv_start : (fn(sockfd : i32, buf : *(u8), len : usize, flags : i32) -> IoFuture),
52
+ __yo_async_sendto_start : (fn(sockfd : i32, buf : *(u8), len : usize, flags : i32, dest_addr : *(u8), addrlen : u32) -> IoFuture),
53
+ __yo_async_recvfrom_start : (fn(sockfd : i32, buf : *(u8), len : usize, flags : i32, src_addr : *(u8), addrlen : *(u32)) -> IoFuture),
54
+ __yo_async_shutdown_start : (fn(sockfd : i32, how : i32) -> IoFuture),
55
+ __yo_async_setsockopt_start : (fn(sockfd : i32, level : i32, optname : i32, optval : *(u8), optlen : u32) -> IoFuture),
56
+ __yo_async_getsockopt_start : (fn(sockfd : i32, level : i32, optname : i32, optval : *(u8), optlen : *(u32)) -> IoFuture),
56
57
  __yo_sync_getsockname : (fn(sockfd : i32, addr : *(u8), addrlen : *(u32)) -> i32),
57
58
  __yo_sync_getpeername : (fn(sockfd : i32, addr : *(u8), addrlen : *(u32)) -> i32),
58
59
  __yo_sync_setsockopt : (fn(sockfd : i32, level : i32, optname : i32, optval : *(u8), optlen : u32) -> i32),
@@ -68,8 +69,8 @@ extern(
68
69
  // ========================================================================
69
70
  // Process Operations
70
71
  // ========================================================================
71
- __yo_async_spawn_start : (fn(file : *(u8), argv : *(?*(u8)), envp : ?*(?*(u8)), stdin_fd : i32, stdout_fd : i32, stderr_fd : i32) -> IOFuture),
72
- __yo_async_waitpid_start : (fn(pid : i32, options : i32) -> IOFuture),
72
+ __yo_async_spawn_start : (fn(file : *(u8), argv : *(?*(u8)), envp : ?*(?*(u8)), stdin_fd : i32, stdout_fd : i32, stderr_fd : i32) -> IoFuture),
73
+ __yo_async_waitpid_start : (fn(pid : i32, options : i32) -> IoFuture),
73
74
  __yo_process_exit_status : (fn(status : i32) -> i32),
74
75
  __yo_process_term_signal : (fn(status : i32) -> i32),
75
76
  // ========================================================================
@@ -128,7 +129,7 @@ extern(
128
129
  // ========================================================================
129
130
  // Timer Operations
130
131
  // ========================================================================
131
- __yo_async_sleep_start : (fn(milliseconds : u64) -> IOFuture),
132
+ __yo_async_sleep_start : (fn(milliseconds : u64) -> IoFuture),
132
133
  // ========================================================================
133
134
  // File Extra Operations (async only: sleep remains async)
134
135
  // ========================================================================
@@ -143,15 +144,15 @@ extern(
143
144
  // ========================================================================
144
145
  // Directory Scanning
145
146
  // ========================================================================
146
- __yo_async_scandir_start : (fn(dirfd : i32, path : *(u8)) -> IOFuture),
147
- __yo_async_opendir_start : (fn(path : *(u8)) -> IOFuture),
148
- __yo_async_readdir_start : (fn(dir : *(u8), entries : *(u8), max_entries : usize) -> IOFuture),
149
- __yo_async_closedir_start : (fn(dir : *(u8)) -> IOFuture),
147
+ __yo_async_scandir_start : (fn(dirfd : i32, path : *(u8)) -> IoFuture),
148
+ __yo_async_opendir_start : (fn(path : *(u8)) -> IoFuture),
149
+ __yo_async_readdir_start : (fn(dir : *(u8), entries : *(u8), max_entries : usize) -> IoFuture),
150
+ __yo_async_closedir_start : (fn(dir : *(u8)) -> IoFuture),
150
151
  // ========================================================================
151
152
  // DNS Operations
152
153
  // ========================================================================
153
- __yo_async_getaddrinfo_start : (fn(node : *(u8), service : ?*(u8), hints : ?*(u8), result : *(?*(u8))) -> IOFuture),
154
- __yo_async_getnameinfo_start : (fn(addr : *(u8), addrlen : u32, host : *(u8), hostlen : usize, service : *(u8), servlen : usize, flags : i32) -> IOFuture),
154
+ __yo_async_getaddrinfo_start : (fn(node : *(u8), service : ?*(u8), hints : ?*(u8), result : *(?*(u8))) -> IoFuture),
155
+ __yo_async_getnameinfo_start : (fn(addr : *(u8), addrlen : u32, host : *(u8), hostlen : usize, service : *(u8), servlen : usize, flags : i32) -> IoFuture),
155
156
  __yo_freeaddrinfo : (fn(res : *(u8)) -> unit),
156
157
  __yo_addrinfo_size : (fn() -> usize),
157
158
  __yo_addrinfo_flags : (fn(ai : *(u8)) -> i32),
@@ -191,7 +192,7 @@ extern(
191
192
  __yo_poll_stop : (fn(handle : *(u8)) -> i32),
192
193
  __yo_poll_close : (fn(handle : *(u8)) -> unit),
193
194
  // ========================================================================
194
- // Synchronous Operations (no IOFuture overhead)
195
+ // Synchronous Operations (no IoFuture overhead)
195
196
  // ========================================================================
196
197
  __yo_sync_pipe : (fn(pipefd : *(i32)) -> i32),
197
198
  __yo_sync_dup : (fn(oldfd : i32) -> i32),
package/std/sys/file.yo CHANGED
@@ -2,64 +2,65 @@
2
2
  //!
3
3
  //! Provides low-level file I/O wrappers around the C runtime externs.
4
4
  //!
5
- //! Async operations return `IOFuture` which resolves to:
5
+ //! Async operations return `IoFuture` which resolves to:
6
6
  //! - Positive value: success (fd for open, bytes for read/write, 0 for others)
7
7
  //! - Negative value: -errno on failure
8
- // Use IOError.from_result() to convert results to Result(i32, IOError).
8
+ // Use IoError.from_result() to convert results to Result(i32, IoError).
9
9
  //
10
10
  // Example:
11
- // IO :: import "std/io";
11
+ // Io :: import "std/io";
12
12
  //
13
13
  // task := async {
14
14
  // (path : *(u8)) = "test.txt";
15
- // fd_result := await IO.openat(IO.AT_FDCWD, path, IO.O_RDONLY, i32(0));
16
- // fd := IOError.from_result(fd_result).unwrap();
17
- // close_result := await IO.close(fd);
15
+ // fd_result := await Io.openat(Io.AT_FDCWD, path, Io.O_RDONLY, i32(0));
16
+ // fd := IoError.from_result(fd_result).unwrap();
17
+ // close_result := await Io.close(fd);
18
18
  // };
19
- { IOFuture } :: import("./future.yo");
19
+ pragma(Pragma.AllowUnsafe);
20
+ { IoFuture } :: import("./future.yo");
20
21
  { __yo_async_read_start, __yo_async_write_start, __yo_async_openat_start, __yo_async_close_start, __yo_async_statx_start, __yo_async_fsync_start, __yo_async_fdatasync_start, __yo_async_ftruncate_start, __yo_file_open, __yo_file_close, __yo_file_size } :: import("./externs.yo");
21
22
  // ============================================================================
22
- // Async File Operations (return IOFuture, use with await)
23
+ // Async File Operations (return IoFuture, use with await)
23
24
  // ============================================================================
24
25
  // Open a file relative to dirfd. Use AT_FDCWD for current directory.
25
26
  // Returns fd on success, -errno on failure.
26
- openat :: (fn(dirfd : i32, path : *(u8), flags : i32, mode : i32) -> IOFuture)(
27
+ openat :: (fn(dirfd : i32, path : *(u8), flags : i32, mode : i32) -> IoFuture)(
27
28
  __yo_async_openat_start(dirfd, path, flags, mode)
28
29
  );
29
30
  // Close a file descriptor.
30
31
  // Returns 0 on success, -errno on failure.
31
- close :: (fn(fd : i32) -> IOFuture)(
32
+ close :: (fn(fd : i32) -> IoFuture)(
32
33
  __yo_async_close_start(fd)
33
34
  );
34
35
  // Read from fd into buffer at the given offset.
35
36
  // Returns number of bytes read on success, -errno on failure.
36
- read :: (fn(fd : i32, buffer : *(u8), size : u32, offset : u64) -> IOFuture)(
37
+ read :: (fn(fd : i32, buffer : *(u8), size : u32, offset : u64) -> IoFuture)(
37
38
  __yo_async_read_start(fd, buffer, size, offset)
38
39
  );
39
40
  // Write buffer to fd at the given offset.
40
41
  // Returns number of bytes written on success, -errno on failure.
41
- write :: (fn(fd : i32, buffer : *(u8), size : u32, offset : u64) -> IOFuture)(
42
+ write :: (fn(fd : i32, buffer : *(u8), size : u32, offset : u64) -> IoFuture)(
42
43
  __yo_async_write_start(fd, buffer, size, offset)
43
44
  );
44
45
  // Get file metadata via statx. Results are written to statxbuf.
45
46
  // Use Statx object to wrap and read the buffer.
46
47
  // Returns 0 on success, -errno on failure.
47
- statx :: (fn(dirfd : i32, path : *(u8), flags : i32, mask : u32, statxbuf : *(u8)) -> IOFuture)(
48
+ statx :: (fn(dirfd : i32, path : *(u8), flags : i32, mask : u32, statxbuf : *(u8)) -> IoFuture)(
48
49
  __yo_async_statx_start(dirfd, path, flags, mask, statxbuf)
49
50
  );
50
51
  // Sync file data and metadata to disk.
51
52
  // Returns 0 on success, -errno on failure.
52
- fsync :: (fn(fd : i32) -> IOFuture)(
53
+ fsync :: (fn(fd : i32) -> IoFuture)(
53
54
  __yo_async_fsync_start(fd)
54
55
  );
55
56
  // Sync file data (but not metadata) to disk.
56
57
  // Returns 0 on success, -errno on failure.
57
- fdatasync :: (fn(fd : i32) -> IOFuture)(
58
+ fdatasync :: (fn(fd : i32) -> IoFuture)(
58
59
  __yo_async_fdatasync_start(fd)
59
60
  );
60
61
  // Truncate file to the given length.
61
62
  // Returns 0 on success, -errno on failure.
62
- ftruncate :: (fn(fd : i32, length : i64) -> IOFuture)(
63
+ ftruncate :: (fn(fd : i32, length : i64) -> IoFuture)(
63
64
  __yo_async_ftruncate_start(fd, length)
64
65
  );
65
66
  // ============================================================================
package/std/sys/future.yo CHANGED
@@ -1,13 +1,14 @@
1
- //! `IOFuture` type — opaque handle to a C async I/O future struct.
1
+ //! `IoFuture` type — opaque handle to a C async I/O future struct.
2
2
  // ============================================================================
3
3
  // Extern type for I/O Future
4
4
  // ============================================================================
5
+ pragma(Pragma.AllowUnsafe);
5
6
  extern(
6
7
  "Yo",
7
8
  __yo_io_future_t : Type
8
9
  );
9
- IOFuture :: Impl(Concrete(__yo_io_future_t), Future(i32));
10
+ IoFuture :: Impl(Concrete(__yo_io_future_t), Future(i32));
10
11
  export(
11
12
  __yo_io_future_t,
12
- IOFuture
13
+ IoFuture
13
14
  );