From 91870185a0ac86808b90ef286b077dba8ce54ac5 Mon Sep 17 00:00:00 2001 From: zrr1999 <2742392377@qq.com> Date: Mon, 13 Apr 2026 01:41:10 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix(platform):=20export=20module?= =?UTF-8?q?=20APIs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- src/basic_cli/cmd.sp | 4 ++-- src/basic_cli/dir.sp | 4 ++-- src/basic_cli/env.sp | 4 ++-- src/basic_cli/file.sp | 8 ++++---- src/basic_cli/stdin.sp | 2 +- src/basic_cli/stdout.sp | 8 ++++---- 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/basic_cli/cmd.sp b/src/basic_cli/cmd.sp index 1e9770f..cc23a68 100644 --- a/src/basic_cli/cmd.sp +++ b/src/basic_cli/cmd.sp @@ -4,7 +4,7 @@ /// Run a command and capture its stdout as a string. /// Returns the full stdout output on success. -foreign fn process_run(cmd: String, args: List[String]) -> String ! ExecError uses [Spawn] +pub foreign fn process_run(cmd: Str, args: List[Str]) -> Str ! ExecError uses [Spawn] /// Run a command and return its exit code. -foreign fn process_run_status(cmd: String, args: List[String]) -> Int ! ExecError uses [Spawn] +pub foreign fn process_run_status(cmd: Str, args: List[Str]) -> Int ! ExecError uses [Spawn] diff --git a/src/basic_cli/dir.sp b/src/basic_cli/dir.sp index e279873..22dc911 100644 --- a/src/basic_cli/dir.sp +++ b/src/basic_cli/dir.sp @@ -1,7 +1,7 @@ /// basic-cli platform — Directory operations /// List entries in a directory, returning their names. -foreign fn dir_list(path: String) -> List[String] ! IoError uses [FileRead] +pub foreign fn dir_list(path: Str) -> List[Str] ! IoError uses [FileRead] /// Create a directory (and any missing parents). -foreign fn dir_mkdir(path: String) -> Unit ! IoError uses [FileWrite] +pub foreign fn dir_mkdir(path: Str) -> () ! IoError uses [FileWrite] diff --git a/src/basic_cli/env.sp b/src/basic_cli/env.sp index 22a6bb2..72f16ff 100644 --- a/src/basic_cli/env.sp +++ b/src/basic_cli/env.sp @@ -1,7 +1,7 @@ /// basic-cli platform — Environment variable access /// Get the value of an environment variable, or None if not set. -foreign fn env_get(key: String) -> Option[String] uses [Env] +pub foreign fn env_get(key: Str) -> Option[Str] uses [Env] /// Set an environment variable. -foreign fn env_set(key: String, value: String) -> Unit uses [Env] +pub foreign fn env_set(key: Str, value: Str) -> () uses [Env] diff --git a/src/basic_cli/file.sp b/src/basic_cli/file.sp index 0d40000..cea3eb8 100644 --- a/src/basic_cli/file.sp +++ b/src/basic_cli/file.sp @@ -3,13 +3,13 @@ /// Provides capability-gated file read and write operations. /// Read the entire contents of a file as a string. -foreign fn file_read(path: String) -> String ! IoError uses [FileRead] +pub foreign fn file_read(path: Str) -> Str ! IoError uses [FileRead] /// Write content to a file, creating or overwriting it. -foreign fn file_write(path: String, content: String) -> Unit ! IoError uses [FileWrite] +pub foreign fn file_write(path: Str, content: Str) -> () ! IoError uses [FileWrite] /// Check whether a file or directory exists at the given path. -foreign fn file_exists(path: String) -> Bool uses [FileRead] +pub foreign fn file_exists(path: Str) -> Bool uses [FileRead] /// Get file metadata (size, modified time, etc.) as a string representation. -foreign fn file_stat(path: String) -> String ! IoError uses [FileRead] +pub foreign fn file_stat(path: Str) -> Str ! IoError uses [FileRead] diff --git a/src/basic_cli/stdin.sp b/src/basic_cli/stdin.sp index 7e86f64..1802154 100644 --- a/src/basic_cli/stdin.sp +++ b/src/basic_cli/stdin.sp @@ -1,4 +1,4 @@ /// basic-cli platform — Standard input operations /// Read a line from stdin (blocks until newline). -foreign fn read_line() -> String uses [Console] +pub foreign fn read_line() -> Str ! IoError uses [Console] diff --git a/src/basic_cli/stdout.sp b/src/basic_cli/stdout.sp index 3c1b05b..99308a1 100644 --- a/src/basic_cli/stdout.sp +++ b/src/basic_cli/stdout.sp @@ -3,13 +3,13 @@ /// Provides capability-gated access to stdout/stderr. /// Print a string to stdout without trailing newline. -foreign fn print(s: String) -> Unit uses [Console] +pub foreign fn print(s: Str) -> () ! IoError uses [Console] /// Print a string to stdout with trailing newline. -foreign fn println(s: String) -> Unit uses [Console] +pub foreign fn println(s: Str) -> () uses [Console] /// Print a formatted string to stderr. -foreign fn eprint(s: String) -> Unit uses [Console] +pub foreign fn eprint(s: Str) -> () ! IoError uses [Console] /// Print a formatted string to stderr with trailing newline. -foreign fn eprintln(s: String) -> Unit uses [Console] +pub foreign fn eprintln(s: Str) -> () uses [Console]