@shd101wyy/yo 0.1.12 → 0.1.13
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.
- package/README.md +10 -1
- package/out/cjs/index.cjs +578 -572
- package/out/cjs/yo-cli.cjs +1413 -592
- package/out/esm/index.mjs +434 -428
- package/out/types/src/build-runner.d.ts +1 -1
- package/out/types/src/doc/builder.d.ts +21 -0
- package/out/types/src/doc/builder.test.d.ts +1 -0
- package/out/types/src/doc/extractor.d.ts +27 -0
- package/out/types/src/doc/extractor.test.d.ts +1 -0
- package/out/types/src/doc/model.d.ts +87 -0
- package/out/types/src/doc/render-html.d.ts +23 -0
- package/out/types/src/doc/render-html.test.d.ts +1 -0
- package/out/types/src/doc/render-json.d.ts +7 -0
- package/out/types/src/doc/render-json.test.d.ts +1 -0
- package/out/types/src/doc/render-markdown.d.ts +13 -0
- package/out/types/src/doc/render-markdown.test.d.ts +1 -0
- package/out/types/src/doc/sections.d.ts +7 -0
- package/out/types/src/doc/sections.test.d.ts +1 -0
- package/out/types/src/doc-command.d.ts +10 -0
- package/out/types/src/env.d.ts +1 -0
- package/out/types/src/evaluator/builtins/build.d.ts +17 -0
- package/out/types/src/evaluator/context.d.ts +1 -0
- package/out/types/src/expr.d.ts +2 -1
- package/out/types/src/token.d.ts +4 -0
- package/out/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -1
- package/scripts/build-site.ts +461 -0
- package/std/alg/hash.yo +12 -24
- package/std/allocator.yo +21 -29
- package/std/async.yo +4 -2
- package/std/build.yo +188 -42
- package/std/cli/arg_parser.yo +37 -1
- package/std/collections/array_list.yo +8 -20
- package/std/collections/btree_map.yo +15 -20
- package/std/collections/deque.yo +13 -15
- package/std/collections/hash_map.yo +15 -54
- package/std/collections/hash_set.yo +14 -50
- package/std/collections/linked_list.yo +6 -23
- package/std/collections/priority_queue.yo +15 -17
- package/std/crypto/md5.yo +10 -9
- package/std/crypto/random.yo +14 -12
- package/std/crypto/sha256.yo +9 -8
- package/std/encoding/base64.yo +13 -15
- package/std/encoding/hex.yo +14 -10
- package/std/encoding/html.yo +14 -11
- package/std/encoding/html_char_utils.yo +14 -11
- package/std/encoding/html_entities.yo +7 -8
- package/std/encoding/json.yo +36 -19
- package/std/encoding/punycode.yo +21 -18
- package/std/encoding/toml.yo +23 -9
- package/std/encoding/utf16.yo +16 -9
- package/std/error.yo +10 -23
- package/std/fmt/display.yo +15 -17
- package/std/fmt/index.yo +6 -27
- package/std/fmt/to_string.yo +4 -10
- package/std/fmt/writer.yo +33 -34
- package/std/fs/dir.yo +37 -30
- package/std/fs/file.yo +77 -75
- package/std/fs/metadata.yo +25 -25
- package/std/fs/temp.yo +21 -27
- package/std/fs/types.yo +20 -23
- package/std/fs/walker.yo +26 -31
- package/std/gc.yo +5 -0
- package/std/glob/index.yo +3 -0
- package/std/http/client.yo +25 -11
- package/std/http/http.yo +20 -0
- package/std/http/index.yo +1 -0
- package/std/io/reader.yo +4 -8
- package/std/io/writer.yo +4 -7
- package/std/libc/assert.yo +2 -2
- package/std/libc/ctype.yo +1 -2
- package/std/libc/dirent.yo +1 -2
- package/std/libc/errno.yo +1 -2
- package/std/libc/fcntl.yo +2 -2
- package/std/libc/float.yo +1 -2
- package/std/libc/limits.yo +1 -2
- package/std/libc/math.yo +2 -0
- package/std/libc/signal.yo +1 -2
- package/std/libc/stdatomic.yo +1 -2
- package/std/libc/stdint.yo +4 -3
- package/std/libc/stdio.yo +2 -0
- package/std/libc/stdlib.yo +2 -0
- package/std/libc/string.yo +2 -0
- package/std/libc/sys/stat.yo +1 -2
- package/std/libc/time.yo +2 -2
- package/std/libc/unistd.yo +2 -0
- package/std/libc/wctype.yo +1 -2
- package/std/libc/windows.yo +2 -2
- package/std/log/index.yo +11 -26
- package/std/net/addr.yo +18 -11
- package/std/net/dns.yo +3 -2
- package/std/net/errors.yo +16 -2
- package/std/net/tcp.yo +25 -22
- package/std/net/udp.yo +14 -12
- package/std/os/env.yo +23 -18
- package/std/os/signal.yo +31 -19
- package/std/path.yo +23 -74
- package/std/prelude.yo +284 -113
- package/std/process.yo +23 -37
- package/std/regex/compiler.yo +3 -5
- package/std/regex/flags.yo +11 -11
- package/std/regex/index.yo +2 -13
- package/std/regex/match.yo +3 -5
- package/std/regex/node.yo +6 -6
- package/std/regex/parser.yo +2 -4
- package/std/regex/unicode.yo +5 -5
- package/std/regex/vm.yo +5 -5
- package/std/string/index.yo +2 -1
- package/std/string/rune.yo +25 -1
- package/std/string/string.yo +31 -19
- package/std/string/unicode.yo +14 -15
- package/std/sync/channel.yo +18 -28
- package/std/sync/cond.yo +4 -0
- package/std/sync/mutex.yo +4 -1
- package/std/sync/once.yo +17 -19
- package/std/sync/rwlock.yo +19 -22
- package/std/sync/waitgroup.yo +21 -23
- package/std/sys/advise.yo +4 -4
- package/std/sys/bufio/buf_reader.yo +19 -16
- package/std/sys/bufio/buf_writer.yo +14 -11
- package/std/sys/clock.yo +4 -4
- package/std/sys/constants.yo +5 -5
- package/std/sys/copy.yo +9 -8
- package/std/sys/dir.yo +9 -8
- package/std/sys/dns.yo +8 -8
- package/std/sys/errors.yo +35 -6
- package/std/sys/events.yo +3 -3
- package/std/sys/externs.yo +3 -3
- package/std/sys/fallocate.yo +4 -4
- package/std/sys/fcntl.yo +8 -6
- package/std/sys/file.yo +7 -8
- package/std/sys/future.yo +1 -3
- package/std/sys/iov.yo +4 -4
- package/std/sys/lock.yo +7 -7
- package/std/sys/mmap.yo +7 -8
- package/std/sys/path.yo +4 -7
- package/std/sys/perm.yo +8 -8
- package/std/sys/pipe.yo +9 -8
- package/std/sys/process.yo +8 -8
- package/std/sys/seek.yo +4 -4
- package/std/sys/signal.yo +4 -4
- package/std/sys/signals.yo +4 -4
- package/std/sys/socket.yo +4 -4
- package/std/sys/socketpair.yo +4 -4
- package/std/sys/sockinfo.yo +4 -4
- package/std/sys/statfs.yo +8 -8
- package/std/sys/statx.yo +4 -4
- package/std/sys/sysinfo.yo +4 -4
- package/std/sys/tcp.yo +8 -8
- package/std/sys/temp.yo +9 -8
- package/std/sys/time.yo +8 -8
- package/std/sys/timer.yo +7 -8
- package/std/sys/tty.yo +13 -10
- package/std/sys/udp.yo +8 -8
- package/std/sys/umask.yo +4 -4
- package/std/sys/unix.yo +5 -5
- package/std/testing/bench.yo +21 -10
- package/std/thread.yo +18 -9
- package/std/time/datetime.yo +12 -14
- package/std/time/duration.yo +12 -14
- package/std/time/instant.yo +13 -16
- package/std/time/sleep.yo +9 -8
- package/std/url/index.yo +3 -19
- package/std/worker.yo +10 -18
package/std/sync/cond.yo
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
//! Condition variable for thread synchronization.
|
|
2
|
+
|
|
1
3
|
{ __YO_THREAD_SYNC_TYPE, mutex_t, Mutex } :: import "./mutex";
|
|
2
4
|
|
|
3
5
|
extern "Yo",
|
|
@@ -9,6 +11,7 @@ extern "Yo",
|
|
|
9
11
|
__yo_cond_destroy : (fn(cv : *(__YO_COND_TYPE)) -> unit)
|
|
10
12
|
;
|
|
11
13
|
|
|
14
|
+
/// Low-level condition variable (manual lifetime via `destroy`).
|
|
12
15
|
cond_t :: newtype(
|
|
13
16
|
cv : __YO_COND_TYPE
|
|
14
17
|
);
|
|
@@ -34,6 +37,7 @@ impl(cond_t,
|
|
|
34
37
|
})
|
|
35
38
|
);
|
|
36
39
|
|
|
40
|
+
/// Reference-counted condition variable with automatic cleanup via `Dispose`.
|
|
37
41
|
Cond :: object(
|
|
38
42
|
cv : __YO_COND_TYPE
|
|
39
43
|
);
|
package/std/sync/mutex.yo
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
//! Mutual exclusion lock primitives.
|
|
2
|
+
|
|
1
3
|
extern "Yo",
|
|
2
4
|
__YO_THREAD_SYNC_TYPE : Type,
|
|
3
5
|
__yo_mutex_create : (fn() -> __YO_THREAD_SYNC_TYPE),
|
|
@@ -6,6 +8,7 @@ extern "Yo",
|
|
|
6
8
|
__yo_mutex_destroy : (fn(mutex : *(__YO_THREAD_SYNC_TYPE)) -> unit)
|
|
7
9
|
;
|
|
8
10
|
|
|
11
|
+
/// Low-level mutex (manual lifetime via `destroy`).
|
|
9
12
|
mutex_t :: newtype(
|
|
10
13
|
mutex : __YO_THREAD_SYNC_TYPE
|
|
11
14
|
);
|
|
@@ -27,7 +30,7 @@ impl(mutex_t,
|
|
|
27
30
|
})
|
|
28
31
|
);
|
|
29
32
|
|
|
30
|
-
|
|
33
|
+
/// Reference-counted mutex with automatic cleanup via `Dispose`.
|
|
31
34
|
Mutex :: object(
|
|
32
35
|
mutex : __YO_THREAD_SYNC_TYPE
|
|
33
36
|
);
|
package/std/sync/once.yo
CHANGED
|
@@ -1,25 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
//
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
1
|
+
//! One-time initialization primitive.
|
|
2
|
+
//!
|
|
3
|
+
//! # Example
|
|
4
|
+
//!
|
|
5
|
+
//! ```rust
|
|
6
|
+
//! { Once } :: import "std/sync/once";
|
|
7
|
+
//!
|
|
8
|
+
//! init := Once.new();
|
|
9
|
+
//! // Only the first call executes the function
|
|
10
|
+
//! init.call(() => {
|
|
11
|
+
//! println("initialized!");
|
|
12
|
+
//! });
|
|
13
|
+
//! init.call(() => {
|
|
14
|
+
//! println("this will NOT run");
|
|
15
|
+
//! });
|
|
16
|
+
//! ```
|
|
16
17
|
|
|
17
18
|
{ Mutex } :: import "./mutex";
|
|
18
19
|
|
|
19
|
-
|
|
20
|
-
// Once
|
|
21
|
-
// ============================================================================
|
|
22
|
-
|
|
20
|
+
/// Execute a function exactly once, thread-safely.
|
|
23
21
|
Once :: object(
|
|
24
22
|
_done : bool,
|
|
25
23
|
_mutex : Mutex
|
package/std/sync/rwlock.yo
CHANGED
|
@@ -1,29 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
//
|
|
10
|
-
|
|
11
|
-
//
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
//
|
|
15
|
-
|
|
16
|
-
//
|
|
17
|
-
|
|
18
|
-
|
|
1
|
+
//! Reader-writer lock allowing multiple concurrent readers or one exclusive writer.
|
|
2
|
+
//!
|
|
3
|
+
//! # Example
|
|
4
|
+
//!
|
|
5
|
+
//! ```rust
|
|
6
|
+
//! { RwLock } :: import "std/sync/rwlock";
|
|
7
|
+
//!
|
|
8
|
+
//! lock := RwLock.new();
|
|
9
|
+
//! // Multiple readers can hold the lock simultaneously
|
|
10
|
+
//! lock.read_lock();
|
|
11
|
+
//! // ... read shared data ...
|
|
12
|
+
//! lock.read_unlock();
|
|
13
|
+
//!
|
|
14
|
+
//! // Only one writer at a time, blocks all readers
|
|
15
|
+
//! lock.write_lock();
|
|
16
|
+
//! // ... write shared data ...
|
|
17
|
+
//! lock.write_unlock();
|
|
18
|
+
//! ```
|
|
19
19
|
|
|
20
20
|
{ Mutex } :: import "./mutex";
|
|
21
21
|
{ Cond } :: import "./cond";
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
// RwLock
|
|
25
|
-
// ============================================================================
|
|
26
|
-
|
|
23
|
+
/// Reader-writer lock built on `Mutex` and `Cond`.
|
|
27
24
|
RwLock :: object(
|
|
28
25
|
_readers : i32,
|
|
29
26
|
_writer : bool,
|
package/std/sync/waitgroup.yo
CHANGED
|
@@ -1,30 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
//
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
1
|
+
//! Wait for a group of tasks to complete, similar to Go's `sync.WaitGroup`.
|
|
2
|
+
//!
|
|
3
|
+
//! # Example
|
|
4
|
+
//!
|
|
5
|
+
//! ```rust
|
|
6
|
+
//! { WaitGroup } :: import "std/sync/waitgroup";
|
|
7
|
+
//! { Thread } :: import "std/thread";
|
|
8
|
+
//!
|
|
9
|
+
//! wg := WaitGroup.new();
|
|
10
|
+
//! wg.add(i32(3));
|
|
11
|
+
//! i := i32(0);
|
|
12
|
+
//! while runtime((i < i32(3))), {
|
|
13
|
+
//! t := Thread.spawn(() => {
|
|
14
|
+
//! // ... do work ...
|
|
15
|
+
//! wg.done();
|
|
16
|
+
//! });
|
|
17
|
+
//! i = (i + i32(1));
|
|
18
|
+
//! };
|
|
19
|
+
//! wg.wait(); // blocks until all 3 tasks call done()
|
|
20
|
+
//! ```
|
|
20
21
|
|
|
21
22
|
{ Mutex } :: import "./mutex";
|
|
22
23
|
{ Cond } :: import "./cond";
|
|
23
24
|
|
|
24
|
-
|
|
25
|
-
// WaitGroup
|
|
26
|
-
// ============================================================================
|
|
27
|
-
|
|
25
|
+
/// Synchronization primitive that blocks until a counter reaches zero.
|
|
28
26
|
WaitGroup :: object(
|
|
29
27
|
_count : i32,
|
|
30
28
|
_mutex : Mutex,
|
package/std/sys/advise.yo
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
//! Kernel advisory hints.
|
|
2
|
+
//!
|
|
3
|
+
//! Advisory wrappers for file and memory access pattern hints.
|
|
4
|
+
//! Returns 0 on success, -errno / negative platform error on failure.
|
|
5
5
|
|
|
6
6
|
{
|
|
7
7
|
__yo_sync_fadvise,
|
|
@@ -1,19 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
1
|
+
//! Buffered reader for file descriptors.
|
|
2
|
+
//!
|
|
3
|
+
//! Wraps a file descriptor with an internal buffer for efficient reads.
|
|
4
|
+
//! Reduces the number of system calls by reading data in larger chunks.
|
|
5
|
+
//!
|
|
6
|
+
//! # Example
|
|
7
|
+
//!
|
|
8
|
+
//! ```rust
|
|
9
|
+
//! { BufReader } :: import "std/sys/bufio/buf_reader";
|
|
10
|
+
//! IO_file :: import "std/sys/file";
|
|
11
|
+
//!
|
|
12
|
+
//! reader := BufReader.new(fd);
|
|
13
|
+
//! line := io.await(reader.read_line(using(io)));
|
|
14
|
+
//! match(line,
|
|
15
|
+
//! .Ok(.Some(s)) => println(s),
|
|
16
|
+
//! .Ok(.None) => println("EOF"),
|
|
17
|
+
//! .Err(e) => println(e.to_string())
|
|
18
|
+
//! );
|
|
19
|
+
//! ```
|
|
17
20
|
|
|
18
21
|
{ ArrayList } :: import "../../collections/array_list";
|
|
19
22
|
open import "../../string";
|
|
@@ -1,14 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
//! Buffered writer for file descriptors.
|
|
2
|
+
//!
|
|
3
|
+
//! Wraps a file descriptor with an internal buffer for efficient writes.
|
|
4
|
+
//! Reduces the number of system calls by batching small writes together.
|
|
5
|
+
//!
|
|
6
|
+
//! # Example
|
|
7
|
+
//!
|
|
8
|
+
//! ```rust
|
|
9
|
+
//! { BufWriter } :: import "std/sys/bufio/buf_writer";
|
|
10
|
+
//!
|
|
11
|
+
//! writer := BufWriter.new(fd);
|
|
12
|
+
//! io.await(writer.write_string(`hello\n`, using(io)));
|
|
13
|
+
//! io.await(writer.flush(using(io)));
|
|
14
|
+
//! ```
|
|
12
15
|
|
|
13
16
|
{ ArrayList } :: import "../../collections/array_list";
|
|
14
17
|
open import "../../string";
|
package/std/sys/clock.yo
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
//! High-resolution clock queries.
|
|
2
|
+
//!
|
|
3
|
+
//! Provides a synchronous wrapper for reading wall-clock and monotonic time.
|
|
4
|
+
//! Returns 0 on success, -errno / negative platform error on failure.
|
|
5
5
|
|
|
6
6
|
{ platform, Platform } :: import "../process";
|
|
7
7
|
{ __yo_sync_clock_gettime } :: import "./externs.yo";
|
package/std/sys/constants.yo
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
//! File system constants.
|
|
2
|
+
//!
|
|
3
|
+
//! File mode bits, permission bits, `AT_*` flags, open flags,
|
|
4
|
+
//! access mode constants, copyfile flags, directory entry types,
|
|
5
|
+
//! and default permission modes.
|
|
6
6
|
|
|
7
7
|
{ platform, Platform } :: import "../process";
|
|
8
8
|
|
package/std/sys/copy.yo
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
//! File copy operations.
|
|
2
|
+
//!
|
|
3
|
+
//! Synchronous wrappers for `copyfile`/`sendfile`.
|
|
4
|
+
//! These are inherently synchronous on all platforms.
|
|
5
|
+
//!
|
|
6
|
+
//! ## Return values
|
|
7
|
+
//!
|
|
8
|
+
//! - `copyfile`: 0 on success, -errno on failure
|
|
9
|
+
//! - `sendfile`: bytes transferred on success, -errno on failure
|
|
9
10
|
|
|
10
11
|
{ __yo_sync_copyfile, __yo_sync_sendfile } :: import "./externs.yo";
|
|
11
12
|
|
package/std/sys/dir.yo
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
//! Directory operations.
|
|
2
|
+
//!
|
|
3
|
+
//! Provides low-level directory manipulation wrappers around C runtime externs.
|
|
4
|
+
//!
|
|
5
|
+
//! Async operations (`mkdir`, `unlink`, `rename`, `symlink`, `link`, `getdents`)
|
|
6
|
+
//! return `IOFuture` which resolves to:
|
|
7
|
+
//! - 0 on success (for mkdir, unlink, rename, symlink, link)
|
|
8
|
+
//! - Bytes read for getdents
|
|
9
|
+
//! - Negative value: -errno on failure
|
|
9
10
|
//
|
|
10
11
|
// Sync operations (readlink) return i32 directly:
|
|
11
12
|
// - Bytes read on success
|
package/std/sys/dns.yo
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
//! DNS resolution operations.
|
|
2
|
+
//!
|
|
3
|
+
//! Provides async DNS resolution wrapping `getaddrinfo`/`getnameinfo`, plus
|
|
4
|
+
//! accessors for iterating the linked list of `addrinfo` results.
|
|
5
|
+
//!
|
|
6
|
+
//! All async operations return `IOFuture` which resolves to:
|
|
7
|
+
//! - 0: success
|
|
8
|
+
//! - Non-zero: raw `gai_error` code (`EAI_NONAME`, `EAI_AGAIN`, etc.)
|
|
9
9
|
//
|
|
10
10
|
// Example:
|
|
11
11
|
// { GlobalAllocator } :: import "../allocator";
|
package/std/sys/errors.yo
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
//
|
|
3
|
-
// Comprehensive I/O error type with errno-to-error mapping.
|
|
1
|
+
//! `IOError` type — comprehensive I/O error type with errno-to-error mapping.
|
|
4
2
|
|
|
5
3
|
{ String } :: import "../string";
|
|
6
4
|
{ ToString } :: import "../fmt";
|
|
@@ -17,44 +15,75 @@
|
|
|
17
15
|
// IOError - I/O error type
|
|
18
16
|
// ============================================================================
|
|
19
17
|
|
|
18
|
+
/// Comprehensive I/O error type with errno-to-error mapping.
|
|
20
19
|
IOError :: enum(
|
|
21
|
-
|
|
20
|
+
/// File or directory not found (ENOENT).
|
|
22
21
|
NotFound,
|
|
22
|
+
/// Permission denied (EACCES, EPERM).
|
|
23
23
|
PermissionDenied,
|
|
24
|
+
/// File or directory already exists (EEXIST).
|
|
24
25
|
AlreadyExists,
|
|
26
|
+
/// Not a directory (ENOTDIR).
|
|
25
27
|
NotADirectory,
|
|
28
|
+
/// Is a directory (EISDIR).
|
|
26
29
|
IsADirectory,
|
|
30
|
+
/// Directory not empty (ENOTEMPTY).
|
|
27
31
|
DirectoryNotEmpty,
|
|
32
|
+
/// Broken pipe (EPIPE).
|
|
28
33
|
BrokenPipe,
|
|
34
|
+
/// Operation would block (EAGAIN, EWOULDBLOCK).
|
|
29
35
|
WouldBlock,
|
|
36
|
+
/// Invalid argument (EINVAL).
|
|
30
37
|
InvalidInput,
|
|
38
|
+
/// Interrupted system call (EINTR).
|
|
31
39
|
Interrupted,
|
|
40
|
+
/// Too many open files (EMFILE, ENFILE).
|
|
32
41
|
TooManyOpenFiles,
|
|
42
|
+
/// File too large (EFBIG).
|
|
33
43
|
FileTooLarge,
|
|
44
|
+
/// No space left on device (ENOSPC).
|
|
34
45
|
NoSpace,
|
|
46
|
+
/// Read-only filesystem (EROFS).
|
|
35
47
|
ReadOnlyFilesystem,
|
|
48
|
+
/// Cross-device link (EXDEV).
|
|
36
49
|
CrossDeviceLink,
|
|
50
|
+
/// Too many links (EMLINK).
|
|
37
51
|
TooManyLinks,
|
|
52
|
+
/// File name too long (ENAMETOOLONG).
|
|
38
53
|
NameTooLong,
|
|
54
|
+
/// Operation not supported (ENOTSUP, EOPNOTSUPP).
|
|
39
55
|
NotSupported,
|
|
56
|
+
/// Operation timed out (ETIMEDOUT).
|
|
40
57
|
TimedOut,
|
|
58
|
+
/// Resource busy (EBUSY).
|
|
41
59
|
Busy,
|
|
60
|
+
/// Bad file descriptor (EBADF).
|
|
42
61
|
BadFileDescriptor,
|
|
62
|
+
/// Generic I/O error (EIO).
|
|
43
63
|
IOError,
|
|
44
64
|
|
|
45
|
-
|
|
65
|
+
/// Connection refused (ECONNREFUSED).
|
|
46
66
|
ConnectionRefused,
|
|
67
|
+
/// Connection reset by peer (ECONNRESET).
|
|
47
68
|
ConnectionReset,
|
|
69
|
+
/// Connection aborted (ECONNABORTED).
|
|
48
70
|
ConnectionAborted,
|
|
71
|
+
/// Not connected (ENOTCONN).
|
|
49
72
|
NotConnected,
|
|
73
|
+
/// Address already in use (EADDRINUSE).
|
|
50
74
|
AddressInUse,
|
|
75
|
+
/// Address not available (EADDRNOTAVAIL).
|
|
51
76
|
AddressNotAvailable,
|
|
77
|
+
/// Network unreachable (ENETUNREACH).
|
|
52
78
|
NetworkUnreachable,
|
|
79
|
+
/// Host unreachable (EHOSTUNREACH).
|
|
53
80
|
HostUnreachable,
|
|
81
|
+
/// Network is down (ENETDOWN).
|
|
54
82
|
NetworkDown,
|
|
83
|
+
/// Already connected (EISCONN).
|
|
55
84
|
AlreadyConnected,
|
|
56
85
|
|
|
57
|
-
|
|
86
|
+
/// Other error with raw errno code.
|
|
58
87
|
Other(code: i32)
|
|
59
88
|
);
|
|
60
89
|
|
package/std/sys/events.yo
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
//! TTY, Poll, and FS Event constants.
|
|
2
2
|
|
|
3
3
|
{
|
|
4
4
|
__yo_fs_event_init, __yo_fs_event_start,
|
|
@@ -54,7 +54,7 @@ poll_init :: (fn(fd: i32) -> PollHandle)(
|
|
|
54
54
|
// Start polling for events.
|
|
55
55
|
// Returns 0 on success, -errno on failure.
|
|
56
56
|
poll_start :: (fn(handle: PollHandle, events: i32, callback: PollCallback, user_data: *(u8)) -> i32)(
|
|
57
|
-
__yo_poll_start(handle.handle, events,
|
|
57
|
+
__yo_poll_start(handle.handle, events, unsafe.cast(callback, *(u8)), user_data)
|
|
58
58
|
);
|
|
59
59
|
|
|
60
60
|
// Stop polling.
|
|
@@ -86,7 +86,7 @@ fs_event_init :: (fn() -> FsEventHandle)(
|
|
|
86
86
|
// Start watching a path.
|
|
87
87
|
// Returns 0 on success, -errno on failure.
|
|
88
88
|
fs_event_start :: (fn(handle: FsEventHandle, path: *(u8), flags: u32, callback: FsEventCallback, user_data: *(u8)) -> i32)(
|
|
89
|
-
__yo_fs_event_start(handle.handle, path, flags,
|
|
89
|
+
__yo_fs_event_start(handle.handle, path, flags, unsafe.cast(callback, *(u8)), user_data)
|
|
90
90
|
);
|
|
91
91
|
|
|
92
92
|
// Stop watching.
|
package/std/sys/externs.yo
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
//! Extern C runtime function declarations.
|
|
2
|
+
//!
|
|
3
|
+
//! All low-level extern functions for async I/O operations.
|
|
4
4
|
|
|
5
5
|
{ IOFuture } :: import "./future.yo";
|
|
6
6
|
|
package/std/sys/fallocate.yo
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
//! File space pre-allocation.
|
|
2
|
+
//!
|
|
3
|
+
//! Synchronous wrapper for `fallocate`-style allocation.
|
|
4
|
+
//! Returns 0 on success, -errno on failure.
|
|
5
5
|
|
|
6
6
|
{ __yo_sync_fallocate } :: import "./externs.yo";
|
|
7
7
|
|
package/std/sys/fcntl.yo
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
//! File descriptor control operations.
|
|
2
|
+
//!
|
|
3
|
+
//! Synchronous wrappers for file descriptor flags and close-on-exec flags.
|
|
4
|
+
//!
|
|
5
|
+
//! ## Returns
|
|
6
|
+
//!
|
|
7
|
+
//! - `getfl`/`getfd`: flags on success, -errno on failure
|
|
8
|
+
//! - `setfl`/`setfd`: 0 on success, -errno on failure
|
|
7
9
|
|
|
8
10
|
{
|
|
9
11
|
__yo_sync_fcntl_getfl,
|
package/std/sys/file.yo
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
//
|
|
1
|
+
//! Async and sync file operations.
|
|
2
|
+
//!
|
|
3
|
+
//! Provides low-level file I/O wrappers around the C runtime externs.
|
|
4
|
+
//!
|
|
5
|
+
//! Async operations return `IOFuture` which resolves to:
|
|
6
|
+
//! - Positive value: success (fd for open, bytes for read/write, 0 for others)
|
|
7
|
+
//! - Negative value: -errno on failure
|
|
9
8
|
// Use IOError.from_result() to convert results to Result(i32, IOError).
|
|
10
9
|
//
|
|
11
10
|
// Example:
|
package/std/sys/future.yo
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
//
|
|
3
|
-
// Opaque handle to C async I/O future struct.
|
|
1
|
+
//! `IOFuture` type — opaque handle to a C async I/O future struct.
|
|
4
2
|
|
|
5
3
|
// ============================================================================
|
|
6
4
|
// Extern type for I/O Future
|
package/std/sys/iov.yo
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
//! Scatter/gather I/O.
|
|
2
|
+
//!
|
|
3
|
+
//! Synchronous wrappers for vectored file descriptor I/O.
|
|
4
|
+
//! Returns byte count on success, -errno / negative platform error on failure.
|
|
5
5
|
|
|
6
6
|
{
|
|
7
7
|
__yo_sync_readv,
|
package/std/sys/lock.yo
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
//! Advisory file locking.
|
|
2
|
+
//!
|
|
3
|
+
//! Synchronous wrapper for POSIX `flock()`.
|
|
4
|
+
//! Returns 0 on success, -errno on failure.
|
|
5
|
+
//!
|
|
6
|
+
//! Operations can be OR'd with `LOCK_NB` for non-blocking.
|
|
7
|
+
//! `LOCK_NB` returns -EWOULDBLOCK (-11) if the lock cannot be acquired immediately.
|
|
8
8
|
|
|
9
9
|
{ __yo_sync_flock } :: import "./externs.yo";
|
|
10
10
|
|
package/std/sys/mmap.yo
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
//
|
|
1
|
+
//! Memory-mapped I/O operations.
|
|
2
|
+
//!
|
|
3
|
+
//! Synchronous wrappers for `mmap`/`munmap`/`mprotect`/`msync`.
|
|
4
|
+
//!
|
|
5
|
+
//! `mmap` returns:
|
|
6
|
+
//! - Mapped pointer on success
|
|
7
|
+
//! - Encoded error pointer on failure (negative errno cast to pointer)
|
|
9
8
|
// Use is_error(ptr) and error_code(ptr) to detect/decode mmap failures.
|
|
10
9
|
|
|
11
10
|
{ platform, Platform } :: import "../process";
|
package/std/sys/path.yo
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
//
|
|
6
|
-
// Return values:
|
|
7
|
-
// - realpath: 0 on success, -errno on failure
|
|
1
|
+
//! Path resolution.
|
|
2
|
+
//!
|
|
3
|
+
//! Synchronous wrapper for `realpath`.
|
|
4
|
+
//! Returns 0 on success, -errno on failure.
|
|
8
5
|
|
|
9
6
|
{ __yo_sync_realpath } :: import "./externs.yo";
|
|
10
7
|
|
package/std/sys/perm.yo
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
//! File permission and access operations.
|
|
2
|
+
//!
|
|
3
|
+
//! Provides synchronous wrappers for `chmod`, `chown`, and `access` operations.
|
|
4
|
+
//! All operations return `i32` directly (no `IOFuture` overhead).
|
|
5
|
+
//!
|
|
6
|
+
//! Returns:
|
|
7
|
+
//! - 0: success
|
|
8
|
+
//! - Negative value: -errno on failure
|
|
9
9
|
//
|
|
10
10
|
// Example:
|
|
11
11
|
// perm :: import "std/sys/perm";
|