Skip to content

Commit

Permalink
internal: use native api in c_runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
Young-Flash committed Jan 22, 2025
1 parent 7068a68 commit 178288d
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 87 deletions.
8 changes: 2 additions & 6 deletions sync_io/moon.pkg.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,7 @@
"targets": {
"sync_io_wasm.mbt": ["wasm", "wasm-gc"],
"sync_io_js.mbt": ["js"],
"sync_io_native.mbt": ["native"]
},
"link": {
"native": {
"cc-flags": "./sync_io/native_stub.c"
}
"sync_io_native.mbt": ["native"],
"util.mbt": ["wasm", "wasm-gc"]
}
}
77 changes: 0 additions & 77 deletions sync_io/native_stub.c

This file was deleted.

2 changes: 1 addition & 1 deletion sync_io/sync_io.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// limitations under the License.

///|
type! IOError {
pub type! IOError {
NotFound(String)
}

Expand Down
6 changes: 3 additions & 3 deletions sync_io/sync_io_native.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ fn read_file_to_bytes_internal(path : String) -> Bytes! {
}

///|
extern "C" fn read_file_to_bytes_ffi(path : Bytes) -> Bytes = "read_file_to_bytes"
fn read_file_to_bytes_ffi(path : Bytes) -> Bytes = "$moonbit.read_file_to_bytes"

///|
fn write_bytes_to_file_internal(path : String, content : Bytes) -> Unit {
Expand All @@ -29,15 +29,15 @@ fn write_bytes_to_file_internal(path : String, content : Bytes) -> Unit {
}

///|
extern "C" fn write_bytes_to_file_ffi(path : Bytes, content : Bytes) = "write_bytes_to_file"
fn write_bytes_to_file_ffi(path : Bytes, content : Bytes) = "$moonbit.write_bytes_to_file"

///|
fn path_exists_internal(path : String) -> Bool {
path_exists_ffi(mbt_string_to_utf8_bytes(path, true)) == 0
}

///|
extern "C" fn path_exists_ffi(path : Bytes) -> Int = "path_exists"
fn path_exists_ffi(path : Bytes) -> Int = "$moonbit.path_exists"

///|
fn mbt_string_to_utf8_bytes(str : String, is_c_str : Bool) -> Bytes {
Expand Down

0 comments on commit 178288d

Please sign in to comment.